@webiny/api-headless-cms-bulk-actions 6.0.0-alpha.5 → 6.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +10 -14
  2. package/abstractions/IUseCase.js +1 -5
  3. package/abstractions/index.d.ts +1 -3
  4. package/abstractions/index.js +1 -38
  5. package/abstractions/index.js.map +1 -1
  6. package/domain/BulkActionName.d.ts +3 -0
  7. package/domain/BulkActionName.js +20 -0
  8. package/domain/BulkActionName.js.map +1 -0
  9. package/features/BulkActionContext/abstractions.d.ts +5 -0
  10. package/features/BulkActionContext/abstractions.js +6 -0
  11. package/features/BulkActionContext/abstractions.js.map +1 -0
  12. package/features/BulkActionContext/index.d.ts +1 -0
  13. package/features/BulkActionContext/index.js +3 -0
  14. package/features/BulkActionContext/index.js.map +1 -0
  15. package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.d.ts +15 -0
  16. package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.js +29 -0
  17. package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.js.map +1 -0
  18. package/features/DeleteEntriesBulkAction/feature.d.ts +1 -0
  19. package/features/DeleteEntriesBulkAction/feature.js +10 -0
  20. package/features/DeleteEntriesBulkAction/feature.js.map +1 -0
  21. package/features/EntriesBulkAction/abstractions.d.ts +38 -0
  22. package/features/EntriesBulkAction/abstractions.js +5 -0
  23. package/features/EntriesBulkAction/abstractions.js.map +1 -0
  24. package/features/EntriesBulkAction/createBulkActionTasks.d.ts +2 -0
  25. package/features/EntriesBulkAction/createBulkActionTasks.js +147 -0
  26. package/features/EntriesBulkAction/createBulkActionTasks.js.map +1 -0
  27. package/{useCases/internals/ChildTaskCleanup → features/EntriesBulkAction/internals}/ChildTasksCleanup.d.ts +1 -1
  28. package/{useCases/internals/ChildTaskCleanup → features/EntriesBulkAction/internals}/ChildTasksCleanup.js +3 -10
  29. package/features/EntriesBulkAction/internals/ChildTasksCleanup.js.map +1 -0
  30. package/features/EntriesBulkAction/internals/CreateTasksByModel.d.ts +16 -0
  31. package/features/EntriesBulkAction/internals/CreateTasksByModel.js +107 -0
  32. package/features/EntriesBulkAction/internals/CreateTasksByModel.js.map +1 -0
  33. package/features/EntriesBulkAction/internals/ProcessTask.d.ts +16 -0
  34. package/features/EntriesBulkAction/internals/ProcessTask.js +76 -0
  35. package/features/EntriesBulkAction/internals/ProcessTask.js.map +1 -0
  36. package/{useCases/internals/ProcessTask/Result.d.ts → features/EntriesBulkAction/internals/ProcessTaskResult.d.ts} +1 -1
  37. package/{useCases/internals/ProcessTask/Result.js → features/EntriesBulkAction/internals/ProcessTaskResult.js} +2 -9
  38. package/features/EntriesBulkAction/internals/ProcessTaskResult.js.map +1 -0
  39. package/features/EntriesBulkAction/internals/ProcessTasksByModel.d.ts +13 -0
  40. package/features/EntriesBulkAction/internals/ProcessTasksByModel.js +56 -0
  41. package/features/EntriesBulkAction/internals/ProcessTasksByModel.js.map +1 -0
  42. package/{useCases/internals/CreateTasksByModel → features/EntriesBulkAction/internals}/TaskCache.d.ts +4 -4
  43. package/{useCases/internals/CreateTasksByModel → features/EntriesBulkAction/internals}/TaskCache.js +1 -8
  44. package/features/EntriesBulkAction/internals/TaskCache.js.map +1 -0
  45. package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.d.ts +15 -0
  46. package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.js +30 -0
  47. package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.js.map +1 -0
  48. package/features/MoveToFolderBulkAction/feature.d.ts +1 -0
  49. package/features/MoveToFolderBulkAction/feature.js +10 -0
  50. package/features/MoveToFolderBulkAction/feature.js.map +1 -0
  51. package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.d.ts +15 -0
  52. package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.js +29 -0
  53. package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.js.map +1 -0
  54. package/features/MoveToTrashBulkAction/feature.d.ts +1 -0
  55. package/features/MoveToTrashBulkAction/feature.js +10 -0
  56. package/features/MoveToTrashBulkAction/feature.js.map +1 -0
  57. package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.d.ts +15 -0
  58. package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.js +37 -0
  59. package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.js.map +1 -0
  60. package/features/PublishEntriesBulkAction/feature.d.ts +1 -0
  61. package/features/PublishEntriesBulkAction/feature.js +10 -0
  62. package/features/PublishEntriesBulkAction/feature.js.map +1 -0
  63. package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.d.ts +15 -0
  64. package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js +27 -0
  65. package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js.map +1 -0
  66. package/features/RestoreEntriesBulkAction/feature.d.ts +1 -0
  67. package/features/RestoreEntriesBulkAction/feature.js +10 -0
  68. package/features/RestoreEntriesBulkAction/feature.js.map +1 -0
  69. package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.d.ts +15 -0
  70. package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js +27 -0
  71. package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js.map +1 -0
  72. package/features/UnpublishEntriesBulkAction/feature.d.ts +1 -0
  73. package/features/UnpublishEntriesBulkAction/feature.js +10 -0
  74. package/features/UnpublishEntriesBulkAction/feature.js.map +1 -0
  75. package/graphql/createBulkActionGraphQL.d.ts +3 -0
  76. package/graphql/createBulkActionGraphQL.js +64 -0
  77. package/graphql/createBulkActionGraphQL.js.map +1 -0
  78. package/graphql/createDefaultGraphQL.d.ts +3 -0
  79. package/{plugins → graphql}/createDefaultGraphQL.js +10 -18
  80. package/graphql/createDefaultGraphQL.js.map +1 -0
  81. package/handlers/eventBridgeEventHandler.js +3 -10
  82. package/handlers/eventBridgeEventHandler.js.map +1 -1
  83. package/handlers/index.d.ts +1 -1
  84. package/handlers/index.js +4 -11
  85. package/handlers/index.js.map +1 -1
  86. package/handlers/setupEventsTenant.js +3 -10
  87. package/handlers/setupEventsTenant.js.map +1 -1
  88. package/index.d.ts +8 -6
  89. package/index.js +46 -69
  90. package/index.js.map +1 -1
  91. package/package.json +19 -23
  92. package/tasks/EmptyTrashBinTaskDefinition.d.ts +26 -0
  93. package/tasks/EmptyTrashBinTaskDefinition.js +124 -0
  94. package/tasks/EmptyTrashBinTaskDefinition.js.map +1 -0
  95. package/tasks/createEmptyTrashBinsTask.d.ts +1 -2
  96. package/tasks/createEmptyTrashBinsTask.js +5 -114
  97. package/tasks/createEmptyTrashBinsTask.js.map +1 -1
  98. package/tasks/index.d.ts +1 -2
  99. package/tasks/index.js +1 -27
  100. package/tasks/index.js.map +1 -1
  101. package/types.d.ts +12 -12
  102. package/types.js +4 -7
  103. package/types.js.map +1 -1
  104. package/abstractions/IListEntries.d.ts +0 -7
  105. package/abstractions/IListEntries.js +0 -7
  106. package/abstractions/IListEntries.js.map +0 -1
  107. package/abstractions/IProcessEntry.d.ts +0 -4
  108. package/abstractions/IProcessEntry.js +0 -7
  109. package/abstractions/IProcessEntry.js.map +0 -1
  110. package/plugins/createBulkAction.d.ts +0 -10
  111. package/plugins/createBulkAction.js +0 -36
  112. package/plugins/createBulkAction.js.map +0 -1
  113. package/plugins/createBulkActionGraphQL.d.ts +0 -7
  114. package/plugins/createBulkActionGraphQL.js +0 -72
  115. package/plugins/createBulkActionGraphQL.js.map +0 -1
  116. package/plugins/createBulkActionTasks.d.ts +0 -9
  117. package/plugins/createBulkActionTasks.js +0 -135
  118. package/plugins/createBulkActionTasks.js.map +0 -1
  119. package/plugins/createDefaultGraphQL.d.ts +0 -3
  120. package/plugins/createDefaultGraphQL.js.map +0 -1
  121. package/plugins/index.d.ts +0 -2
  122. package/plugins/index.js +0 -29
  123. package/plugins/index.js.map +0 -1
  124. package/tasks/createBulkActionEntriesTasks.d.ts +0 -1
  125. package/tasks/createBulkActionEntriesTasks.js +0 -38
  126. package/tasks/createBulkActionEntriesTasks.js.map +0 -1
  127. package/useCases/DeleteEntry.d.ts +0 -10
  128. package/useCases/DeleteEntry.js +0 -26
  129. package/useCases/DeleteEntry.js.map +0 -1
  130. package/useCases/ListDeletedEntries.d.ts +0 -13
  131. package/useCases/ListDeletedEntries.js +0 -28
  132. package/useCases/ListDeletedEntries.js.map +0 -1
  133. package/useCases/ListLatestEntries.d.ts +0 -13
  134. package/useCases/ListLatestEntries.js +0 -28
  135. package/useCases/ListLatestEntries.js.map +0 -1
  136. package/useCases/ListNotPublishedEntries.d.ts +0 -13
  137. package/useCases/ListNotPublishedEntries.js +0 -34
  138. package/useCases/ListNotPublishedEntries.js.map +0 -1
  139. package/useCases/ListPublishedEntries.d.ts +0 -13
  140. package/useCases/ListPublishedEntries.js +0 -28
  141. package/useCases/ListPublishedEntries.js.map +0 -1
  142. package/useCases/MoveEntryToFolder.d.ts +0 -13
  143. package/useCases/MoveEntryToFolder.js +0 -23
  144. package/useCases/MoveEntryToFolder.js.map +0 -1
  145. package/useCases/MoveEntryToTrash.d.ts +0 -10
  146. package/useCases/MoveEntryToTrash.js +0 -26
  147. package/useCases/MoveEntryToTrash.js.map +0 -1
  148. package/useCases/PublishEntry.d.ts +0 -10
  149. package/useCases/PublishEntry.js +0 -20
  150. package/useCases/PublishEntry.js.map +0 -1
  151. package/useCases/RestoreEntryFromTrash.d.ts +0 -10
  152. package/useCases/RestoreEntryFromTrash.js +0 -24
  153. package/useCases/RestoreEntryFromTrash.js.map +0 -1
  154. package/useCases/UnpublishEntry.d.ts +0 -10
  155. package/useCases/UnpublishEntry.js +0 -20
  156. package/useCases/UnpublishEntry.js.map +0 -1
  157. package/useCases/index.d.ts +0 -10
  158. package/useCases/index.js +0 -117
  159. package/useCases/index.js.map +0 -1
  160. package/useCases/internals/ChildTaskCleanup/ChildTasksCleanup.js.map +0 -1
  161. package/useCases/internals/ChildTaskCleanup/index.d.ts +0 -1
  162. package/useCases/internals/ChildTaskCleanup/index.js +0 -18
  163. package/useCases/internals/ChildTaskCleanup/index.js.map +0 -1
  164. package/useCases/internals/CreateTasksByModel/CreateTasksByModel.d.ts +0 -13
  165. package/useCases/internals/CreateTasksByModel/CreateTasksByModel.js +0 -111
  166. package/useCases/internals/CreateTasksByModel/CreateTasksByModel.js.map +0 -1
  167. package/useCases/internals/CreateTasksByModel/TaskCache.js.map +0 -1
  168. package/useCases/internals/CreateTasksByModel/index.d.ts +0 -1
  169. package/useCases/internals/CreateTasksByModel/index.js +0 -18
  170. package/useCases/internals/CreateTasksByModel/index.js.map +0 -1
  171. package/useCases/internals/ProcessTask/ProcessTask.d.ts +0 -14
  172. package/useCases/internals/ProcessTask/ProcessTask.js +0 -81
  173. package/useCases/internals/ProcessTask/ProcessTask.js.map +0 -1
  174. package/useCases/internals/ProcessTask/Result.js.map +0 -1
  175. package/useCases/internals/ProcessTask/index.d.ts +0 -1
  176. package/useCases/internals/ProcessTask/index.js +0 -18
  177. package/useCases/internals/ProcessTask/index.js.map +0 -1
  178. package/useCases/internals/ProcessTasksByModel/ProcessTasksByModel.d.ts +0 -11
  179. package/useCases/internals/ProcessTasksByModel/ProcessTasksByModel.js +0 -67
  180. package/useCases/internals/ProcessTasksByModel/ProcessTasksByModel.js.map +0 -1
  181. package/useCases/internals/ProcessTasksByModel/index.d.ts +0 -1
  182. package/useCases/internals/ProcessTasksByModel/index.js +0 -18
  183. package/useCases/internals/ProcessTasksByModel/index.js.map +0 -1
  184. package/useCases/internals/index.d.ts +0 -4
  185. package/useCases/internals/index.js +0 -51
  186. package/useCases/internals/index.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-bulk-actions",
