@cadenza.io/core 3.17.0 → 3.18.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 +99 -39
- package/dist/index.d.ts +99 -39
- package/dist/index.js +306 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +306 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -319,6 +319,81 @@ declare abstract class GraphLayer extends ExecutionChain implements Graph {
|
|
|
319
319
|
log(): void;
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
type SchemaType = "string" | "number" | "boolean" | "array" | "object" | "any";
|
|
323
|
+
type SchemaConstraints = {
|
|
324
|
+
min?: number;
|
|
325
|
+
max?: number;
|
|
326
|
+
minLength?: number;
|
|
327
|
+
maxLength?: number;
|
|
328
|
+
pattern?: string;
|
|
329
|
+
enum?: any[];
|
|
330
|
+
multipleOf?: number;
|
|
331
|
+
format?: "email" | "url" | "date-time" | "uuid" | "custom";
|
|
332
|
+
oneOf?: any[];
|
|
333
|
+
};
|
|
334
|
+
type SchemaDefinition = {
|
|
335
|
+
type: SchemaType;
|
|
336
|
+
required?: string[];
|
|
337
|
+
properties?: {
|
|
338
|
+
[key: string]: SchemaDefinition;
|
|
339
|
+
};
|
|
340
|
+
items?: SchemaDefinition;
|
|
341
|
+
constraints?: SchemaConstraints;
|
|
342
|
+
description?: string;
|
|
343
|
+
strict?: boolean;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
interface Intent {
|
|
347
|
+
name: string;
|
|
348
|
+
description?: string;
|
|
349
|
+
input?: SchemaDefinition;
|
|
350
|
+
output?: SchemaDefinition;
|
|
351
|
+
}
|
|
352
|
+
interface InquiryOptions {
|
|
353
|
+
timeout: number;
|
|
354
|
+
}
|
|
355
|
+
declare class InquiryBroker extends SignalEmitter {
|
|
356
|
+
static instance_: InquiryBroker;
|
|
357
|
+
static get instance(): InquiryBroker;
|
|
358
|
+
debug: boolean;
|
|
359
|
+
verbose: boolean;
|
|
360
|
+
setDebug(value: boolean): void;
|
|
361
|
+
setVerbose(value: boolean): void;
|
|
362
|
+
validateInquiryName(inquiryName: string): void;
|
|
363
|
+
runner: GraphRunner | undefined;
|
|
364
|
+
metaRunner: GraphRunner | undefined;
|
|
365
|
+
inquiryObservers: Map<string, {
|
|
366
|
+
fn: (runner: GraphRunner, tasks: Task[], context: AnyObject) => void;
|
|
367
|
+
tasks: Set<Task>;
|
|
368
|
+
registered: boolean;
|
|
369
|
+
}>;
|
|
370
|
+
intents: Map<string, Intent>;
|
|
371
|
+
/**
|
|
372
|
+
* Initializes with runners.
|
|
373
|
+
* @param runner Standard runner for user signals.
|
|
374
|
+
* @param metaRunner Meta runner for 'meta.' signals (suppresses further meta-emits).
|
|
375
|
+
*/
|
|
376
|
+
bootstrap(runner: GraphRunner, metaRunner: GraphRunner): void;
|
|
377
|
+
init(): void;
|
|
378
|
+
/**
|
|
379
|
+
* Observes an inquiry with a routine/task.
|
|
380
|
+
* @param inquiry The inquiry (e.g., 'domain.action', 'domain.*' for wildcards).
|
|
381
|
+
* @param task The observer.
|
|
382
|
+
* @edge Duplicates ignored; supports wildcards for broad listening.
|
|
383
|
+
*/
|
|
384
|
+
observe(inquiry: string, task: Task): void;
|
|
385
|
+
/**
|
|
386
|
+
* Unsubscribes a routine/task from an inquiry.
|
|
387
|
+
* @param inquiry The inquiry.
|
|
388
|
+
* @param task The observer.
|
|
389
|
+
* @edge Removes all instances if duplicate; deletes if empty.
|
|
390
|
+
*/
|
|
391
|
+
unsubscribe(inquiry: string, task: Task): void;
|
|
392
|
+
addInquiry(inquiry: string): void;
|
|
393
|
+
addIntent(intent: Intent): void;
|
|
394
|
+
inquire(inquiry: string, context: AnyObject, options?: InquiryOptions): Promise<AnyObject>;
|
|
395
|
+
}
|
|
396
|
+
|
|
322
397
|
/**
|
|
323
398
|
* Represents a node in a graph structure used for executing tasks.
|
|
324
399
|
* A Node is a container for a task and its associated context, providing
|
|
@@ -474,6 +549,7 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
474
549
|
* failure and error propagation.
|
|
475
550
|
*/
|
|
476
551
|
work(): TaskResult | Promise<TaskResult>;
|
|
552
|
+
inquire(inquiry: string, context: AnyObject, options: InquiryOptions): Promise<any>;
|
|
477
553
|
/**
|
|
478
554
|
* Emits a signal along with its associated metadata. The metadata includes
|
|
479
555
|
* task-specific information such as task name, version, execution ID, and
|
|
@@ -748,31 +824,7 @@ declare class TaskIterator implements Iterator {
|
|
|
748
824
|
next(): Task | undefined;
|
|
749
825
|
}
|
|
750
826
|
|
|
751
|
-
type
|
|
752
|
-
type SchemaConstraints = {
|
|
753
|
-
min?: number;
|
|
754
|
-
max?: number;
|
|
755
|
-
minLength?: number;
|
|
756
|
-
maxLength?: number;
|
|
757
|
-
pattern?: string;
|
|
758
|
-
enum?: any[];
|
|
759
|
-
multipleOf?: number;
|
|
760
|
-
format?: "email" | "url" | "date-time" | "uuid" | "custom";
|
|
761
|
-
oneOf?: any[];
|
|
762
|
-
};
|
|
763
|
-
type SchemaDefinition = {
|
|
764
|
-
type: SchemaType;
|
|
765
|
-
required?: string[];
|
|
766
|
-
properties?: {
|
|
767
|
-
[key: string]: SchemaDefinition;
|
|
768
|
-
};
|
|
769
|
-
items?: SchemaDefinition;
|
|
770
|
-
constraints?: SchemaConstraints;
|
|
771
|
-
description?: string;
|
|
772
|
-
strict?: boolean;
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
type TaskFunction = (context: AnyObject, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void) => TaskResult;
|
|
827
|
+
type TaskFunction = (context: AnyObject, emit: (signal: string, context: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void) => TaskResult;
|
|
776
828
|
type TaskResult = boolean | AnyObject | Generator | Promise<any> | void;
|
|
777
829
|
type ThrottleTagGetter = (context?: AnyObject, task?: Task) => string;
|
|
778
830
|
/**
|
|
@@ -817,7 +869,8 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
817
869
|
signalsToEmitAfter: Set<string>;
|
|
818
870
|
signalsToEmitOnFail: Set<string>;
|
|
819
871
|
observedSignals: Set<string>;
|
|
820
|
-
|
|
872
|
+
handlesIntents: Set<string>;
|
|
873
|
+
inquiresIntents: Set<string>;
|
|
821
874
|
readonly taskFunction: TaskFunction;
|
|
822
875
|
/**
|
|
823
876
|
* Constructs an instance of the task with the specified properties and configuration options.
|
|
@@ -913,11 +966,12 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
913
966
|
*
|
|
914
967
|
* @param {GraphContext} context The execution context which provides data and functions necessary for the task.
|
|
915
968
|
* @param {function(string, AnyObject): void} emit A function to emit signals and communicate intermediate results or states.
|
|
969
|
+
* @param {function(string, AnyObject, InquiryOptions): Promise<AnyObject>} inquire A function to inquire something from another task.
|
|
916
970
|
* @param {function(number): void} progressCallback A callback function used to report task progress as a percentage (0 to 100).
|
|
917
971
|
* @param {{ nodeId: string; routineExecId: string }} nodeData An object containing identifiers related to the node and execution routine.
|
|
918
972
|
* @return {TaskResult} The result of the executed task.
|
|
919
973
|
*/
|
|
920
|
-
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void, nodeData: {
|
|
974
|
+
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void, nodeData: {
|
|
921
975
|
nodeId: string;
|
|
922
976
|
routineExecId: string;
|
|
923
977
|
}): TaskResult;
|
|
@@ -1053,7 +1107,10 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
1053
1107
|
* @return {this} Returns the current instance to allow method chaining.
|
|
1054
1108
|
*/
|
|
1055
1109
|
detachAllSignals(): this;
|
|
1056
|
-
|
|
1110
|
+
respondsTo(...inquires: string[]): this;
|
|
1111
|
+
attachIntents(...intentNames: string[]): this;
|
|
1112
|
+
detachIntents(...intentNames: string[]): this;
|
|
1113
|
+
detachAllIntents(): this;
|
|
1057
1114
|
/**
|
|
1058
1115
|
* Maps over the signals in the `signalsToEmitAfter` set and applies a callback function to each signal.
|
|
1059
1116
|
*
|
|
@@ -1404,7 +1461,7 @@ interface EmitOptions {
|
|
|
1404
1461
|
squash?: boolean;
|
|
1405
1462
|
squashId?: string | null;
|
|
1406
1463
|
groupId?: string | null;
|
|
1407
|
-
mergeFunction?: ((oldContext: AnyObject, newContext: AnyObject) => AnyObject) | null;
|
|
1464
|
+
mergeFunction?: ((oldContext: AnyObject, ...newContext: AnyObject[]) => AnyObject) | null;
|
|
1408
1465
|
debounce?: boolean;
|
|
1409
1466
|
throttle?: boolean;
|
|
1410
1467
|
delayMs?: number;
|
|
@@ -1437,7 +1494,7 @@ declare class SignalBroker {
|
|
|
1437
1494
|
metaRunner: GraphRunner | undefined;
|
|
1438
1495
|
debouncedEmitters: Map<string, any>;
|
|
1439
1496
|
squashedEmitters: Map<string, any>;
|
|
1440
|
-
squashedContexts: Map<string, any>;
|
|
1497
|
+
squashedContexts: Map<string, any[]>;
|
|
1441
1498
|
throttleEmitters: Map<string, any>;
|
|
1442
1499
|
throttleQueues: Map<string, any>;
|
|
1443
1500
|
getSignalsTask: Task | undefined;
|
|
@@ -1621,6 +1678,7 @@ declare class DebounceTask extends Task {
|
|
|
1621
1678
|
lastTimeout: NodeJS.Timeout | null;
|
|
1622
1679
|
lastProgressCallback: ((progress: number) => void) | null;
|
|
1623
1680
|
lastEmitFunction: ((signal: string, context: any) => void) | null;
|
|
1681
|
+
lastInquireFunction: ((inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>) | null;
|
|
1624
1682
|
constructor(name: string, task: TaskFunction, description?: string, debounceTime?: number, leading?: boolean, trailing?: boolean, maxWait?: number, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, inputSchema?: SchemaDefinition | undefined, validateInputSchema?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputSchema?: boolean);
|
|
1625
1683
|
/**
|
|
1626
1684
|
* Executes the taskFunction with the provided context, emit function, and progress callback.
|
|
@@ -1641,19 +1699,21 @@ declare class DebounceTask extends Task {
|
|
|
1641
1699
|
* @param {GraphContext} context - The execution context for the operation.
|
|
1642
1700
|
* @param {NodeJS.Timeout} timeout - A timeout object for managing execution delays.
|
|
1643
1701
|
* @param {Function} emit - A callback function to emit signals with a specific context.
|
|
1702
|
+
* @param inquire
|
|
1644
1703
|
* @param {Function} progressCallback - A callback function to report progress during operation execution.
|
|
1645
1704
|
* @return {void} Does not return a value but sets internal timers and invokes provided callbacks.
|
|
1646
1705
|
*/
|
|
1647
|
-
debouncedTrigger(resolve: (value: unknown) => void, reject: (reason?: any) => void, context: GraphContext, timeout: NodeJS.Timeout, emit: (signal: string, context: any) => void, progressCallback: (progress: number) => void): void;
|
|
1706
|
+
debouncedTrigger(resolve: (value: unknown) => void, reject: (reason?: any) => void, context: GraphContext, timeout: NodeJS.Timeout, emit: (signal: string, context: any) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void): void;
|
|
1648
1707
|
/**
|
|
1649
1708
|
* Executes a task with a debounced trigger mechanism.
|
|
1650
1709
|
*
|
|
1651
1710
|
* @param {GraphContext} context - The context containing relevant graph data for the execution.
|
|
1652
1711
|
* @param {function(string, any): void} emit - A function used to emit signals with associated context.
|
|
1712
|
+
* @param inquire
|
|
1653
1713
|
* @param {function(number): void} progressCallback - A callback function to report the progress of the task as a number between 0 and 1.
|
|
1654
1714
|
* @return {Promise<TaskResult>} A promise that resolves with the task result upon completion or rejects on failure.
|
|
1655
1715
|
*/
|
|
1656
|
-
execute(context: GraphContext, emit: (signal: string, context: any) => void, progressCallback: (progress: number) => void): TaskResult;
|
|
1716
|
+
execute(context: GraphContext, emit: (signal: string, context: any) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void): TaskResult;
|
|
1657
1717
|
}
|
|
1658
1718
|
|
|
1659
1719
|
type EphemeralTaskOptions = {
|
|
@@ -1679,11 +1739,12 @@ declare class EphemeralTask extends Task {
|
|
|
1679
1739
|
*
|
|
1680
1740
|
* @param {any} context - The execution context, carrying necessary parameters or states for the operation.
|
|
1681
1741
|
* @param {function(string, AnyObject): void} emit - A function to emit signals with a string identifier and associated context.
|
|
1742
|
+
* @param inquire
|
|
1682
1743
|
* @param {function(number): void} progressCallback - A callback function to report the progress of the execution as a numerical value.
|
|
1683
1744
|
* @param {{ nodeId: string, routineExecId: string }} nodeData - An object containing details about the node ID and routine execution ID.
|
|
1684
1745
|
* @return {any} The result of the execution, returned from the base implementation or processed internally.
|
|
1685
1746
|
*/
|
|
1686
|
-
execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void, nodeData: {
|
|
1747
|
+
execute(context: any, emit: (signal: string, context: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void, nodeData: {
|
|
1687
1748
|
nodeId: string;
|
|
1688
1749
|
routineExecId: string;
|
|
1689
1750
|
}): TaskResult;
|
|
@@ -1749,7 +1810,8 @@ type CadenzaMode = "dev" | "debug" | "verbose" | "production";
|
|
|
1749
1810
|
* utility methods to create, register, and manage various task types.
|
|
1750
1811
|
*/
|
|
1751
1812
|
declare class Cadenza {
|
|
1752
|
-
static
|
|
1813
|
+
static signalBroker: SignalBroker;
|
|
1814
|
+
static inquiryBroker: InquiryBroker;
|
|
1753
1815
|
static runner: GraphRunner;
|
|
1754
1816
|
static metaRunner: GraphRunner;
|
|
1755
1817
|
static registry: GraphRegistry;
|
|
@@ -1834,6 +1896,8 @@ declare class Cadenza {
|
|
|
1834
1896
|
static debounce(signalName: string, context: any, delayMs: number): void;
|
|
1835
1897
|
static get(taskName: string): Task | undefined;
|
|
1836
1898
|
static getRoutine(routineName: string): GraphRoutine | undefined;
|
|
1899
|
+
static defineIntent(intent: Intent): Intent;
|
|
1900
|
+
static inquire(inquiry: string, context: AnyObject, options?: InquiryOptions): Promise<any>;
|
|
1837
1901
|
/**
|
|
1838
1902
|
* Creates and registers a new task with the specified parameters and options.
|
|
1839
1903
|
* Tasks are the basic building blocks of Cadenza graphs and are responsible for executing logic.
|
|
@@ -2185,8 +2249,4 @@ declare class Cadenza {
|
|
|
2185
2249
|
static reset(): void;
|
|
2186
2250
|
}
|
|
2187
2251
|
|
|
2188
|
-
|
|
2189
|
-
constructor(signal: string, description?: string);
|
|
2190
|
-
}
|
|
2191
|
-
|
|
2192
|
-
export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
|
|
2252
|
+
export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -319,6 +319,81 @@ declare abstract class GraphLayer extends ExecutionChain implements Graph {
|
|
|
319
319
|
log(): void;
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
type SchemaType = "string" | "number" | "boolean" | "array" | "object" | "any";
|
|
323
|
+
type SchemaConstraints = {
|
|
324
|
+
min?: number;
|
|
325
|
+
max?: number;
|
|
326
|
+
minLength?: number;
|
|
327
|
+
maxLength?: number;
|
|
328
|
+
pattern?: string;
|
|
329
|
+
enum?: any[];
|
|
330
|
+
multipleOf?: number;
|
|
331
|
+
format?: "email" | "url" | "date-time" | "uuid" | "custom";
|
|
332
|
+
oneOf?: any[];
|
|
333
|
+
};
|
|
334
|
+
type SchemaDefinition = {
|
|
335
|
+
type: SchemaType;
|
|
336
|
+
required?: string[];
|
|
337
|
+
properties?: {
|
|
338
|
+
[key: string]: SchemaDefinition;
|
|
339
|
+
};
|
|
340
|
+
items?: SchemaDefinition;
|
|
341
|
+
constraints?: SchemaConstraints;
|
|
342
|
+
description?: string;
|
|
343
|
+
strict?: boolean;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
interface Intent {
|
|
347
|
+
name: string;
|
|
348
|
+
description?: string;
|
|
349
|
+
input?: SchemaDefinition;
|
|
350
|
+
output?: SchemaDefinition;
|
|
351
|
+
}
|
|
352
|
+
interface InquiryOptions {
|
|
353
|
+
timeout: number;
|
|
354
|
+
}
|
|
355
|
+
declare class InquiryBroker extends SignalEmitter {
|
|
356
|
+
static instance_: InquiryBroker;
|
|
357
|
+
static get instance(): InquiryBroker;
|
|
358
|
+
debug: boolean;
|
|
359
|
+
verbose: boolean;
|
|
360
|
+
setDebug(value: boolean): void;
|
|
361
|
+
setVerbose(value: boolean): void;
|
|
362
|
+
validateInquiryName(inquiryName: string): void;
|
|
363
|
+
runner: GraphRunner | undefined;
|
|
364
|
+
metaRunner: GraphRunner | undefined;
|
|
365
|
+
inquiryObservers: Map<string, {
|
|
366
|
+
fn: (runner: GraphRunner, tasks: Task[], context: AnyObject) => void;
|
|
367
|
+
tasks: Set<Task>;
|
|
368
|
+
registered: boolean;
|
|
369
|
+
}>;
|
|
370
|
+
intents: Map<string, Intent>;
|
|
371
|
+
/**
|
|
372
|
+
* Initializes with runners.
|
|
373
|
+
* @param runner Standard runner for user signals.
|
|
374
|
+
* @param metaRunner Meta runner for 'meta.' signals (suppresses further meta-emits).
|
|
375
|
+
*/
|
|
376
|
+
bootstrap(runner: GraphRunner, metaRunner: GraphRunner): void;
|
|
377
|
+
init(): void;
|
|
378
|
+
/**
|
|
379
|
+
* Observes an inquiry with a routine/task.
|
|
380
|
+
* @param inquiry The inquiry (e.g., 'domain.action', 'domain.*' for wildcards).
|
|
381
|
+
* @param task The observer.
|
|
382
|
+
* @edge Duplicates ignored; supports wildcards for broad listening.
|
|
383
|
+
*/
|
|
384
|
+
observe(inquiry: string, task: Task): void;
|
|
385
|
+
/**
|
|
386
|
+
* Unsubscribes a routine/task from an inquiry.
|
|
387
|
+
* @param inquiry The inquiry.
|
|
388
|
+
* @param task The observer.
|
|
389
|
+
* @edge Removes all instances if duplicate; deletes if empty.
|
|
390
|
+
*/
|
|
391
|
+
unsubscribe(inquiry: string, task: Task): void;
|
|
392
|
+
addInquiry(inquiry: string): void;
|
|
393
|
+
addIntent(intent: Intent): void;
|
|
394
|
+
inquire(inquiry: string, context: AnyObject, options?: InquiryOptions): Promise<AnyObject>;
|
|
395
|
+
}
|
|
396
|
+
|
|
322
397
|
/**
|
|
323
398
|
* Represents a node in a graph structure used for executing tasks.
|
|
324
399
|
* A Node is a container for a task and its associated context, providing
|
|
@@ -474,6 +549,7 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
474
549
|
* failure and error propagation.
|
|
475
550
|
*/
|
|
476
551
|
work(): TaskResult | Promise<TaskResult>;
|
|
552
|
+
inquire(inquiry: string, context: AnyObject, options: InquiryOptions): Promise<any>;
|
|
477
553
|
/**
|
|
478
554
|
* Emits a signal along with its associated metadata. The metadata includes
|
|
479
555
|
* task-specific information such as task name, version, execution ID, and
|
|
@@ -748,31 +824,7 @@ declare class TaskIterator implements Iterator {
|
|
|
748
824
|
next(): Task | undefined;
|
|
749
825
|
}
|
|
750
826
|
|
|
751
|
-
type
|
|
752
|
-
type SchemaConstraints = {
|
|
753
|
-
min?: number;
|
|
754
|
-
max?: number;
|
|
755
|
-
minLength?: number;
|
|
756
|
-
maxLength?: number;
|
|
757
|
-
pattern?: string;
|
|
758
|
-
enum?: any[];
|
|
759
|
-
multipleOf?: number;
|
|
760
|
-
format?: "email" | "url" | "date-time" | "uuid" | "custom";
|
|
761
|
-
oneOf?: any[];
|
|
762
|
-
};
|
|
763
|
-
type SchemaDefinition = {
|
|
764
|
-
type: SchemaType;
|
|
765
|
-
required?: string[];
|
|
766
|
-
properties?: {
|
|
767
|
-
[key: string]: SchemaDefinition;
|
|
768
|
-
};
|
|
769
|
-
items?: SchemaDefinition;
|
|
770
|
-
constraints?: SchemaConstraints;
|
|
771
|
-
description?: string;
|
|
772
|
-
strict?: boolean;
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
type TaskFunction = (context: AnyObject, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void) => TaskResult;
|
|
827
|
+
type TaskFunction = (context: AnyObject, emit: (signal: string, context: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void) => TaskResult;
|
|
776
828
|
type TaskResult = boolean | AnyObject | Generator | Promise<any> | void;
|
|
777
829
|
type ThrottleTagGetter = (context?: AnyObject, task?: Task) => string;
|
|
778
830
|
/**
|
|
@@ -817,7 +869,8 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
817
869
|
signalsToEmitAfter: Set<string>;
|
|
818
870
|
signalsToEmitOnFail: Set<string>;
|
|
819
871
|
observedSignals: Set<string>;
|
|
820
|
-
|
|
872
|
+
handlesIntents: Set<string>;
|
|
873
|
+
inquiresIntents: Set<string>;
|
|
821
874
|
readonly taskFunction: TaskFunction;
|
|
822
875
|
/**
|
|
823
876
|
* Constructs an instance of the task with the specified properties and configuration options.
|
|
@@ -913,11 +966,12 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
913
966
|
*
|
|
914
967
|
* @param {GraphContext} context The execution context which provides data and functions necessary for the task.
|
|
915
968
|
* @param {function(string, AnyObject): void} emit A function to emit signals and communicate intermediate results or states.
|
|
969
|
+
* @param {function(string, AnyObject, InquiryOptions): Promise<AnyObject>} inquire A function to inquire something from another task.
|
|
916
970
|
* @param {function(number): void} progressCallback A callback function used to report task progress as a percentage (0 to 100).
|
|
917
971
|
* @param {{ nodeId: string; routineExecId: string }} nodeData An object containing identifiers related to the node and execution routine.
|
|
918
972
|
* @return {TaskResult} The result of the executed task.
|
|
919
973
|
*/
|
|
920
|
-
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void, nodeData: {
|
|
974
|
+
execute(context: GraphContext, emit: (signal: string, context: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void, nodeData: {
|
|
921
975
|
nodeId: string;
|
|
922
976
|
routineExecId: string;
|
|
923
977
|
}): TaskResult;
|
|
@@ -1053,7 +1107,10 @@ declare class Task extends SignalEmitter implements Graph {
|
|
|
1053
1107
|
* @return {this} Returns the current instance to allow method chaining.
|
|
1054
1108
|
*/
|
|
1055
1109
|
detachAllSignals(): this;
|
|
1056
|
-
|
|
1110
|
+
respondsTo(...inquires: string[]): this;
|
|
1111
|
+
attachIntents(...intentNames: string[]): this;
|
|
1112
|
+
detachIntents(...intentNames: string[]): this;
|
|
1113
|
+
detachAllIntents(): this;
|
|
1057
1114
|
/**
|
|
1058
1115
|
* Maps over the signals in the `signalsToEmitAfter` set and applies a callback function to each signal.
|
|
1059
1116
|
*
|
|
@@ -1404,7 +1461,7 @@ interface EmitOptions {
|
|
|
1404
1461
|
squash?: boolean;
|
|
1405
1462
|
squashId?: string | null;
|
|
1406
1463
|
groupId?: string | null;
|
|
1407
|
-
mergeFunction?: ((oldContext: AnyObject, newContext: AnyObject) => AnyObject) | null;
|
|
1464
|
+
mergeFunction?: ((oldContext: AnyObject, ...newContext: AnyObject[]) => AnyObject) | null;
|
|
1408
1465
|
debounce?: boolean;
|
|
1409
1466
|
throttle?: boolean;
|
|
1410
1467
|
delayMs?: number;
|
|
@@ -1437,7 +1494,7 @@ declare class SignalBroker {
|
|
|
1437
1494
|
metaRunner: GraphRunner | undefined;
|
|
1438
1495
|
debouncedEmitters: Map<string, any>;
|
|
1439
1496
|
squashedEmitters: Map<string, any>;
|
|
1440
|
-
squashedContexts: Map<string, any>;
|
|
1497
|
+
squashedContexts: Map<string, any[]>;
|
|
1441
1498
|
throttleEmitters: Map<string, any>;
|
|
1442
1499
|
throttleQueues: Map<string, any>;
|
|
1443
1500
|
getSignalsTask: Task | undefined;
|
|
@@ -1621,6 +1678,7 @@ declare class DebounceTask extends Task {
|
|
|
1621
1678
|
lastTimeout: NodeJS.Timeout | null;
|
|
1622
1679
|
lastProgressCallback: ((progress: number) => void) | null;
|
|
1623
1680
|
lastEmitFunction: ((signal: string, context: any) => void) | null;
|
|
1681
|
+
lastInquireFunction: ((inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>) | null;
|
|
1624
1682
|
constructor(name: string, task: TaskFunction, description?: string, debounceTime?: number, leading?: boolean, trailing?: boolean, maxWait?: number, concurrency?: number, timeout?: number, register?: boolean, isUnique?: boolean, isMeta?: boolean, isSubMeta?: boolean, isHidden?: boolean, inputSchema?: SchemaDefinition | undefined, validateInputSchema?: boolean, outputSchema?: SchemaDefinition | undefined, validateOutputSchema?: boolean);
|
|
1625
1683
|
/**
|
|
1626
1684
|
* Executes the taskFunction with the provided context, emit function, and progress callback.
|
|
@@ -1641,19 +1699,21 @@ declare class DebounceTask extends Task {
|
|
|
1641
1699
|
* @param {GraphContext} context - The execution context for the operation.
|
|
1642
1700
|
* @param {NodeJS.Timeout} timeout - A timeout object for managing execution delays.
|
|
1643
1701
|
* @param {Function} emit - A callback function to emit signals with a specific context.
|
|
1702
|
+
* @param inquire
|
|
1644
1703
|
* @param {Function} progressCallback - A callback function to report progress during operation execution.
|
|
1645
1704
|
* @return {void} Does not return a value but sets internal timers and invokes provided callbacks.
|
|
1646
1705
|
*/
|
|
1647
|
-
debouncedTrigger(resolve: (value: unknown) => void, reject: (reason?: any) => void, context: GraphContext, timeout: NodeJS.Timeout, emit: (signal: string, context: any) => void, progressCallback: (progress: number) => void): void;
|
|
1706
|
+
debouncedTrigger(resolve: (value: unknown) => void, reject: (reason?: any) => void, context: GraphContext, timeout: NodeJS.Timeout, emit: (signal: string, context: any) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void): void;
|
|
1648
1707
|
/**
|
|
1649
1708
|
* Executes a task with a debounced trigger mechanism.
|
|
1650
1709
|
*
|
|
1651
1710
|
* @param {GraphContext} context - The context containing relevant graph data for the execution.
|
|
1652
1711
|
* @param {function(string, any): void} emit - A function used to emit signals with associated context.
|
|
1712
|
+
* @param inquire
|
|
1653
1713
|
* @param {function(number): void} progressCallback - A callback function to report the progress of the task as a number between 0 and 1.
|
|
1654
1714
|
* @return {Promise<TaskResult>} A promise that resolves with the task result upon completion or rejects on failure.
|
|
1655
1715
|
*/
|
|
1656
|
-
execute(context: GraphContext, emit: (signal: string, context: any) => void, progressCallback: (progress: number) => void): TaskResult;
|
|
1716
|
+
execute(context: GraphContext, emit: (signal: string, context: any) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void): TaskResult;
|
|
1657
1717
|
}
|
|
1658
1718
|
|
|
1659
1719
|
type EphemeralTaskOptions = {
|
|
@@ -1679,11 +1739,12 @@ declare class EphemeralTask extends Task {
|
|
|
1679
1739
|
*
|
|
1680
1740
|
* @param {any} context - The execution context, carrying necessary parameters or states for the operation.
|
|
1681
1741
|
* @param {function(string, AnyObject): void} emit - A function to emit signals with a string identifier and associated context.
|
|
1742
|
+
* @param inquire
|
|
1682
1743
|
* @param {function(number): void} progressCallback - A callback function to report the progress of the execution as a numerical value.
|
|
1683
1744
|
* @param {{ nodeId: string, routineExecId: string }} nodeData - An object containing details about the node ID and routine execution ID.
|
|
1684
1745
|
* @return {any} The result of the execution, returned from the base implementation or processed internally.
|
|
1685
1746
|
*/
|
|
1686
|
-
execute(context: any, emit: (signal: string, context: AnyObject) => void, progressCallback: (progress: number) => void, nodeData: {
|
|
1747
|
+
execute(context: any, emit: (signal: string, context: AnyObject) => void, inquire: (inquiry: string, context: AnyObject, options: InquiryOptions) => Promise<AnyObject>, progressCallback: (progress: number) => void, nodeData: {
|
|
1687
1748
|
nodeId: string;
|
|
1688
1749
|
routineExecId: string;
|
|
1689
1750
|
}): TaskResult;
|
|
@@ -1749,7 +1810,8 @@ type CadenzaMode = "dev" | "debug" | "verbose" | "production";
|
|
|
1749
1810
|
* utility methods to create, register, and manage various task types.
|
|
1750
1811
|
*/
|
|
1751
1812
|
declare class Cadenza {
|
|
1752
|
-
static
|
|
1813
|
+
static signalBroker: SignalBroker;
|
|
1814
|
+
static inquiryBroker: InquiryBroker;
|
|
1753
1815
|
static runner: GraphRunner;
|
|
1754
1816
|
static metaRunner: GraphRunner;
|
|
1755
1817
|
static registry: GraphRegistry;
|
|
@@ -1834,6 +1896,8 @@ declare class Cadenza {
|
|
|
1834
1896
|
static debounce(signalName: string, context: any, delayMs: number): void;
|
|
1835
1897
|
static get(taskName: string): Task | undefined;
|
|
1836
1898
|
static getRoutine(routineName: string): GraphRoutine | undefined;
|
|
1899
|
+
static defineIntent(intent: Intent): Intent;
|
|
1900
|
+
static inquire(inquiry: string, context: AnyObject, options?: InquiryOptions): Promise<any>;
|
|
1837
1901
|
/**
|
|
1838
1902
|
* Creates and registers a new task with the specified parameters and options.
|
|
1839
1903
|
* Tasks are the basic building blocks of Cadenza graphs and are responsible for executing logic.
|
|
@@ -2185,8 +2249,4 @@ declare class Cadenza {
|
|
|
2185
2249
|
static reset(): void;
|
|
2186
2250
|
}
|
|
2187
2251
|
|
|
2188
|
-
|
|
2189
|
-
constructor(signal: string, description?: string);
|
|
2190
|
-
}
|
|
2191
|
-
|
|
2192
|
-
export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
|
|
2252
|
+
export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
|