@12-apps/marketplace 1.1.0 → 1.3.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 (92) hide show
  1. package/ADOPTING.md +37 -7
  2. package/README.md +238 -4
  3. package/dist/99food/en-US.d.ts +19 -0
  4. package/dist/99food/en-US.js +23 -0
  5. package/dist/99food/en-US.js.map +1 -0
  6. package/dist/99food/index.d.ts +162 -0
  7. package/dist/99food/index.js +444 -0
  8. package/dist/99food/index.js.map +1 -0
  9. package/dist/99food/pt-BR.d.ts +23 -0
  10. package/dist/99food/pt-BR.js +23 -0
  11. package/dist/99food/pt-BR.js.map +1 -0
  12. package/dist/{adapter-BggtVFf9.d.ts → adapter-0l_EmuJA.d.ts} +206 -2
  13. package/dist/{chunk-NGNEL4HS.js → chunk-AYYBRQJV.js} +52 -4
  14. package/dist/chunk-AYYBRQJV.js.map +1 -0
  15. package/dist/chunk-BD7DS3XM.js +78 -0
  16. package/dist/chunk-BD7DS3XM.js.map +1 -0
  17. package/dist/chunk-M2V4RFMA.js +23 -0
  18. package/dist/chunk-M2V4RFMA.js.map +1 -0
  19. package/dist/{chunk-7BYVGNU5.js → chunk-RVBTARIY.js} +1 -1
  20. package/dist/chunk-RVBTARIY.js.map +1 -0
  21. package/dist/chunk-XUAFXNOH.js +1604 -0
  22. package/dist/chunk-XUAFXNOH.js.map +1 -0
  23. package/dist/{engine-KrgZ4pA4.d.ts → engine-CZsP8KWd.d.ts} +278 -2
  24. package/dist/hono/index.d.ts +2 -2
  25. package/dist/hono/index.js +2 -2
  26. package/dist/ifood/index.d.ts +16 -12
  27. package/dist/ifood/index.js +248 -121
  28. package/dist/ifood/index.js.map +1 -1
  29. package/dist/index.d.ts +30 -4
  30. package/dist/index.js +189 -346
  31. package/dist/index.js.map +1 -1
  32. package/dist/manifest/server.d.ts +4 -2
  33. package/dist/manifest/server.js +2 -2
  34. package/dist/rappi/en-US.d.ts +14 -0
  35. package/dist/rappi/en-US.js +18 -0
  36. package/dist/rappi/en-US.js.map +1 -0
  37. package/dist/rappi/index.d.ts +190 -0
  38. package/dist/rappi/index.js +359 -0
  39. package/dist/rappi/index.js.map +1 -0
  40. package/dist/rappi/pt-BR.d.ts +18 -0
  41. package/dist/rappi/pt-BR.js +18 -0
  42. package/dist/rappi/pt-BR.js.map +1 -0
  43. package/dist/server/index.d.ts +19 -8
  44. package/dist/server/index.js +4 -2
  45. package/package.json +26 -2
  46. package/prisma/marketplace.prisma +97 -2
  47. package/prisma/migrations/20261113120000_marketplace_catalogue/migration.sql +97 -0
  48. package/src/99food/catalogue.ts +117 -0
  49. package/src/99food/copy.ts +36 -0
  50. package/src/99food/en-US.ts +19 -0
  51. package/src/99food/index.ts +125 -0
  52. package/src/99food/normalize.ts +263 -0
  53. package/src/99food/outbound.ts +220 -0
  54. package/src/99food/pt-BR.ts +23 -0
  55. package/src/core/adapter.ts +27 -2
  56. package/src/core/catalogue-category.ts +119 -0
  57. package/src/core/catalogue-ids.ts +23 -0
  58. package/src/core/catalogue-job.ts +332 -0
  59. package/src/core/catalogue-port.ts +173 -0
  60. package/src/core/catalogue-store.ts +172 -0
  61. package/src/core/catalogue-sweep.ts +43 -0
  62. package/src/core/catalogue.ts +226 -0
  63. package/src/core/decisions.ts +16 -4
  64. package/src/core/engine.ts +54 -0
  65. package/src/core/fetch-order.ts +253 -0
  66. package/src/core/inbox.ts +8 -2
  67. package/src/core/ingest.ts +10 -2
  68. package/src/core/integration.ts +30 -1
  69. package/src/core/order-fetch-marks.ts +63 -0
  70. package/src/core/outbound-sweep.ts +7 -2
  71. package/src/core/outbound.ts +22 -2
  72. package/src/core/payload-read.ts +101 -0
  73. package/src/core/pipeline.ts +64 -15
  74. package/src/core/ports.ts +36 -0
  75. package/src/core/types.ts +14 -0
  76. package/src/ifood/catalogue.ts +273 -0
  77. package/src/ifood/index.ts +4 -0
  78. package/src/ifood/normalize.ts +15 -88
  79. package/src/ifood/outbound.ts +9 -6
  80. package/src/index.ts +49 -1
  81. package/src/rappi/copy.ts +39 -0
  82. package/src/rappi/en-US.ts +14 -0
  83. package/src/rappi/index.ts +161 -0
  84. package/src/rappi/normalize.ts +314 -0
  85. package/src/rappi/outbound.ts +182 -0
  86. package/src/rappi/pt-BR.ts +18 -0
  87. package/src/server/index.ts +1 -0
  88. package/src/server/jobs.ts +71 -8
  89. package/dist/chunk-7BYVGNU5.js.map +0 -1
  90. package/dist/chunk-DVIRN42O.js +0 -707
  91. package/dist/chunk-DVIRN42O.js.map +0 -1
  92. package/dist/chunk-NGNEL4HS.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as NormalizedMarketplaceOrder, h as MarketplaceHttp, M as MarketplaceAdapter, a as MarketplaceProvider, f as MarketplaceCredentials, C as CancellationReason, O as OutboundOrderRef, N as NormalizedEvent } from './adapter-BggtVFf9.js';
