@webiny/tasks 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.e6f0dc8ca7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/context.js +50 -21
- package/context.js.map +1 -1
- package/crud/TaskLogPrivateModel.d.ts +9 -0
- package/crud/TaskLogPrivateModel.js +34 -0
- package/crud/TaskLogPrivateModel.js.map +1 -0
- package/crud/TaskPrivateModel.d.ts +9 -0
- package/crud/TaskPrivateModel.js +46 -0
- package/crud/TaskPrivateModel.js.map +1 -0
- package/crud/cleanupTaskSubtree.d.ts +8 -0
- package/crud/cleanupTaskSubtree.js +76 -0
- package/crud/cleanupTaskSubtree.js.map +1 -0
- package/crud/crud.tasks.d.ts +1 -1
- package/crud/crud.tasks.js +213 -105
- package/crud/crud.tasks.js.map +1 -1
- package/crud/definition.tasks.d.ts +1 -1
- package/crud/definition.tasks.js +9 -18
- package/crud/definition.tasks.js.map +1 -1
- package/crud/service.tasks.d.ts +1 -1
- package/crud/service.tasks.js +31 -36
- package/crud/service.tasks.js.map +1 -1
- package/decorators/RunnableTaskDecorator.d.ts +32 -0
- package/decorators/RunnableTaskDecorator.js +85 -0
- package/decorators/RunnableTaskDecorator.js.map +1 -0
- package/decorators/SelfCleaningTaskDecorator.d.ts +30 -0
- package/decorators/SelfCleaningTaskDecorator.js +98 -0
- package/decorators/SelfCleaningTaskDecorator.js.map +1 -0
- package/domain/errors.d.ts +29 -0
- package/domain/errors.js +47 -0
- package/domain/errors.js.map +1 -0
- package/events/TaskAfterCreateEvent.d.ts +6 -0
- package/events/TaskAfterCreateEvent.js +10 -0
- package/events/TaskAfterCreateEvent.js.map +1 -0
- package/events/TaskAfterDeleteEvent.d.ts +6 -0
- package/events/TaskAfterDeleteEvent.js +10 -0
- package/events/TaskAfterDeleteEvent.js.map +1 -0
- package/events/TaskAfterUpdateEvent.d.ts +6 -0
- package/events/TaskAfterUpdateEvent.js +10 -0
- package/events/TaskAfterUpdateEvent.js.map +1 -0
- package/events/TaskBeforeCreateEvent.d.ts +6 -0
- package/events/TaskBeforeCreateEvent.js +10 -0
- package/events/TaskBeforeCreateEvent.js.map +1 -0
- package/events/TaskBeforeDeleteEvent.d.ts +6 -0
- package/events/TaskBeforeDeleteEvent.js +10 -0
- package/events/TaskBeforeDeleteEvent.js.map +1 -0
- package/events/TaskBeforeUpdateEvent.d.ts +6 -0
- package/events/TaskBeforeUpdateEvent.js +10 -0
- package/events/TaskBeforeUpdateEvent.js.map +1 -0
- package/events/abstractions.d.ts +53 -0
- package/events/abstractions.js +39 -0
- package/events/abstractions.js.map +1 -0
- package/events/index.d.ts +7 -0
- package/events/index.js +9 -0
- package/events/index.js.map +1 -0
- package/features/AbortTask/AbortTaskUseCase.d.ts +10 -0
- package/features/AbortTask/AbortTaskUseCase.js +11 -0
- package/features/AbortTask/AbortTaskUseCase.js.map +1 -0
- package/features/AbortTask/abstractions.d.ts +25 -0
- package/features/AbortTask/abstractions.js +4 -0
- package/features/AbortTask/abstractions.js.map +1 -0
- package/features/AbortTask/feature.d.ts +5 -0
- package/features/AbortTask/feature.js +11 -0
- package/features/AbortTask/feature.js.map +1 -0
- package/features/AbortTask/index.d.ts +2 -0
- package/features/AbortTask/index.js +4 -0
- package/features/AbortTask/index.js.map +1 -0
- package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.d.ts +7 -0
- package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js +10 -0
- package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js.map +1 -0
- package/features/CleanupTaskSubtree/abstractions.d.ts +7 -0
- package/features/CleanupTaskSubtree/abstractions.js +4 -0
- package/features/CleanupTaskSubtree/abstractions.js.map +1 -0
- package/features/CleanupTaskSubtree/index.d.ts +2 -0
- package/features/CleanupTaskSubtree/index.js +4 -0
- package/features/CleanupTaskSubtree/index.js.map +1 -0
- package/features/GetTask/GetTaskUseCase.d.ts +9 -0
- package/features/GetTask/GetTaskUseCase.js +10 -0
- package/features/GetTask/GetTaskUseCase.js.map +1 -0
- package/features/GetTask/abstractions.d.ts +10 -0
- package/features/GetTask/abstractions.js +4 -0
- package/features/GetTask/abstractions.js.map +1 -0
- package/features/GetTask/feature.d.ts +5 -0
- package/features/GetTask/feature.js +11 -0
- package/features/GetTask/feature.js.map +1 -0
- package/features/GetTask/index.d.ts +2 -0
- package/features/GetTask/index.js +4 -0
- package/features/GetTask/index.js.map +1 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.d.ts +12 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +25 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js.map +1 -0
- package/features/GetTaskDefinition/abstractions.d.ts +17 -0
- package/features/GetTaskDefinition/abstractions.js +4 -0
- package/features/GetTaskDefinition/abstractions.js.map +1 -0
- package/features/GetTaskDefinition/feature.d.ts +4 -0
- package/features/GetTaskDefinition/feature.js +10 -0
- package/features/GetTaskDefinition/feature.js.map +1 -0
- package/features/GetTaskDefinition/index.d.ts +2 -0
- package/features/GetTaskDefinition/index.js +4 -0
- package/features/GetTaskDefinition/index.js.map +1 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.d.ts +11 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js +18 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js.map +1 -0
- package/features/ListTaskDefinitions/abstractions.d.ts +9 -0
- package/features/ListTaskDefinitions/abstractions.js +4 -0
- package/features/ListTaskDefinitions/abstractions.js.map +1 -0
- package/features/ListTaskDefinitions/feature.d.ts +4 -0
- package/features/ListTaskDefinitions/feature.js +10 -0
- package/features/ListTaskDefinitions/feature.js.map +1 -0
- package/features/ListTaskDefinitions/index.d.ts +2 -0
- package/features/ListTaskDefinitions/index.js +4 -0
- package/features/ListTaskDefinitions/index.js.map +1 -0
- package/features/ListTasks/ListTasksUseCase.d.ts +9 -0
- package/features/ListTasks/ListTasksUseCase.js +10 -0
- package/features/ListTasks/ListTasksUseCase.js.map +1 -0
- package/features/ListTasks/abstractions.d.ts +13 -0
- package/features/ListTasks/abstractions.js +4 -0
- package/features/ListTasks/abstractions.js.map +1 -0
- package/features/ListTasks/feature.d.ts +5 -0
- package/features/ListTasks/feature.js +11 -0
- package/features/ListTasks/feature.js.map +1 -0
- package/features/ListTasks/index.d.ts +2 -0
- package/features/ListTasks/index.js +4 -0
- package/features/ListTasks/index.js.map +1 -0
- package/features/TaskController/TaskController.d.ts +49 -0
- package/features/TaskController/TaskController.js +71 -0
- package/features/TaskController/TaskController.js.map +1 -0
- package/features/TaskController/augmentation.d.ts +60 -0
- package/features/TaskController/augmentation.js +3 -0
- package/features/TaskController/augmentation.js.map +1 -0
- package/features/TaskController/index.d.ts +2 -0
- package/features/TaskController/index.js +7 -0
- package/features/TaskController/index.js.map +1 -0
- package/features/TaskExecutionContext/TaskExecutionContext.d.ts +24 -0
- package/features/TaskExecutionContext/TaskExecutionContext.js +50 -0
- package/features/TaskExecutionContext/TaskExecutionContext.js.map +1 -0
- package/features/TaskExecutionContext/abstractions.d.ts +26 -0
- package/features/TaskExecutionContext/abstractions.js +13 -0
- package/features/TaskExecutionContext/abstractions.js.map +1 -0
- package/features/TaskExecutionContext/feature.d.ts +4 -0
- package/features/TaskExecutionContext/feature.js +10 -0
- package/features/TaskExecutionContext/feature.js.map +1 -0
- package/features/TaskExecutionContext/index.d.ts +1 -0
- package/features/TaskExecutionContext/index.js +3 -0
- package/features/TaskExecutionContext/index.js.map +1 -0
- package/features/TriggerTask/TriggerTaskUseCase.d.ts +10 -0
- package/features/TriggerTask/TriggerTaskUseCase.js +11 -0
- package/features/TriggerTask/TriggerTaskUseCase.js.map +1 -0
- package/features/TriggerTask/abstractions.d.ts +28 -0
- package/features/TriggerTask/abstractions.js +4 -0
- package/features/TriggerTask/abstractions.js.map +1 -0
- package/features/TriggerTask/feature.d.ts +5 -0
- package/features/TriggerTask/feature.js +11 -0
- package/features/TriggerTask/feature.js.map +1 -0
- package/features/TriggerTask/index.d.ts +2 -0
- package/features/TriggerTask/index.js +4 -0
- package/features/TriggerTask/index.js.map +1 -0
- package/global.d.ts +1 -0
- package/global.js +3 -0
- package/global.js.map +1 -0
- package/graphql/checkPermissions.d.ts +1 -1
- package/graphql/checkPermissions.js +3 -9
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/index.d.ts +1 -1
- package/graphql/index.js +67 -83
- package/graphql/index.js.map +1 -1
- package/graphql/utils.d.ts +3 -3
- package/graphql/utils.js +8 -17
- package/graphql/utils.js.map +1 -1
- package/handler/index.d.ts +2 -2
- package/handler/index.js +33 -40
- package/handler/index.js.map +1 -1
- package/handler/register.js +5 -7
- package/handler/register.js.map +1 -1
- package/handler/types.d.ts +1 -3
- package/handler/types.js +1 -5
- package/handler/types.js.map +1 -1
- package/index.d.ts +5 -6
- package/index.js +5 -60
- package/index.js.map +1 -1
- package/package.json +27 -28
- package/plugins/TaskServicePlugin.d.ts +1 -2
- package/plugins/TaskServicePlugin.js +2 -9
- package/plugins/TaskServicePlugin.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +1 -16
- package/plugins/index.js.map +1 -1
- package/response/DatabaseResponse.d.ts +3 -3
- package/response/DatabaseResponse.js +14 -20
- package/response/DatabaseResponse.js.map +1 -1
- package/response/Response.d.ts +4 -3
- package/response/Response.js +20 -31
- package/response/Response.js.map +1 -1
- package/response/ResponseAbortedResult.d.ts +3 -4
- package/response/ResponseAbortedResult.js +3 -11
- package/response/ResponseAbortedResult.js.map +1 -1
- package/response/ResponseContinueResult.d.ts +4 -5
- package/response/ResponseContinueResult.js +3 -11
- package/response/ResponseContinueResult.js.map +1 -1
- package/response/ResponseDoneResult.d.ts +4 -6
- package/response/ResponseDoneResult.js +3 -11
- package/response/ResponseDoneResult.js.map +1 -1
- package/response/ResponseErrorResult.d.ts +3 -4
- package/response/ResponseErrorResult.js +3 -11
- package/response/ResponseErrorResult.js.map +1 -1
- package/response/TaskResponse.d.ts +7 -6
- package/response/TaskResponse.js +5 -12
- package/response/TaskResponse.js.map +1 -1
- package/response/abstractions/Response.d.ts +7 -7
- package/response/abstractions/Response.js +1 -5
- package/response/abstractions/Response.js.map +1 -1
- package/response/abstractions/ResponseAbortedResult.d.ts +3 -3
- package/response/abstractions/ResponseAbortedResult.js +1 -5
- package/response/abstractions/ResponseAbortedResult.js.map +1 -1
- package/response/abstractions/ResponseBaseResult.d.ts +2 -3
- package/response/abstractions/ResponseBaseResult.js +1 -5
- package/response/abstractions/ResponseBaseResult.js.map +1 -1
- package/response/abstractions/ResponseContinueResult.d.ts +4 -4
- package/response/abstractions/ResponseContinueResult.js +1 -5
- package/response/abstractions/ResponseContinueResult.js.map +1 -1
- package/response/abstractions/ResponseDoneResult.d.ts +5 -6
- package/response/abstractions/ResponseDoneResult.js +1 -5
- package/response/abstractions/ResponseDoneResult.js.map +1 -1
- package/response/abstractions/ResponseErrorResult.d.ts +4 -5
- package/response/abstractions/ResponseErrorResult.js +1 -5
- package/response/abstractions/ResponseErrorResult.js.map +1 -1
- package/response/abstractions/TaskResponse.d.ts +8 -30
- package/response/abstractions/TaskResponse.js +1 -5
- package/response/abstractions/TaskResponse.js.map +1 -1
- package/response/abstractions/index.d.ts +7 -7
- package/response/abstractions/index.js +7 -82
- package/response/abstractions/index.js.map +1 -1
- package/response/index.d.ts +7 -7
- package/response/index.js +7 -82
- package/response/index.js.map +1 -1
- package/runner/TaskControl.d.ts +4 -4
- package/runner/TaskControl.js +61 -39
- package/runner/TaskControl.js.map +1 -1
- package/runner/TaskEventValidation.d.ts +2 -2
- package/runner/TaskEventValidation.js +11 -20
- package/runner/TaskEventValidation.js.map +1 -1
- package/runner/TaskManager.d.ts +7 -10
- package/runner/TaskManager.js +19 -39
- package/runner/TaskManager.js.map +1 -1
- package/runner/TaskManagerStore.d.ts +7 -7
- package/runner/TaskManagerStore.js +16 -25
- package/runner/TaskManagerStore.js.map +1 -1
- package/runner/TaskRunner.d.ts +5 -6
- package/runner/TaskRunner.js +9 -31
- package/runner/TaskRunner.js.map +1 -1
- package/runner/abstractions/TaskControl.d.ts +4 -4
- package/runner/abstractions/TaskControl.js +1 -5
- package/runner/abstractions/TaskControl.js.map +1 -1
- package/runner/abstractions/TaskEventValidation.d.ts +1 -1
- package/runner/abstractions/TaskEventValidation.js +1 -5
- package/runner/abstractions/TaskEventValidation.js.map +1 -1
- package/runner/abstractions/TaskManager.d.ts +4 -4
- package/runner/abstractions/TaskManager.js +1 -5
- package/runner/abstractions/TaskManager.js.map +1 -1
- package/runner/abstractions/TaskManagerStore.d.ts +11 -11
- package/runner/abstractions/TaskManagerStore.js +1 -5
- package/runner/abstractions/TaskManagerStore.js.map +1 -1
- package/runner/abstractions/TaskRunner.d.ts +3 -3
- package/runner/abstractions/TaskRunner.js +1 -5
- package/runner/abstractions/TaskRunner.js.map +1 -1
- package/runner/abstractions/index.d.ts +5 -5
- package/runner/abstractions/index.js +5 -60
- package/runner/abstractions/index.js.map +1 -1
- package/runner/index.d.ts +1 -1
- package/runner/index.js +1 -16
- package/runner/index.js.map +1 -1
- package/service/EventBridgeEventTransportPlugin.d.ts +4 -5
- package/service/EventBridgeEventTransportPlugin.js +8 -17
- package/service/EventBridgeEventTransportPlugin.js.map +1 -1
- package/service/StepFunctionServicePlugin.d.ts +4 -5
- package/service/StepFunctionServicePlugin.js +11 -21
- package/service/StepFunctionServicePlugin.js.map +1 -1
- package/service/createService.d.ts +2 -2
- package/service/createService.js +7 -18
- package/service/createService.js.map +1 -1
- package/service/index.d.ts +3 -3
- package/service/index.js +6 -27
- package/service/index.js.map +1 -1
- package/tasks/testingRunTask.d.ts +10 -1
- package/tasks/testingRunTask.js +13 -18
- package/tasks/testingRunTask.js.map +1 -1
- package/types.d.ts +41 -214
- package/types.js +7 -56
- package/types.js.map +1 -1
- package/utils/ObjectUpdater.js +4 -11
- package/utils/ObjectUpdater.js.map +1 -1
- package/utils/getErrorProperties.d.ts +1 -1
- package/utils/getErrorProperties.js +3 -10
- package/utils/getErrorProperties.js.map +1 -1
- package/utils/getObjectProperties.js +1 -8
- package/utils/getObjectProperties.js.map +1 -1
- package/utils/index.d.ts +3 -3
- package/utils/index.js +3 -38
- package/utils/index.js.map +1 -1
- package/utils/normalizeSelfCleanup.d.ts +2 -0
- package/utils/normalizeSelfCleanup.js +15 -0
- package/utils/normalizeSelfCleanup.js.map +1 -0
- package/crud/model.d.ts +0 -5
- package/crud/model.js +0 -216
- package/crud/model.js.map +0 -1
- package/crud/where.d.ts +0 -1
- package/crud/where.js +0 -33
- package/crud/where.js.map +0 -1
- package/task/index.d.ts +0 -2
- package/task/index.js +0 -29
- package/task/index.js.map +0 -1
- package/task/input.d.ts +0 -15
- package/task/input.js +0 -21
- package/task/input.js.map +0 -1
- package/task/plugin.d.ts +0 -36
- package/task/plugin.js +0 -106
- package/task/plugin.js.map +0 -1
package/types.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { CmsContext as BaseContext, CmsEntryListParams,
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { SecurityPermission } from "@webiny/api-
|
|
6
|
-
import type {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import type
|
|
10
|
-
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
1
|
+
import type { CmsContext as BaseContext, CmsEntryListParams, CmsEntryMeta, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import type { IResponseError } from "./response/abstractions/index.js";
|
|
3
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
4
|
+
import type { IStepFunctionServiceFetchResult } from "./service/StepFunctionServicePlugin.js";
|
|
5
|
+
import type { SecurityPermission } from "@webiny/api-core/types/security.js";
|
|
6
|
+
import type { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
7
|
+
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
8
|
+
import { BaseError, Result } from "@webiny/feature/api";
|
|
9
|
+
import type { IdInterfaceGenerator, NumericInterfaceGenerator } from "@webiny/api";
|
|
10
|
+
import "./features/TaskController/augmentation.js";
|
|
11
|
+
export * from "./handler/types.js";
|
|
12
|
+
export * from "./response/abstractions/index.js";
|
|
13
|
+
export * from "./runner/abstractions/index.js";
|
|
13
14
|
export type ITaskDataInput = GenericRecord;
|
|
14
15
|
export declare enum TaskLogItemType {
|
|
15
16
|
INFO = "info",
|
|
@@ -53,31 +54,11 @@ export declare enum TaskDataStatus {
|
|
|
53
54
|
}
|
|
54
55
|
export interface ITaskIdentity {
|
|
55
56
|
id: string;
|
|
56
|
-
displayName: string
|
|
57
|
+
displayName: string;
|
|
57
58
|
type: string;
|
|
58
59
|
}
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
* ID without the revision number (for example: #0001).
|
|
62
|
-
*/
|
|
63
|
-
id: string;
|
|
64
|
-
name: string;
|
|
65
|
-
taskStatus: TaskDataStatus;
|
|
66
|
-
definitionId: string;
|
|
67
|
-
executionName: string;
|
|
68
|
-
input: T;
|
|
69
|
-
output?: O;
|
|
70
|
-
createdOn: string;
|
|
71
|
-
savedOn: string;
|
|
72
|
-
createdBy: ITaskIdentity;
|
|
73
|
-
startedOn?: string;
|
|
74
|
-
finishedOn?: string;
|
|
75
|
-
eventResponse: GenericRecord | undefined;
|
|
76
|
-
iterations: number;
|
|
77
|
-
parentId?: string;
|
|
78
|
-
}
|
|
79
|
-
export type IGetTaskResponse<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITask<T, O> | null;
|
|
80
|
-
export interface IListTasksResponse<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
60
|
+
export type IGetTaskResponse<T extends TaskService.TaskInput = TaskService.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput> = ITask<T, O> | null;
|
|
61
|
+
export interface IListTasksResponse<T extends TaskService.TaskInput = TaskService.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput> {
|
|
81
62
|
items: ITask<T, O>[];
|
|
82
63
|
meta: CmsEntryMeta;
|
|
83
64
|
}
|
|
@@ -85,47 +66,26 @@ export interface IListTaskLogsResponse {
|
|
|
85
66
|
items: ITaskLog[];
|
|
86
67
|
meta: CmsEntryMeta;
|
|
87
68
|
}
|
|
88
|
-
export type ICreateTaskResponse<T =
|
|
89
|
-
export type IUpdateTaskResponse<T =
|
|
69
|
+
export type ICreateTaskResponse<T extends TaskService.TaskInput = TaskService.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput> = ITask<T, O>;
|
|
70
|
+
export type IUpdateTaskResponse<T extends TaskService.TaskInput = TaskService.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput> = ITask<T, O>;
|
|
90
71
|
export type IDeleteTaskResponse = boolean;
|
|
91
|
-
export interface IListTaskParamsWhere extends
|
|
92
|
-
parentId?: string;
|
|
93
|
-
parentId_not?: string;
|
|
94
|
-
parentId_in?: string[];
|
|
95
|
-
parentId_not_in?: string[];
|
|
96
|
-
definitionId?: string;
|
|
97
|
-
definitionId_not?: string;
|
|
98
|
-
definitionId_in?: string[];
|
|
99
|
-
definitionId_not_in?: string[];
|
|
100
|
-
taskStatus?: string;
|
|
101
|
-
taskStatus_not?: string;
|
|
102
|
-
taskStatus_in?: string[];
|
|
103
|
-
taskStatus_not_in?: string[];
|
|
72
|
+
export interface IListTaskParamsWhere extends IdInterfaceGenerator<"id">, IdInterfaceGenerator<"parentId">, IdInterfaceGenerator<"definitionId">, IdInterfaceGenerator<"taskStatus"> {
|
|
104
73
|
}
|
|
105
74
|
export interface IListTaskParams extends Omit<CmsEntryListParams, "fields" | "search"> {
|
|
106
75
|
where?: IListTaskParamsWhere;
|
|
107
76
|
}
|
|
108
|
-
export interface IListTaskLogParamsWhere extends
|
|
109
|
-
task?: string;
|
|
110
|
-
task_in?: string[];
|
|
111
|
-
task_not?: string;
|
|
112
|
-
iteration?: number;
|
|
113
|
-
iteration_not?: number;
|
|
114
|
-
iteration_gte?: number;
|
|
115
|
-
iteration_gt?: number;
|
|
116
|
-
iteration_lte?: number;
|
|
117
|
-
iteration_lt?: number;
|
|
77
|
+
export interface IListTaskLogParamsWhere extends IdInterfaceGenerator<"id">, IdInterfaceGenerator<"task">, NumericInterfaceGenerator<"iteration"> {
|
|
118
78
|
}
|
|
119
|
-
export interface IListTaskLogParams extends Omit<CmsEntryListParams, "fields" | "search"> {
|
|
79
|
+
export interface IListTaskLogParams extends Omit<CmsEntryListParams, "fields" | "search" | "where"> {
|
|
120
80
|
where?: IListTaskLogParamsWhere;
|
|
121
81
|
}
|
|
122
|
-
export interface ITaskCreateData<T =
|
|
82
|
+
export interface ITaskCreateData<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {
|
|
123
83
|
definitionId: string;
|
|
124
84
|
name: string;
|
|
125
85
|
input: T;
|
|
126
86
|
parentId?: string;
|
|
127
87
|
}
|
|
128
|
-
export interface ITaskUpdateData<I =
|
|
88
|
+
export interface ITaskUpdateData<I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> {
|
|
129
89
|
name?: string;
|
|
130
90
|
input?: I;
|
|
131
91
|
output?: O;
|
|
@@ -136,27 +96,6 @@ export interface ITaskUpdateData<I = ITaskDataInput, O extends ITaskResponseDone
|
|
|
136
96
|
eventResponse?: GenericRecord;
|
|
137
97
|
iterations?: number;
|
|
138
98
|
}
|
|
139
|
-
export interface OnTaskBeforeCreateTopicParams {
|
|
140
|
-
input: ITaskCreateData;
|
|
141
|
-
}
|
|
142
|
-
export interface OnTaskAfterCreateTopicParams {
|
|
143
|
-
input: ITaskCreateData;
|
|
144
|
-
task: ITask;
|
|
145
|
-
}
|
|
146
|
-
export interface OnTaskBeforeUpdateTopicParams {
|
|
147
|
-
input: ITaskUpdateData;
|
|
148
|
-
original: ITask;
|
|
149
|
-
}
|
|
150
|
-
export interface OnTaskAfterUpdateTopicParams {
|
|
151
|
-
input: ITaskUpdateData;
|
|
152
|
-
task: ITask;
|
|
153
|
-
}
|
|
154
|
-
export interface OnTaskBeforeDeleteTopicParams {
|
|
155
|
-
task: ITask;
|
|
156
|
-
}
|
|
157
|
-
export interface OnTaskAfterDeleteTopicParams {
|
|
158
|
-
task: ITask;
|
|
159
|
-
}
|
|
160
99
|
export interface ITaskLogCreateInput {
|
|
161
100
|
executionName: string;
|
|
162
101
|
iteration: number;
|
|
@@ -173,11 +112,17 @@ export interface ITasksContextCrudObject {
|
|
|
173
112
|
/**
|
|
174
113
|
* Tasks
|
|
175
114
|
*/
|
|
176
|
-
getTask<T =
|
|
177
|
-
listTasks<T =
|
|
178
|
-
createTask<T =
|
|
179
|
-
updateTask<T =
|
|
115
|
+
getTask<T extends TaskService.TaskInput = TaskService.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput>(id: string): Promise<IGetTaskResponse<T, O> | null>;
|
|
116
|
+
listTasks<T extends TaskService.TaskInput = TaskService.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput>(params?: IListTaskParams): Promise<IListTasksResponse<T, O>>;
|
|
117
|
+
createTask<T extends TaskService.TaskInput = TaskService.TaskInput>(task: ITaskCreateData<T>): Promise<ICreateTaskResponse<T>>;
|
|
118
|
+
updateTask<T extends TaskService.TaskInput = TaskService.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput>(id: string, data: Partial<ITaskUpdateData<T, O>>): Promise<IUpdateTaskResponse<T, O>>;
|
|
180
119
|
deleteTask(id: string): Promise<IDeleteTaskResponse>;
|
|
120
|
+
/**
|
|
121
|
+
* Recursively delete a task, its logs (if any were written), and its entire
|
|
122
|
+
* descendant subtree. Best-effort: per-record failures are logged and swallowed,
|
|
123
|
+
* the method never throws.
|
|
124
|
+
*/
|
|
125
|
+
cleanupTaskSubtree(id: string): Promise<void>;
|
|
181
126
|
/**
|
|
182
127
|
* Logs
|
|
183
128
|
*/
|
|
@@ -187,19 +132,10 @@ export interface ITasksContextCrudObject {
|
|
|
187
132
|
getLog(id: string): Promise<ITaskLog | null>;
|
|
188
133
|
getLatestLog(taskId: string): Promise<ITaskLog>;
|
|
189
134
|
listLogs(params: IListTaskLogParams): Promise<IListTaskLogsResponse>;
|
|
190
|
-
/**
|
|
191
|
-
* Lifecycle events.
|
|
192
|
-
*/
|
|
193
|
-
onTaskBeforeCreate: Topic<OnTaskBeforeCreateTopicParams>;
|
|
194
|
-
onTaskAfterCreate: Topic<OnTaskAfterCreateTopicParams>;
|
|
195
|
-
onTaskBeforeUpdate: Topic<OnTaskBeforeUpdateTopicParams>;
|
|
196
|
-
onTaskAfterUpdate: Topic<OnTaskAfterUpdateTopicParams>;
|
|
197
|
-
onTaskBeforeDelete: Topic<OnTaskBeforeDeleteTopicParams>;
|
|
198
|
-
onTaskAfterDelete: Topic<OnTaskAfterDeleteTopicParams>;
|
|
199
135
|
}
|
|
200
136
|
export interface ITasksContextDefinitionObject {
|
|
201
|
-
getDefinition: <
|
|
202
|
-
listDefinitions: () =>
|
|
137
|
+
getDefinition: <I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput>(id: string) => TaskDefinition.Runnable<I, O> | null;
|
|
138
|
+
listDefinitions: () => TaskDefinition.Interface[];
|
|
203
139
|
}
|
|
204
140
|
export interface ITaskTriggerParams<I = ITaskDataInput> {
|
|
205
141
|
parent?: Pick<ITask, "id">;
|
|
@@ -213,128 +149,19 @@ export interface ITaskAbortParams {
|
|
|
213
149
|
message?: string;
|
|
214
150
|
}
|
|
215
151
|
export interface ITasksContextServiceObject {
|
|
216
|
-
trigger: <T =
|
|
217
|
-
abort: <T =
|
|
218
|
-
fetchServiceInfo: (input: ITask<any, any> | string) => Promise<IStepFunctionServiceFetchResult
|
|
152
|
+
trigger: <T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput>(params: ITaskTriggerParams<T>) => Promise<Result<ITask<T, O>, BaseError>>;
|
|
153
|
+
abort: <T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput>(params: ITaskAbortParams) => Promise<Result<ITask<T, O>, BaseError>>;
|
|
154
|
+
fetchServiceInfo: (input: ITask<any, any> | string) => Promise<Result<IStepFunctionServiceFetchResult, BaseError>>;
|
|
219
155
|
}
|
|
220
156
|
export interface ITasksContextObject extends ITasksContextCrudObject, ITasksContextDefinitionObject, ITasksContextServiceObject {
|
|
221
157
|
}
|
|
222
158
|
export interface Context extends BaseContext {
|
|
223
159
|
tasks: ITasksContextObject;
|
|
224
160
|
}
|
|
225
|
-
export interface ITaskRunParams<C extends Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
226
|
-
context: C;
|
|
227
|
-
response: ITaskResponse<I, O>;
|
|
228
|
-
isCloseToTimeout: IIsCloseToTimeoutCallable;
|
|
229
|
-
isAborted(): boolean;
|
|
230
|
-
input: I;
|
|
231
|
-
store: ITaskManagerStore<I>;
|
|
232
|
-
trigger<SI = ITaskDataInput>(params: Omit<ITaskTriggerParams<SI>, "parent">): Promise<ITask<SI>>;
|
|
233
|
-
timer: ITimer;
|
|
234
|
-
}
|
|
235
|
-
export interface ITaskOnSuccessParams<C extends Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
236
|
-
context: C;
|
|
237
|
-
task: ITask<I, O>;
|
|
238
|
-
}
|
|
239
|
-
export interface ITaskOnErrorParams<C extends Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
240
|
-
context: C;
|
|
241
|
-
task: ITask<I, O>;
|
|
242
|
-
}
|
|
243
|
-
export interface ITaskOnAbortParams<C extends Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
244
|
-
context: C;
|
|
245
|
-
task: ITask<I, O>;
|
|
246
|
-
}
|
|
247
|
-
export interface ITaskOnMaxIterationsParams<C extends Context> {
|
|
248
|
-
context: C;
|
|
249
|
-
task: ITask;
|
|
250
|
-
}
|
|
251
|
-
export declare enum TaskResponseStatus {
|
|
252
|
-
DONE = "done",
|
|
253
|
-
ERROR = "error",
|
|
254
|
-
CONTINUE = "continue",
|
|
255
|
-
ABORTED = "aborted"
|
|
256
|
-
}
|
|
257
|
-
export type ITaskDefinitionField = Pick<CmsModelField, "fieldId" | "type" | "label" | "renderer" | "helpText" | "placeholderText" | "predefinedValues" | "validation" | "listValidation" | "multipleValues" | "settings">;
|
|
258
|
-
export interface ITaskBeforeTriggerParams<C extends Context = Context, I = ITaskDataInput> {
|
|
259
|
-
context: C;
|
|
260
|
-
data: ITaskCreateData<I>;
|
|
261
|
-
}
|
|
262
|
-
export interface ITaskCreateInputValidationParams<C extends Context = Context> {
|
|
263
|
-
validator: typeof zod;
|
|
264
|
-
context: C;
|
|
265
|
-
}
|
|
266
|
-
export interface ITaskDefinition<C extends Context = Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
267
|
-
/**
|
|
268
|
-
* ID of the task must be unique in the system.
|
|
269
|
-
* It should be in camelCase format, for example: "myCustomTask".
|
|
270
|
-
*
|
|
271
|
-
* TODO: figure out a way to force camelCase in types.
|
|
272
|
-
* CamelCase from type-fest does not help with this.
|
|
273
|
-
*/
|
|
274
|
-
id: string;
|
|
275
|
-
/**
|
|
276
|
-
* Name should be unique, as it will get used to identify the task in the UI.
|
|
277
|
-
*/
|
|
278
|
-
title: string;
|
|
279
|
-
/**
|
|
280
|
-
* A description of the task, for the UI.
|
|
281
|
-
*/
|
|
282
|
-
description?: string;
|
|
283
|
-
/**
|
|
284
|
-
* Maximum number a step function can call the Lambda.
|
|
285
|
-
*/
|
|
286
|
-
maxIterations: number;
|
|
287
|
-
/**
|
|
288
|
-
* Disable storing logs in database for this task.
|
|
289
|
-
*/
|
|
290
|
-
disableDatabaseLogs?: boolean;
|
|
291
|
-
/**
|
|
292
|
-
* Task run method.
|
|
293
|
-
*/
|
|
294
|
-
run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult>;
|
|
295
|
-
/**
|
|
296
|
-
* When a new task is about to be triggered, we will run this method.
|
|
297
|
-
* For example, you can use this method to check if there is a task of the same type already running.
|
|
298
|
-
*/
|
|
299
|
-
onBeforeTrigger?<T = ITaskDataInput>(params: ITaskBeforeTriggerParams<C, T>): Promise<void>;
|
|
300
|
-
/**
|
|
301
|
-
* When task successfully finishes, this method will be called.
|
|
302
|
-
* This will be called during the run time of the task.
|
|
303
|
-
*/
|
|
304
|
-
onDone?(params: ITaskOnSuccessParams<C, I, O>): Promise<void>;
|
|
305
|
-
/**
|
|
306
|
-
* When task fails, this method will be called.
|
|
307
|
-
* This will be called during the run time of the task.
|
|
308
|
-
*/
|
|
309
|
-
onError?(params: ITaskOnErrorParams<C, I>): Promise<void>;
|
|
310
|
-
/**
|
|
311
|
-
* When task is aborted, this method will be called.
|
|
312
|
-
* This method will be called when user aborts the task.
|
|
313
|
-
*/
|
|
314
|
-
onAbort?(params: ITaskOnAbortParams<C, I, O>): Promise<void>;
|
|
315
|
-
/**
|
|
316
|
-
* When task hits max iterations, this method will be called.
|
|
317
|
-
* This will be called during the run time of the task.
|
|
318
|
-
*/
|
|
319
|
-
onMaxIterations?(params: ITaskOnMaxIterationsParams<C>): Promise<void>;
|
|
320
|
-
/**
|
|
321
|
-
* Create a validation schema for the task input.
|
|
322
|
-
* This will be used to validate the input before the task is triggered.
|
|
323
|
-
*
|
|
324
|
-
* By default, the input validation validates the input against the fields defined in the task definition.
|
|
325
|
-
* But it also passes through any fields which might not be defined in the task validation.
|
|
326
|
-
*/
|
|
327
|
-
createInputValidation?: (params: ITaskCreateInputValidationParams<C>) => GenericRecord<keyof I, zod.Schema> | zod.Schema;
|
|
328
|
-
/**
|
|
329
|
-
* Custom input fields and layout for the task input.
|
|
330
|
-
*/
|
|
331
|
-
fields?: ITaskDefinitionField[];
|
|
332
|
-
/**
|
|
333
|
-
* Is the task visible when listing?
|
|
334
|
-
*/
|
|
335
|
-
isPrivate?: boolean;
|
|
336
|
-
}
|
|
337
161
|
export interface TaskPermission extends SecurityPermission {
|
|
338
162
|
name: "task";
|
|
339
163
|
rwd?: string;
|
|
340
164
|
}
|
|
165
|
+
export type ITask<I extends TaskService.TaskInput = TaskService.TaskInput, O extends TaskService.GenericOutput = TaskService.GenericOutput> = TaskService.Task<I, O>;
|
|
166
|
+
export type SelfCleanup = TaskDefinition.SelfCleanup;
|
|
167
|
+
export type SelfCleanupEvent = TaskDefinition.SelfCleanupEvent;
|
package/types.js
CHANGED
|
@@ -1,56 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
TaskLogItemType: true,
|
|
8
|
-
TaskDataStatus: true,
|
|
9
|
-
TaskResponseStatus: true
|
|
10
|
-
};
|
|
11
|
-
exports.TaskResponseStatus = exports.TaskLogItemType = exports.TaskDataStatus = void 0;
|
|
12
|
-
var _types = require("./handler/types");
|
|
13
|
-
Object.keys(_types).forEach(function (key) {
|
|
14
|
-
if (key === "default" || key === "__esModule") return;
|
|
15
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
17
|
-
Object.defineProperty(exports, key, {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _types[key];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
var _abstractions = require("./response/abstractions");
|
|
25
|
-
Object.keys(_abstractions).forEach(function (key) {
|
|
26
|
-
if (key === "default" || key === "__esModule") return;
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
-
if (key in exports && exports[key] === _abstractions[key]) return;
|
|
29
|
-
Object.defineProperty(exports, key, {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return _abstractions[key];
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
var _abstractions2 = require("./runner/abstractions");
|
|
37
|
-
Object.keys(_abstractions2).forEach(function (key) {
|
|
38
|
-
if (key === "default" || key === "__esModule") return;
|
|
39
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
40
|
-
if (key in exports && exports[key] === _abstractions2[key]) return;
|
|
41
|
-
Object.defineProperty(exports, key, {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () {
|
|
44
|
-
return _abstractions2[key];
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
let TaskLogItemType = exports.TaskLogItemType = /*#__PURE__*/function (TaskLogItemType) {
|
|
1
|
+
// TODO had to import for augmentation to work, but is there a better way to do this?
|
|
2
|
+
import "./features/TaskController/augmentation.js";
|
|
3
|
+
export * from "./handler/types.js";
|
|
4
|
+
export * from "./response/abstractions/index.js";
|
|
5
|
+
export * from "./runner/abstractions/index.js";
|
|
6
|
+
export let TaskLogItemType = /*#__PURE__*/function (TaskLogItemType) {
|
|
49
7
|
TaskLogItemType["INFO"] = "info";
|
|
50
8
|
TaskLogItemType["ERROR"] = "error";
|
|
51
9
|
return TaskLogItemType;
|
|
52
10
|
}({});
|
|
53
|
-
let TaskDataStatus =
|
|
11
|
+
export let TaskDataStatus = /*#__PURE__*/function (TaskDataStatus) {
|
|
54
12
|
TaskDataStatus["PENDING"] = "pending";
|
|
55
13
|
TaskDataStatus["RUNNING"] = "running";
|
|
56
14
|
TaskDataStatus["FAILED"] = "failed";
|
|
@@ -58,12 +16,5 @@ let TaskDataStatus = exports.TaskDataStatus = /*#__PURE__*/function (TaskDataSta
|
|
|
58
16
|
TaskDataStatus["ABORTED"] = "aborted";
|
|
59
17
|
return TaskDataStatus;
|
|
60
18
|
}({});
|
|
61
|
-
let TaskResponseStatus = exports.TaskResponseStatus = /*#__PURE__*/function (TaskResponseStatus) {
|
|
62
|
-
TaskResponseStatus["DONE"] = "done";
|
|
63
|
-
TaskResponseStatus["ERROR"] = "error";
|
|
64
|
-
TaskResponseStatus["CONTINUE"] = "continue";
|
|
65
|
-
TaskResponseStatus["ABORTED"] = "aborted";
|
|
66
|
-
return TaskResponseStatus;
|
|
67
|
-
}({});
|
|
68
19
|
|
|
69
20
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_abstractions","_abstractions2","TaskLogItemType","TaskDataStatus","TaskResponseStatus"],"sources":["types.ts"],"sourcesContent":["import type {\n CmsContext as BaseContext,\n CmsEntryListParams,\n CmsEntryListWhere,\n CmsEntryMeta,\n CmsModel,\n CmsModelField\n} from \"@webiny/api-headless-cms/types\";\nimport type { Topic } from \"@webiny/pubsub/types\";\nimport type {\n IResponseError,\n ITaskResponse,\n ITaskResponseDoneResultOutput,\n ITaskResponseResult\n} from \"~/response/abstractions\";\nimport type { IIsCloseToTimeoutCallable, ITaskManagerStore } from \"./runner/abstractions\";\nimport type { SecurityPermission } from \"@webiny/api-security/types\";\nimport type { GenericRecord } from \"@webiny/api/types\";\nimport type { IStepFunctionServiceFetchResult } from \"~/service/StepFunctionServicePlugin\";\nimport type { ITimer } from \"@webiny/handler-aws\";\n\nimport type zod from \"zod\";\n\nexport * from \"./handler/types\";\nexport * from \"./response/abstractions\";\nexport * from \"./runner/abstractions\";\n\nexport type ITaskDataInput = GenericRecord;\n\nexport enum TaskLogItemType {\n INFO = \"info\",\n ERROR = \"error\"\n}\n\nexport interface ITaskLogItemData {\n [key: string]: any;\n}\n\nexport interface ITaskLogItemBase {\n message: string;\n createdOn: string;\n type: TaskLogItemType;\n data?: ITaskLogItemData;\n}\n\nexport interface ITaskLogItemInfo extends ITaskLogItemBase {\n type: TaskLogItemType.INFO;\n}\n\nexport interface ITaskLogItemError extends ITaskLogItemBase {\n type: TaskLogItemType.ERROR;\n error?: IResponseError;\n}\n\nexport type ITaskLogItem = ITaskLogItemInfo | ITaskLogItemError;\n\nexport interface ITaskLog {\n /**\n * ID without the revision number (for example: #0001).\n */\n id: string;\n createdOn: string;\n createdBy: ITaskIdentity;\n executionName: string;\n task: string;\n iteration: number;\n items: ITaskLogItem[];\n}\n\nexport enum TaskDataStatus {\n PENDING = \"pending\",\n RUNNING = \"running\",\n FAILED = \"failed\",\n SUCCESS = \"success\",\n ABORTED = \"aborted\"\n}\n\nexport interface ITaskIdentity {\n id: string;\n displayName: string | null;\n type: string;\n}\n\nexport interface ITask<\n T = GenericRecord,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n /**\n * ID without the revision number (for example: #0001).\n */\n id: string;\n name: string;\n taskStatus: TaskDataStatus;\n definitionId: string;\n executionName: string;\n input: T;\n output?: O;\n createdOn: string;\n savedOn: string;\n createdBy: ITaskIdentity;\n startedOn?: string;\n finishedOn?: string;\n eventResponse: GenericRecord | undefined;\n iterations: number;\n parentId?: string;\n}\n\nexport type IGetTaskResponse<\n T = any,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = ITask<T, O> | null;\n\nexport interface IListTasksResponse<\n T = any,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n items: ITask<T, O>[];\n meta: CmsEntryMeta;\n}\n\nexport interface IListTaskLogsResponse {\n items: ITaskLog[];\n meta: CmsEntryMeta;\n}\n\nexport type ICreateTaskResponse<\n T = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = ITask<T, O>;\nexport type IUpdateTaskResponse<\n T = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = ITask<T, O>;\nexport type IDeleteTaskResponse = boolean;\n\nexport interface IListTaskParamsWhere extends CmsEntryListWhere {\n parentId?: string;\n parentId_not?: string;\n parentId_in?: string[];\n parentId_not_in?: string[];\n definitionId?: string;\n definitionId_not?: string;\n definitionId_in?: string[];\n definitionId_not_in?: string[];\n taskStatus?: string;\n taskStatus_not?: string;\n taskStatus_in?: string[];\n taskStatus_not_in?: string[];\n}\n\nexport interface IListTaskParams extends Omit<CmsEntryListParams, \"fields\" | \"search\"> {\n where?: IListTaskParamsWhere;\n}\n\nexport interface IListTaskLogParamsWhere extends CmsEntryListWhere {\n task?: string;\n task_in?: string[];\n task_not?: string;\n iteration?: number;\n iteration_not?: number;\n iteration_gte?: number;\n iteration_gt?: number;\n iteration_lte?: number;\n iteration_lt?: number;\n}\n\nexport interface IListTaskLogParams extends Omit<CmsEntryListParams, \"fields\" | \"search\"> {\n where?: IListTaskLogParamsWhere;\n}\n\nexport interface ITaskCreateData<T = ITaskDataInput> {\n definitionId: string;\n name: string;\n input: T;\n parentId?: string;\n}\n\nexport interface ITaskUpdateData<\n I = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n name?: string;\n input?: I;\n output?: O;\n taskStatus?: TaskDataStatus;\n executionName?: string;\n startedOn?: string;\n finishedOn?: string;\n eventResponse?: GenericRecord;\n iterations?: number;\n}\n\nexport interface OnTaskBeforeCreateTopicParams {\n input: ITaskCreateData;\n}\n\nexport interface OnTaskAfterCreateTopicParams {\n input: ITaskCreateData;\n task: ITask;\n}\n\nexport interface OnTaskBeforeUpdateTopicParams {\n input: ITaskUpdateData;\n original: ITask;\n}\n\nexport interface OnTaskAfterUpdateTopicParams {\n input: ITaskUpdateData;\n task: ITask;\n}\n\nexport interface OnTaskBeforeDeleteTopicParams {\n task: ITask;\n}\n\nexport interface OnTaskAfterDeleteTopicParams {\n task: ITask;\n}\n\nexport interface ITaskLogCreateInput {\n executionName: string;\n iteration: number;\n}\n\nexport interface ITaskLogUpdateInput {\n items?: ITaskLogItem[];\n}\n\nexport interface ITasksContextCrudObject {\n /**\n * Models\n */\n getTaskModel(): Promise<CmsModel>;\n getLogModel(): Promise<CmsModel>;\n /**\n * Tasks\n */\n getTask<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(\n id: string\n ): Promise<IGetTaskResponse<T, O> | null>;\n listTasks<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(\n params?: IListTaskParams\n ): Promise<IListTasksResponse<T, O>>;\n createTask<T = any>(task: ITaskCreateData<T>): Promise<ICreateTaskResponse<T>>;\n updateTask<\n T = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n >(\n id: string,\n data: Partial<ITaskUpdateData<T, O>>\n ): Promise<IUpdateTaskResponse<T, O>>;\n deleteTask(id: string): Promise<IDeleteTaskResponse>;\n /**\n * Logs\n */\n createLog(task: Pick<ITask, \"id\">, data: ITaskLogCreateInput): Promise<ITaskLog>;\n updateLog(id: string, data: ITaskLogUpdateInput): Promise<ITaskLog>;\n deleteLog(id: string): Promise<boolean>;\n getLog(id: string): Promise<ITaskLog | null>;\n getLatestLog(taskId: string): Promise<ITaskLog>;\n listLogs(params: IListTaskLogParams): Promise<IListTaskLogsResponse>;\n /**\n * Lifecycle events.\n */\n onTaskBeforeCreate: Topic<OnTaskBeforeCreateTopicParams>;\n onTaskAfterCreate: Topic<OnTaskAfterCreateTopicParams>;\n onTaskBeforeUpdate: Topic<OnTaskBeforeUpdateTopicParams>;\n onTaskAfterUpdate: Topic<OnTaskAfterUpdateTopicParams>;\n onTaskBeforeDelete: Topic<OnTaskBeforeDeleteTopicParams>;\n onTaskAfterDelete: Topic<OnTaskAfterDeleteTopicParams>;\n}\n\nexport interface ITasksContextDefinitionObject {\n getDefinition: <\n C extends Context = Context,\n I = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n >(\n id: string\n ) => ITaskDefinition<C, I, O> | null;\n listDefinitions: () => ITaskDefinition[];\n}\n\nexport interface ITaskTriggerParams<I = ITaskDataInput> {\n parent?: Pick<ITask, \"id\">;\n definition: string;\n name?: string;\n input?: I;\n delay?: number;\n}\n\nexport interface ITaskAbortParams {\n id: string;\n message?: string;\n}\n\nexport interface ITasksContextServiceObject {\n trigger: <\n T = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n >(\n params: ITaskTriggerParams<T>\n ) => Promise<ITask<T, O>>;\n abort: <\n T = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n >(\n params: ITaskAbortParams\n ) => Promise<ITask<T, O>>;\n fetchServiceInfo: (\n input: ITask<any, any> | string\n ) => Promise<IStepFunctionServiceFetchResult | null>;\n}\n\nexport interface ITasksContextObject\n extends ITasksContextCrudObject,\n ITasksContextDefinitionObject,\n ITasksContextServiceObject {}\n\nexport interface Context extends BaseContext {\n tasks: ITasksContextObject;\n}\n\nexport interface ITaskRunParams<\n C extends Context,\n I = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n context: C;\n response: ITaskResponse<I, O>;\n isCloseToTimeout: IIsCloseToTimeoutCallable;\n isAborted(): boolean;\n input: I;\n store: ITaskManagerStore<I>;\n trigger<SI = ITaskDataInput>(\n params: Omit<ITaskTriggerParams<SI>, \"parent\">\n ): Promise<ITask<SI>>;\n timer: ITimer;\n}\n\nexport interface ITaskOnSuccessParams<\n C extends Context,\n I = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n context: C;\n task: ITask<I, O>;\n}\n\nexport interface ITaskOnErrorParams<\n C extends Context,\n I = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n context: C;\n task: ITask<I, O>;\n}\n\nexport interface ITaskOnAbortParams<\n C extends Context,\n I = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n context: C;\n task: ITask<I, O>;\n}\n\nexport interface ITaskOnMaxIterationsParams<C extends Context> {\n context: C;\n task: ITask;\n}\n\nexport enum TaskResponseStatus {\n DONE = \"done\",\n ERROR = \"error\",\n CONTINUE = \"continue\",\n ABORTED = \"aborted\"\n}\n\nexport type ITaskDefinitionField = Pick<\n CmsModelField,\n | \"fieldId\"\n | \"type\"\n | \"label\"\n | \"renderer\"\n | \"helpText\"\n | \"placeholderText\"\n | \"predefinedValues\"\n | \"validation\"\n | \"listValidation\"\n | \"multipleValues\"\n | \"settings\"\n>;\n\nexport interface ITaskBeforeTriggerParams<C extends Context = Context, I = ITaskDataInput> {\n context: C;\n data: ITaskCreateData<I>;\n}\n\nexport interface ITaskCreateInputValidationParams<C extends Context = Context> {\n validator: typeof zod;\n context: C;\n}\n\nexport interface ITaskDefinition<\n C extends Context = Context,\n I = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n /**\n * ID of the task must be unique in the system.\n * It should be in camelCase format, for example: \"myCustomTask\".\n *\n * TODO: figure out a way to force camelCase in types.\n * CamelCase from type-fest does not help with this.\n */\n id: string;\n /**\n * Name should be unique, as it will get used to identify the task in the UI.\n */\n title: string;\n /**\n * A description of the task, for the UI.\n */\n description?: string;\n /**\n * Maximum number a step function can call the Lambda.\n */\n maxIterations: number;\n /**\n * Disable storing logs in database for this task.\n */\n disableDatabaseLogs?: boolean;\n /**\n * Task run method.\n */\n run(params: ITaskRunParams<C, I, O>): Promise<ITaskResponseResult>;\n /**\n * When a new task is about to be triggered, we will run this method.\n * For example, you can use this method to check if there is a task of the same type already running.\n */\n onBeforeTrigger?<T = ITaskDataInput>(params: ITaskBeforeTriggerParams<C, T>): Promise<void>;\n /**\n * When task successfully finishes, this method will be called.\n * This will be called during the run time of the task.\n */\n onDone?(params: ITaskOnSuccessParams<C, I, O>): Promise<void>;\n /**\n * When task fails, this method will be called.\n * This will be called during the run time of the task.\n */\n onError?(params: ITaskOnErrorParams<C, I>): Promise<void>;\n /**\n * When task is aborted, this method will be called.\n * This method will be called when user aborts the task.\n */\n onAbort?(params: ITaskOnAbortParams<C, I, O>): Promise<void>;\n /**\n * When task hits max iterations, this method will be called.\n * This will be called during the run time of the task.\n */\n onMaxIterations?(params: ITaskOnMaxIterationsParams<C>): Promise<void>;\n /**\n * Create a validation schema for the task input.\n * This will be used to validate the input before the task is triggered.\n *\n * By default, the input validation validates the input against the fields defined in the task definition.\n * But it also passes through any fields which might not be defined in the task validation.\n */\n createInputValidation?: (\n params: ITaskCreateInputValidationParams<C>\n ) => GenericRecord<keyof I, zod.Schema> | zod.Schema;\n /**\n * Custom input fields and layout for the task input.\n */\n fields?: ITaskDefinitionField[];\n /**\n * Is the task visible when listing?\n */\n isPrivate?: boolean;\n}\n\nexport interface TaskPermission extends SecurityPermission {\n name: \"task\";\n rwd?: string;\n}\n"],"mappings":";;;;;;;;;;;AAuBA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,aAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,aAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,aAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,cAAA,GAAAd,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAY,cAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,cAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,cAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AAAsC,IAI1BW,eAAe,GAAAN,OAAA,CAAAM,eAAA,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAAA,IAwCfC,cAAc,GAAAP,OAAA,CAAAO,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAAA,IA+SdC,kBAAkB,GAAAR,OAAA,CAAAQ,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["TaskLogItemType","TaskDataStatus"],"sources":["types.ts"],"sourcesContent":["import type {\n CmsContext as BaseContext,\n CmsEntryListParams,\n CmsEntryMeta,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IResponseError } from \"~/response/abstractions/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { IStepFunctionServiceFetchResult } from \"~/service/StepFunctionServicePlugin.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\nimport type { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport { BaseError, Result } from \"@webiny/feature/api\";\nimport type { IdInterfaceGenerator, NumericInterfaceGenerator } from \"@webiny/api\";\n// TODO had to import for augmentation to work, but is there a better way to do this?\nimport \"./features/TaskController/augmentation.js\";\n\nexport * from \"./handler/types.js\";\nexport * from \"./response/abstractions/index.js\";\nexport * from \"./runner/abstractions/index.js\";\n\nexport type ITaskDataInput = GenericRecord;\n\nexport enum TaskLogItemType {\n INFO = \"info\",\n ERROR = \"error\"\n}\n\nexport interface ITaskLogItemData {\n [key: string]: any;\n}\n\nexport interface ITaskLogItemBase {\n message: string;\n createdOn: string;\n type: TaskLogItemType;\n data?: ITaskLogItemData;\n}\n\nexport interface ITaskLogItemInfo extends ITaskLogItemBase {\n type: TaskLogItemType.INFO;\n}\n\nexport interface ITaskLogItemError extends ITaskLogItemBase {\n type: TaskLogItemType.ERROR;\n error?: IResponseError;\n}\n\nexport type ITaskLogItem = ITaskLogItemInfo | ITaskLogItemError;\n\nexport interface ITaskLog {\n /**\n * ID without the revision number (for example: #0001).\n */\n id: string;\n createdOn: string;\n createdBy: ITaskIdentity;\n executionName: string;\n task: string;\n iteration: number;\n items: ITaskLogItem[];\n}\n\nexport enum TaskDataStatus {\n PENDING = \"pending\",\n RUNNING = \"running\",\n FAILED = \"failed\",\n SUCCESS = \"success\",\n ABORTED = \"aborted\"\n}\n\nexport interface ITaskIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n\nexport type IGetTaskResponse<\n T extends TaskService.TaskInput = TaskService.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n> = ITask<T, O> | null;\n\nexport interface IListTasksResponse<\n T extends TaskService.TaskInput = TaskService.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n> {\n items: ITask<T, O>[];\n meta: CmsEntryMeta;\n}\n\nexport interface IListTaskLogsResponse {\n items: ITaskLog[];\n meta: CmsEntryMeta;\n}\n\nexport type ICreateTaskResponse<\n T extends TaskService.TaskInput = TaskService.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n> = ITask<T, O>;\nexport type IUpdateTaskResponse<\n T extends TaskService.TaskInput = TaskService.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n> = ITask<T, O>;\nexport type IDeleteTaskResponse = boolean;\n\nexport interface IListTaskParamsWhere\n extends\n IdInterfaceGenerator<\"id\">,\n IdInterfaceGenerator<\"parentId\">,\n IdInterfaceGenerator<\"definitionId\">,\n IdInterfaceGenerator<\"taskStatus\"> {\n //\n}\n\nexport interface IListTaskParams extends Omit<CmsEntryListParams, \"fields\" | \"search\"> {\n where?: IListTaskParamsWhere;\n}\n\nexport interface IListTaskLogParamsWhere\n extends\n IdInterfaceGenerator<\"id\">,\n IdInterfaceGenerator<\"task\">,\n NumericInterfaceGenerator<\"iteration\"> {}\n\nexport interface IListTaskLogParams extends Omit<\n CmsEntryListParams,\n \"fields\" | \"search\" | \"where\"\n> {\n where?: IListTaskLogParamsWhere;\n}\n\nexport interface ITaskCreateData<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {\n definitionId: string;\n name: string;\n input: T;\n parentId?: string;\n}\n\nexport interface ITaskUpdateData<\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> {\n name?: string;\n input?: I;\n output?: O;\n taskStatus?: TaskDataStatus;\n executionName?: string;\n startedOn?: string;\n finishedOn?: string;\n eventResponse?: GenericRecord;\n iterations?: number;\n}\n\nexport interface ITaskLogCreateInput {\n executionName: string;\n iteration: number;\n}\n\nexport interface ITaskLogUpdateInput {\n items?: ITaskLogItem[];\n}\n\nexport interface ITasksContextCrudObject {\n /**\n * Models\n */\n getTaskModel(): Promise<CmsModel>;\n getLogModel(): Promise<CmsModel>;\n /**\n * Tasks\n */\n getTask<\n T extends TaskService.TaskInput = TaskService.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n >(\n id: string\n ): Promise<IGetTaskResponse<T, O> | null>;\n listTasks<\n T extends TaskService.TaskInput = TaskService.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n >(\n params?: IListTaskParams\n ): Promise<IListTasksResponse<T, O>>;\n createTask<T extends TaskService.TaskInput = TaskService.TaskInput>(\n task: ITaskCreateData<T>\n ): Promise<ICreateTaskResponse<T>>;\n updateTask<\n T extends TaskService.TaskInput = TaskService.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n >(\n id: string,\n data: Partial<ITaskUpdateData<T, O>>\n ): Promise<IUpdateTaskResponse<T, O>>;\n deleteTask(id: string): Promise<IDeleteTaskResponse>;\n /**\n * Recursively delete a task, its logs (if any were written), and its entire\n * descendant subtree. Best-effort: per-record failures are logged and swallowed,\n * the method never throws.\n */\n cleanupTaskSubtree(id: string): Promise<void>;\n /**\n * Logs\n */\n createLog(task: Pick<ITask, \"id\">, data: ITaskLogCreateInput): Promise<ITaskLog>;\n updateLog(id: string, data: ITaskLogUpdateInput): Promise<ITaskLog>;\n deleteLog(id: string): Promise<boolean>;\n getLog(id: string): Promise<ITaskLog | null>;\n getLatestLog(taskId: string): Promise<ITaskLog>;\n listLogs(params: IListTaskLogParams): Promise<IListTaskLogsResponse>;\n}\n\nexport interface ITasksContextDefinitionObject {\n getDefinition: <\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n >(\n id: string\n ) => TaskDefinition.Runnable<I, O> | null;\n listDefinitions: () => TaskDefinition.Interface[];\n}\n\nexport interface ITaskTriggerParams<I = ITaskDataInput> {\n parent?: Pick<ITask, \"id\">;\n definition: string;\n name?: string;\n input?: I;\n delay?: number;\n}\n\nexport interface ITaskAbortParams {\n id: string;\n message?: string;\n}\n\nexport interface ITasksContextServiceObject {\n trigger: <\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n >(\n params: ITaskTriggerParams<T>\n ) => Promise<Result<ITask<T, O>, BaseError>>;\n abort: <\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n >(\n params: ITaskAbortParams\n ) => Promise<Result<ITask<T, O>, BaseError>>;\n fetchServiceInfo: (\n input: ITask<any, any> | string\n ) => Promise<Result<IStepFunctionServiceFetchResult, BaseError>>;\n}\n\nexport interface ITasksContextObject\n extends ITasksContextCrudObject, ITasksContextDefinitionObject, ITasksContextServiceObject {}\n\nexport interface Context extends BaseContext {\n tasks: ITasksContextObject;\n}\n\nexport interface TaskPermission extends SecurityPermission {\n name: \"task\";\n rwd?: string;\n}\n\nexport type ITask<\n I extends TaskService.TaskInput = TaskService.TaskInput,\n O extends TaskService.GenericOutput = TaskService.GenericOutput\n> = TaskService.Task<I, O>;\n\nexport type SelfCleanup = TaskDefinition.SelfCleanup;\nexport type SelfCleanupEvent = TaskDefinition.SelfCleanupEvent;\n"],"mappings":"AAcA;AACA;AAEA;AACA;AACA;AAIA,WAAYA,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAwC3B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
|
package/utils/ObjectUpdater.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ObjectUpdater = void 0;
|
|
7
|
-
var _objectMergeAdvanced = require("object-merge-advanced");
|
|
8
1
|
/**
|
|
9
2
|
* We need to use the object-merge-advanced library to merge array items properly.
|
|
10
3
|
* With plain assign or lodash merge, we will lose array items from the source object.
|
|
11
4
|
*/
|
|
12
5
|
|
|
6
|
+
import { mergeAdvanced } from "object-merge-advanced";
|
|
13
7
|
const mergeOptions = {
|
|
14
8
|
hardArrayConcat: true
|
|
15
9
|
};
|
|
16
|
-
class ObjectUpdater {
|
|
10
|
+
export class ObjectUpdater {
|
|
17
11
|
data = {};
|
|
18
12
|
merge(target, clear = true) {
|
|
19
|
-
const item =
|
|
13
|
+
const item = mergeAdvanced(target, this.data, mergeOptions);
|
|
20
14
|
if (!clear) {
|
|
21
15
|
return item;
|
|
22
16
|
}
|
|
@@ -32,7 +26,7 @@ class ObjectUpdater {
|
|
|
32
26
|
return values;
|
|
33
27
|
}
|
|
34
28
|
update(input) {
|
|
35
|
-
this.data =
|
|
29
|
+
this.data = mergeAdvanced(this.data, input, mergeOptions);
|
|
36
30
|
}
|
|
37
31
|
isDirty() {
|
|
38
32
|
return Object.keys(this.data).length > 0;
|
|
@@ -41,6 +35,5 @@ class ObjectUpdater {
|
|
|
41
35
|
this.data = {};
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
|
-
exports.ObjectUpdater = ObjectUpdater;
|
|
45
38
|
|
|
46
39
|
//# sourceMappingURL=ObjectUpdater.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["mergeAdvanced","mergeOptions","hardArrayConcat","ObjectUpdater","data","merge","target","clear","item","fetch","values","structuredClone","update","input","isDirty","Object","keys","length"],"sources":["ObjectUpdater.ts"],"sourcesContent":["/**\n * We need to use the object-merge-advanced library to merge array items properly.\n * With plain assign or lodash merge, we will lose array items from the source object.\n */\nimport type { defaults } from \"object-merge-advanced\";\nimport { mergeAdvanced } from \"object-merge-advanced\";\n\nconst mergeOptions: Partial<typeof defaults> = {\n hardArrayConcat: true\n};\n\nexport class ObjectUpdater<T> {\n private data: Partial<T> = {};\n\n public merge(target: T, clear = true): T {\n const item = mergeAdvanced(target, this.data, mergeOptions);\n if (!clear) {\n return item;\n }\n this.clear();\n return item;\n }\n\n public fetch(clear = true): Partial<T> {\n const values = structuredClone(this.data);\n if (!clear) {\n return values;\n }\n this.clear();\n return values;\n }\n public update(input: Partial<T>) {\n this.data = mergeAdvanced(this.data, input, mergeOptions);\n }\n\n public isDirty(): boolean {\n return Object.keys(this.data).length > 0;\n }\n\n private clear() {\n this.data = {};\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,uBAAuB;AAErD,MAAMC,YAAsC,GAAG;EAC3CC,eAAe,EAAE;AACrB,CAAC;AAED,OAAO,MAAMC,aAAa,CAAI;EAClBC,IAAI,GAAe,CAAC,CAAC;EAEtBC,KAAKA,CAACC,MAAS,EAAEC,KAAK,GAAG,IAAI,EAAK;IACrC,MAAMC,IAAI,GAAGR,aAAa,CAACM,MAAM,EAAE,IAAI,CAACF,IAAI,EAAEH,YAAY,CAAC;IAC3D,IAAI,CAACM,KAAK,EAAE;MACR,OAAOC,IAAI;IACf;IACA,IAAI,CAACD,KAAK,CAAC,CAAC;IACZ,OAAOC,IAAI;EACf;EAEOC,KAAKA,CAACF,KAAK,GAAG,IAAI,EAAc;IACnC,MAAMG,MAAM,GAAGC,eAAe,CAAC,IAAI,CAACP,IAAI,CAAC;IACzC,IAAI,CAACG,KAAK,EAAE;MACR,OAAOG,MAAM;IACjB;IACA,IAAI,CAACH,KAAK,CAAC,CAAC;IACZ,OAAOG,MAAM;EACjB;EACOE,MAAMA,CAACC,KAAiB,EAAE;IAC7B,IAAI,CAACT,IAAI,GAAGJ,aAAa,CAAC,IAAI,CAACI,IAAI,EAAES,KAAK,EAAEZ,YAAY,CAAC;EAC7D;EAEOa,OAAOA,CAAA,EAAY;IACtB,OAAOC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACZ,IAAI,CAAC,CAACa,MAAM,GAAG,CAAC;EAC5C;EAEQV,KAAKA,CAAA,EAAG;IACZ,IAAI,CAACH,IAAI,GAAG,CAAC,CAAC;EAClB;AACJ","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { IResponseError } from "../response/abstractions";
|
|
1
|
+
import type { IResponseError } from "../response/abstractions/index.js";
|
|
2
2
|
export declare const getErrorProperties: (error: Error | IResponseError) => IResponseError;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getErrorProperties = void 0;
|
|
7
|
-
var _getObjectProperties = require("./getObjectProperties");
|
|
8
|
-
const getErrorProperties = error => {
|
|
9
|
-
const value = (0, _getObjectProperties.getObjectProperties)(error);
|
|
1
|
+
import { getObjectProperties } from "./getObjectProperties.js";
|
|
2
|
+
export const getErrorProperties = error => {
|
|
3
|
+
const value = getObjectProperties(error);
|
|
10
4
|
delete value.stack;
|
|
11
5
|
return value;
|
|
12
6
|
};
|
|
13
|
-
exports.getErrorProperties = getErrorProperties;
|
|
14
7
|
|
|
15
8
|
//# sourceMappingURL=getErrorProperties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getObjectProperties","getErrorProperties","error","value","stack"],"sources":["getErrorProperties.ts"],"sourcesContent":["import type { IResponseError } from \"~/response/abstractions/index.js\";\nimport { getObjectProperties } from \"~/utils/getObjectProperties.js\";\n\nexport const getErrorProperties = (error: Error | IResponseError): IResponseError => {\n const value = getObjectProperties<IResponseError>(error);\n\n delete value.stack;\n\n return value;\n};\n"],"mappings":"AACA,SAASA,mBAAmB;AAE5B,OAAO,MAAMC,kBAAkB,GAAIC,KAA6B,IAAqB;EACjF,MAAMC,KAAK,GAAGH,mBAAmB,CAAiBE,KAAK,CAAC;EAExD,OAAOC,KAAK,CAACC,KAAK;EAElB,OAAOD,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getObjectProperties = void 0;
|
|
7
1
|
/**
|
|
8
2
|
* Unfortunately we need some casting as we do not know which properties are available on the object.
|
|
9
3
|
*/
|
|
10
4
|
|
|
11
|
-
const getObjectProperties = input => {
|
|
5
|
+
export const getObjectProperties = input => {
|
|
12
6
|
if (!input || typeof input !== "object") {
|
|
13
7
|
return {};
|
|
14
8
|
}
|
|
@@ -20,6 +14,5 @@ const getObjectProperties = input => {
|
|
|
20
14
|
return acc;
|
|
21
15
|
}, {});
|
|
22
16
|
};
|
|
23
|
-
exports.getObjectProperties = getObjectProperties;
|
|
24
17
|
|
|
25
18
|
//# sourceMappingURL=getObjectProperties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getObjectProperties","input","Object","getOwnPropertyNames","reduce","acc","key"
|
|
1
|
+
{"version":3,"names":["getObjectProperties","input","Object","getOwnPropertyNames","reduce","acc","key"],"sources":["getObjectProperties.ts"],"sourcesContent":["/**\n * Unfortunately we need some casting as we do not know which properties are available on the object.\n */\ninterface GenericRecord {\n [key: string]: any;\n}\n\nexport const getObjectProperties = <T = GenericRecord>(input: unknown): T => {\n if (!input || typeof input !== \"object\") {\n return {} as unknown as T;\n }\n return Object.getOwnPropertyNames(input).reduce<T>((acc, key) => {\n if (key === \"stack\") {\n return acc;\n }\n acc[key as keyof T] = (input as unknown as T)[key as keyof T];\n return acc;\n }, {} as T) as unknown as T;\n};\n"],"mappings":"AAAA;AACA;AACA;;AAKA,OAAO,MAAMA,mBAAmB,GAAuBC,KAAc,IAAQ;EACzE,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACrC,OAAO,CAAC,CAAC;EACb;EACA,OAAOC,MAAM,CAACC,mBAAmB,CAACF,KAAK,CAAC,CAACG,MAAM,CAAI,CAACC,GAAG,EAAEC,GAAG,KAAK;IAC7D,IAAIA,GAAG,KAAK,OAAO,EAAE;MACjB,OAAOD,GAAG;IACd;IACAA,GAAG,CAACC,GAAG,CAAY,GAAIL,KAAK,CAAkBK,GAAG,CAAY;IAC7D,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAM,CAAC;AACf,CAAC","ignoreList":[]}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./getErrorProperties";
|
|
2
|
-
export * from "./getObjectProperties";
|
|
3
|
-
export * from "./ObjectUpdater";
|
|
1
|
+
export * from "./getErrorProperties.js";
|
|
2
|
+
export * from "./getObjectProperties.js";
|
|
3
|
+
export * from "./ObjectUpdater.js";
|
package/utils/index.js
CHANGED
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _getErrorProperties = require("./getErrorProperties");
|
|
7
|
-
Object.keys(_getErrorProperties).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _getErrorProperties[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _getErrorProperties[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _getObjectProperties = require("./getObjectProperties");
|
|
18
|
-
Object.keys(_getObjectProperties).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _getObjectProperties[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _getObjectProperties[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _ObjectUpdater = require("./ObjectUpdater");
|
|
29
|
-
Object.keys(_ObjectUpdater).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _ObjectUpdater[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _ObjectUpdater[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
1
|
+
export * from "./getErrorProperties.js";
|
|
2
|
+
export * from "./getObjectProperties.js";
|
|
3
|
+
export * from "./ObjectUpdater.js";
|
|
39
4
|
|
|
40
5
|
//# sourceMappingURL=index.js.map
|