@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,73 @@
|
|
|
1
|
+
import type { CommerceEmailRuntime } from "./emailRuntime.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { COMMERCE_SHIPMENT_EXCEPTION_EVENT_TYPE } from "../outboxEventSchemas.js";
|
|
4
|
+
import type {
|
|
5
|
+
OutboxEventRow,
|
|
6
|
+
OutboxHandler,
|
|
7
|
+
OutboxHandlerOutcome,
|
|
8
|
+
} from "../outboxDispatchContracts.js";
|
|
9
|
+
import {
|
|
10
|
+
OUTBOX_SHIPMENT_EXCEPTION_TEMPLATE_SLUG,
|
|
11
|
+
type OrderRecipientPort,
|
|
12
|
+
type TransactionalEmailPort,
|
|
13
|
+
} from "../outboxOrderDraftEmailPorts.js";
|
|
14
|
+
|
|
15
|
+
export { OUTBOX_SHIPMENT_EXCEPTION_TEMPLATE_SLUG };
|
|
16
|
+
|
|
17
|
+
const HANDLER_TIMEOUT_MS = 10_000;
|
|
18
|
+
|
|
19
|
+
export const outboxShipmentExceptionEmailDescriptor = Object.freeze({
|
|
20
|
+
eventType: COMMERCE_SHIPMENT_EXCEPTION_EVENT_TYPE, timeoutMs: HANDLER_TIMEOUT_MS,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const payloadSubsetSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
orderUuid: z.guid(),
|
|
26
|
+
orderId: z.string().min(1),
|
|
27
|
+
customerNotification: z.literal("shipment_exception").optional(),
|
|
28
|
+
})
|
|
29
|
+
.passthrough();
|
|
30
|
+
|
|
31
|
+
export function createOutboxShipmentExceptionEmailHandler<Locale extends string>(deps: {
|
|
32
|
+
runtime: Pick<CommerceEmailRuntime<Locale>, "mapSendOutcome" | "parseOutboxPayload" | "resolveLocale">;
|
|
33
|
+
emailPort: TransactionalEmailPort<Locale>;
|
|
34
|
+
recipientPort: OrderRecipientPort;
|
|
35
|
+
}): OutboxHandler {
|
|
36
|
+
return {
|
|
37
|
+
...outboxShipmentExceptionEmailDescriptor,
|
|
38
|
+
async handle(row: OutboxEventRow, signal: AbortSignal): Promise<OutboxHandlerOutcome> {
|
|
39
|
+
const parsed = deps.runtime.parseOutboxPayload(payloadSubsetSchema, row.payload);
|
|
40
|
+
if (parsed.ok === false) {
|
|
41
|
+
return parsed.outcome;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (parsed.data.customerNotification !== "shipment_exception") {
|
|
45
|
+
return { kind: "processed", detail: { skipped: "internal_fulfillment_hold" } };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const recipient = await deps.recipientPort.resolve(parsed.data.orderUuid, signal);
|
|
49
|
+
if (recipient === null) {
|
|
50
|
+
return { kind: "processed", detail: { skipped: "recipient_unresolved" } };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const alreadySent = await deps.emailPort.findExistingSend(
|
|
54
|
+
OUTBOX_SHIPMENT_EXCEPTION_TEMPLATE_SLUG,
|
|
55
|
+
row.id,
|
|
56
|
+
);
|
|
57
|
+
if (alreadySent) {
|
|
58
|
+
return { kind: "processed", detail: { dedupe: "email_already_sent" } };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const outcome = await deps.emailPort.sendShipmentExceptionNotice({
|
|
62
|
+
to: recipient.email,
|
|
63
|
+
firstName: recipient.firstName,
|
|
64
|
+
orderId: parsed.data.orderId,
|
|
65
|
+
outboxEventId: row.id,
|
|
66
|
+
locale: deps.runtime.resolveLocale(recipient.country ?? null),
|
|
67
|
+
signal,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return deps.runtime.mapSendOutcome(outcome);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { HttpRequest, HttpResponse } from "../../http/index.js";
|
|
3
|
+
import type { BffResponder } from "../../bff/index.js";
|
|
4
|
+
import { REFERENCE_CHECKOUT_V1 } from "../checkoutCommandSchemas.js";
|
|
5
|
+
import { CommerceRuntimeConflictError, CommerceRuntimePersistenceError } from "../runtimeErrors.js";
|
|
6
|
+
interface ReferenceRuntime { runtime: { orderId: string; clientId: string; finalizedReplayed: boolean; total: { amountMinor: number; currency: string }; payment: { paymentIntentId: string; paymentAttemptId: string | null; status: string; attemptStatus: string | null } } }
|
|
7
|
+
interface ReferenceSettlement { paymentResult: { status: string; replayed: boolean } }
|
|
8
|
+
|
|
9
|
+
export function createReferenceCheckoutHandler<Command, Runtime extends ReferenceRuntime, Settlement extends ReferenceSettlement, Response>({
|
|
10
|
+
startCheckout,
|
|
11
|
+
checkRateLimit,
|
|
12
|
+
checkRiskBlocklist,
|
|
13
|
+
admitProfile, responder, requestSchema, responseSchema,
|
|
14
|
+
}: {
|
|
15
|
+
startCheckout(command: Command): Promise<{ runtime: Runtime; settlement: Settlement | null; persistence: { replayed: boolean } }>;
|
|
16
|
+
checkRateLimit(req: HttpRequest, command: Command): Promise<{ allowed: boolean }>;
|
|
17
|
+
checkRiskBlocklist?(req: HttpRequest, command: Command): Promise<{ blocked: boolean }>;
|
|
18
|
+
admitProfile(command: Command): boolean; responder: BffResponder;
|
|
19
|
+
requestSchema: z.ZodType<{ command: Command }>; responseSchema: z.ZodType<Response>;
|
|
20
|
+
}) {
|
|
21
|
+
const { sendBffError, sendBffSuccess, sendMethodNotAllowed } = responder;
|
|
22
|
+
return async function handler(req: HttpRequest, res: HttpResponse): Promise<void> {
|
|
23
|
+
if (req.method !== "POST") {
|
|
24
|
+
sendMethodNotAllowed(res, ["POST"]);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const request = requestSchema.safeParse(req.body ?? {});
|
|
29
|
+
if (!request.success) {
|
|
30
|
+
sendBffError(res, "BAD_REQUEST", "Invalid reference checkout request", {
|
|
31
|
+
details: request.error.flatten(),
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
if (!admitProfile(request.data.command)) {
|
|
38
|
+
sendBffError(res, "BAD_REQUEST", "Checkout command does not match the active reference profile");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!(await checkRateLimit(req, request.data.command)).allowed) {
|
|
42
|
+
sendBffError(res, "RATE_LIMITED", "Reference checkout rate limit exceeded");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (checkRiskBlocklist && (await checkRiskBlocklist(req, request.data.command)).blocked) {
|
|
46
|
+
sendBffError(res, "FORBIDDEN", "Reference checkout cannot be completed");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Settlement is owned by the shared paid-order service, not by this
|
|
51
|
+
// handler: it is present exactly when that service settled the attempt,
|
|
52
|
+
// and absent when the runtime is still awaiting or already refused it.
|
|
53
|
+
const result = await startCheckout(request.data.command);
|
|
54
|
+
const settled = result.settlement;
|
|
55
|
+
const response = responseSchema.safeParse({
|
|
56
|
+
version: REFERENCE_CHECKOUT_V1,
|
|
57
|
+
orderId: result.runtime.runtime.orderId,
|
|
58
|
+
clientId: result.runtime.runtime.clientId,
|
|
59
|
+
paymentIntentId: result.runtime.runtime.payment.paymentIntentId,
|
|
60
|
+
paymentAttemptId: result.runtime.runtime.payment.paymentAttemptId,
|
|
61
|
+
paymentStatus: settled?.paymentResult.status ?? result.runtime.runtime.payment.status,
|
|
62
|
+
paymentAttemptStatus: settled
|
|
63
|
+
? "succeeded"
|
|
64
|
+
: result.runtime.runtime.payment.attemptStatus,
|
|
65
|
+
replayed: result.persistence.replayed ||
|
|
66
|
+
result.runtime.runtime.finalizedReplayed ||
|
|
67
|
+
(settled?.paymentResult.replayed ?? false),
|
|
68
|
+
total: result.runtime.runtime.total,
|
|
69
|
+
});
|
|
70
|
+
if (!response.success) {
|
|
71
|
+
sendBffError(res, "INVALID_RESPONSE", "Reference checkout returned invalid response");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
sendBffSuccess(res, response.data, { contractVersion: REFERENCE_CHECKOUT_V1 });
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (error instanceof CommerceRuntimeConflictError) {
|
|
77
|
+
sendBffError(res, "CONFLICT", error.message, { details: error.details });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (error instanceof CommerceRuntimePersistenceError) {
|
|
81
|
+
sendBffError(res, "UPSTREAM_UNAVAILABLE", "Reference checkout persistence failed");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
sendBffError(res, "UPSTREAM_UNAVAILABLE", "Reference checkout failed");
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface ReservationSweepCounts {
|
|
2
|
+
ordersChecked: number;
|
|
3
|
+
ordersExpired: number;
|
|
4
|
+
reservationsReleased: number;
|
|
5
|
+
skippedPaid: number;
|
|
6
|
+
skippedTerminal: number;
|
|
7
|
+
skippedSubscription: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ReservationSweepRpcClient = {
|
|
11
|
+
rpc(
|
|
12
|
+
name: string,
|
|
13
|
+
args: Record<string, unknown>,
|
|
14
|
+
): PromiseLike<{ data: unknown; error: { message?: string } | null }>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export interface RetryHoldSweepCounts {
|
|
18
|
+
holdsChecked: number;
|
|
19
|
+
holdsReleased: number;
|
|
20
|
+
skippedPaid: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createManagedReservationSweepPort(client: ReservationSweepRpcClient) {
|
|
24
|
+
return {
|
|
25
|
+
async sweep(input: { now: string; limit: number }): Promise<ReservationSweepCounts> {
|
|
26
|
+
const { data, error } = await client.rpc("commerce_sweep_expired_reservation_holds", {
|
|
27
|
+
p_idempotency_prefix: "commerce-reservation-sweep-run",
|
|
28
|
+
p_now: input.now,
|
|
29
|
+
p_limit: input.limit,
|
|
30
|
+
});
|
|
31
|
+
if (error) throw new Error(`rpc_sweep: ${error.message ?? "unknown"}`);
|
|
32
|
+
return readSweepCounts(data);
|
|
33
|
+
},
|
|
34
|
+
// Release-only: frees expired subscription_retry_window holds without
|
|
35
|
+
// touching the cycle order, subscription, or dunning case.
|
|
36
|
+
async sweepRetryHolds(input: { now: string; limit: number }): Promise<RetryHoldSweepCounts> {
|
|
37
|
+
const { data, error } = await client.rpc("commerce_sweep_expired_retry_holds", {
|
|
38
|
+
p_now: input.now,
|
|
39
|
+
p_limit: input.limit,
|
|
40
|
+
});
|
|
41
|
+
if (error) throw new Error(`rpc_retry_hold_sweep: ${error.message ?? "unknown"}`);
|
|
42
|
+
const sweep = (data as { retrySweep?: Record<string, unknown> } | null)?.retrySweep;
|
|
43
|
+
return {
|
|
44
|
+
holdsChecked: numberField(sweep, "holdsChecked"),
|
|
45
|
+
holdsReleased: numberField(sweep, "holdsReleased"),
|
|
46
|
+
skippedPaid: numberField(sweep, "skippedPaid"),
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function readSweepCounts(data: unknown): ReservationSweepCounts {
|
|
53
|
+
const sweep = (data as { sweep?: Record<string, unknown> } | null)?.sweep;
|
|
54
|
+
return {
|
|
55
|
+
ordersChecked: numberField(sweep, "ordersChecked"),
|
|
56
|
+
ordersExpired: numberField(sweep, "ordersExpired"),
|
|
57
|
+
reservationsReleased: numberField(sweep, "reservationsReleased"),
|
|
58
|
+
skippedPaid: numberField(sweep, "skippedPaid"),
|
|
59
|
+
skippedTerminal: numberField(sweep, "skippedTerminal"),
|
|
60
|
+
skippedSubscription: numberField(sweep, "skippedSubscription"),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function numberField(record: Record<string, unknown> | undefined, key: string): number {
|
|
65
|
+
const value = record?.[key];
|
|
66
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
67
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface StarterTermsDecision {
|
|
2
|
+
intervalDays: number;
|
|
3
|
+
steadyCadenceDays: number;
|
|
4
|
+
steadyUnits: number;
|
|
5
|
+
graduationSizeConstraint?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type StarterTermsRefusal = "basket_too_small" | "basket_not_admitted" | "demand_unknown";
|
|
9
|
+
|
|
10
|
+
export type StarterTermsResolution =
|
|
11
|
+
| { kind: "terms"; terms: StarterTermsDecision }
|
|
12
|
+
| { kind: "refused"; reason: StarterTermsRefusal };
|
|
13
|
+
|
|
14
|
+
export interface StarterTermsInput<Intent, Snapshot> {
|
|
15
|
+
intent: Intent;
|
|
16
|
+
authoritativeQuote: Snapshot;
|
|
17
|
+
offerVersion?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface StarterTermsPort<Intent, Snapshot> {
|
|
21
|
+
resolve(input: StarterTermsInput<Intent, Snapshot>): Promise<StarterTermsResolution>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CommerceReturnsPort,
|
|
3
|
+
ReturnLifecycleResult,
|
|
4
|
+
ReturnRequestCreateInput,
|
|
5
|
+
} from "../commerceReturnsPort.js";
|
|
6
|
+
|
|
7
|
+
/** Returns request/approve/reject only. Restock and refund fields record intent; no receive, restock or refund execution. */
|
|
8
|
+
export interface CommerceReturnsRpcClient {
|
|
9
|
+
rpc(
|
|
10
|
+
fn: string,
|
|
11
|
+
params: Record<string, unknown>,
|
|
12
|
+
): PromiseLike<{
|
|
13
|
+
data: unknown;
|
|
14
|
+
error: { code?: string; message?: string } | null;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function parseResult(fn: string, data: unknown): ReturnLifecycleResult {
|
|
19
|
+
const result = (data ?? {}) as Record<string, unknown>;
|
|
20
|
+
if (
|
|
21
|
+
typeof result.returnRequestId !== "string" ||
|
|
22
|
+
typeof result.status !== "string"
|
|
23
|
+
) {
|
|
24
|
+
throw new Error(`${fn}_unexpected_result`);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
returnRequestId: result.returnRequestId,
|
|
28
|
+
status: result.status,
|
|
29
|
+
replayed: result.replayed === true,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Returns request/approve/reject only. Restock and refund fields record intent; no receive, restock or refund execution. */
|
|
34
|
+
export function createSupabaseCommerceReturnsPort<Reason extends string = ReturnRequestCreateInput["reasonCode"]>(
|
|
35
|
+
client: CommerceReturnsRpcClient,
|
|
36
|
+
): CommerceReturnsPort<Reason> {
|
|
37
|
+
async function call(
|
|
38
|
+
fn: string,
|
|
39
|
+
params: Record<string, unknown>,
|
|
40
|
+
): Promise<ReturnLifecycleResult> {
|
|
41
|
+
const { data, error } = await client.rpc(fn, params);
|
|
42
|
+
if (error) throw new Error(`${fn}_failed:${error.code ?? "unknown"}`);
|
|
43
|
+
return parseResult(fn, data);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
createRequest(input) {
|
|
48
|
+
return call("commerce_return_request_create", {
|
|
49
|
+
p_idempotency_key: input.idempotencyKey,
|
|
50
|
+
p_order_id: input.orderId,
|
|
51
|
+
p_lines: input.lines.map((line) => ({
|
|
52
|
+
orderItemId: line.orderItemId,
|
|
53
|
+
sku: line.sku ?? null,
|
|
54
|
+
quantity: line.quantity,
|
|
55
|
+
restockDisposition: line.restockDisposition ?? "restock",
|
|
56
|
+
})),
|
|
57
|
+
p_reason_code: input.reasonCode,
|
|
58
|
+
p_customer_note: input.customerNote ?? null,
|
|
59
|
+
p_requested_by: input.requestedBy ?? null,
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
approve(input) {
|
|
63
|
+
return call("commerce_return_approve", {
|
|
64
|
+
p_idempotency_key: input.idempotencyKey,
|
|
65
|
+
p_return_request_id: input.returnRequestId,
|
|
66
|
+
p_approved_by: input.actorUserId ?? null,
|
|
67
|
+
p_refund_mode: input.refundMode,
|
|
68
|
+
p_refund_amount_cents: input.refundAmountCents ?? null,
|
|
69
|
+
p_admin_note: input.adminNote ?? null,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
reject(input) {
|
|
73
|
+
return call("commerce_return_reject", {
|
|
74
|
+
p_idempotency_key: input.idempotencyKey,
|
|
75
|
+
p_return_request_id: input.returnRequestId,
|
|
76
|
+
p_approved_by: input.actorUserId ?? null,
|
|
77
|
+
p_admin_note: input.adminNote ?? null,
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Contribution, RequiredSchema } from "@openlup/core/readiness";
|
|
2
|
+
|
|
3
|
+
/** Descriptors only: owner messages, workers and schedules stay with their owners. */
|
|
4
|
+
export function createAccountSupportContribution(input: {
|
|
5
|
+
version: string;
|
|
6
|
+
requiredSchema: RequiredSchema;
|
|
7
|
+
accountSupport: Readonly<Record<string, ((...args: never[]) => unknown) | null>>;
|
|
8
|
+
dependsOn: NonNullable<Contribution["manifest"]["module"]>["dependsOn"];
|
|
9
|
+
routes?: Contribution["routes"];
|
|
10
|
+
}) {
|
|
11
|
+
const routes = [...input.routes ?? []];
|
|
12
|
+
if (new Set(routes.map(route => route.id)).size !== routes.length) throw new Error("account_support_duplicate_route");
|
|
13
|
+
const contribution: Contribution = {
|
|
14
|
+
manifest: {
|
|
15
|
+
name: "@openlup/platform", version: input.version, kind: "rail",
|
|
16
|
+
module: { id: "account-support", kind: "capability", provides: ["./account-support", "./account-support/contracts"], dependsOn: input.dependsOn },
|
|
17
|
+
emits: [], handles: [], schedules: [], env: [], requiredPorts: Object.keys(input.accountSupport),
|
|
18
|
+
routes: routes.map(route => route.id), requiredSchema: input.requiredSchema,
|
|
19
|
+
}, handlers: [], schedules: [], routes,
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
contributions: [contribution],
|
|
23
|
+
ports: Object.fromEntries(Object.entries(input.accountSupport).filter(([, operation]) => operation !== null)
|
|
24
|
+
.map(([key, operation]) => [`@openlup/platform/account-support:${key}`, operation])),
|
|
25
|
+
routes: Object.fromEntries(routes.map(route => [`@openlup/platform/account-support:${route.id}`, route.handle])),
|
|
26
|
+
triggers: {},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Contribution, RequiredSchema } from "@openlup/core/readiness";
|
|
2
|
+
|
|
3
|
+
/** Describe existing selected commerce callables; never install another executor. */
|
|
4
|
+
export function createCommerceContribution(input: {
|
|
5
|
+
version: string;
|
|
6
|
+
requiredSchema: RequiredSchema;
|
|
7
|
+
commerce: Readonly<Record<string, ((...args: never[]) => unknown) | null>>;
|
|
8
|
+
handlers: Contribution["handlers"];
|
|
9
|
+
schedules: Contribution["schedules"];
|
|
10
|
+
routes: Contribution["routes"];
|
|
11
|
+
}) {
|
|
12
|
+
for (const [kind, names] of [
|
|
13
|
+
["handler", input.handlers.map(handler => handler.eventType)],
|
|
14
|
+
["schedule", input.schedules.map(schedule => schedule.id)],
|
|
15
|
+
["route", input.routes.map(route => route.id)],
|
|
16
|
+
] as const) {
|
|
17
|
+
if (new Set(names).size !== names.length) throw new Error(`commerce_duplicate_${kind}`);
|
|
18
|
+
}
|
|
19
|
+
const contribution: Contribution = {
|
|
20
|
+
manifest: {
|
|
21
|
+
name: "@openlup/platform", version: input.version, kind: "rail",
|
|
22
|
+
module: { id: "commerce", kind: "capability", provides: ["./commerce", "./commerce/contracts", "./commerce/server"], dependsOn: [] },
|
|
23
|
+
emits: [], handles: input.handlers.map(handler => handler.eventType),
|
|
24
|
+
schedules: input.schedules.map(({ id, cadenceSeconds }) => ({ id, cadenceSeconds })), env: [],
|
|
25
|
+
requiredPorts: Object.keys(input.commerce), routes: input.routes.map(route => route.id), requiredSchema: input.requiredSchema,
|
|
26
|
+
},
|
|
27
|
+
handlers: input.handlers.map(({ eventType, timeoutMs }) => Object.freeze({ eventType, timeoutMs })), schedules: input.schedules, routes: input.routes,
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
contributions: [contribution],
|
|
31
|
+
ports: Object.fromEntries(Object.entries(input.commerce).filter(([, fn]) => typeof fn === "function").map(([name, fn]) => [`@openlup/platform/commerce:${name}`, fn])),
|
|
32
|
+
routes: Object.fromEntries(input.routes.map(route => [`@openlup/platform/commerce:${route.id}`, route.handle])),
|
|
33
|
+
triggers: Object.fromEntries(input.schedules.map(schedule => [`@openlup/platform/commerce:${schedule.id}`, schedule.run])),
|
|
34
|
+
};
|
|
35
|
+
}
|
package/src/composition/index.ts
CHANGED
|
@@ -21,3 +21,5 @@ export { createInventoryContribution } from "./inventoryContribution.js";
|
|
|
21
21
|
export { createShippingContribution } from "./shippingContribution.js";
|
|
22
22
|
export { createFulfillmentContribution } from "./fulfillmentContribution.js";
|
|
23
23
|
export { createSubscriptionContribution } from "./subscriptionContribution.js";
|
|
24
|
+
export { createCommerceContribution } from "./commerceContribution.js";
|
|
25
|
+
export { createAccountSupportContribution } from "./accountSupportContribution.js";
|
package/src/fulfillment/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { FULFILLMENT_STATUS_MAP, CANONICAL_LOCAL_FULFILLMENT_STATUSES, CUSTOMER_STEP_SEQUENCE, canonicalStatusToken, stepForToken, customerStepFromSignals, phaseIndexForStep, stepLabelKey, timelineLabelForStep, trackingPhaseKeyForStep, stepUsesTruckIcon } from "./statusMap.js";
|
|
2
2
|
export { parseFulfillmentFact, parseFulfillmentTransitionConflict } from "./normalizedFulfillmentFacts.js";
|
|
3
3
|
export { readFulfillmentCapabilities } from "./providerCapabilities.js";
|
|
4
|
-
export { createOutboxOrderPaidFulfillmentHandler } from "./paidHandoff.js";
|
|
4
|
+
export { createOutboxOrderPaidFulfillmentHandler, outboxOrderPaidFulfillmentDescriptor, parseOutboxPayload } from "./paidHandoff.js";
|
|
5
5
|
export { collectPaidFulfillmentRecoveryCandidates } from "./paidFulfillmentRecovery.js";
|
|
6
6
|
export { runFulfillmentDispatchWorker } from "./providerDispatchWorker.js";
|
|
7
7
|
export { createFulfillmentCommandLedger } from "./providerCommandLedger.js";
|
|
@@ -9,7 +9,7 @@ import type { OrderPaidFulfillmentPort } from "./paidHandoffPorts.js";
|
|
|
9
9
|
const COMMERCE_ORDER_PAID_EVENT_TYPE = "commerce.order.paid";
|
|
10
10
|
const HANDLER_TIMEOUT_MS = 15_000;
|
|
11
11
|
|
|
12
|
-
const outboxOrderPaidFulfillmentDescriptor = Object.freeze({
|
|
12
|
+
export const outboxOrderPaidFulfillmentDescriptor = Object.freeze({
|
|
13
13
|
eventType: COMMERCE_ORDER_PAID_EVENT_TYPE, timeoutMs: HANDLER_TIMEOUT_MS,
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -113,7 +113,7 @@ export function createOutboxOrderPaidFulfillmentHandler(deps: {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function truncateReason(value: string): string { return value.length <= 300 ? value : `${value.slice(0, 300)}…`; }
|
|
116
|
-
function parseOutboxPayload<T>(schema: import("zod").ZodType<T>, payload: unknown):
|
|
116
|
+
export function parseOutboxPayload<T>(schema: import("zod").ZodType<T>, payload: unknown):
|
|
117
117
|
{ ok: true; data: T } | { ok: false; outcome: OutboxHandlerOutcome } {
|
|
118
118
|
const parsed = schema.safeParse(payload);
|
|
119
119
|
if (parsed.success) return { ok: true, data: parsed.data };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { createManagedStockAvailability, type ManagedStockRpc } from "./managedStockAvailability.js";
|
|
1
2
|
import type { z } from "zod";
|
|
2
3
|
import { createPostgresAdminInventoryPort } from "./adminInventory.js";
|
|
3
4
|
import type { InventoryMutationPort, InventoryReadPort } from "./ports.js";
|
|
4
5
|
import type { NewPurchaseStockReadPort } from "./newPurchaseStockAvailability.js";
|
|
6
|
+
import { createPostgresStockAvailability } from "./postgresStockAvailability.js";
|
|
5
7
|
import { createInventorySubscriptionForecastResponseSchema } from "./schemas.js";
|
|
6
8
|
|
|
7
9
|
export interface InventoryBindingDependencies {
|
|
@@ -12,6 +14,8 @@ export interface InventoryBindingDependencies {
|
|
|
12
14
|
readPort: InventoryReadPort; mutationPort: InventoryMutationPort;
|
|
13
15
|
} | null;
|
|
14
16
|
newPurchaseStockReadPort?: NewPurchaseStockReadPort | null;
|
|
17
|
+
stockSourceKey?: string;
|
|
18
|
+
stockRpc?: ManagedStockRpc;
|
|
15
19
|
now?: () => string;
|
|
16
20
|
}
|
|
17
21
|
|
|
@@ -31,18 +35,22 @@ export function createInventoryBindings(deps: InventoryBindingDependencies): Inv
|
|
|
31
35
|
});
|
|
32
36
|
if (!deps.provider?.providerSchema?.safeParse(deps.provider.stockMasterProvider).success) return refused("inventory_provider_mismatch");
|
|
33
37
|
let readPort: InventoryReadPort, mutationPort: InventoryMutationPort;
|
|
38
|
+
let stockRead: NewPurchaseStockReadPort | null | undefined;
|
|
34
39
|
if (deps.dataKind === "postgres") {
|
|
35
40
|
if (!deps.executor || typeof deps.executor.query !== "function") return refused("inventory_executor_required");
|
|
36
41
|
readPort = mutationPort = createPostgresAdminInventoryPort(deps.executor, deps.provider, deps.now);
|
|
42
|
+
stockRead = deps.stockSourceKey?.trim()
|
|
43
|
+
? createPostgresStockAvailability(deps.executor, { sourceKey: deps.stockSourceKey, now: deps.now ?? (() => new Date().toISOString()) }).readPort
|
|
44
|
+
: null;
|
|
37
45
|
} else if (deps.dataKind === "supabase") {
|
|
38
46
|
const store = deps.createManagedStore?.(deps.provider);
|
|
39
47
|
if (!store) return refused("inventory_managed_store_required");
|
|
40
48
|
({ readPort, mutationPort } = store);
|
|
49
|
+
stockRead = deps.newPurchaseStockReadPort ?? (deps.stockRpc
|
|
50
|
+
? createManagedStockAvailability(deps.stockRpc, { now: deps.now ?? (() => new Date().toISOString()) }) : null);
|
|
41
51
|
} else return refused("inventory_store_incompatible");
|
|
42
52
|
if (![readPort?.listStock, readPort?.listReservations, readPort?.checkAtp, readPort?.forecastSubscriptions, mutationPort?.adjustStock].every(fn => typeof fn === "function")) return refused("inventory_store_incompatible");
|
|
43
53
|
const responseSchema = createInventorySubscriptionForecastResponseSchema(deps.provider.providerSchema);
|
|
44
|
-
const native = deps.dataKind === "postgres";
|
|
45
|
-
const stockRead = native ? null : deps.newPurchaseStockReadPort;
|
|
46
54
|
const newPurchaseStockReadPort = typeof stockRead?.read === "function" ? stockRead : null;
|
|
47
55
|
return {
|
|
48
56
|
readPort: {
|
|
@@ -54,8 +62,8 @@ export function createInventoryBindings(deps: InventoryBindingDependencies): Inv
|
|
|
54
62
|
mutationPort, newPurchaseStockReadPort,
|
|
55
63
|
readiness: { ready: true, reason: null },
|
|
56
64
|
unsupported: {
|
|
57
|
-
newPurchaseStockRead:
|
|
58
|
-
|
|
65
|
+
newPurchaseStockRead: newPurchaseStockReadPort ? null : deps.dataKind === "postgres"
|
|
66
|
+
? "inventory_stock_source_key_required" : "inventory_new_purchase_stock_reader_required",
|
|
59
67
|
},
|
|
60
68
|
};
|
|
61
69
|
}
|
package/src/inventory/index.ts
CHANGED
|
@@ -22,3 +22,4 @@ export { INVENTORY_MIGRATIONS } from "./sql.js";
|
|
|
22
22
|
export { createInventoryBindings, type InventoryBindingDependencies, type InventoryBindings } from "./bindings.js";
|
|
23
23
|
export { createPostgresStockAvailability } from "./postgresStockAvailability.js";
|
|
24
24
|
export type { NativeStockPromise } from "./postgresStockAvailability.js";
|
|
25
|
+
export { createManagedStockAvailability, type ManagedStockRpc } from "./managedStockAvailability.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NewPurchaseStockReadPort } from "./newPurchaseStockAvailability.js";
|
|
2
|
+
import { parseStockReadResponse } from "./stockReadResponse.js";
|
|
3
|
+
|
|
4
|
+
/** Minimal service-role RPC seam; transport and credentials remain host-owned. */
|
|
5
|
+
export interface ManagedStockRpc {
|
|
6
|
+
rpc(name: string, args: Record<string, unknown>): PromiseLike<{
|
|
7
|
+
data: unknown;
|
|
8
|
+
error: { message: string; code?: string } | null;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Read-only managed ATP preview with fixed subscription priority. */
|
|
13
|
+
export function createManagedStockAvailability(client: ManagedStockRpc, options: { now: () => string }): NewPurchaseStockReadPort {
|
|
14
|
+
return {
|
|
15
|
+
async read(input) {
|
|
16
|
+
if (input.horizonDays !== 14 || input.excludeOrderId !== null) throw new Error("managed_stock_read_options_unsupported");
|
|
17
|
+
if (!input.skus.length) return new Map();
|
|
18
|
+
const { data, error } = await client.rpc("inventory_new_purchase_stock_read", { p_skus: input.skus, p_as_of: options.now() });
|
|
19
|
+
if (error) throw error;
|
|
20
|
+
return parseStockReadResponse(data);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { parseStockReadResponse, stockObject as object, stockQuantity as quantity } from "./stockReadResponse.js";
|
|
2
2
|
import type { NewPurchaseStockReadPort } from "./newPurchaseStockAvailability.js";
|
|
3
3
|
|
|
4
4
|
interface StockQueryExecutor {
|
|
@@ -8,16 +8,6 @@ export interface NativeStockPromise {
|
|
|
8
8
|
availableQuantity: number; forSaleQuantity: number; hardHoldQuantity: number;
|
|
9
9
|
safetyQuantity: number; softSubscriptionDemandQuantity: number; channelExposureQuantity: number;
|
|
10
10
|
}
|
|
11
|
-
function object(value: unknown): Record<string, unknown> {
|
|
12
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("inventory_stock_response_invalid");
|
|
13
|
-
return value as Record<string, unknown>;
|
|
14
|
-
}
|
|
15
|
-
function quantity(value: unknown): number {
|
|
16
|
-
if ((typeof value !== "number" && typeof value !== "string") || String(value).trim() === "") throw new Error("inventory_stock_quantity_invalid");
|
|
17
|
-
const n = Number(value);
|
|
18
|
-
if (!Number.isSafeInteger(n) || n < 0) throw new Error("inventory_stock_quantity_invalid");
|
|
19
|
-
return n;
|
|
20
|
-
}
|
|
21
11
|
/** Native read-only ATP. The fixed 14-day priority cannot be waived by a new
|
|
22
12
|
* purchase caller. Only the fenced native SQL allocator uses the renewal exemption. */
|
|
23
13
|
export function createPostgresStockAvailability(executor: StockQueryExecutor, options: { sourceKey: string; now: () => string }): {
|
|
@@ -38,16 +28,7 @@ export function createPostgresStockAvailability(executor: StockQueryExecutor, op
|
|
|
38
28
|
if (!input.skus.length) return new Map();
|
|
39
29
|
const value = (await executor.query(`SELECT public.inventory_new_purchase_stock_read(
|
|
40
30
|
$1::text,$2::jsonb,$3::timestamptz) AS response`, [options.sourceKey, JSON.stringify(input.skus), options.now()])).rows[0]?.response;
|
|
41
|
-
|
|
42
|
-
return new Map(value.map(value => {
|
|
43
|
-
const row = object(value);
|
|
44
|
-
if (typeof row.sku !== "string" || !["provider", "missing"].includes(String(row.source)) || typeof row.stale !== "boolean") throw new Error("inventory_stock_response_invalid");
|
|
45
|
-
const result: NewPurchaseStockRow = { sku: row.sku, catalogSkuId: row.catalogSkuId == null ? null : String(row.catalogSkuId),
|
|
46
|
-
source: row.source as "provider" | "missing", providerForSale: row.providerForSale == null ? null : quantity(row.providerForSale),
|
|
47
|
-
activeHolds: quantity(row.activeHolds), safetyStock: quantity(row.safetyStock), available: quantity(row.available), stale: row.stale,
|
|
48
|
-
renewalDemand: quantity(row.renewalDemand), availableForNewPurchases: quantity(row.availableForNewPurchases), excludedOrderHolds: quantity(row.excludedOrderHolds) };
|
|
49
|
-
return [result.sku, result];
|
|
50
|
-
}));
|
|
31
|
+
return parseStockReadResponse(value);
|
|
51
32
|
},
|
|
52
33
|
},
|
|
53
34
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { NewPurchaseStockRow } from "./contracts/newPurchaseStock.js";
|
|
2
|
+
|
|
3
|
+
export function stockObject(value: unknown): Record<string, unknown> {
|
|
4
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("inventory_stock_response_invalid");
|
|
5
|
+
return value as Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export function stockQuantity(value: unknown): number {
|
|
8
|
+
if ((typeof value !== "number" && typeof value !== "string") || String(value).trim() === "") throw new Error("inventory_stock_quantity_invalid");
|
|
9
|
+
const n = Number(value);
|
|
10
|
+
if (!Number.isSafeInteger(n) || n < 0) throw new Error("inventory_stock_quantity_invalid");
|
|
11
|
+
return n;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function parseStockReadResponse(value: unknown): Map<string, NewPurchaseStockRow> {
|
|
15
|
+
if (!Array.isArray(value)) throw new Error("inventory_stock_response_invalid");
|
|
16
|
+
return new Map(value.map(value => {
|
|
17
|
+
const row = stockObject(value);
|
|
18
|
+
if (typeof row.sku !== "string" || !["provider", "missing"].includes(String(row.source)) || typeof row.stale !== "boolean") throw new Error("inventory_stock_response_invalid");
|
|
19
|
+
const result: NewPurchaseStockRow = { sku: row.sku, catalogSkuId: row.catalogSkuId == null ? null : String(row.catalogSkuId),
|
|
20
|
+
source: row.source as "provider" | "missing", providerForSale: row.providerForSale == null ? null : stockQuantity(row.providerForSale),
|
|
21
|
+
activeHolds: stockQuantity(row.activeHolds), safetyStock: stockQuantity(row.safetyStock), available: stockQuantity(row.available), stale: row.stale,
|
|
22
|
+
renewalDemand: stockQuantity(row.renewalDemand), availableForNewPurchases: stockQuantity(row.availableForNewPurchases), excludedOrderHolds: stockQuantity(row.excludedOrderHolds) };
|
|
23
|
+
return [result.sku, result];
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createCommerceQuotePrimitives } from "../quotePrimitives.js";
|
|
2
|
+
export { acquisitionCapabilitySchema, acquisitionTermsExpectationSchema } from "../acquisitionTermsSchemas.js";
|
|
3
|
+
/** @consumer src/domains/commerce/quoteContracts.ts */
|
|
4
|
+
export { resolvedAcquisitionTermsSchema } from "../acquisitionTermsSchemas.js";
|
|
5
|
+
/** @consumer src/domains/commerce/quoteContracts.ts */
|
|
6
|
+
export { shippingTermsSchema } from "../../shipping/thresholdPolicy.js";
|
|
@@ -31,8 +31,9 @@ export type { NativeSubscriptionCommand, NativeSubscriptionCommandBinding } from
|
|
|
31
31
|
export { createPostgresStockWaitStore } from "./postgresStockWaitStore.js";
|
|
32
32
|
export type { NativeStockWaitBinding, NativeStockWaitAdmission } from "./postgresStockWaitStore.js";
|
|
33
33
|
|
|
34
|
-
/** Managed SQL is exposed for service-role hosts; no StockWaitStorePort
|
|
35
|
-
*
|
|
34
|
+
/** Managed SQL is exposed for service-role hosts; no StockWaitStorePort
|
|
35
|
+
* TypeScript adapter is composed for this graph. A NewPurchaseStockReadPort
|
|
36
|
+
* adapter is available in ../inventory for managed service-role hosts.
|
|
36
37
|
* SQL behavior is proved by the managed pgTAP/real-PostgreSQL witnesses.
|
|
37
38
|
*/
|
|
38
39
|
export const MANAGED_SUBSCRIPTION_STOCK_CAPABILITIES = Object.freeze({
|