@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.
- package/CHANGELOG.md +156 -440
- package/README.md +230 -11
- package/dist/commerce/adapters/managed/commerceOmsControlPlane.d.ts +3 -0
- package/dist/commerce/adapters/managed/commerceOmsControlPlane.js +71 -0
- package/dist/commerce/adapters/managed/commerceOmsMutations.d.ts +10 -0
- package/dist/commerce/adapters/managed/commerceOmsMutations.js +119 -0
- package/dist/commerce/adapters/managed/commerceOmsPort.d.ts +28 -0
- package/dist/commerce/adapters/managed/commerceOmsPort.js +101 -0
- package/dist/commerce/adapters/managed/oms/accounting.d.ts +3 -0
- package/dist/commerce/adapters/managed/oms/accounting.js +13 -0
- package/dist/commerce/adapters/managed/oms/fulfillmentReads.d.ts +17 -0
- package/dist/commerce/adapters/managed/oms/fulfillmentReads.js +81 -0
- package/dist/commerce/adapters/managed/oms/inboundEvents.d.ts +9 -0
- package/dist/commerce/adapters/managed/oms/inboundEvents.js +40 -0
- package/dist/commerce/adapters/managed/oms/outboxEvents.d.ts +2 -0
- package/dist/commerce/adapters/managed/oms/outboxEvents.js +23 -0
- package/dist/commerce/adapters/managed/oms/paymentAttempts.d.ts +3 -0
- package/dist/commerce/adapters/managed/oms/paymentAttempts.js +15 -0
- package/dist/commerce/adapters/managed/oms/queueSelection.d.ts +12 -0
- package/dist/commerce/adapters/managed/oms/queueSelection.js +109 -0
- package/dist/commerce/adapters/managed/oms/readProjections.d.ts +18 -0
- package/dist/commerce/adapters/managed/oms/readProjections.js +13 -0
- package/dist/commerce/adapters/managed/oms/readQueries.d.ts +16 -0
- package/dist/commerce/adapters/managed/oms/readQueries.js +276 -0
- package/dist/commerce/adapters/managed/oms/types.d.ts +2 -0
- package/dist/commerce/adapters/managed/oms/types.js +7 -0
- package/dist/commerce/checkoutCommandSchemas.d.ts +89 -0
- package/dist/commerce/checkoutCommandSchemas.js +70 -0
- package/dist/commerce/checkoutHelpers.d.ts +21 -0
- package/dist/commerce/checkoutHelpers.js +29 -0
- package/dist/commerce/checkoutResumeSchemas.d.ts +158 -0
- package/dist/commerce/checkoutResumeSchemas.js +145 -0
- package/dist/commerce/checkoutSchemas.d.ts +158 -0
- package/dist/commerce/checkoutSchemas.js +161 -0
- package/dist/commerce/commerceReturnsPort.d.ts +97 -0
- package/dist/commerce/commerceReturnsPort.js +39 -0
- package/dist/commerce/configuratorIntentPersistenceSchemas.d.ts +20 -0
- package/dist/commerce/configuratorIntentPersistenceSchemas.js +21 -0
- package/dist/commerce/configuratorIntentSchemas.d.ts +63 -0
- package/dist/commerce/configuratorIntentSchemas.js +43 -0
- package/dist/commerce/contractPrimitives.d.ts +50 -0
- package/dist/commerce/contractPrimitives.js +25 -0
- package/dist/commerce/contracts/availability.d.ts +23 -0
- package/dist/commerce/contracts/availability.js +1 -0
- package/dist/commerce/contracts/fulfillmentRecovery.d.ts +25 -0
- package/dist/commerce/contracts/fulfillmentRecovery.js +1 -0
- package/dist/commerce/contracts/index.d.ts +13 -0
- package/dist/commerce/contracts/index.js +1 -0
- package/dist/commerce/contracts/intent.d.ts +86 -0
- package/dist/commerce/contracts/intent.js +1 -0
- package/dist/commerce/contracts/omsTypes.d.ts +1216 -0
- package/dist/commerce/contracts/omsTypes.js +1 -0
- package/dist/commerce/contracts/order.d.ts +39 -0
- package/dist/commerce/contracts/order.js +1 -0
- package/dist/commerce/contracts/orderMoney.d.ts +52 -0
- package/dist/commerce/contracts/orderMoney.js +1 -0
- package/dist/commerce/contracts/ports.d.ts +113 -0
- package/dist/commerce/contracts/ports.js +1 -0
- package/dist/commerce/contracts/recovery.d.ts +11 -0
- package/dist/commerce/contracts/recovery.js +1 -0
- package/dist/commerce/contracts/runtimePorts.d.ts +196 -0
- package/dist/commerce/contracts/runtimePorts.js +1 -0
- package/dist/commerce/contracts/state.d.ts +26 -0
- package/dist/commerce/contracts/state.js +43 -0
- package/dist/commerce/customerDefaultsSnapshotSchemas.d.ts +51 -0
- package/dist/commerce/customerDefaultsSnapshotSchemas.js +106 -0
- package/dist/commerce/errors.d.ts +18 -0
- package/dist/commerce/errors.js +36 -0
- package/dist/commerce/fulfillmentEligibility.d.ts +6 -0
- package/dist/commerce/fulfillmentEligibility.js +31 -0
- package/dist/commerce/index.d.ts +72 -0
- package/dist/commerce/index.js +67 -0
- package/dist/commerce/model/customerFulfillmentRecovery.d.ts +40 -0
- package/dist/commerce/model/customerFulfillmentRecovery.js +144 -0
- package/dist/commerce/model/fulfillmentCancellationEligibility.d.ts +7 -0
- package/dist/commerce/model/fulfillmentCancellationEligibility.js +9 -0
- package/dist/commerce/model/omsAccountingVisibility.d.ts +12 -0
- package/dist/commerce/model/omsAccountingVisibility.js +118 -0
- package/dist/commerce/model/omsBillingInvoiceBuyer.d.ts +2 -0
- package/dist/commerce/model/omsBillingInvoiceBuyer.js +15 -0
- package/dist/commerce/model/omsCurrency.d.ts +4 -0
- package/dist/commerce/model/omsCurrency.js +5 -0
- package/dist/commerce/model/omsFulfillmentDebug.d.ts +20 -0
- package/dist/commerce/model/omsFulfillmentDebug.js +122 -0
- package/dist/commerce/model/omsFulfillmentSummary.d.ts +16 -0
- package/dist/commerce/model/omsFulfillmentSummary.js +189 -0
- package/dist/commerce/model/omsListTotals.d.ts +13 -0
- package/dist/commerce/model/omsListTotals.js +32 -0
- package/dist/commerce/model/omsOperationalLadder.d.ts +51 -0
- package/dist/commerce/model/omsOperationalLadder.js +158 -0
- package/dist/commerce/model/omsOrderLineMoney.d.ts +4 -0
- package/dist/commerce/model/omsOrderLineMoney.js +25 -0
- package/dist/commerce/model/omsPaymentMethodSummary.d.ts +5 -0
- package/dist/commerce/model/omsPaymentMethodSummary.js +11 -0
- package/dist/commerce/model/omsReadModel.d.ts +43 -0
- package/dist/commerce/model/omsReadModel.js +211 -0
- package/dist/commerce/model/omsReadModelCommunication.d.ts +3 -0
- package/dist/commerce/model/omsReadModelCommunication.js +29 -0
- package/dist/commerce/model/omsReadModelHelpers.d.ts +125 -0
- package/dist/commerce/model/omsReadModelHelpers.js +212 -0
- package/dist/commerce/model/omsReadModelList.d.ts +33 -0
- package/dist/commerce/model/omsReadModelList.js +50 -0
- package/dist/commerce/model/omsReadModelListSummary.d.ts +3 -0
- package/dist/commerce/model/omsReadModelListSummary.js +13 -0
- package/dist/commerce/model/omsReadModelPricing.d.ts +5 -0
- package/dist/commerce/model/omsReadModelPricing.js +36 -0
- package/dist/commerce/model/omsReadModelProjections.d.ts +1 -0
- package/dist/commerce/model/omsReadModelProjections.js +1 -0
- package/dist/commerce/model/omsReadModelRowCore.d.ts +79 -0
- package/dist/commerce/model/omsReadModelRowCore.js +149 -0
- package/dist/commerce/model/omsReadModelRows.d.ts +1 -0
- package/dist/commerce/model/omsReadModelRows.js +6 -0
- package/dist/commerce/offerAvailability.d.ts +18 -0
- package/dist/commerce/offerAvailability.js +53 -0
- package/dist/commerce/offerAvailabilitySchemas.d.ts +43 -0
- package/dist/commerce/offerAvailabilitySchemas.js +42 -0
- package/dist/commerce/offerEvidenceSchemas.d.ts +7 -0
- package/dist/commerce/offerEvidenceSchemas.js +13 -0
- package/dist/commerce/oms/omsContractBase.d.ts +130 -0
- package/dist/commerce/oms/omsContractBase.js +86 -0
- package/dist/commerce/oms/omsContractReadAuxSchemas.d.ts +222 -0
- package/dist/commerce/oms/omsContractReadAuxSchemas.js +123 -0
- package/dist/commerce/oms/omsContractReadSchemas.d.ts +2266 -0
- package/dist/commerce/oms/omsContractReadSchemas.js +277 -0
- package/dist/commerce/oms/omsContractRequests.d.ts +196 -0
- package/dist/commerce/oms/omsContractRequests.js +118 -0
- package/dist/commerce/oms/omsContracts.d.ts +5 -0
- package/dist/commerce/oms/omsContracts.js +4 -0
- package/dist/commerce/oms/omsControlPlane.d.ts +275 -0
- package/dist/commerce/oms/omsControlPlane.js +72 -0
- package/dist/commerce/oms/omsFulfillmentContractSchemas.d.ts +203 -0
- package/dist/commerce/oms/omsFulfillmentContractSchemas.js +94 -0
- package/dist/commerce/oms/omsFulfillmentDebugSchemas.d.ts +69 -0
- package/dist/commerce/oms/omsFulfillmentDebugSchemas.js +33 -0
- package/dist/commerce/oms/omsFulfillmentHealthSchemas.d.ts +67 -0
- package/dist/commerce/oms/omsFulfillmentHealthSchemas.js +44 -0
- package/dist/commerce/oms/omsPorts.d.ts +84 -0
- package/dist/commerce/oms/omsPorts.js +148 -0
- package/dist/commerce/oms/omsPrimitives.d.ts +5 -0
- package/dist/commerce/oms/omsPrimitives.js +3 -0
- package/dist/commerce/oms/omsProviderEvidenceSchemas.d.ts +15 -0
- package/dist/commerce/oms/omsProviderEvidenceSchemas.js +12 -0
- package/dist/commerce/orderDraftErrors.d.ts +13 -0
- package/dist/commerce/orderDraftErrors.js +20 -0
- package/dist/commerce/orderEmailEligibility.d.ts +54 -0
- package/dist/commerce/orderEmailEligibility.js +123 -0
- package/dist/commerce/orderEmailLines.d.ts +12 -0
- package/dist/commerce/orderEmailLines.js +8 -0
- package/dist/commerce/orderFeedbackContracts.d.ts +41 -0
- package/dist/commerce/orderFeedbackContracts.js +33 -0
- package/dist/commerce/orderMoney.d.ts +6 -0
- package/dist/commerce/orderMoney.js +168 -0
- package/dist/commerce/orderReviewContracts.d.ts +475 -0
- package/dist/commerce/orderReviewContracts.js +94 -0
- package/dist/commerce/orderReviewPorts.d.ts +140 -0
- package/dist/commerce/orderReviewPorts.js +1 -0
- package/dist/commerce/outboxDispatchContracts.d.ts +30 -0
- package/dist/commerce/outboxDispatchContracts.js +1 -0
- package/dist/commerce/outboxEventSchemas.d.ts +162 -0
- package/dist/commerce/outboxEventSchemas.js +164 -0
- package/dist/commerce/outboxOrderDraftEmailPorts.d.ts +207 -0
- package/dist/commerce/outboxOrderDraftEmailPorts.js +12 -0
- package/dist/commerce/paymentContinuation.d.ts +4 -0
- package/dist/commerce/paymentContinuation.js +4 -0
- package/dist/commerce/ports.d.ts +8 -0
- package/dist/commerce/ports.js +1 -0
- package/dist/commerce/recoveryDestination.d.ts +3 -0
- package/dist/commerce/recoveryDestination.js +17 -0
- package/dist/commerce/runtimeErrors.d.ts +8 -0
- package/dist/commerce/runtimeErrors.js +16 -0
- package/dist/commerce/salesChannelEnvelope.d.ts +20 -0
- package/dist/commerce/salesChannelEnvelope.js +7 -0
- package/dist/commerce/schemas.d.ts +174 -0
- package/dist/commerce/schemas.js +84 -0
- package/dist/commerce/server/checkoutCompensation.d.ts +21 -0
- package/dist/commerce/server/checkoutCompensation.js +32 -0
- package/dist/commerce/server/checkoutConflictClassifiers.d.ts +17 -0
- package/dist/commerce/server/checkoutConflictClassifiers.js +38 -0
- package/dist/commerce/server/checkoutExpiredRecoveryPolicy.d.ts +38 -0
- package/dist/commerce/server/checkoutExpiredRecoveryPolicy.js +85 -0
- package/dist/commerce/server/checkoutInvoiceBuyerSnapshot.d.ts +22 -0
- package/dist/commerce/server/checkoutInvoiceBuyerSnapshot.js +30 -0
- package/dist/commerce/server/checkoutOfferPolicyPort.d.ts +33 -0
- package/dist/commerce/server/checkoutOfferPolicyPort.js +49 -0
- package/dist/commerce/server/checkoutPaymentContinuationCredential.d.ts +58 -0
- package/dist/commerce/server/checkoutPaymentContinuationCredential.js +154 -0
- package/dist/commerce/server/checkoutQuoteTypes.d.ts +19 -0
- package/dist/commerce/server/checkoutQuoteTypes.js +1 -0
- package/dist/commerce/server/checkoutRecoveryOrderPort.d.ts +42 -0
- package/dist/commerce/server/checkoutRecoveryOrderPort.js +1 -0
- package/dist/commerce/server/checkoutRecoveryToken.d.ts +40 -0
- package/dist/commerce/server/checkoutRecoveryToken.js +26 -0
- package/dist/commerce/server/checkoutRefusalContinuation.d.ts +24 -0
- package/dist/commerce/server/checkoutRefusalContinuation.js +18 -0
- package/dist/commerce/server/checkoutRuntimeTypes.d.ts +81 -0
- package/dist/commerce/server/checkoutRuntimeTypes.js +1 -0
- package/dist/commerce/server/commerceCheckoutCommandExecution.d.ts +60 -0
- package/dist/commerce/server/commerceCheckoutCommandExecution.js +136 -0
- package/dist/commerce/server/commerceCheckoutCompensation.d.ts +26 -0
- package/dist/commerce/server/commerceCheckoutCompensation.js +46 -0
- package/dist/commerce/server/commerceCheckoutContinuationTerms.d.ts +50 -0
- package/dist/commerce/server/commerceCheckoutContinuationTerms.js +66 -0
- package/dist/commerce/server/commerceCheckoutCustomerDefaults.d.ts +18 -0
- package/dist/commerce/server/commerceCheckoutCustomerDefaults.js +17 -0
- package/dist/commerce/server/commerceCheckoutFailureHandler.d.ts +51 -0
- package/dist/commerce/server/commerceCheckoutFailureHandler.js +90 -0
- package/dist/commerce/server/commerceCheckoutHandler.d.ts +213 -0
- package/dist/commerce/server/commerceCheckoutHandler.js +196 -0
- package/dist/commerce/server/commerceCheckoutHandlerAdmission.d.ts +58 -0
- package/dist/commerce/server/commerceCheckoutHandlerAdmission.js +94 -0
- package/dist/commerce/server/commerceCheckoutHandlerHelpers.d.ts +67 -0
- package/dist/commerce/server/commerceCheckoutHandlerHelpers.js +155 -0
- package/dist/commerce/server/commerceCheckoutOrchestrationError.d.ts +9 -0
- package/dist/commerce/server/commerceCheckoutOrchestrationError.js +14 -0
- package/dist/commerce/server/commerceCheckoutPromotionPriceChange.d.ts +47 -0
- package/dist/commerce/server/commerceCheckoutPromotionPriceChange.js +43 -0
- package/dist/commerce/server/commerceCheckoutProviderPayment.d.ts +34 -0
- package/dist/commerce/server/commerceCheckoutProviderPayment.js +37 -0
- package/dist/commerce/server/commerceCheckoutQuoteGuard.d.ts +62 -0
- package/dist/commerce/server/commerceCheckoutQuoteGuard.js +106 -0
- package/dist/commerce/server/commerceCheckoutResume.d.ts +29 -0
- package/dist/commerce/server/commerceCheckoutResume.js +81 -0
- package/dist/commerce/server/commerceCheckoutResumeGuard.d.ts +54 -0
- package/dist/commerce/server/commerceCheckoutResumeGuard.js +138 -0
- package/dist/commerce/server/commerceCheckoutSavedPaymentMethod.d.ts +39 -0
- package/dist/commerce/server/commerceCheckoutSavedPaymentMethod.js +44 -0
- package/dist/commerce/server/commerceCheckoutStartRuntimeFailure.d.ts +7 -0
- package/dist/commerce/server/commerceCheckoutStartRuntimeFailure.js +39 -0
- package/dist/commerce/server/commerceCheckoutTiming.d.ts +8 -0
- package/dist/commerce/server/commerceCheckoutTiming.js +31 -0
- package/dist/commerce/server/commerceDiagnostics.d.ts +6 -0
- package/dist/commerce/server/commerceDiagnostics.js +31 -0
- package/dist/commerce/server/commerceOmsCancelOrderHandler.d.ts +7 -0
- package/dist/commerce/server/commerceOmsCancelOrderHandler.js +22 -0
- package/dist/commerce/server/commerceOmsControlPlaneHandlers.d.ts +18 -0
- package/dist/commerce/server/commerceOmsControlPlaneHandlers.js +60 -0
- package/dist/commerce/server/commerceOmsHandlers.d.ts +47 -0
- package/dist/commerce/server/commerceOmsHandlers.js +176 -0
- package/dist/commerce/server/commerceOmsMarkRefundedHandler.d.ts +7 -0
- package/dist/commerce/server/commerceOmsMarkRefundedHandler.js +19 -0
- package/dist/commerce/server/commerceOrderDraft.d.ts +24 -0
- package/dist/commerce/server/commerceOrderDraft.js +92 -0
- package/dist/commerce/server/commercePaidOrderOrchestration.d.ts +131 -0
- package/dist/commerce/server/commercePaidOrderOrchestration.js +140 -0
- package/dist/commerce/server/commerceProviderAttemptFailure.d.ts +133 -0
- package/dist/commerce/server/commerceProviderAttemptFailure.js +175 -0
- package/dist/commerce/server/commerceReturnsHandlers.d.ts +41 -0
- package/dist/commerce/server/commerceReturnsHandlers.js +100 -0
- package/dist/commerce/server/commerceRuntimePort.d.ts +16 -0
- package/dist/commerce/server/commerceRuntimePort.js +57 -0
- package/dist/commerce/server/commerceRuntimeService.d.ts +98 -0
- package/dist/commerce/server/commerceRuntimeService.js +186 -0
- package/dist/commerce/server/commerceRuntimeStartResponse.d.ts +37 -0
- package/dist/commerce/server/commerceRuntimeStartResponse.js +56 -0
- package/dist/commerce/server/commerceStarterOfferGuard.d.ts +55 -0
- package/dist/commerce/server/commerceStarterOfferGuard.js +128 -0
- package/dist/commerce/server/configuratorIntentPersistence.d.ts +47 -0
- package/dist/commerce/server/configuratorIntentPersistence.js +85 -0
- package/dist/commerce/server/configuratorIntentPersistenceHandler.d.ts +14 -0
- package/dist/commerce/server/configuratorIntentPersistenceHandler.js +42 -0
- package/dist/commerce/server/emailRuntime.d.ts +47 -0
- package/dist/commerce/server/emailRuntime.js +1 -0
- package/dist/commerce/server/handlerSupport.d.ts +68 -0
- package/dist/commerce/server/handlerSupport.js +1 -0
- package/dist/commerce/server/index.d.ts +178 -0
- package/dist/commerce/server/index.js +127 -0
- package/dist/commerce/server/offerAvailability.d.ts +21 -0
- package/dist/commerce/server/offerAvailability.js +163 -0
- package/dist/commerce/server/orderDraftRpcPayload.d.ts +20 -0
- package/dist/commerce/server/orderDraftRpcPayload.js +21 -0
- package/dist/commerce/server/orderFeedbackSubmit.d.ts +20 -0
- package/dist/commerce/server/orderFeedbackSubmit.js +16 -0
- package/dist/commerce/server/orderFeedbackTokenCheck.d.ts +17 -0
- package/dist/commerce/server/orderFeedbackTokenCheck.js +14 -0
- package/dist/commerce/server/orderReviewAdminHandlers.d.ts +47 -0
- package/dist/commerce/server/orderReviewAdminHandlers.js +41 -0
- package/dist/commerce/server/orderReviewHandlers.d.ts +114 -0
- package/dist/commerce/server/orderReviewHandlers.js +42 -0
- package/dist/commerce/server/orderReviewLifecycle.d.ts +10 -0
- package/dist/commerce/server/orderReviewLifecycle.js +121 -0
- package/dist/commerce/server/orderReviewMedia.d.ts +11 -0
- package/dist/commerce/server/orderReviewMedia.js +172 -0
- package/dist/commerce/server/orderReviewRawUploadHandler.d.ts +40 -0
- package/dist/commerce/server/orderReviewRawUploadHandler.js +316 -0
- package/dist/commerce/server/outboxCheckoutExpiredEmailHandler.d.ts +14 -0
- package/dist/commerce/server/outboxCheckoutExpiredEmailHandler.js +57 -0
- package/dist/commerce/server/outboxCheckoutRecoveryEmailHandler.d.ts +13 -0
- package/dist/commerce/server/outboxCheckoutRecoveryEmailHandler.js +150 -0
- package/dist/commerce/server/outboxDispatchRegistry.d.ts +46 -0
- package/dist/commerce/server/outboxDispatchRegistry.js +184 -0
- package/dist/commerce/server/outboxDispatchRegistryComposition.d.ts +6 -0
- package/dist/commerce/server/outboxDispatchRegistryComposition.js +23 -0
- package/dist/commerce/server/outboxOrderDraftEmailHandler.d.ts +14 -0
- package/dist/commerce/server/outboxOrderDraftEmailHandler.js +130 -0
- package/dist/commerce/server/outboxOrderPaidEmailHandler.d.ts +21 -0
- package/dist/commerce/server/outboxOrderPaidEmailHandler.js +93 -0
- package/dist/commerce/server/outboxOrderPaidFulfillmentHandler.d.ts +3 -0
- package/dist/commerce/server/outboxOrderPaidFulfillmentHandler.js +1 -0
- package/dist/commerce/server/outboxOrderPaidFulfillmentPorts.d.ts +3 -0
- package/dist/commerce/server/outboxOrderPaidFulfillmentPorts.js +1 -0
- package/dist/commerce/server/outboxOrderRefundedEmailHandler.d.ts +13 -0
- package/dist/commerce/server/outboxOrderRefundedEmailHandler.js +42 -0
- package/dist/commerce/server/outboxPaymentFailedEmailHandler.d.ts +14 -0
- package/dist/commerce/server/outboxPaymentFailedEmailHandler.js +65 -0
- package/dist/commerce/server/outboxReturnEmailHandlers.d.ts +26 -0
- package/dist/commerce/server/outboxReturnEmailHandlers.js +53 -0
- package/dist/commerce/server/outboxShipmentDeliveredEmailHandler.d.ts +17 -0
- package/dist/commerce/server/outboxShipmentDeliveredEmailHandler.js +52 -0
- package/dist/commerce/server/outboxShipmentDispatchedEmailHandler.d.ts +13 -0
- package/dist/commerce/server/outboxShipmentDispatchedEmailHandler.js +87 -0
- package/dist/commerce/server/outboxShipmentExceptionEmailHandler.d.ts +13 -0
- package/dist/commerce/server/outboxShipmentExceptionEmailHandler.js +46 -0
- package/dist/commerce/server/referenceCheckoutHandler.d.ts +48 -0
- package/dist/commerce/server/referenceCheckoutHandler.js +68 -0
- package/dist/commerce/server/reservationSweepPort.d.ts +31 -0
- package/dist/commerce/server/reservationSweepPort.js +45 -0
- package/dist/commerce/server/starterTermsPort.d.ts +22 -0
- package/dist/commerce/server/starterTermsPort.js +1 -0
- package/dist/commerce/server/supabaseCommerceReturnsPort.d.ts +13 -0
- package/dist/commerce/server/supabaseCommerceReturnsPort.js +56 -0
- package/dist/communications/consentPurposeRegistry.d.ts +1 -1
- package/dist/communications/newsletterIntegrationContracts.d.ts +5 -5
- package/dist/composition/commerceContribution.d.ts +21 -0
- package/dist/composition/commerceContribution.js +27 -0
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/index.js +1 -0
- package/dist/fulfillment/handlerSchemas.d.ts +41 -41
- package/dist/fulfillment/index.d.ts +1 -1
- package/dist/fulfillment/index.js +1 -1
- package/dist/fulfillment/paidHandoff.d.ts +12 -1
- package/dist/fulfillment/paidHandoff.js +2 -2
- package/dist/fulfillment/providerDispatchWorker.d.ts +4 -4
- package/dist/identity/customerContracts.d.ts +2 -2
- package/dist/inventory/bindings.d.ts +3 -0
- package/dist/inventory/bindings.js +10 -4
- package/dist/inventory/index.d.ts +1 -0
- package/dist/inventory/index.js +1 -0
- package/dist/inventory/managedStockAvailability.d.ts +15 -0
- package/dist/inventory/managedStockAvailability.js +16 -0
- package/dist/inventory/postgresStockAvailability.js +2 -25
- package/dist/inventory/schemas.d.ts +1 -1
- package/dist/inventory/stockReadResponse.d.ts +4 -0
- package/dist/inventory/stockReadResponse.js +27 -0
- package/dist/pricing/browser/index.d.ts +6 -0
- package/dist/pricing/browser/index.js +6 -0
- package/dist/promotions/adminPromotionsContracts.d.ts +2 -2
- package/dist/subscriptions/contracts/renewal.d.ts +2 -0
- package/dist/subscriptions/index.d.ts +3 -2
- package/dist/subscriptions/index.js +3 -2
- package/dist/subscriptions/renewalCycleFailureMechanism.js +3 -2
- package/package.json +22 -2
- package/release-gates.json +63 -8
- package/src/commerce/adapters/managed/commerceOmsControlPlane.ts +80 -0
- package/src/commerce/adapters/managed/commerceOmsMutations.ts +145 -0
- package/src/commerce/adapters/managed/commerceOmsPort.ts +158 -0
- package/src/commerce/adapters/managed/oms/accounting.ts +18 -0
- package/src/commerce/adapters/managed/oms/fulfillmentReads.ts +82 -0
- package/src/commerce/adapters/managed/oms/inboundEvents.ts +45 -0
- package/src/commerce/adapters/managed/oms/outboxEvents.ts +30 -0
- package/src/commerce/adapters/managed/oms/paymentAttempts.ts +19 -0
- package/src/commerce/adapters/managed/oms/queueSelection.ts +132 -0
- package/src/commerce/adapters/managed/oms/readProjections.ts +22 -0
- package/src/commerce/adapters/managed/oms/readQueries.ts +292 -0
- package/src/commerce/adapters/managed/oms/types.ts +9 -0
- package/src/commerce/checkoutCommandSchemas.ts +93 -0
- package/src/commerce/checkoutHelpers.ts +47 -0
- package/src/commerce/checkoutResumeSchemas.ts +164 -0
- package/src/commerce/checkoutSchemas.ts +182 -0
- package/src/commerce/commerceReturnsPort.ts +67 -0
- package/src/commerce/configuratorIntentPersistenceSchemas.ts +26 -0
- package/src/commerce/configuratorIntentSchemas.ts +47 -0
- package/src/commerce/contractPrimitives.ts +30 -0
- package/src/commerce/contracts/availability.ts +21 -0
- package/src/commerce/contracts/fulfillmentRecovery.ts +26 -0
- package/src/commerce/contracts/index.ts +17 -0
- package/src/commerce/contracts/intent.ts +58 -0
- package/src/commerce/contracts/omsTypes.ts +1217 -0
- package/src/commerce/contracts/order.ts +44 -0
- package/src/commerce/contracts/orderMoney.ts +75 -0
- package/src/commerce/contracts/ports.ts +124 -0
- package/src/commerce/contracts/recovery.ts +24 -0
- package/src/commerce/contracts/runtimePorts.ts +201 -0
- package/src/commerce/contracts/state.ts +64 -0
- package/src/commerce/customerDefaultsSnapshotSchemas.ts +117 -0
- package/src/commerce/errors.ts +53 -0
- package/src/commerce/fulfillmentEligibility.ts +32 -0
- package/src/commerce/index.ts +82 -0
- package/src/commerce/model/customerFulfillmentRecovery.ts +185 -0
- package/src/commerce/model/fulfillmentCancellationEligibility.ts +18 -0
- package/src/commerce/model/omsAccountingVisibility.ts +135 -0
- package/src/commerce/model/omsBillingInvoiceBuyer.ts +20 -0
- package/src/commerce/model/omsCurrency.ts +8 -0
- package/src/commerce/model/omsFulfillmentDebug.ts +157 -0
- package/src/commerce/model/omsFulfillmentSummary.ts +225 -0
- package/src/commerce/model/omsListTotals.ts +38 -0
- package/src/commerce/model/omsOperationalLadder.ts +181 -0
- package/src/commerce/model/omsOrderLineMoney.ts +34 -0
- package/src/commerce/model/omsPaymentMethodSummary.ts +19 -0
- package/src/commerce/model/omsReadModel.ts +302 -0
- package/src/commerce/model/omsReadModelCommunication.ts +32 -0
- package/src/commerce/model/omsReadModelHelpers.ts +279 -0
- package/src/commerce/model/omsReadModelList.ts +90 -0
- package/src/commerce/model/omsReadModelListSummary.ts +19 -0
- package/src/commerce/model/omsReadModelPricing.ts +57 -0
- package/src/commerce/model/omsReadModelProjections.ts +1 -0
- package/src/commerce/model/omsReadModelRowCore.ts +193 -0
- package/src/commerce/model/omsReadModelRows.ts +7 -0
- package/src/commerce/offerAvailability.ts +75 -0
- package/src/commerce/offerAvailabilitySchemas.ts +56 -0
- package/src/commerce/offerEvidenceSchemas.ts +17 -0
- package/src/commerce/oms/omsContractBase.ts +92 -0
- package/src/commerce/oms/omsContractReadAuxSchemas.ts +130 -0
- package/src/commerce/oms/omsContractReadSchemas.ts +303 -0
- package/src/commerce/oms/omsContractRequests.ts +143 -0
- package/src/commerce/oms/omsContracts.ts +6 -0
- package/src/commerce/oms/omsControlPlane.ts +85 -0
- package/src/commerce/oms/omsFulfillmentContractSchemas.ts +113 -0
- package/src/commerce/oms/omsFulfillmentDebugSchemas.ts +38 -0
- package/src/commerce/oms/omsFulfillmentHealthSchemas.ts +46 -0
- package/src/commerce/oms/omsPorts.ts +165 -0
- package/src/commerce/oms/omsPrimitives.ts +3 -0
- package/src/commerce/oms/omsProviderEvidenceSchemas.ts +13 -0
- package/src/commerce/orderDraftErrors.ts +28 -0
- package/src/commerce/orderEmailEligibility.ts +131 -0
- package/src/commerce/orderEmailLines.ts +22 -0
- package/src/commerce/orderFeedbackContracts.ts +47 -0
- package/src/commerce/orderMoney.ts +207 -0
- package/src/commerce/orderReviewContracts.ts +124 -0
- package/src/commerce/orderReviewPorts.ts +94 -0
- package/src/commerce/outboxDispatchContracts.ts +30 -0
- package/src/commerce/outboxEventSchemas.ts +230 -0
- package/src/commerce/outboxOrderDraftEmailPorts.ts +241 -0
- package/src/commerce/paymentContinuation.ts +5 -0
- package/src/commerce/ports.ts +7 -0
- package/src/commerce/recoveryDestination.ts +23 -0
- package/src/commerce/runtimeErrors.ts +19 -0
- package/src/commerce/salesChannelEnvelope.ts +28 -0
- package/src/commerce/schemas.ts +104 -0
- package/src/commerce/server/checkoutCompensation.ts +49 -0
- package/src/commerce/server/checkoutConflictClassifiers.ts +53 -0
- package/src/commerce/server/checkoutExpiredRecoveryPolicy.ts +107 -0
- package/src/commerce/server/checkoutInvoiceBuyerSnapshot.ts +36 -0
- package/src/commerce/server/checkoutOfferPolicyPort.ts +60 -0
- package/src/commerce/server/checkoutPaymentContinuationCredential.ts +222 -0
- package/src/commerce/server/checkoutQuoteTypes.ts +9 -0
- package/src/commerce/server/checkoutRecoveryOrderPort.ts +40 -0
- package/src/commerce/server/checkoutRecoveryToken.ts +63 -0
- package/src/commerce/server/checkoutRefusalContinuation.ts +29 -0
- package/src/commerce/server/checkoutRuntimeTypes.ts +26 -0
- package/src/commerce/server/commerceCheckoutCommandExecution.ts +188 -0
- package/src/commerce/server/commerceCheckoutCompensation.ts +66 -0
- package/src/commerce/server/commerceCheckoutContinuationTerms.ts +87 -0
- package/src/commerce/server/commerceCheckoutCustomerDefaults.ts +24 -0
- package/src/commerce/server/commerceCheckoutFailureHandler.ts +144 -0
- package/src/commerce/server/commerceCheckoutHandler.ts +269 -0
- package/src/commerce/server/commerceCheckoutHandlerAdmission.ts +157 -0
- package/src/commerce/server/commerceCheckoutHandlerHelpers.ts +223 -0
- package/src/commerce/server/commerceCheckoutOrchestrationError.ts +15 -0
- package/src/commerce/server/commerceCheckoutPromotionPriceChange.ts +83 -0
- package/src/commerce/server/commerceCheckoutProviderPayment.ts +45 -0
- package/src/commerce/server/commerceCheckoutQuoteGuard.ts +172 -0
- package/src/commerce/server/commerceCheckoutResume.ts +132 -0
- package/src/commerce/server/commerceCheckoutResumeGuard.ts +195 -0
- package/src/commerce/server/commerceCheckoutSavedPaymentMethod.ts +85 -0
- package/src/commerce/server/commerceCheckoutStartRuntimeFailure.ts +59 -0
- package/src/commerce/server/commerceCheckoutTiming.ts +53 -0
- package/src/commerce/server/commerceDiagnostics.ts +37 -0
- package/src/commerce/server/commerceOmsCancelOrderHandler.ts +43 -0
- package/src/commerce/server/commerceOmsControlPlaneHandlers.ts +71 -0
- package/src/commerce/server/commerceOmsHandlers.ts +275 -0
- package/src/commerce/server/commerceOmsMarkRefundedHandler.ts +39 -0
- package/src/commerce/server/commerceOrderDraft.ts +131 -0
- package/src/commerce/server/commercePaidOrderOrchestration.ts +275 -0
- package/src/commerce/server/commerceProviderAttemptFailure.ts +257 -0
- package/src/commerce/server/commerceReturnsHandlers.ts +143 -0
- package/src/commerce/server/commerceRuntimePort.ts +75 -0
- package/src/commerce/server/commerceRuntimeService.ts +229 -0
- package/src/commerce/server/commerceRuntimeStartResponse.ts +76 -0
- package/src/commerce/server/commerceStarterOfferGuard.ts +200 -0
- package/src/commerce/server/configuratorIntentPersistence.ts +161 -0
- package/src/commerce/server/configuratorIntentPersistenceHandler.ts +54 -0
- package/src/commerce/server/emailRuntime.ts +30 -0
- package/src/commerce/server/handlerSupport.ts +22 -0
- package/src/commerce/server/index.ts +181 -0
- package/src/commerce/server/offerAvailability.ts +275 -0
- package/src/commerce/server/orderDraftRpcPayload.ts +39 -0
- package/src/commerce/server/orderFeedbackSubmit.ts +40 -0
- package/src/commerce/server/orderFeedbackTokenCheck.ts +28 -0
- package/src/commerce/server/orderReviewAdminHandlers.ts +43 -0
- package/src/commerce/server/orderReviewHandlers.ts +57 -0
- package/src/commerce/server/orderReviewLifecycle.ts +129 -0
- package/src/commerce/server/orderReviewMedia.ts +170 -0
- package/src/commerce/server/orderReviewRawUploadHandler.ts +300 -0
- package/src/commerce/server/outboxCheckoutExpiredEmailHandler.ts +86 -0
- package/src/commerce/server/outboxCheckoutRecoveryEmailHandler.ts +188 -0
- package/src/commerce/server/outboxDispatchRegistry.ts +269 -0
- package/src/commerce/server/outboxDispatchRegistryComposition.ts +31 -0
- package/src/commerce/server/outboxOrderDraftEmailHandler.ts +162 -0
- package/src/commerce/server/outboxOrderPaidEmailHandler.ts +147 -0
- package/src/commerce/server/outboxOrderPaidFulfillmentHandler.ts +4 -0
- package/src/commerce/server/outboxOrderPaidFulfillmentPorts.ts +3 -0
- package/src/commerce/server/outboxOrderRefundedEmailHandler.ts +58 -0
- package/src/commerce/server/outboxPaymentFailedEmailHandler.ts +99 -0
- package/src/commerce/server/outboxReturnEmailHandlers.ts +92 -0
- package/src/commerce/server/outboxShipmentDeliveredEmailHandler.ts +94 -0
- package/src/commerce/server/outboxShipmentDispatchedEmailHandler.ts +112 -0
- package/src/commerce/server/outboxShipmentExceptionEmailHandler.ts +73 -0
- package/src/commerce/server/referenceCheckoutHandler.ts +87 -0
- package/src/commerce/server/reservationSweepPort.ts +67 -0
- package/src/commerce/server/starterTermsPort.ts +22 -0
- package/src/commerce/server/supabaseCommerceReturnsPort.ts +81 -0
- package/src/composition/commerceContribution.ts +35 -0
- package/src/composition/index.ts +1 -0
- package/src/fulfillment/index.ts +1 -1
- package/src/fulfillment/paidHandoff.ts +2 -2
- package/src/inventory/bindings.ts +12 -4
- package/src/inventory/index.ts +1 -0
- package/src/inventory/managedStockAvailability.ts +23 -0
- package/src/inventory/postgresStockAvailability.ts +2 -21
- package/src/inventory/stockReadResponse.ts +25 -0
- package/src/pricing/browser/index.ts +6 -0
- package/src/subscriptions/contracts/renewal.ts +2 -1
- package/src/subscriptions/index.ts +3 -2
- package/src/subscriptions/renewalCycleFailureMechanism.ts +3 -1
package/README.md
CHANGED
|
@@ -10,14 +10,27 @@ Development preview. This package is part of the publishable set with core and o
|
|
|
10
10
|
|
|
11
11
|
It holds the runnable server substrate an OpenLup application composes: the Node HTTP runtime, BFF dispatch, scheduling and job leases, blob storage, data gateways, the node-postgres migration runner and bundle composition. Ports and their contracts stay in `@openlup/core/platform-runtime`.
|
|
12
12
|
|
|
13
|
-
For the prepared `0.
|
|
14
|
-
limitations](CHANGELOG.md#
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
For the prepared `0.27.0` set, read the [adjacent-release migration and known
|
|
14
|
+
limitations](CHANGELOG.md#0270) before selecting optional services. Experimental
|
|
15
|
+
commerce schemas and ports use `./commerce` and `./commerce/contracts`;
|
|
16
|
+
handlers, adapters and checkout engines use the Node-only `./commerce/server`.
|
|
17
|
+
The commerce contribution and reference binding remain inert and default-off.
|
|
18
|
+
Install the complete native chain through position 86
|
|
19
|
+
(`20261024184600_subscription_retry_candidate_payment_filter.sql`); M11 adds no
|
|
20
|
+
native SQL. Sparse SQL projections are not an install chain. Native runtime
|
|
21
|
+
roles need the ATP/exposure EXECUTE and underlying SELECT grants described in
|
|
22
|
+
the release notes.
|
|
23
|
+
Managed hosts apply the complete prefix through `20261025110000`, including
|
|
24
|
+
M11's nine forwards for preference/return ownership, operator receipts,
|
|
25
|
+
acquisition/finalize admission, ATP preview and starter graduation. Legacy
|
|
26
|
+
omitted-country input uses the configured settlement region; neutral commands
|
|
27
|
+
require explicit country. Starter graduation admits 14, 21 or 28 days; rollback
|
|
28
|
+
below that forward with a 21-day marker is unsupported, so roll forward.
|
|
29
|
+
The service-only ATP preview uses owner privileges and a fixed search path.
|
|
30
|
+
Retain exact applied failure-attempt attribution for the existing managed
|
|
31
|
+
dunning overloads; native attempt-replay parity remains registered. These
|
|
32
|
+
managed forwards authorize no host activation.
|
|
33
|
+
Preserve captured obligations and receipts on rollback.
|
|
21
34
|
M10 subscription services and contributions remain **EXPERIMENTAL and DEFAULT-OFF**.
|
|
22
35
|
Hosts explicitly supply readiness, execution, commands, mandatory G23 admission,
|
|
23
36
|
a population lease and M04 delivery. Factories activate no serving work. The inert
|
|
@@ -32,7 +45,7 @@ Adopters must not activate unselected or unready invoicing; installation and
|
|
|
32
45
|
inert contributions register no runner, worker, route or schedule.
|
|
33
46
|
M06 managed-host proof classes remain pending in the
|
|
34
47
|
[M06 parity ledger](../../docs/platform/plans/oss-m06-stock-reservations-delivery.md#parity-pending-rows).
|
|
35
|
-
Size comparison uses the published `0.
|
|
48
|
+
Size comparison uses the published `0.26.0` tarball. Preparation and offline
|
|
36
49
|
adapter evidence grant no publication or provider-account certification.
|
|
37
50
|
|
|
38
51
|
Longer module recipes live in the [platform package reference](../../docs/platform/PLATFORM_PACKAGE_REFERENCE.md).
|
|
@@ -75,13 +88,209 @@ timestamp used in the webhook's idempotency key.
|
|
|
75
88
|
| `./inventory` | Experimental schemas/ports, handlers, native stores, projection, injected forecast and SQL descriptor; `./inventory/contracts` DTOs. |
|
|
76
89
|
| `./catalog` | Experimental neutral catalog schemas, drafts, reads, media source packs and publication ports |
|
|
77
90
|
| `./catalog/contracts` | Dependency-free catalog DTOs, media resolver, authority and canonicalization helpers |
|
|
91
|
+
| `./commerce`, `./commerce/contracts` | Browser-safe neutral commerce schema cores, generic ports and pure contract helpers |
|
|
92
|
+
| `./commerce/server` | Node-only OMS, returns, native reviews/media and hosted-feedback handlers/adapters and order-detail composition, email consumers, dispatch registry, paid-fulfillment binding and checkout compensation, checkout handlers, runtime and shared paid-order saga |
|
|
78
93
|
| `./pricing` | Experimental price authority, quote computation/handlers, offer projection/cache, readiness and policy tokens |
|
|
94
|
+
| `./pricing/browser` | Existing quote primitives, acquisition validators and shipping-terms validator, browser-safe |
|
|
79
95
|
| `./pricing/contracts` | Dependency-free authority, money, quote and offer DTOs and version constants |
|
|
80
96
|
| `./promotions` | Experimental promotion application, admin handlers, native read/sweep, SQL projections and acceptance |
|
|
81
97
|
| `./promotions/contracts` | Dependency-free preview and admin DTOs |
|
|
82
98
|
| `./shipping` | Experimental delivery ports, injected-schema handlers, summary/evidence; native flat-rate port + Core schema readiness |
|
|
83
99
|
| `./shipping/contracts` | Type-only delivery, pickup-point, summary and evidence DTOs |
|
|
84
100
|
|
|
101
|
+
## Commerce contracts
|
|
102
|
+
|
|
103
|
+
`./composition` exports the inert `createCommerceContribution` for the installed
|
|
104
|
+
commerce entries and selected callables. Duplicate descriptor identities refuse;
|
|
105
|
+
the [composition recipe](../../docs/platform/ARCHITECTURE_AND_EXTENSIONS.md#contributions-seams-and-readiness)
|
|
106
|
+
and [reference binding](../../docs/platform/RUNTIME_AND_SELF_HOSTING.md#opt-in-disposable-subscription-reference)
|
|
107
|
+
describe host readiness, one executor per operation and native recovery limits.
|
|
108
|
+
|
|
109
|
+
`./commerce` stays browser-safe. `./commerce/server` is the separate Node-only
|
|
110
|
+
entry for checkout engines, handlers, stores and adapters. It exports
|
|
111
|
+
`tryCompensate` and `CheckoutCompensationPort`: release the selected order's
|
|
112
|
+
reservations, attempt unstarted-promotion cancellation, then cancel the abandoned
|
|
113
|
+
order only when promotion cleanup did not succeed. Existing keys, reasons,
|
|
114
|
+
warning messages and swallowed cleanup failures are preserved. The reference
|
|
115
|
+
facade delegates to the same function; composition still owns the cleanup ports.
|
|
116
|
+
The package boundary test bundles the browser entry without Node built-ins or
|
|
117
|
+
the server subtree, and the cold consumer exercises installed compensation.
|
|
118
|
+
Starter declaration types are inferred from the `createStarterOfferGuard`
|
|
119
|
+
binding signature; the declaration interface stays internal to the engine.
|
|
120
|
+
|
|
121
|
+
The Node-only entry owns the checkout admission/quote/resume/failure sequence,
|
|
122
|
+
neutral command adapter, runtime and one paid-order saga. Composition injects
|
|
123
|
+
HTTP schemas/responder, quote and persistence ports, subject/metadata projections
|
|
124
|
+
and the existing prepared-payment execution callables. Provider roles, flow
|
|
125
|
+
selection and trusted provider-evidence classification are reference inputs.
|
|
126
|
+
Saved-method alias and recurring-mode strings are host-defined generics passed
|
|
127
|
+
unchanged through resolver, saga and runtime; the evidence schema owns its internal JSON-length bound. The reference retains
|
|
128
|
+
locale, fiscal, profile, starter-policy, request observation and status-link
|
|
129
|
+
bindings. Acquisition expectations and accepted shipping terms require quote
|
|
130
|
+
acceptance; offer asks require a bound policy. A matching owned saved epoch can
|
|
131
|
+
resume; edited or incomplete state re-quotes. Stock refusal compensates only a
|
|
132
|
+
proved pre-dispatch draft; scoped contention and uncertain dispatch carry no
|
|
133
|
+
cleanup capability. A synchronous decline stays failed and is never auto-settled.
|
|
134
|
+
Neutral finalize and one-time reservation conformance tests use recording ports;
|
|
135
|
+
atomic acquisition/finalize SQL still requires integration with its migration chain.
|
|
136
|
+
|
|
137
|
+
The server entry also owns generic order-draft, runtime-finalize, intent-persistence
|
|
138
|
+
and resume stores, cancellation adapters and reservation sweeps. Structural clients
|
|
139
|
+
retain the incumbent RPC/table calls; composition supplies frozen snapshot schemas,
|
|
140
|
+
ordered finalize arguments, response decoders and fail-open phone normalization.
|
|
141
|
+
Use `createCommerceOrderDraftRpcPort`, `createCheckoutCompensationRpcAdapter`,
|
|
142
|
+
`createCommerceCheckoutResumeQueryPort` and `createConfiguratorIntentPersistenceRpcPort`
|
|
143
|
+
with structural clients, including `ConfiguratorIntentRpcQueryClient` for intent
|
|
144
|
+
persistence. Reference bindings retain their incumbent exported factory names.
|
|
145
|
+
Verified identity overwrites submitted identity after normalization. Draft retries
|
|
146
|
+
supersede only once after an idempotency conflict; catalog refusals do not supersede.
|
|
147
|
+
Recovery classifiers inject subject admission, compare shipping terms as well as
|
|
148
|
+
money, and separate continuation, expiry policy and refused token states. Application
|
|
149
|
+
recovery projection, routes and destinations stay in the host. SQL atomicity and
|
|
150
|
+
active-subscription guards require real PostgreSQL integration; the C2 handoff
|
|
151
|
+
release check is **to be released**.
|
|
152
|
+
|
|
153
|
+
`./commerce/contracts` is a type-only, browser-safe entry for commerce-owned
|
|
154
|
+
records and generic persistence, checkout/runtime, availability, recovery and
|
|
155
|
+
offer-policy ports. It imports no pricing module. Consume pricing DTOs from
|
|
156
|
+
`./pricing/contracts` directly. Commerce does not re-export pricing DTOs; its runtime
|
|
157
|
+
reuses the version constant through `./pricing/contracts`. Quote ports take the
|
|
158
|
+
host request, response and existing options as type parameters; the reference
|
|
159
|
+
binds the existing pricing definitions, adding only the server-bound offer.
|
|
160
|
+
|
|
161
|
+
`./commerce/server` supplies the Node-only OMS handlers, managed adapters and
|
|
162
|
+
order-detail composition.
|
|
163
|
+
`./commerce` remains browser-safe, including its full runtime import closure.
|
|
164
|
+
It also owns canonical order-money validation and commerce event payload schemas.
|
|
165
|
+
The latter reuse the core outbox envelope and inject host quote/draft validators,
|
|
166
|
+
without importing an outbox worker or storage implementation.
|
|
167
|
+
The same entry owns `deriveOfferAvailability`, `defaultOfferAvailability`,
|
|
168
|
+
`availabilityBySku`, `statusForSellableNow`, `reasonCodeFor` and the low-stock
|
|
169
|
+
threshold. Their reference facades preserve function identity. The server entry's
|
|
170
|
+
`createOfferAvailabilityPort` runs the existing physical-table projection over
|
|
171
|
+
an `OfferAvailabilityQueryClient` and an injected `isStockProvider` predicate.
|
|
172
|
+
It preserves active-hold subtraction, lot/location eligibility and provider
|
|
173
|
+
missing/stale refusals. SDK narrowing and provider selection stay host-owned.
|
|
174
|
+
M06 owns normalized new-purchase reads and reservation TTL policy; the reference
|
|
175
|
+
composition passes its selected read port through unchanged. With `dataKind: "postgres"`,
|
|
176
|
+
the host supplies `stockSourceKey` to bind the native ATP reader; omission reports
|
|
177
|
+
`inventory_stock_source_key_required`. Managed composition prefers an injected
|
|
178
|
+
reader, then binds `stockRpc` over `inventory_new_purchase_stock_read`; without
|
|
179
|
+
either it reports `inventory_new_purchase_stock_reader_required`.
|
|
180
|
+
W2 conformance distinguishes reads, fallback and one-time allocation; real SQL
|
|
181
|
+
atomicity and consumption remain integration obligations.
|
|
182
|
+
|
|
183
|
+
`./commerce` provides neutral cart/order/read, checkout, intent, persistence,
|
|
184
|
+
resume and customer-default schema cores and factories. Bind existing pricing
|
|
185
|
+
schemas and explicit host vocabulary, then extend the object cores with local
|
|
186
|
+
locale, profile, sizing, fiscal and provider policy. The reference retains those
|
|
187
|
+
extensions; it does not publish that policy into the package.
|
|
188
|
+
The intent factory accepts a SKU schema with string input and output, preserving
|
|
189
|
+
string SKU inputs when hosts infer request types. Resume and availability bindings
|
|
190
|
+
also preserve string SKU and product-slug inputs. When composing host fields,
|
|
191
|
+
retain their legacy positions: object key order also determines validation issue
|
|
192
|
+
order, including nested variants and checkout requests.
|
|
193
|
+
Offer tokens are opaque; `minimumUnits` is an untrusted ask with an injected default, never an
|
|
194
|
+
admission grant. The server entry executes the offer binding and bounds its server-minted evidence.
|
|
195
|
+
The starter guard receives terms, basket/discount functions and its plan schema
|
|
196
|
+
from the host. These entries install no store, route,
|
|
197
|
+
migration or provider.
|
|
198
|
+
|
|
199
|
+
Required root discovery includes `test/commerce/`: schema refusal/replay and
|
|
200
|
+
port-fit tests join recovery/error/helper witnesses, compensation and neutral W4 composition.
|
|
201
|
+
The unchanged reference suites and a pre-extraction parse transcript protect
|
|
202
|
+
host bindings. The cold consumer imports both installed entries and checks
|
|
203
|
+
availability projection/refusal, opaque offers, injected minimums and snapshot
|
|
204
|
+
refusal without optional peers. This establishes contract proof only.
|
|
205
|
+
|
|
206
|
+
OMS schemas and pure operational builders export from browser-safe `./commerce`.
|
|
207
|
+
Order-money derivation and paid-event constants reuse the existing commerce
|
|
208
|
+
owners. `OmsOrderPaymentStatus` binds the existing generic
|
|
209
|
+
`OmsPaymentStatus<PaymentIntentStatus>` to the core payment states; the generic
|
|
210
|
+
K1 contract remains available unchanged.
|
|
211
|
+
Node-only `./commerce/server` owns the generic handlers, managed RPC/query store
|
|
212
|
+
and detail composition that uses the shipping runtime. DTOs and structural ports
|
|
213
|
+
remain in the type-only contracts entry. Inject settlement,
|
|
214
|
+
identity/presentation and provider read projections at composition. The managed
|
|
215
|
+
client requires only `rpc`; table reads and note persistence receive a separate
|
|
216
|
+
query capability, including the `is(column, value)` filter required by hydration.
|
|
217
|
+
Unprojected timeline labels use canonical step keys; hosts supply localized copy
|
|
218
|
+
through `timelineLabel`. Refund marking remains an operator mark. Replacement creation
|
|
219
|
+
uses the existing fulfillment handler and never confirms arrival or interrupts
|
|
220
|
+
an active subscription. W5/W6 tests pin replay tuples and forbidden effects.
|
|
221
|
+
|
|
222
|
+
Returns expose request, approve and reject only: `CommerceReturnsPort` and
|
|
223
|
+
its schemas are at `./commerce`; the three handler factories and
|
|
224
|
+
`createSupabaseCommerceReturnsPort` are at `./commerce/server`. `restockDisposition`, `refundMode` and
|
|
225
|
+
`refundAmountCents` record intent. Receive, restock and refund execution do not
|
|
226
|
+
exist. The host supplies authorization and a `BffResponder`; the request adapter
|
|
227
|
+
forwards the authenticated principal as `p_requested_by` to the database's owner,
|
|
228
|
+
idempotency-key and fingerprint checks.
|
|
229
|
+
The package request schema defaults to neutral reason codes. Bind a host set with
|
|
230
|
+
`createCommerceReturnsSchemas(reasonCodes)` and supply its request schema to the
|
|
231
|
+
customer handler's `requestSchema` dependency; the reference binding retains its
|
|
232
|
+
legacy set and unchanged request/refusal envelopes.
|
|
233
|
+
|
|
234
|
+
Native order-review contracts and the type-only `OrderReviewLifecyclePort` stay
|
|
235
|
+
at `./commerce`. Customer/admin handler factories, PostgreSQL lifecycle/media
|
|
236
|
+
adapters and raw uploads are exported from `./commerce/server`. Strict schemas keep
|
|
237
|
+
pending declarations distinct from stored/confirmed observed media and keep
|
|
238
|
+
storage locators out of public results. The raw upload handler accepts an
|
|
239
|
+
`OrderReviewRawUploadBinding`; metadata finalization holds its transaction across
|
|
240
|
+
the host's promotion callback. The reference host retains its private filesystem
|
|
241
|
+
object store, lease composition and reconciliation. M02 `BlobStoragePort` is not a
|
|
242
|
+
drop-in binding: it has no private read, inspection, temporary write or promotion
|
|
243
|
+
operations. K3b preserves that host seam and adds no M02 storage bridge.
|
|
244
|
+
|
|
245
|
+
Hosted feedback has its own contracts at `./commerce` and injected Supabase
|
|
246
|
+
submit/token-check ports at `./commerce/server`. This tokenized public post-delivery lifecycle is distinct from native order
|
|
247
|
+
reviews. It requires the adopter's database to provide `submit_order_feedback`
|
|
248
|
+
and `check_order_feedback_token`; native `db/platform` supplies neither RPC.
|
|
249
|
+
These ports add no route or native binding. Review-delay policy remains host-owned
|
|
250
|
+
SQL (class (b) retention): native uses 14 days and the contributed managed profile
|
|
251
|
+
uses 21 days. There is no TypeScript delay parameter or SQL change.
|
|
252
|
+
The reference browser contract facades initialize their shared Zod instance in
|
|
253
|
+
jitless mode before loading package schemas, preserving CSP-safe construction.
|
|
254
|
+
The package contracts add no global Zod configuration side effect. Browser
|
|
255
|
+
conformance bundles the complete commerce entry and both reference facades
|
|
256
|
+
without externals; the raw-upload source is a failing browser control, while
|
|
257
|
+
the complete server entry bundles for Node.
|
|
258
|
+
|
|
259
|
+
Neutral producer event contracts are exported from `./commerce`;
|
|
260
|
+
`createCommerceOutboxEventSchemas` binds the host's exact quote/draft snapshots.
|
|
261
|
+
Event-type literals and host payload behavior are preserved.
|
|
262
|
+
|
|
263
|
+
## Commerce domain effects
|
|
264
|
+
|
|
265
|
+
The experimental Node-only `./commerce/server` entry provides the transactional email
|
|
266
|
+
consumer factories, their descriptors and dispatch registry. Compose explicit
|
|
267
|
+
`uniqueRegistry` composition from `@openlup/outbox` and
|
|
268
|
+
`CommerceEmailRuntime` bindings for the fulfillment payload parser, communications
|
|
269
|
+
transactional scaffold and send-outcome mapping, plus locale, money, generic
|
|
270
|
+
line labels, paid-order presentation and tracking/notification policy. The
|
|
271
|
+
package selects no provider, country, commercial offer or environment policy.
|
|
272
|
+
Neutral email ports take the host locale as a type parameter and carry `contextName` and
|
|
273
|
+
`messageId`; the reference maps its existing extension/provider field names.
|
|
274
|
+
|
|
275
|
+
Draft, paid-email and paid-fulfillment consumers register by separate flags.
|
|
276
|
+
Fulfillment reuses M08's existing handoff and risk seam. This registry adds no
|
|
277
|
+
emitter, dispatcher, invoice executor, schedule, migration or subscription
|
|
278
|
+
mutation. Cancellation email stays unregistered; `extraHandlers` can bind the
|
|
279
|
+
independent accounting consumer. The refund consumer trusts amounts only with
|
|
280
|
+
`provider-refund.v2` evidence. Return approved/rejected are separate notices.
|
|
281
|
+
The live channel-comms policy suppresses the same buyer-facing handlers at
|
|
282
|
+
handle time, settling them as processed with `channel_owns_buyer_comms`.
|
|
283
|
+
|
|
284
|
+
The browser-safe `./commerce` entry provides event contracts, email DTOs and pure
|
|
285
|
+
projections; it never imports `./commerce/server`.
|
|
286
|
+
`projectCommerceSalesChannelEnvelope` retains opaque source identity without
|
|
287
|
+
normalization. `CommerceChannelExposureReadPort` is only a host-injected read;
|
|
288
|
+
no inventory exposure SQL or default implementation is supplied. Producer event
|
|
289
|
+
schemas bind exact host quote/draft snapshots through a factory; email consumers
|
|
290
|
+
retain frozen minimal subsets for in-flight compatibility. W8/W9 package
|
|
291
|
+
conformance and the rebound reference suites cover this boundary. UI extraction
|
|
292
|
+
and any artifact-cap change require their own approved scope.
|
|
293
|
+
|
|
85
294
|
## Shipping
|
|
86
295
|
|
|
87
296
|
Shipping handlers require injected host schemas; contracts are type-only with opaque provider/carrier strings.
|
|
@@ -95,7 +304,7 @@ caller-declared schema requirements. Missing proof keeps the named refusal.
|
|
|
95
304
|
|
|
96
305
|
## Inventory
|
|
97
306
|
|
|
98
|
-
`createInventoryBindings` selects one store with exact host provider validation.
|
|
307
|
+
`createInventoryBindings` selects one store with exact host provider validation. With `dataKind: "postgres"`, supply `stockSourceKey` to bind the existing native ATP new-purchase reader; without it, `unsupported.newPurchaseStockRead` reports `inventory_stock_source_key_required`. Admin reads remain ready. Preview availability subtracts all live holds, remaining subscription demand inside 14 days and channel exposure, clamped at zero. The native reader refuses a different horizon or an own-order exclusion as `native_stock_read_options_unsupported`. For managed reads, an injected reader wins; otherwise supply `stockRpc` to bind `createManagedStockAvailability` with the managed forward `20261025109000_inventory_new_purchase_stock_read.sql`. Without either dependency, the reason remains `inventory_new_purchase_stock_reader_required`. Managed previews retain provider-tagged ATP accounting and refuse other horizons or exclusions as `managed_stock_read_options_unsupported`. The managed SQL reader refuses a NULL as-of timestamp as `inventory_stock_as_of_invalid` (SQLSTATE `22023`). Their conservative stale flag is true if any provider row for the SKU is stale; ATP quantities and allocator freshness checks are unchanged. `createInventoryContribution` declares selected callables without activation.
|
|
99
308
|
|
|
100
309
|
`INVENTORY_MIGRATIONS` projects canonical units 27/33 byte-for-byte; install the full catalogue. Store support and pending proof: [M06 parity](../../docs/platform/plans/oss-m06-stock-reservations-delivery.md#parity-pending-rows).
|
|
101
310
|
|
|
@@ -182,7 +391,15 @@ base reads using the selected list ID, with base-refusal precedence.
|
|
|
182
391
|
|
|
183
392
|
`./pricing/contracts` contains dependency-free authority observations, policy
|
|
184
393
|
DTOs and version constants; its only external type comes from the exact
|
|
185
|
-
`@openlup/core/pricing` entry.
|
|
394
|
+
`@openlup/core/pricing` entry. `./pricing/browser` directly re-exports exactly
|
|
395
|
+
`createCommerceQuotePrimitives`, `acquisitionCapabilitySchema` and
|
|
396
|
+
`acquisitionTermsExpectationSchema`, `resolvedAcquisitionTermsSchema` and
|
|
397
|
+
`shippingTermsSchema`. Acquisition schemas come from their defining file; shipping
|
|
398
|
+
re-exports its pure validator owner through an exact linted edge, preserving identity
|
|
399
|
+
without handlers or Node HTTP declarations. The reference
|
|
400
|
+
quote context admits both terms as optional fields and retains its existing strict
|
|
401
|
+
fields and refusals. The complete browser bundle contains no Node imports or
|
|
402
|
+
pricing server root. Other schemas, Web Crypto hashing and Node HMAC token
|
|
186
403
|
operations stay in the server entry. Tokens retain assignment binding, the
|
|
187
404
|
72-hour default compatibility window and rollback behavior. Secret selection,
|
|
188
405
|
feature flags and readiness remain reference composition responsibilities.
|
|
@@ -822,3 +1039,5 @@ transport or query projection is host-owned. No executor is installed.
|
|
|
822
1039
|
store seller binding and managed wrappers persist its first-ever claim revision;
|
|
823
1040
|
legacy fallback and forward-only migration limits are owned by the
|
|
824
1041
|
[M09 migration section](../../docs/platform/DATA_AND_MIGRATIONS.md#m09-invoicing-forward-design-and-control-approval).
|
|
1042
|
+
|
|
1043
|
+
OMS read projections are optional. Omitting the host health classifier preserves the original unprojected empty health snapshot (`ok`, no reasons or evidence IDs); it does not evaluate provider health. The reference composition injects its existing classifier and evidence readers.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type CommerceOmsControlPlanePort } from "../../oms/omsControlPlane.js";
|
|
2
|
+
import type { CommerceOmsReadPort } from "../../oms/omsPorts.js";
|
|
3
|
+
export declare function createManagedCommerceOmsControlPlanePort(managedPort: CommerceOmsReadPort): CommerceOmsControlPlanePort;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { OMS_CONTROL_PLANE_VERSION, omsControlPlaneActions, omsControlPlaneDetailResponseSchema, omsControlPlaneListResponseSchema, } from "../../oms/omsControlPlane.js";
|
|
2
|
+
export function createManagedCommerceOmsControlPlanePort(managedPort) {
|
|
3
|
+
return {
|
|
4
|
+
async listOrders(request) {
|
|
5
|
+
const result = await managedPort.listOrders({
|
|
6
|
+
page: request.page,
|
|
7
|
+
pageSize: request.pageSize,
|
|
8
|
+
status: request.status,
|
|
9
|
+
sort: "created_desc",
|
|
10
|
+
});
|
|
11
|
+
return omsControlPlaneListResponseSchema.parse({
|
|
12
|
+
contractVersion: OMS_CONTROL_PLANE_VERSION,
|
|
13
|
+
orders: result.orders.map(mapOrder),
|
|
14
|
+
totalCount: result.totalCount,
|
|
15
|
+
page: result.page,
|
|
16
|
+
pageSize: result.pageSize,
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
async getOrderDetail(request) {
|
|
20
|
+
const result = await managedPort.getOrderDetail({ orderId: request.orderId });
|
|
21
|
+
if (!result)
|
|
22
|
+
return null;
|
|
23
|
+
const operation = (type) => {
|
|
24
|
+
if (type === "hold_created" || type === "hold_released")
|
|
25
|
+
return type;
|
|
26
|
+
if (type === "order_cancelled_manual")
|
|
27
|
+
return "order_cancelled";
|
|
28
|
+
if (type === "order_marked_refunded")
|
|
29
|
+
return "order_refunded";
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
return omsControlPlaneDetailResponseSchema.parse({
|
|
33
|
+
contractVersion: OMS_CONTROL_PLANE_VERSION,
|
|
34
|
+
order: mapOrder(result.order),
|
|
35
|
+
holds: result.order.holds.map((hold) => ({
|
|
36
|
+
id: hold.id,
|
|
37
|
+
status: hold.status,
|
|
38
|
+
reason: hold.reason,
|
|
39
|
+
note: hold.note,
|
|
40
|
+
createdAt: hold.createdAt,
|
|
41
|
+
releasedAt: hold.releasedAt,
|
|
42
|
+
})),
|
|
43
|
+
operations: result.order.operations.flatMap((entry) => {
|
|
44
|
+
const action = operation(entry.type);
|
|
45
|
+
return action ? [{
|
|
46
|
+
id: entry.id,
|
|
47
|
+
action,
|
|
48
|
+
holdId: entry.holdId,
|
|
49
|
+
actorId: entry.actorUserId,
|
|
50
|
+
occurredAt: entry.occurredAt,
|
|
51
|
+
}] : [];
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function mapOrder(order) {
|
|
58
|
+
return {
|
|
59
|
+
orderId: order.orderId,
|
|
60
|
+
status: order.status,
|
|
61
|
+
sourceKind: order.sourceKind ?? "storefront",
|
|
62
|
+
sourceOrderRef: order.sourceOrderRef ?? null,
|
|
63
|
+
money: order.total,
|
|
64
|
+
shipmentStatus: order.fulfillmentStatus,
|
|
65
|
+
activeHoldCount: order.activeHoldCount,
|
|
66
|
+
activeHoldReasons: order.activeHoldReasons,
|
|
67
|
+
actions: omsControlPlaneActions(order.status, order.activeHoldCount),
|
|
68
|
+
createdAt: order.createdAt,
|
|
69
|
+
updatedAt: order.updatedAt,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AdminCommerceOrderNoteRequest, AdminCommerceOrderNoteResponse, AdminCommerceOrderUpdateShippingAddressRequest, AdminCommerceOrderUpdateShippingAddressResponse } from "../../oms/omsContracts.js";
|
|
2
|
+
import type { CommerceOmsRpcClient, CommerceOmsStore, RpcError } from "./oms/types.js";
|
|
3
|
+
export declare function addCommerceOmsNote(client: CommerceOmsStore, request: AdminCommerceOrderNoteRequest & {
|
|
4
|
+
actorUserId: string;
|
|
5
|
+
}): Promise<AdminCommerceOrderNoteResponse>;
|
|
6
|
+
export declare function updateCommerceOmsShippingAddress(client: CommerceOmsRpcClient, request: AdminCommerceOrderUpdateShippingAddressRequest & {
|
|
7
|
+
actorUserId: string;
|
|
8
|
+
}): Promise<AdminCommerceOrderUpdateShippingAddressResponse>;
|
|
9
|
+
export declare function callOmsRpc<T>(client: CommerceOmsRpcClient, functionName: string, args: Record<string, unknown>): Promise<T>;
|
|
10
|
+
export declare function mapRpcError(error: RpcError): Error;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { COMMERCE_CONTRACT_VERSION } from "../../../pricing/contracts/index.js";
|
|
2
|
+
import { CommerceOmsConflictError, CommerceOmsPersistenceError, } from "../../oms/omsPorts.js";
|
|
3
|
+
const OPERATION_COLUMNS = "id, order_id, operation_type, hold_id, actor_user_id, occurred_at, payload";
|
|
4
|
+
export async function addCommerceOmsNote(client, request) {
|
|
5
|
+
const insertResult = await client
|
|
6
|
+
.query("commerce_order_operations")
|
|
7
|
+
.insert({
|
|
8
|
+
order_id: request.orderId,
|
|
9
|
+
actor_user_id: request.actorUserId,
|
|
10
|
+
operation_type: "support_note",
|
|
11
|
+
idempotency_key: request.idempotencyKey,
|
|
12
|
+
payload: { note: request.note, metadata: request.metadata ?? {}, source: "commerce.oms.v0" },
|
|
13
|
+
})
|
|
14
|
+
.select(OPERATION_COLUMNS)
|
|
15
|
+
.maybeSingle();
|
|
16
|
+
if (insertResult.error) {
|
|
17
|
+
if (insertResult.error.code === "23505") {
|
|
18
|
+
const replayResult = await client
|
|
19
|
+
.query("commerce_order_operations")
|
|
20
|
+
.select(OPERATION_COLUMNS)
|
|
21
|
+
.eq("idempotency_key", request.idempotencyKey)
|
|
22
|
+
.maybeSingle();
|
|
23
|
+
if (replayResult.error || !replayResult.data)
|
|
24
|
+
throw mapRpcError(insertResult.error);
|
|
25
|
+
return noteResponse(replayResult.data, true);
|
|
26
|
+
}
|
|
27
|
+
throw mapRpcError(insertResult.error);
|
|
28
|
+
}
|
|
29
|
+
return noteResponse(insertResult.data, false);
|
|
30
|
+
}
|
|
31
|
+
export async function updateCommerceOmsShippingAddress(client, request) {
|
|
32
|
+
return callOmsRpc(client, "commerce_oms_update_shipping_address", {
|
|
33
|
+
p_idempotency_key: request.idempotencyKey,
|
|
34
|
+
p_order_id: request.orderId,
|
|
35
|
+
p_address: request.address,
|
|
36
|
+
p_actor_user_id: request.actorUserId,
|
|
37
|
+
p_metadata: {
|
|
38
|
+
...(request.metadata ?? {}),
|
|
39
|
+
_deliveryContactExpectedRevision: request.expectedRevision,
|
|
40
|
+
_deliveryContactExpectedDigest: request.expectedContactDigest,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// Every OMS control RPC answers the same way: the function's own jsonb response,
|
|
45
|
+
// or a Postgres error this module already knows how to classify. The cast is not
|
|
46
|
+
// a validation step and never was - it is recorded here once instead of at each
|
|
47
|
+
// call site, so tightening it later is one edit.
|
|
48
|
+
export async function callOmsRpc(client, functionName, args) {
|
|
49
|
+
const { data, error } = await client.rpc(functionName, args);
|
|
50
|
+
if (error)
|
|
51
|
+
throw mapRpcError(error);
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* SQLSTATE 55P03. A routine here gave up waiting for a lock another writer holds
|
|
56
|
+
* and returned before touching anything - not a failure, a refusal, and the same
|
|
57
|
+
* request may be sent again unchanged.
|
|
58
|
+
*
|
|
59
|
+
* It is read from the code rather than the message because the server's text for
|
|
60
|
+
* it ("canceling statement due to lock timeout") names no routine of ours, so
|
|
61
|
+
* there is nothing for `readShippingAddressReason` to match on. The reason stays
|
|
62
|
+
* routine-neutral for the same span the mapper covers: today only the shipping
|
|
63
|
+
* address correction bounds its waits, but this classification is true of any OMS
|
|
64
|
+
* routine that later does, and a `delivery_contact_` prefix would be a lie the
|
|
65
|
+
* day one of the hold routines raises it.
|
|
66
|
+
*/
|
|
67
|
+
const LOCK_TIMEOUT_SQLSTATE = "55P03";
|
|
68
|
+
export function mapRpcError(error) {
|
|
69
|
+
const text = [error.message, error.details, error.hint].filter(Boolean).join(" ");
|
|
70
|
+
if (error.code === LOCK_TIMEOUT_SQLSTATE) {
|
|
71
|
+
return new CommerceOmsConflictError("Commerce OMS request could not take its locks", {
|
|
72
|
+
code: error.code,
|
|
73
|
+
reason: "lock_timeout",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const shippingAddressReason = readShippingAddressReason(text);
|
|
77
|
+
if (shippingAddressReason) {
|
|
78
|
+
return new CommerceOmsConflictError("Commerce OMS shipping address update blocked", {
|
|
79
|
+
code: error.code,
|
|
80
|
+
reason: shippingAddressReason,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (error.code === "23505" ||
|
|
84
|
+
/(?:commerce_oms_|commerce_order_).*(?:conflict|already|not_found|invalid_status)/.test(text)) {
|
|
85
|
+
return new CommerceOmsConflictError("Commerce OMS hold conflict", { code: error.code });
|
|
86
|
+
}
|
|
87
|
+
return new CommerceOmsPersistenceError("Commerce OMS RPC failed", { code: error.code });
|
|
88
|
+
}
|
|
89
|
+
function noteResponse(operation, replayed) {
|
|
90
|
+
return {
|
|
91
|
+
contractVersion: COMMERCE_CONTRACT_VERSION,
|
|
92
|
+
operation: operationResponse(operation),
|
|
93
|
+
replayed,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function operationResponse(operation) {
|
|
97
|
+
return {
|
|
98
|
+
id: operation.id,
|
|
99
|
+
orderId: operation.order_id,
|
|
100
|
+
type: operation.operation_type,
|
|
101
|
+
holdId: operation.hold_id,
|
|
102
|
+
actorUserId: operation.actor_user_id,
|
|
103
|
+
occurredAt: operation.occurred_at,
|
|
104
|
+
payload: operation.payload,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function readShippingAddressReason(text) {
|
|
108
|
+
if (text.includes("commerce_oms_delivery_contact_stale_revision"))
|
|
109
|
+
return "delivery_contact_stale_revision";
|
|
110
|
+
if (text.includes("commerce_oms_delivery_contact_submission_started"))
|
|
111
|
+
return "delivery_contact_submission_started";
|
|
112
|
+
if (text.includes("commerce_oms_shipping_address_missing_shipping_address"))
|
|
113
|
+
return "missing_shipping_address";
|
|
114
|
+
if (text.includes("commerce_oms_shipping_address_locked_after_label"))
|
|
115
|
+
return "address_locked_after_label";
|
|
116
|
+
if (text.includes("commerce_oms_shipping_address_idempotency_conflict"))
|
|
117
|
+
return "idempotency_conflict";
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OmsActionAvailabilityFlags } from "../../model/omsReadModelHelpers.js";
|
|
2
|
+
import { type CommerceOmsHoldPort, type CommerceOmsReadPort } from "../../oms/omsPorts.js";
|
|
3
|
+
import type { OmsManagedReadProjections } from "./oms/readProjections.js";
|
|
4
|
+
import type { CommerceOmsRpcClient, CommerceOmsStore, RpcError } from "./oms/types.js";
|
|
5
|
+
export type { CommerceOmsRpcClient } from "./oms/types.js";
|
|
6
|
+
export declare function createManagedCommerceOmsPort(client: CommerceOmsRpcClient, options?: {
|
|
7
|
+
actionFlags?: OmsActionAvailabilityFlags;
|
|
8
|
+
queries?: Pick<CommerceOmsStore, "query">;
|
|
9
|
+
projections?: OmsManagedReadProjections;
|
|
10
|
+
}): CommerceOmsReadPort & CommerceOmsHoldPort;
|
|
11
|
+
/**
|
|
12
|
+
* Two outcomes, and the split is the honest one. An error naming a refusal this command can
|
|
13
|
+
* reach - its own `commerce_oms_replacement_*` names, or the reservation vocabulary raised
|
|
14
|
+
* through `inventory_reserve_order` while it mints the replacement's stock generation - is
|
|
15
|
+
* something the operator caused and can answer: it becomes a conflict carrying only the
|
|
16
|
+
* stable reason, not the SQLSTATE and not the message, because that reason is the single
|
|
17
|
+
* field the operator surface renders from. Anything else never reached a refusal at all
|
|
18
|
+
* (transport, permissions, a dead connection) and stays an upstream failure keyed by
|
|
19
|
+
* SQLSTATE, which is diagnostic and never shown as a refusal.
|
|
20
|
+
*
|
|
21
|
+
* The reservation half is the one this wave added, and it is the most likely legitimate
|
|
22
|
+
* refusal in production: the command reserves through an external stock authority, so a
|
|
23
|
+
* stockout arrives as `inventory_external_provider_insufficient_available_stock`. It carries
|
|
24
|
+
* no `commerce_oms_replacement_` prefix, matched nothing, and the operator was told to check
|
|
25
|
+
* holds that were not there. The vocabulary itself lives in
|
|
26
|
+
* `src/domains/commerce/omsPorts.ts` so the surface renders from the same list.
|
|
27
|
+
*/
|
|
28
|
+
export declare function mapReplacementRefusal(error: RpcError): Error;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CommerceOmsConflictError, CommerceOmsPersistenceError, readOmsReplacementRefusal, } from "../../oms/omsPorts.js";
|
|
2
|
+
import { addCommerceOmsNote, callOmsRpc, updateCommerceOmsShippingAddress, } from "./commerceOmsMutations.js";
|
|
3
|
+
import { getCommerceOmsOrderDetail, listCommerceOmsOrders, } from "./oms/readQueries.js";
|
|
4
|
+
export function createManagedCommerceOmsPort(client, options = {}) {
|
|
5
|
+
function readStore() {
|
|
6
|
+
if (!options.queries)
|
|
7
|
+
throw new CommerceOmsPersistenceError("Commerce OMS query capability is required");
|
|
8
|
+
return { rpc: client.rpc.bind(client), query: options.queries.query.bind(options.queries) };
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
listOrders(request) {
|
|
12
|
+
return listCommerceOmsOrders(readStore(), request, options);
|
|
13
|
+
},
|
|
14
|
+
getOrderDetail(request) {
|
|
15
|
+
return getCommerceOmsOrderDetail(readStore(), request, options);
|
|
16
|
+
},
|
|
17
|
+
async createHold(request) {
|
|
18
|
+
return callOmsRpc(client, "commerce_oms_create_hold", {
|
|
19
|
+
p_idempotency_key: request.idempotencyKey,
|
|
20
|
+
p_order_id: request.orderId,
|
|
21
|
+
p_reason: request.reason,
|
|
22
|
+
p_note: request.note ?? null,
|
|
23
|
+
p_actor_user_id: request.actorUserId,
|
|
24
|
+
p_metadata: request.metadata ?? {},
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
async releaseHold(request) {
|
|
28
|
+
return callOmsRpc(client, "commerce_oms_release_hold", {
|
|
29
|
+
p_idempotency_key: request.idempotencyKey,
|
|
30
|
+
p_hold_id: request.holdId,
|
|
31
|
+
p_note: request.note ?? null,
|
|
32
|
+
p_actor_user_id: request.actorUserId,
|
|
33
|
+
p_metadata: request.metadata ?? {},
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
addNote(request) {
|
|
37
|
+
return addCommerceOmsNote(readStore(), request);
|
|
38
|
+
},
|
|
39
|
+
updateShippingAddress(request) {
|
|
40
|
+
return updateCommerceOmsShippingAddress(client, request);
|
|
41
|
+
},
|
|
42
|
+
async markRefunded(request) {
|
|
43
|
+
return callOmsRpc(client, "commerce_order_mark_refunded_manual", {
|
|
44
|
+
p_idempotency_key: request.idempotencyKey,
|
|
45
|
+
p_order_id: request.orderId,
|
|
46
|
+
p_reason: request.reason,
|
|
47
|
+
p_actor_user_id: request.actorUserId,
|
|
48
|
+
p_metadata: request.metadata ?? {},
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
async requestReplacementShipment(request) {
|
|
52
|
+
// Deliberately not `callOmsRpc`: that helper classifies through the shared
|
|
53
|
+
// `mapRpcError`, whose catch-all would collapse thirteen distinct refusals
|
|
54
|
+
// into one anonymous "hold conflict". This command's whole operator value is
|
|
55
|
+
// being told *which* refusal it hit, so the raw error is read here.
|
|
56
|
+
const { data, error } = await client.rpc("commerce_oms_request_replacement_shipment", {
|
|
57
|
+
p_idempotency_key: request.idempotencyKey,
|
|
58
|
+
p_order_id: request.orderId,
|
|
59
|
+
p_reason: request.reason,
|
|
60
|
+
p_actor_user_id: request.actorUserId,
|
|
61
|
+
p_metadata: request.metadata ?? {},
|
|
62
|
+
});
|
|
63
|
+
if (error)
|
|
64
|
+
throw mapReplacementRefusal(error);
|
|
65
|
+
return data;
|
|
66
|
+
},
|
|
67
|
+
async cancelOrder(request) {
|
|
68
|
+
return callOmsRpc(client, "commerce_oms_cancel_unpaid_order", {
|
|
69
|
+
p_idempotency_key: request.idempotencyKey,
|
|
70
|
+
p_order_id: request.orderId,
|
|
71
|
+
p_reason: request.reason,
|
|
72
|
+
p_actor_user_id: request.actorUserId,
|
|
73
|
+
p_metadata: request.metadata ?? {},
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Two outcomes, and the split is the honest one. An error naming a refusal this command can
|
|
80
|
+
* reach - its own `commerce_oms_replacement_*` names, or the reservation vocabulary raised
|
|
81
|
+
* through `inventory_reserve_order` while it mints the replacement's stock generation - is
|
|
82
|
+
* something the operator caused and can answer: it becomes a conflict carrying only the
|
|
83
|
+
* stable reason, not the SQLSTATE and not the message, because that reason is the single
|
|
84
|
+
* field the operator surface renders from. Anything else never reached a refusal at all
|
|
85
|
+
* (transport, permissions, a dead connection) and stays an upstream failure keyed by
|
|
86
|
+
* SQLSTATE, which is diagnostic and never shown as a refusal.
|
|
87
|
+
*
|
|
88
|
+
* The reservation half is the one this wave added, and it is the most likely legitimate
|
|
89
|
+
* refusal in production: the command reserves through an external stock authority, so a
|
|
90
|
+
* stockout arrives as `inventory_external_provider_insufficient_available_stock`. It carries
|
|
91
|
+
* no `commerce_oms_replacement_` prefix, matched nothing, and the operator was told to check
|
|
92
|
+
* holds that were not there. The vocabulary itself lives in
|
|
93
|
+
* `src/domains/commerce/omsPorts.ts` so the surface renders from the same list.
|
|
94
|
+
*/
|
|
95
|
+
export function mapReplacementRefusal(error) {
|
|
96
|
+
const reason = readOmsReplacementRefusal([error.message, error.details, error.hint].filter(Boolean).join(" "));
|
|
97
|
+
if (!reason) {
|
|
98
|
+
return new CommerceOmsPersistenceError("Commerce OMS replacement request failed", { code: error.code });
|
|
99
|
+
}
|
|
100
|
+
return new CommerceOmsConflictError("Commerce OMS replacement request refused", { reason });
|
|
101
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { OmsAccountingInvoiceRow, OmsAccountingOutboxRow } from "../../../model/omsReadModel.js";
|
|
2
|
+
import type { CommerceOmsStore } from "./types.js";
|
|
3
|
+
export declare function readAccountingOutbox(client: CommerceOmsStore, invoices: OmsAccountingInvoiceRow[]): Promise<OmsAccountingOutboxRow[]>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommerceOmsPersistenceError } from "../../../oms/omsPorts.js";
|
|
2
|
+
export async function readAccountingOutbox(client, invoices) {
|
|
3
|
+
const result = invoices.length
|
|
4
|
+
? await client
|
|
5
|
+
.query("accounting_invoice_issue_outbox")
|
|
6
|
+
.select("invoice_id, status, attempt_count, next_attempt_at, last_error, created_at")
|
|
7
|
+
.in("invoice_id", invoices.map((invoice) => invoice.id))
|
|
8
|
+
.order("created_at", { ascending: false })
|
|
9
|
+
: { data: [], error: null };
|
|
10
|
+
if (result.error)
|
|
11
|
+
throw new CommerceOmsPersistenceError("Commerce OMS accounting outbox list read failed");
|
|
12
|
+
return (result.data ?? []);
|
|
13
|
+
}
|