@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,38 @@
|
|
|
1
|
+
import { CheckoutOrchestrationError } from "./commerceCheckoutOrchestrationError.js";
|
|
2
|
+
// Classifiers for the conflict outcomes the checkout orchestration can throw at the
|
|
3
|
+
// `start_runtime` stage. Extracted from the handler so the money-path handler stays
|
|
4
|
+
// within the source-size budget; behaviour is unchanged (pure predicates).
|
|
5
|
+
export function isStockUnavailableCheckoutConflict(error) {
|
|
6
|
+
return (error instanceof CheckoutOrchestrationError &&
|
|
7
|
+
error.message === "start_runtime: Inventory reservation conflict");
|
|
8
|
+
}
|
|
9
|
+
export function isProviderAttemptInFlightCheckoutConflict(error) {
|
|
10
|
+
return (error instanceof CheckoutOrchestrationError &&
|
|
11
|
+
error.reason === "provider_attempt_in_flight");
|
|
12
|
+
}
|
|
13
|
+
export function isJourneyConsumedCheckoutConflict(error) {
|
|
14
|
+
return (error instanceof CheckoutOrchestrationError &&
|
|
15
|
+
error.reason === "journey_consumed");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `start_runtime` conflicts that map to an identical `CONFLICT + reason` response with
|
|
19
|
+
* no compensation side effect — the FE resumes/handles each by its `reason`. Order is
|
|
20
|
+
* significant and preserved from the original inline branches. Stock-unavailable is
|
|
21
|
+
* intentionally NOT here: it additionally cancels the abandoned order, so the handler
|
|
22
|
+
* keeps that branch inline.
|
|
23
|
+
*/
|
|
24
|
+
export const START_RUNTIME_SIMPLE_CONFLICTS = [
|
|
25
|
+
{
|
|
26
|
+
match: isProviderAttemptInFlightCheckoutConflict,
|
|
27
|
+
message: "Checkout payment already in flight",
|
|
28
|
+
reason: "provider_attempt_in_flight",
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
/** Scoped semantic details only; raw SQLSTATE does not authorize this classification. */
|
|
32
|
+
export function isInventoryAdmissionBusy(error) {
|
|
33
|
+
if (!error || typeof error !== "object" || !("details" in error))
|
|
34
|
+
return false;
|
|
35
|
+
const details = error.details;
|
|
36
|
+
return !!details && typeof details === "object" && "code" in details && details.code === "55P03"
|
|
37
|
+
&& "reason" in details && ["inventory_admission_busy", "inventory_lock_unavailable"].includes(String(details.reason));
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CreateQuoteResponse } from "../../pricing/index.js";
|
|
2
|
+
import type { CheckoutRecoveryOrderSnapshot } from "./checkoutRecoveryOrderPort.js";
|
|
3
|
+
import type { CheckoutRecoveryTokenInspection } from "./checkoutRecoveryToken.js";
|
|
4
|
+
type RecoveryQuoteSnapshot = CreateQuoteResponse & {
|
|
5
|
+
quote: {
|
|
6
|
+
context?: {
|
|
7
|
+
sizeConstraint?: unknown;
|
|
8
|
+
shippingTerms?: {
|
|
9
|
+
version: unknown;
|
|
10
|
+
currency: string;
|
|
11
|
+
flatMinor: number;
|
|
12
|
+
freeThresholdMinor: number | null;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const EXPIRED_CHECKOUT_RECOVERY_WINDOW_MS: number;
|
|
18
|
+
export type ExpiredRecoveryEligibility = {
|
|
19
|
+
kind: "eligible";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "paid";
|
|
22
|
+
} | {
|
|
23
|
+
kind: "cancelled";
|
|
24
|
+
} | {
|
|
25
|
+
kind: "unavailable";
|
|
26
|
+
};
|
|
27
|
+
export declare function createExpiredCheckoutRecoveryPolicy<Order extends CheckoutRecoveryOrderSnapshot<unknown, unknown>>(bindings: {
|
|
28
|
+
admitsSubscriptionSubject(order: Order): boolean;
|
|
29
|
+
}): {
|
|
30
|
+
classifyExpiredRecovery: (input: {
|
|
31
|
+
inspection: CheckoutRecoveryTokenInspection | null;
|
|
32
|
+
order: Order | null;
|
|
33
|
+
now: Date;
|
|
34
|
+
}) => ExpiredRecoveryEligibility;
|
|
35
|
+
classifyOrderRecoveryEligibility: (order: Order | null, now: Date) => ExpiredRecoveryEligibility;
|
|
36
|
+
};
|
|
37
|
+
export declare function quotesMatchForRecovery(frozen: RecoveryQuoteSnapshot, fresh: RecoveryQuoteSnapshot): boolean;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export const EXPIRED_CHECKOUT_RECOVERY_WINDOW_MS = 30 * 24 * 60 * 60 * 1000;
|
|
2
|
+
export function createExpiredCheckoutRecoveryPolicy(bindings) {
|
|
3
|
+
function classifyExpiredRecovery(input) {
|
|
4
|
+
const { inspection, order, now } = input;
|
|
5
|
+
if (!inspection || !order || inspection.clientId !== order.clientId)
|
|
6
|
+
return { kind: "unavailable" };
|
|
7
|
+
if (order.status === "paid")
|
|
8
|
+
return { kind: "paid" };
|
|
9
|
+
if (inspection.tokenState === "revoked" || inspection.tokenState === "used") {
|
|
10
|
+
return { kind: "unavailable" };
|
|
11
|
+
}
|
|
12
|
+
return classifyOrderRecoveryEligibility(order, now);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The ORDER half of the same decision, without a token in hand.
|
|
16
|
+
*
|
|
17
|
+
* `classifyExpiredRecovery` answers "may this bearer redeem?"; two of its checks
|
|
18
|
+
* (the token exists, belongs to this order's client, and is neither revoked nor
|
|
19
|
+
* used) are about the bearer and the rest are about the order. Only the second
|
|
20
|
+
* half can be asked BEFORE a token exists, which is exactly the question the
|
|
21
|
+
* operator's mint asks, so it lives here as one function both callers share.
|
|
22
|
+
*
|
|
23
|
+
* ⛔ Do not fork it. Mint-side eligibility drifting from redeem-side eligibility
|
|
24
|
+
* is how support hands a customer a link that the redeem rail then refuses — a
|
|
25
|
+
* dead link is worse than no button at all.
|
|
26
|
+
*/
|
|
27
|
+
function classifyOrderRecoveryEligibility(order, now) {
|
|
28
|
+
if (!order)
|
|
29
|
+
return { kind: "unavailable" };
|
|
30
|
+
if (order.status === "paid")
|
|
31
|
+
return { kind: "paid" };
|
|
32
|
+
const createdAt = Date.parse(order.createdAt);
|
|
33
|
+
if (!Number.isFinite(createdAt) || now.getTime() - createdAt > EXPIRED_CHECKOUT_RECOVERY_WINDOW_MS) {
|
|
34
|
+
return { kind: "unavailable" };
|
|
35
|
+
}
|
|
36
|
+
if (order.status === "cancelled" && !order.technicallyExpired)
|
|
37
|
+
return { kind: "cancelled" };
|
|
38
|
+
// Recreation is only safe after a canonical expiry transition has also
|
|
39
|
+
// released the source reservation. `pending_payment` plus expired-looking
|
|
40
|
+
// metadata is an inconsistent/legacy state: keep the technical-expiry fence
|
|
41
|
+
// that prevents retrying its stale intent, but never create a second hold.
|
|
42
|
+
if (order.status !== "expired" && order.status !== "cancelled")
|
|
43
|
+
return { kind: "unavailable" };
|
|
44
|
+
if (!order.technicallyExpired)
|
|
45
|
+
return { kind: "unavailable" };
|
|
46
|
+
if (!order.quoteSnapshot || !order.shippingAddressId)
|
|
47
|
+
return { kind: "unavailable" };
|
|
48
|
+
if (order.mode === "subscription_cycle" && (!order.subscriptionId || !order.subscriptionCycleId || !bindings.admitsSubscriptionSubject(order))) {
|
|
49
|
+
return { kind: "unavailable" };
|
|
50
|
+
}
|
|
51
|
+
return { kind: "eligible" };
|
|
52
|
+
}
|
|
53
|
+
return { classifyExpiredRecovery, classifyOrderRecoveryEligibility };
|
|
54
|
+
}
|
|
55
|
+
export function quotesMatchForRecovery(frozen, fresh) {
|
|
56
|
+
return JSON.stringify(commercialFingerprint(frozen)) === JSON.stringify(commercialFingerprint(fresh));
|
|
57
|
+
}
|
|
58
|
+
function commercialFingerprint(snapshot) {
|
|
59
|
+
const quote = snapshot.quote;
|
|
60
|
+
const terms = quote.context?.shippingTerms;
|
|
61
|
+
return {
|
|
62
|
+
currency: quote.currency,
|
|
63
|
+
lines: quote.lines.map((line) => ({
|
|
64
|
+
sku: line.sku,
|
|
65
|
+
productSlug: line.productSlug,
|
|
66
|
+
quantity: line.quantity,
|
|
67
|
+
unitPriceGross: line.unitPriceGross,
|
|
68
|
+
lineSubtotalGross: line.lineSubtotalGross,
|
|
69
|
+
tax: line.tax,
|
|
70
|
+
})),
|
|
71
|
+
discounts: quote.discounts,
|
|
72
|
+
subtotalGross: quote.subtotalGross,
|
|
73
|
+
discountTotalGross: quote.discountTotalGross,
|
|
74
|
+
shippingGross: quote.shippingGross ?? null,
|
|
75
|
+
shippingDiscountGross: quote.shippingDiscountGross ?? null,
|
|
76
|
+
shippingTerms: terms ? { version: terms.version, currency: terms.currency,
|
|
77
|
+
flatMinor: terms.flatMinor, freeThresholdMinor: terms.freeThresholdMinor } : null,
|
|
78
|
+
totalGross: quote.totalGross,
|
|
79
|
+
netTotal: quote.netTotal,
|
|
80
|
+
taxTotal: quote.taxTotal,
|
|
81
|
+
mode: quote.context?.mode ?? null,
|
|
82
|
+
cadenceDays: quote.context?.cadenceDays ?? null,
|
|
83
|
+
sizeConstraint: quote.context?.sizeConstraint ?? null,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export declare function buildCheckoutInvoiceBuyerSnapshot<Buyer>(intent: {
|
|
3
|
+
contact: {
|
|
4
|
+
firstName: string;
|
|
5
|
+
lastName: string;
|
|
6
|
+
email: string;
|
|
7
|
+
};
|
|
8
|
+
address: {
|
|
9
|
+
street: string;
|
|
10
|
+
city: string;
|
|
11
|
+
postalCode: string;
|
|
12
|
+
country: string;
|
|
13
|
+
};
|
|
14
|
+
}, invoicePreference: {
|
|
15
|
+
kind: "b2c_named";
|
|
16
|
+
} | {
|
|
17
|
+
kind: "b2b_vat";
|
|
18
|
+
companyName: string;
|
|
19
|
+
email?: string;
|
|
20
|
+
taxId?: string;
|
|
21
|
+
address: object;
|
|
22
|
+
}, schema: z.ZodType<Buyer>): Buyer;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function buildCheckoutInvoiceBuyerSnapshot(intent, invoicePreference, schema) {
|
|
2
|
+
if (invoicePreference.kind === "b2b_vat") {
|
|
3
|
+
return schema.parse({
|
|
4
|
+
name: invoicePreference.companyName,
|
|
5
|
+
email: invoicePreference.email ?? intent.contact.email,
|
|
6
|
+
taxId: invoicePreference.taxId,
|
|
7
|
+
companyName: invoicePreference.companyName,
|
|
8
|
+
source: "checkout_invoice_preference",
|
|
9
|
+
address: {
|
|
10
|
+
...invoicePreference.address,
|
|
11
|
+
source: "checkout_invoice_billing_address",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return schema.parse({
|
|
16
|
+
name: `${intent.contact.firstName} ${intent.contact.lastName}`.trim(),
|
|
17
|
+
email: intent.contact.email,
|
|
18
|
+
taxId: null,
|
|
19
|
+
companyName: null,
|
|
20
|
+
source: "checkout_invoice_preference",
|
|
21
|
+
address: {
|
|
22
|
+
line1: intent.address.street,
|
|
23
|
+
line2: null,
|
|
24
|
+
city: intent.address.city,
|
|
25
|
+
postalCode: intent.address.postalCode,
|
|
26
|
+
country: intent.address.country,
|
|
27
|
+
source: "checkout_shipping_address",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CheckoutKind, CheckoutOfferPolicyPort } from "../contracts/index.js";
|
|
2
|
+
export type { CheckoutOfferPolicyPort } from "../contracts/index.js";
|
|
3
|
+
/** The refusal of an intent that carries an offer field when no adopter port is wired. */
|
|
4
|
+
export declare const CHECKOUT_OFFER_VERSION_UNSUPPORTED = "offer_version_unsupported";
|
|
5
|
+
export declare class CheckoutOfferRefusedError extends Error {
|
|
6
|
+
readonly reason: string;
|
|
7
|
+
constructor(reason: string);
|
|
8
|
+
}
|
|
9
|
+
export type CheckoutOfferBinding<Intent, Quote> = {
|
|
10
|
+
port: CheckoutOfferPolicyPort<Intent, Quote>;
|
|
11
|
+
offerVersion: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Null, without a port call, for an intent that carries neither `offerVersion`
|
|
15
|
+
* nor `minimumUnits`. Otherwise the adopter's port must bind the offer: without
|
|
16
|
+
* a port the intent is refused with `offer_version_unsupported`, and a port
|
|
17
|
+
* refusal keeps its own reason. Both throw `CheckoutOfferRefusedError`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveCheckoutOffer<Intent extends {
|
|
20
|
+
offerVersion?: string;
|
|
21
|
+
minimumUnits?: number;
|
|
22
|
+
}, Quote>(port: CheckoutOfferPolicyPort<Intent, Quote> | undefined, intent: Intent, checkoutKind: CheckoutKind): Promise<CheckoutOfferBinding<Intent, Quote> | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Writes a bound offer version and the adopter's evidence, checked against
|
|
25
|
+
* `commerceOfferEvidenceSchema`, into an accepted snapshot's context. Without a
|
|
26
|
+
* binding the same snapshot is returned; a bound snapshot without a context
|
|
27
|
+
* fails closed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function withCheckoutOfferContext<Intent, Quote extends {
|
|
30
|
+
context?: object;
|
|
31
|
+
}, Response extends {
|
|
32
|
+
quote: Quote;
|
|
33
|
+
}>(binding: CheckoutOfferBinding<Intent, Quote> | null, intent: Intent, snapshot: Response): Promise<Response>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { commerceOfferEvidenceSchema } from "../offerEvidenceSchemas.js";
|
|
2
|
+
/** The refusal of an intent that carries an offer field when no adopter port is wired. */
|
|
3
|
+
export const CHECKOUT_OFFER_VERSION_UNSUPPORTED = "offer_version_unsupported";
|
|
4
|
+
export class CheckoutOfferRefusedError extends Error {
|
|
5
|
+
reason;
|
|
6
|
+
constructor(reason) {
|
|
7
|
+
super(`checkout_offer_refused:${reason}`);
|
|
8
|
+
this.name = "CheckoutOfferRefusedError";
|
|
9
|
+
this.reason = reason;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Null, without a port call, for an intent that carries neither `offerVersion`
|
|
14
|
+
* nor `minimumUnits`. Otherwise the adopter's port must bind the offer: without
|
|
15
|
+
* a port the intent is refused with `offer_version_unsupported`, and a port
|
|
16
|
+
* refusal keeps its own reason. Both throw `CheckoutOfferRefusedError`.
|
|
17
|
+
*/
|
|
18
|
+
export async function resolveCheckoutOffer(port, intent, checkoutKind) {
|
|
19
|
+
if (intent.offerVersion === undefined && intent.minimumUnits === undefined)
|
|
20
|
+
return null;
|
|
21
|
+
if (!port)
|
|
22
|
+
throw new CheckoutOfferRefusedError(CHECKOUT_OFFER_VERSION_UNSUPPORTED);
|
|
23
|
+
const resolution = await port.resolve({ intent, checkoutKind });
|
|
24
|
+
if (resolution.kind === "refused")
|
|
25
|
+
throw new CheckoutOfferRefusedError(resolution.reason);
|
|
26
|
+
return { port, offerVersion: resolution.offerVersion };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Writes a bound offer version and the adopter's evidence, checked against
|
|
30
|
+
* `commerceOfferEvidenceSchema`, into an accepted snapshot's context. Without a
|
|
31
|
+
* binding the same snapshot is returned; a bound snapshot without a context
|
|
32
|
+
* fails closed.
|
|
33
|
+
*/
|
|
34
|
+
export async function withCheckoutOfferContext(binding, intent, snapshot) {
|
|
35
|
+
if (!binding)
|
|
36
|
+
return snapshot;
|
|
37
|
+
const context = snapshot.quote.context;
|
|
38
|
+
if (!context)
|
|
39
|
+
throw new Error("checkout_offer_context_missing");
|
|
40
|
+
const offerEvidence = commerceOfferEvidenceSchema.parse(await binding.port.evidence({
|
|
41
|
+
intent,
|
|
42
|
+
offerVersion: binding.offerVersion,
|
|
43
|
+
quote: snapshot.quote,
|
|
44
|
+
}));
|
|
45
|
+
return {
|
|
46
|
+
...snapshot,
|
|
47
|
+
quote: { ...snapshot.quote, context: { ...context, offerVersion: binding.offerVersion, offerEvidence } },
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type CheckoutContinuationAction = {
|
|
2
|
+
kind: string;
|
|
3
|
+
provider?: string;
|
|
4
|
+
clientSecret?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
};
|
|
7
|
+
declare const PURPOSE: "commerce.checkout-payment-continuation.v1";
|
|
8
|
+
export interface CheckoutPaymentContinuationInput<Rail extends string = string> {
|
|
9
|
+
journeyId: string;
|
|
10
|
+
orderId: string;
|
|
11
|
+
clientId: string;
|
|
12
|
+
paymentIntentId: string;
|
|
13
|
+
paymentAttemptId: string;
|
|
14
|
+
executionRail: Rail;
|
|
15
|
+
}
|
|
16
|
+
export interface CheckoutPaymentContinuationClaims<Rail extends string = string> extends CheckoutPaymentContinuationInput<Rail> {
|
|
17
|
+
version: 1;
|
|
18
|
+
purpose: typeof PURPOSE;
|
|
19
|
+
expiresAt: number;
|
|
20
|
+
}
|
|
21
|
+
export interface CheckoutPaymentContinuationCodec<Rail extends string = string> {
|
|
22
|
+
issue(input: CheckoutPaymentContinuationInput<Rail>): {
|
|
23
|
+
claims: CheckoutPaymentContinuationClaims<Rail>;
|
|
24
|
+
setCookie: string;
|
|
25
|
+
};
|
|
26
|
+
verifyCookieHeader(cookieHeader: unknown): CheckoutPaymentContinuationClaims<Rail> | null;
|
|
27
|
+
}
|
|
28
|
+
export type CheckoutPaymentContinuationMinter<Rail extends string = string> = (res: CheckoutCookieResponse, input: CheckoutPaymentContinuationInput<Rail>) => void;
|
|
29
|
+
export interface CheckoutCookieResponse {
|
|
30
|
+
getHeader?(name: string): string | number | string[] | undefined;
|
|
31
|
+
setHeader(name: string, value: number | string | readonly string[]): unknown;
|
|
32
|
+
}
|
|
33
|
+
export declare function mintPaymentContinuationOnFreshAction<Rail extends string>(input: {
|
|
34
|
+
mint?: CheckoutPaymentContinuationMinter<Rail>;
|
|
35
|
+
res: CheckoutCookieResponse;
|
|
36
|
+
journeyId: string;
|
|
37
|
+
clientId: string;
|
|
38
|
+
requestRail: string;
|
|
39
|
+
response: {
|
|
40
|
+
status: string;
|
|
41
|
+
clientAction?: CheckoutContinuationAction;
|
|
42
|
+
};
|
|
43
|
+
result: {
|
|
44
|
+
continuationActionOrigin: "fresh_execution" | null;
|
|
45
|
+
executionRail: string;
|
|
46
|
+
paymentAttemptId: string | null;
|
|
47
|
+
paymentIntentId: string;
|
|
48
|
+
orderId: string;
|
|
49
|
+
};
|
|
50
|
+
}, executionRails: readonly [Rail, Rail]): void;
|
|
51
|
+
export declare function createCheckoutPaymentContinuationCodec<Rail extends string>(rootSecret: string | undefined, options: {
|
|
52
|
+
cookieName: string;
|
|
53
|
+
executionRails: readonly [Rail, Rail];
|
|
54
|
+
now?: () => Date;
|
|
55
|
+
ttlSeconds?: number;
|
|
56
|
+
}): CheckoutPaymentContinuationCodec<Rail> | null;
|
|
57
|
+
export declare function isCheckoutContinuationRail<Rail extends string>(value: unknown, executionRails: readonly Rail[]): value is Rail;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { CHECKOUT_PAYMENT_CONTINUATION_TTL_SECONDS } from "../paymentContinuation.js";
|
|
3
|
+
const PURPOSE = "commerce.checkout-payment-continuation.v1";
|
|
4
|
+
const DEFAULT_TTL_SECONDS = CHECKOUT_PAYMENT_CONTINUATION_TTL_SECONDS;
|
|
5
|
+
const MIN_TTL_SECONDS = 60;
|
|
6
|
+
const MAX_TTL_SECONDS = CHECKOUT_PAYMENT_CONTINUATION_TTL_SECONDS;
|
|
7
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
8
|
+
const JOURNEY_PATTERN = /^checkout:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
9
|
+
export function mintPaymentContinuationOnFreshAction(input, executionRails) {
|
|
10
|
+
const { result, response } = input;
|
|
11
|
+
if (result.continuationActionOrigin !== "fresh_execution"
|
|
12
|
+
|| !result.paymentAttemptId
|
|
13
|
+
|| !isCheckoutContinuationRail(result.executionRail, executionRails)
|
|
14
|
+
|| result.executionRail !== input.requestRail
|
|
15
|
+
|| response.status === "price_changed"
|
|
16
|
+
|| !responseWantsContinuation(response, result.executionRail, executionRails))
|
|
17
|
+
return;
|
|
18
|
+
// Split out from the guard above ON PURPOSE. Every condition there says "this
|
|
19
|
+
// attempt does not want a continuation"; this one says "it wants one and we
|
|
20
|
+
// cannot issue it", which is an operator problem and used to be
|
|
21
|
+
// indistinguishable from the first. That silence is how the capability stayed
|
|
22
|
+
// dormant in every environment without anyone noticing. Rail and reason only:
|
|
23
|
+
// no order, client, attempt or intent id is logged.
|
|
24
|
+
if (!input.mint) {
|
|
25
|
+
console.warn("checkout_payment_continuation_unavailable", JSON.stringify({ executionRail: result.executionRail, reason: "no_signing_secret" }));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
input.mint(input.res, {
|
|
30
|
+
journeyId: input.journeyId,
|
|
31
|
+
orderId: result.orderId,
|
|
32
|
+
clientId: input.clientId,
|
|
33
|
+
paymentIntentId: result.paymentIntentId,
|
|
34
|
+
paymentAttemptId: result.paymentAttemptId,
|
|
35
|
+
executionRail: result.executionRail,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Continuation is best-effort; checkout success must never depend on it.
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function createCheckoutPaymentContinuationCodec(rootSecret, options) {
|
|
43
|
+
if (!rootSecret || Buffer.byteLength(rootSecret, "utf8") < 32)
|
|
44
|
+
return null;
|
|
45
|
+
const now = options.now ?? (() => new Date());
|
|
46
|
+
const ttlSeconds = options.ttlSeconds ?? DEFAULT_TTL_SECONDS;
|
|
47
|
+
if (!Number.isInteger(ttlSeconds) || ttlSeconds < MIN_TTL_SECONDS || ttlSeconds > MAX_TTL_SECONDS) {
|
|
48
|
+
throw new Error(`Checkout payment continuation TTL must be between ${MIN_TTL_SECONDS} and ${MAX_TTL_SECONDS} seconds`);
|
|
49
|
+
}
|
|
50
|
+
const signingKey = createHmac("sha256", rootSecret).update(PURPOSE).digest();
|
|
51
|
+
function sign(payload) {
|
|
52
|
+
return createHmac("sha256", signingKey).update(payload).digest("base64url");
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
issue(input) {
|
|
56
|
+
if (!isValidInput(input, options.executionRails))
|
|
57
|
+
throw new Error("Invalid checkout payment continuation input");
|
|
58
|
+
const claims = {
|
|
59
|
+
version: 1,
|
|
60
|
+
purpose: PURPOSE,
|
|
61
|
+
expiresAt: Math.floor(now().getTime() / 1000) + ttlSeconds,
|
|
62
|
+
...input,
|
|
63
|
+
};
|
|
64
|
+
const payload = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
|
|
65
|
+
const token = `${payload}.${sign(payload)}`;
|
|
66
|
+
return {
|
|
67
|
+
claims,
|
|
68
|
+
setCookie: `${options.cookieName}=${token}; Path=/; Max-Age=${ttlSeconds}; Secure; HttpOnly; SameSite=Strict`,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
verifyCookieHeader(cookieHeader) {
|
|
72
|
+
const token = readCookie(cookieHeader, options.cookieName);
|
|
73
|
+
if (!token)
|
|
74
|
+
return null;
|
|
75
|
+
const separator = token.indexOf(".");
|
|
76
|
+
if (separator <= 0 || separator === token.length - 1 || token.indexOf(".", separator + 1) !== -1)
|
|
77
|
+
return null;
|
|
78
|
+
const payload = token.slice(0, separator);
|
|
79
|
+
const suppliedSignature = token.slice(separator + 1);
|
|
80
|
+
const expectedSignature = sign(payload);
|
|
81
|
+
const supplied = Buffer.from(suppliedSignature, "utf8");
|
|
82
|
+
const expected = Buffer.from(expectedSignature, "utf8");
|
|
83
|
+
if (supplied.length !== expected.length || !timingSafeEqual(supplied, expected))
|
|
84
|
+
return null;
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
87
|
+
if (!isValidClaims(parsed, options.executionRails))
|
|
88
|
+
return null;
|
|
89
|
+
if (parsed.expiresAt <= Math.floor(now().getTime() / 1000))
|
|
90
|
+
return null;
|
|
91
|
+
return parsed;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function isValidInput(value, executionRails) {
|
|
100
|
+
if (!isRecord(value))
|
|
101
|
+
return false;
|
|
102
|
+
return JOURNEY_PATTERN.test(readString(value, "journeyId"))
|
|
103
|
+
&& UUID_PATTERN.test(readString(value, "orderId"))
|
|
104
|
+
&& UUID_PATTERN.test(readString(value, "clientId"))
|
|
105
|
+
&& UUID_PATTERN.test(readString(value, "paymentIntentId"))
|
|
106
|
+
&& UUID_PATTERN.test(readString(value, "paymentAttemptId"))
|
|
107
|
+
&& isCheckoutContinuationRail(value.executionRail, executionRails);
|
|
108
|
+
}
|
|
109
|
+
function isValidClaims(value, executionRails) {
|
|
110
|
+
if (!isRecord(value))
|
|
111
|
+
return false;
|
|
112
|
+
const keys = Object.keys(value).sort();
|
|
113
|
+
const expectedKeys = [
|
|
114
|
+
"clientId", "expiresAt", "journeyId", "orderId", "paymentAttemptId",
|
|
115
|
+
"executionRail", "paymentIntentId", "purpose", "version",
|
|
116
|
+
].sort();
|
|
117
|
+
return keys.length === expectedKeys.length
|
|
118
|
+
&& keys.every((key, index) => key === expectedKeys[index])
|
|
119
|
+
&& value.version === 1
|
|
120
|
+
&& value.purpose === PURPOSE
|
|
121
|
+
&& Number.isInteger(value.expiresAt)
|
|
122
|
+
&& isValidInput(value, executionRails);
|
|
123
|
+
}
|
|
124
|
+
function readCookie(header, name) {
|
|
125
|
+
const raw = Array.isArray(header) ? header[0] : header;
|
|
126
|
+
if (typeof raw !== "string")
|
|
127
|
+
return null;
|
|
128
|
+
for (const part of raw.split(";")) {
|
|
129
|
+
const trimmed = part.trim();
|
|
130
|
+
const separator = trimmed.indexOf("=");
|
|
131
|
+
if (separator > 0 && trimmed.slice(0, separator) === name) {
|
|
132
|
+
return trimmed.slice(separator + 1) || null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
function isRecord(value) {
|
|
138
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
139
|
+
}
|
|
140
|
+
function readString(value, key) {
|
|
141
|
+
return typeof value[key] === "string" ? value[key] : "";
|
|
142
|
+
}
|
|
143
|
+
function responseWantsContinuation(response, rail, executionRails) {
|
|
144
|
+
return actionMatchesExecutionRail(response.clientAction, rail, executionRails)
|
|
145
|
+
|| (response.clientAction?.kind === "none" && response.status === "processing");
|
|
146
|
+
}
|
|
147
|
+
function actionMatchesExecutionRail(action, rail, executionRails) {
|
|
148
|
+
return rail === executionRails[0]
|
|
149
|
+
? action?.kind === "provider_embedded" && action.provider === executionRails[0]
|
|
150
|
+
: action?.kind === "redirect";
|
|
151
|
+
}
|
|
152
|
+
export function isCheckoutContinuationRail(value, executionRails) {
|
|
153
|
+
return typeof value === "string" && executionRails.includes(value);
|
|
154
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AcquisitionTermsExpectation, ResolvedAcquisitionTerms, CreateQuoteResponse, CommerceQuoteContext, PricingPolicySnapshot } from "../../pricing/index.js";
|
|
2
|
+
export interface CheckoutQuoteSnapshot extends CreateQuoteResponse {
|
|
3
|
+
quote: CreateQuoteResponse["quote"] & {
|
|
4
|
+
context?: CommerceQuoteContext & {
|
|
5
|
+
pricingPolicy?: PricingPolicySnapshot;
|
|
6
|
+
acquisitionTerms?: ResolvedAcquisitionTerms;
|
|
7
|
+
shippingTerms?: unknown;
|
|
8
|
+
offerVersion?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface ExpectedCheckoutQuote {
|
|
13
|
+
totalGross: {
|
|
14
|
+
amountMinor: number;
|
|
15
|
+
currency: string;
|
|
16
|
+
};
|
|
17
|
+
pricingPolicy?: PricingPolicySnapshot;
|
|
18
|
+
acquisitionTerms?: AcquisitionTermsExpectation;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface CheckoutRecoveryPriorPaymentEvidence {
|
|
2
|
+
paymentIntentId: string;
|
|
3
|
+
paymentAttemptId: string;
|
|
4
|
+
provider: string;
|
|
5
|
+
providerPaymentId: string | null;
|
|
6
|
+
idempotencyKey: string;
|
|
7
|
+
retryRequestId: string | null;
|
|
8
|
+
}
|
|
9
|
+
export type CheckoutRecoveryOrderSnapshot<Quote, PaymentStatus, Host extends object = object> = Host & {
|
|
10
|
+
orderId: string;
|
|
11
|
+
orderRef: string;
|
|
12
|
+
orderNumber: string;
|
|
13
|
+
clientId: string;
|
|
14
|
+
status: string;
|
|
15
|
+
mode: "subscription_cycle" | "one_time_order";
|
|
16
|
+
totalMinor: number;
|
|
17
|
+
currency: string;
|
|
18
|
+
cadenceDays: number | null;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
customerEmail: string | null;
|
|
21
|
+
customerName: string | null;
|
|
22
|
+
paymentIntentId: string | null;
|
|
23
|
+
paymentIntentStatus: PaymentStatus | null;
|
|
24
|
+
subscriptionId: string | null;
|
|
25
|
+
subscriptionCycleId: string | null;
|
|
26
|
+
shippingAddressId?: string | null;
|
|
27
|
+
quoteSnapshot?: Quote | null;
|
|
28
|
+
runtimeMetadata?: Record<string, unknown>;
|
|
29
|
+
invoiceBuyerSnapshot?: Record<string, unknown>;
|
|
30
|
+
recoveryRootOrderId?: string;
|
|
31
|
+
recreatedFromOrderId?: string | null;
|
|
32
|
+
technicallyExpired?: boolean;
|
|
33
|
+
priorPaymentEvidence?: CheckoutRecoveryPriorPaymentEvidence | null;
|
|
34
|
+
};
|
|
35
|
+
export interface CheckoutRecoveryOrderReadPort<Order> {
|
|
36
|
+
getRecoveryOrder(input: {
|
|
37
|
+
orderId: string;
|
|
38
|
+
}): Promise<Order | null>;
|
|
39
|
+
getLatestRecoveryOrder?(input: {
|
|
40
|
+
orderId: string;
|
|
41
|
+
}): Promise<Order | null>;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface CheckoutRecoveryTokenContext {
|
|
2
|
+
tokenId: string;
|
|
3
|
+
orderId: string;
|
|
4
|
+
clientId: string;
|
|
5
|
+
/** "subscription_cycle" | "one_time_order" — drives copy + post-pay activation. */
|
|
6
|
+
mode: string;
|
|
7
|
+
status: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CheckoutRecoveryTokenInspection {
|
|
10
|
+
tokenId: string;
|
|
11
|
+
orderId: string;
|
|
12
|
+
clientId: string;
|
|
13
|
+
/** Null when the token exists but the order row is already gone. */
|
|
14
|
+
mode: string | null;
|
|
15
|
+
status: string | null;
|
|
16
|
+
subscriptionId: string | null;
|
|
17
|
+
tokenState: string;
|
|
18
|
+
}
|
|
19
|
+
/** Inspection RPC states; only the named continuation states may resume pending orders. */
|
|
20
|
+
export declare function classifyCheckoutRecoveryTokenState(tokenState: string): "continuation" | "expired_policy" | "refused";
|
|
21
|
+
export interface CheckoutRecoveryTokenPort {
|
|
22
|
+
/** Issue a token for an unpaid order. Returns the new token row id. */
|
|
23
|
+
issue(input: {
|
|
24
|
+
orderId: string;
|
|
25
|
+
rawToken: string;
|
|
26
|
+
expiresAt: string;
|
|
27
|
+
}): Promise<string>;
|
|
28
|
+
/** Validate a raw token; returns the order context, or null if invalid/expired/not recoverable. */
|
|
29
|
+
validate(rawToken: string, now?: Date): Promise<CheckoutRecoveryTokenContext | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Inspect without granting continuation; callers must check state before reconstructing authority.
|
|
32
|
+
*/
|
|
33
|
+
inspect(rawToken: string, now?: Date): Promise<CheckoutRecoveryTokenInspection | null>;
|
|
34
|
+
}
|
|
35
|
+
/** Canonical hash: SHA-256 hex of the raw token (matches the SQL `encode(sha256(...))`). */
|
|
36
|
+
export declare function hashCheckoutRecoveryToken(token: string): string;
|
|
37
|
+
/** A non-hex prefix keeps quoted-printable mail transports from consuming the URL separator. */
|
|
38
|
+
export declare const CHECKOUT_RECOVERY_TOKEN_PREFIX = "rcv_";
|
|
39
|
+
/** A 256-bit URL-safe random token for the deep-link, with the QP-safe prefix. */
|
|
40
|
+
export declare function generateCheckoutRecoveryToken(): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
2
|
+
/** Inspection RPC states; only the named continuation states may resume pending orders. */
|
|
3
|
+
export function classifyCheckoutRecoveryTokenState(tokenState) {
|
|
4
|
+
switch (tokenState) {
|
|
5
|
+
case "active":
|
|
6
|
+
case "order_not_recoverable":
|
|
7
|
+
return "continuation";
|
|
8
|
+
case "expired":
|
|
9
|
+
return "expired_policy";
|
|
10
|
+
case "revoked":
|
|
11
|
+
case "used":
|
|
12
|
+
case "order_not_found":
|
|
13
|
+
default:
|
|
14
|
+
return "refused";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Canonical hash: SHA-256 hex of the raw token (matches the SQL `encode(sha256(...))`). */
|
|
18
|
+
export function hashCheckoutRecoveryToken(token) {
|
|
19
|
+
return createHash("sha256").update(token).digest("hex");
|
|
20
|
+
}
|
|
21
|
+
/** A non-hex prefix keeps quoted-printable mail transports from consuming the URL separator. */
|
|
22
|
+
export const CHECKOUT_RECOVERY_TOKEN_PREFIX = "rcv_";
|
|
23
|
+
/** A 256-bit URL-safe random token for the deep-link, with the QP-safe prefix. */
|
|
24
|
+
export function generateCheckoutRecoveryToken() {
|
|
25
|
+
return CHECKOUT_RECOVERY_TOKEN_PREFIX + randomBytes(32).toString("base64url");
|
|
26
|
+
}
|