@pisell/pisellos 0.10.75 → 0.10.77
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.js +14 -9
- package/dist/shared/receipt/small-ticket.d.ts +3 -0
- package/dist/shared/receipt/small-ticket.js +23 -2
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +13 -1
- package/dist/solution/OrderInvoicePreview/index.js +13 -8
- package/dist/solution/UnifiedBookingSales/index.js +107 -58
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.js +5 -0
- package/lib/shared/receipt/small-ticket.d.ts +3 -0
- package/lib/shared/receipt/small-ticket.js +21 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +13 -1
- package/lib/solution/OrderInvoicePreview/index.js +6 -1
- package/lib/solution/UnifiedBookingSales/index.js +42 -11
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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";
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
package/dist/server/index.js
CHANGED
|
@@ -5502,9 +5502,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5502
5502
|
}, {
|
|
5503
5503
|
key: "getSmallTicketShopInfo",
|
|
5504
5504
|
value: function getSmallTicketShopInfo() {
|
|
5505
|
-
var _shopInfo$is_price_in;
|
|
5505
|
+
var _this$app15, _this$app15$getStore, _this$app15$getStore$, _this$app15$getStore$2, _this$app16, _this$app16$getStore, _this$app16$getStore$, _this$app16$getStore$2, _shopInfo$is_price_in;
|
|
5506
5506
|
var shopInfo = this.getAppData('shop_info') || {};
|
|
5507
|
+
// WebPOS getData does not expose core/default_domain; read the business
|
|
5508
|
+
// shop model directly when the expanded shop_info has not loaded it yet.
|
|
5509
|
+
var shopCore = ((_this$app15 = this.app) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.models) === null || _this$app15 === void 0 || (_this$app15$getStore = _this$app15.getStore) === null || _this$app15$getStore === void 0 || (_this$app15$getStore$ = (_this$app15$getStore$2 = _this$app15$getStore.call(_this$app15)).getDataByModel) === null || _this$app15$getStore$ === void 0 ? void 0 : _this$app15$getStore$.call(_this$app15$getStore$2, 'core', 'core')) || ((_this$app16 = this.app) === null || _this$app16 === void 0 || (_this$app16 = _this$app16.data) === null || _this$app16 === void 0 || (_this$app16 = _this$app16.store) === null || _this$app16 === void 0 || (_this$app16$getStore = _this$app16.getStore) === null || _this$app16$getStore === void 0 || (_this$app16$getStore$ = (_this$app16$getStore$2 = _this$app16$getStore.call(_this$app16)).getDataByModel) === null || _this$app16$getStore$ === void 0 ? void 0 : _this$app16$getStore$.call(_this$app16$getStore$2, 'core', 'core')) || {};
|
|
5507
5510
|
return _objectSpread(_objectSpread({}, shopInfo), {}, {
|
|
5511
|
+
default_domain: shopInfo.default_domain || shopCore.default_domain,
|
|
5512
|
+
private_domain_protocol: shopInfo.private_domain_protocol || shopCore.private_domain_protocol,
|
|
5508
5513
|
currency_symbol: shopInfo.currency_symbol || this.getAppData('shop_symbol') || this.getAppData('currency_symbol'),
|
|
5509
5514
|
currency_code: shopInfo.currency_code || this.getAppData('shop_currency_code') || this.getAppData('currency_code'),
|
|
5510
5515
|
tax_title: shopInfo.tax_title || this.getAppData('tax_title'),
|
|
@@ -6514,13 +6519,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6514
6519
|
key: "handleSyncCheckoutSubmit",
|
|
6515
6520
|
value: function () {
|
|
6516
6521
|
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
6517
|
-
var _this$
|
|
6522
|
+
var _this$app17;
|
|
6518
6523
|
var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
6519
6524
|
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6520
6525
|
while (1) switch (_context63.prev = _context63.next) {
|
|
6521
6526
|
case 0:
|
|
6522
6527
|
backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings;
|
|
6523
|
-
if ((_this$
|
|
6528
|
+
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.post) {
|
|
6524
6529
|
_context63.next = 4;
|
|
6525
6530
|
break;
|
|
6526
6531
|
}
|
|
@@ -6878,9 +6883,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6878
6883
|
}, {
|
|
6879
6884
|
key: "shouldAutoPrintCheckoutReceipt",
|
|
6880
6885
|
value: function shouldAutoPrintCheckoutReceipt() {
|
|
6881
|
-
var _this$core$context2, _this$core$context2$g, _this$
|
|
6886
|
+
var _this$core$context2, _this$core$context2$g, _this$app18, _this$app18$getStorag;
|
|
6882
6887
|
if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
|
|
6883
|
-
return ((_this$
|
|
6888
|
+
return ((_this$app18 = this.app) === null || _this$app18 === void 0 || (_this$app18 = _this$app18.storage) === null || _this$app18 === void 0 || (_this$app18$getStorag = _this$app18.getStorage) === null || _this$app18$getStorag === void 0 ? void 0 : _this$app18$getStorag.call(_this$app18, AUTO_PRINT_STORAGE_KEY)) !== 'false';
|
|
6884
6889
|
}
|
|
6885
6890
|
}, {
|
|
6886
6891
|
key: "shouldBuildSmallTicketData",
|
|
@@ -7504,7 +7509,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7504
7509
|
key: "fetchAndPersistSalesOrderByLookup",
|
|
7505
7510
|
value: function () {
|
|
7506
7511
|
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(lookup, data, title) {
|
|
7507
|
-
var _this$order5, _this$order6, _this$
|
|
7512
|
+
var _this$order5, _this$order6, _this$app19;
|
|
7508
7513
|
var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref78, _backendError$code2, backendStatusCode, _code, _message2, _message3;
|
|
7509
7514
|
return _regeneratorRuntime().wrap(function _callee73$(_context73) {
|
|
7510
7515
|
while (1) switch (_context73.prev = _context73.next) {
|
|
@@ -7520,7 +7525,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7520
7525
|
order: null
|
|
7521
7526
|
});
|
|
7522
7527
|
case 3:
|
|
7523
|
-
if ((_this$
|
|
7528
|
+
if ((_this$app19 = this.app) !== null && _this$app19 !== void 0 && (_this$app19 = _this$app19.request) !== null && _this$app19 !== void 0 && _this$app19.get) {
|
|
7524
7529
|
_context73.next = 6;
|
|
7525
7530
|
break;
|
|
7526
7531
|
}
|
|
@@ -7720,7 +7725,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7720
7725
|
key: "handleUpdateLocalOrdersBatch",
|
|
7721
7726
|
value: (function () {
|
|
7722
7727
|
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(orderIds) {
|
|
7723
|
-
var _this$
|
|
7728
|
+
var _this$app20;
|
|
7724
7729
|
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
|
|
7725
7730
|
return _regeneratorRuntime().wrap(function _callee74$(_context74) {
|
|
7726
7731
|
while (1) switch (_context74.prev = _context74.next) {
|
|
@@ -7741,7 +7746,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7741
7746
|
data: null
|
|
7742
7747
|
});
|
|
7743
7748
|
case 4:
|
|
7744
|
-
if ((_this$
|
|
7749
|
+
if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && _this$app20.request) {
|
|
7745
7750
|
_context74.next = 7;
|
|
7746
7751
|
break;
|
|
7747
7752
|
}
|
|
@@ -15,6 +15,9 @@ export interface SmallTicketShopInfo {
|
|
|
15
15
|
currency_code?: string;
|
|
16
16
|
primary_locale?: string;
|
|
17
17
|
timezone?: string;
|
|
18
|
+
/** Customer-facing shop domain, supplied by the host shop context. */
|
|
19
|
+
default_domain?: string;
|
|
20
|
+
private_domain_protocol?: string;
|
|
18
21
|
[key: string]: any;
|
|
19
22
|
}
|
|
20
23
|
export interface BuildSmallTicketDataParams {
|
|
@@ -403,10 +403,14 @@ function buildBaseData(params) {
|
|
|
403
403
|
currencySymbol = params.currencySymbol,
|
|
404
404
|
financials = params.financials;
|
|
405
405
|
var orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
406
|
-
|
|
406
|
+
var rewardClaim = buildRewardClaimUrl(shopInfo, order.shop_order_number);
|
|
407
|
+
return _objectSpread(_objectSpread({
|
|
407
408
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
408
409
|
note: stringify(order.note),
|
|
409
|
-
shop_order_number: stringify(order.shop_order_number)
|
|
410
|
+
shop_order_number: stringify(order.shop_order_number)
|
|
411
|
+
}, rewardClaim ? {
|
|
412
|
+
reward_claim: rewardClaim
|
|
413
|
+
} : {}), {}, {
|
|
410
414
|
order_number: orderNumber,
|
|
411
415
|
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
412
416
|
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
@@ -424,6 +428,23 @@ function buildBaseData(params) {
|
|
|
424
428
|
updated_at: formatDateTime(order.updated_at, locale)
|
|
425
429
|
} : {});
|
|
426
430
|
}
|
|
431
|
+
function buildRewardClaimUrl(shopInfo, shopOrderNumber) {
|
|
432
|
+
var domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
|
|
433
|
+
var orderNumber = typeof shopOrderNumber === 'string' ? shopOrderNumber.trim() : typeof shopOrderNumber === 'number' && Number.isFinite(shopOrderNumber) ? String(shopOrderNumber) : '';
|
|
434
|
+
if (!domain || !orderNumber) return undefined;
|
|
435
|
+
try {
|
|
436
|
+
var protocol = shopInfo.private_domain_protocol === 'http' ? 'http' : 'https';
|
|
437
|
+
var base = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(domain) ? domain : "".concat(protocol, "://").concat(domain));
|
|
438
|
+
if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password) {
|
|
439
|
+
return undefined;
|
|
440
|
+
}
|
|
441
|
+
var url = new URL('/claim-purchase-rewards', base);
|
|
442
|
+
url.searchParams.set('shop_order_number', orderNumber);
|
|
443
|
+
return url.toString();
|
|
444
|
+
} catch (_unused) {
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
427
448
|
function buildProducts(order, locale, productMap) {
|
|
428
449
|
var products = Array.isArray(order.products) ? order.products : [];
|
|
429
450
|
var allergyByProductUid = buildProductAllergyMap(order, locale);
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 2 | 1 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
373
373
|
};
|
|
374
374
|
setOtherData(key: string, value: any): void;
|
|
375
375
|
getOtherData(key: string): any;
|
|
376
|
-
getProductTypeById(id: number): Promise<"
|
|
376
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
377
377
|
/**
|
|
378
378
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
379
379
|
*
|
|
@@ -479,7 +479,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
479
479
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
480
480
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
481
481
|
*/
|
|
482
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
482
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
|
|
483
|
+
action: "reloadCatalog";
|
|
484
|
+
} | {
|
|
485
|
+
action: "add";
|
|
486
|
+
cacheItem: any;
|
|
487
|
+
} | {
|
|
488
|
+
action: "requiresDetail";
|
|
489
|
+
payload: AddProductRequiresDetailPayload;
|
|
490
|
+
} | {
|
|
491
|
+
action: "requiresBookingEdit";
|
|
492
|
+
cacheItem: any;
|
|
493
|
+
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
494
|
+
};
|
|
483
495
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
484
496
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
485
497
|
/**
|
|
@@ -187,8 +187,8 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
187
187
|
error: null
|
|
188
188
|
});
|
|
189
189
|
var task = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
190
|
-
var
|
|
191
|
-
var _yield$Promise$all, _yield$Promise$all2, snapshot, context, template, source, getData, coreData, shop, languageOptions, remembered, selected, locale, result;
|
|
190
|
+
var _appPlugin$getData, _appPlugin$getApp, _hostApp$models, _hostApp$models$getSt, _hostApp$models$getSt2, _hostApp$models$getSt3, _hostApp$data, _hostApp$data$getStor, _hostApp$data$getStor2, _hostApp$data$getStor3, _coreData$core, _this3$languageSelect;
|
|
191
|
+
var _yield$Promise$all, _yield$Promise$all2, snapshot, context, template, source, appPlugin, getData, coreData, hostApp, shopCore, shop, languageOptions, remembered, selected, locale, result;
|
|
192
192
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
193
193
|
while (1) switch (_context.prev = _context.next) {
|
|
194
194
|
case 0:
|
|
@@ -201,23 +201,28 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
201
201
|
context = _yield$Promise$all2[1];
|
|
202
202
|
template = _yield$Promise$all2[2];
|
|
203
203
|
source = withPaymentMethodNames(snapshot, context.methods);
|
|
204
|
-
|
|
204
|
+
appPlugin = _this3.core.getPlugin('app');
|
|
205
|
+
getData = appPlugin === null || appPlugin === void 0 || (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
|
|
205
206
|
if (!((getData === null || getData === void 0 ? void 0 : getData('shop_id')) != null && String(getData('shop_id')) !== String(input.shopId))) {
|
|
206
|
-
_context.next =
|
|
207
|
+
_context.next = 12;
|
|
207
208
|
break;
|
|
208
209
|
}
|
|
209
210
|
throw new Error('Invoice shop changed');
|
|
210
|
-
case
|
|
211
|
+
case 12:
|
|
211
212
|
coreData = getData === null || getData === void 0 ? void 0 : getData('core');
|
|
213
|
+
hostApp = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp) === null || _appPlugin$getApp === void 0 ? void 0 : _appPlugin$getApp.call(appPlugin);
|
|
214
|
+
shopCore = (hostApp === null || hostApp === void 0 || (_hostApp$models = hostApp.models) === null || _hostApp$models === void 0 || (_hostApp$models$getSt = _hostApp$models.getStore) === null || _hostApp$models$getSt === void 0 || (_hostApp$models$getSt2 = (_hostApp$models$getSt3 = _hostApp$models$getSt.call(_hostApp$models)).getDataByModel) === null || _hostApp$models$getSt2 === void 0 ? void 0 : _hostApp$models$getSt2.call(_hostApp$models$getSt3, 'core', 'core')) || (hostApp === null || hostApp === void 0 || (_hostApp$data = hostApp.data) === null || _hostApp$data === void 0 || (_hostApp$data = _hostApp$data.store) === null || _hostApp$data === void 0 || (_hostApp$data$getStor = _hostApp$data.getStore) === null || _hostApp$data$getStor === void 0 || (_hostApp$data$getStor2 = (_hostApp$data$getStor3 = _hostApp$data$getStor.call(_hostApp$data)).getDataByModel) === null || _hostApp$data$getStor2 === void 0 ? void 0 : _hostApp$data$getStor2.call(_hostApp$data$getStor3, 'core', 'core')) || (coreData === null || coreData === void 0 ? void 0 : coreData.core) || coreData || {};
|
|
212
215
|
shop = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (coreData === null || coreData === void 0 || (_coreData$core = coreData.core) === null || _coreData$core === void 0 ? void 0 : _coreData$core.shop) || (coreData === null || coreData === void 0 ? void 0 : coreData.shop) || {}), (getData === null || getData === void 0 ? void 0 : getData('shop_info')) || {}), input.shop), context.shop), getData !== null && getData !== void 0 && getData('tax_country_code') ? {
|
|
213
216
|
tax_country_code: getData('tax_country_code')
|
|
214
217
|
} : {});
|
|
218
|
+
shop.default_domain || (shop.default_domain = shopCore.default_domain);
|
|
219
|
+
shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
|
|
215
220
|
if (!(generation !== _this3.generation || _this3.disposed)) {
|
|
216
|
-
_context.next =
|
|
221
|
+
_context.next = 20;
|
|
217
222
|
break;
|
|
218
223
|
}
|
|
219
224
|
throw new Error('Invoice request superseded');
|
|
220
|
-
case
|
|
225
|
+
case 20:
|
|
221
226
|
languageOptions = resolveCustomerInvoiceLanguages(template.language, input.locale);
|
|
222
227
|
remembered = (_this3$languageSelect = _this3.languageSelection) === null || _this3$languageSelect === void 0 ? void 0 : _this3$languageSelect.code;
|
|
223
228
|
selected = languageOptions.find(function (option) {
|
|
@@ -254,7 +259,7 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
259
|
error: null
|
|
255
260
|
});
|
|
256
261
|
return _context.abrupt("return", result);
|
|
257
|
-
case
|
|
262
|
+
case 27:
|
|
258
263
|
case "end":
|
|
259
264
|
return _context.stop();
|
|
260
265
|
}
|
|
@@ -245,6 +245,7 @@ var MAX_AVAILABILITY_RANGE_DAYS = 90;
|
|
|
245
245
|
var MAX_AVAILABILITY_CONTEXT_REGISTRY = 128;
|
|
246
246
|
var MAX_AVAILABILITY_PROJECTION_POOL = 16;
|
|
247
247
|
var MAX_REMOTE_OCCUPANCY_RESOURCE_DATE_CELLS = 4096;
|
|
248
|
+
var PREVIEW_OCCUPANCY_CACHE_MAX_AGE_MS = 30 * 1000;
|
|
248
249
|
function isValidClockTime(value) {
|
|
249
250
|
var match = /^(\d{2}):(\d{2})$/.exec(value);
|
|
250
251
|
if (!match) return false;
|
|
@@ -4323,6 +4324,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4323
4324
|
key: "assertAvailabilityPrepareParams",
|
|
4324
4325
|
value: function assertAvailabilityPrepareParams(params) {
|
|
4325
4326
|
var _params$dateRange3, _params$dateRange4;
|
|
4327
|
+
if (params.occupancyCachePolicy !== undefined && params.occupancyCachePolicy !== 'cache_first') {
|
|
4328
|
+
throw new AvailabilityError('INVALID_TARGET_FILTER', 'Unknown occupancyCachePolicy');
|
|
4329
|
+
}
|
|
4326
4330
|
assertAvailabilityCatalogProductIds(params.productIds, 'prepare.productIds');
|
|
4327
4331
|
var hasProductAnchor = Array.isArray(params.productIds) && params.productIds.length > 0;
|
|
4328
4332
|
var hasResourceAnchor = Array.isArray(params.resourceIds) && params.resourceIds.length > 0;
|
|
@@ -4731,7 +4735,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4731
4735
|
key: "fetchAndPublishAvailabilityResourcesV2",
|
|
4732
4736
|
value: function () {
|
|
4733
4737
|
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
4734
|
-
var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
|
|
4738
|
+
var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources, epoch, covering, coveredResources;
|
|
4735
4739
|
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4736
4740
|
while (1) switch (_context43.prev = _context43.next) {
|
|
4737
4741
|
case 0:
|
|
@@ -4746,7 +4750,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4746
4750
|
cacheParams = {
|
|
4747
4751
|
scopeKey: scopeKey,
|
|
4748
4752
|
resourceIds: normalizedResourceIds,
|
|
4749
|
-
dateRange: params.dateRange
|
|
4753
|
+
dateRange: params.dateRange,
|
|
4754
|
+
maxAgeMs: params.maxAgeMs
|
|
4750
4755
|
};
|
|
4751
4756
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
4752
4757
|
if (!cachedRawResources) {
|
|
@@ -4764,15 +4769,51 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4764
4769
|
}
|
|
4765
4770
|
return _context43.abrupt("return", cachedRawResources);
|
|
4766
4771
|
case 9:
|
|
4767
|
-
|
|
4772
|
+
if (!(params.maxAgeMs !== undefined)) {
|
|
4773
|
+
_context43.next = 20;
|
|
4774
|
+
break;
|
|
4775
|
+
}
|
|
4776
|
+
// A visible-month request can cover a concurrent day/resource-subset preview.
|
|
4777
|
+
// Only share fully covering requests; partial overlaps keep the normal fetch path.
|
|
4778
|
+
epoch = this.availabilityRemoteResourceEpoch;
|
|
4779
|
+
covering = Array.from(this.availabilityRemoteResourceQueryInFlight.values()).find(function (entry) {
|
|
4780
|
+
return entry.epoch === epoch && entry.scopeKey === scopeKey && entry.dateRange.startDate <= params.dateRange.startDate && entry.dateRange.endDate >= params.dateRange.endDate && normalizedResourceIds.every(function (id) {
|
|
4781
|
+
return entry.resourceIds.some(function (other) {
|
|
4782
|
+
return String(other) === String(id);
|
|
4783
|
+
});
|
|
4784
|
+
});
|
|
4785
|
+
});
|
|
4786
|
+
if (!covering) {
|
|
4787
|
+
_context43.next = 20;
|
|
4788
|
+
break;
|
|
4789
|
+
}
|
|
4790
|
+
_context43.next = 15;
|
|
4791
|
+
return covering.promise;
|
|
4792
|
+
case 15:
|
|
4793
|
+
if (!(epoch !== this.availabilityRemoteResourceEpoch)) {
|
|
4794
|
+
_context43.next = 17;
|
|
4795
|
+
break;
|
|
4796
|
+
}
|
|
4797
|
+
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'Resource settings changed while loading. Please prepare again.');
|
|
4798
|
+
case 17:
|
|
4799
|
+
// Read a detached, correctly sliced graph after publication. A newer overlapping
|
|
4800
|
+
// response may have invalidated cells, in which case fetch this exact range below.
|
|
4801
|
+
coveredResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
4802
|
+
if (!coveredResources) {
|
|
4803
|
+
_context43.next = 20;
|
|
4804
|
+
break;
|
|
4805
|
+
}
|
|
4806
|
+
return _context43.abrupt("return", coveredResources);
|
|
4807
|
+
case 20:
|
|
4808
|
+
_context43.next = 22;
|
|
4768
4809
|
return this.refreshAvailabilityRemoteResourceQuery({
|
|
4769
4810
|
timezone: params.timezone,
|
|
4770
4811
|
dateRange: params.dateRange,
|
|
4771
4812
|
resourceIds: normalizedResourceIds
|
|
4772
4813
|
});
|
|
4773
|
-
case
|
|
4814
|
+
case 22:
|
|
4774
4815
|
return _context43.abrupt("return", _context43.sent);
|
|
4775
|
-
case
|
|
4816
|
+
case 23:
|
|
4776
4817
|
case "end":
|
|
4777
4818
|
return _context43.stop();
|
|
4778
4819
|
}
|
|
@@ -4787,7 +4828,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4787
4828
|
key: "refreshAvailabilityRemoteResourceQuery",
|
|
4788
4829
|
value: function () {
|
|
4789
4830
|
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
4790
|
-
var
|
|
4831
|
+
var _this16 = this;
|
|
4832
|
+
var normalizedResourceIds, queryKey, epoch, existing, writeVersion, scopeKey, promise, current;
|
|
4791
4833
|
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4792
4834
|
while (1) switch (_context44.prev = _context44.next) {
|
|
4793
4835
|
case 0:
|
|
@@ -4816,42 +4858,47 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4816
4858
|
case 10:
|
|
4817
4859
|
this.availabilityRemoteResourceQuerySequence += 1;
|
|
4818
4860
|
writeVersion = this.availabilityRemoteResourceQuerySequence;
|
|
4861
|
+
scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
|
|
4819
4862
|
promise = this.fetchAvailabilityResourcesV2({
|
|
4820
4863
|
dateRange: params.dateRange,
|
|
4821
4864
|
resourceIds: normalizedResourceIds
|
|
4865
|
+
}).then(function (rawResources) {
|
|
4866
|
+
if (epoch === _this16.availabilityRemoteResourceEpoch) {
|
|
4867
|
+
_this16.availabilityRemoteOccupancyCache.publish({
|
|
4868
|
+
scopeKey: scopeKey,
|
|
4869
|
+
timezoneName: params.timezone,
|
|
4870
|
+
resourceIds: normalizedResourceIds,
|
|
4871
|
+
dateRange: params.dateRange,
|
|
4872
|
+
rawResources: rawResources,
|
|
4873
|
+
version: writeVersion
|
|
4874
|
+
});
|
|
4875
|
+
}
|
|
4876
|
+
return rawResources;
|
|
4822
4877
|
});
|
|
4823
4878
|
this.availabilityRemoteResourceQueryInFlight.set(queryKey, {
|
|
4824
4879
|
epoch: epoch,
|
|
4880
|
+
scopeKey: scopeKey,
|
|
4881
|
+
dateRange: _objectSpread({}, params.dateRange),
|
|
4882
|
+
resourceIds: _toConsumableArray(normalizedResourceIds),
|
|
4825
4883
|
promise: promise
|
|
4826
4884
|
});
|
|
4827
|
-
_context44.prev =
|
|
4828
|
-
_context44.next =
|
|
4885
|
+
_context44.prev = 15;
|
|
4886
|
+
_context44.next = 18;
|
|
4829
4887
|
return promise;
|
|
4830
|
-
case
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
|
|
4835
|
-
timezoneName: params.timezone,
|
|
4836
|
-
resourceIds: normalizedResourceIds,
|
|
4837
|
-
dateRange: params.dateRange,
|
|
4838
|
-
rawResources: rawResources,
|
|
4839
|
-
version: writeVersion
|
|
4840
|
-
});
|
|
4841
|
-
}
|
|
4842
|
-
return _context44.abrupt("return", rawResources);
|
|
4843
|
-
case 20:
|
|
4844
|
-
_context44.prev = 20;
|
|
4888
|
+
case 18:
|
|
4889
|
+
return _context44.abrupt("return", _context44.sent);
|
|
4890
|
+
case 19:
|
|
4891
|
+
_context44.prev = 19;
|
|
4845
4892
|
current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
4846
4893
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
4847
4894
|
this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
|
|
4848
4895
|
}
|
|
4849
|
-
return _context44.finish(
|
|
4850
|
-
case
|
|
4896
|
+
return _context44.finish(19);
|
|
4897
|
+
case 23:
|
|
4851
4898
|
case "end":
|
|
4852
4899
|
return _context44.stop();
|
|
4853
4900
|
}
|
|
4854
|
-
}, _callee44, this, [[
|
|
4901
|
+
}, _callee44, this, [[15,, 19, 23]]);
|
|
4855
4902
|
}));
|
|
4856
4903
|
function refreshAvailabilityRemoteResourceQuery(_x30) {
|
|
4857
4904
|
return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
|
|
@@ -4930,8 +4977,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4930
4977
|
case 17:
|
|
4931
4978
|
_context45.next = 19;
|
|
4932
4979
|
return this.fetchAndPublishAvailabilityResourcesV2(_objectSpread(_objectSpread({}, remoteQuery), {}, {
|
|
4933
|
-
useCacheOnHit:
|
|
4934
|
-
}
|
|
4980
|
+
useCacheOnHit: params.fetchPolicy !== 'cache_first'
|
|
4981
|
+
}, params.fetchPolicy === 'cache_first' ? {
|
|
4982
|
+
maxAgeMs: PREVIEW_OCCUPANCY_CACHE_MAX_AGE_MS
|
|
4983
|
+
} : {}));
|
|
4935
4984
|
case 19:
|
|
4936
4985
|
_context45.t0 = _context45.sent;
|
|
4937
4986
|
case 20:
|
|
@@ -5021,7 +5070,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5021
5070
|
}, {
|
|
5022
5071
|
key: "collectCartResourceOccupancies",
|
|
5023
5072
|
value: function collectCartResourceOccupancies(tempOrder, exclusions) {
|
|
5024
|
-
var
|
|
5073
|
+
var _this17 = this;
|
|
5025
5074
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
5026
5075
|
return bookings.flatMap(function (booking) {
|
|
5027
5076
|
var _ref51, _booking$product_uid2, _booking$metadata2;
|
|
@@ -5038,7 +5087,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5038
5087
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
5039
5088
|
startAt: startAt,
|
|
5040
5089
|
endAt: endAt,
|
|
5041
|
-
fixedOffsetMinutes:
|
|
5090
|
+
fixedOffsetMinutes: _this17.getAvailabilityRuntimeOffsetMinutes(),
|
|
5042
5091
|
rollOverEnd: false
|
|
5043
5092
|
});
|
|
5044
5093
|
if (!range) return [];
|
|
@@ -5056,7 +5105,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5056
5105
|
resource: resource
|
|
5057
5106
|
}
|
|
5058
5107
|
};
|
|
5059
|
-
return
|
|
5108
|
+
return _this17.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
|
|
5060
5109
|
});
|
|
5061
5110
|
});
|
|
5062
5111
|
}
|
|
@@ -5123,16 +5172,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5123
5172
|
}, {
|
|
5124
5173
|
key: "assertContextualQueryFreshness",
|
|
5125
5174
|
value: function assertContextualQueryFreshness(context, request) {
|
|
5126
|
-
var
|
|
5175
|
+
var _this18 = this;
|
|
5127
5176
|
if (request.target === 'time') {
|
|
5128
5177
|
request.candidates.forEach(function (candidate) {
|
|
5129
|
-
|
|
5178
|
+
_this18.assertAvailabilityCandidateFreshness(context, candidate);
|
|
5130
5179
|
});
|
|
5131
5180
|
return;
|
|
5132
5181
|
}
|
|
5133
5182
|
if (request.target === 'resource') {
|
|
5134
5183
|
request.selectedRanges.forEach(function (candidate) {
|
|
5135
|
-
|
|
5184
|
+
_this18.assertAvailabilityCandidateFreshness(context, candidate);
|
|
5136
5185
|
});
|
|
5137
5186
|
}
|
|
5138
5187
|
}
|
|
@@ -5180,7 +5229,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5180
5229
|
key: "buildAvailabilityProjectionSnapshot",
|
|
5181
5230
|
value: function () {
|
|
5182
5231
|
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
5183
|
-
var
|
|
5232
|
+
var _this19 = this;
|
|
5184
5233
|
var options,
|
|
5185
5234
|
normalizedPrepareParams,
|
|
5186
5235
|
timezoneLabel,
|
|
@@ -5236,7 +5285,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5236
5285
|
rawResources: normalizedPrepareParams.rawResources,
|
|
5237
5286
|
scheduleList: scheduleList,
|
|
5238
5287
|
// An explicit internal policy (notably commit's cache_only) remains authoritative.
|
|
5239
|
-
fetchPolicy: options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : 'default'),
|
|
5288
|
+
fetchPolicy: options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : normalizedPrepareParams.occupancyCachePolicy === 'cache_first' ? 'cache_first' : 'default'),
|
|
5240
5289
|
fallbackResources: options.fallbackResources
|
|
5241
5290
|
});
|
|
5242
5291
|
case 14:
|
|
@@ -5247,7 +5296,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5247
5296
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
5248
5297
|
startAt: occupancy.startAt,
|
|
5249
5298
|
endAt: occupancy.endAt,
|
|
5250
|
-
fixedOffsetMinutes:
|
|
5299
|
+
fixedOffsetMinutes: _this19.getAvailabilityRuntimeOffsetMinutes(),
|
|
5251
5300
|
rollOverEnd: false
|
|
5252
5301
|
});
|
|
5253
5302
|
if (!range) return [];
|
|
@@ -5257,7 +5306,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5257
5306
|
})];
|
|
5258
5307
|
});
|
|
5259
5308
|
remoteOccupancies = [].concat(_toConsumableArray(loadedResources.resourceOccupancies), _toConsumableArray(loadedResources.includesInjectedRawOccupancies ? [] : injectedRawOccupancies)).filter(function (occupancy) {
|
|
5260
|
-
return !
|
|
5309
|
+
return !_this19.occupancyIsExcluded(occupancy, exclusions);
|
|
5261
5310
|
});
|
|
5262
5311
|
cartOccupancies = this.collectCartResourceOccupancies(tempOrder, exclusions);
|
|
5263
5312
|
preparedAt = this.getAvailabilityRuntimeDateTime();
|
|
@@ -5399,7 +5448,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5399
5448
|
key: "refreshAvailabilityContextProjection",
|
|
5400
5449
|
value: function () {
|
|
5401
5450
|
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
5402
|
-
var
|
|
5451
|
+
var _this20 = this;
|
|
5403
5452
|
var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
|
|
5404
5453
|
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
5405
5454
|
while (1) switch (_context49.prev = _context49.next) {
|
|
@@ -5424,25 +5473,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5424
5473
|
while (1) switch (_context48.prev = _context48.next) {
|
|
5425
5474
|
case 0:
|
|
5426
5475
|
_context48.next = 2;
|
|
5427
|
-
return
|
|
5476
|
+
return _this20.buildAvailabilityProjectionSnapshot(_this20.cloneAvailabilityPrepareParams(context.prepareParams), {
|
|
5428
5477
|
durationCandidateAnchorAt: context.durationCandidateAnchorAt
|
|
5429
5478
|
});
|
|
5430
5479
|
case 2:
|
|
5431
5480
|
snapshot = _context48.sent;
|
|
5432
|
-
currentContext =
|
|
5481
|
+
currentContext = _this20.availabilityContextRegistry.get(params.contextId);
|
|
5433
5482
|
if (currentContext) {
|
|
5434
5483
|
_context48.next = 6;
|
|
5435
5484
|
break;
|
|
5436
5485
|
}
|
|
5437
5486
|
return _context48.abrupt("return", null);
|
|
5438
5487
|
case 6:
|
|
5439
|
-
if (!(expectedLifecycleGeneration !==
|
|
5488
|
+
if (!(expectedLifecycleGeneration !== _this20.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
|
|
5440
5489
|
_context48.next = 8;
|
|
5441
5490
|
break;
|
|
5442
5491
|
}
|
|
5443
5492
|
return _context48.abrupt("return", null);
|
|
5444
5493
|
case 8:
|
|
5445
|
-
projectionEntry =
|
|
5494
|
+
projectionEntry = _this20.storeAvailabilityProjectionEntry({
|
|
5446
5495
|
contextId: currentContext.contextId,
|
|
5447
5496
|
prepareParams: snapshot.prepareParams,
|
|
5448
5497
|
prepareKey: currentContext.prepareKey,
|
|
@@ -5451,7 +5500,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5451
5500
|
incrementVersion: true
|
|
5452
5501
|
});
|
|
5453
5502
|
_context48.next = 11;
|
|
5454
|
-
return
|
|
5503
|
+
return _this20.emitAvailabilityDiagnostic({
|
|
5455
5504
|
action: 'refresh',
|
|
5456
5505
|
contextId: currentContext.contextId,
|
|
5457
5506
|
contextVersion: projectionEntry.contextVersion,
|
|
@@ -5716,7 +5765,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5716
5765
|
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(contextId) {
|
|
5717
5766
|
var _this$otherParams$pla,
|
|
5718
5767
|
_this$otherParams36,
|
|
5719
|
-
|
|
5768
|
+
_this21 = this;
|
|
5720
5769
|
var request,
|
|
5721
5770
|
_yield$this$ensureAva,
|
|
5722
5771
|
context,
|
|
@@ -5754,7 +5803,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5754
5803
|
}).map(function (group) {
|
|
5755
5804
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
5756
5805
|
ranges: group.ranges.map(function (candidate) {
|
|
5757
|
-
return
|
|
5806
|
+
return _this21.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
|
|
5758
5807
|
})
|
|
5759
5808
|
});
|
|
5760
5809
|
}));
|
|
@@ -5918,7 +5967,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5918
5967
|
_params$availabilityC3,
|
|
5919
5968
|
_this$store$order11,
|
|
5920
5969
|
_this$store$order11$e,
|
|
5921
|
-
|
|
5970
|
+
_this22 = this;
|
|
5922
5971
|
var normalizedContextId, isEditingSelection, isPartyReplacement, strictAvailability, hasCommitGuard, guardedOrder, getGuardedCommitIdentity, guardedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref56, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla3, _this$otherParams38, _params$orderProduct$3, _params$orderProduct6, _existingBooking$hold, _existingBooking$meta, _ref57, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$meta3, _existingBooking$hold2, _transformed$metadata, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, relatedRetailProducts, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref58, _transformed$product_4, update, _this$getTempOrder5, _this$getTempOrder6, _params$salesNotes, _params$salesNotes2, _ref59, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
|
|
5923
5972
|
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5924
5973
|
while (1) switch (_context56.prev = _context56.next) {
|
|
@@ -5947,18 +5996,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5947
5996
|
if (hasCommitGuard) (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$e = _this$store$order11.ensureTempOrder) === null || _this$store$order11$e === void 0 || _this$store$order11$e.call(_this$store$order11);
|
|
5948
5997
|
guardedOrder = hasCommitGuard ? this.getTempOrder() : null;
|
|
5949
5998
|
getGuardedCommitIdentity = function getGuardedCommitIdentity() {
|
|
5950
|
-
var
|
|
5999
|
+
var _this22$otherParams$s, _this22$otherParams, _this22$otherParams2, _this22$core, _this22$getTempOrder, _this22$getTempOrder2;
|
|
5951
6000
|
return JSON.stringify(stableValue({
|
|
5952
|
-
scope:
|
|
5953
|
-
shopId: (
|
|
5954
|
-
contextShopId: (
|
|
5955
|
-
orderId: (
|
|
5956
|
-
externalSaleNumber: (
|
|
6001
|
+
scope: _this22.getAvailabilityScopeDescriptor(),
|
|
6002
|
+
shopId: (_this22$otherParams$s = (_this22$otherParams = _this22.otherParams) === null || _this22$otherParams === void 0 ? void 0 : _this22$otherParams.shop_id) !== null && _this22$otherParams$s !== void 0 ? _this22$otherParams$s : (_this22$otherParams2 = _this22.otherParams) === null || _this22$otherParams2 === void 0 ? void 0 : _this22$otherParams2.shopId,
|
|
6003
|
+
contextShopId: (_this22$core = _this22.core) === null || _this22$core === void 0 || (_this22$core = _this22$core.context) === null || _this22$core === void 0 ? void 0 : _this22$core.shop_id,
|
|
6004
|
+
orderId: (_this22$getTempOrder = _this22.getTempOrder()) === null || _this22$getTempOrder === void 0 ? void 0 : _this22$getTempOrder.order_id,
|
|
6005
|
+
externalSaleNumber: (_this22$getTempOrder2 = _this22.getTempOrder()) === null || _this22$getTempOrder2 === void 0 ? void 0 : _this22$getTempOrder2.external_sale_number
|
|
5957
6006
|
}));
|
|
5958
6007
|
};
|
|
5959
6008
|
guardedCommitIdentity = hasCommitGuard ? getGuardedCommitIdentity() : '';
|
|
5960
6009
|
availabilityCommitTargetGuard = function availabilityCommitTargetGuard() {
|
|
5961
|
-
return
|
|
6010
|
+
return _this22.getTempOrder() === guardedOrder && getGuardedCommitIdentity() === guardedCommitIdentity;
|
|
5962
6011
|
};
|
|
5963
6012
|
guardedCommitPublished = false;
|
|
5964
6013
|
_context56.next = 18;
|
|
@@ -6301,9 +6350,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6301
6350
|
availabilityCommitGuard = hasCommitGuard ? function () {
|
|
6302
6351
|
var _params$availabilityC4;
|
|
6303
6352
|
(_params$availabilityC4 = params.availabilityCommitGuard) === null || _params$availabilityC4 === void 0 || _params$availabilityC4.call(params);
|
|
6304
|
-
|
|
6353
|
+
_this22.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
6305
6354
|
if (!availabilityCommitTargetGuard()) {
|
|
6306
|
-
throw
|
|
6355
|
+
throw _this22.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '预约加购期间订单或业务已变化');
|
|
6307
6356
|
}
|
|
6308
6357
|
if (!strictAvailability) return;
|
|
6309
6358
|
var currentValidation = validateAvailabilitySelection(refreshedProjection, {
|
|
@@ -6374,7 +6423,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6374
6423
|
}
|
|
6375
6424
|
relatedRetailProducts = params.relatedRetailProducts.map(function (source) {
|
|
6376
6425
|
var _line$metadata3;
|
|
6377
|
-
var line =
|
|
6426
|
+
var line = _this22.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
|
|
6378
6427
|
if (!line) throw new AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
|
|
6379
6428
|
if (((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.venue_booking_role) === 'party_extra') {
|
|
6380
6429
|
line.holder_config = {
|
|
@@ -6519,7 +6568,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
6519
6568
|
}
|
|
6520
6569
|
// A notification failure after publication must not invite a duplicate add.
|
|
6521
6570
|
emit = function emit() {
|
|
6522
|
-
return
|
|
6571
|
+
return _this22.core.effects.emit("".concat(_this22.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
|
|
6523
6572
|
};
|
|
6524
6573
|
if (!guardedCommitPublished) {
|
|
6525
6574
|
_context56.next = 180;
|
|
@@ -11,6 +11,8 @@ export declare class AvailabilityRemoteOccupancyCache {
|
|
|
11
11
|
scopeKey: string;
|
|
12
12
|
resourceIds: AvailabilityId[];
|
|
13
13
|
dateRange: AvailabilityDateRange;
|
|
14
|
+
/** Only opt-in preview reads expire cells; legacy reads retain their SWR semantics. */
|
|
15
|
+
maxAgeMs?: number;
|
|
14
16
|
}): Record<string, any>[] | null;
|
|
15
17
|
hasCompleteCoverage(params: {
|
|
16
18
|
scopeKey: string;
|
|
@@ -146,6 +146,7 @@ export var AvailabilityRemoteOccupancyCache = /*#__PURE__*/function () {
|
|
|
146
146
|
var requestedResourceIds = uniqueIds(params.resourceIds);
|
|
147
147
|
var requestedDates = buildDateList(params.dateRange);
|
|
148
148
|
if (requestedResourceIds.length === 0 || requestedDates.length === 0) return [];
|
|
149
|
+
var now = Date.now();
|
|
149
150
|
var resources = [];
|
|
150
151
|
var _iterator = _createForOfIteratorHelper(requestedResourceIds),
|
|
151
152
|
_step;
|
|
@@ -164,6 +165,9 @@ export var AvailabilityRemoteOccupancyCache = /*#__PURE__*/function () {
|
|
|
164
165
|
if (!cell) return {
|
|
165
166
|
v: null
|
|
166
167
|
};
|
|
168
|
+
if (params.maxAgeMs !== undefined && (now < cell.fetchedAt || now - cell.fetchedAt >= params.maxAgeMs)) return {
|
|
169
|
+
v: null
|
|
170
|
+
};
|
|
167
171
|
cell.eventList.forEach(function (rawEvent) {
|
|
168
172
|
eventList.set(buildEventIdentity(resourceId, rawEvent), cloneDeep(rawEvent));
|
|
169
173
|
});
|
|
@@ -85,6 +85,8 @@ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
|
|
|
85
85
|
publishCatalog?: boolean;
|
|
86
86
|
/** Await remote occupancy refresh instead of stale-while-revalidate. Ignores rawResources; does not lock resources. */
|
|
87
87
|
refreshOccupancies?: boolean;
|
|
88
|
+
/** Preview only: reuse complete resource/date coverage for 30 seconds without a background request. refreshOccupancies takes precedence. Omit to retain stale-while-revalidate. */
|
|
89
|
+
occupancyCachePolicy?: 'cache_first';
|
|
88
90
|
/** Enforce configured sale cutoffs and disable manual POS availability overrides for this context. Defaults to false. */
|
|
89
91
|
strictAvailability?: boolean;
|
|
90
92
|
rawResources?: Record<string, any>[];
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
package/lib/server/index.js
CHANGED
|
@@ -3405,8 +3405,13 @@ class Server {
|
|
|
3405
3405
|
}
|
|
3406
3406
|
getSmallTicketShopInfo() {
|
|
3407
3407
|
const shopInfo = this.getAppData('shop_info') || {};
|
|
3408
|
+
// WebPOS getData does not expose core/default_domain; read the business
|
|
3409
|
+
// shop model directly when the expanded shop_info has not loaded it yet.
|
|
3410
|
+
const shopCore = this.app?.models?.getStore?.().getDataByModel?.('core', 'core') || this.app?.data?.store?.getStore?.().getDataByModel?.('core', 'core') || {};
|
|
3408
3411
|
return {
|
|
3409
3412
|
...shopInfo,
|
|
3413
|
+
default_domain: shopInfo.default_domain || shopCore.default_domain,
|
|
3414
|
+
private_domain_protocol: shopInfo.private_domain_protocol || shopCore.private_domain_protocol,
|
|
3410
3415
|
currency_symbol: shopInfo.currency_symbol || this.getAppData('shop_symbol') || this.getAppData('currency_symbol'),
|
|
3411
3416
|
currency_code: shopInfo.currency_code || this.getAppData('shop_currency_code') || this.getAppData('currency_code'),
|
|
3412
3417
|
tax_title: shopInfo.tax_title || this.getAppData('tax_title'),
|
|
@@ -15,6 +15,9 @@ export interface SmallTicketShopInfo {
|
|
|
15
15
|
currency_code?: string;
|
|
16
16
|
primary_locale?: string;
|
|
17
17
|
timezone?: string;
|
|
18
|
+
/** Customer-facing shop domain, supplied by the host shop context. */
|
|
19
|
+
default_domain?: string;
|
|
20
|
+
private_domain_protocol?: string;
|
|
18
21
|
[key: string]: any;
|
|
19
22
|
}
|
|
20
23
|
export interface BuildSmallTicketDataParams {
|
|
@@ -387,10 +387,14 @@ function buildBaseData(params) {
|
|
|
387
387
|
financials
|
|
388
388
|
} = params;
|
|
389
389
|
const orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
390
|
+
const rewardClaim = buildRewardClaimUrl(shopInfo, order.shop_order_number);
|
|
390
391
|
return {
|
|
391
392
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
392
393
|
note: stringify(order.note),
|
|
393
394
|
shop_order_number: stringify(order.shop_order_number),
|
|
395
|
+
...(rewardClaim ? {
|
|
396
|
+
reward_claim: rewardClaim
|
|
397
|
+
} : {}),
|
|
394
398
|
order_number: orderNumber,
|
|
395
399
|
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
396
400
|
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
@@ -409,6 +413,23 @@ function buildBaseData(params) {
|
|
|
409
413
|
} : {})
|
|
410
414
|
};
|
|
411
415
|
}
|
|
416
|
+
function buildRewardClaimUrl(shopInfo, shopOrderNumber) {
|
|
417
|
+
const domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
|
|
418
|
+
const orderNumber = typeof shopOrderNumber === 'string' ? shopOrderNumber.trim() : typeof shopOrderNumber === 'number' && Number.isFinite(shopOrderNumber) ? String(shopOrderNumber) : '';
|
|
419
|
+
if (!domain || !orderNumber) return undefined;
|
|
420
|
+
try {
|
|
421
|
+
const protocol = shopInfo.private_domain_protocol === 'http' ? 'http' : 'https';
|
|
422
|
+
const base = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(domain) ? domain : `${protocol}://${domain}`);
|
|
423
|
+
if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password) {
|
|
424
|
+
return undefined;
|
|
425
|
+
}
|
|
426
|
+
const url = new URL('/claim-purchase-rewards', base);
|
|
427
|
+
url.searchParams.set('shop_order_number', orderNumber);
|
|
428
|
+
return url.toString();
|
|
429
|
+
} catch {
|
|
430
|
+
return undefined;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
412
433
|
function buildProducts(order, locale, productMap) {
|
|
413
434
|
const products = Array.isArray(order.products) ? order.products : [];
|
|
414
435
|
const allergyByProductUid = buildProductAllergyMap(order, locale);
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 2 | 1 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
373
373
|
};
|
|
374
374
|
setOtherData(key: string, value: any): void;
|
|
375
375
|
getOtherData(key: string): any;
|
|
376
|
-
getProductTypeById(id: number): Promise<"
|
|
376
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
377
377
|
/**
|
|
378
378
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
379
379
|
*
|
|
@@ -479,7 +479,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
479
479
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
480
480
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
481
481
|
*/
|
|
482
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
482
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
|
|
483
|
+
action: "reloadCatalog";
|
|
484
|
+
} | {
|
|
485
|
+
action: "add";
|
|
486
|
+
cacheItem: any;
|
|
487
|
+
} | {
|
|
488
|
+
action: "requiresDetail";
|
|
489
|
+
payload: AddProductRequiresDetailPayload;
|
|
490
|
+
} | {
|
|
491
|
+
action: "requiresBookingEdit";
|
|
492
|
+
cacheItem: any;
|
|
493
|
+
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
494
|
+
};
|
|
483
495
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
484
496
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
485
497
|
/**
|
|
@@ -130,9 +130,12 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
130
130
|
const task = (async () => {
|
|
131
131
|
const [snapshot, context, template] = await Promise.all([this.loadSource(input), this.loadContext(input), (0, _loadCustomerInvoiceLayout.loadCustomerInvoiceTemplate)(this.request, input)]);
|
|
132
132
|
const source = (0, _loadPaymentMethods.withPaymentMethodNames)(snapshot, context.methods);
|
|
133
|
-
const
|
|
133
|
+
const appPlugin = this.core.getPlugin('app');
|
|
134
|
+
const getData = appPlugin?.getData?.();
|
|
134
135
|
if (getData?.('shop_id') != null && String(getData('shop_id')) !== String(input.shopId)) throw new Error('Invoice shop changed');
|
|
135
136
|
const coreData = getData?.('core');
|
|
137
|
+
const hostApp = appPlugin?.getApp?.();
|
|
138
|
+
const shopCore = hostApp?.models?.getStore?.().getDataByModel?.('core', 'core') || hostApp?.data?.store?.getStore?.().getDataByModel?.('core', 'core') || coreData?.core || coreData || {};
|
|
136
139
|
const shop = {
|
|
137
140
|
...(coreData?.core?.shop || coreData?.shop || {}),
|
|
138
141
|
...(getData?.('shop_info') || {}),
|
|
@@ -142,6 +145,8 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
142
145
|
tax_country_code: getData('tax_country_code')
|
|
143
146
|
} : {})
|
|
144
147
|
};
|
|
148
|
+
shop.default_domain || (shop.default_domain = shopCore.default_domain);
|
|
149
|
+
shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
|
|
145
150
|
if (generation !== this.generation || this.disposed) throw new Error('Invoice request superseded');
|
|
146
151
|
const languageOptions = (0, _customerInvoiceLanguages.resolveCustomerInvoiceLanguages)(template.language, input.locale);
|
|
147
152
|
const remembered = this.languageSelection?.code;
|
|
@@ -232,6 +232,7 @@ const MAX_AVAILABILITY_RANGE_DAYS = 90;
|
|
|
232
232
|
const MAX_AVAILABILITY_CONTEXT_REGISTRY = 128;
|
|
233
233
|
const MAX_AVAILABILITY_PROJECTION_POOL = 16;
|
|
234
234
|
const MAX_REMOTE_OCCUPANCY_RESOURCE_DATE_CELLS = 4096;
|
|
235
|
+
const PREVIEW_OCCUPANCY_CACHE_MAX_AGE_MS = 30 * 1000;
|
|
235
236
|
function isValidClockTime(value) {
|
|
236
237
|
const match = /^(\d{2}):(\d{2})$/.exec(value);
|
|
237
238
|
if (!match) return false;
|
|
@@ -2811,6 +2812,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2811
2812
|
};
|
|
2812
2813
|
}
|
|
2813
2814
|
assertAvailabilityPrepareParams(params) {
|
|
2815
|
+
if (params.occupancyCachePolicy !== undefined && params.occupancyCachePolicy !== 'cache_first') {
|
|
2816
|
+
throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', 'Unknown occupancyCachePolicy');
|
|
2817
|
+
}
|
|
2814
2818
|
assertAvailabilityCatalogProductIds(params.productIds, 'prepare.productIds');
|
|
2815
2819
|
const hasProductAnchor = Array.isArray(params.productIds) && params.productIds.length > 0;
|
|
2816
2820
|
const hasResourceAnchor = Array.isArray(params.resourceIds) && params.resourceIds.length > 0;
|
|
@@ -3043,7 +3047,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3043
3047
|
const cacheParams = {
|
|
3044
3048
|
scopeKey,
|
|
3045
3049
|
resourceIds: normalizedResourceIds,
|
|
3046
|
-
dateRange: params.dateRange
|
|
3050
|
+
dateRange: params.dateRange,
|
|
3051
|
+
maxAgeMs: params.maxAgeMs
|
|
3047
3052
|
};
|
|
3048
3053
|
const cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
3049
3054
|
if (cachedRawResources) {
|
|
@@ -3058,6 +3063,22 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3058
3063
|
}
|
|
3059
3064
|
return cachedRawResources;
|
|
3060
3065
|
}
|
|
3066
|
+
if (params.maxAgeMs !== undefined) {
|
|
3067
|
+
// A visible-month request can cover a concurrent day/resource-subset preview.
|
|
3068
|
+
// Only share fully covering requests; partial overlaps keep the normal fetch path.
|
|
3069
|
+
const epoch = this.availabilityRemoteResourceEpoch;
|
|
3070
|
+
const covering = Array.from(this.availabilityRemoteResourceQueryInFlight.values()).find(entry => entry.epoch === epoch && entry.scopeKey === scopeKey && entry.dateRange.startDate <= params.dateRange.startDate && entry.dateRange.endDate >= params.dateRange.endDate && normalizedResourceIds.every(id => entry.resourceIds.some(other => String(other) === String(id))));
|
|
3071
|
+
if (covering) {
|
|
3072
|
+
await covering.promise;
|
|
3073
|
+
if (epoch !== this.availabilityRemoteResourceEpoch) {
|
|
3074
|
+
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'Resource settings changed while loading. Please prepare again.');
|
|
3075
|
+
}
|
|
3076
|
+
// Read a detached, correctly sliced graph after publication. A newer overlapping
|
|
3077
|
+
// response may have invalidated cells, in which case fetch this exact range below.
|
|
3078
|
+
const coveredResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
3079
|
+
if (coveredResources) return coveredResources;
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3061
3082
|
return await this.refreshAvailabilityRemoteResourceQuery({
|
|
3062
3083
|
timezone: params.timezone,
|
|
3063
3084
|
dateRange: params.dateRange,
|
|
@@ -3079,19 +3100,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3079
3100
|
}
|
|
3080
3101
|
this.availabilityRemoteResourceQuerySequence += 1;
|
|
3081
3102
|
const writeVersion = this.availabilityRemoteResourceQuerySequence;
|
|
3103
|
+
const scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
|
|
3082
3104
|
const promise = this.fetchAvailabilityResourcesV2({
|
|
3083
3105
|
dateRange: params.dateRange,
|
|
3084
3106
|
resourceIds: normalizedResourceIds
|
|
3085
|
-
})
|
|
3086
|
-
this.availabilityRemoteResourceQueryInFlight.set(queryKey, {
|
|
3087
|
-
epoch,
|
|
3088
|
-
promise
|
|
3089
|
-
});
|
|
3090
|
-
try {
|
|
3091
|
-
const rawResources = await promise;
|
|
3107
|
+
}).then(rawResources => {
|
|
3092
3108
|
if (epoch === this.availabilityRemoteResourceEpoch) {
|
|
3093
3109
|
this.availabilityRemoteOccupancyCache.publish({
|
|
3094
|
-
scopeKey
|
|
3110
|
+
scopeKey,
|
|
3095
3111
|
timezoneName: params.timezone,
|
|
3096
3112
|
resourceIds: normalizedResourceIds,
|
|
3097
3113
|
dateRange: params.dateRange,
|
|
@@ -3100,6 +3116,18 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3100
3116
|
});
|
|
3101
3117
|
}
|
|
3102
3118
|
return rawResources;
|
|
3119
|
+
});
|
|
3120
|
+
this.availabilityRemoteResourceQueryInFlight.set(queryKey, {
|
|
3121
|
+
epoch,
|
|
3122
|
+
scopeKey,
|
|
3123
|
+
dateRange: {
|
|
3124
|
+
...params.dateRange
|
|
3125
|
+
},
|
|
3126
|
+
resourceIds: [...normalizedResourceIds],
|
|
3127
|
+
promise
|
|
3128
|
+
});
|
|
3129
|
+
try {
|
|
3130
|
+
return await promise;
|
|
3103
3131
|
} finally {
|
|
3104
3132
|
const current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3105
3133
|
if (current?.promise === promise) {
|
|
@@ -3149,7 +3177,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3149
3177
|
};
|
|
3150
3178
|
const rawResources = params.fetchPolicy === 'refresh' ? await this.refreshAvailabilityRemoteResourceQuery(remoteQuery) : await this.fetchAndPublishAvailabilityResourcesV2({
|
|
3151
3179
|
...remoteQuery,
|
|
3152
|
-
useCacheOnHit:
|
|
3180
|
+
useCacheOnHit: params.fetchPolicy !== 'cache_first',
|
|
3181
|
+
...(params.fetchPolicy === 'cache_first' ? {
|
|
3182
|
+
maxAgeMs: PREVIEW_OCCUPANCY_CACHE_MAX_AGE_MS
|
|
3183
|
+
} : {})
|
|
3153
3184
|
});
|
|
3154
3185
|
return buildAvailabilityResourcesFromV2({
|
|
3155
3186
|
rawResources,
|
|
@@ -3374,7 +3405,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3374
3405
|
rawResources: normalizedPrepareParams.rawResources,
|
|
3375
3406
|
scheduleList,
|
|
3376
3407
|
// An explicit internal policy (notably commit's cache_only) remains authoritative.
|
|
3377
|
-
fetchPolicy: options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : 'default'),
|
|
3408
|
+
fetchPolicy: options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : normalizedPrepareParams.occupancyCachePolicy === 'cache_first' ? 'cache_first' : 'default'),
|
|
3378
3409
|
fallbackResources: options.fallbackResources
|
|
3379
3410
|
});
|
|
3380
3411
|
const tempOrder = this.getTempOrder();
|
|
@@ -11,6 +11,8 @@ export declare class AvailabilityRemoteOccupancyCache {
|
|
|
11
11
|
scopeKey: string;
|
|
12
12
|
resourceIds: AvailabilityId[];
|
|
13
13
|
dateRange: AvailabilityDateRange;
|
|
14
|
+
/** Only opt-in preview reads expire cells; legacy reads retain their SWR semantics. */
|
|
15
|
+
maxAgeMs?: number;
|
|
14
16
|
}): Record<string, any>[] | null;
|
|
15
17
|
hasCompleteCoverage(params: {
|
|
16
18
|
scopeKey: string;
|
|
@@ -117,6 +117,7 @@ class AvailabilityRemoteOccupancyCache {
|
|
|
117
117
|
const requestedResourceIds = uniqueIds(params.resourceIds);
|
|
118
118
|
const requestedDates = buildDateList(params.dateRange);
|
|
119
119
|
if (requestedResourceIds.length === 0 || requestedDates.length === 0) return [];
|
|
120
|
+
const now = Date.now();
|
|
120
121
|
const resources = [];
|
|
121
122
|
for (const resourceId of requestedResourceIds) {
|
|
122
123
|
const resourceKey = this.buildResourceKey(params.scopeKey, resourceId);
|
|
@@ -125,6 +126,7 @@ class AvailabilityRemoteOccupancyCache {
|
|
|
125
126
|
const cellKey = this.buildCellKey(resourceKey, date);
|
|
126
127
|
const cell = this.touchCell(cellKey);
|
|
127
128
|
if (!cell) return null;
|
|
129
|
+
if (params.maxAgeMs !== undefined && (now < cell.fetchedAt || now - cell.fetchedAt >= params.maxAgeMs)) return null;
|
|
128
130
|
cell.eventList.forEach(rawEvent => {
|
|
129
131
|
eventList.set(buildEventIdentity(resourceId, rawEvent), (0, _lodashEs.cloneDeep)(rawEvent));
|
|
130
132
|
});
|
|
@@ -85,6 +85,8 @@ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
|
|
|
85
85
|
publishCatalog?: boolean;
|
|
86
86
|
/** Await remote occupancy refresh instead of stale-while-revalidate. Ignores rawResources; does not lock resources. */
|
|
87
87
|
refreshOccupancies?: boolean;
|
|
88
|
+
/** Preview only: reuse complete resource/date coverage for 30 seconds without a background request. refreshOccupancies takes precedence. Omit to retain stale-while-revalidate. */
|
|
89
|
+
occupancyCachePolicy?: 'cache_first';
|
|
88
90
|
/** Enforce configured sale cutoffs and disable manual POS availability overrides for this context. Defaults to false. */
|
|
89
91
|
strictAvailability?: boolean;
|
|
90
92
|
rawResources?: Record<string, any>[];
|