@webiny/tasks 6.3.0 → 6.4.0-beta.0

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 (203) hide show
  1. package/context.js +31 -43
  2. package/context.js.map +1 -1
  3. package/crud/TaskLogPrivateModel.js +33 -27
  4. package/crud/TaskLogPrivateModel.js.map +1 -1
  5. package/crud/TaskPrivateModel.js +48 -39
  6. package/crud/TaskPrivateModel.js.map +1 -1
  7. package/crud/cleanupTaskSubtree.js +55 -69
  8. package/crud/cleanupTaskSubtree.js.map +1 -1
  9. package/crud/crud.tasks.js +289 -352
  10. package/crud/crud.tasks.js.map +1 -1
  11. package/crud/definition.tasks.js +13 -16
  12. package/crud/definition.tasks.js.map +1 -1
  13. package/crud/service.tasks.js +119 -155
  14. package/crud/service.tasks.js.map +1 -1
  15. package/decorators/RunnableTaskDecorator.js +61 -77
  16. package/decorators/RunnableTaskDecorator.js.map +1 -1
  17. package/decorators/SelfCleaningTaskDecorator.js +75 -89
  18. package/decorators/SelfCleaningTaskDecorator.js.map +1 -1
  19. package/domain/errors.js +35 -39
  20. package/domain/errors.js.map +1 -1
  21. package/events/TaskAfterCreateEvent.js +8 -5
  22. package/events/TaskAfterCreateEvent.js.map +1 -1
  23. package/events/TaskAfterDeleteEvent.js +8 -5
  24. package/events/TaskAfterDeleteEvent.js.map +1 -1
  25. package/events/TaskAfterUpdateEvent.js +8 -5
  26. package/events/TaskAfterUpdateEvent.js.map +1 -1
  27. package/events/TaskBeforeCreateEvent.js +8 -5
  28. package/events/TaskBeforeCreateEvent.js.map +1 -1
  29. package/events/TaskBeforeDeleteEvent.js +8 -5
  30. package/events/TaskBeforeDeleteEvent.js.map +1 -1
  31. package/events/TaskBeforeUpdateEvent.js +8 -5
  32. package/events/TaskBeforeUpdateEvent.js.map +1 -1
  33. package/events/abstractions.js +7 -36
  34. package/events/abstractions.js.map +1 -1
  35. package/events/index.js +0 -2
  36. package/features/AbortTask/AbortTaskUseCase.js +9 -8
  37. package/features/AbortTask/AbortTaskUseCase.js.map +1 -1
  38. package/features/AbortTask/abstractions.js +2 -1
  39. package/features/AbortTask/abstractions.js.map +1 -1
  40. package/features/AbortTask/feature.js +6 -5
  41. package/features/AbortTask/feature.js.map +1 -1
  42. package/features/AbortTask/index.js +0 -2
  43. package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js +8 -7
  44. package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js.map +1 -1
  45. package/features/CleanupTaskSubtree/abstractions.js +2 -1
  46. package/features/CleanupTaskSubtree/abstractions.js.map +1 -1
  47. package/features/CleanupTaskSubtree/index.js +0 -2
  48. package/features/GetTask/GetTaskUseCase.js +8 -7
  49. package/features/GetTask/GetTaskUseCase.js.map +1 -1
  50. package/features/GetTask/abstractions.js +2 -1
  51. package/features/GetTask/abstractions.js.map +1 -1
  52. package/features/GetTask/feature.js +6 -5
  53. package/features/GetTask/feature.js.map +1 -1
  54. package/features/GetTask/index.js +0 -2
  55. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +18 -16
  56. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js.map +1 -1
  57. package/features/GetTaskDefinition/abstractions.js +2 -1
  58. package/features/GetTaskDefinition/abstractions.js.map +1 -1
  59. package/features/GetTaskDefinition/feature.js +6 -5
  60. package/features/GetTaskDefinition/feature.js.map +1 -1
  61. package/features/GetTaskDefinition/index.js +0 -2
  62. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js +18 -12
  63. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js.map +1 -1
  64. package/features/ListTaskDefinitions/abstractions.js +2 -1
  65. package/features/ListTaskDefinitions/abstractions.js.map +1 -1
  66. package/features/ListTaskDefinitions/feature.js +6 -5
  67. package/features/ListTaskDefinitions/feature.js.map +1 -1
  68. package/features/ListTaskDefinitions/index.js +0 -2
  69. package/features/ListTasks/ListTasksUseCase.js +8 -7
  70. package/features/ListTasks/ListTasksUseCase.js.map +1 -1
  71. package/features/ListTasks/abstractions.js +2 -1
  72. package/features/ListTasks/abstractions.js.map +1 -1
  73. package/features/ListTasks/feature.js +6 -5
  74. package/features/ListTasks/feature.js.map +1 -1
  75. package/features/ListTasks/index.js +0 -2
  76. package/features/TaskController/TaskController.js +60 -60
  77. package/features/TaskController/TaskController.js.map +1 -1
  78. package/features/TaskController/augmentation.js +0 -3
  79. package/features/TaskController/index.js +0 -5
  80. package/features/TaskExecutionContext/TaskExecutionContext.js +38 -45
  81. package/features/TaskExecutionContext/TaskExecutionContext.js.map +1 -1
  82. package/features/TaskExecutionContext/abstractions.js +2 -10
  83. package/features/TaskExecutionContext/abstractions.js.map +1 -1
  84. package/features/TaskExecutionContext/feature.js +6 -5
  85. package/features/TaskExecutionContext/feature.js.map +1 -1
  86. package/features/TaskExecutionContext/index.js +0 -2
  87. package/features/TriggerTask/TriggerTaskUseCase.js +9 -8
  88. package/features/TriggerTask/TriggerTaskUseCase.js.map +1 -1
  89. package/features/TriggerTask/abstractions.js +2 -1
  90. package/features/TriggerTask/abstractions.js.map +1 -1
  91. package/features/TriggerTask/feature.js +6 -5
  92. package/features/TriggerTask/feature.js.map +1 -1
  93. package/features/TriggerTask/index.js +0 -2
  94. package/global.js +0 -2
  95. package/graphql/checkPermissions.js +16 -35
  96. package/graphql/checkPermissions.js.map +1 -1
  97. package/graphql/index.js +154 -187
  98. package/graphql/index.js.map +1 -1
  99. package/graphql/utils.js +15 -14
  100. package/graphql/utils.js.map +1 -1
  101. package/handler/index.js +46 -53
  102. package/handler/index.js.map +1 -1
  103. package/handler/register.js +7 -15
  104. package/handler/register.js.map +1 -1
  105. package/handler/types.js +0 -3
  106. package/index.js +2 -4
  107. package/package.json +17 -17
  108. package/plugins/TaskServicePlugin.js +9 -6
  109. package/plugins/TaskServicePlugin.js.map +1 -1
  110. package/plugins/index.js +0 -2
  111. package/response/DatabaseResponse.js +113 -132
  112. package/response/DatabaseResponse.js.map +1 -1
  113. package/response/Response.js +78 -96
  114. package/response/Response.js.map +1 -1
  115. package/response/ResponseAbortedResult.js +8 -7
  116. package/response/ResponseAbortedResult.js.map +1 -1
  117. package/response/ResponseContinueResult.js +12 -14
  118. package/response/ResponseContinueResult.js.map +1 -1
  119. package/response/ResponseDoneResult.js +10 -9
  120. package/response/ResponseDoneResult.js.map +1 -1
  121. package/response/ResponseErrorResult.js +9 -8
  122. package/response/ResponseErrorResult.js.map +1 -1
  123. package/response/TaskResponse.js +44 -64
  124. package/response/TaskResponse.js.map +1 -1
  125. package/response/abstractions/Response.js +0 -3
  126. package/response/abstractions/ResponseAbortedResult.js +0 -3
  127. package/response/abstractions/ResponseBaseResult.js +0 -3
  128. package/response/abstractions/ResponseContinueResult.js +0 -3
  129. package/response/abstractions/ResponseDoneResult.js +0 -3
  130. package/response/abstractions/ResponseErrorResult.js +0 -3
  131. package/response/abstractions/TaskResponse.js +0 -3
  132. package/response/abstractions/index.js +0 -2
  133. package/response/index.js +0 -2
  134. package/runner/TaskControl.js +150 -221
  135. package/runner/TaskControl.js.map +1 -1
  136. package/runner/TaskEventValidation.js +12 -13
  137. package/runner/TaskEventValidation.js.map +1 -1
  138. package/runner/TaskManager.js +68 -106
  139. package/runner/TaskManager.js.map +1 -1
  140. package/runner/TaskManagerStore.js +90 -139
  141. package/runner/TaskManagerStore.js.map +1 -1
  142. package/runner/TaskRunner.js +45 -65
  143. package/runner/TaskRunner.js.map +1 -1
  144. package/runner/abstractions/TaskControl.js +0 -3
  145. package/runner/abstractions/TaskEventValidation.js +0 -3
  146. package/runner/abstractions/TaskManager.js +0 -3
  147. package/runner/abstractions/TaskManagerStore.js +0 -3
  148. package/runner/abstractions/TaskRunner.js +0 -3
  149. package/runner/abstractions/index.js +0 -2
  150. package/runner/index.js +0 -2
  151. package/service/EventBridgeEventTransportPlugin.js +43 -42
  152. package/service/EventBridgeEventTransportPlugin.js.map +1 -1
  153. package/service/StepFunctionServicePlugin.js +65 -66
  154. package/service/StepFunctionServicePlugin.js.map +1 -1
  155. package/service/createService.js +10 -13
  156. package/service/createService.js.map +1 -1
  157. package/service/index.js +7 -5
  158. package/service/index.js.map +1 -1
  159. package/tasks/testingRunTask.js +11 -10
  160. package/tasks/testingRunTask.js.map +1 -1
  161. package/types.js +12 -12
  162. package/types.js.map +1 -1
  163. package/utils/ObjectUpdater.js +25 -31
  164. package/utils/ObjectUpdater.js.map +1 -1
  165. package/utils/getErrorProperties.js +5 -4
  166. package/utils/getErrorProperties.js.map +1 -1
  167. package/utils/getObjectProperties.js +8 -15
  168. package/utils/getObjectProperties.js.map +1 -1
  169. package/utils/index.js +0 -2
  170. package/utils/normalizeSelfCleanup.js +13 -12
  171. package/utils/normalizeSelfCleanup.js.map +1 -1
  172. package/events/index.js.map +0 -1
  173. package/features/AbortTask/index.js.map +0 -1
  174. package/features/CleanupTaskSubtree/index.js.map +0 -1
  175. package/features/GetTask/index.js.map +0 -1
  176. package/features/GetTaskDefinition/index.js.map +0 -1
  177. package/features/ListTaskDefinitions/index.js.map +0 -1
  178. package/features/ListTasks/index.js.map +0 -1
  179. package/features/TaskController/augmentation.js.map +0 -1
  180. package/features/TaskController/index.js.map +0 -1
  181. package/features/TaskExecutionContext/index.js.map +0 -1
  182. package/features/TriggerTask/index.js.map +0 -1
  183. package/global.js.map +0 -1
  184. package/handler/types.js.map +0 -1
  185. package/index.js.map +0 -1
  186. package/plugins/index.js.map +0 -1
  187. package/response/abstractions/Response.js.map +0 -1
  188. package/response/abstractions/ResponseAbortedResult.js.map +0 -1
  189. package/response/abstractions/ResponseBaseResult.js.map +0 -1
  190. package/response/abstractions/ResponseContinueResult.js.map +0 -1
  191. package/response/abstractions/ResponseDoneResult.js.map +0 -1
  192. package/response/abstractions/ResponseErrorResult.js.map +0 -1
  193. package/response/abstractions/TaskResponse.js.map +0 -1
  194. package/response/abstractions/index.js.map +0 -1
  195. package/response/index.js.map +0 -1
  196. package/runner/abstractions/TaskControl.js.map +0 -1
  197. package/runner/abstractions/TaskEventValidation.js.map +0 -1
  198. package/runner/abstractions/TaskManager.js.map +0 -1
  199. package/runner/abstractions/TaskManagerStore.js.map +0 -1
  200. package/runner/abstractions/TaskRunner.js.map +0 -1
  201. package/runner/abstractions/index.js.map +0 -1
  202. package/runner/index.js.map +0 -1
  203. package/utils/index.js.map +0 -1
