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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,28 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.1.4] - 2026-11-01
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `InMemorySchedulerAdapter.scheduleAt` now rejects after `shutdown()` with an `ApprovalError`
|
|
13
|
+
(code `SCHEDULER_SHUTDOWN`) instead of a plain `Error`; the message is unchanged.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `weekendCalendar` and `businessHoursCalendar` now report an invalid start date as `Invalid Date`
|
|
18
|
+
in their `ApprovalValidationError` messages instead of failing with a bare `RangeError`.
|
|
19
|
+
|
|
20
|
+
## [4.1.3] - 2026-10-28
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- `weekendCalendar().addBusinessDays()` now throws an `ApprovalValidationError` for an infinite
|
|
25
|
+
day count, or a count above 36,600, instead of spinning forever.
|
|
26
|
+
- An `engine.on()` error handler that itself throws no longer aborts `emit()` or skips the
|
|
27
|
+
remaining listeners; the failure is dropped instead of escaping the operation that emitted
|
|
28
|
+
the event.
|
|
29
|
+
|
|
8
30
|
## [4.1.2] - 2026-10-24
|
|
9
31
|
|
|
10
32
|
### Fixed
|
package/dist/index.cjs
CHANGED
|
@@ -434,11 +434,11 @@ var EventBus = class {
|
|
|
434
434
|
const result = listener(args[0]);
|
|
435
435
|
if (typeof result?.then === "function") {
|
|
436
436
|
void Promise.resolve(result).catch((err) => {
|
|
437
|
-
this.
|
|
437
|
+
this.report(err, event);
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
440
|
} catch (err) {
|
|
441
|
-
this.
|
|
441
|
+
this.report(err, event);
|
|
442
442
|
} finally {
|
|
443
443
|
if (once) this.forget(event, listener, wrapped);
|
|
444
444
|
}
|
|
@@ -456,6 +456,17 @@ var EventBus = class {
|
|
|
456
456
|
perListener.push(wrapped);
|
|
457
457
|
return wrapped;
|
|
458
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Hands a listener failure to the configured handler. A throwing handler is
|
|
461
|
+
* swallowed: it would otherwise escape `emit()` and skip the remaining listeners,
|
|
462
|
+
* defeating the isolation this bus promises.
|
|
463
|
+
*/
|
|
464
|
+
report(error, event) {
|
|
465
|
+
try {
|
|
466
|
+
this.onListenerError?.(error, event);
|
|
467
|
+
} catch {
|
|
468
|
+
}
|
|
469
|
+
}
|
|
459
470
|
/** Drop the bookkeeping for one specific wrapper, identified by reference. */
|
|
460
471
|
forget(event, listener, wrapped) {
|
|
461
472
|
const perEvent = this.wrappers.get(event);
|
|
@@ -5214,6 +5225,10 @@ function parseOrThrow(fn) {
|
|
|
5214
5225
|
// src/utils/BusinessCalendar.ts
|
|
5215
5226
|
var DAY_MS = 864e5;
|
|
5216
5227
|
var MAX_SCAN_DAYS = 3660;
|
|
5228
|
+
var MAX_BUSINESS_DAYS = 36600;
|
|
5229
|
+
function describeDate(d) {
|
|
5230
|
+
return Number.isNaN(d.getTime()) ? "Invalid Date" : d.toISOString();
|
|
5231
|
+
}
|
|
5217
5232
|
function dayKey(d) {
|
|
5218
5233
|
const y = d.getFullYear();
|
|
5219
5234
|
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
@@ -5227,6 +5242,11 @@ function weekendCalendar(options = {}) {
|
|
|
5227
5242
|
return {
|
|
5228
5243
|
addBusinessDays(from, days) {
|
|
5229
5244
|
if (days <= 0 || Number.isNaN(days)) return new Date(from.getTime());
|
|
5245
|
+
if (days > MAX_BUSINESS_DAYS) {
|
|
5246
|
+
throw new ApprovalValidationError(
|
|
5247
|
+
`weekendCalendar: cannot add ${days} business days to ${describeDate(from)} \u2014 days must be at most ${MAX_BUSINESS_DAYS}.`
|
|
5248
|
+
);
|
|
5249
|
+
}
|
|
5230
5250
|
const whole = Math.floor(days);
|
|
5231
5251
|
const fraction = days - whole;
|
|
5232
5252
|
const cursor = new Date(from.getTime());
|
|
@@ -5241,7 +5261,7 @@ function weekendCalendar(options = {}) {
|
|
|
5241
5261
|
}
|
|
5242
5262
|
if (++idleDays >= MAX_SCAN_DAYS) {
|
|
5243
5263
|
throw new ApprovalValidationError(
|
|
5244
|
-
`weekendCalendar: no business day found within 10 years of ${from
|
|
5264
|
+
`weekendCalendar: no business day found within 10 years of ${describeDate(from)} \u2014 check weekendDays and holidays.`
|
|
5245
5265
|
);
|
|
5246
5266
|
}
|
|
5247
5267
|
}
|
|
@@ -5288,7 +5308,7 @@ function businessHoursCalendar(options = {}) {
|
|
|
5288
5308
|
return cursor;
|
|
5289
5309
|
}
|
|
5290
5310
|
throw new ApprovalValidationError(
|
|
5291
|
-
`businessHoursCalendar: no working day found within 10 years of ${from
|
|
5311
|
+
`businessHoursCalendar: no working day found within 10 years of ${describeDate(from)} \u2014 check weekendDays and holidays.`
|
|
5292
5312
|
);
|
|
5293
5313
|
};
|
|
5294
5314
|
const base = weekendCalendar(options);
|