@pisell/pisellos 2.3.50 → 2.3.53

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 (177) hide show
  1. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
  2. package/dist/modules/Discount/index.d.ts +0 -1
  3. package/dist/modules/Discount/index.js +11 -40
  4. package/dist/modules/Discount/types.d.ts +0 -1
  5. package/dist/modules/OpenData/index.js +2 -2
  6. package/dist/modules/Order/index.d.ts +6 -8
  7. package/dist/modules/Order/index.js +165 -140
  8. package/dist/modules/Order/types.d.ts +21 -12
  9. package/dist/modules/Order/types.js +11 -0
  10. package/dist/modules/Order/utils.d.ts +0 -10
  11. package/dist/modules/Order/utils.js +3 -35
  12. package/dist/modules/Payment/types.d.ts +8 -0
  13. package/dist/modules/Payment/walletpass.d.ts +7 -1
  14. package/dist/modules/Payment/walletpass.js +155 -45
  15. package/dist/modules/Product/types.d.ts +0 -1
  16. package/dist/modules/ProductList/index.js +14 -33
  17. package/dist/modules/Quotation/index.d.ts +1 -1
  18. package/dist/modules/Quotation/index.js +2 -2
  19. package/dist/modules/Rules/index.js +32 -56
  20. package/dist/modules/SalesSummary/index.js +13 -12
  21. package/dist/modules/SalesSummary/utils.js +7 -1
  22. package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
  23. package/dist/modules/ScanOrderLogger/index.js +2 -15
  24. package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
  25. package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
  26. package/dist/modules/Schedule/index.d.ts +1 -3
  27. package/dist/modules/Schedule/index.js +16 -21
  28. package/dist/modules/Summary/utils.js +13 -38
  29. package/dist/modules/index.d.ts +0 -2
  30. package/dist/modules/index.js +1 -3
  31. package/dist/plugins/window.d.ts +0 -1
  32. package/dist/server/index.d.ts +0 -14
  33. package/dist/server/index.js +793 -907
  34. package/dist/server/modules/index.d.ts +1 -1
  35. package/dist/server/modules/order/index.d.ts +16 -0
  36. package/dist/server/modules/order/index.js +964 -776
  37. package/dist/server/modules/order/types.d.ts +14 -0
  38. package/dist/server/modules/order/types.js +6 -0
  39. package/dist/solution/BaseSales/index.d.ts +18 -13
  40. package/dist/solution/BaseSales/index.js +202 -178
  41. package/dist/solution/BaseSales/utils/cartPromotion.js +5 -3
  42. package/dist/solution/BookingByStep/index.d.ts +2 -17
  43. package/dist/solution/BookingByStep/index.js +215 -294
  44. package/dist/solution/BookingByStep/types.d.ts +1 -2
  45. package/dist/solution/BookingByStep/types.js +1 -3
  46. package/dist/solution/BookingByStep/utils/capacity.js +1 -17
  47. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  48. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  49. package/dist/solution/BookingTicket/index.d.ts +1 -13
  50. package/dist/solution/BookingTicket/index.js +2 -2
  51. package/dist/solution/BookingTicket/types.d.ts +3 -0
  52. package/dist/solution/BookingTicket/utils/cartView.js +44 -32
  53. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
  54. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -10
  55. package/dist/solution/Sales/index.d.ts +1 -0
  56. package/dist/solution/Sales/index.js +16 -2
  57. package/dist/solution/ScanOrder/index.d.ts +14 -26
  58. package/dist/solution/ScanOrder/index.js +739 -1142
  59. package/dist/solution/ScanOrder/types.d.ts +1 -21
  60. package/dist/solution/ScanOrder/utils.d.ts +0 -8
  61. package/dist/solution/ScanOrder/utils.js +25 -66
  62. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  63. package/dist/solution/ShopDiscount/index.js +87 -125
  64. package/dist/solution/VenueBooking/index.d.ts +11 -39
  65. package/dist/solution/VenueBooking/index.js +841 -1167
  66. package/dist/solution/VenueBooking/types.d.ts +0 -3
  67. package/dist/solution/VenueBooking/utils/resource.js +0 -1
  68. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  69. package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
  70. package/dist/solution/index.d.ts +0 -1
  71. package/dist/solution/index.js +1 -2
  72. package/dist/types/index.d.ts +0 -1
  73. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  74. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
  75. package/lib/modules/Discount/index.d.ts +0 -1
  76. package/lib/modules/Discount/index.js +0 -9
  77. package/lib/modules/Discount/types.d.ts +0 -1
  78. package/lib/modules/OpenData/index.js +1 -1
  79. package/lib/modules/Order/index.d.ts +6 -8
  80. package/lib/modules/Order/index.js +89 -38
  81. package/lib/modules/Order/types.d.ts +21 -12
  82. package/lib/modules/Order/utils.d.ts +0 -10
  83. package/lib/modules/Order/utils.js +5 -36
  84. package/lib/modules/Payment/types.d.ts +8 -0
  85. package/lib/modules/Payment/walletpass.d.ts +7 -1
  86. package/lib/modules/Payment/walletpass.js +107 -9
  87. package/lib/modules/Product/types.d.ts +0 -1
  88. package/lib/modules/ProductList/index.js +31 -40
  89. package/lib/modules/Quotation/index.d.ts +1 -1
  90. package/lib/modules/Quotation/index.js +2 -2
  91. package/lib/modules/Rules/index.js +32 -44
  92. package/lib/modules/SalesSummary/index.js +7 -6
  93. package/lib/modules/SalesSummary/utils.js +5 -1
  94. package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
  95. package/lib/modules/ScanOrderLogger/index.js +1 -13
  96. package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
  97. package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
  98. package/lib/modules/Schedule/index.d.ts +1 -3
  99. package/lib/modules/Schedule/index.js +8 -10
  100. package/lib/modules/Summary/utils.js +1 -21
  101. package/lib/modules/index.d.ts +0 -2
  102. package/lib/modules/index.js +1 -5
  103. package/lib/plugins/window.d.ts +0 -1
  104. package/lib/server/index.d.ts +0 -14
  105. package/lib/server/index.js +15 -72
  106. package/lib/server/modules/index.d.ts +1 -1
  107. package/lib/server/modules/order/index.d.ts +16 -0
  108. package/lib/server/modules/order/index.js +140 -4
  109. package/lib/server/modules/order/types.d.ts +14 -0
  110. package/lib/server/modules/order/types.js +1 -0
  111. package/lib/solution/BaseSales/index.d.ts +18 -13
  112. package/lib/solution/BaseSales/index.js +58 -35
  113. package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
  114. package/lib/solution/BookingByStep/index.d.ts +2 -17
  115. package/lib/solution/BookingByStep/index.js +18 -60
  116. package/lib/solution/BookingByStep/types.d.ts +1 -2
  117. package/lib/solution/BookingByStep/types.js +0 -5
  118. package/lib/solution/BookingByStep/utils/capacity.js +1 -20
  119. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  120. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  121. package/lib/solution/BookingTicket/index.d.ts +1 -13
  122. package/lib/solution/BookingTicket/index.js +2 -10
  123. package/lib/solution/BookingTicket/types.d.ts +3 -0
  124. package/lib/solution/BookingTicket/utils/cartView.js +43 -30
  125. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
  126. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  127. package/lib/solution/Sales/index.d.ts +1 -0
  128. package/lib/solution/Sales/index.js +15 -3
  129. package/lib/solution/ScanOrder/index.d.ts +14 -26
  130. package/lib/solution/ScanOrder/index.js +182 -449
  131. package/lib/solution/ScanOrder/types.d.ts +1 -21
  132. package/lib/solution/ScanOrder/utils.d.ts +0 -8
  133. package/lib/solution/ScanOrder/utils.js +0 -31
  134. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  135. package/lib/solution/ShopDiscount/index.js +0 -14
  136. package/lib/solution/VenueBooking/index.d.ts +11 -39
  137. package/lib/solution/VenueBooking/index.js +110 -322
  138. package/lib/solution/VenueBooking/types.d.ts +0 -3
  139. package/lib/solution/VenueBooking/utils/resource.js +0 -1
  140. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  141. package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
  142. package/lib/solution/index.d.ts +0 -1
  143. package/lib/solution/index.js +1 -3
  144. package/lib/types/index.d.ts +0 -1
  145. package/package.json +1 -1
  146. package/dist/modules/Holder/index.d.ts +0 -48
  147. package/dist/modules/Holder/index.js +0 -640
  148. package/dist/modules/Holder/types.d.ts +0 -123
  149. package/dist/modules/Holder/types.js +0 -1
  150. package/dist/modules/Holder/utils.d.ts +0 -13
  151. package/dist/modules/Holder/utils.js +0 -34
  152. package/dist/modules/ResourcePlanner/index.d.ts +0 -24
  153. package/dist/modules/ResourcePlanner/index.js +0 -181
  154. package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
  155. package/dist/modules/ResourcePlanner/planner.js +0 -1069
  156. package/dist/modules/ResourcePlanner/types.d.ts +0 -227
  157. package/dist/modules/ResourcePlanner/types.js +0 -1
  158. package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
  159. package/dist/solution/UnifiedBookingSales/index.js +0 -1891
  160. package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
  161. package/dist/solution/UnifiedBookingSales/types.js +0 -11
  162. package/lib/modules/Holder/index.d.ts +0 -48
  163. package/lib/modules/Holder/index.js +0 -402
  164. package/lib/modules/Holder/types.d.ts +0 -123
  165. package/lib/modules/Holder/types.js +0 -17
  166. package/lib/modules/Holder/utils.d.ts +0 -13
  167. package/lib/modules/Holder/utils.js +0 -71
  168. package/lib/modules/ResourcePlanner/index.d.ts +0 -24
  169. package/lib/modules/ResourcePlanner/index.js +0 -148
  170. package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
  171. package/lib/modules/ResourcePlanner/planner.js +0 -933
  172. package/lib/modules/ResourcePlanner/types.d.ts +0 -227
  173. package/lib/modules/ResourcePlanner/types.js +0 -17
  174. package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
  175. package/lib/solution/UnifiedBookingSales/index.js +0 -1084
  176. package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
  177. package/lib/solution/UnifiedBookingSales/types.js +0 -33
