@cadenza.io/core 1.11.15 → 1.12.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 +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +118 -181
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -181
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -896,7 +896,11 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
896
896
|
if (this.result instanceof Promise) {
|
|
897
897
|
return this.executeAsync();
|
|
898
898
|
}
|
|
899
|
-
this.postProcess();
|
|
899
|
+
const nextNodes = this.postProcess();
|
|
900
|
+
if (nextNodes instanceof Promise) {
|
|
901
|
+
return nextNodes;
|
|
902
|
+
}
|
|
903
|
+
this.nextNodes = nextNodes;
|
|
900
904
|
}
|
|
901
905
|
return this.nextNodes;
|
|
902
906
|
}
|
|
@@ -912,7 +916,11 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
912
916
|
}
|
|
913
917
|
async executeAsync() {
|
|
914
918
|
await this.workAsync();
|
|
915
|
-
this.postProcess();
|
|
919
|
+
const nextNodes = this.postProcess();
|
|
920
|
+
if (nextNodes instanceof Promise) {
|
|
921
|
+
return nextNodes;
|
|
922
|
+
}
|
|
923
|
+
this.nextNodes = nextNodes;
|
|
916
924
|
return this.nextNodes;
|
|
917
925
|
}
|
|
918
926
|
work() {
|
|
@@ -998,7 +1006,20 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
998
1006
|
if (Array.isArray(this.result)) {
|
|
999
1007
|
this.onError(`Returning arrays is not allowed. Returned: ${this.result}`);
|
|
1000
1008
|
}
|
|
1001
|
-
|
|
1009
|
+
const nextNodes = this.divide();
|
|
1010
|
+
if (nextNodes instanceof Promise) {
|
|
1011
|
+
return this.postProcessAsync(nextNodes);
|
|
1012
|
+
}
|
|
1013
|
+
this.nextNodes = nextNodes;
|
|
1014
|
+
this.finalize();
|
|
1015
|
+
return this.nextNodes;
|
|
1016
|
+
}
|
|
1017
|
+
async postProcessAsync(nextNodes) {
|
|
1018
|
+
this.nextNodes = await nextNodes;
|
|
1019
|
+
this.finalize();
|
|
1020
|
+
return this.nextNodes;
|
|
1021
|
+
}
|
|
1022
|
+
finalize() {
|
|
1002
1023
|
if (this.nextNodes.length === 0) {
|
|
1003
1024
|
this.completeSubgraph();
|
|
1004
1025
|
}
|
|
@@ -1055,6 +1076,9 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1055
1076
|
if (((_a = this.result) == null ? void 0 : _a.next) && typeof this.result.next === "function") {
|
|
1056
1077
|
const generator = this.result;
|
|
1057
1078
|
let current = generator.next();
|
|
1079
|
+
if (current instanceof Promise) {
|
|
1080
|
+
return this.divideAsync(current);
|
|
1081
|
+
}
|
|
1058
1082
|
while (!current.done && current.value !== void 0) {
|
|
1059
1083
|
const outputValidation = this.task.validateOutput(current.value);
|
|
1060
1084
|
if (outputValidation !== true) {
|
|
@@ -1098,6 +1122,28 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
1098
1122
|
});
|
|
1099
1123
|
return newNodes;
|
|
1100
1124
|
}
|
|
1125
|
+
async divideAsync(current) {
|
|
1126
|
+
const nextNodes = [];
|
|
1127
|
+
const _current = await current;
|
|
1128
|
+
const outputValidation = this.task.validateOutput(_current.value);
|
|
1129
|
+
if (outputValidation !== true) {
|
|
1130
|
+
this.onError(outputValidation.__validationErrors);
|
|
1131
|
+
return nextNodes;
|
|
1132
|
+
} else {
|
|
1133
|
+
nextNodes.push(...this.generateNewNodes(_current.value));
|
|
1134
|
+
}
|
|
1135
|
+
for await (const result of this.result) {
|
|
1136
|
+
const outputValidation2 = this.task.validateOutput(result);
|
|
1137
|
+
if (outputValidation2 !== true) {
|
|
1138
|
+
this.onError(outputValidation2.__validationErrors);
|
|
1139
|
+
return [];
|
|
1140
|
+
} else {
|
|
1141
|
+
nextNodes.push(...this.generateNewNodes(result));
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
this.divided = true;
|
|
1145
|
+
return nextNodes;
|
|
1146
|
+
}
|
|
1101
1147
|
generateNewNodes(result) {
|
|
1102
1148
|
const groupId = uuid3();
|
|
1103
1149
|
const newNodes = [];
|
|
@@ -3095,26 +3141,28 @@ var Cadenza = class {
|
|
|
3095
3141
|
* @returns The created Task instance.
|
|
3096
3142
|
* @throws Error if name is invalid or duplicate in registry.
|
|
3097
3143
|
*/
|
|
3098
|
-
static createTask(name, func, description, options = {
|
|
3099
|
-
concurrency: 0,
|
|
3100
|
-
timeout: 0,
|
|
3101
|
-
register: true,
|
|
3102
|
-
isUnique: false,
|
|
3103
|
-
isMeta: false,
|
|
3104
|
-
isSubMeta: false,
|
|
3105
|
-
isHidden: false,
|
|
3106
|
-
getTagCallback: void 0,
|
|
3107
|
-
inputSchema: void 0,
|
|
3108
|
-
validateInputContext: false,
|
|
3109
|
-
outputSchema: void 0,
|
|
3110
|
-
validateOutputContext: false,
|
|
3111
|
-
retryCount: 0,
|
|
3112
|
-
retryDelay: 0,
|
|
3113
|
-
retryDelayMax: 0,
|
|
3114
|
-
retryDelayFactor: 1
|
|
3115
|
-
}) {
|
|
3144
|
+
static createTask(name, func, description, options = {}) {
|
|
3116
3145
|
this.bootstrap();
|
|
3117
3146
|
this.validateName(name);
|
|
3147
|
+
options = {
|
|
3148
|
+
concurrency: 0,
|
|
3149
|
+
timeout: 0,
|
|
3150
|
+
register: true,
|
|
3151
|
+
isUnique: false,
|
|
3152
|
+
isMeta: false,
|
|
3153
|
+
isSubMeta: false,
|
|
3154
|
+
isHidden: false,
|
|
3155
|
+
getTagCallback: void 0,
|
|
3156
|
+
inputSchema: void 0,
|
|
3157
|
+
validateInputContext: false,
|
|
3158
|
+
outputSchema: void 0,
|
|
3159
|
+
validateOutputContext: false,
|
|
3160
|
+
retryCount: 0,
|
|
3161
|
+
retryDelay: 0,
|
|
3162
|
+
retryDelayMax: 0,
|
|
3163
|
+
retryDelayFactor: 1,
|
|
3164
|
+
...options
|
|
3165
|
+
};
|
|
3118
3166
|
return new Task(
|
|
3119
3167
|
name,
|
|
3120
3168
|
func,
|
|
@@ -3147,24 +3195,7 @@ var Cadenza = class {
|
|
|
3147
3195
|
* @returns The created MetaTask instance.
|
|
3148
3196
|
* @throws Error if name invalid or duplicate.
|
|
3149
3197
|
*/
|
|
3150
|
-
static createMetaTask(name, func, description, options = {
|
|
3151
|
-
concurrency: 0,
|
|
3152
|
-
timeout: 0,
|
|
3153
|
-
register: true,
|
|
3154
|
-
isUnique: false,
|
|
3155
|
-
isMeta: true,
|
|
3156
|
-
isSubMeta: false,
|
|
3157
|
-
isHidden: false,
|
|
3158
|
-
getTagCallback: void 0,
|
|
3159
|
-
inputSchema: void 0,
|
|
3160
|
-
validateInputContext: false,
|
|
3161
|
-
outputSchema: void 0,
|
|
3162
|
-
validateOutputContext: false,
|
|
3163
|
-
retryCount: 0,
|
|
3164
|
-
retryDelay: 0,
|
|
3165
|
-
retryDelayMax: 0,
|
|
3166
|
-
retryDelayFactor: 1
|
|
3167
|
-
}) {
|
|
3198
|
+
static createMetaTask(name, func, description, options = {}) {
|
|
3168
3199
|
options.isMeta = true;
|
|
3169
3200
|
return this.createTask(name, func, description, options);
|
|
3170
3201
|
}
|
|
@@ -3178,24 +3209,7 @@ var Cadenza = class {
|
|
|
3178
3209
|
* @returns The created UniqueTask.
|
|
3179
3210
|
* @throws Error if invalid.
|
|
3180
3211
|
*/
|
|
3181
|
-
static createUniqueTask(name, func, description, options = {
|
|
3182
|
-
concurrency: 0,
|
|
3183
|
-
timeout: 0,
|
|
3184
|
-
register: true,
|
|
3185
|
-
isUnique: true,
|
|
3186
|
-
isMeta: false,
|
|
3187
|
-
isSubMeta: false,
|
|
3188
|
-
isHidden: false,
|
|
3189
|
-
getTagCallback: void 0,
|
|
3190
|
-
inputSchema: void 0,
|
|
3191
|
-
validateInputContext: false,
|
|
3192
|
-
outputSchema: void 0,
|
|
3193
|
-
validateOutputContext: false,
|
|
3194
|
-
retryCount: 0,
|
|
3195
|
-
retryDelay: 0,
|
|
3196
|
-
retryDelayMax: 0,
|
|
3197
|
-
retryDelayFactor: 1
|
|
3198
|
-
}) {
|
|
3212
|
+
static createUniqueTask(name, func, description, options = {}) {
|
|
3199
3213
|
options.isUnique = true;
|
|
3200
3214
|
return this.createTask(name, func, description, options);
|
|
3201
3215
|
}
|
|
@@ -3207,25 +3221,9 @@ var Cadenza = class {
|
|
|
3207
3221
|
* @param options Optional task options.
|
|
3208
3222
|
* @returns The created UniqueMetaTask.
|
|
3209
3223
|
*/
|
|
3210
|
-
static createUniqueMetaTask(name, func, description, options = {
|
|
3211
|
-
concurrency: 0,
|
|
3212
|
-
timeout: 0,
|
|
3213
|
-
register: true,
|
|
3214
|
-
isUnique: true,
|
|
3215
|
-
isMeta: true,
|
|
3216
|
-
isSubMeta: false,
|
|
3217
|
-
isHidden: false,
|
|
3218
|
-
getTagCallback: void 0,
|
|
3219
|
-
inputSchema: void 0,
|
|
3220
|
-
validateInputContext: false,
|
|
3221
|
-
outputSchema: void 0,
|
|
3222
|
-
validateOutputContext: false,
|
|
3223
|
-
retryCount: 0,
|
|
3224
|
-
retryDelay: 0,
|
|
3225
|
-
retryDelayMax: 0,
|
|
3226
|
-
retryDelayFactor: 1
|
|
3227
|
-
}) {
|
|
3224
|
+
static createUniqueMetaTask(name, func, description, options = {}) {
|
|
3228
3225
|
options.isMeta = true;
|
|
3226
|
+
options.isUnique = true;
|
|
3229
3227
|
return this.createUniqueTask(name, func, description, options);
|
|
3230
3228
|
}
|
|
3231
3229
|
/**
|
|
@@ -3238,23 +3236,8 @@ var Cadenza = class {
|
|
|
3238
3236
|
* @returns The created ThrottledTask.
|
|
3239
3237
|
* @edge If no getter, throttles per task ID; use for resource protection.
|
|
3240
3238
|
*/
|
|
3241
|
-
static createThrottledTask(name, func, throttledIdGetter = () => "default", description, options = {
|
|
3242
|
-
concurrency
|
|
3243
|
-
timeout: 0,
|
|
3244
|
-
register: true,
|
|
3245
|
-
isUnique: false,
|
|
3246
|
-
isMeta: false,
|
|
3247
|
-
isSubMeta: false,
|
|
3248
|
-
isHidden: false,
|
|
3249
|
-
inputSchema: void 0,
|
|
3250
|
-
validateInputContext: false,
|
|
3251
|
-
outputSchema: void 0,
|
|
3252
|
-
validateOutputContext: false,
|
|
3253
|
-
retryCount: 0,
|
|
3254
|
-
retryDelay: 0,
|
|
3255
|
-
retryDelayMax: 0,
|
|
3256
|
-
retryDelayFactor: 1
|
|
3257
|
-
}) {
|
|
3239
|
+
static createThrottledTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
3240
|
+
options.concurrency = 1;
|
|
3258
3241
|
options.getTagCallback = throttledIdGetter;
|
|
3259
3242
|
return this.createTask(name, func, description, options);
|
|
3260
3243
|
}
|
|
@@ -3267,23 +3250,7 @@ var Cadenza = class {
|
|
|
3267
3250
|
* @param options Optional task options.
|
|
3268
3251
|
* @returns The created ThrottledMetaTask.
|
|
3269
3252
|
*/
|
|
3270
|
-
static createThrottledMetaTask(name, func, throttledIdGetter, description, options = {
|
|
3271
|
-
concurrency: 0,
|
|
3272
|
-
timeout: 0,
|
|
3273
|
-
register: true,
|
|
3274
|
-
isUnique: false,
|
|
3275
|
-
isMeta: true,
|
|
3276
|
-
isSubMeta: false,
|
|
3277
|
-
isHidden: false,
|
|
3278
|
-
inputSchema: void 0,
|
|
3279
|
-
validateInputContext: false,
|
|
3280
|
-
outputSchema: void 0,
|
|
3281
|
-
validateOutputContext: false,
|
|
3282
|
-
retryCount: 0,
|
|
3283
|
-
retryDelay: 0,
|
|
3284
|
-
retryDelayMax: 0,
|
|
3285
|
-
retryDelayFactor: 1
|
|
3286
|
-
}) {
|
|
3253
|
+
static createThrottledMetaTask(name, func, throttledIdGetter, description, options = {}) {
|
|
3287
3254
|
options.isMeta = true;
|
|
3288
3255
|
return this.createThrottledTask(
|
|
3289
3256
|
name,
|
|
@@ -3303,24 +3270,26 @@ var Cadenza = class {
|
|
|
3303
3270
|
* @returns The created DebounceTask.
|
|
3304
3271
|
* @edge Multiple triggers within time collapse to one exec.
|
|
3305
3272
|
*/
|
|
3306
|
-
static createDebounceTask(name, func, description, debounceTime = 1e3, options = {
|
|
3307
|
-
concurrency: 0,
|
|
3308
|
-
timeout: 0,
|
|
3309
|
-
register: true,
|
|
3310
|
-
leading: false,
|
|
3311
|
-
trailing: true,
|
|
3312
|
-
maxWait: 0,
|
|
3313
|
-
isUnique: false,
|
|
3314
|
-
isMeta: false,
|
|
3315
|
-
isSubMeta: false,
|
|
3316
|
-
isHidden: false,
|
|
3317
|
-
inputSchema: void 0,
|
|
3318
|
-
validateInputContext: false,
|
|
3319
|
-
outputSchema: void 0,
|
|
3320
|
-
validateOutputContext: false
|
|
3321
|
-
}) {
|
|
3273
|
+
static createDebounceTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
3322
3274
|
this.bootstrap();
|
|
3323
3275
|
this.validateName(name);
|
|
3276
|
+
options = {
|
|
3277
|
+
concurrency: 0,
|
|
3278
|
+
timeout: 0,
|
|
3279
|
+
register: true,
|
|
3280
|
+
leading: false,
|
|
3281
|
+
trailing: true,
|
|
3282
|
+
maxWait: 0,
|
|
3283
|
+
isUnique: false,
|
|
3284
|
+
isMeta: false,
|
|
3285
|
+
isSubMeta: false,
|
|
3286
|
+
isHidden: false,
|
|
3287
|
+
inputSchema: void 0,
|
|
3288
|
+
validateInputContext: false,
|
|
3289
|
+
outputSchema: void 0,
|
|
3290
|
+
validateOutputContext: false,
|
|
3291
|
+
...options
|
|
3292
|
+
};
|
|
3324
3293
|
return new DebounceTask(
|
|
3325
3294
|
name,
|
|
3326
3295
|
func,
|
|
@@ -3351,22 +3320,7 @@ var Cadenza = class {
|
|
|
3351
3320
|
* @param options Optional task options plus optional debounce config (e.g., leading/trailing).
|
|
3352
3321
|
* @returns The created DebouncedMetaTask.
|
|
3353
3322
|
*/
|
|
3354
|
-
static createDebounceMetaTask(name, func, description, debounceTime = 1e3, options = {
|
|
3355
|
-
concurrency: 0,
|
|
3356
|
-
timeout: 0,
|
|
3357
|
-
register: true,
|
|
3358
|
-
leading: false,
|
|
3359
|
-
trailing: true,
|
|
3360
|
-
maxWait: 0,
|
|
3361
|
-
isUnique: false,
|
|
3362
|
-
isMeta: false,
|
|
3363
|
-
isSubMeta: false,
|
|
3364
|
-
isHidden: false,
|
|
3365
|
-
inputSchema: void 0,
|
|
3366
|
-
validateInputContext: false,
|
|
3367
|
-
outputSchema: void 0,
|
|
3368
|
-
validateOutputContext: false
|
|
3369
|
-
}) {
|
|
3323
|
+
static createDebounceMetaTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
3370
3324
|
options.isMeta = true;
|
|
3371
3325
|
return this.createDebounceTask(
|
|
3372
3326
|
name,
|
|
@@ -3386,28 +3340,30 @@ var Cadenza = class {
|
|
|
3386
3340
|
* @returns The created EphemeralTask.
|
|
3387
3341
|
* @edge Destruction triggered post-exec via Node/Builder; emits meta-signal for cleanup.
|
|
3388
3342
|
*/
|
|
3389
|
-
static createEphemeralTask(name, func, description, options = {
|
|
3390
|
-
concurrency: 0,
|
|
3391
|
-
timeout: 0,
|
|
3392
|
-
register: true,
|
|
3393
|
-
isUnique: false,
|
|
3394
|
-
isMeta: false,
|
|
3395
|
-
isSubMeta: false,
|
|
3396
|
-
isHidden: false,
|
|
3397
|
-
once: true,
|
|
3398
|
-
destroyCondition: () => true,
|
|
3399
|
-
getTagCallback: void 0,
|
|
3400
|
-
inputSchema: void 0,
|
|
3401
|
-
validateInputContext: false,
|
|
3402
|
-
outputSchema: void 0,
|
|
3403
|
-
validateOutputContext: false,
|
|
3404
|
-
retryCount: 0,
|
|
3405
|
-
retryDelay: 0,
|
|
3406
|
-
retryDelayMax: 0,
|
|
3407
|
-
retryDelayFactor: 1
|
|
3408
|
-
}) {
|
|
3343
|
+
static createEphemeralTask(name, func, description, options = {}) {
|
|
3409
3344
|
this.bootstrap();
|
|
3410
3345
|
this.validateName(name);
|
|
3346
|
+
options = {
|
|
3347
|
+
concurrency: 0,
|
|
3348
|
+
timeout: 0,
|
|
3349
|
+
register: true,
|
|
3350
|
+
isUnique: false,
|
|
3351
|
+
isMeta: false,
|
|
3352
|
+
isSubMeta: false,
|
|
3353
|
+
isHidden: false,
|
|
3354
|
+
once: true,
|
|
3355
|
+
destroyCondition: () => true,
|
|
3356
|
+
getTagCallback: void 0,
|
|
3357
|
+
inputSchema: void 0,
|
|
3358
|
+
validateInputContext: false,
|
|
3359
|
+
outputSchema: void 0,
|
|
3360
|
+
validateOutputContext: false,
|
|
3361
|
+
retryCount: 0,
|
|
3362
|
+
retryDelay: 0,
|
|
3363
|
+
retryDelayMax: 0,
|
|
3364
|
+
retryDelayFactor: 1,
|
|
3365
|
+
...options
|
|
3366
|
+
};
|
|
3411
3367
|
return new EphemeralTask(
|
|
3412
3368
|
name,
|
|
3413
3369
|
func,
|
|
@@ -3440,26 +3396,7 @@ var Cadenza = class {
|
|
|
3440
3396
|
* @param options Optional task options plus optional "once" (true) and "destroyCondition" (ctx => boolean).
|
|
3441
3397
|
* @returns The created EphemeralMetaTask.
|
|
3442
3398
|
*/
|
|
3443
|
-
static createEphemeralMetaTask(name, func, description, options = {
|
|
3444
|
-
concurrency: 0,
|
|
3445
|
-
timeout: 0,
|
|
3446
|
-
register: true,
|
|
3447
|
-
isUnique: false,
|
|
3448
|
-
isMeta: true,
|
|
3449
|
-
isSubMeta: false,
|
|
3450
|
-
isHidden: false,
|
|
3451
|
-
once: true,
|
|
3452
|
-
destroyCondition: () => true,
|
|
3453
|
-
getTagCallback: void 0,
|
|
3454
|
-
inputSchema: void 0,
|
|
3455
|
-
validateInputContext: false,
|
|
3456
|
-
outputSchema: void 0,
|
|
3457
|
-
validateOutputContext: false,
|
|
3458
|
-
retryCount: 0,
|
|
3459
|
-
retryDelay: 0,
|
|
3460
|
-
retryDelayMax: 0,
|
|
3461
|
-
retryDelayFactor: 1
|
|
3462
|
-
}) {
|
|
3399
|
+
static createEphemeralMetaTask(name, func, description, options = {}) {
|
|
3463
3400
|
options.isMeta = true;
|
|
3464
3401
|
return this.createEphemeralTask(name, func, description, options);
|
|
3465
3402
|
}
|