@webiny/tasks 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.e6f0dc8ca7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/README.md +10 -9
  2. package/context.js +50 -21
  3. package/context.js.map +1 -1
  4. package/crud/TaskLogPrivateModel.d.ts +9 -0
  5. package/crud/TaskLogPrivateModel.js +34 -0
  6. package/crud/TaskLogPrivateModel.js.map +1 -0
  7. package/crud/TaskPrivateModel.d.ts +9 -0
  8. package/crud/TaskPrivateModel.js +46 -0
  9. package/crud/TaskPrivateModel.js.map +1 -0
  10. package/crud/cleanupTaskSubtree.d.ts +8 -0
  11. package/crud/cleanupTaskSubtree.js +76 -0
  12. package/crud/cleanupTaskSubtree.js.map +1 -0
  13. package/crud/crud.tasks.d.ts +1 -1
  14. package/crud/crud.tasks.js +213 -105
  15. package/crud/crud.tasks.js.map +1 -1
  16. package/crud/definition.tasks.d.ts +1 -1
  17. package/crud/definition.tasks.js +9 -18
  18. package/crud/definition.tasks.js.map +1 -1
  19. package/crud/service.tasks.d.ts +1 -1
  20. package/crud/service.tasks.js +31 -36
  21. package/crud/service.tasks.js.map +1 -1
  22. package/decorators/RunnableTaskDecorator.d.ts +32 -0
  23. package/decorators/RunnableTaskDecorator.js +85 -0
  24. package/decorators/RunnableTaskDecorator.js.map +1 -0
  25. package/decorators/SelfCleaningTaskDecorator.d.ts +30 -0
  26. package/decorators/SelfCleaningTaskDecorator.js +98 -0
  27. package/decorators/SelfCleaningTaskDecorator.js.map +1 -0
  28. package/domain/errors.d.ts +29 -0
  29. package/domain/errors.js +47 -0
  30. package/domain/errors.js.map +1 -0
  31. package/events/TaskAfterCreateEvent.d.ts +6 -0
  32. package/events/TaskAfterCreateEvent.js +10 -0
  33. package/events/TaskAfterCreateEvent.js.map +1 -0
  34. package/events/TaskAfterDeleteEvent.d.ts +6 -0
  35. package/events/TaskAfterDeleteEvent.js +10 -0
  36. package/events/TaskAfterDeleteEvent.js.map +1 -0
  37. package/events/TaskAfterUpdateEvent.d.ts +6 -0
  38. package/events/TaskAfterUpdateEvent.js +10 -0
  39. package/events/TaskAfterUpdateEvent.js.map +1 -0
  40. package/events/TaskBeforeCreateEvent.d.ts +6 -0
  41. package/events/TaskBeforeCreateEvent.js +10 -0
  42. package/events/TaskBeforeCreateEvent.js.map +1 -0
  43. package/events/TaskBeforeDeleteEvent.d.ts +6 -0
  44. package/events/TaskBeforeDeleteEvent.js +10 -0
  45. package/events/TaskBeforeDeleteEvent.js.map +1 -0
  46. package/events/TaskBeforeUpdateEvent.d.ts +6 -0
  47. package/events/TaskBeforeUpdateEvent.js +10 -0
  48. package/events/TaskBeforeUpdateEvent.js.map +1 -0
  49. package/events/abstractions.d.ts +53 -0
  50. package/events/abstractions.js +39 -0
  51. package/events/abstractions.js.map +1 -0
  52. package/events/index.d.ts +7 -0
  53. package/events/index.js +9 -0
  54. package/events/index.js.map +1 -0
  55. package/features/AbortTask/AbortTaskUseCase.d.ts +10 -0
  56. package/features/AbortTask/AbortTaskUseCase.js +11 -0
  57. package/features/AbortTask/AbortTaskUseCase.js.map +1 -0
  58. package/features/AbortTask/abstractions.d.ts +25 -0
  59. package/features/AbortTask/abstractions.js +4 -0
  60. package/features/AbortTask/abstractions.js.map +1 -0
  61. package/features/AbortTask/feature.d.ts +5 -0
  62. package/features/AbortTask/feature.js +11 -0
  63. package/features/AbortTask/feature.js.map +1 -0
  64. package/features/AbortTask/index.d.ts +2 -0
  65. package/features/AbortTask/index.js +4 -0
  66. package/features/AbortTask/index.js.map +1 -0
  67. package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.d.ts +7 -0
  68. package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js +10 -0
  69. package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js.map +1 -0
  70. package/features/CleanupTaskSubtree/abstractions.d.ts +7 -0
  71. package/features/CleanupTaskSubtree/abstractions.js +4 -0
  72. package/features/CleanupTaskSubtree/abstractions.js.map +1 -0
  73. package/features/CleanupTaskSubtree/index.d.ts +2 -0
  74. package/features/CleanupTaskSubtree/index.js +4 -0
  75. package/features/CleanupTaskSubtree/index.js.map +1 -0
  76. package/features/GetTask/GetTaskUseCase.d.ts +9 -0
  77. package/features/GetTask/GetTaskUseCase.js +10 -0
  78. package/features/GetTask/GetTaskUseCase.js.map +1 -0
  79. package/features/GetTask/abstractions.d.ts +10 -0
  80. package/features/GetTask/abstractions.js +4 -0
  81. package/features/GetTask/abstractions.js.map +1 -0
  82. package/features/GetTask/feature.d.ts +5 -0
  83. package/features/GetTask/feature.js +11 -0
  84. package/features/GetTask/feature.js.map +1 -0
  85. package/features/GetTask/index.d.ts +2 -0
  86. package/features/GetTask/index.js +4 -0
  87. package/features/GetTask/index.js.map +1 -0
  88. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.d.ts +12 -0
  89. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +25 -0
  90. package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js.map +1 -0
  91. package/features/GetTaskDefinition/abstractions.d.ts +17 -0
  92. package/features/GetTaskDefinition/abstractions.js +4 -0
  93. package/features/GetTaskDefinition/abstractions.js.map +1 -0
  94. package/features/GetTaskDefinition/feature.d.ts +4 -0
  95. package/features/GetTaskDefinition/feature.js +10 -0
  96. package/features/GetTaskDefinition/feature.js.map +1 -0
  97. package/features/GetTaskDefinition/index.d.ts +2 -0
  98. package/features/GetTaskDefinition/index.js +4 -0
  99. package/features/GetTaskDefinition/index.js.map +1 -0
  100. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.d.ts +11 -0
  101. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js +18 -0
  102. package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js.map +1 -0
  103. package/features/ListTaskDefinitions/abstractions.d.ts +9 -0
  104. package/features/ListTaskDefinitions/abstractions.js +4 -0
  105. package/features/ListTaskDefinitions/abstractions.js.map +1 -0
  106. package/features/ListTaskDefinitions/feature.d.ts +4 -0
  107. package/features/ListTaskDefinitions/feature.js +10 -0
  108. package/features/ListTaskDefinitions/feature.js.map +1 -0
  109. package/features/ListTaskDefinitions/index.d.ts +2 -0
  110. package/features/ListTaskDefinitions/index.js +4 -0
  111. package/features/ListTaskDefinitions/index.js.map +1 -0
  112. package/features/ListTasks/ListTasksUseCase.d.ts +9 -0
  113. package/features/ListTasks/ListTasksUseCase.js +10 -0
  114. package/features/ListTasks/ListTasksUseCase.js.map +1 -0
  115. package/features/ListTasks/abstractions.d.ts +13 -0
  116. package/features/ListTasks/abstractions.js +4 -0
  117. package/features/ListTasks/abstractions.js.map +1 -0
  118. package/features/ListTasks/feature.d.ts +5 -0
  119. package/features/ListTasks/feature.js +11 -0
  120. package/features/ListTasks/feature.js.map +1 -0
  121. package/features/ListTasks/index.d.ts +2 -0
  122. package/features/ListTasks/index.js +4 -0
  123. package/features/ListTasks/index.js.map +1 -0
  124. package/features/TaskController/TaskController.d.ts +49 -0
  125. package/features/TaskController/TaskController.js +71 -0
  126. package/features/TaskController/TaskController.js.map +1 -0
  127. package/features/TaskController/augmentation.d.ts +60 -0
  128. package/features/TaskController/augmentation.js +3 -0
  129. package/features/TaskController/augmentation.js.map +1 -0
  130. package/features/TaskController/index.d.ts +2 -0
  131. package/features/TaskController/index.js +7 -0
  132. package/features/TaskController/index.js.map +1 -0
  133. package/features/TaskExecutionContext/TaskExecutionContext.d.ts +24 -0
  134. package/features/TaskExecutionContext/TaskExecutionContext.js +50 -0
  135. package/features/TaskExecutionContext/TaskExecutionContext.js.map +1 -0
  136. package/features/TaskExecutionContext/abstractions.d.ts +26 -0
  137. package/features/TaskExecutionContext/abstractions.js +13 -0
  138. package/features/TaskExecutionContext/abstractions.js.map +1 -0
  139. package/features/TaskExecutionContext/feature.d.ts +4 -0
  140. package/features/TaskExecutionContext/feature.js +10 -0
  141. package/features/TaskExecutionContext/feature.js.map +1 -0
  142. package/features/TaskExecutionContext/index.d.ts +1 -0
  143. package/features/TaskExecutionContext/index.js +3 -0
  144. package/features/TaskExecutionContext/index.js.map +1 -0
  145. package/features/TriggerTask/TriggerTaskUseCase.d.ts +10 -0
  146. package/features/TriggerTask/TriggerTaskUseCase.js +11 -0
  147. package/features/TriggerTask/TriggerTaskUseCase.js.map +1 -0
  148. package/features/TriggerTask/abstractions.d.ts +28 -0
  149. package/features/TriggerTask/abstractions.js +4 -0
  150. package/features/TriggerTask/abstractions.js.map +1 -0
  151. package/features/TriggerTask/feature.d.ts +5 -0
  152. package/features/TriggerTask/feature.js +11 -0
  153. package/features/TriggerTask/feature.js.map +1 -0
  154. package/features/TriggerTask/index.d.ts +2 -0
  155. package/features/TriggerTask/index.js +4 -0
  156. package/features/TriggerTask/index.js.map +1 -0
  157. package/global.d.ts +1 -0
  158. package/global.js +3 -0
  159. package/global.js.map +1 -0
  160. package/graphql/checkPermissions.d.ts +1 -1
  161. package/graphql/checkPermissions.js +3 -9
  162. package/graphql/checkPermissions.js.map +1 -1
  163. package/graphql/index.d.ts +1 -1
  164. package/graphql/index.js +67 -83
  165. package/graphql/index.js.map +1 -1
  166. package/graphql/utils.d.ts +3 -3
  167. package/graphql/utils.js +8 -17
  168. package/graphql/utils.js.map +1 -1
  169. package/handler/index.d.ts +2 -2
  170. package/handler/index.js +33 -40
  171. package/handler/index.js.map +1 -1
  172. package/handler/register.js +5 -7
  173. package/handler/register.js.map +1 -1
  174. package/handler/types.d.ts +1 -3
  175. package/handler/types.js +1 -5
  176. package/handler/types.js.map +1 -1
  177. package/index.d.ts +5 -6
  178. package/index.js +5 -60
  179. package/index.js.map +1 -1
  180. package/package.json +27 -28
  181. package/plugins/TaskServicePlugin.d.ts +1 -2
  182. package/plugins/TaskServicePlugin.js +2 -9
  183. package/plugins/TaskServicePlugin.js.map +1 -1
  184. package/plugins/index.d.ts +1 -1
  185. package/plugins/index.js +1 -16
  186. package/plugins/index.js.map +1 -1
  187. package/response/DatabaseResponse.d.ts +3 -3
  188. package/response/DatabaseResponse.js +14 -20
  189. package/response/DatabaseResponse.js.map +1 -1
  190. package/response/Response.d.ts +4 -3
  191. package/response/Response.js +20 -31
  192. package/response/Response.js.map +1 -1
  193. package/response/ResponseAbortedResult.d.ts +3 -4
  194. package/response/ResponseAbortedResult.js +3 -11
  195. package/response/ResponseAbortedResult.js.map +1 -1
  196. package/response/ResponseContinueResult.d.ts +4 -5
  197. package/response/ResponseContinueResult.js +3 -11
  198. package/response/ResponseContinueResult.js.map +1 -1
  199. package/response/ResponseDoneResult.d.ts +4 -6
  200. package/response/ResponseDoneResult.js +3 -11
  201. package/response/ResponseDoneResult.js.map +1 -1
  202. package/response/ResponseErrorResult.d.ts +3 -4
  203. package/response/ResponseErrorResult.js +3 -11
  204. package/response/ResponseErrorResult.js.map +1 -1
  205. package/response/TaskResponse.d.ts +7 -6
  206. package/response/TaskResponse.js +5 -12
  207. package/response/TaskResponse.js.map +1 -1
  208. package/response/abstractions/Response.d.ts +7 -7
  209. package/response/abstractions/Response.js +1 -5
  210. package/response/abstractions/Response.js.map +1 -1
  211. package/response/abstractions/ResponseAbortedResult.d.ts +3 -3
  212. package/response/abstractions/ResponseAbortedResult.js +1 -5
  213. package/response/abstractions/ResponseAbortedResult.js.map +1 -1
  214. package/response/abstractions/ResponseBaseResult.d.ts +2 -3
  215. package/response/abstractions/ResponseBaseResult.js +1 -5
  216. package/response/abstractions/ResponseBaseResult.js.map +1 -1
  217. package/response/abstractions/ResponseContinueResult.d.ts +4 -4
  218. package/response/abstractions/ResponseContinueResult.js +1 -5
  219. package/response/abstractions/ResponseContinueResult.js.map +1 -1
  220. package/response/abstractions/ResponseDoneResult.d.ts +5 -6
  221. package/response/abstractions/ResponseDoneResult.js +1 -5
  222. package/response/abstractions/ResponseDoneResult.js.map +1 -1
  223. package/response/abstractions/ResponseErrorResult.d.ts +4 -5
  224. package/response/abstractions/ResponseErrorResult.js +1 -5
  225. package/response/abstractions/ResponseErrorResult.js.map +1 -1
  226. package/response/abstractions/TaskResponse.d.ts +8 -30
  227. package/response/abstractions/TaskResponse.js +1 -5
  228. package/response/abstractions/TaskResponse.js.map +1 -1
  229. package/response/abstractions/index.d.ts +7 -7
  230. package/response/abstractions/index.js +7 -82
  231. package/response/abstractions/index.js.map +1 -1
  232. package/response/index.d.ts +7 -7
  233. package/response/index.js +7 -82
  234. package/response/index.js.map +1 -1
  235. package/runner/TaskControl.d.ts +4 -4
  236. package/runner/TaskControl.js +61 -39
  237. package/runner/TaskControl.js.map +1 -1
  238. package/runner/TaskEventValidation.d.ts +2 -2
  239. package/runner/TaskEventValidation.js +11 -20
  240. package/runner/TaskEventValidation.js.map +1 -1
  241. package/runner/TaskManager.d.ts +7 -10
  242. package/runner/TaskManager.js +19 -39
  243. package/runner/TaskManager.js.map +1 -1
  244. package/runner/TaskManagerStore.d.ts +7 -7
  245. package/runner/TaskManagerStore.js +16 -25
  246. package/runner/TaskManagerStore.js.map +1 -1
  247. package/runner/TaskRunner.d.ts +5 -6
  248. package/runner/TaskRunner.js +9 -31
  249. package/runner/TaskRunner.js.map +1 -1
  250. package/runner/abstractions/TaskControl.d.ts +4 -4
  251. package/runner/abstractions/TaskControl.js +1 -5
  252. package/runner/abstractions/TaskControl.js.map +1 -1
  253. package/runner/abstractions/TaskEventValidation.d.ts +1 -1
  254. package/runner/abstractions/TaskEventValidation.js +1 -5
  255. package/runner/abstractions/TaskEventValidation.js.map +1 -1
  256. package/runner/abstractions/TaskManager.d.ts +4 -4
  257. package/runner/abstractions/TaskManager.js +1 -5
  258. package/runner/abstractions/TaskManager.js.map +1 -1
  259. package/runner/abstractions/TaskManagerStore.d.ts +11 -11
  260. package/runner/abstractions/TaskManagerStore.js +1 -5
  261. package/runner/abstractions/TaskManagerStore.js.map +1 -1
  262. package/runner/abstractions/TaskRunner.d.ts +3 -3
  263. package/runner/abstractions/TaskRunner.js +1 -5
  264. package/runner/abstractions/TaskRunner.js.map +1 -1
  265. package/runner/abstractions/index.d.ts +5 -5
  266. package/runner/abstractions/index.js +5 -60
  267. package/runner/abstractions/index.js.map +1 -1
  268. package/runner/index.d.ts +1 -1
  269. package/runner/index.js +1 -16
  270. package/runner/index.js.map +1 -1
  271. package/service/EventBridgeEventTransportPlugin.d.ts +4 -5
  272. package/service/EventBridgeEventTransportPlugin.js +8 -17
  273. package/service/EventBridgeEventTransportPlugin.js.map +1 -1
  274. package/service/StepFunctionServicePlugin.d.ts +4 -5
  275. package/service/StepFunctionServicePlugin.js +11 -21
  276. package/service/StepFunctionServicePlugin.js.map +1 -1
  277. package/service/createService.d.ts +2 -2
  278. package/service/createService.js +7 -18
  279. package/service/createService.js.map +1 -1
  280. package/service/index.d.ts +3 -3
  281. package/service/index.js +6 -27
  282. package/service/index.js.map +1 -1
  283. package/tasks/testingRunTask.d.ts +10 -1
  284. package/tasks/testingRunTask.js +13 -18
  285. package/tasks/testingRunTask.js.map +1 -1
  286. package/types.d.ts +41 -214
  287. package/types.js +7 -56
  288. package/types.js.map +1 -1
  289. package/utils/ObjectUpdater.js +4 -11
  290. package/utils/ObjectUpdater.js.map +1 -1
  291. package/utils/getErrorProperties.d.ts +1 -1
  292. package/utils/getErrorProperties.js +3 -10
  293. package/utils/getErrorProperties.js.map +1 -1
  294. package/utils/getObjectProperties.js +1 -8
  295. package/utils/getObjectProperties.js.map +1 -1
  296. package/utils/index.d.ts +3 -3
  297. package/utils/index.js +3 -38
  298. package/utils/index.js.map +1 -1
  299. package/utils/normalizeSelfCleanup.d.ts +2 -0
  300. package/utils/normalizeSelfCleanup.js +15 -0
  301. package/utils/normalizeSelfCleanup.js.map +1 -0
  302. package/crud/model.d.ts +0 -5
  303. package/crud/model.js +0 -216
  304. package/crud/model.js.map +0 -1
  305. package/crud/where.d.ts +0 -1
  306. package/crud/where.js +0 -33
  307. package/crud/where.js.map +0 -1
  308. package/task/index.d.ts +0 -2
  309. package/task/index.js +0 -29
  310. package/task/index.js.map +0 -1
  311. package/task/input.d.ts +0 -15
  312. package/task/input.js +0 -21
  313. package/task/input.js.map +0 -1
  314. package/task/plugin.d.ts +0 -36
  315. package/task/plugin.js +0 -106
  316. package/task/plugin.js.map +0 -1
