@webiny/tasks 6.0.0-beta.0 → 6.0.0-rc.1

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 (310) hide show
  1. package/README.md +10 -9
  2. package/context.d.ts +2 -3
  3. package/context.js +44 -30
  4. package/context.js.map +1 -1
  5. package/crud/TaskLogPrivateModel.d.ts +9 -0
  6. package/crud/TaskLogPrivateModel.js +34 -0
  7. package/crud/TaskLogPrivateModel.js.map +1 -0
  8. package/crud/TaskPrivateModel.d.ts +9 -0
  9. package/crud/TaskPrivateModel.js +46 -0
  10. package/crud/TaskPrivateModel.js.map +1 -0
  11. package/crud/crud.tasks.d.ts +1 -1
  12. package/crud/crud.tasks.js +238 -94
  13. package/crud/crud.tasks.js.map +1 -1
  14. package/crud/definition.tasks.d.ts +1 -1
  15. package/crud/definition.tasks.js +9 -18
  16. package/crud/definition.tasks.js.map +1 -1
  17. package/crud/service.tasks.d.ts +2 -0
  18. package/crud/{trigger.tasks.js → service.tasks.js} +59 -42
  19. package/crud/service.tasks.js.map +1 -0
  20. package/decorators/RunnableTaskDecorator.d.ts +31 -0
  21. package/decorators/RunnableTaskDecorator.js +82 -0
  22. package/decorators/RunnableTaskDecorator.js.map +1 -0
  23. package/domain/errors.d.ts +29 -0
  24. package/domain/errors.js +47 -0
  25. package/domain/errors.js.map +1 -0
  26. package/events/TaskAfterCreateEvent.d.ts +6 -0
  27. package/events/TaskAfterCreateEvent.js +10 -0
  28. package/events/TaskAfterCreateEvent.js.map +1 -0
  29. package/events/TaskAfterDeleteEvent.d.ts +6 -0
  30. package/events/TaskAfterDeleteEvent.js +10 -0
  31. package/events/TaskAfterDeleteEvent.js.map +1 -0
  32. package/events/TaskAfterUpdateEvent.d.ts +6 -0
  33. package/events/TaskAfterUpdateEvent.js +10 -0
  34. package/events/TaskAfterUpdateEvent.js.map +1 -0
  35. package/events/TaskBeforeCreateEvent.d.ts +6 -0
  36. package/events/TaskBeforeCreateEvent.js +10 -0
  37. package/events/TaskBeforeCreateEvent.js.map +1 -0
  38. package/events/TaskBeforeDeleteEvent.d.ts +6 -0
  39. package/events/TaskBeforeDeleteEvent.js +10 -0
  40. package/events/TaskBeforeDeleteEvent.js.map +1 -0
  41. package/events/TaskBeforeUpdateEvent.d.ts +6 -0
  42. package/events/TaskBeforeUpdateEvent.js +10 -0
  43. package/events/TaskBeforeUpdateEvent.js.map +1 -0
  44. package/events/abstractions.d.ts +53 -0
  45. package/events/abstractions.js +39 -0
  46. package/events/abstractions.js.map +1 -0
  47. package/events/index.d.ts +7 -0
  48. package/events/index.js +9 -0
  49. package/events/index.js.map +1 -0
  50. package/features/AbortTask/AbortTaskUseCase.d.ts +10 -0
  51. package/features/AbortTask/AbortTaskUseCase.js +11 -0
  52. package/features/AbortTask/AbortTaskUseCase.js.map +1 -0
  53. package/features/AbortTask/abstractions.d.ts +25 -0
  54. package/features/AbortTask/abstractions.js +4 -0
  55. package/features/AbortTask/abstractions.js.map +1 -0
  56. package/features/AbortTask/feature.d.ts +2 -0
  57. package/features/AbortTask/feature.js +11 -0
  58. package/features/AbortTask/feature.js.map +1 -0
  59. package/features/AbortTask/index.d.ts +2 -0
  60. package/features/AbortTask/index.js +4 -0
  61. package/features/AbortTask/index.js.map +1 -0
  62. package/features/GetTask/GetTaskUseCase.d.ts +9 -0
  63. package/features/GetTask/GetTaskUseCase.js +10 -0
  64. package/features/GetTask/GetTaskUseCase.js.map +1 -0
  65. package/features/GetTask/abstractions.d.ts +10 -0
  66. package/features/GetTask/abstractions.js +4 -0
  67. package/features/GetTask/abstractions.js.map +1 -0
  68. package/features/GetTask/feature.d.ts +2 -0
  69. package/features/GetTask/feature.js +11 -0
  70. package/features/GetTask/feature.js.map +1 -0
  71. package/features/GetTask/index.d.ts +2 -0
  72. package/features/GetTask/index.js +4 -0
  73. package/features/GetTask/index.js.map +1 -0
  74. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.d.ts +12 -0
  75. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +25 -0
  76. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js.map +1 -0
  77. package/features/GetTaskDefinition/abstractions.d.ts +17 -0
  78. package/features/GetTaskDefinition/abstractions.js +4 -0
  79. package/features/GetTaskDefinition/abstractions.js.map +1 -0
  80. package/features/GetTaskDefinition/feature.d.ts +1 -0
  81. package/features/GetTaskDefinition/feature.js +10 -0
  82. package/features/GetTaskDefinition/feature.js.map +1 -0
  83. package/features/GetTaskDefinition/index.d.ts +2 -0
  84. package/features/GetTaskDefinition/index.js +4 -0
  85. package/features/GetTaskDefinition/index.js.map +1 -0
  86. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.d.ts +11 -0
  87. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js +18 -0
  88. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js.map +1 -0
  89. package/features/ListTaskDefinitions/abstractions.d.ts +9 -0
  90. package/features/ListTaskDefinitions/abstractions.js +4 -0
  91. package/features/ListTaskDefinitions/abstractions.js.map +1 -0
  92. package/features/ListTaskDefinitions/feature.d.ts +1 -0
  93. package/features/ListTaskDefinitions/feature.js +10 -0
  94. package/features/ListTaskDefinitions/feature.js.map +1 -0
  95. package/features/ListTaskDefinitions/index.d.ts +2 -0
  96. package/features/ListTaskDefinitions/index.js +4 -0
  97. package/features/ListTaskDefinitions/index.js.map +1 -0
  98. package/features/ListTasks/ListTasksUseCase.d.ts +9 -0
  99. package/features/ListTasks/ListTasksUseCase.js +10 -0
  100. package/features/ListTasks/ListTasksUseCase.js.map +1 -0
  101. package/features/ListTasks/abstractions.d.ts +13 -0
  102. package/features/ListTasks/abstractions.js +4 -0
  103. package/features/ListTasks/abstractions.js.map +1 -0
  104. package/features/ListTasks/feature.d.ts +2 -0
  105. package/features/ListTasks/feature.js +11 -0
  106. package/features/ListTasks/feature.js.map +1 -0
  107. package/features/ListTasks/index.d.ts +2 -0
  108. package/features/ListTasks/index.js +4 -0
  109. package/features/ListTasks/index.js.map +1 -0
  110. package/features/TaskController/TaskController.d.ts +49 -0
  111. package/features/TaskController/TaskController.js +71 -0
  112. package/features/TaskController/TaskController.js.map +1 -0
  113. package/features/TaskController/augmentation.d.ts +60 -0
  114. package/features/TaskController/augmentation.js +3 -0
  115. package/features/TaskController/augmentation.js.map +1 -0
  116. package/features/TaskController/index.d.ts +2 -0
  117. package/features/TaskController/index.js +7 -0
  118. package/features/TaskController/index.js.map +1 -0
  119. package/features/TaskExecutionContext/TaskExecutionContext.d.ts +24 -0
  120. package/features/TaskExecutionContext/TaskExecutionContext.js +50 -0
  121. package/features/TaskExecutionContext/TaskExecutionContext.js.map +1 -0
  122. package/features/TaskExecutionContext/abstractions.d.ts +26 -0
  123. package/features/TaskExecutionContext/abstractions.js +13 -0
  124. package/features/TaskExecutionContext/abstractions.js.map +1 -0
  125. package/features/TaskExecutionContext/feature.d.ts +1 -0
  126. package/features/TaskExecutionContext/feature.js +10 -0
  127. package/features/TaskExecutionContext/feature.js.map +1 -0
  128. package/features/TaskExecutionContext/index.d.ts +1 -0
  129. package/features/TaskExecutionContext/index.js +3 -0
  130. package/features/TaskExecutionContext/index.js.map +1 -0
  131. package/features/TriggerTask/TriggerTaskUseCase.d.ts +10 -0
  132. package/features/TriggerTask/TriggerTaskUseCase.js +11 -0
  133. package/features/TriggerTask/TriggerTaskUseCase.js.map +1 -0
  134. package/features/TriggerTask/abstractions.d.ts +28 -0
  135. package/features/TriggerTask/abstractions.js +4 -0
  136. package/features/TriggerTask/abstractions.js.map +1 -0
  137. package/features/TriggerTask/feature.d.ts +2 -0
  138. package/features/TriggerTask/feature.js +11 -0
  139. package/features/TriggerTask/feature.js.map +1 -0
  140. package/features/TriggerTask/index.d.ts +2 -0
  141. package/features/TriggerTask/index.js +4 -0
  142. package/features/TriggerTask/index.js.map +1 -0
  143. package/global.d.ts +1 -0
  144. package/global.js +3 -0
  145. package/global.js.map +1 -0
  146. package/graphql/checkPermissions.d.ts +1 -1
  147. package/graphql/checkPermissions.js +3 -9
  148. package/graphql/checkPermissions.js.map +1 -1
  149. package/graphql/index.d.ts +1 -1
  150. package/graphql/index.js +64 -71
  151. package/graphql/index.js.map +1 -1
  152. package/graphql/utils.d.ts +1 -1
  153. package/graphql/utils.js +8 -17
  154. package/graphql/utils.js.map +1 -1
  155. package/handler/index.d.ts +2 -5
  156. package/handler/index.js +33 -40
  157. package/handler/index.js.map +1 -1
  158. package/handler/register.js +8 -8
  159. package/handler/register.js.map +1 -1
  160. package/handler/types.d.ts +2 -2
  161. package/handler/types.js +1 -5
  162. package/handler/types.js.map +1 -1
  163. package/index.d.ts +5 -6
  164. package/index.js +5 -60
  165. package/index.js.map +1 -1
  166. package/package.json +23 -44
  167. package/plugins/TaskServicePlugin.d.ts +19 -0
  168. package/plugins/TaskServicePlugin.js +10 -0
  169. package/plugins/TaskServicePlugin.js.map +1 -0
  170. package/plugins/index.d.ts +1 -1
  171. package/plugins/index.js +1 -16
  172. package/plugins/index.js.map +1 -1
  173. package/response/DatabaseResponse.d.ts +3 -3
  174. package/response/DatabaseResponse.js +14 -20
  175. package/response/DatabaseResponse.js.map +1 -1
  176. package/response/Response.d.ts +4 -3
  177. package/response/Response.js +63 -27
  178. package/response/Response.js.map +1 -1
  179. package/response/ResponseAbortedResult.d.ts +3 -4
  180. package/response/ResponseAbortedResult.js +3 -11
  181. package/response/ResponseAbortedResult.js.map +1 -1
  182. package/response/ResponseContinueResult.d.ts +4 -4
  183. package/response/ResponseContinueResult.js +3 -11
  184. package/response/ResponseContinueResult.js.map +1 -1
  185. package/response/ResponseDoneResult.d.ts +4 -5
  186. package/response/ResponseDoneResult.js +4 -12
  187. package/response/ResponseDoneResult.js.map +1 -1
  188. package/response/ResponseErrorResult.d.ts +3 -4
  189. package/response/ResponseErrorResult.js +3 -11
  190. package/response/ResponseErrorResult.js.map +1 -1
  191. package/response/TaskResponse.d.ts +7 -6
  192. package/response/TaskResponse.js +7 -14
  193. package/response/TaskResponse.js.map +1 -1
  194. package/response/abstractions/Response.d.ts +9 -9
  195. package/response/abstractions/Response.js +1 -5
  196. package/response/abstractions/Response.js.map +1 -1
  197. package/response/abstractions/ResponseAbortedResult.d.ts +3 -3
  198. package/response/abstractions/ResponseAbortedResult.js +1 -5
  199. package/response/abstractions/ResponseAbortedResult.js.map +1 -1
  200. package/response/abstractions/ResponseBaseResult.d.ts +2 -3
  201. package/response/abstractions/ResponseBaseResult.js +1 -5
  202. package/response/abstractions/ResponseBaseResult.js.map +1 -1
  203. package/response/abstractions/ResponseContinueResult.d.ts +5 -4
  204. package/response/abstractions/ResponseContinueResult.js +1 -5
  205. package/response/abstractions/ResponseContinueResult.js.map +1 -1
  206. package/response/abstractions/ResponseDoneResult.d.ts +5 -6
  207. package/response/abstractions/ResponseDoneResult.js +1 -5
  208. package/response/abstractions/ResponseDoneResult.js.map +1 -1
  209. package/response/abstractions/ResponseErrorResult.d.ts +6 -6
  210. package/response/abstractions/ResponseErrorResult.js +1 -5
  211. package/response/abstractions/ResponseErrorResult.js.map +1 -1
  212. package/response/abstractions/TaskResponse.d.ts +9 -34
  213. package/response/abstractions/TaskResponse.js +1 -5
  214. package/response/abstractions/TaskResponse.js.map +1 -1
  215. package/response/abstractions/index.d.ts +7 -7
  216. package/response/abstractions/index.js +7 -82
  217. package/response/abstractions/index.js.map +1 -1
  218. package/response/index.d.ts +7 -7
  219. package/response/index.js +7 -82
  220. package/response/index.js.map +1 -1
  221. package/runner/TaskControl.d.ts +4 -4
  222. package/runner/TaskControl.js +98 -49
  223. package/runner/TaskControl.js.map +1 -1
  224. package/runner/TaskEventValidation.d.ts +2 -2
  225. package/runner/TaskEventValidation.js +11 -20
  226. package/runner/TaskEventValidation.js.map +1 -1
  227. package/runner/TaskManager.d.ts +7 -8
  228. package/runner/TaskManager.js +19 -38
  229. package/runner/TaskManager.js.map +1 -1
  230. package/runner/TaskManagerStore.d.ts +14 -5
  231. package/runner/TaskManagerStore.js +40 -26
  232. package/runner/TaskManagerStore.js.map +1 -1
  233. package/runner/TaskRunner.d.ts +6 -7
  234. package/runner/TaskRunner.js +9 -31
  235. package/runner/TaskRunner.js.map +1 -1
  236. package/runner/abstractions/TaskControl.d.ts +4 -4
  237. package/runner/abstractions/TaskControl.js +1 -5
  238. package/runner/abstractions/TaskControl.js.map +1 -1
  239. package/runner/abstractions/TaskEventValidation.d.ts +2 -2
  240. package/runner/abstractions/TaskEventValidation.js +1 -5
  241. package/runner/abstractions/TaskEventValidation.js.map +1 -1
  242. package/runner/abstractions/TaskManager.d.ts +4 -4
  243. package/runner/abstractions/TaskManager.js +1 -5
  244. package/runner/abstractions/TaskManager.js.map +1 -1
  245. package/runner/abstractions/TaskManagerStore.d.ts +15 -9
  246. package/runner/abstractions/TaskManagerStore.js +1 -5
  247. package/runner/abstractions/TaskManagerStore.js.map +1 -1
  248. package/runner/abstractions/TaskRunner.d.ts +9 -4
  249. package/runner/abstractions/TaskRunner.js +1 -5
  250. package/runner/abstractions/TaskRunner.js.map +1 -1
  251. package/runner/abstractions/index.d.ts +5 -5
  252. package/runner/abstractions/index.js +5 -60
  253. package/runner/abstractions/index.js.map +1 -1
  254. package/runner/index.d.ts +1 -1
  255. package/runner/index.js +1 -16
  256. package/runner/index.js.map +1 -1
  257. package/service/EventBridgeEventTransportPlugin.d.ts +16 -0
  258. package/service/EventBridgeEventTransportPlugin.js +51 -0
  259. package/service/EventBridgeEventTransportPlugin.js.map +1 -0
  260. package/service/StepFunctionServicePlugin.d.ts +25 -0
  261. package/service/StepFunctionServicePlugin.js +78 -0
  262. package/service/StepFunctionServicePlugin.js.map +1 -0
  263. package/service/createService.d.ts +6 -0
  264. package/service/createService.js +19 -0
  265. package/service/createService.js.map +1 -0
  266. package/service/index.d.ts +4 -0
  267. package/service/index.js +10 -0
  268. package/service/index.js.map +1 -0
  269. package/tasks/testingRunTask.d.ts +10 -1
  270. package/tasks/testingRunTask.js +13 -18
  271. package/tasks/testingRunTask.js.map +1 -1
  272. package/types.d.ts +47 -215
  273. package/types.js +8 -68
  274. package/types.js.map +1 -1
  275. package/utils/ObjectUpdater.js +4 -11
  276. package/utils/ObjectUpdater.js.map +1 -1
  277. package/utils/getErrorProperties.d.ts +2 -2
  278. package/utils/getErrorProperties.js +5 -10
  279. package/utils/getErrorProperties.js.map +1 -1
  280. package/utils/getObjectProperties.js +1 -8
  281. package/utils/getObjectProperties.js.map +1 -1
  282. package/utils/index.d.ts +3 -0
  283. package/utils/index.js +5 -0
  284. package/utils/index.js.map +1 -0
  285. package/crud/model.d.ts +0 -5
  286. package/crud/model.js +0 -216
  287. package/crud/model.js.map +0 -1
  288. package/crud/transport/EventBridgeEventTransportPlugin.d.ts +0 -5
  289. package/crud/transport/EventBridgeEventTransportPlugin.js +0 -58
  290. package/crud/transport/EventBridgeEventTransportPlugin.js.map +0 -1
  291. package/crud/trigger.tasks.d.ts +0 -2
  292. package/crud/trigger.tasks.js.map +0 -1
  293. package/crud/where.d.ts +0 -1
  294. package/crud/where.js +0 -33
  295. package/crud/where.js.map +0 -1
  296. package/plugins/TaskTriggerTransportPlugin.d.ts +0 -17
  297. package/plugins/TaskTriggerTransportPlugin.js +0 -20
  298. package/plugins/TaskTriggerTransportPlugin.js.map +0 -1
  299. package/task/index.d.ts +0 -2
  300. package/task/index.js +0 -29
  301. package/task/index.js.map +0 -1
  302. package/task/input.d.ts +0 -15
  303. package/task/input.js +0 -21
  304. package/task/input.js.map +0 -1
  305. package/task/plugin.d.ts +0 -34
  306. package/task/plugin.js +0 -100
  307. package/task/plugin.js.map +0 -1
  308. package/transport/createTransport.d.ts +0 -7
  309. package/transport/createTransport.js +0 -32
  310. package/transport/createTransport.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { ITaskRunner } from "./";
