@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.
- package/dist/effects/index.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -2
- package/dist/model/strategy/type.d.ts +1 -1
- package/dist/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Payment/index.js +35 -7
- package/dist/modules/Payment/types.d.ts +9 -7
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/Checkout/index.js +31 -2
- package/dist/solution/Checkout/types.d.ts +2 -0
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/utils.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.d.ts +2 -2
- package/dist/utils/watch.d.ts +2 -2
- package/lib/core/index.js +28 -27
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +7 -3
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -3
- package/lib/model/strategy/adapter/walletPass/example.js +21 -21
- package/lib/model/strategy/adapter/walletPass/index.js +4 -2
- package/lib/model/strategy/adapter/walletPass/locales.js +10 -10
- package/lib/model/strategy/adapter/walletPass/utils.js +9 -4
- package/lib/model/strategy/index.js +10 -7
- package/lib/model/strategy/strategy-example.js +19 -19
- package/lib/model/strategy/type.d.ts +1 -1
- package/lib/modules/Account/index.js +10 -9
- package/lib/modules/AccountList/index.js +11 -14
- package/lib/modules/BaseModule.js +3 -6
- package/lib/modules/Cart/index.js +9 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +15 -18
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +6 -10
- package/lib/modules/Date/types.js +0 -1
- package/lib/modules/Discount/index.js +6 -11
- package/lib/modules/Guests/index.js +15 -10
- package/lib/modules/Order/index.js +9 -11
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +94 -86
- package/lib/modules/Payment/types.d.ts +9 -7
- package/lib/modules/Payment/utils.js +6 -3
- package/lib/modules/Payment/walletpass.js +33 -33
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +5 -6
- package/lib/modules/ProductList/index.js +3 -5
- package/lib/modules/Resource/index.js +12 -8
- package/lib/modules/Rules/index.js +21 -16
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +5 -8
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +4 -2
- package/lib/modules/Step/index.js +4 -7
- package/lib/modules/Summary/index.js +4 -9
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +129 -86
- package/lib/solution/BookingByStep/utils/capacity.js +15 -10
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/utils/stock.js +6 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
- package/lib/solution/BookingTicket/index.js +14 -19
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/Checkout/index.js +233 -217
- package/lib/solution/Checkout/types.d.ts +2 -0
- package/lib/solution/Checkout/utils/index.js +22 -18
- package/lib/solution/RegisterAndLogin/config.js +2 -2
- package/lib/solution/RegisterAndLogin/index.js +110 -114
- package/lib/solution/RegisterAndLogin/utils.js +9 -9
- package/lib/solution/ShopDiscount/index.js +13 -16
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +7 -5
- package/package.json +18 -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("
|
|
59
|
+
errors.push("密码长度至少为8位");
|
|
60
60
|
}
|
|
61
61
|
if (password.length > 128) {
|
|
62
|
-
errors.push("
|
|
62
|
+
errors.push("密码长度不能超过128位");
|
|
63
63
|
}
|
|
64
64
|
if (!/[a-z]/.test(password)) {
|
|
65
|
-
errors.push("
|
|
65
|
+
errors.push("密码必须包含至少一个小写字母");
|
|
66
66
|
}
|
|
67
67
|
if (!/[A-Z]/.test(password)) {
|
|
68
|
-
errors.push("
|
|
68
|
+
errors.push("密码必须包含至少一个大写字母");
|
|
69
69
|
}
|
|
70
70
|
if (!/\d/.test(password)) {
|
|
71
|
-
errors.push("
|
|
71
|
+
errors.push("密码必须包含至少一个数字");
|
|
72
72
|
}
|
|
73
73
|
if (!/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(password)) {
|
|
74
|
-
errors.push("
|
|
74
|
+
errors.push("密码必须包含至少一个特殊字符");
|
|
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]: "微信",
|
|
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
|
|
227
|
+
console.warn("JSON 解析失败:", 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
|
|
235
|
+
console.warn("JSON 字符串化失败:", error);
|
|
236
236
|
return defaultValue;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
@@ -40,16 +40,12 @@ var import_utils = require("./utils");
|
|
|
40
40
|
var import_decimal = __toESM(require("decimal.js"));
|
|
41
41
|
var import_lodash_es = require("lodash-es");
|
|
42
42
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
43
|
-
defaultName = "shopDiscount";
|
|
44
|
-
defaultVersion = "1.0.0";
|
|
45
|
-
isSolution = true;
|
|
46
|
-
request;
|
|
47
|
-
window;
|
|
48
|
-
store;
|
|
49
|
-
options = {};
|
|
50
|
-
hooks;
|
|
51
43
|
constructor(name, version) {
|
|
52
44
|
super(name, version);
|
|
45
|
+
this.defaultName = "shopDiscount";
|
|
46
|
+
this.defaultVersion = "1.0.0";
|
|
47
|
+
this.isSolution = true;
|
|
48
|
+
this.options = {};
|
|
53
49
|
this.store = {
|
|
54
50
|
customer: null,
|
|
55
51
|
productList: [],
|
|
@@ -69,7 +65,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
69
65
|
this.options = options;
|
|
70
66
|
this.store = { ...this.store, ...options.store || {} };
|
|
71
67
|
this.hooks = (_b = (_a = options.otherParams) == null ? void 0 : _a.rules) == null ? void 0 : _b.hooks;
|
|
72
|
-
console.log("[ShopDiscount]
|
|
68
|
+
console.log("[ShopDiscount] 初始化完成");
|
|
73
69
|
this.initializePlugins();
|
|
74
70
|
this.registerDependentModules();
|
|
75
71
|
this.registerEventListeners();
|
|
@@ -82,7 +78,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
82
78
|
(_b = this.store.rules) == null ? void 0 : _b.destroy();
|
|
83
79
|
this.core.effects.offByModuleDestroy(this.name);
|
|
84
80
|
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
85
|
-
console.log("[ShopDiscount]
|
|
81
|
+
console.log("[ShopDiscount] 已销毁");
|
|
86
82
|
}
|
|
87
83
|
async clear() {
|
|
88
84
|
var _a, _b;
|
|
@@ -97,10 +93,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
97
93
|
this.request = this.core.getPlugin("request");
|
|
98
94
|
this.window = this.core.getPlugin("window");
|
|
99
95
|
if (!this.request) {
|
|
100
|
-
throw new Error("ShopDiscount
|
|
96
|
+
throw new Error("ShopDiscount需要 request 插件支持");
|
|
101
97
|
}
|
|
102
98
|
if (!this.window) {
|
|
103
|
-
throw new Error("ShopDiscount
|
|
99
|
+
throw new Error("ShopDiscount需要 window 插件支持");
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
102
|
registerDependentModules() {
|
|
@@ -330,7 +326,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
330
326
|
discountList: newDiscountList || this.getDiscountList()
|
|
331
327
|
};
|
|
332
328
|
} catch (error) {
|
|
333
|
-
console.error("[ShopDiscount]
|
|
329
|
+
console.error("[ShopDiscount] 扫码出错:", error);
|
|
334
330
|
return {
|
|
335
331
|
type: "clientCalc",
|
|
336
332
|
isAvailable: false,
|
|
@@ -413,7 +409,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
413
409
|
const isProductFree = (id) => {
|
|
414
410
|
var _a2;
|
|
415
411
|
const targetProduct = productList.find((n) => n.id === id);
|
|
416
|
-
if (!targetProduct)
|
|
412
|
+
if (!targetProduct)
|
|
413
|
+
return false;
|
|
417
414
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
|
|
418
415
|
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);
|
|
419
416
|
};
|
|
@@ -462,7 +459,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
462
459
|
);
|
|
463
460
|
}
|
|
464
461
|
} catch (error) {
|
|
465
|
-
console.error("[ShopDiscount]
|
|
462
|
+
console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
|
|
466
463
|
}
|
|
467
464
|
}
|
|
468
465
|
async bestDiscount(cb) {
|
|
@@ -517,7 +514,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
517
514
|
filteredDiscountList
|
|
518
515
|
);
|
|
519
516
|
} catch (error) {
|
|
520
|
-
console.error("[ShopDiscount]
|
|
517
|
+
console.error("[ShopDiscount] 加载准备配置出错:", error);
|
|
521
518
|
}
|
|
522
519
|
}
|
|
523
520
|
};
|
|
@@ -11,7 +11,7 @@ export declare enum ShopDiscountHooks {
|
|
|
11
11
|
onRulesListChange = "shopDiscount:onRulesListChange",
|
|
12
12
|
onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type Customer = {
|
|
15
15
|
id: string | number;
|
|
16
16
|
name: string;
|
|
17
17
|
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[]) =>
|
|
15
|
+
export declare const getDiscountListAmountTotal: (discount: Discount[]) => any;
|
|
16
16
|
/**
|
|
17
17
|
* 获取折扣金额 计算每个折扣的金额
|
|
18
18
|
* @param discount
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
export declare const getDiscountListAmount: (discount: Discount[]) =>
|
|
21
|
+
export declare const getDiscountListAmount: (discount: Discount[]) => any;
|
|
22
22
|
export interface ScheduleItem {
|
|
23
23
|
id: number;
|
|
24
24
|
name: string | {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface ModuleOptions {
|
|
|
27
27
|
initialState?: Record<string, any>;
|
|
28
28
|
otherParams?: Record<string, any>;
|
|
29
29
|
}
|
|
30
|
-
export
|
|
30
|
+
export 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;
|
package/lib/utils/task.d.ts
CHANGED
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;
|
|
29
26
|
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
|
}
|
package/lib/utils/watch.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* 监听模块
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type WatchEventCallback = (...args: any[]) => void;
|
|
6
|
+
export type WatchEventItem = {
|
|
7
7
|
key: string;
|
|
8
8
|
callback: WatchEventCallback;
|
|
9
9
|
};
|
package/lib/utils/watch.js
CHANGED
|
@@ -23,10 +23,12 @@ __export(watch_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(watch_exports);
|
|
25
25
|
var Watch = class {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
constructor() {
|
|
27
|
+
// 监听列表
|
|
28
|
+
this.events = /* @__PURE__ */ new Map();
|
|
29
|
+
// 启用列表 - 使用数组保持顺序
|
|
30
|
+
this.enableListMap = /* @__PURE__ */ new Map();
|
|
31
|
+
}
|
|
30
32
|
/**
|
|
31
33
|
* 订阅事件
|
|
32
34
|
* @param event 事件名称
|
|
@@ -130,7 +132,7 @@ var Watch = class {
|
|
|
130
132
|
try {
|
|
131
133
|
(_a = callbacks.get(lastCallbackKey)) == null ? void 0 : _a(...args);
|
|
132
134
|
} catch (error) {
|
|
133
|
-
console.error(
|
|
135
|
+
console.error(`执行事件"${watchKey}"的回调时出错:`, error);
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.376",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,22 @@
|
|
|
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 --registry=https://registry.npmjs.com/ && 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
|
+
},
|
|
12
28
|
"repository": {
|
|
13
29
|
"type": "git",
|
|
14
30
|
"url": "git+https://github.com/username/pisell-os.git"
|
|
@@ -52,20 +68,5 @@
|
|
|
52
68
|
},
|
|
53
69
|
"publishConfig": {
|
|
54
70
|
"access": "public"
|
|
55
|
-
},
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "father build",
|
|
58
|
-
"dev": "father dev --watch",
|
|
59
|
-
"push": "yalc push --replace",
|
|
60
|
-
"test": "vitest",
|
|
61
|
-
"lint": "eslint src --ext .ts",
|
|
62
|
-
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
63
|
-
"changeset": "changeset",
|
|
64
|
-
"version": "changeset version",
|
|
65
|
-
"release": "changeset publish --registry=https://registry.npmjs.com/ && npm run sync && git push",
|
|
66
|
-
"example": "npx parcel-bundler examples/index.html",
|
|
67
|
-
"docs": "typedoc --out docs src/index.ts",
|
|
68
|
-
"sync": "node sync.js",
|
|
69
|
-
"deploy": "npm run build && npm run changeset && npm run version && npm run release"
|
|
70
71
|
}
|
|
71
|
-
}
|
|
72
|
+
}
|