@pisell/pisellos 0.10.76 → 0.10.78

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 (212) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/effects/index.d.ts +19 -0
  3. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +105 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  7. package/dist/model/strategy/adapter/dataVariant/type.d.ts +173 -0
  8. package/dist/model/strategy/adapter/promotion/adapter.d.ts +70 -0
  9. package/dist/model/strategy/adapter/promotion/examples.d.ts +224 -0
  10. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +535 -0
  12. package/dist/model/strategy/adapter/type.d.ts +28 -0
  13. package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
  14. package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  15. package/dist/model/strategy/adapter/walletPass/type.d.ts +192 -0
  16. package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  17. package/dist/model/strategy/engine.d.ts +119 -0
  18. package/dist/model/strategy/type.d.ts +245 -0
  19. package/dist/modules/Account/types.d.ts +56 -0
  20. package/dist/modules/BookingContext/types.d.ts +104 -0
  21. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  22. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  23. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  24. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  25. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  26. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  27. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/Customer/constants.d.ts +7 -0
  31. package/dist/modules/Date/types.d.ts +84 -0
  32. package/dist/modules/Date/utils.d.ts +36 -0
  33. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  34. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  35. package/dist/modules/Order/payment-utils.d.ts +26 -0
  36. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  37. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  38. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +68 -0
  39. package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
  40. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +21 -0
  41. package/dist/modules/Payment/mx51.d.ts +0 -0
  42. package/dist/modules/Payment/types.d.ts +943 -0
  43. package/dist/modules/Payment/utils.d.ts +19 -0
  44. package/dist/modules/Product/index.d.ts +1 -1
  45. package/dist/modules/ProductList/index.d.ts +2 -0
  46. package/dist/modules/ProductList/index.js +125 -39
  47. package/dist/modules/Quotation/types.d.ts +61 -0
  48. package/dist/modules/Resource/types.d.ts +50 -0
  49. package/dist/modules/Resource/utils.d.ts +23 -0
  50. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  51. package/dist/modules/ResourcePlanner/planner.js +5 -0
  52. package/dist/modules/SalesSummary/types.d.ts +69 -0
  53. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  54. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  55. package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
  56. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
  57. package/dist/modules/Schedule/type.d.ts +157 -0
  58. package/dist/modules/Schedule/types.d.ts +201 -0
  59. package/dist/modules/Schedule/utils.d.ts +67 -0
  60. package/dist/modules/Step/tyeps.d.ts +20 -0
  61. package/dist/modules/SurchargeList/types.d.ts +15 -0
  62. package/dist/plugins/app.d.ts +10 -0
  63. package/dist/plugins/shopStore.d.ts +4 -0
  64. package/dist/plugins/user.d.ts +7 -0
  65. package/dist/server/modules/floor-plan/types.d.ts +43 -0
  66. package/dist/server/modules/menu/types.d.ts +68 -0
  67. package/dist/server/modules/payment/types.d.ts +9 -0
  68. package/dist/server/modules/quotation/types.d.ts +50 -0
  69. package/dist/server/modules/resource/types.d.ts +121 -0
  70. package/dist/server/modules/schedule/types.d.ts +1 -0
  71. package/dist/server/modules/schedule/utils.d.ts +32 -0
  72. package/dist/server/types.d.ts +66 -0
  73. package/dist/server/utils/index.d.ts +5 -0
  74. package/dist/server/utils/schedule.d.ts +14 -0
  75. package/dist/server/utils/time.d.ts +18 -0
  76. package/dist/solution/BaseSales/index.d.ts +12 -1
  77. package/dist/solution/BaseSales/index.js +275 -185
  78. package/dist/solution/BookingByStep/index.d.ts +2 -2
  79. package/dist/solution/BookingTicket/index.d.ts +1 -13
  80. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  81. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  82. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  83. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +38 -0
  84. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  85. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  86. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  87. package/dist/solution/PlaceOrder/index.d.ts +0 -0
  88. package/dist/solution/RegisterAndLogin/config.d.ts +93 -0
  89. package/dist/solution/RegisterAndLogin/types.d.ts +445 -0
  90. package/dist/solution/RegisterAndLogin/utils.d.ts +103 -0
  91. package/dist/solution/UnifiedBookingSales/index.d.ts +23 -1
  92. package/dist/solution/UnifiedBookingSales/index.js +1367 -646
  93. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  94. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
  95. package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  96. package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
  97. package/dist/solution/UnifiedBookingSales/types.d.ts +25 -0
  98. package/dist/solution/UnifiedBookingSales/types.js +2 -0
  99. package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  100. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +277 -0
  101. package/dist/store/createStore.d.ts +3 -0
  102. package/dist/types/index.d.ts +132 -0
  103. package/dist/utils/os-private-payload.d.ts +5 -0
  104. package/dist/utils/payment-number.d.ts +9 -0
  105. package/dist/utils/task.d.ts +40 -0
  106. package/dist/utils/watch.d.ts +102 -0
  107. package/lib/apis/picoding.d.ts +0 -0
  108. package/lib/effects/index.d.ts +19 -0
  109. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  110. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +105 -0
  111. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  112. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  113. package/lib/model/strategy/adapter/dataVariant/type.d.ts +173 -0
  114. package/lib/model/strategy/adapter/promotion/adapter.d.ts +70 -0
  115. package/lib/model/strategy/adapter/promotion/examples.d.ts +224 -0
  116. package/lib/model/strategy/adapter/promotion/type.d.ts +535 -0
  117. package/lib/model/strategy/adapter/type.d.ts +28 -0
  118. package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
  119. package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  120. package/lib/model/strategy/adapter/walletPass/type.d.ts +192 -0
  121. package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  122. package/lib/model/strategy/engine.d.ts +119 -0
  123. package/lib/model/strategy/type.d.ts +245 -0
  124. package/lib/modules/Account/types.d.ts +56 -0
  125. package/lib/modules/BookingContext/types.d.ts +104 -0
  126. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  127. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  128. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  129. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  131. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  132. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  133. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  134. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  135. package/lib/modules/Customer/constants.d.ts +7 -0
  136. package/lib/modules/Date/types.d.ts +84 -0
  137. package/lib/modules/Date/utils.d.ts +36 -0
  138. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  139. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  140. package/lib/modules/Order/payment-utils.d.ts +26 -0
  141. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  142. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  143. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +68 -0
  144. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  145. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +21 -0
  146. package/lib/modules/Payment/mx51.d.ts +0 -0
  147. package/lib/modules/Payment/types.d.ts +943 -0
  148. package/lib/modules/Payment/utils.d.ts +19 -0
  149. package/lib/modules/Product/index.d.ts +1 -1
  150. package/lib/modules/ProductList/index.d.ts +2 -0
  151. package/lib/modules/ProductList/index.js +56 -0
  152. package/lib/modules/Quotation/types.d.ts +61 -0
  153. package/lib/modules/Resource/types.d.ts +50 -0
  154. package/lib/modules/Resource/utils.d.ts +23 -0
  155. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  156. package/lib/modules/ResourcePlanner/planner.js +4 -0
  157. package/lib/modules/SalesSummary/types.d.ts +69 -0
  158. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  159. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  160. package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
  161. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
  162. package/lib/modules/Schedule/type.d.ts +157 -0
  163. package/lib/modules/Schedule/types.d.ts +201 -0
  164. package/lib/modules/Schedule/utils.d.ts +67 -0
  165. package/lib/modules/Step/tyeps.d.ts +20 -0
  166. package/lib/modules/SurchargeList/types.d.ts +15 -0
  167. package/lib/plugins/app.d.ts +10 -0
  168. package/lib/plugins/shopStore.d.ts +4 -0
  169. package/lib/plugins/user.d.ts +7 -0
  170. package/lib/server/modules/floor-plan/types.d.ts +43 -0
  171. package/lib/server/modules/menu/types.d.ts +68 -0
  172. package/lib/server/modules/payment/types.d.ts +9 -0
  173. package/lib/server/modules/quotation/types.d.ts +50 -0
  174. package/lib/server/modules/resource/types.d.ts +121 -0
  175. package/lib/server/modules/schedule/types.d.ts +1 -0
  176. package/lib/server/modules/schedule/utils.d.ts +32 -0
  177. package/lib/server/types.d.ts +66 -0
  178. package/lib/server/utils/index.d.ts +5 -0
  179. package/lib/server/utils/schedule.d.ts +14 -0
  180. package/lib/server/utils/time.d.ts +18 -0
  181. package/lib/solution/BaseSales/index.d.ts +12 -1
  182. package/lib/solution/BaseSales/index.js +65 -0
  183. package/lib/solution/BookingByStep/index.d.ts +2 -2
  184. package/lib/solution/BookingTicket/index.d.ts +1 -13
  185. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  186. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  187. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  188. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +38 -0
  189. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  190. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  191. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  192. package/lib/solution/PlaceOrder/index.d.ts +0 -0
  193. package/lib/solution/RegisterAndLogin/config.d.ts +93 -0
  194. package/lib/solution/RegisterAndLogin/types.d.ts +445 -0
  195. package/lib/solution/RegisterAndLogin/utils.d.ts +103 -0
  196. package/lib/solution/UnifiedBookingSales/index.d.ts +23 -1
  197. package/lib/solution/UnifiedBookingSales/index.js +399 -14
  198. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
  199. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
  200. package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
  201. package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
  202. package/lib/solution/UnifiedBookingSales/types.d.ts +25 -0
  203. package/lib/solution/UnifiedBookingSales/types.js +1 -0
  204. package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
  205. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +151 -0
  206. package/lib/store/createStore.d.ts +3 -0
  207. package/lib/types/index.d.ts +132 -0
  208. package/lib/utils/os-private-payload.d.ts +5 -0
  209. package/lib/utils/payment-number.d.ts +9 -0
  210. package/lib/utils/task.d.ts +40 -0
  211. package/lib/utils/watch.d.ts +102 -0
  212. package/package.json +1 -1
