@pisell/pisellos 2.3.216 → 2.3.218

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -642,7 +642,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
642
642
  generateIdempotencyToken(): string;
643
643
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
644
644
  createOrder(params: CommitOrderParams['query']): {
645
- type: "virtual" | "appointment_booking";
645
+ type: "appointment_booking" | "virtual";
646
646
  platform: string;
647
647
  sales_channel: string;
648
648
  order_sales_channel: string;
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
345
+ weekNum: 0 | 1 | 2 | 3 | 5 | 6 | 4;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -91,6 +91,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
91
91
  private availabilityProjectionRefreshInFlight;
92
92
  private availabilityRemoteOccupancyCache;
93
93
  private availabilitySessionResourceCache;
94
+ private readonly fetchAvailabilitySessionResources;
94
95
  private availabilityRemoteResourceQueryInFlight;
95
96
  private availabilityRemoteResourceQuerySequence;
96
97
  private availabilityRemoteResourceEpoch;
@@ -1412,6 +1412,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1412
1412
  _defineProperty(_assertThisInitialized(_this), "availabilityProjectionRefreshInFlight", new Map());
1413
1413
  _defineProperty(_assertThisInitialized(_this), "availabilityRemoteOccupancyCache", new AvailabilityRemoteOccupancyCache(MAX_REMOTE_OCCUPANCY_RESOURCE_DATE_CELLS));
1414
1414
  _defineProperty(_assertThisInitialized(_this), "availabilitySessionResourceCache", new AvailabilitySessionResourceCache());
1415
+ _defineProperty(_assertThisInitialized(_this), "fetchAvailabilitySessionResources", function (query) {
1416
+ return _this.fetchAvailabilityResourcesV2(_objectSpread(_objectSpread({}, query), {}, {
1417
+ strictResponse: true
1418
+ }));
1419
+ });
1415
1420
  _defineProperty(_assertThisInitialized(_this), "availabilityRemoteResourceQueryInFlight", new Map());
1416
1421
  _defineProperty(_assertThisInitialized(_this), "availabilityRemoteResourceQuerySequence", 0);
1417
1422
  _defineProperty(_assertThisInitialized(_this), "availabilityRemoteResourceEpoch", 0);
@@ -4428,14 +4433,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4428
4433
  return menus.some(function (menu) {
4429
4434
  return productMatchesVenueMenu(product, menu);
4430
4435
  });
4431
- }).map(function (product) {
4432
- return _this15.getVenueCatalogHydratedProduct(product);
4433
4436
  });
4434
4437
  if ((_input$product_ids = input.product_ids) !== null && _input$product_ids !== void 0 && _input$product_ids.length) products = products.filter(function (product) {
4435
4438
  return input.product_ids.some(function (id) {
4436
4439
  return Number(id) === Number(product.id);
4437
4440
  });
4438
4441
  });
4442
+ // Detail/quote reads must not deep-clone every other member of the pool.
4443
+ // Hydration owns a fresh copy of each selected product, including variants.
4444
+ products = products.map(function (product) {
4445
+ return _this15.getVenueCatalogHydratedProduct(product);
4446
+ });
4439
4447
  var user = (_this15$core$getPlugi = (_this15$core = _this15.core).getPlugin) === null || _this15$core$getPlugi === void 0 ? void 0 : _this15$core$getPlugi.call(_this15$core, 'user');
4440
4448
  var queryPayload = {
4441
4449
  schedule_date: datetime.slice(0, 10),
@@ -4446,7 +4454,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4446
4454
  var result = tryResolveClientDataVariants({
4447
4455
  core: _this15.core,
4448
4456
  otherParams: _this15.otherParams,
4449
- products: cloneDeep(products),
4457
+ products: products,
4450
4458
  queryPayload: queryPayload,
4451
4459
  handledByOsServer: false,
4452
4460
  scheduleList: _this15.getAvailabilityScheduleCatalog(),
@@ -6172,11 +6180,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6172
6180
  scopeKey: "".concat(scope, ":").concat(this.buildAvailabilityRemoteResourceScopeKey(timezone)),
6173
6181
  timezoneName: timezone
6174
6182
  }, resourceQuery), {}, {
6175
- fetch: function fetch(query) {
6176
- return _this20.fetchAvailabilityResourcesV2(_objectSpread(_objectSpread({}, query), {}, {
6177
- strictResponse: true
6178
- }));
6179
- }
6183
+ fetch: this.fetchAvailabilitySessionResources
6180
6184
  }));
6181
6185
  case 24:
6182
6186
  _context55.t1 = _context55.sent;
@@ -6395,7 +6399,6 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6395
6399
  key: "loadAvailabilityResources",
