@final-commerce/common 2.4.0-staging.2 → 2.4.0
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.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +4 -0
- package/dist/pos-types/index.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3248,11 +3248,19 @@ function shopDayKey(instant, timeZone) {
|
|
|
3248
3248
|
return `${year}-${pad(month)}-${pad(day)}`;
|
|
3249
3249
|
}
|
|
3250
3250
|
function shopDayRange(fromDayKey, count, timeZone) {
|
|
3251
|
-
const
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3251
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(fromDayKey ?? "");
|
|
3252
|
+
if (!match) {
|
|
3253
|
+
throw new BookingRulesError(`Booking rules: "${fromDayKey}" is not a shop day (YYYY-MM-DD)`);
|
|
3254
|
+
}
|
|
3255
|
+
if (!Number.isInteger(count) || count < 1) {
|
|
3256
|
+
throw new BookingRulesError(`Booking rules: "${count}" is not a number of days`);
|
|
3257
|
+
}
|
|
3258
|
+
const [, year, month, day] = match.map(Number);
|
|
3259
|
+
const from = instantFromLocal(year, month, day, 0, timeZone);
|
|
3260
|
+
if (shopDayKey(from, timeZone) !== fromDayKey) {
|
|
3261
|
+
throw new BookingRulesError(`Booking rules: "${fromDayKey}" is not a real day`);
|
|
3262
|
+
}
|
|
3263
|
+
return { from, to: instantFromLocal(year, month, day + count, 0, timeZone) };
|
|
3256
3264
|
}
|
|
3257
3265
|
function buildAvailability({
|
|
3258
3266
|
productId,
|