@pisell/pisellos 0.0.373 → 0.0.376

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 (92) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/model/strategy/adapter/walletPass/utils.js +7 -2
  3. package/dist/model/strategy/type.d.ts +1 -1
  4. package/dist/modules/Customer/types.d.ts +1 -1
  5. package/dist/modules/Payment/index.js +35 -7
  6. package/dist/modules/Payment/types.d.ts +9 -7
  7. package/dist/modules/Product/index.d.ts +1 -1
  8. package/dist/modules/Rules/types.d.ts +1 -1
  9. package/dist/modules/Schedule/type.d.ts +7 -7
  10. package/dist/modules/Schedule/types.d.ts +9 -9
  11. package/dist/solution/BookingByStep/index.d.ts +2 -2
  12. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  13. package/dist/solution/Checkout/index.js +31 -2
  14. package/dist/solution/Checkout/types.d.ts +2 -0
  15. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  16. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  17. package/dist/types/index.d.ts +1 -1
  18. package/dist/utils/task.d.ts +2 -2
  19. package/dist/utils/watch.d.ts +2 -2
  20. package/lib/core/index.js +28 -27
  21. package/lib/effects/index.d.ts +2 -2
  22. package/lib/effects/index.js +7 -3
  23. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -3
  24. package/lib/model/strategy/adapter/walletPass/example.js +21 -21
  25. package/lib/model/strategy/adapter/walletPass/index.js +4 -2
  26. package/lib/model/strategy/adapter/walletPass/locales.js +10 -10
  27. package/lib/model/strategy/adapter/walletPass/utils.js +9 -4
  28. package/lib/model/strategy/index.js +10 -7
  29. package/lib/model/strategy/strategy-example.js +19 -19
  30. package/lib/model/strategy/type.d.ts +1 -1
  31. package/lib/modules/Account/index.js +10 -9
  32. package/lib/modules/AccountList/index.js +11 -14
  33. package/lib/modules/BaseModule.js +3 -6
  34. package/lib/modules/Cart/index.js +9 -14
  35. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  36. package/lib/modules/Customer/constants.js +1 -1
  37. package/lib/modules/Customer/index.js +15 -18
  38. package/lib/modules/Customer/types.d.ts +1 -1
  39. package/lib/modules/Date/index.js +6 -10
  40. package/lib/modules/Date/types.js +0 -1
  41. package/lib/modules/Discount/index.js +6 -11
  42. package/lib/modules/Guests/index.js +15 -10
  43. package/lib/modules/Order/index.js +9 -11
  44. package/lib/modules/Payment/cash.js +1 -1
  45. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  46. package/lib/modules/Payment/eftpos.js +1 -1
  47. package/lib/modules/Payment/index.js +94 -86
  48. package/lib/modules/Payment/types.d.ts +9 -7
  49. package/lib/modules/Payment/utils.js +6 -3
  50. package/lib/modules/Payment/walletpass.js +33 -33
  51. package/lib/modules/Product/index.d.ts +1 -1
  52. package/lib/modules/Product/index.js +5 -6
  53. package/lib/modules/ProductList/index.js +3 -5
  54. package/lib/modules/Resource/index.js +12 -8
  55. package/lib/modules/Rules/index.js +21 -16
  56. package/lib/modules/Rules/types.d.ts +1 -1
  57. package/lib/modules/Schedule/index.js +5 -8
  58. package/lib/modules/Schedule/type.d.ts +7 -7
  59. package/lib/modules/Schedule/types.d.ts +9 -9
  60. package/lib/modules/Schedule/utils.js +4 -2
  61. package/lib/modules/Step/index.js +4 -7
  62. package/lib/modules/Summary/index.js +4 -9
  63. package/lib/plugins/request.js +33 -34
  64. package/lib/plugins/window.js +113 -101
  65. package/lib/solution/BookingByStep/index.d.ts +2 -2
  66. package/lib/solution/BookingByStep/index.js +129 -86
  67. package/lib/solution/BookingByStep/utils/capacity.js +15 -10
  68. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  69. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  70. package/lib/solution/BookingByStep/utils/stock.js +6 -3
  71. package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
  72. package/lib/solution/BookingTicket/index.js +14 -19
  73. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  74. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  75. package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
  76. package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
  77. package/lib/solution/BuyTickets/index.js +15 -15
  78. package/lib/solution/Checkout/index.js +233 -217
  79. package/lib/solution/Checkout/types.d.ts +2 -0
  80. package/lib/solution/Checkout/utils/index.js +22 -18
  81. package/lib/solution/RegisterAndLogin/config.js +2 -2
  82. package/lib/solution/RegisterAndLogin/index.js +110 -114
  83. package/lib/solution/RegisterAndLogin/utils.js +9 -9
  84. package/lib/solution/ShopDiscount/index.js +13 -16
  85. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  86. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  87. package/lib/types/index.d.ts +1 -1
  88. package/lib/utils/task.d.ts +2 -2
  89. package/lib/utils/task.js +3 -3
  90. package/lib/utils/watch.d.ts +2 -2
  91. package/lib/utils/watch.js +7 -5
  92. package/package.json +18 -17
