@pisell/pisellos 2.3.104 → 2.3.106
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 +9 -0
- package/dist/modules/Order/index.js +21 -1
- package/dist/modules/Payment/walletpass.js +20 -21
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +193 -47
- package/dist/modules/ResourcePlanner/types.d.ts +26 -0
- package/dist/modules/Rules/index.js +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +2 -0
- package/dist/server/utils/small-ticket.js +49 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/index.js +121 -40
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Order/index.js +17 -0
- package/lib/modules/Payment/walletpass.js +14 -11
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +161 -34
- package/lib/modules/ResourcePlanner/types.d.ts +26 -0
- package/lib/modules/Rules/index.js +1 -1
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +2 -0
- package/lib/server/utils/small-ticket.js +50 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/index.js +97 -25
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
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";
|
|
@@ -32,7 +32,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
32
32
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
33
|
import { BaseModule } from "../BaseModule";
|
|
34
34
|
import { OrderHooks } from "./types";
|
|
35
|
-
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
|
|
35
|
+
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
38
|
import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
|
|
@@ -7347,6 +7347,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7347
7347
|
row.metadata.booking_uid = row.booking_uid;
|
|
7348
7348
|
}
|
|
7349
7349
|
row = restoreHydratedBundleDiscounts(row, normalizeOrderProductDiscountList);
|
|
7350
|
+
var rawOriginalPrice = Number(row.original_price);
|
|
7351
|
+
var rawSellingPrice = Number(row.selling_price);
|
|
7352
|
+
var hasProductDiscounts = Array.isArray(row.discount_list) && row.discount_list.length > 0;
|
|
7353
|
+
var hasBundleDiscounts = row.product_bundle.some(function (bundle) {
|
|
7354
|
+
return Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
7355
|
+
});
|
|
7356
|
+
var isUndiscountedV2Line = String(row.metadata.price_schema_version) === '2' && Number.isFinite(rawOriginalPrice) && Number.isFinite(rawSellingPrice) && new Decimal(rawOriginalPrice).eq(rawSellingPrice) && !hasProductDiscounts && !hasBundleDiscounts;
|
|
7357
|
+
if (isUndiscountedV2Line) {
|
|
7358
|
+
var hasPriceValue = function hasPriceValue(value) {
|
|
7359
|
+
return value !== undefined && value !== null && value !== '';
|
|
7360
|
+
};
|
|
7361
|
+
row.product_bundle = row.product_bundle.map(function (bundle) {
|
|
7362
|
+
if (!bundle || isMarkdownBundle(bundle) || hasPriceValue(bundle.original_price) || hasPriceValue(bundle.product_price) || !hasPriceValue(bundle.bundle_selling_price)) {
|
|
7363
|
+
return bundle;
|
|
7364
|
+
}
|
|
7365
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
7366
|
+
original_price: bundle.bundle_selling_price
|
|
7367
|
+
});
|
|
7368
|
+
});
|
|
7369
|
+
}
|
|
7350
7370
|
var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
|
|
7351
7371
|
if (!existingIdentity) {
|
|
7352
7372
|
row.metadata.unique_identification_number = createUuidV4();
|
|
@@ -851,7 +851,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
851
851
|
key: "getUserIdentificationCodeListAsync",
|
|
852
852
|
value: function () {
|
|
853
853
|
var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
|
854
|
-
var _newParams$products, _newParams$prepare_pa, _this$walletParams4, newParams,
|
|
854
|
+
var _newParams$products, _newParams$prepare_pa, _this$walletParams4, newParams, response, sortedData;
|
|
855
855
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
856
856
|
while (1) switch (_context6.prev = _context6.next) {
|
|
857
857
|
case 0:
|
|
@@ -864,20 +864,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
864
864
|
this.paymentModule.logInfo('[WalletPass] 商品列表为空,跳过获取用户识别码列表');
|
|
865
865
|
return _context6.abrupt("return", []);
|
|
866
866
|
case 5:
|
|
867
|
-
platform = this.paymentModule.getPlatform();
|
|
868
|
-
if (
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
this.
|
|
874
|
-
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
case 11:
|
|
867
|
+
// const platform = this.paymentModule.getPlatform();
|
|
868
|
+
// if (platform === 'pc' || platform === 'h5') {
|
|
869
|
+
// this.userIdentificationCodes = [];
|
|
870
|
+
// this.emitEvent(WalletPassHooks.OnUserIdentificationCodesUpdated, {
|
|
871
|
+
// userIdentificationCodes: [],
|
|
872
|
+
// } as OnUserIdentificationCodesUpdatedEventData);
|
|
873
|
+
// this.paymentModule.logInfo(
|
|
874
|
+
// '[WalletPass] 用户端平台跳过获取用户识别码列表',
|
|
875
|
+
// { platform },
|
|
876
|
+
// );
|
|
877
|
+
// return [];
|
|
878
|
+
// }
|
|
879
|
+
|
|
881
880
|
if (typeof newParams.payment_order_id === 'string' && newParams.payment_order_id.startsWith('LOCAL_')) {
|
|
882
881
|
newParams.payment_order_id = undefined;
|
|
883
882
|
}
|
|
@@ -888,9 +887,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
888
887
|
filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
|
|
889
888
|
payment_order_id: (_this$walletParams4 = this.walletParams) === null || _this$walletParams4 === void 0 ? void 0 : _this$walletParams4.payment_order_id
|
|
890
889
|
});
|
|
891
|
-
_context6.next =
|
|
890
|
+
_context6.next = 9;
|
|
892
891
|
return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
|
|
893
|
-
case
|
|
892
|
+
case 9:
|
|
894
893
|
response = _context6.sent;
|
|
895
894
|
// 对获取到的数据进行排序,将错误码为 500100、500200、500300 的项目排到最后
|
|
896
895
|
sortedData = sortUserIdentificationCodeList((response === null || response === void 0 ? void 0 : response.data) || []);
|
|
@@ -911,19 +910,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
911
910
|
})
|
|
912
911
|
});
|
|
913
912
|
return _context6.abrupt("return", this.userIdentificationCodes);
|
|
914
|
-
case
|
|
915
|
-
_context6.prev =
|
|
913
|
+
case 17:
|
|
914
|
+
_context6.prev = 17;
|
|
916
915
|
_context6.t0 = _context6["catch"](0);
|
|
917
916
|
this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context6.t0, {
|
|
918
917
|
customer_id: params.customer_id,
|
|
919
918
|
available: params.available
|
|
920
919
|
});
|
|
921
920
|
return _context6.abrupt("return", []);
|
|
922
|
-
case
|
|
921
|
+
case 21:
|
|
923
922
|
case "end":
|
|
924
923
|
return _context6.stop();
|
|
925
924
|
}
|
|
926
|
-
}, _callee6, this, [[0,
|
|
925
|
+
}, _callee6, this, [[0, 17]]);
|
|
927
926
|
}));
|
|
928
927
|
function getUserIdentificationCodeListAsync(_x7) {
|
|
929
928
|
return _getUserIdentificationCodeListAsync.apply(this, arguments);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AvailabilityProjection, AvailabilityProjectionInput, AvailabilityQuery, AvailabilityQueryResult, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, GetProductTimeRangesRequest, GetProductTimeRangesRuntimeOptions, ProductTimeRangeGroup } from './types';
|
|
2
2
|
export declare function createAvailabilityProjection(input: AvailabilityProjectionInput): AvailabilityProjection;
|
|
3
3
|
export declare function getProductTimeRanges(projection: AvailabilityProjection, request?: GetProductTimeRangesRequest, runtimeOptions?: GetProductTimeRangesRuntimeOptions): ProductTimeRangeGroup[];
|
|
4
|
-
export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery): AvailabilityQueryResult;
|
|
5
|
-
export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams): AvailabilitySelectionValidationResult;
|
|
4
|
+
export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery, runtimeOptions?: GetProductTimeRangesRuntimeOptions): AvailabilityQueryResult;
|
|
5
|
+
export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams, runtimeOptions?: GetProductTimeRangesRuntimeOptions): AvailabilitySelectionValidationResult;
|
|
@@ -62,13 +62,21 @@ function resolveRequestedDurationMinutes(product, request) {
|
|
|
62
62
|
}
|
|
63
63
|
function resolveRequestedDurationStartTimes(product, request) {
|
|
64
64
|
var _request$durationStar;
|
|
65
|
-
|
|
65
|
+
var allowSessionCustomRanges = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
66
|
+
if (product.kind !== 'duration' && !(product.kind === 'session' && allowSessionCustomRanges)) return [];
|
|
66
67
|
var values = (_request$durationStar = request.durationStartTimesByProductId) === null || _request$durationStar === void 0 ? void 0 : _request$durationStar[String(product.id)];
|
|
67
68
|
if (!Array.isArray(values)) return [];
|
|
68
69
|
return Array.from(new Set(values.filter(function (value) {
|
|
69
70
|
return typeof value === 'string' && /^([01]\d|2[0-3]):[0-5]\d$/.test(value);
|
|
70
71
|
})));
|
|
71
72
|
}
|
|
73
|
+
function resolveRequestedSessionDurationMinutes(product, request, allowSessionCustomRanges) {
|
|
74
|
+
var _request$durationMinu2;
|
|
75
|
+
if (product.kind !== 'session' || !allowSessionCustomRanges) return undefined;
|
|
76
|
+
var override = (_request$durationMinu2 = request.durationMinutesByProductId) === null || _request$durationMinu2 === void 0 ? void 0 : _request$durationMinu2[String(product.id)];
|
|
77
|
+
var normalized = Number(override);
|
|
78
|
+
return Number.isInteger(normalized) && normalized > 0 ? normalized : undefined;
|
|
79
|
+
}
|
|
72
80
|
function toDateTime(value, _timezoneName) {
|
|
73
81
|
try {
|
|
74
82
|
return localDateTimeToScalar(parseLocalDateTime(value));
|
|
@@ -167,8 +175,70 @@ function addLeadWindow(base, unit, unitType, _timezoneName) {
|
|
|
167
175
|
if (unitType === 'hours') return addLocalHours(base, unit);
|
|
168
176
|
return addLocalMinutes(base, unit);
|
|
169
177
|
}
|
|
178
|
+
function normalizedWindowContainsRange(windows, candidateRange, timezoneName) {
|
|
179
|
+
return windows.some(function (window) {
|
|
180
|
+
var normalized = normalizeAbsoluteRange(window, timezoneName);
|
|
181
|
+
return Boolean(normalized && contains(normalized, candidateRange));
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function normalizedWindowsContainDate(windows, date, timezoneName) {
|
|
185
|
+
return windows.some(function (window) {
|
|
186
|
+
var normalized = normalizeAbsoluteRange(window, timezoneName);
|
|
187
|
+
return Boolean(normalized && formatDate(normalized.start, timezoneName) === date);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function isRangeFromExcludedWindows(params) {
|
|
191
|
+
var candidateDate = formatDate(params.candidateRange.start, params.timezoneName);
|
|
192
|
+
var hasNormalWindowOnDate = normalizedWindowsContainDate(params.normalWindows, candidateDate, params.timezoneName);
|
|
193
|
+
var hasExcludedWindowOnDate = normalizedWindowsContainDate(params.excludedWindows, candidateDate, params.timezoneName);
|
|
194
|
+
if (!hasNormalWindowOnDate && hasExcludedWindowOnDate) return true;
|
|
195
|
+
return !normalizedWindowContainsRange(params.normalWindows, params.candidateRange, params.timezoneName) && normalizedWindowContainsRange(params.excludedWindows, params.candidateRange, params.timezoneName);
|
|
196
|
+
}
|
|
197
|
+
function isCandidateFromExcludedScheduleDate(params) {
|
|
198
|
+
var projection = params.projection,
|
|
199
|
+
product = params.product,
|
|
200
|
+
candidate = params.candidate,
|
|
201
|
+
candidateRange = params.candidateRange;
|
|
202
|
+
var operatingHours = projection.meta.defaults.operatingHours;
|
|
203
|
+
if (isRangeFromExcludedWindows({
|
|
204
|
+
normalWindows: operatingHours.windows,
|
|
205
|
+
excludedWindows: operatingHours.excludedWindows || [],
|
|
206
|
+
candidateRange: candidateRange,
|
|
207
|
+
timezoneName: projection.meta.timezone
|
|
208
|
+
})) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
if (product.kind !== 'session' && product.kind !== 'venue_slot') {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
if (candidate.source !== 'session_schedule') {
|
|
215
|
+
var hasNormalRule = (product.sessionRules || []).some(function (rule) {
|
|
216
|
+
return matchesScheduleRuleDate(rule, candidate.date, projection.meta.timezone);
|
|
217
|
+
});
|
|
218
|
+
var hasExcludedOverrideRule = (product.sessionRules || []).some(function (rule) {
|
|
219
|
+
return !matchesScheduleRuleDate(rule, candidate.date, projection.meta.timezone) && matchesScheduleRuleDate(rule, candidate.date, projection.meta.timezone, true);
|
|
220
|
+
});
|
|
221
|
+
return !hasNormalRule && hasExcludedOverrideRule;
|
|
222
|
+
}
|
|
223
|
+
var candidateDateRange = {
|
|
224
|
+
startDate: candidate.date,
|
|
225
|
+
endDate: candidate.date
|
|
226
|
+
};
|
|
227
|
+
var candidateIdentity = getProductTimeRangeIdentity(candidate);
|
|
228
|
+
var normalRanges = getSessionRangesForProduct(projection, product, candidateDateRange);
|
|
229
|
+
if (normalRanges.some(function (range) {
|
|
230
|
+
return getProductTimeRangeIdentity(range) === candidateIdentity;
|
|
231
|
+
})) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return getSessionRangesForProduct(projection, product, candidateDateRange, true).some(function (range) {
|
|
235
|
+
return getProductTimeRangeIdentity(range) === candidateIdentity;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
170
238
|
function evaluateCandidateTimeGate(params) {
|
|
171
|
-
var
|
|
239
|
+
var projection = params.projection,
|
|
240
|
+
product = params.product,
|
|
241
|
+
candidate = params.candidate,
|
|
172
242
|
candidateRange = params.candidateRange,
|
|
173
243
|
evaluationContext = params.evaluationContext,
|
|
174
244
|
timezoneName = params.timezoneName;
|
|
@@ -180,6 +250,18 @@ function evaluateCandidateTimeGate(params) {
|
|
|
180
250
|
conflictCode: 'past'
|
|
181
251
|
};
|
|
182
252
|
}
|
|
253
|
+
if (evaluationContext.allowExcludedScheduleDateOverride && isCandidateFromExcludedScheduleDate({
|
|
254
|
+
projection: projection,
|
|
255
|
+
product: product,
|
|
256
|
+
candidate: candidate,
|
|
257
|
+
candidateRange: candidateRange
|
|
258
|
+
})) {
|
|
259
|
+
return {
|
|
260
|
+
status: 'unavailable',
|
|
261
|
+
reasonCodes: ['schedule_excluded_date'],
|
|
262
|
+
conflictCode: 'schedule_excluded_date'
|
|
263
|
+
};
|
|
264
|
+
}
|
|
183
265
|
var policy = product.cutOffPolicy;
|
|
184
266
|
if (!policy) return null;
|
|
185
267
|
if (resolveCutOffPolicyIssue(policy)) {
|
|
@@ -212,7 +294,13 @@ function evaluateCandidateTimeGate(params) {
|
|
|
212
294
|
};
|
|
213
295
|
}
|
|
214
296
|
if (policy.type === 'before_start') {
|
|
215
|
-
|
|
297
|
+
// Flexible-duration candidates and POS fixed-duration anchors start at
|
|
298
|
+
// minute precision. Keep that current minute selectable instead of treating
|
|
299
|
+
// the freshly generated candidate as already started because the query
|
|
300
|
+
// clock still contains seconds.
|
|
301
|
+
var usesMinutePrecision = product.isFlexibleDuration || evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration';
|
|
302
|
+
var hasNotReachedStart = usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start;
|
|
303
|
+
if (hasNotReachedStart) return null;
|
|
216
304
|
return {
|
|
217
305
|
status: 'unavailable',
|
|
218
306
|
reasonCodes: ['booking_cutoff_before_start'],
|
|
@@ -322,7 +410,8 @@ function normalizeCoverage(input) {
|
|
|
322
410
|
};
|
|
323
411
|
}
|
|
324
412
|
function normalizeResourceWindow(resource, coverage, timezoneName) {
|
|
325
|
-
|
|
413
|
+
var includeExcludedWindows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
414
|
+
return mergeRanges([].concat(_toConsumableArray(resource.windows || []), _toConsumableArray(includeExcludedWindows ? resource.excludedWindows || [] : [])).map(function (window) {
|
|
326
415
|
return normalizeAbsoluteRange(window, timezoneName);
|
|
327
416
|
}).filter(function (window) {
|
|
328
417
|
return Boolean(window);
|
|
@@ -395,12 +484,15 @@ function normalizeResources(resources) {
|
|
|
395
484
|
capacity: Math.max(1, Number(resource.capacity || 1) || 1),
|
|
396
485
|
windows: (resource.windows || []).map(function (window) {
|
|
397
486
|
return _objectSpread({}, window);
|
|
487
|
+
}),
|
|
488
|
+
excludedWindows: (resource.excludedWindows || []).map(function (window) {
|
|
489
|
+
return _objectSpread({}, window);
|
|
398
490
|
})
|
|
399
491
|
});
|
|
400
492
|
});
|
|
401
493
|
}
|
|
402
494
|
function normalizeOperatingHours(params) {
|
|
403
|
-
var _params$input, _params$input2, _params$input3;
|
|
495
|
+
var _params$input, _params$input2, _params$input3, _params$input4;
|
|
404
496
|
var fallbackWindows = enumerateDates(params.dateRange.startDate, params.dateRange.endDate).map(function (date) {
|
|
405
497
|
var start = toDateTimeInDate(date, params.businessHours.startTime, params.timezoneName);
|
|
406
498
|
var end = toDateTimeInDate(date, params.businessHours.endTime, params.timezoneName);
|
|
@@ -418,26 +510,32 @@ function normalizeOperatingHours(params) {
|
|
|
418
510
|
endAt: formatDateTime(range.end, params.timezoneName, params.fixedOffsetMinutes)
|
|
419
511
|
};
|
|
420
512
|
});
|
|
421
|
-
var
|
|
422
|
-
return
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
source: ((_params$input = params.input) === null || _params$input === void 0 ? void 0 : _params$input.source) || params.fallbackSource,
|
|
437
|
-
scheduleIds: uniqById(((_params$input2 = params.input) === null || _params$input2 === void 0 ? void 0 : _params$input2.scheduleIds) || []),
|
|
438
|
-
missingScheduleIds: uniqById(((_params$input3 = params.input) === null || _params$input3 === void 0 ? void 0 : _params$input3.missingScheduleIds) || []),
|
|
439
|
-
windows: windows
|
|
513
|
+
var normalizeWindows = function normalizeWindows(source) {
|
|
514
|
+
return mergeRanges(source.map(function (window) {
|
|
515
|
+
return normalizeAbsoluteRange(window, params.timezoneName);
|
|
516
|
+
}).filter(function (window) {
|
|
517
|
+
return Boolean(window);
|
|
518
|
+
}).map(function (window) {
|
|
519
|
+
return clipRange(window, params.coverage);
|
|
520
|
+
}).filter(function (window) {
|
|
521
|
+
return Boolean(window);
|
|
522
|
+
})).map(function (range) {
|
|
523
|
+
return {
|
|
524
|
+
startAt: formatDateTime(range.start, params.timezoneName, params.fixedOffsetMinutes),
|
|
525
|
+
endAt: formatDateTime(range.end, params.timezoneName, params.fixedOffsetMinutes)
|
|
526
|
+
};
|
|
527
|
+
});
|
|
440
528
|
};
|
|
529
|
+
var windows = normalizeWindows(sourceWindows);
|
|
530
|
+
var excludedWindows = normalizeWindows(((_params$input = params.input) === null || _params$input === void 0 ? void 0 : _params$input.excludedWindows) || []);
|
|
531
|
+
return _objectSpread({
|
|
532
|
+
source: ((_params$input2 = params.input) === null || _params$input2 === void 0 ? void 0 : _params$input2.source) || params.fallbackSource,
|
|
533
|
+
scheduleIds: uniqById(((_params$input3 = params.input) === null || _params$input3 === void 0 ? void 0 : _params$input3.scheduleIds) || []),
|
|
534
|
+
missingScheduleIds: uniqById(((_params$input4 = params.input) === null || _params$input4 === void 0 ? void 0 : _params$input4.missingScheduleIds) || []),
|
|
535
|
+
windows: windows
|
|
536
|
+
}, excludedWindows.length > 0 ? {
|
|
537
|
+
excludedWindows: excludedWindows
|
|
538
|
+
} : {});
|
|
441
539
|
}
|
|
442
540
|
function matchesRequirementGroup(requirementGroup, resource, product) {
|
|
443
541
|
var _requirementGroup$res;
|
|
@@ -747,11 +845,12 @@ function resolveProjectionDateRange(projection, requestDateRange) {
|
|
|
747
845
|
};
|
|
748
846
|
}
|
|
749
847
|
function buildOperatingRanges(projection, dateRange) {
|
|
848
|
+
var includeExcludedWindows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
750
849
|
var coverage = {
|
|
751
850
|
start: toDateStart(dateRange.startDate, projection.meta.timezone),
|
|
752
851
|
end: toDateEnd(nextDate(dateRange.endDate), projection.meta.timezone)
|
|
753
852
|
};
|
|
754
|
-
return mergeRanges(projection.meta.defaults.operatingHours.windows.map(function (window) {
|
|
853
|
+
return mergeRanges([].concat(_toConsumableArray(projection.meta.defaults.operatingHours.windows), _toConsumableArray(includeExcludedWindows ? projection.meta.defaults.operatingHours.excludedWindows || [] : [])).map(function (window) {
|
|
755
854
|
return normalizeAbsoluteRange(window, projection.meta.timezone);
|
|
756
855
|
}).filter(function (window) {
|
|
757
856
|
return Boolean(window);
|
|
@@ -762,12 +861,13 @@ function buildOperatingRanges(projection, dateRange) {
|
|
|
762
861
|
}));
|
|
763
862
|
}
|
|
764
863
|
function buildResourceWindowIndex(projection) {
|
|
864
|
+
var includeExcludedWindows = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
765
865
|
var coverage = {
|
|
766
866
|
start: toDateTime(projection.meta.coverage.startAt, projection.meta.timezone),
|
|
767
867
|
end: toDateTime(projection.meta.coverage.endAt, projection.meta.timezone)
|
|
768
868
|
};
|
|
769
869
|
return new Map(projection.resources.map(function (resource) {
|
|
770
|
-
return [String(resource.id), normalizeResourceWindow(resource, coverage, projection.meta.timezone)];
|
|
870
|
+
return [String(resource.id), normalizeResourceWindow(resource, coverage, projection.meta.timezone, includeExcludedWindows)];
|
|
771
871
|
}));
|
|
772
872
|
}
|
|
773
873
|
function buildGroupWorkingRanges(params) {
|
|
@@ -789,7 +889,7 @@ function buildGroupWorkingRanges(params) {
|
|
|
789
889
|
return !filteredResourceIdSet || filteredResourceIdSet.has(String(resource.id));
|
|
790
890
|
}).map(function (resource) {
|
|
791
891
|
var _params$resourceWindo;
|
|
792
|
-
var windows = ((_params$resourceWindo = params.resourceWindowIndex) === null || _params$resourceWindo === void 0 ? void 0 : _params$resourceWindo.get(String(resource.id))) || normalizeResourceWindow(resource, coverage, projection.meta.timezone);
|
|
892
|
+
var windows = ((_params$resourceWindo = params.resourceWindowIndex) === null || _params$resourceWindo === void 0 ? void 0 : _params$resourceWindo.get(String(resource.id))) || normalizeResourceWindow(resource, coverage, projection.meta.timezone, params.includeExcludedWindows === true);
|
|
793
893
|
return windows.map(function (window) {
|
|
794
894
|
return clipRange(window, coverage);
|
|
795
895
|
}).filter(function (window) {
|
|
@@ -836,11 +936,12 @@ function buildGroupWorkingRanges(params) {
|
|
|
836
936
|
return mergeRanges(satisfiedRanges);
|
|
837
937
|
}
|
|
838
938
|
function materializeScheduleRules(rules, dateRange, timezoneName, fixedOffsetMinutes) {
|
|
939
|
+
var allowExcludedScheduleDates = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
839
940
|
var dates = enumerateDates(dateRange.startDate, dateRange.endDate);
|
|
840
941
|
var seen = new Map();
|
|
841
942
|
rules.forEach(function (rule) {
|
|
842
943
|
dates.forEach(function (date) {
|
|
843
|
-
if (!matchesScheduleRuleDate(rule, date, timezoneName)) return;
|
|
944
|
+
if (!matchesScheduleRuleDate(rule, date, timezoneName, allowExcludedScheduleDates)) return;
|
|
844
945
|
var start = toDateTimeInDate(date, rule.startTime, timezoneName);
|
|
845
946
|
var end = toDateTimeInDate(date, rule.endTime, timezoneName);
|
|
846
947
|
if (end <= start) end = toDateTimeInDate(nextDate(date, timezoneName), rule.endTime, timezoneName);
|
|
@@ -873,8 +974,9 @@ function materializeScheduleRules(rules, dateRange, timezoneName, fixedOffsetMin
|
|
|
873
974
|
}
|
|
874
975
|
function matchesScheduleRuleDate(rule, date, _timezoneName) {
|
|
875
976
|
var _rule$includeDates, _rule$excludeDates;
|
|
977
|
+
var allowExcludedScheduleDate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
876
978
|
if ((_rule$includeDates = rule.includeDates) !== null && _rule$includeDates !== void 0 && _rule$includeDates.includes(date)) return true;
|
|
877
|
-
if ((_rule$excludeDates = rule.excludeDates) !== null && _rule$excludeDates !== void 0 && _rule$excludeDates.includes(date)) return false;
|
|
979
|
+
if (!allowExcludedScheduleDate && (_rule$excludeDates = rule.excludeDates) !== null && _rule$excludeDates !== void 0 && _rule$excludeDates.includes(date)) return false;
|
|
878
980
|
if (rule.startDate && date < rule.startDate) return false;
|
|
879
981
|
if (rule.endDate && date > rule.endDate) return false;
|
|
880
982
|
if (rule.mode === 'designation') {
|
|
@@ -930,6 +1032,7 @@ function buildGroupResourceIndex(params) {
|
|
|
930
1032
|
}
|
|
931
1033
|
function getSessionRangesForProduct(projection, product, dateRange) {
|
|
932
1034
|
var _extractFixedOffsetMi2;
|
|
1035
|
+
var allowExcludedScheduleDates = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
933
1036
|
var fixedOffsetMinutes = (_extractFixedOffsetMi2 = extractFixedOffsetMinutes(projection.meta.now)) !== null && _extractFixedOffsetMi2 !== void 0 ? _extractFixedOffsetMi2 : captureRuntimeOffsetMinutes();
|
|
934
1037
|
var ranges = (product.sessionRanges || []).map(function (range) {
|
|
935
1038
|
var _range$scheduleRefs2;
|
|
@@ -955,7 +1058,7 @@ function getSessionRangesForProduct(projection, product, dateRange) {
|
|
|
955
1058
|
primaryScheduleRef: (_range$scheduleRefs2 = range.scheduleRefs) === null || _range$scheduleRefs2 === void 0 ? void 0 : _range$scheduleRefs2[0]
|
|
956
1059
|
};
|
|
957
1060
|
}).filter(Boolean);
|
|
958
|
-
var ruleRanges = materializeScheduleRules(product.sessionRules || [], dateRange, projection.meta.timezone, fixedOffsetMinutes);
|
|
1061
|
+
var ruleRanges = materializeScheduleRules(product.sessionRules || [], dateRange, projection.meta.timezone, fixedOffsetMinutes, allowExcludedScheduleDates);
|
|
959
1062
|
return dedupeProductRanges([].concat(_toConsumableArray(ranges), _toConsumableArray(ruleRanges.map(function (range) {
|
|
960
1063
|
return _objectSpread(_objectSpread({}, range), {}, {
|
|
961
1064
|
key: "".concat(String(product.id), ":").concat(range.startAt, ":").concat(range.endAt),
|
|
@@ -1010,7 +1113,8 @@ export function getProductTimeRanges(projection) {
|
|
|
1010
1113
|
var dateRange = resolveProjectionDateRange(projection, request.dateRange);
|
|
1011
1114
|
var slotStepMinutes = projection.meta.defaults.slotStepMinutes;
|
|
1012
1115
|
var fixedOffsetMinutes = (_extractFixedOffsetMi3 = extractFixedOffsetMinutes(projection.meta.now)) !== null && _extractFixedOffsetMi3 !== void 0 ? _extractFixedOffsetMi3 : captureRuntimeOffsetMinutes();
|
|
1013
|
-
var
|
|
1116
|
+
var allowExcludedScheduleDateOverride = runtimeOptions.allowExcludedScheduleDateOverride === true;
|
|
1117
|
+
var resourceWindowIndex = buildResourceWindowIndex(projection, allowExcludedScheduleDateOverride);
|
|
1014
1118
|
var filteredProductIdSet = (_request$productIds = request.productIds) !== null && _request$productIds !== void 0 && _request$productIds.length ? new Set(request.productIds.map(String)) : null;
|
|
1015
1119
|
return projection.products.filter(function (product) {
|
|
1016
1120
|
return !filteredProductIdSet || filteredProductIdSet.has(String(product.id));
|
|
@@ -1025,18 +1129,32 @@ export function getProductTimeRanges(projection) {
|
|
|
1025
1129
|
};
|
|
1026
1130
|
}
|
|
1027
1131
|
if (product.kind === 'session' || product.kind === 'venue_slot') {
|
|
1132
|
+
var fixedRanges = getSessionRangesForProduct(projection, product, dateRange, allowExcludedScheduleDateOverride);
|
|
1133
|
+
var customRanges = [];
|
|
1134
|
+
var customDurationMinutes = resolveRequestedSessionDurationMinutes(product, request, runtimeOptions.allowSessionCustomRanges === true);
|
|
1135
|
+
var _requestedStartTimes = resolveRequestedDurationStartTimes(product, request, runtimeOptions.allowSessionCustomRanges === true);
|
|
1136
|
+
if (product.kind === 'session' && customDurationMinutes && dateRange.startDate === dateRange.endDate) {
|
|
1137
|
+
_requestedStartTimes.forEach(function (startTime) {
|
|
1138
|
+
var start = toDateTimeInDate(dateRange.startDate, startTime, projection.meta.timezone);
|
|
1139
|
+
if (!Number.isFinite(start)) return;
|
|
1140
|
+
customRanges.push(createDurationTimeRange(product, start, customDurationMinutes, projection, fixedOffsetMinutes));
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1028
1143
|
return {
|
|
1029
1144
|
productId: product.id,
|
|
1030
1145
|
title: product.title,
|
|
1031
1146
|
kind: product.kind,
|
|
1032
1147
|
slotStepMinutes: slotStepMinutes,
|
|
1033
|
-
ranges:
|
|
1148
|
+
ranges: dedupeProductRanges([].concat(_toConsumableArray(fixedRanges), customRanges))
|
|
1034
1149
|
};
|
|
1035
1150
|
}
|
|
1036
1151
|
var requiredGroups = (product.requirementGroups || []).filter(function (group) {
|
|
1037
1152
|
return group.required !== false;
|
|
1038
1153
|
});
|
|
1039
|
-
var operatingRanges = buildOperatingRanges(projection, dateRange);
|
|
1154
|
+
var operatingRanges = buildOperatingRanges(projection, dateRange, allowExcludedScheduleDateOverride);
|
|
1155
|
+
var operatingEndAt = dateRange.startDate === dateRange.endDate && operatingRanges.length > 0 ? formatDateTime(Math.max.apply(Math, _toConsumableArray(operatingRanges.map(function (range) {
|
|
1156
|
+
return range.end;
|
|
1157
|
+
}))), projection.meta.timezone, fixedOffsetMinutes) : undefined;
|
|
1040
1158
|
var resourceRanges = requiredGroups.length ? requiredGroups.map(function (group) {
|
|
1041
1159
|
return buildGroupWorkingRanges({
|
|
1042
1160
|
projection: projection,
|
|
@@ -1045,7 +1163,8 @@ export function getProductTimeRanges(projection) {
|
|
|
1045
1163
|
dateRange: dateRange,
|
|
1046
1164
|
resourceIds: request.resourceIds,
|
|
1047
1165
|
partySize: normalizedPartySize,
|
|
1048
|
-
resourceWindowIndex: resourceWindowIndex
|
|
1166
|
+
resourceWindowIndex: resourceWindowIndex,
|
|
1167
|
+
includeExcludedWindows: allowExcludedScheduleDateOverride
|
|
1049
1168
|
});
|
|
1050
1169
|
}).reduce(function (current, ranges) {
|
|
1051
1170
|
return current === null ? ranges : intersectRangeLists(current, ranges);
|
|
@@ -1062,7 +1181,8 @@ export function getProductTimeRanges(projection) {
|
|
|
1062
1181
|
}
|
|
1063
1182
|
return floorToMinute(evaluatedAt);
|
|
1064
1183
|
}();
|
|
1065
|
-
var
|
|
1184
|
+
var durationCandidateAnchor = toDateTime(projection.meta.durationCandidateAnchorAt, projection.meta.timezone);
|
|
1185
|
+
var durationAnchor = runtimeOptions.useExactDurationCandidateMinute ? floorToMinute(durationCandidateAnchor) : ceilToTenMinutes(durationCandidateAnchor, projection.meta.timezone);
|
|
1066
1186
|
var requestedStartTimes = resolveRequestedDurationStartTimes(product, request);
|
|
1067
1187
|
var ranges = [];
|
|
1068
1188
|
baseRanges.forEach(function (range) {
|
|
@@ -1104,13 +1224,16 @@ export function getProductTimeRanges(projection) {
|
|
|
1104
1224
|
ranges.push(createDurationTimeRange(product, start, durationMinutes, projection, fixedOffsetMinutes));
|
|
1105
1225
|
});
|
|
1106
1226
|
}
|
|
1107
|
-
return {
|
|
1227
|
+
return _objectSpread(_objectSpread({
|
|
1108
1228
|
productId: product.id,
|
|
1109
1229
|
title: product.title,
|
|
1110
1230
|
kind: product.kind,
|
|
1111
|
-
slotStepMinutes: slotStepMinutes
|
|
1231
|
+
slotStepMinutes: slotStepMinutes
|
|
1232
|
+
}, operatingEndAt ? {
|
|
1233
|
+
operatingEndAt: operatingEndAt
|
|
1234
|
+
} : {}), {}, {
|
|
1112
1235
|
ranges: dedupeProductRanges(ranges)
|
|
1113
|
-
};
|
|
1236
|
+
});
|
|
1114
1237
|
});
|
|
1115
1238
|
}
|
|
1116
1239
|
function aggregateMatchedCells(productId, requirementGroupId, resourceId, candidateRange, indexedCells) {
|
|
@@ -1324,7 +1447,9 @@ function buildEvaluationContext(params) {
|
|
|
1324
1447
|
evaluatedAt: evaluatedAt,
|
|
1325
1448
|
evaluatedAtMs: evaluatedAt,
|
|
1326
1449
|
resourceIdSet: (_params$resourceIds2 = params.resourceIds) !== null && _params$resourceIds2 !== void 0 && _params$resourceIds2.length ? new Set(params.resourceIds.map(String)) : null,
|
|
1327
|
-
selectionsByGroupKey: selectionsByGroupKey
|
|
1450
|
+
selectionsByGroupKey: selectionsByGroupKey,
|
|
1451
|
+
useExactDurationCandidateMinute: params.useExactDurationCandidateMinute === true,
|
|
1452
|
+
allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true
|
|
1328
1453
|
};
|
|
1329
1454
|
}
|
|
1330
1455
|
function summarizeStatuses(statuses) {
|
|
@@ -1496,7 +1621,8 @@ function evaluateCandidateSummary(projection, candidate, request) {
|
|
|
1496
1621
|
var evaluationContext = request.evaluationContext || buildEvaluationContext({
|
|
1497
1622
|
projection: projection,
|
|
1498
1623
|
evaluatedAt: request.evaluatedAt,
|
|
1499
|
-
resourceIds: request.resourceIds
|
|
1624
|
+
resourceIds: request.resourceIds,
|
|
1625
|
+
allowExcludedScheduleDateOverride: request.allowExcludedScheduleDateOverride
|
|
1500
1626
|
});
|
|
1501
1627
|
var requestedPartySize = normalizePartySize(request.partySize);
|
|
1502
1628
|
var requiredGroups = (product.requirementGroups || []).filter(function (group) {
|
|
@@ -1514,7 +1640,9 @@ function evaluateCandidateSummary(projection, candidate, request) {
|
|
|
1514
1640
|
});
|
|
1515
1641
|
});
|
|
1516
1642
|
var gate = evaluateCandidateTimeGate({
|
|
1643
|
+
projection: projection,
|
|
1517
1644
|
product: product,
|
|
1645
|
+
candidate: candidate,
|
|
1518
1646
|
candidateRange: candidateRange,
|
|
1519
1647
|
evaluationContext: evaluationContext,
|
|
1520
1648
|
timezoneName: projection.meta.timezone
|
|
@@ -1569,7 +1697,8 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1569
1697
|
projection: projection,
|
|
1570
1698
|
evaluatedAt: request.evaluatedAt,
|
|
1571
1699
|
resourceIds: request.resourceIds,
|
|
1572
|
-
requirementSelections: request.requirementSelections
|
|
1700
|
+
requirementSelections: request.requirementSelections,
|
|
1701
|
+
allowExcludedScheduleDateOverride: request.allowExcludedScheduleDateOverride
|
|
1573
1702
|
});
|
|
1574
1703
|
var requestedPartySize = normalizePartySize(request.partySize);
|
|
1575
1704
|
var partySize = requestedPartySize !== null && requestedPartySize !== void 0 ? requestedPartySize : 1;
|
|
@@ -1592,6 +1721,12 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1592
1721
|
var options = matchedResources.map(function (resource) {
|
|
1593
1722
|
var _request$cellIndex, _resource$raw2;
|
|
1594
1723
|
var matchedCell = aggregateMatchedCells(product.id, requirementGroup.id, resource.id, candidateRange, ((_request$cellIndex = request.cellIndex) === null || _request$cellIndex === void 0 ? void 0 : _request$cellIndex.get([String(product.id), requirementGroup.id, String(resource.id)].join(':'))) || []);
|
|
1724
|
+
var isExcludedScheduleDate = evaluationContext.allowExcludedScheduleDateOverride && isRangeFromExcludedWindows({
|
|
1725
|
+
normalWindows: resource.windows || [],
|
|
1726
|
+
excludedWindows: resource.excludedWindows || [],
|
|
1727
|
+
candidateRange: candidateRange,
|
|
1728
|
+
timezoneName: projection.meta.timezone
|
|
1729
|
+
});
|
|
1595
1730
|
if (!matchedCell) {
|
|
1596
1731
|
var _resource$raw;
|
|
1597
1732
|
var _isPast = candidateRange.endMs <= evaluationContext.evaluatedAtMs;
|
|
@@ -1603,7 +1738,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1603
1738
|
resourceType: resource.resourceType,
|
|
1604
1739
|
status: _isPast ? 'past' : 'unavailable',
|
|
1605
1740
|
maxPartySize: 0,
|
|
1606
|
-
reasonCodes: _isPast ? ['past'] : ['outside_resource_window']
|
|
1741
|
+
reasonCodes: _isPast ? ['past'] : [].concat(_toConsumableArray(isExcludedScheduleDate ? ['schedule_excluded_date'] : []), ['outside_resource_window'])
|
|
1607
1742
|
};
|
|
1608
1743
|
}
|
|
1609
1744
|
var remainingCapacity = matchedCell.remainingCapacity;
|
|
@@ -1611,6 +1746,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1611
1746
|
var isPast = candidateRange.endMs <= evaluationContext.evaluatedAtMs;
|
|
1612
1747
|
var maxPartySize = isPast ? 0 : Math.max(0, remainingCapacity || 0);
|
|
1613
1748
|
var requiredCapacity = resolveRequiredCapacity(requirementGroup, product, requestedPartySize);
|
|
1749
|
+
var reasonCodes = Array.from(new Set([].concat(_toConsumableArray(matchedCell.reasonCodes), _toConsumableArray(isExcludedScheduleDate ? ['schedule_excluded_date'] : []))));
|
|
1614
1750
|
var status = function () {
|
|
1615
1751
|
if (isPast) return 'past';
|
|
1616
1752
|
if (matchedCell.status === 'unavailable') return 'unavailable';
|
|
@@ -1628,7 +1764,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1628
1764
|
remainingCapacity: remainingCapacity,
|
|
1629
1765
|
maxCapacity: maxCapacity,
|
|
1630
1766
|
maxPartySize: maxPartySize,
|
|
1631
|
-
reasonCodes: isPast ? Array.from(new Set([].concat(
|
|
1767
|
+
reasonCodes: isPast ? Array.from(new Set([].concat(reasonCodes, ['past']))) : reasonCodes,
|
|
1632
1768
|
matchedCell: matchedCell
|
|
1633
1769
|
};
|
|
1634
1770
|
});
|
|
@@ -1686,7 +1822,9 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1686
1822
|
return group.status;
|
|
1687
1823
|
});
|
|
1688
1824
|
var gate = evaluateCandidateTimeGate({
|
|
1825
|
+
projection: projection,
|
|
1689
1826
|
product: product,
|
|
1827
|
+
candidate: candidate,
|
|
1690
1828
|
candidateRange: candidateRange,
|
|
1691
1829
|
evaluationContext: evaluationContext,
|
|
1692
1830
|
timezoneName: projection.meta.timezone
|
|
@@ -1775,6 +1913,7 @@ function assertRangesWithinProjection(projection, ranges) {
|
|
|
1775
1913
|
}
|
|
1776
1914
|
export function queryAvailabilityProjection(projection, request) {
|
|
1777
1915
|
var _extractFixedOffsetMi6, _request$productIds2;
|
|
1916
|
+
var runtimeOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1778
1917
|
var normalizedPartySize = normalizePartySize(request.partySize);
|
|
1779
1918
|
var evaluatedAt = formatDateTime(localDateToScalar(new Date()), projection.meta.timezone, (_extractFixedOffsetMi6 = extractFixedOffsetMinutes(projection.meta.now)) !== null && _extractFixedOffsetMi6 !== void 0 ? _extractFixedOffsetMi6 : captureRuntimeOffsetMinutes());
|
|
1780
1919
|
if (request.target === 'time') {
|
|
@@ -1797,7 +1936,9 @@ export function queryAvailabilityProjection(projection, request) {
|
|
|
1797
1936
|
var evaluationContext = buildEvaluationContext({
|
|
1798
1937
|
projection: projection,
|
|
1799
1938
|
evaluatedAt: evaluatedAt,
|
|
1800
|
-
resourceIds: request.resourceIds
|
|
1939
|
+
resourceIds: request.resourceIds,
|
|
1940
|
+
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
1941
|
+
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
1801
1942
|
});
|
|
1802
1943
|
if (request.target === 'time') {
|
|
1803
1944
|
var candidates = dedupeProductRanges(request.candidates);
|
|
@@ -1885,7 +2026,9 @@ export function queryAvailabilityProjection(projection, request) {
|
|
|
1885
2026
|
resourceIds: request.resourceIds,
|
|
1886
2027
|
partySize: normalizedPartySize
|
|
1887
2028
|
}, {
|
|
1888
|
-
evaluatedAt: evaluatedAt
|
|
2029
|
+
evaluatedAt: evaluatedAt,
|
|
2030
|
+
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
2031
|
+
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
1889
2032
|
});
|
|
1890
2033
|
var candidateGroupMap = new Map(candidateGroups.map(function (group) {
|
|
1891
2034
|
return [String(group.productId), group];
|
|
@@ -2063,6 +2206,7 @@ function summarizeProductStatus(statuses) {
|
|
|
2063
2206
|
}
|
|
2064
2207
|
export function validateAvailabilitySelection(projection, params) {
|
|
2065
2208
|
var _extractFixedOffsetMi7;
|
|
2209
|
+
var runtimeOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2066
2210
|
var normalizedPartySize = normalizePartySize(params.partySize);
|
|
2067
2211
|
var normalizedBookingCount = normalizeBookingCount(params.bookingCount);
|
|
2068
2212
|
assertRangesWithinProjection(projection, [params.candidate]);
|
|
@@ -2083,14 +2227,16 @@ export function validateAvailabilitySelection(projection, params) {
|
|
|
2083
2227
|
evaluationContext: buildEvaluationContext({
|
|
2084
2228
|
projection: projection,
|
|
2085
2229
|
evaluatedAt: evaluatedAt,
|
|
2086
|
-
requirementSelections: params.requirementSelections
|
|
2230
|
+
requirementSelections: params.requirementSelections,
|
|
2231
|
+
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
2232
|
+
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
2087
2233
|
})
|
|
2088
2234
|
});
|
|
2089
2235
|
var conflicts = [];
|
|
2090
2236
|
if (evaluated.gate) {
|
|
2091
2237
|
conflicts.push({
|
|
2092
2238
|
code: evaluated.gate.conflictCode,
|
|
2093
|
-
message: evaluated.gate.
|
|
2239
|
+
message: evaluated.gate.conflictCode === 'past' ? '候选时间已过期' : evaluated.gate.conflictCode === 'schedule_excluded_date' ? '候选日期已被日程排除' : '候选时间不满足预订时间门禁',
|
|
2094
2240
|
reasonCodes: evaluated.gate.reasonCodes,
|
|
2095
2241
|
productId: params.candidate.productId,
|
|
2096
2242
|
candidateKey: params.candidate.key
|