@pisell/pisellos 0.0.490 → 0.0.492

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.
Files changed (157) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/model/strategy/adapter/index.d.ts +2 -0
  4. package/dist/model/strategy/adapter/index.js +3 -1
  5. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
  6. package/dist/model/strategy/adapter/itemRule/adapter.js +439 -0
  7. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  8. package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
  9. package/dist/model/strategy/adapter/itemRule/examples.d.ts +64 -0
  10. package/dist/model/strategy/adapter/itemRule/examples.js +315 -0
  11. package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
  12. package/dist/model/strategy/adapter/itemRule/index.js +5 -0
  13. package/dist/model/strategy/adapter/itemRule/type.d.ts +206 -0
  14. package/dist/model/strategy/adapter/itemRule/type.js +101 -0
  15. package/dist/model/strategy/adapter/walletPass/utils.js +2 -2
  16. package/dist/modules/OpenData/index.d.ts +23 -0
  17. package/dist/modules/OpenData/index.js +167 -0
  18. package/dist/modules/OpenData/types.d.ts +73 -0
  19. package/dist/modules/OpenData/types.js +1 -0
  20. package/dist/modules/OpenData/utils.d.ts +2 -0
  21. package/dist/modules/OpenData/utils.js +75 -0
  22. package/dist/modules/Order/index.d.ts +53 -1
  23. package/dist/modules/Order/index.js +717 -27
  24. package/dist/modules/Order/types.d.ts +144 -12
  25. package/dist/modules/Order/utils.d.ts +25 -0
  26. package/dist/modules/Order/utils.js +214 -1
  27. package/dist/modules/Product/utils.js +2 -2
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -1
  30. package/dist/modules/Quotation/index.d.ts +40 -0
  31. package/dist/modules/Quotation/index.js +212 -0
  32. package/dist/modules/Quotation/types.d.ts +42 -0
  33. package/dist/modules/Quotation/types.js +1 -0
  34. package/dist/modules/Rules/index.js +2 -2
  35. package/dist/modules/SalesSummary/index.d.ts +63 -0
  36. package/dist/modules/SalesSummary/index.js +174 -0
  37. package/dist/modules/SalesSummary/types.d.ts +59 -0
  38. package/dist/modules/SalesSummary/types.js +1 -0
  39. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  40. package/dist/modules/SalesSummary/utils.js +506 -0
  41. package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
  42. package/dist/modules/ScanOrderLogger/index.js +161 -0
  43. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  44. package/dist/modules/ScanOrderLogger/providers/feishu.js +95 -0
  45. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  46. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  47. package/dist/modules/ScanOrderLogger/types.d.ts +46 -0
  48. package/dist/modules/ScanOrderLogger/types.js +1 -0
  49. package/dist/modules/Summary/utils.d.ts +3 -3
  50. package/dist/modules/Summary/utils.js +4 -4
  51. package/dist/modules/index.d.ts +4 -0
  52. package/dist/modules/index.js +5 -1
  53. package/dist/solution/BookingByStep/index.d.ts +1 -1
  54. package/dist/solution/BookingByStep/types.d.ts +3 -1
  55. package/dist/solution/BookingByStep/types.js +5 -1
  56. package/dist/solution/ScanOrder/index.d.ts +90 -0
  57. package/dist/solution/ScanOrder/index.js +1853 -0
  58. package/dist/solution/ScanOrder/types.d.ts +210 -0
  59. package/dist/solution/ScanOrder/types.js +16 -0
  60. package/dist/solution/ScanOrder/utils.d.ts +93 -0
  61. package/dist/solution/ScanOrder/utils.js +378 -0
  62. package/dist/solution/VenueBooking/index.d.ts +159 -0
  63. package/dist/solution/VenueBooking/index.js +2773 -0
  64. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  65. package/dist/solution/VenueBooking/types.d.ts +123 -0
  66. package/dist/solution/VenueBooking/types.js +21 -0
  67. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
  68. package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
  69. package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
  70. package/dist/solution/VenueBooking/utils/resource.js +94 -0
  71. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +18 -0
  72. package/dist/solution/VenueBooking/utils/slotMerge.js +128 -0
  73. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  74. package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
  75. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  76. package/dist/solution/VenueBooking/utils.js +1 -0
  77. package/dist/solution/index.d.ts +2 -0
  78. package/dist/solution/index.js +3 -1
  79. package/lib/apis/picoding.d.ts +0 -0
  80. package/lib/apis/picoding.js +0 -0
  81. package/lib/model/strategy/adapter/index.d.ts +2 -0
  82. package/lib/model/strategy/adapter/index.js +6 -0
  83. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
  84. package/lib/model/strategy/adapter/itemRule/adapter.js +338 -0
  85. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  86. package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
  87. package/lib/model/strategy/adapter/itemRule/examples.d.ts +64 -0
  88. package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
  89. package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
  90. package/lib/model/strategy/adapter/itemRule/index.js +58 -0
  91. package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
  92. package/lib/model/strategy/adapter/itemRule/type.js +46 -0
  93. package/lib/model/strategy/adapter/walletPass/utils.js +2 -2
  94. package/lib/modules/OpenData/index.d.ts +23 -0
  95. package/lib/modules/OpenData/index.js +116 -0
  96. package/lib/modules/OpenData/types.d.ts +73 -0
  97. package/lib/modules/OpenData/types.js +17 -0
  98. package/lib/modules/OpenData/utils.d.ts +2 -0
  99. package/lib/modules/OpenData/utils.js +111 -0
  100. package/lib/modules/Order/index.d.ts +53 -1
  101. package/lib/modules/Order/index.js +389 -1
  102. package/lib/modules/Order/types.d.ts +144 -12
  103. package/lib/modules/Order/utils.d.ts +25 -0
  104. package/lib/modules/Order/utils.js +217 -0
  105. package/lib/modules/Product/utils.js +2 -2
  106. package/lib/modules/ProductList/index.d.ts +1 -1
  107. package/lib/modules/ProductList/index.js +2 -1
  108. package/lib/modules/Quotation/index.d.ts +40 -0
  109. package/lib/modules/Quotation/index.js +128 -0
  110. package/lib/modules/Quotation/types.d.ts +42 -0
  111. package/lib/modules/Quotation/types.js +17 -0
  112. package/lib/modules/Rules/index.js +1 -1
  113. package/lib/modules/SalesSummary/index.d.ts +63 -0
  114. package/lib/modules/SalesSummary/index.js +105 -0
  115. package/lib/modules/SalesSummary/types.d.ts +59 -0
  116. package/lib/modules/SalesSummary/types.js +17 -0
  117. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  118. package/lib/modules/SalesSummary/utils.js +445 -0
  119. package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
  120. package/lib/modules/ScanOrderLogger/index.js +135 -0
  121. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  122. package/lib/modules/ScanOrderLogger/providers/feishu.js +82 -0
  123. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  124. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  125. package/lib/modules/ScanOrderLogger/types.d.ts +46 -0
  126. package/lib/modules/ScanOrderLogger/types.js +17 -0
  127. package/lib/modules/Summary/utils.d.ts +3 -3
  128. package/lib/modules/Summary/utils.js +4 -4
  129. package/lib/modules/index.d.ts +4 -0
  130. package/lib/modules/index.js +9 -1
  131. package/lib/solution/BookingByStep/index.d.ts +1 -1
  132. package/lib/solution/BookingByStep/types.d.ts +3 -1
  133. package/lib/solution/BookingByStep/types.js +10 -0
  134. package/lib/solution/ScanOrder/index.d.ts +90 -0
  135. package/lib/solution/ScanOrder/index.js +1071 -0
  136. package/lib/solution/ScanOrder/types.d.ts +210 -0
  137. package/lib/solution/ScanOrder/types.js +36 -0
  138. package/lib/solution/ScanOrder/utils.d.ts +93 -0
  139. package/lib/solution/ScanOrder/utils.js +342 -0
  140. package/lib/solution/VenueBooking/index.d.ts +159 -0
  141. package/lib/solution/VenueBooking/index.js +1508 -0
  142. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  143. package/lib/solution/VenueBooking/types.d.ts +123 -0
  144. package/lib/solution/VenueBooking/types.js +44 -0
  145. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
  146. package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
  147. package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
  148. package/lib/solution/VenueBooking/utils/resource.js +80 -0
  149. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +18 -0
  150. package/lib/solution/VenueBooking/utils/slotMerge.js +156 -0
  151. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  152. package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
  153. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  154. package/lib/solution/VenueBooking/utils.js +69 -0
  155. package/lib/solution/index.d.ts +2 -0
  156. package/lib/solution/index.js +5 -1
  157. package/package.json +1 -1
