@webiny/background-tasks 6.6.0-alpha.1 → 6.6.0-alpha.11
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/api/BackgroundTasksFeature.js +42 -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/SelfCleaningTaskHandlerDecorator.d.ts +33 -0
- package/api/decorators/{SelfCleaningTaskDecorator.js → SelfCleaningTaskHandlerDecorator.js} +15 -39
- package/api/decorators/SelfCleaningTaskHandlerDecorator.js.map +1 -0
- package/api/decorators/TaskDefinitionDefaultsDecorator.d.ts +27 -0
- package/api/decorators/{RunnableTaskDecorator.js → TaskDefinitionDefaultsDecorator.js} +11 -32
- package/api/decorators/TaskDefinitionDefaultsDecorator.js.map +1 -0
- package/api/domain/errors.d.ts +14 -10
- package/api/domain/errors.js +27 -12
- 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/AbortTask/abstractions.d.ts +4 -0
- package/api/features/AbortTask/abstractions.js.map +1 -1
- 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/{GetTaskDefinition/GetTaskDefinitionUseCase.d.ts → GetRunnableTaskDefinition/GetRunnableTaskDefinitionUseCase.d.ts} +5 -7
- 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 +7 -8
- 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/TaskService/BackgroundTaskService.d.ts +42 -0
- package/api/features/TaskService/BackgroundTaskService.js +211 -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/TriggerTask/abstractions.d.ts +6 -0
- package/api/features/TriggerTask/abstractions.js.map +1 -1
- 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 +14 -4
- package/api/runner/TaskControl.js +29 -29
- package/api/runner/TaskControl.js.map +1 -1
- package/api/runner/TaskManager.js +3 -3
- package/api/runner/TaskManager.js.map +1 -1
- package/api/runner/TaskManagerStore.d.ts +14 -5
- package/api/runner/TaskManagerStore.js +23 -7
- package/api/runner/TaskManagerStore.js.map +1 -1
- package/api/runner/TaskRunner.js +14 -4
- package/api/runner/TaskRunner.js.map +1 -1
- package/api/types.d.ts +1 -48
- package/api/types.js.map +1 -1
- package/package.json +28 -30
- 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 -134
- package/api/crud/service.tasks.js.map +0 -1
- package/api/decorators/RunnableTaskDecorator.d.ts +0 -33
- package/api/decorators/RunnableTaskDecorator.js.map +0 -1
- package/api/decorators/SelfCleaningTaskDecorator.d.ts +0 -33
- package/api/decorators/SelfCleaningTaskDecorator.js.map +0 -1
- package/api/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +0 -88
- 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,59 +1,77 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { SelfCleaningTaskDecorator } from "./decorators/SelfCleaningTaskDecorator.js";
|
|
2
|
+
import { TaskDefinitionDefaultsDecorator } from "./decorators/TaskDefinitionDefaultsDecorator.js";
|
|
3
|
+
import { SelfCleaningTaskHandlerDecorator } from "./decorators/SelfCleaningTaskHandlerDecorator.js";
|
|
5
4
|
import { TaskController } from "./features/TaskController/index.js";
|
|
6
5
|
import { TaskPrivateModel } from "./crud/TaskPrivateModel.js";
|
|
7
6
|
import { TaskLogPrivateModel } from "./crud/TaskLogPrivateModel.js";
|
|
8
7
|
import { BackgroundTaskSettingsModel } from "./models/BackgroundTaskSettingsModel.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { TaskModelProvider } from "./domain/task/TaskModelProvider.js";
|
|
9
|
+
import { TaskLogModelProvider } from "./domain/task/TaskLogModelProvider.js";
|
|
10
|
+
import { TasksRepository } from "./domain/task/TasksRepository.js";
|
|
11
|
+
import { TaskLogsRepository } from "./domain/task/TaskLogsRepository.js";
|
|
12
12
|
import { TaskExecutionContextFeature } from "./features/TaskExecutionContext/feature.js";
|
|
13
13
|
import { TaskHandlerResolverFeature } from "./features/TaskHandlerResolver/feature.js";
|
|
14
|
-
import {
|
|
14
|
+
import { GetRunnableTaskDefinitionFeature } from "./features/GetRunnableTaskDefinition/feature.js";
|
|
15
15
|
import { ListTaskDefinitionsFeature } from "./features/ListTaskDefinitions/feature.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { CleanupTaskSubtreeFeature } from "./features/CleanupTaskSubtree/index.js";
|
|
17
|
+
import { CreateTaskFeature } from "./features/CreateTask/index.js";
|
|
18
|
+
import { UpdateTaskFeature } from "./features/UpdateTask/index.js";
|
|
19
|
+
import { DeleteTaskFeature } from "./features/DeleteTask/index.js";
|
|
20
|
+
import { BackgroundTaskServiceFeature } from "./features/TaskService/index.js";
|
|
21
|
+
import { CreateTaskLogFeature } from "./features/CreateTaskLog/index.js";
|
|
22
|
+
import { UpdateTaskLogFeature } from "./features/UpdateTaskLog/index.js";
|
|
23
|
+
import { DeleteTaskLogFeature } from "./features/DeleteTaskLog/index.js";
|
|
24
|
+
import { GetLatestTaskLogFeature } from "./features/GetLatestTaskLog/index.js";
|
|
25
|
+
import { ListTaskLogsFeature } from "./features/ListTaskLogs/index.js";
|
|
18
26
|
import { TriggerTaskFeature } from "./features/TriggerTask/feature.js";
|
|
19
27
|
import { AbortTaskFeature } from "./features/AbortTask/feature.js";
|
|
20
28
|
import { GetTaskFeature } from "./features/GetTask/feature.js";
|
|
29
|
+
import { TriggerVisibleTaskFeature } from "./features/TriggerVisibleTask/feature.js";
|
|
30
|
+
import { ListVisibleTaskDefinitionsFeature } from "./features/ListVisibleTaskDefinitions/feature.js";
|
|
21
31
|
import { ListTasksFeature } from "./features/ListTasks/feature.js";
|
|
22
32
|
import { TestingRunTaskDefinition } from "./tasks/testingRunTask.js";
|
|
23
33
|
import { BackgroundTaskPermissionsFeature } from "./features/BackgroundTaskPermissions/feature.js";
|
|
24
34
|
import { GetBackgroundTaskSettingsFeature } from "./features/GetBackgroundTaskSettings/feature.js";
|
|
25
35
|
import { UpdateBackgroundTaskSettingsFeature } from "./features/UpdateBackgroundTaskSettings/feature.js";
|
|
26
|
-
import {
|
|
36
|
+
import { BackgroundTasksGraphQLSchema } from "./graphql/BackgroundTasksGraphQLSchema.js";
|
|
27
37
|
const BackgroundTasksFeature = createFeature({
|
|
28
38
|
name: "BackgroundTasks",
|
|
29
39
|
register (container) {
|
|
30
40
|
container.register(TaskPrivateModel);
|
|
31
41
|
container.register(TaskLogPrivateModel);
|
|
32
42
|
container.register(BackgroundTaskSettingsModel);
|
|
33
|
-
container.registerDecorator(
|
|
34
|
-
container.registerDecorator(
|
|
43
|
+
container.registerDecorator(TaskDefinitionDefaultsDecorator);
|
|
44
|
+
container.registerDecorator(SelfCleaningTaskHandlerDecorator);
|
|
35
45
|
TaskHandlerResolverFeature.register(container);
|
|
36
|
-
|
|
46
|
+
GetRunnableTaskDefinitionFeature.register(container);
|
|
37
47
|
ListTaskDefinitionsFeature.register(container);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
container.registerInstance(TasksCrud, tasksCrud);
|
|
44
|
-
container.registerInstance(TaskService, tasksCrud);
|
|
45
|
-
TriggerTaskFeature.register(container);
|
|
46
|
-
AbortTaskFeature.register(container);
|
|
48
|
+
container.register(TaskModelProvider);
|
|
49
|
+
container.register(TaskLogModelProvider);
|
|
50
|
+
container.register(TasksRepository);
|
|
51
|
+
container.register(TaskLogsRepository);
|
|
47
52
|
GetTaskFeature.register(container);
|
|
48
53
|
ListTasksFeature.register(container);
|
|
49
|
-
|
|
54
|
+
CreateTaskFeature.register(container);
|
|
55
|
+
UpdateTaskFeature.register(container);
|
|
56
|
+
DeleteTaskFeature.register(container);
|
|
57
|
+
CleanupTaskSubtreeFeature.register(container);
|
|
58
|
+
CreateTaskLogFeature.register(container);
|
|
59
|
+
UpdateTaskLogFeature.register(container);
|
|
60
|
+
DeleteTaskLogFeature.register(container);
|
|
61
|
+
GetLatestTaskLogFeature.register(container);
|
|
62
|
+
ListTaskLogsFeature.register(container);
|
|
63
|
+
BackgroundTaskServiceFeature.register(container);
|
|
64
|
+
TriggerTaskFeature.register(container);
|
|
65
|
+
AbortTaskFeature.register(container);
|
|
66
|
+
TriggerVisibleTaskFeature.register(container);
|
|
67
|
+
ListVisibleTaskDefinitionsFeature.register(container);
|
|
50
68
|
TaskExecutionContextFeature.register(container);
|
|
51
69
|
container.register(TaskController);
|
|
52
70
|
container.register(TestingRunTaskDefinition);
|
|
53
71
|
BackgroundTaskPermissionsFeature.register(container);
|
|
54
72
|
GetBackgroundTaskSettingsFeature.register(container);
|
|
55
73
|
UpdateBackgroundTaskSettingsFeature.register(container);
|
|
56
|
-
container.register(
|
|
74
|
+
container.register(BackgroundTasksGraphQLSchema);
|
|
57
75
|
}
|
|
58
76
|
});
|
|
59
77
|
export { BackgroundTasksFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/BackgroundTasksFeature.js","sources":["../../src/api/BackgroundTasksFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport {
|
|
1
|
+
{"version":3,"file":"api/BackgroundTasksFeature.js","sources":["../../src/api/BackgroundTasksFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { TaskDefinitionDefaultsDecorator } from \"./decorators/TaskDefinitionDefaultsDecorator.js\";\nimport { SelfCleaningTaskHandlerDecorator } from \"./decorators/SelfCleaningTaskHandlerDecorator.js\";\nimport { TaskController } from \"./features/TaskController/index.js\";\nimport { TaskPrivateModel } from \"./crud/TaskPrivateModel.js\";\nimport { TaskLogPrivateModel } from \"./crud/TaskLogPrivateModel.js\";\nimport { BackgroundTaskSettingsModel } from \"./models/BackgroundTaskSettingsModel.js\";\nimport { TaskModelProvider } from \"./domain/task/TaskModelProvider.js\";\nimport { TaskLogModelProvider } from \"./domain/task/TaskLogModelProvider.js\";\nimport { TasksRepository } from \"./domain/task/TasksRepository.js\";\nimport { TaskLogsRepository } from \"./domain/task/TaskLogsRepository.js\";\nimport { TaskExecutionContextFeature } from \"./features/TaskExecutionContext/feature.js\";\nimport { TaskHandlerResolverFeature } from \"./features/TaskHandlerResolver/feature.js\";\nimport { GetRunnableTaskDefinitionFeature } from \"./features/GetRunnableTaskDefinition/feature.js\";\nimport { ListTaskDefinitionsFeature } from \"./features/ListTaskDefinitions/feature.js\";\nimport { CleanupTaskSubtreeFeature } from \"./features/CleanupTaskSubtree/index.js\";\nimport { CreateTaskFeature } from \"./features/CreateTask/index.js\";\nimport { UpdateTaskFeature } from \"./features/UpdateTask/index.js\";\nimport { DeleteTaskFeature } from \"./features/DeleteTask/index.js\";\nimport { BackgroundTaskServiceFeature } from \"./features/TaskService/index.js\";\nimport { CreateTaskLogFeature } from \"./features/CreateTaskLog/index.js\";\nimport { UpdateTaskLogFeature } from \"./features/UpdateTaskLog/index.js\";\nimport { DeleteTaskLogFeature } from \"./features/DeleteTaskLog/index.js\";\nimport { GetLatestTaskLogFeature } from \"./features/GetLatestTaskLog/index.js\";\nimport { ListTaskLogsFeature } from \"./features/ListTaskLogs/index.js\";\nimport { TriggerTaskFeature } from \"./features/TriggerTask/feature.js\";\nimport { AbortTaskFeature } from \"./features/AbortTask/feature.js\";\nimport { GetTaskFeature } from \"./features/GetTask/feature.js\";\nimport { TriggerVisibleTaskFeature } from \"./features/TriggerVisibleTask/feature.js\";\nimport { ListVisibleTaskDefinitionsFeature } from \"./features/ListVisibleTaskDefinitions/feature.js\";\nimport { ListTasksFeature } from \"./features/ListTasks/feature.js\";\nimport { TestingRunTaskDefinition } from \"./tasks/testingRunTask.js\";\nimport { BackgroundTaskPermissionsFeature } from \"./features/BackgroundTaskPermissions/feature.js\";\nimport { GetBackgroundTaskSettingsFeature } from \"./features/GetBackgroundTaskSettings/feature.js\";\nimport { UpdateBackgroundTaskSettingsFeature } from \"./features/UpdateBackgroundTaskSettings/feature.js\";\nimport { BackgroundTasksGraphQLSchema } from \"./graphql/BackgroundTasksGraphQLSchema.js\";\n\nexport const BackgroundTasksFeature = createFeature({\n name: \"BackgroundTasks\",\n register(container) {\n // Register models at register() time so they are available to GetModelUseCase when the\n // ModelsFetcher cache is first filled (which may happen during an earlier feature's enhance).\n container.register(TaskPrivateModel);\n container.register(TaskLogPrivateModel);\n container.register(BackgroundTaskSettingsModel);\n\n // Metadata rules, applied to every registered TaskDefinition.\n container.registerDecorator(TaskDefinitionDefaultsDecorator);\n\n // Self-cleanup runs in the lifecycle hooks, which belong to the handler. Applied when the\n // runner resolves the handler a definition names.\n container.registerDecorator(SelfCleaningTaskHandlerDecorator);\n\n // Task definition use cases.\n TaskHandlerResolverFeature.register(container);\n GetRunnableTaskDefinitionFeature.register(container);\n ListTaskDefinitionsFeature.register(container);\n\n // Task and log storage.\n container.register(TaskModelProvider);\n container.register(TaskLogModelProvider);\n container.register(TasksRepository);\n container.register(TaskLogsRepository);\n\n // Task use cases, and the public TaskService (trigger, abort, service info) on top of them.\n GetTaskFeature.register(container);\n ListTasksFeature.register(container);\n CreateTaskFeature.register(container);\n UpdateTaskFeature.register(container);\n DeleteTaskFeature.register(container);\n CleanupTaskSubtreeFeature.register(container);\n CreateTaskLogFeature.register(container);\n UpdateTaskLogFeature.register(container);\n DeleteTaskLogFeature.register(container);\n GetLatestTaskLogFeature.register(container);\n ListTaskLogsFeature.register(container);\n BackgroundTaskServiceFeature.register(container);\n TriggerTaskFeature.register(container);\n AbortTaskFeature.register(container);\n\n // The GraphQL API's use cases: private definitions cannot be started or listed; their\n // runs are visible like any other.\n TriggerVisibleTaskFeature.register(container);\n ListVisibleTaskDefinitionsFeature.register(container);\n\n // Execution context (singleton), controller, and the built-in test task.\n TaskExecutionContextFeature.register(container);\n container.register(TaskController);\n container.register(TestingRunTaskDefinition);\n\n // Permissions + settings features.\n BackgroundTaskPermissionsFeature.register(container);\n GetBackgroundTaskSettingsFeature.register(container);\n UpdateBackgroundTaskSettingsFeature.register(container);\n\n // GraphQL schema, rendered from the CMS task/log content models.\n container.register(BackgroundTasksGraphQLSchema);\n }\n});\n"],"names":["BackgroundTasksFeature","createFeature","container","TaskPrivateModel","TaskLogPrivateModel","BackgroundTaskSettingsModel","TaskDefinitionDefaultsDecorator","SelfCleaningTaskHandlerDecorator","TaskHandlerResolverFeature","GetRunnableTaskDefinitionFeature","ListTaskDefinitionsFeature","TaskModelProvider","TaskLogModelProvider","TasksRepository","TaskLogsRepository","GetTaskFeature","ListTasksFeature","CreateTaskFeature","UpdateTaskFeature","DeleteTaskFeature","CleanupTaskSubtreeFeature","CreateTaskLogFeature","UpdateTaskLogFeature","DeleteTaskLogFeature","GetLatestTaskLogFeature","ListTaskLogsFeature","BackgroundTaskServiceFeature","TriggerTaskFeature","AbortTaskFeature","TriggerVisibleTaskFeature","ListVisibleTaskDefinitionsFeature","TaskExecutionContextFeature","TaskController","TestingRunTaskDefinition","BackgroundTaskPermissionsFeature","GetBackgroundTaskSettingsFeature","UpdateBackgroundTaskSettingsFeature","BackgroundTasksGraphQLSchema"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QAGdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QAGnBH,UAAU,iBAAiB,CAACI;QAI5BJ,UAAU,iBAAiB,CAACK;QAG5BC,2BAA2B,QAAQ,CAACN;QACpCO,iCAAiC,QAAQ,CAACP;QAC1CQ,2BAA2B,QAAQ,CAACR;QAGpCA,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;QAGnBC,eAAe,QAAQ,CAACb;QACxBc,iBAAiB,QAAQ,CAACd;QAC1Be,kBAAkB,QAAQ,CAACf;QAC3BgB,kBAAkB,QAAQ,CAAChB;QAC3BiB,kBAAkB,QAAQ,CAACjB;QAC3BkB,0BAA0B,QAAQ,CAAClB;QACnCmB,qBAAqB,QAAQ,CAACnB;QAC9BoB,qBAAqB,QAAQ,CAACpB;QAC9BqB,qBAAqB,QAAQ,CAACrB;QAC9BsB,wBAAwB,QAAQ,CAACtB;QACjCuB,oBAAoB,QAAQ,CAACvB;QAC7BwB,6BAA6B,QAAQ,CAACxB;QACtCyB,mBAAmB,QAAQ,CAACzB;QAC5B0B,iBAAiB,QAAQ,CAAC1B;QAI1B2B,0BAA0B,QAAQ,CAAC3B;QACnC4B,kCAAkC,QAAQ,CAAC5B;QAG3C6B,4BAA4B,QAAQ,CAAC7B;QACrCA,UAAU,QAAQ,CAAC8B;QACnB9B,UAAU,QAAQ,CAAC+B;QAGnBC,iCAAiC,QAAQ,CAAChC;QAC1CiC,iCAAiC,QAAQ,CAACjC;QAC1CkC,oCAAoC,QAAQ,CAAClC;QAG7CA,UAAU,QAAQ,CAACmC;IACvB;AACJ"}
|
|
@@ -6,7 +6,8 @@ class TaskLogPrivateModelImpl {
|
|
|
6
6
|
return [
|
|
7
7
|
builder.private({
|
|
8
8
|
modelId: WEBINY_TASK_LOG_MODEL_ID,
|
|
9
|
-
name: "Webiny Task Log"
|
|
9
|
+
name: "Webiny Task Log",
|
|
10
|
+
lifecycleEvents: false
|
|
10
11
|
}).fields((fields)=>({
|
|
11
12
|
executionName: fields.text().label("Execution Name"),
|
|
12
13
|
task: fields.text().label("Task").required("Task is required."),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/crud/TaskLogPrivateModel.js","sources":["../../../src/api/crud/TaskLogPrivateModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\nimport { TaskLogItemType } from \"~/api/types.js\";\n\nexport const WEBINY_TASK_LOG_MODEL_ID = \"wbyTaskLog\";\n\nclass TaskLogPrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: WEBINY_TASK_LOG_MODEL_ID,\n name: \"Webiny Task Log\"\n })\n .fields(fields => ({\n executionName: fields.text().label(\"Execution Name\"),\n task: fields.text().label(\"Task\").required(\"Task is required.\"),\n iteration: fields\n .number()\n .label(\"Iteration\")\n .required(\"Iteration is required.\"),\n items: fields\n .object()\n .label(\"Items\")\n .list()\n .required(\"Items is required.\")\n .fields(fields => ({\n message: fields\n .text()\n .label(\"Message\")\n .required(\"Message is required.\"),\n createdOn: fields\n .datetime()\n .label(\"Created On\")\n .required(\"Created On is required.\"),\n type: fields\n .text()\n .label(\"Type\")\n .required(\"Type is required.\")\n .predefinedValues([\n {\n value: TaskLogItemType.INFO,\n label: \"Info\"\n },\n {\n value: TaskLogItemType.ERROR,\n label: \"Error\"\n }\n ]),\n data: fields.json().label(\"Data\"),\n error: fields.json().label(\"Error\")\n }))\n }))\n ];\n }\n}\n\nexport const TaskLogPrivateModel = ModelFactory.createImplementation({\n implementation: TaskLogPrivateModelImpl,\n dependencies: []\n});\n"],"names":["WEBINY_TASK_LOG_MODEL_ID","TaskLogPrivateModelImpl","builder","fields","TaskLogItemType","TaskLogPrivateModel","ModelFactory"],"mappings":";;AAGO,MAAMA,2BAA2B;AAExC,MAAMC;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASF;gBACT,MAAM;
|
|
1
|
+
{"version":3,"file":"api/crud/TaskLogPrivateModel.js","sources":["../../../src/api/crud/TaskLogPrivateModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\nimport { TaskLogItemType } from \"~/api/types.js\";\n\nexport const WEBINY_TASK_LOG_MODEL_ID = \"wbyTaskLog\";\n\nclass TaskLogPrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: WEBINY_TASK_LOG_MODEL_ID,\n name: \"Webiny Task Log\",\n lifecycleEvents: false\n })\n .fields(fields => ({\n executionName: fields.text().label(\"Execution Name\"),\n task: fields.text().label(\"Task\").required(\"Task is required.\"),\n iteration: fields\n .number()\n .label(\"Iteration\")\n .required(\"Iteration is required.\"),\n items: fields\n .object()\n .label(\"Items\")\n .list()\n .required(\"Items is required.\")\n .fields(fields => ({\n message: fields\n .text()\n .label(\"Message\")\n .required(\"Message is required.\"),\n createdOn: fields\n .datetime()\n .label(\"Created On\")\n .required(\"Created On is required.\"),\n type: fields\n .text()\n .label(\"Type\")\n .required(\"Type is required.\")\n .predefinedValues([\n {\n value: TaskLogItemType.INFO,\n label: \"Info\"\n },\n {\n value: TaskLogItemType.ERROR,\n label: \"Error\"\n }\n ]),\n data: fields.json().label(\"Data\"),\n error: fields.json().label(\"Error\")\n }))\n }))\n ];\n }\n}\n\nexport const TaskLogPrivateModel = ModelFactory.createImplementation({\n implementation: TaskLogPrivateModelImpl,\n dependencies: []\n});\n"],"names":["WEBINY_TASK_LOG_MODEL_ID","TaskLogPrivateModelImpl","builder","fields","TaskLogItemType","TaskLogPrivateModel","ModelFactory"],"mappings":";;AAGO,MAAMA,2BAA2B;AAExC,MAAMC;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASF;gBACT,MAAM;gBACN,iBAAiB;YACrB,GACC,MAAM,CAACG,CAAAA,SAAW;oBACf,eAAeA,OAAO,IAAI,GAAG,KAAK,CAAC;oBACnC,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC,QAAQ,QAAQ,CAAC;oBAC3C,WAAWA,OACN,MAAM,GACN,KAAK,CAAC,aACN,QAAQ,CAAC;oBACd,OAAOA,OACF,MAAM,GACN,KAAK,CAAC,SACN,IAAI,GACJ,QAAQ,CAAC,sBACT,MAAM,CAACA,CAAAA,SAAW;4BACf,SAASA,OACJ,IAAI,GACJ,KAAK,CAAC,WACN,QAAQ,CAAC;4BACd,WAAWA,OACN,QAAQ,GACR,KAAK,CAAC,cACN,QAAQ,CAAC;4BACd,MAAMA,OACD,IAAI,GACJ,KAAK,CAAC,QACN,QAAQ,CAAC,qBACT,gBAAgB,CAAC;gCACd;oCACI,OAAOC,gBAAgB,IAAI;oCAC3B,OAAO;gCACX;gCACA;oCACI,OAAOA,gBAAgB,KAAK;oCAC5B,OAAO;gCACX;6BACH;4BACL,MAAMD,OAAO,IAAI,GAAG,KAAK,CAAC;4BAC1B,OAAOA,OAAO,IAAI,GAAG,KAAK,CAAC;wBAC/B;gBACR;SACP;IACL;AACJ;AAEO,MAAME,sBAAsBC,aAAa,oBAAoB,CAAC;IACjE,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -6,7 +6,8 @@ class TaskPrivateModelImpl {
|
|
|
6
6
|
return [
|
|
7
7
|
builder.private({
|
|
8
8
|
modelId: WEBINY_TASK_MODEL_ID,
|
|
9
|
-
name: "Webiny Task"
|
|
9
|
+
name: "Webiny Task",
|
|
10
|
+
lifecycleEvents: false
|
|
10
11
|
}).fields((fields)=>({
|
|
11
12
|
name: fields.text().label("Name").required("Name is required."),
|
|
12
13
|
definitionId: fields.text().label("Definition ID").required("Definition ID is required."),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/crud/TaskPrivateModel.js","sources":["../../../src/api/crud/TaskPrivateModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\nimport { TaskDataStatus } from \"~/api/types.js\";\n\nexport const WEBINY_TASK_MODEL_ID = \"wbyTask\";\n\nclass TaskPrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: WEBINY_TASK_MODEL_ID,\n name: \"Webiny Task\"\n })\n .fields(fields => ({\n name: fields.text().label(\"Name\").required(\"Name is required.\"),\n definitionId: fields\n .text()\n .label(\"Definition ID\")\n .required(\"Definition ID is required.\"),\n parentId: fields.text().label(\"Parent ID\"),\n executionName: fields.text().label(\"Execution Name\"),\n iterations: fields.number().label(\"Iterations\"),\n input: fields.json().label(\"Input\"),\n output: fields.json().label(\"Output\"),\n taskStatus: fields\n .text()\n .label(\"Status\")\n .predefinedValues([\n {\n value: TaskDataStatus.PENDING,\n label: \"Pending\"\n },\n {\n value: TaskDataStatus.RUNNING,\n label: \"Running\"\n },\n {\n value: TaskDataStatus.FAILED,\n label: \"Failed\"\n },\n {\n value: TaskDataStatus.SUCCESS,\n label: \"Success\"\n },\n {\n value: TaskDataStatus.ABORTED,\n label: \"Aborted\"\n }\n ])\n .settings({ defaultValue: TaskDataStatus.PENDING }),\n startedOn: fields.datetime().label(\"Started On\"),\n finishedOn: fields.datetime().label(\"Finished On\"),\n eventResponse: fields.json().label(\"Event Response\")\n }))\n ];\n }\n}\n\nexport const TaskPrivateModel = ModelFactory.createImplementation({\n implementation: TaskPrivateModelImpl,\n dependencies: []\n});\n"],"names":["WEBINY_TASK_MODEL_ID","TaskPrivateModelImpl","builder","fields","TaskDataStatus","TaskPrivateModel","ModelFactory"],"mappings":";;AAGO,MAAMA,uBAAuB;AAEpC,MAAMC;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASF;gBACT,MAAM;
|
|
1
|
+
{"version":3,"file":"api/crud/TaskPrivateModel.js","sources":["../../../src/api/crud/TaskPrivateModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\nimport { TaskDataStatus } from \"~/api/types.js\";\n\nexport const WEBINY_TASK_MODEL_ID = \"wbyTask\";\n\nclass TaskPrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: WEBINY_TASK_MODEL_ID,\n name: \"Webiny Task\",\n lifecycleEvents: false\n })\n .fields(fields => ({\n name: fields.text().label(\"Name\").required(\"Name is required.\"),\n definitionId: fields\n .text()\n .label(\"Definition ID\")\n .required(\"Definition ID is required.\"),\n parentId: fields.text().label(\"Parent ID\"),\n executionName: fields.text().label(\"Execution Name\"),\n iterations: fields.number().label(\"Iterations\"),\n input: fields.json().label(\"Input\"),\n output: fields.json().label(\"Output\"),\n taskStatus: fields\n .text()\n .label(\"Status\")\n .predefinedValues([\n {\n value: TaskDataStatus.PENDING,\n label: \"Pending\"\n },\n {\n value: TaskDataStatus.RUNNING,\n label: \"Running\"\n },\n {\n value: TaskDataStatus.FAILED,\n label: \"Failed\"\n },\n {\n value: TaskDataStatus.SUCCESS,\n label: \"Success\"\n },\n {\n value: TaskDataStatus.ABORTED,\n label: \"Aborted\"\n }\n ])\n .settings({ defaultValue: TaskDataStatus.PENDING }),\n startedOn: fields.datetime().label(\"Started On\"),\n finishedOn: fields.datetime().label(\"Finished On\"),\n eventResponse: fields.json().label(\"Event Response\")\n }))\n ];\n }\n}\n\nexport const TaskPrivateModel = ModelFactory.createImplementation({\n implementation: TaskPrivateModelImpl,\n dependencies: []\n});\n"],"names":["WEBINY_TASK_MODEL_ID","TaskPrivateModelImpl","builder","fields","TaskDataStatus","TaskPrivateModel","ModelFactory"],"mappings":";;AAGO,MAAMA,uBAAuB;AAEpC,MAAMC;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASF;gBACT,MAAM;gBACN,iBAAiB;YACrB,GACC,MAAM,CAACG,CAAAA,SAAW;oBACf,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC,QAAQ,QAAQ,CAAC;oBAC3C,cAAcA,OACT,IAAI,GACJ,KAAK,CAAC,iBACN,QAAQ,CAAC;oBACd,UAAUA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC9B,eAAeA,OAAO,IAAI,GAAG,KAAK,CAAC;oBACnC,YAAYA,OAAO,MAAM,GAAG,KAAK,CAAC;oBAClC,OAAOA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC3B,QAAQA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC5B,YAAYA,OACP,IAAI,GACJ,KAAK,CAAC,UACN,gBAAgB,CAAC;wBACd;4BACI,OAAOC,eAAe,OAAO;4BAC7B,OAAO;wBACX;wBACA;4BACI,OAAOA,eAAe,OAAO;4BAC7B,OAAO;wBACX;wBACA;4BACI,OAAOA,eAAe,MAAM;4BAC5B,OAAO;wBACX;wBACA;4BACI,OAAOA,eAAe,OAAO;4BAC7B,OAAO;wBACX;wBACA;4BACI,OAAOA,eAAe,OAAO;4BAC7B,OAAO;wBACX;qBACH,EACA,QAAQ,CAAC;wBAAE,cAAcA,eAAe,OAAO;oBAAC;oBACrD,WAAWD,OAAO,QAAQ,GAAG,KAAK,CAAC;oBACnC,YAAYA,OAAO,QAAQ,GAAG,KAAK,CAAC;oBACpC,eAAeA,OAAO,IAAI,GAAG,KAAK,CAAC;gBACvC;SACP;IACL;AACJ;AAEO,MAAME,mBAAmBC,aAAa,oBAAoB,CAAC;IAC9D,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
3
|
+
import { CleanupTaskSubtreeUseCase } from "../../api/features/CleanupTaskSubtree/index.js";
|
|
4
|
+
type HookParams = TaskHandler.LifecycleHookParams;
|
|
5
|
+
/**
|
|
6
|
+
* Deletes a finished task, and its descendants, for the events its definition asked for.
|
|
7
|
+
*
|
|
8
|
+
* Registered against `TaskHandler`, so it wraps every task's handler. Which task it is wrapping, and
|
|
9
|
+
* whether that task wants cleaning up, both come from `params.definition` rather than from anything
|
|
10
|
+
* captured at construction: one decorator instance serves whichever handler is resolved.
|
|
11
|
+
*
|
|
12
|
+
* The user's hook runs first and its failure is swallowed, so a task that throws on the way out is
|
|
13
|
+
* still cleaned up. That is what the previous single-object implementation did.
|
|
14
|
+
*/
|
|
15
|
+
export declare class SelfCleaningTaskHandlerDecoratorImpl implements TaskHandler.Interface {
|
|
16
|
+
private readonly cleanupTaskSubtree;
|
|
17
|
+
private readonly logger;
|
|
18
|
+
private readonly decoratee;
|
|
19
|
+
constructor(cleanupTaskSubtree: CleanupTaskSubtreeUseCase.Interface, logger: Logger.Interface, decoratee: TaskHandler.Interface);
|
|
20
|
+
get run(): (params: import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskRunParams<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>) => Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResult<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
21
|
+
get onBeforeTrigger(): ((params: import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskBeforeTriggerParams<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput>) => Promise<void>) | undefined;
|
|
22
|
+
get onMaxIterations(): ((params: import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskLifecycleHook<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>) => Promise<void>) | undefined;
|
|
23
|
+
get createInputValidation(): ((params: import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskCreateInputValidationParams) => import("@webiny/api/types").GenericRecord<PropertyKey, import("zod").Schema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>> | import("zod").Schema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>) | undefined;
|
|
24
|
+
get onDone(): (params: HookParams) => Promise<void>;
|
|
25
|
+
get onError(): (params: HookParams) => Promise<void>;
|
|
26
|
+
get onAbort(): (params: HookParams) => Promise<void>;
|
|
27
|
+
private cleanUpIfAsked;
|
|
28
|
+
private safeCall;
|
|
29
|
+
}
|
|
30
|
+
export declare const SelfCleaningTaskHandlerDecorator: typeof SelfCleaningTaskHandlerDecoratorImpl & {
|
|
31
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskHandler<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
2
|
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
3
3
|
import { normalizeSelfCleanup } from "../utils/normalizeSelfCleanup.js";
|
|
4
4
|
import { CleanupTaskSubtreeUseCase } from "../features/CleanupTaskSubtree/index.js";
|
|
5
5
|
import { getErrorProperties } from "../utils/getErrorProperties.js";
|
|
6
|
-
class
|
|
6
|
+
class SelfCleaningTaskHandlerDecoratorImpl {
|
|
7
7
|
constructor(cleanupTaskSubtree, logger, decoratee){
|
|
8
8
|
this.cleanupTaskSubtree = cleanupTaskSubtree;
|
|
9
9
|
this.logger = logger;
|
|
10
10
|
this.decoratee = decoratee;
|
|
11
|
-
this.events = normalizeSelfCleanup(decoratee.selfCleanup);
|
|
12
|
-
}
|
|
13
|
-
get handler() {
|
|
14
|
-
return this.decoratee.handler;
|
|
15
|
-
}
|
|
16
|
-
get id() {
|
|
17
|
-
return this.decoratee.id;
|
|
18
|
-
}
|
|
19
|
-
get title() {
|
|
20
|
-
return this.decoratee.title;
|
|
21
|
-
}
|
|
22
|
-
get description() {
|
|
23
|
-
return this.decoratee.description;
|
|
24
|
-
}
|
|
25
|
-
get isPrivate() {
|
|
26
|
-
return this.decoratee.isPrivate;
|
|
27
|
-
}
|
|
28
|
-
get maxIterations() {
|
|
29
|
-
return this.decoratee.maxIterations;
|
|
30
|
-
}
|
|
31
|
-
get selfCleanup() {
|
|
32
|
-
return this.decoratee.selfCleanup;
|
|
33
|
-
}
|
|
34
|
-
get createInputValidation() {
|
|
35
|
-
return this.decoratee.createInputValidation;
|
|
36
11
|
}
|
|
37
12
|
get run() {
|
|
38
|
-
return this.decoratee.run
|
|
13
|
+
return this.decoratee.run.bind(this.decoratee);
|
|
39
14
|
}
|
|
40
15
|
get onBeforeTrigger() {
|
|
41
16
|
return this.decoratee.onBeforeTrigger?.bind(this.decoratee);
|
|
@@ -43,29 +18,30 @@ class SelfCleaningTaskDecoratorImpl {
|
|
|
43
18
|
get onMaxIterations() {
|
|
44
19
|
return this.decoratee.onMaxIterations?.bind(this.decoratee);
|
|
45
20
|
}
|
|
46
|
-
get
|
|
47
|
-
|
|
48
|
-
return this.decoratee.databaseLogs;
|
|
21
|
+
get createInputValidation() {
|
|
22
|
+
return this.decoratee.createInputValidation?.bind(this.decoratee);
|
|
49
23
|
}
|
|
50
24
|
get onDone() {
|
|
51
25
|
return async (params)=>{
|
|
52
26
|
await this.safeCall(this.decoratee.onDone, params, "onDone");
|
|
53
|
-
|
|
27
|
+
await this.cleanUpIfAsked(params, "onSuccess");
|
|
54
28
|
};
|
|
55
29
|
}
|
|
56
30
|
get onError() {
|
|
57
31
|
return async (params)=>{
|
|
58
32
|
await this.safeCall(this.decoratee.onError, params, "onError");
|
|
59
|
-
|
|
33
|
+
await this.cleanUpIfAsked(params, "onError");
|
|
60
34
|
};
|
|
61
35
|
}
|
|
62
36
|
get onAbort() {
|
|
63
37
|
return async (params)=>{
|
|
64
38
|
await this.safeCall(this.decoratee.onAbort, params, "onAbort");
|
|
65
|
-
|
|
39
|
+
await this.cleanUpIfAsked(params, "onAbort");
|
|
66
40
|
};
|
|
67
41
|
}
|
|
68
|
-
async
|
|
42
|
+
async cleanUpIfAsked(params, event) {
|
|
43
|
+
const events = normalizeSelfCleanup(params.definition.selfCleanup);
|
|
44
|
+
if (!events.has(event)) return;
|
|
69
45
|
await this.cleanupTaskSubtree.execute(params.task.id);
|
|
70
46
|
}
|
|
71
47
|
async safeCall(hook, params, name) {
|
|
@@ -81,13 +57,13 @@ class SelfCleaningTaskDecoratorImpl {
|
|
|
81
57
|
}
|
|
82
58
|
}
|
|
83
59
|
}
|
|
84
|
-
const
|
|
85
|
-
decorator:
|
|
60
|
+
const SelfCleaningTaskHandlerDecorator = TaskHandler.createDecorator({
|
|
61
|
+
decorator: SelfCleaningTaskHandlerDecoratorImpl,
|
|
86
62
|
dependencies: [
|
|
87
63
|
CleanupTaskSubtreeUseCase,
|
|
88
64
|
Logger
|
|
89
65
|
]
|
|
90
66
|
});
|
|
91
|
-
export {
|
|
67
|
+
export { SelfCleaningTaskHandlerDecorator, SelfCleaningTaskHandlerDecoratorImpl };
|
|
92
68
|
|
|
93
|
-
//# sourceMappingURL=
|
|
69
|
+
//# sourceMappingURL=SelfCleaningTaskHandlerDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/decorators/SelfCleaningTaskHandlerDecorator.js","sources":["../../../src/api/decorators/SelfCleaningTaskHandlerDecorator.ts"],"sourcesContent":["import { TaskHandler } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\nimport { normalizeSelfCleanup } from \"~/api/utils/normalizeSelfCleanup.js\";\nimport { CleanupTaskSubtreeUseCase } from \"~/api/features/CleanupTaskSubtree/index.js\";\nimport { getErrorProperties } from \"~/api/utils/getErrorProperties.js\";\n\ntype HookParams = TaskHandler.LifecycleHookParams;\n\n/**\n * Deletes a finished task, and its descendants, for the events its definition asked for.\n *\n * Registered against `TaskHandler`, so it wraps every task's handler. Which task it is wrapping, and\n * whether that task wants cleaning up, both come from `params.definition` rather than from anything\n * captured at construction: one decorator instance serves whichever handler is resolved.\n *\n * The user's hook runs first and its failure is swallowed, so a task that throws on the way out is\n * still cleaned up. That is what the previous single-object implementation did.\n */\nexport class SelfCleaningTaskHandlerDecoratorImpl implements TaskHandler.Interface {\n public constructor(\n private readonly cleanupTaskSubtree: CleanupTaskSubtreeUseCase.Interface,\n private readonly logger: Logger.Interface,\n private readonly decoratee: TaskHandler.Interface\n ) {}\n\n get run() {\n return this.decoratee.run.bind(this.decoratee);\n }\n\n get onBeforeTrigger() {\n return this.decoratee.onBeforeTrigger?.bind(this.decoratee);\n }\n\n get onMaxIterations() {\n return this.decoratee.onMaxIterations?.bind(this.decoratee);\n }\n\n get createInputValidation() {\n return this.decoratee.createInputValidation?.bind(this.decoratee);\n }\n\n get onDone() {\n return async (params: HookParams) => {\n await this.safeCall(this.decoratee.onDone, params, \"onDone\");\n await this.cleanUpIfAsked(params, \"onSuccess\");\n };\n }\n\n get onError() {\n return async (params: HookParams) => {\n await this.safeCall(this.decoratee.onError, params, \"onError\");\n await this.cleanUpIfAsked(params, \"onError\");\n };\n }\n\n get onAbort() {\n return async (params: HookParams) => {\n await this.safeCall(this.decoratee.onAbort, params, \"onAbort\");\n await this.cleanUpIfAsked(params, \"onAbort\");\n };\n }\n\n private async cleanUpIfAsked(\n params: HookParams,\n event: \"onSuccess\" | \"onError\" | \"onAbort\"\n ): Promise<void> {\n const events = normalizeSelfCleanup(params.definition.selfCleanup);\n if (!events.has(event)) {\n return;\n }\n\n await this.cleanupTaskSubtree.execute(params.task.id);\n }\n\n private async safeCall(\n hook: TaskHandler.Interface[\"onDone\"],\n params: HookParams,\n name: string\n ): Promise<void> {\n if (!hook) {\n return;\n }\n\n try {\n await hook.call(this.decoratee, params);\n } catch (ex) {\n this.logger.error(\n { error: getErrorProperties(ex), taskId: params.task.id, hook: name },\n \"Error executing task lifecycle hook.\"\n );\n }\n }\n}\n\nexport const SelfCleaningTaskHandlerDecorator = TaskHandler.createDecorator({\n decorator: SelfCleaningTaskHandlerDecoratorImpl,\n dependencies: [CleanupTaskSubtreeUseCase, Logger]\n});\n"],"names":["SelfCleaningTaskHandlerDecoratorImpl","cleanupTaskSubtree","logger","decoratee","params","event","events","normalizeSelfCleanup","hook","name","ex","getErrorProperties","SelfCleaningTaskHandlerDecorator","TaskHandler","CleanupTaskSubtreeUseCase","Logger"],"mappings":";;;;;AAkBO,MAAMA;IACT,YACqBC,kBAAuD,EACvDC,MAAwB,EACxBC,SAAgC,CACnD;aAHmBF,kBAAkB,GAAlBA;aACAC,MAAM,GAANA;aACAC,SAAS,GAATA;IAClB;IAEH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS;IACjD;IAEA,IAAI,kBAAkB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,KAAK,IAAI,CAAC,SAAS;IAC9D;IAEA,IAAI,kBAAkB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,KAAK,IAAI,CAAC,SAAS;IAC9D;IAEA,IAAI,wBAAwB;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,KAAK,IAAI,CAAC,SAAS;IACpE;IAEA,IAAI,SAAS;QACT,OAAO,OAAOC;YACV,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAEA,QAAQ;YACnD,MAAM,IAAI,CAAC,cAAc,CAACA,QAAQ;QACtC;IACJ;IAEA,IAAI,UAAU;QACV,OAAO,OAAOA;YACV,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAEA,QAAQ;YACpD,MAAM,IAAI,CAAC,cAAc,CAACA,QAAQ;QACtC;IACJ;IAEA,IAAI,UAAU;QACV,OAAO,OAAOA;YACV,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAEA,QAAQ;YACpD,MAAM,IAAI,CAAC,cAAc,CAACA,QAAQ;QACtC;IACJ;IAEA,MAAc,eACVA,MAAkB,EAClBC,KAA0C,EAC7B;QACb,MAAMC,SAASC,qBAAqBH,OAAO,UAAU,CAAC,WAAW;QACjE,IAAI,CAACE,OAAO,GAAG,CAACD,QACZ;QAGJ,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACD,OAAO,IAAI,CAAC,EAAE;IACxD;IAEA,MAAc,SACVI,IAAqC,EACrCJ,MAAkB,EAClBK,IAAY,EACC;QACb,IAAI,CAACD,MACD;QAGJ,IAAI;YACA,MAAMA,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,EAAEJ;QACpC,EAAE,OAAOM,IAAI;YACT,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;gBAAE,OAAOC,mBAAmBD;gBAAK,QAAQN,OAAO,IAAI,CAAC,EAAE;gBAAE,MAAMK;YAAK,GACpE;QAER;IACJ;AACJ;AAEO,MAAMG,mCAAmCC,YAAY,eAAe,CAAC;IACxE,WAAWb;IACX,cAAc;QAACc;QAA2BC;KAAO;AACrD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fills in the defaults a definition is allowed to leave out, applies the one rule that overrides
|
|
4
|
+
* what a definition asked for (self-cleanup forces `databaseLogs` off), and rejects an id that is
|
|
5
|
+
* not camelCase.
|
|
6
|
+
*
|
|
7
|
+
* Everything here is metadata. A definition carries no behaviour, so there is nothing to forward:
|
|
8
|
+
* `GetRunnableTaskDefinitionUseCase` takes `run` and the hooks from the handler that `handler` names, after
|
|
9
|
+
* this decorator has run.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TaskDefinitionDefaultsDecoratorImpl implements TaskDefinition.Interface {
|
|
12
|
+
private decoratee;
|
|
13
|
+
private readonly cleansUp;
|
|
14
|
+
constructor(decoratee: TaskDefinition.Interface);
|
|
15
|
+
get id(): string;
|
|
16
|
+
get title(): string;
|
|
17
|
+
get description(): string | undefined;
|
|
18
|
+
get handler(): import("@webiny/di").Constructor<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskHandler<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
19
|
+
get isPrivate(): boolean;
|
|
20
|
+
get databaseLogs(): boolean;
|
|
21
|
+
get maxIterations(): number;
|
|
22
|
+
get selfCleanup(): import("@webiny/api-core/features/task/TaskDefinition/abstractions").ISelfCleanup | undefined;
|
|
23
|
+
private validate;
|
|
24
|
+
}
|
|
25
|
+
export declare const TaskDefinitionDefaultsDecorator: typeof TaskDefinitionDefaultsDecoratorImpl & {
|
|
26
|
+
__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>>;
|
|
27
|
+
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import camelCase from "lodash/camelCase.js";
|
|
2
2
|
import error from "@webiny/error";
|
|
3
3
|
import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
4
|
+
import { normalizeSelfCleanup } from "../utils/normalizeSelfCleanup.js";
|
|
4
5
|
const DEFAULT_MAX_ITERATIONS = 50;
|
|
5
|
-
class
|
|
6
|
+
class TaskDefinitionDefaultsDecoratorImpl {
|
|
6
7
|
constructor(decoratee){
|
|
7
8
|
this.decoratee = decoratee;
|
|
8
9
|
this.validate();
|
|
10
|
+
this.cleansUp = normalizeSelfCleanup(decoratee.selfCleanup).size > 0;
|
|
9
11
|
}
|
|
10
12
|
get id() {
|
|
11
13
|
return this.decoratee.id;
|
|
@@ -16,10 +18,14 @@ class RunnableTaskDecoratorImpl {
|
|
|
16
18
|
get description() {
|
|
17
19
|
return this.decoratee.description;
|
|
18
20
|
}
|
|
21
|
+
get handler() {
|
|
22
|
+
return this.decoratee.handler;
|
|
23
|
+
}
|
|
19
24
|
get isPrivate() {
|
|
20
25
|
return this.decoratee.isPrivate || false;
|
|
21
26
|
}
|
|
22
27
|
get databaseLogs() {
|
|
28
|
+
if (this.cleansUp) return false;
|
|
23
29
|
return this.decoratee.databaseLogs || false;
|
|
24
30
|
}
|
|
25
31
|
get maxIterations() {
|
|
@@ -28,41 +34,14 @@ class RunnableTaskDecoratorImpl {
|
|
|
28
34
|
get selfCleanup() {
|
|
29
35
|
return this.decoratee.selfCleanup;
|
|
30
36
|
}
|
|
31
|
-
get createInputValidation() {
|
|
32
|
-
return this.decoratee.createInputValidation;
|
|
33
|
-
}
|
|
34
|
-
get handler() {
|
|
35
|
-
return this.decoratee.handler;
|
|
36
|
-
}
|
|
37
|
-
get run() {
|
|
38
|
-
return this.decoratee.run?.bind(this.decoratee);
|
|
39
|
-
}
|
|
40
|
-
get onBeforeTrigger() {
|
|
41
|
-
return this.decoratee.onBeforeTrigger?.bind(this.decoratee);
|
|
42
|
-
}
|
|
43
|
-
get onDone() {
|
|
44
|
-
return this.decoratee.onDone?.bind(this.decoratee);
|
|
45
|
-
}
|
|
46
|
-
get onError() {
|
|
47
|
-
return this.decoratee.onError?.bind(this.decoratee);
|
|
48
|
-
}
|
|
49
|
-
get onAbort() {
|
|
50
|
-
return this.decoratee.onAbort?.bind(this.decoratee);
|
|
51
|
-
}
|
|
52
|
-
get onMaxIterations() {
|
|
53
|
-
return this.decoratee.onMaxIterations?.bind(this.decoratee);
|
|
54
|
-
}
|
|
55
37
|
validate() {
|
|
56
38
|
if (camelCase(this.decoratee.id) !== this.decoratee.id) throw new error(`Task ID "${this.decoratee.id}" is invalid. It must be in camelCase format, for example: "myCustomTask".`);
|
|
57
39
|
}
|
|
58
|
-
getTask() {
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
40
|
}
|
|
62
|
-
const
|
|
63
|
-
decorator:
|
|
41
|
+
const TaskDefinitionDefaultsDecorator = TaskDefinition.createDecorator({
|
|
42
|
+
decorator: TaskDefinitionDefaultsDecoratorImpl,
|
|
64
43
|
dependencies: []
|
|
65
44
|
});
|
|
66
|
-
export {
|
|
45
|
+
export { TaskDefinitionDefaultsDecorator, TaskDefinitionDefaultsDecoratorImpl };
|
|
67
46
|
|
|
68
|
-
//# sourceMappingURL=
|
|
47
|
+
//# sourceMappingURL=TaskDefinitionDefaultsDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/decorators/TaskDefinitionDefaultsDecorator.js","sources":["../../../src/api/decorators/TaskDefinitionDefaultsDecorator.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase.js\";\nimport WebinyError from \"@webiny/error\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { normalizeSelfCleanup } from \"~/api/utils/normalizeSelfCleanup.js\";\n\nconst DEFAULT_MAX_ITERATIONS = 50;\n\n/**\n * Fills in the defaults a definition is allowed to leave out, applies the one rule that overrides\n * what a definition asked for (self-cleanup forces `databaseLogs` off), and rejects an id that is\n * not camelCase.\n *\n * Everything here is metadata. A definition carries no behaviour, so there is nothing to forward:\n * `GetRunnableTaskDefinitionUseCase` takes `run` and the hooks from the handler that `handler` names, after\n * this decorator has run.\n */\nexport class TaskDefinitionDefaultsDecoratorImpl implements TaskDefinition.Interface {\n private readonly cleansUp: boolean;\n\n constructor(private decoratee: TaskDefinition.Interface) {\n this.validate();\n this.cleansUp = normalizeSelfCleanup(decoratee.selfCleanup).size > 0;\n }\n\n get id() {\n return this.decoratee.id;\n }\n\n get title() {\n return this.decoratee.title;\n }\n\n get description() {\n return this.decoratee.description;\n }\n\n get handler() {\n return this.decoratee.handler;\n }\n\n // The three defaults.\n get isPrivate() {\n return this.decoratee.isPrivate || false;\n }\n\n get databaseLogs() {\n // A task that deletes itself on the way out has nowhere to keep logs, so asking for any\n // cleanup event overrides the task's own choice.\n if (this.cleansUp) {\n return false;\n }\n return this.decoratee.databaseLogs || false;\n }\n\n get maxIterations() {\n return this.decoratee.maxIterations || DEFAULT_MAX_ITERATIONS;\n }\n\n get selfCleanup() {\n return this.decoratee.selfCleanup;\n }\n\n private validate(): void {\n if (camelCase(this.decoratee.id) !== this.decoratee.id) {\n throw new WebinyError(\n `Task ID \"${this.decoratee.id}\" is invalid. It must be in camelCase format, for example: \"myCustomTask\".`\n );\n }\n }\n}\n\nexport const TaskDefinitionDefaultsDecorator = TaskDefinition.createDecorator({\n decorator: TaskDefinitionDefaultsDecoratorImpl,\n dependencies: []\n});\n"],"names":["DEFAULT_MAX_ITERATIONS","TaskDefinitionDefaultsDecoratorImpl","decoratee","normalizeSelfCleanup","camelCase","WebinyError","TaskDefinitionDefaultsDecorator","TaskDefinition"],"mappings":";;;;AAKA,MAAMA,yBAAyB;AAWxB,MAAMC;IAGT,YAAoBC,SAAmC,CAAE;aAArCA,SAAS,GAATA;QAChB,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,QAAQ,GAAGC,qBAAqBD,UAAU,WAAW,EAAE,IAAI,GAAG;IACvE;IAEA,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE;IAC5B;IAEA,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK;IAC/B;IAEA,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW;IACrC;IAEA,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO;IACjC;IAGA,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI;IACvC;IAEA,IAAI,eAAe;QAGf,IAAI,IAAI,CAAC,QAAQ,EACb,OAAO;QAEX,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,IAAI;IAC1C;IAEA,IAAI,gBAAgB;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,IAAIF;IAC3C;IAEA,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW;IACrC;IAEQ,WAAiB;QACrB,IAAII,UAAU,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,EAClD,MAAM,IAAIC,MACN,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,0EAA0E,CAAC;IAGrH;AACJ;AAEO,MAAMC,kCAAkCC,eAAe,eAAe,CAAC;IAC1E,WAAWN;IACX,cAAc,EAAE;AACpB"}
|
package/api/domain/errors.d.ts
CHANGED
|
@@ -7,16 +7,6 @@ export declare class TaskDefinitionNotFoundError extends BaseError<{
|
|
|
7
7
|
readonly code: "BackgroundTasks/TaskDefinition/NotFoundError";
|
|
8
8
|
constructor(id: string);
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* A definition was found by id but supplies no behaviour: neither a `handler` class nor its own
|
|
12
|
-
* `run()`. Only reachable while definitions are migrating from one shape to the other.
|
|
13
|
-
*/
|
|
14
|
-
export declare class TaskDefinitionNotRunnableError extends BaseError<{
|
|
15
|
-
id: string;
|
|
16
|
-
}> {
|
|
17
|
-
readonly code: "BackgroundTasks/TaskDefinition/NotRunnableError";
|
|
18
|
-
constructor(id: string);
|
|
19
|
-
}
|
|
20
10
|
export declare class TaskNotFoundError extends BaseError {
|
|
21
11
|
readonly code: "BackgroundTasks/Task/NotFoundError";
|
|
22
12
|
constructor();
|
|
@@ -31,6 +21,16 @@ export declare class TaskAbortError extends BaseError<{
|
|
|
31
21
|
status: string;
|
|
32
22
|
});
|
|
33
23
|
}
|
|
24
|
+
export declare class TaskTriggerError extends BaseError<{
|
|
25
|
+
definitionId: string;
|
|
26
|
+
}> {
|
|
27
|
+
readonly code: "BackgroundTasks/Task/TriggerError";
|
|
28
|
+
constructor(params: {
|
|
29
|
+
message: string;
|
|
30
|
+
definitionId: string;
|
|
31
|
+
});
|
|
32
|
+
static from(error: unknown, definitionId: string): TaskTriggerError;
|
|
33
|
+
}
|
|
34
34
|
export declare class TaskLogNotFoundError extends BaseError {
|
|
35
35
|
readonly code: "BackgroundTasks/Log/NotFoundError";
|
|
36
36
|
constructor();
|
|
@@ -64,4 +64,8 @@ export declare class BackgroundTaskNotAuthorizedError extends BaseError {
|
|
|
64
64
|
readonly code: "BackgroundTasks/NotAuthorized";
|
|
65
65
|
constructor();
|
|
66
66
|
}
|
|
67
|
+
export declare class TaskInputValidationError extends BaseError<Record<string, any>> {
|
|
68
|
+
readonly code: "VALIDATION_FAILED_INVALID_FIELDS";
|
|
69
|
+
constructor(error: ZodError);
|
|
70
|
+
}
|
|
67
71
|
export {};
|
package/api/domain/errors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseError } from "@webiny/feature/api";
|
|
2
|
-
import { parseZodError } from "@webiny/utils";
|
|
2
|
+
import { createZodError, parseZodError } from "@webiny/utils";
|
|
3
3
|
class TaskDefinitionNotFoundError extends BaseError {
|
|
4
4
|
constructor(id){
|
|
5
5
|
super({
|
|
@@ -10,16 +10,6 @@ class TaskDefinitionNotFoundError extends BaseError {
|
|
|
10
10
|
}), this.code = "BackgroundTasks/TaskDefinition/NotFoundError";
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
class TaskDefinitionNotRunnableError extends BaseError {
|
|
14
|
-
constructor(id){
|
|
15
|
-
super({
|
|
16
|
-
message: `Task definition "${id}" defines neither a "handler" nor a "run" method.`,
|
|
17
|
-
data: {
|
|
18
|
-
id
|
|
19
|
-
}
|
|
20
|
-
}), this.code = "BackgroundTasks/TaskDefinition/NotRunnableError";
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
13
|
class TaskNotFoundError extends BaseError {
|
|
24
14
|
constructor(){
|
|
25
15
|
super({
|
|
@@ -35,6 +25,23 @@ class TaskAbortError extends BaseError {
|
|
|
35
25
|
}), this.code = "BackgroundTasks/Task/Abort";
|
|
36
26
|
}
|
|
37
27
|
}
|
|
28
|
+
class TaskTriggerError extends BaseError {
|
|
29
|
+
constructor(params){
|
|
30
|
+
super({
|
|
31
|
+
message: params.message,
|
|
32
|
+
data: {
|
|
33
|
+
definitionId: params.definitionId
|
|
34
|
+
}
|
|
35
|
+
}), this.code = "BackgroundTasks/Task/TriggerError";
|
|
36
|
+
}
|
|
37
|
+
static from(error, definitionId) {
|
|
38
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
39
|
+
return new TaskTriggerError({
|
|
40
|
+
message,
|
|
41
|
+
definitionId
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
38
45
|
class TaskLogNotFoundError extends BaseError {
|
|
39
46
|
constructor(){
|
|
40
47
|
super({
|
|
@@ -106,6 +113,14 @@ class BackgroundTaskNotAuthorizedError extends BaseError {
|
|
|
106
113
|
}), this.code = "BackgroundTasks/NotAuthorized";
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
|
-
|
|
116
|
+
class TaskInputValidationError extends BaseError {
|
|
117
|
+
constructor(error){
|
|
118
|
+
super({
|
|
119
|
+
message: "Validation failed.",
|
|
120
|
+
data: createZodError(error).data ?? {}
|
|
121
|
+
}), this.code = "VALIDATION_FAILED_INVALID_FIELDS";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export { BackgroundTaskModelNotFoundError, BackgroundTaskNotAuthorizedError, BackgroundTaskPersistenceError, BackgroundTaskValidationError, TaskAbortError, TaskDefinitionNotFoundError, TaskInputValidationError, TaskLogNotFoundError, TaskNotFoundError, TaskServiceInfoError, TaskTriggerError };
|
|
110
125
|
|
|
111
126
|
//# sourceMappingURL=errors.js.map
|