@pisell/pisellos 2.2.323 → 2.2.325

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 (199) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/inventory/index.d.ts +92 -0
  4. package/dist/inventory/index.js +509 -0
  5. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  6. package/dist/modules/BookingContext/index.d.ts +2 -2
  7. package/dist/modules/BookingContext/index.js +55 -25
  8. package/dist/modules/BookingContext/types.d.ts +2 -0
  9. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  10. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  11. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  12. package/dist/modules/BookingContext/utils/index.js +1 -0
  13. package/dist/modules/BookingContext/utils/productExtend.d.ts +20 -1
  14. package/dist/modules/BookingContext/utils/productExtend.js +122 -29
  15. package/dist/modules/Date/index.d.ts +1 -1
  16. package/dist/modules/Date/index.js +60 -14
  17. package/dist/modules/Date/types.d.ts +5 -0
  18. package/dist/modules/Discount/index.js +1 -0
  19. package/dist/modules/OpenData/index.d.ts +1 -0
  20. package/dist/modules/OpenData/index.js +1 -0
  21. package/dist/modules/OpenData/salesSettings.d.ts +32 -0
  22. package/dist/modules/OpenData/salesSettings.js +80 -0
  23. package/dist/modules/OpenData/types.d.ts +16 -0
  24. package/dist/modules/OpenData/utils.d.ts +1 -1
  25. package/dist/modules/OpenData/utils.js +3 -2
  26. package/dist/modules/Order/index.d.ts +55 -12
  27. package/dist/modules/Order/index.js +2699 -1411
  28. package/dist/modules/Order/types.d.ts +43 -5
  29. package/dist/modules/Order/types.js +4 -0
  30. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  31. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  32. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  33. package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  34. package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
  35. package/dist/modules/Order/utils.d.ts +3 -1
  36. package/dist/modules/Order/utils.js +6 -2
  37. package/dist/modules/Product/index.d.ts +1 -1
  38. package/dist/modules/ProductList/clientDataVariants.js +6 -2
  39. package/dist/modules/ProductList/index.d.ts +2 -0
  40. package/dist/modules/ProductList/index.js +161 -51
  41. package/dist/modules/ResourcePlanner/planner.js +58 -2
  42. package/dist/modules/ResourcePlanner/types.d.ts +13 -0
  43. package/dist/modules/Rules/index.d.ts +2 -0
  44. package/dist/modules/Rules/index.js +58 -39
  45. package/dist/modules/Schedule/index.d.ts +7 -1
  46. package/dist/modules/Schedule/index.js +155 -39
  47. package/dist/modules/Schedule/types.d.ts +2 -0
  48. package/dist/modules/bookingReadValidation.d.ts +6 -0
  49. package/dist/modules/bookingReadValidation.js +72 -0
  50. package/dist/plugins/request.d.ts +2 -0
  51. package/dist/server/index.d.ts +8 -0
  52. package/dist/server/index.js +1458 -1166
  53. package/dist/server/modules/order/index.js +2 -1
  54. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  55. package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
  56. package/dist/shared/receipt/small-ticket.d.ts +4 -0
  57. package/dist/shared/receipt/small-ticket.js +70 -12
  58. package/dist/solution/BaseSales/index.d.ts +39 -5
  59. package/dist/solution/BaseSales/index.js +1828 -1462
  60. package/dist/solution/BaseSales/types.d.ts +1 -0
  61. package/dist/solution/BaseSales/types.js +1 -0
  62. package/dist/solution/BookingByStep/index.d.ts +16 -2
  63. package/dist/solution/BookingByStep/index.js +676 -361
  64. package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
  65. package/dist/solution/BookingByStep/utils/resources.js +117 -76
  66. package/dist/solution/BookingTicket/index.d.ts +15 -3
  67. package/dist/solution/BookingTicket/index.js +249 -135
  68. package/dist/solution/BookingTicket/types.d.ts +14 -2
  69. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
  70. package/dist/solution/BookingTicket/utils/addProductDecision.js +39 -11
  71. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  72. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  73. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  74. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
  75. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  76. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  77. package/dist/solution/OrderInvoicePreview/index.js +14 -8
  78. package/dist/solution/ScanOrder/index.d.ts +2 -0
  79. package/dist/solution/ScanOrder/index.js +166 -67
  80. package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
  81. package/dist/solution/ScanOrder/menuAvailability.js +363 -0
  82. package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
  83. package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
  84. package/dist/solution/UnifiedBookingSales/index.d.ts +96 -4
  85. package/dist/solution/UnifiedBookingSales/index.js +3374 -1177
  86. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  87. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
  88. package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  89. package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
  90. package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  91. package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
  92. package/dist/solution/UnifiedBookingSales/types.d.ts +71 -2
  93. package/dist/solution/UnifiedBookingSales/types.js +7 -1
  94. package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  95. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +283 -0
  96. package/dist/utils/platform.d.ts +2 -0
  97. package/dist/utils/platform.js +6 -0
  98. package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
  99. package/dist/utils/pos-receipt-auto-print.js +14 -0
  100. package/lib/index.d.ts +1 -0
  101. package/lib/index.js +12 -0
  102. package/lib/inventory/index.d.ts +92 -0
  103. package/lib/inventory/index.js +287 -0
  104. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  105. package/lib/modules/BookingContext/index.d.ts +2 -2
  106. package/lib/modules/BookingContext/index.js +42 -10
  107. package/lib/modules/BookingContext/types.d.ts +2 -0
  108. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  109. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  110. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  111. package/lib/modules/BookingContext/utils/index.js +11 -0
  112. package/lib/modules/BookingContext/utils/productExtend.d.ts +20 -1
  113. package/lib/modules/BookingContext/utils/productExtend.js +96 -7
  114. package/lib/modules/Date/index.d.ts +1 -1
  115. package/lib/modules/Date/index.js +28 -5
  116. package/lib/modules/Date/types.d.ts +5 -0
  117. package/lib/modules/Discount/index.js +1 -0
  118. package/lib/modules/OpenData/index.d.ts +1 -0
  119. package/lib/modules/OpenData/index.js +12 -0
  120. package/lib/modules/OpenData/salesSettings.d.ts +32 -0
  121. package/lib/modules/OpenData/salesSettings.js +70 -0
  122. package/lib/modules/OpenData/types.d.ts +16 -0
  123. package/lib/modules/OpenData/utils.d.ts +1 -1
  124. package/lib/modules/OpenData/utils.js +3 -2
  125. package/lib/modules/Order/index.d.ts +55 -12
  126. package/lib/modules/Order/index.js +659 -80
  127. package/lib/modules/Order/types.d.ts +43 -5
  128. package/lib/modules/Order/types.js +2 -0
  129. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  130. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  131. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  132. package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  133. package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
  134. package/lib/modules/Order/utils.d.ts +3 -1
  135. package/lib/modules/Order/utils.js +6 -2
  136. package/lib/modules/Product/index.d.ts +1 -1
  137. package/lib/modules/ProductList/clientDataVariants.js +6 -2
  138. package/lib/modules/ProductList/index.d.ts +2 -0
  139. package/lib/modules/ProductList/index.js +74 -0
  140. package/lib/modules/ResourcePlanner/planner.js +52 -1
  141. package/lib/modules/ResourcePlanner/types.d.ts +13 -0
  142. package/lib/modules/Rules/index.d.ts +2 -0
  143. package/lib/modules/Rules/index.js +25 -9
  144. package/lib/modules/Schedule/index.d.ts +7 -1
  145. package/lib/modules/Schedule/index.js +68 -4
  146. package/lib/modules/Schedule/types.d.ts +2 -0
  147. package/lib/modules/bookingReadValidation.d.ts +6 -0
  148. package/lib/modules/bookingReadValidation.js +56 -0
  149. package/lib/plugins/request.d.ts +2 -0
  150. package/lib/server/index.d.ts +8 -0
  151. package/lib/server/index.js +194 -19
  152. package/lib/server/modules/order/index.js +2 -1
  153. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  154. package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
  155. package/lib/shared/receipt/small-ticket.d.ts +4 -0
  156. package/lib/shared/receipt/small-ticket.js +63 -8
  157. package/lib/solution/BaseSales/index.d.ts +39 -5
  158. package/lib/solution/BaseSales/index.js +212 -18
  159. package/lib/solution/BaseSales/types.d.ts +1 -0
  160. package/lib/solution/BaseSales/types.js +1 -0
  161. package/lib/solution/BookingByStep/index.d.ts +16 -2
  162. package/lib/solution/BookingByStep/index.js +222 -14
  163. package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
  164. package/lib/solution/BookingByStep/utils/resources.js +25 -15
  165. package/lib/solution/BookingTicket/index.d.ts +15 -3
  166. package/lib/solution/BookingTicket/index.js +47 -4
  167. package/lib/solution/BookingTicket/types.d.ts +14 -2
  168. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
  169. package/lib/solution/BookingTicket/utils/addProductDecision.js +37 -6
  170. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  171. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  172. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  173. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
  174. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  175. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  176. package/lib/solution/OrderInvoicePreview/index.js +7 -1
  177. package/lib/solution/ScanOrder/index.d.ts +2 -0
  178. package/lib/solution/ScanOrder/index.js +72 -2
  179. package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
  180. package/lib/solution/ScanOrder/menuAvailability.js +203 -0
  181. package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
  182. package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
  183. package/lib/solution/UnifiedBookingSales/index.d.ts +96 -4
  184. package/lib/solution/UnifiedBookingSales/index.js +1316 -73
  185. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  186. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
  187. package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  188. package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
  189. package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  190. package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
  191. package/lib/solution/UnifiedBookingSales/types.d.ts +71 -2
  192. package/lib/solution/UnifiedBookingSales/types.js +4 -1
  193. package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  194. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +155 -0
  195. package/lib/utils/platform.d.ts +2 -0
  196. package/lib/utils/platform.js +7 -0
  197. package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
  198. package/lib/utils/pos-receipt-auto-print.js +13 -0
  199. package/package.json +1 -1
