import { type DrainTriggerInboxCallback, type DrainTriggerInboxOptions } from "./schemas"; import type { ApiPluginProvides } from "../../api"; import type { LeaseTriggerInboxMessagesPluginProvides } from "../leaseTriggerInboxMessages"; import type { AckTriggerInboxMessagesPluginProvides } from "../ackTriggerInboxMessages"; import type { ReleaseTriggerInboxMessagesPluginProvides } from "../releaseTriggerInboxMessages"; import type { LeasedTriggerMessageItem } from "../../../schemas/TriggerMessage"; export { ZapierAbortDrainSignal, ZapierReleaseTriggerMessageSignal, } from "./schemas"; interface RunDrainPassOptions { sdk: ApiPluginProvides & LeaseTriggerInboxMessagesPluginProvides & AckTriggerInboxMessagesPluginProvides & ReleaseTriggerInboxMessagesPluginProvides; inboxId: string; onMessage: DrainTriggerInboxCallback; concurrency: number; leaseLimit: number; leaseSeconds: number | undefined; maxMessages: number | undefined; releaseOnError: boolean; continueOnError: boolean; onError: ((err: unknown, msg: LeasedTriggerMessageItem) => void | Promise) | undefined; signal: AbortSignal | undefined; firstFetch: boolean; } export interface RunDrainPassOutcome { /** True if a callback raised the abort signal during this pass. */ abortedFromCallback: boolean; /** Number of items the pipeline marked done (ok or rejected). */ processed: number; } /** * One drain pass through `runBatchedDrainPipeline`. Used directly by * `drainTriggerInbox` (single pass) and as the inner loop body of * `watchTriggerInbox` (called repeatedly with poll backoff between * empty passes). */ export declare function runDrainPass(options: RunDrainPassOptions): Promise; /** * Validate the per-message callback. `onMessage` is required — no * identity default, since "lease and ack everything in this inbox" * is a footgun on a casual call. JS callers that skip onMessage hit * this guard at runtime; TS callers are rejected at the call site. */ export declare function requireOnMessage(onMessage: DrainTriggerInboxCallback | undefined): DrainTriggerInboxCallback; /** * Compute concurrency and lease size with symmetric defaulting: * * both unset -> concurrency=1, leaseLimit=1 * concurrency=N -> concurrency=N, leaseLimit=N * leaseLimit=L -> concurrency=L, leaseLimit=L * both set -> use both as given * * The symmetry kills the "set leaseLimit alone, get prefetch * pathology" footgun: a leased message buffer is never larger than * the worker pool that can immediately work it. */ export declare function resolveConcurrencyAndLease(options: { concurrency?: number; leaseLimit?: number; }): { concurrency: number; leaseLimit: number; }; export declare const drainTriggerInboxPlugin: (sdk: { context: { api: import("../../..").ApiClient; resolveCredentials: () => Promise; }; } & { leaseTriggerInboxMessages: (options?: { inbox: string; leaseLimit?: number | undefined; leaseSeconds?: number | undefined; signal?: AbortSignal | undefined; } | undefined) => Promise<{ data: { lease_id: string | null; leased_until: string | null; results: { id: string; created_at: string; status: string; message_attributes: { lease_count: number; error_message: string | null; possible_duplicate_data: boolean; }; payload: Record; }[]; inbox_attributes: { status: string; paused_reason: string | null; }; }; }>; } & { context: { meta: { leaseTriggerInboxMessages: import("../../..").PluginMeta; }; }; } & { ackTriggerInboxMessages: (options?: { inbox: string; lease: string; messages?: string[] | undefined; } | undefined) => Promise<{ data: { acked_id: string | null; results: { id: string; created_at: string; status: string; message_attributes: { lease_count: number; error_message: string | null; possible_duplicate_data: boolean; }; }[]; }; }>; } & { context: { meta: { ackTriggerInboxMessages: import("../../..").PluginMeta; }; }; } & { releaseTriggerInboxMessages: (options?: { inbox: string; lease: string; messages?: string[] | undefined; } | undefined) => Promise<{ data: { released_id: string | null; results: { id: string; created_at: string; status: string; message_attributes: { lease_count: number; error_message: string | null; possible_duplicate_data: boolean; }; }[]; }; }>; } & { context: { meta: { releaseTriggerInboxMessages: import("../../..").PluginMeta; }; }; } & { context: { meta: Record; }; }) => { drainTriggerInbox: (options: DrainTriggerInboxOptions) => Promise; context: { meta: { drainTriggerInbox: { type: "create"; description: string; itemType: string; returnType: string; inputSchema: import("zod").ZodObject<{ inbox: import("zod").ZodString & { _def: import("zod/v4/core").$ZodStringDef & import("../../..").PositionalMetadata; }; onMessage: import("zod").ZodOptional>; concurrency: import("zod").ZodOptional; leaseLimit: import("zod").ZodOptional; leaseSeconds: import("zod").ZodOptional; releaseOnError: import("zod").ZodOptional; continueOnError: import("zod").ZodOptional; onError: import("zod").ZodOptional>; signal: import("zod").ZodOptional>; maxMessages: import("zod").ZodOptional; }, import("zod/v4/core").$strip>; resolvers: { inbox: import("../../..").DynamicResolver<{ id: string; created_at: string; name: string | null; status: string; paused_reason: string | null; notification_url: string | null; subscription: { connection_id: string | number | null; app_key: string; action_key: string; inputs: Record; }; }, {}>; }; packages: readonly ["sdk"]; categories: string[]; experimental: true; }; }; }; }; export type DrainTriggerInboxPluginProvides = ReturnType; //# sourceMappingURL=index.d.ts.map