@cadenza.io/core 3.15.5 → 3.15.9
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 +1 -20
- package/dist/index.d.ts +1 -20
- package/dist/index.js +59 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -46,17 +46,6 @@ declare class GraphContext {
|
|
|
46
46
|
* @returns Frozen metadata object.
|
|
47
47
|
*/
|
|
48
48
|
getMetadata(): AnyObject;
|
|
49
|
-
/**
|
|
50
|
-
* Clones this context (new instance).
|
|
51
|
-
* @returns New GraphContext.
|
|
52
|
-
*/
|
|
53
|
-
clone(): GraphContext;
|
|
54
|
-
/**
|
|
55
|
-
* Creates new context from data (via registry).
|
|
56
|
-
* @param context New data.
|
|
57
|
-
* @returns New GraphContext.
|
|
58
|
-
*/
|
|
59
|
-
mutate(context: AnyObject): GraphContext;
|
|
60
49
|
/**
|
|
61
50
|
* Combines the current GraphContext with another GraphContext, merging their user data
|
|
62
51
|
* and full context into a new GraphContext instance.
|
|
@@ -814,7 +803,6 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
814
803
|
layerIndex: number;
|
|
815
804
|
progressWeight: number;
|
|
816
805
|
nextTasks: Set<Task>;
|
|
817
|
-
onFailTasks: Set<Task>;
|
|
818
806
|
predecessorTasks: Set<Task>;
|
|
819
807
|
destroyed: boolean;
|
|
820
808
|
register: boolean;
|
|
@@ -989,10 +977,9 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
989
977
|
* Maps over the next set of tasks or failed tasks if specified, applying the provided callback function.
|
|
990
978
|
*
|
|
991
979
|
* @param {Function} callback A function that will be called with each task, transforming the task as needed. It receives a single parameter of type Task.
|
|
992
|
-
* @param {boolean} [failed=false] A boolean that determines whether to map over the failed tasks (true) or the next tasks (false).
|
|
993
980
|
* @return {any[]} An array of transformed tasks resulting from applying the callback function.
|
|
994
981
|
*/
|
|
995
|
-
mapNext(callback: (task: Task) => any
|
|
982
|
+
mapNext(callback: (task: Task) => any): any[];
|
|
996
983
|
/**
|
|
997
984
|
* Maps through each task in the set of predecessor tasks and applies the provided callback function.
|
|
998
985
|
*
|
|
@@ -1527,12 +1514,6 @@ declare class SignalBroker {
|
|
|
1527
1514
|
* @return {void} This method does not return any value.
|
|
1528
1515
|
*/
|
|
1529
1516
|
addSignal(signal: string): void;
|
|
1530
|
-
/**
|
|
1531
|
-
* Lists all observed signals.
|
|
1532
|
-
* @returns Array of signals.
|
|
1533
|
-
*/
|
|
1534
|
-
listObservedSignals(): string[];
|
|
1535
|
-
listEmittedSignals(): string[];
|
|
1536
1517
|
reset(): void;
|
|
1537
1518
|
}
|
|
1538
1519
|
|
package/dist/index.d.ts
CHANGED
|
@@ -46,17 +46,6 @@ declare class GraphContext {
|
|
|
46
46
|
* @returns Frozen metadata object.
|
|
47
47
|
*/
|
|
48
48
|
getMetadata(): AnyObject;
|
|
49
|
-
/**
|
|
50
|
-
* Clones this context (new instance).
|
|
51
|
-
* @returns New GraphContext.
|
|
52
|
-
*/
|
|
53
|
-
clone(): GraphContext;
|
|
54
|
-
/**
|
|
55
|
-
* Creates new context from data (via registry).
|
|
56
|
-
* @param context New data.
|
|
57
|
-
* @returns New GraphContext.
|
|
58
|
-
*/
|
|
59
|
-
mutate(context: AnyObject): GraphContext;
|
|
60
49
|
/**
|
|
61
50
|
* Combines the current GraphContext with another GraphContext, merging their user data
|
|
62
51
|
* and full context into a new GraphContext instance.
|
|
@@ -814,7 +803,6 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
814
803
|
layerIndex: number;
|
|
815
804
|
progressWeight: number;
|
|
816
805
|
nextTasks: Set<Task>;
|
|
817
|
-
onFailTasks: Set<Task>;
|
|
818
806
|
predecessorTasks: Set<Task>;
|
|
819
807
|
destroyed: boolean;
|
|
820
808
|
register: boolean;
|
|
@@ -989,10 +977,9 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
989
977
|
* Maps over the next set of tasks or failed tasks if specified, applying the provided callback function.
|
|
990
978
|
*
|
|
991
979
|
* @param {Function} callback A function that will be called with each task, transforming the task as needed. It receives a single parameter of type Task.
|
|
992
|
-
* @param {boolean} [failed=false] A boolean that determines whether to map over the failed tasks (true) or the next tasks (false).
|
|
993
980
|
* @return {any[]} An array of transformed tasks resulting from applying the callback function.
|
|
994
981
|
*/
|
|
995
|
-
mapNext(callback: (task: Task) => any
|
|
982
|
+
mapNext(callback: (task: Task) => any): any[];
|
|
996
983
|
/**
|
|
997
984
|
* Maps through each task in the set of predecessor tasks and applies the provided callback function.
|
|
998
985
|
*
|
|
@@ -1527,12 +1514,6 @@ declare class SignalBroker {
|
|
|
1527
1514
|
* @return {void} This method does not return any value.
|
|
1528
1515
|
*/
|
|
1529
1516
|
addSignal(signal: string): void;
|
|
1530
|
-
/**
|
|
1531
|
-
* Lists all observed signals.
|
|
1532
|
-
* @returns Array of signals.
|
|
1533
|
-
*/
|
|
1534
|
-
listObservedSignals(): string[];
|
|
1535
|
-
listEmittedSignals(): string[];
|
|
1536
1517
|
reset(): void;
|
|
1537
1518
|
}
|
|
1538
1519
|
|
package/dist/index.js
CHANGED
|
@@ -657,16 +657,6 @@ var SignalBroker = class _SignalBroker {
|
|
|
657
657
|
this.emit("meta.signal_broker.added", { signalName: _signal });
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
|
-
/**
|
|
661
|
-
* Lists all observed signals.
|
|
662
|
-
* @returns Array of signals.
|
|
663
|
-
*/
|
|
664
|
-
listObservedSignals() {
|
|
665
|
-
return Array.from(this.signalObservers.keys());
|
|
666
|
-
}
|
|
667
|
-
listEmittedSignals() {
|
|
668
|
-
return Array.from(this.emittedSignalsRegistry);
|
|
669
|
-
}
|
|
670
660
|
reset() {
|
|
671
661
|
this.signalObservers.clear();
|
|
672
662
|
this.emittedSignalsRegistry.clear();
|
|
@@ -978,21 +968,6 @@ var GraphContext = class _GraphContext {
|
|
|
978
968
|
getMetadata() {
|
|
979
969
|
return this.metadata;
|
|
980
970
|
}
|
|
981
|
-
/**
|
|
982
|
-
* Clones this context (new instance).
|
|
983
|
-
* @returns New GraphContext.
|
|
984
|
-
*/
|
|
985
|
-
clone() {
|
|
986
|
-
return this.mutate(this.fullContext);
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Creates new context from data (via registry).
|
|
990
|
-
* @param context New data.
|
|
991
|
-
* @returns New GraphContext.
|
|
992
|
-
*/
|
|
993
|
-
mutate(context) {
|
|
994
|
-
return new _GraphContext(context);
|
|
995
|
-
}
|
|
996
971
|
/**
|
|
997
972
|
* Combines the current GraphContext with another GraphContext, merging their user data
|
|
998
973
|
* and full context into a new GraphContext instance.
|
|
@@ -1234,18 +1209,27 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1234
1209
|
this.layer = layer;
|
|
1235
1210
|
layer.add(this);
|
|
1236
1211
|
const context = this.context.getFullContext();
|
|
1212
|
+
let signalEmissionId = context.__signalEmissionId ?? null;
|
|
1213
|
+
delete context.__signalEmissionId;
|
|
1214
|
+
if (context.__signalEmission?.consumed === false && (!this.isMeta() || this.debug)) {
|
|
1215
|
+
signalEmissionId = context.__signalEmission.uuid;
|
|
1216
|
+
context.__signalEmission.consumed = true;
|
|
1217
|
+
context.__signalEmission.consumedBy = this.id;
|
|
1218
|
+
}
|
|
1237
1219
|
const scheduledAt = Date.now();
|
|
1238
1220
|
this.emitMetricsWithMetadata("meta.node.scheduled", {
|
|
1239
1221
|
data: {
|
|
1240
1222
|
uuid: this.id,
|
|
1241
1223
|
routineExecutionId: this.routineExecId,
|
|
1242
1224
|
executionTraceId: this.executionTraceId,
|
|
1243
|
-
context: this.
|
|
1225
|
+
context: this.context.getContext(),
|
|
1226
|
+
metaContext: this.context.getMetadata(),
|
|
1244
1227
|
taskName: this.task.name,
|
|
1245
1228
|
taskVersion: this.task.version,
|
|
1246
1229
|
isMeta: this.isMeta(),
|
|
1247
1230
|
isScheduled: true,
|
|
1248
1231
|
splitGroupId: this.splitGroupId,
|
|
1232
|
+
signalEmissionId,
|
|
1249
1233
|
created: formatTimestamp(scheduledAt)
|
|
1250
1234
|
}
|
|
1251
1235
|
});
|
|
@@ -1273,30 +1257,14 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1273
1257
|
},
|
|
1274
1258
|
filter: {
|
|
1275
1259
|
taskName: this.task.name,
|
|
1276
|
-
taskVersion: this.task.version
|
|
1277
|
-
|
|
1278
|
-
|
|
1260
|
+
taskVersion: this.task.version,
|
|
1261
|
+
predecessorTaskName: context.__localTaskName,
|
|
1262
|
+
predecessorTaskVersion: context.__localTaskVersion
|
|
1263
|
+
}
|
|
1279
1264
|
}
|
|
1280
1265
|
);
|
|
1281
1266
|
context.__previousTaskExecutionId = null;
|
|
1282
1267
|
}
|
|
1283
|
-
if (context.__signalEmission?.consumed === false && (!this.isMeta() || this.debug)) {
|
|
1284
|
-
this.emitMetricsWithMetadata("meta.node.consumed_signal", {
|
|
1285
|
-
data: {
|
|
1286
|
-
signalEmissionId: context.__signalEmission.uuid,
|
|
1287
|
-
signalName: context.__signalEmission.signalName,
|
|
1288
|
-
signalTag: context.__signalEmission.signalTag,
|
|
1289
|
-
taskName: this.task.name,
|
|
1290
|
-
taskVersion: this.task.version,
|
|
1291
|
-
taskExecutionId: this.id,
|
|
1292
|
-
routineExecutionId: this.routineExecId,
|
|
1293
|
-
executionTraceId: this.executionTraceId,
|
|
1294
|
-
consumedAt: formatTimestamp(scheduledAt)
|
|
1295
|
-
}
|
|
1296
|
-
});
|
|
1297
|
-
context.__signalEmission.consumed = true;
|
|
1298
|
-
context.__signalEmission.consumedBy = this.id;
|
|
1299
|
-
}
|
|
1300
1268
|
}
|
|
1301
1269
|
}
|
|
1302
1270
|
/**
|
|
@@ -1366,7 +1334,8 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1366
1334
|
data: {
|
|
1367
1335
|
isRunning: false,
|
|
1368
1336
|
isComplete: true,
|
|
1369
|
-
resultContext: this.context.
|
|
1337
|
+
resultContext: this.context.getContext(),
|
|
1338
|
+
metaResultContext: this.context.getMetadata(),
|
|
1370
1339
|
errored: this.errored,
|
|
1371
1340
|
failed: this.failed,
|
|
1372
1341
|
errorMessage: context.__error,
|
|
@@ -1376,17 +1345,18 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1376
1345
|
filter: { uuid: this.id }
|
|
1377
1346
|
});
|
|
1378
1347
|
if (this.graphDone()) {
|
|
1379
|
-
const context2 = this.context.
|
|
1380
|
-
if (context2.
|
|
1348
|
+
const context2 = this.context.getFullContext();
|
|
1349
|
+
if (context2.__isDeputy)
|
|
1381
1350
|
this.emitWithMetadata(
|
|
1382
1351
|
`meta.node.graph_completed:${this.routineExecId}`,
|
|
1383
|
-
context2
|
|
1352
|
+
context2
|
|
1384
1353
|
);
|
|
1385
1354
|
this.emitMetricsWithMetadata("meta.node.ended_routine_execution", {
|
|
1386
1355
|
data: {
|
|
1387
1356
|
isRunning: false,
|
|
1388
1357
|
isComplete: true,
|
|
1389
|
-
resultContext: this.context.
|
|
1358
|
+
resultContext: this.context.getContext(),
|
|
1359
|
+
metaResultContext: this.context.getMetadata(),
|
|
1390
1360
|
progress: 1,
|
|
1391
1361
|
ended: formatTimestamp(end)
|
|
1392
1362
|
},
|
|
@@ -1750,14 +1720,6 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1750
1720
|
return newNodes;
|
|
1751
1721
|
}
|
|
1752
1722
|
}
|
|
1753
|
-
if (this.errored) {
|
|
1754
|
-
newNodes.push(
|
|
1755
|
-
...this.task.mapNext(
|
|
1756
|
-
(t) => this.clone().split((0, import_uuid4.v4)()).differentiate(t).migrate({ ...this.result }),
|
|
1757
|
-
true
|
|
1758
|
-
)
|
|
1759
|
-
);
|
|
1760
|
-
}
|
|
1761
1723
|
this.divided = true;
|
|
1762
1724
|
this.migrate({
|
|
1763
1725
|
...this.context.getFullContext(),
|
|
@@ -1805,19 +1767,20 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1805
1767
|
const groupId = (0, import_uuid4.v4)();
|
|
1806
1768
|
const newNodes = [];
|
|
1807
1769
|
if (typeof result !== "boolean") {
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1770
|
+
this.failed = result.failed !== void 0 && result.failed || result.error !== void 0;
|
|
1771
|
+
if (!this.failed) {
|
|
1772
|
+
newNodes.push(
|
|
1773
|
+
...this.task.mapNext((t) => {
|
|
1774
|
+
const context = t.isUnique ? {
|
|
1775
|
+
joinedContexts: [
|
|
1776
|
+
{ ...result, taskName: this.task.name, __nodeId: this.id }
|
|
1777
|
+
],
|
|
1778
|
+
...this.context.getMetadata()
|
|
1779
|
+
} : { ...result, ...this.context.getMetadata() };
|
|
1780
|
+
return this.clone().split(groupId).differentiate(t).migrate(context);
|
|
1781
|
+
})
|
|
1782
|
+
);
|
|
1783
|
+
}
|
|
1821
1784
|
} else {
|
|
1822
1785
|
const shouldContinue = result;
|
|
1823
1786
|
if (shouldContinue) {
|
|
@@ -2234,7 +2197,6 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
2234
2197
|
context.__routineExecId = routineExecId;
|
|
2235
2198
|
const ctx = new GraphContext(context || {});
|
|
2236
2199
|
if (!isSubMeta) {
|
|
2237
|
-
const contextData = ctx.export();
|
|
2238
2200
|
if (isNewTrace) {
|
|
2239
2201
|
this.emitMetrics("meta.runner.new_trace", {
|
|
2240
2202
|
data: {
|
|
@@ -2244,7 +2206,8 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
2244
2206
|
issuer_id: context.__metadata?.__issuerId ?? context.__issuerId ?? null,
|
|
2245
2207
|
issued_at: formatTimestamp(Date.now()),
|
|
2246
2208
|
intent: context.__metadata?.__intent ?? context.__intent ?? null,
|
|
2247
|
-
context:
|
|
2209
|
+
context: ctx.getContext(),
|
|
2210
|
+
metaContext: ctx.getMetadata(),
|
|
2248
2211
|
is_meta: isMeta
|
|
2249
2212
|
},
|
|
2250
2213
|
__metadata: {
|
|
@@ -2259,7 +2222,8 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
2259
2222
|
routineVersion,
|
|
2260
2223
|
isMeta,
|
|
2261
2224
|
executionTraceId,
|
|
2262
|
-
context:
|
|
2225
|
+
context: ctx.getContext(),
|
|
2226
|
+
metaContext: ctx.getMetadata(),
|
|
2263
2227
|
previousRoutineExecution: context.__localRoutineExecId ?? context.__metadata?.__routineExecId ?? null,
|
|
2264
2228
|
created: formatTimestamp(Date.now())
|
|
2265
2229
|
},
|
|
@@ -2430,7 +2394,6 @@ var Task = class _Task extends SignalEmitter {
|
|
|
2430
2394
|
this.layerIndex = 0;
|
|
2431
2395
|
this.progressWeight = 0;
|
|
2432
2396
|
this.nextTasks = /* @__PURE__ */ new Set();
|
|
2433
|
-
this.onFailTasks = /* @__PURE__ */ new Set();
|
|
2434
2397
|
this.predecessorTasks = /* @__PURE__ */ new Set();
|
|
2435
2398
|
this.destroyed = false;
|
|
2436
2399
|
this.register = true;
|
|
@@ -2511,9 +2474,13 @@ var Task = class _Task extends SignalEmitter {
|
|
|
2511
2474
|
isMeta: this.isMeta,
|
|
2512
2475
|
isSubMeta: this.isSubMeta,
|
|
2513
2476
|
validateInputContext: this.validateInputContext,
|
|
2514
|
-
validateOutputContext: this.validateOutputContext
|
|
2477
|
+
validateOutputContext: this.validateOutputContext,
|
|
2515
2478
|
// inputContextSchemaId: this.inputContextSchema,
|
|
2516
2479
|
// outputContextSchemaId: this.outputContextSchema,
|
|
2480
|
+
emitsSignals: Array.from(this.emitsSignals),
|
|
2481
|
+
signalsToEmitAfter: Array.from(this.signalsToEmitAfter),
|
|
2482
|
+
signalsToEmitOnFail: Array.from(this.signalsToEmitOnFail),
|
|
2483
|
+
observesSignals: Array.from(this.observedSignals)
|
|
2517
2484
|
},
|
|
2518
2485
|
taskInstance: this,
|
|
2519
2486
|
__isSubMeta: this.isSubMeta
|
|
@@ -2889,10 +2856,6 @@ var Task = class _Task extends SignalEmitter {
|
|
|
2889
2856
|
task.nextTasks.delete(this);
|
|
2890
2857
|
this.predecessorTasks.delete(task);
|
|
2891
2858
|
}
|
|
2892
|
-
if (task.onFailTasks.has(this)) {
|
|
2893
|
-
task.onFailTasks.delete(this);
|
|
2894
|
-
this.predecessorTasks.delete(task);
|
|
2895
|
-
}
|
|
2896
2859
|
this.updateLayerFromPredecessors();
|
|
2897
2860
|
}
|
|
2898
2861
|
/**
|
|
@@ -2991,11 +2954,10 @@ var Task = class _Task extends SignalEmitter {
|
|
|
2991
2954
|
* Maps over the next set of tasks or failed tasks if specified, applying the provided callback function.
|
|
2992
2955
|
*
|
|
2993
2956
|
* @param {Function} callback A function that will be called with each task, transforming the task as needed. It receives a single parameter of type Task.
|
|
2994
|
-
* @param {boolean} [failed=false] A boolean that determines whether to map over the failed tasks (true) or the next tasks (false).
|
|
2995
2957
|
* @return {any[]} An array of transformed tasks resulting from applying the callback function.
|
|
2996
2958
|
*/
|
|
2997
|
-
mapNext(callback
|
|
2998
|
-
const tasks =
|
|
2959
|
+
mapNext(callback) {
|
|
2960
|
+
const tasks = Array.from(this.nextTasks);
|
|
2999
2961
|
return tasks.map(callback);
|
|
3000
2962
|
}
|
|
3001
2963
|
/**
|
|
@@ -3082,13 +3044,20 @@ var Task = class _Task extends SignalEmitter {
|
|
|
3082
3044
|
this.emitsSignals.add(signal);
|
|
3083
3045
|
Cadenza.broker.registerEmittedSignal(signal);
|
|
3084
3046
|
if (this.register) {
|
|
3085
|
-
const
|
|
3047
|
+
const data = {
|
|
3048
|
+
emitsSignals: Array.from(this.emitsSignals)
|
|
3049
|
+
};
|
|
3050
|
+
if (this.signalsToEmitAfter.has(signal)) {
|
|
3051
|
+
data.emitsSignalsAfter = Array.from(this.signalsToEmitAfter);
|
|
3052
|
+
}
|
|
3053
|
+
if (this.signalsToEmitOnFail.has(signal)) {
|
|
3054
|
+
data.emitsSignalsOnFail = Array.from(this.signalsToEmitOnFail);
|
|
3055
|
+
}
|
|
3086
3056
|
this.emitWithMetadata("meta.task.attached_signal", {
|
|
3087
|
-
data
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
isOnFail
|
|
3057
|
+
data,
|
|
3058
|
+
filter: {
|
|
3059
|
+
name: this.name,
|
|
3060
|
+
version: this.version
|
|
3092
3061
|
}
|
|
3093
3062
|
});
|
|
3094
3063
|
}
|
|
@@ -3235,10 +3204,8 @@ var Task = class _Task extends SignalEmitter {
|
|
|
3235
3204
|
this.detachAllSignals();
|
|
3236
3205
|
this.predecessorTasks.forEach((pred) => pred.nextTasks.delete(this));
|
|
3237
3206
|
this.nextTasks.forEach((next) => next.predecessorTasks.delete(this));
|
|
3238
|
-
this.onFailTasks.forEach((fail) => fail.predecessorTasks.delete(this));
|
|
3239
3207
|
this.nextTasks.clear();
|
|
3240
3208
|
this.predecessorTasks.clear();
|
|
3241
|
-
this.onFailTasks.clear();
|
|
3242
3209
|
this.destroyed = true;
|
|
3243
3210
|
if (this.register) {
|
|
3244
3211
|
this.emitMetricsWithMetadata("meta.task.destroyed", {
|
|
@@ -3281,7 +3248,6 @@ var Task = class _Task extends SignalEmitter {
|
|
|
3281
3248
|
__outputSchema: this.outputContextSchema,
|
|
3282
3249
|
__validateOutputContext: this.validateOutputContext,
|
|
3283
3250
|
__nextTasks: Array.from(this.nextTasks).map((t) => t.name),
|
|
3284
|
-
__onFailTasks: Array.from(this.onFailTasks).map((t) => t.name),
|
|
3285
3251
|
__previousTasks: Array.from(this.predecessorTasks).map((t) => t.name)
|
|
3286
3252
|
};
|
|
3287
3253
|
}
|