@12-apps/marketplace 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/ADOPTING.md +70 -0
  2. package/dist/99food/index.d.ts +2 -2
  3. package/dist/99food/index.js +2 -2
  4. package/dist/{adapter-CxzF-qGx.d.ts → adapter-ZpAWKoCk.d.ts} +116 -2
  5. package/dist/{chunk-7IYUO2KC.js → chunk-3B5EULS6.js} +2 -2
  6. package/dist/{chunk-EABVLQKK.js → chunk-BLHZ3MRB.js} +2 -2
  7. package/dist/{chunk-UZO2NILN.js → chunk-MDEIRGNL.js} +1067 -877
  8. package/dist/chunk-MDEIRGNL.js.map +1 -0
  9. package/dist/{chunk-KKFMDV5K.js → chunk-Q5RMVNU5.js} +1 -1
  10. package/dist/{chunk-KKFMDV5K.js.map → chunk-Q5RMVNU5.js.map} +1 -1
  11. package/dist/{chunk-CF5BSXE5.js → chunk-ZT6TZTLD.js} +1 -1
  12. package/dist/chunk-ZT6TZTLD.js.map +1 -0
  13. package/dist/{client-C-4QvVq3.d.ts → client-DpEq0yXb.d.ts} +1 -1
  14. package/dist/{engine-Y6Rpf5p7.d.ts → engine-DRRhAjZK.d.ts} +171 -143
  15. package/dist/hono/index.d.ts +2 -2
  16. package/dist/hono/index.js +3 -3
  17. package/dist/ifood/index.d.ts +7 -2
  18. package/dist/ifood/index.js +138 -100
  19. package/dist/ifood/index.js.map +1 -1
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +76 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/keeta/index.d.ts +2 -2
  24. package/dist/keeta/index.js +2 -2
  25. package/dist/manifest/server.d.ts +2 -2
  26. package/dist/manifest/server.js +3 -3
  27. package/dist/rappi/index.d.ts +1 -1
  28. package/dist/rappi/index.js +1 -1
  29. package/dist/server/index.d.ts +2 -2
  30. package/dist/server/index.js +3 -3
  31. package/package.json +1 -1
  32. package/prisma/marketplace.prisma +1 -1
  33. package/prisma/migrations/20261203200000_marketplace_status_logistics_steps/migration.sql +12 -0
  34. package/src/core/adapter.ts +2 -1
  35. package/src/core/delivery-code.ts +119 -0
  36. package/src/core/engine.ts +10 -2
  37. package/src/core/logistics.ts +388 -0
  38. package/src/core/outbound-queue.ts +6 -1
  39. package/src/core/outbound-sweep.ts +10 -5
  40. package/src/core/outbound.ts +4 -5
  41. package/src/core/pipeline.ts +6 -1
  42. package/src/core/ports.ts +5 -2
  43. package/src/core/status-job.ts +3 -0
  44. package/src/core/status-store.ts +2 -1
  45. package/src/core/types.ts +2 -0
  46. package/src/ifood/index.ts +3 -0
  47. package/src/ifood/logistics.ts +38 -0
  48. package/src/ifood/normalize.ts +11 -1
  49. package/src/index.ts +10 -0
  50. package/dist/chunk-CF5BSXE5.js.map +0 -1
  51. package/dist/chunk-UZO2NILN.js.map +0 -1
  52. /package/dist/{chunk-7IYUO2KC.js.map → chunk-3B5EULS6.js.map} +0 -0
  53. /package/dist/{chunk-EABVLQKK.js.map → chunk-BLHZ3MRB.js.map} +0 -0
@@ -13,4 +13,4 @@ export {
13
13
  PROVIDER_ID_PATTERN,
14
14
  normalizedLineTotalCents
15
15
  };