@@ -1,123 +0,0 @@
1
- import { ProductData } from '../Product/types';
2
- /**
3
- * 商品 holder 配置
4
- */
5
- export interface IHolderConfig {
6
- required?: number;
7
- resource_id: number;
8
- status?: string;
9
- [key: string]: any;
10
- }
11
- /**
12
- * 表单记录
13
- */
14
- export interface IFormRecord {
15
- form_id: number;
16
- form_record_id: number;
17
- main_field: string;
18
- customer_cover?: string;
19
- created_at?: string;
20
- customer_id?: number;
21
- [key: string]: any;
22
- }
23
- /**
24
- * 表单配置/定义
25
- */
26
- export interface IFormInfo {
27
- form_id: number;
28
- name: string;
29
- fields?: Record<string, any>[];
30
- [key: string]: any;
31
- }
32
- /**
33
- * 单个 form_id 下的数据结构
34
- */
35
- export interface IFormItemData {
36
- records: IFormRecord[];
37
- form: IFormInfo | Record<string, any>;
38
- }
39
- /**
40
- * form_id 为 key 的 map 结构,如 948: { records: [], form: {} }
41
- */
42
- export type HolderFormMap = Record<string, IFormItemData>;
43
- /**
44
- * Holder 模块 reactive store,仅 holderMap 会触发 changed 事件
45
- */
46
- export interface HolderState {
47
- holderMap: HolderFormMap;
48
- }
49
- export interface IFetchFormInfoParams {
50
- url?: string;
51
- query: {
52
- form_id: string | number;
53
- };
54
- useCache?: boolean;
55
- }
56
- export interface IFetchFormRecordsParams {
57
- url?: string;
58
- query: {
59
- customer_id?: number;
60
- form_id: string | number;
61
- shop_id: string | number;
62
- num?: number;
63
- skip?: number;
64
- [key: string]: any;
65
- };
66
- useCache?: boolean;
67
- }
68
- export interface IAddFormRecordParams {
69
- url?: string;
70
- body: {
71
- form_id: number;
72
- shop_id: number | string;
73
- customer_id?: number;
74
- [key: string]: any;
75
- };
76
- }
77
- /**
78
- * UI 层自行调用添加接口后,将返回记录写入 holderMap
79
- */
80
- export interface IAppendFormRecordParams {
81
- /** 接口返回的 data,或完整响应 { data: {...} } */
82
- record: IFormRecord | Record<string, any>;
83
- /** 可选,未传则从 record.form_id 读取 */
84
- form_id?: number | string;
85
- }
86
- export interface IEnsureFormDataParams {
87
- form_id: number | string;
88
- shop_id: number | string;
89
- customer_id?: number;
90
- useCache?: boolean;
91
- forceRefresh?: boolean;
92
- formInfoUrl?: string;
93
- recordsUrl?: string;
94
- skip?: number;
95
- num?: number;
96
- }
97
- export interface IEnsureFormByProductParams {
98
- product: ProductData | Record<string, any>;
99
- customer_id?: number;
100
- shop_id?: number | string;
101
- useCache?: boolean;
102
- }
103
- export interface IRefreshAllFormRecordsParams {
104
- customer_id?: number;
105
- useCache?: boolean;
106
- recordsUrl?: string;
107
- num?: number;
108
- skip?: number;
109
- }
110
- export interface HolderModuleAPI {
111
- getHolderFormMap: () => HolderFormMap;
112
- getHolderFormData: (formId: number | string) => IFormItemData | undefined;
113
- setFormData: (formId: number | string, data: Partial<IFormItemData>) => void;
114
- fetchFormInfo: (params: IFetchFormInfoParams) => Promise<IFormInfo | IFormInfo[]>;
115
- fetchRecords: (params: IFetchFormRecordsParams) => Promise<IFormRecord[]>;
116
- ensureFormData: (params: IEnsureFormDataParams) => Promise<IFormItemData>;
117
- ensureFormByProduct: (params: IEnsureFormByProductParams) => Promise<IFormItemData | null>;
118
- addFormRecord: (params: IAddFormRecordParams) => Promise<IFormRecord>;
119
- appendFormRecord: (params: IAppendFormRecordParams) => IFormRecord;
120
- removeFormRecord: (formId: number | string, formRecordId: number) => void;
121
- clearFormData: (formId?: number | string) => void;
122
- refreshAllFormRecords: (params?: IRefreshAllFormRecordsParams) => Promise<HolderFormMap>;
123
- }
@@ -1,17 +0,0 @@
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/Holder/types.ts
16
- var types_exports = {};
17
- module.exports = __toCommonJS(types_exports);
@@ -1,13 +0,0 @@
1
- import { ProductData } from '../Product/types';
2
- import { IFormItemData, IHolderConfig } from './types';
3
- export declare function getProductHolderConfig(product?: ProductData | Record<string, any> | null): IHolderConfig | null;
4
- export declare function getFormIdFromHolderConfig(config: IHolderConfig): number;
5
- export declare function normalizeFormId(formId: number | string): number;
6
- export declare function createEmptyFormItemData(): {
7
- records: any[];
8
- form: Record<string, any>;
9
- };
10
- export declare function resolveFormMetaFromHolderItem(mapKey: string, item: IFormItemData): {
11
- form_id: string | number;
12
- shop_id: number | string;
13
- } | null;
@@ -1,71 +0,0 @@
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/Holder/utils.ts
20
- var utils_exports = {};
21
- __export(utils_exports, {
22
- createEmptyFormItemData: () => createEmptyFormItemData,
23
- getFormIdFromHolderConfig: () => getFormIdFromHolderConfig,
24
- getProductHolderConfig: () => getProductHolderConfig,
25
- normalizeFormId: () => normalizeFormId,
26
- resolveFormMetaFromHolderItem: () => resolveFormMetaFromHolderItem
27
- });
28
- module.exports = __toCommonJS(utils_exports);
29
- function getProductHolderConfig(product) {
30
- var _a;
31
- if (!product)
32
- return null;
33
- const config = (product == null ? void 0 : product.holder_config) ?? ((_a = product == null ? void 0 : product.origin) == null ? void 0 : _a.holder_config);
34
- if ((config == null ? void 0 : config.status) && (config == null ? void 0 : config.status) !== "enable")
35
- return null;
36
- if (!(config == null ? void 0 : config.resource_id))
37
- return null;
38
- return config;
39
- }
40
- function getFormIdFromHolderConfig(config) {
41
- return Number(config == null ? void 0 : config.resource_id);
42
- }
43
- function normalizeFormId(formId) {
44
- return Number(formId);
45
- }
46
- function createEmptyFormItemData() {
47
- return {
48
- records: [],
49
- form: {}
50
- };
51
- }
52
- function resolveFormMetaFromHolderItem(mapKey, item) {
53
- const formInfo = item.form || {};
54
- const nestedForm = formInfo.form || {};
55
- const form_id = normalizeFormId(
56
- nestedForm.id ?? formInfo.form_id ?? formInfo.id ?? mapKey
57
- );
58
- const shop_id = nestedForm.shop_id ?? formInfo.shop_id;
59
- if (shop_id === void 0 || shop_id === null || shop_id === "") {
60
- return null;
61
- }
62
- return { form_id, shop_id };
63
- }
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- createEmptyFormItemData,
67
- getFormIdFromHolderConfig,
68
- getProductHolderConfig,
69
- normalizeFormId,
70
- resolveFormMetaFromHolderItem
71
- });
@@ -1,24 +0,0 @@
1
- import { BaseModule } from '../BaseModule';
2
- import type { Module, ModuleOptions, PisellCore } from '../../types';
3
- import type { ResourcePlannerAssignmentResult, ResourcePlannerAssignableSlotResult, ResourcePlannerContextInput, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerSelectionPatch, ResourcePlannerSnapshot, ResourcePlannerValidationResult } from './types';
4
- export * from './types';
5
- export * from './planner';
6
- export declare enum ResourcePlannerHooks {
7
- onContextChanged = "resourcePlanner:onContextChanged",
8
- onSelectionChanged = "resourcePlanner:onSelectionChanged",
9
- onProjectionChanged = "resourcePlanner:onProjectionChanged"
10
- }
11
- export declare class ResourcePlannerModule extends BaseModule implements Module {
12
- protected defaultName: string;
13
- protected defaultVersion: string;
14
- private store;
15
- initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
16
- setContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
17
- mergeContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
18
- setSelectionPatch(patch: ResourcePlannerSelectionPatch): ResourcePlannerSnapshot;
19
- queryAvailability(query?: ResourcePlannerQuery): ResourcePlannerProjection;
20
- autoAssign(query?: ResourcePlannerQuery): ResourcePlannerAssignmentResult;
21
- resolveAssignableSlots(query?: ResourcePlannerQuery): ResourcePlannerAssignableSlotResult;
22
- validateSelection(): ResourcePlannerValidationResult;
23
- getSnapshot(): ResourcePlannerSnapshot;
24
- }
@@ -1,148 +0,0 @@
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/ResourcePlanner/index.ts
21
- var ResourcePlanner_exports = {};
22
- __export(ResourcePlanner_exports, {
23
- ResourcePlannerHooks: () => ResourcePlannerHooks,
24
- ResourcePlannerModule: () => ResourcePlannerModule
25
- });
26
- module.exports = __toCommonJS(ResourcePlanner_exports);
27
- var import_BaseModule = require("../BaseModule");
28
- var import_planner = require("./planner");
29
- __reExport(ResourcePlanner_exports, require("./types"), module.exports);
30
- __reExport(ResourcePlanner_exports, require("./planner"), module.exports);
31
- var ResourcePlannerHooks = /* @__PURE__ */ ((ResourcePlannerHooks2) => {
32
- ResourcePlannerHooks2["onContextChanged"] = "resourcePlanner:onContextChanged";
33
- ResourcePlannerHooks2["onSelectionChanged"] = "resourcePlanner:onSelectionChanged";
34
- ResourcePlannerHooks2["onProjectionChanged"] = "resourcePlanner:onProjectionChanged";
35
- return ResourcePlannerHooks2;
36
- })(ResourcePlannerHooks || {});
37
- var ResourcePlannerModule = class extends import_BaseModule.BaseModule {
38
- constructor() {
39
- super(...arguments);
40
- this.defaultName = "resourcePlanner";
41
- this.defaultVersion = "1.0.0";
42
- }
43
- async initialize(core, options) {
44
- this.core = core;
45
- const initialState = options.initialState;
46
- this.store = {
47
- context: (0, import_planner.normalizePlannerContext)((initialState == null ? void 0 : initialState.context) || import_planner.DEFAULT_RESOURCE_PLANNER_CONTEXT),
48
- selection: (initialState == null ? void 0 : initialState.selection) || { ...import_planner.DEFAULT_RESOURCE_PLANNER_SELECTION },
49
- projection: (initialState == null ? void 0 : initialState.projection) || null,
50
- version: (initialState == null ? void 0 : initialState.version) || 0
51
- };
52
- }
53
- setContext(input) {
54
- this.store.context = (0, import_planner.normalizePlannerContext)(input);
55
- this.store.version += 1;
56
- this.store.projection = null;
57
- const snapshot = this.getSnapshot();
58
- void this.core.effects.emit(`${this.name}:contextChanged`, snapshot);
59
- return snapshot;
60
- }
61
- mergeContext(input) {
62
- return this.setContext({
63
- ...this.store.context,
64
- ...input,
65
- products: input.products || this.store.context.products,
66
- resources: input.resources || this.store.context.resources,
67
- externalEvents: input.externalEvents || this.store.context.externalEvents
68
- });
69
- }
70
- setSelectionPatch(patch) {
71
- const assignments = patch.assignments ? patch.replaceAssignments === false ? [...this.store.selection.assignments, ...patch.assignments] : patch.assignments : this.store.selection.assignments;
72
- this.store.selection = {
73
- ...this.store.selection,
74
- ...patch,
75
- productIds: patch.productIds || this.store.selection.productIds,
76
- resourceIds: patch.resourceIds || this.store.selection.resourceIds,
77
- assignments
78
- };
79
- this.store.version += 1;
80
- const snapshot = this.getSnapshot();
81
- void this.core.effects.emit(`${this.name}:selectionChanged`, snapshot);
82
- return snapshot;
83
- }
84
- queryAvailability(query = {}) {
85
- const mergedQuery = {
86
- mode: this.store.selection.mode,
87
- productIds: this.store.selection.productIds,
88
- date: this.store.selection.date,
89
- startTime: this.store.selection.startTime,
90
- endTime: this.store.selection.endTime,
91
- resourceIds: this.store.selection.resourceIds,
92
- ...query
93
- };
94
- const projection = (0, import_planner.queryPlannerAvailability)(this.store.context, mergedQuery);
95
- this.store.projection = projection;
96
- this.store.version += 1;
97
- void this.core.effects.emit(`${this.name}:projectionChanged`, this.getSnapshot());
98
- return projection;
99
- }
100
- autoAssign(query = {}) {
101
- const result = (0, import_planner.autoAssignResources)(this.store.context, {
102
- mode: this.store.selection.mode,
103
- productIds: this.store.selection.productIds,
104
- date: this.store.selection.date,
105
- startTime: this.store.selection.startTime,
106
- endTime: this.store.selection.endTime,
107
- resourceIds: this.store.selection.resourceIds,
108
- ...query
109
- });
110
- const resourceIds = Array.from(new Map(
111
- result.assignments.map((assignment) => [String(assignment.resourceId), assignment.resourceId])
112
- ).values());
113
- this.setSelectionPatch({
114
- assignments: result.assignments,
115
- ...resourceIds.length ? { resourceIds } : {}
116
- });
117
- return result;
118
- }
119
- resolveAssignableSlots(query = {}) {
120
- return (0, import_planner.resolveAssignableSlots)(this.store.context, {
121
- mode: this.store.selection.mode,
122
- productIds: this.store.selection.productIds,
123
- date: this.store.selection.date,
124
- startTime: this.store.selection.startTime,
125
- endTime: this.store.selection.endTime,
126
- resourceIds: this.store.selection.resourceIds,
127
- ...query
128
- });
129
- }
130
- validateSelection() {
131
- return (0, import_planner.validateAssignments)(this.store.context, this.store.selection);
132
- }
133
- getSnapshot() {
134
- return {
135
- context: this.store.context,
136
- selection: this.store.selection,
137
- projection: this.store.projection,
138
- version: this.store.version
139
- };
140
- }
141
- };
142
- // Annotate the CommonJS export names for ESM import in node:
143
- 0 && (module.exports = {
144
- ResourcePlannerHooks,
145
- ResourcePlannerModule,
146
- ...require("./types"),
147
- ...require("./planner")
148
- });
@@ -1,14 +0,0 @@
1
- import type { ResourcePlannerAssignmentResult, ResourcePlannerAssignableSlotResult, ResourcePlannerAvailabilityCell, ResourcePlannerContextInput, ResourcePlannerDemandInterval, ResourcePlannerProduct, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerResource, ResourcePlannerSelection, ResourcePlannerValidationResult } from './types';
2
- export declare const DEFAULT_RESOURCE_PLANNER_CONTEXT: Required<ResourcePlannerContextInput>;
3
- export declare const DEFAULT_RESOURCE_PLANNER_SELECTION: ResourcePlannerSelection;
4
- export declare function normalizePlannerContext(input?: ResourcePlannerContextInput): Required<ResourcePlannerContextInput>;
5
- export declare function buildDemandIntervals(products: ResourcePlannerProduct[], query: ResourcePlannerQuery, context?: Required<ResourcePlannerContextInput>): ResourcePlannerDemandInterval[];
6
- export declare function evaluateResourceForInterval(params: {
7
- resource: ResourcePlannerResource;
8
- interval: ResourcePlannerDemandInterval;
9
- context: Required<ResourcePlannerContextInput>;
10
- }): ResourcePlannerAvailabilityCell;
11
- export declare function queryPlannerAvailability(contextInput: ResourcePlannerContextInput, query?: ResourcePlannerQuery): ResourcePlannerProjection;
12
- export declare function resolveAssignableSlots(contextInput: ResourcePlannerContextInput, query?: ResourcePlannerQuery): ResourcePlannerAssignableSlotResult;
13
- export declare function autoAssignResources(contextInput: ResourcePlannerContextInput, query?: ResourcePlannerQuery): ResourcePlannerAssignmentResult;
14
- export declare function validateAssignments(contextInput: ResourcePlannerContextInput, selection: ResourcePlannerSelection): ResourcePlannerValidationResult;