import { type PoolClient } from '@evershop/postgres-query-builder'; import { pool } from '../../../lib/postgres/connection.js'; import type { OrderAddressRow, OrderRow, ShipmentRow } from '../../../types/db/index.js'; import type { CarrierAddress } from '../types/carrier.js'; /** * Payload accepted by the new createShipment service. The API stays pure โ€” * `items` is mandatory and non-empty; the admin UI handles the * "ship everything that's left" convenience by pre-populating the picker. * * See wiki/multi-shipment-design.md โ†’ "Services" โ†’ "createShipment". */ export interface CreateShipmentPayload { items: Array<{ order_item_id: number; qty: number; }>; carrier: string; tracking_number?: string; notifyCustomer?: boolean; } export interface CreateShipmentResult { shipment: ShipmentRow; items: Array<{ order_item_id: number; qty: number; }>; /** `true` if a label was created as part of this call (Stream C). */ labelCreated: boolean; } /** * Per-item pre-check result. Used to thread between phase 1 (validation) and * phase 2 (insert) so we don't re-load order_items in both. */ interface ItemCheck { order_item_id: number; qty: number; qty_ordered: number; qty_already_shipped: number; no_shipping_required: boolean; } /** * Map an `order_address` row into the carrier-input `CarrierAddress` shape by * token, through `toIntegrationAddress` (spec ยง 3.10): `company` is finally * filled (from `organization`), the second and third address lines join into * `address2`, `city` is the locality's display name, `province` the stored * administrative-area key, and `dependentLocality` is carried for countries * that have one. Exported for its unit test. */ export declare function toCarrierAddress(row: OrderAddressRow | null): Promise; declare const createShipmentDefault: (orderUuid: string, payload: CreateShipmentPayload, conn?: PoolClient) => Promise; /** * Default export accepts BOTH the new payload object and the legacy positional * form. We dispatch by inspecting the second arg so the rewrite can land * without simultaneously updating every caller in one diff. */ export default function createShipment(orderUuid: string, payloadOrCarrier: CreateShipmentPayload | string | null, trackingNumberOrConn?: string | null | PoolClient, maybeConn?: PoolClient): Promise; export { createShipmentDefault as createShipmentNew }; export declare function hookBeforeCreateShipment(callback: (this: Record, ...args: [ orderUuid: string, payload: CreateShipmentPayload, conn?: PoolClient ]) => void | Promise, priority?: number): void; export declare function hookAfterCreateShipment(callback: (this: Record, ...args: [ orderUuid: string, payload: CreateShipmentPayload, conn?: PoolClient ]) => void | Promise, priority?: number): void; export declare function hookBeforeValidateShipmentItems(callback: (this: { order: OrderRow; payload: CreateShipmentPayload; }, ...args: [ order: OrderRow, payload: CreateShipmentPayload, connection: PoolClient | typeof pool ]) => void | Promise, priority?: number): void; export declare function hookAfterValidateShipmentItems(callback: (this: { order: OrderRow; payload: CreateShipmentPayload; }, ...args: [ order: OrderRow, payload: CreateShipmentPayload, connection: PoolClient | typeof pool ]) => void | Promise, priority?: number): void; export declare function hookBeforeInsertShipment(callback: (this: { order: OrderRow; payload: CreateShipmentPayload; }, ...args: [ payload: CreateShipmentPayload, order: OrderRow, connection: PoolClient ]) => void | Promise, priority?: number): void; export declare function hookAfterInsertShipment(callback: (this: { order: OrderRow; payload: CreateShipmentPayload; }, ...args: [ payload: CreateShipmentPayload, order: OrderRow, connection: PoolClient ]) => void | Promise, priority?: number): void; export declare function hookBeforeInsertShipmentItems(callback: (this: { shipment: ShipmentRow; checks: ItemCheck[]; }, ...args: [ shipment: ShipmentRow, checks: ItemCheck[], connection: PoolClient ]) => void | Promise, priority?: number): void; export declare function hookAfterInsertShipmentItems(callback: (this: { shipment: ShipmentRow; checks: ItemCheck[]; }, ...args: [ shipment: ShipmentRow, checks: ItemCheck[], connection: PoolClient ]) => void | Promise, priority?: number): void;