2
- import { IResponse, IResponseResult } from "../../response/abstractions";
3
- import { Context } from "../../types";
4
- import { ITaskEvent } from "../../handler/types";
1
+ import type { ITaskRunner } from "../../runner/abstractions/index.js";
2
+ import type { IResponse, IResponseResult } from "../../response/abstractions/index.js";
3
+ import type { Context } from "../../types.js";
4
+ import type { ITaskEvent } from "../../handler/types.js";
5
5
  export interface ITaskControl {
6
6
  runner: ITaskRunner;
7
7
  response: IResponse;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=TaskControl.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TaskControl.ts"],"sourcesContent":["import { ITaskRunner } from \"~/runner/abstractions\";\nimport { IResponse, IResponseResult } from \"~/response/abstractions\";\nimport { Context } from \"~/types\";\nimport { ITaskEvent } from \"~/handler/types\";\n\nexport interface ITaskControl {\n runner: ITaskRunner;\n response: IResponse;\n context: Context;\n\n run(event: ITaskEvent): Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["TaskControl.ts"],"sourcesContent":["import type { ITaskRunner } from \"~/runner/abstractions/index.js\";\nimport type { IResponse, IResponseResult } from \"~/response/abstractions/index.js\";\nimport type { Context } from \"~/types.js\";\nimport type { ITaskEvent } from \"~/handler/types.js\";\n\nexport interface ITaskControl {\n runner: ITaskRunner;\n response: IResponse;\n context: Context;\n\n run(event: ITaskEvent): Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { ITaskEvent } from "../../handler/types";
2
- export declare type ITaskEventValidationResult = ITaskEvent;
1
+ import type { ITaskEvent } from "../../handler/types.js";
2
+ export type ITaskEventValidationResult = ITaskEvent;
3
3
  export interface ITaskEventValidation {
4
4
  validate: (event: Partial<ITaskEvent>) => ITaskEventValidationResult;
5
5
  }
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=TaskEventValidation.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TaskEventValidation.ts"],"sourcesContent":["import { ITaskEvent } from \"~/handler/types\";\n\nexport type ITaskEventValidationResult = ITaskEvent;\n\nexport interface ITaskEventValidation {\n validate: (event: Partial<ITaskEvent>) => ITaskEventValidationResult;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["TaskEventValidation.ts"],"sourcesContent":["import type { ITaskEvent } from \"~/handler/types.js\";\n\nexport type ITaskEventValidationResult = ITaskEvent;\n\nexport interface ITaskEventValidation {\n validate: (event: Partial<ITaskEvent>) => ITaskEventValidationResult;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { IResponseResult } from "../../response/abstractions";
2
- import { ITask, ITaskDataInput, ITaskDefinition } from "../../types";
3
- export interface ITaskManager<T = ITaskDataInput> {
4
- run: (definition: ITaskDefinition, task: ITask<T>) => Promise<IResponseResult>;
1
+ import type { IResponseResult } from "../../response/abstractions/index.js";
2
+ import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
+ export interface ITaskManager {
4
+ run: (definition: TaskDefinition.Runnable) => Promise<IResponseResult>;
5
5
  }
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=TaskManager.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TaskManager.ts"],"sourcesContent":["import { IResponseResult } from \"~/response/abstractions\";\nimport { ITask, ITaskDataInput, ITaskDefinition } from \"~/types\";\n\nexport interface ITaskManager<T = ITaskDataInput> {\n run: (definition: ITaskDefinition, task: ITask<T>) => Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["TaskManager.ts"],"sourcesContent":["import type { IResponseResult } from \"~/response/abstractions/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface ITaskManager {\n run: (definition: TaskDefinition.Runnable) => Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,17 +1,18 @@
1
- import { IResponseError, ITask, ITaskDataInput, ITaskLogItemData, ITaskResponseDoneResultOutput, ITaskUpdateData, TaskDataStatus } from "../../types";
2
- export declare type ITaskManagerStoreUpdateTaskValues<T extends ITaskDataInput = ITaskDataInput> = T;
3
- export interface ITaskManagerStoreUpdateTaskValuesCb<T extends ITaskDataInput = ITaskDataInput> {
1
+ import type { IResponseError, ITask, ITaskLogItemData, ITaskUpdateData, TaskDataStatus } from "../../types.js";
2
+ import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
+ export type ITaskManagerStoreUpdateTaskValues<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> = T;
4
+ export interface ITaskManagerStoreUpdateTaskValuesCb<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {
4
5
  (input: T): T;
5
6
  }
6
7
  export interface ITaskManagerStoreUpdateTaskInputOptions {
7
8
  save: boolean;
8
9
  }
9
- export declare type ITaskManagerStoreUpdateTaskInputParam<T extends ITaskDataInput = ITaskDataInput> = ITaskManagerStoreUpdateTaskValuesCb<T> | Partial<ITaskManagerStoreUpdateTaskValues<T>>;
10
- export interface ITaskManagerStoreUpdateTaskParamCb<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
10
+ export type ITaskManagerStoreUpdateTaskInputParam<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> = ITaskManagerStoreUpdateTaskValuesCb<T> | Partial<ITaskManagerStoreUpdateTaskValues<T>>;
11
+ export interface ITaskManagerStoreUpdateTaskParamCb<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> {
11
12
  (task: ITask<T, O>): ITaskUpdateData<T, O>;
12
13
  }
13
- export declare type ITaskManagerStoreUpdateTask<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITaskUpdateData<T, O>;
14
- export declare type ITaskManagerStoreUpdateTaskParams<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = ITaskManagerStoreUpdateTaskParamCb<T, O> | Partial<ITaskManagerStoreUpdateTask<T, O>>;
14
+ export type ITaskManagerStoreUpdateTask<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> = ITaskUpdateData<T, O>;
15
+ export type ITaskManagerStoreUpdateTaskParams<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> = ITaskManagerStoreUpdateTaskParamCb<T, O> | Partial<ITaskManagerStoreUpdateTask<T, O>>;
15
16
  export interface ITaskManagerStoreInfoLog {
16
17
  message: string;
17
18
  data?: ITaskLogItemData;
@@ -42,13 +43,18 @@ export interface ITaskManagerStoreAddLogOptions {
42
43
  /**
43
44
  * Interface should not be used outside the @webiny/tasks package.
44
45
  */
45
- export interface ITaskManagerStorePrivate<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
46
+ export interface ITaskManagerStorePrivate<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> {
46
47
  getTask: () => ITask<T, O>;
47
48
  getStatus: () => TaskDataStatus;
48
49
  /**
49
50
  * @throws {Error} If task not found or something goes wrong during the database update.
50
51
  */
51
52
  updateTask(params: ITaskManagerStoreUpdateTaskParams<T, O>, options?: ITaskManagerStoreUpdateTaskOptions): Promise<void>;
53
+ /**
54
+ * List all child tasks of the current task.
55
+ * If definitionId is provided, filter by that parameter.
56
+ */
57
+ listChildTasks<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput>(definitionId?: string): Promise<ITask<T, O>[]>;
52
58
  /**
53
59
  * Update the task input, which are used to store custom user data.
54
60
  * You can send partial input, and it will be merged with the existing input.
@@ -83,4 +89,4 @@ export interface ITaskManagerStorePrivate<T extends ITaskDataInput = ITaskDataIn
83
89
  */
84
90
  save(): Promise<void>;
85
91
  }
86
- export declare type ITaskManagerStore<T extends ITaskDataInput = ITaskDataInput, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> = Omit<ITaskManagerStorePrivate<T, O>, "save">;
92
+ export type ITaskManagerStore<T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput, O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> = Omit<ITaskManagerStorePrivate<T, O>, "save">;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=TaskManagerStore.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TaskManagerStore.ts"],"sourcesContent":["import {\n IResponseError,\n ITask,\n ITaskDataInput,\n ITaskLogItemData,\n ITaskResponseDoneResultOutput,\n ITaskUpdateData,\n TaskDataStatus\n} from \"~/types\";\n\nexport type ITaskManagerStoreUpdateTaskValues<T extends ITaskDataInput = ITaskDataInput> = T;\n\nexport interface ITaskManagerStoreUpdateTaskValuesCb<T extends ITaskDataInput = ITaskDataInput> {\n (input: T): T;\n}\n\nexport interface ITaskManagerStoreUpdateTaskInputOptions {\n save: boolean;\n}\n\nexport type ITaskManagerStoreUpdateTaskInputParam<T extends ITaskDataInput = ITaskDataInput> =\n | ITaskManagerStoreUpdateTaskValuesCb<T>\n | Partial<ITaskManagerStoreUpdateTaskValues<T>>;\n\nexport interface ITaskManagerStoreUpdateTaskParamCb<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n (task: ITask<T, O>): ITaskUpdateData<T, O>;\n}\n\nexport type ITaskManagerStoreUpdateTask<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = ITaskUpdateData<T, O>;\n\nexport type ITaskManagerStoreUpdateTaskParams<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = ITaskManagerStoreUpdateTaskParamCb<T, O> | Partial<ITaskManagerStoreUpdateTask<T, O>>;\n\nexport interface ITaskManagerStoreInfoLog {\n message: string;\n data?: ITaskLogItemData;\n}\n\nexport interface ITaskManagerStoreErrorLog {\n message: string;\n data?: ITaskLogItemData;\n error: IResponseError | Error;\n}\n\nexport interface ITaskManagerStoreSetOutputOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\nexport interface ITaskManagerStoreUpdateTaskOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\nexport interface ITaskManagerStoreAddLogOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\n/**\n * Interface should not be used outside the @webiny/tasks package.\n */\nexport interface ITaskManagerStorePrivate<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n getTask: () => ITask<T, O>;\n getStatus: () => TaskDataStatus;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateTask(\n params: ITaskManagerStoreUpdateTaskParams<T, O>,\n options?: ITaskManagerStoreUpdateTaskOptions\n ): Promise<void>;\n /**\n * Update the task input, which are used to store custom user data.\n * You can send partial input, and it will be merged with the existing input.\n *\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateInput: (\n params: ITaskManagerStoreUpdateTaskInputParam<T>,\n options?: ITaskManagerStoreUpdateTaskInputOptions\n ) => Promise<void>;\n getInput: () => T;\n /**\n * Update the task output, which are used to store the output data.\n * You can send partial output, and it will be merged with the existing output.\n *\n * Second parameter is optional options, and it contains a possibility not to store the task immediately.\n *\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateOutput: (\n values: Partial<O>,\n options?: ITaskManagerStoreSetOutputOptions\n ) => Promise<void>;\n getOutput: () => O;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n addInfoLog: (log: ITaskManagerStoreInfoLog) => Promise<void>;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n *\n *\n */\n addErrorLog: (log: ITaskManagerStoreErrorLog) => Promise<void>;\n /**\n * Should store the task and logs into the database, if any.\n * If nothing to update, it should skip calling the internal store methods.\n */\n save(): Promise<void>;\n}\n\nexport type ITaskManagerStore<\n T extends ITaskDataInput = ITaskDataInput,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> = Omit<ITaskManagerStorePrivate<T, O>, \"save\">;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["TaskManagerStore.ts"],"sourcesContent":["import type {\n IResponseError,\n ITask,\n ITaskLogItemData,\n ITaskUpdateData,\n TaskDataStatus\n} from \"~/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport type ITaskManagerStoreUpdateTaskValues<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput\n> = T;\n\nexport interface ITaskManagerStoreUpdateTaskValuesCb<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput\n> {\n (input: T): T;\n}\n\nexport interface ITaskManagerStoreUpdateTaskInputOptions {\n save: boolean;\n}\n\nexport type ITaskManagerStoreUpdateTaskInputParam<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput\n> = ITaskManagerStoreUpdateTaskValuesCb<T> | Partial<ITaskManagerStoreUpdateTaskValues<T>>;\n\nexport interface ITaskManagerStoreUpdateTaskParamCb<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> {\n (task: ITask<T, O>): ITaskUpdateData<T, O>;\n}\n\nexport type ITaskManagerStoreUpdateTask<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> = ITaskUpdateData<T, O>;\n\nexport type ITaskManagerStoreUpdateTaskParams<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> = ITaskManagerStoreUpdateTaskParamCb<T, O> | Partial<ITaskManagerStoreUpdateTask<T, O>>;\n\nexport interface ITaskManagerStoreInfoLog {\n message: string;\n data?: ITaskLogItemData;\n}\n\nexport interface ITaskManagerStoreErrorLog {\n message: string;\n data?: ITaskLogItemData;\n error: IResponseError | Error;\n}\n\nexport interface ITaskManagerStoreSetOutputOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\nexport interface ITaskManagerStoreUpdateTaskOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\nexport interface ITaskManagerStoreAddLogOptions {\n /**\n * Default is true.\n */\n save?: boolean;\n}\n\n/**\n * Interface should not be used outside the @webiny/tasks package.\n */\nexport interface ITaskManagerStorePrivate<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> {\n getTask: () => ITask<T, O>;\n getStatus: () => TaskDataStatus;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateTask(\n params: ITaskManagerStoreUpdateTaskParams<T, O>,\n options?: ITaskManagerStoreUpdateTaskOptions\n ): Promise<void>;\n /**\n * List all child tasks of the current task.\n * If definitionId is provided, filter by that parameter.\n */\n listChildTasks<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n >(\n definitionId?: string\n ): Promise<ITask<T, O>[]>;\n /**\n * Update the task input, which are used to store custom user data.\n * You can send partial input, and it will be merged with the existing input.\n *\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateInput: (\n params: ITaskManagerStoreUpdateTaskInputParam<T>,\n options?: ITaskManagerStoreUpdateTaskInputOptions\n ) => Promise<void>;\n getInput: () => T;\n /**\n * Update the task output, which are used to store the output data.\n * You can send partial output, and it will be merged with the existing output.\n *\n * Second parameter is optional options, and it contains a possibility not to store the task immediately.\n *\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n updateOutput: (\n values: Partial<O>,\n options?: ITaskManagerStoreSetOutputOptions\n ) => Promise<void>;\n getOutput: () => O;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n */\n addInfoLog: (log: ITaskManagerStoreInfoLog) => Promise<void>;\n /**\n * @throws {Error} If task not found or something goes wrong during the database update.\n *\n *\n */\n addErrorLog: (log: ITaskManagerStoreErrorLog) => Promise<void>;\n /**\n * Should store the task and logs into the database, if any.\n * If nothing to update, it should skip calling the internal store methods.\n */\n save(): Promise<void>;\n}\n\nexport type ITaskManagerStore<\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> = Omit<ITaskManagerStorePrivate<T, O>, \"save\">;\n"],"mappings":"","ignoreList":[]}
@@ -1,8 +1,13 @@
1
- import { Context } from "../../types";
2
- import { ITaskEvent } from "../../handler/types";
3
- import { IResponseResult } from "../../response/abstractions";
1
+ import type { Context } from "../../types.js";
2
+ import type { ITaskEvent } from "../../handler/types.js";
3
+ import type { IResponseResult } from "../../response/abstractions/index.js";
4
+ import type { ITimer } from "@webiny/handler-aws";
5
+ export interface IIsCloseToTimeoutCallable {
6
+ (seconds?: number): boolean;
7
+ }
4
8
  export interface ITaskRunner<C extends Context = Context> {
5
9
  context: C;
6
- isCloseToTimeout(seconds?: number): boolean;
10
+ isCloseToTimeout: IIsCloseToTimeoutCallable;
11
+ timer: ITimer;
7
12
  run(event: ITaskEvent): Promise<IResponseResult>;
8
13
  }
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=TaskRunner.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TaskRunner.ts"],"sourcesContent":["import { Context } from \"~/types\";\nimport { ITaskEvent } from \"~/handler/types\";\nimport { IResponseResult } from \"~/response/abstractions\";\n\nexport interface ITaskRunner<C extends Context = Context> {\n context: C;\n isCloseToTimeout(seconds?: number): boolean;\n run(event: ITaskEvent): Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["TaskRunner.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport type { ITaskEvent } from \"~/handler/types.js\";\nimport type { IResponseResult } from \"~/response/abstractions/index.js\";\nimport type { ITimer } from \"@webiny/handler-aws\";\n\nexport interface IIsCloseToTimeoutCallable {\n (seconds?: number): boolean;\n}\n\nexport interface ITaskRunner<C extends Context = Context> {\n context: C;\n isCloseToTimeout: IIsCloseToTimeoutCallable;\n timer: ITimer;\n run(event: ITaskEvent): Promise<IResponseResult>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- export * from "./TaskControl";
2
- export * from "./TaskEventValidation";
3
- export * from "./TaskManager";
4
- export * from "./TaskRunner";
5
- export * from "./TaskManagerStore";
1
+ export * from "./TaskControl.js";
2
+ export * from "./TaskEventValidation.js";
3
+ export * from "./TaskManager.js";
4
+ export * from "./TaskRunner.js";
5
+ export * from "./TaskManagerStore.js";
@@ -1,62 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _TaskControl = require("./TaskControl");
7
- Object.keys(_TaskControl).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _TaskControl[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _TaskControl[key];
14
- }
15
- });
16
- });
17
- var _TaskEventValidation = require("./TaskEventValidation");
18
- Object.keys(_TaskEventValidation).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _TaskEventValidation[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _TaskEventValidation[key];
25
- }
26
- });
27
- });
28
- var _TaskManager = require("./TaskManager");
29
- Object.keys(_TaskManager).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _TaskManager[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _TaskManager[key];
36
- }
37
- });
38
- });
39
- var _TaskRunner = require("./TaskRunner");
40
- Object.keys(_TaskRunner).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _TaskRunner[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _TaskRunner[key];
47
- }
48
- });
49
- });
50
- var _TaskManagerStore = require("./TaskManagerStore");
51
- Object.keys(_TaskManagerStore).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _TaskManagerStore[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _TaskManagerStore[key];
58
- }
59
- });
60
- });
1
+ export * from "./TaskControl.js";
2
+ export * from "./TaskEventValidation.js";
3
+ export * from "./TaskManager.js";
4
+ export * from "./TaskRunner.js";
5
+ export * from "./TaskManagerStore.js";
61
6
 
