@pisell/pisellos 2.3.217 → 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.
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +1 -0
- package/dist/solution/UnifiedBookingSales/index.js +42 -46
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +4 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +91 -14
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +1 -0
- package/lib/solution/UnifiedBookingSales/index.js +6 -8
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +4 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +69 -4
- package/package.json +1 -1
|
@@ -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: "
|
|
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 |
|
|
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);
|
|
@@ -6175,11 +6180,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6175
6180
|
scopeKey: "".concat(scope, ":").concat(this.buildAvailabilityRemoteResourceScopeKey(timezone)),
|
|
6176
6181
|
timezoneName: timezone
|
|
6177
6182
|
}, resourceQuery), {}, {
|
|
6178
|
-
fetch:
|
|
6179
|
-
return _this20.fetchAvailabilityResourcesV2(_objectSpread(_objectSpread({}, query), {}, {
|
|
6180
|
-
strictResponse: true
|
|
6181
|
-
}));
|
|
6182
|
-
}
|
|
6183
|
+
fetch: this.fetchAvailabilitySessionResources
|
|
6183
6184
|
}));
|
|
6184
6185
|
case 24:
|
|
6185
6186
|
_context55.t1 = _context55.sent;
|
|
@@ -6398,7 +6399,6 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6398
6399
|
key: "loadAvailabilityResources",
|
|
6399
6400
|
value: function () {
|
|
6400
6401
|
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
6401
|
-
var _this22 = this;
|
|
6402
6402
|
var resourceIds, _rawResources, cachedRawResources, remoteQuery, rawResources;
|
|
6403
6403
|
return _regeneratorRuntime().wrap(function _callee57$(_context58) {
|
|
6404
6404
|
while (1) switch (_context58.prev = _context58.next) {
|
|
@@ -6423,11 +6423,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6423
6423
|
timezoneName: params.timezone,
|
|
6424
6424
|
resourceIds: resourceIds,
|
|
6425
6425
|
dateRange: params.dateRange,
|
|
6426
|
-
fetch:
|
|
6427
|
-
return _this22.fetchAvailabilityResourcesV2(_objectSpread(_objectSpread({}, query), {}, {
|
|
6428
|
-
strictResponse: true
|
|
6429
|
-
}));
|
|
6430
|
-
}
|
|
6426
|
+
fetch: this.fetchAvailabilitySessionResources
|
|
6431
6427
|
});
|
|
6432
6428
|
case 6:
|
|
6433
6429
|
_rawResources = _context58.sent;
|
|
@@ -6585,7 +6581,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6585
6581
|
}, {
|
|
6586
6582
|
key: "collectCartResourceOccupancies",
|
|
6587
6583
|
value: function collectCartResourceOccupancies(tempOrder, exclusions) {
|
|
6588
|
-
var
|
|
6584
|
+
var _this22 = this;
|
|
6589
6585
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
6590
6586
|
return bookings.flatMap(function (booking) {
|
|
6591
6587
|
var _ref59, _booking$product_uid2, _booking$metadata2;
|
|
@@ -6602,7 +6598,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6602
6598
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
6603
6599
|
startAt: startAt,
|
|
6604
6600
|
endAt: endAt,
|
|
6605
|
-
fixedOffsetMinutes:
|
|
6601
|
+
fixedOffsetMinutes: _this22.getAvailabilityRuntimeOffsetMinutes(),
|
|
6606
6602
|
rollOverEnd: false
|
|
6607
6603
|
});
|
|
6608
6604
|
if (!range) return [];
|
|
@@ -6620,7 +6616,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6620
6616
|
resource: resource
|
|
6621
6617
|
}
|
|
6622
6618
|
};
|
|
6623
|
-
return
|
|
6619
|
+
return _this22.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
|
|
6624
6620
|
});
|
|
6625
6621
|
});
|
|
6626
6622
|
}
|
|
@@ -6687,16 +6683,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6687
6683
|
}, {
|
|
6688
6684
|
key: "assertContextualQueryFreshness",
|
|
6689
6685
|
value: function assertContextualQueryFreshness(context, request) {
|
|
6690
|
-
var
|
|
6686
|
+
var _this23 = this;
|
|
6691
6687
|
if (request.target === 'time') {
|
|
6692
6688
|
request.candidates.forEach(function (candidate) {
|
|
6693
|
-
|
|
6689
|
+
_this23.assertAvailabilityCandidateFreshness(context, candidate);
|
|
6694
6690
|
});
|
|
6695
6691
|
return;
|
|
6696
6692
|
}
|
|
6697
6693
|
if (request.target === 'resource') {
|
|
6698
6694
|
request.selectedRanges.forEach(function (candidate) {
|
|
6699
|
-
|
|
6695
|
+
_this23.assertAvailabilityCandidateFreshness(context, candidate);
|
|
6700
6696
|
});
|
|
6701
6697
|
}
|
|
6702
6698
|
}
|
|
@@ -6745,7 +6741,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6745
6741
|
key: "buildAvailabilityProjectionSnapshot",
|
|
6746
6742
|
value: function () {
|
|
6747
6743
|
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
6748
|
-
var
|
|
6744
|
+
var _this24 = this;
|
|
6749
6745
|
var options,
|
|
6750
6746
|
normalizedPrepareParams,
|
|
6751
6747
|
timezoneLabel,
|
|
@@ -6827,7 +6823,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6827
6823
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
6828
6824
|
startAt: occupancy.startAt,
|
|
6829
6825
|
endAt: occupancy.endAt,
|
|
6830
|
-
fixedOffsetMinutes:
|
|
6826
|
+
fixedOffsetMinutes: _this24.getAvailabilityRuntimeOffsetMinutes(),
|
|
6831
6827
|
rollOverEnd: false
|
|
6832
6828
|
});
|
|
6833
6829
|
if (!range) return [];
|
|
@@ -6837,7 +6833,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6837
6833
|
})];
|
|
6838
6834
|
});
|
|
6839
6835
|
remoteOccupancies = [].concat(_toConsumableArray(loadedResources.resourceOccupancies), _toConsumableArray(loadedResources.includesInjectedRawOccupancies ? [] : injectedRawOccupancies)).filter(function (occupancy) {
|
|
6840
|
-
return !
|
|
6836
|
+
return !_this24.occupancyIsExcluded(occupancy, exclusions);
|
|
6841
6837
|
});
|
|
6842
6838
|
cartOccupancies = this.collectCartResourceOccupancies(tempOrder, exclusions);
|
|
6843
6839
|
preparedAt = this.getAvailabilityRuntimeDateTime();
|
|
@@ -6979,7 +6975,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6979
6975
|
key: "refreshAvailabilityContextProjection",
|
|
6980
6976
|
value: function () {
|
|
6981
6977
|
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
|
|
6982
|
-
var
|
|
6978
|
+
var _this25 = this;
|
|
6983
6979
|
var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
|
|
6984
6980
|
return _regeneratorRuntime().wrap(function _callee61$(_context62) {
|
|
6985
6981
|
while (1) switch (_context62.prev = _context62.next) {
|
|
@@ -7004,25 +7000,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7004
7000
|
while (1) switch (_context61.prev = _context61.next) {
|
|
7005
7001
|
case 0:
|
|
7006
7002
|
_context61.next = 2;
|
|
7007
|
-
return
|
|
7003
|
+
return _this25.buildAvailabilityProjectionSnapshot(_this25.cloneAvailabilityPrepareParams(context.prepareParams), {
|
|
7008
7004
|
durationCandidateAnchorAt: context.durationCandidateAnchorAt
|
|
7009
7005
|
});
|
|
7010
7006
|
case 2:
|
|
7011
7007
|
snapshot = _context61.sent;
|
|
7012
|
-
currentContext =
|
|
7008
|
+
currentContext = _this25.availabilityContextRegistry.get(params.contextId);
|
|
7013
7009
|
if (currentContext) {
|
|
7014
7010
|
_context61.next = 6;
|
|
7015
7011
|
break;
|
|
7016
7012
|
}
|
|
7017
7013
|
return _context61.abrupt("return", null);
|
|
7018
7014
|
case 6:
|
|
7019
|
-
if (!(expectedLifecycleGeneration !==
|
|
7015
|
+
if (!(expectedLifecycleGeneration !== _this25.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
|
|
7020
7016
|
_context61.next = 8;
|
|
7021
7017
|
break;
|
|
7022
7018
|
}
|
|
7023
7019
|
return _context61.abrupt("return", null);
|
|
7024
7020
|
case 8:
|
|
7025
|
-
projectionEntry =
|
|
7021
|
+
projectionEntry = _this25.storeAvailabilityProjectionEntry({
|
|
7026
7022
|
contextId: currentContext.contextId,
|
|
7027
7023
|
prepareParams: snapshot.prepareParams,
|
|
7028
7024
|
prepareKey: currentContext.prepareKey,
|
|
@@ -7031,7 +7027,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7031
7027
|
incrementVersion: true
|
|
7032
7028
|
});
|
|
7033
7029
|
_context61.next = 11;
|
|
7034
|
-
return
|
|
7030
|
+
return _this25.emitAvailabilityDiagnostic({
|
|
7035
7031
|
action: 'refresh',
|
|
7036
7032
|
contextId: currentContext.contextId,
|
|
7037
7033
|
contextVersion: projectionEntry.contextVersion,
|
|
@@ -7310,7 +7306,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7310
7306
|
_this$otherParams48,
|
|
7311
7307
|
_context$prepareParam2,
|
|
7312
7308
|
_extractFixedOffsetMi3,
|
|
7313
|
-
|
|
7309
|
+
_this26 = this;
|
|
7314
7310
|
var request,
|
|
7315
7311
|
_yield$this$ensureAva,
|
|
7316
7312
|
context,
|
|
@@ -7426,7 +7422,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7426
7422
|
}).map(function (group) {
|
|
7427
7423
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
7428
7424
|
ranges: group.ranges.map(function (candidate) {
|
|
7429
|
-
return
|
|
7425
|
+
return _this26.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
|
|
7430
7426
|
})
|
|
7431
7427
|
});
|
|
7432
7428
|
}));
|
|
@@ -7606,7 +7602,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7606
7602
|
var _removeBookingProductsOutsideStartDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(startDate) {
|
|
7607
7603
|
var _this$getTempOrder5,
|
|
7608
7604
|
_this$otherParams50,
|
|
7609
|
-
|
|
7605
|
+
_this27 = this;
|
|
7610
7606
|
var products, targetDate, identities;
|
|
7611
7607
|
return _regeneratorRuntime().wrap(function _callee68$(_context69) {
|
|
7612
7608
|
while (1) switch (_context69.prev = _context69.next) {
|
|
@@ -7630,7 +7626,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7630
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) {
|
|
7631
7627
|
return [];
|
|
7632
7628
|
}
|
|
7633
|
-
var booking =
|
|
7629
|
+
var booking = _this27.findLinkedBooking(product);
|
|
7634
7630
|
if (!booking || isFulfillmentTimingBooking(booking)) return [];
|
|
7635
7631
|
var bookingDate = getVisibleCalendarDate(booking.start_date);
|
|
7636
7632
|
return bookingDate && bookingDate !== targetDate ? [buildAvailabilityLineIdentity(product)] : [];
|
|
@@ -7652,7 +7648,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7652
7648
|
value: (function () {
|
|
7653
7649
|
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(contextId, params) {
|
|
7654
7650
|
var _this$availabilityCon,
|
|
7655
|
-
|
|
7651
|
+
_this28 = this,
|
|
7656
7652
|
_this$otherParams$pla5,
|
|
7657
7653
|
_this$otherParams51,
|
|
7658
7654
|
_this$availabilityCon2,
|
|
@@ -7679,7 +7675,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7679
7675
|
params = _objectSpread(_objectSpread({}, params), {}, {
|
|
7680
7676
|
availabilityCommitGuard: function availabilityCommitGuard() {
|
|
7681
7677
|
callerGuard === null || callerGuard === void 0 || callerGuard();
|
|
7682
|
-
if (!
|
|
7678
|
+
if (!_this28.isOrderSessionCurrent(calendarOrderSessionId)) {
|
|
7683
7679
|
throw new AvailabilityError('AVAILABILITY_SELECTION_STALE', 'Calendar booking order session changed.');
|
|
7684
7680
|
}
|
|
7685
7681
|
}
|
|
@@ -7710,21 +7706,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
7710
7706
|
if (isOrderRememberedSelection) this.assertRememberedOrderSession(params.orderSessionId);
|
|
7711
7707
|
rememberedOrder = hasCommitGuard ? this.getTempOrder() : null;
|
|
7712
7708
|
getRememberedCommitIdentity = function getRememberedCommitIdentity() {
|
|
7713
|
-
var
|
|
7709
|
+
var _this28$otherParams$s, _this28$otherParams, _this28$otherParams2, _this28$core, _this28$getTempOrder, _this28$getTempOrder2;
|
|
7714
7710
|
return JSON.stringify(stableValue(_objectSpread({
|
|
7715
|
-
scope:
|
|
7716
|
-
shopId: (
|
|
7717
|
-
contextShopId: (
|
|
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
|
|
7718
7714
|
}, isOrderRememberedSelection ? {
|
|
7719
|
-
orderSessionId:
|
|
7715
|
+
orderSessionId: _this28.getOrderSessionId()
|
|
7720
7716
|
} : {
|
|
7721
|
-
orderId: (
|
|
7722
|
-
externalSaleNumber: (
|
|
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
|
|
7723
7719
|
})));
|
|
7724
7720
|
};
|
|
7725
7721
|
rememberedCommitIdentity = hasCommitGuard ? getRememberedCommitIdentity() : '';
|
|
7726
7722
|
availabilityCommitTargetGuard = function availabilityCommitTargetGuard() {
|
|
7727
|
-
return (isOrderRememberedSelection ?
|
|
7723
|
+
return (isOrderRememberedSelection ? _this28.isOrderSessionCurrent(params.orderSessionId) : _this28.getTempOrder() === rememberedOrder) && getRememberedCommitIdentity() === rememberedCommitIdentity;
|
|
7728
7724
|
};
|
|
7729
7725
|
guardedCommitPublished = false;
|
|
7730
7726
|
_context70.next = 26;
|
|
@@ -8134,13 +8130,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
8134
8130
|
availabilityCommitGuard = hasCommitGuard ? function () {
|
|
8135
8131
|
var _params$availabilityC4, _params2;
|
|
8136
8132
|
(_params$availabilityC4 = (_params2 = params).availabilityCommitGuard) === null || _params$availabilityC4 === void 0 || _params$availabilityC4.call(_params2);
|
|
8137
|
-
|
|
8133
|
+
_this28.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
8138
8134
|
if (!availabilityCommitTargetGuard()) {
|
|
8139
|
-
throw
|
|
8135
|
+
throw _this28.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '记忆时间加购期间订单或业务已变化');
|
|
8140
8136
|
}
|
|
8141
8137
|
// Same-order immutable snapshots and generated sale IDs preserve the session.
|
|
8142
8138
|
// Capture the actual object Order is about to publish, not an earlier snapshot.
|
|
8143
|
-
if (isOrderRememberedSelection) rememberedOrder =
|
|
8139
|
+
if (isOrderRememberedSelection) rememberedOrder = _this28.getTempOrder();
|
|
8144
8140
|
if (customerSelectionSnapshot || !isRememberedSelection && !strictAvailability) return;
|
|
8145
8141
|
var currentValidation = validateAvailabilitySelection(refreshedProjection, {
|
|
8146
8142
|
candidate: refreshedCandidateBase,
|
|
@@ -8148,7 +8144,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
8148
8144
|
partySize: partySize,
|
|
8149
8145
|
bookingCount: bookingCount
|
|
8150
8146
|
}, {
|
|
8151
|
-
useDurationTimeGrid:
|
|
8147
|
+
useDurationTimeGrid: _this28.usesDurationTimeGrid(refreshedProjection),
|
|
8152
8148
|
enforceSaleCutoff: true,
|
|
8153
8149
|
rememberedTimeByProductId: rememberedTimeByProductId
|
|
8154
8150
|
});
|
|
@@ -8246,7 +8242,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
8246
8242
|
break;
|
|
8247
8243
|
}
|
|
8248
8244
|
relatedRetailProducts = params.relatedRetailProducts.map(function (source) {
|
|
8249
|
-
var line =
|
|
8245
|
+
var line = _this28.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
|
|
8250
8246
|
if (!line) throw new AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
|
|
8251
8247
|
// This is the only replacement-specific UID restore. Order checks ownership/collisions.
|
|
8252
8248
|
var sourceUid = getProductLineUid(source);
|
|
@@ -8395,7 +8391,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
8395
8391
|
}
|
|
8396
8392
|
// A notification failure after publication must not invite a duplicate add.
|
|
8397
8393
|
emit = function emit() {
|
|
8398
|
-
return
|
|
8394
|
+
return _this28.core.effects.emit("".concat(_this28.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
|
|
8399
8395
|
};
|
|
8400
8396
|
if (!guardedCommitPublished) {
|
|
8401
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
|
|
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 !==
|
|
104
|
-
throw
|
|
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 (
|
|
125
|
-
var pending =
|
|
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
|
|
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 (!
|
|
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 (
|
|
293
|
+
if (_this3.pending.get(cellKey) === promise) _this3.pending.delete(cellKey);
|
|
217
294
|
});
|
|
218
295
|
});
|
|
219
296
|
cellKeys.forEach(function (cellKey) {
|
|
220
|
-
return
|
|
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 =
|
|
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: "
|
|
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 |
|
|
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;
|
|
@@ -3837,10 +3841,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3837
3841
|
scopeKey: `${scope}:${this.buildAvailabilityRemoteResourceScopeKey(timezone)}`,
|
|
3838
3842
|
timezoneName: timezone,
|
|
3839
3843
|
...resourceQuery,
|
|
3840
|
-
fetch:
|
|
3841
|
-
...query,
|
|
3842
|
-
strictResponse: true
|
|
3843
|
-
})
|
|
3844
|
+
fetch: this.fetchAvailabilitySessionResources
|
|
3844
3845
|
}) : await this.fetchAvailabilityResourcesV2({
|
|
3845
3846
|
...resourceQuery,
|
|
3846
3847
|
strictResponse: true
|
|
@@ -3961,10 +3962,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3961
3962
|
timezoneName: params.timezone,
|
|
3962
3963
|
resourceIds,
|
|
3963
3964
|
dateRange: params.dateRange,
|
|
3964
|
-
fetch:
|
|
3965
|
-
...query,
|
|
3966
|
-
strictResponse: true
|
|
3967
|
-
})
|
|
3965
|
+
fetch: this.fetchAvailabilitySessionResources
|
|
3968
3966
|
});
|
|
3969
3967
|
return buildAvailabilityResourcesFromV2({
|
|
3970
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
|
|
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
|
|
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();
|