@openlup/platform 0.21.0 → 0.23.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 +432 -146
- package/README.md +82 -589
- package/dist/composition/composeBundle.d.ts +7 -0
- package/dist/composition/composeBundle.js +2 -0
- package/dist/composition/fulfillmentContribution.d.ts +21 -0
- package/dist/composition/fulfillmentContribution.js +19 -0
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/index.js +1 -0
- package/dist/fulfillment/adapterConformance.d.ts +3 -0
- package/dist/fulfillment/adapterConformance.js +223 -0
- package/dist/fulfillment/bindings.d.ts +3 -0
- package/dist/fulfillment/bindings.js +29 -0
- package/dist/fulfillment/commerceFulfillmentHandlers.d.ts +29 -0
- package/dist/fulfillment/commerceFulfillmentHandlers.js +184 -0
- package/dist/fulfillment/commerceFulfillmentReadModel.d.ts +86 -0
- package/dist/fulfillment/commerceFulfillmentReadModel.js +131 -0
- package/dist/fulfillment/contracts/alignment.d.ts +25 -0
- package/dist/fulfillment/contracts/alignment.js +1 -0
- package/dist/fulfillment/contracts/bindings.d.ts +51 -0
- package/dist/fulfillment/contracts/bindings.js +1 -0
- package/dist/fulfillment/contracts/capabilities.d.ts +29 -0
- package/dist/fulfillment/contracts/capabilities.js +1 -0
- package/dist/fulfillment/contracts/conformance.d.ts +95 -0
- package/dist/fulfillment/contracts/conformance.js +1 -0
- package/dist/fulfillment/contracts/customerAlignment.d.ts +6 -0
- package/dist/fulfillment/contracts/customerAlignment.js +1 -0
- package/dist/fulfillment/contracts/dispatch.d.ts +143 -0
- package/dist/fulfillment/contracts/dispatch.js +1 -0
- package/dist/fulfillment/contracts/index.d.ts +18 -0
- package/dist/fulfillment/contracts/index.js +1 -0
- package/dist/fulfillment/contracts/label.d.ts +35 -0
- package/dist/fulfillment/contracts/label.js +1 -0
- package/dist/fulfillment/contracts/nativeUnsupported.d.ts +6 -0
- package/dist/fulfillment/contracts/nativeUnsupported.js +1 -0
- package/dist/fulfillment/contracts/observation.d.ts +72 -0
- package/dist/fulfillment/contracts/observation.js +1 -0
- package/dist/fulfillment/contracts/operator.d.ts +64 -0
- package/dist/fulfillment/contracts/operator.js +1 -0
- package/dist/fulfillment/contracts/read.d.ts +110 -0
- package/dist/fulfillment/contracts/read.js +1 -0
- package/dist/fulfillment/contracts/readback.d.ts +59 -0
- package/dist/fulfillment/contracts/readback.js +1 -0
- package/dist/fulfillment/contracts/replacement.d.ts +34 -0
- package/dist/fulfillment/contracts/replacement.js +1 -0
- package/dist/fulfillment/contracts/store.d.ts +89 -0
- package/dist/fulfillment/contracts/store.js +1 -0
- package/dist/fulfillment/contracts/sync.d.ts +226 -0
- package/dist/fulfillment/contracts/sync.js +1 -0
- package/dist/fulfillment/currentFulfillmentParcel.d.ts +2 -0
- package/dist/fulfillment/currentFulfillmentParcel.js +1 -0
- package/dist/fulfillment/delayReadModel.d.ts +11 -0
- package/dist/fulfillment/delayReadModel.js +45 -0
- package/dist/fulfillment/deliveryAlignmentReadModel.d.ts +4 -0
- package/dist/fulfillment/deliveryAlignmentReadModel.js +12 -0
- package/dist/fulfillment/dispatchProjection.d.ts +26 -0
- package/dist/fulfillment/dispatchProjection.js +107 -0
- package/dist/fulfillment/fulfillmentObservationEffects.d.ts +66 -0
- package/dist/fulfillment/fulfillmentObservationEffects.js +36 -0
- package/dist/fulfillment/handlerSchemas.d.ts +647 -0
- package/dist/fulfillment/handlerSchemas.js +213 -0
- package/dist/fulfillment/handlerSupport.d.ts +33 -0
- package/dist/fulfillment/handlerSupport.js +25 -0
- package/dist/fulfillment/index.d.ts +38 -0
- package/dist/fulfillment/index.js +37 -0
- package/dist/fulfillment/labelLifecycle.d.ts +24 -0
- package/dist/fulfillment/labelLifecycle.js +9 -0
- package/dist/fulfillment/lowStockEvidenceHandler.d.ts +36 -0
- package/dist/fulfillment/lowStockEvidenceHandler.js +46 -0
- package/dist/fulfillment/migrations.d.ts +32 -0
- package/dist/fulfillment/migrations.js +9 -0
- package/dist/fulfillment/nativeUnsupported.d.ts +10 -0
- package/dist/fulfillment/nativeUnsupported.js +18 -0
- package/dist/fulfillment/normalizedFulfillmentFacts.d.ts +2 -0
- package/dist/fulfillment/normalizedFulfillmentFacts.js +1 -0
- package/dist/fulfillment/observationProjection.d.ts +32 -0
- package/dist/fulfillment/observationProjection.js +90 -0
- package/dist/fulfillment/omnipack/capabilities.d.ts +3 -0
- package/dist/fulfillment/omnipack/capabilities.js +16 -0
- package/dist/fulfillment/omnipack/client.d.ts +39 -0
- package/dist/fulfillment/omnipack/client.js +172 -0
- package/dist/fulfillment/omnipack/index.d.ts +55 -0
- package/dist/fulfillment/omnipack/index.js +408 -0
- package/dist/fulfillment/omnipack/mappers.d.ts +79 -0
- package/dist/fulfillment/omnipack/mappers.js +199 -0
- package/dist/fulfillment/omnipack/observation.d.ts +28 -0
- package/dist/fulfillment/omnipack/observation.js +72 -0
- package/dist/fulfillment/omnipack/omnipackDispatchPayload.d.ts +36 -0
- package/dist/fulfillment/omnipack/omnipackDispatchPayload.js +63 -0
- package/dist/fulfillment/omnipack/omnipackOutboundOrderPayload.d.ts +83 -0
- package/dist/fulfillment/omnipack/omnipackOutboundOrderPayload.js +113 -0
- package/dist/fulfillment/omnipack/omnipackProductPackPayload.d.ts +11 -0
- package/dist/fulfillment/omnipack/omnipackProductPackPayload.js +38 -0
- package/dist/fulfillment/omnipack/omnipackProductPayload.d.ts +18 -0
- package/dist/fulfillment/omnipack/omnipackProductPayload.js +51 -0
- package/dist/fulfillment/omnipack/omnipackReconciliationPayload.d.ts +1 -0
- package/dist/fulfillment/omnipack/omnipackReconciliationPayload.js +3 -0
- package/dist/fulfillment/omnipack/omnipackStatusVocabulary.d.ts +4 -0
- package/dist/fulfillment/omnipack/omnipackStatusVocabulary.js +87 -0
- package/dist/fulfillment/omnipack/omnipackWebhookPayload.d.ts +9 -0
- package/dist/fulfillment/omnipack/omnipackWebhookPayload.js +76 -0
- package/dist/fulfillment/omnipack/productSyncMappers.d.ts +18 -0
- package/dist/fulfillment/omnipack/productSyncMappers.js +43 -0
- package/dist/fulfillment/omnipack/providerError.d.ts +25 -0
- package/dist/fulfillment/omnipack/providerError.js +47 -0
- package/dist/fulfillment/omnipack/reconciliation.d.ts +15 -0
- package/dist/fulfillment/omnipack/reconciliation.js +55 -0
- package/dist/fulfillment/omnipack/trackingReferences.d.ts +16 -0
- package/dist/fulfillment/omnipack/trackingReferences.js +52 -0
- package/dist/fulfillment/paidFulfillmentRecovery.d.ts +67 -0
- package/dist/fulfillment/paidFulfillmentRecovery.js +154 -0
- package/dist/fulfillment/paidHandoff.d.ts +27 -0
- package/dist/fulfillment/paidHandoff.js +86 -0
- package/dist/fulfillment/paidHandoffPorts.d.ts +24 -0
- package/dist/fulfillment/paidHandoffPorts.js +3 -0
- package/dist/fulfillment/postgresDeliveryAlignment.d.ts +4 -0
- package/dist/fulfillment/postgresDeliveryAlignment.js +12 -0
- package/dist/fulfillment/postgresDispatchStore.d.ts +16 -0
- package/dist/fulfillment/postgresDispatchStore.js +44 -0
- package/dist/fulfillment/postgresEvidenceReadPort.d.ts +25 -0
- package/dist/fulfillment/postgresEvidenceReadPort.js +45 -0
- package/dist/fulfillment/postgresPaidFulfillmentRecovery.d.ts +25 -0
- package/dist/fulfillment/postgresPaidFulfillmentRecovery.js +26 -0
- package/dist/fulfillment/postgresPaidHandoffStore.d.ts +4 -0
- package/dist/fulfillment/postgresPaidHandoffStore.js +10 -0
- package/dist/fulfillment/postgresShipmentSpine.d.ts +70 -0
- package/dist/fulfillment/postgresShipmentSpine.js +246 -0
- package/dist/fulfillment/postgresStockSyncPort.d.ts +8 -0
- package/dist/fulfillment/postgresStockSyncPort.js +66 -0
- package/dist/fulfillment/productReconciliationEvidenceHandler.d.ts +36 -0
- package/dist/fulfillment/productReconciliationEvidenceHandler.js +50 -0
- package/dist/fulfillment/providerCapabilities.d.ts +9 -0
- package/dist/fulfillment/providerCapabilities.js +17 -0
- package/dist/fulfillment/providerCommandLedger.d.ts +143 -0
- package/dist/fulfillment/providerCommandLedger.js +14 -0
- package/dist/fulfillment/providerDispatchAcceptance.d.ts +27 -0
- package/dist/fulfillment/providerDispatchAcceptance.js +29 -0
- package/dist/fulfillment/providerDispatchError.d.ts +6 -0
- package/dist/fulfillment/providerDispatchError.js +5 -0
- package/dist/fulfillment/providerDispatchWorker.d.ts +44 -0
- package/dist/fulfillment/providerDispatchWorker.js +199 -0
- package/dist/fulfillment/providerProductSyncWorker.d.ts +28 -0
- package/dist/fulfillment/providerProductSyncWorker.js +122 -0
- package/dist/fulfillment/providerReconciliationError.d.ts +9 -0
- package/dist/fulfillment/providerReconciliationError.js +17 -0
- package/dist/fulfillment/providerReconciliationTerminalSkip.d.ts +2 -0
- package/dist/fulfillment/providerReconciliationTerminalSkip.js +6 -0
- package/dist/fulfillment/providerReconciliationTimestamp.d.ts +1 -0
- package/dist/fulfillment/providerReconciliationTimestamp.js +27 -0
- package/dist/fulfillment/providerReconciliationWorker.d.ts +90 -0
- package/dist/fulfillment/providerReconciliationWorker.js +207 -0
- package/dist/fulfillment/providerStockAvailability.d.ts +13 -0
- package/dist/fulfillment/providerStockAvailability.js +51 -0
- package/dist/fulfillment/providerStockSyncWorker.d.ts +41 -0
- package/dist/fulfillment/providerStockSyncWorker.js +295 -0
- package/dist/fulfillment/providerTrackingReferences.d.ts +16 -0
- package/dist/fulfillment/providerTrackingReferences.js +23 -0
- package/dist/fulfillment/replacementRefusals.d.ts +5 -0
- package/dist/fulfillment/replacementRefusals.js +38 -0
- package/dist/fulfillment/replacementShipmentHandler.d.ts +5 -0
- package/dist/fulfillment/replacementShipmentHandler.js +46 -0
- package/dist/fulfillment/schemaCapabilities.d.ts +13 -0
- package/dist/fulfillment/schemaCapabilities.js +7 -0
- package/dist/fulfillment/shipmentsOverviewHandler.d.ts +16 -0
- package/dist/fulfillment/shipmentsOverviewHandler.js +54 -0
- package/dist/fulfillment/statusMap.d.ts +2 -0
- package/dist/fulfillment/statusMap.js +1 -0
- package/dist/fulfillment/trackingProgress.d.ts +1 -0
- package/dist/fulfillment/trackingProgress.js +1 -0
- package/dist/fulfillment/verifiedIngress.d.ts +79 -0
- package/dist/fulfillment/verifiedIngress.js +94 -0
- package/dist/invoicing/capabilities.d.ts +11 -0
- package/dist/invoicing/capabilities.js +10 -0
- package/dist/invoicing/contracts/capabilities.d.ts +40 -0
- package/dist/invoicing/contracts/capabilities.js +1 -0
- package/dist/invoicing/contracts/companyLookup.d.ts +49 -0
- package/dist/invoicing/contracts/companyLookup.js +1 -0
- package/dist/invoicing/contracts/delivery.d.ts +74 -0
- package/dist/invoicing/contracts/delivery.js +1 -0
- package/dist/invoicing/contracts/facts.d.ts +100 -0
- package/dist/invoicing/contracts/facts.js +1 -0
- package/dist/invoicing/contracts/host.d.ts +246 -0
- package/dist/invoicing/contracts/host.js +1 -0
- package/dist/invoicing/contracts/index.d.ts +16 -0
- package/dist/invoicing/contracts/index.js +1 -0
- package/dist/invoicing/contracts/provider.d.ts +126 -0
- package/dist/invoicing/contracts/provider.js +1 -0
- package/dist/invoicing/contracts/settlement.d.ts +66 -0
- package/dist/invoicing/contracts/settlement.js +1 -0
- package/dist/invoicing/contracts/store.d.ts +267 -0
- package/dist/invoicing/contracts/store.js +1 -0
- package/dist/invoicing/index.d.ts +1 -0
- package/dist/invoicing/index.js +1 -0
- package/dist/payments/stripe/index.d.ts +25 -0
- package/dist/payments/stripe/index.js +25 -0
- package/dist/payments/tpay/index.d.ts +30 -0
- package/dist/payments/tpay/index.js +30 -0
- package/dist/subscriptions/automaticRenewal.d.ts +44 -0
- package/dist/subscriptions/automaticRenewal.js +81 -0
- package/dist/subscriptions/automaticRenewalExecution.d.ts +21 -0
- package/dist/subscriptions/automaticRenewalExecution.js +44 -0
- package/dist/subscriptions/contracts/commands.d.ts +115 -0
- package/dist/subscriptions/contracts/commands.js +1 -0
- package/dist/subscriptions/contracts/dunning.d.ts +133 -0
- package/dist/subscriptions/contracts/dunning.js +1 -0
- package/dist/subscriptions/contracts/index.d.ts +6 -0
- package/dist/subscriptions/contracts/index.js +1 -0
- package/dist/subscriptions/contracts/messages.d.ts +43 -0
- package/dist/subscriptions/contracts/messages.js +1 -0
- package/dist/subscriptions/contracts/renewal.d.ts +533 -0
- package/dist/subscriptions/contracts/renewal.js +1 -0
- package/dist/subscriptions/contracts/stockWait.d.ts +73 -0
- package/dist/subscriptions/contracts/stockWait.js +1 -0
- package/dist/subscriptions/index.d.ts +39 -0
- package/dist/subscriptions/index.js +17 -0
- package/dist/subscriptions/paymentOutcomes.d.ts +8 -0
- package/dist/subscriptions/paymentOutcomes.js +27 -0
- package/dist/subscriptions/postgresRenewalStore.d.ts +20 -0
- package/dist/subscriptions/postgresRenewalStore.js +61 -0
- package/dist/subscriptions/postgresRetryStore.d.ts +78 -0
- package/dist/subscriptions/postgresRetryStore.js +142 -0
- package/dist/subscriptions/renewalCycleFailureMechanism.d.ts +34 -0
- package/dist/subscriptions/renewalCycleFailureMechanism.js +79 -0
- package/dist/subscriptions/renewalCycleMechanism.d.ts +46 -0
- package/dist/subscriptions/renewalCycleMechanism.js +157 -0
- package/dist/subscriptions/renewalCycleRefusalMechanism.d.ts +41 -0
- package/dist/subscriptions/renewalCycleRefusalMechanism.js +160 -0
- package/dist/subscriptions/renewalIdentity.d.ts +3 -0
- package/dist/subscriptions/renewalIdentity.js +4 -0
- package/package.json +37 -2
- package/release-gates.json +97 -3
- package/sql/20260808210000_fulfillment_shipment_rail.sql +810 -0
- package/sql/20260819150000_fulfillment_shipment_sequence.sql +98 -0
- package/sql/20261022080000_fulfillment_command_ledger.sql +786 -0
- package/sql/20261022090000_fulfillment_delivery_alignment.sql +1106 -0
- package/sql/20261022160000_subscription_retry_lifecycle.sql +328 -0
- package/sql/20261022165000_fulfillment_stock_evidence_replay_reopen.sql +30 -0
- package/src/composition/composeBundle.ts +4 -0
- package/src/composition/fulfillmentContribution.ts +28 -0
- package/src/composition/index.ts +1 -0
- package/src/fulfillment/adapterConformance.ts +195 -0
- package/src/fulfillment/bindings.ts +26 -0
- package/src/fulfillment/commerceFulfillmentHandlers.ts +263 -0
- package/src/fulfillment/commerceFulfillmentReadModel.ts +257 -0
- package/src/fulfillment/contracts/alignment.ts +13 -0
- package/src/fulfillment/contracts/bindings.ts +30 -0
- package/src/fulfillment/contracts/capabilities.ts +15 -0
- package/src/fulfillment/contracts/conformance.ts +63 -0
- package/src/fulfillment/contracts/customerAlignment.ts +4 -0
- package/src/fulfillment/contracts/dispatch.ts +73 -0
- package/src/fulfillment/contracts/index.ts +18 -0
- package/src/fulfillment/contracts/label.ts +9 -0
- package/src/fulfillment/contracts/nativeUnsupported.ts +6 -0
- package/src/fulfillment/contracts/observation.ts +26 -0
- package/src/fulfillment/contracts/operator.ts +31 -0
- package/src/fulfillment/contracts/read.ts +42 -0
- package/src/fulfillment/contracts/readback.ts +24 -0
- package/src/fulfillment/contracts/replacement.ts +15 -0
- package/src/fulfillment/contracts/store.ts +27 -0
- package/src/fulfillment/contracts/sync.ts +72 -0
- package/src/fulfillment/currentFulfillmentParcel.ts +2 -0
- package/src/fulfillment/delayReadModel.ts +60 -0
- package/src/fulfillment/deliveryAlignmentReadModel.ts +15 -0
- package/src/fulfillment/dispatchProjection.ts +105 -0
- package/src/fulfillment/fulfillmentObservationEffects.ts +86 -0
- package/src/fulfillment/handlerSchemas.ts +255 -0
- package/src/fulfillment/handlerSupport.ts +25 -0
- package/src/fulfillment/index.ts +39 -0
- package/src/fulfillment/labelLifecycle.ts +11 -0
- package/src/fulfillment/lowStockEvidenceHandler.ts +60 -0
- package/src/fulfillment/migrations.ts +9 -0
- package/src/fulfillment/nativeUnsupported.ts +23 -0
- package/src/fulfillment/normalizedFulfillmentFacts.ts +2 -0
- package/src/fulfillment/observationProjection.ts +92 -0
- package/src/fulfillment/omnipack/capabilities.ts +18 -0
- package/src/fulfillment/omnipack/client.ts +270 -0
- package/src/fulfillment/omnipack/index.ts +369 -0
- package/src/fulfillment/omnipack/mappers.ts +282 -0
- package/src/fulfillment/omnipack/observation.ts +79 -0
- package/src/fulfillment/omnipack/omnipackDispatchPayload.ts +93 -0
- package/src/fulfillment/omnipack/omnipackOutboundOrderPayload.ts +194 -0
- package/src/fulfillment/omnipack/omnipackProductPackPayload.ts +47 -0
- package/src/fulfillment/omnipack/omnipackProductPayload.ts +67 -0
- package/src/fulfillment/omnipack/omnipackReconciliationPayload.ts +7 -0
- package/src/fulfillment/omnipack/omnipackStatusVocabulary.ts +103 -0
- package/src/fulfillment/omnipack/omnipackWebhookPayload.ts +73 -0
- package/src/fulfillment/omnipack/productSyncMappers.ts +74 -0
- package/src/fulfillment/omnipack/providerError.ts +64 -0
- package/src/fulfillment/omnipack/reconciliation.ts +56 -0
- package/src/fulfillment/omnipack/trackingReferences.ts +77 -0
- package/src/fulfillment/paidFulfillmentRecovery.ts +252 -0
- package/src/fulfillment/paidHandoff.ts +122 -0
- package/src/fulfillment/paidHandoffPorts.ts +21 -0
- package/src/fulfillment/postgresDeliveryAlignment.ts +14 -0
- package/src/fulfillment/postgresDispatchStore.ts +55 -0
- package/src/fulfillment/postgresEvidenceReadPort.ts +59 -0
- package/src/fulfillment/postgresPaidFulfillmentRecovery.ts +29 -0
- package/src/fulfillment/postgresPaidHandoffStore.ts +11 -0
- package/src/fulfillment/postgresShipmentSpine.ts +338 -0
- package/src/fulfillment/postgresStockSyncPort.ts +68 -0
- package/src/fulfillment/productReconciliationEvidenceHandler.ts +64 -0
- package/src/fulfillment/providerCapabilities.ts +18 -0
- package/src/fulfillment/providerCommandLedger.ts +53 -0
- package/src/fulfillment/providerDispatchAcceptance.ts +37 -0
- package/src/fulfillment/providerDispatchError.ts +7 -0
- package/src/fulfillment/providerDispatchWorker.ts +159 -0
- package/src/fulfillment/providerProductSyncWorker.ts +154 -0
- package/src/fulfillment/providerReconciliationError.ts +20 -0
- package/src/fulfillment/providerReconciliationTerminalSkip.ts +8 -0
- package/src/fulfillment/providerReconciliationTimestamp.ts +34 -0
- package/src/fulfillment/providerReconciliationWorker.ts +206 -0
- package/src/fulfillment/providerStockAvailability.ts +60 -0
- package/src/fulfillment/providerStockSyncWorker.ts +318 -0
- package/src/fulfillment/providerTrackingReferences.ts +32 -0
- package/src/fulfillment/replacementRefusals.ts +43 -0
- package/src/fulfillment/replacementShipmentHandler.ts +47 -0
- package/src/fulfillment/schemaCapabilities.ts +7 -0
- package/src/fulfillment/shipmentsOverviewHandler.ts +73 -0
- package/src/fulfillment/statusMap.ts +2 -0
- package/src/fulfillment/trackingProgress.ts +1 -0
- package/src/fulfillment/verifiedIngress.ts +113 -0
- package/src/invoicing/capabilities.ts +9 -0
- package/src/invoicing/contracts/capabilities.ts +15 -0
- package/src/invoicing/contracts/companyLookup.ts +13 -0
- package/src/invoicing/contracts/delivery.ts +24 -0
- package/src/invoicing/contracts/facts.ts +60 -0
- package/src/invoicing/contracts/host.ts +85 -0
- package/src/invoicing/contracts/index.ts +16 -0
- package/src/invoicing/contracts/provider.ts +78 -0
- package/src/invoicing/contracts/settlement.ts +39 -0
- package/src/invoicing/contracts/store.ts +98 -0
- package/src/invoicing/index.ts +1 -0
- package/src/payments/stripe/index.ts +30 -0
- package/src/payments/tpay/index.ts +36 -0
- package/src/subscriptions/automaticRenewal.ts +87 -0
- package/src/subscriptions/automaticRenewalExecution.ts +39 -0
- package/src/subscriptions/contracts/commands.ts +46 -0
- package/src/subscriptions/contracts/dunning.ts +48 -0
- package/src/subscriptions/contracts/index.ts +6 -0
- package/src/subscriptions/contracts/messages.ts +18 -0
- package/src/subscriptions/contracts/renewal.ts +325 -0
- package/src/subscriptions/contracts/stockWait.ts +34 -0
- package/src/subscriptions/index.ts +24 -0
- package/src/subscriptions/paymentOutcomes.ts +23 -0
- package/src/subscriptions/postgresRenewalStore.ts +76 -0
- package/src/subscriptions/postgresRetryStore.ts +174 -0
- package/src/subscriptions/renewalCycleFailureMechanism.ts +119 -0
- package/src/subscriptions/renewalCycleMechanism.ts +225 -0
- package/src/subscriptions/renewalCycleRefusalMechanism.ts +215 -0
- package/src/subscriptions/renewalIdentity.ts +5 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PAYMENT_INTENT_STATUSES } from '@openlup/core/payment';
|
|
3
|
+
const OMS_FULFILLMENT_BLOCK_REASONS = ['order_not_paid', 'payment_not_succeeded', 'subscription_cycle_not_paid', 'active_hold', 'missing_shipping_address', 'inventory_review', 'risk_review'];
|
|
4
|
+
const OMS_INVENTORY_STATUSES = ['not_checked', 'reserved', 'missing', 'released', 'expired', 'consumed', 'review_required'];
|
|
5
|
+
export const COMMERCE_FULFILLMENT_CONTRACT_VERSION = "commerce.fulfillment.v0";
|
|
6
|
+
export const COMMERCE_FULFILLMENT_STATUSES = [
|
|
7
|
+
"created",
|
|
8
|
+
"packed",
|
|
9
|
+
"label_pending",
|
|
10
|
+
"label_created",
|
|
11
|
+
"handed_over",
|
|
12
|
+
"in_transit",
|
|
13
|
+
"delivered",
|
|
14
|
+
"exception",
|
|
15
|
+
"cancelled",
|
|
16
|
+
];
|
|
17
|
+
export const COMMERCE_FULFILLMENT_OPERATION_TYPES = [
|
|
18
|
+
"created",
|
|
19
|
+
"packed",
|
|
20
|
+
"provider_attempt_recorded",
|
|
21
|
+
"label_created",
|
|
22
|
+
"handed_over",
|
|
23
|
+
"tracking_event_recorded",
|
|
24
|
+
"cancelled",
|
|
25
|
+
];
|
|
26
|
+
export const COMMERCE_FULFILLMENT_PROVIDER_ATTEMPT_STATUSES = [
|
|
27
|
+
"recorded",
|
|
28
|
+
"succeeded",
|
|
29
|
+
"failed",
|
|
30
|
+
];
|
|
31
|
+
const uuidSchema = z.guid();
|
|
32
|
+
const datetimeSchema = z.string().datetime({ offset: true });
|
|
33
|
+
export const commerceFulfillmentStatusSchema = z.enum(COMMERCE_FULFILLMENT_STATUSES);
|
|
34
|
+
export const commerceFulfillmentOperationTypeSchema = z.enum(COMMERCE_FULFILLMENT_OPERATION_TYPES);
|
|
35
|
+
export const commerceFulfillmentProviderAttemptStatusSchema = z.enum(COMMERCE_FULFILLMENT_PROVIDER_ATTEMPT_STATUSES);
|
|
36
|
+
export const commerceFulfillmentPaymentStatusSchema = z.enum(["not_started", ...PAYMENT_INTENT_STATUSES]);
|
|
37
|
+
export const commerceFulfillmentInventoryStatusSchema = z.enum(OMS_INVENTORY_STATUSES);
|
|
38
|
+
export const commerceFulfillmentBlockReasonSchema = z.enum(OMS_FULFILLMENT_BLOCK_REASONS);
|
|
39
|
+
export const commerceFulfillmentShippingAddressSnapshotSchema = z.object({
|
|
40
|
+
addressId: uuidSchema,
|
|
41
|
+
clientId: uuidSchema,
|
|
42
|
+
label: z.string().nullable(),
|
|
43
|
+
line1: z.string().trim().min(1),
|
|
44
|
+
line2: z.string().nullable(),
|
|
45
|
+
city: z.string().trim().min(1),
|
|
46
|
+
postalCode: z.string().trim().min(1),
|
|
47
|
+
country: z.string().trim().min(2).max(3),
|
|
48
|
+
}).strict();
|
|
49
|
+
export const commerceFulfillmentLineSchema = z.object({
|
|
50
|
+
id: uuidSchema.nullable(),
|
|
51
|
+
orderItemId: uuidSchema,
|
|
52
|
+
skuId: uuidSchema,
|
|
53
|
+
sku: z.string().trim().min(1),
|
|
54
|
+
title: z.string().trim().min(1).nullable(),
|
|
55
|
+
quantity: z.number().int().positive(),
|
|
56
|
+
inventoryReservationIds: z.array(uuidSchema),
|
|
57
|
+
productSnapshot: z.record(z.string(), z.unknown()),
|
|
58
|
+
}).strict();
|
|
59
|
+
export const commerceFulfillmentPaymentSummarySchema = z.object({
|
|
60
|
+
paymentIntentId: uuidSchema,
|
|
61
|
+
paymentStatus: commerceFulfillmentPaymentStatusSchema,
|
|
62
|
+
providerPaymentId: z.string().nullable(),
|
|
63
|
+
}).strict();
|
|
64
|
+
export const commerceFulfillmentInventorySummarySchema = z.object({
|
|
65
|
+
status: commerceFulfillmentInventoryStatusSchema,
|
|
66
|
+
reservationId: uuidSchema.nullable(),
|
|
67
|
+
reservationStatus: z.enum(["reserved", "released", "consumed", "expired"]).nullable(),
|
|
68
|
+
expiresAt: datetimeSchema.nullable(),
|
|
69
|
+
locationId: uuidSchema.nullable(),
|
|
70
|
+
locationCode: z.string().nullable(),
|
|
71
|
+
}).strict();
|
|
72
|
+
export const commerceFulfillmentOmsEligibilitySchema = z.object({
|
|
73
|
+
allowed: z.boolean(),
|
|
74
|
+
reason: commerceFulfillmentBlockReasonSchema.nullable(),
|
|
75
|
+
}).strict();
|
|
76
|
+
export const commerceFulfillmentOperationSchema = z.object({
|
|
77
|
+
id: uuidSchema,
|
|
78
|
+
type: commerceFulfillmentOperationTypeSchema,
|
|
79
|
+
occurredAt: datetimeSchema,
|
|
80
|
+
actorUserId: uuidSchema.nullable(),
|
|
81
|
+
payload: z.record(z.string(), z.unknown()),
|
|
82
|
+
}).strict();
|
|
83
|
+
export const commerceFulfillmentOrderSchema = z.object({
|
|
84
|
+
id: uuidSchema,
|
|
85
|
+
orderId: uuidSchema,
|
|
86
|
+
clientId: uuidSchema.nullable(),
|
|
87
|
+
status: commerceFulfillmentStatusSchema,
|
|
88
|
+
providerKind: z.string().trim().min(1).nullable(),
|
|
89
|
+
providerTrackingId: z.string().trim().min(1).nullable(),
|
|
90
|
+
shippingAddress: commerceFulfillmentShippingAddressSnapshotSchema,
|
|
91
|
+
lines: z.array(commerceFulfillmentLineSchema).min(1),
|
|
92
|
+
payment: commerceFulfillmentPaymentSummarySchema,
|
|
93
|
+
inventory: commerceFulfillmentInventorySummarySchema,
|
|
94
|
+
omsEligibility: commerceFulfillmentOmsEligibilitySchema,
|
|
95
|
+
latestOperation: commerceFulfillmentOperationSchema.nullable(),
|
|
96
|
+
createdAt: datetimeSchema,
|
|
97
|
+
updatedAt: datetimeSchema,
|
|
98
|
+
}).strict();
|
|
99
|
+
export const adminCommerceFulfillmentOrdersListRequestSchema = z.object({
|
|
100
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
101
|
+
pageSize: z.coerce.number().int().min(1).max(100).default(25),
|
|
102
|
+
status: commerceFulfillmentStatusSchema.optional(),
|
|
103
|
+
}).strict();
|
|
104
|
+
export const adminCommerceFulfillmentOrderDetailRequestSchema = z
|
|
105
|
+
.object({
|
|
106
|
+
fulfillmentOrderId: uuidSchema.optional(),
|
|
107
|
+
orderId: uuidSchema.optional(),
|
|
108
|
+
})
|
|
109
|
+
.strict()
|
|
110
|
+
.refine((request) => request.fulfillmentOrderId || request.orderId, {
|
|
111
|
+
message: "fulfillmentOrderId or orderId is required",
|
|
112
|
+
});
|
|
113
|
+
export const adminCommerceFulfillmentCreateRequestSchema = z.object({
|
|
114
|
+
idempotencyKey: z.string().trim().min(8).max(120),
|
|
115
|
+
orderId: uuidSchema,
|
|
116
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
117
|
+
}).strict();
|
|
118
|
+
export const adminCommerceFulfillmentRecordProviderAttemptRequestSchema = z.object({
|
|
119
|
+
idempotencyKey: z.string().trim().min(8).max(120),
|
|
120
|
+
fulfillmentOrderId: uuidSchema,
|
|
121
|
+
providerKind: z.string().trim().min(1),
|
|
122
|
+
status: commerceFulfillmentProviderAttemptStatusSchema,
|
|
123
|
+
requestPayload: z.record(z.string(), z.unknown()).default({}),
|
|
124
|
+
responsePayload: z.record(z.string(), z.unknown()).default({}),
|
|
125
|
+
error: z.string().trim().min(1).nullable().optional(),
|
|
126
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
127
|
+
}).strict();
|
|
128
|
+
export const adminCommerceFulfillmentRecordLabelRequestSchema = z.object({
|
|
129
|
+
idempotencyKey: z.string().trim().min(8).max(120),
|
|
130
|
+
fulfillmentOrderId: uuidSchema,
|
|
131
|
+
providerKind: z.string().trim().min(1),
|
|
132
|
+
providerTrackingId: z.string().trim().min(1),
|
|
133
|
+
labelUrl: z.string().trim().min(1).nullable().optional(),
|
|
134
|
+
deliveryEstimateDays: z.number().int().nonnegative().nullable().optional(),
|
|
135
|
+
rawProviderPayload: z.record(z.string(), z.unknown()).default({}),
|
|
136
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
137
|
+
}).strict();
|
|
138
|
+
export const adminCommerceFulfillmentHandOffRequestSchema = z.object({
|
|
139
|
+
idempotencyKey: z.string().trim().min(8).max(120),
|
|
140
|
+
fulfillmentOrderId: uuidSchema,
|
|
141
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
142
|
+
}).strict();
|
|
143
|
+
export const adminCommerceFulfillmentTrackingEventRequestSchema = z.object({
|
|
144
|
+
idempotencyKey: z.string().trim().min(8).max(120),
|
|
145
|
+
fulfillmentOrderId: uuidSchema,
|
|
146
|
+
status: z.enum(["in_transit", "delivered", "exception"]),
|
|
147
|
+
providerTrackingId: z.string().trim().min(1).optional(),
|
|
148
|
+
rawEvent: z.record(z.string(), z.unknown()).default({}),
|
|
149
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
150
|
+
}).strict();
|
|
151
|
+
export const adminCommerceFulfillmentCancelRequestSchema = z.object({
|
|
152
|
+
idempotencyKey: z.string().trim().min(8).max(120),
|
|
153
|
+
fulfillmentOrderId: uuidSchema,
|
|
154
|
+
reason: z.string().trim().min(1).max(240),
|
|
155
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
156
|
+
}).strict();
|
|
157
|
+
export const adminCommerceFulfillmentOrdersListResponseSchema = z.object({
|
|
158
|
+
contractVersion: z.literal(COMMERCE_FULFILLMENT_CONTRACT_VERSION),
|
|
159
|
+
orders: z.array(commerceFulfillmentOrderSchema),
|
|
160
|
+
totalCount: z.number().int().min(0),
|
|
161
|
+
page: z.number().int().min(1),
|
|
162
|
+
pageSize: z.number().int().min(1),
|
|
163
|
+
}).strict();
|
|
164
|
+
export const adminCommerceFulfillmentOrderDetailResponseSchema = z.object({
|
|
165
|
+
contractVersion: z.literal(COMMERCE_FULFILLMENT_CONTRACT_VERSION),
|
|
166
|
+
order: commerceFulfillmentOrderSchema,
|
|
167
|
+
}).strict();
|
|
168
|
+
export const adminCommerceFulfillmentMutationResponseSchema = z.object({
|
|
169
|
+
contractVersion: z.literal(COMMERCE_FULFILLMENT_CONTRACT_VERSION),
|
|
170
|
+
fulfillmentOrderId: uuidSchema,
|
|
171
|
+
orderId: uuidSchema,
|
|
172
|
+
status: commerceFulfillmentStatusSchema,
|
|
173
|
+
replayed: z.boolean(),
|
|
174
|
+
}).strict();
|
|
175
|
+
export const adminCommerceOrderRequestReplacementShipmentRequestSchema = z.object({
|
|
176
|
+
idempotencyKey: z.string().trim().min(8).max(120),
|
|
177
|
+
orderId: uuidSchema,
|
|
178
|
+
reason: z.enum(['damaged', 'lost', 'returned_undelivered', 'other']),
|
|
179
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
180
|
+
}).strict();
|
|
181
|
+
export const omsOperationTypeSchema = z.enum([
|
|
182
|
+
"hold_created",
|
|
183
|
+
"hold_released",
|
|
184
|
+
"fulfillment_reviewed",
|
|
185
|
+
"support_note",
|
|
186
|
+
"shipping_address_updated",
|
|
187
|
+
"order_marked_refunded",
|
|
188
|
+
"order_cancelled_manual",
|
|
189
|
+
"replacement_shipment_requested",
|
|
190
|
+
]);
|
|
191
|
+
export const omsOrderOperationSchema = z.object({
|
|
192
|
+
id: uuidSchema,
|
|
193
|
+
orderId: uuidSchema,
|
|
194
|
+
type: omsOperationTypeSchema,
|
|
195
|
+
holdId: uuidSchema.nullable(),
|
|
196
|
+
actorUserId: uuidSchema.nullable(),
|
|
197
|
+
occurredAt: datetimeSchema,
|
|
198
|
+
payload: z.record(z.string(), z.unknown()),
|
|
199
|
+
});
|
|
200
|
+
export const adminCommerceOrderRequestReplacementShipmentResponseSchema = z.object({
|
|
201
|
+
contractVersion: z.literal('commerce.v0'),
|
|
202
|
+
operation: omsOrderOperationSchema,
|
|
203
|
+
replacement: z.object({
|
|
204
|
+
fulfillmentOrderId: z.string().uuid(),
|
|
205
|
+
orderId: z.string().uuid(),
|
|
206
|
+
sequenceNo: z.number().int().min(1),
|
|
207
|
+
replacesFulfillmentOrderId: z.string().uuid(),
|
|
208
|
+
reason: z.enum(["damaged", "lost", "returned_undelivered", "other"]),
|
|
209
|
+
status: z.string(),
|
|
210
|
+
}),
|
|
211
|
+
releasedHoldIds: z.array(z.string().uuid()).default([]),
|
|
212
|
+
replayed: z.boolean(),
|
|
213
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FulfillmentNativeUnsupported } from './contracts/nativeUnsupported.js';
|
|
2
|
+
export interface FulfillmentHandlerRequest {
|
|
3
|
+
method?: string;
|
|
4
|
+
query: Record<string, string | string[] | undefined>;
|
|
5
|
+
body?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface FulfillmentHandlerResponder<Response> {
|
|
8
|
+
sendMethodNotAllowed(res: Response, methods: readonly string[]): void;
|
|
9
|
+
sendBffSuccess(res: Response, data: unknown): void;
|
|
10
|
+
sendBffError(res: Response, code: 'UNAUTHORIZED' | 'FORBIDDEN' | 'BAD_REQUEST' | 'INVALID_RESPONSE' | 'NOT_FOUND' | 'CONFLICT' | 'UPSTREAM_UNAVAILABLE', message: string, options?: {
|
|
11
|
+
details: unknown;
|
|
12
|
+
}): void;
|
|
13
|
+
}
|
|
14
|
+
export type AdminAuthResult = {
|
|
15
|
+
ok: false;
|
|
16
|
+
code: 'UNAUTHORIZED' | 'FORBIDDEN';
|
|
17
|
+
message: string;
|
|
18
|
+
} | {
|
|
19
|
+
ok: true;
|
|
20
|
+
userId: string;
|
|
21
|
+
};
|
|
22
|
+
export interface BaseDeps<Response> {
|
|
23
|
+
authorizeAdmin(req: FulfillmentHandlerRequest): Promise<AdminAuthResult>;
|
|
24
|
+
respond: FulfillmentHandlerResponder<Response>;
|
|
25
|
+
}
|
|
26
|
+
export declare function isNativeUnsupported(value: unknown): value is FulfillmentNativeUnsupported;
|
|
27
|
+
export declare class CommerceFulfillmentConflictError extends Error {
|
|
28
|
+
readonly details: Record<string, unknown>;
|
|
29
|
+
constructor(message?: string, details?: Record<string, unknown>);
|
|
30
|
+
}
|
|
31
|
+
export declare function authorize<Response>(req: FulfillmentHandlerRequest, res: Response, authorizeAdmin: BaseDeps<Response>['authorizeAdmin'], respond: FulfillmentHandlerResponder<Response>): Promise<{
|
|
32
|
+
userId: string;
|
|
33
|
+
} | null>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function isNativeUnsupported(value) {
|
|
2
|
+
return typeof value === 'object' && value !== null && 'kind' in value && value.kind === 'native_unsupported';
|
|
3
|
+
}
|
|
4
|
+
export class CommerceFulfillmentConflictError extends Error {
|
|
5
|
+
details;
|
|
6
|
+
constructor(message = 'Commerce fulfillment conflict', details = {}) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.details = details;
|
|
9
|
+
this.name = 'CommerceFulfillmentConflictError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export async function authorize(req, res, authorizeAdmin, respond) {
|
|
13
|
+
try {
|
|
14
|
+
const authorization = await authorizeAdmin(req);
|
|
15
|
+
if (authorization.ok === false) {
|
|
16
|
+
respond.sendBffError(res, authorization.code, authorization.message);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return { userId: authorization.userId };
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
respond.sendBffError(res, 'UPSTREAM_UNAVAILABLE', 'Admin authorization failed');
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { FULFILLMENT_STATUS_MAP, CANONICAL_LOCAL_FULFILLMENT_STATUSES, CUSTOMER_STEP_SEQUENCE, canonicalStatusToken, stepForToken, customerStepFromSignals, phaseIndexForStep, stepLabelKey, timelineLabelForStep, trackingPhaseKeyForStep, stepUsesTruckIcon } from "./statusMap.js";
|
|
2
|
+
export { parseFulfillmentFact, parseFulfillmentTransitionConflict } from "./normalizedFulfillmentFacts.js";
|
|
3
|
+
export { readFulfillmentCapabilities } from "./providerCapabilities.js";
|
|
4
|
+
export { createOutboxOrderPaidFulfillmentHandler } from "./paidHandoff.js";
|
|
5
|
+
export { collectPaidFulfillmentRecoveryCandidates } from "./paidFulfillmentRecovery.js";
|
|
6
|
+
export { runFulfillmentDispatchWorker } from "./providerDispatchWorker.js";
|
|
7
|
+
export { createFulfillmentCommandLedger } from "./providerCommandLedger.js";
|
|
8
|
+
export type { FulfillmentIngressCounts, FulfillmentIngressResult } from "./verifiedIngress.js";
|
|
9
|
+
export { verifyAndNormalizeFulfillmentObservation, fulfillmentIngressHttpResult } from "./verifiedIngress.js";
|
|
10
|
+
export { applyFulfillmentObservationEffects } from "./fulfillmentObservationEffects.js";
|
|
11
|
+
export { reconcileFulfillmentObservations, runFulfillmentReconciliationPage } from "./providerReconciliationWorker.js";
|
|
12
|
+
export { runFulfillmentStockSyncWorker } from "./providerStockSyncWorker.js";
|
|
13
|
+
export { runFulfillmentProductSyncWorker } from "./providerProductSyncWorker.js";
|
|
14
|
+
export { createFulfillmentLowStockEvidenceHandler } from "./lowStockEvidenceHandler.js";
|
|
15
|
+
export { createProductReconciliationEvidenceHandler } from "./productReconciliationEvidenceHandler.js";
|
|
16
|
+
export { runFulfillmentAdapterConformance } from "./adapterConformance.js";
|
|
17
|
+
export { createPostgresFulfillmentShipmentSpinePort } from './postgresShipmentSpine.js';
|
|
18
|
+
export { createPostgresFulfillmentLowStockEvidencePort } from './postgresEvidenceReadPort.js';
|
|
19
|
+
export { createPostgresFulfillmentStockSyncPort } from './postgresStockSyncPort.js';
|
|
20
|
+
export { createPostgresPaidFulfillmentRecoveryOpsPort } from './postgresPaidFulfillmentRecovery.js';
|
|
21
|
+
export { createPostgresFulfillmentDispatchStore } from './postgresDispatchStore.js';
|
|
22
|
+
export { createPostgresPaidFulfillmentHandoffStore } from './postgresPaidHandoffStore.js';
|
|
23
|
+
export { createPostgresDeliveryAlignmentPort } from './postgresDeliveryAlignment.js';
|
|
24
|
+
export { readDeliveryAlignment } from './deliveryAlignmentReadModel.js';
|
|
25
|
+
export { FULFILLMENT_NATIVE_CAPABILITIES } from './schemaCapabilities.js';
|
|
26
|
+
export { FULFILLMENT_MIGRATIONS } from './migrations.js';
|
|
27
|
+
export { createAdminCommerceFulfillmentOrdersListHandler, createAdminCommerceFulfillmentOrderDetailHandler, createAdminCommerceFulfillmentCreateOrderHandler, createAdminCommerceFulfillmentRecordProviderAttemptHandler, createAdminCommerceFulfillmentRecordLabelHandler, createAdminCommerceFulfillmentHandOffHandler, createAdminCommerceFulfillmentTrackingEventHandler, createAdminCommerceFulfillmentCancelOrderHandler } from './commerceFulfillmentHandlers.js';
|
|
28
|
+
export { createAdminCommerceOrderRequestReplacementShipmentHandler } from './replacementShipmentHandler.js';
|
|
29
|
+
export { CommerceFulfillmentConflictError } from './handlerSupport.js';
|
|
30
|
+
export { readFulfillmentDelay } from './delayReadModel.js';
|
|
31
|
+
export { readFulfillmentLabel, cleanupFulfillmentLabel } from './labelLifecycle.js';
|
|
32
|
+
export { currentParcel, currentParcelFor, currentParcelPerOrder, currentParcelFirst, belongsToParcel, rowsForParcel, parcelSequenceNo, compareParcelPrecedence } from './currentFulfillmentParcel.js';
|
|
33
|
+
export { FULFILLMENT_NATIVE_UNSUPPORTED, createNativeUnsupportedFulfillmentPorts } from './nativeUnsupported.js';
|
|
34
|
+
export { FULFILLMENT_REPLACEMENT_REFUSALS } from './replacementRefusals.js';
|
|
35
|
+
export { buildCommerceFulfillmentOrdersListResponse, buildCommerceFulfillmentOrderDetailResponse } from './commerceFulfillmentReadModel.js';
|
|
36
|
+
export { createFulfillmentShipmentsOverviewHandler } from './shipmentsOverviewHandler.js';
|
|
37
|
+
export { fulfillmentProgressPresentation } from './trackingProgress.js';
|
|
38
|
+
export { createFulfillmentServices } from './bindings.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export { FULFILLMENT_STATUS_MAP, CANONICAL_LOCAL_FULFILLMENT_STATUSES, CUSTOMER_STEP_SEQUENCE, canonicalStatusToken, stepForToken, customerStepFromSignals, phaseIndexForStep, stepLabelKey, timelineLabelForStep, trackingPhaseKeyForStep, stepUsesTruckIcon } from "./statusMap.js";
|
|
2
|
+
export { parseFulfillmentFact, parseFulfillmentTransitionConflict } from "./normalizedFulfillmentFacts.js";
|
|
3
|
+
export { readFulfillmentCapabilities } from "./providerCapabilities.js";
|
|
4
|
+
export { createOutboxOrderPaidFulfillmentHandler } from "./paidHandoff.js";
|
|
5
|
+
export { collectPaidFulfillmentRecoveryCandidates } from "./paidFulfillmentRecovery.js";
|
|
6
|
+
export { runFulfillmentDispatchWorker } from "./providerDispatchWorker.js";
|
|
7
|
+
export { createFulfillmentCommandLedger } from "./providerCommandLedger.js";
|
|
8
|
+
export { verifyAndNormalizeFulfillmentObservation, fulfillmentIngressHttpResult } from "./verifiedIngress.js";
|
|
9
|
+
export { applyFulfillmentObservationEffects } from "./fulfillmentObservationEffects.js";
|
|
10
|
+
export { reconcileFulfillmentObservations, runFulfillmentReconciliationPage } from "./providerReconciliationWorker.js";
|
|
11
|
+
export { runFulfillmentStockSyncWorker } from "./providerStockSyncWorker.js";
|
|
12
|
+
export { runFulfillmentProductSyncWorker } from "./providerProductSyncWorker.js";
|
|
13
|
+
export { createFulfillmentLowStockEvidenceHandler } from "./lowStockEvidenceHandler.js";
|
|
14
|
+
export { createProductReconciliationEvidenceHandler } from "./productReconciliationEvidenceHandler.js";
|
|
15
|
+
export { runFulfillmentAdapterConformance } from "./adapterConformance.js";
|
|
16
|
+
export { createPostgresFulfillmentShipmentSpinePort } from './postgresShipmentSpine.js';
|
|
17
|
+
export { createPostgresFulfillmentLowStockEvidencePort } from './postgresEvidenceReadPort.js';
|
|
18
|
+
export { createPostgresFulfillmentStockSyncPort } from './postgresStockSyncPort.js';
|
|
19
|
+
export { createPostgresPaidFulfillmentRecoveryOpsPort } from './postgresPaidFulfillmentRecovery.js';
|
|
20
|
+
export { createPostgresFulfillmentDispatchStore } from './postgresDispatchStore.js';
|
|
21
|
+
export { createPostgresPaidFulfillmentHandoffStore } from './postgresPaidHandoffStore.js';
|
|
22
|
+
export { createPostgresDeliveryAlignmentPort } from './postgresDeliveryAlignment.js';
|
|
23
|
+
export { readDeliveryAlignment } from './deliveryAlignmentReadModel.js';
|
|
24
|
+
export { FULFILLMENT_NATIVE_CAPABILITIES } from './schemaCapabilities.js';
|
|
25
|
+
export { FULFILLMENT_MIGRATIONS } from './migrations.js';
|
|
26
|
+
export { createAdminCommerceFulfillmentOrdersListHandler, createAdminCommerceFulfillmentOrderDetailHandler, createAdminCommerceFulfillmentCreateOrderHandler, createAdminCommerceFulfillmentRecordProviderAttemptHandler, createAdminCommerceFulfillmentRecordLabelHandler, createAdminCommerceFulfillmentHandOffHandler, createAdminCommerceFulfillmentTrackingEventHandler, createAdminCommerceFulfillmentCancelOrderHandler } from './commerceFulfillmentHandlers.js';
|
|
27
|
+
export { createAdminCommerceOrderRequestReplacementShipmentHandler } from './replacementShipmentHandler.js';
|
|
28
|
+
export { CommerceFulfillmentConflictError } from './handlerSupport.js';
|
|
29
|
+
export { readFulfillmentDelay } from './delayReadModel.js';
|
|
30
|
+
export { readFulfillmentLabel, cleanupFulfillmentLabel } from './labelLifecycle.js';
|
|
31
|
+
export { currentParcel, currentParcelFor, currentParcelPerOrder, currentParcelFirst, belongsToParcel, rowsForParcel, parcelSequenceNo, compareParcelPrecedence } from './currentFulfillmentParcel.js';
|
|
32
|
+
export { FULFILLMENT_NATIVE_UNSUPPORTED, createNativeUnsupportedFulfillmentPorts } from './nativeUnsupported.js';
|
|
33
|
+
export { FULFILLMENT_REPLACEMENT_REFUSALS } from './replacementRefusals.js';
|
|
34
|
+
export { buildCommerceFulfillmentOrdersListResponse, buildCommerceFulfillmentOrderDetailResponse } from './commerceFulfillmentReadModel.js';
|
|
35
|
+
export { createFulfillmentShipmentsOverviewHandler } from './shipmentsOverviewHandler.js';
|
|
36
|
+
export { fulfillmentProgressPresentation } from './trackingProgress.js';
|
|
37
|
+
export { createFulfillmentServices } from './bindings.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FulfillmentLabelPort, LabelDocument } from './contracts/label.js';
|
|
2
|
+
/** Storage-only read: a missing cached label never proves the parcel absent. Signed URLs are transient. */
|
|
3
|
+
export declare function readFulfillmentLabel(port: Pick<FulfillmentLabelPort, 'read'>, document: LabelDocument | null): Promise<{
|
|
4
|
+
kind: "available";
|
|
5
|
+
url: string;
|
|
6
|
+
expiresAt: string | null;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "refused";
|
|
9
|
+
refusal: import("./contracts/dispatch.js").FulfillmentRefusal;
|
|
10
|
+
}>;
|
|
11
|
+
/** Provider and storage deletion remain host-owned; canProceed never asserts either deletion. */
|
|
12
|
+
type LabelCleanupInput = Parameters<FulfillmentLabelPort['void']>[0] & {
|
|
13
|
+
actorUserId: string;
|
|
14
|
+
idempotencyKey: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function cleanupFulfillmentLabel(port: {
|
|
17
|
+
void(input: LabelCleanupInput): ReturnType<FulfillmentLabelPort['void']>;
|
|
18
|
+
}, input: LabelCleanupInput): Promise<{
|
|
19
|
+
providerDeletion: "confirmed" | "unconfirmed";
|
|
20
|
+
labelDeleted: boolean;
|
|
21
|
+
canProceed: boolean;
|
|
22
|
+
refusal?: import("./contracts/dispatch.js").FulfillmentRefusal;
|
|
23
|
+
}>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Storage-only read: a missing cached label never proves the parcel absent. Signed URLs are transient. */
|
|
2
|
+
export async function readFulfillmentLabel(port, document) {
|
|
3
|
+
if (!document)
|
|
4
|
+
return { kind: 'refused', refusal: { reason: 'local_missing', phase: 'readback', retryable: false } };
|
|
5
|
+
return port.read(document);
|
|
6
|
+
}
|
|
7
|
+
export async function cleanupFulfillmentLabel(port, input) {
|
|
8
|
+
return port.void(input);
|
|
9
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Read-only evidence boundary; parsing remains with the owning host schema. */
|
|
2
|
+
export declare function createFulfillmentLowStockEvidenceHandler<Request extends {
|
|
3
|
+
method?: string;
|
|
4
|
+
query: Record<string, string | string[] | undefined>;
|
|
5
|
+
}, Response, Query, Result>({ evidencePort, authorizeAdmin, requestSchema, responseSchema, respond }: {
|
|
6
|
+
evidencePort: {
|
|
7
|
+
getLowStockEvidence(query: Query): Promise<unknown>;
|
|
8
|
+
};
|
|
9
|
+
authorizeAdmin(request: Request): Promise<boolean>;
|
|
10
|
+
requestSchema: {
|
|
11
|
+
safeParse(input: unknown): {
|
|
12
|
+
success: true;
|
|
13
|
+
data: Query;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
error: {
|
|
17
|
+
flatten(): unknown;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
responseSchema: {
|
|
22
|
+
safeParse(input: unknown): {
|
|
23
|
+
success: true;
|
|
24
|
+
data: Result;
|
|
25
|
+
} | {
|
|
26
|
+
success: false;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
respond: {
|
|
30
|
+
sendBffError(res: Response, code: "UPSTREAM_UNAVAILABLE" | "UNAUTHORIZED" | "BAD_REQUEST" | "INVALID_RESPONSE", message: string, options?: {
|
|
31
|
+
details: unknown;
|
|
32
|
+
}): void;
|
|
33
|
+
sendBffSuccess(res: Response, data: Result): void;
|
|
34
|
+
sendMethodNotAllowed(res: Response, methods: readonly string[]): void;
|
|
35
|
+
};
|
|
36
|
+
}): (req: Request, res: Response) => Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Read-only evidence boundary; parsing remains with the owning host schema. */
|
|
2
|
+
export function createFulfillmentLowStockEvidenceHandler({ evidencePort, authorizeAdmin, requestSchema, responseSchema, respond }) {
|
|
3
|
+
const { sendBffError, sendBffSuccess, sendMethodNotAllowed } = respond;
|
|
4
|
+
return async function handler(req, res) {
|
|
5
|
+
if (req.method !== "GET") {
|
|
6
|
+
sendMethodNotAllowed(res, ["GET"]);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
let authorized = false;
|
|
10
|
+
try {
|
|
11
|
+
authorized = await authorizeAdmin(req);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
sendBffError(res, "UPSTREAM_UNAVAILABLE", "Admin authorization failed");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!authorized) {
|
|
18
|
+
sendBffError(res, "UNAUTHORIZED", "Admin session required");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const request = requestSchema.safeParse({
|
|
22
|
+
statusFilter: scalarQuery(req.query.statusFilter),
|
|
23
|
+
});
|
|
24
|
+
if (!request.success) {
|
|
25
|
+
sendBffError(res, "BAD_REQUEST", "Invalid low-stock evidence request", {
|
|
26
|
+
details: request.error.flatten(),
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const result = await evidencePort.getLowStockEvidence(request.data);
|
|
32
|
+
const response = responseSchema.safeParse(result);
|
|
33
|
+
if (!response.success) {
|
|
34
|
+
sendBffError(res, "INVALID_RESPONSE", "Low-stock evidence returned invalid response");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
sendBffSuccess(res, response.data);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
sendBffError(res, "UPSTREAM_UNAVAILABLE", "Low-stock evidence read failed");
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function scalarQuery(value) {
|
|
45
|
+
return Array.isArray(value) ? value[0] : value;
|
|
46
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Byte-identical sparse projections; install the complete canonical catalogue. */
|
|
2
|
+
export declare const FULFILLMENT_MIGRATIONS: readonly [{
|
|
3
|
+
readonly position: 5;
|
|
4
|
+
readonly catalogPath: "db/platform/migrations/20260808210000_fulfillment_shipment_rail.sql";
|
|
5
|
+
readonly sha256: "eb5824551903717f3868690909fcc2cb6a7f845abe5cb19bd4cff13103b1383d";
|
|
6
|
+
readonly url: URL;
|
|
7
|
+
}, {
|
|
8
|
+
readonly position: 27;
|
|
9
|
+
readonly catalogPath: "db/platform/migrations/20260814000000_fulfillment_stock_evidence.sql";
|
|
10
|
+
readonly sha256: "df20c2491cb0196b4e28d19e7578c95bfa5c87b8f89fb0b6284c0e0695a3cc1d";
|
|
11
|
+
readonly url: URL;
|
|
12
|
+
}, {
|
|
13
|
+
readonly position: 51;
|
|
14
|
+
readonly catalogPath: "db/platform/migrations/20260819150000_fulfillment_shipment_sequence.sql";
|
|
15
|
+
readonly sha256: "906706cf66a6a555aa1219b12eb674d937eaa099abde6da18766310af43aaa9f";
|
|
16
|
+
readonly url: URL;
|
|
17
|
+
}, {
|
|
18
|
+
readonly position: 73;
|
|
19
|
+
readonly catalogPath: "db/platform/migrations/20261022080000_fulfillment_command_ledger.sql";
|
|
20
|
+
readonly sha256: "c6806906cdb0b6931b29f7a5c7c800016e98d04e6ea956f3c1e219a6cdb7e9d1";
|
|
21
|
+
readonly url: URL;
|
|
22
|
+
}, {
|
|
23
|
+
readonly position: 74;
|
|
24
|
+
readonly catalogPath: "db/platform/migrations/20261022090000_fulfillment_delivery_alignment.sql";
|
|
25
|
+
readonly sha256: "d9966ae79fe77a0feae8317dc5b46ef2d8196dd0790b1cd0ee1b06ab58061499";
|
|
26
|
+
readonly url: URL;
|
|
27
|
+
}, {
|
|
28
|
+
readonly position: 76;
|
|
29
|
+
readonly catalogPath: "db/platform/migrations/20261022165000_fulfillment_stock_evidence_replay_reopen.sql";
|
|
30
|
+
readonly sha256: "6d132dec2820047f4e337bcf752b3d884600ccc12de03887fe6d6aa5575bc1db";
|
|
31
|
+
readonly url: URL;
|
|
32
|
+
}];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Byte-identical sparse projections; install the complete canonical catalogue. */
|
|
2
|
+
export const FULFILLMENT_MIGRATIONS = [
|
|
3
|
+
{ position: 5, catalogPath: "db/platform/migrations/20260808210000_fulfillment_shipment_rail.sql", sha256: "eb5824551903717f3868690909fcc2cb6a7f845abe5cb19bd4cff13103b1383d", url: new URL("../../sql/20260808210000_fulfillment_shipment_rail.sql", import.meta.url) },
|
|
4
|
+
{ position: 27, catalogPath: "db/platform/migrations/20260814000000_fulfillment_stock_evidence.sql", sha256: "df20c2491cb0196b4e28d19e7578c95bfa5c87b8f89fb0b6284c0e0695a3cc1d", url: new URL("../../sql/20260814000000_fulfillment_stock_evidence.sql", import.meta.url) },
|
|
5
|
+
{ position: 51, catalogPath: "db/platform/migrations/20260819150000_fulfillment_shipment_sequence.sql", sha256: "906706cf66a6a555aa1219b12eb674d937eaa099abde6da18766310af43aaa9f", url: new URL("../../sql/20260819150000_fulfillment_shipment_sequence.sql", import.meta.url) },
|
|
6
|
+
{ position: 73, catalogPath: "db/platform/migrations/20261022080000_fulfillment_command_ledger.sql", sha256: "c6806906cdb0b6931b29f7a5c7c800016e98d04e6ea956f3c1e219a6cdb7e9d1", url: new URL("../../sql/20261022080000_fulfillment_command_ledger.sql", import.meta.url) },
|
|
7
|
+
{ position: 74, catalogPath: "db/platform/migrations/20261022090000_fulfillment_delivery_alignment.sql", sha256: "d9966ae79fe77a0feae8317dc5b46ef2d8196dd0790b1cd0ee1b06ab58061499", url: new URL("../../sql/20261022090000_fulfillment_delivery_alignment.sql", import.meta.url) },
|
|
8
|
+
{ position: 76, catalogPath: "db/platform/migrations/20261022165000_fulfillment_stock_evidence_replay_reopen.sql", sha256: "6d132dec2820047f4e337bcf752b3d884600ccc12de03887fe6d6aa5575bc1db", url: new URL("../../sql/20261022165000_fulfillment_stock_evidence_replay_reopen.sql", import.meta.url) },
|
|
9
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FulfillmentCommerceReadPort, FulfillmentShipmentsOverviewPort } from './contracts/read.js';
|
|
2
|
+
import type { FulfillmentNativeUnsupported } from './contracts/nativeUnsupported.js';
|
|
3
|
+
import type { FulfillmentReplacementPort } from './contracts/replacement.js';
|
|
4
|
+
import type { FulfillmentOperatorMutationPort } from './contracts/operator.js';
|
|
5
|
+
import type { FulfillmentCustomerAlignmentRowsReader } from './contracts/customerAlignment.js';
|
|
6
|
+
export declare const FULFILLMENT_NATIVE_UNSUPPORTED: FulfillmentNativeUnsupported;
|
|
7
|
+
/** Deliberately has no executor: unsupported native parity can never make a partial write. */
|
|
8
|
+
export declare function createNativeUnsupportedFulfillmentPorts(): FulfillmentReplacementPort & FulfillmentOperatorMutationPort & FulfillmentCommerceReadPort & FulfillmentShipmentsOverviewPort & {
|
|
9
|
+
readCustomerAlignmentRows: FulfillmentCustomerAlignmentRowsReader;
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const FULFILLMENT_NATIVE_UNSUPPORTED = Object.freeze({ kind: 'native_unsupported', reason: 'host_binding_required', retryable: false });
|
|
2
|
+
/** Deliberately has no executor: unsupported native parity can never make a partial write. */
|
|
3
|
+
export function createNativeUnsupportedFulfillmentPorts() {
|
|
4
|
+
const unsupported = async () => FULFILLMENT_NATIVE_UNSUPPORTED;
|
|
5
|
+
return {
|
|
6
|
+
requestReplacementShipment: unsupported,
|
|
7
|
+
createCommerceFulfillmentOrder: unsupported,
|
|
8
|
+
recordCommerceFulfillmentProviderAttempt: unsupported,
|
|
9
|
+
recordCommerceFulfillmentLabel: unsupported,
|
|
10
|
+
handOffCommerceFulfillmentOrder: unsupported,
|
|
11
|
+
recordCommerceFulfillmentTrackingEvent: unsupported,
|
|
12
|
+
cancelCommerceFulfillmentOrder: unsupported,
|
|
13
|
+
readCustomerAlignmentRows: unsupported,
|
|
14
|
+
listCommerceFulfillmentOrders: unsupported,
|
|
15
|
+
getCommerceFulfillmentOrderDetail: unsupported,
|
|
16
|
+
getShipmentsOverview: unsupported,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { isCanonicalLocalFulfillmentStatus, parseFulfillmentFact, parseFulfillmentTransitionConflict } from "@openlup/core/fulfillment";
|
|
2
|
+
export type { CanonicalNormalizedFulfillmentFact as NormalizedFulfillmentFact, CanonicalNormalizedFulfillmentFactV1 as NormalizedFulfillmentFactV1, CanonicalNormalizedFulfillmentFactV0 as NormalizedFulfillmentFactV0, CanonicalCompatibleNormalizedFulfillmentFact as CompatibleNormalizedFulfillmentFact, CanonicalFulfillmentTransitionSnapshot as FulfillmentTransitionSnapshot, CanonicalTransitionConflict as TransitionConflict } from "@openlup/core/fulfillment";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isCanonicalLocalFulfillmentStatus, parseFulfillmentFact, parseFulfillmentTransitionConflict } from "@openlup/core/fulfillment";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CanonicalLocalFulfillmentStatus, FulfillmentObservation, FulfillmentObservationCodecs } from "./contracts/index.js";
|
|
2
|
+
export declare function projectCorrelation(value: FulfillmentObservation["correlation"], privacy?: {
|
|
3
|
+
token(value: string | null | undefined, codec?: (value: string) => string | null): string | null;
|
|
4
|
+
readonly redactedFieldCount: number;
|
|
5
|
+
}, codecs?: FulfillmentObservationCodecs): FulfillmentObservation["correlation"];
|
|
6
|
+
export declare function projectProviderStatus(value: NonNullable<FulfillmentObservation["providerStatus"]>, privacy?: {
|
|
7
|
+
token(value: string | null | undefined, codec?: (value: string) => string | null): string | null;
|
|
8
|
+
readonly redactedFieldCount: number;
|
|
9
|
+
}): NonNullable<FulfillmentObservation["providerStatus"]>;
|
|
10
|
+
export type PollEvidence = Pick<FulfillmentObservation, "correlation" | "eventKey" | "providerStatus" | "diagnostics">;
|
|
11
|
+
/** Unknown-status quarantine/ACK evidence has the same privacy boundary as observations. */
|
|
12
|
+
export declare function projectPollEvidence(value: PollEvidence): PollEvidence;
|
|
13
|
+
/** One URL policy: strict default, optional adopter codec, and approval at every sink. */
|
|
14
|
+
export declare function publicTrackingUrl(value: string, approve?: (url: string) => boolean, codec?: (url: string) => string | null): string | null;
|
|
15
|
+
export declare function projectTrackingReference(value: FulfillmentObservation["trackingRefs"][number], privacy?: {
|
|
16
|
+
token(value: string | null | undefined, codec?: (value: string) => string | null): string | null;
|
|
17
|
+
readonly redactedFieldCount: number;
|
|
18
|
+
}, approveTrackingUrl?: (url: string) => boolean, codecs?: FulfillmentObservationCodecs): {
|
|
19
|
+
trackingNumber: string;
|
|
20
|
+
carrierRef: string | null;
|
|
21
|
+
serviceRef: string | null;
|
|
22
|
+
publicUrl: string | null;
|
|
23
|
+
} | null;
|
|
24
|
+
/** New boundary projection: arbitrary adapter properties are never durable. */
|
|
25
|
+
export declare function projectObservation(value: FulfillmentObservation, approveTrackingUrl?: (url: string) => boolean, codecs?: FulfillmentObservationCodecs): FulfillmentObservation;
|
|
26
|
+
/** Donor finished-picking boundary is narrower than the coarse packing stage. */
|
|
27
|
+
export declare const observationStatusPolicy: {
|
|
28
|
+
consumesStock: (status: CanonicalLocalFulfillmentStatus) => boolean;
|
|
29
|
+
handsOver: (status: CanonicalLocalFulfillmentStatus) => boolean;
|
|
30
|
+
suppressDispatched: (status: CanonicalLocalFulfillmentStatus) => status is "delivered";
|
|
31
|
+
trackingStatus: (status: CanonicalLocalFulfillmentStatus) => "in_transit" | "delivered";
|
|
32
|
+
};
|