@pisell/pisellos 0.0.6 → 0.0.7
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/core/index.d.ts +1 -0
- package/dist/core/index.js +7 -1
- package/dist/effects/index.d.ts +1 -1
- package/dist/effects/index.js +4 -5
- package/dist/modules/Account/index.d.ts +7 -1
- package/dist/modules/Account/index.js +67 -17
- package/dist/modules/Account/types.d.ts +2 -1
- package/dist/modules/AccountList/index.d.ts +18 -0
- package/dist/modules/AccountList/index.js +264 -0
- package/dist/modules/AccountList/types.d.ts +37 -0
- package/dist/modules/AccountList/types.js +17 -0
- package/dist/modules/BaseModule.js +1 -0
- package/dist/modules/Cart/index.d.ts +3 -1
- package/dist/modules/Cart/index.js +53 -12
- package/dist/modules/Cart/types.d.ts +3 -3
- package/dist/modules/Date/types.d.ts +2 -1
- package/dist/modules/Date/types.js +1 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +20 -12
- package/dist/modules/Resource/index.d.ts +7 -5
- package/dist/modules/Resource/index.js +17 -20
- package/dist/modules/Resource/utils.d.ts +23 -0
- package/dist/modules/Resource/utils.js +28 -0
- package/dist/modules/Step/index.d.ts +19 -0
- package/dist/modules/Step/index.js +107 -0
- package/dist/modules/Step/tyeps.d.ts +18 -0
- package/dist/modules/Step/tyeps.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +29 -1
- package/dist/solution/BookingByStep/index.js +363 -12
- package/dist/solution/BookingByStep/types.d.ts +6 -2
- package/dist/solution/BookingByStep/types.js +29 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +61 -0
- package/dist/solution/BookingByStep/utils/resources.js +380 -0
- package/dist/store/createStore.js +1 -1
- package/dist/types/index.d.ts +2 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js +5 -1
- package/lib/effects/index.d.ts +1 -1
- package/lib/effects/index.js +1 -2
- package/lib/modules/Account/index.d.ts +7 -1
- package/lib/modules/Account/index.js +34 -18
- package/lib/modules/Account/types.d.ts +2 -1
- package/lib/modules/AccountList/index.d.ts +18 -0
- package/lib/modules/AccountList/index.js +126 -0
- package/lib/modules/AccountList/types.d.ts +37 -0
- package/lib/modules/AccountList/types.js +33 -0
- package/lib/modules/BaseModule.js +1 -0
- package/lib/modules/Cart/index.d.ts +3 -1
- package/lib/modules/Cart/index.js +13 -3
- package/lib/modules/Cart/types.d.ts +3 -3
- package/lib/modules/Date/types.d.ts +2 -1
- package/lib/modules/Date/types.js +1 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +8 -7
- package/lib/modules/Resource/index.d.ts +7 -5
- package/lib/modules/Resource/index.js +16 -20
- package/lib/modules/Resource/utils.d.ts +23 -0
- package/lib/modules/Resource/utils.js +39 -0
- package/lib/modules/Step/index.d.ts +19 -0
- package/lib/modules/Step/index.js +76 -0
- package/lib/modules/Step/tyeps.d.ts +18 -0
- package/lib/modules/Step/tyeps.js +17 -0
- package/lib/solution/BookingByStep/index.d.ts +29 -1
- package/lib/solution/BookingByStep/index.js +99 -5
- package/lib/solution/BookingByStep/types.d.ts +6 -2
- package/lib/solution/BookingByStep/types.js +33 -2
- package/lib/solution/BookingByStep/utils/resources.d.ts +61 -0
- package/lib/solution/BookingByStep/utils/resources.js +215 -0
- package/lib/store/createStore.js +1 -1
- package/lib/types/index.d.ts +2 -1
- package/package.json +9 -8
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { AccountModule, Account } from '../Account';
|
|
3
|
+
import { BaseModule } from '../BaseModule';
|
|
4
|
+
import { AccountListState } from './types';
|
|
5
|
+
export declare class AccountListModule extends BaseModule implements Module {
|
|
6
|
+
protected defaultName: string;
|
|
7
|
+
protected defaultVersion: string;
|
|
8
|
+
private store;
|
|
9
|
+
constructor(name?: string, version?: string);
|
|
10
|
+
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
11
|
+
addAccount(account: Account): Promise<void>;
|
|
12
|
+
updateAccount(id: string, updates: Partial<Account>): Promise<void>;
|
|
13
|
+
removeAccount(id: string): Promise<void>;
|
|
14
|
+
getAccounts(): AccountModule[];
|
|
15
|
+
getAccount(id: string): AccountModule | null;
|
|
16
|
+
clearAccounts(): Promise<void>;
|
|
17
|
+
getState(): AccountListState;
|
|
18
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/AccountList/index.ts
|
|
20
|
+
var AccountList_exports = {};
|
|
21
|
+
__export(AccountList_exports, {
|
|
22
|
+
AccountListModule: () => AccountListModule
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(AccountList_exports);
|
|
25
|
+
var import_Account = require("../Account");
|
|
26
|
+
var import_BaseModule = require("../BaseModule");
|
|
27
|
+
var import_types = require("./types");
|
|
28
|
+
var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
29
|
+
constructor(name, version) {
|
|
30
|
+
super(name, version);
|
|
31
|
+
this.defaultName = "accountList";
|
|
32
|
+
this.defaultVersion = "1.0.0";
|
|
33
|
+
this.store = {
|
|
34
|
+
accounts: [],
|
|
35
|
+
isLoading: false,
|
|
36
|
+
error: null
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async initialize(core, options) {
|
|
40
|
+
this.core = core;
|
|
41
|
+
this.store = options == null ? void 0 : options.store;
|
|
42
|
+
this.store.accounts = [];
|
|
43
|
+
}
|
|
44
|
+
async addAccount(account) {
|
|
45
|
+
try {
|
|
46
|
+
this.store.isLoading = true;
|
|
47
|
+
this.store.error = null;
|
|
48
|
+
if (this.store.accounts.some((a) => a.getId() === account.id)) {
|
|
49
|
+
throw new Error(`Account with id ${account.id} already exists`);
|
|
50
|
+
}
|
|
51
|
+
const accountModule = new import_Account.AccountModule(`account_${account.id}`);
|
|
52
|
+
this.core.registerModule(accountModule);
|
|
53
|
+
this.store.accounts = [...this.store.accounts, accountModule];
|
|
54
|
+
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
this.store.error = error instanceof Error ? error.message : "Failed to add account";
|
|
57
|
+
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListError, this.store.error);
|
|
58
|
+
} finally {
|
|
59
|
+
this.store.isLoading = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async updateAccount(id, updates) {
|
|
63
|
+
try {
|
|
64
|
+
this.store.isLoading = true;
|
|
65
|
+
this.store.error = null;
|
|
66
|
+
const account = this.getAccount(id);
|
|
67
|
+
if (!account) {
|
|
68
|
+
throw new Error(`Account with id ${id} not found`);
|
|
69
|
+
}
|
|
70
|
+
Object.assign(account, updates);
|
|
71
|
+
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
this.store.error = error instanceof Error ? error.message : "Failed to update account";
|
|
74
|
+
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListError, this.store.error);
|
|
75
|
+
} finally {
|
|
76
|
+
this.store.isLoading = false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async removeAccount(id) {
|
|
80
|
+
try {
|
|
81
|
+
this.store.isLoading = true;
|
|
82
|
+
this.store.error = null;
|
|
83
|
+
const index = this.store.accounts.findIndex((a) => a.getId() === id);
|
|
84
|
+
if (index === -1) {
|
|
85
|
+
throw new Error(`Account with id ${id} not found`);
|
|
86
|
+
}
|
|
87
|
+
this.store.accounts[index].destory();
|
|
88
|
+
this.store.accounts = [
|
|
89
|
+
...this.store.accounts.slice(0, index),
|
|
90
|
+
...this.store.accounts.slice(index + 1)
|
|
91
|
+
];
|
|
92
|
+
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
this.store.error = error instanceof Error ? error.message : "Failed to remove account";
|
|
95
|
+
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListError, this.store.error);
|
|
96
|
+
} finally {
|
|
97
|
+
this.store.isLoading = false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
getAccounts() {
|
|
101
|
+
return [...this.store.accounts];
|
|
102
|
+
}
|
|
103
|
+
getAccount(id) {
|
|
104
|
+
return this.store.accounts.find((account) => account.getId() === id) || null;
|
|
105
|
+
}
|
|
106
|
+
async clearAccounts() {
|
|
107
|
+
try {
|
|
108
|
+
this.store.isLoading = true;
|
|
109
|
+
this.store.error = null;
|
|
110
|
+
this.store.accounts = [];
|
|
111
|
+
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
this.store.error = error instanceof Error ? error.message : "Failed to clear accounts";
|
|
114
|
+
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListError, this.store.error);
|
|
115
|
+
} finally {
|
|
116
|
+
this.store.isLoading = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
getState() {
|
|
120
|
+
return { ...this.store };
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
AccountListModule
|
|
126
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Account, AccountModule } from "../Account";
|
|
2
|
+
export declare enum AccountListHooks {
|
|
3
|
+
OnAccountListUpdate = "accountList:onUpdate",
|
|
4
|
+
OnAccountListError = "accountList:onError"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 账户列表查询参数
|
|
8
|
+
*/
|
|
9
|
+
export interface AccountListQuery {
|
|
10
|
+
page?: number;
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
search?: string;
|
|
13
|
+
sortBy?: string;
|
|
14
|
+
sortOrder?: 'asc' | 'desc';
|
|
15
|
+
filters?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 账户列表状态
|
|
19
|
+
*/
|
|
20
|
+
export interface AccountListState {
|
|
21
|
+
accounts: AccountModule[];
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
error: string | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 账户列表模块 API
|
|
27
|
+
*/
|
|
28
|
+
export interface AccountListModuleAPI {
|
|
29
|
+
addAccount: (account: Account) => Promise<void>;
|
|
30
|
+
updateAccount: (id: string, updates: Partial<AccountModule>) => Promise<void>;
|
|
31
|
+
removeAccount: (id: string) => Promise<void>;
|
|
32
|
+
getAccounts: () => AccountModule[];
|
|
33
|
+
getAccount: (id: string) => AccountModule | null;
|
|
34
|
+
clearAccounts: () => Promise<void>;
|
|
35
|
+
addAccounts: (accounts: AccountModule[]) => Promise<void>;
|
|
36
|
+
getState: () => AccountListState;
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/AccountList/types.ts
|
|
20
|
+
var types_exports = {};
|
|
21
|
+
__export(types_exports, {
|
|
22
|
+
AccountListHooks: () => AccountListHooks
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
|
25
|
+
var AccountListHooks = /* @__PURE__ */ ((AccountListHooks2) => {
|
|
26
|
+
AccountListHooks2["OnAccountListUpdate"] = "accountList:onUpdate";
|
|
27
|
+
AccountListHooks2["OnAccountListError"] = "accountList:onError";
|
|
28
|
+
return AccountListHooks2;
|
|
29
|
+
})(AccountListHooks || {});
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
AccountListHooks
|
|
33
|
+
});
|
|
@@ -28,6 +28,8 @@ export declare class CartModule extends BaseModule implements Module {
|
|
|
28
28
|
getItemCount(): number;
|
|
29
29
|
getTotalPrice(): number;
|
|
30
30
|
getItems(): Promise<CartItem[]>;
|
|
31
|
-
|
|
31
|
+
updateItem(id: string, item: CartItem): Promise<void>;
|
|
32
32
|
removeItem(id: string): Promise<void>;
|
|
33
|
+
storeTemp(key: string, value: any): Promise<void>;
|
|
34
|
+
getTemp(key?: string): Promise<any>;
|
|
33
35
|
}
|
|
@@ -38,7 +38,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
38
38
|
getItemCount: this.getItemCount.bind(this),
|
|
39
39
|
getTotalPrice: this.getTotalPrice.bind(this),
|
|
40
40
|
getItems: this.getItems.bind(this),
|
|
41
|
-
|
|
41
|
+
updateItem: this.updateItem.bind(this),
|
|
42
42
|
removeItem: this.removeItem.bind(this)
|
|
43
43
|
};
|
|
44
44
|
}
|
|
@@ -56,6 +56,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
56
56
|
if (!this.window) {
|
|
57
57
|
throw new Error("购物车模块需要 window 插件支持");
|
|
58
58
|
}
|
|
59
|
+
this.store.temp = {};
|
|
59
60
|
console.log("[CartModule] 初始化完成");
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
@@ -82,11 +83,11 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
82
83
|
async getItems() {
|
|
83
84
|
return this.store.list;
|
|
84
85
|
}
|
|
85
|
-
async
|
|
86
|
+
async updateItem(id, item) {
|
|
86
87
|
const items = this.store.list;
|
|
87
88
|
const itemIndex = items.findIndex((i) => i.id === id);
|
|
88
89
|
if (itemIndex !== -1) {
|
|
89
|
-
items[itemIndex] =
|
|
90
|
+
items[itemIndex] = item;
|
|
90
91
|
this.store.list = items;
|
|
91
92
|
await this.core.effects.emit(import_types.CartHooks.OnCartUpdateItem, items);
|
|
92
93
|
}
|
|
@@ -96,6 +97,15 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
96
97
|
this.store.list = items;
|
|
97
98
|
await this.core.effects.emit(import_types.CartHooks.OnCartRemove, items);
|
|
98
99
|
}
|
|
100
|
+
async storeTemp(key, value) {
|
|
101
|
+
this.store.temp[key] = value;
|
|
102
|
+
}
|
|
103
|
+
async getTemp(key) {
|
|
104
|
+
if (!key) {
|
|
105
|
+
return this.store.temp;
|
|
106
|
+
}
|
|
107
|
+
return this.store.temp[key];
|
|
108
|
+
}
|
|
99
109
|
};
|
|
100
110
|
// Annotate the CommonJS export names for ESM import in node:
|
|
101
111
|
0 && (module.exports = {
|
|
@@ -10,7 +10,6 @@ export declare enum CartHooks {
|
|
|
10
10
|
*/
|
|
11
11
|
export interface CartItem {
|
|
12
12
|
id: string;
|
|
13
|
-
name: string;
|
|
14
13
|
price: number;
|
|
15
14
|
quantity: number;
|
|
16
15
|
product: ProductData;
|
|
@@ -19,8 +18,9 @@ export interface CartItem {
|
|
|
19
18
|
* 购物车状态接口
|
|
20
19
|
*/
|
|
21
20
|
export interface CartState {
|
|
22
|
-
list:
|
|
21
|
+
list: any[];
|
|
23
22
|
total: number;
|
|
23
|
+
temp: Record<string, any>;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* 购物车模块 API
|
|
@@ -30,6 +30,6 @@ export interface CartModuleAPI {
|
|
|
30
30
|
getItemCount: () => number;
|
|
31
31
|
getTotalPrice: () => number;
|
|
32
32
|
getItems: () => Promise<CartItem[]>;
|
|
33
|
-
|
|
33
|
+
updateItem: (id: string, item: CartItem) => Promise<void>;
|
|
34
34
|
removeItem: (id: string) => Promise<void>;
|
|
35
35
|
}
|
|
@@ -25,6 +25,7 @@ module.exports = __toCommonJS(types_exports);
|
|
|
25
25
|
var DateHooks = /* @__PURE__ */ ((DateHooks2) => {
|
|
26
26
|
DateHooks2["OnDateChange"] = "date:onDateChange";
|
|
27
27
|
DateHooks2["OnTimeSlotChange"] = "date:onTimeSlotChange";
|
|
28
|
+
DateHooks2["OnGetDateList"] = "date:onGetDateList";
|
|
28
29
|
return DateHooks2;
|
|
29
30
|
})(DateHooks || {});
|
|
30
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -12,5 +12,5 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
12
12
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
13
13
|
getProducts(): Promise<ProductData[]>;
|
|
14
14
|
getProduct(id: number): Promise<Product | undefined>;
|
|
15
|
-
addProduct(): Promise<void>;
|
|
15
|
+
addProduct(products: ProductData[]): Promise<void>;
|
|
16
16
|
}
|
|
@@ -35,16 +35,16 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
35
35
|
}
|
|
36
36
|
async initialize(core, options) {
|
|
37
37
|
this.core = core;
|
|
38
|
-
this.store =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
38
|
+
this.store = options.store;
|
|
39
|
+
this.store.productMap = /* @__PURE__ */ new Map();
|
|
40
|
+
this.store.list = [];
|
|
42
41
|
this.storeChange();
|
|
43
42
|
}
|
|
44
43
|
async storeChange(path, value) {
|
|
45
|
-
|
|
44
|
+
var _a;
|
|
45
|
+
(_a = this.store.list) == null ? void 0 : _a.forEach((product) => {
|
|
46
46
|
if (!this.store.productMap.has(`product-${product.id}`)) {
|
|
47
|
-
const newProductModule = new import_Product.Product(`
|
|
47
|
+
const newProductModule = new import_Product.Product(`product_${product.id.toString()}`);
|
|
48
48
|
this.core.registerModule(newProductModule, { initialState: product });
|
|
49
49
|
this.store.productMap.set(product.id.toString(), newProductModule);
|
|
50
50
|
}
|
|
@@ -61,7 +61,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
61
61
|
return product;
|
|
62
62
|
return void 0;
|
|
63
63
|
}
|
|
64
|
-
async addProduct() {
|
|
64
|
+
async addProduct(products) {
|
|
65
|
+
this.store.list = [...this.store.list, ...products];
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Resource, ResourceTimeSlot
|
|
4
|
-
export declare class ResourceListModule extends BaseModule implements Module
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { Resource, ResourceTimeSlot } from './types';
|
|
4
|
+
export declare class ResourceListModule extends BaseModule implements Module {
|
|
5
|
+
protected defaultName: string;
|
|
6
|
+
protected defaultVersion: string;
|
|
7
|
+
private store;
|
|
8
|
+
constructor(name: string, version: string);
|
|
9
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
8
10
|
getResources(): Promise<Resource[]>;
|
|
9
11
|
selectResource(resourceId: string): Promise<void>;
|
|
10
12
|
getSelectedResource(): Resource | null;
|
|
@@ -25,34 +25,30 @@ module.exports = __toCommonJS(Resource_exports);
|
|
|
25
25
|
var import_BaseModule = require("../BaseModule");
|
|
26
26
|
var import_types = require("./types");
|
|
27
27
|
var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
28
|
-
constructor() {
|
|
29
|
-
super(
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
selectedResource: null
|
|
33
|
-
};
|
|
28
|
+
constructor(name, version) {
|
|
29
|
+
super(name, version);
|
|
30
|
+
this.defaultName = "resourceList";
|
|
31
|
+
this.defaultVersion = "1.0.0";
|
|
34
32
|
}
|
|
35
33
|
async initialize(core, options) {
|
|
36
34
|
this.core = core;
|
|
37
|
-
|
|
38
|
-
this.state = { ...this.state, ...options.initialState };
|
|
39
|
-
}
|
|
35
|
+
this.store = options.store;
|
|
40
36
|
}
|
|
41
37
|
async getResources() {
|
|
42
|
-
return this.
|
|
38
|
+
return this.store.list;
|
|
43
39
|
}
|
|
44
40
|
async selectResource(resourceId) {
|
|
45
|
-
const resource = this.
|
|
41
|
+
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
46
42
|
if (!resource)
|
|
47
43
|
return;
|
|
48
|
-
this.
|
|
44
|
+
this.store.selectedResource = resource;
|
|
49
45
|
await this.core.effects.emit(import_types.ResourceHooks.OnResourceSelect, resource);
|
|
50
46
|
}
|
|
51
47
|
getSelectedResource() {
|
|
52
|
-
return this.
|
|
48
|
+
return this.store.selectedResource;
|
|
53
49
|
}
|
|
54
50
|
async checkAvailability(resourceId, start, end) {
|
|
55
|
-
const resource = this.
|
|
51
|
+
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
56
52
|
if (!resource)
|
|
57
53
|
return false;
|
|
58
54
|
return resource.timeSlots.some(
|
|
@@ -60,13 +56,13 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
60
56
|
);
|
|
61
57
|
}
|
|
62
58
|
async getAvailableTimeSlots(resourceId) {
|
|
63
|
-
const resource = this.
|
|
59
|
+
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
64
60
|
if (!resource)
|
|
65
61
|
return [];
|
|
66
62
|
return resource.timeSlots.filter((slot) => slot.availableCapacity > 0);
|
|
67
63
|
}
|
|
68
64
|
getAvailableCapacity(resourceId, timeSlot) {
|
|
69
|
-
const resource = this.
|
|
65
|
+
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
70
66
|
if (!resource)
|
|
71
67
|
return 0;
|
|
72
68
|
const slot = resource.timeSlots.find(
|
|
@@ -75,14 +71,14 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
75
71
|
return (slot == null ? void 0 : slot.availableCapacity) || 0;
|
|
76
72
|
}
|
|
77
73
|
async updateResource(resourceId, updates) {
|
|
78
|
-
const index = this.
|
|
74
|
+
const index = this.store.list.findIndex((r) => r.id === resourceId);
|
|
79
75
|
if (index === -1)
|
|
80
76
|
return;
|
|
81
|
-
this.
|
|
82
|
-
...this.
|
|
77
|
+
this.store.list[index] = {
|
|
78
|
+
...this.store.list[index],
|
|
83
79
|
...updates
|
|
84
80
|
};
|
|
85
|
-
await this.core.effects.emit(import_types.ResourceHooks.OnResourceChange, this.
|
|
81
|
+
await this.core.effects.emit(import_types.ResourceHooks.OnResourceChange, this.store.list[index]);
|
|
86
82
|
}
|
|
87
83
|
};
|
|
88
84
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface Resource {
|
|
2
|
+
id: string;
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @title: 获取资源map
|
|
7
|
+
* @description:
|
|
8
|
+
* @param {any} resourceList
|
|
9
|
+
* @return {*}
|
|
10
|
+
* @Author: zhiwei.Wang
|
|
11
|
+
*/
|
|
12
|
+
export declare const getResourcesMap: (resourceList: Resource[]) => Record<string, Resource>;
|
|
13
|
+
/**
|
|
14
|
+
* @title: 根据ids筛选资源列表
|
|
15
|
+
* @description:
|
|
16
|
+
* @param {any} resourcesMap
|
|
17
|
+
* @param {any} ids
|
|
18
|
+
* @return {*}
|
|
19
|
+
* @Author: zhiwei.Wang
|
|
20
|
+
* @Date: 2024-09-19 20:23
|
|
21
|
+
*/
|
|
22
|
+
export declare const getResourcesByIds: (resourcesMap: Record<string, Resource>, ids: number[]) => Resource[];
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Resource/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
getResourcesByIds: () => getResourcesByIds,
|
|
23
|
+
getResourcesMap: () => getResourcesMap
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
var getResourcesMap = (resourceList) => {
|
|
27
|
+
return resourceList.reduce((pre, item) => {
|
|
28
|
+
pre[item.id] = item;
|
|
29
|
+
return pre;
|
|
30
|
+
}, {});
|
|
31
|
+
};
|
|
32
|
+
var getResourcesByIds = (resourcesMap, ids) => {
|
|
33
|
+
return (ids || []).map((id) => resourcesMap[id]);
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
getResourcesByIds,
|
|
38
|
+
getResourcesMap
|
|
39
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from "../../types";
|
|
2
|
+
import { BaseModule } from "../BaseModule";
|
|
3
|
+
import { IStep, IStepModuleAPI } from "./tyeps";
|
|
4
|
+
export declare class StepModule extends BaseModule implements Module, IStepModuleAPI {
|
|
5
|
+
protected defaultName: string;
|
|
6
|
+
protected defaultVersion: string;
|
|
7
|
+
private store;
|
|
8
|
+
constructor(name?: string, version?: string);
|
|
9
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
10
|
+
init(steps: IStep[]): void;
|
|
11
|
+
private setSteps;
|
|
12
|
+
private setCurrentStep;
|
|
13
|
+
getStepList(): IStep[];
|
|
14
|
+
getCurrentStep(): IStep;
|
|
15
|
+
getCurrentStepIndex(): number;
|
|
16
|
+
prevStep(): void;
|
|
17
|
+
nextStep(): void;
|
|
18
|
+
gotoStep(stepIndex: number): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Step/index.ts
|
|
20
|
+
var Step_exports = {};
|
|
21
|
+
__export(Step_exports, {
|
|
22
|
+
StepModule: () => StepModule
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Step_exports);
|
|
25
|
+
var import_BaseModule = require("../BaseModule");
|
|
26
|
+
var StepModule = class extends import_BaseModule.BaseModule {
|
|
27
|
+
constructor(name, version) {
|
|
28
|
+
super(name, version);
|
|
29
|
+
this.defaultName = "step";
|
|
30
|
+
this.defaultVersion = "1.0.0";
|
|
31
|
+
}
|
|
32
|
+
async initialize(core, options) {
|
|
33
|
+
this.core = core;
|
|
34
|
+
this.store = options.store;
|
|
35
|
+
}
|
|
36
|
+
init(steps) {
|
|
37
|
+
this.setSteps(steps);
|
|
38
|
+
this.setCurrentStep(0);
|
|
39
|
+
}
|
|
40
|
+
setSteps(stepList) {
|
|
41
|
+
this.store.stepList = stepList;
|
|
42
|
+
}
|
|
43
|
+
setCurrentStep(stepIndex) {
|
|
44
|
+
if (stepIndex < 0 || stepIndex >= this.store.stepList.length) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.store.currentStepIndex = stepIndex;
|
|
48
|
+
this.store.currentStep = this.store.stepList[stepIndex];
|
|
49
|
+
}
|
|
50
|
+
getStepList() {
|
|
51
|
+
return this.store.stepList;
|
|
52
|
+
}
|
|
53
|
+
getCurrentStep() {
|
|
54
|
+
return this.store.currentStep;
|
|
55
|
+
}
|
|
56
|
+
getCurrentStepIndex() {
|
|
57
|
+
return this.store.currentStepIndex;
|
|
58
|
+
}
|
|
59
|
+
prevStep() {
|
|
60
|
+
if (this.store.currentStepIndex > 0) {
|
|
61
|
+
this.setCurrentStep(this.store.currentStepIndex - 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
nextStep() {
|
|
65
|
+
if (this.store.currentStepIndex < this.store.stepList.length - 1) {
|
|
66
|
+
this.setCurrentStep(this.store.currentStepIndex + 1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
gotoStep(stepIndex) {
|
|
70
|
+
this.setCurrentStep(stepIndex);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
StepModule
|
|
76
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface IStepState {
|
|
2
|
+
stepList: IStep[];
|
|
3
|
+
currentStep: IStep;
|
|
4
|
+
currentStepIndex: number;
|
|
5
|
+
}
|
|
6
|
+
export interface IStep {
|
|
7
|
+
index: number;
|
|
8
|
+
key: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface IStepModuleAPI {
|
|
12
|
+
getStepList: () => IStep[];
|
|
13
|
+
getCurrentStep: () => IStep;
|
|
14
|
+
getCurrentStepIndex: () => number;
|
|
15
|
+
nextStep: () => void;
|
|
16
|
+
prevStep: () => void;
|
|
17
|
+
gotoStep: (stepIndex: number) => void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/modules/Step/tyeps.ts
|
|
16
|
+
var tyeps_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(tyeps_exports);
|