@cadenza.io/core 2.0.0 → 3.0.0

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
@@ -48,8 +48,8 @@ declare class GraphContext {
48
48
  * @returns Exported object.
49
49
  */
50
50
  export(): {
51
- __id: string;
52
- __context: AnyObject;
51
+ id: string;
52
+ context: AnyObject;
53
53
  };
54
54
  }
55
55
 
@@ -258,8 +258,8 @@ declare class GraphNode extends SignalEmitter implements Graph {
258
258
  __id: string;
259
259
  __task: AnyObject;
260
260
  __context: {
261
- __id: string;
262
- __context: AnyObject;
261
+ id: string;
262
+ context: AnyObject;
263
263
  };
264
264
  __result: TaskResult;
265
265
  __executionTime: number;
@@ -284,8 +284,8 @@ declare class GraphNode extends SignalEmitter implements Graph {
284
284
  __version: number;
285
285
  };
286
286
  __context: {
287
- __id: string;
288
- __context: AnyObject;
287
+ id: string;
288
+ context: AnyObject;
289
289
  };
290
290
  __executionTime: number;
291
291
  __executionStart: number;
@@ -324,68 +324,6 @@ declare class TaskIterator implements Iterator {
324
324
  next(): Task | undefined;
325
325
  }
326
326
 
327
- declare class SignalParticipant extends SignalEmitter {
328
- emitsSignals: Set<string>;
329
- signalsToEmitAfter: Set<string>;
330
- signalsToEmitOnFail: Set<string>;
331
- observedSignals: Set<string>;
332
- /**
333
- * Subscribes to signals (chainable).
334
- * @param signals The signal names.
335
- * @returns This for chaining.
336
- * @edge Duplicates ignored; assumes broker.observe binds this as handler.
337
- */
338
- doOn(...signals: string[]): this;
339
- /**
340
- * Sets signals to emit post-execution (chainable).
341
- * @param signals The signal names.
342
- * @returns This for chaining.
343
- */
344
- emitsAfter(...signals: string[]): this;
345
- emitsOnFail(...signals: string[]): this;
346
- /**
347
- * Unsubscribes from all observed signals.
348
- * @returns This for chaining.
349
- */
350
- unsubscribeAll(): this;
351
- /**
352
- * Unsubscribes from specific signals.
353
- * @param signals The signals.
354
- * @returns This for chaining.
355
- * @edge No-op if not subscribed.
356
- */
357
- unsubscribe(...signals: string[]): this;
358
- /**
359
- * Detaches specific emitted signals.
360
- * @param signals The signals.
361
- * @returns This for chaining.
362
- */
363
- detachSignals(...signals: string[]): this;
364
- /**
365
- * Detaches all emitted signals.
366
- * @returns This for chaining.
367
- */
368
- detachAllSignals(): this;
369
- mapSignals(callback: (signal: string) => void): void[];
370
- mapOnFailSignals(callback: (signal: string) => void): void[];
371
- /**
372
- * Emits attached signals.
373
- * @param context The context for emission.
374
- * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
375
- */
376
- emitSignals(context: GraphContext): void;
377
- /**
378
- * Emits attached fail signals.
379
- * @param context The context for emission.
380
- * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
381
- */
382
- emitOnFailSignals(context: GraphContext): void;
383
- /**
384
- * Destroys the participant (unsub/detach).
385
- */
386
- destroy(): void;
387
- }
388
-
389
327
  type SchemaType = "string" | "number" | "boolean" | "array" | "object" | "any";
390
328
  type SchemaConstraints = {
391
329
  min?: number;
@@ -413,7 +351,7 @@ type SchemaDefinition = {
413
351
  type TaskFunction = (context: AnyObject, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void) => TaskResult;
414
352
  type TaskResult = boolean | AnyObject | Generator | Promise<any> | void;
415
353
  type ThrottleTagGetter = (context?: AnyObject, task?: Task) => string;
416
- declare class Task extends SignalParticipant implements Graph {
354
+ declare class Task extends SignalEmitter implements Graph {
417
355
  readonly name: string;
418
356
  readonly description: string;
419
357
  version: number;
@@ -442,6 +380,10 @@ declare class Task extends SignalParticipant implements Graph {
442
380
  onFailTasks: Set<Task>;
443
381
  predecessorTasks: Set<Task>;
444
382
  destroyed: boolean;
383
+ emitsSignals: Set<string>;
384
+ signalsToEmitAfter: Set<string>;
385
+ signalsToEmitOnFail: Set<string>;
386
+ observedSignals: Set<string>;
445
387
  readonly taskFunction: TaskFunction;
446
388
  /**
447
389
  * Constructs a Task (static definition).
@@ -511,6 +453,57 @@ declare class Task extends SignalParticipant implements Graph {
511
453
  hasCycle(): boolean;
512
454
  mapNext(callback: (task: Task) => any, failed?: boolean): any[];
513
455
  mapPrevious(callback: (task: Task) => any): any[];
456
+ /**
457
+ * Subscribes to signals (chainable).
458
+ * @param signals The signal names.
459
+ * @returns This for chaining.
460
+ * @edge Duplicates ignored; assumes broker.observe binds this as handler.
461
+ */
462
+ doOn(...signals: string[]): this;
463
+ /**
464
+ * Sets signals to emit post-execution (chainable).
465
+ * @param signals The signal names.
466
+ * @returns This for chaining.
467
+ */
468
+ emits(...signals: string[]): this;
469
+ emitsOnFail(...signals: string[]): this;
470
+ /**
471
+ * Unsubscribes from all observed signals.
472
+ * @returns This for chaining.
473
+ */
474
+ unsubscribeAll(): this;
475
+ /**
476
+ * Unsubscribes from specific signals.
477
+ * @param signals The signals.
478
+ * @returns This for chaining.
479
+ * @edge No-op if not subscribed.
480
+ */
481
+ unsubscribe(...signals: string[]): this;
482
+ /**
483
+ * Detaches specific emitted signals.
484
+ * @param signals The signals.
485
+ * @returns This for chaining.
486
+ */
487
+ detachSignals(...signals: string[]): this;
488
+ /**
489
+ * Detaches all emitted signals.
490
+ * @returns This for chaining.
491
+ */
492
+ detachAllSignals(): this;
493
+ mapSignals(callback: (signal: string) => void): void[];
494
+ mapOnFailSignals(callback: (signal: string) => void): void[];
495
+ /**
496
+ * Emits attached signals.
497
+ * @param context The context for emission.
498
+ * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
499
+ */
500
+ emitSignals(context: GraphContext): void;
501
+ /**
502
+ * Emits attached fail signals.
503
+ * @param context The context for emission.
504
+ * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
505
+ */
506
+ emitOnFailSignals(context: GraphContext): void;
514
507
  destroy(): void;
515
508
  export(): AnyObject;
516
509
  getIterator(): TaskIterator;
@@ -577,12 +570,13 @@ declare class GraphRun {
577
570
  setExporter(exporter: GraphExporter): void;
578
571
  }
579
572
 
580
- declare class GraphRoutine extends SignalParticipant {
573
+ declare class GraphRoutine extends SignalEmitter {
581
574
  readonly name: string;
582
575
  version: number;
583
576
  readonly description: string;
584
577
  readonly isMeta: boolean;
585
578
  tasks: Set<Task>;
579
+ observedSignals: Set<string>;
586
580
  constructor(name: string, tasks: Task[], description: string, isMeta?: boolean);
587
581
  /**
588
582
  * Applies callback to starting tasks.
@@ -595,6 +589,25 @@ declare class GraphRoutine extends SignalParticipant {
595
589
  * @param version The Version.
596
590
  */
597
591
  setVersion(version: number): void;
592
+ /**
593
+ * Subscribes to signals (chainable).
594
+ * @param signals The signal names.
595
+ * @returns This for chaining.
596
+ * @edge Duplicates ignored; assumes broker.observe binds this as handler.
597
+ */
598
+ doOn(...signals: string[]): this;
599
+ /**
600
+ * Unsubscribes from all observed signals.
601
+ * @returns This for chaining.
602
+ */
603
+ unsubscribeAll(): this;
604
+ /**
605
+ * Unsubscribes from specific signals.
606
+ * @param signals The signals.
607
+ * @returns This for chaining.
608
+ * @edge No-op if not subscribed.
609
+ */
610
+ unsubscribe(...signals: string[]): this;
598
611
  /**
599
612
  * Destroys the routine.
600
613
  */
@@ -938,4 +951,4 @@ declare class SignalTask extends Task {
938
951
  constructor(signal: string, description?: string);
939
952
  }
940
953
 
941
- export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalParticipant, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
954
+ export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
package/dist/index.d.ts CHANGED
@@ -48,8 +48,8 @@ declare class GraphContext {
48
48
  * @returns Exported object.
49
49
  */
50
50
  export(): {
51
- __id: string;
52
- __context: AnyObject;
51
+ id: string;
52
+ context: AnyObject;
53
53
  };
54
54
  }
55
55
 
@@ -258,8 +258,8 @@ declare class GraphNode extends SignalEmitter implements Graph {
258
258
  __id: string;
259
259
  __task: AnyObject;
260
260
  __context: {
261
- __id: string;
262
- __context: AnyObject;
261
+ id: string;
262
+ context: AnyObject;
263
263
  };
264
264
  __result: TaskResult;
265
265
  __executionTime: number;
@@ -284,8 +284,8 @@ declare class GraphNode extends SignalEmitter implements Graph {
284
284
  __version: number;
285
285
  };
286
286
  __context: {
287
- __id: string;
288
- __context: AnyObject;
287
+ id: string;
288
+ context: AnyObject;
289
289
  };
290
290
  __executionTime: number;
291
291
  __executionStart: number;
@@ -324,68 +324,6 @@ declare class TaskIterator implements Iterator {
324
324
  next(): Task | undefined;
325
325
  }
326
326
 
327
- declare class SignalParticipant extends SignalEmitter {
328
- emitsSignals: Set<string>;
329
- signalsToEmitAfter: Set<string>;
330
- signalsToEmitOnFail: Set<string>;
331
- observedSignals: Set<string>;
332
- /**
333
- * Subscribes to signals (chainable).
334
- * @param signals The signal names.
335
- * @returns This for chaining.
336
- * @edge Duplicates ignored; assumes broker.observe binds this as handler.
337
- */
338
- doOn(...signals: string[]): this;
339
- /**
340
- * Sets signals to emit post-execution (chainable).
341
- * @param signals The signal names.
342
- * @returns This for chaining.
343
- */
344
- emitsAfter(...signals: string[]): this;
345
- emitsOnFail(...signals: string[]): this;
346
- /**
347
- * Unsubscribes from all observed signals.
348
- * @returns This for chaining.
349
- */
350
- unsubscribeAll(): this;
351
- /**
352
- * Unsubscribes from specific signals.
353
- * @param signals The signals.
354
- * @returns This for chaining.
355
- * @edge No-op if not subscribed.
356
- */
357
- unsubscribe(...signals: string[]): this;
358
- /**
359
- * Detaches specific emitted signals.
360
- * @param signals The signals.
361
- * @returns This for chaining.
362
- */
363
- detachSignals(...signals: string[]): this;
364
- /**
365
- * Detaches all emitted signals.
366
- * @returns This for chaining.
367
- */
368
- detachAllSignals(): this;
369
- mapSignals(callback: (signal: string) => void): void[];
370
- mapOnFailSignals(callback: (signal: string) => void): void[];
371
- /**
372
- * Emits attached signals.
373
- * @param context The context for emission.
374
- * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
375
- */
376
- emitSignals(context: GraphContext): void;
377
- /**
378
- * Emits attached fail signals.
379
- * @param context The context for emission.
380
- * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
381
- */
382
- emitOnFailSignals(context: GraphContext): void;
383
- /**
384
- * Destroys the participant (unsub/detach).
385
- */
386
- destroy(): void;
387
- }
388
-
389
327
  type SchemaType = "string" | "number" | "boolean" | "array" | "object" | "any";
390
328
  type SchemaConstraints = {
391
329
  min?: number;
@@ -413,7 +351,7 @@ type SchemaDefinition = {
413
351
  type TaskFunction = (context: AnyObject, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void) => TaskResult;
414
352
  type TaskResult = boolean | AnyObject | Generator | Promise<any> | void;
415
353
  type ThrottleTagGetter = (context?: AnyObject, task?: Task) => string;
416
- declare class Task extends SignalParticipant implements Graph {
354
+ declare class Task extends SignalEmitter implements Graph {
417
355
  readonly name: string;
418
356
  readonly description: string;
419
357
  version: number;
@@ -442,6 +380,10 @@ declare class Task extends SignalParticipant implements Graph {
442
380
  onFailTasks: Set<Task>;
443
381
  predecessorTasks: Set<Task>;
444
382
  destroyed: boolean;
383
+ emitsSignals: Set<string>;
384
+ signalsToEmitAfter: Set<string>;
385
+ signalsToEmitOnFail: Set<string>;
386
+ observedSignals: Set<string>;
445
387
  readonly taskFunction: TaskFunction;
446
388
  /**
447
389
  * Constructs a Task (static definition).
@@ -511,6 +453,57 @@ declare class Task extends SignalParticipant implements Graph {
511
453
  hasCycle(): boolean;
512
454
  mapNext(callback: (task: Task) => any, failed?: boolean): any[];
513
455
  mapPrevious(callback: (task: Task) => any): any[];
456
+ /**
457
+ * Subscribes to signals (chainable).
458
+ * @param signals The signal names.
459
+ * @returns This for chaining.
460
+ * @edge Duplicates ignored; assumes broker.observe binds this as handler.
461
+ */
462
+ doOn(...signals: string[]): this;
463
+ /**
464
+ * Sets signals to emit post-execution (chainable).
465
+ * @param signals The signal names.
466
+ * @returns This for chaining.
467
+ */
468
+ emits(...signals: string[]): this;
469
+ emitsOnFail(...signals: string[]): this;
470
+ /**
471
+ * Unsubscribes from all observed signals.
472
+ * @returns This for chaining.
473
+ */
474
+ unsubscribeAll(): this;
475
+ /**
476
+ * Unsubscribes from specific signals.
477
+ * @param signals The signals.
478
+ * @returns This for chaining.
479
+ * @edge No-op if not subscribed.
480
+ */
481
+ unsubscribe(...signals: string[]): this;
482
+ /**
483
+ * Detaches specific emitted signals.
484
+ * @param signals The signals.
485
+ * @returns This for chaining.
486
+ */
487
+ detachSignals(...signals: string[]): this;
488
+ /**
489
+ * Detaches all emitted signals.
490
+ * @returns This for chaining.
491
+ */
492
+ detachAllSignals(): this;
493
+ mapSignals(callback: (signal: string) => void): void[];
494
+ mapOnFailSignals(callback: (signal: string) => void): void[];
495
+ /**
496
+ * Emits attached signals.
497
+ * @param context The context for emission.
498
+ * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
499
+ */
500
+ emitSignals(context: GraphContext): void;
501
+ /**
502
+ * Emits attached fail signals.
503
+ * @param context The context for emission.
504
+ * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
505
+ */
506
+ emitOnFailSignals(context: GraphContext): void;
514
507
  destroy(): void;
515
508
  export(): AnyObject;
516
509
  getIterator(): TaskIterator;
@@ -577,12 +570,13 @@ declare class GraphRun {
577
570
  setExporter(exporter: GraphExporter): void;
578
571
  }
579
572
 
580
- declare class GraphRoutine extends SignalParticipant {
573
+ declare class GraphRoutine extends SignalEmitter {
581
574
  readonly name: string;
582
575
  version: number;
583
576
  readonly description: string;
584
577
  readonly isMeta: boolean;
585
578
  tasks: Set<Task>;
579
+ observedSignals: Set<string>;
586
580
  constructor(name: string, tasks: Task[], description: string, isMeta?: boolean);
587
581
  /**
588
582
  * Applies callback to starting tasks.
@@ -595,6 +589,25 @@ declare class GraphRoutine extends SignalParticipant {
595
589
  * @param version The Version.
596
590
  */
597
591
  setVersion(version: number): void;
592
+ /**
593
+ * Subscribes to signals (chainable).
594
+ * @param signals The signal names.
595
+ * @returns This for chaining.
596
+ * @edge Duplicates ignored; assumes broker.observe binds this as handler.
597
+ */
598
+ doOn(...signals: string[]): this;
599
+ /**
600
+ * Unsubscribes from all observed signals.
601
+ * @returns This for chaining.
602
+ */
603
+ unsubscribeAll(): this;
604
+ /**
605
+ * Unsubscribes from specific signals.
606
+ * @param signals The signals.
607
+ * @returns This for chaining.
608
+ * @edge No-op if not subscribed.
609
+ */
610
+ unsubscribe(...signals: string[]): this;
598
611
  /**
599
612
  * Destroys the routine.
600
613
  */
@@ -938,4 +951,4 @@ declare class SignalTask extends Task {
938
951
  constructor(signal: string, description?: string);
939
952
  }
940
953
 
941
- export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalParticipant, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
954
+ export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };