@pisell/pisellos 1.0.147 → 1.0.148

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 (107) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/model/strategy/adapter/itemRule/type.d.ts +6 -6
  3. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  4. package/dist/model/strategy/adapter/promotion/type.d.ts +5 -5
  5. package/dist/model/strategy/type.d.ts +1 -1
  6. package/dist/modules/Customer/types.d.ts +1 -1
  7. package/dist/modules/Discount/types.d.ts +1 -1
  8. package/dist/modules/Payment/types.d.ts +7 -7
  9. package/dist/modules/Product/index.d.ts +1 -1
  10. package/dist/modules/Rules/index.js +2 -1
  11. package/dist/modules/Rules/types.d.ts +1 -1
  12. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  13. package/dist/modules/Schedule/type.d.ts +7 -7
  14. package/dist/modules/Schedule/types.d.ts +9 -9
  15. package/dist/solution/BookingByStep/index.d.ts +1 -1
  16. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  17. package/dist/solution/BookingTicket/index.d.ts +1 -1
  18. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  19. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  20. package/dist/types/index.d.ts +1 -1
  21. package/dist/utils/task.d.ts +2 -2
  22. package/dist/utils/watch.d.ts +2 -2
  23. package/lib/core/index.js +27 -28
  24. package/lib/effects/index.d.ts +2 -2
  25. package/lib/effects/index.js +3 -7
  26. package/lib/model/strategy/adapter/itemRule/adapter.js +7 -14
  27. package/lib/model/strategy/adapter/itemRule/evaluator.js +5 -5
  28. package/lib/model/strategy/adapter/itemRule/examples.js +12 -12
  29. package/lib/model/strategy/adapter/itemRule/type.d.ts +6 -6
  30. package/lib/model/strategy/adapter/promotion/adapter.js +2 -4
  31. package/lib/model/strategy/adapter/promotion/evaluator.js +16 -19
  32. package/lib/model/strategy/adapter/promotion/examples.js +8 -8
  33. package/lib/model/strategy/adapter/promotion/type.d.ts +5 -5
  34. package/lib/model/strategy/adapter/walletPass/evaluator.js +5 -5
  35. package/lib/model/strategy/adapter/walletPass/example.js +21 -21
  36. package/lib/model/strategy/adapter/walletPass/index.js +2 -4
  37. package/lib/model/strategy/adapter/walletPass/locales.js +18 -18
  38. package/lib/model/strategy/adapter/walletPass/utils.js +21 -42
  39. package/lib/model/strategy/engine.js +6 -8
  40. package/lib/model/strategy/strategy-example.js +19 -19
  41. package/lib/model/strategy/type.d.ts +1 -1
  42. package/lib/modules/Account/index.js +9 -10
  43. package/lib/modules/AccountList/index.js +14 -11
  44. package/lib/modules/BaseModule.js +6 -3
  45. package/lib/modules/Cart/index.js +14 -9
  46. package/lib/modules/Cart/utils/cartProduct.js +3 -6
  47. package/lib/modules/Customer/constants.js +1 -1
  48. package/lib/modules/Customer/index.js +18 -15
  49. package/lib/modules/Customer/types.d.ts +1 -1
  50. package/lib/modules/Date/index.js +10 -6
  51. package/lib/modules/Date/types.js +1 -0
  52. package/lib/modules/Discount/index.js +11 -6
  53. package/lib/modules/Discount/types.d.ts +1 -1
  54. package/lib/modules/Guests/index.js +10 -15
  55. package/lib/modules/Order/index.js +10 -7
  56. package/lib/modules/Payment/cash.js +1 -1
  57. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  58. package/lib/modules/Payment/eftpos.js +1 -1
  59. package/lib/modules/Payment/index.js +86 -73
  60. package/lib/modules/Payment/types.d.ts +7 -7
  61. package/lib/modules/Payment/utils.js +3 -6
  62. package/lib/modules/Payment/walletpass.js +33 -33
  63. package/lib/modules/Product/index.d.ts +1 -1
  64. package/lib/modules/Product/index.js +6 -5
  65. package/lib/modules/ProductList/index.js +5 -3
  66. package/lib/modules/Resource/index.js +8 -12
  67. package/lib/modules/Rules/index.js +24 -36
  68. package/lib/modules/Rules/types.d.ts +1 -1
  69. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  70. package/lib/modules/Schedule/index.js +8 -5
  71. package/lib/modules/Schedule/type.d.ts +7 -7
  72. package/lib/modules/Schedule/types.d.ts +9 -9
  73. package/lib/modules/Schedule/utils.js +2 -4
  74. package/lib/modules/Step/index.js +7 -4
  75. package/lib/modules/Summary/index.js +9 -4
  76. package/lib/modules/Summary/utils.js +8 -16
  77. package/lib/plugins/request.js +34 -33
  78. package/lib/plugins/window.js +101 -113
  79. package/lib/solution/BookingByStep/index.d.ts +1 -1
  80. package/lib/solution/BookingByStep/index.js +110 -177
  81. package/lib/solution/BookingByStep/utils/capacity.js +10 -15
  82. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  83. package/lib/solution/BookingByStep/utils/resources.js +4 -8
  84. package/lib/solution/BookingByStep/utils/stock.js +3 -6
  85. package/lib/solution/BookingByStep/utils/timeslots.js +26 -31
  86. package/lib/solution/BookingTicket/index.d.ts +1 -1
  87. package/lib/solution/BookingTicket/index.js +19 -14
  88. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  89. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  90. package/lib/solution/BookingTicket/utils/scan/index.js +3 -1
  91. package/lib/solution/BookingTicket/utils/scan/scanCache.js +10 -9
  92. package/lib/solution/BuyTickets/index.js +15 -15
  93. package/lib/solution/Checkout/index.js +216 -211
  94. package/lib/solution/Checkout/utils/index.js +18 -22
  95. package/lib/solution/RegisterAndLogin/config.js +2 -2
  96. package/lib/solution/RegisterAndLogin/index.js +114 -110
  97. package/lib/solution/RegisterAndLogin/utils.js +9 -9
  98. package/lib/solution/ShopDiscount/index.js +16 -13
  99. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  100. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  101. package/lib/solution/ShopDiscount/utils.js +1 -2
  102. package/lib/types/index.d.ts +1 -1
  103. package/lib/utils/task.d.ts +2 -2
  104. package/lib/utils/task.js +3 -3
  105. package/lib/utils/watch.d.ts +2 -2
  106. package/lib/utils/watch.js +5 -7
  107. package/package.json +16 -17
