@pisell/pisellos 2.3.105 → 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/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +172 -49
- package/dist/modules/ResourcePlanner/types.d.ts +19 -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/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +92 -19
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Order/index.js +17 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +141 -35
- package/lib/modules/ResourcePlanner/types.d.ts +19 -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/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +84 -20
- package/package.json +1 -1
|
@@ -655,6 +655,22 @@ function normalizeResource(raw, fixedOffsetMinutes = (0, _localClock.captureRunt
|
|
|
655
655
|
const id = raw.resourceId ?? raw.resource_id ?? raw.id;
|
|
656
656
|
if (id === undefined || id === null || id === '') return null;
|
|
657
657
|
const rawWindows = raw.windows || raw.times || [];
|
|
658
|
+
const rawExcludedWindows = raw.excludedWindows || raw.excluded_windows || [];
|
|
659
|
+
const normalizeWindows = windows => (Array.isArray(windows) ? windows : []).flatMap(window => {
|
|
660
|
+
const range = normalizeAvailabilityLocalDateTimeRange({
|
|
661
|
+
startAt: window.startAt || window.start_at || window.start,
|
|
662
|
+
endAt: window.endAt || window.end_at || window.end,
|
|
663
|
+
fixedOffsetMinutes,
|
|
664
|
+
rollOverEnd: true
|
|
665
|
+
});
|
|
666
|
+
if (!range) return [];
|
|
667
|
+
return [{
|
|
668
|
+
startAt: range.startAt,
|
|
669
|
+
endAt: range.endAt,
|
|
670
|
+
source: window.source,
|
|
671
|
+
raw: window
|
|
672
|
+
}];
|
|
673
|
+
});
|
|
658
674
|
return {
|
|
659
675
|
id,
|
|
660
676
|
formId: raw.formId ?? raw.form_id ?? raw.resource_form_id,
|
|
@@ -662,21 +678,8 @@ function normalizeResource(raw, fixedOffsetMinutes = (0, _localClock.captureRunt
|
|
|
662
678
|
code: raw.code,
|
|
663
679
|
resourceType: normalizeResourceType(raw.type || raw.resourceType),
|
|
664
680
|
capacity: Math.max(1, Number(raw.capacity || raw.max_capacity || 1) || 1),
|
|
665
|
-
windows: (
|
|
666
|
-
|
|
667
|
-
startAt: window.startAt || window.start_at || window.start,
|
|
668
|
-
endAt: window.endAt || window.end_at || window.end,
|
|
669
|
-
fixedOffsetMinutes,
|
|
670
|
-
rollOverEnd: true
|
|
671
|
-
});
|
|
672
|
-
if (!range) return [];
|
|
673
|
-
return [{
|
|
674
|
-
startAt: range.startAt,
|
|
675
|
-
endAt: range.endAt,
|
|
676
|
-
source: window.source,
|
|
677
|
-
raw: window
|
|
678
|
-
}];
|
|
679
|
-
}),
|
|
681
|
+
windows: normalizeWindows(rawWindows),
|
|
682
|
+
excludedWindows: normalizeWindows(rawExcludedWindows),
|
|
680
683
|
raw
|
|
681
684
|
};
|
|
682
685
|
}
|
|
@@ -695,6 +698,17 @@ function dateRangeDays(dateRange) {
|
|
|
695
698
|
}
|
|
696
699
|
return dates;
|
|
697
700
|
}
|
|
701
|
+
function getExcludedScheduleDateOverrideTimePoints(date, schedule) {
|
|
702
|
+
if (!schedule.repeat_rule?.excluded_date?.length) return [];
|
|
703
|
+
if ((0, _getDateIsInSchedule.getScheduleStartEndTimePoints)(date, [schedule]).length > 0) return [];
|
|
704
|
+
return (0, _getDateIsInSchedule.getScheduleStartEndTimePoints)(date, [{
|
|
705
|
+
...schedule,
|
|
706
|
+
repeat_rule: {
|
|
707
|
+
...schedule.repeat_rule,
|
|
708
|
+
excluded_date: []
|
|
709
|
+
}
|
|
710
|
+
}]);
|
|
711
|
+
}
|
|
698
712
|
function normalizeResourceOccupancy(rawEvent, resourceId, source = 'remote', fixedOffsetMinutes = (0, _localClock.captureRuntimeOffsetMinutes)()) {
|
|
699
713
|
const range = normalizeAvailabilityLocalDateTimeRange({
|
|
700
714
|
startAt: rawEvent.start_at ?? rawEvent.startAt ?? rawEvent.start_time ?? rawEvent.startTime,
|
|
@@ -787,7 +801,26 @@ function buildAvailabilityResourcesFromV2(params) {
|
|
|
787
801
|
}
|
|
788
802
|
}];
|
|
789
803
|
})));
|
|
804
|
+
const excludedWindows = dates.flatMap(date => schedules.flatMap(schedule => getExcludedScheduleDateOverrideTimePoints(date, schedule).flatMap(slot => {
|
|
805
|
+
const range = normalizeAvailabilityLocalDateTimeRange({
|
|
806
|
+
startAt: slot.start_at,
|
|
807
|
+
endAt: slot.end_at,
|
|
808
|
+
fixedOffsetMinutes,
|
|
809
|
+
rollOverEnd: true
|
|
810
|
+
});
|
|
811
|
+
if (!range) return [];
|
|
812
|
+
return [{
|
|
813
|
+
startAt: range.startAt,
|
|
814
|
+
endAt: range.endAt,
|
|
815
|
+
source: `resource_schedule_excluded:${schedule.id}`,
|
|
816
|
+
raw: {
|
|
817
|
+
scheduleId: schedule.id,
|
|
818
|
+
excludedDate: date
|
|
819
|
+
}
|
|
820
|
+
}];
|
|
821
|
+
})));
|
|
790
822
|
resource.windows = materializedWindows.length > 0 ? materializedWindows : explicitWindows;
|
|
823
|
+
resource.excludedWindows = [...(resource.excludedWindows || []), ...excludedWindows];
|
|
791
824
|
if (resource.windows.length === 0 && missingScheduleIds.length > 0) {
|
|
792
825
|
resource.windows = buildResourceWindowFallbackTimes({
|
|
793
826
|
raw,
|
|
@@ -1028,7 +1061,7 @@ function buildBookingFromAvailabilitySelection(params) {
|
|
|
1028
1061
|
}
|
|
1029
1062
|
};
|
|
1030
1063
|
}
|
|
1031
|
-
const POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
|
|
1064
|
+
const POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'schedule_excluded_date', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
|
|
1032
1065
|
// A required group whose selected resource is outside its window is surfaced
|
|
1033
1066
|
// as missing_resource at group level. Structural validation below still
|
|
1034
1067
|
// rejects a genuinely missing selection.
|
|
@@ -2240,11 +2273,31 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2240
2273
|
source: `operating_schedule:${descriptor.scheduleIds.map(String).join(',')}`
|
|
2241
2274
|
}] : [];
|
|
2242
2275
|
}));
|
|
2276
|
+
const excludedWindows = dateRangeDays(params.dateRange).flatMap(date => schedules.flatMap(schedule => getExcludedScheduleDateOverrideTimePoints(date, schedule).flatMap(slot => {
|
|
2277
|
+
const range = normalizeAvailabilityLocalDateTimeRange({
|
|
2278
|
+
startAt: slot.start_at,
|
|
2279
|
+
endAt: slot.end_at,
|
|
2280
|
+
fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes(),
|
|
2281
|
+
rollOverEnd: true
|
|
2282
|
+
});
|
|
2283
|
+
return range ? [{
|
|
2284
|
+
startAt: range.startAt,
|
|
2285
|
+
endAt: range.endAt,
|
|
2286
|
+
source: `operating_schedule_excluded:${schedule.id}`,
|
|
2287
|
+
raw: {
|
|
2288
|
+
scheduleId: schedule.id,
|
|
2289
|
+
excludedDate: date
|
|
2290
|
+
}
|
|
2291
|
+
}] : [];
|
|
2292
|
+
})));
|
|
2243
2293
|
return {
|
|
2244
2294
|
source: descriptor.source,
|
|
2245
2295
|
scheduleIds: [...descriptor.scheduleIds],
|
|
2246
2296
|
missingScheduleIds,
|
|
2247
|
-
windows
|
|
2297
|
+
windows,
|
|
2298
|
+
...(excludedWindows.length > 0 ? {
|
|
2299
|
+
excludedWindows
|
|
2300
|
+
} : {})
|
|
2248
2301
|
};
|
|
2249
2302
|
}
|
|
2250
2303
|
async loadAvailabilityProducts(params) {
|
|
@@ -2942,7 +2995,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2942
2995
|
} : {})
|
|
2943
2996
|
}, {
|
|
2944
2997
|
evaluatedAt: this.getAvailabilityRuntimeDateTime(),
|
|
2945
|
-
|
|
2998
|
+
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
2999
|
+
allowSessionCustomRanges: isPosAvailabilityRequest,
|
|
3000
|
+
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
2946
3001
|
}).map(group => ({
|
|
2947
3002
|
...group,
|
|
2948
3003
|
ranges: group.ranges.map(candidate => this.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate))
|
|
@@ -2957,7 +3012,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2957
3012
|
refreshed
|
|
2958
3013
|
} = await this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
2959
3014
|
this.assertContextualQueryFreshness(context, request);
|
|
2960
|
-
const
|
|
3015
|
+
const isPosAvailabilityRequest = String(this.otherParams?.platform ?? '').trim().toLowerCase() === 'pos';
|
|
3016
|
+
const result = (0, _ResourcePlanner.queryAvailabilityProjection)(projectionEntry.projection, request, {
|
|
3017
|
+
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
3018
|
+
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
3019
|
+
});
|
|
2961
3020
|
const contextVersion = context.activeVersion;
|
|
2962
3021
|
const contextualResult = result.target === 'time' ? {
|
|
2963
3022
|
...result,
|
|
@@ -3214,7 +3273,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3214
3273
|
} : {})
|
|
3215
3274
|
} : {})
|
|
3216
3275
|
}, {
|
|
3217
|
-
|
|
3276
|
+
useExactDurationCandidateMinute: allowPosAvailabilityOverride,
|
|
3277
|
+
allowSessionCustomRanges: allowPosAvailabilityOverride,
|
|
3278
|
+
allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
|
|
3218
3279
|
}).flatMap(group => group.ranges);
|
|
3219
3280
|
const refreshedCandidateBase = refreshedRanges.find(candidate => candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt);
|
|
3220
3281
|
if (!refreshedCandidateBase) {
|
|
@@ -3235,6 +3296,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3235
3296
|
requirementSelections: params.requirementSelections,
|
|
3236
3297
|
partySize,
|
|
3237
3298
|
bookingCount
|
|
3299
|
+
}, {
|
|
3300
|
+
useExactDurationCandidateMinute: allowPosAvailabilityOverride,
|
|
3301
|
+
allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
|
|
3238
3302
|
});
|
|
3239
3303
|
if (allowPosAvailabilityOverride && !validation.ok && validation.conflicts.every(conflict => POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES.has(conflict.code))) {
|
|
3240
3304
|
const forced = buildPosForcedAvailabilityAssignments({
|