@@ -1,75 +1,55 @@
1
1
  import { Response, ResponseErrorResult } from "../response/index.js";
2
2
  import { TaskControl } from "./TaskControl.js";
3
3
  import { getErrorProperties } from "../utils/getErrorProperties.js";
4
- const transformMinutesIntoMilliseconds = minutes => {
5
- return minutes * 60000;
6
- };
4
+ const transformMinutesIntoMilliseconds = (minutes)=>60000 * minutes;
7
5
  const DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES = 3;
8
- export class TaskRunner {
9
- /**
10
- * When DI is introduced, these will get injected.
11
- *
12
- * container.bind<Request>("Request").toConstantValue(request);
13
- * @inject("Request") public readonly request: Request;
14
- *
15
- * Follow the same example for the rest of the properties.
16
- */
17
-
18
- /**
19
- * We take all required variables separately because they will get injected via DI - so less refactoring is required in the future.
20
- */
21
- constructor(context, timer, validation) {
22
- this.context = context;
23
- this.timer = timer;
24
- this.validation = validation;
25
- }
26
- isCloseToTimeout(seconds) {
27
- const milliseconds = seconds ? seconds * 1000 : this.getIsCloseToTimeoutMilliseconds();
28
- return this.timer.getRemainingMilliseconds() < milliseconds;
29
- }
30
- async run(rawEvent) {
31
- const response = new Response({
32
- ...rawEvent
33
- });
34
- let event;
35
- try {
36
- event = this.validation.validate(rawEvent);
37
- } catch (ex) {
38
- return response.error({
39
- error: getErrorProperties(ex)
40
- });
6
+ class TaskRunner {
7
+ constructor(context, timer, validation){
8
+ this.context = context;
9
+ this.timer = timer;
10
+ this.validation = validation;
11
+ }
12
+ isCloseToTimeout(seconds) {
13
+ const milliseconds = seconds ? 1000 * seconds : this.getIsCloseToTimeoutMilliseconds();
14
+ return this.timer.getRemainingMilliseconds() < milliseconds;
41
15
  }
42
- response.setEvent(event);
43
- /**
44
- * If we received a delay when initiating the task, we need to send the continue response immediately.
45
- */
46
- if (rawEvent.delay && rawEvent.delay > 0) {
47
- return response.continue({
48
- input: {},
49
- wait: rawEvent.delay
50
- });
16
+ async run(rawEvent) {
17
+ const response = new Response({
18
+ ...rawEvent
19
+ });
20
+ let event;
21
+ try {
22
+ event = this.validation.validate(rawEvent);
23
+ } catch (ex) {
24
+ return response.error({
25
+ error: getErrorProperties(ex)
26
+ });
27
+ }
28
+ response.setEvent(event);
29
+ if (rawEvent.delay && rawEvent.delay > 0) return response.continue({
30
+ input: {},
31
+ wait: rawEvent.delay
32
+ });
33
+ const control = new TaskControl(this, response, this.context);
34
+ try {
35
+ const result = await control.run(event);
36
+ if (result instanceof ResponseErrorResult === false) return result;
37
+ console.error(result);
38
+ return result;
39
+ } catch (ex) {
40
+ console.error(`Failed to execute task "${event.webinyTaskId}".`);
41
+ console.error(ex);
42
+ return response.error({
43
+ error: getErrorProperties(ex)
44
+ });
45
+ }
51
46
  }
52
- const control = new TaskControl(this, response, this.context);
53
- try {
54
- const result = await control.run(event);
55
- if (result instanceof ResponseErrorResult === false) {
56
- return result;
57
- }
58
- console.error(result);
59
- return result;
60
- } catch (ex) {
61
- console.error(`Failed to execute task "${event.webinyTaskId}".`);
62
- console.error(ex);
63
- return response.error({
64
- error: getErrorProperties(ex)
65
- });
47
+ getIsCloseToTimeoutMilliseconds() {
48
+ const value = parseInt(process.env["WEBINY_TASKS_TIMEOUT_CLOSE_MINUTES"] || "");
49
+ const result = value > 0 ? value : DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES;
50
+ return transformMinutesIntoMilliseconds(result);
66
51
  }
67
- }
68
- getIsCloseToTimeoutMilliseconds() {
69
- const value = parseInt(process.env["WEBINY_TASKS_TIMEOUT_CLOSE_MINUTES"] || "");
70
- const result = value > 0 ? value : DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES;
71
- return transformMinutesIntoMilliseconds(result);
72
- }
73
52
  }
53
+ export { TaskRunner };
74
54
 
75
55
  //# sourceMappingURL=TaskRunner.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Response","ResponseErrorResult","TaskControl","getErrorProperties","transformMinutesIntoMilliseconds","minutes","DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES","TaskRunner","constructor","context","timer","validation","isCloseToTimeout","seconds","milliseconds","getIsCloseToTimeoutMilliseconds","getRemainingMilliseconds","run","rawEvent","response","event","validate","ex","error","setEvent","delay","continue","input","wait","control","result","console","webinyTaskId","value","parseInt","process","env"],"sources":["TaskRunner.ts"],"sourcesContent":["import type { ITaskEvent, ITaskRawEvent } from \"~/handler/types.js\";\nimport type { ITaskEventValidation, ITaskRunner } from \"./abstractions/index.js\";\nimport type { Context } from \"~/types.js\";\nimport { Response, ResponseErrorResult } from \"~/response/index.js\";\nimport { TaskControl } from \"./TaskControl.js\";\nimport type { IResponseResult } from \"~/response/abstractions/index.js\";\nimport { getErrorProperties } from \"~/utils/getErrorProperties.js\";\nimport type { ITimer } from \"@webiny/handler-aws/utils/index.js\";\n\nconst transformMinutesIntoMilliseconds = (minutes: number) => {\n return minutes * 60000;\n};\n\nconst DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES = 3;\n\nexport class TaskRunner<C extends Context = Context> implements ITaskRunner<C> {\n /**\n * When DI is introduced, these will get injected.\n *\n * container.bind<Request>(\"Request\").toConstantValue(request);\n * @inject(\"Request\") public readonly request: Request;\n *\n * Follow the same example for the rest of the properties.\n */\n public readonly context: C;\n public readonly timer: ITimer;\n private readonly validation: ITaskEventValidation;\n\n /**\n * We take all required variables separately because they will get injected via DI - so less refactoring is required in the future.\n */\n public constructor(context: C, timer: ITimer, validation: ITaskEventValidation) {\n this.context = context;\n this.timer = timer;\n this.validation = validation;\n }\n\n public isCloseToTimeout(seconds?: number) {\n const milliseconds = seconds ? seconds * 1000 : this.getIsCloseToTimeoutMilliseconds();\n return this.timer.getRemainingMilliseconds() < milliseconds;\n }\n\n public async run(rawEvent: ITaskRawEvent): Promise<IResponseResult> {\n const response = new Response({\n ...rawEvent\n });\n\n let event: ITaskEvent;\n try {\n event = this.validation.validate(rawEvent);\n } catch (ex) {\n return response.error({\n error: getErrorProperties(ex)\n });\n }\n response.setEvent(event);\n /**\n * If we received a delay when initiating the task, we need to send the continue response immediately.\n */\n if (rawEvent.delay && rawEvent.delay > 0) {\n return response.continue({\n input: {},\n wait: rawEvent.delay\n });\n }\n\n const control = new TaskControl(this, response, this.context);\n\n try {\n const result = await control.run(event);\n if (result instanceof ResponseErrorResult === false) {\n return result;\n }\n console.error(result);\n return result;\n } catch (ex) {\n console.error(`Failed to execute task \"${event.webinyTaskId}\".`);\n console.error(ex);\n return response.error({\n error: getErrorProperties(ex)\n });\n }\n }\n\n private getIsCloseToTimeoutMilliseconds() {\n const value = parseInt(process.env[\"WEBINY_TASKS_TIMEOUT_CLOSE_MINUTES\"] || \"\");\n const result = value > 0 ? value : DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES;\n return transformMinutesIntoMilliseconds(result);\n }\n}\n"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,mBAAmB;AACtC,SAASC,WAAW;AAEpB,SAASC,kBAAkB;AAG3B,MAAMC,gCAAgC,GAAIC,OAAe,IAAK;EAC1D,OAAOA,OAAO,GAAG,KAAK;AAC1B,CAAC;AAED,MAAMC,mCAAmC,GAAG,CAAC;AAE7C,OAAO,MAAMC,UAAU,CAAwD;EAC3E;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;EAKI;AACJ;AACA;EACWC,WAAWA,CAACC,OAAU,EAAEC,KAAa,EAAEC,UAAgC,EAAE;IAC5E,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,UAAU,GAAGA,UAAU;EAChC;EAEOC,gBAAgBA,CAACC,OAAgB,EAAE;IACtC,MAAMC,YAAY,GAAGD,OAAO,GAAGA,OAAO,GAAG,IAAI,GAAG,IAAI,CAACE,+BAA+B,C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KAAK,EAAEpB,kBAAkB,CAACmB,EAAE;MAChC,CAAC,CAAC;IACN;EACJ;EAEQP,+BAA+BA,CAAA,EAAG;IACtC,MAAMkB,KAAK,GAAGC,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,oCAAoC,CAAC,IAAI,EAAE,CAAC;IAC/E,MAAMN,MAAM,GAAGG,KAAK,GAAG,CAAC,GAAGA,KAAK,GAAG3B,mCAAmC;IACtE,OAAOF,gCAAgC,CAAC0B,MAAM,CAAC;EACnD;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"runner/TaskRunner.js","sources":["../../src/runner/TaskRunner.ts"],"sourcesContent":["import type { ITaskEvent, ITaskRawEvent } from \"~/handler/types.js\";\nimport type { ITaskEventValidation, ITaskRunner } from \"./abstractions/index.js\";\nimport type { Context } from \"~/types.js\";\nimport { Response, ResponseErrorResult } from \"~/response/index.js\";\nimport { TaskControl } from \"./TaskControl.js\";\nimport type { IResponseResult } from \"~/response/abstractions/index.js\";\nimport { getErrorProperties } from \"~/utils/getErrorProperties.js\";\nimport type { ITimer } from \"@webiny/handler-aws/utils/index.js\";\n\nconst transformMinutesIntoMilliseconds = (minutes: number) => {\n return minutes * 60000;\n};\n\nconst DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES = 3;\n\nexport class TaskRunner<C extends Context = Context> implements ITaskRunner<C> {\n /**\n * When DI is introduced, these will get injected.\n *\n * container.bind<Request>(\"Request\").toConstantValue(request);\n * @inject(\"Request\") public readonly request: Request;\n *\n * Follow the same example for the rest of the properties.\n */\n public readonly context: C;\n public readonly timer: ITimer;\n private readonly validation: ITaskEventValidation;\n\n /**\n * We take all required variables separately because they will get injected via DI - so less refactoring is required in the future.\n */\n public constructor(context: C, timer: ITimer, validation: ITaskEventValidation) {\n this.context = context;\n this.timer = timer;\n this.validation = validation;\n }\n\n public isCloseToTimeout(seconds?: number) {\n const milliseconds = seconds ? seconds * 1000 : this.getIsCloseToTimeoutMilliseconds();\n return this.timer.getRemainingMilliseconds() < milliseconds;\n }\n\n public async run(rawEvent: ITaskRawEvent): Promise<IResponseResult> {\n const response = new Response({\n ...rawEvent\n });\n\n let event: ITaskEvent;\n try {\n event = this.validation.validate(rawEvent);\n } catch (ex) {\n return response.error({\n error: getErrorProperties(ex)\n });\n }\n response.setEvent(event);\n /**\n * If we received a delay when initiating the task, we need to send the continue response immediately.\n */\n if (rawEvent.delay && rawEvent.delay > 0) {\n return response.continue({\n input: {},\n wait: rawEvent.delay\n });\n }\n\n const control = new TaskControl(this, response, this.context);\n\n try {\n const result = await control.run(event);\n if (result instanceof ResponseErrorResult === false) {\n return result;\n }\n console.error(result);\n return result;\n } catch (ex) {\n console.error(`Failed to execute task \"${event.webinyTaskId}\".`);\n console.error(ex);\n return response.error({\n error: getErrorProperties(ex)\n });\n }\n }\n\n private getIsCloseToTimeoutMilliseconds() {\n const value = parseInt(process.env[\"WEBINY_TASKS_TIMEOUT_CLOSE_MINUTES\"] || \"\");\n const result = value > 0 ? value : DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES;\n return transformMinutesIntoMilliseconds(result);\n }\n}\n"],"names":["transformMinutesIntoMilliseconds","minutes","DEFAULT_TASKS_TIMEOUT_CLOSE_MINUTES","TaskRunner","context","timer","validation","seconds","milliseconds","rawEvent","response","Response","event","ex","getErrorProperties","control","TaskControl","result","ResponseErrorResult","console","value","parseInt","process"],"mappings":";;;AASA,MAAMA,mCAAmC,CAACC,UAC/BA,AAAU,QAAVA;AAGX,MAAMC,sCAAsC;AAErC,MAAMC;IAgBT,YAAmBC,OAAU,EAAEC,KAAa,EAAEC,UAAgC,CAAE;QAC5E,IAAI,CAAC,OAAO,GAAGF;QACf,IAAI,CAAC,KAAK,GAAGC;QACb,IAAI,CAAC,UAAU,GAAGC;IACtB;IAEO,iBAAiBC,OAAgB,EAAE;QACtC,MAAMC,eAAeD,UAAUA,AAAU,OAAVA,UAAiB,IAAI,CAAC,+BAA+B;QACpF,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,KAAKC;IACnD;IAEA,MAAa,IAAIC,QAAuB,EAA4B;QAChE,MAAMC,WAAW,IAAIC,SAAS;YAC1B,GAAGF,QAAQ;QACf;QAEA,IAAIG;QACJ,IAAI;YACAA,QAAQ,IAAI,CAAC,UAAU,CAAC,QAAQ,CAACH;QACrC,EAAE,OAAOI,IAAI;YACT,OAAOH,SAAS,KAAK,CAAC;gBAClB,OAAOI,mBAAmBD;YAC9B;QACJ;QACAH,SAAS,QAAQ,CAACE;QAIlB,IAAIH,SAAS,KAAK,IAAIA,SAAS,KAAK,GAAG,GACnC,OAAOC,SAAS,QAAQ,CAAC;YACrB,OAAO,CAAC;YACR,MAAMD,SAAS,KAAK;QACxB;QAGJ,MAAMM,UAAU,IAAIC,YAAY,IAAI,EAAEN,UAAU,IAAI,CAAC,OAAO;QAE5D,IAAI;YACA,MAAMO,SAAS,MAAMF,QAAQ,GAAG,CAACH;YACjC,IAAIK,kBAAkBC,wBAAwB,OAC1C,OAAOD;YAEXE,QAAQ,KAAK,CAACF;YACd,OAAOA;QACX,EAAE,OAAOJ,IAAI;YACTM,QAAQ,KAAK,CAAC,CAAC,wBAAwB,EAAEP,MAAM,YAAY,CAAC,EAAE,CAAC;YAC/DO,QAAQ,KAAK,CAACN;YACd,OAAOH,SAAS,KAAK,CAAC;gBAClB,OAAOI,mBAAmBD;YAC9B;QACJ;IACJ;IAEQ,kCAAkC;QACtC,MAAMO,QAAQC,SAASC,QAAQ,GAAG,CAAC,qCAAqC,IAAI;QAC5E,MAAML,SAASG,QAAQ,IAAIA,QAAQlB;QACnC,OAAOF,iCAAiCiB;IAC5C;AACJ"}
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=TaskControl.js.map
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=TaskEventValidation.js.map
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=TaskManager.js.map
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=TaskManagerStore.js.map
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=TaskRunner.js.map
@@ -3,5 +3,3 @@ export * from "./TaskEventValidation.js";
3
3
  export * from "./TaskManager.js";
4
4
  export * from "./TaskRunner.js";
5
5
  export * from "./TaskManagerStore.js";
6
-
7
- //# sourceMappingURL=index.js.map
package/runner/index.js CHANGED
@@ -1,3 +1 @@
1
1
  export * from "./TaskRunner.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -2,50 +2,51 @@ import { TaskServicePlugin } from "../plugins/index.js";
2
2
  import { EventBridgeClient, PutEventsCommand } from "@webiny/aws-sdk/client-eventbridge/index.js";
3
3
  import { WebinyError } from "@webiny/error";
4
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
- });
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
+ const event = {
13
+ webinyTaskId: task.id,
14
+ webinyTaskDefinitionId: task.definitionId,
15
+ tenant: this.getTenant(),
16
+ delay
17
+ };
18
+ const cmd = new PutEventsCommand({
19
+ Entries: [
20
+ {
21
+ Source: "webiny-api-tasks",
22
+ EventBusName: String(process.env.EVENT_BUS),
23
+ DetailType: "WebinyBackgroundTask",
24
+ Detail: JSON.stringify(event)
25
+ }
26
+ ]
27
+ });
28
+ try {
29
+ const result = await this.client.send(cmd);
30
+ return JSON.parse(JSON.stringify(result));
31
+ } catch (ex) {
32
+ throw new WebinyError(ex.message || "Could not trigger task via Event Bridge!", ex.code || "TRIGGER_TASK_ERROR", {
33
+ event,
34
+ ...ex.data || {}
35
+ });
36
+ }
37
+ }
38
+ async fetch() {
39
+ throw new WebinyError("Not implemented!", "NOT_IMPLEMENTED");
38
40
  }
39
- }
40
- async fetch() {
41
- throw new WebinyError("Not implemented!", "NOT_IMPLEMENTED");
42
- }
43
41
  }