package/plugins/index.js CHANGED
@@ -1,18 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _TaskServicePlugin = require("./TaskServicePlugin");
7
- Object.keys(_TaskServicePlugin).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _TaskServicePlugin[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _TaskServicePlugin[key];
14
- }
15
- });
16
- });
1
+ export * from "./TaskServicePlugin.js";
17
2
 
18
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_TaskServicePlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./TaskServicePlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,kBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./TaskServicePlugin.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1,12 +1,12 @@
1
- import type { IResponse, IResponseAsync, IResponseContinueParams, IResponseContinueResult, IResponseDoneParams, IResponseDoneResult, IResponseErrorParams, IResponseErrorResult, IResponseResult } from "./abstractions";
2
- import type { ITaskManagerStorePrivate } from "../runner/abstractions";
1
+ import type { IResponse, IResponseAsync, IResponseContinueParams, IResponseContinueResult, IResponseDoneParams, IResponseDoneResult, IResponseErrorParams, IResponseErrorResult, IResponseResult } from "./abstractions/index.js";
2
+ import type { ITaskManagerStorePrivate } from "../runner/abstractions/index.js";
3
3
  export declare class DatabaseResponse implements IResponseAsync {
4
4
  readonly response: IResponse;
5
5
  private readonly store;
6
6
  constructor(response: IResponse, store: ITaskManagerStorePrivate);
7
7
  from(result: IResponseResult): Promise<IResponseResult>;
8
8
  done(params: IResponseDoneParams): Promise<IResponseDoneResult>;
9
- aborted(): Promise<import("../types").IResponseAbortedResult>;
9
+ aborted(): Promise<import("~/types.js").IResponseAbortedResult>;
10
10
  continue(params: IResponseContinueParams): Promise<IResponseContinueResult | IResponseErrorResult>;
11
11
  error(params: IResponseErrorParams): Promise<IResponseErrorResult>;
12
12
  }