@@ -0,0 +1,269 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/model/strategy/adapter/itemRule/examples.ts
20
+ var examples_exports = {};
21
+ __export(examples_exports, {
22
+ HOTPOT_BASE_REQUIRED_STRATEGY: () => HOTPOT_BASE_REQUIRED_STRATEGY,
23
+ MAX_BUNS_PER_TABLE_STRATEGY: () => MAX_BUNS_PER_TABLE_STRATEGY,
24
+ MIN_CONDIMENT_PER_PERSON_STRATEGY: () => MIN_CONDIMENT_PER_PERSON_STRATEGY,
25
+ quickUseItemRuleEvaluator: () => quickUseItemRuleEvaluator,
26
+ runItemRuleEvaluatorDemo: () => runItemRuleEvaluatorDemo
27
+ });
28
+ module.exports = __toCommonJS(examples_exports);
29
+ var import_evaluator = require("./evaluator");
30
+ var import_type = require("./type");
31
+ var MIN_CONDIMENT_PER_PERSON_STRATEGY = {
32
+ metadata: {
33
+ id: "RULE_MIN_CONDIMENT_PER_PERSON",
34
+ name: {
35
+ "zh-CN": "每人至少一份小料",
36
+ en: "Min 1 Condiment per person"
37
+ },
38
+ type: "item_rule",
39
+ description: {
40
+ "zh-CN": "火锅小料数量不少于成人人数,自动添加",
41
+ en: "Condiment count must be at least adult pax, auto-added to cart"
42
+ }
43
+ },
44
+ conditions: {
45
+ operator: "and",
46
+ rules: [],
47
+ actionIds: ["quantity_check_condiment", "prefill_condiment"]
48
+ },
49
+ actions: [
50
+ {
51
+ id: "quantity_check_condiment",
52
+ type: import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK,
53
+ value: null,
54
+ target: "cart",
55
+ priority: 10,
56
+ config: {
57
+ targetType: "product",
58
+ targets: [{ product_id: 10001 }, { product_id: 10002 }],
59
+ quantityRules: [
60
+ { comparison: "minimum", source: "total_pax" }
61
+ ],
62
+ scope: "first_submission_only",
63
+ validationMessage: {
64
+ "zh-CN": "小料至少需要 {min} 份(每位成人一份)",
65
+ en: "Condiment requires at least {min} items (one per adult)"
66
+ }
67
+ }
68
+ },
69
+ {
70
+ id: "prefill_condiment",
71
+ type: import_type.ITEM_RULE_ACTION_TYPES.PREFILL_CART,
72
+ value: null,
73
+ target: "cart",
74
+ priority: 5,
75
+ config: {
76
+ products: [
77
+ {
78
+ product_id: 10001,
79
+ quantityFrom: "total_pax"
80
+ }
81
+ ]
82
+ }
83
+ }
84
+ ]
85
+ };
86
+ var MAX_BUNS_PER_TABLE_STRATEGY = {
87
+ metadata: {
88
+ id: "RULE_MAX_BUNS_PER_TABLE",
89
+ name: {
90
+ "zh-CN": "每桌限量供应3份包子",
91
+ en: "3 Buns limit per table"
92
+ },
93
+ type: "item_rule",
94
+ description: {
95
+ "zh-CN": "肉包和菜包合计每桌不超过3份,含加单累计",
96
+ en: "Max 3 buns per table (pork + veggie combined, cumulative)"
97
+ }
98
+ },
99
+ conditions: {
100
+ operator: "and",
101
+ rules: [],
102
+ actionIds: ["quantity_check_buns"]
103
+ },
104
+ actions: [
105
+ {
106
+ id: "quantity_check_buns",
107
+ type: import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK,
108
+ value: null,
109
+ target: "cart",
110
+ priority: 10,
111
+ config: {
112
+ targetType: "product",
113
+ targets: [
114
+ { product_id: 20001 },
115
+ { product_id: 20002 }
116
+ ],
117
+ quantityRules: [
118
+ { comparison: "maximum", source: "fixed", value: 3 }
119
+ ],
120
+ scope: "cumulative",
121
+ validationMessage: {
122
+ "zh-CN": "包子每桌限量 {max} 份(含加单累计)",
123
+ en: "Buns are limited to {max} per table (cumulative)"
124
+ }
125
+ }
126
+ }
127
+ ]
128
+ };
129
+ var HOTPOT_BASE_REQUIRED_STRATEGY = {
130
+ metadata: {
131
+ id: "RULE_HOTPOT_BASE_REQUIRED",
132
+ name: {
133
+ "zh-CN": "锅底必选",
134
+ en: "Hotpot base required"
135
+ },
136
+ type: "item_rule",
137
+ description: {
138
+ "zh-CN": "堂食必须选择一个锅底",
139
+ en: "Hotpot base is mandatory for dine-in"
140
+ }
141
+ },
142
+ conditions: {
143
+ operator: "and",
144
+ rules: [
145
+ {
146
+ type: "operator",
147
+ dimension: "context",
148
+ field: "serviceType",
149
+ operator: "=",
150
+ value: "dine-in"
151
+ }
152
+ ],
153
+ actionIds: ["quantity_check_base", "prefill_base"]
154
+ },
155
+ actions: [
156
+ {
157
+ id: "quantity_check_base",
158
+ type: import_type.ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK,
159
+ value: null,
160
+ target: "cart",
161
+ priority: 10,
162
+ config: {
163
+ targetType: "product",
164
+ targets: [{ product_id: 30001 }],
165
+ quantityRules: [
166
+ { comparison: "exact", source: "fixed", value: 1 }
167
+ ],
168
+ scope: "first_submission_only",
169
+ validationMessage: {
170
+ "zh-CN": "请选择 {exact} 个锅底",
171
+ en: "Please select exactly {exact} hotpot base"
172
+ }
173
+ }
174
+ },
175
+ {
176
+ id: "prefill_base",
177
+ type: import_type.ITEM_RULE_ACTION_TYPES.PREFILL_CART,
178
+ value: null,
179
+ target: "cart",
180
+ priority: 5,
181
+ config: {
182
+ products: [
183
+ {
184
+ product_id: 30001,
185
+ quantityFrom: "fixed",
186
+ quantity: 1
187
+ }
188
+ ]
189
+ }
190
+ }
191
+ ]
192
+ };
193
+ function quickUseItemRuleEvaluator() {
194
+ const evaluator = new import_evaluator.ItemRuleEvaluator();
195
+ evaluator.setStrategyConfigs([
196
+ MIN_CONDIMENT_PER_PERSON_STRATEGY,
197
+ MAX_BUNS_PER_TABLE_STRATEGY,
198
+ HOTPOT_BASE_REQUIRED_STRATEGY
199
+ ]);
200
+ const businessData = {
201
+ pax: { total: 3, adult: 3, child: 0 },
202
+ serviceType: "dine-in",
203
+ cartItems: [
204
+ { product_id: 10001, quantity: 1 },
205
+ { product_id: 20001, quantity: 2 },
206
+ { product_id: 20002, quantity: 1 }
207
+ ],
208
+ historicalItems: [{ product_id: 20001, quantity: 1 }],
209
+ submissionIndex: 0
210
+ };
211
+ return {
212
+ configCount: evaluator.getStrategyConfigs().length,
213
+ evaluation: evaluator.evaluate(businessData),
214
+ quantityLimits: evaluator.getQuantityLimits(businessData),
215
+ validation: evaluator.validateCart(businessData),
216
+ prefillItems: evaluator.getPrefillItems(businessData)
217
+ };
218
+ }
219
+ function runItemRuleEvaluatorDemo() {
220
+ const evaluator = new import_evaluator.ItemRuleEvaluator();
221
+ evaluator.setStrategyConfigs([
222
+ MIN_CONDIMENT_PER_PERSON_STRATEGY
223
+ // MAX_BUNS_PER_TABLE_STRATEGY,
224
+ // HOTPOT_BASE_REQUIRED_STRATEGY,
225
+ ]);
226
+ const firstSubmissionData = {
227
+ pax: { total: 4, adult: 3, child: 1 },
228
+ serviceType: "dine-in",
229
+ submissionIndex: 0,
230
+ cartItems: [
231
+ { product_id: 10001, quantity: 3 }
232
+ // { product_id: 20001, quantity: 2 },
233
+ // { product_id: 20002, quantity: 1 },
234
+ ],
235
+ historicalItems: [{ product_id: 20001, quantity: 1 }]
236
+ };
237
+ const additionalSubmissionData = {
238
+ ...firstSubmissionData,
239
+ submissionIndex: 1
240
+ };
241
+ const firstEvaluation = evaluator.evaluate(firstSubmissionData);
242
+ const additionalEvaluation = evaluator.evaluate(additionalSubmissionData);
243
+ const quantityLimits = evaluator.getQuantityLimits(firstSubmissionData);
244
+ const validateResult = evaluator.validateCart(firstSubmissionData);
245
+ const prefillItems = evaluator.getPrefillItems(firstSubmissionData);
246
+ const baseOnlyEvaluation = evaluator.evaluate({
247
+ ...firstSubmissionData,
248
+ strategyConfigs: [HOTPOT_BASE_REQUIRED_STRATEGY]
249
+ });
250
+ return {
251
+ // configuredRuleIds: evaluator
252
+ // .getStrategyConfigs()
253
+ // .map((config) => config.metadata.id),
254
+ firstEvaluation,
255
+ // additionalEvaluation,
256
+ // quantityLimits,
257
+ validateResult,
258
+ prefillItems
259
+ // baseOnlyEvaluation,
260
+ };
261
+ }
262
+ // Annotate the CommonJS export names for ESM import in node:
263
+ 0 && (module.exports = {
264
+ HOTPOT_BASE_REQUIRED_STRATEGY,
265
+ MAX_BUNS_PER_TABLE_STRATEGY,
266
+ MIN_CONDIMENT_PER_PERSON_STRATEGY,
267
+ quickUseItemRuleEvaluator,
268
+ runItemRuleEvaluatorDemo
269
+ });
@@ -0,0 +1,5 @@
1
+ export { ItemRuleEvaluator } from './evaluator';
2
+ export { ItemRuleAdapter } from './adapter';
3
+ export { default } from './adapter';
4
+ export { MIN_CONDIMENT_PER_PERSON_STRATEGY, MAX_BUNS_PER_TABLE_STRATEGY, HOTPOT_BASE_REQUIRED_STRATEGY, quickUseItemRuleEvaluator, runItemRuleEvaluatorDemo, } from './examples';
5
+ export * from './type';
@@ -0,0 +1,58 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/model/strategy/adapter/itemRule/index.ts
31
+ var itemRule_exports = {};
32
+ __export(itemRule_exports, {
33
+ HOTPOT_BASE_REQUIRED_STRATEGY: () => import_examples.HOTPOT_BASE_REQUIRED_STRATEGY,
34
+ ItemRuleAdapter: () => import_adapter.ItemRuleAdapter,
35
+ ItemRuleEvaluator: () => import_evaluator.ItemRuleEvaluator,
36
+ MAX_BUNS_PER_TABLE_STRATEGY: () => import_examples.MAX_BUNS_PER_TABLE_STRATEGY,
37
+ MIN_CONDIMENT_PER_PERSON_STRATEGY: () => import_examples.MIN_CONDIMENT_PER_PERSON_STRATEGY,
38
+ default: () => import_adapter2.default,
39
+ quickUseItemRuleEvaluator: () => import_examples.quickUseItemRuleEvaluator,
40
+ runItemRuleEvaluatorDemo: () => import_examples.runItemRuleEvaluatorDemo
41
+ });
42
+ module.exports = __toCommonJS(itemRule_exports);
43
+ var import_evaluator = require("./evaluator");
44
+ var import_adapter = require("./adapter");
45
+ var import_adapter2 = __toESM(require("./adapter"));
46
+ var import_examples = require("./examples");
47
+ __reExport(itemRule_exports, require("./type"), module.exports);
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ HOTPOT_BASE_REQUIRED_STRATEGY,
51
+ ItemRuleAdapter,
52
+ ItemRuleEvaluator,
53
+ MAX_BUNS_PER_TABLE_STRATEGY,
54
+ MIN_CONDIMENT_PER_PERSON_STRATEGY,
55
+ quickUseItemRuleEvaluator,
56
+ runItemRuleEvaluatorDemo,
57
+ ...require("./type")
58
+ });
@@ -0,0 +1,206 @@
1
+ import type { StrategyConfig, EvaluationResult } from '../../type';
2
+ export declare const ITEM_RULE_ACTION_TYPES: {
3
+ /** 数量校验 */
4
+ readonly QUANTITY_CHECK: "QUANTITY_CHECK";
5
+ /** 预填购物车 */
6
+ readonly PREFILL_CART: "PREFILL_CART";
7
+ };
8
+ export type ItemRuleActionType = (typeof ITEM_RULE_ACTION_TYPES)[keyof typeof ITEM_RULE_ACTION_TYPES];
9
+ export declare const ITEM_RULE_TEMPLATES: {
10
+ /** 空白规则 */
11
+ readonly BLANK: "blank";
12
+ /** 人数关联最少量(每人至少N份) */
13
+ readonly MINIMUM_PER_PERSON: "minimum_per_person";
14
+ /** 每桌限量 */
15
+ readonly MAXIMUM_PER_TABLE: "maximum_per_table";
16
+ /** 必选商品 */
17
+ readonly MUST_INCLUDE: "must_include";
18
+ };
19
+ export type ItemRuleTemplate = (typeof ITEM_RULE_TEMPLATES)[keyof typeof ITEM_RULE_TEMPLATES];
20
+ /** 数量比较类型 */
21
+ export type QuantityComparison = 'minimum' | 'maximum' | 'exact' | 'must_include';
22
+ /** 数量来源 */
23
+ export type QuantitySource = 'total_pax' | 'adult_pax' | 'fixed';
24
+ /** 目标类型(当前仅支持按商品) */
25
+ export type TargetType = 'product';
26
+ /** 作用范围 */
27
+ export type RuleScope = 'each_submission' | 'first_submission_only' | 'subsequent_only' | 'cumulative';
28
+ /**
29
+ * 单条数量规则
30
+ *
31
+ * 例如:Minimum + Total Pax 表示"最少数量 = 总人数"
32
+ * 例如:Maximum + Fixed + 10 表示"最多10份"
33
+ */
34
+ export interface QuantityRule {
35
+ /** 比较方式 */
36
+ comparison: QuantityComparison;
37
+ /** 数量来源 */
38
+ source: QuantitySource;
39
+ /** 固定值(当 source 为 'fixed' 时使用) */
40
+ value?: number;
41
+ }
42
+ /**
43
+ * Quantity Check Action 的详细配置
44
+ *
45
+ * 存储在 ActionEffect.config 中
46
+ */
47
+ export interface QuantityCheckConfig {
48
+ /** 目标类型 */
49
+ targetType: TargetType;
50
+ /** 目标商品 ID 列表 */
51
+ targets: TargetItem[];
52
+ /** 数量规则列表(多条规则同时生效) */
53
+ quantityRules: QuantityRule[];
54
+ /** 作用范围 */
55
+ scope: RuleScope;
56
+ /** 校验失败时的提示语,支持 {min} {max} 占位符,支持多语言 */
57
+ validationMessage?: string | Record<string, string>;
58
+ }
59
+ /** 目标项 */
60
+ export interface TargetItem {
61
+ /** 目标商品 ID */
62
+ product_id: number;
63
+ /** 变体 ID */
64
+ product_variant_id?: number;
65
+ }
66
+ /**
67
+ * 预填商品项
68
+ */
69
+ export interface PrefillProduct {
70
+ /** 商品 ID */
71
+ product_id: number;
72
+ /** 变体 ID(可选,0 或不填表示无变体/默认) */
73
+ product_variant_id?: number;
74
+ /** 数量来源 */
75
+ quantityFrom: QuantitySource;
76
+ /** 固定数量(当 quantityFrom 为 'fixed' 时使用) */
77
+ quantity?: number;
78
+ }
79
+ /**
80
+ * Prefill Cart Action 的详细配置
81
+ *
82
+ * 存储在 ActionEffect.config 中
83
+ */
84
+ export interface PrefillCartConfig {
85
+ /** 要预填的商品列表 */
86
+ products: PrefillProduct[];
87
+ }
88
+ /**
89
+ * 购物车商品摘要
90
+ */
91
+ export interface CartItemSummary {
92
+ /** 商品 ID */
93
+ product_id: number;
94
+ /** 变体 ID */
95
+ product_variant_id?: number;
96
+ /** 数量 */
97
+ quantity: number;
98
+ }
99
+ /**
100
+ * 就餐人数信息
101
+ */
102
+ export interface PaxInfo {
103
+ /** 总人数 */
104
+ total: number;
105
+ /** 成人人数 */
106
+ adult: number;
107
+ /** 儿童人数 */
108
+ child: number;
109
+ }
110
+ /**
111
+ * ItemRule 评估器的输入业务数据
112
+ */
113
+ export interface ItemRuleBusinessData {
114
+ /** 就餐人数 */
115
+ pax: PaxInfo;
116
+ /** 当前购物车商品列表 */
117
+ cartItems: CartItemSummary[];
118
+ /** 历史订单商品列表(用于 cumulative scope,主订单+加单的商品汇总) */
119
+ historicalItems?: CartItemSummary[];
120
+ /** 服务类型(如 'dine-in', 'takeaway') */
121
+ serviceType?: string;
122
+ /** 当前提交次数(0=首次提交, >0=追加提交) */
123
+ submissionIndex?: number;
124
+ /** 策略配置列表(可选,如果不传则使用 setStrategyConfigs 设置的) */
125
+ strategyConfigs?: StrategyConfig[];
126
+ /** 自定义属性(会合并到 context.attributes) */
127
+ custom?: Record<string, any>;
128
+ }
129
+ /**
130
+ * 单个 Quantity Check 的校验结果
131
+ */
132
+ export interface QuantityCheckResult {
133
+ /** 规则 ID(对应 ActionEffect.id) */
134
+ ruleId: string;
135
+ /** 是否通过校验 */
136
+ passed: boolean;
137
+ /** 目标类型 */
138
+ targetType: TargetType;
139
+ /** 目标列表 */
140
+ targets: TargetItem[];
141
+ /** 当前购物车中的实际数量 */
142
+ actualQuantity: number;
143
+ /** 要求的最小数量(根据规则计算后的值) */
144
+ requiredMin?: number;
145
+ /** 要求的最大数量 */
146
+ requiredMax?: number;
147
+ /** 要求的精确数量 */
148
+ requiredExact?: number;
149
+ /** 是否必须包含(must_include) */
150
+ mustInclude?: boolean;
151
+ /** 格式化后的校验提示语 */
152
+ validationMessage?: string;
153
+ /** 作用范围 */
154
+ scope: RuleScope;
155
+ /** 未通过的具体规则 */
156
+ failedRules?: QuantityRule[];
157
+ }
158
+ /**
159
+ * 单个 Prefill Cart 的预填结果
160
+ */
161
+ export interface PrefillItemResult {
162
+ /** 规则 ID(对应 ActionEffect.id) */
163
+ ruleId: string;
164
+ /** 商品 ID */
165
+ product_id: number;
166
+ /** 变体 ID */
167
+ product_variant_id?: number;
168
+ /** 应添加的数量 */
169
+ quantity: number;
170
+ }
171
+ /**
172
+ * 单条规则的数量限制(不含校验结果,仅描述配置中的约束)
173
+ */
174
+ export interface QuantityLimitResult {
175
+ /** 规则 ID(对应 ActionEffect.id) */
176
+ ruleId: string;
177
+ /** 目标类型 */
178
+ targetType: TargetType;
179
+ /** 目标列表 */
180
+ targets: TargetItem[];
181
+ /** 要求的最小数量 */
182
+ requiredMin?: number;
183
+ /** 要求的最大数量 */
184
+ requiredMax?: number;
185
+ /** 要求的精确数量 */
186
+ requiredExact?: number;
187
+ /** 是否必须包含 */
188
+ mustInclude?: boolean;
189
+ /** 作用范围 */
190
+ scope: RuleScope;
191
+ }
192
+ /**
193
+ * ItemRule 评估器的完整输出结果
194
+ */
195
+ export interface ItemRuleEvaluationResult {
196
+ /** 所有数量校验结果 */
197
+ quantityChecks: QuantityCheckResult[];
198
+ /** 需要预填的商品列表 */
199
+ prefillItems: PrefillItemResult[];
200
+ /** 所有校验是否全部通过 */
201
+ allPassed: boolean;
202
+ /** 未通过的校验列表 */
203
+ failedChecks: QuantityCheckResult[];
204
+ /** 原始策略评估结果列表 */
205
+ rawResults: EvaluationResult[];
206
+ }
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/model/strategy/adapter/itemRule/type.ts
20
+ var type_exports = {};
21
+ __export(type_exports, {
22
+ ITEM_RULE_ACTION_TYPES: () => ITEM_RULE_ACTION_TYPES,
23
+ ITEM_RULE_TEMPLATES: () => ITEM_RULE_TEMPLATES
24
+ });
25
+ module.exports = __toCommonJS(type_exports);
26
+ var ITEM_RULE_ACTION_TYPES = {
27
+ /** 数量校验 */
28
+ QUANTITY_CHECK: "QUANTITY_CHECK",
29
+ /** 预填购物车 */
30
+ PREFILL_CART: "PREFILL_CART"
31
+ };
32
+ var ITEM_RULE_TEMPLATES = {
33
+ /** 空白规则 */
34
+ BLANK: "blank",
35
+ /** 人数关联最少量(每人至少N份) */
36
+ MINIMUM_PER_PERSON: "minimum_per_person",
37
+ /** 每桌限量 */
38
+ MAXIMUM_PER_TABLE: "maximum_per_table",
39
+ /** 必选商品 */
40
+ MUST_INCLUDE: "must_include"
41
+ };
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ ITEM_RULE_ACTION_TYPES,
45
+ ITEM_RULE_TEMPLATES
46
+ });
@@ -694,7 +694,7 @@ var getProductDiscountDifference = (product) => {
694
694
  return new import_decimal.default(((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.product_discount_difference) || 0).toNumber();
695
695
  };
696
696
  var getMainProductPrice = (product, isDeductTaxAndFee) => {
697
- var _a, _b, _c, _d;
697
+ var _a, _b, _c, _d, _e;
698
698
  let mainProductPrice = new import_decimal.default((product == null ? void 0 : product.main_product_selling_price) || ((_a = product.metadata) == null ? void 0 : _a.main_product_selling_price) || 0);
699
699
  for (let bundleItem of (product == null ? void 0 : product.product_bundle) || []) {
700
700
  if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
@@ -706,7 +706,7 @@ var getMainProductPrice = (product, isDeductTaxAndFee) => {
706
706
  if (product.is_price_include_tax === 1) {
707
707
  taxFee = new import_decimal.default(0);
708
708
  }
709
- const surchargeFee = new import_decimal.default(((_d = product == null ? void 0 : product.metadata) == null ? void 0 : _d.main_product_attached_bundle_surcharge_fee) || 0);
709
+ const surchargeFee = new import_decimal.default(((_d = product == null ? void 0 : product.metadata) == null ? void 0 : _d.main_product_attached_bundle_surcharge_fee) || 0).add(((_e = product == null ? void 0 : product.metadata) == null ? void 0 : _e.surcharge_rounding_remainder) || 0);
710
710
  const taxAndFeeTotal = taxFee.add(surchargeFee);
711
711
  if (isDeductTaxAndFee) {
712
712
  mainProductPrice = mainProductPrice.add(taxAndFeeTotal);
@@ -0,0 +1,23 @@
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import type { ScheduleModule } from '../Schedule';
4
+ import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult } from './types';
5
+ export * from './types';
6
+ export { computeAvailability } from './utils';
7
+ export declare class OpenDataModule extends BaseModule implements Module {
8
+ protected defaultName: string;
9
+ protected defaultVersion: string;
10
+ private request;
11
+ private window;
12
+ private store;
13
+ private cacheId;
14
+ private openCache;
15
+ private fatherModule;
16
+ private otherParams;
17
+ constructor(name?: string, version?: string);
18
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
19
+ fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
20
+ getOpenData(): OpenDataConfig | null;
21
+ checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
22
+ storeChange(): void;
23
+ }