@@ -56,22 +56,22 @@ function validatePhone(phone) {
56
56
  function validatePassword(password) {
57
57
  const errors = [];
58
58
  if (password.length < 8) {
59
- errors.push("密码长度至少为8位");
59
+ errors.push("\u5BC6\u7801\u957F\u5EA6\u81F3\u5C11\u4E3A8\u4F4D");
60
60
  }
61
61
  if (password.length > 128) {
62
- errors.push("密码长度不能超过128位");
62
+ errors.push("\u5BC6\u7801\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7128\u4F4D");
63
63
  }
64
64
  if (!/[a-z]/.test(password)) {
65
- errors.push("密码必须包含至少一个小写字母");
65
+ errors.push("\u5BC6\u7801\u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4E2A\u5C0F\u5199\u5B57\u6BCD");
66
66
  }
67
67
  if (!/[A-Z]/.test(password)) {
68
- errors.push("密码必须包含至少一个大写字母");
68
+ errors.push("\u5BC6\u7801\u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD");
69
69
  }
70
70
  if (!/\d/.test(password)) {
71
- errors.push("密码必须包含至少一个数字");
71
+ errors.push("\u5BC6\u7801\u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4E2A\u6570\u5B57");
72
72
  }
73
73
  if (!/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(password)) {
74
- errors.push("密码必须包含至少一个特殊字符");
74
+ errors.push("\u5BC6\u7801\u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4E2A\u7279\u6B8A\u5B57\u7B26");
75
75
  }
76
76
  return {
77
77
  isValid: errors.length === 0,
@@ -124,7 +124,7 @@ function getOAuthProviderDisplayName(provider) {
124
124
  [import_types.OAuthProvider.FACEBOOK]: "Facebook",
125
125
  [import_types.OAuthProvider.APPLE]: "Apple",
126
126
  [import_types.OAuthProvider.GOOGLE]: "Google",
127
- [import_types.OAuthProvider.WECHAT]: "微信",
127
+ [import_types.OAuthProvider.WECHAT]: "\u5FAE\u4FE1",
128
128
  [import_types.OAuthProvider.GITHUB]: "GitHub"
129
129
  };
130
130
  return displayNames[provider] || provider;
@@ -224,7 +224,7 @@ function safeJsonParse(jsonString, defaultValue) {
224
224
  try {
225
225
  return JSON.parse(jsonString);
226
226
  } catch (error) {
227
- console.warn("JSON 解析失败:", error);
227
+ console.warn("JSON \u89E3\u6790\u5931\u8D25:", error);
228
228
  return defaultValue;
229
229
  }
230
230
  }
@@ -232,7 +232,7 @@ function safeJsonStringify(obj, defaultValue = "{}") {
232
232
  try {
233
233
  return JSON.stringify(obj);
234
234
  } catch (error) {
235
- console.warn("JSON 字符串化失败:", error);
235
+ console.warn("JSON \u5B57\u7B26\u4E32\u5316\u5931\u8D25:", error);
236
236
  return defaultValue;
237
237
  }
238
238
  }
@@ -41,12 +41,16 @@ var import_types = require("../../modules/Rules/types");
41
41
  var import_decimal = __toESM(require("decimal.js"));
42
42
  var import_lodash_es = require("lodash-es");
43
43
  var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
44
+ defaultName = "shopDiscount";
45
+ defaultVersion = "1.0.0";
46
+ isSolution = true;
47
+ request;
48
+ window;
49
+ store;
50
+ options = {};
51
+ hooks;
44
52
  constructor(name, version) {
45
53
  super(name, version);
46
- this.defaultName = "shopDiscount";
47
- this.defaultVersion = "1.0.0";
48
- this.isSolution = true;
49
- this.options = {};
50
54
  this.store = {
51
55
  customer: null,
52
56
  productList: [],
@@ -68,7 +72,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
68
72
  this.options = options;
69
73
  this.store = { ...this.store, ...options.store || {} };
70
74
  this.hooks = (_b = (_a = options.otherParams) == null ? void 0 : _a.rules) == null ? void 0 : _b.hooks;
71
- console.log("[ShopDiscount] 初始化完成");
75
+ console.log("[ShopDiscount] \u521D\u59CB\u5316\u5B8C\u6210");
72
76
  this.initializePlugins();
73
77
  this.registerDependentModules();
74
78
  this.registerEventListeners();
@@ -81,7 +85,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
81
85
  (_b = this.store.rules) == null ? void 0 : _b.destroy();
82
86
  this.core.effects.offByModuleDestroy(this.name);
83
87
  await this.core.effects.emit(`${this.name}:onDestroy`, {});
84
- console.log("[ShopDiscount] 已销毁");
88
+ console.log("[ShopDiscount] \u5DF2\u9500\u6BC1");
85
89
  }
86
90
  async clear() {
87
91
  var _a, _b;
@@ -96,10 +100,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
96
100
  this.request = this.core.getPlugin("request");
97
101
  this.window = this.core.getPlugin("window");
98
102
  if (!this.request) {
99
- throw new Error("ShopDiscount需要 request 插件支持");
103
+ throw new Error("ShopDiscount\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
100
104
  }
101
105
  if (!this.window) {
102
- throw new Error("ShopDiscount需要 window 插件支持");
106
+ throw new Error("ShopDiscount\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
103
107
  }
104
108
  }
105
109
  registerDependentModules() {
@@ -357,7 +361,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
357
361
  unavailableReason
358
362
  };
359
363
  } catch (error) {
360
- console.error("[ShopDiscount] 扫码出错:", error);
364
+ console.error("[ShopDiscount] \u626B\u7801\u51FA\u9519:", error);
361
365
  return {
362
366
  type: "clientCalc",
363
367
  isAvailable: false,
@@ -449,8 +453,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
449
453
  const isProductFree = (id) => {
450
454
  var _a2;
451
455
  const targetProduct = productList.find((n) => n.id === id);
452
- if (!targetProduct)
453
- return false;
456
+ if (!targetProduct) return false;
454
457
  const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
455
458
  return Number(product == null ? void 0 : product.total) <= 0 && (Number(product == null ? void 0 : product.origin_total) <= 0 || !(product == null ? void 0 : product.origin_total)) || (0, import_lodash_es.isBoolean)(product == null ? void 0 : product.vouchersApplicable) && !(product == null ? void 0 : product.vouchersApplicable);
456
459
  };
@@ -499,7 +502,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
499
502
  );
500
503
  }
501
504
  } catch (error) {
502
- console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
505
+ console.error("[ShopDiscount] \u83B7\u53D6\u5BA2\u6237\u94B1\u5305\u4FE1\u606F\u51FA\u9519:", error);
503
506
  }
504
507
  }
505
508
  async bestDiscount(cb) {
@@ -557,7 +560,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
557
560
  filteredDiscountList
558
561
  );
559
562
  } catch (error) {
560
- console.error("[ShopDiscount] 加载准备配置出错:", error);
563
+ console.error("[ShopDiscount] \u52A0\u8F7D\u51C6\u5907\u914D\u7F6E\u51FA\u9519:", error);
561
564
  }
562
565
  }
563
566
  };
