@pisell/pisellos 2.2.243 → 2.2.244

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 (315) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +2 -3
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
  4. package/dist/modules/Cart/utils/cartProduct.js +3 -24
  5. package/dist/modules/Cart/utils/changePrice.js +11 -11
  6. package/dist/modules/Customer/index.d.ts +0 -20
  7. package/dist/modules/Customer/index.js +83 -172
  8. package/dist/modules/Customer/types.d.ts +0 -2
  9. package/dist/modules/Discount/index.js +3 -4
  10. package/dist/modules/Discount/types.d.ts +0 -1
  11. package/dist/modules/OpenData/index.d.ts +0 -8
  12. package/dist/modules/OpenData/index.js +17 -37
  13. package/dist/modules/Order/index.d.ts +18 -268
  14. package/dist/modules/Order/index.js +757 -3306
  15. package/dist/modules/Order/types.d.ts +31 -279
  16. package/dist/modules/Order/types.js +0 -38
  17. package/dist/modules/Order/utils.d.ts +5 -147
  18. package/dist/modules/Order/utils.js +103 -746
  19. package/dist/modules/Payment/index.d.ts +13 -10
  20. package/dist/modules/Payment/index.js +837 -467
  21. package/dist/modules/Payment/types.d.ts +0 -2
  22. package/dist/modules/Payment/utils.js +1 -2
  23. package/dist/modules/Payment/walletpass.js +7 -14
  24. package/dist/modules/ProductList/index.d.ts +12 -16
  25. package/dist/modules/ProductList/index.js +59 -133
  26. package/dist/modules/ProductList/types.d.ts +0 -14
  27. package/dist/modules/Quotation/index.d.ts +1 -0
  28. package/dist/modules/Quotation/index.js +22 -25
  29. package/dist/modules/Rules/index.d.ts +0 -4
  30. package/dist/modules/Rules/index.js +69 -93
  31. package/dist/modules/Rules/types.d.ts +0 -1
  32. package/dist/modules/SalesSummary/index.d.ts +25 -8
  33. package/dist/modules/SalesSummary/index.js +35 -86
  34. package/dist/modules/SalesSummary/types.d.ts +1 -4
  35. package/dist/modules/SalesSummary/utils.d.ts +25 -2
  36. package/dist/modules/SalesSummary/utils.js +162 -794
  37. package/dist/modules/Schedule/index.d.ts +0 -7
  38. package/dist/modules/Schedule/index.js +2 -24
  39. package/dist/modules/Summary/index.js +3 -4
  40. package/dist/modules/index.d.ts +0 -2
  41. package/dist/modules/index.js +1 -3
  42. package/dist/plugins/request.d.ts +0 -1
  43. package/dist/server/index.d.ts +1 -204
  44. package/dist/server/index.js +928 -3658
  45. package/dist/server/modules/index.d.ts +0 -2
  46. package/dist/server/modules/index.js +0 -2
  47. package/dist/server/modules/order/index.d.ts +4 -120
  48. package/dist/server/modules/order/index.js +483 -1779
  49. package/dist/server/modules/order/types.d.ts +3 -32
  50. package/dist/server/modules/order/types.js +0 -8
  51. package/dist/server/modules/order/utils/filterBookings.js +3 -26
  52. package/dist/server/modules/order/utils/filterOrders.js +8 -23
  53. package/dist/server/modules/products/index.d.ts +7 -34
  54. package/dist/server/modules/products/index.js +317 -631
  55. package/dist/server/modules/resource/index.d.ts +0 -2
  56. package/dist/server/modules/resource/index.js +3 -29
  57. package/dist/server/modules/schedule/index.d.ts +4 -4
  58. package/dist/server/modules/schedule/index.js +88 -111
  59. package/dist/solution/BaseSales/index.d.ts +9 -131
  60. package/dist/solution/BaseSales/index.js +447 -1944
  61. package/dist/solution/BaseSales/types.d.ts +6 -76
  62. package/dist/solution/BaseSales/types.js +4 -5
  63. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  64. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
  65. package/dist/solution/BaseSales/utils.d.ts +1 -1
  66. package/dist/solution/BaseSales/utils.js +21 -62
  67. package/dist/solution/BookingByStep/index.d.ts +1 -1
  68. package/dist/solution/BookingTicket/index.d.ts +10 -270
  69. package/dist/solution/BookingTicket/index.js +237 -1772
  70. package/dist/solution/BookingTicket/types.d.ts +1 -118
  71. package/dist/solution/BookingTicket/types.js +2 -41
  72. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  73. package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
  74. package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
  75. package/dist/solution/BookingTicket/utils/cartView.js +7 -94
  76. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  77. package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
  78. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  79. package/dist/solution/Checkout/index.d.ts +0 -1
  80. package/dist/solution/Checkout/index.js +9 -10
  81. package/dist/solution/RegisterAndLogin/config.js +10 -2
  82. package/dist/solution/ScanOrder/index.d.ts +3 -9
  83. package/dist/solution/ScanOrder/index.js +134 -241
  84. package/dist/solution/ScanOrder/types.d.ts +5 -9
  85. package/dist/solution/ScanOrder/types.js +3 -2
  86. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  87. package/dist/solution/ScanOrder/utils.js +22 -84
  88. package/dist/solution/VenueBooking/index.d.ts +2 -5
  89. package/dist/solution/VenueBooking/index.js +59 -110
  90. package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  91. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  92. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  93. package/dist/types/index.d.ts +0 -10
  94. package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
  95. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  96. package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
  97. package/lib/modules/Cart/utils/cartProduct.js +3 -20
  98. package/lib/modules/Cart/utils/changePrice.js +20 -12
  99. package/lib/modules/Customer/index.d.ts +0 -20
  100. package/lib/modules/Customer/index.js +11 -64
  101. package/lib/modules/Customer/types.d.ts +0 -2
  102. package/lib/modules/Discount/index.js +1 -5
  103. package/lib/modules/Discount/types.d.ts +0 -1
  104. package/lib/modules/OpenData/index.d.ts +0 -8
  105. package/lib/modules/OpenData/index.js +5 -19
  106. package/lib/modules/Order/index.d.ts +18 -268
  107. package/lib/modules/Order/index.js +344 -2149
  108. package/lib/modules/Order/types.d.ts +31 -279
  109. package/lib/modules/Order/types.js +0 -1
  110. package/lib/modules/Order/utils.d.ts +5 -147
  111. package/lib/modules/Order/utils.js +46 -614
  112. package/lib/modules/Payment/index.d.ts +13 -10
  113. package/lib/modules/Payment/index.js +150 -18
  114. package/lib/modules/Payment/types.d.ts +0 -2
  115. package/lib/modules/Payment/utils.js +1 -2
  116. package/lib/modules/Payment/walletpass.js +3 -7
  117. package/lib/modules/ProductList/index.d.ts +12 -16
  118. package/lib/modules/ProductList/index.js +4 -41
  119. package/lib/modules/ProductList/types.d.ts +0 -14
  120. package/lib/modules/Quotation/index.d.ts +1 -0
  121. package/lib/modules/Quotation/index.js +16 -19
  122. package/lib/modules/Rules/index.d.ts +0 -4
  123. package/lib/modules/Rules/index.js +120 -136
  124. package/lib/modules/Rules/types.d.ts +0 -1
  125. package/lib/modules/SalesSummary/index.d.ts +25 -8
  126. package/lib/modules/SalesSummary/index.js +4 -30
  127. package/lib/modules/SalesSummary/types.d.ts +1 -4
  128. package/lib/modules/SalesSummary/utils.d.ts +25 -2
  129. package/lib/modules/SalesSummary/utils.js +91 -645
  130. package/lib/modules/Schedule/index.d.ts +0 -7
  131. package/lib/modules/Schedule/index.js +1 -17
  132. package/lib/modules/Summary/index.js +4 -5
  133. package/lib/modules/index.d.ts +0 -2
  134. package/lib/modules/index.js +1 -5
  135. package/lib/plugins/request.d.ts +0 -1
  136. package/lib/server/index.d.ts +1 -204
  137. package/lib/server/index.js +57 -1888
  138. package/lib/server/modules/index.d.ts +0 -2
  139. package/lib/server/modules/index.js +0 -3
  140. package/lib/server/modules/order/index.d.ts +4 -120
  141. package/lib/server/modules/order/index.js +142 -919
  142. package/lib/server/modules/order/types.d.ts +3 -32
  143. package/lib/server/modules/order/utils/filterBookings.js +5 -24
  144. package/lib/server/modules/order/utils/filterOrders.js +6 -15
  145. package/lib/server/modules/products/index.d.ts +7 -34
  146. package/lib/server/modules/products/index.js +54 -189
  147. package/lib/server/modules/resource/index.d.ts +0 -2
  148. package/lib/server/modules/resource/index.js +3 -27
  149. package/lib/server/modules/schedule/index.d.ts +4 -4
  150. package/lib/server/modules/schedule/index.js +40 -47
  151. package/lib/solution/BaseSales/index.d.ts +9 -131
  152. package/lib/solution/BaseSales/index.js +63 -1106
  153. package/lib/solution/BaseSales/types.d.ts +6 -76
  154. package/lib/solution/BaseSales/types.js +1 -3
  155. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  156. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
  157. package/lib/solution/BaseSales/utils.d.ts +1 -1
  158. package/lib/solution/BaseSales/utils.js +10 -54
  159. package/lib/solution/BookingByStep/index.d.ts +1 -1
  160. package/lib/solution/BookingTicket/index.d.ts +10 -270
  161. package/lib/solution/BookingTicket/index.js +29 -922
  162. package/lib/solution/BookingTicket/types.d.ts +1 -118
  163. package/lib/solution/BookingTicket/types.js +0 -11
  164. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  165. package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
  166. package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
  167. package/lib/solution/BookingTicket/utils/cartView.js +6 -61
  168. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  169. package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
  170. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  171. package/lib/solution/Checkout/index.d.ts +0 -1
  172. package/lib/solution/Checkout/index.js +2 -1
  173. package/lib/solution/RegisterAndLogin/config.js +10 -2
  174. package/lib/solution/ScanOrder/index.d.ts +3 -9
  175. package/lib/solution/ScanOrder/index.js +70 -153
  176. package/lib/solution/ScanOrder/types.d.ts +5 -9
  177. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  178. package/lib/solution/ScanOrder/utils.js +17 -83
  179. package/lib/solution/VenueBooking/index.d.ts +2 -5
  180. package/lib/solution/VenueBooking/index.js +17 -54
  181. package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  182. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  183. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  184. package/lib/types/index.d.ts +0 -10
  185. package/package.json +1 -1
  186. package/dist/modules/BookingContext/index.d.ts +0 -48
  187. package/dist/modules/BookingContext/index.js +0 -566
  188. package/dist/modules/BookingContext/types.d.ts +0 -102
  189. package/dist/modules/BookingContext/types.js +0 -51
  190. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  191. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
  192. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  193. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
  194. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  195. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
  196. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  197. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  198. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  199. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  200. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  201. package/dist/modules/BookingContext/utils/index.js +0 -11
  202. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  203. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  204. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  205. package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
  206. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  207. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  208. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  209. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  210. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  211. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  212. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  213. package/dist/modules/BookingContext/utils/resources.js +0 -486
  214. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  215. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  216. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  217. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  218. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  219. package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
  220. package/dist/modules/SurchargeList/index.d.ts +0 -16
  221. package/dist/modules/SurchargeList/index.js +0 -162
  222. package/dist/modules/SurchargeList/types.d.ts +0 -11
  223. package/dist/modules/SurchargeList/types.js +0 -1
  224. package/dist/server/modules/payment/index.d.ts +0 -28
  225. package/dist/server/modules/payment/index.js +0 -305
  226. package/dist/server/modules/payment/types.d.ts +0 -9
  227. package/dist/server/modules/payment/types.js +0 -1
  228. package/dist/server/test.json +0 -713
  229. package/dist/server/utils/small-ticket.d.ts +0 -71
  230. package/dist/server/utils/small-ticket.js +0 -830
  231. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  232. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
  233. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  234. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  235. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  236. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  237. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  238. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
  239. package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  240. package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
  241. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  242. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
  243. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  244. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
  245. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  246. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
  247. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  248. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
  249. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  250. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
  251. package/lib/modules/BookingContext/index.d.ts +0 -48
  252. package/lib/modules/BookingContext/index.js +0 -368
  253. package/lib/modules/BookingContext/types.d.ts +0 -102
  254. package/lib/modules/BookingContext/types.js +0 -34
  255. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  256. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
  257. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  258. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
  259. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  260. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
  261. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  262. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  263. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  264. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  265. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  266. package/lib/modules/BookingContext/utils/index.js +0 -43
  267. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  268. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  269. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  270. package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
  271. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  272. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  273. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  274. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  275. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  276. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  277. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  278. package/lib/modules/BookingContext/utils/resources.js +0 -377
  279. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  280. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  281. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  282. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  283. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  284. package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
  285. package/lib/modules/SurchargeList/index.d.ts +0 -16
  286. package/lib/modules/SurchargeList/index.js +0 -89
  287. package/lib/modules/SurchargeList/types.d.ts +0 -11
  288. package/lib/modules/SurchargeList/types.js +0 -17
  289. package/lib/server/modules/payment/index.d.ts +0 -28
  290. package/lib/server/modules/payment/index.js +0 -192
  291. package/lib/server/modules/payment/types.d.ts +0 -9
  292. package/lib/server/modules/payment/types.js +0 -17
  293. package/lib/server/test.json +0 -713
  294. package/lib/server/utils/small-ticket.d.ts +0 -71
  295. package/lib/server/utils/small-ticket.js +0 -781
  296. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  297. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
  298. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  299. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  300. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  301. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
  302. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  303. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
  304. package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  305. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  306. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  307. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
  308. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  309. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
  310. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  311. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
  312. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  313. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
  314. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  315. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
