@pisell/pisellos 2.2.291 → 2.2.293

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 (174) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +108 -65
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  8. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  9. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  10. package/dist/modules/BookingContext/index.d.ts +3 -0
  11. package/dist/modules/BookingContext/index.js +42 -13
  12. package/dist/modules/BookingContext/types.d.ts +4 -4
  13. package/dist/modules/BookingContext/types.js +3 -3
  14. package/dist/modules/OpenData/types.d.ts +1 -0
  15. package/dist/modules/Order/index.d.ts +18 -3
  16. package/dist/modules/Order/index.js +885 -485
  17. package/dist/modules/Order/salesNotes.d.ts +31 -0
  18. package/dist/modules/Order/salesNotes.js +492 -0
  19. package/dist/modules/Order/types.d.ts +93 -5
  20. package/dist/modules/Order/types.js +5 -0
  21. package/dist/modules/Order/utils.d.ts +12 -0
  22. package/dist/modules/Order/utils.js +96 -31
  23. package/dist/modules/Product/types.d.ts +2 -0
  24. package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
  25. package/dist/modules/ProductList/clientDataVariants.js +216 -0
  26. package/dist/modules/ProductList/index.d.ts +18 -3
  27. package/dist/modules/ProductList/index.js +220 -38
  28. package/dist/modules/ProductList/types.d.ts +10 -0
  29. package/dist/modules/Quotation/index.d.ts +22 -0
  30. package/dist/modules/Quotation/index.js +293 -28
  31. package/dist/modules/ResourcePlanner/index.d.ts +0 -22
  32. package/dist/modules/ResourcePlanner/index.js +1 -180
  33. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  34. package/dist/modules/ResourcePlanner/localClock.js +183 -0
  35. package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
  36. package/dist/modules/ResourcePlanner/planner.js +2111 -958
  37. package/dist/modules/ResourcePlanner/types.d.ts +359 -187
  38. package/dist/modules/ResourcePlanner/types.js +33 -1
  39. package/dist/plugins/request.d.ts +1 -0
  40. package/dist/server/index.d.ts +17 -2
  41. package/dist/server/index.js +1134 -932
  42. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  43. package/dist/server/modules/floor-plan/index.js +240 -98
  44. package/dist/server/modules/menu/index.js +48 -23
  45. package/dist/server/modules/order/index.d.ts +17 -7
  46. package/dist/server/modules/order/index.js +419 -207
  47. package/dist/server/modules/products/index.d.ts +10 -4
  48. package/dist/server/modules/products/index.js +177 -84
  49. package/dist/server/modules/resource/index.js +21 -13
  50. package/dist/server/utils/product.d.ts +1 -1
  51. package/dist/server/utils/product.js +186 -22
  52. package/dist/server/utils/small-ticket.d.ts +9 -1
  53. package/dist/server/utils/small-ticket.js +131 -84
  54. package/dist/solution/BaseSales/index.d.ts +26 -3
  55. package/dist/solution/BaseSales/index.js +1384 -905
  56. package/dist/solution/BaseSales/types.d.ts +2 -0
  57. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  58. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +10 -3
  59. package/dist/solution/BaseSales/utils.js +6 -3
  60. package/dist/solution/BookingByStep/index.d.ts +4 -4
  61. package/dist/solution/BookingTicket/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.js +4 -2
  63. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  64. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -3
  65. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  66. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  67. package/dist/solution/RegisterAndLogin/config.js +95 -40
  68. package/dist/solution/RegisterAndLogin/index.js +4 -1
  69. package/dist/solution/ScanOrder/index.d.ts +1 -0
  70. package/dist/solution/ScanOrder/index.js +31 -27
  71. package/dist/solution/ScanOrder/types.d.ts +2 -0
  72. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  73. package/dist/solution/ScanOrder/utils.js +8 -3
  74. package/dist/solution/UnifiedBookingSales/index.d.ts +128 -74
  75. package/dist/solution/UnifiedBookingSales/index.js +3877 -963
  76. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  77. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
  78. package/dist/solution/UnifiedBookingSales/types.d.ts +161 -77
  79. package/dist/solution/UnifiedBookingSales/types.js +4 -9
  80. package/dist/solution/VenueBooking/index.d.ts +3 -0
  81. package/dist/solution/VenueBooking/index.js +549 -497
  82. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  83. package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
  84. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  85. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
  86. package/dist/utils/platform.d.ts +8 -0
  87. package/dist/utils/platform.js +15 -0
  88. package/lib/core/index.d.ts +7 -0
  89. package/lib/core/index.js +20 -2
  90. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  92. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  93. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  94. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  95. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  96. package/lib/modules/BookingContext/index.d.ts +3 -0
  97. package/lib/modules/BookingContext/index.js +35 -8
  98. package/lib/modules/BookingContext/types.d.ts +4 -4
  99. package/lib/modules/BookingContext/types.js +3 -3
  100. package/lib/modules/OpenData/types.d.ts +1 -0
  101. package/lib/modules/Order/index.d.ts +18 -3
  102. package/lib/modules/Order/index.js +325 -28
  103. package/lib/modules/Order/salesNotes.d.ts +31 -0
  104. package/lib/modules/Order/salesNotes.js +382 -0
  105. package/lib/modules/Order/types.d.ts +93 -5
  106. package/lib/modules/Order/types.js +4 -0
  107. package/lib/modules/Order/utils.d.ts +12 -0
  108. package/lib/modules/Order/utils.js +85 -16
  109. package/lib/modules/Product/types.d.ts +2 -0
  110. package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
  111. package/lib/modules/ProductList/clientDataVariants.js +204 -0
  112. package/lib/modules/ProductList/index.d.ts +18 -3
  113. package/lib/modules/ProductList/index.js +137 -8
  114. package/lib/modules/ProductList/types.d.ts +10 -0
  115. package/lib/modules/Quotation/index.d.ts +22 -0
  116. package/lib/modules/Quotation/index.js +158 -11
  117. package/lib/modules/ResourcePlanner/index.d.ts +0 -22
  118. package/lib/modules/ResourcePlanner/index.js +9 -129
  119. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  120. package/lib/modules/ResourcePlanner/localClock.js +205 -0
  121. package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
  122. package/lib/modules/ResourcePlanner/planner.js +1807 -783
  123. package/lib/modules/ResourcePlanner/types.d.ts +359 -187
  124. package/lib/modules/ResourcePlanner/types.js +13 -1
  125. package/lib/plugins/request.d.ts +1 -0
  126. package/lib/server/index.d.ts +17 -2
  127. package/lib/server/index.js +149 -21
  128. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  129. package/lib/server/modules/floor-plan/index.js +60 -7
  130. package/lib/server/modules/menu/index.js +26 -4
  131. package/lib/server/modules/order/index.d.ts +17 -7
  132. package/lib/server/modules/order/index.js +194 -57
  133. package/lib/server/modules/products/index.d.ts +10 -4
  134. package/lib/server/modules/products/index.js +93 -23
  135. package/lib/server/modules/resource/index.js +12 -2
  136. package/lib/server/utils/product.d.ts +1 -1
  137. package/lib/server/utils/product.js +163 -3
  138. package/lib/server/utils/small-ticket.d.ts +9 -1
  139. package/lib/server/utils/small-ticket.js +123 -79
  140. package/lib/solution/BaseSales/index.d.ts +26 -3
  141. package/lib/solution/BaseSales/index.js +396 -70
  142. package/lib/solution/BaseSales/types.d.ts +2 -0
  143. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  144. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +9 -2
  145. package/lib/solution/BaseSales/utils.js +3 -0
  146. package/lib/solution/BookingByStep/index.d.ts +4 -4
  147. package/lib/solution/BookingTicket/index.d.ts +1 -1
  148. package/lib/solution/BookingTicket/index.js +2 -1
  149. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  150. package/lib/solution/BookingTicket/utils/addProductDecision.js +5 -2
  151. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  152. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  153. package/lib/solution/RegisterAndLogin/config.js +49 -8
  154. package/lib/solution/RegisterAndLogin/index.js +4 -1
  155. package/lib/solution/ScanOrder/index.d.ts +1 -0
  156. package/lib/solution/ScanOrder/index.js +5 -1
  157. package/lib/solution/ScanOrder/types.d.ts +2 -0
  158. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  159. package/lib/solution/ScanOrder/utils.js +4 -0
  160. package/lib/solution/UnifiedBookingSales/index.d.ts +128 -74
  161. package/lib/solution/UnifiedBookingSales/index.js +2592 -424
  162. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  163. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +316 -0
  164. package/lib/solution/UnifiedBookingSales/types.d.ts +161 -77
  165. package/lib/solution/UnifiedBookingSales/types.js +4 -6
  166. package/lib/solution/VenueBooking/index.d.ts +3 -0
  167. package/lib/solution/VenueBooking/index.js +33 -9
  168. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  169. package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
  170. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  171. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
  172. package/lib/utils/platform.d.ts +8 -0
  173. package/lib/utils/platform.js +22 -0
  174. package/package.json +1 -1
