@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,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { parseFulfillmentFact } from "./normalizedFulfillmentFacts.js";
|
|
3
|
+
import { admittedReference, durableStrings, reference } from "./dispatchProjection.js";
|
|
4
|
+
import { FULFILLMENT_STATUS_MAP } from "./statusMap.js";
|
|
5
|
+
const timestamp = z.iso.datetime({ offset: true });
|
|
6
|
+
export function projectCorrelation(value, privacy = durableStrings(), codecs = {}) {
|
|
7
|
+
const token = (value) => privacy.token(value, text => admittedReference(text, codecs.approveReference));
|
|
8
|
+
return { orderRef: value.orderRef, fulfillmentRef: value.fulfillmentRef, externalRef: token(value.externalRef),
|
|
9
|
+
orderNumber: token(value.orderNumber), providerFulfillmentRef: token(value.providerFulfillmentRef), parcelRef: value.parcelRef };
|
|
10
|
+
}
|
|
11
|
+
export function projectProviderStatus(value, privacy = durableStrings()) {
|
|
12
|
+
return { primary: privacy.token(value.primary), subStatus: privacy.token(value.subStatus) };
|
|
13
|
+
}
|
|
14
|
+
function pollEvidence(value, privacy, codecs = {}) {
|
|
15
|
+
// Host identities and keys composed from admitted parts are already authoritative.
|
|
16
|
+
return { eventKey: value.eventKey, correlation: projectCorrelation(value.correlation, privacy, codecs),
|
|
17
|
+
...(value.providerStatus ? { providerStatus: projectProviderStatus(value.providerStatus, privacy) } : {}) };
|
|
18
|
+
}
|
|
19
|
+
/** Unknown-status quarantine/ACK evidence has the same privacy boundary as observations. */
|
|
20
|
+
export function projectPollEvidence(value) {
|
|
21
|
+
const privacy = durableStrings(value.diagnostics?.redactedFieldCount);
|
|
22
|
+
const safe = pollEvidence(value, privacy);
|
|
23
|
+
return { ...safe, ...(privacy.redactedFieldCount ? { diagnostics: { redactedFieldCount: privacy.redactedFieldCount } } : {}) };
|
|
24
|
+
}
|
|
25
|
+
/** One URL policy: strict default, optional adopter codec, and approval at every sink. */
|
|
26
|
+
export function publicTrackingUrl(value, approve, codec) {
|
|
27
|
+
try {
|
|
28
|
+
const candidate = codec ? codec(value) : value;
|
|
29
|
+
if (!candidate)
|
|
30
|
+
return null;
|
|
31
|
+
const url = new URL(candidate);
|
|
32
|
+
return url.protocol === "https:" && !url.username && !url.password && (codec || (!url.search && !url.hash)) && approve?.(url.href) ? url.href : null;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function projectTrackingReference(value, privacy = durableStrings(), approveTrackingUrl, codecs = {}) {
|
|
39
|
+
const token = (value) => privacy.token(value, text => admittedReference(text, codecs.approveReference));
|
|
40
|
+
const trackingNumber = token(value.trackingNumber);
|
|
41
|
+
if (trackingNumber === null)
|
|
42
|
+
return null;
|
|
43
|
+
const serviceRef = token(value.serviceRef);
|
|
44
|
+
// Even an opaque-looking derived carrier is unsafe when its service was refused.
|
|
45
|
+
const carrierRef = privacy.token(value.carrierRef, text => value.serviceRef !== null && serviceRef === null ? null : reference(text));
|
|
46
|
+
return { trackingNumber, carrierRef, serviceRef,
|
|
47
|
+
publicUrl: privacy.token(value.publicUrl, url => publicTrackingUrl(url, approveTrackingUrl, codecs.trackingUrl)) };
|
|
48
|
+
}
|
|
49
|
+
/** New boundary projection: arbitrary adapter properties are never durable. */
|
|
50
|
+
export function projectObservation(value, approveTrackingUrl, codecs = {}) {
|
|
51
|
+
const privacy = durableStrings(value.diagnostics?.redactedFieldCount), token = privacy.token;
|
|
52
|
+
const diagnostics = {};
|
|
53
|
+
if (value.diagnostics?.admission) {
|
|
54
|
+
const count = (value) => Number.isSafeInteger(value) && value > 0 ? value : 0;
|
|
55
|
+
diagnostics.admission = { rejectedTrackingRefs: count(value.diagnostics.admission.rejectedTrackingRefs), rejectedTrackingUrls: count(value.diagnostics.admission.rejectedTrackingUrls) };
|
|
56
|
+
}
|
|
57
|
+
if (value.diagnostics?.refusal) {
|
|
58
|
+
const { reason, phase, retryable } = value.diagnostics.refusal;
|
|
59
|
+
diagnostics.refusal = { reason: token(reason), phase: token(phase), retryable };
|
|
60
|
+
}
|
|
61
|
+
if (value.diagnostics?.stockContention)
|
|
62
|
+
diagnostics.stockContention = { sqlState: "55P03", phase: "provider_stock_consumed", retryable: true };
|
|
63
|
+
if (value.diagnostics?.annotation)
|
|
64
|
+
diagnostics.annotation = token(value.diagnostics.annotation);
|
|
65
|
+
if (value.diagnostics?.recoveredPickedReceipt) {
|
|
66
|
+
const { receiptRef, closed } = value.diagnostics.recoveredPickedReceipt;
|
|
67
|
+
diagnostics.recoveredPickedReceipt = { receiptRef, closed };
|
|
68
|
+
}
|
|
69
|
+
const fact = parseFulfillmentFact(value.fact);
|
|
70
|
+
const safe = {
|
|
71
|
+
...pollEvidence(value, privacy, codecs),
|
|
72
|
+
fact: { ...fact, mapperVersion: token(fact.mapperVersion) ?? "redacted" }, eventKind: (token(value.eventKind) ?? "redacted"),
|
|
73
|
+
firstReceivedAt: timestamp.parse(value.firstReceivedAt),
|
|
74
|
+
trackingRefs: value.trackingRefs.flatMap(ref => {
|
|
75
|
+
const projected = projectTrackingReference(ref, privacy, approveTrackingUrl, codecs);
|
|
76
|
+
return projected ? [projected] : [];
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
if (privacy.redactedFieldCount)
|
|
80
|
+
diagnostics.redactedFieldCount = privacy.redactedFieldCount;
|
|
81
|
+
return { ...safe, ...(Object.keys(diagnostics).length ? { diagnostics } : {}) };
|
|
82
|
+
}
|
|
83
|
+
const HANDOVER_STATUSES = new Set(FULFILLMENT_STATUS_MAP.stages.filter(stage => stage.effects.handover).flatMap(stage => stage.localStatus));
|
|
84
|
+
/** Donor finished-picking boundary is narrower than the coarse packing stage. */
|
|
85
|
+
export const observationStatusPolicy = {
|
|
86
|
+
consumesStock: (status) => ["packed", "in_transit", "delivered"].includes(status),
|
|
87
|
+
handsOver: (status) => HANDOVER_STATUSES.has(status),
|
|
88
|
+
suppressDispatched: (status) => status === "delivered",
|
|
89
|
+
trackingStatus: (status) => status,
|
|
90
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Offline protocol capabilities; selection and account readiness belong to the host. */
|
|
2
|
+
export const omnipackFulfillmentCapabilities = Object.freeze({
|
|
3
|
+
providerRef: "omnipack", role: "warehouse", defaultOff: true, selected: false,
|
|
4
|
+
readiness: Object.freeze({ ready: false, refusal: Object.freeze({ reason: "not_ready", phase: "selection", retryable: false }) }),
|
|
5
|
+
operations: Object.freeze({
|
|
6
|
+
dispatch: Object.freeze({ supported: true }), readback: Object.freeze({ supported: true }),
|
|
7
|
+
exactAbsence: Object.freeze({ supported: false, reason: "not_exposed" }), verifyObservation: Object.freeze({ supported: true }),
|
|
8
|
+
syncStock: Object.freeze({ supported: true }), syncProducts: Object.freeze({ supported: true }),
|
|
9
|
+
labelCreate: Object.freeze({ supported: false, reason: "not_exposed" }), labelRead: Object.freeze({ supported: false, reason: "host_only" }),
|
|
10
|
+
labelVoid: Object.freeze({ supported: false, reason: "not_exposed" }), cancel: Object.freeze({ supported: false, reason: "not_exposed" }),
|
|
11
|
+
pickupPoint: Object.freeze({ supported: true }), courierPickup: Object.freeze({ supported: false, reason: "not_exposed" }),
|
|
12
|
+
}),
|
|
13
|
+
authentication: "token", freshness: "not_available", ownsDeliveredNotification: false,
|
|
14
|
+
stockAuthority: "external_stock_master_with_local_reservations", labelReadOwner: "host_storage",
|
|
15
|
+
actionPolicy: Object.freeze({ providerSpecificAdminActions: false, genericAdminActions: true, mutationSurface: "provider_adapter" }),
|
|
16
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type OmnipackFulfilmentEvidence, type OmnipackFulfilmentRequestEvidence, type OmnipackOrderCreatedEvidence, type OmnipackProductCreatedEvidence, type OmnipackStockEvidence, type OmnipackStockMovementEvidence } from "./mappers.js";
|
|
2
|
+
import { type OmnipackProductEvidence, type OmnipackProductPackCreatedEvidence } from "./productSyncMappers.js";
|
|
3
|
+
export { OmnipackProviderError, sanitizeOmnipackProviderError, type SanitizedOmnipackProviderError, } from "./providerError.js";
|
|
4
|
+
export interface OmnipackClientConfig {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
credentials: () => {
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
} | Promise<{
|
|
10
|
+
username: string;
|
|
11
|
+
password: string;
|
|
12
|
+
}>;
|
|
13
|
+
timeoutMs: number;
|
|
14
|
+
safeReadRetries: number;
|
|
15
|
+
productPath: string;
|
|
16
|
+
}
|
|
17
|
+
export interface OmnipackClient {
|
|
18
|
+
createOrder(body: string): Promise<OmnipackOrderCreatedEvidence>;
|
|
19
|
+
createProduct(payload: Record<string, unknown>, sku: string): Promise<OmnipackProductCreatedEvidence>;
|
|
20
|
+
getProduct(sku: string): Promise<OmnipackProductEvidence>;
|
|
21
|
+
createProductPack(sku: string, payload: Record<string, unknown>, ean: string): Promise<OmnipackProductPackCreatedEvidence>;
|
|
22
|
+
getStock(options?: {
|
|
23
|
+
refuseRedirectRetry: boolean;
|
|
24
|
+
}): Promise<OmnipackStockEvidence[]>;
|
|
25
|
+
getStockMovements(params?: OmnipackQueryParams): Promise<OmnipackStockMovementEvidence[]>;
|
|
26
|
+
getFulfilmentsPage(params?: OmnipackQueryParams): Promise<{
|
|
27
|
+
rows: OmnipackFulfilmentEvidence[];
|
|
28
|
+
complete: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
getFulfilments(params?: OmnipackQueryParams): Promise<OmnipackFulfilmentEvidence[]>;
|
|
31
|
+
getFulfilmentRequests(params?: OmnipackQueryParams): Promise<OmnipackFulfilmentRequestEvidence[]>;
|
|
32
|
+
}
|
|
33
|
+
export interface OmnipackQueryParams {
|
|
34
|
+
startLocalDate?: string;
|
|
35
|
+
endLocalDate?: string;
|
|
36
|
+
page?: number;
|
|
37
|
+
size?: number;
|
|
38
|
+
}
|
|
39
|
+
export declare function createOmnipackClient(config: OmnipackClientConfig, fetchImpl: typeof fetch): OmnipackClient;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { mapOmnipackFulfilmentRequestsResponse, mapOmnipackFulfilmentsResponse, mapOmnipackOrderCreatedResponse, mapOmnipackProductCreatedResponse, mapOmnipackStockMovementsResponse, mapOmnipackStockResponse, sanitizeOmnipackPayload, } from "./mappers.js";
|
|
2
|
+
import { mapOmnipackProductPackCreatedResponse, mapOmnipackProductResponse, } from "./productSyncMappers.js";
|
|
3
|
+
import { mayPostHaveSucceeded, OmnipackProviderError } from "./providerError.js";
|
|
4
|
+
export { OmnipackProviderError, sanitizeOmnipackProviderError, } from "./providerError.js";
|
|
5
|
+
const PRODUCT_PACKS_SEGMENT = "packs";
|
|
6
|
+
export function createOmnipackClient(config, fetchImpl) {
|
|
7
|
+
return {
|
|
8
|
+
async createOrder(body) {
|
|
9
|
+
return mapOmnipackOrderCreatedResponse(await requestJson(fetchImpl, config, "createOrder", "/orders", {
|
|
10
|
+
method: "POST",
|
|
11
|
+
body,
|
|
12
|
+
}));
|
|
13
|
+
},
|
|
14
|
+
async createProduct(payload, sku) {
|
|
15
|
+
const body = await requestJson(fetchImpl, config, "createProduct", config.productPath, post(payload));
|
|
16
|
+
return mapOmnipackProductCreatedResponse(body, sku);
|
|
17
|
+
},
|
|
18
|
+
async getProduct(sku) {
|
|
19
|
+
const path = productResourcePath(config.productPath, sku);
|
|
20
|
+
return mapOmnipackProductResponse(await requestJson(fetchImpl, config, "getProduct", path, { method: "GET" }), sku);
|
|
21
|
+
},
|
|
22
|
+
async createProductPack(sku, payload, ean) {
|
|
23
|
+
const path = `${productResourcePath(config.productPath, sku)}/${PRODUCT_PACKS_SEGMENT}`;
|
|
24
|
+
const body = await requestJson(fetchImpl, config, "createProductPack", path, post(payload));
|
|
25
|
+
return mapOmnipackProductPackCreatedResponse(body, sku, ean);
|
|
26
|
+
},
|
|
27
|
+
async getStock(options) {
|
|
28
|
+
return mapOmnipackStockResponse(await requestJson(fetchImpl, config, "getStock", "/stock", { method: "GET" }, options?.refuseRedirectRetry));
|
|
29
|
+
},
|
|
30
|
+
async getStockMovements(params) {
|
|
31
|
+
return mapOmnipackStockMovementsResponse(await requestJson(fetchImpl, config, "getStockMovements", withQuery("/stock-movements", params), { method: "GET" }, true));
|
|
32
|
+
},
|
|
33
|
+
async getFulfilmentsPage(params) {
|
|
34
|
+
const body = await requestJson(fetchImpl, config, "getFulfilments", withQuery("/fulfilments", params), { method: "GET" });
|
|
35
|
+
const rows = mapOmnipackFulfilmentsResponse(body);
|
|
36
|
+
// Only explicit single-page totals establish whole-collection uniqueness.
|
|
37
|
+
const record = body;
|
|
38
|
+
const page = record?.page;
|
|
39
|
+
const complete = page?.number === 0 && page.totalPages === 1 && page.totalElements === rows.length
|
|
40
|
+
&& typeof page.size === "number" && Number.isSafeInteger(page.size) && page.size >= rows.length && page.size > 0
|
|
41
|
+
&& !record?._links?.next && !record?.incomplete && !record?.partial;
|
|
42
|
+
return { rows, complete };
|
|
43
|
+
},
|
|
44
|
+
async getFulfilments(params) {
|
|
45
|
+
return mapOmnipackFulfilmentsResponse(await requestJson(fetchImpl, config, "getFulfilments", withQuery("/fulfilments", params), { method: "GET" }));
|
|
46
|
+
},
|
|
47
|
+
async getFulfilmentRequests(params) {
|
|
48
|
+
return mapOmnipackFulfilmentRequestsResponse(await requestJson(fetchImpl, config, "getFulfilmentRequests", withQuery("/fulfilment-requests", params), { method: "GET" }));
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async function requestJson(fetchImpl, config, operation, path, init, refuseRedirectRetry = false) {
|
|
53
|
+
const method = (init.method ?? "GET").toUpperCase();
|
|
54
|
+
const attempts = method === "GET" ? config.safeReadRetries + 1 : 1;
|
|
55
|
+
// Dispatch/readback diagnostics must not change product-sync or stock retry policy.
|
|
56
|
+
const diagnoseRedirectFailure = refuseRedirectRetry || operation === "createOrder"
|
|
57
|
+
|| operation === "getFulfilments" || operation === "getFulfilmentRequests";
|
|
58
|
+
let lastError = null;
|
|
59
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
60
|
+
let submitted = false;
|
|
61
|
+
try {
|
|
62
|
+
const base = new URL(config.baseUrl);
|
|
63
|
+
const url = new URL(path, base);
|
|
64
|
+
if (url.origin !== base.origin || url.username || url.password || url.protocol !== "https:")
|
|
65
|
+
throw new Error("Invalid fulfillment path");
|
|
66
|
+
const response = await fetchWithTimeout(fetchImpl, url, config, init, () => { submitted = true; });
|
|
67
|
+
if (response.ok)
|
|
68
|
+
return await readJsonBody(response);
|
|
69
|
+
const retryable = method === "GET" && isRetryableStatus(response.status);
|
|
70
|
+
// A failed body read cannot erase the rejection status already received.
|
|
71
|
+
const body = await readJsonBody(response).catch(() => null);
|
|
72
|
+
lastError = new OmnipackProviderError({
|
|
73
|
+
operation,
|
|
74
|
+
status: response.status,
|
|
75
|
+
code: refuseRedirectRetry && response.status >= 300 && response.status < 400 ? "redirect_refused" : readProviderErrorCode(body) ?? `http_${response.status}`,
|
|
76
|
+
retryable,
|
|
77
|
+
mayHaveSucceeded: mayPostHaveSucceeded(method, response.status),
|
|
78
|
+
});
|
|
79
|
+
if (!retryable || attempt === attempts)
|
|
80
|
+
throw lastError;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const retryable = method === "GET" && attempt < attempts;
|
|
84
|
+
lastError = submitted && error instanceof OmnipackProviderError
|
|
85
|
+
? error
|
|
86
|
+
: new OmnipackProviderError({
|
|
87
|
+
operation,
|
|
88
|
+
status: null,
|
|
89
|
+
code: diagnoseRedirectFailure && isRedirectRefusal(error) ? "redirect_refused" : "network_error",
|
|
90
|
+
retryable,
|
|
91
|
+
mayHaveSucceeded: submitted && mayPostHaveSucceeded(method, null),
|
|
92
|
+
});
|
|
93
|
+
if (!retryable || (refuseRedirectRetry && lastError.code === "redirect_refused"))
|
|
94
|
+
throw lastError;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
throw lastError;
|
|
98
|
+
}
|
|
99
|
+
async function fetchWithTimeout(fetchImpl, url, config, init, onSubmit) {
|
|
100
|
+
const controller = new AbortController();
|
|
101
|
+
const timeout = setTimeout(() => controller.abort(), config.timeoutMs);
|
|
102
|
+
try {
|
|
103
|
+
const credentials = await config.credentials();
|
|
104
|
+
const requestInit = {
|
|
105
|
+
...init,
|
|
106
|
+
signal: controller.signal,
|
|
107
|
+
redirect: "error",
|
|
108
|
+
headers: {
|
|
109
|
+
Accept: "application/json",
|
|
110
|
+
"Content-Type": "application/json",
|
|
111
|
+
Authorization: `Basic ${Buffer.from(`${credentials.username}:${credentials.password}`).toString("base64")}`,
|
|
112
|
+
...(init.headers ?? {}),
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
new Request(url, requestInit); // Validate construction before crossing the submission boundary.
|
|
116
|
+
controller.signal.throwIfAborted();
|
|
117
|
+
onSubmit();
|
|
118
|
+
return await fetchImpl(url, requestInit);
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
clearTimeout(timeout);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function readJsonBody(response) {
|
|
125
|
+
const text = await response.text();
|
|
126
|
+
if (!text)
|
|
127
|
+
return {};
|
|
128
|
+
try {
|
|
129
|
+
return sanitizeOmnipackPayload(JSON.parse(text));
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// A non-retried JSON POST init (mutations must not be silently re-sent — requestJson keys retry
|
|
136
|
+
// off the GET method).
|
|
137
|
+
function post(payload) {
|
|
138
|
+
return { method: "POST", body: JSON.stringify(payload) };
|
|
139
|
+
}
|
|
140
|
+
// Per-product resource path (GET /products/{sku}, base for /packs). sku is percent-encoded; the
|
|
141
|
+
// product path is right-trimmed so a trailing-slash path override does not double the slash.
|
|
142
|
+
function productResourcePath(productPath, sku) {
|
|
143
|
+
return `${productPath.replace(/\/+$/, "")}/${encodeURIComponent(sku)}`;
|
|
144
|
+
}
|
|
145
|
+
function withQuery(path, params) {
|
|
146
|
+
const url = new URL(path, "https://example.test");
|
|
147
|
+
if (params?.startLocalDate)
|
|
148
|
+
url.searchParams.set("startLocalDate", params.startLocalDate);
|
|
149
|
+
if (params?.endLocalDate)
|
|
150
|
+
url.searchParams.set("endLocalDate", params.endLocalDate);
|
|
151
|
+
if (typeof params?.page === "number")
|
|
152
|
+
url.searchParams.set("page", String(params.page));
|
|
153
|
+
if (typeof params?.size === "number")
|
|
154
|
+
url.searchParams.set("size", String(params.size));
|
|
155
|
+
return `${url.pathname}${url.search}`;
|
|
156
|
+
}
|
|
157
|
+
function readProviderErrorCode(body) {
|
|
158
|
+
return typeof body === "object" && body !== null && "code" in body && typeof body.code === "string"
|
|
159
|
+
&& /^[A-Z][A-Z0-9_]{0,63}$/.test(body.code)
|
|
160
|
+
? body.code
|
|
161
|
+
: null;
|
|
162
|
+
}
|
|
163
|
+
function isRetryableStatus(status) {
|
|
164
|
+
return status === 408 || status === 429 || status >= 500;
|
|
165
|
+
}
|
|
166
|
+
// Fetch implementations expose redirect refusal as an exception, sometimes through cause.
|
|
167
|
+
// Inspect it only to select a closed diagnostic; no exception text leaves this adapter.
|
|
168
|
+
function isRedirectRefusal(error) {
|
|
169
|
+
if (!(error instanceof Error))
|
|
170
|
+
return false;
|
|
171
|
+
return /redirect/i.test(error.message) || (error.cause instanceof Error && /redirect/i.test(error.cause.message));
|
|
172
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { FulfillmentCapabilityDescriptor, FulfillmentDispatchPort, FulfillmentDispatchRequest, FulfillmentLabelPort, FulfillmentObservationPort, FulfillmentReadbackPort, FulfillmentObservationPagePort, FulfillmentStockSyncProvider, FulfillmentProductSyncProvider } from "../contracts/index.js";
|
|
2
|
+
import { type OmnipackWebhookRouteEvent } from "./omnipackWebhookPayload.js";
|
|
3
|
+
import { type OmnipackObservationCodecs } from "./observation.js";
|
|
4
|
+
export { omnipackFulfillmentCapabilities } from "./capabilities.js";
|
|
5
|
+
/** Node-only, explicit construction. Secrets are supplied per call, never retained as values. */
|
|
6
|
+
export interface OmnipackFulfillmentAdapterConfig {
|
|
7
|
+
http: {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
credentials: () => {
|
|
10
|
+
username: string;
|
|
11
|
+
password: string;
|
|
12
|
+
} | Promise<{
|
|
13
|
+
username: string;
|
|
14
|
+
password: string;
|
|
15
|
+
}>;
|
|
16
|
+
fetchImpl: typeof fetch;
|
|
17
|
+
timeoutMs: number;
|
|
18
|
+
safeReadRetries: number;
|
|
19
|
+
productPath: string;
|
|
20
|
+
};
|
|
21
|
+
selected?: boolean;
|
|
22
|
+
/** Per-instance retention target; default 10,000. Evicts oldest completed submissions, never in-flight. */
|
|
23
|
+
maxRetainedSubmissions?: number;
|
|
24
|
+
/** Host account evidence, independent of credentials. Omission remains not ready. */
|
|
25
|
+
readiness?: FulfillmentCapabilityDescriptor["readiness"];
|
|
26
|
+
/** Called in prepare and again for new dispatches; return identical metadata for the same request or dispatch refuses. */
|
|
27
|
+
resolveProduct: (line: FulfillmentDispatchRequest["lines"][number]) => Promise<{
|
|
28
|
+
lotNumber?: string;
|
|
29
|
+
expirationDate?: string;
|
|
30
|
+
} | null>;
|
|
31
|
+
notification: {
|
|
32
|
+
token: () => string | undefined | Promise<string | undefined>;
|
|
33
|
+
expectedEvent: OmnipackWebhookRouteEvent;
|
|
34
|
+
};
|
|
35
|
+
clock: () => string;
|
|
36
|
+
mintEvidenceReference: () => `evidence:${string}`;
|
|
37
|
+
mintSyncRunId: () => string;
|
|
38
|
+
approveTrackingUrl: (url: string) => boolean;
|
|
39
|
+
observationCodecs?: OmnipackObservationCodecs;
|
|
40
|
+
/** Writes occur only through deliberate calls; scheduled composition must remain pull-only. */
|
|
41
|
+
product?: {
|
|
42
|
+
resolvePushMetadata: (sku: string) => Promise<Record<string, unknown> | null>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** No route, schedule, environment reader or default binding is installed. */
|
|
46
|
+
export declare function createOmnipackFulfillmentAdapter(config: OmnipackFulfillmentAdapterConfig): {
|
|
47
|
+
capabilities: FulfillmentCapabilityDescriptor;
|
|
48
|
+
dispatch: FulfillmentDispatchPort;
|
|
49
|
+
label: FulfillmentLabelPort;
|
|
50
|
+
observation: FulfillmentObservationPort;
|
|
51
|
+
readback: FulfillmentReadbackPort;
|
|
52
|
+
reconciliation: FulfillmentObservationPagePort;
|
|
53
|
+
stockSync: FulfillmentStockSyncProvider;
|
|
54
|
+
productSync: FulfillmentProductSyncProvider;
|
|
55
|
+
};
|