@12-apps/marketplace 1.20.0 → 1.20.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 +1 -0
- package/dist/{chunk-RS2QKQ6S.js → chunk-C2MFGZ3H.js} +2 -2
- package/dist/{chunk-S2ISELNJ.js → chunk-T6A46MH3.js} +52 -43
- package/dist/chunk-T6A46MH3.js.map +1 -0
- package/dist/hono/index.js +2 -2
- package/dist/index.js +1 -1
- package/dist/manifest/server.js +2 -2
- package/dist/server/index.js +2 -2
- package/package.json +1 -1
- package/src/core/acknowledge.ts +16 -1
- package/src/core/order-fetch-marks.ts +9 -2
- package/dist/chunk-S2ISELNJ.js.map +0 -1
- /package/dist/{chunk-RS2QKQ6S.js.map → chunk-C2MFGZ3H.js.map} +0 -0
package/dist/hono/index.js
CHANGED
package/dist/index.js
CHANGED
package/dist/manifest/server.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MARKETPLACE_JOBS,
|
|
3
3
|
createApiMarketplace
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-C2MFGZ3H.js";
|
|
5
5
|
import "../chunk-LO7OKO6V.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-T6A46MH3.js";
|
|
7
7
|
import "../chunk-Q5RMVNU5.js";
|
|
8
8
|
import "../chunk-7QVYU63E.js";
|
|
9
9
|
|
package/dist/server/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
MARKETPLACE_SWEEP_QUEUE,
|
|
7
7
|
ORDER_NOT_PENDING_CODE,
|
|
8
8
|
createApiMarketplace
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-C2MFGZ3H.js";
|
|
10
10
|
import {
|
|
11
11
|
MARKETPLACE_DECIDE,
|
|
12
12
|
MARKETPLACE_MANAGE,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
upsertMarketplaceIntegrationsBody,
|
|
21
21
|
upsertMarketplaceMenuLinksBody
|
|
22
22
|
} from "../chunk-LO7OKO6V.js";
|
|
23
|
-
import "../chunk-
|
|
23
|
+
import "../chunk-T6A46MH3.js";
|
|
24
24
|
import "../chunk-Q5RMVNU5.js";
|
|
25
25
|
import "../chunk-7QVYU63E.js";
|
|
26
26
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@12-apps/marketplace",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "One marketplace integration engine for every marketplace: the durable inbox, the ingest pipeline, the acceptance clock and its sweep, the SKU map, the integration settings with sealed credentials, and the outbound engine (confirm, cancellation request, retries), behind an adapter port. Each marketplace is an adapter at its own subpath (./ifood, ./99food and ./keeta on Open Delivery, ./rappi). Framework-neutral wiring route descriptors (./server) with a Hono adapter (./hono), dep-free job blueprints, MCP tools and the package-owned Prisma partial + migrations.",
|
package/src/core/acknowledge.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MarketplaceAdapter, OutboundResult } from "./adapter";
|
|
2
2
|
import { readOutboundConnection } from "./integration";
|
|
3
|
+
import { CANCELLED_BEFORE_INGEST_EVENT_TYPE } from "./order-fetch-marks";
|
|
3
4
|
import type { EngineContext } from "./ports";
|
|
4
5
|
import type { MarketplaceProvider } from "./types";
|
|
5
6
|
|
|
@@ -45,6 +46,13 @@ function acknowledgementOf(ctx: EngineContext, provider: string): NonNullable<Ma
|
|
|
45
46
|
return ctx.registry.get(provider)?.acknowledgement ?? null;
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Only rows the marketplace sent are owed: the engine's own marker
|
|
51
|
+
* (`engine:cancelled:<id>`) is never sent, even one an older release left
|
|
52
|
+
* unstamped, or the marketplace refuses the whole batch (FUT-6315).
|
|
53
|
+
*/
|
|
54
|
+
const SENT_BY_THE_MARKETPLACE = { eventType: { not: CANCELLED_BEFORE_INGEST_EVENT_TYPE } } as const;
|
|
55
|
+
|
|
48
56
|
/** How many stores one pass re-queues, per marketplace. */
|
|
49
57
|
const SWEEP_STORES = 500;
|
|
50
58
|
|
|
@@ -94,6 +102,7 @@ export async function runAcknowledge(
|
|
|
94
102
|
provider: payload.provider,
|
|
95
103
|
acknowledgedAt: null,
|
|
96
104
|
receivedAt: { gte: windowStart(ctx, acknowledgement.retentionMs) },
|
|
105
|
+
...SENT_BY_THE_MARKETPLACE,
|
|
97
106
|
},
|
|
98
107
|
orderBy: { receivedAt: "asc" },
|
|
99
108
|
take: acknowledgement.batchSize,
|
|
@@ -164,7 +173,13 @@ export async function sweepAcknowledgements(ctx: EngineContext): Promise<{ reque
|
|
|
164
173
|
const acknowledgement = acknowledgementOf(ctx, provider);
|
|
165
174
|
if (!acknowledgement) continue;
|
|
166
175
|
const rows = (await db.marketplaceInboxEvent.findMany({
|
|
167
|
-
where: {
|
|
176
|
+
where: {
|
|
177
|
+
provider,
|
|
178
|
+
acknowledgedAt: null,
|
|
179
|
+
clientId: { not: null },
|
|
180
|
+
receivedAt: { gte: windowStart(ctx, acknowledgement.retentionMs) },
|
|
181
|
+
...SENT_BY_THE_MARKETPLACE,
|
|
182
|
+
},
|
|
168
183
|
// One row per store, bounded: the next pass takes the rest.
|
|
169
184
|
distinct: ["clientId"],
|
|
170
185
|
take: SWEEP_STORES,
|
|
@@ -22,7 +22,13 @@ import type { MarketplaceProvider } from "./types";
|
|
|
22
22
|
/** The settled reason of a row that was not ingested because its order was cancelled first. */
|
|
23
23
|
export const CANCELLED_BEFORE_INGEST_REASON = "cancelled before its order body arrived";
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The marker row's `eventType`. The row is the engine's own, not an event the
|
|
27
|
+
* marketplace sent, so nothing is owed for it: it is written acknowledged, and
|
|
28
|
+
* the acknowledgment job never reads one (FUT-6315: iFood refused a whole batch
|
|
29
|
+
* that carried `engine:cancelled:<id>` as "an invalid event id").
|
|
30
|
+
*/
|
|
31
|
+
export const CANCELLED_BEFORE_INGEST_EVENT_TYPE = "ENGINE_CANCELLED_BEFORE_INGEST";
|
|
26
32
|
|
|
27
33
|
const markerId = (externalOrderId: string): string => `engine:cancelled:${externalOrderId}`;
|
|
28
34
|
|
|
@@ -38,13 +44,14 @@ export async function markCancelledBeforeIngest(
|
|
|
38
44
|
clientId: input.clientId,
|
|
39
45
|
provider: input.provider,
|
|
40
46
|
eventId: markerId(input.externalOrderId),
|
|
41
|
-
eventType:
|
|
47
|
+
eventType: CANCELLED_BEFORE_INGEST_EVENT_TYPE,
|
|
42
48
|
externalOrderId: input.externalOrderId,
|
|
43
49
|
payload: {},
|
|
44
50
|
status: "IGNORED",
|
|
45
51
|
error: "cancelled before the order was ingested",
|
|
46
52
|
receivedAt: ctx.ports.clock.now(),
|
|
47
53
|
processedAt: ctx.ports.clock.now(),
|
|
54
|
+
acknowledgedAt: ctx.ports.clock.now(),
|
|
48
55
|
},
|
|
49
56
|
select: { id: true },
|
|
50
57
|
});
|