@12-apps/marketplace 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/ADOPTING.md +17 -0
  2. package/README.md +56 -0
  3. package/dist/99food/index.d.ts +4 -2
  4. package/dist/99food/index.js +32 -3
  5. package/dist/99food/index.js.map +1 -1
  6. package/dist/{adapter-DOjTak1H.d.ts → adapter-CYJzu1c9.d.ts} +45 -1
  7. package/dist/{chunk-YVUZHXUF.js → chunk-6N2HEV3U.js} +4 -4
  8. package/dist/chunk-6N2HEV3U.js.map +1 -0
  9. package/dist/{chunk-SJUKBCVO.js → chunk-BMCERPQX.js} +198 -12
  10. package/dist/chunk-BMCERPQX.js.map +1 -0
  11. package/dist/{chunk-L3DCOZUU.js → chunk-HEXLCTOG.js} +1 -1
  12. package/dist/chunk-HEXLCTOG.js.map +1 -0
  13. package/dist/{chunk-UYFYGGCS.js → chunk-NP4EYKPO.js} +3 -1
  14. package/dist/chunk-NP4EYKPO.js.map +1 -0
  15. package/dist/{engine-DG1fg43Y.d.ts → engine-wmW-VuBL.d.ts} +107 -4
  16. package/dist/hono/index.d.ts +2 -2
  17. package/dist/hono/index.js +3 -3
  18. package/dist/ifood/index.d.ts +1 -1
  19. package/dist/ifood/index.js +29 -3
  20. package/dist/ifood/index.js.map +1 -1
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +104 -7
  23. package/dist/index.js.map +1 -1
  24. package/dist/manifest/index.d.ts +3 -0
  25. package/dist/manifest/index.js +1 -1
  26. package/dist/manifest/server.d.ts +2 -2
  27. package/dist/manifest/server.js +3 -3
  28. package/dist/rappi/index.d.ts +7 -1
  29. package/dist/rappi/index.js +20 -3
  30. package/dist/rappi/index.js.map +1 -1
  31. package/dist/server/index.d.ts +6 -2
  32. package/dist/server/index.js +3 -3
  33. package/package.json +1 -1
  34. package/prisma/marketplace.prisma +45 -1
  35. package/prisma/migrations/20261126120000_marketplace_status_updates/migration.sql +60 -0
  36. package/src/99food/index.ts +6 -0
  37. package/src/99food/normalize.ts +7 -1
  38. package/src/99food/outbound.ts +55 -0
  39. package/src/core/adapter.ts +41 -1
  40. package/src/core/bulk.ts +1 -1
  41. package/src/core/engine.ts +9 -0
  42. package/src/core/ingest.ts +6 -0
  43. package/src/core/integration.ts +17 -0
  44. package/src/core/lifecycle-port.ts +16 -0
  45. package/src/core/lifecycle.ts +133 -0
  46. package/src/core/outbound-queue.ts +24 -4
  47. package/src/core/outbound-sweep.ts +49 -5
  48. package/src/core/outbound.ts +11 -0
  49. package/src/core/pipeline.ts +22 -2
  50. package/src/core/ports.ts +39 -3
  51. package/src/core/status-inform.ts +51 -0
  52. package/src/core/status-job.ts +207 -0
  53. package/src/core/status-store.ts +85 -0
  54. package/src/core/types.ts +14 -0
  55. package/src/ifood/index.ts +7 -1
  56. package/src/ifood/normalize.ts +17 -0
  57. package/src/ifood/outbound.ts +35 -0
  58. package/src/index.ts +6 -0
  59. package/src/rappi/index.ts +6 -1
  60. package/src/rappi/normalize.ts +6 -0
  61. package/src/rappi/outbound.ts +31 -2
  62. package/src/server/mcp.ts +2 -0
  63. package/src/server/webhook.ts +3 -1
  64. package/dist/chunk-L3DCOZUU.js.map +0 -1
  65. package/dist/chunk-SJUKBCVO.js.map +0 -1
  66. package/dist/chunk-UYFYGGCS.js.map +0 -1
  67. package/dist/chunk-YVUZHXUF.js.map +0 -1
@@ -31,4 +31,4 @@ export {
31
31
  tokenGrantResultOf,
32
32
  answered
33
33
  };
