@pisell/pisellos 2.3.44 → 2.3.45

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 (146) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  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 +2 -4
  7. package/dist/modules/Order/index.js +25 -54
  8. package/dist/modules/Order/types.d.ts +0 -9
  9. package/dist/modules/Order/utils.d.ts +0 -10
  10. package/dist/modules/Order/utils.js +3 -35
  11. package/dist/modules/Product/types.d.ts +0 -1
  12. package/dist/modules/ProductList/index.js +14 -33
  13. package/dist/modules/Quotation/index.d.ts +1 -1
  14. package/dist/modules/Quotation/index.js +2 -2
  15. package/dist/modules/Rules/index.js +13 -47
  16. package/dist/modules/SalesSummary/index.js +13 -12
  17. package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
  18. package/dist/modules/ScanOrderLogger/index.js +2 -15
  19. package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
  20. package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
  21. package/dist/modules/Schedule/index.d.ts +1 -3
  22. package/dist/modules/Schedule/index.js +16 -21
  23. package/dist/modules/Summary/utils.js +13 -38
  24. package/dist/modules/index.d.ts +0 -2
  25. package/dist/modules/index.js +1 -3
  26. package/dist/plugins/window.d.ts +0 -1
  27. package/dist/server/index.d.ts +0 -14
  28. package/dist/server/index.js +657 -772
  29. package/dist/solution/BaseSales/index.d.ts +0 -7
  30. package/dist/solution/BaseSales/index.js +42 -64
  31. package/dist/solution/BookingByStep/index.d.ts +1 -16
  32. package/dist/solution/BookingByStep/index.js +215 -294
  33. package/dist/solution/BookingByStep/types.d.ts +1 -2
  34. package/dist/solution/BookingByStep/types.js +1 -3
  35. package/dist/solution/BookingByStep/utils/capacity.js +1 -17
  36. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  37. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  38. package/dist/solution/BookingTicket/index.d.ts +2 -14
  39. package/dist/solution/BookingTicket/index.js +2 -2
  40. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
  41. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -10
  42. package/dist/solution/ScanOrder/index.d.ts +14 -26
  43. package/dist/solution/ScanOrder/index.js +739 -1142
  44. package/dist/solution/ScanOrder/types.d.ts +1 -21
  45. package/dist/solution/ScanOrder/utils.d.ts +0 -8
  46. package/dist/solution/ScanOrder/utils.js +25 -66
  47. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  48. package/dist/solution/ShopDiscount/index.js +87 -125
  49. package/dist/solution/VenueBooking/index.d.ts +11 -39
  50. package/dist/solution/VenueBooking/index.js +841 -1167
  51. package/dist/solution/VenueBooking/types.d.ts +0 -3
  52. package/dist/solution/VenueBooking/utils/resource.js +0 -1
  53. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  54. package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
  55. package/dist/solution/index.d.ts +0 -1
  56. package/dist/solution/index.js +1 -2
  57. package/dist/types/index.d.ts +0 -1
  58. package/lib/modules/Discount/index.d.ts +0 -1
  59. package/lib/modules/Discount/index.js +0 -9
  60. package/lib/modules/Discount/types.d.ts +0 -1
  61. package/lib/modules/OpenData/index.js +1 -1
  62. package/lib/modules/Order/index.d.ts +2 -4
  63. package/lib/modules/Order/index.js +10 -26
  64. package/lib/modules/Order/types.d.ts +0 -9
  65. package/lib/modules/Order/utils.d.ts +0 -10
  66. package/lib/modules/Order/utils.js +5 -36
  67. package/lib/modules/Product/types.d.ts +0 -1
  68. package/lib/modules/ProductList/index.js +31 -40
  69. package/lib/modules/Quotation/index.d.ts +1 -1
  70. package/lib/modules/Quotation/index.js +2 -2
  71. package/lib/modules/Rules/index.js +16 -33
  72. package/lib/modules/SalesSummary/index.js +7 -6
  73. package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
  74. package/lib/modules/ScanOrderLogger/index.js +1 -13
  75. package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
  76. package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
  77. package/lib/modules/Schedule/index.d.ts +1 -3
  78. package/lib/modules/Schedule/index.js +8 -10
  79. package/lib/modules/Summary/utils.js +1 -21
  80. package/lib/modules/index.d.ts +0 -2
  81. package/lib/modules/index.js +1 -5
  82. package/lib/plugins/window.d.ts +0 -1
  83. package/lib/server/index.d.ts +0 -14
  84. package/lib/server/index.js +5 -65
  85. package/lib/solution/BaseSales/index.d.ts +0 -7
  86. package/lib/solution/BaseSales/index.js +8 -24
  87. package/lib/solution/BookingByStep/index.d.ts +1 -16
  88. package/lib/solution/BookingByStep/index.js +18 -60
  89. package/lib/solution/BookingByStep/types.d.ts +1 -2
  90. package/lib/solution/BookingByStep/types.js +0 -5
  91. package/lib/solution/BookingByStep/utils/capacity.js +1 -20
  92. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  93. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  94. package/lib/solution/BookingTicket/index.d.ts +2 -14
  95. package/lib/solution/BookingTicket/index.js +2 -10
  96. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
  97. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  98. package/lib/solution/ScanOrder/index.d.ts +14 -26
  99. package/lib/solution/ScanOrder/index.js +182 -449
  100. package/lib/solution/ScanOrder/types.d.ts +1 -21
  101. package/lib/solution/ScanOrder/utils.d.ts +0 -8
  102. package/lib/solution/ScanOrder/utils.js +0 -31
  103. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  104. package/lib/solution/ShopDiscount/index.js +0 -14
  105. package/lib/solution/VenueBooking/index.d.ts +11 -39
  106. package/lib/solution/VenueBooking/index.js +110 -322
  107. package/lib/solution/VenueBooking/types.d.ts +0 -3
  108. package/lib/solution/VenueBooking/utils/resource.js +0 -1
  109. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  110. package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
  111. package/lib/solution/index.d.ts +0 -1
  112. package/lib/solution/index.js +1 -3
  113. package/lib/types/index.d.ts +0 -1
  114. package/package.json +1 -1
  115. package/dist/modules/Holder/index.d.ts +0 -48
  116. package/dist/modules/Holder/index.js +0 -640
  117. package/dist/modules/Holder/types.d.ts +0 -123
  118. package/dist/modules/Holder/types.js +0 -1
  119. package/dist/modules/Holder/utils.d.ts +0 -13
  120. package/dist/modules/Holder/utils.js +0 -34
  121. package/dist/modules/ResourcePlanner/index.d.ts +0 -24
  122. package/dist/modules/ResourcePlanner/index.js +0 -181
  123. package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
  124. package/dist/modules/ResourcePlanner/planner.js +0 -1069
  125. package/dist/modules/ResourcePlanner/types.d.ts +0 -227
  126. package/dist/modules/ResourcePlanner/types.js +0 -1
  127. package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
  128. package/dist/solution/UnifiedBookingSales/index.js +0 -1891
  129. package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
  130. package/dist/solution/UnifiedBookingSales/types.js +0 -11
  131. package/lib/modules/Holder/index.d.ts +0 -48
  132. package/lib/modules/Holder/index.js +0 -402
  133. package/lib/modules/Holder/types.d.ts +0 -123
  134. package/lib/modules/Holder/types.js +0 -17
  135. package/lib/modules/Holder/utils.d.ts +0 -13
  136. package/lib/modules/Holder/utils.js +0 -71
  137. package/lib/modules/ResourcePlanner/index.d.ts +0 -24
  138. package/lib/modules/ResourcePlanner/index.js +0 -148
  139. package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
  140. package/lib/modules/ResourcePlanner/planner.js +0 -933
  141. package/lib/modules/ResourcePlanner/types.d.ts +0 -227
  142. package/lib/modules/ResourcePlanner/types.js +0 -17
  143. package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
  144. package/lib/solution/UnifiedBookingSales/index.js +0 -1084
  145. package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
  146. 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;