@openlup/platform 0.26.0 → 0.28.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 +305 -327
- package/README.md +332 -16
- package/dist/account-support/accountReadFacade.d.ts +8 -0
- package/dist/account-support/accountReadFacade.js +10 -0
- package/dist/account-support/accountReadModels.d.ts +69 -0
- package/dist/account-support/accountReadModels.js +272 -0
- package/dist/account-support/bindings.d.ts +23 -0
- package/dist/account-support/bindings.js +16 -0
- package/dist/account-support/contracts/account.d.ts +281 -0
- package/dist/account-support/contracts/account.js +1 -0
- package/dist/account-support/contracts/capabilities.d.ts +44 -0
- package/dist/account-support/contracts/capabilities.js +1 -0
- package/dist/account-support/contracts/commands.d.ts +307 -0
- package/dist/account-support/contracts/commands.js +1 -0
- package/dist/account-support/contracts/customer360.d.ts +154 -0
- package/dist/account-support/contracts/customer360.js +1 -0
- package/dist/account-support/contracts/index.d.ts +10 -0
- package/dist/account-support/contracts/index.js +1 -0
- package/dist/account-support/contracts/invoice.d.ts +79 -0
- package/dist/account-support/contracts/invoice.js +1 -0
- package/dist/account-support/contracts/operator.d.ts +289 -0
- package/dist/account-support/contracts/operator.js +1 -0
- package/dist/account-support/contribution.d.ts +24 -0
- package/dist/account-support/contribution.js +22 -0
- package/dist/account-support/customer360.d.ts +106 -0
- package/dist/account-support/customer360.js +163 -0
- package/dist/account-support/customerAccountReadDiagnostics.d.ts +11 -0
- package/dist/account-support/customerAccountReadDiagnostics.js +71 -0
- package/dist/account-support/index.d.ts +26 -0
- package/dist/account-support/index.js +15 -0
- package/dist/account-support/invoiceAccess.d.ts +57 -0
- package/dist/account-support/invoiceAccess.js +40 -0
- package/dist/account-support/migrations.d.ts +14 -0
- package/dist/account-support/migrations.js +7 -0
- package/dist/account-support/operatorAuthority.d.ts +67 -0
- package/dist/account-support/operatorAuthority.js +379 -0
- package/dist/account-support/operatorRecovery.d.ts +66 -0
- package/dist/account-support/operatorRecovery.js +129 -0
- package/dist/account-support/orderHistory.d.ts +50 -0
- package/dist/account-support/orderHistory.js +188 -0
- package/dist/account-support/paymentMethodComposition.d.ts +5 -0
- package/dist/account-support/paymentMethodComposition.js +4 -0
- package/dist/account-support/postgresOperatorAuthority.d.ts +16 -0
- package/dist/account-support/postgresOperatorAuthority.js +93 -0
- package/dist/account-support/selfService.d.ts +6 -0
- package/dist/account-support/selfService.js +81 -0
- package/dist/account-support/subscriptionCommandCodec.d.ts +10 -0
- package/dist/account-support/subscriptionCommandCodec.js +38 -0
- package/dist/catalog/draftSchemas.d.ts +1 -1
- package/dist/catalog/foundationSchemas.d.ts +3 -3
- package/dist/catalog/resolvedSkuProjection.d.ts +2 -2
- package/dist/catalog/sellableSchemas.d.ts +2 -2
- 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 +10 -10
- package/dist/composition/accountSupportContribution.d.ts +18 -0
- package/dist/composition/accountSupportContribution.js +21 -0
- package/dist/composition/commerceContribution.d.ts +21 -0
- package/dist/composition/commerceContribution.js +27 -0
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +2 -0
- package/dist/fulfillment/handlerSchemas.d.ts +69 -69
- 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 +4 -4
- 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/invoicing/snapshot.d.ts +1 -1
- package/dist/pricing/acquisitionQuoteBinding.d.ts +1 -1
- package/dist/pricing/browser/index.d.ts +6 -0
- package/dist/pricing/browser/index.js +6 -0
- package/dist/pricing/catalogFactsSchemas.d.ts +1 -1
- package/dist/pricing/quotePromotionEvidence.d.ts +1 -1
- package/dist/pricing/quoteSchemas.d.ts +56 -56
- package/dist/promotions/adminPromotionCodesContracts.d.ts +30 -30
- package/dist/promotions/adminPromotionsContracts.d.ts +16 -16
- package/dist/subscriptions/index.d.ts +3 -2
- package/dist/subscriptions/index.js +3 -2
- package/package.json +32 -2
- package/release-gates.json +90 -8
- package/sql/20261026120000_account_support_operator_authority.sql +693 -0
- package/src/account-support/accountReadFacade.ts +15 -0
- package/src/account-support/accountReadModels.ts +371 -0
- package/src/account-support/bindings.ts +28 -0
- package/src/account-support/contracts/account.ts +306 -0
- package/src/account-support/contracts/capabilities.ts +30 -0
- package/src/account-support/contracts/commands.ts +243 -0
- package/src/account-support/contracts/customer360.ts +150 -0
- package/src/account-support/contracts/index.ts +141 -0
- package/src/account-support/contracts/invoice.ts +44 -0
- package/src/account-support/contracts/operator.ts +123 -0
- package/src/account-support/contribution.ts +35 -0
- package/src/account-support/customer360.ts +268 -0
- package/src/account-support/customerAccountReadDiagnostics.ts +83 -0
- package/src/account-support/index.ts +72 -0
- package/src/account-support/invoiceAccess.ts +63 -0
- package/src/account-support/migrations.ts +7 -0
- package/src/account-support/operatorAuthority.ts +393 -0
- package/src/account-support/operatorRecovery.ts +136 -0
- package/src/account-support/orderHistory.ts +309 -0
- package/src/account-support/paymentMethodComposition.ts +8 -0
- package/src/account-support/postgresOperatorAuthority.ts +92 -0
- package/src/account-support/selfService.ts +83 -0
- package/src/account-support/subscriptionCommandCodec.ts +48 -0
- 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/accountSupportContribution.ts +28 -0
- package/src/composition/commerceContribution.ts +35 -0
- package/src/composition/index.ts +2 -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/index.ts +3 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { SubscriptionCycleStatus } from "@openlup/core/subscription";
|
|
2
|
+
import { adminCommerceOrdersListResponseSchema,type AdminCommerceOrdersListResponse,type AdminOmsOrderSearchMatch,type AdminOmsOrderListItem as OmsOrderListItem } from "../oms/omsContracts.js";
|
|
3
|
+
import type {
|
|
4
|
+
OmsFulfillmentOperationRow,
|
|
5
|
+
OmsFulfillmentOrderRow,
|
|
6
|
+
OmsProviderDispatchRefRow,
|
|
7
|
+
OmsProviderStatusEvidenceRow,
|
|
8
|
+
OmsReleasedProviderExceptionHoldRow,
|
|
9
|
+
OmsShipmentExternalRefRow,
|
|
10
|
+
} from "./omsFulfillmentSummary.js";
|
|
11
|
+
import { summarizeOmsListTotals } from "./omsListTotals.js";
|
|
12
|
+
import { findCustomer } from "./omsReadModelHelpers.js";
|
|
13
|
+
import { summarizeOmsListOrders } from "./omsReadModelListSummary.js";
|
|
14
|
+
import type { OmsReadModelProjections } from "./omsReadModelProjections.js";
|
|
15
|
+
import { buildOmsOrderRowCore } from "./omsReadModelRowCore.js";
|
|
16
|
+
import type { OmsAccountingInvoiceRow,OmsAccountingOutboxRow,OmsCustomerRow,OmsInventoryReservationRow,OmsOrderItemRow,OmsOrderRow,OmsPaymentAttemptRow,OmsPaymentIntentRow } from "./omsReadModelRows.js";
|
|
17
|
+
import { COMMERCE_CONTRACT_VERSION } from "../../pricing/contracts/index.js";
|
|
18
|
+
|
|
19
|
+
export function buildOmsOrderListResponse(input: {
|
|
20
|
+
orders: OmsOrderRow[];
|
|
21
|
+
identityExtras?: Record<string, Record<string, unknown>>;
|
|
22
|
+
projections?: OmsReadModelProjections;
|
|
23
|
+
paymentIntents: OmsPaymentIntentRow[];
|
|
24
|
+
paymentAttempts?: OmsPaymentAttemptRow[];
|
|
25
|
+
activeHoldCounts: Record<string, number>;
|
|
26
|
+
activeHoldReasons?: Record<string, OmsOrderListItem["activeHoldReasons"]>;
|
|
27
|
+
fulfillmentHealthDigests?: Record<string, OmsOrderListItem["fulfillmentHealthDigest"]>;
|
|
28
|
+
customers?: OmsCustomerRow[];
|
|
29
|
+
orderItems?: OmsOrderItemRow[];
|
|
30
|
+
inventoryReservations?: OmsInventoryReservationRow[];
|
|
31
|
+
fulfillmentOrders?: OmsFulfillmentOrderRow[];
|
|
32
|
+
fulfillmentOperations?: OmsFulfillmentOperationRow[];
|
|
33
|
+
shipmentExternalRefs?: OmsShipmentExternalRefRow[];
|
|
34
|
+
providerDispatchRefs?: OmsProviderDispatchRefRow[];
|
|
35
|
+
providerStatusEvidence?: OmsProviderStatusEvidenceRow[];
|
|
36
|
+
releasedProviderExceptionHolds?: OmsReleasedProviderExceptionHoldRow[];
|
|
37
|
+
accountingInvoices?: OmsAccountingInvoiceRow[];
|
|
38
|
+
accountingOutbox?: OmsAccountingOutboxRow[];
|
|
39
|
+
subscriptionCycleStatuses?: Record<string, SubscriptionCycleStatus | null>;
|
|
40
|
+
searchMatches?: Record<string, AdminOmsOrderSearchMatch>;
|
|
41
|
+
summaryCounts?: AdminCommerceOrdersListResponse["summaryCounts"];
|
|
42
|
+
summaryTotals?: AdminCommerceOrdersListResponse["summaryTotals"];
|
|
43
|
+
totalCount: number;
|
|
44
|
+
page: number;
|
|
45
|
+
pageSize: number;
|
|
46
|
+
}): AdminCommerceOrdersListResponse {
|
|
47
|
+
const orders = input.orders.map((order) => {
|
|
48
|
+
// The list's only job on top of the shared core is to narrow each collection
|
|
49
|
+
// to this order; the detail hands the core the singletons it already loaded.
|
|
50
|
+
const { row: listItem } = buildOmsOrderRowCore({
|
|
51
|
+
projections: input.projections,
|
|
52
|
+
order,
|
|
53
|
+
activeHoldCount: input.activeHoldCounts[order.id] ?? 0,
|
|
54
|
+
paymentIntents: input.paymentIntents,
|
|
55
|
+
paymentAttempts: input.paymentAttempts ?? [],
|
|
56
|
+
identity: { customer: findCustomer(order, input.customers ?? []), ...input.identityExtras?.[order.id] },
|
|
57
|
+
orderItems: input.orderItems?.filter((item) => item.order_id === order.id),
|
|
58
|
+
inventoryReservations: (input.inventoryReservations ?? []).filter((reservation) => reservation.order_id === order.id),
|
|
59
|
+
fulfillmentOrders: (input.fulfillmentOrders ?? []).filter((candidate) => candidate.order_id === order.id),
|
|
60
|
+
fulfillmentOperations: input.fulfillmentOperations ?? [],
|
|
61
|
+
shipmentExternalRefs: (input.shipmentExternalRefs ?? []).filter((candidate) => candidate.order_id === order.id),
|
|
62
|
+
dispatchRefs: input.providerDispatchRefs ?? [],
|
|
63
|
+
statusEvidence: input.providerStatusEvidence ?? [],
|
|
64
|
+
releasedProviderExceptionHolds: (input.releasedProviderExceptionHolds ?? []).filter((hold) => hold.order_id === order.id),
|
|
65
|
+
accountingInvoice: (input.accountingInvoices ?? []).find((invoice) => invoice.order_id === order.id) ?? null,
|
|
66
|
+
accountingOutbox: input.accountingOutbox ?? [],
|
|
67
|
+
subscriptionCycleStatus: order.subscription_cycle_id ? input.subscriptionCycleStatuses?.[order.subscription_cycle_id] ?? null : null,
|
|
68
|
+
});
|
|
69
|
+
// Both diagnostics arrive as per-order maps built by the read that owns the
|
|
70
|
+
// rows they are derived from - the hold `reason` column for one, the health
|
|
71
|
+
// builder for the other - exactly as `activeHoldCounts` already does. A caller
|
|
72
|
+
// that supplies neither gets the quiet row it would have got before this wave.
|
|
73
|
+
const diagnostics = {
|
|
74
|
+
activeHoldReasons: input.activeHoldReasons?.[order.id] ?? [],
|
|
75
|
+
fulfillmentHealthDigest: input.fulfillmentHealthDigests?.[order.id] ?? { healthStatus: "ok" as const, attentionReasons: [] },
|
|
76
|
+
};
|
|
77
|
+
const match = input.searchMatches?.[order.id];
|
|
78
|
+
return match ? { ...listItem, ...diagnostics, match } : { ...listItem, ...diagnostics };
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return (input.projections?.parseList ?? (value => adminCommerceOrdersListResponseSchema.parse(value)))({
|
|
82
|
+
contractVersion: COMMERCE_CONTRACT_VERSION,
|
|
83
|
+
orders,
|
|
84
|
+
summaryCounts: input.summaryCounts ?? summarizeOmsListOrders(orders, input.projections),
|
|
85
|
+
summaryTotals: input.summaryTotals ?? summarizeOmsListTotals(orders, input.projections?.currency),
|
|
86
|
+
totalCount: input.totalCount,
|
|
87
|
+
page: input.page,
|
|
88
|
+
pageSize: input.pageSize,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AdminCommerceOrdersListResponse } from "../oms/omsContracts.js";
|
|
2
|
+
import type { OmsReadModelProjections } from "./omsReadModelProjections.js";
|
|
3
|
+
|
|
4
|
+
export function summarizeOmsListOrders(
|
|
5
|
+
orders: AdminCommerceOrdersListResponse["orders"],
|
|
6
|
+
projections?: OmsReadModelProjections,
|
|
7
|
+
): AdminCommerceOrdersListResponse["summaryCounts"] {
|
|
8
|
+
return {
|
|
9
|
+
needsAttention: orders.filter((order) => order.attentionReason !== "none").length,
|
|
10
|
+
activeHold: orders.filter((order) => order.activeHoldCount > 0).length,
|
|
11
|
+
readyForFulfillment: orders.filter((order) => order.nextAction === "create_fulfillment").length,
|
|
12
|
+
paymentIssues: orders.filter((order) => order.attentionReason === "payment_required").length,
|
|
13
|
+
inventoryRisk: orders.filter((order) => order.attentionReason === "inventory_missing").length,
|
|
14
|
+
fulfillmentBlocked: orders.filter((order) => order.attentionReason === "fulfillment_blocked").length,
|
|
15
|
+
fulfillmentExceptions: orders.filter((order) => order.attentionReason === "fulfillment_exception").length,
|
|
16
|
+
invoiceIssues: orders.filter((order) => order.nextAction === "review_invoice").length,
|
|
17
|
+
providerDispatchedNotPicked: orders.filter((order) => Boolean(projections?.dispatchedNotPickedStatus) && order.providerOpsStatus === projections?.dispatchedNotPickedStatus).length,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { OmsOrderDetail } from "../oms/omsContracts.js";
|
|
2
|
+
import type { OmsOrderItemRow,OmsOrderRow } from "./omsReadModelRows.js";
|
|
3
|
+
import {
|
|
4
|
+
deriveOrderMoney,
|
|
5
|
+
type CanonicalOrderMoney,
|
|
6
|
+
} from "../orderMoney.js";
|
|
7
|
+
|
|
8
|
+
export function deriveOmsOrderMoney(
|
|
9
|
+
order: OmsOrderRow,
|
|
10
|
+
items?: readonly OmsOrderItemRow[],
|
|
11
|
+
): CanonicalOrderMoney {
|
|
12
|
+
return deriveOrderMoney(
|
|
13
|
+
{
|
|
14
|
+
id: order.id,
|
|
15
|
+
currency: order.currency,
|
|
16
|
+
subtotal_cents: order.subtotal_cents ?? order.total_cents,
|
|
17
|
+
discount_cents: order.discount_cents ?? 0,
|
|
18
|
+
shipping_cents: order.shipping_cents ?? 0,
|
|
19
|
+
shipping_discount_cents: order.shipping_discount_cents ?? 0,
|
|
20
|
+
tax_cents: order.tax_cents ?? 0,
|
|
21
|
+
total_cents: order.total_cents,
|
|
22
|
+
},
|
|
23
|
+
items?.map((item) => ({
|
|
24
|
+
id: item.id,
|
|
25
|
+
quantity: item.quantity,
|
|
26
|
+
unit_price_cents: item.unit_price_cents ?? 0,
|
|
27
|
+
total_cents: item.total_cents ?? 0,
|
|
28
|
+
discount_allocated_cents: item.discount_allocated_cents,
|
|
29
|
+
effective_total_cents: item.effective_total_cents,
|
|
30
|
+
effective_net_cents: item.effective_net_cents,
|
|
31
|
+
vat_rate_bps: item.vat_rate_bps ?? 0,
|
|
32
|
+
})),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function pricingSummaryForOrder(
|
|
37
|
+
order: OmsOrderRow,
|
|
38
|
+
items?: readonly OmsOrderItemRow[],
|
|
39
|
+
orderMoney: CanonicalOrderMoney = deriveOmsOrderMoney(order, items),
|
|
40
|
+
): OmsOrderDetail["pricingSummary"] {
|
|
41
|
+
return {
|
|
42
|
+
subtotal: money(orderMoney.subtotal, order.currency),
|
|
43
|
+
productDiscount: money(orderMoney.productDiscount, order.currency),
|
|
44
|
+
shipping: money(orderMoney.shippingEffective, order.currency),
|
|
45
|
+
shippingDiscount: money(orderMoney.shippingDiscount, order.currency),
|
|
46
|
+
discountTotal: money(
|
|
47
|
+
orderMoney.productDiscount + orderMoney.shippingDiscount,
|
|
48
|
+
order.currency,
|
|
49
|
+
),
|
|
50
|
+
finalTotal: money(orderMoney.total, order.currency),
|
|
51
|
+
source: "order_columns",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function money(amountMinor: number, currency: OmsOrderDetail["total"]["currency"]): OmsOrderDetail["total"] {
|
|
56
|
+
return { amountMinor, currency };
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { OmsReadModelProjections } from "../contracts/omsTypes.js";
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { OmsDeliveryContactResolution,OmsOrderDetail } from "../oms/omsContracts.js";
|
|
2
|
+
import { accountingSummary } from "./omsAccountingVisibility.js";
|
|
3
|
+
import {
|
|
4
|
+
buildOmsFulfillmentSummary,
|
|
5
|
+
deriveOmsCustomerFulfillmentStep,
|
|
6
|
+
type OmsProviderDispatchRefRow as OmsDispatchRefRow,
|
|
7
|
+
type OmsFulfillmentOrderRow
|
|
8
|
+
} from "./omsFulfillmentSummary.js";
|
|
9
|
+
import { paymentMethodForOrder } from "./omsPaymentMethodSummary.js";
|
|
10
|
+
import {
|
|
11
|
+
baseOrder,
|
|
12
|
+
evaluateOperationalState,
|
|
13
|
+
inventorySummary,
|
|
14
|
+
paymentStatusForOrder,
|
|
15
|
+
} from "./omsReadModelHelpers.js";
|
|
16
|
+
import type { OmsOrderRowCore,OmsOrderRowCoreInput } from "./omsReadModelRows.js";
|
|
17
|
+
import { evaluateCommerceFulfillmentEligibility } from "../fulfillmentEligibility.js";
|
|
18
|
+
|
|
19
|
+
export function buildOmsOrderRowCore(input: OmsOrderRowCoreInput): OmsOrderRowCore {
|
|
20
|
+
const paymentStatus = paymentStatusForOrder(input.order.id, input.paymentIntents);
|
|
21
|
+
const paymentMethod = paymentMethodForOrder(input.order.id, input.paymentIntents, input.paymentAttempts, input.projections);
|
|
22
|
+
const inventory = inventorySummary(input.inventoryReservations, input.orderItems ?? []);
|
|
23
|
+
const fulfillment = buildOmsFulfillmentSummary({
|
|
24
|
+
projections: input.projections,
|
|
25
|
+
fulfillmentOrders: input.fulfillmentOrders,
|
|
26
|
+
fulfillmentOperations: input.fulfillmentOperations,
|
|
27
|
+
shipmentExternalRefs: input.shipmentExternalRefs,
|
|
28
|
+
providerAttempts: input.providerAttempts,
|
|
29
|
+
providerDispatchRefs: input.dispatchRefs,
|
|
30
|
+
providerStatusEvidence: input.statusEvidence,
|
|
31
|
+
});
|
|
32
|
+
const providerOps = input.projections?.providerOps?.(input) ?? { status: "none", sla: null, providerOrderId: null };
|
|
33
|
+
const customerFulfillmentStep = deriveOmsCustomerFulfillmentStep(
|
|
34
|
+
input.order.status,
|
|
35
|
+
fulfillment,
|
|
36
|
+
input.fulfillmentOrders[0]?.delivered_at,
|
|
37
|
+
input.releasedProviderExceptionHolds,
|
|
38
|
+
input.statusEvidence,
|
|
39
|
+
input.activeHoldCount,
|
|
40
|
+
input.projections,
|
|
41
|
+
);
|
|
42
|
+
const accounting = accountingSummary(input.accountingInvoice, input.accountingOutbox, input.projections);
|
|
43
|
+
const fulfillmentEligibility = evaluateCommerceFulfillmentEligibility({
|
|
44
|
+
orderMode: input.order.mode,
|
|
45
|
+
orderStatus: input.order.status,
|
|
46
|
+
paymentStatus,
|
|
47
|
+
subscriptionCycleStatus: input.subscriptionCycleStatus,
|
|
48
|
+
activeHoldCount: input.activeHoldCount,
|
|
49
|
+
hasShippingAddress: Boolean(input.order.shipping_address_id),
|
|
50
|
+
inventoryStatus: inventory.status,
|
|
51
|
+
});
|
|
52
|
+
const operational = evaluateOperationalState({
|
|
53
|
+
order: input.order,
|
|
54
|
+
paymentStatus,
|
|
55
|
+
activeHoldCount: input.activeHoldCount,
|
|
56
|
+
inventoryStatus: inventory.status,
|
|
57
|
+
fulfillmentStatus: fulfillment.status,
|
|
58
|
+
fulfillmentEligibility,
|
|
59
|
+
accountingStatus: accounting.status,
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
row: baseOrder({
|
|
63
|
+
order: input.order,
|
|
64
|
+
paymentStatus,
|
|
65
|
+
paymentMethod,
|
|
66
|
+
activeHoldCount: input.activeHoldCount,
|
|
67
|
+
identity: input.identity,
|
|
68
|
+
inventoryStatus: inventory.status,
|
|
69
|
+
fulfillmentStatus: fulfillment.status,
|
|
70
|
+
customerFulfillmentStep,
|
|
71
|
+
accountingStatus: accounting.status,
|
|
72
|
+
providerOpsStatus: providerOps.status,
|
|
73
|
+
providerOpsSla: providerOps.sla,
|
|
74
|
+
providerOrderId: providerOps.providerOrderId,
|
|
75
|
+
attentionReason: operational.attentionReason,
|
|
76
|
+
nextAction: operational.nextAction,
|
|
77
|
+
orderItems: input.orderItems,
|
|
78
|
+
orderMoney: input.orderMoney,
|
|
79
|
+
}),
|
|
80
|
+
paymentStatus,
|
|
81
|
+
inventory,
|
|
82
|
+
fulfillment,
|
|
83
|
+
accounting,
|
|
84
|
+
fulfillmentEligibility,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type DeliveryContact = NonNullable<NonNullable<OmsOrderDetail["deliveryContact"]>["effective"]>;
|
|
89
|
+
|
|
90
|
+
export function buildOmsDeliveryContactProjection(input: {
|
|
91
|
+
resolution: OmsDeliveryContactResolution;
|
|
92
|
+
currentParcel: OmsFulfillmentOrderRow | null;
|
|
93
|
+
dispatchRefs: OmsDispatchRefRow[];
|
|
94
|
+
}): NonNullable<OmsOrderDetail["deliveryContact"]> {
|
|
95
|
+
const baseline = parseDeliveryContact(input.resolution.baseline);
|
|
96
|
+
const effective = parseDeliveryContact(input.resolution.contact);
|
|
97
|
+
const providerSubmissionState = deliveryContactProviderSubmissionState(input.currentParcel, input.dispatchRefs);
|
|
98
|
+
const frozen = input.dispatchRefs.some(deliveryContactRefIsEffectful)
|
|
99
|
+
|| Boolean(input.currentParcel && !canUpdateShippingAddress(input.currentParcel.status));
|
|
100
|
+
return {
|
|
101
|
+
baseline, effective, scope: input.resolution.scope, source: effective?.source ?? null,
|
|
102
|
+
revision: effective?.revision ?? null, digest: effective ? input.resolution.contactDigest : null,
|
|
103
|
+
frozen, providerSubmissionState,
|
|
104
|
+
correctionAllowed: Boolean(effective && input.resolution.contactDigest) && !frozen,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function deliveryContactAddress(
|
|
109
|
+
contact: DeliveryContact | null,
|
|
110
|
+
addressId: string | null | undefined,
|
|
111
|
+
): OmsOrderDetail["shippingAddress"] {
|
|
112
|
+
if (!contact || !addressId) return null;
|
|
113
|
+
return {
|
|
114
|
+
id: addressId, label: null, line1: contact.line1, line2: contact.line2,
|
|
115
|
+
city: contact.city, postalCode: contact.postalCode, country: contact.country,
|
|
116
|
+
recipientName: contact.recipientName, contactPhone: contact.contactPhone,
|
|
117
|
+
companyName: null, taxId: null, deliveryNotes: contact.deliveryInstructions,
|
|
118
|
+
courierInstructions: contact.courierInstructions,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function buildCurrentDeliveryContact(input: {
|
|
123
|
+
resolution: OmsDeliveryContactResolution;
|
|
124
|
+
shippingAddressId: string | null | undefined;
|
|
125
|
+
fulfillmentOrders: OmsFulfillmentOrderRow[];
|
|
126
|
+
dispatchRefs: OmsDispatchRefRow[];
|
|
127
|
+
}) {
|
|
128
|
+
const currentParcel = input.fulfillmentOrders[0] ?? null;
|
|
129
|
+
const deliveryContact = buildOmsDeliveryContactProjection({
|
|
130
|
+
resolution: input.resolution,
|
|
131
|
+
currentParcel,
|
|
132
|
+
dispatchRefs: currentParcel
|
|
133
|
+
? input.dispatchRefs.filter((row) => row.fulfillment_order_id === currentParcel.id)
|
|
134
|
+
: [],
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
deliveryContact,
|
|
138
|
+
effectiveShippingAddress: deliveryContactAddress(deliveryContact.effective, input.shippingAddressId),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function parseDeliveryContact(value: unknown): DeliveryContact | null {
|
|
143
|
+
const row = objectRecord(value);
|
|
144
|
+
if (row.schemaVersion !== 1) return null;
|
|
145
|
+
const source = nullableText(row.source);
|
|
146
|
+
const revision = positiveInteger(row.revision);
|
|
147
|
+
if (!source || revision === null) return null;
|
|
148
|
+
return {
|
|
149
|
+
schemaVersion: 1, source, revision,
|
|
150
|
+
recipientName: nullableText(row.recipientName), contactEmail: nullableText(row.contactEmail),
|
|
151
|
+
contactPhone: nullableText(row.contactPhone), line1: nullableText(row.line1),
|
|
152
|
+
line2: nullableText(row.line2), city: nullableText(row.city),
|
|
153
|
+
postalCode: nullableText(row.postalCode), country: nullableText(row.country),
|
|
154
|
+
selectedDelivery: recordOrNull(row.selectedDelivery),
|
|
155
|
+
deliveryInstructions: nullableText(row.deliveryInstructions),
|
|
156
|
+
courierInstructions: nullableText(row.courierInstructions),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function deliveryContactProviderSubmissionState(
|
|
161
|
+
parcel: OmsFulfillmentOrderRow | null,
|
|
162
|
+
dispatchRefs: OmsDispatchRefRow[],
|
|
163
|
+
): NonNullable<OmsOrderDetail["deliveryContact"]>["providerSubmissionState"] {
|
|
164
|
+
if (!parcel) return "not_materialized";
|
|
165
|
+
if (!dispatchRefs.length) return "not_started";
|
|
166
|
+
const dispatchRef = dispatchRefs.find(deliveryContactRefIsEffectful) ?? dispatchRefs[0]!;
|
|
167
|
+
const known = ["draft", "submitting", "created", "uncertain", "failed", "cancel_requested", "cancelled"] as const;
|
|
168
|
+
return known.find((status) => status === dispatchRef.status) ?? "unknown";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function deliveryContactRefIsEffectful(dispatchRef: OmsDispatchRefRow | null): boolean {
|
|
172
|
+
return Boolean(dispatchRef && !(dispatchRef.status === "draft" && !dispatchRef.provider_order_id));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function objectRecord(value: unknown): Record<string, unknown> {
|
|
176
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : {};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function recordOrNull(value: unknown): Record<string, unknown> | null {
|
|
180
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function nullableText(value: unknown): string | null {
|
|
184
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function positiveInteger(value: unknown): number | null {
|
|
188
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function canUpdateShippingAddress(status: OmsOrderDetail["fulfillmentStatus"]): boolean {
|
|
192
|
+
return !status || status === "created" || status === "packed" || status === "label_pending";
|
|
193
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { OmsAccountingInvoiceRow,OmsAccountingOutboxRow,OmsAddressRow,OmsCommunicationDeliveryRow,OmsCustomerRow,OmsHoldRow,OmsInventoryReservationRow,OmsOperationRow,OmsOrderItemRow,OmsOrderRow,OmsOrderRowCore,OmsOrderRowCoreInput,OmsPaymentAttemptRow,OmsPaymentIntentRow,OmsPaymentTransitionRow } from "../contracts/omsTypes.js";
|
|
2
|
+
|
|
3
|
+
// Every status union below is read back out of the contract the row feeds, so a
|
|
4
|
+
// vocabulary can only be widened in one place. The rows are DB shapes, not
|
|
5
|
+
// contract shapes, so the derivation is by indexed access rather than by
|
|
6
|
+
// re-importing the zod schemas - this file stays type-only and carries no
|
|
7
|
+
// runtime import.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CommerceOfferAvailability,
|
|
3
|
+
CommerceOfferAvailabilityRequestItem,
|
|
4
|
+
CommerceOfferAvailabilityStatus,
|
|
5
|
+
} from "./contracts/availability.js";
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_LOW_STOCK_THRESHOLD = 20;
|
|
8
|
+
|
|
9
|
+
export interface DeriveOfferAvailabilityInput
|
|
10
|
+
extends CommerceOfferAvailabilityRequestItem {
|
|
11
|
+
sellableNow: number | null;
|
|
12
|
+
lowStockThreshold?: number;
|
|
13
|
+
source: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function deriveOfferAvailability(
|
|
17
|
+
input: DeriveOfferAvailabilityInput,
|
|
18
|
+
): CommerceOfferAvailability {
|
|
19
|
+
const status = statusForSellableNow(input.sellableNow, input.lowStockThreshold);
|
|
20
|
+
return {
|
|
21
|
+
sku: input.sku,
|
|
22
|
+
productSlug: input.productSlug,
|
|
23
|
+
variantId: input.variantId,
|
|
24
|
+
status,
|
|
25
|
+
visibleInConfigurator: status !== "out_of_stock",
|
|
26
|
+
sellableNow: input.sellableNow,
|
|
27
|
+
reasonCode: reasonCodeFor(status),
|
|
28
|
+
source: input.source,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function defaultOfferAvailability(
|
|
33
|
+
item: CommerceOfferAvailabilityRequestItem,
|
|
34
|
+
source = "static",
|
|
35
|
+
): CommerceOfferAvailability {
|
|
36
|
+
return {
|
|
37
|
+
sku: item.sku,
|
|
38
|
+
productSlug: item.productSlug,
|
|
39
|
+
variantId: item.variantId,
|
|
40
|
+
status: "available",
|
|
41
|
+
visibleInConfigurator: true,
|
|
42
|
+
sellableNow: null,
|
|
43
|
+
reasonCode: "static_available",
|
|
44
|
+
source,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function availabilityBySku(
|
|
49
|
+
items: readonly CommerceOfferAvailability[],
|
|
50
|
+
): Map<string, CommerceOfferAvailability> {
|
|
51
|
+
return new Map(items.map((item) => [item.sku, item]));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The status ladder itself, exported so a composed offer (a bundle derives one
|
|
56
|
+
* status from many components) reads the SAME four rungs rather than mirroring
|
|
57
|
+
* them. A second copy would drift the first time a rung moves.
|
|
58
|
+
*/
|
|
59
|
+
export function statusForSellableNow(
|
|
60
|
+
sellableNow: number | null,
|
|
61
|
+
lowStockThreshold = DEFAULT_LOW_STOCK_THRESHOLD,
|
|
62
|
+
): CommerceOfferAvailabilityStatus {
|
|
63
|
+
if (sellableNow == null) return "unknown";
|
|
64
|
+
if (sellableNow <= 0) return "out_of_stock";
|
|
65
|
+
if (sellableNow <= lowStockThreshold) return "low_stock";
|
|
66
|
+
return "available";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The reason-code vocabulary for a stock-derived status; exported for the same reason. */
|
|
70
|
+
export function reasonCodeFor(status: CommerceOfferAvailabilityStatus): string {
|
|
71
|
+
if (status === "available") return "stock_available";
|
|
72
|
+
if (status === "low_stock") return "low_stock";
|
|
73
|
+
if (status === "out_of_stock") return "out_of_stock";
|
|
74
|
+
return "stock_unknown";
|
|
75
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import type { CommerceOfferAvailabilityRequestItem } from "./contracts/index.js";
|
|
4
|
+
|
|
5
|
+
/** Bind the existing product identifier and SKU validators without importing a host. */
|
|
6
|
+
export function createOfferAvailabilitySchemas(
|
|
7
|
+
catalogProductSlugSchema: z.ZodType<string, string>,
|
|
8
|
+
commerceSkuSchema: z.ZodType<string, string>,
|
|
9
|
+
) {
|
|
10
|
+
const commerceOfferAvailabilityStatusSchema = z.enum([
|
|
11
|
+
"available",
|
|
12
|
+
"low_stock",
|
|
13
|
+
"out_of_stock",
|
|
14
|
+
"unknown",
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const commerceOfferAvailabilitySourceSchema = z
|
|
18
|
+
.string()
|
|
19
|
+
.trim()
|
|
20
|
+
.min(1)
|
|
21
|
+
.max(80);
|
|
22
|
+
|
|
23
|
+
const commerceOfferAvailabilityRequestItemSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
sku: commerceSkuSchema,
|
|
26
|
+
productSlug: catalogProductSlugSchema,
|
|
27
|
+
variantId: z.string().trim().min(1).max(120),
|
|
28
|
+
requestedQuantity: z.number().int().positive().default(1),
|
|
29
|
+
checkoutMode: z.enum(["one_time", "subscription"]).default("one_time"),
|
|
30
|
+
})
|
|
31
|
+
.strict();
|
|
32
|
+
|
|
33
|
+
const commerceOfferAvailabilitySchema = z
|
|
34
|
+
.object({
|
|
35
|
+
sku: commerceSkuSchema,
|
|
36
|
+
productSlug: catalogProductSlugSchema,
|
|
37
|
+
variantId: z.string().trim().min(1).max(120),
|
|
38
|
+
status: commerceOfferAvailabilityStatusSchema,
|
|
39
|
+
visibleInConfigurator: z.boolean(),
|
|
40
|
+
sellableNow: z.number().int().nonnegative().nullable(),
|
|
41
|
+
reasonCode: z.string().trim().min(1).max(120),
|
|
42
|
+
source: commerceOfferAvailabilitySourceSchema,
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
|
45
|
+
|
|
46
|
+
return { commerceOfferAvailabilityStatusSchema, commerceOfferAvailabilitySourceSchema, commerceOfferAvailabilityRequestItemSchema, commerceOfferAvailabilitySchema };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** One request per variant, preserving order and checkout mode. */
|
|
50
|
+
export function offerAvailabilityRequestItems(
|
|
51
|
+
variants: readonly { sku: string; slug: string; variantId: string }[],
|
|
52
|
+
checkoutMode: CommerceOfferAvailabilityRequestItem["checkoutMode"],
|
|
53
|
+
): CommerceOfferAvailabilityRequestItem[] {
|
|
54
|
+
return variants.map(variant => ({ sku: variant.sku, productSlug: variant.slug,
|
|
55
|
+
variantId: variant.variantId, requestedQuantity: 1, checkoutMode }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const COMMERCE_OFFER_EVIDENCE_MAX_JSON_LENGTH = 4_096;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The adopter's own record of why a checkout was bound to an offer version.
|
|
7
|
+
* Server-minted only: core bounds its keys and size and never reads it.
|
|
8
|
+
*/
|
|
9
|
+
export const commerceOfferEvidenceSchema = z
|
|
10
|
+
.record(z.string().regex(/^[A-Za-z][A-Za-z0-9]{0,39}$/), z.unknown())
|
|
11
|
+
.superRefine((evidence, ctx) => {
|
|
12
|
+
if (JSON.stringify(evidence).length > COMMERCE_OFFER_EVIDENCE_MAX_JSON_LENGTH) {
|
|
13
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "offer evidence exceeds 4096 characters" });
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type CommerceOfferEvidence = z.infer<typeof commerceOfferEvidenceSchema>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { PAYMENT_ATTEMPT_STATUSES,PAYMENT_INTENT_STATUSES } from "@openlup/core/payment";
|
|
2
|
+
import { SUBSCRIPTION_CYCLE_STATUSES } from "@openlup/core/subscription";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import {
|
|
5
|
+
OMS_FULFILLMENT_BLOCK_REASONS,
|
|
6
|
+
OMS_INVENTORY_STATUSES,
|
|
7
|
+
} from "../contracts/state.js";
|
|
8
|
+
|
|
9
|
+
export const commerceOrderModeSchema = z.enum(["one_time", "subscription_cycle"]);
|
|
10
|
+
export const omsPaymentStatusSchema = z.enum(["not_started", ...PAYMENT_INTENT_STATUSES]);
|
|
11
|
+
export const omsPaymentAttemptStatusSchema = z.enum(PAYMENT_ATTEMPT_STATUSES);
|
|
12
|
+
export const omsSubscriptionCycleStatusSchema = z.enum(SUBSCRIPTION_CYCLE_STATUSES);
|
|
13
|
+
|
|
14
|
+
export const omsHoldReasonSchema = z.enum([
|
|
15
|
+
"payment_not_succeeded",
|
|
16
|
+
"inventory_review",
|
|
17
|
+
"risk_review",
|
|
18
|
+
"address_review",
|
|
19
|
+
"fulfillment_exception",
|
|
20
|
+
"manual_support",
|
|
21
|
+
]);
|
|
22
|
+
export const omsHoldStatusSchema = z.enum(["active", "released"]);
|
|
23
|
+
export const omsOperationTypeSchema = z.enum([
|
|
24
|
+
"hold_created",
|
|
25
|
+
"hold_released",
|
|
26
|
+
"fulfillment_reviewed",
|
|
27
|
+
"support_note",
|
|
28
|
+
"shipping_address_updated",
|
|
29
|
+
"order_marked_refunded",
|
|
30
|
+
"order_cancelled_manual",
|
|
31
|
+
// The replacement command's audit row. The database CHECK was widened for it by
|
|
32
|
+
// 20260820100000_replacement_shipment_command.sql; without the same widening here
|
|
33
|
+
// the operation appears in `commerce_order_operations` and then fails this enum on
|
|
34
|
+
// every read of the order that carries it - the replacement response itself, and
|
|
35
|
+
// the whole order-detail timeline afterwards.
|
|
36
|
+
"replacement_shipment_requested",
|
|
37
|
+
]);
|
|
38
|
+
export const omsFulfillmentBlockReasonSchema = z.enum(OMS_FULFILLMENT_BLOCK_REASONS);
|
|
39
|
+
export const omsInventoryStatusSchema = z.enum(OMS_INVENTORY_STATUSES);
|
|
40
|
+
export const omsFulfillmentStatusSchema = z.enum([
|
|
41
|
+
"created",
|
|
42
|
+
"packed",
|
|
43
|
+
"label_pending",
|
|
44
|
+
"label_created",
|
|
45
|
+
"handed_over",
|
|
46
|
+
"in_transit",
|
|
47
|
+
"delivered",
|
|
48
|
+
"exception",
|
|
49
|
+
"cancelled",
|
|
50
|
+
]);
|
|
51
|
+
export const omsAccountingStatusSchema = z.string();
|
|
52
|
+
export const omsAttentionReasonSchema = z.enum([
|
|
53
|
+
"none",
|
|
54
|
+
"payment_required",
|
|
55
|
+
"active_hold",
|
|
56
|
+
"missing_shipping_address",
|
|
57
|
+
"inventory_missing",
|
|
58
|
+
"fulfillment_blocked",
|
|
59
|
+
"fulfillment_pending",
|
|
60
|
+
"fulfillment_exception",
|
|
61
|
+
"invoice_missing",
|
|
62
|
+
"invoice_issue_failed",
|
|
63
|
+
"invoice_buyer_data_invalid",
|
|
64
|
+
]);
|
|
65
|
+
export const omsNextActionSchema = z.enum([
|
|
66
|
+
"none",
|
|
67
|
+
"review_payment",
|
|
68
|
+
"release_hold",
|
|
69
|
+
"review_address",
|
|
70
|
+
"review_inventory",
|
|
71
|
+
"review_fulfillment",
|
|
72
|
+
"create_fulfillment",
|
|
73
|
+
"record_label",
|
|
74
|
+
"hand_off",
|
|
75
|
+
"review_tracking",
|
|
76
|
+
"review_invoice",
|
|
77
|
+
]);
|
|
78
|
+
export const omsProviderOpsStatusSchema = z.string();
|
|
79
|
+
export const omsProviderOpsSlaStatusSchema = z.enum([
|
|
80
|
+
"ok",
|
|
81
|
+
"watch",
|
|
82
|
+
"breached",
|
|
83
|
+
"paused_non_shipping_day",
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
export const uuidSchema = z.guid();
|
|
87
|
+
export const datetimeSchema = z.string().datetime({ offset: true });
|
|
88
|
+
export const nullableTextSchema = z.string().nullable();
|
|
89
|
+
export const actionEligibilitySchema = z.object({
|
|
90
|
+
allowed: z.boolean(),
|
|
91
|
+
reason: z.string().nullable(),
|
|
92
|
+
}).strict();
|