@pisell/pisellos 2.2.299 → 2.2.301
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +163 -46
- package/dist/modules/ResourcePlanner/types.d.ts +17 -0
- package/dist/solution/UnifiedBookingSales/index.js +92 -19
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +137 -35
- package/lib/modules/ResourcePlanner/types.d.ts +17 -0
- package/lib/solution/UnifiedBookingSales/index.js +84 -20
- package/package.json +1 -1
|
@@ -673,14 +673,9 @@ function normalizeResource(raw) {
|
|
|
673
673
|
var id = (_ref5 = (_raw$resourceId = raw.resourceId) !== null && _raw$resourceId !== void 0 ? _raw$resourceId : raw.resource_id) !== null && _ref5 !== void 0 ? _ref5 : raw.id;
|
|
674
674
|
if (id === undefined || id === null || id === '') return null;
|
|
675
675
|
var rawWindows = raw.windows || raw.times || [];
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
name: raw.resourceName || raw.main_field || raw.name || raw.title,
|
|
680
|
-
code: raw.code,
|
|
681
|
-
resourceType: normalizeResourceType(raw.type || raw.resourceType),
|
|
682
|
-
capacity: Math.max(1, Number(raw.capacity || raw.max_capacity || 1) || 1),
|
|
683
|
-
windows: (Array.isArray(rawWindows) ? rawWindows : []).flatMap(function (window) {
|
|
676
|
+
var rawExcludedWindows = raw.excludedWindows || raw.excluded_windows || [];
|
|
677
|
+
var normalizeWindows = function normalizeWindows(windows) {
|
|
678
|
+
return (Array.isArray(windows) ? windows : []).flatMap(function (window) {
|
|
684
679
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
685
680
|
startAt: window.startAt || window.start_at || window.start,
|
|
686
681
|
endAt: window.endAt || window.end_at || window.end,
|
|
@@ -694,7 +689,17 @@ function normalizeResource(raw) {
|
|
|
694
689
|
source: window.source,
|
|
695
690
|
raw: window
|
|
696
691
|
}];
|
|
697
|
-
})
|
|
692
|
+
});
|
|
693
|
+
};
|
|
694
|
+
return {
|
|
695
|
+
id: id,
|
|
696
|
+
formId: (_ref6 = (_raw$formId = raw.formId) !== null && _raw$formId !== void 0 ? _raw$formId : raw.form_id) !== null && _ref6 !== void 0 ? _ref6 : raw.resource_form_id,
|
|
697
|
+
name: raw.resourceName || raw.main_field || raw.name || raw.title,
|
|
698
|
+
code: raw.code,
|
|
699
|
+
resourceType: normalizeResourceType(raw.type || raw.resourceType),
|
|
700
|
+
capacity: Math.max(1, Number(raw.capacity || raw.max_capacity || 1) || 1),
|
|
701
|
+
windows: normalizeWindows(rawWindows),
|
|
702
|
+
excludedWindows: normalizeWindows(rawExcludedWindows),
|
|
698
703
|
raw: raw
|
|
699
704
|
};
|
|
700
705
|
}
|
|
@@ -718,6 +723,16 @@ function dateRangeDays(dateRange) {
|
|
|
718
723
|
}
|
|
719
724
|
return dates;
|
|
720
725
|
}
|
|
726
|
+
function getExcludedScheduleDateOverrideTimePoints(date, schedule) {
|
|
727
|
+
var _schedule$repeat_rule;
|
|
728
|
+
if (!((_schedule$repeat_rule = schedule.repeat_rule) !== null && _schedule$repeat_rule !== void 0 && (_schedule$repeat_rule = _schedule$repeat_rule.excluded_date) !== null && _schedule$repeat_rule !== void 0 && _schedule$repeat_rule.length)) return [];
|
|
729
|
+
if (getScheduleStartEndTimePoints(date, [schedule]).length > 0) return [];
|
|
730
|
+
return getScheduleStartEndTimePoints(date, [_objectSpread(_objectSpread({}, schedule), {}, {
|
|
731
|
+
repeat_rule: _objectSpread(_objectSpread({}, schedule.repeat_rule), {}, {
|
|
732
|
+
excluded_date: []
|
|
733
|
+
})
|
|
734
|
+
})]);
|
|
735
|
+
}
|
|
721
736
|
function normalizeResourceOccupancy(rawEvent, resourceId) {
|
|
722
737
|
var _ref9, _ref10, _rawEvent$start_at, _ref11, _ref12, _rawEvent$end_at, _ref13, _ref14, _rawEvent$pax, _rawEvent$schedule_ev, _ref15, _rawEvent$schedule_ev2, _ref16, _rawEvent$booking_uid, _rawEvent$metadata, _ref17, _rawEvent$product_uid, _rawEvent$metadata2;
|
|
723
738
|
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'remote';
|
|
@@ -824,7 +839,30 @@ export function buildAvailabilityResourcesFromV2(params) {
|
|
|
824
839
|
});
|
|
825
840
|
});
|
|
826
841
|
});
|
|
842
|
+
var excludedWindows = dates.flatMap(function (date) {
|
|
843
|
+
return schedules.flatMap(function (schedule) {
|
|
844
|
+
return getExcludedScheduleDateOverrideTimePoints(date, schedule).flatMap(function (slot) {
|
|
845
|
+
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
846
|
+
startAt: slot.start_at,
|
|
847
|
+
endAt: slot.end_at,
|
|
848
|
+
fixedOffsetMinutes: fixedOffsetMinutes,
|
|
849
|
+
rollOverEnd: true
|
|
850
|
+
});
|
|
851
|
+
if (!range) return [];
|
|
852
|
+
return [{
|
|
853
|
+
startAt: range.startAt,
|
|
854
|
+
endAt: range.endAt,
|
|
855
|
+
source: "resource_schedule_excluded:".concat(schedule.id),
|
|
856
|
+
raw: {
|
|
857
|
+
scheduleId: schedule.id,
|
|
858
|
+
excludedDate: date
|
|
859
|
+
}
|
|
860
|
+
}];
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
});
|
|
827
864
|
resource.windows = materializedWindows.length > 0 ? materializedWindows : explicitWindows;
|
|
865
|
+
resource.excludedWindows = [].concat(_toConsumableArray(resource.excludedWindows || []), _toConsumableArray(excludedWindows));
|
|
828
866
|
if (resource.windows.length === 0 && missingScheduleIds.length > 0) {
|
|
829
867
|
resource.windows = buildResourceWindowFallbackTimes({
|
|
830
868
|
raw: raw,
|
|
@@ -1092,7 +1130,7 @@ function buildBookingFromAvailabilitySelection(params) {
|
|
|
1092
1130
|
} : {})
|
|
1093
1131
|
});
|
|
1094
1132
|
}
|
|
1095
|
-
var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
|
|
1133
|
+
var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'schedule_excluded_date', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
|
|
1096
1134
|
// A required group whose selected resource is outside its window is surfaced
|
|
1097
1135
|
// as missing_resource at group level. Structural validation below still
|
|
1098
1136
|
// rejects a genuinely missing selection.
|
|
@@ -3053,12 +3091,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3053
3091
|
}] : [];
|
|
3054
3092
|
});
|
|
3055
3093
|
});
|
|
3056
|
-
|
|
3094
|
+
var excludedWindows = dateRangeDays(params.dateRange).flatMap(function (date) {
|
|
3095
|
+
return schedules.flatMap(function (schedule) {
|
|
3096
|
+
return getExcludedScheduleDateOverrideTimePoints(date, schedule).flatMap(function (slot) {
|
|
3097
|
+
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3098
|
+
startAt: slot.start_at,
|
|
3099
|
+
endAt: slot.end_at,
|
|
3100
|
+
fixedOffsetMinutes: _this3.getAvailabilityRuntimeOffsetMinutes(),
|
|
3101
|
+
rollOverEnd: true
|
|
3102
|
+
});
|
|
3103
|
+
return range ? [{
|
|
3104
|
+
startAt: range.startAt,
|
|
3105
|
+
endAt: range.endAt,
|
|
3106
|
+
source: "operating_schedule_excluded:".concat(schedule.id),
|
|
3107
|
+
raw: {
|
|
3108
|
+
scheduleId: schedule.id,
|
|
3109
|
+
excludedDate: date
|
|
3110
|
+
}
|
|
3111
|
+
}] : [];
|
|
3112
|
+
});
|
|
3113
|
+
});
|
|
3114
|
+
});
|
|
3115
|
+
return _objectSpread({
|
|
3057
3116
|
source: descriptor.source,
|
|
3058
3117
|
scheduleIds: _toConsumableArray(descriptor.scheduleIds),
|
|
3059
3118
|
missingScheduleIds: missingScheduleIds,
|
|
3060
3119
|
windows: windows
|
|
3061
|
-
}
|
|
3120
|
+
}, excludedWindows.length > 0 ? {
|
|
3121
|
+
excludedWindows: excludedWindows
|
|
3122
|
+
} : {});
|
|
3062
3123
|
}
|
|
3063
3124
|
}, {
|
|
3064
3125
|
key: "loadAvailabilityProducts",
|
|
@@ -4232,7 +4293,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4232
4293
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
4233
4294
|
} : {}), {
|
|
4234
4295
|
evaluatedAt: this.getAvailabilityRuntimeDateTime(),
|
|
4235
|
-
|
|
4296
|
+
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
4297
|
+
allowSessionCustomRanges: isPosAvailabilityRequest,
|
|
4298
|
+
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
4236
4299
|
}).map(function (group) {
|
|
4237
4300
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
4238
4301
|
ranges: group.ranges.map(function (candidate) {
|
|
@@ -4255,7 +4318,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4255
4318
|
key: "queryBookingAvailability",
|
|
4256
4319
|
value: (function () {
|
|
4257
4320
|
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(contextId, request) {
|
|
4258
|
-
var
|
|
4321
|
+
var _this$otherParams$pla2, _this$otherParams19;
|
|
4322
|
+
var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, result, contextVersion, contextualResult;
|
|
4259
4323
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
4260
4324
|
while (1) switch (_context36.prev = _context36.next) {
|
|
4261
4325
|
case 0:
|
|
@@ -4267,7 +4331,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4267
4331
|
projectionEntry = _yield$this$ensureAva2.projectionEntry;
|
|
4268
4332
|
refreshed = _yield$this$ensureAva2.refreshed;
|
|
4269
4333
|
this.assertContextualQueryFreshness(context, request);
|
|
4270
|
-
|
|
4334
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
|
|
4335
|
+
result = queryAvailabilityProjection(projectionEntry.projection, request, {
|
|
4336
|
+
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
4337
|
+
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
4338
|
+
});
|
|
4271
4339
|
contextVersion = context.activeVersion;
|
|
4272
4340
|
contextualResult = result.target === 'time' ? _objectSpread(_objectSpread({}, result), {}, {
|
|
4273
4341
|
data: result.data.map(function (group) {
|
|
@@ -4299,7 +4367,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4299
4367
|
contextVersion: contextVersion,
|
|
4300
4368
|
refreshed: refreshed
|
|
4301
4369
|
}));
|
|
4302
|
-
case
|
|
4370
|
+
case 12:
|
|
4303
4371
|
case "end":
|
|
4304
4372
|
return _context36.stop();
|
|
4305
4373
|
}
|
|
@@ -4376,7 +4444,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4376
4444
|
key: "commitAvailabilitySelection",
|
|
4377
4445
|
value: (function () {
|
|
4378
4446
|
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(contextId, params) {
|
|
4379
|
-
var normalizedContextId, _params$bookingCount, _ref46, _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$
|
|
4447
|
+
var normalizedContextId, _params$bookingCount, _ref46, _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$otherParams20, _ref47, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref48, _ref49, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, 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, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref50, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
|
|
4380
4448
|
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
4381
4449
|
while (1) switch (_context37.prev = _context37.next) {
|
|
4382
4450
|
case 0:
|
|
@@ -4606,7 +4674,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4606
4674
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
4607
4675
|
candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
|
|
4608
4676
|
candidateStartTime = getCandidateStartTime(params.candidate);
|
|
4609
|
-
allowPosAvailabilityOverride = String((_this$otherParams$
|
|
4677
|
+
allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
|
|
4610
4678
|
refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
|
|
4611
4679
|
productIds: [params.candidate.productId],
|
|
4612
4680
|
dateRange: {
|
|
@@ -4620,7 +4688,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4620
4688
|
}, allowPosAvailabilityOverride ? {
|
|
4621
4689
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
4622
4690
|
} : {}) : {}) : {}), {
|
|
4623
|
-
|
|
4691
|
+
useExactDurationCandidateMinute: allowPosAvailabilityOverride,
|
|
4692
|
+
allowSessionCustomRanges: allowPosAvailabilityOverride,
|
|
4693
|
+
allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
|
|
4624
4694
|
}).flatMap(function (group) {
|
|
4625
4695
|
return group.ranges;
|
|
4626
4696
|
});
|
|
@@ -4653,6 +4723,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4653
4723
|
requirementSelections: params.requirementSelections,
|
|
4654
4724
|
partySize: partySize,
|
|
4655
4725
|
bookingCount: bookingCount
|
|
4726
|
+
}, {
|
|
4727
|
+
useExactDurationCandidateMinute: allowPosAvailabilityOverride,
|
|
4728
|
+
allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
|
|
4656
4729
|
});
|
|
4657
4730
|
if (allowPosAvailabilityOverride && !validation.ok && validation.conflicts.every(function (conflict) {
|
|
4658
4731
|
return POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES.has(conflict.code);
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
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,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;
|