@pisell/pisellos 0.10.58 → 0.10.59

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 (34) 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 +500 -0
  5. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  6. package/dist/modules/Order/index.d.ts +19 -2
  7. package/dist/modules/Order/index.js +1369 -1021
  8. package/dist/modules/Order/types.d.ts +5 -0
  9. package/dist/modules/ProductList/index.d.ts +1 -3
  10. package/dist/modules/ProductList/index.js +120 -192
  11. package/dist/modules/ProductList/types.d.ts +0 -8
  12. package/dist/modules/ProductList/types.js +0 -2
  13. package/dist/solution/BaseSales/index.d.ts +8 -0
  14. package/dist/solution/BaseSales/index.js +1382 -1207
  15. package/dist/solution/BookingByStep/index.d.ts +1 -1
  16. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -7
  17. package/dist/solution/UnifiedBookingSales/index.js +446 -586
  18. package/lib/index.d.ts +1 -0
  19. package/lib/index.js +12 -0
  20. package/lib/inventory/index.d.ts +92 -0
  21. package/lib/inventory/index.js +280 -0
  22. package/lib/modules/Order/index.d.ts +19 -2
  23. package/lib/modules/Order/index.js +111 -19
  24. package/lib/modules/Order/types.d.ts +5 -0
  25. package/lib/modules/ProductList/index.d.ts +1 -3
  26. package/lib/modules/ProductList/index.js +22 -31
  27. package/lib/modules/ProductList/types.d.ts +0 -8
  28. package/lib/modules/ProductList/types.js +0 -1
  29. package/lib/solution/BaseSales/index.d.ts +8 -0
  30. package/lib/solution/BaseSales/index.js +82 -7
  31. package/lib/solution/BookingByStep/index.d.ts +1 -1
  32. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -7
  33. package/lib/solution/UnifiedBookingSales/index.js +12 -80
  34. package/package.json +1 -1
@@ -526,6 +526,11 @@ export interface OrderHooksConfig {
526
526
  beforeCartIntentCommit?: (context: OrderCartIntentCommitContext) => void;
527
527
  /** Captures tenant/business runtime identity for asynchronous cart intents. */
528
528
  getCartIntentScope?: () => unknown;
529
+ /** Awaited before a local cart draft is published. Reject to leave the live order unchanged. */
530
+ onBeforeCartCommit?: (context: {
531
+ currentItems: readonly OrderProduct[];
532
+ proposedItems: readonly OrderProduct[];
533
+ }) => void | Promise<void>;
529
534
  onBeforeMergeProductToOrder?: (context: OrderProductMergeDecisionContext) => OrderProductMergeDecisionResult | Promise<OrderProductMergeDecisionResult>;
530
535
  }
531
536
  /**
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { ProductListLoadProductsParams, ProductListStoreQueryParams, ProductEnrichmentContext } from './types';
3
+ import { ProductListLoadProductsParams, ProductListStoreQueryParams } from './types';
4
4
  import { ProductData } from '../Product/types';
5
5
  export * from './types';
6
6
  export declare class ProductList extends BaseModule implements Module {
@@ -19,8 +19,6 @@ export declare class ProductList extends BaseModule implements Module {
19
19
  * productList.updateOtherParams({ channel: 'pos' });
20
20
  */
21
21
  updateOtherParams(params: Record<string, any>): void;
22
- enrichProducts(products: ProductData[], context: ProductEnrichmentContext): Promise<ProductData[]>;
23
- private enrichCatalog;
24
22
  storeChange(path?: string, value?: any): Promise<void>;