44
- export class EventBridgeEventTransportPlugin extends TaskServicePlugin {
45
- name = "task.eventBridgeEventTransport";
46
- createService(params) {
47
- return new EventBridgeService(params);
48
- }
42
+ class EventBridgeEventTransportPlugin extends TaskServicePlugin {
43
+ createService(params) {
44
+ return new EventBridgeService(params);
45
+ }
46
+ constructor(...args){
47
+ super(...args), this.name = "task.eventBridgeEventTransport";
48
+ }
49
49
  }
50
+ export { EventBridgeEventTransportPlugin };
50
51
 
51
52
  //# sourceMappingURL=EventBridgeEventTransportPlugin.js.map
@@ -1 +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,SAAS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B;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":[]}
1
+ {"version":3,"file":"service/EventBridgeEventTransportPlugin.js","sources":["../../src/service/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"],"names":["EventBridgeService","params","EventBridgeClient","process","task","delay","event","cmd","PutEventsCommand","String","JSON","result","ex","WebinyError","EventBridgeEventTransportPlugin","TaskServicePlugin"],"mappings":";;;AAYA,MAAMA;IAIF,YAAmBC,MAAsC,CAAE;QACvD,IAAI,CAAC,MAAM,GAAG,IAAIC,kBAAkB;YAChC,QAAQC,QAAQ,GAAG,CAAC,UAAU;QAClC;QACA,IAAI,CAAC,SAAS,GAAGF,OAAO,SAAS;IACrC;IAEA,MAAa,KAAKG,IAAsB,EAAEC,KAAa,EAAmC;QAKtF,MAAMC,QAAyB;YAC3B,cAAcF,KAAK,EAAE;YACrB,wBAAwBA,KAAK,YAAY;YACzC,QAAQ,IAAI,CAAC,SAAS;YACtBC;QACJ;QAEA,MAAME,MAAM,IAAIC,iBAAiB;YAC7B,SAAS;gBACL;oBACI,QAAQ;oBACR,cAAcC,OAAON,QAAQ,GAAG,CAAC,SAAS;oBAC1C,YAAY;oBACZ,QAAQO,KAAK,SAAS,CAACJ;gBAC3B;aACH;QACL;QACA,IAAI;YACA,MAAMK,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAACJ;YAEtC,OAAOG,KAAK,KAAK,CAACA,KAAK,SAAS,CAACC;QACrC,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIC,YACND,GAAG,OAAO,IAAI,4CACdA,GAAG,IAAI,IAAI,sBACX;gBACIN;gBACA,GAAIM,GAAG,IAAI,IAAI,CAAC,CAAC;YACrB;QAER;IACJ;IAEA,MAAa,QAAgC;QACzC,MAAM,IAAIC,YAAY,oBAAoB;IAC9C;AACJ;AAEO,MAAMC,wCAAwCC;IAE1C,cAAcd,MAAsC,EAAE;QACzD,OAAO,IAAID,mBAAmBC;IAClC;;QAJG,qBACa,IAAI,GAAG;;AAI3B"}
@@ -2,77 +2,76 @@ import { TaskServicePlugin } from "../plugins/index.js";
2
2
  import { createStepFunctionClient, describeExecutionFactory, triggerStepFunctionFactory } from "@webiny/aws-sdk/client-sfn/index.js";
3
3
  import { generateAlphaNumericId } from "@webiny/utils";
4
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;
5
+ class StepFunctionService {
6
+ constructor(params){
7
+ this.getTenant = params.getTenant;
8
+ const client = createStepFunctionClient();
9
+ this.trigger = triggerStepFunctionFactory(client);
10
+ this.get = describeExecutionFactory(client);
17
11
  }
18
- const {
19
- bgTaskSfn
20
- } = manifest.api || {};
21
- if (!bgTaskSfn) {
22
- console.error("Background task state machine not found.");
23
- return null;
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 { bgTaskSfn } = manifest.api || {};
19
+ if (!bgTaskSfn) {
20
+ console.error("Background task state machine not found.");
21
+ return null;
22
+ }
23
+ const input = {
24
+ webinyTaskId: task.id,
25
+ webinyTaskDefinitionId: task.definitionId,
26
+ tenant: this.getTenant(),
27
+ delay
28
+ };
29
+ const name = `${task.definitionId}_${task.id}_${generateAlphaNumericId(10)}`;
30
+ try {
31
+ const result = await this.trigger({
32
+ input: {
33
+ detail: input
34
+ },
35
+ stateMachineArn: bgTaskSfn,
36
+ name
37
+ });
38
+ return {
39
+ ...result,
40
+ name
41
+ };
42
+ } catch (ex) {
43
+ console.log("Could not trigger a step function.");
44
+ console.error(ex);
45
+ return null;
46
+ }
24
47
  }
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
+ async fetch(task) {
49
+ const executionArn = task.eventResponse?.executionArn;
50
+ if (!executionArn) {
51
+ console.error(`Execution ARN not found in task "${task.id}".`);
52
+ return null;
53
+ }
54
+ try {
55
+ const result = await this.get({
56
+ executionArn
57
+ });
58
+ if (!result) return null;
59
+ return JSON.parse(JSON.stringify(result));
60
+ } catch (ex) {
61
+ console.log("Could not get the execution details.");
62
+ console.error(ex);
63
+ return null;
64
+ }
48
65
  }
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;
66
+ }
67
+ class StepFunctionServicePlugin extends TaskServicePlugin {
68
+ createService(params) {
69
+ return new StepFunctionService(params);
55
70
  }
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;
71
+ constructor(...args){
72
+ super(...args), this.name = "task.stepFunctionTriggerTransport";
68
73
  }
69
- }
70
- }
71
- export class StepFunctionServicePlugin extends TaskServicePlugin {
72
- name = "task.stepFunctionTriggerTransport";
73
- createService(params) {
74
- return new StepFunctionService(params);
75
- }
76
74
  }