6396
6400
  value: function () {
6397
6401
  var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
6398
- var _this22 = this;
6399
6402
  var resourceIds, _rawResources, cachedRawResources, remoteQuery, rawResources;
6400
6403
  return _regeneratorRuntime().wrap(function _callee57$(_context58) {
6401
6404
  while (1) switch (_context58.prev = _context58.next) {
@@ -6420,11 +6423,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6420
6423
  timezoneName: params.timezone,
6421
6424
  resourceIds: resourceIds,
6422
6425
  dateRange: params.dateRange,
6423
- fetch: function fetch(query) {
6424
- return _this22.fetchAvailabilityResourcesV2(_objectSpread(_objectSpread({}, query), {}, {
6425
- strictResponse: true
6426
- }));
6427
- }
6426
+ fetch: this.fetchAvailabilitySessionResources
6428
6427
  });
6429
6428
  case 6:
6430
6429
  _rawResources = _context58.sent;
@@ -6582,7 +6581,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6582
6581
  }, {
6583
6582
  key: "collectCartResourceOccupancies",
6584
6583
  value: function collectCartResourceOccupancies(tempOrder, exclusions) {
6585
- var _this23 = this;
6584
+ var _this22 = this;
6586
6585
  var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
6587
6586
  return bookings.flatMap(function (booking) {
6588
6587
  var _ref59, _booking$product_uid2, _booking$metadata2;
@@ -6599,7 +6598,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6599
6598
  var range = normalizeAvailabilityLocalDateTimeRange({
6600
6599
  startAt: startAt,
6601
6600
  endAt: endAt,
6602
- fixedOffsetMinutes: _this23.getAvailabilityRuntimeOffsetMinutes(),
6601
+ fixedOffsetMinutes: _this22.getAvailabilityRuntimeOffsetMinutes(),
6603
6602
  rollOverEnd: false
6604
6603
  });
6605
6604
  if (!range) return [];
@@ -6617,7 +6616,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6617
6616
  resource: resource
6618
6617
  }
6619
6618
  };
6620
- return _this23.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
6619
+ return _this22.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
6621
6620
  });
6622
6621
  });
6623
6622
  }
@@ -6684,16 +6683,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6684
6683
  }, {
6685
6684
  key: "assertContextualQueryFreshness",
6686
6685
  value: function assertContextualQueryFreshness(context, request) {
6687
- var _this24 = this;
6686
+ var _this23 = this;
6688
6687
  if (request.target === 'time') {
6689
6688
  request.candidates.forEach(function (candidate) {
6690
- _this24.assertAvailabilityCandidateFreshness(context, candidate);
6689
+ _this23.assertAvailabilityCandidateFreshness(context, candidate);
6691
6690
  });
6692
6691
  return;
6693
6692
  }
6694
6693
  if (request.target === 'resource') {
6695
6694
  request.selectedRanges.forEach(function (candidate) {
6696
- _this24.assertAvailabilityCandidateFreshness(context, candidate);
6695
+ _this23.assertAvailabilityCandidateFreshness(context, candidate);
6697
6696
  });
6698
6697
  }
6699
6698
  }
@@ -6742,7 +6741,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6742
6741
  key: "buildAvailabilityProjectionSnapshot",
6743
6742
  value: function () {
6744
6743
  var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
6745
- var _this25 = this;
6744
+ var _this24 = this;
6746
6745
  var options,
6747
6746
  normalizedPrepareParams,
6748
6747
  timezoneLabel,
@@ -6824,7 +6823,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6824
6823
  var range = normalizeAvailabilityLocalDateTimeRange({
6825
6824
  startAt: occupancy.startAt,
6826
6825
  endAt: occupancy.endAt,
6827
- fixedOffsetMinutes: _this25.getAvailabilityRuntimeOffsetMinutes(),
6826
+ fixedOffsetMinutes: _this24.getAvailabilityRuntimeOffsetMinutes(),
6828
6827
  rollOverEnd: false
6829
6828
  });
6830
6829
  if (!range) return [];
@@ -6834,7 +6833,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6834
6833
  })];
6835
6834
  });
6836
6835
  remoteOccupancies = [].concat(_toConsumableArray(loadedResources.resourceOccupancies), _toConsumableArray(loadedResources.includesInjectedRawOccupancies ? [] : injectedRawOccupancies)).filter(function (occupancy) {
6837
- return !_this25.occupancyIsExcluded(occupancy, exclusions);
6836
+ return !_this24.occupancyIsExcluded(occupancy, exclusions);
6838
6837
  });
6839
6838
  cartOccupancies = this.collectCartResourceOccupancies(tempOrder, exclusions);
6840
6839
  preparedAt = this.getAvailabilityRuntimeDateTime();
@@ -6976,7 +6975,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6976
6975
  key: "refreshAvailabilityContextProjection",