@@ -2,7 +2,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  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
3
  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; }
4
4
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
+ 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."); }
5
7
  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); }
8
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
10
  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; }
7
11
  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; }
8
12
  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); } }
@@ -36,12 +40,20 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
36
40
  list: []
37
41
  });
38
42
  _defineProperty(_assertThisInitialized(_this), "scheduleResolver", void 0);
43
+ _defineProperty(_assertThisInitialized(_this), "app", void 0);
44
+ _defineProperty(_assertThisInitialized(_this), "quotationListUpdatedListener", void 0);
45
+ _defineProperty(_assertThisInitialized(_this), "quotationCache", new Map());
46
+ _defineProperty(_assertThisInitialized(_this), "quotationLoadPromises", new Map());
47
+ _defineProperty(_assertThisInitialized(_this), "quotationCacheVersions", new Map());
48
+ _defineProperty(_assertThisInitialized(_this), "lifecycleGeneration", 0);
49
+ _defineProperty(_assertThisInitialized(_this), "activeChannelKey", '');
39
50
  return _this;
40
51
  }
41
52
  _createClass(QuotationModule, [{
42
53
  key: "initialize",
43
54
  value: function () {
44
55
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
56
+ var _core$getPlugin, _core$getPlugin$getAp;
45
57
  return _regeneratorRuntime().wrap(function _callee$(_context) {
46
58
  while (1) switch (_context.prev = _context.next) {
47
59
  case 0:
@@ -53,10 +65,16 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
53
65
  }
54
66
  throw new Error('QuotationModule 需要 request 插件支持');
55
67
  case 4:
68
+ this.app = (_core$getPlugin = core.getPlugin('app')) === null || _core$getPlugin === void 0 || (_core$getPlugin$getAp = _core$getPlugin.getApp) === null || _core$getPlugin$getAp === void 0 ? void 0 : _core$getPlugin$getAp.call(_core$getPlugin);
56
69
  this.store = {
57
70
  list: []
58
71
  };
59
- case 5:
72
+ this.quotationCache.clear();
73
+ this.quotationLoadPromises.clear();
74
+ this.quotationCacheVersions.clear();
75
+ this.activeChannelKey = '';
76
+ this.lifecycleGeneration += 1;
77
+ case 11:
60
78
  case "end":
61
79
  return _context.stop();
62
80
  }
@@ -71,48 +89,227 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
71
89
  key: "loadQuotations",
72
90
  value: function () {
73
91
  var _loadQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
74
- var _data;
75
- var query, res, list;
92
+ var channelKey, cacheVersion, lifecycleGeneration, loadPromise;
76
93
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
77
94
  while (1) switch (_context2.prev = _context2.next) {
78
95
  case 0:
79
- query = {};
80
- if (params !== null && params !== void 0 && params.channel) query.channel = params.channel;
81
- if ((params === null || params === void 0 ? void 0 : params.channel) === 'online_store') {
82
- query.channel = 'online-store';
83
- }
84
- _context2.next = 5;
85
- return this.request.get('/quotation/available', query, {
86
- useCache: false,
87
- osServer: true
88
- });
89
- case 5:
90
- res = _context2.sent;
91
- list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
92
- list.sort(function (a, b) {
93
- return b.sort - a.sort;
96
+ channelKey = this.normalizeChannel(params === null || params === void 0 ? void 0 : params.channel);
97
+ cacheVersion = this.bumpQuotationCacheVersion(channelKey);
98
+ lifecycleGeneration = this.lifecycleGeneration;
99
+ this.activateChannel(channelKey);
100
+ loadPromise = this.fetchQuotations({
101
+ channelKey: channelKey,
102
+ cacheVersion: cacheVersion,
103
+ lifecycleGeneration: lifecycleGeneration
94
104
  });
95
- this.store.list = list;
105
+ this.quotationLoadPromises.set(channelKey, loadPromise);
106
+ _context2.prev = 6;
107
+ _context2.next = 9;
108
+ return loadPromise;
96
109
  case 9:
110
+ _context2.prev = 9;
111
+ if (this.quotationLoadPromises.get(channelKey) === loadPromise) {
112
+ this.quotationLoadPromises.delete(channelKey);
113
+ }
114
+ return _context2.finish(9);
115
+ case 12:
97
116
  case "end":
98
117
  return _context2.stop();
99
118
  }
100
- }, _callee2, this);
119
+ }, _callee2, this, [[6,, 9, 12]]);
101
120
  }));
102
121
  function loadQuotations(_x3) {
103
122
  return _loadQuotations.apply(this, arguments);
104
123
  }
105
124
  return loadQuotations;
106
125
  }()