75
+ export { StepFunctionService, StepFunctionServicePlugin };
77
76
 
78
77
  //# sourceMappingURL=StepFunctionServicePlugin.js.map
@@ -1 +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,I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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":[]}
1
+ {"version":3,"file":"service/StepFunctionServicePlugin.js","sources":["../../src/service/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"],"names":["StepFunctionService","params","client","createStepFunctionClient","triggerStepFunctionFactory","describeExecutionFactory","task","delay","manifest","ServiceDiscovery","console","bgTaskSfn","input","name","generateAlphaNumericId","result","ex","executionArn","JSON","StepFunctionServicePlugin","TaskServicePlugin"],"mappings":";;;;AAuBO,MAAMA;IAKT,YAAmBC,MAAsC,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KAAK,KAAK,CAACA,KAAK,SAAS,CAACH;QACrC,EAAE,OAAOC,IAAI;YACTN,QAAQ,GAAG,CAAC;YACZA,QAAQ,KAAK,CAACM;YACd,OAAO;QACX;IACJ;AACJ;AAEO,MAAMG,kCAAkCC;IAGpC,cAAcnB,MAAsC,EAAE;QACzD,OAAO,IAAID,oBAAoBC;IACnC;;QALG,qBACa,IAAI,GAAG;;AAK3B"}
@@ -1,19 +1,16 @@
1
1
  import { TaskServicePlugin } from "../plugins/index.js";
