@pisell/private-materials 6.12.167 → 6.12.169
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +10 -10
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +10 -10
- package/es/components/HDLKiosk/{contracts → app/contracts}/config.js +1 -1
- package/es/components/HDLKiosk/app/manifest.js +11 -11
- package/es/components/HDLKiosk/app/operations.js +92 -0
- package/es/components/HDLKiosk/app/workflow/barcode.js +11 -13
- package/es/components/HDLKiosk/app/workflow/index.js +16 -0
- package/es/components/HDLKiosk/app/workflow/predicates.js +1 -1
- package/es/components/HDLKiosk/app/workflow/quick.js +1 -1
- package/es/components/HDLKiosk/app/workflow/registry.js +4 -4
- package/es/components/HDLKiosk/app/workflow/scale.js +5 -1
- package/es/components/HDLKiosk/docs/00-/346/226/207/344/273/266/345/257/274/350/210/252.md +104 -167
- package/es/components/HDLKiosk/docs/01-/346/240/270/345/277/203/350/277/220/350/241/214/346/234/272/345/210/266.md +105 -101
- package/es/components/HDLKiosk/docs/03-/344/270/232/345/212/241/346/265/201/347/250/213/344/270/216/344/272/244/344/272/222/350/247/204/345/210/231.md +2 -2
- package/es/components/HDLKiosk/docs/04-/350/256/276/345/244/207/344/270/216/347/247/260/351/207/215.md +43 -26
- package/es/components/HDLKiosk/docs/05-/344/272/244/346/230/223/345/256/211/345/205/250.md +2 -0
- package/es/components/HDLKiosk/docs/07-/345/220/216/347/273/255/345/267/245/344/275/234.md +1 -1
- package/es/components/HDLKiosk/docs/08-/346/227/240/345/244/264Application/350/277/220/350/241/214/346/227/266/351/207/215/346/236/204/350/256/276/350/256/241.md +719 -0
- package/es/components/HDLKiosk/docs/09-Entry/350/256/276/345/244/207/344/272/213/344/273/266/351/207/215/346/236/204/344/277/256/345/244/215/346/212/245/345/221/212.md +187 -0
- package/es/components/HDLKiosk/docs/README.md +6 -2
- package/es/components/HDLKiosk/docs//345/256/236/346/226/275/350/277/233/345/272/246.md +8 -7
- package/es/components/HDLKiosk/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +16 -18
- package/es/components/HDLKiosk/index.js +22 -28
- package/es/components/HDLKiosk/index.less +1 -1
- package/es/components/HDLKiosk/kernel/README.md +14 -13
- package/es/components/HDLKiosk/kernel/application/defineApplication.js +63 -24
- package/es/components/HDLKiosk/kernel/application/defineSlice.js +6 -6
- package/es/components/HDLKiosk/kernel/application/runtime.js +237 -0
- package/es/components/HDLKiosk/kernel/operations/coordinator.js +1 -1
- package/es/components/HDLKiosk/kernel/operations/registry.js +3 -3
- package/es/components/HDLKiosk/kernel/operations/sessionEpoch.js +1 -1
- package/es/components/HDLKiosk/kernel/operations/types.js +7 -3
- package/es/components/HDLKiosk/kernel/workflow/actor.js +51 -22
- package/es/components/HDLKiosk/kernel/workflow/compiler.js +23 -30
- package/es/components/HDLKiosk/runtime/createRuntime.js +238 -0
- package/es/components/HDLKiosk/{devices → runtime/devices}/dedupeStore.js +1 -1
- package/es/components/HDLKiosk/{devices → runtime/devices}/scaleIngress.js +1 -1
- package/es/components/HDLKiosk/{devices/scale/runtime.js → runtime/devices/scaleStore.js} +18 -24
- package/es/components/HDLKiosk/{devices → runtime/devices}/scannerIngress.js +1 -1
- package/es/components/HDLKiosk/runtime/devices/scannerSessionPort.js +60 -0
- package/es/components/HDLKiosk/runtime/devices/scannerSessionRouter.js +212 -0
- package/es/components/HDLKiosk/runtime/operations/barcode.js +18 -0
- package/es/components/HDLKiosk/runtime/operations/cart.js +44 -0
- package/es/components/HDLKiosk/{app → runtime}/operations/cartConsistency.js +1 -1
- package/es/components/HDLKiosk/{app → runtime}/operations/checkout.js +95 -110
- package/es/components/HDLKiosk/{app → runtime}/operations/checkoutRequirements.js +1 -1
- package/es/components/HDLKiosk/{app → runtime}/operations/checkoutSafety.js +1 -1
- package/es/components/HDLKiosk/{app → runtime}/operations/coordinator.js +2 -2
- package/es/components/HDLKiosk/runtime/operations/customization.js +70 -0
- package/es/components/HDLKiosk/{app → runtime}/operations/errors.js +1 -1
- package/es/components/HDLKiosk/runtime/operations/fulfillment.js +6 -0
- package/es/components/HDLKiosk/runtime/operations/identity.js +55 -0
- package/es/components/HDLKiosk/runtime/operations/registry.js +34 -0
- package/es/components/HDLKiosk/runtime/operations/session.js +29 -0
- package/es/components/HDLKiosk/runtime/operations/types.js +13 -0
- package/es/components/HDLKiosk/runtime/session/blockPolicy.js +14 -0
- package/es/components/HDLKiosk/runtime/{createWorkflowSession.js → session/createSession.js} +67 -17
- package/es/components/HDLKiosk/runtime/{domainTransitionRunner.js → session/transitionRunner.js} +10 -5
- package/es/components/HDLKiosk/runtime/{workflowContext.js → session/workflowContext.js} +2 -2
- package/es/components/HDLKiosk/runtime/{workflowLifecycle.js → session/workflowLifecycle.js} +2 -2
- package/es/components/HDLKiosk/runtime/triggers.js +28 -0
- package/es/components/HDLKiosk/slices/catalog/Screen/index.js +15 -8
- package/es/components/HDLKiosk/slices/catalog/Screen/index.less +74 -13
- package/es/components/HDLKiosk/slices/catalog/slice.js +2 -2
- package/es/components/HDLKiosk/slices/customization/Screen/index.js +37 -38
- package/es/components/HDLKiosk/slices/customization/Screen/index.less +5 -0
- package/es/components/HDLKiosk/slices/customization/slice.js +3 -4
- package/es/components/HDLKiosk/slices/fulfillment/slice.js +2 -2
- package/es/components/HDLKiosk/slices/fulfillment/view.js +1 -1
- package/es/components/HDLKiosk/slices/identity/Screen/index.js +2 -2
- package/es/components/HDLKiosk/slices/identity/slice.js +3 -3
- package/es/components/HDLKiosk/slices/identity/view.js +1 -1
- package/es/components/HDLKiosk/slices/payment/slice.js +3 -3
- package/es/components/HDLKiosk/slices/primaryProductPrompt/slice.js +2 -2
- package/es/components/HDLKiosk/slices/primaryProductPrompt/view.js +2 -2
- package/es/components/HDLKiosk/{runtime → ui}/HDLKioskWorkflowView.js +45 -131
- package/es/components/HDLKiosk/ui/ScaleSimulatorConsole/index.js +387 -0
- package/es/components/HDLKiosk/ui/ScaleSimulatorConsole/index.less +621 -0
- package/es/components/HDLKiosk/{app → ui}/ScreenRenderer.js +7 -7
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskActionDispatcher.js +66 -0
- package/es/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskCustomerController.js +1 -1
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskDeviceController.js +25 -0
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskExitController.js +53 -0
- package/es/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskScreenData.js +1 -1
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.js +39 -0
- package/es/components/HDLKiosk/{app → ui}/entry/Screen/index.js +8 -6
- package/es/components/HDLKiosk/{app → ui}/entry/model.js +2 -2
- package/es/components/HDLKiosk/ui/scale.js +20 -0
- package/es/components/HDLKiosk/{runtime/useHostSnapshot.js → ui/snapshots.js} +6 -8
- package/es/components/HDLKiosk/{app → ui}/views.js +1 -1
- package/es/components/HDLKiosk/{runtime → ui}/workflowEvent.js +1 -1
- package/es/components/HDLKiosk/utils.js +4 -4
- package/es/components/bigSale/templates/HDLKiosk/adapter/HDLKioskPaymentRuntime.js +2 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/capabilities.js +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/projection.js +21 -11
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales.js +21 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/scaleTrigger.js +20 -5
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +3 -0
- package/es/components/bigSale/templates/HDLKiosk/index.js +3 -3
- package/lib/components/HDLKiosk/{contracts → app/contracts}/config.js +1 -1
- package/lib/components/HDLKiosk/app/manifest.js +18 -19
- package/lib/components/HDLKiosk/app/operations.js +105 -0
- package/lib/components/HDLKiosk/app/workflow/barcode.js +11 -13
- package/lib/components/HDLKiosk/app/workflow/index.js +16 -0
- package/lib/components/HDLKiosk/app/workflow/predicates.js +1 -0
- package/lib/components/HDLKiosk/app/workflow/quick.js +1 -1
- package/lib/components/HDLKiosk/app/workflow/registry.js +3 -3
- package/lib/components/HDLKiosk/app/workflow/scale.js +5 -1
- package/lib/components/HDLKiosk/docs/00-/346/226/207/344/273/266/345/257/274/350/210/252.md +104 -167
- package/lib/components/HDLKiosk/docs/01-/346/240/270/345/277/203/350/277/220/350/241/214/346/234/272/345/210/266.md +105 -101
- package/lib/components/HDLKiosk/docs/03-/344/270/232/345/212/241/346/265/201/347/250/213/344/270/216/344/272/244/344/272/222/350/247/204/345/210/231.md +2 -2
- package/lib/components/HDLKiosk/docs/04-/350/256/276/345/244/207/344/270/216/347/247/260/351/207/215.md +43 -26
- package/lib/components/HDLKiosk/docs/05-/344/272/244/346/230/223/345/256/211/345/205/250.md +2 -0
- package/lib/components/HDLKiosk/docs/07-/345/220/216/347/273/255/345/267/245/344/275/234.md +1 -1
- package/lib/components/HDLKiosk/docs/08-/346/227/240/345/244/264Application/350/277/220/350/241/214/346/227/266/351/207/215/346/236/204/350/256/276/350/256/241.md +719 -0
- package/lib/components/HDLKiosk/docs/09-Entry/350/256/276/345/244/207/344/272/213/344/273/266/351/207/215/346/236/204/344/277/256/345/244/215/346/212/245/345/221/212.md +187 -0
- package/lib/components/HDLKiosk/docs/README.md +6 -2
- package/lib/components/HDLKiosk/docs//345/256/236/346/226/275/350/277/233/345/272/246.md +8 -7
- package/lib/components/HDLKiosk/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +16 -18
- package/lib/components/HDLKiosk/index.js +25 -31
- package/lib/components/HDLKiosk/index.less +1 -1
- package/lib/components/HDLKiosk/kernel/README.md +14 -13
- package/lib/components/HDLKiosk/kernel/application/defineApplication.js +65 -25
- package/lib/components/HDLKiosk/kernel/application/defineSlice.js +6 -6
- package/lib/components/HDLKiosk/kernel/application/runtime.js +237 -0
- package/lib/components/HDLKiosk/kernel/operations/coordinator.js +1 -1
- package/lib/components/HDLKiosk/kernel/operations/registry.js +3 -3
- package/lib/components/HDLKiosk/kernel/operations/sessionEpoch.js +1 -1
- package/lib/components/HDLKiosk/kernel/operations/types.js +8 -3
- package/lib/components/HDLKiosk/kernel/workflow/actor.js +51 -22
- package/lib/components/HDLKiosk/kernel/workflow/compiler.js +23 -30
- package/lib/components/HDLKiosk/runtime/createRuntime.js +239 -0
- package/lib/components/HDLKiosk/{devices → runtime/devices}/dedupeStore.js +1 -1
- package/lib/components/HDLKiosk/{devices → runtime/devices}/scaleIngress.js +1 -1
- package/lib/components/HDLKiosk/{devices/scale/runtime.js → runtime/devices/scaleStore.js} +17 -27
- package/lib/components/HDLKiosk/{devices → runtime/devices}/scannerIngress.js +1 -1
- package/lib/components/HDLKiosk/runtime/devices/scannerSessionPort.js +60 -0
- package/lib/components/HDLKiosk/runtime/devices/scannerSessionRouter.js +212 -0
- package/lib/components/HDLKiosk/runtime/operations/barcode.js +17 -0
- package/lib/components/HDLKiosk/runtime/operations/cart.js +46 -0
- package/lib/components/HDLKiosk/{app → runtime}/operations/cartConsistency.js +1 -1
- package/lib/components/HDLKiosk/{app → runtime}/operations/checkout.js +97 -112
- package/lib/components/HDLKiosk/{app → runtime}/operations/checkoutRequirements.js +1 -1
- package/lib/components/HDLKiosk/{app → runtime}/operations/checkoutSafety.js +1 -1
- package/lib/components/HDLKiosk/{app → runtime}/operations/coordinator.js +2 -2
- package/lib/components/HDLKiosk/runtime/operations/customization.js +73 -0
- package/lib/components/HDLKiosk/{app → runtime}/operations/errors.js +1 -1
- package/lib/components/HDLKiosk/runtime/operations/fulfillment.js +5 -0
- package/lib/components/HDLKiosk/runtime/operations/identity.js +55 -0
- package/lib/components/HDLKiosk/runtime/operations/registry.js +34 -0
- package/lib/components/HDLKiosk/runtime/operations/session.js +30 -0
- package/lib/components/HDLKiosk/runtime/operations/types.js +14 -0
- package/lib/components/HDLKiosk/runtime/session/blockPolicy.js +14 -0
- package/lib/components/HDLKiosk/runtime/{createWorkflowSession.js → session/createSession.js} +71 -21
- package/lib/components/HDLKiosk/runtime/{domainTransitionRunner.js → session/transitionRunner.js} +10 -5
- package/lib/components/HDLKiosk/runtime/{workflowContext.js → session/workflowContext.js} +2 -2
- package/lib/components/HDLKiosk/runtime/{workflowLifecycle.js → session/workflowLifecycle.js} +2 -2
- package/lib/components/HDLKiosk/runtime/triggers.js +28 -0
- package/lib/components/HDLKiosk/slices/catalog/Screen/index.js +15 -8
- package/lib/components/HDLKiosk/slices/catalog/Screen/index.less +74 -13
- package/lib/components/HDLKiosk/slices/catalog/slice.js +3 -3
- package/lib/components/HDLKiosk/slices/customization/Screen/index.js +38 -39
- package/lib/components/HDLKiosk/slices/customization/Screen/index.less +5 -0
- package/lib/components/HDLKiosk/slices/customization/slice.js +5 -6
- package/lib/components/HDLKiosk/slices/fulfillment/slice.js +3 -3
- package/lib/components/HDLKiosk/slices/fulfillment/view.js +1 -1
- package/lib/components/HDLKiosk/slices/identity/Screen/index.js +2 -2
- package/lib/components/HDLKiosk/slices/identity/slice.js +4 -4
- package/lib/components/HDLKiosk/slices/identity/view.js +1 -1
- package/lib/components/HDLKiosk/slices/payment/slice.js +5 -5
- package/lib/components/HDLKiosk/slices/primaryProductPrompt/slice.js +2 -2
- package/lib/components/HDLKiosk/slices/primaryProductPrompt/view.js +2 -2
- package/lib/components/HDLKiosk/{runtime → ui}/HDLKioskWorkflowView.js +46 -132
- package/lib/components/HDLKiosk/ui/ScaleSimulatorConsole/index.js +390 -0
- package/lib/components/HDLKiosk/ui/ScaleSimulatorConsole/index.less +621 -0
- package/lib/components/HDLKiosk/{app → ui}/ScreenRenderer.js +7 -7
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskActionDispatcher.js +67 -0
- package/lib/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskCustomerController.js +1 -1
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskDeviceController.js +26 -0
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskExitController.js +54 -0
- package/lib/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskScreenData.js +1 -1
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.js +40 -0
- package/lib/components/HDLKiosk/{app → ui}/entry/Screen/index.js +8 -6
- package/lib/components/HDLKiosk/{app → ui}/entry/model.js +2 -2
- package/lib/components/HDLKiosk/ui/scale.js +24 -0
- package/lib/components/HDLKiosk/{runtime/useHostSnapshot.js → ui/snapshots.js} +6 -7
- package/lib/components/HDLKiosk/{app → ui}/views.js +1 -1
- package/lib/components/HDLKiosk/{runtime → ui}/workflowEvent.js +1 -1
- package/lib/components/HDLKiosk/utils.js +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/HDLKioskPaymentRuntime.js +2 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/capabilities.js +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/projection.js +21 -10
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales.js +20 -2
- package/lib/components/bigSale/templates/HDLKiosk/adapter/scaleTrigger.js +19 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +3 -0
- package/lib/components/bigSale/templates/HDLKiosk/index.js +4 -4
- package/package.json +2 -2
- package/es/components/HDLKiosk/app/constants.js +0 -9
- package/es/components/HDLKiosk/app/operations/barcode.js +0 -22
- package/es/components/HDLKiosk/app/operations/cart.js +0 -60
- package/es/components/HDLKiosk/app/operations/fulfillment.js +0 -11
- package/es/components/HDLKiosk/app/operations/session.js +0 -41
- package/es/components/HDLKiosk/app/operations/types.js +0 -11
- package/es/components/HDLKiosk/devices/entryArbiter.js +0 -33
- package/es/components/HDLKiosk/runtime/controllers/useHDLKioskDeviceController.js +0 -75
- package/es/components/HDLKiosk/runtime/controllers/useHDLKioskScannerController.js +0 -160
- package/es/components/HDLKiosk/runtime/controllers/useHDLKioskSessionController.js +0 -185
- package/es/components/HDLKiosk/runtime/useWorkflowSnapshot.js +0 -12
- package/es/components/HDLKiosk/slices/customization/operation.js +0 -80
- package/es/components/HDLKiosk/slices/identity/operation.js +0 -60
- package/lib/components/HDLKiosk/app/constants.js +0 -9
- package/lib/components/HDLKiosk/app/operations/barcode.js +0 -21
- package/lib/components/HDLKiosk/app/operations/cart.js +0 -62
- package/lib/components/HDLKiosk/app/operations/fulfillment.js +0 -10
- package/lib/components/HDLKiosk/app/operations/session.js +0 -42
- package/lib/components/HDLKiosk/app/operations/types.js +0 -12
- package/lib/components/HDLKiosk/devices/entryArbiter.js +0 -33
- package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskDeviceController.js +0 -76
- package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskScannerController.js +0 -161
- package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskSessionController.js +0 -186
- package/lib/components/HDLKiosk/runtime/useWorkflowSnapshot.js +0 -13
- package/lib/components/HDLKiosk/slices/customization/operation.js +0 -83
- package/lib/components/HDLKiosk/slices/identity/operation.js +0 -60
- /package/es/components/HDLKiosk/{app → ui}/entry/Screen/index.less +0 -0
- /package/lib/components/HDLKiosk/{app → ui}/entry/Screen/index.less +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/devices/scannerSessionPort.ts
|
|
3
|
+
const NON_WRITABLE_ACTIVITIES = new Set(["paymentCompleted"]);
|
|
4
|
+
const PAYMENT_OPERATION_IDS = new Set([
|
|
5
|
+
"checkout.open",
|
|
6
|
+
"checkout.payEftpos",
|
|
7
|
+
"checkout.requestStaffPaymentApproval",
|
|
8
|
+
"session.reset"
|
|
9
|
+
]);
|
|
10
|
+
function isPaymentFrozen(host) {
|
|
11
|
+
const status = host.sales.getObservedSnapshot().payment.status;
|
|
12
|
+
return status === "pending" || status === "unknown" || status === "succeeded";
|
|
13
|
+
}
|
|
14
|
+
function isHDLKioskSessionCartWritable(session) {
|
|
15
|
+
var _session$definition$n;
|
|
16
|
+
const snapshot = session.actor.getSnapshot();
|
|
17
|
+
if (snapshot.status === "blocked" || snapshot.status === "finished") return false;
|
|
18
|
+
const activity = (_session$definition$n = session.definition.nodes[snapshot.nodeId]) === null || _session$definition$n === void 0 ? void 0 : _session$definition$n.activity;
|
|
19
|
+
if (!activity || NON_WRITABLE_ACTIVITIES.has(activity)) return false;
|
|
20
|
+
return !(snapshot.activeOperation && PAYMENT_OPERATION_IDS.has(snapshot.activeOperation.definitionId));
|
|
21
|
+
}
|
|
22
|
+
function createHDLKioskScannerSessionPort(host, session) {
|
|
23
|
+
return Object.freeze({
|
|
24
|
+
id: session.id,
|
|
25
|
+
sessionEpoch: () => session.actor.getSnapshot().sessionEpoch,
|
|
26
|
+
decideConsume: () => {
|
|
27
|
+
if (isPaymentFrozen(host)) return {
|
|
28
|
+
status: "rejected",
|
|
29
|
+
reason: "paymentFrozen"
|
|
30
|
+
};
|
|
31
|
+
return isHDLKioskSessionCartWritable(session) ? { status: "accepted" } : {
|
|
32
|
+
status: "rejected",
|
|
33
|
+
reason: "sessionNotCartWritable"
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
beforeConsume: () => {
|
|
37
|
+
const pendingNavigation = session.actor.getSnapshot().pendingNavigation;
|
|
38
|
+
if (pendingNavigation) session.actor.resolvePendingNavigation(pendingNavigation.navigationId, "cancel");
|
|
39
|
+
},
|
|
40
|
+
consume: function() {
|
|
41
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* ({ code, eventId }) {
|
|
42
|
+
const sessionEpoch = session.actor.getSnapshot().sessionEpoch;
|
|
43
|
+
const result = yield session.executeCommand("barcode.consume", { code }, `scan:${sessionEpoch}:${eventId}`);
|
|
44
|
+
if (result.status === "succeeded") return {
|
|
45
|
+
operationStatus: result.status,
|
|
46
|
+
queueDirective: result.data.code === "requiresSelection" ? "pauseForSelection" : "continue"
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
operationStatus: result.status,
|
|
50
|
+
queueDirective: result.status === "partialFailure" || result.status === "unknown" ? "stopUncertain" : "continue"
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return function consume(_x) {
|
|
54
|
+
return _ref.apply(this, arguments);
|
|
55
|
+
};
|
|
56
|
+
}()
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
exports.createHDLKioskScannerSessionPort = createHDLKioskScannerSessionPort;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
const require_scannerIngress = require("./scannerIngress.js");
|
|
3
|
+
//#region src/components/HDLKiosk/runtime/devices/scannerSessionRouter.ts
|
|
4
|
+
function createScannerSessionRouter({ host, entrySupported, maxPendingEvents = 5 }) {
|
|
5
|
+
const ingress = require_scannerIngress.createScannerIngress({ maxPendingEvents });
|
|
6
|
+
let phase = "idle";
|
|
7
|
+
let activeStartId;
|
|
8
|
+
let listening = false;
|
|
9
|
+
let session;
|
|
10
|
+
let queue = [];
|
|
11
|
+
let currentTask;
|
|
12
|
+
let processing = false;
|
|
13
|
+
let generation = 0;
|
|
14
|
+
let rejectionSequence = 0;
|
|
15
|
+
const emitRejected = (task, reason) => {
|
|
16
|
+
rejectionSequence += 1;
|
|
17
|
+
try {
|
|
18
|
+
host.telemetry.emit({
|
|
19
|
+
name: "hdlKiosk.device.eventRejected",
|
|
20
|
+
traceId: `hdl-scanner-rejected-${rejectionSequence}`,
|
|
21
|
+
occurredAt: Date.now(),
|
|
22
|
+
attributes: {
|
|
23
|
+
eventType: task.event.type,
|
|
24
|
+
eventId: task.event.eventId,
|
|
25
|
+
reason
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
} catch (_unused) {}
|
|
29
|
+
};
|
|
30
|
+
const rejectQueue = (reason) => {
|
|
31
|
+
const rejected = queue;
|
|
32
|
+
queue = [];
|
|
33
|
+
rejected.forEach((task) => emitRejected(task, reason));
|
|
34
|
+
};
|
|
35
|
+
const emitCompleted = (task, target, result, stale) => {
|
|
36
|
+
try {
|
|
37
|
+
host.telemetry.emit({
|
|
38
|
+
name: "hdlKiosk.scanner.taskFinished",
|
|
39
|
+
traceId: `hdl-scan:${target.sessionEpoch()}:${task.event.eventId}`,
|
|
40
|
+
occurredAt: Date.now(),
|
|
41
|
+
attributes: {
|
|
42
|
+
eventId: task.event.eventId,
|
|
43
|
+
sessionEpoch: target.sessionEpoch(),
|
|
44
|
+
status: result.operationStatus,
|
|
45
|
+
stale
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
} catch (_unused2) {}
|
|
49
|
+
};
|
|
50
|
+
const processQueue = function() {
|
|
51
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
|
|
52
|
+
if (processing || phase !== "active" || !listening || !session) return;
|
|
53
|
+
processing = true;
|
|
54
|
+
const processGeneration = generation;
|
|
55
|
+
try {
|
|
56
|
+
while (phase === "active" && listening && generation === processGeneration && session && queue.length > 0) {
|
|
57
|
+
const target = session;
|
|
58
|
+
const task = queue.shift();
|
|
59
|
+
if (!task) continue;
|
|
60
|
+
const decision = target.decideConsume();
|
|
61
|
+
if (decision.status === "rejected") {
|
|
62
|
+
emitRejected(task, decision.reason);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
let result;
|
|
66
|
+
try {
|
|
67
|
+
var _target$beforeConsume;
|
|
68
|
+
(_target$beforeConsume = target.beforeConsume) === null || _target$beforeConsume === void 0 || _target$beforeConsume.call(target);
|
|
69
|
+
currentTask = task;
|
|
70
|
+
result = yield target.consume({
|
|
71
|
+
eventId: task.event.eventId,
|
|
72
|
+
code: task.code
|
|
73
|
+
});
|
|
74
|
+
} catch (_unused3) {
|
|
75
|
+
currentTask = void 0;
|
|
76
|
+
emitRejected(task, "scanExecutionFailed");
|
|
77
|
+
rejectQueue("previousScanExecutionFailed");
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
currentTask = void 0;
|
|
81
|
+
const stale = generation !== processGeneration || phase !== "active" || !listening || session !== target;
|
|
82
|
+
emitCompleted(task, target, result, stale);
|
|
83
|
+
if (stale) break;
|
|
84
|
+
if (result.queueDirective === "pauseForSelection") {
|
|
85
|
+
rejectQueue("barcodeSelectionPending");
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (result.queueDirective === "stopUncertain") {
|
|
89
|
+
rejectQueue("previousScanResultUncertain");
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
} finally {
|
|
94
|
+
currentTask = void 0;
|
|
95
|
+
processing = false;
|
|
96
|
+
if (phase === "active" && listening && queue.length > 0) processQueue();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return function processQueue() {
|
|
100
|
+
return _ref.apply(this, arguments);
|
|
101
|
+
};
|
|
102
|
+
}();
|
|
103
|
+
const beginSessionStart = (startId) => {
|
|
104
|
+
if (!startId.trim() || phase === "disposed" || phase === "active") return false;
|
|
105
|
+
if (phase === "starting") return activeStartId === startId;
|
|
106
|
+
phase = "starting";
|
|
107
|
+
activeStartId = startId;
|
|
108
|
+
return true;
|
|
109
|
+
};
|
|
110
|
+
const failSessionStart = (startId, reason = "sessionStartFailed") => {
|
|
111
|
+
if (phase !== "starting" || activeStartId !== startId) return false;
|
|
112
|
+
generation += 1;
|
|
113
|
+
rejectQueue(reason);
|
|
114
|
+
activeStartId = void 0;
|
|
115
|
+
session = void 0;
|
|
116
|
+
phase = "idle";
|
|
117
|
+
return true;
|
|
118
|
+
};
|
|
119
|
+
const triggerAdapter = Object.freeze({
|
|
120
|
+
trigger: "onScan",
|
|
121
|
+
activate: ({ emit }) => {
|
|
122
|
+
if (phase === "disposed") return void 0;
|
|
123
|
+
listening = true;
|
|
124
|
+
const unsubscribe = host.devices.subscribe((event) => {
|
|
125
|
+
if (!listening || phase === "disposed" || event.type !== "barcode") return;
|
|
126
|
+
const target = session;
|
|
127
|
+
const decision = target === null || target === void 0 ? void 0 : target.decideConsume();
|
|
128
|
+
const rejectedReason = (decision === null || decision === void 0 ? void 0 : decision.status) === "rejected" ? decision.reason : void 0;
|
|
129
|
+
const result = ingress.accept(event, {
|
|
130
|
+
active: listening,
|
|
131
|
+
supported: host.capabilities.scanner.available && (phase !== "idle" || entrySupported),
|
|
132
|
+
workflowLocked: false,
|
|
133
|
+
nodeAcceptsEvent: phase !== "active" || (decision === null || decision === void 0 ? void 0 : decision.status) === "accepted" || rejectedReason === "paymentFrozen",
|
|
134
|
+
paymentFrozen: phase === "active" && rejectedReason === "paymentFrozen",
|
|
135
|
+
pendingEventCount: queue.length + (currentTask ? 1 : 0)
|
|
136
|
+
});
|
|
137
|
+
if (result.status === "rejected") {
|
|
138
|
+
emitRejected({
|
|
139
|
+
event,
|
|
140
|
+
code: event.code
|
|
141
|
+
}, result.reason);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const task = {
|
|
145
|
+
event: result.event,
|
|
146
|
+
code: result.code
|
|
147
|
+
};
|
|
148
|
+
queue.push(task);
|
|
149
|
+
if (phase === "active") {
|
|
150
|
+
processQueue();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (phase === "starting") return;
|
|
154
|
+
const startId = `device:scanner:${result.event.eventId}`;
|
|
155
|
+
if (!beginSessionStart(startId)) {
|
|
156
|
+
queue.pop();
|
|
157
|
+
emitRejected(task, "sessionStartConflict");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
emit({
|
|
161
|
+
channel: "product",
|
|
162
|
+
occurrenceId: result.event.eventId,
|
|
163
|
+
correlationId: startId
|
|
164
|
+
}).then((startResult) => {
|
|
165
|
+
if (startResult.status === "rejected") failSessionStart(startId, startResult.reason);
|
|
166
|
+
}).catch(() => failSessionStart(startId, "sessionStartFailed"));
|
|
167
|
+
}, { sources: ["scanner"] });
|
|
168
|
+
return () => {
|
|
169
|
+
listening = false;
|
|
170
|
+
generation += 1;
|
|
171
|
+
rejectQueue("inactive");
|
|
172
|
+
if (phase === "starting" && activeStartId) failSessionStart(activeStartId, "inactive");
|
|
173
|
+
unsubscribe();
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return Object.freeze({
|
|
178
|
+
triggerAdapter,
|
|
179
|
+
beginSessionStart,
|
|
180
|
+
bindSession: (startId, nextSession) => {
|
|
181
|
+
if (phase !== "starting" || activeStartId !== startId) return false;
|
|
182
|
+
activeStartId = void 0;
|
|
183
|
+
session = nextSession;
|
|
184
|
+
phase = "active";
|
|
185
|
+
processQueue();
|
|
186
|
+
return true;
|
|
187
|
+
},
|
|
188
|
+
failSessionStart,
|
|
189
|
+
releaseSession: (sessionId) => {
|
|
190
|
+
if ((session === null || session === void 0 ? void 0 : session.id) !== sessionId) return false;
|
|
191
|
+
generation += 1;
|
|
192
|
+
rejectQueue("sessionDisposed");
|
|
193
|
+
activeStartId = void 0;
|
|
194
|
+
session = void 0;
|
|
195
|
+
phase = "idle";
|
|
196
|
+
ingress.reset();
|
|
197
|
+
return true;
|
|
198
|
+
},
|
|
199
|
+
dispose: () => {
|
|
200
|
+
if (phase === "disposed") return;
|
|
201
|
+
generation += 1;
|
|
202
|
+
rejectQueue("inactive");
|
|
203
|
+
activeStartId = void 0;
|
|
204
|
+
session = void 0;
|
|
205
|
+
listening = false;
|
|
206
|
+
phase = "disposed";
|
|
207
|
+
ingress.reset();
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
exports.createScannerSessionRouter = createScannerSessionRouter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
const require_operations = require("../../app/operations.js");
|
|
3
|
+
const require_cartConsistency = require("./cartConsistency.js");
|
|
4
|
+
//#region src/components/HDLKiosk/runtime/operations/barcode.ts
|
|
5
|
+
const barcodeConsumeOperationBinding = require("./types.js").bindOperation(require_operations.barcodeConsumeOperation, { execute: function() {
|
|
6
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
7
|
+
const beforeFingerprint = context.host.sales.getObservedSnapshot().fingerprint.value;
|
|
8
|
+
const mutation = yield context.host.sales.consumeBarcode(input.code, signal);
|
|
9
|
+
if (mutation.status === "succeeded" && mutation.data.code === "requiresSelection") return mutation;
|
|
10
|
+
return require_cartConsistency.finalizeCartMutation(context, mutation, signal, () => mutation.status === "succeeded" && mutation.data.code === "added" && mutation.data.cartChangeConfirmed === true || context.host.sales.getObservedSnapshot().fingerprint.value !== beforeFingerprint);
|
|
11
|
+
});
|
|
12
|
+
return function execute(_x, _x2, _x3) {
|
|
13
|
+
return _ref.apply(this, arguments);
|
|
14
|
+
};
|
|
15
|
+
}() });
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.barcodeConsumeOperationBinding = barcodeConsumeOperationBinding;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
const require_operations = require("../../app/operations.js");
|
|
3
|
+
const require_cartConsistency = require("./cartConsistency.js");
|
|
4
|
+
const require_types = require("./types.js");
|
|
5
|
+
//#region src/components/HDLKiosk/runtime/operations/cart.ts
|
|
6
|
+
const cartAddProductOperationBinding = require_types.bindOperation(require_operations.cartAddProductOperation, { execute: function() {
|
|
7
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
8
|
+
return require_cartConsistency.finalizeCartMutation(context, yield context.host.sales.addProduct(input, signal), signal);
|
|
9
|
+
});
|
|
10
|
+
return function execute(_x, _x2, _x3) {
|
|
11
|
+
return _ref.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
}() });
|
|
14
|
+
const cartUpdateQuantityOperationBinding = require_types.bindOperation(require_operations.cartUpdateQuantityOperation, { execute: function() {
|
|
15
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
16
|
+
const mutation = yield context.host.sales.updateQuantity(input, signal);
|
|
17
|
+
return require_cartConsistency.finalizeCartMutation(context, mutation, signal, () => {
|
|
18
|
+
var _mutation$data$confir;
|
|
19
|
+
if (mutation.status === "succeeded" && mutation.data.affectedLineId === input.lineId && ((_mutation$data$confir = mutation.data.confirmedLine) === null || _mutation$data$confir === void 0 ? void 0 : _mutation$data$confir.lineId) === input.lineId && decimalValuesEqual(mutation.data.confirmedLine.quantity, input.quantity)) return true;
|
|
20
|
+
const line = context.host.sales.getObservedSnapshot().cart.lines.find((item) => item.lineId === input.lineId);
|
|
21
|
+
return decimalValuesEqual(line === null || line === void 0 ? void 0 : line.quantity, input.quantity);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return function execute(_x4, _x5, _x6) {
|
|
25
|
+
return _ref2.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
}() });
|
|
28
|
+
function decimalValuesEqual(left, right) {
|
|
29
|
+
if (left === void 0) return false;
|
|
30
|
+
const leftNumber = Number(left);
|
|
31
|
+
const rightNumber = Number(right);
|
|
32
|
+
return Number.isFinite(leftNumber) && Number.isFinite(rightNumber) && leftNumber === rightNumber;
|
|
33
|
+
}
|
|
34
|
+
const cartRemoveLineOperationBinding = require_types.bindOperation(require_operations.cartRemoveLineOperation, { execute: function() {
|
|
35
|
+
var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
36
|
+
const mutation = yield context.host.sales.removeLine(input, signal);
|
|
37
|
+
return require_cartConsistency.finalizeCartMutation(context, mutation, signal, () => mutation.status === "succeeded" && mutation.data.removedLineId === input.lineId || !context.host.sales.getObservedSnapshot().cart.lines.some((item) => item.lineId === input.lineId));
|
|
38
|
+
});
|
|
39
|
+
return function execute(_x7, _x8, _x9) {
|
|
40
|
+
return _ref3.apply(this, arguments);
|
|
41
|
+
};
|
|
42
|
+
}() });
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.cartAddProductOperationBinding = cartAddProductOperationBinding;
|
|
45
|
+
exports.cartRemoveLineOperationBinding = cartRemoveLineOperationBinding;
|
|
46
|
+
exports.cartUpdateQuantityOperationBinding = cartUpdateQuantityOperationBinding;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
2
|
const require_errors = require("./errors.js");
|
|
3
|
-
//#region src/components/HDLKiosk/
|
|
3
|
+
//#region src/components/HDLKiosk/runtime/operations/cartConsistency.ts
|
|
4
4
|
function finalizeCartMutation(_x, _x2, _x3, _x4) {
|
|
5
5
|
return _finalizeCartMutation.apply(this, arguments);
|
|
6
6
|
}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
1
2
|
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
+
const require_operations = require("../../app/operations.js");
|
|
2
4
|
const require_errors = require("./errors.js");
|
|
3
5
|
const require_types = require("./types.js");
|
|
4
6
|
const require_checkoutRequirements = require("./checkoutRequirements.js");
|
|
5
|
-
//#region src/components/HDLKiosk/
|
|
7
|
+
//#region src/components/HDLKiosk/runtime/operations/checkout.ts
|
|
6
8
|
function forwardFailure(result) {
|
|
7
9
|
return result;
|
|
8
10
|
}
|
|
11
|
+
const PAYMENT_ALREADY_STARTED_ERRORS = new Set([
|
|
12
|
+
"checkoutPaymentAlreadySettled",
|
|
13
|
+
"checkoutPaymentAlreadyStarted",
|
|
14
|
+
"checkoutAlreadyStarted"
|
|
15
|
+
]);
|
|
16
|
+
/** 标记当前支付命令尚未进入 Host dispatch,供硬阻断策略安全放行。 */
|
|
17
|
+
function forwardPreDispatchFailure(result) {
|
|
18
|
+
if ((result.status === "partialFailure" || result.status === "unknown") && !PAYMENT_ALREADY_STARTED_ERRORS.has(result.error.code)) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, result), {}, { error: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, result.error), {}, { details: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, result.error.details), {}, { checkoutDispatched: false }) }) });
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
9
21
|
function evaluateCheckoutRequirements(context, sales) {
|
|
10
22
|
return require_checkoutRequirements.defaultCheckoutRequirementRegistry.evaluate(context.checkoutRequirementIds, {
|
|
11
23
|
workflow: context.workflowContext,
|
|
@@ -98,126 +110,99 @@ function _ensureCheckoutPrepared() {
|
|
|
98
110
|
});
|
|
99
111
|
return _ensureCheckoutPrepared.apply(this, arguments);
|
|
100
112
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (preparation.status !== "succeeded") return forwardFailure(preparation);
|
|
122
|
-
const snapshot = host.sales.getObservedSnapshot();
|
|
123
|
-
const requirements = evaluateCheckoutRequirements(context, snapshot);
|
|
124
|
-
const validationFailure = requirementFailure(requirements);
|
|
125
|
-
if (validationFailure) return validationFailure;
|
|
126
|
-
const decision = checkoutSafety.beginOpen(snapshot, sessionEpoch, requirements.requirementIds);
|
|
127
|
-
if (decision.status === "rejected") return decision.reason === "checkoutAlreadyStarted" ? require_errors.operationUnknown(decision.reason) : require_errors.operationFailed(decision.reason, "back");
|
|
128
|
-
if (signal.aborted) {
|
|
129
|
-
const result = {
|
|
130
|
-
status: "cancelled",
|
|
131
|
-
reason: "checkoutAbortedBeforeDispatch"
|
|
132
|
-
};
|
|
133
|
-
checkoutSafety.settle(result);
|
|
134
|
-
return result;
|
|
135
|
-
}
|
|
136
|
-
let result;
|
|
137
|
-
try {
|
|
138
|
-
result = yield host.sales.openCheckout(signal);
|
|
139
|
-
} catch (error) {
|
|
140
|
-
result = require_errors.operationUnknown("checkoutInvocationUnhandled", error);
|
|
141
|
-
}
|
|
113
|
+
const checkoutPrepareOperationBinding = require_types.bindOperation(require_operations.checkoutPrepareOperation, { execute: (context, _input, signal) => {
|
|
114
|
+
const fulfillment = context.workflowContext.fulfillment;
|
|
115
|
+
return prepareCheckout(context, signal, fulfillment ? { mode: fulfillment } : void 0);
|
|
116
|
+
} });
|
|
117
|
+
const checkoutOpenOperationBinding = require_types.bindOperation(require_operations.checkoutOpenOperation, { execute: function() {
|
|
118
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, _input, signal) {
|
|
119
|
+
const { host, checkoutSafety, sessionEpoch } = context;
|
|
120
|
+
const preparation = yield ensureCheckoutPrepared(context, signal);
|
|
121
|
+
if (preparation.status !== "succeeded") return forwardPreDispatchFailure(preparation);
|
|
122
|
+
const snapshot = host.sales.getObservedSnapshot();
|
|
123
|
+
const requirements = evaluateCheckoutRequirements(context, snapshot);
|
|
124
|
+
const validationFailure = requirementFailure(requirements);
|
|
125
|
+
if (validationFailure) return validationFailure;
|
|
126
|
+
const decision = checkoutSafety.beginOpen(snapshot, sessionEpoch, requirements.requirementIds);
|
|
127
|
+
if (decision.status === "rejected") return decision.reason === "checkoutAlreadyStarted" ? require_errors.operationUnknown(decision.reason) : require_errors.operationFailed(decision.reason, "back");
|
|
128
|
+
if (signal.aborted) {
|
|
129
|
+
const result = {
|
|
130
|
+
status: "cancelled",
|
|
131
|
+
reason: "checkoutAbortedBeforeDispatch"
|
|
132
|
+
};
|
|
142
133
|
checkoutSafety.settle(result);
|
|
143
134
|
return result;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
135
|
+
}
|
|
136
|
+
let result;
|
|
137
|
+
try {
|
|
138
|
+
result = yield host.sales.openCheckout(signal);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
result = require_errors.operationUnknown("checkoutInvocationUnhandled", error);
|
|
141
|
+
}
|
|
142
|
+
checkoutSafety.settle(result);
|
|
143
|
+
return result;
|
|
144
|
+
});
|
|
145
|
+
return function execute(_x8, _x9, _x10) {
|
|
146
|
+
return _ref.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
}() });
|
|
150
149
|
/** Kiosk EFTPOS 直连入口:Host 只能调用嵌入式 PaymentMethodRuntime。 */
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (decision.status === "rejected") return decision.reason === "checkoutAlreadyStarted" ? require_errors.operationUnknown(decision.reason) : require_errors.operationFailed(decision.reason, "back");
|
|
168
|
-
if (signal.aborted) {
|
|
169
|
-
const result = {
|
|
170
|
-
status: "cancelled",
|
|
171
|
-
reason: "checkoutAbortedBeforeDispatch"
|
|
172
|
-
};
|
|
173
|
-
checkoutSafety.settle(result);
|
|
174
|
-
return result;
|
|
175
|
-
}
|
|
176
|
-
let result;
|
|
177
|
-
try {
|
|
178
|
-
result = yield host.sales.payEftpos(input, signal);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
result = require_errors.operationUnknown("checkoutInvocationUnhandled", error);
|
|
181
|
-
}
|
|
182
|
-
if (result.status === "succeeded" && !(yield waitForPaymentProjection(context, signal))) result = require_errors.operationUnknown("checkoutPaymentProjectionNotConfirmed");
|
|
150
|
+
const checkoutPayEftposOperationBinding = require_types.bindOperation(require_operations.checkoutPayEftposOperation, { execute: function() {
|
|
151
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
152
|
+
const { host, checkoutSafety, sessionEpoch } = context;
|
|
153
|
+
const preparation = yield ensureCheckoutPrepared(context, signal);
|
|
154
|
+
if (preparation.status !== "succeeded") return forwardPreDispatchFailure(preparation);
|
|
155
|
+
const snapshot = host.sales.getObservedSnapshot();
|
|
156
|
+
const requirements = evaluateCheckoutRequirements(context, snapshot);
|
|
157
|
+
const validationFailure = requirementFailure(requirements);
|
|
158
|
+
if (validationFailure) return validationFailure;
|
|
159
|
+
const decision = checkoutSafety.beginOpen(snapshot, sessionEpoch, requirements.requirementIds);
|
|
160
|
+
if (decision.status === "rejected") return decision.reason === "checkoutAlreadyStarted" ? require_errors.operationUnknown(decision.reason) : require_errors.operationFailed(decision.reason, "back");
|
|
161
|
+
if (signal.aborted) {
|
|
162
|
+
const result = {
|
|
163
|
+
status: "cancelled",
|
|
164
|
+
reason: "checkoutAbortedBeforeDispatch"
|
|
165
|
+
};
|
|
183
166
|
checkoutSafety.settle(result);
|
|
184
167
|
return result;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
168
|
+
}
|
|
169
|
+
let result;
|
|
170
|
+
try {
|
|
171
|
+
result = yield host.sales.payEftpos(input, signal);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
result = require_errors.operationUnknown("checkoutInvocationUnhandled", error);
|
|
174
|
+
}
|
|
175
|
+
if (result.status === "succeeded" && !(yield waitForPaymentProjection(context, signal))) result = require_errors.operationUnknown("checkoutPaymentProjectionNotConfirmed");
|
|
176
|
+
checkoutSafety.settle(result);
|
|
177
|
+
return result;
|
|
178
|
+
});
|
|
179
|
+
return function execute(_x11, _x12, _x13) {
|
|
180
|
+
return _ref2.apply(this, arguments);
|
|
181
|
+
};
|
|
182
|
+
}() });
|
|
191
183
|
/** 店员付款只请求主屏授权;授权派发绝不视作付款成功。 */
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (preparation.status !== "succeeded") return forwardFailure(preparation);
|
|
202
|
-
const validationFailure = requirementFailure(evaluateCheckoutRequirements(context, context.host.sales.getObservedSnapshot()));
|
|
203
|
-
if (validationFailure) return validationFailure;
|
|
204
|
-
if (signal.aborted) return {
|
|
205
|
-
status: "cancelled",
|
|
206
|
-
reason: "authorizationAborted"
|
|
207
|
-
};
|
|
208
|
-
return context.host.sales.requestStaffPaymentApproval(input, signal);
|
|
209
|
-
});
|
|
210
|
-
return function execute(_x14, _x15, _x16) {
|
|
211
|
-
return _ref3.apply(this, arguments);
|
|
184
|
+
const checkoutRequestStaffPaymentApprovalOperationBinding = require_types.bindOperation(require_operations.checkoutRequestStaffPaymentApprovalOperation, { execute: function() {
|
|
185
|
+
var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
186
|
+
const preparation = yield ensureCheckoutPrepared(context, signal);
|
|
187
|
+
if (preparation.status !== "succeeded") return forwardFailure(preparation);
|
|
188
|
+
const validationFailure = requirementFailure(evaluateCheckoutRequirements(context, context.host.sales.getObservedSnapshot()));
|
|
189
|
+
if (validationFailure) return validationFailure;
|
|
190
|
+
if (signal.aborted) return {
|
|
191
|
+
status: "cancelled",
|
|
192
|
+
reason: "authorizationAborted"
|
|
212
193
|
};
|
|
213
|
-
|
|
214
|
-
});
|
|
194
|
+
return context.host.sales.requestStaffPaymentApproval(input, signal);
|
|
195
|
+
});
|
|
196
|
+
return function execute(_x14, _x15, _x16) {
|
|
197
|
+
return _ref3.apply(this, arguments);
|
|
198
|
+
};
|
|
199
|
+
}() });
|
|
215
200
|
const MONEY = /^(?:0|[1-9]\d*)(?:\.\d+)?$/;
|
|
216
201
|
function isSafeMoney(value) {
|
|
217
202
|
return MONEY.test(value) && Number.isFinite(Number(value));
|
|
218
203
|
}
|
|
219
204
|
//#endregion
|
|
220
|
-
exports.
|
|
221
|
-
exports.
|
|
222
|
-
exports.
|
|
223
|
-
exports.
|
|
205
|
+
exports.checkoutOpenOperationBinding = checkoutOpenOperationBinding;
|
|
206
|
+
exports.checkoutPayEftposOperationBinding = checkoutPayEftposOperationBinding;
|
|
207
|
+
exports.checkoutPrepareOperationBinding = checkoutPrepareOperationBinding;
|
|
208
|
+
exports.checkoutRequestStaffPaymentApprovalOperationBinding = checkoutRequestStaffPaymentApprovalOperationBinding;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
-
//#region src/components/HDLKiosk/
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/operations/checkoutRequirements.ts
|
|
3
3
|
function createCheckoutRequirementRegistry(definitions) {
|
|
4
4
|
const byId = /* @__PURE__ */ new Map();
|
|
5
5
|
definitions.forEach((definition) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
-
//#region src/components/HDLKiosk/
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/operations/checkoutSafety.ts
|
|
3
3
|
const DEFAULT_TOKEN_TTL_MS = 3e4;
|
|
4
4
|
function createCheckoutSafetyController({ tokenTtlMs = DEFAULT_TOKEN_TTL_MS, now = Date.now } = {}) {
|
|
5
5
|
if (!Number.isFinite(tokenTtlMs) || tokenTtlMs <= 0) throw new Error("HDLKiosk checkout token TTL must be positive");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
-
const require_errors = require("./errors.js");
|
|
3
2
|
const require_coordinator = require("../../kernel/operations/coordinator.js");
|
|
3
|
+
const require_errors = require("./errors.js");
|
|
4
4
|
const require_checkoutSafety = require("./checkoutSafety.js");
|
|
5
|
-
//#region src/components/HDLKiosk/
|
|
5
|
+
//#region src/components/HDLKiosk/runtime/operations/coordinator.ts
|
|
6
6
|
function conflicts(left, right) {
|
|
7
7
|
if (left === "none" || right === "none") return false;
|
|
8
8
|
if (left === "session" || right === "session") return true;
|