@pisell/pisellos 0.0.5

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 (138) hide show
  1. package/README.md +180 -0
  2. package/dist/core/index.d.ts +30 -0
  3. package/dist/core/index.js +360 -0
  4. package/dist/effects/index.d.ts +17 -0
  5. package/dist/effects/index.js +162 -0
  6. package/dist/index.d.ts +11 -0
  7. package/dist/index.js +17 -0
  8. package/dist/modules/Account/index.d.ts +21 -0
  9. package/dist/modules/Account/index.js +212 -0
  10. package/dist/modules/Account/types.d.ts +41 -0
  11. package/dist/modules/Account/types.js +19 -0
  12. package/dist/modules/BaseModule.d.ts +11 -0
  13. package/dist/modules/BaseModule.js +27 -0
  14. package/dist/modules/Cart/index.d.ts +33 -0
  15. package/dist/modules/Cart/index.js +242 -0
  16. package/dist/modules/Cart/types.d.ts +35 -0
  17. package/dist/modules/Cart/types.js +19 -0
  18. package/dist/modules/Date/index.d.ts +17 -0
  19. package/dist/modules/Date/index.js +133 -0
  20. package/dist/modules/Date/types.d.ts +32 -0
  21. package/dist/modules/Date/types.js +17 -0
  22. package/dist/modules/Guests/index.d.ts +17 -0
  23. package/dist/modules/Guests/index.js +259 -0
  24. package/dist/modules/Guests/types.d.ts +43 -0
  25. package/dist/modules/Guests/types.js +23 -0
  26. package/dist/modules/Order/index.d.ts +17 -0
  27. package/dist/modules/Order/index.js +228 -0
  28. package/dist/modules/Order/types.d.ts +57 -0
  29. package/dist/modules/Order/types.js +29 -0
  30. package/dist/modules/Payment/index.d.ts +18 -0
  31. package/dist/modules/Payment/index.js +243 -0
  32. package/dist/modules/Payment/types.d.ts +49 -0
  33. package/dist/modules/Payment/types.js +31 -0
  34. package/dist/modules/Product/index.d.ts +39 -0
  35. package/dist/modules/Product/index.js +118 -0
  36. package/dist/modules/Product/types.d.ts +387 -0
  37. package/dist/modules/Product/types.js +1 -0
  38. package/dist/modules/ProductList/index.d.ts +16 -0
  39. package/dist/modules/ProductList/index.js +158 -0
  40. package/dist/modules/ProductList/types.d.ts +9 -0
  41. package/dist/modules/ProductList/types.js +5 -0
  42. package/dist/modules/Resource/index.d.ts +15 -0
  43. package/dist/modules/Resource/index.js +219 -0
  44. package/dist/modules/Resource/types.d.ts +44 -0
  45. package/dist/modules/Resource/types.js +22 -0
  46. package/dist/modules/index.d.ts +3 -0
  47. package/dist/modules/index.js +3 -0
  48. package/dist/plugins/index.d.ts +2 -0
  49. package/dist/plugins/index.js +2 -0
  50. package/dist/plugins/request.d.ts +127 -0
  51. package/dist/plugins/request.js +592 -0
  52. package/dist/plugins/window.d.ts +115 -0
  53. package/dist/plugins/window.js +328 -0
  54. package/dist/solution/BookingByStep/index.d.ts +12 -0
  55. package/dist/solution/BookingByStep/index.js +77 -0
  56. package/dist/solution/BookingByStep/types.d.ts +27 -0
  57. package/dist/solution/BookingByStep/types.js +10 -0
  58. package/dist/solution/BuyTickets/index.d.ts +26 -0
  59. package/dist/solution/BuyTickets/index.js +339 -0
  60. package/dist/solution/BuyTickets/types.d.ts +24 -0
  61. package/dist/solution/BuyTickets/types.js +19 -0
  62. package/dist/solution/PlaceOrder/index.d.ts +0 -0
  63. package/dist/solution/PlaceOrder/index.js +54 -0
  64. package/dist/solution/index.d.ts +1 -0
  65. package/dist/solution/index.js +1 -0
  66. package/dist/store/createStore.d.ts +3 -0
  67. package/dist/store/createStore.js +43 -0
  68. package/dist/types/index.d.ts +85 -0
  69. package/dist/types/index.js +1 -0
  70. package/lib/core/index.d.ts +30 -0
  71. package/lib/core/index.js +212 -0
  72. package/lib/effects/index.d.ts +17 -0
  73. package/lib/effects/index.js +78 -0
  74. package/lib/index.d.ts +11 -0
  75. package/lib/index.js +51 -0
  76. package/lib/modules/Account/index.d.ts +21 -0
  77. package/lib/modules/Account/index.js +93 -0
  78. package/lib/modules/Account/types.d.ts +41 -0
  79. package/lib/modules/Account/types.js +35 -0
  80. package/lib/modules/BaseModule.d.ts +11 -0
  81. package/lib/modules/BaseModule.js +40 -0
  82. package/lib/modules/Cart/index.d.ts +33 -0
  83. package/lib/modules/Cart/index.js +104 -0
  84. package/lib/modules/Cart/types.d.ts +35 -0
  85. package/lib/modules/Cart/types.js +35 -0
  86. package/lib/modules/Date/index.d.ts +17 -0
  87. package/lib/modules/Date/index.js +75 -0
  88. package/lib/modules/Date/types.d.ts +32 -0
  89. package/lib/modules/Date/types.js +33 -0
  90. package/lib/modules/Guests/index.d.ts +17 -0
  91. package/lib/modules/Guests/index.js +95 -0
  92. package/lib/modules/Guests/types.d.ts +43 -0
  93. package/lib/modules/Guests/types.js +35 -0
  94. package/lib/modules/Order/index.d.ts +17 -0
  95. package/lib/modules/Order/index.js +95 -0
  96. package/lib/modules/Order/types.d.ts +57 -0
  97. package/lib/modules/Order/types.js +35 -0
  98. package/lib/modules/Payment/index.d.ts +18 -0
  99. package/lib/modules/Payment/index.js +103 -0
  100. package/lib/modules/Payment/types.d.ts +49 -0
  101. package/lib/modules/Payment/types.js +35 -0
  102. package/lib/modules/Product/index.d.ts +39 -0
  103. package/lib/modules/Product/index.js +87 -0
  104. package/lib/modules/Product/types.d.ts +387 -0
  105. package/lib/modules/Product/types.js +17 -0
  106. package/lib/modules/ProductList/index.d.ts +16 -0
  107. package/lib/modules/ProductList/index.js +71 -0
  108. package/lib/modules/ProductList/types.d.ts +9 -0
  109. package/lib/modules/ProductList/types.js +33 -0
  110. package/lib/modules/Resource/index.d.ts +15 -0
  111. package/lib/modules/Resource/index.js +91 -0
  112. package/lib/modules/Resource/types.d.ts +44 -0
  113. package/lib/modules/Resource/types.js +34 -0
  114. package/lib/modules/index.d.ts +3 -0
  115. package/lib/modules/index.js +27 -0
  116. package/lib/plugins/index.d.ts +2 -0
  117. package/lib/plugins/index.js +25 -0
  118. package/lib/plugins/request.d.ts +127 -0
  119. package/lib/plugins/request.js +297 -0
  120. package/lib/plugins/window.d.ts +115 -0
  121. package/lib/plugins/window.js +252 -0
  122. package/lib/solution/BookingByStep/index.d.ts +12 -0
  123. package/lib/solution/BookingByStep/index.js +53 -0
  124. package/lib/solution/BookingByStep/types.d.ts +27 -0
  125. package/lib/solution/BookingByStep/types.js +38 -0
  126. package/lib/solution/BuyTickets/index.d.ts +26 -0
  127. package/lib/solution/BuyTickets/index.js +122 -0
  128. package/lib/solution/BuyTickets/types.d.ts +24 -0
  129. package/lib/solution/BuyTickets/types.js +40 -0
  130. package/lib/solution/PlaceOrder/index.d.ts +0 -0
  131. package/lib/solution/PlaceOrder/index.js +0 -0
  132. package/lib/solution/index.d.ts +1 -0
  133. package/lib/solution/index.js +23 -0
  134. package/lib/store/createStore.d.ts +3 -0
  135. package/lib/store/createStore.js +46 -0
  136. package/lib/types/index.d.ts +85 -0
  137. package/lib/types/index.js +17 -0
  138. package/package.json +65 -0