2
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
3
+ 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) throw new WebinyError("Missing TaskServicePlugin.", "PLUGIN_ERROR", {
7
+ type: TaskServicePlugin.type
8
+ });
9
+ const getTenant = ()=>params.context.tenancy.getCurrentTenant().id;
10
+ return plugin.createService({
11
+ getTenant
9
12
  });
10
- }
11
- const getTenant = () => {
12
- return params.context.tenancy.getCurrentTenant().id;
13
- };
14
- return plugin.createService({
15
- getTenant
16
- });
17
13
  };
14
+ export { createService };
18
15
 
19
16
  //# sourceMappingURL=createService.js.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"service/createService.js","sources":["../../src/service/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"],"names":["createService","params","plugins","TaskServicePlugin","plugin","WebinyError","getTenant"],"mappings":";;AASO,MAAMA,gBAAgB,CAACC;IAC1B,MAAMC,UAAUD,OAAO,OAAO,CAAC,OAAO,CACjC,MAAM,CAAoBE,kBAAkB,IAAI,EAChD,OAAO;IAEZ,MAAMC,SAASF,QAAQ,IAAI,CAACE,CAAAA,SAAUA,OAAO,OAAO,KAAKF,OAAO,CAAC,EAAE;IACnE,IAAI,CAACE,QACD,MAAM,IAAIC,YAAY,8BAA8B,gBAAgB;QAChE,MAAMF,kBAAkB,IAAI;IAChC;IAGJ,MAAMG,YAAY,IACPL,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,GAAG,EAAE;IAGvD,OAAOG,OAAO,aAAa,CAAC;QACxBE;IACJ;AACJ"}