@@ -99,7 +99,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
99
99
  }, {
100
100
  key: "updateOtherParams",
101
101
  value: function updateOtherParams(params) {
102
+ var previousScope = this.otherParams.catalogScopeKey;
102
103
  this.otherParams = params || {};
104
+ if (previousScope !== this.otherParams.catalogScopeKey && (previousScope || this.otherParams.catalogScopeKey)) {
105
+ this.store.list = [];
106
+ this.rawProductPriceSources.clear();
107
+ this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
108
+ }
103
109
  }
104
110
  }, {
105
111
  key: "storeChange",
@@ -155,12 +161,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
155
161
  key: "loadProducts",
156
162
  value: function () {
157
163
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
158
- var _this$otherParams,
164
+ var _this2 = this,
165
+ _this$otherParams,
159
166
  _this$otherParams$bus,
160
167
  _this$otherParams2,
161
168
  _this$otherParams3,
162
- _this$otherParams4,
163
- _this2 = this;
169
+ _this$otherParams4;
164
170
  var _ref,
165
171
  _ref$category_ids,
166
172
  category_ids,
@@ -182,6 +188,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
182
188
  status,
183
189
  strategy_context,
184
190
  options,
191
+ scope,
192
+ assertScope,
185
193
  userPlugin,
186
194
  customer_id,
187
195
  _userPlugin$get,
@@ -203,7 +211,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
203
211
  case 0:
204
212
  _ref = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
205
213
  options = _args5.length > 1 ? _args5[1] : undefined;
206
- // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
214
+ scope = this.otherParams.catalogScopeKey;
215
+ assertScope = function assertScope() {
216
+ if (scope !== _this2.otherParams.catalogScopeKey) throw Object.assign(new Error('Product catalog context changed'), {
217
+ name: 'AbortError'
218
+ });
219
+ }; // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
207
220
  // if (!schedule_ids?.length) {
208
221
  // const schedule_ids_data = this.store.schedule
209
222
  // .getScheduleListByIds(schedule_ids)
@@ -280,14 +293,20 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
280
293
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
281
294
  while (1) switch (_context4.prev = _context4.next) {
282
295
  case 0:
296
+ if (!(scope !== _this2.otherParams.catalogScopeKey)) {
297
+ _context4.next = 2;
298
+ break;
299
+ }
300
+ return _context4.abrupt("return");
301
+ case 2:
283
302
  callbackList = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list;
284
303
  if (Array.isArray(callbackList)) {
285
- _context4.next = 4;
304
+ _context4.next = 6;
286
305
  break;
287
306
  }
288
307
  originalCallback(result);
289
308
  return _context4.abrupt("return");
290
- case 4:
309
+ case 6:
291
310
  if (!handledByOsServer) {
292
311
  // Subscription callbacks may contain only changed products. Upsert
293
312
  // their raw records without evicting other IDs from the scope.
@@ -300,15 +319,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
300
319
  queryPayload: queryPayload,
301
320
  handledByOsServer: handledByOsServer
302
321
  });
303
- _context4.next = 8;
322
+ assertScope();
323
+ _context4.next = 11;
304
324
  return _this2.addProduct(products);
305
- case 8:
325
+ case 11:
306
326
  originalCallback(handledByOsServer ? result : _objectSpread(_objectSpread({}, result), {}, {
307
327
  data: _objectSpread(_objectSpread({}, result.data), {}, {
308
328
  list: products
309
329
  })
310
330
  }));
311
- case 9:
331
+ case 12:
312
332
  case "end":
313
333
  return _context4.stop();
314
334
  }
@@ -318,15 +338,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
318
338
  return _ref2.apply(this, arguments);
319
339
  };
