hierarchical-approval 4.1.2 → 4.1.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/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.1.3] - 2026-10-28
9
+
10
+ ### Fixed
11
+
12
+ - `weekendCalendar().addBusinessDays()` now throws an `ApprovalValidationError` for an infinite
13
+ day count, or a count above 36,600, instead of spinning forever.
14
+ - An `engine.on()` error handler that itself throws no longer aborts `emit()` or skips the
15
+ remaining listeners; the failure is dropped instead of escaping the operation that emitted
16
+ the event.
17
+
8
18
  ## [4.1.2] - 2026-10-24
9
19
 
10
20
  ### 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.onListenerError?.(err, event);
437
+ this.report(err, event);
438
438
  });
439
439
  }
440
440
  } catch (err) {
441
- this.onListenerError?.(err, event);
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,7 @@ 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;
5217
5229
  function dayKey(d) {
5218
5230
  const y = d.getFullYear();
5219
5231
  const m = String(d.getMonth() + 1).padStart(2, "0");
@@ -5227,6 +5239,11 @@ function weekendCalendar(options = {}) {
5227
5239
  return {
5228
5240
  addBusinessDays(from, days) {
5229
5241
  if (days <= 0 || Number.isNaN(days)) return new Date(from.getTime());
5242
+ if (days > MAX_BUSINESS_DAYS) {
5243
+ throw new ApprovalValidationError(
5244
+ `weekendCalendar: cannot add ${days} business days to ${from.toISOString()} \u2014 days must be at most ${MAX_BUSINESS_DAYS}.`
5245
+ );
5246
+ }
5230
5247
  const whole = Math.floor(days);
5231
5248
  const fraction = days - whole;
5232
5249
  const cursor = new Date(from.getTime());