hierarchical-approval 4.1.2 → 4.1.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/CHANGELOG.md +22 -0
- package/dist/index.cjs +24 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -4
- package/dist/index.js.map +1 -1
- package/dist/nestjs.cjs +13 -2
- package/dist/nestjs.cjs.map +1 -1
- package/dist/nestjs.js +13 -2
- package/dist/nestjs.js.map +1 -1
- package/dist/plugins/scheduler.cjs +26 -2
- package/dist/plugins/scheduler.cjs.map +1 -1
- package/dist/plugins/scheduler.js +26 -2
- package/dist/plugins/scheduler.js.map +1 -1
- package/dist/testing.cjs +13 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +13 -2
- package/dist/testing.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -428,11 +428,11 @@ var EventBus = class {
|
|
|
428
428
|
const result = listener(args[0]);
|
|
429
429
|
if (typeof result?.then === "function") {
|
|
430
430
|
void Promise.resolve(result).catch((err) => {
|
|
431
|
-
this.
|
|
431
|
+
this.report(err, event);
|
|
432
432
|
});
|
|
433
433
|
}
|
|
434
434
|
} catch (err) {
|
|
435
|
-
this.
|
|
435
|
+
this.report(err, event);
|
|
436
436
|
} finally {
|
|
437
437
|
if (once) this.forget(event, listener, wrapped);
|
|
438
438
|
}
|
|
@@ -450,6 +450,17 @@ var EventBus = class {
|
|
|
450
450
|
perListener.push(wrapped);
|
|
451
451
|
return wrapped;
|
|
452
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Hands a listener failure to the configured handler. A throwing handler is
|
|
455
|
+
* swallowed: it would otherwise escape `emit()` and skip the remaining listeners,
|
|
456
|
+
* defeating the isolation this bus promises.
|
|
457
|
+
*/
|
|
458
|
+
report(error, event) {
|
|
459
|
+
try {
|
|
460
|
+
this.onListenerError?.(error, event);
|
|
461
|
+
} catch {
|
|
462
|
+
}
|
|
463
|
+
}
|
|
453
464
|
/** Drop the bookkeeping for one specific wrapper, identified by reference. */
|
|
454
465
|
forget(event, listener, wrapped) {
|
|
455
466
|
const perEvent = this.wrappers.get(event);
|
|
@@ -5208,6 +5219,10 @@ function parseOrThrow(fn) {
|
|
|
5208
5219
|
// src/utils/BusinessCalendar.ts
|
|
5209
5220
|
var DAY_MS = 864e5;
|
|
5210
5221
|
var MAX_SCAN_DAYS = 3660;
|
|
5222
|
+
var MAX_BUSINESS_DAYS = 36600;
|
|
5223
|
+
function describeDate(d) {
|
|
5224
|
+
return Number.isNaN(d.getTime()) ? "Invalid Date" : d.toISOString();
|
|
5225
|
+
}
|
|
5211
5226
|
function dayKey(d) {
|
|
5212
5227
|
const y = d.getFullYear();
|
|
5213
5228
|
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
@@ -5221,6 +5236,11 @@ function weekendCalendar(options = {}) {
|
|
|
5221
5236
|
return {
|
|
5222
5237
|
addBusinessDays(from, days) {
|
|
5223
5238
|
if (days <= 0 || Number.isNaN(days)) return new Date(from.getTime());
|
|
5239
|
+
if (days > MAX_BUSINESS_DAYS) {
|
|
5240
|
+
throw new ApprovalValidationError(
|
|
5241
|
+
`weekendCalendar: cannot add ${days} business days to ${describeDate(from)} \u2014 days must be at most ${MAX_BUSINESS_DAYS}.`
|
|
5242
|
+
);
|
|
5243
|
+
}
|
|
5224
5244
|
const whole = Math.floor(days);
|
|
5225
5245
|
const fraction = days - whole;
|
|
5226
5246
|
const cursor = new Date(from.getTime());
|
|
@@ -5235,7 +5255,7 @@ function weekendCalendar(options = {}) {
|
|
|
5235
5255
|
}
|
|
5236
5256
|
if (++idleDays >= MAX_SCAN_DAYS) {
|
|
5237
5257
|
throw new ApprovalValidationError(
|
|
5238
|
-
`weekendCalendar: no business day found within 10 years of ${from
|
|
5258
|
+
`weekendCalendar: no business day found within 10 years of ${describeDate(from)} \u2014 check weekendDays and holidays.`
|
|
5239
5259
|
);
|
|
5240
5260
|
}
|
|
5241
5261
|
}
|
|
@@ -5282,7 +5302,7 @@ function businessHoursCalendar(options = {}) {
|
|
|
5282
5302
|
return cursor;
|
|
5283
5303
|
}
|
|
5284
5304
|
throw new ApprovalValidationError(
|
|
5285
|
-
`businessHoursCalendar: no working day found within 10 years of ${from
|
|
5305
|
+
`businessHoursCalendar: no working day found within 10 years of ${describeDate(from)} \u2014 check weekendDays and holidays.`
|
|
5286
5306
|
);
|
|
5287
5307
|
};
|
|
5288
5308
|
const base = weekendCalendar(options);
|