320
340
  }()) : undefined;
321
- _context5.next = 16;
341
+ _context5.next = 18;
322
342
  return this.request.post("/product/query", queryPayload, {
323
343
  osServer: true,
324
344
  callback: subscriptionCallback,
325
345
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
326
346
  customToast: function customToast() {}
327
347
  });
328
- case 16:
348
+ case 18:
329
349
  productsData = _context5.sent;
350
+ assertScope();
330
351
  if (!handledByOsServer && Array.isArray(productsData.data.list)) {
331
352
  this.replaceRawProductQueryResult(productsData.data.list, product_ids);
332
353
  }
@@ -348,7 +369,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
348
369
  // }
349
370
  this.addProduct(sortedList);
350
371
  return _context5.abrupt("return", sortedList);
351
- case 22:
372
+ case 25:
352
373
  case "end":
353
374
  return _context5.stop();
354
375
  }
@@ -390,11 +411,100 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
390
411
  return _loadProductsPrice.apply(this, arguments);
391
412
  }
392
413
  return loadProductsPrice;
414
+ }() /** Venue-only raw, complete pool load. No date/customer evaluation and no shared catalog publication. */
415
+ }, {
416
+ key: "loadVenueCatalogPool",
417
+ value: (function () {
418
+ var _loadVenueCatalogPool = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
419
+ var _this$otherParams5, _params$product_ids, _params$category_ids, _params$extension_typ, _ref4, _data$total;
420
+ var params,
421
+ channelMap,
422
+ channel,
423
+ response,
424
+ data,
425
+ total,
426
+ _args7 = arguments;
427
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
428
+ while (1) switch (_context7.prev = _context7.next) {
429
+ case 0:
430
+ params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
431
+ channelMap = {
432
+ online_store: 'online-store',
433
+ scan_to_order: 'online-store',
434
+ 'scan-to-order': 'online-store',
435
+ scan_to_order_2: 'online-store',
436
+ scan_to_order_3: 'scantoorder3'
437
+ };
438
+ channel = (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.channel;
439
+ _context7.next = 5;
440
+ return this.request.post('/product/query', _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
441
+ // Bypass the endpoint cache when seeding this pool; subsequent reads still
442
+ // reuse the venue catalog session's single local snapshot.
443
+ force_ignore_cache_flag: 1,
444
+ // The customer endpoint otherwise filters out future/variant members.
445
+ open_quotation: 0,
446
+ open_bundle: 1,
447
+ with: _toConsumableArray(PRODUCT_QUERY_DATA_VARIANT_RELATIONS),
448
+ with_count: ['bundleGroup', 'optionGroup'],
449
+ with_schedule: 1,
450
+ status: 'published',
451
+ num: 500,
452
+ skip: 1,
453
+ is_eject: 1,
454
+ // Channel is stable for this runtime owner and remains a server publication
455
+ // filter. Date/customer/menu membership and pricing are evaluated locally.
456
+ application_code: typeof channel === 'string' ? channelMap[channel] || channel : channel
457
+ }, (_params$product_ids = params.product_ids) !== null && _params$product_ids !== void 0 && _params$product_ids.length ? {
458
+ ids: params.product_ids
459
+ } : {}), params.collection ? {
460
+ collection: params.collection
461
+ } : {}), (_params$category_ids = params.category_ids) !== null && _params$category_ids !== void 0 && _params$category_ids.length ? {
462
+ category_ids: params.category_ids
463
+ } : {}), (_params$extension_typ = params.extension_type) !== null && _params$extension_typ !== void 0 && _params$extension_typ.length ? {
464
+ extension_type: params.extension_type
465
+ } : {}), {}, {
466
+ front_end_cache_id: params.cacheId
467
+ }), {
468
+ useCache: false,
469
+ customToast: function customToast() {}
470
+ });
471
+ case 5:
472
+ response = _context7.sent;
473
+ data = response === null || response === void 0 ? void 0 : response.data;
474
+ if (!((response === null || response === void 0 ? void 0 : response.status) === false || (response === null || response === void 0 ? void 0 : response.code) != null && Number(response.code) !== 200 || !Array.isArray(data === null || data === void 0 ? void 0 : data.list))) {
475
+ _context7.next = 9;
476
+ break;
477
+ }
478
+ throw Object.assign(new Error((response === null || response === void 0 ? void 0 : response.message) || 'The complete venue product pool could not be loaded.'), {
479
+ code: 'VENUE_CATALOG_LOAD_FAILED'
480
+ });
481
+ case 9:
482
+ total = (_ref4 = (_data$total = data.total) !== null && _data$total !== void 0 ? _data$total : data.total_count) !== null && _ref4 !== void 0 ? _ref4 : data.total_num;
483
+ if (!(total != null && Number.isFinite(Number(total)) && Number(total) > data.list.length || total == null && data.list.length >= 500)) {
484
+ _context7.next = 12;
485
+ break;
486
+ }
487
+ throw Object.assign(new Error('The venue product pool is incomplete. A single complete catalog response is required.'), {
488
+ code: 'VENUE_CATALOG_INCOMPLETE'
489
+ });
490
+ case 12:
491
+ return _context7.abrupt("return", cloneDeep(data.list));
492
+ case 13:
493
+ case "end":
494
+ return _context7.stop();
495
+ }
496
+ }, _callee7, this);
497
+ }));
498
+ function loadVenueCatalogPool() {
499
+ return _loadVenueCatalogPool.apply(this, arguments);
500
+ }
501
+ return loadVenueCatalogPool;
393
502
  }()