126
+ }, {
127
+ key: "ensureQuotations",
128
+ value: function () {
129
+ var _ensureQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
130
+ var channelKey, lifecycleGeneration, pending, cacheVersion, _latestPending, latestPending;
131
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
132
+ while (1) switch (_context3.prev = _context3.next) {
133
+ case 0:
134
+ channelKey = this.normalizeChannel(params === null || params === void 0 ? void 0 : params.channel);
135
+ lifecycleGeneration = this.lifecycleGeneration;
136
+ case 2:
137
+ if (!true) {
138
+ _context3.next = 46;
139
+ break;
140
+ }
141
+ if (!(this.lifecycleGeneration !== lifecycleGeneration)) {
142
+ _context3.next = 5;
143
+ break;
144
+ }
145
+ return _context3.abrupt("return");
146
+ case 5:
147
+ if (!this.quotationCache.has(channelKey)) {
148
+ _context3.next = 8;
149
+ break;
150
+ }
151
+ this.activateChannel(channelKey);
152
+ return _context3.abrupt("return");
153
+ case 8:
154
+ pending = this.quotationLoadPromises.get(channelKey);
155
+ if (pending) {
156
+ _context3.next = 24;
157
+ break;
158
+ }
159
+ _context3.prev = 10;
160
+ _context3.next = 13;
161
+ return this.loadQuotations(params);
162
+ case 13:
163
+ _context3.next = 23;
164
+ break;
165
+ case 15:
166
+ _context3.prev = 15;
167
+ _context3.t0 = _context3["catch"](10);
168
+ if (!this.quotationCache.has(channelKey)) {
169
+ _context3.next = 20;
170
+ break;
171
+ }
172
+ this.activateChannel(channelKey);
173
+ return _context3.abrupt("return");
174
+ case 20:
175
+ if (!this.quotationLoadPromises.has(channelKey)) {
176
+ _context3.next = 22;
177
+ break;
178
+ }
179
+ return _context3.abrupt("continue", 2);
180
+ case 22:
181
+ throw _context3.t0;
182
+ case 23:
183
+ return _context3.abrupt("continue", 2);
184
+ case 24:
185
+ cacheVersion = this.getQuotationCacheVersion(channelKey);
186
+ _context3.prev = 25;
187
+ _context3.next = 28;
188
+ return pending;
189
+ case 28:
190
+ _context3.next = 38;
191
+ break;
192
+ case 30:
193
+ _context3.prev = 30;
194
+ _context3.t1 = _context3["catch"](25);
195
+ _latestPending = this.quotationLoadPromises.get(channelKey);
196
+ if (!(_latestPending && _latestPending !== pending)) {
197
+ _context3.next = 35;
198
+ break;
199
+ }
200
+ return _context3.abrupt("continue", 2);
201
+ case 35:
202
+ if (!(this.getQuotationCacheVersion(channelKey) !== cacheVersion)) {
203
+ _context3.next = 37;
204
+ break;
205
+ }
206
+ return _context3.abrupt("continue", 2);
207
+ case 37:
208
+ throw _context3.t1;
209
+ case 38:
210
+ if (!this.quotationCache.has(channelKey)) {
211
+ _context3.next = 41;
212
+ break;
213
+ }
214
+ this.activateChannel(channelKey);
215
+ return _context3.abrupt("return");
216
+ case 41:
217
+ latestPending = this.quotationLoadPromises.get(channelKey);
218
+ if (!(latestPending && latestPending !== pending)) {
219
+ _context3.next = 44;
220
+ break;
221
+ }
222
+ return _context3.abrupt("continue", 2);
223
+ case 44:
224
+ _context3.next = 2;
225
+ break;
226
+ case 46:
227
+ case "end":
228
+ return _context3.stop();
229
+ }
230
+ }, _callee3, this, [[10, 15], [25, 30]]);
231
+ }));
232
+ function ensureQuotations(_x4) {
233
+ return _ensureQuotations.apply(this, arguments);
234
+ }
235
+ return ensureQuotations;
236
+ }()
237
+ }, {
238
+ key: "invalidateQuotationCache",
239
+ value: function invalidateQuotationCache(channel) {
240
+ var _this2 = this;
241
+ if (channel !== undefined) {
242
+ var channelKey = this.normalizeChannel(channel);
243
+ this.bumpQuotationCacheVersion(channelKey);
244
+ this.quotationCache.delete(channelKey);
245
+ this.quotationLoadPromises.delete(channelKey);
246
+ if (this.activeChannelKey === channelKey) this.store.list = [];
247
+ return;
248
+ }
249
+ var channelKeys = new Set([].concat(_toConsumableArray(this.quotationCache.keys()), _toConsumableArray(this.quotationLoadPromises.keys()), _toConsumableArray(this.quotationCacheVersions.keys()), [this.activeChannelKey]));
250
+ channelKeys.forEach(function (channelKey) {
251
+ return _this2.bumpQuotationCacheVersion(channelKey);
252
+ });
253
+ this.quotationCache.clear();
254
+ this.quotationLoadPromises.clear();
255
+ this.store.list = [];
256
+ }
257
+ }, {
258
+ key: "fetchQuotations",
259
+ value: function () {
260
+ var _fetchQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
261
+ var _this3 = this;
262
+ var query, initialResultApplied, applyRemoteUpdate, res;
263
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
264
+ while (1) switch (_context4.prev = _context4.next) {
265
+ case 0:
266
+ query = {};
267
+ if (params.channelKey) query.channel = params.channelKey;
268
+ initialResultApplied = false;
269
+ applyRemoteUpdate = function applyRemoteUpdate(response) {
270
+ var applied = _this3.applyQuotationResponse(response, params);
271
+ if (applied && initialResultApplied && _this3.activeChannelKey === params.channelKey) {
272
+ _this3.notifyQuotationListUpdated();
273
+ }
274
+ };
275
+ _context4.next = 6;
276
+ return this.request.get('/quotation/available', query, {
277
+ cache: {
278
+ type: 'indexDB',
279
+ updateCache: true,
280
+ cacheKeyData: this.getQuotationCacheKeyData(query)
281
+ },
282
+ cacheUpdateChange: applyRemoteUpdate
283
+ });
284
+ case 6:
285
+ res = _context4.sent;
286
+ this.applyQuotationResponse(res, params);
287
+ initialResultApplied = true;
288
+ case 9:
289
+ case "end":
290
+ return _context4.stop();
291
+ }
292
+ }, _callee4, this);
293
+ }));
294
+ function fetchQuotations(_x5) {
295
+ return _fetchQuotations.apply(this, arguments);
296
+ }
297
+ return fetchQuotations;
298
+ }()
107
299
  }, {
108
300
  key: "getQuotationList",
109
301
  value: function getQuotationList() {
110
302
  return this.store.list;
111
303
  }
304
+ }, {
305
+ key: "setQuotationListUpdatedListener",
306
+ value: function setQuotationListUpdatedListener(listener) {
307
+ this.quotationListUpdatedListener = listener;
308
+ }
112
309
  }, {
113
310
  key: "getQuotationCustomerScopeInfo",
114
311
  value: function getQuotationCustomerScopeInfo() {
115
- var _this2 = this;
312
+ var _this4 = this;
116
313
  var customerById = new Map();
117
314
  var quotationScopes = this.store.list.filter(function (quotation) {
118
315
  return Array.isArray(quotation.customer) && quotation.customer.length > 0;
@@ -122,7 +319,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
122
319
  var localSeen = new Set();
123
320
  var quotationCustomers = quotation.customer || [];
124
321
  quotationCustomers.forEach(function (customer) {
125
- var customerId = _this2.normalizeCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
322
+ var customerId = _this4.normalizeCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
126
323
  if (!customerId || localSeen.has(customerId)) return;
127
324
  localSeen.add(customerId);
128
325
  customerIds.push(customerId);
@@ -168,7 +365,8 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
168
365
  variantId = params.variantId,
169
366
  datetime = params.datetime,
170
367
  customer_id = params.customer_id;
171
- var _iterator = _createForOfIteratorHelper(this.store.list),
368
+ var quotations = params.channel === undefined ? this.store.list : this.quotationCache.get(this.normalizeChannel(params.channel)) || [];
369
+ var _iterator = _createForOfIteratorHelper(quotations),
172
370
  _step;
173
371
  try {
174
372
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -208,7 +406,8 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
208
406
  key: "buildProductPriceMap",
209
407
  value: function buildProductPriceMap(params) {
210
408
  var map = new Map();
211
- if (!this.store.list.length) return map;
409
+ var quotations = params.channel === undefined ? this.store.list : this.quotationCache.get(this.normalizeChannel(params.channel)) || [];
410
+ if (!quotations.length) return map;
212
411
  var _iterator2 = _createForOfIteratorHelper(params.productIds),
213
412
  _step2;
214
413
  try {
@@ -223,6 +422,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
223
422
  var price = this.getPriceForProduct({
224
423
  productId: productId,
225
424
  datetime: timePoint,
425
+ channel: params.channel,
226
426
  customer_id: params.customer_id
227
427
  });
228
428
  if (price !== null) {
@@ -247,6 +447,71 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
247
447
  value: function setScheduleResolver(resolver) {
248
448
  this.scheduleResolver = resolver;
249
449
  }
450
+ }, {
451
+ key: "applyQuotationResponse",
452
+ value: function applyQuotationResponse(response, params) {
453
+ var _data;
454
+ var source = (response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
455
+ var list = _toConsumableArray(source).sort(function (a, b) {
456
+ return Number(b.sort || 0) - Number(a.sort || 0);
457
+ });
458
+ if (this.lifecycleGeneration !== params.lifecycleGeneration || this.getQuotationCacheVersion(params.channelKey) !== params.cacheVersion) {
459
+ return false;
460
+ }
461
+ this.quotationCache.set(params.channelKey, list);
462
+ if (this.activeChannelKey === params.channelKey) this.store.list = list;
463
+ return true;
464
+ }
465
+ }, {
466
+ key: "notifyQuotationListUpdated",
467
+ value: function notifyQuotationListUpdated() {
468
+ try {
469
+ var _this$quotationListUp;
470
+ (_this$quotationListUp = this.quotationListUpdatedListener) === null || _this$quotationListUp === void 0 || _this$quotationListUp.call(this);
471
+ } catch (error) {
472
+ console.warn('[QuotationModule] 报价单后台更新回调失败', error);
473
+ }
474
+ }
475
+ }, {
476
+ key: "getQuotationCacheKeyData",
477
+ value: function getQuotationCacheKeyData(query) {
478
+ var shopId = '';
479
+ try {
480
+ var _this$app, _this$app$getStorage;
481
+ var storedCore = (_this$app = this.app) === null || _this$app === void 0 || (_this$app = _this$app.storage) === null || _this$app === void 0 || (_this$app$getStorage = _this$app.getStorage) === null || _this$app$getStorage === void 0 ? void 0 : _this$app$getStorage.call(_this$app, 'core');
482
+ var coreInfo = typeof storedCore === 'string' ? JSON.parse(storedCore || '{}') : storedCore || {};
483
+ shopId = String((coreInfo === null || coreInfo === void 0 ? void 0 : coreInfo.id) || '');
484
+ } catch (_unused) {
485
+ // 缓存隔离信息读取失败时仍按请求参数缓存。
486
+ }
487
+ return _objectSpread(_objectSpread({}, query), {}, {
488
+ shop_id: shopId
489
+ });
490
+ }
491
+ }, {
492
+ key: "normalizeChannel",
493
+ value: function normalizeChannel(channel) {
494
+ var normalized = (channel === null || channel === void 0 ? void 0 : channel.trim().toLowerCase()) || '';
495
+ return normalized === 'online_store' ? 'online-store' : normalized;
496
+ }
497
+ }, {
498
+ key: "activateChannel",
499
+ value: function activateChannel(channelKey) {
500
+ this.activeChannelKey = channelKey;
501
+ this.store.list = this.quotationCache.get(channelKey) || [];
502
+ }
503
+ }, {
504
+ key: "getQuotationCacheVersion",
505
+ value: function getQuotationCacheVersion(channelKey) {
506
+ return this.quotationCacheVersions.get(channelKey) || 0;
507
+ }
508
+ }, {
509
+ key: "bumpQuotationCacheVersion",
510
+ value: function bumpQuotationCacheVersion(channelKey) {
511
+ var nextVersion = this.getQuotationCacheVersion(channelKey) + 1;
512
+ this.quotationCacheVersions.set(channelKey, nextVersion);
513
+ return nextVersion;
514
+ }
250
515
  }, {
251
516
  key: "isQuotationVisibleForCustomer",
252
517
  value: function isQuotationVisibleForCustomer(quotation, customerId) {
@@ -273,17 +538,17 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
273
538
  key: "isQuotationActiveAt",
274
539
  value: function isQuotationActiveAt(quotation, datetime) {
275
540
  var _quotation$schedule,
276
- _this3 = this;
541
+ _this5 = this;
277
542
  if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
278
543
  var scheduleItems = [];
279
544
  quotation.schedule.forEach(function (s) {
280
- var _this3$scheduleResolv;
281
- var full = (_this3$scheduleResolv = _this3.scheduleResolver) === null || _this3$scheduleResolv === void 0 ? void 0 : _this3$scheduleResolv.call(_this3, s.id);
545
+ var _this5$scheduleResolv;
546
+ var full = (_this5$scheduleResolv = _this5.scheduleResolver) === null || _this5$scheduleResolv === void 0 ? void 0 : _this5$scheduleResolv.call(_this5, s.id);
282
547
  if (full) {
283
548
  scheduleItems.push(full);
284
549
  return;
285
550
  }
286
- if (_this3.scheduleResolver) {
551
+ if (_this5.scheduleResolver) {
287
552
  return;
288
553
  }
289
554
  var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
@@ -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
- }