@adobe/spacecat-shared-utils 1.82.0 → 1.82.1
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/calendar-week-helper.js +16 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.82.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.82.0...@adobe/spacecat-shared-utils-v1.82.1) (2025-12-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* 0 week valid month on numSeries ([#1220](https://github.com/adobe/spacecat-shared/issues/1220)) ([7670da9](https://github.com/adobe/spacecat-shared/commit/7670da9691b2623aa149b1b07c36c97585112ca7))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-utils-v1.82.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.81.1...@adobe/spacecat-shared-utils-v1.82.0) (2025-12-03)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -208,17 +208,17 @@ export function getTemporalCondition({
|
|
|
208
208
|
year,
|
|
209
209
|
numSeries = 1,
|
|
210
210
|
} = {}) {
|
|
211
|
-
const
|
|
212
|
-
const
|
|
211
|
+
const hasValidWeek = isValidWeek(week, year);
|
|
212
|
+
const hasValidMonth = isValidMonth(month, year);
|
|
213
213
|
|
|
214
214
|
if (numSeries > 1) {
|
|
215
|
-
if (!
|
|
215
|
+
if (!hasValidWeek && !hasValidMonth) {
|
|
216
216
|
throw new Error('Missing required parameters: week or month');
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
const conditions = [];
|
|
220
220
|
for (let i = 0; i < numSeries; i += 1) {
|
|
221
|
-
if (
|
|
221
|
+
if (hasValidWeek) {
|
|
222
222
|
let currentWeek = week - i;
|
|
223
223
|
let currentYear = year;
|
|
224
224
|
if (currentWeek < 1) {
|
|
@@ -226,7 +226,7 @@ export function getTemporalCondition({
|
|
|
226
226
|
currentYear -= 1;
|
|
227
227
|
}
|
|
228
228
|
conditions.push(getWeekInfo(currentWeek, currentYear).temporalCondition);
|
|
229
|
-
} else if (
|
|
229
|
+
} else if (hasValidMonth) {
|
|
230
230
|
let currentMonth = month - i;
|
|
231
231
|
let currentYear = year;
|
|
232
232
|
if (currentMonth < 1) {
|
|
@@ -239,22 +239,27 @@ export function getTemporalCondition({
|
|
|
239
239
|
return conditions.join(' OR ');
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
if (
|
|
242
|
+
if (hasValidWeek) {
|
|
243
243
|
return getWeekInfo(week, year).temporalCondition;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
if (
|
|
246
|
+
if (hasValidMonth) {
|
|
247
247
|
return getMonthInfo(month, year).temporalCondition;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// Fallbacks
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
// If week was provided (even if invalid), default to last full week
|
|
252
|
+
if (Number.isInteger(week)) {
|
|
253
253
|
return getWeekInfo().temporalCondition;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
//
|
|
257
|
-
|
|
256
|
+
// If month was provided (even if invalid), default to last full month
|
|
257
|
+
if (Number.isInteger(month)) {
|
|
258
|
+
return getMonthInfo().temporalCondition;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// If neither was provided, default to last full week
|
|
262
|
+
return getWeekInfo().temporalCondition;
|
|
258
263
|
}
|
|
259
264
|
|
|
260
265
|
// Note: This function binds week exclusively to one year
|