1
+ import { m as CatalogueItem, l as CatalogueImage, a as NormalizedMarketplaceOrder, v as MarketplaceHttp, M as MarketplaceAdapter, e as MarketplaceProvider, t as MarketplaceCredentials, q as CatalogueWarningCode, f as CancellationReason, O as OutboundOrderRef, N as NormalizedEvent, b as CatalogueMenuOptions } from './adapter-0l_EmuJA.js';
2
2
 
3
3
  /**
4
4
  * What the engine needs FROM its host, and nothing more.
@@ -55,6 +55,27 @@ interface MarketplaceDb {
55
55
  count: number;
56
56
  }>;
57
57
  };
58
+ /**
59
+ * OPTIONAL in the type, so a host on 1.x that has not yet composed the
60
+ * catalogue model still compiles; the catalogue calls refuse without it
61
+ * (FUT-4768, migration `20261113120000_marketplace_catalogue`).
62
+ */
63
+ marketplaceCataloguePublication?: {
64
+ findFirst(args: unknown): Promise<unknown>;
65
+ findMany(args: unknown): Promise<unknown[]>;
66
+ upsert(args: unknown): Promise<unknown>;
67
+ updateMany(args: unknown): Promise<{
68
+ count: number;
69
+ }>;
70
+ };
71
+ /** OPTIONAL, as above: the marketplace's category ids, found or created once per name. */
72
+ marketplaceCatalogueCategory?: {
73
+ findFirst(args: unknown): Promise<unknown>;
74
+ create(args: unknown): Promise<unknown>;
75
+ updateMany(args: unknown): Promise<{
76
+ count: number;
77
+ }>;
78
+ };
58
79
  }
59
80
  /**
60
81
  * One order line after the engine has matched it against the SKU map.
@@ -220,6 +241,18 @@ interface MarketplaceLogger {
220
241
  warn(message: string, ...meta: unknown[]): void;
221
242
  error(message: string, ...meta: unknown[]): void;
222
243
  }
244
+ /**
245
+ * The host's catalogue, as the catalogue publishing reads it (FUT-4768). The
246
+ * engine never reads a host table: the host maps its product into the item
247
+ * shape, at the moment the job sends it, so what goes out is the product as it
248
+ * is now rather than as it was when the switch was turned on.
249
+ */
250
+ interface MarketplaceCataloguePort {
251
+ /** These products as they go out, keyed by product id. Missing ids are products that no longer exist. */
252
+ items(clientId: string, productIds: readonly string[]): Promise<Map<string, CatalogueItem>>;
253
+ /** The bytes behind an item's photo, for a marketplace that takes an upload; null when they cannot be read. */
254
+ image(url: string): Promise<CatalogueImage | null>;
255
+ }
223
256
  /** Everything the host plugs in. */