6977
6976
  value: function () {
6978
6977
  var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6979
- var _this26 = this;
6978
+ var _this25 = this;
6980
6979
  var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
6981
6980
  return _regeneratorRuntime().wrap(function _callee61$(_context62) {
6982
6981
  while (1) switch (_context62.prev = _context62.next) {
@@ -7001,25 +7000,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7001
7000
  while (1) switch (_context61.prev = _context61.next) {
7002
7001
  case 0:
7003
7002
  _context61.next = 2;
7004
- return _this26.buildAvailabilityProjectionSnapshot(_this26.cloneAvailabilityPrepareParams(context.prepareParams), {
7003
+ return _this25.buildAvailabilityProjectionSnapshot(_this25.cloneAvailabilityPrepareParams(context.prepareParams), {
7005
7004
  durationCandidateAnchorAt: context.durationCandidateAnchorAt
7006
7005
  });
7007
7006
  case 2:
7008
7007
  snapshot = _context61.sent;
7009
- currentContext = _this26.availabilityContextRegistry.get(params.contextId);
7008
+ currentContext = _this25.availabilityContextRegistry.get(params.contextId);
7010
7009
  if (currentContext) {
7011
7010
  _context61.next = 6;
7012
7011
  break;
7013
7012
  }
7014
7013
  return _context61.abrupt("return", null);
7015
7014
  case 6:
7016
- if (!(expectedLifecycleGeneration !== _this26.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
7015
+ if (!(expectedLifecycleGeneration !== _this25.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
7017
7016
  _context61.next = 8;
7018
7017
  break;
7019
7018
  }
7020
7019
  return _context61.abrupt("return", null);
7021
7020
  case 8:
7022
- projectionEntry = _this26.storeAvailabilityProjectionEntry({
7021
+ projectionEntry = _this25.storeAvailabilityProjectionEntry({
7023
7022
  contextId: currentContext.contextId,
7024
7023
  prepareParams: snapshot.prepareParams,
7025
7024
  prepareKey: currentContext.prepareKey,
@@ -7028,7 +7027,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7028
7027
  incrementVersion: true
7029
7028
  });
7030
7029
  _context61.next = 11;
7031
- return _this26.emitAvailabilityDiagnostic({
7030
+ return _this25.emitAvailabilityDiagnostic({
7032
7031
  action: 'refresh',
7033
7032
  contextId: currentContext.contextId,
7034
7033
  contextVersion: projectionEntry.contextVersion,
@@ -7307,7 +7306,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7307
7306
  _this$otherParams48,
7308
7307
  _context$prepareParam2,
7309
7308
  _extractFixedOffsetMi3,
7310
- _this27 = this;
7309
+ _this26 = this;
7311
7310
  var request,
7312
7311
  _yield$this$ensureAva,
7313
7312
  context,
@@ -7423,7 +7422,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7423
7422
  }).map(function (group) {
7424
7423
  return _objectSpread(_objectSpread({}, group), {}, {
7425
7424
  ranges: group.ranges.map(function (candidate) {
7426
- return _this27.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
7425
+ return _this26.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
7427
7426
  })
7428
7427
  });
7429
7428
  }));
@@ -7603,7 +7602,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7603
7602
  var _removeBookingProductsOutsideStartDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(startDate) {
7604
7603
  var _this$getTempOrder5,
7605
7604
  _this$otherParams50,
7606
- _this28 = this;
7605
+ _this27 = this;
7607
7606
  var products, targetDate, identities;
7608
7607
  return _regeneratorRuntime().wrap(function _callee68$(_context69) {
7609
7608
  while (1) switch (_context69.prev = _context69.next) {
@@ -7627,7 +7626,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7627
7626
  if (!getProductLineUid(product) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.product_add_schedule_time) != null) {
7628
7627
  return [];
7629
7628
  }
7630
- var booking = _this28.findLinkedBooking(product);
7629
+ var booking = _this27.findLinkedBooking(product);
7631
7630
  if (!booking || isFulfillmentTimingBooking(booking)) return [];
7632
7631
  var bookingDate = getVisibleCalendarDate(booking.start_date);
7633
7632
  return bookingDate && bookingDate !== targetDate ? [buildAvailabilityLineIdentity(product)] : [];
@@ -7649,7 +7648,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7649
7648
  value: (function () {
7650
7649
  var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(contextId, params) {
7651
7650
  var _this$availabilityCon,
7652
- _this29 = this,
7651
+ _this28 = this,
7653
7652
  _this$otherParams$pla5,
7654
7653
  _this$otherParams51,
7655
7654
  _this$availabilityCon2,
@@ -7676,7 +7675,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7676
7675
  params = _objectSpread(_objectSpread({}, params), {}, {
7677
7676
  availabilityCommitGuard: function availabilityCommitGuard() {
7678
7677
  callerGuard === null || callerGuard === void 0 || callerGuard();
7679
- if (!_this29.isOrderSessionCurrent(calendarOrderSessionId)) {
7678
+ if (!_this28.isOrderSessionCurrent(calendarOrderSessionId)) {
7680
7679
  throw new AvailabilityError('AVAILABILITY_SELECTION_STALE', 'Calendar booking order session changed.');
7681
7680
  }
7682
7681
  }
@@ -7707,21 +7706,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7707
7706
  if (isOrderRememberedSelection) this.assertRememberedOrderSession(params.orderSessionId);
7708
7707
  rememberedOrder = hasCommitGuard ? this.getTempOrder() : null;
7709
7708
  getRememberedCommitIdentity = function getRememberedCommitIdentity() {
7710
- var _this29$otherParams$s, _this29$otherParams, _this29$otherParams2, _this29$core, _this29$getTempOrder, _this29$getTempOrder2;
7709
+ var _this28$otherParams$s, _this28$otherParams, _this28$otherParams2, _this28$core, _this28$getTempOrder, _this28$getTempOrder2;
7711
7710
  return JSON.stringify(stableValue(_objectSpread({
7712
- scope: _this29.getAvailabilityScopeDescriptor(),
7713
- shopId: (_this29$otherParams$s = (_this29$otherParams = _this29.otherParams) === null || _this29$otherParams === void 0 ? void 0 : _this29$otherParams.shop_id) !== null && _this29$otherParams$s !== void 0 ? _this29$otherParams$s : (_this29$otherParams2 = _this29.otherParams) === null || _this29$otherParams2 === void 0 ? void 0 : _this29$otherParams2.shopId,
7714
- contextShopId: (_this29$core = _this29.core) === null || _this29$core === void 0 || (_this29$core = _this29$core.context) === null || _this29$core === void 0 ? void 0 : _this29$core.shop_id
7711
+ scope: _this28.getAvailabilityScopeDescriptor(),
7712
+ shopId: (_this28$otherParams$s = (_this28$otherParams = _this28.otherParams) === null || _this28$otherParams === void 0 ? void 0 : _this28$otherParams.shop_id) !== null && _this28$otherParams$s !== void 0 ? _this28$otherParams$s : (_this28$otherParams2 = _this28.otherParams) === null || _this28$otherParams2 === void 0 ? void 0 : _this28$otherParams2.shopId,
7713
+ contextShopId: (_this28$core = _this28.core) === null || _this28$core === void 0 || (_this28$core = _this28$core.context) === null || _this28$core === void 0 ? void 0 : _this28$core.shop_id
7715
7714
  }, isOrderRememberedSelection ? {
7716
- orderSessionId: _this29.getOrderSessionId()
7715
+ orderSessionId: _this28.getOrderSessionId()
7717
7716
  } : {
7718
- orderId: (_this29$getTempOrder = _this29.getTempOrder()) === null || _this29$getTempOrder === void 0 ? void 0 : _this29$getTempOrder.order_id,
7719
- externalSaleNumber: (_this29$getTempOrder2 = _this29.getTempOrder()) === null || _this29$getTempOrder2 === void 0 ? void 0 : _this29$getTempOrder2.external_sale_number
7717
+ orderId: (_this28$getTempOrder = _this28.getTempOrder()) === null || _this28$getTempOrder === void 0 ? void 0 : _this28$getTempOrder.order_id,
7718
+ externalSaleNumber: (_this28$getTempOrder2 = _this28.getTempOrder()) === null || _this28$getTempOrder2 === void 0 ? void 0 : _this28$getTempOrder2.external_sale_number
7720
7719
  })));
7721
7720
  };
7722
7721
  rememberedCommitIdentity = hasCommitGuard ? getRememberedCommitIdentity() : '';
7723
7722
  availabilityCommitTargetGuard = function availabilityCommitTargetGuard() {
7724
- return (isOrderRememberedSelection ? _this29.isOrderSessionCurrent(params.orderSessionId) : _this29.getTempOrder() === rememberedOrder) && getRememberedCommitIdentity() === rememberedCommitIdentity;
7723
+ return (isOrderRememberedSelection ? _this28.isOrderSessionCurrent(params.orderSessionId) : _this28.getTempOrder() === rememberedOrder) && getRememberedCommitIdentity() === rememberedCommitIdentity;
7725
7724
  };
7726
7725
  guardedCommitPublished = false;
7727
7726
  _context70.next = 26;
@@ -8131,13 +8130,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8131
8130
  availabilityCommitGuard = hasCommitGuard ? function () {
8132
8131
  var _params$availabilityC4, _params2;
8133
8132
  (_params$availabilityC4 = (_params2 = params).availabilityCommitGuard) === null || _params$availabilityC4 === void 0 || _params$availabilityC4.call(_params2);
8134
- _this29.assertAvailabilityCommitWriteCAS(commitWriteGuard);
8133
+ _this28.assertAvailabilityCommitWriteCAS(commitWriteGuard);
8135
8134
  if (!availabilityCommitTargetGuard()) {
8136
- throw _this29.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '记忆时间加购期间订单或业务已变化');
8135
+ throw _this28.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '记忆时间加购期间订单或业务已变化');
8137
8136
  }
8138
8137
  // Same-order immutable snapshots and generated sale IDs preserve the session.
8139
8138
  // Capture the actual object Order is about to publish, not an earlier snapshot.
8140
- if (isOrderRememberedSelection) rememberedOrder = _this29.getTempOrder();
8139
+ if (isOrderRememberedSelection) rememberedOrder = _this28.getTempOrder();
8141
8140
  if (customerSelectionSnapshot || !isRememberedSelection && !strictAvailability) return;
8142
8141
  var currentValidation = validateAvailabilitySelection(refreshedProjection, {
8143
8142
  candidate: refreshedCandidateBase,
@@ -8145,7 +8144,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8145
8144
  partySize: partySize,
8146
8145
  bookingCount: bookingCount
8147
8146
  }, {
8148
- useDurationTimeGrid: _this29.usesDurationTimeGrid(refreshedProjection),
8147
+ useDurationTimeGrid: _this28.usesDurationTimeGrid(refreshedProjection),
8149
8148
  enforceSaleCutoff: true,
8150
8149
  rememberedTimeByProductId: rememberedTimeByProductId
8151
8150
  });
@@ -8243,7 +8242,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8243
8242
  break;
8244
8243
  }
8245
8244
  relatedRetailProducts = params.relatedRetailProducts.map(function (source) {
8246
- var line = _this29.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
8245
+ var line = _this28.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
8247
8246
  if (!line) throw new AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
8248
8247
  // This is the only replacement-specific UID restore. Order checks ownership/collisions.
8249
8248
  var sourceUid = getProductLineUid(source);
@@ -8392,7 +8391,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8392
8391
  }
8393
8392
  // A notification failure after publication must not invite a duplicate add.
8394
8393
  emit = function emit() {
8395
- return _this29.core.effects.emit("".concat(_this29.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
8394
+ return _this28.core.effects.emit("".concat(_this28.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
8396
8395
  };
8397
8396
  if (!guardedCommitPublished) {
8398
8397
  _context70.next = 218;
@@ -21,7 +21,11 @@ export declare class AvailabilitySessionResourceCache {
21
21
  private readonly cells;
22
22
  private readonly pending;
23
23
  private generation;
24
+ private queuedBatches;
25
+ private batchFlushScheduled;
24
26
  clear(): void;
27
+ private enqueueFetch;
28
+ private flushFetchBatches;
25
29
  load(params: AvailabilitySessionResourceLoadParams): Promise<RawResource[]>;
26
30
  }
27
31
  export {};
@@ -1,11 +1,11 @@
1
1
  var _excluded = ["event_list"];
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
6
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
+ 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; }
8
+ 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; }
9
9
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
10
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
11
11
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -15,6 +15,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
15
15
  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); }
16
16
  import { cloneDeep } from 'lodash-es';
17
17
  import { dateOrdinalFromLocalDate, formatLocalDate, localDateTimeToScalar, localDateToScalarStart, nextDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
18
+ function sessionChangedError() {
19
+ return Object.assign(new Error('Resource session changed while loading. Please prepare again.'), {
20
+ code: 'AVAILABILITY_CONTEXT_NOT_FOUND'
21
+ });
22
+ }
18
23
  function datesInRange(range) {
19
24
  var count = dateOrdinalFromLocalDate(range.endDate) - dateOrdinalFromLocalDate(range.startDate) + 1;
20
25
  // A legal 90-business-day projection may include its preceding opening and overnight tail.
@@ -81,6 +86,8 @@ export var AvailabilitySessionResourceCache = /*#__PURE__*/function () {
81
86
  _defineProperty(this, "cells", new Map());
82
87
  _defineProperty(this, "pending", new Map());
83
88
  _defineProperty(this, "generation", 0);
89
+ _defineProperty(this, "queuedBatches", []);
90
+ _defineProperty(this, "batchFlushScheduled", false);
84
91
  }
85
92
  _createClass(AvailabilitySessionResourceCache, [{
86
93
  key: "clear",
@@ -88,22 +95,92 @@ export var AvailabilitySessionResourceCache = /*#__PURE__*/function () {
88
95
  this.generation += 1;
89
96
  this.cells.clear();
90
97
  this.pending.clear();
98
+ // A queued request has not reached the transport yet. Settle its waiters
99
+ // now, rather than leaving them pending or dispatching it in the new scope.
100
+ var queued = this.queuedBatches;
101
+ this.queuedBatches = [];
102
+ queued.forEach(function (batch) {
103
+ return batch.reject(sessionChangedError());
104
+ });
105
+ }
106
+ }, {
107
+ key: "enqueueFetch",
108
+ value: function enqueueFetch(params, query, generation) {
109
+ var _this = this;
110
+ var batch = this.queuedBatches.find(function (entry) {
111
+ return entry.generation === generation && entry.scopeKey === params.scopeKey && entry.timezoneName === params.timezoneName && entry.fetch === params.fetch && entry.dateRange.startDate === query.dateRange.startDate && entry.dateRange.endDate === query.dateRange.endDate;
112
+ });
113
+ if (!batch) {
114
+ var resolve;
115
+ var reject;
116
+ var promise = new Promise(function (resolvePromise, rejectPromise) {
117
+ resolve = resolvePromise;
118
+ reject = rejectPromise;
119
+ });
120
+ batch = {
121
+ generation: generation,
122
+ scopeKey: params.scopeKey,
123
+ timezoneName: params.timezoneName,
124
+ dateRange: _objectSpread({}, query.dateRange),
125
+ fetch: params.fetch,
126
+ resourceIds: new Map(),
127
+ promise: promise,
128
+ resolve: resolve,
129
+ reject: reject
130
+ };
131
+ this.queuedBatches.push(batch);
132
+ }
133
+ query.resourceIds.forEach(function (id) {
134
+ return batch.resourceIds.set(String(id), id);
135
+ });
136
+ if (!this.batchFlushScheduled) {
137
+ this.batchFlushScheduled = true;
138
+ // Fetching was already asynchronous. Collect requests from this turn only;
139
+ // do not add a timer or broaden their physical date coverage.
140
+ void Promise.resolve().then(function () {
141
+ return _this.flushFetchBatches();
142
+ });
143
+ }
144
+ return batch.promise;
145
+ }
146
+ }, {
147
+ key: "flushFetchBatches",
148
+ value: function flushFetchBatches() {
149
+ var _this2 = this;
150
+ this.batchFlushScheduled = false;
151
+ var queued = this.queuedBatches;
152
+ this.queuedBatches = [];
153
+ queued.forEach(function (batch) {
154
+ if (batch.generation !== _this2.generation) {
155
+ batch.reject(sessionChangedError());
156
+ return;
157
+ }
158
+ var query = {
159
+ resourceIds: Array.from(batch.resourceIds.values()).sort(function (left, right) {
160
+ return String(left).localeCompare(String(right));
161
+ }),
162
+ dateRange: _objectSpread({}, batch.dateRange)
163
+ };
164
+ try {
165
+ Promise.resolve(batch.fetch(cloneDeep(query))).then(batch.resolve, batch.reject);
166
+ } catch (error) {
167
+ batch.reject(error);
168
+ }
169
+ });
91
170
  }
92
171
  }, {
93
172
  key: "load",
94
173
  value: function () {
95
174
  var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
96
- var _this = this;
175
+ var _this3 = this;
97
176
  var generation, assertCurrent, resources, dates, key, waits, gaps, previousIds, result;
98
177
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
99
178
  while (1) switch (_context2.prev = _context2.next) {
100
179
  case 0:
101
180
  generation = this.generation;
102
181
  assertCurrent = function assertCurrent() {
103
- if (generation !== _this.generation) {
104
- throw Object.assign(new Error('Resource session changed while loading. Please prepare again.'), {
105
- code: 'AVAILABILITY_CONTEXT_NOT_FOUND'
106
- });
182
+ if (generation !== _this3.generation) {
183
+ throw sessionChangedError();
107
184
  }
108
185
  };
109
186
  resources = Array.from(new Map(params.resourceIds.filter(function (id) {
@@ -121,8 +198,8 @@ export var AvailabilitySessionResourceCache = /*#__PURE__*/function () {
121
198
  dates.forEach(function (date) {
122
199
  var missing = resources.filter(function (resourceId) {
123
200
  var cellKey = key(resourceId, date);
124
- if (_this.cells.has(cellKey)) return false;
125
- var pending = _this.pending.get(cellKey);
201
+ if (_this3.cells.has(cellKey)) return false;
202
+ var pending = _this3.pending.get(cellKey);
126
203
  if (pending) {
127
204
  waits.add(pending);
128
205
  return false;
@@ -163,7 +240,7 @@ export var AvailabilitySessionResourceCache = /*#__PURE__*/function () {
163
240
  case 0:
164
241
  assertCurrent();
165
242
  _context.next = 3;
166
- return params.fetch(cloneDeep(query));
243
+ return _this3.enqueueFetch(params, query, generation);
167
244
  case 3:
168
245
  response = _context.sent;
169
246
  assertCurrent();
@@ -204,7 +281,7 @@ export var AvailabilitySessionResourceCache = /*#__PURE__*/function () {
204
281
  });
205
282
  assertCurrent();
206
283
  updates.forEach(function (cell, cellKey) {
207
- if (!_this.cells.has(cellKey)) _this.cells.set(cellKey, cell);
284
+ if (!_this3.cells.has(cellKey)) _this3.cells.set(cellKey, cell);
208
285
  });
209
286
  case 13:
210
287
  case "end":
@@ -213,11 +290,11 @@ export var AvailabilitySessionResourceCache = /*#__PURE__*/function () {
213
290
  }, _callee);
214
291
  }))).finally(function () {
215
292
  cellKeys.forEach(function (cellKey) {
216
- if (_this.pending.get(cellKey) === promise) _this.pending.delete(cellKey);
293
+ if (_this3.pending.get(cellKey) === promise) _this3.pending.delete(cellKey);
217
294
  });
218
295
  });
219
296
  cellKeys.forEach(function (cellKey) {
220
- return _this.pending.set(cellKey, promise);
297
+ return _this3.pending.set(cellKey, promise);
221
298
  });
222
299
  waits.add(promise);
223
300
  });
@@ -230,7 +307,7 @@ export var AvailabilitySessionResourceCache = /*#__PURE__*/function () {
230
307
  var metadata = null;
231
308
  var events = new Map();
232
309
  dates.forEach(function (date) {
233
- var cell = _this.cells.get(key(id, date));
310
+ var cell = _this3.cells.get(key(id, date));
234
311
  if (!cell) throw new Error('Resource session coverage was lost. Please prepare again.');
235
312
  if (!metadata && cell.resource) metadata = cell.resource;
236
313
  var occurrences = new Map();
@@ -642,7 +642,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
642
642
  generateIdempotencyToken(): string;
643
643
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
644
644
  createOrder(params: CommitOrderParams['query']): {
645
- type: "virtual" | "appointment_booking";
645
+ type: "appointment_booking" | "virtual";
646
646
  platform: string;
647
647
  sales_channel: string;
648
648
  order_sales_channel: string;
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
345
+ weekNum: 0 | 1 | 2 | 3 | 5 | 6 | 4;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -91,6 +91,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
91
91
  private availabilityProjectionRefreshInFlight;
92
92
  private availabilityRemoteOccupancyCache;
93
93
  private availabilitySessionResourceCache;
94
+ private readonly fetchAvailabilitySessionResources;
94
95
  private availabilityRemoteResourceQueryInFlight;
95
96
  private availabilityRemoteResourceQuerySequence;
96
97
  private availabilityRemoteResourceEpoch;
@@ -1307,6 +1307,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1307
1307
  availabilityProjectionRefreshInFlight = new Map();
1308
1308
  availabilityRemoteOccupancyCache = new _remoteOccupancyCache.AvailabilityRemoteOccupancyCache(MAX_REMOTE_OCCUPANCY_RESOURCE_DATE_CELLS);
1309
1309
  availabilitySessionResourceCache = new _sessionResourceCache.AvailabilitySessionResourceCache();
1310
+ fetchAvailabilitySessionResources = query => this.fetchAvailabilityResourcesV2({
1311
+ ...query,
1312
+ strictResponse: true
1313
+ });
1310
1314
  availabilityRemoteResourceQueryInFlight = new Map();
1311
1315
  availabilityRemoteResourceQuerySequence = 0;
1312
1316
  availabilityRemoteResourceEpoch = 0;
@@ -2841,8 +2845,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2841
2845
  throw (0, _venueCatalogSession.venueCatalogError)('VENUE_CATALOG_DATETIME_INVALID', 'Choose a valid venue catalog date and time.');
2842
2846
  }
2843
2847
  const menus = (0, _venueCatalogSession.activeVenueMenus)(pool.menus, this.getAvailabilityScheduleCatalog(), datetime, Boolean(input.schedule_date && !input.schedule_datetime));
2844
- let products = pool.products.filter(product => menus.some(menu => (0, _venueCatalogSession.productMatchesVenueMenu)(product, menu))).map(product => this.getVenueCatalogHydratedProduct(product));
2848
+ let products = pool.products.filter(product => menus.some(menu => (0, _venueCatalogSession.productMatchesVenueMenu)(product, menu)));
2845
2849
  if (input.product_ids?.length) products = products.filter(product => input.product_ids.some(id => Number(id) === Number(product.id)));
2850
+ // Detail/quote reads must not deep-clone every other member of the pool.
2851
+ // Hydration owns a fresh copy of each selected product, including variants.
2852
+ products = products.map(product => this.getVenueCatalogHydratedProduct(product));
2846
2853
  const user = this.core.getPlugin?.('user');
2847
2854
  const queryPayload = {
2848
2855
  schedule_date: datetime.slice(0, 10),
@@ -2856,7 +2863,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2856
2863
  const result = (0, _clientDataVariants.tryResolveClientDataVariants)({
2857
2864
  core: this.core,
2858
2865
  otherParams: this.otherParams,
2859
- products: (0, _lodashEs.cloneDeep)(products),
2866
+ products,
2860
2867
  queryPayload,
2861
2868
  handledByOsServer: false,
2862
2869
  scheduleList: this.getAvailabilityScheduleCatalog(),
@@ -3834,10 +3841,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3834
3841
  scopeKey: `${scope}:${this.buildAvailabilityRemoteResourceScopeKey(timezone)}`,
3835
3842
  timezoneName: timezone,
3836
3843
  ...resourceQuery,
3837
- fetch: query => this.fetchAvailabilityResourcesV2({
3838
- ...query,
3839
- strictResponse: true
3840
- })
3844
+ fetch: this.fetchAvailabilitySessionResources
3841
3845
  }) : await this.fetchAvailabilityResourcesV2({
3842
3846
  ...resourceQuery,
3843
3847
  strictResponse: true
@@ -3958,10 +3962,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3958
3962
  timezoneName: params.timezone,
3959
3963
  resourceIds,
3960
3964
  dateRange: params.dateRange,
3961
- fetch: query => this.fetchAvailabilityResourcesV2({
3962
- ...query,
3963
- strictResponse: true
3964
- })
3965
+ fetch: this.fetchAvailabilitySessionResources
3965
3966
  });
3966
3967
  return buildAvailabilityResourcesFromV2({
3967
3968
  rawResources,
@@ -21,7 +21,11 @@ export declare class AvailabilitySessionResourceCache {
21
21
  private readonly cells;
22
22
  private readonly pending;
23
23
  private generation;
24
+ private queuedBatches;
25
+ private batchFlushScheduled;
24
26
  clear(): void;
27
+ private enqueueFetch;
28
+ private flushFetchBatches;
25
29
  load(params: AvailabilitySessionResourceLoadParams): Promise<RawResource[]>;
26
30
  }
27
31
  export {};
@@ -6,6 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.AvailabilitySessionResourceCache = void 0;
7
7
  var _lodashEs = require("lodash-es");
8
8
  var _localClock = require("../../modules/ResourcePlanner/localClock");
9
+ function sessionChangedError() {
10
+ return Object.assign(new Error('Resource session changed while loading. Please prepare again.'), {
11
+ code: 'AVAILABILITY_CONTEXT_NOT_FOUND'
12
+ });
13
+ }
9
14
  function datesInRange(range) {
10
15
  const count = (0, _localClock.dateOrdinalFromLocalDate)(range.endDate) - (0, _localClock.dateOrdinalFromLocalDate)(range.startDate) + 1;
11
16
  // A legal 90-business-day projection may include its preceding opening and overnight tail.
@@ -67,18 +72,78 @@ class AvailabilitySessionResourceCache {
67
72
  cells = new Map();
68
73
  pending = new Map();
69
74
  generation = 0;
75
+ queuedBatches = [];
76
+ batchFlushScheduled = false;
70
77
  clear() {
71
78
  this.generation += 1;
72
79
  this.cells.clear();
73
80
  this.pending.clear();
81
+ // A queued request has not reached the transport yet. Settle its waiters
82
+ // now, rather than leaving them pending or dispatching it in the new scope.
83
+ const queued = this.queuedBatches;
84
+ this.queuedBatches = [];
85
+ queued.forEach(batch => batch.reject(sessionChangedError()));
86
+ }
87
+ enqueueFetch(params, query, generation) {
88
+ let batch = this.queuedBatches.find(entry => entry.generation === generation && entry.scopeKey === params.scopeKey && entry.timezoneName === params.timezoneName && entry.fetch === params.fetch && entry.dateRange.startDate === query.dateRange.startDate && entry.dateRange.endDate === query.dateRange.endDate);
89
+ if (!batch) {
90
+ let resolve;
91
+ let reject;
92
+ const promise = new Promise((resolvePromise, rejectPromise) => {
93
+ resolve = resolvePromise;
94
+ reject = rejectPromise;
95
+ });
96
+ batch = {
97
+ generation,
98
+ scopeKey: params.scopeKey,
99
+ timezoneName: params.timezoneName,
100
+ dateRange: {
101
+ ...query.dateRange
102
+ },
103
+ fetch: params.fetch,
104
+ resourceIds: new Map(),
105
+ promise,
106
+ resolve,
107
+ reject
108
+ };
109
+ this.queuedBatches.push(batch);
110
+ }
111
+ query.resourceIds.forEach(id => batch.resourceIds.set(String(id), id));
112
+ if (!this.batchFlushScheduled) {
113
+ this.batchFlushScheduled = true;
114
+ // Fetching was already asynchronous. Collect requests from this turn only;
115
+ // do not add a timer or broaden their physical date coverage.
116
+ void Promise.resolve().then(() => this.flushFetchBatches());
117
+ }
118
+ return batch.promise;
119
+ }
120
+ flushFetchBatches() {
121
+ this.batchFlushScheduled = false;
122
+ const queued = this.queuedBatches;
123
+ this.queuedBatches = [];
124
+ queued.forEach(batch => {
125
+ if (batch.generation !== this.generation) {
126
+ batch.reject(sessionChangedError());
127
+ return;
128
+ }
129
+ const query = {
130
+ resourceIds: Array.from(batch.resourceIds.values()).sort((left, right) => String(left).localeCompare(String(right))),
131
+ dateRange: {
132
+ ...batch.dateRange
133
+ }
134
+ };
135
+ try {
136
+ Promise.resolve(batch.fetch((0, _lodashEs.cloneDeep)(query))).then(batch.resolve, batch.reject);
137
+ } catch (error) {
138
+ batch.reject(error);
139
+ }
140
+ });
74
141
  }
75
142
  async load(params) {
76
143
  const generation = this.generation;
77
144
  const assertCurrent = () => {
78
145
  if (generation !== this.generation) {
79
- throw Object.assign(new Error('Resource session changed while loading. Please prepare again.'), {
80
- code: 'AVAILABILITY_CONTEXT_NOT_FOUND'
81
- });
146
+ throw sessionChangedError();
82
147
  }
83
148
  };
84
149
  const resources = Array.from(new Map(params.resourceIds.filter(id => id !== undefined && id !== null && id !== '').map(id => [String(id), id])).values());
@@ -121,7 +186,7 @@ class AvailabilitySessionResourceCache {
121
186
  const cellKeys = query.resourceIds.flatMap(id => queryDates.map(date => key(id, date)));
122
187
  const promise = Promise.resolve().then(async () => {
123
188
  assertCurrent();
124
- const response = await params.fetch((0, _lodashEs.cloneDeep)(query));
189
+ const response = await this.enqueueFetch(params, query, generation);
125
190
  assertCurrent();
126
191
  if (!Array.isArray(response)) throw new Error('Booking resources returned an invalid response.');
127
192
  const byId = new Map();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.216",
4
+ "version": "2.3.218",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",