394
503
  /**
395
504
  * Remember raw remote product records before client-side Data Variant
396
505
  * evaluation. Quote-only reads can then always start from a clean baseline.
397
506
  */
507
+ )
398
508
  }, {
399
509
  key: "rememberRawProductQueryResult",
400
510
  value: function rememberRawProductQueryResult(products) {
@@ -448,19 +558,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
448
558
  }, {
449
559
  key: "getProducts",
450
560
  value: function () {
451
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
452
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
453
- while (1) switch (_context7.prev = _context7.next) {
561
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
562
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
563
+ while (1) switch (_context8.prev = _context8.next) {
454
564
  case 0:
455
- _context7.next = 2;
565
+ _context8.next = 2;
456
566
  return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
457
567
  case 2:
458
- return _context7.abrupt("return", cloneDeep(this.store.list));
568
+ return _context8.abrupt("return", cloneDeep(this.store.list));
459
569
  case 3:
460
570
  case "end":
461
- return _context7.stop();
571
+ return _context8.stop();
462
572
  }
463
- }, _callee7, this);
573
+ }, _callee8, this);
464
574
  }));
465
575
  function getProducts() {
466
576
  return _getProducts.apply(this, arguments);
@@ -470,23 +580,23 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
470
580
  }, {
471
581
  key: "getProduct",
472
582
  value: function () {
473
- var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
583
+ var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(id) {
474
584
  var product;
475
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
476
- while (1) switch (_context8.prev = _context8.next) {
585
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
586
+ while (1) switch (_context9.prev = _context9.next) {
477
587
  case 0:
478
- _context8.next = 2;
588
+ _context9.next = 2;
479
589
  return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
480
590
  case 2:
481
591
  product = this.store.list.find(function (product) {
482
592
  return product.id === id;
483
593
  });
484
- return _context8.abrupt("return", product ? cloneDeep(product) : undefined);
594
+ return _context9.abrupt("return", product ? cloneDeep(product) : undefined);
485
595
  case 4:
486
596
  case "end":
487
- return _context8.stop();
597
+ return _context9.stop();
488
598
  }
489
- }, _callee8, this);
599
+ }, _callee9, this);
490
600
  }));