@@ -25,16 +25,11 @@ module.exports = __toCommonJS(Summary_exports);
25
25
  var import_BaseModule = require("../BaseModule");
26
26
  var import_utils = require("./utils");
27
27
  var SummaryModule = class extends import_BaseModule.BaseModule {
28
- defaultName = "summary";
29
- defaultVersion = "1.0.0";
30
- shopStore;
31
- store;
32
- request;
33
- cacheId;
34
- openCache = false;
35
- fatherModule;
36
28
  constructor(name, version) {
37
29
  super(name, version);
30
+ this.defaultName = "summary";
31
+ this.defaultVersion = "1.0.0";
32
+ this.openCache = false;
38
33
  }
39
34
  async initialize(core, options) {
40
35
  var _a, _b;
@@ -53,7 +48,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
53
48
  this.fatherModule = options.otherParams.fatherModule;
54
49
  }
55
50
  if (!this.shopStore) {
56
- throw new Error("SummaryModule \u9700\u8981 shopStore \u63D2\u4EF6\u652F\u6301");
51
+ throw new Error("SummaryModule 需要 shopStore 插件支持");
57
52
  }
58
53
  }
59
54
  async getSummary(cartItems) {
@@ -24,9 +24,6 @@ __export(request_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(request_exports);
26
26
  var RequestError = class extends Error {
27
- response;
28
- request;
29
- config;
30
27
  constructor(message, config, request, response) {
31
28
  super(message);
32
29
  this.name = "RequestError";
@@ -36,36 +33,38 @@ var RequestError = class extends Error {
36
33
  }
37
34
  };
38
35
  var RequestPluginImpl = class {
39
- name = "request";
40
- version = "1.0.0";
41
- core = null;
42
- /**
43
- * 默认请求选项
44
- */
45
- defaultOptions = {
46
- method: "GET",
47
- headers: {
48
- "Content-Type": "application/json"
49
- },
50
- timeout: 3e4,
51
- responseType: "json"
52
- };
53
- /**
54
- * 全局拦截器
55
- */
56
- interceptors = {
57
- request: [],
58
- response: [],
59
- error: []
60
- };
36
+ constructor() {
37
+ this.name = "request";
38
+ this.version = "1.0.0";
39
+ this.core = null;
40
+ /**
41
+ * 默认请求选项
42
+ */
43
+ this.defaultOptions = {
44
+ method: "GET",
45
+ headers: {
46
+ "Content-Type": "application/json"
47
+ },
48
+ timeout: 3e4,
49
+ responseType: "json"
50
+ };
51
+ /**
52
+ * 全局拦截器
53
+ */
54
+ this.interceptors = {
55
+ request: [],
56
+ response: [],
57
+ error: []
58
+ };
59
+ }
61
60
  // 初始化方法
62
61
  initialize() {
63
62
  this.core = globalThis.pisellOS;
64
- console.log("[RequestPlugin] \u521D\u59CB\u5316\u5B8C\u6210");
63
+ console.log("[RequestPlugin] 初始化完成");
65
64
  }
66
65
  // 销毁方法
67
66
  destroy() {
68
- console.log("[RequestPlugin] \u5DF2\u9500\u6BC1");
67
+ console.log("[RequestPlugin] 已销毁");
69
68
  }
70
69
  /**
71
70
  * 添加请求拦截器
@@ -150,7 +149,7 @@ var RequestPluginImpl = class {
150
149
  config = await Promise.resolve(interceptor(config));
151
150
  } catch (error) {
152
151
  const requestError = error instanceof RequestError ? error : new RequestError(
153
- error instanceof Error ? error.message : "\u8BF7\u6C42\u62E6\u622A\u5668\u9519\u8BEF",
152
+ error instanceof Error ? error.message : "请求拦截器错误",
154
153
  config
155
154
  );
156
155
  let processedError = requestError;
@@ -175,7 +174,7 @@ var RequestPluginImpl = class {
175
174
  );
176
175
  } catch (error) {
177
176
  const requestError = error instanceof RequestError ? error : new RequestError(
178
- error instanceof Error ? error.message : "\u54CD\u5E94\u62E6\u622A\u5668\u9519\u8BEF",
177
+ error instanceof Error ? error.message : "响应拦截器错误",
179
178
  config,
180
179
  null,
181
180
  response
@@ -195,7 +194,7 @@ var RequestPluginImpl = class {
195
194
  return processedResponse.data;
196
195
  } catch (error) {
197
196
  const requestError = error instanceof RequestError ? error : new RequestError(
198
- error instanceof Error ? error.message : "\u8BF7\u6C42\u9519\u8BEF",
197
+ error instanceof Error ? error.message : "请求错误",
199
198
  config
200
199
  );
201
200
  let processedError = requestError;
@@ -226,7 +225,7 @@ var RequestPluginImpl = class {
226
225
  withCredentials
227
226
  } = config;
228
227
  if (!url) {
229
- throw new RequestError("URL\u4E0D\u80FD\u4E3A\u7A7A", config);
228
+ throw new RequestError("URL不能为空", config);
230
229
  }
231
230
  let fullUrl = url;
232
231
  if (params && Object.keys(params).length > 0) {
@@ -256,13 +255,13 @@ var RequestPluginImpl = class {
256
255
  const timeoutPromise = new Promise((_, reject) => {
257
256
  if (timeout) {
258
257
  timeoutId = setTimeout(() => {
259
- reject(new RequestError(`\u8BF7\u6C42\u8D85\u65F6: ${timeout}ms`, config));
258
+ reject(new RequestError(`请求超时: ${timeout}ms`, config));
260
259
  }, timeout);
261
260
  }
262
261
  });
263
262
  try {
264
263
  const fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(
265
- new RequestError("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301 fetch API", config)
264
+ new RequestError("当前环境不支持 fetch API", config)
266
265
  );
267
266
  const response = await Promise.race([fetchPromise, timeoutPromise]);
268
267
  const responseHeaders = {};
@@ -298,7 +297,7 @@ var RequestPluginImpl = class {
298
297
  };
299
298
  if (!response.ok) {
300
299
  throw new RequestError(
301
- `\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${response.status}`,
300
+ `请求失败,状态码: ${response.status}`,
302
301
  config,
303
302
  fetchOptions,
304
303
  result
@@ -23,7 +23,9 @@ __export(window_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(window_exports);
25
25
  var SimpleStorage = class {
26
- items = {};
26
+ constructor() {
27
+ this.items = {};
28
+ }
27
29
  get length() {
28
30
  return Object.keys(this.items).length;
29
31
  }
@@ -45,16 +47,18 @@ var SimpleStorage = class {
45
47
  }
46
48
  };
47
49
  var SimpleLocation = class {
48
- hash = "";
49
- host = "localhost";
50
- hostname = "localhost";
51
- href = "https://localhost";
52
- origin = "https://localhost";
53
- pathname = "/";
54
- port = "";
55
- protocol = "https:";
56
- search = "";
57
- ancestorOrigins = {};
50
+ constructor() {
51
+ this.hash = "";
52
+ this.host = "localhost";
53
+ this.hostname = "localhost";
54
+ this.href = "https://localhost";
55
+ this.origin = "https://localhost";
56
+ this.pathname = "/";
57
+ this.port = "";
58
+ this.protocol = "https:";
59
+ this.search = "";
60
+ this.ancestorOrigins = {};
61
+ }
58
62
  assign(url) {
59
63
  }
60
64
  reload() {
@@ -66,25 +70,29 @@ var SimpleLocation = class {
66
70
  }
67
71
  };
68
72
  var SimpleNavigator = class {
69
- userAgent = "PisellOS/1.0";
70
- language = "zh-CN";
71
- languages = ["zh-CN", "en-US"];
72
- onLine = true;
73
- cookieEnabled = true;
74
- // 以下属性只提供必要实现
75
- appCodeName = "PisellOS";
76
- appName = "PisellOS";
77
- appVersion = "1.0";
78
- platform = "PisellOS";
79
- product = "PisellOS";
73
+ constructor() {
74
+ this.userAgent = "PisellOS/1.0";
75
+ this.language = "zh-CN";
76
+ this.languages = ["zh-CN", "en-US"];
77
+ this.onLine = true;
78
+ this.cookieEnabled = true;
79
+ // 以下属性只提供必要实现
80
+ this.appCodeName = "PisellOS";
81
+ this.appName = "PisellOS";
82
+ this.appVersion = "1.0";
83
+ this.platform = "PisellOS";
84
+ this.product = "PisellOS";
85
+ }
80
86
  javaEnabled() {
81
87
  return false;
82
88
  }
83
89
  };
84
90
  var SimpleHistory = class {
85
- length = 0;
86
- scrollRestoration = "auto";
87
- state = null;
91
+ constructor() {
92
+ this.length = 0;
93
+ this.scrollRestoration = "auto";
94
+ this.state = null;
95
+ }
88
96
  back() {
89
97
  }
90
98
  forward() {
@@ -97,8 +105,17 @@ var SimpleHistory = class {
97
105
  }
98
106
  };
99
107
  var SimpleDocument = class {
100
- // 仅实现基本功能
101
- elements = {};
108
+ constructor() {
109
+ // 仅实现基本功能
110
+ this.elements = {};
111
+ // Document 接口的必要属性
112
+ this.URL = "https://localhost";
113
+ this.documentURI = "https://localhost";
114
+ this.origin = "https://localhost";
115
+ this.characterSet = "UTF-8";
116
+ this.contentType = "text/html";
117
+ this.compatMode = "CSS1Compat";
118
+ }
102
119
  createElement(tagName) {
103
120
  const element = {
104
121
  tagName: tagName.toUpperCase(),
@@ -138,13 +155,6 @@ var SimpleDocument = class {
138
155
  getElementById(id) {
139
156
  return this.elements[id] || null;
140
157
  }
141
- // Document 接口的必要属性
142
- URL = "https://localhost";
143
- documentURI = "https://localhost";
144
- origin = "https://localhost";
145
- characterSet = "UTF-8";
146
- contentType = "text/html";
147
- compatMode = "CSS1Compat";
148
158
  querySelector() {
149
159
  return null;
150
160
  }
@@ -159,82 +169,84 @@ var SimpleDocument = class {
159
169
  }
160
170
  };
161
171
  var WindowPluginImpl = class {
162
- name = "window";
163
- version = "1.0.0";
164
- // 定时器相关
165
- setTimeout = Object.assign(
166
- function(handler, timeout, ...args) {
167
- if (typeof globalThis !== "undefined" && globalThis.setTimeout) {
168
- return globalThis.setTimeout(handler, timeout, ...args);
172
+ constructor() {
173
+ this.name = "window";
174
+ this.version = "1.0.0";
175
+ // 定时器相关
176
+ this.setTimeout = Object.assign(
177
+ function(handler, timeout, ...args) {
178
+ if (typeof globalThis !== "undefined" && globalThis.setTimeout) {
179
+ return globalThis.setTimeout(handler, timeout, ...args);
180
+ }
181
+ const timeoutId = Date.now();
182
+ Promise.resolve().then(() => {
183
+ setTimeout(() => {
184
+ if (typeof handler === "function") {
185
+ handler(...args);
186
+ } else {
187
+ eval(handler);
188
+ }
189
+ }, timeout || 0);
190
+ });
191
+ return timeoutId;
192
+ },
193
+ {
194
+ __promisify__: function(delay, value) {
195
+ return new Promise((resolve) => setTimeout(resolve, delay, value));
196
+ }
169
197
  }
170
- const timeoutId = Date.now();
171
- Promise.resolve().then(() => {
172
- setTimeout(() => {
173
- if (typeof handler === "function") {
174
- handler(...args);
175
- } else {
176
- eval(handler);
177
- }
178
- }, timeout || 0);
179
- });
180
- return timeoutId;
181
- },
182
- {
183
- __promisify__: function(delay, value) {
184
- return new Promise((resolve) => setTimeout(resolve, delay, value));
198
+ );
199
+ this.clearTimeout = function(timeout2) {
200
+ if (typeof globalThis !== "undefined" && globalThis.clearTimeout) {
201
+ globalThis.clearTimeout(timeout2);
185
202
  }
186
- }
187
- );
188
- clearTimeout = function(timeout2) {
189
- if (typeof globalThis !== "undefined" && globalThis.clearTimeout) {
190
- globalThis.clearTimeout(timeout2);
191
- }
192
- };
193
- setInterval = Object.assign(
194
- function(handler, timeout, ...args) {
195
- if (typeof globalThis !== "undefined" && globalThis.setInterval) {
196
- return globalThis.setInterval(handler, timeout, ...args);
203
+ };
204
+ this.setInterval = Object.assign(
205
+ function(handler, timeout, ...args) {
206
+ if (typeof globalThis !== "undefined" && globalThis.setInterval) {
207
+ return globalThis.setInterval(handler, timeout, ...args);
208
+ }
209
+ const intervalId = Date.now();
210
+ const recursiveTimeout = () => {
211
+ this.setTimeout(() => {
212
+ if (typeof handler === "function") {
213
+ handler(...args);
214
+ } else {
215
+ eval(handler);
216
+ }
217
+ recursiveTimeout();
218
+ }, timeout || 0);
219
+ };
220
+ recursiveTimeout();
221
+ return intervalId;
222
+ },
223
+ {
224
+ __promisify__: function(delay, value) {
225
+ return new Promise((resolve) => setInterval(resolve, delay, value));
226
+ }
197
227
  }
198
- const intervalId = Date.now();
199
- const recursiveTimeout = () => {
200
- this.setTimeout(() => {
201
- if (typeof handler === "function") {
202
- handler(...args);
203
- } else {
204
- eval(handler);
205
- }
206
- recursiveTimeout();
207
- }, timeout || 0);
208
- };
209
- recursiveTimeout();
210
- return intervalId;
211
- },
212
- {
213
- __promisify__: function(delay, value) {
214
- return new Promise((resolve) => setInterval(resolve, delay, value));
228
+ );
229
+ this.clearInterval = function(timeout2) {
230
+ if (typeof globalThis !== "undefined" && globalThis.clearInterval) {
231
+ globalThis.clearInterval(timeout2);
215
232
  }
216
- }
217
- );
218
- clearInterval = function(timeout2) {
219
- if (typeof globalThis !== "undefined" && globalThis.clearInterval) {
220
- globalThis.clearInterval(timeout2);
221
- }
222
- };
223
- // 存储相关
224
- localStorage = new SimpleStorage();
225
- sessionStorage = new SimpleStorage();
226
- // 浏览器环境对象
227
- location = new SimpleLocation();
228
- navigator = new SimpleNavigator();
229
- document = new SimpleDocument();
230
- history = new SimpleHistory();
233
+ };
234
+ // 存储相关
235
+ this.localStorage = new SimpleStorage();
236
+ this.sessionStorage = new SimpleStorage();
237
+ // 浏览器环境对象
238
+ this.location = new SimpleLocation();
239
+ this.navigator = new SimpleNavigator();
240
+ this.document = new SimpleDocument();
241
+ this.history = new SimpleHistory();
242
+ }
231
243
  // 初始化方法
232
244
  initialize() {
233
- console.log("[WindowPlugin] \u521D\u59CB\u5316\u5B8C\u6210");
245
+ console.log("[WindowPlugin] 初始化完成");
234
246
  }
235
247
  // 销毁方法
236
248
  destroy() {
237
- console.log("[WindowPlugin] \u5DF2\u9500\u6BC1");
249
+ console.log("[WindowPlugin] 已销毁");
238
250
  }
239
251
  };
240
252
  var window_default = new WindowPluginImpl();
@@ -308,7 +308,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
308
308
  date: string;
309
309
  status: string;
310
310
  week: string;
311
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
311
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
312
312
  }[]>;
313
313
  submitTimeSlot(timeSlots: TimeSliceItem): void;
314
314
  private getScheduleDataByIds;
@@ -353,7 +353,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
353
353
  };
354
354
  setOtherData(key: string, value: any): void;
355
355
  getOtherData(key: string): any;
356
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
356
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
357
357
  /**
358
358
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
359
359
  *