@webiny/tasks 5.39.2 → 5.39.3-beta.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/crud/EventBridgeEventTransport.d.ts +16 -0
- package/crud/EventBridgeEventTransport.js +57 -0
- package/crud/EventBridgeEventTransport.js.map +1 -0
- package/crud/crud.tasks.js +89 -52
- package/crud/crud.tasks.js.map +1 -1
- package/crud/model.js +1 -5
- package/crud/model.js.map +1 -1
- package/crud/trigger.tasks.js +26 -5
- package/crud/trigger.tasks.js.map +1 -1
- package/graphql/index.js +1 -1
- package/graphql/index.js.map +1 -1
- package/handler/index.d.ts +2 -2
- package/handler/index.js +17 -3
- package/handler/index.js.map +1 -1
- package/handler/types.d.ts +4 -0
- package/handler/types.js.map +1 -1
- package/package.json +19 -18
- package/response/DatabaseResponse.d.ts +2 -2
- package/response/DatabaseResponse.js +7 -1
- package/response/DatabaseResponse.js.map +1 -1
- package/response/Response.d.ts +3 -1
- package/response/Response.js +7 -1
- package/response/Response.js.map +1 -1
- package/response/ResponseAbortedResult.js +1 -1
- package/response/ResponseAbortedResult.js.map +1 -1
- package/response/ResponseContinueResult.d.ts +5 -1
- package/response/ResponseContinueResult.js +4 -0
- package/response/ResponseContinueResult.js.map +1 -1
- package/response/TaskResponse.d.ts +1 -1
- package/response/TaskResponse.js +6 -1
- package/response/TaskResponse.js.map +1 -1
- package/response/abstractions/Response.d.ts +1 -0
- package/response/abstractions/Response.js.map +1 -1
- package/response/abstractions/ResponseContinueResult.d.ts +1 -0
- package/response/abstractions/ResponseContinueResult.js.map +1 -1
- package/response/abstractions/TaskResponse.d.ts +7 -2
- package/response/abstractions/TaskResponse.js.map +1 -1
- package/runner/TaskManager.d.ts +2 -3
- package/runner/TaskManager.js +23 -20
- package/runner/TaskManager.js.map +1 -1
- package/runner/TaskManagerStore.d.ts +14 -10
- package/runner/TaskManagerStore.js +56 -19
- package/runner/TaskManagerStore.js.map +1 -1
- package/runner/TaskRunner.d.ts +7 -12
- package/runner/TaskRunner.js +22 -15
- package/runner/TaskRunner.js.map +1 -1
- package/runner/abstractions/TaskManagerStore.d.ts +52 -13
- package/runner/abstractions/TaskManagerStore.js.map +1 -1
- package/runner/abstractions/TaskRunner.d.ts +1 -7
- package/runner/abstractions/TaskRunner.js.map +1 -1
- package/task/plugin.js +1 -1
- package/task/plugin.js.map +1 -1
- package/timer/CustomTimer.d.ts +6 -0
- package/timer/CustomTimer.js +21 -0
- package/timer/CustomTimer.js.map +1 -0
- package/timer/Timer.d.ts +9 -0
- package/timer/Timer.js +17 -0
- package/timer/Timer.js.map +1 -0
- package/timer/abstractions/ITimer.d.ts +6 -0
- package/timer/abstractions/ITimer.js +7 -0
- package/timer/abstractions/ITimer.js.map +1 -0
- package/timer/factory.d.ts +4 -0
- package/timer/factory.js +20 -0
- package/timer/factory.js.map +1 -0
- package/timer/index.d.ts +4 -0
- package/timer/index.js +51 -0
- package/timer/index.js.map +1 -0
- package/types.d.ts +62 -35
- package/types.js +11 -5
- package/types.js.map +1 -1
- package/utils/ObjectUpdater.d.ts +8 -0
- package/utils/ObjectUpdater.js +46 -0
- package/utils/ObjectUpdater.js.map +1 -0
- package/crud/createEventBridgeEvent.d.ts +0 -9
- package/crud/createEventBridgeEvent.js +0 -73
- package/crud/createEventBridgeEvent.js.map +0 -1
- package/runner/utils/getErrorProperties.d.ts +0 -5
- package/runner/utils/getErrorProperties.js +0 -18
- package/runner/utils/getErrorProperties.js.map +0 -1
- package/runner/utils/getObjectProperties.d.ts +0 -4
- package/runner/utils/getObjectProperties.js +0 -21
- package/runner/utils/getObjectProperties.js.map +0 -1
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { IResponseError, ITask, ITaskDataInput, ITaskLogItemData, ITaskUpdateData, TaskDataStatus } from "../../types";
|
|
1
|
+
import { IResponseError, ITask, ITaskDataInput, ITaskLogItemData, ITaskResponseDoneResultOutput, ITaskUpdateData, TaskDataStatus } from "../../types";
|
|
2
2
|
export declare type ITaskManagerStoreUpdateTaskValues<T extends ITaskDataInput = ITaskDataInput> = T;
|
|
3
3
|
export interface ITaskManagerStoreUpdateTaskValuesCb<T extends ITaskDataInput = ITaskDataInput> {
|
|
4
|
-
(input: T):
|
|
4
|
+
(input: T): T;
|
|
5
|
+
}
|
|
6
|
+
export interface ITaskManagerStoreUpdateTaskInputOptions {
|
|
7
|
+
save: boolean;
|
|
5
8
|
}
|
|
6
9
|
export declare type ITaskManagerStoreUpdateTaskInputParam<T extends ITaskDataInput = ITaskDataInput> = ITaskManagerStoreUpdateTaskValuesCb<T> | Partial<ITaskManagerStoreUpdateTaskValues<T>>;
|
|
7
|
-
export interface ITaskManagerStoreUpdateTaskParamCb<T extends ITaskDataInput = ITaskDataInput> {
|
|
8
|
-
(task: ITask<T>): ITaskUpdateData<T>;
|
|
10
|
+
export interface ITaskManagerStoreUpdateTaskParamCb<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
11
|
+
(task: ITask<T, O>): ITaskUpdateData<T, O>;
|
|
9
12
|
}
|
|
10
|
-
export declare type ITaskManagerStoreUpdateTask<T extends ITaskDataInput = ITaskDataInput> = ITaskUpdateData<T>;
|
|
11
|
-
export declare type
|
|
13
|
+
export declare type ITaskManagerStoreUpdateTask<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITaskUpdateData<T, O>;
|
|
14
|
+
export declare type ITaskManagerStoreUpdateTaskParams<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITaskManagerStoreUpdateTaskParamCb<T, O> | Partial<ITaskManagerStoreUpdateTask<T, O>>;
|
|
12
15
|
export interface ITaskManagerStoreInfoLog {
|
|
13
16
|
message: string;
|
|
14
17
|
data?: ITaskLogItemData;
|
|
@@ -18,22 +21,52 @@ export interface ITaskManagerStoreErrorLog {
|
|
|
18
21
|
data?: ITaskLogItemData;
|
|
19
22
|
error: IResponseError | Error;
|
|
20
23
|
}
|
|
21
|
-
export interface
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
export interface ITaskManagerStoreSetOutputOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Default is true.
|
|
27
|
+
*/
|
|
28
|
+
save?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ITaskManagerStoreUpdateTaskOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Default is true.
|
|
33
|
+
*/
|
|
34
|
+
save?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ITaskManagerStoreAddLogOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Default is true.
|
|
39
|
+
*/
|
|
40
|
+
save?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Interface should not be used outside the @webiny/tasks package.
|
|
44
|
+
*/
|
|
45
|
+
export interface ITaskManagerStorePrivate<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
46
|
+
getTask: () => ITask<T, O>;
|
|
24
47
|
getStatus: () => TaskDataStatus;
|
|
25
48
|
/**
|
|
26
49
|
* @throws {Error} If task not found or something goes wrong during the database update.
|
|
27
50
|
*/
|
|
28
|
-
updateTask
|
|
51
|
+
updateTask(params: ITaskManagerStoreUpdateTaskParams<T, O>, options?: ITaskManagerStoreUpdateTaskOptions): Promise<void>;
|
|
29
52
|
/**
|
|
30
|
-
* Update task input, which are used to store custom user data.
|
|
31
|
-
* You can send partial input, and
|
|
53
|
+
* Update the task input, which are used to store custom user data.
|
|
54
|
+
* You can send partial input, and it will be merged with the existing input.
|
|
32
55
|
*
|
|
33
56
|
* @throws {Error} If task not found or something goes wrong during the database update.
|
|
34
57
|
*/
|
|
35
|
-
updateInput: (params: ITaskManagerStoreUpdateTaskInputParam<T
|
|
58
|
+
updateInput: (params: ITaskManagerStoreUpdateTaskInputParam<T>, options?: ITaskManagerStoreUpdateTaskInputOptions) => Promise<void>;
|
|
36
59
|
getInput: () => T;
|
|
60
|
+
/**
|
|
61
|
+
* Update the task output, which are used to store the output data.
|
|
62
|
+
* You can send partial output, and it will be merged with the existing output.
|
|
63
|
+
*
|
|
64
|
+
* Second parameter is optional options, and it contains a possibility not to store the task immediately.
|
|
65
|
+
*
|
|
66
|
+
* @throws {Error} If task not found or something goes wrong during the database update.
|
|
67
|
+
*/
|
|
68
|
+
updateOutput: (values: Partial<O>, options?: ITaskManagerStoreSetOutputOptions) => Promise<void>;
|
|
69
|
+
getOutput: () => O;
|
|
37
70
|
/**
|
|
38
71
|
* @throws {Error} If task not found or something goes wrong during the database update.
|
|
39
72
|
*/
|
|
@@ -44,4 +77,10 @@ export interface ITaskManagerStore<T extends ITaskDataInput = ITaskDataInput> {
|
|
|
44
77
|
*
|
|
45
78
|
*/
|
|
46
79
|
addErrorLog: (log: ITaskManagerStoreErrorLog) => Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Should store the task and logs into the database, if any.
|
|
82
|
+
* If nothing to update, it should skip calling the internal store methods.
|
|
83
|
+
*/
|
|
84
|
+
save(): Promise<void>;
|
|
47
85
|
}
|
|
86
|
+
export declare type ITaskManagerStore<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = Omit<ITaskManagerStorePrivate<T, O>, "save">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["TaskManagerStore.ts"],"sourcesContent":["import {\n IResponseError,\n ITask,\n ITaskDataInput,\n ITaskLogItemData,\n ITaskUpdateData,\n TaskDataStatus\n} from \"~/types\";\n\nexport type ITaskManagerStoreUpdateTaskValues<T extends ITaskDataInput = ITaskDataInput> = T;\n\nexport interface ITaskManagerStoreUpdateTaskValuesCb<T extends ITaskDataInput = ITaskDataInput> {\n (input: T):
|
|
1
|
+
{"version":3,"names":[],"sources":["TaskManagerStore.ts"],"sourcesContent":["import {\n IResponseError,\n ITask,\n ITaskDataInput,\n ITaskLogItemData,\n ITaskResponseDoneResultOutput,\n ITaskUpdateData,\n TaskDataStatus\n} from \"~/types\";\n\nexport type ITaskManagerStoreUpdateTaskValues<T extends ITaskDataInput = ITaskDataInput> = T;\n\nexport interface ITaskManagerStoreUpdateTaskValuesCb<T extends ITaskDataInput = ITaskDataInput> {\n (input: T): T;\n}\n\nexport interface ITaskManagerStoreUpdateTaskInputOptions {\n save: boolean;\n}\n\nexport type ITaskManagerStoreUpdateTaskInputParam<T extends ITaskDataInput = ITaskDataInput> =\n | ITaskManagerStoreUpdateTaskValuesCb<T>\n | Partial<ITaskManagerStoreUpdateTaskValues<T>>;\n\nexport interface ITaskManagerStoreUpdateTaskParamCb<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n (task: ITask<T, O>): ITaskUpdateData<T, O>;\n}\n\nexport type ITaskManagerStoreUpdateTask<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = ITaskUpdateData<T, O>;\n\nexport type ITaskManagerStoreUpdateTaskParams<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = ITaskManagerStoreUpdateTaskParamCb<T, O> | Partial<ITaskManagerStoreUpdateTask<T, O>>;\n\nexport interface ITaskManagerStoreInfoLog {\n message: string;\n data?: ITaskLogItemData;\n}\n\nexport interface ITaskManagerStoreErrorLog {\n message: string;\n data?: ITaskLogItemData;\n error: IResponseError | Error;\n}\n\nexport interface ITaskManagerStoreSetOutputOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\nexport interface ITaskManagerStoreUpdateTaskOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\nexport interface ITaskManagerStoreAddLogOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\n/**\n * Interface should not be used outside the @webiny/tasks package.\n */\nexport interface ITaskManagerStorePrivate<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n getTask: () => ITask<T, O>;\n getStatus: () => TaskDataStatus;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateTask(\n params: ITaskManagerStoreUpdateTaskParams<T, O>,\n options?: ITaskManagerStoreUpdateTaskOptions\n ): Promise<void>;\n /**\n * Update the task input, which are used to store custom user data.\n * You can send partial input, and it will be merged with the existing input.\n *\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateInput: (\n params: ITaskManagerStoreUpdateTaskInputParam<T>,\n options?: ITaskManagerStoreUpdateTaskInputOptions\n ) => Promise<void>;\n getInput: () => T;\n /**\n * Update the task output, which are used to store the output data.\n * You can send partial output, and it will be merged with the existing output.\n *\n * Second parameter is optional options, and it contains a possibility not to store the task immediately.\n *\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateOutput: (\n values: Partial<O>,\n options?: ITaskManagerStoreSetOutputOptions\n ) => Promise<void>;\n getOutput: () => O;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n addInfoLog: (log: ITaskManagerStoreInfoLog) => Promise<void>;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n *\n *\n */\n addErrorLog: (log: ITaskManagerStoreErrorLog) => Promise<void>;\n /**\n * Should store the task and logs into the database, if any.\n * If nothing to update, it should skip calling the internal store methods.\n */\n save(): Promise<void>;\n}\n\nexport type ITaskManagerStore<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = Omit<ITaskManagerStorePrivate<T, O>, \"save\">;\n"],"mappings":""}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { Context as LambdaContext } from "aws-lambda/handler";
|
|
2
1
|
import { Context } from "../../types";
|
|
3
|
-
import { Reply, Request } from "@webiny/handler/types";
|
|
4
2
|
import { ITaskEvent } from "../../handler/types";
|
|
5
3
|
import { IResponseResult } from "../../response/abstractions";
|
|
6
4
|
export interface ITaskRunner<C extends Context = Context> {
|
|
7
|
-
request: Request;
|
|
8
|
-
reply: Reply;
|
|
9
5
|
context: C;
|
|
10
|
-
|
|
11
|
-
isCloseToTimeout: (seconds?: number) => boolean;
|
|
12
|
-
getRemainingTime: () => number;
|
|
6
|
+
isCloseToTimeout(seconds?: number): boolean;
|
|
13
7
|
run(event: ITaskEvent): Promise<IResponseResult>;
|
|
14
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["TaskRunner.ts"],"sourcesContent":["import { Context
|
|
1
|
+
{"version":3,"names":[],"sources":["TaskRunner.ts"],"sourcesContent":["import { Context } from \"~/types\";\nimport { ITaskEvent } from \"~/handler/types\";\nimport { IResponseResult } from \"~/response/abstractions\";\n\nexport interface ITaskRunner<C extends Context = Context> {\n context: C;\n isCloseToTimeout(seconds?: number): boolean;\n run(event: ITaskEvent): Promise<IResponseResult>;\n}\n"],"mappings":""}
|
package/task/plugin.js
CHANGED
|
@@ -13,7 +13,7 @@ var _plugins = require("@webiny/plugins");
|
|
|
13
13
|
*
|
|
14
14
|
* This mechanism will prevent infinite loops in case of a bug in the task code.
|
|
15
15
|
*/
|
|
16
|
-
const DEFAULT_MAX_ITERATIONS =
|
|
16
|
+
const DEFAULT_MAX_ITERATIONS = 50;
|
|
17
17
|
class TaskDefinitionPlugin extends _plugins.Plugin {
|
|
18
18
|
static type = "webiny.backgroundTask";
|
|
19
19
|
get id() {
|
package/task/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_camelCase","_interopRequireDefault","require","_error","_plugins","DEFAULT_MAX_ITERATIONS","TaskDefinitionPlugin","Plugin","type","id","task","title","fields","run","onDone","onAbort","onError","onMaxIterations","maxIterations","constructor","isPrivate","config","validate","getTask","setFields","cb","Array","from","addField","field","concat","camelCase","message","console","log","WebinyError","exports","createTaskDefinition","params","createPrivateTaskDefinition","createTaskDefinitionField"],"sources":["plugin.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase\";\nimport WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport {\n Context,\n ITaskDefinition,\n ITaskDefinitionField,\n ITaskResponseDoneResultOutput\n} from \"~/types\";\n\n/**\n * By default, we will stop iterating through the task after DEFAULT_MAX_ITERATIONS.\n *\n * This mechanism will prevent infinite loops in case of a bug in the task code.\n */\nconst DEFAULT_MAX_ITERATIONS =
|
|
1
|
+
{"version":3,"names":["_camelCase","_interopRequireDefault","require","_error","_plugins","DEFAULT_MAX_ITERATIONS","TaskDefinitionPlugin","Plugin","type","id","task","title","fields","run","onDone","onAbort","onError","onMaxIterations","maxIterations","constructor","isPrivate","config","validate","getTask","setFields","cb","Array","from","addField","field","concat","camelCase","message","console","log","WebinyError","exports","createTaskDefinition","params","createPrivateTaskDefinition","createTaskDefinitionField"],"sources":["plugin.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase\";\nimport WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport {\n Context,\n ITaskDefinition,\n ITaskDefinitionField,\n ITaskResponseDoneResultOutput\n} from \"~/types\";\n\n/**\n * By default, we will stop iterating through the task after DEFAULT_MAX_ITERATIONS.\n *\n * This mechanism will prevent infinite loops in case of a bug in the task code.\n */\nconst DEFAULT_MAX_ITERATIONS = 50;\n\nexport interface ITaskPluginSetFieldsCallback {\n (fields: ITaskDefinitionField[]): ITaskDefinitionField[] | undefined;\n}\n\nexport interface ITaskDefinitionParams<\n C extends Context = Context,\n I = any,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> extends Omit<ITaskDefinition<C, I, O>, \"fields\" | \"maxIterations\"> {\n config?: (task: Pick<TaskDefinitionPlugin<C, I, O>, \"addField\" | \"setFields\">) => void;\n maxIterations?: number;\n}\n\nexport class TaskDefinitionPlugin<\n C extends Context = Context,\n I = any,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n >\n extends Plugin\n implements ITaskDefinition<C, I, O>\n{\n public static override readonly type: string = \"webiny.backgroundTask\";\n\n public readonly isPrivate: boolean;\n\n private readonly task: ITaskDefinition<C, I, O>;\n\n public get id() {\n return this.task.id;\n }\n\n public get title() {\n return this.task.title;\n }\n\n public get fields() {\n return this.task.fields;\n }\n\n public get run() {\n return this.task.run;\n }\n\n public get onDone() {\n return this.task.onDone;\n }\n\n public get onAbort() {\n return this.task.onAbort;\n }\n\n public get onError() {\n return this.task.onError;\n }\n\n public get onMaxIterations() {\n return this.task.onMaxIterations;\n }\n\n public get maxIterations(): number {\n return this.task.maxIterations || DEFAULT_MAX_ITERATIONS;\n }\n\n public constructor(task: ITaskDefinitionParams<C, I, O>) {\n super();\n this.isPrivate = task.isPrivate || false;\n this.task = {\n ...task,\n maxIterations: task.maxIterations || DEFAULT_MAX_ITERATIONS,\n fields: []\n };\n if (typeof task.config === \"function\") {\n task.config(this);\n }\n this.validate();\n }\n\n public getTask() {\n return this.task;\n }\n\n public setFields(cb: ITaskPluginSetFieldsCallback) {\n const fields = Array.from(this.task.fields || []);\n this.task.fields = cb(fields);\n }\n\n public addField(field: ITaskDefinitionField) {\n this.task.fields = (this.task.fields || []).concat([field]);\n }\n /**\n * TODO implement zod validation if validation becomes too complex\n */\n private validate(): void {\n if (camelCase(this.task.id) !== this.task.id) {\n /**\n * We want to log and throw the message so it can be seen in the CloudWatch logs.\n */\n const message = `Task ID \"${this.task.id}\" is invalid. It must be in camelCase format, for example: \"myCustomTask\".`;\n console.log(message);\n throw new WebinyError(message);\n }\n }\n}\n\nexport const createTaskDefinition = <\n C extends Context = Context,\n I = any,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n>(\n params: ITaskDefinitionParams<C, I, O>\n) => {\n return new TaskDefinitionPlugin<C, I, O>(params);\n};\n\nexport const createPrivateTaskDefinition = <\n C extends Context = Context,\n I = any,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n>(\n params: ITaskDefinitionParams<C, I, O>\n) => {\n return new TaskDefinitionPlugin<C, I, O>({\n ...params,\n isPrivate: true\n });\n};\n\nexport const createTaskDefinitionField = (params: ITaskDefinitionField) => {\n return params;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CustomTimer = void 0;
|
|
7
|
+
const MAX_RUNNING_MINUTES = 14;
|
|
8
|
+
const MAX_RUNNING_MILLISECONDS = MAX_RUNNING_MINUTES * 60 * 1000;
|
|
9
|
+
class CustomTimer {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.startTime = Date.now();
|
|
12
|
+
}
|
|
13
|
+
getRemainingMilliseconds() {
|
|
14
|
+
const result = this.startTime + MAX_RUNNING_MILLISECONDS - Date.now(); // 14 minutes
|
|
15
|
+
console.log("It looks like the Lambda Context getRemainingTimeInMillis does not exist. Mocked remaining time:", result);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.CustomTimer = CustomTimer;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=CustomTimer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAX_RUNNING_MINUTES","MAX_RUNNING_MILLISECONDS","CustomTimer","constructor","startTime","Date","now","getRemainingMilliseconds","result","console","log","exports"],"sources":["CustomTimer.ts"],"sourcesContent":["import { ITimer } from \"~/timer/abstractions/ITimer\";\n\nconst MAX_RUNNING_MINUTES = 14;\nconst MAX_RUNNING_MILLISECONDS = MAX_RUNNING_MINUTES * 60 * 1000;\n\nexport class CustomTimer implements ITimer {\n private readonly startTime: number;\n\n public constructor() {\n this.startTime = Date.now();\n }\n\n public getRemainingMilliseconds(): number {\n const result = this.startTime + MAX_RUNNING_MILLISECONDS - Date.now(); // 14 minutes\n console.log(\n \"It looks like the Lambda Context getRemainingTimeInMillis does not exist. Mocked remaining time:\",\n result\n );\n return result;\n }\n}\n"],"mappings":";;;;;;AAEA,MAAMA,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,wBAAwB,GAAGD,mBAAmB,GAAG,EAAE,GAAG,IAAI;AAEzD,MAAME,WAAW,CAAmB;EAGhCC,WAAWA,CAAA,EAAG;IACjB,IAAI,CAACC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;EAC/B;EAEOC,wBAAwBA,CAAA,EAAW;IACtC,MAAMC,MAAM,GAAG,IAAI,CAACJ,SAAS,GAAGH,wBAAwB,GAAGI,IAAI,CAACC,GAAG,CAAC,CAAC,CAAC,CAAC;IACvEG,OAAO,CAACC,GAAG,CACP,kGAAkG,EAClGF,MACJ,CAAC;IACD,OAAOA,MAAM;EACjB;AACJ;AAACG,OAAA,CAAAT,WAAA,GAAAA,WAAA"}
|
package/timer/Timer.d.ts
ADDED
package/timer/Timer.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Timer = void 0;
|
|
7
|
+
class Timer {
|
|
8
|
+
constructor(cb) {
|
|
9
|
+
this.cb = cb;
|
|
10
|
+
}
|
|
11
|
+
getRemainingMilliseconds() {
|
|
12
|
+
return this.cb();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.Timer = Timer;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=Timer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Timer","constructor","cb","getRemainingMilliseconds","exports"],"sources":["Timer.ts"],"sourcesContent":["import { ITimer } from \"./abstractions/ITimer\";\n\nexport interface ITimerCb {\n (): number;\n}\n\nexport class Timer implements ITimer {\n private readonly cb: ITimerCb;\n\n public constructor(cb: ITimerCb) {\n this.cb = cb;\n }\n public getRemainingMilliseconds(): number {\n return this.cb();\n }\n}\n"],"mappings":";;;;;;AAMO,MAAMA,KAAK,CAAmB;EAG1BC,WAAWA,CAACC,EAAY,EAAE;IAC7B,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EACOC,wBAAwBA,CAAA,EAAW;IACtC,OAAO,IAAI,CAACD,EAAE,CAAC,CAAC;EACpB;AACJ;AAACE,OAAA,CAAAJ,KAAA,GAAAA,KAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["ITimer.ts"],"sourcesContent":["export interface ITimer {\n /**\n * Return value must be in milliseconds.\n */\n getRemainingMilliseconds(): number;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ITimer } from "./abstractions/ITimer";
|
|
2
|
+
import { Context as LambdaContext } from "aws-lambda/handler";
|
|
3
|
+
export declare type ITimerFactoryParams = Pick<LambdaContext, "getRemainingTimeInMillis">;
|
|
4
|
+
export declare const timerFactory: (params?: Partial<ITimerFactoryParams>) => ITimer;
|
package/timer/factory.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.timerFactory = void 0;
|
|
7
|
+
var _CustomTimer = require("./CustomTimer");
|
|
8
|
+
var _Timer = require("./Timer");
|
|
9
|
+
const timerFactory = params => {
|
|
10
|
+
const customTimer = new _CustomTimer.CustomTimer();
|
|
11
|
+
return new _Timer.Timer(() => {
|
|
12
|
+
if (params?.getRemainingTimeInMillis) {
|
|
13
|
+
return params.getRemainingTimeInMillis();
|
|
14
|
+
}
|
|
15
|
+
return customTimer.getRemainingMilliseconds();
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.timerFactory = timerFactory;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_CustomTimer","require","_Timer","timerFactory","params","customTimer","CustomTimer","Timer","getRemainingTimeInMillis","getRemainingMilliseconds","exports"],"sources":["factory.ts"],"sourcesContent":["import { ITimer } from \"~/timer/abstractions/ITimer\";\nimport { CustomTimer } from \"./CustomTimer\";\nimport { Context as LambdaContext } from \"aws-lambda/handler\";\nimport { Timer } from \"./Timer\";\n\nexport type ITimerFactoryParams = Pick<LambdaContext, \"getRemainingTimeInMillis\">;\n\nexport const timerFactory = (params?: Partial<ITimerFactoryParams>): ITimer => {\n const customTimer = new CustomTimer();\n\n return new Timer(() => {\n if (params?.getRemainingTimeInMillis) {\n return params.getRemainingTimeInMillis();\n }\n return customTimer.getRemainingMilliseconds();\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAIO,MAAME,YAAY,GAAIC,MAAqC,IAAa;EAC3E,MAAMC,WAAW,GAAG,IAAIC,wBAAW,CAAC,CAAC;EAErC,OAAO,IAAIC,YAAK,CAAC,MAAM;IACnB,IAAIH,MAAM,EAAEI,wBAAwB,EAAE;MAClC,OAAOJ,MAAM,CAACI,wBAAwB,CAAC,CAAC;IAC5C;IACA,OAAOH,WAAW,CAACI,wBAAwB,CAAC,CAAC;EACjD,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAP,YAAA,GAAAA,YAAA"}
|
package/timer/index.d.ts
ADDED
package/timer/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ITimer = require("./abstractions/ITimer");
|
|
7
|
+
Object.keys(_ITimer).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ITimer[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _ITimer[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _CustomTimer = require("./CustomTimer");
|
|
18
|
+
Object.keys(_CustomTimer).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _CustomTimer[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _CustomTimer[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _factory = require("./factory");
|
|
29
|
+
Object.keys(_factory).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _factory[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _factory[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _Timer = require("./Timer");
|
|
40
|
+
Object.keys(_Timer).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _Timer[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _Timer[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ITimer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_CustomTimer","_factory","_Timer"],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions/ITimer\";\nexport * from \"./CustomTimer\";\nexport * from \"./factory\";\nexport * from \"./Timer\";\n"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,YAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,YAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,YAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,YAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,QAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,QAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,QAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,QAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,MAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,MAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,MAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,MAAA,CAAAP,GAAA;IAAA;EAAA;AAAA"}
|
package/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { CmsContext as BaseContext, CmsEntryListParams, CmsEntryMeta, CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import { CmsContext as BaseContext, CmsEntryListParams, CmsEntryListWhere, CmsEntryMeta, CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
import { IResponseError, ITaskResponse, ITaskResponseDoneResultOutput, ITaskResponseResult } from "./response/abstractions";
|
|
4
4
|
import { ITaskManagerStore } from "./runner/abstractions";
|
|
5
|
-
import {
|
|
5
|
+
import { PutEventsCommandOutput } from "@webiny/aws-sdk/client-eventbridge";
|
|
6
6
|
import { SecurityPermission } from "@webiny/api-security/types";
|
|
7
|
+
export { PutEventsCommandOutput };
|
|
7
8
|
export * from "./handler/types";
|
|
8
9
|
export * from "./response/abstractions";
|
|
9
10
|
export * from "./runner/abstractions";
|
|
@@ -74,11 +75,11 @@ export interface ITask<T = any, O extends ITaskResponseDoneResultOutput = ITaskR
|
|
|
74
75
|
createdBy: ITaskIdentity;
|
|
75
76
|
startedOn?: string;
|
|
76
77
|
finishedOn?: string;
|
|
77
|
-
eventResponse:
|
|
78
|
+
eventResponse: PutEventsCommandOutput | undefined;
|
|
78
79
|
iterations: number;
|
|
79
80
|
parentId?: string;
|
|
80
81
|
}
|
|
81
|
-
export declare type IGetTaskResponse<T = any> = ITask<T> | null;
|
|
82
|
+
export declare type IGetTaskResponse<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITask<T, O> | null;
|
|
82
83
|
export interface IListTasksResponse<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
83
84
|
items: ITask<T, O>[];
|
|
84
85
|
meta: CmsEntryMeta;
|
|
@@ -87,11 +88,38 @@ export interface IListTaskLogsResponse {
|
|
|
87
88
|
items: ITaskLog[];
|
|
88
89
|
meta: CmsEntryMeta;
|
|
89
90
|
}
|
|
90
|
-
export declare type ICreateTaskResponse<T =
|
|
91
|
-
export declare type IUpdateTaskResponse<T =
|
|
91
|
+
export declare type ICreateTaskResponse<T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITask<T, O>;
|
|
92
|
+
export declare type IUpdateTaskResponse<T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITask<T, O>;
|
|
92
93
|
export declare type IDeleteTaskResponse = boolean;
|
|
93
|
-
export
|
|
94
|
-
|
|
94
|
+
export interface IListTaskParams extends Omit<CmsEntryListParams, "fields" | "search"> {
|
|
95
|
+
where?: CmsEntryListWhere & {
|
|
96
|
+
parentId?: string;
|
|
97
|
+
parentId_not?: string;
|
|
98
|
+
parentId_in?: string[];
|
|
99
|
+
parentId_not_in?: string[];
|
|
100
|
+
definitionId?: string;
|
|
101
|
+
definitionId_not?: string;
|
|
102
|
+
definitionId_in?: string[];
|
|
103
|
+
definitionId_not_in?: string[];
|
|
104
|
+
taskStatus?: string;
|
|
105
|
+
taskStatus_not?: string;
|
|
106
|
+
taskStatus_in?: string[];
|
|
107
|
+
taskStatus_not_in?: string[];
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export interface IListTaskLogParams extends Omit<CmsEntryListParams, "fields" | "search"> {
|
|
111
|
+
where?: CmsEntryListWhere & {
|
|
112
|
+
task?: string;
|
|
113
|
+
task_in?: string[];
|
|
114
|
+
task_not?: string;
|
|
115
|
+
iteration?: number;
|
|
116
|
+
iteration_not?: number;
|
|
117
|
+
iteration_gte?: number;
|
|
118
|
+
iteration_gt?: number;
|
|
119
|
+
iteration_lte?: number;
|
|
120
|
+
iteration_lt?: number;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
95
123
|
export interface ITaskCreateData<T = ITaskDataInput> {
|
|
96
124
|
definitionId: string;
|
|
97
125
|
name: string;
|
|
@@ -106,7 +134,7 @@ export interface ITaskUpdateData<I = ITaskDataInput, O extends ITaskResponseDone
|
|
|
106
134
|
executionName?: string;
|
|
107
135
|
startedOn?: string;
|
|
108
136
|
finishedOn?: string;
|
|
109
|
-
eventResponse?:
|
|
137
|
+
eventResponse?: PutEventsCommandOutput;
|
|
110
138
|
iterations?: number;
|
|
111
139
|
}
|
|
112
140
|
export interface OnTaskBeforeCreateTopicParams {
|
|
@@ -135,30 +163,31 @@ export interface ITaskLogCreateInput {
|
|
|
135
163
|
iteration: number;
|
|
136
164
|
}
|
|
137
165
|
export interface ITaskLogUpdateInput {
|
|
138
|
-
items
|
|
166
|
+
items?: ITaskLogItem[];
|
|
139
167
|
}
|
|
140
168
|
export interface ITasksContextCrudObject {
|
|
141
169
|
/**
|
|
142
170
|
* Models
|
|
143
171
|
*/
|
|
144
|
-
getTaskModel
|
|
145
|
-
getLogModel
|
|
172
|
+
getTaskModel(): Promise<CmsModel>;
|
|
173
|
+
getLogModel(): Promise<CmsModel>;
|
|
146
174
|
/**
|
|
147
175
|
* Tasks
|
|
148
176
|
*/
|
|
149
|
-
getTask
|
|
150
|
-
listTasks
|
|
151
|
-
createTask
|
|
152
|
-
updateTask
|
|
153
|
-
deleteTask
|
|
177
|
+
getTask<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(id: string): Promise<IGetTaskResponse<T, O> | null>;
|
|
178
|
+
listTasks<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(params?: IListTaskParams): Promise<IListTasksResponse<T, O>>;
|
|
179
|
+
createTask<T = any>(task: ITaskCreateData<T>): Promise<ICreateTaskResponse<T>>;
|
|
180
|
+
updateTask<T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(id: string, data: Partial<ITaskUpdateData<T, O>>): Promise<IUpdateTaskResponse<T, O>>;
|
|
181
|
+
deleteTask(id: string): Promise<IDeleteTaskResponse>;
|
|
154
182
|
/**
|
|
155
183
|
* Logs
|
|
156
184
|
*/
|
|
157
|
-
createLog
|
|
158
|
-
updateLog
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
185
|
+
createLog(task: Pick<ITask, "id">, data: ITaskLogCreateInput): Promise<ITaskLog>;
|
|
186
|
+
updateLog(id: string, data: ITaskLogUpdateInput): Promise<ITaskLog>;
|
|
187
|
+
deleteLog(id: string): Promise<boolean>;
|
|
188
|
+
getLog(id: string): Promise<ITaskLog | null>;
|
|
189
|
+
getLatestLog(taskId: string): Promise<ITaskLog>;
|
|
190
|
+
listLogs(params: IListTaskLogParams): Promise<IListTaskLogsResponse>;
|
|
162
191
|
/**
|
|
163
192
|
* Lifecycle events.
|
|
164
193
|
*/
|
|
@@ -176,14 +205,12 @@ export interface ITasksContextDefinitionObject {
|
|
|
176
205
|
getDefinition: <T = ITaskDataInput>(id: string) => ITaskDefinition<Context, T> | null;
|
|
177
206
|
listDefinitions: () => ITaskDefinition[];
|
|
178
207
|
}
|
|
179
|
-
/**
|
|
180
|
-
* TODO: implement delayed trigger
|
|
181
|
-
*/
|
|
182
208
|
export interface ITaskTriggerParams<I = ITaskDataInput> {
|
|
183
209
|
parent?: ITask;
|
|
184
210
|
definition: string;
|
|
185
211
|
name?: string;
|
|
186
212
|
input?: I;
|
|
213
|
+
delay?: number;
|
|
187
214
|
}
|
|
188
215
|
export interface ITaskAbortParams {
|
|
189
216
|
id: string;
|
|
@@ -201,11 +228,11 @@ export interface Context extends BaseContext {
|
|
|
201
228
|
export interface ITaskRunParams<C extends Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
202
229
|
context: C;
|
|
203
230
|
response: ITaskResponse<I, O>;
|
|
204
|
-
isCloseToTimeout
|
|
205
|
-
isAborted
|
|
231
|
+
isCloseToTimeout(seconds?: number): boolean;
|
|
232
|
+
isAborted(): boolean;
|
|
206
233
|
input: I;
|
|
207
234
|
store: ITaskManagerStore<I>;
|
|
208
|
-
trigger
|
|
235
|
+
trigger<SI = ITaskDataInput>(params: Omit<ITaskTriggerParams<SI>, "parent">): Promise<ITask<SI>>;
|
|
209
236
|
}
|
|
210
237
|
export interface ITaskOnSuccessParams<C extends Context, I = ITaskDataInput> {
|
|
211
238
|
context: C;
|
|
@@ -232,7 +259,7 @@ export declare enum TaskResponseStatus {
|
|
|
232
259
|
export declare type ITaskDefinitionField = Pick<CmsModelField, "fieldId" | "type" | "label" | "renderer" | "helpText" | "placeholderText" | "predefinedValues" | "validation" | "listValidation" | "multipleValues" | "settings">;
|
|
233
260
|
export interface ITaskBeforeTriggerParams<C extends Context = Context, I = ITaskDataInput> {
|
|
234
261
|
context: C;
|
|
235
|
-
|
|
262
|
+
data: ITaskCreateData<I>;
|
|
236
263
|
}
|
|
237
264
|
export interface ITaskDefinition<C extends Context = Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
238
265
|
/**
|
|
@@ -258,32 +285,32 @@ export interface ITaskDefinition<C extends Context = Context, I = ITaskDataInput
|
|
|
258
285
|
/**
|
|
259
286
|
* Task run method.
|
|
260
287
|
*/
|
|
261
|
-
run
|
|
288
|
+
run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult>;
|
|
262
289
|
/**
|
|
263
290
|
* When a new task is about to be triggered, we will run this method.
|
|
264
291
|
* For example, you can use this method to check if there is a task of the same type already running.
|
|
265
292
|
*/
|
|
266
|
-
onBeforeTrigger
|
|
293
|
+
onBeforeTrigger?<T = ITaskDataInput>(params: ITaskBeforeTriggerParams<C, T>): Promise<void>;
|
|
267
294
|
/**
|
|
268
295
|
* When task successfully finishes, this method will be called.
|
|
269
296
|
* This will be called during the run time of the task.
|
|
270
297
|
*/
|
|
271
|
-
onDone
|
|
298
|
+
onDone?(params: ITaskOnSuccessParams<C, I>): Promise<void>;
|
|
272
299
|
/**
|
|
273
300
|
* When task fails, this method will be called.
|
|
274
301
|
* This will be called during the run time of the task.
|
|
275
302
|
*/
|
|
276
|
-
onError
|
|
303
|
+
onError?(params: ITaskOnErrorParams<C, I>): Promise<void>;
|
|
277
304
|
/**
|
|
278
305
|
* When task is aborted, this method will be called.
|
|
279
306
|
* This method will be called when user aborts the task.
|
|
280
307
|
*/
|
|
281
|
-
onAbort
|
|
308
|
+
onAbort?(params: ITaskOnAbortParams<C>): Promise<void>;
|
|
282
309
|
/**
|
|
283
310
|
* When task hits max iterations, this method will be called.
|
|
284
311
|
* This will be called during the run time of the task.
|
|
285
312
|
*/
|
|
286
|
-
onMaxIterations
|
|
313
|
+
onMaxIterations?(params: ITaskOnMaxIterationsParams<C>): Promise<void>;
|
|
287
314
|
/**
|
|
288
315
|
* Custom input fields and layout for the task input.
|
|
289
316
|
*/
|
package/types.js
CHANGED
|
@@ -6,9 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
ITaskLogItemType: true,
|
|
8
8
|
TaskDataStatus: true,
|
|
9
|
-
TaskResponseStatus: true
|
|
9
|
+
TaskResponseStatus: true,
|
|
10
|
+
PutEventsCommandOutput: true
|
|
10
11
|
};
|
|
11
|
-
exports.
|
|
12
|
+
exports.ITaskLogItemType = void 0;
|
|
13
|
+
Object.defineProperty(exports, "PutEventsCommandOutput", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _clientEventbridge.PutEventsCommandOutput;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
exports.TaskResponseStatus = exports.TaskDataStatus = void 0;
|
|
20
|
+
var _clientEventbridge = require("@webiny/aws-sdk/client-eventbridge");
|
|
12
21
|
var _types = require("./handler/types");
|
|
13
22
|
Object.keys(_types).forEach(function (key) {
|
|
14
23
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -59,9 +68,6 @@ let TaskDataStatus = /*#__PURE__*/function (TaskDataStatus) {
|
|
|
59
68
|
TaskDataStatus["ABORTED"] = "aborted";
|
|
60
69
|
return TaskDataStatus;
|
|
61
70
|
}({});
|
|
62
|
-
/**
|
|
63
|
-
* TODO: implement delayed trigger
|
|
64
|
-
*/
|
|
65
71
|
exports.TaskDataStatus = TaskDataStatus;
|
|
66
72
|
let TaskResponseStatus = /*#__PURE__*/function (TaskResponseStatus) {
|
|
67
73
|
TaskResponseStatus["DONE"] = "done";
|