25
23
  /**
26
24
  * 获取加时商品列表。
@@ -99,105 +99,27 @@ 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
- key: "enrichProducts",
111
+ key: "storeChange",
106
112
  value: function () {
107
- var _enrichProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(products, context) {
108
- var _context$signal, _context$signal2;
109
- var enrich, result;
113
+ var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, value) {
110
114
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
111
115
  while (1) switch (_context2.prev = _context2.next) {
112
116
  case 0:
113
- enrich = this.otherParams.enrichProducts;
114
- if (enrich) {
115
- _context2.next = 3;
116
- break;
117
- }
118
- return _context2.abrupt("return", products);
119
- case 3:
120
- if (!((_context$signal = context.signal) !== null && _context$signal !== void 0 && _context$signal.aborted)) {
121
- _context2.next = 5;
122
- break;
123
- }
124
- throw new Error('Product enrichment cancelled');
125
- case 5:
126
- _context2.next = 7;
127
- return enrich(cloneDeep(products), _objectSpread({
128
- businessCode: this.otherParams.businessCode,
129
- channel: this.otherParams.channel
130
- }, context));
131
- case 7:
132
- result = _context2.sent;
133
- if (!((_context$signal2 = context.signal) !== null && _context$signal2 !== void 0 && _context$signal2.aborted)) {
134
- _context2.next = 10;
135
- break;
136
- }
137
- throw new Error('Product enrichment cancelled');
138
- case 10:
139
- if (Array.isArray(result)) {
140
- _context2.next = 12;
141
- break;
142
- }
143
- throw new Error('Product enrichment must return an array');
144
- case 12:
145
- return _context2.abrupt("return", result);
146
- case 13:
147
117
  case "end":
148
118
  return _context2.stop();
149
119
  }
150
- }, _callee2, this);
151
- }));
152
- function enrichProducts(_x3, _x4) {
153
- return _enrichProducts.apply(this, arguments);
154
- }
155
- return enrichProducts;
156
- }()
157
- }, {
158
- key: "enrichCatalog",
159
- value: function () {
160
- var _enrichCatalog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(products, reason) {
161
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
162
- while (1) switch (_context3.prev = _context3.next) {
163
- case 0:
164
- _context3.prev = 0;
165
- _context3.next = 3;
166
- return this.enrichProducts(products, {
167
- reason: reason
168
- });
169
- case 3:
170
- return _context3.abrupt("return", _context3.sent);
171
- case 6:
172
- _context3.prev = 6;
173
- _context3.t0 = _context3["catch"](0);
174
- // An unavailable supplementary source is not zero stock or an empty catalog.
175
- console.warn('[ProductList] Supplementary product data could not be refreshed');
176
- return _context3.abrupt("return", products);
177
- case 10:
178
- case "end":
179
- return _context3.stop();
180
- }
181
- }, _callee3, this, [[0, 6]]);
182
- }));
183
- function enrichCatalog(_x5, _x6) {
184
- return _enrichCatalog.apply(this, arguments);
185
- }
186
- return enrichCatalog;
187
- }()
188
- }, {
189
- key: "storeChange",
190
- value: function () {
191
- var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(path, value) {
192
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
193
- while (1) switch (_context4.prev = _context4.next) {
194
- case 0:
195
- case "end":
196
- return _context4.stop();
197
- }
198
- }, _callee4);
120
+ }, _callee2);
199
121
  }));
200
- function storeChange(_x7, _x8) {
122
+ function storeChange(_x3, _x4) {
201
123
  return _storeChange.apply(this, arguments);
202
124
  }
203
125
  return storeChange;
@@ -211,14 +133,14 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
211
133
  }, {
212
134
  key: "getAddTimeProducts",
213
135
  value: (function () {
214
- var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
136
+ var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
215
137
  var params,
216
- _args5 = arguments;
217
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
218
- while (1) switch (_context5.prev = _context5.next) {
138
+ _args3 = arguments;
139
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
140
+ while (1) switch (_context3.prev = _context3.next) {
219
141
  case 0:
220
- params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
221
- return _context5.abrupt("return", this.loadProducts(_objectSpread(_objectSpread({
142
+ params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
143
+ return _context3.abrupt("return", this.loadProducts(_objectSpread(_objectSpread({
222
144
  schedule_date: dayjs().format('YYYY-MM-DD'),
223
145
  status: 'published'
224
146
  }, params), {}, {
@@ -226,9 +148,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
226
148
  })));
227
149
  case 2:
228
150
  case "end":
229
- return _context5.stop();
151
+ return _context3.stop();
230
152
  }
231
- }, _callee5, this);
153
+ }, _callee3, this);
232
154
  }));
233
155
  function getAddTimeProducts() {
234
156
  return _getAddTimeProducts.apply(this, arguments);
@@ -238,13 +160,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
238
160
  }, {
239
161
  key: "loadProducts",
240
162
  value: function () {
241
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
242
- var _this$otherParams,
163
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
164
+ var _this2 = this,
165
+ _this$otherParams,
243
166
  _this$otherParams$bus,
244
167
  _this$otherParams2,
245
168
  _this$otherParams3,
246
- _this$otherParams4,
247
- _this2 = this;
169
+ _this$otherParams4;
248
170
  var _ref,
249
171
  _ref$category_ids,
250
172
  category_ids,
@@ -266,6 +188,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
266
188
  status,
267
189
  strategy_context,
268
190
  options,
191
+ scope,
192
+ assertScope,
269
193
  userPlugin,
270
194
  customer_id,
271
195
  _userPlugin$get,
@@ -280,15 +204,21 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
280
204
  subscriptionCallback,
281
205
  productsData,
282
206
  resolvedList,
283
- enrichedList,
284
207
  sortedList,
285
- _args7 = arguments;
286
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
287
- while (1) switch (_context7.prev = _context7.next) {
208
+ _args5 = arguments;
209
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
210
+ while (1) switch (_context5.prev = _context5.next) {
288
211
  case 0:
289
- _ref = _args7.length > 0 && _args7[0] !== undefined ? _args7[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;
290
- options = _args7.length > 1 ? _args7[1] : undefined;
291
- // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
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;
213
+ options = _args5.length > 1 ? _args5[1] : undefined;
214
+ scope = this.otherParams.catalogScopeKey;
215
+ assertScope = function assertScope() {
216
+ if (scope !== _this2.otherParams.catalogScopeKey) {
217
+ throw Object.assign(new Error('Product catalog context changed'), {
218
+ name: 'AbortError'
219
+ });
220
+ }
221
+ }; // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
292
222
  // if (!schedule_ids?.length) {
293
223
  // const schedule_ids_data = this.store.schedule
294
224
  // .getScheduleListByIds(schedule_ids)
@@ -359,63 +289,67 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
359
289
  handledByOsServer = isProductQueryHandledByOsServer(this.core, this.request);
360
290
  originalCallback = typeof (options === null || options === void 0 ? void 0 : options.callback) === 'function' ? options.callback : undefined;
361
291
  subscriptionCallback = originalCallback ? ( /*#__PURE__*/function () {
362
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(result) {
292
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(result) {
363
293
  var _result$data;
364
- var callbackList, resolvedCallbackList, enrichedCallbackList;
365
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
366
- while (1) switch (_context6.prev = _context6.next) {
294
+ var callbackList, products;
295
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
296
+ while (1) switch (_context4.prev = _context4.next) {
367
297
  case 0:
298
+ if (!(scope !== _this2.otherParams.catalogScopeKey)) {
299
+ _context4.next = 2;
300
+ break;
301
+ }
302
+ return _context4.abrupt("return");
303
+ case 2:
368
304
  callbackList = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list;
369
305
  if (Array.isArray(callbackList)) {
370
- _context6.next = 4;
306
+ _context4.next = 6;
371
307
  break;
372
308
  }
373
309
  originalCallback(result);
374
- return _context6.abrupt("return");
375
- case 4:
310
+ return _context4.abrupt("return");
311
+ case 6:
376
312
  if (!handledByOsServer) {
377
313
  // Subscription payloads may contain only changed products, so keep
378
314
  // the existing raw catalog scope and upsert the changed records.
379
315
  _this2.rememberRawProductQueryResult(callbackList);
380
316
  }
381
- resolvedCallbackList = resolveClientDataVariants({
317
+ products = resolveClientDataVariants({
382
318
  core: _this2.core,
383
319
  otherParams: _this2.otherParams,
384
320
  products: callbackList,
385
321
  queryPayload: queryPayload,
386
322
  handledByOsServer: handledByOsServer
387
323
  });
388
- _context6.next = 8;
389
- return _this2.enrichCatalog(resolvedCallbackList, 'catalog-update');
390
- case 8:
391
- enrichedCallbackList = _context6.sent;
392
- _context6.next = 11;
393
- return _this2.addProduct(enrichedCallbackList);
324
+ assertScope();
325
+ _context4.next = 11;
326
+ return _this2.addProduct(products);
394
327
  case 11:
395
- originalCallback(enrichedCallbackList === callbackList ? result : _objectSpread(_objectSpread({}, result), {}, {
328
+ originalCallback(handledByOsServer ? result : _objectSpread(_objectSpread({}, result), {}, {
396
329
  data: _objectSpread(_objectSpread({}, result.data), {}, {
397
- list: enrichedCallbackList
330
+ list: products
398
331
  })
399
332
  }));
400
333
  case 12:
401
334
  case "end":
402
- return _context6.stop();
335
+ return _context4.stop();
403
336
  }
404
- }, _callee6);
337
+ }, _callee4);
405
338
  }));
406
- return function (_x9) {
339
+ return function (_x5) {
407
340
  return _ref2.apply(this, arguments);
408
341
  };
409
342
  }()) : undefined;
410
- _context7.next = 16;
343
+ _context5.next = 18;
411
344
  return this.request.post("/product/query", queryPayload, {
412
345
  osServer: true,
413
346
  callback: subscriptionCallback,
414
347
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
415
348
  customToast: function customToast() {}
416
349
  });
417
- case 16:
418
- productsData = _context7.sent;
350
+ case 18:
351
+ productsData = _context5.sent;
352
+ assertScope();
419
353
  if (!handledByOsServer && Array.isArray(productsData.data.list)) {
420
354
  this.replaceRawProductQueryResult(productsData.data.list, product_ids);
421
355
  }
@@ -426,11 +360,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
426
360
  queryPayload: queryPayload,
427
361
  handledByOsServer: handledByOsServer
428
362
  });