491
601
  function getProduct(_x7) {
492
602
  return _getProduct.apply(this, arguments);
@@ -496,7 +606,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
496
606
  }, {
497
607
  key: "queryProducts",
498
608
  value: function () {
499
- var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
609
+ var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
500
610
  var params,
501
611
  includeIds,
502
612
  excludeIds,
@@ -507,11 +617,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
507
617
  channelApplications,
508
618
  codeOrBarcode,
509
619
  products,
510
- _args9 = arguments;
511
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
512
- while (1) switch (_context9.prev = _context9.next) {
620
+ _args10 = arguments;
621
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
622
+ while (1) switch (_context10.prev = _context10.next) {
513
623
  case 0:
514
- params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
624
+ params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
515
625
  includeIds = normalizeQuerySet(params.includeIds);
516
626
  excludeIds = normalizeQuerySet(params.excludeIds);
517
627
  categoryIds = normalizeQuerySet(params.categoryIds);
@@ -550,12 +660,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
550
660
  }
551
661
  return true;
552
662
  });
553
- return _context9.abrupt("return", cloneDeep(products));
663
+ return _context10.abrupt("return", cloneDeep(products));
554
664
  case 11:
555
665
  case "end":
556
- return _context9.stop();
666
+ return _context10.stop();
557
667
  }
