@pisell/pisellos 2.2.314 → 2.2.315

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 (214) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  8. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  9. package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
  10. package/dist/modules/BookingContext/utils/productExtend.js +62 -18
  11. package/dist/modules/BookingContext/utils/resources.js +1 -1
  12. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  13. package/dist/modules/BusinessAvailability/index.js +204 -0
  14. package/dist/modules/Cart/index.js +4 -3
  15. package/dist/modules/Cart/types.d.ts +2 -0
  16. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  17. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  18. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  19. package/dist/modules/FulfillmentTiming/index.js +407 -0
  20. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  21. package/dist/modules/FulfillmentTiming/types.js +1 -0
  22. package/dist/modules/OpenData/types.d.ts +14 -0
  23. package/dist/modules/Order/index.d.ts +14 -2
  24. package/dist/modules/Order/index.js +856 -486
  25. package/dist/modules/Order/localEftposState.d.ts +13 -0
  26. package/dist/modules/Order/localEftposState.js +39 -0
  27. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  28. package/dist/modules/Order/pickupTiming.js +53 -0
  29. package/dist/modules/Order/types.d.ts +30 -2
  30. package/dist/modules/Order/utils.js +25 -7
  31. package/dist/modules/Payment/index.js +9 -10
  32. package/dist/modules/Product/types.d.ts +11 -0
  33. package/dist/modules/ProductList/index.js +1 -1
  34. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  35. package/dist/modules/ResourcePlanner/planner.js +332 -23
  36. package/dist/modules/ResourcePlanner/types.d.ts +29 -0
  37. package/dist/modules/Schedule/index.d.ts +8 -0
  38. package/dist/modules/Schedule/index.js +141 -39
  39. package/dist/modules/index.d.ts +1 -0
  40. package/dist/modules/index.js +1 -0
  41. package/dist/plugins/request.d.ts +7 -0
  42. package/dist/server/index.d.ts +1 -0
  43. package/dist/server/index.js +1536 -1309
  44. package/dist/server/modules/form/index.d.ts +19 -0
  45. package/dist/server/modules/form/index.js +205 -0
  46. package/dist/server/modules/form/types.d.ts +13 -0
  47. package/dist/server/modules/form/types.js +3 -0
  48. package/dist/server/modules/index.d.ts +3 -0
  49. package/dist/server/modules/index.js +4 -0
  50. package/dist/server/modules/order/index.d.ts +15 -0
  51. package/dist/server/modules/order/index.js +920 -688
  52. package/dist/server/modules/order/types.d.ts +1 -0
  53. package/dist/server/test.json +1 -1
  54. package/dist/server/utils/small-ticket.d.ts +1 -85
  55. package/dist/server/utils/small-ticket.js +2 -2542
  56. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  57. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  58. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  59. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  60. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  61. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
  62. package/dist/shared/receipt/small-ticket.d.ts +96 -0
  63. package/dist/shared/receipt/small-ticket.js +2751 -0
  64. package/dist/shared/receipt/templateVisibility.d.ts +23 -0
  65. package/dist/shared/receipt/templateVisibility.js +64 -0
  66. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  67. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  68. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  69. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  70. package/dist/solution/BaseSales/index.d.ts +39 -16
  71. package/dist/solution/BaseSales/index.js +1754 -1154
  72. package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
  73. package/dist/solution/BaseSales/pickupTiming.js +616 -0
  74. package/dist/solution/BaseSales/types.d.ts +11 -0
  75. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  76. package/dist/solution/BookingByStep/index.d.ts +3 -1
  77. package/dist/solution/BookingByStep/index.js +8 -3
  78. package/dist/solution/BookingTicket/index.d.ts +8 -2
  79. package/dist/solution/BookingTicket/index.js +513 -436
  80. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  81. package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
  82. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  83. package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
  84. package/dist/solution/OrderInvoicePreview/index.js +340 -0
  85. package/dist/solution/RegisterAndLogin/config.js +54 -11
  86. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  87. package/dist/solution/RegisterAndLogin/index.js +1 -1
  88. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  89. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  90. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  91. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  92. package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
  93. package/dist/solution/UnifiedBookingSales/index.js +1714 -905
  94. package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
  95. package/dist/solution/VenueBooking/index.d.ts +15 -2
  96. package/dist/solution/VenueBooking/index.js +1062 -785
  97. package/dist/solution/VenueBooking/types.d.ts +2 -1
  98. package/dist/solution/VenueBooking/types.js +1 -0
  99. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  100. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  101. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  102. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  103. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  104. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  105. package/dist/solution/index.d.ts +1 -0
  106. package/dist/solution/index.js +2 -1
  107. package/lib/index.d.ts +2 -0
  108. package/lib/index.js +21 -1
  109. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  110. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  111. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  112. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  113. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  114. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  115. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  116. package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
  117. package/lib/modules/BookingContext/utils/productExtend.js +45 -2
  118. package/lib/modules/BookingContext/utils/resources.js +1 -1
  119. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  120. package/lib/modules/BusinessAvailability/index.js +146 -0
  121. package/lib/modules/Cart/index.js +4 -2
  122. package/lib/modules/Cart/types.d.ts +2 -0
  123. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  124. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  125. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  126. package/lib/modules/FulfillmentTiming/index.js +359 -0
  127. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  128. package/lib/modules/FulfillmentTiming/types.js +5 -0
  129. package/lib/modules/OpenData/types.d.ts +14 -0
  130. package/lib/modules/Order/index.d.ts +14 -2
  131. package/lib/modules/Order/index.js +240 -38
  132. package/lib/modules/Order/localEftposState.d.ts +13 -0
  133. package/lib/modules/Order/localEftposState.js +44 -0
  134. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  135. package/lib/modules/Order/pickupTiming.js +61 -0
  136. package/lib/modules/Order/types.d.ts +30 -2
  137. package/lib/modules/Order/utils.js +21 -5
  138. package/lib/modules/Payment/index.js +3 -4
  139. package/lib/modules/Product/types.d.ts +11 -0
  140. package/lib/modules/ProductList/index.js +1 -1
  141. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  142. package/lib/modules/ResourcePlanner/planner.js +252 -8
  143. package/lib/modules/ResourcePlanner/types.d.ts +29 -0
  144. package/lib/modules/Schedule/index.d.ts +8 -0
  145. package/lib/modules/Schedule/index.js +68 -12
  146. package/lib/modules/index.d.ts +1 -0
  147. package/lib/modules/index.js +11 -0
  148. package/lib/plugins/request.d.ts +7 -0
  149. package/lib/server/index.d.ts +1 -0
  150. package/lib/server/index.js +158 -37
  151. package/lib/server/modules/form/index.d.ts +19 -0
  152. package/lib/server/modules/form/index.js +73 -0
  153. package/lib/server/modules/form/types.d.ts +13 -0
  154. package/lib/server/modules/form/types.js +9 -0
  155. package/lib/server/modules/index.d.ts +3 -0
  156. package/lib/server/modules/index.js +15 -1
  157. package/lib/server/modules/order/index.d.ts +15 -0
  158. package/lib/server/modules/order/index.js +114 -3
  159. package/lib/server/modules/order/types.d.ts +1 -0
  160. package/lib/server/test.json +1 -1
  161. package/lib/server/utils/small-ticket.d.ts +1 -85
  162. package/lib/server/utils/small-ticket.js +9 -2305
  163. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  164. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  165. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  166. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  167. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  168. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
  169. package/lib/shared/receipt/small-ticket.d.ts +96 -0
  170. package/lib/shared/receipt/small-ticket.js +2546 -0
  171. package/lib/shared/receipt/templateVisibility.d.ts +23 -0
  172. package/lib/shared/receipt/templateVisibility.js +63 -0
  173. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  174. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  175. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  176. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  177. package/lib/solution/BaseSales/index.d.ts +39 -16
  178. package/lib/solution/BaseSales/index.js +333 -31
  179. package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
  180. package/lib/solution/BaseSales/pickupTiming.js +290 -0
  181. package/lib/solution/BaseSales/types.d.ts +11 -0
  182. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  183. package/lib/solution/BookingByStep/index.d.ts +3 -1
  184. package/lib/solution/BookingByStep/index.js +7 -3
  185. package/lib/solution/BookingTicket/index.d.ts +8 -2
  186. package/lib/solution/BookingTicket/index.js +65 -6
  187. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  188. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
  189. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  190. package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
  191. package/lib/solution/OrderInvoicePreview/index.js +246 -0
  192. package/lib/solution/RegisterAndLogin/config.js +57 -11
  193. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  194. package/lib/solution/RegisterAndLogin/index.js +9 -1
  195. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  196. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  197. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  198. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  199. package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
  200. package/lib/solution/UnifiedBookingSales/index.js +561 -74
  201. package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
  202. package/lib/solution/VenueBooking/index.d.ts +15 -2
  203. package/lib/solution/VenueBooking/index.js +243 -96
  204. package/lib/solution/VenueBooking/types.d.ts +2 -1
  205. package/lib/solution/VenueBooking/types.js +1 -0
  206. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  207. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  208. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  209. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  210. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  211. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  212. package/lib/solution/index.d.ts +1 -0
  213. package/lib/solution/index.js +11 -0
  214. package/package.json +1 -1
