import { type DisplayProperty, type EventFilter, type HandleTriggerSource, type RegisterWebhookSource, type TriggerMetadata } from "@systemfsoftware/trigger.dev_core-v2"; import type { IOWithIntegrations, TriggerIntegration } from "../integrations.js"; import { IO } from "../io.js"; import { Job } from "../job.js"; import { TriggerClient } from "../triggerClient.js"; import type { EventSpecification, SchemaParser, Trigger, TriggerContext, VerifyResult } from "../types.js"; import type { SerializableJson } from "@systemfsoftware/trigger.dev_core-v2"; import type { Prettify } from "@systemfsoftware/trigger.dev_core-v2"; type WebhookCRUDContext> = { active: boolean; params: TParams; config: { current: Partial; desired: TConfig; }; url: string; secret: string; }; type WebhookCRUDFunction> = (options: { io: IOWithIntegrations<{ integration: TIntegration; }>; ctx: WebhookCRUDContext; }) => Promise; interface WebhookCRUD> { create: WebhookCRUDFunction; read?: WebhookCRUDFunction; update?: WebhookCRUDFunction; delete: WebhookCRUDFunction; } export type WebhookConfig = { [K in TConfigKeys]: string[]; }; type RegisterFunctionEvent> = { source: { active: boolean; data?: any; secret: string; url: string; }; params: TParams; config: TConfig; }; type WebhookRegisterEvent> = { id: string; source: RegisterWebhookSource; dynamicTriggerId?: string; config: TConfig; }; type RegisterFunctionOutput> = { secret?: string; data?: SerializableJson; config: TConfig; }; type RegisterFunction> = (event: RegisterFunctionEvent, io: IOWithIntegrations<{ integration: TIntegration; }>, ctx: TriggerContext) => Promise | undefined>; export type WebhookHandlerEvent = { rawEvent: Request; source: Prettify & { params: TParams; }>; }; export type WebhookDeliveryContext = { key: string; secret: string; params: any; }; type EventGenerator, TIntegration extends TriggerIntegration> = (options: { request: Request; client: TriggerClient; ctx: WebhookDeliveryContext; }) => Promise; type KeyFunction = (params: TParams) => string; type FilterFunction> = (params: TParams, config?: TConfig) => EventFilter; type WebhookOptions> = { id: string; version: string; integration: TIntegration; schemas: { params: SchemaParser; config?: SchemaParser; }; key: KeyFunction; crud: WebhookCRUD; filter?: FilterFunction; register?: RegisterFunction; verify?: (options: { request: Request; client: TriggerClient; ctx: WebhookDeliveryContext; }) => Promise; generateEvents: EventGenerator; properties?: (params: TParams) => DisplayProperty[]; }; export declare class WebhookSource = Record> { #private; private options; constructor(options: WebhookOptions); generateEvents(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext): Promise; filter(params: TParams, config?: TConfig): EventFilter; properties(params: TParams): DisplayProperty[]; get crud(): WebhookCRUD; register(params: TParams, registerEvent: WebhookRegisterEvent, io: IO, ctx: TriggerContext): Promise | undefined>; verify(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext): Promise; key(params: TParams): string; get integration(): TIntegration; get integrationConfig(): { id: string; metadata: { name: string; id: string; instructions?: string | undefined; }; }; get id(): string; get version(): string; } export type GetWebhookParams> = TWebhook extends WebhookSource ? TParams : never; export type GetWebhookConfig> = TWebhook extends WebhookSource ? TConfig : never; export type WebhookTriggerOptions, TEventSource extends WebhookSource, TConfig extends Record = Record> = { event: TEventSpecification; source: TEventSource; params: GetWebhookParams; config: TConfig; }; export declare class WebhookTrigger, TEventSource extends WebhookSource> implements Trigger { private options; constructor(options: WebhookTriggerOptions); get event(): TEventSpecification; get source(): TEventSource; get key(): string; toJSON(): TriggerMetadata; filter(eventFilter: EventFilter): WebhookTrigger & { filter: EventFilter; }, TEventSource>; attachToJob(triggerClient: TriggerClient, job: Job, any>): void; get preprocessRuns(): boolean; verifyPayload(payload: ReturnType): Promise<{ success: true; }>; } export {}; //# sourceMappingURL=webhook.d.ts.map