@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,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventParameters } from "@workglow/util";
|
|
7
|
+
import { TaskGraph } from "../task-graph/TaskGraph";
|
|
8
|
+
/**
|
|
9
|
+
* Service token for TaskGraphRepository
|
|
10
|
+
*/
|
|
11
|
+
export declare const TASK_GRAPH_REPOSITORY: import("@workglow/util").ServiceToken<TaskGraphRepository>;
|
|
12
|
+
/**
|
|
13
|
+
* Events that can be emitted by the TaskGraphRepository
|
|
14
|
+
*/
|
|
15
|
+
export type TaskGraphRepositoryEvents = keyof TaskGraphRepositoryEventListeners;
|
|
16
|
+
export type TaskGraphRepositoryEventListeners = {
|
|
17
|
+
graph_saved: (key: string) => void;
|
|
18
|
+
graph_retrieved: (key: string) => void;
|
|
19
|
+
graph_cleared: () => void;
|
|
20
|
+
};
|
|
21
|
+
export type TaskGraphRepositoryEventListener<Event extends TaskGraphRepositoryEvents> = TaskGraphRepositoryEventListeners[Event];
|
|
22
|
+
export type TaskGraphRepositoryEventParameters<Event extends TaskGraphRepositoryEvents> = EventParameters<TaskGraphRepositoryEventListeners, Event>;
|
|
23
|
+
/**
|
|
24
|
+
* Repository class for managing task graphs persistence and retrieval.
|
|
25
|
+
* Provides functionality to save, load, and manipulate task graphs with their associated tasks and data flows.
|
|
26
|
+
*/
|
|
27
|
+
export declare abstract class TaskGraphRepository {
|
|
28
|
+
/**
|
|
29
|
+
* The type of the repository
|
|
30
|
+
*/
|
|
31
|
+
type: string;
|
|
32
|
+
/**
|
|
33
|
+
* The event emitter for the task graphs
|
|
34
|
+
*/
|
|
35
|
+
private get events();
|
|
36
|
+
private _events;
|
|
37
|
+
/**
|
|
38
|
+
* Registers an event listener for the specified event
|
|
39
|
+
* @param name The event name to listen for
|
|
40
|
+
* @param fn The callback function to execute when the event occurs
|
|
41
|
+
*/
|
|
42
|
+
on<Event extends TaskGraphRepositoryEvents>(name: Event, fn: TaskGraphRepositoryEventListener<Event>): void;
|
|
43
|
+
/**
|
|
44
|
+
* Removes an event listener for the specified event
|
|
45
|
+
* @param name The event name to stop listening for
|
|
46
|
+
* @param fn The callback function to remove
|
|
47
|
+
*/
|
|
48
|
+
off<Event extends TaskGraphRepositoryEvents>(name: Event, fn: TaskGraphRepositoryEventListener<Event>): void;
|
|
49
|
+
/**
|
|
50
|
+
* Adds an event listener that will only be called once
|
|
51
|
+
* @param name The event name to listen for
|
|
52
|
+
* @param fn The callback function to execute when the event occurs
|
|
53
|
+
*/
|
|
54
|
+
once<Event extends TaskGraphRepositoryEvents>(name: Event, fn: TaskGraphRepositoryEventListener<Event>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Returns when the event was emitted (promise form of once)
|
|
57
|
+
* @param name The event name to check
|
|
58
|
+
* @returns true if the event has listeners, false otherwise
|
|
59
|
+
*/
|
|
60
|
+
waitOn<Event extends TaskGraphRepositoryEvents>(name: Event): Promise<TaskGraphRepositoryEventParameters<Event>>;
|
|
61
|
+
/**
|
|
62
|
+
* Emits an event (if there are listeners)
|
|
63
|
+
* @param name The event name to emit
|
|
64
|
+
* @param args The event parameters
|
|
65
|
+
*/
|
|
66
|
+
emit<Event extends TaskGraphRepositoryEvents>(name: Event, ...args: TaskGraphRepositoryEventParameters<Event>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Saves a task graph to persistent storage
|
|
69
|
+
* @param key The unique identifier for the task graph
|
|
70
|
+
* @param output The task graph to save
|
|
71
|
+
* @emits graph_saved when the operation completes
|
|
72
|
+
*/
|
|
73
|
+
abstract saveTaskGraph(key: string, output: TaskGraph): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves a task graph from persistent storage
|
|
76
|
+
* @param key The unique identifier of the task graph to retrieve
|
|
77
|
+
* @returns The retrieved task graph, or undefined if not found
|
|
78
|
+
* @emits graph_retrieved when the operation completes successfully
|
|
79
|
+
*/
|
|
80
|
+
abstract getTaskGraph(key: string): Promise<TaskGraph | undefined>;
|
|
81
|
+
/**
|
|
82
|
+
* Clears all task graphs from the repository
|
|
83
|
+
* @emits graph_cleared when the operation completes
|
|
84
|
+
*/
|
|
85
|
+
abstract clear(): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Returns the number of task graphs stored in the repository
|
|
88
|
+
* @returns The count of stored task graphs
|
|
89
|
+
*/
|
|
90
|
+
abstract size(): Promise<number>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=TaskGraphRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskGraphRepository.d.ts","sourceRoot":"","sources":["../../src/storage/TaskGraphRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoC,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,qBAAqB,4DAEjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,iCAAiC,CAAC;AAEhF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gCAAgC,CAAC,KAAK,SAAS,yBAAyB,IAClF,iCAAiC,CAAC,KAAK,CAAC,CAAC;AAE3C,MAAM,MAAM,kCAAk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0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { TabularRepository } from "@workglow/storage";
|
|
7
|
+
import { TaskGraph } from "../task-graph/TaskGraph";
|
|
8
|
+
import { TaskGraphRepository } from "./TaskGraphRepository";
|
|
9
|
+
export declare const TaskGraphSchema: {
|
|
10
|
+
type: "object";
|
|
11
|
+
properties: {
|
|
12
|
+
key: {
|
|
13
|
+
type: "string";
|
|
14
|
+
};
|
|
15
|
+
value: {
|
|
16
|
+
type: "string";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
additionalProperties: false;
|
|
20
|
+
};
|
|
21
|
+
export declare const TaskGraphPrimaryKeyNames: readonly ["key"];
|
|
22
|
+
/**
|
|
23
|
+
* Options for the TaskGraphRepository
|
|
24
|
+
*/
|
|
25
|
+
export type TaskGraphRepositoryStorage = TabularRepository<typeof TaskGraphSchema, typeof TaskGraphPrimaryKeyNames>;
|
|
26
|
+
type TaskGraphRepositoryOptions = {
|
|
27
|
+
tabularRepository: TaskGraphRepositoryStorage;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Repository class for managing task graphs persistence and retrieval.
|
|
31
|
+
* Provides functionality to save, load, and manipulate task graphs with their associated tasks and data flows.
|
|
32
|
+
*/
|
|
33
|
+
export declare class TaskGraphTabularRepository extends TaskGraphRepository {
|
|
34
|
+
/**
|
|
35
|
+
* The type of the repository
|
|
36
|
+
*/
|
|
37
|
+
type: string;
|
|
38
|
+
/**
|
|
39
|
+
* The tabular repository for the task graphs
|
|
40
|
+
*/
|
|
41
|
+
tabularRepository: TaskGraphRepositoryStorage;
|
|
42
|
+
/**
|
|
43
|
+
* Constructor for the TaskGraphRepository
|
|
44
|
+
* @param options The options for the repository
|
|
45
|
+
*/
|
|
46
|
+
constructor({ tabularRepository }: TaskGraphRepositoryOptions);
|
|
47
|
+
/**
|
|
48
|
+
* Saves a task graph to persistent storage
|
|
49
|
+
* @param key The unique identifier for the task graph
|
|
50
|
+
* @param output The task graph to save
|
|
51
|
+
* @emits graph_saved when the operation completes
|
|
52
|
+
*/
|
|
53
|
+
saveTaskGraph(key: string, output: TaskGraph): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves a task graph from persistent storage
|
|
56
|
+
* @param key The unique identifier of the task graph to retrieve
|
|
57
|
+
* @returns The retrieved task graph, or undefined if not found
|
|
58
|
+
* @emits graph_retrieved when the operation completes successfully
|
|
59
|
+
*/
|
|
60
|
+
getTaskGraph(key: string): Promise<TaskGraph | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* Clears all task graphs from the repository
|
|
63
|
+
* @emits graph_cleared when the operation completes
|
|
64
|
+
*/
|
|
65
|
+
clear(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the number of task graphs stored in the repository
|
|
68
|
+
* @returns The count of stored task graphs
|
|
69
|
+
*/
|
|
70
|
+
size(): Promise<number>;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=TaskGraphTabularRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskGraphTabularRepository.d.ts","sourceRoot":"","sources":["../../src/storage/TaskGraphTabularRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,eAAe;;;;;;;;;;;CAOI,CAAC;AAEjC,eAAO,MAAM,wBAAwB,kBAAmB,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,iBAAiB,CACxD,OAAO,eAAe,EACtB,OAAO,wBAAwB,CAChC,CAAC;AACF,KAAK,0BAA0B,GAAG;IAChC,iBAAiB,EAAE,0BAA0B,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,mBAAmB;IACjE;;OAEG;IACI,IAAI,SAAgC;IAE3C;;OAEG;IACH,iBAAiB,EAAE,0BAA0B,CAAC;IAE9C;;;OAGG;gBACS,EAAE,iBAAiB,EAAE,EAAE,0BAA0B;IAK7D;;;;;OAKG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlE;;;;;OAKG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAa/D;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;CAG9B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventParameters } from "@workglow/util";
|
|
7
|
+
import { TaskInput, TaskOutput } from "../task/TaskTypes";
|
|
8
|
+
/**
|
|
9
|
+
* Service token for TaskOutputRepository
|
|
10
|
+
*/
|
|
11
|
+
export declare const TASK_OUTPUT_REPOSITORY: import("@workglow/util").ServiceToken<TaskOutputRepository>;
|
|
12
|
+
export type TaskOutputEventListeners = {
|
|
13
|
+
output_saved: (taskType: string) => void;
|
|
14
|
+
output_retrieved: (taskType: string) => void;
|
|
15
|
+
output_cleared: () => void;
|
|
16
|
+
output_pruned: () => void;
|
|
17
|
+
};
|
|
18
|
+
export type TaskOutputEvents = keyof TaskOutputEventListeners;
|
|
19
|
+
export type TaskOutputEventListener<Event extends TaskOutputEvents> = TaskOutputEventListeners[Event];
|
|
20
|
+
export type TaskOutputEventParameters<Event extends TaskOutputEvents> = EventParameters<TaskOutputEventListeners, Event>;
|
|
21
|
+
/**
|
|
22
|
+
* Abstract class for managing task outputs in a repository
|
|
23
|
+
* Provides methods for saving, retrieving, and clearing task outputs
|
|
24
|
+
*/
|
|
25
|
+
export declare abstract class TaskOutputRepository {
|
|
26
|
+
/**
|
|
27
|
+
* Whether to compress the output
|
|
28
|
+
*/
|
|
29
|
+
outputCompression: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Constructor for the TaskOutputRepository
|
|
32
|
+
* @param options The options for the repository
|
|
33
|
+
*/
|
|
34
|
+
constructor({ outputCompression }: {
|
|
35
|
+
outputCompression?: boolean | undefined;
|
|
36
|
+
});
|
|
37
|
+
private get events();
|
|
38
|
+
private _events;
|
|
39
|
+
/**
|
|
40
|
+
* Registers an event listener for a specific event
|
|
41
|
+
* @param name The event name to listen for
|
|
42
|
+
* @param fn The callback function to execute when the event occurs
|
|
43
|
+
*/
|
|
44
|
+
on<Event extends TaskOutputEvents>(name: Event, fn: TaskOutputEventListener<Event>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Removes an event listener for a specific event
|
|
47
|
+
* @param name The event name to stop listening for
|
|
48
|
+
* @param fn The callback function to remove
|
|
49
|
+
*/
|
|
50
|
+
off<Event extends TaskOutputEvents>(name: Event, fn: TaskOutputEventListener<Event>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a promise that resolves when the event is emitted
|
|
53
|
+
* @param name The event name to listen for
|
|
54
|
+
* @returns a promise that resolves to the event parameters
|
|
55
|
+
*/
|
|
56
|
+
waitOn<Event extends TaskOutputEvents>(name: Event): Promise<TaskOutputEventParameters<Event>>;
|
|
57
|
+
/**
|
|
58
|
+
* Emits an event (if there are listeners)
|
|
59
|
+
* @param name The event name to emit
|
|
60
|
+
* @param args The event parameters
|
|
61
|
+
*/
|
|
62
|
+
emit<Event extends TaskOutputEvents>(name: Event, ...args: TaskOutputEventParameters<Event>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Saves a task output to the repository
|
|
65
|
+
* @param taskType The type of task to save the output for
|
|
66
|
+
* @param inputs The input parameters for the task
|
|
67
|
+
* @param output The task output to save
|
|
68
|
+
*/
|
|
69
|
+
abstract saveOutput(taskType: string, inputs: TaskInput, output: TaskOutput, createdAt?: Date): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves a task output from the repository
|
|
72
|
+
* @param taskType The type of task to retrieve the output for
|
|
73
|
+
* @param inputs The input parameters for the task
|
|
74
|
+
* @returns The retrieved task output, or undefined if not found
|
|
75
|
+
*/
|
|
76
|
+
abstract getOutput(taskType: string, inputs: TaskInput): Promise<TaskOutput | undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* Clears all task outputs from the repository
|
|
79
|
+
* @emits output_cleared when the operation completes
|
|
80
|
+
*/
|
|
81
|
+
abstract clear(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the number of task outputs stored in the repository
|
|
84
|
+
* @returns The count of stored task outputs
|
|
85
|
+
*/
|
|
86
|
+
abstract size(): Promise<number>;
|
|
87
|
+
/**
|
|
88
|
+
* Clear all task outputs from the repository that are older than the given date
|
|
89
|
+
* @param olderThanInMs The time in milliseconds to clear task outputs older than
|
|
90
|
+
*/
|
|
91
|
+
abstract clearOlderThan(olderThanInMs: number): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=TaskOutputRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskOutputRepository.d.ts","sourceRoot":"","sources":["../../src/storage/TaskOutputRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoC,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,sBAAsB,6DAElC,CAA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ACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,UAAU,EAClB,SAAS,CAAC,EAAE,IAAI,GACf,OAAO,CAAC,IAAI,CAAC;IAEhB;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAExF;;;OAGG;IACH,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type TabularRepository } from "@workglow/storage";
|
|
7
|
+
import { TaskInput, TaskOutput } from "../task/TaskTypes";
|
|
8
|
+
import { TaskOutputRepository } from "./TaskOutputRepository";
|
|
9
|
+
export type TaskOutputPrimaryKey = {
|
|
10
|
+
key: string;
|
|
11
|
+
taskType: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const TaskOutputSchema: {
|
|
14
|
+
type: "object";
|
|
15
|
+
properties: {
|
|
16
|
+
key: {
|
|
17
|
+
type: "string";
|
|
18
|
+
};
|
|
19
|
+
taskType: {
|
|
20
|
+
type: "string";
|
|
21
|
+
};
|
|
22
|
+
value: {
|
|
23
|
+
type: "string";
|
|
24
|
+
contentEncoding: string;
|
|
25
|
+
};
|
|
26
|
+
createdAt: {
|
|
27
|
+
type: "string";
|
|
28
|
+
format: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
additionalProperties: false;
|
|
32
|
+
};
|
|
33
|
+
export declare const TaskOutputPrimaryKeyNames: readonly ["key", "taskType"];
|
|
34
|
+
export type TaskOutputRepositoryStorage = TabularRepository<typeof TaskOutputSchema, typeof TaskOutputPrimaryKeyNames>;
|
|
35
|
+
export type TaskOutputRepositoryOptions = {
|
|
36
|
+
tabularRepository: TaskOutputRepositoryStorage;
|
|
37
|
+
outputCompression?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Abstract class for managing task outputs in a repository
|
|
41
|
+
* Provides methods for saving, retrieving, and clearing task outputs
|
|
42
|
+
*/
|
|
43
|
+
export declare class TaskOutputTabularRepository extends TaskOutputRepository {
|
|
44
|
+
/**
|
|
45
|
+
* The tabular repository for the task outputs
|
|
46
|
+
*/
|
|
47
|
+
tabularRepository: TaskOutputRepositoryStorage;
|
|
48
|
+
/**
|
|
49
|
+
* Constructor for the TaskOutputTabularRepository
|
|
50
|
+
* @param options The options for the repository
|
|
51
|
+
*/
|
|
52
|
+
constructor({ tabularRepository, outputCompression }: TaskOutputRepositoryOptions);
|
|
53
|
+
keyFromInputs(inputs: TaskInput): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Saves a task output to the repository
|
|
56
|
+
* @param taskType The type of task to save the output for
|
|
57
|
+
* @param inputs The input parameters for the task
|
|
58
|
+
* @param output The task output to save
|
|
59
|
+
*/
|
|
60
|
+
saveOutput(taskType: string, inputs: TaskInput, output: TaskOutput, createdAt?: Date): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves a task output from the repository
|
|
63
|
+
* @param taskType The type of task to retrieve the output for
|
|
64
|
+
* @param inputs The input parameters for the task
|
|
65
|
+
* @returns The retrieved task output, or undefined if not found
|
|
66
|
+
*/
|
|
67
|
+
getOutput(taskType: string, inputs: TaskInput): Promise<TaskOutput | undefined>;
|
|
68
|
+
/**
|
|
69
|
+
* Clears all task outputs from the repository
|
|
70
|
+
* @emits output_cleared when the operation completes
|
|
71
|
+
*/
|
|
72
|
+
clear(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns the number of task outputs stored in the repository
|
|
75
|
+
* @returns The count of stored task outputs
|
|
76
|
+
*/
|
|
77
|
+
size(): Promise<number>;
|
|
78
|
+
/**
|
|
79
|
+
* Clear all task outputs from the repository that are older than the given date
|
|
80
|
+
* @param olderThanInMs The time in milliseconds to clear task outputs older than
|
|
81
|
+
*/
|
|
82
|
+
clearOlderThan(olderThanInMs: number): Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=TaskOutputTabularRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskOutputTabularRepository.d.ts","sourceRoot":"","sources":["../../src/storage/TaskOutputTabularRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;CASG,CAAC;AAEjC,eAAO,MAAM,yBAAyB,8BAA+B,CAAC;AAEtE,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CACzD,OAAO,gBAAgB,EACvB,OAAO,yBAAyB,CACjC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,iBAAiB,EAAE,2BAA2B,CAAC;IAC/C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,oBAAoB;IACnE;;OAEG;IACH,iBAAiB,EAAE,2BAA2B,CAAC;IAE/C;;;OAGG;gBACS,EAAE,iBAAiB,EAAE,iBAAwB,EAAE,EAAE,2BAA2B;IAM3E,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAI9D;;;;;OAKG;IACG,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,UAAU,EAClB,SAAS,OAAa,GACrB,OAAO,CAAC,IAAI,CAAC;IAyBhB;;;;;OAKG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAkCrF;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B;;;OAGG;IACG,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAK3D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type DataPortSchema } from "@workglow/util";
|
|
7
|
+
import { GraphResultArray } from "../task-graph/TaskGraphRunner";
|
|
8
|
+
import { GraphAsTask } from "./GraphAsTask";
|
|
9
|
+
import { GraphAsTaskRunner } from "./GraphAsTaskRunner";
|
|
10
|
+
import { JsonTaskItem, TaskGraphItemJson } from "./TaskJSON";
|
|
11
|
+
import { TaskConfig, TaskInput, TaskOutput } from "./TaskTypes";
|
|
12
|
+
/**
|
|
13
|
+
* ArrayTask is a compound task that either:
|
|
14
|
+
* 1. Executes directly if all inputs are non-arrays
|
|
15
|
+
* 2. Creates a subGraph with one task instance per array element if any input is an array
|
|
16
|
+
* 3. Creates all combinations if multiple inputs are arrays
|
|
17
|
+
*/
|
|
18
|
+
export declare class ArrayTask<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends TaskConfig = TaskConfig> extends GraphAsTask<Input, Output, Config> {
|
|
19
|
+
/**
|
|
20
|
+
* The type identifier for this task class
|
|
21
|
+
*/
|
|
22
|
+
static type: string;
|
|
23
|
+
/**
|
|
24
|
+
* Make this task have results that look like an array
|
|
25
|
+
*/
|
|
26
|
+
static readonly compoundMerge: "PROPERTY_ARRAY";
|
|
27
|
+
/**
|
|
28
|
+
* Gets input schema for this task from the static inputSchema property, which is user defined (reverts GraphAsTask's override)
|
|
29
|
+
*/
|
|
30
|
+
inputSchema(): DataPortSchema;
|
|
31
|
+
/**
|
|
32
|
+
* Gets output schema for this task from the static outputSchema property, which is user defined (reverts GraphAsTask's override)
|
|
33
|
+
*/
|
|
34
|
+
outputSchema(): DataPortSchema;
|
|
35
|
+
/**
|
|
36
|
+
* Regenerates the task subgraph based on input arrays
|
|
37
|
+
*/
|
|
38
|
+
regenerateGraph(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Generates all possible combinations of array inputs
|
|
41
|
+
* @param input Input object containing arrays
|
|
42
|
+
* @param inputMakeArray Keys of properties to generate combinations for
|
|
43
|
+
* @returns Array of input objects with all possible combinations
|
|
44
|
+
*/
|
|
45
|
+
protected generateCombinations(input: Input, inputMakeArray: Array<keyof Input>): Input[];
|
|
46
|
+
toJSON(): TaskGraphItemJson;
|
|
47
|
+
toDependencyJSON(): JsonTaskItem;
|
|
48
|
+
/**
|
|
49
|
+
* Create a custom runner for ArrayTask that overrides input passing behavior
|
|
50
|
+
* as inputs were already distributed to child tasks during graph regeneration
|
|
51
|
+
*/
|
|
52
|
+
_runner: ArrayTaskRunner<Input, Output, Config>;
|
|
53
|
+
/**
|
|
54
|
+
* Task runner for handling the task execution
|
|
55
|
+
*/
|
|
56
|
+
get runner(): ArrayTaskRunner<Input, Output, Config>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Custom runner for ArrayTask that passes empty input to child tasks.
|
|
60
|
+
* ArrayTask child tasks get their input values from their defaults (set during task creation),
|
|
61
|
+
* not from the parent task's input.
|
|
62
|
+
*/
|
|
63
|
+
declare class ArrayTaskRunner<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends TaskConfig = TaskConfig> extends GraphAsTaskRunner<Input, Output, Config> {
|
|
64
|
+
task: ArrayTask<Input, Output, Config>;
|
|
65
|
+
/**
|
|
66
|
+
* Override to pass empty input to subgraph.
|
|
67
|
+
* Child tasks will use their defaults instead of parent input.
|
|
68
|
+
*/
|
|
69
|
+
protected executeTaskChildren(_input: Input): Promise<GraphResultArray<Output>>;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=ArrayTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayTask.d.ts","sourceRoot":"","sources":["../../src/task/ArrayTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAS,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,gBAAgB,EAAkB,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;GAKG;AACH,qBAAa,SAAS,CACpB,KAAK,SAAS,SAAS,GAAG,SAAS,EACnC,MAAM,SAAS,UAAU,GAAG,UAAU,EACtC,MAAM,SAAS,UAAU,GAAG,UAAU,CACtC,SAAQ,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;IAC1C;;OAEG;IACH,OAAc,IAAI,SAAe;IAEjC;;OAEG;IACH,gBAAuB,aAAa,mBAA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