@@ -1,150 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _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; } } }; }
3
- 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); }
4
- 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; }
5
- 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; }
6
- 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; }
7
- 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; }
8
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
- 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); }
10
- /**
11
- * 扫码商品条码预选规格纯函数(对齐 ticketBooking addServiceVariant/utils)。
12
- */
13
-
14
- /** 套餐商品 */
15
- export function isScanProductBundle(item) {
16
- return ((item === null || item === void 0 ? void 0 : item.bundle_group_count) || 0) > 0;
17
- }
18
-
19
- /** 单规格 / 选项组商品 */
20
- export function isScanProductOption(item) {
21
- var _item$option_group;
22
- return ((item === null || item === void 0 ? void 0 : item.option_group_count) || 0) > 0 || ((item === null || item === void 0 || (_item$option_group = item.option_group) === null || _item$option_group === void 0 ? void 0 : _item$option_group.length) || 0) > 0;
23
- }
24
- function formatVariantGroupTitle(title) {
25
- var variantGroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
26
- try {
27
- return variantGroup.map(function (group) {
28
- var value = title === null || title === void 0 ? void 0 : title[group === null || group === void 0 ? void 0 : group.position_id];
29
- return value ? "".concat((group === null || group === void 0 ? void 0 : group.name) || '-', ": ").concat(value) : '';
30
- }).filter(Boolean).join(', ');
31
- } catch (_unused) {
32
- return '';
33
- }
34
- }
35
- function formatDataKey(data) {
36
- var _next$option, _next$bundle;
37
- var next = _objectSpread({}, data);
38
- var key = "".concat(next.product_id);
39
- var rowKey = key;
40
- if (next.product_variant_id) {
41
- var str = "_".concat(next.product_variant_id);
42
- key += str;
43
- rowKey += str;
44
- }
45
- if (next !== null && next !== void 0 && (_next$option = next.option) !== null && _next$option !== void 0 && _next$option.length) {
46
- var _iterator = _createForOfIteratorHelper(next.option),
47
- _step;
48
- try {
49
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
50
- var item = _step.value;
51
- var _str = "_".concat(item.option_group_id, "_").concat(item.product_option_item_id);
52
- key += _str;
53
- rowKey += "".concat(_str, "_").concat(item.quantity || item.num);
54
- }
55
- } catch (err) {
56
- _iterator.e(err);
57
- } finally {
58
- _iterator.f();
59
- }
60
- }
61
- if (next !== null && next !== void 0 && (_next$bundle = next.bundle) !== null && _next$bundle !== void 0 && _next$bundle.length) {
62
- var _iterator2 = _createForOfIteratorHelper(next.bundle),
63
- _step2;
64
- try {
65
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
66
- var _item = _step2.value;
67
- var _str2 = "_".concat(_item.group_id, "_").concat(_item.bundle_product_id);
68
- key += _str2;
69
- rowKey += "".concat(_str2, "_").concat(_item.quantity || _item.num);
70
- if (_item !== null && _item !== void 0 && _item.option) {
71
- var _iterator3 = _createForOfIteratorHelper(_item.option),
72
- _step3;
73
- try {
74
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
75
- var opt = _step3.value;
76
- var optStr = "_".concat(opt.option_group_id, "_").concat(opt.product_option_item_id);
77
- key += optStr;
78
- rowKey += "".concat(optStr, "_").concat(opt.quantity || opt.num);
79
- }
80
- } catch (err) {
81
- _iterator3.e(err);
82
- } finally {
83
- _iterator3.f();
84
- }
85
- }
86
- }
87
- } catch (err) {
88
- _iterator2.e(err);
89
- } finally {
90
- _iterator2.f();
91
- }
92
- }
93
- if (next !== null && next !== void 0 && next.session) {
94
- var _next$session;
95
- var _str3 = "_".concat((_next$session = next.session) === null || _next$session === void 0 ? void 0 : _next$session.key);
96
- key += _str3;
97
- rowKey += _str3;
98
- }
99
- if (next !== null && next !== void 0 && next.schedule) {
100
- var _next$schedule;
101
- var _str4 = "_".concat((_next$schedule = next.schedule) === null || _next$schedule === void 0 ? void 0 : _next$schedule.key);
102
- key += _str4;
103
- rowKey += _str4;
104
- }
105
- next.key = key;
106
- next.rowKey = rowKey;
107
- return next;
108
- }
109
-
110
- /**
111
- * 根据条码匹配 variant,生成 cartDetailValue(对齐 ticketBooking `genValues`)。
112
- *
113
- * @example
114
- * ```ts
115
- * const values = genScanProductValues(catalogItem, '6901234567890');
116
- * const itemWithSelection = { ...catalogItem, cartDetailValue: values };
117
- * ```
118
- */
119
- export function genScanProductValues(item, code) {
120
- var _item$variant_group, _item$option_group2;
121
- var params = {
122
- bundle: [],
123
- option: [],
124
- product_id: item.id,
125
- product_variant_id: 0,
126
- quantity: 1,
127
- rowKey: '',
128
- session: null
129
- };
130
- if (item !== null && item !== void 0 && (_item$variant_group = item.variant_group) !== null && _item$variant_group !== void 0 && _item$variant_group.length || item !== null && item !== void 0 && (_item$option_group2 = item.option_group) !== null && _item$option_group2 !== void 0 && _item$option_group2.length) {
131
- var variantItem = (item.variant || []).find(function (v) {
132
- return (v === null || v === void 0 ? void 0 : v.code) === code || (v === null || v === void 0 ? void 0 : v.barcode) === code;
133
- });
134
- if (variantItem) {
135
- params.price = Number((variantItem === null || variantItem === void 0 ? void 0 : variantItem.price) || 0);
136
- params.product_variant_id = variantItem.id;
137
- params.product_option_string = formatVariantGroupTitle(variantItem === null || variantItem === void 0 ? void 0 : variantItem.title, (item === null || item === void 0 ? void 0 : item.variant_group) || []);
138
- }
139
- }
140
- return formatDataKey(params);
141
- }
142
-
143
- /**
144
- * 统计条码命中的 variant 数量(多命中时需弹窗选择)。
145
- */
146
- export function countScanVariantMatches(item, code) {
147
- return ((item === null || item === void 0 ? void 0 : item.variant) || []).filter(function (v) {
148
- return (v === null || v === void 0 ? void 0 : v.code) === code || (v === null || v === void 0 ? void 0 : v.barcode) === code;
149
- }).length;
150
- }
@@ -1,23 +0,0 @@
1
- import type { ProductData } from '../../../modules/Product/types';
2
- export interface SessionCatalogStaleInfo {
3
- productId: number | string | null;
4
- productTitle: string | null;
5
- sessionDay: string | null;
6
- timeBarDay: string | null;
7
- bookingDate: unknown;
8
- }
9
- /**
10
- * 判断 session 商品 catalog 中的 session 日历日是否与当前 TimeBar / bookingDate 不一致。
11
- *
12
- * @example
13
- * isSessionCatalogDateStale(product, '2026-06-05 19:01:18');
14
- * // session 为 2026-06-04 → true;一致或无 session 快照 → false
15
- */
16
- export declare function isSessionCatalogDateStale(product: ProductData & Record<string, any>, bookingDate: unknown): boolean;
17
- /**
18
- * 组装 session catalog 日期不一致时的日志 metadata。
19
- *
20
- * @example
21
- * buildSessionCatalogStaleInfo(product, '2026-06-05 19:01:18');
22
- */
23
- export declare function buildSessionCatalogStaleInfo(product: ProductData & Record<string, any>, bookingDate: unknown): SessionCatalogStaleInfo;
@@ -1,78 +0,0 @@
1
- import dayjs from 'dayjs';
2
- var SESSION_EXTENSION_TYPES = ['session_product', 'session_ticket'];
3
-
4
- /**
5
- * 是否为 session 商品。
6
- *
7
- * @example
8
- * getIsSessionProduct({ extension_type: 'session_ticket' }); // true
9
- */
10
- function getIsSessionProduct(product) {
11
- return SESSION_EXTENSION_TYPES.includes(product === null || product === void 0 ? void 0 : product.extension_type);
12
- }
13
-
14
- /**
15
- * 从 session 快照解析日历日 YYYY-MM-DD。
16
- *
17
- * @example
18
- * resolveSessionCalendarDay({ start_at: '2026-06-05 10:00:00' }); // '2026-06-05'
19
- */
20
- function resolveSessionCalendarDay(session) {
21
- var _session$start_at;
22
- if (!session) return null;
23
- var raw = (_session$start_at = session.start_at) !== null && _session$start_at !== void 0 ? _session$start_at : session.end_at;
24
- if (!raw) return null;
25
- var parsed = dayjs(raw);
26
- return parsed.isValid() ? parsed.format('YYYY-MM-DD') : null;
27
- }
28
-
29
- /**
30
- * 将 booking / TimeBar 日期规范为 YYYY-MM-DD。
31
- *
32
- * @example
33
- * formatScheduleCalendarDay('2026-06-05 19:01:18'); // '2026-06-05'
34
- */
35
- function formatScheduleCalendarDay(date) {
36
- if (date == null || date === '') return null;
37
- var parsed = dayjs(date);
38
- return parsed.isValid() ? parsed.format('YYYY-MM-DD') : null;
39
- }
40
- /**
41
- * 判断 session 商品 catalog 中的 session 日历日是否与当前 TimeBar / bookingDate 不一致。
42
- *
43
- * @example
44
- * isSessionCatalogDateStale(product, '2026-06-05 19:01:18');
45
- * // session 为 2026-06-04 → true;一致或无 session 快照 → false
46
- */
47
- export function isSessionCatalogDateStale(product, bookingDate) {
48
- var _product$cartDetailVa;
49
- if (!getIsSessionProduct(product)) {
50
- return false;
51
- }
52
- var timeBarDay = formatScheduleCalendarDay(bookingDate);
53
- if (!timeBarDay) {
54
- return false;
55
- }
56
- var sessionDay = resolveSessionCalendarDay((_product$cartDetailVa = product.cartDetailValue) === null || _product$cartDetailVa === void 0 ? void 0 : _product$cartDetailVa.session);
57
- if (!sessionDay) {
58
- return false;
59
- }
60
- return sessionDay !== timeBarDay;
61
- }
62
-
63
- /**
64
- * 组装 session catalog 日期不一致时的日志 metadata。
65
- *
66
- * @example
67
- * buildSessionCatalogStaleInfo(product, '2026-06-05 19:01:18');
68
- */
69
- export function buildSessionCatalogStaleInfo(product, bookingDate) {
70
- var _product$id, _ref, _product$title, _product$cartDetailVa2;
71
- return {
72
- productId: (_product$id = product === null || product === void 0 ? void 0 : product.id) !== null && _product$id !== void 0 ? _product$id : null,
73
- productTitle: (_ref = (_product$title = product === null || product === void 0 ? void 0 : product.title) !== null && _product$title !== void 0 ? _product$title : product === null || product === void 0 ? void 0 : product.name) !== null && _ref !== void 0 ? _ref : null,
74
- sessionDay: resolveSessionCalendarDay((_product$cartDetailVa2 = product.cartDetailValue) === null || _product$cartDetailVa2 === void 0 ? void 0 : _product$cartDetailVa2.session),
75
- timeBarDay: formatScheduleCalendarDay(bookingDate),
76
- bookingDate: bookingDate
77
- };
78
- }
@@ -1,48 +0,0 @@
1
- import { Module, ModuleOptions, PisellCore } from '../../types';
2
- import { BaseModule } from '../BaseModule';
3
- import { BookingContextConfig, BookingContextDateInput, BookingContextModuleAPI, BookingContextResource, BookingContextResourceMap, BookingContextState, InitBookingContextParams, LoadBookingConfigParams, LoadBookingResourcesParams } from './types';
4
- export * from './types';
5
- export * from './utils';
6
- /**
7
- * 清理跨实例共享缓存,仅供单元测试隔离使用。
8
- *
9
- * @example
10
- * __clearBookingContextSharedCacheForTest();
11
- */
12
- export declare function __clearBookingContextSharedCacheForTest(): void;
13
- /** 稳定序列化 config 查询参数,用于判断是否与上次 loadBookingConfig 一致。 */
14
- export declare function buildBookingConfigQueryKey(params?: LoadBookingConfigParams): string;
15
- /** 稳定序列化资源列表查询(date + bookingIds),用于跳过重复 loadResources。 */
16
- export declare function buildBookingResourcesQueryKey(params?: LoadBookingResourcesParams): string;
17
- export declare class BookingContextModule extends BaseModule implements Module, BookingContextModuleAPI {
18
- protected defaultName: string;
19
- protected defaultVersion: string;
20
- private request;
21
- private store;
22
- /** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
23
- private lastConfigQueryKey;
24
- /** 上次成功 loadResources 的 query key(date|bookingIds);命中则不再请求。 */
25
- private lastResourcesQueryKey;
26
- constructor(name?: string, version?: string);
27
- initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
28
- loadBookingConfig(params?: LoadBookingConfigParams, options?: {
29
- forceRefresh?: boolean;
30
- }): Promise<BookingContextConfig | null>;
31
- loadResources(params?: LoadBookingResourcesParams, options?: {
32
- forceRefresh?: boolean;
33
- }): Promise<BookingContextResource[]>;
34
- /**
35
- * store 内是否已具备与本次 init 入参等价的 config / resources(不再打接口)。
36
- */
37
- isBookingContextReady(params?: InitBookingContextParams): boolean;
38
- initBookingContext(params?: InitBookingContextParams): Promise<BookingContextState>;
39
- setBookingConfig(config: BookingContextConfig | null): void;
40
- getBookingConfig(): BookingContextConfig | null;
41
- setResources(resources: BookingContextResource[] | null | undefined): void;
42
- getResourcesOrigin(): BookingContextResource[];
43
- getResourcesOriginMap(): BookingContextResourceMap;
44
- setDate(date: BookingContextDateInput): void;
45
- getDate(): string | null;
46
- getState(): BookingContextState;
47
- clear(): void;
48
- }
@@ -1,368 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/modules/BookingContext/index.ts
31
- var BookingContext_exports = {};
32
- __export(BookingContext_exports, {
33
- BookingContextModule: () => BookingContextModule,
34
- __clearBookingContextSharedCacheForTest: () => __clearBookingContextSharedCacheForTest,
35
- buildBookingConfigQueryKey: () => buildBookingConfigQueryKey,
36
- buildBookingResourcesQueryKey: () => buildBookingResourcesQueryKey
37
- });
38
- module.exports = __toCommonJS(BookingContext_exports);
39
- var import_dayjs = __toESM(require("dayjs"));
40
- var import_BaseModule = require("../BaseModule");
41
- var import_request = require("../../plugins/request");
42
- var import_types = require("./types");
43
- var import_formatResourceList = require("./utils/formatResourceList");
44
- __reExport(BookingContext_exports, require("./types"), module.exports);
45
- __reExport(BookingContext_exports, require("./utils"), module.exports);
46
- var EMPTY_STATE = {
47
- bookingConfig: null,
48
- resourcesOrigin: [],
49
- resourcesOriginMap: {},
50
- date: null
51
- };
52
- var DEFAULT_BOOKING_CONFIG_PARAMS = {
53
- item_type: "appointment_booking",
54
- sub_type: "ticket"
55
- };
56
- var BOARD_CONFIG_CACHE = {
57
- useCache: true,
58
- cache: {
59
- mode: import_request.RequestModeENUM.REMOTE_LOCAL,
60
- type: "indexDB",
61
- updateCache: true
62
- }
63
- };
64
- var RESOURCE_LIST_CACHE = {
65
- useCache: true,
66
- cache: {
67
- mode: import_request.RequestModeENUM.REMOTE_LOCAL,
68
- type: "memory"
69
- }
70
- };
71
- var requestScopeIds = /* @__PURE__ */ new WeakMap();
72
- var nextRequestScopeId = 1;
73
- var sharedBookingConfigCache = /* @__PURE__ */ new Map();
74
- var sharedBookingConfigPending = /* @__PURE__ */ new Map();
75
- var sharedResourcesCache = /* @__PURE__ */ new Map();
76
- var sharedResourcesPending = /* @__PURE__ */ new Map();
77
- function getRequestScopeId(request) {
78
- const key = request;
79
- const existed = requestScopeIds.get(key);
80
- if (existed)
81
- return existed;
82
- const id = nextRequestScopeId++;
83
- requestScopeIds.set(key, id);
84
- return id;
85
- }
86
- function buildSharedCacheKey(request, queryKey) {
87
- return `${getRequestScopeId(request)}:${queryKey}`;
88
- }
89
- function __clearBookingContextSharedCacheForTest() {
90
- sharedBookingConfigCache.clear();
91
- sharedBookingConfigPending.clear();
92
- sharedResourcesCache.clear();
93
- sharedResourcesPending.clear();
94
- }
95
- function normalizeDate(input) {
96
- if (input === null || input === void 0)
97
- return null;
98
- if (typeof input === "string")
99
- return input || null;
100
- if (input instanceof Date)
101
- return input.toISOString();
102
- if (typeof input.format === "function") {
103
- try {
104
- return input.format() || null;
105
- } catch {
106
- return null;
107
- }
108
- }
109
- return null;
110
- }
111
- function toScheduleQueryDate(input) {
112
- const normalized = normalizeDate(input);
113
- if (!normalized)
114
- return (0, import_dayjs.default)().format("YYYY-MM-DD");
115
- const parsed = (0, import_dayjs.default)(normalized);
116
- return parsed.isValid() ? parsed.format("YYYY-MM-DD") : (0, import_dayjs.default)().format("YYYY-MM-DD");
117
- }
118
- function buildResourcesMap(resources) {
119
- const map = {};
120
- resources.forEach((resource) => {
121
- if (resource && resource.id !== void 0 && resource.id !== null) {
122
- map[String(resource.id)] = resource;
123
- }
124
- });
125
- return map;
126
- }
127
- function buildBookingConfigQueryKey(params = {}) {
128
- const merged = { ...DEFAULT_BOOKING_CONFIG_PARAMS, ...params };
129
- const keys = Object.keys(merged).sort();
130
- const sorted = {};
131
- keys.forEach((k) => {
132
- sorted[k] = merged[k];
133
- });
134
- return JSON.stringify(sorted);
135
- }
136
- function buildBookingResourcesQueryKey(params = {}) {
137
- const date = toScheduleQueryDate(params.date);
138
- const ids = (params.bookingIds || []).filter((id) => typeof id === "number" && Number.isFinite(id)).sort((a, b) => a - b);
139
- return `${date}|${ids.join(",")}`;
140
- }
141
- var BookingContextModule = class extends import_BaseModule.BaseModule {
142
- constructor(name, version) {
143
- super(name, version);
144
- this.defaultName = "bookingContext";
145
- this.defaultVersion = "1.0.0";
146
- this.store = { ...EMPTY_STATE };
147
- /** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
148
- this.lastConfigQueryKey = null;
149
- /** 上次成功 loadResources 的 query key(date|bookingIds);命中则不再请求。 */
150
- this.lastResourcesQueryKey = null;
151
- }
152
- async initialize(core, options = {}) {
153
- this.core = core;
154
- this.request = core.getPlugin("request");
155
- if (!this.request) {
156
- throw new Error("BookingContextModule 需要 request 插件支持");
157
- }
158
- this.store = {
159
- bookingConfig: null,
160
- resourcesOrigin: [],
161
- resourcesOriginMap: {},
162
- date: null
163
- };
164
- const initialState = options.initialState || {};
165
- if (initialState.bookingConfig) {
166
- this.store.bookingConfig = initialState.bookingConfig;
167
- }
168
- if (Array.isArray(initialState.resourcesOrigin)) {
169
- this.store.resourcesOrigin = initialState.resourcesOrigin;
170
- this.store.resourcesOriginMap = buildResourcesMap(initialState.resourcesOrigin);
171
- }
172
- if (initialState.date) {
173
- this.store.date = initialState.date;
174
- }
175
- }
176
- async loadBookingConfig(params = {}, options = {}) {
177
- const configKey = buildBookingConfigQueryKey(params);
178
- if (!options.forceRefresh && this.store.bookingConfig != null && this.lastConfigQueryKey === configKey) {
179
- return this.store.bookingConfig;
180
- }
181
- const query = {
182
- ...DEFAULT_BOOKING_CONFIG_PARAMS,
183
- ...params
184
- };
185
- const sharedKey = buildSharedCacheKey(this.request, configKey);
186
- if (!options.forceRefresh && sharedBookingConfigCache.has(sharedKey)) {
187
- const cached = sharedBookingConfigCache.get(sharedKey) ?? null;
188
- this.setBookingConfig(cached);
189
- this.lastConfigQueryKey = configKey;
190
- return cached;
191
- }
192
- let pending = !options.forceRefresh ? sharedBookingConfigPending.get(sharedKey) : void 0;
193
- if (!pending) {
194
- const requestPromise = (async () => {
195
- try {
196
- const res = await this.request.get(
197
- "/core/board/management/config",
198
- query,
199
- BOARD_CONFIG_CACHE
200
- );
201
- const config2 = (res == null ? void 0 : res.data) ?? null;
202
- sharedBookingConfigCache.set(sharedKey, config2);
203
- return config2;
204
- } finally {
205
- sharedBookingConfigPending.delete(sharedKey);
206
- }
207
- })();
208
- pending = requestPromise;
209
- sharedBookingConfigPending.set(sharedKey, requestPromise);
210
- }
211
- const config = await pending;
212
- this.setBookingConfig(config);
213
- this.lastConfigQueryKey = configKey;
214
- return config;
215
- }
216
- async loadResources(params = {}, options = {}) {
217
- const date = toScheduleQueryDate(params.date ?? this.store.date);
218
- const resourcesKey = buildBookingResourcesQueryKey({
219
- date,
220
- bookingIds: params.bookingIds
221
- });
222
- if (!options.forceRefresh && this.lastResourcesQueryKey === resourcesKey) {
223
- return this.getResourcesOrigin();
224
- }
225
- const sharedKey = buildSharedCacheKey(this.request, resourcesKey);
226
- if (!options.forceRefresh && sharedResourcesCache.has(sharedKey)) {
227
- const cached = sharedResourcesCache.get(sharedKey) ?? [];
228
- this.setResources(cached);
229
- this.lastResourcesQueryKey = resourcesKey;
230
- return this.getResourcesOrigin();
231
- }
232
- let pending = !options.forceRefresh ? sharedResourcesPending.get(sharedKey) : void 0;
233
- if (!pending) {
234
- const requestPromise = (async () => {
235
- try {
236
- const res = await this.request.get(
237
- "/schedule/resource/list",
238
- { date },
239
- RESOURCE_LIST_CACHE
240
- );
241
- const { list: list2 } = (0, import_formatResourceList.formatResourceListAndMap)(res == null ? void 0 : res.data, params.bookingIds || []);
242
- sharedResourcesCache.set(sharedKey, list2);
243
- return list2;
244
- } finally {
245
- sharedResourcesPending.delete(sharedKey);
246
- }
247
- })();
248
- pending = requestPromise;
249
- sharedResourcesPending.set(sharedKey, requestPromise);
250
- }
251
- const list = await pending;
252
- this.setResources(list);
253
- this.lastResourcesQueryKey = resourcesKey;
254
- return this.getResourcesOrigin();
255
- }
256
- /**
257
- * store 内是否已具备与本次 init 入参等价的 config / resources(不再打接口)。
258
- */
259
- isBookingContextReady(params = {}) {
260
- const configKey = buildBookingConfigQueryKey(params.bookingConfigParams);
261
- const dateInput = params.date ?? this.store.date ?? (0, import_dayjs.default)();
262
- const queryDate = toScheduleQueryDate(dateInput);
263
- const resourcesKey = buildBookingResourcesQueryKey({
264
- date: queryDate,
265
- bookingIds: params.bookingIds
266
- });
267
- const configReady = this.store.bookingConfig != null && this.lastConfigQueryKey === configKey;
268
- const resourcesReady = params.loadResources === false || this.lastResourcesQueryKey === resourcesKey;
269
- return configReady && resourcesReady;
270
- }
271
- async initBookingContext(params = {}) {
272
- const dateInput = params.date ?? this.store.date ?? (0, import_dayjs.default)();
273
- const queryDate = toScheduleQueryDate(dateInput);
274
- this.setDate(dateInput);
275
- if (!params.forceRefresh && this.isBookingContextReady(params)) {
276
- return this.getState();
277
- }
278
- const configKey = buildBookingConfigQueryKey(params.bookingConfigParams);
279
- const resourcesKey = buildBookingResourcesQueryKey({
280
- date: queryDate,
281
- bookingIds: params.bookingIds
282
- });
283
- const needConfig = params.forceRefresh || this.store.bookingConfig == null || this.lastConfigQueryKey !== configKey;
284
- const needResources = params.loadResources !== false && (params.forceRefresh || this.lastResourcesQueryKey !== resourcesKey);
285
- if (needConfig) {
286
- await this.loadBookingConfig(params.bookingConfigParams, {
287
- forceRefresh: params.forceRefresh
288
- });
289
- }
290
- if (needResources) {
291
- await this.loadResources(
292
- {
293
- date: queryDate,
294
- bookingIds: params.bookingIds
295
- },
296
- {
297
- forceRefresh: params.forceRefresh
298
- }
299
- );
300
- }
301
- return this.getState();
302
- }
303
- setBookingConfig(config) {
304
- this.store.bookingConfig = config || null;
305
- this.core.effects.emit(
306
- `${this.name}:${import_types.BookingContextEvent.OnBookingConfigChange}`,
307
- this.store.bookingConfig
308
- );
309
- }
310
- getBookingConfig() {
311
- return this.store.bookingConfig;
312
- }
313
- setResources(resources) {
314
- const list = Array.isArray(resources) ? resources : [];
315
- this.store.resourcesOrigin = list;
316
- this.store.resourcesOriginMap = buildResourcesMap(list);
317
- this.core.effects.emit(`${this.name}:${import_types.BookingContextEvent.OnResourcesChange}`, {
318
- resourcesOrigin: this.store.resourcesOrigin,
319
- resourcesOriginMap: this.store.resourcesOriginMap
320
- });
321
- }
322
- getResourcesOrigin() {
323
- return [...this.store.resourcesOrigin];
324
- }
325
- getResourcesOriginMap() {
326
- return this.store.resourcesOriginMap;
327
- }
328
- setDate(date) {
329
- this.store.date = normalizeDate(date);
330
- this.core.effects.emit(`${this.name}:${import_types.BookingContextEvent.OnDateChange}`, this.store.date);
331
- }
332
- getDate() {
333
- return this.store.date;
334
- }
335
- getState() {
336
- return {
337
- bookingConfig: this.store.bookingConfig,
338
- resourcesOrigin: [...this.store.resourcesOrigin],
339
- resourcesOriginMap: this.store.resourcesOriginMap,
340
- date: this.store.date
341
- };
342
- }
343
- clear() {
344
- this.lastConfigQueryKey = null;
345
- this.lastResourcesQueryKey = null;
346
- this.store = {
347
- bookingConfig: null,
348
- resourcesOrigin: [],
349
- resourcesOriginMap: {},
350
- date: null
351
- };
352
- this.core.effects.emit(`${this.name}:${import_types.BookingContextEvent.OnBookingConfigChange}`, null);
353
- this.core.effects.emit(`${this.name}:${import_types.BookingContextEvent.OnResourcesChange}`, {
354
- resourcesOrigin: [],
355
- resourcesOriginMap: {}
356
- });
357
- this.core.effects.emit(`${this.name}:${import_types.BookingContextEvent.OnDateChange}`, null);
358
- }
359
- };
360
- // Annotate the CommonJS export names for ESM import in node:
361
- 0 && (module.exports = {
362
- BookingContextModule,
363
- __clearBookingContextSharedCacheForTest,
364
- buildBookingConfigQueryKey,
365
- buildBookingResourcesQueryKey,
366
- ...require("./types"),
367
- ...require("./utils")
368
- });