@pisell/pisellos 2.1.36 → 2.2.1

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 (133) hide show
  1. package/dist/core/index.d.ts +8 -1
  2. package/dist/core/index.js +116 -42
  3. package/dist/effects/index.d.ts +1 -0
  4. package/dist/effects/index.js +29 -6
  5. package/dist/modules/Account/index.js +2 -3
  6. package/dist/modules/BaseModule.d.ts +3 -0
  7. package/dist/modules/BaseModule.js +15 -0
  8. package/dist/modules/Customer/index.js +9 -10
  9. package/dist/modules/Customer/types.d.ts +2 -2
  10. package/dist/modules/Customer/types.js +2 -2
  11. package/dist/modules/Discount/index.js +1 -1
  12. package/dist/modules/Guests/index.js +9 -9
  13. package/dist/modules/Order/index.js +1 -1
  14. package/dist/modules/Payment/index.js +63 -73
  15. package/dist/modules/Payment/walletpass.js +4 -1
  16. package/dist/modules/Product/types.d.ts +19 -0
  17. package/dist/modules/ProductList/index.js +5 -14
  18. package/dist/modules/Resource/index.js +1 -1
  19. package/dist/modules/Rules/index.js +2 -3
  20. package/dist/modules/Schedule/types.d.ts +2 -0
  21. package/dist/plugins/request.d.ts +1 -0
  22. package/dist/server/index.d.ts +152 -0
  23. package/dist/server/index.js +946 -0
  24. package/dist/server/modules/index.d.ts +16 -0
  25. package/dist/server/modules/index.js +21 -0
  26. package/dist/server/modules/menu/index.d.ts +63 -0
  27. package/dist/server/modules/menu/index.js +476 -0
  28. package/dist/server/modules/menu/types.d.ts +68 -0
  29. package/dist/server/modules/menu/types.js +16 -0
  30. package/dist/server/modules/products/index.d.ts +141 -0
  31. package/dist/server/modules/products/index.js +768 -0
  32. package/dist/server/modules/products/types.d.ts +94 -0
  33. package/dist/server/modules/products/types.js +43 -0
  34. package/dist/server/modules/quotation/index.d.ts +47 -0
  35. package/dist/server/modules/quotation/index.js +367 -0
  36. package/dist/server/modules/quotation/types.d.ts +50 -0
  37. package/dist/server/modules/quotation/types.js +20 -0
  38. package/dist/server/modules/schedule/index.d.ts +62 -0
  39. package/dist/server/modules/schedule/index.js +431 -0
  40. package/dist/server/modules/schedule/types.d.ts +1 -0
  41. package/dist/server/modules/schedule/types.js +2 -0
  42. package/dist/server/modules/schedule/utils.d.ts +32 -0
  43. package/dist/server/modules/schedule/utils.js +747 -0
  44. package/dist/server/types.d.ts +64 -0
  45. package/dist/server/types.js +1 -0
  46. package/dist/server/utils/index.d.ts +5 -0
  47. package/dist/server/utils/index.js +6 -0
  48. package/dist/server/utils/product.d.ts +18 -0
  49. package/dist/server/utils/product.js +339 -0
  50. package/dist/server/utils/schedule.d.ts +14 -0
  51. package/dist/server/utils/schedule.js +108 -0
  52. package/dist/server/utils/time.d.ts +18 -0
  53. package/dist/server/utils/time.js +53 -0
  54. package/dist/solution/BookingByStep/index.d.ts +0 -16
  55. package/dist/solution/BookingByStep/index.js +57 -508
  56. package/dist/solution/BookingByStep/utils/capacity.d.ts +2 -7
  57. package/dist/solution/BookingByStep/utils/capacity.js +8 -24
  58. package/dist/solution/BookingTicket/index.d.ts +12 -0
  59. package/dist/solution/BookingTicket/index.js +122 -79
  60. package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  61. package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
  62. package/dist/solution/BuyTickets/index.js +7 -8
  63. package/dist/solution/Checkout/index.d.ts +1 -46
  64. package/dist/solution/Checkout/index.js +530 -850
  65. package/dist/solution/ShopDiscount/index.js +9 -10
  66. package/dist/types/index.d.ts +27 -0
  67. package/lib/core/index.d.ts +8 -1
  68. package/lib/core/index.js +48 -1
  69. package/lib/effects/index.d.ts +1 -0
  70. package/lib/effects/index.js +13 -0
  71. package/lib/modules/Account/index.js +2 -3
  72. package/lib/modules/BaseModule.d.ts +3 -0
  73. package/lib/modules/BaseModule.js +9 -0
  74. package/lib/modules/Customer/index.js +9 -10
  75. package/lib/modules/Customer/types.d.ts +2 -2
  76. package/lib/modules/Customer/types.js +2 -2
  77. package/lib/modules/Discount/index.js +1 -1
  78. package/lib/modules/Guests/index.js +9 -9
  79. package/lib/modules/Order/index.js +1 -1
  80. package/lib/modules/Payment/index.js +56 -43
  81. package/lib/modules/Payment/walletpass.js +3 -1
  82. package/lib/modules/Product/types.d.ts +19 -0
  83. package/lib/modules/ProductList/index.js +4 -13
  84. package/lib/modules/Resource/index.js +1 -1
  85. package/lib/modules/Rules/index.js +2 -3
  86. package/lib/modules/Schedule/types.d.ts +2 -0
  87. package/lib/plugins/request.d.ts +1 -0
  88. package/lib/server/index.d.ts +152 -0
  89. package/lib/server/index.js +555 -0
  90. package/lib/server/modules/index.d.ts +16 -0
  91. package/lib/server/modules/index.js +47 -0
  92. package/lib/server/modules/menu/index.d.ts +63 -0
  93. package/lib/server/modules/menu/index.js +234 -0
  94. package/lib/server/modules/menu/types.d.ts +68 -0
  95. package/lib/server/modules/menu/types.js +33 -0
  96. package/lib/server/modules/products/index.d.ts +141 -0
  97. package/lib/server/modules/products/index.js +434 -0
  98. package/lib/server/modules/products/types.d.ts +94 -0
  99. package/lib/server/modules/products/types.js +35 -0
  100. package/lib/server/modules/quotation/index.d.ts +47 -0
  101. package/lib/server/modules/quotation/index.js +177 -0
  102. package/lib/server/modules/quotation/types.d.ts +50 -0
  103. package/lib/server/modules/quotation/types.js +33 -0
  104. package/lib/server/modules/schedule/index.d.ts +62 -0
  105. package/lib/server/modules/schedule/index.js +231 -0
  106. package/lib/server/modules/schedule/types.d.ts +1 -0
  107. package/lib/server/modules/schedule/types.js +23 -0
  108. package/lib/server/modules/schedule/utils.d.ts +32 -0
  109. package/lib/server/modules/schedule/utils.js +451 -0
  110. package/lib/server/types.d.ts +64 -0
  111. package/lib/server/types.js +17 -0
  112. package/lib/server/utils/index.d.ts +5 -0
  113. package/lib/server/utils/index.js +25 -0
  114. package/lib/server/utils/product.d.ts +18 -0
  115. package/lib/server/utils/product.js +262 -0
  116. package/lib/server/utils/schedule.d.ts +14 -0
  117. package/lib/server/utils/schedule.js +88 -0
  118. package/lib/server/utils/time.d.ts +18 -0
  119. package/lib/server/utils/time.js +70 -0
  120. package/lib/solution/BookingByStep/index.d.ts +0 -16
  121. package/lib/solution/BookingByStep/index.js +44 -316
  122. package/lib/solution/BookingByStep/utils/capacity.d.ts +2 -7
  123. package/lib/solution/BookingByStep/utils/capacity.js +8 -21
  124. package/lib/solution/BookingTicket/index.d.ts +12 -0
  125. package/lib/solution/BookingTicket/index.js +25 -6
  126. package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  127. package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
  128. package/lib/solution/BuyTickets/index.js +7 -8
  129. package/lib/solution/Checkout/index.d.ts +1 -46
  130. package/lib/solution/Checkout/index.js +92 -289
  131. package/lib/solution/ShopDiscount/index.js +10 -11
  132. package/lib/types/index.d.ts +27 -0
  133. package/package.json +2 -2