16
- //# sourceMappingURL=chunk-KKFMDV5K.js.map
16
+ //# sourceMappingURL=chunk-Q5RMVNU5.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/types.ts"],"sourcesContent":["import type { NormalizedDisputeEvent } from \"./dispute-port\";\n\n/**\n * The canonical shape every marketplace adapter normalizes INTO.\n *\n * This type is the seam. The engine below it knows no marketplace by name: a\n * marketplace is an adapter registered with the engine (`./adapter`), and the\n * provider id is whatever that adapter says it is. A second marketplace is a\n * second adapter, never a second pipeline, a second acceptance clock or a\n * second idea of what an order is.\n *\n * Deliberately POORER than any marketplace's own payload. Everything a store\n * operates on is here; everything else stays in the inbox row's raw `payload`,\n * which is where a normalization bug is reconstructed from.\n */\n\n/**\n * A marketplace's id, as its adapter declares it (`\"IFOOD\"`). Uppercase\n * letters, digits and underscores; the migration's CHECK holds the same shape.\n * A string rather than a closed union, because the set of marketplaces is the\n * set of registered adapters, and a union would make a new one a code change\n * in the engine.\n */\nexport type MarketplaceProvider = string;\n\n/** The shape a provider id must have. Shared by the registry and the CHECK. */\nexport const PROVIDER_ID_PATTERN = /^[A-Z][A-Z0-9_]*$/u;\n\n/** One line of an incoming order, before it is resolved against the catalog. */\nexport interface NormalizedOrderLine {\n /** The marketplace's own SKU — the key the SKU map is matched on. */\n externalSku: string;\n /** What the marketplace called it. Snapshotted, and the fallback line text. */\n name: string;\n quantity: number;\n /**\n * Unit price in the smallest currency unit AS THE MARKETPLACE STATES IT. A\n * marketplace's menu carries its own prices, and the buyer's receipt is the\n * marketplace's one: re-pricing from the host's catalog would produce a\n * total nobody was charged.\n */\n unitPriceCents: number;\n /** The buyer's note on this line, when they left one. */\n note: string | null;\n /**\n * OPTIONAL (FUT-5803). The options the buyer chose on this line (a\n * complemento: \"borda recheada\", \"sem cebola\"), each priced on its own. When\n * present, `unitPriceCents` is the item ALONE and the line costs\n * `unitPriceCents × quantity + Σ options[].totalCents`\n * ({@link normalizedLineTotalCents}). Absent: none is itemized. Open\n * Delivery and Rappi then fold the options' price into `unitPriceCents`;\n * iFood does not, so an iFood item that states `optionsPrice` but lists no\n * `options[]` is priced as the item alone. Never an empty array.\n */\n options?: NormalizedLineOption[];\n}\n\n/** One option on an order line, as the marketplace priced it (FUT-5803). */\nexport interface NormalizedLineOption {\n /** The marketplace's own code for the option, when it gives one. */\n externalCode: string | null;\n name: string;\n /** The group the marketplace shows it under (\"Borda\", \"Adicionais\"), when it says. */\n groupName: string | null;\n /** How many, for the WHOLE line (never per unit of it). */\n quantity: number;\n unitPriceCents: number;\n /**\n * Always exactly `unitPriceCents × quantity`. A stated price that does not\n * divide by its count arrives as two rows of the same option (the floor,\n * then one unit carrying the remainder), whose counts sum to the stated one.\n */\n totalCents: number;\n}\n\n/** What a line costs: the item times its quantity, plus each of its options. */\nexport function normalizedLineTotalCents(line: Pick<NormalizedOrderLine, \"unitPriceCents\" | \"quantity\" | \"options\">): number {\n return line.unitPriceCents * line.quantity + (line.options ?? []).reduce((sum, option) => sum + option.totalCents, 0);\n}\n\n/** The buyer, as much of them as the marketplace discloses. */\nexport interface NormalizedBuyer {\n /** The marketplace's own stable id for this customer, when it gives one. */\n externalId: string | null;\n name: string | null;\n phone: string | null;\n /**\n * OPTIONAL (FUT-5803). The buyer's tax id for the invoice (a CPF or a CNPJ),\n * digits only. Absent: the marketplace states none.\n */\n document?: string | null;\n /**\n * OPTIONAL (FUT-5803). The extension that reaches the buyer through the\n * marketplace's masked number in `phone` (iFood's `phone.localizer`). Absent: none.\n */\n phoneLocalizer?: string | null;\n}\n\n/** Where a delivery goes, as much of it as the marketplace states. */\nexport interface NormalizedAddress {\n street: string;\n number: string;\n neighborhood: string;\n complement: string | null;\n /** The sentence that finds the door. */\n reference: string | null;\n postalCode: string | null;\n city: string | null;\n state: string | null;\n}\n\n/**\n * How the order reaches the buyer: brought to the door (`DELIVERY`), collected\n * (`TAKEOUT`), eaten at the store (`DINE_IN`), or ordered from inside it, at a\n * table or a spot the buyer names (`INDOOR`, FUT-5803).\n */\nexport type MarketplaceOrderType = \"DELIVERY\" | \"TAKEOUT\" | \"DINE_IN\" | \"INDOOR\";\n\n/** WHO carries a delivery: the merchant's own courier, or the marketplace's fleet. */\nexport type MarketplaceDeliveredBy = \"MERCHANT\" | \"MARKETPLACE\";\n\n/** WHO pays for a discount: the store, the marketplace's own campaign, or someone else (a card issuer, a voucher). */\nexport type MarketplaceDiscountSponsor = \"MERCHANT\" | \"MARKETPLACE\" | \"OTHER\";\n\n/** One discount on an order, as the part one sponsor pays. */\nexport interface NormalizedOrderDiscount {\n /** The discount's value in the smallest currency unit. */\n cents: number;\n sponsor: MarketplaceDiscountSponsor;\n /** What the marketplace called the campaign, when it says. */\n name?: string;\n}\n\n/**\n * How a buyer paid, as a closed set a host has words for. `OTHER`: stated,\n * and none of these (the marketplace's own word is in `statedMethod`).\n */\nexport type MarketplacePaymentMethod =\n | \"CREDIT\"\n | \"DEBIT\"\n | \"MEAL_VOUCHER\"\n | \"FOOD_VOUCHER\"\n | \"PIX\"\n | \"CASH\"\n | \"DIGITAL_WALLET\"\n | \"OTHER\";\n\n/** One way the buyer pays an order (FUT-5803). */\nexport interface NormalizedPaymentMethod {\n method: MarketplacePaymentMethod;\n /** The marketplace's own word for the method, verbatim; null when it states none. */\n statedMethod: string | null;\n /**\n * True: already paid on the marketplace. False: to collect from the buyer at\n * the door or the counter. Null: unstated.\n */\n prepaid: boolean | null;\n /** What this method pays, in the smallest currency unit. */\n valueCents: number;\n /** The card's brand as the marketplace names it (\"VISA\"), when it does. */\n cardBrand: string | null;\n /** On cash: the note the buyer pays with, so the courier brings the change. Null: no change asked, or unstated. */\n changeForCents: number | null;\n}\n\n/** The order's payment, as the marketplace states it (FUT-5803). */\nexport interface NormalizedPayments {\n /** What the marketplace already collected. Null: unstated. */\n prepaidCents: number | null;\n /** What is still to collect from the buyer. Null: unstated. */\n pendingCents: number | null;\n methods: NormalizedPaymentMethod[];\n}\n\n/** A fee the marketplace charged the buyer besides delivery (FUT-5803), such as a small-order fee. */\nexport interface NormalizedOrderFee {\n /** The marketplace's own kind, verbatim (`SMALL_ORDER_FEE`). */\n kind: string;\n cents: number;\n /** What the marketplace called it, when it says. */\n name?: string;\n}\n\n/** An incoming marketplace order, normalized. */\nexport interface NormalizedMarketplaceOrder {\n provider: MarketplaceProvider;\n /** The marketplace's order id — THE idempotency key for the whole pipeline. */\n externalOrderId: string;\n /** The short code the courier and the buyer say out loud. */\n externalDisplayId: string | null;\n buyer: NormalizedBuyer;\n lines: NormalizedOrderLine[];\n /**\n * What the buyer paid, gross. NOT derived from the lines when the\n * marketplace states it: its total carries fees, promotions and rounding the\n * line sum does not, and the number that must match the receipt is this one.\n */\n totalCents: number;\n /** The marketplace's cut, when it states one. NULL is \"did not say\", not 0. */\n commissionCents: number | null;\n /** The marketplace's own promise to the buyer. */\n deliveryDueAt: Date | null;\n /** When the marketplace says the order was placed. */\n placedAt: Date;\n /** Null when the payload does not say. */\n orderType?: MarketplaceOrderType | null;\n /** Null on a take-out and when unstated. */\n deliveredBy?: MarketplaceDeliveredBy | null;\n /** Null on a take-out and when unstated. */\n deliveryAddress?: NormalizedAddress | null;\n /**\n * OPTIONAL. The delivery fee the buyer was charged, in the smallest currency\n * unit. 0 is a free delivery; null or absent is \"did not say\".\n */\n deliveryFeeCents?: number | null;\n /** OPTIONAL. The items' sum as the marketplace states it, before fees and discounts. Null or absent is \"did not say\". */\n subtotalCents?: number | null;\n /**\n * OPTIONAL. The discounts on the order, one entry per sponsor's share, so a\n * host can tell what the store gave from what the marketplace paid for.\n * Absent is \"did not say\"; an empty array is \"no discount\".\n */\n discounts?: NormalizedOrderDiscount[];\n /**\n * OPTIONAL. The merchant the order names, when its body says (Open\n * Delivery's `merchant.id`). A fetched order naming another merchant than\n * the connection's is refused.\n */\n externalMerchantId?: string | null;\n /**\n * OPTIONAL (FUT-5665). The code the marketplace's courier states at the\n * counter to collect the bag (iFood's `delivery.pickupCode`), for the host\n * to check locally at the hand-over. Null or absent: the marketplace asks\n * none for this order (the check is off for the store, or the store carries\n * the bag itself).\n */\n pickupCode?: string | null;\n /**\n * OPTIONAL (FUT-5803). How the buyer pays: each method, what is prepaid and\n * what is still to collect, and the change a cash buyer asks for. Absent:\n * the marketplace states none.\n */\n payments?: NormalizedPayments;\n /**\n * OPTIONAL (FUT-5803). The fees besides delivery, inside `totalCents`.\n * Absent is \"did not say\"; an empty array is \"none\".\n */\n additionalFees?: NormalizedOrderFee[];\n}\n\n/**\n * What an event says about the STORE's own cancellation request: `CONFIRMED`\n * when the marketplace cancelled the order (a pending request is answered),\n * `FAILED` when it refused the request.\n */\nexport type CancellationOutcome = \"CONFIRMED\" | \"FAILED\";\n\n/**\n * A step of the order's life a marketplace announces about an order it\n * already has (FUT-4653): the courier left (`DISPATCHED`), the marketplace's\n * courier has the bag (`COLLECTED`, FUT-5665: for a fleet bag it is the same\n * hand-over as `DISPATCHED`) or the order is finished (`CONCLUDED`). An event\n * that names one moves nothing by itself; the engine asks the host to move the\n * order forward (`onLifecycle`).\n */\nexport type MarketplaceLifecycle = \"DISPATCHED\" | \"COLLECTED\" | \"CONCLUDED\";\n\n/**\n * Where the marketplace's own courier is with a bag (FUT-5665), provider-\n * neutral: named (`ASSIGNED`), on the way to the store (`GOING_TO_ORIGIN`),\n * at the counter (`ARRIVED_AT_ORIGIN`), holding the bag (`COLLECTED`), or\n * bringing it back (`RETURNING_TO_ORIGIN`, then `RETURNED_TO_ORIGIN`).\n */\nexport type MarketplaceCourierStep =\n | \"ASSIGNED\"\n | \"GOING_TO_ORIGIN\"\n | \"ARRIVED_AT_ORIGIN\"\n | \"COLLECTED\"\n | \"RETURNING_TO_ORIGIN\"\n | \"RETURNED_TO_ORIGIN\";\n\n/** What the courier rides, as a closed set the host has words for. `OTHER`: stated, and none of these. */\nexport type MarketplaceCourierVehicle = \"MOTORCYCLE\" | \"BICYCLE\" | \"CAR\" | \"OTHER\";\n\n/** Who the marketplace sent, as much as it says. */\nexport interface MarketplaceCourier {\n name: string | null;\n /** An https URL of the courier's photo, or null (any other scheme is dropped). */\n photoUrl: string | null;\n vehicle: MarketplaceCourierVehicle | null;\n}\n\n/** One courier event, normalized (FUT-5665). */\nexport interface NormalizedCourierEvent {\n step: MarketplaceCourierStep;\n /** When the marketplace says it happened; null when it does not (the engine then hands the host its clock). */\n at: Date | null;\n /** Who is coming: on `ASSIGNED`, when the marketplace names them; null otherwise. */\n courier: MarketplaceCourier | null;\n /** The bag is coming back (`RETURNING`) or is back (`RETURNED`); null on every other step. */\n returning: \"RETURNING\" | \"RETURNED\" | null;\n}\n\n/** What an adapter makes of one inbound delivery. */\nexport interface NormalizedEvent {\n provider: MarketplaceProvider;\n /** The delivery's own id — the inbox dedup key, paired with the provider. */\n eventId: string;\n /** The provider's event type verbatim, kept for the inbox row and the log. */\n eventType: string;\n /** The merchant this event names, used to attribute it to a tenant. */\n externalMerchantId: string | null;\n externalOrderId: string | null;\n /**\n * The order this event carries, or null when the event is one the engine\n * understands and does not ingest. A null here is an IGNORED inbox row (or a\n * cancellation, below), never a failure.\n */\n order: NormalizedMarketplaceOrder | null;\n /** The marketplace has CANCELLED the order. */\n cancelled: boolean;\n /**\n * The answer to the store's own cancellation request, when this event is\n * one. A `cancelled: true` event reads as `CONFIRMED` when this is absent.\n */\n cancellationOutcome?: CancellationOutcome | null;\n /**\n * OPTIONAL. This event announces an order whose body the marketplace serves\n * separately (Open Delivery's `CREATED` carries only the order's id): the\n * engine fetches it through the adapter's `fetchOrder`, in the\n * `marketplace.fetch-order` job, never inside the request that delivered\n * the event. Ignored when `order` is present.\n */\n orderToFetch?: boolean;\n /**\n * OPTIONAL. The lifecycle step this event announces about an order the\n * engine already has. Absent or null: the event names none. An event that\n * names one carries no order body.\n */\n lifecycle?: MarketplaceLifecycle | null;\n /**\n * OPTIONAL (FUT-5665). Where the marketplace's courier is, when this event\n * says. A `COLLECTED` names the lifecycle too. Absent or null: the event\n * names no courier step.\n */\n courier?: NormalizedCourierEvent | null;\n /**\n * OPTIONAL (FUT-5653). The store accepted the order in the marketplace's own\n * app (iFood's `CFM`): an order still AWAITING here is accepted through the\n * host's admit, with no confirm sent back. Carries no order body.\n */\n marketplaceConfirmed?: boolean;\n /**\n * OPTIONAL (FUT-6099). A dispute the marketplace opened or closed on this\n * order (iFood's HSD / HSS). Carries no order body, and never moves the\n * order or its acceptance.\n */\n dispute?: NormalizedDisputeEvent | null;\n}\n"],"mappings":";;;;;AA0BO,IAAM,sBAAsB;AAkD5B,SAAS,yBAAyB,MAAoF;AAC3H,SAAO,KAAK,iBAAiB,KAAK,YAAY,KAAK,WAAW,CAAC,GAAG,OAAO,CAAC,KAAK,WAAW,MAAM,OAAO,YAAY,CAAC;AACtH;AAFgB;","names":[]}
1
+ {"version":3,"sources":["../src/core/types.ts"],"sourcesContent":["import type { NormalizedDisputeEvent } from \"./dispute-port\";\n\n/**\n * The canonical shape every marketplace adapter normalizes INTO.\n *\n * This type is the seam. The engine below it knows no marketplace by name: a\n * marketplace is an adapter registered with the engine (`./adapter`), and the\n * provider id is whatever that adapter says it is. A second marketplace is a\n * second adapter, never a second pipeline, a second acceptance clock or a\n * second idea of what an order is.\n *\n * Deliberately POORER than any marketplace's own payload. Everything a store\n * operates on is here; everything else stays in the inbox row's raw `payload`,\n * which is where a normalization bug is reconstructed from.\n */\n\n/**\n * A marketplace's id, as its adapter declares it (`\"IFOOD\"`). Uppercase\n * letters, digits and underscores; the migration's CHECK holds the same shape.\n * A string rather than a closed union, because the set of marketplaces is the\n * set of registered adapters, and a union would make a new one a code change\n * in the engine.\n */\nexport type MarketplaceProvider = string;\n\n/** The shape a provider id must have. Shared by the registry and the CHECK. */\nexport const PROVIDER_ID_PATTERN = /^[A-Z][A-Z0-9_]*$/u;\n\n/** One line of an incoming order, before it is resolved against the catalog. */\nexport interface NormalizedOrderLine {\n /** The marketplace's own SKU — the key the SKU map is matched on. */\n externalSku: string;\n /** What the marketplace called it. Snapshotted, and the fallback line text. */\n name: string;\n quantity: number;\n /**\n * Unit price in the smallest currency unit AS THE MARKETPLACE STATES IT. A\n * marketplace's menu carries its own prices, and the buyer's receipt is the\n * marketplace's one: re-pricing from the host's catalog would produce a\n * total nobody was charged.\n */\n unitPriceCents: number;\n /** The buyer's note on this line, when they left one. */\n note: string | null;\n /**\n * OPTIONAL (FUT-5803). The options the buyer chose on this line (a\n * complemento: \"borda recheada\", \"sem cebola\"), each priced on its own. When\n * present, `unitPriceCents` is the item ALONE and the line costs\n * `unitPriceCents × quantity + Σ options[].totalCents`\n * ({@link normalizedLineTotalCents}). Absent: none is itemized. Open\n * Delivery and Rappi then fold the options' price into `unitPriceCents`;\n * iFood does not, so an iFood item that states `optionsPrice` but lists no\n * `options[]` is priced as the item alone. Never an empty array.\n */\n options?: NormalizedLineOption[];\n}\n\n/** One option on an order line, as the marketplace priced it (FUT-5803). */\nexport interface NormalizedLineOption {\n /** The marketplace's own code for the option, when it gives one. */\n externalCode: string | null;\n name: string;\n /** The group the marketplace shows it under (\"Borda\", \"Adicionais\"), when it says. */\n groupName: string | null;\n /** How many, for the WHOLE line (never per unit of it). */\n quantity: number;\n unitPriceCents: number;\n /**\n * Always exactly `unitPriceCents × quantity`. A stated price that does not\n * divide by its count arrives as two rows of the same option (the floor,\n * then one unit carrying the remainder), whose counts sum to the stated one.\n */\n totalCents: number;\n}\n\n/** What a line costs: the item times its quantity, plus each of its options. */\nexport function normalizedLineTotalCents(line: Pick<NormalizedOrderLine, \"unitPriceCents\" | \"quantity\" | \"options\">): number {\n return line.unitPriceCents * line.quantity + (line.options ?? []).reduce((sum, option) => sum + option.totalCents, 0);\n}\n\n/** The buyer, as much of them as the marketplace discloses. */\nexport interface NormalizedBuyer {\n /** The marketplace's own stable id for this customer, when it gives one. */\n externalId: string | null;\n name: string | null;\n phone: string | null;\n /**\n * OPTIONAL (FUT-5803). The buyer's tax id for the invoice (a CPF or a CNPJ),\n * digits only. Absent: the marketplace states none.\n */\n document?: string | null;\n /**\n * OPTIONAL (FUT-5803). The extension that reaches the buyer through the\n * marketplace's masked number in `phone` (iFood's `phone.localizer`). Absent: none.\n */\n phoneLocalizer?: string | null;\n}\n\n/** Where a delivery goes, as much of it as the marketplace states. */\nexport interface NormalizedAddress {\n street: string;\n number: string;\n neighborhood: string;\n complement: string | null;\n /** The sentence that finds the door. */\n reference: string | null;\n postalCode: string | null;\n city: string | null;\n state: string | null;\n}\n\n/**\n * How the order reaches the buyer: brought to the door (`DELIVERY`), collected\n * (`TAKEOUT`), eaten at the store (`DINE_IN`), or ordered from inside it, at a\n * table or a spot the buyer names (`INDOOR`, FUT-5803).\n */\nexport type MarketplaceOrderType = \"DELIVERY\" | \"TAKEOUT\" | \"DINE_IN\" | \"INDOOR\";\n\n/** WHO carries a delivery: the merchant's own courier, or the marketplace's fleet. */\nexport type MarketplaceDeliveredBy = \"MERCHANT\" | \"MARKETPLACE\";\n\n/** WHO pays for a discount: the store, the marketplace's own campaign, or someone else (a card issuer, a voucher). */\nexport type MarketplaceDiscountSponsor = \"MERCHANT\" | \"MARKETPLACE\" | \"OTHER\";\n\n/** One discount on an order, as the part one sponsor pays. */\nexport interface NormalizedOrderDiscount {\n /** The discount's value in the smallest currency unit. */\n cents: number;\n sponsor: MarketplaceDiscountSponsor;\n /** What the marketplace called the campaign, when it says. */\n name?: string;\n}\n\n/**\n * How a buyer paid, as a closed set a host has words for. `OTHER`: stated,\n * and none of these (the marketplace's own word is in `statedMethod`).\n */\nexport type MarketplacePaymentMethod =\n | \"CREDIT\"\n | \"DEBIT\"\n | \"MEAL_VOUCHER\"\n | \"FOOD_VOUCHER\"\n | \"PIX\"\n | \"CASH\"\n | \"DIGITAL_WALLET\"\n | \"OTHER\";\n\n/** One way the buyer pays an order (FUT-5803). */\nexport interface NormalizedPaymentMethod {\n method: MarketplacePaymentMethod;\n /** The marketplace's own word for the method, verbatim; null when it states none. */\n statedMethod: string | null;\n /**\n * True: already paid on the marketplace. False: to collect from the buyer at\n * the door or the counter. Null: unstated.\n */\n prepaid: boolean | null;\n /** What this method pays, in the smallest currency unit. */\n valueCents: number;\n /** The card's brand as the marketplace names it (\"VISA\"), when it does. */\n cardBrand: string | null;\n /** On cash: the note the buyer pays with, so the courier brings the change. Null: no change asked, or unstated. */\n changeForCents: number | null;\n}\n\n/** The order's payment, as the marketplace states it (FUT-5803). */\nexport interface NormalizedPayments {\n /** What the marketplace already collected. Null: unstated. */\n prepaidCents: number | null;\n /** What is still to collect from the buyer. Null: unstated. */\n pendingCents: number | null;\n methods: NormalizedPaymentMethod[];\n}\n\n/** A fee the marketplace charged the buyer besides delivery (FUT-5803), such as a small-order fee. */\nexport interface NormalizedOrderFee {\n /** The marketplace's own kind, verbatim (`SMALL_ORDER_FEE`). */\n kind: string;\n cents: number;\n /** What the marketplace called it, when it says. */\n name?: string;\n}\n\n/** An incoming marketplace order, normalized. */\nexport interface NormalizedMarketplaceOrder {\n provider: MarketplaceProvider;\n /** The marketplace's order id — THE idempotency key for the whole pipeline. */\n externalOrderId: string;\n /** The short code the courier and the buyer say out loud. */\n externalDisplayId: string | null;\n buyer: NormalizedBuyer;\n lines: NormalizedOrderLine[];\n /**\n * What the buyer paid, gross. NOT derived from the lines when the\n * marketplace states it: its total carries fees, promotions and rounding the\n * line sum does not, and the number that must match the receipt is this one.\n */\n totalCents: number;\n /** The marketplace's cut, when it states one. NULL is \"did not say\", not 0. */\n commissionCents: number | null;\n /** The marketplace's own promise to the buyer. */\n deliveryDueAt: Date | null;\n /** When the marketplace says the order was placed. */\n placedAt: Date;\n /** Null when the payload does not say. */\n orderType?: MarketplaceOrderType | null;\n /** Null on a take-out and when unstated. */\n deliveredBy?: MarketplaceDeliveredBy | null;\n /** Null on a take-out and when unstated. */\n deliveryAddress?: NormalizedAddress | null;\n /**\n * OPTIONAL. The delivery fee the buyer was charged, in the smallest currency\n * unit. 0 is a free delivery; null or absent is \"did not say\".\n */\n deliveryFeeCents?: number | null;\n /** OPTIONAL. The items' sum as the marketplace states it, before fees and discounts. Null or absent is \"did not say\". */\n subtotalCents?: number | null;\n /**\n * OPTIONAL. The discounts on the order, one entry per sponsor's share, so a\n * host can tell what the store gave from what the marketplace paid for.\n * Absent is \"did not say\"; an empty array is \"no discount\".\n */\n discounts?: NormalizedOrderDiscount[];\n /**\n * OPTIONAL. The merchant the order names, when its body says (Open\n * Delivery's `merchant.id`). A fetched order naming another merchant than\n * the connection's is refused.\n */\n externalMerchantId?: string | null;\n /**\n * OPTIONAL (FUT-5665). The code the marketplace's courier states at the\n * counter to collect the bag (iFood's `delivery.pickupCode`), for the host\n * to check locally at the hand-over. Null or absent: the marketplace asks\n * none for this order (the check is off for the store, or the store carries\n * the bag itself).\n */\n pickupCode?: string | null;\n /**\n * OPTIONAL (FUT-5803). How the buyer pays: each method, what is prepaid and\n * what is still to collect, and the change a cash buyer asks for. Absent:\n * the marketplace states none.\n */\n payments?: NormalizedPayments;\n /**\n * OPTIONAL (FUT-5803). The fees besides delivery, inside `totalCents`.\n * Absent is \"did not say\"; an empty array is \"none\".\n */\n additionalFees?: NormalizedOrderFee[];\n}\n\n/**\n * What an event says about the STORE's own cancellation request: `CONFIRMED`\n * when the marketplace cancelled the order (a pending request is answered),\n * `FAILED` when it refused the request.\n */\nexport type CancellationOutcome = \"CONFIRMED\" | \"FAILED\";\n\n/**\n * A step of the order's life a marketplace announces about an order it\n * already has (FUT-4653): the courier left (`DISPATCHED`), the marketplace's\n * courier has the bag (`COLLECTED`, FUT-5665: for a fleet bag it is the same\n * hand-over as `DISPATCHED`) or the order is finished (`CONCLUDED`). An event\n * that names one moves nothing by itself; the engine asks the host to move the\n * order forward (`onLifecycle`).\n */\nexport type MarketplaceLifecycle = \"DISPATCHED\" | \"COLLECTED\" | \"CONCLUDED\";\n\n/**\n * Where the marketplace's own courier is with a bag (FUT-5665), provider-\n * neutral: named (`ASSIGNED`), on the way to the store (`GOING_TO_ORIGIN`),\n * at the counter (`ARRIVED_AT_ORIGIN`), holding the bag (`COLLECTED`), or\n * bringing it back (`RETURNING_TO_ORIGIN`, then `RETURNED_TO_ORIGIN`).\n */\nexport type MarketplaceCourierStep =\n | \"ASSIGNED\"\n | \"GOING_TO_ORIGIN\"\n | \"ARRIVED_AT_ORIGIN\"\n | \"COLLECTED\"\n | \"RETURNING_TO_ORIGIN\"\n | \"RETURNED_TO_ORIGIN\";\n\n/** What the courier rides, as a closed set the host has words for. `OTHER`: stated, and none of these. */\nexport type MarketplaceCourierVehicle = \"MOTORCYCLE\" | \"BICYCLE\" | \"CAR\" | \"OTHER\";\n\n/** Who the marketplace sent, as much as it says. */\nexport interface MarketplaceCourier {\n name: string | null;\n /** An https URL of the courier's photo, or null (any other scheme is dropped). */\n photoUrl: string | null;\n vehicle: MarketplaceCourierVehicle | null;\n}\n\n/** One courier event, normalized (FUT-5665). */\nexport interface NormalizedCourierEvent {\n step: MarketplaceCourierStep;\n /** When the marketplace says it happened; null when it does not (the engine then hands the host its clock). */\n at: Date | null;\n /** Who is coming: on `ASSIGNED`, when the marketplace names them; null otherwise. */\n courier: MarketplaceCourier | null;\n /** The bag is coming back (`RETURNING`) or is back (`RETURNED`); null on every other step. */\n returning: \"RETURNING\" | \"RETURNED\" | null;\n}\n\n/** What an adapter makes of one inbound delivery. */\nexport interface NormalizedEvent {\n provider: MarketplaceProvider;\n /** The delivery's own id — the inbox dedup key, paired with the provider. */\n eventId: string;\n /** The provider's event type verbatim, kept for the inbox row and the log. */\n eventType: string;\n /** The merchant this event names, used to attribute it to a tenant. */\n externalMerchantId: string | null;\n externalOrderId: string | null;\n /**\n * The order this event carries, or null when the event is one the engine\n * understands and does not ingest. A null here is an IGNORED inbox row (or a\n * cancellation, below), never a failure.\n */\n order: NormalizedMarketplaceOrder | null;\n /** The marketplace has CANCELLED the order. */\n cancelled: boolean;\n /**\n * The answer to the store's own cancellation request, when this event is\n * one. A `cancelled: true` event reads as `CONFIRMED` when this is absent.\n */\n cancellationOutcome?: CancellationOutcome | null;\n /**\n * OPTIONAL. This event announces an order whose body the marketplace serves\n * separately (Open Delivery's `CREATED` carries only the order's id): the\n * engine fetches it through the adapter's `fetchOrder`, in the\n * `marketplace.fetch-order` job, never inside the request that delivered\n * the event. Ignored when `order` is present.\n */\n orderToFetch?: boolean;\n /**\n * OPTIONAL. The lifecycle step this event announces about an order the\n * engine already has. Absent or null: the event names none. An event that\n * names one carries no order body.\n */\n lifecycle?: MarketplaceLifecycle | null;\n /**\n * OPTIONAL (FUT-5665). Where the marketplace's courier is, when this event\n * says. A `COLLECTED` names the lifecycle too. Absent or null: the event\n * names no courier step.\n */\n courier?: NormalizedCourierEvent | null;\n /**\n * OPTIONAL (FUT-5653). The store accepted the order in the marketplace's own\n * app (iFood's `CFM`): an order still AWAITING here is accepted through the\n * host's admit, with no confirm sent back. Carries no order body.\n */\n marketplaceConfirmed?: boolean;\n /** The marketplace asked the customer's delivery code for the order (FUT-6167). */\n deliveryCodeRequested?: boolean;\n /**\n * OPTIONAL (FUT-6099). A dispute the marketplace opened or closed on this\n * order (iFood's HSD / HSS). Carries no order body, and never moves the\n * order or its acceptance.\n */\n dispute?: NormalizedDisputeEvent | null;\n}\n"],"mappings":";;;;;AA0BO,IAAM,sBAAsB;AAkD5B,SAAS,yBAAyB,MAAoF;AAC3H,SAAO,KAAK,iBAAiB,KAAK,YAAY,KAAK,WAAW,CAAC,GAAG,OAAO,CAAC,KAAK,WAAW,MAAM,OAAO,YAAY,CAAC;AACtH;AAFgB;","names":[]}
@@ -31,4 +31,4 @@ export {
31
31
  tokenGrantResultOf,
32
32
  answered
33
33
  };
34
- //# sourceMappingURL=chunk-CF5BSXE5.js.map
34
+ //# sourceMappingURL=chunk-ZT6TZTLD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/adapter.ts"],"sourcesContent":["import type { MarketplaceCatalogue } from \"./catalogue-port\";\nimport type { MarketplaceCourierApi } from \"./courier-port\";\nimport type { MarketplaceDisputeApi } from \"./dispute-port\";\nimport type { CatalogueReader } from \"./catalogue-read-port\";\nimport type { MarketplaceAppLinking, MarketplaceLinking } from \"./linking-port\";\nimport type { LogisticsAdapter } from \"./logistics\";\nimport type { MarketplaceAvailability } from \"./pause-port\";\nimport type {\n MarketplaceDeliveredBy,\n MarketplaceProvider,\n NormalizedEvent,\n NormalizedMarketplaceOrder,\n} from \"./types\";\n\n/**\n * The adapter port: everything one marketplace is, behind one shape.\n *\n * The owner's rule, which this file exists to make true: \"the integration\n * engine must be the same for all integrations: iFood, Rappi, 99. Only an\n * adapter is made for each one, to connect to the base engine.\"\n *\n * A marketplace differs from the next in five ways that matter to a store:\n * how its deliveries look and are signed (`normalize`, `readSignature`,\n * `verifySignature`), what it lets a store answer through its API (`confirm`,\n * `requestCancellation`), which reasons a refusal may carry\n * (`cancellationReasons`), and where a person goes when the API cannot do it\n * (`appLink`). Everything else — the inbox, the clock, the SKU map, the\n * outbound bookkeeping and its retries — is the engine's and does not change\n * with the marketplace.\n *\n * What a marketplace CAN do is stated by its adapter as\n * {@link MarketplaceCapabilities} and read by the engine and the host. It is\n * never inferred from the provider's id: a branch on the id outside an adapter\n * would make the next marketplace a code change instead of an adapter.\n *\n * The HTTP client is a host port ({@link MarketplaceHttp}), handed to every\n * outbound call. An adapter never reaches the network on its own, so tests\n * answer the seam and nothing else, and the host owns the timeout, the proxy\n * and the CA.\n */\n\n/** A marketplace's credentials, as the merchant supplies them. Sealed at rest. */\nexport interface MarketplaceCredentials {\n clientId: string;\n clientSecret: string;\n /**\n * The shared secret a delivery's signature is verified against. Separate\n * from the OAuth pair: a merchant rotating their webhook secret has not\n * re-onboarded.\n */\n webhookSecret: string | null;\n}\n\n/** What the host's HTTP client takes. */\nexport interface MarketplaceHttpRequest {\n /**\n * `PATCH` since FUT-4768: iFood's catalogue sets an item's status with it.\n * `DELETE` since FUT-4851: iFood removes an interruption with it.\n */\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n url: string;\n headers: Record<string, string>;\n body?: string;\n}\n\n/** What the host's HTTP client answers: any status, never a throw for a 4xx or 5xx. */\nexport interface MarketplaceHttpResponse {\n status: number;\n body: string;\n}\n\n/** The host's HTTP client. It throws only when no answer arrived (a timeout, a network error). */\nexport type MarketplaceHttp = (request: MarketplaceHttpRequest) => Promise<MarketplaceHttpResponse>;\n\n/** What a marketplace can do, stated by its adapter. */\nexport interface MarketplaceCapabilities {\n /** Accepting is answered through the API. */\n apiConfirm: boolean;\n /** A cancellation can be requested through the API at all. */\n apiCancel: boolean;\n /** …and still once the order was accepted. */\n cancelAfterAccept: boolean;\n /** The cancellation's outcome arrives later as an event rather than in the answer. */\n asyncCancellationOutcome: boolean;\n /** `appLink` names this order, rather than only the marketplace's portal. */\n perOrderAppLink: boolean;\n /** Confirming states a preparation time. */\n confirmTakesPreparationTime: boolean;\n /**\n * OPTIONAL. How long the marketplace takes, at most, to answer a store's\n * cancellation request, in milliseconds: past it the outbound sweep fails\n * the request as TIMEOUT. Absent: only the 24-hour give-up applies.\n */\n cancellationAnswerWindowMs?: number;\n /**\n * OPTIONAL. The steps this marketplace can be told about (`informStatus`).\n * Absent or empty: the engine tells it nothing.\n */\n statusSteps?: readonly StatusStep[];\n /**\n * OPTIONAL. The HTTP status a recorded delivery is answered with (FUT-5984:\n * iFood wants `202 Accepted`). Absent: 200. Refusals and failures keep theirs.\n */\n webhookAnswerStatus?: 200 | 202;\n /**\n * OPTIONAL. The marketplace announces that the store accepted an order in the\n * marketplace's own app (`NormalizedEvent.marketplaceConfirmed`, FUT-5653).\n * Its ingest then applies a confirmation that arrived before the order.\n */\n marketplaceConfirms?: boolean;\n /**\n * OPTIONAL. A status step is told only after the marketplace took the\n * store's confirm (`confirmedAt`, FUT-5673: iFood refuses a step of an order\n * it has not confirmed). Absent: steps never wait on the confirm.\n */\n statusAfterConfirm?: boolean;\n /** OPTIONAL (FUT-6099). The buyer's disputes arrive as events and are answered through `disputes`. */\n disputes?: boolean;\n}\n\n/**\n * A marketplace's presence heartbeat (FUT-5984: iFood's `KEEPALIVE`), read off\n * a delivery: `merchantIds` when it asks about named merchants (its\n * per-merchant mode), null when it asks about the whole app.\n */\nexport interface PresenceProbe {\n merchantIds: readonly string[] | null;\n}\n\n/** Acknowledging recorded events to the marketplace (FUT-5984: iFood's `events/acknowledgment`). */\nexport interface MarketplaceAcknowledgement {\n /** At most this many event ids per call. */\n batchSize: number;\n /** How long the marketplace keeps an event: an older one is never acknowledged. */\n retentionMs: number;\n /** Acknowledge these event ids, in one call. */\n send(ctx: AdapterCallContext, eventIds: readonly string[]): Promise<OutboundResult>;\n}\n\n/** One cancellation reason the marketplace lists for one order: its code and its own words. */\nexport interface OrderCancellationReason {\n code: string;\n description: string;\n}\n\n/** One order's reasons read from the marketplace, or the refusal / retry of the read. */\nexport type OrderCancellationReasonsResult =\n | { kind: \"reasons\"; reasons: OrderCancellationReason[] }\n | Exclude<OutboundResult, { kind: \"accepted\" }>;\n\n/**\n * A step of the order the store tells the marketplace about (FUT-4653): the\n * order is ready for pickup, the courier left, the order was handed over.\n */\nexport type StatusStep = \"READY\" | \"DISPATCHED\" | \"HANDED_OVER\";\n\n/** What a status call is told about the order: who carries it (null: a take-out, or unstated). */\nexport interface StatusFacts {\n step: StatusStep;\n deliveredBy: MarketplaceDeliveredBy | null;\n}\n\n/** One reason a store may give for refusing or cancelling an order. */\nexport interface CancellationReason {\n /** The marketplace's own code, sent verbatim. */\n code: string;\n /** The label the host was configured with for this code (a named pack). */\n label: string;\n /** This reason means \"an item is unavailable\": the host preselects it when stock is short. */\n itemUnavailable: boolean;\n /** The marketplace requires the offending SKUs with this reason. */\n needsItems: boolean;\n}\n\n/** The order an outbound call is about, as the engine knows it. */\nexport interface OutboundOrderRef {\n externalOrderId: string;\n externalDisplayId: string | null;\n /** The host's own id for the order. */\n hostOrderCode: string;\n /** When the engine recorded the order. */\n placedAt: Date;\n}\n\n/** A per-engine token cache an adapter reads and fills. Never persisted. */\nexport type AdapterTokenCache = Map<string, { token: string; expiresAt: number }>;\n\n/**\n * A connection LINKED through the software's own app (FUT-5613): the store's\n * access token comes from its refresh token, not from a client-credentials\n * grant. `key` is where the token sits in {@link AdapterTokenCache} (delete it\n * to forget a token the marketplace refused); `accessToken` answers the cached\n * one or refreshes, once per connection however many calls ask at once.\n */\nexport interface AdapterGrant {\n key: string;\n accessToken(): Promise<{ token: string } | OutboundResult>;\n}\n\n/** What one outbound call is handed. */\nexport interface AdapterCallContext {\n http: MarketplaceHttp;\n /** The store's own credentials, or, for a linked connection, the software's app. */\n credentials: MarketplaceCredentials;\n environment: \"SANDBOX\" | \"PRODUCTION\";\n /** Written to no row, log or audit entry: memory only, per process. */\n tokens: AdapterTokenCache;\n now: Date;\n /** Present for a linked connection: the token comes from here, never from a client-credentials grant. */\n grant?: AdapterGrant;\n}\n\n/** One outbound call's answer, in the three shapes the engine acts on. */\nexport type OutboundResult =\n /** 2xx. For a marketplace whose outcome is asynchronous, \"the request was taken\". */\n | { kind: \"accepted\" }\n /**\n * A final 4xx (not 408/425/429): never retried. `own` marks a refusal that\n * is not the marketplace's judgement of the order: our credentials were not\n * accepted, or our request was malformed. A cancellation request that ends\n * so fails as UNREACHABLE, not REFUSED.\n */\n | { kind: \"refused\"; status: number; message: string; own?: true }\n /** 408, 425, 429, 5xx, a timeout, a network error: retried until the last attempt. */\n | { kind: \"retry\"; reason: string };\n\n/**\n * One order-body fetch's answer: the order, normalized, or the same refusal and\n * retry shapes an outbound call answers with (a 404 for an expired order is a\n * refusal; a 5xx, a timeout or a 429 is a retry).\n */\nexport type FetchOrderResult =\n | { kind: \"order\"; order: NormalizedMarketplaceOrder }\n | Exclude<OutboundResult, { kind: \"accepted\" }>;\n\n/** What a cancellation request carries. */\nexport interface CancellationRequestInput {\n reason: CancellationReason;\n /** Free text from the store; empty means \"the reason's own label\". */\n text: string;\n mode: \"MANUAL\" | \"AUTO\";\n offendingSkus: readonly string[];\n}\n\n/** One marketplace, in and out. */\nexport interface MarketplaceAdapter extends LogisticsAdapter {\n readonly provider: MarketplaceProvider;\n readonly capabilities: MarketplaceCapabilities;\n /** Inbound: one delivery into the canonical shape, or null when it carries no order id. */\n normalize(payload: unknown): NormalizedEvent | null;\n /** Which header carries this marketplace's signature, read off the request. */\n readSignature(header: (name: string) => string | null): string | null;\n /** Is this delivery's signature the one this store's secret would produce? */\n verifySignature(rawBody: string, signature: string | null, secret: string | null): boolean;\n /**\n * The marketplace's documented reasons, static and offline: a dialog never\n * waits on the network. With `orderCancellationReasons`, the fallback of an\n * order whose own list could not be read.\n */\n cancellationReasons(): readonly CancellationReason[];\n /** Tell the marketplace the store accepted the order. */\n confirm(\n ctx: AdapterCallContext,\n order: OutboundOrderRef,\n input: { preparationMinutes: number | null },\n ): Promise<OutboundResult>;\n /** Ask the marketplace to cancel the order, with one of its own reasons. */\n requestCancellation(\n ctx: AdapterCallContext,\n order: OutboundOrderRef,\n input: CancellationRequestInput,\n ): Promise<OutboundResult>;\n /**\n * OPTIONAL. Whether this marketplace takes this step for this kind of order,\n * answered offline, with no call: the job asks it BEFORE it claims anything\n * (an unsupported step leaves no row). Absent: every step in\n * `capabilities.statusSteps` is taken for every order.\n */\n statusSupported?(facts: StatusFacts): boolean;\n /**\n * OPTIONAL. Tell the marketplace the order reached a step (FUT-4653). Called\n * only from the `marketplace.outbound` job, action `status`. `unsupported`\n * (no endpoint for this step and this kind of order) ends the job with no\n * row. Absent: the marketplace is told nothing.\n */\n informStatus?(\n ctx: AdapterCallContext,\n order: OutboundOrderRef,\n facts: StatusFacts,\n ): Promise<OutboundResult | { kind: \"unsupported\" }>;\n /**\n * OPTIONAL. The step that must be told before this one for this kind of\n * order (FUT-5984: iFood's dispatch of a merchant bag follows its\n * `readyToPickup`), or null. The status job sends it first when it is not\n * told yet.\n */\n statusPrerequisite?(facts: StatusFacts): StatusStep | null;\n /**\n * OPTIONAL. A delivery that is the marketplace's presence heartbeat, not an\n * event (FUT-5984: iFood's `KEEPALIVE`), or null. Answered 202 once its\n * signature is proved, with nothing recorded.\n */\n presence?(payload: unknown): PresenceProbe | null;\n /** OPTIONAL. Acknowledging recorded events (FUT-5984). Absent: nothing is acknowledged. */\n readonly acknowledgement?: MarketplaceAcknowledgement;\n /**\n * OPTIONAL. Read the reasons the marketplace accepts for cancelling THIS\n * order (FUT-5984: iFood's `GET /orders/{id}/cancellationReasons`). Called\n * only from the `marketplace.cancellation-reasons` job. Absent: the static\n * `cancellationReasons()` are every order's.\n */\n orderCancellationReasons?(ctx: AdapterCallContext, order: { externalOrderId: string }): Promise<OrderCancellationReasonsResult>;\n /**\n * OPTIONAL. Fetch the order an event announced with `orderToFetch` (a\n * marketplace whose events carry no order body). Called only from the\n * `marketplace.fetch-order` job. An adapter whose events always carry the\n * order leaves it out. A final `refused` marked `own` with a 4xx status is\n * our credentials refused: the engine stamps the connection FAILED.\n */\n fetchOrder?(ctx: AdapterCallContext, order: { externalOrderId: string }): Promise<FetchOrderResult>;\n /**\n * OPTIONAL. Publishing the store's products to this marketplace's catalogue\n * (FUT-4768): `push` (the adapter writes each item) or `pull` (the\n * marketplace reads a menu document the host serves). Absent: the\n * marketplace cannot be published to, and the host says so.\n */\n readonly catalogue?: MarketplaceCatalogue;\n /**\n * OPTIONAL. Reading the menu the store already keeps on this marketplace,\n * through its own connection, for the host to import (FUT-951). Absent: the\n * menu cannot be read through an API, and the host says so.\n */\n readonly catalogueReader?: CatalogueReader;\n /**\n * OPTIONAL. Closing the store on this marketplace for a while, and opening\n * it again (FUT-4851). Absent: the marketplace cannot be paused through an\n * API, and the host says so.\n */\n readonly availability?: MarketplaceAvailability;\n /**\n * OPTIONAL. Linking a store through the software's own app on this\n * marketplace (FUT-5613). Absent: a store connects with its own credentials only.\n */\n readonly linking?: MarketplaceLinking;\n /**\n * OPTIONAL. Linking a store through the software's CENTRALIZED app (FUT-5798):\n * the store authorizes the app on the portal and picks its store from the\n * app's list; no code, no token of its own. Wins over `linking` when both are set.\n */\n readonly appLinking?: MarketplaceAppLinking;\n /**\n * OPTIONAL. The marketplace's own courier (FUT-5665): the pickup-code check\n * and the tracking read. Absent: neither is offered, and the host says so.\n */\n readonly courier?: MarketplaceCourierApi;\n /** OPTIONAL (FUT-6099). Answering the buyer's disputes; present with `capabilities.disputes`. */\n readonly disputes?: MarketplaceDisputeApi;\n /** Where \"open it on the marketplace\" goes: the order when `perOrderAppLink`, else the portal. Always https. */\n appLink(order: Pick<OutboundOrderRef, \"externalOrderId\" | \"externalDisplayId\">): string;\n}\n\n/**\n * The 4xx statuses that are NOT a refusal: a request timeout (408), \"too\n * early\" (425) and a rate limit (429) say \"ask again later\" by HTTP's own\n * semantics, and a marketplace rate-limits its merchant API.\n */\nconst TRANSIENT_CLIENT_STATUSES = new Set([408, 425, 429]);\n\n/**\n * Read one HTTP answer the way the engine acts on it. Shared by every adapter\n * whose API speaks plain status codes, so the rule is one rule rather than one\n * per marketplace: 2xx accepted; a 4xx other than 408/425/429 refused and\n * final; everything else (408, 425, 429, 5xx, anything unexpected) retried.\n */\nexport function outboundResultOf(response: MarketplaceHttpResponse): OutboundResult {\n if (response.status >= 200 && response.status < 300) return { kind: \"accepted\" };\n const message = response.body.slice(0, 300);\n const refusal = response.status >= 400 && response.status < 500 && !TRANSIENT_CLIENT_STATUSES.has(response.status);\n if (refusal) return { kind: \"refused\", status: response.status, message };\n return { kind: \"retry\", reason: `status ${response.status}: ${message}` };\n}\n\n/**\n * {@link outboundResultOf} for a token grant: a final 4xx there says our\n * credentials were not accepted, never a judgement of any order, so it is an\n * `own` refusal.\n */\nexport function tokenGrantResultOf(response: MarketplaceHttpResponse): OutboundResult {\n const result = outboundResultOf(response);\n return result.kind === \"refused\" ? { ...result, own: true } : result;\n}\n\n/** A call that never got an answer is a retry, with the reason a log can read. */\nexport async function answered(call: () => Promise<OutboundResult>): Promise<OutboundResult> {\n try {\n return await call();\n } catch (error) {\n return { kind: \"retry\", reason: error instanceof Error ? error.message : String(error) };\n }\n}\n"],"mappings":";;;;;AA8WA,IAAM,4BAA4B,oBAAI,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC;AAQlD,SAAS,iBAAiB,UAAmD;AAClF,MAAI,SAAS,UAAU,OAAO,SAAS,SAAS,IAAK,QAAO,EAAE,MAAM,WAAW;AAC/E,QAAM,UAAU,SAAS,KAAK,MAAM,GAAG,GAAG;AAC1C,QAAM,UAAU,SAAS,UAAU,OAAO,SAAS,SAAS,OAAO,CAAC,0BAA0B,IAAI,SAAS,MAAM;AACjH,MAAI,QAAS,QAAO,EAAE,MAAM,WAAW,QAAQ,SAAS,QAAQ,QAAQ;AACxE,SAAO,EAAE,MAAM,SAAS,QAAQ,UAAU,SAAS,MAAM,KAAK,OAAO,GAAG;AAC1E;AANgB;AAaT,SAAS,mBAAmB,UAAmD;AACpF,QAAM,SAAS,iBAAiB,QAAQ;AACxC,SAAO,OAAO,SAAS,YAAY,EAAE,GAAG,QAAQ,KAAK,KAAK,IAAI;AAChE;AAHgB;AAMhB,eAAsB,SAAS,MAA8D;AAC3F,MAAI;AACF,WAAO,MAAM,KAAK;AAAA,EACpB,SAAS,OAAO;AACd,WAAO,EAAE,MAAM,SAAS,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE;AAAA,EACzF;AACF;AANsB;","names":[]}
@@ -1,4 +1,4 @@
1
- import { O as OutboundResult } from './adapter-CxzF-qGx.js';
1
+ import { O as OutboundResult } from './adapter-ZpAWKoCk.js';
2
2
 