3
- "version": "6.0.0-alpha.5",
3
+ "version": "6.0.0-rc.1",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "description": "Webiny Headless CMS bulk actions",
6
7
  "keywords": [
@@ -13,33 +14,28 @@
13
14
  },
14
15
  "license": "MIT",
15
16
  "dependencies": {
16
- "@webiny/api-headless-cms": "6.0.0-alpha.5",
17
- "@webiny/handler": "6.0.0-alpha.5",
18
- "@webiny/handler-aws": "6.0.0-alpha.5",
19
- "@webiny/tasks": "6.0.0-alpha.5",
20
- "@webiny/utils": "6.0.0-alpha.5"
17
+ "@webiny/api-headless-cms": "6.0.0-rc.1",
18
+ "@webiny/feature": "6.0.0-rc.1",
19
+ "@webiny/handler": "6.0.0-rc.1",
20
+ "@webiny/handler-aws": "6.0.0-rc.1",
21
+ "@webiny/tasks": "6.0.0-rc.1",
22
+ "@webiny/utils": "6.0.0-rc.1"
21
23
  },
22
24
  "devDependencies": {
23
- "@webiny/api": "6.0.0-alpha.5",
24
- "@webiny/api-admin-users": "6.0.0-alpha.5",
25
- "@webiny/api-i18n": "6.0.0-alpha.5",
26
- "@webiny/api-security": "6.0.0-alpha.5",
27
- "@webiny/api-tenancy": "6.0.0-alpha.5",
28
- "@webiny/api-wcp": "6.0.0-alpha.5",
29
- "@webiny/handler-graphql": "6.0.0-alpha.5",
30
- "@webiny/plugins": "6.0.0-alpha.5",
31
- "@webiny/project-utils": "6.0.0-alpha.5",
32
- "@webiny/wcp": "6.0.0-alpha.5",
33
- "graphql": "15.9.0",
34
- "typescript": "5.3.3"
35
- },
36
- "scripts": {
37
- "build": "node ../cli/bin.js run build",
38
- "watch": "node ../cli/bin.js run watch"
25
+ "@webiny/api": "6.0.0-rc.1",
26
+ "@webiny/api-core": "6.0.0-rc.1",
27
+ "@webiny/build-tools": "6.0.0-rc.1",
28
+ "@webiny/handler-graphql": "6.0.0-rc.1",
29
+ "@webiny/plugins": "6.0.0-rc.1",
30
+ "@webiny/project-utils": "6.0.0-rc.1",
31
+ "@webiny/wcp": "6.0.0-rc.1",
32
+ "graphql": "16.12.0",
33
+ "typescript": "5.9.3",
34
+ "vitest": "4.0.18"
39
35
  },