@@ -34,7 +34,6 @@ __export(ShopDiscount_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(ShopDiscount_exports);
36
36
  var import_BaseModule = require("../../modules/BaseModule");
37
- var import_types = require("./types");
38
37
  var import_Discount = require("../../modules/Discount");
39
38
  var import_Rules = require("../../modules/Rules");
40
39
  var import_decimal = __toESM(require("decimal.js"));
@@ -73,7 +72,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
73
72
  (_a = this.store.discount) == null ? void 0 : _a.destroy();
74
73
  (_b = this.store.rules) == null ? void 0 : _b.destroy();
75
74
  this.core.effects.offByModuleDestroy(this.name);
76
- await this.core.effects.emit(import_types.ShopDiscountHooks.onDestroy, {});
75
+ await this.core.effects.emit(`${this.name}:onDestroy`, {});
77
76
  console.log("[ShopDiscount] 已销毁");
78
77
  }
79
78
  async clear() {
@@ -123,8 +122,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
123
122
  this.store.rules = rules;
124
123
  }
125
124
  registerEventListeners() {
126
- this.core.effects.on(
127
- import_types.ShopDiscountHooks.onCustomerChange,
125
+ this.core.effects.only(
126
+ `${this.name}:onCustomerChange`,
128
127
  (customer) => {
129
128
  var _a;
130
129
  if (((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) && this.getDiscountList().length) {
@@ -146,7 +145,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
146
145
  if (((_a = this.store.customer) == null ? void 0 : _a.id) !== customer.id) {
147
146
  this.store.customer = customer;
148
147
  await this.core.effects.emit(
149
- import_types.ShopDiscountHooks.onCustomerChange,
148
+ `${this.name}:onCustomerChange`,
150
149
  customer
151
150
  );
152
151
  }
@@ -292,7 +291,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
292
291
  // 触发优惠列表变更事件
293
292
  async emitDiscountListChange(discountList) {
294
293
  await this.core.effects.emit(
295
- import_types.ShopDiscountHooks.onDiscountListChange,
294
+ `${this.name}:onDiscountListChange`,
296
295
  discountList
297
296
  );
298
297
  }
@@ -390,7 +389,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
390
389
  const { ...customer } = result.data;
391
390
  this.setCustomer(customer);
392
391
  await this.core.effects.emit(
393
- import_types.ShopDiscountHooks.onScanCustomerChange,
392
+ `${this.name}:onScanCustomerChange`,
394
393
  customer
395
394
  );
396
395
  }
@@ -406,12 +405,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
406
405
  const result = this.calcDiscount(this.store.productList);
407
406
  cb == null ? void 0 : cb(result);
408
407
  await this.core.effects.emit(
409
- import_types.ShopDiscountHooks.onLoadPrepareCalcResult,
408
+ `${this.name}:onLoadPrepareCalcResult`,
410
409
  result
411
410
  );
412
411
  }
413
412
  await this.core.effects.emit(
414
- import_types.ShopDiscountHooks.onLoadDiscountList,
413
+ `${this.name}:onLoadDiscountList`,
415
414
  newDiscountList
416
415
  );
417
416
  }
@@ -437,12 +436,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
437
436
  if ((_d = this.store.productList) == null ? void 0 : _d.length) {
438
437
  const result = this.calcDiscount(this.store.productList);
439
438
  await this.core.effects.emit(
440
- import_types.ShopDiscountHooks.onLoadPrepareCalcResult,
439
+ `${this.name}:onLoadPrepareCalcResult`,
441
440
  result
442
441
  );
443
442
  }
444
443
  await this.core.effects.emit(
445
- import_types.ShopDiscountHooks.onLoadDiscountList,
444
+ `${this.name}:onLoadDiscountList`,
446
445
  newDiscountList
447
446
  );
448
447
  } catch (error) {
@@ -40,6 +40,7 @@ export interface PisellCore {
40
40
  effects: {
41
41
  on: (event: string, callback: (payload: any) => void) => () => void;
42
42
  once: (event: string, callback: (payload: any) => void) => () => void;
43
+ only: (event: string, callback: (payload: any) => void) => () => void;
43
44
  off: (event: string, callback: (payload: any) => void) => void;
44
45
  emit: (event: string, payload: any, value?: any) => Promise<{
45
46
  status: boolean;
@@ -74,6 +75,26 @@ export interface ModuleContextConfig {
74
75
  name: string;
75
76
  validations: ContextValidationRule[];
76
77
  }
78
+ /**
79
+ * Server 模块配置
80
+ */
81
+ export interface ServerModuleConfig {
82
+ /** 模块名称 */
83
+ name: string;
84
+ /** 是否自动预加载数据 */
85
+ preload?: boolean;
86
+ /** 模块配置参数 */
87
+ config?: Record<string, any>;
88
+ }
89
+ /**
90
+ * Server 配置选项
91
+ */
92
+ export interface ServerOptions {
93
+ /** 要启用的模块列表 */
94
+ modules?: string[] | ServerModuleConfig[];
95
+ /** 是否自动初始化数据 */
96
+ autoInitData?: boolean;
97
+ }
77
98
  export interface PisellOSOptions {
78
99
  debug?: boolean;
79
100
  plugins?: Array<{
@@ -85,4 +106,10 @@ export interface PisellOSOptions {
85
106
  options?: ModuleOptions;
86
107
  }>;
87
108
  context?: BusinessContext;
109
+ /** Server 配置 */
110
+ server?: ServerOptions;
111
+ }
112
+ export interface InitializeServerOptions {
113
+ onModuleLoad?: (module: string) => void;
114
+ onModuleLoadComplete?: (module: string) => void;
88
115
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.36",
4
+ "version": "2.2.1",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -69,4 +69,4 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  }
72
- }
72
+ }