@final-commerce/common 2.12.0-staging.3 → 2.12.0-staging.4
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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3921,14 +3921,30 @@ function wholePeriodsIn(ratePeriod, timeZone, startAt, endAt, days) {
|
|
|
3921
3921
|
return months;
|
|
3922
3922
|
}
|
|
3923
3923
|
function courseSessions(rule, timeZone) {
|
|
3924
|
-
const
|
|
3925
|
-
|
|
3926
|
-
const sessions = sessionCells(rule, timeZone, new Date(bookableFrom), new Date(bookableTo)).sort(
|
|
3927
|
-
(first, second) => +first.startAt - +second.startAt
|
|
3928
|
-
);
|
|
3924
|
+
const [from, to] = rule.sessions?.weekly?.length ? weeklyCourseRange(rule) : datesCourseRange(rule.sessions?.dates ?? [], timeZone);
|
|
3925
|
+
const sessions = sessionCells(rule, timeZone, from, to).sort((first, second) => +first.startAt - +second.startAt);
|
|
3929
3926
|
if (sessions.length === 0) throw new BookingRulesError("These course dates hold no session");
|
|
3930
3927
|
return sessions;
|
|
3931
3928
|
}
|
|
3929
|
+
function courseSpan(rule, timeZone) {
|
|
3930
|
+
const sessions = courseSessions(rule, timeZone);
|
|
3931
|
+
return { from: sessions[0].startAt, to: sessions[sessions.length - 1].bufferEndAt };
|
|
3932
|
+
}
|
|
3933
|
+
function weeklyCourseRange(rule) {
|
|
3934
|
+
const { bookableFrom, bookableTo } = rule.window;
|
|
3935
|
+
if (!bookableFrom || !bookableTo) throw new BookingRulesError("A course needs both course dates");
|
|
3936
|
+
return [new Date(bookableFrom), new Date(bookableTo)];
|
|
3937
|
+
}
|
|
3938
|
+
function datesCourseRange(dates, timeZone) {
|
|
3939
|
+
if (dates.length === 0) throw new BookingRulesError("A course needs its sessions");
|
|
3940
|
+
const days = dates.map(({ date }) => date).sort();
|
|
3941
|
+
const [firstYear, firstMonth, firstDay] = calendarDate(days[0]);
|
|
3942
|
+
const [lastYear, lastMonth, lastDay] = calendarDate(days[days.length - 1]);
|
|
3943
|
+
return [
|
|
3944
|
+
instantFromLocal(firstYear, firstMonth, firstDay, 0, timeZone),
|
|
3945
|
+
instantFromLocal(lastYear, lastMonth, lastDay + 1, 0, timeZone)
|
|
3946
|
+
];
|
|
3947
|
+
}
|
|
3932
3948
|
var courseStarted = (rule, sessions, now) => sessions[0].startAt.getTime() < now.getTime() + (rule.window.minNoticeMinutes ?? 0) * 6e4;
|
|
3933
3949
|
function courseStartedInZone(rule, sessions, now, timeZone) {
|
|
3934
3950
|
const { minNotice } = ruleDurationsOf(rule);
|
|
@@ -5026,6 +5042,7 @@ export {
|
|
|
5026
5042
|
conditionSummary,
|
|
5027
5043
|
convertFixedFeeToLocalCurrency,
|
|
5028
5044
|
courseSessions,
|
|
5045
|
+
courseSpan,
|
|
5029
5046
|
courseStarted,
|
|
5030
5047
|
courseStartedInZone,
|
|
5031
5048
|
createAmount,
|