@12-apps/marketplace 1.9.0 → 1.11.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 +63 -1
- package/README.md +64 -1
- package/dist/99food/index.d.ts +2 -2
- package/dist/99food/index.js +2 -2
- package/dist/{adapter-CYJzu1c9.d.ts → adapter-CD0SfdVS.d.ts} +124 -1
- package/dist/{chunk-PYHNM47K.js → chunk-DCWOQ5PN.js} +2 -2
- package/dist/{chunk-6N2HEV3U.js → chunk-OS4TSIFU.js} +190 -12
- package/dist/chunk-OS4TSIFU.js.map +1 -0
- package/dist/chunk-SGOTN5PX.js +345 -0
- package/dist/chunk-SGOTN5PX.js.map +1 -0
- package/dist/{chunk-HEXLCTOG.js → chunk-TVZU4HNT.js} +1 -1
- package/dist/chunk-TVZU4HNT.js.map +1 -0
- package/dist/{chunk-BMCERPQX.js → chunk-YWMEIMO3.js} +221 -27
- package/dist/chunk-YWMEIMO3.js.map +1 -0
- package/dist/{client-B4EQCRD_.d.ts → client-11sncog4.d.ts} +1 -1
- package/dist/{engine-wmW-VuBL.d.ts → engine-C_3RK8wC.d.ts} +207 -64
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +3 -3
- package/dist/ifood/index.d.ts +5 -2
- package/dist/ifood/index.js +125 -7
- package/dist/ifood/index.js.map +1 -1
- package/dist/index.d.ts +23 -4
- package/dist/index.js +280 -26
- 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/index.d.ts +223 -2
- 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 +246 -8
- 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 +47 -0
- package/prisma/migrations/20261126230000_marketplace_menu_link_variation/migration.sql +11 -0
- package/prisma/migrations/20261127090000_marketplace_app_link/migration.sql +81 -0
- package/src/core/adapter.ts +21 -0
- package/src/core/bulk.ts +77 -15
- package/src/core/engine.ts +59 -3
- package/src/core/ingest.ts +2 -1
- package/src/core/integration.ts +60 -32
- 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/menu-links.ts +36 -6
- package/src/core/merchant-claim.ts +106 -0
- package/src/core/order-types.ts +74 -0
- package/src/core/ports.ts +26 -65
- package/src/ifood/index.ts +4 -0
- package/src/ifood/linking.ts +170 -0
- package/src/ifood/outbound.ts +10 -3
- package/src/index.ts +14 -0
- 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 +13 -4
- 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-6N2HEV3U.js.map +0 -1
- package/dist/chunk-BMCERPQX.js.map +0 -1
- package/dist/chunk-HEXLCTOG.js.map +0 -1
- package/dist/chunk-NP4EYKPO.js +0 -252
- package/dist/chunk-NP4EYKPO.js.map +0 -1
- /package/dist/{chunk-PYHNM47K.js.map → chunk-DCWOQ5PN.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/adapter.ts"],"sourcesContent":["import type { MarketplaceCatalogue } from \"./catalogue-port\";\nimport type { CatalogueReader } from \"./catalogue-read-port\";\nimport type { MarketplaceAvailability } from \"./pause-port\";\nimport type {\n MarketplaceDeliveredBy,\n MarketplaceProvider,\n NormalizedEvent,\n NormalizedMarketplaceOrder,\n} from \"./types\";\n\n/**\n * The adapter port: everything one marketplace is, behind one shape.\n *\n * The owner's rule, which this file exists to make true: \"the integration\n * engine must be the same for all integrations: iFood, Rappi, 99. Only an\n * adapter is made for each one, to connect to the base engine.\"\n *\n * A marketplace differs from the next in five ways that matter to a store:\n * how its deliveries look and are signed (`normalize`, `readSignature`,\n * `verifySignature`), what it lets a store answer through its API (`confirm`,\n * `requestCancellation`), which reasons a refusal may carry\n * (`cancellationReasons`), and where a person goes when the API cannot do it\n * (`appLink`). Everything else — the inbox, the clock, the SKU map, the\n * outbound bookkeeping and its retries — is the engine's and does not change\n * with the marketplace.\n *\n * What a marketplace CAN do is stated by its adapter as\n * {@link MarketplaceCapabilities} and read by the engine and the host. It is\n * never inferred from the provider's id: a branch on the id outside an adapter\n * would make the next marketplace a code change instead of an adapter.\n *\n * The HTTP client is a host port ({@link MarketplaceHttp}), handed to every\n * outbound call. An adapter never reaches the network on its own, so tests\n * answer the seam and nothing else, and the host owns the timeout, the proxy\n * and the CA.\n */\n\n/** A marketplace's credentials, as the merchant supplies them. Sealed at rest. */\nexport interface MarketplaceCredentials {\n clientId: string;\n clientSecret: string;\n /**\n * The shared secret a delivery's signature is verified against. Separate\n * from the OAuth pair: a merchant rotating their webhook secret has not\n * re-onboarded.\n */\n webhookSecret: string | null;\n}\n\n/** What the host's HTTP client takes. */\nexport interface MarketplaceHttpRequest {\n /**\n * `PATCH` since FUT-4768: iFood's catalogue sets an item's status with it.\n * `DELETE` since FUT-4851: iFood removes an interruption with it.\n */\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n url: string;\n headers: Record<string, string>;\n body?: string;\n}\n\n/** What the host's HTTP client answers: any status, never a throw for a 4xx or 5xx. */\nexport interface MarketplaceHttpResponse {\n status: number;\n body: string;\n}\n\n/** The host's HTTP client. It throws only when no answer arrived (a timeout, a network error). */\nexport type MarketplaceHttp = (request: MarketplaceHttpRequest) => Promise<MarketplaceHttpResponse>;\n\n/** What a marketplace can do, stated by its adapter. */\nexport interface MarketplaceCapabilities {\n /** Accepting is answered through the API. */\n apiConfirm: boolean;\n /** A cancellation can be requested through the API at all. */\n apiCancel: boolean;\n /** …and still once the order was accepted. */\n cancelAfterAccept: boolean;\n /** The cancellation's outcome arrives later as an event rather than in the answer. */\n asyncCancellationOutcome: boolean;\n /** `appLink` names this order, rather than only the marketplace's portal. */\n perOrderAppLink: boolean;\n /** Confirming states a preparation time. */\n confirmTakesPreparationTime: boolean;\n /**\n * OPTIONAL. How long the marketplace takes, at most, to answer a store's\n * cancellation request, in milliseconds: past it the outbound sweep fails\n * the request as TIMEOUT. Absent: only the 24-hour give-up applies.\n */\n cancellationAnswerWindowMs?: number;\n /**\n * OPTIONAL. The steps this marketplace can be told about (`informStatus`).\n * Absent or empty: the engine tells it nothing.\n */\n statusSteps?: readonly StatusStep[];\n}\n\n/**\n * A step of the order the store tells the marketplace about (FUT-4653): the\n * order is ready for pickup, the courier left, the order was handed over.\n */\nexport type StatusStep = \"READY\" | \"DISPATCHED\" | \"HANDED_OVER\";\n\n/** What a status call is told about the order: who carries it (null: a take-out, or unstated). */\nexport interface StatusFacts {\n step: StatusStep;\n deliveredBy: MarketplaceDeliveredBy | null;\n}\n\n/** One reason a store may give for refusing or cancelling an order. */\nexport interface CancellationReason {\n /** The marketplace's own code, sent verbatim. */\n code: string;\n /** The label the host was configured with for this code (a named pack). */\n label: string;\n /** This reason means \"an item is unavailable\": the host preselects it when stock is short. */\n itemUnavailable: boolean;\n /** The marketplace requires the offending SKUs with this reason. */\n needsItems: boolean;\n}\n\n/** The order an outbound call is about, as the engine knows it. */\nexport interface OutboundOrderRef {\n externalOrderId: string;\n externalDisplayId: string | null;\n /** The host's own id for the order. */\n hostOrderCode: string;\n /** When the engine recorded the order. */\n placedAt: Date;\n}\n\n/** A per-engine token cache an adapter reads and fills. Never persisted. */\nexport type AdapterTokenCache = Map<string, { token: string; expiresAt: number }>;\n\n/** What one outbound call is handed. */\nexport interface AdapterCallContext {\n http: MarketplaceHttp;\n credentials: MarketplaceCredentials;\n environment: \"SANDBOX\" | \"PRODUCTION\";\n /** Written to no row, log or audit entry: memory only, per process. */\n tokens: AdapterTokenCache;\n now: Date;\n}\n\n/** One outbound call's answer, in the three shapes the engine acts on. */\nexport type OutboundResult =\n /** 2xx. For a marketplace whose outcome is asynchronous, \"the request was taken\". */\n | { kind: \"accepted\" }\n /**\n * A final 4xx (not 408/425/429): never retried. `own` marks a refusal that\n * is not the marketplace's judgement of the order: our credentials were not\n * accepted, or our request was malformed. A cancellation request that ends\n * so fails as UNREACHABLE, not REFUSED.\n */\n | { kind: \"refused\"; status: number; message: string; own?: true }\n /** 408, 425, 429, 5xx, a timeout, a network error: retried until the last attempt. */\n | { kind: \"retry\"; reason: string };\n\n/**\n * One order-body fetch's answer: the order, normalized, or the same refusal and\n * retry shapes an outbound call answers with (a 404 for an expired order is a\n * refusal; a 5xx, a timeout or a 429 is a retry).\n */\nexport type FetchOrderResult =\n | { kind: \"order\"; order: NormalizedMarketplaceOrder }\n | Exclude<OutboundResult, { kind: \"accepted\" }>;\n\n/** What a cancellation request carries. */\nexport interface CancellationRequestInput {\n reason: CancellationReason;\n /** Free text from the store; empty means \"the reason's own label\". */\n text: string;\n mode: \"MANUAL\" | \"AUTO\";\n offendingSkus: readonly string[];\n}\n\n/** One marketplace, in and out. */\nexport interface MarketplaceAdapter {\n readonly provider: MarketplaceProvider;\n readonly capabilities: MarketplaceCapabilities;\n /** Inbound: one delivery into the canonical shape, or null when it carries no order id. */\n normalize(payload: unknown): NormalizedEvent | null;\n /** Which header carries this marketplace's signature, read off the request. */\n readSignature(header: (name: string) => string | null): string | null;\n /** Is this delivery's signature the one this store's secret would produce? */\n verifySignature(rawBody: string, signature: string | null, secret: string | null): boolean;\n /** The marketplace's documented reasons, static and offline: a dialog never waits on the network. */\n cancellationReasons(): readonly CancellationReason[];\n /** Tell the marketplace the store accepted the order. */\n confirm(\n ctx: AdapterCallContext,\n order: OutboundOrderRef,\n input: { preparationMinutes: number | null },\n ): Promise<OutboundResult>;\n /** Ask the marketplace to cancel the order, with one of its own reasons. */\n requestCancellation(\n ctx: AdapterCallContext,\n order: OutboundOrderRef,\n input: CancellationRequestInput,\n ): Promise<OutboundResult>;\n /**\n * OPTIONAL. Whether this marketplace takes this step for this kind of order,\n * answered offline, with no call: the job asks it BEFORE it claims anything\n * (an unsupported step leaves no row). Absent: every step in\n * `capabilities.statusSteps` is taken for every order.\n */\n statusSupported?(facts: StatusFacts): boolean;\n /**\n * OPTIONAL. Tell the marketplace the order reached a step (FUT-4653). Called\n * only from the `marketplace.outbound` job, action `status`. `unsupported`\n * (no endpoint for this step and this kind of order) ends the job with no\n * row. Absent: the marketplace is told nothing.\n */\n informStatus?(\n ctx: AdapterCallContext,\n order: OutboundOrderRef,\n facts: StatusFacts,\n ): Promise<OutboundResult | { kind: \"unsupported\" }>;\n /**\n * OPTIONAL. Fetch the order an event announced with `orderToFetch` (a\n * marketplace whose events carry no order body). Called only from the\n * `marketplace.fetch-order` job. An adapter whose events always carry the\n * order (iFood) leaves it out.\n */\n fetchOrder?(ctx: AdapterCallContext, order: { externalOrderId: string }): Promise<FetchOrderResult>;\n /**\n * OPTIONAL. Publishing the store's products to this marketplace's catalogue\n * (FUT-4768): `push` (the adapter writes each item) or `pull` (the\n * marketplace reads a menu document the host serves). Absent: the\n * marketplace cannot be published to, and the host says so.\n */\n readonly catalogue?: MarketplaceCatalogue;\n /**\n * OPTIONAL. Reading the menu the store already keeps on this marketplace,\n * through its own connection, for the host to import (FUT-951). Absent: the\n * menu cannot be read through an API, and the host says so.\n */\n readonly catalogueReader?: CatalogueReader;\n /**\n * OPTIONAL. Closing the store on this marketplace for a while, and opening\n * it again (FUT-4851). Absent: the marketplace cannot be paused through an\n * API, and the host says so.\n */\n readonly availability?: MarketplaceAvailability;\n /** Where \"open it on the marketplace\" goes: the order when `perOrderAppLink`, else the portal. Always https. */\n appLink(order: Pick<OutboundOrderRef, \"externalOrderId\" | \"externalDisplayId\">): string;\n}\n\n/**\n * The 4xx statuses that are NOT a refusal: a request timeout (408), \"too\n * early\" (425) and a rate limit (429) say \"ask again later\" by HTTP's own\n * semantics, and a marketplace rate-limits its merchant API.\n */\nconst TRANSIENT_CLIENT_STATUSES = new Set([408, 425, 429]);\n\n/**\n * Read one HTTP answer the way the engine acts on it. Shared by every adapter\n * whose API speaks plain status codes, so the rule is one rule rather than one\n * per marketplace: 2xx accepted; a 4xx other than 408/425/429 refused and\n * final; everything else (408, 425, 429, 5xx, anything unexpected) retried.\n */\nexport function outboundResultOf(response: MarketplaceHttpResponse): OutboundResult {\n if (response.status >= 200 && response.status < 300) return { kind: \"accepted\" };\n const message = response.body.slice(0, 300);\n const refusal = response.status >= 400 && response.status < 500 && !TRANSIENT_CLIENT_STATUSES.has(response.status);\n if (refusal) return { kind: \"refused\", status: response.status, message };\n return { kind: \"retry\", reason: `status ${response.status}: ${message}` };\n}\n\n/**\n * {@link outboundResultOf} for a token grant: a final 4xx there says our\n * credentials were not accepted, never a judgement of any order, so it is an\n * `own` refusal.\n */\nexport function tokenGrantResultOf(response: MarketplaceHttpResponse): OutboundResult {\n const result = outboundResultOf(response);\n return result.kind === \"refused\" ? { ...result, own: true } : result;\n}\n\n/** A call that never got an answer is a retry, with the reason a log can read. */\nexport async function answered(call: () => Promise<OutboundResult>): Promise<OutboundResult> {\n try {\n return await call();\n } catch (error) {\n return { kind: \"retry\", reason: error instanceof Error ? error.message : String(error) };\n }\n}\n"],"mappings":";;;;;AA6PA,IAAM,4BAA4B,oBAAI,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC;AAQlD,SAAS,iBAAiB,UAAmD;AAClF,MAAI,SAAS,UAAU,OAAO,SAAS,SAAS,IAAK,QAAO,EAAE,MAAM,WAAW;AAC/E,QAAM,UAAU,SAAS,KAAK,MAAM,GAAG,GAAG;AAC1C,QAAM,UAAU,SAAS,UAAU,OAAO,SAAS,SAAS,OAAO,CAAC,0BAA0B,IAAI,SAAS,MAAM;AACjH,MAAI,QAAS,QAAO,EAAE,MAAM,WAAW,QAAQ,SAAS,QAAQ,QAAQ;AACxE,SAAO,EAAE,MAAM,SAAS,QAAQ,UAAU,SAAS,MAAM,KAAK,OAAO,GAAG;AAC1E;AANgB;AAaT,SAAS,mBAAmB,UAAmD;AACpF,QAAM,SAAS,iBAAiB,QAAQ;AACxC,SAAO,OAAO,SAAS,YAAY,EAAE,GAAG,QAAQ,KAAK,KAAK,IAAI;AAChE;AAHgB;AAMhB,eAAsB,SAAS,MAA8D;AAC3F,MAAI;AACF,WAAO,MAAM,KAAK;AAAA,EACpB,SAAS,OAAO;AACd,WAAO,EAAE,MAAM,SAAS,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE;AAAA,EACzF;AACF;AANsB;","names":[]}
|
package/dist/chunk-NP4EYKPO.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__name
|
|
3
|
-
} from "./chunk-7QVYU63E.js";
|
|
4
|
-
|
|
5
|
-
// src/server/contribution.ts
|
|
6
|
-
var MARKETPLACE_PERMISSIONS = {
|
|
7
|
-
source: "@12-apps/marketplace",
|
|
8
|
-
ids: ["marketplace:manage", "marketplace:decide"],
|
|
9
|
-
permissions: {
|
|
10
|
-
"marketplace:manage": { kind: "class" },
|
|
11
|
-
"marketplace:decide": { kind: "class" }
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var MARKETPLACE_MANAGE = "marketplace:manage";
|
|
15
|
-
var MARKETPLACE_DECIDE = "marketplace:decide";
|
|
16
|
-
|
|
17
|
-
// src/server/mcp.ts
|
|
18
|
-
import { z } from "zod";
|
|
19
|
-
var providerSchema = z.string().regex(/^[A-Z][A-Z0-9_]*$/u);
|
|
20
|
-
var environmentSchema = z.enum(["SANDBOX", "PRODUCTION"]);
|
|
21
|
-
var booleanText = z.enum(["true", "false"]);
|
|
22
|
-
var idsText = z.string().transform((text) => text.split(",").map((id) => id.trim()).filter((id) => id !== "")).pipe(z.array(z.string().min(1)).min(1).max(100));
|
|
23
|
-
function noDuplicates(list, field, keyOf) {
|
|
24
|
-
return (rows, ctx) => {
|
|
25
|
-
const seen = /* @__PURE__ */ new Set();
|
|
26
|
-
rows.forEach((row, index) => {
|
|
27
|
-
const key = keyOf(row);
|
|
28
|
-
if (seen.has(key)) {
|
|
29
|
-
ctx.addIssue({ code: "custom", path: [index, field], message: `${field} repeats an earlier row of ${list}` });
|
|
30
|
-
}
|
|
31
|
-
seen.add(key);
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
__name(noDuplicates, "noDuplicates");
|
|
36
|
-
var marketplaceParams = z.strictObject({
|
|
37
|
-
tenantSlug: z.string().min(1)
|
|
38
|
-
});
|
|
39
|
-
var listMarketplaceIntegrationsQuery = z.strictObject({
|
|
40
|
-
ids: idsText.optional(),
|
|
41
|
-
includeArchived: booleanText.optional()
|
|
42
|
-
});
|
|
43
|
-
var credentialsInput = z.strictObject({
|
|
44
|
-
clientId: z.string().trim().min(1),
|
|
45
|
-
clientSecret: z.string().trim().min(1),
|
|
46
|
-
webhookSecret: z.string().trim().min(1).nullable().optional()
|
|
47
|
-
});
|
|
48
|
-
var integrationUpsertInput = z.strictObject({
|
|
49
|
-
operation: z.literal("upsert").optional(),
|
|
50
|
-
provider: providerSchema,
|
|
51
|
-
enabled: z.boolean().optional(),
|
|
52
|
-
environment: environmentSchema.optional(),
|
|
53
|
-
externalMerchantId: z.string().trim().min(1).nullable().optional(),
|
|
54
|
-
autoAccept: z.boolean().optional(),
|
|
55
|
-
followStatus: z.boolean().optional(),
|
|
56
|
-
// Below a minute nothing human can answer in time; above an hour the
|
|
57
|
-
// deadline has stopped describing anything a marketplace would wait for.
|
|
58
|
-
ackSlaSeconds: z.number().int().min(60).max(3600).optional(),
|
|
59
|
-
credentials: credentialsInput.optional()
|
|
60
|
-
});
|
|
61
|
-
var integrationArchiveInput = z.strictObject({
|
|
62
|
-
operation: z.enum(["archive", "unarchive"]),
|
|
63
|
-
provider: providerSchema,
|
|
64
|
-
reason: z.string().trim().min(1).max(500).nullable().optional()
|
|
65
|
-
});
|
|
66
|
-
var upsertMarketplaceIntegrationsBody = z.strictObject({
|
|
67
|
-
validateOnly: z.boolean().optional(),
|
|
68
|
-
integrations: z.array(z.union([integrationArchiveInput, integrationUpsertInput])).min(1).max(20).superRefine(noDuplicates("integrations", "provider", (row) => row.provider))
|
|
69
|
-
});
|
|
70
|
-
var listMarketplaceMenuLinksQuery = z.strictObject({
|
|
71
|
-
provider: providerSchema.optional(),
|
|
72
|
-
// A query string is text: "false" must mean false.
|
|
73
|
-
unmapped: booleanText.optional(),
|
|
74
|
-
ids: idsText.optional()
|
|
75
|
-
});
|
|
76
|
-
var menuLinkInput = z.strictObject({
|
|
77
|
-
provider: providerSchema,
|
|
78
|
-
externalSku: z.string().trim().min(1),
|
|
79
|
-
externalName: z.string().trim().min(1).optional(),
|
|
80
|
-
menuItemId: z.string().min(1).nullable()
|
|
81
|
-
});
|
|
82
|
-
var upsertMarketplaceMenuLinksBody = z.strictObject({
|
|
83
|
-
validateOnly: z.boolean().optional(),
|
|
84
|
-
links: z.array(menuLinkInput).min(1).max(200).superRefine(noDuplicates("links", "externalSku", (row) => `${row.provider}\0${row.externalSku}`))
|
|
85
|
-
});
|
|
86
|
-
var listMarketplaceAcceptancesQuery = z.strictObject({
|
|
87
|
-
ids: idsText.optional()
|
|
88
|
-
});
|
|
89
|
-
var admissionInput = z.strictObject({
|
|
90
|
-
admitStockPastZero: z.boolean().optional()
|
|
91
|
-
});
|
|
92
|
-
var decisionInput = z.discriminatedUnion("decision", [
|
|
93
|
-
z.strictObject({
|
|
94
|
-
orderId: z.string().min(1),
|
|
95
|
-
decision: z.literal("ACCEPT"),
|
|
96
|
-
admission: admissionInput.optional(),
|
|
97
|
-
preparationMinutes: z.number().int().min(1).max(240).optional()
|
|
98
|
-
}),
|
|
99
|
-
z.strictObject({
|
|
100
|
-
orderId: z.string().min(1),
|
|
101
|
-
decision: z.literal("REJECT"),
|
|
102
|
-
reasonCode: z.string().trim().min(1).optional(),
|
|
103
|
-
offendingSkus: z.array(z.string().trim().min(1)).min(1).max(50).optional()
|
|
104
|
-
})
|
|
105
|
-
]);
|
|
106
|
-
var decideMarketplaceOrdersBody = z.strictObject({
|
|
107
|
-
validateOnly: z.boolean().optional(),
|
|
108
|
-
decisions: z.array(decisionInput).min(1).max(50).superRefine(noDuplicates("decisions", "orderId", (row) => row.orderId))
|
|
109
|
-
});
|
|
110
|
-
var reasonSchema = z.object({
|
|
111
|
-
code: z.string(),
|
|
112
|
-
label: z.string(),
|
|
113
|
-
itemUnavailable: z.boolean(),
|
|
114
|
-
needsItems: z.boolean()
|
|
115
|
-
});
|
|
116
|
-
var capabilitiesSchema = z.object({
|
|
117
|
-
apiConfirm: z.boolean(),
|
|
118
|
-
apiCancel: z.boolean(),
|
|
119
|
-
cancelAfterAccept: z.boolean(),
|
|
120
|
-
asyncCancellationOutcome: z.boolean(),
|
|
121
|
-
perOrderAppLink: z.boolean(),
|
|
122
|
-
confirmTakesPreparationTime: z.boolean()
|
|
123
|
-
});
|
|
124
|
-
var integrationSchema = z.object({
|
|
125
|
-
provider: z.string(),
|
|
126
|
-
enabled: z.boolean(),
|
|
127
|
-
environment: environmentSchema,
|
|
128
|
-
status: z.enum(["UNVERIFIED", "VERIFIED", "FAILED"]),
|
|
129
|
-
externalMerchantId: z.string().nullable(),
|
|
130
|
-
autoAccept: z.boolean(),
|
|
131
|
-
followStatus: z.boolean(),
|
|
132
|
-
ackSlaSeconds: z.number().int(),
|
|
133
|
-
connected: z.boolean(),
|
|
134
|
-
lastEventAt: z.string().nullable(),
|
|
135
|
-
lastVerifiedAt: z.string().nullable(),
|
|
136
|
-
archivedAt: z.string().nullable(),
|
|
137
|
-
capabilities: capabilitiesSchema.nullable(),
|
|
138
|
-
reasons: z.array(reasonSchema)
|
|
139
|
-
});
|
|
140
|
-
var menuLinkSchema = z.object({
|
|
141
|
-
id: z.string(),
|
|
142
|
-
provider: z.string(),
|
|
143
|
-
externalSku: z.string(),
|
|
144
|
-
externalName: z.string(),
|
|
145
|
-
menuItemId: z.string().nullable(),
|
|
146
|
-
lastSeenAt: z.string()
|
|
147
|
-
});
|
|
148
|
-
var pendingAcceptanceSchema = z.object({
|
|
149
|
-
id: z.string(),
|
|
150
|
-
orderId: z.string(),
|
|
151
|
-
provider: z.string(),
|
|
152
|
-
externalOrderId: z.string(),
|
|
153
|
-
externalDisplayId: z.string().nullable(),
|
|
154
|
-
totalCents: z.number().int(),
|
|
155
|
-
buyerName: z.string().nullable(),
|
|
156
|
-
acknowledgeBy: z.string().nullable(),
|
|
157
|
-
externalDueAt: z.string().nullable(),
|
|
158
|
-
commissionCents: z.number().int().nullable(),
|
|
159
|
-
unmappedLines: z.number().int(),
|
|
160
|
-
createdAt: z.string().nullable()
|
|
161
|
-
});
|
|
162
|
-
var decidedSchema = z.object({
|
|
163
|
-
orderId: z.string(),
|
|
164
|
-
status: z.enum(["ACCEPTED", "REJECTED"]),
|
|
165
|
-
cancellation: z.enum(["PENDING", "REQUESTED", "CONFIRMED", "FAILED"]).nullable(),
|
|
166
|
-
reasonCode: z.string().nullable(),
|
|
167
|
-
offendingSkus: z.array(z.string())
|
|
168
|
-
});
|
|
169
|
-
var BASE = "/admin/{tenantSlug}/marketplace";
|
|
170
|
-
var MARKETPLACE_MCP_TOOLS = [
|
|
171
|
-
{
|
|
172
|
-
operationId: "listMarketplaceIntegrations",
|
|
173
|
-
method: "GET",
|
|
174
|
-
path: BASE,
|
|
175
|
-
summary: "List one or many of a store's marketplace connections (pass `ids` as provider ids, e.g. `ids=IFOOD`): whether each is enabled, its environment, auto-accept, the acknowledgement window, and each marketplace's capabilities and refusal reasons. Archived connections only with `includeArchived=true`. Never returns the stored credentials: `connected` says only whether a set is on file.",
|
|
176
|
-
tags: ["marketplace"],
|
|
177
|
-
params: marketplaceParams,
|
|
178
|
-
query: listMarketplaceIntegrationsQuery,
|
|
179
|
-
response: z.object({ data: z.array(integrationSchema) }),
|
|
180
|
-
annotations: { readOnly: true }
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
operationId: "upsertMarketplaceIntegrations",
|
|
184
|
-
method: "PUT",
|
|
185
|
-
path: BASE,
|
|
186
|
-
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.",
|
|
187
|
-
tags: ["marketplace"],
|
|
188
|
-
params: marketplaceParams,
|
|
189
|
-
body: upsertMarketplaceIntegrationsBody,
|
|
190
|
-
response: z.object({ data: z.object({ validateOnly: z.boolean(), integrations: z.array(integrationSchema) }) }),
|
|
191
|
-
annotations: { readOnly: false, destructive: false }
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
operationId: "listMarketplaceMenuLinks",
|
|
195
|
-
method: "GET",
|
|
196
|
-
path: `${BASE}/menu-links`,
|
|
197
|
-
summary: "List a store's marketplace SKU map, or the links named by `ids`: every external SKU an incoming order has carried, and the catalog id it resolves to. `unmapped=true` is the attention list: the SKUs that arrived with nothing behind them, newest-seen first. An unmapped SKU never rejects an order.",
|
|
198
|
-
tags: ["marketplace"],
|
|
199
|
-
params: marketplaceParams,
|
|
200
|
-
query: listMarketplaceMenuLinksQuery,
|
|
201
|
-
response: z.object({ data: z.array(menuLinkSchema) }),
|
|
202
|
-
annotations: { readOnly: true }
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
operationId: "upsertMarketplaceMenuLinks",
|
|
206
|
-
method: "PUT",
|
|
207
|
-
path: `${BASE}/menu-links`,
|
|
208
|
-
summary: "Map one or many external marketplace SKUs to the store's catalog ids, or unmap them with `menuItemId: null`, in one all-or-nothing call keyed by (`provider`, `externalSku`). A SKU never seen is created, so a store can map ahead of the first order. Applies to orders ingested from now on. Any problem (a catalog id that is not the store's, a repeated SKU) writes nothing; `validateOnly: true` checks without writing.",
|
|
209
|
-
tags: ["marketplace"],
|
|
210
|
-
params: marketplaceParams,
|
|
211
|
-
body: upsertMarketplaceMenuLinksBody,
|
|
212
|
-
response: z.object({ data: z.object({ validateOnly: z.boolean(), links: z.array(menuLinkSchema) }) }),
|
|
213
|
-
annotations: { readOnly: false, destructive: false }
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
operationId: "listMarketplaceAcceptances",
|
|
217
|
-
method: "GET",
|
|
218
|
-
path: `${BASE}/acceptances`,
|
|
219
|
-
summary: "List the marketplace orders waiting on the store's acceptance, soonest deadline first, or those named by `ids` (order ids). `acknowledgeBy` is the instant the marketplace cancels an unacknowledged order; `unmappedLines` counts the lines that arrived with nothing behind them.",
|
|
220
|
-
tags: ["marketplace"],
|
|
221
|
-
params: marketplaceParams,
|
|
222
|
-
query: listMarketplaceAcceptancesQuery,
|
|
223
|
-
response: z.object({ data: z.array(pendingAcceptanceSchema) }),
|
|
224
|
-
annotations: { readOnly: true }
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
operationId: "decideMarketplaceOrders",
|
|
228
|
-
method: "POST",
|
|
229
|
-
path: `${BASE}/acceptances`,
|
|
230
|
-
summary: "Accept or refuse one or many marketplace orders on the acceptance clock, all-or-nothing. ACCEPT may carry `admission` (`admitStockPastZero: true` after the store was told an item is short) and `preparationMinutes`. REJECT cancels the order here and asks the marketplace to cancel it, with `reasonCode` from the marketplace's own list (see `listMarketplaceIntegrations`; its first reason when omitted) and, for a reason that needs them, `offendingSkus` from the order. Any problem writes nothing: an unknown code or item is a 422, an order no longer awaiting a decision a 409, and the store's own refusal a 409 with its code (e.g. `MARKETPLACE_STOCK_ASK` with the short items). `validateOnly: true` checks everything without writing.",
|
|
231
|
-
tags: ["marketplace"],
|
|
232
|
-
params: marketplaceParams,
|
|
233
|
-
body: decideMarketplaceOrdersBody,
|
|
234
|
-
response: z.object({ data: z.object({ validateOnly: z.boolean(), decisions: z.array(decidedSchema) }) }),
|
|
235
|
-
annotations: { readOnly: false, destructive: true, openWorld: true }
|
|
236
|
-
}
|
|
237
|
-
];
|
|
238
|
-
|
|
239
|
-
export {
|
|
240
|
-
MARKETPLACE_PERMISSIONS,
|
|
241
|
-
MARKETPLACE_MANAGE,
|
|
242
|
-
MARKETPLACE_DECIDE,
|
|
243
|
-
marketplaceParams,
|
|
244
|
-
listMarketplaceIntegrationsQuery,
|
|
245
|
-
upsertMarketplaceIntegrationsBody,
|
|
246
|
-
listMarketplaceMenuLinksQuery,
|
|
247
|
-
upsertMarketplaceMenuLinksBody,
|
|
248
|
-
listMarketplaceAcceptancesQuery,
|
|
249
|
-
decideMarketplaceOrdersBody,
|
|
250
|
-
MARKETPLACE_MCP_TOOLS
|
|
251
|
-
};
|
|
252
|
-
//# sourceMappingURL=chunk-NP4EYKPO.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/contribution.ts","../src/server/mcp.ts"],"sourcesContent":["import type { WirePermissionsContribution } from \"@12-apps/wiring\";\n\n/**\n * THIS PACKAGE'S OWN PERMISSION CONTRIBUTION.\n *\n * Two privileges, kept apart on purpose (the ADR-0117 pattern of naming the\n * act, not the role):\n *\n * - `marketplace:manage` — CONNECT a marketplace (store its credentials, turn\n * it on, set auto-accept and the acceptance window) and MAP its SKUs to the\n * catalog. Committing the store to a commercial relationship and teaching\n * the engine what a SKU means are the same person's job.\n * - `marketplace:decide` — read the acceptance queue and answer it: accept or\n * refuse an order with a reason. That is whoever is on the floor when the\n * clock runs, and a queue only an owner could answer would lapse.\n *\n * Which roles hold either is the HOST's decision; the package only names\n * them. The shape is `@12-apps/rbac`'s `PermissionContribution`, taken from\n * the wiring contract's type-only twin. No labels: a label is a word in a\n * language, and the vocabulary a picker renders is the host's.\n */\nexport const MARKETPLACE_PERMISSIONS = {\n source: \"@12-apps/marketplace\",\n ids: [\"marketplace:manage\", \"marketplace:decide\"],\n permissions: {\n \"marketplace:manage\": { kind: \"class\" },\n \"marketplace:decide\": { kind: \"class\" },\n },\n} as const satisfies WirePermissionsContribution;\n\n/** Connect a marketplace and map its SKUs. */\nexport const MARKETPLACE_MANAGE = \"marketplace:manage\";\n/** Read and answer the acceptance queue. */\nexport const MARKETPLACE_DECIDE = \"marketplace:decide\";\n","import { z } from \"zod\";\n\nimport type { WireMcpTool } from \"@12-apps/wiring\";\n\n/**\n * The marketplace tool surface — authored ONCE, beside the route descriptors\n * it proxies to, and reused as the runtime validators. The advertised schema\n * and what a handler accepts are the same objects, so they cannot drift.\n *\n * The shape is the bulk-upsert protocol: ONE bulk write per entity\n * (connections, SKU links, decisions), each taking a list, all-or-nothing,\n * `validateOnly` supported, idempotent on the natural key, every refusal\n * returned with its path; a connection is ARCHIVED, never deleted. A read is\n * the entity's `list*` tool, taking `ids`.\n *\n * Every input is STRICT (an unknown key is refused, never stripped), and the\n * cross-row checks (a key twice in one call) are part of the schema. The\n * provider is checked for SHAPE here and for EXISTENCE at runtime, because\n * the set of marketplaces is the set of adapters a host registered.\n *\n * Paths are RELATIVE to the http capability's mount (`/api` in the origin\n * host). The webhook is not a tool: a marketplace's server-to-server callback\n * is not a capability anybody invokes.\n */\n\nconst providerSchema = z.string().regex(/^[A-Z][A-Z0-9_]*$/u);\nconst environmentSchema = z.enum([\"SANDBOX\", \"PRODUCTION\"]);\nconst booleanText = z.enum([\"true\", \"false\"]);\n/** A comma-separated id list in a query string: `ids=a,b`. */\nconst idsText = z\n .string()\n .transform((text) => text.split(\",\").map((id) => id.trim()).filter((id) => id !== \"\"))\n .pipe(z.array(z.string().min(1)).min(1).max(100));\n\n/** Flag every row whose key repeats an earlier one, at that row's path. */\nfunction noDuplicates<T>(list: string, field: string, keyOf: (row: T) => string) {\n return (rows: readonly T[], ctx: z.RefinementCtx): void => {\n const seen = new Set<string>();\n rows.forEach((row, index) => {\n const key = keyOf(row);\n if (seen.has(key)) {\n ctx.addIssue({ code: \"custom\", path: [index, field], message: `${field} repeats an earlier row of ${list}` });\n }\n seen.add(key);\n });\n };\n}\n\n/** Path params for the tenant-scoped marketplace resource. */\nexport const marketplaceParams = z.strictObject({\n tenantSlug: z.string().min(1),\n});\n\n/** Which connections to read. */\nexport const listMarketplaceIntegrationsQuery = z.strictObject({\n ids: idsText.optional(),\n includeArchived: booleanText.optional(),\n});\n\n/** The credential half of a save. Absent leaves the stored secrets alone. */\nconst credentialsInput = z.strictObject({\n clientId: z.string().trim().min(1),\n clientSecret: z.string().trim().min(1),\n webhookSecret: z.string().trim().min(1).nullable().optional(),\n});\n\n/** Create or patch one connection; any subset of its settings. */\nconst integrationUpsertInput = z.strictObject({\n operation: z.literal(\"upsert\").optional(),\n provider: providerSchema,\n enabled: z.boolean().optional(),\n environment: environmentSchema.optional(),\n externalMerchantId: z.string().trim().min(1).nullable().optional(),\n autoAccept: z.boolean().optional(),\n followStatus: z.boolean().optional(),\n // Below a minute nothing human can answer in time; above an hour the\n // deadline has stopped describing anything a marketplace would wait for.\n ackSlaSeconds: z.number().int().min(60).max(3600).optional(),\n credentials: credentialsInput.optional(),\n});\n\n/** Archive (reversible) or unarchive one connection, with an optional reason. */\nconst integrationArchiveInput = z.strictObject({\n operation: z.enum([\"archive\", \"unarchive\"]),\n provider: providerSchema,\n reason: z.string().trim().min(1).max(500).nullable().optional(),\n});\n\n/** Many connection changes, all-or-nothing. */\nexport const upsertMarketplaceIntegrationsBody = z.strictObject({\n validateOnly: z.boolean().optional(),\n integrations: z\n .array(z.union([integrationArchiveInput, integrationUpsertInput]))\n .min(1)\n .max(20)\n .superRefine(noDuplicates(\"integrations\", \"provider\", (row) => row.provider)),\n});\n\n/** Filters for the SKU map. `unmapped=true` IS the attention list. */\nexport const listMarketplaceMenuLinksQuery = z.strictObject({\n provider: providerSchema.optional(),\n // A query string is text: \"false\" must mean false.\n unmapped: booleanText.optional(),\n ids: idsText.optional(),\n});\n\n/** Map one external SKU to a catalog id, or unmap it with `menuItemId: null`. */\nconst menuLinkInput = z.strictObject({\n provider: providerSchema,\n externalSku: z.string().trim().min(1),\n externalName: z.string().trim().min(1).optional(),\n menuItemId: z.string().min(1).nullable(),\n});\n\n/** Many SKU links, all-or-nothing; idempotent on (provider, externalSku). */\nexport const upsertMarketplaceMenuLinksBody = z.strictObject({\n validateOnly: z.boolean().optional(),\n links: z\n .array(menuLinkInput)\n .min(1)\n .max(200)\n .superRefine(noDuplicates(\"links\", \"externalSku\", (row) => `${row.provider}\\u0000${row.externalSku}`)),\n});\n\n/** Which queued orders to read. */\nexport const listMarketplaceAcceptancesQuery = z.strictObject({\n ids: idsText.optional(),\n});\n\n/** What the person confirmed beside an accept, for the host's admission. */\nconst admissionInput = z.strictObject({\n admitStockPastZero: z.boolean().optional(),\n});\n\n/**\n * One decision. An accept may carry the admission and a preparation time; a\n * refusal one of the marketplace's reason codes (its first when omitted) and,\n * for a reason that needs them, the order's offending SKUs. A field of the\n * other kind is refused, not ignored.\n */\nconst decisionInput = z.discriminatedUnion(\"decision\", [\n z.strictObject({\n orderId: z.string().min(1),\n decision: z.literal(\"ACCEPT\"),\n admission: admissionInput.optional(),\n preparationMinutes: z.number().int().min(1).max(240).optional(),\n }),\n z.strictObject({\n orderId: z.string().min(1),\n decision: z.literal(\"REJECT\"),\n reasonCode: z.string().trim().min(1).optional(),\n offendingSkus: z.array(z.string().trim().min(1)).min(1).max(50).optional(),\n }),\n]);\n\n/** Many decisions, all-or-nothing, the host admitting each inside one transaction. */\nexport const decideMarketplaceOrdersBody = z.strictObject({\n validateOnly: z.boolean().optional(),\n decisions: z\n .array(decisionInput)\n .min(1)\n .max(50)\n .superRefine(noDuplicates(\"decisions\", \"orderId\", (row) => row.orderId)),\n});\n\nconst reasonSchema = z.object({\n code: z.string(),\n label: z.string(),\n itemUnavailable: z.boolean(),\n needsItems: z.boolean(),\n});\n\nconst capabilitiesSchema = z.object({\n apiConfirm: z.boolean(),\n apiCancel: z.boolean(),\n cancelAfterAccept: z.boolean(),\n asyncCancellationOutcome: z.boolean(),\n perOrderAppLink: z.boolean(),\n confirmTakesPreparationTime: z.boolean(),\n});\n\n/** A connection as every read returns it: `connected` stands in for the secrets. */\nconst integrationSchema = z.object({\n provider: z.string(),\n enabled: z.boolean(),\n environment: environmentSchema,\n status: z.enum([\"UNVERIFIED\", \"VERIFIED\", \"FAILED\"]),\n externalMerchantId: z.string().nullable(),\n autoAccept: z.boolean(),\n followStatus: z.boolean(),\n ackSlaSeconds: z.number().int(),\n connected: z.boolean(),\n lastEventAt: z.string().nullable(),\n lastVerifiedAt: z.string().nullable(),\n archivedAt: z.string().nullable(),\n capabilities: capabilitiesSchema.nullable(),\n reasons: z.array(reasonSchema),\n});\n\nconst menuLinkSchema = z.object({\n id: z.string(),\n provider: z.string(),\n externalSku: z.string(),\n externalName: z.string(),\n menuItemId: z.string().nullable(),\n lastSeenAt: z.string(),\n});\n\nconst pendingAcceptanceSchema = z.object({\n id: z.string(),\n orderId: z.string(),\n provider: z.string(),\n externalOrderId: z.string(),\n externalDisplayId: z.string().nullable(),\n totalCents: z.number().int(),\n buyerName: z.string().nullable(),\n acknowledgeBy: z.string().nullable(),\n externalDueAt: z.string().nullable(),\n commissionCents: z.number().int().nullable(),\n unmappedLines: z.number().int(),\n createdAt: z.string().nullable(),\n});\n\nconst decidedSchema = z.object({\n orderId: z.string(),\n status: z.enum([\"ACCEPTED\", \"REJECTED\"]),\n cancellation: z.enum([\"PENDING\", \"REQUESTED\", \"CONFIRMED\", \"FAILED\"]).nullable(),\n reasonCode: z.string().nullable(),\n offendingSkus: z.array(z.string()),\n});\n\nconst BASE = \"/admin/{tenantSlug}/marketplace\";\n\n/** The six marketplace tools: a read and a bulk write per entity. */\nexport const MARKETPLACE_MCP_TOOLS = [\n {\n operationId: \"listMarketplaceIntegrations\",\n method: \"GET\",\n path: BASE,\n summary:\n \"List one or many of a store's marketplace connections (pass `ids` as provider ids, e.g. `ids=IFOOD`): whether each is enabled, its environment, auto-accept, the acknowledgement window, and each marketplace's capabilities and refusal reasons. Archived connections only with `includeArchived=true`. Never returns the stored credentials: `connected` says only whether a set is on file.\",\n tags: [\"marketplace\"],\n params: marketplaceParams,\n query: listMarketplaceIntegrationsQuery,\n response: z.object({ data: z.array(integrationSchema) }),\n annotations: { readOnly: true },\n },\n {\n operationId: \"upsertMarketplaceIntegrations\",\n method: \"PUT\",\n path: BASE,\n summary:\n \"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.\",\n tags: [\"marketplace\"],\n params: marketplaceParams,\n body: upsertMarketplaceIntegrationsBody,\n response: z.object({ data: z.object({ validateOnly: z.boolean(), integrations: z.array(integrationSchema) }) }),\n annotations: { readOnly: false, destructive: false },\n },\n {\n operationId: \"listMarketplaceMenuLinks\",\n method: \"GET\",\n path: `${BASE}/menu-links`,\n summary:\n \"List a store's marketplace SKU map, or the links named by `ids`: every external SKU an incoming order has carried, and the catalog id it resolves to. `unmapped=true` is the attention list: the SKUs that arrived with nothing behind them, newest-seen first. An unmapped SKU never rejects an order.\",\n tags: [\"marketplace\"],\n params: marketplaceParams,\n query: listMarketplaceMenuLinksQuery,\n response: z.object({ data: z.array(menuLinkSchema) }),\n annotations: { readOnly: true },\n },\n {\n operationId: \"upsertMarketplaceMenuLinks\",\n method: \"PUT\",\n path: `${BASE}/menu-links`,\n summary:\n \"Map one or many external marketplace SKUs to the store's catalog ids, or unmap them with `menuItemId: null`, in one all-or-nothing call keyed by (`provider`, `externalSku`). A SKU never seen is created, so a store can map ahead of the first order. Applies to orders ingested from now on. Any problem (a catalog id that is not the store's, a repeated SKU) writes nothing; `validateOnly: true` checks without writing.\",\n tags: [\"marketplace\"],\n params: marketplaceParams,\n body: upsertMarketplaceMenuLinksBody,\n response: z.object({ data: z.object({ validateOnly: z.boolean(), links: z.array(menuLinkSchema) }) }),\n annotations: { readOnly: false, destructive: false },\n },\n {\n operationId: \"listMarketplaceAcceptances\",\n method: \"GET\",\n path: `${BASE}/acceptances`,\n summary:\n \"List the marketplace orders waiting on the store's acceptance, soonest deadline first, or those named by `ids` (order ids). `acknowledgeBy` is the instant the marketplace cancels an unacknowledged order; `unmappedLines` counts the lines that arrived with nothing behind them.\",\n tags: [\"marketplace\"],\n params: marketplaceParams,\n query: listMarketplaceAcceptancesQuery,\n response: z.object({ data: z.array(pendingAcceptanceSchema) }),\n annotations: { readOnly: true },\n },\n {\n operationId: \"decideMarketplaceOrders\",\n method: \"POST\",\n path: `${BASE}/acceptances`,\n summary:\n \"Accept or refuse one or many marketplace orders on the acceptance clock, all-or-nothing. ACCEPT may carry `admission` (`admitStockPastZero: true` after the store was told an item is short) and `preparationMinutes`. REJECT cancels the order here and asks the marketplace to cancel it, with `reasonCode` from the marketplace's own list (see `listMarketplaceIntegrations`; its first reason when omitted) and, for a reason that needs them, `offendingSkus` from the order. Any problem writes nothing: an unknown code or item is a 422, an order no longer awaiting a decision a 409, and the store's own refusal a 409 with its code (e.g. `MARKETPLACE_STOCK_ASK` with the short items). `validateOnly: true` checks everything without writing.\",\n tags: [\"marketplace\"],\n params: marketplaceParams,\n body: decideMarketplaceOrdersBody,\n response: z.object({ data: z.object({ validateOnly: z.boolean(), decisions: z.array(decidedSchema) }) }),\n annotations: { readOnly: false, destructive: true, openWorld: true },\n },\n] as const satisfies readonly WireMcpTool<z.ZodType>[];\n"],"mappings":";;;;;AAqBO,IAAM,0BAA0B;AAAA,EACrC,QAAQ;AAAA,EACR,KAAK,CAAC,sBAAsB,oBAAoB;AAAA,EAChD,aAAa;AAAA,IACX,sBAAsB,EAAE,MAAM,QAAQ;AAAA,IACtC,sBAAsB,EAAE,MAAM,QAAQ;AAAA,EACxC;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