package/service/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { EventBridgeEventTransportPlugin } from "./EventBridgeEventTransportPlugin.js";
2
2
  import { StepFunctionServicePlugin } from "./StepFunctionServicePlugin.js";
3
- export const createServicePlugins = () => {
4
- return [new StepFunctionServicePlugin({
5
- default: true
6
- }), new EventBridgeEventTransportPlugin()];
7
- };
8
3
  export * from "./createService.js";
4
+ const createServicePlugins = ()=>[
5
+ new StepFunctionServicePlugin({
6
+ default: true
7
+ }),
8
+ new EventBridgeEventTransportPlugin()
9
+ ];
10
+ export { createServicePlugins };
9
11
 
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +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
+ {"version":3,"file":"service/index.js","sources":["../../src/service/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"],"names":["createServicePlugins","StepFunctionServicePlugin","EventBridgeEventTransportPlugin"],"mappings":";;;AAGO,MAAMA,uBAAuB,IACzB;QACH,IAAIC,0BAA0B;YAAE,SAAS;QAAK;QAC9C,IAAIC;KACP"}
@@ -1,16 +1,17 @@
1
1
  import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
2
  class TestingRunTask {
3
- id = "testingRun";
4
- title = "A mock task to test run the step function permissions.";
5
- async run({
6
- controller
7
- }) {
8
- return controller.response.done("Task successfully finished.");
9
- }
3
+ async run({ controller }) {
4
+ return controller.response.done("Task successfully finished.");
5
+ }
6
+ constructor(){
7
+ this.id = "testingRun";
8
+ this.title = "A mock task to test run the step function permissions.";
9
+ }
10
10
  }
