@pisell/pisellos 0.10.83 → 0.10.84

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.
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
- enumerable: true,
8
- get: function () {
9
- return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
- }
11
- });
12
- Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
- enumerable: true,
14
- get: function () {
15
- return _examples.ITEM_REWARD_STRATEGY;
16
- }
17
- });
18
- Object.defineProperty(exports, "PromotionAdapter", {
19
- enumerable: true,
20
- get: function () {
21
- return _adapter.PromotionAdapter;
22
- }
23
- });
24
- Object.defineProperty(exports, "PromotionEvaluator", {
25
- enumerable: true,
26
- get: function () {
27
- return _evaluator.PromotionEvaluator;
28
- }
29
- });
30
- Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
- enumerable: true,
32
- get: function () {
33
- return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
- }
35
- });
36
- Object.defineProperty(exports, "default", {
37
- enumerable: true,
38
- get: function () {
39
- return _adapter.default;
40
- }
41
- });
42
- var _evaluator = require("./evaluator");
43
- var _adapter = _interopRequireWildcard(require("./adapter"));
44
- var _examples = require("./examples");
45
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
1
+ "use strict";
@@ -310,6 +310,9 @@ class ProductList extends _BaseModule.BaseModule {
310
310
  } : {}),
311
311
  front_end_cache_id: params.cacheId
312
312
  }, {
313
+ // Core dispatches Kiosk to its local product query; PC/H5 without that
314
+ // route keep using HTTP. open_quotation: 0 preserves the raw venue pool.
315
+ osServer: true,
313
316
  useCache: false,
314
317
  customToast: () => {}
315
318
  });
@@ -319,7 +322,7 @@ class ProductList extends _BaseModule.BaseModule {
319
322
  code: 'VENUE_CATALOG_LOAD_FAILED'
320
323
  });
321
324
  }
322
- const total = data.total ?? data.total_count ?? data.total_num;
325
+ const total = data.total ?? data.total_count ?? data.total_num ?? data.count;
323
326
  if (total != null && Number.isFinite(Number(total)) && Number(total) > data.list.length || total == null && data.list.length >= 500) {
324
327
  throw Object.assign(new Error('The venue product pool is incomplete. A single complete catalog response is required.'), {
325
328
  code: 'VENUE_CATALOG_INCOMPLETE'
@@ -286,6 +286,7 @@ declare class Server {
286
286
  * 存储订阅者信息,便于数据变更时推送最新结果
287
287
  */
288
288
  private handleProductQuery;
289
+ private queryRawKioskProductPool;
289
290
  /**
290
291
  * ProductList callers such as standalone retail pages do not always have a selected schedule.
291
292
  * In that case query against the current local time so menu availability can still be evaluated.
@@ -1655,6 +1655,11 @@ class Server {
1655
1655
  data,
1656
1656
  config
1657
1657
  }) => {
1658
+ // Venue previews seed one complete raw Kiosk pool. Quoting or applying the
1659
+ // current schedule here would remove members needed by other preview dates.
1660
+ if (data?.open_quotation === 0 && data?.application_code === 'kiosk') {
1661
+ return this.queryRawKioskProductPool(data);
1662
+ }
1658
1663
  const {
1659
1664
  menu_list_ids,
1660
1665
  customer_id,
@@ -1720,6 +1725,40 @@ class Server {
1720
1725
  }
1721
1726
  return result;
1722
1727
  };
1728
+ async queryRawKioskProductPool(data) {
1729
+ const preload = this.startupModulePreloadInFlight;
1730
+ if (preload) await preload;
1731
+ if (!this.products?.getProducts) {
1732
+ throw new Error('The local product catalog is not ready.');
1733
+ }
1734
+ const products = await this.products.getProducts();
1735
+ if (!Array.isArray(products)) {
1736
+ throw new Error('The local product catalog is unavailable.');
1737
+ }
1738
+ const filterSet = value => Array.isArray(value) && value.length ? new Set(value.filter(item => typeof item === 'string' || typeof item === 'number').map(item => String(item).trim()).filter(Boolean)) : undefined;
1739
+ const ids = filterSet(data.ids);
1740
+ const collections = filterSet(typeof data.collection === 'number' ? [data.collection] : data.collection);
1741
+ const categories = filterSet(data.category_ids);
1742
+ const extensionTypes = filterSet(data.extension_type);
1743
+ const list = products.filter(product => {
1744
+ if ((product.status || 'published') !== 'published' || 'deleted_at' in product && product.deleted_at) return false;
1745
+ if (!Array.isArray(product.channel_application) || !product.channel_application.includes('kiosk')) return false;
1746
+ if (ids && !ids.has(String(product.id))) return false;
1747
+ if (collections && !product.collection?.some(collection => collections.has(String(collection.id)))) return false;
1748
+ if (categories && !product.categories?.some(category => categories.has(String(category.id)) || categories.has(String(category.pivot?.product_category_id)))) return false;
1749
+ return !extensionTypes || extensionTypes.has(String(product.extension_type));
1750
+ });
1751
+ return {
1752
+ code: 200,
1753
+ status: true,
1754
+ message: '',
1755
+ data: {
1756
+ list,
1757
+ count: list.length,
1758
+ schedule_time_points: []
1759
+ }
1760
+ };
1761
+ }
1723
1762
 
1724
1763
  /**
1725
1764
  * ProductList callers such as standalone retail pages do not always have a selected schedule.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.83",
4
+ "version": "0.10.84",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",