@pisell/pisellos 0.10.9 → 0.10.11
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/OpenData/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +60 -47
- package/dist/modules/Order/types.d.ts +5 -2
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +7 -4
- package/dist/modules/ResourcePlanner/index.d.ts +0 -22
- package/dist/modules/ResourcePlanner/index.js +1 -180
- package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/dist/modules/ResourcePlanner/localClock.js +183 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
- package/dist/modules/ResourcePlanner/planner.js +2019 -936
- package/dist/modules/ResourcePlanner/types.d.ts +346 -187
- package/dist/modules/ResourcePlanner/types.js +33 -1
- package/dist/solution/BaseSales/index.js +32 -9
- package/dist/solution/BookingTicket/index.js +4 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +110 -73
- package/dist/solution/UnifiedBookingSales/index.js +3349 -971
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +133 -76
- package/dist/solution/UnifiedBookingSales/types.js +4 -9
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +16 -5
- package/lib/modules/Order/types.d.ts +5 -2
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +2 -1
- package/lib/modules/ResourcePlanner/index.d.ts +0 -22
- package/lib/modules/ResourcePlanner/index.js +0 -123
- package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/lib/modules/ResourcePlanner/localClock.js +270 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
- package/lib/modules/ResourcePlanner/planner.js +1903 -798
- package/lib/modules/ResourcePlanner/types.d.ts +346 -187
- package/lib/modules/ResourcePlanner/types.js +19 -0
- package/lib/solution/BaseSales/index.js +38 -22
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +110 -73
- package/lib/solution/UnifiedBookingSales/index.js +2289 -374
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +376 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +133 -76
- package/lib/solution/UnifiedBookingSales/types.js +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface LocalDateParts {
|
|
2
|
+
year: number;
|
|
3
|
+
month: number;
|
|
4
|
+
day: number;
|
|
5
|
+
}
|
|
6
|
+
export interface LocalDateTimeParts extends LocalDateParts {
|
|
7
|
+
hour: number;
|
|
8
|
+
minute: number;
|
|
9
|
+
second: number;
|
|
10
|
+
}
|
|
11
|
+
type LocalDateInput = string | LocalDateParts;
|
|
12
|
+
type LocalDateTimeInput = string | number | LocalDateTimeParts;
|
|
13
|
+
export declare function parseLocalDate(value: string): LocalDateParts;
|
|
14
|
+
export declare function parseLocalDateTime(value: string): LocalDateTimeParts;
|
|
15
|
+
export declare function extractFixedOffsetMinutes(value: string | null | undefined): number | null;
|
|
16
|
+
export declare function captureRuntimeOffsetMinutes(value?: Date): number;
|
|
17
|
+
export declare function formatFixedOffset(offsetMinutes: number | null | undefined): string;
|
|
18
|
+
export declare function localDateTimeToScalar(value: LocalDateTimeParts): number;
|
|
19
|
+
export declare function localDateToScalar(value: Date): number;
|
|
20
|
+
export declare function localDateToScalarStart(value: LocalDateInput): number;
|
|
21
|
+
export declare function scalarToLocalDateParts(value: number): LocalDateParts;
|
|
22
|
+
export declare function scalarToLocalDateTimeParts(value: number): LocalDateTimeParts;
|
|
23
|
+
export declare function dateOrdinalFromLocalDate(value: LocalDateInput): number;
|
|
24
|
+
export declare function weekdayFromLocalDate(value: LocalDateInput): number;
|
|
25
|
+
export declare function formatLocalDate(value: LocalDateInput | number): string;
|
|
26
|
+
export declare function formatLocalTime(value: LocalDateTimeInput, includeSeconds?: boolean): string;
|
|
27
|
+
export declare function formatLocalDateTime(value: LocalDateTimeInput, fixedOffsetMinutes?: number | null): string;
|
|
28
|
+
export declare function addLocalMinutes(value: number, minutes: number): number;
|
|
29
|
+
export declare function addLocalHours(value: number, hours: number): number;
|
|
30
|
+
export declare function addLocalCalendarDays(value: number, days: number): number;
|
|
31
|
+
export declare function nextDate(value: LocalDateInput): string;
|
|
32
|
+
export declare function ceilLocalScalarToTenMinutes(value: number): number;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var MINUTE_MS = 60 * 1000;
|
|
2
|
+
var HOUR_MS = 60 * MINUTE_MS;
|
|
3
|
+
function pad(value) {
|
|
4
|
+
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
5
|
+
return String(value).padStart(size, '0');
|
|
6
|
+
}
|
|
7
|
+
function isFiniteInteger(value) {
|
|
8
|
+
return Number.isInteger(value) && Number.isFinite(value);
|
|
9
|
+
}
|
|
10
|
+
function assertDateParts(parts) {
|
|
11
|
+
if (!isFiniteInteger(parts.year) || !isFiniteInteger(parts.month) || !isFiniteInteger(parts.day)) {
|
|
12
|
+
throw new Error('Invalid local date parts');
|
|
13
|
+
}
|
|
14
|
+
var probe = new Date(Date.UTC(parts.year, parts.month - 1, parts.day));
|
|
15
|
+
if (probe.getUTCFullYear() !== parts.year || probe.getUTCMonth() !== parts.month - 1 || probe.getUTCDate() !== parts.day) {
|
|
16
|
+
throw new Error('Invalid local date');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function assertTimeParts(parts) {
|
|
20
|
+
if (!isFiniteInteger(parts.hour) || !isFiniteInteger(parts.minute) || !isFiniteInteger(parts.second) || parts.hour < 0 || parts.hour > 23 || parts.minute < 0 || parts.minute > 59 || parts.second < 0 || parts.second > 59) {
|
|
21
|
+
throw new Error('Invalid local time');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function localDateInputToParts(value) {
|
|
25
|
+
if (typeof value !== 'string') {
|
|
26
|
+
assertDateParts(value);
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
return parseLocalDate(value);
|
|
30
|
+
}
|
|
31
|
+
function scalarToDate(value) {
|
|
32
|
+
if (!Number.isFinite(value)) {
|
|
33
|
+
throw new Error('Invalid local scalar');
|
|
34
|
+
}
|
|
35
|
+
return new Date(value);
|
|
36
|
+
}
|
|
37
|
+
export function parseLocalDate(value) {
|
|
38
|
+
var match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
|
39
|
+
if (!match) {
|
|
40
|
+
throw new Error("Invalid local date: ".concat(value));
|
|
41
|
+
}
|
|
42
|
+
var parts = {
|
|
43
|
+
year: Number(match[1]),
|
|
44
|
+
month: Number(match[2]),
|
|
45
|
+
day: Number(match[3])
|
|
46
|
+
};
|
|
47
|
+
assertDateParts(parts);
|
|
48
|
+
return parts;
|
|
49
|
+
}
|
|
50
|
+
export function parseLocalDateTime(value) {
|
|
51
|
+
var match = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d{1,9})?(?:[zZ]|[+-]\d{2}:\d{2})?$/.exec(value.trim());
|
|
52
|
+
if (!match) {
|
|
53
|
+
throw new Error("Invalid local datetime: ".concat(value));
|
|
54
|
+
}
|
|
55
|
+
var parts = {
|
|
56
|
+
year: Number(match[1]),
|
|
57
|
+
month: Number(match[2]),
|
|
58
|
+
day: Number(match[3]),
|
|
59
|
+
hour: Number(match[4]),
|
|
60
|
+
minute: Number(match[5]),
|
|
61
|
+
second: Number(match[6] || '0')
|
|
62
|
+
};
|
|
63
|
+
assertDateParts(parts);
|
|
64
|
+
assertTimeParts(parts);
|
|
65
|
+
return parts;
|
|
66
|
+
}
|
|
67
|
+
export function extractFixedOffsetMinutes(value) {
|
|
68
|
+
if (!value) return null;
|
|
69
|
+
var trimmed = value.trim();
|
|
70
|
+
if (trimmed.toUpperCase() === 'Z') return 0;
|
|
71
|
+
var directMatch = /^([+-])(\d{2}):(\d{2})$/.exec(trimmed);
|
|
72
|
+
var suffixMatch = /([zZ]|[+-]\d{2}:\d{2})$/.exec(trimmed);
|
|
73
|
+
var target = directMatch ? trimmed : suffixMatch === null || suffixMatch === void 0 ? void 0 : suffixMatch[1];
|
|
74
|
+
if (!target) return null;
|
|
75
|
+
if (target.toUpperCase() === 'Z') return 0;
|
|
76
|
+
var match = /^([+-])(\d{2}):(\d{2})$/.exec(target);
|
|
77
|
+
if (!match) return null;
|
|
78
|
+
var minutes = Number(match[2]) * 60 + Number(match[3]);
|
|
79
|
+
return match[1] === '-' ? -minutes : minutes;
|
|
80
|
+
}
|
|
81
|
+
export function captureRuntimeOffsetMinutes() {
|
|
82
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
|
|
83
|
+
return -value.getTimezoneOffset();
|
|
84
|
+
}
|
|
85
|
+
export function formatFixedOffset(offsetMinutes) {
|
|
86
|
+
if (offsetMinutes === null || offsetMinutes === undefined) return '';
|
|
87
|
+
if (!Number.isFinite(offsetMinutes)) {
|
|
88
|
+
throw new Error('Invalid fixed offset');
|
|
89
|
+
}
|
|
90
|
+
var normalized = Math.trunc(offsetMinutes);
|
|
91
|
+
if (normalized === 0) return 'Z';
|
|
92
|
+
var sign = normalized >= 0 ? '+' : '-';
|
|
93
|
+
var absolute = Math.abs(normalized);
|
|
94
|
+
return "".concat(sign).concat(pad(Math.floor(absolute / 60)), ":").concat(pad(absolute % 60));
|
|
95
|
+
}
|
|
96
|
+
export function localDateTimeToScalar(value) {
|
|
97
|
+
assertDateParts(value);
|
|
98
|
+
assertTimeParts(value);
|
|
99
|
+
return Date.UTC(value.year, value.month - 1, value.day, value.hour, value.minute, value.second, 0);
|
|
100
|
+
}
|
|
101
|
+
export function localDateToScalar(value) {
|
|
102
|
+
return Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds(), 0);
|
|
103
|
+
}
|
|
104
|
+
export function localDateToScalarStart(value) {
|
|
105
|
+
var parts = localDateInputToParts(value);
|
|
106
|
+
return Date.UTC(parts.year, parts.month - 1, parts.day, 0, 0, 0, 0);
|
|
107
|
+
}
|
|
108
|
+
export function scalarToLocalDateParts(value) {
|
|
109
|
+
var date = scalarToDate(value);
|
|
110
|
+
return {
|
|
111
|
+
year: date.getUTCFullYear(),
|
|
112
|
+
month: date.getUTCMonth() + 1,
|
|
113
|
+
day: date.getUTCDate()
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export function scalarToLocalDateTimeParts(value) {
|
|
117
|
+
var date = scalarToDate(value);
|
|
118
|
+
return {
|
|
119
|
+
year: date.getUTCFullYear(),
|
|
120
|
+
month: date.getUTCMonth() + 1,
|
|
121
|
+
day: date.getUTCDate(),
|
|
122
|
+
hour: date.getUTCHours(),
|
|
123
|
+
minute: date.getUTCMinutes(),
|
|
124
|
+
second: date.getUTCSeconds()
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export function dateOrdinalFromLocalDate(value) {
|
|
128
|
+
var parts = localDateInputToParts(value);
|
|
129
|
+
return Math.floor(Date.UTC(parts.year, parts.month - 1, parts.day) / (24 * HOUR_MS));
|
|
130
|
+
}
|
|
131
|
+
export function weekdayFromLocalDate(value) {
|
|
132
|
+
var parts = localDateInputToParts(value);
|
|
133
|
+
return new Date(Date.UTC(parts.year, parts.month - 1, parts.day)).getUTCDay();
|
|
134
|
+
}
|
|
135
|
+
export function formatLocalDate(value) {
|
|
136
|
+
var parts = typeof value === 'number' ? scalarToLocalDateParts(value) : localDateInputToParts(value);
|
|
137
|
+
return "".concat(pad(parts.year, 4), "-").concat(pad(parts.month), "-").concat(pad(parts.day));
|
|
138
|
+
}
|
|
139
|
+
export function formatLocalTime(value) {
|
|
140
|
+
var includeSeconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
141
|
+
var parts = typeof value === 'number' ? scalarToLocalDateTimeParts(value) : typeof value === 'string' ? parseLocalDateTime(value) : value;
|
|
142
|
+
assertTimeParts(parts);
|
|
143
|
+
if (!includeSeconds) {
|
|
144
|
+
return "".concat(pad(parts.hour), ":").concat(pad(parts.minute));
|
|
145
|
+
}
|
|
146
|
+
return "".concat(pad(parts.hour), ":").concat(pad(parts.minute), ":").concat(pad(parts.second));
|
|
147
|
+
}
|
|
148
|
+
export function formatLocalDateTime(value, fixedOffsetMinutes) {
|
|
149
|
+
var parts = typeof value === 'number' ? scalarToLocalDateTimeParts(value) : typeof value === 'string' ? parseLocalDateTime(value) : value;
|
|
150
|
+
assertDateParts(parts);
|
|
151
|
+
assertTimeParts(parts);
|
|
152
|
+
return "".concat(formatLocalDate(parts), "T").concat(formatLocalTime(parts)).concat(formatFixedOffset(fixedOffsetMinutes));
|
|
153
|
+
}
|
|
154
|
+
export function addLocalMinutes(value, minutes) {
|
|
155
|
+
if (!Number.isFinite(minutes)) {
|
|
156
|
+
throw new Error('Invalid minute delta');
|
|
157
|
+
}
|
|
158
|
+
return value + Math.trunc(minutes) * MINUTE_MS;
|
|
159
|
+
}
|
|
160
|
+
export function addLocalHours(value, hours) {
|
|
161
|
+
if (!Number.isFinite(hours)) {
|
|
162
|
+
throw new Error('Invalid hour delta');
|
|
163
|
+
}
|
|
164
|
+
return value + Math.trunc(hours) * HOUR_MS;
|
|
165
|
+
}
|
|
166
|
+
export function addLocalCalendarDays(value, days) {
|
|
167
|
+
if (!Number.isFinite(days)) {
|
|
168
|
+
throw new Error('Invalid day delta');
|
|
169
|
+
}
|
|
170
|
+
var parts = scalarToLocalDateTimeParts(value);
|
|
171
|
+
return Date.UTC(parts.year, parts.month - 1, parts.day + Math.trunc(days), parts.hour, parts.minute, parts.second, 0);
|
|
172
|
+
}
|
|
173
|
+
export function nextDate(value) {
|
|
174
|
+
return formatLocalDate(addLocalCalendarDays(localDateToScalarStart(value), 1));
|
|
175
|
+
}
|
|
176
|
+
export function ceilLocalScalarToTenMinutes(value) {
|
|
177
|
+
var parts = scalarToLocalDateTimeParts(value);
|
|
178
|
+
var minuteRemainder = parts.minute % 10;
|
|
179
|
+
if (minuteRemainder === 0 && parts.second === 0) return value;
|
|
180
|
+
var deltaMinutes = parts.second === 0 ? 10 - minuteRemainder : minuteRemainder === 0 ? 10 : 10 - minuteRemainder;
|
|
181
|
+
var roundedBase = Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, 0, 0);
|
|
182
|
+
return addLocalMinutes(roundedBase, deltaMinutes);
|
|
183
|
+
}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function evaluateResourceForInterval(params: {
|
|
7
|
-
resource: ResourcePlannerResource;
|
|
8
|
-
interval: ResourcePlannerDemandInterval;
|
|
9
|
-
context: Required<ResourcePlannerContextInput>;
|
|
10
|
-
}): ResourcePlannerAvailabilityCell;
|
|
11
|
-
export declare function queryPlannerAvailability(contextInput: ResourcePlannerContextInput, query?: ResourcePlannerQuery): ResourcePlannerProjection;
|
|
12
|
-
export declare function resolveAssignableSlots(contextInput: ResourcePlannerContextInput, query?: ResourcePlannerQuery): ResourcePlannerAssignableSlotResult;
|
|
13
|
-
export declare function autoAssignResources(contextInput: ResourcePlannerContextInput, query?: ResourcePlannerQuery): ResourcePlannerAssignmentResult;
|
|
14
|
-
export declare function validateAssignments(contextInput: ResourcePlannerContextInput, selection: ResourcePlannerSelection): ResourcePlannerValidationResult;
|
|
1
|
+
import type { AvailabilityProjection, AvailabilityProjectionInput, AvailabilityQuery, AvailabilityQueryResult, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, GetProductTimeRangesRequest, ProductTimeRangeGroup } from './types';
|
|
2
|
+
export declare function createAvailabilityProjection(input: AvailabilityProjectionInput): AvailabilityProjection;
|
|
3
|
+
export declare function getProductTimeRanges(projection: AvailabilityProjection, request?: GetProductTimeRangesRequest): ProductTimeRangeGroup[];
|
|
4
|
+
export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery): AvailabilityQueryResult;
|
|
5
|
+
export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams): AvailabilitySelectionValidationResult;
|