@openlup/platform 0.25.0 → 0.27.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 (524) hide show
  1. package/CHANGELOG.md +156 -440
  2. package/README.md +230 -11
  3. package/dist/commerce/adapters/managed/commerceOmsControlPlane.d.ts +3 -0
  4. package/dist/commerce/adapters/managed/commerceOmsControlPlane.js +71 -0
  5. package/dist/commerce/adapters/managed/commerceOmsMutations.d.ts +10 -0
  6. package/dist/commerce/adapters/managed/commerceOmsMutations.js +119 -0
  7. package/dist/commerce/adapters/managed/commerceOmsPort.d.ts +28 -0
  8. package/dist/commerce/adapters/managed/commerceOmsPort.js +101 -0
  9. package/dist/commerce/adapters/managed/oms/accounting.d.ts +3 -0
  10. package/dist/commerce/adapters/managed/oms/accounting.js +13 -0
  11. package/dist/commerce/adapters/managed/oms/fulfillmentReads.d.ts +17 -0
  12. package/dist/commerce/adapters/managed/oms/fulfillmentReads.js +81 -0
  13. package/dist/commerce/adapters/managed/oms/inboundEvents.d.ts +9 -0
  14. package/dist/commerce/adapters/managed/oms/inboundEvents.js +40 -0
  15. package/dist/commerce/adapters/managed/oms/outboxEvents.d.ts +2 -0
  16. package/dist/commerce/adapters/managed/oms/outboxEvents.js +23 -0
  17. package/dist/commerce/adapters/managed/oms/paymentAttempts.d.ts +3 -0
  18. package/dist/commerce/adapters/managed/oms/paymentAttempts.js +15 -0
  19. package/dist/commerce/adapters/managed/oms/queueSelection.d.ts +12 -0
  20. package/dist/commerce/adapters/managed/oms/queueSelection.js +109 -0
  21. package/dist/commerce/adapters/managed/oms/readProjections.d.ts +18 -0
  22. package/dist/commerce/adapters/managed/oms/readProjections.js +13 -0
  23. package/dist/commerce/adapters/managed/oms/readQueries.d.ts +16 -0
  24. package/dist/commerce/adapters/managed/oms/readQueries.js +276 -0
  25. package/dist/commerce/adapters/managed/oms/types.d.ts +2 -0
  26. package/dist/commerce/adapters/managed/oms/types.js +7 -0
  27. package/dist/commerce/checkoutCommandSchemas.d.ts +89 -0
  28. package/dist/commerce/checkoutCommandSchemas.js +70 -0
  29. package/dist/commerce/checkoutHelpers.d.ts +21 -0
  30. package/dist/commerce/checkoutHelpers.js +29 -0
  31. package/dist/commerce/checkoutResumeSchemas.d.ts +158 -0
  32. package/dist/commerce/checkoutResumeSchemas.js +145 -0
  33. package/dist/commerce/checkoutSchemas.d.ts +158 -0
  34. package/dist/commerce/checkoutSchemas.js +161 -0
  35. package/dist/commerce/commerceReturnsPort.d.ts +97 -0
  36. package/dist/commerce/commerceReturnsPort.js +39 -0
  37. package/dist/commerce/configuratorIntentPersistenceSchemas.d.ts +20 -0
  38. package/dist/commerce/configuratorIntentPersistenceSchemas.js +21 -0
  39. package/dist/commerce/configuratorIntentSchemas.d.ts +63 -0
  40. package/dist/commerce/configuratorIntentSchemas.js +43 -0
  41. package/dist/commerce/contractPrimitives.d.ts +50 -0
  42. package/dist/commerce/contractPrimitives.js +25 -0
  43. package/dist/commerce/contracts/availability.d.ts +23 -0
  44. package/dist/commerce/contracts/availability.js +1 -0
  45. package/dist/commerce/contracts/fulfillmentRecovery.d.ts +25 -0
  46. package/dist/commerce/contracts/fulfillmentRecovery.js +1 -0
  47. package/dist/commerce/contracts/index.d.ts +13 -0
  48. package/dist/commerce/contracts/index.js +1 -0
  49. package/dist/commerce/contracts/intent.d.ts +86 -0
  50. package/dist/commerce/contracts/intent.js +1 -0
  51. package/dist/commerce/contracts/omsTypes.d.ts +1216 -0
  52. package/dist/commerce/contracts/omsTypes.js +1 -0
  53. package/dist/commerce/contracts/order.d.ts +39 -0
  54. package/dist/commerce/contracts/order.js +1 -0
  55. package/dist/commerce/contracts/orderMoney.d.ts +52 -0
  56. package/dist/commerce/contracts/orderMoney.js +1 -0
  57. package/dist/commerce/contracts/ports.d.ts +113 -0
  58. package/dist/commerce/contracts/ports.js +1 -0
  59. package/dist/commerce/contracts/recovery.d.ts +11 -0
  60. package/dist/commerce/contracts/recovery.js +1 -0
  61. package/dist/commerce/contracts/runtimePorts.d.ts +196 -0
  62. package/dist/commerce/contracts/runtimePorts.js +1 -0
  63. package/dist/commerce/contracts/state.d.ts +26 -0
  64. package/dist/commerce/contracts/state.js +43 -0
  65. package/dist/commerce/customerDefaultsSnapshotSchemas.d.ts +51 -0
  66. package/dist/commerce/customerDefaultsSnapshotSchemas.js +106 -0
  67. package/dist/commerce/errors.d.ts +18 -0
  68. package/dist/commerce/errors.js +36 -0
  69. package/dist/commerce/fulfillmentEligibility.d.ts +6 -0
  70. package/dist/commerce/fulfillmentEligibility.js +31 -0
  71. package/dist/commerce/index.d.ts +72 -0
  72. package/dist/commerce/index.js +67 -0
  73. package/dist/commerce/model/customerFulfillmentRecovery.d.ts +40 -0
  74. package/dist/commerce/model/customerFulfillmentRecovery.js +144 -0
  75. package/dist/commerce/model/fulfillmentCancellationEligibility.d.ts +7 -0
  76. package/dist/commerce/model/fulfillmentCancellationEligibility.js +9 -0
  77. package/dist/commerce/model/omsAccountingVisibility.d.ts +12 -0
  78. package/dist/commerce/model/omsAccountingVisibility.js +118 -0
  79. package/dist/commerce/model/omsBillingInvoiceBuyer.d.ts +2 -0
  80. package/dist/commerce/model/omsBillingInvoiceBuyer.js +15 -0
  81. package/dist/commerce/model/omsCurrency.d.ts +4 -0
  82. package/dist/commerce/model/omsCurrency.js +5 -0
  83. package/dist/commerce/model/omsFulfillmentDebug.d.ts +20 -0
  84. package/dist/commerce/model/omsFulfillmentDebug.js +122 -0
  85. package/dist/commerce/model/omsFulfillmentSummary.d.ts +16 -0
  86. package/dist/commerce/model/omsFulfillmentSummary.js +189 -0
  87. package/dist/commerce/model/omsListTotals.d.ts +13 -0
  88. package/dist/commerce/model/omsListTotals.js +32 -0
  89. package/dist/commerce/model/omsOperationalLadder.d.ts +51 -0
  90. package/dist/commerce/model/omsOperationalLadder.js +158 -0
  91. package/dist/commerce/model/omsOrderLineMoney.d.ts +4 -0
  92. package/dist/commerce/model/omsOrderLineMoney.js +25 -0
  93. package/dist/commerce/model/omsPaymentMethodSummary.d.ts +5 -0
  94. package/dist/commerce/model/omsPaymentMethodSummary.js +11 -0
  95. package/dist/commerce/model/omsReadModel.d.ts +43 -0
  96. package/dist/commerce/model/omsReadModel.js +211 -0
  97. package/dist/commerce/model/omsReadModelCommunication.d.ts +3 -0
  98. package/dist/commerce/model/omsReadModelCommunication.js +29 -0
  99. package/dist/commerce/model/omsReadModelHelpers.d.ts +125 -0
  100. package/dist/commerce/model/omsReadModelHelpers.js +212 -0
  101. package/dist/commerce/model/omsReadModelList.d.ts +33 -0
  102. package/dist/commerce/model/omsReadModelList.js +50 -0
  103. package/dist/commerce/model/omsReadModelListSummary.d.ts +3 -0
  104. package/dist/commerce/model/omsReadModelListSummary.js +13 -0
  105. package/dist/commerce/model/omsReadModelPricing.d.ts +5 -0
  106. package/dist/commerce/model/omsReadModelPricing.js +36 -0
  107. package/dist/commerce/model/omsReadModelProjections.d.ts +1 -0
  108. package/dist/commerce/model/omsReadModelProjections.js +1 -0
  109. package/dist/commerce/model/omsReadModelRowCore.d.ts +79 -0
  110. package/dist/commerce/model/omsReadModelRowCore.js +149 -0
  111. package/dist/commerce/model/omsReadModelRows.d.ts +1 -0
  112. package/dist/commerce/model/omsReadModelRows.js +6 -0
  113. package/dist/commerce/offerAvailability.d.ts +18 -0
  114. package/dist/commerce/offerAvailability.js +53 -0
  115. package/dist/commerce/offerAvailabilitySchemas.d.ts +43 -0
  116. package/dist/commerce/offerAvailabilitySchemas.js +42 -0
  117. package/dist/commerce/offerEvidenceSchemas.d.ts +7 -0
  118. package/dist/commerce/offerEvidenceSchemas.js +13 -0
  119. package/dist/commerce/oms/omsContractBase.d.ts +130 -0
  120. package/dist/commerce/oms/omsContractBase.js +86 -0
  121. package/dist/commerce/oms/omsContractReadAuxSchemas.d.ts +222 -0
  122. package/dist/commerce/oms/omsContractReadAuxSchemas.js +123 -0
  123. package/dist/commerce/oms/omsContractReadSchemas.d.ts +2266 -0
  124. package/dist/commerce/oms/omsContractReadSchemas.js +277 -0
  125. package/dist/commerce/oms/omsContractRequests.d.ts +196 -0
  126. package/dist/commerce/oms/omsContractRequests.js +118 -0
  127. package/dist/commerce/oms/omsContracts.d.ts +5 -0
  128. package/dist/commerce/oms/omsContracts.js +4 -0
  129. package/dist/commerce/oms/omsControlPlane.d.ts +275 -0
  130. package/dist/commerce/oms/omsControlPlane.js +72 -0
  131. package/dist/commerce/oms/omsFulfillmentContractSchemas.d.ts +203 -0
  132. package/dist/commerce/oms/omsFulfillmentContractSchemas.js +94 -0
  133. package/dist/commerce/oms/omsFulfillmentDebugSchemas.d.ts +69 -0
  134. package/dist/commerce/oms/omsFulfillmentDebugSchemas.js +33 -0
  135. package/dist/commerce/oms/omsFulfillmentHealthSchemas.d.ts +67 -0
  136. package/dist/commerce/oms/omsFulfillmentHealthSchemas.js +44 -0
  137. package/dist/commerce/oms/omsPorts.d.ts +84 -0
  138. package/dist/commerce/oms/omsPorts.js +148 -0
  139. package/dist/commerce/oms/omsPrimitives.d.ts +5 -0
  140. package/dist/commerce/oms/omsPrimitives.js +3 -0
  141. package/dist/commerce/oms/omsProviderEvidenceSchemas.d.ts +15 -0
  142. package/dist/commerce/oms/omsProviderEvidenceSchemas.js +12 -0
  143. package/dist/commerce/orderDraftErrors.d.ts +13 -0
  144. package/dist/commerce/orderDraftErrors.js +20 -0
  145. package/dist/commerce/orderEmailEligibility.d.ts +54 -0
  146. package/dist/commerce/orderEmailEligibility.js +123 -0
  147. package/dist/commerce/orderEmailLines.d.ts +12 -0
  148. package/dist/commerce/orderEmailLines.js +8 -0
  149. package/dist/commerce/orderFeedbackContracts.d.ts +41 -0
  150. package/dist/commerce/orderFeedbackContracts.js +33 -0
  151. package/dist/commerce/orderMoney.d.ts +6 -0
  152. package/dist/commerce/orderMoney.js +168 -0
  153. package/dist/commerce/orderReviewContracts.d.ts +475 -0
  154. package/dist/commerce/orderReviewContracts.js +94 -0
  155. package/dist/commerce/orderReviewPorts.d.ts +140 -0
  156. package/dist/commerce/orderReviewPorts.js +1 -0
  157. package/dist/commerce/outboxDispatchContracts.d.ts +30 -0
  158. package/dist/commerce/outboxDispatchContracts.js +1 -0
  159. package/dist/commerce/outboxEventSchemas.d.ts +162 -0
  160. package/dist/commerce/outboxEventSchemas.js +164 -0
  161. package/dist/commerce/outboxOrderDraftEmailPorts.d.ts +207 -0
  162. package/dist/commerce/outboxOrderDraftEmailPorts.js +12 -0
  163. package/dist/commerce/paymentContinuation.d.ts +4 -0
  164. package/dist/commerce/paymentContinuation.js +4 -0
  165. package/dist/commerce/ports.d.ts +8 -0
  166. package/dist/commerce/ports.js +1 -0
  167. package/dist/commerce/recoveryDestination.d.ts +3 -0
  168. package/dist/commerce/recoveryDestination.js +17 -0
  169. package/dist/commerce/runtimeErrors.d.ts +8 -0
  170. package/dist/commerce/runtimeErrors.js +16 -0
  171. package/dist/commerce/salesChannelEnvelope.d.ts +20 -0
  172. package/dist/commerce/salesChannelEnvelope.js +7 -0
  173. package/dist/commerce/schemas.d.ts +174 -0
  174. package/dist/commerce/schemas.js +84 -0
  175. package/dist/commerce/server/checkoutCompensation.d.ts +21 -0
  176. package/dist/commerce/server/checkoutCompensation.js +32 -0
  177. package/dist/commerce/server/checkoutConflictClassifiers.d.ts +17 -0
  178. package/dist/commerce/server/checkoutConflictClassifiers.js +38 -0
  179. package/dist/commerce/server/checkoutExpiredRecoveryPolicy.d.ts +38 -0
  180. package/dist/commerce/server/checkoutExpiredRecoveryPolicy.js +85 -0
  181. package/dist/commerce/server/checkoutInvoiceBuyerSnapshot.d.ts +22 -0
  182. package/dist/commerce/server/checkoutInvoiceBuyerSnapshot.js +30 -0
  183. package/dist/commerce/server/checkoutOfferPolicyPort.d.ts +33 -0
  184. package/dist/commerce/server/checkoutOfferPolicyPort.js +49 -0
  185. package/dist/commerce/server/checkoutPaymentContinuationCredential.d.ts +58 -0
  186. package/dist/commerce/server/checkoutPaymentContinuationCredential.js +154 -0
  187. package/dist/commerce/server/checkoutQuoteTypes.d.ts +19 -0
  188. package/dist/commerce/server/checkoutQuoteTypes.js +1 -0
  189. package/dist/commerce/server/checkoutRecoveryOrderPort.d.ts +42 -0
  190. package/dist/commerce/server/checkoutRecoveryOrderPort.js +1 -0
  191. package/dist/commerce/server/checkoutRecoveryToken.d.ts +40 -0
  192. package/dist/commerce/server/checkoutRecoveryToken.js +26 -0
  193. package/dist/commerce/server/checkoutRefusalContinuation.d.ts +24 -0
  194. package/dist/commerce/server/checkoutRefusalContinuation.js +18 -0
  195. package/dist/commerce/server/checkoutRuntimeTypes.d.ts +81 -0
  196. package/dist/commerce/server/checkoutRuntimeTypes.js +1 -0
  197. package/dist/commerce/server/commerceCheckoutCommandExecution.d.ts +60 -0
  198. package/dist/commerce/server/commerceCheckoutCommandExecution.js +136 -0
  199. package/dist/commerce/server/commerceCheckoutCompensation.d.ts +26 -0
  200. package/dist/commerce/server/commerceCheckoutCompensation.js +46 -0
  201. package/dist/commerce/server/commerceCheckoutContinuationTerms.d.ts +50 -0
  202. package/dist/commerce/server/commerceCheckoutContinuationTerms.js +66 -0
  203. package/dist/commerce/server/commerceCheckoutCustomerDefaults.d.ts +18 -0
  204. package/dist/commerce/server/commerceCheckoutCustomerDefaults.js +17 -0
  205. package/dist/commerce/server/commerceCheckoutFailureHandler.d.ts +51 -0
  206. package/dist/commerce/server/commerceCheckoutFailureHandler.js +90 -0
  207. package/dist/commerce/server/commerceCheckoutHandler.d.ts +213 -0
  208. package/dist/commerce/server/commerceCheckoutHandler.js +196 -0
  209. package/dist/commerce/server/commerceCheckoutHandlerAdmission.d.ts +58 -0
  210. package/dist/commerce/server/commerceCheckoutHandlerAdmission.js +94 -0
  211. package/dist/commerce/server/commerceCheckoutHandlerHelpers.d.ts +67 -0
  212. package/dist/commerce/server/commerceCheckoutHandlerHelpers.js +155 -0
  213. package/dist/commerce/server/commerceCheckoutOrchestrationError.d.ts +9 -0
  214. package/dist/commerce/server/commerceCheckoutOrchestrationError.js +14 -0
  215. package/dist/commerce/server/commerceCheckoutPromotionPriceChange.d.ts +47 -0
  216. package/dist/commerce/server/commerceCheckoutPromotionPriceChange.js +43 -0
  217. package/dist/commerce/server/commerceCheckoutProviderPayment.d.ts +34 -0
  218. package/dist/commerce/server/commerceCheckoutProviderPayment.js +37 -0
  219. package/dist/commerce/server/commerceCheckoutQuoteGuard.d.ts +62 -0
  220. package/dist/commerce/server/commerceCheckoutQuoteGuard.js +106 -0
  221. package/dist/commerce/server/commerceCheckoutResume.d.ts +29 -0
  222. package/dist/commerce/server/commerceCheckoutResume.js +81 -0
  223. package/dist/commerce/server/commerceCheckoutResumeGuard.d.ts +54 -0
  224. package/dist/commerce/server/commerceCheckoutResumeGuard.js +138 -0
  225. package/dist/commerce/server/commerceCheckoutSavedPaymentMethod.d.ts +39 -0
  226. package/dist/commerce/server/commerceCheckoutSavedPaymentMethod.js +44 -0
  227. package/dist/commerce/server/commerceCheckoutStartRuntimeFailure.d.ts +7 -0
  228. package/dist/commerce/server/commerceCheckoutStartRuntimeFailure.js +39 -0
  229. package/dist/commerce/server/commerceCheckoutTiming.d.ts +8 -0
  230. package/dist/commerce/server/commerceCheckoutTiming.js +31 -0
  231. package/dist/commerce/server/commerceDiagnostics.d.ts +6 -0
  232. package/dist/commerce/server/commerceDiagnostics.js +31 -0
  233. package/dist/commerce/server/commerceOmsCancelOrderHandler.d.ts +7 -0
  234. package/dist/commerce/server/commerceOmsCancelOrderHandler.js +22 -0
  235. package/dist/commerce/server/commerceOmsControlPlaneHandlers.d.ts +18 -0
  236. package/dist/commerce/server/commerceOmsControlPlaneHandlers.js +60 -0
  237. package/dist/commerce/server/commerceOmsHandlers.d.ts +47 -0
  238. package/dist/commerce/server/commerceOmsHandlers.js +176 -0
  239. package/dist/commerce/server/commerceOmsMarkRefundedHandler.d.ts +7 -0
  240. package/dist/commerce/server/commerceOmsMarkRefundedHandler.js +19 -0
  241. package/dist/commerce/server/commerceOrderDraft.d.ts +24 -0
  242. package/dist/commerce/server/commerceOrderDraft.js +92 -0
  243. package/dist/commerce/server/commercePaidOrderOrchestration.d.ts +131 -0
  244. package/dist/commerce/server/commercePaidOrderOrchestration.js +140 -0
  245. package/dist/commerce/server/commerceProviderAttemptFailure.d.ts +133 -0
  246. package/dist/commerce/server/commerceProviderAttemptFailure.js +175 -0
  247. package/dist/commerce/server/commerceReturnsHandlers.d.ts +41 -0
  248. package/dist/commerce/server/commerceReturnsHandlers.js +100 -0
  249. package/dist/commerce/server/commerceRuntimePort.d.ts +16 -0
  250. package/dist/commerce/server/commerceRuntimePort.js +57 -0
  251. package/dist/commerce/server/commerceRuntimeService.d.ts +98 -0
  252. package/dist/commerce/server/commerceRuntimeService.js +186 -0
  253. package/dist/commerce/server/commerceRuntimeStartResponse.d.ts +37 -0
  254. package/dist/commerce/server/commerceRuntimeStartResponse.js +56 -0
  255. package/dist/commerce/server/commerceStarterOfferGuard.d.ts +55 -0
  256. package/dist/commerce/server/commerceStarterOfferGuard.js +128 -0
  257. package/dist/commerce/server/configuratorIntentPersistence.d.ts +47 -0
  258. package/dist/commerce/server/configuratorIntentPersistence.js +85 -0
  259. package/dist/commerce/server/configuratorIntentPersistenceHandler.d.ts +14 -0
  260. package/dist/commerce/server/configuratorIntentPersistenceHandler.js +42 -0
  261. package/dist/commerce/server/emailRuntime.d.ts +47 -0
  262. package/dist/commerce/server/emailRuntime.js +1 -0
  263. package/dist/commerce/server/handlerSupport.d.ts +68 -0
  264. package/dist/commerce/server/handlerSupport.js +1 -0
  265. package/dist/commerce/server/index.d.ts +178 -0
  266. package/dist/commerce/server/index.js +127 -0
  267. package/dist/commerce/server/offerAvailability.d.ts +21 -0
  268. package/dist/commerce/server/offerAvailability.js +163 -0
  269. package/dist/commerce/server/orderDraftRpcPayload.d.ts +20 -0
  270. package/dist/commerce/server/orderDraftRpcPayload.js +21 -0
  271. package/dist/commerce/server/orderFeedbackSubmit.d.ts +20 -0
  272. package/dist/commerce/server/orderFeedbackSubmit.js +16 -0
  273. package/dist/commerce/server/orderFeedbackTokenCheck.d.ts +17 -0
  274. package/dist/commerce/server/orderFeedbackTokenCheck.js +14 -0
  275. package/dist/commerce/server/orderReviewAdminHandlers.d.ts +47 -0
  276. package/dist/commerce/server/orderReviewAdminHandlers.js +41 -0
  277. package/dist/commerce/server/orderReviewHandlers.d.ts +114 -0
  278. package/dist/commerce/server/orderReviewHandlers.js +42 -0
  279. package/dist/commerce/server/orderReviewLifecycle.d.ts +10 -0
  280. package/dist/commerce/server/orderReviewLifecycle.js +121 -0
  281. package/dist/commerce/server/orderReviewMedia.d.ts +11 -0
  282. package/dist/commerce/server/orderReviewMedia.js +172 -0
  283. package/dist/commerce/server/orderReviewRawUploadHandler.d.ts +40 -0
  284. package/dist/commerce/server/orderReviewRawUploadHandler.js +316 -0
  285. package/dist/commerce/server/outboxCheckoutExpiredEmailHandler.d.ts +14 -0
  286. package/dist/commerce/server/outboxCheckoutExpiredEmailHandler.js +57 -0
  287. package/dist/commerce/server/outboxCheckoutRecoveryEmailHandler.d.ts +13 -0
  288. package/dist/commerce/server/outboxCheckoutRecoveryEmailHandler.js +150 -0
  289. package/dist/commerce/server/outboxDispatchRegistry.d.ts +46 -0
  290. package/dist/commerce/server/outboxDispatchRegistry.js +184 -0
  291. package/dist/commerce/server/outboxDispatchRegistryComposition.d.ts +6 -0
  292. package/dist/commerce/server/outboxDispatchRegistryComposition.js +23 -0
  293. package/dist/commerce/server/outboxOrderDraftEmailHandler.d.ts +14 -0
  294. package/dist/commerce/server/outboxOrderDraftEmailHandler.js +130 -0
  295. package/dist/commerce/server/outboxOrderPaidEmailHandler.d.ts +21 -0
  296. package/dist/commerce/server/outboxOrderPaidEmailHandler.js +93 -0
  297. package/dist/commerce/server/outboxOrderPaidFulfillmentHandler.d.ts +3 -0
  298. package/dist/commerce/server/outboxOrderPaidFulfillmentHandler.js +1 -0
  299. package/dist/commerce/server/outboxOrderPaidFulfillmentPorts.d.ts +3 -0
  300. package/dist/commerce/server/outboxOrderPaidFulfillmentPorts.js +1 -0
  301. package/dist/commerce/server/outboxOrderRefundedEmailHandler.d.ts +13 -0
  302. package/dist/commerce/server/outboxOrderRefundedEmailHandler.js +42 -0
  303. package/dist/commerce/server/outboxPaymentFailedEmailHandler.d.ts +14 -0
  304. package/dist/commerce/server/outboxPaymentFailedEmailHandler.js +65 -0
  305. package/dist/commerce/server/outboxReturnEmailHandlers.d.ts +26 -0
  306. package/dist/commerce/server/outboxReturnEmailHandlers.js +53 -0
  307. package/dist/commerce/server/outboxShipmentDeliveredEmailHandler.d.ts +17 -0
  308. package/dist/commerce/server/outboxShipmentDeliveredEmailHandler.js +52 -0
  309. package/dist/commerce/server/outboxShipmentDispatchedEmailHandler.d.ts +13 -0
  310. package/dist/commerce/server/outboxShipmentDispatchedEmailHandler.js +87 -0
  311. package/dist/commerce/server/outboxShipmentExceptionEmailHandler.d.ts +13 -0
  312. package/dist/commerce/server/outboxShipmentExceptionEmailHandler.js +46 -0
  313. package/dist/commerce/server/referenceCheckoutHandler.d.ts +48 -0
  314. package/dist/commerce/server/referenceCheckoutHandler.js +68 -0
  315. package/dist/commerce/server/reservationSweepPort.d.ts +31 -0
  316. package/dist/commerce/server/reservationSweepPort.js +45 -0
  317. package/dist/commerce/server/starterTermsPort.d.ts +22 -0
  318. package/dist/commerce/server/starterTermsPort.js +1 -0
  319. package/dist/commerce/server/supabaseCommerceReturnsPort.d.ts +13 -0
  320. package/dist/commerce/server/supabaseCommerceReturnsPort.js +56 -0
  321. package/dist/communications/consentPurposeRegistry.d.ts +1 -1
  322. package/dist/communications/newsletterIntegrationContracts.d.ts +5 -5
  323. package/dist/composition/commerceContribution.d.ts +21 -0
  324. package/dist/composition/commerceContribution.js +27 -0
  325. package/dist/composition/index.d.ts +1 -0
  326. package/dist/composition/index.js +1 -0
  327. package/dist/fulfillment/handlerSchemas.d.ts +41 -41
  328. package/dist/fulfillment/index.d.ts +1 -1
  329. package/dist/fulfillment/index.js +1 -1
  330. package/dist/fulfillment/paidHandoff.d.ts +12 -1
  331. package/dist/fulfillment/paidHandoff.js +2 -2
  332. package/dist/fulfillment/providerDispatchWorker.d.ts +4 -4
  333. package/dist/identity/customerContracts.d.ts +2 -2
  334. package/dist/inventory/bindings.d.ts +3 -0
  335. package/dist/inventory/bindings.js +10 -4
  336. package/dist/inventory/index.d.ts +1 -0
  337. package/dist/inventory/index.js +1 -0
  338. package/dist/inventory/managedStockAvailability.d.ts +15 -0
  339. package/dist/inventory/managedStockAvailability.js +16 -0
  340. package/dist/inventory/postgresStockAvailability.js +2 -25
  341. package/dist/inventory/schemas.d.ts +1 -1
  342. package/dist/inventory/stockReadResponse.d.ts +4 -0
  343. package/dist/inventory/stockReadResponse.js +27 -0
  344. package/dist/pricing/browser/index.d.ts +6 -0
  345. package/dist/pricing/browser/index.js +6 -0
  346. package/dist/promotions/adminPromotionsContracts.d.ts +2 -2
  347. package/dist/subscriptions/contracts/renewal.d.ts +2 -0
  348. package/dist/subscriptions/index.d.ts +3 -2
  349. package/dist/subscriptions/index.js +3 -2
  350. package/dist/subscriptions/renewalCycleFailureMechanism.js +3 -2
  351. package/package.json +22 -2
  352. package/release-gates.json +63 -8
  353. package/src/commerce/adapters/managed/commerceOmsControlPlane.ts +80 -0
  354. package/src/commerce/adapters/managed/commerceOmsMutations.ts +145 -0
  355. package/src/commerce/adapters/managed/commerceOmsPort.ts +158 -0
  356. package/src/commerce/adapters/managed/oms/accounting.ts +18 -0
  357. package/src/commerce/adapters/managed/oms/fulfillmentReads.ts +82 -0
  358. package/src/commerce/adapters/managed/oms/inboundEvents.ts +45 -0
  359. package/src/commerce/adapters/managed/oms/outboxEvents.ts +30 -0
  360. package/src/commerce/adapters/managed/oms/paymentAttempts.ts +19 -0
  361. package/src/commerce/adapters/managed/oms/queueSelection.ts +132 -0
  362. package/src/commerce/adapters/managed/oms/readProjections.ts +22 -0
  363. package/src/commerce/adapters/managed/oms/readQueries.ts +292 -0
  364. package/src/commerce/adapters/managed/oms/types.ts +9 -0
  365. package/src/commerce/checkoutCommandSchemas.ts +93 -0
  366. package/src/commerce/checkoutHelpers.ts +47 -0
  367. package/src/commerce/checkoutResumeSchemas.ts +164 -0
  368. package/src/commerce/checkoutSchemas.ts +182 -0
  369. package/src/commerce/commerceReturnsPort.ts +67 -0
  370. package/src/commerce/configuratorIntentPersistenceSchemas.ts +26 -0
  371. package/src/commerce/configuratorIntentSchemas.ts +47 -0
  372. package/src/commerce/contractPrimitives.ts +30 -0
  373. package/src/commerce/contracts/availability.ts +21 -0
  374. package/src/commerce/contracts/fulfillmentRecovery.ts +26 -0
  375. package/src/commerce/contracts/index.ts +17 -0
  376. package/src/commerce/contracts/intent.ts +58 -0
  377. package/src/commerce/contracts/omsTypes.ts +1217 -0
  378. package/src/commerce/contracts/order.ts +44 -0
  379. package/src/commerce/contracts/orderMoney.ts +75 -0
  380. package/src/commerce/contracts/ports.ts +124 -0
  381. package/src/commerce/contracts/recovery.ts +24 -0
  382. package/src/commerce/contracts/runtimePorts.ts +201 -0
  383. package/src/commerce/contracts/state.ts +64 -0
  384. package/src/commerce/customerDefaultsSnapshotSchemas.ts +117 -0
  385. package/src/commerce/errors.ts +53 -0
  386. package/src/commerce/fulfillmentEligibility.ts +32 -0
  387. package/src/commerce/index.ts +82 -0
  388. package/src/commerce/model/customerFulfillmentRecovery.ts +185 -0
  389. package/src/commerce/model/fulfillmentCancellationEligibility.ts +18 -0
  390. package/src/commerce/model/omsAccountingVisibility.ts +135 -0
  391. package/src/commerce/model/omsBillingInvoiceBuyer.ts +20 -0
  392. package/src/commerce/model/omsCurrency.ts +8 -0
  393. package/src/commerce/model/omsFulfillmentDebug.ts +157 -0
  394. package/src/commerce/model/omsFulfillmentSummary.ts +225 -0
  395. package/src/commerce/model/omsListTotals.ts +38 -0
  396. package/src/commerce/model/omsOperationalLadder.ts +181 -0
  397. package/src/commerce/model/omsOrderLineMoney.ts +34 -0
  398. package/src/commerce/model/omsPaymentMethodSummary.ts +19 -0
  399. package/src/commerce/model/omsReadModel.ts +302 -0
  400. package/src/commerce/model/omsReadModelCommunication.ts +32 -0
  401. package/src/commerce/model/omsReadModelHelpers.ts +279 -0
  402. package/src/commerce/model/omsReadModelList.ts +90 -0
  403. package/src/commerce/model/omsReadModelListSummary.ts +19 -0
  404. package/src/commerce/model/omsReadModelPricing.ts +57 -0
  405. package/src/commerce/model/omsReadModelProjections.ts +1 -0
  406. package/src/commerce/model/omsReadModelRowCore.ts +193 -0
  407. package/src/commerce/model/omsReadModelRows.ts +7 -0
  408. package/src/commerce/offerAvailability.ts +75 -0
  409. package/src/commerce/offerAvailabilitySchemas.ts +56 -0
  410. package/src/commerce/offerEvidenceSchemas.ts +17 -0
  411. package/src/commerce/oms/omsContractBase.ts +92 -0
  412. package/src/commerce/oms/omsContractReadAuxSchemas.ts +130 -0
  413. package/src/commerce/oms/omsContractReadSchemas.ts +303 -0
  414. package/src/commerce/oms/omsContractRequests.ts +143 -0
  415. package/src/commerce/oms/omsContracts.ts +6 -0
  416. package/src/commerce/oms/omsControlPlane.ts +85 -0
  417. package/src/commerce/oms/omsFulfillmentContractSchemas.ts +113 -0
  418. package/src/commerce/oms/omsFulfillmentDebugSchemas.ts +38 -0
  419. package/src/commerce/oms/omsFulfillmentHealthSchemas.ts +46 -0
  420. package/src/commerce/oms/omsPorts.ts +165 -0
  421. package/src/commerce/oms/omsPrimitives.ts +3 -0
  422. package/src/commerce/oms/omsProviderEvidenceSchemas.ts +13 -0
  423. package/src/commerce/orderDraftErrors.ts +28 -0
  424. package/src/commerce/orderEmailEligibility.ts +131 -0
  425. package/src/commerce/orderEmailLines.ts +22 -0
  426. package/src/commerce/orderFeedbackContracts.ts +47 -0
  427. package/src/commerce/orderMoney.ts +207 -0
  428. package/src/commerce/orderReviewContracts.ts +124 -0
  429. package/src/commerce/orderReviewPorts.ts +94 -0
  430. package/src/commerce/outboxDispatchContracts.ts +30 -0
  431. package/src/commerce/outboxEventSchemas.ts +230 -0
  432. package/src/commerce/outboxOrderDraftEmailPorts.ts +241 -0
  433. package/src/commerce/paymentContinuation.ts +5 -0
  434. package/src/commerce/ports.ts +7 -0
  435. package/src/commerce/recoveryDestination.ts +23 -0
  436. package/src/commerce/runtimeErrors.ts +19 -0
  437. package/src/commerce/salesChannelEnvelope.ts +28 -0
  438. package/src/commerce/schemas.ts +104 -0
  439. package/src/commerce/server/checkoutCompensation.ts +49 -0
  440. package/src/commerce/server/checkoutConflictClassifiers.ts +53 -0
  441. package/src/commerce/server/checkoutExpiredRecoveryPolicy.ts +107 -0
  442. package/src/commerce/server/checkoutInvoiceBuyerSnapshot.ts +36 -0
  443. package/src/commerce/server/checkoutOfferPolicyPort.ts +60 -0
  444. package/src/commerce/server/checkoutPaymentContinuationCredential.ts +222 -0
  445. package/src/commerce/server/checkoutQuoteTypes.ts +9 -0
  446. package/src/commerce/server/checkoutRecoveryOrderPort.ts +40 -0
  447. package/src/commerce/server/checkoutRecoveryToken.ts +63 -0
  448. package/src/commerce/server/checkoutRefusalContinuation.ts +29 -0
  449. package/src/commerce/server/checkoutRuntimeTypes.ts +26 -0
  450. package/src/commerce/server/commerceCheckoutCommandExecution.ts +188 -0
  451. package/src/commerce/server/commerceCheckoutCompensation.ts +66 -0
  452. package/src/commerce/server/commerceCheckoutContinuationTerms.ts +87 -0
  453. package/src/commerce/server/commerceCheckoutCustomerDefaults.ts +24 -0
  454. package/src/commerce/server/commerceCheckoutFailureHandler.ts +144 -0
  455. package/src/commerce/server/commerceCheckoutHandler.ts +269 -0
  456. package/src/commerce/server/commerceCheckoutHandlerAdmission.ts +157 -0
  457. package/src/commerce/server/commerceCheckoutHandlerHelpers.ts +223 -0
  458. package/src/commerce/server/commerceCheckoutOrchestrationError.ts +15 -0
  459. package/src/commerce/server/commerceCheckoutPromotionPriceChange.ts +83 -0
  460. package/src/commerce/server/commerceCheckoutProviderPayment.ts +45 -0
  461. package/src/commerce/server/commerceCheckoutQuoteGuard.ts +172 -0
  462. package/src/commerce/server/commerceCheckoutResume.ts +132 -0
  463. package/src/commerce/server/commerceCheckoutResumeGuard.ts +195 -0
  464. package/src/commerce/server/commerceCheckoutSavedPaymentMethod.ts +85 -0
  465. package/src/commerce/server/commerceCheckoutStartRuntimeFailure.ts +59 -0
  466. package/src/commerce/server/commerceCheckoutTiming.ts +53 -0
  467. package/src/commerce/server/commerceDiagnostics.ts +37 -0
  468. package/src/commerce/server/commerceOmsCancelOrderHandler.ts +43 -0
  469. package/src/commerce/server/commerceOmsControlPlaneHandlers.ts +71 -0
  470. package/src/commerce/server/commerceOmsHandlers.ts +275 -0
  471. package/src/commerce/server/commerceOmsMarkRefundedHandler.ts +39 -0
  472. package/src/commerce/server/commerceOrderDraft.ts +131 -0
  473. package/src/commerce/server/commercePaidOrderOrchestration.ts +275 -0
  474. package/src/commerce/server/commerceProviderAttemptFailure.ts +257 -0
  475. package/src/commerce/server/commerceReturnsHandlers.ts +143 -0
  476. package/src/commerce/server/commerceRuntimePort.ts +75 -0
  477. package/src/commerce/server/commerceRuntimeService.ts +229 -0
  478. package/src/commerce/server/commerceRuntimeStartResponse.ts +76 -0
  479. package/src/commerce/server/commerceStarterOfferGuard.ts +200 -0
  480. package/src/commerce/server/configuratorIntentPersistence.ts +161 -0
  481. package/src/commerce/server/configuratorIntentPersistenceHandler.ts +54 -0
  482. package/src/commerce/server/emailRuntime.ts +30 -0
  483. package/src/commerce/server/handlerSupport.ts +22 -0
  484. package/src/commerce/server/index.ts +181 -0
  485. package/src/commerce/server/offerAvailability.ts +275 -0
  486. package/src/commerce/server/orderDraftRpcPayload.ts +39 -0
  487. package/src/commerce/server/orderFeedbackSubmit.ts +40 -0
  488. package/src/commerce/server/orderFeedbackTokenCheck.ts +28 -0
  489. package/src/commerce/server/orderReviewAdminHandlers.ts +43 -0
  490. package/src/commerce/server/orderReviewHandlers.ts +57 -0
  491. package/src/commerce/server/orderReviewLifecycle.ts +129 -0
  492. package/src/commerce/server/orderReviewMedia.ts +170 -0
  493. package/src/commerce/server/orderReviewRawUploadHandler.ts +300 -0
  494. package/src/commerce/server/outboxCheckoutExpiredEmailHandler.ts +86 -0
  495. package/src/commerce/server/outboxCheckoutRecoveryEmailHandler.ts +188 -0
  496. package/src/commerce/server/outboxDispatchRegistry.ts +269 -0
  497. package/src/commerce/server/outboxDispatchRegistryComposition.ts +31 -0
  498. package/src/commerce/server/outboxOrderDraftEmailHandler.ts +162 -0
  499. package/src/commerce/server/outboxOrderPaidEmailHandler.ts +147 -0
  500. package/src/commerce/server/outboxOrderPaidFulfillmentHandler.ts +4 -0
  501. package/src/commerce/server/outboxOrderPaidFulfillmentPorts.ts +3 -0
  502. package/src/commerce/server/outboxOrderRefundedEmailHandler.ts +58 -0
  503. package/src/commerce/server/outboxPaymentFailedEmailHandler.ts +99 -0
  504. package/src/commerce/server/outboxReturnEmailHandlers.ts +92 -0
  505. package/src/commerce/server/outboxShipmentDeliveredEmailHandler.ts +94 -0
  506. package/src/commerce/server/outboxShipmentDispatchedEmailHandler.ts +112 -0
  507. package/src/commerce/server/outboxShipmentExceptionEmailHandler.ts +73 -0
  508. package/src/commerce/server/referenceCheckoutHandler.ts +87 -0
  509. package/src/commerce/server/reservationSweepPort.ts +67 -0
  510. package/src/commerce/server/starterTermsPort.ts +22 -0
  511. package/src/commerce/server/supabaseCommerceReturnsPort.ts +81 -0
  512. package/src/composition/commerceContribution.ts +35 -0
  513. package/src/composition/index.ts +1 -0
  514. package/src/fulfillment/index.ts +1 -1
  515. package/src/fulfillment/paidHandoff.ts +2 -2
  516. package/src/inventory/bindings.ts +12 -4
  517. package/src/inventory/index.ts +1 -0
  518. package/src/inventory/managedStockAvailability.ts +23 -0
  519. package/src/inventory/postgresStockAvailability.ts +2 -21
  520. package/src/inventory/stockReadResponse.ts +25 -0
  521. package/src/pricing/browser/index.ts +6 -0
  522. package/src/subscriptions/contracts/renewal.ts +2 -1
  523. package/src/subscriptions/index.ts +3 -2
  524. package/src/subscriptions/renewalCycleFailureMechanism.ts +3 -1