429
- _context7.next = 21;
430
- return this.enrichCatalog(resolvedList, 'catalog');
431
- case 21:
432
- enrichedList = _context7.sent;
433
- sortedList = enrichedList.slice().sort(function (a, b) {
363
+ sortedList = resolvedList.slice().sort(function (a, b) {
434
364
  return Number(b.sort) - Number(a.sort);
435
365
  }); // if (sortedList.length) {
436
366
  // sortedList.forEach((n: any) => {
@@ -439,15 +369,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
439
369
  // }
440
370
  // })
441
371
  // }
442
- _context7.next = 25;
443
- return this.addProduct(sortedList);
372
+ this.addProduct(sortedList);
373
+ return _context5.abrupt("return", sortedList);
444
374
  case 25:
445
- return _context7.abrupt("return", sortedList);
446
- case 26:
447
375
  case "end":
448
- return _context7.stop();
376
+ return _context5.stop();
449
377
  }
450
- }, _callee7, this);
378
+ }, _callee5, this);
451
379
  }));
452
380
  function loadProducts() {
453
381
  return _loadProducts.apply(this, arguments);
@@ -457,13 +385,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
457
385
  }, {
458
386
  key: "loadProductsPrice",
459
387
  value: function () {
460
- var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref3) {
388
+ var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
461
389
  var _ref3$ids, ids, customer_id, schedule_date, channel, productsData;
462
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
463
- while (1) switch (_context8.prev = _context8.next) {
390
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
391
+ while (1) switch (_context6.prev = _context6.next) {
464
392
  case 0:
465
393
  _ref3$ids = _ref3.ids, ids = _ref3$ids === void 0 ? [] : _ref3$ids, customer_id = _ref3.customer_id, schedule_date = _ref3.schedule_date, channel = _ref3.channel;
466
- _context8.next = 3;
394
+ _context6.next = 3;
467
395
  return this.request.post("/product/query/price", {
468
396
  ids: ids,
469
397
  customer_id: customer_id,
@@ -473,15 +401,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
473
401
  useCache: true
474
402
  });
475
403
  case 3:
476
- productsData = _context8.sent;
477
- return _context8.abrupt("return", productsData.data);
404
+ productsData = _context6.sent;
405
+ return _context6.abrupt("return", productsData.data);
478
406
  case 5:
479
407
  case "end":
480
- return _context8.stop();
408
+ return _context6.stop();
481
409
  }
482
- }, _callee8, this);
410
+ }, _callee6, this);
483
411
  }));
