import type { FulfillmentOrder, FulfillmentOrderRequest, FulfillmentProvider } from "../core/fulfillment"; import type { CommerceDb } from "./queries"; export type StorefrontFulfillmentInstallation = { config: Record; created_at: Date; id: string; label: string; owner_key: string | null; provider: string; secret_alias: string | null; status: string; updated_at: Date; }; export type StorefrontFulfillmentJob = { attempts: number; completed_at: Date | null; created_at: Date; id: string; installation_id: string | null; last_attempt_at: Date | null; last_error: string | null; lease_expires_at: Date | null; next_attempt_at: Date | null; order_id: string; payload: Record; provider_order_id: string | null; request: FulfillmentOrderRequest | null; result: FulfillmentOrder | null; status: string; updated_at: Date; worker_id: string | null; }; export type StorefrontFulfillmentFleetJob = { job: StorefrontFulfillmentJob; ownerKey: string; }; export type StorefrontFulfillmentOrder = { amount_cents: number; catalog_id: string; created_at: Date; currency: string; customer_email: string | null; customer_name: string | null; id: string; installation_id: string; intent_id: string; lines: Array>; owner_key: string; provider_session_id: string; shipping: Record | null; status: string; updated_at: Date; }; export declare class StorefrontFulfillmentError extends Error { readonly code: "credential_unavailable" | "fulfillment_disabled" | "installation_disabled" | "installation_not_found" | "job_not_found" | "job_not_retryable" | "order_invalid"; constructor(code: "credential_unavailable" | "fulfillment_disabled" | "installation_disabled" | "installation_not_found" | "job_not_found" | "job_not_retryable" | "order_invalid"); } export declare const createStorefrontFulfillmentService: (options: { credentialAvailable: (ownerKey: string, alias: string) => Promise; db: CommerceDb; enabled?: boolean; leaseMs?: number; now?: () => Date; prepare: (input: { installation: StorefrontFulfillmentInstallation; job: StorefrontFulfillmentJob; order: StorefrontFulfillmentOrder; }) => Promise; providerFor: (installation: StorefrontFulfillmentInstallation) => Promise; reconcileMs?: number; }) => { installationEnabled: (ownerKey: string, installationId?: string) => Promise; listFleet: () => Promise<{ installations: { config: Record; created_at: Date; id: string; label: string; owner_key: string | null; provider: string; secret_alias: string | null; status: string; updated_at: Date; }[]; jobs: { job: { attempts: number; completed_at: Date | null; created_at: Date; id: string; installation_id: string | null; last_attempt_at: Date | null; last_error: string | null; lease_expires_at: Date | null; next_attempt_at: Date | null; order_id: string; payload: Record; provider_order_id: string | null; request: FulfillmentOrderRequest | null; result: FulfillmentOrder | null; status: string; updated_at: Date; worker_id: string | null; }; ownerKey: string; }[]; }>; listOwner: (ownerKey: string) => Promise<{ installations: { config: Record; created_at: Date; id: string; label: string; owner_key: string | null; provider: string; secret_alias: string | null; status: string; updated_at: Date; }[]; jobs: { attempts: number; completed_at: Date | null; created_at: Date; id: string; installation_id: string | null; last_attempt_at: Date | null; last_error: string | null; lease_expires_at: Date | null; next_attempt_at: Date | null; order_id: string; payload: Record; provider_order_id: string | null; request: FulfillmentOrderRequest | null; result: FulfillmentOrder | null; status: string; updated_at: Date; worker_id: string | null; }[]; }>; quarantine: (ownerKey: string, jobId: string, reason: string) => Promise; retry: (ownerKey: string, jobId: string) => Promise; runCycle: (workerId: string, limit?: number) => Promise<({ jobId: string; result: FulfillmentOrder; status: string; } | { jobId: string; status: string; } | null)[]>; saveInstallation: (ownerKey: string, input: { config?: Record; id?: string; label: string; provider: string; secretAlias: string; }) => Promise<{ config: Record; created_at: Date; id: string; label: string; owner_key: string | null; provider: string; secret_alias: string | null; status: string; updated_at: Date; }>; setInstallationEnabled: (ownerKey: string, installationId: string, active: boolean) => Promise<{ config: Record; created_at: Date; id: string; label: string; owner_key: string | null; provider: string; secret_alias: string | null; status: string; updated_at: Date; }>; };