@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,24 @@
|
|
|
1
|
+
import type { CheckoutContinuationAction } from "./checkoutPaymentContinuationCredential.js";
|
|
2
|
+
import type { CheckoutCookieResponse, CheckoutPaymentContinuationMinter } from "./checkoutPaymentContinuationCredential.js";
|
|
3
|
+
/** A separate guard: refusal diagnostics must not widen existing action authority. */
|
|
4
|
+
export declare function mintCheckoutRefusalContinuation<Rail extends string>(input: {
|
|
5
|
+
mint?: CheckoutPaymentContinuationMinter<Rail>;
|
|
6
|
+
res: CheckoutCookieResponse;
|
|
7
|
+
journeyId: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
requestRail: string;
|
|
10
|
+
response: {
|
|
11
|
+
status: string;
|
|
12
|
+
clientAction?: CheckoutContinuationAction;
|
|
13
|
+
};
|
|
14
|
+
result: {
|
|
15
|
+
orderId: string;
|
|
16
|
+
paymentIntentId: string;
|
|
17
|
+
paymentAttemptId: string | null;
|
|
18
|
+
executionRail: string;
|
|
19
|
+
continuationActionOrigin: "fresh_execution" | null;
|
|
20
|
+
status: string;
|
|
21
|
+
runtimePaymentStatus?: string;
|
|
22
|
+
paymentAttemptStatus?: string | null;
|
|
23
|
+
};
|
|
24
|
+
}, executionRails: readonly [Rail, Rail]): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isCheckoutContinuationRail } from "./checkoutPaymentContinuationCredential.js";
|
|
2
|
+
/** A separate guard: refusal diagnostics must not widen existing action authority. */
|
|
3
|
+
export function mintCheckoutRefusalContinuation(input, executionRails) {
|
|
4
|
+
const { result, response } = input;
|
|
5
|
+
if (!input.mint || result.continuationActionOrigin !== "fresh_execution"
|
|
6
|
+
|| result.runtimePaymentStatus !== "failed" || result.paymentAttemptStatus !== "failed" || response.status !== "failed"
|
|
7
|
+
|| (response.clientAction && response.clientAction.kind !== "none")
|
|
8
|
+
|| !result.orderId || !result.paymentIntentId || !result.paymentAttemptId
|
|
9
|
+
|| result.executionRail !== input.requestRail
|
|
10
|
+
|| !isCheckoutContinuationRail(result.executionRail, executionRails))
|
|
11
|
+
return;
|
|
12
|
+
try {
|
|
13
|
+
input.mint(input.res, { journeyId: input.journeyId, clientId: input.clientId,
|
|
14
|
+
orderId: result.orderId, paymentIntentId: result.paymentIntentId,
|
|
15
|
+
paymentAttemptId: result.paymentAttemptId, executionRail: result.executionRail });
|
|
16
|
+
}
|
|
17
|
+
catch { /* Optional guidance must never turn a settled refusal into an error. */ }
|
|
18
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { PaymentExecutionBaseInput, PaymentExecutionBaseResult } from "@openlup/core/payment";
|
|
2
|
+
export type CheckoutExecutionProvider = string;
|
|
3
|
+
export type CheckoutProviderFlow = string;
|
|
4
|
+
export interface CheckoutRuntimeRequest<MethodKind extends string = string, RecurringModel extends string = string> {
|
|
5
|
+
idempotencyKey: string;
|
|
6
|
+
paymentProvider: CheckoutExecutionProvider;
|
|
7
|
+
providerFlow: CheckoutProviderFlow;
|
|
8
|
+
paymentAttemptSequence?: number;
|
|
9
|
+
paymentMethodRef?: string;
|
|
10
|
+
paymentMethodAliasType?: MethodKind;
|
|
11
|
+
paymentMethodRecurringModel?: RecurringModel;
|
|
12
|
+
providerPayer?: {
|
|
13
|
+
email: string;
|
|
14
|
+
name: string;
|
|
15
|
+
ip?: string | null;
|
|
16
|
+
userAgent?: string | null;
|
|
17
|
+
};
|
|
18
|
+
saveForFutureUse?: boolean;
|
|
19
|
+
returnContext?: "public" | "account";
|
|
20
|
+
paymentExecution?: unknown;
|
|
21
|
+
declaredBankId?: string;
|
|
22
|
+
metadata: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface CheckoutRuntimeExecutionInput<Transient, Flow extends string = string, MethodKind extends string = string, RecurringModel extends string = string> extends PaymentExecutionBaseInput {
|
|
25
|
+
orderRef: string;
|
|
26
|
+
providerFlow?: Flow;
|
|
27
|
+
clientId?: string;
|
|
28
|
+
orderId?: string;
|
|
29
|
+
paymentMethodRef?: string;
|
|
30
|
+
paymentMethodAliasType?: MethodKind;
|
|
31
|
+
paymentMethodRecurringModel?: RecurringModel;
|
|
32
|
+
payer?: {
|
|
33
|
+
email: string;
|
|
34
|
+
name: string;
|
|
35
|
+
ip?: string | null;
|
|
36
|
+
userAgent?: string | null;
|
|
37
|
+
};
|
|
38
|
+
saveForFutureUse?: boolean;
|
|
39
|
+
returnContext?: "public" | "account";
|
|
40
|
+
transientProviderInput?: Transient | null;
|
|
41
|
+
}
|
|
42
|
+
export interface CheckoutRuntimeExecutionResult extends PaymentExecutionBaseResult {
|
|
43
|
+
provider: CheckoutExecutionProvider;
|
|
44
|
+
clientSecret?: string | null;
|
|
45
|
+
redirectUrl?: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface CheckoutRuntimeExecutionPort<Execution, Transient, Flow extends string = string, MethodKind extends string = string, RecurringModel extends string = string> {
|
|
48
|
+
execute(input: CheckoutRuntimeExecutionInput<Transient, Flow, MethodKind, RecurringModel>): Promise<Execution>;
|
|
49
|
+
}
|
|
50
|
+
export interface CheckoutRuntimeResultRequest {
|
|
51
|
+
idempotencyKey: string;
|
|
52
|
+
orderId: string;
|
|
53
|
+
paymentIntentId: string;
|
|
54
|
+
resultStatus: string;
|
|
55
|
+
}
|
|
56
|
+
export interface CheckoutRuntimePaymentPort {
|
|
57
|
+
createIntent(input: {
|
|
58
|
+
idempotencyKey: string;
|
|
59
|
+
targetKind: "one_time_order" | "subscription_cycle";
|
|
60
|
+
orderId: string;
|
|
61
|
+
subscriptionId: string | null;
|
|
62
|
+
subscriptionCycleId: string | null;
|
|
63
|
+
amountMinor: number;
|
|
64
|
+
currency: string;
|
|
65
|
+
metadata: Record<string, unknown>;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
paymentIntentId: string;
|
|
68
|
+
paymentId: string;
|
|
69
|
+
status: string;
|
|
70
|
+
replayed: boolean;
|
|
71
|
+
}>;
|
|
72
|
+
applyResult(input: CheckoutRuntimeResultRequest): Promise<{
|
|
73
|
+
orderId: string;
|
|
74
|
+
kind: string;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
export interface CheckoutRuntimeResponse {
|
|
78
|
+
runtime: {
|
|
79
|
+
orderId: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { CreateQuoteRequest, PricingPolicySnapshot } from "../../pricing/index.js";
|
|
3
|
+
import type { CheckoutJourney, CommerceOrderDraftWritePort, CheckoutCommandRuntimeResult } from "../contracts/index.js";
|
|
4
|
+
import type { CommerceQuotePort } from "../ports.js";
|
|
5
|
+
import type { CheckoutCommandV1, CheckoutCommandPersistenceResult } from "../checkoutCommandSchemas.js";
|
|
6
|
+
import { type CheckoutCompensationPort } from "./commerceCheckoutCompensation.js";
|
|
7
|
+
import type { PaidOrderOrchestrationDeps, CheckoutJourneyRuntimeRequest, CheckoutJourneyRuntimeResponse, CheckoutJourneyResultRequest, OrchestratedCheckoutResult } from "./commercePaidOrderOrchestration.js";
|
|
8
|
+
import type { CheckoutPaymentExecution } from "./commerceCheckoutProviderPayment.js";
|
|
9
|
+
import type { CheckoutQuoteSnapshot } from "./checkoutQuoteTypes.js";
|
|
10
|
+
export interface CheckoutCommandQuoteRequest extends CreateQuoteRequest {
|
|
11
|
+
customerEligibilityContext: {
|
|
12
|
+
email: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface CheckoutCommandExecutionRequest<Provider extends string = string, MethodKind extends string = string, RecurringModel extends string = string> {
|
|
16
|
+
command: CheckoutCommandV1;
|
|
17
|
+
paymentProvider: Provider;
|
|
18
|
+
paymentAttemptSequence?: number;
|
|
19
|
+
paymentMethodRef?: string;
|
|
20
|
+
paymentMethodAliasType?: MethodKind;
|
|
21
|
+
paymentMethodRecurringModel?: RecurringModel;
|
|
22
|
+
saveForFutureUse?: boolean;
|
|
23
|
+
returnContext?: "public" | "account";
|
|
24
|
+
providerPayer?: {
|
|
25
|
+
email: string;
|
|
26
|
+
name: string;
|
|
27
|
+
ip?: string | null;
|
|
28
|
+
userAgent?: string | null;
|
|
29
|
+
};
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export declare function checkoutCommandJourney(command: CheckoutCommandV1, metadata: Record<string, unknown> | undefined): CheckoutJourney<CheckoutCommandQuoteRequest, PricingPolicySnapshot>;
|
|
33
|
+
export declare function createCheckoutCommandExecutor<Provisioned extends {
|
|
34
|
+
clientId: string;
|
|
35
|
+
addressId: string;
|
|
36
|
+
}, Snapshot extends CheckoutQuoteSnapshot, Draft extends {
|
|
37
|
+
orderDraft: {
|
|
38
|
+
orderId: string;
|
|
39
|
+
};
|
|
40
|
+
}, Extension extends object, Runtime extends CheckoutJourneyRuntimeResponse<Provider>, Settlement, ExecutionPort extends object, PaymentExecution extends CheckoutPaymentExecution, Provider extends string, Flow extends string, MethodKind extends string = string, RecurringModel extends string = string>(bindings: {
|
|
41
|
+
commandSchema: z.ZodType<CheckoutCommandV1>;
|
|
42
|
+
commandProvisioned(persistence: CheckoutCommandPersistenceResult): Provisioned;
|
|
43
|
+
orchestrateCheckoutJourney(deps: PaidOrderOrchestrationDeps<Provisioned, CheckoutCommandQuoteRequest, Snapshot, Draft, Extension, Runtime, Settlement, PaymentExecution, Provider, Flow, MethodKind, RecurringModel>, journey: CheckoutJourney<CheckoutCommandQuoteRequest, PricingPolicySnapshot>): Promise<OrchestratedCheckoutResult<Snapshot, Provider>>;
|
|
44
|
+
}): {
|
|
45
|
+
executeCheckoutCommand: (request: CheckoutCommandExecutionRequest<Provider, MethodKind, RecurringModel>, deps: {
|
|
46
|
+
quotePort?: CommerceQuotePort<CheckoutCommandQuoteRequest, Snapshot, import("../../pricing/index.js").CreateQuoteOptions>;
|
|
47
|
+
persistencePort?: {
|
|
48
|
+
persistCheckoutCommand(command: CheckoutCommandV1): Promise<CheckoutCommandPersistenceResult>;
|
|
49
|
+
};
|
|
50
|
+
orderDraftPort?: CommerceOrderDraftWritePort<{
|
|
51
|
+
idempotencyKey: string;
|
|
52
|
+
quoteSnapshot: Snapshot;
|
|
53
|
+
}, Draft>;
|
|
54
|
+
resolveExecutionPort?: (provider: string) => ExecutionPort;
|
|
55
|
+
compensationPort?: CheckoutCompensationPort;
|
|
56
|
+
now?: () => Date;
|
|
57
|
+
startRuntime(request: CheckoutJourneyRuntimeRequest<Snapshot, PaymentExecution, Provider, Flow, MethodKind, RecurringModel> & Extension, executionPort: ExecutionPort): Promise<Runtime>;
|
|
58
|
+
applyPaymentResult(request: CheckoutJourneyResultRequest): Promise<Settlement>;
|
|
59
|
+
}) => Promise<CheckoutCommandRuntimeResult<Snapshot, CheckoutCommandPersistenceResult, Draft, Runtime, Settlement>>;
|
|
60
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { buildOrderDeliveryContact } from "../checkoutHelpers.js";
|
|
2
|
+
import { CommerceRuntimeConflictError, CommerceRuntimePersistenceError } from "../runtimeErrors.js";
|
|
3
|
+
import { tryCompensate } from "./commerceCheckoutCompensation.js";
|
|
4
|
+
import { CheckoutOrchestrationError } from "./commerceCheckoutOrchestrationError.js";
|
|
5
|
+
export function checkoutCommandJourney(command, metadata) {
|
|
6
|
+
return {
|
|
7
|
+
idempotencyKey: command.idempotencyKey,
|
|
8
|
+
contactEmail: command.customer.email,
|
|
9
|
+
createQuoteRequest: () => ({
|
|
10
|
+
mode: command.mode,
|
|
11
|
+
lines: command.lines.map((line) => ({
|
|
12
|
+
sku: line.sku,
|
|
13
|
+
quantity: line.quantity,
|
|
14
|
+
modeAtLine: command.mode,
|
|
15
|
+
})),
|
|
16
|
+
cadenceDays: command.cadenceDays ?? null,
|
|
17
|
+
promoCodes: [],
|
|
18
|
+
customerEligibilityContext: { email: command.customer.email },
|
|
19
|
+
}),
|
|
20
|
+
createRuntimeMetadata: () => ({
|
|
21
|
+
...metadata,
|
|
22
|
+
checkoutCommandVersion: command.version,
|
|
23
|
+
cadenceDays: command.cadenceDays,
|
|
24
|
+
deliveryContact: buildOrderDeliveryContact({
|
|
25
|
+
recipientName: `${command.customer.firstName} ${command.customer.lastName}`,
|
|
26
|
+
contactEmail: command.customer.email,
|
|
27
|
+
contactPhone: command.customer.phone,
|
|
28
|
+
line1: command.shippingAddress.street,
|
|
29
|
+
city: command.shippingAddress.city,
|
|
30
|
+
postalCode: command.shippingAddress.postalCode,
|
|
31
|
+
country: command.shippingAddress.country,
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function createCheckoutCommandExecutor(bindings) {
|
|
37
|
+
const COMMAND_CONFLICT_REASONS = new Set([
|
|
38
|
+
"journey_consumed",
|
|
39
|
+
"promotion_code_price_changed",
|
|
40
|
+
"provider_attempt_in_flight",
|
|
41
|
+
]);
|
|
42
|
+
async function executeCheckoutCommand(request, deps) {
|
|
43
|
+
const command = bindings.commandSchema.safeParse(request.command);
|
|
44
|
+
if (!command.success)
|
|
45
|
+
throw new CommerceRuntimeConflictError("Checkout command is invalid");
|
|
46
|
+
const { quotePort, persistencePort, orderDraftPort, resolveExecutionPort } = deps;
|
|
47
|
+
if (!quotePort || !persistencePort || !orderDraftPort || !resolveExecutionPort) {
|
|
48
|
+
throw new CommerceRuntimePersistenceError("Checkout command runtime composition is incomplete", { missing: [!quotePort && "quote", !persistencePort && "persistence", !orderDraftPort && "order_draft", !resolveExecutionPort && "payment_provider"].filter(Boolean) });
|
|
49
|
+
}
|
|
50
|
+
const adapter = resolveExecutionPort(request.paymentProvider);
|
|
51
|
+
if (typeof adapter !== "object" || adapter === null || !("execute" in adapter) || typeof adapter.execute !== "function") {
|
|
52
|
+
throw new CommerceRuntimePersistenceError("Checkout command payment provider adapter is unavailable");
|
|
53
|
+
}
|
|
54
|
+
const executionPort = adapter;
|
|
55
|
+
const journey = checkoutCommandJourney(command.data, request.metadata);
|
|
56
|
+
// Quote and its currency guard stay ahead of every write: a mismatched
|
|
57
|
+
// currency must not leave a persisted client, address, or draft behind.
|
|
58
|
+
const quoteSnapshot = await quotePort.createQuote(journey.createQuoteRequest());
|
|
59
|
+
if (quoteSnapshot.quote.currency !== command.data.currency) {
|
|
60
|
+
throw new CommerceRuntimeConflictError("Checkout command currency does not match quote", {
|
|
61
|
+
commandCurrency: command.data.currency,
|
|
62
|
+
quoteCurrency: quoteSnapshot.quote.currency,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const persistence = await persistencePort.persistCheckoutCommand(command.data);
|
|
66
|
+
if (persistence.subjectId !== null) {
|
|
67
|
+
throw new CommerceRuntimePersistenceError("Checkout command persistence returned an unexpected subject");
|
|
68
|
+
}
|
|
69
|
+
// From here the neutral command runs the SAME application service as the
|
|
70
|
+
// legacy configurator checkout: one stage sequence, one start-runtime failure
|
|
71
|
+
// mapping, one provider invariant set, one settle step, one compensation.
|
|
72
|
+
const captured = { orderDraft: null, runtime: null, settlement: null };
|
|
73
|
+
try {
|
|
74
|
+
const orchestrationDeps = {
|
|
75
|
+
journey,
|
|
76
|
+
provisioned: bindings.commandProvisioned(persistence),
|
|
77
|
+
checkoutKind: command.data.mode === "subscription" ? "subscription_initial" : "one_time",
|
|
78
|
+
quotePort,
|
|
79
|
+
quoteSnapshot,
|
|
80
|
+
orderDraftPort: {
|
|
81
|
+
createOrderDraft: async (draftRequest, options) => {
|
|
82
|
+
captured.orderDraft = await orderDraftPort.createOrderDraft(draftRequest, options);
|
|
83
|
+
return captured.orderDraft;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
runtimePort: {
|
|
87
|
+
startRuntime: async (startRequest) => {
|
|
88
|
+
captured.runtime = await deps.startRuntime(startRequest, executionPort);
|
|
89
|
+
return captured.runtime;
|
|
90
|
+
},
|
|
91
|
+
applyPaymentResult: async (settleRequest) => {
|
|
92
|
+
captured.settlement = await deps.applyPaymentResult(settleRequest);
|
|
93
|
+
return captured.settlement;
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
paymentProvider: request.paymentProvider,
|
|
97
|
+
paymentAttemptSequence: request.paymentAttemptSequence,
|
|
98
|
+
paymentMethodRef: request.paymentMethodRef,
|
|
99
|
+
paymentMethodAliasType: request.paymentMethodAliasType,
|
|
100
|
+
paymentMethodRecurringModel: request.paymentMethodRecurringModel,
|
|
101
|
+
saveForFutureUse: request.saveForFutureUse,
|
|
102
|
+
returnContext: request.returnContext,
|
|
103
|
+
providerPayer: request.providerPayer,
|
|
104
|
+
now: deps.now ?? (() => new Date()),
|
|
105
|
+
};
|
|
106
|
+
await bindings.orchestrateCheckoutJourney(orchestrationDeps, journey);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
throw await mapOrchestrationFailure(error, journey.idempotencyKey, deps.compensationPort);
|
|
110
|
+
}
|
|
111
|
+
if (!captured.orderDraft || !captured.runtime) {
|
|
112
|
+
throw new CommerceRuntimePersistenceError("Checkout command runtime produced no result");
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
quoteSnapshot,
|
|
116
|
+
persistence,
|
|
117
|
+
orderDraft: captured.orderDraft,
|
|
118
|
+
runtime: captured.runtime,
|
|
119
|
+
settlement: captured.settlement,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async function mapOrchestrationFailure(error, idempotencyKey, compensationPort) {
|
|
123
|
+
if (!(error instanceof CheckoutOrchestrationError))
|
|
124
|
+
return error;
|
|
125
|
+
// `orderIdForCompensation` is a compensation capability, not an order id: the
|
|
126
|
+
// saga deliberately withholds it when a provider attempt may be in flight.
|
|
127
|
+
if (error.orderIdForCompensation && compensationPort) {
|
|
128
|
+
await tryCompensate(compensationPort, idempotencyKey, error.orderIdForCompensation);
|
|
129
|
+
}
|
|
130
|
+
const details = { stage: error.message.split(":")[0], reason: error.reason };
|
|
131
|
+
return error.reason && COMMAND_CONFLICT_REASONS.has(error.reason)
|
|
132
|
+
? new CommerceRuntimeConflictError("Checkout command could not be completed", details)
|
|
133
|
+
: new CommerceRuntimePersistenceError("Checkout command runtime failed", details);
|
|
134
|
+
}
|
|
135
|
+
return { executeCheckoutCommand };
|
|
136
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface CheckoutCompensationPort {
|
|
2
|
+
releaseOrderReservations(input: {
|
|
3
|
+
idempotencyKey: string;
|
|
4
|
+
orderId: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
releasedCount: number;
|
|
8
|
+
}>;
|
|
9
|
+
cancelUnstartedPromotionOrder(input: {
|
|
10
|
+
idempotencyKey: string;
|
|
11
|
+
orderId: string;
|
|
12
|
+
reason: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
cancelled: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
cancelAbandonedOrder(input: {
|
|
17
|
+
idempotencyKey: string;
|
|
18
|
+
orderId: string;
|
|
19
|
+
reason: string;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
cancelled: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export declare function tryCompensate(port: CheckoutCompensationPort, idempotencyKey: string, orderId: string, options?: {
|
|
25
|
+
cancellationReason?: string;
|
|
26
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export async function tryCompensate(port, idempotencyKey, orderId, options) {
|
|
2
|
+
const promotionCancellationReason = options?.cancellationReason
|
|
3
|
+
?? "checkout_orchestration_failed_before_runtime";
|
|
4
|
+
const abandonedCancellationReason = options?.cancellationReason
|
|
5
|
+
?? "checkout_orchestration_failed_before_provider_dispatch";
|
|
6
|
+
try {
|
|
7
|
+
await port.releaseOrderReservations({
|
|
8
|
+
idempotencyKey: `${idempotencyKey}:checkout-compensation`,
|
|
9
|
+
orderId,
|
|
10
|
+
reason: "checkout_orchestration_failed",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
console.warn("checkout_compensation_release_failed", JSON.stringify({ orderId }));
|
|
15
|
+
}
|
|
16
|
+
let promotionOrderCancelled = false;
|
|
17
|
+
try {
|
|
18
|
+
const result = await port.cancelUnstartedPromotionOrder({
|
|
19
|
+
idempotencyKey,
|
|
20
|
+
orderId,
|
|
21
|
+
reason: promotionCancellationReason,
|
|
22
|
+
});
|
|
23
|
+
promotionOrderCancelled = result.cancelled;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
console.warn("checkout_promotion_draft_compensation_failed", JSON.stringify({ orderId }));
|
|
27
|
+
}
|
|
28
|
+
if (promotionOrderCancelled)
|
|
29
|
+
return;
|
|
30
|
+
// The promotion-specific cleanup deliberately refuses an order once a local
|
|
31
|
+
// payment intent exists. A deterministic pre-dispatch runtime failure is still
|
|
32
|
+
// safe to cancel: the caller withholds the order id for every uncertain or
|
|
33
|
+
// in-flight provider attempt, so reaching this fallback proves no PSP dispatch
|
|
34
|
+
// may have taken money. Use the canonical aggregate cleanup to close the order,
|
|
35
|
+
// payment intent and provisional subscription instead of leaving pending ghosts.
|
|
36
|
+
try {
|
|
37
|
+
await port.cancelAbandonedOrder({
|
|
38
|
+
idempotencyKey,
|
|
39
|
+
orderId,
|
|
40
|
+
reason: abandonedCancellationReason,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
console.warn("checkout_abandoned_order_compensation_failed", JSON.stringify({ orderId }));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { type AcquisitionTermsExpectation, type CreateQuoteRequest } from "../../pricing/index.js";
|
|
3
|
+
import type { CheckoutKind, ConfiguratorIntent } from "../contracts/index.js";
|
|
4
|
+
import type { CheckoutQuoteSnapshot } from "./checkoutQuoteTypes.js";
|
|
5
|
+
import type { StarterDeclaration } from "./commerceStarterOfferGuard.js";
|
|
6
|
+
import { type CheckoutResumeGuardDeps } from "./commerceCheckoutResumeGuard.js";
|
|
7
|
+
export declare function createSavedAcquisitionContinuation<Intent extends ConfiguratorIntent & {
|
|
8
|
+
selectedDelivery?: unknown;
|
|
9
|
+
}, Provisioned, Request extends CreateQuoteRequest, Snapshot extends CheckoutQuoteSnapshot, InvoicePreference, Response>(bindings: {
|
|
10
|
+
quoteSchema: z.ZodType<Snapshot>;
|
|
11
|
+
buildQuoteRequest(intent: Intent, provisioned: Provisioned): Request;
|
|
12
|
+
sameSubjectContext(context: NonNullable<Snapshot["quote"]["context"]>, fresh: Request, provisioned: Provisioned): boolean;
|
|
13
|
+
runtimeMetadata(intent: Intent, kind: CheckoutKind, preference?: InvoicePreference): Record<string, unknown>;
|
|
14
|
+
starterDeclaration(intent: Intent): StarterDeclaration | undefined;
|
|
15
|
+
starterPlan(snapshot: Snapshot): {
|
|
16
|
+
starterIntervalDays: number;
|
|
17
|
+
delivery2: {
|
|
18
|
+
discountBps: number;
|
|
19
|
+
};
|
|
20
|
+
graduation: {
|
|
21
|
+
cadenceDays: number;
|
|
22
|
+
lines: Array<{
|
|
23
|
+
qty: number;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
} | undefined;
|
|
27
|
+
buildSavedOrderResumeResponse(input: {
|
|
28
|
+
resumable: Awaited<ReturnType<NonNullable<CheckoutResumeGuardDeps["resumableOrderPort"]>["findResumableOrderForClient"]>> & {};
|
|
29
|
+
clientId: string;
|
|
30
|
+
checkoutKind: CheckoutKind;
|
|
31
|
+
intent: Intent;
|
|
32
|
+
}): Response;
|
|
33
|
+
}): {
|
|
34
|
+
resolveSavedAcquisitionContinuation: (input: {
|
|
35
|
+
deps: CheckoutResumeGuardDeps;
|
|
36
|
+
clientId: string;
|
|
37
|
+
provisioned: Provisioned;
|
|
38
|
+
checkoutKind: CheckoutKind;
|
|
39
|
+
intent: Intent;
|
|
40
|
+
invoicePreference?: InvoicePreference;
|
|
41
|
+
expectedQuote?: {
|
|
42
|
+
totalGross: {
|
|
43
|
+
amountMinor: number;
|
|
44
|
+
currency: string;
|
|
45
|
+
};
|
|
46
|
+
acquisitionTerms?: AcquisitionTermsExpectation;
|
|
47
|
+
};
|
|
48
|
+
now: () => Date;
|
|
49
|
+
}) => Promise<Response | null>;
|
|
50
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { acquisitionExpectationChanged } from "../../pricing/index.js";
|
|
2
|
+
import { stableJson } from "../../promotions/index.js";
|
|
3
|
+
import { selectedDeliveryMatches } from "./commerceCheckoutResumeGuard.js";
|
|
4
|
+
export function createSavedAcquisitionContinuation(bindings) {
|
|
5
|
+
async function resolveSavedAcquisitionContinuation(input) {
|
|
6
|
+
const { deps, clientId, checkoutKind, intent, expectedQuote } = input;
|
|
7
|
+
if (!deps.resumableOrderPort || !expectedQuote || checkoutKind !== "subscription_initial")
|
|
8
|
+
return null;
|
|
9
|
+
try {
|
|
10
|
+
const resumable = await deps.resumableOrderPort.findResumableOrderForClient({
|
|
11
|
+
clientId, withinMinutes: deps.resumeWindowMinutes ?? 60,
|
|
12
|
+
now: input.now(), journeyKey: intent.idempotencyKey,
|
|
13
|
+
});
|
|
14
|
+
if (!resumable || !resumable.paymentIntentId || !selectedDeliveryMatches(resumable.metadata, intent))
|
|
15
|
+
return null;
|
|
16
|
+
const saved = bindings.quoteSchema.safeParse(resumable.metadata?.quoteSnapshot);
|
|
17
|
+
if (!saved.success)
|
|
18
|
+
return null;
|
|
19
|
+
const { quote } = saved.data;
|
|
20
|
+
const context = quote.context;
|
|
21
|
+
const fresh = bindings.buildQuoteRequest(intent, input.provisioned);
|
|
22
|
+
if (!context || context.mode !== "subscription" || context.cadenceDays !== fresh.cadenceDays
|
|
23
|
+
|| !bindings.sameSubjectContext(context, fresh, input.provisioned) || context.offerVersion !== intent.offerVersion
|
|
24
|
+
|| stableJson(context.promoCodes) !== stableJson(fresh.promoCodes)
|
|
25
|
+
|| lineKey(quote.lines) !== lineKey(fresh.lines)
|
|
26
|
+
|| stableJson(quote.totalGross) !== stableJson(expectedQuote.totalGross)
|
|
27
|
+
|| acquisitionExpectationChanged(expectedQuote.acquisitionTerms, context.acquisitionTerms)
|
|
28
|
+
|| acquisitionExpectationChanged(bindings.starterDeclaration(intent)?.acquisitionTerms, context.acquisitionTerms))
|
|
29
|
+
return null;
|
|
30
|
+
const metadata = resumable.metadata ?? {};
|
|
31
|
+
const finalized = record(metadata.runtimeFinalize);
|
|
32
|
+
const savedContact = metadata.deliveryContact ?? finalized?.deliveryContact;
|
|
33
|
+
const freshMetadata = bindings.runtimeMetadata(intent, checkoutKind, input.invoicePreference);
|
|
34
|
+
if (!savedContact || stableJson(savedContact) !== stableJson(freshMetadata.deliveryContact))
|
|
35
|
+
return null;
|
|
36
|
+
const savedInvoice = metadata.invoiceBuyerSnapshot ?? finalized?.invoiceBuyerSnapshot;
|
|
37
|
+
if (!savedInvoice || stableJson(savedInvoice) !== stableJson(freshMetadata.invoiceBuyerSnapshot))
|
|
38
|
+
return null;
|
|
39
|
+
const starter = bindings.starterPlan(saved.data);
|
|
40
|
+
const declared = bindings.starterDeclaration(intent);
|
|
41
|
+
if (Boolean(starter) !== Boolean(declared))
|
|
42
|
+
return null;
|
|
43
|
+
if (starter && declared && (starter.starterIntervalDays !== declared.intervalDays
|
|
44
|
+
|| starter.delivery2.discountBps !== declared.delivery2DiscountBps
|
|
45
|
+
|| starter.graduation.cadenceDays !== declared.steady.cadenceDays
|
|
46
|
+
|| starter.graduation.lines.reduce((n, line) => n + line.qty, 0) !== declared.steady.units))
|
|
47
|
+
return null;
|
|
48
|
+
return bindings.buildSavedOrderResumeResponse({ resumable, clientId, checkoutKind, intent });
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Lookup is an optimization; regular quote/admission remains authoritative.
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function lineKey(lines) {
|
|
56
|
+
const totals = new Map();
|
|
57
|
+
for (const line of lines)
|
|
58
|
+
totals.set(line.sku, (totals.get(line.sku) ?? 0) + line.quantity);
|
|
59
|
+
return stableJson([...totals].sort(([a], [b]) => a.localeCompare(b)));
|
|
60
|
+
}
|
|
61
|
+
function record(value) {
|
|
62
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
63
|
+
? value : null;
|
|
64
|
+
}
|
|
65
|
+
return { resolveSavedAcquisitionContinuation };
|
|
66
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HttpResponse } from "../../http/index.js";
|
|
2
|
+
import type { BffResponder } from "../../bff/index.js";
|
|
3
|
+
import type { z } from "zod";
|
|
4
|
+
import type { CheckoutKind, CommerceCustomerDefaultsReadPort } from "../contracts/index.js";
|
|
5
|
+
export declare function readCheckoutCustomerDefaults<Snapshot>(input: {
|
|
6
|
+
port: CommerceCustomerDefaultsReadPort<Snapshot> | undefined;
|
|
7
|
+
clientId: string;
|
|
8
|
+
checkoutKind: CheckoutKind;
|
|
9
|
+
recordStage: <T>(operation: () => Promise<T>) => Promise<T>;
|
|
10
|
+
}, schema: z.ZodType<Snapshot>): Promise<Snapshot | null>;
|
|
11
|
+
export declare function readCheckoutCustomerDefaultsOrRespond<Snapshot>(input: Parameters<typeof readCheckoutCustomerDefaults<Snapshot>>[0] & {
|
|
12
|
+
res: HttpResponse;
|
|
13
|
+
}, schema: z.ZodType<Snapshot>, responder: BffResponder): Promise<{
|
|
14
|
+
kind: "read";
|
|
15
|
+
snapshot: Snapshot | null;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "responded";
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export async function readCheckoutCustomerDefaults(input, schema) {
|
|
2
|
+
const { port, clientId, checkoutKind, recordStage } = input;
|
|
3
|
+
if (!port)
|
|
4
|
+
return null;
|
|
5
|
+
const snapshot = await recordStage(() => port.getCustomerDefaultsSnapshot({ clientId, checkoutKind }));
|
|
6
|
+
return snapshot ? schema.parse(snapshot) : null;
|
|
7
|
+
}
|
|
8
|
+
export async function readCheckoutCustomerDefaultsOrRespond(input, schema, responder) {
|
|
9
|
+
const { res, ...read } = input;
|
|
10
|
+
try {
|
|
11
|
+
return { kind: "read", snapshot: await readCheckoutCustomerDefaults(read, schema) };
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
responder.sendBffError(res, "UPSTREAM_UNAVAILABLE", "Checkout customer defaults read failed", { details: { feature: "checkout", stage: "customer_defaults" } });
|
|
15
|
+
return { kind: "responded" };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { HttpResponse } from "../../http/index.js";
|
|
2
|
+
import type { BffResponder } from "../../bff/index.js";
|
|
3
|
+
import type { CheckoutKind, ConfiguratorIntent as NeutralIntent } from "../contracts/index.js";
|
|
4
|
+
import type { CommerceQuotePort } from "../ports.js";
|
|
5
|
+
import type { PricingPolicySnapshot } from "../../pricing/index.js";
|
|
6
|
+
import type { CheckoutQuoteSnapshot } from "./checkoutQuoteTypes.js";
|
|
7
|
+
import { type CheckoutCompensationPort } from "./commerceCheckoutCompensation.js";
|
|
8
|
+
import type { CheckoutTimingOutcome } from "./commerceCheckoutTiming.js";
|
|
9
|
+
export declare function createCheckoutFailureHandler<Intent extends NeutralIntent, Provisioned, Request, Snapshot extends CheckoutQuoteSnapshot>(bindings: {
|
|
10
|
+
responder: BffResponder;
|
|
11
|
+
logProviderFailure(error: unknown): void;
|
|
12
|
+
respondQuoteFailure(res: HttpResponse, error: unknown): boolean;
|
|
13
|
+
previewDiagnosticsEnabled(): boolean;
|
|
14
|
+
respondToPromotionCodePriceChange(input: {
|
|
15
|
+
res: HttpResponse;
|
|
16
|
+
quotePort: CommerceQuotePort<Request, Snapshot, import("../../pricing/index.js").CreateQuoteOptions>;
|
|
17
|
+
intent: Intent;
|
|
18
|
+
provisioned: Provisioned;
|
|
19
|
+
checkoutKind: CheckoutKind;
|
|
20
|
+
acceptedQuoteSnapshot: Snapshot | null;
|
|
21
|
+
expectedQuote?: {
|
|
22
|
+
totalGross: {
|
|
23
|
+
amountMinor: number;
|
|
24
|
+
currency: string;
|
|
25
|
+
};
|
|
26
|
+
pricingPolicy?: PricingPolicySnapshot;
|
|
27
|
+
};
|
|
28
|
+
resolvePricingPolicy?: (request: Request) => PricingPolicySnapshot | undefined | Promise<PricingPolicySnapshot | undefined>;
|
|
29
|
+
recordQuote: <T>(operation: () => Promise<T>) => Promise<T>;
|
|
30
|
+
}): Promise<boolean>;
|
|
31
|
+
}): {
|
|
32
|
+
respondToCheckoutFailure: (input: {
|
|
33
|
+
error: unknown;
|
|
34
|
+
compensationPort: CheckoutCompensationPort;
|
|
35
|
+
intent: Intent;
|
|
36
|
+
res: HttpResponse;
|
|
37
|
+
quotePort: CommerceQuotePort<Request, Snapshot, import("../../pricing/index.js").CreateQuoteOptions>;
|
|
38
|
+
provisioned: Provisioned;
|
|
39
|
+
checkoutKind: CheckoutKind;
|
|
40
|
+
acceptedQuoteSnapshot: Snapshot | null;
|
|
41
|
+
expectedQuote?: {
|
|
42
|
+
totalGross: {
|
|
43
|
+
amountMinor: number;
|
|
44
|
+
currency: string;
|
|
45
|
+
};
|
|
46
|
+
pricingPolicy?: PricingPolicySnapshot;
|
|
47
|
+
};
|
|
48
|
+
resolvePricingPolicy?: (request: Request) => PricingPolicySnapshot | undefined | Promise<PricingPolicySnapshot | undefined>;
|
|
49
|
+
recordQuote: <T>(operation: () => Promise<T>) => Promise<T>;
|
|
50
|
+
}) => Promise<CheckoutTimingOutcome>;
|
|
51
|
+
};
|