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/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.onListenerError?.(err, event);
431
+ this.report(err, event);
432
432
  });
433
433
  }
434
434
  } catch (err) {
435
- this.onListenerError?.(err, event);
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,7 @@ 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;
5211
5223
  function dayKey(d) {
5212
5224
  const y = d.getFullYear();
5213
5225
  const m = String(d.getMonth() + 1).padStart(2, "0");
@@ -5221,6 +5233,11 @@ function weekendCalendar(options = {}) {
5221
5233
  return {
5222
5234
  addBusinessDays(from, days) {
5223
5235
  if (days <= 0 || Number.isNaN(days)) return new Date(from.getTime());
5236
+ if (days > MAX_BUSINESS_DAYS) {
5237
+ throw new ApprovalValidationError(
5238
+ `weekendCalendar: cannot add ${days} business days to ${from.toISOString()} \u2014 days must be at most ${MAX_BUSINESS_DAYS}.`
5239
+ );
5240
+ }
5224
5241
  const whole = Math.floor(days);
5225
5242
  const fraction = days - whole;
5226
5243
  const cursor = new Date(from.getTime());