@openlup/platform 0.16.0 → 0.18.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 (773) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/README.md +564 -6
  3. package/dist/catalog/activeSkuSelection.d.ts +2 -0
  4. package/dist/catalog/activeSkuSelection.js +20 -0
  5. package/dist/catalog/adminBindings.d.ts +72 -0
  6. package/dist/catalog/adminBindings.js +1 -0
  7. package/dist/catalog/adminBundleHandler.d.ts +26 -0
  8. package/dist/catalog/adminBundleHandler.js +111 -0
  9. package/dist/catalog/adminBundleReadHandler.d.ts +20 -0
  10. package/dist/catalog/adminBundleReadHandler.js +185 -0
  11. package/dist/catalog/adminBundleWritePort.d.ts +85 -0
  12. package/dist/catalog/adminBundleWritePort.js +1 -0
  13. package/dist/catalog/bundleAvailability.d.ts +63 -0
  14. package/dist/catalog/bundleAvailability.js +78 -0
  15. package/dist/catalog/bundleAvailabilityService.d.ts +65 -0
  16. package/dist/catalog/bundleAvailabilityService.js +89 -0
  17. package/dist/catalog/bundleBindings.d.ts +33 -0
  18. package/dist/catalog/bundleBindings.js +1 -0
  19. package/dist/catalog/bundleCatalogQueries.d.ts +28 -0
  20. package/dist/catalog/bundleCatalogQueries.js +84 -0
  21. package/dist/catalog/bundleCatalogReadPort.d.ts +166 -0
  22. package/dist/catalog/bundleCatalogReadPort.js +36 -0
  23. package/dist/catalog/bundleCatalogStore.d.ts +3 -0
  24. package/dist/catalog/bundleCatalogStore.js +152 -0
  25. package/dist/catalog/bundleRuleCodes.d.ts +41 -0
  26. package/dist/catalog/bundleRuleCodes.js +110 -0
  27. package/dist/catalog/bundleRules.d.ts +69 -0
  28. package/dist/catalog/bundleRules.js +102 -0
  29. package/dist/catalog/catalogDraftStore.d.ts +4 -0
  30. package/dist/catalog/catalogDraftStore.js +63 -0
  31. package/dist/catalog/catalogSkuEnvelope.d.ts +7 -0
  32. package/dist/catalog/catalogSkuEnvelope.js +142 -0
  33. package/dist/catalog/catalogSkuEnvelopeMapper.d.ts +38 -0
  34. package/dist/catalog/catalogSkuEnvelopeMapper.js +88 -0
  35. package/dist/catalog/contracts/bundleAdmin.d.ts +143 -0
  36. package/dist/catalog/contracts/bundleAdmin.js +1 -0
  37. package/dist/catalog/contracts/bundleAvailability.d.ts +61 -0
  38. package/dist/catalog/contracts/bundleAvailability.js +1 -0
  39. package/dist/catalog/contracts/bundleRead.d.ts +223 -0
  40. package/dist/catalog/contracts/bundleRead.js +1 -0
  41. package/dist/catalog/contracts/draft.d.ts +79 -0
  42. package/dist/catalog/contracts/draft.js +47 -0
  43. package/dist/catalog/contracts/foundation.d.ts +78 -0
  44. package/dist/catalog/contracts/foundation.js +53 -0
  45. package/dist/catalog/contracts/index.d.ts +14 -0
  46. package/dist/catalog/contracts/index.js +6 -0
  47. package/dist/catalog/contracts/lifecycle.d.ts +77 -0
  48. package/dist/catalog/contracts/lifecycle.js +1 -0
  49. package/dist/catalog/contracts/productMediaContracts.d.ts +77 -0
  50. package/dist/catalog/contracts/productMediaContracts.js +149 -0
  51. package/dist/catalog/contracts/productTypes.d.ts +54 -0
  52. package/dist/catalog/contracts/productTypes.js +16 -0
  53. package/dist/catalog/contracts/resolveProductMedia.d.ts +3 -0
  54. package/dist/catalog/contracts/resolveProductMedia.js +78 -0
  55. package/dist/catalog/contracts/sellable.d.ts +23 -0
  56. package/dist/catalog/contracts/sellable.js +1 -0
  57. package/dist/catalog/draftHandler.d.ts +25 -0
  58. package/dist/catalog/draftHandler.js +118 -0
  59. package/dist/catalog/draftPorts.d.ts +18 -0
  60. package/dist/catalog/draftPorts.js +8 -0
  61. package/dist/catalog/draftSchemas.d.ts +423 -0
  62. package/dist/catalog/draftSchemas.js +89 -0
  63. package/dist/catalog/draftValidation.d.ts +21 -0
  64. package/dist/catalog/draftValidation.js +125 -0
  65. package/dist/catalog/foundationSchemas.d.ts +98 -0
  66. package/dist/catalog/foundationSchemas.js +110 -0
  67. package/dist/catalog/index.d.ts +43 -0
  68. package/dist/catalog/index.js +25 -0
  69. package/dist/catalog/mediaSourcePack.d.ts +51 -0
  70. package/dist/catalog/mediaSourcePack.js +247 -0
  71. package/dist/catalog/productTypeSchemas.d.ts +46 -0
  72. package/dist/catalog/productTypeSchemas.js +72 -0
  73. package/dist/catalog/publicationPorts.d.ts +42 -0
  74. package/dist/catalog/publicationPorts.js +1 -0
  75. package/dist/catalog/readPorts.d.ts +51 -0
  76. package/dist/catalog/readPorts.js +1 -0
  77. package/dist/catalog/referenceCatalogHandler.d.ts +7 -0
  78. package/dist/catalog/referenceCatalogHandler.js +27 -0
  79. package/dist/catalog/resolvedSkuProjection.d.ts +88 -0
  80. package/dist/catalog/resolvedSkuProjection.js +60 -0
  81. package/dist/catalog/sellableBundleHandler.d.ts +46 -0
  82. package/dist/catalog/sellableBundleHandler.js +84 -0
  83. package/dist/catalog/sellableSchemas.d.ts +46 -0
  84. package/dist/catalog/sellableSchemas.js +27 -0
  85. package/dist/catalog/sql.d.ts +46 -0
  86. package/dist/catalog/sql.js +13 -0
  87. package/dist/catalog/validation.d.ts +2 -0
  88. package/dist/catalog/validation.js +3 -0
  89. package/dist/communications/accountingDocumentDelivery.d.ts +35 -0
  90. package/dist/communications/accountingDocumentDelivery.js +33 -0
  91. package/dist/communications/authEmailError.d.ts +5 -0
  92. package/dist/communications/authEmailError.js +8 -0
  93. package/dist/communications/authEmailPorts.d.ts +2 -0
  94. package/dist/communications/authEmailPorts.js +1 -0
  95. package/dist/communications/authSendEmailHook.d.ts +35 -0
  96. package/dist/communications/authSendEmailHook.js +250 -0
  97. package/dist/communications/capturedTransactionalDelivery.d.ts +13 -0
  98. package/dist/communications/capturedTransactionalDelivery.js +14 -0
  99. package/dist/communications/communicationSync.d.ts +11 -0
  100. package/dist/communications/communicationSync.js +79 -0
  101. package/dist/communications/communicationSyncWorker.d.ts +68 -0
  102. package/dist/communications/communicationSyncWorker.js +218 -0
  103. package/dist/communications/consentPolicy.d.ts +19 -0
  104. package/dist/communications/consentPolicy.js +43 -0
  105. package/dist/communications/consentPurposeRegistry.d.ts +4 -0
  106. package/dist/communications/consentPurposeRegistry.js +24 -0
  107. package/dist/communications/contracts/abandonedCart.d.ts +27 -0
  108. package/dist/communications/contracts/abandonedCart.js +25 -0
  109. package/dist/communications/contracts/authEmail.d.ts +62 -0
  110. package/dist/communications/contracts/authEmail.js +1 -0
  111. package/dist/communications/contracts/backInStock.d.ts +28 -0
  112. package/dist/communications/contracts/backInStock.js +28 -0
  113. package/dist/communications/contracts/blocks.d.ts +24 -0
  114. package/dist/communications/contracts/blocks.js +23 -0
  115. package/dist/communications/contracts/checkoutExpired.d.ts +22 -0
  116. package/dist/communications/contracts/checkoutExpired.js +25 -0
  117. package/dist/communications/contracts/checkoutRecovery.d.ts +26 -0
  118. package/dist/communications/contracts/checkoutRecovery.js +37 -0
  119. package/dist/communications/contracts/commerceEmailContent.d.ts +176 -0
  120. package/dist/communications/contracts/commerceEmailContent.js +1 -0
  121. package/dist/communications/contracts/commerceEngagementEmailContent.d.ts +95 -0
  122. package/dist/communications/contracts/commerceEngagementEmailContent.js +1 -0
  123. package/dist/communications/contracts/consent.d.ts +12 -0
  124. package/dist/communications/contracts/consent.js +1 -0
  125. package/dist/communications/contracts/email.d.ts +182 -0
  126. package/dist/communications/contracts/email.js +1 -0
  127. package/dist/communications/contracts/guideCard.d.ts +3 -0
  128. package/dist/communications/contracts/guideCard.js +26 -0
  129. package/dist/communications/contracts/index.d.ts +52 -0
  130. package/dist/communications/contracts/index.js +42 -0
  131. package/dist/communications/contracts/inquiryContent.d.ts +32 -0
  132. package/dist/communications/contracts/inquiryContent.js +33 -0
  133. package/dist/communications/contracts/invoiceDocumentContent.d.ts +26 -0
  134. package/dist/communications/contracts/invoiceDocumentContent.js +36 -0
  135. package/dist/communications/contracts/marketingAutomation.d.ts +52 -0
  136. package/dist/communications/contracts/marketingAutomation.js +1 -0
  137. package/dist/communications/contracts/marketingSync.d.ts +194 -0
  138. package/dist/communications/contracts/marketingSync.js +1 -0
  139. package/dist/communications/contracts/newsletter.d.ts +63 -0
  140. package/dist/communications/contracts/newsletter.js +1 -0
  141. package/dist/communications/contracts/newsletterWebhook.d.ts +26 -0
  142. package/dist/communications/contracts/newsletterWebhook.js +1 -0
  143. package/dist/communications/contracts/optOutContent.d.ts +11 -0
  144. package/dist/communications/contracts/optOutContent.js +17 -0
  145. package/dist/communications/contracts/orderCanceled.d.ts +25 -0
  146. package/dist/communications/contracts/orderCanceled.js +27 -0
  147. package/dist/communications/contracts/orderDraft.d.ts +46 -0
  148. package/dist/communications/contracts/orderDraft.js +46 -0
  149. package/dist/communications/contracts/orderPaid.d.ts +53 -0
  150. package/dist/communications/contracts/orderPaid.js +71 -0
  151. package/dist/communications/contracts/orderRefunded.d.ts +24 -0
  152. package/dist/communications/contracts/orderRefunded.js +27 -0
  153. package/dist/communications/contracts/paymentFailed.d.ts +24 -0
  154. package/dist/communications/contracts/paymentFailed.js +24 -0
  155. package/dist/communications/contracts/publicIntake.d.ts +49 -0
  156. package/dist/communications/contracts/publicIntake.js +1 -0
  157. package/dist/communications/contracts/render.d.ts +2 -0
  158. package/dist/communications/contracts/render.js +229 -0
  159. package/dist/communications/contracts/reorderReminder.d.ts +24 -0
  160. package/dist/communications/contracts/reorderReminder.js +24 -0
  161. package/dist/communications/contracts/returnEmails.d.ts +25 -0
  162. package/dist/communications/contracts/returnEmails.js +62 -0
  163. package/dist/communications/contracts/reviewEffects.d.ts +26 -0
  164. package/dist/communications/contracts/reviewEffects.js +25 -0
  165. package/dist/communications/contracts/reviewRequest.d.ts +26 -0
  166. package/dist/communications/contracts/reviewRequest.js +24 -0
  167. package/dist/communications/contracts/roleNotificationContent.d.ts +25 -0
  168. package/dist/communications/contracts/roleNotificationContent.js +46 -0
  169. package/dist/communications/contracts/shipmentDelivered.d.ts +23 -0
  170. package/dist/communications/contracts/shipmentDelivered.js +24 -0
  171. package/dist/communications/contracts/shipmentDispatched.d.ts +27 -0
  172. package/dist/communications/contracts/shipmentDispatched.js +35 -0
  173. package/dist/communications/contracts/shipmentException.d.ts +21 -0
  174. package/dist/communications/contracts/shipmentException.js +26 -0
  175. package/dist/communications/contracts/subscriptionActivationActionRequired.d.ts +17 -0
  176. package/dist/communications/contracts/subscriptionActivationActionRequired.js +22 -0
  177. package/dist/communications/contracts/subscriptionAddressChanged.d.ts +19 -0
  178. package/dist/communications/contracts/subscriptionAddressChanged.js +25 -0
  179. package/dist/communications/contracts/subscriptionCancelled.d.ts +19 -0
  180. package/dist/communications/contracts/subscriptionCancelled.js +25 -0
  181. package/dist/communications/contracts/subscriptionCycleSkipped.d.ts +25 -0
  182. package/dist/communications/contracts/subscriptionCycleSkipped.js +40 -0
  183. package/dist/communications/contracts/subscriptionDeliveryRescheduled.d.ts +25 -0
  184. package/dist/communications/contracts/subscriptionDeliveryRescheduled.js +39 -0
  185. package/dist/communications/contracts/subscriptionEmailContent.d.ts +145 -0
  186. package/dist/communications/contracts/subscriptionEmailContent.js +1 -0
  187. package/dist/communications/contracts/subscriptionPackageChanged.d.ts +20 -0
  188. package/dist/communications/contracts/subscriptionPackageChanged.js +26 -0
  189. package/dist/communications/contracts/subscriptionPauseReminder.d.ts +23 -0
  190. package/dist/communications/contracts/subscriptionPauseReminder.js +29 -0
  191. package/dist/communications/contracts/subscriptionPaused.d.ts +21 -0
  192. package/dist/communications/contracts/subscriptionPaused.js +25 -0
  193. package/dist/communications/contracts/subscriptionPaymentExpired.d.ts +34 -0
  194. package/dist/communications/contracts/subscriptionPaymentExpired.js +37 -0
  195. package/dist/communications/contracts/subscriptionPaymentFailed.d.ts +49 -0
  196. package/dist/communications/contracts/subscriptionPaymentFailed.js +56 -0
  197. package/dist/communications/contracts/subscriptionPaymentRecovered.d.ts +19 -0
  198. package/dist/communications/contracts/subscriptionPaymentRecovered.js +22 -0
  199. package/dist/communications/contracts/subscriptionRenewalAtRisk.d.ts +36 -0
  200. package/dist/communications/contracts/subscriptionRenewalAtRisk.js +36 -0
  201. package/dist/communications/contracts/subscriptionRenewalUpcoming.d.ts +49 -0
  202. package/dist/communications/contracts/subscriptionRenewalUpcoming.js +43 -0
  203. package/dist/communications/contracts/subscriptionResumed.d.ts +23 -0
  204. package/dist/communications/contracts/subscriptionResumed.js +25 -0
  205. package/dist/communications/contracts/subscriptionWelcome.d.ts +44 -0
  206. package/dist/communications/contracts/subscriptionWelcome.js +45 -0
  207. package/dist/communications/contracts/subscriptionWinback.d.ts +21 -0
  208. package/dist/communications/contracts/subscriptionWinback.js +28 -0
  209. package/dist/communications/contracts/transactionalDelivery.d.ts +42 -0
  210. package/dist/communications/contracts/transactionalDelivery.js +1 -0
  211. package/dist/communications/contracts/types.d.ts +46 -0
  212. package/dist/communications/contracts/types.js +1 -0
  213. package/dist/communications/contribution.d.ts +10 -0
  214. package/dist/communications/contribution.js +24 -0
  215. package/dist/communications/deliveryReconciliation.d.ts +64 -0
  216. package/dist/communications/deliveryReconciliation.js +60 -0
  217. package/dist/communications/emailEgress.d.ts +38 -0
  218. package/dist/communications/emailEgress.js +100 -0
  219. package/dist/communications/emailHealthAssessment.d.ts +39 -0
  220. package/dist/communications/emailHealthAssessment.js +59 -0
  221. package/dist/communications/emailHealthMetricsPort.d.ts +17 -0
  222. package/dist/communications/emailHealthMetricsPort.js +1 -0
  223. package/dist/communications/emailNotificationControl.d.ts +27 -0
  224. package/dist/communications/emailNotificationControl.js +10 -0
  225. package/dist/communications/emailObservation.d.ts +28 -0
  226. package/dist/communications/emailObservation.js +23 -0
  227. package/dist/communications/emailTransport.d.ts +82 -0
  228. package/dist/communications/emailTransport.js +95 -0
  229. package/dist/communications/errors.d.ts +15 -0
  230. package/dist/communications/errors.js +30 -0
  231. package/dist/communications/index.d.ts +47 -0
  232. package/dist/communications/index.js +38 -0
  233. package/dist/communications/integrationEventSignature.d.ts +15 -0
  234. package/dist/communications/integrationEventSignature.js +37 -0
  235. package/dist/communications/klaviyo/consentPush.d.ts +51 -0
  236. package/dist/communications/klaviyo/consentPush.js +19 -0
  237. package/dist/communications/klaviyo/index.d.ts +110 -0
  238. package/dist/communications/klaviyo/index.js +860 -0
  239. package/dist/communications/managedTransactionalDeliveryStore.d.ts +12 -0
  240. package/dist/communications/managedTransactionalDeliveryStore.js +49 -0
  241. package/dist/communications/nativeOperations.d.ts +79 -0
  242. package/dist/communications/nativeOperations.js +3 -0
  243. package/dist/communications/newsletterIntegrationContracts.d.ts +130 -0
  244. package/dist/communications/newsletterIntegrationContracts.js +128 -0
  245. package/dist/communications/newsletterWebhookPort.d.ts +11 -0
  246. package/dist/communications/newsletterWebhookPort.js +84 -0
  247. package/dist/communications/newsletterWebhookProcessing.d.ts +17 -0
  248. package/dist/communications/newsletterWebhookProcessing.js +71 -0
  249. package/dist/communications/originPolicy.d.ts +40 -0
  250. package/dist/communications/originPolicy.js +100 -0
  251. package/dist/communications/postgresCommunicationSync.d.ts +79 -0
  252. package/dist/communications/postgresCommunicationSync.js +111 -0
  253. package/dist/communications/postgresConsentEvaluator.d.ts +19 -0
  254. package/dist/communications/postgresConsentEvaluator.js +43 -0
  255. package/dist/communications/postgresDeliveryReconciliation.d.ts +3 -0
  256. package/dist/communications/postgresDeliveryReconciliation.js +113 -0
  257. package/dist/communications/postgresNativeOperations.d.ts +13 -0
  258. package/dist/communications/postgresNativeOperations.js +63 -0
  259. package/dist/communications/postgresNotificationRecipients.d.ts +37 -0
  260. package/dist/communications/postgresNotificationRecipients.js +60 -0
  261. package/dist/communications/postgresTransactionalDeliveryStore.d.ts +7 -0
  262. package/dist/communications/postgresTransactionalDeliveryStore.js +55 -0
  263. package/dist/communications/preferencesToken.d.ts +10 -0
  264. package/dist/communications/preferencesToken.js +40 -0
  265. package/dist/communications/publicPreferenceToken.d.ts +24 -0
  266. package/dist/communications/publicPreferenceToken.js +53 -0
  267. package/dist/communications/resend/index.d.ts +40 -0
  268. package/dist/communications/resend/index.js +310 -0
  269. package/dist/communications/shipmentNotifications.d.ts +34 -0
  270. package/dist/communications/shipmentNotifications.js +61 -0
  271. package/dist/communications/sql.d.ts +26 -0
  272. package/dist/communications/sql.js +7 -0
  273. package/dist/communications/standardWebhooks.d.ts +14 -0
  274. package/dist/communications/standardWebhooks.js +73 -0
  275. package/dist/communications/status.d.ts +11 -0
  276. package/dist/communications/status.js +36 -0
  277. package/dist/communications/transactionalDelivery.d.ts +19 -0
  278. package/dist/communications/transactionalDelivery.js +96 -0
  279. package/dist/communications/transactionalDeliveryIdentifier.d.ts +3 -0
  280. package/dist/communications/transactionalDeliveryIdentifier.js +6 -0
  281. package/dist/communications/unsubscribeToken.d.ts +77 -0
  282. package/dist/communications/unsubscribeToken.js +150 -0
  283. package/dist/communications/validation.d.ts +2 -0
  284. package/dist/communications/validation.js +3 -0
  285. package/dist/composition/catalogContribution.d.ts +18 -0
  286. package/dist/composition/catalogContribution.js +21 -0
  287. package/dist/composition/index.d.ts +1 -0
  288. package/dist/composition/index.js +1 -0
  289. package/dist/http/index.d.ts +1 -0
  290. package/dist/http/index.js +1 -0
  291. package/dist/http/webhookSignature.d.ts +42 -0
  292. package/dist/http/webhookSignature.js +86 -0
  293. package/dist/identity/customerContracts.d.ts +2 -2
  294. package/dist/inventory/adminInventory.d.ts +13 -0
  295. package/dist/inventory/adminInventory.js +214 -0
  296. package/dist/inventory/contracts/forecast.d.ts +86 -0
  297. package/dist/inventory/contracts/forecast.js +1 -0
  298. package/dist/inventory/contracts/index.d.ts +4 -0
  299. package/dist/inventory/contracts/index.js +1 -0
  300. package/dist/inventory/contracts/inventory.d.ts +157 -0
  301. package/dist/inventory/contracts/inventory.js +1 -0
  302. package/dist/inventory/contracts/newPurchaseStock.d.ts +20 -0
  303. package/dist/inventory/contracts/newPurchaseStock.js +1 -0
  304. package/dist/inventory/contracts/reservation.d.ts +18 -0
  305. package/dist/inventory/contracts/reservation.js +1 -0
  306. package/dist/inventory/forecast.d.ts +24 -0
  307. package/dist/inventory/forecast.js +200 -0
  308. package/dist/inventory/index.d.ts +13 -0
  309. package/dist/inventory/index.js +10 -0
  310. package/dist/inventory/inventoryHandlers.d.ts +53 -0
  311. package/dist/inventory/inventoryHandlers.js +151 -0
  312. package/dist/inventory/newPurchaseStockAvailability.d.ts +47 -0
  313. package/dist/inventory/newPurchaseStockAvailability.js +75 -0
  314. package/dist/inventory/ports.d.ts +21 -0
  315. package/dist/inventory/ports.js +16 -0
  316. package/dist/inventory/renewalReservation.d.ts +27 -0
  317. package/dist/inventory/renewalReservation.js +61 -0
  318. package/dist/inventory/reservationPolicy.d.ts +6 -0
  319. package/dist/inventory/reservationPolicy.js +19 -0
  320. package/dist/inventory/schemas.d.ts +137 -0
  321. package/dist/inventory/schemas.js +112 -0
  322. package/dist/inventory/sql.d.ts +14 -0
  323. package/dist/inventory/sql.js +5 -0
  324. package/dist/inventory/subscriptionForecastCalculation.d.ts +4 -0
  325. package/dist/inventory/subscriptionForecastCalculation.js +133 -0
  326. package/dist/pricing/acquisitionFinancialPolicy.d.ts +26 -0
  327. package/dist/pricing/acquisitionFinancialPolicy.js +1 -0
  328. package/dist/pricing/acquisitionOfferPricing.d.ts +27 -0
  329. package/dist/pricing/acquisitionOfferPricing.js +25 -0
  330. package/dist/pricing/acquisitionOfferPricingHandler.d.ts +20 -0
  331. package/dist/pricing/acquisitionOfferPricingHandler.js +105 -0
  332. package/dist/pricing/acquisitionOfferPricingSchemas.d.ts +31 -0
  333. package/dist/pricing/acquisitionOfferPricingSchemas.js +33 -0
  334. package/dist/pricing/acquisitionQuoteBinding.d.ts +12 -0
  335. package/dist/pricing/acquisitionQuoteBinding.js +12 -0
  336. package/dist/pricing/acquisitionReadiness.d.ts +31 -0
  337. package/dist/pricing/acquisitionReadiness.js +117 -0
  338. package/dist/pricing/acquisitionTerms.d.ts +19 -0
  339. package/dist/pricing/acquisitionTerms.js +126 -0
  340. package/dist/pricing/acquisitionTermsSchemas.d.ts +59 -0
  341. package/dist/pricing/acquisitionTermsSchemas.js +42 -0
  342. package/dist/pricing/catalogFactsProvenance.d.ts +33 -0
  343. package/dist/pricing/catalogFactsProvenance.js +64 -0
  344. package/dist/pricing/catalogFactsSchemas.d.ts +45 -0
  345. package/dist/pricing/catalogFactsSchemas.js +58 -0
  346. package/dist/pricing/commerceOfferPricing.d.ts +25 -0
  347. package/dist/pricing/commerceOfferPricing.js +139 -0
  348. package/dist/pricing/commerceOfferPricingCache.d.ts +10 -0
  349. package/dist/pricing/commerceOfferPricingCache.js +44 -0
  350. package/dist/pricing/commerceOfferPricingHandler.d.ts +21 -0
  351. package/dist/pricing/commerceOfferPricingHandler.js +78 -0
  352. package/dist/pricing/commercePriceAuthority.d.ts +26 -0
  353. package/dist/pricing/commercePriceAuthority.js +79 -0
  354. package/dist/pricing/commercePricingPolicyErrors.d.ts +40 -0
  355. package/dist/pricing/commercePricingPolicyErrors.js +67 -0
  356. package/dist/pricing/commerceQuoteBatchHandler.d.ts +37 -0
  357. package/dist/pricing/commerceQuoteBatchHandler.js +83 -0
  358. package/dist/pricing/commerceQuoteCatalogReadPort.d.ts +27 -0
  359. package/dist/pricing/commerceQuoteCatalogReadPort.js +8 -0
  360. package/dist/pricing/commerceQuoteHandler.d.ts +31 -0
  361. package/dist/pricing/commerceQuoteHandler.js +110 -0
  362. package/dist/pricing/commerceQuoteSnapshotExpect.d.ts +9 -0
  363. package/dist/pricing/commerceQuoteSnapshotExpect.js +22 -0
  364. package/dist/pricing/contracts/acquisitionTerms.d.ts +32 -0
  365. package/dist/pricing/contracts/acquisitionTerms.js +2 -0
  366. package/dist/pricing/contracts/authority.d.ts +27 -0
  367. package/dist/pricing/contracts/authority.js +1 -0
  368. package/dist/pricing/contracts/evidence.d.ts +33 -0
  369. package/dist/pricing/contracts/evidence.js +1 -0
  370. package/dist/pricing/contracts/index.d.ts +17 -0
  371. package/dist/pricing/contracts/index.js +7 -0
  372. package/dist/pricing/contracts/money.d.ts +27 -0
  373. package/dist/pricing/contracts/money.js +1 -0
  374. package/dist/pricing/contracts/offer.d.ts +52 -0
  375. package/dist/pricing/contracts/offer.js +4 -0
  376. package/dist/pricing/contracts/offerPolicy.d.ts +16 -0
  377. package/dist/pricing/contracts/offerPolicy.js +5 -0
  378. package/dist/pricing/contracts/policy.d.ts +22 -0
  379. package/dist/pricing/contracts/policy.js +3 -0
  380. package/dist/pricing/contracts/provenance.d.ts +24 -0
  381. package/dist/pricing/contracts/provenance.js +2 -0
  382. package/dist/pricing/contracts/quote.d.ts +94 -0
  383. package/dist/pricing/contracts/quote.js +1 -0
  384. package/dist/pricing/dbBackedCommerceQuoteHelpers.d.ts +78 -0
  385. package/dist/pricing/dbBackedCommerceQuoteHelpers.js +146 -0
  386. package/dist/pricing/dbBackedCommerceQuotePort.d.ts +66 -0
  387. package/dist/pricing/dbBackedCommerceQuotePort.js +206 -0
  388. package/dist/pricing/dbBackedCommerceQuoteSnapshotVerifier.d.ts +4 -0
  389. package/dist/pricing/dbBackedCommerceQuoteSnapshotVerifier.js +25 -0
  390. package/dist/pricing/index.d.ts +51 -0
  391. package/dist/pricing/index.js +36 -0
  392. package/dist/pricing/offerPolicyReadiness.d.ts +21 -0
  393. package/dist/pricing/offerPolicyReadiness.js +79 -0
  394. package/dist/pricing/offerPolicySchemas.d.ts +25 -0
  395. package/dist/pricing/offerPolicySchemas.js +15 -0
  396. package/dist/pricing/offerPricingSchemas.d.ts +315 -0
  397. package/dist/pricing/offerPricingSchemas.js +65 -0
  398. package/dist/pricing/ports.d.ts +13 -0
  399. package/dist/pricing/ports.js +9 -0
  400. package/dist/pricing/pricingPolicyToken.d.ts +39 -0
  401. package/dist/pricing/pricingPolicyToken.js +84 -0
  402. package/dist/pricing/quoteAcquisitionTerms.d.ts +2 -0
  403. package/dist/pricing/quoteAcquisitionTerms.js +4 -0
  404. package/dist/pricing/quoteCodeRejectionDetails.d.ts +20 -0
  405. package/dist/pricing/quoteCodeRejectionDetails.js +22 -0
  406. package/dist/pricing/quotePorts.d.ts +30 -0
  407. package/dist/pricing/quotePorts.js +20 -0
  408. package/dist/pricing/quotePrimitives.d.ts +13 -0
  409. package/dist/pricing/quotePrimitives.js +18 -0
  410. package/dist/pricing/quotePromotionEvidence.d.ts +39 -0
  411. package/dist/pricing/quotePromotionEvidence.js +73 -0
  412. package/dist/pricing/quoteSchemas.d.ts +1176 -0
  413. package/dist/pricing/quoteSchemas.js +196 -0
  414. package/dist/pricing/subscriptionPricePolicy.d.ts +52 -0
  415. package/dist/pricing/subscriptionPricePolicy.js +96 -0
  416. package/dist/pricing/taxProfileGuard.d.ts +2 -0
  417. package/dist/pricing/taxProfileGuard.js +24 -0
  418. package/dist/pricing/validation.d.ts +2 -0
  419. package/dist/pricing/validation.js +3 -0
  420. package/dist/promotions/adminBindings.d.ts +72 -0
  421. package/dist/promotions/adminBindings.js +1 -0
  422. package/dist/promotions/adminPromotionCodesContracts.d.ts +498 -0
  423. package/dist/promotions/adminPromotionCodesContracts.js +211 -0
  424. package/dist/promotions/adminPromotionCodesDataPort.d.ts +47 -0
  425. package/dist/promotions/adminPromotionCodesDataPort.js +1 -0
  426. package/dist/promotions/adminPromotionCodesHandler.d.ts +14 -0
  427. package/dist/promotions/adminPromotionCodesHandler.js +194 -0
  428. package/dist/promotions/adminPromotionsContracts.d.ts +235 -0
  429. package/dist/promotions/adminPromotionsContracts.js +99 -0
  430. package/dist/promotions/adminPromotionsDataPort.d.ts +42 -0
  431. package/dist/promotions/adminPromotionsDataPort.js +1 -0
  432. package/dist/promotions/adminPromotionsHandler.d.ts +16 -0
  433. package/dist/promotions/adminPromotionsHandler.js +47 -0
  434. package/dist/promotions/contracts/index.d.ts +387 -0
  435. package/dist/promotions/contracts/index.js +1 -0
  436. package/dist/promotions/index.d.ts +22 -0
  437. package/dist/promotions/index.js +21 -0
  438. package/dist/promotions/promoDataPort.d.ts +47 -0
  439. package/dist/promotions/promoDataPort.js +14 -0
  440. package/dist/promotions/promotionAcceptanceTelemetry.d.ts +29 -0
  441. package/dist/promotions/promotionAcceptanceTelemetry.js +45 -0
  442. package/dist/promotions/promotionBenefitDefinition.d.ts +37 -0
  443. package/dist/promotions/promotionBenefitDefinition.js +33 -0
  444. package/dist/promotions/promotionClaimSweepPort.d.ts +14 -0
  445. package/dist/promotions/promotionClaimSweepPort.js +8 -0
  446. package/dist/promotions/promotionClaims.d.ts +5 -0
  447. package/dist/promotions/promotionClaims.js +57 -0
  448. package/dist/promotions/promotionCodePreview.d.ts +11 -0
  449. package/dist/promotions/promotionCodePreview.js +154 -0
  450. package/dist/promotions/promotionCodeQuotePort.d.ts +25 -0
  451. package/dist/promotions/promotionCodeQuotePort.js +1 -0
  452. package/dist/promotions/promotionQuoteAcceptance.d.ts +65 -0
  453. package/dist/promotions/promotionQuoteAcceptance.js +202 -0
  454. package/dist/promotions/promotionQuoteBinding.d.ts +71 -0
  455. package/dist/promotions/promotionQuoteBinding.js +85 -0
  456. package/dist/promotions/quoteAutomaticPromotions.d.ts +24 -0
  457. package/dist/promotions/quoteAutomaticPromotions.js +36 -0
  458. package/dist/promotions/quotePromoDiscounts.d.ts +32 -0
  459. package/dist/promotions/quotePromoDiscounts.js +140 -0
  460. package/dist/promotions/quotePromotionCodeAdjustments.d.ts +27 -0
  461. package/dist/promotions/quotePromotionCodeAdjustments.js +223 -0
  462. package/dist/promotions/quotePromotionV2.d.ts +29 -0
  463. package/dist/promotions/quotePromotionV2.js +174 -0
  464. package/dist/promotions/sql.d.ts +14 -0
  465. package/dist/promotions/sql.js +5 -0
  466. package/dist/promotions/validation.d.ts +2 -0
  467. package/dist/promotions/validation.js +3 -0
  468. package/dist/shipping/addressCanonLookupHandler.d.ts +7 -0
  469. package/dist/shipping/addressCanonLookupHandler.js +105 -0
  470. package/dist/shipping/addressCanonical.d.ts +2 -0
  471. package/dist/shipping/addressCanonical.js +26 -0
  472. package/dist/shipping/addressPorts.d.ts +39 -0
  473. package/dist/shipping/addressPorts.js +1 -0
  474. package/dist/shipping/addressSchemas.d.ts +30 -0
  475. package/dist/shipping/addressSchemas.js +1 -0
  476. package/dist/shipping/adminShippingRateHandler.d.ts +4 -0
  477. package/dist/shipping/adminShippingRateHandler.js +64 -0
  478. package/dist/shipping/contracts/address.d.ts +144 -0
  479. package/dist/shipping/contracts/address.js +1 -0
  480. package/dist/shipping/contracts/delivery.d.ts +110 -0
  481. package/dist/shipping/contracts/delivery.js +1 -0
  482. package/dist/shipping/contracts/index.d.ts +3 -0
  483. package/dist/shipping/contracts/index.js +1 -0
  484. package/dist/shipping/contracts/shippingRate.d.ts +11 -0
  485. package/dist/shipping/contracts/shippingRate.js +1 -0
  486. package/dist/shipping/customerAddressesHandler.d.ts +5 -0
  487. package/dist/shipping/customerAddressesHandler.js +80 -0
  488. package/dist/shipping/customerSelfServiceAddressModels.d.ts +27 -0
  489. package/dist/shipping/customerSelfServiceAddressModels.js +101 -0
  490. package/dist/shipping/deliverySelectionHandler.d.ts +10 -0
  491. package/dist/shipping/deliverySelectionHandler.js +77 -0
  492. package/dist/shipping/deliverySelectionPort.d.ts +8 -0
  493. package/dist/shipping/deliverySelectionPort.js +1 -0
  494. package/dist/shipping/deliverySelectionSummary.d.ts +2 -0
  495. package/dist/shipping/deliverySelectionSummary.js +53 -0
  496. package/dist/shipping/handlerSchemas.d.ts +21 -0
  497. package/dist/shipping/handlerSchemas.js +1 -0
  498. package/dist/shipping/index.d.ts +17 -0
  499. package/dist/shipping/index.js +8 -0
  500. package/dist/shipping/pickupPointSearchPort.d.ts +4 -0
  501. package/dist/shipping/pickupPointSearchPort.js +1 -0
  502. package/dist/shipping/readDeliverySelectionEvidence.d.ts +2 -0
  503. package/dist/shipping/readDeliverySelectionEvidence.js +44 -0
  504. package/dist/shipping/shippingRatePorts.d.ts +52 -0
  505. package/dist/shipping/shippingRatePorts.js +1 -0
  506. package/package.json +72 -2
  507. package/release-gates.json +249 -8
  508. package/sql/20260807140000_read_parity_catalog.sql +94 -0
  509. package/sql/20260807190000_comms_outbox_rail.sql +329 -0
  510. package/sql/20260810120000_storefront_catalog_attributes.sql +51 -0
  511. package/sql/20260810120001_transactional_delivery_receipts.sql +209 -0
  512. package/sql/20260812140000_sellable_bundle_catalog.sql +124 -0
  513. package/sql/20260812210000_bundle_operator_write_boundary.sql +567 -0
  514. package/sql/20260813120000_communications_control_plane.sql +568 -0
  515. package/sql/20260814000000_fulfillment_stock_evidence.sql +239 -0
  516. package/sql/20260815120000_automatic_subscription_renewal.sql +1083 -0
  517. package/sql/20260817180000_promotion_claim_lifecycle.sql +591 -0
  518. package/sql/20260817180100_promotion_claim_lifecycle_validation.sql +23 -0
  519. package/sql/20260827220000_catalog_document_revision_foundation.sql +226 -0
  520. package/sql/20260827220001_catalog_document_revision_foundation_validate.sql +10 -0
  521. package/sql/20260908100000_catalog_draft_foundation.sql +217 -0
  522. package/sql/20261019200000_communications_native_operations.sql +68 -0
  523. package/src/catalog/activeSkuSelection.ts +20 -0
  524. package/src/catalog/adminBindings.ts +59 -0
  525. package/src/catalog/adminBundleHandler.ts +165 -0
  526. package/src/catalog/adminBundleReadHandler.ts +261 -0
  527. package/src/catalog/adminBundleWritePort.ts +102 -0
  528. package/src/catalog/bundleAvailability.ts +129 -0
  529. package/src/catalog/bundleAvailabilityService.ts +171 -0
  530. package/src/catalog/bundleBindings.ts +29 -0
  531. package/src/catalog/bundleCatalogQueries.ts +98 -0
  532. package/src/catalog/bundleCatalogReadPort.ts +177 -0
  533. package/src/catalog/bundleCatalogStore.ts +269 -0
  534. package/src/catalog/bundleRuleCodes.ts +134 -0
  535. package/src/catalog/bundleRules.ts +153 -0
  536. package/src/catalog/catalogDraftStore.ts +71 -0
  537. package/src/catalog/catalogSkuEnvelope.ts +214 -0
  538. package/src/catalog/catalogSkuEnvelopeMapper.ts +160 -0
  539. package/src/catalog/contracts/bundleAdmin.ts +20 -0
  540. package/src/catalog/contracts/bundleAvailability.ts +5 -0
  541. package/src/catalog/contracts/bundleRead.ts +13 -0
  542. package/src/catalog/contracts/draft.ts +69 -0
  543. package/src/catalog/contracts/foundation.ts +104 -0
  544. package/src/catalog/contracts/index.ts +14 -0
  545. package/src/catalog/contracts/lifecycle.ts +74 -0
  546. package/src/catalog/contracts/productMediaContracts.ts +170 -0
  547. package/src/catalog/contracts/productTypes.ts +35 -0
  548. package/src/catalog/contracts/resolveProductMedia.ts +85 -0
  549. package/src/catalog/contracts/sellable.ts +12 -0
  550. package/src/catalog/draftHandler.ts +105 -0
  551. package/src/catalog/draftPorts.ts +18 -0
  552. package/src/catalog/draftSchemas.ts +88 -0
  553. package/src/catalog/draftValidation.ts +100 -0
  554. package/src/catalog/foundationSchemas.ts +123 -0
  555. package/src/catalog/index.ts +43 -0
  556. package/src/catalog/mediaSourcePack.ts +219 -0
  557. package/src/catalog/productTypeSchemas.ts +70 -0
  558. package/src/catalog/publicationPorts.ts +44 -0
  559. package/src/catalog/readPorts.ts +61 -0
  560. package/src/catalog/referenceCatalogHandler.ts +39 -0
  561. package/src/catalog/resolvedSkuProjection.ts +76 -0
  562. package/src/catalog/sellableBundleHandler.ts +133 -0
  563. package/src/catalog/sellableSchemas.ts +33 -0
  564. package/src/catalog/sql.ts +14 -0
  565. package/src/catalog/validation.ts +3 -0
  566. package/src/communications/accountingDocumentDelivery.ts +63 -0
  567. package/src/communications/authEmailError.ts +10 -0
  568. package/src/communications/authEmailPorts.ts +2 -0
  569. package/src/communications/authSendEmailHook.ts +310 -0
  570. package/src/communications/capturedTransactionalDelivery.ts +29 -0
  571. package/src/communications/communicationSync.ts +96 -0
  572. package/src/communications/communicationSyncWorker.ts +302 -0
  573. package/src/communications/consentPolicy.ts +82 -0
  574. package/src/communications/consentPurposeRegistry.ts +31 -0
  575. package/src/communications/contracts/abandonedCart.ts +64 -0
  576. package/src/communications/contracts/authEmail.ts +73 -0
  577. package/src/communications/contracts/backInStock.ts +69 -0
  578. package/src/communications/contracts/blocks.ts +47 -0
  579. package/src/communications/contracts/checkoutExpired.ts +62 -0
  580. package/src/communications/contracts/checkoutRecovery.ts +68 -0
  581. package/src/communications/contracts/commerceEmailContent.ts +189 -0
  582. package/src/communications/contracts/commerceEngagementEmailContent.ts +106 -0
  583. package/src/communications/contracts/consent.ts +13 -0
  584. package/src/communications/contracts/email.ts +210 -0
  585. package/src/communications/contracts/guideCard.ts +34 -0
  586. package/src/communications/contracts/index.ts +52 -0
  587. package/src/communications/contracts/inquiryContent.ts +53 -0
  588. package/src/communications/contracts/invoiceDocumentContent.ts +57 -0
  589. package/src/communications/contracts/marketingAutomation.ts +45 -0
  590. package/src/communications/contracts/marketingSync.ts +109 -0
  591. package/src/communications/contracts/newsletter.ts +78 -0
  592. package/src/communications/contracts/newsletterWebhook.ts +23 -0
  593. package/src/communications/contracts/optOutContent.ts +23 -0
  594. package/src/communications/contracts/orderCanceled.ts +64 -0
  595. package/src/communications/contracts/orderDraft.ts +112 -0
  596. package/src/communications/contracts/orderPaid.ts +147 -0
  597. package/src/communications/contracts/orderRefunded.ts +63 -0
  598. package/src/communications/contracts/paymentFailed.ts +59 -0
  599. package/src/communications/contracts/publicIntake.ts +53 -0
  600. package/src/communications/contracts/render.ts +271 -0
  601. package/src/communications/contracts/reorderReminder.ts +59 -0
  602. package/src/communications/contracts/returnEmails.ts +113 -0
  603. package/src/communications/contracts/reviewEffects.ts +60 -0
  604. package/src/communications/contracts/reviewRequest.ts +59 -0
  605. package/src/communications/contracts/roleNotificationContent.ts +65 -0
  606. package/src/communications/contracts/shipmentDelivered.ts +59 -0
  607. package/src/communications/contracts/shipmentDispatched.ts +77 -0
  608. package/src/communications/contracts/shipmentException.ts +62 -0
  609. package/src/communications/contracts/subscriptionActivationActionRequired.ts +37 -0
  610. package/src/communications/contracts/subscriptionAddressChanged.ts +56 -0
  611. package/src/communications/contracts/subscriptionCancelled.ts +57 -0
  612. package/src/communications/contracts/subscriptionCycleSkipped.ts +80 -0
  613. package/src/communications/contracts/subscriptionDeliveryRescheduled.ts +79 -0
  614. package/src/communications/contracts/subscriptionEmailContent.ts +163 -0
  615. package/src/communications/contracts/subscriptionPackageChanged.ts +59 -0
  616. package/src/communications/contracts/subscriptionPauseReminder.ts +63 -0
  617. package/src/communications/contracts/subscriptionPaused.ts +58 -0
  618. package/src/communications/contracts/subscriptionPaymentExpired.ts +83 -0
  619. package/src/communications/contracts/subscriptionPaymentFailed.ts +117 -0
  620. package/src/communications/contracts/subscriptionPaymentRecovered.ts +50 -0
  621. package/src/communications/contracts/subscriptionRenewalAtRisk.ts +85 -0
  622. package/src/communications/contracts/subscriptionRenewalUpcoming.ts +103 -0
  623. package/src/communications/contracts/subscriptionResumed.ts +60 -0
  624. package/src/communications/contracts/subscriptionWelcome.ts +102 -0
  625. package/src/communications/contracts/subscriptionWinback.ts +62 -0
  626. package/src/communications/contracts/transactionalDelivery.ts +43 -0
  627. package/src/communications/contracts/types.ts +58 -0
  628. package/src/communications/contribution.ts +33 -0
  629. package/src/communications/deliveryReconciliation.ts +108 -0
  630. package/src/communications/emailEgress.ts +111 -0
  631. package/src/communications/emailHealthAssessment.ts +106 -0
  632. package/src/communications/emailHealthMetricsPort.ts +17 -0
  633. package/src/communications/emailNotificationControl.ts +28 -0
  634. package/src/communications/emailObservation.ts +43 -0
  635. package/src/communications/emailTransport.ts +167 -0
  636. package/src/communications/errors.ts +34 -0
  637. package/src/communications/index.ts +47 -0
  638. package/src/communications/integrationEventSignature.ts +49 -0
  639. package/src/communications/klaviyo/consentPush.ts +19 -0
  640. package/src/communications/klaviyo/index.ts +649 -0
  641. package/src/communications/managedTransactionalDeliveryStore.ts +59 -0
  642. package/src/communications/nativeOperations.ts +40 -0
  643. package/src/communications/newsletterIntegrationContracts.ts +154 -0
  644. package/src/communications/newsletterWebhookPort.ts +104 -0
  645. package/src/communications/newsletterWebhookProcessing.ts +102 -0
  646. package/src/communications/originPolicy.ts +151 -0
  647. package/src/communications/postgresCommunicationSync.ts +127 -0
  648. package/src/communications/postgresConsentEvaluator.ts +49 -0
  649. package/src/communications/postgresDeliveryReconciliation.ts +101 -0
  650. package/src/communications/postgresNativeOperations.ts +55 -0
  651. package/src/communications/postgresNotificationRecipients.ts +57 -0
  652. package/src/communications/postgresTransactionalDeliveryStore.ts +79 -0
  653. package/src/communications/preferencesToken.ts +62 -0
  654. package/src/communications/publicPreferenceToken.ts +68 -0
  655. package/src/communications/resend/index.ts +350 -0
  656. package/src/communications/shipmentNotifications.ts +78 -0
  657. package/src/communications/sql.ts +7 -0
  658. package/src/communications/standardWebhooks.ts +84 -0
  659. package/src/communications/status.ts +51 -0
  660. package/src/communications/transactionalDelivery.ts +114 -0
  661. package/src/communications/transactionalDeliveryIdentifier.ts +9 -0
  662. package/src/communications/unsubscribeToken.ts +186 -0
  663. package/src/communications/validation.ts +3 -0
  664. package/src/composition/catalogContribution.ts +32 -0
  665. package/src/composition/index.ts +1 -0
  666. package/src/http/index.ts +1 -0
  667. package/src/http/webhookSignature.ts +96 -0
  668. package/src/inventory/adminInventory.ts +251 -0
  669. package/src/inventory/contracts/forecast.ts +96 -0
  670. package/src/inventory/contracts/index.ts +18 -0
  671. package/src/inventory/contracts/inventory.ts +14 -0
  672. package/src/inventory/contracts/newPurchaseStock.ts +23 -0
  673. package/src/inventory/contracts/reservation.ts +20 -0
  674. package/src/inventory/forecast.ts +239 -0
  675. package/src/inventory/index.ts +21 -0
  676. package/src/inventory/inventoryHandlers.ts +215 -0
  677. package/src/inventory/newPurchaseStockAvailability.ts +120 -0
  678. package/src/inventory/ports.ts +46 -0
  679. package/src/inventory/renewalReservation.ts +88 -0
  680. package/src/inventory/reservationPolicy.ts +27 -0
  681. package/src/inventory/schemas.ts +128 -0
  682. package/src/inventory/sql.ts +5 -0
  683. package/src/inventory/subscriptionForecastCalculation.ts +157 -0
  684. package/src/pricing/acquisitionFinancialPolicy.ts +26 -0
  685. package/src/pricing/acquisitionOfferPricing.ts +38 -0
  686. package/src/pricing/acquisitionOfferPricingHandler.ts +157 -0
  687. package/src/pricing/acquisitionOfferPricingSchemas.ts +35 -0
  688. package/src/pricing/acquisitionQuoteBinding.ts +12 -0
  689. package/src/pricing/acquisitionReadiness.ts +148 -0
  690. package/src/pricing/acquisitionTerms.ts +125 -0
  691. package/src/pricing/acquisitionTermsSchemas.ts +52 -0
  692. package/src/pricing/catalogFactsProvenance.ts +102 -0
  693. package/src/pricing/catalogFactsSchemas.ts +69 -0
  694. package/src/pricing/commerceOfferPricing.ts +224 -0
  695. package/src/pricing/commerceOfferPricingCache.ts +53 -0
  696. package/src/pricing/commerceOfferPricingHandler.ts +137 -0
  697. package/src/pricing/commercePriceAuthority.ts +104 -0
  698. package/src/pricing/commercePricingPolicyErrors.ts +88 -0
  699. package/src/pricing/commerceQuoteBatchHandler.ts +129 -0
  700. package/src/pricing/commerceQuoteCatalogReadPort.ts +42 -0
  701. package/src/pricing/commerceQuoteHandler.ts +184 -0
  702. package/src/pricing/commerceQuoteSnapshotExpect.ts +48 -0
  703. package/src/pricing/contracts/acquisitionTerms.ts +26 -0
  704. package/src/pricing/contracts/authority.ts +44 -0
  705. package/src/pricing/contracts/evidence.ts +25 -0
  706. package/src/pricing/contracts/index.ts +17 -0
  707. package/src/pricing/contracts/money.ts +32 -0
  708. package/src/pricing/contracts/offer.ts +42 -0
  709. package/src/pricing/contracts/offerPolicy.ts +17 -0
  710. package/src/pricing/contracts/policy.ts +26 -0
  711. package/src/pricing/contracts/provenance.ts +19 -0
  712. package/src/pricing/contracts/quote.ts +106 -0
  713. package/src/pricing/dbBackedCommerceQuoteHelpers.ts +256 -0
  714. package/src/pricing/dbBackedCommerceQuotePort.ts +260 -0
  715. package/src/pricing/dbBackedCommerceQuoteSnapshotVerifier.ts +49 -0
  716. package/src/pricing/index.ts +52 -0
  717. package/src/pricing/offerPolicyReadiness.ts +110 -0
  718. package/src/pricing/offerPolicySchemas.ts +23 -0
  719. package/src/pricing/offerPricingSchemas.ts +92 -0
  720. package/src/pricing/ports.ts +17 -0
  721. package/src/pricing/pricingPolicyToken.ts +119 -0
  722. package/src/pricing/quoteAcquisitionTerms.ts +10 -0
  723. package/src/pricing/quoteCodeRejectionDetails.ts +23 -0
  724. package/src/pricing/quotePorts.ts +58 -0
  725. package/src/pricing/quotePrimitives.ts +21 -0
  726. package/src/pricing/quotePromotionEvidence.ts +82 -0
  727. package/src/pricing/quoteSchemas.ts +230 -0
  728. package/src/pricing/subscriptionPricePolicy.ts +113 -0
  729. package/src/pricing/taxProfileGuard.ts +33 -0
  730. package/src/pricing/validation.ts +3 -0
  731. package/src/promotions/adminBindings.ts +53 -0
  732. package/src/promotions/adminPromotionCodesContracts.ts +244 -0
  733. package/src/promotions/adminPromotionCodesDataPort.ts +56 -0
  734. package/src/promotions/adminPromotionCodesHandler.ts +254 -0
  735. package/src/promotions/adminPromotionsContracts.ts +121 -0
  736. package/src/promotions/adminPromotionsDataPort.ts +48 -0
  737. package/src/promotions/adminPromotionsHandler.ts +72 -0
  738. package/src/promotions/contracts/index.ts +387 -0
  739. package/src/promotions/index.ts +22 -0
  740. package/src/promotions/promoDataPort.ts +65 -0
  741. package/src/promotions/promotionAcceptanceTelemetry.ts +73 -0
  742. package/src/promotions/promotionBenefitDefinition.ts +48 -0
  743. package/src/promotions/promotionClaimSweepPort.ts +23 -0
  744. package/src/promotions/promotionClaims.ts +70 -0
  745. package/src/promotions/promotionCodePreview.ts +183 -0
  746. package/src/promotions/promotionCodeQuotePort.ts +35 -0
  747. package/src/promotions/promotionQuoteAcceptance.ts +284 -0
  748. package/src/promotions/promotionQuoteBinding.ts +158 -0
  749. package/src/promotions/quoteAutomaticPromotions.ts +58 -0
  750. package/src/promotions/quotePromoDiscounts.ts +185 -0
  751. package/src/promotions/quotePromotionCodeAdjustments.ts +277 -0
  752. package/src/promotions/quotePromotionV2.ts +223 -0
  753. package/src/promotions/sql.ts +5 -0
  754. package/src/promotions/validation.ts +3 -0
  755. package/src/shipping/addressCanonLookupHandler.ts +114 -0
  756. package/src/shipping/addressCanonical.ts +31 -0
  757. package/src/shipping/addressPorts.ts +48 -0
  758. package/src/shipping/addressSchemas.ts +28 -0
  759. package/src/shipping/adminShippingRateHandler.ts +72 -0
  760. package/src/shipping/contracts/address.ts +71 -0
  761. package/src/shipping/contracts/delivery.ts +114 -0
  762. package/src/shipping/contracts/index.ts +18 -0
  763. package/src/shipping/contracts/shippingRate.ts +7 -0
  764. package/src/shipping/customerAddressesHandler.ts +100 -0
  765. package/src/shipping/customerSelfServiceAddressModels.ts +124 -0
  766. package/src/shipping/deliverySelectionHandler.ts +94 -0
  767. package/src/shipping/deliverySelectionPort.ts +10 -0
  768. package/src/shipping/deliverySelectionSummary.ts +56 -0
  769. package/src/shipping/handlerSchemas.ts +19 -0
  770. package/src/shipping/index.ts +23 -0
  771. package/src/shipping/pickupPointSearchPort.ts +8 -0
  772. package/src/shipping/readDeliverySelectionEvidence.ts +51 -0
  773. package/src/shipping/shippingRatePorts.ts +36 -0
