@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,289 @@
|
|
|
1
|
+
import type { OperatorContext } from "./customer360.js";
|
|
2
|
+
export type OperatorSubscriptionAction = "pause" | "resume" | "slide_next_cycle" | "change_shipping_address";
|
|
3
|
+
export interface OperatorNewShippingAddress {
|
|
4
|
+
recipientName: string;
|
|
5
|
+
line1: string;
|
|
6
|
+
line2?: string;
|
|
7
|
+
postalCode: string;
|
|
8
|
+
city: string;
|
|
9
|
+
country: string;
|
|
10
|
+
contactPhone?: string;
|
|
11
|
+
}
|
|
12
|
+
export type OperatorShippingAddressPayload = {
|
|
13
|
+
shippingAddressId: string;
|
|
14
|
+
reason?: string;
|
|
15
|
+
} | {
|
|
16
|
+
newAddress: OperatorNewShippingAddress;
|
|
17
|
+
reason?: string;
|
|
18
|
+
};
|
|
19
|
+
export type OperatorSubscriptionPayload = {
|
|
20
|
+
pausePreset?: "2_weeks" | "1_month" | "indefinite";
|
|
21
|
+
reason?: string;
|
|
22
|
+
newNextCycleAt?: string;
|
|
23
|
+
slideMinDays?: number;
|
|
24
|
+
confirmedChargeTiming?: boolean;
|
|
25
|
+
} | OperatorShippingAddressPayload;
|
|
26
|
+
export type OperatorSubscriptionRefusal = "subscription_not_found" | "subject_not_found" | "subject_account_unlinked" | "version_conflict" | "slide_target_invalid" | "slide_not_available" | "slide_out_of_window" | "payment_blocked" | "invalid_transition" | "charge_timing_not_confirmed" | "payment_method_not_chargeable" | "invalid_address";
|
|
27
|
+
export type RecoveryRefusal = "subject_not_found" | "case_not_found" | "lifecycle_not_eligible" | "dunning_authority_unavailable" | "case_not_open" | "recoverable_order_unavailable";
|
|
28
|
+
export type EmailCorrectionRefusal = "subject_not_found" | "subject_account_linked" | "email_expectation_conflict" | "email_already_in_use";
|
|
29
|
+
export type PhoneCorrectionRefusal = "subject_not_found" | "phone_expectation_conflict";
|
|
30
|
+
export type LeadRefusal = "lead_not_found" | "customer_not_found" | "lead_email_expectation_conflict" | "lead_has_identity" | "lead_has_commercial_footprint" | "unclassified_referencing_table";
|
|
31
|
+
export type OperatorContactCommand = {
|
|
32
|
+
action: "correct_email";
|
|
33
|
+
subjectId: string;
|
|
34
|
+
expectedEmail: string;
|
|
35
|
+
newEmail: string;
|
|
36
|
+
idempotencyKey: string;
|
|
37
|
+
} | {
|
|
38
|
+
action: "correct_phone";
|
|
39
|
+
subjectId: string;
|
|
40
|
+
expectedPhone: string;
|
|
41
|
+
newPhone: string;
|
|
42
|
+
idempotencyKey: string;
|
|
43
|
+
};
|
|
44
|
+
export interface OperatorLeadCommand {
|
|
45
|
+
action: "absorb_lead";
|
|
46
|
+
subjectId: string;
|
|
47
|
+
leadId: string;
|
|
48
|
+
expectedLeadEmail: string;
|
|
49
|
+
idempotencyKey: string;
|
|
50
|
+
}
|
|
51
|
+
export type OperatorRecoveryCommand = {
|
|
52
|
+
action: "issue_recovery";
|
|
53
|
+
subjectId: string;
|
|
54
|
+
caseId: string;
|
|
55
|
+
idempotencyKey: string;
|
|
56
|
+
} | {
|
|
57
|
+
action: "apply_subscription_action";
|
|
58
|
+
subscriptionId: string;
|
|
59
|
+
subscriptionAction: OperatorSubscriptionAction;
|
|
60
|
+
expectedVersion: number;
|
|
61
|
+
idempotencyKey: string;
|
|
62
|
+
payload?: OperatorSubscriptionPayload;
|
|
63
|
+
} | OperatorContactCommand | OperatorLeadCommand;
|
|
64
|
+
/** Carries trusted context and the original command; performs no authorization or writes.
|
|
65
|
+
* The host preserves the command key, optional reason and expected version.
|
|
66
|
+
*/
|
|
67
|
+
export interface OperatorRecoveryCommandEnvelope<Command = OperatorRecoveryCommand> {
|
|
68
|
+
actor: OperatorContext;
|
|
69
|
+
subject: {
|
|
70
|
+
subjectId: string;
|
|
71
|
+
subscriptionId?: string;
|
|
72
|
+
orderId?: string;
|
|
73
|
+
caseId?: string;
|
|
74
|
+
};
|
|
75
|
+
command: Command;
|
|
76
|
+
reason: string | null;
|
|
77
|
+
idempotencyKey: string;
|
|
78
|
+
expectedVersion: number | null;
|
|
79
|
+
evidence: readonly {
|
|
80
|
+
owner: string;
|
|
81
|
+
resourceId: string;
|
|
82
|
+
revision: string | null;
|
|
83
|
+
}[];
|
|
84
|
+
}
|
|
85
|
+
export type OperatorSubscriptionResult = {
|
|
86
|
+
outcome: "applied" | "noop" | "replayed";
|
|
87
|
+
subscriptionStatus: string;
|
|
88
|
+
nextCycleAt: string | null;
|
|
89
|
+
templateVersion: number;
|
|
90
|
+
eventId: string | null;
|
|
91
|
+
appliedBy: "operator_reschedule_band" | "customer_self_service_delegate" | null;
|
|
92
|
+
} | {
|
|
93
|
+
outcome: "refused" | "conflict";
|
|
94
|
+
refusalCode: OperatorSubscriptionRefusal;
|
|
95
|
+
};
|
|
96
|
+
/** Actual M10 receipt evidence; support never manufactures an audit identifier. */
|
|
97
|
+
export interface OperatorOwnerReceipt {
|
|
98
|
+
id: string;
|
|
99
|
+
actorId: string;
|
|
100
|
+
idempotencyKey: string;
|
|
101
|
+
commandFingerprint: string;
|
|
102
|
+
result: Record<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
/** Additive native superset. The managed transcription above remains unchanged. */
|
|
105
|
+
export type NativeOperatorSubscriptionResult = (OperatorSubscriptionResult & {
|
|
106
|
+
ownerReceipt?: OperatorOwnerReceipt;
|
|
107
|
+
}) | {
|
|
108
|
+
outcome: "refused";
|
|
109
|
+
refusalCode: "operator_subscription_authority_unavailable";
|
|
110
|
+
ownerReceipt?: OperatorOwnerReceipt;
|
|
111
|
+
};
|
|
112
|
+
export type OperatorAuthorityUnavailable = {
|
|
113
|
+
outcome: "refused";
|
|
114
|
+
refusalCode: "operator_subscription_authority_unavailable";
|
|
115
|
+
};
|
|
116
|
+
export type OperatorEmailCorrectionResult = {
|
|
117
|
+
outcome: "applied" | "noop" | "replayed";
|
|
118
|
+
authUserLinked: boolean;
|
|
119
|
+
} | {
|
|
120
|
+
outcome: "refused" | "conflict";
|
|
121
|
+
refusalCode: EmailCorrectionRefusal;
|
|
122
|
+
};
|
|
123
|
+
export type OperatorPhoneCorrectionResult = {
|
|
124
|
+
outcome: "applied" | "noop" | "replayed";
|
|
125
|
+
} | {
|
|
126
|
+
outcome: "refused" | "conflict";
|
|
127
|
+
refusalCode: PhoneCorrectionRefusal;
|
|
128
|
+
};
|
|
129
|
+
export type CustomerRecoveryAuthorityResult = {
|
|
130
|
+
outcome: "issued";
|
|
131
|
+
deliveryStatus: string;
|
|
132
|
+
auditEventId: string;
|
|
133
|
+
} | {
|
|
134
|
+
outcome: "replayed";
|
|
135
|
+
deliveryStatus: string;
|
|
136
|
+
auditEventId: string;
|
|
137
|
+
} | {
|
|
138
|
+
outcome: "refused";
|
|
139
|
+
refusalCode: RecoveryRefusal;
|
|
140
|
+
} | {
|
|
141
|
+
outcome: "conflict";
|
|
142
|
+
conflictCode: "idempotency_conflict";
|
|
143
|
+
};
|
|
144
|
+
export interface LeadAbsorptionCarried {
|
|
145
|
+
personalization: number;
|
|
146
|
+
consents: number;
|
|
147
|
+
sourceLinks: number;
|
|
148
|
+
deliveries: number;
|
|
149
|
+
}
|
|
150
|
+
export type OperatorLeadAbsorptionResult = {
|
|
151
|
+
outcome: "applied" | "noop" | "replayed";
|
|
152
|
+
leadId: string;
|
|
153
|
+
customerId: string;
|
|
154
|
+
carried: LeadAbsorptionCarried;
|
|
155
|
+
} | {
|
|
156
|
+
outcome: "refused" | "conflict";
|
|
157
|
+
leadId: string;
|
|
158
|
+
refusalCode: LeadRefusal;
|
|
159
|
+
blockingTables: string[];
|
|
160
|
+
};
|
|
161
|
+
export interface OperatorEmailCorrectionClaim {
|
|
162
|
+
idempotencyKey: string;
|
|
163
|
+
claimToken: string;
|
|
164
|
+
sequence: string;
|
|
165
|
+
}
|
|
166
|
+
export interface OperatorIdentityMovePort {
|
|
167
|
+
findClientHoldingEmail(email: string): Promise<{
|
|
168
|
+
clientId: string;
|
|
169
|
+
} | null>;
|
|
170
|
+
readIdentityEmail(authUserId: string): Promise<string>;
|
|
171
|
+
moveIdentityEmail(authUserId: string, email: string, claim: OperatorEmailCorrectionClaim): Promise<void>;
|
|
172
|
+
}
|
|
173
|
+
export type OperatorEmailCorrectionAdmission = OperatorEmailCorrectionResult | {
|
|
174
|
+
outcome: "admitted";
|
|
175
|
+
authUserId: string | null;
|
|
176
|
+
originalEmail: string;
|
|
177
|
+
newEmail: string;
|
|
178
|
+
};
|
|
179
|
+
export type OperatorEmailCorrectionPhase = "complete" | "release" | "fail";
|
|
180
|
+
export type OperatorEmailCorrectionSettlement = OperatorEmailCorrectionResult | {
|
|
181
|
+
outcome: "pending";
|
|
182
|
+
} | {
|
|
183
|
+
outcome: "failed";
|
|
184
|
+
};
|
|
185
|
+
export type OperatorEmailCorrectionExecution = OperatorEmailCorrectionSettlement | (OperatorEmailCorrectionClaim & {
|
|
186
|
+
outcome: "claimed";
|
|
187
|
+
authUserId: string | null;
|
|
188
|
+
originalEmail: string;
|
|
189
|
+
newEmail: string;
|
|
190
|
+
});
|
|
191
|
+
export type OperatorAccountLinkRefusal = "subject_not_found" | "subject_not_customer" | "subject_email_missing" | "email_expectation_conflict" | "subject_account_linked" | "identity_not_linkable" | "identity_linked_elsewhere";
|
|
192
|
+
export type OperatorAccountLinkResult = {
|
|
193
|
+
outcome: "applied" | "noop" | "replayed";
|
|
194
|
+
} | {
|
|
195
|
+
outcome: "refused" | "conflict";
|
|
196
|
+
refusalCode: OperatorAccountLinkRefusal;
|
|
197
|
+
};
|
|
198
|
+
export interface OperatorAccountLinkRequest {
|
|
199
|
+
action: "link_account";
|
|
200
|
+
subjectId: string;
|
|
201
|
+
expectedEmail: string;
|
|
202
|
+
idempotencyKey: string;
|
|
203
|
+
}
|
|
204
|
+
export interface OperatorAccountLinkIdentityPort {
|
|
205
|
+
findSubject(clientId: string): Promise<{
|
|
206
|
+
identityKind: string | null;
|
|
207
|
+
email: string | null;
|
|
208
|
+
authUserId: string | null;
|
|
209
|
+
} | null>;
|
|
210
|
+
resolveIdentityForEmail(email: string): Promise<string>;
|
|
211
|
+
}
|
|
212
|
+
export interface OperatorSubscriptionInput {
|
|
213
|
+
subscriptionId: string;
|
|
214
|
+
subscriptionAction: OperatorSubscriptionAction;
|
|
215
|
+
expectedVersion: number;
|
|
216
|
+
payload: OperatorSubscriptionPayload;
|
|
217
|
+
idempotencyKey: string;
|
|
218
|
+
operatorId: string;
|
|
219
|
+
}
|
|
220
|
+
export interface OperatorEmailInput {
|
|
221
|
+
subjectId: string;
|
|
222
|
+
expectedEmail: string;
|
|
223
|
+
newEmail: string;
|
|
224
|
+
idempotencyKey: string;
|
|
225
|
+
operatorId: string;
|
|
226
|
+
}
|
|
227
|
+
export interface OperatorPhoneInput {
|
|
228
|
+
subjectId: string;
|
|
229
|
+
expectedPhone: string;
|
|
230
|
+
newPhone: string;
|
|
231
|
+
idempotencyKey: string;
|
|
232
|
+
operatorId: string;
|
|
233
|
+
}
|
|
234
|
+
export interface OperatorLinkInput {
|
|
235
|
+
subjectId: string;
|
|
236
|
+
expectedEmail: string;
|
|
237
|
+
authUserId: string | null;
|
|
238
|
+
idempotencyKey: string;
|
|
239
|
+
operatorId: string;
|
|
240
|
+
}
|
|
241
|
+
export interface OperatorRecoveryInput {
|
|
242
|
+
subjectId: string;
|
|
243
|
+
caseId: string;
|
|
244
|
+
idempotencyKey: string;
|
|
245
|
+
operatorId: string;
|
|
246
|
+
}
|
|
247
|
+
export interface OperatorAbsorptionInput {
|
|
248
|
+
customerId: string;
|
|
249
|
+
leadId: string;
|
|
250
|
+
expectedLeadEmail: string;
|
|
251
|
+
idempotencyKey: string;
|
|
252
|
+
operatorId: string;
|
|
253
|
+
}
|
|
254
|
+
export interface ManagedOperatorAuthorityPort {
|
|
255
|
+
applySubscriptionAction(input: OperatorSubscriptionInput): Promise<OperatorSubscriptionResult>;
|
|
256
|
+
correctSubjectEmail(input: OperatorEmailInput): Promise<OperatorEmailCorrectionAdmission>;
|
|
257
|
+
claimSubjectEmail(input: {
|
|
258
|
+
idempotencyKey: string;
|
|
259
|
+
}): Promise<OperatorEmailCorrectionExecution>;
|
|
260
|
+
settleSubjectEmail(input: {
|
|
261
|
+
idempotencyKey: string;
|
|
262
|
+
claimToken: string;
|
|
263
|
+
phase: OperatorEmailCorrectionPhase;
|
|
264
|
+
}): Promise<OperatorEmailCorrectionSettlement>;
|
|
265
|
+
correctSubjectPhone(input: OperatorPhoneInput): Promise<OperatorPhoneCorrectionResult>;
|
|
266
|
+
linkSubjectAccount(input: OperatorLinkInput): Promise<OperatorAccountLinkResult>;
|
|
267
|
+
issueRecovery(input: OperatorRecoveryInput): Promise<CustomerRecoveryAuthorityResult>;
|
|
268
|
+
absorbLead(input: OperatorAbsorptionInput): Promise<OperatorLeadAbsorptionResult>;
|
|
269
|
+
}
|
|
270
|
+
export interface NativeOperatorAuthorityPort {
|
|
271
|
+
applySubscriptionAction(input: OperatorSubscriptionInput): Promise<NativeOperatorSubscriptionResult>;
|
|
272
|
+
correctSubjectEmail(input: OperatorEmailInput): Promise<OperatorAuthorityUnavailable>;
|
|
273
|
+
correctSubjectPhone(input: OperatorPhoneInput): Promise<OperatorAuthorityUnavailable>;
|
|
274
|
+
linkSubjectAccount(input: OperatorLinkInput): Promise<OperatorAuthorityUnavailable>;
|
|
275
|
+
issueRecovery(input: OperatorRecoveryInput): Promise<CustomerRecoveryAuthorityResult>;
|
|
276
|
+
absorbLead(input: OperatorAbsorptionInput): Promise<OperatorLeadAbsorptionResult>;
|
|
277
|
+
}
|
|
278
|
+
export type LinkThenSubscriptionResult = {
|
|
279
|
+
outcome: "link_refused";
|
|
280
|
+
link: OperatorAccountLinkResult | OperatorAuthorityUnavailable;
|
|
281
|
+
} | {
|
|
282
|
+
outcome: "completed";
|
|
283
|
+
link: OperatorAccountLinkResult;
|
|
284
|
+
subscription: NativeOperatorSubscriptionResult;
|
|
285
|
+
} | {
|
|
286
|
+
outcome: "partial";
|
|
287
|
+
link: OperatorAccountLinkResult;
|
|
288
|
+
subscription: NativeOperatorSubscriptionResult | null;
|
|
289
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AccountSupportCapabilities } from "./contracts/index.js";
|
|
2
|
+
import type { AccountSupportCallable, AccountSupportOperations } from "./bindings.js";
|
|
3
|
+
export type AccountSupportBindingRefusal = {
|
|
4
|
+
readonly kind: "refused";
|
|
5
|
+
readonly code: "disabled" | "schema_unknown" | "schema_unsatisfied";
|
|
6
|
+
};
|
|
7
|
+
export type AccountSupportReadiness = {
|
|
8
|
+
readonly kind: "ready";
|
|
9
|
+
} | AccountSupportBindingRefusal;
|
|
10
|
+
export type GuardedAccountSupportOperation<F> = F extends AccountSupportCallable ? (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>> | AccountSupportBindingRefusal> : null;
|
|
11
|
+
export type GuardedAccountSupportOperations<O extends AccountSupportOperations> = {
|
|
12
|
+
readonly [K in keyof O]: GuardedAccountSupportOperation<O[K]>;
|
|
13
|
+
};
|
|
14
|
+
/** One guard per callable identity, shared by service, port and route aliases. */
|
|
15
|
+
export declare function createAccountSupportServices<O extends AccountSupportOperations>(input: {
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
capabilities: AccountSupportCapabilities;
|
|
18
|
+
operations: O;
|
|
19
|
+
readiness(): Promise<AccountSupportReadiness>;
|
|
20
|
+
}): Readonly<{
|
|
21
|
+
capabilities: AccountSupportCapabilities;
|
|
22
|
+
readiness: () => Promise<AccountSupportReadiness>;
|
|
23
|
+
operations: Readonly<GuardedAccountSupportOperations<O>>;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** One guard per callable identity, shared by service, port and route aliases. */
|
|
2
|
+
export function createAccountSupportServices(input) {
|
|
3
|
+
const enabled = input.enabled === true, observe = input.readiness;
|
|
4
|
+
async function readiness() {
|
|
5
|
+
return enabled ? observe() : { kind: "refused", code: "disabled" };
|
|
6
|
+
}
|
|
7
|
+
const guards = new Map();
|
|
8
|
+
const operations = Object.fromEntries(Object.entries(input.operations).map(([key, operation]) => {
|
|
9
|
+
if (operation === null)
|
|
10
|
+
return [key, null];
|
|
11
|
+
let guarded = guards.get(operation);
|
|
12
|
+
if (!guarded) {
|
|
13
|
+
guarded = async (...args) => {
|
|
14
|
+
const state = await readiness();
|
|
15
|
+
return state.kind === "ready" ? operation(...args) : state;
|
|
16
|
+
};
|
|
17
|
+
guards.set(operation, guarded);
|
|
18
|
+
}
|
|
19
|
+
return [key, guarded];
|
|
20
|
+
}));
|
|
21
|
+
return Object.freeze({ capabilities: input.capabilities, readiness, operations: Object.freeze(operations) });
|
|
22
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Customer360Snapshot, Customer360Subject, Customer360ContactHealth, Customer360ReadPort, Customer360Lookup, Customer360SummaryReadPort, DiagnosticHistoryReadPort } from "./contracts/customer360.js";
|
|
2
|
+
export declare const SUPPORT_CUSTOMER_360_CONTRACT_VERSION: "support.customer_360.v2";
|
|
3
|
+
type Row = Record<string, unknown>;
|
|
4
|
+
export type CustomerJourneyAuditEvent = {
|
|
5
|
+
eventId: string;
|
|
6
|
+
occurredAt: string;
|
|
7
|
+
action: string;
|
|
8
|
+
outcome: string;
|
|
9
|
+
entity: {
|
|
10
|
+
kind: "subject" | "order" | "subscription" | "dunning_case";
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export interface ContactHealthDelivery {
|
|
15
|
+
readonly status: string;
|
|
16
|
+
readonly occurredAt: string | null;
|
|
17
|
+
readonly permanentBounce: boolean | null;
|
|
18
|
+
}
|
|
19
|
+
export interface Customer360ProjectionInput<Extension = unknown> {
|
|
20
|
+
subject: {
|
|
21
|
+
subjectId: string;
|
|
22
|
+
displayName: string | null;
|
|
23
|
+
email: string | null;
|
|
24
|
+
phone?: string | null;
|
|
25
|
+
lifecycleStage: Customer360Subject["lifecycleStage"];
|
|
26
|
+
createdAt: string | null;
|
|
27
|
+
lastActivityAt: string | null;
|
|
28
|
+
};
|
|
29
|
+
legacy: {
|
|
30
|
+
lookup: {
|
|
31
|
+
warnings: string[];
|
|
32
|
+
};
|
|
33
|
+
customer: {
|
|
34
|
+
authUserLinked: boolean;
|
|
35
|
+
};
|
|
36
|
+
orders: {
|
|
37
|
+
orderId: string;
|
|
38
|
+
orderNumber: string | null;
|
|
39
|
+
status: string | null;
|
|
40
|
+
omsProjection: Row;
|
|
41
|
+
}[];
|
|
42
|
+
subscriptions: {
|
|
43
|
+
subscriptionId: string;
|
|
44
|
+
status: string | null;
|
|
45
|
+
nextCycleAt: string | null;
|
|
46
|
+
templateVersion?: number | null;
|
|
47
|
+
paymentMethodStatus?: string | null;
|
|
48
|
+
renewalOrders: Row[];
|
|
49
|
+
}[];
|
|
50
|
+
payment: {
|
|
51
|
+
status: string | null;
|
|
52
|
+
intents: Row[];
|
|
53
|
+
};
|
|
54
|
+
timeline: Row[];
|
|
55
|
+
} | null;
|
|
56
|
+
cases: Row[];
|
|
57
|
+
notices: Row[];
|
|
58
|
+
tokens: Row[];
|
|
59
|
+
recoveryAudit: Row[];
|
|
60
|
+
orderTruth: Row[];
|
|
61
|
+
now: number;
|
|
62
|
+
contactHealth?: Customer360ContactHealth | null;
|
|
63
|
+
signedIn?: boolean;
|
|
64
|
+
addresses?: Customer360Snapshot["addresses"] | null;
|
|
65
|
+
subscriptionPointers?: Map<string, {
|
|
66
|
+
shippingAddressId: string | null;
|
|
67
|
+
paymentMethodKind: string | null;
|
|
68
|
+
}> | null;
|
|
69
|
+
/** false means failed/unavailable; null means no enrichment selected. */
|
|
70
|
+
profile?: {
|
|
71
|
+
extension: Extension;
|
|
72
|
+
partial: boolean;
|
|
73
|
+
} | false | null;
|
|
74
|
+
}
|
|
75
|
+
export interface Customer360ProjectionPolicy {
|
|
76
|
+
lifecycle(subject: Customer360ProjectionInput["subject"]): Customer360Subject["lifecycle"];
|
|
77
|
+
/** Stable audit identity hashing remains in the server host. */
|
|
78
|
+
timelineAudit(event: Row, subjectId: string): CustomerJourneyAuditEvent[];
|
|
79
|
+
}
|
|
80
|
+
export declare function projectCustomer360Snapshot<Extension>(input: Customer360ProjectionInput<Extension>, policy: Customer360ProjectionPolicy): Customer360Snapshot<Extension>;
|
|
81
|
+
export declare function boundedCustomerJourneyAudit(events: CustomerJourneyAuditEvent[]): {
|
|
82
|
+
events: CustomerJourneyAuditEvent[];
|
|
83
|
+
windowed: boolean;
|
|
84
|
+
};
|
|
85
|
+
export declare function deriveContactHealth(deliveries: readonly ContactHealthDelivery[]): Customer360ContactHealth;
|
|
86
|
+
/** Authorize before every source read; retain host defaults, ambiguity, null and failure semantics. */
|
|
87
|
+
export declare function createCustomer360ReadFacade<Search, Snapshot, SummaryRequest, SummaryResult, DiagnosticRequest, DiagnosticResult>(ports: {
|
|
88
|
+
authorize(): Promise<boolean>;
|
|
89
|
+
journey: Customer360ReadPort<Search, Snapshot>;
|
|
90
|
+
summary: Customer360SummaryReadPort<SummaryRequest, SummaryResult>;
|
|
91
|
+
diagnostics: DiagnosticHistoryReadPort<DiagnosticRequest, DiagnosticResult>;
|
|
92
|
+
}): {
|
|
93
|
+
searchCustomerJourney: (request: Customer360Lookup) => Promise<Search | {
|
|
94
|
+
kind: "denied";
|
|
95
|
+
}>;
|
|
96
|
+
getCustomerJourney: (request: Customer360Lookup) => Promise<Snapshot | {
|
|
97
|
+
kind: "denied";
|
|
98
|
+
} | null>;
|
|
99
|
+
getPortableSummary: (request: SummaryRequest) => Promise<SummaryResult | {
|
|
100
|
+
kind: "denied";
|
|
101
|
+
}>;
|
|
102
|
+
history: (request: DiagnosticRequest) => Promise<DiagnosticResult | {
|
|
103
|
+
kind: "denied";
|
|
104
|
+
}>;
|
|
105
|
+
};
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export const SUPPORT_CUSTOMER_360_CONTRACT_VERSION = "support.customer_360.v2";
|
|
2
|
+
export function projectCustomer360Snapshot(input, policy) {
|
|
3
|
+
const { subject, legacy, cases, notices, tokens, recoveryAudit, orderTruth, now } = input;
|
|
4
|
+
const orders = legacy?.orders.map(order => ({
|
|
5
|
+
orderId: order.orderId,
|
|
6
|
+
orderNumber: order.orderNumber,
|
|
7
|
+
status: order.status ?? "unknown",
|
|
8
|
+
subscriptionId: string(order.omsProjection.subscriptionId),
|
|
9
|
+
totalMinor: integer(order.omsProjection.totalMinor),
|
|
10
|
+
currency: string(order.omsProjection.currency),
|
|
11
|
+
createdAt: date(order.omsProjection.createdAt)
|
|
12
|
+
})) ?? [];
|
|
13
|
+
const pending = (row) => orderTruth.some(order => order.id === row.order_id && order.client_id === row.client_id && order.status === "pending_payment");
|
|
14
|
+
const eligible = (row) => subject.lifecycleStage === "customer" && row.status === "open" && pending(row);
|
|
15
|
+
const audit = boundedCustomerJourneyAudit([
|
|
16
|
+
...(legacy?.timeline ?? []).flatMap(event => policy.timelineAudit(event, subject.subjectId)),
|
|
17
|
+
...recoveryAudit.flatMap(recoveryEvent)
|
|
18
|
+
]);
|
|
19
|
+
const profile = input.profile;
|
|
20
|
+
const warnings = [...new Set([
|
|
21
|
+
...(legacy?.lookup.warnings ?? []),
|
|
22
|
+
...(audit.windowed ? ["evidence_window_limited:customer_360_audit_trail"] : []),
|
|
23
|
+
...(recoveryAudit.length === 80 ? ["evidence_window_limited:customer_recovery_audit"] : []),
|
|
24
|
+
...(profile === false ? ["evidence_unavailable:customer_profile"] : profile?.partial ? ["evidence_partial:customer_profile"] : [])
|
|
25
|
+
])];
|
|
26
|
+
return {
|
|
27
|
+
contractVersion: SUPPORT_CUSTOMER_360_CONTRACT_VERSION,
|
|
28
|
+
lookup: { query: subject.subjectId, matchedBy: "subject_id", confidence: "exact", warnings },
|
|
29
|
+
...(input.contactHealth ? { contactHealth: input.contactHealth } : {}),
|
|
30
|
+
...(input.addresses ? { addresses: input.addresses } : {}),
|
|
31
|
+
...(profile ? { extension: profile.extension } : {}),
|
|
32
|
+
subject: {
|
|
33
|
+
subjectId: subject.subjectId,
|
|
34
|
+
displayName: subject.displayName,
|
|
35
|
+
email: subject.email,
|
|
36
|
+
phone: subject.phone ?? null,
|
|
37
|
+
lifecycleStage: subject.lifecycleStage,
|
|
38
|
+
lifecycle: policy.lifecycle(subject),
|
|
39
|
+
firstSeenAt: subject.createdAt,
|
|
40
|
+
lastActivityAt: latest([...(legacy?.timeline ?? []), ...cases, ...recoveryAudit]) ?? subject.lastActivityAt,
|
|
41
|
+
...(legacy ? { authUserLinked: legacy.customer.authUserLinked } : {}),
|
|
42
|
+
...(input.signedIn === undefined ? {} : { hasSignedIn: input.signedIn })
|
|
43
|
+
},
|
|
44
|
+
orders,
|
|
45
|
+
subscriptions: legacy?.subscriptions.map(value => ({
|
|
46
|
+
subscriptionId: value.subscriptionId,
|
|
47
|
+
status: value.status ?? "unknown",
|
|
48
|
+
nextCycleAt: value.nextCycleAt,
|
|
49
|
+
latestOrderId: string(value.renewalOrders[0]?.orderId),
|
|
50
|
+
...(typeof value.templateVersion === "number" ? { templateVersion: value.templateVersion } : {}),
|
|
51
|
+
...(input.subscriptionPointers
|
|
52
|
+
? {
|
|
53
|
+
shippingAddressId: input.subscriptionPointers.get(value.subscriptionId)?.shippingAddressId ?? null,
|
|
54
|
+
paymentMethodKind: input.subscriptionPointers.get(value.subscriptionId)?.paymentMethodKind ?? null
|
|
55
|
+
}
|
|
56
|
+
: {}),
|
|
57
|
+
paymentMethodStatus: string(value.paymentMethodStatus)
|
|
58
|
+
})) ?? [],
|
|
59
|
+
payment: orders.map(order => {
|
|
60
|
+
const intent = legacy?.payment.intents.find(value => string(value.orderId) === order.orderId);
|
|
61
|
+
return {
|
|
62
|
+
orderId: order.orderId,
|
|
63
|
+
status: string(intent?.status) ?? legacy?.payment.status ?? "unknown",
|
|
64
|
+
recoverable: cases.some(row => row.order_id === order.orderId && eligible(row)),
|
|
65
|
+
amountMinor: order.totalMinor,
|
|
66
|
+
currency: order.currency,
|
|
67
|
+
lastAttemptAt: date(intent?.updatedAt)
|
|
68
|
+
};
|
|
69
|
+
}),
|
|
70
|
+
dunningCases: cases.map(row => ({
|
|
71
|
+
caseId: string(row.id),
|
|
72
|
+
subscriptionId: string(row.subscription_id),
|
|
73
|
+
orderId: string(row.order_id),
|
|
74
|
+
status: string(row.status) ?? "unknown",
|
|
75
|
+
retryAttempt: integer(row.retry_attempt) ?? 0,
|
|
76
|
+
nextRetryAt: date(row.next_retry_at),
|
|
77
|
+
notificationStatus: string(latestNotice(notices, string(row.id))?.status),
|
|
78
|
+
recoveryAvailable: eligible(row)
|
|
79
|
+
})),
|
|
80
|
+
recovery: cases.map(row => {
|
|
81
|
+
const id = string(row.id), related = tokens.filter(value => value.case_id === id);
|
|
82
|
+
return {
|
|
83
|
+
caseId: id,
|
|
84
|
+
status: pending(row) && related.some(value => {
|
|
85
|
+
const expiry = date(value.expires_at);
|
|
86
|
+
return Boolean(expiry && Date.parse(expiry) > now && !value.used_at && !value.revoked_at);
|
|
87
|
+
}) ? "available" : "unavailable",
|
|
88
|
+
actionAvailable: eligible(row),
|
|
89
|
+
lastIssuedAt: related.map(value => date(value.created_at)).filter(value => value !== null).sort().at(-1) ?? null,
|
|
90
|
+
lastDeliveryStatus: string(latestNotice(notices, id, "payment_recovery")?.status)
|
|
91
|
+
};
|
|
92
|
+
}),
|
|
93
|
+
auditTrail: audit.events
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function boundedCustomerJourneyAudit(events) {
|
|
97
|
+
const instant = (value) => Number.isFinite(Date.parse(value)) ? Date.parse(value) : 0;
|
|
98
|
+
const newest = [...events].sort((a, b) => instant(b.occurredAt) - instant(a.occurredAt) || a.eventId.localeCompare(b.eventId));
|
|
99
|
+
return {
|
|
100
|
+
events: newest.slice(0, 80).sort((a, b) => instant(a.occurredAt) - instant(b.occurredAt) || a.eventId.localeCompare(b.eventId)),
|
|
101
|
+
windowed: newest.length > 80
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function deriveContactHealth(deliveries) {
|
|
105
|
+
const terminal = ["delivered", "bounced", "complained", "failed"];
|
|
106
|
+
const newest = deliveries.filter((value) => terminal.includes(value.status) && typeof value.occurredAt === "string")
|
|
107
|
+
.reduce((best, value) => best === null || value.occurredAt > best.occurredAt ? value : best, null);
|
|
108
|
+
if (!newest)
|
|
109
|
+
return { lastTerminalStatus: null, lastTerminalAt: null, reachable: true };
|
|
110
|
+
return {
|
|
111
|
+
lastTerminalStatus: newest.status,
|
|
112
|
+
lastTerminalAt: newest.occurredAt,
|
|
113
|
+
reachable: newest.status === "delivered" || (newest.status === "bounced" && newest.permanentBounce === false)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** Authorize before every source read; retain host defaults, ambiguity, null and failure semantics. */
|
|
117
|
+
export function createCustomer360ReadFacade(ports) {
|
|
118
|
+
async function read(query) {
|
|
119
|
+
if (!await ports.authorize())
|
|
120
|
+
return { kind: "denied" };
|
|
121
|
+
return query();
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
searchCustomerJourney: (request) => read(() => ports.journey.searchCustomerJourney(request)),
|
|
125
|
+
getCustomerJourney: (request) => read(() => ports.journey.getCustomerJourney(request)),
|
|
126
|
+
getPortableSummary: (request) => read(() => ports.summary.getPortableSummary(request)),
|
|
127
|
+
history: (request) => read(() => ports.diagnostics.history(request))
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function recoveryEvent(row) {
|
|
131
|
+
const eventId = string(row.id), occurredAt = date(row.occurred_at), id = string(row.case_id), outcome = string(row.outcome);
|
|
132
|
+
if (!eventId || !occurredAt || !id || !outcome)
|
|
133
|
+
return [];
|
|
134
|
+
const refusal = string(row.refusal_code);
|
|
135
|
+
return [{
|
|
136
|
+
eventId,
|
|
137
|
+
occurredAt,
|
|
138
|
+
action: "recovery.issue",
|
|
139
|
+
outcome: refusal ? `${outcome}:${refusal}` : outcome,
|
|
140
|
+
entity: { kind: "dunning_case", id }
|
|
141
|
+
}];
|
|
142
|
+
}
|
|
143
|
+
function latestNotice(rows, id, kind) {
|
|
144
|
+
return rows.filter(row => row.case_id === id && row.recipient_kind === "customer" && (!kind || row.notification_kind === kind))
|
|
145
|
+
.sort((a, b) => `${string(b.created_at) ?? ""}:${string(b.id) ?? ""}`.localeCompare(`${string(a.created_at) ?? ""}:${string(a.id) ?? ""}`))[0];
|
|
146
|
+
}
|
|
147
|
+
function string(value) {
|
|
148
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
149
|
+
}
|
|
150
|
+
function integer(value) {
|
|
151
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : null;
|
|
152
|
+
}
|
|
153
|
+
function date(value) {
|
|
154
|
+
const text = string(value);
|
|
155
|
+
return text && !Number.isNaN(Date.parse(text)) ? text : null;
|
|
156
|
+
}
|
|
157
|
+
function latest(rows) {
|
|
158
|
+
return rows.map(row => date(row.updated_at ?? row.updatedAt ?? row.created_at ?? row.createdAt ?? row.occurred_at ?? row.occurredAt))
|
|
159
|
+
.filter(value => value !== null)
|
|
160
|
+
.sort((a, b) => Date.parse(a) - Date.parse(b))
|
|
161
|
+
.at(-1)
|
|
162
|
+
?? null;
|
|
163
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type CustomerAccountReadStage = "account_aggregate";
|
|
2
|
+
type DiagnosticRecord = Record<string, unknown>;
|
|
3
|
+
export declare class CustomerAccountReadModelError extends Error {
|
|
4
|
+
readonly stage: CustomerAccountReadStage;
|
|
5
|
+
readonly cause: unknown;
|
|
6
|
+
constructor(stage: CustomerAccountReadStage, cause: unknown);
|
|
7
|
+
}
|
|
8
|
+
export declare function withCustomerAccountReadStage<T>(stage: CustomerAccountReadStage, operation: () => Promise<T>): Promise<T>;
|
|
9
|
+
export declare function customerAccountReadFailureDetails(error: unknown): DiagnosticRecord;
|
|
10
|
+
export declare function logCustomerAccountReadFailure(error: unknown): void;
|
|
11
|
+
export {};
|