import { type ConnectionAuth, type DisplayProperty, type EventFilter, type HandleTriggerSource, type HttpSourceResponseMetadata, type NormalizedResponse, type Prettify, type RegisterTriggerSource, type SendEvent, type SerializableJson, type TriggerMetadata } from "@systemfsoftware/trigger.dev_core-v2"; import { Logger } from "@systemfsoftware/trigger.dev_core-backend"; import type { Buffer } from "buffer"; 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 } from "../types.js"; export type HttpSourceEvent = { url: string; method: string; headers: Record; rawBody?: Buffer | null; }; type SmtpSourceEvent = { from: string; to: string; subject: string; body: string; }; type SqsSourceEvent = { body: string; }; type ExternalSourceChannelMap = { HTTP: { event: Request; register: { url: string; }; }; SMTP: { event: SmtpSourceEvent; register: {}; }; SQS: { event: SqsSourceEvent; register: {}; }; }; type ChannelNames = keyof ExternalSourceChannelMap; type TriggerOptionDiff = { desired: string[]; missing: string[]; orphaned: string[]; }; type TriggerOptionDiffs = any> = TriggerOptionsRecordWithEvent; type TriggerOptionsRecordWithEvent> = { event: TValue; } & TriggerOptionRecord; export type TriggerOptionRecord = any> = { [K in keyof TTriggerOptionDefinitions]: TValue; }; type RegisterFunctionEvent = any> = { options: TriggerOptionDiffs; source: { active: boolean; data?: any; secret: string; } & ExternalSourceChannelMap[TChannel]["register"]; params: TParams; }; type RegisterSourceEvent = any> = { id: string; source: RegisterTriggerSource; dynamicTriggerId?: string; options: TriggerOptionDiffs; }; type RegisterFunctionOutput = any> = { secret?: string; data?: SerializableJson; options: TriggerOptionsRecordWithEvent; }; type RegisterFunction = any> = (event: RegisterFunctionEvent, io: IOWithIntegrations<{ integration: TIntegration; }>, ctx: TriggerContext) => Promise | undefined>; export type HandlerEvent = { rawEvent: ExternalSourceChannelMap[TChannel]["event"]; source: Prettify & { params: TParams; }>; }; type HandlerFunction = (event: HandlerEvent, logger: Logger, integration: TTriggerIntegration, auth?: ConnectionAuth) => Promise<{ events: SendEvent[]; response?: NormalizedResponse; metadata?: HttpSourceResponseMetadata; } | void>; type KeyFunction = (params: TParams) => string; type FilterFunction = any> = (params: TParams, options?: TTriggerOptionDefinitions) => EventFilter; type ExternalSourceOptions = any> = { id: string; version: string; schema: SchemaParser; optionSchema?: SchemaParser; integration: TIntegration; register: RegisterFunction; filter?: FilterFunction; handler: HandlerFunction; key: KeyFunction; properties?: (params: TParams) => DisplayProperty[]; }; export declare class ExternalSource = any> { private options; channel: TChannel; constructor(channel: TChannel, options: ExternalSourceOptions); handle(source: HandleTriggerSource, rawEvent: ExternalSourceChannelMap[TChannel]["event"], logger: Logger): Promise; filter(params: TParams, options?: TTriggerOptionDefinitions): EventFilter; properties(params: TParams): DisplayProperty[]; register(params: TParams, registerEvent: RegisterSourceEvent, io: IO, ctx: TriggerContext): Promise | undefined>; 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 ExternalSourceParams> = TExternalSource extends ExternalSource ? TParams : never; export type ExternalSourceTriggerOptions, TEventSource extends ExternalSource, TTriggerOptionDefinitions extends Record = any> = { event: TEventSpecification; source: TEventSource; params: ExternalSourceParams; options: TriggerOptionRecord; }; export declare class ExternalSourceTrigger, TEventSource extends ExternalSource> implements Trigger { private options; constructor(options: ExternalSourceTriggerOptions); get event(): TEventSpecification; toJSON(): TriggerMetadata; attachToJob(triggerClient: TriggerClient, job: Job, any>): void; get preprocessRuns(): boolean; verifyPayload(payload: ReturnType): Promise<{ success: true; }>; } export declare function omit, K extends keyof T>(obj: T, key: K): { result: Omit; ommited: T[K]; }; export {}; //# sourceMappingURL=externalSource.d.ts.map