484
- function loadProductsPrice(_x10) {
412
+ function loadProductsPrice(_x6) {
485
413
  return _loadProductsPrice.apply(this, arguments);
486
414
  }
487
415
  return loadProductsPrice;
@@ -543,19 +471,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
543
471
  }, {
544
472
  key: "getProducts",
545
473
  value: function () {
546
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
547
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
548
- while (1) switch (_context9.prev = _context9.next) {
474
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
475
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
476
+ while (1) switch (_context7.prev = _context7.next) {
549
477
  case 0:
550
- _context9.next = 2;
478
+ _context7.next = 2;
551
479
  return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
552
480
  case 2:
553
- return _context9.abrupt("return", cloneDeep(this.store.list));
481
+ return _context7.abrupt("return", cloneDeep(this.store.list));
554
482
  case 3:
555
483
  case "end":
556
- return _context9.stop();
484
+ return _context7.stop();
557
485
  }
558
- }, _callee9, this);
486
+ }, _callee7, this);
559
487
  }));
560
488
  function getProducts() {
561
489
  return _getProducts.apply(this, arguments);
@@ -565,25 +493,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
565
493
  }, {
566
494
  key: "getProduct",
567
495
  value: function () {
568
- var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(id) {
496
+ var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
569
497
  var product;
570
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
571
- while (1) switch (_context10.prev = _context10.next) {
498
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
499
+ while (1) switch (_context8.prev = _context8.next) {
572
500
  case 0:
573
- _context10.next = 2;
501
+ _context8.next = 2;
574
502
  return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
575
503
  case 2:
576
504
  product = this.store.list.find(function (product) {
577
505
  return product.id === id;
578
506
  });
579
- return _context10.abrupt("return", product ? cloneDeep(product) : undefined);
507
+ return _context8.abrupt("return", product ? cloneDeep(product) : undefined);
580
508
  case 4:
581
509
  case "end":
582
- return _context10.stop();
510
+ return _context8.stop();
583
511
  }
584
- }, _callee10, this);
512
+ }, _callee8, this);
585
513
  }));
