@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 +0,0 @@
1
- export {};
@@ -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,34 +0,0 @@
1
- export function getProductHolderConfig(product) {
2
- var _product$holder_confi, _product$origin;
3
- if (!product) return null;
4
- var config = (_product$holder_confi = product === null || product === void 0 ? void 0 : product.holder_config) !== null && _product$holder_confi !== void 0 ? _product$holder_confi : product === null || product === void 0 || (_product$origin = product.origin) === null || _product$origin === void 0 ? void 0 : _product$origin.holder_config;
5
- if (config !== null && config !== void 0 && config.status && (config === null || config === void 0 ? void 0 : config.status) !== 'enable') return null;
6
- if (!(config !== null && config !== void 0 && config.resource_id)) return null;
7
- return config;
8
- }
9
- export function getFormIdFromHolderConfig(config) {
10
- return Number(config === null || config === void 0 ? void 0 : config.resource_id);
11
- }
12
- export function normalizeFormId(formId) {
13
- return Number(formId);
14
- }
15
- export function createEmptyFormItemData() {
16
- return {
17
- records: [],
18
- form: {}
19
- };
20
- }
21
- export function resolveFormMetaFromHolderItem(mapKey, item) {
22
- var _ref, _ref2, _nestedForm$id, _nestedForm$shop_id;
23
- var formInfo = item.form || {};
24
- var nestedForm = formInfo.form || {};
25
- var form_id = normalizeFormId((_ref = (_ref2 = (_nestedForm$id = nestedForm.id) !== null && _nestedForm$id !== void 0 ? _nestedForm$id : formInfo.form_id) !== null && _ref2 !== void 0 ? _ref2 : formInfo.id) !== null && _ref !== void 0 ? _ref : mapKey);
26
- var shop_id = (_nestedForm$shop_id = nestedForm.shop_id) !== null && _nestedForm$shop_id !== void 0 ? _nestedForm$shop_id : formInfo.shop_id;
27
- if (shop_id === undefined || shop_id === null || shop_id === '') {
28
- return null;
29
- }
30
- return {
31
- form_id: form_id,
32
- shop_id: shop_id
33
- };
34
- }
@@ -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,181 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
9
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
15
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
17
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
20
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
25
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
26
- import { BaseModule } from "../BaseModule";
27
- import { autoAssignResources, DEFAULT_RESOURCE_PLANNER_CONTEXT, DEFAULT_RESOURCE_PLANNER_SELECTION, normalizePlannerContext, queryPlannerAvailability, resolveAssignableSlots as _resolveAssignableSlots, validateAssignments } from "./planner";
28
- export * from "./types";
29
- export * from "./planner";
30
- export var ResourcePlannerHooks = /*#__PURE__*/function (ResourcePlannerHooks) {
31
- ResourcePlannerHooks["onContextChanged"] = "resourcePlanner:onContextChanged";
32
- ResourcePlannerHooks["onSelectionChanged"] = "resourcePlanner:onSelectionChanged";
33
- ResourcePlannerHooks["onProjectionChanged"] = "resourcePlanner:onProjectionChanged";
34
- return ResourcePlannerHooks;
35
- }({});
36
- export var ResourcePlannerModule = /*#__PURE__*/function (_BaseModule) {
37
- _inherits(ResourcePlannerModule, _BaseModule);
38
- var _super = _createSuper(ResourcePlannerModule);
39
- function ResourcePlannerModule() {
40
- var _this;
41
- _classCallCheck(this, ResourcePlannerModule);
42
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
- args[_key] = arguments[_key];
44
- }
45
- _this = _super.call.apply(_super, [this].concat(args));
46
- _defineProperty(_assertThisInitialized(_this), "defaultName", 'resourcePlanner');
47
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
48
- _defineProperty(_assertThisInitialized(_this), "store", void 0);
49
- return _this;
50
- }
51
- _createClass(ResourcePlannerModule, [{
52
- key: "initialize",
53
- value: function () {
54
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
55
- var initialState;
56
- return _regeneratorRuntime().wrap(function _callee$(_context) {
57
- while (1) switch (_context.prev = _context.next) {
58
- case 0:
59
- this.core = core;
60
- initialState = options.initialState;
61
- this.store = {
62
- context: normalizePlannerContext((initialState === null || initialState === void 0 ? void 0 : initialState.context) || DEFAULT_RESOURCE_PLANNER_CONTEXT),
63
- selection: (initialState === null || initialState === void 0 ? void 0 : initialState.selection) || _objectSpread({}, DEFAULT_RESOURCE_PLANNER_SELECTION),
64
- projection: (initialState === null || initialState === void 0 ? void 0 : initialState.projection) || null,
65
- version: (initialState === null || initialState === void 0 ? void 0 : initialState.version) || 0
66
- };
67
- case 3:
68
- case "end":
69
- return _context.stop();
70
- }
71
- }, _callee, this);
72
- }));
73
- function initialize(_x, _x2) {
74
- return _initialize.apply(this, arguments);
75
- }
76
- return initialize;
77
- }()
78
- }, {
79
- key: "setContext",
80
- value: function setContext(input) {
81
- this.store.context = normalizePlannerContext(input);
82
- this.store.version += 1;
83
- this.store.projection = null;
84
- var snapshot = this.getSnapshot();
85
- void this.core.effects.emit("".concat(this.name, ":contextChanged"), snapshot);
86
- return snapshot;
87
- }
88
- }, {
89
- key: "mergeContext",
90
- value: function mergeContext(input) {
91
- return this.setContext(_objectSpread(_objectSpread(_objectSpread({}, this.store.context), input), {}, {
92
- products: input.products || this.store.context.products,
93
- resources: input.resources || this.store.context.resources,
94
- externalEvents: input.externalEvents || this.store.context.externalEvents
95
- }));
96
- }
97
- }, {
98
- key: "setSelectionPatch",
99
- value: function setSelectionPatch(patch) {
100
- var assignments = patch.assignments ? patch.replaceAssignments === false ? [].concat(_toConsumableArray(this.store.selection.assignments), _toConsumableArray(patch.assignments)) : patch.assignments : this.store.selection.assignments;
101
- this.store.selection = _objectSpread(_objectSpread(_objectSpread({}, this.store.selection), patch), {}, {
102
- productIds: patch.productIds || this.store.selection.productIds,
103
- resourceIds: patch.resourceIds || this.store.selection.resourceIds,
104
- assignments: assignments
105
- });
106
- this.store.version += 1;
107
- var snapshot = this.getSnapshot();
108
- void this.core.effects.emit("".concat(this.name, ":selectionChanged"), snapshot);
109
- return snapshot;
110
- }
111
- }, {
112
- key: "queryAvailability",
113
- value: function queryAvailability() {
114
- var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
115
- var mergedQuery = _objectSpread({
116
- mode: this.store.selection.mode,
117
- productIds: this.store.selection.productIds,
118
- date: this.store.selection.date,
119
- startTime: this.store.selection.startTime,
120
- endTime: this.store.selection.endTime,
121
- resourceIds: this.store.selection.resourceIds
122
- }, query);
123
- var projection = queryPlannerAvailability(this.store.context, mergedQuery);
124
- this.store.projection = projection;
125
- this.store.version += 1;
126
- void this.core.effects.emit("".concat(this.name, ":projectionChanged"), this.getSnapshot());
127
- return projection;
128
- }
129
- }, {
130
- key: "autoAssign",
131
- value: function autoAssign() {
132
- var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
133
- var result = autoAssignResources(this.store.context, _objectSpread({
134
- mode: this.store.selection.mode,
135
- productIds: this.store.selection.productIds,
136
- date: this.store.selection.date,
137
- startTime: this.store.selection.startTime,
138
- endTime: this.store.selection.endTime,
139
- resourceIds: this.store.selection.resourceIds
140
- }, query));
141
- var resourceIds = Array.from(new Map(result.assignments.map(function (assignment) {
142
- return [String(assignment.resourceId), assignment.resourceId];
143
- })).values());
144
- this.setSelectionPatch(_objectSpread({
145
- assignments: result.assignments
146
- }, resourceIds.length ? {
147
- resourceIds: resourceIds
148
- } : {}));
149
- return result;
150
- }
151
- }, {
152
- key: "resolveAssignableSlots",
153
- value: function resolveAssignableSlots() {
154
- var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
155
- return _resolveAssignableSlots(this.store.context, _objectSpread({
156
- mode: this.store.selection.mode,
157
- productIds: this.store.selection.productIds,
158
- date: this.store.selection.date,
159
- startTime: this.store.selection.startTime,
160
- endTime: this.store.selection.endTime,
161
- resourceIds: this.store.selection.resourceIds
162
- }, query));
163
- }
164
- }, {
165
- key: "validateSelection",
166
- value: function validateSelection() {
167
- return validateAssignments(this.store.context, this.store.selection);
168
- }
169
- }, {
170
- key: "getSnapshot",
171
- value: function getSnapshot() {
172
- return {
173
- context: this.store.context,
174
- selection: this.store.selection,
175
- projection: this.store.projection,
176
- version: this.store.version
177
- };
178
- }
179
- }]);
180
- return ResourcePlannerModule;
181
- }(BaseModule);
@@ -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;