/** * Standard error format returned by the Zapier API */ export interface ApiError { status: number; code: string; title: string; detail: string; source?: unknown; meta?: unknown; } /** * Base options for all error constructors */ export interface ErrorOptions { statusCode?: number; errors?: ApiError[]; cause?: unknown; response?: unknown; } /** * Base class for all Zapier SDK errors * Use instanceof ZapierError to check if an error is from the SDK */ export declare abstract class ZapierError extends Error { abstract readonly name: string; abstract readonly code: string; statusCode?: number; errors?: ApiError[]; cause?: unknown; response?: unknown; constructor(message: string, options?: ErrorOptions); } /** * Error thrown when API requests fail */ export declare class ZapierApiError extends ZapierError { readonly name = "ZapierApiError"; readonly code: "ZAPIER_API_ERROR"; constructor(message: string, options?: ErrorOptions); } /** * Error thrown when an app is not found */ export declare class ZapierAppNotFoundError extends ZapierError { readonly name = "ZapierAppNotFoundError"; readonly code: "ZAPIER_APP_NOT_FOUND_ERROR"; appKey?: string; constructor(message: string, options?: ErrorOptions & { appKey?: string; }); } /** * Error thrown when validation fails (e.g., invalid parameters) */ export declare class ZapierValidationError extends ZapierError { readonly name = "ZapierValidationError"; readonly code: "ZAPIER_VALIDATION_ERROR"; details?: unknown; constructor(message: string, options?: ErrorOptions & { details?: unknown; }); } /** * Error for unrecognized/unknown errors that get wrapped by safe functions */ export declare class ZapierUnknownError extends ZapierError { readonly name = "ZapierUnknownError"; readonly code: "ZAPIER_UNKNOWN_ERROR"; constructor(message: string, options?: ErrorOptions); } /** * Error thrown for authentication and authorization failures (401/403) */ export declare class ZapierAuthenticationError extends ZapierError { readonly name = "ZapierAuthenticationError"; readonly code: "ZAPIER_AUTHENTICATION_ERROR"; constructor(message: string, options?: ErrorOptions); } /** * Error thrown when a resource is not found (404) */ export declare class ZapierNotFoundError extends ZapierError { readonly name: string; readonly code: string; constructor(message: string, options?: ErrorOptions); } /** * Error thrown when a requested resource is not found and the caller * provided a `resource` hint on the request, populating `resourceType` * and (optionally) `resourceId`. Subclass of `ZapierNotFoundError` so * `instanceof ZapierNotFoundError` checks continue to work. */ export declare class ZapierResourceNotFoundError extends ZapierNotFoundError { readonly name = "ZapierResourceNotFoundError"; readonly code: "ZAPIER_RESOURCE_NOT_FOUND_ERROR"; resourceType?: string; resourceId?: string; constructor(message: string, options?: ErrorOptions & { resourceType?: string; resourceId?: string; }); } /** * Error thrown when required app or implementation configuration is missing */ export declare class ZapierConfigurationError extends ZapierError { readonly name = "ZapierConfigurationError"; readonly code: "ZAPIER_CONFIGURATION_ERROR"; configType?: string; constructor(message: string, options?: ErrorOptions & { configType?: string; }); } /** * Error thrown when code bundling or compilation fails */ export declare class ZapierBundleError extends ZapierError { readonly name = "ZapierBundleError"; readonly code: "ZAPIER_BUNDLE_ERROR"; buildErrors?: string[]; constructor(message: string, options?: ErrorOptions & { buildErrors?: string[]; }); } /** * Error thrown when operations timeout or exceed retry limits */ export declare class ZapierTimeoutError extends ZapierError { readonly name = "ZapierTimeoutError"; readonly code: "ZAPIER_TIMEOUT_ERROR"; attempts?: number; maxAttempts?: number; constructor(message: string, options?: ErrorOptions & { attempts?: number; maxAttempts?: number; }); } /** * Error thrown when action execution fails due to errors returned from the third-party service * This happens when the Actions API returns a 200 status but includes errors in the response */ export declare class ZapierActionError extends ZapierError { readonly name = "ZapierActionError"; readonly code: "ZAPIER_ACTION_ERROR"; appKey?: string; actionKey?: string; constructor(message: string, options?: ErrorOptions & { appKey?: string; actionKey?: string; }); get actionErrors(): ApiError[] | undefined; } /** * Error thrown when an operation conflicts with existing state (409). Common * cases: creating a named resource where a different one already exists with * the same name, or operating on a resource in an incompatible state. */ export declare class ZapierConflictError extends ZapierError { readonly name = "ZapierConflictError"; readonly code: "ZAPIER_CONFLICT_ERROR"; resourceType?: string; constructor(message: string, options?: ErrorOptions & { resourceType?: string; }); } /** * Rate limit information extracted from response headers */ export interface RateLimitInfo { /** How long to wait before retrying (from Retry-After or X-RateLimit-Reset) */ retryAfterMs?: number; /** Maximum requests allowed in the window (from X-RateLimit-Limit) */ limit?: number; /** Requests remaining in the current window (from X-RateLimit-Remaining) */ remaining?: number; /** When the rate limit window resets in ms since epoch (from X-RateLimit-Reset) */ resetMs?: number; } /** * Error thrown when rate limited (429) after all retries are exhausted */ export declare class ZapierRateLimitError extends ZapierError { readonly name = "ZapierRateLimitError"; readonly code: "ZAPIER_RATE_LIMIT_ERROR"; rateLimit: RateLimitInfo; retries: number; constructor(message: string, options?: ErrorOptions & { rateLimit?: RateLimitInfo; retries?: number; }); } /** * Terminal status of an approval attempt, exposed on `ZapierApprovalError.approvalStatus`. * * - `pending`: The approval was created but not yet resolved. Only thrown in * `approvalMode: "throw"` — the caller is expected to surface the approval URL * to an end user (e.g. an LLM instructing its user to click the link). * - `denied`: A human explicitly rejected the approval in the UI. * - `policy_denied`: A policy rule blocked the request before (or instead of) * creating an approval. Cannot be approved by a human. * - `approval_required`: The backend requested approval, but `approvalMode` is * `"disabled"` (the default) so the SDK did not create an approval. Set * `approvalMode` to `"poll"` or `"throw"` (or the `ZAPIER_APPROVAL_MODE` env * var) to enable the approval flow. * - `timeout`: Poll mode exceeded `approvalTimeoutMs` without the approval * being resolved. * - `max_retries_exceeded`: A single request triggered more sequential approval * rounds than `maxApprovalRetries` allows (runaway-loop safeguard). */ export type ApprovalStatus = "denied" | "timeout" | "pending" | "policy_denied" | "approval_required" | "max_retries_exceeded"; /** * Error thrown when a request requires approval and the approval is denied, times out, * or the auth type doesn't support the approval flow. */ export declare class ZapierApprovalError extends ZapierError { readonly name = "ZapierApprovalError"; readonly code: "ZAPIER_APPROVAL_ERROR"; approvalId?: string; approvalStatus?: ApprovalStatus; approvalUrl?: string; pollUrl?: string; constructor(message: string, options?: ErrorOptions & { approvalId?: string; status?: ApprovalStatus; approvalUrl?: string; pollUrl?: string; }); } /** * Error thrown when Relay itself encounters an error (as opposed to the upstream partner API returning an error). * Indicated by the presence of the X-Relay-Error response header. */ export declare class ZapierRelayError extends ZapierError { readonly name = "ZapierRelayError"; readonly code: "ZAPIER_RELAY_ERROR"; constructor(message: string, options?: ErrorOptions); } /** * Utility function to format error messages for display */ export declare function formatErrorMessage(error: ZapierError): string; //# sourceMappingURL=errors.d.ts.map