586
- function getProduct(_x11) {
514
+ function getProduct(_x7) {
587
515
  return _getProduct.apply(this, arguments);
588
516
  }
589
517
  return getProduct;
@@ -591,7 +519,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
591
519
  }, {
592
520
  key: "queryProducts",
593
521
  value: function () {
594
- var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
522
+ var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
595
523
  var params,
596
524
  includeIds,
597
525
  excludeIds,
@@ -602,11 +530,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
602
530
  channelApplications,
603
531
  codeOrBarcode,
604
532
  products,
605
- _args11 = arguments;
606
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
607
- while (1) switch (_context11.prev = _context11.next) {
533
+ _args9 = arguments;
534
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
535
+ while (1) switch (_context9.prev = _context9.next) {
608
536
  case 0:
609
- params = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
537
+ params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
610
538
  includeIds = normalizeQuerySet(params.includeIds);
611
539
  excludeIds = normalizeQuerySet(params.excludeIds);
612
540
  categoryIds = normalizeQuerySet(params.categoryIds);
@@ -645,12 +573,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
645
573
  }
646
574
  return true;
647
575
  });
648
- return _context11.abrupt("return", cloneDeep(products));
576
+ return _context9.abrupt("return", cloneDeep(products));
649
577
  case 11:
650
578
  case "end":
651
- return _context11.stop();
579
+ return _context9.stop();
652
580
  }
653
- }, _callee11, this);
581
+ }, _callee9, this);
654
582
  }));
655
583
  function queryProducts() {
656
584
  return _queryProducts.apply(this, arguments);
@@ -660,23 +588,23 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
660
588
  }, {
661
589
  key: "getProductByIds",
662
590
  value: function () {
663
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(ids) {
664
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
665
- while (1) switch (_context12.prev = _context12.next) {
591
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(ids) {
592
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
593
+ while (1) switch (_context10.prev = _context10.next) {
666
594
  case 0:
667
- _context12.next = 2;
595
+ _context10.next = 2;
668
596
  return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
669
597
  case 2:
670
- return _context12.abrupt("return", this.queryProducts({
598
+ return _context10.abrupt("return", this.queryProducts({
671
599
  includeIds: ids
672
600
  }));
673
601
  case 3:
674
602
  case "end":
675
- return _context12.stop();
603
+ return _context10.stop();
676
604
  }
677
- }, _callee12, this);
605
+ }, _callee10, this);
678
606
  }));
679
- function getProductByIds(_x12) {
607
+ function getProductByIds(_x8) {
680
608
  return _getProductByIds.apply(this, arguments);
681
609
  }
682
610
  return getProductByIds;
@@ -684,10 +612,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
684
612
  }, {
685
613
  key: "addProduct",
686
614
  value: function () {
687
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(products) {
615
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(products) {
688
616
  var _this6 = this;
689
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
690
- while (1) switch (_context13.prev = _context13.next) {
617
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
618
+ while (1) switch (_context11.prev = _context11.next) {
691
619
  case 0:
692
620
  // list 需要根据 id 去重
693
621
  if (!this.store.list) {
@@ -710,11 +638,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
710
638
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
711
639
  case 4:
712
640
  case "end":
713
- return _context13.stop();
641
+ return _context11.stop();
714
642
  }
715
- }, _callee13, this);
643
+ }, _callee11, this);
716
644
  }));
