@adobe/spacecat-shared-utils 1.76.0 → 1.77.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 +14 -0
- package/package.json +1 -1
- package/src/calendar-week-helper.js +34 -1
- package/src/log-wrapper.js +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.77.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.77.0...@adobe/spacecat-shared-utils-v1.77.1) (2025-11-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **utils:** correct logWrapper format string handling ([#1156](https://github.com/adobe/spacecat-shared/issues/1156)) ([dabe38c](https://github.com/adobe/spacecat-shared/commit/dabe38c258b2a221c6733165657e856d978e5636))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-utils-v1.77.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.76.0...@adobe/spacecat-shared-utils-v1.77.0) (2025-11-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* utils function getTemporalCondition extended ([#1155](https://github.com/adobe/spacecat-shared/issues/1155)) ([aad2d1c](https://github.com/adobe/spacecat-shared/commit/aad2d1c7229e98c7e45f07a541c81c1d4cf7c0c4))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-utils-v1.76.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.75.0...@adobe/spacecat-shared-utils-v1.76.0) (2025-11-20)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -202,10 +202,43 @@ export function getMonthInfo(inputMonth = null, inputYear = null) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// --- Public: Main decision function ---
|
|
205
|
-
export function getTemporalCondition({
|
|
205
|
+
export function getTemporalCondition({
|
|
206
|
+
week,
|
|
207
|
+
month,
|
|
208
|
+
year,
|
|
209
|
+
numSeries = 1,
|
|
210
|
+
} = {}) {
|
|
206
211
|
const hasWeek = Number.isInteger(week) && Number.isInteger(year);
|
|
207
212
|
const hasMonth = Number.isInteger(month) && Number.isInteger(year);
|
|
208
213
|
|
|
214
|
+
if (numSeries > 1) {
|
|
215
|
+
if (!hasWeek && !hasMonth) {
|
|
216
|
+
throw new Error('Missing required parameters: week or month');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const conditions = [];
|
|
220
|
+
for (let i = 0; i < numSeries; i += 1) {
|
|
221
|
+
if (hasWeek) {
|
|
222
|
+
let currentWeek = week - i;
|
|
223
|
+
let currentYear = year;
|
|
224
|
+
if (currentWeek < 1) {
|
|
225
|
+
currentWeek = has53CalendarWeeks(currentYear) ? 53 : 52;
|
|
226
|
+
currentYear -= 1;
|
|
227
|
+
}
|
|
228
|
+
conditions.push(getWeekInfo(currentWeek, currentYear).temporalCondition);
|
|
229
|
+
} else if (hasMonth) {
|
|
230
|
+
let currentMonth = month - i;
|
|
231
|
+
let currentYear = year;
|
|
232
|
+
if (currentMonth < 1) {
|
|
233
|
+
currentMonth = 12;
|
|
234
|
+
currentYear -= 1;
|
|
235
|
+
}
|
|
236
|
+
conditions.push(getMonthInfo(currentMonth, currentYear).temporalCondition);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return conditions.join(' OR ');
|
|
240
|
+
}
|
|
241
|
+
|
|
209
242
|
if (hasWeek && isValidWeek(week, year)) {
|
|
210
243
|
return getWeekInfo(week, year).temporalCondition;
|
|
211
244
|
}
|
package/src/log-wrapper.js
CHANGED
|
@@ -59,7 +59,14 @@ export function logWrapper(fn) {
|
|
|
59
59
|
// Enhance context.log directly to include markers in all log statements
|
|
60
60
|
context.log = logLevels.reduce((accumulator, level) => {
|
|
61
61
|
if (typeof log[level] === 'function') {
|
|
62
|
-
accumulator[level] = (...args) =>
|
|
62
|
+
accumulator[level] = (...args) => {
|
|
63
|
+
// If first argument is a string (format string), prepend the marker to it
|
|
64
|
+
if (args.length > 0 && typeof args[0] === 'string') {
|
|
65
|
+
const enhancedArgs = [`${markerString} ${args[0]}`, ...args.slice(1)];
|
|
66
|
+
return log[level](...enhancedArgs);
|
|
67
|
+
}
|
|
68
|
+
return log[level](...args);
|
|
69
|
+
};
|
|
63
70
|
}
|
|
64
71
|
return accumulator;
|
|
65
72
|
}, {});
|