40
36
  "publishConfig": {
41
37
  "access": "public",
42
38
  "directory": "dist"
43
39
  },
44
- "gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
40
+ "gitHead": "36d702721ff9ed39fb21d6f5fe7922a2a8716e63"
45
41
  }
@@ -0,0 +1,26 @@
1
+ import type { IEmptyTrashBinsInput, IEmptyTrashBinsOutput } from "../types.js";
2
+ import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
+ import { ListTenantsUseCase } from "@webiny/api-core/features/tenancy/ListTenants/index.js";
4
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
5
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
6
+ import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js";
7
+ import { ListDeletedEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
8
+ declare class EmptyTrashBinTask implements TaskDefinition.Interface<IEmptyTrashBinsInput, IEmptyTrashBinsOutput> {
9
+ private tenantContext;
10
+ private listTenants;
11
+ private listModels;
12
+ private listDeletedEntries;
13
+ private deleteEntry;
14
+ readonly isPrivate = true;
15
+ readonly id = "hcmsEntriesEmptyTrashBins";
16
+ readonly title = "Headless CMS - Empty all trash bins";
17
+ readonly description = "Delete all entries in the trash bin for each model in the system.";
18
+ readonly maxIterations = 120;
19
+ readonly databaseLogs = false;
20
+ constructor(tenantContext: TenantContext.Interface, listTenants: ListTenantsUseCase.Interface, listModels: ListModelsUseCase.Interface, listDeletedEntries: ListDeletedEntriesUseCase.Interface, deleteEntry: DeleteEntryUseCase.Interface);
21
+ run(params: TaskDefinition.RunParams<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>): Promise<TaskDefinition.Result<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>>;
22
+ }
23
+ export declare const EmptyTrashBinTaskDefinition: typeof EmptyTrashBinTask & {
24
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
25
+ };
26
+ export {};
@@ -0,0 +1,124 @@
1
+ import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
+ import { ListTenantsUseCase } from "@webiny/api-core/features/tenancy/ListTenants/index.js";
3
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
4
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
5
+ import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js";
6
+ import { ListDeletedEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
7
+ const calculateDateTimeString = () => {
8
+ // Retrieve the retention period from the environment variable WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS,
9
+ // or default to 90 days if not set or set to 0.
10
+ const retentionPeriodFromEnv = process.env["WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS"];
11
+ const retentionPeriod = retentionPeriodFromEnv && Number(retentionPeriodFromEnv) !== 0 ? Number(retentionPeriodFromEnv) : 90;
12
+
13
+ // Calculate the date-time by subtracting the retention period (in days) from the current date.
14
+ const currentDate = new Date();
15
+ currentDate.setDate(currentDate.getDate() - retentionPeriod);
16
+
17
+ // Return the calculated date-time string in ISO 8601 format.
18
+ return currentDate.toISOString();
19
+ };
20
+ class EmptyTrashBinTask {
21
+ isPrivate = true;
22
+ id = "hcmsEntriesEmptyTrashBins";
23
+ title = "Headless CMS - Empty all trash bins";
24
+ description = "Delete all entries in the trash bin for each model in the system.";
25
+ maxIterations = 120;
26
+ databaseLogs = false;
27
+ constructor(tenantContext, listTenants, listModels, listDeletedEntries, deleteEntry) {
28
+ this.tenantContext = tenantContext;
29
+ this.listTenants = listTenants;
30
+ this.listModels = listModels;
31
+ this.listDeletedEntries = listDeletedEntries;
32
+ this.deleteEntry = deleteEntry;
33
+ }
34
+ async run(params) {
35
+ const {
36
+ input,
37
+ controller
38
+ } = params;
39
+
40
+ // Abort the task if needed.
41
+ if (controller.runtime.isAborted()) {
42
+ return controller.response.aborted();
43
+ }
44
+
45
+ // Fetch all tenants, excluding those already processed.
46
+ const tenantsResult = await this.listTenants.execute();
47
+ const baseTenants = tenantsResult.value;
48
+ const executedTenantIds = input.executedTenantIds || [];
49
+ const tenants = baseTenants.filter(tenant => !executedTenantIds.includes(tenant.id));
50
+ let shouldTaskContinue = false;
51
+
52
+ // Iterate over each tenant.
53
+ await this.tenantContext.withEachTenant(tenants, async tenant => {
54
+ if (controller.runtime.isCloseToTimeout()) {
55
+ shouldTaskContinue = true;
56
+ return;
57
+ }
58
+ if (controller.runtime.isCloseToTimeout()) {
59
+ shouldTaskContinue = true;
60
+ return;
61
+ }
62
+
63
+ // List all non-private models.
64
+ const modelsResult = await this.listModels.execute({
65
+ includePrivate: false
66
+ });
67
+ const models = modelsResult.value;
68
+
69
+ // Process each model to delete trashed entries.
70
+ for (const model of models) {
71
+ // Query parameters for fetching deleted entries older than a minute ago.
72
+ const listEntriesParams = {
73
+ where: {
74
+ deletedOn_lt: calculateDateTimeString()
75
+ },
76
+ limit: 50
77
+ };
78
+
79
+ // Continue deleting entries while there are entries left to delete.
80
+ while (true) {
81
+ const listResult = await this.listDeletedEntries.execute(model, listEntriesParams);
82
+ const {
83
+ entries,
84
+ meta
85
+ } = listResult.value;
86
+ if (meta.totalCount === 0) {
87
+ break;
88
+ }
89
+ if (controller.runtime.isCloseToTimeout()) {
90
+ shouldTaskContinue = true;
91
+ break;
92
+ }
93
+ for (const entry of entries) {
94
+ if (controller.runtime.isCloseToTimeout()) {
95
+ shouldTaskContinue = true;
96
+ break;
97
+ }
98
+ // Delete each entry individually.
99
+ await this.deleteEntry.execute(model, entry.id, {
100
+ permanently: true
101
+ });
102
+ }
103
+ }
104
+ }
105
+
106
+ // If the task isn't continuing, add the tenant to the executed list.
107
+ if (!shouldTaskContinue) {
108
+ executedTenantIds.push(tenant.id);
109
+ }
110
+ });
111
+
112
+ // Continue the task or mark it as done based on the `shouldContinue` flag.
113
+ return shouldTaskContinue ? controller.response.continue({
114
+ ...input,
115
+ executedTenantIds
116
+ }) : controller.response.done("Task done: emptied the trash bin for all registered models.");
117
+ }
118
+ }
119
+ export const EmptyTrashBinTaskDefinition = TaskDefinition.createImplementation({
120
+ implementation: EmptyTrashBinTask,
121
+ dependencies: [TenantContext, ListTenantsUseCase, ListModelsUseCase, ListDeletedEntriesUseCase, DeleteEntryUseCase]
122
+ });
123
+
124
+ //# sourceMappingURL=EmptyTrashBinTaskDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TaskDefinition","ListTenantsUseCase","TenantContext","ListModelsUseCase","DeleteEntryUseCase","ListDeletedEntriesUseCase","calculateDateTimeString","retentionPeriodFromEnv","process","env","retentionPeriod","Number","currentDate","Date","setDate","getDate","toISOString","EmptyTrashBinTask","isPrivate","id","title","description","maxIterations","databaseLogs","constructor","tenantContext","listTenants","listModels","listDeletedEntries","deleteEntry","run","params","input","controller","runtime","isAborted","response","aborted","tenantsResult","execute","baseTenants","value","executedTenantIds","tenants","filter","tenant","includes","shouldTaskContinue","withEachTenant","isCloseToTimeout","modelsResult","includePrivate","models","model","listEntriesParams","where","deletedOn_lt","limit","listResult","entries","meta","totalCount","entry","permanently","push","continue","done","EmptyTrashBinTaskDefinition","createImplementation","implementation","dependencies"],"sources":["EmptyTrashBinTaskDefinition.ts"],"sourcesContent":["import type { IEmptyTrashBinsInput, IEmptyTrashBinsOutput } from \"~/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { ListTenantsUseCase } from \"@webiny/api-core/features/tenancy/ListTenants/index.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js\";\nimport { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\n\nconst calculateDateTimeString = () => {\n // Retrieve the retention period from the environment variable WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS,\n // or default to 90 days if not set or set to 0.\n const retentionPeriodFromEnv = process.env[\"WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS\"];\n const retentionPeriod =\n retentionPeriodFromEnv && Number(retentionPeriodFromEnv) !== 0\n ? Number(retentionPeriodFromEnv)\n : 90;\n\n // Calculate the date-time by subtracting the retention period (in days) from the current date.\n const currentDate = new Date();\n currentDate.setDate(currentDate.getDate() - retentionPeriod);\n\n // Return the calculated date-time string in ISO 8601 format.\n return currentDate.toISOString();\n};\n\nclass EmptyTrashBinTask\n implements TaskDefinition.Interface<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>\n{\n public readonly isPrivate = true;\n public readonly id = \"hcmsEntriesEmptyTrashBins\";\n public readonly title = \"Headless CMS - Empty all trash bins\";\n public readonly description =\n \"Delete all entries in the trash bin for each model in the system.\";\n public readonly maxIterations = 120;\n public readonly databaseLogs = false;\n\n constructor(\n private tenantContext: TenantContext.Interface,\n private listTenants: ListTenantsUseCase.Interface,\n private listModels: ListModelsUseCase.Interface,\n private listDeletedEntries: ListDeletedEntriesUseCase.Interface,\n private deleteEntry: DeleteEntryUseCase.Interface\n ) {}\n\n async run(\n params: TaskDefinition.RunParams<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>\n ): Promise<TaskDefinition.Result<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>> {\n const { input, controller } = params;\n\n // Abort the task if needed.\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n // Fetch all tenants, excluding those already processed.\n const tenantsResult = await this.listTenants.execute();\n const baseTenants = tenantsResult.value;\n const executedTenantIds = input.executedTenantIds || [];\n const tenants = baseTenants.filter(tenant => !executedTenantIds.includes(tenant.id));\n\n let shouldTaskContinue = false;\n\n // Iterate over each tenant.\n await this.tenantContext.withEachTenant(tenants, async tenant => {\n if (controller.runtime.isCloseToTimeout()) {\n shouldTaskContinue = true;\n return;\n }\n\n if (controller.runtime.isCloseToTimeout()) {\n shouldTaskContinue = true;\n return;\n }\n\n // List all non-private models.\n const modelsResult = await this.listModels.execute({ includePrivate: false });\n const models = modelsResult.value;\n\n // Process each model to delete trashed entries.\n for (const model of models) {\n // Query parameters for fetching deleted entries older than a minute ago.\n const listEntriesParams = {\n where: {\n deletedOn_lt: calculateDateTimeString()\n },\n limit: 50\n };\n\n // Continue deleting entries while there are entries left to delete.\n while (true) {\n const listResult = await this.listDeletedEntries.execute(\n model,\n listEntriesParams\n );\n const { entries, meta } = listResult.value;\n\n if (meta.totalCount === 0) {\n break;\n }\n\n if (controller.runtime.isCloseToTimeout()) {\n shouldTaskContinue = true;\n break;\n }\n for (const entry of entries) {\n if (controller.runtime.isCloseToTimeout()) {\n shouldTaskContinue = true;\n break;\n }\n // Delete each entry individually.\n await this.deleteEntry.execute(model, entry.id, { permanently: true });\n }\n }\n }\n\n // If the task isn't continuing, add the tenant to the executed list.\n if (!shouldTaskContinue) {\n executedTenantIds.push(tenant.id);\n }\n });\n\n // Continue the task or mark it as done based on the `shouldContinue` flag.\n return shouldTaskContinue\n ? controller.response.continue({ ...input, executedTenantIds })\n : controller.response.done(\n \"Task done: emptied the trash bin for all registered models.\"\n );\n }\n}\n\nexport const EmptyTrashBinTaskDefinition = TaskDefinition.createImplementation({\n implementation: EmptyTrashBinTask,\n dependencies: [\n TenantContext,\n ListTenantsUseCase,\n ListModelsUseCase,\n ListDeletedEntriesUseCase,\n DeleteEntryUseCase\n ]\n});\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,kBAAkB,QAAQ,wDAAwD;AAC3F,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,iBAAiB,QAAQ,oEAAoE;AACtG,SAASC,kBAAkB,QAAQ,qEAAqE;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,gBAAgB,CAAC,CAAC,EAAE;YACvCF,kBAAkB,GAAG,IAAI;YACzB;UACJ;UACA,KAAK,MAAMe,KAAK,IAAIH,OAAO,EAAE;YACzB,IAAI1B,UAAU,CAACC,OAAO,CAACe,gBAAgB,CAAC,CAAC,EAAE;cACvCF,kBAAkB,GAAG,IAAI;cACzB;YACJ;YACA;YACA,MAAM,IAAI,CAAClB,WAAW,CAACU,OAAO,CAACc,KAAK,EAAES,KAAK,CAAC3C,EAAE,EAAE;cAAE4C,WAAW,EAAE;YAAK,CAAC,CAAC;UAC1E;QACJ;MACJ;;MAEA;MACA,IAAI,CAAChB,kBAAkB,EAAE;QACrBL,iBAAiB,CAACsB,IAAI,CAACnB,MAAM,CAAC1B,EAAE,CAAC;MACrC;IACJ,CAAC,CAAC;;IAEF;IACA,OAAO4B,kBAAkB,GACnBd,UAAU,CAACG,QAAQ,CAAC6B,QAAQ,CAAC;MAAE,GAAGjC,KAAK;MAAEU;IAAkB,CAAC,CAAC,GAC7DT,UAAU,CAACG,QAAQ,CAAC8B,IAAI,CACpB,6DACJ,CAAC;EACX;AACJ;AAEA,OAAO,MAAMC,2BAA2B,GAAGnE,cAAc,CAACoE,oBAAoB,CAAC;EAC3EC,cAAc,EAAEpD,iBAAiB;EACjCqD,YAAY,EAAE,CACVpE,aAAa,EACbD,kBAAkB,EAClBE,iBAAiB,EACjBE,yBAAyB,EACzBD,kBAAkB;AAE1B,CAAC,CAAC","ignoreList":[]}
@@ -1,2 +1 @@
1
- import type { HcmsBulkActionsContext, IEmptyTrashBinsInput } from "../types";
2
- export declare const createEmptyTrashBinsTask: () => import("@webiny/tasks").TaskDefinitionPlugin<HcmsBulkActionsContext, IEmptyTrashBinsInput, import("@webiny/tasks").ITaskResponseDoneResultOutput>;
1
+ export declare const createEmptyTrashBinsTask: () => import("@webiny/api").ContextPlugin<import("@webiny/api/types.js").Context>;
@@ -1,118 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createEmptyTrashBinsTask = void 0;
7
- var _tasks = require("@webiny/tasks");
8
- var _useCases = require("../useCases");
9
- const calculateDateTimeString = () => {
10
- // Retrieve the retention period from the environment variable WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS,
11
- // or default to 90 days if not set or set to 0.
12
- const retentionPeriodFromEnv = process.env["WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS"];
13
- const retentionPeriod = retentionPeriodFromEnv && Number(retentionPeriodFromEnv) !== 0 ? Number(retentionPeriodFromEnv) : 90;
14
-
15
- // Calculate the date-time by subtracting the retention period (in days) from the current date.
16
- const currentDate = new Date();
17
- currentDate.setDate(currentDate.getDate() - retentionPeriod);
18
-
19
- // Return the calculated date-time string in ISO 8601 format.
20
- return currentDate.toISOString();
21
- };
22
- const createEmptyTrashBinsTask = () => {
23
- return (0, _tasks.createTaskDefinition)({
24
- isPrivate: true,
25
- id: "hcmsEntriesEmptyTrashBins",
26
- title: "Headless CMS - Empty all trash bins",
27
- description: "Delete all entries in the trash bin for each model in the system.",
28
- maxIterations: 120,
29
- disableDatabaseLogs: true,
30
- run: async params => {
31
- const {
32
- response,
33
- isAborted,
34
- context,
35
- input,
36
- isCloseToTimeout
37
- } = params;
38
-
39
- // Abort the task if needed.
40
- if (isAborted()) {
41
- return response.aborted();
42
- }
43
-
44
- // Fetch all tenants, excluding those already processed.
45
- const baseTenants = await context.tenancy.listTenants();
46
- const executedTenantIds = input.executedTenantIds || [];
47
- const tenants = baseTenants.filter(tenant => !executedTenantIds.includes(tenant.id));
48
- let shouldContinue = false; // Flag to check if task should continue.
49
-
50
- // Iterate over each tenant.
51
- await context.tenancy.withEachTenant(tenants, async tenant => {
52
- if (isCloseToTimeout()) {
53
- shouldContinue = true;
54
- return;
55
- }
56
-
57
- // Reloading locales for the current tenant to ensure the correct data is available before proceeding.
58
- await context.i18n.reloadLocales();
59
-
60
- // Fetch all locales for the tenant.
61
- const locales = context.i18n.getLocales();
62
- await context.i18n.withEachLocale(locales, async () => {
63
- if (isCloseToTimeout()) {
64
- shouldContinue = true;
65
- return;
66
- }
67
-
68
- // List all non-private models for the current locale.
69
- const models = await context.security.withoutAuthorization(async () => (await context.cms.listModels()).filter(m => !m.isPrivate));
70
-
71
- // Process each model to delete trashed entries.
72
- for (const model of models) {
73
- const list = (0, _useCases.createListDeletedEntries)(context); // List trashed entries.
74
- const mutation = (0, _useCases.createDeleteEntry)(context); // Mutation to delete entries.
75
-
76
- // Query parameters for fetching deleted entries older than a minute ago.
77
- const listEntriesParams = {
78
- where: {
79
- deletedOn_lt: calculateDateTimeString()
80
- },
81
- limit: 50
82
- };
83
- let result;
84
- // Continue deleting entries while there are entries left to delete.
85
- while ((result = await list.execute(model.modelId, listEntriesParams)) && result.meta.totalCount > 0) {
86
- if (isCloseToTimeout()) {
87
- shouldContinue = true;
88
- break;
89
- }
90
- for (const entry of result.entries) {
91
- if (isCloseToTimeout()) {
92
- shouldContinue = true;
93
- break;
94
- }
95
- // Delete each entry individually.
96
- await mutation.execute(model, entry.id);
97
- }
98
- }
99
- }
100
- });
101
-
102
- // If the task isn't continuing, add the tenant to the executed list.
103
- if (!shouldContinue) {
104
- executedTenantIds.push(tenant.id);
105
- }
106
- });
107
-
108
- // Continue the task or mark it as done based on the `shouldContinue` flag.
109
- return shouldContinue ? response.continue({
110
- ...input,
111
- executedTenantIds
112
- }) : response.done("Task done: emptied the trash bin for all registered models.");
113
- }
1
+ import { createContextPlugin } from "@webiny/api";
2
+ import { EmptyTrashBinTaskDefinition } from "./EmptyTrashBinTaskDefinition.js";
3
+ export const createEmptyTrashBinsTask = () => {
4
+ return createContextPlugin(context => {
5
+ context.container.register(EmptyTrashBinTaskDefinition);
114
6
  });
115
7
  };
116
- exports.createEmptyTrashBinsTask = createEmptyTrashBinsTask;
117
8
 
118
9
  //# sourceMappingURL=createEmptyTrashBinsTask.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_tasks","require","_useCases","calculateDateTimeString","retentionPeriodFromEnv","process","env","retentionPeriod","Number","currentDate","Date","setDate","getDate","toISOString","createEmptyTrashBinsTask","createTaskDefinition","isPrivate","id","title","description","maxIterations","disableDatabaseLogs","run","params","response","isAborted","context","input","isCloseToTimeout","aborted","baseTenants","tenancy","listTenants","executedTenantIds","tenants","filter","tenant","includes","shouldContinue","withEachTenant","i18n","reloadLocales","locales","getLocales","withEachLocale","models","security","withoutAuthorization","cms","listModels","m","model","list","createListDeletedEntries","mutation","createDeleteEntry","listEntriesParams","where","deletedOn_lt","limit","result","execute","modelId","meta","totalCount","entry","entries","push","continue","done","exports"],"sources":["createEmptyTrashBinsTask.ts"],"sourcesContent":["import { createTaskDefinition } from \"@webiny/tasks\";\nimport { createDeleteEntry, createListDeletedEntries } from \"~/useCases\";\nimport type {\n HcmsBulkActionsContext,\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput,\n IEmptyTrashBinsTaskParams\n} from \"~/types\";\n\nconst calculateDateTimeString = () => {\n // Retrieve the retention period from the environment variable WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS,\n // or default to 90 days if not set or set to 0.\n const retentionPeriodFromEnv = process.env[\"WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS\"];\n const retentionPeriod =\n retentionPeriodFromEnv && Number(retentionPeriodFromEnv) !== 0\n ? Number(retentionPeriodFromEnv)\n : 90;\n\n // Calculate the date-time by subtracting the retention period (in days) from the current date.\n const currentDate = new Date();\n currentDate.setDate(currentDate.getDate() - retentionPeriod);\n\n // Return the calculated date-time string in ISO 8601 format.\n return currentDate.toISOString();\n};\n\nexport const createEmptyTrashBinsTask = () => {\n return createTaskDefinition<\n HcmsBulkActionsContext,\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n >({\n isPrivate: true,\n id: \"hcmsEntriesEmptyTrashBins\",\n title: \"Headless CMS - Empty all trash bins\",\n description: \"Delete all entries in the trash bin for each model in the system.\",\n maxIterations: 120,\n disableDatabaseLogs: true,\n run: async (params: IEmptyTrashBinsTaskParams) => {\n const { response, isAborted, context, input, isCloseToTimeout } = params;\n\n // Abort the task if needed.\n if (isAborted()) {\n return response.aborted();\n }\n\n // Fetch all tenants, excluding those already processed.\n const baseTenants = await context.tenancy.listTenants();\n const executedTenantIds = input.executedTenantIds || [];\n const tenants = baseTenants.filter(tenant => !executedTenantIds.includes(tenant.id));\n let shouldContinue = false; // Flag to check if task should continue.\n\n // Iterate over each tenant.\n await context.tenancy.withEachTenant(tenants, async tenant => {\n if (isCloseToTimeout()) {\n shouldContinue = true;\n return;\n }\n\n // Reloading locales for the current tenant to ensure the correct data is available before proceeding.\n await context.i18n.reloadLocales();\n\n // Fetch all locales for the tenant.\n const locales = context.i18n.getLocales();\n await context.i18n.withEachLocale(locales, async () => {\n if (isCloseToTimeout()) {\n shouldContinue = true;\n return;\n }\n\n // List all non-private models for the current locale.\n const models = await context.security.withoutAuthorization(async () =>\n (await context.cms.listModels()).filter(m => !m.isPrivate)\n );\n\n // Process each model to delete trashed entries.\n for (const model of models) {\n const list = createListDeletedEntries(context); // List trashed entries.\n const mutation = createDeleteEntry(context); // Mutation to delete entries.\n\n // Query parameters for fetching deleted entries older than a minute ago.\n const listEntriesParams = {\n where: { deletedOn_lt: calculateDateTimeString() },\n limit: 50\n };\n\n let result;\n // Continue deleting entries while there are entries left to delete.\n while (\n (result = await list.execute(model.modelId, listEntriesParams)) &&\n result.meta.totalCount > 0\n ) {\n if (isCloseToTimeout()) {\n shouldContinue = true;\n break;\n }\n for (const entry of result.entries) {\n if (isCloseToTimeout()) {\n shouldContinue = true;\n break;\n }\n // Delete each entry individually.\n await mutation.execute(model, entry.id);\n }\n }\n }\n });\n\n // If the task isn't continuing, add the tenant to the executed list.\n if (!shouldContinue) {\n executedTenantIds.push(tenant.id);\n }\n });\n\n // Continue the task or mark it as done based on the `shouldContinue` flag.\n return shouldContinue\n ? response.continue({ ...input, executedTenantIds })\n : response.done(\"Task done: emptied the trash bin for all registered models.\");\n }\n });\n};\n"],"mappings":";;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,GAAG,CAAC,EAC5B;cACE,IAAIpC,gBAAgB,CAAC,CAAC,EAAE;gBACpBU,cAAc,GAAG,IAAI;gBACrB;cACJ;cACA,KAAK,MAAM2B,KAAK,IAAIL,MAAM,CAACM,OAAO,EAAE;gBAChC,IAAItC,gBAAgB,CAAC,CAAC,EAAE;kBACpBU,cAAc,GAAG,IAAI;kBACrB;gBACJ;gBACA;gBACA,MAAMgB,QAAQ,CAACO,OAAO,CAACV,KAAK,EAAEc,KAAK,CAAChD,EAAE,CAAC;cAC3C;YACJ;UACJ;QACJ,CAAC,CAAC;;QAEF;QACA,IAAI,CAACqB,cAAc,EAAE;UACjBL,iBAAiB,CAACkC,IAAI,CAAC/B,MAAM,CAACnB,EAAE,CAAC;QACrC;MACJ,CAAC,CAAC;;MAEF;MACA,OAAOqB,cAAc,GACfd,QAAQ,CAAC4C,QAAQ,CAAC;QAAE,GAAGzC,KAAK;QAAEM;MAAkB,CAAC,CAAC,GAClDT,QAAQ,CAAC6C,IAAI,CAAC,6DAA6D,CAAC;IACtF;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAxD,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createContextPlugin","EmptyTrashBinTaskDefinition","createEmptyTrashBinsTask","context","container","register"],"sources":["createEmptyTrashBinsTask.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport { EmptyTrashBinTaskDefinition } from \"./EmptyTrashBinTaskDefinition.js\";\n\nexport const createEmptyTrashBinsTask = () => {\n return createContextPlugin(context => {\n context.container.register(EmptyTrashBinTaskDefinition);\n });\n};\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,aAAa;AACjD,SAASC,2BAA2B;AAEpC,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,OAAOF,mBAAmB,CAACG,OAAO,IAAI;IAClCA,OAAO,CAACC,SAAS,CAACC,QAAQ,CAACJ,2BAA2B,CAAC;EAC3D,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
package/tasks/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export * from "./createBulkActionEntriesTasks";
2
- export * from "./createEmptyTrashBinsTask";
1
+ export * from "./createEmptyTrashBinsTask.js";
package/tasks/index.js CHANGED
@@ -1,29 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _createBulkActionEntriesTasks = require("./createBulkActionEntriesTasks");
7
- Object.keys(_createBulkActionEntriesTasks).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _createBulkActionEntriesTasks[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _createBulkActionEntriesTasks[key];
14
- }
15
- });
16
- });
17
- var _createEmptyTrashBinsTask = require("./createEmptyTrashBinsTask");
18
- Object.keys(_createEmptyTrashBinsTask).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _createEmptyTrashBinsTask[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _createEmptyTrashBinsTask[key];
25
- }
26
- });
27
- });
1
+ export * from "./createEmptyTrashBinsTask.js";
28
2
 
