@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.
- package/ADOPTING.md +134 -1
- package/README.md +49 -3
- package/dist/99food/index.d.ts +2 -2
- package/dist/99food/index.js +2 -2
- package/dist/{adapter-CD0SfdVS.d.ts → adapter-CQ4QiZPi.d.ts} +327 -174
- package/dist/{chunk-TVZU4HNT.js → chunk-4J2KJ3ZW.js} +1 -1
- package/dist/{chunk-TVZU4HNT.js.map → chunk-4J2KJ3ZW.js.map} +1 -1
- package/dist/{chunk-YWMEIMO3.js → chunk-CEWTV2TC.js} +176 -40
- package/dist/chunk-CEWTV2TC.js.map +1 -0
- package/dist/{chunk-DCWOQ5PN.js → chunk-NFJQQWG4.js} +2 -2
- package/dist/{chunk-OS4TSIFU.js → chunk-W57TITU4.js} +2 -2
- package/dist/{client-11sncog4.d.ts → client-CCSnylou.d.ts} +1 -1
- package/dist/{engine-C_3RK8wC.d.ts → engine-1KlJ_8jK.d.ts} +34 -5
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +2 -2
- package/dist/ifood/index.d.ts +20 -2
- package/dist/ifood/index.js +349 -125
- package/dist/ifood/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +162 -65
- package/dist/index.js.map +1 -1
- package/dist/keeta/index.d.ts +2 -18
- package/dist/keeta/index.js +12 -3
- package/dist/keeta/index.js.map +1 -1
- package/dist/manifest/server.d.ts +2 -2
- package/dist/manifest/server.js +2 -2
- 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 +2 -2
- package/package.json +1 -1
- package/src/core/adapter.ts +8 -1
- package/src/core/connection-stamp.ts +61 -0
- package/src/core/courier-port.ts +100 -0
- package/src/core/courier.ts +153 -0
- package/src/core/engine.ts +4 -1
- package/src/core/fetch-order.ts +54 -12
- package/src/core/integration.ts +19 -4
- package/src/core/lifecycle.ts +27 -4
- package/src/core/outbound-queue.ts +24 -11
- package/src/core/outbound.ts +8 -6
- package/src/core/pickup-code.ts +136 -0
- package/src/core/pipeline.ts +15 -6
- package/src/core/ports.ts +23 -1
- package/src/core/status-store.ts +2 -3
- package/src/core/types.ts +56 -4
- package/src/ifood/courier.ts +210 -0
- package/src/ifood/fetch-order.ts +103 -0
- package/src/ifood/index.ts +9 -1
- package/src/ifood/normalize.ts +30 -3
- package/src/index.ts +16 -0
- package/src/keeta/normalize.ts +21 -6
- package/dist/chunk-YWMEIMO3.js.map +0 -1
- /package/dist/{chunk-DCWOQ5PN.js.map → chunk-NFJQQWG4.js.map} +0 -0
- /package/dist/{chunk-OS4TSIFU.js.map → chunk-W57TITU4.js.map} +0 -0
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
answered,
|
|
15
15
|
outboundResultOf,
|
|
16
16
|
tokenGrantResultOf
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-4J2KJ3ZW.js";
|
|
18
18
|
import {
|
|
19
19
|
__name
|
|
20
20
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -475,4 +475,4 @@ export {
|
|
|
475
475
|
normalizeOpenDeliveryEventAs,
|
|
476
476
|
normalizeOpenDeliveryOrderAs
|
|
477
477
|
};
|
|
478
|
-
//# sourceMappingURL=chunk-
|
|
478
|
+
//# sourceMappingURL=chunk-NFJQQWG4.js.map
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
CatalogueRetryError,
|
|
19
19
|
FetchOrderRetryError,
|
|
20
20
|
OutboundRetryError
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-CEWTV2TC.js";
|
|
22
22
|
import {
|
|
23
23
|
__name
|
|
24
24
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -651,4 +651,4 @@ export {
|
|
|
651
651
|
MARKETPLACE_JOBS,
|
|
652
652
|
createApiMarketplace
|
|
653
653
|
};
|
|
654
|
-
//# sourceMappingURL=chunk-
|
|
654
|
+
//# sourceMappingURL=chunk-W57TITU4.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a8 as MarketplaceDeliveredBy, ae as MarketplaceLinkAttemptDelegate, u as CatalogueItem, t as CatalogueImage, a as NormalizedMarketplaceOrder, N as NormalizedEvent, ap as StatusStep, i as NormalizedCourierEvent, a3 as MarketplaceCourierFacts, a1 as MarketplaceCourierAnswer, an as PickupCodeValidation, aa as MarketplaceHttp, Z as MarketplaceAppCredentialsPort, c as MarketplaceAdapter, l as MarketplaceProvider, a7 as MarketplaceCredentials, Q as CatalogueWarningCode, Y as LinkedMerchant, ad as MarketplaceLifecycle, a4 as MarketplaceCourierStep, a2 as MarketplaceCourierEngine, m as CancellationReason, ak as OutboundOrderRef, b as CatalogueMenuOptions, B as CatalogueReadResult } from './adapter-CQ4QiZPi.js';
|
|
2
2
|
|
|
3
3
|
/** What the engine tells the host about the order a lifecycle event names. */
|
|
4
4
|
interface MarketplaceLifecycleFacts {
|
|
@@ -286,6 +286,22 @@ interface MarketplaceOrderPort {
|
|
|
286
286
|
* Absent: the engine cannot tell, and sends nothing.
|
|
287
287
|
*/
|
|
288
288
|
statusHolds?(clientId: string, orderId: string, step: StatusStep): Promise<boolean>;
|
|
289
|
+
/**
|
|
290
|
+
* OPTIONAL (FUT-5665). The marketplace's courier moved: named, on the way,
|
|
291
|
+
* at the counter, holding the bag, or bringing it back. Store the facts on
|
|
292
|
+
* the order; never move it (a `COLLECTED` moves through `onLifecycle`).
|
|
293
|
+
* Idempotent: a redelivery is deduped, but the reconcile pass re-runs a
|
|
294
|
+
* FAILED row. Asked for an ACCEPTED order only, whatever the connection's
|
|
295
|
+
* `followStatus`. Absent: courier events are understood and ignored.
|
|
296
|
+
*/
|
|
297
|
+
onCourier?(clientId: string, orderId: string, event: NormalizedCourierEvent, facts: MarketplaceCourierFacts): Promise<MarketplaceCourierAnswer>;
|
|
298
|
+
/**
|
|
299
|
+
* OPTIONAL (FUT-5665). The marketplace's verdict on the pickup code the host
|
|
300
|
+
* sent with `engine.validatePickupCode`. Called once per job, after the
|
|
301
|
+
* hand-over has committed: `INVALID` warns, it moves nothing. A throw is
|
|
302
|
+
* logged. Absent: the verdict is only logged.
|
|
303
|
+
*/
|
|
304
|
+
onPickupCodeValidated?(clientId: string, orderId: string, validation: PickupCodeValidation): Promise<void>;
|
|
289
305
|
/** Queue facts for a batch of orders, keyed by id. Missing ids are dropped. */
|
|
290
306
|
summarize(clientId: string, orderIds: readonly string[]): Promise<Map<string, MarketplaceOrderSummary>>;
|
|
291
307
|
}
|
|
@@ -1074,10 +1090,11 @@ interface LinkFinished {
|
|
|
1074
1090
|
/** The wire name, `<namespace>.<blueprint>` as the jobs contribution binds it. */
|
|
1075
1091
|
declare const MARKETPLACE_OUTBOUND_JOB = "marketplace.outbound";
|
|
1076
1092
|
/**
|
|
1077
|
-
* What goes out: the store's aceite, the store's cancellation request,
|
|
1078
|
-
* step of the order the store reached (`status`, FUT-4653)
|
|
1093
|
+
* What goes out: the store's aceite, the store's cancellation request, a
|
|
1094
|
+
* step of the order the store reached (`status`, FUT-4653), or the pickup code
|
|
1095
|
+
* the store checked at the hand-over (`validatePickupCode`, FUT-5665).
|
|
1079
1096
|
*/
|
|
1080
|
-
type OutboundAction = "confirm" | "requestCancellation" | "status";
|
|
1097
|
+
type OutboundAction = "confirm" | "requestCancellation" | "status" | "validatePickupCode";
|
|
1081
1098
|
/** The outbound job's payload. Identifiers only. */
|
|
1082
1099
|
interface OutboundJobPayload {
|
|
1083
1100
|
clientId: string;
|
|
@@ -1090,6 +1107,12 @@ interface OutboundJobPayload {
|
|
|
1090
1107
|
* belongs to: the owner of its SENDING claim. Absent on every other action.
|
|
1091
1108
|
*/
|
|
1092
1109
|
claimKey?: string;
|
|
1110
|
+
/**
|
|
1111
|
+
* OPTIONAL. The pickup code a `validatePickupCode` call sends; absent on every
|
|
1112
|
+
* other action. The one non-identifier in the payload: a short-lived code the
|
|
1113
|
+
* job needs to send, which no log line prints.
|
|
1114
|
+
*/
|
|
1115
|
+
code?: string;
|
|
1093
1116
|
}
|
|
1094
1117
|
/** The dedupe key: at most one queued call per (order, action). */
|
|
1095
1118
|
declare function outboundDedupeKey(payload: OutboundJobPayload): string;
|
|
@@ -1367,6 +1390,12 @@ type DeliveryOutcome = {
|
|
|
1367
1390
|
kind: "moved";
|
|
1368
1391
|
orderId: string;
|
|
1369
1392
|
lifecycle: MarketplaceLifecycle;
|
|
1393
|
+
}
|
|
1394
|
+
/** A courier event's facts were stored by the host's `onCourier` (FUT-5665). */
|
|
1395
|
+
| {
|
|
1396
|
+
kind: "courier";
|
|
1397
|
+
orderId: string;
|
|
1398
|
+
step: MarketplaceCourierStep;
|
|
1370
1399
|
} | {
|
|
1371
1400
|
kind: "cancelled";
|
|
1372
1401
|
} | {
|
|
@@ -1407,7 +1436,7 @@ interface MarketplaceOrderState {
|
|
|
1407
1436
|
}
|
|
1408
1437
|
|
|
1409
1438
|
/** Everything the mounted engine can do, with the ports and adapters bound in. */
|
|
1410
|
-
interface MarketplaceEngine {
|
|
1439
|
+
interface MarketplaceEngine extends MarketplaceCourierEngine {
|
|
1411
1440
|
/** Every registered marketplace, in registration order. */
|
|
1412
1441
|
providers(): readonly MarketplaceProvider[];
|
|
1413
1442
|
/** Whether a provider id (a URL segment, a body field) names a registered adapter. */
|
package/dist/hono/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono, Context } from 'hono';
|
|
2
2
|
import { ApiMarketplace, MarketplaceApiConfig, MarketplaceActor } from '../server/index.js';
|
|
3
|
-
import '../engine-
|
|
4
|
-
import '../adapter-
|
|
3
|
+
import '../engine-1KlJ_8jK.js';
|
|
4
|
+
import '../adapter-CQ4QiZPi.js';
|
|
5
5
|
import '@12-apps/wiring';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
package/dist/hono/index.js
CHANGED
package/dist/ifood/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NormalizedEvent, d as PushCatalogue, e as CatalogueItemOut, f as CatalogueReader, g as MarketplaceLinking,
|
|
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 MarketplaceCourierApi, i as NormalizedCourierEvent, M as MarketplaceAvailability, S as StorePauseRequest, j as StorePauseResult, k as StorePauseRef, O as OutboundResult, c as MarketplaceAdapter } from '../adapter-CQ4QiZPi.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The words the iFood adapter needs from its host, and nothing else.
|
|
@@ -30,6 +30,12 @@ interface IfoodAdapterCopy {
|
|
|
30
30
|
* connection untestable.
|
|
31
31
|
*/
|
|
32
32
|
declare function verifyIfoodSignature(rawBody: string, signature: string | null, webhookSecret: string | null): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The order body of a placed-order event, or null when it carries none. Also
|
|
35
|
+
* reads the order iFood serves at `GET /order/v1.0/orders/{id}` (`./fetch-order.ts`),
|
|
36
|
+
* whose fields are the same ones the event's `order` would carry.
|
|
37
|
+
*/
|
|
38
|
+
declare function readIfoodOrder(payload: unknown, externalOrderId: string, missingStreetNumber: string): NormalizedMarketplaceOrder | null;
|
|
33
39
|
/**
|
|
34
40
|
* Normalize one iFood delivery.
|
|
35
41
|
*
|
|
@@ -42,6 +48,13 @@ declare function normalizeIfoodEvent(payload: unknown, options: {
|
|
|
42
48
|
missingStreetNumber: string;
|
|
43
49
|
}): NormalizedEvent | null;
|
|
44
50
|
|
|
51
|
+
/** Fetch one order iFood's event only named. Never throws: no answer is a retry. */
|
|
52
|
+
declare function ifoodFetchOrder(ctx: AdapterCallContext, ref: {
|
|
53
|
+
externalOrderId: string;
|
|
54
|
+
}, options: {
|
|
55
|
+
missingStreetNumber: string;
|
|
56
|
+
}): Promise<FetchOrderResult>;
|
|
57
|
+
|
|
45
58
|
/** The item's and its product's ids, stable per publication. */
|
|
46
59
|
declare const ifoodItemId: (ref: string) => string;
|
|
47
60
|
declare const ifoodProductId: (ref: string) => string;
|
|
@@ -56,6 +69,11 @@ declare const IFOOD_CATALOGUE_READER: CatalogueReader;
|
|
|
56
69
|
/** The iFood adapter's linking half. */
|
|
57
70
|
declare const IFOOD_LINKING: MarketplaceLinking;
|
|
58
71
|
|
|
72
|
+
/** The courier step an iFood event names, or null. */
|
|
73
|
+
declare function readIfoodCourierEvent(payload: unknown, eventType: string): NormalizedCourierEvent | null;
|
|
74
|
+
/** iFood's courier calls, for the adapter's `courier`. */
|
|
75
|
+
declare const IFOOD_COURIER: MarketplaceCourierApi;
|
|
76
|
+
|
|
59
77
|
/**
|
|
60
78
|
* iFood's catalogue answer mapped into the engine's {@link CatalogueSnapshotItem}
|
|
61
79
|
* (FUT-951). Pure and offline: `./catalogue-read.ts` makes the calls.
|
|
@@ -121,4 +139,4 @@ interface IfoodAdapterConfig {
|
|
|
121
139
|
/** Build the iFood adapter. Its reasons are static: a dialog never waits on iFood. */
|
|
122
140
|
declare function createIfoodAdapter(config: IfoodAdapterConfig): MarketplaceAdapter;
|
|
123
141
|
|
|
124
|
-
export { IFOOD_AVAILABILITY, IFOOD_CANCELLATION_ANSWER_WINDOW_MS, IFOOD_CATALOGUE, IFOOD_CATALOGUE_READER, IFOOD_IMAGE_BASE_URL, IFOOD_LINKING, IFOOD_PROVIDER, IFOOD_REASON_CODES, type IfoodAdapterConfig, type IfoodAdapterCopy, type IfoodReasonCode, createIfoodAdapter, ifoodItemBody, ifoodItemId, ifoodLocalTime, ifoodPause, ifoodProductId, ifoodResume, normalizeIfoodEvent, verifyIfoodSignature };
|
|
142
|
+
export { IFOOD_AVAILABILITY, IFOOD_CANCELLATION_ANSWER_WINDOW_MS, IFOOD_CATALOGUE, IFOOD_CATALOGUE_READER, IFOOD_COURIER, IFOOD_IMAGE_BASE_URL, IFOOD_LINKING, IFOOD_PROVIDER, IFOOD_REASON_CODES, type IfoodAdapterConfig, type IfoodAdapterCopy, type IfoodReasonCode, createIfoodAdapter, ifoodFetchOrder, ifoodItemBody, ifoodItemId, ifoodLocalTime, ifoodPause, ifoodProductId, ifoodResume, normalizeIfoodEvent, readIfoodCourierEvent, readIfoodOrder, verifyIfoodSignature };
|