@cadenza.io/core 3.13.1 → 3.13.3
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/README.md +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -937,7 +937,7 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
937
937
|
* @return {this} The current task instance for method chaining.
|
|
938
938
|
* @throws {Error} Throws an error if adding a predecessor creates a cycle in the task structure.
|
|
939
939
|
*/
|
|
940
|
-
doAfter(...tasks: Task[]): this;
|
|
940
|
+
doAfter(...tasks: (Task | undefined)[]): this;
|
|
941
941
|
/**
|
|
942
942
|
* Adds a sequence of tasks as successors to the current task, ensuring no cyclic dependencies are introduced.
|
|
943
943
|
* Metrics are emitted when a relationship is successfully added.
|
|
@@ -946,7 +946,7 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
946
946
|
* @return {this} Returns the current task instance for method chaining.
|
|
947
947
|
* @throws {Error} Throws an error if adding a task causes a cyclic dependency.
|
|
948
948
|
*/
|
|
949
|
-
then(...tasks: Task[]): this;
|
|
949
|
+
then(...tasks: (Task | undefined)[]): this;
|
|
950
950
|
/**
|
|
951
951
|
* Decouples the current task from the provided task by removing mutual references.
|
|
952
952
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -937,7 +937,7 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
937
937
|
* @return {this} The current task instance for method chaining.
|
|
938
938
|
* @throws {Error} Throws an error if adding a predecessor creates a cycle in the task structure.
|
|
939
939
|
*/
|
|
940
|
-
doAfter(...tasks: Task[]): this;
|
|
940
|
+
doAfter(...tasks: (Task | undefined)[]): this;
|
|
941
941
|
/**
|
|
942
942
|
* Adds a sequence of tasks as successors to the current task, ensuring no cyclic dependencies are introduced.
|
|
943
943
|
* Metrics are emitted when a relationship is successfully added.
|
|
@@ -946,7 +946,7 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
946
946
|
* @return {this} Returns the current task instance for method chaining.
|
|
947
947
|
* @throws {Error} Throws an error if adding a task causes a cyclic dependency.
|
|
948
948
|
*/
|
|
949
|
-
then(...tasks: Task[]): this;
|
|
949
|
+
then(...tasks: (Task | undefined)[]): this;
|
|
950
950
|
/**
|
|
951
951
|
* Decouples the current task from the provided task by removing mutual references.
|
|
952
952
|
*
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ function deepCloneFilter(input, filterOut = () => false) {
|
|
|
50
50
|
const currentTarget = key !== void 0 ? target[key] : target;
|
|
51
51
|
if (
|
|
52
52
|
// TODO Should probably not be done like this...
|
|
53
|
-
key === "
|
|
53
|
+
key === "taskInstance" || key === "routineInstance" || key === "task" || key === "routine" || key === "tasks" || key === "routines" || key === "httpServer" || key === "httpsServer"
|
|
54
54
|
) {
|
|
55
55
|
target[key] = source;
|
|
56
56
|
continue;
|
|
@@ -170,15 +170,15 @@ var SignalBroker = class _SignalBroker {
|
|
|
170
170
|
}
|
|
171
171
|
}));
|
|
172
172
|
return {
|
|
173
|
-
|
|
173
|
+
signals: processedSignals,
|
|
174
174
|
...ctx
|
|
175
175
|
};
|
|
176
176
|
});
|
|
177
177
|
this.registerSignalTask = Cadenza.createMetaTask(
|
|
178
178
|
"Register signal",
|
|
179
179
|
(ctx) => {
|
|
180
|
-
const {
|
|
181
|
-
this.signalObservers.get(
|
|
180
|
+
const { signalName } = ctx;
|
|
181
|
+
this.signalObservers.get(signalName).registered = true;
|
|
182
182
|
}
|
|
183
183
|
).doOn("meta.signal.registered");
|
|
184
184
|
}
|
|
@@ -444,7 +444,7 @@ var SignalBroker = class _SignalBroker {
|
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
this.emit("meta.signal_broker.added", {
|
|
447
|
+
this.emit("meta.signal_broker.added", { signalName: _signal });
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
/**
|
|
@@ -1862,7 +1862,7 @@ var GraphRoutine = class extends SignalEmitter {
|
|
|
1862
1862
|
description: this.description,
|
|
1863
1863
|
isMeta: this.isMeta
|
|
1864
1864
|
},
|
|
1865
|
-
|
|
1865
|
+
routineInstance: this
|
|
1866
1866
|
});
|
|
1867
1867
|
tasks.forEach((t) => {
|
|
1868
1868
|
this.tasks.add(t);
|
|
@@ -2109,7 +2109,7 @@ var Task = class _Task extends SignalEmitter {
|
|
|
2109
2109
|
// inputContextSchemaId: this.inputContextSchema,
|
|
2110
2110
|
// outputContextSchemaId: this.outputContextSchema,
|
|
2111
2111
|
},
|
|
2112
|
-
|
|
2112
|
+
taskInstance: this,
|
|
2113
2113
|
__isSubMeta: this.isSubMeta
|
|
2114
2114
|
});
|
|
2115
2115
|
}
|
|
@@ -2420,6 +2420,7 @@ var Task = class _Task extends SignalEmitter {
|
|
|
2420
2420
|
*/
|
|
2421
2421
|
doAfter(...tasks) {
|
|
2422
2422
|
for (const pred of tasks) {
|
|
2423
|
+
if (!pred) continue;
|
|
2423
2424
|
if (this.predecessorTasks.has(pred)) continue;
|
|
2424
2425
|
pred.nextTasks.add(this);
|
|
2425
2426
|
this.predecessorTasks.add(pred);
|
|
@@ -2450,6 +2451,7 @@ var Task = class _Task extends SignalEmitter {
|
|
|
2450
2451
|
*/
|
|
2451
2452
|
then(...tasks) {
|
|
2452
2453
|
for (const next of tasks) {
|
|
2454
|
+
if (!next) continue;
|
|
2453
2455
|
if (this.nextTasks.has(next)) continue;
|
|
2454
2456
|
this.nextTasks.add(next);
|
|
2455
2457
|
next.predecessorTasks.add(this);
|
|
@@ -2908,11 +2910,11 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2908
2910
|
this.registerTask = new Task(
|
|
2909
2911
|
"Register task",
|
|
2910
2912
|
(context) => {
|
|
2911
|
-
const {
|
|
2912
|
-
if (
|
|
2913
|
-
this.tasks.set(
|
|
2913
|
+
const { taskInstance } = context;
|
|
2914
|
+
if (taskInstance && !this.tasks.has(taskInstance.name)) {
|
|
2915
|
+
this.tasks.set(taskInstance.name, taskInstance);
|
|
2914
2916
|
}
|
|
2915
|
-
delete context.
|
|
2917
|
+
delete context.taskInstance;
|
|
2916
2918
|
return true;
|
|
2917
2919
|
},
|
|
2918
2920
|
"Registers tasks. Seed for meta.taskCreated",
|
|
@@ -2951,7 +2953,7 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2951
2953
|
const { __name } = context;
|
|
2952
2954
|
for (const task of this.tasks.values()) {
|
|
2953
2955
|
if (task.name === __name) {
|
|
2954
|
-
return { ...context,
|
|
2956
|
+
return { ...context, task };
|
|
2955
2957
|
}
|
|
2956
2958
|
}
|
|
2957
2959
|
return false;
|
|
@@ -2965,13 +2967,13 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2965
2967
|
const layerTasks = Array.from(this.tasks.values()).filter(
|
|
2966
2968
|
(task) => task.layerIndex === __layerIndex
|
|
2967
2969
|
);
|
|
2968
|
-
return { ...context,
|
|
2970
|
+
return { ...context, tasks: layerTasks };
|
|
2969
2971
|
},
|
|
2970
2972
|
"Gets tasks by layer index."
|
|
2971
2973
|
);
|
|
2972
2974
|
this.getAllTasks = Cadenza.createMetaTask(
|
|
2973
2975
|
"Get all tasks",
|
|
2974
|
-
(context) => ({ ...context,
|
|
2976
|
+
(context) => ({ ...context, tasks: Array.from(this.tasks.values()) }),
|
|
2975
2977
|
// Use arrow to capture this
|
|
2976
2978
|
"Gets all tasks."
|
|
2977
2979
|
);
|
|
@@ -2979,7 +2981,7 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2979
2981
|
"Do for each task",
|
|
2980
2982
|
function* (context) {
|
|
2981
2983
|
for (const task of this.tasks.values()) {
|
|
2982
|
-
yield { ...context,
|
|
2984
|
+
yield { ...context, task };
|
|
2983
2985
|
}
|
|
2984
2986
|
}.bind(this),
|
|
2985
2987
|
// Bind to capture this in generator
|
|
@@ -2997,11 +2999,11 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2997
2999
|
this.registerRoutine = Cadenza.createMetaTask(
|
|
2998
3000
|
"Register routine",
|
|
2999
3001
|
(context) => {
|
|
3000
|
-
const {
|
|
3001
|
-
if (
|
|
3002
|
-
this.routines.set(
|
|
3002
|
+
const { routineInstance } = context;
|
|
3003
|
+
if (routineInstance && !this.routines.has(routineInstance.name)) {
|
|
3004
|
+
this.routines.set(routineInstance.name, routineInstance);
|
|
3003
3005
|
}
|
|
3004
|
-
delete context.
|
|
3006
|
+
delete context.routineInstance;
|
|
3005
3007
|
return true;
|
|
3006
3008
|
},
|
|
3007
3009
|
"Registers routine."
|
|
@@ -3012,7 +3014,7 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
3012
3014
|
const { __name } = context;
|
|
3013
3015
|
for (const routine of this.routines.values()) {
|
|
3014
3016
|
if (routine.name === __name) {
|
|
3015
|
-
return { ...context,
|
|
3017
|
+
return { ...context, routine };
|
|
3016
3018
|
}
|
|
3017
3019
|
}
|
|
3018
3020
|
return false;
|
|
@@ -3023,7 +3025,7 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
3023
3025
|
"Get all routines",
|
|
3024
3026
|
(context) => ({
|
|
3025
3027
|
...context,
|
|
3026
|
-
|
|
3028
|
+
routines: Array.from(this.routines.values())
|
|
3027
3029
|
}),
|
|
3028
3030
|
// Use arrow to capture this
|
|
3029
3031
|
"Gets all routines."
|
|
@@ -3032,7 +3034,7 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
3032
3034
|
"Do for each routine",
|
|
3033
3035
|
function* (context) {
|
|
3034
3036
|
for (const routine of this.routines.values()) {
|
|
3035
|
-
yield { ...context,
|
|
3037
|
+
yield { ...context, routine };
|
|
3036
3038
|
}
|
|
3037
3039
|
}.bind(this),
|
|
3038
3040
|
"Yields each routine."
|
|
@@ -3239,10 +3241,10 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
3239
3241
|
}
|
|
3240
3242
|
// TODO This should not live here. This is deputy related.
|
|
3241
3243
|
startRun(context, emit) {
|
|
3242
|
-
if (context.
|
|
3243
|
-
const routine = context.
|
|
3244
|
-
delete context.
|
|
3245
|
-
delete context.
|
|
3244
|
+
if (context.task || context.routine) {
|
|
3245
|
+
const routine = context.task ?? context.routine;
|
|
3246
|
+
delete context.task;
|
|
3247
|
+
delete context.routine;
|
|
3246
3248
|
context.__routineExecId = context.__metadata?.__deputyExecId ?? null;
|
|
3247
3249
|
context.__isDeputy = true;
|
|
3248
3250
|
this.run(routine, context);
|