@cadenza.io/core 1.12.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 +91 -84
- package/dist/index.d.ts +91 -84
- package/dist/index.js +306 -287
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +306 -286
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -89,7 +89,7 @@ var SignalBroker = class _SignalBroker {
|
|
|
89
89
|
this.metaRunner = metaRunner;
|
|
90
90
|
}
|
|
91
91
|
init() {
|
|
92
|
-
Cadenza.
|
|
92
|
+
Cadenza.createMetaTask(
|
|
93
93
|
"Execute and clear queued signals",
|
|
94
94
|
() => {
|
|
95
95
|
for (const [id, signals] of this.emitStacks.entries()) {
|
|
@@ -101,13 +101,8 @@ var SignalBroker = class _SignalBroker {
|
|
|
101
101
|
}
|
|
102
102
|
return true;
|
|
103
103
|
},
|
|
104
|
-
"Executes queued signals and clears the stack"
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
maxWait: 1e4,
|
|
108
|
-
leading: true
|
|
109
|
-
}
|
|
110
|
-
).doOn("meta.process_signal_queue_requested").emitsAfter("meta.signal_broker.queue_empty");
|
|
104
|
+
"Executes queued signals and clears the stack"
|
|
105
|
+
).doOn("meta.process_signal_queue_requested").emits("meta.signal_broker.queue_empty");
|
|
111
106
|
this.getSignalsTask = Cadenza.createMetaTask("Get signals", (ctx) => {
|
|
112
107
|
return {
|
|
113
108
|
__signals: Array.from(this.signalObservers.keys()),
|
|
@@ -246,7 +241,7 @@ var SignalBroker = class _SignalBroker {
|
|
|
246
241
|
};
|
|
247
242
|
|
|
248
243
|
// src/engine/GraphRunner.ts
|
|
249
|
-
import { v4 as
|
|
244
|
+
import { v4 as uuid4 } from "uuid";
|
|
250
245
|
|
|
251
246
|
// src/engine/GraphRun.ts
|
|
252
247
|
import { v4 as uuid } from "uuid";
|
|
@@ -332,10 +327,10 @@ var VueFlowExportVisitor = class {
|
|
|
332
327
|
}
|
|
333
328
|
visitNode(node) {
|
|
334
329
|
const snapshot = node.export();
|
|
335
|
-
if (!this.contextToColor[snapshot.__context.
|
|
336
|
-
this.contextToColor[snapshot.__context.
|
|
330
|
+
if (!this.contextToColor[snapshot.__context.id]) {
|
|
331
|
+
this.contextToColor[snapshot.__context.id] = this.colorRandomizer.getRandomColor();
|
|
337
332
|
}
|
|
338
|
-
const color = this.contextToColor[snapshot.__context.
|
|
333
|
+
const color = this.contextToColor[snapshot.__context.id];
|
|
339
334
|
this.elements.push({
|
|
340
335
|
id: snapshot.__id.slice(0, 8),
|
|
341
336
|
label: snapshot.__task.__name,
|
|
@@ -352,7 +347,7 @@ var VueFlowExportVisitor = class {
|
|
|
352
347
|
executionEnd: snapshot.__executionEnd,
|
|
353
348
|
description: snapshot.__task.__description,
|
|
354
349
|
functionString: snapshot.__task.__functionString,
|
|
355
|
-
context: snapshot.__context.
|
|
350
|
+
context: snapshot.__context.context,
|
|
356
351
|
layerIndex: snapshot.__task.__layerIndex
|
|
357
352
|
}
|
|
358
353
|
});
|
|
@@ -420,11 +415,11 @@ var VueFlowExporter = class {
|
|
|
420
415
|
continue;
|
|
421
416
|
}
|
|
422
417
|
const tasks = task.getIterator();
|
|
423
|
-
const
|
|
418
|
+
const exportedTaskNames = [];
|
|
424
419
|
while (tasks.hasNext()) {
|
|
425
420
|
const task2 = tasks.next();
|
|
426
|
-
if (task2 && !
|
|
427
|
-
|
|
421
|
+
if (task2 && !exportedTaskNames.includes(task2.name)) {
|
|
422
|
+
exportedTaskNames.push(task2.name);
|
|
428
423
|
task2.accept(exporterVisitor);
|
|
429
424
|
}
|
|
430
425
|
}
|
|
@@ -586,8 +581,8 @@ var GraphContext = class _GraphContext {
|
|
|
586
581
|
*/
|
|
587
582
|
export() {
|
|
588
583
|
return {
|
|
589
|
-
|
|
590
|
-
|
|
584
|
+
id: this.id,
|
|
585
|
+
context: this.getFullContext()
|
|
591
586
|
};
|
|
592
587
|
}
|
|
593
588
|
};
|
|
@@ -720,7 +715,7 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
720
715
|
return this.routineExecId === node.routineExecId;
|
|
721
716
|
}
|
|
722
717
|
sharesTaskWith(node) {
|
|
723
|
-
return this.task.
|
|
718
|
+
return this.task.name === node.task.name;
|
|
724
719
|
}
|
|
725
720
|
sharesContextWith(node) {
|
|
726
721
|
return this.context.id === node.context.id;
|
|
@@ -735,7 +730,7 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
735
730
|
return this.task.getTag(this.context);
|
|
736
731
|
}
|
|
737
732
|
scheduleOn(layer) {
|
|
738
|
-
var _a;
|
|
733
|
+
var _a, _b, _c;
|
|
739
734
|
let shouldSchedule = true;
|
|
740
735
|
const nodes = layer.getNodesByRoutineExecId(this.routineExecId);
|
|
741
736
|
for (const node of nodes) {
|
|
@@ -758,10 +753,10 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
758
753
|
data: {
|
|
759
754
|
uuid: this.id,
|
|
760
755
|
routineExecutionId: this.routineExecId,
|
|
761
|
-
|
|
756
|
+
executionTraceId: (_b = context.__executionTraceId) != null ? _b : (_a = context.__metadata) == null ? void 0 : _a.__executionTraceId,
|
|
762
757
|
context: this.context.export(),
|
|
763
|
-
taskId: this.task.id,
|
|
764
758
|
taskName: this.task.name,
|
|
759
|
+
taskVersion: this.task.version,
|
|
765
760
|
isMeta: this.isMeta(),
|
|
766
761
|
isScheduled: true,
|
|
767
762
|
splitGroupId: this.splitGroupId,
|
|
@@ -776,28 +771,19 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
776
771
|
executionCount: "increment"
|
|
777
772
|
},
|
|
778
773
|
filter: {
|
|
779
|
-
|
|
780
|
-
|
|
774
|
+
taskName: this.task.name,
|
|
775
|
+
taskVersion: this.task.version,
|
|
776
|
+
previousTaskName: node.task.name,
|
|
777
|
+
previousTaskVersion: node.task.version
|
|
781
778
|
}
|
|
782
779
|
});
|
|
783
|
-
if (node.failed || node.errored) {
|
|
784
|
-
this.emitMetricsWithMetadata("meta.node.failed_mapped", {
|
|
785
|
-
data: {
|
|
786
|
-
executionCount: "increment"
|
|
787
|
-
},
|
|
788
|
-
filter: {
|
|
789
|
-
taskId: this.task.id,
|
|
790
|
-
failTaskId: node.task.id
|
|
791
|
-
}
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
780
|
});
|
|
795
|
-
if (((
|
|
781
|
+
if (((_c = context.__signalEmission) == null ? void 0 : _c.consumed) === false && (!this.isMeta() || this.debug)) {
|
|
796
782
|
this.emitMetricsWithMetadata("meta.node.consumed_signal", {
|
|
797
783
|
data: {
|
|
798
784
|
signalName: context.__signalEmission.signalName,
|
|
799
|
-
taskId: this.task.id,
|
|
800
785
|
taskName: this.task.name,
|
|
786
|
+
taskVersion: this.task.version,
|
|
801
787
|
taskExecutionId: this.id,
|
|
802
788
|
consumedAt: formatTimestamp(scheduledAt)
|
|
803
789
|
}
|
|
@@ -949,8 +935,8 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
949
935
|
const data = { ...ctx };
|
|
950
936
|
if (!this.task.isHidden) {
|
|
951
937
|
data.__signalEmission = {
|
|
952
|
-
taskId: this.task.id,
|
|
953
938
|
taskName: this.task.name,
|
|
939
|
+
taskVersion: this.task.version,
|
|
954
940
|
taskExecutionId: this.id
|
|
955
941
|
};
|
|
956
942
|
data.__metadata = {
|
|
@@ -963,8 +949,8 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
963
949
|
const data = { ...ctx };
|
|
964
950
|
if (!this.task.isHidden) {
|
|
965
951
|
data.__signalEmission = {
|
|
966
|
-
taskId: this.task.id,
|
|
967
952
|
taskName: this.task.name,
|
|
953
|
+
taskVersion: this.task.version,
|
|
968
954
|
taskExecutionId: this.id,
|
|
969
955
|
isMetric: true
|
|
970
956
|
};
|
|
@@ -1286,8 +1272,8 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1286
1272
|
return {
|
|
1287
1273
|
__id: this.id,
|
|
1288
1274
|
__task: {
|
|
1289
|
-
|
|
1290
|
-
|
|
1275
|
+
__name: this.task.name,
|
|
1276
|
+
__version: this.task.version
|
|
1291
1277
|
},
|
|
1292
1278
|
__context: this.context.export(),
|
|
1293
1279
|
__executionTime: this.executionTime,
|
|
@@ -1315,16 +1301,57 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1315
1301
|
};
|
|
1316
1302
|
|
|
1317
1303
|
// src/graph/definition/GraphRoutine.ts
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
this.emitsSignals = /* @__PURE__ */ new Set();
|
|
1325
|
-
this.signalsToEmitAfter = /* @__PURE__ */ new Set();
|
|
1326
|
-
this.signalsToEmitOnFail = /* @__PURE__ */ new Set();
|
|
1304
|
+
var GraphRoutine = class extends SignalEmitter {
|
|
1305
|
+
constructor(name, tasks, description, isMeta = false) {
|
|
1306
|
+
super();
|
|
1307
|
+
this.version = 1;
|
|
1308
|
+
this.isMeta = false;
|
|
1309
|
+
this.tasks = /* @__PURE__ */ new Set();
|
|
1327
1310
|
this.observedSignals = /* @__PURE__ */ new Set();
|
|
1311
|
+
this.name = name;
|
|
1312
|
+
this.description = description;
|
|
1313
|
+
this.isMeta = isMeta;
|
|
1314
|
+
this.emit("meta.routine.created", {
|
|
1315
|
+
data: {
|
|
1316
|
+
name: this.name,
|
|
1317
|
+
version: this.version,
|
|
1318
|
+
description: this.description,
|
|
1319
|
+
isMeta: this.isMeta
|
|
1320
|
+
},
|
|
1321
|
+
__routineInstance: this
|
|
1322
|
+
});
|
|
1323
|
+
tasks.forEach((t) => {
|
|
1324
|
+
this.tasks.add(t);
|
|
1325
|
+
this.emit("meta.routine.task_added", {
|
|
1326
|
+
data: {
|
|
1327
|
+
taskName: t.name,
|
|
1328
|
+
taskVersion: t.version,
|
|
1329
|
+
routineName: this.name,
|
|
1330
|
+
routineVersion: this.version
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Applies callback to starting tasks.
|
|
1337
|
+
* @param callBack The callback.
|
|
1338
|
+
* @returns Promise if async.
|
|
1339
|
+
*/
|
|
1340
|
+
async forEachTask(callBack) {
|
|
1341
|
+
const promises = [];
|
|
1342
|
+
for (const task of this.tasks) {
|
|
1343
|
+
const res = callBack(task);
|
|
1344
|
+
if (res instanceof Promise) promises.push(res);
|
|
1345
|
+
}
|
|
1346
|
+
await Promise.all(promises);
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Sets global Version.
|
|
1350
|
+
* @param version The Version.
|
|
1351
|
+
*/
|
|
1352
|
+
setVersion(version) {
|
|
1353
|
+
this.version = version;
|
|
1354
|
+
this.emit("meta.routine.global_version_set", { version: this.version });
|
|
1328
1355
|
}
|
|
1329
1356
|
/**
|
|
1330
1357
|
* Subscribes to signals (chainable).
|
|
@@ -1340,25 +1367,6 @@ var SignalParticipant = class extends SignalEmitter {
|
|
|
1340
1367
|
});
|
|
1341
1368
|
return this;
|
|
1342
1369
|
}
|
|
1343
|
-
/**
|
|
1344
|
-
* Sets signals to emit post-execution (chainable).
|
|
1345
|
-
* @param signals The signal names.
|
|
1346
|
-
* @returns This for chaining.
|
|
1347
|
-
*/
|
|
1348
|
-
emitsAfter(...signals) {
|
|
1349
|
-
signals.forEach((signal) => {
|
|
1350
|
-
this.signalsToEmitAfter.add(signal);
|
|
1351
|
-
this.emitsSignals.add(signal);
|
|
1352
|
-
});
|
|
1353
|
-
return this;
|
|
1354
|
-
}
|
|
1355
|
-
emitsOnFail(...signals) {
|
|
1356
|
-
signals.forEach((signal) => {
|
|
1357
|
-
this.signalsToEmitOnFail.add(signal);
|
|
1358
|
-
this.emitsSignals.add(signal);
|
|
1359
|
-
});
|
|
1360
|
-
return this;
|
|
1361
|
-
}
|
|
1362
1370
|
/**
|
|
1363
1371
|
* Unsubscribes from all observed signals.
|
|
1364
1372
|
* @returns This for chaining.
|
|
@@ -1385,125 +1393,19 @@ var SignalParticipant = class extends SignalEmitter {
|
|
|
1385
1393
|
});
|
|
1386
1394
|
return this;
|
|
1387
1395
|
}
|
|
1388
|
-
/**
|
|
1389
|
-
* Detaches specific emitted signals.
|
|
1390
|
-
* @param signals The signals.
|
|
1391
|
-
* @returns This for chaining.
|
|
1392
|
-
*/
|
|
1393
|
-
detachSignals(...signals) {
|
|
1394
|
-
signals.forEach((signal) => this.signalsToEmitAfter.delete(signal));
|
|
1395
|
-
return this;
|
|
1396
|
-
}
|
|
1397
|
-
/**
|
|
1398
|
-
* Detaches all emitted signals.
|
|
1399
|
-
* @returns This for chaining.
|
|
1400
|
-
*/
|
|
1401
|
-
detachAllSignals() {
|
|
1402
|
-
this.signalsToEmitAfter.clear();
|
|
1403
|
-
return this;
|
|
1404
|
-
}
|
|
1405
|
-
mapSignals(callback) {
|
|
1406
|
-
return Array.from(this.signalsToEmitAfter).map(callback);
|
|
1407
|
-
}
|
|
1408
|
-
mapOnFailSignals(callback) {
|
|
1409
|
-
return Array.from(this.signalsToEmitOnFail).map(callback);
|
|
1410
|
-
}
|
|
1411
|
-
/**
|
|
1412
|
-
* Emits attached signals.
|
|
1413
|
-
* @param context The context for emission.
|
|
1414
|
-
* @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
|
|
1415
|
-
*/
|
|
1416
|
-
emitSignals(context) {
|
|
1417
|
-
this.signalsToEmitAfter.forEach((signal) => {
|
|
1418
|
-
this.emit(signal, context.getFullContext());
|
|
1419
|
-
});
|
|
1420
|
-
}
|
|
1421
|
-
/**
|
|
1422
|
-
* Emits attached fail signals.
|
|
1423
|
-
* @param context The context for emission.
|
|
1424
|
-
* @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
|
|
1425
|
-
*/
|
|
1426
|
-
emitOnFailSignals(context) {
|
|
1427
|
-
this.signalsToEmitOnFail.forEach((signal) => {
|
|
1428
|
-
this.emit(signal, context.getFullContext());
|
|
1429
|
-
});
|
|
1430
|
-
}
|
|
1431
|
-
/**
|
|
1432
|
-
* Destroys the participant (unsub/detach).
|
|
1433
|
-
*/
|
|
1434
|
-
destroy() {
|
|
1435
|
-
this.unsubscribeAll();
|
|
1436
|
-
this.detachAllSignals();
|
|
1437
|
-
}
|
|
1438
|
-
};
|
|
1439
|
-
|
|
1440
|
-
// src/graph/definition/GraphRoutine.ts
|
|
1441
|
-
var GraphRoutine = class extends SignalParticipant {
|
|
1442
|
-
constructor(name, tasks, description, isMeta = false) {
|
|
1443
|
-
super();
|
|
1444
|
-
this.isMeta = false;
|
|
1445
|
-
this.tasks = /* @__PURE__ */ new Set();
|
|
1446
|
-
this.id = uuid4();
|
|
1447
|
-
this.name = name;
|
|
1448
|
-
this.description = description;
|
|
1449
|
-
this.isMeta = isMeta;
|
|
1450
|
-
this.emit("meta.routine.created", {
|
|
1451
|
-
data: {
|
|
1452
|
-
uuid: this.id,
|
|
1453
|
-
name: this.name,
|
|
1454
|
-
description: this.description,
|
|
1455
|
-
isMeta: this.isMeta
|
|
1456
|
-
},
|
|
1457
|
-
__routineInstance: this
|
|
1458
|
-
});
|
|
1459
|
-
tasks.forEach((t) => {
|
|
1460
|
-
this.tasks.add(t);
|
|
1461
|
-
this.emit("meta.routine.task_added", {
|
|
1462
|
-
data: {
|
|
1463
|
-
taskId: t.id,
|
|
1464
|
-
routineId: this.id
|
|
1465
|
-
}
|
|
1466
|
-
});
|
|
1467
|
-
});
|
|
1468
|
-
}
|
|
1469
|
-
/**
|
|
1470
|
-
* Applies callback to starting tasks.
|
|
1471
|
-
* @param callBack The callback.
|
|
1472
|
-
* @returns Promise if async.
|
|
1473
|
-
*/
|
|
1474
|
-
async forEachTask(callBack) {
|
|
1475
|
-
const promises = [];
|
|
1476
|
-
for (const task of this.tasks) {
|
|
1477
|
-
const res = callBack(task);
|
|
1478
|
-
if (res instanceof Promise) promises.push(res);
|
|
1479
|
-
}
|
|
1480
|
-
await Promise.all(promises);
|
|
1481
|
-
}
|
|
1482
|
-
/**
|
|
1483
|
-
* Sets global ID.
|
|
1484
|
-
* @param id The ID.
|
|
1485
|
-
*/
|
|
1486
|
-
setGlobalId(id) {
|
|
1487
|
-
const oldId = this.id;
|
|
1488
|
-
this.id = id;
|
|
1489
|
-
this.emit("meta.routine.global_id_set", { __id: this.id, __oldId: oldId });
|
|
1490
|
-
}
|
|
1491
|
-
// Removed emitsSignals per clarification (routines as listeners only)
|
|
1492
1396
|
/**
|
|
1493
1397
|
* Destroys the routine.
|
|
1494
1398
|
*/
|
|
1495
1399
|
destroy() {
|
|
1400
|
+
this.unsubscribeAll();
|
|
1496
1401
|
this.tasks.clear();
|
|
1497
1402
|
this.emit("meta.routine.destroyed", {
|
|
1498
1403
|
data: { deleted: true },
|
|
1499
|
-
filter: {
|
|
1404
|
+
filter: { name: this.name, version: this.version }
|
|
1500
1405
|
});
|
|
1501
1406
|
}
|
|
1502
1407
|
};
|
|
1503
1408
|
|
|
1504
|
-
// src/graph/definition/Task.ts
|
|
1505
|
-
import { v4 as uuid5 } from "uuid";
|
|
1506
|
-
|
|
1507
1409
|
// src/graph/iterators/TaskIterator.ts
|
|
1508
1410
|
var TaskIterator = class {
|
|
1509
1411
|
constructor(task) {
|
|
@@ -1536,7 +1438,7 @@ var TaskIterator = class {
|
|
|
1536
1438
|
};
|
|
1537
1439
|
|
|
1538
1440
|
// src/graph/definition/Task.ts
|
|
1539
|
-
var Task = class extends
|
|
1441
|
+
var Task = class extends SignalEmitter {
|
|
1540
1442
|
/**
|
|
1541
1443
|
* Constructs a Task (static definition).
|
|
1542
1444
|
* @param name Name.
|
|
@@ -1562,6 +1464,7 @@ var Task = class extends SignalParticipant {
|
|
|
1562
1464
|
*/
|
|
1563
1465
|
constructor(name, task, description = "", concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false, isSubMeta = false, isHidden = false, getTagCallback = void 0, inputSchema = void 0, validateInputContext = false, outputSchema = void 0, validateOutputContext = false, retryCount = 0, retryDelay = 0, retryDelayMax = 0, retryDelayFactor = 1) {
|
|
1564
1466
|
super(isSubMeta || isHidden);
|
|
1467
|
+
this.version = 1;
|
|
1565
1468
|
this.isMeta = false;
|
|
1566
1469
|
this.isSubMeta = false;
|
|
1567
1470
|
this.isHidden = false;
|
|
@@ -1585,7 +1488,10 @@ var Task = class extends SignalParticipant {
|
|
|
1585
1488
|
this.onFailTasks = /* @__PURE__ */ new Set();
|
|
1586
1489
|
this.predecessorTasks = /* @__PURE__ */ new Set();
|
|
1587
1490
|
this.destroyed = false;
|
|
1588
|
-
this.
|
|
1491
|
+
this.emitsSignals = /* @__PURE__ */ new Set();
|
|
1492
|
+
this.signalsToEmitAfter = /* @__PURE__ */ new Set();
|
|
1493
|
+
this.signalsToEmitOnFail = /* @__PURE__ */ new Set();
|
|
1494
|
+
this.observedSignals = /* @__PURE__ */ new Set();
|
|
1589
1495
|
this.name = name;
|
|
1590
1496
|
this.taskFunction = task.bind(this);
|
|
1591
1497
|
this.description = description;
|
|
@@ -1610,9 +1516,9 @@ var Task = class extends SignalParticipant {
|
|
|
1610
1516
|
if (register && !this.isHidden && !this.isSubMeta) {
|
|
1611
1517
|
const { __functionString, __getTagCallback } = this.export();
|
|
1612
1518
|
this.emitWithMetadata("meta.task.created", {
|
|
1613
|
-
|
|
1614
|
-
uuid: this.id,
|
|
1519
|
+
data: {
|
|
1615
1520
|
name: this.name,
|
|
1521
|
+
version: this.version,
|
|
1616
1522
|
description: this.description,
|
|
1617
1523
|
functionString: __functionString,
|
|
1618
1524
|
tagIdGetter: __getTagCallback,
|
|
@@ -1631,22 +1537,20 @@ var Task = class extends SignalParticipant {
|
|
|
1631
1537
|
isMeta: this.isMeta,
|
|
1632
1538
|
validateInputContext: this.validateInputContext,
|
|
1633
1539
|
validateOutputContext: this.validateOutputContext,
|
|
1634
|
-
|
|
1635
|
-
|
|
1540
|
+
inputContextSchema: this.inputContextSchema,
|
|
1541
|
+
outputContextSchema: this.outputContextSchema
|
|
1636
1542
|
},
|
|
1637
1543
|
__taskInstance: this
|
|
1638
1544
|
});
|
|
1639
1545
|
}
|
|
1640
1546
|
}
|
|
1641
1547
|
getTag(context) {
|
|
1642
|
-
return this.
|
|
1548
|
+
return this.name;
|
|
1643
1549
|
}
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
this.
|
|
1647
|
-
|
|
1648
|
-
__id: this.id,
|
|
1649
|
-
__oldId: oldId
|
|
1550
|
+
setVersion(version) {
|
|
1551
|
+
this.version = version;
|
|
1552
|
+
this.emitWithMetadata("meta.task.version_set", {
|
|
1553
|
+
__version: this.version
|
|
1650
1554
|
});
|
|
1651
1555
|
}
|
|
1652
1556
|
setTimeout(timeout) {
|
|
@@ -1674,8 +1578,8 @@ var Task = class extends SignalParticipant {
|
|
|
1674
1578
|
const data = { ...ctx };
|
|
1675
1579
|
if (!this.isHidden && !this.isSubMeta) {
|
|
1676
1580
|
data.__signalEmission = {
|
|
1677
|
-
|
|
1678
|
-
|
|
1581
|
+
taskName: this.name,
|
|
1582
|
+
taskVersion: this.version
|
|
1679
1583
|
};
|
|
1680
1584
|
}
|
|
1681
1585
|
this.emit(signal, data);
|
|
@@ -1684,8 +1588,8 @@ var Task = class extends SignalParticipant {
|
|
|
1684
1588
|
const data = { ...ctx };
|
|
1685
1589
|
if (!this.isHidden && !this.isSubMeta) {
|
|
1686
1590
|
data.__signalEmission = {
|
|
1687
|
-
taskId: this.id,
|
|
1688
1591
|
taskName: this.name,
|
|
1592
|
+
taskVersion: this.version,
|
|
1689
1593
|
isMetric: true
|
|
1690
1594
|
};
|
|
1691
1595
|
}
|
|
@@ -1808,8 +1712,8 @@ var Task = class extends SignalParticipant {
|
|
|
1808
1712
|
);
|
|
1809
1713
|
if (!validationResult.valid) {
|
|
1810
1714
|
this.emitWithMetadata("meta.task.input_validation_failed", {
|
|
1811
|
-
__taskId: this.id,
|
|
1812
1715
|
__taskName: this.name,
|
|
1716
|
+
__taskVersion: this.version,
|
|
1813
1717
|
__context: context,
|
|
1814
1718
|
__errors: validationResult.errors
|
|
1815
1719
|
});
|
|
@@ -1830,7 +1734,8 @@ var Task = class extends SignalParticipant {
|
|
|
1830
1734
|
);
|
|
1831
1735
|
if (!validationResult.valid) {
|
|
1832
1736
|
this.emitWithMetadata("meta.task.outputValidationFailed", {
|
|
1833
|
-
|
|
1737
|
+
__taskName: this.name,
|
|
1738
|
+
__taskVersion: this.version,
|
|
1834
1739
|
__result: context,
|
|
1835
1740
|
__errors: validationResult.errors
|
|
1836
1741
|
});
|
|
@@ -1871,8 +1776,10 @@ var Task = class extends SignalParticipant {
|
|
|
1871
1776
|
}
|
|
1872
1777
|
this.emitMetricsWithMetadata("meta.task.relationship_added", {
|
|
1873
1778
|
data: {
|
|
1874
|
-
|
|
1875
|
-
|
|
1779
|
+
taskName: this.name,
|
|
1780
|
+
taskVersion: this.version,
|
|
1781
|
+
predecessorTaskName: pred.name,
|
|
1782
|
+
predecessorTaskVersion: pred.version
|
|
1876
1783
|
}
|
|
1877
1784
|
});
|
|
1878
1785
|
}
|
|
@@ -1891,8 +1798,10 @@ var Task = class extends SignalParticipant {
|
|
|
1891
1798
|
}
|
|
1892
1799
|
this.emitMetricsWithMetadata("meta.task.relationship_added", {
|
|
1893
1800
|
data: {
|
|
1894
|
-
|
|
1895
|
-
|
|
1801
|
+
taskName: next.name,
|
|
1802
|
+
taskVersion: next.version,
|
|
1803
|
+
predecessorTaskName: this.name,
|
|
1804
|
+
predecessorTaskVersion: this.version
|
|
1896
1805
|
}
|
|
1897
1806
|
});
|
|
1898
1807
|
}
|
|
@@ -1910,25 +1819,6 @@ var Task = class extends SignalParticipant {
|
|
|
1910
1819
|
}
|
|
1911
1820
|
this.updateLayerFromPredecessors();
|
|
1912
1821
|
}
|
|
1913
|
-
doOnFail(...tasks) {
|
|
1914
|
-
for (const task of tasks) {
|
|
1915
|
-
if (this.onFailTasks.has(task)) continue;
|
|
1916
|
-
this.onFailTasks.add(task);
|
|
1917
|
-
task.predecessorTasks.add(this);
|
|
1918
|
-
task.updateLayerFromPredecessors();
|
|
1919
|
-
if (task.hasCycle()) {
|
|
1920
|
-
this.decouple(task);
|
|
1921
|
-
throw new Error(`Cycle adding onFail ${task.name} to ${this.name}`);
|
|
1922
|
-
}
|
|
1923
|
-
this.emitMetricsWithMetadata("meta.task.on_fail_relationship_added", {
|
|
1924
|
-
data: {
|
|
1925
|
-
taskId: this.id,
|
|
1926
|
-
onFailTaskId: task.id
|
|
1927
|
-
}
|
|
1928
|
-
});
|
|
1929
|
-
}
|
|
1930
|
-
return this;
|
|
1931
|
-
}
|
|
1932
1822
|
updateProgressWeights() {
|
|
1933
1823
|
const layers = this.getSubgraphLayers();
|
|
1934
1824
|
const numLayers = layers.size;
|
|
@@ -1968,7 +1858,7 @@ var Task = class extends SignalParticipant {
|
|
|
1968
1858
|
data: {
|
|
1969
1859
|
layerIndex: this.layerIndex
|
|
1970
1860
|
},
|
|
1971
|
-
filter: {
|
|
1861
|
+
filter: { name: this.name, version: this.version }
|
|
1972
1862
|
});
|
|
1973
1863
|
}
|
|
1974
1864
|
const queue = Array.from(this.nextTasks);
|
|
@@ -2001,8 +1891,165 @@ var Task = class extends SignalParticipant {
|
|
|
2001
1891
|
mapPrevious(callback) {
|
|
2002
1892
|
return Array.from(this.predecessorTasks).map(callback);
|
|
2003
1893
|
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Subscribes to signals (chainable).
|
|
1896
|
+
* @param signals The signal names.
|
|
1897
|
+
* @returns This for chaining.
|
|
1898
|
+
* @edge Duplicates ignored; assumes broker.observe binds this as handler.
|
|
1899
|
+
*/
|
|
1900
|
+
doOn(...signals) {
|
|
1901
|
+
signals.forEach((signal) => {
|
|
1902
|
+
if (this.observedSignals.has(signal)) return;
|
|
1903
|
+
Cadenza.broker.observe(signal, this);
|
|
1904
|
+
this.observedSignals.add(signal);
|
|
1905
|
+
this.emitWithMetadata("meta.task.observed_signal", {
|
|
1906
|
+
data: {
|
|
1907
|
+
signalName: signal,
|
|
1908
|
+
taskName: this.name,
|
|
1909
|
+
taskVersion: this.version
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
});
|
|
1913
|
+
return this;
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Sets signals to emit post-execution (chainable).
|
|
1917
|
+
* @param signals The signal names.
|
|
1918
|
+
* @returns This for chaining.
|
|
1919
|
+
*/
|
|
1920
|
+
emits(...signals) {
|
|
1921
|
+
signals.forEach((signal) => {
|
|
1922
|
+
this.signalsToEmitAfter.add(signal);
|
|
1923
|
+
this.emitsSignals.add(signal);
|
|
1924
|
+
this.emitWithMetadata("meta.task.attached_signal", {
|
|
1925
|
+
data: {
|
|
1926
|
+
signalName: signal,
|
|
1927
|
+
taskName: this.name,
|
|
1928
|
+
taskVersion: this.version
|
|
1929
|
+
}
|
|
1930
|
+
});
|
|
1931
|
+
});
|
|
1932
|
+
return this;
|
|
1933
|
+
}
|
|
1934
|
+
emitsOnFail(...signals) {
|
|
1935
|
+
signals.forEach((signal) => {
|
|
1936
|
+
this.signalsToEmitOnFail.add(signal);
|
|
1937
|
+
this.emitsSignals.add(signal);
|
|
1938
|
+
this.emitWithMetadata("meta.task.attached_signal", {
|
|
1939
|
+
data: {
|
|
1940
|
+
signalName: signal,
|
|
1941
|
+
taskName: this.name,
|
|
1942
|
+
taskVersion: this.version,
|
|
1943
|
+
isOnFail: true
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
});
|
|
1947
|
+
return this;
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Unsubscribes from all observed signals.
|
|
1951
|
+
* @returns This for chaining.
|
|
1952
|
+
*/
|
|
1953
|
+
unsubscribeAll() {
|
|
1954
|
+
this.observedSignals.forEach((signal) => {
|
|
1955
|
+
Cadenza.broker.unsubscribe(signal, this);
|
|
1956
|
+
this.emitWithMetadata("meta.task.unsubscribed_signal", {
|
|
1957
|
+
filter: {
|
|
1958
|
+
signalName: signal,
|
|
1959
|
+
taskName: this.name,
|
|
1960
|
+
taskVersion: this.version
|
|
1961
|
+
}
|
|
1962
|
+
});
|
|
1963
|
+
});
|
|
1964
|
+
this.observedSignals.clear();
|
|
1965
|
+
return this;
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Unsubscribes from specific signals.
|
|
1969
|
+
* @param signals The signals.
|
|
1970
|
+
* @returns This for chaining.
|
|
1971
|
+
* @edge No-op if not subscribed.
|
|
1972
|
+
*/
|
|
1973
|
+
unsubscribe(...signals) {
|
|
1974
|
+
signals.forEach((signal) => {
|
|
1975
|
+
if (this.observedSignals.has(signal)) {
|
|
1976
|
+
Cadenza.broker.unsubscribe(signal, this);
|
|
1977
|
+
this.observedSignals.delete(signal);
|
|
1978
|
+
this.emitWithMetadata("meta.task.unsubscribed_signal", {
|
|
1979
|
+
filter: {
|
|
1980
|
+
signalName: signal,
|
|
1981
|
+
taskName: this.name,
|
|
1982
|
+
taskVersion: this.version
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
return this;
|
|
1988
|
+
}
|
|
1989
|
+
/**
|
|
1990
|
+
* Detaches specific emitted signals.
|
|
1991
|
+
* @param signals The signals.
|
|
1992
|
+
* @returns This for chaining.
|
|
1993
|
+
*/
|
|
1994
|
+
detachSignals(...signals) {
|
|
1995
|
+
signals.forEach((signal) => {
|
|
1996
|
+
this.signalsToEmitAfter.delete(signal);
|
|
1997
|
+
this.emitWithMetadata("meta.task.detached_signal", {
|
|
1998
|
+
filter: {
|
|
1999
|
+
signalName: signal,
|
|
2000
|
+
taskName: this.name,
|
|
2001
|
+
taskVersion: this.version
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
2004
|
+
});
|
|
2005
|
+
return this;
|
|
2006
|
+
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Detaches all emitted signals.
|
|
2009
|
+
* @returns This for chaining.
|
|
2010
|
+
*/
|
|
2011
|
+
detachAllSignals() {
|
|
2012
|
+
this.signalsToEmitAfter.forEach((signal) => {
|
|
2013
|
+
this.emitWithMetadata("meta.task.detached_signal", {
|
|
2014
|
+
filter: {
|
|
2015
|
+
signalName: signal,
|
|
2016
|
+
taskName: this.name,
|
|
2017
|
+
taskVersion: this.version
|
|
2018
|
+
}
|
|
2019
|
+
});
|
|
2020
|
+
});
|
|
2021
|
+
this.signalsToEmitAfter.clear();
|
|
2022
|
+
return this;
|
|
2023
|
+
}
|
|
2024
|
+
mapSignals(callback) {
|
|
2025
|
+
return Array.from(this.signalsToEmitAfter).map(callback);
|
|
2026
|
+
}
|
|
2027
|
+
mapOnFailSignals(callback) {
|
|
2028
|
+
return Array.from(this.signalsToEmitOnFail).map(callback);
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Emits attached signals.
|
|
2032
|
+
* @param context The context for emission.
|
|
2033
|
+
* @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
|
|
2034
|
+
*/
|
|
2035
|
+
emitSignals(context) {
|
|
2036
|
+
this.signalsToEmitAfter.forEach((signal) => {
|
|
2037
|
+
this.emit(signal, context.getFullContext());
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Emits attached fail signals.
|
|
2042
|
+
* @param context The context for emission.
|
|
2043
|
+
* @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
|
|
2044
|
+
*/
|
|
2045
|
+
emitOnFailSignals(context) {
|
|
2046
|
+
this.signalsToEmitOnFail.forEach((signal) => {
|
|
2047
|
+
this.emit(signal, context.getFullContext());
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2004
2050
|
destroy() {
|
|
2005
|
-
|
|
2051
|
+
this.unsubscribeAll();
|
|
2052
|
+
this.detachAllSignals();
|
|
2006
2053
|
this.predecessorTasks.forEach((pred) => pred.nextTasks.delete(this));
|
|
2007
2054
|
this.nextTasks.forEach((next) => next.predecessorTasks.delete(this));
|
|
2008
2055
|
this.onFailTasks.forEach((fail) => fail.predecessorTasks.delete(this));
|
|
@@ -2012,12 +2059,11 @@ var Task = class extends SignalParticipant {
|
|
|
2012
2059
|
this.destroyed = true;
|
|
2013
2060
|
this.emitMetricsWithMetadata("meta.task.destroyed", {
|
|
2014
2061
|
data: { deleted: true },
|
|
2015
|
-
filter: {
|
|
2062
|
+
filter: { name: this.name, version: this.version }
|
|
2016
2063
|
});
|
|
2017
2064
|
}
|
|
2018
2065
|
export() {
|
|
2019
2066
|
return {
|
|
2020
|
-
__id: this.id,
|
|
2021
2067
|
__name: this.name,
|
|
2022
2068
|
__description: this.description,
|
|
2023
2069
|
__layerIndex: this.layerIndex,
|
|
@@ -2037,9 +2083,9 @@ var Task = class extends SignalParticipant {
|
|
|
2037
2083
|
__validateInputContext: this.validateInputContext,
|
|
2038
2084
|
__outputSchema: this.outputContextSchema,
|
|
2039
2085
|
__validateOutputContext: this.validateOutputContext,
|
|
2040
|
-
__nextTasks: Array.from(this.nextTasks).map((t) => t.
|
|
2041
|
-
__onFailTasks: Array.from(this.onFailTasks).map((t) => t.
|
|
2042
|
-
__previousTasks: Array.from(this.predecessorTasks).map((t) => t.
|
|
2086
|
+
__nextTasks: Array.from(this.nextTasks).map((t) => t.name),
|
|
2087
|
+
__onFailTasks: Array.from(this.onFailTasks).map((t) => t.name),
|
|
2088
|
+
__previousTasks: Array.from(this.predecessorTasks).map((t) => t.name)
|
|
2043
2089
|
};
|
|
2044
2090
|
}
|
|
2045
2091
|
getIterator() {
|
|
@@ -2062,8 +2108,8 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2062
2108
|
"Register task",
|
|
2063
2109
|
(context) => {
|
|
2064
2110
|
const { __taskInstance } = context;
|
|
2065
|
-
if (__taskInstance && !this.tasks.has(__taskInstance.
|
|
2066
|
-
this.tasks.set(__taskInstance.
|
|
2111
|
+
if (__taskInstance && !this.tasks.has(__taskInstance.name)) {
|
|
2112
|
+
this.tasks.set(__taskInstance.name, __taskInstance);
|
|
2067
2113
|
}
|
|
2068
2114
|
delete context.__taskInstance;
|
|
2069
2115
|
return true;
|
|
@@ -2074,20 +2120,8 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2074
2120
|
true,
|
|
2075
2121
|
false,
|
|
2076
2122
|
true
|
|
2077
|
-
).doOn("meta.task.created");
|
|
2078
|
-
this.tasks.set(this.registerTask.
|
|
2079
|
-
this.updateTaskId = Cadenza.createMetaTask(
|
|
2080
|
-
"Update task id",
|
|
2081
|
-
(context) => {
|
|
2082
|
-
const { __id, __oldId } = context;
|
|
2083
|
-
const task = this.tasks.get(__oldId);
|
|
2084
|
-
if (!task) return context;
|
|
2085
|
-
this.tasks.set(__id, task);
|
|
2086
|
-
this.tasks.delete(__oldId);
|
|
2087
|
-
return context;
|
|
2088
|
-
},
|
|
2089
|
-
"Updates task id."
|
|
2090
|
-
).doOn("meta.task.global_id_set");
|
|
2123
|
+
).doOn("meta.task.created").emits("meta.graph_registry.task_registered");
|
|
2124
|
+
this.tasks.set(this.registerTask.name, this.registerTask);
|
|
2091
2125
|
this.updateTaskInputSchema = Cadenza.createMetaTask(
|
|
2092
2126
|
"Update task input schema",
|
|
2093
2127
|
(context) => {
|
|
@@ -2110,14 +2144,6 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2110
2144
|
},
|
|
2111
2145
|
"Updates task input schema."
|
|
2112
2146
|
).doOn("meta.task.output_schema_updated");
|
|
2113
|
-
this.getTaskById = Cadenza.createMetaTask(
|
|
2114
|
-
"Get task by id",
|
|
2115
|
-
(context) => {
|
|
2116
|
-
const { __id } = context;
|
|
2117
|
-
return { ...context, __task: this.tasks.get(__id) };
|
|
2118
|
-
},
|
|
2119
|
-
"Gets task by id."
|
|
2120
|
-
);
|
|
2121
2147
|
this.getTaskByName = Cadenza.createMetaTask(
|
|
2122
2148
|
"Get task by name",
|
|
2123
2149
|
(context) => {
|
|
@@ -2161,8 +2187,8 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2161
2187
|
this.deleteTask = Cadenza.createMetaTask(
|
|
2162
2188
|
"Delete task",
|
|
2163
2189
|
(context) => {
|
|
2164
|
-
const {
|
|
2165
|
-
this.tasks.delete(
|
|
2190
|
+
const { __name } = context;
|
|
2191
|
+
this.tasks.delete(__name);
|
|
2166
2192
|
return context;
|
|
2167
2193
|
},
|
|
2168
2194
|
"Deletes task."
|
|
@@ -2171,34 +2197,14 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2171
2197
|
"Register routine",
|
|
2172
2198
|
(context) => {
|
|
2173
2199
|
const { __routineInstance } = context;
|
|
2174
|
-
if (__routineInstance && !this.routines.has(__routineInstance.
|
|
2175
|
-
this.routines.set(__routineInstance.
|
|
2200
|
+
if (__routineInstance && !this.routines.has(__routineInstance.name)) {
|
|
2201
|
+
this.routines.set(__routineInstance.name, __routineInstance);
|
|
2176
2202
|
}
|
|
2177
2203
|
delete context.__routineInstance;
|
|
2178
2204
|
return true;
|
|
2179
2205
|
},
|
|
2180
2206
|
"Registers routine."
|
|
2181
2207
|
).doOn("meta.routine.created");
|
|
2182
|
-
this.updateRoutineId = Cadenza.createMetaTask(
|
|
2183
|
-
"Update routine id",
|
|
2184
|
-
(context) => {
|
|
2185
|
-
const { __id, __oldId } = context;
|
|
2186
|
-
const routine = this.routines.get(__oldId);
|
|
2187
|
-
if (!routine) return context;
|
|
2188
|
-
this.routines.set(__id, routine);
|
|
2189
|
-
this.routines.delete(__oldId);
|
|
2190
|
-
return context;
|
|
2191
|
-
},
|
|
2192
|
-
"Updates routine id."
|
|
2193
|
-
).doOn("meta.routine.global_id_set");
|
|
2194
|
-
this.getRoutineById = Cadenza.createMetaTask(
|
|
2195
|
-
"Get routine by id",
|
|
2196
|
-
(context) => {
|
|
2197
|
-
const { __id } = context;
|
|
2198
|
-
return { ...context, routine: this.routines.get(__id) };
|
|
2199
|
-
},
|
|
2200
|
-
"Gets routine by id."
|
|
2201
|
-
);
|
|
2202
2208
|
this.getRoutineByName = Cadenza.createMetaTask(
|
|
2203
2209
|
"Get routine by name",
|
|
2204
2210
|
(context) => {
|
|
@@ -2233,8 +2239,8 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2233
2239
|
this.deleteRoutine = Cadenza.createMetaTask(
|
|
2234
2240
|
"Delete routine",
|
|
2235
2241
|
(context) => {
|
|
2236
|
-
const {
|
|
2237
|
-
this.routines.delete(
|
|
2242
|
+
const { __name } = context;
|
|
2243
|
+
this.routines.delete(__name);
|
|
2238
2244
|
return context;
|
|
2239
2245
|
},
|
|
2240
2246
|
"Deletes routine."
|
|
@@ -2247,7 +2253,6 @@ var GraphRegistry = class _GraphRegistry {
|
|
|
2247
2253
|
reset() {
|
|
2248
2254
|
this.tasks.clear();
|
|
2249
2255
|
this.routines.clear();
|
|
2250
|
-
this.tasks.set(this.registerTask.id, this.registerTask);
|
|
2251
2256
|
}
|
|
2252
2257
|
};
|
|
2253
2258
|
|
|
@@ -2264,7 +2269,6 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
2264
2269
|
this.verbose = false;
|
|
2265
2270
|
this.isRunning = false;
|
|
2266
2271
|
this.isMeta = false;
|
|
2267
|
-
this.id = uuid6();
|
|
2268
2272
|
this.isMeta = isMeta;
|
|
2269
2273
|
this.strategy = Cadenza.runStrategy.PARALLEL;
|
|
2270
2274
|
this.currentRun = new GraphRun(this.strategy);
|
|
@@ -2289,20 +2293,20 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
2289
2293
|
* @edge Empty tasks warns no-op.
|
|
2290
2294
|
*/
|
|
2291
2295
|
addTasks(tasks, context = {}) {
|
|
2292
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2296
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2293
2297
|
let _tasks = Array.isArray(tasks) ? tasks : [tasks];
|
|
2294
2298
|
if (_tasks.length === 0) {
|
|
2295
2299
|
console.warn("No tasks/routines to add.");
|
|
2296
2300
|
return;
|
|
2297
2301
|
}
|
|
2298
2302
|
let routineName = _tasks.map((t) => t.name).join(" | ");
|
|
2303
|
+
let routineVersion = null;
|
|
2299
2304
|
let isMeta = _tasks.every((t) => t.isMeta);
|
|
2300
|
-
let routineId = null;
|
|
2301
2305
|
const allTasks = _tasks.flatMap((t) => {
|
|
2302
2306
|
if (t instanceof GraphRoutine) {
|
|
2303
2307
|
routineName = t.name;
|
|
2308
|
+
routineVersion = t.version;
|
|
2304
2309
|
isMeta = t.isMeta;
|
|
2305
|
-
routineId = t.id;
|
|
2306
2310
|
const routineTasks = [];
|
|
2307
2311
|
t.forEachTask((task) => routineTasks.push(task));
|
|
2308
2312
|
return routineTasks;
|
|
@@ -2312,18 +2316,35 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
2312
2316
|
const isSubMeta = allTasks.some((t) => t.isSubMeta) || !!context.__isSubMeta;
|
|
2313
2317
|
context.__isSubMeta = isSubMeta;
|
|
2314
2318
|
const ctx = new GraphContext(context || {});
|
|
2315
|
-
const
|
|
2319
|
+
const isNewTrace = !!context.__routineExecId;
|
|
2320
|
+
const routineExecId = (_a = context.__routineExecId) != null ? _a : uuid4();
|
|
2316
2321
|
context.__routineExecId = routineExecId;
|
|
2317
2322
|
if (!isSubMeta) {
|
|
2323
|
+
const executionTraceId = (_d = (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId) != null ? _d : uuid4();
|
|
2324
|
+
const contextData = ctx.export();
|
|
2325
|
+
if (isNewTrace) {
|
|
2326
|
+
this.emitMetrics("meta.runner.new_trace", {
|
|
2327
|
+
data: {
|
|
2328
|
+
uuid: executionTraceId,
|
|
2329
|
+
issuer_type: "service",
|
|
2330
|
+
// TODO: Add issuer type
|
|
2331
|
+
issuer_id: (_g = (_f = (_e = context.__metadata) == null ? void 0 : _e.__issuerId) != null ? _f : context.__issuerId) != null ? _g : null,
|
|
2332
|
+
issued_at: formatTimestamp(Date.now()),
|
|
2333
|
+
intent: (_j = (_i = (_h = context.__metadata) == null ? void 0 : _h.__intent) != null ? _i : context.__intent) != null ? _j : null,
|
|
2334
|
+
context: contextData,
|
|
2335
|
+
is_meta: isMeta
|
|
2336
|
+
}
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2318
2339
|
this.emitMetrics("meta.runner.added_tasks", {
|
|
2319
2340
|
data: {
|
|
2320
2341
|
uuid: routineExecId,
|
|
2321
2342
|
name: routineName,
|
|
2343
|
+
routineVersion,
|
|
2322
2344
|
isMeta,
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
context:
|
|
2326
|
-
previousRoutineExecution: (_f = (_e = context.__metadata) == null ? void 0 : _e.__routineExecId) != null ? _f : null,
|
|
2345
|
+
executionTraceId,
|
|
2346
|
+
context: isNewTrace ? contextData.id : contextData,
|
|
2347
|
+
previousRoutineExecution: (_l = (_k = context.__metadata) == null ? void 0 : _k.__routineExecId) != null ? _l : null,
|
|
2327
2348
|
// TODO: There is a chance this is not added to the database yet...
|
|
2328
2349
|
created: formatTimestamp(Date.now())
|
|
2329
2350
|
}
|
|
@@ -3461,7 +3482,6 @@ export {
|
|
|
3461
3482
|
GraphRunner,
|
|
3462
3483
|
SignalBroker,
|
|
3463
3484
|
SignalEmitter,
|
|
3464
|
-
SignalParticipant,
|
|
3465
3485
|
SignalTask,
|
|
3466
3486
|
Task,
|
|
3467
3487
|
index_default as default
|