/** * Event sources in the product's words: what each kind is, where its events * come from, its status, and its deliveries. Pure; text comes from the host's * message catalog through the `t` each function takes first. */ import type { CreateEventSourceRequest, EventActor, EventDelivery, EventSource, WebhookEventAdapter } from "@opengeni/sdk"; import type { OpenGeniText } from "../../messages/runtime.js"; import type { ProductStatus } from "../../ui/status-badge.js"; /** What a person picks when adding a source. One per kind and webhook adapter. */ export type EventSourceChoice = "webhook" | "linear" | "sentry" | "tailscale" | "github" | "slack" | "gmail" | "mcp" | "workspace"; export interface EventSourceChoiceMeta { choice: EventSourceChoice; /** "GitHub", "Linear", "Your own app". */ name: string; /** One sentence: what arrives and how it connects. */ description: string; /** For the brand logo, when the host has one. */ providerDomain: string | null; /** How it connects: Opengeni sets it up, or a person pastes a URL and secret. */ setup: "automatic" | "paste"; /** Who can see it and its events. */ audience: "workspace" | "personal" | "choice"; } /** The choice's name: the app's own name, or what the kind is called. */ export declare function eventSourceChoiceName(t: OpenGeniText, choice: EventSourceChoice): string; export declare function eventSourceChoiceMeta(t: OpenGeniText, choice: EventSourceChoice): EventSourceChoiceMeta; /** Every kind of source a person can add, in the order to offer them. */ export declare function eventSourceChoices(t: OpenGeniText): EventSourceChoiceMeta[]; /** True for a known choice, for example a `?kind=` link parameter. */ export declare function isEventSourceChoice(value: unknown): value is EventSourceChoice; /** The facts about a source that say which choice it is. */ export type EventSourceChoiceSubject = Pick & { format?: { preset?: string | undefined; signature?: { scheme: string; parameter?: string | undefined; } | undefined; } | null | undefined; }; /** * The choice a source is: its kind, its app for a custom webhook made with an * app's preset (or a server's older `linear` or `sentry` adapter), else a * webhook. */ export declare function eventSourceChoiceOf(source: EventSourceChoiceSubject): EventSourceChoice; export declare const WEBHOOK_ADAPTER_OF: Partial>; /** A stand-in source of the chosen kind, for its tile before one exists. */ export declare function eventSourceSubjectOfChoice(t: OpenGeniText, choice: EventSourceChoice): Pick & { format: { preset: string; } | null; }; /** What adding one is called: "Add GitHub", "Add a webhook". */ export declare function eventSourceAddLabel(t: OpenGeniText, choice: EventSourceChoice): string; /** * "GitHub", "Linear webhook", "Webhook", "MCP server", "Workspace events": the * kind, not the name. */ export declare function eventSourceKindLabel(t: OpenGeniText, source: EventSourceChoiceSubject): string; /** The domain whose logo stands for the source, when it has one. */ export declare function eventSourceProviderDomain(source: EventSourceChoiceSubject): string | null; /** * Why a source or trigger is held back, or why a source can't send an event * type, as the server reported it: a code, the same reason as an English * sentence, and what the app or server said, when it said something. */ export interface EventStatusReasonParts { /** The server's sentence, shown when the code is missing or unknown here. */ text: string | null; code?: string | null | undefined; detail?: string | null | undefined; } /** * A held-back reason in the viewer's language. Known codes are worded from * the catalog, naming the source when `sourceName` is given; anything else, * such as a code from a newer server, shows the server's sentence. */ export declare function eventStatusReasonText(t: OpenGeniText, reason: EventStatusReasonParts, sourceName?: string | null): string | null; /** * The badge a source's or trigger's row shows; a healthy one shows none. * `sourceName` names the source in the reason; a source's own name is used * when the item is a source. */ export declare function eventSourceStatusBadge(t: OpenGeniText, item: Pick & Partial>, sourceName?: string | null): { status: ProductStatus; label: string; reason: string | null; } | null; /** How a pasted webhook is connected: the app gets the URL, Opengeni gets its secret. */ export interface PastedWebhookSetup { /** "Linear". */ app: string; /** What the app calls the secret: "signing secret", "client secret". */ secretName: string; /** Where to paste the URL in the app, in one sentence. */ urlStep: string; /** Where the app shows the secret, in one sentence. */ secretStep: string; } export declare function pastedWebhookSetup(t: OpenGeniText, source: EventSourceChoiceSubject): PastedWebhookSetup | null; /** The request that adds a source of the chosen kind; an unnamed webhook takes the kind's name. */ export declare function createEventSourceRequest(t: OpenGeniText, input: { choice: EventSourceChoice; name: string; visibility: "private" | "workspace"; signingSecret?: string | undefined; mcpServerId?: string | undefined; connectionId?: string | undefined; }): CreateEventSourceRequest; /** What became of a delivery, as its badge. */ export declare function eventDeliveryStatusBadge(t: OpenGeniText, status: EventDelivery["status"]): { status: ProductStatus; label: string; }; /** "3 events", "No events", "1 event". */ export declare function deliveryEventsLabel(t: OpenGeniText, delivery: Pick): string; /** * What a delivery became, as its row's title: "pull_request.opened", * "issues.opened and issue_comment.created", "push and 2 more", or the count * when the server does not say which types. */ export declare function deliveryTitle(t: OpenGeniText, delivery: Pick & { eventTypes?: readonly string[] | undefined; }): string; /** "1.2 KB", with the host locale's decimal separator. */ export declare function byteSizeLabel(t: OpenGeniText, bytes: number): string; /** Who caused an event, in words; null when unknown. */ export declare function eventActorLabel(t: OpenGeniText, actor: EventActor): string | null;