/**
 * API Client Type Definitions
 *
 * This module contains all type definitions related to the Zapier API client,
 * including configuration options, client interfaces, request/response types,
 * and API response models.
 *
 * API response model types are inferred from Zod schemas defined in api/schemas.ts
 * to ensure a single source of truth and eliminate duplication.
 */
import type { ConnectionSchema, ConnectionsResponseSchema } from "@zapier/zapier-sdk-core/v0/schemas/connections";
import type { ImplementationMetaSchema, ImplementationsMetaResponseSchema } from "@zapier/zapier-sdk-core/v0/schemas/implementations";
import type { SdkEvent } from "../types/events";
import type { Credentials } from "../types/credentials";
import type { RequestContext } from "@zapier/policy-context";
import type { ZapierCache } from "../cache";
import type { z } from "zod";
import type { NeedChoicesSchema, NeedSchema, ActionLinksSchema, ActionPermissionsSchema, ActionSchema, ChoiceSchema, FieldSchema, ActionExecutionResultSchema, ActionFieldChoiceSchema, ActionFieldSchema, UserProfileSchema, AppSchema, NeedsRequestSchema, NeedsResponseSchema, ImplementationSchema, ImplementationsResponseSchema, ServiceSchema, ServicesResponseSchema, NeedChoicesRequestSchema, NeedChoicesResponseSchema, NeedChoicesResponseMetaSchema, NeedChoicesResponseLinksSchema } from "./schemas";
export interface ApiClientOptions {
    baseUrl: string;
    /**
     * Authentication credentials.
     */
    credentials?: Credentials;
    /**
     * @deprecated Use `credentials` instead.
     */
    token?: string;
    debug?: boolean;
    fetch?: typeof globalThis.fetch;
    onEvent?: (event: SdkEvent) => void;
    /**
     * Maximum number of retries for rate-limited requests (429 responses).
     * Set to 0 to disable retries. Default is 3.
     */
    maxNetworkRetries?: number;
    /**
     * Maximum delay in milliseconds to wait for a rate limit retry.
     * If the server requests a longer delay, the request fails immediately.
     * Default is 60000 (60 seconds).
     */
    maxNetworkRetryDelayMs?: number;
    /**
     * Maximum number of concurrent in-flight HTTP requests per client.
     * Requests beyond this limit queue in FIFO order until a slot frees.
     * Pass `Infinity` to disable. Default: 200.
     */
    maxConcurrentRequests?: number;
    /**
     * Controls how the approval flow is handled.
     * - "poll": Create the approval, open the URL in a browser, poll until
     *   resolved, and retry the original request on success.
     * - "throw": Create the approval and throw a ZapierApprovalError immediately
     *   with the approval URL so the caller can surface it.
     * - "disabled": Throw a ZapierApprovalError on approval-required responses
     *   without creating an approval.
     * Resolution order is: explicit option, then ZAPIER_APPROVAL_MODE, then a
     * TTY-based default ("poll" if interactive, "throw" otherwise).
     */
    approvalMode?: "disabled" | "poll" | "throw";
    /**
     * Timeout in ms for approval polling. Default: 600000 (10 minutes).
     */
    approvalTimeoutMs?: number;
    /**
     * Maximum number of sequential approval rounds for a single request before
     * giving up. A single request can legitimately require multiple approvals
     * (one per gating policy); this cap prevents a runaway loop if the server
     * keeps returning approval_required. Default: 2.
     */
    maxApprovalRetries?: number;
    /**
     * Identifies the wrapping package that built this client (e.g., the CLI or
     * MCP server). When set, emitted as `x-zapier-sdk-package` /
     * `x-zapier-sdk-package-version` telemetry headers. Omitted by direct
     * `createZapierSdk` callers — their identity is captured by
     * `x-zapier-sdk-version` alone.
     */
    callerPackage?: {
        name: string;
        version: string;
    };
    /**
     * Pluggable key-value cache used to cache access tokens across
     * invocations. See ZapierCache in ../cache.ts.
     */
    cache?: ZapierCache;
}
export interface ApiClient {
    get: <T = unknown>(path: string, options?: RequestOptions) => Promise<T>;
    post: <T = unknown>(path: string, data?: unknown, options?: RequestOptions) => Promise<T>;
    put: <T = unknown>(path: string, data?: unknown, options?: RequestOptions) => Promise<T>;
    patch: <T = unknown>(path: string, data?: unknown, options?: RequestOptions) => Promise<T>;
    delete: <T = unknown>(path: string, data?: unknown, options?: RequestOptions) => Promise<T>;
    poll: <T = unknown>(path: string, options?: PollOptions) => Promise<T>;
    fetch: (path: string, init?: RequestInit & {
        searchParams?: Record<string, string>;
        authRequired?: boolean;
        approvalContext?: () => RequestContext;
    }) => Promise<Response>;
}
export interface RequestOptions {
    headers?: Record<string, string>;
    searchParams?: Record<string, string>;
    authRequired?: boolean;
    /**
     * OAuth scopes required for this request. When using client credentials,
     * these scopes will be requested during token exchange (merged with any
     * scopes specified in the credentials object).
     */
    requiredScopes?: string[];
    customErrorHandler?: (errorInfo: {
        status: number;
        statusText: string;
        data: unknown;
    }) => Error | undefined;
    /**
     * Optional metadata about what this request is fetching/affecting. When
     * set, 404 responses throw `ZapierResourceNotFoundError` with
     * `resourceType` / `resourceId` populated. The `type` is free-form;
     * conventionally it matches how the resource appears in API URL segments
     * (`"table"`, `"record"`, `"connection"`, etc.).
     */
    resource?: {
        type: string;
        id?: string | number;
    };
    /**
     * Builds the policy context for this request if it triggers the approval
     * flow. Callers that may receive a 403 `approval_required` response MUST
     * provide this so the SDK can create an approval with the correct context.
     */
    approvalContext?: () => RequestContext;
    /**
     * Abort signal forwarded to the underlying `fetch`. Aborting cancels
     * the in-flight request and any rate-limit retry sleep before the
     * next attempt; the resulting `AbortError` is the caller's
     * responsibility to handle.
     */
    signal?: AbortSignal;
}
export interface PollOptions extends RequestOptions {
    initialDelay?: number;
    timeoutMs?: number;
    successStatus?: number;
    pendingStatus?: number;
    /** Function to check if the response body indicates pending state (return true to continue polling) */
    isPending?: (response: unknown) => boolean;
    resultExtractor?: (response: unknown) => unknown;
}
export interface DebugLogger {
    (message: string, data?: unknown): void;
}
export type NeedChoices = z.infer<typeof NeedChoicesSchema>;
export type Need = z.infer<typeof NeedSchema>;
export type ActionLinks = z.infer<typeof ActionLinksSchema>;
export type ActionPermissions = z.infer<typeof ActionPermissionsSchema>;
export type Action = z.infer<typeof ActionSchema>;
export type Choice = z.infer<typeof ChoiceSchema>;
export type Field = z.infer<typeof FieldSchema>;
export type ActionExecutionResult = z.infer<typeof ActionExecutionResultSchema>;
export type ActionFieldChoice = z.infer<typeof ActionFieldChoiceSchema>;
export type ActionField = z.infer<typeof ActionFieldSchema>;
export type Connection = z.infer<typeof ConnectionSchema>;
export type ConnectionsResponse = z.infer<typeof ConnectionsResponseSchema>;
export type UserProfile = z.infer<typeof UserProfileSchema>;
export type App = z.infer<typeof AppSchema>;
export type Service = z.infer<typeof ServiceSchema>;
export type ServicesResponse = z.infer<typeof ServicesResponseSchema>;
export type NeedsRequest = z.infer<typeof NeedsRequestSchema>;
export type NeedsResponse = z.infer<typeof NeedsResponseSchema>;
export type Implementation = z.infer<typeof ImplementationSchema>;
export type ImplementationsResponse = z.infer<typeof ImplementationsResponseSchema>;
export type ImplementationMeta = z.infer<typeof ImplementationMetaSchema>;
export type ImplementationsMetaResponse = z.infer<typeof ImplementationsMetaResponseSchema>;
export type NeedChoicesRequest = z.infer<typeof NeedChoicesRequestSchema>;
export type NeedChoicesResponse = z.infer<typeof NeedChoicesResponseSchema>;
export type NeedChoicesResponseMeta = z.infer<typeof NeedChoicesResponseMetaSchema>;
export type NeedChoicesResponseLinks = z.infer<typeof NeedChoicesResponseLinksSchema>;
//# sourceMappingURL=types.d.ts.map