@cadenza.io/core 3.19.2 → 3.19.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/dist/index.d.mts CHANGED
@@ -335,13 +335,14 @@ type SchemaDefinition = {
335
335
  type: SchemaType;
336
336
  required?: string[];
337
337
  properties?: {
338
- [key: string]: SchemaDefinition;
338
+ [key: string]: Schema;
339
339
  };
340
- items?: SchemaDefinition;
340
+ items?: Schema;
341
341
  constraints?: SchemaConstraints;
342
342
  description?: string;
343
343
  strict?: boolean;
344
344
  };
345
+ type Schema = SchemaDefinition | SchemaDefinition[];
345
346
 
346
347
  interface Intent {
347
348
  name: string;
@@ -848,9 +849,9 @@ declare class Task extends SignalEmitter implements Graph {
848
849
  readonly isDeputy: boolean;
849
850
  readonly isEphemeral: boolean;
850
851
  readonly isDebounce: boolean;
851
- inputContextSchema: SchemaDefinition;
852
+ inputContextSchema: Schema;
852
853
  validateInputContext: boolean;
853
- outputContextSchema: SchemaDefinition;
854
+ outputContextSchema: Schema;
854
855
  validateOutputContext: boolean;
855
856
  readonly retryCount: number;
856
857
  readonly retryDelay: number;
@@ -886,16 +887,16 @@ declare class Task extends SignalEmitter implements Graph {
886
887
  * @param {boolean} [isSubMeta=false] - Indicates if the task is a sub-meta-task.
887
888
  * @param {boolean} [isHidden=false] - Determines if the task is hidden and not exposed publicly.
888
889
  * @param {ThrottleTagGetter} [getTagCallback=undefined] - A callback to generate a throttle tag for the task.
889
- * @param {SchemaDefinition} [inputSchema=undefined] - The input schema for validating the task's input context.
890
+ * @param {Schema} [inputSchema=undefined] - The input schema for validating the task's input context.
890
891
  * @param {boolean} [validateInputContext=false] - Specifies if the input context should be validated against the input schema.
891
- * @param {SchemaDefinition} [outputSchema=undefined] - The output schema for validating the task's output context.
892
+ * @param {Schema} [outputSchema=undefined] - The output schema for validating the task's output context.
892
893
  * @param {boolean} [validateOutputContext=false] - Specifies if the output context should be validated against the output schema.
893
894
  * @param {number} [retryCount=0] - The number of retry attempts allowed for the task in case of failure.
894
895
  * @param {number} [retryDelay=0] - The initial delay (in milliseconds) between retry attempts.
895
896
  * @param {number} [retryDelayMax=0] - The maximum delay (in milliseconds) allowed between retries.
896
897
  * @param {number} [retryDelayFactor=1] - The factor by which the retry delay increases after each attempt.
897
898
  */
898
- constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition, validateInputContext?: boolean, outputSchema?: SchemaDefinition, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
899
+ constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: Schema, validateInputContext?: boolean, outputSchema?: Schema, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
899
900
  clone(traverse?: boolean, includeSignals?: boolean): Task;
900
901
  /**
901
902
  * Retrieves the tag associated with the instance.
@@ -909,8 +910,8 @@ declare class Task extends SignalEmitter implements Graph {
909
910
  setTimeout(timeout: number): void;
910
911
  setConcurrency(concurrency: number): void;
911
912
  setProgressWeight(weight: number): void;
912
- setInputContextSchema(schema: SchemaDefinition): void;
913
- setOutputContextSchema(schema: SchemaDefinition): void;
913
+ setInputContextSchema(schema: Schema): void;
914
+ setOutputContextSchema(schema: Schema): void;
914
915
  setValidateInputContext(value: boolean): void;
915
916
  setValidateOutputContext(value: boolean): void;
916
917
  /**
@@ -937,15 +938,16 @@ declare class Task extends SignalEmitter implements Graph {
937
938
  * Validates a data object against a specified schema definition and returns validation results.
938
939
  *
939
940
  * @param {any} data - The target object to validate against the schema.
940
- * @param {SchemaDefinition | undefined} schema - The schema definition describing the expected structure and constraints of the data.
941
+ * @param {Schema | undefined} schema - The schema definition describing the expected structure and constraints of the data.
941
942
  * @param {string} [path="context"] - The base path or context for traversing the data, used in generating error messages.
942
943
  * @return {{ valid: boolean, errors: Record<string, string> }} - An object containing a validity flag (`valid`)
943
944
  * and a map (`errors`) of validation error messages keyed by property paths.
944
945
  */
945
- validateSchema(data: any, schema: SchemaDefinition | undefined, path?: string): {
946
+ validateSchema(data: any, schema: Schema | undefined, path?: string): {
946
947
  valid: boolean;
947
948
  errors: Record<string, string>;
948
949
  };
950
+ validateProp(prop: SchemaDefinition, key: string, value?: any, path?: string): Record<string, string>;
949
951
  /**
950
952
  * Validates the input context against the predefined schema and emits metadata if validation fails.
951
953
  *
@@ -1504,6 +1506,7 @@ declare class SignalBroker {
1504
1506
  private isStrategyFlushing;
1505
1507
  private readonly defaultStrategyName;
1506
1508
  constructor();
1509
+ logMemoryFootprint(label?: string): void;
1507
1510
  /**
1508
1511
  * Validates the provided signal name string to ensure it adheres to specific formatting rules.
1509
1512
  * Throws an error if any of the validation checks fail.
@@ -1685,7 +1688,7 @@ declare class DebounceTask extends Task {
1685
1688
  lastProgressCallback: ((progress: number) => void) | null;
1686
1689
  lastEmitFunction: ((signal: string, context: any) => void) | null;
1687
1690
  lastInquireFunction: ((inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>) | null;
1688
- constructor(name: string, task: TaskFunction, description?: string, debounceTime?: number, leading?: boolean, trailing?: boolean, maxWait?: number, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, inputSchema?: SchemaDefinition | undefined, validateInputSchema?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputSchema?: boolean);
1691
+ constructor(name: string, task: TaskFunction, description?: string, debounceTime?: number, leading?: boolean, trailing?: boolean, maxWait?: number, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, inputSchema?: Schema | undefined, validateInputSchema?: boolean, outputSchema?: Schema | undefined, validateOutputSchema?: boolean);
1689
1692
  /**
1690
1693
  * Executes the taskFunction with the provided context, emit function, and progress callback.
1691
1694
  * It clears any existing timeout before execution.
@@ -1739,7 +1742,7 @@ declare class EphemeralTask extends Task {
1739
1742
  readonly once: boolean;
1740
1743
  readonly condition: (context: any) => boolean;
1741
1744
  readonly isEphemeral: boolean;
1742
- constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
1745
+ constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: Schema | undefined, validateInputContext?: boolean, outputSchema?: Schema | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
1743
1746
  /**
1744
1747
  * Executes the process logic with the provided context, emit function, progress callback, and node data.
1745
1748
  *
@@ -1800,9 +1803,9 @@ interface TaskOptions {
1800
1803
  isSubMeta?: boolean;
1801
1804
  isHidden?: boolean;
1802
1805
  getTagCallback?: ThrottleTagGetter;
1803
- inputSchema?: SchemaDefinition;
1806
+ inputSchema?: Schema;
1804
1807
  validateInputContext?: boolean;
1805
- outputSchema?: SchemaDefinition;
1808
+ outputSchema?: Schema;
1806
1809
  validateOutputContext?: boolean;
1807
1810
  retryCount?: number;
1808
1811
  retryDelay?: number;
@@ -1897,7 +1900,7 @@ declare class Cadenza {
1897
1900
  * ```
1898
1901
  */
1899
1902
  static emit(event: string, data?: AnyObject, options?: EmitOptions): void;
1900
- static schedule(taskName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
1903
+ static schedule(signalName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
1901
1904
  static interval(taskName: string, context: AnyObject, intervalMs: number, leading?: boolean, startDateTime?: Date): void;
1902
1905
  static debounce(signalName: string, context: any, delayMs: number): void;
1903
1906
  static get(taskName: string): Task | undefined;
@@ -2255,4 +2258,4 @@ declare class Cadenza {
2255
2258
  static reset(): void;
2256
2259
  }
2257
2260
 
2258
- export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, InquiryBroker, type InquiryOptions, type Intent, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
2261
+ export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, InquiryBroker, type InquiryOptions, type Intent, type Schema, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
package/dist/index.d.ts CHANGED
@@ -335,13 +335,14 @@ type SchemaDefinition = {
335
335
  type: SchemaType;
336
336
  required?: string[];
337
337
  properties?: {
338
- [key: string]: SchemaDefinition;
338
+ [key: string]: Schema;
339
339
  };
340
- items?: SchemaDefinition;
340
+ items?: Schema;
341
341
  constraints?: SchemaConstraints;
342
342
  description?: string;
343
343
  strict?: boolean;
344
344
  };
345
+ type Schema = SchemaDefinition | SchemaDefinition[];
345
346
 
346
347
  interface Intent {
347
348
  name: string;
@@ -848,9 +849,9 @@ declare class Task extends SignalEmitter implements Graph {
848
849
  readonly isDeputy: boolean;
849
850
  readonly isEphemeral: boolean;
850
851
  readonly isDebounce: boolean;
851
- inputContextSchema: SchemaDefinition;
852
+ inputContextSchema: Schema;
852
853
  validateInputContext: boolean;
853
- outputContextSchema: SchemaDefinition;
854
+ outputContextSchema: Schema;
854
855
  validateOutputContext: boolean;
855
856
  readonly retryCount: number;
856
857
  readonly retryDelay: number;
@@ -886,16 +887,16 @@ declare class Task extends SignalEmitter implements Graph {
886
887
  * @param {boolean} [isSubMeta=false] - Indicates if the task is a sub-meta-task.
887
888
  * @param {boolean} [isHidden=false] - Determines if the task is hidden and not exposed publicly.
888
889
  * @param {ThrottleTagGetter} [getTagCallback=undefined] - A callback to generate a throttle tag for the task.
889
- * @param {SchemaDefinition} [inputSchema=undefined] - The input schema for validating the task's input context.
890
+ * @param {Schema} [inputSchema=undefined] - The input schema for validating the task's input context.
890
891
  * @param {boolean} [validateInputContext=false] - Specifies if the input context should be validated against the input schema.
891
- * @param {SchemaDefinition} [outputSchema=undefined] - The output schema for validating the task's output context.
892
+ * @param {Schema} [outputSchema=undefined] - The output schema for validating the task's output context.
892
893
  * @param {boolean} [validateOutputContext=false] - Specifies if the output context should be validated against the output schema.
893
894
  * @param {number} [retryCount=0] - The number of retry attempts allowed for the task in case of failure.
894
895
  * @param {number} [retryDelay=0] - The initial delay (in milliseconds) between retry attempts.
895
896
  * @param {number} [retryDelayMax=0] - The maximum delay (in milliseconds) allowed between retries.
896
897
  * @param {number} [retryDelayFactor=1] - The factor by which the retry delay increases after each attempt.
897
898
  */
898
- constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition, validateInputContext?: boolean, outputSchema?: SchemaDefinition, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
899
+ constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: Schema, validateInputContext?: boolean, outputSchema?: Schema, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
899
900
  clone(traverse?: boolean, includeSignals?: boolean): Task;
900
901
  /**
901
902
  * Retrieves the tag associated with the instance.
@@ -909,8 +910,8 @@ declare class Task extends SignalEmitter implements Graph {
909
910
  setTimeout(timeout: number): void;
910
911
  setConcurrency(concurrency: number): void;
911
912
  setProgressWeight(weight: number): void;
912
- setInputContextSchema(schema: SchemaDefinition): void;
913
- setOutputContextSchema(schema: SchemaDefinition): void;
913
+ setInputContextSchema(schema: Schema): void;
914
+ setOutputContextSchema(schema: Schema): void;
914
915
  setValidateInputContext(value: boolean): void;
915
916
  setValidateOutputContext(value: boolean): void;
916
917
  /**
@@ -937,15 +938,16 @@ declare class Task extends SignalEmitter implements Graph {
937
938
  * Validates a data object against a specified schema definition and returns validation results.
938
939
  *
939
940
  * @param {any} data - The target object to validate against the schema.
940
- * @param {SchemaDefinition | undefined} schema - The schema definition describing the expected structure and constraints of the data.
941
+ * @param {Schema | undefined} schema - The schema definition describing the expected structure and constraints of the data.
941
942
  * @param {string} [path="context"] - The base path or context for traversing the data, used in generating error messages.
942
943
  * @return {{ valid: boolean, errors: Record<string, string> }} - An object containing a validity flag (`valid`)
943
944
  * and a map (`errors`) of validation error messages keyed by property paths.
944
945
  */
945
- validateSchema(data: any, schema: SchemaDefinition | undefined, path?: string): {
946
+ validateSchema(data: any, schema: Schema | undefined, path?: string): {
946
947
  valid: boolean;
947
948
  errors: Record<string, string>;
948
949
  };
950
+ validateProp(prop: SchemaDefinition, key: string, value?: any, path?: string): Record<string, string>;
949
951
  /**
950
952
  * Validates the input context against the predefined schema and emits metadata if validation fails.
951
953
  *
@@ -1504,6 +1506,7 @@ declare class SignalBroker {
1504
1506
  private isStrategyFlushing;
1505
1507
  private readonly defaultStrategyName;
1506
1508
  constructor();
1509
+ logMemoryFootprint(label?: string): void;
1507
1510
  /**
1508
1511
  * Validates the provided signal name string to ensure it adheres to specific formatting rules.
1509
1512
  * Throws an error if any of the validation checks fail.
@@ -1685,7 +1688,7 @@ declare class DebounceTask extends Task {
1685
1688
  lastProgressCallback: ((progress: number) => void) | null;
1686
1689
  lastEmitFunction: ((signal: string, context: any) => void) | null;
1687
1690
  lastInquireFunction: ((inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>) | null;
1688
- constructor(name: string, task: TaskFunction, description?: string, debounceTime?: number, leading?: boolean, trailing?: boolean, maxWait?: number, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, inputSchema?: SchemaDefinition | undefined, validateInputSchema?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputSchema?: boolean);
1691
+ constructor(name: string, task: TaskFunction, description?: string, debounceTime?: number, leading?: boolean, trailing?: boolean, maxWait?: number, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, inputSchema?: Schema | undefined, validateInputSchema?: boolean, outputSchema?: Schema | undefined, validateOutputSchema?: boolean);
1689
1692
  /**
1690
1693
  * Executes the taskFunction with the provided context, emit function, and progress callback.
1691
1694
  * It clears any existing timeout before execution.
@@ -1739,7 +1742,7 @@ declare class EphemeralTask extends Task {
1739
1742
  readonly once: boolean;
1740
1743
  readonly condition: (context: any) => boolean;
1741
1744
  readonly isEphemeral: boolean;
1742
- constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
1745
+ constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: Schema | undefined, validateInputContext?: boolean, outputSchema?: Schema | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
1743
1746
  /**
1744
1747
  * Executes the process logic with the provided context, emit function, progress callback, and node data.
1745
1748
  *
@@ -1800,9 +1803,9 @@ interface TaskOptions {
1800
1803
  isSubMeta?: boolean;
1801
1804
  isHidden?: boolean;
1802
1805
  getTagCallback?: ThrottleTagGetter;
1803
- inputSchema?: SchemaDefinition;
1806
+ inputSchema?: Schema;
1804
1807
  validateInputContext?: boolean;
1805
- outputSchema?: SchemaDefinition;
1808
+ outputSchema?: Schema;
1806
1809
  validateOutputContext?: boolean;
1807
1810
  retryCount?: number;
1808
1811
  retryDelay?: number;
@@ -1897,7 +1900,7 @@ declare class Cadenza {
1897
1900
  * ```
1898
1901
  */
1899
1902
  static emit(event: string, data?: AnyObject, options?: EmitOptions): void;
1900
- static schedule(taskName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
1903
+ static schedule(signalName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
1901
1904
  static interval(taskName: string, context: AnyObject, intervalMs: number, leading?: boolean, startDateTime?: Date): void;
1902
1905
  static debounce(signalName: string, context: any, delayMs: number): void;
1903
1906
  static get(taskName: string): Task | undefined;
@@ -2255,4 +2258,4 @@ declare class Cadenza {
2255
2258
  static reset(): void;
2256
2259
  }
2257
2260
 
2258
- export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, InquiryBroker, type InquiryOptions, type Intent, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
2261
+ export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, InquiryBroker, type InquiryOptions, type Intent, type Schema, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
package/dist/index.js CHANGED
@@ -1309,6 +1309,36 @@ var SignalBroker = class _SignalBroker {
1309
1309
  setVerbose(value) {
1310
1310
  this.verbose = value;
1311
1311
  }
1312
+ // Dor debugging
1313
+ logMemoryFootprint(label = "current") {
1314
+ console.log(`[${label}] SignalBroker state sizes:`);
1315
+ console.log(` \u2022 signalObservers entries: ${this.signalObservers.size}`);
1316
+ console.log(
1317
+ ` \u2022 emittedSignalsRegistry size: ${this.emittedSignalsRegistry.size}`
1318
+ );
1319
+ let totalSquashContexts = 0;
1320
+ let totalSquashGroups = 0;
1321
+ for (const groups of this.strategyData.values()) {
1322
+ totalSquashGroups += groups.size;
1323
+ for (const data of groups.values()) {
1324
+ totalSquashContexts += data.contexts.length;
1325
+ }
1326
+ }
1327
+ console.log(` \u2022 Active squash groups: ${totalSquashGroups}`);
1328
+ console.log(` \u2022 Total queued squash contexts: ${totalSquashContexts}`);
1329
+ let totalDebouncers = this.debouncedEmitters.size;
1330
+ console.log(` \u2022 Active debouncers: ${totalDebouncers}`);
1331
+ let totalThrottleQueues = 0;
1332
+ for (const q of this.throttleQueues.values()) {
1333
+ totalThrottleQueues += q.length;
1334
+ }
1335
+ console.log(` \u2022 Total items in throttle queues: ${totalThrottleQueues}`);
1336
+ let totalScheduled = 0;
1337
+ for (const bucket of this.scheduledBuckets.values()) {
1338
+ totalScheduled += bucket.length;
1339
+ }
1340
+ console.log(` \u2022 Pending scheduled items: ${totalScheduled}`);
1341
+ }
1312
1342
  /**
1313
1343
  * Validates the provided signal name string to ensure it adheres to specific formatting rules.
1314
1344
  * Throws an error if any of the validation checks fail.
@@ -1504,7 +1534,8 @@ var SignalBroker = class _SignalBroker {
1504
1534
  delay = options.exactDateTime.getTime() - Date.now();
1505
1535
  }
1506
1536
  delay = Math.max(0, delay);
1507
- const bucketKey = Math.ceil(delay / 100) * 100;
1537
+ const dueAt = Date.now() + delay;
1538
+ const bucketKey = Math.ceil(dueAt / 100) * 100;
1508
1539
  let bucket = this.scheduledBuckets.get(bucketKey);
1509
1540
  if (!bucket) {
1510
1541
  bucket = [];
@@ -3609,9 +3640,9 @@ var Task = class _Task extends SignalEmitter {
3609
3640
  * @param {boolean} [isSubMeta=false] - Indicates if the task is a sub-meta-task.
3610
3641
  * @param {boolean} [isHidden=false] - Determines if the task is hidden and not exposed publicly.
3611
3642
  * @param {ThrottleTagGetter} [getTagCallback=undefined] - A callback to generate a throttle tag for the task.
3612
- * @param {SchemaDefinition} [inputSchema=undefined] - The input schema for validating the task's input context.
3643
+ * @param {Schema} [inputSchema=undefined] - The input schema for validating the task's input context.
3613
3644
  * @param {boolean} [validateInputContext=false] - Specifies if the input context should be validated against the input schema.
3614
- * @param {SchemaDefinition} [outputSchema=undefined] - The output schema for validating the task's output context.
3645
+ * @param {Schema} [outputSchema=undefined] - The output schema for validating the task's output context.
3615
3646
  * @param {boolean} [validateOutputContext=false] - Specifies if the output context should be validated against the output schema.
3616
3647
  * @param {number} [retryCount=0] - The number of retry attempts allowed for the task in case of failure.
3617
3648
  * @param {number} [retryDelay=0] - The initial delay (in milliseconds) between retry attempts.
@@ -3856,14 +3887,27 @@ var Task = class _Task extends SignalEmitter {
3856
3887
  * Validates a data object against a specified schema definition and returns validation results.
3857
3888
  *
3858
3889
  * @param {any} data - The target object to validate against the schema.
3859
- * @param {SchemaDefinition | undefined} schema - The schema definition describing the expected structure and constraints of the data.
3890
+ * @param {Schema | undefined} schema - The schema definition describing the expected structure and constraints of the data.
3860
3891
  * @param {string} [path="context"] - The base path or context for traversing the data, used in generating error messages.
3861
3892
  * @return {{ valid: boolean, errors: Record<string, string> }} - An object containing a validity flag (`valid`)
3862
3893
  * and a map (`errors`) of validation error messages keyed by property paths.
3863
3894
  */
3864
3895
  validateSchema(data, schema, path = "context") {
3865
3896
  const errors = {};
3866
- if (!schema || typeof schema !== "object") return { valid: true, errors };
3897
+ if (!schema || typeof schema !== "object" && !Array.isArray(schema))
3898
+ return { valid: true, errors };
3899
+ if (Array.isArray(schema)) {
3900
+ for (const s of schema) {
3901
+ const subValidation = this.validateSchema(data, s, path);
3902
+ if (!subValidation.valid) {
3903
+ Object.assign(errors, subValidation.errors);
3904
+ }
3905
+ if (subValidation.valid) {
3906
+ return { valid: true, errors: {} };
3907
+ }
3908
+ }
3909
+ return { valid: false, errors };
3910
+ }
3867
3911
  const required = schema.required || [];
3868
3912
  for (const key of required) {
3869
3913
  if (!(key in data)) {
@@ -3874,84 +3918,12 @@ var Task = class _Task extends SignalEmitter {
3874
3918
  for (const [key, value] of Object.entries(data)) {
3875
3919
  if (key in properties) {
3876
3920
  const prop = properties[key];
3877
- const propType = prop.type;
3878
- if (propType === "any") {
3879
- continue;
3880
- }
3881
- if ((value === void 0 || value === null) && !prop.strict) {
3882
- continue;
3883
- }
3884
- if (propType === "string" && typeof value !== "string") {
3885
- errors[`${path}.${key}`] = `Expected 'string' for '${key}', got '${typeof value}'`;
3886
- } else if (propType === "number" && typeof value !== "number") {
3887
- errors[`${path}.${key}`] = `Expected 'number' for '${key}', got '${typeof value}'`;
3888
- } else if (propType === "boolean" && typeof value !== "boolean") {
3889
- errors[`${path}.${key}`] = `Expected 'boolean' for '${key}', got '${typeof value}'`;
3890
- } else if (propType === "array" && !Array.isArray(value)) {
3891
- errors[`${path}.${key}`] = `Expected 'array' for '${key}', got '${typeof value}'`;
3892
- } else if (propType === "object" && (typeof value !== "object" || value === null || Array.isArray(value))) {
3893
- errors[`${path}.${key}`] = `Expected 'object' for '${key}', got '${typeof value}'`;
3894
- } else if (propType === "array" && prop.items) {
3895
- if (Array.isArray(value)) {
3896
- value.forEach((item, index) => {
3897
- const subValidation = this.validateSchema(
3898
- item,
3899
- prop.items,
3900
- `${path}.${key}[${index}]`
3901
- );
3902
- if (!subValidation.valid) {
3903
- Object.assign(errors, subValidation.errors);
3904
- }
3905
- });
3906
- }
3907
- } else if (propType === "object" && !Array.isArray(value) && value !== null) {
3908
- const subValidation = this.validateSchema(
3909
- value,
3910
- prop,
3911
- `${path}.${key}`
3912
- );
3913
- if (!subValidation.valid) {
3914
- Object.assign(errors, subValidation.errors);
3915
- }
3916
- }
3917
- const constraints = prop.constraints || {};
3918
- if (typeof value === "string") {
3919
- if (constraints.minLength && value.length < constraints.minLength) {
3920
- errors[`${path}.${key}`] = `String '${key}' shorter than minLength ${constraints.minLength}`;
3921
- }
3922
- if (constraints.maxLength && value.length > constraints.maxLength) {
3923
- errors[`${path}.${key}`] = `String '${key}' exceeds maxLength ${constraints.maxLength}`;
3924
- }
3925
- if (constraints.pattern && !new RegExp(constraints.pattern).test(value)) {
3926
- errors[`${path}.${key}`] = `String '${key}' does not match pattern ${constraints.pattern}`;
3927
- }
3928
- } else if (typeof value === "number") {
3929
- if (constraints.min && value < constraints.min) {
3930
- errors[`${path}.${key}`] = `Number '${key}' below min ${constraints.min}`;
3921
+ if (Array.isArray(prop)) {
3922
+ for (const p of prop) {
3923
+ Object.assign(errors, this.validateProp(p, key, value, path));
3931
3924
  }
3932
- if (constraints.max && value > constraints.max) {
3933
- errors[`${path}.${key}`] = `Number '${key}' exceeds max ${constraints.max}`;
3934
- }
3935
- if (constraints.multipleOf && value % constraints.multipleOf !== 0) {
3936
- errors[`${path}.${key}`] = `Number '${key}' not multiple of ${constraints.multipleOf}`;
3937
- }
3938
- } else if (constraints.enum && !constraints.enum.includes(value)) {
3939
- errors[`${path}.${key}`] = `Value '${value}' for '${key}' not in enum ${JSON.stringify(constraints.enum)}`;
3940
- } else if (constraints.format) {
3941
- const formats = {
3942
- email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
3943
- url: /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/,
3944
- "date-time": /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/,
3945
- uuid: /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
3946
- custom: /.*/
3947
- // Placeholder; override with prop.constraints.pattern if present
3948
- };
3949
- const regex = formats[constraints.format] || new RegExp(constraints.pattern || ".*");
3950
- if (typeof value === "string" && !regex.test(value)) {
3951
- errors[`${path}.${key}`] = `Value '${value}' for '${key}' does not match format '${constraints.format}'`;
3952
- }
3953
- } else if (constraints.oneOf && !constraints.oneOf.includes(value)) {
3954
- errors[`${path}.${key}`] = `Value '${value}' for '${key}' not in oneOf ${JSON.stringify(constraints.oneOf)}`;
3925
+ } else {
3926
+ Object.assign(errors, this.validateProp(prop, key, value, path));
3955
3927
  }
3956
3928
  } else if (schema.strict) {
3957
3929
  errors[`${path}.${key}`] = `Key '${key}' is not allowed`;
@@ -3962,6 +3934,83 @@ var Task = class _Task extends SignalEmitter {
3962
3934
  }
3963
3935
  return { valid: true, errors: {} };
3964
3936
  }
3937
+ validateProp(prop, key, value, path = "context") {
3938
+ const propType = prop.type;
3939
+ const errors = {};
3940
+ if (propType === "any") {
3941
+ return errors;
3942
+ }
3943
+ if ((value === void 0 || value === null) && !prop.strict) {
3944
+ return errors;
3945
+ }
3946
+ if (propType === "string" && typeof value !== "string") {
3947
+ errors[`${path}.${key}`] = `Expected 'string' for '${key}', got '${typeof value}'`;
3948
+ } else if (propType === "number" && typeof value !== "number") {
3949
+ errors[`${path}.${key}`] = `Expected 'number' for '${key}', got '${typeof value}'`;
3950
+ } else if (propType === "boolean" && typeof value !== "boolean") {
3951
+ errors[`${path}.${key}`] = `Expected 'boolean' for '${key}', got '${typeof value}'`;
3952
+ } else if (propType === "array" && !Array.isArray(value)) {
3953
+ errors[`${path}.${key}`] = `Expected 'array' for '${key}', got '${typeof value}'`;
3954
+ } else if (propType === "object" && (typeof value !== "object" || value === null || Array.isArray(value))) {
3955
+ errors[`${path}.${key}`] = `Expected 'object' for '${key}', got '${typeof value}'`;
3956
+ } else if (propType === "array" && prop.items) {
3957
+ value.forEach((item, index) => {
3958
+ const subValidation = this.validateSchema(
3959
+ item,
3960
+ prop.items,
3961
+ `${path}.${key}[${index}]`
3962
+ );
3963
+ if (!subValidation.valid) {
3964
+ Object.assign(errors, subValidation.errors);
3965
+ }
3966
+ });
3967
+ } else if (propType === "object" && !Array.isArray(value) && value !== null) {
3968
+ const subValidation = this.validateSchema(value, prop, `${path}.${key}`);
3969
+ if (!subValidation.valid) {
3970
+ Object.assign(errors, subValidation.errors);
3971
+ }
3972
+ }
3973
+ const constraints = prop.constraints || {};
3974
+ if (typeof value === "string") {
3975
+ if (constraints.minLength && value.length < constraints.minLength) {
3976
+ errors[`${path}.${key}`] = `String '${key}' shorter than minLength ${constraints.minLength}`;
3977
+ }
3978
+ if (constraints.maxLength && value.length > constraints.maxLength) {
3979
+ errors[`${path}.${key}`] = `String '${key}' exceeds maxLength ${constraints.maxLength}`;
3980
+ }
3981
+ if (constraints.pattern && !new RegExp(constraints.pattern).test(value)) {
3982
+ errors[`${path}.${key}`] = `String '${key}' does not match pattern ${constraints.pattern}`;
3983
+ }
3984
+ } else if (typeof value === "number") {
3985
+ if (constraints.min && value < constraints.min) {
3986
+ errors[`${path}.${key}`] = `Number '${key}' below min ${constraints.min}`;
3987
+ }
3988
+ if (constraints.max && value > constraints.max) {
3989
+ errors[`${path}.${key}`] = `Number '${key}' exceeds max ${constraints.max}`;
3990
+ }
3991
+ if (constraints.multipleOf && value % constraints.multipleOf !== 0) {
3992
+ errors[`${path}.${key}`] = `Number '${key}' not multiple of ${constraints.multipleOf}`;
3993
+ }
3994
+ } else if (constraints.enum && !constraints.enum.includes(value)) {
3995
+ errors[`${path}.${key}`] = `Value '${value}' for '${key}' not in enum ${JSON.stringify(constraints.enum)}`;
3996
+ } else if (constraints.format) {
3997
+ const formats = {
3998
+ email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
3999
+ url: /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/,
4000
+ "date-time": /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/,
4001
+ uuid: /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
4002
+ custom: /.*/
4003
+ // Placeholder; override with prop.constraints.pattern if present
4004
+ };
4005
+ const regex = formats[constraints.format] || new RegExp(constraints.pattern || ".*");
4006
+ if (typeof value === "string" && !regex.test(value)) {
4007
+ errors[`${path}.${key}`] = `Value '${value}' for '${key}' does not match format '${constraints.format}'`;
4008
+ }
4009
+ } else if (constraints.oneOf && !constraints.oneOf.includes(value)) {
4010
+ errors[`${path}.${key}`] = `Value '${value}' for '${key}' not in oneOf ${JSON.stringify(constraints.oneOf)}`;
4011
+ }
4012
+ return errors;
4013
+ }
3965
4014
  /**
3966
4015
  * Validates the input context against the predefined schema and emits metadata if validation fails.
3967
4016
  *
@@ -6004,8 +6053,11 @@ var Cadenza = class {
6004
6053
  static emit(event, data = {}, options = {}) {
6005
6054
  this.signalBroker?.emit(event, data, options);
6006
6055
  }
6007
- static schedule(taskName, context, delayMs, exactDateTime) {
6008
- this.signalBroker?.schedule(taskName, context, { delayMs, exactDateTime });
6056
+ static schedule(signalName, context, delayMs, exactDateTime) {
6057
+ this.signalBroker?.schedule(signalName, context, {
6058
+ delayMs,
6059
+ exactDateTime
6060
+ });
6009
6061
  }
6010
6062
  static interval(taskName, context, intervalMs, leading = false, startDateTime) {
6011
6063
  this.signalBroker?.interval(