717
- function addProduct(_x13) {
645
+ function addProduct(_x9) {
718
646
  return _addProduct.apply(this, arguments);
719
647
  }
720
648
  return addProduct;
@@ -722,18 +650,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
722
650
  }, {
723
651
  key: "selectProducts",
724
652
  value: function () {
725
- var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(products) {
726
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
727
- while (1) switch (_context14.prev = _context14.next) {
653
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(products) {
654
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
655
+ while (1) switch (_context12.prev = _context12.next) {
728
656
  case 0:
729
657
  this.store.selectProducts = products;
730
658
  case 1:
731
659
  case "end":
732
- return _context14.stop();
660
+ return _context12.stop();
733
661
  }
734
- }, _callee14, this);
662
+ }, _callee12, this);
735
663
  }));
736
- function selectProducts(_x14) {
664
+ function selectProducts(_x10) {
737
665
  return _selectProducts.apply(this, arguments);
738
666
  }
739
667
  return selectProducts;
@@ -1,12 +1,4 @@
1
1
  import { ProductData } from '../Product/types';
2
- /** Runtime-only enrichment; never serialized into a product query. */
3
- export interface ProductEnrichmentContext {
4
- reason: 'catalog' | 'catalog-update' | 'detail-open';
5
- businessCode?: string;
6
- channel?: string;
7
- signal?: AbortSignal;
8
- }
9
- export type ProductEnricher = (products: ProductData[], context: ProductEnrichmentContext) => Promise<ProductData[]>;
10
2
  export interface ProductListLoadProductsParams {
11
3
  category_ids?: number[];
12
4
  product_ids?: number[];
@@ -1,5 +1,3 @@
1
- /** Runtime-only enrichment; never serialized into a product query. */
2
-
3
1
  export var ProductListHooks = /*#__PURE__*/function (ProductListHooks) {
4
2
  ProductListHooks["onGetProducts"] = "productList:onGetProducts";
5
3
  ProductListHooks["onGetProduct"] = "productList:onGetProduct";
@@ -1,3 +1,4 @@
1
+ import { InventoryController, type CheckoutRuntimeSnapshot } from '../../inventory';
1
2
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
3
  import { BaseModule } from '../../modules/BaseModule';
3
4
  import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesSubmitSalesOrderParams, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentOptions, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
@@ -49,6 +50,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
49
50
  protected appPlugin: AppPlugin;
50
51
  protected store: BaseSalesState;
51
52
  protected otherParams: Record<string, any>;
53
+ getInventory(): InventoryController | undefined;
54
+ prepareCheckout(signal?: AbortSignal): Promise<CheckoutRuntimeSnapshot | undefined>;
52
55
  protected cacheId: string | undefined;
53
56
  /**
54
57
  * 由已在初始化阶段解析过设备短号的业务解决方案写入。
@@ -187,6 +190,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
187
190
  * 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
188
191
  */
189
192
  protected createSubModule(moduleName: string): Module | null;
193
+ private inventoryOrderHooks?;
190
194
  protected getSubModuleHooks(moduleName: string): any;
191
195
  /**
192
196
  * 构造传给 BaseSales 子模块的完整运行态参数,保证初始化和后续同步语义一致。
@@ -224,7 +228,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
224
228
  private isActiveVirtualSettlementOrder;
225
229
  private isHistoricalVirtualSettlementOrder;
226
230
  private syncAppDataToTempOrder;
231
+ private initialization?;
232
+ /** Hosts can await readiness without changing Core's synchronous registration API. */
233
+ whenInitialized(): Promise<void>;
227
234
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
235
+ private initializeSalesRuntime;
228
236
  destroy(): Promise<void>;
229
237
  /**
230
238
  * 加载销售订单到统一 tempOrder 工作区。