@@ -63,8 +63,10 @@ Object.keys(_types).forEach(function (key) {
63
63
  });
64
64
  });
65
65
  var _remoteOccupancyCache = require("./remoteOccupancyCache");
66
+ var _sessionResourceCache = require("./sessionResourceCache");
66
67
  var _businessAvailability = require("./businessAvailability");
67
68
  var _catalogQueryBatch = require("./catalogQueryBatch");
69
+ var _venueCatalogSession = require("./venueCatalogSession");
68
70
  var _BookingTicket = require("../BookingTicket");
69
71
  var _localClock = require("../../modules/ResourcePlanner/localClock");
70
72
  var _platform = require("../../utils/platform");
@@ -232,6 +234,7 @@ const MAX_AVAILABILITY_RANGE_DAYS = 90;
232
234
  const MAX_AVAILABILITY_CONTEXT_REGISTRY = 128;
233
235
  const MAX_AVAILABILITY_PROJECTION_POOL = 16;
234
236
  const MAX_REMOTE_OCCUPANCY_RESOURCE_DATE_CELLS = 4096;
237
+ const PREVIEW_OCCUPANCY_CACHE_MAX_AGE_MS = 30 * 1000;
235
238
  function isValidClockTime(value) {
236
239
  const match = /^(\d{2}):(\d{2})$/.exec(value);
237
240
  if (!match) return false;
@@ -1228,6 +1231,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1228
1231
  runtimeInitializationGeneration = 0;
1229
1232
  runtimeOpenDataDestroyed = false;
1230
1233
  unifiedProductCatalog = [];
1234
+ venueCatalogSessions = new Set();
1235
+ venueCatalogSessionKey;
1236
+ venueCatalogMenus;
1237
+ venueVariantDetails = new Map();
1231
1238
  availabilityRuntimeOffsetMinutes = null;
1232
1239
  availabilityScheduleCatalog = null;
1233
1240
  availabilityProjectionSequence = 0;
@@ -1238,6 +1245,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1238
1245
  availabilityPrepareInFlight = new Map();
1239
1246
  availabilityProjectionRefreshInFlight = new Map();
1240
1247
  availabilityRemoteOccupancyCache = new _remoteOccupancyCache.AvailabilityRemoteOccupancyCache(MAX_REMOTE_OCCUPANCY_RESOURCE_DATE_CELLS);
1248
+ availabilitySessionResourceCache = new _sessionResourceCache.AvailabilitySessionResourceCache();
1241
1249
  availabilityRemoteResourceQueryInFlight = new Map();
1242
1250
  availabilityRemoteResourceQuerySequence = 0;
1243
1251
  availabilityRemoteResourceEpoch = 0;
@@ -1434,6 +1442,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1434
1442
  clearAvailabilityRemoteResourceState() {
1435
1443
  this.availabilityRemoteResourceEpoch += 1;
1436
1444
  this.availabilityRemoteOccupancyCache.clear();
1445
+ this.availabilitySessionResourceCache.clear();
1437
1446
  this.availabilityRemoteResourceQueryInFlight.clear();
1438
1447
  this.availabilityRemoteResourceQuerySequence = 0;
1439
1448
  }
@@ -2214,6 +2223,319 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2214
2223
  async queryCatalogProductDetail(params) {
2215
2224
  return this.loadCatalogProductDetail(params, query => this.queryCatalogSnapshot(query));
2216
2225
  }
2226
+ isVenueCatalogLocalPricingActive() {
2227
+ return this.venueCatalogSessions.size > 0;
2228
+ }
2229
+ getVenueCatalogLocalPriceSource(productId, selectedProduct) {
2230
+ const scope = this.getRuntimeOpenDataScope();
2231
+ const role = selectedProduct?.metadata?.venue_booking_role;
2232
+ const poolRole = role === 'party_extra' || role === 'tickets_extra' ? 'extras' : role === 'party_main' || role === 'tickets' ? 'main' : undefined;
2233
+ const matches = Array.from(this.venueCatalogSessions).filter(entry => entry.scope === scope && entry.generation === this.runtimeInitializationGeneration && (!poolRole || entry.role === poolRole) && entry.pool?.products.some(row => Number(row.id) === productId));
2234
+ if (!matches.length) return undefined;
2235
+ const pool = matches[0].pool;
2236
+ const product = this.getVenueCatalogHydratedProduct(pool.products.find(row => Number(row.id) === productId));
2237
+ // Legacy promotion/gift inputs may have no venue role. Equivalent complete
2238
+ // sources are unambiguous; different pool snapshots must never use Set order.
2239
+ if (matches.slice(1).some(entry => !(0, _lodashEs.isEqual)(product, this.getVenueCatalogHydratedProduct(entry.pool.products.find(row => Number(row.id) === productId))) || !(0, _lodashEs.isEqual)(pool.pricingMenus, entry.pool.pricingMenus))) return undefined;
2240
+ return {
2241
+ product: (0, _lodashEs.cloneDeep)(product),
2242
+ menuList: (0, _lodashEs.cloneDeep)(pool.pricingMenus)
2243
+ };
2244
+ }
2245
+ async getProductByIds(ids, options) {
2246
+ const active = this.isVenueCatalogLocalPricingActive();
2247
+ const products = await super.getProductByIds(ids, active ? {
2248
+ loadMissing: false
2249
+ } : options);
2250
+ return active ? products.map(product => this.getVenueCatalogHydratedProduct(product)) : products;
2251
+ }
2252
+ getVenueCatalogHydratedProduct(product) {
2253
+ const variants = this.venueVariantDetails.get(Number(product.id ?? product.product_id))?.data;
2254
+ return variants ? {
2255
+ ...(0, _lodashEs.cloneDeep)(product),
2256
+ variant: (0, _lodashEs.cloneDeep)(variants)
2257
+ } : (0, _lodashEs.cloneDeep)(product);
2258
+ }
2259
+
2260
+ /** Explicit user opening for legacy promotion/gift SKU hosts. Pure readers never call this. */
2261
+ async prepareVenueCatalogProductDetail(params) {
2262
+ if (!this.isVenueCatalogLocalPricingActive()) throw (0, _venueCatalogSession.venueCatalogError)('VENUE_CATALOG_REQUIRED', 'Open a venue catalog before configuring this product.');
2263
+ const owner = this.venueCatalogSessionKey;
2264
+ const scope = this.getRuntimeOpenDataScope();
2265
+ const generation = this.runtimeInitializationGeneration;
2266
+ const source = this.getVenueCatalogLocalPriceSource(params.product_id);
2267
+ if (!source) return undefined;
2268
+ await this.hydrateVenueVariantDetail(source.product, params);
2269
+ if (this.runtimeOpenDataDestroyed || !this.isVenueCatalogLocalPricingActive() || owner !== this.venueCatalogSessionKey || scope !== this.getRuntimeOpenDataScope() || generation !== this.runtimeInitializationGeneration) {
2270
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_CATALOG_STALE', 'The venue catalog changed while loading product options.');
2271
+ }
2272
+ return this.getVenueCatalogHydratedProduct(source.product);
2273
+ }
2274
+ async hydrateVenueVariantDetail(raw, params) {
2275
+ // is_variant is the backend's explicit gate. Ordinary retail never requests detail.
2276
+ if (Number(raw.is_variant) !== 1) return;
2277
+ const count = Number(raw.variant_count) || 0;
2278
+ if (Array.isArray(raw.variant) && raw.variant.length > 0 && raw.variant.length >= count) return;
2279
+ const productId = Number(raw.id ?? raw.product_id);
2280
+ let entry = this.venueVariantDetails.get(productId);
2281
+ if (entry?.failed && params.retry === true) {
2282
+ this.venueVariantDetails.delete(productId);
2283
+ entry = undefined;
2284
+ }
2285
+ if (!entry) {
2286
+ const owner = this.venueCatalogSessionKey;
2287
+ const scope = this.getRuntimeOpenDataScope();
2288
+ const generation = this.runtimeInitializationGeneration;
2289
+ const core = this.core;
2290
+ const request = this.request;
2291
+ const next = {
2292
+ promise: Promise.resolve([])
2293
+ };
2294
+ const assertCurrent = () => {
2295
+ if (this.runtimeOpenDataDestroyed || !this.isVenueCatalogLocalPricingActive() || owner !== this.venueCatalogSessionKey || scope !== this.getRuntimeOpenDataScope() || generation !== this.runtimeInitializationGeneration || core !== this.core || request !== this.request || this.venueVariantDetails.get(productId) !== next) {
2296
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_CATALOG_STALE', 'The venue catalog changed while loading product options.');
2297
+ }
2298
+ };
2299
+ this.venueVariantDetails.set(productId, next);
2300
+ next.promise = Promise.resolve().then(async () => {
2301
+ assertCurrent();
2302
+ const response = await request.get(`/product/show/${productId}`, {
2303
+ open_bundle: 1,
2304
+ with_schedule: 1,
2305
+ is_eject: 1,
2306
+ with: [..._clientDataVariants.PRODUCT_QUERY_DATA_VARIANT_RELATIONS]
2307
+ }, {
2308
+ useCache: false,
2309
+ customToast: () => {}
2310
+ });
2311
+ assertCurrent();
2312
+ if (response?.status === false || response?.code != null && Number(response.code) !== 200) {
2313
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_VARIANT_DETAIL_FAILED', response?.message || 'Product options could not be loaded.');
2314
+ }
2315
+ const detail = response?.data?.item ?? response?.data;
2316
+ if (Number(detail?.id ?? detail?.product_id) !== productId || !Array.isArray(detail?.variant) || !detail.variant.length || detail.variant.length < count) {
2317
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_VARIANT_DETAIL_INCOMPLETE', 'Complete product variants are unavailable. Please retry.');
2318
+ }
2319
+ const variants = detail.variant.map(value => {
2320
+ const variant = (0, _lodashEs.cloneDeep)(value);
2321
+ const original = variant._dataVariant?.original;
2322
+ const evaluated = variant._dataVariant || Array.isArray(variant.metadata?.data_variant_ids);
2323
+ const basePrice = original?.price ?? original?.base_price ?? variant.base_price ?? (evaluated ? undefined : variant.price);
2324
+ if (!Number.isSafeInteger(Number(variant.id)) || Number(variant.id) <= 0 || basePrice === undefined || basePrice === null || basePrice === '' || !Number.isFinite(Number(basePrice))) {
2325
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_VARIANT_DETAIL_INCOMPLETE', 'The base price for a product variant is unavailable.');
2326
+ }
2327
+ // Copy only combination SKU data. The pool's price/data_variants and
2328
+ // pricing metadata remain its original baseline for every later context.
2329
+ variant.price = basePrice;
2330
+ variant.base_price = basePrice;
2331
+ if (variant.selling_price !== undefined) variant.selling_price = basePrice;
2332
+ delete variant._dataVariant;
2333
+ if (variant.metadata) delete variant.metadata.data_variant_ids;
2334
+ return variant;
2335
+ });
2336
+ next.data = variants;
2337
+ for (const pool of this.venueCatalogSessions) {
2338
+ if (pool.scope !== scope || !pool.pool) continue;
2339
+ const product = pool.pool.products.find(row => Number(row.id) === productId);
2340
+ if (!product) continue;
2341
+ const hydrated = this.getVenueCatalogHydratedProduct(product);
2342
+ this.store.products?.rememberRawProductQueryResult?.([(0, _lodashEs.cloneDeep)(hydrated)]);
2343
+ this.store.products?.addProduct?.([(0, _lodashEs.cloneDeep)(hydrated)]);
2344
+ }
2345
+ return variants;
2346
+ }).catch(error => {
2347
+ next.failed = true;
2348
+ throw error;
2349
+ });
2350
+ entry = next;
2351
+ }
2352
+ await entry.promise;
2353
+ }
2354
+
2355
+ /** One complete raw product query per explicitly configured pool for this page lifetime. */
2356
+ createVenueCatalogSession(params) {
2357
+ if (!(0, _platform.isCustomerUserPlatform)(this.otherParams?.platform)) {
2358
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_CATALOG_PLATFORM_UNSUPPORTED', 'Venue catalog sessions require a customer platform.');
2359
+ }
2360
+ const ids = params.menu_list_ids;
2361
+ if (!Array.isArray(ids) || !ids.length || ids.some(id => !Number.isSafeInteger(id) || id <= 0)) {
2362
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_MENU_REQUIRED', 'Choose an explicit menu for this venue product pool.');
2363
+ }
2364
+ const menuIds = [...new Set(ids)].sort((a, b) => a - b);
2365
+ const scope = this.getRuntimeOpenDataScope();
2366
+ const generation = this.runtimeInitializationGeneration;
2367
+ const core = this.core;
2368
+ const request = this.request;
2369
+ const entry = {
2370
+ scope,
2371
+ generation,
2372
+ role: params.poolRole
2373
+ };
2374
+ const sessionKey = JSON.stringify([scope, generation, params.sessionKey ?? null]);
2375
+ if (!this.venueCatalogSessions.size || sessionKey !== this.venueCatalogSessionKey) {
2376
+ // React may create new page pools before disposing the old page's pools.
2377
+ // The explicit session identity prevents reusing old-order occupancy then.
2378
+ this.venueCatalogSessions.clear();
2379
+ this.venueCatalogSessionKey = sessionKey;
2380
+ this.venueCatalogMenus = undefined;
2381
+ this.venueVariantDetails.clear();
2382
+ this.availabilitySessionResourceCache.clear();
2383
+ }
2384
+ this.venueCatalogSessions.add(entry);
2385
+ const assertCurrent = () => {
2386
+ if (!this.venueCatalogSessions.has(entry)) {
2387
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_CATALOG_DISPOSED', 'The venue catalog session is closed.');
2388
+ }
2389
+ if (this.runtimeOpenDataDestroyed || this.core !== core || this.request !== request || generation !== this.runtimeInitializationGeneration || scope !== this.getRuntimeOpenDataScope()) {
2390
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_CATALOG_STALE', 'The venue store context changed. Reopen the booking page.');
2391
+ }
2392
+ };
2393
+ const now = () => {
2394
+ const timezone = String(this.otherParams?.businessTimezone || this.getPickupTimingContextData('timezone') || '').trim();
2395
+ if (!timezone) throw (0, _venueCatalogSession.venueCatalogError)('VENUE_TIMEZONE_REQUIRED', 'The venue timezone is not ready.');
2396
+ const parts = new Intl.DateTimeFormat('en-GB', {
2397
+ timeZone: timezone,
2398
+ year: 'numeric',
2399
+ month: '2-digit',
2400
+ day: '2-digit',
2401
+ hour: '2-digit',
2402
+ minute: '2-digit',
2403
+ second: '2-digit',
2404
+ hourCycle: 'h23'
2405
+ }).formatToParts(new Date());
2406
+ const part = type => parts.find(item => item.type === type)?.value;
2407
+ return `${part('year')}-${part('month')}-${part('day')} ${part('hour')}:${part('minute')}:${part('second')}`;
2408
+ };
2409
+ const snapshot = (pool, input) => {
2410
+ assertCurrent();
2411
+ if (input.menu_list_ids && JSON.stringify([...new Set(input.menu_list_ids)].sort((a, b) => a - b)) !== JSON.stringify(menuIds)) {
2412
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_MENU_SCOPE_CHANGED', 'This catalog session belongs to another menu.');
2413
+ }
2414
+ const current = now();
2415
+ const datetime = input.schedule_datetime || (input.schedule_date ? `${input.schedule_date} ${current.slice(11)}` : current);
2416
+ if (!(0, _localClock.parseLocalDateTime)(datetime.replace('T', ' ')) || input.schedule_date && datetime.slice(0, 10) !== input.schedule_date) {
2417
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_CATALOG_DATETIME_INVALID', 'Choose a valid venue catalog date and time.');
2418
+ }
2419
+ const menus = (0, _venueCatalogSession.activeVenueMenus)(pool.menus, this.getAvailabilityScheduleCatalog(), datetime, Boolean(input.schedule_date && !input.schedule_datetime));
2420
+ let products = pool.products.filter(product => menus.some(menu => (0, _venueCatalogSession.productMatchesVenueMenu)(product, menu))).map(product => this.getVenueCatalogHydratedProduct(product));
2421
+ if (input.product_ids?.length) products = products.filter(product => input.product_ids.some(id => Number(id) === Number(product.id)));
2422
+ const user = this.core.getPlugin?.('user');
2423
+ const queryPayload = {
2424
+ schedule_date: datetime.slice(0, 10),
2425
+ schedule_datetime: datetime,
2426
+ customer_id: input.customer_id ?? this.getTempOrder()?.customer_id ?? user?.get?.()?.id,
2427
+ strategy_context: {
2428
+ ...this.getPriceQueryStrategyContext(),
2429
+ ...(input.strategy_context || {})
2430
+ }
2431
+ };
2432
+ const result = (0, _clientDataVariants.tryResolveClientDataVariants)({
2433
+ core: this.core,
2434
+ otherParams: this.otherParams,
2435
+ products: (0, _lodashEs.cloneDeep)(products),
2436
+ queryPayload,
2437
+ handledByOsServer: false,
2438
+ scheduleList: this.getAvailabilityScheduleCatalog(),
2439
+ menuList: pool.pricingMenus
2440
+ });
2441
+ if (result.status !== 'resolved' && result.status !== 'empty') {
2442
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_LOCAL_PRICE_UNAVAILABLE', 'Complete product pricing rules are not ready. Please retry.');
2443
+ }
2444
+ return result.products.slice().sort((a, b) => Number(b.sort || 0) - Number(a.sort || 0));
2445
+ };
2446
+ return (0, _venueCatalogSession.createVenueCatalogSessionAdapter)({
2447
+ assertCurrent,
2448
+ load: async () => {
2449
+ if (!this.venueCatalogMenus || this.venueCatalogMenus.scope !== scope) {
2450
+ const promise = request.get('/form/data/v1', {
2451
+ skip: 1,
2452
+ num: 999,
2453
+ code: 'menu_list'
2454
+ }, {
2455
+ useCache: false,
2456
+ customToast: () => {}
2457
+ }).then(response => (0, _venueCatalogSession.readVenueCatalogList)(response, 'Venue menus'));
2458
+ this.venueCatalogMenus = {
2459
+ scope,
2460
+ promise
2461
+ };
2462
+ void promise.catch(() => {
2463
+ if (this.venueCatalogMenus?.promise === promise) this.venueCatalogMenus = undefined;
2464
+ });
2465
+ }
2466
+ const pricingMenus = await this.venueCatalogMenus.promise;
2467
+ const menus = (0, _venueCatalogSession.validateVenueMenus)(pricingMenus, menuIds);
2468
+ assertCurrent();
2469
+ // A menu query with a date may exclude future members. Read the raw ID union
2470
+ // without menu/time/customer pricing filters, then filter collection/all menus locally.
2471
+ const onlyIds = menus.every(menu => menu.partyroom_package.type === 'products');
2472
+ const onlyCollections = menus.every(menu => menu.partyroom_package.type === 'product_collection');
2473
+ const productIds = onlyIds ? [...new Set(menus.flatMap(menu => menu.partyroom_package.products.map(product => Number(product.product_id))))] : undefined;
2474
+ const collections = onlyCollections ? [...new Set(menus.flatMap(menu => menu.partyroom_package.products.map(product => String(product.product_collection_id))))] : undefined;
2475
+ const products = onlyIds && !productIds?.length ? [] : await this.store.products.loadVenueCatalogPool({
2476
+ product_ids: productIds,
2477
+ collection: collections,
2478
+ category_ids: params.category_ids,
2479
+ extension_type: params.extension_type,
2480
+ cacheId: this.cacheId
2481
+ });
2482
+ assertCurrent();
2483
+ const pool = {
2484
+ menus,
2485
+ pricingMenus: (0, _lodashEs.cloneDeep)(pricingMenus),
2486
+ products: products.filter(product => menus.some(menu => (0, _venueCatalogSession.productMatchesVenueMenu)(product, menu)))
2487
+ };
2488
+ entry.pool = (0, _lodashEs.cloneDeep)(pool);
2489
+ // Legacy marketing lookups can reuse complete records without changing
2490
+ // either pool's membership or publishing a replacement sales catalog.
2491
+ this.store.products.rememberRawProductQueryResult((0, _lodashEs.cloneDeep)(pool.products));
2492
+ this.store.products.addProduct((0, _lodashEs.cloneDeep)(pool.products));
2493
+ return pool;
2494
+ },
2495
+ snapshot,
2496
+ prepareDetail: async (pool, query) => {
2497
+ const raw = pool.products.find(product => Number(product.id) === Number(query.product_id));
2498
+ if (raw) await this.hydrateVenueVariantDetail(raw, query);
2499
+ assertCurrent();
2500
+ },
2501
+ quote: async (pool, query) => {
2502
+ const product = query.product;
2503
+ const productId = Number(product?.product_id ?? product?.id);
2504
+ const booking = query.booking;
2505
+ const datetime = booking?.start_date ? `${booking.start_date} ${booking.start_time || '00:00:00'}` : query.datetime || now();
2506
+ if (!snapshot(pool, {
2507
+ product_ids: [productId],
2508
+ schedule_datetime: datetime,
2509
+ customer_id: query.customer_id == null ? undefined : Number(query.customer_id)
2510
+ }).length) {
2511
+ throw (0, _venueCatalogSession.venueCatalogError)('VENUE_PRODUCT_UNAVAILABLE', 'This product is unavailable in the selected menu at this time.');
2512
+ }
2513
+ const raw = pool.products.find(row => Number(row.id) === productId);
2514
+ if (!raw) throw (0, _venueCatalogSession.venueCatalogError)('VENUE_PRODUCT_UNAVAILABLE', 'This product is not in the venue catalog.');
2515
+ const result = await this.calculateVenueCatalogProductBookingPrice({
2516
+ ...query,
2517
+ datetime
2518
+ }, {
2519
+ product: this.getVenueCatalogHydratedProduct(raw),
2520
+ menuList: pool.pricingMenus
2521
+ });
2522
+ assertCurrent();
2523
+ return result;
2524
+ },
2525
+ onRetry: () => {
2526
+ for (const [id, detail] of this.venueVariantDetails) if (detail.failed) this.venueVariantDetails.delete(id);
2527
+ },
2528
+ onDispose: () => {
2529
+ this.venueCatalogSessions.delete(entry);
2530
+ if (!this.venueCatalogSessions.size) {
2531
+ this.venueCatalogSessionKey = undefined;
2532
+ this.venueCatalogMenus = undefined;
2533
+ this.venueVariantDetails.clear();
2534
+ this.availabilitySessionResourceCache.clear();
2535
+ }
2536
+ }
2537
+ });
2538
+ }
2217
2539
 
2218
2540
  /**
2219
2541
  * Opt-in calendar/card preview batching. Results expire after sixty seconds or a
@@ -2811,6 +3133,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2811
3133
  };
2812
3134
  }
2813
3135
  assertAvailabilityPrepareParams(params) {
3136
+ if (params.occupancyCachePolicy !== undefined && params.occupancyCachePolicy !== 'cache_first' && params.occupancyCachePolicy !== 'session') {
3137
+ throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', 'Unknown occupancyCachePolicy');
3138
+ }
2814
3139
  assertAvailabilityCatalogProductIds(params.productIds, 'prepare.productIds');
2815
3140
  const hasProductAnchor = Array.isArray(params.productIds) && params.productIds.length > 0;
2816
3141
  const hasResourceAnchor = Array.isArray(params.resourceIds) && params.resourceIds.length > 0;
@@ -3021,12 +3346,26 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3021
3346
  }
3022
3347
  };
3023
3348
  assertCurrent();
3024
- const resources = await this.fetchAvailabilityResourcesV2({
3349
+ const resourceQuery = {
3025
3350
  dateRange: {
3026
3351
  startDate: date,
3027
3352
  endDate: date
3028
3353
  },
3029
- resourceIds,
3354
+ resourceIds
3355
+ };
3356
+ // Match normalizeAvailabilityPrepareDescriptor so confirmation reuses exactly
3357
+ // the same resource/date coverage as the selection projection.
3358
+ const timezone = String(this.otherParams?.businessTimezone || Intl.DateTimeFormat().resolvedOptions().timeZone || 'Asia/Shanghai').trim();
3359
+ const resources = this.isVenueCatalogLocalPricingActive() ? await this.availabilitySessionResourceCache.load({
3360
+ scopeKey: `${scope}:${this.buildAvailabilityRemoteResourceScopeKey(timezone)}`,
3361
+ timezoneName: timezone,
3362
+ ...resourceQuery,
3363
+ fetch: query => this.fetchAvailabilityResourcesV2({
3364
+ ...query,
3365
+ strictResponse: true
3366
+ })
3367
+ }) : await this.fetchAvailabilityResourcesV2({
3368
+ ...resourceQuery,
3030
3369
  strictResponse: true
3031
3370
  });
3032
3371
  assertCurrent();
@@ -3043,7 +3382,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3043
3382
  const cacheParams = {
3044
3383
  scopeKey,
3045
3384
  resourceIds: normalizedResourceIds,
3046
- dateRange: params.dateRange
3385
+ dateRange: params.dateRange,
3386
+ maxAgeMs: params.maxAgeMs
3047
3387
  };
3048
3388
  const cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
3049
3389
  if (cachedRawResources) {
@@ -3058,6 +3398,22 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3058
3398
  }
3059
3399
  return cachedRawResources;
3060
3400
  }
3401
+ if (params.maxAgeMs !== undefined) {
3402
+ // A visible-month request can cover a concurrent day/resource-subset preview.
3403
+ // Only share fully covering requests; partial overlaps keep the normal fetch path.
3404
+ const epoch = this.availabilityRemoteResourceEpoch;
3405
+ const covering = Array.from(this.availabilityRemoteResourceQueryInFlight.values()).find(entry => entry.epoch === epoch && entry.scopeKey === scopeKey && entry.dateRange.startDate <= params.dateRange.startDate && entry.dateRange.endDate >= params.dateRange.endDate && normalizedResourceIds.every(id => entry.resourceIds.some(other => String(other) === String(id))));
3406
+ if (covering) {
3407
+ await covering.promise;
3408
+ if (epoch !== this.availabilityRemoteResourceEpoch) {
3409
+ throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'Resource settings changed while loading. Please prepare again.');
3410
+ }
3411
+ // Read a detached, correctly sliced graph after publication. A newer overlapping
3412
+ // response may have invalidated cells, in which case fetch this exact range below.
3413
+ const coveredResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
3414
+ if (coveredResources) return coveredResources;
3415
+ }
3416
+ }
3061
3417
  return await this.refreshAvailabilityRemoteResourceQuery({
3062
3418
  timezone: params.timezone,
3063
3419
  dateRange: params.dateRange,
@@ -3079,19 +3435,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3079
3435
  }
3080
3436
  this.availabilityRemoteResourceQuerySequence += 1;
3081
3437
  const writeVersion = this.availabilityRemoteResourceQuerySequence;
3438
+ const scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
3082
3439
  const promise = this.fetchAvailabilityResourcesV2({
3083
3440
  dateRange: params.dateRange,
3084
3441
  resourceIds: normalizedResourceIds
3085
- });
3086
- this.availabilityRemoteResourceQueryInFlight.set(queryKey, {
3087
- epoch,
3088
- promise
3089
- });
3090
- try {
3091
- const rawResources = await promise;
3442
+ }).then(rawResources => {
3092
3443
  if (epoch === this.availabilityRemoteResourceEpoch) {
3093
3444
  this.availabilityRemoteOccupancyCache.publish({
3094
- scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
3445
+ scopeKey,
3095
3446
  timezoneName: params.timezone,
3096
3447
  resourceIds: normalizedResourceIds,
3097
3448
  dateRange: params.dateRange,
@@ -3100,6 +3451,18 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3100
3451
  });
3101
3452
  }
3102
3453
  return rawResources;
3454
+ });
3455
+ this.availabilityRemoteResourceQueryInFlight.set(queryKey, {
3456
+ epoch,
3457
+ scopeKey,
3458
+ dateRange: {
3459
+ ...params.dateRange
3460
+ },
3461
+ resourceIds: [...normalizedResourceIds],
3462
+ promise
3463
+ });
3464
+ try {
3465
+ return await promise;
3103
3466
  } finally {
3104
3467
  const current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
3105
3468
  if (current?.promise === promise) {
@@ -3115,6 +3478,24 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3115
3478
  resourceOccupancies: []
3116
3479
  };
3117
3480
  }
3481
+ if (params.fetchPolicy === 'session') {
3482
+ const rawResources = await this.availabilitySessionResourceCache.load({
3483
+ scopeKey: `${this.getRuntimeOpenDataScope()}:${this.buildAvailabilityRemoteResourceScopeKey(params.timezone)}`,
3484
+ timezoneName: params.timezone,
3485
+ resourceIds,
3486
+ dateRange: params.dateRange,
3487
+ fetch: query => this.fetchAvailabilityResourcesV2({
3488
+ ...query,
3489
+ strictResponse: true
3490
+ })
3491
+ });
3492
+ return buildAvailabilityResourcesFromV2({
3493
+ rawResources,
3494
+ scheduleList: params.scheduleList,
3495
+ dateRange: params.dateRange,
3496
+ fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
3497
+ });
3498
+ }
3118
3499
  if (Array.isArray(params.rawResources) && params.fetchPolicy !== 'refresh') {
3119
3500
  return buildAvailabilityResourcesFromV2({
3120
3501
  rawResources: params.rawResources,
@@ -3149,7 +3530,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3149
3530
  };
3150
3531
  const rawResources = params.fetchPolicy === 'refresh' ? await this.refreshAvailabilityRemoteResourceQuery(remoteQuery) : await this.fetchAndPublishAvailabilityResourcesV2({
3151
3532
  ...remoteQuery,
3152
- useCacheOnHit: true
3533
+ useCacheOnHit: params.fetchPolicy !== 'cache_first',
3534
+ ...(params.fetchPolicy === 'cache_first' ? {
3535
+ maxAgeMs: PREVIEW_OCCUPANCY_CACHE_MAX_AGE_MS
3536
+ } : {})
3153
3537
  });
3154
3538
  return buildAvailabilityResourcesFromV2({
3155
3539
  rawResources,
@@ -3373,8 +3757,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3373
3757
  products,
3374
3758
  rawResources: normalizedPrepareParams.rawResources,
3375
3759
  scheduleList,
3376
- // An explicit internal policy (notably commit's cache_only) remains authoritative.
3377
- fetchPolicy: options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : 'default'),
3760
+ // Explicit Venue sessions retain physical occupancy coverage across preview,
3761
+ // selection and commit. Cart-derived occupancy is still rebuilt below.
3762
+ fetchPolicy: normalizedPrepareParams.occupancyCachePolicy === 'session' ? 'session' : options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : normalizedPrepareParams.occupancyCachePolicy === 'cache_first' ? 'cache_first' : 'default'),
3378
3763
  fallbackResources: options.fallbackResources
3379
3764
  });
3380
3765
  const tempOrder = this.getTempOrder();
@@ -11,6 +11,8 @@ export declare class AvailabilityRemoteOccupancyCache {
11
11
  scopeKey: string;
12
12
  resourceIds: AvailabilityId[];
13
13
  dateRange: AvailabilityDateRange;
14
+ /** Only opt-in preview reads expire cells; legacy reads retain their SWR semantics. */
15
+ maxAgeMs?: number;
14
16
  }): Record<string, any>[] | null;