@@ -0,0 +1,25 @@
1
+ import { isDeepStrictEqual } from "node:util";
2
+ import { CommerceQuoteSnapshotError, } from "./quotePorts.js";
3
+ import { projectPublicQuoteSnapshot } from "./catalogFactsProvenance.js";
4
+ import { createExpectedQuote } from "./commerceQuoteSnapshotExpect.js";
5
+ export function createDbBackedCommerceQuoteSnapshotVerifier(quotePort, quoteRequestFromSnapshot, createQuoteResponseSchema) {
6
+ async function verifyAndEnrich(snapshot) {
7
+ const publicSnapshot = projectPublicQuoteSnapshot(snapshot);
8
+ const expected = await createExpectedQuote(quotePort.createServerAuthoritativeQuote
9
+ ? { createQuote: quotePort.createServerAuthoritativeQuote.bind(quotePort) }
10
+ : quotePort, quoteRequestFromSnapshot(publicSnapshot), {
11
+ invalidResponseMessage: "Commerce DB-backed quote verifier returned invalid response",
12
+ catalogMismatchMessage: "Commerce quote snapshot does not match current DB-backed catalog pricing",
13
+ }, createQuoteResponseSchema);
14
+ if (!isDeepStrictEqual(publicSnapshot, projectPublicQuoteSnapshot(expected))) {
15
+ throw new CommerceQuoteSnapshotError("QUOTE_SNAPSHOT_MISMATCH", "Commerce quote snapshot does not match current DB-backed catalog pricing", {
16
+ reason: "snapshot_does_not_match_db_backed_quote",
17
+ skus: publicSnapshot.quote.lines.map((line) => line.sku),
18
+ });
19
+ }
20
+ return expected;
21
+ }
22
+ return {
23
+ verifyQuoteSnapshot: verifyAndEnrich,
24
+ };
25
+ }
@@ -0,0 +1,51 @@
1
+ export * from "./contracts/index.js";
2
+ export { CommercePriceAuthorityError } from "./ports.js";
3
+ export type { CommercePriceAuthorityPort } from "./ports.js";
4
+ export { createCommercePriceAuthorityPort, selectUniqueEffectivePriceList } from "./commercePriceAuthority.js";
5
+ export type { CommercePriceAuthorityReadPort, TimedAuthorityValue } from "./commercePriceAuthority.js";
6
+ export { subscriptionPricePolicySemanticsSchema, subscriptionPricePolicyCanonicalInputSchema, subscriptionPricePolicyRevisionSchema, SubscriptionPricePolicyDigestError, canonicalSubscriptionPricePolicyTuple, digestSubscriptionPricePolicy, assertSubscriptionPricePolicyDigest, deriveSubscriptionUnitPrice } from "./subscriptionPricePolicy.js";
7
+ export { offerPolicyVersionSchema, promotionEngineVersionSchema, pricingPolicyRequestSchema, pricingPolicySnapshotSchema } from "./offerPolicySchemas.js";
8
+ export { createPricingPolicyToken, verifyPricingPolicyToken, resolvePricingPolicy } from "./pricingPolicyToken.js";
9
+ export type { PricingPolicyTokenPayload } from "./pricingPolicyToken.js";
10
+ export { CommercePricingPolicyUnavailableError, PRICING_POLICY_REQUEST_REASONS, CommercePricingPolicyRequestError, mapPricingPolicyFailure } from "./commercePricingPolicyErrors.js";
11
+ export type { PricingPolicyRequestReason, SafePricingPolicyReason, PricingPolicyFailureMapping } from "./commercePricingPolicyErrors.js";
12
+ export { CommerceQuoteError, CommerceQuoteSnapshotError } from "./quotePorts.js";
13
+ export type { CreateQuoteOptions, CommerceQuotePort, CommerceQuoteSnapshotVerifierPort, CommerceQuoteErrorCode, CommerceQuoteSnapshotErrorCode } from "./quotePorts.js";
14
+ export { createCommerceQuotePrimitives } from "./quotePrimitives.js";
15
+ export { createCommerceQuoteSchemas, splitIncludedVat, quoteMoneyCurrenciesMatch } from "./quoteSchemas.js";
16
+ export { quoteDiscountSchema, hasValidV2PromotionEvidence } from "./quotePromotionEvidence.js";
17
+ export { quoteCodeRejectionDetailSchema } from "./quoteCodeRejectionDetails.js";
18
+ export { catalogFactsProvenanceSchema, rejectCatalogFactsFromPublicQuote } from "./catalogFactsSchemas.js";
19
+ export { createCatalogFactsProvenance, catalogFactsForQuoteLine, projectPublicQuoteSnapshot } from "./catalogFactsProvenance.js";
20
+ export { CommerceQuoteCatalogReadError } from "./commerceQuoteCatalogReadPort.js";
21
+ export type { CommerceQuoteCatalogItem, CommerceQuoteCatalogReadPort, CommerceQuoteCatalogReadRefusalCode } from "./commerceQuoteCatalogReadPort.js";
22
+ export { assertSupportedCommerceTaxProfile } from "./taxProfileGuard.js";
23
+ export { buildSkuIndex, eligibleQtyForMode, resolveOneTimeComparison, resolveStrictQuotePrice, assertSubscriptionCheapest, toGrossMinor, calculateIncludedVat, mapPricingComponent, moneyIn, sum } from "./dbBackedCommerceQuoteHelpers.js";
24
+ export type { SkuIndexEntry, StrictQuotePriceResolution } from "./dbBackedCommerceQuoteHelpers.js";
25
+ export { createDbBackedCommerceQuotePort } from "./dbBackedCommerceQuotePort.js";
26
+ export type { DbBackedCommerceQuotePortDeps, QuotePromotionResult } from "./dbBackedCommerceQuotePort.js";
27
+ export { createExpectedQuote } from "./commerceQuoteSnapshotExpect.js";
28
+ export type { QuoteSnapshotExpectMessages } from "./commerceQuoteSnapshotExpect.js";
29
+ export { createDbBackedCommerceQuoteSnapshotVerifier } from "./dbBackedCommerceQuoteSnapshotVerifier.js";
30
+ export { createCommerceQuoteHandler } from "./commerceQuoteHandler.js";
31
+ export type { CommerceQuoteHandlerDeps } from "./commerceQuoteHandler.js";
32
+ export { createCommerceQuoteBatchHandler } from "./commerceQuoteBatchHandler.js";
33
+ export type { CommerceQuoteBatchHandlerDeps } from "./commerceQuoteBatchHandler.js";
34
+ export { createCommerceOfferPricingSchemas } from "./offerPricingSchemas.js";
35
+ export { projectCommerceOfferPricing } from "./commerceOfferPricing.js";
36
+ export type { CommerceOfferPricingDeps } from "./commerceOfferPricing.js";
37
+ export { createCommerceOfferPricingHandler, COMMERCE_OFFER_PRICING_CACHE_CONTROL, COMMERCE_OFFER_PRICING_ASSIGNED_CACHE_CONTROL, OFFER_POLICY_CAPABILITY_HEADER, OFFER_POLICY_TOKEN_HEADER, OFFER_POLICY_VISITOR_HEADER } from "./commerceOfferPricingHandler.js";
38
+ export type { CommerceOfferPricingHandlerDeps } from "./commerceOfferPricingHandler.js";
39
+ export { createCommerceOfferPricingCache } from "./commerceOfferPricingCache.js";
40
+ export type { CommerceOfferPricingCache } from "./commerceOfferPricingCache.js";
41
+ export { OFFER_POLICY_V2_READINESS_CONTRACT, createOfferPolicyReadinessCache, readOfferPolicyV2Readiness, resetOfferPolicyReadinessCacheForTests } from "./offerPolicyReadiness.js";
42
+ export type { OfferPolicyV2Readiness, OfferPolicyReadinessPort, OfferPolicyReadinessCache } from "./offerPolicyReadiness.js";
43
+ export * from "./acquisitionFinancialPolicy.js";
44
+ export * from "./acquisitionTermsSchemas.js";
45
+ export * from "./acquisitionTerms.js";
46
+ export * from "./quoteAcquisitionTerms.js";
47
+ export * from "./acquisitionQuoteBinding.js";
48
+ export * from "./acquisitionOfferPricingSchemas.js";
49
+ export * from "./acquisitionOfferPricing.js";
50
+ export * from "./acquisitionOfferPricingHandler.js";
51
+ export * from "./acquisitionReadiness.js";
@@ -0,0 +1,36 @@
1
+ export * from "./contracts/index.js";
2
+ export { CommercePriceAuthorityError } from "./ports.js";
3
+ export { createCommercePriceAuthorityPort, selectUniqueEffectivePriceList } from "./commercePriceAuthority.js";
4
+ export { subscriptionPricePolicySemanticsSchema, subscriptionPricePolicyCanonicalInputSchema, subscriptionPricePolicyRevisionSchema, SubscriptionPricePolicyDigestError, canonicalSubscriptionPricePolicyTuple, digestSubscriptionPricePolicy, assertSubscriptionPricePolicyDigest, deriveSubscriptionUnitPrice } from "./subscriptionPricePolicy.js";
5
+ export { offerPolicyVersionSchema, promotionEngineVersionSchema, pricingPolicyRequestSchema, pricingPolicySnapshotSchema } from "./offerPolicySchemas.js";
6
+ export { createPricingPolicyToken, verifyPricingPolicyToken, resolvePricingPolicy } from "./pricingPolicyToken.js";
7
+ export { CommercePricingPolicyUnavailableError, PRICING_POLICY_REQUEST_REASONS, CommercePricingPolicyRequestError, mapPricingPolicyFailure } from "./commercePricingPolicyErrors.js";
8
+ export { CommerceQuoteError, CommerceQuoteSnapshotError } from "./quotePorts.js";
9
+ export { createCommerceQuotePrimitives } from "./quotePrimitives.js";
10
+ export { createCommerceQuoteSchemas, splitIncludedVat, quoteMoneyCurrenciesMatch } from "./quoteSchemas.js";
11
+ export { quoteDiscountSchema, hasValidV2PromotionEvidence } from "./quotePromotionEvidence.js";
12
+ export { quoteCodeRejectionDetailSchema } from "./quoteCodeRejectionDetails.js";
13
+ export { catalogFactsProvenanceSchema, rejectCatalogFactsFromPublicQuote } from "./catalogFactsSchemas.js";
14
+ export { createCatalogFactsProvenance, catalogFactsForQuoteLine, projectPublicQuoteSnapshot } from "./catalogFactsProvenance.js";
15
+ export { CommerceQuoteCatalogReadError } from "./commerceQuoteCatalogReadPort.js";
16
+ export { assertSupportedCommerceTaxProfile } from "./taxProfileGuard.js";
17
+ export { buildSkuIndex, eligibleQtyForMode, resolveOneTimeComparison, resolveStrictQuotePrice, assertSubscriptionCheapest, toGrossMinor, calculateIncludedVat, mapPricingComponent, moneyIn, sum } from "./dbBackedCommerceQuoteHelpers.js";
18
+ export { createDbBackedCommerceQuotePort } from "./dbBackedCommerceQuotePort.js";
19
+ export { createExpectedQuote } from "./commerceQuoteSnapshotExpect.js";
20
+ export { createDbBackedCommerceQuoteSnapshotVerifier } from "./dbBackedCommerceQuoteSnapshotVerifier.js";
21
+ export { createCommerceQuoteHandler } from "./commerceQuoteHandler.js";
22
+ export { createCommerceQuoteBatchHandler } from "./commerceQuoteBatchHandler.js";
23
+ export { createCommerceOfferPricingSchemas } from "./offerPricingSchemas.js";
24
+ export { projectCommerceOfferPricing } from "./commerceOfferPricing.js";
25
+ export { createCommerceOfferPricingHandler, COMMERCE_OFFER_PRICING_CACHE_CONTROL, COMMERCE_OFFER_PRICING_ASSIGNED_CACHE_CONTROL, OFFER_POLICY_CAPABILITY_HEADER, OFFER_POLICY_TOKEN_HEADER, OFFER_POLICY_VISITOR_HEADER } from "./commerceOfferPricingHandler.js";
26
+ export { createCommerceOfferPricingCache } from "./commerceOfferPricingCache.js";
27
+ export { OFFER_POLICY_V2_READINESS_CONTRACT, createOfferPolicyReadinessCache, readOfferPolicyV2Readiness, resetOfferPolicyReadinessCacheForTests } from "./offerPolicyReadiness.js";
28
+ export * from "./acquisitionFinancialPolicy.js";
29
+ export * from "./acquisitionTermsSchemas.js";
30
+ export * from "./acquisitionTerms.js";
31
+ export * from "./quoteAcquisitionTerms.js";
32
+ export * from "./acquisitionQuoteBinding.js";
33
+ export * from "./acquisitionOfferPricingSchemas.js";
34
+ export * from "./acquisitionOfferPricing.js";
35
+ export * from "./acquisitionOfferPricingHandler.js";
36
+ export * from "./acquisitionReadiness.js";
@@ -0,0 +1,21 @@
1
+ export declare const OFFER_POLICY_V2_READINESS_CONTRACT = "commerce-offer-policy-v2-readiness.v1";
2
+ export interface OfferPolicyV2Readiness {
3
+ contractVersion: typeof OFFER_POLICY_V2_READINESS_CONTRACT;
4
+ ready: boolean;
5
+ checkedAt: string;
6
+ reasons: string[];
7
+ }
8
+ export interface OfferPolicyReadinessPort {
9
+ readOfferPolicyV2Readiness(): Promise<unknown>;
10
+ }
11
+ export interface OfferPolicyReadinessCache {
12
+ read(port: OfferPolicyReadinessPort): Promise<OfferPolicyV2Readiness>;
13
+ clear(): void;
14
+ }
15
+ export declare function createOfferPolicyReadinessCache(input?: {
16
+ now?: () => number;
17
+ positiveTtlMs?: number;
18
+ negativeTtlMs?: number;
19
+ }): OfferPolicyReadinessCache;
20
+ export declare function readOfferPolicyV2Readiness(port: OfferPolicyReadinessPort): Promise<OfferPolicyV2Readiness>;
21
+ export declare function resetOfferPolicyReadinessCacheForTests(isTest: boolean): void;
@@ -0,0 +1,79 @@
1
+ export const OFFER_POLICY_V2_READINESS_CONTRACT = "commerce-offer-policy-v2-readiness.v1";
2
+ export function createOfferPolicyReadinessCache(input = {}) {
3
+ const now = input.now ?? Date.now;
4
+ const positiveTtlMs = Math.min(60_000, Math.max(0, input.positiveTtlMs ?? 60_000));
5
+ const negativeTtlMs = Math.min(5_000, Math.max(0, input.negativeTtlMs ?? 5_000));
6
+ let cached = null;
7
+ let inFlight = null;
8
+ return {
9
+ read(port) {
10
+ const current = now();
11
+ if (cached && cached.expiresAtMs > current)
12
+ return Promise.resolve(cached.readiness);
13
+ if (inFlight)
14
+ return inFlight;
15
+ const startedAtMs = current;
16
+ inFlight = loadFailClosed(port)
17
+ .then((readiness) => {
18
+ cached = {
19
+ readiness,
20
+ // Bound staleness from the start of the database read. A slow RPC
21
+ // must consume the TTL, not extend a green decision past 60s.
22
+ expiresAtMs: startedAtMs + (readiness.ready ? positiveTtlMs : negativeTtlMs),
23
+ };
24
+ return readiness;
25
+ })
26
+ .finally(() => {
27
+ inFlight = null;
28
+ });
29
+ return inFlight;
30
+ },
31
+ clear() {
32
+ cached = null;
33
+ inFlight = null;
34
+ },
35
+ };
36
+ }
37
+ const sharedCache = createOfferPolicyReadinessCache();
38
+ export function readOfferPolicyV2Readiness(port) {
39
+ return sharedCache.read(port);
40
+ }
41
+ export function resetOfferPolicyReadinessCacheForTests(isTest) {
42
+ if (isTest)
43
+ sharedCache.clear();
44
+ }
45
+ async function loadFailClosed(port) {
46
+ try {
47
+ const parsed = parseReadiness(await port.readOfferPolicyV2Readiness());
48
+ return parsed ?? unavailable("readiness_contract_invalid");
49
+ }
50
+ catch {
51
+ return unavailable("readiness_rpc_unavailable");
52
+ }
53
+ }
54
+ function parseReadiness(value) {
55
+ if (!value || typeof value !== "object" || Array.isArray(value))
56
+ return null;
57
+ const record = value;
58
+ if (record.contractVersion !== OFFER_POLICY_V2_READINESS_CONTRACT ||
59
+ typeof record.ready !== "boolean" ||
60
+ typeof record.checkedAt !== "string" ||
61
+ !Number.isFinite(Date.parse(record.checkedAt)) ||
62
+ !Array.isArray(record.reasons) ||
63
+ !record.reasons.every((reason) => typeof reason === "string"))
64
+ return null;
65
+ return {
66
+ contractVersion: OFFER_POLICY_V2_READINESS_CONTRACT,
67
+ ready: record.ready,
68
+ checkedAt: record.checkedAt,
69
+ reasons: record.reasons,
70
+ };
71
+ }
72
+ function unavailable(reason) {
73
+ return {
74
+ contractVersion: OFFER_POLICY_V2_READINESS_CONTRACT,
75
+ ready: false,
76
+ checkedAt: new Date(0).toISOString(),
77
+ reasons: [reason],
78
+ };
79
+ }
@@ -0,0 +1,25 @@
1
+ import { z } from "./validation.js";
2
+ export declare const offerPolicyVersionSchema: z.ZodEnum<{
3
+ "commerce.offer-policy.v1": "commerce.offer-policy.v1";
4
+ "commerce.offer-policy.v2": "commerce.offer-policy.v2";
5
+ }>;
6
+ export declare const promotionEngineVersionSchema: z.ZodEnum<{
7
+ "promotion-engine.v2": "promotion-engine.v2";
8
+ "promotion-engine.v1": "promotion-engine.v1";
9
+ }>;
10
+ /** Client capability plus an opaque server-signed assignment. Never a version selector. */
11
+ export declare const pricingPolicyRequestSchema: z.ZodObject<{
12
+ capability: z.ZodOptional<z.ZodLiteral<"commerce.offer-policy.v2">>;
13
+ token: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strict>;
15
+ export declare const pricingPolicySnapshotSchema: z.ZodObject<{
16
+ offerPolicyVersion: z.ZodEnum<{
17
+ "commerce.offer-policy.v1": "commerce.offer-policy.v1";
18
+ "commerce.offer-policy.v2": "commerce.offer-policy.v2";
19
+ }>;
20
+ promotionEngineVersion: z.ZodEnum<{
21
+ "promotion-engine.v2": "promotion-engine.v2";
22
+ "promotion-engine.v1": "promotion-engine.v1";
23
+ }>;
24
+ pricingPolicyToken: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strict>;
@@ -0,0 +1,15 @@
1
+ import { z } from "./validation.js";
2
+ import { OFFER_POLICY_V1, OFFER_POLICY_V2, PROMOTION_ENGINE_V1, PROMOTION_ENGINE_V2, OFFER_POLICY_V2_CAPABILITY } from "./contracts/index.js";
3
+ export const offerPolicyVersionSchema = z.enum([OFFER_POLICY_V1, OFFER_POLICY_V2]);
4
+ export const promotionEngineVersionSchema = z.enum([PROMOTION_ENGINE_V1, PROMOTION_ENGINE_V2]);
5
+ /** Client capability plus an opaque server-signed assignment. Never a version selector. */
6
+ export const pricingPolicyRequestSchema = z.object({
7
+ capability: z.literal(OFFER_POLICY_V2_CAPABILITY).optional(),
8
+ token: z.string().trim().min(32).max(2048).optional(),
9
+ }).strict();
10
+ export const pricingPolicySnapshotSchema = z.object({
11
+ offerPolicyVersion: offerPolicyVersionSchema,
12
+ promotionEngineVersion: promotionEngineVersionSchema,
13
+ pricingPolicyToken: z.string().trim().min(32).max(2048).optional(),
14
+ }).strict().refine((value) => (value.offerPolicyVersion === OFFER_POLICY_V1 && value.promotionEngineVersion === PROMOTION_ENGINE_V1) ||
15
+ (value.offerPolicyVersion === OFFER_POLICY_V2 && value.promotionEngineVersion === PROMOTION_ENGINE_V2), { message: "offer policy and promotion engine versions must be paired" });
@@ -0,0 +1,315 @@
1
+ import { z } from "zod";
2
+ import type { CommerceMoney } from "./contracts/money.js";
3
+ export declare function createCommerceOfferPricingSchemas<ScopeV1 extends string, ScopeV2 extends string>({ commerceMoneySchema, catalogProductSlugSchema, scopeV1Schema, scopeV2Schema, minimumProductPayableMinor, minimumProductPayableMessage, }: {
4
+ commerceMoneySchema: z.ZodType<CommerceMoney>;
5
+ catalogProductSlugSchema: z.ZodType<string>;
6
+ scopeV1Schema: z.ZodType<ScopeV1>;
7
+ scopeV2Schema: z.ZodType<ScopeV2>;
8
+ minimumProductPayableMinor: number;
9
+ minimumProductPayableMessage: string;
10
+ }): {
11
+ commerceProductOfferPricingSchema: z.ZodObject<{
12
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
13
+ unitCount: z.ZodNumber;
14
+ oneTime: z.ZodObject<{
15
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
16
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
17
+ }, z.core.$strict>;
18
+ subscriptionInitial: z.ZodObject<{
19
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
20
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
21
+ }, z.core.$strict>;
22
+ subscriptionRecurring: z.ZodObject<{
23
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
24
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
25
+ }, z.core.$strict>;
26
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
27
+ initialDiscountPercent: z.ZodNumber;
28
+ recurringDiscountPercent: z.ZodNumber;
29
+ }, z.core.$strict>;
30
+ commerceOfferPricingV1ResponseSchema: z.ZodObject<{
31
+ contractVersion: z.ZodLiteral<"commerce.offer-pricing.v1">;
32
+ scope: z.ZodType<ScopeV1, unknown, z.core.$ZodTypeInternals<ScopeV1, unknown>>;
33
+ products: z.ZodArray<z.ZodObject<{
34
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
35
+ unitCount: z.ZodNumber;
36
+ oneTime: z.ZodObject<{
37
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
38
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
39
+ }, z.core.$strict>;
40
+ subscriptionInitial: z.ZodObject<{
41
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
42
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
43
+ }, z.core.$strict>;
44
+ subscriptionRecurring: z.ZodObject<{
45
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
46
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
47
+ }, z.core.$strict>;
48
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
49
+ initialDiscountPercent: z.ZodNumber;
50
+ recurringDiscountPercent: z.ZodNumber;
51
+ }, z.core.$strict>>;
52
+ minimum: z.ZodObject<{
53
+ oneTime: z.ZodObject<{
54
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
55
+ unitCount: z.ZodNumber;
56
+ oneTime: z.ZodObject<{
57
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
58
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
59
+ }, z.core.$strict>;
60
+ subscriptionInitial: z.ZodObject<{
61
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
62
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
63
+ }, z.core.$strict>;
64
+ subscriptionRecurring: z.ZodObject<{
65
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
66
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
67
+ }, z.core.$strict>;
68
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
69
+ initialDiscountPercent: z.ZodNumber;
70
+ recurringDiscountPercent: z.ZodNumber;
71
+ }, z.core.$strict>;
72
+ subscription: z.ZodObject<{
73
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
74
+ unitCount: z.ZodNumber;
75
+ oneTime: z.ZodObject<{
76
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
77
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
78
+ }, z.core.$strict>;
79
+ subscriptionInitial: z.ZodObject<{
80
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
81
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
82
+ }, z.core.$strict>;
83
+ subscriptionRecurring: z.ZodObject<{
84
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
85
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
86
+ }, z.core.$strict>;
87
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
88
+ initialDiscountPercent: z.ZodNumber;
89
+ recurringDiscountPercent: z.ZodNumber;
90
+ }, z.core.$strict>;
91
+ }, z.core.$strict>;
92
+ }, z.core.$strict>;
93
+ commerceOfferPricingV2ResponseSchema: z.ZodObject<{
94
+ contractVersion: z.ZodLiteral<"commerce.offer-pricing.v2">;
95
+ scope: z.ZodType<ScopeV2, unknown, z.core.$ZodTypeInternals<ScopeV2, unknown>>;
96
+ pricingPolicy: z.ZodObject<{
97
+ offerPolicyVersion: z.ZodEnum<{
98
+ "commerce.offer-policy.v1": "commerce.offer-policy.v1";
99
+ "commerce.offer-policy.v2": "commerce.offer-policy.v2";
100
+ }>;
101
+ promotionEngineVersion: z.ZodEnum<{
102
+ "promotion-engine.v2": "promotion-engine.v2";
103
+ "promotion-engine.v1": "promotion-engine.v1";
104
+ }>;
105
+ pricingPolicyToken: z.ZodOptional<z.ZodString>;
106
+ }, z.core.$strict>;
107
+ products: z.ZodArray<z.ZodObject<{
108
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
109
+ unitCount: z.ZodNumber;
110
+ oneTime: z.ZodObject<{
111
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
112
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
113
+ }, z.core.$strict>;
114
+ subscriptionInitial: z.ZodObject<{
115
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
116
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
117
+ }, z.core.$strict>;
118
+ subscriptionRecurring: z.ZodObject<{
119
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
120
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
121
+ }, z.core.$strict>;
122
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
123
+ initialDiscountPercent: z.ZodNumber;
124
+ recurringDiscountPercent: z.ZodNumber;
125
+ }, z.core.$strict>>;
126
+ minimum: z.ZodObject<{
127
+ oneTime: z.ZodObject<{
128
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
129
+ unitCount: z.ZodNumber;
130
+ oneTime: z.ZodObject<{
131
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
132
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
133
+ }, z.core.$strict>;
134
+ subscriptionInitial: z.ZodObject<{
135
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
136
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
137
+ }, z.core.$strict>;
138
+ subscriptionRecurring: z.ZodObject<{
139
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
140
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
141
+ }, z.core.$strict>;
142
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
143
+ initialDiscountPercent: z.ZodNumber;
144
+ recurringDiscountPercent: z.ZodNumber;
145
+ }, z.core.$strict>;
146
+ subscription: z.ZodObject<{
147
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
148
+ unitCount: z.ZodNumber;
149
+ oneTime: z.ZodObject<{
150
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
151
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
152
+ }, z.core.$strict>;
153
+ subscriptionInitial: z.ZodObject<{
154
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
155
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
156
+ }, z.core.$strict>;
157
+ subscriptionRecurring: z.ZodObject<{
158
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
159
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
160
+ }, z.core.$strict>;
161
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
162
+ initialDiscountPercent: z.ZodNumber;
163
+ recurringDiscountPercent: z.ZodNumber;
164
+ }, z.core.$strict>;
165
+ }, z.core.$strict>;
166
+ shipping: z.ZodObject<{
167
+ gross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
168
+ discountGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
169
+ payable: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
170
+ }, z.core.$strict>;
171
+ minimumProductPayable: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
172
+ }, z.core.$strict>;
173
+ commerceOfferPricingResponseSchema: z.ZodUnion<readonly [z.ZodObject<{
174
+ contractVersion: z.ZodLiteral<"commerce.offer-pricing.v1">;
175
+ scope: z.ZodType<ScopeV1, unknown, z.core.$ZodTypeInternals<ScopeV1, unknown>>;
176
+ products: z.ZodArray<z.ZodObject<{
177
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
178
+ unitCount: z.ZodNumber;
179
+ oneTime: z.ZodObject<{
180
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
181
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
182
+ }, z.core.$strict>;
183
+ subscriptionInitial: z.ZodObject<{
184
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
185
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
186
+ }, z.core.$strict>;
187
+ subscriptionRecurring: z.ZodObject<{
188
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
189
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
190
+ }, z.core.$strict>;
191
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
192
+ initialDiscountPercent: z.ZodNumber;
193
+ recurringDiscountPercent: z.ZodNumber;
194
+ }, z.core.$strict>>;
195
+ minimum: z.ZodObject<{
196
+ oneTime: z.ZodObject<{
197
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
198
+ unitCount: z.ZodNumber;
199
+ oneTime: z.ZodObject<{
200
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
201
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
202
+ }, z.core.$strict>;
203
+ subscriptionInitial: z.ZodObject<{
204
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
205
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
206
+ }, z.core.$strict>;
207
+ subscriptionRecurring: z.ZodObject<{
208
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
209
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
210
+ }, z.core.$strict>;
211
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
212
+ initialDiscountPercent: z.ZodNumber;
213
+ recurringDiscountPercent: z.ZodNumber;
214
+ }, z.core.$strict>;
215
+ subscription: z.ZodObject<{
216
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
217
+ unitCount: z.ZodNumber;
218
+ oneTime: z.ZodObject<{
219
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
220
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
221
+ }, z.core.$strict>;
222
+ subscriptionInitial: z.ZodObject<{
223
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
224
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
225
+ }, z.core.$strict>;
226
+ subscriptionRecurring: z.ZodObject<{
227
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
228
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
229
+ }, z.core.$strict>;
230
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
231
+ initialDiscountPercent: z.ZodNumber;
232
+ recurringDiscountPercent: z.ZodNumber;
233
+ }, z.core.$strict>;
234
+ }, z.core.$strict>;
235
+ }, z.core.$strict>, z.ZodObject<{
236
+ contractVersion: z.ZodLiteral<"commerce.offer-pricing.v2">;
237
+ scope: z.ZodType<ScopeV2, unknown, z.core.$ZodTypeInternals<ScopeV2, unknown>>;
238
+ pricingPolicy: z.ZodObject<{
239
+ offerPolicyVersion: z.ZodEnum<{
240
+ "commerce.offer-policy.v1": "commerce.offer-policy.v1";
241
+ "commerce.offer-policy.v2": "commerce.offer-policy.v2";
242
+ }>;
243
+ promotionEngineVersion: z.ZodEnum<{
244
+ "promotion-engine.v2": "promotion-engine.v2";
245
+ "promotion-engine.v1": "promotion-engine.v1";
246
+ }>;
247
+ pricingPolicyToken: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strict>;
249
+ products: z.ZodArray<z.ZodObject<{
250
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
251
+ unitCount: z.ZodNumber;
252
+ oneTime: z.ZodObject<{
253
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
254
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
255
+ }, z.core.$strict>;
256
+ subscriptionInitial: z.ZodObject<{
257
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
258
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
259
+ }, z.core.$strict>;
260
+ subscriptionRecurring: z.ZodObject<{
261
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
262
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
263
+ }, z.core.$strict>;
264
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
265
+ initialDiscountPercent: z.ZodNumber;
266
+ recurringDiscountPercent: z.ZodNumber;
267
+ }, z.core.$strict>>;
268
+ minimum: z.ZodObject<{
269
+ oneTime: z.ZodObject<{
270
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
271
+ unitCount: z.ZodNumber;
272
+ oneTime: z.ZodObject<{
273
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
274
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
275
+ }, z.core.$strict>;
276
+ subscriptionInitial: z.ZodObject<{
277
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
278
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
279
+ }, z.core.$strict>;
280
+ subscriptionRecurring: z.ZodObject<{
281
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
282
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
283
+ }, z.core.$strict>;
284
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
285
+ initialDiscountPercent: z.ZodNumber;
286
+ recurringDiscountPercent: z.ZodNumber;
287
+ }, z.core.$strict>;
288
+ subscription: z.ZodObject<{
289
+ productSlug: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
290
+ unitCount: z.ZodNumber;
291
+ oneTime: z.ZodObject<{
292
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
293
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
294
+ }, z.core.$strict>;
295
+ subscriptionInitial: z.ZodObject<{
296
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
297
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
298
+ }, z.core.$strict>;
299
+ subscriptionRecurring: z.ZodObject<{
300
+ packageGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
301
+ unitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
302
+ }, z.core.$strict>;
303
+ catalogAnchorUnitGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
304
+ initialDiscountPercent: z.ZodNumber;
305
+ recurringDiscountPercent: z.ZodNumber;
306
+ }, z.core.$strict>;
307
+ }, z.core.$strict>;
308
+ shipping: z.ZodObject<{
309
+ gross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
310
+ discountGross: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
311
+ payable: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
312
+ }, z.core.$strict>;
313
+ minimumProductPayable: z.ZodType<CommerceMoney, unknown, z.core.$ZodTypeInternals<CommerceMoney, unknown>>;
314
+ }, z.core.$strict>]>;
315
+ };
@@ -0,0 +1,65 @@
1
+ import { z } from "zod";
2
+ import { COMMERCE_OFFER_PRICING_CONTRACT_VERSION, COMMERCE_OFFER_PRICING_V2_CONTRACT_VERSION } from "./contracts/offer.js";
3
+ import { pricingPolicySnapshotSchema } from "./offerPolicySchemas.js";
4
+ export function createCommerceOfferPricingSchemas({ commerceMoneySchema, catalogProductSlugSchema, scopeV1Schema, scopeV2Schema, minimumProductPayableMinor, minimumProductPayableMessage, }) {
5
+ const offerPriceSchema = z
6
+ .object({
7
+ packageGross: commerceMoneySchema,
8
+ unitGross: commerceMoneySchema,
9
+ })
10
+ .strict();
11
+ const commerceProductOfferPricingSchema = z
12
+ .object({
13
+ productSlug: catalogProductSlugSchema,
14
+ unitCount: z.number().int().positive(),
15
+ oneTime: offerPriceSchema,
16
+ subscriptionInitial: offerPriceSchema,
17
+ subscriptionRecurring: offerPriceSchema,
18
+ catalogAnchorUnitGross: commerceMoneySchema,
19
+ initialDiscountPercent: z.number().int().min(0).max(100),
20
+ recurringDiscountPercent: z.number().int().min(0).max(100),
21
+ })
22
+ .strict();
23
+ const commerceOfferPricingV1ResponseSchema = z
24
+ .object({
25
+ contractVersion: z.literal(COMMERCE_OFFER_PRICING_CONTRACT_VERSION),
26
+ scope: scopeV1Schema,
27
+ products: z.array(commerceProductOfferPricingSchema).min(1),
28
+ minimum: z
29
+ .object({
30
+ oneTime: commerceProductOfferPricingSchema,
31
+ subscription: commerceProductOfferPricingSchema,
32
+ })
33
+ .strict(),
34
+ })
35
+ .strict();
36
+ const commerceOfferPricingV2ResponseSchema = z
37
+ .object({
38
+ contractVersion: z.literal(COMMERCE_OFFER_PRICING_V2_CONTRACT_VERSION),
39
+ scope: scopeV2Schema,
40
+ pricingPolicy: pricingPolicySnapshotSchema,
41
+ products: z.array(commerceProductOfferPricingSchema).min(1),
42
+ minimum: z.object({
43
+ oneTime: commerceProductOfferPricingSchema,
44
+ subscription: commerceProductOfferPricingSchema,
45
+ }).strict(),
46
+ shipping: z.object({
47
+ gross: commerceMoneySchema,
48
+ discountGross: commerceMoneySchema,
49
+ payable: commerceMoneySchema,
50
+ }).strict(),
51
+ minimumProductPayable: commerceMoneySchema,
52
+ })
53
+ .strict()
54
+ .refine((value) => value.pricingPolicy.offerPolicyVersion === "commerce.offer-policy.v2" &&
55
+ value.pricingPolicy.promotionEngineVersion === "promotion-engine.v2", { message: "offer-pricing v2 requires the paired v2 policy", path: ["pricingPolicy"] })
56
+ .refine((value) => value.minimumProductPayable.amountMinor === minimumProductPayableMinor, { message: minimumProductPayableMessage, path: ["minimumProductPayable"] })
57
+ .refine((value) => value.shipping.payable.amountMinor ===
58
+ value.shipping.gross.amountMinor - value.shipping.discountGross.amountMinor, { message: "offer-pricing v2 shipping arithmetic is inconsistent", path: ["shipping"] });
59
+ const commerceOfferPricingResponseSchema = z.union([
60
+ commerceOfferPricingV1ResponseSchema,
61
+ commerceOfferPricingV2ResponseSchema,
62
+ ]);
63
+ return { commerceProductOfferPricingSchema, commerceOfferPricingV1ResponseSchema,
64
+ commerceOfferPricingV2ResponseSchema, commerceOfferPricingResponseSchema };
65
+ }