@webiny/tasks 6.0.0-beta.0 → 6.0.0-rc.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/README.md +10 -9
- package/context.d.ts +2 -3
- package/context.js +44 -30
- package/context.js.map +1 -1
- package/crud/TaskLogPrivateModel.d.ts +9 -0
- package/crud/TaskLogPrivateModel.js +34 -0
- package/crud/TaskLogPrivateModel.js.map +1 -0
- package/crud/TaskPrivateModel.d.ts +9 -0
- package/crud/TaskPrivateModel.js +46 -0
- package/crud/TaskPrivateModel.js.map +1 -0
- package/crud/crud.tasks.d.ts +1 -1
- package/crud/crud.tasks.js +238 -94
- package/crud/crud.tasks.js.map +1 -1
- package/crud/definition.tasks.d.ts +1 -1
- package/crud/definition.tasks.js +9 -18
- package/crud/definition.tasks.js.map +1 -1
- package/crud/service.tasks.d.ts +2 -0
- package/crud/{trigger.tasks.js → service.tasks.js} +59 -42
- package/crud/service.tasks.js.map +1 -0
- package/decorators/RunnableTaskDecorator.d.ts +31 -0
- package/decorators/RunnableTaskDecorator.js +82 -0
- package/decorators/RunnableTaskDecorator.js.map +1 -0
- package/domain/errors.d.ts +29 -0
- package/domain/errors.js +47 -0
- package/domain/errors.js.map +1 -0
- package/events/TaskAfterCreateEvent.d.ts +6 -0
- package/events/TaskAfterCreateEvent.js +10 -0
- package/events/TaskAfterCreateEvent.js.map +1 -0
- package/events/TaskAfterDeleteEvent.d.ts +6 -0
- package/events/TaskAfterDeleteEvent.js +10 -0
- package/events/TaskAfterDeleteEvent.js.map +1 -0
- package/events/TaskAfterUpdateEvent.d.ts +6 -0
- package/events/TaskAfterUpdateEvent.js +10 -0
- package/events/TaskAfterUpdateEvent.js.map +1 -0
- package/events/TaskBeforeCreateEvent.d.ts +6 -0
- package/events/TaskBeforeCreateEvent.js +10 -0
- package/events/TaskBeforeCreateEvent.js.map +1 -0
- package/events/TaskBeforeDeleteEvent.d.ts +6 -0
- package/events/TaskBeforeDeleteEvent.js +10 -0
- package/events/TaskBeforeDeleteEvent.js.map +1 -0
- package/events/TaskBeforeUpdateEvent.d.ts +6 -0
- package/events/TaskBeforeUpdateEvent.js +10 -0
- package/events/TaskBeforeUpdateEvent.js.map +1 -0
- package/events/abstractions.d.ts +53 -0
- package/events/abstractions.js +39 -0
- package/events/abstractions.js.map +1 -0
- package/events/index.d.ts +7 -0
- package/events/index.js +9 -0
- package/events/index.js.map +1 -0
- package/features/AbortTask/AbortTaskUseCase.d.ts +10 -0
- package/features/AbortTask/AbortTaskUseCase.js +11 -0
- package/features/AbortTask/AbortTaskUseCase.js.map +1 -0
- package/features/AbortTask/abstractions.d.ts +25 -0
- package/features/AbortTask/abstractions.js +4 -0
- package/features/AbortTask/abstractions.js.map +1 -0
- package/features/AbortTask/feature.d.ts +2 -0
- package/features/AbortTask/feature.js +11 -0
- package/features/AbortTask/feature.js.map +1 -0
- package/features/AbortTask/index.d.ts +2 -0
- package/features/AbortTask/index.js +4 -0
- package/features/AbortTask/index.js.map +1 -0
- package/features/GetTask/GetTaskUseCase.d.ts +9 -0
- package/features/GetTask/GetTaskUseCase.js +10 -0
- package/features/GetTask/GetTaskUseCase.js.map +1 -0
- package/features/GetTask/abstractions.d.ts +10 -0
- package/features/GetTask/abstractions.js +4 -0
- package/features/GetTask/abstractions.js.map +1 -0
- package/features/GetTask/feature.d.ts +2 -0
- package/features/GetTask/feature.js +11 -0
- package/features/GetTask/feature.js.map +1 -0
- package/features/GetTask/index.d.ts +2 -0
- package/features/GetTask/index.js +4 -0
- package/features/GetTask/index.js.map +1 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.d.ts +12 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +25 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js.map +1 -0
- package/features/GetTaskDefinition/abstractions.d.ts +17 -0
- package/features/GetTaskDefinition/abstractions.js +4 -0
- package/features/GetTaskDefinition/abstractions.js.map +1 -0
- package/features/GetTaskDefinition/feature.d.ts +1 -0
- package/features/GetTaskDefinition/feature.js +10 -0
- package/features/GetTaskDefinition/feature.js.map +1 -0
- package/features/GetTaskDefinition/index.d.ts +2 -0
- package/features/GetTaskDefinition/index.js +4 -0
- package/features/GetTaskDefinition/index.js.map +1 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.d.ts +11 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js +18 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js.map +1 -0
- package/features/ListTaskDefinitions/abstractions.d.ts +9 -0
- package/features/ListTaskDefinitions/abstractions.js +4 -0
- package/features/ListTaskDefinitions/abstractions.js.map +1 -0
- package/features/ListTaskDefinitions/feature.d.ts +1 -0
- package/features/ListTaskDefinitions/feature.js +10 -0
- package/features/ListTaskDefinitions/feature.js.map +1 -0
- package/features/ListTaskDefinitions/index.d.ts +2 -0
- package/features/ListTaskDefinitions/index.js +4 -0
- package/features/ListTaskDefinitions/index.js.map +1 -0
- package/features/ListTasks/ListTasksUseCase.d.ts +9 -0
- package/features/ListTasks/ListTasksUseCase.js +10 -0
- package/features/ListTasks/ListTasksUseCase.js.map +1 -0
- package/features/ListTasks/abstractions.d.ts +13 -0
- package/features/ListTasks/abstractions.js +4 -0
- package/features/ListTasks/abstractions.js.map +1 -0
- package/features/ListTasks/feature.d.ts +2 -0
- package/features/ListTasks/feature.js +11 -0
- package/features/ListTasks/feature.js.map +1 -0
- package/features/ListTasks/index.d.ts +2 -0
- package/features/ListTasks/index.js +4 -0
- package/features/ListTasks/index.js.map +1 -0
- package/features/TaskController/TaskController.d.ts +49 -0
- package/features/TaskController/TaskController.js +71 -0
- package/features/TaskController/TaskController.js.map +1 -0
- package/features/TaskController/augmentation.d.ts +60 -0
- package/features/TaskController/augmentation.js +3 -0
- package/features/TaskController/augmentation.js.map +1 -0
- package/features/TaskController/index.d.ts +2 -0
- package/features/TaskController/index.js +7 -0
- package/features/TaskController/index.js.map +1 -0
- package/features/TaskExecutionContext/TaskExecutionContext.d.ts +24 -0
- package/features/TaskExecutionContext/TaskExecutionContext.js +50 -0
- package/features/TaskExecutionContext/TaskExecutionContext.js.map +1 -0
- package/features/TaskExecutionContext/abstractions.d.ts +26 -0
- package/features/TaskExecutionContext/abstractions.js +13 -0
- package/features/TaskExecutionContext/abstractions.js.map +1 -0
- package/features/TaskExecutionContext/feature.d.ts +1 -0
- package/features/TaskExecutionContext/feature.js +10 -0
- package/features/TaskExecutionContext/feature.js.map +1 -0
- package/features/TaskExecutionContext/index.d.ts +1 -0
- package/features/TaskExecutionContext/index.js +3 -0
- package/features/TaskExecutionContext/index.js.map +1 -0
- package/features/TriggerTask/TriggerTaskUseCase.d.ts +10 -0
- package/features/TriggerTask/TriggerTaskUseCase.js +11 -0
- package/features/TriggerTask/TriggerTaskUseCase.js.map +1 -0
- package/features/TriggerTask/abstractions.d.ts +28 -0
- package/features/TriggerTask/abstractions.js +4 -0
- package/features/TriggerTask/abstractions.js.map +1 -0
- package/features/TriggerTask/feature.d.ts +2 -0
- package/features/TriggerTask/feature.js +11 -0
- package/features/TriggerTask/feature.js.map +1 -0
- package/features/TriggerTask/index.d.ts +2 -0
- package/features/TriggerTask/index.js +4 -0
- package/features/TriggerTask/index.js.map +1 -0
- package/global.d.ts +1 -0
- package/global.js +3 -0
- package/global.js.map +1 -0
- package/graphql/checkPermissions.d.ts +1 -1
- package/graphql/checkPermissions.js +3 -9
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/index.d.ts +1 -1
- package/graphql/index.js +64 -71
- package/graphql/index.js.map +1 -1
- package/graphql/utils.d.ts +1 -1
- package/graphql/utils.js +8 -17
- package/graphql/utils.js.map +1 -1
- package/handler/index.d.ts +2 -5
- package/handler/index.js +33 -40
- package/handler/index.js.map +1 -1
- package/handler/register.js +8 -8
- package/handler/register.js.map +1 -1
- package/handler/types.d.ts +2 -2
- package/handler/types.js +1 -5
- package/handler/types.js.map +1 -1
- package/index.d.ts +5 -6
- package/index.js +5 -60
- package/index.js.map +1 -1
- package/package.json +23 -44
- package/plugins/TaskServicePlugin.d.ts +19 -0
- package/plugins/TaskServicePlugin.js +10 -0
- package/plugins/TaskServicePlugin.js.map +1 -0
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +1 -16
- package/plugins/index.js.map +1 -1
- package/response/DatabaseResponse.d.ts +3 -3
- package/response/DatabaseResponse.js +14 -20
- package/response/DatabaseResponse.js.map +1 -1
- package/response/Response.d.ts +4 -3
- package/response/Response.js +63 -27
- package/response/Response.js.map +1 -1
- package/response/ResponseAbortedResult.d.ts +3 -4
- package/response/ResponseAbortedResult.js +3 -11
- package/response/ResponseAbortedResult.js.map +1 -1
- package/response/ResponseContinueResult.d.ts +4 -4
- package/response/ResponseContinueResult.js +3 -11
- package/response/ResponseContinueResult.js.map +1 -1
- package/response/ResponseDoneResult.d.ts +4 -5
- package/response/ResponseDoneResult.js +4 -12
- package/response/ResponseDoneResult.js.map +1 -1
- package/response/ResponseErrorResult.d.ts +3 -4
- package/response/ResponseErrorResult.js +3 -11
- package/response/ResponseErrorResult.js.map +1 -1
- package/response/TaskResponse.d.ts +7 -6
- package/response/TaskResponse.js +7 -14
- package/response/TaskResponse.js.map +1 -1
- package/response/abstractions/Response.d.ts +9 -9
- package/response/abstractions/Response.js +1 -5
- package/response/abstractions/Response.js.map +1 -1
- package/response/abstractions/ResponseAbortedResult.d.ts +3 -3
- package/response/abstractions/ResponseAbortedResult.js +1 -5
- package/response/abstractions/ResponseAbortedResult.js.map +1 -1
- package/response/abstractions/ResponseBaseResult.d.ts +2 -3
- package/response/abstractions/ResponseBaseResult.js +1 -5
- package/response/abstractions/ResponseBaseResult.js.map +1 -1
- package/response/abstractions/ResponseContinueResult.d.ts +5 -4
- package/response/abstractions/ResponseContinueResult.js +1 -5
- package/response/abstractions/ResponseContinueResult.js.map +1 -1
- package/response/abstractions/ResponseDoneResult.d.ts +5 -6
- package/response/abstractions/ResponseDoneResult.js +1 -5
- package/response/abstractions/ResponseDoneResult.js.map +1 -1
- package/response/abstractions/ResponseErrorResult.d.ts +6 -6
- package/response/abstractions/ResponseErrorResult.js +1 -5
- package/response/abstractions/ResponseErrorResult.js.map +1 -1
- package/response/abstractions/TaskResponse.d.ts +9 -34
- package/response/abstractions/TaskResponse.js +1 -5
- package/response/abstractions/TaskResponse.js.map +1 -1
- package/response/abstractions/index.d.ts +7 -7
- package/response/abstractions/index.js +7 -82
- package/response/abstractions/index.js.map +1 -1
- package/response/index.d.ts +7 -7
- package/response/index.js +7 -82
- package/response/index.js.map +1 -1
- package/runner/TaskControl.d.ts +4 -4
- package/runner/TaskControl.js +98 -49
- package/runner/TaskControl.js.map +1 -1
- package/runner/TaskEventValidation.d.ts +2 -2
- package/runner/TaskEventValidation.js +11 -20
- package/runner/TaskEventValidation.js.map +1 -1
- package/runner/TaskManager.d.ts +7 -8
- package/runner/TaskManager.js +19 -38
- package/runner/TaskManager.js.map +1 -1
- package/runner/TaskManagerStore.d.ts +14 -5
- package/runner/TaskManagerStore.js +40 -26
- package/runner/TaskManagerStore.js.map +1 -1
- package/runner/TaskRunner.d.ts +6 -7
- package/runner/TaskRunner.js +9 -31
- package/runner/TaskRunner.js.map +1 -1
- package/runner/abstractions/TaskControl.d.ts +4 -4
- package/runner/abstractions/TaskControl.js +1 -5
- package/runner/abstractions/TaskControl.js.map +1 -1
- package/runner/abstractions/TaskEventValidation.d.ts +2 -2
- package/runner/abstractions/TaskEventValidation.js +1 -5
- package/runner/abstractions/TaskEventValidation.js.map +1 -1
- package/runner/abstractions/TaskManager.d.ts +4 -4
- package/runner/abstractions/TaskManager.js +1 -5
- package/runner/abstractions/TaskManager.js.map +1 -1
- package/runner/abstractions/TaskManagerStore.d.ts +15 -9
- package/runner/abstractions/TaskManagerStore.js +1 -5
- package/runner/abstractions/TaskManagerStore.js.map +1 -1
- package/runner/abstractions/TaskRunner.d.ts +9 -4
- package/runner/abstractions/TaskRunner.js +1 -5
- package/runner/abstractions/TaskRunner.js.map +1 -1
- package/runner/abstractions/index.d.ts +5 -5
- package/runner/abstractions/index.js +5 -60
- package/runner/abstractions/index.js.map +1 -1
- package/runner/index.d.ts +1 -1
- package/runner/index.js +1 -16
- package/runner/index.js.map +1 -1
- package/service/EventBridgeEventTransportPlugin.d.ts +16 -0
- package/service/EventBridgeEventTransportPlugin.js +51 -0
- package/service/EventBridgeEventTransportPlugin.js.map +1 -0
- package/service/StepFunctionServicePlugin.d.ts +25 -0
- package/service/StepFunctionServicePlugin.js +78 -0
- package/service/StepFunctionServicePlugin.js.map +1 -0
- package/service/createService.d.ts +6 -0
- package/service/createService.js +19 -0
- package/service/createService.js.map +1 -0
- package/service/index.d.ts +4 -0
- package/service/index.js +10 -0
- package/service/index.js.map +1 -0
- package/tasks/testingRunTask.d.ts +10 -1
- package/tasks/testingRunTask.js +13 -18
- package/tasks/testingRunTask.js.map +1 -1
- package/types.d.ts +47 -215
- package/types.js +8 -68
- package/types.js.map +1 -1
- package/utils/ObjectUpdater.js +4 -11
- package/utils/ObjectUpdater.js.map +1 -1
- package/utils/getErrorProperties.d.ts +2 -2
- package/utils/getErrorProperties.js +5 -10
- package/utils/getErrorProperties.js.map +1 -1
- package/utils/getObjectProperties.js +1 -8
- package/utils/getObjectProperties.js.map +1 -1
- package/utils/index.d.ts +3 -0
- package/utils/index.js +5 -0
- package/utils/index.js.map +1 -0
- package/crud/model.d.ts +0 -5
- package/crud/model.js +0 -216
- package/crud/model.js.map +0 -1
- package/crud/transport/EventBridgeEventTransportPlugin.d.ts +0 -5
- package/crud/transport/EventBridgeEventTransportPlugin.js +0 -58
- package/crud/transport/EventBridgeEventTransportPlugin.js.map +0 -1
- package/crud/trigger.tasks.d.ts +0 -2
- package/crud/trigger.tasks.js.map +0 -1
- package/crud/where.d.ts +0 -1
- package/crud/where.js +0 -33
- package/crud/where.js.map +0 -1
- package/plugins/TaskTriggerTransportPlugin.d.ts +0 -17
- package/plugins/TaskTriggerTransportPlugin.js +0 -20
- package/plugins/TaskTriggerTransportPlugin.js.map +0 -1
- package/task/index.d.ts +0 -2
- package/task/index.js +0 -29
- package/task/index.js.map +0 -1
- package/task/input.d.ts +0 -15
- package/task/input.js +0 -21
- package/task/input.js.map +0 -1
- package/task/plugin.d.ts +0 -34
- package/task/plugin.js +0 -100
- package/task/plugin.js.map +0 -1
- package/transport/createTransport.d.ts +0 -7
- package/transport/createTransport.js +0 -32
- package/transport/createTransport.js.map +0 -1
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare type ITaskResponseResult<I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITaskResponseDoneResult<O> | ITaskResponseContinueResult<I> | ITaskResponseErrorResult | ITaskResponseAbortedResult;
|
|
4
|
-
export interface ITaskResponseDoneResultOutput {
|
|
5
|
-
error?: IResponseError;
|
|
6
|
-
[key: string]: string | string[] | number | boolean | undefined | Record<string, any> | IResponseError;
|
|
7
|
-
}
|
|
8
|
-
export interface ITaskResponseDoneResult<O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
9
|
-
message?: string;
|
|
10
|
-
output?: O;
|
|
11
|
-
status: TaskResponseStatus.DONE;
|
|
12
|
-
}
|
|
13
|
-
export interface ITaskResponseContinueResult<T = ITaskDataInput> {
|
|
14
|
-
input: T;
|
|
15
|
-
wait?: number;
|
|
16
|
-
status: TaskResponseStatus.CONTINUE;
|
|
17
|
-
}
|
|
18
|
-
export interface ITaskResponseErrorResult {
|
|
19
|
-
error: IResponseError;
|
|
20
|
-
status: TaskResponseStatus.ERROR;
|
|
21
|
-
}
|
|
22
|
-
export interface ITaskResponseAbortedResult {
|
|
23
|
-
status: TaskResponseStatus.ABORTED;
|
|
24
|
-
}
|
|
1
|
+
import type { IResponseError } from "./ResponseErrorResult.js";
|
|
2
|
+
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
25
3
|
export interface ITaskResponseContinueOptionsUntil {
|
|
26
4
|
date: Date;
|
|
27
5
|
}
|
|
28
6
|
export interface ITaskResponseContinueOptionsSeconds {
|
|
29
7
|
seconds: number;
|
|
30
8
|
}
|
|
31
|
-
export
|
|
32
|
-
export interface
|
|
33
|
-
(output?: O):
|
|
34
|
-
(message?: string, output?: O):
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
continue: (data: T, options?: ITaskResponseContinueOptions) => ITaskResponseContinueResult<T>;
|
|
39
|
-
error: (error: IResponseError | Error | string) => ITaskResponseErrorResult;
|
|
40
|
-
aborted: () => ITaskResponseAbortedResult;
|
|
9
|
+
export type ITaskResponseContinueOptions = ITaskResponseContinueOptionsUntil | ITaskResponseContinueOptionsSeconds;
|
|
10
|
+
export interface ITaskResponse<I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> {
|
|
11
|
+
done(output?: O): TaskDefinition.ResultDone<O>;
|
|
12
|
+
done(message?: string, output?: O): TaskDefinition.ResultDone<O>;
|
|
13
|
+
continue(data: I, options?: ITaskResponseContinueOptions): TaskDefinition.ResultContinue<I>;
|
|
14
|
+
error(error: IResponseError | Error | string): TaskDefinition.ResultError;
|
|
15
|
+
aborted(): TaskDefinition.ResultAborted;
|
|
41
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["TaskResponse.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"names":[],"sources":["TaskResponse.ts"],"sourcesContent":["import type { IResponseError } from \"./ResponseErrorResult.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface ITaskResponseContinueOptionsUntil {\n date: Date;\n}\nexport interface ITaskResponseContinueOptionsSeconds {\n seconds: number;\n}\n\nexport type ITaskResponseContinueOptions =\n | ITaskResponseContinueOptionsUntil\n | ITaskResponseContinueOptionsSeconds;\n\nexport interface ITaskResponse<\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> {\n done(output?: O): TaskDefinition.ResultDone<O>;\n done(message?: string, output?: O): TaskDefinition.ResultDone<O>;\n continue(data: I, options?: ITaskResponseContinueOptions): TaskDefinition.ResultContinue<I>;\n error(error: IResponseError | Error | string): TaskDefinition.ResultError;\n aborted(): TaskDefinition.ResultAborted;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./Response";
|
|
2
|
-
export * from "./ResponseContinueResult";
|
|
3
|
-
export * from "./ResponseDoneResult";
|
|
4
|
-
export * from "./ResponseErrorResult";
|
|
5
|
-
export * from "./ResponseAbortedResult";
|
|
6
|
-
export * from "./ResponseBaseResult";
|
|
7
|
-
export * from "./TaskResponse";
|
|
1
|
+
export * from "./Response.js";
|
|
2
|
+
export * from "./ResponseContinueResult.js";
|
|
3
|
+
export * from "./ResponseDoneResult.js";
|
|
4
|
+
export * from "./ResponseErrorResult.js";
|
|
5
|
+
export * from "./ResponseAbortedResult.js";
|
|
6
|
+
export * from "./ResponseBaseResult.js";
|
|
7
|
+
export * from "./TaskResponse.js";
|
|
@@ -1,84 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _Response[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _Response[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _ResponseContinueResult = require("./ResponseContinueResult");
|
|
18
|
-
Object.keys(_ResponseContinueResult).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _ResponseContinueResult[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _ResponseContinueResult[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _ResponseDoneResult = require("./ResponseDoneResult");
|
|
29
|
-
Object.keys(_ResponseDoneResult).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _ResponseDoneResult[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _ResponseDoneResult[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _ResponseErrorResult = require("./ResponseErrorResult");
|
|
40
|
-
Object.keys(_ResponseErrorResult).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _ResponseErrorResult[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _ResponseErrorResult[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _ResponseAbortedResult = require("./ResponseAbortedResult");
|
|
51
|
-
Object.keys(_ResponseAbortedResult).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _ResponseAbortedResult[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _ResponseAbortedResult[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _ResponseBaseResult = require("./ResponseBaseResult");
|
|
62
|
-
Object.keys(_ResponseBaseResult).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _ResponseBaseResult[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _ResponseBaseResult[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _TaskResponse = require("./TaskResponse");
|
|
73
|
-
Object.keys(_TaskResponse).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _TaskResponse[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _TaskResponse[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
1
|
+
export * from "./Response.js";
|
|
2
|
+
export * from "./ResponseContinueResult.js";
|
|
3
|
+
export * from "./ResponseDoneResult.js";
|
|
4
|
+
export * from "./ResponseErrorResult.js";
|
|
5
|
+
export * from "./ResponseAbortedResult.js";
|
|
6
|
+
export * from "./ResponseBaseResult.js";
|
|
7
|
+
export * from "./TaskResponse.js";
|
|
83
8
|
|
|
84
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Response.js\";\nexport * from \"./ResponseContinueResult.js\";\nexport * from \"./ResponseDoneResult.js\";\nexport * from \"./ResponseErrorResult.js\";\nexport * from \"./ResponseAbortedResult.js\";\nexport * from \"./ResponseBaseResult.js\";\nexport * from \"./TaskResponse.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/response/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./DatabaseResponse";
|
|
2
|
-
export * from "./Response";
|
|
3
|
-
export * from "./ResponseContinueResult";
|
|
4
|
-
export * from "./ResponseDoneResult";
|
|
5
|
-
export * from "./ResponseAbortedResult";
|
|
6
|
-
export * from "./ResponseErrorResult";
|
|
7
|
-
export * from "./TaskResponse";
|
|
1
|
+
export * from "./DatabaseResponse.js";
|
|
2
|
+
export * from "./Response.js";
|
|
3
|
+
export * from "./ResponseContinueResult.js";
|
|
4
|
+
export * from "./ResponseDoneResult.js";
|
|
5
|
+
export * from "./ResponseAbortedResult.js";
|
|
6
|
+
export * from "./ResponseErrorResult.js";
|
|
7
|
+
export * from "./TaskResponse.js";
|
package/response/index.js
CHANGED
|
@@ -1,84 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _DatabaseResponse[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _DatabaseResponse[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _Response = require("./Response");
|
|
18
|
-
Object.keys(_Response).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _Response[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _Response[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _ResponseContinueResult = require("./ResponseContinueResult");
|
|
29
|
-
Object.keys(_ResponseContinueResult).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _ResponseContinueResult[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _ResponseContinueResult[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _ResponseDoneResult = require("./ResponseDoneResult");
|
|
40
|
-
Object.keys(_ResponseDoneResult).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _ResponseDoneResult[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _ResponseDoneResult[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _ResponseAbortedResult = require("./ResponseAbortedResult");
|
|
51
|
-
Object.keys(_ResponseAbortedResult).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _ResponseAbortedResult[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _ResponseAbortedResult[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _ResponseErrorResult = require("./ResponseErrorResult");
|
|
62
|
-
Object.keys(_ResponseErrorResult).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _ResponseErrorResult[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _ResponseErrorResult[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _TaskResponse = require("./TaskResponse");
|
|
73
|
-
Object.keys(_TaskResponse).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _TaskResponse[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _TaskResponse[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
1
|
+
export * from "./DatabaseResponse.js";
|
|
2
|
+
export * from "./Response.js";
|
|
3
|
+
export * from "./ResponseContinueResult.js";
|
|
4
|
+
export * from "./ResponseDoneResult.js";
|
|
5
|
+
export * from "./ResponseAbortedResult.js";
|
|
6
|
+
export * from "./ResponseErrorResult.js";
|
|
7
|
+
export * from "./TaskResponse.js";
|
|
83
8
|
|
|
84
9
|
//# sourceMappingURL=index.js.map
|
package/response/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./DatabaseResponse.js\";\nexport * from \"./Response.js\";\nexport * from \"./ResponseContinueResult.js\";\nexport * from \"./ResponseDoneResult.js\";\nexport * from \"./ResponseAbortedResult.js\";\nexport * from \"./ResponseErrorResult.js\";\nexport * from \"./TaskResponse.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/runner/TaskControl.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ITaskEvent } from "../handler/types";
|
|
2
|
-
import { Context } from "../types";
|
|
3
|
-
import { ITaskControl, ITaskRunner } from "./abstractions";
|
|
4
|
-
import { IResponse, IResponseResult } from "../response/abstractions";
|
|
1
|
+
import type { ITaskEvent } from "../handler/types.js";
|
|
2
|
+
import type { Context } from "../types.js";
|
|
3
|
+
import type { ITaskControl, ITaskRunner } from "./abstractions/index.js";
|
|
4
|
+
import type { IResponse, IResponseResult } from "../response/abstractions/index.js";
|
|
5
5
|
export declare class TaskControl implements ITaskControl {
|
|
6
6
|
readonly runner: ITaskRunner;
|
|
7
7
|
readonly response: IResponse;
|
package/runner/TaskControl.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _TaskManagerStore = require("./TaskManagerStore");
|
|
11
|
-
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
12
|
-
var _getErrorProperties = require("../utils/getErrorProperties");
|
|
13
|
-
class TaskControl {
|
|
1
|
+
import { TaskDataStatus } from "../types.js";
|
|
2
|
+
import { TaskManager } from "./TaskManager.js";
|
|
3
|
+
import { DatabaseResponse, TaskResponse } from "../response/index.js";
|
|
4
|
+
import { TaskManagerStore } from "./TaskManagerStore.js";
|
|
5
|
+
import { getErrorProperties } from "../utils/getErrorProperties.js";
|
|
6
|
+
import { AuthenticatedIdentity } from "@webiny/api-core/features/IdentityContext";
|
|
7
|
+
import { TaskExecutionContext } from "../features/TaskExecutionContext/index.js";
|
|
8
|
+
import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
9
|
+
export class TaskControl {
|
|
14
10
|
constructor(runner, response, context) {
|
|
15
11
|
this.runner = runner;
|
|
16
12
|
this.context = context;
|
|
@@ -27,19 +23,52 @@ class TaskControl {
|
|
|
27
23
|
let task;
|
|
28
24
|
try {
|
|
29
25
|
task = await this.getTask(taskId);
|
|
30
|
-
this.context.security.setIdentity(
|
|
26
|
+
this.context.security.setIdentity(new AuthenticatedIdentity({
|
|
27
|
+
id: task.createdBy.id,
|
|
28
|
+
type: task.createdBy.type,
|
|
29
|
+
displayName: task.createdBy.displayName ?? "",
|
|
30
|
+
context: {
|
|
31
|
+
canAccessTenant: true
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
31
34
|
} catch (error) {
|
|
35
|
+
/**
|
|
36
|
+
* TODO Refactor error handling.
|
|
37
|
+
*/
|
|
38
|
+
// @ts-expect-error
|
|
32
39
|
return this.response.error({
|
|
33
|
-
error
|
|
40
|
+
...getErrorProperties(error)
|
|
34
41
|
});
|
|
35
42
|
}
|
|
36
43
|
/**
|
|
37
|
-
*
|
|
44
|
+
* Let's get the task definition.
|
|
45
|
+
*/
|
|
46
|
+
const definition = this.context.tasks.getDefinition(task.definitionId);
|
|
47
|
+
if (!definition) {
|
|
48
|
+
return this.response.error({
|
|
49
|
+
error: {
|
|
50
|
+
message: `Task "${task.id}" cannot be executed because there is no "${task.definitionId}" definition plugin.`,
|
|
51
|
+
code: "TASK_DEFINITION_ERROR",
|
|
52
|
+
data: {
|
|
53
|
+
definitionId: task.definitionId
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Only enable logs if definition explicitly allows them.
|
|
38
60
|
*/
|
|
61
|
+
const databaseLogs = definition.databaseLogs === true;
|
|
39
62
|
|
|
63
|
+
/**
|
|
64
|
+
* As this as a run of the task, we need to create a new log entry.
|
|
65
|
+
*/
|
|
40
66
|
let taskLog;
|
|
41
67
|
try {
|
|
42
|
-
taskLog = await this.getTaskLog(
|
|
68
|
+
taskLog = await this.getTaskLog({
|
|
69
|
+
task,
|
|
70
|
+
databaseLogs
|
|
71
|
+
});
|
|
43
72
|
} catch (error) {
|
|
44
73
|
return this.response.error({
|
|
45
74
|
error
|
|
@@ -49,14 +78,14 @@ class TaskControl {
|
|
|
49
78
|
* Make sure that task does not run if it is aborted.
|
|
50
79
|
* This will effectively end the Step Function execution with a "success" status.
|
|
51
80
|
*/
|
|
52
|
-
if (task.taskStatus ===
|
|
81
|
+
if (task.taskStatus === TaskDataStatus.ABORTED) {
|
|
53
82
|
return this.response.aborted();
|
|
54
83
|
}
|
|
55
84
|
/**
|
|
56
85
|
* Do not run if already a success (done).
|
|
57
86
|
*/
|
|
58
87
|
//
|
|
59
|
-
else if (task.taskStatus ===
|
|
88
|
+
else if (task.taskStatus === TaskDataStatus.SUCCESS) {
|
|
60
89
|
return this.response.error({
|
|
61
90
|
error: {
|
|
62
91
|
message: "Task is already done, cannot run it again."
|
|
@@ -67,33 +96,35 @@ class TaskControl {
|
|
|
67
96
|
* Do not run if already failed.
|
|
68
97
|
*/
|
|
69
98
|
//
|
|
70
|
-
else if (task.taskStatus ===
|
|
99
|
+
else if (task.taskStatus === TaskDataStatus.FAILED) {
|
|
71
100
|
return this.response.error({
|
|
72
101
|
error: {
|
|
73
102
|
message: "Task has failed, cannot run it again."
|
|
74
103
|
}
|
|
75
104
|
});
|
|
76
105
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
106
|
+
const store = new TaskManagerStore({
|
|
107
|
+
context: this.context,
|
|
108
|
+
task,
|
|
109
|
+
log: taskLog,
|
|
110
|
+
databaseLogs
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Populate TaskExecutionContext BEFORE executing task
|
|
114
|
+
const executionContext = this.context.container.resolve(TaskExecutionContext);
|
|
115
|
+
executionContext.setStore(store);
|
|
116
|
+
executionContext.setRunner(this.runner);
|
|
117
|
+
executionContext.setTimer(this.runner.timer);
|
|
118
|
+
executionContext.setResponse(new TaskResponse(this.response));
|
|
119
|
+
const manager = new TaskManager(this.context, this.response, store);
|
|
120
|
+
const databaseResponse = new DatabaseResponse(this.response, store);
|
|
93
121
|
try {
|
|
94
122
|
const result = await manager.run(definition);
|
|
95
|
-
await
|
|
96
|
-
|
|
123
|
+
const responseResult = await databaseResponse.from(result);
|
|
124
|
+
|
|
125
|
+
// Get the updated task from store (no database read needed - store maintains local cache)
|
|
126
|
+
await this.runEvents(result, definition, store.getTask());
|
|
127
|
+
return responseResult;
|
|
97
128
|
} catch (ex) {
|
|
98
129
|
/**
|
|
99
130
|
* We always want to store the error in the task log.
|
|
@@ -109,28 +140,29 @@ class TaskControl {
|
|
|
109
140
|
}
|
|
110
141
|
}
|
|
111
142
|
}));
|
|
143
|
+
} finally {
|
|
144
|
+
// Clear execution context after task completes
|
|
145
|
+
executionContext.clear();
|
|
112
146
|
}
|
|
113
147
|
}
|
|
114
148
|
async runEvents(result, definition, task) {
|
|
115
|
-
if (result.status ===
|
|
149
|
+
if (result.status === TaskResultStatus.ERROR && definition.onError) {
|
|
116
150
|
try {
|
|
117
151
|
await definition.onError({
|
|
118
|
-
task
|
|
119
|
-
context: this.context
|
|
152
|
+
task
|
|
120
153
|
});
|
|
121
154
|
} catch (ex) {
|
|
122
155
|
console.error(`Error executing onError hook for task "${task.id}".`);
|
|
123
|
-
console.log(
|
|
156
|
+
console.log(getErrorProperties(ex));
|
|
124
157
|
}
|
|
125
|
-
} else if (result.status ===
|
|
158
|
+
} else if (result.status === TaskResultStatus.DONE && definition.onDone) {
|
|
126
159
|
try {
|
|
127
160
|
await definition.onDone({
|
|
128
|
-
task
|
|
129
|
-
context: this.context
|
|
161
|
+
task
|
|
130
162
|
});
|
|
131
163
|
} catch (ex) {
|
|
132
164
|
console.error(`Error executing onDone hook for task "${task.id}".`);
|
|
133
|
-
console.log(
|
|
165
|
+
console.log(getErrorProperties(ex));
|
|
134
166
|
}
|
|
135
167
|
}
|
|
136
168
|
}
|
|
@@ -157,7 +189,25 @@ class TaskControl {
|
|
|
157
189
|
}
|
|
158
190
|
});
|
|
159
191
|
}
|
|
160
|
-
async getTaskLog(
|
|
192
|
+
async getTaskLog(params) {
|
|
193
|
+
const {
|
|
194
|
+
task,
|
|
195
|
+
databaseLogs
|
|
196
|
+
} = params;
|
|
197
|
+
/**
|
|
198
|
+
* If logs are disabled, let's return a mocked one.
|
|
199
|
+
*/
|
|
200
|
+
if (!databaseLogs) {
|
|
201
|
+
return {
|
|
202
|
+
id: `${task.id}-log`,
|
|
203
|
+
createdOn: task.createdOn,
|
|
204
|
+
createdBy: task.createdBy,
|
|
205
|
+
executionName: task.executionName,
|
|
206
|
+
task: task.id,
|
|
207
|
+
iteration: task.iterations,
|
|
208
|
+
items: []
|
|
209
|
+
};
|
|
210
|
+
}
|
|
161
211
|
let taskLog = null;
|
|
162
212
|
/**
|
|
163
213
|
* First we are trying to get existing latest log.
|
|
@@ -168,7 +218,7 @@ class TaskControl {
|
|
|
168
218
|
/**
|
|
169
219
|
* If error is not the NotFoundError, we need to throw it.
|
|
170
220
|
*/
|
|
171
|
-
if (error
|
|
221
|
+
if (error.code !== "NOT_FOUND") {
|
|
172
222
|
throw this.response.error({
|
|
173
223
|
error
|
|
174
224
|
});
|
|
@@ -190,6 +240,5 @@ class TaskControl {
|
|
|
190
240
|
}
|
|
191
241
|
}
|
|
192
242
|
}
|
|
193
|
-
exports.TaskControl = TaskControl;
|
|
194
243
|
|
|
195
244
|
//# sourceMappingURL=TaskControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","_TaskManager","_response","_TaskManagerStore","_handlerGraphql","_getErrorProperties","TaskControl","constructor","runner","response","context","run","event","taskId","webinyTaskId","task","getTask","security","setIdentity","createdBy","error","taskLog","getTaskLog","taskStatus","TaskDataStatus","ABORTED","aborted","SUCCESS","message","FAILED","taskResponse","TaskResponse","store","TaskManagerStore","manager","TaskManager","databaseResponse","DatabaseResponse","definition","tasks","getDefinition","definitionId","id","code","data","result","runEvents","from","ex","stack","input","status","TaskResponseStatus","ERROR","onError","console","log","getErrorProperties","DONE","onDone","getLatestLog","NotFoundError","currentIteration","iteration","createLog","executionName","exports"],"sources":["TaskControl.ts"],"sourcesContent":["import { ITaskEvent } from \"~/handler/types\";\nimport {\n Context,\n ITask,\n ITaskDataInput,\n ITaskDefinition,\n ITaskLog,\n TaskDataStatus,\n TaskResponseStatus\n} from \"~/types\";\nimport { ITaskControl, ITaskRunner } from \"./abstractions\";\nimport { TaskManager } from \"./TaskManager\";\nimport { IResponse, IResponseResult } from \"~/response/abstractions\";\nimport { DatabaseResponse, TaskResponse } from \"~/response\";\nimport { TaskManagerStore } from \"./TaskManagerStore\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { getErrorProperties } from \"~/utils/getErrorProperties\";\n\nexport class TaskControl implements ITaskControl {\n public readonly runner: ITaskRunner;\n public readonly response: IResponse;\n public readonly context: Context;\n\n public constructor(runner: ITaskRunner, response: IResponse, context: Context) {\n this.runner = runner;\n this.context = context;\n this.response = response;\n }\n\n public async run(event: Pick<ITaskEvent, \"webinyTaskId\">): Promise<IResponseResult> {\n const taskId = event.webinyTaskId;\n /**\n * This is the initial getTask idea.\n * We will need to take care of child tasks:\n * * child tasks can be in multiple levels (child task creates a child task, etc...).\n * * child tasks could be executed in parallel.\n */\n let task: ITask<ITaskDataInput>;\n try {\n task = await this.getTask(taskId);\n this.context.security.setIdentity(task.createdBy);\n } catch (error) {\n return this.response.error({\n error\n });\n }\n /**\n * As this as a run of the task, we need to create a new log entry.\n */\n\n let taskLog: ITaskLog;\n try {\n taskLog = await this.getTaskLog(task);\n } catch (error) {\n return this.response.error({\n error\n });\n }\n /**\n * Make sure that task does not run if it is aborted.\n * This will effectively end the Step Function execution with a \"success\" status.\n */\n if (task.taskStatus === TaskDataStatus.ABORTED) {\n return this.response.aborted();\n }\n /**\n * Do not run if already a success (done).\n */\n //\n else if (task.taskStatus === TaskDataStatus.SUCCESS) {\n return this.response.error({\n error: {\n message: \"Task is already done, cannot run it again.\"\n }\n });\n }\n /**\n * Do not run if already failed.\n */\n //\n else if (task.taskStatus === TaskDataStatus.FAILED) {\n return this.response.error({\n error: {\n message: \"Task has failed, cannot run it again.\"\n }\n });\n }\n const taskResponse = new TaskResponse(this.response);\n const store = new TaskManagerStore(this.context, task, taskLog);\n\n const manager = new TaskManager(\n this.runner,\n this.context,\n this.response,\n taskResponse,\n store\n );\n\n const databaseResponse = new DatabaseResponse(this.response, store);\n\n const definition = this.context.tasks.getDefinition(task.definitionId);\n if (!definition) {\n return await databaseResponse.error({\n error: {\n message: `Task \"${task.id}\" cannot be executed because there is no \"${task.definitionId}\" definition plugin.`,\n code: \"TASK_DEFINITION_ERROR\",\n data: {\n definitionId: task.definitionId\n }\n }\n });\n }\n\n try {\n const result = await manager.run(definition);\n\n await this.runEvents(result, definition, task);\n\n return await databaseResponse.from(result);\n } catch (ex) {\n /**\n * We always want to store the error in the task log.\n */\n return await databaseResponse.from(\n this.response.error({\n error: {\n message: ex.message,\n code: ex.code || \"TASK_ERROR\",\n stack: ex.stack,\n data: {\n ...ex.data,\n input: task.input\n }\n }\n })\n );\n }\n }\n\n private async runEvents(\n result: IResponseResult,\n definition: ITaskDefinition,\n task: ITask\n ): Promise<void> {\n if (result.status === TaskResponseStatus.ERROR && definition.onError) {\n try {\n await definition.onError({\n task,\n context: this.context\n });\n } catch (ex) {\n console.error(`Error executing onError hook for task \"${task.id}\".`);\n console.log(getErrorProperties(ex));\n }\n } else if (result.status === TaskResponseStatus.DONE && definition.onDone) {\n try {\n await definition.onDone({\n task,\n context: this.context\n });\n } catch (ex) {\n console.error(`Error executing onDone hook for task \"${task.id}\".`);\n console.log(getErrorProperties(ex));\n }\n }\n }\n\n private async getTask<T = any>(id: string): Promise<ITask<T>> {\n try {\n const task = await this.runner.context.tasks.getTask<T>(id);\n if (task) {\n return task;\n }\n } catch (ex) {\n throw this.response.error({\n error: {\n message: ex.message,\n code: ex.code || \"TASK_ERROR\",\n stack: ex.stack,\n data: ex.data\n }\n });\n }\n throw this.response.error({\n error: {\n message: `Task \"${id}\" cannot be executed because it does not exist.`,\n code: \"TASK_NOT_FOUND\"\n }\n });\n }\n\n private async getTaskLog(task: ITask): Promise<ITaskLog> {\n let taskLog: ITaskLog | null = null;\n /**\n * First we are trying to get existing latest log.\n */\n try {\n taskLog = await this.context.tasks.getLatestLog(task.id);\n } catch (error) {\n /**\n * If error is not the NotFoundError, we need to throw it.\n */\n if (error instanceof NotFoundError === false) {\n throw this.response.error({\n error\n });\n }\n /**\n * Otherwise just continue and create a new log.\n */\n }\n\n const currentIteration = taskLog?.iteration || 0;\n\n try {\n return await this.context.tasks.createLog(task, {\n executionName: this.response.event.executionName,\n iteration: currentIteration + 1\n });\n } catch (error) {\n thro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,YAAYyC,6BAAa,KAAK,KAAK,EAAE;QAC1C,MAAM,IAAI,CAACpD,QAAQ,CAACW,KAAK,CAAC;UACtBA;QACJ,CAAC,CAAC;MACN;MACA;AACZ;AACA;IACQ;IAEA,MAAM0C,gBAAgB,GAAGzC,OAAO,EAAE0C,SAAS,IAAI,CAAC;IAEhD,IAAI;MACA,OAAO,MAAM,IAAI,CAACrD,OAAO,CAAC6B,KAAK,CAACyB,SAAS,CAACjD,IAAI,EAAE;QAC5CkD,aAAa,EAAE,IAAI,CAACxD,QAAQ,CAACG,KAAK,CAACqD,aAAa;QAChDF,SAAS,EAAED,gBAAgB,GAAG;MAClC,CAAC,CAAC;IACN,CAAC,CAAC,OAAO1C,KAAK,EAAE;MACZ,MAAM,IAAI,CAACX,QAAQ,CAACW,KAAK,CAAC;QACtBA;MACJ,CAAC,CAAC;IACN;EACJ;AACJ;AAAC8C,OAAA,CAAA5D,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["TaskDataStatus","TaskManager","DatabaseResponse","TaskResponse","TaskManagerStore","getErrorProperties","AuthenticatedIdentity","TaskExecutionContext","TaskResultStatus","TaskControl","constructor","runner","response","context","run","event","taskId","webinyTaskId","task","getTask","security","setIdentity","id","createdBy","type","displayName","canAccessTenant","error","definition","tasks","getDefinition","definitionId","message","code","data","databaseLogs","taskLog","getTaskLog","taskStatus","ABORTED","aborted","SUCCESS","FAILED","store","log","executionContext","container","resolve","setStore","setRunner","setTimer","timer","setResponse","manager","databaseResponse","result","responseResult","from","runEvents","ex","stack","input","clear","status","ERROR","onError","console","DONE","onDone","params","createdOn","executionName","iteration","iterations","items","getLatestLog","currentIteration","createLog"],"sources":["TaskControl.ts"],"sourcesContent":["import type { ITaskEvent } from \"~/handler/types.js\";\nimport type { Context, ITask, ITaskDataInput, ITaskLog } from \"~/types.js\";\nimport { TaskDataStatus } from \"~/types.js\";\nimport type { ITaskControl, ITaskRunner } from \"./abstractions/index.js\";\nimport { TaskManager } from \"./TaskManager.js\";\nimport type { IResponse, IResponseResult } from \"~/response/abstractions/index.js\";\nimport { DatabaseResponse, TaskResponse } from \"~/response/index.js\";\nimport { TaskManagerStore } from \"./TaskManagerStore.js\";\nimport { getErrorProperties } from \"~/utils/getErrorProperties.js\";\nimport { AuthenticatedIdentity } from \"@webiny/api-core/features/IdentityContext\";\nimport { TaskExecutionContext } from \"~/features/TaskExecutionContext/index.js\";\nimport {\n TaskDefinition,\n TaskResultStatus\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\ninterface IGetTaskLogParams {\n task: ITask;\n databaseLogs: boolean;\n}\n\nexport class TaskControl implements ITaskControl {\n public readonly runner: ITaskRunner;\n public readonly response: IResponse;\n public readonly context: Context;\n\n public constructor(runner: ITaskRunner, response: IResponse, context: Context) {\n this.runner = runner;\n this.context = context;\n this.response = response;\n }\n\n public async run(event: Pick<ITaskEvent, \"webinyTaskId\">): Promise<IResponseResult> {\n const taskId = event.webinyTaskId;\n /**\n * This is the initial getTask idea.\n * We will need to take care of child tasks:\n * * child tasks can be in multiple levels (child task creates a child task, etc...).\n * * child tasks could be executed in parallel.\n */\n let task: ITask<ITaskDataInput>;\n try {\n task = await this.getTask(taskId);\n this.context.security.setIdentity(\n new AuthenticatedIdentity({\n id: task.createdBy.id,\n type: task.createdBy.type,\n displayName: task.createdBy.displayName ?? \"\",\n context: {\n canAccessTenant: true\n }\n })\n );\n } catch (error) {\n /**\n * TODO Refactor error handling.\n */\n // @ts-expect-error\n return this.response.error({\n ...getErrorProperties(error)\n });\n }\n /**\n * Let's get the task definition.\n */\n const definition = this.context.tasks.getDefinition(task.definitionId);\n if (!definition) {\n return this.response.error({\n error: {\n message: `Task \"${task.id}\" cannot be executed because there is no \"${task.definitionId}\" definition plugin.`,\n code: \"TASK_DEFINITION_ERROR\",\n data: {\n definitionId: task.definitionId\n }\n }\n });\n }\n /**\n * Only enable logs if definition explicitly allows them.\n */\n const databaseLogs = definition.databaseLogs === true;\n\n /**\n * As this as a run of the task, we need to create a new log entry.\n */\n let taskLog: ITaskLog;\n try {\n taskLog = await this.getTaskLog({\n task,\n databaseLogs\n });\n } catch (error) {\n return this.response.error({\n error\n });\n }\n /**\n * Make sure that task does not run if it is aborted.\n * This will effectively end the Step Function execution with a \"success\" status.\n */\n if (task.taskStatus === TaskDataStatus.ABORTED) {\n return this.response.aborted();\n }\n /**\n * Do not run if already a success (done).\n */\n //\n else if (task.taskStatus === TaskDataStatus.SUCCESS) {\n return this.response.error({\n error: {\n message: \"Task is already done, cannot run it again.\"\n }\n });\n }\n /**\n * Do not run if already failed.\n */\n //\n else if (task.taskStatus === TaskDataStatus.FAILED) {\n return this.response.error({\n error: {\n message: \"Task has failed, cannot run it again.\"\n }\n });\n }\n\n const store = new TaskManagerStore({\n context: this.context,\n task,\n log: taskLog,\n databaseLogs\n });\n\n // Populate TaskExecutionContext BEFORE executing task\n const executionContext = this.context.container.resolve(TaskExecutionContext);\n executionContext.setStore(store);\n executionContext.setRunner(this.runner);\n executionContext.setTimer(this.runner.timer);\n executionContext.setResponse(new TaskResponse(this.response));\n\n const manager = new TaskManager(this.context, this.response, store);\n\n const databaseResponse = new DatabaseResponse(this.response, store);\n\n try {\n const result = await manager.run(definition);\n\n const responseResult = await databaseResponse.from(result);\n\n // Get the updated task from store (no database read needed - store maintains local cache)\n await this.runEvents(result, definition, store.getTask());\n\n return responseResult;\n } catch (ex) {\n /**\n * We always want to store the error in the task log.\n */\n return await databaseResponse.from(\n this.response.error({\n error: {\n message: ex.message,\n code: ex.code || \"TASK_ERROR\",\n stack: ex.stack,\n data: {\n ...ex.data,\n input: task.input\n }\n }\n })\n );\n } finally {\n // Clear execution context after task completes\n executionContext.clear();\n }\n }\n\n private async runEvents(\n result: IResponseResult,\n definition: TaskDefinition.Runnable,\n task: ITask\n ): Promise<void> {\n if (result.status === TaskResultStatus.ERROR && definition.onError) {\n try {\n await definition.onError({\n task\n });\n } catch (ex) {\n console.error(`Error executing onError hook for task \"${task.id}\".`);\n console.log(getErrorProperties(ex));\n }\n } else if (result.status === TaskResultStatus.DONE && definition.onDone) {\n try {\n await definition.onDone({\n task\n });\n } catch (ex) {\n console.error(`Error executing onDone hook for task \"${task.id}\".`);\n console.log(getErrorProperties(ex));\n }\n }\n }\n\n private async getTask<T extends TaskDefinition.TaskInput>(id: string): Promise<ITask<T>> {\n try {\n const task = await this.runner.context.tasks.getTask<T>(id);\n if (task) {\n return task;\n }\n } catch (ex) {\n throw this.response.error({\n error: {\n message: ex.message,\n code: ex.code || \"TASK_ERROR\",\n stack: ex.stack,\n data: ex.data\n }\n });\n }\n throw this.response.error({\n error: {\n message: `Task \"${id}\" cannot be executed because it does not exist.`,\n code: \"TASK_NOT_FOUND\"\n }\n });\n }\n\n private async getTaskLog(params: IGetTaskLogParams): Promise<ITaskLog> {\n const { task, databaseLogs } = params;\n /**\n * If logs are disabled, let's return a mocked one.\n */\n if (!databaseLogs) {\n return {\n id: `${task.id}-log`,\n createdOn: task.createdOn,\n createdBy: task.createdBy,\n executionName: task.executionName,\n task: task.id,\n iteration: task.iterations,\n items: []\n };\n }\n let taskLog: ITaskLog | null = null;\n /**\n * First we are trying to get existing latest log.\n */\n try {\n taskLog = await this.context.tasks.getLatestLog(task.id);\n } catch (error) {\n /**\n * If error is not the NotFoundError, we need to throw it.\n */\n if (error.code !== \"NOT_FOUND\") {\n throw this.response.error({\n error\n });\n }\n /**\n * Otherwise just continue and create a new log.\n */\n }\n\n const currentIteration = taskLog?.iteration || 0;\n\n try {\n return await this.context.tasks.createLog(task, {\n executionName: this.response.event.executionName,\n iteration: currentIteration + 1\n });\n } catch (error) {\n throw this.response.error({\n error\n });\n }\n }\n}\n"],"mappings":"AAEA,SAASA,cAAc;AAEvB,SAASC,WAAW;AAEpB,SAASC,gBAAgB,EAAEC,YAAY;AACvC,SAASC,gBAAgB;AACzB,SAASC,kBAAkB;AAC3B,SAASC,qBAAqB,QAAQ,2CAA2C;AACjF,SAASC,oBAAoB;AAC7B,SA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CAACgD,SAAS,CAAC3D,IAAI,EAAE;QAC5CqD,aAAa,EAAE,IAAI,CAAC3D,QAAQ,CAACG,KAAK,CAACwD,aAAa;QAChDC,SAAS,EAAEI,gBAAgB,GAAG;MAClC,CAAC,CAAC;IACN,CAAC,CAAC,OAAOjD,KAAK,EAAE;MACZ,MAAM,IAAI,CAACf,QAAQ,CAACe,KAAK,CAAC;QACtBA;MACJ,CAAC,CAAC;IACN;EACJ;AACJ","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ITaskEventValidation, ITaskEventValidationResult } from "./abstractions";
|
|
2
|
-
import { ITaskEvent } from "../handler/types";
|
|
1
|
+
import type { ITaskEventValidation, ITaskEventValidationResult } from "./abstractions/index.js";
|
|
2
|
+
import type { ITaskEvent } from "../handler/types.js";
|
|
3
3
|
export declare class TaskEventValidation implements ITaskEventValidation {
|
|
4
4
|
validate(event: Partial<ITaskEvent>): ITaskEventValidationResult;
|
|
5
5
|
}
|