15
17
  hasCompleteCoverage(params: {
16
18
  scopeKey: string;
@@ -117,6 +117,7 @@ class AvailabilityRemoteOccupancyCache {
117
117
  const requestedResourceIds = uniqueIds(params.resourceIds);
118
118
  const requestedDates = buildDateList(params.dateRange);
119
119
  if (requestedResourceIds.length === 0 || requestedDates.length === 0) return [];
120
+ const now = Date.now();
120
121
  const resources = [];
121
122
  for (const resourceId of requestedResourceIds) {
122
123
  const resourceKey = this.buildResourceKey(params.scopeKey, resourceId);
@@ -125,6 +126,7 @@ class AvailabilityRemoteOccupancyCache {
125
126
  const cellKey = this.buildCellKey(resourceKey, date);
126
127
  const cell = this.touchCell(cellKey);
127
128
  if (!cell) return null;
129
+ if (params.maxAgeMs !== undefined && (now < cell.fetchedAt || now - cell.fetchedAt >= params.maxAgeMs)) return null;
128
130
  cell.eventList.forEach(rawEvent => {
129
131
  eventList.set(buildEventIdentity(resourceId, rawEvent), (0, _lodashEs.cloneDeep)(rawEvent));
130
132
  });
@@ -0,0 +1,27 @@
1
+ import type { AvailabilityDateRange } from '../../modules/ResourcePlanner';
2
+ type ResourceId = number | string;
3
+ type RawResource = Record<string, any>;
4
+ export interface AvailabilitySessionResourceQuery {
5
+ resourceIds: ResourceId[];
6
+ dateRange: AvailabilityDateRange;
7
+ }
8
+ export interface AvailabilitySessionResourceLoadParams extends AvailabilitySessionResourceQuery {
9
+ /** The owner supplies shop/tenant, order cache, business and channel identity. */
10
+ scopeKey: string;
11
+ timezoneName: string;
12
+ /** Must reject transport/business errors; only a successful empty array is negative coverage. */
13
+ fetch: (query: AvailabilitySessionResourceQuery) => Promise<RawResource[]>;
14
+ }
15
+ /**
16
+ * Opt-in venue-session snapshots. Unlike the legacy SWR cache, a covered resource/day is never
17
+ * refreshed or evicted during this session. Only missing cells are fetched, including when a new
18
+ * resource set partly overlaps an earlier one. The final backend submission remains authoritative.
19
+ */
20
+ export declare class AvailabilitySessionResourceCache {
21
+ private readonly cells;
22
+ private readonly pending;
23
+ private generation;
24
+ clear(): void;
25
+ load(params: AvailabilitySessionResourceLoadParams): Promise<RawResource[]>;
26
+ }
27
+ export {};