@@ -10,7 +10,7 @@ export declare enum ShopDiscountHooks {
10
10
  onRulesListChange = "shopDiscount:onRulesListChange",
11
11
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
12
12
  }
13
- export type Customer = {
13
+ export declare type Customer = {
14
14
  id: string | number;
15
15
  name: string;
16
16
  email: string;
@@ -12,13 +12,13 @@ export declare const isAllNormalProduct: (items: any[]) => boolean;
12
12
  * @returns
13
13
  */
14
14
  export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
15
- export declare const getDiscountListAmountTotal: (discount: Discount[]) => any;
15
+ export declare const getDiscountListAmountTotal: (discount: Discount[]) => Discount;
16
16
  /**
17
17
  * 获取折扣金额 计算每个折扣的金额
18
18
  * @param discount
19
19
  * @returns
20
20
  */
21
- export declare const getDiscountListAmount: (discount: Discount[]) => any;
21
+ export declare const getDiscountListAmount: (discount: Discount[]) => Discount;
22
22
  export interface ScheduleItem {
23
23
  id: number;
24
24
  name: string | {
@@ -355,8 +355,7 @@ var calculateOrderLevelDiscountAllocation = (discount, applicableProducts) => {
355
355
  if (singleQuantityProducts.length > 0) {
356
356
  const productsWithEnoughSpace = singleQuantityProducts.filter((product) => {
357
357
  const allocation = result.get(product.productId);
358
- if (!allocation)
359
- return false;
358
+ if (!allocation) return false;
360
359
  const remainingSpace = new import_decimal.default(product.amount).minus(allocation.discountAmount).toNumber();
361
360
  return remainingSpace >= totalDifference;
362
361
  });
@@ -27,7 +27,7 @@ export interface ModuleOptions {
27
27
  initialState?: Record<string, any>;
28
28
  otherParams?: Record<string, any>;
29
29
  }
30
- export type EventHandler = (data?: any) => void;
30
+ export declare type EventHandler = (data?: any) => void;
31
31
  export interface PisellCore {
32
32
  registerPlugin: (plugin: Plugin, options?: PluginOptions) => void;
33
33
  getPlugin: <T extends Plugin>(name: string) => T | null;
@@ -1,5 +1,5 @@
1
- type Action = (...args: any[]) => Promise<any>;
2
- type Task = {
1
+ declare type Action = (...args: any[]) => Promise<any>;
2
+ declare type Task = {
3
3
  uuid: string;
4
4
  type: string;
5
5
  actionParams?: Record<string, any>;
package/lib/utils/task.js CHANGED
@@ -23,10 +23,10 @@ __export(task_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(task_exports);
25
25
  var Tasks = class {
26
+ actions = /* @__PURE__ */ new Map();
27
+ taskQueue = [];
28
+ isRunning = false;
26
29
  constructor(actions) {
27
- this.actions = /* @__PURE__ */ new Map();
28
- this.taskQueue = [];
29
- this.isRunning = false;
30
30
  if (actions) {
31
31
  this.actions = actions;
32
32
  }
@@ -2,8 +2,8 @@
2
2
  * 监听模块
3
3
  *
4
4
  */
5
- export type WatchEventCallback = (...args: any[]) => void;
6
- export type WatchEventItem = {
5
+ export declare type WatchEventCallback = (...args: any[]) => void;
6
+ export declare type WatchEventItem = {
7
7
  key: string;
8
8
  callback: WatchEventCallback;
9
9
  };
@@ -23,12 +23,10 @@ __export(watch_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(watch_exports);
25
25
  var Watch = class {
26
- constructor() {
27
- // 监听列表
28
- this.events = /* @__PURE__ */ new Map();
29
- // 启用列表 - 使用数组保持顺序
30
- this.enableListMap = /* @__PURE__ */ new Map();
31
- }
26
+ // 监听列表
27
+ events = /* @__PURE__ */ new Map();
28
+ // 启用列表 - 使用数组保持顺序
29
+ enableListMap = /* @__PURE__ */ new Map();
32
30
  /**
33
31
  * 订阅事件
34
32
  * @param event 事件名称
@@ -132,7 +130,7 @@ var Watch = class {
132
130
  try {
133
131
  (_a = callbacks.get(lastCallbackKey)) == null ? void 0 : _a(...args);
134
132
  } catch (error) {
135
- console.error(`执行事件"${watchKey}"的回调时出错:`, error);
133
+ console.error(`\u6267\u884C\u4E8B\u4EF6"${watchKey}"\u7684\u56DE\u8C03\u65F6\u51FA\u9519:`, error);
136
134
  }
137
135
  }
138
136
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "1.0.147",
4
+ "version": "1.0.148",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -9,22 +9,6 @@
9
9
  "dist",
10
10
  "lib"
11
11
  ],
12
- "scripts": {
13
- "build": "father build",
14
- "dev": "father dev --watch",
15
- "push": "yalc push --replace",
16
- "test": "vitest",
17
- "lint": "eslint src --ext .ts",
18
- "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
19
- "changeset": "changeset",
20
- "version": "changeset version",
21
- "release": "changeset publish && npm run sync && git push",
22
- "example": "npx parcel-bundler examples/index.html",
23
- "docs": "typedoc --out docs src/index.ts",
24
- "sync": "node sync.js",
25
- "prepublishOnly": "npm run build",
26
- "deploy": "npm run build && npm run changeset && npm run version && npm run release"
27
- },
28
12
  "repository": {
29
13
  "type": "git",
30
14
  "url": "git+https://github.com/username/pisell-os.git"
@@ -72,5 +56,20 @@
72
56
  },
73
57
  "volta": {
74
58
  "node": "18.20.8"
59
+ },
60
+ "scripts": {
61
+ "build": "father build",
62
+ "dev": "father dev --watch",
63
+ "push": "yalc push --replace",
64
+ "test": "vitest",
65
+ "lint": "eslint src --ext .ts",
66
+ "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
67
+ "changeset": "changeset",
68
+ "version": "changeset version",
69
+ "release": "changeset publish && npm run sync && git push",
70
+ "example": "npx parcel-bundler examples/index.html",
71
+ "docs": "typedoc --out docs src/index.ts",
72
+ "sync": "node sync.js",
73
+ "deploy": "npm run build && npm run changeset && npm run version && npm run release"
75
74
  }
76
75
  }