@openlup/platform 0.21.0 → 0.22.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 +210 -47
- package/README.md +27 -4
- 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 +93 -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 +105 -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 +52 -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 +38 -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 +86 -0
- package/dist/fulfillment/contracts/store.js +1 -0
- package/dist/fulfillment/contracts/sync.d.ts +170 -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 +7 -0
- package/dist/fulfillment/dispatchProjection.js +18 -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 +37 -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 +27 -0
- package/dist/fulfillment/migrations.js +8 -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 +11 -0
- package/dist/fulfillment/observationProjection.js +37 -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 +37 -0
- package/dist/fulfillment/omnipack/client.js +162 -0
- package/dist/fulfillment/omnipack/index.d.ts +52 -0
- package/dist/fulfillment/omnipack/index.js +349 -0
- package/dist/fulfillment/omnipack/mappers.d.ts +73 -0
- package/dist/fulfillment/omnipack/mappers.js +177 -0
- package/dist/fulfillment/omnipack/observation.d.ts +21 -0
- package/dist/fulfillment/omnipack/observation.js +57 -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/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 +63 -0
- package/dist/fulfillment/postgresShipmentSpine.js +232 -0
- package/dist/fulfillment/postgresStockSyncPort.d.ts +8 -0
- package/dist/fulfillment/postgresStockSyncPort.js +63 -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 +26 -0
- package/dist/fulfillment/providerDispatchAcceptance.js +23 -0
- package/dist/fulfillment/providerDispatchError.d.ts +6 -0
- package/dist/fulfillment/providerDispatchError.js +5 -0
- package/dist/fulfillment/providerDispatchWorker.d.ts +31 -0
- package/dist/fulfillment/providerDispatchWorker.js +172 -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 +82 -0
- package/dist/fulfillment/providerReconciliationWorker.js +151 -0
- package/dist/fulfillment/providerStockAvailability.d.ts +13 -0
- package/dist/fulfillment/providerStockAvailability.js +51 -0
- package/dist/fulfillment/providerStockSyncWorker.d.ts +37 -0
- package/dist/fulfillment/providerStockSyncWorker.js +186 -0
- package/dist/fulfillment/providerTrackingReferences.d.ts +15 -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 +52 -0
- package/dist/fulfillment/verifiedIngress.js +66 -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/package.json +17 -2
- package/release-gates.json +44 -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/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 +61 -0
- package/src/fulfillment/contracts/customerAlignment.ts +4 -0
- package/src/fulfillment/contracts/dispatch.ts +58 -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 +18 -0
- package/src/fulfillment/contracts/operator.ts +31 -0
- package/src/fulfillment/contracts/read.ts +42 -0
- package/src/fulfillment/contracts/readback.ts +11 -0
- package/src/fulfillment/contracts/replacement.ts +15 -0
- package/src/fulfillment/contracts/store.ts +26 -0
- package/src/fulfillment/contracts/sync.ts +61 -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 +20 -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 +38 -0
- package/src/fulfillment/labelLifecycle.ts +11 -0
- package/src/fulfillment/lowStockEvidenceHandler.ts +60 -0
- package/src/fulfillment/migrations.ts +8 -0
- package/src/fulfillment/nativeUnsupported.ts +23 -0
- package/src/fulfillment/normalizedFulfillmentFacts.ts +2 -0
- package/src/fulfillment/observationProjection.ts +41 -0
- package/src/fulfillment/omnipack/capabilities.ts +18 -0
- package/src/fulfillment/omnipack/client.ts +258 -0
- package/src/fulfillment/omnipack/index.ts +312 -0
- package/src/fulfillment/omnipack/mappers.ts +261 -0
- package/src/fulfillment/omnipack/observation.ts +61 -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/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 +321 -0
- package/src/fulfillment/postgresStockSyncPort.ts +65 -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 +31 -0
- package/src/fulfillment/providerDispatchError.ts +7 -0
- package/src/fulfillment/providerDispatchWorker.ts +131 -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 +150 -0
- package/src/fulfillment/providerStockAvailability.ts +60 -0
- package/src/fulfillment/providerStockSyncWorker.ts +222 -0
- package/src/fulfillment/providerTrackingReferences.ts +31 -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 +80 -0
- package/src/payments/stripe/index.ts +30 -0
- package/src/payments/tpay/index.ts +36 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { COMMERCE_FULFILLMENT_CONTRACT_VERSION, adminCommerceFulfillmentOrderDetailResponseSchema, adminCommerceFulfillmentOrdersListResponseSchema, } from "./handlerSchemas.js";
|
|
2
|
+
export function buildCommerceFulfillmentOrdersListResponse(input, policy) {
|
|
3
|
+
return adminCommerceFulfillmentOrdersListResponseSchema.parse({
|
|
4
|
+
contractVersion: COMMERCE_FULFILLMENT_CONTRACT_VERSION,
|
|
5
|
+
orders: input.fulfillmentOrders.map((fulfillmentOrder) => buildCommerceFulfillmentOrder({
|
|
6
|
+
fulfillmentOrder,
|
|
7
|
+
lines: input.lines.filter((line) => line.fulfillment_order_id === fulfillmentOrder.id),
|
|
8
|
+
latestOperation: input.latestOperations.find((operation) => operation.fulfillment_order_id === fulfillmentOrder.id) ??
|
|
9
|
+
null,
|
|
10
|
+
orderContext: findRequired(input.orderContexts, fulfillmentOrder.order_id, "order context"),
|
|
11
|
+
paymentIntent: findRequired(input.paymentIntents, fulfillmentOrder.order_id, "payment intent"),
|
|
12
|
+
inventoryReservations: input.inventoryReservations.filter((reservation) => reservation.order_id === fulfillmentOrder.order_id),
|
|
13
|
+
shipmentRef: input.shipmentRefs.find((ref) => ref.order_id === fulfillmentOrder.order_id && ref.active) ?? null,
|
|
14
|
+
activeHoldCount: input.activeHoldCounts[fulfillmentOrder.order_id] ?? 0,
|
|
15
|
+
subscriptionCycleStatuses: input.subscriptionCycleStatuses,
|
|
16
|
+
policy,
|
|
17
|
+
})),
|
|
18
|
+
totalCount: input.totalCount,
|
|
19
|
+
page: input.page,
|
|
20
|
+
pageSize: input.pageSize,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function buildCommerceFulfillmentOrderDetailResponse(input, policy) {
|
|
24
|
+
return adminCommerceFulfillmentOrderDetailResponseSchema.parse({
|
|
25
|
+
contractVersion: COMMERCE_FULFILLMENT_CONTRACT_VERSION,
|
|
26
|
+
order: buildCommerceFulfillmentOrder({
|
|
27
|
+
fulfillmentOrder: input.fulfillmentOrder,
|
|
28
|
+
lines: input.lines,
|
|
29
|
+
latestOperation: input.latestOperation,
|
|
30
|
+
orderContext: input.orderContext,
|
|
31
|
+
paymentIntent: input.paymentIntent,
|
|
32
|
+
inventoryReservations: input.inventoryReservations,
|
|
33
|
+
shipmentRef: input.shipmentRef,
|
|
34
|
+
activeHoldCount: input.activeHoldCount,
|
|
35
|
+
policy,
|
|
36
|
+
subscriptionCycleStatuses: {
|
|
37
|
+
[input.orderContext.subscription_cycle_id ?? ""]: input.subscriptionCycleStatus,
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function buildCommerceFulfillmentOrder(input) {
|
|
43
|
+
const paymentStatus = input.paymentIntent.status;
|
|
44
|
+
const inventory = inventorySummary(input.inventoryReservations);
|
|
45
|
+
return {
|
|
46
|
+
id: input.fulfillmentOrder.id,
|
|
47
|
+
orderId: input.fulfillmentOrder.order_id,
|
|
48
|
+
clientId: input.fulfillmentOrder.client_id,
|
|
49
|
+
status: input.fulfillmentOrder.status,
|
|
50
|
+
providerKind: input.fulfillmentOrder.provider_kind,
|
|
51
|
+
providerTrackingId: input.shipmentRef?.provider_tracking_id ?? null,
|
|
52
|
+
shippingAddress: normalizeShippingAddressSnapshot(input.fulfillmentOrder.shipping_address_snapshot),
|
|
53
|
+
lines: input.lines.map((line) => ({
|
|
54
|
+
id: line.id,
|
|
55
|
+
orderItemId: line.order_item_id,
|
|
56
|
+
skuId: line.sku_id,
|
|
57
|
+
sku: line.sku,
|
|
58
|
+
title: line.title,
|
|
59
|
+
quantity: line.quantity,
|
|
60
|
+
inventoryReservationIds: line.inventory_reservation_ids,
|
|
61
|
+
productSnapshot: line.product_snapshot,
|
|
62
|
+
})),
|
|
63
|
+
payment: {
|
|
64
|
+
paymentIntentId: input.paymentIntent.id,
|
|
65
|
+
paymentStatus,
|
|
66
|
+
providerPaymentId: input.paymentIntent.provider_payment_id,
|
|
67
|
+
},
|
|
68
|
+
inventory,
|
|
69
|
+
omsEligibility: input.policy.evaluateCommerceFulfillmentEligibility({
|
|
70
|
+
orderMode: input.orderContext.mode,
|
|
71
|
+
orderStatus: input.orderContext.status,
|
|
72
|
+
paymentStatus,
|
|
73
|
+
subscriptionCycleStatus: input.orderContext.subscription_cycle_id
|
|
74
|
+
? input.subscriptionCycleStatuses[input.orderContext.subscription_cycle_id] ?? null
|
|
75
|
+
: null,
|
|
76
|
+
activeHoldCount: input.activeHoldCount,
|
|
77
|
+
hasShippingAddress: Boolean(input.orderContext.shipping_address_id),
|
|
78
|
+
inventoryStatus: inventory.status,
|
|
79
|
+
}),
|
|
80
|
+
latestOperation: input.latestOperation
|
|
81
|
+
? {
|
|
82
|
+
id: input.latestOperation.id,
|
|
83
|
+
type: input.latestOperation.operation_type,
|
|
84
|
+
occurredAt: input.latestOperation.occurred_at,
|
|
85
|
+
actorUserId: input.latestOperation.actor_user_id,
|
|
86
|
+
payload: input.latestOperation.payload,
|
|
87
|
+
}
|
|
88
|
+
: null,
|
|
89
|
+
createdAt: input.fulfillmentOrder.created_at,
|
|
90
|
+
updatedAt: input.fulfillmentOrder.updated_at,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function normalizeShippingAddressSnapshot(snapshot) {
|
|
94
|
+
return {
|
|
95
|
+
addressId: snapshot.addressId,
|
|
96
|
+
clientId: snapshot.clientId,
|
|
97
|
+
label: snapshot.label,
|
|
98
|
+
line1: snapshot.line1,
|
|
99
|
+
line2: snapshot.line2,
|
|
100
|
+
city: snapshot.city,
|
|
101
|
+
postalCode: snapshot.postalCode,
|
|
102
|
+
country: snapshot.country,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function inventorySummary(reservations) {
|
|
106
|
+
const reservation = reservations[0] ?? null;
|
|
107
|
+
if (!reservation) {
|
|
108
|
+
return {
|
|
109
|
+
status: "missing",
|
|
110
|
+
reservationId: null,
|
|
111
|
+
reservationStatus: null,
|
|
112
|
+
expiresAt: null,
|
|
113
|
+
locationId: null,
|
|
114
|
+
locationCode: null,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
status: reservation.status === "reserved" ? "reserved" : reservation.status,
|
|
119
|
+
reservationId: reservation.id,
|
|
120
|
+
reservationStatus: reservation.status,
|
|
121
|
+
expiresAt: reservation.expires_at,
|
|
122
|
+
locationId: reservation.location_id,
|
|
123
|
+
locationCode: reservation.inventory_locations?.code ?? null,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function findRequired(rows, orderId, label) {
|
|
127
|
+
const row = rows.find((candidate) => candidate.order_id === orderId || candidate.id === orderId);
|
|
128
|
+
if (!row)
|
|
129
|
+
throw new Error(`Missing commerce fulfillment ${label} for order ${orderId}`);
|
|
130
|
+
return row;
|
|
131
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Late delivery extends the next cycle, never stacks deliveries or moves it earlier.
|
|
3
|
+
* A replacement may settle alignment as aligned only after reaching the customer.
|
|
4
|
+
* Its superseded predecessor is no longer outstanding; an in-flight or undelivered
|
|
5
|
+
* replacement still is. Never call subscription_delivery_alignment_confirm_replacement
|
|
6
|
+
* for a replacement that did not arrive: it records "Parcel delivered" and shifts
|
|
7
|
+
* the cycle later. That note-only operator attestation remains outside this port;
|
|
8
|
+
* no automatic caller or new guard is introduced.
|
|
9
|
+
*/
|
|
10
|
+
export interface DeliveryAlignmentPort {
|
|
11
|
+
recordArrival(input: {
|
|
12
|
+
requestKey: string;
|
|
13
|
+
parcelRef: string;
|
|
14
|
+
deliveredAt: string;
|
|
15
|
+
evidenceRef: `evidence:${string}`;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
disposition: "aligned" | "outstanding" | "manual_review";
|
|
18
|
+
nextCycleAt: string | null;
|
|
19
|
+
replayed: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
read(fulfillmentRef: string): Promise<{
|
|
22
|
+
disposition: "aligned" | "outstanding" | "manual_review";
|
|
23
|
+
nextCycleAt: string | null;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { FulfillmentCapabilityDescriptor } from './capabilities.js';
|
|
2
|
+
import type { FulfillmentDispatchPort, FulfillmentDispatchRequest, FulfillmentRefusal, FulfillmentSelection } from './dispatch.js';
|
|
3
|
+
import type { FulfillmentNativeUnsupported } from './nativeUnsupported.js';
|
|
4
|
+
import type { DispatchRecord, FulfillmentStorePort } from './store.js';
|
|
5
|
+
/** In-memory ports and host closures only; never serialize options or recipient inputs. */
|
|
6
|
+
export interface FulfillmentServicesOptions {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
selection: FulfillmentSelection | null;
|
|
9
|
+
capability: FulfillmentCapabilityDescriptor | null;
|
|
10
|
+
store: FulfillmentStorePort | null;
|
|
11
|
+
provider: FulfillmentDispatchPort | null;
|
|
12
|
+
readiness(): Promise<{
|
|
13
|
+
ready: true;
|
|
14
|
+
} | {
|
|
15
|
+
ready: false;
|
|
16
|
+
refusal: FulfillmentRefusal | FulfillmentNativeUnsupported;
|
|
17
|
+
}>;
|
|
18
|
+
listCandidates(limit: number): Promise<readonly FulfillmentDispatchRequest[]>;
|
|
19
|
+
keys: {
|
|
20
|
+
request(candidate: FulfillmentDispatchRequest): string;
|
|
21
|
+
mappedAttempt(requestKey: string, mappedAttemptIndex: number): string;
|
|
22
|
+
acceptance(fulfillmentRef: string): {
|
|
23
|
+
providerAttemptKey: string;
|
|
24
|
+
labelKey: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
config: {
|
|
28
|
+
mode: DispatchRecord['mode'];
|
|
29
|
+
batchLimit: number;
|
|
30
|
+
};
|
|
31
|
+
now?: () => Date;
|
|
32
|
+
}
|
|
33
|
+
/** Import and construction are inert. Every invocation checks activation before any worker. */
|
|
34
|
+
export interface FulfillmentServices {
|
|
35
|
+
readiness(): ReturnType<FulfillmentServicesOptions['readiness']>;
|
|
36
|
+
runDispatch(): Promise<FulfillmentNativeUnsupported | {
|
|
37
|
+
kind: 'refused';
|
|
38
|
+
refusal: FulfillmentRefusal;
|
|
39
|
+
} | {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
skipped: boolean;
|
|
42
|
+
checked: number;
|
|
43
|
+
updated: number;
|
|
44
|
+
failures: number;
|
|
45
|
+
mode: DispatchRecord['mode'];
|
|
46
|
+
replayed: number;
|
|
47
|
+
providerCalls: number;
|
|
48
|
+
readBacks: number;
|
|
49
|
+
reason: string | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FulfillmentRefusal } from "./dispatch.js";
|
|
2
|
+
export interface FulfillmentCapabilityDescriptor {
|
|
3
|
+
providerRef: string;
|
|
4
|
+
role: "warehouse" | "direct_carrier" | "manual" | "simulator";
|
|
5
|
+
operations: Readonly<Record<"dispatch" | "readback" | "exactAbsence" | "verifyObservation" | "syncStock" | "syncProducts" | "labelCreate" | "labelRead" | "labelVoid" | "cancel" | "pickupPoint" | "courierPickup", {
|
|
6
|
+
supported: true;
|
|
7
|
+
} | {
|
|
8
|
+
supported: false;
|
|
9
|
+
reason: "not_exposed" | "host_only" | "not_implemented";
|
|
10
|
+
}>>;
|
|
11
|
+
authentication: "token" | "authenticated_timestamp" | "none";
|
|
12
|
+
freshness: "authenticated_timestamp" | "not_available";
|
|
13
|
+
defaultOff: true;
|
|
14
|
+
selected: boolean;
|
|
15
|
+
readiness: {
|
|
16
|
+
ready: true;
|
|
17
|
+
} | {
|
|
18
|
+
ready: false;
|
|
19
|
+
refusal: FulfillmentRefusal;
|
|
20
|
+
};
|
|
21
|
+
ownsDeliveredNotification: boolean;
|
|
22
|
+
stockAuthority: "local_atp" | "external_stock_master_with_local_reservations";
|
|
23
|
+
labelReadOwner: "host_storage" | "adapter" | "none";
|
|
24
|
+
actionPolicy: {
|
|
25
|
+
providerSpecificAdminActions: boolean;
|
|
26
|
+
genericAdminActions: boolean;
|
|
27
|
+
mutationSurface: "none" | "local_only" | "provider_adapter";
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { FulfillmentCapabilityDescriptor } from "./capabilities.js";
|
|
2
|
+
import type { FulfillmentDispatchPort, FulfillmentDispatchRequest } from "./dispatch.js";
|
|
3
|
+
import type { FulfillmentLabelPort } from "./label.js";
|
|
4
|
+
import type { FulfillmentObservationPort } from "./observation.js";
|
|
5
|
+
import type { FulfillmentReadbackPort } from "./readback.js";
|
|
6
|
+
import type { FulfillmentStockSyncProvider, FulfillmentProductSyncProvider } from "./sync.js";
|
|
7
|
+
import type { FulfillmentStorePort } from "./store.js";
|
|
8
|
+
type Fixture<Method extends (...args: never[]) => unknown> = {
|
|
9
|
+
input: Parameters<Method>;
|
|
10
|
+
expected: Awaited<ReturnType<Method>>;
|
|
11
|
+
};
|
|
12
|
+
type SyncFixture<Port> = {
|
|
13
|
+
[K in keyof Port]: Port[K] extends (...args: never[]) => unknown ? {
|
|
14
|
+
operation: K;
|
|
15
|
+
input: Parameters<Port[K]>;
|
|
16
|
+
expected: Awaited<ReturnType<Port[K]>> | {
|
|
17
|
+
kind: "refused";
|
|
18
|
+
refusal: {
|
|
19
|
+
reason: "unsupported";
|
|
20
|
+
phase: "sync";
|
|
21
|
+
retryable: false;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
} : never;
|
|
25
|
+
}[keyof Port];
|
|
26
|
+
/** Offline adapter-owned inputs and exact expected outputs; never real customer data. */
|
|
27
|
+
export interface FulfillmentAdapterConformanceSubject {
|
|
28
|
+
subjectId: string;
|
|
29
|
+
adapter: {
|
|
30
|
+
capabilities: FulfillmentCapabilityDescriptor;
|
|
31
|
+
dispatch: FulfillmentDispatchPort;
|
|
32
|
+
label?: FulfillmentLabelPort;
|
|
33
|
+
observation?: FulfillmentObservationPort;
|
|
34
|
+
readback?: FulfillmentReadbackPort;
|
|
35
|
+
stockSync?: FulfillmentStockSyncProvider;
|
|
36
|
+
productSync?: FulfillmentProductSyncProvider;
|
|
37
|
+
};
|
|
38
|
+
/** Count external submission I/O, including attempted calls. Preparation/refusals must not increase it. */
|
|
39
|
+
readIoCount(): number;
|
|
40
|
+
sensitiveValues: readonly string[];
|
|
41
|
+
fixtures: {
|
|
42
|
+
dispatch: readonly {
|
|
43
|
+
input: FulfillmentDispatchRequest;
|
|
44
|
+
expectedPrepare: Awaited<ReturnType<FulfillmentDispatchPort["prepare"]>>;
|
|
45
|
+
expectedDispatch?: Awaited<ReturnType<FulfillmentDispatchPort["dispatch"]>>;
|
|
46
|
+
/** Repeating this operation must not increase external submission I/O. */
|
|
47
|
+
replay?: boolean;
|
|
48
|
+
}[];
|
|
49
|
+
label?: {
|
|
50
|
+
create?: readonly Fixture<FulfillmentLabelPort["create"]>[];
|
|
51
|
+
read?: readonly Fixture<FulfillmentLabelPort["read"]>[];
|
|
52
|
+
void?: readonly Fixture<FulfillmentLabelPort["void"]>[];
|
|
53
|
+
};
|
|
54
|
+
observation?: readonly Fixture<FulfillmentObservationPort["verifyAndNormalize"]>[];
|
|
55
|
+
readback?: readonly (Fixture<FulfillmentReadbackPort["read"]> & {
|
|
56
|
+
localMissing?: boolean;
|
|
57
|
+
})[];
|
|
58
|
+
stockSync?: readonly SyncFixture<FulfillmentStockSyncProvider>[];
|
|
59
|
+
productSync?: readonly SyncFixture<FulfillmentProductSyncProvider>[];
|
|
60
|
+
};
|
|
61
|
+
/** A fresh isolated host store per call; no database implementation is supplied by the runner. */
|
|
62
|
+
store?: {
|
|
63
|
+
create(): Promise<FulfillmentStorePort & {
|
|
64
|
+
/** Offline fixture inspection, not a new production store operation. */
|
|
65
|
+
readMappedAttempts(): Promise<readonly {
|
|
66
|
+
attemptKey: string;
|
|
67
|
+
fulfillmentRef: string;
|
|
68
|
+
preparedEvidence: Parameters<FulfillmentStorePort["recordProviderAttempt"]>[2];
|
|
69
|
+
mode: Parameters<FulfillmentStorePort["recordProviderAttempt"]>[3];
|
|
70
|
+
status: "recorded";
|
|
71
|
+
}[]>;
|
|
72
|
+
}>;
|
|
73
|
+
claim: Parameters<FulfillmentStorePort["claim"]>[0];
|
|
74
|
+
remappedClaim: Parameters<FulfillmentStorePort["claim"]>[0];
|
|
75
|
+
mappedAttemptKey: string;
|
|
76
|
+
remappedAttemptKey: string;
|
|
77
|
+
request: FulfillmentDispatchRequest;
|
|
78
|
+
remappedRequest: FulfillmentDispatchRequest;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Sanitized proof only: no fixture inputs, raw responses, transient URLs or credentials. */
|
|
82
|
+
export interface FulfillmentAdapterConformanceEvidence {
|
|
83
|
+
subjects: readonly {
|
|
84
|
+
subjectId: string;
|
|
85
|
+
providerRef: string;
|
|
86
|
+
}[];
|
|
87
|
+
cases: readonly {
|
|
88
|
+
subjectId: string;
|
|
89
|
+
operation: string;
|
|
90
|
+
passed: true;
|
|
91
|
+
}[];
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FulfillmentNativeUnsupported } from './nativeUnsupported.js';
|
|
2
|
+
export interface CustomerDeliveryAlignment {
|
|
3
|
+
state: 'protected' | 'aligned';
|
|
4
|
+
}
|
|
5
|
+
/** Absence from the map means no current customer case, distinct from protected. */
|
|
6
|
+
export type FulfillmentCustomerAlignmentRowsReader = (subscriptionIds: string[]) => Promise<Record<string, unknown>[] | FulfillmentNativeUnsupported>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
type DeliveryKind = "parcel-locker" | "courier";
|
|
2
|
+
type PickupPoint = {
|
|
3
|
+
id: string;
|
|
4
|
+
provider: string;
|
|
5
|
+
name: string;
|
|
6
|
+
address: {
|
|
7
|
+
line1: string;
|
|
8
|
+
postalCode: string;
|
|
9
|
+
city: string;
|
|
10
|
+
country: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export interface FulfillmentSelection {
|
|
14
|
+
providerRef: string | null;
|
|
15
|
+
carrierRef: string | null;
|
|
16
|
+
serviceRef: string | null;
|
|
17
|
+
deliveryKind: DeliveryKind;
|
|
18
|
+
pickupPoint: PickupPoint | null;
|
|
19
|
+
}
|
|
20
|
+
export interface FulfillmentRefusal {
|
|
21
|
+
reason: "not_dispatchable" | "selection_required" | "provider_mismatch" | "carrier_service_required" | "disabled" | "not_ready" | "unsupported" | "withheld" | "claim_conflict" | "contact_stale" | "stock_contention" | "local_missing" | "io_failure" | "malformed" | "untrusted" | "unsupported_event" | "stale" | "missing_correlation";
|
|
22
|
+
phase: "selection" | "prepare" | "claim" | "begin" | "dispatch" | "acknowledge" | "verify" | "normalize" | "apply" | "readback" | "sync";
|
|
23
|
+
retryable: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Frozen domain input, never copied into command evidence. Credentials stay in adapter closures. */
|
|
26
|
+
export interface FulfillmentDispatchRequest {
|
|
27
|
+
requestKey: string;
|
|
28
|
+
fulfillmentRef: string;
|
|
29
|
+
orderRef: string;
|
|
30
|
+
orderNumber: string | null;
|
|
31
|
+
parcelRef: string | null;
|
|
32
|
+
contactRevision: {
|
|
33
|
+
schemaVersion: number;
|
|
34
|
+
source: string;
|
|
35
|
+
revision: number;
|
|
36
|
+
};
|
|
37
|
+
recipient: {
|
|
38
|
+
name: string | null;
|
|
39
|
+
email: string | null;
|
|
40
|
+
phone: string | null;
|
|
41
|
+
line1: string;
|
|
42
|
+
line2: string | null;
|
|
43
|
+
city: string;
|
|
44
|
+
postalCode: string;
|
|
45
|
+
country: string;
|
|
46
|
+
deliveryInstructions: string | null;
|
|
47
|
+
courierInstructions: string | null;
|
|
48
|
+
};
|
|
49
|
+
lines: readonly {
|
|
50
|
+
skuRef: string;
|
|
51
|
+
title: string | null;
|
|
52
|
+
quantity: number;
|
|
53
|
+
productRef: string | null;
|
|
54
|
+
packRef: string | null;
|
|
55
|
+
}[];
|
|
56
|
+
selection: FulfillmentSelection;
|
|
57
|
+
}
|
|
58
|
+
/** Allowlisted durable evidence; fingerprint commits to actual adapter command bytes. */
|
|
59
|
+
export interface DispatchEvidence {
|
|
60
|
+
commandFingerprint: string;
|
|
61
|
+
contactRevision: FulfillmentDispatchRequest["contactRevision"];
|
|
62
|
+
providerRef: string;
|
|
63
|
+
carrierRef: string | null;
|
|
64
|
+
serviceRef: string | null;
|
|
65
|
+
}
|
|
66
|
+
export type FulfillmentDispatchResult = {
|
|
67
|
+
kind: "accepted";
|
|
68
|
+
externalRef: string;
|
|
69
|
+
evidence: DispatchEvidence;
|
|
70
|
+
providerAttemptKey: string;
|
|
71
|
+
labelKey: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: "not_dispatched";
|
|
74
|
+
effectMayHaveSucceeded: false;
|
|
75
|
+
refusal: FulfillmentRefusal;
|
|
76
|
+
} | {
|
|
77
|
+
kind: "unknown";
|
|
78
|
+
effectMayHaveSucceeded: true;
|
|
79
|
+
refusal: FulfillmentRefusal;
|
|
80
|
+
};
|
|
81
|
+
export type FulfillmentDispatchPrepareResult = {
|
|
82
|
+
kind: "prepared";
|
|
83
|
+
evidence: DispatchEvidence;
|
|
84
|
+
} | {
|
|
85
|
+
kind: "refused";
|
|
86
|
+
refusal: FulfillmentRefusal;
|
|
87
|
+
};
|
|
88
|
+
export interface FulfillmentDispatchPort {
|
|
89
|
+
/**
|
|
90
|
+
* Without external submission, build the actual command and fingerprint its bytes
|
|
91
|
+
* before store claim/begin. Return only sanitized evidence; keep the raw command
|
|
92
|
+
* transient inside the adapter. Refuse not_dispatchable or the exact selection
|
|
93
|
+
* refusal when preparation cannot proceed. A contact_stale remap requires a new
|
|
94
|
+
* prepare of the rebuilt request/command before another claim/begin.
|
|
95
|
+
*/
|
|
96
|
+
prepare(request: FulfillmentDispatchRequest): Promise<FulfillmentDispatchPrepareResult>;
|
|
97
|
+
/**
|
|
98
|
+
* Send exactly the prepared command identified by this evidence. Never silently
|
|
99
|
+
* rebuild a different command; absent/mismatched preparation refuses before I/O.
|
|
100
|
+
* Absent/mismatched preparation: not_dispatchable, phase dispatch, retryable false.
|
|
101
|
+
* Unknown submission outcomes require readback, never blind re-submission.
|
|
102
|
+
*/
|
|
103
|
+
dispatch(request: FulfillmentDispatchRequest, evidence: DispatchEvidence): Promise<FulfillmentDispatchResult>;
|
|
104
|
+
}
|
|
105
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type { DispatchEvidence, FulfillmentDispatchPrepareResult, FulfillmentSelection, FulfillmentDispatchRequest, FulfillmentDispatchResult, FulfillmentDispatchPort, FulfillmentRefusal } from "./dispatch.js";
|
|
2
|
+
export type { LabelDocument, FulfillmentLabelPort } from "./label.js";
|
|
3
|
+
/** G17 local reads/ingress persistence are inline runtime worker inputs; this provider envelope is unchanged. */
|
|
4
|
+
export type { FulfillmentObservation, FulfillmentObservationPort, FulfillmentTrackingReference } from "./observation.js";
|
|
5
|
+
export type { FulfillmentReadbackResult, FulfillmentReadbackPort } from "./readback.js";
|
|
6
|
+
export type { SyncCursor, StockSnapshot, StockMovement, LocalStock, FulfillmentStockSyncProvider, FulfillmentStockSyncPort, FulfillmentProductSyncProvider, FulfillmentProductSyncPort } from "./sync.js";
|
|
7
|
+
export type { FulfillmentCapabilityDescriptor } from "./capabilities.js";
|
|
8
|
+
export type { DispatchRecord, FulfillmentStorePort, FulfillmentPaidHandoffPort } from "./store.js";
|
|
9
|
+
export type { DeliveryAlignmentPort } from "./alignment.js";
|
|
10
|
+
export type { FulfillmentAdapterConformanceSubject, FulfillmentAdapterConformanceEvidence } from "./conformance.js";
|
|
11
|
+
export type { FulfillmentNativeUnsupported } from './nativeUnsupported.js';
|
|
12
|
+
export type { FulfillmentReplacementPort, FulfillmentReplacementRequest, FulfillmentReplacementResult } from './replacement.js';
|
|
13
|
+
export type { FulfillmentOperatorMutationPort, FulfillmentOperatorMutationResult } from './operator.js';
|
|
14
|
+
export type { CustomerDeliveryAlignment, FulfillmentCustomerAlignmentRowsReader } from './customerAlignment.js';
|
|
15
|
+
export type { FulfillmentCommerceReadPort, FulfillmentCommerceReadPolicy, FulfillmentOrderStatus, FulfillmentPaymentStatus, FulfillmentCommerceOrder, FulfillmentOrdersListRequest, FulfillmentOrdersListResponse, FulfillmentOrderDetailRequest, FulfillmentOrderDetailResponse, FulfillmentShipmentsOverviewPort, FulfillmentShipmentsOverviewRequest, FulfillmentShipmentsOverviewResponse } from './read.js';
|
|
16
|
+
export type { FulfillmentProgressInput, FulfillmentProgressPresentation } from './read.js';
|
|
17
|
+
export type { FulfillmentServicesOptions, FulfillmentServices } from './bindings.js';
|
|
18
|
+
export type { CanonicalLocalFulfillmentStatus, CustomerFulfillmentStep } from "@openlup/core/fulfillment";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { FulfillmentDispatchRequest, FulfillmentRefusal } from "./dispatch.js";
|
|
2
|
+
/** Durable storage pointer. No signed URL or credential belongs here. */
|
|
3
|
+
export interface LabelDocument {
|
|
4
|
+
objectRef: string;
|
|
5
|
+
mediaType: "application/pdf";
|
|
6
|
+
externalRef: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface FulfillmentLabelPort {
|
|
9
|
+
create(input: FulfillmentDispatchRequest): Promise<{
|
|
10
|
+
kind: "created";
|
|
11
|
+
parcelRef: string;
|
|
12
|
+
document: LabelDocument | null;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "refused";
|
|
15
|
+
refusal: FulfillmentRefusal;
|
|
16
|
+
}>;
|
|
17
|
+
/** Transient host response only; never part of a store record. */
|
|
18
|
+
read(document: LabelDocument): Promise<{
|
|
19
|
+
kind: "available";
|
|
20
|
+
url: string;
|
|
21
|
+
expiresAt: string | null;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "refused";
|
|
24
|
+
refusal: FulfillmentRefusal;
|
|
25
|
+
}>;
|
|
26
|
+
void(input: {
|
|
27
|
+
parcelRef: string;
|
|
28
|
+
document: LabelDocument | null;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
providerDeletion: "confirmed" | "unconfirmed";
|
|
31
|
+
labelDeleted: boolean;
|
|
32
|
+
canProceed: boolean;
|
|
33
|
+
refusal?: FulfillmentRefusal;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { NormalizedFulfillmentFact } from "@openlup/core/fulfillment";
|
|
2
|
+
import type { CanonicalLocalFulfillmentStatus } from "./index.js";
|
|
3
|
+
import type { FulfillmentRefusal } from "./dispatch.js";
|
|
4
|
+
export interface FulfillmentTrackingReference {
|
|
5
|
+
trackingNumber: string;
|
|
6
|
+
carrierRef: string | null;
|
|
7
|
+
serviceRef: string | null;
|
|
8
|
+
publicUrl: string | null;
|
|
9
|
+
}
|
|
10
|
+
/** Durable normalized envelope. eventKey, not the receivedAt-bearing fact fingerprint, deduplicates retries. */
|
|
11
|
+
export interface FulfillmentObservation {
|
|
12
|
+
fact: NormalizedFulfillmentFact<CanonicalLocalFulfillmentStatus>;
|
|
13
|
+
eventKind: "shipment.accepted" | "order.processing_started" | "order.picked" | "order.shipped" | "order.delivered" | "parcel.exception" | "parcel.cancelled";
|
|
14
|
+
eventKey: string;
|
|
15
|
+
firstReceivedAt: string;
|
|
16
|
+
correlation: {
|
|
17
|
+
orderRef: string | null;
|
|
18
|
+
fulfillmentRef: string | null;
|
|
19
|
+
externalRef: string | null;
|
|
20
|
+
orderNumber: string | null;
|
|
21
|
+
providerFulfillmentRef: string | null;
|
|
22
|
+
parcelRef: string | null;
|
|
23
|
+
};
|
|
24
|
+
trackingRefs: readonly FulfillmentTrackingReference[];
|
|
25
|
+
diagnostics?: {
|
|
26
|
+
refusal?: FulfillmentRefusal;
|
|
27
|
+
stockContention?: {
|
|
28
|
+
sqlState: "55P03";
|
|
29
|
+
phase: "provider_stock_consumed";
|
|
30
|
+
retryable: true;
|
|
31
|
+
};
|
|
32
|
+
annotation?: "recorded" | "failed";
|
|
33
|
+
recoveredPickedReceipt?: {
|
|
34
|
+
receiptRef: string;
|
|
35
|
+
closed: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface FulfillmentObservationPort {
|
|
40
|
+
/** Authenticate untouched bytes before parsing. Inputs live only during verification. */
|
|
41
|
+
verifyAndNormalize(input: {
|
|
42
|
+
rawBody: Uint8Array;
|
|
43
|
+
headers: Readonly<Record<string, string>>;
|
|
44
|
+
receivedAt: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
kind: "verified";
|
|
47
|
+
observation: FulfillmentObservation;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "refused";
|
|
50
|
+
refusal: FulfillmentRefusal;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { FulfillmentNativeUnsupported } from './nativeUnsupported.js';
|
|
2
|
+
/** Host transaction inputs. actorUserId and idempotencyKey are required for attribution and replay receipts. */
|
|
3
|
+
interface MutationInput {
|
|
4
|
+
idempotencyKey: string;
|
|
5
|
+
actorUserId: string;
|
|
6
|
+
metadata?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface ParcelMutationInput extends MutationInput {
|
|
9
|
+
fulfillmentOrderId: string;
|
|
10
|
+
}
|
|
11
|
+
type AdminCommerceFulfillmentCreateRequest = MutationInput & {
|
|
12
|
+
orderId: string;
|
|
13
|
+
};
|
|
14
|
+
type AdminCommerceFulfillmentRecordProviderAttemptRequest = ParcelMutationInput & {
|
|
15
|
+
providerKind: string;
|
|
16
|
+
status: 'recorded' | 'succeeded' | 'failed';
|
|
17
|
+
requestPayload?: Record<string, unknown>;
|
|
18
|
+
responsePayload?: Record<string, unknown>;
|
|
19
|
+
error?: string | null;
|
|
20
|
+
};
|
|
21
|
+
type AdminCommerceFulfillmentRecordLabelRequest = ParcelMutationInput & {
|
|
22
|
+
providerKind: string;
|
|
23
|
+
providerTrackingId: string;
|
|
24
|
+
labelUrl?: string | null;
|
|
25
|
+
deliveryEstimateDays?: number | null;
|
|
26
|
+
rawProviderPayload?: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
type AdminCommerceFulfillmentHandOffRequest = ParcelMutationInput;
|
|
29
|
+
type AdminCommerceFulfillmentTrackingEventRequest = ParcelMutationInput & {
|
|
30
|
+
status: 'in_transit' | 'delivered' | 'exception';
|
|
31
|
+
providerTrackingId?: string;
|
|
32
|
+
rawEvent?: Record<string, unknown>;
|
|
33
|
+
};
|
|
34
|
+
type AdminCommerceFulfillmentCancelRequest = ParcelMutationInput & {
|
|
35
|
+
reason: string;
|
|
36
|
+
};
|
|
37
|
+
export interface FulfillmentOperatorMutationResult {
|
|
38
|
+
contractVersion: 'commerce.fulfillment.v0';
|
|
39
|
+
fulfillmentOrderId: string;
|
|
40
|
+
orderId: string;
|
|
41
|
+
status: 'created' | 'packed' | 'label_pending' | 'label_created' | 'handed_over' | 'in_transit' | 'delivered' | 'exception' | 'cancelled';
|
|
42
|
+
replayed: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface FulfillmentOperatorMutationPort {
|
|
45
|
+
createCommerceFulfillmentOrder(request: AdminCommerceFulfillmentCreateRequest & {
|
|
46
|
+
actorUserId: string;
|
|
47
|
+
}): Promise<FulfillmentOperatorMutationResult | FulfillmentNativeUnsupported>;
|
|
48
|
+
recordCommerceFulfillmentProviderAttempt(request: AdminCommerceFulfillmentRecordProviderAttemptRequest & {
|
|
49
|
+
actorUserId: string;
|
|
50
|
+
}): Promise<FulfillmentOperatorMutationResult | FulfillmentNativeUnsupported>;
|
|
51
|
+
recordCommerceFulfillmentLabel(request: AdminCommerceFulfillmentRecordLabelRequest & {
|
|
52
|
+
actorUserId: string;
|
|
53
|
+
}): Promise<FulfillmentOperatorMutationResult | FulfillmentNativeUnsupported>;
|
|
54
|
+
handOffCommerceFulfillmentOrder(request: AdminCommerceFulfillmentHandOffRequest & {
|
|
55
|
+
actorUserId: string;
|
|
56
|
+
}): Promise<FulfillmentOperatorMutationResult | FulfillmentNativeUnsupported>;
|
|
57
|
+
recordCommerceFulfillmentTrackingEvent(request: AdminCommerceFulfillmentTrackingEventRequest & {
|
|
58
|
+
actorUserId: string;
|
|
59
|
+
}): Promise<FulfillmentOperatorMutationResult | FulfillmentNativeUnsupported>;
|
|
60
|
+
cancelCommerceFulfillmentOrder(request: AdminCommerceFulfillmentCancelRequest & {
|
|
61
|
+
actorUserId: string;
|
|
62
|
+
}): Promise<FulfillmentOperatorMutationResult | FulfillmentNativeUnsupported>;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|