29
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_createBulkActionEntriesTasks","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_createEmptyTrashBinsTask"],"sources":["index.ts"],"sourcesContent":["export * from \"./createBulkActionEntriesTasks\";\nexport * from \"./createEmptyTrashBinsTask\";\n"],"mappings":";;;;;AAAA,IAAAA,6BAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,6BAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,6BAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,6BAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,yBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,yBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,yBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,yBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createEmptyTrashBinsTask.js\";\n"],"mappings":"AAAA","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { CmsContext } from "@webiny/api-headless-cms/types";
2
- import type { Context as BaseContext } from "@webiny/handler/types";
3
- import type { Context as TasksContext, ITaskResponseDoneResultOutput, ITaskRunParams } from "@webiny/tasks/types";
4
- import type { SecurityIdentity } from "@webiny/api-security/types";
1
+ import type { CmsContext } from "@webiny/api-headless-cms/types/index.js";
2
+ import type { Context as BaseContext } from "@webiny/handler/types.js";
3
+ import type { Context as TasksContext, ITaskIdentity } from "@webiny/tasks/types.js";
4
+ import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
5
5
  export interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {
6
6
  }
7
7
  /**
@@ -11,15 +11,15 @@ export interface IBulkActionOperationInput {
11
11
  modelId: string;
12
12
  ids: string[];
13
13
  data?: Record<string, any>;
14
- identity: SecurityIdentity;
14
+ identity: ITaskIdentity;
15
15
  done?: string[];
16
16
  failed?: string[];
17
17
  }
18
- export interface IBulkActionOperationOutput extends ITaskResponseDoneResultOutput {
18
+ export interface IBulkActionOperationOutput {
19
19
  done: string[];
20
20
  failed: string[];
21
21
  }
22
- export type IBulkActionOperationTaskParams = ITaskRunParams<HcmsBulkActionsContext, IBulkActionOperationInput, IBulkActionOperationOutput>;
22
+ export type IBulkActionOperationTaskParams = TaskDefinition.RunParams<IBulkActionOperationInput, IBulkActionOperationOutput>;
23
23
  /**
24
24
  * Bulk Action Operation By Model
25
25
  */
