@webiny/api-headless-cms-bulk-actions 5.41.0-dbt.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/abstractions/IListEntries.d.ts +7 -0
  4. package/abstractions/IListEntries.js +7 -0
  5. package/abstractions/IListEntries.js.map +1 -0
  6. package/abstractions/IProcessEntry.d.ts +4 -0
  7. package/abstractions/IProcessEntry.js +7 -0
  8. package/abstractions/IProcessEntry.js.map +1 -0
  9. package/abstractions/IUseCase.d.ts +3 -0
  10. package/abstractions/IUseCase.js +7 -0
  11. package/abstractions/IUseCase.js.map +1 -0
  12. package/abstractions/index.d.ts +3 -0
  13. package/abstractions/index.js +40 -0
  14. package/abstractions/index.js.map +1 -0
  15. package/handlers/eventBridgeEventHandler.d.ts +1 -0
  16. package/handlers/eventBridgeEventHandler.js +49 -0
  17. package/handlers/eventBridgeEventHandler.js.map +1 -0
  18. package/handlers/index.d.ts +1 -0
  19. package/handlers/index.js +14 -0
  20. package/handlers/index.js.map +1 -0
  21. package/handlers/setupEventsTenant.d.ts +1 -0
  22. package/handlers/setupEventsTenant.js +19 -0
  23. package/handlers/setupEventsTenant.js.map +1 -0
  24. package/index.d.ts +4 -0
  25. package/index.js +51 -0
  26. package/index.js.map +1 -0
  27. package/package.json +52 -0
  28. package/plugins/createBulkAction.d.ts +9 -0
  29. package/plugins/createBulkAction.js +35 -0
  30. package/plugins/createBulkAction.js.map +1 -0
  31. package/plugins/createBulkActionGraphQL.d.ts +7 -0
  32. package/plugins/createBulkActionGraphQL.js +56 -0
  33. package/plugins/createBulkActionGraphQL.js.map +1 -0
  34. package/plugins/createBulkActionTasks.d.ts +8 -0
  35. package/plugins/createBulkActionTasks.js +108 -0
  36. package/plugins/createBulkActionTasks.js.map +1 -0
  37. package/plugins/createDefaultGraphQL.d.ts +3 -0
  38. package/plugins/createDefaultGraphQL.js +57 -0
  39. package/plugins/createDefaultGraphQL.js.map +1 -0
  40. package/plugins/index.d.ts +2 -0
  41. package/plugins/index.js +29 -0
  42. package/plugins/index.js.map +1 -0
  43. package/tasks/createBulkActionEntriesTasks.d.ts +1 -0
  44. package/tasks/createBulkActionEntriesTasks.js +38 -0
  45. package/tasks/createBulkActionEntriesTasks.js.map +1 -0
  46. package/tasks/createEmptyTrashBinsTask.d.ts +2 -0
  47. package/tasks/createEmptyTrashBinsTask.js +84 -0
  48. package/tasks/createEmptyTrashBinsTask.js.map +1 -0
  49. package/tasks/index.d.ts +1 -0
  50. package/tasks/index.js +14 -0
  51. package/tasks/index.js.map +1 -0
  52. package/types.d.ts +41 -0
  53. package/types.js +7 -0
  54. package/types.js.map +1 -0
  55. package/useCases/DeleteEntry.d.ts +10 -0
  56. package/useCases/DeleteEntry.js +26 -0
  57. package/useCases/DeleteEntry.js.map +1 -0
  58. package/useCases/ListDeletedEntries.d.ts +13 -0
  59. package/useCases/ListDeletedEntries.js +28 -0
  60. package/useCases/ListDeletedEntries.js.map +1 -0
  61. package/useCases/ListLatestEntries.d.ts +13 -0
  62. package/useCases/ListLatestEntries.js +28 -0
  63. package/useCases/ListLatestEntries.js.map +1 -0
  64. package/useCases/ListPublishedEntries.d.ts +13 -0
  65. package/useCases/ListPublishedEntries.js +28 -0
  66. package/useCases/ListPublishedEntries.js.map +1 -0
  67. package/useCases/MoveEntryToFolder.d.ts +13 -0
  68. package/useCases/MoveEntryToFolder.js +23 -0
  69. package/useCases/MoveEntryToFolder.js.map +1 -0
  70. package/useCases/MoveEntryToTrash.d.ts +10 -0
  71. package/useCases/MoveEntryToTrash.js +26 -0
  72. package/useCases/MoveEntryToTrash.js.map +1 -0
  73. package/useCases/PublishEntry.d.ts +10 -0
  74. package/useCases/PublishEntry.js +20 -0
  75. package/useCases/PublishEntry.js.map +1 -0
  76. package/useCases/RestoreEntryFromTrash.d.ts +10 -0
  77. package/useCases/RestoreEntryFromTrash.js +24 -0
  78. package/useCases/RestoreEntryFromTrash.js.map +1 -0
  79. package/useCases/UnpublishEntry.d.ts +10 -0
  80. package/useCases/UnpublishEntry.js +20 -0
  81. package/useCases/UnpublishEntry.js.map +1 -0
  82. package/useCases/index.d.ts +9 -0
  83. package/useCases/index.js +106 -0
  84. package/useCases/index.js.map +1 -0
  85. package/useCases/internals/ChildTaskCleanup/ChildTasksCleanup.d.ts +13 -0
  86. package/useCases/internals/ChildTaskCleanup/ChildTasksCleanup.js +63 -0
  87. package/useCases/internals/ChildTaskCleanup/ChildTasksCleanup.js.map +1 -0
  88. package/useCases/internals/ChildTaskCleanup/index.d.ts +1 -0
  89. package/useCases/internals/ChildTaskCleanup/index.js +18 -0
  90. package/useCases/internals/ChildTaskCleanup/index.js.map +1 -0
  91. package/useCases/internals/CreateTasksByModel/CreateTasksByModel.d.ts +12 -0
  92. package/useCases/internals/CreateTasksByModel/CreateTasksByModel.js +107 -0
  93. package/useCases/internals/CreateTasksByModel/CreateTasksByModel.js.map +1 -0
  94. package/useCases/internals/CreateTasksByModel/TaskCache.d.ts +31 -0
  95. package/useCases/internals/CreateTasksByModel/TaskCache.js +68 -0
  96. package/useCases/internals/CreateTasksByModel/TaskCache.js.map +1 -0
  97. package/useCases/internals/CreateTasksByModel/index.d.ts +1 -0
  98. package/useCases/internals/CreateTasksByModel/index.js +18 -0
  99. package/useCases/internals/CreateTasksByModel/index.js.map +1 -0
  100. package/useCases/internals/ProcessTask/ProcessTask.d.ts +14 -0
  101. package/useCases/internals/ProcessTask/ProcessTask.js +92 -0
  102. package/useCases/internals/ProcessTask/ProcessTask.js.map +1 -0
  103. package/useCases/internals/ProcessTask/Result.d.ts +9 -0
  104. package/useCases/internals/ProcessTask/Result.js +29 -0
  105. package/useCases/internals/ProcessTask/Result.js.map +1 -0
  106. package/useCases/internals/ProcessTask/index.d.ts +1 -0
  107. package/useCases/internals/ProcessTask/index.js +18 -0
  108. package/useCases/internals/ProcessTask/index.js.map +1 -0
  109. package/useCases/internals/ProcessTasksByModel/ProcessTasksByModel.d.ts +11 -0
  110. package/useCases/internals/ProcessTasksByModel/ProcessTasksByModel.js +61 -0
  111. package/useCases/internals/ProcessTasksByModel/ProcessTasksByModel.js.map +1 -0
  112. package/useCases/internals/ProcessTasksByModel/index.d.ts +1 -0
  113. package/useCases/internals/ProcessTasksByModel/index.js +18 -0
  114. package/useCases/internals/ProcessTasksByModel/index.js.map +1 -0
  115. package/useCases/internals/index.d.ts +4 -0
  116. package/useCases/internals/index.js +51 -0
  117. package/useCases/internals/index.js.map +1 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _CreateTasksByModel = require("./CreateTasksByModel");
