@workglow/task-graph 0.0.52
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/LICENSE +201 -0
- package/README.md +1280 -0
- package/dist/browser.d.ts +7 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +2842 -0
- package/dist/browser.js.map +33 -0
- package/dist/bun.d.ts +7 -0
- package/dist/bun.d.ts.map +1 -0
- package/dist/bun.js +2843 -0
- package/dist/bun.js.map +33 -0
- package/dist/common.d.ts +33 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/node.d.ts +7 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2842 -0
- package/dist/node.js.map +33 -0
- package/dist/storage/TaskGraphRepository.d.ts +92 -0
- package/dist/storage/TaskGraphRepository.d.ts.map +1 -0
- package/dist/storage/TaskGraphTabularRepository.d.ts +73 -0
- package/dist/storage/TaskGraphTabularRepository.d.ts.map +1 -0
- package/dist/storage/TaskOutputRepository.d.ts +93 -0
- package/dist/storage/TaskOutputRepository.d.ts.map +1 -0
- package/dist/storage/TaskOutputTabularRepository.d.ts +84 -0
- package/dist/storage/TaskOutputTabularRepository.d.ts.map +1 -0
- package/dist/task/ArrayTask.d.ts +72 -0
- package/dist/task/ArrayTask.d.ts.map +1 -0
- package/dist/task/ConditionalTask.d.ts +278 -0
- package/dist/task/ConditionalTask.d.ts.map +1 -0
- package/dist/task/GraphAsTask.d.ts +79 -0
- package/dist/task/GraphAsTask.d.ts.map +1 -0
- package/dist/task/GraphAsTaskRunner.d.ts +36 -0
- package/dist/task/GraphAsTaskRunner.d.ts.map +1 -0
- package/dist/task/ITask.d.ts +144 -0
- package/dist/task/ITask.d.ts.map +1 -0
- package/dist/task/ITaskRunner.d.ts +36 -0
- package/dist/task/ITaskRunner.d.ts.map +1 -0
- package/dist/task/JobQueueFactory.d.ts +23 -0
- package/dist/task/JobQueueFactory.d.ts.map +1 -0
- package/dist/task/JobQueueTask.d.ts +65 -0
- package/dist/task/JobQueueTask.d.ts.map +1 -0
- package/dist/task/Task.d.ts +334 -0
- package/dist/task/Task.d.ts.map +1 -0
- package/dist/task/TaskError.d.ts +66 -0
- package/dist/task/TaskError.d.ts.map +1 -0
- package/dist/task/TaskEvents.d.ts +40 -0
- package/dist/task/TaskEvents.d.ts.map +1 -0
- package/dist/task/TaskJSON.d.ts +82 -0
- package/dist/task/TaskJSON.d.ts.map +1 -0
- package/dist/task/TaskQueueRegistry.d.ts +69 -0
- package/dist/task/TaskQueueRegistry.d.ts.map +1 -0
- package/dist/task/TaskRegistry.d.ts +31 -0
- package/dist/task/TaskRegistry.d.ts.map +1 -0
- package/dist/task/TaskRunner.d.ts +99 -0
- package/dist/task/TaskRunner.d.ts.map +1 -0
- package/dist/task/TaskTypes.d.ts +68 -0
- package/dist/task/TaskTypes.d.ts.map +1 -0
- package/dist/task-graph/Conversions.d.ts +28 -0
- package/dist/task-graph/Conversions.d.ts.map +1 -0
- package/dist/task-graph/Dataflow.d.ts +73 -0
- package/dist/task-graph/Dataflow.d.ts.map +1 -0
- package/dist/task-graph/DataflowEvents.d.ts +34 -0
- package/dist/task-graph/DataflowEvents.d.ts.map +1 -0
- package/dist/task-graph/ITaskGraph.d.ts +38 -0
- package/dist/task-graph/ITaskGraph.d.ts.map +1 -0
- package/dist/task-graph/IWorkflow.d.ts +13 -0
- package/dist/task-graph/IWorkflow.d.ts.map +1 -0
- package/dist/task-graph/TaskGraph.d.ts +230 -0
- package/dist/task-graph/TaskGraph.d.ts.map +1 -0
- package/dist/task-graph/TaskGraphEvents.d.ts +54 -0
- package/dist/task-graph/TaskGraphEvents.d.ts.map +1 -0
- package/dist/task-graph/TaskGraphRunner.d.ts +202 -0
- package/dist/task-graph/TaskGraphRunner.d.ts.map +1 -0
- package/dist/task-graph/TaskGraphScheduler.d.ts +56 -0
- package/dist/task-graph/TaskGraphScheduler.d.ts.map +1 -0
- package/dist/task-graph/Workflow.d.ts +155 -0
- package/dist/task-graph/Workflow.d.ts.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +59 -0
- package/src/storage/README.md +61 -0
- package/src/task/ConditionalTask.README.md +268 -0
- package/src/task/README.md +251 -0
- package/src/task-graph/README.md +142 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Job, JobConstructorParam, JobQueue } from "@workglow/job-queue";
|
|
7
|
+
import { ArrayTask } from "./ArrayTask";
|
|
8
|
+
import { IExecuteContext } from "./ITask";
|
|
9
|
+
import { TaskEventListeners } from "./TaskEvents";
|
|
10
|
+
import { TaskConfig, TaskInput, TaskOutput } from "./TaskTypes";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration interface for JobQueueTask.
|
|
13
|
+
* Extends the base TaskConfig with job queue specific properties.
|
|
14
|
+
*/
|
|
15
|
+
export interface JobQueueTaskConfig extends TaskConfig {
|
|
16
|
+
/**
|
|
17
|
+
* Queue selection for the task
|
|
18
|
+
* - `true` (default): create/use the task's default queue
|
|
19
|
+
* - `false`: run directly without queueing (requires `canRunDirectly`)
|
|
20
|
+
* - `string`: use an explicitly registered queue name
|
|
21
|
+
*/
|
|
22
|
+
queue?: boolean | string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Extended event listeners for JobQueueTask.
|
|
26
|
+
* Adds progress event handling to base task event listeners.
|
|
27
|
+
*/
|
|
28
|
+
export type JobQueueTaskEventListeners = Omit<TaskEventListeners, "progress"> & {
|
|
29
|
+
progress: (progress: number, message?: string, details?: Record<string, any> | null) => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Abstract base class for tasks that operate within a job queue.
|
|
33
|
+
* Provides functionality for managing job execution, progress tracking, and queue integration.
|
|
34
|
+
*
|
|
35
|
+
* @template Input - Type of input data for the task
|
|
36
|
+
* @template Output - Type of output data produced by the task
|
|
37
|
+
* @template Config - Type of configuration object for the task
|
|
38
|
+
*/
|
|
39
|
+
export declare abstract class JobQueueTask<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends JobQueueTaskConfig = JobQueueTaskConfig> extends ArrayTask<Input, Output, Config> {
|
|
40
|
+
static readonly type: string;
|
|
41
|
+
static canRunDirectly: boolean;
|
|
42
|
+
/** Name of the queue currently processing the task */
|
|
43
|
+
currentQueueName?: string;
|
|
44
|
+
/** ID of the current job being processed */
|
|
45
|
+
currentJobId?: string | unknown;
|
|
46
|
+
/** ID of the current runner being used */
|
|
47
|
+
currentRunnerId?: string;
|
|
48
|
+
jobClass: new (config: JobConstructorParam<Input, Output>) => Job<Input, Output>;
|
|
49
|
+
constructor(input?: Input, config?: Config);
|
|
50
|
+
execute(input: Input, executeContext: IExecuteContext): Promise<Output | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Override this method to create the right job class for the queue for this task
|
|
53
|
+
* @returns Promise<Job> - The created job
|
|
54
|
+
*/
|
|
55
|
+
createJob(input: Input, queue?: JobQueue<any, any>): Promise<Job<any, any>>;
|
|
56
|
+
protected resolveQueue(input: Input): Promise<JobQueue<Input, Output> | undefined>;
|
|
57
|
+
protected getDefaultQueueName(_input: Input): Promise<string | undefined>;
|
|
58
|
+
protected createAndRegisterQueue(queueName: string, input: Input): Promise<JobQueue<Input, Output>>;
|
|
59
|
+
/**
|
|
60
|
+
* Aborts the task
|
|
61
|
+
* @returns A promise that resolves when the task is aborted
|
|
62
|
+
*/
|
|
63
|
+
abort(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=JobQueueTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobQueueTask.d.ts","sourceRoot":"","sources":["../../src/task/JobQueueTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,G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,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAE5E,KAAK,GAAE,KAAmB,EAAE,MAAM,GAAE,MAAqB;IAQ/D,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAyDzF;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;cASjE,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;cAmCxE,mBAAmB,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;cAI/D,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IA4BnC;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAU7B"}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventEmitter, SchemaNode, type DataPortSchema } from "@workglow/util";
|
|
7
|
+
import { TaskGraph } from "../task-graph/TaskGraph";
|
|
8
|
+
import type { IExecuteContext, IExecuteReactiveContext, ITask } from "./ITask";
|
|
9
|
+
import { TaskError } from "./TaskError";
|
|
10
|
+
import { type TaskEventListener, type TaskEventListeners, type TaskEventParameters, type TaskEvents } from "./TaskEvents";
|
|
11
|
+
import type { JsonTaskItem, TaskGraphItemJson } from "./TaskJSON";
|
|
12
|
+
import { TaskRunner } from "./TaskRunner";
|
|
13
|
+
import { TaskStatus, type Provenance, type TaskConfig, type TaskInput, type TaskOutput, type TaskTypeName } from "./TaskTypes";
|
|
14
|
+
/**
|
|
15
|
+
* Base class for all tasks that implements the ITask interface.
|
|
16
|
+
* This abstract class provides common functionality for both simple and compound tasks.
|
|
17
|
+
*
|
|
18
|
+
* The Task class is responsible for:
|
|
19
|
+
* 1. Defining what a task is (inputs, outputs, configuration)
|
|
20
|
+
* 2. Providing the execution logic (via execute and executeReactive)
|
|
21
|
+
* 3. Delegating the running logic to a TaskRunner
|
|
22
|
+
*/
|
|
23
|
+
export declare class Task<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends TaskConfig = TaskConfig> implements ITask<Input, Output, Config> {
|
|
24
|
+
/**
|
|
25
|
+
* The type identifier for this task class
|
|
26
|
+
*/
|
|
27
|
+
static type: TaskTypeName;
|
|
28
|
+
/**
|
|
29
|
+
* The category this task belongs to
|
|
30
|
+
*/
|
|
31
|
+
static category: string;
|
|
32
|
+
/**
|
|
33
|
+
* The title of this task
|
|
34
|
+
*/
|
|
35
|
+
static title: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether this task has side effects
|
|
38
|
+
*/
|
|
39
|
+
static cacheable: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether this task has dynamic input/output schemas that can change at runtime.
|
|
42
|
+
* Tasks with dynamic schemas should override instance methods for inputSchema() and/or outputSchema()
|
|
43
|
+
* and emit 'schemaChange' events when their schemas change.
|
|
44
|
+
*/
|
|
45
|
+
static hasDynamicSchemas: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Input schema for this task
|
|
48
|
+
*/
|
|
49
|
+
static inputSchema(): DataPortSchema;
|
|
50
|
+
/**
|
|
51
|
+
* Output schema for this task
|
|
52
|
+
*/
|
|
53
|
+
static outputSchema(): DataPortSchema;
|
|
54
|
+
/**
|
|
55
|
+
* The actual task execution logic for subclasses to override
|
|
56
|
+
*
|
|
57
|
+
* @param input The input to the task
|
|
58
|
+
* @param config The configuration for the task
|
|
59
|
+
* @throws TaskError if the task fails
|
|
60
|
+
* @returns The output of the task or undefined if no changes
|
|
61
|
+
*/
|
|
62
|
+
execute(input: Input, context: IExecuteContext): Promise<Output | undefined>;
|
|
63
|
+
/**
|
|
64
|
+
* Default implementation of executeReactive that does nothing.
|
|
65
|
+
* Subclasses should override this to provide actual reactive functionality.
|
|
66
|
+
*
|
|
67
|
+
* This is generally for UI updating, and should be lightweight.
|
|
68
|
+
* @param input The input to the task
|
|
69
|
+
* @param output The current output of the task
|
|
70
|
+
* @returns The updated output of the task or undefined if no changes
|
|
71
|
+
*/
|
|
72
|
+
executeReactive(input: Input, output: Output, context: IExecuteReactiveContext): Promise<Output | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Task runner for handling the task execution
|
|
75
|
+
*/
|
|
76
|
+
protected _runner: TaskRunner<Input, Output, Config> | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the task runner instance
|
|
79
|
+
* Creates a new one if it doesn't exist
|
|
80
|
+
*/
|
|
81
|
+
get runner(): TaskRunner<Input, Output, Config>;
|
|
82
|
+
/**
|
|
83
|
+
* Runs the task and returns the output
|
|
84
|
+
* Delegates to the task runner
|
|
85
|
+
*
|
|
86
|
+
* @param overrides Optional input overrides
|
|
87
|
+
* @throws TaskError if the task fails
|
|
88
|
+
* @returns The task output
|
|
89
|
+
*/
|
|
90
|
+
run(overrides?: Partial<Input>): Promise<Output>;
|
|
91
|
+
/**
|
|
92
|
+
* Runs the task in reactive mode
|
|
93
|
+
* Delegates to the task runner
|
|
94
|
+
*
|
|
95
|
+
* @param overrides Optional input overrides
|
|
96
|
+
* @returns The task output
|
|
97
|
+
*/
|
|
98
|
+
runReactive(overrides?: Partial<Input>): Promise<Output>;
|
|
99
|
+
/**
|
|
100
|
+
* Aborts task execution
|
|
101
|
+
* Delegates to the task runner
|
|
102
|
+
*/
|
|
103
|
+
abort(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Disables task execution
|
|
106
|
+
* Delegates to the task runner
|
|
107
|
+
*/
|
|
108
|
+
disable(): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Gets input schema for this task
|
|
111
|
+
*/
|
|
112
|
+
inputSchema(): DataPortSchema;
|
|
113
|
+
/**
|
|
114
|
+
* Gets output schema for this task
|
|
115
|
+
*/
|
|
116
|
+
outputSchema(): DataPortSchema;
|
|
117
|
+
get type(): TaskTypeName;
|
|
118
|
+
get category(): string;
|
|
119
|
+
get title(): string;
|
|
120
|
+
get cacheable(): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Default input values for this task.
|
|
123
|
+
* If no overrides at run time, then this would be equal to the input.
|
|
124
|
+
* resetInputData() will reset inputs to these defaults.
|
|
125
|
+
*/
|
|
126
|
+
defaults: Record<string, any>;
|
|
127
|
+
/**
|
|
128
|
+
* The input to the task at the time of the task run.
|
|
129
|
+
* This takes defaults from construction time and overrides from run time.
|
|
130
|
+
* It is the input that created the output.
|
|
131
|
+
*/
|
|
132
|
+
runInputData: Record<string, any>;
|
|
133
|
+
/**
|
|
134
|
+
* The output of the task at the time of the task run.
|
|
135
|
+
* This is the result of the task execution.
|
|
136
|
+
*/
|
|
137
|
+
runOutputData: Record<string, any>;
|
|
138
|
+
/**
|
|
139
|
+
* The configuration of the task
|
|
140
|
+
*/
|
|
141
|
+
config: Config;
|
|
142
|
+
/**
|
|
143
|
+
* Current status of the task
|
|
144
|
+
*/
|
|
145
|
+
status: TaskStatus;
|
|
146
|
+
/**
|
|
147
|
+
* Progress of the task (0-100)
|
|
148
|
+
*/
|
|
149
|
+
progress: number;
|
|
150
|
+
/**
|
|
151
|
+
* When the task was created
|
|
152
|
+
*/
|
|
153
|
+
createdAt: Date;
|
|
154
|
+
/**
|
|
155
|
+
* When the task started execution
|
|
156
|
+
*/
|
|
157
|
+
startedAt?: Date;
|
|
158
|
+
/**
|
|
159
|
+
* When the task completed execution
|
|
160
|
+
*/
|
|
161
|
+
completedAt?: Date;
|
|
162
|
+
/**
|
|
163
|
+
* Error that occurred during task execution, if any
|
|
164
|
+
*/
|
|
165
|
+
error?: TaskError;
|
|
166
|
+
/**
|
|
167
|
+
* Event emitter for task lifecycle events
|
|
168
|
+
*/
|
|
169
|
+
get events(): EventEmitter<TaskEventListeners>;
|
|
170
|
+
protected _events: EventEmitter<TaskEventListeners> | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Provenance information for the task
|
|
173
|
+
*/
|
|
174
|
+
protected nodeProvenance: Provenance;
|
|
175
|
+
/**
|
|
176
|
+
* Creates a new task instance
|
|
177
|
+
*
|
|
178
|
+
* @param callerDefaultInputs Default input values provided by the caller
|
|
179
|
+
* @param config Configuration for the task
|
|
180
|
+
*/
|
|
181
|
+
constructor(callerDefaultInputs?: Partial<Input>, config?: Partial<Config>);
|
|
182
|
+
/**
|
|
183
|
+
* Gets default input values from input schema
|
|
184
|
+
*/
|
|
185
|
+
getDefaultInputsFromStaticInputDefinitions(): Partial<Input>;
|
|
186
|
+
/**
|
|
187
|
+
* Resets input data to defaults
|
|
188
|
+
*/
|
|
189
|
+
resetInputData(): void;
|
|
190
|
+
/**
|
|
191
|
+
* Sets the default input values for the task
|
|
192
|
+
*
|
|
193
|
+
* @param defaults The default input values to set
|
|
194
|
+
*/
|
|
195
|
+
setDefaults(defaults: Record<string, any>): void;
|
|
196
|
+
/**
|
|
197
|
+
* Sets input values for the task
|
|
198
|
+
*
|
|
199
|
+
* @param input Input values to set
|
|
200
|
+
*/
|
|
201
|
+
setInput(input: Record<string, any>): void;
|
|
202
|
+
/**
|
|
203
|
+
* Adds/merges input data during graph execution.
|
|
204
|
+
* Unlike {@link setInput}, this method:
|
|
205
|
+
* - Detects changes using deep equality
|
|
206
|
+
* - Accumulates array values (appends rather than replaces)
|
|
207
|
+
* - Handles DATAFLOW_ALL_PORTS for pass-through
|
|
208
|
+
* - Handles additionalProperties for dynamic schemas
|
|
209
|
+
*
|
|
210
|
+
* @param overrides The input data to merge
|
|
211
|
+
* @returns true if any input data was changed, false otherwise
|
|
212
|
+
*/
|
|
213
|
+
addInput(overrides: Partial<Input> | undefined): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Stub for narrowing input. Override in subclasses for custom logic.
|
|
216
|
+
* @param input The input to narrow
|
|
217
|
+
* @returns The (possibly narrowed) input
|
|
218
|
+
*/
|
|
219
|
+
narrowInput(input: Record<string, any>): Promise<Record<string, any>>;
|
|
220
|
+
/**
|
|
221
|
+
* Subscribes to an event
|
|
222
|
+
*/
|
|
223
|
+
subscribe<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): () => void;
|
|
224
|
+
/**
|
|
225
|
+
* Registers an event listener
|
|
226
|
+
*/
|
|
227
|
+
on<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void;
|
|
228
|
+
/**
|
|
229
|
+
* Removes an event listener
|
|
230
|
+
*/
|
|
231
|
+
off<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void;
|
|
232
|
+
/**
|
|
233
|
+
* Registers a one-time event listener
|
|
234
|
+
*/
|
|
235
|
+
once<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void;
|
|
236
|
+
/**
|
|
237
|
+
* Returns a promise that resolves when the specified event is emitted
|
|
238
|
+
*/
|
|
239
|
+
waitOn<Event extends TaskEvents>(name: Event): Promise<TaskEventParameters<Event>>;
|
|
240
|
+
/**
|
|
241
|
+
* Emits an event
|
|
242
|
+
*/
|
|
243
|
+
emit<Event extends TaskEvents>(name: Event, ...args: TaskEventParameters<Event>): void;
|
|
244
|
+
/**
|
|
245
|
+
* Emits a schemaChange event when the task's input or output schema changes.
|
|
246
|
+
* This should be called by tasks with dynamic schemas when their configuration
|
|
247
|
+
* changes in a way that affects their schemas.
|
|
248
|
+
*
|
|
249
|
+
* @param inputSchema - The new input schema (optional, will use current schema if not provided)
|
|
250
|
+
* @param outputSchema - The new output schema (optional, will use current schema if not provided)
|
|
251
|
+
*/
|
|
252
|
+
protected emitSchemaChange(inputSchema?: DataPortSchema, outputSchema?: DataPortSchema): void;
|
|
253
|
+
/**
|
|
254
|
+
* The compiled input schema
|
|
255
|
+
*/
|
|
256
|
+
private static _inputSchemaNode;
|
|
257
|
+
protected static generateInputSchemaNode(schema: DataPortSchema): SchemaNode;
|
|
258
|
+
/**
|
|
259
|
+
* Gets the compiled input schema
|
|
260
|
+
*/
|
|
261
|
+
protected static getInputSchemaNode(type: TaskTypeName): SchemaNode;
|
|
262
|
+
protected getInputSchemaNode(type: TaskTypeName): SchemaNode;
|
|
263
|
+
/**
|
|
264
|
+
* Validates an input data object against the task's input schema
|
|
265
|
+
*/
|
|
266
|
+
validateInput(input: Partial<Input>): Promise<boolean>;
|
|
267
|
+
/**
|
|
268
|
+
* Gets the task ID from the config
|
|
269
|
+
*/
|
|
270
|
+
id(): unknown;
|
|
271
|
+
/**
|
|
272
|
+
* Gets provenance information for the task
|
|
273
|
+
*/
|
|
274
|
+
getProvenance(): Provenance;
|
|
275
|
+
/**
|
|
276
|
+
* Strips symbol properties from an object to make it serializable
|
|
277
|
+
* @param obj The object to strip symbols from
|
|
278
|
+
* @returns A new object without symbol properties
|
|
279
|
+
*/
|
|
280
|
+
private stripSymbols;
|
|
281
|
+
/**
|
|
282
|
+
* Serializes the task and its subtasks into a format that can be stored
|
|
283
|
+
* @returns The serialized task and subtasks
|
|
284
|
+
*/
|
|
285
|
+
toJSON(): TaskGraphItemJson;
|
|
286
|
+
/**
|
|
287
|
+
* Converts the task to a JSON format suitable for dependency tracking
|
|
288
|
+
* @returns The task and subtasks in JSON thats easier for humans to read
|
|
289
|
+
*/
|
|
290
|
+
toDependencyJSON(): JsonTaskItem;
|
|
291
|
+
/**
|
|
292
|
+
* Checks if the task has children. Useful to gate to use of the internal subGraph
|
|
293
|
+
* as this will return without creating a new graph if graph is non-existent .
|
|
294
|
+
*
|
|
295
|
+
* @returns True if the task has children, otherwise false
|
|
296
|
+
*/
|
|
297
|
+
hasChildren(): boolean;
|
|
298
|
+
private _taskAddedListener;
|
|
299
|
+
/**
|
|
300
|
+
* The internal task graph containing subtasks
|
|
301
|
+
*
|
|
302
|
+
* In the base case, these may just be incidental tasks that are not part of the task graph
|
|
303
|
+
* but are used to manage the task's state as part of task execution. Therefore, the graph
|
|
304
|
+
* is not used by the default runner.
|
|
305
|
+
*/
|
|
306
|
+
protected _subGraph: TaskGraph | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* Sets the subtask graph for the compound task
|
|
309
|
+
* @param subGraph The subtask graph to set
|
|
310
|
+
*/
|
|
311
|
+
set subGraph(subGraph: TaskGraph);
|
|
312
|
+
/**
|
|
313
|
+
* The internal task graph containing subtasks
|
|
314
|
+
*
|
|
315
|
+
* In the base case, these may just be incidental tasks that are not part of the task graph
|
|
316
|
+
* but are used to manage the task's state as part of task execution. Therefore, the graph
|
|
317
|
+
* is not used by the default runner.
|
|
318
|
+
*
|
|
319
|
+
* Creates a new graph if one doesn't exist.
|
|
320
|
+
*
|
|
321
|
+
* @returns The task graph
|
|
322
|
+
*/
|
|
323
|
+
get subGraph(): TaskGraph;
|
|
324
|
+
/**
|
|
325
|
+
* Regenerates the task graph, which is internal state to execute() with config.own()
|
|
326
|
+
*
|
|
327
|
+
* This is a destructive operation that removes all dataflows and tasks from the graph.
|
|
328
|
+
* It is used to reset the graph to a clean state.
|
|
329
|
+
*
|
|
330
|
+
* GraphAsTask and others override this and do not call super
|
|
331
|
+
*/
|
|
332
|
+
regenerateGraph(): void;
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=Task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/task/Task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,YAAY,EACZ,UAAU,EAEV,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,K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kBAAkB,CAExB;IAEF;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAa;IAEvD;;;OAGG;IACH,IAAI,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAM/B;IAED;;;;;;;;;;OAUG;IACH,IAAI,QAAQ,IAAI,SAAS,CAMxB;IAED;;;;;;;OAOG;IACI,eAAe,IAAI,IAAI;CAW/B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { JobError } from "@workglow/job-queue";
|
|
7
|
+
import { BaseError } from "@workglow/util";
|
|
8
|
+
export declare class TaskError extends BaseError {
|
|
9
|
+
static readonly type: string;
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A task configuration error
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare class TaskConfigurationError extends TaskError {
|
|
17
|
+
static readonly type: string;
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A task workflow error
|
|
22
|
+
*/
|
|
23
|
+
export declare class WorkflowError extends TaskError {
|
|
24
|
+
static readonly type: string;
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A task error that is caused by a task being aborted
|
|
29
|
+
*
|
|
30
|
+
* Examples: task.abort() was called, or some other reason an abort signal was received
|
|
31
|
+
*/
|
|
32
|
+
export declare class TaskAbortedError extends TaskError {
|
|
33
|
+
static readonly type: string;
|
|
34
|
+
constructor(message?: string);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A task error that is caused by a task failing
|
|
38
|
+
*
|
|
39
|
+
* Examples: task.run() threw an error
|
|
40
|
+
*/
|
|
41
|
+
export declare class TaskFailedError extends TaskError {
|
|
42
|
+
static readonly type: string;
|
|
43
|
+
constructor(message?: string);
|
|
44
|
+
}
|
|
45
|
+
export declare class JobTaskFailedError extends TaskFailedError {
|
|
46
|
+
static readonly type: string;
|
|
47
|
+
jobError: JobError;
|
|
48
|
+
constructor(err: JobError);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A task error that is caused by an error converting JSON to a Task
|
|
52
|
+
*/
|
|
53
|
+
export declare class TaskJSONError extends TaskError {
|
|
54
|
+
static readonly type: string;
|
|
55
|
+
constructor(message?: string);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A task error that is caused by invalid input data
|
|
59
|
+
*
|
|
60
|
+
* Examples: task.run() received invalid input data
|
|
61
|
+
*/
|
|
62
|
+
export declare class TaskInvalidInputError extends TaskError {
|
|
63
|
+
static readonly type: string;
|
|
64
|
+
constructor(message?: string);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=TaskError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskError.d.ts","sourceRoot":"","sources":["../../src/task/TaskError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qBAAa,SAAU,SAAQ,SAAS;IACtC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAe;gBAC/B,OAAO,EAAE,MAAM;CAG5B;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACnD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAA4B;gBAC5C,OAAO,EAAE,MAAM;CAG5B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAmB;gBACnC,OAAO,EAAE,MAAM;CAG5B;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAsB;gBACtC,OAAO,GAAE,MAAuB;CAG7C;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAqB;gBACrC,OAAO,GAAE,MAAsB;CAG5C;AAED,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAwB;IAC7C,QAAQ,EAAE,QAAQ,CAAC;gBACd,GAAG,EAAE,QAAQ;CAI1B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAmB;gBACnC,OAAO,GAAE,MAA0C;CAGhE;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,SAAS;IAClD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAA2B;gBAC3C,OAAO,GAAE,MAA6B;CAGnD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventParameters, type DataPortSchema } from "@workglow/util";
|
|
7
|
+
import { TaskStatus } from "../common";
|
|
8
|
+
import { TaskAbortedError, TaskError } from "./TaskError";
|
|
9
|
+
/**
|
|
10
|
+
* Event listeners for task lifecycle events
|
|
11
|
+
*/
|
|
12
|
+
export type TaskEventListeners = {
|
|
13
|
+
/** Fired when a task starts execution */
|
|
14
|
+
start: () => void;
|
|
15
|
+
/** Fired when a task completes successfully */
|
|
16
|
+
complete: () => void;
|
|
17
|
+
/** Fired when a task is aborted */
|
|
18
|
+
abort: (error: TaskAbortedError) => void;
|
|
19
|
+
/** Fired when a task encounters an error */
|
|
20
|
+
error: (error: TaskError) => void;
|
|
21
|
+
/** Fired when a task is disabled */
|
|
22
|
+
disabled: () => void;
|
|
23
|
+
/** Fired when a task reports progress */
|
|
24
|
+
progress: (progress: number, message?: string, ...args: any[]) => void;
|
|
25
|
+
/** Fired when a regenerative task regenerates its graph */
|
|
26
|
+
regenerate: () => void;
|
|
27
|
+
/** Fired when a task is reset to original state */
|
|
28
|
+
reset: () => void;
|
|
29
|
+
/** Fired when a task status is updated */
|
|
30
|
+
status: (status: TaskStatus) => void;
|
|
31
|
+
/** Fired when a task's input or output schema changes (for tasks with dynamic schemas) */
|
|
32
|
+
schemaChange: (inputSchema?: DataPortSchema, outputSchema?: DataPortSchema) => void;
|
|
33
|
+
};
|
|
34
|
+
/** Union type of all possible task event names */
|
|
35
|
+
export type TaskEvents = keyof TaskEventListeners;
|
|
36
|
+
/** Type for task event listener functions */
|
|
37
|
+
export type TaskEventListener<Event extends TaskEvents> = TaskEventListeners[Event];
|
|
38
|
+
/** Type for task event parameters */
|
|
39
|
+
export type TaskEventParameters<Event extends TaskEvents> = EventParameters<TaskEventListeners, Event>;
|
|
40
|
+
//# sourceMappingURL=TaskEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskEvents.d.ts","sourceRoot":"","sources":["../../src/task/TaskEvents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK1D;;GAEG;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yCAAyC;IACzC,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,IAAI,CAAC;IAErB,mCAAmC;IACnC,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEzC,4CAA4C;IAC5C,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAElC,oCAAoC;IACpC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAErB,yCAAyC;IACzC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAEvE,2DAA2D;IAC3D,UAAU,EAAE,MAAM,IAAI,CAAC;IAEvB,mDAAmD;IACnD,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB,0CAA0C;IAC1C,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAErC,0FAA0F;IAC1F,YAAY,EAAE,CAAC,WAAW,CAAC,EAAE,cAAc,EAAE,YAAY,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;CACrF,CAAC;AACF,kDAAkD;AAElD,MAAM,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC;AAClD,6CAA6C;AAE7C,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,UAAU,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACpF,qCAAqC;AAErC,MAAM,MAAM,mBAAmB,CAAC,KAAK,SAAS,UAAU,IAAI,eAAe,CACzE,kBAAkB,EAClB,KAAK,CACN,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { TaskGraph } from "../task-graph/TaskGraph";
|
|
2
|
+
import { CompoundMergeStrategy } from "../task-graph/TaskGraphRunner";
|
|
3
|
+
import { DataPorts, Provenance, TaskInput } from "./TaskTypes";
|
|
4
|
+
/**
|
|
5
|
+
* Represents a single task item in the JSON configuration.
|
|
6
|
+
* This structure defines how tasks should be configured in JSON format.
|
|
7
|
+
*/
|
|
8
|
+
export type JsonTaskItem = {
|
|
9
|
+
/** Unique identifier for the task */
|
|
10
|
+
id: unknown;
|
|
11
|
+
/** Type of task to create */
|
|
12
|
+
type: string;
|
|
13
|
+
/** Optional display name for the task */
|
|
14
|
+
name?: string;
|
|
15
|
+
/** Input configuration for the task */
|
|
16
|
+
input?: TaskInput;
|
|
17
|
+
/** Defines data flow between tasks */
|
|
18
|
+
dependencies?: {
|
|
19
|
+
/** Input parameter name mapped to source task output */
|
|
20
|
+
[x: string]: {
|
|
21
|
+
/** ID of the source task */
|
|
22
|
+
id: unknown;
|
|
23
|
+
/** Output parameter name from source task */
|
|
24
|
+
output: string;
|
|
25
|
+
} | Array<{
|
|
26
|
+
id: unknown;
|
|
27
|
+
output: string;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
/** Optional user data to use for this task, not used by the task framework except it will be exported as part of the task JSON*/
|
|
31
|
+
extras?: DataPorts;
|
|
32
|
+
/** Optional metadata about task origin */
|
|
33
|
+
provenance?: Provenance;
|
|
34
|
+
/** Nested tasks for compound operations */
|
|
35
|
+
subtasks?: JsonTaskItem[];
|
|
36
|
+
}; /**
|
|
37
|
+
* Represents a task graph item, which can be a task or a subgraph
|
|
38
|
+
*/
|
|
39
|
+
export type TaskGraphItemJson = {
|
|
40
|
+
id: unknown;
|
|
41
|
+
type: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
input?: TaskInput;
|
|
44
|
+
provenance?: Provenance;
|
|
45
|
+
extras?: DataPorts;
|
|
46
|
+
subgraph?: TaskGraphJson;
|
|
47
|
+
merge?: CompoundMergeStrategy;
|
|
48
|
+
};
|
|
49
|
+
export type TaskGraphJson = {
|
|
50
|
+
tasks: TaskGraphItemJson[];
|
|
51
|
+
dataflows: DataflowJson[];
|
|
52
|
+
};
|
|
53
|
+
export type DataflowJson = {
|
|
54
|
+
sourceTaskId: unknown;
|
|
55
|
+
sourceTaskPortId: string;
|
|
56
|
+
targetTaskId: unknown;
|
|
57
|
+
targetTaskPortId: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Creates a task instance from a JSON task item configuration
|
|
61
|
+
* Validates required fields and resolves task type from registry
|
|
62
|
+
*/
|
|
63
|
+
export declare const createTaskFromDependencyJSON: (item: JsonTaskItem) => import("./ITask").ITask<any, any, any>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a task graph from an array of JSON task items
|
|
66
|
+
* Recursively processes subtasks for compound tasks
|
|
67
|
+
*/
|
|
68
|
+
export declare const createGraphFromDependencyJSON: (jsonItems: JsonTaskItem[]) => TaskGraph;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a task instance from a task graph item JSON representation
|
|
71
|
+
* @param item The JSON representation of the task
|
|
72
|
+
* @returns A new task instance
|
|
73
|
+
* @throws Error if required fields are missing or invalid
|
|
74
|
+
*/
|
|
75
|
+
export declare const createTaskFromGraphJSON: (item: TaskGraphItemJson) => import("./ITask").ITask<any, any, any>;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a TaskGraph instance from its JSON representation
|
|
78
|
+
* @param graphJsonObj The JSON representation of the task graph
|
|
79
|
+
* @returns A new TaskGraph instance with all tasks and data flows
|
|
80
|
+
*/
|
|
81
|
+
export declare const createGraphFromGraphJSON: (graphJsonObj: TaskGraphJson) => TaskGraph;
|
|
82
|
+
//# sourceMappingURL=TaskJSON.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskJSON.d.ts","sourceRoot":"","sources":["../../src/task/TaskJSON.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAItE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAc,SAAS,EAAE,MAAM,aAAa,CAAC;AAK3E;;;GAGG;AAEH,MAAM,MAAM,YAAY,GAAG;IACzB,qCAAqC;IACrC,EAAE,EAAE,OAAO,CAAC;IAEZ,6BAA6B;IAC7B,IAAI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