@cadenza.io/core 1.4.0 → 1.5.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 +71 -17
- package/dist/index.d.ts +71 -17
- package/dist/index.js +305 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +304 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,8 +30,6 @@ __export(index_exports, {
|
|
|
30
30
|
SignalParticipant: () => SignalParticipant,
|
|
31
31
|
SignalTask: () => SignalTask,
|
|
32
32
|
Task: () => Task,
|
|
33
|
-
ThrottledTask: () => ThrottledTask,
|
|
34
|
-
UniqueTask: () => UniqueTask,
|
|
35
33
|
default: () => index_default
|
|
36
34
|
});
|
|
37
35
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -143,7 +141,7 @@ var SignalBroker = class _SignalBroker {
|
|
|
143
141
|
executeListener(signal, context) {
|
|
144
142
|
const obs = this.signalObservers.get(signal);
|
|
145
143
|
const runner = this.getRunner(signal);
|
|
146
|
-
if (obs && runner) {
|
|
144
|
+
if (obs && obs.tasks.size && runner) {
|
|
147
145
|
obs.fn(runner, Array.from(obs.tasks), context);
|
|
148
146
|
return true;
|
|
149
147
|
}
|
|
@@ -732,6 +730,14 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
732
730
|
if (!this.divided && !this.processing) {
|
|
733
731
|
this.start();
|
|
734
732
|
this.processing = true;
|
|
733
|
+
const inputValidation = this.task.validateInput(
|
|
734
|
+
this.context.getContext()
|
|
735
|
+
);
|
|
736
|
+
if (inputValidation !== true) {
|
|
737
|
+
this.onError(inputValidation.__validationErrors);
|
|
738
|
+
this.postProcess();
|
|
739
|
+
return this.nextNodes;
|
|
740
|
+
}
|
|
735
741
|
try {
|
|
736
742
|
this.result = this.work();
|
|
737
743
|
} catch (e) {
|
|
@@ -786,12 +792,13 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
786
792
|
}
|
|
787
793
|
this.end();
|
|
788
794
|
}
|
|
789
|
-
onError(error) {
|
|
795
|
+
onError(error, errorData = {}) {
|
|
790
796
|
this.result = {
|
|
791
797
|
...this.context.getFullContext(),
|
|
792
798
|
__error: `Node error: ${error}`,
|
|
793
799
|
error: `Node error: ${error}`,
|
|
794
|
-
returnedValue: this.result
|
|
800
|
+
returnedValue: this.result,
|
|
801
|
+
...errorData
|
|
795
802
|
};
|
|
796
803
|
this.migrate(this.result);
|
|
797
804
|
this.errored = true;
|
|
@@ -803,15 +810,26 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
803
810
|
const generator = this.result;
|
|
804
811
|
let current = generator.next();
|
|
805
812
|
while (!current.done && current.value !== void 0) {
|
|
806
|
-
|
|
807
|
-
|
|
813
|
+
const outputValidation = this.task.validateOutput(current.value);
|
|
814
|
+
if (outputValidation !== true) {
|
|
815
|
+
this.onError(outputValidation.__validationErrors);
|
|
816
|
+
break;
|
|
817
|
+
} else {
|
|
818
|
+
newNodes.push(...this.generateNewNodes(current.value));
|
|
819
|
+
current = generator.next();
|
|
820
|
+
}
|
|
808
821
|
}
|
|
809
822
|
} else if (this.result !== void 0 && !this.errored) {
|
|
810
823
|
newNodes.push(...this.generateNewNodes(this.result));
|
|
811
824
|
if (typeof this.result !== "boolean") {
|
|
825
|
+
const outputValidation = this.task.validateOutput(this.result);
|
|
826
|
+
if (outputValidation !== true) {
|
|
827
|
+
this.onError(outputValidation.__validationErrors);
|
|
828
|
+
}
|
|
812
829
|
this.migrate({ ...this.result, ...this.context.getMetaData() });
|
|
813
830
|
}
|
|
814
|
-
}
|
|
831
|
+
}
|
|
832
|
+
if (this.errored) {
|
|
815
833
|
newNodes.push(
|
|
816
834
|
...this.task.mapNext(
|
|
817
835
|
(t) => this.clone().split((0, import_uuid3.v4)()).differentiate(t).migrate({ ...this.result }),
|
|
@@ -1183,9 +1201,14 @@ var Task = class extends SignalParticipant {
|
|
|
1183
1201
|
* @param register Register via signal (default true).
|
|
1184
1202
|
* @param isUnique
|
|
1185
1203
|
* @param isMeta
|
|
1204
|
+
* @param getTagCallback
|
|
1205
|
+
* @param inputSchema
|
|
1206
|
+
* @param validateInputContext
|
|
1207
|
+
* @param outputSchema
|
|
1208
|
+
* @param validateOutputContext
|
|
1186
1209
|
* @edge Emits 'meta.task.created' with { __task: this } for seed.
|
|
1187
1210
|
*/
|
|
1188
|
-
constructor(name, task, description = "", concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false) {
|
|
1211
|
+
constructor(name, task, description = "", concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false, getTagCallback = void 0, inputSchema = void 0, validateInputContext = false, outputSchema = void 0, validateOutputContext = false) {
|
|
1189
1212
|
super();
|
|
1190
1213
|
this.isMeta = false;
|
|
1191
1214
|
this.isUnique = false;
|
|
@@ -1193,6 +1216,10 @@ var Task = class extends SignalParticipant {
|
|
|
1193
1216
|
this.isSignal = false;
|
|
1194
1217
|
this.isDeputy = false;
|
|
1195
1218
|
this.isEphemeral = false;
|
|
1219
|
+
this.inputContextSchema = void 0;
|
|
1220
|
+
this.validateInputContext = false;
|
|
1221
|
+
this.outputContextSchema = void 0;
|
|
1222
|
+
this.validateOutputContext = false;
|
|
1196
1223
|
this.layerIndex = 0;
|
|
1197
1224
|
this.progressWeight = 0;
|
|
1198
1225
|
this.nextTasks = /* @__PURE__ */ new Set();
|
|
@@ -1207,6 +1234,14 @@ var Task = class extends SignalParticipant {
|
|
|
1207
1234
|
this.timeout = timeout;
|
|
1208
1235
|
this.isUnique = isUnique;
|
|
1209
1236
|
this.isMeta = isMeta;
|
|
1237
|
+
this.inputContextSchema = inputSchema;
|
|
1238
|
+
this.validateInputContext = validateInputContext;
|
|
1239
|
+
this.outputContextSchema = outputSchema;
|
|
1240
|
+
this.validateOutputContext = validateOutputContext;
|
|
1241
|
+
if (getTagCallback) {
|
|
1242
|
+
this.getTag = (context) => getTagCallback(context, this);
|
|
1243
|
+
this.throttled = true;
|
|
1244
|
+
}
|
|
1210
1245
|
if (register) {
|
|
1211
1246
|
this.emit("meta.task.created", { __task: this });
|
|
1212
1247
|
}
|
|
@@ -1228,6 +1263,169 @@ var Task = class extends SignalParticipant {
|
|
|
1228
1263
|
setProgressWeight(weight) {
|
|
1229
1264
|
this.progressWeight = weight;
|
|
1230
1265
|
}
|
|
1266
|
+
setInputContextSchema(schema) {
|
|
1267
|
+
this.inputContextSchema = schema;
|
|
1268
|
+
}
|
|
1269
|
+
setOutputContextSchema(schema) {
|
|
1270
|
+
this.outputContextSchema = schema;
|
|
1271
|
+
}
|
|
1272
|
+
setValidateInputContext(value) {
|
|
1273
|
+
this.validateInputContext = value;
|
|
1274
|
+
}
|
|
1275
|
+
setValidateOutputContext(value) {
|
|
1276
|
+
this.validateOutputContext = value;
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Validates a context deeply against a schema.
|
|
1280
|
+
* @param data - The data to validate (input context or output result).
|
|
1281
|
+
* @param schema - The schema definition.
|
|
1282
|
+
* @param path - The current path for error reporting (default: 'root').
|
|
1283
|
+
* @returns { { valid: boolean, errors: Record<string, string> } } - Validation result with detailed errors if invalid.
|
|
1284
|
+
* @description Recursively checks types, required fields, and constraints; allows extra properties not in schema.
|
|
1285
|
+
*/
|
|
1286
|
+
validateSchema(data, schema, path = "context") {
|
|
1287
|
+
const errors = {};
|
|
1288
|
+
if (!schema || typeof schema !== "object") return { valid: true, errors };
|
|
1289
|
+
const required = schema.required || [];
|
|
1290
|
+
for (const key of required) {
|
|
1291
|
+
if (!(key in data)) {
|
|
1292
|
+
errors[`${path}.${key}`] = `Required field '${key}' is missing`;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
const properties = schema.properties || {};
|
|
1296
|
+
for (const [key, value] of Object.entries(data)) {
|
|
1297
|
+
if (key in properties) {
|
|
1298
|
+
const prop = properties[key];
|
|
1299
|
+
const propType = prop.type;
|
|
1300
|
+
if (propType === "string" && typeof value !== "string") {
|
|
1301
|
+
errors[`${path}.${key}`] = `Expected 'string' for '${key}', got '${typeof value}'`;
|
|
1302
|
+
} else if (propType === "number" && typeof value !== "number") {
|
|
1303
|
+
errors[`${path}.${key}`] = `Expected 'number' for '${key}', got '${typeof value}'`;
|
|
1304
|
+
} else if (propType === "boolean" && typeof value !== "boolean") {
|
|
1305
|
+
errors[`${path}.${key}`] = `Expected 'boolean' for '${key}', got '${typeof value}'`;
|
|
1306
|
+
} else if (propType === "array" && !Array.isArray(value)) {
|
|
1307
|
+
errors[`${path}.${key}`] = `Expected 'array' for '${key}', got '${typeof value}'`;
|
|
1308
|
+
} else if (propType === "object" && (typeof value !== "object" || value === null || Array.isArray(value))) {
|
|
1309
|
+
errors[`${path}.${key}`] = `Expected 'object' for '${key}', got '${typeof value}'`;
|
|
1310
|
+
} else if (propType === "array" && prop.items) {
|
|
1311
|
+
if (Array.isArray(value)) {
|
|
1312
|
+
value.forEach((item, index) => {
|
|
1313
|
+
const subValidation = this.validateSchema(
|
|
1314
|
+
item,
|
|
1315
|
+
prop.items,
|
|
1316
|
+
`${path}.${key}[${index}]`
|
|
1317
|
+
);
|
|
1318
|
+
if (!subValidation.valid) {
|
|
1319
|
+
Object.assign(errors, subValidation.errors);
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
} else if (propType === "object" && !Array.isArray(value) && value !== null) {
|
|
1324
|
+
const subValidation = this.validateSchema(
|
|
1325
|
+
value,
|
|
1326
|
+
prop,
|
|
1327
|
+
`${path}.${key}`
|
|
1328
|
+
);
|
|
1329
|
+
if (!subValidation.valid) {
|
|
1330
|
+
Object.assign(errors, subValidation.errors);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
const constraints = prop.constraints || {};
|
|
1334
|
+
if (typeof value === "string") {
|
|
1335
|
+
if (constraints.minLength && value.length < constraints.minLength) {
|
|
1336
|
+
errors[`${path}.${key}`] = `String '${key}' shorter than minLength ${constraints.minLength}`;
|
|
1337
|
+
}
|
|
1338
|
+
if (constraints.maxLength && value.length > constraints.maxLength) {
|
|
1339
|
+
errors[`${path}.${key}`] = `String '${key}' exceeds maxLength ${constraints.maxLength}`;
|
|
1340
|
+
}
|
|
1341
|
+
if (constraints.pattern && !new RegExp(constraints.pattern).test(value)) {
|
|
1342
|
+
errors[`${path}.${key}`] = `String '${key}' does not match pattern ${constraints.pattern}`;
|
|
1343
|
+
}
|
|
1344
|
+
} else if (typeof value === "number") {
|
|
1345
|
+
if (constraints.min && value < constraints.min) {
|
|
1346
|
+
errors[`${path}.${key}`] = `Number '${key}' below min ${constraints.min}`;
|
|
1347
|
+
}
|
|
1348
|
+
if (constraints.max && value > constraints.max) {
|
|
1349
|
+
errors[`${path}.${key}`] = `Number '${key}' exceeds max ${constraints.max}`;
|
|
1350
|
+
}
|
|
1351
|
+
if (constraints.multipleOf && value % constraints.multipleOf !== 0) {
|
|
1352
|
+
errors[`${path}.${key}`] = `Number '${key}' not multiple of ${constraints.multipleOf}`;
|
|
1353
|
+
}
|
|
1354
|
+
} else if (constraints.enum && !constraints.enum.includes(value)) {
|
|
1355
|
+
errors[`${path}.${key}`] = `Value '${value}' for '${key}' not in enum ${JSON.stringify(constraints.enum)}`;
|
|
1356
|
+
} else if (constraints.format) {
|
|
1357
|
+
const formats = {
|
|
1358
|
+
email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
|
|
1359
|
+
url: /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/,
|
|
1360
|
+
"date-time": /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/,
|
|
1361
|
+
uuid: /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
|
|
1362
|
+
custom: /.*/
|
|
1363
|
+
// Placeholder; override with prop.constraints.pattern if present
|
|
1364
|
+
};
|
|
1365
|
+
const regex = formats[constraints.format] || new RegExp(constraints.pattern || ".*");
|
|
1366
|
+
if (typeof value === "string" && !regex.test(value)) {
|
|
1367
|
+
errors[`${path}.${key}`] = `Value '${value}' for '${key}' does not match format '${constraints.format}'`;
|
|
1368
|
+
}
|
|
1369
|
+
} else if (constraints.oneOf && !constraints.oneOf.includes(value)) {
|
|
1370
|
+
errors[`${path}.${key}`] = `Value '${value}' for '${key}' not in oneOf ${JSON.stringify(constraints.oneOf)}`;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
if (Object.keys(errors).length > 0) {
|
|
1375
|
+
return { valid: false, errors };
|
|
1376
|
+
}
|
|
1377
|
+
return { valid: true, errors: {} };
|
|
1378
|
+
}
|
|
1379
|
+
validateInput(context) {
|
|
1380
|
+
if (this.validateInputContext) {
|
|
1381
|
+
const validationResult = this.validateSchema(
|
|
1382
|
+
context,
|
|
1383
|
+
this.inputContextSchema
|
|
1384
|
+
);
|
|
1385
|
+
if (!validationResult.valid) {
|
|
1386
|
+
this.emit("meta.task.validationFailed", {
|
|
1387
|
+
__taskId: this.id,
|
|
1388
|
+
__context: context,
|
|
1389
|
+
__errors: validationResult.errors
|
|
1390
|
+
});
|
|
1391
|
+
return {
|
|
1392
|
+
errored: true,
|
|
1393
|
+
__error: "Input context validation failed",
|
|
1394
|
+
__validationErrors: JSON.stringify(validationResult.errors)
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
return true;
|
|
1399
|
+
}
|
|
1400
|
+
validateOutput(context) {
|
|
1401
|
+
if (this.validateOutputContext) {
|
|
1402
|
+
const validationResult = this.validateSchema(
|
|
1403
|
+
context,
|
|
1404
|
+
this.outputContextSchema
|
|
1405
|
+
);
|
|
1406
|
+
if (!validationResult.valid) {
|
|
1407
|
+
this.emit("meta.task.outputValidationFailed", {
|
|
1408
|
+
__taskId: this.id,
|
|
1409
|
+
__result: context,
|
|
1410
|
+
__errors: validationResult.errors
|
|
1411
|
+
});
|
|
1412
|
+
return {
|
|
1413
|
+
errored: true,
|
|
1414
|
+
__error: "Output context validation failed",
|
|
1415
|
+
__validationErrors: JSON.stringify(validationResult.errors)
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
return true;
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Executes the task function after optional input validation.
|
|
1423
|
+
* @param context - The GraphContext to validate and execute.
|
|
1424
|
+
* @param progressCallback - Callback for progress updates.
|
|
1425
|
+
* @returns TaskResult from the taskFunction or error object on validation failure.
|
|
1426
|
+
* @edge If validateInputContext is true, validates context; on failure, emits 'meta.task.validationFailed' with detailed errors.
|
|
1427
|
+
* @edge If validateOutputContext is true, validates output; on failure, emits 'meta.task.outputValidationFailed' with detailed errors.
|
|
1428
|
+
*/
|
|
1231
1429
|
execute(context, progressCallback) {
|
|
1232
1430
|
return this.taskFunction(context.getClonedContext(), progressCallback);
|
|
1233
1431
|
}
|
|
@@ -1375,6 +1573,10 @@ var Task = class extends SignalParticipant {
|
|
|
1375
1573
|
__timeout: this.timeout,
|
|
1376
1574
|
__functionString: this.taskFunction.toString(),
|
|
1377
1575
|
__getTagCallback: this.getTag.toString(),
|
|
1576
|
+
__inputSchema: this.inputContextSchema,
|
|
1577
|
+
__validateInputContext: this.validateInputContext,
|
|
1578
|
+
__outputSchema: this.outputContextSchema,
|
|
1579
|
+
__validateOutputContext: this.validateOutputContext,
|
|
1378
1580
|
__nextTasks: Array.from(this.nextTasks).map((t) => t.id),
|
|
1379
1581
|
__onFailTasks: Array.from(this.onFailTasks).map((t) => t.id),
|
|
1380
1582
|
__previousTasks: Array.from(this.predecessorTasks).map((t) => t.id)
|
|
@@ -1602,7 +1804,7 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
1602
1804
|
* @edge Emits 'meta.runner.added_tasks' with metadata.
|
|
1603
1805
|
* @edge Empty tasks warns no-op.
|
|
1604
1806
|
*/
|
|
1605
|
-
addTasks(tasks, context) {
|
|
1807
|
+
addTasks(tasks, context = {}) {
|
|
1606
1808
|
var _a, _b, _c, _d, _e, _f;
|
|
1607
1809
|
let _tasks = Array.isArray(tasks) ? tasks : [tasks];
|
|
1608
1810
|
if (_tasks.length === 0) {
|
|
@@ -1708,27 +1910,9 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
1708
1910
|
}
|
|
1709
1911
|
};
|
|
1710
1912
|
|
|
1711
|
-
// src/graph/definition/ThrottledTask.ts
|
|
1712
|
-
var ThrottledTask = class extends Task {
|
|
1713
|
-
constructor(name, task, description = "", getTagCallback = (context, task2) => "default", concurrency = 1, timeout = 0, register = true, isUnique = false, isMeta = false) {
|
|
1714
|
-
super(
|
|
1715
|
-
name,
|
|
1716
|
-
task,
|
|
1717
|
-
description,
|
|
1718
|
-
concurrency,
|
|
1719
|
-
timeout,
|
|
1720
|
-
register,
|
|
1721
|
-
isUnique,
|
|
1722
|
-
isMeta
|
|
1723
|
-
);
|
|
1724
|
-
this.throttled = true;
|
|
1725
|
-
this.getTag = (context) => getTagCallback(context, this);
|
|
1726
|
-
}
|
|
1727
|
-
};
|
|
1728
|
-
|
|
1729
1913
|
// src/graph/definition/DebounceTask.ts
|
|
1730
1914
|
var DebounceTask = class extends Task {
|
|
1731
|
-
constructor(name, task, description = "", debounceTime = 1e3, leading = false, trailing = true, concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false) {
|
|
1915
|
+
constructor(name, task, description = "", debounceTime = 1e3, leading = false, trailing = true, concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false, inputSchema = void 0, validateInputSchema = false, outputSchema = void 0, validateOutputSchema = false) {
|
|
1732
1916
|
super(
|
|
1733
1917
|
name,
|
|
1734
1918
|
task,
|
|
@@ -1737,7 +1921,12 @@ var DebounceTask = class extends Task {
|
|
|
1737
1921
|
timeout,
|
|
1738
1922
|
register,
|
|
1739
1923
|
isUnique,
|
|
1740
|
-
isMeta
|
|
1924
|
+
isMeta,
|
|
1925
|
+
void 0,
|
|
1926
|
+
inputSchema,
|
|
1927
|
+
validateInputSchema,
|
|
1928
|
+
outputSchema,
|
|
1929
|
+
validateOutputSchema
|
|
1741
1930
|
);
|
|
1742
1931
|
this.timer = null;
|
|
1743
1932
|
this.lastResolve = null;
|
|
@@ -1809,7 +1998,7 @@ var DebounceTask = class extends Task {
|
|
|
1809
1998
|
|
|
1810
1999
|
// src/graph/definition/EphemeralTask.ts
|
|
1811
2000
|
var EphemeralTask = class extends Task {
|
|
1812
|
-
constructor(name, task, description = "", once = true, condition = () => true, concurrency = 0, timeout = 0, register = false, isUnique = false, isMeta = false) {
|
|
2001
|
+
constructor(name, task, description = "", once = true, condition = () => true, concurrency = 0, timeout = 0, register = false, isUnique = false, isMeta = false, getTagCallback = void 0, inputSchema = void 0, validateInputContext = false, outputSchema = void 0, validateOutputContext = false) {
|
|
1813
2002
|
super(
|
|
1814
2003
|
name,
|
|
1815
2004
|
task,
|
|
@@ -1818,7 +2007,12 @@ var EphemeralTask = class extends Task {
|
|
|
1818
2007
|
timeout,
|
|
1819
2008
|
register,
|
|
1820
2009
|
isUnique,
|
|
1821
|
-
isMeta
|
|
2010
|
+
isMeta,
|
|
2011
|
+
getTagCallback,
|
|
2012
|
+
inputSchema,
|
|
2013
|
+
validateInputContext,
|
|
2014
|
+
outputSchema,
|
|
2015
|
+
validateOutputContext
|
|
1822
2016
|
);
|
|
1823
2017
|
this.isEphemeral = true;
|
|
1824
2018
|
this.once = once;
|
|
@@ -2384,7 +2578,12 @@ var Cadenza = class {
|
|
|
2384
2578
|
timeout: 0,
|
|
2385
2579
|
register: true,
|
|
2386
2580
|
isUnique: false,
|
|
2387
|
-
isMeta: false
|
|
2581
|
+
isMeta: false,
|
|
2582
|
+
getTagCallback: void 0,
|
|
2583
|
+
inputSchema: void 0,
|
|
2584
|
+
validateInputContext: false,
|
|
2585
|
+
outputSchema: void 0,
|
|
2586
|
+
validateOutputContext: false
|
|
2388
2587
|
}) {
|
|
2389
2588
|
this.bootstrap();
|
|
2390
2589
|
this.validateName(name);
|
|
@@ -2396,7 +2595,12 @@ var Cadenza = class {
|
|
|
2396
2595
|
options.timeout,
|
|
2397
2596
|
options.register,
|
|
2398
2597
|
options.isUnique,
|
|
2399
|
-
options.isMeta
|
|
2598
|
+
options.isMeta,
|
|
2599
|
+
options.getTagCallback,
|
|
2600
|
+
options.inputSchema,
|
|
2601
|
+
options.validateInputContext,
|
|
2602
|
+
options.outputSchema,
|
|
2603
|
+
options.validateOutputContext
|
|
2400
2604
|
);
|
|
2401
2605
|
}
|
|
2402
2606
|
/**
|
|
@@ -2414,7 +2618,12 @@ var Cadenza = class {
|
|
|
2414
2618
|
timeout: 0,
|
|
2415
2619
|
register: true,
|
|
2416
2620
|
isUnique: false,
|
|
2417
|
-
isMeta: true
|
|
2621
|
+
isMeta: true,
|
|
2622
|
+
getTagCallback: void 0,
|
|
2623
|
+
inputSchema: void 0,
|
|
2624
|
+
validateInputContext: false,
|
|
2625
|
+
outputSchema: void 0,
|
|
2626
|
+
validateOutputContext: false
|
|
2418
2627
|
}) {
|
|
2419
2628
|
options.isMeta = true;
|
|
2420
2629
|
return this.createTask(name, func, description, options);
|
|
@@ -2434,7 +2643,12 @@ var Cadenza = class {
|
|
|
2434
2643
|
timeout: 0,
|
|
2435
2644
|
register: true,
|
|
2436
2645
|
isUnique: true,
|
|
2437
|
-
isMeta: false
|
|
2646
|
+
isMeta: false,
|
|
2647
|
+
getTagCallback: void 0,
|
|
2648
|
+
inputSchema: void 0,
|
|
2649
|
+
validateInputContext: false,
|
|
2650
|
+
outputSchema: void 0,
|
|
2651
|
+
validateOutputContext: false
|
|
2438
2652
|
}) {
|
|
2439
2653
|
options.isUnique = true;
|
|
2440
2654
|
return this.createTask(name, func, description, options);
|
|
@@ -2452,7 +2666,12 @@ var Cadenza = class {
|
|
|
2452
2666
|
timeout: 0,
|
|
2453
2667
|
register: true,
|
|
2454
2668
|
isUnique: true,
|
|
2455
|
-
isMeta: true
|
|
2669
|
+
isMeta: true,
|
|
2670
|
+
getTagCallback: void 0,
|
|
2671
|
+
inputSchema: void 0,
|
|
2672
|
+
validateInputContext: false,
|
|
2673
|
+
outputSchema: void 0,
|
|
2674
|
+
validateOutputContext: false
|
|
2456
2675
|
}) {
|
|
2457
2676
|
options.isMeta = true;
|
|
2458
2677
|
return this.createUniqueTask(name, func, description, options);
|
|
@@ -2467,26 +2686,19 @@ var Cadenza = class {
|
|
|
2467
2686
|
* @returns The created ThrottledTask.
|
|
2468
2687
|
* @edge If no getter, throttles per task ID; use for resource protection.
|
|
2469
2688
|
*/
|
|
2470
|
-
static createThrottledTask(name, func, throttledIdGetter, description, options = {
|
|
2689
|
+
static createThrottledTask(name, func, throttledIdGetter = () => "default", description, options = {
|
|
2471
2690
|
concurrency: 1,
|
|
2472
2691
|
timeout: 0,
|
|
2473
2692
|
register: true,
|
|
2474
2693
|
isUnique: false,
|
|
2475
|
-
isMeta: false
|
|
2694
|
+
isMeta: false,
|
|
2695
|
+
inputSchema: void 0,
|
|
2696
|
+
validateInputContext: false,
|
|
2697
|
+
outputSchema: void 0,
|
|
2698
|
+
validateOutputContext: false
|
|
2476
2699
|
}) {
|
|
2477
|
-
|
|
2478
|
-
this.
|
|
2479
|
-
return new ThrottledTask(
|
|
2480
|
-
name,
|
|
2481
|
-
func,
|
|
2482
|
-
description,
|
|
2483
|
-
throttledIdGetter,
|
|
2484
|
-
options.concurrency,
|
|
2485
|
-
options.timeout,
|
|
2486
|
-
options.register,
|
|
2487
|
-
options.isUnique,
|
|
2488
|
-
options.isMeta
|
|
2489
|
-
);
|
|
2700
|
+
options.getTagCallback = throttledIdGetter;
|
|
2701
|
+
return this.createTask(name, func, description, options);
|
|
2490
2702
|
}
|
|
2491
2703
|
/**
|
|
2492
2704
|
* Creates a ThrottledMetaTask for meta-layer throttling.
|
|
@@ -2502,7 +2714,11 @@ var Cadenza = class {
|
|
|
2502
2714
|
timeout: 0,
|
|
2503
2715
|
register: true,
|
|
2504
2716
|
isUnique: false,
|
|
2505
|
-
isMeta: true
|
|
2717
|
+
isMeta: true,
|
|
2718
|
+
inputSchema: void 0,
|
|
2719
|
+
validateInputContext: false,
|
|
2720
|
+
outputSchema: void 0,
|
|
2721
|
+
validateOutputContext: false
|
|
2506
2722
|
}) {
|
|
2507
2723
|
options.isMeta = true;
|
|
2508
2724
|
return this.createThrottledTask(
|
|
@@ -2530,7 +2746,11 @@ var Cadenza = class {
|
|
|
2530
2746
|
leading: false,
|
|
2531
2747
|
trailing: true,
|
|
2532
2748
|
isUnique: false,
|
|
2533
|
-
isMeta: false
|
|
2749
|
+
isMeta: false,
|
|
2750
|
+
inputSchema: void 0,
|
|
2751
|
+
validateInputContext: false,
|
|
2752
|
+
outputSchema: void 0,
|
|
2753
|
+
validateOutputContext: false
|
|
2534
2754
|
}) {
|
|
2535
2755
|
this.bootstrap();
|
|
2536
2756
|
this.validateName(name);
|
|
@@ -2545,7 +2765,11 @@ var Cadenza = class {
|
|
|
2545
2765
|
options.timeout,
|
|
2546
2766
|
options.register,
|
|
2547
2767
|
options.isUnique,
|
|
2548
|
-
options.isMeta
|
|
2768
|
+
options.isMeta,
|
|
2769
|
+
options.inputSchema,
|
|
2770
|
+
options.validateInputContext,
|
|
2771
|
+
options.outputSchema,
|
|
2772
|
+
options.validateOutputContext
|
|
2549
2773
|
);
|
|
2550
2774
|
}
|
|
2551
2775
|
/**
|
|
@@ -2564,7 +2788,11 @@ var Cadenza = class {
|
|
|
2564
2788
|
leading: false,
|
|
2565
2789
|
trailing: true,
|
|
2566
2790
|
isUnique: false,
|
|
2567
|
-
isMeta: false
|
|
2791
|
+
isMeta: false,
|
|
2792
|
+
inputSchema: void 0,
|
|
2793
|
+
validateInputContext: false,
|
|
2794
|
+
outputSchema: void 0,
|
|
2795
|
+
validateOutputContext: false
|
|
2568
2796
|
}) {
|
|
2569
2797
|
options.isMeta = true;
|
|
2570
2798
|
return this.createDebounceTask(
|
|
@@ -2592,7 +2820,12 @@ var Cadenza = class {
|
|
|
2592
2820
|
timeout: 0,
|
|
2593
2821
|
register: true,
|
|
2594
2822
|
isUnique: false,
|
|
2595
|
-
isMeta: false
|
|
2823
|
+
isMeta: false,
|
|
2824
|
+
getTagCallback: void 0,
|
|
2825
|
+
inputSchema: void 0,
|
|
2826
|
+
validateInputContext: false,
|
|
2827
|
+
outputSchema: void 0,
|
|
2828
|
+
validateOutputContext: false
|
|
2596
2829
|
}) {
|
|
2597
2830
|
this.bootstrap();
|
|
2598
2831
|
this.validateName(name);
|
|
@@ -2606,7 +2839,12 @@ var Cadenza = class {
|
|
|
2606
2839
|
options.timeout,
|
|
2607
2840
|
options.register,
|
|
2608
2841
|
options.isUnique,
|
|
2609
|
-
options.isMeta
|
|
2842
|
+
options.isMeta,
|
|
2843
|
+
options.getTagCallback,
|
|
2844
|
+
options.inputSchema,
|
|
2845
|
+
options.validateInputContext,
|
|
2846
|
+
options.outputSchema,
|
|
2847
|
+
options.validateOutputContext
|
|
2610
2848
|
);
|
|
2611
2849
|
}
|
|
2612
2850
|
/**
|
|
@@ -2622,7 +2860,14 @@ var Cadenza = class {
|
|
|
2622
2860
|
static createEphemeralMetaTask(name, func, description, once = true, destroyCondition = () => true, options = {
|
|
2623
2861
|
concurrency: 0,
|
|
2624
2862
|
timeout: 0,
|
|
2625
|
-
register: true
|
|
2863
|
+
register: true,
|
|
2864
|
+
isUnique: false,
|
|
2865
|
+
isMeta: true,
|
|
2866
|
+
getTagCallback: void 0,
|
|
2867
|
+
inputSchema: void 0,
|
|
2868
|
+
validateInputContext: false,
|
|
2869
|
+
outputSchema: void 0,
|
|
2870
|
+
validateOutputContext: false
|
|
2626
2871
|
}) {
|
|
2627
2872
|
options.isMeta = true;
|
|
2628
2873
|
return this.createEphemeralTask(
|
|
@@ -2681,14 +2926,6 @@ var SignalTask = class extends Task {
|
|
|
2681
2926
|
}
|
|
2682
2927
|
};
|
|
2683
2928
|
|
|
2684
|
-
// src/graph/definition/UniqueTask.ts
|
|
2685
|
-
var UniqueTask = class extends Task {
|
|
2686
|
-
constructor() {
|
|
2687
|
-
super(...arguments);
|
|
2688
|
-
this.isUnique = true;
|
|
2689
|
-
}
|
|
2690
|
-
};
|
|
2691
|
-
|
|
2692
2929
|
// src/index.ts
|
|
2693
2930
|
var index_default = Cadenza;
|
|
2694
2931
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -2702,8 +2939,6 @@ var index_default = Cadenza;
|
|
|
2702
2939
|
SignalEmitter,
|
|
2703
2940
|
SignalParticipant,
|
|
2704
2941
|
SignalTask,
|
|
2705
|
-
Task
|
|
2706
|
-
ThrottledTask,
|
|
2707
|
-
UniqueTask
|
|
2942
|
+
Task
|
|
2708
2943
|
});
|
|
2709
2944
|
//# sourceMappingURL=index.js.map
|