@webiny/tasks 0.0.0-unstable.06b2ede40f
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/LICENSE +21 -0
- package/README.md +10 -0
- package/context.d.ts +2 -0
- package/context.js +33 -0
- package/context.js.map +1 -0
- package/crud/crud.tasks.d.ts +2 -0
- package/crud/crud.tasks.js +273 -0
- package/crud/crud.tasks.js.map +1 -0
- package/crud/definition.tasks.d.ts +2 -0
- package/crud/definition.tasks.js +29 -0
- package/crud/definition.tasks.js.map +1 -0
- package/crud/model.d.ts +5 -0
- package/crud/model.js +216 -0
- package/crud/model.js.map +1 -0
- package/crud/service.tasks.d.ts +2 -0
- package/crud/service.tasks.js +171 -0
- package/crud/service.tasks.js.map +1 -0
- package/crud/where.d.ts +1 -0
- package/crud/where.js +33 -0
- package/crud/where.js.map +1 -0
- package/graphql/checkPermissions.d.ts +7 -0
- package/graphql/checkPermissions.js +46 -0
- package/graphql/checkPermissions.js.map +1 -0
- package/graphql/index.d.ts +2 -0
- package/graphql/index.js +351 -0
- package/graphql/index.js.map +1 -0
- package/graphql/utils.d.ts +9 -0
- package/graphql/utils.js +28 -0
- package/graphql/utils.js.map +1 -0
- package/handler/index.d.ts +6 -0
- package/handler/index.js +69 -0
- package/handler/index.js.map +1 -0
- package/handler/register.d.ts +1 -0
- package/handler/register.js +25 -0
- package/handler/register.js.map +1 -0
- package/handler/types.d.ts +25 -0
- package/handler/types.js +7 -0
- package/handler/types.js.map +1 -0
- package/index.d.ts +6 -0
- package/index.js +62 -0
- package/index.js.map +1 -0
- package/package.json +50 -0
- package/plugins/TaskServicePlugin.d.ts +20 -0
- package/plugins/TaskServicePlugin.js +17 -0
- package/plugins/TaskServicePlugin.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +18 -0
- package/plugins/index.js.map +1 -0
- package/response/DatabaseResponse.d.ts +12 -0
- package/response/DatabaseResponse.js +152 -0
- package/response/DatabaseResponse.js.map +1 -0
- package/response/Response.d.ts +13 -0
- package/response/Response.js +120 -0
- package/response/Response.js.map +1 -0
- package/response/ResponseAbortedResult.d.ts +10 -0
- package/response/ResponseAbortedResult.js +19 -0
- package/response/ResponseAbortedResult.js.map +1 -0
- package/response/ResponseContinueResult.d.ts +18 -0
- package/response/ResponseContinueResult.js +26 -0
- package/response/ResponseContinueResult.js.map +1 -0
- package/response/ResponseDoneResult.d.ts +13 -0
- package/response/ResponseDoneResult.js +21 -0
- package/response/ResponseDoneResult.js.map +1 -0
- package/response/ResponseErrorResult.d.ts +11 -0
- package/response/ResponseErrorResult.js +20 -0
- package/response/ResponseErrorResult.js.map +1 -0
- package/response/TaskResponse.d.ts +11 -0
- package/response/TaskResponse.js +80 -0
- package/response/TaskResponse.js.map +1 -0
- package/response/abstractions/Response.d.ts +25 -0
- package/response/abstractions/Response.js +7 -0
- package/response/abstractions/Response.js.map +1 -0
- package/response/abstractions/ResponseAbortedResult.d.ts +5 -0
- package/response/abstractions/ResponseAbortedResult.js +7 -0
- package/response/abstractions/ResponseAbortedResult.js.map +1 -0
- package/response/abstractions/ResponseBaseResult.d.ts +8 -0
- package/response/abstractions/ResponseBaseResult.js +7 -0
- package/response/abstractions/ResponseBaseResult.js.map +1 -0
- package/response/abstractions/ResponseContinueResult.d.ts +21 -0
- package/response/abstractions/ResponseContinueResult.js +7 -0
- package/response/abstractions/ResponseContinueResult.js.map +1 -0
- package/response/abstractions/ResponseDoneResult.d.ts +14 -0
- package/response/abstractions/ResponseDoneResult.js +7 -0
- package/response/abstractions/ResponseDoneResult.js.map +1 -0
- package/response/abstractions/ResponseErrorResult.d.ts +19 -0
- package/response/abstractions/ResponseErrorResult.js +7 -0
- package/response/abstractions/ResponseErrorResult.js.map +1 -0
- package/response/abstractions/TaskResponse.d.ts +38 -0
- package/response/abstractions/TaskResponse.js +7 -0
- package/response/abstractions/TaskResponse.js.map +1 -0
- package/response/abstractions/index.d.ts +7 -0
- package/response/abstractions/index.js +84 -0
- package/response/abstractions/index.js.map +1 -0
- package/response/index.d.ts +7 -0
- package/response/index.js +84 -0
- package/response/index.js.map +1 -0
- package/runner/TaskControl.d.ts +14 -0
- package/runner/TaskControl.js +222 -0
- package/runner/TaskControl.js.map +1 -0
- package/runner/TaskEventValidation.d.ts +5 -0
- package/runner/TaskEventValidation.js +30 -0
- package/runner/TaskEventValidation.js.map +1 -0
- package/runner/TaskManager.d.ts +14 -0
- package/runner/TaskManager.js +139 -0
- package/runner/TaskManager.js.map +1 -0
- package/runner/TaskManagerStore.d.ts +40 -0
- package/runner/TaskManagerStore.js +167 -0
- package/runner/TaskManagerStore.js.map +1 -0
- package/runner/TaskRunner.d.ts +26 -0
- package/runner/TaskRunner.js +97 -0
- package/runner/TaskRunner.js.map +1 -0
- package/runner/abstractions/TaskControl.d.ts +10 -0
- package/runner/abstractions/TaskControl.js +7 -0
- package/runner/abstractions/TaskControl.js.map +1 -0
- package/runner/abstractions/TaskEventValidation.d.ts +5 -0
- package/runner/abstractions/TaskEventValidation.js +7 -0
- package/runner/abstractions/TaskEventValidation.js.map +1 -0
- package/runner/abstractions/TaskManager.d.ts +5 -0
- package/runner/abstractions/TaskManager.js +7 -0
- package/runner/abstractions/TaskManager.js.map +1 -0
- package/runner/abstractions/TaskManagerStore.d.ts +92 -0
- package/runner/abstractions/TaskManagerStore.js +7 -0
- package/runner/abstractions/TaskManagerStore.js.map +1 -0
- package/runner/abstractions/TaskRunner.d.ts +13 -0
- package/runner/abstractions/TaskRunner.js +7 -0
- package/runner/abstractions/TaskRunner.js.map +1 -0
- package/runner/abstractions/index.d.ts +5 -0
- package/runner/abstractions/index.js +62 -0
- package/runner/abstractions/index.js.map +1 -0
- package/runner/index.d.ts +1 -0
- package/runner/index.js +18 -0
- package/runner/index.js.map +1 -0
- package/service/EventBridgeEventTransportPlugin.d.ts +17 -0
- package/service/EventBridgeEventTransportPlugin.js +60 -0
- package/service/EventBridgeEventTransportPlugin.js.map +1 -0
- package/service/StepFunctionServicePlugin.d.ts +26 -0
- package/service/StepFunctionServicePlugin.js +88 -0
- package/service/StepFunctionServicePlugin.js.map +1 -0
- package/service/createService.d.ts +6 -0
- package/service/createService.js +30 -0
- package/service/createService.js.map +1 -0
- package/service/index.d.ts +4 -0
- package/service/index.js +31 -0
- package/service/index.js.map +1 -0
- package/task/index.d.ts +2 -0
- package/task/index.js +29 -0
- package/task/index.js.map +1 -0
- package/task/input.d.ts +15 -0
- package/task/input.js +21 -0
- package/task/input.js.map +1 -0
- package/task/plugin.d.ts +36 -0
- package/task/plugin.js +106 -0
- package/task/plugin.js.map +1 -0
- package/tasks/testingRunTask.d.ts +1 -0
- package/tasks/testingRunTask.js +21 -0
- package/tasks/testingRunTask.js.map +1 -0
- package/types.d.ts +340 -0
- package/types.js +69 -0
- package/types.js.map +1 -0
- package/utils/ObjectUpdater.d.ts +8 -0
- package/utils/ObjectUpdater.js +46 -0
- package/utils/ObjectUpdater.js.map +1 -0
- package/utils/getErrorProperties.d.ts +2 -0
- package/utils/getErrorProperties.js +15 -0
- package/utils/getErrorProperties.js.map +1 -0
- package/utils/getObjectProperties.d.ts +8 -0
- package/utils/getObjectProperties.js +25 -0
- package/utils/getObjectProperties.js.map +1 -0
- package/utils/index.d.ts +3 -0
- package/utils/index.js +40 -0
- package/utils/index.js.map +1 -0
package/types.d.ts
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import type { CmsContext as BaseContext, CmsEntryListParams, CmsEntryListWhere, CmsEntryMeta, CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { Topic } from "@webiny/pubsub/types";
|
|
3
|
+
import type { IResponseError, ITaskResponse, ITaskResponseDoneResultOutput, ITaskResponseResult } from "./response/abstractions";
|
|
4
|
+
import type { IIsCloseToTimeoutCallable, ITaskManagerStore } from "./runner/abstractions";
|
|
5
|
+
import type { SecurityPermission } from "@webiny/api-security/types";
|
|
6
|
+
import type { GenericRecord } from "@webiny/api/types";
|
|
7
|
+
import type { IStepFunctionServiceFetchResult } from "./service/StepFunctionServicePlugin";
|
|
8
|
+
import type { ITimer } from "@webiny/handler-aws";
|
|
9
|
+
import type zod from "zod";
|
|
10
|
+
export * from "./handler/types";
|
|
11
|
+
export * from "./response/abstractions";
|
|
12
|
+
export * from "./runner/abstractions";
|
|
13
|
+
export type ITaskDataInput = GenericRecord;
|
|
14
|
+
export declare enum TaskLogItemType {
|
|
15
|
+
INFO = "info",
|
|
16
|
+
ERROR = "error"
|
|
17
|
+
}
|
|
18
|
+
export interface ITaskLogItemData {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
export interface ITaskLogItemBase {
|
|
22
|
+
message: string;
|
|
23
|
+
createdOn: string;
|
|
24
|
+
type: TaskLogItemType;
|
|
25
|
+
data?: ITaskLogItemData;
|
|
26
|
+
}
|
|
27
|
+
export interface ITaskLogItemInfo extends ITaskLogItemBase {
|
|
28
|
+
type: TaskLogItemType.INFO;
|
|
29
|
+
}
|
|
30
|
+
export interface ITaskLogItemError extends ITaskLogItemBase {
|
|
31
|
+
type: TaskLogItemType.ERROR;
|
|
32
|
+
error?: IResponseError;
|
|
33
|
+
}
|
|
34
|
+
export type ITaskLogItem = ITaskLogItemInfo | ITaskLogItemError;
|
|
35
|
+
export interface ITaskLog {
|
|
36
|
+
/**
|
|
37
|
+
* ID without the revision number (for example: #0001).
|
|
38
|
+
*/
|
|
39
|
+
id: string;
|
|
40
|
+
createdOn: string;
|
|
41
|
+
createdBy: ITaskIdentity;
|
|
42
|
+
executionName: string;
|
|
43
|
+
task: string;
|
|
44
|
+
iteration: number;
|
|
45
|
+
items: ITaskLogItem[];
|
|
46
|
+
}
|
|
47
|
+
export declare enum TaskDataStatus {
|
|
48
|
+
PENDING = "pending",
|
|
49
|
+
RUNNING = "running",
|
|
50
|
+
FAILED = "failed",
|
|
51
|
+
SUCCESS = "success",
|
|
52
|
+
ABORTED = "aborted"
|
|
53
|
+
}
|
|
54
|
+
export interface ITaskIdentity {
|
|
55
|
+
id: string;
|
|
56
|
+
displayName: string | null;
|
|
57
|
+
type: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ITask<T = GenericRecord, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
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> {
|
|
81
|
+
items: ITask<T, O>[];
|
|
82
|
+
meta: CmsEntryMeta;
|
|
83
|
+
}
|
|
84
|
+
export interface IListTaskLogsResponse {
|
|
85
|
+
items: ITaskLog[];
|
|
86
|
+
meta: CmsEntryMeta;
|
|
87
|
+
}
|
|
88
|
+
export type ICreateTaskResponse<T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITask<T, O>;
|
|
89
|
+
export type IUpdateTaskResponse<T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITask<T, O>;
|
|
90
|
+
export type IDeleteTaskResponse = boolean;
|
|
91
|
+
export interface IListTaskParamsWhere extends CmsEntryListWhere {
|
|
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[];
|
|
104
|
+
}
|
|
105
|
+
export interface IListTaskParams extends Omit<CmsEntryListParams, "fields" | "search"> {
|
|
106
|
+
where?: IListTaskParamsWhere;
|
|
107
|
+
}
|
|
108
|
+
export interface IListTaskLogParamsWhere extends CmsEntryListWhere {
|
|
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;
|
|
118
|
+
}
|
|
119
|
+
export interface IListTaskLogParams extends Omit<CmsEntryListParams, "fields" | "search"> {
|
|
120
|
+
where?: IListTaskLogParamsWhere;
|
|
121
|
+
}
|
|
122
|
+
export interface ITaskCreateData<T = ITaskDataInput> {
|
|
123
|
+
definitionId: string;
|
|
124
|
+
name: string;
|
|
125
|
+
input: T;
|
|
126
|
+
parentId?: string;
|
|
127
|
+
}
|
|
128
|
+
export interface ITaskUpdateData<I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
129
|
+
name?: string;
|
|
130
|
+
input?: I;
|
|
131
|
+
output?: O;
|
|
132
|
+
taskStatus?: TaskDataStatus;
|
|
133
|
+
executionName?: string;
|
|
134
|
+
startedOn?: string;
|
|
135
|
+
finishedOn?: string;
|
|
136
|
+
eventResponse?: GenericRecord;
|
|
137
|
+
iterations?: number;
|
|
138
|
+
}
|
|
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
|
+
export interface ITaskLogCreateInput {
|
|
161
|
+
executionName: string;
|
|
162
|
+
iteration: number;
|
|
163
|
+
}
|
|
164
|
+
export interface ITaskLogUpdateInput {
|
|
165
|
+
items?: ITaskLogItem[];
|
|
166
|
+
}
|
|
167
|
+
export interface ITasksContextCrudObject {
|
|
168
|
+
/**
|
|
169
|
+
* Models
|
|
170
|
+
*/
|
|
171
|
+
getTaskModel(): Promise<CmsModel>;
|
|
172
|
+
getLogModel(): Promise<CmsModel>;
|
|
173
|
+
/**
|
|
174
|
+
* Tasks
|
|
175
|
+
*/
|
|
176
|
+
getTask<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(id: string): Promise<IGetTaskResponse<T, O> | null>;
|
|
177
|
+
listTasks<T = any, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(params?: IListTaskParams): Promise<IListTasksResponse<T, O>>;
|
|
178
|
+
createTask<T = any>(task: ITaskCreateData<T>): Promise<ICreateTaskResponse<T>>;
|
|
179
|
+
updateTask<T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(id: string, data: Partial<ITaskUpdateData<T, O>>): Promise<IUpdateTaskResponse<T, O>>;
|
|
180
|
+
deleteTask(id: string): Promise<IDeleteTaskResponse>;
|
|
181
|
+
/**
|
|
182
|
+
* Logs
|
|
183
|
+
*/
|
|
184
|
+
createLog(task: Pick<ITask, "id">, data: ITaskLogCreateInput): Promise<ITaskLog>;
|
|
185
|
+
updateLog(id: string, data: ITaskLogUpdateInput): Promise<ITaskLog>;
|
|
186
|
+
deleteLog(id: string): Promise<boolean>;
|
|
187
|
+
getLog(id: string): Promise<ITaskLog | null>;
|
|
188
|
+
getLatestLog(taskId: string): Promise<ITaskLog>;
|
|
189
|
+
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
|
+
}
|
|
200
|
+
export interface ITasksContextDefinitionObject {
|
|
201
|
+
getDefinition: <C extends Context = Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(id: string) => ITaskDefinition<C, I, O> | null;
|
|
202
|
+
listDefinitions: () => ITaskDefinition[];
|
|
203
|
+
}
|
|
204
|
+
export interface ITaskTriggerParams<I = ITaskDataInput> {
|
|
205
|
+
parent?: Pick<ITask, "id">;
|
|
206
|
+
definition: string;
|
|
207
|
+
name?: string;
|
|
208
|
+
input?: I;
|
|
209
|
+
delay?: number;
|
|
210
|
+
}
|
|
211
|
+
export interface ITaskAbortParams {
|
|
212
|
+
id: string;
|
|
213
|
+
message?: string;
|
|
214
|
+
}
|
|
215
|
+
export interface ITasksContextServiceObject {
|
|
216
|
+
trigger: <T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(params: ITaskTriggerParams<T>) => Promise<ITask<T, O>>;
|
|
217
|
+
abort: <T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(params: ITaskAbortParams) => Promise<ITask<T, O>>;
|
|
218
|
+
fetchServiceInfo: (input: ITask<any, any> | string) => Promise<IStepFunctionServiceFetchResult | null>;
|
|
219
|
+
}
|
|
220
|
+
export interface ITasksContextObject extends ITasksContextCrudObject, ITasksContextDefinitionObject, ITasksContextServiceObject {
|
|
221
|
+
}
|
|
222
|
+
export interface Context extends BaseContext {
|
|
223
|
+
tasks: ITasksContextObject;
|
|
224
|
+
}
|
|
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
|
+
export interface TaskPermission extends SecurityPermission {
|
|
338
|
+
name: "task";
|
|
339
|
+
rwd?: string;
|
|
340
|
+
}
|
package/types.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
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) {
|
|
49
|
+
TaskLogItemType["INFO"] = "info";
|
|
50
|
+
TaskLogItemType["ERROR"] = "error";
|
|
51
|
+
return TaskLogItemType;
|
|
52
|
+
}({});
|
|
53
|
+
let TaskDataStatus = exports.TaskDataStatus = /*#__PURE__*/function (TaskDataStatus) {
|
|
54
|
+
TaskDataStatus["PENDING"] = "pending";
|
|
55
|
+
TaskDataStatus["RUNNING"] = "running";
|
|
56
|
+
TaskDataStatus["FAILED"] = "failed";
|
|
57
|
+
TaskDataStatus["SUCCESS"] = "success";
|
|
58
|
+
TaskDataStatus["ABORTED"] = "aborted";
|
|
59
|
+
return TaskDataStatus;
|
|
60
|
+
}({});
|
|
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
|
+
|
|
69
|
+
//# sourceMappingURL=types.js.map
|
package/types.js.map
ADDED
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* We need to use the object-merge-advanced library to merge array items properly.
|
|
10
|
+
* With plain assign or lodash merge, we will lose array items from the source object.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const mergeOptions = {
|
|
14
|
+
hardArrayConcat: true
|
|
15
|
+
};
|
|
16
|
+
class ObjectUpdater {
|
|
17
|
+
data = {};
|
|
18
|
+
merge(target, clear = true) {
|
|
19
|
+
const item = (0, _objectMergeAdvanced.mergeAdvanced)(target, this.data, mergeOptions);
|
|
20
|
+
if (!clear) {
|
|
21
|
+
return item;
|
|
22
|
+
}
|
|
23
|
+
this.clear();
|
|
24
|
+
return item;
|
|
25
|
+
}
|
|
26
|
+
fetch(clear = true) {
|
|
27
|
+
const values = structuredClone(this.data);
|
|
28
|
+
if (!clear) {
|
|
29
|
+
return values;
|
|
30
|
+
}
|
|
31
|
+
this.clear();
|
|
32
|
+
return values;
|
|
33
|
+
}
|
|
34
|
+
update(input) {
|
|
35
|
+
this.data = (0, _objectMergeAdvanced.mergeAdvanced)(this.data, input, mergeOptions);
|
|
36
|
+
}
|
|
37
|
+
isDirty() {
|
|
38
|
+
return Object.keys(this.data).length > 0;
|
|
39
|
+
}
|
|
40
|
+
clear() {
|
|
41
|
+
this.data = {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ObjectUpdater = ObjectUpdater;
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=ObjectUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_objectMergeAdvanced","require","mergeOptions","hardArrayConcat","ObjectUpdater","data","merge","target","clear","item","mergeAdvanced","fetch","values","structuredClone","update","input","isDirty","Object","keys","length","exports"],"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":";;;;;;AAKA,IAAAA,oBAAA,GAAAC,OAAA;AALA;AACA;AACA;AACA;;AAIA,MAAMC,YAAsC,GAAG;EAC3CC,eAAe,EAAE;AACrB,CAAC;AAEM,MAAMC,aAAa,CAAI;EAClBC,IAAI,GAAe,CAAC,CAAC;EAEtBC,KAAKA,CAACC,MAAS,EAAEC,KAAK,GAAG,IAAI,EAAK;IACrC,MAAMC,IAAI,GAAG,IAAAC,kCAAa,EAACH,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;EAEOE,KAAKA,CAACH,KAAK,GAAG,IAAI,EAAc;IACnC,MAAMI,MAAM,GAAGC,eAAe,CAAC,IAAI,CAACR,IAAI,CAAC;IACzC,IAAI,CAACG,KAAK,EAAE;MACR,OAAOI,MAAM;IACjB;IACA,IAAI,CAACJ,KAAK,CAAC,CAAC;IACZ,OAAOI,MAAM;EACjB;EACOE,MAAMA,CAACC,KAAiB,EAAE;IAC7B,IAAI,CAACV,IAAI,GAAG,IAAAK,kCAAa,EAAC,IAAI,CAACL,IAAI,EAAEU,KAAK,EAAEb,YAAY,CAAC;EAC7D;EAEOc,OAAOA,CAAA,EAAY;IACtB,OAAOC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACb,IAAI,CAAC,CAACc,MAAM,GAAG,CAAC;EAC5C;EAEQX,KAAKA,CAAA,EAAG;IACZ,IAAI,CAACH,IAAI,GAAG,CAAC,CAAC;EAClB;AACJ;AAACe,OAAA,CAAAhB,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
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);
|
|
10
|
+
delete value.stack;
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
13
|
+
exports.getErrorProperties = getErrorProperties;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=getErrorProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_getObjectProperties","require","getErrorProperties","error","value","getObjectProperties","stack","exports"],"sources":["getErrorProperties.ts"],"sourcesContent":["import type { IResponseError } from \"~/response/abstractions\";\nimport { getObjectProperties } from \"~/utils/getObjectProperties\";\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,IAAAA,oBAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAIC,KAA6B,IAAqB;EACjF,MAAMC,KAAK,GAAG,IAAAC,wCAAmB,EAAiBF,KAAK,CAAC;EAExD,OAAOC,KAAK,CAACE,KAAK;EAElB,OAAOF,KAAK;AAChB,CAAC;AAACG,OAAA,CAAAL,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getObjectProperties = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Unfortunately we need some casting as we do not know which properties are available on the object.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const getObjectProperties = input => {
|
|
12
|
+
if (!input || typeof input !== "object") {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
return Object.getOwnPropertyNames(input).reduce((acc, key) => {
|
|
16
|
+
if (key === "stack") {
|
|
17
|
+
return acc;
|
|
18
|
+
}
|
|
19
|
+
acc[key] = input[key];
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
};
|
|
23
|
+
exports.getObjectProperties = getObjectProperties;
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=getObjectProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getObjectProperties","input","Object","getOwnPropertyNames","reduce","acc","key","exports"],"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;;AAKO,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;AAACE,OAAA,CAAAP,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/utils/index.d.ts
ADDED
package/utils/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
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
|
+
});
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_getErrorProperties","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_getObjectProperties","_ObjectUpdater"],"sources":["index.ts"],"sourcesContent":["export * from \"./getErrorProperties\";\nexport * from \"./getObjectProperties\";\nexport * from \"./ObjectUpdater\";\n"],"mappings":";;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,mBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,mBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,mBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,oBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,oBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,oBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,oBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,cAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,cAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,cAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,cAAA,CAAAN,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|