@@ -1,26 +1,21 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DatabaseResponse = void 0;
7
- var _types = require("../types");
8
- var _handlerGraphql = require("@webiny/handler-graphql");
9
- var _getErrorProperties = require("../utils/getErrorProperties");
10
- class DatabaseResponse {
1
+ import { TaskDataStatus } from "../types.js";
2
+ import { NotFoundError } from "@webiny/handler-graphql";
3
+ import { getErrorProperties } from "../utils/getErrorProperties.js";
4
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
5
+ export class DatabaseResponse {
11
6
  constructor(response, store) {
12
7
  this.response = response;
13
8
  this.store = store;
14
9
  }
15
10
  from(result) {
16
11
  switch (result.status) {
17
- case _types.TaskResponseStatus.DONE:
12
+ case TaskResultStatus.DONE:
18
13
  return this.done(result);
19
- case _types.TaskResponseStatus.CONTINUE:
14
+ case TaskResultStatus.CONTINUE:
20
15
  return this.continue(result);
21
- case _types.TaskResponseStatus.ERROR:
16
+ case TaskResultStatus.ERROR:
22
17
  return this.error(result);
23
- case _types.TaskResponseStatus.ABORTED:
18
+ case TaskResultStatus.ABORTED:
24
19
  return this.aborted();
25
20
  }
26
21
  }
@@ -32,7 +27,7 @@ class DatabaseResponse {
32
27
  let message = params.message;
33
28
  try {
34
29
  await this.store.updateTask({
35
- taskStatus: _types.TaskDataStatus.SUCCESS,
30
+ taskStatus: TaskDataStatus.SUCCESS,
36
31
  finishedOn: new Date().toISOString(),
37
32
  output
38
33
  });
@@ -63,7 +58,7 @@ class DatabaseResponse {
63
58
  ...task.input,
64
59
  ...params.input
65
60
  },
66
- taskStatus: _types.TaskDataStatus.RUNNING
61
+ taskStatus: TaskDataStatus.RUNNING
67
62
  });
68
63
  await this.store.addInfoLog({
69
64
  message: "Task continuing.",
@@ -74,7 +69,7 @@ class DatabaseResponse {
74
69
  /**
75
70
  * If task was not found, we just return the error.
76
71
  */
77
- if (ex instanceof _handlerGraphql.NotFoundError) {
72
+ if (ex instanceof NotFoundError) {
78
73
  return this.response.error({
79
74
  error: {
80
75
  message: ex.message || `Task not found.`,
@@ -102,10 +97,10 @@ class DatabaseResponse {
102
97
  return this.response.continue(params);
103
98
  }
104
99
  async error(params) {
105
- const error = params.error instanceof Error ? (0, _getErrorProperties.getErrorProperties)(params.error) : params.error;
100
+ const error = params.error instanceof Error ? getErrorProperties(params.error) : params.error;
106
101
  try {
107
102
  await this.store.updateTask({
108
- taskStatus: _types.TaskDataStatus.FAILED,
103
+ taskStatus: TaskDataStatus.FAILED,
109
104
  finishedOn: new Date().toISOString(),
110
105
  output: {
111
106
  error
@@ -147,6 +142,5 @@ class DatabaseResponse {
147
142
  });
148
143
  }
149
144
  }
150
- exports.DatabaseResponse = DatabaseResponse;
151
145
 
152
146
  //# sourceMappingURL=DatabaseResponse.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","_handlerGraphql","_getErrorProperties","DatabaseResponse","constructor","response","store","from","result","status","TaskResponseStatus","DONE","done","CONTINUE","continue","ERROR","error","ABORTED","aborted","params","output","rest","message","updateTask","taskStatus","TaskDataStatus","SUCCESS","finishedOn","Date","toISOString","addInfoLog","save","ex","task","getTask","input","RUNNING","data","NotFoundError","code","getInput","Error","getErrorProperties","FAILED","addErrorLog","exports"],"sources":["DatabaseResponse.ts"],"sourcesContent":["import { TaskDataStatus, TaskResponseStatus } from \"~/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type {\n IResponse,\n IResponseAsync,\n IResponseContinueParams,\n IResponseContinueResult,\n IResponseDoneParams,\n IResponseDoneResult,\n IResponseErrorParams,\n IResponseErrorResult,\n IResponseResult\n} from \"./abstractions\";\nimport type { ITaskManagerStorePrivate } from \"~/runner/abstractions\";\nimport { getErrorProperties } from \"~/utils/getErrorProperties\";\n\nexport class DatabaseResponse implements IResponseAsync {\n public readonly response: IResponse;\n\n private readonly store: ITaskManagerStorePrivate;\n\n public constructor(response: IResponse, store: ITaskManagerStorePrivate) {\n this.response = response;\n this.store = store;\n }\n\n public from(result: IResponseResult): Promise<IResponseResult> {\n switch (result.status) {\n case TaskResponseStatus.DONE:\n return this.done(result);\n case TaskResponseStatus.CONTINUE:\n return this.continue(result);\n case TaskResponseStatus.ERROR:\n return this.error(result);\n case TaskResponseStatus.ABORTED:\n return this.aborted();\n }\n }\n\n public async done(params: IResponseDoneParams): Promise<IResponseDoneResult> {\n const { output, ...rest } = params;\n let message = params.message;\n try {\n await this.store.updateTask({\n taskStatus: TaskDataStatus.SUCCESS,\n finishedOn: new Date().toISOString(),\n output\n });\n await this.store.addInfoLog({\n message: message || \"Task done.\"\n });\n await this.store.save();\n } catch (ex) {\n message = `Task done, but failed to update task log. (${ex.message || \"unknown\"})`;\n }\n /**\n * Default behavior is to return the done response.\n */\n return this.response.done({\n ...rest,\n message,\n output\n });\n }\n\n public async aborted() {\n return this.response.aborted();\n }\n\n public async continue(\n params: IResponseContinueParams\n ): Promise<IResponseContinueResult | IResponseErrorResult> {\n try {\n const task = this.store.getTask();\n await this.store.updateTask({\n input: {\n ...task.input,\n ...params.input\n },\n taskStatus: TaskDataStatus.RUNNING\n });\n await this.store.addInfoLog({\n message: \"Task continuing.\",\n data: params.input\n });\n await this.store.save();\n } catch (ex) {\n /**\n * If task was not found, we just return the error.\n */\n if (ex instanceof NotFoundError) {\n return this.response.error({\n error: {\n message: ex.message || `Task not found.`,\n code: ex.code || \"TASK_NOT_FOUND\",\n data: {\n ...ex.data,\n input: this.store.getInput()\n }\n }\n });\n }\n /**\n * Otherwise, we store the error and return it...\n */\n return this.error({\n error: {\n message: `Failed to update task input: ${ex.message || \"unknown error\"}`,\n code: ex.code || \"TASK_UPDATE_ERROR\"\n }\n });\n }\n /**\n * Default behavior is to return the continue response.\n */\n return this.response.continue(params);\n }\n\n public async error(params: IResponseErrorParams): Promise<IResponseErrorResult> {\n const error =\n params.error instanceof Error ? getErrorProperties(params.error) : params.error;\n try {\n await this.store.updateTask({\n taskStatus: TaskDataStatus.FAILED,\n finishedOn: new Date().toISOString(),\n output: {\n error\n }\n });\n await this.store.addErrorLog({\n message: params.error.message,\n data: this.store.getInput(),\n error\n });\n await this.store.save();\n } catch (ex) {\n return this.response.error({\n ...params,\n error: {\n ...error,\n message: ex.message || error.message,\n code: ex.code || error.code,\n data: {\n ...error.data,\n ...ex.data,\n input: this.store.getInput()\n }\n }\n });\n }\n /**\n * Default behavior is to return the error response.\n */\n return this.response.error({\n ...params,\n error: {\n ...params.error,\n data: {\n ...error.data,\n input: this.store.getInput()\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAaA,IAAAE,mBAAA,GAAAF,OAAA;AAEO,MAAMG,gBAAgB,CAA2B;EAK7CC,WAAWA,CAACC,QAAmB,EAAEC,KAA+B,EAAE;IACrE,IAAI,CAACD,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,KAAK,GAAGA,KAAK;EACtB;EAEOC,IAAIA,CAACC,MAAuB,EAA4B;IAC3D,QAAQA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AE,IAAI,CAAC7B,KAAK,CAACkC,QAAQ,CAAC;QAC/B;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACK,OAAA,CAAA1C,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["TaskDataStatus","NotFoundError","getErrorProperties","TaskResultStatus","DatabaseResponse","constructor","response","store","from","result","status","DONE","done","CONTINUE","continue","ERROR","error","ABORTED","aborted","params","output","rest","message","updateTask","taskStatus","SUCCESS","finishedOn","Date","toISOString","addInfoLog","save","ex","task","getTask","input","RUNNING","data","code","getInput","Error","FAILED","addErrorLog"],"sources":["DatabaseResponse.ts"],"sourcesContent":["import { TaskDataStatus } from \"~/types.js\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type {\n IResponse,\n IResponseAsync,\n IResponseContinueParams,\n IResponseContinueResult,\n IResponseDoneParams,\n IResponseDoneResult,\n IResponseErrorParams,\n IResponseErrorResult,\n IResponseResult\n} from \"./abstractions/index.js\";\nimport type { ITaskManagerStorePrivate } from \"~/runner/abstractions/index.js\";\nimport { getErrorProperties } from \"~/utils/getErrorProperties.js\";\nimport { TaskResultStatus } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport class DatabaseResponse implements IResponseAsync {\n public readonly response: IResponse;\n\n private readonly store: ITaskManagerStorePrivate;\n\n public constructor(response: IResponse, store: ITaskManagerStorePrivate) {\n this.response = response;\n this.store = store;\n }\n\n public from(result: IResponseResult): Promise<IResponseResult> {\n switch (result.status) {\n case TaskResultStatus.DONE:\n return this.done(result);\n case TaskResultStatus.CONTINUE:\n return this.continue(result);\n case TaskResultStatus.ERROR:\n return this.error(result);\n case TaskResultStatus.ABORTED:\n return this.aborted();\n }\n }\n\n public async done(params: IResponseDoneParams): Promise<IResponseDoneResult> {\n const { output, ...rest } = params;\n let message = params.message;\n try {\n await this.store.updateTask({\n taskStatus: TaskDataStatus.SUCCESS,\n finishedOn: new Date().toISOString(),\n output\n });\n await this.store.addInfoLog({\n message: message || \"Task done.\"\n });\n await this.store.save();\n } catch (ex) {\n message = `Task done, but failed to update task log. (${ex.message || \"unknown\"})`;\n }\n /**\n * Default behavior is to return the done response.\n */\n return this.response.done({\n ...rest,\n message,\n output\n });\n }\n\n public async aborted() {\n return this.response.aborted();\n }\n\n public async continue(\n params: IResponseContinueParams\n ): Promise<IResponseContinueResult | IResponseErrorResult> {\n try {\n const task = this.store.getTask();\n await this.store.updateTask({\n input: {\n ...task.input,\n ...params.input\n },\n taskStatus: TaskDataStatus.RUNNING\n });\n await this.store.addInfoLog({\n message: \"Task continuing.\",\n data: params.input\n });\n await this.store.save();\n } catch (ex) {\n /**\n * If task was not found, we just return the error.\n */\n if (ex instanceof NotFoundError) {\n return this.response.error({\n error: {\n message: ex.message || `Task not found.`,\n code: ex.code || \"TASK_NOT_FOUND\",\n data: {\n ...ex.data,\n input: this.store.getInput()\n }\n }\n });\n }\n /**\n * Otherwise, we store the error and return it...\n */\n return this.error({\n error: {\n message: `Failed to update task input: ${ex.message || \"unknown error\"}`,\n code: ex.code || \"TASK_UPDATE_ERROR\"\n }\n });\n }\n /**\n * Default behavior is to return the continue response.\n */\n return this.response.continue(params);\n }\n\n public async error(params: IResponseErrorParams): Promise<IResponseErrorResult> {\n const error =\n params.error instanceof Error ? getErrorProperties(params.error) : params.error;\n try {\n await this.store.updateTask({\n taskStatus: TaskDataStatus.FAILED,\n finishedOn: new Date().toISOString(),\n output: {\n error\n }\n });\n await this.store.addErrorLog({\n message: params.error.message,\n data: this.store.getInput(),\n error\n });\n await this.store.save();\n } catch (ex) {\n return this.response.error({\n ...params,\n error: {\n ...error,\n message: ex.message || error.message,\n code: ex.code || error.code,\n data: {\n ...error.data,\n ...ex.data,\n input: this.store.getInput()\n }\n }\n });\n }\n /**\n * Default behavior is to return the error response.\n */\n return this.response.error({\n ...params,\n error: {\n ...params.error,\n data: {\n ...error.data,\n input: this.store.getInput()\n }\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc;AACv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VF,KAAK,EAAE,IAAI,CAAC3B,KAAK,CAAC+B,QAAQ,CAAC;UAC/B;QACJ;MACJ,CAAC,CAAC;IACN;IACA;AACR;AACA;IACQ,OAAO,IAAI,CAAChC,QAAQ,CAACU,KAAK,CAAC;MACvB,GAAGG,MAAM;MACTH,KAAK,EAAE;QACH,GAAGG,MAAM,CAACH,KAAK;QACfoB,IAAI,EAAE;UACF,GAAGpB,KAAK,CAACoB,IAAI;UACbF,KAAK,EAAE,IAAI,CAAC3B,KAAK,CAAC+B,QAAQ,CAAC;QAC/B;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
@@ -1,5 +1,6 @@
1
- import type { ITaskEvent } from "../handler/types";
2
- import type { IResponse, IResponseAbortedResult, IResponseContinueParams, IResponseContinueResult, IResponseDoneParams, IResponseDoneResult, IResponseErrorParams, IResponseErrorResult, IResponseFromParams, IResponseResult, ITaskResponseDoneResultOutput } from "./abstractions";
1
+ import type { ITaskEvent } from "../handler/types.js";
2
+ import type { IResponse, IResponseAbortedResult, IResponseContinueParams, IResponseContinueResult, IResponseDoneParams, IResponseDoneResult, IResponseErrorParams, IResponseErrorResult, IResponseFromParams, IResponseResult } from "./abstractions/index.js";
3
+ import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
4
  export declare class Response implements IResponse {
4
5
  private _event;
5
6
  get event(): ITaskEvent;
@@ -7,7 +8,7 @@ export declare class Response implements IResponse {
7
8
  setEvent(event: ITaskEvent): void;
8
9
  from(params: IResponseFromParams): IResponseResult;
9
10
  continue(params: IResponseContinueParams): IResponseContinueResult;
10
- done<O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(params?: IResponseDoneParams<O>): IResponseDoneResult<O>;
11
+ done<O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput>(params?: IResponseDoneParams<O>): IResponseDoneResult<O>;
11
12
  aborted(): IResponseAbortedResult;
12
13
  error(params: IResponseErrorParams): IResponseErrorResult;
13
14
  }
@@ -1,17 +1,11 @@
1
- "use strict";
1
+ import sizeOfObject from "object-sizeof";
2
+ import { ResponseContinueResult } from "./ResponseContinueResult.js";
3
+ import { ResponseDoneResult } from "./ResponseDoneResult.js";
4
+ import { ResponseErrorResult } from "./ResponseErrorResult.js";
5
+ import { ResponseAbortedResult } from "./ResponseAbortedResult.js";
6
+ import { getErrorProperties } from "../utils/getErrorProperties.js";
7
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
8
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Response = void 0;
8
- var _objectSizeof = _interopRequireDefault(require("object-sizeof"));
9
- var _types = require("../types");
10
- var _ResponseContinueResult = require("./ResponseContinueResult");
11
- var _ResponseDoneResult = require("./ResponseDoneResult");
12
- var _ResponseErrorResult = require("./ResponseErrorResult");
13
- var _ResponseAbortedResult = require("./ResponseAbortedResult");
14
- var _getErrorProperties = require("../utils/getErrorProperties");
15
9
  /**
16
10
  * Step Functions has a limit of 256KB for the output size.
17
11
  * We will set the max output to be 232KB to leave some room for the rest of the data.
@@ -34,18 +28,18 @@ const getOutput = output => {
34
28
  if (!output || Object.keys(output).length === 0) {
35
29
  return undefined;
36
30
  }
37
- let size = (0, _objectSizeof.default)(output);
31
+ let size = sizeOfObject(output);
38
32
  if (size > MAX_SIZE_BYTES) {
39
33
  if (output.stack) {
40
34
  delete output.stack;
41
- size = (0, _objectSizeof.default)(output);
35
+ size = sizeOfObject(output);
42
36
  if (size <= MAX_SIZE_BYTES) {
43
37
  return output;
44
38
  }
45
39
  }
46
40
  if (output.error?.stack) {
47
41
  delete output.error.stack;
48
- size = (0, _objectSizeof.default)(output);
42
+ size = sizeOfObject(output);
49
43
  if (size <= MAX_SIZE_BYTES) {
50
44
  return output;
51
45
  }
@@ -56,7 +50,7 @@ const getOutput = output => {
56
50
  }
57
51
  return output;
58
52
  };
59
- class Response {
53
+ export class Response {
60
54
  get event() {
61
55
  return this._event;
62
56
  }
@@ -68,53 +62,48 @@ class Response {
68
62
  }
69
63
  from(params) {
70
64
  switch (params.status) {
71
- case _types.TaskResponseStatus.DONE:
65
+ case TaskResultStatus.DONE:
72
66
  return this.done(params);
73
- case _types.TaskResponseStatus.CONTINUE:
67
+ case TaskResultStatus.CONTINUE:
74
68
  return this.continue(params);
75
- case _types.TaskResponseStatus.ERROR:
69
+ case TaskResultStatus.ERROR:
76
70
  return this.error(params);
77
71
  }
78
72
  }
79
73
  continue(params) {
80
- return new _ResponseContinueResult.ResponseContinueResult({
74
+ return new ResponseContinueResult({
81
75
  message: params.message,
82
76
  input: params.input,
83
77
  webinyTaskId: params?.webinyTaskId || this.event.webinyTaskId,
84
78
  webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,
85
79
  tenant: params?.tenant || this.event.tenant,
86
- locale: params?.locale || this.event.locale,
87
80
  wait: params.wait
88
81
  });
89
82
  }
90
83
  done(params) {
91
- return new _ResponseDoneResult.ResponseDoneResult({
84
+ return new ResponseDoneResult({
92
85
  webinyTaskId: params?.webinyTaskId || this.event.webinyTaskId,
93
86
  webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,
94
87
  tenant: params?.tenant || this.event.tenant,
95
- locale: params?.locale || this.event.locale,
96
88
  message: params?.message,
97
89
  output: getOutput(params?.output)
98
90
  });
99
91
  }
100
92
  aborted() {
101
- return new _ResponseAbortedResult.ResponseAbortedResult({
93
+ return new ResponseAbortedResult({
102
94
  webinyTaskId: this.event.webinyTaskId,
103
95
  webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,
104
- tenant: this.event.tenant,
105
- locale: this.event.locale
96
+ tenant: this.event.tenant
106
97
  });
107
98
  }
108
99
  error(params) {
109
- return new _ResponseErrorResult.ResponseErrorResult({
100
+ return new ResponseErrorResult({
110
101
  webinyTaskId: params.webinyTaskId || this.event.webinyTaskId,
111
102
  webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,
112
103
  tenant: params.tenant || this.event.tenant,
113
- locale: params.locale || this.event.locale,
114
- error: params.error instanceof Error ? (0, _getErrorProperties.getErrorProperties)(params.error) : params.error
104
+ error: params.error instanceof Error ? getErrorProperties(params.error) : params.error
115
105
  });
116
106
  }
117
107
  }
118
- exports.Response = Response;
119
108
 
120
109
  //# sourceMappingURL=Response.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_objectSizeof","_interopRequireDefault","require","_types","_ResponseContinueResult","_ResponseDoneResult","_ResponseErrorResult","_ResponseAbortedResult","_getErrorProperties","MAX_SIZE_BYTES","createMaxSizeOutput","size","message","max","getOutput","output","Object","keys","length","undefined","sizeOfObject","stack","error","Response","event","_event","constructor","setEvent","from","params","status","TaskResponseStatus","DONE","done","CONTINUE","continue","ERROR","ResponseContinueResult","input","webinyTaskId","webinyTaskDefinitionId","tenant","locale","wait","ResponseDoneResult","aborted","ResponseAbortedResult","ResponseErrorResult","Error","getErrorProperties","exports"],"sources":["Response.ts"],"sourcesContent":["import sizeOfObject from \"object-sizeof\";\n\nimport type { ITaskEvent } from \"~/handler/types\";\nimport { TaskResponseStatus } from \"~/types\";\nimport type {\n IResponse,\n IResponseAbortedResult,\n IResponseContinueParams,\n IResponseContinueResult,\n IResponseDoneParams,\n IResponseDoneResult,\n IResponseErrorParams,\n IResponseErrorResult,\n IResponseFromParams,\n IResponseResult,\n ITaskResponseDoneResultOutput\n} from \"./abstractions\";\nimport { ResponseContinueResult } from \"~/response/ResponseContinueResult\";\nimport { ResponseDoneResult } from \"~/response/ResponseDoneResult\";\nimport { ResponseErrorResult } from \"~/response/ResponseErrorResult\";\nimport { ResponseAbortedResult } from \"./ResponseAbortedResult\";\nimport { getErrorProperties } from \"~/utils/getErrorProperties\";\n\n/**\n * Step Functions has a limit of 256KB for the output size.\n * We will set the max output to be 232KB to leave some room for the rest of the data.\n */\nconst MAX_SIZE_BYTES: number = 232 * 1024;\n\ninterface ICreateMaxSizeOutputParams {\n size: number;\n}\n\nconst createMaxSizeOutput = <O extends ITaskResponseDoneResultOutput>({\n size\n}: ICreateMaxSizeOutputParams): O => {\n return {\n message: `Output size exceeds the maximum allowed size.`,\n size,\n max: MAX_SIZE_BYTES\n } as unknown as O;\n};\n/**\n * Figure out the size of the output object and remove the stack trace if the size exceeds the maximum allowed size.\n * If the size is still greater than the maximum allowed size, just return the message that the output size exceeds the maximum allowed size.\n */\nconst getOutput = <O extends ITaskResponseDoneResultOutput>(output?: O): O | undefined => {\n if (!output || Object.keys(output).length === 0) {\n return undefined;\n }\n let size = sizeOfObject(output);\n if (size > MAX_SIZE_BYTES) {\n if (output.stack) {\n delete output.stack;\n size = sizeOfObject(output);\n if (size <= MAX_SIZE_BYTES) {\n return output;\n }\n }\n if (output.error?.stack) {\n delete output.error.stack;\n size = sizeOfObject(output);\n if (size <= MAX_SIZE_BYTES) {\n return output;\n }\n }\n return createMaxSizeOutput<O>({ size });\n }\n return output;\n};\n\nexport class Response implements IResponse {\n private _event: ITaskEvent;\n\n public get event(): ITaskEvent {\n return this._event;\n }\n\n public constructor(event: ITaskEvent) {\n this._event = event;\n }\n\n public setEvent(event: ITaskEvent) {\n this._event = event;\n }\n\n public from(params: IResponseFromParams): IResponseResult {\n switch (params.status) {\n case TaskResponseStatus.DONE:\n return this.done(params);\n case TaskResponseStatus.CONTINUE:\n return this.continue(params);\n case TaskResponseStatus.ERROR:\n return this.error(params);\n }\n }\n\n public continue(params: IResponseContinueParams): IResponseContinueResult {\n return new ResponseContinueResult({\n message: params.message,\n input: params.input,\n webinyTaskId: params?.webinyTaskId || this.event.webinyTaskId,\n webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,\n tenant: params?.tenant || this.event.tenant,\n locale: params?.locale || this.event.locale,\n wait: params.wait\n });\n }\n\n public done<O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(\n params?: IResponseDoneParams<O>\n ): IResponseDoneResult<O> {\n return new ResponseDoneResult<O>({\n webinyTaskId: params?.webinyTaskId || this.event.webinyTaskId,\n webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,\n tenant: params?.tenant || this.event.tenant,\n locale: params?.locale || this.event.locale,\n message: params?.message,\n output: getOutput<O>(params?.output)\n });\n }\n\n public aborted(): IResponseAbortedResult {\n return new ResponseAbortedResult({\n webinyTaskId: this.event.webinyTaskId,\n webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,\n tenant: this.event.tenant,\n locale: this.event.locale\n });\n }\n\n public error(params: IResponseErrorParams): IResponseErrorResult {\n return new ResponseErrorResult({\n webinyTaskId: params.webinyTaskId || this.event.webinyTaskId,\n webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,\n tenant: params.tenant || this.event.tenant,\n locale: params.locale || this.event.locale,\n error: params.error instanceof Error ? getErrorProperties(params.error) : params.error\n });\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAcA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AAEA;AACA;AACA;AACA;AACA,MAAMO,cAAsB,GAAG,GAAG,GAAG,IAAI;AAMzC,MAAMC,mBAAmB,GAAGA,CAA0C;EAClEC;AACwB,CAAC,KAAQ;EACjC,OAAO;IACHC,OAAO,EAAE,+CAA+C;IACxDD,IAAI;IACJE,GAAG,EAAEJ;EACT,CAAC;AACL,CAAC;AACD;AACA;AACA;AACA;AACA,MAAMK,SAAS,GAA6CC,MAAU,IAAoB;EACtF,IAAI,CAACA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE;IAC7C,OAAOC,SAAS;EACpB;EACA,IAAIR,IAAI,GAAG,IAAAS,qBAAY,EAACL,MAAM,CAAC;EAC/B,I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AY,EAAEV,MAAM,CAACU,YAAY,IAAI,IAAI,CAACf,KAAK,CAACe,YAAY;MAC5DC,sBAAsB,EAAE,IAAI,CAAChB,KAAK,CAACgB,sBAAsB;MACzDC,MAAM,EAAEZ,MAAM,CAACY,MAAM,IAAI,IAAI,CAACjB,KAAK,CAACiB,MAAM;MAC1CC,MAAM,EAAEb,MAAM,CAACa,MAAM,IAAI,IAAI,CAAClB,KAAK,CAACkB,MAAM;MAC1CpB,KAAK,EAAEO,MAAM,CAACP,KAAK,YAAY0B,KAAK,GAAG,IAAAC,sCAAkB,EAACpB,MAAM,CAACP,KAAK,CAAC,GAAGO,MAAM,CAACP;IACrF,CAAC,CAAC;EACN;AACJ;AAAC4B,OAAA,CAAA3B,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["sizeOfObject","ResponseContinueResult","ResponseDoneResult","ResponseErrorResult","ResponseAbortedResult","getErrorProperties","TaskResultStatus","MAX_SIZE_BYTES","createMaxSizeOutput","size","message","max","getOutput","output","Object","keys","length","undefined","stack","error","Response","event","_event","constructor","setEvent","from","params","status","DONE","done","CONTINUE","continue","ERROR","input","webinyTaskId","webinyTaskDefinitionId","tenant","wait","aborted","Error"],"sources":["Response.ts"],"sourcesContent":["import sizeOfObject from \"object-sizeof\";\n\nimport type { ITaskEvent } from \"~/handler/types.js\";\nimport type {\n IResponse,\n IResponseAbortedResult,\n IResponseContinueParams,\n IResponseContinueResult,\n IResponseDoneParams,\n IResponseDoneResult,\n IResponseErrorParams,\n IResponseErrorResult,\n IResponseFromParams,\n IResponseResult\n} from \"./abstractions/index.js\";\nimport { ResponseContinueResult } from \"~/response/ResponseContinueResult.js\";\nimport { ResponseDoneResult } from \"~/response/ResponseDoneResult.js\";\nimport { ResponseErrorResult } from \"~/response/ResponseErrorResult.js\";\nimport { ResponseAbortedResult } from \"./ResponseAbortedResult.js\";\nimport { getErrorProperties } from \"~/utils/getErrorProperties.js\";\nimport {\n TaskDefinition,\n TaskResultStatus\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\n/**\n * Step Functions has a limit of 256KB for the output size.\n * We will set the max output to be 232KB to leave some room for the rest of the data.\n */\nconst MAX_SIZE_BYTES: number = 232 * 1024;\n\ninterface ICreateMaxSizeOutputParams {\n size: number;\n}\n\nconst createMaxSizeOutput = <O extends TaskDefinition.TaskOutput>({\n size\n}: ICreateMaxSizeOutputParams): O => {\n return {\n message: `Output size exceeds the maximum allowed size.`,\n size,\n max: MAX_SIZE_BYTES\n } as unknown as O;\n};\n/**\n * Figure out the size of the output object and remove the stack trace if the size exceeds the maximum allowed size.\n * If the size is still greater than the maximum allowed size, just return the message that the output size exceeds the maximum allowed size.\n */\nconst getOutput = <O extends TaskDefinition.TaskOutput>(output?: O): O | undefined => {\n if (!output || Object.keys(output).length === 0) {\n return undefined;\n }\n let size = sizeOfObject(output);\n if (size > MAX_SIZE_BYTES) {\n if (output.stack) {\n delete output.stack;\n size = sizeOfObject(output);\n if (size <= MAX_SIZE_BYTES) {\n return output;\n }\n }\n if (output.error?.stack) {\n delete output.error.stack;\n size = sizeOfObject(output);\n if (size <= MAX_SIZE_BYTES) {\n return output;\n }\n }\n return createMaxSizeOutput<O>({ size });\n }\n return output;\n};\n\nexport class Response implements IResponse {\n private _event: ITaskEvent;\n\n public get event(): ITaskEvent {\n return this._event;\n }\n\n public constructor(event: ITaskEvent) {\n this._event = event;\n }\n\n public setEvent(event: ITaskEvent) {\n this._event = event;\n }\n\n public from(params: IResponseFromParams): IResponseResult {\n switch (params.status) {\n case TaskResultStatus.DONE:\n return this.done(params);\n case TaskResultStatus.CONTINUE:\n return this.continue(params);\n case TaskResultStatus.ERROR:\n return this.error(params);\n }\n }\n\n public continue(params: IResponseContinueParams): IResponseContinueResult {\n return new ResponseContinueResult({\n message: params.message,\n input: params.input,\n webinyTaskId: params?.webinyTaskId || this.event.webinyTaskId,\n webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,\n tenant: params?.tenant || this.event.tenant,\n wait: params.wait\n });\n }\n\n public done<O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput>(\n params?: IResponseDoneParams<O>\n ): IResponseDoneResult<O> {\n return new ResponseDoneResult<O>({\n webinyTaskId: params?.webinyTaskId || this.event.webinyTaskId,\n webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,\n tenant: params?.tenant || this.event.tenant,\n message: params?.message,\n output: getOutput<O>(params?.output)\n });\n }\n\n public aborted(): IResponseAbortedResult {\n return new ResponseAbortedResult({\n webinyTaskId: this.event.webinyTaskId,\n webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,\n tenant: this.event.tenant\n });\n }\n\n public error(params: IResponseErrorParams): IResponseErrorResult {\n return new ResponseErrorResult({\n webinyTaskId: params.webinyTaskId || this.event.webinyTaskId,\n webinyTaskDefinitionId: this.event.webinyTaskDefinitionId,\n tenant: params.tenant || this.event.tenant,\n error: params.error instanceof Error ? getErrorProperties(params.error) : params.error\n });\n }\n}\n"],"mappings":"AAAA,OAAOA,YAAY,MAAM,eAAe;AAexC,SAASC,sBAAsB;AAC/B,SAASC,kBAAkB;AAC3B,SAASC,mBAAmB;AAC5B,SAASC,qBAAqB;AAC9B,SAASC,kBAAkB;AAC3B,SAEIC,gBAAgB,QACb,wDAAwD;;AAE/D;AACA;AACA;AACA;AACA,MAAMC,cAAsB,GAAG,GAAG,GAAG,IAAI;AAMzC,MAAMC,mBAAmB,GAAGA,CAAsC;EAC9DC;AACwB,CAAC,KAAQ;EACjC,OAAO;IACHC,OAAO,EAAE,+CAA+C;IACxDD,IAAI;IACJE,GAAG,EAAEJ;EACT,CAAC;AACL,CAAC;AACD;AACA;AACA;AACA;AACA,MAAMK,SAAS,GAAyCC,MAAU,IAAoB;EAClF,IAAI,CAACA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE;IAC7C,OAAOC,SAAS;EACpB;EACA,IAAIR,IAAI,GAAGT,YAAY,CAACa,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,KAAK,EAAEO,MAAM,CAACP,KAAK,YAAYoB,KAAK,GAAGlC,kBAAkB,CAACqB,MAAM,CAACP,KAAK,CAAC,GAAGO,MAAM,CAACP;IACrF,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
@@ -1,10 +1,9 @@
1
- import { TaskResponseStatus } from "../types";
2
- import type { IResponseAbortedResult } from "./abstractions";
1
+ import type { IResponseAbortedResult } from "./abstractions/index.js";
2
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
3
  export declare class ResponseAbortedResult implements IResponseAbortedResult {
4
4
  readonly webinyTaskId: string;
5
5
  readonly webinyTaskDefinitionId: string;
6
6
  readonly tenant: string;
7
- readonly locale: string;
8
- readonly status: TaskResponseStatus.ABORTED;
7
+ readonly status: TaskResultStatus.ABORTED;
9
8
  constructor(params: Omit<IResponseAbortedResult, "status">);
10
9
  }
@@ -1,19 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ResponseAbortedResult = void 0;
7
- var _types = require("../types");
8
- class ResponseAbortedResult {
9
- status = _types.TaskResponseStatus.ABORTED;
1
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
+ export class ResponseAbortedResult {
3
+ status = TaskResultStatus.ABORTED;
10
4
  constructor(params) {
11
5
  this.webinyTaskId = params.webinyTaskId;
12
6
  this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;
13
7
  this.tenant = params.tenant;
14
- this.locale = params.locale;
15
8
  }
16
9
  }
17
- exports.ResponseAbortedResult = ResponseAbortedResult;
18
10
 
19
11
  //# sourceMappingURL=ResponseAbortedResult.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","ResponseAbortedResult","status","TaskResponseStatus","ABORTED","constructor","params","webinyTaskId","webinyTaskDefinitionId","tenant","locale","exports"],"sources":["ResponseAbortedResult.ts"],"sourcesContent":["import { TaskResponseStatus } from \"~/types\";\nimport type { IResponseAbortedResult } from \"./abstractions\";\n\nexport class ResponseAbortedResult implements IResponseAbortedResult {\n public readonly webinyTaskId: string;\n public readonly webinyTaskDefinitionId: string;\n public readonly tenant: string;\n public readonly locale: string;\n public readonly status: TaskResponseStatus.ABORTED = TaskResponseStatus.ABORTED;\n\n public constructor(params: Omit<IResponseAbortedResult, \"status\">) {\n this.webinyTaskId = params.webinyTaskId;\n this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;\n this.tenant = params.tenant;\n this.locale = params.locale;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,qBAAqB,CAAmC;EAKjDC,MAAM,GAA+BC,yBAAkB,CAACC,OAAO;EAExEC,WAAWA,CAACC,MAA8C,EAAE;IAC/D,IAAI,CAACC,YAAY,GAAGD,MAAM,CAACC,YAAY;IACvC,IAAI,CAACC,sBAAsB,GAAGF,MAAM,CAACE,sBAAsB;IAC3D,IAAI,CAACC,MAAM,GAAGH,MAAM,CAACG,MAAM;IAC3B,IAAI,CAACC,MAAM,GAAGJ,MAAM,CAACI,MAAM;EAC/B;AACJ;AAACC,OAAA,CAAAV,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["TaskResultStatus","ResponseAbortedResult","status","ABORTED","constructor","params","webinyTaskId","webinyTaskDefinitionId","tenant"],"sources":["ResponseAbortedResult.ts"],"sourcesContent":["import type { IResponseAbortedResult } from \"./abstractions/index.js\";\nimport { TaskResultStatus } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport class ResponseAbortedResult implements IResponseAbortedResult {\n public readonly webinyTaskId: string;\n public readonly webinyTaskDefinitionId: string;\n public readonly tenant: string;\n public readonly status: TaskResultStatus.ABORTED = TaskResultStatus.ABORTED;\n\n public constructor(params: Omit<IResponseAbortedResult, \"status\">) {\n this.webinyTaskId = params.webinyTaskId;\n this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;\n this.tenant = params.tenant;\n }\n}\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,wDAAwD;AAEzF,OAAO,MAAMC,qBAAqB,CAAmC;EAIjDC,MAAM,GAA6BF,gBAAgB,CAACG,OAAO;EAEpEC,WAAWA,CAACC,MAA8C,EAAE;IAC/D,IAAI,CAACC,YAAY,GAAGD,MAAM,CAACC,YAAY;IACvC,IAAI,CAACC,sBAAsB,GAAGF,MAAM,CAACE,sBAAsB;IAC3D,IAAI,CAACC,MAAM,GAAGH,MAAM,CAACG,MAAM;EAC/B;AACJ","ignoreList":[]}
@@ -1,13 +1,12 @@
1
- import type { ITaskDataInput } from "../types";
2
- import { TaskResponseStatus } from "../types";
3
- import type { IResponseContinueResult } from "./abstractions";
1
+ import type { ITaskDataInput } from "../types.js";
2
+ import type { IResponseContinueResult } from "./abstractions/index.js";
3
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
4
4
  export declare class ResponseContinueResult<T = ITaskDataInput> implements IResponseContinueResult<T> {
5
5
  readonly message?: string | undefined;
6
6
  readonly webinyTaskId: string;
7
7
  readonly webinyTaskDefinitionId: string;
8
8
  readonly tenant: string;
9
- readonly locale: string;
10
- readonly status: TaskResponseStatus.CONTINUE;
9
+ readonly status: TaskResultStatus.CONTINUE;
11
10
  readonly input: T;
12
11
  /**
13
12
  * We need this to make sure that the task will not use the delay from the previous iteration.
@@ -1,12 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ResponseContinueResult = void 0;
7
- var _types = require("../types");
8
- class ResponseContinueResult {
9
- status = _types.TaskResponseStatus.CONTINUE;
1
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
+ export class ResponseContinueResult {
3
+ status = TaskResultStatus.CONTINUE;
10
4
  /**
11
5
  * We need this to make sure that the task will not use the delay from the previous iteration.
12
6
  */
@@ -16,11 +10,9 @@ class ResponseContinueResult {
16
10
  this.webinyTaskId = params.webinyTaskId;
17
11
  this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;
18
12
  this.tenant = params.tenant;
19
- this.locale = params.locale;
20
13
  this.input = params.input;
21
14
  this.wait = params.wait;
22
15
  }
23
16
  }
24
- exports.ResponseContinueResult = ResponseContinueResult;
25
17
 
26
18
  //# sourceMappingURL=ResponseContinueResult.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","ResponseContinueResult","status","TaskResponseStatus","CONTINUE","delay","constructor","params","message","webinyTaskId","webinyTaskDefinitionId","tenant","locale","input","wait","exports"],"sources":["ResponseContinueResult.ts"],"sourcesContent":["import type { ITaskDataInput } from \"~/types\";\nimport { TaskResponseStatus } from \"~/types\";\nimport type { IResponseContinueResult } from \"./abstractions\";\n\nexport class ResponseContinueResult<T = ITaskDataInput> implements IResponseContinueResult<T> {\n public readonly message?: string | undefined;\n public readonly webinyTaskId: string;\n public readonly webinyTaskDefinitionId: string;\n public readonly tenant: string;\n public readonly locale: string;\n public readonly status: TaskResponseStatus.CONTINUE = TaskResponseStatus.CONTINUE;\n public readonly input: T;\n /**\n * We need this to make sure that the task will not use the delay from the previous iteration.\n */\n public readonly delay = -1;\n public readonly wait?: number;\n\n public constructor(params: Omit<IResponseContinueResult<T>, \"delay\" | \"status\">) {\n this.message = params.message;\n this.webinyTaskId = params.webinyTaskId;\n this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;\n this.tenant = params.tenant;\n this.locale = params.locale;\n this.input = params.input;\n this.wait = params.wait;\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,sBAAsB,CAA2D;EAM1EC,MAAM,GAAgCC,yBAAkB,CAACC,QAAQ;EAEjF;AACJ;AACA;EACoBC,KAAK,GAAG,CAAC,CAAC;EAGnBC,WAAWA,CAACC,MAA4D,EAAE;IAC7E,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,YAAY,GAAGF,MAAM,CAACE,YAAY;IACvC,IAAI,CAACC,sBAAsB,GAAGH,MAAM,CAACG,sBAAsB;IAC3D,IAAI,CAACC,MAAM,GAAGJ,MAAM,CAACI,MAAM;IAC3B,IAAI,CAACC,MAAM,GAAGL,MAAM,CAACK,MAAM;IAC3B,IAAI,CAACC,KAAK,GAAGN,MAAM,CAACM,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGP,MAAM,CAACO,IAAI;EAC3B;AACJ;AAACC,OAAA,CAAAd,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"names":["TaskResultStatus","ResponseContinueResult","status","CONTINUE","delay","constructor","params","message","webinyTaskId","webinyTaskDefinitionId","tenant","input","wait"],"sources":["ResponseContinueResult.ts"],"sourcesContent":["import type { ITaskDataInput } from \"~/types.js\";\nimport type { IResponseContinueResult } from \"./abstractions/index.js\";\nimport { TaskResultStatus } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport class ResponseContinueResult<T = ITaskDataInput> implements IResponseContinueResult<T> {\n public readonly message?: string | undefined;\n public readonly webinyTaskId: string;\n public readonly webinyTaskDefinitionId: string;\n public readonly tenant: string;\n public readonly status: TaskResultStatus.CONTINUE = TaskResultStatus.CONTINUE;\n public readonly input: T;\n /**\n * We need this to make sure that the task will not use the delay from the previous iteration.\n */\n public readonly delay = -1;\n public readonly wait?: number;\n\n public constructor(params: Omit<IResponseContinueResult<T>, \"delay\" | \"status\">) {\n this.message = params.message;\n this.webinyTaskId = params.webinyTaskId;\n this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;\n this.tenant = params.tenant;\n this.input = params.input;\n this.wait = params.wait;\n }\n}\n"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,wDAAwD;AAEzF,OAAO,MAAMC,sBAAsB,CAA2D;EAK1EC,MAAM,GAA8BF,gBAAgB,CAACG,QAAQ;EAE7E;AACJ;AACA;EACoBC,KAAK,GAAG,CAAC,CAAC;EAGnBC,WAAWA,CAACC,MAA4D,EAAE;IAC7E,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,YAAY,GAAGF,MAAM,CAACE,YAAY;IACvC,IAAI,CAACC,sBAAsB,GAAGH,MAAM,CAACG,sBAAsB;IAC3D,IAAI,CAACC,MAAM,GAAGJ,MAAM,CAACI,MAAM;IAC3B,IAAI,CAACC,KAAK,GAAGL,MAAM,CAACK,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGN,MAAM,CAACM,IAAI;EAC3B;AACJ","ignoreList":[]}
@@ -1,13 +1,11 @@
1
- import type { ITaskResponseDoneResultOutput } from "../types";
2
- import { TaskResponseStatus } from "../types";
3
- import type { IResponseDoneResult } from "./abstractions";
4
- export declare class ResponseDoneResult<O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> implements IResponseDoneResult<O> {
1
+ import type { IResponseDoneResult } from "./abstractions/index.js";
2
+ import { TaskDefinition, TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
+ export declare class ResponseDoneResult<O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput> implements IResponseDoneResult<O> {
5
4
  readonly message?: string | undefined;
6
5
  readonly webinyTaskId: string;
7
6
  readonly webinyTaskDefinitionId: string;
8
7
  readonly tenant: string;
9
- readonly locale: string;
10
8
  readonly output?: O;
11
- readonly status: TaskResponseStatus.DONE;
9
+ readonly status: TaskResultStatus.DONE;
12
10
  constructor(params: Omit<IResponseDoneResult<O>, "status">);
13
11
  }
@@ -1,21 +1,13 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ResponseDoneResult = void 0;
7
- var _types = require("../types");
8
- class ResponseDoneResult {
9
- status = _types.TaskResponseStatus.DONE;
1
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
+ export class ResponseDoneResult {
3
+ status = TaskResultStatus.DONE;
10
4
  constructor(params) {
11
5
  this.message = params.message;
12
6
  this.webinyTaskId = params.webinyTaskId;
13
7
  this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;
14
8
  this.tenant = params.tenant;
15
- this.locale = params.locale;
16
9
  this.output = Object.keys(params.output || {}).length > 0 ? params.output : undefined;
17
10
  }
18
11
  }
19
- exports.ResponseDoneResult = ResponseDoneResult;
20
12
 
21
13
  //# sourceMappingURL=ResponseDoneResult.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","ResponseDoneResult","status","TaskResponseStatus","DONE","constructor","params","message","webinyTaskId","webinyTaskDefinitionId","tenant","locale","output","Object","keys","length","undefined","exports"],"sources":["ResponseDoneResult.ts"],"sourcesContent":["import type { ITaskResponseDoneResultOutput } from \"~/types\";\nimport { TaskResponseStatus } from \"~/types\";\nimport type { IResponseDoneResult } from \"./abstractions\";\n\nexport class ResponseDoneResult<\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> implements IResponseDoneResult<O>\n{\n public readonly message?: string | undefined;\n public readonly webinyTaskId: string;\n public readonly webinyTaskDefinitionId: string;\n public readonly tenant: string;\n public readonly locale: string;\n public readonly output?: O;\n public readonly status: TaskResponseStatus.DONE = TaskResponseStatus.DONE;\n\n public constructor(params: Omit<IResponseDoneResult<O>, \"status\">) {\n this.message = params.message;\n this.webinyTaskId = params.webinyTaskId;\n this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;\n this.tenant = params.tenant;\n this.locale = params.locale;\n this.output = Object.keys(params.output || {}).length > 0 ? params.output : undefined;\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,kBAAkB,CAG/B;EAOoBC,MAAM,GAA4BC,yBAAkB,CAACC,IAAI;EAElEC,WAAWA,CAACC,MAA8C,EAAE;IAC/D,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,YAAY,GAAGF,MAAM,CAACE,YAAY;IACvC,IAAI,CAACC,sBAAsB,GAAGH,MAAM,CAACG,sBAAsB;IAC3D,IAAI,CAACC,MAAM,GAAGJ,MAAM,CAACI,MAAM;IAC3B,IAAI,CAACC,MAAM,GAAGL,MAAM,CAACK,MAAM;IAC3B,IAAI,CAACC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACR,MAAM,CAACM,MAAM,IAAI,CAAC,CAAC,CAAC,CAACG,MAAM,GAAG,CAAC,GAAGT,MAAM,CAACM,MAAM,GAAGI,SAAS;EACzF;AACJ;AAACC,OAAA,CAAAhB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["TaskResultStatus","ResponseDoneResult","status","DONE","constructor","params","message","webinyTaskId","webinyTaskDefinitionId","tenant","output","Object","keys","length","undefined"],"sources":["ResponseDoneResult.ts"],"sourcesContent":["import type { IResponseDoneResult } from \"./abstractions/index.js\";\nimport {\n TaskDefinition,\n TaskResultStatus\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport class ResponseDoneResult<\n O extends TaskDefinition.TaskOutput = TaskDefinition.TaskOutput\n> implements IResponseDoneResult<O> {\n public readonly message?: string | undefined;\n public readonly webinyTaskId: string;\n public readonly webinyTaskDefinitionId: string;\n public readonly tenant: string;\n public readonly output?: O;\n public readonly status: TaskResultStatus.DONE = TaskResultStatus.DONE;\n\n public constructor(params: Omit<IResponseDoneResult<O>, \"status\">) {\n this.message = params.message;\n this.webinyTaskId = params.webinyTaskId;\n this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;\n this.tenant = params.tenant;\n this.output = Object.keys(params.output || {}).length > 0 ? params.output : undefined;\n }\n}\n"],"mappings":"AACA,SAEIA,gBAAgB,QACb,wDAAwD;AAE/D,OAAO,MAAMC,kBAAkB,CAEK;EAMhBC,MAAM,GAA0BF,gBAAgB,CAACG,IAAI;EAE9DC,WAAWA,CAACC,MAA8C,EAAE;IAC/D,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,YAAY,GAAGF,MAAM,CAACE,YAAY;IACvC,IAAI,CAACC,sBAAsB,GAAGH,MAAM,CAACG,sBAAsB;IAC3D,IAAI,CAACC,MAAM,GAAGJ,MAAM,CAACI,MAAM;IAC3B,IAAI,CAACC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACP,MAAM,CAACK,MAAM,IAAI,CAAC,CAAC,CAAC,CAACG,MAAM,GAAG,CAAC,GAAGR,MAAM,CAACK,MAAM,GAAGI,SAAS;EACzF;AACJ","ignoreList":[]}
@@ -1,11 +1,10 @@
1
- import { TaskResponseStatus } from "../types";
2
- import type { IResponseError, IResponseErrorResult } from "./abstractions";
1
+ import type { IResponseError, IResponseErrorResult } from "./abstractions/index.js";
2
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
3
  export declare class ResponseErrorResult implements IResponseErrorResult {
4
4
  readonly webinyTaskId: string;
5
5
  readonly webinyTaskDefinitionId: string;
6
6
  readonly tenant: string;
7
- readonly locale: string;
8
7
  readonly error: IResponseError;
9
- readonly status: TaskResponseStatus.ERROR;
8
+ readonly status: TaskResultStatus.ERROR;
10
9
  constructor(params: Omit<IResponseErrorResult, "status">);
11
10
  }
@@ -1,20 +1,12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ResponseErrorResult = void 0;
7
- var _types = require("../types");
8
- class ResponseErrorResult {
9
- status = _types.TaskResponseStatus.ERROR;
1
+ import { TaskResultStatus } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
+ export class ResponseErrorResult {
3
+ status = TaskResultStatus.ERROR;
10
4
  constructor(params) {
11
5
  this.webinyTaskId = params.webinyTaskId;
12
6
  this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;
13
7
  this.tenant = params.tenant;
14
- this.locale = params.locale;
15
8
  this.error = params.error;
16
9
  }
17
10
  }
18
- exports.ResponseErrorResult = ResponseErrorResult;
19
11
 
20
12
  //# sourceMappingURL=ResponseErrorResult.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","ResponseErrorResult","status","TaskResponseStatus","ERROR","constructor","params","webinyTaskId","webinyTaskDefinitionId","tenant","locale","error","exports"],"sources":["ResponseErrorResult.ts"],"sourcesContent":["import { TaskResponseStatus } from \"~/types\";\nimport type { IResponseError, IResponseErrorResult } from \"./abstractions\";\n\nexport class ResponseErrorResult implements IResponseErrorResult {\n public readonly webinyTaskId: string;\n public readonly webinyTaskDefinitionId: string;\n public readonly tenant: string;\n public readonly locale: string;\n public readonly error: IResponseError;\n public readonly status: TaskResponseStatus.ERROR = TaskResponseStatus.ERROR;\n\n public constructor(params: Omit<IResponseErrorResult, \"status\">) {\n this.webinyTaskId = params.webinyTaskId;\n this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;\n this.tenant = params.tenant;\n this.locale = params.locale;\n this.error = params.error;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,mBAAmB,CAAiC;EAM7CC,MAAM,GAA6BC,yBAAkB,CAACC,KAAK;EAEpEC,WAAWA,CAACC,MAA4C,EAAE;IAC7D,IAAI,CAACC,YAAY,GAAGD,MAAM,CAACC,YAAY;IACvC,IAAI,CAACC,sBAAsB,GAAGF,MAAM,CAACE,sBAAsB;IAC3D,IAAI,CAACC,MAAM,GAAGH,MAAM,CAACG,MAAM;IAC3B,IAAI,CAACC,MAAM,GAAGJ,MAAM,CAACI,MAAM;IAC3B,IAAI,CAACC,KAAK,GAAGL,MAAM,CAACK,KAAK;EAC7B;AACJ;AAACC,OAAA,CAAAX,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["TaskResultStatus","ResponseErrorResult","status","ERROR","constructor","params","webinyTaskId","webinyTaskDefinitionId","tenant","error"],"sources":["ResponseErrorResult.ts"],"sourcesContent":["import type { IResponseError, IResponseErrorResult } from \"./abstractions/index.js\";\nimport { TaskResultStatus } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport class ResponseErrorResult implements IResponseErrorResult {\n public readonly webinyTaskId: string;\n public readonly webinyTaskDefinitionId: string;\n public readonly tenant: string;\n public readonly error: IResponseError;\n public readonly status: TaskResultStatus.ERROR = TaskResultStatus.ERROR;\n\n public constructor(params: Omit<IResponseErrorResult, \"status\">) {\n this.webinyTaskId = params.webinyTaskId;\n this.webinyTaskDefinitionId = params.webinyTaskDefinitionId;\n this.tenant = params.tenant;\n this.error = params.error;\n }\n}\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,wDAAwD;AAEzF,OAAO,MAAMC,mBAAmB,CAAiC;EAK7CC,MAAM,GAA2BF,gBAAgB,CAACG,KAAK;EAEhEC,WAAWA,CAACC,MAA4C,EAAE;IAC7D,IAAI,CAACC,YAAY,GAAGD,MAAM,CAACC,YAAY;IACvC,IAAI,CAACC,sBAAsB,GAAGF,MAAM,CAACE,sBAAsB;IAC3D,IAAI,CAACC,MAAM,GAAGH,MAAM,CAACG,MAAM;IAC3B,IAAI,CAACC,KAAK,GAAGJ,MAAM,CAACI,KAAK;EAC7B;AACJ","ignoreList":[]}
@@ -1,11 +1,12 @@
1
- import type { IResponse, IResponseError, ITaskResponse, ITaskResponseAbortedResult, ITaskResponseContinueOptions, ITaskResponseContinueResult, ITaskResponseDoneResult, ITaskResponseDoneResultOutput, ITaskResponseErrorResult } from "./abstractions";
2
- import type { ITaskDataInput } from "../types";
1
+ import type { IResponse, IResponseError, ITaskResponse, ITaskResponseContinueOptions } from "./abstractions/index.js";
2
+ import type { ITaskDataInput } from "../types.js";
3
+ import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
4
  export declare class TaskResponse implements ITaskResponse {
4
5
  private readonly response;
5
6
  constructor(response: IResponse);
6
- done<O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput>(message?: string | O, output?: O): ITaskResponseDoneResult<O>;
7
- continue<T = ITaskDataInput>(input: T, options?: ITaskResponseContinueOptions): ITaskResponseContinueResult;
8
- error(error: IResponseError | Error | string): ITaskResponseErrorResult;
9
- aborted(): ITaskResponseAbortedResult;
7
+ done<O extends TaskDefinition.ResultDone = TaskDefinition.ResultDone>(message?: string | O, output?: O): TaskDefinition.ResultDone<O>;
8
+ continue<T = ITaskDataInput>(input: T, options?: ITaskResponseContinueOptions): TaskDefinition.ResultContinue;
9
+ error(error: IResponseError | Error | string): TaskDefinition.ResultError;
10
+ aborted(): TaskDefinition.ResultAborted;
10
11
  private getError;
11
12
  }