@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,73 @@
|
|
|
1
|
+
const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
+
const require_canonicalSkuValue = require("../../../../plus/skuOptionsSelection/utils/canonicalSkuValue.js");
|
|
4
|
+
const require_operations = require("../../app/operations.js");
|
|
5
|
+
const require_errors = require("./errors.js");
|
|
6
|
+
const require_cartConsistency = require("./cartConsistency.js");
|
|
7
|
+
const require_types = require("./types.js");
|
|
8
|
+
let decimal_js = require("decimal.js");
|
|
9
|
+
decimal_js = require_runtime.__toESM(decimal_js);
|
|
10
|
+
//#region src/components/HDLKiosk/runtime/operations/customization.ts
|
|
11
|
+
/**
|
|
12
|
+
* 文件角色:在 Customization Next 边界提交称重主商品本地草稿。
|
|
13
|
+
* 运行机制:校验稳定净重/必选项,调用 Host/OS 主商品 writer,再验证目标行、重量、
|
|
14
|
+
* SkuValue 和“新增或原行发生变化”的最小 receipt/Projection 事实。
|
|
15
|
+
* 边界:页面输入变化不调用本 Operation;OS 内部的加购弹窗与业务判断不属于 HDLKiosk。
|
|
16
|
+
*/
|
|
17
|
+
const productRemovePrimaryProductOperationBinding = require_types.bindOperation(require_operations.productRemovePrimaryProductOperation, { execute: function() {
|
|
18
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
19
|
+
if (!input.lineId) return {
|
|
20
|
+
status: "succeeded",
|
|
21
|
+
data: {}
|
|
22
|
+
};
|
|
23
|
+
const mutation = yield context.host.sales.removeLine({ lineId: input.lineId }, signal);
|
|
24
|
+
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));
|
|
25
|
+
});
|
|
26
|
+
return function execute(_x, _x2, _x3) {
|
|
27
|
+
return _ref.apply(this, arguments);
|
|
28
|
+
};
|
|
29
|
+
}() });
|
|
30
|
+
function hasValidSkuValue(input) {
|
|
31
|
+
const canonical = require_canonicalSkuValue.canonicalizeSkuValue(input.skuValue);
|
|
32
|
+
return Boolean(input.productId && canonical && canonical.productId === input.productId);
|
|
33
|
+
}
|
|
34
|
+
function sameSkuValue(expected, actual) {
|
|
35
|
+
const expectedFingerprint = require_canonicalSkuValue.createSkuValueFingerprint(expected);
|
|
36
|
+
return Boolean(expectedFingerprint && expectedFingerprint === require_canonicalSkuValue.createSkuValueFingerprint(actual));
|
|
37
|
+
}
|
|
38
|
+
function sameWeight(actual, expected) {
|
|
39
|
+
const actualValue = new decimal_js.default(actual || NaN);
|
|
40
|
+
const expectedValue = new decimal_js.default(expected || NaN);
|
|
41
|
+
return actualValue.isFinite() && expectedValue.isFinite() && actualValue.equals(expectedValue);
|
|
42
|
+
}
|
|
43
|
+
const productSyncPrimaryWeightedProductOperationBinding = require_types.bindOperation(require_operations.productSyncPrimaryWeightedProductOperation, { execute: function() {
|
|
44
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
45
|
+
if (!hasValidSkuValue(input)) return require_errors.operationFailed("customizationInputInvalid", "back");
|
|
46
|
+
const beforeLines = new Map(context.host.sales.getObservedSnapshot().cart.lines.map((line) => [line.lineId, line.quantity]));
|
|
47
|
+
const before = context.host.sales.getObservedSnapshot();
|
|
48
|
+
const previousPrimary = input.existingLineId ? before.cart.lines.find((line) => line.lineId === input.existingLineId) : void 0;
|
|
49
|
+
if (input.existingLineId && (!previousPrimary || previousPrimary.productId !== input.productId)) return require_errors.operationFailed("customizationExistingLineInvalid", "back");
|
|
50
|
+
const mutation = yield context.host.sales.syncPrimaryWeightedProduct(input, signal);
|
|
51
|
+
return require_cartConsistency.finalizeCartMutation(context, mutation, signal, () => {
|
|
52
|
+
const after = context.host.sales.getObservedSnapshot();
|
|
53
|
+
const projectionMatches = after.cart.lines.some((line) => {
|
|
54
|
+
if (mutation.status === "succeeded" && mutation.data.affectedLineId && line.lineId !== mutation.data.affectedLineId) return false;
|
|
55
|
+
if (line.productId !== input.productId) return false;
|
|
56
|
+
const skuMatches = sameSkuValue(input.skuValue, line.skuValue);
|
|
57
|
+
const weightMatches = sameWeight(line.quantity, input.measurement.netWeightKg);
|
|
58
|
+
const previousQuantity = beforeLines.get(line.lineId);
|
|
59
|
+
if (input.existingLineId) return line.lineId === input.existingLineId && skuMatches && weightMatches && mutation.status === "succeeded" && mutation.data.affectedLineId === input.existingLineId && after.observationId > before.observationId;
|
|
60
|
+
return skuMatches && weightMatches && (previousQuantity === void 0 || previousQuantity !== line.quantity);
|
|
61
|
+
});
|
|
62
|
+
const successfulOutcome = mutation.status === "succeeded" ? mutation.data : void 0;
|
|
63
|
+
const confirmedLine = successfulOutcome === null || successfulOutcome === void 0 ? void 0 : successfulOutcome.confirmedLine;
|
|
64
|
+
return Boolean(confirmedLine && confirmedLine.productId === input.productId && (!(successfulOutcome === null || successfulOutcome === void 0 ? void 0 : successfulOutcome.affectedLineId) || confirmedLine.lineId === successfulOutcome.affectedLineId) && (!input.existingLineId || (successfulOutcome === null || successfulOutcome === void 0 ? void 0 : successfulOutcome.affectedLineId) === input.existingLineId && confirmedLine.lineId === input.existingLineId) && sameWeight(confirmedLine.quantity, input.measurement.netWeightKg) && sameSkuValue(input.skuValue, confirmedLine.skuValue) && (Boolean(input.existingLineId) || !beforeLines.has(confirmedLine.lineId) || beforeLines.get(confirmedLine.lineId) !== confirmedLine.quantity)) || projectionMatches;
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
return function execute(_x4, _x5, _x6) {
|
|
68
|
+
return _ref2.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}() });
|
|
71
|
+
//#endregion
|
|
72
|
+
exports.productRemovePrimaryProductOperationBinding = productRemovePrimaryProductOperationBinding;
|
|
73
|
+
exports.productSyncPrimaryWeightedProductOperationBinding = productSyncPrimaryWeightedProductOperationBinding;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const require_operations = require("../../app/operations.js");
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/operations/fulfillment.ts
|
|
3
|
+
const setFulfillmentOperationBinding = require("./types.js").bindOperation(require_operations.setFulfillmentOperation, { execute: (context, input, signal) => context.host.sales.setFulfillment(input, signal) });
|
|
4
|
+
//#endregion
|
|
5
|
+
exports.setFulfillmentOperationBinding = setFulfillmentOperationBinding;
|
|
@@ -0,0 +1,55 @@
|
|
|
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_errors = require("./errors.js");
|
|
4
|
+
const require_types = require("./types.js");
|
|
5
|
+
//#region src/components/HDLKiosk/runtime/operations/identity.ts
|
|
6
|
+
function partialFailure(code, cause) {
|
|
7
|
+
return {
|
|
8
|
+
status: "partialFailure",
|
|
9
|
+
error: require_errors.createOperationError(code, "staff", cause)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function identityMatches(customerId, customer) {
|
|
13
|
+
if (!customerId) return (customer === null || customer === void 0 ? void 0 : customer.member) !== true;
|
|
14
|
+
if ((customer === null || customer === void 0 ? void 0 : customer.member) !== true) return false;
|
|
15
|
+
return customer.customerId === customerId;
|
|
16
|
+
}
|
|
17
|
+
const identitySyncOperationBinding = require_types.bindOperation(require_operations.identitySyncOperation, { execute: function() {
|
|
18
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
19
|
+
var _input$customerId;
|
|
20
|
+
if (!input || input.customerId !== void 0 && !input.customerId.trim()) return require_errors.operationFailed("identityInputInvalid", "back");
|
|
21
|
+
const customerId = (_input$customerId = input.customerId) === null || _input$customerId === void 0 ? void 0 : _input$customerId.trim();
|
|
22
|
+
const beforeSelection = context.host.sales.getObservedSnapshot();
|
|
23
|
+
const selected = yield context.host.sales.selectIdentity(customerId ? { customerId } : {}, signal);
|
|
24
|
+
if (selected.status !== "succeeded") return selected;
|
|
25
|
+
if (signal.aborted) return require_errors.operationUnknown("identityAbortedAfterWrite");
|
|
26
|
+
const afterSelection = context.host.sales.getObservedSnapshot();
|
|
27
|
+
const hasOrderLines = beforeSelection.cart.lineCount > 0 || afterSelection.cart.lineCount > 0;
|
|
28
|
+
let summaryConfirmed = false;
|
|
29
|
+
if (hasOrderLines) {
|
|
30
|
+
const consistency = yield context.host.sales.waitForCartConsistency(signal);
|
|
31
|
+
if (consistency.status !== "succeeded") {
|
|
32
|
+
if (consistency.status === "unknown") return consistency;
|
|
33
|
+
return partialFailure("identityConsistencyFailed", consistency);
|
|
34
|
+
}
|
|
35
|
+
const summary = yield context.host.sales.recalculateSummary(signal);
|
|
36
|
+
if (summary.status !== "succeeded") {
|
|
37
|
+
if (summary.status === "unknown") return summary;
|
|
38
|
+
return partialFailure("identitySummaryRecalculationFailed", summary);
|
|
39
|
+
}
|
|
40
|
+
summaryConfirmed = Boolean(summary.data.confirmedSummary);
|
|
41
|
+
}
|
|
42
|
+
const observed = context.host.sales.getObservedSnapshot();
|
|
43
|
+
if (hasOrderLines && !summaryConfirmed && observed.summary.status !== "ready") return partialFailure("identitySummaryProjectionMissing");
|
|
44
|
+
if (!(customerId ? identityMatches(customerId, selected.data.customer) : selected.data.customer === void 0) && !identityMatches(customerId, observed.customer)) return require_errors.operationUnknown("identitySelectionNotObserved");
|
|
45
|
+
return {
|
|
46
|
+
status: "succeeded",
|
|
47
|
+
data: void 0
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
return function execute(_x, _x2, _x3) {
|
|
51
|
+
return _ref.apply(this, arguments);
|
|
52
|
+
};
|
|
53
|
+
}() });
|
|
54
|
+
//#endregion
|
|
55
|
+
exports.identitySyncOperationBinding = identitySyncOperationBinding;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const require_types = require("./types.js");
|
|
2
|
+
const require_barcode = require("./barcode.js");
|
|
3
|
+
const require_cart = require("./cart.js");
|
|
4
|
+
const require_checkout = require("./checkout.js");
|
|
5
|
+
const require_fulfillment = require("./fulfillment.js");
|
|
6
|
+
const require_session = require("./session.js");
|
|
7
|
+
const require_identity = require("./identity.js");
|
|
8
|
+
const require_customization = require("./customization.js");
|
|
9
|
+
//#region src/components/HDLKiosk/runtime/operations/registry.ts
|
|
10
|
+
/**
|
|
11
|
+
* 文件角色:为 HDLKiosk Operation Contract 提供生产 Runtime Handler Registry。
|
|
12
|
+
* 边界:Application Manifest 只引用 Contract;Host 业务方法只能从本 Binding 层进入。
|
|
13
|
+
*/
|
|
14
|
+
const HDLKIOSK_OPERATION_BINDINGS = Object.freeze([
|
|
15
|
+
require_barcode.barcodeConsumeOperationBinding,
|
|
16
|
+
require_cart.cartAddProductOperationBinding,
|
|
17
|
+
require_cart.cartRemoveLineOperationBinding,
|
|
18
|
+
require_cart.cartUpdateQuantityOperationBinding,
|
|
19
|
+
require_checkout.checkoutOpenOperationBinding,
|
|
20
|
+
require_checkout.checkoutPayEftposOperationBinding,
|
|
21
|
+
require_checkout.checkoutPrepareOperationBinding,
|
|
22
|
+
require_checkout.checkoutRequestStaffPaymentApprovalOperationBinding,
|
|
23
|
+
require_session.sessionEnsureOperationBinding,
|
|
24
|
+
require_session.sessionResetOperationBinding,
|
|
25
|
+
require_fulfillment.setFulfillmentOperationBinding,
|
|
26
|
+
require_identity.identitySyncOperationBinding,
|
|
27
|
+
require_customization.productRemovePrimaryProductOperationBinding,
|
|
28
|
+
require_customization.productSyncPrimaryWeightedProductOperationBinding
|
|
29
|
+
]);
|
|
30
|
+
function createHDLKioskOperationRegistry() {
|
|
31
|
+
return require_types.createOperationRegistry(HDLKIOSK_OPERATION_BINDINGS);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.createHDLKioskOperationRegistry = createHDLKioskOperationRegistry;
|
|
@@ -0,0 +1,30 @@
|
|
|
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_errors = require("./errors.js");
|
|
4
|
+
const require_types = require("./types.js");
|
|
5
|
+
//#region src/components/HDLKiosk/runtime/operations/session.ts
|
|
6
|
+
function forwardFailure(result) {
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
const sessionEnsureOperationBinding = require_types.bindOperation(require_operations.sessionEnsureOperation, { execute: ({ host }, _input, signal) => host.sales.ensureSession(signal) });
|
|
10
|
+
const sessionResetOperationBinding = require_types.bindOperation(require_operations.sessionResetOperation, { execute: function() {
|
|
11
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* ({ host }, _input, signal) {
|
|
12
|
+
const before = host.sales.getObservedSnapshot();
|
|
13
|
+
if (before.payment.status === "pending" || before.payment.status === "unknown") return require_errors.operationUnknown("resetBlockedByPaymentState");
|
|
14
|
+
const reset = yield host.sales.clearAndReset(signal);
|
|
15
|
+
if (reset.status !== "succeeded") return forwardFailure(reset);
|
|
16
|
+
if (!reset.data.cartEmpty) return require_errors.operationUnknown("resetHostResultNotEmpty");
|
|
17
|
+
const consistency = yield host.sales.waitForCartConsistency(signal);
|
|
18
|
+
if (consistency.status !== "succeeded") return forwardFailure(consistency);
|
|
19
|
+
return {
|
|
20
|
+
status: "succeeded",
|
|
21
|
+
data: void 0
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return function execute(_x, _x2, _x3) {
|
|
25
|
+
return _ref.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
}() });
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.sessionEnsureOperationBinding = sessionEnsureOperationBinding;
|
|
30
|
+
exports.sessionResetOperationBinding = sessionResetOperationBinding;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
+
const require_registry = require("../../kernel/operations/registry.js");
|
|
3
|
+
const require_types = require("../../kernel/operations/types.js");
|
|
4
|
+
//#region src/components/HDLKiosk/runtime/operations/types.ts
|
|
5
|
+
function bindOperation(contract, handler) {
|
|
6
|
+
const bound = require_types.bindKernelOperation(contract, { execute: handler.execute });
|
|
7
|
+
return Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, bound), {}, { verify: handler.verify }));
|
|
8
|
+
}
|
|
9
|
+
function createOperationRegistry(operations) {
|
|
10
|
+
return require_registry.createKernelOperationRegistry(operations);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.bindOperation = bindOperation;
|
|
14
|
+
exports.createOperationRegistry = createOperationRegistry;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/components/HDLKiosk/runtime/session/blockPolicy.ts
|
|
2
|
+
const CHECKOUT_DISPATCH_OPERATIONS = new Set(["checkout.open", "checkout.payEftpos"]);
|
|
3
|
+
/** 这些结果发生在任何支付调用之前,不存在重复扣款风险。 */
|
|
4
|
+
const RETRYABLE_CHECKOUT_PREFLIGHT_ERRORS = new Set(["checkoutProjectionUnstable", "checkoutCartStillChanging"]);
|
|
5
|
+
function shouldHardBlockOperationResult(operationId, result) {
|
|
6
|
+
var _result$error$details;
|
|
7
|
+
if (result.status !== "partialFailure" && result.status !== "unknown") return false;
|
|
8
|
+
if (operationId === "session.reset") return true;
|
|
9
|
+
if (!CHECKOUT_DISPATCH_OPERATIONS.has(operationId)) return false;
|
|
10
|
+
if (((_result$error$details = result.error.details) === null || _result$error$details === void 0 ? void 0 : _result$error$details.checkoutDispatched) === false) return false;
|
|
11
|
+
return !RETRYABLE_CHECKOUT_PREFLIGHT_ERRORS.has(result.error.code);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.shouldHardBlockOperationResult = shouldHardBlockOperationResult;
|
package/lib/components/HDLKiosk/runtime/{createWorkflowSession.js → session/createSession.js}
RENAMED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
require("
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const require_lifecycle = require("
|
|
11
|
-
const require_actor = require("
|
|
12
|
-
const require_compiler = require("
|
|
13
|
-
const
|
|
1
|
+
require("../../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
|
+
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
4
|
+
const require_registry = require("../../app/workflow/registry.js");
|
|
5
|
+
const require_predicates = require("../../app/workflow/predicates.js");
|
|
6
|
+
const require_navigationGuards = require("../../app/workflow/navigationGuards.js");
|
|
7
|
+
const require_policy = require("../../app/workflow/policy.js");
|
|
8
|
+
const require_index = require("../../app/workflow/index.js");
|
|
9
|
+
const require_registry$1 = require("../operations/registry.js");
|
|
10
|
+
const require_lifecycle = require("../../kernel/lifecycle.js");
|
|
11
|
+
const require_actor = require("../../kernel/workflow/actor.js");
|
|
12
|
+
const require_compiler = require("../../kernel/workflow/compiler.js");
|
|
13
|
+
const require_coordinator = require("../operations/coordinator.js");
|
|
14
|
+
const require_blockPolicy = require("./blockPolicy.js");
|
|
15
|
+
const require_transitionRunner = require("./transitionRunner.js");
|
|
14
16
|
const require_workflowLifecycle = require("./workflowLifecycle.js");
|
|
15
17
|
const require_workflowContext = require("./workflowContext.js");
|
|
16
18
|
let _pisell_utils = require("@pisell/utils");
|
|
17
|
-
//#region src/components/HDLKiosk/runtime/
|
|
19
|
+
//#region src/components/HDLKiosk/runtime/session/createSession.ts
|
|
18
20
|
/**
|
|
19
21
|
* 文件角色:创建一次点餐会话所需的全部纯 Core 对象。
|
|
20
22
|
* 运行机制:选择/编译 Definition,组装 Activity Registry、Operation Registry、
|
|
@@ -22,14 +24,14 @@ let _pisell_utils = require("@pisell/utils");
|
|
|
22
24
|
* 边界:每次会话创建一次;不持有 React UI,也不复用上一单 Actor。
|
|
23
25
|
*/
|
|
24
26
|
function createHDLKioskWorkflowSession(entry, host, options = {}) {
|
|
25
|
-
var _options$initialConte, _options$lifecycleExt;
|
|
26
|
-
const operations =
|
|
27
|
+
var _options$initialConte, _options$lifecycleExt, _options$cause, _options$sessionId;
|
|
28
|
+
const operations = require_registry$1.createHDLKioskOperationRegistry();
|
|
27
29
|
const structuralCompilation = require_compiler.compileWorkflowStructure(require_registry.getBuiltInWorkflowDefinition(entry), {
|
|
28
30
|
operations,
|
|
29
31
|
activities: require_registry.defaultActivityRegistry,
|
|
30
32
|
predicates: require_predicates.defaultPredicateRegistry,
|
|
31
33
|
navigationGuards: require_navigationGuards.defaultNavigationGuardRegistry,
|
|
32
|
-
workflowIds:
|
|
34
|
+
workflowIds: require_index.HDL_WORKFLOW_IDS
|
|
33
35
|
});
|
|
34
36
|
if (structuralCompilation.status !== "valid") throw new Error(`Invalid built-in HDLKiosk workflow: ${structuralCompilation.issues.map((issue) => issue.code).join(",")}`);
|
|
35
37
|
const definition = structuralCompilation.definition;
|
|
@@ -42,7 +44,7 @@ function createHDLKioskWorkflowSession(entry, host, options = {}) {
|
|
|
42
44
|
});
|
|
43
45
|
let actorRef;
|
|
44
46
|
const coordinator = require_coordinator.createOperationCoordinator(host, operations, {
|
|
45
|
-
checkoutRequirementIds: definition.
|
|
47
|
+
checkoutRequirementIds: definition.requirements,
|
|
46
48
|
getWorkflowContext: () => {
|
|
47
49
|
var _actorRef$getSnapshot;
|
|
48
50
|
return (_actorRef$getSnapshot = actorRef === null || actorRef === void 0 ? void 0 : actorRef.getSnapshot().context) !== null && _actorRef$getSnapshot !== void 0 ? _actorRef$getSnapshot : initialContext;
|
|
@@ -52,7 +54,7 @@ function createHDLKioskWorkflowSession(entry, host, options = {}) {
|
|
|
52
54
|
coordinator.dispose();
|
|
53
55
|
throw new Error(`HDLKiosk workflow ${definition.id} cannot use entry ${entry}`);
|
|
54
56
|
}
|
|
55
|
-
const transitionRunner =
|
|
57
|
+
const transitionRunner = require_transitionRunner.createHDLKioskTransitionRunner({
|
|
56
58
|
host,
|
|
57
59
|
coordinator,
|
|
58
60
|
predicates: require_predicates.defaultPredicateRegistry
|
|
@@ -67,6 +69,40 @@ function createHDLKioskWorkflowSession(entry, host, options = {}) {
|
|
|
67
69
|
beforeEach: require_navigationGuards.createHDLKioskBeforeEachGuard(() => host.sales.getObservedSnapshot())
|
|
68
70
|
});
|
|
69
71
|
actorRef = workflowActor;
|
|
72
|
+
let paymentProjectionObservationId;
|
|
73
|
+
const advanceConfirmedPayment = () => {
|
|
74
|
+
var _definition$nodes$sna;
|
|
75
|
+
const snapshot = workflowActor.getSnapshot();
|
|
76
|
+
const projection = host.sales.getObservedSnapshot();
|
|
77
|
+
if (snapshot.status !== "idle" || ((_definition$nodes$sna = definition.nodes[snapshot.nodeId]) === null || _definition$nodes$sna === void 0 ? void 0 : _definition$nodes$sna.activity) !== "paymentMethod" || projection.payment.status !== "succeeded" || paymentProjectionObservationId === projection.observationId) return;
|
|
78
|
+
paymentProjectionObservationId = projection.observationId;
|
|
79
|
+
workflowActor.send({
|
|
80
|
+
type: "ACTIVITY_INTENT",
|
|
81
|
+
stepId: snapshot.nodeId,
|
|
82
|
+
activityId: "paymentMethod",
|
|
83
|
+
intent: "complete",
|
|
84
|
+
intentId: `projection:payment:${snapshot.sessionEpoch}:${projection.observationId}`
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
let unsubscribePaymentProjection = () => void 0;
|
|
88
|
+
let unsubscribePaymentWorkflow = () => void 0;
|
|
89
|
+
try {
|
|
90
|
+
unsubscribePaymentProjection = host.sales.subscribe(advanceConfirmedPayment);
|
|
91
|
+
unsubscribePaymentWorkflow = workflowActor.subscribe(advanceConfirmedPayment);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
unsubscribePaymentProjection();
|
|
94
|
+
workflowActor.dispose();
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
advanceConfirmedPayment();
|
|
98
|
+
const sessionSnapshot = workflowActor.getSnapshot();
|
|
99
|
+
const cause = (_options$cause = options.cause) !== null && _options$cause !== void 0 ? _options$cause : Object.freeze({
|
|
100
|
+
trigger: "manual",
|
|
101
|
+
channel: definition.id,
|
|
102
|
+
occurrenceId: `${definition.id}:${sessionSnapshot.sessionEpoch}`,
|
|
103
|
+
correlationId: `${definition.id}:${sessionSnapshot.sessionEpoch}`
|
|
104
|
+
});
|
|
105
|
+
let disposed = false;
|
|
70
106
|
try {
|
|
71
107
|
const snapshot = workflowActor.getSnapshot();
|
|
72
108
|
host.telemetry.emit({
|
|
@@ -80,10 +116,24 @@ function createHDLKioskWorkflowSession(entry, host, options = {}) {
|
|
|
80
116
|
}
|
|
81
117
|
});
|
|
82
118
|
} catch (_unused) {}
|
|
119
|
+
const disposeSession = () => {
|
|
120
|
+
if (disposed) return;
|
|
121
|
+
disposed = true;
|
|
122
|
+
unsubscribePaymentProjection();
|
|
123
|
+
unsubscribePaymentWorkflow();
|
|
124
|
+
workflowActor.dispose();
|
|
125
|
+
};
|
|
126
|
+
const publicActor = Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, workflowActor), {}, { dispose: disposeSession }));
|
|
83
127
|
return Object.freeze({
|
|
128
|
+
id: (_options$sessionId = options.sessionId) !== null && _options$sessionId !== void 0 ? _options$sessionId : `${definition.id}:${sessionSnapshot.sessionEpoch}:${cause.occurrenceId}`,
|
|
129
|
+
workflowId: definition.id,
|
|
130
|
+
cause,
|
|
84
131
|
entry,
|
|
85
132
|
definition,
|
|
86
|
-
actor:
|
|
133
|
+
actor: publicActor,
|
|
134
|
+
dispatch: (event) => workflowActor.send(event),
|
|
135
|
+
isActive: () => !disposed && workflowActor.getSnapshot().status !== "finished",
|
|
136
|
+
dispose: disposeSession,
|
|
87
137
|
ensure: (intentId) => {
|
|
88
138
|
const snapshot = workflowActor.getSnapshot();
|
|
89
139
|
return coordinator.execute("session.ensure", {
|
|
@@ -102,7 +152,7 @@ function createHDLKioskWorkflowSession(entry, host, options = {}) {
|
|
|
102
152
|
sessionEpoch: snapshot.sessionEpoch,
|
|
103
153
|
input
|
|
104
154
|
});
|
|
105
|
-
if (
|
|
155
|
+
if (require_blockPolicy.shouldHardBlockOperationResult(commandId, result)) workflowActor.block(result.error, intentId);
|
|
106
156
|
return result;
|
|
107
157
|
});
|
|
108
158
|
return function executeCommand(_x, _x2, _x3) {
|
package/lib/components/HDLKiosk/runtime/{domainTransitionRunner.js → session/transitionRunner.js}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const require_asyncToGenerator = require("
|
|
2
|
-
const require_transition = require("
|
|
3
|
-
|
|
1
|
+
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
const require_transition = require("../../kernel/workflow/transition.js");
|
|
3
|
+
const require_blockPolicy = require("./blockPolicy.js");
|
|
4
|
+
//#region src/components/HDLKiosk/runtime/session/transitionRunner.ts
|
|
4
5
|
let domainErrorSequence = 0;
|
|
5
6
|
function createDomainWorkflowError(code, recovery = "staff", cause) {
|
|
6
7
|
domainErrorSequence += 1;
|
|
@@ -44,7 +45,7 @@ function createHDLKioskTransitionRunner({ host, coordinator, predicates, now = D
|
|
|
44
45
|
const error = createDomainWorkflowError("workflowPredicateEvaluationFailed", "staff", cause);
|
|
45
46
|
emitError(error, workflowId, stepId, event.intent);
|
|
46
47
|
return {
|
|
47
|
-
status: "
|
|
48
|
+
status: "stay",
|
|
48
49
|
lastError: error
|
|
49
50
|
};
|
|
50
51
|
}
|
|
@@ -94,6 +95,10 @@ function createHDLKioskTransitionRunner({ host, coordinator, predicates, now = D
|
|
|
94
95
|
status: "stay",
|
|
95
96
|
lastError: createDomainWorkflowError("checkoutPaymentCancelled", "retry", result.reason)
|
|
96
97
|
};
|
|
98
|
+
if ((result.status === "partialFailure" || result.status === "unknown") && !require_blockPolicy.shouldHardBlockOperationResult(command.id, result)) return {
|
|
99
|
+
status: "stay",
|
|
100
|
+
lastError: result.error
|
|
101
|
+
};
|
|
97
102
|
const decision = require_transition.resolveOperationTransition({
|
|
98
103
|
currentNodeId: stepId,
|
|
99
104
|
targetNodeId: transition.target,
|
|
@@ -105,7 +110,7 @@ function createHDLKioskTransitionRunner({ host, coordinator, predicates, now = D
|
|
|
105
110
|
};
|
|
106
111
|
if (decision.nodeId === transition.target) return {
|
|
107
112
|
status: "advance",
|
|
108
|
-
|
|
113
|
+
receipt: (command.id === "checkout.open" || command.id === "checkout.payEftpos") && result.status === "succeeded" ? result.data : void 0
|
|
109
114
|
};
|
|
110
115
|
return {
|
|
111
116
|
status: "stay",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_objectSpread2 = require("
|
|
2
|
-
//#region src/components/HDLKiosk/runtime/workflowContext.ts
|
|
1
|
+
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/session/workflowContext.ts
|
|
3
3
|
const reduceHDLKioskWorkflowContext = (context, patch) => {
|
|
4
4
|
if (!patch) return context;
|
|
5
5
|
const fulfillment = patch.fulfillment === "dine_in" || patch.fulfillment === "takeaway" ? patch.fulfillment : context.fulfillment;
|
package/lib/components/HDLKiosk/runtime/{workflowLifecycle.js → session/workflowLifecycle.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_asyncToGenerator = require("
|
|
2
|
-
//#region src/components/HDLKiosk/runtime/workflowLifecycle.ts
|
|
1
|
+
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/session/workflowLifecycle.ts
|
|
3
3
|
function createHDLKioskWorkflowLifecycle(host, now = Date.now) {
|
|
4
4
|
const lifecycle = {
|
|
5
5
|
committed: function() {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const require_scaleIngress = require("./devices/scaleIngress.js");
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/triggers.ts
|
|
3
|
+
function createHDLKioskEntryTriggerAdapters(host, config, scannerTriggerAdapter) {
|
|
4
|
+
const scaleIngress = require_scaleIngress.createScaleIngress();
|
|
5
|
+
const onWeight = Object.freeze({
|
|
6
|
+
trigger: "onWeight",
|
|
7
|
+
activate: ({ emit }) => host.devices.subscribe((event) => {
|
|
8
|
+
if (event.type !== "weightChanged") return;
|
|
9
|
+
const accepted = scaleIngress.accept(event, {
|
|
10
|
+
active: true,
|
|
11
|
+
supported: config.enabledEntries.includes("scale") && Boolean(config.primaryWeightedProductId) && host.capabilities.scale.available && host.capabilities.scale.weightChangeTrigger,
|
|
12
|
+
workflowLocked: false,
|
|
13
|
+
nodeAcceptsEvent: true,
|
|
14
|
+
paymentFrozen: false
|
|
15
|
+
});
|
|
16
|
+
if (accepted.status !== "accepted") return;
|
|
17
|
+
emit({
|
|
18
|
+
channel: "weighing-product",
|
|
19
|
+
occurrenceId: accepted.event.eventId,
|
|
20
|
+
correlationId: `device:scale:${accepted.event.eventId}`,
|
|
21
|
+
payload: { weight: accepted.event.weight }
|
|
22
|
+
});
|
|
23
|
+
}, { sources: ["scale"] })
|
|
24
|
+
});
|
|
25
|
+
return Object.freeze([scannerTriggerAdapter, onWeight]);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.createHDLKioskEntryTriggerAdapters = createHDLKioskEntryTriggerAdapters;
|
|
@@ -228,20 +228,24 @@ function CatalogScreen({ products, loading, errorReference, errorMessage, busy,
|
|
|
228
228
|
const item = rawItem;
|
|
229
229
|
const product = item;
|
|
230
230
|
const quantity = formatQuantity(orderBar.quantitiesByProduct[product.productId]);
|
|
231
|
+
const addProduct = () => send({
|
|
232
|
+
kind: "command",
|
|
233
|
+
command: "cart.addProduct",
|
|
234
|
+
input: {
|
|
235
|
+
productId: product.productId,
|
|
236
|
+
quantity: "1"
|
|
237
|
+
}
|
|
238
|
+
});
|
|
231
239
|
const action = /* @__PURE__ */ react.default.createElement("button", {
|
|
232
240
|
type: "button",
|
|
233
241
|
className: `${require_kioskCatalog.KIOSK_CATALOG_PRODUCT_CARD_CLASS_NAME}__add`,
|
|
234
242
|
disabled: busy || !product.available,
|
|
235
243
|
"aria-label": `${_pisell_utils.locales.getText("pisell2.hdl-kiosk.catalog-add-item")}: ${product.name}`,
|
|
236
244
|
"aria-busy": busy || void 0,
|
|
237
|
-
onClick: () =>
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
productId: product.productId,
|
|
242
|
-
quantity: "1"
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
+
onClick: (event) => {
|
|
246
|
+
event.stopPropagation();
|
|
247
|
+
addProduct();
|
|
248
|
+
}
|
|
245
249
|
}, quantity ? /* @__PURE__ */ react.default.createElement("span", { "data-length": Math.min(quantity.length, 5) }, quantity) : /* @__PURE__ */ react.default.createElement(PlusIcon, null));
|
|
246
250
|
return /* @__PURE__ */ react.default.createElement(require_index.default, {
|
|
247
251
|
key: product.productId,
|
|
@@ -249,6 +253,9 @@ function CatalogScreen({ products, loading, errorReference, errorMessage, busy,
|
|
|
249
253
|
index,
|
|
250
254
|
scenario: "booking2",
|
|
251
255
|
selectionTrigger: "click",
|
|
256
|
+
onSelect: busy || !product.available ? void 0 : addProduct,
|
|
257
|
+
onSelectCover: busy || !product.available ? void 0 : addProduct,
|
|
258
|
+
onSelectInfo: busy || !product.available ? void 0 : addProduct,
|
|
252
259
|
className: require_kioskCatalog.KIOSK_CATALOG_PRODUCT_CARD_CLASS_NAME,
|
|
253
260
|
customSkuCardAllConfig: require_kioskCatalog.createKioskCatalogProductCardConfig({
|
|
254
261
|
title: product.name,
|