11
- export const TestingRunTaskDefinition = TaskDefinition.createImplementation({
12
- implementation: TestingRunTask,
13
- dependencies: []
11
+ const TestingRunTaskDefinition = TaskDefinition.createImplementation({
12
+ implementation: TestingRunTask,
13
+ dependencies: []
14
14
  });
15
+ export { TestingRunTaskDefinition };
15
16
 
16
17
  //# sourceMappingURL=testingRunTask.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["TaskDefinition","TestingRunTask","id","title","run","controller","response","done","TestingRunTaskDefinition","createImplementation","implementation","dependencies"],"sources":["testingRunTask.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nclass TestingRunTask implements TaskDefinition.Interface {\n id = \"testingRun\";\n title = \"A mock task to test run the step function permissions.\";\n\n async run({ controller }: TaskDefinition.RunParams) {\n return controller.response.done(\"Task successfully finished.\");\n }\n}\n\nexport const TestingRunTaskDefinition = TaskDefinition.createImplementation({\n implementation: TestingRunTask,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,wDAAwD;AAEvF,MAAMC,cAAc,CAAqC;EACrDC,EAAE,GAAG,YAAY;EACjBC,KAAK,GAAG,wDAAwD;EAEhE,MAAMC,GAAGA,CAAC;IAAEC;EAAqC,CAAC,EAAE;IAChD,OAAOA,UAAU,CAACC,QAAQ,CAACC,IAAI,CAAC,6BAA6B,CAAC;EAClE;AACJ;AAEA,OAAO,MAAMC,wBAAwB,GAAGR,cAAc,CAACS,oBAAoB,CAAC;EACxEC,cAAc,EAAET,cAAc;EAC9BU,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"tasks/testingRunTask.js","sources":["../../src/tasks/testingRunTask.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nclass TestingRunTask implements TaskDefinition.Interface {\n id = \"testingRun\";\n title = \"A mock task to test run the step function permissions.\";\n\n async run({ controller }: TaskDefinition.RunParams) {\n return controller.response.done(\"Task successfully finished.\");\n }\n}\n\nexport const TestingRunTaskDefinition = TaskDefinition.createImplementation({\n implementation: TestingRunTask,\n dependencies: []\n});\n"],"names":["TestingRunTask","controller","TestingRunTaskDefinition","TaskDefinition"],"mappings":";AAEA,MAAMA;IAIF,MAAM,IAAI,EAAEC,UAAU,EAA4B,EAAE;QAChD,OAAOA,WAAW,QAAQ,CAAC,IAAI,CAAC;IACpC;;aALA,EAAE,GAAG;aACL,KAAK,GAAG;;AAKZ;AAEO,MAAMC,2BAA2BC,eAAe,oBAAoB,CAAC;IACxE,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}