@webiny/background-tasks 6.6.0-alpha.0 → 6.6.0-alpha.10
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/admin/BackgroundTaskRoutes.js +16 -3
- package/admin/BackgroundTaskRoutes.js.map +1 -1
- package/admin/presentation/TaskDetail/components/TaskDetailDrawer.js +6 -0
- package/admin/presentation/TaskDetail/components/TaskDetailDrawer.js.map +1 -1
- package/admin/presentation/TaskExecutions/components/TaskExecutionsView.js +44 -24
- package/admin/presentation/TaskExecutions/components/TaskExecutionsView.js.map +1 -1
- package/api/BackgroundTasksFeature.js +44 -24
- package/api/BackgroundTasksFeature.js.map +1 -1
- package/api/crud/TaskLogPrivateModel.js +2 -1
- package/api/crud/TaskLogPrivateModel.js.map +1 -1
- package/api/crud/TaskPrivateModel.js +2 -1
- package/api/crud/TaskPrivateModel.js.map +1 -1
- package/api/decorators/{SelfCleaningTaskDecorator.d.ts → SelfCleaningTaskHandlerDecorator.d.ts} +21 -18
- package/api/decorators/SelfCleaningTaskHandlerDecorator.js +69 -0
- package/api/decorators/SelfCleaningTaskHandlerDecorator.js.map +1 -0
- package/api/decorators/TaskDefinitionDefaultsDecorator.d.ts +27 -0
- package/api/decorators/TaskDefinitionDefaultsDecorator.js +47 -0
- package/api/decorators/TaskDefinitionDefaultsDecorator.js.map +1 -0
- package/api/domain/errors.d.ts +4 -0
- package/api/domain/errors.js +10 -2
- package/api/domain/errors.js.map +1 -1
- package/api/domain/task/TaskLogModelProvider.d.ts +12 -0
- package/api/domain/task/TaskLogModelProvider.js +23 -0
- package/api/domain/task/TaskLogModelProvider.js.map +1 -0
- package/api/domain/task/TaskLogsRepository.d.ts +34 -0
- package/api/domain/task/TaskLogsRepository.js +146 -0
- package/api/domain/task/TaskLogsRepository.js.map +1 -0
- package/api/domain/task/TaskModelProvider.d.ts +12 -0
- package/api/domain/task/TaskModelProvider.js +23 -0
- package/api/domain/task/TaskModelProvider.js.map +1 -0
- package/api/domain/task/TasksRepository.d.ts +37 -0
- package/api/domain/task/TasksRepository.js +126 -0
- package/api/domain/task/TasksRepository.js.map +1 -0
- package/api/domain/task/abstractions.d.ts +50 -0
- package/api/domain/task/abstractions.js +8 -0
- package/api/domain/task/abstractions.js.map +1 -0
- package/api/domain/task/createRevisionId.d.ts +1 -0
- package/api/domain/task/createRevisionId.js +8 -0
- package/api/domain/task/createRevisionId.js.map +1 -0
- package/api/domain/task/entryToTask.d.ts +3 -0
- package/api/domain/task/entryToTask.js +20 -0
- package/api/domain/task/entryToTask.js.map +1 -0
- package/api/domain/task/entryToTaskLog.d.ts +3 -0
- package/api/domain/task/entryToTaskLog.js +12 -0
- package/api/domain/task/entryToTaskLog.js.map +1 -0
- package/api/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.d.ts +25 -5
- package/api/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js +111 -5
- package/api/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js.map +1 -1
- package/api/features/CleanupTaskSubtree/feature.d.ts +4 -0
- package/api/features/CleanupTaskSubtree/feature.js +11 -0
- package/api/features/CleanupTaskSubtree/feature.js.map +1 -0
- package/api/features/CleanupTaskSubtree/index.d.ts +1 -1
- package/api/features/CleanupTaskSubtree/index.js +1 -1
- package/api/features/CreateTask/CreateTaskUseCase.d.ts +17 -0
- package/api/features/CreateTask/CreateTaskUseCase.js +56 -0
- package/api/features/CreateTask/CreateTaskUseCase.js.map +1 -0
- package/api/features/CreateTask/abstractions.d.ts +21 -0
- package/api/features/CreateTask/abstractions.js +5 -0
- package/api/features/CreateTask/abstractions.js.map +1 -0
- package/api/features/{GetTaskDefinition → CreateTask}/feature.d.ts +1 -1
- package/api/features/CreateTask/feature.js +11 -0
- package/api/features/CreateTask/feature.js.map +1 -0
- package/api/features/CreateTask/index.d.ts +2 -0
- package/api/features/CreateTask/index.js +2 -0
- package/api/features/CreateTaskLog/CreateTaskLogUseCase.d.ts +13 -0
- package/api/features/CreateTaskLog/CreateTaskLogUseCase.js +19 -0
- package/api/features/CreateTaskLog/CreateTaskLogUseCase.js.map +1 -0
- package/api/features/CreateTaskLog/abstractions.d.ts +16 -0
- package/api/features/CreateTaskLog/abstractions.js +5 -0
- package/api/features/CreateTaskLog/abstractions.js.map +1 -0
- package/api/features/CreateTaskLog/feature.d.ts +4 -0
- package/api/features/CreateTaskLog/feature.js +11 -0
- package/api/features/CreateTaskLog/feature.js.map +1 -0
- package/api/features/CreateTaskLog/index.d.ts +2 -0
- package/api/features/CreateTaskLog/index.js +2 -0
- package/api/features/DeleteTask/DeleteTaskUseCase.d.ts +14 -0
- package/api/features/DeleteTask/DeleteTaskUseCase.js +34 -0
- package/api/features/DeleteTask/DeleteTaskUseCase.js.map +1 -0
- package/api/features/DeleteTask/abstractions.d.ts +17 -0
- package/api/features/DeleteTask/abstractions.js +5 -0
- package/api/features/DeleteTask/abstractions.js.map +1 -0
- package/api/features/DeleteTask/feature.d.ts +4 -0
- package/api/features/DeleteTask/feature.js +11 -0
- package/api/features/DeleteTask/feature.js.map +1 -0
- package/api/features/DeleteTask/index.d.ts +2 -0
- package/api/features/DeleteTask/index.js +2 -0
- package/api/features/DeleteTaskLog/DeleteTaskLogUseCase.d.ts +11 -0
- package/api/features/DeleteTaskLog/DeleteTaskLogUseCase.js +19 -0
- package/api/features/DeleteTaskLog/DeleteTaskLogUseCase.js.map +1 -0
- package/api/features/DeleteTaskLog/abstractions.d.ts +14 -0
- package/api/features/DeleteTaskLog/abstractions.js +5 -0
- package/api/features/DeleteTaskLog/abstractions.js.map +1 -0
- package/api/features/DeleteTaskLog/feature.d.ts +4 -0
- package/api/features/DeleteTaskLog/feature.js +11 -0
- package/api/features/DeleteTaskLog/feature.js.map +1 -0
- package/api/features/DeleteTaskLog/index.d.ts +2 -0
- package/api/features/DeleteTaskLog/index.js +2 -0
- package/api/features/GetLatestTaskLog/GetLatestTaskLogUseCase.d.ts +11 -0
- package/api/features/GetLatestTaskLog/GetLatestTaskLogUseCase.js +19 -0
- package/api/features/GetLatestTaskLog/GetLatestTaskLogUseCase.js.map +1 -0
- package/api/features/GetLatestTaskLog/abstractions.d.ts +15 -0
- package/api/features/GetLatestTaskLog/abstractions.js +5 -0
- package/api/features/GetLatestTaskLog/abstractions.js.map +1 -0
- package/api/features/GetLatestTaskLog/feature.d.ts +4 -0
- package/api/features/GetLatestTaskLog/feature.js +11 -0
- package/api/features/GetLatestTaskLog/feature.js.map +1 -0
- package/api/features/GetLatestTaskLog/index.d.ts +2 -0
- package/api/features/GetLatestTaskLog/index.js +2 -0
- package/api/features/GetRunnableTaskDefinition/GetRunnableTaskDefinitionUseCase.d.ts +13 -0
- package/api/features/GetRunnableTaskDefinition/GetRunnableTaskDefinitionUseCase.js +51 -0
- package/api/features/GetRunnableTaskDefinition/GetRunnableTaskDefinitionUseCase.js.map +1 -0
- package/api/features/{GetTaskDefinition → GetRunnableTaskDefinition}/abstractions.d.ts +6 -6
- package/api/features/GetRunnableTaskDefinition/abstractions.js +5 -0
- package/api/features/GetRunnableTaskDefinition/abstractions.js.map +1 -0
- package/api/features/GetRunnableTaskDefinition/feature.d.ts +4 -0
- package/api/features/GetRunnableTaskDefinition/feature.js +11 -0
- package/api/features/GetRunnableTaskDefinition/feature.js.map +1 -0
- package/api/features/GetRunnableTaskDefinition/index.d.ts +2 -0
- package/api/features/GetRunnableTaskDefinition/index.js +2 -0
- package/api/features/GetTask/GetTaskUseCase.d.ts +9 -5
- package/api/features/GetTask/GetTaskUseCase.js +12 -4
- package/api/features/GetTask/GetTaskUseCase.js.map +1 -1
- package/api/features/GetTask/abstractions.d.ts +9 -2
- package/api/features/GetTask/abstractions.js.map +1 -1
- package/api/features/GetTask/feature.js +2 -4
- package/api/features/GetTask/feature.js.map +1 -1
- package/api/features/ListTaskLogs/ListTaskLogsUseCase.d.ts +12 -0
- package/api/features/ListTaskLogs/ListTaskLogsUseCase.js +19 -0
- package/api/features/ListTaskLogs/ListTaskLogsUseCase.js.map +1 -0
- package/api/features/ListTaskLogs/abstractions.d.ts +15 -0
- package/api/features/ListTaskLogs/abstractions.js +5 -0
- package/api/features/ListTaskLogs/abstractions.js.map +1 -0
- package/api/features/ListTaskLogs/feature.d.ts +4 -0
- package/api/features/ListTaskLogs/feature.js +11 -0
- package/api/features/ListTaskLogs/feature.js.map +1 -0
- package/api/features/ListTaskLogs/index.d.ts +2 -0
- package/api/features/ListTaskLogs/index.js +2 -0
- package/api/features/ListTasks/ListTasksUseCase.d.ts +9 -6
- package/api/features/ListTasks/ListTasksUseCase.js +12 -4
- package/api/features/ListTasks/ListTasksUseCase.js.map +1 -1
- package/api/features/ListTasks/abstractions.d.ts +9 -3
- package/api/features/ListTasks/abstractions.js.map +1 -1
- package/api/features/ListTasks/feature.js +2 -4
- package/api/features/ListTasks/feature.js.map +1 -1
- package/api/features/ListVisibleTaskDefinitions/ListVisibleTaskDefinitionsUseCase.d.ts +11 -0
- package/api/features/ListVisibleTaskDefinitions/ListVisibleTaskDefinitionsUseCase.js +19 -0
- package/api/features/ListVisibleTaskDefinitions/ListVisibleTaskDefinitionsUseCase.js.map +1 -0
- package/api/features/ListVisibleTaskDefinitions/abstractions.d.ts +9 -0
- package/api/features/ListVisibleTaskDefinitions/abstractions.js +5 -0
- package/api/features/ListVisibleTaskDefinitions/abstractions.js.map +1 -0
- package/api/features/ListVisibleTaskDefinitions/feature.d.ts +4 -0
- package/api/features/ListVisibleTaskDefinitions/feature.js +11 -0
- package/api/features/ListVisibleTaskDefinitions/feature.js.map +1 -0
- package/api/features/ListVisibleTaskDefinitions/index.d.ts +2 -0
- package/api/features/ListVisibleTaskDefinitions/index.js +2 -0
- package/api/features/TaskHandlerResolver/TaskHandlerResolver.d.ts +12 -0
- package/api/features/TaskHandlerResolver/TaskHandlerResolver.js +19 -0
- package/api/features/TaskHandlerResolver/TaskHandlerResolver.js.map +1 -0
- package/api/features/TaskHandlerResolver/abstractions.d.ts +17 -0
- package/api/features/TaskHandlerResolver/abstractions.js +5 -0
- package/api/features/TaskHandlerResolver/abstractions.js.map +1 -0
- package/api/features/TaskHandlerResolver/feature.d.ts +9 -0
- package/api/features/TaskHandlerResolver/feature.js +11 -0
- package/api/features/TaskHandlerResolver/feature.js.map +1 -0
- package/api/features/TaskHandlerResolver/index.d.ts +2 -0
- package/api/features/TaskHandlerResolver/index.js +2 -0
- package/api/features/TaskService/BackgroundTaskService.d.ts +42 -0
- package/api/features/TaskService/BackgroundTaskService.js +191 -0
- package/api/features/TaskService/BackgroundTaskService.js.map +1 -0
- package/api/features/TaskService/feature.d.ts +4 -0
- package/api/features/TaskService/feature.js +11 -0
- package/api/features/TaskService/feature.js.map +1 -0
- package/api/features/TaskService/index.d.ts +1 -0
- package/api/features/TaskService/index.js +1 -0
- package/api/features/TriggerVisibleTask/TriggerVisibleTaskUseCase.d.ts +15 -0
- package/api/features/TriggerVisibleTask/TriggerVisibleTaskUseCase.js +26 -0
- package/api/features/TriggerVisibleTask/TriggerVisibleTaskUseCase.js.map +1 -0
- package/api/features/TriggerVisibleTask/abstractions.d.ts +17 -0
- package/api/features/TriggerVisibleTask/abstractions.js +5 -0
- package/api/features/TriggerVisibleTask/abstractions.js.map +1 -0
- package/api/features/TriggerVisibleTask/feature.d.ts +4 -0
- package/api/features/TriggerVisibleTask/feature.js +11 -0
- package/api/features/TriggerVisibleTask/feature.js.map +1 -0
- package/api/features/TriggerVisibleTask/index.d.ts +2 -0
- package/api/features/TriggerVisibleTask/index.js +2 -0
- package/api/features/UpdateBackgroundTaskSettings/UpdateBackgroundTaskSettingsRepository.js +3 -1
- package/api/features/UpdateBackgroundTaskSettings/UpdateBackgroundTaskSettingsRepository.js.map +1 -1
- package/api/features/UpdateTask/UpdateTaskUseCase.d.ts +17 -0
- package/api/features/UpdateTask/UpdateTaskUseCase.js +36 -0
- package/api/features/UpdateTask/UpdateTaskUseCase.js.map +1 -0
- package/api/features/UpdateTask/abstractions.d.ts +22 -0
- package/api/features/UpdateTask/abstractions.js +5 -0
- package/api/features/UpdateTask/abstractions.js.map +1 -0
- package/api/features/UpdateTask/feature.d.ts +4 -0
- package/api/features/UpdateTask/feature.js +11 -0
- package/api/features/UpdateTask/feature.js.map +1 -0
- package/api/features/UpdateTask/index.d.ts +2 -0
- package/api/features/UpdateTask/index.js +2 -0
- package/api/features/UpdateTaskLog/UpdateTaskLogUseCase.d.ts +12 -0
- package/api/features/UpdateTaskLog/UpdateTaskLogUseCase.js +19 -0
- package/api/features/UpdateTaskLog/UpdateTaskLogUseCase.js.map +1 -0
- package/api/features/UpdateTaskLog/abstractions.d.ts +16 -0
- package/api/features/UpdateTaskLog/abstractions.js +5 -0
- package/api/features/UpdateTaskLog/abstractions.js.map +1 -0
- package/api/features/UpdateTaskLog/feature.d.ts +4 -0
- package/api/features/UpdateTaskLog/feature.js +11 -0
- package/api/features/UpdateTaskLog/feature.js.map +1 -0
- package/api/features/UpdateTaskLog/index.d.ts +2 -0
- package/api/features/UpdateTaskLog/index.js +2 -0
- package/api/graphql/BackgroundTasksGraphQLSchema.d.ts +29 -0
- package/api/graphql/BackgroundTasksGraphQLSchema.js +462 -0
- package/api/graphql/BackgroundTasksGraphQLSchema.js.map +1 -0
- package/api/index.d.ts +11 -2
- package/api/index.js +11 -2
- package/api/runner/TaskControl.d.ts +35 -1
- package/api/runner/TaskControl.js +52 -42
- package/api/runner/TaskControl.js.map +1 -1
- package/api/runner/TaskManager.d.ts +12 -1
- package/api/runner/TaskManager.js +11 -10
- package/api/runner/TaskManager.js.map +1 -1
- package/api/runner/TaskManagerStore.d.ts +16 -0
- package/api/runner/TaskManagerStore.js +23 -7
- package/api/runner/TaskManagerStore.js.map +1 -1
- package/api/runner/TaskRunner.js +35 -4
- package/api/runner/TaskRunner.js.map +1 -1
- package/api/tasks/testingRunTask.d.ts +10 -2
- package/api/tasks/testingRunTask.js +10 -3
- package/api/tasks/testingRunTask.js.map +1 -1
- package/api/types.d.ts +1 -48
- package/api/types.js.map +1 -1
- package/package.json +28 -32
- package/testing/index.d.ts +3 -0
- package/testing/index.js +2 -0
- package/testing/mockTaskTriggerTransportPlugin.d.ts +2 -0
- package/testing/mockTaskTriggerTransportPlugin.js +18 -0
- package/testing/mockTaskTriggerTransportPlugin.js.map +1 -0
- package/testing/runner.d.ts +19 -0
- package/testing/runner.js +44 -0
- package/testing/runner.js.map +1 -0
- package/api/TasksCrud.d.ts +0 -10
- package/api/TasksCrud.js +0 -5
- package/api/TasksCrud.js.map +0 -1
- package/api/crud/cleanupTaskSubtree.d.ts +0 -8
- package/api/crud/cleanupTaskSubtree.js +0 -63
- package/api/crud/cleanupTaskSubtree.js.map +0 -1
- package/api/crud/crud.tasks.d.ts +0 -3
- package/api/crud/crud.tasks.js +0 -318
- package/api/crud/crud.tasks.js.map +0 -1
- package/api/crud/definition.tasks.d.ts +0 -3
- package/api/crud/definition.tasks.js +0 -17
- package/api/crud/definition.tasks.js.map +0 -1
- package/api/crud/service.tasks.d.ts +0 -3
- package/api/crud/service.tasks.js +0 -132
- package/api/crud/service.tasks.js.map +0 -1
- package/api/decorators/RunnableTaskDecorator.d.ts +0 -32
- package/api/decorators/RunnableTaskDecorator.js +0 -69
- package/api/decorators/RunnableTaskDecorator.js.map +0 -1
- package/api/decorators/SelfCleaningTaskDecorator.js +0 -84
- package/api/decorators/SelfCleaningTaskDecorator.js.map +0 -1
- package/api/features/GetTaskDefinition/GetTaskDefinitionUseCase.d.ts +0 -12
- package/api/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +0 -27
- package/api/features/GetTaskDefinition/GetTaskDefinitionUseCase.js.map +0 -1
- package/api/features/GetTaskDefinition/abstractions.js +0 -5
- package/api/features/GetTaskDefinition/abstractions.js.map +0 -1
- package/api/features/GetTaskDefinition/feature.js +0 -11
- package/api/features/GetTaskDefinition/feature.js.map +0 -1
- package/api/features/GetTaskDefinition/index.d.ts +0 -2
- package/api/features/GetTaskDefinition/index.js +0 -2
- package/api/graphql/BackgroundTasksContextualSchema.d.ts +0 -21
- package/api/graphql/BackgroundTasksContextualSchema.js +0 -369
- package/api/graphql/BackgroundTasksContextualSchema.js.map +0 -1
- package/api/service/createService.d.ts +0 -6
- package/api/service/createService.js +0 -11
- package/api/service/createService.js.map +0 -1
- package/api/service/index.d.ts +0 -1
- package/api/service/index.js +0 -1
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import type { Result } from "@webiny/feature/api";
|
|
1
2
|
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
2
3
|
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
3
|
-
import type { IListTasksResponse
|
|
4
|
+
import type { IListTasksResponse } from "../../../api/types.js";
|
|
5
|
+
import type { IListTaskParams } from "../../../api/types.js";
|
|
6
|
+
import type { BackgroundTaskPersistenceError } from "../../../api/domain/errors.js";
|
|
7
|
+
type UseCaseError = BackgroundTaskPersistenceError;
|
|
4
8
|
export interface IListTasksUseCase {
|
|
5
|
-
execute<I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput>(params?: ListTasksParams): Promise<IListTasksResponse<I, O>>;
|
|
9
|
+
execute<I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput>(params?: ListTasksParams): Promise<Result<IListTasksResponse<I, O>, UseCaseError>>;
|
|
6
10
|
}
|
|
7
11
|
export type ListTasksParams = IListTaskParams;
|
|
8
12
|
export declare const ListTasksUseCase: import("@webiny/di").Abstraction<IListTasksUseCase>;
|
|
9
13
|
export declare namespace ListTasksUseCase {
|
|
10
14
|
type Interface = IListTasksUseCase;
|
|
11
15
|
type Params = ListTasksParams;
|
|
12
|
-
type
|
|
16
|
+
type Error = UseCaseError;
|
|
17
|
+
type Return<I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput> = Promise<Result<IListTasksResponse<I, O>, UseCaseError>>;
|
|
13
18
|
}
|
|
19
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ListTasks/abstractions.js","sources":["../../../../src/api/features/ListTasks/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport type { IListTasksResponse
|
|
1
|
+
{"version":3,"file":"api/features/ListTasks/abstractions.js","sources":["../../../../src/api/features/ListTasks/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport type { IListTasksResponse } from \"~/api/types.js\";\nimport type { IListTaskParams } from \"~/api/types.js\";\nimport type { BackgroundTaskPersistenceError } from \"~/api/domain/errors.js\";\n\ntype UseCaseError = BackgroundTaskPersistenceError;\n\nexport interface IListTasksUseCase {\n execute<\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n >(\n params?: ListTasksParams\n ): Promise<Result<IListTasksResponse<I, O>, UseCaseError>>;\n}\n\nexport type ListTasksParams = IListTaskParams;\n\nexport const ListTasksUseCase = createAbstraction<IListTasksUseCase>(\"Tasks/ListTasksUseCase\");\n\nexport namespace ListTasksUseCase {\n export type Interface = IListTasksUseCase;\n export type Params = ListTasksParams;\n export type Error = UseCaseError;\n\n export type Return<\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n > = Promise<Result<IListTasksResponse<I, O>, UseCaseError>>;\n}\n"],"names":["ListTasksUseCase","createAbstraction"],"mappings":";AAqBO,MAAMA,mBAAmBC,kBAAqC"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
|
-
import {
|
|
3
|
-
import { ListTasksUseCase } from "./abstractions.js";
|
|
4
|
-
import { TasksCrud } from "../../TasksCrud.js";
|
|
2
|
+
import { ListTasksUseCase } from "./ListTasksUseCase.js";
|
|
5
3
|
const ListTasksFeature = createFeature({
|
|
6
4
|
name: "ListTasks",
|
|
7
5
|
register (container) {
|
|
8
|
-
container.
|
|
6
|
+
container.register(ListTasksUseCase);
|
|
9
7
|
}
|
|
10
8
|
});
|
|
11
9
|
export { ListTasksFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ListTasks/feature.js","sources":["../../../../src/api/features/ListTasks/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport {
|
|
1
|
+
{"version":3,"file":"api/features/ListTasks/feature.js","sources":["../../../../src/api/features/ListTasks/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListTasksUseCase } from \"./ListTasksUseCase.js\";\n\nexport const ListTasksFeature = createFeature({\n name: \"ListTasks\",\n register(container) {\n container.register(ListTasksUseCase);\n }\n});\n"],"names":["ListTasksFeature","createFeature","container","ListTasksUseCase"],"mappings":";;AAGO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ListVisibleTaskDefinitionsUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
2
|
+
import { ListTaskDefinitionsUseCase } from "../../../api/features/ListTaskDefinitions/abstractions.js";
|
|
3
|
+
declare class ListVisibleTaskDefinitionsUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
4
|
+
private readonly listTaskDefinitions;
|
|
5
|
+
constructor(listTaskDefinitions: ListTaskDefinitionsUseCase.Interface);
|
|
6
|
+
execute(): import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").TaskDefinition.Interface<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskOutput>[];
|
|
7
|
+
}
|
|
8
|
+
export declare const ListVisibleTaskDefinitionsUseCase: typeof ListVisibleTaskDefinitionsUseCaseImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListVisibleTaskDefinitionsUseCase>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ListVisibleTaskDefinitionsUseCase } from "./abstractions.js";
|
|
2
|
+
import { ListTaskDefinitionsUseCase } from "../ListTaskDefinitions/abstractions.js";
|
|
3
|
+
class ListVisibleTaskDefinitionsUseCaseImpl {
|
|
4
|
+
constructor(listTaskDefinitions){
|
|
5
|
+
this.listTaskDefinitions = listTaskDefinitions;
|
|
6
|
+
}
|
|
7
|
+
execute() {
|
|
8
|
+
return this.listTaskDefinitions.execute().filter((definition)=>!definition.isPrivate);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const ListVisibleTaskDefinitionsUseCase_ListVisibleTaskDefinitionsUseCase = ListVisibleTaskDefinitionsUseCase.createImplementation({
|
|
12
|
+
implementation: ListVisibleTaskDefinitionsUseCaseImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
ListTaskDefinitionsUseCase
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { ListVisibleTaskDefinitionsUseCase_ListVisibleTaskDefinitionsUseCase as ListVisibleTaskDefinitionsUseCase };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=ListVisibleTaskDefinitionsUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ListVisibleTaskDefinitions/ListVisibleTaskDefinitionsUseCase.js","sources":["../../../../src/api/features/ListVisibleTaskDefinitions/ListVisibleTaskDefinitionsUseCase.ts"],"sourcesContent":["import { ListVisibleTaskDefinitionsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { ListTaskDefinitionsUseCase } from \"~/api/features/ListTaskDefinitions/abstractions.js\";\n\nclass ListVisibleTaskDefinitionsUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly listTaskDefinitions: ListTaskDefinitionsUseCase.Interface\n ) {}\n\n public execute() {\n return this.listTaskDefinitions.execute().filter(definition => !definition.isPrivate);\n }\n}\n\nexport const ListVisibleTaskDefinitionsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListVisibleTaskDefinitionsUseCaseImpl,\n dependencies: [ListTaskDefinitionsUseCase]\n});\n"],"names":["ListVisibleTaskDefinitionsUseCaseImpl","listTaskDefinitions","definition","ListVisibleTaskDefinitionsUseCase","UseCaseAbstraction","ListTaskDefinitionsUseCase"],"mappings":";;AAGA,MAAMA;IACF,YACqBC,mBAAyD,CAC5E;aADmBA,mBAAmB,GAAnBA;IAClB;IAEI,UAAU;QACb,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,GAAG,MAAM,CAACC,CAAAA,aAAc,CAACA,WAAW,SAAS;IACxF;AACJ;AAEO,MAAMC,sEAAoCC,kCAAAA,oBAAuC,CAAC;IACrF,gBAAgBJ;IAChB,cAAc;QAACK;KAA2B;AAC9C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
|
+
export interface IListVisibleTaskDefinitionsUseCase {
|
|
3
|
+
execute(): TaskDefinition.Interface[];
|
|
4
|
+
}
|
|
5
|
+
/** List task definitions for the GraphQL API, without the private ones. */
|
|
6
|
+
export declare const ListVisibleTaskDefinitionsUseCase: import("@webiny/di").Abstraction<IListVisibleTaskDefinitionsUseCase>;
|
|
7
|
+
export declare namespace ListVisibleTaskDefinitionsUseCase {
|
|
8
|
+
type Interface = IListVisibleTaskDefinitionsUseCase;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ListVisibleTaskDefinitions/abstractions.js","sources":["../../../../src/api/features/ListVisibleTaskDefinitions/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface IListVisibleTaskDefinitionsUseCase {\n execute(): TaskDefinition.Interface[];\n}\n\n/** List task definitions for the GraphQL API, without the private ones. */\nexport const ListVisibleTaskDefinitionsUseCase =\n createAbstraction<IListVisibleTaskDefinitionsUseCase>(\n \"Tasks/ListVisibleTaskDefinitionsUseCase\"\n );\n\nexport namespace ListVisibleTaskDefinitionsUseCase {\n export type Interface = IListVisibleTaskDefinitionsUseCase;\n}\n"],"names":["ListVisibleTaskDefinitionsUseCase","createAbstraction"],"mappings":";AAQO,MAAMA,oCACTC,kBACI"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListVisibleTaskDefinitionsUseCase } from "./ListVisibleTaskDefinitionsUseCase.js";
|
|
3
|
+
const ListVisibleTaskDefinitionsFeature = createFeature({
|
|
4
|
+
name: "ListVisibleTaskDefinitions",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(ListVisibleTaskDefinitionsUseCase);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { ListVisibleTaskDefinitionsFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ListVisibleTaskDefinitions/feature.js","sources":["../../../../src/api/features/ListVisibleTaskDefinitions/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListVisibleTaskDefinitionsUseCase } from \"./ListVisibleTaskDefinitionsUseCase.js\";\n\nexport const ListVisibleTaskDefinitionsFeature = createFeature({\n name: \"ListVisibleTaskDefinitions\",\n register(container) {\n container.register(ListVisibleTaskDefinitionsUseCase);\n }\n});\n"],"names":["ListVisibleTaskDefinitionsFeature","createFeature","container","ListVisibleTaskDefinitionsUseCase"],"mappings":";;AAGO,MAAMA,oCAAoCC,cAAc;IAC3D,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Container, Constructor } from "@webiny/di";
|
|
2
|
+
import type { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
3
|
+
import { TaskHandlerResolver as Abstraction } from "./abstractions.js";
|
|
4
|
+
declare class ContainerTaskHandlerResolver implements Abstraction.Interface {
|
|
5
|
+
private readonly container;
|
|
6
|
+
constructor(container: Container);
|
|
7
|
+
resolve<I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput>(handler: Constructor<TaskDefinition.Handler<I, O>>): TaskDefinition.Handler<I, O>;
|
|
8
|
+
}
|
|
9
|
+
export declare const TaskHandlerResolver: typeof ContainerTaskHandlerResolver & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ITaskHandlerResolver>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestContainer } from "@webiny/event-handler-core/features/events/RequestContainer.js";
|
|
2
|
+
import { TaskHandlerResolver } from "./abstractions.js";
|
|
3
|
+
class ContainerTaskHandlerResolver {
|
|
4
|
+
constructor(container){
|
|
5
|
+
this.container = container;
|
|
6
|
+
}
|
|
7
|
+
resolve(handler) {
|
|
8
|
+
return this.container.resolveImplementation(handler);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const TaskHandlerResolver_TaskHandlerResolver = TaskHandlerResolver.createImplementation({
|
|
12
|
+
implementation: ContainerTaskHandlerResolver,
|
|
13
|
+
dependencies: [
|
|
14
|
+
RequestContainer
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { TaskHandlerResolver_TaskHandlerResolver as TaskHandlerResolver };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=TaskHandlerResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/TaskHandlerResolver/TaskHandlerResolver.js","sources":["../../../../src/api/features/TaskHandlerResolver/TaskHandlerResolver.ts"],"sourcesContent":["import type { Container, Constructor } from \"@webiny/di\";\nimport { RequestContainer } from \"@webiny/event-handler-core/features/events/RequestContainer.js\";\nimport type { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { TaskHandlerResolver as Abstraction } from \"./abstractions.js\";\n\nclass ContainerTaskHandlerResolver implements Abstraction.Interface {\n public constructor(private readonly container: Container) {}\n\n public resolve<\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n >(handler: Constructor<TaskDefinition.Handler<I, O>>): TaskDefinition.Handler<I, O> {\n // `resolveImplementation` builds the class from its own dependency metadata and runs it\n // through the normal resolution path, so decorators registered against the handler still\n // apply. It deliberately ignores registrations, which is what we want here: the definition\n // names the class directly and nothing registers handlers against an abstraction.\n return this.container.resolveImplementation(handler);\n }\n}\n\nexport const TaskHandlerResolver = Abstraction.createImplementation({\n implementation: ContainerTaskHandlerResolver,\n dependencies: [RequestContainer]\n});\n"],"names":["ContainerTaskHandlerResolver","container","handler","TaskHandlerResolver","Abstraction","RequestContainer"],"mappings":";;AAKA,MAAMA;IACF,YAAoCC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAEpD,QAGLC,OAAkD,EAAgC;QAKhF,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAACA;IAChD;AACJ;AAEO,MAAMC,0CAAsBC,oBAAAA,oBAAgC,CAAC;IAChE,gBAAgBJ;IAChB,cAAc;QAACK;KAAiB;AACpC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Constructor } from "@webiny/di";
|
|
2
|
+
import type { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
3
|
+
export interface ITaskHandlerResolver {
|
|
4
|
+
resolve<I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput>(handler: Constructor<TaskDefinition.Handler<I, O>>): TaskDefinition.Handler<I, O>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Builds the behaviour half of a task on demand.
|
|
8
|
+
*
|
|
9
|
+
* Something has to turn `definition.handler` (a class) into an instance, and that needs the
|
|
10
|
+
* container. Rather than injecting the container into a use case — which is the service-locator
|
|
11
|
+
* pattern we keep out of DI classes — it lives behind this one narrow abstraction. Everything else
|
|
12
|
+
* depends on `resolve(handler)` and stays testable with a stub.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TaskHandlerResolver: import("@webiny/di").Abstraction<ITaskHandlerResolver>;
|
|
15
|
+
export declare namespace TaskHandlerResolver {
|
|
16
|
+
type Interface = ITaskHandlerResolver;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/TaskHandlerResolver/abstractions.js","sources":["../../../../src/api/features/TaskHandlerResolver/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Constructor } from \"@webiny/di\";\nimport type { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface ITaskHandlerResolver {\n resolve<\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n >(\n handler: Constructor<TaskDefinition.Handler<I, O>>\n ): TaskDefinition.Handler<I, O>;\n}\n\n/**\n * Builds the behaviour half of a task on demand.\n *\n * Something has to turn `definition.handler` (a class) into an instance, and that needs the\n * container. Rather than injecting the container into a use case — which is the service-locator\n * pattern we keep out of DI classes — it lives behind this one narrow abstraction. Everything else\n * depends on `resolve(handler)` and stays testable with a stub.\n */\nexport const TaskHandlerResolver = createAbstraction<ITaskHandlerResolver>(\n \"Tasks/TaskHandlerResolver\"\n);\n\nexport namespace TaskHandlerResolver {\n export type Interface = ITaskHandlerResolver;\n}\n"],"names":["TaskHandlerResolver","createAbstraction"],"mappings":";AAqBO,MAAMA,sBAAsBC,kBAC/B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Must be registered on the per-request container, which is what `registerApiRequestStack` does via
|
|
3
|
+
* `BackgroundTasksFeature`. The resolver depends on `RequestContainer`; registered on the root it
|
|
4
|
+
* would capture the root container and never see per-request registrations.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TaskHandlerResolverFeature: {
|
|
7
|
+
name: string;
|
|
8
|
+
register(container: import("@webiny/di").Container): void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { TaskHandlerResolver } from "./TaskHandlerResolver.js";
|
|
3
|
+
const TaskHandlerResolverFeature = createFeature({
|
|
4
|
+
name: "TaskHandlerResolver",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(TaskHandlerResolver);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { TaskHandlerResolverFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/TaskHandlerResolver/feature.js","sources":["../../../../src/api/features/TaskHandlerResolver/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { TaskHandlerResolver } from \"./TaskHandlerResolver.js\";\n\n/**\n * Must be registered on the per-request container, which is what `registerApiRequestStack` does via\n * `BackgroundTasksFeature`. The resolver depends on `RequestContainer`; registered on the root it\n * would capture the root container and never see per-request registrations.\n */\nexport const TaskHandlerResolverFeature = createFeature({\n name: \"TaskHandlerResolver\",\n register(container) {\n container.register(TaskHandlerResolver);\n }\n});\n"],"names":["TaskHandlerResolverFeature","createFeature","container","TaskHandlerResolver"],"mappings":";;AAQO,MAAMA,6BAA6BC,cAAc;IACpD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BaseError, Result } from "@webiny/feature/api";
|
|
2
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
3
|
+
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
4
|
+
import type { IServiceInfo, ITaskAbortParams, ITaskTriggerParams } from "@webiny/api-core/features/task/TaskService/abstractions.js";
|
|
5
|
+
import { TaskService as TaskTransport } from "../../../api/domain/TaskService.js";
|
|
6
|
+
import { GetTaskUseCase } from "../../../api/features/GetTask/index.js";
|
|
7
|
+
import { CreateTaskLogUseCase } from "../../../api/features/CreateTaskLog/index.js";
|
|
8
|
+
import { GetLatestTaskLogUseCase } from "../../../api/features/GetLatestTaskLog/index.js";
|
|
9
|
+
import { UpdateTaskLogUseCase } from "../../../api/features/UpdateTaskLog/index.js";
|
|
10
|
+
import { CreateTaskUseCase } from "../../../api/features/CreateTask/index.js";
|
|
11
|
+
import { UpdateTaskUseCase } from "../../../api/features/UpdateTask/index.js";
|
|
12
|
+
import { DeleteTaskUseCase } from "../../../api/features/DeleteTask/index.js";
|
|
13
|
+
import { GetRunnableTaskDefinitionUseCase } from "../../../api/features/GetRunnableTaskDefinition/index.js";
|
|
14
|
+
type TaskInput = TaskService.TaskInput;
|
|
15
|
+
type TaskOutput = TaskService.GenericOutput;
|
|
16
|
+
/**
|
|
17
|
+
* The public TaskService: stores a task and hands it to the transport (Step Functions, the worker),
|
|
18
|
+
* aborts a running task, and reads what the transport knows about one.
|
|
19
|
+
*/
|
|
20
|
+
declare class BackgroundTaskServiceImpl implements TaskService.Interface {
|
|
21
|
+
private readonly getDefinition;
|
|
22
|
+
private readonly createTask;
|
|
23
|
+
private readonly updateTask;
|
|
24
|
+
private readonly deleteTask;
|
|
25
|
+
private readonly getTask;
|
|
26
|
+
private readonly getLatestTaskLog;
|
|
27
|
+
private readonly createTaskLog;
|
|
28
|
+
private readonly updateTaskLog;
|
|
29
|
+
private readonly transports;
|
|
30
|
+
private readonly logger;
|
|
31
|
+
constructor(getDefinition: GetRunnableTaskDefinitionUseCase.Interface, createTask: CreateTaskUseCase.Interface, updateTask: UpdateTaskUseCase.Interface, deleteTask: DeleteTaskUseCase.Interface, getTask: GetTaskUseCase.Interface, getLatestTaskLog: GetLatestTaskLogUseCase.Interface, createTaskLog: CreateTaskLogUseCase.Interface, updateTaskLog: UpdateTaskLogUseCase.Interface, transports: TaskTransport.Interface[], logger: Logger.Interface);
|
|
32
|
+
trigger<I extends TaskInput = TaskInput, O extends TaskOutput = TaskOutput>(params: ITaskTriggerParams<I>): Promise<Result<TaskService.Task<I, O>, BaseError>>;
|
|
33
|
+
fetchServiceInfo(input: TaskService.Task | string): Promise<Result<IServiceInfo, BaseError>>;
|
|
34
|
+
abort<I extends TaskInput = TaskInput, O extends TaskOutput = TaskOutput>(params: ITaskAbortParams): Promise<Result<TaskService.Task<I, O>, BaseError<any>>>;
|
|
35
|
+
private findTask;
|
|
36
|
+
private getTransport;
|
|
37
|
+
private getOrCreateLog;
|
|
38
|
+
}
|
|
39
|
+
export declare const BackgroundTaskService: typeof BackgroundTaskServiceImpl & {
|
|
40
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskService/abstractions.js").ITaskService>;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { Result } from "@webiny/feature/api";
|
|
3
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
4
|
+
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
5
|
+
import { NotFoundError } from "@webiny/api-graphql";
|
|
6
|
+
import { TaskService as TaskService_js_TaskService } from "../../domain/TaskService.js";
|
|
7
|
+
import { GetTaskUseCase } from "../GetTask/index.js";
|
|
8
|
+
import { CreateTaskLogUseCase } from "../CreateTaskLog/index.js";
|
|
9
|
+
import { GetLatestTaskLogUseCase } from "../GetLatestTaskLog/index.js";
|
|
10
|
+
import { UpdateTaskLogUseCase } from "../UpdateTaskLog/index.js";
|
|
11
|
+
import { CreateTaskUseCase } from "../CreateTask/index.js";
|
|
12
|
+
import { UpdateTaskUseCase } from "../UpdateTask/index.js";
|
|
13
|
+
import { DeleteTaskUseCase } from "../DeleteTask/index.js";
|
|
14
|
+
import { GetRunnableTaskDefinitionUseCase } from "../GetRunnableTaskDefinition/index.js";
|
|
15
|
+
import { TaskAbortError, TaskDefinitionNotFoundError, TaskNotFoundError, TaskServiceInfoError } from "../../domain/errors.js";
|
|
16
|
+
import { TaskDataStatus, TaskLogItemType } from "../../types.js";
|
|
17
|
+
const MAX_DELAY_DAYS = 355;
|
|
18
|
+
const MAX_DELAY_SECONDS = 24 * MAX_DELAY_DAYS * 3600;
|
|
19
|
+
const validateDelay = (input, delay)=>{
|
|
20
|
+
if (!delay || delay < 0 || false === Number.isInteger(delay)) return;
|
|
21
|
+
else if (delay < MAX_DELAY_SECONDS) return;
|
|
22
|
+
throw new error(`The maximum delay for a task is ${MAX_DELAY_DAYS} days.`, "MAX_DELAY_ERROR", {
|
|
23
|
+
...input,
|
|
24
|
+
delay
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
class BackgroundTaskServiceImpl {
|
|
28
|
+
constructor(getDefinition, createTask, updateTask, deleteTask, getTask, getLatestTaskLog, createTaskLog, updateTaskLog, transports, logger){
|
|
29
|
+
this.getDefinition = getDefinition;
|
|
30
|
+
this.createTask = createTask;
|
|
31
|
+
this.updateTask = updateTask;
|
|
32
|
+
this.deleteTask = deleteTask;
|
|
33
|
+
this.getTask = getTask;
|
|
34
|
+
this.getLatestTaskLog = getLatestTaskLog;
|
|
35
|
+
this.createTaskLog = createTaskLog;
|
|
36
|
+
this.updateTaskLog = updateTaskLog;
|
|
37
|
+
this.transports = transports;
|
|
38
|
+
this.logger = logger;
|
|
39
|
+
}
|
|
40
|
+
async trigger(params) {
|
|
41
|
+
const transport = this.getTransport();
|
|
42
|
+
const { definition: id, input: inputValues, name, parent, delay = 0 } = params;
|
|
43
|
+
const definitionResult = this.getDefinition.execute(id);
|
|
44
|
+
if (definitionResult.isFail()) throw new error("Task definition was not found!", "TASK_DEFINITION_ERROR", {
|
|
45
|
+
id
|
|
46
|
+
});
|
|
47
|
+
const definition = definitionResult.value;
|
|
48
|
+
const input = {
|
|
49
|
+
name: name || definition.title,
|
|
50
|
+
definitionId: id,
|
|
51
|
+
input: inputValues || {},
|
|
52
|
+
parentId: parent?.id
|
|
53
|
+
};
|
|
54
|
+
if (definition.onBeforeTrigger) await definition.onBeforeTrigger({
|
|
55
|
+
data: input,
|
|
56
|
+
definition
|
|
57
|
+
});
|
|
58
|
+
validateDelay(input, delay);
|
|
59
|
+
const created = await this.createTask.execute(input);
|
|
60
|
+
if (created.isFail()) {
|
|
61
|
+
this.logger.error({
|
|
62
|
+
error: created.error
|
|
63
|
+
}, "Could not create the task.");
|
|
64
|
+
throw created.error;
|
|
65
|
+
}
|
|
66
|
+
const task = created.value;
|
|
67
|
+
let response = null;
|
|
68
|
+
try {
|
|
69
|
+
response = await transport.send(task, delay);
|
|
70
|
+
if (!response) throw new error("Could not trigger the step function!", "TRIGGER_STEP_FUNCTION_ERROR", {
|
|
71
|
+
task
|
|
72
|
+
});
|
|
73
|
+
} catch (ex) {
|
|
74
|
+
this.logger.error({
|
|
75
|
+
error: ex
|
|
76
|
+
}, "Could not trigger the step function.");
|
|
77
|
+
await this.deleteTask.execute(task.id);
|
|
78
|
+
throw ex;
|
|
79
|
+
}
|
|
80
|
+
const updated = await this.updateTask.execute(task.id, {
|
|
81
|
+
eventResponse: response
|
|
82
|
+
});
|
|
83
|
+
if (updated.isFail()) throw updated.error;
|
|
84
|
+
return Result.ok(updated.value);
|
|
85
|
+
}
|
|
86
|
+
async fetchServiceInfo(input) {
|
|
87
|
+
const transport = this.getTransport();
|
|
88
|
+
const task = "object" == typeof input ? input : await this.findTask(input);
|
|
89
|
+
if (task || "string" != typeof input) {
|
|
90
|
+
if (!task) throw new error("Task was not found!", "TASK_FETCH_ERROR", {
|
|
91
|
+
input
|
|
92
|
+
});
|
|
93
|
+
} else throw new NotFoundError(`Task "${input}" was not found!`);
|
|
94
|
+
try {
|
|
95
|
+
const info = await transport.fetch(task);
|
|
96
|
+
if (info) return Result.ok(info);
|
|
97
|
+
return Result.fail(new TaskServiceInfoError());
|
|
98
|
+
} catch (ex) {
|
|
99
|
+
this.logger.error({
|
|
100
|
+
error: ex
|
|
101
|
+
}, "Service fetch error.");
|
|
102
|
+
return Result.fail(new TaskServiceInfoError());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async abort(params) {
|
|
106
|
+
const taskResult = await this.getTask.execute(params.id);
|
|
107
|
+
if (taskResult.isFail()) return Result.fail(taskResult.error);
|
|
108
|
+
const task = taskResult.value;
|
|
109
|
+
const definitionResult = this.getDefinition.execute(task.definitionId);
|
|
110
|
+
if (definitionResult.isFail()) return Result.fail(new TaskDefinitionNotFoundError(task.definitionId));
|
|
111
|
+
const definition = definitionResult.value;
|
|
112
|
+
if (false === [
|
|
113
|
+
TaskDataStatus.PENDING,
|
|
114
|
+
TaskDataStatus.RUNNING
|
|
115
|
+
].includes(task.taskStatus)) return Result.fail(new TaskAbortError({
|
|
116
|
+
id: params.id,
|
|
117
|
+
status: task.taskStatus
|
|
118
|
+
}));
|
|
119
|
+
const taskLog = await this.getOrCreateLog(task);
|
|
120
|
+
try {
|
|
121
|
+
const updated = await this.updateTask.execute(task.id, {
|
|
122
|
+
taskStatus: TaskDataStatus.ABORTED
|
|
123
|
+
});
|
|
124
|
+
if (updated.isFail()) throw updated.error;
|
|
125
|
+
const logUpdate = await this.updateTaskLog.execute(taskLog.id, {
|
|
126
|
+
items: taskLog.items.concat([
|
|
127
|
+
{
|
|
128
|
+
message: params.message || "Task aborted.",
|
|
129
|
+
type: TaskLogItemType.INFO,
|
|
130
|
+
createdOn: new Date().toISOString()
|
|
131
|
+
}
|
|
132
|
+
])
|
|
133
|
+
});
|
|
134
|
+
if (logUpdate.isFail()) throw logUpdate.error;
|
|
135
|
+
if (definition.onAbort) await definition.onAbort({
|
|
136
|
+
task: updated.value,
|
|
137
|
+
definition
|
|
138
|
+
});
|
|
139
|
+
return Result.ok(updated.value);
|
|
140
|
+
} catch (ex) {
|
|
141
|
+
throw new error("Could not abort the task!", "TASK_ABORT_ERROR", {
|
|
142
|
+
id: params.id,
|
|
143
|
+
message: ex.message
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async findTask(id) {
|
|
148
|
+
const result = await this.getTask.execute(id);
|
|
149
|
+
if (result.isOk()) return result.value;
|
|
150
|
+
else if (result.error instanceof TaskNotFoundError) return null;
|
|
151
|
+
throw result.error;
|
|
152
|
+
}
|
|
153
|
+
getTransport() {
|
|
154
|
+
const transport = this.transports[this.transports.length - 1];
|
|
155
|
+
if (!transport) throw new error("Missing TaskService.", "TASK_SERVICE_ERROR");
|
|
156
|
+
return transport;
|
|
157
|
+
}
|
|
158
|
+
async getOrCreateLog(task) {
|
|
159
|
+
const latest = await this.getLatestTaskLog.execute(task.id);
|
|
160
|
+
if (latest.isOk()) return latest.value;
|
|
161
|
+
const created = await this.createTaskLog.execute(task, {
|
|
162
|
+
iteration: 1,
|
|
163
|
+
executionName: task.executionName
|
|
164
|
+
});
|
|
165
|
+
if (created.isFail()) throw created.error;
|
|
166
|
+
return created.value;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const BackgroundTaskService = TaskService.createImplementation({
|
|
170
|
+
implementation: BackgroundTaskServiceImpl,
|
|
171
|
+
dependencies: [
|
|
172
|
+
GetRunnableTaskDefinitionUseCase,
|
|
173
|
+
CreateTaskUseCase,
|
|
174
|
+
UpdateTaskUseCase,
|
|
175
|
+
DeleteTaskUseCase,
|
|
176
|
+
GetTaskUseCase,
|
|
177
|
+
GetLatestTaskLogUseCase,
|
|
178
|
+
CreateTaskLogUseCase,
|
|
179
|
+
UpdateTaskLogUseCase,
|
|
180
|
+
[
|
|
181
|
+
TaskService_js_TaskService,
|
|
182
|
+
{
|
|
183
|
+
multiple: true
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
Logger
|
|
187
|
+
]
|
|
188
|
+
});
|
|
189
|
+
export { BackgroundTaskService };
|
|
190
|
+
|
|
191
|
+
//# sourceMappingURL=BackgroundTaskService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/TaskService/BackgroundTaskService.js","sources":["../../../../src/api/features/TaskService/BackgroundTaskService.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { BaseError, Result } from \"@webiny/feature/api\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport type {\n IServiceInfo,\n ITaskAbortParams,\n ITaskTriggerParams\n} from \"@webiny/api-core/features/task/TaskService/abstractions.js\";\nimport type { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { NotFoundError } from \"@webiny/api-graphql\";\nimport { TaskService as TaskTransport } from \"~/api/domain/TaskService.js\";\nimport { GetTaskUseCase } from \"~/api/features/GetTask/index.js\";\nimport { CreateTaskLogUseCase } from \"~/api/features/CreateTaskLog/index.js\";\nimport { GetLatestTaskLogUseCase } from \"~/api/features/GetLatestTaskLog/index.js\";\nimport { UpdateTaskLogUseCase } from \"~/api/features/UpdateTaskLog/index.js\";\nimport { CreateTaskUseCase } from \"~/api/features/CreateTask/index.js\";\nimport { UpdateTaskUseCase } from \"~/api/features/UpdateTask/index.js\";\nimport { DeleteTaskUseCase } from \"~/api/features/DeleteTask/index.js\";\nimport { GetRunnableTaskDefinitionUseCase } from \"~/api/features/GetRunnableTaskDefinition/index.js\";\nimport {\n TaskAbortError,\n TaskDefinitionNotFoundError,\n TaskNotFoundError,\n TaskServiceInfoError\n} from \"~/api/domain/errors.js\";\nimport { TaskDataStatus, TaskLogItemType } from \"~/api/types.js\";\nimport type { ITaskLog } from \"~/api/types.js\";\n\ntype TaskInput = TaskService.TaskInput;\ntype TaskOutput = TaskService.GenericOutput;\n\nconst MAX_DELAY_DAYS = 355;\nconst MAX_DELAY_SECONDS = MAX_DELAY_DAYS * 24 * 60 * 60;\n\nconst validateDelay = (input: TaskDefinition.TaskCreateData<any>, delay: number): void => {\n if (!delay || delay < 0 || Number.isInteger(delay) === false) {\n return;\n } else if (delay < MAX_DELAY_SECONDS) {\n return;\n }\n throw new WebinyError(\n `The maximum delay for a task is ${MAX_DELAY_DAYS} days.`,\n \"MAX_DELAY_ERROR\",\n { ...input, delay }\n );\n};\n\n/**\n * The public TaskService: stores a task and hands it to the transport (Step Functions, the worker),\n * aborts a running task, and reads what the transport knows about one.\n */\nclass BackgroundTaskServiceImpl implements TaskService.Interface {\n constructor(\n private readonly getDefinition: GetRunnableTaskDefinitionUseCase.Interface,\n private readonly createTask: CreateTaskUseCase.Interface,\n private readonly updateTask: UpdateTaskUseCase.Interface,\n private readonly deleteTask: DeleteTaskUseCase.Interface,\n private readonly getTask: GetTaskUseCase.Interface,\n private readonly getLatestTaskLog: GetLatestTaskLogUseCase.Interface,\n private readonly createTaskLog: CreateTaskLogUseCase.Interface,\n private readonly updateTaskLog: UpdateTaskLogUseCase.Interface,\n private readonly transports: TaskTransport.Interface[],\n private readonly logger: Logger.Interface\n ) {}\n\n async trigger<I extends TaskInput = TaskInput, O extends TaskOutput = TaskOutput>(\n params: ITaskTriggerParams<I>\n ): Promise<Result<TaskService.Task<I, O>, BaseError>> {\n const transport = this.getTransport();\n const { definition: id, input: inputValues, name, parent, delay = 0 } = params;\n const definitionResult = this.getDefinition.execute(id);\n if (definitionResult.isFail()) {\n throw new WebinyError(`Task definition was not found!`, \"TASK_DEFINITION_ERROR\", {\n id\n });\n }\n const definition = definitionResult.value;\n const input: TaskDefinition.TaskCreateData<I> = {\n name: name || definition.title,\n definitionId: id,\n input: inputValues || ({} as I),\n parentId: parent?.id\n };\n\n if (definition.onBeforeTrigger) {\n await definition.onBeforeTrigger({ data: input, definition });\n }\n validateDelay(input, delay);\n\n const created = await this.createTask.execute<I>(input);\n if (created.isFail()) {\n this.logger.error({ error: created.error }, \"Could not create the task.\");\n throw created.error;\n }\n const task = created.value;\n\n let response: unknown = null;\n try {\n response = await transport.send(task, delay);\n if (!response) {\n throw new WebinyError(\n `Could not trigger the step function!`,\n \"TRIGGER_STEP_FUNCTION_ERROR\",\n { task }\n );\n }\n } catch (ex) {\n this.logger.error({ error: ex }, \"Could not trigger the step function.\");\n // The task can't run, so don't leave it behind as pending.\n await this.deleteTask.execute(task.id);\n throw ex;\n }\n\n const updated = await this.updateTask.execute<I, O>(task.id, {\n eventResponse: response as Record<string, any>\n });\n if (updated.isFail()) {\n throw updated.error;\n }\n\n return Result.ok(updated.value);\n }\n\n async fetchServiceInfo(\n input: TaskService.Task | string\n ): Promise<Result<IServiceInfo, BaseError>> {\n const transport = this.getTransport();\n const task = typeof input === \"object\" ? input : await this.findTask(input);\n if (!task && typeof input === \"string\") {\n throw new NotFoundError(`Task \"${input}\" was not found!`);\n } else if (!task) {\n throw new WebinyError(`Task was not found!`, \"TASK_FETCH_ERROR\", { input });\n }\n\n try {\n const info = (await transport.fetch(task)) as IServiceInfo | null;\n if (info) {\n return Result.ok(info);\n }\n return Result.fail(new TaskServiceInfoError());\n } catch (ex) {\n this.logger.error({ error: ex }, \"Service fetch error.\");\n return Result.fail(new TaskServiceInfoError());\n }\n }\n\n async abort<I extends TaskInput = TaskInput, O extends TaskOutput = TaskOutput>(\n params: ITaskAbortParams\n ): Promise<Result<TaskService.Task<I, O>, BaseError<any>>> {\n const taskResult = await this.getTask.execute<I, O>(params.id);\n if (taskResult.isFail()) {\n return Result.fail(taskResult.error);\n }\n const task = taskResult.value;\n\n const definitionResult = this.getDefinition.execute<I, O>(task.definitionId);\n if (definitionResult.isFail()) {\n return Result.fail(new TaskDefinitionNotFoundError(task.definitionId));\n }\n const definition = definitionResult.value;\n\n // Only a pending or running task can be aborted.\n if ([TaskDataStatus.PENDING, TaskDataStatus.RUNNING].includes(task.taskStatus) === false) {\n return Result.fail(new TaskAbortError({ id: params.id, status: task.taskStatus }));\n }\n\n const taskLog = await this.getOrCreateLog(task);\n try {\n const updated = await this.updateTask.execute<I, O>(task.id, {\n taskStatus: TaskDataStatus.ABORTED\n });\n if (updated.isFail()) {\n throw updated.error;\n }\n const logUpdate = await this.updateTaskLog.execute(taskLog.id, {\n items: taskLog.items.concat([\n {\n message: params.message || \"Task aborted.\",\n type: TaskLogItemType.INFO,\n createdOn: new Date().toISOString()\n }\n ])\n });\n if (logUpdate.isFail()) {\n throw logUpdate.error;\n }\n // TODO: determine when to kick off the onAbort hook\n if (definition.onAbort) {\n await definition.onAbort({ task: updated.value, definition });\n }\n\n return Result.ok(updated.value);\n } catch (ex) {\n throw new WebinyError(`Could not abort the task!`, \"TASK_ABORT_ERROR\", {\n id: params.id,\n message: ex.message\n });\n }\n }\n\n // A missing task is null; any other failure is thrown, so it isn't mistaken for a missing one.\n private async findTask(id: string): Promise<TaskService.Task | null> {\n const result = await this.getTask.execute(id);\n if (result.isOk()) {\n return result.value;\n } else if (result.error instanceof TaskNotFoundError) {\n return null;\n }\n throw result.error;\n }\n\n private getTransport(): TaskTransport.Interface {\n // The last registration wins, so a test or a deployment can swap the transport.\n const transport = this.transports[this.transports.length - 1];\n if (!transport) {\n throw new WebinyError(\"Missing TaskService.\", \"TASK_SERVICE_ERROR\");\n }\n return transport;\n }\n\n private async getOrCreateLog(task: TaskService.Task<any, any>): Promise<ITaskLog> {\n const latest = await this.getLatestTaskLog.execute(task.id);\n if (latest.isOk()) {\n return latest.value;\n }\n const created = await this.createTaskLog.execute(task, {\n iteration: 1,\n executionName: task.executionName\n });\n if (created.isFail()) {\n throw created.error;\n }\n return created.value;\n }\n}\n\nexport const BackgroundTaskService = TaskService.createImplementation({\n implementation: BackgroundTaskServiceImpl,\n dependencies: [\n GetRunnableTaskDefinitionUseCase,\n CreateTaskUseCase,\n UpdateTaskUseCase,\n DeleteTaskUseCase,\n GetTaskUseCase,\n GetLatestTaskLogUseCase,\n CreateTaskLogUseCase,\n UpdateTaskLogUseCase,\n [TaskTransport, { multiple: true }],\n Logger\n ]\n});\n"],"names":["MAX_DELAY_DAYS","MAX_DELAY_SECONDS","validateDelay","input","delay","Number","WebinyError","BackgroundTaskServiceImpl","getDefinition","createTask","updateTask","deleteTask","getTask","getLatestTaskLog","createTaskLog","updateTaskLog","transports","logger","params","transport","id","inputValues","name","parent","definitionResult","definition","created","task","response","ex","updated","Result","NotFoundError","info","TaskServiceInfoError","taskResult","TaskDefinitionNotFoundError","TaskDataStatus","TaskAbortError","taskLog","logUpdate","TaskLogItemType","Date","result","TaskNotFoundError","latest","BackgroundTaskService","TaskService","GetRunnableTaskDefinitionUseCase","CreateTaskUseCase","UpdateTaskUseCase","DeleteTaskUseCase","GetTaskUseCase","GetLatestTaskLogUseCase","CreateTaskLogUseCase","UpdateTaskLogUseCase","TaskTransport","Logger"],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { BackgroundTaskService } from "./BackgroundTaskService.js";
|
|
3
|
+
const BackgroundTaskServiceFeature = createFeature({
|
|
4
|
+
name: "BackgroundTaskService",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(BackgroundTaskService);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { BackgroundTaskServiceFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/TaskService/feature.js","sources":["../../../../src/api/features/TaskService/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { BackgroundTaskService } from \"./BackgroundTaskService.js\";\n\nexport const BackgroundTaskServiceFeature = createFeature({\n name: \"BackgroundTaskService\",\n register(container) {\n container.register(BackgroundTaskService);\n }\n});\n"],"names":["BackgroundTaskServiceFeature","createFeature","container","BackgroundTaskService"],"mappings":";;AAGO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BackgroundTaskServiceFeature } from "./feature.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BackgroundTaskServiceFeature } from "./feature.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { TriggerVisibleTaskUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
3
|
+
import { TriggerTaskUseCase } from "../../../api/features/TriggerTask/abstractions.js";
|
|
4
|
+
import { GetRunnableTaskDefinitionUseCase } from "../../../api/features/GetRunnableTaskDefinition/abstractions.js";
|
|
5
|
+
import { TaskDefinitionNotFoundError } from "../../../api/domain/errors.js";
|
|
6
|
+
declare class TriggerVisibleTaskUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
7
|
+
private readonly triggerTask;
|
|
8
|
+
private readonly getRunnableTaskDefinition;
|
|
9
|
+
constructor(triggerTask: TriggerTaskUseCase.Interface, getRunnableTaskDefinition: GetRunnableTaskDefinitionUseCase.Interface);
|
|
10
|
+
execute(params: TriggerTaskUseCase.Params): Promise<Result<import("@webiny/api-core/features/task/TaskService/abstractions.js").TaskService.Task<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskInput, import("@webiny/api-core/features/task/TaskService/abstractions.js").IGenericOutput>, TaskDefinitionNotFoundError | import("~/api/domain/errors.js").TaskNotFoundError | import("~/api/domain/errors.js").TaskServiceInfoError>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const TriggerVisibleTaskUseCase: typeof TriggerVisibleTaskUseCaseImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ITriggerVisibleTaskUseCase>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { TriggerVisibleTaskUseCase } from "./abstractions.js";
|
|
3
|
+
import { TriggerTaskUseCase } from "../TriggerTask/abstractions.js";
|
|
4
|
+
import { GetRunnableTaskDefinitionUseCase } from "../GetRunnableTaskDefinition/abstractions.js";
|
|
5
|
+
import { TaskDefinitionNotFoundError } from "../../domain/errors.js";
|
|
6
|
+
class TriggerVisibleTaskUseCaseImpl {
|
|
7
|
+
constructor(triggerTask, getRunnableTaskDefinition){
|
|
8
|
+
this.triggerTask = triggerTask;
|
|
9
|
+
this.getRunnableTaskDefinition = getRunnableTaskDefinition;
|
|
10
|
+
}
|
|
11
|
+
async execute(params) {
|
|
12
|
+
const definition = this.getRunnableTaskDefinition.execute(params.definition);
|
|
13
|
+
if (definition.isFail() || definition.value.isPrivate) return Result.fail(new TaskDefinitionNotFoundError(params.definition));
|
|
14
|
+
return this.triggerTask.execute(params);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const TriggerVisibleTaskUseCase_TriggerVisibleTaskUseCase = TriggerVisibleTaskUseCase.createImplementation({
|
|
18
|
+
implementation: TriggerVisibleTaskUseCaseImpl,
|
|
19
|
+
dependencies: [
|
|
20
|
+
TriggerTaskUseCase,
|
|
21
|
+
GetRunnableTaskDefinitionUseCase
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { TriggerVisibleTaskUseCase_TriggerVisibleTaskUseCase as TriggerVisibleTaskUseCase };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=TriggerVisibleTaskUseCase.js.map
|