@@ -0,0 +1,204 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
+ 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; } } }; }
6
+ 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; }
7
+ 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; }
8
+ 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; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ 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); }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ 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."); }
13
+ 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); }
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+ 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; }
17
+ 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); }
18
+ import dayjs from 'dayjs';
19
+ import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
20
+ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
21
+ import { getScheduleStartEndTimePoints } from "../Schedule/getDateIsInSchedule";
22
+ dayjs.extend(isSameOrAfter);
23
+ dayjs.extend(isSameOrBefore);
24
+ var DAY = 86400000;
25
+ var behavior = function behavior(value) {
26
+ return value === 'show_menu_disabled' ? value : 'hide_all';
27
+ };
28
+ var message = function message(value) {
29
+ return typeof value === 'string' || value !== null && _typeof(value) === 'object' && !Array.isArray(value) ? value : null;
30
+ };
31
+ export function normalizeBusinessAvailabilityConfig(data) {
32
+ var rawIds = data['availability.operating_hours'];
33
+ var ids = Array.isArray(rawIds) ? rawIds.map(function (id) {
34
+ return typeof id === 'number' || typeof id === 'string' ? Number(id) : NaN;
35
+ }) : [];
36
+ var validIds = ids.filter(function (id) {
37
+ return Number.isInteger(id) && id > 0;
38
+ });
39
+ var paused = data['availability.paused'];
40
+ return {
41
+ paused: paused === true || paused === 1 || paused === 'true' || paused === '1',
42
+ pauseBehavior: behavior(data['availability.pause_behavior']),
43
+ closedBehavior: behavior(data['availability.closed_behavior']),
44
+ pauseMessage: message(data['availability.pause_message']),
45
+ closedMessage: message(data['availability.closed_message']),
46
+ scheduleIds: _toConsumableArray(new Set(validIds)),
47
+ invalidScheduleIds: rawIds != null && (!Array.isArray(rawIds) || validIds.length !== ids.length),
48
+ // Only an explicitly disabled setting changes the existing payment flow.
49
+ requirePaymentOnSubmit: data['sale.require_payment_on_submit'] !== false
50
+ };
51
+ }
52
+ function createClock(timezone) {
53
+ if (!timezone) throw new Error('Store timezone is unavailable.');
54
+ var formatter = new Intl.DateTimeFormat('en-GB', {
55
+ timeZone: timezone,
56
+ year: 'numeric',
57
+ month: '2-digit',
58
+ day: '2-digit',
59
+ hour: '2-digit',
60
+ minute: '2-digit',
61
+ second: '2-digit',
62
+ hourCycle: 'h23'
63
+ });
64
+ var local = function local(timestamp) {
65
+ var parts = {};
66
+ formatter.formatToParts(timestamp).forEach(function (part) {
67
+ parts[part.type] = part.value;
68
+ });
69
+ var date = "".concat(parts.year, "-").concat(parts.month, "-").concat(parts.day);
70
+ return {
71
+ date: date,
72
+ scalar: Date.parse("".concat(date, "T").concat(parts.hour, ":").concat(parts.minute, ":").concat(parts.second, "Z"))
73
+ };
74
+ };
75
+ var offsets = new Set();
76
+ var instants = function instants(scalar) {
77
+ offsets.clear();
78
+ for (var hours = -36; hours <= 36; hours += 6) {
79
+ var sample = scalar + hours * 3600000;
80
+ offsets.add(local(sample).scalar - sample);
81
+ }
82
+ return _toConsumableArray(offsets).map(function (offset) {
83
+ return scalar - offset;
84
+ }).filter(function (instant) {
85
+ return local(instant).scalar === scalar;
86
+ }).sort(function (a, b) {
87
+ return a - b;
88
+ });
89
+ };
90
+ return {
91
+ local: local,
92
+ instants: instants
93
+ };
94
+ }
95
+
96
+ /** Business ordering is independent of reservation switches and Pickup slot availability. */
97
+ export function computeBusinessAvailability(input) {
98
+ var config = input.config,
99
+ schedules = input.schedules,
100
+ timezone = input.timezone,
101
+ now = input.now;
102
+ var nowAt = now.getTime();
103
+ var base = {
104
+ requirePaymentOnSubmit: config.requirePaymentOnSubmit,
105
+ nextChangeAt: nowAt + DAY
106
+ };
107
+ if (config.paused) {
108
+ return _objectSpread(_objectSpread({}, base), {}, {
109
+ status: 'paused',
110
+ behavior: config.pauseBehavior,
111
+ message: config.pauseMessage
112
+ });
113
+ }
114
+ if (config.invalidScheduleIds) throw new Error('Business operating-hours configuration is invalid.');
115
+ if (!config.scheduleIds.length) return _objectSpread(_objectSpread({}, base), {}, {
116
+ status: 'open',
117
+ behavior: null,
118
+ message: null
119
+ });
120
+ var selected = schedules.filter(function (schedule) {
121
+ return config.scheduleIds.includes(Number(schedule.id));
122
+ });
123
+ if (config.scheduleIds.some(function (id) {
124
+ return !selected.some(function (schedule) {
125
+ return Number(schedule.id) === id;
126
+ });
127
+ })) {
128
+ throw new Error('A configured business operating-hours schedule is unavailable.');
129
+ }
130
+ var clock = createClock(timezone);
131
+ var current = clock.local(nowAt);
132
+ var today = Date.parse("".concat(current.date, "T00:00:00Z"));
133
+ var nextMidnight = clock.instants(today + DAY).find(function (instant) {
134
+ return instant > nowAt;
135
+ });
136
+ var nextChangeAt = nextMidnight !== null && nextMidnight !== void 0 ? nextMidnight : nowAt + 60000;
137
+ var open = false;
138
+ // Yesterday contributes the tail of overnight windows; today supplies the next boundary.
139
+ for (var _i = 0, _arr = [today - DAY, today]; _i < _arr.length; _i++) {
140
+ var dateAt = _arr[_i];
141
+ var date = new Date(dateAt).toISOString().slice(0, 10);
142
+ // Schedule's resolver merges by time-of-day, so resolve each schedule independently.
143
+ var _iterator = _createForOfIteratorHelper(selected),
144
+ _step;
145
+ try {
146
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
147
+ var schedule = _step.value;
148
+ var _iterator2 = _createForOfIteratorHelper(getScheduleStartEndTimePoints(date, [schedule])),
149
+ _step2;
150
+ try {
151
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
152
+ var window = _step2.value;
153
+ var toMinutes = function toMinutes(value) {
154
+ if (!/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value) && value !== '24:00') {
155
+ throw new Error('Business operating-hours schedule contains an invalid time.');
156
+ }
157
+ var _value$split$map = value.split(':').map(Number),
158
+ _value$split$map2 = _slicedToArray(_value$split$map, 2),
159
+ hours = _value$split$map2[0],
160
+ minutes = _value$split$map2[1];
161
+ return hours * 60 + minutes;
162
+ };
163
+ var start = dateAt + toMinutes(window.start_time) * 60000;
164
+ var end = dateAt + toMinutes(window.end_time) * 60000;
165
+ if (end <= start) end += DAY;
166
+ if (current.scalar >= start && current.scalar < end) open = true;
167
+ for (var _i2 = 0, _arr2 = [start, end]; _i2 < _arr2.length; _i2++) {
168
+ var boundary = _arr2[_i2];
169
+ var _iterator3 = _createForOfIteratorHelper(clock.instants(boundary)),
170
+ _step3;
171
+ try {
172
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
173
+ var instant = _step3.value;
174
+ if (instant > nowAt) nextChangeAt = Math.min(nextChangeAt, instant);
175
+ }
176
+ } catch (err) {
177
+ _iterator3.e(err);
178
+ } finally {
179
+ _iterator3.f();
180
+ }
181
+ }
182
+ }
183
+ } catch (err) {
184
+ _iterator2.e(err);
185
+ } finally {
186
+ _iterator2.f();
187
+ }
188
+ }
189
+ } catch (err) {
190
+ _iterator.e(err);
191
+ } finally {
192
+ _iterator.f();
193
+ }
194
+ }
195
+ // A timezone offset change can repeat/skip a wall-clock boundary. A local-only safety
196
+ // check also covers throttled timers; it does not fetch either configuration source.
197
+ nextChangeAt = Math.min(nextChangeAt, nowAt + 60000);
198
+ return _objectSpread(_objectSpread({}, base), {}, {
199
+ nextChangeAt: nextChangeAt,
200
+ status: open ? 'open' : 'closed',
201
+ behavior: open ? null : config.closedBehavior,
202
+ message: open ? null : config.closedMessage
203
+ });
204
+ }
@@ -113,11 +113,11 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
113
113
  key: "addItem",
