@cadenza.io/core 3.7.0 → 3.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 +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +41 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -441,11 +441,15 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
441
441
|
* @param context - The GraphContext to validate and execute.
|
|
442
442
|
* @param emit
|
|
443
443
|
* @param progressCallback - Callback for progress updates.
|
|
444
|
+
* @param nodeData
|
|
444
445
|
* @returns TaskResult from the taskFunction or error object on validation failure.
|
|
445
446
|
* @edge If validateInputContext is true, validates context; on failure, emits 'meta.task.validationFailed' with detailed errors.
|
|
446
447
|
* @edge If validateOutputContext is true, validates output; on failure, emits 'meta.task.outputValidationFailed' with detailed errors.
|
|
447
448
|
*/
|
|
448
|
-
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void
|
|
449
|
+
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void, nodeData: {
|
|
450
|
+
nodeId: string;
|
|
451
|
+
routineExecId: string;
|
|
452
|
+
}): TaskResult;
|
|
449
453
|
doAfter(...tasks: Task[]): this;
|
|
450
454
|
then(...tasks: Task[]): this;
|
|
451
455
|
decouple(task: Task): void;
|
|
@@ -779,7 +783,10 @@ declare class EphemeralTask extends Task {
|
|
|
779
783
|
readonly condition: (context: any) => boolean;
|
|
780
784
|
readonly isEphemeral: boolean;
|
|
781
785
|
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);
|
|
782
|
-
execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void
|
|
786
|
+
execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void, nodeData: {
|
|
787
|
+
nodeId: string;
|
|
788
|
+
routineExecId: string;
|
|
789
|
+
}): TaskResult;
|
|
783
790
|
}
|
|
784
791
|
|
|
785
792
|
declare class GraphAsyncRun extends GraphRunStrategy {
|
package/dist/index.d.ts
CHANGED
|
@@ -441,11 +441,15 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
441
441
|
* @param context - The GraphContext to validate and execute.
|
|
442
442
|
* @param emit
|
|
443
443
|
* @param progressCallback - Callback for progress updates.
|
|
444
|
+
* @param nodeData
|
|
444
445
|
* @returns TaskResult from the taskFunction or error object on validation failure.
|
|
445
446
|
* @edge If validateInputContext is true, validates context; on failure, emits 'meta.task.validationFailed' with detailed errors.
|
|
446
447
|
* @edge If validateOutputContext is true, validates output; on failure, emits 'meta.task.outputValidationFailed' with detailed errors.
|
|
447
448
|
*/
|
|
448
|
-
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void
|
|
449
|
+
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void, nodeData: {
|
|
450
|
+
nodeId: string;
|
|
451
|
+
routineExecId: string;
|
|
452
|
+
}): TaskResult;
|
|
449
453
|
doAfter(...tasks: Task[]): this;
|
|
450
454
|
then(...tasks: Task[]): this;
|
|
451
455
|
decouple(task: Task): void;
|
|
@@ -779,7 +783,10 @@ declare class EphemeralTask extends Task {
|
|
|
779
783
|
readonly condition: (context: any) => boolean;
|
|
780
784
|
readonly isEphemeral: boolean;
|
|
781
785
|
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);
|
|
782
|
-
execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void
|
|
786
|
+
execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void, nodeData: {
|
|
787
|
+
nodeId: string;
|
|
788
|
+
routineExecId: string;
|
|
789
|
+
}): TaskResult;
|
|
783
790
|
}
|
|
784
791
|
|
|
785
792
|
declare class GraphAsyncRun extends GraphRunStrategy {
|
package/dist/index.js
CHANGED
|
@@ -256,10 +256,25 @@ var SignalBroker = class _SignalBroker {
|
|
|
256
256
|
}
|
|
257
257
|
executeListener(signal, context) {
|
|
258
258
|
const obs = this.signalObservers.get(signal);
|
|
259
|
+
if (!obs || obs.tasks.size === 0) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
259
262
|
const isMeta = signal.startsWith("meta");
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
if (!isMeta) {
|
|
264
|
+
const tasks = [];
|
|
265
|
+
const metaTasks = [];
|
|
266
|
+
obs.tasks.forEach(
|
|
267
|
+
(task) => task.isMeta ? metaTasks.push(task) : tasks.push(task)
|
|
268
|
+
);
|
|
269
|
+
if (tasks.length && this.runner) {
|
|
270
|
+
obs.fn(this.runner, tasks, context);
|
|
271
|
+
}
|
|
272
|
+
if (metaTasks.length && this.metaRunner) {
|
|
273
|
+
obs.fn(this.metaRunner, metaTasks, context);
|
|
274
|
+
}
|
|
275
|
+
return true;
|
|
276
|
+
} else if (this.metaRunner) {
|
|
277
|
+
obs.fn(this.metaRunner, Array.from(obs.tasks), context);
|
|
263
278
|
return true;
|
|
264
279
|
}
|
|
265
280
|
return false;
|
|
@@ -838,6 +853,23 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
838
853
|
}
|
|
839
854
|
});
|
|
840
855
|
});
|
|
856
|
+
if (context.__previousTaskExecutionId) {
|
|
857
|
+
this.emitMetricsWithMetadata(
|
|
858
|
+
"meta.node.detected_previous_task_execution",
|
|
859
|
+
{
|
|
860
|
+
data: {
|
|
861
|
+
taskExecutionId: this.id,
|
|
862
|
+
previousTaskExecutionId: context.__previousTaskExecutionId
|
|
863
|
+
},
|
|
864
|
+
filter: {
|
|
865
|
+
taskName: this.task.name,
|
|
866
|
+
taskVersion: this.task.version
|
|
867
|
+
},
|
|
868
|
+
...context
|
|
869
|
+
}
|
|
870
|
+
);
|
|
871
|
+
context.__previousTaskExecutionId = null;
|
|
872
|
+
}
|
|
841
873
|
if (context.__signalEmission?.consumed === false && (!this.isMeta() || this.debug)) {
|
|
842
874
|
this.emitMetricsWithMetadata("meta.node.consumed_signal", {
|
|
843
875
|
data: {
|
|
@@ -983,7 +1015,8 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
983
1015
|
const result = this.task.execute(
|
|
984
1016
|
this.context,
|
|
985
1017
|
this.emitWithMetadata.bind(this),
|
|
986
|
-
this.onProgress.bind(this)
|
|
1018
|
+
this.onProgress.bind(this),
|
|
1019
|
+
{ nodeId: this.id, routineExecId: this.routineExecId }
|
|
987
1020
|
);
|
|
988
1021
|
if (result?.errored || result?.failed) {
|
|
989
1022
|
return this.retry(result);
|
|
@@ -1015,9 +1048,6 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1015
1048
|
};
|
|
1016
1049
|
}
|
|
1017
1050
|
this.emit(signal, data);
|
|
1018
|
-
if (!this.task.emitsSignals.has(signal)) {
|
|
1019
|
-
this.task.attachSignal(signal);
|
|
1020
|
-
}
|
|
1021
1051
|
}
|
|
1022
1052
|
emitMetricsWithMetadata(signal, data) {
|
|
1023
1053
|
if (!this.task?.isHidden) {
|
|
@@ -1035,9 +1065,6 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1035
1065
|
};
|
|
1036
1066
|
}
|
|
1037
1067
|
this.emitMetrics(signal, data);
|
|
1038
|
-
if (!this.task.emitsSignals.has(signal)) {
|
|
1039
|
-
this.task.attachSignal(signal);
|
|
1040
|
-
}
|
|
1041
1068
|
}
|
|
1042
1069
|
onProgress(progress) {
|
|
1043
1070
|
progress = Math.min(Math.max(0, progress), 1);
|
|
@@ -1845,11 +1872,12 @@ var Task = class extends SignalEmitter {
|
|
|
1845
1872
|
* @param context - The GraphContext to validate and execute.
|
|
1846
1873
|
* @param emit
|
|
1847
1874
|
* @param progressCallback - Callback for progress updates.
|
|
1875
|
+
* @param nodeData
|
|
1848
1876
|
* @returns TaskResult from the taskFunction or error object on validation failure.
|
|
1849
1877
|
* @edge If validateInputContext is true, validates context; on failure, emits 'meta.task.validationFailed' with detailed errors.
|
|
1850
1878
|
* @edge If validateOutputContext is true, validates output; on failure, emits 'meta.task.outputValidationFailed' with detailed errors.
|
|
1851
1879
|
*/
|
|
1852
|
-
execute(context, emit, progressCallback) {
|
|
1880
|
+
execute(context, emit, progressCallback, nodeData) {
|
|
1853
1881
|
return this.taskFunction(
|
|
1854
1882
|
this.isMeta ? context.getClonedFullContext() : context.getClonedContext(),
|
|
1855
1883
|
emit,
|
|
@@ -2667,8 +2695,8 @@ var EphemeralTask = class extends Task {
|
|
|
2667
2695
|
this.once = once;
|
|
2668
2696
|
this.condition = condition;
|
|
2669
2697
|
}
|
|
2670
|
-
execute(context, emit, progressCallback) {
|
|
2671
|
-
const result = super.execute(context, emit, progressCallback);
|
|
2698
|
+
execute(context, emit, progressCallback, nodeData) {
|
|
2699
|
+
const result = super.execute(context, emit, progressCallback, nodeData);
|
|
2672
2700
|
if (this.once || this.condition(result)) {
|
|
2673
2701
|
this.destroy();
|
|
2674
2702
|
}
|