@12-apps/marketplace 1.17.0 → 1.18.1
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.
- package/ADOPTING.md +70 -0
- package/README.md +7 -7
- package/dist/99food/index.d.ts +2 -2
- package/dist/99food/index.js +2 -2
- package/dist/{adapter-CxzF-qGx.d.ts → adapter-ZpAWKoCk.d.ts} +116 -2
- package/dist/{chunk-7IYUO2KC.js → chunk-3B5EULS6.js} +2 -2
- package/dist/{chunk-EABVLQKK.js → chunk-BLHZ3MRB.js} +2 -2
- package/dist/{chunk-UZO2NILN.js → chunk-MDEIRGNL.js} +1067 -877
- package/dist/chunk-MDEIRGNL.js.map +1 -0
- package/dist/{chunk-KKFMDV5K.js → chunk-Q5RMVNU5.js} +1 -1
- package/dist/{chunk-KKFMDV5K.js.map → chunk-Q5RMVNU5.js.map} +1 -1
- package/dist/{chunk-CF5BSXE5.js → chunk-ZT6TZTLD.js} +1 -1
- package/dist/chunk-ZT6TZTLD.js.map +1 -0
- package/dist/{client-C-4QvVq3.d.ts → client-DpEq0yXb.d.ts} +1 -1
- package/dist/{engine-Y6Rpf5p7.d.ts → engine-DRRhAjZK.d.ts} +171 -143
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +3 -3
- package/dist/ifood/index.d.ts +7 -2
- package/dist/ifood/index.js +189 -107
- package/dist/ifood/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +76 -5
- package/dist/index.js.map +1 -1
- package/dist/keeta/index.d.ts +2 -2
- package/dist/keeta/index.js +2 -2
- package/dist/manifest/server.d.ts +2 -2
- package/dist/manifest/server.js +3 -3
- package/dist/rappi/index.d.ts +1 -1
- package/dist/rappi/index.js +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +3 -3
- package/package.json +1 -1
- package/prisma/marketplace.prisma +1 -1
- package/prisma/migrations/20261203200000_marketplace_status_logistics_steps/migration.sql +12 -0
- package/src/core/adapter.ts +2 -1
- package/src/core/delivery-code.ts +119 -0
- package/src/core/engine.ts +10 -2
- package/src/core/logistics.ts +388 -0
- package/src/core/outbound-queue.ts +6 -1
- package/src/core/outbound-sweep.ts +10 -5
- package/src/core/outbound.ts +4 -5
- package/src/core/pipeline.ts +6 -1
- package/src/core/ports.ts +5 -2
- package/src/core/status-job.ts +3 -0
- package/src/core/status-store.ts +2 -1
- package/src/core/types.ts +2 -0
- package/src/ifood/catalogs.ts +34 -0
- package/src/ifood/catalogue-read.ts +30 -10
- package/src/ifood/catalogue.ts +34 -9
- package/src/ifood/index.ts +3 -0
- package/src/ifood/logistics.ts +38 -0
- package/src/ifood/normalize.ts +11 -1
- package/src/index.ts +10 -0
- package/dist/chunk-CF5BSXE5.js.map +0 -1
- package/dist/chunk-UZO2NILN.js.map +0 -1
- /package/dist/{chunk-7IYUO2KC.js.map → chunk-3B5EULS6.js.map} +0 -0
- /package/dist/{chunk-EABVLQKK.js.map → chunk-BLHZ3MRB.js.map} +0 -0
package/ADOPTING.md
CHANGED
|
@@ -891,3 +891,73 @@ write-ups of iFood's handshake guide, not iFood's page. Not verified live:
|
|
|
891
891
|
| **Read** | `engine.disputes({ clientId, settledSince })` for the board (the host's own shift start), `{ orderIds }` for an order. Draw `status` OPEN (with `expiresAt`'s countdown; past it, the host's "deadline gone" line and no answer), SENDING / ANSWERED (what was sent, `answer`, and "waiting on the marketplace"; `failure: ALREADY_ANSWERED` means another answer stood), SETTLED (`settlement.outcome`). A `failure` on an OPEN dispute is the last answer's refusal: say so beside the answer controls. |
|
|
892
892
|
| **Answer** | `engine.answerDispute({ clientId, disputeId, orderId, answer })` (pass the order the person acted on: a dispute of another order is NOT_FOUND before anything is claimed) with `{ kind: "ACCEPT" }`, `{ kind: "REJECT", reasonCode }` or `{ kind: "ALTERNATIVE", alternativeId, amountCents? , minutes? }`. Answers `queued` with the view, or `refused` with `NOT_FOUND`, `ALREADY_ANSWERED`, `EXPIRED`, `UNSUPPORTED`, `INVALID_REASON`, `INVALID_ALTERNATIVE`, `INVALID_AMOUNT` or `INVALID_MINUTES`. Gate it with `marketplace:decide`. |
|
|
893
893
|
| **Capability** | `engine.adapter(provider)?.capabilities.disputes` (iFood only). Offer Recusar only when `rejectReasons` is not empty, and Propor only when `alternatives` is not empty. |
|
|
894
|
+
|
|
895
|
+
## 16. iFood Logistics: the job that reports the store's courier (FUT-6166)
|
|
896
|
+
|
|
897
|
+
§14's wire client, driven by the engine. The host binds two ports and calls one method:
|
|
898
|
+
|
|
899
|
+
- **`logisticsCredentials(provider, environment)`** (engine port, OPTIONAL): the
|
|
900
|
+
software's Logistics app, or null. It is a separate app from
|
|
901
|
+
`appCredentials`. Absent or null: no Logistics step is ever sent (logged at info).
|
|
902
|
+
- **`order.logisticsDriver(clientId, orderId)`** (order port, OPTIONAL): the
|
|
903
|
+
store's courier on the order, `{ name, phone, vehicle }`, or null. It is read
|
|
904
|
+
before the run claims anything, only while ASSIGNED is still owed, and is never
|
|
905
|
+
carried in the job's payload. Null or absent: the run is skipped, logged at
|
|
906
|
+
info, and lets go of any claim it held (through the status table's
|
|
907
|
+
`deleteMany`, which a Prisma delegate has; without it the claim waits for the
|
|
908
|
+
sweep's give-up). Answer null once the host's undo of a
|
|
909
|
+
dispatch took the courier off: that is the whole undo contract, since the
|
|
910
|
+
engine asks the host nothing else before it sends a Logistics step.
|
|
911
|
+
- **`engine.informLogistics({ clientId, orderId, step, at })`**: one enqueue of
|
|
912
|
+
`marketplace.outbound`, action `logistics`. It never throws. Steps:
|
|
913
|
+
`ASSIGNED`, `GOING_TO_ORIGIN`, `ARRIVED_AT_ORIGIN`, `DISPATCHED`,
|
|
914
|
+
`ARRIVED_AT_DESTINATION`.
|
|
915
|
+
|
|
916
|
+
The job runs only for an ACCEPTED order that the store carries
|
|
917
|
+
(`deliveredBy: MERCHANT`) with no standing cancellation request, and only on
|
|
918
|
+
an adapter with a `logistics` half (iFood). It sends every step not yet SENT,
|
|
919
|
+
in order, up to the one named. Each step has its own claim row,
|
|
920
|
+
`LOGISTICS_<STEP>`, in the status table. The table's `step` CHECK admits
|
|
921
|
+
those five values from migration `20261203200000_marketplace_status_logistics_steps`,
|
|
922
|
+
which the host takes in with `prisma:sync-partials` before it binds the job.
|
|
923
|
+
So a step is never sent twice, and a run waits while another run holds a
|
|
924
|
+
step's claim. A claim left SENDING is re-queued by the outbound sweep as a
|
|
925
|
+
`logistics` job up to its own step.
|
|
926
|
+
|
|
927
|
+
- While ASSIGNED is owed, the job reads the courier before it claims anything.
|
|
928
|
+
No courier now is a skip, not a failure: pass the board's undo window as
|
|
929
|
+
`delayMs`, and a dispatch undone inside it sends nothing, while a later
|
|
930
|
+
dispatch (a new `at`) still does. Once ASSIGNED went, the later steps are sent
|
|
931
|
+
without asking, so a host may clear the courier on a later move.
|
|
932
|
+
- A final refusal, an invalid driver or the last attempt marks the step FAILED and
|
|
933
|
+
stops the chain: the marketplace would refuse a later step out of order.
|
|
934
|
+
- A 429, 5xx or timeout is retried.
|
|
935
|
+
- Nothing here touches the order.
|
|
936
|
+
|
|
937
|
+
## 17. iFood Logistics: the customer's delivery code (FUT-6167)
|
|
938
|
+
|
|
939
|
+
When the store's own courier carries an iFood order, iFood can ask the courier
|
|
940
|
+
for the code the customer reads in the iFood app before the order counts as
|
|
941
|
+
delivered (`DELIVERY_DROP_CODE_REQUESTED`, code `DDCR`). The engine has two
|
|
942
|
+
halves for it; a host binds neither and nothing changes.
|
|
943
|
+
|
|
944
|
+
- **`order.onDeliveryCodeRequested(clientId, orderId)`**, optional. The event
|
|
945
|
+
normalizes as `deliveryCodeRequested: true`. For an ACCEPTED order the
|
|
946
|
+
engine calls the hook, settles the event PROCESSED and publishes; the
|
|
947
|
+
outcome is `{ kind: "deliveryCodeRequested", orderId }`. The hook must be
|
|
948
|
+
idempotent (a redelivery calls it again). Before its order exists the event
|
|
949
|
+
is deferred like any other; for an order in another state it is IGNORED.
|
|
950
|
+
Store the request on the order, so the courier's close asks for the code.
|
|
951
|
+
- **`engine.verifyDeliveryCode({ clientId, orderId, code })`**, called in the
|
|
952
|
+
courier's close request (the courier waits for it at the door, so it is
|
|
953
|
+
never a job). It runs on the Logistics app's credentials (§16) and never
|
|
954
|
+
throws. Its answer:
|
|
955
|
+
- `VERIFIED`: close.
|
|
956
|
+
- `WRONG_CODE`: iFood's 422 (or a code that is no code at all). Say so and
|
|
957
|
+
let the courier type it again.
|
|
958
|
+
- `NOT_REQUESTED`: iFood's 412, no code was asked for this order. Close.
|
|
959
|
+
- `UNAVAILABLE` with a reason: no such order, the store does not carry it, no
|
|
960
|
+
Logistics app, or iFood did not answer. **Close anyway and tell the
|
|
961
|
+
store**: a close is never refused because the marketplace is away.
|
|
962
|
+
|
|
963
|
+
The code itself is never logged, stored or put in an error.
|
package/README.md
CHANGED
|
@@ -111,8 +111,8 @@ there, chosen in the adapter's code and marked so beside it.
|
|
|
111
111
|
|---|---|
|
|
112
112
|
| Base `https://merchant-api.ifood.com.br/catalog/v2.0/merchants/{merchantId}/…`; bearer token from the same OAuth grant as orders | CONFIRMED — [Introduction](https://developer.ifood.com.br/en-US/docs/food/guides/modules/catalog/introduction) |
|
|
113
113
|
| Hierarchy catalog → context (DEFAULT delivery, WHITELABEL, INDOOR) → category → item → products / option groups / options; each level has its own status | CONFIRMED — [Fundamentals](https://developer.ifood.com.br/en-US/docs/food/guides/modules/catalog/fundamentals) |
|
|
114
|
-
| `GET /catalogs`; `GET /categories`
|
|
115
|
-
| `PUT /items` with `item`, `products`, `optionGroups`, `options` (all four always sent) creates or REPLACES the whole item; the item appears at once (synchronous) | CONFIRMED — Introduction, Endpoints |
|
|
114
|
+
| `GET /catalogs` answers `[{ catalogId, context: ["DEFAULT"], status, … }]`; the categories live UNDER a catalog: `GET /catalogs/{catalogId}/categories` and `POST /catalogs/{catalogId}/categories` `{ name, status, template: "DEFAULT" }` → `{ id, … }`. There is no merchant-level `/categories` route: iFood answers it 404 `no Route matched with those values` (FUT-6146). The adapter works in the catalog whose `context` holds `DEFAULT`; a merchant with none is refused | CONFIRMED — live against iFood's sandbox, 2026-12-03 (FUT-6146: `/categories` 404, `/catalogs` 200, `/catalogs/{catalogId}/categories` 200); the same paths in the public [golang-ifood-sdk](https://pkg.go.dev/github.com/arxdsilva/golang-ifood-sdk@v1.1.1/services/catalog) (`category.go`) |
|
|
115
|
+
| `PUT /items` with `item`, `products`, `optionGroups`, `options` (all four always sent) creates or REPLACES the whole item; the item appears at once (synchronous). Merchant-level, not under a catalog, as are `PATCH /items/status` and `POST /image/upload` | CONFIRMED — Introduction, Endpoints |
|
|
116
116
|
| `item.id` and `products[].id` are UUID v4 the software generates (another shape answers 404); `externalCode` is the software's code, unique per merchant (409 when reused); `status` AVAILABLE / UNAVAILABLE; `price` `{ value, originalValue? }` in the major unit | CONFIRMED — Fundamentals, Introduction |
|
|
117
117
|
| `PATCH /items/status` `{ itemId, status }` and `PATCH /items/price` `{ itemId, price }`, synchronous; the batch forms (`/products/status`, `/products/price`) answer a `batchId` and run asynchronously | CONFIRMED — Endpoints, [Errors](https://developer.ifood.com.br/en-US/docs/food/guides/modules/catalog/errors-and-troubleshooting) |
|
|
118
118
|
| `POST /image/upload` `{ image: "data:image/png;base64,…" }` → `{ imagePath }`, reusable across items; jpg/jpeg/png, at most 5 MB (413 above) | CONFIRMED — Endpoints, Errors |
|
|
@@ -187,7 +187,7 @@ const result = await engine.readCatalogue({ clientId, provider: "IFOOD" });
|
|
|
187
187
|
| **The snapshot** | `categories[]` → `items[]`, each with `externalId`, `externalCode`, `name`, `description`, `priceCents` (null when none), `photoUrl` (absolute, or null), `available`, `optionGroups[]` (`name`, `min`, `max`, `options[]` with `name`, `priceDeltaCents`, `photoUrl`, `available`) and `warnings[]`. Sizes, flavours and add-ons are all option groups. |
|
|
188
188
|
| **Money** | Integer cents of the menu's currency, `centsFromMajor(value)`: cut to 12 significant digits (no float error), then rounded half up to the cent (`1.005` → 101). A negative or non-numeric price is no price. |
|
|
189
189
|
| **Nothing dropped silently** | A field that cannot be mapped is a warning on its item (`PRICE_MISSING`, `OPTION_PRICE_MISSING`, `OPTION_GROUP_UNREADABLE`, `OPTION_UNREADABLE`, `PHOTO_UNREADABLE`, `ITEM_TYPE_UNSUPPORTED`), naming the group or option; an item or category that cannot be read at all is a notice on the snapshot (`ITEM_UNREADABLE`, `CATEGORY_UNREADABLE`). Codes are vocabulary: the host words them. |
|
|
190
|
-
| **Failures** | Before any call the engine refuses `UNSUPPORTED` (no reader), `NOT_CONNECTED` (no live connection with a merchant id), `CREDENTIALS` (none on file, or they do not open), with `status`/`message` null. From the marketplace: `CREDENTIALS` (the token grant refused), `NOT_AUTHORIZED` (this app may not read this merchant), `REFUSED` (another final 4xx, or a category list that is not a list), or `retry`. One category answered in an unexpected shape is a `CATEGORY_UNREADABLE` notice, and the rest of the menu is still read. |
|
|
190
|
+
| **Failures** | Before any call the engine refuses `UNSUPPORTED` (no reader), `NOT_CONNECTED` (no live connection with a merchant id), `CREDENTIALS` (none on file, or they do not open), with `status`/`message` null. From the marketplace: `CREDENTIALS` (the token grant refused), `NOT_AUTHORIZED` (this app may not read this merchant), `REFUSED` (another final 4xx, a 404 included, a catalog list with no DEFAULT catalog, or a category list that is not a list), or `retry`. One category answered in an unexpected shape is a `CATEGORY_UNREADABLE` notice, and the rest of the menu is still read. |
|
|
191
191
|
|
|
192
192
|
**iFood** (`src/ifood/catalogue-read.ts`, `src/ifood/catalogue-snapshot.ts`).
|
|
193
193
|
Read 2026-11-16: the Catalog module's Introduction was read whole; its
|
|
@@ -198,8 +198,8 @@ reader that day, so what they would settle is ESTIMATED below (the push's
|
|
|
198
198
|
| fact | status |
|
|
199
199
|
|---|---|
|
|
200
200
|
| Same base and bearer token as the push: `https://merchant-api.ifood.com.br/catalog/v2.0/merchants/{merchantId}/…`, client-credentials grant of the store's own app | CONFIRMED — [Introduction](https://developer.ifood.com.br/en-US/docs/food/guides/modules/catalog/introduction) |
|
|
201
|
-
| `GET /categories` lists the merchant's categories | CONFIRMED —
|
|
202
|
-
| `GET /categories/{categoryId}/items` lists a category's items "with their associated complements" | CONFIRMED — Introduction, step 5 |
|
|
201
|
+
| `GET /catalogs` then `GET /catalogs/{catalogId}/categories` (the `DEFAULT` context's catalog) lists the merchant's categories; the merchant-level `GET /categories` does not exist (404) | CONFIRMED — live against iFood's sandbox, 2026-12-03 (FUT-6146); see the push's table |
|
|
202
|
+
| `GET /categories/{categoryId}/items` (merchant-level) lists a category's items "with their associated complements" | CONFIRMED — Introduction, step 5 |
|
|
203
203
|
| An item is `item` (id, type, categoryId, status, `price { value }` in the major unit, externalCode), `products` (id, name, description, externalCode, and `optionGroups: [{ id, min, max }]` linking a product to its groups), `optionGroups` (id, name, status, `optionIds`), `options` (id, `productId` naming the product with its name, status, `price { value }`) | CONFIRMED as the `PUT /items` payload — Introduction, steps 3 and 4 |
|
|
204
204
|
| The category list answers an array of `{ id, name, status, externalCode }` | ESTIMATED (the push makes the same estimate) |
|
|
205
205
|
| `GET /categories/{categoryId}/items` answers the PUT's four lists as `{ items, products, optionGroups, options }` | ESTIMATED |
|
|
@@ -208,10 +208,10 @@ reader that day, so what they would settle is ESTIMATED below (the push's
|
|
|
208
208
|
| No pagination: neither call shows a page, size or cursor parameter, so the menu is read one category per call | ESTIMATED |
|
|
209
209
|
| 401: the token is dropped and the call asked once more with a fresh one; a second 401 is a `retry` | choice (as the push's `call`) |
|
|
210
210
|
| The token grant refused (400/401/403) is `CREDENTIALS`; 403 on a catalogue call (the Errors page: the module is not enabled for the app) is `NOT_AUTHORIZED`; 429, 408, 425 and 5xx are a `retry`; another 4xx is `REFUSED` | CONFIRMED for the statuses — [Errors](https://developer.ifood.com.br/en-US/docs/food/guides/modules/catalog/errors-and-troubleshooting), as read 2026-11-13; the mapping is a choice |
|
|
211
|
-
| A 404 on the category list
|
|
211
|
+
| A 404 on the catalog or category list is `REFUSED` with iFood's status and words, never `NOT_AUTHORIZED`: a path or resource iFood does not have is not a permission problem (FUT-6146 read a wrong route as "not authorized"); a catalog list with no `DEFAULT` catalog is `REFUSED`; a 404 on one category's items (deleted between the calls) leaves that category out with a `CATEGORY_UNREADABLE` notice | choice (FUT-6146) |
|
|
212
212
|
| A photo path is used as a URL path as it is (an encoded `%20` stays); only characters a URL may not carry are encoded | choice |
|
|
213
213
|
| An item `type` other than `DEFAULT` (a pizza, a combo) is read as a plain item with `ITEM_TYPE_UNSUPPORTED` | choice |
|
|
214
|
-
| The read covers the
|
|
214
|
+
| The read covers the DEFAULT (delivery) context's catalog; other catalogs and `contextModifiers` prices are not read | choice |
|
|
215
215
|
|
|
216
216
|
99Food, Keeta and Rappi state no `catalogueReader`: `engine.readCatalogue` answers
|
|
217
217
|
`UNSUPPORTED` for them.
|
package/dist/99food/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NormalizedEvent, a as NormalizedMarketplaceOrder, C as CatalogueMenuEntry, b as CatalogueMenuOptions, P as PullCatalogue, M as MarketplaceAvailability, A as AdapterCallContext, O as OutboundResult, c as MarketplaceAdapter } from '../adapter-
|
|
2
|
-
import { O as OpenDeliveryApiBaseUrls } from '../client-
|
|
1
|
+
import { N as NormalizedEvent, a as NormalizedMarketplaceOrder, C as CatalogueMenuEntry, b as CatalogueMenuOptions, P as PullCatalogue, M as MarketplaceAvailability, A as AdapterCallContext, O as OutboundResult, c as MarketplaceAdapter } from '../adapter-ZpAWKoCk.js';
|
|
2
|
+
import { O as OpenDeliveryApiBaseUrls } from '../client-DpEq0yXb.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The words the 99Food adapter needs from its host, and nothing else.
|
package/dist/99food/index.js
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
openDeliveryStatus,
|
|
13
13
|
openDeliverySwitchAvailability,
|
|
14
14
|
verifyOpenDeliverySignature
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-3B5EULS6.js";
|
|
16
16
|
import "../chunk-M2V4RFMA.js";
|
|
17
17
|
import "../chunk-E4XJXHUK.js";
|
|
18
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-ZT6TZTLD.js";
|
|
19
19
|
import {
|
|
20
20
|
__name
|
|
21
21
|
} from "../chunk-7QVYU63E.js";
|
|
@@ -601,6 +601,8 @@ interface NormalizedEvent {
|
|
|
601
601
|
* host's admit, with no confirm sent back. Carries no order body.
|
|
602
602
|
*/
|
|
603
603
|
marketplaceConfirmed?: boolean;
|
|
604
|
+
/** The marketplace asked the customer's delivery code for the order (FUT-6167). */
|
|
605
|
+
deliveryCodeRequested?: boolean;
|
|
604
606
|
/**
|
|
605
607
|
* OPTIONAL (FUT-6099). A dispute the marketplace opened or closed on this
|
|
606
608
|
* order (iFood's HSD / HSS). Carries no order body, and never moves the
|
|
@@ -996,6 +998,118 @@ interface MarketplaceLinkAttemptDelegate {
|
|
|
996
998
|
}>;
|
|
997
999
|
}
|
|
998
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* The store's OWN courier carrying a marketplace order, reported to the
|
|
1003
|
+
* marketplace (FUT-5988, FUT-6166): iFood's Logistics module, so the buyer
|
|
1004
|
+
* follows the delivery in the marketplace's app.
|
|
1005
|
+
*
|
|
1006
|
+
* The host says the courier reached a step (`informLogistics`, one enqueue);
|
|
1007
|
+
* the `marketplace.outbound` job, action `logistics`, sends every step still
|
|
1008
|
+
* owed up to it, in the marketplace's one order, each under its own claim row
|
|
1009
|
+
* in the status table (`LOGISTICS_<STEP>`, unique per order and step, so a
|
|
1010
|
+
* step is never sent twice). Only for an ACCEPTED order the store carries
|
|
1011
|
+
* itself (`deliveredBy: MERCHANT`), only when the adapter has a Logistics
|
|
1012
|
+
* half and the host configured the Logistics app's credentials
|
|
1013
|
+
* (`logisticsCredentials`, the software's own app, never the store's PDV
|
|
1014
|
+
* credentials). The courier's name and phone are read from the host at send
|
|
1015
|
+
* time (`order.logisticsDriver`), never carried in the job's payload.
|
|
1016
|
+
*
|
|
1017
|
+
* A step that fails (a final refusal, or the last attempt) is FAILED and the
|
|
1018
|
+
* chain stops there: the marketplace refuses a later step out of order. A
|
|
1019
|
+
* failure never touches the order.
|
|
1020
|
+
*/
|
|
1021
|
+
/** The steps, in the one order a marketplace takes them. */
|
|
1022
|
+
declare const LOGISTICS_STEPS: readonly ["ASSIGNED", "GOING_TO_ORIGIN", "ARRIVED_AT_ORIGIN", "DISPATCHED", "ARRIVED_AT_DESTINATION"];
|
|
1023
|
+
type LogisticsStep = (typeof LOGISTICS_STEPS)[number];
|
|
1024
|
+
/** How the courier travels, as the marketplace is told. */
|
|
1025
|
+
type LogisticsVehicle = "MOTORCYCLE" | "CAR" | "BICYCLE" | "ON_FOOT" | "SCOOTER";
|
|
1026
|
+
/** Who carries the order, read from the host when ASSIGNED is sent. */
|
|
1027
|
+
interface LogisticsDriver {
|
|
1028
|
+
name: string;
|
|
1029
|
+
phone: string;
|
|
1030
|
+
vehicle: LogisticsVehicle;
|
|
1031
|
+
}
|
|
1032
|
+
/** An adapter's Logistics half: the wire calls, nothing else. */
|
|
1033
|
+
interface MarketplaceLogistics {
|
|
1034
|
+
assignDriver(ctx: AdapterCallContext, order: OutboundOrderRef, driver: LogisticsDriver): Promise<OutboundResult | {
|
|
1035
|
+
kind: "invalid";
|
|
1036
|
+
reason: string;
|
|
1037
|
+
}>;
|
|
1038
|
+
step(ctx: AdapterCallContext, order: OutboundOrderRef, step: Exclude<LogisticsStep, "ASSIGNED">): Promise<OutboundResult>;
|
|
1039
|
+
/** OPTIONAL (FUT-6167). The customer's delivery code, typed by the courier at the door. */
|
|
1040
|
+
verifyDeliveryCode?(ctx: AdapterCallContext, order: OutboundOrderRef, code: string): Promise<DeliveryCodeAnswer>;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* What the marketplace said of the customer's delivery code (FUT-6167).
|
|
1044
|
+
* UNAVAILABLE is never a refusal of the close: the host closes and records it.
|
|
1045
|
+
*/
|
|
1046
|
+
type DeliveryCodeAnswer = {
|
|
1047
|
+
kind: "VERIFIED";
|
|
1048
|
+
}
|
|
1049
|
+
/** Wrong, or not a code at all: the courier may type it again. */
|
|
1050
|
+
| {
|
|
1051
|
+
kind: "WRONG_CODE";
|
|
1052
|
+
}
|
|
1053
|
+
/** The marketplace never asked this order for a code. */
|
|
1054
|
+
| {
|
|
1055
|
+
kind: "NOT_REQUESTED";
|
|
1056
|
+
} | {
|
|
1057
|
+
kind: "UNAVAILABLE";
|
|
1058
|
+
reason: string;
|
|
1059
|
+
};
|
|
1060
|
+
/** The adapter's Logistics half (`MarketplaceAdapter` extends it). */
|
|
1061
|
+
interface LogisticsAdapter {
|
|
1062
|
+
/** OPTIONAL (FUT-6166). The store's own courier reported to the marketplace. */
|
|
1063
|
+
readonly logistics?: MarketplaceLogistics;
|
|
1064
|
+
}
|
|
1065
|
+
/** The order port's Logistics half (`MarketplaceOrderPort` extends it). */
|
|
1066
|
+
interface LogisticsOrderPort {
|
|
1067
|
+
/**
|
|
1068
|
+
* OPTIONAL (FUT-6166). The store's courier carrying the order, read before a
|
|
1069
|
+
* Logistics run claims anything while ASSIGNED is still owed, or null when none
|
|
1070
|
+
* is. Null or absent: the run is skipped and claims nothing. Answer null after
|
|
1071
|
+
* the host's undo of a dispatch (ADOPTING §16).
|
|
1072
|
+
*/
|
|
1073
|
+
logisticsDriver?(clientId: string, orderId: string): Promise<LogisticsDriver | null>;
|
|
1074
|
+
/**
|
|
1075
|
+
* OPTIONAL (FUT-6167). The marketplace asked the customer's delivery code for
|
|
1076
|
+
* an ACCEPTED order: store it, so the courier's close asks for the code.
|
|
1077
|
+
* Idempotent: a redelivery calls it again. Absent: the event is ignored.
|
|
1078
|
+
*/
|
|
1079
|
+
onDeliveryCodeRequested?(clientId: string, orderId: string): Promise<void>;
|
|
1080
|
+
}
|
|
1081
|
+
/** The host's Logistics ports (`MarketplacePorts` extends it). */
|
|
1082
|
+
interface LogisticsPorts {
|
|
1083
|
+
/**
|
|
1084
|
+
* OPTIONAL (FUT-6166). The software's Logistics app on this marketplace (a
|
|
1085
|
+
* separate app from the one that links stores), or null. Absent or null: no
|
|
1086
|
+
* Logistics step is ever sent.
|
|
1087
|
+
*/
|
|
1088
|
+
logisticsCredentials?: MarketplaceAppCredentialsPort;
|
|
1089
|
+
}
|
|
1090
|
+
/** What the host says when its courier reaches a step. */
|
|
1091
|
+
interface InformLogisticsInput {
|
|
1092
|
+
clientId: string;
|
|
1093
|
+
orderId: string;
|
|
1094
|
+
step: LogisticsStep;
|
|
1095
|
+
/** The move's instant: it keys the job and owns the claims it makes. */
|
|
1096
|
+
at: Date;
|
|
1097
|
+
/**
|
|
1098
|
+
* Hold the job this long (the host's undo window): a move undone inside it
|
|
1099
|
+
* leaves the order with no courier, and the job then sends nothing.
|
|
1100
|
+
*/
|
|
1101
|
+
delayMs?: number;
|
|
1102
|
+
}
|
|
1103
|
+
/** The engine's Logistics half (`MarketplaceEngine` extends it). */
|
|
1104
|
+
interface MarketplaceLogisticsEngine {
|
|
1105
|
+
/**
|
|
1106
|
+
* The store's own courier reached a step (FUT-6166): ONE enqueue of the
|
|
1107
|
+
* `marketplace.outbound` job, action `logistics`, which sends every step
|
|
1108
|
+
* still owed up to it. Never throws. True when the queue took it.
|
|
1109
|
+
*/
|
|
1110
|
+
informLogistics(input: InformLogisticsInput): Promise<boolean>;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
999
1113
|
/**
|
|
1000
1114
|
* The adapter port's OPTIONAL availability capability: closing a store on a
|
|
1001
1115
|
* marketplace for a while, and opening it again (FUT-4851).
|
|
@@ -1342,7 +1456,7 @@ interface CancellationRequestInput {
|
|
|
1342
1456
|
offendingSkus: readonly string[];
|
|
1343
1457
|
}
|
|
1344
1458
|
/** One marketplace, in and out. */
|
|
1345
|
-
interface MarketplaceAdapter {
|
|
1459
|
+
interface MarketplaceAdapter extends LogisticsAdapter {
|
|
1346
1460
|
readonly provider: MarketplaceProvider;
|
|
1347
1461
|
readonly capabilities: MarketplaceCapabilities;
|
|
1348
1462
|
/** Inbound: one delivery into the canonical shape, or null when it carries no order id. */
|
|
@@ -1469,4 +1583,4 @@ declare function tokenGrantResultOf(response: MarketplaceHttpResponse): Outbound
|
|
|
1469
1583
|
/** A call that never got an answer is a retry, with the reason a log can read. */
|
|
1470
1584
|
declare function answered(call: () => Promise<OutboundResult>): Promise<OutboundResult>;
|
|
1471
1585
|
|
|
1472
|
-
export { type
|
|
1586
|
+
export { type DisputeAnswerResult as $, type AdapterCallContext as A, type CatalogueReadContext as B, type CatalogueMenuEntry as C, type CatalogueReadNotice as D, type CatalogueReadRefusalCode as E, type FetchOrderResult as F, type CatalogueReadResult as G, type CatalogueReadWarning as H, type CatalogueReadWarningCode as I, type CatalogueSnapshot as J, type CatalogueSnapshotCategory as K, type CatalogueSnapshotItem as L, type MarketplaceAvailability as M, type NormalizedEvent as N, type OutboundResult as O, type PullCatalogue as P, type CatalogueSnapshotOption as Q, type CatalogueSnapshotOptionGroup as R, type StorePauseRequest as S, type CatalogueStoredImage as T, type CatalogueWarningCode as U, type CourierTrackingCallResult as V, type CourierTrackingResult as W, type DeliveryCodeAnswer as X, type DisputeAlternative as Y, type DisputeAlternativeType as Z, type DisputeAnswer as _, type NormalizedMarketplaceOrder as a, tokenGrantResultOf as a$, type DisputeFailureCode as a0, type DisputeItem as a1, type DisputeOutcome as a2, type DisputeReason as a3, type InformLogisticsInput as a4, LOGISTICS_STEPS as a5, type LinkCallContext as a6, type LinkCode as a7, type LinkGrant as a8, type LinkResult as a9, type MarketplaceOrderType as aA, type MarketplacePaymentMethod as aB, type NormalizedAddress as aC, type NormalizedBuyer as aD, type NormalizedDisputeEvent as aE, type NormalizedDisputeOpened as aF, type NormalizedDisputeSettled as aG, type NormalizedLineOption as aH, type NormalizedOrderDiscount as aI, type NormalizedOrderFee as aJ, type NormalizedOrderLine as aK, type NormalizedPaymentMethod as aL, type NormalizedPayments as aM, type OrderCancellationReason as aN, type OrderCancellationReasonsResult as aO, type OutboundOrderRef as aP, PROVIDER_ID_PATTERN as aQ, type PickupCodeCallResult as aR, type PickupCodeValidation as aS, type PresenceProbe as aT, type StatusFacts as aU, type StatusStep as aV, type ValidatePickupCodeInput as aW, answered as aX, centsFromMajor as aY, normalizedLineTotalCents as aZ, outboundResultOf as a_, type LinkedMerchant as aa, type LogisticsDriver as ab, type LogisticsStep as ac, type LogisticsVehicle as ad, type MarketplaceAcknowledgement as ae, type MarketplaceAppCredentialsPort as af, type MarketplaceCapabilities as ag, type MarketplaceCatalogue as ah, type MarketplaceCourier as ai, type MarketplaceCourierAnswer as aj, type MarketplaceCourierEngine as ak, type MarketplaceCourierFacts as al, type MarketplaceCourierStep as am, type MarketplaceCourierTracking as an, type MarketplaceCourierVehicle as ao, type MarketplaceCredentials as ap, type MarketplaceDeliveredBy as aq, type MarketplaceDiscountSponsor as ar, type MarketplaceDisputeApi as as, type MarketplaceDisputeChange as at, type MarketplaceDisputeDelegate as au, type MarketplaceHttp as av, type MarketplaceHttpRequest as aw, type MarketplaceHttpResponse as ax, type MarketplaceLifecycle as ay, type MarketplaceLinkAttemptDelegate as az, type CatalogueMenuOptions as b, type LogisticsPorts as b0, type LogisticsOrderPort as b1, type MarketplaceLogisticsEngine as b2, type MarketplaceAdapter as c, type PushCatalogue as d, type CatalogueItemOut as e, type CatalogueReader as f, type MarketplaceLinking as g, type MarketplaceAppLinking as h, type MarketplaceCourierApi as i, type NormalizedCourierEvent as j, type StorePauseResult as k, type StorePauseRef as l, type MarketplaceLogistics as m, type MarketplaceProvider as n, type CancellationReason as o, type AdapterGrant as p, type AdapterTokenCache as q, type AppLinkCallContext as r, type CancellationOutcome as s, type CancellationRequestInput as t, type CatalogueCallContext as u, type CatalogueFailure as v, type CatalogueImage as w, type CatalogueItem as x, type CatalogueItemRef as y, type CataloguePublishResult as z };
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
answered,
|
|
16
16
|
outboundResultOf,
|
|
17
17
|
tokenGrantResultOf
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ZT6TZTLD.js";
|
|
19
19
|
import {
|
|
20
20
|
__name
|
|
21
21
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -483,4 +483,4 @@ export {
|
|
|
483
483
|
normalizeOpenDeliveryEventAs,
|
|
484
484
|
normalizeOpenDeliveryOrderAs
|
|
485
485
|
};
|
|
486
|
-
//# sourceMappingURL=chunk-
|
|
486
|
+
//# sourceMappingURL=chunk-3B5EULS6.js.map
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
DisputeAnswerRetryError,
|
|
24
24
|
FetchOrderRetryError,
|
|
25
25
|
OutboundRetryError
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-MDEIRGNL.js";
|
|
27
27
|
import {
|
|
28
28
|
__name
|
|
29
29
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -770,4 +770,4 @@ export {
|
|
|
770
770
|
MARKETPLACE_JOBS,
|
|
771
771
|
createApiMarketplace
|
|
772
772
|
};
|
|
773
|
-
//# sourceMappingURL=chunk-
|
|
773
|
+
//# sourceMappingURL=chunk-BLHZ3MRB.js.map
|