@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.
Files changed (316) hide show
  1. package/README.md +10 -9
  2. package/context.js +50 -21
  3. package/context.js.map +1 -1
  4. package/crud/TaskLogPrivateModel.d.ts +9 -0
  5. package/crud/TaskLogPrivateModel.js +34 -0
  6. package/crud/TaskLogPrivateModel.js.map +1 -0
  7. package/crud/TaskPrivateModel.d.ts +9 -0
  8. package/crud/TaskPrivateModel.js +46 -0
  9. package/crud/TaskPrivateModel.js.map +1 -0
  10. package/crud/cleanupTaskSubtree.d.ts +8 -0
  11. package/crud/cleanupTaskSubtree.js +76 -0
  12. package/crud/cleanupTaskSubtree.js.map +1 -0
  13. package/crud/crud.tasks.d.ts +1 -1
  14. package/crud/crud.tasks.js +213 -105
  15. package/crud/crud.tasks.js.map +1 -1
  16. package/crud/definition.tasks.d.ts +1 -1
  17. package/crud/definition.tasks.js +9 -18
  18. package/crud/definition.tasks.js.map +1 -1
  19. package/crud/service.tasks.d.ts +1 -1
  20. package/crud/service.tasks.js +31 -36
  21. package/crud/service.tasks.js.map +1 -1
  22. package/decorators/RunnableTaskDecorator.d.ts +32 -0
  23. package/decorators/RunnableTaskDecorator.js +85 -0
  24. package/decorators/RunnableTaskDecorator.js.map +1 -0
  25. package/decorators/SelfCleaningTaskDecorator.d.ts +30 -0
  26. package/decorators/SelfCleaningTaskDecorator.js +98 -0
  27. package/decorators/SelfCleaningTaskDecorator.js.map +1 -0
  28. package/domain/errors.d.ts +29 -0
  29. package/domain/errors.js +47 -0
  30. package/domain/errors.js.map +1 -0
  31. package/events/TaskAfterCreateEvent.d.ts +6 -0
  32. package/events/TaskAfterCreateEvent.js +10 -0
  33. package/events/TaskAfterCreateEvent.js.map +1 -0
  34. package/events/TaskAfterDeleteEvent.d.ts +6 -0
  35. package/events/TaskAfterDeleteEvent.js +10 -0
  36. package/events/TaskAfterDeleteEvent.js.map +1 -0
  37. package/events/TaskAfterUpdateEvent.d.ts +6 -0
  38. package/events/TaskAfterUpdateEvent.js +10 -0
  39. package/events/TaskAfterUpdateEvent.js.map +1 -0
  40. package/events/TaskBeforeCreateEvent.d.ts +6 -0
  41. package/events/TaskBeforeCreateEvent.js +10 -0
  42. package/events/TaskBeforeCreateEvent.js.map +1 -0
  43. package/events/TaskBeforeDeleteEvent.d.ts +6 -0
  44. package/events/TaskBeforeDeleteEvent.js +10 -0
  45. package/events/TaskBeforeDeleteEvent.js.map +1 -0
  46. package/events/TaskBeforeUpdateEvent.d.ts +6 -0
  47. package/events/TaskBeforeUpdateEvent.js +10 -0
  48. package/events/TaskBeforeUpdateEvent.js.map +1 -0
  49. package/events/abstractions.d.ts +53 -0
  50. package/events/abstractions.js +39 -0
  51. package/events/abstractions.js.map +1 -0
  52. package/events/index.d.ts +7 -0
  53. package/events/index.js +9 -0
  54. package/events/index.js.map +1 -0
  55. package/features/AbortTask/AbortTaskUseCase.d.ts +10 -0
  56. package/features/AbortTask/AbortTaskUseCase.js +11 -0
  57. package/features/AbortTask/AbortTaskUseCase.js.map +1 -0
  58. package/features/AbortTask/abstractions.d.ts +25 -0
  59. package/features/AbortTask/abstractions.js +4 -0
  60. package/features/AbortTask/abstractions.js.map +1 -0
  61. package/features/AbortTask/feature.d.ts +5 -0
  62. package/features/AbortTask/feature.js +11 -0
  63. package/features/AbortTask/feature.js.map +1 -0
  64. package/features/AbortTask/index.d.ts +2 -0
  65. package/features/AbortTask/index.js +4 -0
  66. package/features/AbortTask/index.js.map +1 -0
  67. package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.d.ts +7 -0
  68. package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js +10 -0
  69. package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js.map +1 -0
  70. package/features/CleanupTaskSubtree/abstractions.d.ts +7 -0
  71. package/features/CleanupTaskSubtree/abstractions.js +4 -0
  72. package/features/CleanupTaskSubtree/abstractions.js.map +1 -0
  73. package/features/CleanupTaskSubtree/index.d.ts +2 -0
  74. package/features/CleanupTaskSubtree/index.js +4 -0
  75. package/features/CleanupTaskSubtree/index.js.map +1 -0
  76. package/features/GetTask/GetTaskUseCase.d.ts +9 -0
  77. package/features/GetTask/GetTaskUseCase.js +10 -0
  78. package/features/GetTask/GetTaskUseCase.js.map +1 -0
  79. package/features/GetTask/abstractions.d.ts +10 -0
  80. package/features/GetTask/abstractions.js +4 -0
  81. package/features/GetTask/abstractions.js.map +1 -0
  82. package/features/GetTask/feature.d.ts +5 -0
  83. package/features/GetTask/feature.js +11 -0
  84. package/features/GetTask/feature.js.map +1 -0
  85. package/features/GetTask/index.d.ts +2 -0
  86. package/features/GetTask/index.js +4 -0
  87. package/features/GetTask/index.js.map +1 -0
  88. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.d.ts +12 -0
  89. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +25 -0
  90. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js.map +1 -0
  91. package/features/GetTaskDefinition/abstractions.d.ts +17 -0
  92. package/features/GetTaskDefinition/abstractions.js +4 -0
  93. package/features/GetTaskDefinition/abstractions.js.map +1 -0
  94. package/features/GetTaskDefinition/feature.d.ts +4 -0
  95. package/features/GetTaskDefinition/feature.js +10 -0
  96. package/features/GetTaskDefinition/feature.js.map +1 -0
  97. package/features/GetTaskDefinition/index.d.ts +2 -0
  98. package/features/GetTaskDefinition/index.js +4 -0
  99. package/features/GetTaskDefinition/index.js.map +1 -0
  100. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.d.ts +11 -0
  101. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js +18 -0
  102. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js.map +1 -0
  103. package/features/ListTaskDefinitions/abstractions.d.ts +9 -0
  104. package/features/ListTaskDefinitions/abstractions.js +4 -0
  105. package/features/ListTaskDefinitions/abstractions.js.map +1 -0
  106. package/features/ListTaskDefinitions/feature.d.ts +4 -0
  107. package/features/ListTaskDefinitions/feature.js +10 -0
  108. package/features/ListTaskDefinitions/feature.js.map +1 -0
  109. package/features/ListTaskDefinitions/index.d.ts +2 -0
  110. package/features/ListTaskDefinitions/index.js +4 -0
  111. package/features/ListTaskDefinitions/index.js.map +1 -0
  112. package/features/ListTasks/ListTasksUseCase.d.ts +9 -0
  113. package/features/ListTasks/ListTasksUseCase.js +10 -0
  114. package/features/ListTasks/ListTasksUseCase.js.map +1 -0
  115. package/features/ListTasks/abstractions.d.ts +13 -0
  116. package/features/ListTasks/abstractions.js +4 -0
  117. package/features/ListTasks/abstractions.js.map +1 -0
  118. package/features/ListTasks/feature.d.ts +5 -0
  119. package/features/ListTasks/feature.js +11 -0
  120. package/features/ListTasks/feature.js.map +1 -0
  121. package/features/ListTasks/index.d.ts +2 -0
  122. package/features/ListTasks/index.js +4 -0
  123. package/features/ListTasks/index.js.map +1 -0
  124. package/features/TaskController/TaskController.d.ts +49 -0
  125. package/features/TaskController/TaskController.js +71 -0
  126. package/features/TaskController/TaskController.js.map +1 -0
  127. package/features/TaskController/augmentation.d.ts +60 -0
  128. package/features/TaskController/augmentation.js +3 -0
  129. package/features/TaskController/augmentation.js.map +1 -0
  130. package/features/TaskController/index.d.ts +2 -0
  131. package/features/TaskController/index.js +7 -0
  132. package/features/TaskController/index.js.map +1 -0
  133. package/features/TaskExecutionContext/TaskExecutionContext.d.ts +24 -0
  134. package/features/TaskExecutionContext/TaskExecutionContext.js +50 -0
  135. package/features/TaskExecutionContext/TaskExecutionContext.js.map +1 -0
  136. package/features/TaskExecutionContext/abstractions.d.ts +26 -0
  137. package/features/TaskExecutionContext/abstractions.js +13 -0
  138. package/features/TaskExecutionContext/abstractions.js.map +1 -0
  139. package/features/TaskExecutionContext/feature.d.ts +4 -0
  140. package/features/TaskExecutionContext/feature.js +10 -0
  141. package/features/TaskExecutionContext/feature.js.map +1 -0
  142. package/features/TaskExecutionContext/index.d.ts +1 -0
  143. package/features/TaskExecutionContext/index.js +3 -0
  144. package/features/TaskExecutionContext/index.js.map +1 -0
  145. package/features/TriggerTask/TriggerTaskUseCase.d.ts +10 -0
  146. package/features/TriggerTask/TriggerTaskUseCase.js +11 -0
  147. package/features/TriggerTask/TriggerTaskUseCase.js.map +1 -0
  148. package/features/TriggerTask/abstractions.d.ts +28 -0
  149. package/features/TriggerTask/abstractions.js +4 -0
  150. package/features/TriggerTask/abstractions.js.map +1 -0
  151. package/features/TriggerTask/feature.d.ts +5 -0
  152. package/features/TriggerTask/feature.js +11 -0
  153. package/features/TriggerTask/feature.js.map +1 -0
  154. package/features/TriggerTask/index.d.ts +2 -0
  155. package/features/TriggerTask/index.js +4 -0
  156. package/features/TriggerTask/index.js.map +1 -0
  157. package/global.d.ts +1 -0
  158. package/global.js +3 -0
  159. package/global.js.map +1 -0
  160. package/graphql/checkPermissions.d.ts +1 -1
  161. package/graphql/checkPermissions.js +3 -9
  162. package/graphql/checkPermissions.js.map +1 -1
  163. package/graphql/index.d.ts +1 -1
  164. package/graphql/index.js +67 -83
  165. package/graphql/index.js.map +1 -1
  166. package/graphql/utils.d.ts +3 -3
  167. package/graphql/utils.js +8 -17
  168. package/graphql/utils.js.map +1 -1
  169. package/handler/index.d.ts +2 -2
  170. package/handler/index.js +33 -40
  171. package/handler/index.js.map +1 -1
  172. package/handler/register.js +5 -7
  173. package/handler/register.js.map +1 -1
  174. package/handler/types.d.ts +1 -3
  175. package/handler/types.js +1 -5
  176. package/handler/types.js.map +1 -1
  177. package/index.d.ts +5 -6
  178. package/index.js +5 -60
  179. package/index.js.map +1 -1
  180. package/package.json +27 -28
  181. package/plugins/TaskServicePlugin.d.ts +1 -2
  182. package/plugins/TaskServicePlugin.js +2 -9
  183. package/plugins/TaskServicePlugin.js.map +1 -1
  184. package/plugins/index.d.ts +1 -1
  185. package/plugins/index.js +1 -16
  186. package/plugins/index.js.map +1 -1
  187. package/response/DatabaseResponse.d.ts +3 -3
  188. package/response/DatabaseResponse.js +14 -20
  189. package/response/DatabaseResponse.js.map +1 -1
  190. package/response/Response.d.ts +4 -3
  191. package/response/Response.js +20 -31
  192. package/response/Response.js.map +1 -1
  193. package/response/ResponseAbortedResult.d.ts +3 -4
  194. package/response/ResponseAbortedResult.js +3 -11
  195. package/response/ResponseAbortedResult.js.map +1 -1
  196. package/response/ResponseContinueResult.d.ts +4 -5
  197. package/response/ResponseContinueResult.js +3 -11
  198. package/response/ResponseContinueResult.js.map +1 -1
  199. package/response/ResponseDoneResult.d.ts +4 -6
  200. package/response/ResponseDoneResult.js +3 -11
  201. package/response/ResponseDoneResult.js.map +1 -1
  202. package/response/ResponseErrorResult.d.ts +3 -4
  203. package/response/ResponseErrorResult.js +3 -11
  204. package/response/ResponseErrorResult.js.map +1 -1
  205. package/response/TaskResponse.d.ts +7 -6
  206. package/response/TaskResponse.js +5 -12
  207. package/response/TaskResponse.js.map +1 -1
  208. package/response/abstractions/Response.d.ts +7 -7
  209. package/response/abstractions/Response.js +1 -5
  210. package/response/abstractions/Response.js.map +1 -1
  211. package/response/abstractions/ResponseAbortedResult.d.ts +3 -3
  212. package/response/abstractions/ResponseAbortedResult.js +1 -5
  213. package/response/abstractions/ResponseAbortedResult.js.map +1 -1
  214. package/response/abstractions/ResponseBaseResult.d.ts +2 -3
  215. package/response/abstractions/ResponseBaseResult.js +1 -5
  216. package/response/abstractions/ResponseBaseResult.js.map +1 -1
  217. package/response/abstractions/ResponseContinueResult.d.ts +4 -4
  218. package/response/abstractions/ResponseContinueResult.js +1 -5
  219. package/response/abstractions/ResponseContinueResult.js.map +1 -1
  220. package/response/abstractions/ResponseDoneResult.d.ts +5 -6
  221. package/response/abstractions/ResponseDoneResult.js +1 -5
  222. package/response/abstractions/ResponseDoneResult.js.map +1 -1
  223. package/response/abstractions/ResponseErrorResult.d.ts +4 -5
  224. package/response/abstractions/ResponseErrorResult.js +1 -5
  225. package/response/abstractions/ResponseErrorResult.js.map +1 -1
  226. package/response/abstractions/TaskResponse.d.ts +8 -30
  227. package/response/abstractions/TaskResponse.js +1 -5
  228. package/response/abstractions/TaskResponse.js.map +1 -1
  229. package/response/abstractions/index.d.ts +7 -7
  230. package/response/abstractions/index.js +7 -82
  231. package/response/abstractions/index.js.map +1 -1
  232. package/response/index.d.ts +7 -7
  233. package/response/index.js +7 -82
  234. package/response/index.js.map +1 -1
  235. package/runner/TaskControl.d.ts +4 -4
  236. package/runner/TaskControl.js +61 -39
  237. package/runner/TaskControl.js.map +1 -1
  238. package/runner/TaskEventValidation.d.ts +2 -2
  239. package/runner/TaskEventValidation.js +11 -20
  240. package/runner/TaskEventValidation.js.map +1 -1
  241. package/runner/TaskManager.d.ts +7 -10
  242. package/runner/TaskManager.js +19 -39
  243. package/runner/TaskManager.js.map +1 -1
  244. package/runner/TaskManagerStore.d.ts +7 -7
  245. package/runner/TaskManagerStore.js +16 -25
  246. package/runner/TaskManagerStore.js.map +1 -1
  247. package/runner/TaskRunner.d.ts +5 -6
  248. package/runner/TaskRunner.js +9 -31
  249. package/runner/TaskRunner.js.map +1 -1
  250. package/runner/abstractions/TaskControl.d.ts +4 -4
  251. package/runner/abstractions/TaskControl.js +1 -5
  252. package/runner/abstractions/TaskControl.js.map +1 -1
  253. package/runner/abstractions/TaskEventValidation.d.ts +1 -1
  254. package/runner/abstractions/TaskEventValidation.js +1 -5
  255. package/runner/abstractions/TaskEventValidation.js.map +1 -1
  256. package/runner/abstractions/TaskManager.d.ts +4 -4
  257. package/runner/abstractions/TaskManager.js +1 -5
  258. package/runner/abstractions/TaskManager.js.map +1 -1
  259. package/runner/abstractions/TaskManagerStore.d.ts +11 -11
  260. package/runner/abstractions/TaskManagerStore.js +1 -5
  261. package/runner/abstractions/TaskManagerStore.js.map +1 -1
  262. package/runner/abstractions/TaskRunner.d.ts +3 -3
  263. package/runner/abstractions/TaskRunner.js +1 -5
  264. package/runner/abstractions/TaskRunner.js.map +1 -1
  265. package/runner/abstractions/index.d.ts +5 -5
  266. package/runner/abstractions/index.js +5 -60
  267. package/runner/abstractions/index.js.map +1 -1
  268. package/runner/index.d.ts +1 -1
  269. package/runner/index.js +1 -16
  270. package/runner/index.js.map +1 -1
  271. package/service/EventBridgeEventTransportPlugin.d.ts +4 -5
  272. package/service/EventBridgeEventTransportPlugin.js +8 -17
  273. package/service/EventBridgeEventTransportPlugin.js.map +1 -1
  274. package/service/StepFunctionServicePlugin.d.ts +4 -5
  275. package/service/StepFunctionServicePlugin.js +11 -21
  276. package/service/StepFunctionServicePlugin.js.map +1 -1
  277. package/service/createService.d.ts +2 -2
  278. package/service/createService.js +7 -18
  279. package/service/createService.js.map +1 -1
  280. package/service/index.d.ts +3 -3
  281. package/service/index.js +6 -27
  282. package/service/index.js.map +1 -1
  283. package/tasks/testingRunTask.d.ts +10 -1
  284. package/tasks/testingRunTask.js +13 -18
  285. package/tasks/testingRunTask.js.map +1 -1
  286. package/types.d.ts +41 -214
  287. package/types.js +7 -56
  288. package/types.js.map +1 -1
  289. package/utils/ObjectUpdater.js +4 -11
  290. package/utils/ObjectUpdater.js.map +1 -1
  291. package/utils/getErrorProperties.d.ts +1 -1
  292. package/utils/getErrorProperties.js +3 -10
  293. package/utils/getErrorProperties.js.map +1 -1
  294. package/utils/getObjectProperties.js +1 -8
  295. package/utils/getObjectProperties.js.map +1 -1
  296. package/utils/index.d.ts +3 -3
  297. package/utils/index.js +3 -38
  298. package/utils/index.js.map +1 -1
  299. package/utils/normalizeSelfCleanup.d.ts +2 -0
  300. package/utils/normalizeSelfCleanup.js +15 -0
  301. package/utils/normalizeSelfCleanup.js.map +1 -0
  302. package/crud/model.d.ts +0 -5
  303. package/crud/model.js +0 -216
  304. package/crud/model.js.map +0 -1
  305. package/crud/where.d.ts +0 -1
  306. package/crud/where.js +0 -33
  307. package/crud/where.js.map +0 -1
  308. package/task/index.d.ts +0 -2
  309. package/task/index.js +0 -29
  310. package/task/index.js.map +0 -1
  311. package/task/input.d.ts +0 -15
  312. package/task/input.js +0 -21
  313. package/task/input.js.map +0 -1
  314. package/task/plugin.d.ts +0 -36
  315. package/task/plugin.js +0 -106
  316. package/task/plugin.js.map +0 -1
package/types.d.ts CHANGED
@@ -1,15 +1,16 @@
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";
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 | null;
57
+ displayName: string;
57
58
  type: string;
58
59
  }
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> {
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 = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITask<T, O>;
89
- export type IUpdateTaskResponse<T = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITask<T, O>;
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 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[];
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 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;
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 = ITaskDataInput> {
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 = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
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 = 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>>;
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: <C extends Context = Context, I = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(id: string) => ITaskDefinition<C, I, O> | null;
202
- listDefinitions: () => ITaskDefinition[];
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 = 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>;
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
- "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) {
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 = exports.TaskDataStatus = /*#__PURE__*/function (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":[]}
@@ -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 = (0, _objectMergeAdvanced.mergeAdvanced)(target, this.data, mergeOptions);
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 = (0, _objectMergeAdvanced.mergeAdvanced)(this.data, input, mergeOptions);
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":["_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":[]}
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
- "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);
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":["_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":[]}
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","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":[]}
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
- "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
- });
1
+ export * from "./getErrorProperties.js";
2
+ export * from "./getObjectProperties.js";
3
+ export * from "./ObjectUpdater.js";
39
4
 
40
5
  //# sourceMappingURL=index.js.map