export type FulfillmentStatus = "pending" | "accepted" | "in_production" | "partially_shipped" | "shipped" | "cancelled" | "failed"; export type FulfillmentAddress = { firstName: string; lastName: string; company?: string; address1: string; address2?: string; city: string; state?: string; postalCode: string; country: string; email?: string; phone?: string; }; export type FulfillmentArtwork = { url: string; placement: string; presetId?: string; exactArtwork?: boolean; }; export type FulfillmentLine = { id: string; variantId: string; /** The provider account/route selected for this line. */ providerId: string; /** Exact provider-side catalog SKU. */ providerSku: string; quantity: number; artwork: FulfillmentArtwork[]; metadata?: Record; }; export type FulfillmentOrderRequest = { /** Stable merchant order id; providers use this as the idempotency key. */ externalOrderId: string; recipient: FulfillmentAddress; shippingMethod?: string; lines: FulfillmentLine[]; sandbox?: boolean; metadata?: Record; }; export type FulfillmentTracking = { carrier?: string; trackingNumber: string; trackingUrl?: string; shippedAt?: string; }; export type FulfillmentOrder = { providerOrderId: string; externalOrderId: string; status: FulfillmentStatus; costCents?: number; currency?: string; tracking: FulfillmentTracking[]; raw?: unknown; }; export type FulfillmentValidation = { valid: boolean; errors: { lineId?: string; message: string; }[]; }; export type FulfillmentCostQuote = { /** Provider-calculated item production cost before shipping. */ itemsCents: number; /** Provider-calculated shipping cost for the selected destination/method. */ shippingCents: number; /** Provider-specific production additions such as a second decoration side. */ adjustmentsCents: number; totalCents: number; currency: string; quotedAt: string; /** Human-readable normalized assumptions; never put credentials here. */ assumptions: string[]; }; export type FulfillmentCostQuoteRequest = Omit; /** * Read-only pricing preflight. A quote does not reserve provider inventory or * price: spending callers must refresh it immediately before authorization and * still bind settlement to the provider's final accepted cost. */ export interface FulfillmentCostQuoteProvider { quoteOrder(order: FulfillmentCostQuoteRequest): Promise; } export type FulfillmentShippingMethod = { /** Stable provider value passed back as FulfillmentOrderRequest.shippingMethod. */ id: string; name: string; description?: string; carrier?: string; }; export type FulfillmentShippingMethodRequest = Omit; /** * Discovers provider-supported shipping choices for the current destination and * basket. Discovery is read-only and does not reserve capacity or price. */ export interface FulfillmentShippingMethodProvider { listShippingMethods(order: FulfillmentShippingMethodRequest): Promise; } export type FulfillmentEvent = { id?: string; providerOrderId: string; externalOrderId?: string; type: "accepted" | "production" | "shipped" | "cancelled" | "failed"; status: FulfillmentStatus; tracking?: FulfillmentTracking[]; occurredAt?: string; raw?: unknown; }; export interface FulfillmentProvider { readonly id: string; validateOrder(order: FulfillmentOrderRequest): FulfillmentValidation | Promise; submitOrder(order: FulfillmentOrderRequest): Promise; getOrder(providerOrderId: string): Promise; cancelOrder?(providerOrderId: string): Promise; parseWebhook?(request: Request): Promise; } /** One provider-scoped job produced from a possibly mixed-provider order. */ export type RoutedFulfillmentOrder = FulfillmentOrderRequest & { providerId: string; }; /** Split a checkout into idempotent provider jobs without losing line data. */ export declare const routeFulfillmentOrder: (order: FulfillmentOrderRequest) => RoutedFulfillmentOrder[]; export declare const validateFulfillmentOrder: (order: FulfillmentOrderRequest) => FulfillmentValidation;