@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,41 @@
1
+ import type { BundleAllocationFailureCode } from "@openlup/core/pricing";
2
+ /**
3
+ * Bundle write rules — the named, enforced invariants of the agent-operable
4
+ * bundle write path. These codes are the single vocabulary shared by the request
5
+ * contracts, the pure rule predicates (`bundleRules.ts`), managed write routines
6
+ * and the over-the-wire error taxonomy. Managed routines re-derive state rules;
7
+ * native actor-kind enforcement relies on the handler, not an independent
8
+ * database gate.
9
+ *
10
+ * The catalog rules use this same shape; the lifecycle subset is expressed
11
+ * through the host lifecycle kit, and the codes stay here as
12
+ * this domain's registry.
13
+ */
14
+ export declare const BUNDLE_RULE_CODES: readonly ["DRAFT_ONLY_FOR_MACHINE", "MIN_COMPONENTS", "ADDON_ONLY_COMPOSITION", "DUPLICATE_COMPONENT", "CODE_TAKEN", "COMPONENT_NOT_FOUND", "COMPONENT_NOT_SELLABLE", "COMPONENT_CURRENCY_MISMATCH", "TARGET_ABOVE_COMPONENT_SUM", "TARGET_BELOW_FLOOR", "PRICE_REQUIRED_TO_SELL", "COMPOSITION_REQUIRED_TO_SELL", "APPEND_ONLY_PRICE", "NO_HARD_DELETE", "RESTORE_REQUIRES_ARCHIVED", "DEACTIVATE_REQUIRES_ACTIVE", "FULFILLMENT_MODE_UNSUPPORTED", "CONSTRAINT_VALIDATION_FAILED", "CLONE_SOURCE_NOT_FOUND"];
15
+ export type BundleRuleCode = (typeof BUNDLE_RULE_CODES)[number];
16
+ /**
17
+ * The two target-price codes are NOT re-derived here — they are the kernel
18
+ * allocator's own failure vocabulary, projected onto this domain's registry.
19
+ *
20
+ * Declared as an exhaustive `Record` over `BundleAllocationFailureCode` on
21
+ * purpose: when `@openlup/core/pricing` learns a new failure code, this object
22
+ * stops compiling until the domain decides which rule it is. `REFERENCE_TOTAL_ZERO`
23
+ * means the composition weighed nothing, which is the same condition
24
+ * `MIN_COMPONENTS` names from the request side.
25
+ */
26
+ export declare const BUNDLE_ALLOCATION_RULE_CODE: Record<BundleAllocationFailureCode, BundleRuleCode>;
27
+ /**
28
+ * Which rules are decidable from the request alone (pure, pre-flight) and which
29
+ * are state-dependent and authoritatively enforced by the write routine. This
30
+ * documents intent and keeps the handler honest about what it can decide before
31
+ * the write. `CONSTRAINT_VALIDATION_FAILED` is `port`: it is decided by the
32
+ * injected `CompositionRulesPort`, which is neither the request nor the database.
33
+ */
34
+ export declare const BUNDLE_RULE_ENFORCEMENT: Record<BundleRuleCode, "request" | "port" | "rpc">;
35
+ export type BundleActorKind = "human" | "machine";
36
+ export type BundleWriteOperation = "create_draft" | "update_draft" | "set_composition" | "set_target_price" | "archive" | "restore" | "clone_draft" | "activate" | "deactivate";
37
+ /** The domain's rule result, projected from the generic kit `RuleResult`. */
38
+ export type BundleRuleResult = {
39
+ ok: boolean;
40
+ violations: BundleRuleCode[];
41
+ };
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Bundle write rules — the named, enforced invariants of the agent-operable
3
+ * bundle write path. These codes are the single vocabulary shared by the request
4
+ * contracts, the pure rule predicates (`bundleRules.ts`), managed write routines
5
+ * and the over-the-wire error taxonomy. Managed routines re-derive state rules;
6
+ * native actor-kind enforcement relies on the handler, not an independent
7
+ * database gate.
8
+ *
9
+ * The catalog rules use this same shape; the lifecycle subset is expressed
10
+ * through the host lifecycle kit, and the codes stay here as
11
+ * this domain's registry.
12
+ */
13
+ export const BUNDLE_RULE_CODES = [
14
+ // Machine (agent) actors compose, price and archive drafts, but may NOT
15
+ // activate or deactivate. Enforced by the handler (allowedActorKinds); the
16
+ // managed activate/deactivate routines also re-derive and RAISE it, while the
17
+ // native routines rely on the handler gate.
18
+ "DRAFT_ONLY_FOR_MACHINE",
19
+ // A bundle with no components is not a bill of materials. Request-decidable on
20
+ // the whole-set composition replace.
21
+ "MIN_COMPONENTS",
22
+ // Every component being an add-on leaves nothing that is always in the box.
23
+ // At least one non-addon component is required. Request-decidable.
24
+ "ADDON_ONLY_COMPOSITION",
25
+ // One row per unit per bundle: multiplicity is the quantity, never a repeated
26
+ // component. Request-decidable on the whole-set replace.
27
+ "DUPLICATE_COMPONENT",
28
+ // Creating a bundle whose code is already used is rejected (unique code).
29
+ "CODE_TAKEN",
30
+ // A composition entry naming a unit that does not exist is rejected.
31
+ "COMPONENT_NOT_FOUND",
32
+ // A component must itself be sellable: active AND sellable on its own. A bundle
33
+ // must not become the only way an unsellable unit reaches a customer.
34
+ "COMPONENT_NOT_SELLABLE",
35
+ // Every component must be priced in the currency of the bundle's price list;
36
+ // a mixed-currency bill of materials has no single reference total.
37
+ "COMPONENT_CURRENCY_MISMATCH",
38
+ // A bundle is never priced above the sum of its parts. Hard refusal, not a
39
+ // warning: the discount framing is the product, and the kernel allocator
40
+ // returns the same decision as one comparison.
41
+ "TARGET_ABOVE_COMPONENT_SUM",
42
+ // The target cannot cover every component's minimum payable amount.
43
+ "TARGET_BELOW_FLOOR",
44
+ // Activation requires an active target price on the bundle.
45
+ "PRICE_REQUIRED_TO_SELL",
46
+ // Activation requires a non-empty composition.
47
+ "COMPOSITION_REQUIRED_TO_SELL",
48
+ // Target-price changes INSERT a new price row and deactivate the old one; an
49
+ // existing row is never mutated in place.
50
+ "APPEND_ONLY_PRICE",
51
+ // A bundle referenced by an order or a subscription is never hard-deleted;
52
+ // removal is an archive (status flip).
53
+ "NO_HARD_DELETE",
54
+ // Restore is the inverse of archive: it applies only to an ARCHIVED bundle.
55
+ "RESTORE_REQUIRES_ARCHIVED",
56
+ // Deactivate (unpublish) applies only to a LIVE bundle.
57
+ "DEACTIVATE_REQUIRES_ACTIVE",
58
+ // Only the exploded fulfillment mode has a runtime. The stored column admits
59
+ // the pre-packed mode so it never has to be widened; the refusal lives here.
60
+ "FULFILLMENT_MODE_UNSUPPORTED",
61
+ // A non-empty composition constraint is validated by the injected
62
+ // CompositionRulesPort; its refusal surfaces under this code.
63
+ "CONSTRAINT_VALIDATION_FAILED",
64
+ // Clone reads its source before replaying a fresh draft; a missing source is
65
+ // rejected before the replay.
66
+ "CLONE_SOURCE_NOT_FOUND",
67
+ ];
68
+ /**
69
+ * The two target-price codes are NOT re-derived here — they are the kernel
70
+ * allocator's own failure vocabulary, projected onto this domain's registry.
71
+ *
72
+ * Declared as an exhaustive `Record` over `BundleAllocationFailureCode` on
73
+ * purpose: when `@openlup/core/pricing` learns a new failure code, this object
74
+ * stops compiling until the domain decides which rule it is. `REFERENCE_TOTAL_ZERO`
75
+ * means the composition weighed nothing, which is the same condition
76
+ * `MIN_COMPONENTS` names from the request side.
77
+ */
78
+ export const BUNDLE_ALLOCATION_RULE_CODE = {
79
+ REFERENCE_TOTAL_ZERO: "MIN_COMPONENTS",
80
+ TARGET_ABOVE_COMPONENT_SUM: "TARGET_ABOVE_COMPONENT_SUM",
81
+ TARGET_BELOW_FLOOR: "TARGET_BELOW_FLOOR",
82
+ };
83
+ /**
84
+ * Which rules are decidable from the request alone (pure, pre-flight) and which
85
+ * are state-dependent and authoritatively enforced by the write routine. This
86
+ * documents intent and keeps the handler honest about what it can decide before
87
+ * the write. `CONSTRAINT_VALIDATION_FAILED` is `port`: it is decided by the
88
+ * injected `CompositionRulesPort`, which is neither the request nor the database.
89
+ */
90
+ export const BUNDLE_RULE_ENFORCEMENT = {
91
+ DRAFT_ONLY_FOR_MACHINE: "request",
92
+ MIN_COMPONENTS: "request",
93
+ ADDON_ONLY_COMPOSITION: "request",
94
+ DUPLICATE_COMPONENT: "request",
95
+ FULFILLMENT_MODE_UNSUPPORTED: "request",
96
+ CONSTRAINT_VALIDATION_FAILED: "port",
97
+ CODE_TAKEN: "rpc",
98
+ COMPONENT_NOT_FOUND: "rpc",
99
+ COMPONENT_NOT_SELLABLE: "rpc",
100
+ COMPONENT_CURRENCY_MISMATCH: "rpc",
101
+ TARGET_ABOVE_COMPONENT_SUM: "rpc",
102
+ TARGET_BELOW_FLOOR: "rpc",
103
+ PRICE_REQUIRED_TO_SELL: "rpc",
104
+ COMPOSITION_REQUIRED_TO_SELL: "rpc",
105
+ APPEND_ONLY_PRICE: "rpc",
106
+ NO_HARD_DELETE: "rpc",
107
+ RESTORE_REQUIRES_ARCHIVED: "rpc",
108
+ DEACTIVATE_REQUIRES_ACTIVE: "rpc",
109
+ CLONE_SOURCE_NOT_FOUND: "rpc",
110
+ };
@@ -0,0 +1,69 @@
1
+ import type { BundleComponentInput } from "@openlup/core/pricing";
2
+ import type { CompositionConstraint, CompositionRulesPort } from "@openlup/core/bundle";
3
+ import type { BundleRuleBindings } from "./bundleBindings.js";
4
+ import { type BundleActorKind, type BundleRuleResult } from "./bundleRuleCodes.js";
5
+ /**
6
+ * Pure, request-checkable bundle write rules.
7
+ *
8
+ * Only what is decidable from the request alone lives here. The state-dependent
9
+ * rules (code uniqueness, component existence/sellability/currency, the target
10
+ * price against real component prices, the activation preconditions, append-only
11
+ * pricing, archive-not-delete) are re-derived by the managed write routines.
12
+ * This layer fast-fails request-checkable violations without replacing those
13
+ * state checks. Actor-kind enforcement is separate: managed publication routines
14
+ * independently check it, while native publication relies on the handler gate.
15
+ */
16
+ /** The composition shape the request-layer rules can reason about. */
17
+ export interface BundleCompositionEntry {
18
+ readonly sku: string;
19
+ readonly quantity: number;
20
+ readonly isAddon: boolean;
21
+ }
22
+ /** The only fulfillment mode with a runtime. The column admits more; this does not. */
23
+ export declare const SUPPORTED_BUNDLE_FULFILLMENT_MODES: readonly ["virtual"];
24
+ export type SupportedBundleFulfillmentMode = (typeof SUPPORTED_BUNDLE_FULFILLMENT_MODES)[number];
25
+ /**
26
+ * The lifecycle/actor gate every operation passes. Machine actors are confined to
27
+ * drafts: they may compose, price, archive, restore and clone, but neither
28
+ * activate nor deactivate.
29
+ */
30
+ export declare function createBundleWriteRules({ assertActivateNotMachineActor }: Pick<BundleRuleBindings, "assertActivateNotMachineActor">): {
31
+ evaluateBundleWriteRules: (input: {
32
+ operation: string;
33
+ actorKind: BundleActorKind;
34
+ }) => BundleRuleResult;
35
+ };
36
+ /**
37
+ * Whole-set composition rules, decidable from the replacement set alone: it must
38
+ * carry at least one entry, at least one entry that is not an add-on, and no unit
39
+ * twice (multiplicity is the quantity, never a repeated row).
40
+ */
41
+ export declare function evaluateBundleComposition(components: readonly BundleCompositionEntry[]): BundleRuleResult;
42
+ /** The runtime refusal of every fulfillment mode the stored column admits but no code honours. */
43
+ export declare function evaluateBundleFulfillmentMode(mode: string): BundleRuleResult;
44
+ /**
45
+ * Project the kernel allocator's decision onto this domain's rule vocabulary.
46
+ *
47
+ * The allocator (`@openlup/core/pricing`) owns the arithmetic and the two
48
+ * refusals a target price can earn; this maps its failure code through the
49
+ * exhaustive `BUNDLE_ALLOCATION_RULE_CODE` table so the codes cannot drift apart.
50
+ * It is pure: the caller supplies the component reference prices it already holds.
51
+ * The authority for a committed write remains the write routine, which holds the
52
+ * live prices.
53
+ */
54
+ export declare function evaluateBundleTargetPrice(input: {
55
+ components: readonly BundleComponentInput[];
56
+ targetPriceMinor: number;
57
+ minimumUnitPayableMinor?: number;
58
+ }): BundleRuleResult;
59
+ /** An empty envelope means "unconstrained"; there is nothing for the port to decide. */
60
+ export declare function isEmptyCompositionConstraint(constraint: CompositionConstraint | null | undefined): boolean;
61
+ /**
62
+ * Delegate a non-empty composition constraint to the injected rules port. The
63
+ * platform stores the envelope and never interprets it, so this domain does not
64
+ * either: it asks the adopter's port and reports the refusal under one code.
65
+ */
66
+ export declare function evaluateBundleCompositionConstraint(port: CompositionRulesPort | undefined, input: {
67
+ readonly components: readonly BundleCompositionEntry[];
68
+ readonly constraint: CompositionConstraint | null | undefined;
69
+ }): Promise<BundleRuleResult>;
@@ -0,0 +1,102 @@
1
+ import { allocateBundleTargetPrice } from "@openlup/core/pricing";
2
+ import { BUNDLE_ALLOCATION_RULE_CODE, } from "./bundleRuleCodes.js";
3
+ /** The only fulfillment mode with a runtime. The column admits more; this does not. */
4
+ export const SUPPORTED_BUNDLE_FULFILLMENT_MODES = ["virtual"];
5
+ function isSupportedFulfillmentMode(mode) {
6
+ return SUPPORTED_BUNDLE_FULFILLMENT_MODES.includes(mode);
7
+ }
8
+ /**
9
+ * The lifecycle/actor gate every operation passes. Machine actors are confined to
10
+ * drafts: they may compose, price, archive, restore and clone, but neither
11
+ * activate nor deactivate.
12
+ */
13
+ export function createBundleWriteRules({ assertActivateNotMachineActor }) {
14
+ function evaluateBundleWriteRules(input) {
15
+ const violations = [];
16
+ const activateViolation = assertActivateNotMachineActor(input);
17
+ if (activateViolation)
18
+ violations.push(activateViolation);
19
+ // `assertActivateNotMachineActor` only knows the publish direction it was written
20
+ // for. Unpublish is the same class of transition and carries the same code.
21
+ if (input.operation === "deactivate" && input.actorKind === "machine") {
22
+ violations.push("DRAFT_ONLY_FOR_MACHINE");
23
+ }
24
+ return { ok: violations.length === 0, violations };
25
+ }
26
+ return { evaluateBundleWriteRules };
27
+ }
28
+ /**
29
+ * Whole-set composition rules, decidable from the replacement set alone: it must
30
+ * carry at least one entry, at least one entry that is not an add-on, and no unit
31
+ * twice (multiplicity is the quantity, never a repeated row).
32
+ */
33
+ export function evaluateBundleComposition(components) {
34
+ const violations = [];
35
+ if (components.length === 0)
36
+ violations.push("MIN_COMPONENTS");
37
+ else if (components.every((component) => component.isAddon))
38
+ violations.push("ADDON_ONLY_COMPOSITION");
39
+ const seen = new Set();
40
+ for (const component of components) {
41
+ if (seen.has(component.sku)) {
42
+ violations.push("DUPLICATE_COMPONENT");
43
+ break;
44
+ }
45
+ seen.add(component.sku);
46
+ }
47
+ return { ok: violations.length === 0, violations };
48
+ }
49
+ /** The runtime refusal of every fulfillment mode the stored column admits but no code honours. */
50
+ export function evaluateBundleFulfillmentMode(mode) {
51
+ return isSupportedFulfillmentMode(mode)
52
+ ? { ok: true, violations: [] }
53
+ : { ok: false, violations: ["FULFILLMENT_MODE_UNSUPPORTED"] };
54
+ }
55
+ /**
56
+ * Project the kernel allocator's decision onto this domain's rule vocabulary.
57
+ *
58
+ * The allocator (`@openlup/core/pricing`) owns the arithmetic and the two
59
+ * refusals a target price can earn; this maps its failure code through the
60
+ * exhaustive `BUNDLE_ALLOCATION_RULE_CODE` table so the codes cannot drift apart.
61
+ * It is pure: the caller supplies the component reference prices it already holds.
62
+ * The authority for a committed write remains the write routine, which holds the
63
+ * live prices.
64
+ */
65
+ export function evaluateBundleTargetPrice(input) {
66
+ const outcome = allocateBundleTargetPrice({
67
+ components: input.components,
68
+ targetPriceMinor: input.targetPriceMinor,
69
+ ...(input.minimumUnitPayableMinor === undefined
70
+ ? {}
71
+ : { minimumUnitPayableMinor: input.minimumUnitPayableMinor }),
72
+ });
73
+ // Narrowed by presence rather than by the `ok` literal: the app compiler runs
74
+ // without strictNullChecks, where a boolean-literal discriminant does not narrow.
75
+ if (!("code" in outcome))
76
+ return { ok: true, violations: [] };
77
+ return { ok: false, violations: [BUNDLE_ALLOCATION_RULE_CODE[outcome.code]] };
78
+ }
79
+ /** An empty envelope means "unconstrained"; there is nothing for the port to decide. */
80
+ export function isEmptyCompositionConstraint(constraint) {
81
+ return !constraint || constraint.kind.trim() === "";
82
+ }
83
+ /**
84
+ * Delegate a non-empty composition constraint to the injected rules port. The
85
+ * platform stores the envelope and never interprets it, so this domain does not
86
+ * either: it asks the adopter's port and reports the refusal under one code.
87
+ */
88
+ export async function evaluateBundleCompositionConstraint(port, input) {
89
+ if (isEmptyCompositionConstraint(input.constraint) || !port)
90
+ return { ok: true, violations: [] };
91
+ const constraint = input.constraint;
92
+ const outcome = await port.validateComposition({
93
+ coreLines: input.components
94
+ .filter((component) => !component.isAddon)
95
+ .map((component) => ({ variantId: component.sku, qty: component.quantity, isAddon: false })),
96
+ addonLines: input.components
97
+ .filter((component) => component.isAddon)
98
+ .map((component) => ({ variantId: component.sku, qty: component.quantity, isAddon: true })),
99
+ constraint,
100
+ });
101
+ return outcome.ok ? { ok: true, violations: [] } : { ok: false, violations: ["CONSTRAINT_VALIDATION_FAILED"] };
102
+ }
@@ -0,0 +1,4 @@
1
+ import { type CatalogDraftStorePort } from "./draftPorts.js";
2
+ import type { PgQueryExecutor } from "../data/index.js";
3
+ /** Dark owner-only storage. Composition must verify the operator before use. */
4
+ export declare function createPostgresCatalogDraftStore(client: PgQueryExecutor): CatalogDraftStorePort;
@@ -0,0 +1,63 @@
1
+ import { catalogDraftApplyResultSchema, catalogDraftGetQuerySchema, catalogDraftListQuerySchema, catalogDraftPageSchema, catalogDraftRecordSchema, } from "./draftSchemas.js";
2
+ import { CatalogDraftStoreError } from "./draftPorts.js";
3
+ /** Dark owner-only storage. Composition must verify the operator before use. */
4
+ export function createPostgresCatalogDraftStore(client) {
5
+ async function call(sql, values) {
6
+ try {
7
+ const { rows } = await client.query(sql, values);
8
+ if (rows.length !== 1 || !("result" in rows[0])) {
9
+ throw new CatalogDraftStoreError({ outcome: "dependency_unavailable", reason: "invalid_store_response" });
10
+ }
11
+ return rows[0].result;
12
+ }
13
+ catch (error) {
14
+ if (error instanceof CatalogDraftStoreError)
15
+ throw error;
16
+ throw new CatalogDraftStoreError(refusal(error));
17
+ }
18
+ }
19
+ return {
20
+ async apply(request) {
21
+ try {
22
+ const result = await call("SELECT public.catalog_draft_apply($1::text, $2::text, $3::text) AS result", [request.canonicalCommand, request.fingerprint, request.actorId]);
23
+ const parsed = catalogDraftApplyResultSchema.safeParse(result);
24
+ if (!parsed.success)
25
+ return { outcome: "dependency_unavailable", reason: "invalid_store_response" };
26
+ return parsed.data;
27
+ }
28
+ catch (error) {
29
+ return error instanceof CatalogDraftStoreError ? error.refusal : refusal(error);
30
+ }
31
+ },
32
+ async get(query) {
33
+ const input = catalogDraftGetQuerySchema.safeParse(query);
34
+ if (!input.success)
35
+ throw new CatalogDraftStoreError({ outcome: "validation_issue", reason: "invalid_get_query" });
36
+ const result = await call("SELECT public.catalog_draft_get($1::uuid, $2::integer, $3::text) AS result", [input.data.draftId, input.data.revision ?? null, input.data.commandKey ?? null]);
37
+ const parsed = catalogDraftRecordSchema.nullable().safeParse(result);
38
+ if (!parsed.success)
39
+ throw new CatalogDraftStoreError({ outcome: "dependency_unavailable", reason: "invalid_store_response" });
40
+ return parsed.data;
41
+ },
42
+ async list(query) {
43
+ const input = catalogDraftListQuerySchema.safeParse(query);
44
+ if (!input.success)
45
+ throw new CatalogDraftStoreError({ outcome: "validation_issue", reason: "invalid_list_query" });
46
+ const result = await call("SELECT public.catalog_draft_list($1::uuid, $2::integer) AS result", [input.data.afterDraftId ?? null, input.data.limit]);
47
+ const parsed = catalogDraftPageSchema.safeParse(result);
48
+ if (!parsed.success)
49
+ throw new CatalogDraftStoreError({ outcome: "dependency_unavailable", reason: "invalid_store_response" });
50
+ return parsed.data;
51
+ },
52
+ };
53
+ }
54
+ function refusal(error) {
55
+ const code = error && typeof error === "object" && "code" in error ? error.code : null;
56
+ if (code === "42501")
57
+ return { outcome: "unauthorized", reason: "operator_required" };
58
+ if (code === "22023")
59
+ return { outcome: "validation_issue", reason: "invalid_store_request" };
60
+ if (code === "23505")
61
+ return { outcome: "conflict", reason: "identity_reserved" };
62
+ return { outcome: "dependency_unavailable", reason: "store_unavailable" };
63
+ }
@@ -0,0 +1,7 @@
1
+ import type { PublicCatalogSkuEnvelopeReadPort } from "./readPorts.js";
2
+ import type { PgQueryExecutor } from "../data/index.js";
3
+ /**
4
+ * Portable W2a envelope reader. It reads only product/SKU/revision references
5
+ * and neutral identifiers; application document content never crosses this seam.
6
+ */
7
+ export declare function createPostgresCatalogSkuEnvelopeReadPort(executor: PgQueryExecutor): PublicCatalogSkuEnvelopeReadPort;
@@ -0,0 +1,142 @@
1
+ import { CatalogSkuAuthorityError, catalogSkuEnvelopeSelectorSchema, } from "./foundationSchemas.js";
2
+ import { parseCatalogActiveSkuSelection } from "./activeSkuSelection.js";
3
+ import { mapPostgresCatalogSkuEnvelope, readPostgresCatalogSkuIdentifiers, requirePostgresCatalogSkuEnvelopeRow, } from "./catalogSkuEnvelopeMapper.js";
4
+ const ENVELOPE_COLUMNS_SQL = `
5
+ product.id AS product_id,
6
+ product.slug AS product_slug,
7
+ product.primary_sku_id,
8
+ product.current_document_revision_id,
9
+ sku.id AS sku_id,
10
+ sku.product_id AS sku_product_id,
11
+ sku.sku AS sku_code,
12
+ sku.net_weight_g AS net_content_unscaled,
13
+ sku.status AS sku_status,
14
+ sku.sellable_standalone AS sellable_one_time,
15
+ sku.sellable_in_subscription AS sellable_subscription,
16
+ sku.is_addon,
17
+ sku.asset_ref,
18
+ revision.id AS document_revision_id,
19
+ revision.product_id AS document_product_id,
20
+ revision.revision_no AS document_revision_no,
21
+ revision.schema_id AS document_schema_id,
22
+ revision.document_ref AS document_ref,
23
+ revision.source_ref AS document_source_ref,
24
+ revision.digest AS document_digest`;
25
+ const SKU_ENVELOPE_FROM_SQL = `
26
+ SELECT ${ENVELOPE_COLUMNS_SQL}
27
+ FROM public.catalog_skus AS sku
28
+ JOIN public.catalog_products AS product
29
+ ON product.id = sku.product_id
30
+ LEFT JOIN public.catalog_product_document_revisions AS revision
31
+ ON revision.id = product.current_document_revision_id`;
32
+ const LIST_ENVELOPES_SQL = `${SKU_ENVELOPE_FROM_SQL}
33
+ WHERE ($1::uuid IS NULL OR sku.id > $1::uuid)
34
+ ORDER BY sku.id
35
+ LIMIT $2::integer`;
36
+ const LIST_ACTIVE_ENVELOPES_SQL = `${SKU_ENVELOPE_FROM_SQL}
37
+ WHERE sku.status = 'active'
38
+ AND (sku.sellable_standalone OR sku.sellable_in_subscription)
39
+ AND ($3::text[] IS NULL OR sku.sku = ANY($3::text[]))
40
+ AND ($1::uuid IS NULL OR sku.id > $1::uuid)
41
+ ORDER BY sku.id
42
+ LIMIT $2::integer`;
43
+ const LIST_PUBLIC_ACTIVE_ENVELOPES_SQL = `${SKU_ENVELOPE_FROM_SQL}
44
+ WHERE sku.status = 'active'
45
+ AND ($1::uuid IS NULL OR sku.id > $1::uuid)
46
+ ORDER BY sku.id
47
+ LIMIT $2::integer`;
48
+ const LIST_PUBLIC_ACTIVE_PRODUCT_ENVELOPES_SQL = `${SKU_ENVELOPE_FROM_SQL}
49
+ WHERE sku.product_id = $1::uuid
50
+ AND sku.status = 'active'
51
+ AND ($2::uuid IS NULL OR sku.id > $2::uuid)
52
+ ORDER BY sku.id
53
+ LIMIT $3::integer`;
54
+ const DETAIL_ENVELOPE_BY_ID_SQL = `${SKU_ENVELOPE_FROM_SQL}
55
+ WHERE sku.id = $1::uuid`;
56
+ const DETAIL_ENVELOPE_BY_SKU_CODE_SQL = `${SKU_ENVELOPE_FROM_SQL}
57
+ WHERE sku.sku = $1
58
+ LIMIT 2`;
59
+ const DETAIL_ENVELOPE_BY_PRIMARY_PRODUCT_SLUG_SQL = `
60
+ SELECT ${ENVELOPE_COLUMNS_SQL}
61
+ FROM public.catalog_products AS product
62
+ LEFT JOIN public.catalog_skus AS sku
63
+ ON sku.id = product.primary_sku_id
64
+ LEFT JOIN public.catalog_product_document_revisions AS revision
65
+ ON revision.id = product.current_document_revision_id
66
+ WHERE product.slug = $1
67
+ LIMIT 2`;
68
+ /**
69
+ * Portable W2a envelope reader. It reads only product/SKU/revision references
70
+ * and neutral identifiers; application document content never crosses this seam.
71
+ */
72
+ export function createPostgresCatalogSkuEnvelopeReadPort(executor) {
73
+ return {
74
+ async listSkuEnvelopes(query) {
75
+ return listEnvelopes(executor, query, LIST_ENVELOPES_SQL);
76
+ },
77
+ async listActiveSkuEnvelopes(query) {
78
+ const skuCodes = parseCatalogActiveSkuSelection(query.skuCodes);
79
+ return listEnvelopes(executor, query, LIST_ACTIVE_ENVELOPES_SQL, [], [skuCodes ?? null]);
80
+ },
81
+ async listPublicActiveSkuEnvelopes(query) {
82
+ return listEnvelopes(executor, query, LIST_PUBLIC_ACTIVE_ENVELOPES_SQL);
83
+ },
84
+ async listPublicActiveProductSkuEnvelopes(productId, query) {
85
+ return listEnvelopes(executor, query, LIST_PUBLIC_ACTIVE_PRODUCT_ENVELOPES_SQL, [productId]);
86
+ },
87
+ async getSkuEnvelope(selector) {
88
+ const parsed = catalogSkuEnvelopeSelectorSchema.parse(selector);
89
+ const rows = await readRows(executor, parsed.kind === "sku_code"
90
+ ? DETAIL_ENVELOPE_BY_SKU_CODE_SQL
91
+ : DETAIL_ENVELOPE_BY_PRIMARY_PRODUCT_SLUG_SQL, [parsed.kind === "sku_code" ? parsed.skuCode : parsed.productSlug]);
92
+ const row = uniqueDetailRow(rows, parsed.kind === "sku_code"
93
+ ? "catalog_sku_authority_sku_absent"
94
+ : "catalog_sku_authority_product_absent");
95
+ requirePostgresCatalogSkuEnvelopeRow(row, parsed.kind === "primary_product_slug"
96
+ ? "catalog_sku_authority_primary_sku_invalid"
97
+ : "catalog_sku_authority_current_document_invalid");
98
+ if (parsed.kind === "primary_product_slug"
99
+ && (row.primary_sku_id !== row.sku_id || row.product_id !== row.sku_product_id)) {
100
+ throw new CatalogSkuAuthorityError("catalog_sku_authority_primary_sku_invalid");
101
+ }
102
+ const identifiers = await readPostgresCatalogSkuIdentifiers(executor, [row.sku_id]);
103
+ return mapPostgresCatalogSkuEnvelope(row, identifiers.get(row.sku_id) ?? []);
104
+ },
105
+ async getSkuEnvelopeById(skuId) {
106
+ const row = uniqueDetailRow(await readRows(executor, DETAIL_ENVELOPE_BY_ID_SQL, [skuId]), "catalog_sku_authority_sku_absent");
107
+ requirePostgresCatalogSkuEnvelopeRow(row, "catalog_sku_authority_current_document_invalid");
108
+ const identifiers = await readPostgresCatalogSkuIdentifiers(executor, [row.sku_id]);
109
+ return mapPostgresCatalogSkuEnvelope(row, identifiers.get(row.sku_id) ?? []);
110
+ },
111
+ };
112
+ }
113
+ async function listEnvelopes(executor, query, sql, prefixValues = [], suffixValues = []) {
114
+ const rows = await readRows(executor, sql, [...prefixValues, query.cursor, checkedLimit(query.limit) + 1, ...suffixValues]);
115
+ const pageRows = rows.slice(0, query.limit).map((row) => {
116
+ requirePostgresCatalogSkuEnvelopeRow(row, "catalog_sku_authority_current_document_invalid");
117
+ return row;
118
+ });
119
+ const identifiers = await readPostgresCatalogSkuIdentifiers(executor, pageRows.map((row) => row.sku_id));
120
+ return {
121
+ items: pageRows.map((row) => mapPostgresCatalogSkuEnvelope(row, identifiers.get(row.sku_id) ?? [])),
122
+ nextCursor: rows.length > query.limit ? pageRows[pageRows.length - 1]?.sku_id ?? null : null,
123
+ };
124
+ }
125
+ function uniqueDetailRow(rows, absent) {
126
+ if (rows.length === 0)
127
+ throw new CatalogSkuAuthorityError(absent);
128
+ if (rows.length !== 1) {
129
+ throw new CatalogSkuAuthorityError("catalog_sku_authority_selector_ambiguous");
130
+ }
131
+ return rows[0];
132
+ }
133
+ async function readRows(executor, sql, values) {
134
+ const { rows } = await executor.query(sql, values);
135
+ return rows;
136
+ }
137
+ function checkedLimit(limit) {
138
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > 500) {
139
+ throw new RangeError("catalog_sku_envelope_invalid_limit");
140
+ }
141
+ return limit;
142
+ }
@@ -0,0 +1,38 @@
1
+ import { CatalogSkuAuthorityError, type CatalogSkuIdentifier, type NeutralSkuEnvelopeV1 } from "./foundationSchemas.js";
2
+ import type { PgQueryExecutor } from "../data/index.js";
3
+ export interface PostgresCatalogSkuEnvelopeRow {
4
+ product_id: string;
5
+ product_slug: string;
6
+ primary_sku_id: string | null;
7
+ current_document_revision_id: string | null;
8
+ sku_id: string | null;
9
+ sku_product_id: string | null;
10
+ sku_code: string | null;
11
+ net_content_unscaled: number | null;
12
+ sku_status: "draft" | "active" | "archived" | null;
13
+ sellable_one_time: boolean | null;
14
+ sellable_subscription: boolean | null;
15
+ is_addon: boolean | null;
16
+ asset_ref: string | null;
17
+ document_revision_id: string | null;
18
+ document_product_id: string | null;
19
+ document_revision_no: number | null;
20
+ document_schema_id: string | null;
21
+ document_ref: string | null;
22
+ document_source_ref: string | null;
23
+ document_digest: string | null;
24
+ }
25
+ export type CompletePostgresCatalogSkuEnvelopeRow = PostgresCatalogSkuEnvelopeRow & {
26
+ primary_sku_id: string;
27
+ sku_id: string;
28
+ sku_product_id: string;
29
+ sku_code: string;
30
+ net_content_unscaled: number;
31
+ sku_status: "draft" | "active" | "archived";
32
+ sellable_one_time: boolean;
33
+ sellable_subscription: boolean;
34
+ is_addon: boolean;
35
+ };
36
+ export declare function requirePostgresCatalogSkuEnvelopeRow(row: PostgresCatalogSkuEnvelopeRow, refusal: CatalogSkuAuthorityError["code"]): asserts row is CompletePostgresCatalogSkuEnvelopeRow;
37
+ export declare function readPostgresCatalogSkuIdentifiers(executor: PgQueryExecutor, skuIds: string[]): Promise<Map<string, CatalogSkuIdentifier[]>>;
38
+ export declare function mapPostgresCatalogSkuEnvelope(row: CompletePostgresCatalogSkuEnvelopeRow, identifiers: CatalogSkuIdentifier[]): NeutralSkuEnvelopeV1;