@pisell/pisellos 2.2.78 → 2.2.80

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,4 +1,4 @@
1
- import { Plugin, PluginOptions, Module, ModuleOptions, PisellCore, PisellOSOptions, BusinessContext, ModuleContextConfig, InitializeServerOptions } from '../types';
1
+ import { Plugin, PluginOptions, Module, ModuleOptions, PisellCore, PisellOSOptions, BusinessContext, ModuleContextConfig, ServerOptions, InitializeServerOptions } from '../types';
2
2
  import { EffectsManager } from '../effects';
3
3
  /**
4
4
  * pisell OS 核心实现
@@ -11,7 +11,7 @@ declare class PisellOSCore implements PisellCore {
11
11
  private debug;
12
12
  context: BusinessContext;
13
13
  server: any;
14
- private serverOptions?;
14
+ serverOptions?: ServerOptions;
15
15
  constructor(options?: PisellOSOptions);
16
16
  private initialize;
17
17
  /**
@@ -22,6 +22,9 @@ export declare class ProductList extends BaseModule implements Module {
22
22
  schedule_datetime?: string;
23
23
  with_count?: string[];
24
24
  with_schedule?: number;
25
+ }, options?: {
26
+ callback?: (result: any) => void;
27
+ subscriberId?: string;
25
28
  }): Promise<any>;
26
29
  loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
27
30
  ids?: number[];
@@ -84,7 +84,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
84
84
  }, {
85
85
  key: "loadProducts",
86
86
  value: function () {
87
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
87
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref, options) {
88
88
  var _this$otherParams;
89
89
  var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData, sortedList;
90
90
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -134,7 +134,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
134
134
  with_schedule: with_schedule,
135
135
  schedule_datetime: schedule_datetime
136
136
  }, {
137
- osServer: true
137
+ osServer: true,
138
+ callback: options === null || options === void 0 ? void 0 : options.callback,
139
+ subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId
138
140
  });
139
141
  case 6:
140
142
  productsData = _context3.sent;
@@ -155,7 +157,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
155
157
  }
156
158
  }, _callee3, this);
157
159
  }));
158
- function loadProducts(_x5) {
160
+ function loadProducts(_x5, _x6) {
159
161
  return _loadProducts.apply(this, arguments);
160
162
  }
161
163
  return loadProducts;
@@ -187,7 +189,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
187
189
  }
188
190
  }, _callee4, this);
189
191
  }));
190
- function loadProductsPrice(_x6) {
192
+ function loadProductsPrice(_x7) {
191
193
  return _loadProductsPrice.apply(this, arguments);
192
194
  }
193
195
  return loadProductsPrice;
@@ -235,7 +237,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
235
237
  }
236
238
  }, _callee6, this);
237
239
  }));
238
- function getProduct(_x7) {
240
+ function getProduct(_x8) {
239
241
  return _getProduct.apply(this, arguments);
240
242
  }
241
243
  return getProduct;
@@ -273,7 +275,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
273
275
  }
274
276
  }, _callee7, this);
275
277
  }));
276
- function addProduct(_x8) {
278
+ function addProduct(_x9) {
277
279
  return _addProduct.apply(this, arguments);
278
280
  }
279
281
  return addProduct;
@@ -292,7 +294,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
292
294
  }
293
295
  }, _callee8, this);
294
296
  }));
295
- function selectProducts(_x9) {
297
+ function selectProducts(_x10) {
296
298
  return _selectProducts.apply(this, arguments);
297
299
  }
298
300
  return selectProducts;
@@ -69,6 +69,8 @@ export interface RequestOptions {
69
69
  customToast?: () => void;
70
70
  cache?: CacheProps;
71
71
  osServer?: boolean;
72
+ callback?: (res: any) => void;
73
+ subscriberId?: string;
72
74
  }
73
75
  /**
74
76
  * 响应接口
@@ -18,6 +18,7 @@ declare class Server {
18
18
  quotation?: QuotationModule;
19
19
  schedule?: ScheduleModuleEx;
20
20
  router: Router;
21
+ private productQuerySubscribers;
21
22
  private moduleRegistry;
22
23
  constructor(core: PisellCore);
23
24
  /**
@@ -85,6 +86,12 @@ declare class Server {
85
86
  * 获取所有已注册的模块列表
86
87
  */
87
88
  getRegisteredModules(): string[];
89
+ /**
90
+ * 后台静默刷新商品数据
91
+ * 重新拉取全量 SSE 接口,更新本地数据后触发 onProductsSyncCompleted
92
+ * 不影响当前界面展示,适用于切回前台、定时刷新等场景
93
+ */
94
+ refreshProductsInBackground(): Promise<void>;
88
95
  /**
89
96
  * 清空所有server模块的IndexedDB缓存
90
97
  * @returns Promise<void>
@@ -132,10 +139,28 @@ declare class Server {
132
139
  */
133
140
  private registerServerRoutes;
134
141
  /**
135
- * 处理商品查询请求(编排 Products、Menu、Schedule 模块)
136
- * 这是一个业务编排方法,协调多个模块完成复杂的业务需求
142
+ * 根据 subscriberId 移除商品查询订阅者
143
+ */
144
+ removeProductQuerySubscriber(subscriberId?: string): void;
145
+ /**
146
+ * 处理商品查询请求
147
+ * 存储订阅者信息,便于数据变更时推送最新结果
137
148
  */
138
149
  private handleProductQuery;
150
+ /**
151
+ * 取消商品查询订阅(HTTP 路由入口)
152
+ */
153
+ private handleUnsubscribeProductQuery;
154
+ /**
155
+ * 商品查询的核心计算逻辑(编排 Products、Menu、Schedule 模块)
156
+ * 供 handleProductQuery 首次返回及 pubsub 变更推送复用
157
+ */
158
+ private computeProductQueryResult;
159
+ /**
160
+ * 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
161
+ * 由 ProductsModule 的 onProductsSyncCompleted 事件触发
162
+ */
163
+ private recomputeAndNotifyProductQuery;
139
164
  /**
140
165
  * 根据餐牌配置过滤商品
141
166
  * @param products 所有商品列表