@cadenza.io/core 1.11.12 → 1.11.14

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
@@ -4,9 +4,9 @@ type AnyObject = {
4
4
 
5
5
  declare class GraphContext {
6
6
  readonly id: string;
7
- private readonly fullContext;
8
- private readonly userData;
9
- private readonly metaData;
7
+ readonly fullContext: AnyObject;
8
+ readonly userData: AnyObject;
9
+ readonly metadata: AnyObject;
10
10
  constructor(context: AnyObject);
11
11
  /**
12
12
  * Gets frozen user data (read-only, no clone).
@@ -24,7 +24,7 @@ declare class GraphContext {
24
24
  * Gets frozen metadata (read-only).
25
25
  * @returns Frozen metadata object.
26
26
  */
27
- getMetaData(): AnyObject;
27
+ getMetadata(): AnyObject;
28
28
  /**
29
29
  * Clones this context (new instance).
30
30
  * @returns New GraphContext.
@@ -107,7 +107,7 @@ declare class GraphNodeIterator implements Iterator {
107
107
  }
108
108
 
109
109
  declare abstract class SignalEmitter {
110
- protected silent: boolean;
110
+ silent: boolean;
111
111
  /**
112
112
  * Constructor for signal emitters.
113
113
  * @param silent If true, suppresses all emissions (e.g., for meta-runners to avoid loops; affects all emits).
@@ -118,18 +118,18 @@ declare abstract class SignalEmitter {
118
118
  * @param signal The signal name.
119
119
  * @param data Optional payload (defaults to empty object).
120
120
  */
121
- protected emit(signal: string, data?: AnyObject): void;
121
+ emit(signal: string, data?: AnyObject): void;
122
122
  /**
123
123
  * Emits a signal via the broker if not silent.
124
124
  * @param signal The signal name.
125
125
  * @param data Optional payload (defaults to empty object).
126
126
  */
127
- protected emitMetrics(signal: string, data?: AnyObject): void;
127
+ emitMetrics(signal: string, data?: AnyObject): void;
128
128
  }
129
129
 
130
130
  declare abstract class ExecutionChain {
131
- protected next: ExecutionChain | undefined;
132
- protected previous: ExecutionChain | undefined;
131
+ next: ExecutionChain | undefined;
132
+ previous: ExecutionChain | undefined;
133
133
  setNext(next: ExecutionChain): void;
134
134
  get hasNext(): boolean;
135
135
  get hasPreceding(): boolean;
@@ -151,11 +151,11 @@ declare class GraphLayerIterator implements Iterator {
151
151
  }
152
152
 
153
153
  declare abstract class GraphLayer extends ExecutionChain implements Graph {
154
- protected readonly index: number;
155
- protected nodes: GraphNode[];
156
- private executionTime;
157
- private executionStart;
158
- protected debug: boolean;
154
+ readonly index: number;
155
+ nodes: GraphNode[];
156
+ executionTime: number;
157
+ executionStart: number;
158
+ debug: boolean;
159
159
  constructor(index: number);
160
160
  setDebug(value: boolean): void;
161
161
  abstract execute(context?: GraphContext): unknown;
@@ -186,27 +186,27 @@ declare abstract class GraphLayer extends ExecutionChain implements Graph {
186
186
  declare class GraphNode extends SignalEmitter implements Graph {
187
187
  id: string;
188
188
  routineExecId: string;
189
- private task;
190
- private context;
191
- private layer;
192
- private divided;
193
- private splitGroupId;
194
- private processing;
195
- private subgraphComplete;
196
- private graphComplete;
197
- private result;
198
- private retryCount;
199
- private retryDelay;
200
- private retries;
201
- private previousNodes;
202
- private nextNodes;
203
- private executionTime;
204
- private executionStart;
205
- private failed;
206
- private errored;
189
+ task: Task;
190
+ context: GraphContext;
191
+ layer: GraphLayer | undefined;
192
+ divided: boolean;
193
+ splitGroupId: string;
194
+ processing: boolean;
195
+ subgraphComplete: boolean;
196
+ graphComplete: boolean;
197
+ result: TaskResult;
198
+ retryCount: number;
199
+ retryDelay: number;
200
+ retries: number;
201
+ previousNodes: GraphNode[];
202
+ nextNodes: GraphNode[];
203
+ executionTime: number;
204
+ executionStart: number;
205
+ failed: boolean;
206
+ errored: boolean;
207
207
  destroyed: boolean;
208
- protected debug: boolean;
209
- protected verbose: boolean;
208
+ debug: boolean;
209
+ verbose: boolean;
210
210
  constructor(task: Task, context: GraphContext, routineExecId: string, prevNodes?: GraphNode[], debug?: boolean, verbose?: boolean);
211
211
  setDebug(value: boolean): void;
212
212
  isUnique(): boolean;
@@ -226,27 +226,27 @@ declare class GraphNode extends SignalEmitter implements Graph {
226
226
  start(): number;
227
227
  end(): number;
228
228
  execute(): GraphNode[] | Promise<GraphNode[]>;
229
- private workAsync;
230
- private executeAsync;
231
- private work;
232
- protected emitWithMetadata(signal: string, ctx: AnyObject): void;
233
- protected emitMetricsWithMetadata(signal: string, ctx: AnyObject): void;
234
- private onProgress;
235
- private postProcess;
236
- private onError;
237
- private retry;
238
- private retryAsync;
239
- private delayRetry;
240
- private divide;
241
- private generateNewNodes;
242
- private differentiate;
243
- private migrate;
244
- private split;
229
+ workAsync(): Promise<void>;
230
+ executeAsync(): Promise<GraphNode[]>;
231
+ work(): TaskResult | Promise<TaskResult>;
232
+ emitWithMetadata(signal: string, ctx: AnyObject): void;
233
+ emitMetricsWithMetadata(signal: string, ctx: AnyObject): void;
234
+ onProgress(progress: number): void;
235
+ postProcess(): void;
236
+ onError(error: unknown, errorData?: AnyObject): void;
237
+ retry(prevResult?: any): Promise<TaskResult>;
238
+ retryAsync(prevResult?: any): Promise<TaskResult>;
239
+ delayRetry(): Promise<void>;
240
+ divide(): GraphNode[];
241
+ generateNewNodes(result: any): GraphNode[];
242
+ differentiate(task: Task): GraphNode;
243
+ migrate(ctx: any): GraphNode;
244
+ split(id: string): GraphNode;
245
245
  clone(): GraphNode;
246
246
  consume(node: GraphNode): void;
247
- private changeIdentity;
248
- private completeSubgraph;
249
- private completeGraph;
247
+ changeIdentity(id: string): void;
248
+ completeSubgraph(): void;
249
+ completeGraph(): void;
250
250
  destroy(): void;
251
251
  getIterator(): GraphNodeIterator;
252
252
  mapNext(callback: (node: GraphNode) => any): any[];
@@ -308,20 +308,24 @@ declare abstract class GraphVisitor {
308
308
  }
309
309
 
310
310
  declare class TaskIterator implements Iterator {
311
- private currentTask;
312
- private currentLayer;
313
- private nextLayer;
314
- private iterator;
311
+ currentTask: Task | undefined;
312
+ currentLayer: Set<Task>;
313
+ nextLayer: Set<Task>;
314
+ iterator: {
315
+ next: () => {
316
+ value: Task | undefined;
317
+ };
318
+ };
315
319
  constructor(task: Task);
316
320
  hasNext(): boolean;
317
321
  next(): Task | undefined;
318
322
  }
319
323
 
320
324
  declare class SignalParticipant extends SignalEmitter {
321
- protected emitsSignals: Set<string>;
322
- protected signalsToEmitAfter: Set<string>;
323
- protected signalsToEmitOnFail: Set<string>;
324
- protected observedSignals: Set<string>;
325
+ emitsSignals: Set<string>;
326
+ signalsToEmitAfter: Set<string>;
327
+ signalsToEmitOnFail: Set<string>;
328
+ observedSignals: Set<string>;
325
329
  /**
326
330
  * Subscribes to signals (chainable).
327
331
  * @param signals The signal names.
@@ -421,21 +425,21 @@ declare class Task extends SignalParticipant implements Graph {
421
425
  readonly isDeputy: boolean;
422
426
  readonly isEphemeral: boolean;
423
427
  readonly isDebounce: boolean;
424
- protected inputContextSchema: SchemaDefinition | undefined;
425
- protected validateInputContext: boolean;
426
- protected outputContextSchema: SchemaDefinition | undefined;
427
- protected validateOutputContext: boolean;
428
+ inputContextSchema: SchemaDefinition | undefined;
429
+ validateInputContext: boolean;
430
+ outputContextSchema: SchemaDefinition | undefined;
431
+ validateOutputContext: boolean;
428
432
  readonly retryCount: number;
429
433
  readonly retryDelay: number;
430
434
  readonly retryDelayMax: number;
431
435
  readonly retryDelayFactor: number;
432
436
  layerIndex: number;
433
437
  progressWeight: number;
434
- private nextTasks;
435
- private onFailTasks;
436
- private predecessorTasks;
438
+ nextTasks: Set<Task>;
439
+ onFailTasks: Set<Task>;
440
+ predecessorTasks: Set<Task>;
437
441
  destroyed: boolean;
438
- protected readonly taskFunction: TaskFunction;
442
+ readonly taskFunction: TaskFunction;
439
443
  /**
440
444
  * Constructs a Task (static definition).
441
445
  * @param name Name.
@@ -469,8 +473,8 @@ declare class Task extends SignalParticipant implements Graph {
469
473
  setOutputContextSchema(schema: SchemaDefinition): void;
470
474
  setValidateInputContext(value: boolean): void;
471
475
  setValidateOutputContext(value: boolean): void;
472
- private emitWithMetadata;
473
- private emitMetricsWithMetadata;
476
+ emitWithMetadata(signal: string, ctx?: AnyObject): void;
477
+ emitMetricsWithMetadata(signal: string, ctx?: AnyObject): void;
474
478
  /**
475
479
  * Validates a context deeply against a schema.
476
480
  * @param data - The data to validate (input context or output result).
@@ -479,7 +483,7 @@ declare class Task extends SignalParticipant implements Graph {
479
483
  * @returns { { valid: boolean, errors: Record<string, string> } } - Validation result with detailed errors if invalid.
480
484
  * @description Recursively checks types, required fields, and constraints; allows extra properties not in schema.
481
485
  */
482
- protected validateSchema(data: any, schema: SchemaDefinition | undefined, path?: string): {
486
+ validateSchema(data: any, schema: SchemaDefinition | undefined, path?: string): {
483
487
  valid: boolean;
484
488
  errors: Record<string, string>;
485
489
  };
@@ -499,10 +503,10 @@ declare class Task extends SignalParticipant implements Graph {
499
503
  then(...tasks: Task[]): this;
500
504
  decouple(task: Task): void;
501
505
  doOnFail(...tasks: Task[]): this;
502
- private updateProgressWeights;
503
- private getSubgraphLayers;
504
- private updateLayerFromPredecessors;
505
- private hasCycle;
506
+ updateProgressWeights(): void;
507
+ getSubgraphLayers(): Map<number, Set<Task>>;
508
+ updateLayerFromPredecessors(): void;
509
+ hasCycle(): boolean;
506
510
  mapNext(callback: (task: Task) => any, failed?: boolean): any[];
507
511
  mapPrevious(callback: (task: Task) => any): any[];
508
512
  destroy(): void;
@@ -530,20 +534,20 @@ declare abstract class GraphBuilder {
530
534
  getResult(): GraphLayer;
531
535
  compose(): void;
532
536
  addNode(node: GraphNode): void;
533
- protected addNodes(nodes: GraphNode[]): void;
534
- protected addLayer(index: number): void;
535
- protected createLayer(index: number): GraphLayer;
536
- protected getLayer(layerIndex: number): GraphLayer;
537
+ addNodes(nodes: GraphNode[]): void;
538
+ addLayer(index: number): void;
539
+ createLayer(index: number): GraphLayer;
540
+ getLayer(layerIndex: number): GraphLayer;
537
541
  reset(): void;
538
542
  }
539
543
 
540
544
  declare abstract class GraphRunStrategy {
541
- protected graphBuilder: GraphBuilder;
542
- protected runInstance?: GraphRun;
545
+ graphBuilder: GraphBuilder;
546
+ runInstance?: GraphRun;
543
547
  constructor();
544
548
  setRunInstance(runInstance: GraphRun): void;
545
549
  changeStrategy(builder: GraphBuilder): void;
546
- protected reset(): void;
550
+ reset(): void;
547
551
  addNode(node: GraphNode): void;
548
552
  updateRunInstance(): void;
549
553
  abstract run(): void;
@@ -558,9 +562,9 @@ interface RunJson {
558
562
  }
559
563
  declare class GraphRun {
560
564
  readonly id: string;
561
- private graph;
562
- private strategy;
563
- private exporter;
565
+ graph: GraphLayer | undefined;
566
+ strategy: GraphRunStrategy;
567
+ exporter: GraphExporter | undefined;
564
568
  constructor(strategy: GraphRunStrategy);
565
569
  setGraph(graph: GraphLayer): void;
566
570
  addNode(node: GraphNode): void;
@@ -576,7 +580,7 @@ declare class GraphRoutine extends SignalParticipant {
576
580
  readonly name: string;
577
581
  readonly description: string;
578
582
  readonly isMeta: boolean;
579
- private tasks;
583
+ tasks: Set<Task>;
580
584
  constructor(name: string, tasks: Task[], description: string, isMeta?: boolean);
581
585
  /**
582
586
  * Applies callback to starting tasks.
@@ -597,12 +601,12 @@ declare class GraphRoutine extends SignalParticipant {
597
601
 
598
602
  declare class GraphRunner extends SignalEmitter {
599
603
  readonly id: string;
600
- protected currentRun: GraphRun;
601
- private debug;
602
- private verbose;
603
- protected isRunning: boolean;
604
- private readonly isMeta;
605
- protected strategy: GraphRunStrategy;
604
+ currentRun: GraphRun;
605
+ debug: boolean;
606
+ verbose: boolean;
607
+ isRunning: boolean;
608
+ readonly isMeta: boolean;
609
+ strategy: GraphRunStrategy;
606
610
  /**
607
611
  * Constructs a runner.
608
612
  * @param isMeta Meta flag (default false).
@@ -618,7 +622,7 @@ declare class GraphRunner extends SignalEmitter {
618
622
  * @edge Emits 'meta.runner.added_tasks' with metadata.
619
623
  * @edge Empty tasks warns no-op.
620
624
  */
621
- protected addTasks(tasks: Task | GraphRoutine | (Task | GraphRoutine)[], context?: AnyObject): void;
625
+ addTasks(tasks: Task | GraphRoutine | (Task | GraphRoutine)[], context?: AnyObject): void;
622
626
  /**
623
627
  * Runs tasks/routines.
624
628
  * @param tasks Optional tasks/routines.
@@ -627,36 +631,36 @@ declare class GraphRunner extends SignalEmitter {
627
631
  * @edge If running, returns current; else runs and resets.
628
632
  */
629
633
  run(tasks?: Task | GraphRoutine | (Task | GraphRoutine)[], context?: AnyObject): GraphRun | Promise<GraphRun>;
630
- private runAsync;
631
- protected reset(): GraphRun;
634
+ runAsync(run: Promise<void>): Promise<GraphRun>;
635
+ reset(): GraphRun;
632
636
  setDebug(value: boolean): void;
633
637
  setVerbose(value: boolean): void;
634
638
  destroy(): void;
635
639
  setStrategy(strategy: GraphRunStrategy): void;
636
- private startRun;
640
+ startRun(context: AnyObject): boolean;
637
641
  }
638
642
 
639
643
  declare class SignalBroker {
640
- private static instance_;
644
+ static instance_: SignalBroker;
641
645
  /**
642
646
  * Singleton instance for signal management.
643
647
  * @returns The broker instance.
644
648
  */
645
649
  static get instance(): SignalBroker;
646
- private debug;
647
- private verbose;
650
+ debug: boolean;
651
+ verbose: boolean;
648
652
  setDebug(value: boolean): void;
649
653
  setVerbose(value: boolean): void;
650
- protected validateSignalName(signalName: string): void;
651
- protected runner: GraphRunner | undefined;
652
- protected metaRunner: GraphRunner | undefined;
654
+ validateSignalName(signalName: string): void;
655
+ runner: GraphRunner | undefined;
656
+ metaRunner: GraphRunner | undefined;
653
657
  getSignalsTask: Task | undefined;
654
- protected signalObservers: Map<string, {
658
+ signalObservers: Map<string, {
655
659
  fn: (runner: GraphRunner, tasks: (Task | GraphRoutine)[], context: AnyObject) => void;
656
660
  tasks: Set<Task | GraphRoutine>;
657
661
  }>;
658
- protected emitStacks: Map<string, Map<string, AnyObject>>;
659
- protected constructor();
662
+ emitStacks: Map<string, Map<string, AnyObject>>;
663
+ constructor();
660
664
  /**
661
665
  * Initializes with runners.
662
666
  * @param runner Standard runner for user signals.
@@ -687,8 +691,8 @@ declare class SignalBroker {
687
691
  */
688
692
  emit(signal: string, context?: AnyObject): void;
689
693
  execute(signal: string, context: AnyObject): boolean;
690
- private executeListener;
691
- private addSignal;
694
+ executeListener(signal: string, context: AnyObject): boolean;
695
+ addSignal(signal: string): void;
692
696
  /**
693
697
  * Lists all observed signals.
694
698
  * @returns Array of signals.
@@ -698,10 +702,10 @@ declare class SignalBroker {
698
702
  }
699
703
 
700
704
  declare class GraphRegistry {
701
- private static _instance;
705
+ static _instance: GraphRegistry;
702
706
  static get instance(): GraphRegistry;
703
- private tasks;
704
- private routines;
707
+ tasks: Map<string, Task>;
708
+ routines: Map<string, GraphRoutine>;
705
709
  registerTask: Task;
706
710
  updateTaskId: Task;
707
711
  updateTaskInputSchema: Task;
@@ -719,7 +723,7 @@ declare class GraphRegistry {
719
723
  getAllRoutines: Task;
720
724
  doForEachRoutine: Task;
721
725
  deleteRoutine: Task;
722
- private constructor();
726
+ constructor();
723
727
  reset(): void;
724
728
  }
725
729
 
@@ -729,22 +733,22 @@ interface DebounceOptions {
729
733
  maxWait?: number;
730
734
  }
731
735
  declare class DebounceTask extends Task {
732
- private readonly debounceTime;
733
- private leading;
734
- private trailing;
735
- private maxWait;
736
- private timer;
737
- private maxTimer;
738
- private hasLaterCall;
739
- private lastResolve;
740
- private lastReject;
741
- private lastContext;
742
- private lastTimeout;
743
- private lastProgressCallback;
744
- private lastEmitFunction;
736
+ readonly debounceTime: number;
737
+ leading: boolean;
738
+ trailing: boolean;
739
+ maxWait: number;
740
+ timer: NodeJS.Timeout | null;
741
+ maxTimer: NodeJS.Timeout | null;
742
+ hasLaterCall: boolean;
743
+ lastResolve: ((value: unknown) => void) | null;
744
+ lastReject: ((reason?: any) => void) | null;
745
+ lastContext: GraphContext | null;
746
+ lastTimeout: NodeJS.Timeout | null;
747
+ lastProgressCallback: ((progress: number) => void) | null;
748
+ lastEmitFunction: ((signal: string, context: any) => void) | null;
745
749
  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);
746
- private executeFunction;
747
- private debouncedTrigger;
750
+ executeFunction(): void;
751
+ debouncedTrigger(resolve: (value: unknown) => void, reject: (reason?: any) => void, context: GraphContext, timeout: NodeJS.Timeout, emit: (signal: string, context: any) => void, progressCallback: (progress: number) => void): void;
748
752
  execute(context: GraphContext, emit: (signal: string, context: any) => void, progressCallback: (progress: number) => void): TaskResult;
749
753
  }
750
754
 
@@ -753,8 +757,8 @@ type EphemeralTaskOptions = {
753
757
  destroyCondition?: (context: any) => boolean;
754
758
  };
755
759
  declare class EphemeralTask extends Task {
756
- private readonly once;
757
- private readonly condition;
760
+ readonly once: boolean;
761
+ readonly condition: (context: any) => boolean;
758
762
  readonly isEphemeral: boolean;
759
763
  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);
760
764
  execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void): TaskResult;
@@ -763,7 +767,7 @@ declare class EphemeralTask extends Task {
763
767
  declare class GraphAsyncRun extends GraphRunStrategy {
764
768
  constructor();
765
769
  run(): Promise<void>;
766
- protected reset(): void;
770
+ reset(): void;
767
771
  export(): any;
768
772
  }
769
773
 
@@ -796,8 +800,8 @@ declare class Cadenza {
796
800
  static runner: GraphRunner;
797
801
  static metaRunner: GraphRunner;
798
802
  static registry: GraphRegistry;
799
- protected static isBootstrapped: boolean;
800
- protected static mode: CadenzaMode;
803
+ static isBootstrapped: boolean;
804
+ static mode: CadenzaMode;
801
805
  static bootstrap(): void;
802
806
  static get runStrategy(): {
803
807
  PARALLEL: GraphAsyncRun;