@pisell/pisellos 2.3.166 → 2.3.168
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.
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/server/index.js +18 -16
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/index.js +36 -28
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/server/index.js +2 -2
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/index.js +31 -18
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
595
595
|
generateIdempotencyToken(): string;
|
|
596
596
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
597
597
|
createOrder(params: CommitOrderParams['query']): {
|
|
598
|
-
type: "
|
|
598
|
+
type: "virtual" | "appointment_booking";
|
|
599
599
|
platform: string;
|
|
600
600
|
sales_channel: string;
|
|
601
601
|
order_sales_channel: string;
|
package/dist/server/index.js
CHANGED
|
@@ -2483,7 +2483,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2483
2483
|
case 23:
|
|
2484
2484
|
// 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
|
|
2485
2485
|
this.core.effects.on(ProductsHooks.onProductsSyncCompleted, function (payload) {
|
|
2486
|
-
_this3.recomputeAndNotifyProductQuery({
|
|
2486
|
+
return _this3.recomputeAndNotifyProductQuery({
|
|
2487
2487
|
changedIds: payload === null || payload === void 0 ? void 0 : payload.changedIds
|
|
2488
2488
|
});
|
|
2489
2489
|
});
|
|
@@ -9060,7 +9060,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9060
9060
|
_iterator18.s();
|
|
9061
9061
|
case 6:
|
|
9062
9062
|
if ((_step18 = _iterator18.n()).done) {
|
|
9063
|
-
_context82.next =
|
|
9063
|
+
_context82.next = 23;
|
|
9064
9064
|
break;
|
|
9065
9065
|
}
|
|
9066
9066
|
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
@@ -9071,39 +9071,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
9071
9071
|
});
|
|
9072
9072
|
case 11:
|
|
9073
9073
|
result = _context82.sent;
|
|
9074
|
-
|
|
9074
|
+
_context82.next = 14;
|
|
9075
|
+
return subscriber.callback(result);
|
|
9076
|
+
case 14:
|
|
9075
9077
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
9076
9078
|
subscriberId: subscriberId
|
|
9077
9079
|
});
|
|
9078
|
-
_context82.next =
|
|
9080
|
+
_context82.next = 21;
|
|
9079
9081
|
break;
|
|
9080
|
-
case
|
|
9081
|
-
_context82.prev =
|
|
9082
|
+
case 17:
|
|
9083
|
+
_context82.prev = 17;
|
|
9082
9084
|
_context82.t0 = _context82["catch"](8);
|
|
9083
9085
|
errorMessage = _context82.t0 instanceof Error ? _context82.t0.message : String(_context82.t0);
|
|
9084
9086
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
9085
9087
|
subscriberId: subscriberId,
|
|
9086
9088
|
error: errorMessage
|
|
9087
9089
|
});
|
|
9088
|
-
case
|
|
9090
|
+
case 21:
|
|
9089
9091
|
_context82.next = 6;
|
|
9090
9092
|
break;
|
|
9091
|
-
case
|
|
9092
|
-
_context82.next =
|
|
9093
|
+
case 23:
|
|
9094
|
+
_context82.next = 28;
|
|
9093
9095
|
break;
|
|
9094
|
-
case
|
|
9095
|
-
_context82.prev =
|
|
9096
|
+
case 25:
|
|
9097
|
+
_context82.prev = 25;
|
|
9096
9098
|
_context82.t1 = _context82["catch"](4);
|
|
9097
9099
|
_iterator18.e(_context82.t1);
|
|
9098
|
-
case
|
|
9099
|
-
_context82.prev =
|
|
9100
|
+
case 28:
|
|
9101
|
+
_context82.prev = 28;
|
|
9100
9102
|
_iterator18.f();
|
|
9101
|
-
return _context82.finish(
|
|
9102
|
-
case
|
|
9103
|
+
return _context82.finish(28);
|
|
9104
|
+
case 31:
|
|
9103
9105
|
case "end":
|
|
9104
9106
|
return _context82.stop();
|
|
9105
9107
|
}
|
|
9106
|
-
}, _callee82, this, [[4,
|
|
9108
|
+
}, _callee82, this, [[4, 25, 28, 31], [8, 17]]);
|
|
9107
9109
|
}));
|
|
9108
9110
|
function recomputeAndNotifyProductQuery(_x92) {
|
|
9109
9111
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
@@ -3,6 +3,7 @@ import { BaseModule } from '../../../modules/BaseModule';
|
|
|
3
3
|
import { ProductData } from '../../../modules/Product/types';
|
|
4
4
|
import type { RouteDefinition } from '../../types';
|
|
5
5
|
import { ProductIdScope, type ProductSnapshot, ProductFormatter, ProductFormatterContext } from './types';
|
|
6
|
+
import type { CommittedProducts, ReplicatedProducts } from './types';
|
|
6
7
|
/**
|
|
7
8
|
* Products 模块 - 用于获取和管理完整的商品详细数据
|
|
8
9
|
* 相比 ProductList 模块,Products 会获取所有详细信息并缓存
|
|
@@ -40,6 +41,26 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
40
41
|
private productIndexDBSaveQueue;
|
|
41
42
|
/** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
|
|
42
43
|
private lastScheduleTimePoints;
|
|
44
|
+
private committedProductState?;
|
|
45
|
+
private productReplicationSourceGeneration;
|
|
46
|
+
private productPersistenceFailed;
|
|
47
|
+
private runtimeSyncMode;
|
|
48
|
+
private runtimeSyncGeneration;
|
|
49
|
+
private requestReplicaRefresh?;
|
|
50
|
+
private replicaApplyQueue;
|
|
51
|
+
private productSyncQueue;
|
|
52
|
+
private replicaPriceDirtyIds;
|
|
53
|
+
/** Installed after initial preload; initial cache/network loading stays unchanged. */
|
|
54
|
+
setRuntimeSyncMode(mode: 'normal' | 'memoryReplica', requestRefresh?: (trigger: string) => Promise<void>): Promise<void>;
|
|
55
|
+
isMemoryReplica(): boolean;
|
|
56
|
+
/** Read persisted data once on the main screen to establish a committed baseline. */
|
|
57
|
+
enableProductReplicationSource(): Promise<void>;
|
|
58
|
+
/** Release the extra catalog without changing the normal product store or persistence. */
|
|
59
|
+
disableProductReplicationSource(): void;
|
|
60
|
+
getCommittedProductSnapshot(): CommittedProducts | null;
|
|
61
|
+
private recordProductCommit;
|
|
62
|
+
applyReplicatedProducts(change: ReplicatedProducts): Promise<void>;
|
|
63
|
+
private refreshFromReplica;
|
|
43
64
|
constructor(name?: string, version?: string);
|
|
44
65
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
45
66
|
/**
|
|
@@ -230,7 +251,10 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
230
251
|
* 根据 ID 列表删除商品(用于 pubsub 同步删除场景)
|
|
231
252
|
* 同时更新 store.list、store.map、IndexDB 和价格缓存
|
|
232
253
|
*/
|
|
233
|
-
removeProductsByIds(ids: number[]
|
|
254
|
+
removeProductsByIds(ids: number[], options?: {
|
|
255
|
+
skipIndexDB?: boolean;
|
|
256
|
+
skipEmit?: boolean;
|
|
257
|
+
}): Promise<void>;
|
|
234
258
|
/**
|
|
235
259
|
* 重新从服务器加载全量商品列表并更新本地 store
|
|
236
260
|
* 用于 pubsub 同步 create / update / batch_update 场景
|
|
@@ -261,13 +285,8 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
261
285
|
* await this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer')
|
|
262
286
|
*/
|
|
263
287
|
private replaceProductsSnapshotInIndexDB;
|
|
264
|
-
/**
|
|
265
|
-
* 增量 upsert 商品到 IndexDB,不清空表;用于 pubsub 批次合并后的变更商品。
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* await this.patchProductsInIndexDB(changedProducts, 'pubsub.processProductSyncMessages', mergeActions)
|
|
269
|
-
*/
|
|
270
288
|
private patchProductsInIndexDB;
|
|
289
|
+
private persistProductDelta;
|
|
271
290
|
/**
|
|
272
291
|
* 同步更新商品 Map 缓存
|
|
273
292
|
* 将 list 中的商品同步到 map,以 id 为 key
|
|
@@ -309,6 +328,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
309
328
|
* Server 层监听该事件后对变更商品增量执行 prepareProductsWithPrice 并更新缓存
|
|
310
329
|
*/
|
|
311
330
|
private processProductSyncMessages;
|
|
331
|
+
private processProductSyncBatch;
|
|
312
332
|
/**
|
|
313
333
|
* 通过 SSE 按 ids 增量拉取商品数据
|
|
314
334
|
* 请求 GET /shop/core/stream?type=product&ids={ids}
|
|
@@ -342,6 +362,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
342
362
|
* 销毁同步资源(取消 pubsub 订阅、清除定时器)
|
|
343
363
|
*/
|
|
344
364
|
destroyProductSync(): void;
|
|
365
|
+
destroy(): void;
|
|
345
366
|
/**
|
|
346
367
|
* 获取模块的路由定义
|
|
347
368
|
* Products 模块暂不提供路由,由 Server 层统一处理
|