@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.
- package/README.md +10 -9
- package/context.js +50 -21
- package/context.js.map +1 -1
- package/crud/TaskLogPrivateModel.d.ts +9 -0
- package/crud/TaskLogPrivateModel.js +34 -0
- package/crud/TaskLogPrivateModel.js.map +1 -0
- package/crud/TaskPrivateModel.d.ts +9 -0
- package/crud/TaskPrivateModel.js +46 -0
- package/crud/TaskPrivateModel.js.map +1 -0
- package/crud/cleanupTaskSubtree.d.ts +8 -0
- package/crud/cleanupTaskSubtree.js +76 -0
- package/crud/cleanupTaskSubtree.js.map +1 -0
- package/crud/crud.tasks.d.ts +1 -1
- package/crud/crud.tasks.js +213 -105
- package/crud/crud.tasks.js.map +1 -1
- package/crud/definition.tasks.d.ts +1 -1
- package/crud/definition.tasks.js +9 -18
- package/crud/definition.tasks.js.map +1 -1
- package/crud/service.tasks.d.ts +1 -1
- package/crud/service.tasks.js +31 -36
- package/crud/service.tasks.js.map +1 -1
- package/decorators/RunnableTaskDecorator.d.ts +32 -0
- package/decorators/RunnableTaskDecorator.js +85 -0
- package/decorators/RunnableTaskDecorator.js.map +1 -0
- package/decorators/SelfCleaningTaskDecorator.d.ts +30 -0
- package/decorators/SelfCleaningTaskDecorator.js +98 -0
- package/decorators/SelfCleaningTaskDecorator.js.map +1 -0
- package/domain/errors.d.ts +29 -0
- package/domain/errors.js +47 -0
- package/domain/errors.js.map +1 -0
- package/events/TaskAfterCreateEvent.d.ts +6 -0
- package/events/TaskAfterCreateEvent.js +10 -0
- package/events/TaskAfterCreateEvent.js.map +1 -0
- package/events/TaskAfterDeleteEvent.d.ts +6 -0
- package/events/TaskAfterDeleteEvent.js +10 -0
- package/events/TaskAfterDeleteEvent.js.map +1 -0
- package/events/TaskAfterUpdateEvent.d.ts +6 -0
- package/events/TaskAfterUpdateEvent.js +10 -0
- package/events/TaskAfterUpdateEvent.js.map +1 -0
- package/events/TaskBeforeCreateEvent.d.ts +6 -0
- package/events/TaskBeforeCreateEvent.js +10 -0
- package/events/TaskBeforeCreateEvent.js.map +1 -0
- package/events/TaskBeforeDeleteEvent.d.ts +6 -0
- package/events/TaskBeforeDeleteEvent.js +10 -0
- package/events/TaskBeforeDeleteEvent.js.map +1 -0
- package/events/TaskBeforeUpdateEvent.d.ts +6 -0
- package/events/TaskBeforeUpdateEvent.js +10 -0
- package/events/TaskBeforeUpdateEvent.js.map +1 -0
- package/events/abstractions.d.ts +53 -0
- package/events/abstractions.js +39 -0
- package/events/abstractions.js.map +1 -0
- package/events/index.d.ts +7 -0
- package/events/index.js +9 -0
- package/events/index.js.map +1 -0
- package/features/AbortTask/AbortTaskUseCase.d.ts +10 -0
- package/features/AbortTask/AbortTaskUseCase.js +11 -0
- package/features/AbortTask/AbortTaskUseCase.js.map +1 -0
- package/features/AbortTask/abstractions.d.ts +25 -0
- package/features/AbortTask/abstractions.js +4 -0
- package/features/AbortTask/abstractions.js.map +1 -0
- package/features/AbortTask/feature.d.ts +5 -0
- package/features/AbortTask/feature.js +11 -0
- package/features/AbortTask/feature.js.map +1 -0
- package/features/AbortTask/index.d.ts +2 -0
- package/features/AbortTask/index.js +4 -0
- package/features/AbortTask/index.js.map +1 -0
- package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.d.ts +7 -0
- package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js +10 -0
- package/features/CleanupTaskSubtree/CleanupTaskSubtreeUseCase.js.map +1 -0
- package/features/CleanupTaskSubtree/abstractions.d.ts +7 -0
- package/features/CleanupTaskSubtree/abstractions.js +4 -0
- package/features/CleanupTaskSubtree/abstractions.js.map +1 -0
- package/features/CleanupTaskSubtree/index.d.ts +2 -0
- package/features/CleanupTaskSubtree/index.js +4 -0
- package/features/CleanupTaskSubtree/index.js.map +1 -0
- package/features/GetTask/GetTaskUseCase.d.ts +9 -0
- package/features/GetTask/GetTaskUseCase.js +10 -0
- package/features/GetTask/GetTaskUseCase.js.map +1 -0
- package/features/GetTask/abstractions.d.ts +10 -0
- package/features/GetTask/abstractions.js +4 -0
- package/features/GetTask/abstractions.js.map +1 -0
- package/features/GetTask/feature.d.ts +5 -0
- package/features/GetTask/feature.js +11 -0
- package/features/GetTask/feature.js.map +1 -0
- package/features/GetTask/index.d.ts +2 -0
- package/features/GetTask/index.js +4 -0
- package/features/GetTask/index.js.map +1 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.d.ts +12 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js +25 -0
- package/features/GetTaskDefinition/GetTaskDefinitionUseCase.js.map +1 -0
- package/features/GetTaskDefinition/abstractions.d.ts +17 -0
- package/features/GetTaskDefinition/abstractions.js +4 -0
- package/features/GetTaskDefinition/abstractions.js.map +1 -0
- package/features/GetTaskDefinition/feature.d.ts +4 -0
- package/features/GetTaskDefinition/feature.js +10 -0
- package/features/GetTaskDefinition/feature.js.map +1 -0
- package/features/GetTaskDefinition/index.d.ts +2 -0
- package/features/GetTaskDefinition/index.js +4 -0
- package/features/GetTaskDefinition/index.js.map +1 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.d.ts +11 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js +18 -0
- package/features/ListTaskDefinitions/ListTaskDefinitionsUseCase.js.map +1 -0
- package/features/ListTaskDefinitions/abstractions.d.ts +9 -0
- package/features/ListTaskDefinitions/abstractions.js +4 -0
- package/features/ListTaskDefinitions/abstractions.js.map +1 -0
- package/features/ListTaskDefinitions/feature.d.ts +4 -0
- package/features/ListTaskDefinitions/feature.js +10 -0
- package/features/ListTaskDefinitions/feature.js.map +1 -0
- package/features/ListTaskDefinitions/index.d.ts +2 -0
- package/features/ListTaskDefinitions/index.js +4 -0
- package/features/ListTaskDefinitions/index.js.map +1 -0
- package/features/ListTasks/ListTasksUseCase.d.ts +9 -0
- package/features/ListTasks/ListTasksUseCase.js +10 -0
- package/features/ListTasks/ListTasksUseCase.js.map +1 -0
- package/features/ListTasks/abstractions.d.ts +13 -0
- package/features/ListTasks/abstractions.js +4 -0
- package/features/ListTasks/abstractions.js.map +1 -0
- package/features/ListTasks/feature.d.ts +5 -0
- package/features/ListTasks/feature.js +11 -0
- package/features/ListTasks/feature.js.map +1 -0
- package/features/ListTasks/index.d.ts +2 -0
- package/features/ListTasks/index.js +4 -0
- package/features/ListTasks/index.js.map +1 -0
- package/features/TaskController/TaskController.d.ts +49 -0
- package/features/TaskController/TaskController.js +71 -0
- package/features/TaskController/TaskController.js.map +1 -0
- package/features/TaskController/augmentation.d.ts +60 -0
- package/features/TaskController/augmentation.js +3 -0
- package/features/TaskController/augmentation.js.map +1 -0
- package/features/TaskController/index.d.ts +2 -0
- package/features/TaskController/index.js +7 -0
- package/features/TaskController/index.js.map +1 -0
- package/features/TaskExecutionContext/TaskExecutionContext.d.ts +24 -0
- package/features/TaskExecutionContext/TaskExecutionContext.js +50 -0
- package/features/TaskExecutionContext/TaskExecutionContext.js.map +1 -0
- package/features/TaskExecutionContext/abstractions.d.ts +26 -0
- package/features/TaskExecutionContext/abstractions.js +13 -0
- package/features/TaskExecutionContext/abstractions.js.map +1 -0
- package/features/TaskExecutionContext/feature.d.ts +4 -0
- package/features/TaskExecutionContext/feature.js +10 -0
- package/features/TaskExecutionContext/feature.js.map +1 -0
- package/features/TaskExecutionContext/index.d.ts +1 -0
- package/features/TaskExecutionContext/index.js +3 -0
- package/features/TaskExecutionContext/index.js.map +1 -0
- package/features/TriggerTask/TriggerTaskUseCase.d.ts +10 -0
- package/features/TriggerTask/TriggerTaskUseCase.js +11 -0
- package/features/TriggerTask/TriggerTaskUseCase.js.map +1 -0
- package/features/TriggerTask/abstractions.d.ts +28 -0
- package/features/TriggerTask/abstractions.js +4 -0
- package/features/TriggerTask/abstractions.js.map +1 -0
- package/features/TriggerTask/feature.d.ts +5 -0
- package/features/TriggerTask/feature.js +11 -0
- package/features/TriggerTask/feature.js.map +1 -0
- package/features/TriggerTask/index.d.ts +2 -0
- package/features/TriggerTask/index.js +4 -0
- package/features/TriggerTask/index.js.map +1 -0
- package/global.d.ts +1 -0
- package/global.js +3 -0
- package/global.js.map +1 -0
- package/graphql/checkPermissions.d.ts +1 -1
- package/graphql/checkPermissions.js +3 -9
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/index.d.ts +1 -1
- package/graphql/index.js +67 -83
- package/graphql/index.js.map +1 -1
- package/graphql/utils.d.ts +3 -3
- package/graphql/utils.js +8 -17
- package/graphql/utils.js.map +1 -1
- package/handler/index.d.ts +2 -2
- package/handler/index.js +33 -40
- package/handler/index.js.map +1 -1
- package/handler/register.js +5 -7
- package/handler/register.js.map +1 -1
- package/handler/types.d.ts +1 -3
- package/handler/types.js +1 -5
- package/handler/types.js.map +1 -1
- package/index.d.ts +5 -6
- package/index.js +5 -60
- package/index.js.map +1 -1
- package/package.json +27 -28
- package/plugins/TaskServicePlugin.d.ts +1 -2
- package/plugins/TaskServicePlugin.js +2 -9
- package/plugins/TaskServicePlugin.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +1 -16
- package/plugins/index.js.map +1 -1
- package/response/DatabaseResponse.d.ts +3 -3
- package/response/DatabaseResponse.js +14 -20
- package/response/DatabaseResponse.js.map +1 -1
- package/response/Response.d.ts +4 -3
- package/response/Response.js +20 -31
- package/response/Response.js.map +1 -1
- package/response/ResponseAbortedResult.d.ts +3 -4
- package/response/ResponseAbortedResult.js +3 -11
- package/response/ResponseAbortedResult.js.map +1 -1
- package/response/ResponseContinueResult.d.ts +4 -5
- package/response/ResponseContinueResult.js +3 -11
- package/response/ResponseContinueResult.js.map +1 -1
- package/response/ResponseDoneResult.d.ts +4 -6
- package/response/ResponseDoneResult.js +3 -11
- package/response/ResponseDoneResult.js.map +1 -1
- package/response/ResponseErrorResult.d.ts +3 -4
- package/response/ResponseErrorResult.js +3 -11
- package/response/ResponseErrorResult.js.map +1 -1
- package/response/TaskResponse.d.ts +7 -6
- package/response/TaskResponse.js +5 -12
- package/response/TaskResponse.js.map +1 -1
- package/response/abstractions/Response.d.ts +7 -7
- package/response/abstractions/Response.js +1 -5
- package/response/abstractions/Response.js.map +1 -1
- package/response/abstractions/ResponseAbortedResult.d.ts +3 -3
- package/response/abstractions/ResponseAbortedResult.js +1 -5
- package/response/abstractions/ResponseAbortedResult.js.map +1 -1
- package/response/abstractions/ResponseBaseResult.d.ts +2 -3
- package/response/abstractions/ResponseBaseResult.js +1 -5
- package/response/abstractions/ResponseBaseResult.js.map +1 -1
- package/response/abstractions/ResponseContinueResult.d.ts +4 -4
- package/response/abstractions/ResponseContinueResult.js +1 -5
- package/response/abstractions/ResponseContinueResult.js.map +1 -1
- package/response/abstractions/ResponseDoneResult.d.ts +5 -6
- package/response/abstractions/ResponseDoneResult.js +1 -5
- package/response/abstractions/ResponseDoneResult.js.map +1 -1
- package/response/abstractions/ResponseErrorResult.d.ts +4 -5
- package/response/abstractions/ResponseErrorResult.js +1 -5
- package/response/abstractions/ResponseErrorResult.js.map +1 -1
- package/response/abstractions/TaskResponse.d.ts +8 -30
- package/response/abstractions/TaskResponse.js +1 -5
- package/response/abstractions/TaskResponse.js.map +1 -1
- package/response/abstractions/index.d.ts +7 -7
- package/response/abstractions/index.js +7 -82
- package/response/abstractions/index.js.map +1 -1
- package/response/index.d.ts +7 -7
- package/response/index.js +7 -82
- package/response/index.js.map +1 -1
- package/runner/TaskControl.d.ts +4 -4
- package/runner/TaskControl.js +61 -39
- package/runner/TaskControl.js.map +1 -1
- package/runner/TaskEventValidation.d.ts +2 -2
- package/runner/TaskEventValidation.js +11 -20
- package/runner/TaskEventValidation.js.map +1 -1
- package/runner/TaskManager.d.ts +7 -10
- package/runner/TaskManager.js +19 -39
- package/runner/TaskManager.js.map +1 -1
- package/runner/TaskManagerStore.d.ts +7 -7
- package/runner/TaskManagerStore.js +16 -25
- package/runner/TaskManagerStore.js.map +1 -1
- package/runner/TaskRunner.d.ts +5 -6
- package/runner/TaskRunner.js +9 -31
- package/runner/TaskRunner.js.map +1 -1
- package/runner/abstractions/TaskControl.d.ts +4 -4
- package/runner/abstractions/TaskControl.js +1 -5
- package/runner/abstractions/TaskControl.js.map +1 -1
- package/runner/abstractions/TaskEventValidation.d.ts +1 -1
- package/runner/abstractions/TaskEventValidation.js +1 -5
- package/runner/abstractions/TaskEventValidation.js.map +1 -1
- package/runner/abstractions/TaskManager.d.ts +4 -4
- package/runner/abstractions/TaskManager.js +1 -5
- package/runner/abstractions/TaskManager.js.map +1 -1
- package/runner/abstractions/TaskManagerStore.d.ts +11 -11
- package/runner/abstractions/TaskManagerStore.js +1 -5
- package/runner/abstractions/TaskManagerStore.js.map +1 -1
- package/runner/abstractions/TaskRunner.d.ts +3 -3
- package/runner/abstractions/TaskRunner.js +1 -5
- package/runner/abstractions/TaskRunner.js.map +1 -1
- package/runner/abstractions/index.d.ts +5 -5
- package/runner/abstractions/index.js +5 -60
- package/runner/abstractions/index.js.map +1 -1
- package/runner/index.d.ts +1 -1
- package/runner/index.js +1 -16
- package/runner/index.js.map +1 -1
- package/service/EventBridgeEventTransportPlugin.d.ts +4 -5
- package/service/EventBridgeEventTransportPlugin.js +8 -17
- package/service/EventBridgeEventTransportPlugin.js.map +1 -1
- package/service/StepFunctionServicePlugin.d.ts +4 -5
- package/service/StepFunctionServicePlugin.js +11 -21
- package/service/StepFunctionServicePlugin.js.map +1 -1
- package/service/createService.d.ts +2 -2
- package/service/createService.js +7 -18
- package/service/createService.js.map +1 -1
- package/service/index.d.ts +3 -3
- package/service/index.js +6 -27
- package/service/index.js.map +1 -1
- package/tasks/testingRunTask.d.ts +10 -1
- package/tasks/testingRunTask.js +13 -18
- package/tasks/testingRunTask.js.map +1 -1
- package/types.d.ts +41 -214
- package/types.js +7 -56
- package/types.js.map +1 -1
- package/utils/ObjectUpdater.js +4 -11
- package/utils/ObjectUpdater.js.map +1 -1
- package/utils/getErrorProperties.d.ts +1 -1
- package/utils/getErrorProperties.js +3 -10
- package/utils/getErrorProperties.js.map +1 -1
- package/utils/getObjectProperties.js +1 -8
- package/utils/getObjectProperties.js.map +1 -1
- package/utils/index.d.ts +3 -3
- package/utils/index.js +3 -38
- package/utils/index.js.map +1 -1
- package/utils/normalizeSelfCleanup.d.ts +2 -0
- package/utils/normalizeSelfCleanup.js +15 -0
- package/utils/normalizeSelfCleanup.js.map +1 -0
- package/crud/model.d.ts +0 -5
- package/crud/model.js +0 -216
- package/crud/model.js.map +0 -1
- package/crud/where.d.ts +0 -1
- package/crud/where.js +0 -33
- package/crud/where.js.map +0 -1
- package/task/index.d.ts +0 -2
- package/task/index.js +0 -29
- package/task/index.js.map +0 -1
- package/task/input.d.ts +0 -15
- package/task/input.js +0 -21
- package/task/input.js.map +0 -1
- package/task/plugin.d.ts +0 -36
- package/task/plugin.js +0 -106
- package/task/plugin.js.map +0 -1
package/plugins/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
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
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
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("
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
12
|
+
case TaskResultStatus.DONE:
|
|
18
13
|
return this.done(result);
|
|
19
|
-
case
|
|
14
|
+
case TaskResultStatus.CONTINUE:
|
|
20
15
|
return this.continue(result);
|
|
21
|
-
case
|
|
16
|
+
case TaskResultStatus.ERROR:
|
|
22
17
|
return this.error(result);
|
|
23
|
-
case
|
|
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:
|
|
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:
|
|
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
|
|
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 ?
|
|
100
|
+
const error = params.error instanceof Error ? getErrorProperties(params.error) : params.error;
|
|
106
101
|
try {
|
|
107
102
|
await this.store.updateTask({
|
|
108
|
-
taskStatus:
|
|
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":["
|
|
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":"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","ignoreList":[]}
|
package/response/Response.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ITaskEvent } from "../handler/types";
|
|
2
|
-
import type { IResponse, IResponseAbortedResult, IResponseContinueParams, IResponseContinueResult, IResponseDoneParams, IResponseDoneResult, IResponseErrorParams, IResponseErrorResult, IResponseFromParams, IResponseResult
|
|
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
|
|
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
|
}
|
package/response/Response.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
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 = (
|
|
31
|
+
let size = sizeOfObject(output);
|
|
38
32
|
if (size > MAX_SIZE_BYTES) {
|
|
39
33
|
if (output.stack) {
|
|
40
34
|
delete output.stack;
|
|
41
|
-
size = (
|
|
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 = (
|
|
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
|
|
65
|
+
case TaskResultStatus.DONE:
|
|
72
66
|
return this.done(params);
|
|
73
|
-
case
|
|
67
|
+
case TaskResultStatus.CONTINUE:
|
|
74
68
|
return this.continue(params);
|
|
75
|
-
case
|
|
69
|
+
case TaskResultStatus.ERROR:
|
|
76
70
|
return this.error(params);
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
continue(params) {
|
|
80
|
-
return new
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
package/response/Response.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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":"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","ignoreList":[]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
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
|
|
8
|
-
readonly status: TaskResponseStatus.ABORTED;
|
|
7
|
+
readonly status: TaskResultStatus.ABORTED;
|
|
9
8
|
constructor(params: Omit<IResponseAbortedResult, "status">);
|
|
10
9
|
}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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":["
|
|
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 {
|
|
3
|
-
import
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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":["
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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:
|
|
9
|
+
readonly status: TaskResultStatus.DONE;
|
|
12
10
|
constructor(params: Omit<IResponseDoneResult<O>, "status">);
|
|
13
11
|
}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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":["
|
|
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 {
|
|
2
|
-
import
|
|
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:
|
|
8
|
+
readonly status: TaskResultStatus.ERROR;
|
|
10
9
|
constructor(params: Omit<IResponseErrorResult, "status">);
|
|
11
10
|
}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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":["
|
|
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,
|
|
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
|
|
7
|
-
continue<T = ITaskDataInput>(input: T, options?: ITaskResponseContinueOptions):
|
|
8
|
-
error(error: IResponseError | Error | string):
|
|
9
|
-
aborted():
|
|
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
|
}
|