@@ -0,0 +1,387 @@
1
+ /**
2
+ * 商品基本信息接口
3
+ */
4
+ export interface ProductData {
5
+ /** 商品id */
6
+ id: number;
7
+ /** 扩展类型id */
8
+ extension_id: number;
9
+ /** 扩展类型 */
10
+ extension_type: string;
11
+ /** 商品所属商户id */
12
+ shop_id: number;
13
+ /** 商品标题 */
14
+ title: string;
15
+ /** 商品slug */
16
+ slug: string;
17
+ /** draft:草稿;published:已发布;pending:待发布;archived:已归档 */
18
+ status: 'draft' | 'published' | 'pending' | 'archived';
19
+ /** 库存数量 */
20
+ stock_quantity: number;
21
+ /** 销售数量 */
22
+ sales_quantity: number;
23
+ /** 总库存数量包含组合规格商品 */
24
+ sum_stock: number;
25
+ /** 商品价格 */
26
+ price: string;
27
+ /** 商品原价 */
28
+ original_price: string;
29
+ /** 商品成本价 */
30
+ cost_price: string;
31
+ /** 商品封面图 */
32
+ cover: string;
33
+ /** 销售渠道 */
34
+ channel_application: string[];
35
+ /** 0:不限库存;1:跟踪库存 */
36
+ is_track: number;
37
+ /** 0:缺货后不允许售卖;1:缺货后继续售卖; */
38
+ over_sold: number;
39
+ /** 0:不含税;1:含税 */
40
+ is_gst: number;
41
+ /** 商品编码 */
42
+ code: string;
43
+ /** 商品条码 */
44
+ barcode: string;
45
+ /** 是否支持配送 */
46
+ is_delivery: number;
47
+ /** 重量单位 */
48
+ weight_unit: string;
49
+ /** 重量值 */
50
+ weight_value: string;
51
+ /** 商品类型 */
52
+ type: string;
53
+ /** 单位 */
54
+ unit: string;
55
+ /** 排序 */
56
+ sort: number;
57
+ /** 是否有规格 */
58
+ is_variant: number;
59
+ /** 规格数量 */
60
+ variant_count: number;
61
+ /** 截止时间配置 */
62
+ cut_off_time: {
63
+ /** 单位值 */
64
+ unit: number;
65
+ /** 单位类型 */
66
+ unit_type: string;
67
+ /** 未来天数 */
68
+ future_day: number;
69
+ /** 类型 */
70
+ type: string;
71
+ /** 进行中配置 */
72
+ ongoing: {
73
+ /** 类型 */
74
+ type: string;
75
+ /** 单位值 */
76
+ unit: number;
77
+ };
78
+ };
79
+ /** 政策 */
80
+ policy: number;
81
+ /** 机器码配置 */
82
+ machine_code: {
83
+ /** 是否允许改期 */
84
+ make_over: number;
85
+ /** 是否允许提前 */
86
+ beforehand: number;
87
+ /** 限制数量 */
88
+ limit_count: number;
89
+ /** 客户限制 */
90
+ customer: number;
91
+ /** 发送动作 */
92
+ send_action: string;
93
+ /** 是否隐藏充值 */
94
+ hide_recharge: number;
95
+ /** 是否自动分销 */
96
+ distributor_automatic: number;
97
+ };
98
+ /** 时长配置 */
99
+ duration: {
100
+ /** 类型 */
101
+ type: string;
102
+ /** 值 */
103
+ value: number;
104
+ };
105
+ /** 商品显示设置 */
106
+ product_display_setting: {
107
+ /** kiosk配置 */
108
+ kiosk: {
109
+ /** 是否使用显示模式 */
110
+ use_display_mode: number;
111
+ /** 商品选项模式 */
112
+ product_option_mode: any;
113
+ /** 商品选项模式分页 */
114
+ product_option_mode_paging: any;
115
+ /** 商品套餐模式 */
116
+ product_bundle_mode: any;
117
+ /** 商品套餐模式分页 */
118
+ product_bundle_mode_paging: any;
119
+ };
120
+ };
121
+ /** 货架商品数据 */
122
+ shelf_product_datas: any[];
123
+ /** 步进值 */
124
+ step_value: number;
125
+ /** 最小数量单位 */
126
+ min_num_unit: number;
127
+ /** 是否收取税费 */
128
+ is_charge_tax: number;
129
+ /** 基础价格 */
130
+ base_price: string;
131
+ /** 规格列表 */
132
+ variant: any[];
133
+ media: ProductMedia[];
134
+ tags: ProductTag[];
135
+ categories: ProductCategory[];
136
+ bundle_groups: ProductBundleGroup[];
137
+ }
138
+ /**
139
+ * 商品媒体信息接口
140
+ */
141
+ export interface ProductMedia {
142
+ /** 媒体id */
143
+ id: number;
144
+ /** 商品id */
145
+ product_id: number;
146
+ /** 店铺id */
147
+ shop_id: number;
148
+ /** 媒体标题 */
149
+ title: string;
150
+ /** 完整的url */
151
+ url: string;
152
+ /** 媒体资源扩展名mp4,jpg,png */
153
+ extension: string;
154
+ /** 媒体资源类型:video,image */
155
+ type: string;
156
+ /** 排序字段asc */
157
+ sort: number;
158
+ /** 创建账号id */
159
+ create_account_id: number;
160
+ /** 更新账号id */
161
+ update_account_id: number;
162
+ /** 删除时间 */
163
+ deleted_at: string | null;
164
+ /** 创建时间 */
165
+ created_at: string;
166
+ /** 更新时间 */
167
+ updated_at: string;
168
+ }
169
+ /**
170
+ * 商品标签接口
171
+ */
172
+ export interface ProductTag {
173
+ /** 标签id */
174
+ id: number;
175
+ /** 店铺id */
176
+ shop_id: number;
177
+ /** 标签名称 */
178
+ name: string;
179
+ /** 标签名称首字母 */
180
+ name_letter: string;
181
+ /** 最后应用时间 */
182
+ last_applicable_time: number;
183
+ /** 创建账号id */
184
+ create_account_id: number;
185
+ /** 更新账号id */
186
+ update_account_id: number;
187
+ /** 删除时间 */
188
+ deleted_at: string | null;
189
+ /** 创建时间 */
190
+ created_at: string;
191
+ /** 更新时间 */
192
+ updated_at: string;
193
+ /** 关联信息 */
194
+ pivot: {
195
+ /** 商品id */
196
+ product_id: number;
197
+ /** 标签id */
198
+ product_tag_id: number;
199
+ };
200
+ }
201
+ /**
202
+ * 商品分类接口
203
+ */
204
+ export interface ProductCategory {
205
+ /** 类别id */
206
+ id: number;
207
+ /** 店铺id */
208
+ shop_id: number;
209
+ /** 类别名称 */
210
+ name: string;
211
+ /** 类别名称首字母 */
212
+ name_letter: string;
213
+ /** 最后应用时间 */
214
+ last_applicable_time: number;
215
+ /** 创建账号id */
216
+ create_account_id: number;
217
+ /** 更新账号id */
218
+ update_account_id: number;
219
+ /** 删除时间 */
220
+ deleted_at: string | null;
221
+ /** 创建时间 */
222
+ created_at: string;
223
+ /** 更新时间 */
224
+ updated_at: string;
225
+ /** 关联信息 */
226
+ pivot: {
227
+ /** 商品id */
228
+ product_id: number;
229
+ /** 分类id */
230
+ product_category_id: number;
231
+ /** 创建时间 */
232
+ created_at: string;
233
+ /** 更新时间 */
234
+ updated_at: string;
235
+ };
236
+ }
237
+ /**
238
+ * 商品规格组接口
239
+ */
240
+ export interface ProductVariantGroup {
241
+ /** 组合规格组id */
242
+ id: number;
243
+ /** 商品id */
244
+ product_id: number;
245
+ /** 店铺id */
246
+ shop_id: number;
247
+ /** 组合规格组名称 */
248
+ name: string;
249
+ /** 组合规格组位置标识 */
250
+ position_id: number;
251
+ /** 排序 */
252
+ sort: number;
253
+ /** 创建账号id */
254
+ create_account_id: number;
255
+ /** 更新账号id */
256
+ update_account_id: number;
257
+ /** 删除时间 */
258
+ deleted_at: string | null;
259
+ /** 创建时间 */
260
+ created_at: string;
261
+ /** 更新时间 */
262
+ updated_at: string;
263
+ /** 0正常 */
264
+ status: number;
265
+ /** 组合规格选项集合列表 */
266
+ variant_item: ProductVariantItem[];
267
+ }
268
+ /**
269
+ * 商品规格项接口
270
+ */
271
+ export interface ProductVariantItem {
272
+ /** 选项id */
273
+ id: number;
274
+ /** 规格组id */
275
+ variant_group_id: number;
276
+ /** 商品id */
277
+ product_id: number;
278
+ /** 店铺id */
279
+ shop_id: number;
280
+ /** 选项位置标识 */
281
+ position_id: number;
282
+ /** 选项名称 */
283
+ name: string;
284
+ /** 排序 */
285
+ sort: number;
286
+ /** 创建账号id */
287
+ create_account_id: number;
288
+ /** 更新账号id */
289
+ update_account_id: number;
290
+ /** 删除时间 */
291
+ deleted_at: string | null;
292
+ /** 创建时间 */
293
+ created_at: string;
294
+ /** 更新时间 */
295
+ updated_at: string;
296
+ /** 0正常 */
297
+ status: number;
298
+ }
299
+ /**
300
+ * 商品规格接口
301
+ */
302
+ export interface ProductVariant {
303
+ /** 组合商品id */
304
+ id: number;
305
+ /** 商品id */
306
+ product_id: number;
307
+ /** 店铺id */
308
+ shop_id: number;
309
+ /** 规格键 */
310
+ sku_key: string;
311
+ /** 规格id */
312
+ sku_ids: string;
313
+ /** 组合商品的封面图 */
314
+ cover: string;
315
+ /** 组合商品的价格 */
316
+ price: string;
317
+ /** 组合商品的成本价 */
318
+ original_price: number;
319
+ /** 0:不含税;1:含税 */
320
+ is_gst: number;
321
+ /** 组合商品的编码 */
322
+ code: string;
323
+ /** 组合商品条码 */
324
+ barcode: string;
325
+ /** 0:不限库存;1:跟踪库存 */
326
+ is_track: number;
327
+ /** 库存数量 */
328
+ stock_quantity: number;
329
+ /** 排序 */
330
+ sort: number;
331
+ /** 0:缺货后不允许售卖;1:缺货后继续售卖; */
332
+ over_sold: number;
333
+ /** 0:启用 1:禁用 */
334
+ disabled: number;
335
+ /** 创建账号id */
336
+ create_account_id: number;
337
+ /** 更新账号id */
338
+ update_account_id: number;
339
+ /** 删除时间 */
340
+ deleted_at: string | null;
341
+ /** 创建时间 */
342
+ created_at: string;
343
+ /** 更新时间 */
344
+ updated_at: string;
345
+ /** 组合商品的名称 */
346
+ title: string[];
347
+ /** 0正常 */
348
+ status: number;
349
+ }
350
+ /**
351
+ * 商品套餐组接口
352
+ */
353
+ export interface ProductBundleGroup {
354
+ /** 套餐分组id */
355
+ id: string;
356
+ /** 名称 */
357
+ name: string;
358
+ /** 最小数量 */
359
+ min_quantity: string;
360
+ /** 最大数量 */
361
+ max_quantity: string;
362
+ /** 套餐明细 */
363
+ bundle_item: ProductBundleItem[];
364
+ }
365
+ /**
366
+ * 商品套餐项接口
367
+ */
368
+ export interface ProductBundleItem {
369
+ /** 套餐明细id */
370
+ id: string;
371
+ /** 扩展类型id */
372
+ extension_id: string;
373
+ /** 扩展类型 */
374
+ extension_type: string;
375
+ /** 绑定的商品id */
376
+ bundle_product_id: string;
377
+ /** 加价:markup, 减价:markdown,product_price:商品价格 */
378
+ price_type: string;
379
+ /** 价格 */
380
+ price: string;
381
+ /** 最大数量 */
382
+ max_quantity: string;
383
+ /** 明细标题 */
384
+ title: string;
385
+ /** 明细库存 */
386
+ stock_quantity: string;
387
+ }
@@ -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/Product/types.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,16 @@
1
+ import { Module, PisellCore } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { Product } from '../Product';
4
+ import { ProductData } from '../Product/types';
5
+ export * from './types';
6
+ export declare class ProductList extends BaseModule implements Module {
7
+ protected defaultName: string;
8
+ protected defaultVersion: string;
9
+ private store;
10
+ constructor(name?: string, version?: string);
11
+ initialize(core: PisellCore, options: any): Promise<void>;
12
+ storeChange(path?: string, value?: any): Promise<void>;
13
+ getProducts(): Promise<ProductData[]>;
14
+ getProduct(id: number): Promise<Product | undefined>;
15
+ addProduct(): Promise<void>;
16
+ }
@@ -0,0 +1,71 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/modules/ProductList/index.ts
21
+ var ProductList_exports = {};
22
+ __export(ProductList_exports, {
23
+ ProductList: () => ProductList
24
+ });
25
+ module.exports = __toCommonJS(ProductList_exports);
26
+ var import_BaseModule = require("../BaseModule");
27
+ var import_Product = require("../Product");
28
+ var import_types = require("./types");
29
+ __reExport(ProductList_exports, require("./types"), module.exports);
30
+ var ProductList = class extends import_BaseModule.BaseModule {
31
+ constructor(name, version) {
32
+ super(name, version);
33
+ this.defaultName = "productList";
34
+ this.defaultVersion = "1.0.0";
35
+ }
36
+ async initialize(core, options) {
37
+ this.core = core;
38
+ this.store = {
39
+ ...options.store || {},
40
+ productMap: /* @__PURE__ */ new Map()
41
+ };
42
+ this.storeChange();
43
+ }
44
+ async storeChange(path, value) {
45
+ this.store.list.forEach((product) => {
46
+ if (!this.store.productMap.has(`product-${product.id}`)) {
47
+ const newProductModule = new import_Product.Product(`product-${product.id.toString()}`);
48
+ this.core.registerModule(newProductModule, { initialState: product });
49
+ this.store.productMap.set(product.id.toString(), newProductModule);
50
+ }
51
+ });
52
+ }
53
+ async getProducts() {
54
+ await this.core.effects.emit(import_types.ProductListHooks.onGetProducts, this.store.list);
55
+ return this.store.list;
56
+ }
57
+ async getProduct(id) {
58
+ await this.core.effects.emit(import_types.ProductListHooks.onGetProduct, this.store.list);
59
+ const product = this.store.productMap.get(`${id}`);
60
+ if (product)
61
+ return product;
62
+ return void 0;
63
+ }
64
+ async addProduct() {
65
+ }
66
+ };
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ ProductList,
70
+ ...require("./types")
71
+ });
@@ -0,0 +1,9 @@
1
+ import { ProductData } from '../Product/types';
2
+ export interface ProductListData {
3
+ list: ProductData[];
4
+ productMap: Map<string, any>;
5
+ }
6
+ export declare enum ProductListHooks {
7
+ onGetProducts = "productList:onGetProducts",
8
+ onGetProduct = "productList:onGetProduct"
9
+ }
@@ -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/ProductList/types.ts
20
+ var types_exports = {};
21
+ __export(types_exports, {
22
+ ProductListHooks: () => ProductListHooks
23
+ });
24
+ module.exports = __toCommonJS(types_exports);
25
+ var ProductListHooks = /* @__PURE__ */ ((ProductListHooks2) => {
26
+ ProductListHooks2["onGetProducts"] = "productList:onGetProducts";
27
+ ProductListHooks2["onGetProduct"] = "productList:onGetProduct";
28
+ return ProductListHooks2;
29
+ })(ProductListHooks || {});
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ ProductListHooks
33
+ });
@@ -0,0 +1,15 @@
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { Resource, ResourceTimeSlot, ResourceListModuleAPI } from './types';
4
+ export declare class ResourceListModule extends BaseModule implements Module, ResourceListModuleAPI {
5
+ private state;
6
+ constructor();
7
+ initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
8
+ getResources(): Promise<Resource[]>;
9
+ selectResource(resourceId: string): Promise<void>;
10
+ getSelectedResource(): Resource | null;
11
+ checkAvailability(resourceId: string, start: Date, end: Date): Promise<boolean>;
12
+ getAvailableTimeSlots(resourceId: string): Promise<ResourceTimeSlot[]>;
13
+ getAvailableCapacity(resourceId: string, timeSlot: ResourceTimeSlot): number;
14
+ updateResource(resourceId: string, updates: Partial<Resource>): Promise<void>;
15
+ }
@@ -0,0 +1,91 @@
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/index.ts
20
+ var Resource_exports = {};
21
+ __export(Resource_exports, {
22
+ ResourceListModule: () => ResourceListModule
23
+ });
24
+ module.exports = __toCommonJS(Resource_exports);
25
+ var import_BaseModule = require("../BaseModule");
26
+ var import_types = require("./types");
27
+ var ResourceListModule = class extends import_BaseModule.BaseModule {
28
+ constructor() {
29
+ super("resource", "1.0.0");
30
+ this.state = {
31
+ list: [],
32
+ selectedResource: null
33
+ };
34
+ }
35
+ async initialize(core, options) {
36
+ this.core = core;
37
+ if (options == null ? void 0 : options.initialState) {
38
+ this.state = { ...this.state, ...options.initialState };
39
+ }
40
+ }
41
+ async getResources() {
42
+ return this.state.list;
43
+ }
44
+ async selectResource(resourceId) {
45
+ const resource = this.state.list.find((r) => r.id === resourceId);
46
+ if (!resource)
47
+ return;
48
+ this.state.selectedResource = resource;
49
+ await this.core.effects.emit(import_types.ResourceHooks.OnResourceSelect, resource);
50
+ }
51
+ getSelectedResource() {
52
+ return this.state.selectedResource;
53
+ }
54
+ async checkAvailability(resourceId, start, end) {
55
+ const resource = this.state.list.find((r) => r.id === resourceId);
56
+ if (!resource)
57
+ return false;
58
+ return resource.timeSlots.some(
59
+ (slot) => slot.start.getTime() <= start.getTime() && slot.end.getTime() >= end.getTime() && slot.availableCapacity > 0
60
+ );
61
+ }
62
+ async getAvailableTimeSlots(resourceId) {
63
+ const resource = this.state.list.find((r) => r.id === resourceId);
64
+ if (!resource)
65
+ return [];
66
+ return resource.timeSlots.filter((slot) => slot.availableCapacity > 0);
67
+ }
68
+ getAvailableCapacity(resourceId, timeSlot) {
69
+ const resource = this.state.list.find((r) => r.id === resourceId);
70
+ if (!resource)
71
+ return 0;
72
+ const slot = resource.timeSlots.find(
73
+ (s) => s.start.getTime() === timeSlot.start.getTime() && s.end.getTime() === timeSlot.end.getTime()
74
+ );
75
+ return (slot == null ? void 0 : slot.availableCapacity) || 0;
76
+ }
77
+ async updateResource(resourceId, updates) {
78
+ const index = this.state.list.findIndex((r) => r.id === resourceId);
79
+ if (index === -1)
80
+ return;
81
+ this.state.list[index] = {
82
+ ...this.state.list[index],
83
+ ...updates
84
+ };
85
+ await this.core.effects.emit(import_types.ResourceHooks.OnResourceChange, this.state.list[index]);
86
+ }
87
+ };
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ ResourceListModule
91
+ });
@@ -0,0 +1,44 @@
1
+ export declare enum ResourceHooks {
2
+ OnResourceSelect = "resource:onResourceSelect",
3
+ OnResourceChange = "resource:onResourceChange",
4
+ OnAvailabilityCheck = "resource:onAvailabilityCheck"
5
+ }
6
+ /**
7
+ * 资源可用时间段
8
+ */
9
+ export interface ResourceTimeSlot {
10
+ start: Date;
11
+ end: Date;
12
+ capacity: number;
13
+ availableCapacity: number;
14
+ }
15
+ /**
16
+ * 资源信息
17
+ */
18
+ export interface Resource {
19
+ id: string;
20
+ name: string;
21
+ type: string;
22
+ capacity: number;
23
+ timeSlots: ResourceTimeSlot[];
24
+ metadata?: Record<string, any>;
25
+ }
26
+ /**
27
+ * 资源列表状态
28
+ */
29
+ export interface ResourceState {
30
+ list: Resource[];
31
+ selectedResource: Resource | null;
32
+ }
33
+ /**
34
+ * 资源列表模块 API
35
+ */
36
+ export interface ResourceListModuleAPI {
37
+ getResources: () => Promise<Resource[]>;
38
+ selectResource: (resourceId: string) => Promise<void>;
39
+ getSelectedResource: () => Resource | null;
40
+ checkAvailability: (resourceId: string, start: Date, end: Date) => Promise<boolean>;
41
+ getAvailableTimeSlots: (resourceId: string) => Promise<ResourceTimeSlot[]>;
42
+ getAvailableCapacity: (resourceId: string, timeSlot: ResourceTimeSlot) => number;
43
+ updateResource: (resourceId: string, updates: Partial<Resource>) => Promise<void>;
44
+ }