3
3
  /**
4
4
  * The HTTP half every Open Delivery adapter shares: the token grant and its
@@ -1,4 +1,4 @@
1
- import { aj as MarketplaceDeliveredBy, aA as NormalizedLineOption, as as MarketplaceLinkAttemptDelegate, an as MarketplaceDisputeDelegate, w as CatalogueItem, v as CatalogueImage, a as NormalizedMarketplaceOrder, N as NormalizedEvent, aO as StatusStep, j as NormalizedCourierEvent, ae as MarketplaceCourierFacts, ac as MarketplaceCourierAnswer, aL as PickupCodeValidation, am as MarketplaceDisputeChange, ao as MarketplaceHttp, a8 as MarketplaceAppCredentialsPort, c as MarketplaceAdapter, m as MarketplaceProvider, ai as MarketplaceCredentials, T as CatalogueWarningCode, aM as PresenceProbe, n as CancellationReason, a6 as LinkedMerchant, _ as DisputeFailureCode, $ as DisputeItem, W as DisputeAlternative, a1 as DisputeReason, a0 as DisputeOutcome, ar as MarketplaceLifecycle, af as MarketplaceCourierStep, ad as MarketplaceCourierEngine, aI as OutboundOrderRef, b as CatalogueMenuOptions, E as CatalogueReadResult } from './adapter-CxzF-qGx.js';
1
+ import { aq as MarketplaceDeliveredBy, aH as NormalizedLineOption, az as MarketplaceLinkAttemptDelegate, au as MarketplaceDisputeDelegate, x as CatalogueItem, w as CatalogueImage, b0 as LogisticsPorts, b1 as LogisticsOrderPort, a as NormalizedMarketplaceOrder, N as NormalizedEvent, aV as StatusStep, j as NormalizedCourierEvent, al as MarketplaceCourierFacts, aj as MarketplaceCourierAnswer, aS as PickupCodeValidation, at as MarketplaceDisputeChange, av as MarketplaceHttp, af as MarketplaceAppCredentialsPort, c as MarketplaceAdapter, ac as LogisticsStep, ay as MarketplaceLifecycle, am as MarketplaceCourierStep, X as DeliveryCodeAnswer, n as MarketplaceProvider, ap as MarketplaceCredentials, U as CatalogueWarningCode, aT as PresenceProbe, o as CancellationReason, aa as LinkedMerchant, a0 as DisputeFailureCode, a1 as DisputeItem, Y as DisputeAlternative, a3 as DisputeReason, a2 as DisputeOutcome, ak as MarketplaceCourierEngine, b2 as MarketplaceLogisticsEngine, aP as OutboundOrderRef, b as CatalogueMenuOptions, G as CatalogueReadResult } from './adapter-ZpAWKoCk.js';
2
2
 
3
3
  /** What the engine tells the host about the order a lifecycle event names. */
