@pisell/pisellos 0.10.8 → 0.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +0 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/OpenData/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +20 -1
- package/dist/modules/Order/index.js +976 -730
- package/dist/modules/Order/types.d.ts +6 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/dist/modules/Order/utils/virtualSettlement.js +271 -0
- package/dist/modules/Order/utils.js +89 -48
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +4 -1
- package/dist/modules/Payment/walletpass.d.ts +11 -0
- package/dist/modules/Payment/walletpass.js +235 -60
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +15 -2
- package/dist/modules/ProductList/index.js +92 -13
- package/dist/modules/ResourcePlanner/index.d.ts +0 -22
- package/dist/modules/ResourcePlanner/index.js +1 -180
- package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/dist/modules/ResourcePlanner/localClock.js +183 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
- package/dist/modules/ResourcePlanner/planner.js +2019 -936
- package/dist/modules/ResourcePlanner/types.d.ts +346 -187
- package/dist/modules/ResourcePlanner/types.js +33 -1
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +90 -58
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +252 -94
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +26 -2
- package/dist/solution/BaseSales/index.js +1310 -931
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +78 -12
- package/dist/solution/BookingByStep/index.d.ts +4 -4
- package/dist/solution/BookingTicket/index.d.ts +5 -1
- package/dist/solution/BookingTicket/index.js +225 -161
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +5 -3
- package/dist/solution/ScanOrder/index.js +25 -64
- package/dist/solution/UnifiedBookingSales/index.d.ts +110 -73
- package/dist/solution/UnifiedBookingSales/index.js +3349 -971
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +133 -76
- package/dist/solution/UnifiedBookingSales/types.js +4 -9
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +37 -3
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +20 -1
- package/lib/modules/Order/index.js +393 -128
- package/lib/modules/Order/types.d.ts +6 -1
- package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/lib/modules/Order/utils/virtualSettlement.js +300 -0
- package/lib/modules/Order/utils.js +65 -21
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +5 -1
- package/lib/modules/Payment/walletpass.d.ts +11 -0
- package/lib/modules/Payment/walletpass.js +198 -17
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +15 -2
- package/lib/modules/ProductList/index.js +85 -3
- package/lib/modules/ResourcePlanner/index.d.ts +0 -22
- package/lib/modules/ResourcePlanner/index.js +0 -123
- package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/lib/modules/ResourcePlanner/localClock.js +270 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
- package/lib/modules/ResourcePlanner/planner.js +1903 -798
- package/lib/modules/ResourcePlanner/types.d.ts +346 -187
- package/lib/modules/ResourcePlanner/types.js +19 -0
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +10 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +25 -1
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +54 -14
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +66 -2
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +26 -2
- package/lib/solution/BaseSales/index.js +261 -23
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +61 -11
- package/lib/solution/BookingByStep/index.d.ts +4 -4
- package/lib/solution/BookingTicket/index.d.ts +5 -1
- package/lib/solution/BookingTicket/index.js +32 -3
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -1
- package/lib/solution/ScanOrder/index.js +17 -54
- package/lib/solution/UnifiedBookingSales/index.d.ts +110 -73
- package/lib/solution/UnifiedBookingSales/index.js +2289 -374
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +376 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +133 -76
- package/lib/solution/UnifiedBookingSales/types.js +3 -2
- package/package.json +1 -1
|
@@ -18,6 +18,19 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
18
18
|
* productList.updateOtherParams({ channel: 'pos' });
|
|
19
19
|
*/
|
|
20
20
|
updateOtherParams(params: Record<string, any>): void;
|
|
21
|
+
/**
|
|
22
|
+
* 判断当前商品查询是否会被本地 OS Server 接管。
|
|
23
|
+
*
|
|
24
|
+
* 不能只看请求参数中的 osServer=true:H5 RequestPlugin 会透传该参数,但仍然直接请求远端接口。
|
|
25
|
+
* 这里按 RequestPlugin 实际使用的 baseUrl 检查已注册路由,避免 OS Server 与客户端重复执行
|
|
26
|
+
* Data Variant 评估。
|
|
27
|
+
*/
|
|
28
|
+
private isProductQueryHandledByOsServer;
|
|
29
|
+
/**
|
|
30
|
+
* 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
|
|
31
|
+
* OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
|
|
32
|
+
*/
|
|
33
|
+
private resolveClientDataVariants;
|
|
21
34
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
22
35
|
/**
|
|
23
36
|
* 获取加时商品列表。
|
|
@@ -25,11 +38,11 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
25
38
|
* @example
|
|
26
39
|
* const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
|
|
27
40
|
*/
|
|
28
|
-
getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<
|
|
41
|
+
getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<ProductData[]>;
|
|
29
42
|
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, strategy_context, }?: ProductListLoadProductsParams, options?: {
|
|
30
43
|
callback?: (result: any) => void;
|
|
31
44
|
subscriberId?: string;
|
|
32
|
-
}): Promise<
|
|
45
|
+
}): Promise<ProductData[]>;
|
|
33
46
|
loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
|
|
34
47
|
ids?: number[];
|
|
35
48
|
customer_id?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
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
1
|
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; }
|
|
3
2
|
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; }
|
|
3
|
+
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); }
|
|
4
4
|
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; }
|
|
5
5
|
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); } }
|
|
6
6
|
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); }); }; }
|
|
@@ -78,6 +78,64 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
78
78
|
value: function updateOtherParams(params) {
|
|
79
79
|
this.otherParams = params || {};
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 判断当前商品查询是否会被本地 OS Server 接管。
|
|
84
|
+
*
|
|
85
|
+
* 不能只看请求参数中的 osServer=true:H5 RequestPlugin 会透传该参数,但仍然直接请求远端接口。
|
|
86
|
+
* 这里按 RequestPlugin 实际使用的 baseUrl 检查已注册路由,避免 OS Server 与客户端重复执行
|
|
87
|
+
* Data Variant 评估。
|
|
88
|
+
*/
|
|
89
|
+
}, {
|
|
90
|
+
key: "isProductQueryHandledByOsServer",
|
|
91
|
+
value: function isProductQueryHandledByOsServer() {
|
|
92
|
+
var _this$core, _this$request;
|
|
93
|
+
var server = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.server;
|
|
94
|
+
if (!server || typeof server.hasRoute !== 'function') return false;
|
|
95
|
+
var requestBaseUrl = String(((_this$request = this.request) === null || _this$request === void 0 ? void 0 : _this$request.baseUrl) || '/shop').replace(/\/+$/, '');
|
|
96
|
+
var routePath = "".concat(requestBaseUrl, "/product/query");
|
|
97
|
+
return server.hasRoute('post', routePath) === true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
|
|
102
|
+
* OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
|
|
103
|
+
*/
|
|
104
|
+
}, {
|
|
105
|
+
key: "resolveClientDataVariants",
|
|
106
|
+
value: function resolveClientDataVariants(products, queryPayload, handledByOsServer) {
|
|
107
|
+
var _this$core2, _this$otherParams, _scheduleModule$getSc, _this$core3, _this$core4, _this$otherParams2, _strategyContext$busi;
|
|
108
|
+
if (handledByOsServer || products.length === 0) return products;
|
|
109
|
+
var evaluator = (_this$core2 = this.core) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.context) === null || _this$core2 === void 0 ? void 0 : _this$core2.dataVariantEvaluator;
|
|
110
|
+
if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
|
|
111
|
+
return products;
|
|
112
|
+
}
|
|
113
|
+
var strategyContext = queryPayload.strategy_context && _typeof(queryPayload.strategy_context) === 'object' ? queryPayload.strategy_context : {};
|
|
114
|
+
var fatherModule = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.fatherModule) || '').trim();
|
|
115
|
+
var scheduleModule = (fatherModule ? this.core.getModule("".concat(fatherModule, "_schedule")) : null) || this.core.getModule('schedule');
|
|
116
|
+
var scheduleList = scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule);
|
|
117
|
+
var contextScheduleList = (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.scheduleList;
|
|
118
|
+
var contextMenuList = (_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.menuList;
|
|
119
|
+
var businessData = {
|
|
120
|
+
products: products,
|
|
121
|
+
scheduleDateTime: queryPayload.schedule_datetime || queryPayload.schedule_date,
|
|
122
|
+
scheduleList: Array.isArray(scheduleList) ? scheduleList : Array.isArray(contextScheduleList) ? contextScheduleList : [],
|
|
123
|
+
menuList: Array.isArray((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.menuList) ? this.otherParams.menuList : Array.isArray(contextMenuList) ? contextMenuList : [],
|
|
124
|
+
customerId: queryPayload.customer_id,
|
|
125
|
+
channel: strategyContext.channel,
|
|
126
|
+
orderType: strategyContext.orderType || strategyContext.order_type,
|
|
127
|
+
businessCode: (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : strategyContext.businessCode,
|
|
128
|
+
availableWalletIds: strategyContext.available_wallet_ids,
|
|
129
|
+
custom: strategyContext
|
|
130
|
+
};
|
|
131
|
+
try {
|
|
132
|
+
var _result = evaluator.resolveProducts(businessData);
|
|
133
|
+
return Array.isArray(_result === null || _result === void 0 ? void 0 : _result.products) ? _result.products : products;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error('[ProductList] Data Variant 客户端解析失败', error);
|
|
136
|
+
return products;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
81
139
|
}, {
|
|
82
140
|
key: "storeChange",
|
|
83
141
|
value: function () {
|
|
@@ -132,7 +190,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
132
190
|
key: "loadProducts",
|
|
133
191
|
value: function () {
|
|
134
192
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
135
|
-
var _this$
|
|
193
|
+
var _this$otherParams3,
|
|
194
|
+
_this2 = this;
|
|
136
195
|
var _ref,
|
|
137
196
|
_ref$category_ids,
|
|
138
197
|
category_ids,
|
|
@@ -161,7 +220,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
161
220
|
rawApplicationCode,
|
|
162
221
|
mappedApplicationCode,
|
|
163
222
|
queryPayload,
|
|
223
|
+
handledByOsServer,
|
|
224
|
+
callback,
|
|
164
225
|
productsData,
|
|
226
|
+
resolvedList,
|
|
165
227
|
sortedList,
|
|
166
228
|
_args4 = arguments;
|
|
167
229
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
@@ -196,7 +258,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
258
|
scan_to_order_2: 'mobile_order',
|
|
197
259
|
scan_to_order_3: 'scantoorder3'
|
|
198
260
|
};
|
|
199
|
-
rawApplicationCode = (_this$
|
|
261
|
+
rawApplicationCode = (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
|
|
200
262
|
mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
|
|
201
263
|
queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
202
264
|
open_quotation: 1,
|
|
@@ -225,18 +287,35 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
225
287
|
is_eject: 1,
|
|
226
288
|
with_schedule: with_schedule,
|
|
227
289
|
schedule_datetime: schedule_datetime,
|
|
228
|
-
extension_type: extension_type
|
|
290
|
+
extension_type: extension_type,
|
|
291
|
+
strategy_context: strategy_context
|
|
229
292
|
});
|
|
230
|
-
|
|
293
|
+
handledByOsServer = this.isProductQueryHandledByOsServer();
|
|
294
|
+
callback = !handledByOsServer && typeof (options === null || options === void 0 ? void 0 : options.callback) === 'function' ? function (result) {
|
|
295
|
+
var _result$data, _options$callback2;
|
|
296
|
+
var callbackList = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list;
|
|
297
|
+
if (!Array.isArray(callbackList)) {
|
|
298
|
+
var _options$callback;
|
|
299
|
+
(_options$callback = options.callback) === null || _options$callback === void 0 || _options$callback.call(options, result);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
(_options$callback2 = options.callback) === null || _options$callback2 === void 0 || _options$callback2.call(options, _objectSpread(_objectSpread({}, result), {}, {
|
|
303
|
+
data: _objectSpread(_objectSpread({}, result.data), {}, {
|
|
304
|
+
list: _this2.resolveClientDataVariants(callbackList, queryPayload, false)
|
|
305
|
+
})
|
|
306
|
+
}));
|
|
307
|
+
} : options === null || options === void 0 ? void 0 : options.callback;
|
|
308
|
+
_context4.next = 13;
|
|
231
309
|
return this.request.post("/product/query", queryPayload, {
|
|
232
310
|
osServer: true,
|
|
233
|
-
callback:
|
|
311
|
+
callback: callback,
|
|
234
312
|
subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
|
|
235
313
|
customToast: function customToast() {}
|
|
236
314
|
});
|
|
237
|
-
case
|
|
315
|
+
case 13:
|
|
238
316
|
productsData = _context4.sent;
|
|
239
|
-
|
|
317
|
+
resolvedList = this.resolveClientDataVariants(productsData.data.list || [], queryPayload, handledByOsServer);
|
|
318
|
+
sortedList = resolvedList.slice().sort(function (a, b) {
|
|
240
319
|
return Number(b.sort) - Number(a.sort);
|
|
241
320
|
}); // if (sortedList.length) {
|
|
242
321
|
// sortedList.forEach((n: any) => {
|
|
@@ -247,7 +326,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
247
326
|
// }
|
|
248
327
|
this.addProduct(sortedList);
|
|
249
328
|
return _context4.abrupt("return", sortedList);
|
|
250
|
-
case
|
|
329
|
+
case 18:
|
|
251
330
|
case "end":
|
|
252
331
|
return _context4.stop();
|
|
253
332
|
}
|
|
@@ -368,7 +447,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
368
447
|
key: "addProduct",
|
|
369
448
|
value: function () {
|
|
370
449
|
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(products) {
|
|
371
|
-
var
|
|
450
|
+
var _this3 = this;
|
|
372
451
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
373
452
|
while (1) switch (_context9.prev = _context9.next) {
|
|
374
453
|
case 0:
|
|
@@ -377,13 +456,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
377
456
|
this.store.list = [];
|
|
378
457
|
}
|
|
379
458
|
products.forEach(function (n) {
|
|
380
|
-
var index =
|
|
459
|
+
var index = _this3.store.list.findIndex(function (m) {
|
|
381
460
|
return m.id === n.id;
|
|
382
461
|
});
|
|
383
462
|
if (index === -1) {
|
|
384
|
-
|
|
463
|
+
_this3.store.list.push(n);
|
|
385
464
|
} else {
|
|
386
|
-
|
|
465
|
+
_this3.store.list[index] = n;
|
|
387
466
|
}
|
|
388
467
|
});
|
|
389
468
|
// 根据 sort 值做降序排序(数字越大越靠前)
|
|
@@ -1,24 +1,2 @@
|
|
|
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
1
|
export * from './types';
|
|
5
2
|
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 +1,2 @@
|
|
|
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
1
|
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);
|
|
2
|
+
export * from "./planner";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface LocalDateParts {
|
|
2
|
+
year: number;
|
|
3
|
+
month: number;
|
|
4
|
+
day: number;
|
|
5
|
+
}
|
|
6
|
+
export interface LocalDateTimeParts extends LocalDateParts {
|
|
7
|
+
hour: number;
|
|
8
|
+
minute: number;
|
|
9
|
+
second: number;
|
|
10
|
+
}
|
|
11
|
+
type LocalDateInput = string | LocalDateParts;
|
|
12
|
+
type LocalDateTimeInput = string | number | LocalDateTimeParts;
|
|
13
|
+
export declare function parseLocalDate(value: string): LocalDateParts;
|
|
14
|
+
export declare function parseLocalDateTime(value: string): LocalDateTimeParts;
|
|
15
|
+
export declare function extractFixedOffsetMinutes(value: string | null | undefined): number | null;
|
|
16
|
+
export declare function captureRuntimeOffsetMinutes(value?: Date): number;
|
|
17
|
+
export declare function formatFixedOffset(offsetMinutes: number | null | undefined): string;
|
|
18
|
+
export declare function localDateTimeToScalar(value: LocalDateTimeParts): number;
|
|
19
|
+
export declare function localDateToScalar(value: Date): number;
|
|
20
|
+
export declare function localDateToScalarStart(value: LocalDateInput): number;
|
|
21
|
+
export declare function scalarToLocalDateParts(value: number): LocalDateParts;
|
|
22
|
+
export declare function scalarToLocalDateTimeParts(value: number): LocalDateTimeParts;
|
|
23
|
+
export declare function dateOrdinalFromLocalDate(value: LocalDateInput): number;
|
|
24
|
+
export declare function weekdayFromLocalDate(value: LocalDateInput): number;
|
|
25
|
+
export declare function formatLocalDate(value: LocalDateInput | number): string;
|
|
26
|
+
export declare function formatLocalTime(value: LocalDateTimeInput, includeSeconds?: boolean): string;
|
|
27
|
+
export declare function formatLocalDateTime(value: LocalDateTimeInput, fixedOffsetMinutes?: number | null): string;
|
|
28
|
+
export declare function addLocalMinutes(value: number, minutes: number): number;
|
|
29
|
+
export declare function addLocalHours(value: number, hours: number): number;
|
|
30
|
+
export declare function addLocalCalendarDays(value: number, days: number): number;
|
|
31
|
+
export declare function nextDate(value: LocalDateInput): string;
|
|
32
|
+
export declare function ceilLocalScalarToTenMinutes(value: number): number;
|
|
33
|
+
export {};
|