54 lines · 2.0 KB
export const INTEGRATION_KINDS = ["slack", "google_chat", "linear", "github", "webhook"] as const;
export type IntegrationKind = (typeof INTEGRATION_KINDS)[number];

export const INTEGRATION_KIND_LABELS: Record<IntegrationKind, string> = {
  slack: "Slack",
  google_chat: "Google Chat",
  linear: "Linear",
  github: "GitHub",
  webhook: "Webhook",
};

/** Event categories an integration can subscribe to. Chat integrations start quiet: only PRs and releases. */
export const INTEGRATION_EVENTS = ["push", "pull_request", "review", "ci", "release", "issues", "github"] as const;
export type IntegrationEvent = (typeof INTEGRATION_EVENTS)[number];

export const INTEGRATION_EVENT_LABELS: Record<IntegrationEvent, string> = {
  push: "Pushes",
  pull_request: "Pull requests (opened, merged, closed)",
  review: "Reviews",
  ci: "CI runs",
  release: "Releases",
  issues: "Issues",
  github: "Relayed GitHub webhooks",
};

export const DEFAULT_INTEGRATION_EVENTS: IntegrationEvent[] = ["pull_request", "release"];

/** Non-secret, per-integration routing and noise controls. */
export type IntegrationFilters = {
  /** Glob-ish branch filter for pushes and CI (`main`, `release/*`); empty means the default branch only. */
  branches: string[];
  /** Only report failed CI runs (and the first green run after a failure is not tracked). */
  ciFailuresOnly: boolean;
  /** Skip draft pull requests. */
  skipDrafts: boolean;
  /** Skip events from bot-like actors (names ending in `[bot]` or `-bot`). */
  skipBots: boolean;
};

export const DEFAULT_FILTERS: IntegrationFilters = {