4
4
  interface MarketplaceLifecycleFacts {
@@ -197,6 +197,10 @@ interface MarketplaceDb {
197
197
  updateMany(args: unknown): Promise<{
198
198
  count: number;
199
199
  }>;
200
+ /** OPTIONAL (FUT-6166): a Logistics run lets go of its claims when the order has no courier now. */
201
+ deleteMany?(args: unknown): Promise<{
202
+ count: number;
203
+ }>;
200
204
  };
201
205
  marketplaceLinkAttempt?: MarketplaceLinkAttemptDelegate;
202
206
  /** OPTIONAL (FUT-6099): the buyer's disputes, migration `20261203190000_marketplace_disputes`. */
@@ -223,7 +227,7 @@ interface MarketplaceAdmissionRequest {
223
227
  * transition has already been claimed and committed when they are called, and
224
228
  * a host that fails its half must not un-decide the acceptance.
225
229
  */
226
- interface MarketplaceOrderPort {
230
+ interface MarketplaceOrderPort extends LogisticsOrderPort {
227
231
  /**
228
232
  * Judge a decision BEFORE its claim commits, inside the claim's
229
233
  * transaction: the stock check (and the draw) of an accept, anything the
@@ -390,7 +394,7 @@ interface MarketplaceCataloguePort {
390
394
  image(url: string): Promise<CatalogueImage | null>;
391
395
  }
392
396
  /** Everything the host plugs in. */
393
- interface MarketplacePorts {
397
+ interface MarketplacePorts extends LogisticsPorts {
394
398
  db: () => Promise<MarketplaceDb>;
395
399
  /**
396
400
  * Run `fn` in ONE database transaction and hand it the transaction's client
@@ -445,6 +449,168 @@ interface MarketplaceEngineConfig extends MarketplacePorts {
445
449
  adapters: readonly MarketplaceAdapter[];
446
450
  }
447
451
 
452
+ /**
453
+ * The outbound job's name and payload — what a decision QUEUES.
454
+ *
455
+ * No path that answers a request ever calls a marketplace: an aceite, a
456
+ * refusal, a webhook and an ingest only enqueue this, and the job does the
457
+ * call. The payload carries identifiers only; the reason code and every
458
+ * outcome live on the acceptance row, so a replayed or duplicated job reads
459
+ * the truth rather than a stale copy of it.
460
+ */
461
+ /** The wire name, `<namespace>.<blueprint>` as the jobs contribution binds it. */
462
+ declare const MARKETPLACE_OUTBOUND_JOB = "marketplace.outbound";
463
+ /**
464
+ * What goes out: the store's aceite, the store's cancellation request, a
465
+ * step of the order the store reached (`status`, FUT-4653), or the pickup code
466
+ * the store checked at the hand-over (`validatePickupCode`, FUT-5665).
467
+ */
468
+ type OutboundAction = "confirm" | "requestCancellation" | "status" | "validatePickupCode" | "logistics";
469
+ /** The outbound job's payload. Identifiers only. */
470
+ interface OutboundJobPayload {
471
+ clientId: string;
472
+ orderId: string;
473
+ action: OutboundAction;
474
+ /** OPTIONAL. The step a `status` call tells the marketplace about; absent on every other action. */
475
+ step?: StatusStep;
476
+ /**
477
+ * OPTIONAL. The key of the move (or of the sweep's re-claim) a `status` call
478
+ * belongs to: the owner of its SENDING claim. Absent on every other action.
479
+ */
480
+ claimKey?: string;
481
+ /**
482
+ * OPTIONAL. The pickup code a `validatePickupCode` call sends; absent on every
483
+ * other action. The one non-identifier in the payload: a short-lived code the
484
+ * job needs to send, which no log line prints.
485
+ */
486
+ code?: string;
487
+ /** OPTIONAL (FUT-6166). The step a `logistics` call sends up to; absent on every other action. */
488
+ logisticsStep?: LogisticsStep;
489
+ }
490
+ /** The dedupe key: at most one queued call per (order, action). */
491
+ declare function outboundDedupeKey(payload: OutboundJobPayload): string;
492
+
493
+ /**
494
+ * Normalized marketplace order → the host's own order.
495
+ *
496
+ * The rule this module is written around, stated once so every decision below
497
+ * reads against it: **losing a paid marketplace order is the one unforgivable
498
+ * failure.** An unmapped SKU, a buyer with no name, a total that does not equal
499
+ * the line sum — none of them reject the order. They land, flagged, on a screen
500
+ * a human can act on. The only thing that stops an ingestion is a condition
501
+ * under which persisting would be WRONG rather than incomplete.
502
+ *
503
+ * Idempotent on `(provider, externalOrderId)`, which the acceptance table's
504
+ * unique enforces. That is what makes a redelivered webhook, a reconciliation
505
+ * poll racing it, and a retry after a crash all safe: each either creates the
506
+ * one order or finds it already there. The pre-read below is a fast path, not
507
+ * the guarantee — two concurrent deliveries both miss it and only one of them
508
+ * reaches a row.
509
+ */
510
+ /** What one ingestion did. */
511
+ interface IngestResult {
512
+ /** The HOST's order id. */
513
+ orderId: string;
514
+ /** False when the order already existed — a redelivery, not a second sale. */
515
+ created: boolean;
516
+ /** SKUs that arrived with nothing behind them, in this order. */
517
+ unmappedSkus: string[];
518
+ /**
519
+ * Whether this order was born accepted: the connection auto-accepts AND the
520
+ * host's `mayAutoAccept`, when bound, allowed it.
521
+ */
522
+ autoAccepted: boolean;
523
+ }
524
+ /** The store's operating decisions, read from the connection at ingest time. */
525
+ interface IngestSettings {
526
+ autoAccept: boolean;
527
+ ackSlaSeconds: number;
528
+ /**
529
+ * OPTIONAL. The connection's switch for following the marketplace's status
530
+ * (FUT-4653). Absent is OFF: a host that builds settings by hand keeps the
531
+ * behaviour it had before the switch existed.
532
+ */
533
+ followStatus?: boolean;
534
+ }
535
+
536
+ /** How a delivery ended. `duplicate` and `ignored` are both ordinary outcomes. */
537
+ type DeliveryOutcome = {
538
+ kind: "ingested";
539
+ orderId: string;
540
+ unmappedSkus: string[];
541
+ }
542
+ /** A lifecycle event moved the order forward, through the host's `onLifecycle` (FUT-4653). */
543
+ | {
544
+ kind: "moved";
545
+ orderId: string;
546
+ lifecycle: MarketplaceLifecycle;
547
+ }
548
+ /** The marketplace asked the customer's delivery code; the host stored it (FUT-6167). */
549
+ | {
550
+ kind: "deliveryCodeRequested";
551
+ orderId: string;
552
+ }
553
+ /** A courier event's facts were stored by the host's `onCourier` (FUT-5665). */
554
+ | {
555
+ kind: "courier";
556
+ orderId: string;
557
+ step: MarketplaceCourierStep;
558
+ }
559
+ /**
560
+ * The store accepted it in the marketplace's own app (FUT-5653): `accepted`
561
+ * when the host admitted it here too, else it waits AWAITING for a person
562
+ * (with the host's `refusal`, when it refused), never expired.
563
+ */
564
+ | {
565
+ kind: "confirmedByMarketplace";
566
+ orderId: string;
567
+ accepted: boolean;
568
+ refusal?: {
569
+ code: string;
570
+ message: string;
571
+ };
572
+ }
573
+ /** A dispute opened or closed on the order (FUT-6099); `unchanged` for a second event of one already kept. */
574
+ | {
575
+ kind: "dispute";
576
+ orderId: string;
577
+ disputeId: string;
578
+ change: "opened" | "settled" | "unchanged";
579
+ } | {
580
+ kind: "cancelled";
581
+ } | {
582
+ kind: "cancellationFailed";
583
+ }
584
+ /** Recorded; the order body is fetched by the `marketplace.fetch-order` job. */
585
+ | {
586
+ kind: "awaitingOrder";
587
+ } | {
588
+ kind: "duplicate";
589
+ } | {
590
+ kind: "ignored";
591
+ reason: string;
592
+ } | {
593
+ kind: "failed";
594
+ reason: string;
595
+ };
596
+
597
+ /** What the courier typed, for one of the host's orders. */
598
+ interface VerifyDeliveryCodeInput {
599
+ clientId: string;
600
+ /** The host's own order id. */
601
+ orderId: string;
602
+ code: string;
603
+ }
604
+ /** The engine's delivery-code half (`MarketplaceEngine` extends it). */
605
+ interface MarketplaceDeliveryCodeEngine {
606
+ /**
607
+ * Check the customer's delivery code with the marketplace (FUT-6167). Never
608
+ * throws; UNAVAILABLE says why nothing could be checked (no such order, the
609
+ * store does not carry it, no Logistics app, the marketplace did not answer).
610
+ */
611
+ verifyDeliveryCode(input: VerifyDeliveryCodeInput): Promise<DeliveryCodeAnswer>;
612
+ }
613
+
448
614
  /**
449
615
  * The acceptance clock — the store saying yes (or no) to an order.
450
616
  *
@@ -1269,105 +1435,6 @@ interface DisputeRow {
1269
1435
  /** A row as a host draws it. */
1270
1436
  declare function disputeView(row: DisputeRow): MarketplaceDisputeView;
1271
1437
 
1272
- /**
1273
- * Normalized marketplace order → the host's own order.
1274
- *
1275
- * The rule this module is written around, stated once so every decision below
1276
- * reads against it: **losing a paid marketplace order is the one unforgivable
1277
- * failure.** An unmapped SKU, a buyer with no name, a total that does not equal
1278
- * the line sum — none of them reject the order. They land, flagged, on a screen
1279
- * a human can act on. The only thing that stops an ingestion is a condition
1280
- * under which persisting would be WRONG rather than incomplete.
1281
- *
1282
- * Idempotent on `(provider, externalOrderId)`, which the acceptance table's
1283
- * unique enforces. That is what makes a redelivered webhook, a reconciliation
1284
- * poll racing it, and a retry after a crash all safe: each either creates the
1285
- * one order or finds it already there. The pre-read below is a fast path, not
1286
- * the guarantee — two concurrent deliveries both miss it and only one of them
1287
- * reaches a row.
1288
- */
1289
- /** What one ingestion did. */
1290
- interface IngestResult {
1291
- /** The HOST's order id. */
1292
- orderId: string;
1293
- /** False when the order already existed — a redelivery, not a second sale. */
1294
- created: boolean;
1295
- /** SKUs that arrived with nothing behind them, in this order. */
1296
- unmappedSkus: string[];
1297
- /**
1298
- * Whether this order was born accepted: the connection auto-accepts AND the
1299
- * host's `mayAutoAccept`, when bound, allowed it.
1300
- */
1301
- autoAccepted: boolean;
1302
- }
1303
- /** The store's operating decisions, read from the connection at ingest time. */
1304
- interface IngestSettings {
1305
- autoAccept: boolean;
1306
- ackSlaSeconds: number;
1307
- /**
1308
- * OPTIONAL. The connection's switch for following the marketplace's status
1309
- * (FUT-4653). Absent is OFF: a host that builds settings by hand keeps the
1310
- * behaviour it had before the switch existed.
1311
- */
1312
- followStatus?: boolean;
1313
- }
1314
-
1315
- /** How a delivery ended. `duplicate` and `ignored` are both ordinary outcomes. */
1316
- type DeliveryOutcome = {
1317
- kind: "ingested";
1318
- orderId: string;
1319
- unmappedSkus: string[];
1320
- }
1321
- /** A lifecycle event moved the order forward, through the host's `onLifecycle` (FUT-4653). */
1322
- | {
1323
- kind: "moved";
1324
- orderId: string;
1325
- lifecycle: MarketplaceLifecycle;
1326
- }
1327
- /** A courier event's facts were stored by the host's `onCourier` (FUT-5665). */
1328
- | {
1329
- kind: "courier";
1330
- orderId: string;
1331
- step: MarketplaceCourierStep;
1332
- }
1333
- /**
1334
- * The store accepted it in the marketplace's own app (FUT-5653): `accepted`
1335
- * when the host admitted it here too, else it waits AWAITING for a person
1336
- * (with the host's `refusal`, when it refused), never expired.
1337
- */
1338
- | {
1339
- kind: "confirmedByMarketplace";
1340
- orderId: string;
1341
- accepted: boolean;
1342
- refusal?: {
1343
- code: string;
1344
- message: string;
1345
- };
1346
- }
1347
- /** A dispute opened or closed on the order (FUT-6099); `unchanged` for a second event of one already kept. */
1348
- | {
1349
- kind: "dispute";
1350
- orderId: string;
1351
- disputeId: string;
1352
- change: "opened" | "settled" | "unchanged";
1353
- } | {
1354
- kind: "cancelled";
1355
- } | {
1356
- kind: "cancellationFailed";
1357
- }
1358
- /** Recorded; the order body is fetched by the `marketplace.fetch-order` job. */
1359
- | {
1360
- kind: "awaitingOrder";
1361
- } | {
1362
- kind: "duplicate";
1363
- } | {
1364
- kind: "ignored";
1365
- reason: string;
1366
- } | {
1367
- kind: "failed";
1368
- reason: string;
1369
- };
1370
-
1371
1438
  /**
1372
1439
  * A marketplace's disputes (FUT-6099), the engine's half: the event that opens
1373
1440
  * or closes one is kept per order, and the store's answer is claimed here and
@@ -1541,45 +1608,6 @@ interface PendingInboxEvent {
1541
1608
  receivedAt?: Date | null;
1542
1609
  }
1543
1610
 
1544
- /**
1545
- * The outbound job's name and payload — what a decision QUEUES.
1546
- *
1547
- * No path that answers a request ever calls a marketplace: an aceite, a
1548
- * refusal, a webhook and an ingest only enqueue this, and the job does the
1549
- * call. The payload carries identifiers only; the reason code and every
1550
- * outcome live on the acceptance row, so a replayed or duplicated job reads
1551
- * the truth rather than a stale copy of it.
1552
- */
1553
- /** The wire name, `<namespace>.<blueprint>` as the jobs contribution binds it. */
1554
- declare const MARKETPLACE_OUTBOUND_JOB = "marketplace.outbound";
1555
- /**
1556
- * What goes out: the store's aceite, the store's cancellation request, a
1557
- * step of the order the store reached (`status`, FUT-4653), or the pickup code
1558
- * the store checked at the hand-over (`validatePickupCode`, FUT-5665).
1559
- */
1560
- type OutboundAction = "confirm" | "requestCancellation" | "status" | "validatePickupCode";
1561
- /** The outbound job's payload. Identifiers only. */
1562
- interface OutboundJobPayload {
1563
- clientId: string;
1564
- orderId: string;
1565
- action: OutboundAction;
1566
- /** OPTIONAL. The step a `status` call tells the marketplace about; absent on every other action. */
1567
- step?: StatusStep;
1568
- /**
1569
- * OPTIONAL. The key of the move (or of the sweep's re-claim) a `status` call
1570
- * belongs to: the owner of its SENDING claim. Absent on every other action.
1571
- */
1572
- claimKey?: string;
1573
- /**
1574
- * OPTIONAL. The pickup code a `validatePickupCode` call sends; absent on every
1575
- * other action. The one non-identifier in the payload: a short-lived code the
1576
- * job needs to send, which no log line prints.
1577
- */
1578
- code?: string;
1579
- }
1580
- /** The dedupe key: at most one queued call per (order, action). */
1581
- declare function outboundDedupeKey(payload: OutboundJobPayload): string;
1582
-
1583
1611
  /**
1584
1612
  * The outbound engine: one queued call to a marketplace, start to finish.
1585
1613
  *
@@ -1869,7 +1897,7 @@ interface MarketplaceOrderState {
1869
1897
  }
1870
1898
 
1871
1899
  /** Everything the mounted engine can do, with the ports and adapters bound in. */
1872
- interface MarketplaceEngine extends MarketplaceCourierEngine, MarketplaceConformityEngine, MarketplaceLinkEngine, MarketplaceDisputeEngine {
1900
+ interface MarketplaceEngine extends MarketplaceCourierEngine, MarketplaceConformityEngine, MarketplaceLinkEngine, MarketplaceDisputeEngine, MarketplaceLogisticsEngine, MarketplaceDeliveryCodeEngine {
1873
1901
  /** Every registered marketplace, in registration order. */
1874
1902
  providers(): readonly MarketplaceProvider[];
1875
1903
  /** Whether a provider id (a URL segment, a body field) names a registered adapter. */
@@ -2058,4 +2086,4 @@ interface MarketplaceEngine extends MarketplaceCourierEngine, MarketplaceConform
2058
2086
  */
2059
2087
  declare function createMarketplaceEngine(config: MarketplaceEngineConfig): MarketplaceEngine;
2060
2088
 
2061
- export { type IngestionTarget as $, type AcceptanceDecision as A, type BulkProblem as B, type CancellationFailureReason as C, type CatalogueStatus as D, type CatalogueTarget as E, type DecideManyResult as F, type DecidedRow as G, type DecisionInput as H, type DecisionProblem as I, type DecisionProblemCode as J, type DecisionResult as K, type DeliveryOutcome as L, type DisputeAnswerInput as M, type DisputeAnswerJobPayload as N, type DisputeAnswerOutcome as O, DisputeAnswerRetryError as P, type DisputeAnswerView as Q, type DisputeRefusalCode as R, type DisputeRow as S, type DisputeStatus as T, type ExpirySweepResult as U, type FetchOrderJobPayload as V, type FetchOrderOutcome as W, FetchOrderRetryError as X, type InformStatusInput as Y, type IngestResult as Z, type IngestSettings as _, type AcceptanceStatus as a, disputeView as a$, type IntegrationRowInput as a0, type LinkFailure as a1, type LinkFinished as a2, type LinkPendingView as a3, type LinkRefusalCode as a4, MARKETPLACE_ACKNOWLEDGE_JOB as a5, MARKETPLACE_AVAILABILITY_JOB as a6, MARKETPLACE_CANCELLATION_REASONS_JOB as a7, MARKETPLACE_CATALOGUE_JOB as a8, MARKETPLACE_DISPUTE_ANSWER_JOB as a9, type MarketplaceRefusal as aA, type MarketplaceSecretsPort as aB, type MenuLinkRowInput as aC, OUTBOUND_GIVE_UP_MS as aD, OUTBOUND_STALE_MS as aE, type OutboundAction as aF, type OutboundAttempt as aG, type OutboundJobPayload as aH, type OutboundOutcome as aI, OutboundRetryError as aJ, type OutboundSweepResult as aK, type PauseOutcome as aL, type PauseStoreInput as aM, type PauseStoreResult as aN, type PendingAcceptance as aO, type PendingInboxEvent as aP, type ResolvedOrderLine as aQ, type ResumeOutcome as aR, STORE_PAUSE_LEASE_MS as aS, type SaveMarketplaceIntegrationInput as aT, type StoreAvailabilityView as aU, type StorePauseFailureCode as aV, type StorePauseState as aW, type StorePauseWanted as aX, availabilityDedupeKey as aY, catalogueDedupeKey as aZ, createMarketplaceEngine as a_, MARKETPLACE_FETCH_ORDER_JOB as aa, MARKETPLACE_OUTBOUND_JOB as ab, type MarketplaceAdmission as ac, type MarketplaceAdmissionRequest as ad, type MarketplaceAdmissionResult as ae, type MarketplaceAuditEntry as af, type MarketplaceAuditPort as ag, type MarketplaceAuthMode as ah, type MarketplaceCataloguePort as ai, type MarketplaceClockPort as aj, type MarketplaceConformityEngine as ak, type MarketplaceDb as al, type MarketplaceDisputeEngine as am, type MarketplaceDisputeView as an, type MarketplaceEngine as ao, type MarketplaceEngineConfig as ap, type MarketplaceEnqueuePort as aq, type MarketplaceIntegrationView as ar, type MarketplaceLifecycleAnswer as as, type MarketplaceLifecycleFacts as at, type MarketplaceLogger as au, type MarketplaceMenuLinkView as av, type MarketplaceOrderPort as aw, type MarketplaceOrderState as ax, type MarketplaceOrderSummary as ay, type MarketplacePorts as az, type AcknowledgeJobPayload as b, outboundDedupeKey as b0, type AcknowledgeOutcome as c, AcknowledgeRetryError as d, type AnswerDisputeResult as e, type AvailabilityJobPayload as f, type AvailabilityOutcome as g, AvailabilityRetryError as h, type AvailabilitySweepResult as i, type BulkProblemCode as j, type BulkResult as k, type CancellationReasonsJobPayload as l, type CancellationReasonsOutcome as m, CancellationReasonsRetryError as n, type CancellationStatus as o, type CatalogueAction as p, type CatalogueActionResult as q, type CatalogueDocumentResult as r, type CatalogueFailedAction as s, type CatalogueFailureCode as t, type CatalogueJobPayload as u, type CatalogueOutcome as v, type CataloguePublicationView as w, type CataloguePublishInput as x, type CatalogueRefusalCode as y, CatalogueRetryError as z };
2089
+ export { type IngestionTarget as $, type AcceptanceDecision as A, type BulkProblem as B, type CancellationFailureReason as C, type CatalogueStatus as D, type CatalogueTarget as E, type DecideManyResult as F, type DecidedRow as G, type DecisionInput as H, type DecisionProblem as I, type DecisionProblemCode as J, type DecisionResult as K, type DeliveryOutcome as L, type DisputeAnswerInput as M, type DisputeAnswerJobPayload as N, type DisputeAnswerOutcome as O, DisputeAnswerRetryError as P, type DisputeAnswerView as Q, type DisputeRefusalCode as R, type DisputeRow as S, type DisputeStatus as T, type ExpirySweepResult as U, type FetchOrderJobPayload as V, type FetchOrderOutcome as W, FetchOrderRetryError as X, type InformStatusInput as Y, type IngestResult as Z, type IngestSettings as _, type AcceptanceStatus as a, catalogueDedupeKey as a$, type IntegrationRowInput as a0, type LinkFailure as a1, type LinkFinished as a2, type LinkPendingView as a3, type LinkRefusalCode as a4, MARKETPLACE_ACKNOWLEDGE_JOB as a5, MARKETPLACE_AVAILABILITY_JOB as a6, MARKETPLACE_CANCELLATION_REASONS_JOB as a7, MARKETPLACE_CATALOGUE_JOB as a8, MARKETPLACE_DISPUTE_ANSWER_JOB as a9, type MarketplacePorts as aA, type MarketplaceRefusal as aB, type MarketplaceSecretsPort as aC, type MenuLinkRowInput as aD, OUTBOUND_GIVE_UP_MS as aE, OUTBOUND_STALE_MS as aF, type OutboundAction as aG, type OutboundAttempt as aH, type OutboundJobPayload as aI, type OutboundOutcome as aJ, OutboundRetryError as aK, type OutboundSweepResult as aL, type PauseOutcome as aM, type PauseStoreInput as aN, type PauseStoreResult as aO, type PendingAcceptance as aP, type PendingInboxEvent as aQ, type ResolvedOrderLine as aR, type ResumeOutcome as aS, STORE_PAUSE_LEASE_MS as aT, type SaveMarketplaceIntegrationInput as aU, type StoreAvailabilityView as aV, type StorePauseFailureCode as aW, type StorePauseState as aX, type StorePauseWanted as aY, type VerifyDeliveryCodeInput as aZ, availabilityDedupeKey as a_, MARKETPLACE_FETCH_ORDER_JOB as aa, MARKETPLACE_OUTBOUND_JOB as ab, type MarketplaceAdmission as ac, type MarketplaceAdmissionRequest as ad, type MarketplaceAdmissionResult as ae, type MarketplaceAuditEntry as af, type MarketplaceAuditPort as ag, type MarketplaceAuthMode as ah, type MarketplaceCataloguePort as ai, type MarketplaceClockPort as aj, type MarketplaceConformityEngine as ak, type MarketplaceDb as al, type MarketplaceDeliveryCodeEngine as am, type MarketplaceDisputeEngine as an, type MarketplaceDisputeView as ao, type MarketplaceEngine as ap, type MarketplaceEngineConfig as aq, type MarketplaceEnqueuePort as ar, type MarketplaceIntegrationView as as, type MarketplaceLifecycleAnswer as at, type MarketplaceLifecycleFacts as au, type MarketplaceLogger as av, type MarketplaceMenuLinkView as aw, type MarketplaceOrderPort as ax, type MarketplaceOrderState as ay, type MarketplaceOrderSummary as az, type AcknowledgeJobPayload as b, createMarketplaceEngine as b0, disputeView as b1, outboundDedupeKey as b2, type AcknowledgeOutcome as c, AcknowledgeRetryError as d, type AnswerDisputeResult as e, type AvailabilityJobPayload as f, type AvailabilityOutcome as g, AvailabilityRetryError as h, type AvailabilitySweepResult as i, type BulkProblemCode as j, type BulkResult as k, type CancellationReasonsJobPayload as l, type CancellationReasonsOutcome as m, CancellationReasonsRetryError as n, type CancellationStatus as o, type CatalogueAction as p, type CatalogueActionResult as q, type CatalogueDocumentResult as r, type CatalogueFailedAction as s, type CatalogueFailureCode as t, type CatalogueJobPayload as u, type CatalogueOutcome as v, type CataloguePublicationView as w, type CataloguePublishInput as x, type CatalogueRefusalCode as y, CatalogueRetryError as z };
@@ -1,7 +1,7 @@
1
1
  import { Hono, Context } from 'hono';
2
2
  import { ApiMarketplace, MarketplaceApiConfig, MarketplaceActor } from '../server/index.js';
3
- import '../engine-Y6Rpf5p7.js';
4
- import '../adapter-CxzF-qGx.js';
3
+ import '../engine-DRRhAjZK.js';
4
+ import '../adapter-ZpAWKoCk.js';
5
5
  import '@12-apps/wiring';
6
6
  import 'zod';
7
7
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createApiMarketplace
3
- } from "../chunk-EABVLQKK.js";
3
+ } from "../chunk-BLHZ3MRB.js";
4
4
  import "../chunk-LO7OKO6V.js";
5
- import "../chunk-UZO2NILN.js";
6
- import "../chunk-KKFMDV5K.js";
5
+ import "../chunk-MDEIRGNL.js";
6
+ import "../chunk-Q5RMVNU5.js";
7
7
  import {
8
8
  __name
9
9
  } from "../chunk-7QVYU63E.js";
@@ -1,4 +1,4 @@
1
- import { N as NormalizedEvent, a as NormalizedMarketplaceOrder, A as AdapterCallContext, F as FetchOrderResult, d as PushCatalogue, e as CatalogueItemOut, f as CatalogueReader, g as MarketplaceLinking, h as MarketplaceAppLinking, i as MarketplaceCourierApi, j as NormalizedCourierEvent, M as MarketplaceAvailability, S as StorePauseRequest, k as StorePauseResult, l as StorePauseRef, O as OutboundResult, c as MarketplaceAdapter } from '../adapter-CxzF-qGx.js';
1
+ import { N as NormalizedEvent, a as NormalizedMarketplaceOrder, A as AdapterCallContext, F as FetchOrderResult, d as PushCatalogue, e as CatalogueItemOut, f as CatalogueReader, g as MarketplaceLinking, h as MarketplaceAppLinking, i as MarketplaceCourierApi, j as NormalizedCourierEvent, M as MarketplaceAvailability, S as StorePauseRequest, k as StorePauseResult, l as StorePauseRef, O as OutboundResult, m as MarketplaceLogistics, c as MarketplaceAdapter } from '../adapter-ZpAWKoCk.js';
2
2
 
3
3
  /**
4
4
  * The words the iFood adapter needs from its host, and nothing else.
@@ -182,6 +182,11 @@ type IfoodDeliveryCodeResult = {
182
182
  * no result carries iFood's answer body, so nothing here puts it in a log.
183
183
  */
184
184
  declare function ifoodLogisticsVerifyDeliveryCode(ctx: AdapterCallContext, externalOrderId: string, code: string): Promise<IfoodDeliveryCodeResult>;
185
+ /**
186
+ * The adapter's Logistics half (FUT-6166): the engine's steps on iFood's
187
+ * wire. An invalid driver is answered as the engine's `invalid`.
188
+ */
189
+ declare const IFOOD_LOGISTICS: MarketplaceLogistics;
185
190
 
186
191
  /**
187
192
  * `@12-apps/marketplace/ifood` — iFood, as one adapter on the engine.
@@ -212,4 +217,4 @@ interface IfoodAdapterConfig {
212
217
  */
213
218
  declare function createIfoodAdapter(config: IfoodAdapterConfig): MarketplaceAdapter;
214
219
 
215
- export { IFOOD_APPS_PORTAL_URL, IFOOD_APP_LINKING, IFOOD_AVAILABILITY, IFOOD_CANCELLATION_ANSWER_WINDOW_MS, IFOOD_CATALOGUE, IFOOD_CATALOGUE_READER, IFOOD_COURIER, IFOOD_IMAGE_BASE_URL, IFOOD_LINKING, IFOOD_LOGISTICS_STEPS, IFOOD_LOGISTICS_VEHICLES, IFOOD_PROVIDER, IFOOD_REASON_CODES, type IfoodAdapterConfig, type IfoodAdapterCopy, type IfoodDeliveryCodeResult, type IfoodLogisticsDriver, type IfoodLogisticsInvalid, type IfoodLogisticsStep, type IfoodLogisticsVehicle, type IfoodReasonCode, createIfoodAdapter, ifoodAddressLine, ifoodFetchOrder, ifoodItemBody, ifoodItemId, ifoodLocalTime, ifoodLogisticsAssignDriver, ifoodLogisticsStep, ifoodLogisticsStepsTo, ifoodLogisticsVerifyDeliveryCode, ifoodPause, ifoodProductId, ifoodResume, normalizeIfoodEvent, readIfoodCourierEvent, readIfoodOrder, readIfoodPresence, verifyIfoodSignature };
220
+ export { IFOOD_APPS_PORTAL_URL, IFOOD_APP_LINKING, IFOOD_AVAILABILITY, IFOOD_CANCELLATION_ANSWER_WINDOW_MS, IFOOD_CATALOGUE, IFOOD_CATALOGUE_READER, IFOOD_COURIER, IFOOD_IMAGE_BASE_URL, IFOOD_LINKING, IFOOD_LOGISTICS, IFOOD_LOGISTICS_STEPS, IFOOD_LOGISTICS_VEHICLES, IFOOD_PROVIDER, IFOOD_REASON_CODES, type IfoodAdapterConfig, type IfoodAdapterCopy, type IfoodDeliveryCodeResult, type IfoodLogisticsDriver, type IfoodLogisticsInvalid, type IfoodLogisticsStep, type IfoodLogisticsVehicle, type IfoodReasonCode, createIfoodAdapter, ifoodAddressLine, ifoodFetchOrder, ifoodItemBody, ifoodItemId, ifoodLocalTime, ifoodLogisticsAssignDriver, ifoodLogisticsStep, ifoodLogisticsStepsTo, ifoodLogisticsVerifyDeliveryCode, ifoodPause, ifoodProductId, ifoodResume, normalizeIfoodEvent, readIfoodCourierEvent, readIfoodOrder, readIfoodPresence, verifyIfoodSignature };