34
- //# sourceMappingURL=chunk-L3DCOZUU.js.map
34
+ //# sourceMappingURL=chunk-HEXLCTOG.js.map
@@ -0,0 +1 @@
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":[]}
@@ -52,6 +52,7 @@ var integrationUpsertInput = z.strictObject({
52
52
  environment: environmentSchema.optional(),
53
53
  externalMerchantId: z.string().trim().min(1).nullable().optional(),
54
54
  autoAccept: z.boolean().optional(),
55
+ followStatus: z.boolean().optional(),
55
56
  // Below a minute nothing human can answer in time; above an hour the
56
57
  // deadline has stopped describing anything a marketplace would wait for.
57
58
  ackSlaSeconds: z.number().int().min(60).max(3600).optional(),
@@ -127,6 +128,7 @@ var integrationSchema = z.object({
127
128
  status: z.enum(["UNVERIFIED", "VERIFIED", "FAILED"]),
128
129
  externalMerchantId: z.string().nullable(),
129
130
  autoAccept: z.boolean(),
131
+ followStatus: z.boolean(),
130
132
  ackSlaSeconds: z.number().int(),
131
133
  connected: z.boolean(),
132
134
  lastEventAt: z.string().nullable(),
@@ -247,4 +249,4 @@ export {
247
249
  decideMarketplaceOrdersBody,
248
250
  MARKETPLACE_MCP_TOOLS
249
251
  };
250
- //# sourceMappingURL=chunk-UYFYGGCS.js.map
252
+ //# sourceMappingURL=chunk-NP4EYKPO.js.map
@@ -0,0 +1 @@
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;AACF;AAGO,IAAM,qBAAqB;AAE3B,IAAM,qBAAqB;;;ACjClC,SAAS,SAAS;AAyBlB,IAAM,iBAAiB,EAAE,OAAO,EAAE,MAAM,oBAAoB;AAC5D,IAAM,oBAAoB,EAAE,KAAK,CAAC,WAAW,YAAY,CAAC;AAC1D,IAAM,cAAc,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC;AAE5C,IAAM,UAAU,EACb,OAAO,EACP,UAAU,CAAC,SAAS,KAAK,MAAM,GAAG,EAAE,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,OAAO,EAAE,CAAC,EACpF,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,CAAC;AAGlD,SAAS,aAAgB,MAAc,OAAe,OAA2B;AAC/E,SAAO,CAAC,MAAoB,QAA+B;AACzD,UAAM,OAAO,oBAAI,IAAY;AAC7B,SAAK,QAAQ,CAAC,KAAK,UAAU;AAC3B,YAAM,MAAM,MAAM,GAAG;AACrB,UAAI,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IACP,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,EAAE,CAAC;AAAA,IACpD,aAAa,EAAE,UAAU,KAAK;AAAA,EAChC;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,MAAM,GAAG,IAAI;AAAA,IACb,SACE;AAAA,IACF,MAAM,CAAC,aAAa;AAAA,IACpB,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,GAAG,OAAO,EAAE,MAAM,cAAc,EAAE,CAAC,EAAE,CAAC;AAAA,IACpG,aAAa,EAAE,UAAU,OAAO,aAAa,MAAM;AAAA,EACrD;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,MAAM,GAAG,IAAI;AAAA,IACb,SACE;AAAA,IACF,MAAM,CAAC,aAAa;AAAA,IACpB,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,EAAE,CAAC;AAAA,IAC7D,aAAa,EAAE,UAAU,KAAK;AAAA,EAChC;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,MAAM,GAAG,IAAI;AAAA,IACb,SACE;AAAA,IACF,MAAM,CAAC,aAAa;AAAA,IACpB,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,GAAG,WAAW,EAAE,MAAM,aAAa,EAAE,CAAC,EAAE,CAAC;AAAA,IACvG,aAAa,EAAE,UAAU,OAAO,aAAa,MAAM,WAAW,KAAK;AAAA,EACrE;AACF;","names":[]}
@@ -1,4 +1,21 @@
1
- import { q as CatalogueItem, p as CatalogueImage, a as NormalizedMarketplaceOrder, T as MarketplaceHttp, c as MarketplaceAdapter, i as MarketplaceProvider, L as MarketplaceCredentials, H as CatalogueWarningCode, j as CancellationReason, $ as OutboundOrderRef, N as NormalizedEvent, b as CatalogueMenuOptions, w as CatalogueReadResult } from './adapter-DOjTak1H.js';
1
+ import { Q as MarketplaceDeliveredBy, q as CatalogueItem, p as CatalogueImage, a as NormalizedMarketplaceOrder, N as NormalizedEvent, a3 as StatusStep, T as MarketplaceHttp, c as MarketplaceAdapter, i as MarketplaceProvider, L as MarketplaceCredentials, H as CatalogueWarningCode, W as MarketplaceLifecycle, j as CancellationReason, a0 as OutboundOrderRef, b as CatalogueMenuOptions, w as CatalogueReadResult } from './adapter-CYJzu1c9.js';
2
+
3
+ /** What the engine tells the host about the order a lifecycle event names. */
4
+ interface MarketplaceLifecycleFacts {
5
+ /** Who carries the delivery: the merchant's courier, the marketplace's fleet; null for a take-out or when unstated. */
6
+ deliveredBy: MarketplaceDeliveredBy | null;
7
+ }
8
+ /**
9
+ * The host's answer to a lifecycle event: `moved` (the order moved forward),
10
+ * `unchanged` (it did not, with the engine's default reason), or `unchanged`
11
+ * with the host's own reason, which becomes the inbox row's (an inbox row is
12
+ * a human's; "no courier named for a merchant delivery" is more use than
13
+ * "already at or past DISPATCHED").
14
+ */
15
+ type MarketplaceLifecycleAnswer = "moved" | "unchanged" | {
16
+ kind: "unchanged";
17
+ reason: string;
18
+ };
2
19
 
3
20
  /**
4
21
  * What the engine needs FROM its host, and nothing more.
@@ -89,6 +106,18 @@ interface MarketplaceDb {
89
106
  count: number;
90
107
  }>;
91
108
  };
109
+ /**
110
+ * OPTIONAL in the type, so a host on 1.x that has not yet composed the
111
+ * status model still compiles; the lifecycle and status paths do nothing
112
+ * without it (FUT-4653, migration `20261126120000_marketplace_status_updates`).
113
+ */
114
+ marketplaceStatusUpdate?: {
115
+ findMany(args: unknown): Promise<unknown[]>;
116
+ create(args: unknown): Promise<unknown>;
117
+ updateMany(args: unknown): Promise<{
118
+ count: number;
119
+ }>;
120
+ };
92
121
  }
93
122
  /**
94
123
  * One order line after the engine has matched it against the SKU map.
@@ -221,6 +250,24 @@ interface MarketplaceOrderPort {
221
250
  * marketplace's: a person finishes it there, through the adapter's app link.
222
251
  */
223
252
  onCancellationFailed?(clientId: string, orderId: string, reason: CancellationFailureReason): Promise<void>;
253
+ /**
254
+ * OPTIONAL. The marketplace announced a step of an order the engine holds
255
+ * (`DISPATCHED`, `CONCLUDED`), the connection follows the marketplace's
256
+ * status, and the order is ACCEPTED with no cancellation request standing.
257
+ * Move the order FORWARD to the step if it is not there yet, and never
258
+ * otherwise: answer `unchanged` for an order already there or past it, or
259
+ * one that has no such step. Idempotent by forward-only: a hook that throws
260
+ * leaves the inbox row FAILED and the reconcile pass runs it again. Absent:
261
+ * every lifecycle event is understood and ignored, as before FUT-4653.
262
+ */
263
+ onLifecycle?(clientId: string, orderId: string, event: NormalizedEvent, facts: MarketplaceLifecycleFacts): Promise<MarketplaceLifecycleAnswer>;
264
+ /**
265
+ * OPTIONAL. Does the order still hold this step: the card is at it or past
266
+ * it, not canceled or failed. Asked by the status job right before it tells
267
+ * the marketplace, so a step the store undid in the meantime is never sent.
268
+ * Absent: the engine cannot tell, and sends nothing.
269
+ */
270
+ statusHolds?(clientId: string, orderId: string, step: StatusStep): Promise<boolean>;
224
271
  /** Queue facts for a batch of orders, keyed by id. Missing ids are dropped. */
225
272
  summarize(clientId: string, orderIds: readonly string[]): Promise<Map<string, MarketplaceOrderSummary>>;
226
273
  }
@@ -242,6 +289,7 @@ interface MarketplaceSecretsPort {
242
289
  interface MarketplaceEnqueuePort {
243
290
  enqueue(name: string, payload: unknown, options?: {
244
291
  dedupeKey?: string;
292
+ delayMs?: number;
245
293
  }): Promise<{
246
294
  enqueued: boolean;
247
295
  reason?: string;
@@ -405,6 +453,12 @@ interface MarketplaceIntegrationView {
405
453
  status: "UNVERIFIED" | "VERIFIED" | "FAILED";
406
454
  externalMerchantId: string | null;
407
455
  autoAccept: boolean;
456
+ /**
457
+ * Whether the marketplace's DISPATCHED and CONCLUDED events move the order
458
+ * forward here (FUT-4653). Always set by this version; optional in the type
459
+ * so a view built by hand against 1.x still compiles.
460
+ */
461
+ followStatus?: boolean;
408
462
  ackSlaSeconds: number;
409
463
  /**
410
464
  * Whether the store has a usable connection — i.e. whether secrets are on
@@ -426,6 +480,8 @@ interface SaveMarketplaceIntegrationInput {
426
480
  environment?: "SANDBOX" | "PRODUCTION";
427
481
  externalMerchantId?: string | null;
428
482
  autoAccept?: boolean;
483
+ /** Whether the marketplace's DISPATCHED and CONCLUDED events move the order forward here. New connections: true. */
484
+ followStatus?: boolean;
429
485
  ackSlaSeconds?: number;
430
486
  /**
431
487
  * The secrets, when the operator re-entered them. Absent means "leave the
@@ -438,6 +494,8 @@ interface SaveMarketplaceIntegrationInput {
438
494
  interface IngestionTarget {
439
495
  enabled: boolean;
440
496
  autoAccept: boolean;
497
+ /** Whether lifecycle events move the order forward (FUT-4653). */
498
+ followStatus: boolean;
441
499
  ackSlaSeconds: number;
442
500
  webhookSecret: string | null;
443
501
  /** The merchant the store connected; a fetched order naming another is refused. */
@@ -901,6 +959,12 @@ interface IngestResult {
901
959
  interface IngestSettings {
902
960
  autoAccept: boolean;
903
961
  ackSlaSeconds: number;
962
+ /**
963
+ * OPTIONAL. The connection's switch for following the marketplace's status
964
+ * (FUT-4653). Absent is OFF: a host that builds settings by hand keeps the
965
+ * behaviour it had before the switch existed.
966
+ */
967
+ followStatus?: boolean;
904
968
  }
905
969
 
906
970
  /**
@@ -914,13 +978,23 @@ interface IngestSettings {
914
978
  */
915
979
  /** The wire name, `<namespace>.<blueprint>` as the jobs contribution binds it. */
916
980
  declare const MARKETPLACE_OUTBOUND_JOB = "marketplace.outbound";
917
- /** What goes out: the store's aceite, or the store's cancellation request. */
918
- type OutboundAction = "confirm" | "requestCancellation";
981
+ /**
982
+ * What goes out: the store's aceite, the store's cancellation request, or a
983
+ * step of the order the store reached (`status`, FUT-4653).
984
+ */
985
+ type OutboundAction = "confirm" | "requestCancellation" | "status";
919
986
  /** The outbound job's payload. Identifiers only. */
920
987
  interface OutboundJobPayload {
921
988
  clientId: string;
922
989
  orderId: string;
923
990
  action: OutboundAction;
991
+ /** OPTIONAL. The step a `status` call tells the marketplace about; absent on every other action. */
992
+ step?: StatusStep;
993
+ /**
994
+ * OPTIONAL. The key of the move (or of the sweep's re-claim) a `status` call
995
+ * belongs to: the owner of its SENDING claim. Absent on every other action.
996
+ */
997
+ claimKey?: string;
924
998
  }
925
999
  /** The dedupe key: at most one queued call per (order, action). */
926
1000
  declare function outboundDedupeKey(payload: OutboundJobPayload): string;
@@ -967,6 +1041,22 @@ interface OutboundAttempt {
967
1041
  maxAttempts: number;
968
1042
  }
969
1043
 
1044
+ /** What the host says when an order reaches a step (FUT-4653). */
1045
+ interface InformStatusInput {
1046
+ clientId: string;
1047
+ /** The host's order id. */
1048
+ orderId: string;
1049
+ step: StatusStep;
1050
+ /**
1051
+ * The instant of the move (the card's own timestamp), which makes the job's
1052
+ * key: a re-dispatch after an undo is another instant, and a queue keeps a
1053
+ * finished job's id and would swallow the same key.
1054
+ */
1055
+ at: Date;
1056
+ /** OPTIONAL. Run the job this much later: the board's undo window for a dispatch. */
1057
+ delayMs?: number;
1058
+ }
1059
+
970
1060
  /**
971
1061
  * The pause record: one row per (store, marketplace), the engine's memory of
972
1062
  * what it asked the marketplace and what the marketplace holds (FUT-4851).
@@ -1176,6 +1266,12 @@ type DeliveryOutcome = {
1176
1266
  kind: "ingested";
1177
1267
  orderId: string;
1178
1268
  unmappedSkus: string[];
1269
+ }
1270
+ /** A lifecycle event moved the order forward, through the host's `onLifecycle` (FUT-4653). */
1271
+ | {
1272
+ kind: "moved";
1273
+ orderId: string;
1274
+ lifecycle: MarketplaceLifecycle;
1179
1275
  } | {
1180
1276
  kind: "cancelled";
1181
1277
  } | {
@@ -1328,6 +1424,13 @@ interface MarketplaceEngine {
1328
1424
  sweepOutbound(now?: Date): Promise<OutboundSweepResult>;
1329
1425
  /** Run one queued outbound call (the `marketplace.outbound` job's body). */
1330
1426
  runOutbound(payload: OutboundJobPayload, attempt: OutboundAttempt): Promise<OutboundOutcome>;
1427
+ /**
1428
+ * Tell the marketplace the order reached a step (FUT-4653): ONE enqueue of
1429
+ * the `marketplace.outbound` job, action `status`. Never throws, runs no
1430
+ * statement and calls nobody: the job decides everything else. True when the
1431
+ * queue took it.
1432
+ */
1433
+ informStatus(input: InformStatusInput): Promise<boolean>;
1331
1434
  /** Fetch and ingest one announced order (the `marketplace.fetch-order` job's body). */
1332
1435
  runFetchOrder(payload: FetchOrderJobPayload, attempt: OutboundAttempt): Promise<FetchOrderOutcome>;
1333
1436
  /**
@@ -1398,4 +1501,4 @@ interface MarketplaceEngine {
1398
1501
  */
1399
1502
  declare function createMarketplaceEngine(config: MarketplaceEngineConfig): MarketplaceEngine;
1400
1503
 
1401
- export { type MarketplaceEnqueuePort as $, type AcceptanceDecision as A, type BulkProblem as B, type CancellationFailureReason as C, type DecideManyResult as D, type DeliveryOutcome as E, type ExpirySweepResult as F, type FetchOrderJobPayload as G, type FetchOrderOutcome as H, FetchOrderRetryError as I, type IngestResult as J, type IngestSettings as K, type IngestionTarget as L, type IntegrationRowInput as M, MARKETPLACE_AVAILABILITY_JOB as N, MARKETPLACE_CATALOGUE_JOB as O, MARKETPLACE_FETCH_ORDER_JOB as P, MARKETPLACE_OUTBOUND_JOB as Q, type MarketplaceAdmission as R, type MarketplaceAdmissionRequest as S, type MarketplaceAdmissionResult as T, type MarketplaceAuditEntry as U, type MarketplaceAuditPort as V, type MarketplaceCataloguePort as W, type MarketplaceClockPort as X, type MarketplaceDb as Y, type MarketplaceEngine as Z, type MarketplaceEngineConfig as _, type AcceptanceStatus as a, type MarketplaceIntegrationView as a0, type MarketplaceLogger as a1, type MarketplaceMenuLinkView as a2, type MarketplaceOrderPort as a3, type MarketplaceOrderState as a4, type MarketplaceOrderSummary as a5, type MarketplacePorts as a6, type MarketplaceRefusal as a7, type MarketplaceSecretsPort as a8, type MenuLinkRowInput as a9, OUTBOUND_GIVE_UP_MS as aa, OUTBOUND_STALE_MS as ab, type OutboundAction as ac, type OutboundAttempt as ad, type OutboundJobPayload as ae, type OutboundOutcome as af, OutboundRetryError as ag, type OutboundSweepResult as ah, type PauseOutcome as ai, type PauseStoreInput as aj, type PauseStoreResult as ak, type PendingAcceptance as al, type PendingInboxEvent as am, type ResolvedOrderLine as an, type ResumeOutcome as ao, STORE_PAUSE_LEASE_MS as ap, type SaveMarketplaceIntegrationInput as aq, type StoreAvailabilityView as ar, type StorePauseFailureCode as as, type StorePauseState as at, type StorePauseWanted as au, availabilityDedupeKey as av, catalogueDedupeKey as aw, createMarketplaceEngine as ax, outboundDedupeKey as ay, type AvailabilityJobPayload as b, type AvailabilityOutcome as c, AvailabilityRetryError as d, type AvailabilitySweepResult as e, type BulkProblemCode as f, type BulkResult as g, type CancellationStatus as h, type CatalogueAction as i, type CatalogueActionResult as j, type CatalogueDocumentResult as k, type CatalogueFailedAction as l, type CatalogueFailureCode as m, type CatalogueJobPayload as n, type CatalogueOutcome as o, type CataloguePublicationView as p, type CataloguePublishInput as q, type CatalogueRefusalCode as r, CatalogueRetryError as s, type CatalogueStatus as t, type CatalogueTarget as u, type DecidedRow as v, type DecisionInput as w, type DecisionProblem as x, type DecisionProblemCode as y, type DecisionResult as z };
1504
+ export { type MarketplaceEngineConfig as $, type AcceptanceDecision as A, type BulkProblem as B, type CancellationFailureReason as C, type DecideManyResult as D, type DeliveryOutcome as E, type ExpirySweepResult as F, type FetchOrderJobPayload as G, type FetchOrderOutcome as H, FetchOrderRetryError as I, type InformStatusInput as J, type IngestResult as K, type IngestSettings as L, type IngestionTarget as M, type IntegrationRowInput as N, MARKETPLACE_AVAILABILITY_JOB as O, MARKETPLACE_CATALOGUE_JOB as P, MARKETPLACE_FETCH_ORDER_JOB as Q, MARKETPLACE_OUTBOUND_JOB as R, type MarketplaceAdmission as S, type MarketplaceAdmissionRequest as T, type MarketplaceAdmissionResult as U, type MarketplaceAuditEntry as V, type MarketplaceAuditPort as W, type MarketplaceCataloguePort as X, type MarketplaceClockPort as Y, type MarketplaceDb as Z, type MarketplaceEngine as _, type AcceptanceStatus as a, type MarketplaceEnqueuePort as a0, type MarketplaceIntegrationView as a1, type MarketplaceLifecycleAnswer as a2, type MarketplaceLifecycleFacts as a3, type MarketplaceLogger as a4, type MarketplaceMenuLinkView as a5, type MarketplaceOrderPort as a6, type MarketplaceOrderState as a7, type MarketplaceOrderSummary as a8, type MarketplacePorts as a9, createMarketplaceEngine as aA, outboundDedupeKey as aB, type MarketplaceRefusal as aa, type MarketplaceSecretsPort as ab, type MenuLinkRowInput as ac, OUTBOUND_GIVE_UP_MS as ad, OUTBOUND_STALE_MS as ae, type OutboundAction as af, type OutboundAttempt as ag, type OutboundJobPayload as ah, type OutboundOutcome as ai, OutboundRetryError as aj, type OutboundSweepResult as ak, type PauseOutcome as al, type PauseStoreInput as am, type PauseStoreResult as an, type PendingAcceptance as ao, type PendingInboxEvent as ap, type ResolvedOrderLine as aq, type ResumeOutcome as ar, STORE_PAUSE_LEASE_MS as as, type SaveMarketplaceIntegrationInput as at, type StoreAvailabilityView as au, type StorePauseFailureCode as av, type StorePauseState as aw, type StorePauseWanted as ax, availabilityDedupeKey as ay, catalogueDedupeKey as az, type AvailabilityJobPayload as b, type AvailabilityOutcome as c, AvailabilityRetryError as d, type AvailabilitySweepResult as e, type BulkProblemCode as f, type BulkResult as g, type CancellationStatus as h, type CatalogueAction as i, type CatalogueActionResult as j, type CatalogueDocumentResult as k, type CatalogueFailedAction as l, type CatalogueFailureCode as m, type CatalogueJobPayload as n, type CatalogueOutcome as o, type CataloguePublicationView as p, type CataloguePublishInput as q, type CatalogueRefusalCode as r, CatalogueRetryError as s, type CatalogueStatus as t, type CatalogueTarget as u, type DecidedRow as v, type DecisionInput as w, type DecisionProblem as x, type DecisionProblemCode as y, type DecisionResult as z };
@@ -1,7 +1,7 @@
1
1
  import { Hono, Context } from 'hono';
2
2
  import { ApiMarketplace, MarketplaceApiConfig, MarketplaceActor } from '../server/index.js';
3
- import '../engine-DG1fg43Y.js';
4
- import '../adapter-DOjTak1H.js';
3
+ import '../engine-wmW-VuBL.js';
4
+ import '../adapter-CYJzu1c9.js';
5
5
  import '@12-apps/wiring';
6
6
  import 'zod';
7
7
 
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createApiMarketplace
3
- } from "../chunk-YVUZHXUF.js";
4
- import "../chunk-UYFYGGCS.js";
5
- import "../chunk-SJUKBCVO.js";
3
+ } from "../chunk-6N2HEV3U.js";
4
+ import "../chunk-NP4EYKPO.js";
5
+ import "../chunk-BMCERPQX.js";
6
6
  import {
7
7
  __name
8
8
  } from "../chunk-7QVYU63E.js";
@@ -1,4 +1,4 @@
1
- import { N as NormalizedEvent, d as PushCatalogue, e as CatalogueItemOut, f as CatalogueReader, M as MarketplaceAvailability, A as AdapterCallContext, S as StorePauseRequest, g as StorePauseResult, h as StorePauseRef, O as OutboundResult, c as MarketplaceAdapter } from '../adapter-DOjTak1H.js';
1
+ import { N as NormalizedEvent, d as PushCatalogue, e as CatalogueItemOut, f as CatalogueReader, M as MarketplaceAvailability, A as AdapterCallContext, S as StorePauseRequest, g as StorePauseResult, h as StorePauseRef, O as OutboundResult, c as MarketplaceAdapter } from '../adapter-CYJzu1c9.js';
2
2
 
3
3
  /**
4
4
  * The words the iFood adapter needs from its host, and nothing else.
@@ -17,7 +17,7 @@ import {
17
17
  answered,
18
18
  outboundResultOf,
19
19
  tokenGrantResultOf
20
- } from "../chunk-L3DCOZUU.js";
20
+ } from "../chunk-HEXLCTOG.js";
21
21
  import {
22
22
  __name
23
23
  } from "../chunk-7QVYU63E.js";
@@ -106,6 +106,19 @@ function ifoodRequestCancellation(ctx, order, input) {
106
106
  });
107
107
  }
108
108
  __name(ifoodRequestCancellation, "ifoodRequestCancellation");
109
+ var STATUS_ACTION = {
110
+ READY: /* @__PURE__ */ __name((facts) => facts.deliveredBy === "MERCHANT" ? null : "readyToPickup", "READY"),
111
+ DISPATCHED: /* @__PURE__ */ __name((facts) => facts.deliveredBy === "MERCHANT" ? "dispatch" : null, "DISPATCHED")
112
+ };
113
+ function ifoodStatusSupported(facts) {
114
+ return STATUS_ACTION[facts.step]?.(facts) != null;
115
+ }
116
+ __name(ifoodStatusSupported, "ifoodStatusSupported");
117
+ async function ifoodInformStatus(ctx, order, facts) {
118
+ const action = STATUS_ACTION[facts.step]?.(facts) ?? null;
119
+ return action === null ? { kind: "unsupported" } : postOrder(ctx, order.externalOrderId, action);
120
+ }
121
+ __name(ifoodInformStatus, "ifoodInformStatus");
109
122
 
110
123
  // src/ifood/catalogue.ts
111
124
  var catalogUrl = /* @__PURE__ */ __name((merchantId, path) => `${IFOOD_API}/catalog/v2.0/merchants/${encodeURIComponent(merchantId)}/${path}`, "catalogUrl");
@@ -548,6 +561,12 @@ var IFOOD_CATALOGUE_READER = {
548
561
  var ORDER_PLACED = /* @__PURE__ */ new Set(["PLC", "PLACED", "ORDER_PLACED"]);
549
562
  var ORDER_CANCELLED = /* @__PURE__ */ new Set(["CAN", "CANCELLED", "ORDER_CANCELLED"]);
550
563
  var CANCELLATION_REQUEST_FAILED = /* @__PURE__ */ new Set(["CARF", "CANCELLATION_REQUEST_FAILED"]);
564
+ var LIFECYCLE_OF = {
565
+ DSP: "DISPATCHED",
566
+ DISPATCHED: "DISPATCHED",
567
+ CON: "CONCLUDED",
568
+ CONCLUDED: "CONCLUDED"
569
+ };
551
570
  function verifyIfoodSignature(rawBody, signature, webhookSecret) {
552
571
  return verifyHmacSha256Hex(rawBody, signature, webhookSecret);
553
572
  }
@@ -685,7 +704,8 @@ function normalizeIfoodEvent(payload, options) {
685
704
  externalOrderId,
686
705
  order: placed ? readOrder(payload, externalOrderId, options.missingStreetNumber) : null,
687
706
  cancelled,
688
- cancellationOutcome: cancelled ? "CONFIRMED" : refusedRequest ? "FAILED" : null
707
+ cancellationOutcome: cancelled ? "CONFIRMED" : refusedRequest ? "FAILED" : null,
708
+ ...LIFECYCLE_OF[eventType.toUpperCase()] ? { lifecycle: LIFECYCLE_OF[eventType.toUpperCase()] } : {}
689
709
  };
690
710
  }
691
711
  __name(normalizeIfoodEvent, "normalizeIfoodEvent");
@@ -873,7 +893,11 @@ function createIfoodAdapter(config) {
873
893
  // iFood's documentation, which names no answer deadline: iFood answers a
874
894
  // request in seconds when it answers at all, so 5 minutes is generous.
875
895
  // A host overrides it with the engine's `cancellationWindowMs`.
876
- cancellationAnswerWindowMs: IFOOD_CANCELLATION_ANSWER_WINDOW_MS
896
+ cancellationAnswerWindowMs: IFOOD_CANCELLATION_ANSWER_WINDOW_MS,
897
+ // Told what iFood has an endpoint for (ESTIMATED, see `./outbound.ts`): ready for
898
+ // pickup, and dispatched for a merchant bag. Never "handed over": iFood's own
899
+ // CONCLUDED is that.
900
+ statusSteps: ["READY", "DISPATCHED"]
877
901
  },
878
902
  normalize: /* @__PURE__ */ __name((payload) => normalizeIfoodEvent(payload, normalizeOptions), "normalize"),
879
903
  readSignature: /* @__PURE__ */ __name((header) => header("x-ifood-signature") ?? header("x-signature"), "readSignature"),
@@ -885,6 +909,8 @@ function createIfoodAdapter(config) {
885
909
  catalogueReader: IFOOD_CATALOGUE_READER,
886
910
  confirm: /* @__PURE__ */ __name((ctx, order) => ifoodConfirm(ctx, order), "confirm"),
887
911
  requestCancellation: ifoodRequestCancellation,
912
+ statusSupported: ifoodStatusSupported,
913
+ informStatus: ifoodInformStatus,
888
914
  // The Merchant API's interruptions: an id and an end per closure (FUT-4851).
889
915
  availability: IFOOD_AVAILABILITY,
890
916
  // No per-order deep link is known, so the portal, where a live order is