@12-apps/marketplace 1.13.0 → 1.15.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 (72) hide show
  1. package/ADOPTING.md +258 -3
  2. package/README.md +27 -2
  3. package/dist/99food/index.d.ts +2 -2
  4. package/dist/99food/index.js +3 -3
  5. package/dist/{adapter-CQ4QiZPi.d.ts → adapter-CjVdMhZ2.d.ts} +177 -4
  6. package/dist/{chunk-CEWTV2TC.js → chunk-B4DYPQFE.js} +657 -251
  7. package/dist/chunk-B4DYPQFE.js.map +1 -0
  8. package/dist/{chunk-4J2KJ3ZW.js → chunk-BTKVZAJI.js} +1 -1
  9. package/dist/chunk-BTKVZAJI.js.map +1 -0
  10. package/dist/{chunk-BD7DS3XM.js → chunk-E4XJXHUK.js} +20 -1
  11. package/dist/chunk-E4XJXHUK.js.map +1 -0
  12. package/dist/{chunk-W57TITU4.js → chunk-FQI56NGC.js} +53 -6
  13. package/dist/chunk-FQI56NGC.js.map +1 -0
  14. package/dist/chunk-H2VQRD3B.js +16 -0
  15. package/dist/chunk-H2VQRD3B.js.map +1 -0
  16. package/dist/{chunk-NFJQQWG4.js → chunk-TRUK5ZBE.js} +12 -4
  17. package/dist/chunk-TRUK5ZBE.js.map +1 -0
  18. package/dist/{client-CCSnylou.d.ts → client-DgzCkl8u.d.ts} +1 -1
  19. package/dist/{engine-1KlJ_8jK.d.ts → engine-BSLdhAGC.d.ts} +134 -3
  20. package/dist/hono/index.d.ts +2 -2
  21. package/dist/hono/index.js +3 -2
  22. package/dist/hono/index.js.map +1 -1
  23. package/dist/ifood/index.d.ts +13 -3
  24. package/dist/ifood/index.js +219 -29
  25. package/dist/ifood/index.js.map +1 -1
  26. package/dist/index.d.ts +29 -5
  27. package/dist/index.js +59 -7
  28. package/dist/index.js.map +1 -1
  29. package/dist/keeta/index.d.ts +2 -2
  30. package/dist/keeta/index.js +3 -3
  31. package/dist/manifest/server.d.ts +4 -2
  32. package/dist/manifest/server.js +3 -2
  33. package/dist/manifest/server.js.map +1 -1
  34. package/dist/rappi/index.d.ts +1 -1
  35. package/dist/rappi/index.js +2 -2
  36. package/dist/server/index.d.ts +14 -5
  37. package/dist/server/index.js +3 -2
  38. package/package.json +1 -1
  39. package/prisma/marketplace.prisma +17 -3
  40. package/prisma/migrations/20261202120000_marketplace_ifood_conformity/migration.sql +25 -0
  41. package/src/core/acceptance.ts +12 -6
  42. package/src/core/acknowledge.ts +189 -0
  43. package/src/core/adapter.ts +74 -1
  44. package/src/core/cancellation.ts +10 -6
  45. package/src/core/conformity.ts +63 -0
  46. package/src/core/engine.ts +3 -2
  47. package/src/core/ingest.ts +7 -0
  48. package/src/core/link-store.ts +2 -4
  49. package/src/core/marketplace-confirmed.ts +229 -0
  50. package/src/core/order-reasons.ts +119 -0
  51. package/src/core/order-types.ts +8 -0
  52. package/src/core/outbound.ts +5 -1
  53. package/src/core/payload-read.ts +24 -0
  54. package/src/core/pipeline.ts +27 -1
  55. package/src/core/ports.ts +2 -0
  56. package/src/core/registry.ts +28 -2
  57. package/src/core/state.ts +10 -0
  58. package/src/core/status-job.ts +86 -3
  59. package/src/core/types.ts +117 -2
  60. package/src/ifood/index.ts +27 -4
  61. package/src/ifood/normalize.ts +38 -5
  62. package/src/ifood/order-details.ts +120 -0
  63. package/src/ifood/outbound.ts +131 -27
  64. package/src/index.ts +24 -0
  65. package/src/open-delivery/normalize.ts +9 -0
  66. package/src/server/jobs.ts +57 -4
  67. package/src/server/webhook.ts +27 -4
  68. package/dist/chunk-4J2KJ3ZW.js.map +0 -1
  69. package/dist/chunk-BD7DS3XM.js.map +0 -1
  70. package/dist/chunk-CEWTV2TC.js.map +0 -1
  71. package/dist/chunk-NFJQQWG4.js.map +0 -1
  72. package/dist/chunk-W57TITU4.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/payload-read.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from \"node:crypto\";\n\n/**\n * The defensive readers every adapter's normalizer is built from.\n *\n * A marketplace payload is UNTRUSTED: a documented shape and the shape that\n * actually arrives drift, and a `TypeError` reading a missing field would\n * reject a paid order at the door. Every reader here produces a value or\n * null, never a throw. They are wire-format-neutral (no marketplace's key\n * names), which is why they live beside the engine rather than in an adapter.\n */\n\n/** Read a nested value without asserting the shape of anything on the way. */\nexport function pick(source: unknown, ...path: string[]): unknown {\n let cursor: unknown = source;\n for (const key of path) {\n if (typeof cursor !== \"object\" || cursor === null) return undefined;\n cursor = (cursor as Record<string, unknown>)[key];\n }\n return cursor;\n}\n\n/** A non-blank string (trimmed), a finite number as text, or null. */\nexport function asString(value: unknown): string | null {\n if (typeof value === \"string\" && value.trim() !== \"\") return value.trim();\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value);\n return null;\n}\n\n/**\n * The first of several candidate paths that yields a string.\n *\n * A marketplace states the same fact under different keys depending on which\n * API version delivered it, so nearly every read is a fallback chain. Expressed\n * as data rather than as `??` so a chain grows by one entry, not one branch.\n */\nexport function firstString(source: unknown, paths: string[][]): string | null {\n for (const path of paths) {\n const found = asString(pick(source, ...path));\n if (found !== null) return found;\n }\n return null;\n}\n\n/**\n * Money stated in DECIMAL units (`12.9`) → integer cents.\n *\n * Rounded rather than truncated: `Math.trunc(12.9 * 100)` is 1289 on IEEE-754,\n * so truncation loses a cent on ordinary prices, always in the store's\n * disfavour.\n */\nexport function toCents(value: unknown): number | null {\n const numeric = typeof value === \"string\" ? Number(value) : value;\n if (typeof numeric !== \"number\" || !Number.isFinite(numeric)) return null;\n return Math.round(numeric * 100);\n}\n\n/** {@link firstString} for money. */\nexport function firstCents(source: unknown, paths: string[][]): number | null {\n for (const path of paths) {\n const found = toCents(pick(source, ...path));\n if (found !== null) return found;\n }\n return null;\n}\n\n/** An ISO timestamp → a Date, or null when absent or unparseable. */\nfunction toDate(value: unknown): Date | null {\n const raw = asString(value);\n if (!raw) return null;\n const parsed = new Date(raw);\n return Number.isNaN(parsed.getTime()) ? null : parsed;\n}\n\n/** {@link firstString} for timestamps. */\nexport function firstDate(source: unknown, paths: string[][]): Date | null {\n for (const path of paths) {\n const found = toDate(pick(source, ...path));\n if (found !== null) return found;\n }\n return null;\n}\n\n/**\n * Verify a lowercase-hex HMAC-SHA256 of the raw body (an optional `sha256=`\n * prefix tolerated), keyed by `secret`.\n *\n * Unsigned deliveries are refused whenever a secret is CONFIGURED; a store\n * that has not set one yet is accepted, and that state is visible on the\n * connection screen rather than silent. Compared in constant time over bytes:\n * an early-exit `===` on a hex digest leaks the prefix a forger already got\n * right, one request at a time.\n */\nexport function verifyHmacSha256Hex(rawBody: string, signature: string | null, secret: string | null): boolean {\n if (!secret) return true;\n if (!signature) return false;\n const expected = createHmac(\"sha256\", secret).update(rawBody, \"utf8\").digest(\"hex\");\n const given = Buffer.from(signature.trim().toLowerCase().replace(/^sha256=/u, \"\"), \"utf8\");\n const mine = Buffer.from(expected, \"utf8\");\n return given.length === mine.length && timingSafeEqual(given, mine);\n}\n"],"mappings":";;;;;AAAA,SAAS,YAAY,uBAAuB;AAarC,SAAS,KAAK,WAAoB,MAAyB;AAChE,MAAI,SAAkB;AACtB,aAAW,OAAO,MAAM;AACtB,QAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,aAAU,OAAmC,GAAG;AAAA,EAClD;AACA,SAAO;AACT;AAPgB;AAUT,SAAS,SAAS,OAA+B;AACtD,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,GAAI,QAAO,MAAM,KAAK;AACxE,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,EAAG,QAAO,OAAO,KAAK;AAC5E,SAAO;AACT;AAJgB;AAaT,SAAS,YAAY,QAAiB,OAAkC;AAC7E,aAAW,QAAQ,OAAO;AACxB,UAAM,QAAQ,SAAS,KAAK,QAAQ,GAAG,IAAI,CAAC;AAC5C,QAAI,UAAU,KAAM,QAAO;AAAA,EAC7B;AACA,SAAO;AACT;AANgB;AAeT,SAAS,QAA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