@final-commerce/common 2.4.0-preprod.2 → 2.4.0-preprod.3
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/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3057,11 +3057,19 @@ function shopDayKey(instant, timeZone) {
|
|
|
3057
3057
|
return `${year}-${pad(month)}-${pad(day)}`;
|
|
3058
3058
|
}
|
|
3059
3059
|
function shopDayRange(fromDayKey, count, timeZone) {
|
|
3060
|
-
const
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3060
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(fromDayKey ?? "");
|
|
3061
|
+
if (!match) {
|
|
3062
|
+
throw new BookingRulesError(`Booking rules: "${fromDayKey}" is not a shop day (YYYY-MM-DD)`);
|
|
3063
|
+
}
|
|
3064
|
+
if (!Number.isInteger(count) || count < 1) {
|
|
3065
|
+
throw new BookingRulesError(`Booking rules: "${count}" is not a number of days`);
|
|
3066
|
+
}
|
|
3067
|
+
const [, year, month, day] = match.map(Number);
|
|
3068
|
+
const from = instantFromLocal(year, month, day, 0, timeZone);
|
|
3069
|
+
if (shopDayKey(from, timeZone) !== fromDayKey) {
|
|
3070
|
+
throw new BookingRulesError(`Booking rules: "${fromDayKey}" is not a real day`);
|
|
3071
|
+
}
|
|
3072
|
+
return { from, to: instantFromLocal(year, month, day + count, 0, timeZone) };
|
|
3065
3073
|
}
|
|
3066
3074
|
function buildAvailability({
|
|
3067
3075
|
productId,
|