@@ -31,23 +31,23 @@ export declare enum BulkActionOperationByModelAction {
31
31
  }
32
32
  export interface IBulkActionOperationByModelInput {
33
33
  modelId: string;
34
- identity?: SecurityIdentity;
34
+ identity?: ITaskIdentity;
35
35
  where?: Record<string, any>;
36
36
  search?: string;
37
37
  after?: string | null;
38
38
  data?: Record<string, any>;
39
39
  action?: BulkActionOperationByModelAction;
40
40
  }
41
- export interface IBulkActionOperationByModelOutput extends ITaskResponseDoneResultOutput {
41
+ export interface IBulkActionOperationByModelOutput {
42
42
  done: string[];
43
43
  failed: string[];
44
44
  }
45
- export type IBulkActionOperationByModelTaskParams = ITaskRunParams<HcmsBulkActionsContext, IBulkActionOperationByModelInput, IBulkActionOperationByModelOutput>;
45
+ export type IBulkActionOperationByModelTaskParams = TaskDefinition.RunParams<IBulkActionOperationByModelInput, IBulkActionOperationByModelOutput>;
46
46
  /**
47
47
  * Empty Trash Bin
48
48
  */
49
49
  export interface IEmptyTrashBinsInput {
50
50
  executedTenantIds?: string[] | null;
51
51
  }
52
- export type IEmptyTrashBinsOutput = ITaskResponseDoneResultOutput;
53
- export type IEmptyTrashBinsTaskParams = ITaskRunParams<HcmsBulkActionsContext, IEmptyTrashBinsInput, IEmptyTrashBinsOutput>;
52
+ export type IEmptyTrashBinsOutput = TaskDefinition.ResultDone;
53
+ export type IEmptyTrashBinsTaskParams = TaskDefinition.RunParams<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>;
package/types.js CHANGED
@@ -1,22 +1,19 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.BulkActionOperationByModelAction = void 0;
7
1
  /**
8
2
  * Bulk Action Operation
9
3
  */
4
+
10
5
  /**
11
6
  * Bulk Action Operation By Model
12
7
  */
13
- let BulkActionOperationByModelAction = exports.BulkActionOperationByModelAction = /*#__PURE__*/function (BulkActionOperationByModelAction) {
8
+
9
+ export let BulkActionOperationByModelAction = /*#__PURE__*/function (BulkActionOperationByModelAction) {
14
10
  BulkActionOperationByModelAction["CREATE_SUBTASKS"] = "CREATE_SUBTASKS";
15
11
  BulkActionOperationByModelAction["CHECK_MORE_SUBTASKS"] = "CHECK_MORE_SUBTASKS";
16
12
  BulkActionOperationByModelAction["PROCESS_SUBTASKS"] = "PROCESS_SUBTASKS";
17
13
  BulkActionOperationByModelAction["END_TASK"] = "END_TASK";
18
14
  return BulkActionOperationByModelAction;
19
15
  }({});
16
+
20
17
  /**
21
18
  * Empty Trash Bin
22
19
  */
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["BulkActionOperationByModelAction","exports"],"sources":["types.ts"],"sourcesContent":["import type { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport type { Context as BaseContext } from \"@webiny/handler/types\";\nimport type {\n Context as TasksContext,\n ITaskResponseDoneResultOutput,\n ITaskRunParams\n} from \"@webiny/tasks/types\";\nimport type { SecurityIdentity } from \"@webiny/api-security/types\";\n\nexport interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {}\n\n/**\n * Bulk Action Operation\n */\n\nexport interface IBulkActionOperationInput {\n modelId: string;\n ids: string[];\n data?: Record<string, any>;\n identity: SecurityIdentity;\n done?: string[];\n failed?: string[];\n}\n\nexport interface IBulkActionOperationOutput extends ITaskResponseDoneResultOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationTaskParams = ITaskRunParams<\n HcmsBulkActionsContext,\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n>;\n\n/**\n * Bulk Action Operation By Model\n */\n\nexport enum BulkActionOperationByModelAction {\n CREATE_SUBTASKS = \"CREATE_SUBTASKS\",\n CHECK_MORE_SUBTASKS = \"CHECK_MORE_SUBTASKS\",\n PROCESS_SUBTASKS = \"PROCESS_SUBTASKS\",\n END_TASK = \"END_TASK\"\n}\n\nexport interface IBulkActionOperationByModelInput {\n modelId: string;\n identity?: SecurityIdentity;\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n data?: Record<string, any>;\n action?: BulkActionOperationByModelAction;\n}\n\nexport interface IBulkActionOperationByModelOutput extends ITaskResponseDoneResultOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationByModelTaskParams = ITaskRunParams<\n HcmsBulkActionsContext,\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n>;\n\n/**\n * Empty Trash Bin\n */\n\nexport interface IEmptyTrashBinsInput {\n executedTenantIds?: string[] | null;\n}\n\nexport type IEmptyTrashBinsOutput = ITaskResponseDoneResultOutput;\n\nexport type IEmptyTrashBinsTaskParams = ITaskRunParams<\n HcmsBulkActionsContext,\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n>;\n"],"mappings":";;;;;;AAWA;AACA;AACA;AAsBA;AACA;AACA;AAFA,IAIYA,gCAAgC,GAAAC,OAAA,CAAAD,gCAAA,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA;AA4B5C;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["BulkActionOperationByModelAction"],"sources":["types.ts"],"sourcesContent":["import type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { Context as TasksContext, ITaskIdentity } from \"@webiny/tasks/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {}\n\n/**\n * Bulk Action Operation\n */\n\nexport interface IBulkActionOperationInput {\n modelId: string;\n ids: string[];\n data?: Record<string, any>;\n identity: ITaskIdentity;\n done?: string[];\n failed?: string[];\n}\n\nexport interface IBulkActionOperationOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n>;\n\n/**\n * Bulk Action Operation By Model\n */\n\nexport enum BulkActionOperationByModelAction {\n CREATE_SUBTASKS = \"CREATE_SUBTASKS\",\n CHECK_MORE_SUBTASKS = \"CHECK_MORE_SUBTASKS\",\n PROCESS_SUBTASKS = \"PROCESS_SUBTASKS\",\n END_TASK = \"END_TASK\"\n}\n\nexport interface IBulkActionOperationByModelInput {\n modelId: string;\n identity?: ITaskIdentity;\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n data?: Record<string, any>;\n action?: BulkActionOperationByModelAction;\n}\n\nexport interface IBulkActionOperationByModelOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationByModelTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n>;\n\n/**\n * Empty Trash Bin\n */\n\nexport interface IEmptyTrashBinsInput {\n executedTenantIds?: string[] | null;\n}\n\nexport type IEmptyTrashBinsOutput = TaskDefinition.ResultDone;\n\nexport type IEmptyTrashBinsTaskParams = TaskDefinition.RunParams<\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n>;\n"],"mappings":"AAOA;AACA;AACA;;AAqBA;AACA;AACA;;AAEA,WAAYA,gCAAgC,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA;;AA2B5C;AACA;AACA","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- import type { CmsEntry, CmsEntryListParams, CmsEntryMeta } from "@webiny/api-headless-cms/types";
2
- export interface IListEntries {
3
- execute: (modelId: string, params: CmsEntryListParams) => Promise<{
4
- entries: CmsEntry[];
5
- meta: CmsEntryMeta;
6
- }>;
7
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=IListEntries.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["IListEntries.ts"],"sourcesContent":["import type { CmsEntry, CmsEntryListParams, CmsEntryMeta } from \"@webiny/api-headless-cms/types\";\n\nexport interface IListEntries {\n execute: (\n modelId: string,\n params: CmsEntryListParams\n ) => Promise<{ entries: CmsEntry[]; meta: CmsEntryMeta }>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import type { CmsModel } from "@webiny/api-headless-cms/types";
2
- export interface IProcessEntry {
3
- execute: (model: CmsModel, id: string, data?: any) => Promise<void>;
4
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=IProcessEntry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["IProcessEntry.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface IProcessEntry {\n execute: (model: CmsModel, id: string, data?: any) => Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import type { IListEntries, IProcessEntry } from "../abstractions";
2
- import type { HcmsBulkActionsContext } from "../types";
3
- export interface CreateBulkActionConfig {
4
- name: string;
5
- dataLoader: (context: HcmsBulkActionsContext) => IListEntries;
6
- dataProcessor: (context: HcmsBulkActionsContext) => IProcessEntry;
7
- modelIds?: string[];
8
- batchSize?: number;
9
- }
10
- export declare const createBulkAction: (config: CreateBulkActionConfig) => (import("@webiny/api").ContextPlugin<HcmsBulkActionsContext> | (import("@webiny/tasks").TaskDefinitionPlugin<HcmsBulkActionsContext, import("../types").IBulkActionOperationByModelInput, import("../types").IBulkActionOperationByModelOutput> | import("@webiny/tasks").TaskDefinitionPlugin<HcmsBulkActionsContext, import("../types").IBulkActionOperationInput, import("../types").IBulkActionOperationOutput>)[])[];
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createBulkAction = void 0;
7
- var _createBulkActionGraphQL = require("./createBulkActionGraphQL");
8
- var _createBulkActionTasks = require("./createBulkActionTasks");
9
- function toPascalCase(str) {
10
- // Step 1: Remove non-alphanumeric characters and replace them with spaces
11
- str = str.replace(/[^a-zA-Z0-9]+/g, " ");
12
-
13
- // Step 2: Split the string into words
14
- const words = str.split(" ");
15
-
16
- // Step 3: Capitalize the first letter of each word
17
- const capitalizedWords = words.map(word => word.charAt(0).toUpperCase() + word.slice(1));
18
-
19
- // Step 4: Join all the capitalized words together
20
- return capitalizedWords.join("");
21
- }
22
- const createBulkAction = config => {
23
- const name = toPascalCase(config.name);
24
- return [(0, _createBulkActionTasks.createBulkActionTasks)({
25
- name,
26
- dataLoader: config.dataLoader,
27
- dataProcessor: config.dataProcessor,
28
- batchSize: config.batchSize
29
- }), (0, _createBulkActionGraphQL.createBulkActionGraphQL)({
30
- name,
31
- modelIds: config.modelIds
32
- })];
33
- };
34
- exports.createBulkAction = createBulkAction;
35
-
36
- //# sourceMappingURL=createBulkAction.js.map