62
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_TaskControl","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_TaskEventValidation","_TaskManager","_TaskRunner","_TaskManagerStore"],"sources":["index.ts"],"sourcesContent":["export * from \"./TaskControl\";\nexport * from \"./TaskEventValidation\";\nexport * from \"./TaskManager\";\nexport * from \"./TaskRunner\";\nexport * from \"./TaskManagerStore\";\n"],"mappings":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,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,YAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,YAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,YAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,YAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,WAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,WAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,WAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,WAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,iBAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,iBAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,iBAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,iBAAA,CAAAR,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./TaskControl.js\";\nexport * from \"./TaskEventValidation.js\";\nexport * from \"./TaskManager.js\";\nexport * from \"./TaskRunner.js\";\nexport * from \"./TaskManagerStore.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
package/runner/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./TaskRunner";
1
+ export * from "./TaskRunner.js";
package/runner/index.js CHANGED
@@ -1,18 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _TaskRunner = require("./TaskRunner");
7
- Object.keys(_TaskRunner).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _TaskRunner[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _TaskRunner[key];
14
- }
15
- });
16
- });
1
+ export * from "./TaskRunner.js";
17
2
 
18
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_TaskRunner","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./TaskRunner\";\n"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./TaskRunner.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import type { ITaskService, ITaskServiceCreatePluginParams, ITaskServiceTask } from "../plugins/index.js";
2
+ import { TaskServicePlugin } from "../plugins/index.js";
3
+ import type { PutEventsCommandOutput } from "@webiny/aws-sdk/client-eventbridge/index.js";
4
+ import type { GenericRecord } from "@webiny/api/types.js";
5
+ declare class EventBridgeService implements ITaskService {
6
+ protected readonly getTenant: () => string;
7
+ private readonly client;
8
+ constructor(params: ITaskServiceCreatePluginParams);
9
+ send(task: ITaskServiceTask, delay: number): Promise<PutEventsCommandOutput>;
10
+ fetch(): Promise<GenericRecord>;
11
+ }
12
+ export declare class EventBridgeEventTransportPlugin extends TaskServicePlugin {
13
+ name: string;
14
+ createService(params: ITaskServiceCreatePluginParams): EventBridgeService;
15
+ }
16
+ export {};
@@ -0,0 +1,51 @@
1
+ import { TaskServicePlugin } from "../plugins/index.js";
2
+ import { EventBridgeClient, PutEventsCommand } from "@webiny/aws-sdk/client-eventbridge/index.js";
3
+ import { WebinyError } from "@webiny/error";
4
+ class EventBridgeService {
5
+ constructor(params) {
6
+ this.client = new EventBridgeClient({
7
+ region: process.env.AWS_REGION
8
+ });
9
+ this.getTenant = params.getTenant;
10
+ }
11
+ async send(task, delay) {
12
+ /**
13
+ * The ITaskEvent is what our handler expect to get.
14
+ * Endpoint and stateMachineId are added by the step function.
15
+ */
16
+ const event = {
17
+ webinyTaskId: task.id,
18
+ webinyTaskDefinitionId: task.definitionId,
19
+ tenant: this.getTenant(),
20
+ delay
21
+ };
22
+ const cmd = new PutEventsCommand({
23
+ Entries: [{
24
+ Source: "webiny-api-tasks",
25
+ EventBusName: String(process.env.EVENT_BUS),
26
+ DetailType: "WebinyBackgroundTask",
27
+ Detail: JSON.stringify(event)
28
+ }]
29
+ });
30
+ try {
31
+ const result = await this.client.send(cmd);
32
+ return JSON.parse(JSON.stringify(result));
33
+ } catch (ex) {
34
+ throw new WebinyError(ex.message || "Could not trigger task via Event Bridge!", ex.code || "TRIGGER_TASK_ERROR", {
35
+ event,
36
+ ...(ex.data || {})
37
+ });
38
+ }
39
+ }
40
+ async fetch() {
41
+ throw new WebinyError("Not implemented!", "NOT_IMPLEMENTED");
42
+ }
43
+ }
44
+ export class EventBridgeEventTransportPlugin extends TaskServicePlugin {
45
+ name = "task.eventBridgeEventTransport";
46
+ createService(params) {
47
+ return new EventBridgeService(params);
48
+ }
49
+ }
50
+
51
+ //# sourceMappingURL=EventBridgeEventTransportPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TaskServicePlugin","EventBridgeClient","PutEventsCommand","WebinyError","EventBridgeService","constructor","params","client","region","process","env","AWS_REGION","getTenant","send","task","delay","event","webinyTaskId","id","webinyTaskDefinitionId","definitionId","tenant","cmd","Entries","Source","EventBusName","String","EVENT_BUS","DetailType","Detail","JSON","stringify","result","parse","ex","message","code","data","fetch","EventBridgeEventTransportPlugin","name","createService"],"sources":["EventBridgeEventTransportPlugin.ts"],"sourcesContent":["import type {\n ITaskService,\n ITaskServiceCreatePluginParams,\n ITaskServiceTask\n} from \"~/plugins/index.js\";\nimport { TaskServicePlugin } from \"~/plugins/index.js\";\nimport type { ITaskEventInput } from \"~/types.js\";\nimport type { PutEventsCommandOutput } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport { EventBridgeClient, PutEventsCommand } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nclass EventBridgeService implements ITaskService {\n protected readonly getTenant: () => string;\n private readonly client: EventBridgeClient;\n\n public constructor(params: ITaskServiceCreatePluginParams) {\n this.client = new EventBridgeClient({\n region: process.env.AWS_REGION\n });\n this.getTenant = params.getTenant;\n }\n\n public async send(task: ITaskServiceTask, delay: number): Promise<PutEventsCommandOutput> {\n /**\n * The ITaskEvent is what our handler expect to get.\n * Endpoint and stateMachineId are added by the step function.\n */\n const event: ITaskEventInput = {\n webinyTaskId: task.id,\n webinyTaskDefinitionId: task.definitionId,\n tenant: this.getTenant(),\n delay\n };\n\n const cmd = new PutEventsCommand({\n Entries: [\n {\n Source: \"webiny-api-tasks\",\n EventBusName: String(process.env.EVENT_BUS),\n DetailType: \"WebinyBackgroundTask\",\n Detail: JSON.stringify(event)\n }\n ]\n });\n try {\n const result = await this.client.send(cmd);\n\n return JSON.parse(JSON.stringify(result));\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not trigger task via Event Bridge!\",\n ex.code || \"TRIGGER_TASK_ERROR\",\n {\n event,\n ...(ex.data || {})\n }\n );\n }\n }\n\n public async fetch(): Promise<GenericRecord> {\n throw new WebinyError(\"Not implemented!\", \"NOT_IMPLEMENTED\");\n }\n}\n\nexport class EventBridgeEventTransportPlugin extends TaskServicePlugin {\n public override name = \"task.eventBridgeEventTransport\";\n public createService(params: ITaskServiceCreatePluginParams) {\n return new EventBridgeService(params);\n }\n}\n"],"mappings":"AAKA,SAASA,iBAAiB;AAG1B,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,6CAA6C;AACjG,SAASC,WAAW,QAAQ,eAAe;AAG3C,MAAMC,kBAAkB,CAAyB;EAItCC,WAAWA,CAACC,MAAsC,EAAE;IACvD,IAAI,CAACC,MAAM,GAAG,IAAIN,iBAAiB,CAAC;MAChCO,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC;IACxB,CAAC,CAAC;IACF,IAAI,CAACC,SAAS,GAAGN,MAAM,CAACM,SAAS;EACrC;EAEA,MAAaC,IAAIA,CAACC,IAAsB,EAAEC,KAAa,EAAmC;IACtF;AACR;AACA;AACA;IACQ,MAAMC,KAAsB,GAAG;MAC3BC,YAAY,EAAEH,IAAI,CAACI,EAAE;MACrBC,sBAAsB,EAAEL,IAAI,CAACM,YAAY;MACzCC,MAAM,EAAE,IAAI,CAACT,SAAS,CAAC,CAAC;MACxBG;IACJ,CAAC;IAED,MAAMO,GAAG,GAAG,IAAIpB,gBAAgB,CAAC;MAC7BqB,OAAO,EAAE,CACL;QACIC,MAAM,EAAE,kBAAkB;QAC1BC,YAAY,EAAEC,MAAM,CAACjB,OAAO,CAACC,GAAG,CAACiB,SAAS,CAAC;QAC3CC,UAAU,EAAE,sBAAsB;QAClCC,MAAM,EAAEC,IAAI,CAACC,SAAS,CAACf,KAAK;MAChC,CAAC;IAET,CAAC,CAAC;IACF,IAAI;MACA,MAAMgB,MAAM,GAAG,MAAM,IAAI,CAACzB,MAAM,CAACM,IAAI,CAACS,GAAG,CAAC;MAE1C,OAAOQ,IAAI,CAACG,KAAK,CAACH,IAAI,CAACC,SAAS,CAACC,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC,OAAOE,EAAE,EAAE;MACT,MAAM,IAAI/B,WAAW,CACjB+B,EAAE,CAACC,OAAO,IAAI,0CAA0C,EACxDD,EAAE,CAACE,IAAI,IAAI,oBAAoB,EAC/B;QACIpB,KAAK;QACL,IAAIkB,EAAE,CAACG,IAAI,IAAI,CAAC,CAAC;MACrB,CACJ,CAAC;IACL;EACJ;EAEA,MAAaC,KAAKA,CAAA,EAA2B;IACzC,MAAM,IAAInC,WAAW,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;EAChE;AACJ;AAEA,OAAO,MAAMoC,+BAA+B,SAASvC,iBAAiB,CAAC;EACnDwC,IAAI,GAAG,gCAAgC;EAChDC,aAAaA,CAACnC,MAAsC,EAAE;IACzD,OAAO,IAAIF,kBAAkB,CAACE,MAAM,CAAC;EACzC;AACJ","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import type { ITaskService, ITaskServiceCreatePluginParams, ITaskServiceTask } from "../plugins/index.js";
2
+ import { TaskServicePlugin } from "../plugins/index.js";
3
+ import type { DescribeExecutionCommandOutput } from "@webiny/aws-sdk/client-sfn/index.js";
4
+ import type { ITask } from "../types.js";
5
+ export type IStepFunctionServiceFetchResult = DescribeExecutionCommandOutput;
6
+ export interface IDetailWrapper<T> {
7
+ detail: T;
8
+ }
9
+ export declare class StepFunctionService implements ITaskService {
10
+ private readonly getTenant;
11
+ private readonly trigger;
12
+ private readonly get;
13
+ constructor(params: ITaskServiceCreatePluginParams);
14
+ send(task: ITaskServiceTask, delay: number): Promise<{
15
+ name: string;
16
+ executionArn: string | undefined;
17
+ startDate: Date | undefined;
18
+ $metadata: import("@smithy/types").ResponseMetadata;
19
+ } | null>;
20
+ fetch(task: ITask): Promise<IStepFunctionServiceFetchResult | null>;
21
+ }
22
+ export declare class StepFunctionServicePlugin extends TaskServicePlugin {
23
+ name: string;
24
+ createService(params: ITaskServiceCreatePluginParams): StepFunctionService;
25
+ }
@@ -0,0 +1,78 @@
1
+ import { TaskServicePlugin } from "../plugins/index.js";
2
+ import { createStepFunctionClient, describeExecutionFactory, triggerStepFunctionFactory } from "@webiny/aws-sdk/client-sfn/index.js";
3
+ import { generateAlphaNumericId } from "@webiny/utils";
4
+ import { ServiceDiscovery } from "@webiny/api";
5
+ export class StepFunctionService {
6
+ constructor(params) {
7
+ this.getTenant = params.getTenant;
8
+ const client = createStepFunctionClient();
9
+ this.trigger = triggerStepFunctionFactory(client);
10
+ this.get = describeExecutionFactory(client);
11
+ }
12
+ async send(task, delay) {
13
+ const manifest = await ServiceDiscovery.load();
14
+ if (!manifest) {
15
+ console.error("Service manifest not found.");
16
+ return null;
17
+ }
18
+ const {
19
+ bgTaskSfn
20
+ } = manifest.api || {};
21
+ if (!bgTaskSfn) {
22
+ console.error("Background task state machine not found.");
23
+ return null;
24
+ }
25
+ const input = {
26
+ webinyTaskId: task.id,
27
+ webinyTaskDefinitionId: task.definitionId,
28
+ tenant: this.getTenant(),
29
+ delay
30
+ };
31
+ const name = `${task.definitionId}_${task.id}_${generateAlphaNumericId(10)}`;
32
+ try {
33
+ const result = await this.trigger({
34
+ input: {
35
+ detail: input
36
+ },
37
+ stateMachineArn: bgTaskSfn,
38
+ name
39
+ });
40
+ return {
41
+ ...result,
42
+ name
43
+ };
44
+ } catch (ex) {
45
+ console.log("Could not trigger a step function.");
46
+ console.error(ex);
47
+ return null;
48
+ }
49
+ }
50
+ async fetch(task) {
51
+ const executionArn = task.eventResponse?.executionArn;
52
+ if (!executionArn) {
53
+ console.error(`Execution ARN not found in task "${task.id}".`);
54
+ return null;
55
+ }
56
+ try {
57
+ const result = await this.get({
58
+ executionArn
59
+ });
60
+ if (!result) {
61
+ return null;
62
+ }
63
+ return JSON.parse(JSON.stringify(result));
64
+ } catch (ex) {
65
+ console.log("Could not get the execution details.");
66
+ console.error(ex);
67
+ return null;
68
+ }
69
+ }
70
+ }
71
+ export class StepFunctionServicePlugin extends TaskServicePlugin {
72
+ name = "task.stepFunctionTriggerTransport";
73
+ createService(params) {
74
+ return new StepFunctionService(params);
75
+ }
76
+ }
77
+
78
+ //# sourceMappingURL=StepFunctionServicePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TaskServicePlugin","createStepFunctionClient","describeExecutionFactory","triggerStepFunctionFactory","generateAlphaNumericId","ServiceDiscovery","StepFunctionService","constructor","params","getTenant","client","trigger","get","send","task","delay","manifest","load","console","error","bgTaskSfn","api","input","webinyTaskId","id","webinyTaskDefinitionId","definitionId","tenant","name","result","detail","stateMachineArn","ex","log","fetch","executionArn","eventResponse","JSON","parse","stringify","StepFunctionServicePlugin","createService"],"sources":["StepFunctionServicePlugin.ts"],"sourcesContent":["import type {\n ITaskService,\n ITaskServiceCreatePluginParams,\n ITaskServiceTask\n} from \"~/plugins/index.js\";\nimport { TaskServicePlugin } from \"~/plugins/index.js\";\nimport type { DescribeExecutionCommandOutput } from \"@webiny/aws-sdk/client-sfn/index.js\";\nimport {\n createStepFunctionClient,\n describeExecutionFactory,\n triggerStepFunctionFactory\n} from \"@webiny/aws-sdk/client-sfn/index.js\";\nimport type { ITaskEventInput } from \"~/handler/types.js\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\nimport { ServiceDiscovery } from \"@webiny/api\";\nimport type { ITask } from \"~/types.js\";\n\nexport type IStepFunctionServiceFetchResult = DescribeExecutionCommandOutput;\n\nexport interface IDetailWrapper<T> {\n detail: T;\n}\n\nexport class StepFunctionService implements ITaskService {\n private readonly getTenant: () => string;\n private readonly trigger: ReturnType<typeof triggerStepFunctionFactory>;\n private readonly get: ReturnType<typeof describeExecutionFactory>;\n\n public constructor(params: ITaskServiceCreatePluginParams) {\n this.getTenant = params.getTenant;\n const client = createStepFunctionClient();\n this.trigger = triggerStepFunctionFactory(client);\n this.get = describeExecutionFactory(client);\n }\n public async send(task: ITaskServiceTask, delay: number) {\n const manifest = await ServiceDiscovery.load();\n if (!manifest) {\n console.error(\"Service manifest not found.\");\n return null;\n }\n const { bgTaskSfn } = manifest.api || {};\n if (!bgTaskSfn) {\n console.error(\"Background task state machine not found.\");\n return null;\n }\n\n const input: ITaskEventInput = {\n webinyTaskId: task.id,\n webinyTaskDefinitionId: task.definitionId,\n tenant: this.getTenant(),\n delay\n };\n const name = `${task.definitionId}_${task.id}_${generateAlphaNumericId(10)}`;\n try {\n const result = await this.trigger<IDetailWrapper<ITaskEventInput>>({\n input: {\n detail: input\n },\n stateMachineArn: bgTaskSfn,\n name\n });\n return {\n ...result,\n name\n };\n } catch (ex) {\n console.log(\"Could not trigger a step function.\");\n console.error(ex);\n return null;\n }\n }\n\n public async fetch(task: ITask): Promise<IStepFunctionServiceFetchResult | null> {\n const executionArn = task.eventResponse?.executionArn;\n if (!executionArn) {\n console.error(`Execution ARN not found in task \"${task.id}\".`);\n return null;\n }\n try {\n const result = await this.get({\n executionArn\n });\n if (!result) {\n return null;\n }\n return JSON.parse(JSON.stringify(result));\n } catch (ex) {\n console.log(\"Could not get the execution details.\");\n console.error(ex);\n return null;\n }\n }\n}\n\nexport class StepFunctionServicePlugin extends TaskServicePlugin {\n public override name = \"task.stepFunctionTriggerTransport\";\n\n public createService(params: ITaskServiceCreatePluginParams) {\n return new StepFunctionService(params);\n }\n}\n"],"mappings":"AAKA,SAASA,iBAAiB;AAE1B,SACIC,wBAAwB,EACxBC,wBAAwB,EACxBC,0BAA0B,QACvB,qCAAqC;AAE5C,SAASC,sBAAsB,QAAQ,eAAe;AACtD,SAASC,gBAAgB,QAAQ,aAAa;AAS9C,OAAO,MAAMC,mBAAmB,CAAyB;EAK9CC,WAAWA,CAACC,MAAsC,EAAE;IACvD,IAAI,CAACC,SAAS,GAAGD,MAAM,CAACC,SAAS;IACjC,MAAMC,MAAM,GAAGT,wBAAwB,CAAC,CAAC;IACzC,IAAI,CAACU,OAAO,GAAGR,0BAA0B,CAACO,MAAM,CAAC;IACjD,IAAI,CAACE,GAAG,GAAGV,wBAAwB,CAACQ,MAAM,CAAC;EAC/C;EACA,MAAaG,IAAIA,CAACC,IAAsB,EAAEC,KAAa,EAAE;IACrD,MAAMC,QAAQ,GAAG,MAAMX,gBAAgB,CAACY,IAAI,CAAC,CAAC;IAC9C,IAAI,CAACD,QAAQ,EAAE;MACXE,OAAO,CAACC,KAAK,CAAC,6BAA6B,CAAC;MAC5C,OAAO,IAAI;IACf;IACA,MAAM;MAAEC;IAAU,CAAC,GAAGJ,QAAQ,CAACK,GAAG,IAAI,CAAC,CAAC;IACxC,IAAI,CAACD,SAAS,EAAE;MACZF,OAAO,CAACC,KAAK,CAAC,0CAA0C,CAAC;MACzD,OAAO,IAAI;IACf;IAEA,MAAMG,KAAsB,GAAG;MAC3BC,YAAY,EAAET,IAAI,CAACU,EAAE;MACrBC,sBAAsB,EAAEX,IAAI,CAACY,YAAY;MACzCC,MAAM,EAAE,IAAI,CAAClB,SAAS,CAAC,CAAC;MACxBM;IACJ,CAAC;IACD,MAAMa,IAAI,GAAG,GAAGd,IAAI,CAACY,YAAY,IAAIZ,IAAI,CAACU,EAAE,IAAIpB,sBAAsB,CAAC,EAAE,CAAC,EAAE;IAC5E,IAAI;MACA,MAAMyB,MAAM,GAAG,MAAM,IAAI,CAAClB,OAAO,CAAkC;QAC/DW,KAAK,EAAE;UACHQ,MAAM,EAAER;QACZ,CAAC;QACDS,eAAe,EAAEX,SAAS;QAC1BQ;MACJ,CAAC,CAAC;MACF,OAAO;QACH,GAAGC,MAAM;QACTD;MACJ,CAAC;IACL,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTd,OAAO,CAACe,GAAG,CAAC,oCAAoC,CAAC;MACjDf,OAAO,CAACC,KAAK,CAACa,EAAE,CAAC;MACjB,OAAO,IAAI;IACf;EACJ;EAEA,MAAaE,KAAKA,CAACpB,IAAW,EAAmD;IAC7E,MAAMqB,YAAY,GAAGrB,IAAI,CAACsB,aAAa,EAAED,YAAY;IACrD,IAAI,CAACA,YAAY,EAAE;MACfjB,OAAO,CAACC,KAAK,CAAC,oCAAoCL,IAAI,CAACU,EAAE,IAAI,CAAC;MAC9D,OAAO,IAAI;IACf;IACA,IAAI;MACA,MAAMK,MAAM,GAAG,MAAM,IAAI,CAACjB,GAAG,CAAC;QAC1BuB;MACJ,CAAC,CAAC;MACF,IAAI,CAACN,MAAM,EAAE;QACT,OAAO,IAAI;MACf;MACA,OAAOQ,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACV,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC,OAAOG,EAAE,EAAE;MACTd,OAAO,CAACe,GAAG,CAAC,sCAAsC,CAAC;MACnDf,OAAO,CAACC,KAAK,CAACa,EAAE,CAAC;MACjB,OAAO,IAAI;IACf;EACJ;AACJ;AAEA,OAAO,MAAMQ,yBAAyB,SAASxC,iBAAiB,CAAC;EAC7C4B,IAAI,GAAG,mCAAmC;EAEnDa,aAAaA,CAACjC,MAAsC,EAAE;IACzD,OAAO,IAAIF,mBAAmB,CAACE,MAAM,CAAC;EAC1C;AACJ","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { Context } from "../types.js";
2
+ import type { ITaskService } from "../plugins/index.js";
3
+ export interface ICreateTransport {
4
+ context: Context;
5
+ }
6
+ export declare const createService: (params: ICreateTransport) => ITaskService;
@@ -0,0 +1,19 @@
1
+ import { TaskServicePlugin } from "../plugins/index.js";
2
+ import { WebinyError } from "@webiny/error";
3
+ export const createService = params => {
4
+ const plugins = params.context.plugins.byType(TaskServicePlugin.type).reverse();
5
+ const plugin = plugins.find(plugin => plugin.default) || plugins[0];
6
+ if (!plugin) {
7
+ throw new WebinyError("Missing TaskServicePlugin.", "PLUGIN_ERROR", {
8
+ type: TaskServicePlugin.type
9
+ });
10
+ }
11
+ const getTenant = () => {
12
+ return params.context.tenancy.getCurrentTenant().id;
13
+ };
14
+ return plugin.createService({
15
+ getTenant
16
+ });
17
+ };
18
+
19
+ //# sourceMappingURL=createService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TaskServicePlugin","WebinyError","createService","params","plugins","context","byType","type","reverse","plugin","find","default","getTenant","tenancy","getCurrentTenant","id"],"sources":["createService.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport type { ITaskService } from \"~/plugins/index.js\";\nimport { TaskServicePlugin } from \"~/plugins/index.js\";\nimport { WebinyError } from \"@webiny/error\";\n\nexport interface ICreateTransport {\n context: Context;\n}\n\nexport const createService = (params: ICreateTransport): ITaskService => {\n const plugins = params.context.plugins\n .byType<TaskServicePlugin>(TaskServicePlugin.type)\n .reverse();\n\n const plugin = plugins.find(plugin => plugin.default) || plugins[0];\n if (!plugin) {\n throw new WebinyError(\"Missing TaskServicePlugin.\", \"PLUGIN_ERROR\", {\n type: TaskServicePlugin.type\n });\n }\n\n const getTenant = (): string => {\n return params.context.tenancy.getCurrentTenant().id;\n };\n\n return plugin.createService({\n getTenant\n });\n};\n"],"mappings":"AAEA,SAASA,iBAAiB;AAC1B,SAASC,WAAW,QAAQ,eAAe;AAM3C,OAAO,MAAMC,aAAa,GAAIC,MAAwB,IAAmB;EACrE,MAAMC,OAAO,GAAGD,MAAM,CAACE,OAAO,CAACD,OAAO,CACjCE,MAAM,CAAoBN,iBAAiB,CAACO,IAAI,CAAC,CACjDC,OAAO,CAAC,CAAC;EAEd,MAAMC,MAAM,GAAGL,OAAO,CAACM,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACE,OAAO,CAAC,IAAIP,OAAO,CAAC,CAAC,CAAC;EACnE,IAAI,CAACK,MAAM,EAAE;IACT,MAAM,IAAIR,WAAW,CAAC,4BAA4B,EAAE,cAAc,EAAE;MAChEM,IAAI,EAAEP,iBAAiB,CAACO;IAC5B,CAAC,CAAC;EACN;EAEA,MAAMK,SAAS,GAAGA,CAAA,KAAc;IAC5B,OAAOT,MAAM,CAACE,OAAO,CAACQ,OAAO,CAACC,gBAAgB,CAAC,CAAC,CAACC,EAAE;EACvD,CAAC;EAED,OAAON,MAAM,CAACP,aAAa,CAAC;IACxBU;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { EventBridgeEventTransportPlugin } from "./EventBridgeEventTransportPlugin.js";
2
+ import { StepFunctionServicePlugin } from "./StepFunctionServicePlugin.js";
3
+ export declare const createServicePlugins: () => (StepFunctionServicePlugin | EventBridgeEventTransportPlugin)[];
4
+ export * from "./createService.js";
@@ -0,0 +1,10 @@
1
+ import { EventBridgeEventTransportPlugin } from "./EventBridgeEventTransportPlugin.js";
2
+ import { StepFunctionServicePlugin } from "./StepFunctionServicePlugin.js";
3
+ export const createServicePlugins = () => {
4
+ return [new StepFunctionServicePlugin({
5
+ default: true
6
+ }), new EventBridgeEventTransportPlugin()];
7
+ };
8
+ export * from "./createService.js";
9
+
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EventBridgeEventTransportPlugin","StepFunctionServicePlugin","createServicePlugins","default"],"sources":["index.ts"],"sourcesContent":["import { EventBridgeEventTransportPlugin } from \"./EventBridgeEventTransportPlugin.js\";\nimport { StepFunctionServicePlugin } from \"./StepFunctionServicePlugin.js\";\n\nexport const createServicePlugins = () => {\n return [\n new StepFunctionServicePlugin({ default: true }),\n new EventBridgeEventTransportPlugin()\n ];\n};\n\nexport * from \"./createService.js\";\n"],"mappings":"AAAA,SAASA,+BAA+B;AACxC,SAASC,yBAAyB;AAElC,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACtC,OAAO,CACH,IAAID,yBAAyB,CAAC;IAAEE,OAAO,EAAE;EAAK,CAAC,CAAC,EAChD,IAAIH,+BAA+B,CAAC,CAAC,CACxC;AACL,CAAC;AAED","ignoreList":[]}
@@ -1 +1,10 @@
1
- export declare const createTestingRunTask: () => import("../task").TaskDefinitionPlugin<import("..").Context, any, import("..").ITaskResponseDoneResultOutput>;
1
+ import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
+ declare class TestingRunTask implements TaskDefinition.Interface {
3
+ id: string;
4
+ title: string;
5
+ run({ controller }: TaskDefinition.RunParams): Promise<TaskDefinition.ResultDone<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
6
+ }
7
+ export declare const TestingRunTaskDefinition: typeof TestingRunTask & {
8
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
9
+ };
10
+ export {};