@cadenza.io/core 1.7.11 → 1.9.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 +38 -13
- package/dist/index.d.ts +38 -13
- package/dist/index.js +219 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +219 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -119,13 +119,13 @@ declare abstract class SignalEmitter {
|
|
|
119
119
|
* @param data Optional payload (defaults to empty object).
|
|
120
120
|
* @edge No emission if silent; for metrics in silent mode, consider override or separate method.
|
|
121
121
|
*/
|
|
122
|
-
emit(signal: string, data?:
|
|
122
|
+
protected emit(signal: string, data?: AnyObject): void;
|
|
123
123
|
/**
|
|
124
124
|
* Emits a signal via the broker even if silent.
|
|
125
125
|
* @param signal The signal name.
|
|
126
126
|
* @param data Optional payload (defaults to empty object).
|
|
127
127
|
*/
|
|
128
|
-
emitMetric(signal: string, data?:
|
|
128
|
+
protected emitMetric(signal: string, data?: AnyObject): void;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
declare abstract class ExecutionChain {
|
|
@@ -195,6 +195,9 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
195
195
|
private subgraphComplete;
|
|
196
196
|
private graphComplete;
|
|
197
197
|
private result;
|
|
198
|
+
private retryCount;
|
|
199
|
+
private retryDelay;
|
|
200
|
+
private retries;
|
|
198
201
|
private previousNodes;
|
|
199
202
|
private nextNodes;
|
|
200
203
|
private executionTime;
|
|
@@ -222,11 +225,16 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
222
225
|
start(): number;
|
|
223
226
|
end(): number;
|
|
224
227
|
execute(): GraphNode[] | Promise<GraphNode[]>;
|
|
225
|
-
private
|
|
228
|
+
private workAsync;
|
|
229
|
+
private executeAsync;
|
|
226
230
|
private work;
|
|
231
|
+
protected emitWithMetadata(signal: string, context: AnyObject): void;
|
|
227
232
|
private onProgress;
|
|
228
233
|
private postProcess;
|
|
229
234
|
private onError;
|
|
235
|
+
private retry;
|
|
236
|
+
private retryAsync;
|
|
237
|
+
private delayRetry;
|
|
230
238
|
private divide;
|
|
231
239
|
private generateNewNodes;
|
|
232
240
|
private differentiate;
|
|
@@ -248,7 +256,7 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
248
256
|
__id: string;
|
|
249
257
|
__context: AnyObject;
|
|
250
258
|
};
|
|
251
|
-
__result:
|
|
259
|
+
__result: TaskResult;
|
|
252
260
|
__executionTime: number;
|
|
253
261
|
__executionStart: number;
|
|
254
262
|
__executionEnd: number;
|
|
@@ -308,7 +316,8 @@ declare class TaskIterator implements Iterator {
|
|
|
308
316
|
}
|
|
309
317
|
|
|
310
318
|
declare class SignalParticipant extends SignalEmitter {
|
|
311
|
-
protected
|
|
319
|
+
protected emitsSignals: Set<string>;
|
|
320
|
+
protected signalsToEmitAfter: Set<string>;
|
|
312
321
|
protected signalsToEmitOnFail: Set<string>;
|
|
313
322
|
protected observedSignals: Set<string>;
|
|
314
323
|
/**
|
|
@@ -323,7 +332,7 @@ declare class SignalParticipant extends SignalEmitter {
|
|
|
323
332
|
* @param signals The signal names.
|
|
324
333
|
* @returns This for chaining.
|
|
325
334
|
*/
|
|
326
|
-
|
|
335
|
+
emitsAfter(...signals: string[]): this;
|
|
327
336
|
emitsOnFail(...signals: string[]): this;
|
|
328
337
|
/**
|
|
329
338
|
* Unsubscribes from all observed signals.
|
|
@@ -348,6 +357,8 @@ declare class SignalParticipant extends SignalEmitter {
|
|
|
348
357
|
* @returns This for chaining.
|
|
349
358
|
*/
|
|
350
359
|
detachAllSignals(): this;
|
|
360
|
+
mapSignals(callback: (signal: string) => void): void[];
|
|
361
|
+
mapOnFailSignals(callback: (signal: string) => void): void[];
|
|
351
362
|
/**
|
|
352
363
|
* Emits attached signals.
|
|
353
364
|
* @param context The context for emission.
|
|
@@ -390,8 +401,8 @@ type SchemaDefinition = {
|
|
|
390
401
|
strict?: boolean;
|
|
391
402
|
};
|
|
392
403
|
|
|
393
|
-
type TaskFunction = (context: AnyObject, progressCallback: (progress: number) => void) => TaskResult;
|
|
394
|
-
type TaskResult = boolean |
|
|
404
|
+
type TaskFunction = (context: AnyObject, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void) => TaskResult;
|
|
405
|
+
type TaskResult = boolean | AnyObject | Generator | Promise<any> | void;
|
|
395
406
|
type ThrottleTagGetter = (context?: AnyObject, task?: Task) => string;
|
|
396
407
|
declare class Task extends SignalParticipant implements Graph {
|
|
397
408
|
id: string;
|
|
@@ -409,6 +420,10 @@ declare class Task extends SignalParticipant implements Graph {
|
|
|
409
420
|
protected validateInputContext: boolean;
|
|
410
421
|
protected outputContextSchema: SchemaDefinition | undefined;
|
|
411
422
|
protected validateOutputContext: boolean;
|
|
423
|
+
readonly retryCount: number;
|
|
424
|
+
readonly retryDelay: number;
|
|
425
|
+
readonly retryDelayMax: number;
|
|
426
|
+
readonly retryDelayFactor: number;
|
|
412
427
|
layerIndex: number;
|
|
413
428
|
progressWeight: number;
|
|
414
429
|
private nextTasks;
|
|
@@ -431,9 +446,13 @@ declare class Task extends SignalParticipant implements Graph {
|
|
|
431
446
|
* @param validateInputContext
|
|
432
447
|
* @param outputSchema
|
|
433
448
|
* @param validateOutputContext
|
|
449
|
+
* @param retryCount
|
|
450
|
+
* @param retryDelay
|
|
451
|
+
* @param retryDelayMax
|
|
452
|
+
* @param retryDelayFactor
|
|
434
453
|
* @edge Emits 'meta.task.created' with { __task: this } for seed.
|
|
435
454
|
*/
|
|
436
|
-
constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean);
|
|
455
|
+
constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
|
|
437
456
|
getTag(context?: AnyObject): string;
|
|
438
457
|
setGlobalId(id: string): void;
|
|
439
458
|
setTimeout(timeout: number): void;
|
|
@@ -460,12 +479,13 @@ declare class Task extends SignalParticipant implements Graph {
|
|
|
460
479
|
/**
|
|
461
480
|
* Executes the task function after optional input validation.
|
|
462
481
|
* @param context - The GraphContext to validate and execute.
|
|
482
|
+
* @param emit
|
|
463
483
|
* @param progressCallback - Callback for progress updates.
|
|
464
484
|
* @returns TaskResult from the taskFunction or error object on validation failure.
|
|
465
485
|
* @edge If validateInputContext is true, validates context; on failure, emits 'meta.task.validationFailed' with detailed errors.
|
|
466
486
|
* @edge If validateOutputContext is true, validates output; on failure, emits 'meta.task.outputValidationFailed' with detailed errors.
|
|
467
487
|
*/
|
|
468
|
-
execute(context: GraphContext, progressCallback: (progress: number) => void): TaskResult;
|
|
488
|
+
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void): TaskResult;
|
|
469
489
|
doAfter(...tasks: Task[]): this;
|
|
470
490
|
then(...tasks: Task[]): this;
|
|
471
491
|
decouple(task: Task): void;
|
|
@@ -708,18 +728,19 @@ declare class DebounceTask extends Task {
|
|
|
708
728
|
private lastContext;
|
|
709
729
|
private lastTimeout;
|
|
710
730
|
private lastProgressCallback;
|
|
731
|
+
private lastEmitFunction;
|
|
711
732
|
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, inputSchema?: SchemaDefinition | undefined, validateInputSchema?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputSchema?: boolean);
|
|
712
733
|
private executeFunction;
|
|
713
734
|
private debouncedTrigger;
|
|
714
|
-
execute(context: GraphContext, progressCallback: (progress: number) => void): TaskResult;
|
|
735
|
+
execute(context: GraphContext, emit: (signal: string, context: any) => void, progressCallback: (progress: number) => void): TaskResult;
|
|
715
736
|
}
|
|
716
737
|
|
|
717
738
|
declare class EphemeralTask extends Task {
|
|
718
739
|
private readonly once;
|
|
719
740
|
private readonly condition;
|
|
720
741
|
readonly isEphemeral: boolean;
|
|
721
|
-
constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean);
|
|
722
|
-
execute(context: any, progressCallback: (progress: number) => void): TaskResult;
|
|
742
|
+
constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
|
|
743
|
+
execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void): TaskResult;
|
|
723
744
|
}
|
|
724
745
|
|
|
725
746
|
declare class GraphAsyncRun extends GraphRunStrategy {
|
|
@@ -745,6 +766,10 @@ interface TaskOptions {
|
|
|
745
766
|
validateInputContext?: boolean;
|
|
746
767
|
outputSchema?: SchemaDefinition;
|
|
747
768
|
validateOutputContext?: boolean;
|
|
769
|
+
retryCount?: number;
|
|
770
|
+
retryDelay?: number;
|
|
771
|
+
retryDelayMax?: number;
|
|
772
|
+
retryDelayFactor?: number;
|
|
748
773
|
}
|
|
749
774
|
type CadenzaMode = "dev" | "debug" | "production";
|
|
750
775
|
declare class Cadenza {
|
package/dist/index.d.ts
CHANGED
|
@@ -119,13 +119,13 @@ declare abstract class SignalEmitter {
|
|
|
119
119
|
* @param data Optional payload (defaults to empty object).
|
|
120
120
|
* @edge No emission if silent; for metrics in silent mode, consider override or separate method.
|
|
121
121
|
*/
|
|
122
|
-
emit(signal: string, data?:
|
|
122
|
+
protected emit(signal: string, data?: AnyObject): void;
|
|
123
123
|
/**
|
|
124
124
|
* Emits a signal via the broker even if silent.
|
|
125
125
|
* @param signal The signal name.
|
|
126
126
|
* @param data Optional payload (defaults to empty object).
|
|
127
127
|
*/
|
|
128
|
-
emitMetric(signal: string, data?:
|
|
128
|
+
protected emitMetric(signal: string, data?: AnyObject): void;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
declare abstract class ExecutionChain {
|
|
@@ -195,6 +195,9 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
195
195
|
private subgraphComplete;
|
|
196
196
|
private graphComplete;
|
|
197
197
|
private result;
|
|
198
|
+
private retryCount;
|
|
199
|
+
private retryDelay;
|
|
200
|
+
private retries;
|
|
198
201
|
private previousNodes;
|
|
199
202
|
private nextNodes;
|
|
200
203
|
private executionTime;
|
|
@@ -222,11 +225,16 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
222
225
|
start(): number;
|
|
223
226
|
end(): number;
|
|
224
227
|
execute(): GraphNode[] | Promise<GraphNode[]>;
|
|
225
|
-
private
|
|
228
|
+
private workAsync;
|
|
229
|
+
private executeAsync;
|
|
226
230
|
private work;
|
|
231
|
+
protected emitWithMetadata(signal: string, context: AnyObject): void;
|
|
227
232
|
private onProgress;
|
|
228
233
|
private postProcess;
|
|
229
234
|
private onError;
|
|
235
|
+
private retry;
|
|
236
|
+
private retryAsync;
|
|
237
|
+
private delayRetry;
|
|
230
238
|
private divide;
|
|
231
239
|
private generateNewNodes;
|
|
232
240
|
private differentiate;
|
|
@@ -248,7 +256,7 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
248
256
|
__id: string;
|
|
249
257
|
__context: AnyObject;
|
|
250
258
|
};
|
|
251
|
-
__result:
|
|
259
|
+
__result: TaskResult;
|
|
252
260
|
__executionTime: number;
|
|
253
261
|
__executionStart: number;
|
|
254
262
|
__executionEnd: number;
|
|
@@ -308,7 +316,8 @@ declare class TaskIterator implements Iterator {
|
|
|
308
316
|
}
|
|
309
317
|
|
|
310
318
|
declare class SignalParticipant extends SignalEmitter {
|
|
311
|
-
protected
|
|
319
|
+
protected emitsSignals: Set<string>;
|
|
320
|
+
protected signalsToEmitAfter: Set<string>;
|
|
312
321
|
protected signalsToEmitOnFail: Set<string>;
|
|
313
322
|
protected observedSignals: Set<string>;
|
|
314
323
|
/**
|
|
@@ -323,7 +332,7 @@ declare class SignalParticipant extends SignalEmitter {
|
|
|
323
332
|
* @param signals The signal names.
|
|
324
333
|
* @returns This for chaining.
|
|
325
334
|
*/
|
|
326
|
-
|
|
335
|
+
emitsAfter(...signals: string[]): this;
|
|
327
336
|
emitsOnFail(...signals: string[]): this;
|
|
328
337
|
/**
|
|
329
338
|
* Unsubscribes from all observed signals.
|
|
@@ -348,6 +357,8 @@ declare class SignalParticipant extends SignalEmitter {
|
|
|
348
357
|
* @returns This for chaining.
|
|
349
358
|
*/
|
|
350
359
|
detachAllSignals(): this;
|
|
360
|
+
mapSignals(callback: (signal: string) => void): void[];
|
|
361
|
+
mapOnFailSignals(callback: (signal: string) => void): void[];
|
|
351
362
|
/**
|
|
352
363
|
* Emits attached signals.
|
|
353
364
|
* @param context The context for emission.
|
|
@@ -390,8 +401,8 @@ type SchemaDefinition = {
|
|
|
390
401
|
strict?: boolean;
|
|
391
402
|
};
|
|
392
403
|
|
|
393
|
-
type TaskFunction = (context: AnyObject, progressCallback: (progress: number) => void) => TaskResult;
|
|
394
|
-
type TaskResult = boolean |
|
|
404
|
+
type TaskFunction = (context: AnyObject, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void) => TaskResult;
|
|
405
|
+
type TaskResult = boolean | AnyObject | Generator | Promise<any> | void;
|
|
395
406
|
type ThrottleTagGetter = (context?: AnyObject, task?: Task) => string;
|
|
396
407
|
declare class Task extends SignalParticipant implements Graph {
|
|
397
408
|
id: string;
|
|
@@ -409,6 +420,10 @@ declare class Task extends SignalParticipant implements Graph {
|
|
|
409
420
|
protected validateInputContext: boolean;
|
|
410
421
|
protected outputContextSchema: SchemaDefinition | undefined;
|
|
411
422
|
protected validateOutputContext: boolean;
|
|
423
|
+
readonly retryCount: number;
|
|
424
|
+
readonly retryDelay: number;
|
|
425
|
+
readonly retryDelayMax: number;
|
|
426
|
+
readonly retryDelayFactor: number;
|
|
412
427
|
layerIndex: number;
|
|
413
428
|
progressWeight: number;
|
|
414
429
|
private nextTasks;
|
|
@@ -431,9 +446,13 @@ declare class Task extends SignalParticipant implements Graph {
|
|
|
431
446
|
* @param validateInputContext
|
|
432
447
|
* @param outputSchema
|
|
433
448
|
* @param validateOutputContext
|
|
449
|
+
* @param retryCount
|
|
450
|
+
* @param retryDelay
|
|
451
|
+
* @param retryDelayMax
|
|
452
|
+
* @param retryDelayFactor
|
|
434
453
|
* @edge Emits 'meta.task.created' with { __task: this } for seed.
|
|
435
454
|
*/
|
|
436
|
-
constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean);
|
|
455
|
+
constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
|
|
437
456
|
getTag(context?: AnyObject): string;
|
|
438
457
|
setGlobalId(id: string): void;
|
|
439
458
|
setTimeout(timeout: number): void;
|
|
@@ -460,12 +479,13 @@ declare class Task extends SignalParticipant implements Graph {
|
|
|
460
479
|
/**
|
|
461
480
|
* Executes the task function after optional input validation.
|
|
462
481
|
* @param context - The GraphContext to validate and execute.
|
|
482
|
+
* @param emit
|
|
463
483
|
* @param progressCallback - Callback for progress updates.
|
|
464
484
|
* @returns TaskResult from the taskFunction or error object on validation failure.
|
|
465
485
|
* @edge If validateInputContext is true, validates context; on failure, emits 'meta.task.validationFailed' with detailed errors.
|
|
466
486
|
* @edge If validateOutputContext is true, validates output; on failure, emits 'meta.task.outputValidationFailed' with detailed errors.
|
|
467
487
|
*/
|
|
468
|
-
execute(context: GraphContext, progressCallback: (progress: number) => void): TaskResult;
|
|
488
|
+
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void): TaskResult;
|
|
469
489
|
doAfter(...tasks: Task[]): this;
|
|
470
490
|
then(...tasks: Task[]): this;
|
|
471
491
|
decouple(task: Task): void;
|
|
@@ -708,18 +728,19 @@ declare class DebounceTask extends Task {
|
|
|
708
728
|
private lastContext;
|
|
709
729
|
private lastTimeout;
|
|
710
730
|
private lastProgressCallback;
|
|
731
|
+
private lastEmitFunction;
|
|
711
732
|
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, inputSchema?: SchemaDefinition | undefined, validateInputSchema?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputSchema?: boolean);
|
|
712
733
|
private executeFunction;
|
|
713
734
|
private debouncedTrigger;
|
|
714
|
-
execute(context: GraphContext, progressCallback: (progress: number) => void): TaskResult;
|
|
735
|
+
execute(context: GraphContext, emit: (signal: string, context: any) => void, progressCallback: (progress: number) => void): TaskResult;
|
|
715
736
|
}
|
|
716
737
|
|
|
717
738
|
declare class EphemeralTask extends Task {
|
|
718
739
|
private readonly once;
|
|
719
740
|
private readonly condition;
|
|
720
741
|
readonly isEphemeral: boolean;
|
|
721
|
-
constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean);
|
|
722
|
-
execute(context: any, progressCallback: (progress: number) => void): TaskResult;
|
|
742
|
+
constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, getTagCallback?: ThrottleTagGetter | undefined, inputSchema?: SchemaDefinition | undefined, validateInputContext?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputContext?: boolean, retryCount?: number, retryDelay?: number, retryDelayMax?: number, retryDelayFactor?: number);
|
|
743
|
+
execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void): TaskResult;
|
|
723
744
|
}
|
|
724
745
|
|
|
725
746
|
declare class GraphAsyncRun extends GraphRunStrategy {
|
|
@@ -745,6 +766,10 @@ interface TaskOptions {
|
|
|
745
766
|
validateInputContext?: boolean;
|
|
746
767
|
outputSchema?: SchemaDefinition;
|
|
747
768
|
validateOutputContext?: boolean;
|
|
769
|
+
retryCount?: number;
|
|
770
|
+
retryDelay?: number;
|
|
771
|
+
retryDelayMax?: number;
|
|
772
|
+
retryDelayFactor?: number;
|
|
748
773
|
}
|
|
749
774
|
type CadenzaMode = "dev" | "debug" | "production";
|
|
750
775
|
declare class Cadenza {
|