558
- }, _callee9, this);
668
+ }, _callee10, this);
559
669
  }));
560
670
  function queryProducts() {
561
671
  return _queryProducts.apply(this, arguments);
@@ -565,21 +675,21 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
565
675
  }, {
566
676
  key: "getProductByIds",
567
677
  value: function () {
568
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(ids) {
569
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
570
- while (1) switch (_context10.prev = _context10.next) {
678
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(ids) {
679
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
680
+ while (1) switch (_context11.prev = _context11.next) {
571
681
  case 0:
572
- _context10.next = 2;
682
+ _context11.next = 2;
573
683
  return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
574
684
  case 2:
575
- return _context10.abrupt("return", this.queryProducts({
685
+ return _context11.abrupt("return", this.queryProducts({
576
686
  includeIds: ids
577
687
  }));
578
688
  case 3:
579
689
  case "end":
580
- return _context10.stop();
690
+ return _context11.stop();
581
691
  }
582
- }, _callee10, this);
692
+ }, _callee11, this);
583
693
  }));
584
694
  function getProductByIds(_x8) {
585
695
  return _getProductByIds.apply(this, arguments);
@@ -589,10 +699,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
589
699
  }, {
590
700
  key: "addProduct",
591
701
  value: function () {
592
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(products) {
702
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(products) {
593
703
  var _this6 = this;
594
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
595
- while (1) switch (_context11.prev = _context11.next) {
704
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
705
+ while (1) switch (_context12.prev = _context12.next) {
596
706
  case 0:
597
707
  // list 需要根据 id 去重
598
708
  if (!this.store.list) {
@@ -615,9 +725,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
615
725
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
616
726
  case 4:
617
727
  case "end":
618
- return _context11.stop();
728
+ return _context12.stop();
619
729
  }
620
- }, _callee11, this);
730
+ }, _callee12, this);
621
731
  }));
622
732
  function addProduct(_x9) {
623
733
  return _addProduct.apply(this, arguments);
@@ -627,16 +737,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
627
737
  }, {
628
738
  key: "selectProducts",
629
739
  value: function () {
630
- var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(products) {
631
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
632
- while (1) switch (_context12.prev = _context12.next) {
740
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(products) {
741
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
742
+ while (1) switch (_context13.prev = _context13.next) {
633
743
  case 0:
634
744
  this.store.selectProducts = products;
635
745
  case 1:
636
746
  case "end":
637
- return _context12.stop();
747
+ return _context13.stop();
638
748
  }
639
- }, _callee12, this);
749
+ }, _callee13, this);
640
750
  }));
641
751
  function selectProducts(_x10) {
642
752
  return _selectProducts.apply(this, arguments);
@@ -243,6 +243,16 @@ function isCandidateFromExcludedScheduleDate(params) {
243
243
  return getProductTimeRangeIdentity(range) === candidateIdentity;
244
244
  });
245
245
  }
246
+ function resolveRememberedDurationRange(product, value, timezoneName) {
247
+ if (value === undefined) return null;
248
+ var range = normalizeAbsoluteRange(value, timezoneName);
249
+ if (!range || range.end <= range.start) {
250
+ throw availabilityError('INVALID_TARGET_FILTER', '记忆时间必须包含有效且递增的开始和结束时间');
251
+ }
252
+ if (product.kind !== 'duration') return null;
253
+ if (!product.isFlexibleDuration && (!Number.isFinite(product.durationMinutes) || range.end - range.start !== Number(product.durationMinutes) * 60000)) return null;
254
+ return range;
255
+ }
246
256
  function evaluateCandidateTimeGate(params) {
247
257
  var projection = params.projection,
248
258
  product = params.product,
@@ -314,6 +324,11 @@ function evaluateCandidateTimeGate(params) {
314
324
  };
315
325
  }
316
326
  if (policy.type === 'before_start') {
327
+ var _evaluationContext$re;
328
+ var rememberedRange = resolveRememberedDurationRange(product, (_evaluationContext$re = evaluationContext.rememberedTimeByProductId) === null || _evaluationContext$re === void 0 ? void 0 : _evaluationContext$re[String(product.id)], timezoneName);
329
+ // Only the exact order-scoped interval may retain its start after this
330
+ // cutoff. The end/past and operating-window gates above still apply.
331
+ if ((rememberedRange === null || rememberedRange === void 0 ? void 0 : rememberedRange.start) === candidateRange.start && rememberedRange.end === candidateRange.end) return null;
317
332
  // POS fixed-duration candidates use the context's stable opening-minute
318
333
  // anchor. Keep that anchored range selectable while it is still active;
319
334
  // otherwise a minute refresh turns it into 0 capacity and incorrectly
@@ -612,6 +627,11 @@ function buildCellKey(params) {
612
627
  return [String(params.productId), params.groupId, String(params.resourceId), params.start, params.end].join(':');
613
628
  }
614
629
  function dedupeOccupancyRefKey(occupancy) {
630
+ var _occupancy$raw;
631
+ var sessionKey = (_occupancy$raw = occupancy.raw) === null || _occupancy$raw === void 0 ? void 0 : _occupancy$raw.__availabilitySessionOccupancyKey;
632
+ if (typeof sessionKey === 'string' && sessionKey) {
633
+ return "session:".concat(JSON.stringify([String(occupancy.resourceId), sessionKey]));
634
+ }
615
635
  if (occupancy.scheduleEventId !== undefined && occupancy.scheduleEventId !== null) {
616
636
  return "scheduleEvent:".concat(String(occupancy.resourceId), ":").concat(String(occupancy.scheduleEventId));
617
637
  }
@@ -1171,8 +1191,22 @@ export function getDurationBusinessDate(projection, startAt) {
1171
1191
  });
1172
1192
  return (period === null || period === void 0 ? void 0 : period.businessDate) || startAt.slice(0, 10);
1173
1193
  }
1194
+ function getRequestedProductRange(projection, product, request, runtimeOptions, fixedOffsetMinutes) {
1195
+ var _request$requestedRan;
1196
+ var range = (_request$requestedRan = request.requestedRangesByProductId) === null || _request$requestedRan === void 0 ? void 0 : _request$requestedRan[String(product.id)];
1197
+ if (!runtimeOptions.allowRequestedRanges || !range || product.kind !== 'duration' && product.kind !== 'session') return [];
1198
+ var start = toDateTime(range.startAt);
1199
+ var end = toDateTime(range.endAt);
1200
+ if (!Number.isFinite(start) || !Number.isFinite(end) || !Number.isInteger((end - start) / 60000) || end <= start) {
1201
+ throw availabilityError('INVALID_TARGET_FILTER', '手工预约范围必须包含有效起止时间和正整数分钟时长');
1202
+ }
1203
+ var candidate = createDurationTimeRangeWithEnd(product, start, end, projection, fixedOffsetMinutes);
1204
+ candidate.businessDate = getDurationBusinessDate(projection, candidate.startAt);
1205
+ assertRangesWithinProjection(projection, [candidate]);
1206
+ return [candidate];
1207
+ }
1174
1208
  function getAlignedDurationRanges(params) {
1175
- var _request$rememberedSt, _request$editingStart;
1209
+ var _request$rememberedSt, _request$rememberedTi, _request$editingStart;
1176
1210
  var projection = params.projection,
1177
1211
  product = params.product,
1178
1212
  request = params.request,
@@ -1314,6 +1348,14 @@ function getAlignedDurationRanges(params) {
1314
1348
  addRange(start, start + duration * 60000);
1315
1349
  }
1316
1350
  }
1351
+ var rememberedRange = resolveRememberedDurationRange(product, (_request$rememberedTi = request.rememberedTimeByProductId) === null || _request$rememberedTi === void 0 ? void 0 : _request$rememberedTi[String(product.id)], projection.meta.timezone);
1352
+ if (rememberedRange && baseRanges.some(function (range) {
1353
+ return contains(range, rememberedRange);
1354
+ })) {
1355
+ // Never extend a remembered flexible interval when the resource now has a
1356
+ // later closing time, or rebuild a fixed interval after its duration changed.
1357
+ addRange(rememberedRange.start, rememberedRange.end);
1358
+ }
1317
1359
  var editingAt = (_request$editingStart = request.editingStartAtByProductId) === null || _request$editingStart === void 0 ? void 0 : _request$editingStart[String(product.id)];
