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<void>) | 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<RunDrainPassOutcome>;
/**
 * 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<string | {
            clientId: string;
            clientSecret: string;
            type?: "client_credentials" | undefined;
            baseUrl?: string | undefined;
            scope?: string | undefined;
        } | {
            clientId: string;
            type?: "pkce" | undefined;
            baseUrl?: string | undefined;
            scope?: string | undefined;
        } | undefined>;
    };
} & {
    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<string, unknown>;
            }[];
            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<string, import("../../..").PluginMeta>;
    };
}) => {
    drainTriggerInbox: (options: DrainTriggerInboxOptions) => Promise<void>;
    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<import("zod").ZodFunction<import("zod/v4/core").$ZodFunctionArgs, import("zod/v4/core").$ZodFunctionOut>>;
                    concurrency: import("zod").ZodOptional<import("zod").ZodNumber>;
                    leaseLimit: import("zod").ZodOptional<import("zod").ZodNumber>;
                    leaseSeconds: import("zod").ZodOptional<import("zod").ZodNumber>;
                    releaseOnError: import("zod").ZodOptional<import("zod").ZodBoolean>;
                    continueOnError: import("zod").ZodOptional<import("zod").ZodBoolean>;
                    onError: import("zod").ZodOptional<import("zod").ZodFunction<import("zod/v4/core").$ZodFunctionArgs, import("zod/v4/core").$ZodFunctionOut>>;
                    signal: import("zod").ZodOptional<import("zod").ZodCustom<AbortSignal, AbortSignal>>;
                    maxMessages: import("zod").ZodOptional<import("zod").ZodNumber>;
                }, 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<string, unknown>;
                        };
                    }, {}>;
                };
                packages: readonly ["sdk"];
                categories: string[];
                experimental: true;
            };
        };
    };
};
export type DrainTriggerInboxPluginProvides = ReturnType<typeof drainTriggerInboxPlugin>;
//# sourceMappingURL=index.d.ts.map