import { c as InferCredentialSetAuth, p as Primitive, s as CredentialSetId, t as AnyCredentialSet } from "./CredentialSet-lUr_8nN3.mjs"; import { c as AnyZodSchema, h as Simplify, l as InferSchema, m as JsonValue, p as JsonObject, t as CredentialSetManifest } from "./schemas-DXcT2SRm.mjs"; import { c as ExecutionIdentityPolicy } from "./credential-requirements-PoSYqj0L.mjs"; import { z } from "zod"; //#region src/shared/duration.d.ts type Duration = number | `${number}s` | `${number}m` | `${number}h` | `${number}d` | `${number}w` | `${number}y`; declare const DurationSchema: z.ZodType; /** * Convert a {@link Duration} value into milliseconds. * * Accepts the full Duration union: a positive integer (treated as ms) * or a string like "5s", "2m", "1h", "1d", "1w", "1y". */ declare function parseDurationToMs(duration: Duration): number; //#endregion //#region src/shared/schedule.d.ts type CronField = `${number}` | '*' | `${number}-${number}` | `*/${number}` | `${number}/${number}` | `${number}-${number}/${number}` | `${number},${number}` | `${number},${number},${string}`; type CronExpression = `${CronField} ${CronField} ${CronField} ${CronField} ${CronField}`; type Schedule = Duration | CronExpression; declare const ScheduleSchema: z.ZodType; declare const IANATimezoneSchema: z.ZodEnum<{ UTC: "UTC"; GMT: "GMT"; "Etc/UTC": "Etc/UTC"; "Etc/GMT": "Etc/GMT"; "America/New_York": "America/New_York"; "America/Chicago": "America/Chicago"; "America/Denver": "America/Denver"; "America/Los_Angeles": "America/Los_Angeles"; "America/Phoenix": "America/Phoenix"; "America/Anchorage": "America/Anchorage"; "America/Toronto": "America/Toronto"; "America/Vancouver": "America/Vancouver"; "America/Mexico_City": "America/Mexico_City"; "America/Sao_Paulo": "America/Sao_Paulo"; "America/Buenos_Aires": "America/Buenos_Aires"; "Europe/London": "Europe/London"; "Europe/Paris": "Europe/Paris"; "Europe/Berlin": "Europe/Berlin"; "Europe/Rome": "Europe/Rome"; "Europe/Madrid": "Europe/Madrid"; "Europe/Amsterdam": "Europe/Amsterdam"; "Europe/Stockholm": "Europe/Stockholm"; "Europe/Vienna": "Europe/Vienna"; "Europe/Zurich": "Europe/Zurich"; "Europe/Moscow": "Europe/Moscow"; "Europe/Athens": "Europe/Athens"; "Europe/Dublin": "Europe/Dublin"; "Asia/Tokyo": "Asia/Tokyo"; "Asia/Shanghai": "Asia/Shanghai"; "Asia/Hong_Kong": "Asia/Hong_Kong"; "Asia/Singapore": "Asia/Singapore"; "Asia/Seoul": "Asia/Seoul"; "Asia/Dubai": "Asia/Dubai"; "Asia/Kolkata": "Asia/Kolkata"; "Asia/Bangkok": "Asia/Bangkok"; "Asia/Jakarta": "Asia/Jakarta"; "Asia/Manila": "Asia/Manila"; "Asia/Taipei": "Asia/Taipei"; "Australia/Sydney": "Australia/Sydney"; "Australia/Melbourne": "Australia/Melbourne"; "Australia/Brisbane": "Australia/Brisbane"; "Australia/Perth": "Australia/Perth"; "Australia/Adelaide": "Australia/Adelaide"; "Pacific/Auckland": "Pacific/Auckland"; "Pacific/Honolulu": "Pacific/Honolulu"; "Africa/Cairo": "Africa/Cairo"; "Africa/Johannesburg": "Africa/Johannesburg"; "Africa/Lagos": "Africa/Lagos"; "Africa/Nairobi": "Africa/Nairobi"; "Asia/Riyadh": "Asia/Riyadh"; "Asia/Tehran": "Asia/Tehran"; "Asia/Jerusalem": "Asia/Jerusalem"; "Asia/Doha": "Asia/Doha"; }>; type IANATimezone = z.infer; /** * Calculate the next run time from a schedule. * For duration/number: adds interval to current time. * For cron: calculates next occurrence, respecting timezone if provided. */ declare function calculateNextRunAt(schedule: Schedule, now: Date, timezone?: string): string; //#endregion //#region src/trigger/shared/idempotency-config.d.ts declare const idempotencyKeyConfigSchema: z.ZodUnion; strategy: z.ZodLiteral<"hash">; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"payload">; path: z.ZodString; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"header">; strategy: z.ZodLiteral<"hash">; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"header">; name: z.ZodString; }, z.core.$strip>]>; type IdempotencyKeyConfig = z.infer; declare function resolveIdempotencyKey(params: { config: IdempotencyKeyConfig | null | undefined; payload: unknown; headers?: Record; }): string | undefined; //#endregion //#region src/trigger/types.d.ts type CredentialNamespace> = InferCredentialSetAuth>; type TriggerType = 'cron' | 'polling' | 'webhook'; type TriggerModeDefault = 'managed' | 'subscribable'; type TriggerRuntimeDescriptor = Readonly<{ /** True when this trigger bundles a `poll` export executed in a VM. Polling only. */poll?: boolean; filterSchema?: JsonObject; /** Webhook-only declarative idempotency-key resolver. */ idempotencyConfig?: IdempotencyKeyConfig; }>; type TriggerManifest = Readonly<{ manifestVersion: 1; type: 'trigger'; triggerType: TTriggerType; id: string; description: string; enabled: boolean; modeDefault: TriggerModeDefault; executionIdentityPolicy?: ExecutionIdentityPolicy; credentialSets?: readonly CredentialSetManifest[]; runtime: TRuntime; }>; interface TriggerBaseConfig { readonly credentialSets?: TCredentialSets; readonly description: string; readonly enabled?: boolean; readonly executionIdentityPolicy?: ExecutionIdentityPolicy; readonly modeDefault?: TriggerModeDefault; readonly id: string; } type TriggerCredentials = TCredentialSets extends readonly AnyCredentialSet[] ? Simplify<{ readonly [TCredentialId in CredentialSetId]: CredentialNamespace }> : Record; type TriggerCredentialContext = Readonly<{ credentials: Readonly>; triggerId: string; triggerType: TriggerType; }>; type AnyTrigger = TriggerInstance; /** * The trigger object shape — everything the old Trigger class exposed, * plus .narrow() and callable behavior. * * TRequest is the typed request context available in transform callbacks * when binding a trigger to a workflow (e.g. WebhookRequest for webhook triggers). */ interface TriggerInstance { readonly isTrigger: true; readonly id: string; readonly description: string; readonly enabled: boolean; readonly modeDefault: TriggerModeDefault; readonly executionIdentityPolicy?: ExecutionIdentityPolicy; readonly credentialSets: TCredentialSets; readonly filter?: AnyZodSchema; readonly idempotencyKey?: IdempotencyKeyConfig; toManifest(): TManifest & { narrowedFrom?: string; lineage?: readonly string[]; }; narrow(config: NarrowConfig): CallableTrigger; } /** * A callable trigger object. It IS a trigger (has name, toManifest, etc.) * and is also callable — calling it with { transform?, filter? } returns a BoundTrigger. */ type CallableTrigger = TriggerInstance & ((opts?: TriggerBindOptions) => BoundTrigger); interface NarrowConfig<_TPayload> { readonly id: string; readonly description?: string; readonly filter?: AnyZodSchema; } /** * Options when calling a trigger to create a workflow binding. * Only `transform` is supported. Filtering happens on the trigger itself * (or via `.narrow()`); attachment-side filters are intentionally absent. */ interface TriggerBindOptions { readonly transform?: (payload: TPayload, request?: TRequest) => TOutput | Promise; } /** * A trigger that has been bound with an optional transform for use in a * Workflow's triggers array. */ interface BoundTrigger { readonly isBoundTrigger: true; readonly trigger: TriggerInstance; readonly transform?: (payload: TPayload, request?: TRequest) => TOutput | Promise; } type ValidTriggerEntry = TriggerInstance | BoundTrigger; /** Union type for Workflow's triggers array */ type TriggerEntry = TriggerInstance | BoundTrigger; //#endregion //#region src/trigger/base/Trigger.d.ts declare abstract class Trigger extends Primitive { #private; readonly kind: "trigger"; readonly credentialSets: TCredentialSets; readonly description: string; readonly enabled: boolean; readonly executionIdentityPolicy?: TManifest['executionIdentityPolicy']; readonly modeDefault: TManifest['modeDefault']; readonly id: string; protected constructor(config: TriggerBaseConfig, manifest: TManifest); toManifest(): TManifest; getCredentialRequirements(): { credentialSetId: string; credentialType: "oauth" | "manual"; credentialKeys: string[]; optionalCredentialKeys?: string[] | undefined; storedCredentialKeys?: string[] | undefined; optionalStoredCredentialKeys?: string[] | undefined; schemaFingerprint?: string | undefined; needsDynamicResolution?: boolean | undefined; dynamicResolutionCacheMs?: number | undefined; onCredentialRevoked?: "fail" | "retry-once" | undefined; proxy?: { hosts?: string[] | undefined; hostPatterns?: string[] | undefined; injection?: { headers?: boolean | undefined; basicAuth?: boolean | undefined; queryParams?: boolean | undefined; body?: boolean | undefined; } | undefined; } | undefined; needsRawSecret?: boolean | undefined; requiredOAuthScopes?: string[] | undefined; }[]; protected finalize(): void; } //#endregion //#region src/shared/schema.d.ts declare function schemaToJsonSchema(schema: AnyZodSchema): JsonObject; //#endregion //#region src/trigger/cron/types.d.ts type CronTriggerRuntime = TriggerRuntimeDescriptor & Readonly<{ input: ReturnType; payloadMode: 'static'; schedule: string; timezone?: string; }>; type CronTriggerManifest = TriggerManifest<'cron', CronTriggerRuntime> & { /** Static payload for cron triggers — the workflow input when this trigger fires */readonly payload?: JsonValue; }; interface CronTriggerConfig extends TriggerBaseConfig { readonly input: TInputSchema; readonly payload: z.input & JsonValue; readonly schedule: Schedule; readonly timezone?: IANATimezone; } //#endregion //#region src/trigger/cron/CronTrigger.d.ts /** * Creates a callable cron trigger. * Cron triggers have static payloads — no filter, idempotencyKey, or transform. */ declare function cronTrigger(config: CronTriggerConfig): CallableTrigger, TCredentialSets, CronTriggerManifest> & { readonly input: TInputSchema; readonly payload: InferSchema & JsonValue; readonly schedule: Schedule; readonly timezone?: IANATimezone; }; declare class CronTrigger extends Trigger { readonly input: TInputSchema; readonly payload: InferSchema & JsonValue; readonly schedule: Schedule; readonly timezone?: IANATimezone; constructor(config: CronTriggerConfig); } //#endregion //#region src/trigger/cron/schemas.d.ts declare const cronTriggerManifestSchema: z.ZodObject<{ manifestVersion: z.ZodLiteral<1>; type: z.ZodLiteral<"trigger">; triggerType: z.ZodLiteral<"cron">; id: z.ZodString; description: z.ZodString; enabled: z.ZodBoolean; modeDefault: z.ZodEnum<{ managed: "managed"; subscribable: "subscribable"; }>; executionIdentityPolicy: z.ZodOptional; }, z.core.$strip>>; credentialSets: z.ZodOptional; type: z.ZodLiteral<"credentialSet">; id: z.ZodString; name: z.ZodString; description: z.ZodOptional; auth: z.ZodType>; credentialType: z.ZodEnum<{ oauth: "oauth"; manual: "manual"; }>; exposure: z.ZodOptional>; proxy: z.ZodOptional>; hostPatterns: z.ZodOptional>; injection: z.ZodOptional; basicAuth: z.ZodOptional; queryParams: z.ZodOptional; body: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>>; needsRawSecret: z.ZodOptional; }, z.core.$strip>>>; runtime: z.ZodObject<{ poll: z.ZodOptional; filterSchema: z.ZodOptional>>; idempotencyConfig: z.ZodOptional; strategy: z.ZodLiteral<"hash">; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"payload">; path: z.ZodString; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"header">; strategy: z.ZodLiteral<"hash">; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"header">; name: z.ZodString; }, z.core.$strip>]>>; input: z.ZodType>; payloadMode: z.ZodLiteral<"static">; schedule: z.ZodString; timezone: z.ZodOptional; }, z.core.$strip>; payload: z.ZodOptional>>; }, z.core.$strip>; //#endregion //#region src/trigger/polling/types.d.ts type PollingState = Readonly<{ lastPolledAt?: string; lastResponse?: TResponse; }>; type PollingContext = TriggerCredentialContext & PollingState>; type PollingFn = (ctx: PollingContext) => z.input | Promise>; type PollingTriggerRuntime = TriggerRuntimeDescriptor & Readonly<{ response: ReturnType; schedule: string; state: { lastPolledAt: true; lastResponse: true; }; }>; type PollingTriggerManifest = TriggerManifest<'polling', PollingTriggerRuntime>; interface PollingTriggerConfig extends TriggerBaseConfig { readonly poll: PollingFn; readonly filter?: AnyZodSchema; readonly response: TResponseSchema; readonly schedule: Schedule; } //#endregion //#region src/trigger/polling/PollingTrigger.d.ts /** * Creates a callable polling trigger. */ declare function pollingTrigger(config: PollingTriggerConfig): CallableTrigger, TCredentialSets, PollingTriggerManifest> & { readonly poll: PollingFn; readonly response: TResponseSchema; readonly schedule: Schedule; parseResponse(response: unknown): InferSchema; }; declare class PollingTrigger extends Trigger { readonly poll: PollingFn; readonly filter?: AnyZodSchema; readonly response: TResponseSchema; readonly schedule: Schedule; constructor(config: PollingTriggerConfig); parseResponse(response: unknown): InferSchema; } //#endregion //#region src/trigger/polling/schemas.d.ts declare const pollingTriggerManifestSchema: z.ZodObject<{ manifestVersion: z.ZodLiteral<1>; type: z.ZodLiteral<"trigger">; triggerType: z.ZodLiteral<"polling">; id: z.ZodString; description: z.ZodString; enabled: z.ZodBoolean; modeDefault: z.ZodEnum<{ managed: "managed"; subscribable: "subscribable"; }>; executionIdentityPolicy: z.ZodOptional; }, z.core.$strip>>; credentialSets: z.ZodOptional; type: z.ZodLiteral<"credentialSet">; id: z.ZodString; name: z.ZodString; description: z.ZodOptional; auth: z.ZodType>; credentialType: z.ZodEnum<{ oauth: "oauth"; manual: "manual"; }>; exposure: z.ZodOptional>; proxy: z.ZodOptional>; hostPatterns: z.ZodOptional>; injection: z.ZodOptional; basicAuth: z.ZodOptional; queryParams: z.ZodOptional; body: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>>; needsRawSecret: z.ZodOptional; }, z.core.$strip>>>; runtime: z.ZodObject<{ poll: z.ZodOptional; filterSchema: z.ZodOptional>>; idempotencyConfig: z.ZodOptional; strategy: z.ZodLiteral<"hash">; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"payload">; path: z.ZodString; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"header">; strategy: z.ZodLiteral<"hash">; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"header">; name: z.ZodString; }, z.core.$strip>]>>; response: z.ZodType>; schedule: z.ZodString; state: z.ZodObject<{ lastPolledAt: z.ZodLiteral; lastResponse: z.ZodLiteral; }, z.core.$strip>; }, z.core.$strip>; }, z.core.$strip>; //#endregion //#region src/trigger/webhook/schemas.d.ts declare const WebhookRequestSchema: z.ZodObject<{ method: z.ZodString; path: z.ZodString; query: z.ZodRecord, z.ZodUndefined]>>; headers: z.ZodRecord>; rawBody: z.ZodString; }, z.core.$strip>; declare const WebhookSourceManifestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"custom">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"app">; appRef: z.ZodString; }, z.core.$strip>], "type">; declare const webhookTriggerManifestSchema: z.ZodObject<{ manifestVersion: z.ZodLiteral<1>; type: z.ZodLiteral<"trigger">; triggerType: z.ZodLiteral<"webhook">; id: z.ZodString; description: z.ZodString; enabled: z.ZodBoolean; modeDefault: z.ZodEnum<{ managed: "managed"; subscribable: "subscribable"; }>; executionIdentityPolicy: z.ZodOptional; }, z.core.$strip>>; credentialSets: z.ZodOptional; type: z.ZodLiteral<"credentialSet">; id: z.ZodString; name: z.ZodString; description: z.ZodOptional; auth: z.ZodType>; credentialType: z.ZodEnum<{ oauth: "oauth"; manual: "manual"; }>; exposure: z.ZodOptional>; proxy: z.ZodOptional>; hostPatterns: z.ZodOptional>; injection: z.ZodOptional; basicAuth: z.ZodOptional; queryParams: z.ZodOptional; body: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>>; needsRawSecret: z.ZodOptional; }, z.core.$strip>>>; runtime: z.ZodObject<{ poll: z.ZodOptional; filterSchema: z.ZodOptional>>; idempotencyConfig: z.ZodOptional; strategy: z.ZodLiteral<"hash">; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"payload">; path: z.ZodString; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"header">; strategy: z.ZodLiteral<"hash">; }, z.core.$strip>, z.ZodObject<{ from: z.ZodLiteral<"header">; name: z.ZodString; }, z.core.$strip>]>>; source: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"custom">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"app">; appRef: z.ZodString; }, z.core.$strip>], "type">; payload: z.ZodType>; }, z.core.$strip>; }, z.core.$strip>; //#endregion //#region src/trigger/webhook/types.d.ts type WebhookRequest = z.infer; /** * `custom` source: the platform owns the HTTP surface and authenticates * requests with a Keystroke-issued secret. Authors declare nothing else — * the secret + publicId are issued at deploy time and the platform always * replies `202 { received }`. */ interface WebhookCustomSource { readonly type: 'custom'; } /** * `app` source: the trigger is fanned out by a Keystroke-managed platform * app endpoint (Slack, GitHub, Linear, ...). Verification happens centrally * using app-level secrets; there is no per-activation HTTP surface. */ interface WebhookAppSource { readonly type: 'app'; readonly appRef: string; } type WebhookSource = WebhookCustomSource | WebhookAppSource; type WebhookSourceManifest = z.infer; type WebhookTriggerRuntime = TriggerRuntimeDescriptor & Readonly<{ source: WebhookSourceManifest; payload: ReturnType; }>; type WebhookTriggerManifest = TriggerManifest<'webhook', WebhookTriggerRuntime>; interface WebhookTriggerConfig extends Omit, 'credentialSets'> { readonly source: WebhookSource; /** * Payload schema. Optional — defaults to `z.unknown()` when omitted. * Integration packages shipping `source: 'app'` typed wrappers should * pass the raw provider event schema here. */ readonly payload?: TPayloadSchema; /** * Pure-Zod filter schema. Evaluated server-side as JSON Schema before any * VM hop. Refinements, transforms, and pipelines are rejected at construct * time — for conditional logic, do the check at the start of the workflow. */ readonly filter?: AnyZodSchema; readonly idempotencyKey?: IdempotencyKeyConfig; } //#endregion //#region src/trigger/webhook/WebhookTrigger.d.ts /** * Creates a callable webhook trigger. * * `source: { type: 'custom' }` — the platform owns the HTTP surface and * authenticates with a Keystroke-issued secret. The platform always replies * `202 { received }`. * `source: { type: 'app', appRef }` — fanned out by a managed provider app. */ declare function webhookTrigger(config: WebhookTriggerConfig): CallableTrigger, readonly [], WebhookTriggerManifest, WebhookRequest> & { readonly source: WebhookSource; readonly payload: TPayloadSchema; }; declare class WebhookTrigger extends Trigger { readonly filter?: AnyZodSchema; readonly idempotencyKey?: WebhookTriggerConfig['idempotencyKey']; readonly source: WebhookSource; readonly payload: TPayloadSchema; constructor(config: WebhookTriggerConfig); } //#endregion export { ScheduleSchema as A, TriggerEntry as C, idempotencyKeyConfigSchema as D, IdempotencyKeyConfig as E, Duration as M, DurationSchema as N, resolveIdempotencyKey as O, parseDurationToMs as P, TriggerBindOptions as S, ValidTriggerEntry as T, cronTrigger as _, WebhookRequest as a, BoundTrigger as b, WebhookTriggerManifest as c, PollingTrigger as d, pollingTrigger as f, CronTrigger as g, cronTriggerManifestSchema as h, WebhookCustomSource as i, calculateNextRunAt as j, Schedule as k, webhookTriggerManifestSchema as l, PollingTriggerManifest as m, webhookTrigger as n, WebhookSource as o, PollingContext as p, WebhookAppSource as r, WebhookSourceManifest as s, WebhookTrigger as t, pollingTriggerManifestSchema as u, CronTriggerManifest as v, TriggerManifest as w, CallableTrigger as x, AnyTrigger as y };