1318
1360
  if (editingAt !== undefined) {
1319
1361
  var _request$durationMinu3;
@@ -1379,6 +1421,16 @@ export function getProductTimeRanges(projection) {
1379
1421
  return projection.products.filter(function (product) {
1380
1422
  return !filteredProductIdSet || filteredProductIdSet.has(String(product.id));
1381
1423
  }).map(function (product) {
1424
+ var requestedRanges = getRequestedProductRange(projection, product, request, runtimeOptions, fixedOffsetMinutes);
1425
+ if (requestedRanges.length > 0) {
1426
+ return {
1427
+ productId: product.id,
1428
+ title: product.title,
1429
+ kind: product.kind,
1430
+ slotStepMinutes: slotStepMinutes,
1431
+ ranges: dedupeProductRanges(requestedRanges)
1432
+ };
1433
+ }
1382
1434
  if (product.kind === 'normal') {
1383
1435
  return {
1384
1436
  productId: product.id,
@@ -1726,7 +1778,8 @@ function buildEvaluationContext(params) {
1726
1778
  durationCandidateAnchorAtMs: Number.isFinite(durationCandidateAnchorAt) ? floorToMinute(durationCandidateAnchorAt) : null,
1727
1779
  allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true,
1728
1780
  useDurationTimeGrid: params.useDurationTimeGrid === true,
1729
- enforceSaleCutoff: params.enforceSaleCutoff === true
1781
+ enforceSaleCutoff: params.enforceSaleCutoff === true,
1782
+ rememberedTimeByProductId: params.rememberedTimeByProductId
1730
1783
  };
1731
1784
  }
1732
1785
  function summarizeStatuses(statuses) {
@@ -2216,6 +2269,7 @@ export function queryAvailabilityProjection(projection, request) {
2216
2269
  resourceIds: request.resourceIds,
2217
2270
  useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
2218
2271
  enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
2272
+ rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
2219
2273
  useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
2220
2274
  allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
2221
2275
  });
@@ -2308,6 +2362,7 @@ export function queryAvailabilityProjection(projection, request) {
2308
2362
  evaluatedAt: evaluatedAt,
2309
2363
  useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
2310
2364
  enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
2365
+ rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
2311
2366
  useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
2312
2367
  allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
2313
2368
  });
@@ -2542,6 +2597,7 @@ export function validateAvailabilitySelection(projection, params) {
2542
2597
  requirementSelections: params.requirementSelections,
2543
2598
  useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
2544
2599
  enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
2600
+ rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
2545
2601
  useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
2546
2602
  allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
2547
2603
  })
@@ -263,8 +263,17 @@ export interface GetProductTimeRangesRequest {
263
263
  partySize?: number;
264
264
  durationMinutesByProductId?: Record<string, number>;
265
265
  durationStartTimesByProductId?: Record<string, string[]>;
266
+ /** Explicit POS manual interval. Endpoints are absolute datetimes, not business-day HH:mm. */
267
+ requestedRangesByProductId?: Record<string, {
268
+ startAt: string;
269
+ endAt: string;
270
+ }>;
266
271
  /** Restore only the exact remembered start; recompute the end from current product/windows. */
267
272
  rememberedStartAtByProductId?: Record<string, string>;
273
+ /** Order-scoped v2 memory preserves the complete actual booking interval. */
274
+ rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
275
+ /** Required by the POS facade before accepting v2 remembered intervals. */
276
+ orderSessionId?: string;
268
277
  /** Edit only: preserve the full actual start plus an explicit durationMinutesByProductId. */
269
278
  editingStartAtByProductId?: Record<string, string>;
270
279
  /**
@@ -279,6 +288,8 @@ export interface GetProductTimeRangesRuntimeOptions {
279
288
  useDurationTimeGrid?: boolean;
280
289
  /** Automatic remembered selection must not use POS opening-minute cutoff exceptions. */
281
290
  enforceSaleCutoff?: boolean;
291
+ /** Internal POS capability, validated against the current order session by the facade. */
292
+ rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
282
293
  /**
283
294
  * Internal POS capability: fixed-duration candidates start from the stable
284
295
  * context anchor's current minute instead of rounding up to ten minutes, and
@@ -294,6 +305,8 @@ export interface GetProductTimeRangesRuntimeOptions {
294
305
  * disabled.
295
306
  */
296
307
  allowSessionCustomRanges?: boolean;
308
+ /** Internal POS manual capability; automatic/remembered selections must leave this disabled. */
309
+ allowRequestedRanges?: boolean;
297
310
  /**
298
311
  * Internal POS capability: materialize candidates whose schedule date was
299
312
  * explicitly excluded, while availability evaluation keeps them unavailable.
@@ -9,6 +9,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
9
9
  private store;
10
10
  window: WindowPlugin;
11
11
  private hooks;
12
+ private discountScope?;
13
+ setDiscountScope(scope: (product: any, discount: Discount) => boolean): void;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
14
16
  setRulesList(rulesList: Rules[]): Promise<void>;