@@ -0,0 +1,158 @@
1
+ import type { OmsActionAvailabilityFlags } from "../../model/omsReadModelHelpers.js";
2
+ import type {
3
+ AdminCommerceOrderCancelRequest,
4
+ AdminCommerceOrderDetailRequest,
5
+ AdminCommerceOrderDetailResponse,
6
+ AdminCommerceOrderHoldRequest,
7
+ AdminCommerceOrderHoldResponse,
8
+ AdminCommerceOrderMarkRefundedRequest,
9
+ AdminCommerceOrderMarkRefundedResponse,
10
+ AdminCommerceOrderNoteRequest,
11
+ AdminCommerceOrderNoteResponse,
12
+ AdminCommerceOrderReleaseHoldRequest,
13
+ AdminCommerceOrderRequestReplacementShipmentRequest,
14
+ AdminCommerceOrderRequestReplacementShipmentResponse,
15
+ AdminCommerceOrderUpdateShippingAddressRequest,
16
+ AdminCommerceOrderUpdateShippingAddressResponse,
17
+ AdminCommerceOrdersListRequest,
18
+ AdminCommerceOrdersListResponse,
19
+ } from "../../oms/omsContracts.js";
20
+ import {
21
+ CommerceOmsConflictError,
22
+ CommerceOmsPersistenceError,
23
+ readOmsReplacementRefusal,
24
+ type CommerceOmsHoldPort,
25
+ type CommerceOmsReadPort,
26
+ } from "../../oms/omsPorts.js";
27
+ import {
28
+ addCommerceOmsNote,
29
+ callOmsRpc,
30
+ updateCommerceOmsShippingAddress,
31
+ } from "./commerceOmsMutations.js";
32
+ import type { OmsManagedReadProjections } from "./oms/readProjections.js";
33
+ import {
34
+ getCommerceOmsOrderDetail,
35
+ listCommerceOmsOrders,
36
+ } from "./oms/readQueries.js";
37
+ import type { CommerceOmsRpcClient,CommerceOmsStore,RpcError } from "./oms/types.js";
38
+
39
+ export type { CommerceOmsRpcClient } from "./oms/types.js";
40
+
41
+ export function createManagedCommerceOmsPort(
42
+ client: CommerceOmsRpcClient,
43
+ options: { actionFlags?: OmsActionAvailabilityFlags; queries?: Pick<CommerceOmsStore, "query">; projections?: OmsManagedReadProjections } = {},
44
+ ): CommerceOmsReadPort & CommerceOmsHoldPort {
45
+ function readStore(): CommerceOmsStore {
46
+ if (!options.queries) throw new CommerceOmsPersistenceError("Commerce OMS query capability is required");
47
+ return { rpc: client.rpc.bind(client), query: options.queries.query.bind(options.queries) };
48
+ }
49
+ return {
50
+ listOrders(request: AdminCommerceOrdersListRequest): Promise<AdminCommerceOrdersListResponse> {
51
+ return listCommerceOmsOrders(readStore(), request, options);
52
+ },
53
+
54
+ getOrderDetail(request: AdminCommerceOrderDetailRequest): Promise<AdminCommerceOrderDetailResponse | null> {
55
+ return getCommerceOmsOrderDetail(readStore(), request, options);
56
+ },
57
+
58
+ async createHold(request: AdminCommerceOrderHoldRequest & { actorUserId: string }): Promise<AdminCommerceOrderHoldResponse> {
59
+ return callOmsRpc<AdminCommerceOrderHoldResponse>(client, "commerce_oms_create_hold", {
60
+ p_idempotency_key: request.idempotencyKey,
61
+ p_order_id: request.orderId,
62
+ p_reason: request.reason,
63
+ p_note: request.note ?? null,
64
+ p_actor_user_id: request.actorUserId,
65
+ p_metadata: request.metadata ?? {},
66
+ });
67
+ },
68
+
69
+ async releaseHold(request: AdminCommerceOrderReleaseHoldRequest & { actorUserId: string }): Promise<AdminCommerceOrderHoldResponse> {
70
+ return callOmsRpc<AdminCommerceOrderHoldResponse>(client, "commerce_oms_release_hold", {
71
+ p_idempotency_key: request.idempotencyKey,
72
+ p_hold_id: request.holdId,
73
+ p_note: request.note ?? null,
74
+ p_actor_user_id: request.actorUserId,
75
+ p_metadata: request.metadata ?? {},
76
+ });
77
+ },
78
+
79
+ addNote(request: AdminCommerceOrderNoteRequest & { actorUserId: string }): Promise<AdminCommerceOrderNoteResponse> {
80
+ return addCommerceOmsNote(readStore(), request);
81
+ },
82
+
83
+ updateShippingAddress(
84
+ request: AdminCommerceOrderUpdateShippingAddressRequest & { actorUserId: string },
85
+ ): Promise<AdminCommerceOrderUpdateShippingAddressResponse> {
86
+ return updateCommerceOmsShippingAddress(client, request);
87
+ },
88
+
89
+ async markRefunded(
90
+ request: AdminCommerceOrderMarkRefundedRequest & { actorUserId: string },
91
+ ): Promise<AdminCommerceOrderMarkRefundedResponse> {
92
+ return callOmsRpc<AdminCommerceOrderMarkRefundedResponse>(client, "commerce_order_mark_refunded_manual", {
93
+ p_idempotency_key: request.idempotencyKey,
94
+ p_order_id: request.orderId,
95
+ p_reason: request.reason,
96
+ p_actor_user_id: request.actorUserId,
97
+ p_metadata: request.metadata ?? {},
98
+ });
99
+ },
100
+
101
+ async requestReplacementShipment(
102
+ request: AdminCommerceOrderRequestReplacementShipmentRequest & { actorUserId: string },
103
+ ): Promise<AdminCommerceOrderRequestReplacementShipmentResponse> {
104
+ // Deliberately not `callOmsRpc`: that helper classifies through the shared
105
+ // `mapRpcError`, whose catch-all would collapse thirteen distinct refusals
106
+ // into one anonymous "hold conflict". This command's whole operator value is
107
+ // being told *which* refusal it hit, so the raw error is read here.
108
+ const { data, error } = await client.rpc("commerce_oms_request_replacement_shipment", {
109
+ p_idempotency_key: request.idempotencyKey,
110
+ p_order_id: request.orderId,
111
+ p_reason: request.reason,
112
+ p_actor_user_id: request.actorUserId,
113
+ p_metadata: request.metadata ?? {},
114
+ });
115
+ if (error) throw mapReplacementRefusal(error);
116
+ return data as AdminCommerceOrderRequestReplacementShipmentResponse;
117
+ },
118
+
119
+ async cancelOrder(
120
+ request: AdminCommerceOrderCancelRequest & { actorUserId: string },
121
+ ): Promise<AdminCommerceOrderMarkRefundedResponse> {
122
+ return callOmsRpc<AdminCommerceOrderMarkRefundedResponse>(client, "commerce_oms_cancel_unpaid_order", {
123
+ p_idempotency_key: request.idempotencyKey,
124
+ p_order_id: request.orderId,
125
+ p_reason: request.reason,
126
+ p_actor_user_id: request.actorUserId,
127
+ p_metadata: request.metadata ?? {},
128
+ });
129
+ },
130
+ };
131
+ }
132
+
133
+ /**
134
+ * Two outcomes, and the split is the honest one. An error naming a refusal this command can
135
+ * reach - its own `commerce_oms_replacement_*` names, or the reservation vocabulary raised
136
+ * through `inventory_reserve_order` while it mints the replacement's stock generation - is
137
+ * something the operator caused and can answer: it becomes a conflict carrying only the
138
+ * stable reason, not the SQLSTATE and not the message, because that reason is the single
139
+ * field the operator surface renders from. Anything else never reached a refusal at all
140
+ * (transport, permissions, a dead connection) and stays an upstream failure keyed by
141
+ * SQLSTATE, which is diagnostic and never shown as a refusal.
142
+ *
143
+ * The reservation half is the one this wave added, and it is the most likely legitimate
144
+ * refusal in production: the command reserves through an external stock authority, so a
145
+ * stockout arrives as `inventory_external_provider_insufficient_available_stock`. It carries
146
+ * no `commerce_oms_replacement_` prefix, matched nothing, and the operator was told to check
147
+ * holds that were not there. The vocabulary itself lives in
148
+ * `src/domains/commerce/omsPorts.ts` so the surface renders from the same list.
149
+ */
150
+ export function mapReplacementRefusal(error: RpcError): Error {
151
+ const reason = readOmsReplacementRefusal(
152
+ [error.message, error.details, error.hint].filter(Boolean).join(" "),
153
+ );
154
+ if (!reason) {
155
+ return new CommerceOmsPersistenceError("Commerce OMS replacement request failed", { code: error.code });
156
+ }
157
+ return new CommerceOmsConflictError("Commerce OMS replacement request refused", { reason });
158
+ }
@@ -0,0 +1,18 @@
1
+ import type { OmsAccountingInvoiceRow,OmsAccountingOutboxRow } from "../../../model/omsReadModel.js";
2
+ import { CommerceOmsPersistenceError } from "../../../oms/omsPorts.js";
3
+ import type { CommerceOmsStore } from "./types.js";
4
+
5
+ export async function readAccountingOutbox(
6
+ client: CommerceOmsStore,
7
+ invoices: OmsAccountingInvoiceRow[],
8
+ ): Promise<OmsAccountingOutboxRow[]> {
9
+ const result = invoices.length
10
+ ? await client
11
+ .query("accounting_invoice_issue_outbox")
12
+ .select("invoice_id, status, attempt_count, next_attempt_at, last_error, created_at")
13
+ .in("invoice_id", invoices.map((invoice) => invoice.id))
14
+ .order("created_at", { ascending: false })
15
+ : { data: [], error: null };
16
+ if (result.error) throw new CommerceOmsPersistenceError("Commerce OMS accounting outbox list read failed");
17
+ return (result.data ?? []) as OmsAccountingOutboxRow[];
18
+ }
@@ -0,0 +1,82 @@
1
+ import { currentParcelFirst,type FulfillmentParcelRow } from "@openlup/core/fulfillment";
2
+ import type { CommerceOmsStore,RpcError } from "./types.js";
3
+
4
+ const SHIPMENT_EXTERNAL_REF_BASE_COLUMNS = "order_id, provider_tracking_id, active";
5
+ // `fulfillment_order_id` rides the rich list: it is what narrows an order's references to the
6
+ // parcel currently representing it, and a deployment that predates the column falls back to the
7
+ // base list, where every reference answers for every parcel exactly as it did before.
8
+ const SHIPMENT_EXTERNAL_REF_COLUMNS = `${SHIPMENT_EXTERNAL_REF_BASE_COLUMNS}, fulfillment_order_id, provider_kind, tracking_url, carrier_kind, service, created_at, updated_at`;
9
+ // Kept out of the shared provider-evidence matcher on purpose: that one also guards the
10
+ // fulfillment-order reads, and `fulfillment_order_id` is a column half the schema carries, so
11
+ // folding it in there would silently downgrade an unrelated read on any error naming it.
12
+ function isMissingParcelAttributionError(error: RpcError | null): boolean {
13
+ if (!error) return false;
14
+ return `${error.message ?? ""} ${error.details ?? ""} ${error.hint ?? ""}`.toLowerCase().includes("fulfillment_order_id");
15
+ }
16
+
17
+ function shipmentRefReadDegrades(error: RpcError | null): boolean {
18
+ return isOptionalProviderEvidenceColumnError(error) || isMissingParcelAttributionError(error);
19
+ }
20
+
21
+ export async function readShipmentRefsByOrderIds(client: CommerceOmsStore, orderIds: string[]) {
22
+ if (!orderIds.length) return { data: [], error: null };
23
+ const result = await client.query("shipment_external_refs").select(SHIPMENT_EXTERNAL_REF_COLUMNS).in("order_id", orderIds).eq("active", true);
24
+ if (!shipmentRefReadDegrades(result.error)) return result;
25
+ return client.query("shipment_external_refs").select(SHIPMENT_EXTERNAL_REF_BASE_COLUMNS).in("order_id", orderIds).eq("active", true);
26
+ }
27
+
28
+ export async function readShipmentRefsByOrderId(client: CommerceOmsStore, orderId: string) {
29
+ const result = await client.query("shipment_external_refs").select(SHIPMENT_EXTERNAL_REF_COLUMNS).eq("order_id", orderId).eq("active", true);
30
+ if (!shipmentRefReadDegrades(result.error)) return result;
31
+ return client.query("shipment_external_refs").select(SHIPMENT_EXTERNAL_REF_BASE_COLUMNS).eq("order_id", orderId).eq("active", true);
32
+ }
33
+
34
+ // `sequence_no` rides the BASE list, not the rich one: it is what resolves which parcel
35
+ // currently represents an order, so the degraded read that drops provider evidence must still
36
+ // be able to answer that question deterministically.
37
+ const FULFILLMENT_ORDER_BASE_COLUMNS = "id, order_id, sequence_no, status, shipping_address_snapshot, handed_over_at, delivered_at, created_at, updated_at";
38
+ // `handed_over_at` rides the query that already reads the row, and is the only durable witness of
39
+ // which side of handover a provider exception happened on - the FSM's `exception` no longer says.
40
+ // `replaces_fulfillment_order_id` and `replacement_reason` ride the rich list with
41
+ // `provider_kind`: they are what tells an operator that the parcel on their screen IS a
42
+ // replacement and why, and a deployment that predates them degrades to the base list, where
43
+ // every parcel reads as the original exactly as it did before the columns existed.
44
+ const FULFILLMENT_ORDER_COLUMNS = `${FULFILLMENT_ORDER_BASE_COLUMNS}, provider_kind, replaces_fulfillment_order_id, replacement_reason`;
45
+
46
+ // A deployment that predates the optional provider-evidence columns answers the rich select with
47
+ // a missing-column error; every read here retries on the base list rather than failing.
48
+ export function isOptionalProviderEvidenceColumnError(error: { code?: string; message?: string; details?: string; hint?: string } | null): boolean {
49
+ if (!error) return false;
50
+ const text = `${error.message ?? ""} ${error.details ?? ""} ${error.hint ?? ""}`.toLowerCase();
51
+ return ["fulfillment_provider_stock_current", "provider_kind", "tracking_url", "carrier_kind", "service", "replaces_fulfillment_order_id", "replacement_reason"].some((column) => text.includes(column)); // Only columns the BASE list OMITS belong here: created_at/updated_at are in it, so they could never be recovered - they only widened the silent downgrade.
52
+ }
53
+
54
+ // Deliberately no `.maybeSingle()`: PostgREST *errors* (PGRST116) when a single-object read
55
+ // matches two rows, and an order carrying a replacement parcel holds two.
56
+ //
57
+ // ⚠️ This returns EVERY parcel of the order, current one first, where it used to return the
58
+ // current one alone. That is what stopped the original parcel's tracking from vanishing from
59
+ // the operator's screen the moment a replacement existed. Callers that need exactly one row
60
+ // take `[0]`, which `currentParcelFirst` guarantees is the current parcel; nothing downstream
61
+ // widens its attribution, because the provider-evidence reads are still keyed on that one id.
62
+ export async function readFulfillmentParcelsByOrderId(client: CommerceOmsStore, orderId: string): Promise<{ data: unknown[]; error: RpcError | null }> {
63
+ const rich = await client.query("commerce_fulfillment_orders").select(FULFILLMENT_ORDER_COLUMNS).eq("order_id", orderId);
64
+ const result = isOptionalProviderEvidenceColumnError(rich.error)
65
+ ? await client.query("commerce_fulfillment_orders").select(FULFILLMENT_ORDER_BASE_COLUMNS).eq("order_id", orderId)
66
+ : rich;
67
+ if (result.error) return { data: [], error: result.error };
68
+ return { data: currentParcelFirst((result.data ?? []) as FulfillmentParcelRow[]), error: null };
69
+ }
70
+
71
+ // The list read hands every order's rows to one builder, which narrows per order and then takes
72
+ // the first of what is left (`omsReadModelList.ts` filter -> `omsFulfillmentSummary.ts` [0]), so
73
+ // each order's rows must arrive with its current parcel first.
74
+ export async function readFulfillmentOrdersByOrderIds(client: CommerceOmsStore, orderIds: string[]): Promise<{ data: unknown[]; error: RpcError | null }> {
75
+ if (!orderIds.length) return { data: [], error: null };
76
+ const rich = await client.query("commerce_fulfillment_orders").select(FULFILLMENT_ORDER_COLUMNS).in("order_id", orderIds);
77
+ const result = isOptionalProviderEvidenceColumnError(rich.error)
78
+ ? await client.query("commerce_fulfillment_orders").select(FULFILLMENT_ORDER_BASE_COLUMNS).in("order_id", orderIds)
79
+ : rich;
80
+ if (result.error) return { data: [], error: result.error };
81
+ return { data: currentParcelFirst((result.data ?? []) as FulfillmentParcelRow[]), error: null };
82
+ }
@@ -0,0 +1,45 @@
1
+ import type { OmsInboundProviderEventRow } from "../../../model/omsFulfillmentDebug.js";
2
+ import type { OmsProviderDispatchRefRow } from "../../../model/omsFulfillmentSummary.js";
3
+ import type { OmsOrderRow } from "../../../model/omsReadModel.js";
4
+ import { CommerceOmsPersistenceError } from "../../../oms/omsPorts.js";
5
+ import { distinctIds,type CommerceOmsStore } from "./types.js";
6
+
7
+ const INBOUND_EVENT_COLUMNS = "id, provider, provider_event_id, event_type, processing_status, payload, error, created_at, processed_at";
8
+
9
+ export async function readOmsInboundEvents(
10
+ client: CommerceOmsStore,
11
+ input: { order: OmsOrderRow; dispatchRefs: OmsProviderDispatchRefRow[]; providerKind: string },
12
+ ): Promise<OmsInboundProviderEventRow[]> {
13
+ const needles = distinctIds([
14
+ input.order.order_number,
15
+ input.order.id,
16
+ ...input.dispatchRefs.map((row) => row.provider_order_id ?? null),
17
+ ]);
18
+ if (!needles.length) return [];
19
+ const result = await client
20
+ .query("inbound_provider_events")
21
+ .select(INBOUND_EVENT_COLUMNS)
22
+ .eq("provider", input.providerKind)
23
+ .order("created_at", { ascending: false })
24
+ .range(0, 49);
25
+ if (isOptionalInboundEventError(result.error)) return [];
26
+ if (result.error) throw new CommerceOmsPersistenceError("Commerce OMS provider inbound events read failed");
27
+ return ((result.data ?? []) as OmsInboundProviderEventRow[]).filter((row) => matchesNeedle(row, needles));
28
+ }
29
+
30
+ function matchesNeedle(row: OmsInboundProviderEventRow, needles: string[]): boolean {
31
+ const haystack = JSON.stringify({
32
+ providerEventId: row.provider_event_id,
33
+ eventType: row.event_type,
34
+ payload: row.payload,
35
+ error: row.error,
36
+ });
37
+ return needles.some((needle) => haystack.includes(needle));
38
+ }
39
+
40
+ function isOptionalInboundEventError(error: { code?: string; message?: string; details?: string; hint?: string } | null): boolean {
41
+ if (!error) return false;
42
+ if (error.code === "42P01" || error.code === "42703") return true;
43
+ const text = `${error.message ?? ""} ${error.details ?? ""} ${error.hint ?? ""}`.toLowerCase();
44
+ return text.includes("inbound_provider_events");
45
+ }
@@ -0,0 +1,30 @@
1
+ import { COMMERCE_ORDER_PAID_EVENT_TYPE } from "../../../outboxEventSchemas.js";
2
+ import type { CommerceOmsStore } from "./types.js";
3
+
4
+ const ORDER_PAID_OUTBOX_COLUMNS = "id,event_type,status,aggregate_id,created_at,available_at,attempts";
5
+ const ORDER_PAID_OUTBOX_BASE_COLUMNS = "id,event_type,status,aggregate_id,created_at,available_at";
6
+
7
+ export async function readOrderPaidOutboxEvents(client: CommerceOmsStore, orderId: string) {
8
+ const primary = await selectOrderPaidOutboxEvents(client, orderId, ORDER_PAID_OUTBOX_COLUMNS);
9
+ if (!isMissingAttemptsColumn(primary.error)) return primary;
10
+ return selectOrderPaidOutboxEvents(client, orderId, ORDER_PAID_OUTBOX_BASE_COLUMNS);
11
+ }
12
+
13
+ function selectOrderPaidOutboxEvents(
14
+ client: CommerceOmsStore,
15
+ orderId: string,
16
+ columns: string,
17
+ ) {
18
+ return client
19
+ .query("outbox_events")
20
+ .select(columns)
21
+ .eq("event_type", COMMERCE_ORDER_PAID_EVENT_TYPE)
22
+ .eq("aggregate_id", orderId)
23
+ .order("created_at", { ascending: false });
24
+ }
25
+
26
+ function isMissingAttemptsColumn(error: { message?: string; details?: string; hint?: string } | null): boolean {
27
+ if (!error) return false;
28
+ const text = `${error.message ?? ""} ${error.details ?? ""} ${error.hint ?? ""}`.toLowerCase();
29
+ return text.includes("attempts");
30
+ }
@@ -0,0 +1,19 @@
1
+ import type { OmsPaymentAttemptRow,OmsPaymentIntentRow } from "../../../model/omsReadModel.js";
2
+ import { CommerceOmsPersistenceError } from "../../../oms/omsPorts.js";
3
+ import type { CommerceOmsStore } from "./types.js";
4
+
5
+ export async function readActivePaymentAttempts(
6
+ client: CommerceOmsStore,
7
+ paymentIntents: OmsPaymentIntentRow[],
8
+ ): Promise<OmsPaymentAttemptRow[]> {
9
+ const attemptIds = paymentIntents
10
+ .map((intent) => intent.active_attempt_id)
11
+ .filter((id): id is string => Boolean(id));
12
+ if (attemptIds.length === 0) return [];
13
+ const result = await client
14
+ .query("commerce_payment_attempts")
15
+ .select("id, payment_intent_id, status, provider, provider_attempt_id, next_action_kind, updated_at")
16
+ .in("id", attemptIds);
17
+ if (result.error) throw new CommerceOmsPersistenceError("Commerce OMS payment attempt list read failed");
18
+ return (result.data ?? []) as OmsPaymentAttemptRow[];
19
+ }
@@ -0,0 +1,132 @@
1
+ import type { OmsManagedReadProjections } from "../../../contracts/omsTypes.js";
2
+ type MatchSchema = NonNullable<OmsManagedReadProjections["queueMatchSchema"]>;
3
+ import type { QueueSelection } from "../../../contracts/omsTypes.js";
4
+ import { neutralOmsCurrencyPolicy,type OmsCurrencyPolicy } from "../../../model/omsCurrency.js";
5
+ import type {
6
+ AdminCommerceOrdersListRequest,
7
+ AdminOmsOrderListSummaryCounts,
8
+ AdminOmsOrderSearchMatch
9
+ } from "../../../oms/omsContracts.js";
10
+ import { omsOrderListSummaryCountsSchema,omsOrderListSummaryTotalsSchema,omsOrderSearchMatchSchema } from "../../../oms/omsContracts.js";
11
+ import { CommerceOmsPersistenceError } from "../../../oms/omsPorts.js";
12
+ import type { CommerceOmsStore,RpcError } from "./types.js";
13
+ export type { QueueSelection } from "../../../contracts/omsTypes.js";
14
+
15
+ /** The refusal the queue RPC raises when the paid set spans several currencies. */
16
+ const MIXED_CURRENCY_REFUSAL = "commerce_oms_summary_mixed_currency";
17
+
18
+ export async function readQueueSelection(
19
+ client: CommerceOmsStore,
20
+ request: AdminCommerceOrdersListRequest,
21
+ options: { currency?: OmsCurrencyPolicy; matchSchema?: MatchSchema; projectResult?(data: unknown): unknown } = {},
22
+ ): Promise<QueueSelection> {
23
+ const { data, error } = await client.rpc("commerce_oms_admin_list_queue", {
24
+ p_page: request.page,
25
+ p_page_size: request.pageSize,
26
+ p_search: request.search ?? null,
27
+ p_status: request.status ?? null,
28
+ p_mode: request.mode ?? null,
29
+ p_payment_status: request.paymentStatus ?? null,
30
+ p_fulfillment_status: request.fulfillmentStatus ?? null,
31
+ p_inventory_status: request.inventoryStatus ?? null,
32
+ p_accounting_status: request.accountingStatus ?? null,
33
+ p_provider_ops_status: request.providerOpsStatus ?? null,
34
+ p_attention_reason: request.attentionReason ?? null,
35
+ p_attention_only: request.attentionOnly ?? false,
36
+ p_next_action: request.nextAction ?? null,
37
+ p_from: request.from ?? null,
38
+ p_to: request.to ?? null,
39
+ p_sort: request.sort,
40
+ // Default false: the queue hides withdrawn rows unless the operator asks.
41
+ // The RPC declares no parameter defaults, so this must always be sent.
42
+ p_include_withdrawn: request.includeWithdrawn ?? false,
43
+ });
44
+ if (error) throw queueSelectionError(error);
45
+ return parseQueueSelection(options.projectResult?.(data) ?? data, options.currency ?? neutralOmsCurrencyPolicy, options.matchSchema);
46
+ }
47
+
48
+ // A cross-currency paid set is a refusal the RPC raises on purpose, not a
49
+ // generic read failure: it names an operator-visible condition (two currencies
50
+ // in one dashboard total) that a retry will not clear. Keep it distinguishable.
51
+ function queueSelectionError(error: RpcError): CommerceOmsPersistenceError {
52
+ const raised = `${error.message ?? ""} ${error.details ?? ""} ${error.hint ?? ""}`;
53
+ if (raised.includes(MIXED_CURRENCY_REFUSAL)) {
54
+ return new CommerceOmsPersistenceError(
55
+ "Commerce OMS queue summary spans more than one currency",
56
+ { reason: MIXED_CURRENCY_REFUSAL },
57
+ );
58
+ }
59
+ return new CommerceOmsPersistenceError("Commerce OMS queue selection read failed");
60
+ }
61
+
62
+ function parseQueueSelection(data: unknown, currency: OmsCurrencyPolicy, matchSchema: MatchSchema = omsOrderSearchMatchSchema): QueueSelection {
63
+ const record = isRecord(data) ? data : {};
64
+ const orderIds = Array.isArray(record.orderIds)
65
+ ? record.orderIds.filter((id): id is string => typeof id === "string")
66
+ : [];
67
+ const totalCount = Number(record.totalCount ?? 0);
68
+ const summaryCounts = omsOrderListSummaryCountsSchema.parse({
69
+ ...ZERO_SUMMARY_COUNTS,
70
+ ...(isRecord(record.summaryCounts) ? record.summaryCounts : {}),
71
+ });
72
+ const summaryTotals = omsOrderListSummaryTotalsSchema.parse({
73
+ gmv: { amountMinor: 0, currency: currency.defaultCurrency },
74
+ aov: { amountMinor: 0, currency: currency.defaultCurrency },
75
+ orderCount: 0, paidSubscriptionCycleCount: 0,
76
+ ...normalizeSummaryTotals(isRecord(record.summaryTotals) ? record.summaryTotals : {}, currency),
77
+ });
78
+ const matches = parseMatches(record.matches, matchSchema);
79
+ if (!Number.isInteger(totalCount) || totalCount < 0) {
80
+ throw new CommerceOmsPersistenceError("Commerce OMS queue selection count invalid");
81
+ }
82
+ return { orderIds, totalCount, matches, summaryCounts, summaryTotals };
83
+ }
84
+
85
+ function parseMatches(value: unknown, schema: MatchSchema): Record<string, AdminOmsOrderSearchMatch> {
86
+ if (!isRecord(value)) return {};
87
+ return Object.fromEntries(
88
+ Object.entries(value).flatMap(([orderId, match]) => {
89
+ const parsed = schema.safeParse(match);
90
+ return parsed.success ? [[orderId, parsed.data]] : [];
91
+ }),
92
+ );
93
+ }
94
+
95
+ function isRecord(value: unknown): value is Record<string, unknown> {
96
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
97
+ }
98
+
99
+ // The queue RPC still emits the legacy `newSubscriptionCount` JSON key. It counts
100
+ // PAID subscription cycles (the initial checkout cycle #1 plus every paid renewal),
101
+ // so map it onto the accurately-named `paidSubscriptionCycleCount` contract field.
102
+ // The new key is accepted too, so a future RPC rename is a no-op here.
103
+ function normalizeSummaryTotals(raw: Record<string, unknown>, currency: OmsCurrencyPolicy): Record<string, unknown> {
104
+ const { newSubscriptionCount, gmv, aov, ...rest } = raw;
105
+ const normalized: Record<string, unknown> = { ...rest };
106
+ if (gmv !== undefined) normalized.gmv = withDefaultCurrency(gmv, currency);
107
+ if (aov !== undefined) normalized.aov = withDefaultCurrency(aov, currency);
108
+ if (newSubscriptionCount !== undefined) {
109
+ normalized.paidSubscriptionCycleCount = normalized.paidSubscriptionCycleCount ?? newSubscriptionCount;
110
+ }
111
+ return normalized;
112
+ }
113
+
114
+ // The queue RPC no longer names a currency: `min(currency)` over an EMPTY paid
115
+ // set is NULL by design, so the schema stays currency-agnostic. Labelling a
116
+ // zero total is a platform-policy decision, and policy has exactly one home.
117
+ function withDefaultCurrency(money: unknown, currency: OmsCurrencyPolicy): unknown {
118
+ if (!isRecord(money) || money.currency != null) return money;
119
+ return { ...money, currency: currency.defaultCurrency };
120
+ }
121
+
122
+ const ZERO_SUMMARY_COUNTS: AdminOmsOrderListSummaryCounts = {
123
+ needsAttention: 0,
124
+ activeHold: 0,
125
+ readyForFulfillment: 0,
126
+ paymentIssues: 0,
127
+ inventoryRisk: 0,
128
+ fulfillmentBlocked: 0,
129
+ fulfillmentExceptions: 0,
130
+ invoiceIssues: 0,
131
+ providerDispatchedNotPicked: 0,
132
+ };
@@ -0,0 +1,22 @@
1
+ import type { OmsManagedReadProjections } from "../../../contracts/omsTypes.js";
2
+ export type { OmsManagedReadProjections } from "../../../contracts/omsTypes.js";
3
+ import type { OmsReadModelProjections } from "../../../model/omsReadModelProjections.js";
4
+ import type { OmsOrderDetail } from "../../../oms/omsContracts.js";
5
+ import type { OmsOrderRow, OmsOrderItemRow, OmsPaymentIntentRow, OmsAccountingInvoiceRow } from "../../../model/omsReadModelRows.js";
6
+ import type { OmsFulfillmentOperationRow, OmsFulfillmentOrderRow, OmsProviderDispatchRefRow, OmsProviderStatusEvidenceRow, OmsProviderAttemptRow, OmsReleasedProviderExceptionHoldRow } from "../../../model/omsFulfillmentSummary.js";
7
+ import type { OmsInboundProviderEventRow, OmsFulfillmentProviderStockCurrentRow } from "../../../model/omsFulfillmentDebug.js";
8
+ import type { CommerceOmsStore } from "./types.js";
9
+
10
+ export const emptyOmsManagedReadProjections = {
11
+ readIdentity: async (): Promise<Record<string, Record<string, unknown>>> => ({}),
12
+ mapInvoice: (value: unknown) => value as OmsAccountingInvoiceRow,
13
+ readFulfillmentOperations: async () => [],
14
+ readProviderDispatchRefs: async () => [],
15
+ readProviderStatusEvidence: async () => [],
16
+ readProviderAttempts: async () => [],
17
+ readReleasedProviderExceptionHolds: async () => [],
18
+ readProviderStockCurrent: async () => [],
19
+ readInboundEvents: async () => [],
20
+ buildHealth: (input: { order: OmsOrderRow }): OmsOrderDetail["fulfillmentHealth"] => ({ healthStatus: "ok", attentionReasons: [], oldestAgeSeconds: null, opaqueIds: { orderId: input.order.id, fulfillmentOrderId: null, outboxEventId: null, dispatchRefFulfillmentOrderId: null, latestEvidenceFulfillmentOrderId: null } }),
21
+ buildHealthDigests: () => ({}),
22
+ };