114
114
  value: (function () {
115
115
  var _addItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
116
- var account, product, bundle, options, date, _params$quantity, quantity, cartItem, newProduct, items;
116
+ var account, product, bundle, options, date, _params$quantity, quantity, isLegacyOrder, cartItem, newProduct, items;
117
117
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
118
118
  while (1) switch (_context2.prev = _context2.next) {
119
119
  case 0:
120
- account = params.account, product = params.product, bundle = params.bundle, options = params.options, date = params.date, _params$quantity = params.quantity, quantity = _params$quantity === void 0 ? 1 : _params$quantity; // 生成一个唯一的 ID
120
+ account = params.account, product = params.product, bundle = params.bundle, options = params.options, date = params.date, _params$quantity = params.quantity, quantity = _params$quantity === void 0 ? 1 : _params$quantity, isLegacyOrder = params.isLegacyOrder; // 生成一个唯一的 ID
121
121
  cartItem = {
122
122
  _id: getUniqueId(),
123
123
  _origin: createCartItemOrigin()
@@ -134,7 +134,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
134
134
  bundle: bundle,
135
135
  options: options,
136
136
  product_variant_id: newProduct.product_variant_id,
137
- quantity: quantity
137
+ quantity: quantity,
138
+ isLegacyOrder: isLegacyOrder
138
139
  });
139
140
  }
140
141
  if (account) {
@@ -180,6 +180,8 @@ export interface IAddItemParams {
180
180
  };
181
181
  /** 商品组合规格ID */
182
182
  product_variant_id?: number;
183
+ /** 是否由旧版下单流程加入购物车 */
184
+ isLegacyOrder?: boolean;
183
185
  }
184
186
  /**
185
187
  * 更新购物车信息参数
@@ -21,6 +21,7 @@ export declare const formatProductToCartItem: (params: {
21
21
  product_variant_id?: number;
22
22
  quantity?: number;
23
23
  discounts?: any[];
24
+ isLegacyOrder?: boolean;
24
25
  }) => CartItem;
25
26
  export declare const formatProductToCartItemOrigin: (params: {
26
27
  cartItem: CartItem;
@@ -29,6 +30,7 @@ export declare const formatProductToCartItemOrigin: (params: {
29
30
  options?: any;
30
31
  product_variant_id?: number;
31
32
  quantity?: number;
33
+ isLegacyOrder?: boolean;
32
34
  }) => any;
33
35
  /**
34
36
  * 获取商品总价
@@ -61,7 +63,7 @@ export declare const getProductOriginTotalPrice: (params: {
61
63
  * @param options 套餐规格信息
62
64
  * @returns 格式化后的套餐规格信息
63
65
  */
64
- export declare const formatOptions: (options: any) => any;
66
+ export declare const formatOptions: (options: any, product?: ProductData) => any;
65
67
  export declare const formatOptionsToOrigin: (options: any) => any;
66
68
  /**
67
69
  * 格式化商品套餐信息
@@ -1,4 +1,5 @@
1
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
+ var _excluded = ["option"];
2
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
4
  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
5
  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); }
@@ -10,6 +11,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
11
  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; }
11
12
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
13
  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); }
14
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
16
  import Decimal from 'decimal.js';
14
17
  import { isNormalProduct } from "../../Product/utils";
15
18
  import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
@@ -117,7 +120,7 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
117
120
  cartItem.bundle = formatBundle(bundle);
118
121
  }
119
122
  if (options !== null && options !== void 0 && options.length) {
120
- cartItem.options = formatOptions(options);
123
+ cartItem.options = formatOptions(options, product);
121
124
  }
122
125
  // 拼装出 product_option_string
123
126
  if (product_variant_id) {
@@ -167,7 +170,9 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
167
170
  options = params.options,
168
171
  product_variant_id = params.product_variant_id,
169
172
  _params$quantity2 = params.quantity,
170
- quantity = _params$quantity2 === void 0 ? 1 : _params$quantity2;
173
+ quantity = _params$quantity2 === void 0 ? 1 : _params$quantity2,
174
+ _params$isLegacyOrder = params.isLegacyOrder,
175
+ isLegacyOrder = _params$isLegacyOrder === void 0 ? false : _params$isLegacyOrder;
171
176
  var origin = cartItem._origin;
172
177
  var product_discount_difference = (((_origin$product = origin.product) === null || _origin$product === void 0 ? void 0 : _origin$product.discount_list) || []).filter(function (item) {
173
178
  var _item$metadata;
@@ -177,15 +182,23 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
177
182
  return pre + ((cur === null || cur === void 0 || (_cur$metadata = cur.metadata) === null || _cur$metadata === void 0 ? void 0 : _cur$metadata.product_discount_difference) || 0);
178
183
  }, 0);
179
184
  if (product) {
180
- var _origin$product2, _origin$product3, _product$duration, _product$duration2;
181
- origin.product = _objectSpread(_objectSpread({}, origin.product || {}), {}, {
185
+ var _origin$product2, _origin$product3, _origin$product4, _origin$product5, _product$duration, _product$duration2;
186
+ var _ref = ((_origin$product2 = origin.product) === null || _origin$product2 === void 0 ? void 0 : _origin$product2.product_sku) || {},
187
+ _option = _ref.option,
188
+ legacyProductSku = _objectWithoutProperties(_ref, _excluded);
189
+ origin.product = _objectSpread(_objectSpread(_objectSpread({}, origin.product || {}), {}, {
182
190
  num: quantity,
183
191
  product_id: product.id,
184
192
  product_variant_id: product_variant_id || 0,
185
- product_bundle: ((_origin$product2 = origin.product) === null || _origin$product2 === void 0 ? void 0 : _origin$product2.product_bundle) || [],
186
- product_sku: ((_origin$product3 = origin.product) === null || _origin$product3 === void 0 ? void 0 : _origin$product3.product_sku) || {
193
+ product_bundle: ((_origin$product3 = origin.product) === null || _origin$product3 === void 0 ? void 0 : _origin$product3.product_bundle) || []
194
+ }, isLegacyOrder ? {
195
+ product_sku: legacyProductSku,
196
+ product_option_item: ((_origin$product4 = origin.product) === null || _origin$product4 === void 0 ? void 0 : _origin$product4.product_option_item) || []
197
+ } : {
198
+ product_sku: ((_origin$product5 = origin.product) === null || _origin$product5 === void 0 ? void 0 : _origin$product5.product_sku) || {
187
199
  option: []
188
- },
200
+ }
201
+ }), {}, {
189
202
  metadata: {
190
203
  product_discount_difference: product_discount_difference
191
204
  }
@@ -198,16 +211,21 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
198
211
  origin.product.product_bundle = formatBundleToOrigin(bundle);
199
212
  }
200
213
  if (options !== null && options !== void 0 && options.length) {
201
- origin.product.product_sku = _objectSpread(_objectSpread({}, origin.product.product_sku || {}), {}, {
202
- option: formatOptionsToOrigin(options).map(function (option) {
203
- var _option$add_price;
204
- var next = _objectSpread(_objectSpread({}, option), {}, {
205
- add_price: (_option$add_price = option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option.price
206
- });
207
- delete next.price;
208
- return next;
209
- })
210
- });
214
+ var formattedOptions = formatOptionsToOrigin(options);
215
+ if (isLegacyOrder) {
216
+ origin.product.product_option_item = formattedOptions;
217
+ } else {
218
+ origin.product.product_sku = _objectSpread(_objectSpread({}, origin.product.product_sku || {}), {}, {
219
+ option: formattedOptions.map(function (option) {
220
+ var _option$add_price;
221
+ var next = _objectSpread(_objectSpread({}, option), {}, {
222
+ add_price: (_option$add_price = option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option.price
223
+ });
224
+ delete next.price;
225
+ return next;
226
+ })
227
+ });
228
+ }
211
229
  }
212
230
  }
213
231
  return origin;
@@ -230,10 +248,10 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
230
248
 
231
249
  // option 行:unit 折后价在循环中与主商品使用同一套 getDiscountAmount(含 deductOptionPrice)
232
250
  var optionRows = (_options$map = options === null || options === void 0 ? void 0 : options.map(function (currentValue) {
233
- var _ref, _currentValue$price, _ref2, _currentValue$num;
251
+ var _ref2, _currentValue$price, _ref3, _currentValue$num;
234
252
  return {
235
- unit: Number((_ref = (_currentValue$price = currentValue.price) !== null && _currentValue$price !== void 0 ? _currentValue$price : currentValue.add_price) !== null && _ref !== void 0 ? _ref : 0),
236
- num: Number((_ref2 = (_currentValue$num = currentValue.num) !== null && _currentValue$num !== void 0 ? _currentValue$num : currentValue.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1)
253
+ unit: Number((_ref2 = (_currentValue$price = currentValue.price) !== null && _currentValue$price !== void 0 ? _currentValue$price : currentValue.add_price) !== null && _ref2 !== void 0 ? _ref2 : 0),
254
+ num: Number((_ref3 = (_currentValue$num = currentValue.num) !== null && _currentValue$num !== void 0 ? _currentValue$num : currentValue.quantity) !== null && _ref3 !== void 0 ? _ref3 : 1)
237
255
  };
238
256
  })) !== null && _options$map !== void 0 ? _options$map : [];
239
257
 
@@ -317,12 +335,21 @@ export var getProductOriginTotalPrice = function getProductOriginTotalPrice(para
317
335
  * @param options 套餐规格信息
318
336
  * @returns 格式化后的套餐规格信息
319
337
  */
320
- export var formatOptions = function formatOptions(options) {
338
+ export var formatOptions = function formatOptions(options, product) {
321
339
  if (!(options !== null && options !== void 0 && options.length)) return [];
322
340
  return options.map(function (item) {
341
+ var _ref4, _item$id, _product$option_group, _optionGroup$option_i, _ref5, _ref6, _item$name;
342
+ var optionGroupId = item === null || item === void 0 ? void 0 : item.option_group_id;
343
+ var optionItemId = (_ref4 = (_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.option_group_item_id) !== null && _ref4 !== void 0 ? _ref4 : item === null || item === void 0 ? void 0 : item.product_option_item_id;
344
+ var optionGroup = product === null || product === void 0 || (_product$option_group = product.option_group) === null || _product$option_group === void 0 ? void 0 : _product$option_group.find(function (group) {
345
+ return String(group === null || group === void 0 ? void 0 : group.id) === String(optionGroupId);
346
+ });
347
+ var optionItem = optionGroup === null || optionGroup === void 0 || (_optionGroup$option_i = optionGroup.option_item) === null || _optionGroup$option_i === void 0 ? void 0 : _optionGroup$option_i.find(function (candidate) {
348
+ return String(candidate === null || candidate === void 0 ? void 0 : candidate.id) === String(optionItemId);
349
+ });
323
350
  return {
324
- id: item === null || item === void 0 ? void 0 : item.id,
325
- name: item === null || item === void 0 ? void 0 : item.name,
351
+ id: optionItemId,
352
+ name: (_ref5 = (_ref6 = (_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : item === null || item === void 0 ? void 0 : item.title) !== null && _ref6 !== void 0 ? _ref6 : optionItem === null || optionItem === void 0 ? void 0 : optionItem.name) !== null && _ref5 !== void 0 ? _ref5 : optionItem === null || optionItem === void 0 ? void 0 : optionItem.title,
326
353
  num: item === null || item === void 0 ? void 0 : item.num,
327
354
  price: item === null || item === void 0 ? void 0 : item.price,
328
355
  total: item === null || item === void 0 ? void 0 : item.price,
@@ -337,7 +364,7 @@ export var formatOptionsToOrigin = function formatOptionsToOrigin(options) {
337
364
  return options.map(function (d) {
338
365
  return {
339
366
  num: d.num,
340
- option_group_item_id: d.option_group_item_id,
367
+ option_group_item_id: (d === null || d === void 0 ? void 0 : d.option_group_item_id) || (d === null || d === void 0 ? void 0 : d.product_option_item_id),
341
368
  option_group_id: d.option_group_id
342
369
  };
343
370
  });
@@ -431,11 +458,11 @@ export var getProductDeposit = function getProductDeposit(params) {
431
458
  // 判定商品是否有定金规则
432
459
  if ((product === null || product === void 0 || (_product$custom_depos2 = product.custom_deposit_data) === null || _product$custom_depos2 === void 0 ? void 0 : _product$custom_depos2.has_deposit) == 1) {
433
460
  var total = new Decimal(0);
434
- var _ref3 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
435
- deposit_fixed = _ref3.deposit_fixed,
436
- deposit_percentage = _ref3.deposit_percentage,
437
- deposit_policy_data = _ref3.deposit_policy_data,
438
- self_deposit_policy_ids = _ref3.self_deposit_policy_ids;
461
+ var _ref7 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
462
+ deposit_fixed = _ref7.deposit_fixed,
463
+ deposit_percentage = _ref7.deposit_percentage,
464
+ deposit_policy_data = _ref7.deposit_policy_data,
465
+ self_deposit_policy_ids = _ref7.self_deposit_policy_ids;
439
466
  // 所有协议数据
440
467
  var allProtocols = deposit_policy_data || [];
441
468
  // 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
@@ -529,9 +556,9 @@ export var handleProductDeposit = function handleProductDeposit(params) {
529
556
  depositTotal: new Decimal(0)
530
557
  };
531
558
  }
532
- var _ref4 = depositData || {},
533
- deposit_fixed = _ref4.deposit_fixed,
534
- deposit_percentage = _ref4.deposit_percentage;
559
+ var _ref8 = depositData || {},
560
+ deposit_fixed = _ref8.deposit_fixed,
561
+ deposit_percentage = _ref8.deposit_percentage;
535
562
  if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
536
563
  var depositFixed = Decimal(deposit_fixed || 0);
537
564
  var depositPercent = Decimal(deposit_percentage || 0);
@@ -0,0 +1,11 @@
1
+ import type { PickupTimingAvailability, PickupTimingBookingTimes, PickupTimingClockInput, PickupTimingComputeInput, PickupTimingConfig, PickupTimingSelection, PickupTimingSlot, PickupTimingValidationResult } from './types';
2
+ export * from './types';
3
+ /** Consume effective OpenData values only; legacy switches never enable Pickup. */
4
+ export declare function normalizePickupTimingConfig(openData: Record<string, unknown>): PickupTimingConfig;
5
+ export declare function resolvePickupTimingDateTime(date: string, time: string, timezone: string, instant?: string): PickupTimingSlot | undefined;
6
+ export declare function getAsapPickupTiming({ config, timezone, now }: PickupTimingClockInput): PickupTimingSlot;
7
+ export declare function pickupTimingSlotToBookingTimes(slot: PickupTimingSlot): PickupTimingBookingTimes;
8
+ export declare function computePickupTimingAvailability(input: PickupTimingComputeInput): PickupTimingAvailability;
9
+ export declare function validatePickupTimingSelection(selection: PickupTimingSelection, input: PickupTimingComputeInput & {
10
+ allowManualOverride?: boolean;
11
+ }): PickupTimingValidationResult;