@12-apps/marketplace 1.11.0 → 1.13.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 (55) hide show
  1. package/ADOPTING.md +134 -1
  2. package/README.md +49 -3
  3. package/dist/99food/index.d.ts +2 -2
  4. package/dist/99food/index.js +2 -2
  5. package/dist/{adapter-CD0SfdVS.d.ts → adapter-CQ4QiZPi.d.ts} +327 -174
  6. package/dist/{chunk-TVZU4HNT.js → chunk-4J2KJ3ZW.js} +1 -1
  7. package/dist/{chunk-TVZU4HNT.js.map → chunk-4J2KJ3ZW.js.map} +1 -1
  8. package/dist/{chunk-YWMEIMO3.js → chunk-CEWTV2TC.js} +176 -40
  9. package/dist/chunk-CEWTV2TC.js.map +1 -0
  10. package/dist/{chunk-DCWOQ5PN.js → chunk-NFJQQWG4.js} +2 -2
  11. package/dist/{chunk-OS4TSIFU.js → chunk-W57TITU4.js} +2 -2
  12. package/dist/{client-11sncog4.d.ts → client-CCSnylou.d.ts} +1 -1
  13. package/dist/{engine-C_3RK8wC.d.ts → engine-1KlJ_8jK.d.ts} +34 -5
  14. package/dist/hono/index.d.ts +2 -2
  15. package/dist/hono/index.js +2 -2
  16. package/dist/ifood/index.d.ts +20 -2
  17. package/dist/ifood/index.js +349 -125
  18. package/dist/ifood/index.js.map +1 -1
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +162 -65
  21. package/dist/index.js.map +1 -1
  22. package/dist/keeta/index.d.ts +2 -18
  23. package/dist/keeta/index.js +12 -3
  24. package/dist/keeta/index.js.map +1 -1
  25. package/dist/manifest/server.d.ts +2 -2
  26. package/dist/manifest/server.js +2 -2
  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 +2 -2
  31. package/package.json +1 -1
  32. package/src/core/adapter.ts +8 -1
  33. package/src/core/connection-stamp.ts +61 -0
  34. package/src/core/courier-port.ts +100 -0
  35. package/src/core/courier.ts +153 -0
  36. package/src/core/engine.ts +4 -1
  37. package/src/core/fetch-order.ts +54 -12
  38. package/src/core/integration.ts +19 -4
  39. package/src/core/lifecycle.ts +27 -4
  40. package/src/core/outbound-queue.ts +24 -11
  41. package/src/core/outbound.ts +8 -6
  42. package/src/core/pickup-code.ts +136 -0
  43. package/src/core/pipeline.ts +15 -6
  44. package/src/core/ports.ts +23 -1
  45. package/src/core/status-store.ts +2 -3
  46. package/src/core/types.ts +56 -4
  47. package/src/ifood/courier.ts +210 -0
  48. package/src/ifood/fetch-order.ts +103 -0
  49. package/src/ifood/index.ts +9 -1
  50. package/src/ifood/normalize.ts +30 -3
  51. package/src/index.ts +16 -0
  52. package/src/keeta/normalize.ts +21 -6
  53. package/dist/chunk-YWMEIMO3.js.map +0 -1
  54. /package/dist/{chunk-DCWOQ5PN.js.map → chunk-NFJQQWG4.js.map} +0 -0
  55. /package/dist/{chunk-OS4TSIFU.js.map → chunk-W57TITU4.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { outboundResultOf, type AdapterCallContext } from "../core/adapter";
2
- import { pick } from "../core/payload-read";
3
- import type { NormalizedEvent, NormalizedMarketplaceOrder } from "../core/types";
2
+ import { firstDate, pick } from "../core/payload-read";
3
+ import type { MarketplaceCourierStep, NormalizedEvent, NormalizedMarketplaceOrder } from "../core/types";
4
4
  import { isStop, openDeliveryCall, type OpenDeliveryDialect } from "../open-delivery/client";
5
5
  import { normalizeOpenDeliveryEventAs, normalizeOpenDeliveryOrderAs } from "../open-delivery/normalize";
6
6
 
@@ -12,15 +12,26 @@ import { normalizeOpenDeliveryEventAs, normalizeOpenDeliveryOrderAs } from "../o
12
12
  *
13
13
  * Events (Keeta's order guide, read 2026-11-26): `CREATED` → fetch;
14
14
  * `CANCELLED` (with a JSON-string `metadata` carrying `reason` and `code`) →
15
- * cancelled; `DISPATCHED`, `CONCLUDED` → lifecycle. Keeta has NO
15
+ * cancelled; `DISPATCHED`, `CONCLUDED` → lifecycle; `RIDER_ARRIVED_AT_STORE`,
16
+ * `ORDER_COLLECTED` → courier steps (the second a lifecycle too). Keeta has NO
16
17
  * `CANCELLATION_REQUEST_DENIED`: a store's request that Keeta does not grant
17
18
  * produces no event, so it ends TIMEOUT at the adapter's answer window. The
18
- * rest (`CONFIRMED`, `READY_FOR_PICKUP`, `PICKUP_ONGOING`,
19
- * `RIDER_ARRIVED_AT_STORE`, `ORDER_COLLECTED`, `DELIVERED`,
19
+ * rest (`CONFIRMED`, `READY_FOR_PICKUP`, `PICKUP_ONGOING`, `DELIVERED`,
20
20
  * `CANCELLATION_REQUESTED`, `USER_REFUND_REQUEST`, `REFUNDED`,
21
21
  * `REFUND_FAILED`, `RECOMMENDED_PREPARATION_START`) are recorded and IGNORED.
22
22
  */
23
23
 
24
+ /**
25
+ * Keeta's rider events as courier steps (FUT-5665). ESTIMATED: the event names
26
+ * are Keeta's order guide's (read 2026-11-26), their meaning is read off the
27
+ * names; they carry no rider's name, photo or vehicle. `PICKUP_ONGOING` is left
28
+ * IGNORED: whether it means "on the way" or "at the counter" is not stated.
29
+ */
30
+ const KEETA_COURIER_STEP_OF: Readonly<Record<string, MarketplaceCourierStep>> = {
31
+ RIDER_ARRIVED_AT_STORE: "ARRIVED_AT_ORIGIN",
32
+ ORDER_COLLECTED: "COLLECTED",
33
+ };
34
+
24
35
  /** The provider id Keeta is registered under. Uppercase: the column's CHECK holds that shape. */
25
36
  export const KEETA_PROVIDER = "KEETA";
26
37
 
@@ -31,7 +42,11 @@ const DECRYPT_BATCH = 50;
31
42
 
32
43
  /** Normalize one webhook `Event`. Null only when it names no order. */
33
44
  export function normalizeKeetaEvent(payload: unknown): NormalizedEvent | null {
34
- return normalizeOpenDeliveryEventAs(KEETA_PROVIDER, payload);
45
+ const event = normalizeOpenDeliveryEventAs(KEETA_PROVIDER, payload);
46
+ const step = event ? KEETA_COURIER_STEP_OF[event.eventType] : undefined;
47
+ if (!event || !step) return event;
48
+ const courier = { step, at: firstDate(payload, [["createdAt"]]), courier: null, returning: null };
49
+ return { ...event, courier, ...(step === "COLLECTED" ? { lifecycle: "COLLECTED" as const } : {}) };
35
50
  }
36
51
 
37
52
  /** Normalize one `Order`, after {@link revealKeetaOrder}. Null when it carries no id or no line. */