@12-apps/marketplace 1.10.0 → 1.12.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 +126 -1
- package/README.md +100 -1
- package/dist/99food/index.d.ts +2 -2
- package/dist/99food/index.js +2 -2
- package/dist/{adapter-CYJzu1c9.d.ts → adapter-nUyZpLzz.d.ts} +448 -173
- package/dist/{chunk-2BA2EHNF.js → chunk-45ZVN5XI.js} +316 -42
- package/dist/chunk-45ZVN5XI.js.map +1 -0
- package/dist/{chunk-PYHNM47K.js → chunk-L6FG6T4S.js} +2 -2
- package/dist/{chunk-HEXLCTOG.js → chunk-LACBT6NC.js} +1 -1
- package/dist/chunk-LACBT6NC.js.map +1 -0
- package/dist/{chunk-WVZ2IXFH.js → chunk-MIPNQ7X5.js} +190 -12
- package/dist/chunk-MIPNQ7X5.js.map +1 -0
- package/dist/chunk-SGOTN5PX.js +345 -0
- package/dist/chunk-SGOTN5PX.js.map +1 -0
- package/dist/{client-B4EQCRD_.d.ts → client-Ctas7WCS.d.ts} +1 -1
- package/dist/{engine-DK3iV_Kk.d.ts → engine-CIy9P7Cq.d.ts} +149 -8
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +3 -3
- package/dist/ifood/index.d.ts +10 -2
- package/dist/ifood/index.js +297 -25
- package/dist/ifood/index.js.map +1 -1
- package/dist/index.d.ts +23 -4
- package/dist/index.js +424 -84
- 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/index.d.ts +219 -1
- package/dist/manifest/index.js +1 -1
- 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/en-US.d.ts +13 -0
- package/dist/server/en-US.js +13 -0
- package/dist/server/en-US.js.map +1 -1
- package/dist/server/index.d.ts +241 -7
- package/dist/server/index.js +3 -3
- package/dist/server/pt-BR.d.ts +13 -0
- package/dist/server/pt-BR.js +13 -0
- package/dist/server/pt-BR.js.map +1 -1
- package/package.json +1 -1
- package/prisma/marketplace.prisma +41 -0
- package/prisma/migrations/20261127090000_marketplace_app_link/migration.sql +81 -0
- package/src/core/adapter.ts +27 -0
- package/src/core/bulk.ts +43 -8
- package/src/core/courier-port.ts +100 -0
- package/src/core/courier.ts +153 -0
- package/src/core/engine.ts +63 -4
- package/src/core/integration.ts +60 -32
- package/src/core/lifecycle.ts +27 -4
- package/src/core/link-store.ts +170 -0
- package/src/core/linking-port.ts +100 -0
- package/src/core/linking.ts +363 -0
- package/src/core/merchant-claim.ts +106 -0
- 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 +26 -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/index.ts +8 -0
- package/src/ifood/linking.ts +170 -0
- package/src/ifood/normalize.ts +7 -0
- package/src/ifood/outbound.ts +10 -3
- package/src/index.ts +30 -0
- package/src/keeta/normalize.ts +21 -6
- package/src/server/copy.ts +20 -2
- package/src/server/en-US.ts +13 -0
- package/src/server/index.ts +1 -1
- package/src/server/link-routes.ts +140 -0
- package/src/server/mcp-link.ts +103 -0
- package/src/server/mcp.ts +6 -2
- package/src/server/pt-BR.ts +13 -0
- package/src/server/routes.ts +5 -2
- package/src/server/webhook.ts +86 -0
- package/dist/chunk-2BA2EHNF.js.map +0 -1
- package/dist/chunk-HEXLCTOG.js.map +0 -1
- package/dist/chunk-WVZ2IXFH.js.map +0 -1
- package/dist/chunk-ZO4S3LF4.js +0 -254
- package/dist/chunk-ZO4S3LF4.js.map +0 -1
- /package/dist/{chunk-PYHNM47K.js.map → chunk-L6FG6T4S.js.map} +0 -0
package/dist/server/en-US.js
CHANGED
|
@@ -18,6 +18,19 @@ var MARKETPLACE_SERVER_COPY_EN_US = {
|
|
|
18
18
|
UNKNOWN_PROVIDER: "Unknown marketplace.",
|
|
19
19
|
NOTHING_TO_UPDATE: "Nothing to update.",
|
|
20
20
|
CATALOG_ITEM_NOT_FOUND: "Product not found."
|
|
21
|
+
},
|
|
22
|
+
link: {
|
|
23
|
+
problems: {
|
|
24
|
+
UNAVAILABLE: "Connecting through the app is not available for this marketplace.",
|
|
25
|
+
NO_LINK_IN_PROGRESS: "No connection is in progress. Start again from the first step.",
|
|
26
|
+
LINK_EXPIRED: "The code has expired. Get a new code and repeat the steps.",
|
|
27
|
+
CODE_REFUSED: "The marketplace refused the authorization code. Check the code and paste it again.",
|
|
28
|
+
MARKETPLACE_REFUSED: "The marketplace refused the connection request.",
|
|
29
|
+
NOT_LINKED: "This store is not connected through the app. Connect it again.",
|
|
30
|
+
UNKNOWN_MERCHANT: "This store is not among the ones authorized on the marketplace.",
|
|
31
|
+
MERCHANT_TAKEN: "This marketplace store is already connected to another account."
|
|
32
|
+
},
|
|
33
|
+
tryAgain: "The marketplace did not answer. Try again in a moment."
|
|
21
34
|
}
|
|
22
35
|
};
|
|
23
36
|
export {
|
package/dist/server/en-US.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/en-US.ts"],"sourcesContent":["import type { MarketplaceServerCopy } from \"./copy\";\n\n/** The marketplace routes' en-US pack. */\nexport const MARKETPLACE_SERVER_COPY_EN_US = {\n invalidInput: \"Invalid data.\",\n nothingSaved: \"Nothing was saved. Fix the problems listed and send the whole call again.\",\n orderNoLongerPending: \"This order was already decided or has expired. Refresh the screen.\",\n problems: {\n DUPLICATE: \"This row repeats one earlier in the same call.\",\n NOT_FOUND: \"Not found.\",\n ALREADY_DECIDED: \"This order was already decided.\",\n EXPIRED: \"This order's acceptance window has passed.\",\n CONFLICT: \"Someone else decided this order a moment ago.\",\n INVALID_REASON: \"That reason is not one this marketplace accepts.\",\n ITEMS_REQUIRED: \"This reason needs the items it is about.\",\n UNKNOWN_ITEM: \"This item is not in the order.\",\n HOST_REFUSED: \"The store refused this decision.\",\n UNKNOWN_PROVIDER: \"Unknown marketplace.\",\n NOTHING_TO_UPDATE: \"Nothing to update.\",\n CATALOG_ITEM_NOT_FOUND: \"Product not found.\",\n },\n} as const satisfies MarketplaceServerCopy;\n"],"mappings":";;;AAGO,IAAM,gCAAgC;AAAA,EAC3C,cAAc;AAAA,EACd,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,UAAU;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,wBAAwB;AAAA,EAC1B;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/server/en-US.ts"],"sourcesContent":["import type { MarketplaceServerCopy } from \"./copy\";\n\n/** The marketplace routes' en-US pack. */\nexport const MARKETPLACE_SERVER_COPY_EN_US = {\n invalidInput: \"Invalid data.\",\n nothingSaved: \"Nothing was saved. Fix the problems listed and send the whole call again.\",\n orderNoLongerPending: \"This order was already decided or has expired. Refresh the screen.\",\n problems: {\n DUPLICATE: \"This row repeats one earlier in the same call.\",\n NOT_FOUND: \"Not found.\",\n ALREADY_DECIDED: \"This order was already decided.\",\n EXPIRED: \"This order's acceptance window has passed.\",\n CONFLICT: \"Someone else decided this order a moment ago.\",\n INVALID_REASON: \"That reason is not one this marketplace accepts.\",\n ITEMS_REQUIRED: \"This reason needs the items it is about.\",\n UNKNOWN_ITEM: \"This item is not in the order.\",\n HOST_REFUSED: \"The store refused this decision.\",\n UNKNOWN_PROVIDER: \"Unknown marketplace.\",\n NOTHING_TO_UPDATE: \"Nothing to update.\",\n CATALOG_ITEM_NOT_FOUND: \"Product not found.\",\n },\n link: {\n problems: {\n UNAVAILABLE: \"Connecting through the app is not available for this marketplace.\",\n NO_LINK_IN_PROGRESS: \"No connection is in progress. Start again from the first step.\",\n LINK_EXPIRED: \"The code has expired. Get a new code and repeat the steps.\",\n CODE_REFUSED: \"The marketplace refused the authorization code. Check the code and paste it again.\",\n MARKETPLACE_REFUSED: \"The marketplace refused the connection request.\",\n NOT_LINKED: \"This store is not connected through the app. Connect it again.\",\n UNKNOWN_MERCHANT: \"This store is not among the ones authorized on the marketplace.\",\n MERCHANT_TAKEN: \"This marketplace store is already connected to another account.\",\n },\n tryAgain: \"The marketplace did not answer. Try again in a moment.\",\n },\n} as const satisfies MarketplaceServerCopy;\n"],"mappings":";;;AAGO,IAAM,gCAAgC;AAAA,EAC3C,cAAc;AAAA,EACd,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,UAAU;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,wBAAwB;AAAA,EAC1B;AAAA,EACA,MAAM;AAAA,IACJ,UAAU;AAAA,MACR,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,cAAc;AAAA,MACd,cAAc;AAAA,MACd,qBAAqB;AAAA,MACrB,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,IAClB;AAAA,IACA,UAAU;AAAA,EACZ;AACF;","names":[]}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { y as DecisionProblemCode, f as BulkProblemCode,
|
|
1
|
+
import { y as DecisionProblemCode, f as BulkProblemCode, R as LinkRefusalCode, a3 as MarketplaceEngine, a9 as MarketplaceLogger, am as OutboundJobPayload, G as FetchOrderJobPayload, n as CatalogueJobPayload, b as AvailabilityJobPayload } from '../engine-CIy9P7Cq.js';
|
|
2
2
|
import { WireRoute, WireJobBlueprint } from '@12-apps/wiring';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import '../adapter-
|
|
4
|
+
import '../adapter-nUyZpLzz.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Every problem code a route words from `problems`, decisions and bulk writes
|
|
8
|
+
* alike. MERCHANT_TAKEN is worded by `link.problems` instead (FUT-5613), so a
|
|
9
|
+
* host's own pack written against 1.x still compiles.
|
|
10
|
+
*/
|
|
11
|
+
type MarketplaceProblemCode = DecisionProblemCode | Exclude<BulkProblemCode, "MERCHANT_TAKEN">;
|
|
8
12
|
/**
|
|
9
13
|
* Every sentence the marketplace routes answer with. Required, no defaults
|
|
10
14
|
* (the copy-port doctrine): two packs sit beside it (`./pt-BR`, `./en-US`),
|
|
@@ -23,6 +27,18 @@ interface MarketplaceServerCopy {
|
|
|
23
27
|
orderNoLongerPending: string;
|
|
24
28
|
/** One sentence per problem code, for each `problems[].message`. */
|
|
25
29
|
problems: Readonly<Record<MarketplaceProblemCode, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* OPTIONAL in the type, so a host's own pack written against 1.x still
|
|
32
|
+
* compiles: the sentences of the linking routes (FUT-5613). Absent, those
|
|
33
|
+
* routes answer the machine code as `error`. Both shipped packs carry it.
|
|
34
|
+
*/
|
|
35
|
+
link?: MarketplaceLinkCopy;
|
|
36
|
+
}
|
|
37
|
+
/** What the linking routes say: one sentence per refusal, and one for "try again". */
|
|
38
|
+
interface MarketplaceLinkCopy {
|
|
39
|
+
problems: Readonly<Record<LinkRefusalCode, string>>;
|
|
40
|
+
/** The marketplace did not answer (a timeout, a 5xx, a rate limit). */
|
|
41
|
+
tryAgain: string;
|
|
26
42
|
}
|
|
27
43
|
|
|
28
44
|
/**
|
|
@@ -249,7 +265,7 @@ declare const decideMarketplaceOrdersBody: z.ZodObject<{
|
|
|
249
265
|
offendingSkus: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
250
266
|
}, z.core.$strict>], "decision">>;
|
|
251
267
|
}, z.core.$strict>;
|
|
252
|
-
/** The
|
|
268
|
+
/** The marketplace tools: a read and a bulk write per entity, and the five linking tools (FUT-5613). */
|
|
253
269
|
declare const MARKETPLACE_MCP_TOOLS: readonly [{
|
|
254
270
|
readonly operationId: "listMarketplaceIntegrations";
|
|
255
271
|
readonly method: "GET";
|
|
@@ -287,6 +303,10 @@ declare const MARKETPLACE_MCP_TOOLS: readonly [{
|
|
|
287
303
|
lastEventAt: z.ZodNullable<z.ZodString>;
|
|
288
304
|
lastVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
289
305
|
archivedAt: z.ZodNullable<z.ZodString>;
|
|
306
|
+
authMode: z.ZodEnum<{
|
|
307
|
+
CREDENTIALS: "CREDENTIALS";
|
|
308
|
+
LINKED: "LINKED";
|
|
309
|
+
}>;
|
|
290
310
|
capabilities: z.ZodNullable<z.ZodObject<{
|
|
291
311
|
apiConfirm: z.ZodBoolean;
|
|
292
312
|
apiCancel: z.ZodBoolean;
|
|
@@ -310,7 +330,7 @@ declare const MARKETPLACE_MCP_TOOLS: readonly [{
|
|
|
310
330
|
readonly operationId: "upsertMarketplaceIntegrations";
|
|
311
331
|
readonly method: "PUT";
|
|
312
332
|
readonly path: "/admin/{tenantSlug}/marketplace";
|
|
313
|
-
readonly summary: "Create, update, archive or unarchive one or many marketplace connections in one all-or-nothing call. A row is keyed by `provider`; `operation` is `upsert` (default: any subset of the settings; omitting `credentials` keeps the stored secrets, sending them resets the status to UNVERIFIED), `archive` or `unarchive` (reversible, audited, with an optional `reason`). Any problem writes nothing and every problem comes back with its path. `validateOnly: true` checks without writing.";
|
|
333
|
+
readonly summary: "Create, update, archive or unarchive one or many marketplace connections in one all-or-nothing call. A row is keyed by `provider`; `operation` is `upsert` (default: any subset of the settings; omitting `credentials` keeps the stored secrets, sending them resets the status to UNVERIFIED), `archive` or `unarchive` (reversible, audited, with an optional `reason`). An `externalMerchantId` another store's live connection holds is refused `MERCHANT_TAKEN` at that field (an unarchive reviving one, at `provider`). Any problem writes nothing and every problem comes back with its path. `validateOnly: true` checks without writing.";
|
|
314
334
|
readonly tags: readonly ["marketplace"];
|
|
315
335
|
readonly params: z.ZodObject<{
|
|
316
336
|
tenantSlug: z.ZodString;
|
|
@@ -366,6 +386,10 @@ declare const MARKETPLACE_MCP_TOOLS: readonly [{
|
|
|
366
386
|
lastEventAt: z.ZodNullable<z.ZodString>;
|
|
367
387
|
lastVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
368
388
|
archivedAt: z.ZodNullable<z.ZodString>;
|
|
389
|
+
authMode: z.ZodEnum<{
|
|
390
|
+
CREDENTIALS: "CREDENTIALS";
|
|
391
|
+
LINKED: "LINKED";
|
|
392
|
+
}>;
|
|
369
393
|
capabilities: z.ZodNullable<z.ZodObject<{
|
|
370
394
|
apiConfirm: z.ZodBoolean;
|
|
371
395
|
apiCancel: z.ZodBoolean;
|
|
@@ -536,6 +560,216 @@ declare const MARKETPLACE_MCP_TOOLS: readonly [{
|
|
|
536
560
|
readonly destructive: true;
|
|
537
561
|
readonly openWorld: true;
|
|
538
562
|
};
|
|
563
|
+
}, {
|
|
564
|
+
readonly operationId: "getMarketplaceLink";
|
|
565
|
+
readonly method: "GET";
|
|
566
|
+
readonly path: "/admin/{tenantSlug}/marketplace/link";
|
|
567
|
+
readonly summary: "Read in one call whether a store can connect a marketplace through the software's own app (no credentials typed), and the portal code still in progress, if any: `userCode`, the portal link that already carries it, and when it expires.";
|
|
568
|
+
readonly tags: readonly ["marketplace"];
|
|
569
|
+
readonly params: z.ZodObject<{
|
|
570
|
+
tenantSlug: z.ZodString;
|
|
571
|
+
}, z.core.$strict>;
|
|
572
|
+
readonly query: z.ZodObject<{
|
|
573
|
+
provider: z.ZodString;
|
|
574
|
+
environment: z.ZodOptional<z.ZodEnum<{
|
|
575
|
+
SANDBOX: "SANDBOX";
|
|
576
|
+
PRODUCTION: "PRODUCTION";
|
|
577
|
+
}>>;
|
|
578
|
+
}, z.core.$strict>;
|
|
579
|
+
readonly response: z.ZodObject<{
|
|
580
|
+
data: z.ZodObject<{
|
|
581
|
+
available: z.ZodBoolean;
|
|
582
|
+
pending: z.ZodNullable<z.ZodObject<{
|
|
583
|
+
userCode: z.ZodString;
|
|
584
|
+
verificationUrl: z.ZodString;
|
|
585
|
+
verificationUrlComplete: z.ZodString;
|
|
586
|
+
expiresAt: z.ZodString;
|
|
587
|
+
}, z.core.$strip>>;
|
|
588
|
+
}, z.core.$strip>;
|
|
589
|
+
}, z.core.$strip>;
|
|
590
|
+
readonly annotations: {
|
|
591
|
+
readonly readOnly: true;
|
|
592
|
+
};
|
|
593
|
+
}, {
|
|
594
|
+
readonly operationId: "listMarketplaceLinkMerchants";
|
|
595
|
+
readonly method: "GET";
|
|
596
|
+
readonly path: "/admin/{tenantSlug}/marketplace/link/merchants";
|
|
597
|
+
readonly summary: "List the marketplace stores a linked connection's authorization covers, to choose which one this store is.";
|
|
598
|
+
readonly tags: readonly ["marketplace"];
|
|
599
|
+
readonly params: z.ZodObject<{
|
|
600
|
+
tenantSlug: z.ZodString;
|
|
601
|
+
}, z.core.$strict>;
|
|
602
|
+
readonly query: z.ZodObject<{
|
|
603
|
+
provider: z.ZodString;
|
|
604
|
+
}, z.core.$strict>;
|
|
605
|
+
readonly response: z.ZodObject<{
|
|
606
|
+
data: z.ZodArray<z.ZodObject<{
|
|
607
|
+
id: z.ZodString;
|
|
608
|
+
name: z.ZodNullable<z.ZodString>;
|
|
609
|
+
corporateName: z.ZodNullable<z.ZodString>;
|
|
610
|
+
}, z.core.$strip>>;
|
|
611
|
+
}, z.core.$strip>;
|
|
612
|
+
readonly annotations: {
|
|
613
|
+
readonly readOnly: true;
|
|
614
|
+
readonly openWorld: true;
|
|
615
|
+
};
|
|
616
|
+
}, {
|
|
617
|
+
readonly operationId: "startMarketplaceLink";
|
|
618
|
+
readonly method: "POST";
|
|
619
|
+
readonly path: "/admin/{tenantSlug}/marketplace/link/start";
|
|
620
|
+
readonly summary: "Start connecting a marketplace through the software's own app in one call: answers the code the person types on the marketplace's portal and the portal link that already carries it (valid ten minutes on iFood). Replaces a code in progress. 409 UNAVAILABLE when the software has no app on that marketplace.";
|
|
621
|
+
readonly tags: readonly ["marketplace"];
|
|
622
|
+
readonly params: z.ZodObject<{
|
|
623
|
+
tenantSlug: z.ZodString;
|
|
624
|
+
}, z.core.$strict>;
|
|
625
|
+
readonly body: z.ZodObject<{
|
|
626
|
+
provider: z.ZodString;
|
|
627
|
+
environment: z.ZodOptional<z.ZodEnum<{
|
|
628
|
+
SANDBOX: "SANDBOX";
|
|
629
|
+
PRODUCTION: "PRODUCTION";
|
|
630
|
+
}>>;
|
|
631
|
+
}, z.core.$strict>;
|
|
632
|
+
readonly response: z.ZodObject<{
|
|
633
|
+
data: z.ZodObject<{
|
|
634
|
+
userCode: z.ZodString;
|
|
635
|
+
verificationUrl: z.ZodString;
|
|
636
|
+
verificationUrlComplete: z.ZodString;
|
|
637
|
+
expiresAt: z.ZodString;
|
|
638
|
+
}, z.core.$strip>;
|
|
639
|
+
}, z.core.$strip>;
|
|
640
|
+
readonly annotations: {
|
|
641
|
+
readonly readOnly: false;
|
|
642
|
+
readonly destructive: false;
|
|
643
|
+
readonly openWorld: true;
|
|
644
|
+
};
|
|
645
|
+
}, {
|
|
646
|
+
readonly operationId: "finishMarketplaceLink";
|
|
647
|
+
readonly method: "POST";
|
|
648
|
+
readonly path: "/admin/{tenantSlug}/marketplace/link/finish";
|
|
649
|
+
readonly summary: "Finish connecting, in one call, with the authorization code the marketplace's portal showed the person. Stores the connection as LINKED and selects the marketplace store when the authorization covers only one; `merchants` lists them (null when they could not be listed). 422 CODE_REFUSED for a wrong code (the code in progress stays, paste again); 409 LINK_EXPIRED past its ten minutes.";
|
|
650
|
+
readonly tags: readonly ["marketplace"];
|
|
651
|
+
readonly params: z.ZodObject<{
|
|
652
|
+
tenantSlug: z.ZodString;
|
|
653
|
+
}, z.core.$strict>;
|
|
654
|
+
readonly body: z.ZodObject<{
|
|
655
|
+
provider: z.ZodString;
|
|
656
|
+
authorizationCode: z.ZodString;
|
|
657
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
658
|
+
}, z.core.$strict>;
|
|
659
|
+
readonly response: z.ZodObject<{
|
|
660
|
+
data: z.ZodObject<{
|
|
661
|
+
integration: z.ZodObject<{
|
|
662
|
+
provider: z.ZodString;
|
|
663
|
+
enabled: z.ZodBoolean;
|
|
664
|
+
environment: z.ZodEnum<{
|
|
665
|
+
SANDBOX: "SANDBOX";
|
|
666
|
+
PRODUCTION: "PRODUCTION";
|
|
667
|
+
}>;
|
|
668
|
+
status: z.ZodEnum<{
|
|
669
|
+
FAILED: "FAILED";
|
|
670
|
+
UNVERIFIED: "UNVERIFIED";
|
|
671
|
+
VERIFIED: "VERIFIED";
|
|
672
|
+
}>;
|
|
673
|
+
externalMerchantId: z.ZodNullable<z.ZodString>;
|
|
674
|
+
autoAccept: z.ZodBoolean;
|
|
675
|
+
followStatus: z.ZodBoolean;
|
|
676
|
+
ackSlaSeconds: z.ZodNumber;
|
|
677
|
+
connected: z.ZodBoolean;
|
|
678
|
+
lastEventAt: z.ZodNullable<z.ZodString>;
|
|
679
|
+
lastVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
680
|
+
archivedAt: z.ZodNullable<z.ZodString>;
|
|
681
|
+
authMode: z.ZodEnum<{
|
|
682
|
+
CREDENTIALS: "CREDENTIALS";
|
|
683
|
+
LINKED: "LINKED";
|
|
684
|
+
}>;
|
|
685
|
+
capabilities: z.ZodNullable<z.ZodObject<{
|
|
686
|
+
apiConfirm: z.ZodBoolean;
|
|
687
|
+
apiCancel: z.ZodBoolean;
|
|
688
|
+
cancelAfterAccept: z.ZodBoolean;
|
|
689
|
+
asyncCancellationOutcome: z.ZodBoolean;
|
|
690
|
+
perOrderAppLink: z.ZodBoolean;
|
|
691
|
+
confirmTakesPreparationTime: z.ZodBoolean;
|
|
692
|
+
}, z.core.$strip>>;
|
|
693
|
+
reasons: z.ZodArray<z.ZodObject<{
|
|
694
|
+
code: z.ZodString;
|
|
695
|
+
label: z.ZodString;
|
|
696
|
+
itemUnavailable: z.ZodBoolean;
|
|
697
|
+
needsItems: z.ZodBoolean;
|
|
698
|
+
}, z.core.$strip>>;
|
|
699
|
+
}, z.core.$strip>;
|
|
700
|
+
merchants: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
701
|
+
id: z.ZodString;
|
|
702
|
+
name: z.ZodNullable<z.ZodString>;
|
|
703
|
+
corporateName: z.ZodNullable<z.ZodString>;
|
|
704
|
+
}, z.core.$strip>>>;
|
|
705
|
+
}, z.core.$strip>;
|
|
706
|
+
}, z.core.$strip>;
|
|
707
|
+
readonly annotations: {
|
|
708
|
+
readonly readOnly: false;
|
|
709
|
+
readonly destructive: false;
|
|
710
|
+
readonly openWorld: true;
|
|
711
|
+
};
|
|
712
|
+
}, {
|
|
713
|
+
readonly operationId: "selectMarketplaceLinkMerchant";
|
|
714
|
+
readonly method: "PUT";
|
|
715
|
+
readonly path: "/admin/{tenantSlug}/marketplace/link/merchant";
|
|
716
|
+
readonly summary: "Choose in one call which marketplace store a linked connection is, among those its authorization covers. 422 UNKNOWN_MERCHANT for one it does not cover; 409 MERCHANT_TAKEN when another store's connection holds it.";
|
|
717
|
+
readonly tags: readonly ["marketplace"];
|
|
718
|
+
readonly params: z.ZodObject<{
|
|
719
|
+
tenantSlug: z.ZodString;
|
|
720
|
+
}, z.core.$strict>;
|
|
721
|
+
readonly body: z.ZodObject<{
|
|
722
|
+
provider: z.ZodString;
|
|
723
|
+
merchantId: z.ZodString;
|
|
724
|
+
}, z.core.$strict>;
|
|
725
|
+
readonly response: z.ZodObject<{
|
|
726
|
+
data: z.ZodObject<{
|
|
727
|
+
integration: z.ZodObject<{
|
|
728
|
+
provider: z.ZodString;
|
|
729
|
+
enabled: z.ZodBoolean;
|
|
730
|
+
environment: z.ZodEnum<{
|
|
731
|
+
SANDBOX: "SANDBOX";
|
|
732
|
+
PRODUCTION: "PRODUCTION";
|
|
733
|
+
}>;
|
|
734
|
+
status: z.ZodEnum<{
|
|
735
|
+
FAILED: "FAILED";
|
|
736
|
+
UNVERIFIED: "UNVERIFIED";
|
|
737
|
+
VERIFIED: "VERIFIED";
|
|
738
|
+
}>;
|
|
739
|
+
externalMerchantId: z.ZodNullable<z.ZodString>;
|
|
740
|
+
autoAccept: z.ZodBoolean;
|
|
741
|
+
followStatus: z.ZodBoolean;
|
|
742
|
+
ackSlaSeconds: z.ZodNumber;
|
|
743
|
+
connected: z.ZodBoolean;
|
|
744
|
+
lastEventAt: z.ZodNullable<z.ZodString>;
|
|
745
|
+
lastVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
746
|
+
archivedAt: z.ZodNullable<z.ZodString>;
|
|
747
|
+
authMode: z.ZodEnum<{
|
|
748
|
+
CREDENTIALS: "CREDENTIALS";
|
|
749
|
+
LINKED: "LINKED";
|
|
750
|
+
}>;
|
|
751
|
+
capabilities: z.ZodNullable<z.ZodObject<{
|
|
752
|
+
apiConfirm: z.ZodBoolean;
|
|
753
|
+
apiCancel: z.ZodBoolean;
|
|
754
|
+
cancelAfterAccept: z.ZodBoolean;
|
|
755
|
+
asyncCancellationOutcome: z.ZodBoolean;
|
|
756
|
+
perOrderAppLink: z.ZodBoolean;
|
|
757
|
+
confirmTakesPreparationTime: z.ZodBoolean;
|
|
758
|
+
}, z.core.$strip>>;
|
|
759
|
+
reasons: z.ZodArray<z.ZodObject<{
|
|
760
|
+
code: z.ZodString;
|
|
761
|
+
label: z.ZodString;
|
|
762
|
+
itemUnavailable: z.ZodBoolean;
|
|
763
|
+
needsItems: z.ZodBoolean;
|
|
764
|
+
}, z.core.$strip>>;
|
|
765
|
+
}, z.core.$strip>;
|
|
766
|
+
}, z.core.$strip>;
|
|
767
|
+
}, z.core.$strip>;
|
|
768
|
+
readonly annotations: {
|
|
769
|
+
readonly readOnly: false;
|
|
770
|
+
readonly destructive: false;
|
|
771
|
+
readonly openWorld: true;
|
|
772
|
+
};
|
|
539
773
|
}];
|
|
540
774
|
|
|
541
775
|
/**
|
|
@@ -556,4 +790,4 @@ interface ApiMarketplace {
|
|
|
556
790
|
/** Build the route table over a mounted engine. */
|
|
557
791
|
declare function createApiMarketplace(config: MarketplaceApiConfig): ApiMarketplace;
|
|
558
792
|
|
|
559
|
-
export { type ApiMarketplace, MARKETPLACE_AVAILABILITY_ATTEMPTS, MARKETPLACE_DECIDE, MARKETPLACE_FETCH_ORDER_ATTEMPTS, MARKETPLACE_JOBS, MARKETPLACE_MANAGE, MARKETPLACE_MCP_TOOLS, MARKETPLACE_OUTBOUND_ATTEMPTS, MARKETPLACE_PERMISSIONS, MARKETPLACE_SWEEP_QUEUE, type MarketplaceActor, type MarketplaceApiConfig, type MarketplaceJobDeps, type MarketplaceProblemCode, type MarketplaceRoute, type MarketplaceServerCopy, ORDER_NOT_PENDING_CODE, createApiMarketplace, decideMarketplaceOrdersBody, listMarketplaceAcceptancesQuery, listMarketplaceIntegrationsQuery, listMarketplaceMenuLinksQuery, marketplaceParams, upsertMarketplaceIntegrationsBody, upsertMarketplaceMenuLinksBody };
|
|
793
|
+
export { type ApiMarketplace, MARKETPLACE_AVAILABILITY_ATTEMPTS, MARKETPLACE_DECIDE, MARKETPLACE_FETCH_ORDER_ATTEMPTS, MARKETPLACE_JOBS, MARKETPLACE_MANAGE, MARKETPLACE_MCP_TOOLS, MARKETPLACE_OUTBOUND_ATTEMPTS, MARKETPLACE_PERMISSIONS, MARKETPLACE_SWEEP_QUEUE, type MarketplaceActor, type MarketplaceApiConfig, type MarketplaceJobDeps, type MarketplaceLinkCopy, type MarketplaceProblemCode, type MarketplaceRoute, type MarketplaceServerCopy, ORDER_NOT_PENDING_CODE, createApiMarketplace, decideMarketplaceOrdersBody, listMarketplaceAcceptancesQuery, listMarketplaceIntegrationsQuery, listMarketplaceMenuLinksQuery, marketplaceParams, upsertMarketplaceIntegrationsBody, upsertMarketplaceMenuLinksBody };
|
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-MIPNQ7X5.js";
|
|
10
10
|
import {
|
|
11
11
|
MARKETPLACE_DECIDE,
|
|
12
12
|
MARKETPLACE_MANAGE,
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
marketplaceParams,
|
|
20
20
|
upsertMarketplaceIntegrationsBody,
|
|
21
21
|
upsertMarketplaceMenuLinksBody
|
|
22
|
-
} from "../chunk-
|
|
23
|
-
import "../chunk-
|
|
22
|
+
} from "../chunk-SGOTN5PX.js";
|
|
23
|
+
import "../chunk-45ZVN5XI.js";
|
|
24
24
|
import "../chunk-7QVYU63E.js";
|
|
25
25
|
export {
|
|
26
26
|
MARKETPLACE_AVAILABILITY_ATTEMPTS,
|
package/dist/server/pt-BR.d.ts
CHANGED
|
@@ -17,6 +17,19 @@ declare const MARKETPLACE_SERVER_COPY_PT_BR: {
|
|
|
17
17
|
readonly NOTHING_TO_UPDATE: "Nada para atualizar.";
|
|
18
18
|
readonly CATALOG_ITEM_NOT_FOUND: "Produto não encontrado.";
|
|
19
19
|
};
|
|
20
|
+
readonly link: {
|
|
21
|
+
readonly problems: {
|
|
22
|
+
readonly UNAVAILABLE: "A conexão pelo aplicativo não está disponível para este marketplace.";
|
|
23
|
+
readonly NO_LINK_IN_PROGRESS: "Nenhuma conexão em andamento. Comece de novo pelo primeiro passo.";
|
|
24
|
+
readonly LINK_EXPIRED: "O código expirou. Gere um código novo e repita os passos.";
|
|
25
|
+
readonly CODE_REFUSED: "O marketplace recusou o código de autorização. Confira o código e cole de novo.";
|
|
26
|
+
readonly MARKETPLACE_REFUSED: "O marketplace recusou o pedido de conexão.";
|
|
27
|
+
readonly NOT_LINKED: "Esta loja não está conectada pelo aplicativo. Conecte de novo.";
|
|
28
|
+
readonly UNKNOWN_MERCHANT: "Esta loja não está entre as autorizadas no marketplace.";
|
|
29
|
+
readonly MERCHANT_TAKEN: "Esta loja do marketplace já está conectada a outra conta.";
|
|
30
|
+
};
|
|
31
|
+
readonly tryAgain: "O marketplace não respondeu. Tente de novo em instantes.";
|
|
32
|
+
};
|
|
20
33
|
};
|
|
21
34
|
|
|
22
35
|
export { MARKETPLACE_SERVER_COPY_PT_BR };
|
package/dist/server/pt-BR.js
CHANGED
|
@@ -18,6 +18,19 @@ var MARKETPLACE_SERVER_COPY_PT_BR = {
|
|
|
18
18
|
UNKNOWN_PROVIDER: "Marketplace desconhecido.",
|
|
19
19
|
NOTHING_TO_UPDATE: "Nada para atualizar.",
|
|
20
20
|
CATALOG_ITEM_NOT_FOUND: "Produto n\xE3o encontrado."
|
|
21
|
+
},
|
|
22
|
+
link: {
|
|
23
|
+
problems: {
|
|
24
|
+
UNAVAILABLE: "A conex\xE3o pelo aplicativo n\xE3o est\xE1 dispon\xEDvel para este marketplace.",
|
|
25
|
+
NO_LINK_IN_PROGRESS: "Nenhuma conex\xE3o em andamento. Comece de novo pelo primeiro passo.",
|
|
26
|
+
LINK_EXPIRED: "O c\xF3digo expirou. Gere um c\xF3digo novo e repita os passos.",
|
|
27
|
+
CODE_REFUSED: "O marketplace recusou o c\xF3digo de autoriza\xE7\xE3o. Confira o c\xF3digo e cole de novo.",
|
|
28
|
+
MARKETPLACE_REFUSED: "O marketplace recusou o pedido de conex\xE3o.",
|
|
29
|
+
NOT_LINKED: "Esta loja n\xE3o est\xE1 conectada pelo aplicativo. Conecte de novo.",
|
|
30
|
+
UNKNOWN_MERCHANT: "Esta loja n\xE3o est\xE1 entre as autorizadas no marketplace.",
|
|
31
|
+
MERCHANT_TAKEN: "Esta loja do marketplace j\xE1 est\xE1 conectada a outra conta."
|
|
32
|
+
},
|
|
33
|
+
tryAgain: "O marketplace n\xE3o respondeu. Tente de novo em instantes."
|
|
21
34
|
}
|
|
22
35
|
};
|
|
23
36
|
export {
|
package/dist/server/pt-BR.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/pt-BR.ts"],"sourcesContent":["import type { MarketplaceServerCopy } from \"./copy\";\n\n/** The marketplace routes' pt-BR pack. */\nexport const MARKETPLACE_SERVER_COPY_PT_BR = {\n invalidInput: \"Dados inválidos.\",\n nothingSaved: \"Nada foi salvo. Corrija os problemas listados e envie tudo de novo.\",\n orderNoLongerPending: \"Este pedido já foi decidido ou expirou. Atualize a tela.\",\n problems: {\n DUPLICATE: \"Esta linha repete outra da mesma chamada.\",\n NOT_FOUND: \"Não encontrado.\",\n ALREADY_DECIDED: \"Este pedido já foi decidido.\",\n EXPIRED: \"O prazo para aceitar este pedido passou.\",\n CONFLICT: \"Outra pessoa decidiu este pedido agora há pouco.\",\n INVALID_REASON: \"Motivo inválido para este marketplace.\",\n ITEMS_REQUIRED: \"Este motivo precisa dos itens a que se refere.\",\n UNKNOWN_ITEM: \"Este item não está no pedido.\",\n HOST_REFUSED: \"A loja recusou esta decisão.\",\n UNKNOWN_PROVIDER: \"Marketplace desconhecido.\",\n NOTHING_TO_UPDATE: \"Nada para atualizar.\",\n CATALOG_ITEM_NOT_FOUND: \"Produto não encontrado.\",\n },\n} as const satisfies MarketplaceServerCopy;\n"],"mappings":";;;AAGO,IAAM,gCAAgC;AAAA,EAC3C,cAAc;AAAA,EACd,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,UAAU;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,wBAAwB;AAAA,EAC1B;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/server/pt-BR.ts"],"sourcesContent":["import type { MarketplaceServerCopy } from \"./copy\";\n\n/** The marketplace routes' pt-BR pack. */\nexport const MARKETPLACE_SERVER_COPY_PT_BR = {\n invalidInput: \"Dados inválidos.\",\n nothingSaved: \"Nada foi salvo. Corrija os problemas listados e envie tudo de novo.\",\n orderNoLongerPending: \"Este pedido já foi decidido ou expirou. Atualize a tela.\",\n problems: {\n DUPLICATE: \"Esta linha repete outra da mesma chamada.\",\n NOT_FOUND: \"Não encontrado.\",\n ALREADY_DECIDED: \"Este pedido já foi decidido.\",\n EXPIRED: \"O prazo para aceitar este pedido passou.\",\n CONFLICT: \"Outra pessoa decidiu este pedido agora há pouco.\",\n INVALID_REASON: \"Motivo inválido para este marketplace.\",\n ITEMS_REQUIRED: \"Este motivo precisa dos itens a que se refere.\",\n UNKNOWN_ITEM: \"Este item não está no pedido.\",\n HOST_REFUSED: \"A loja recusou esta decisão.\",\n UNKNOWN_PROVIDER: \"Marketplace desconhecido.\",\n NOTHING_TO_UPDATE: \"Nada para atualizar.\",\n CATALOG_ITEM_NOT_FOUND: \"Produto não encontrado.\",\n },\n link: {\n problems: {\n UNAVAILABLE: \"A conexão pelo aplicativo não está disponível para este marketplace.\",\n NO_LINK_IN_PROGRESS: \"Nenhuma conexão em andamento. Comece de novo pelo primeiro passo.\",\n LINK_EXPIRED: \"O código expirou. Gere um código novo e repita os passos.\",\n CODE_REFUSED: \"O marketplace recusou o código de autorização. Confira o código e cole de novo.\",\n MARKETPLACE_REFUSED: \"O marketplace recusou o pedido de conexão.\",\n NOT_LINKED: \"Esta loja não está conectada pelo aplicativo. Conecte de novo.\",\n UNKNOWN_MERCHANT: \"Esta loja não está entre as autorizadas no marketplace.\",\n MERCHANT_TAKEN: \"Esta loja do marketplace já está conectada a outra conta.\",\n },\n tryAgain: \"O marketplace não respondeu. Tente de novo em instantes.\",\n },\n} as const satisfies MarketplaceServerCopy;\n"],"mappings":";;;AAGO,IAAM,gCAAgC;AAAA,EAC3C,cAAc;AAAA,EACd,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,UAAU;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,wBAAwB;AAAA,EAC1B;AAAA,EACA,MAAM;AAAA,IACJ,UAAU;AAAA,MACR,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,cAAc;AAAA,MACd,cAAc;AAAA,MACd,qBAAqB;AAAA,MACrB,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,IAClB;AAAA,IACA,UAAU;AAAA,EACZ;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@12-apps/marketplace",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
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.",
|
|
@@ -67,6 +67,12 @@ model MarketplaceIntegration {
|
|
|
67
67
|
/// and carrying VERIFIED across a rotation asserts a probe that never ran.
|
|
68
68
|
status String @default("UNVERIFIED")
|
|
69
69
|
|
|
70
|
+
/// CREDENTIALS | LINKED (CHECK). CREDENTIALS: the store's own app, its
|
|
71
|
+
/// client id and secret in `credentials`. LINKED: the store authorized the
|
|
72
|
+
/// software's own app (FUT-5613); `credentials` holds only its refresh token,
|
|
73
|
+
/// and the app's credentials are the host's configuration.
|
|
74
|
+
authMode String @default("CREDENTIALS") @map("auth_mode")
|
|
75
|
+
|
|
70
76
|
lastEventAt DateTime? @map("last_event_at")
|
|
71
77
|
lastVerifiedAt DateTime? @map("last_verified_at")
|
|
72
78
|
|
|
@@ -80,6 +86,9 @@ model MarketplaceIntegration {
|
|
|
80
86
|
|
|
81
87
|
@@unique([clientId, provider])
|
|
82
88
|
@@index([provider, externalMerchantId])
|
|
89
|
+
// One LIVE connection per (provider, externalMerchantId) is a partial unique index
|
|
90
|
+
// (WHERE archived_at IS NULL), which Prisma cannot express, as
|
|
91
|
+
// marketplace_integrations_live_merchant_key (migration 20261127090000, FUT-5613).
|
|
83
92
|
@@map("marketplace_integrations")
|
|
84
93
|
}
|
|
85
94
|
|
|
@@ -457,3 +466,35 @@ model MarketplaceStatusUpdate {
|
|
|
457
466
|
// 'SENDING'), which Prisma cannot express, as marketplace_acceptances_cancellation_waiting_idx.
|
|
458
467
|
@@map("marketplace_status_updates")
|
|
459
468
|
}
|
|
469
|
+
|
|
470
|
+
/// One store's linking in progress through the software's own app (FUT-5613):
|
|
471
|
+
/// the code it types on the marketplace's portal, and the VERIFIER the exchange
|
|
472
|
+
/// needs, sealed by the host's secrets port and never sent to a browser.
|
|
473
|
+
///
|
|
474
|
+
/// At most one per (store, marketplace): starting again replaces it. The row
|
|
475
|
+
/// is short-lived by nature (the marketplace's code lives ten minutes) and is
|
|
476
|
+
/// removed by the exchange that uses it; it is not a connection and never
|
|
477
|
+
/// reads as one.
|
|
478
|
+
model MarketplaceLinkAttempt {
|
|
479
|
+
id String @id @default(uuid())
|
|
480
|
+
clientId String @map("client_id")
|
|
481
|
+
provider String
|
|
482
|
+
|
|
483
|
+
/// SANDBOX | PRODUCTION (CHECK): the app the code was asked of.
|
|
484
|
+
environment String @default("PRODUCTION")
|
|
485
|
+
|
|
486
|
+
/// The verifier, sealed. Opened only by the exchange.
|
|
487
|
+
verifier String
|
|
488
|
+
|
|
489
|
+
/// What the screen shows again after a reload: the code and the portal links.
|
|
490
|
+
userCode String @map("user_code")
|
|
491
|
+
verificationUrl String @map("verification_url")
|
|
492
|
+
verificationUrlComplete String @map("verification_url_complete")
|
|
493
|
+
expiresAt DateTime @map("expires_at")
|
|
494
|
+
|
|
495
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
496
|
+
updatedAt DateTime @updatedAt @map("updated_at")
|
|
497
|
+
|
|
498
|
+
@@unique([clientId, provider])
|
|
499
|
+
@@map("marketplace_link_attempts")
|
|
500
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
-- @domains: marketplace
|
|
2
|
+
-- @12-apps/marketplace: linking a store through the software's own app (FUT-5613).
|
|
3
|
+
-- Additive and replay-safe, like the engine's earlier migrations: one new
|
|
4
|
+
-- column with a default, one new table with its CHECKs and its unique, and one
|
|
5
|
+
-- partial unique index. No foreign key into a host table, and nothing the
|
|
6
|
+
-- previous release reads is changed.
|
|
7
|
+
--
|
|
8
|
+
-- `auth_mode` says how a connection authenticates: CREDENTIALS (the store's
|
|
9
|
+
-- own app, every existing row) or LINKED (the store authorized the software's
|
|
10
|
+
-- app; the sealed `credentials` blob holds its refresh token).
|
|
11
|
+
--
|
|
12
|
+
-- `marketplace_link_attempts` holds one linking in progress per (store,
|
|
13
|
+
-- marketplace): the portal code shown to the person and the sealed verifier
|
|
14
|
+
-- the exchange needs, removed by the exchange that uses it.
|
|
15
|
+
|
|
16
|
+
ALTER TABLE "marketplace_integrations" ADD COLUMN IF NOT EXISTS "auth_mode" TEXT NOT NULL DEFAULT 'CREDENTIALS';
|
|
17
|
+
|
|
18
|
+
DO $$ BEGIN
|
|
19
|
+
ALTER TABLE "marketplace_integrations" ADD CONSTRAINT "marketplace_integrations_auth_mode_check"
|
|
20
|
+
CHECK ("auth_mode" IN ('CREDENTIALS', 'LINKED'));
|
|
21
|
+
EXCEPTION WHEN duplicate_object THEN NULL; END $$;
|
|
22
|
+
|
|
23
|
+
CREATE TABLE IF NOT EXISTS "marketplace_link_attempts" (
|
|
24
|
+
"id" TEXT NOT NULL,
|
|
25
|
+
"client_id" TEXT NOT NULL,
|
|
26
|
+
"provider" TEXT NOT NULL,
|
|
27
|
+
"environment" TEXT NOT NULL DEFAULT 'PRODUCTION',
|
|
28
|
+
"verifier" TEXT NOT NULL,
|
|
29
|
+
"user_code" TEXT NOT NULL,
|
|
30
|
+
"verification_url" TEXT NOT NULL,
|
|
31
|
+
"verification_url_complete" TEXT NOT NULL,
|
|
32
|
+
"expires_at" TIMESTAMP(3) NOT NULL,
|
|
33
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
34
|
+
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
35
|
+
|
|
36
|
+
CONSTRAINT "marketplace_link_attempts_pkey" PRIMARY KEY ("id")
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
DO $$ BEGIN
|
|
40
|
+
ALTER TABLE "marketplace_link_attempts" ADD CONSTRAINT "marketplace_link_attempts_provider_shape"
|
|
41
|
+
CHECK ("provider" ~ '^[A-Z][A-Z0-9_]*$');
|
|
42
|
+
EXCEPTION WHEN duplicate_object THEN NULL; END $$;
|
|
43
|
+
|
|
44
|
+
DO $$ BEGIN
|
|
45
|
+
ALTER TABLE "marketplace_link_attempts" ADD CONSTRAINT "marketplace_link_attempts_environment_check"
|
|
46
|
+
CHECK ("environment" IN ('SANDBOX', 'PRODUCTION'));
|
|
47
|
+
EXCEPTION WHEN duplicate_object THEN NULL; END $$;
|
|
48
|
+
|
|
49
|
+
-- One linking in progress per store and marketplace: starting again replaces it.
|
|
50
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "marketplace_link_attempts_client_id_provider_key"
|
|
51
|
+
ON "marketplace_link_attempts"("client_id", "provider");
|
|
52
|
+
|
|
53
|
+
-- One live connection per marketplace store: the app's single webhook address
|
|
54
|
+
-- routes a delivery by the merchant id it names, so two live rows holding one
|
|
55
|
+
-- merchant would hand one store's orders to another. Archived rows and rows
|
|
56
|
+
-- with no merchant yet are outside the index.
|
|
57
|
+
--
|
|
58
|
+
-- Until this release nothing refused a merchant id another store held, so a
|
|
59
|
+
-- host may already have such pairs. The index is then NOT created, and no row
|
|
60
|
+
-- is rewritten or archived: which store a marketplace store really is, is the
|
|
61
|
+
-- host's call. The engine still refuses every new duplicate and attributes an
|
|
62
|
+
-- ambiguous merchant to nobody; a later migration adds the index once the host
|
|
63
|
+
-- has resolved them (the WARNING names how many).
|
|
64
|
+
DO $$
|
|
65
|
+
DECLARE
|
|
66
|
+
duplicates integer;
|
|
67
|
+
BEGIN
|
|
68
|
+
SELECT count(*) INTO duplicates FROM (
|
|
69
|
+
SELECT 1 FROM "marketplace_integrations"
|
|
70
|
+
WHERE "archived_at" IS NULL AND "external_merchant_id" IS NOT NULL
|
|
71
|
+
GROUP BY "provider", "external_merchant_id"
|
|
72
|
+
HAVING count(*) > 1
|
|
73
|
+
) AS held_twice;
|
|
74
|
+
IF duplicates > 0 THEN
|
|
75
|
+
RAISE WARNING 'marketplace_integrations_live_merchant_key not created: % merchant id(s) are held by more than one live connection', duplicates;
|
|
76
|
+
ELSE
|
|
77
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "marketplace_integrations_live_merchant_key"
|
|
78
|
+
ON "marketplace_integrations"("provider", "external_merchant_id")
|
|
79
|
+
WHERE "archived_at" IS NULL AND "external_merchant_id" IS NOT NULL;
|
|
80
|
+
END IF;
|
|
81
|
+
END $$;
|
package/src/core/adapter.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { MarketplaceCatalogue } from "./catalogue-port";
|
|
2
|
+
import type { MarketplaceCourierApi } from "./courier-port";
|
|
2
3
|
import type { CatalogueReader } from "./catalogue-read-port";
|
|
4
|
+
import type { MarketplaceLinking } from "./linking-port";
|
|
3
5
|
import type { MarketplaceAvailability } from "./pause-port";
|
|
4
6
|
import type {
|
|
5
7
|
MarketplaceDeliveredBy,
|
|
@@ -132,14 +134,29 @@ export interface OutboundOrderRef {
|
|
|
132
134
|
/** A per-engine token cache an adapter reads and fills. Never persisted. */
|
|
133
135
|
export type AdapterTokenCache = Map<string, { token: string; expiresAt: number }>;
|
|
134
136
|
|
|
137
|
+
/**
|
|
138
|
+
* A connection LINKED through the software's own app (FUT-5613): the store's
|
|
139
|
+
* access token comes from its refresh token, not from a client-credentials
|
|
140
|
+
* grant. `key` is where the token sits in {@link AdapterTokenCache} (delete it
|
|
141
|
+
* to forget a token the marketplace refused); `accessToken` answers the cached
|
|
142
|
+
* one or refreshes, once per connection however many calls ask at once.
|
|
143
|
+
*/
|
|
144
|
+
export interface AdapterGrant {
|
|
145
|
+
key: string;
|
|
146
|
+
accessToken(): Promise<{ token: string } | OutboundResult>;
|
|
147
|
+
}
|
|
148
|
+
|
|
135
149
|
/** What one outbound call is handed. */
|
|
136
150
|
export interface AdapterCallContext {
|
|
137
151
|
http: MarketplaceHttp;
|
|
152
|
+
/** The store's own credentials, or, for a linked connection, the software's app. */
|
|
138
153
|
credentials: MarketplaceCredentials;
|
|
139
154
|
environment: "SANDBOX" | "PRODUCTION";
|
|
140
155
|
/** Written to no row, log or audit entry: memory only, per process. */
|
|
141
156
|
tokens: AdapterTokenCache;
|
|
142
157
|
now: Date;
|
|
158
|
+
/** Present for a linked connection: the token comes from here, never from a client-credentials grant. */
|
|
159
|
+
grant?: AdapterGrant;
|
|
143
160
|
}
|
|
144
161
|
|
|
145
162
|
/** One outbound call's answer, in the three shapes the engine acts on. */
|
|
@@ -242,6 +259,16 @@ export interface MarketplaceAdapter {
|
|
|
242
259
|
* API, and the host says so.
|
|
243
260
|
*/
|
|
244
261
|
readonly availability?: MarketplaceAvailability;
|
|
262
|
+
/**
|
|
263
|
+
* OPTIONAL. Linking a store through the software's own app on this
|
|
264
|
+
* marketplace (FUT-5613). Absent: a store connects with its own credentials only.
|
|
265
|
+
*/
|
|
266
|
+
readonly linking?: MarketplaceLinking;
|
|
267
|
+
/**
|
|
268
|
+
* OPTIONAL. The marketplace's own courier (FUT-5665): the pickup-code check
|
|
269
|
+
* and the tracking read. Absent: neither is offered, and the host says so.
|
|
270
|
+
*/
|
|
271
|
+
readonly courier?: MarketplaceCourierApi;
|
|
245
272
|
/** Where "open it on the marketplace" goes: the order when `perOrderAppLink`, else the portal. Always https. */
|
|
246
273
|
appLink(order: Pick<OutboundOrderRef, "externalOrderId" | "externalDisplayId">): string;
|
|
247
274
|
}
|