@webiny/tasks 6.0.0-beta.0 → 6.0.0-rc.1
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,7 +1,7 @@
|
|
|
1
|
-
import { ITaskRunner } from "
|
|
2
|
-
import { IResponse, IResponseResult } from "../../response/abstractions";
|
|
3
|
-
import { Context } from "../../types";
|
|
4
|
-
import { ITaskEvent } from "../../handler/types";
|
|
1
|
+
import type { ITaskRunner } from "../../runner/abstractions/index.js";
|
|
2
|
+
import type { IResponse, IResponseResult } from "../../response/abstractions/index.js";
|
|
3
|
+
import type { Context } from "../../types.js";
|
|
4
|
+
import type { ITaskEvent } from "../../handler/types.js";
|
|
5
5
|
export interface ITaskControl {
|
|
6
6
|
runner: ITaskRunner;
|
|
7
7
|
response: IResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["TaskControl.ts"],"sourcesContent":["import { ITaskRunner } from \"~/runner/abstractions\";\nimport { IResponse, IResponseResult } from \"~/response/abstractions\";\nimport { Context } from \"~/types\";\nimport { ITaskEvent } from \"~/handler/types\";\n\nexport interface ITaskControl {\n runner: ITaskRunner;\n response: IResponse;\n context: Context;\n\n run(event: ITaskEvent): Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["TaskControl.ts"],"sourcesContent":["import type { ITaskRunner } from \"~/runner/abstractions/index.js\";\nimport type { IResponse, IResponseResult } from \"~/response/abstractions/index.js\";\nimport type { Context } from \"~/types.js\";\nimport type { ITaskEvent } from \"~/handler/types.js\";\n\nexport interface ITaskControl {\n runner: ITaskRunner;\n response: IResponse;\n context: Context;\n\n run(event: ITaskEvent): Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ITaskEvent } from "../../handler/types";
|
|
2
|
-
export
|
|
1
|
+
import type { ITaskEvent } from "../../handler/types.js";
|
|
2
|
+
export type ITaskEventValidationResult = ITaskEvent;
|
|
3
3
|
export interface ITaskEventValidation {
|
|
4
4
|
validate: (event: Partial<ITaskEvent>) => ITaskEventValidationResult;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["TaskEventValidation.ts"],"sourcesContent":["import { ITaskEvent } from \"~/handler/types\";\n\nexport type ITaskEventValidationResult = ITaskEvent;\n\nexport interface ITaskEventValidation {\n validate: (event: Partial<ITaskEvent>) => ITaskEventValidationResult;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["TaskEventValidation.ts"],"sourcesContent":["import type { ITaskEvent } from \"~/handler/types.js\";\n\nexport type ITaskEventValidationResult = ITaskEvent;\n\nexport interface ITaskEventValidation {\n validate: (event: Partial<ITaskEvent>) => ITaskEventValidationResult;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IResponseResult } from "../../response/abstractions";
|
|
2
|
-
import {
|
|
3
|
-
export interface ITaskManager
|
|
4
|
-
run: (definition:
|
|
1
|
+
import type { IResponseResult } from "../../response/abstractions/index.js";
|
|
2
|
+
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
3
|
+
export interface ITaskManager {
|
|
4
|
+
run: (definition: TaskDefinition.Runnable) => Promise<IResponseResult>;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["TaskManager.ts"],"sourcesContent":["import { IResponseResult } from \"~/response/abstractions\";\nimport {
|
|
1
|
+
{"version":3,"names":[],"sources":["TaskManager.ts"],"sourcesContent":["import type { IResponseResult } from \"~/response/abstractions/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface ITaskManager {\n run: (definition: TaskDefinition.Runnable) => Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { IResponseError, ITask,
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import type { IResponseError, ITask, ITaskLogItemData, ITaskUpdateData, TaskDataStatus } from "../../types.js";
|
|
2
|
+
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
3
|
+
export type ITaskManagerStoreUpdateTaskValues<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> = T;
|
|
4
|
+
export interface ITaskManagerStoreUpdateTaskValuesCb<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {
|
|
4
5
|
(input: T): T;
|
|
5
6
|
}
|
|
6
7
|
export interface ITaskManagerStoreUpdateTaskInputOptions {
|
|
7
8
|
save: boolean;
|
|
8
9
|
}
|
|
9
|
-
export
|
|
10
|
-
export interface ITaskManagerStoreUpdateTaskParamCb<T extends
|
|
10
|
+
export type ITaskManagerStoreUpdateTaskInputParam<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> = ITaskManagerStoreUpdateTaskValuesCb<T> | Partial<ITaskManagerStoreUpdateTaskValues<T>>;
|
|
11
|
+
export interface ITaskManagerStoreUpdateTaskParamCb<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> {
|
|
11
12
|
(task: ITask<T, O>): ITaskUpdateData<T, O>;
|
|
12
13
|
}
|
|
13
|
-
export
|
|
14
|
-
export
|
|
14
|
+
export type ITaskManagerStoreUpdateTask<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> = ITaskUpdateData<T, O>;
|
|
15
|
+
export type ITaskManagerStoreUpdateTaskParams<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> = ITaskManagerStoreUpdateTaskParamCb<T, O> | Partial<ITaskManagerStoreUpdateTask<T, O>>;
|
|
15
16
|
export interface ITaskManagerStoreInfoLog {
|
|
16
17
|
message: string;
|
|
17
18
|
data?: ITaskLogItemData;
|
|
@@ -42,13 +43,18 @@ export interface ITaskManagerStoreAddLogOptions {
|
|
|
42
43
|
/**
|
|
43
44
|
* Interface should not be used outside the @webiny/tasks package.
|
|
44
45
|
*/
|
|
45
|
-
export interface ITaskManagerStorePrivate<T extends
|
|
46
|
+
export interface ITaskManagerStorePrivate<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> {
|
|
46
47
|
getTask: () => ITask<T, O>;
|
|
47
48
|
getStatus: () => TaskDataStatus;
|
|
48
49
|
/**
|
|
49
50
|
* @throws {Error} If task not found or something goes wrong during the database update.
|
|
50
51
|
*/
|
|
51
52
|
updateTask(params: ITaskManagerStoreUpdateTaskParams<T, O>, options?: ITaskManagerStoreUpdateTaskOptions): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* List all child tasks of the current task.
|
|
55
|
+
* If definitionId is provided, filter by that parameter.
|
|
56
|
+
*/
|
|
57
|
+
listChildTasks<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput>(definitionId?: string): Promise<ITask<T, O>[]>;
|
|
52
58
|
/**
|
|
53
59
|
* Update the task input, which are used to store custom user data.
|
|
54
60
|
* You can send partial input, and it will be merged with the existing input.
|
|
@@ -83,4 +89,4 @@ export interface ITaskManagerStorePrivate<T extends ITaskDataInput = ITaskDataIn
|
|
|
83
89
|
*/
|
|
84
90
|
save(): Promise<void>;
|
|
85
91
|
}
|
|
86
|
-
export
|
|
92
|
+
export type ITaskManagerStore<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> = Omit<ITaskManagerStorePrivate<T, O>, "save">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["TaskManagerStore.ts"],"sourcesContent":["import {\n IResponseError,\n ITask,\n
|
|
1
|
+
{"version":3,"names":[],"sources":["TaskManagerStore.ts"],"sourcesContent":["import type {\n IResponseError,\n ITask,\n ITaskLogItemData,\n ITaskUpdateData,\n TaskDataStatus\n} from \"~/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport type ITaskManagerStoreUpdateTaskValues<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput\n> = T;\n\nexport interface ITaskManagerStoreUpdateTaskValuesCb<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput\n> {\n (input: T): T;\n}\n\nexport interface ITaskManagerStoreUpdateTaskInputOptions {\n save: boolean;\n}\n\nexport type ITaskManagerStoreUpdateTaskInputParam<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput\n> = ITaskManagerStoreUpdateTaskValuesCb<T> | Partial<ITaskManagerStoreUpdateTaskValues<T>>;\n\nexport interface ITaskManagerStoreUpdateTaskParamCb<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> {\n (task: ITask<T, O>): ITaskUpdateData<T, O>;\n}\n\nexport type ITaskManagerStoreUpdateTask<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> = ITaskUpdateData<T, O>;\n\nexport type ITaskManagerStoreUpdateTaskParams<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\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 TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\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 * List all child tasks of the current task.\n * If definitionId is provided, filter by that parameter.\n */\n listChildTasks<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n >(\n definitionId?: string\n ): Promise<ITask<T, O>[]>;\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 TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> = Omit<ITaskManagerStorePrivate<T, O>, \"save\">;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { Context } from "../../types";
|
|
2
|
-
import { ITaskEvent } from "../../handler/types";
|
|
3
|
-
import { IResponseResult } from "../../response/abstractions";
|
|
1
|
+
import type { Context } from "../../types.js";
|
|
2
|
+
import type { ITaskEvent } from "../../handler/types.js";
|
|
3
|
+
import type { IResponseResult } from "../../response/abstractions/index.js";
|
|
4
|
+
import type { ITimer } from "@webiny/handler-aws";
|
|
5
|
+
export interface IIsCloseToTimeoutCallable {
|
|
6
|
+
(seconds?: number): boolean;
|
|
7
|
+
}
|
|
4
8
|
export interface ITaskRunner<C extends Context = Context> {
|
|
5
9
|
context: C;
|
|
6
|
-
isCloseToTimeout
|
|
10
|
+
isCloseToTimeout: IIsCloseToTimeoutCallable;
|
|
11
|
+
timer: ITimer;
|
|
7
12
|
run(event: ITaskEvent): Promise<IResponseResult>;
|
|
8
13
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
{"version":3,"names":[],"sources":["TaskRunner.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport type { ITaskEvent } from \"~/handler/types.js\";\nimport type { IResponseResult } from \"~/response/abstractions/index.js\";\nimport type { ITimer } from \"@webiny/handler-aws\";\n\nexport interface IIsCloseToTimeoutCallable {\n (seconds?: number): boolean;\n}\n\nexport interface ITaskRunner<C extends Context = Context> {\n context: C;\n isCloseToTimeout: IIsCloseToTimeoutCallable;\n timer: ITimer;\n run(event: ITaskEvent): Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./TaskControl";
|
|
2
|
-
export * from "./TaskEventValidation";
|
|
3
|
-
export * from "./TaskManager";
|
|
4
|
-
export * from "./TaskRunner";
|
|
5
|
-
export * from "./TaskManagerStore";
|
|
1
|
+
export * from "./TaskControl.js";
|
|
2
|
+
export * from "./TaskEventValidation.js";
|
|
3
|
+
export * from "./TaskManager.js";
|
|
4
|
+
export * from "./TaskRunner.js";
|
|
5
|
+
export * from "./TaskManagerStore.js";
|
|
@@ -1,62 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _TaskControl = require("./TaskControl");
|
|
7
|
-
Object.keys(_TaskControl).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _TaskControl[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _TaskControl[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _TaskEventValidation = require("./TaskEventValidation");
|
|
18
|
-
Object.keys(_TaskEventValidation).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _TaskEventValidation[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _TaskEventValidation[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _TaskManager = require("./TaskManager");
|
|
29
|
-
Object.keys(_TaskManager).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _TaskManager[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _TaskManager[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _TaskRunner = require("./TaskRunner");
|
|
40
|
-
Object.keys(_TaskRunner).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _TaskRunner[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _TaskRunner[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _TaskManagerStore = require("./TaskManagerStore");
|
|
51
|
-
Object.keys(_TaskManagerStore).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _TaskManagerStore[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _TaskManagerStore[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
1
|
+
export * from "./TaskControl.js";
|
|
2
|
+
export * from "./TaskEventValidation.js";
|
|
3
|
+
export * from "./TaskManager.js";
|
|
4
|
+
export * from "./TaskRunner.js";
|
|
5
|
+
export * from "./TaskManagerStore.js";
|
|
61
6
|
|
|
62
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./TaskControl.js\";\nexport * from \"./TaskEventValidation.js\";\nexport * from \"./TaskManager.js\";\nexport * from \"./TaskRunner.js\";\nexport * from \"./TaskManagerStore.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/runner/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./TaskRunner";
|
|
1
|
+
export * from "./TaskRunner.js";
|
package/runner/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _TaskRunner = require("./TaskRunner");
|
|
7
|
-
Object.keys(_TaskRunner).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _TaskRunner[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _TaskRunner[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
export * from "./TaskRunner.js";
|
|
17
2
|
|
|
18
3
|
//# sourceMappingURL=index.js.map
|
package/runner/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./TaskRunner.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ITaskService, ITaskServiceCreatePluginParams, ITaskServiceTask } from "../plugins/index.js";
|
|
2
|
+
import { TaskServicePlugin } from "../plugins/index.js";
|
|
3
|
+
import type { PutEventsCommandOutput } from "@webiny/aws-sdk/client-eventbridge/index.js";
|
|
4
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
5
|
+
declare class EventBridgeService implements ITaskService {
|
|
6
|
+
protected readonly getTenant: () => string;
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(params: ITaskServiceCreatePluginParams);
|
|
9
|
+
send(task: ITaskServiceTask, delay: number): Promise<PutEventsCommandOutput>;
|
|
10
|
+
fetch(): Promise<GenericRecord>;
|
|
11
|
+
}
|
|
12
|
+
export declare class EventBridgeEventTransportPlugin extends TaskServicePlugin {
|
|
13
|
+
name: string;
|
|
14
|
+
createService(params: ITaskServiceCreatePluginParams): EventBridgeService;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TaskServicePlugin } from "../plugins/index.js";
|
|
2
|
+
import { EventBridgeClient, PutEventsCommand } from "@webiny/aws-sdk/client-eventbridge/index.js";
|
|
3
|
+
import { WebinyError } from "@webiny/error";
|
|
4
|
+
class EventBridgeService {
|
|
5
|
+
constructor(params) {
|
|
6
|
+
this.client = new EventBridgeClient({
|
|
7
|
+
region: process.env.AWS_REGION
|
|
8
|
+
});
|
|
9
|
+
this.getTenant = params.getTenant;
|
|
10
|
+
}
|
|
11
|
+
async send(task, delay) {
|
|
12
|
+
/**
|
|
13
|
+
* The ITaskEvent is what our handler expect to get.
|
|
14
|
+
* Endpoint and stateMachineId are added by the step function.
|
|
15
|
+
*/
|
|
16
|
+
const event = {
|
|
17
|
+
webinyTaskId: task.id,
|
|
18
|
+
webinyTaskDefinitionId: task.definitionId,
|
|
19
|
+
tenant: this.getTenant(),
|
|
20
|
+
delay
|
|
21
|
+
};
|
|
22
|
+
const cmd = new PutEventsCommand({
|
|
23
|
+
Entries: [{
|
|
24
|
+
Source: "webiny-api-tasks",
|
|
25
|
+
EventBusName: String(process.env.EVENT_BUS),
|
|
26
|
+
DetailType: "WebinyBackgroundTask",
|
|
27
|
+
Detail: JSON.stringify(event)
|
|
28
|
+
}]
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
const result = await this.client.send(cmd);
|
|
32
|
+
return JSON.parse(JSON.stringify(result));
|
|
33
|
+
} catch (ex) {
|
|
34
|
+
throw new WebinyError(ex.message || "Could not trigger task via Event Bridge!", ex.code || "TRIGGER_TASK_ERROR", {
|
|
35
|
+
event,
|
|
36
|
+
...(ex.data || {})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async fetch() {
|
|
41
|
+
throw new WebinyError("Not implemented!", "NOT_IMPLEMENTED");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class EventBridgeEventTransportPlugin extends TaskServicePlugin {
|
|
45
|
+
name = "task.eventBridgeEventTransport";
|
|
46
|
+
createService(params) {
|
|
47
|
+
return new EventBridgeService(params);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=EventBridgeEventTransportPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TaskServicePlugin","EventBridgeClient","PutEventsCommand","WebinyError","EventBridgeService","constructor","params","client","region","process","env","AWS_REGION","getTenant","send","task","delay","event","webinyTaskId","id","webinyTaskDefinitionId","definitionId","tenant","cmd","Entries","Source","EventBusName","String","EVENT_BUS","DetailType","Detail","JSON","stringify","result","parse","ex","message","code","data","fetch","EventBridgeEventTransportPlugin","name","createService"],"sources":["EventBridgeEventTransportPlugin.ts"],"sourcesContent":["import type {\n ITaskService,\n ITaskServiceCreatePluginParams,\n ITaskServiceTask\n} from \"~/plugins/index.js\";\nimport { TaskServicePlugin } from \"~/plugins/index.js\";\nimport type { ITaskEventInput } from \"~/types.js\";\nimport type { PutEventsCommandOutput } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport { EventBridgeClient, PutEventsCommand } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nclass EventBridgeService implements ITaskService {\n protected readonly getTenant: () => string;\n private readonly client: EventBridgeClient;\n\n public constructor(params: ITaskServiceCreatePluginParams) {\n this.client = new EventBridgeClient({\n region: process.env.AWS_REGION\n });\n this.getTenant = params.getTenant;\n }\n\n public async send(task: ITaskServiceTask, delay: number): Promise<PutEventsCommandOutput> {\n /**\n * The ITaskEvent is what our handler expect to get.\n * Endpoint and stateMachineId are added by the step function.\n */\n const event: ITaskEventInput = {\n webinyTaskId: task.id,\n webinyTaskDefinitionId: task.definitionId,\n tenant: this.getTenant(),\n delay\n };\n\n const cmd = new PutEventsCommand({\n Entries: [\n {\n Source: \"webiny-api-tasks\",\n EventBusName: String(process.env.EVENT_BUS),\n DetailType: \"WebinyBackgroundTask\",\n Detail: JSON.stringify(event)\n }\n ]\n });\n try {\n const result = await this.client.send(cmd);\n\n return JSON.parse(JSON.stringify(result));\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not trigger task via Event Bridge!\",\n ex.code || \"TRIGGER_TASK_ERROR\",\n {\n event,\n ...(ex.data || {})\n }\n );\n }\n }\n\n public async fetch(): Promise<GenericRecord> {\n throw new WebinyError(\"Not implemented!\", \"NOT_IMPLEMENTED\");\n }\n}\n\nexport class EventBridgeEventTransportPlugin extends TaskServicePlugin {\n public override name = \"task.eventBridgeEventTransport\";\n public createService(params: ITaskServiceCreatePluginParams) {\n return new EventBridgeService(params);\n }\n}\n"],"mappings":"AAKA,SAASA,iBAAiB;AAG1B,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,6CAA6C;AACjG,SAASC,WAAW,QAAQ,eAAe;AAG3C,MAAMC,kBAAkB,CAAyB;EAItCC,WAAWA,CAACC,MAAsC,EAAE;IACvD,IAAI,CAACC,MAAM,GAAG,IAAIN,iBAAiB,CAAC;MAChCO,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC;IACxB,CAAC,CAAC;IACF,IAAI,CAACC,SAAS,GAAGN,MAAM,CAACM,SAAS;EACrC;EAEA,MAAaC,IAAIA,CAACC,IAAsB,EAAEC,KAAa,EAAmC;IACtF;AACR;AACA;AACA;IACQ,MAAMC,KAAsB,GAAG;MAC3BC,YAAY,EAAEH,IAAI,CAACI,EAAE;MACrBC,sBAAsB,EAAEL,IAAI,CAACM,YAAY;MACzCC,MAAM,EAAE,IAAI,CAACT,SAAS,CAAC,CAAC;MACxBG;IACJ,CAAC;IAED,MAAMO,GAAG,GAAG,IAAIpB,gBAAgB,CAAC;MAC7BqB,OAAO,EAAE,CACL;QACIC,MAAM,EAAE,kBAAkB;QAC1BC,YAAY,EAAEC,MAAM,CAACjB,OAAO,CAACC,GAAG,CAACiB,SAAS,CAAC;QAC3CC,UAAU,EAAE,sBAAsB;QAClCC,MAAM,EAAEC,IAAI,CAACC,SAAS,CAACf,KAAK;MAChC,CAAC;IAET,CAAC,CAAC;IACF,IAAI;MACA,MAAMgB,MAAM,GAAG,MAAM,IAAI,CAACzB,MAAM,CAACM,IAAI,CAACS,GAAG,CAAC;MAE1C,OAAOQ,IAAI,CAACG,KAAK,CAACH,IAAI,CAACC,SAAS,CAACC,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC,OAAOE,EAAE,EAAE;MACT,MAAM,IAAI/B,WAAW,CACjB+B,EAAE,CAACC,OAAO,IAAI,0CAA0C,EACxDD,EAAE,CAACE,IAAI,IAAI,oBAAoB,EAC/B;QACIpB,KAAK;QACL,IAAIkB,EAAE,CAACG,IAAI,IAAI,CAAC,CAAC;MACrB,CACJ,CAAC;IACL;EACJ;EAEA,MAAaC,KAAKA,CAAA,EAA2B;IACzC,MAAM,IAAInC,WAAW,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;EAChE;AACJ;AAEA,OAAO,MAAMoC,+BAA+B,SAASvC,iBAAiB,CAAC;EACnDwC,IAAI,GAAG,gCAAgC;EAChDC,aAAaA,CAACnC,MAAsC,EAAE;IACzD,OAAO,IAAIF,kBAAkB,CAACE,MAAM,CAAC;EACzC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ITaskService, ITaskServiceCreatePluginParams, ITaskServiceTask } from "../plugins/index.js";
|
|
2
|
+
import { TaskServicePlugin } from "../plugins/index.js";
|
|
3
|
+
import type { DescribeExecutionCommandOutput } from "@webiny/aws-sdk/client-sfn/index.js";
|
|
4
|
+
import type { ITask } from "../types.js";
|
|
5
|
+
export type IStepFunctionServiceFetchResult = DescribeExecutionCommandOutput;
|
|
6
|
+
export interface IDetailWrapper<T> {
|
|
7
|
+
detail: T;
|
|
8
|
+
}
|
|
9
|
+
export declare class StepFunctionService implements ITaskService {
|
|
10
|
+
private readonly getTenant;
|
|
11
|
+
private readonly trigger;
|
|
12
|
+
private readonly get;
|
|
13
|
+
constructor(params: ITaskServiceCreatePluginParams);
|
|
14
|
+
send(task: ITaskServiceTask, delay: number): Promise<{
|
|
15
|
+
name: string;
|
|
16
|
+
executionArn: string | undefined;
|
|
17
|
+
startDate: Date | undefined;
|
|
18
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
19
|
+
} | null>;
|
|
20
|
+
fetch(task: ITask): Promise<IStepFunctionServiceFetchResult | null>;
|
|
21
|
+
}
|
|
22
|
+
export declare class StepFunctionServicePlugin extends TaskServicePlugin {
|
|
23
|
+
name: string;
|
|
24
|
+
createService(params: ITaskServiceCreatePluginParams): StepFunctionService;
|
|
25
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { TaskServicePlugin } from "../plugins/index.js";
|
|
2
|
+
import { createStepFunctionClient, describeExecutionFactory, triggerStepFunctionFactory } from "@webiny/aws-sdk/client-sfn/index.js";
|
|
3
|
+
import { generateAlphaNumericId } from "@webiny/utils";
|
|
4
|
+
import { ServiceDiscovery } from "@webiny/api";
|
|
5
|
+
export class StepFunctionService {
|
|
6
|
+
constructor(params) {
|
|
7
|
+
this.getTenant = params.getTenant;
|
|
8
|
+
const client = createStepFunctionClient();
|
|
9
|
+
this.trigger = triggerStepFunctionFactory(client);
|
|
10
|
+
this.get = describeExecutionFactory(client);
|
|
11
|
+
}
|
|
12
|
+
async send(task, delay) {
|
|
13
|
+
const manifest = await ServiceDiscovery.load();
|
|
14
|
+
if (!manifest) {
|
|
15
|
+
console.error("Service manifest not found.");
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
bgTaskSfn
|
|
20
|
+
} = manifest.api || {};
|
|
21
|
+
if (!bgTaskSfn) {
|
|
22
|
+
console.error("Background task state machine not found.");
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const input = {
|
|
26
|
+
webinyTaskId: task.id,
|
|
27
|
+
webinyTaskDefinitionId: task.definitionId,
|
|
28
|
+
tenant: this.getTenant(),
|
|
29
|
+
delay
|
|
30
|
+
};
|
|
31
|
+
const name = `${task.definitionId}_${task.id}_${generateAlphaNumericId(10)}`;
|
|
32
|
+
try {
|
|
33
|
+
const result = await this.trigger({
|
|
34
|
+
input: {
|
|
35
|
+
detail: input
|
|
36
|
+
},
|
|
37
|
+
stateMachineArn: bgTaskSfn,
|
|
38
|
+
name
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
...result,
|
|
42
|
+
name
|
|
43
|
+
};
|
|
44
|
+
} catch (ex) {
|
|
45
|
+
console.log("Could not trigger a step function.");
|
|
46
|
+
console.error(ex);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async fetch(task) {
|
|
51
|
+
const executionArn = task.eventResponse?.executionArn;
|
|
52
|
+
if (!executionArn) {
|
|
53
|
+
console.error(`Execution ARN not found in task "${task.id}".`);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const result = await this.get({
|
|
58
|
+
executionArn
|
|
59
|
+
});
|
|
60
|
+
if (!result) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return JSON.parse(JSON.stringify(result));
|
|
64
|
+
} catch (ex) {
|
|
65
|
+
console.log("Could not get the execution details.");
|
|
66
|
+
console.error(ex);
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export class StepFunctionServicePlugin extends TaskServicePlugin {
|
|
72
|
+
name = "task.stepFunctionTriggerTransport";
|
|
73
|
+
createService(params) {
|
|
74
|
+
return new StepFunctionService(params);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=StepFunctionServicePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TaskServicePlugin","createStepFunctionClient","describeExecutionFactory","triggerStepFunctionFactory","generateAlphaNumericId","ServiceDiscovery","StepFunctionService","constructor","params","getTenant","client","trigger","get","send","task","delay","manifest","load","console","error","bgTaskSfn","api","input","webinyTaskId","id","webinyTaskDefinitionId","definitionId","tenant","name","result","detail","stateMachineArn","ex","log","fetch","executionArn","eventResponse","JSON","parse","stringify","StepFunctionServicePlugin","createService"],"sources":["StepFunctionServicePlugin.ts"],"sourcesContent":["import type {\n ITaskService,\n ITaskServiceCreatePluginParams,\n ITaskServiceTask\n} from \"~/plugins/index.js\";\nimport { TaskServicePlugin } from \"~/plugins/index.js\";\nimport type { DescribeExecutionCommandOutput } from \"@webiny/aws-sdk/client-sfn/index.js\";\nimport {\n createStepFunctionClient,\n describeExecutionFactory,\n triggerStepFunctionFactory\n} from \"@webiny/aws-sdk/client-sfn/index.js\";\nimport type { ITaskEventInput } from \"~/handler/types.js\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\nimport { ServiceDiscovery } from \"@webiny/api\";\nimport type { ITask } from \"~/types.js\";\n\nexport type IStepFunctionServiceFetchResult = DescribeExecutionCommandOutput;\n\nexport interface IDetailWrapper<T> {\n detail: T;\n}\n\nexport class StepFunctionService implements ITaskService {\n private readonly getTenant: () => string;\n private readonly trigger: ReturnType<typeof triggerStepFunctionFactory>;\n private readonly get: ReturnType<typeof describeExecutionFactory>;\n\n public constructor(params: ITaskServiceCreatePluginParams) {\n this.getTenant = params.getTenant;\n const client = createStepFunctionClient();\n this.trigger = triggerStepFunctionFactory(client);\n this.get = describeExecutionFactory(client);\n }\n public async send(task: ITaskServiceTask, delay: number) {\n const manifest = await ServiceDiscovery.load();\n if (!manifest) {\n console.error(\"Service manifest not found.\");\n return null;\n }\n const { bgTaskSfn } = manifest.api || {};\n if (!bgTaskSfn) {\n console.error(\"Background task state machine not found.\");\n return null;\n }\n\n const input: ITaskEventInput = {\n webinyTaskId: task.id,\n webinyTaskDefinitionId: task.definitionId,\n tenant: this.getTenant(),\n delay\n };\n const name = `${task.definitionId}_${task.id}_${generateAlphaNumericId(10)}`;\n try {\n const result = await this.trigger<IDetailWrapper<ITaskEventInput>>({\n input: {\n detail: input\n },\n stateMachineArn: bgTaskSfn,\n name\n });\n return {\n ...result,\n name\n };\n } catch (ex) {\n console.log(\"Could not trigger a step function.\");\n console.error(ex);\n return null;\n }\n }\n\n public async fetch(task: ITask): Promise<IStepFunctionServiceFetchResult | null> {\n const executionArn = task.eventResponse?.executionArn;\n if (!executionArn) {\n console.error(`Execution ARN not found in task \"${task.id}\".`);\n return null;\n }\n try {\n const result = await this.get({\n executionArn\n });\n if (!result) {\n return null;\n }\n return JSON.parse(JSON.stringify(result));\n } catch (ex) {\n console.log(\"Could not get the execution details.\");\n console.error(ex);\n return null;\n }\n }\n}\n\nexport class StepFunctionServicePlugin extends TaskServicePlugin {\n public override name = \"task.stepFunctionTriggerTransport\";\n\n public createService(params: ITaskServiceCreatePluginParams) {\n return new StepFunctionService(params);\n }\n}\n"],"mappings":"AAKA,SAASA,iBAAiB;AAE1B,SACIC,wBAAwB,EACxBC,wBAAwB,EACxBC,0BAA0B,QACvB,qCAAqC;AAE5C,SAASC,sBAAsB,QAAQ,eAAe;AACtD,SAASC,gBAAgB,QAAQ,aAAa;AAS9C,OAAO,MAAMC,mBAAmB,CAAyB;EAK9CC,WAAWA,CAACC,MAAsC,EAAE;IACvD,IAAI,CAACC,SAAS,GAAGD,MAAM,CAACC,SAAS;IACjC,MAAMC,MAAM,GAAGT,wBAAwB,CAAC,CAAC;IACzC,IAAI,CAACU,OAAO,GAAGR,0BAA0B,CAACO,MAAM,CAAC;IACjD,IAAI,CAACE,GAAG,GAAGV,wBAAwB,CAACQ,MAAM,CAAC;EAC/C;EACA,MAAaG,IAAIA,CAACC,IAAsB,EAAEC,KAAa,EAAE;IACrD,MAAMC,QAAQ,GAAG,MAAMX,gBAAgB,CAACY,IAAI,CAAC,CAAC;IAC9C,IAAI,CAACD,QAAQ,EAAE;MACXE,OAAO,CAACC,KAAK,CAAC,6BAA6B,CAAC;MAC5C,OAAO,IAAI;IACf;IACA,MAAM;MAAEC;IAAU,CAAC,GAAGJ,QAAQ,CAACK,GAAG,IAAI,CAAC,CAAC;IACxC,IAAI,CAACD,SAAS,EAAE;MACZF,OAAO,CAACC,KAAK,CAAC,0CAA0C,CAAC;MACzD,OAAO,IAAI;IACf;IAEA,MAAMG,KAAsB,GAAG;MAC3BC,YAAY,EAAET,IAAI,CAACU,EAAE;MACrBC,sBAAsB,EAAEX,IAAI,CAACY,YAAY;MACzCC,MAAM,EAAE,IAAI,CAAClB,SAAS,CAAC,CAAC;MACxBM;IACJ,CAAC;IACD,MAAMa,IAAI,GAAG,GAAGd,IAAI,CAACY,YAAY,IAAIZ,IAAI,CAACU,EAAE,IAAIpB,sBAAsB,CAAC,EAAE,CAAC,EAAE;IAC5E,IAAI;MACA,MAAMyB,MAAM,GAAG,MAAM,IAAI,CAAClB,OAAO,CAAkC;QAC/DW,KAAK,EAAE;UACHQ,MAAM,EAAER;QACZ,CAAC;QACDS,eAAe,EAAEX,SAAS;QAC1BQ;MACJ,CAAC,CAAC;MACF,OAAO;QACH,GAAGC,MAAM;QACTD;MACJ,CAAC;IACL,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTd,OAAO,CAACe,GAAG,CAAC,oCAAoC,CAAC;MACjDf,OAAO,CAACC,KAAK,CAACa,EAAE,CAAC;MACjB,OAAO,IAAI;IACf;EACJ;EAEA,MAAaE,KAAKA,CAACpB,IAAW,EAAmD;IAC7E,MAAMqB,YAAY,GAAGrB,IAAI,CAACsB,aAAa,EAAED,YAAY;IACrD,IAAI,CAACA,YAAY,EAAE;MACfjB,OAAO,CAACC,KAAK,CAAC,oCAAoCL,IAAI,CAACU,EAAE,IAAI,CAAC;MAC9D,OAAO,IAAI;IACf;IACA,IAAI;MACA,MAAMK,MAAM,GAAG,MAAM,IAAI,CAACjB,GAAG,CAAC;QAC1BuB;MACJ,CAAC,CAAC;MACF,IAAI,CAACN,MAAM,EAAE;QACT,OAAO,IAAI;MACf;MACA,OAAOQ,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACV,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC,OAAOG,EAAE,EAAE;MACTd,OAAO,CAACe,GAAG,CAAC,sCAAsC,CAAC;MACnDf,OAAO,CAACC,KAAK,CAACa,EAAE,CAAC;MACjB,OAAO,IAAI;IACf;EACJ;AACJ;AAEA,OAAO,MAAMQ,yBAAyB,SAASxC,iBAAiB,CAAC;EAC7C4B,IAAI,GAAG,mCAAmC;EAEnDa,aAAaA,CAACjC,MAAsC,EAAE;IACzD,OAAO,IAAIF,mBAAmB,CAACE,MAAM,CAAC;EAC1C;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TaskServicePlugin } from "../plugins/index.js";
|
|
2
|
+
import { WebinyError } from "@webiny/error";
|
|
3
|
+
export const createService = params => {
|
|
4
|
+
const plugins = params.context.plugins.byType(TaskServicePlugin.type).reverse();
|
|
5
|
+
const plugin = plugins.find(plugin => plugin.default) || plugins[0];
|
|
6
|
+
if (!plugin) {
|
|
7
|
+
throw new WebinyError("Missing TaskServicePlugin.", "PLUGIN_ERROR", {
|
|
8
|
+
type: TaskServicePlugin.type
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const getTenant = () => {
|
|
12
|
+
return params.context.tenancy.getCurrentTenant().id;
|
|
13
|
+
};
|
|
14
|
+
return plugin.createService({
|
|
15
|
+
getTenant
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=createService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TaskServicePlugin","WebinyError","createService","params","plugins","context","byType","type","reverse","plugin","find","default","getTenant","tenancy","getCurrentTenant","id"],"sources":["createService.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport type { ITaskService } from \"~/plugins/index.js\";\nimport { TaskServicePlugin } from \"~/plugins/index.js\";\nimport { WebinyError } from \"@webiny/error\";\n\nexport interface ICreateTransport {\n context: Context;\n}\n\nexport const createService = (params: ICreateTransport): ITaskService => {\n const plugins = params.context.plugins\n .byType<TaskServicePlugin>(TaskServicePlugin.type)\n .reverse();\n\n const plugin = plugins.find(plugin => plugin.default) || plugins[0];\n if (!plugin) {\n throw new WebinyError(\"Missing TaskServicePlugin.\", \"PLUGIN_ERROR\", {\n type: TaskServicePlugin.type\n });\n }\n\n const getTenant = (): string => {\n return params.context.tenancy.getCurrentTenant().id;\n };\n\n return plugin.createService({\n getTenant\n });\n};\n"],"mappings":"AAEA,SAASA,iBAAiB;AAC1B,SAASC,WAAW,QAAQ,eAAe;AAM3C,OAAO,MAAMC,aAAa,GAAIC,MAAwB,IAAmB;EACrE,MAAMC,OAAO,GAAGD,MAAM,CAACE,OAAO,CAACD,OAAO,CACjCE,MAAM,CAAoBN,iBAAiB,CAACO,IAAI,CAAC,CACjDC,OAAO,CAAC,CAAC;EAEd,MAAMC,MAAM,GAAGL,OAAO,CAACM,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACE,OAAO,CAAC,IAAIP,OAAO,CAAC,CAAC,CAAC;EACnE,IAAI,CAACK,MAAM,EAAE;IACT,MAAM,IAAIR,WAAW,CAAC,4BAA4B,EAAE,cAAc,EAAE;MAChEM,IAAI,EAAEP,iBAAiB,CAACO;IAC5B,CAAC,CAAC;EACN;EAEA,MAAMK,SAAS,GAAGA,CAAA,KAAc;IAC5B,OAAOT,MAAM,CAACE,OAAO,CAACQ,OAAO,CAACC,gBAAgB,CAAC,CAAC,CAACC,EAAE;EACvD,CAAC;EAED,OAAON,MAAM,CAACP,aAAa,CAAC;IACxBU;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EventBridgeEventTransportPlugin } from "./EventBridgeEventTransportPlugin.js";
|
|
2
|
+
import { StepFunctionServicePlugin } from "./StepFunctionServicePlugin.js";
|
|
3
|
+
export declare const createServicePlugins: () => (StepFunctionServicePlugin | EventBridgeEventTransportPlugin)[];
|
|
4
|
+
export * from "./createService.js";
|
package/service/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EventBridgeEventTransportPlugin } from "./EventBridgeEventTransportPlugin.js";
|
|
2
|
+
import { StepFunctionServicePlugin } from "./StepFunctionServicePlugin.js";
|
|
3
|
+
export const createServicePlugins = () => {
|
|
4
|
+
return [new StepFunctionServicePlugin({
|
|
5
|
+
default: true
|
|
6
|
+
}), new EventBridgeEventTransportPlugin()];
|
|
7
|
+
};
|
|
8
|
+
export * from "./createService.js";
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EventBridgeEventTransportPlugin","StepFunctionServicePlugin","createServicePlugins","default"],"sources":["index.ts"],"sourcesContent":["import { EventBridgeEventTransportPlugin } from \"./EventBridgeEventTransportPlugin.js\";\nimport { StepFunctionServicePlugin } from \"./StepFunctionServicePlugin.js\";\n\nexport const createServicePlugins = () => {\n return [\n new StepFunctionServicePlugin({ default: true }),\n new EventBridgeEventTransportPlugin()\n ];\n};\n\nexport * from \"./createService.js\";\n"],"mappings":"AAAA,SAASA,+BAA+B;AACxC,SAASC,yBAAyB;AAElC,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACtC,OAAO,CACH,IAAID,yBAAyB,CAAC;IAAEE,OAAO,EAAE;EAAK,CAAC,CAAC,EAChD,IAAIH,+BAA+B,CAAC,CAAC,CACxC;AACL,CAAC;AAED","ignoreList":[]}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
|
+
declare class TestingRunTask implements TaskDefinition.Interface {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
run({ controller }: TaskDefinition.RunParams): Promise<TaskDefinition.ResultDone<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const TestingRunTaskDefinition: typeof TestingRunTask & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|