7
+ Object.keys(_CreateTasksByModel).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _CreateTasksByModel[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _CreateTasksByModel[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_CreateTasksByModel","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./CreateTasksByModel\";\n"],"mappings":";;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,mBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,mBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,mBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import { IBulkActionOperationTaskParams } from "../../../types";
2
+ import { IProcessEntry } from "../../../abstractions";
3
+ /**
4
+ * The `ProcessTask` class is responsible for processing a batch of entries
5
+ * based on the provided parameters. It uses a gateway to perform the actual
6
+ * processing and maintains the results of the operations, including successfully
7
+ * processed and failed entries.
8
+ */
9
+ export declare class ProcessTask {
10
+ private readonly result;
11
+ private gateway;
12
+ constructor(gateway: IProcessEntry);
13
+ execute(params: IBulkActionOperationTaskParams): Promise<import("@webiny/tasks").ITaskResponseErrorResult | import("@webiny/tasks").ITaskResponseAbortedResult | import("@webiny/tasks").ITaskResponseContinueResult<import("../../../types").IBulkActionOperationInput> | import("@webiny/tasks").ITaskResponseDoneResult<import("../../../types").IBulkActionOperationOutput>>;
14
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ProcessTask = void 0;
7
+ var _Result = require("./Result");
8
+ /**
9
+ * The `ProcessTask` class is responsible for processing a batch of entries
10
+ * based on the provided parameters. It uses a gateway to perform the actual
11
+ * processing and maintains the results of the operations, including successfully
12
+ * processed and failed entries.
13
+ */
14
+ class ProcessTask {
15
+ constructor(gateway) {
16
+ this.result = new _Result.Result();
17
+ this.gateway = gateway;
18
+ }
19
+ async execute(params) {
20
+ const {
21
+ input,
22
+ response,
23
+ isAborted,
24
+ isCloseToTimeout,
25
+ context,
26
+ store
27
+ } = params;
28
+ try {
29
+ if (isAborted()) {
30
+ return response.aborted();
31
+ } else if (isCloseToTimeout()) {
32
+ return response.continue({
33
+ ...input
34
+ });
35
+ }
36
+
37
+ // Check if the input contains a model ID.
38
+ if (!input.modelId) {
39
+ return response.error(`Missing "modelId" in the input.`);
40
+ }
41
+
42
+ // Check if the model exists.
43
+ const model = await context.cms.getModel(input.modelId);
44
+ if (!model) {
45
+ return response.error(`Model with ${input.modelId} not found!`);
46
+ }
47
+
48
+ // Check if there are any IDs to process.
49
+ if (!input.ids || input.ids.length === 0) {
50
+ return response.done(`Task done: no entries to process for "${input.modelId}" model.`);
51
+ }
52
+
53
+ // Process each ID in the input.
54
+ for (const id of input.ids) {
55
+ try {
56
+ // Set the security identity in the context.
57
+ context.security.setIdentity(input.identity);
58
+ // Execute the gateway operation for the current ID.
59
+ await this.gateway.execute(model, id, input.data);
60
+ // Add the ID to the list of successfully processed entries.
61
+ this.result.addDone(id);
62
+ } catch (ex) {
63
+ // Handle any errors that occur during processing of the current ID.
64
+ const message = ex.message || `Failed to process entry with id "${id}".`;
65
+ try {
66
+ console.error(message);
67
+ await store.addErrorLog({
68
+ message,
69
+ error: ex
70
+ });
71
+ } catch {
72
+ console.error(`Failed to add error log: "${message}"`);
73
+ } finally {
74
+ // Add the ID to the list of failed entries.
75
+ this.result.addFailed(id);
76
+ }
77
+ }
78
+ }
79
+
80
+ // Return a done response with the results of the processing.
81
+ return response.done(`Task done: all entries processed for "${model.name}" model.`, {
82
+ done: this.result.getDone(),
83
+ failed: this.result.getFailed()
84
+ });
85
+ } catch (ex) {
86
+ return response.error(ex.message ?? `Error while processing task.`);
87
+ }
88
+ }
89
+ }
90
+ exports.ProcessTask = ProcessTask;
91
+
92
+ //# sourceMappingURL=ProcessTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Result","require","ProcessTask","constructor","gateway","result","Result","execute","params","input","response","isAborted","isCloseToTimeout","context","store","aborted","continue","modelId","error","model","cms","getModel","ids","length","done","id","security","setIdentity","identity","data","addDone","ex","message","console","addErrorLog","addFailed","name","getDone","failed","getFailed","exports"],"sources":["ProcessTask.ts"],"sourcesContent":["import { Result } from \"./Result\";\nimport { IBulkActionOperationTaskParams } from \"~/types\";\nimport { IProcessEntry } from \"~/abstractions\";\n\n/**\n * The `ProcessTask` class is responsible for processing a batch of entries\n * based on the provided parameters. It uses a gateway to perform the actual\n * processing and maintains the results of the operations, including successfully\n * processed and failed entries.\n */\nexport class ProcessTask {\n private readonly result: Result;\n private gateway: IProcessEntry;\n\n constructor(gateway: IProcessEntry) {\n this.result = new Result();\n this.gateway = gateway;\n }\n\n async execute(params: IBulkActionOperationTaskParams) {\n const { input, response, isAborted, isCloseToTimeout, context, store } = params;\n\n try {\n if (isAborted()) {\n return response.aborted();\n } else if (isCloseToTimeout()) {\n return response.continue({\n ...input\n });\n }\n\n // Check if the input contains a model ID.\n if (!input.modelId) {\n return response.error(`Missing \"modelId\" in the input.`);\n }\n\n // Check if the model exists.\n const model = await context.cms.getModel(input.modelId);\n\n if (!model) {\n return response.error(`Model with ${input.modelId} not found!`);\n }\n\n // Check if there are any IDs to process.\n if (!input.ids || input.ids.length === 0) {\n return response.done(\n `Task done: no entries to process for \"${input.modelId}\" model.`\n );\n }\n\n // Process each ID in the input.\n for (const id of input.ids) {\n try {\n // Set the security identity in the context.\n context.security.setIdentity(input.identity);\n // Execute the gateway operation for the current ID.\n await this.gateway.execute(model, id, input.data);\n // Add the ID to the list of successfully processed entries.\n this.result.addDone(id);\n } catch (ex) {\n // Handle any errors that occur during processing of the current ID.\n const message = ex.message || `Failed to process entry with id \"${id}\".`;\n try {\n console.error(message);\n await store.addErrorLog({\n message,\n error: ex\n });\n } catch {\n console.error(`Failed to add error log: \"${message}\"`);\n } finally {\n // Add the ID to the list of failed entries.\n this.result.addFailed(id);\n }\n }\n }\n\n // Return a done response with the results of the processing.\n return response.done(`Task done: all entries processed for \"${model.name}\" model.`, {\n done: this.result.getDone(),\n failed: this.result.getFailed()\n });\n } catch (ex) {\n return response.error(ex.message ?? `Error while processing task.`);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,CAAC;EAIrBC,WAAWA,CAACC,OAAsB,EAAE;IAChC,IAAI,CAACC,MAAM,GAAG,IAAIC,cAAM,CAAC,CAAC;IAC1B,IAAI,CAACF,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMG,OAAOA,CAACC,MAAsC,EAAE;IAClD,M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AAE,CAACC,OAAO,IAAK,oCAAmCP,EAAG,IAAG;UACxE,IAAI;YACAQ,OAAO,CAACf,KAAK,CAACc,OAAO,CAAC;YACtB,MAAMlB,KAAK,CAACoB,WAAW,CAAC;cACpBF,OAAO;cACPd,KAAK,EAAEa;YACX,CAAC,CAAC;UACN,CAAC,CAAC,MAAM;YACJE,OAAO,CAACf,KAAK,CAAE,6BAA4Bc,OAAQ,GAAE,CAAC;UAC1D,CAAC,SAAS;YACN;YACA,IAAI,CAAC3B,MAAM,CAAC8B,SAAS,CAACV,EAAE,CAAC;UAC7B;QACJ;MACJ;;MAEA;MACA,OAAOf,QAAQ,CAACc,IAAI,CAAE,yCAAwCL,KAAK,CAACiB,IAAK,UAAS,EAAE;QAChFZ,IAAI,EAAE,IAAI,CAACnB,MAAM,CAACgC,OAAO,CAAC,CAAC;QAC3BC,MAAM,EAAE,IAAI,CAACjC,MAAM,CAACkC,SAAS,CAAC;MAClC,CAAC,CAAC;IACN,CAAC,CAAC,OAAOR,EAAE,EAAE;MACT,OAAOrB,QAAQ,CAACQ,KAAK,CAACa,EAAE,CAACC,OAAO,IAAK,8BAA6B,CAAC;IACvE;EACJ;AACJ;AAACQ,OAAA,CAAAtC,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ export declare class Result {
2
+ private readonly done;
3
+ private readonly failed;
4
+ constructor();
5
+ addDone(entryId: string): void;
6
+ addFailed(entryId: string): void;
7
+ getFailed(): string[];
8
+ getDone(): string[];
9
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Result = void 0;
7
+ class Result {
8
+ constructor() {
9
+ this.done = new Set();
10
+ this.failed = new Set();
11
+ }
12
+ addDone(entryId) {
13
+ this.failed.delete(entryId);
14
+ this.done.add(entryId);
15
+ }
16
+ addFailed(entryId) {
17
+ this.failed.add(entryId);
18
+ this.done.delete(entryId);
19
+ }
20
+ getFailed() {
21
+ return Array.from(this.failed);
22
+ }
23
+ getDone() {
24
+ return Array.from(this.done);
25
+ }
26
+ }
27
+ exports.Result = Result;
28
+
29
+ //# sourceMappingURL=Result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","constructor","done","Set","failed","addDone","entryId","delete","add","addFailed","getFailed","Array","from","getDone","exports"],"sources":["Result.ts"],"sourcesContent":["export class Result {\n private readonly done: Set<string>;\n private readonly failed: Set<string>;\n\n public constructor() {\n this.done = new Set();\n this.failed = new Set();\n }\n\n public addDone(entryId: string): void {\n this.failed.delete(entryId);\n this.done.add(entryId);\n }\n\n public addFailed(entryId: string): void {\n this.failed.add(entryId);\n this.done.delete(entryId);\n }\n\n public getFailed() {\n return Array.from(this.failed);\n }\n\n public getDone() {\n return Array.from(this.done);\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,MAAM,CAAC;EAITC,WAAWA,CAAA,EAAG;IACjB,IAAI,CAACC,IAAI,GAAG,IAAIC,GAAG,CAAC,CAAC;IACrB,IAAI,CAACC,MAAM,GAAG,IAAID,GAAG,CAAC,CAAC;EAC3B;EAEOE,OAAOA,CAACC,OAAe,EAAQ;IAClC,IAAI,CAACF,MAAM,CAACG,MAAM,CAACD,OAAO,CAAC;IAC3B,IAAI,CAACJ,IAAI,CAACM,GAAG,CAACF,OAAO,CAAC;EAC1B;EAEOG,SAASA,CAACH,OAAe,EAAQ;IACpC,IAAI,CAACF,MAAM,CAACI,GAAG,CAACF,OAAO,CAAC;IACxB,IAAI,CAACJ,IAAI,CAACK,MAAM,CAACD,OAAO,CAAC;EAC7B;EAEOI,SAASA,CAAA,EAAG;IACf,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACR,MAAM,CAAC;EAClC;EAEOS,OAAOA,CAAA,EAAG;IACb,OAAOF,KAAK,CAACC,IAAI,CAAC,IAAI,CAACV,IAAI,CAAC;EAChC;AACJ;AAACY,OAAA,CAAAd,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export * from "./ProcessTask";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _ProcessTask = require("./ProcessTask");
7
+ Object.keys(_ProcessTask).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _ProcessTask[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _ProcessTask[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ProcessTask","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./ProcessTask\";\n"],"mappings":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import { IBulkActionOperationByModelTaskParams } from "../../../types";
2
+ /**
3
+ * The `ProcessTasksByModel` class is responsible for processing tasks for a specific model.
4
+ * It checks for any running or pending tasks from the parent task and continues or completes
5
+ * the task based on the status.
6
+ */
7
+ export declare class ProcessTasksByModel {
8
+ private taskDefinition;
9
+ constructor(taskDefinition: string);
10
+ execute(params: IBulkActionOperationByModelTaskParams): Promise<import("@webiny/tasks").ITaskResponseErrorResult | import("@webiny/tasks").ITaskResponseAbortedResult | import("@webiny/tasks").ITaskResponseContinueResult<import("../../../types").IBulkActionOperationByModelInput> | import("@webiny/tasks").ITaskResponseDoneResult<import("../../../types").IBulkActionOperationByModelOutput>>;
11
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ProcessTasksByModel = void 0;
7
+ var _tasks = require("@webiny/tasks");
8
+ const WAITING_TIME = 10;
9
+
10
+ /**
11
+ * The `ProcessTasksByModel` class is responsible for processing tasks for a specific model.
12
+ * It checks for any running or pending tasks from the parent task and continues or completes
13
+ * the task based on the status.
14
+ */
15
+ class ProcessTasksByModel {
16
+ constructor(taskDefinition) {
17
+ this.taskDefinition = taskDefinition;
18
+ }
19
+ async execute(params) {
20
+ const {
21
+ response,
22
+ input,
23
+ isAborted,
24
+ isCloseToTimeout,
25
+ context,
26
+ store
27
+ } = params;
28
+ try {
29
+ if (isAborted()) {
30
+ return response.aborted();
31
+ } else if (isCloseToTimeout()) {
32
+ return response.continue({
33
+ ...input
34
+ });
35
+ }
36
+ const result = await context.tasks.listTasks({
37
+ where: {
38
+ parentId: store.getTask().id,
39
+ definitionId: this.taskDefinition,
40
+ taskStatus_in: [_tasks.TaskDataStatus.RUNNING, _tasks.TaskDataStatus.PENDING]
41
+ },
42
+ limit: 1
43
+ });
44
+
45
+ // If there are running or pending tasks, continue with a wait.
46
+ if (result.items.length > 0) {
47
+ return response.continue({
48
+ ...input
49
+ }, {
50
+ seconds: WAITING_TIME
51
+ });
52
+ }
53
+ return response.done(`Task done: task "${this.taskDefinition}" has been successfully processed for entries from "${input.modelId}" model.`);
54
+ } catch (ex) {
55
+ return response.error(ex.message ?? `Error while processing task "${this.taskDefinition}"`);
56
+ }
57
+ }
58
+ }
59
+ exports.ProcessTasksByModel = ProcessTasksByModel;
60
+
61
+ //# sourceMappingURL=ProcessTasksByModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_tasks","require","WAITING_TIME","ProcessTasksByModel","constructor","taskDefinition","execute","params","response","input","isAborted","isCloseToTimeout","context","store","aborted","continue","result","tasks","listTasks","where","parentId","getTask","id","definitionId","taskStatus_in","TaskDataStatus","RUNNING","PENDING","limit","items","length","seconds","done","modelId","ex","error","message","exports"],"sources":["ProcessTasksByModel.ts"],"sourcesContent":["import { TaskDataStatus } from \"@webiny/tasks\";\nimport { IBulkActionOperationByModelTaskParams } from \"~/types\";\n\nconst WAITING_TIME = 10;\n\n/**\n * The `ProcessTasksByModel` class is responsible for processing tasks for a specific model.\n * It checks for any running or pending tasks from the parent task and continues or completes\n * the task based on the status.\n */\nexport class ProcessTasksByModel {\n private taskDefinition: string;\n\n constructor(taskDefinition: string) {\n this.taskDefinition = taskDefinition;\n }\n\n async execute(params: IBulkActionOperationByModelTaskParams) {\n const { response, input, isAborted, isCloseToTimeout, context, store } = params;\n\n try {\n if (isAborted()) {\n return response.aborted();\n } else if (isCloseToTimeout()) {\n return response.continue({\n ...input\n });\n }\n\n const result = await context.tasks.listTasks({\n where: {\n parentId: store.getTask().id,\n definitionId: this.taskDefinition,\n taskStatus_in: [TaskDataStatus.RUNNING, TaskDataStatus.PENDING]\n },\n limit: 1\n });\n\n // If there are running or pending tasks, continue with a wait.\n if (result.items.length > 0) {\n return response.continue(\n {\n ...input\n },\n {\n seconds: WAITING_TIME\n }\n );\n }\n\n return response.done(\n `Task done: task \"${this.taskDefinition}\" has been successfully processed for entries from \"${input.modelId}\" model.`\n );\n } catch (ex) {\n return response.error(\n ex.message ?? `Error while processing task \"${this.taskDefinition}\"`\n );\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,MAAMC,YAAY,GAAG,EAAE;;AAEvB;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,CAAC;EAG7BC,WAAWA,CAACC,cAAsB,EAAE;IAChC,IAAI,CAACA,cAAc,GAAGA,cAAc;EACxC;EAEA,MAAMC,OAAOA,CAACC,MAA6C,EAAE;IACzD,MAAM;MAAEC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__esModule", {
4
+ value: true
5
+ });
6
+ var _ProcessTasksByModel = require("./ProcessTasksByModel");
7
+ Object.keys(_ProcessTasksByModel).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _ProcessTasksByModel[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _ProcessTasksByModel[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ProcessTasksByModel","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./ProcessTasksByModel\";\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export * from "./ChildTaskCleanup";
2
+ export * from "./CreateTasksByModel";
3
+ export * from "./ProcessTask";
4
+ export * from "./ProcessTasksByModel";
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _ChildTaskCleanup = require("./ChildTaskCleanup");
7
+ Object.keys(_ChildTaskCleanup).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _ChildTaskCleanup[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _ChildTaskCleanup[key];
14
+ }
15
+ });
16
+ });
17
+ var _CreateTasksByModel = require("./CreateTasksByModel");
18
+ Object.keys(_CreateTasksByModel).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _CreateTasksByModel[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _CreateTasksByModel[key];
25
+ }
26
+ });
27
+ });
28
+ var _ProcessTask = require("./ProcessTask");
29
+ Object.keys(_ProcessTask).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _ProcessTask[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _ProcessTask[key];
36
+ }
37
+ });
38
+ });
39
+ var _ProcessTasksByModel = require("./ProcessTasksByModel");
40
+ Object.keys(_ProcessTasksByModel).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _ProcessTasksByModel[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _ProcessTasksByModel[key];
47
+ }
48
+ });
49
+ });
50
+
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ChildTaskCleanup","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_CreateTasksByModel","_ProcessTask","_ProcessTasksByModel"],"sources":["index.ts"],"sourcesContent":["export * from \"./ChildTaskCleanup\";\nexport * from \"./CreateTasksByModel\";\nexport * from \"./ProcessTask\";\nexport * from \"./ProcessTasksByModel\";\n"],"mappings":";;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,iBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,iBAAA,CAAAK,G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