224
257
  interface MarketplacePorts {
225
258
  db: () => Promise<MarketplaceDb>;
@@ -251,6 +284,11 @@ interface MarketplacePorts {
251
284
  * only given up on after `OUTBOUND_GIVE_UP_MS`.
252
285
  */
253
286
  cancellationWindowMs?: number;
287
+ /**
288
+ * OPTIONAL. The host's catalogue, for publishing products to a marketplace's
289
+ * catalogue. Absent: every catalogue call answers `UNSUPPORTED`.
290
+ */
291
+ catalogue?: MarketplaceCataloguePort;
254
292
  /** The acceptance window a connection gets when it does not state its own. */
255
293
  defaultAckSlaSeconds: number;
256
294
  /** How many stored deliveries one reconciliation pass re-runs. */
@@ -367,6 +405,8 @@ interface IngestionTarget {
367
405
  autoAccept: boolean;
368
406
  ackSlaSeconds: number;
369
407
  webhookSecret: string | null;
408
+ /** The merchant the store connected; a fetched order naming another is refused. */
409
+ externalMerchantId: string | null;
370
410
  }
371
411
 
372
412
  /**
@@ -526,6 +566,208 @@ type DecisionResult = ({
526
566
  details?: unknown;
527
567
  };
528
568
 
569
+ /**
570
+ * The catalogue publication's rows and the reads every catalogue path shares
571
+ * (FUT-4768). The table is `marketplace_catalogue_publications`; its states
572
+ * are the mechanism's vocabulary, never a language.
573
+ */
574
+ /** Where one product stands in one marketplace's catalogue. */
575
+ type CatalogueStatus = "PUBLISHING" | "PUBLISHED" | "WITHDRAWING" | "WITHDRAWN" | "FAILED";
576
+ /** Which action a FAILED row failed at. */
577
+ type CatalogueFailedAction = "PUBLISH" | "WITHDRAW";
578
+ /**
579
+ * Why a row FAILED, as a code the host turns into its own words. Vocabulary,
580
+ * not copy: the engine writes no sentence a person reads.
581
+ *
582
+ * - `REFUSED` — the marketplace said no; its own words are in `failureReason`.
583
+ * - `UNAVAILABLE` — no usable answer on any attempt (5xx, 429, timeouts).
584
+ * - `TIMEOUT` — still on its way a day later (the sweep gave up).
585
+ * - `NOT_CONNECTED` — no live connection with a merchant id (archived, removed).
586
+ * - `CREDENTIALS` — no credentials on file, or they would not open.
587
+ * - `PRODUCT_GONE` — the host's catalogue no longer has the product.
588
+ * - `UNSUPPORTED` — the marketplace has no catalogue capability any more.
589
+ * - `INTERNAL` — the engine or the adapter threw (logged, never shown).
590
+ */
591
+ type CatalogueFailureCode = "REFUSED" | "UNAVAILABLE" | "TIMEOUT" | "NOT_CONNECTED" | "CREDENTIALS" | "PRODUCT_GONE" | "UNSUPPORTED" | "INTERNAL";
592
+ /** One publication as a host reads it. */
593
+ interface CataloguePublicationView {
594
+ provider: MarketplaceProvider;
595
+ productId: string;
596
+ status: CatalogueStatus;
597
+ /** The store's price for this marketplace; null is "the store's own price". */
598
+ priceCents: number | null;
599
+ /** The price the last successful publish sent. */
600
+ sentPriceCents: number | null;
601
+ /** The marketplace's id for the item, from the last successful publish. */
602
+ externalId: string | null;
603
+ /** What the last successful publish could not do (the photo); null when it did everything. */
604
+ warningCode: CatalogueWarningCode | null;
605
+ failedAction: CatalogueFailedAction | null;
606
+ /** Why it FAILED; null unless FAILED. The host's copy is keyed by it. */
607
+ failureCode: CatalogueFailureCode | null;
608
+ /**
609
+ * The marketplace's OWN words for a `REFUSED` (its answer's body, truncated);
610
+ * null for every other code. Never an engine or internal message.
611
+ */
612
+ failureReason: string | null;
613
+ requestedAt: Date;
614
+ publishedAt: Date | null;
615
+ withdrawnAt: Date | null;
616
+ failedAt: Date | null;
617
+ }
618
+
619
+ /**
620
+ * Catalogue publishing, as a host calls it (FUT-4768): from a product's page,
621
+ * the store turns the product ON (`publish`) or OFF (`withdraw`) per connected
622
+ * marketplace, with an optional price for that marketplace, and reads where
623
+ * each stands (`catalogueState`, one read for a whole page).
624
+ *
625
+ * Nothing here calls a marketplace: a publish or withdraw stamps the row and
626
+ * queues `marketplace.catalogue`, whose job makes the call. The host's product
627
+ * is read through its `catalogue` port, never from a host table, and only the
628
+ * job reads it for sending, so what goes out is the product as it is then.
629
+ */
630
+ /** Why a catalogue call was refused before anything was stamped. Vocabulary, not copy. */
631
+ type CatalogueRefusalCode =
632
+ /** The marketplace has no catalogue capability, or the host bound no catalogue port or table. */
633
+ "UNSUPPORTED"
634
+ /** No live connection with credentials and a merchant id. */
635
+ | "NOT_CONNECTED"
636
+ /** The host's catalogue does not have this product. */
637
+ | "UNKNOWN_PRODUCT"
638
+ /** The price for the marketplace is not a positive integer of the smallest unit. */
639
+ | "INVALID_PRICE";
640
+ /** What `publish` and `withdraw` answer. */
641
+ type CatalogueActionResult =
642
+ /** Stamped and queued (or already on its way: a double tap is this, with nothing new queued). */
643
+ {
644
+ kind: "queued";
645
+ publication: CataloguePublicationView;
646
+ }
647
+ /** Nothing to do: the product is not in that marketplace's catalogue, or was never there. */
648
+ | {
649
+ kind: "unchanged";
650
+ publication: CataloguePublicationView | null;
651
+ } | {
652
+ kind: "refused";
653
+ code: CatalogueRefusalCode;
654
+ };
655
+ /** What a pull marketplace's menu document read answers. */
656
+ type CatalogueDocumentResult = {
657
+ kind: "document";
658
+ document: unknown;
659
+ } | {
660
+ kind: "refused";
661
+ code: Exclude<CatalogueRefusalCode, "UNKNOWN_PRODUCT" | "INVALID_PRICE">;
662
+ };
663
+ /** One product on one marketplace. */
664
+ interface CatalogueTarget {
665
+ clientId: string;
666
+ provider: MarketplaceProvider;
667
+ productId: string;
668
+ }
669
+ /** A publish: the target, and the price for this marketplace — absent keeps the stored one, null is the store's. */
670
+ interface CataloguePublishInput extends CatalogueTarget {
671
+ priceCents?: number | null;
672
+ }
673
+
674
+ /**
675
+ * The catalogue job (`marketplace.catalogue`): one publish or withdraw of one
676
+ * product on one marketplace, start to finish (FUT-4768).
677
+ *
678
+ * The same rules as the outbound job, for the same reasons:
679
+ *
680
+ * - **idempotent by the ROW** — a run acts only while the row still asks for
681
+ * its action (PUBLISHING for a publish, WITHDRAWING for a withdraw) at the
682
+ * instant it was asked (`requested_at`), so a duplicate or stale job calls
683
+ * nobody, and a stamp never overwrites a newer ask;
684
+ * - **2xx done, a final 4xx FAILED with the marketplace's reason, anything
685
+ * else retried** until the last attempt, which ends FAILED;
686
+ * - **queued, never called inline** — `publish` and `withdraw` only stamp and
687
+ * enqueue; the sweep re-queues a row still owed.
688
+ *
689
+ * Push or pull is the adapter's `catalogue.mode`, never a provider check: a
690
+ * push marketplace gets the item written or withdrawn; a pull marketplace is
691
+ * told its menu changed (the host serves the document, which already reflects
692
+ * the row).
693
+ */
694
+ /** The wire name, `<namespace>.<blueprint>` as the jobs contribution binds it. */
695
+ declare const MARKETPLACE_CATALOGUE_JOB = "marketplace.catalogue";
696
+ /** What one run does to its row. */
697
+ type CatalogueAction = "publish" | "withdraw";
698
+ /** The job's payload. Identifiers only: what to send lives on the row and in the host's catalogue. */
699
+ interface CatalogueJobPayload {
700
+ clientId: string;
701
+ publicationId: string;
702
+ action: CatalogueAction;
703
+ }
704
+ /** What one run did. */
705
+ type CatalogueOutcome = {
706
+ kind: "skipped";
707
+ reason: string;
708
+ } | {
709
+ kind: "done";
710
+ action: CatalogueAction;
711
+ }
712
+ /** `reason` is the row's failure code; the detail went to the log. */
713
+ | {
714
+ kind: "failed";
715
+ action: CatalogueAction;
716
+ reason: string;
717
+ };
718
+ /** Thrown so the queue retries. Its message is what the job log reads. */
719
+ declare class CatalogueRetryError extends Error {
720
+ constructor(message: string);
721
+ }
722
+ /** The dedupe key: one queued run per (row, ask). A re-ask carries a new instant, so it is never swallowed. */
723
+ declare function catalogueDedupeKey(payload: CatalogueJobPayload, requestedAt: Date): string;
724
+
725
+ /**
726
+ * Fetching an order the event only announced — the engine's half of a
727
+ * marketplace whose events carry no order body (Open Delivery's `CREATED`).
728
+ *
729
+ * The rule this keeps: no path that answers a request calls a marketplace. So
730
+ * the webhook only RECORDS the delivery (PENDING, "order details to fetch")
731
+ * and queues `marketplace.fetch-order`; the job reads the row, asks the
732
+ * adapter's `fetchOrder` through the host's HTTP port with the store's own
733
+ * credentials, and ingests what comes back through the one ingest path. The
734
+ * inbox reconciliation sweep re-queues the job for a row that is still owed
735
+ * once it is older than the job's own retry span ({@link FETCH_REQUEUE_AGE_MS}),
736
+ * so a refused enqueue or a dead worker loses nothing — and it never fetches
737
+ * itself, so a host that holds the job (its enqueue port answers "held")
738
+ * holds every fetch.
739
+ *
740
+ * Two things are judged before a fetched order is ingested: a cancellation
741
+ * that outran the fetch (`./order-fetch-marks.ts`) wins, and an order naming a
742
+ * merchant other than the connection's is refused.
743
+ *
744
+ * Nothing here knows a marketplace: which events need a fetch is the adapter's
745
+ * `orderToFetch`, and how to fetch is its `fetchOrder`.
746
+ */
747
+ /** The wire name, `<namespace>.<blueprint>` as the jobs contribution binds it. */
748
+ declare const MARKETPLACE_FETCH_ORDER_JOB = "marketplace.fetch-order";
749
+ /** The job's payload. Identifiers only: the event itself is the inbox row's. */
750
+ interface FetchOrderJobPayload {
751
+ clientId: string;
752
+ inboxId: string;
753
+ }
754
+ /** What one run did. */
755
+ type FetchOrderOutcome = {
756
+ kind: "skipped";
757
+ reason: string;
758
+ } | {
759
+ kind: "ingested";
760
+ orderId: string;
761
+ unmappedSkus: string[];
762
+ } | {
763
+ kind: "failed";
764
+ reason: string;
765
+ };
766
+ /** Thrown so the queue retries the fetch. Its message is what the job log reads. */
767
+ declare class FetchOrderRetryError extends Error {
768
+ constructor(message: string);
769
+ }
770
+
529
771
  /**
530
772
  * The outbound sweep: nothing owed to a marketplace is lost.
531
773
  *
@@ -575,6 +817,8 @@ interface OutboundSweepResult {
575
817
  givenUp: number;
576
818
  /** Requests failed as TIMEOUT past their marketplace's answer window. */
577
819
  timedOut: number;
820
+ /** Catalogue publishes and withdraws still owed, re-queued (FUT-4768). */
821
+ catalogueRequeued: number;
578
822
  }
579
823
 
580
824
  /** One stored delivery, as the retry sweep re-reads it. */
@@ -583,6 +827,8 @@ interface PendingInboxEvent {
583
827
  clientId: string;
584
828
  provider: MarketplaceProvider;
585
829
  payload: unknown;
830
+ /** When the delivery was recorded. */
831
+ receivedAt?: Date | null;
586
832
  }
587
833
 
588
834
  /**
@@ -692,6 +938,10 @@ type DeliveryOutcome = {
692
938
  kind: "cancelled";
693
939
  } | {
694
940
  kind: "cancellationFailed";
941
+ }
942
+ /** Recorded; the order body is fetched by the `marketplace.fetch-order` job. */
943
+ | {
944
+ kind: "awaitingOrder";
695
945
  } | {
696
946
  kind: "duplicate";
697
947
  } | {
@@ -836,6 +1086,32 @@ interface MarketplaceEngine {
836
1086
  sweepOutbound(now?: Date): Promise<OutboundSweepResult>;
837
1087
  /** Run one queued outbound call (the `marketplace.outbound` job's body). */
838
1088
  runOutbound(payload: OutboundJobPayload, attempt: OutboundAttempt): Promise<OutboundOutcome>;
1089
+ /** Fetch and ingest one announced order (the `marketplace.fetch-order` job's body). */
1090
+ runFetchOrder(payload: FetchOrderJobPayload, attempt: OutboundAttempt): Promise<FetchOrderOutcome>;
1091
+ /**
1092
+ * How this marketplace's catalogue is published (`push`, `pull`), or null
1093
+ * when it cannot be: the adapter states no catalogue, or the host bound no
1094
+ * catalogue port (FUT-4768).
1095
+ */
1096
+ catalogueMode(provider: string): "push" | "pull" | null;
1097
+ /** Put a product in a marketplace's catalogue (or send it again), with an optional price for it. Queued. */
1098
+ publish(input: CataloguePublishInput): Promise<CatalogueActionResult>;
1099
+ /** Take a product out of a marketplace's catalogue. Queued. */
1100
+ withdraw(input: CatalogueTarget): Promise<CatalogueActionResult>;
1101
+ /** Where these products stand on these marketplaces, in one read. */
1102
+ catalogueState(input: {
1103
+ clientId: string;
1104
+ productIds: readonly string[];
1105
+ providers?: readonly string[];
1106
+ }): Promise<CataloguePublicationView[]>;
1107
+ /** The menu part of the document a PULL marketplace reads, for the host to serve. */
1108
+ catalogueDocument(input: {
1109
+ clientId: string;
1110
+ provider: MarketplaceProvider;
1111
+ options: CatalogueMenuOptions;
1112
+ }): Promise<CatalogueDocumentResult>;
1113
+ /** Run one queued publish or withdraw (the `marketplace.catalogue` job's body). */
1114
+ runCatalogue(payload: CatalogueJobPayload, attempt: OutboundAttempt): Promise<CatalogueOutcome>;
839
1115
  }
840
1116
  /**
841
1117
  * Mount the engine onto a host.
@@ -847,4 +1123,4 @@ interface MarketplaceEngine {
847
1123
  */
848
1124
  declare function createMarketplaceEngine(config: MarketplaceEngineConfig): MarketplaceEngine;
849
1125
 
850
- export { outboundDedupeKey as $, type AcceptanceDecision as A, type BulkProblem as B, type CancellationFailureReason as C, type DecideManyResult as D, type ExpirySweepResult as E, type MarketplaceOrderPort as F, type MarketplaceOrderState as G, type MarketplaceOrderSummary as H, type IngestResult as I, type MarketplacePorts as J, type MarketplaceRefusal as K, type MarketplaceSecretsPort as L, MARKETPLACE_OUTBOUND_JOB as M, type MenuLinkRowInput as N, OUTBOUND_GIVE_UP_MS as O, OUTBOUND_STALE_MS as P, type OutboundAction as Q, type OutboundAttempt as R, type OutboundJobPayload as S, type OutboundOutcome as T, OutboundRetryError as U, type OutboundSweepResult as V, type PendingAcceptance as W, type PendingInboxEvent as X, type ResolvedOrderLine as Y, type SaveMarketplaceIntegrationInput as Z, createMarketplaceEngine as _, type AcceptanceStatus as a, type BulkProblemCode as b, type BulkResult as c, type CancellationStatus as d, type DecidedRow as e, type DecisionInput as f, type DecisionProblem as g, type DecisionProblemCode as h, type DecisionResult as i, type DeliveryOutcome as j, type IngestSettings as k, type IngestionTarget as l, type IntegrationRowInput as m, type MarketplaceAdmission as n, type MarketplaceAdmissionRequest as o, type MarketplaceAdmissionResult as p, type MarketplaceAuditEntry as q, type MarketplaceAuditPort as r, type MarketplaceClockPort as s, type MarketplaceDb as t, type MarketplaceEngine as u, type MarketplaceEngineConfig as v, type MarketplaceEnqueuePort as w, type MarketplaceIntegrationView as x, type MarketplaceLogger as y, type MarketplaceMenuLinkView as z };
1126
+ export { type MarketplaceOrderState as $, type AcceptanceDecision as A, type BulkProblem as B, type CancellationFailureReason as C, type DecideManyResult as D, type ExpirySweepResult as E, type FetchOrderJobPayload as F, type IngestionTarget as G, type IntegrationRowInput as H, type IngestResult as I, MARKETPLACE_FETCH_ORDER_JOB as J, MARKETPLACE_OUTBOUND_JOB as K, type MarketplaceAdmission as L, MARKETPLACE_CATALOGUE_JOB as M, type MarketplaceAdmissionRequest as N, type MarketplaceAdmissionResult as O, type MarketplaceAuditEntry as P, type MarketplaceAuditPort as Q, type MarketplaceCataloguePort as R, type MarketplaceClockPort as S, type MarketplaceDb as T, type MarketplaceEngine as U, type MarketplaceEngineConfig as V, type MarketplaceEnqueuePort as W, type MarketplaceIntegrationView as X, type MarketplaceLogger as Y, type MarketplaceMenuLinkView as Z, type MarketplaceOrderPort as _, type AcceptanceStatus as a, type MarketplaceOrderSummary as a0, type MarketplacePorts as a1, type MarketplaceRefusal as a2, type MarketplaceSecretsPort as a3, type MenuLinkRowInput as a4, OUTBOUND_GIVE_UP_MS as a5, OUTBOUND_STALE_MS as a6, type OutboundAction as a7, type OutboundAttempt as a8, type OutboundJobPayload as a9, type OutboundOutcome as aa, OutboundRetryError as ab, type OutboundSweepResult as ac, type PendingAcceptance as ad, type PendingInboxEvent as ae, type ResolvedOrderLine as af, type SaveMarketplaceIntegrationInput as ag, catalogueDedupeKey as ah, createMarketplaceEngine as ai, outboundDedupeKey as aj, type BulkProblemCode as b, type BulkResult as c, type CancellationStatus as d, type CatalogueAction as e, type CatalogueActionResult as f, type CatalogueDocumentResult as g, type CatalogueFailedAction as h, type CatalogueFailureCode as i, type CatalogueJobPayload as j, type CatalogueOutcome as k, type CataloguePublicationView as l, type CataloguePublishInput as m, type CatalogueRefusalCode as n, CatalogueRetryError as o, type CatalogueStatus as p, type CatalogueTarget as q, type DecidedRow as r, type DecisionInput as s, type DecisionProblem as t, type DecisionProblemCode as u, type DecisionResult as v, type DeliveryOutcome as w, type FetchOrderOutcome as x, FetchOrderRetryError as y, type IngestSettings 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-KrgZ4pA4.js';
4
- import '../adapter-BggtVFf9.js';
3
+ import '../engine-CZsP8KWd.js';
4
+ import '../adapter-0l_EmuJA.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-NGNEL4HS.js";
3
+ } from "../chunk-AYYBRQJV.js";
4
4
  import "../chunk-UYFYGGCS.js";
5
- import "../chunk-DVIRN42O.js";
5
+ import "../chunk-XUAFXNOH.js";
6
6
  import {
7
7
  __name
8
8
  } from "../chunk-7QVYU63E.js";
@@ -1,4 +1,4 @@
1
- import { N as NormalizedEvent, M as MarketplaceAdapter } from '../adapter-BggtVFf9.js';
1
+ import { N as NormalizedEvent, c as PushCatalogue, d as CatalogueItemOut, M as MarketplaceAdapter } from '../adapter-0l_EmuJA.js';
2
2
 
3
3
  /**
4
4
  * The words the iFood adapter needs from its host, and nothing else.
@@ -22,16 +22,12 @@ interface IfoodAdapterCopy {
22
22
  }
23
23
 
24
24
  /**
25
- * Verify a delivery against the merchant's webhook secret.
26
- *
27
- * Unsigned deliveries are refused whenever a secret is CONFIGURED. A store that
28
- * has not set one yet is accepted — iFood's own onboarding issues the secret
29
- * after the merchant is certified, so refusing before then would make the
30
- * connection untestable — and that state is visible on the integration screen
31
- * rather than silent.
32
- *
33
- * Compared in constant time over bytes: an early-exit `===` on a hex digest
34
- * leaks the prefix a forger already got right, one request at a time.
25
+ * Verify a delivery against the merchant's webhook secret: iFood signs the raw
26
+ * body with HMAC-SHA256, hex. The rule (an unset secret accepts; a set one
27
+ * refuses an unsigned delivery; constant-time compare) is the engine's
28
+ * {@link verifyHmacSha256Hex}. iFood's own onboarding issues the secret after
29
+ * the merchant is certified, so refusing before then would make the
30
+ * connection untestable.
35
31
  */
36
32
  declare function verifyIfoodSignature(rawBody: string, signature: string | null, webhookSecret: string | null): boolean;
37
33
  /**
@@ -46,6 +42,14 @@ declare function normalizeIfoodEvent(payload: unknown, options: {
46
42
  missingStreetNumber: string;
47
43
  }): NormalizedEvent | null;
48
44
 
45
+ /** The item's and its product's ids, stable per publication. */
46
+ declare const ifoodItemId: (ref: string) => string;
47
+ declare const ifoodProductId: (ref: string) => string;
48
+ /** The `PUT /items` body for one simple item with no add-ons. */
49
+ declare function ifoodItemBody(item: CatalogueItemOut, category: string, image: string | null): unknown;
50
+ /** iFood's catalogue capability. */
51
+ declare const IFOOD_CATALOGUE: PushCatalogue;
52
+
49
53
  /**
50
54
  * `@12-apps/marketplace/ifood` — iFood, as one adapter on the engine.
51
55
  *
@@ -72,4 +76,4 @@ interface IfoodAdapterConfig {
72
76
  /** Build the iFood adapter. Its reasons are static: a dialog never waits on iFood. */
73
77
  declare function createIfoodAdapter(config: IfoodAdapterConfig): MarketplaceAdapter;
74
78
 
75
- export { IFOOD_CANCELLATION_ANSWER_WINDOW_MS, IFOOD_PROVIDER, IFOOD_REASON_CODES, type IfoodAdapterConfig, type IfoodAdapterCopy, type IfoodReasonCode, createIfoodAdapter, normalizeIfoodEvent, verifyIfoodSignature };
79
+ export { IFOOD_CANCELLATION_ANSWER_WINDOW_MS, IFOOD_CATALOGUE, IFOOD_PROVIDER, IFOOD_REASON_CODES, type IfoodAdapterConfig, type IfoodAdapterCopy, type IfoodReasonCode, createIfoodAdapter, ifoodItemBody, ifoodItemId, ifoodProductId, normalizeIfoodEvent, verifyIfoodSignature };