@webiny/api-headless-cms-bulk-actions 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.a85ef555b2

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 (58) hide show
  1. package/HcmsBulkActionsFeature.d.ts +7 -0
  2. package/HcmsBulkActionsFeature.js +32 -0
  3. package/HcmsBulkActionsFeature.js.map +1 -0
  4. package/features/EntriesBulkAction/createBulkActionTasks.d.ts +66 -4
  5. package/features/EntriesBulkAction/createBulkActionTasks.js +165 -118
  6. package/features/EntriesBulkAction/createBulkActionTasks.js.map +1 -1
  7. package/features/EntriesBulkAction/internals/ChildTasksCleanup.d.ts +9 -6
  8. package/features/EntriesBulkAction/internals/ChildTasksCleanup.js +19 -10
  9. package/features/EntriesBulkAction/internals/ChildTasksCleanup.js.map +1 -1
  10. package/features/EntriesBulkAction/internals/CreateTasksByModel.d.ts +5 -4
  11. package/features/EntriesBulkAction/internals/CreateTasksByModel.js +8 -7
  12. package/features/EntriesBulkAction/internals/CreateTasksByModel.js.map +1 -1
  13. package/features/EntriesBulkAction/internals/ProcessTask.d.ts +3 -1
  14. package/features/EntriesBulkAction/internals/ProcessTask.js +6 -2
  15. package/features/EntriesBulkAction/internals/ProcessTask.js.map +1 -1
  16. package/features/EntriesBulkAction/internals/ProcessTasksByModel.d.ts +3 -3
  17. package/features/EntriesBulkAction/internals/ProcessTasksByModel.js +5 -3
  18. package/features/EntriesBulkAction/internals/ProcessTasksByModel.js.map +1 -1
  19. package/features/EntriesBulkAction/internals/TaskCache.d.ts +7 -5
  20. package/features/EntriesBulkAction/internals/TaskCache.js +10 -4
  21. package/features/EntriesBulkAction/internals/TaskCache.js.map +1 -1
  22. package/graphql/BulkActionsGraphQLSchema.d.ts +12 -0
  23. package/graphql/BulkActionsGraphQLSchema.js +106 -0
  24. package/graphql/BulkActionsGraphQLSchema.js.map +1 -0
  25. package/graphql/createBulkActionGraphQL.js +21 -18
  26. package/graphql/createBulkActionGraphQL.js.map +1 -1
  27. package/graphql/createDefaultGraphQL.d.ts +7 -2
  28. package/graphql/createDefaultGraphQL.js +41 -39
  29. package/graphql/createDefaultGraphQL.js.map +1 -1
  30. package/index.d.ts +2 -7
  31. package/index.js +1 -46
  32. package/package.json +17 -15
  33. package/tasks/{EmptyTrashBinTaskDefinition.d.ts → EmptyTrashBinTask.d.ts} +9 -4
  34. package/tasks/{EmptyTrashBinTaskDefinition.js → EmptyTrashBinTask.js} +32 -17
  35. package/tasks/EmptyTrashBinTask.js.map +1 -0
  36. package/types.d.ts +4 -2
  37. package/types.js.map +1 -1
  38. package/features/BulkActionContext/abstractions.d.ts +0 -5
  39. package/features/BulkActionContext/abstractions.js +0 -5
  40. package/features/BulkActionContext/abstractions.js.map +0 -1
  41. package/features/BulkActionContext/index.d.ts +0 -1
  42. package/features/BulkActionContext/index.js +0 -1
  43. package/handlers/eventBridgeEventHandler.d.ts +0 -1
  44. package/handlers/eventBridgeEventHandler.js +0 -28
  45. package/handlers/eventBridgeEventHandler.js.map +0 -1
  46. package/handlers/index.d.ts +0 -1
  47. package/handlers/index.js +0 -9
  48. package/handlers/index.js.map +0 -1
  49. package/handlers/setupEventsTenant.d.ts +0 -1
  50. package/handlers/setupEventsTenant.js +0 -10
  51. package/handlers/setupEventsTenant.js.map +0 -1
  52. package/index.js.map +0 -1
  53. package/tasks/EmptyTrashBinTaskDefinition.js.map +0 -1
  54. package/tasks/createEmptyTrashBinsTask.d.ts +0 -1
  55. package/tasks/createEmptyTrashBinsTask.js +0 -8
  56. package/tasks/createEmptyTrashBinsTask.js.map +0 -1
  57. package/tasks/index.d.ts +0 -1
  58. package/tasks/index.js +0 -1
@@ -2,12 +2,12 @@ import { TaskCache } from "./TaskCache.js";
2
2
  import { BulkActionOperationByModelAction } from "../../../types.js";
3
3
  const MAX_TASK_LIST_LENGTH = 10;
4
4
  class CreateTasksByModel {
5
- constructor(context, getModel, bulkAction, taskDefinition, batchSize){
5
+ constructor(getModel, triggerTask, bulkAction, taskDefinition, batchSize, logger){
6
6
  this.getModel = getModel;
7
- this.taskCache = new TaskCache(taskDefinition);
7
+ this.taskCache = new TaskCache(taskDefinition, logger);
8
8
  this.batchSize = batchSize;
9
9
  this.bulkAction = bulkAction;
10
- this.context = context;
10
+ this.triggerTask = triggerTask;
11
11
  }
12
12
  async execute(params) {
13
13
  const { input, controller } = params;
@@ -24,7 +24,7 @@ class CreateTasksByModel {
24
24
  while(true){
25
25
  if (controller.runtime.isAborted()) return controller.response.aborted();
26
26
  if (controller.runtime.isCloseToTimeout()) {
27
- await this.taskCache.triggerTask(this.context, controller.state.getTask());
27
+ await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());
28
28
  return controller.response.continue({
29
29
  ...input,
30
30
  action: BulkActionOperationByModelAction.PROCESS_SUBTASKS
@@ -36,14 +36,14 @@ class CreateTasksByModel {
36
36
  action: BulkActionOperationByModelAction.END_TASK
37
37
  });
38
38
  if (this.taskCache.getTasksLength() === MAX_TASK_LIST_LENGTH) {
39
- await this.taskCache.triggerTask(this.context, controller.state.getTask());
39
+ await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());
40
40
  return controller.response.continue({
41
41
  ...input,
42
42
  action: BulkActionOperationByModelAction.PROCESS_SUBTASKS
43
43
  });
44
44
  }
45
45
  if (0 === entries.length) {
46
- await this.taskCache.triggerTask(this.context, controller.state.getTask());
46
+ await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());
47
47
  return controller.response.continue({
48
48
  ...input,
49
49
  action: BulkActionOperationByModelAction.PROCESS_SUBTASKS
@@ -52,13 +52,14 @@ class CreateTasksByModel {
52
52
  const ids = [];
53
53
  for(let i = 0; i < entries.length; i++)ids.push(entries[i].id);
54
54
  if (ids.length > 0) this.taskCache.cacheTask({
55
+ actionName: input.actionName,
55
56
  modelId: input.modelId,
56
57
  identity: input.identity,
57
58
  data: input.data,
58
59
  ids
59
60
  });
60
61
  if (!meta.hasMoreItems || !meta.cursor) {
61
- await this.taskCache.triggerTask(this.context, controller.state.getTask());
62
+ await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());
62
63
  return controller.response.continue({
63
64
  ...input,
64
65
  action: BulkActionOperationByModelAction.PROCESS_SUBTASKS
@@ -1 +1 @@
1
- {"version":3,"file":"features/EntriesBulkAction/internals/CreateTasksByModel.js","sources":["../../../../src/features/EntriesBulkAction/internals/CreateTasksByModel.ts"],"sourcesContent":["import type { CmsEntryListParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport { TaskCache } from \"./TaskCache.js\";\nimport type { IBulkActionOperationByModelTaskParams } from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { BulkActionContext } from \"~/features/BulkActionContext/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\n\nconst MAX_TASK_LIST_LENGTH = 10;\n\n/**\n * The `CreateTasksByModel` class handles the execution of a task to process entries in batches.\n */\nexport class CreateTasksByModel {\n private readonly taskCache: TaskCache;\n private readonly batchSize: number;\n private readonly bulkAction: EntriesBulkAction.Interface;\n private readonly context: BulkActionContext.Interface;\n private readonly getModel: GetModelUseCase.Interface;\n\n constructor(\n context: BulkActionContext.Interface,\n getModel: GetModelUseCase.Interface,\n bulkAction: EntriesBulkAction.Interface,\n taskDefinition: string,\n batchSize: number\n ) {\n this.getModel = getModel;\n this.taskCache = new TaskCache(taskDefinition);\n this.batchSize = batchSize;\n this.bulkAction = bulkAction;\n this.context = context;\n }\n\n async execute(params: IBulkActionOperationByModelTaskParams) {\n const { input, controller } = params;\n\n try {\n const modelResult = await this.getModel.execute(input.modelId);\n\n if (modelResult.isFail()) {\n return controller.response.error(`Model with ${input.modelId} not found!`);\n }\n\n const model = modelResult.value;\n\n const listEntriesParams: CmsEntryListParams = {\n where: input.where,\n search: input.search,\n after: input.after,\n limit: this.batchSize\n };\n\n while (true) {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n await this.taskCache.triggerTask(this.context, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // List entries from the HCMS based on the provided query\n const { entries, meta } = await this.bulkAction.loadData(model, listEntriesParams);\n\n // End the task if no entries match the query\n if (meta.totalCount === 0) {\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.END_TASK\n });\n }\n\n // Continue processing if we are reached the task list length limit\n if (this.taskCache.getTasksLength() === MAX_TASK_LIST_LENGTH) {\n await this.taskCache.triggerTask(this.context, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // Continue processing if no entries are returned in the current batch\n if (entries.length === 0) {\n await this.taskCache.triggerTask(this.context, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // Extract entry IDs\n const ids: string[] = [];\n for (let i = 0; i < entries.length; i++) {\n ids.push(entries[i].id);\n }\n\n if (ids.length > 0) {\n // Cache the task with the entry IDs\n this.taskCache.cacheTask({\n modelId: input.modelId,\n identity: input.identity,\n data: input.data,\n ids\n });\n }\n\n // Continue processing if there are no more entries or pagination is complete\n if (!meta.hasMoreItems || !meta.cursor) {\n await this.taskCache.triggerTask(this.context, controller.state.getTask());\n\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n listEntriesParams.after = meta.cursor;\n }\n } catch (ex) {\n return controller.response.error(ex.message ?? `Error while creating task.`);\n }\n }\n}\n"],"names":["MAX_TASK_LIST_LENGTH","CreateTasksByModel","context","getModel","bulkAction","taskDefinition","batchSize","TaskCache","params","input","controller","modelResult","model","listEntriesParams","BulkActionOperationByModelAction","entries","meta","ids","i","ex"],"mappings":";;AAQA,MAAMA,uBAAuB;AAK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AEAD,kBAAkB,KAAK,GAAGG,KAAK,MAAM;YACzC;QACJ,EAAE,OAAOG,IAAI;YACT,OAAOT,WAAW,QAAQ,CAAC,KAAK,CAACS,GAAG,OAAO,IAAI;QACnD;IACJ;AACJ"}
1
+ {"version":3,"file":"features/EntriesBulkAction/internals/CreateTasksByModel.js","sources":["../../../../src/features/EntriesBulkAction/internals/CreateTasksByModel.ts"],"sourcesContent":["import type { CmsEntryListParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport { TaskCache } from \"./TaskCache.js\";\nimport type { IBulkActionOperationByModelTaskParams } from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport type { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport type { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\nimport type { Logger } from \"@webiny/api-core/features/logger/index.js\";\n\nconst MAX_TASK_LIST_LENGTH = 10;\n\n/**\n * The `CreateTasksByModel` class handles the execution of a task to process entries in batches.\n */\nexport class CreateTasksByModel {\n private readonly taskCache: TaskCache;\n private readonly batchSize: number;\n private readonly bulkAction: EntriesBulkAction.Interface;\n private readonly triggerTask: TriggerTaskUseCase.Interface;\n private readonly getModel: GetModelUseCase.Interface;\n\n constructor(\n getModel: GetModelUseCase.Interface,\n triggerTask: TriggerTaskUseCase.Interface,\n bulkAction: EntriesBulkAction.Interface,\n taskDefinition: string,\n batchSize: number,\n logger: Logger.Interface\n ) {\n this.getModel = getModel;\n this.taskCache = new TaskCache(taskDefinition, logger);\n this.batchSize = batchSize;\n this.bulkAction = bulkAction;\n this.triggerTask = triggerTask;\n }\n\n async execute(params: IBulkActionOperationByModelTaskParams) {\n const { input, controller } = params;\n\n try {\n const modelResult = await this.getModel.execute(input.modelId);\n\n if (modelResult.isFail()) {\n return controller.response.error(`Model with ${input.modelId} not found!`);\n }\n\n const model = modelResult.value;\n\n const listEntriesParams: CmsEntryListParams = {\n where: input.where,\n search: input.search,\n after: input.after,\n limit: this.batchSize\n };\n\n while (true) {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // List entries from the HCMS based on the provided query\n const { entries, meta } = await this.bulkAction.loadData(model, listEntriesParams);\n\n // End the task if no entries match the query\n if (meta.totalCount === 0) {\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.END_TASK\n });\n }\n\n // Continue processing if we are reached the task list length limit\n if (this.taskCache.getTasksLength() === MAX_TASK_LIST_LENGTH) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // Continue processing if no entries are returned in the current batch\n if (entries.length === 0) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n // Extract entry IDs\n const ids: string[] = [];\n for (let i = 0; i < entries.length; i++) {\n ids.push(entries[i].id);\n }\n\n if (ids.length > 0) {\n this.taskCache.cacheTask({\n actionName: input.actionName,\n modelId: input.modelId,\n identity: input.identity,\n data: input.data,\n ids\n });\n }\n\n // Continue processing if there are no more entries or pagination is complete\n if (!meta.hasMoreItems || !meta.cursor) {\n await this.taskCache.triggerTask(this.triggerTask, controller.state.getTask());\n\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n listEntriesParams.after = meta.cursor;\n }\n } catch (ex) {\n return controller.response.error(ex.message ?? `Error while creating task.`);\n }\n }\n}\n"],"names":["MAX_TASK_LIST_LENGTH","CreateTasksByModel","getModel","triggerTask","bulkAction","taskDefinition","batchSize","logger","TaskCache","params","input","controller","modelResult","model","listEntriesParams","BulkActionOperationByModelAction","entries","meta","ids","i","ex"],"mappings":";;AASA,MAAMA,uBAAuB;AAKtB,MAAMC;IAOT,YACIC,QAAmC,EACnCC,WAAyC,EACzCC,UAAuC,EACvCC,cAAsB,EACtBC,SAAiB,EACjBC,MAAwB,CAC1B;QACE,IAAI,CAAC,QAAQ,GAAGL;QAChB,IAAI,CAAC,SAAS,GAAG,IAAIM,UAAUH,gBAAgBE;QAC/C,IAAI,CAAC,SAAS,GAAGD;QACjB,IAAI,CAAC,UAAU,GAAGF;QAClB,IAAI,CAAC,WAAW,GAAGD;IACvB;IAEA,MAAM,QAAQM,MAA6C,EAAE;QACzD,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;QAE9B,IAAI;YACA,MAAMG,cAAc,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACF,MAAM,OAAO;YAE7D,IAAIE,YAAY,MAAM,IAClB,OAAOD,WAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAED,MAAM,OAAO,CAAC,WAAW,CAAC;YAG7E,MAAMG,QAAQD,YAAY,KAAK;YAE/B,MAAME,oBAAwC;gBAC1C,OAAOJ,MAAM,KAAK;gBAClB,QAAQA,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,OAAO,IAAI,CAAC,SAAS;YACzB;YAEA,MAAO,KAAM;gBACT,IAAIC,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;gBAC/B,IAAIA,WAAW,OAAO,CAAC,gBAAgB,IAAI;oBAC9C,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAEA,WAAW,KAAK,CAAC,OAAO;oBAC3E,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAAC;wBAChC,GAAGD,KAAK;wBACR,QAAQK,iCAAiC,gBAAgB;oBAC7D;gBACJ;gBAGA,MAAM,EAA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WAAW,EAAEN,WAAW,KAAK,CAAC,OAAO;oBAE3E,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAAC;wBAChC,GAAGD,KAAK;wBACR,QAAQK,iCAAiC,gBAAgB;oBAC7D;gBACJ;gBAEAD,kBAAkB,KAAK,GAAGG,KAAK,MAAM;YACzC;QACJ,EAAE,OAAOG,IAAI;YACT,OAAOT,WAAW,QAAQ,CAAC,KAAK,CAACS,GAAG,OAAO,IAAI;QACnD;IACJ;AACJ"}
@@ -1,6 +1,7 @@
1
1
  import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
2
2
  import { EntriesBulkAction } from "../../../features/EntriesBulkAction/abstractions.js";
3
3
  import type { IBulkActionOperationTaskParams } from "../../../types.js";
4
+ import type { Logger } from "@webiny/api-core/features/logger/index.js";
4
5
  /**
5
6
  * The `ProcessTask` class is responsible for processing a batch of entries
6
7
  * based on the provided parameters. It uses a gateway to perform the actual
@@ -10,7 +11,8 @@ import type { IBulkActionOperationTaskParams } from "../../../types.js";
10
11
  export declare class ProcessTask {
11
12
  private bulkAction;
12
13
  private getModel;
14
+ private logger;
13
15
  private readonly result;
14
- constructor(bulkAction: EntriesBulkAction.Interface, getModel: GetModelUseCase.Interface);
16
+ constructor(bulkAction: EntriesBulkAction.Interface, getModel: GetModelUseCase.Interface, logger: Logger.Interface);
15
17
  execute({ input, controller }: IBulkActionOperationTaskParams): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskResultAborted | import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskResultError | import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").TaskDefinition.ResultContinue<import("~/types.js").IBulkActionOperationInput> | import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").TaskDefinition.ResultDone<import("~/types.js").IBulkActionOperationOutput>>;
16
18
  }
@@ -1,8 +1,9 @@
1
1
  import { ProcessTaskResult } from "./ProcessTaskResult.js";
2
2
  class ProcessTask {
3
- constructor(bulkAction, getModel){
3
+ constructor(bulkAction, getModel, logger){
4
4
  this.bulkAction = bulkAction;
5
5
  this.getModel = getModel;
6
+ this.logger = logger;
6
7
  this.result = new ProcessTaskResult();
7
8
  }
8
9
  async execute({ input, controller }) {
@@ -26,7 +27,10 @@ class ProcessTask {
26
27
  });
27
28
  this.result.addDone(id);
28
29
  } catch (ex) {
29
- console.error(ex.message || `Failed to process entry with id "${id}".`);
30
+ this.logger.error({
31
+ error: ex,
32
+ id
33
+ }, `Failed to process entry with id "${id}".`);
30
34
  this.result.addFailed(id);
31
35
  }
32
36
  return controller.response.done(`Task done: all entries processed for "${model.name}" model.`, {
@@ -1 +1 @@
1
- {"version":3,"file":"features/EntriesBulkAction/internals/ProcessTask.js","sources":["../../../../src/features/EntriesBulkAction/internals/ProcessTask.ts"],"sourcesContent":["import { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { ProcessTaskResult } from \"./ProcessTaskResult.js\";\nimport type { IBulkActionOperationTaskParams } from \"~/types.js\";\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: ProcessTaskResult;\n\n constructor(\n private bulkAction: EntriesBulkAction.Interface,\n private getModel: GetModelUseCase.Interface\n ) {\n this.result = new ProcessTaskResult();\n }\n\n async execute({ input, controller }: IBulkActionOperationTaskParams) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue({\n ...input\n });\n }\n\n // Check if the input contains a model ID.\n if (!input.modelId) {\n return controller.response.error(`Missing \"modelId\" in the input.`);\n }\n\n // Check if the model exists.\n const modelResult = await this.getModel.execute(input.modelId);\n\n if (modelResult.isFail()) {\n return controller.response.error(`Model with ${input.modelId} not found!`);\n }\n\n const model = modelResult.value;\n\n // Check if there are any IDs to process.\n if (!input.ids || input.ids.length === 0) {\n return controller.response.done(\n `Task done: no entries to process for \"${input.modelId}\" model.`,\n {\n done: [],\n failed: []\n }\n );\n }\n\n // Process each ID in the input.\n for (const id of input.ids) {\n try {\n // Execute the gateway operation for the current ID.\n await this.bulkAction.processData(model, {\n id,\n data: input.data\n });\n\n // Add the ID to the list of successfully processed entries.\n this.result.addDone(id);\n } catch (ex) {\n console.error(ex.message || `Failed to process entry with id \"${id}\".`);\n // Add the ID to the list of failed entries.\n this.result.addFailed(id);\n }\n }\n\n // Return a done response with the results of the processing.\n return controller.response.done(\n `Task done: all entries processed for \"${model.name}\" model.`,\n {\n done: this.result.getDone(),\n failed: this.result.getFailed()\n }\n );\n } catch (ex) {\n return controller.response.error(ex.message ?? `Error while processing task.`);\n }\n }\n}\n"],"names":["ProcessTask","bulkAction","getModel","ProcessTaskResult","input","controller","modelResult","model","id","ex","console"],"mappings":";AAWO,MAAMA;IAGT,YACYC,UAAuC,EACvCC,QAAmC,CAC7C;aAFUD,UAAU,GAAVA;aACAC,QAAQ,GAARA;QAER,IAAI,CAAC,MAAM,GAAG,IAAIC;IACtB;IAEA,MAAM,QAAQ,EAAEC,KAAK,EAAEC,UAAU,EAAkC,EAAE;QACjE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAC/B,IAAIA,WAAW,OAAO,CAAC,gBAAgB,IAC1C,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAAC;gBAChC,GAAGD,KAAK;YACZ;YAIJ,IAAI,CAACA,MAAM,OAAO,EACd,OAAOC,WAAW,QAAQ,CAAC,KAAK,CAAC;YAIrC,MAAMC,cAAc,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACF,MAAM,OAAO;YAE7D,IAAIE,YAAY,MAAM,IAClB,OAAOD,WAAW,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAED,MAAM,OAAO,CAAC,WAAW,CAAC;YAG7E,MAAMG,QAAQD,YAAY,KAAK;YAG/B,IAAI,CAACF,MAAM,GAAG,IAAIA,AAAqB,MAArBA,MAAM,GAAG,CAAC,MAAM,EAC9B,OAAOC,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,sCAAsC,EAAED,MAAM,OAAO,CAAC,QAAQ,CAAC,EAChE;gBACI,MAAM,EAAE;gBACR,QAAQ,EAAE;YACd;YAKR,KAAK,MAAMI,MAAMJ,MAAM,GAAG,CACtB,IAAI;gBAEA,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAACG,OAAO;oBACrCC;oBACA,MAAMJ,MAAM,IAAI;gBACpB;gBAGA,IAAI,CAAC,MAAM,CAAC,OAAO,CAACI;YACxB,EAAE,OAAOC,IAAI;gBACTC,QAAQ,KAAK,CAACD,GAAG,OAAO,IAAI,CAAC,iCAAiC,EAAED,GAAG,EAAE,CAAC;gBAEtE,IAAI,CAAC,MAAM,CAAC,SAAS,CAACA;YAC1B;YAIJ,OAAOH,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,sCAAsC,EAAEE,MAAM,IAAI,CAAC,QAAQ,CAAC,EAC7D;gBACI,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO;gBACzB,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS;YACjC;QAER,EAAE,OAAOE,IAAI;YACT,OAAOJ,WAAW,QAAQ,CAAC,KAAK,CAACI,GAAG,OAAO,IAAI;QACnD;IACJ;AACJ"}
1
+ {"version":3,"file":"features/EntriesBulkAction/internals/ProcessTask.js","sources":["../../../../src/features/EntriesBulkAction/internals/ProcessTask.ts"],"sourcesContent":["import { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { ProcessTaskResult } from \"./ProcessTaskResult.js\";\nimport type { IBulkActionOperationTaskParams } from \"~/types.js\";\nimport type { Logger } from \"@webiny/api-core/features/logger/index.js\";\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: ProcessTaskResult;\n\n constructor(\n private bulkAction: EntriesBulkAction.Interface,\n private getModel: GetModelUseCase.Interface,\n private logger: Logger.Interface\n ) {\n this.result = new ProcessTaskResult();\n }\n\n async execute({ input, controller }: IBulkActionOperationTaskParams) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue({\n ...input\n });\n }\n\n // Check if the input contains a model ID.\n if (!input.modelId) {\n return controller.response.error(`Missing \"modelId\" in the input.`);\n }\n\n // Check if the model exists.\n const modelResult = await this.getModel.execute(input.modelId);\n\n if (modelResult.isFail()) {\n return controller.response.error(`Model with ${input.modelId} not found!`);\n }\n\n const model = modelResult.value;\n\n // Check if there are any IDs to process.\n if (!input.ids || input.ids.length === 0) {\n return controller.response.done(\n `Task done: no entries to process for \"${input.modelId}\" model.`,\n {\n done: [],\n failed: []\n }\n );\n }\n\n // Process each ID in the input.\n for (const id of input.ids) {\n try {\n // Execute the gateway operation for the current ID.\n await this.bulkAction.processData(model, {\n id,\n data: input.data\n });\n\n // Add the ID to the list of successfully processed entries.\n this.result.addDone(id);\n } catch (ex) {\n this.logger.error(\n { error: ex, id },\n `Failed to process entry with id \"${id}\".`\n );\n // Add the ID to the list of failed entries.\n this.result.addFailed(id);\n }\n }\n\n // Return a done response with the results of the processing.\n return controller.response.done(\n `Task done: all entries processed for \"${model.name}\" model.`,\n {\n done: this.result.getDone(),\n failed: this.result.getFailed()\n }\n );\n } catch (ex) {\n return controller.response.error(ex.message ?? `Error while processing task.`);\n }\n }\n}\n"],"names":["ProcessTask","bulkAction","getModel","logger","ProcessTaskResult","input","controller","modelResult","model","id","ex"],"mappings":";AAYO,MAAMA;IA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,CAAC,iCAAiC,EAAEA,GAAG,EAAE,CAAC;gBAG9C,IAAI,CAAC,MAAM,CAAC,SAAS,CAACA;YAC1B;YAIJ,OAAOH,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,sCAAsC,EAAEE,MAAM,IAAI,CAAC,QAAQ,CAAC,EAC7D;gBACI,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO;gBACzB,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS;YACjC;QAER,EAAE,OAAOE,IAAI;YACT,OAAOJ,WAAW,QAAQ,CAAC,KAAK,CAACI,GAAG,OAAO,IAAI;QACnD;IACJ;AACJ"}
@@ -1,13 +1,13 @@
1
+ import type { ListTasksUseCase } from "@webiny/background-tasks/api";
1
2
  import type { IBulkActionOperationByModelTaskParams } from "../../../types.js";
2
- import { BulkActionContext } from "../../../features/BulkActionContext/index.js";
3
3
  /**
4
4
  * The `ProcessTasksByModel` class is responsible for processing tasks for a specific model.
5
5
  * It checks for any running or pending tasks from the parent task and continues or completes
6
6
  * the task based on the status.
7
7
  */
8
8
  export declare class ProcessTasksByModel {
9
- private context;
9
+ private readonly listTasks;
10
10
  private readonly taskDefinition;
11
- constructor(context: BulkActionContext.Interface, taskDefinition: string);
11
+ constructor(listTasks: ListTasksUseCase.Interface, taskDefinition: string);
12
12
  execute({ input, controller }: IBulkActionOperationByModelTaskParams): Promise<import("@webiny/api-core/features/task/TaskDefinition").ITaskResultAborted | import("@webiny/api-core/features/task/TaskDefinition").ITaskResultError | import("@webiny/api-core/features/task/TaskDefinition").TaskDefinition.ResultContinue<import("~/types.js").IBulkActionOperationByModelInput>>;
13
13
  }
@@ -1,8 +1,8 @@
1
1
  import { TaskDataStatus } from "@webiny/background-tasks/api";
2
2
  import { BulkActionOperationByModelAction } from "../../../types.js";
3
3
  class ProcessTasksByModel {
4
- constructor(context, taskDefinition){
5
- this.context = context;
4
+ constructor(listTasks, taskDefinition){
5
+ this.listTasks = listTasks;
6
6
  this.taskDefinition = taskDefinition;
7
7
  }
8
8
  async execute({ input, controller }) {
@@ -12,7 +12,7 @@ class ProcessTasksByModel {
12
12
  ...input,
13
13
  action: BulkActionOperationByModelAction.PROCESS_SUBTASKS
14
14
  });
15
- const { items } = await this.context.tasks.listTasks({
15
+ const result = await this.listTasks.execute({
16
16
  where: {
17
17
  parentId: controller.state.getTask().id,
18
18
  definitionId: this.taskDefinition,
@@ -23,6 +23,8 @@ class ProcessTasksByModel {
23
23
  },
24
24
  limit: 1
25
25
  });
26
+ if (result.isFail()) throw result.error;
27
+ const { items } = result.value;
26
28
  if (items.length > 0) return controller.response.continue({
27
29
  ...input,
28
30
  action: BulkActionOperationByModelAction.PROCESS_SUBTASKS
@@ -1 +1 @@
1
- {"version":3,"file":"features/EntriesBulkAction/internals/ProcessTasksByModel.js","sources":["../../../../src/features/EntriesBulkAction/internals/ProcessTasksByModel.ts"],"sourcesContent":["import { TaskDataStatus } from \"@webiny/background-tasks/api\";\nimport type { IBulkActionOperationByModelTaskParams } from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\nimport { BulkActionContext } from \"~/features/BulkActionContext/index.js\";\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 context: BulkActionContext.Interface;\n private readonly taskDefinition: string;\n\n constructor(context: BulkActionContext.Interface, taskDefinition: string) {\n this.context = context;\n this.taskDefinition = taskDefinition;\n }\n\n async execute({ input, controller }: IBulkActionOperationByModelTaskParams) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n const { items } = await this.context.tasks.listTasks({\n where: {\n parentId: controller.state.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 (items.length > 0) {\n return controller.response.continue(\n {\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n },\n {\n seconds: 120\n }\n );\n }\n\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.CHECK_MORE_SUBTASKS\n });\n } catch (ex) {\n return controller.response.error(\n ex.message ?? `Error while processing task \"${this.taskDefinition}\"`\n );\n }\n }\n}\n"],"names":["ProcessTasksByModel","context","taskDefinition","input","controller","BulkActionOperationByModelAction","items","TaskDataStatus","ex"],"mappings":";;AAUO,MAAMA;IAIT,YAAYC,OAAoC,EAAEC,cAAsB,CAAE;QACtE,IAAI,CAAC,OAAO,GAAGD;QACf,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QAAQ,EAAEC,KAAK,EAAEC,UAAU,EAAyC,EAAE;QACxE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAC/B,IAAIA,WAAW,OAAO,CAAC,gBAAgB,IAC1C,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAAC;gBAChC,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,gBAAgB;YAC7D;YAGJ,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;gBACjD,OAAO;oBACH,UAAUF,WAAW,KAAK,CAAC,OAAO,GAAG,EAAE;oBACvC,cAAc,IAAI,CAAC,cAAc;oBACjC,eAAe;wBAACG,eAAe,OAAO;wBAAEA,eAAe,OAAO;qBAAC;gBACnE;gBACA,OAAO;YACX;YAGA,IAAID,MAAM,MAAM,GAAG,GACf,OAAOF,WAAW,QAAQ,CAAC,QAAQ,CAC/B;gBACI,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,gBAAgB;YAC7D,GACA;gBACI,SAAS;YACb;YAIR,OAAOD,WAAW,QAAQ,CAAC,QAAQ,CAAC;gBAChC,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,mBAAmB;YAChE;QACJ,EAAE,OAAOG,IAAI;YACT,OAAOJ,WAAW,QAAQ,CAAC,KAAK,CAC5BI,GAAG,OAAO,IAAI,CAAC,6BAA6B,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QAE5E;IACJ;AACJ"}
1
+ {"version":3,"file":"features/EntriesBulkAction/internals/ProcessTasksByModel.js","sources":["../../../../src/features/EntriesBulkAction/internals/ProcessTasksByModel.ts"],"sourcesContent":["import { TaskDataStatus } from \"@webiny/background-tasks/api\";\nimport type { ListTasksUseCase } from \"@webiny/background-tasks/api\";\nimport type { IBulkActionOperationByModelTaskParams } from \"~/types.js\";\nimport { BulkActionOperationByModelAction } from \"~/types.js\";\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 readonly listTasks: ListTasksUseCase.Interface;\n private readonly taskDefinition: string;\n\n constructor(listTasks: ListTasksUseCase.Interface, taskDefinition: string) {\n this.listTasks = listTasks;\n this.taskDefinition = taskDefinition;\n }\n\n async execute({ input, controller }: IBulkActionOperationByModelTaskParams) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n } else if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n });\n }\n\n const result = await this.listTasks.execute({\n where: {\n parentId: controller.state.getTask().id,\n definitionId: this.taskDefinition,\n taskStatus_in: [TaskDataStatus.RUNNING, TaskDataStatus.PENDING]\n },\n limit: 1\n });\n if (result.isFail()) {\n throw result.error;\n }\n const { items } = result.value;\n\n // If there are running or pending tasks, continue with a wait.\n if (items.length > 0) {\n return controller.response.continue(\n {\n ...input,\n action: BulkActionOperationByModelAction.PROCESS_SUBTASKS\n },\n {\n seconds: 120\n }\n );\n }\n\n return controller.response.continue({\n ...input,\n action: BulkActionOperationByModelAction.CHECK_MORE_SUBTASKS\n });\n } catch (ex) {\n return controller.response.error(\n ex.message ?? `Error while processing task \"${this.taskDefinition}\"`\n );\n }\n }\n}\n"],"names":["ProcessTasksByModel","listTasks","taskDefinition","input","controller","BulkActionOperationByModelAction","result","TaskDataStatus","items","ex"],"mappings":";;AAUO,MAAMA;IAIT,YAAYC,SAAqC,EAAEC,cAAsB,CAAE;QACvE,IAAI,CAAC,SAAS,GAAGD;QACjB,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QAAQ,EAAEC,KAAK,EAAEC,UAAU,EAAyC,EAAE;QACxE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAC/B,IAAIA,WAAW,OAAO,CAAC,gBAAgB,IAC1C,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAAC;gBAChC,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,gBAAgB;YAC7D;YAGJ,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBACxC,OAAO;oBACH,UAAUF,WAAW,KAAK,CAAC,OAAO,GAAG,EAAE;oBACvC,cAAc,IAAI,CAAC,cAAc;oBACjC,eAAe;wBAACG,eAAe,OAAO;wBAAEA,eAAe,OAAO;qBAAC;gBACnE;gBACA,OAAO;YACX;YACA,IAAID,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,MAAM,EAAEE,KAAK,EAAE,GAAGF,OAAO,KAAK;YAG9B,IAAIE,MAAM,MAAM,GAAG,GACf,OAAOJ,WAAW,QAAQ,CAAC,QAAQ,CAC/B;gBACI,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,gBAAgB;YAC7D,GACA;gBACI,SAAS;YACb;YAIR,OAAOD,WAAW,QAAQ,CAAC,QAAQ,CAAC;gBAChC,GAAGD,KAAK;gBACR,QAAQE,iCAAiC,mBAAmB;YAChE;QACJ,EAAE,OAAOI,IAAI;YACT,OAAOL,WAAW,QAAQ,CAAC,KAAK,CAC5BK,GAAG,OAAO,IAAI,CAAC,6BAA6B,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QAE5E;IACJ;AACJ"}
@@ -1,5 +1,6 @@
1
1
  import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
- import type { HcmsBulkActionsContext } from "../../../types.js";
2
+ import type { TriggerTaskUseCase } from "@webiny/background-tasks/api";
3
+ import type { Logger } from "@webiny/api-core/features/logger/index.js";
3
4
  /**
4
5
  * TaskCache class for managing and triggering cached tasks.
5
6
  * @template TTask - Task input data.
@@ -7,18 +8,19 @@ import type { HcmsBulkActionsContext } from "../../../types.js";
7
8
  export declare class TaskCache<TTask extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {
8
9
  private readonly taskDefinition;
9
10
  private taskCache;
10
- constructor(taskDefinition: string);
11
+ private readonly logger;
12
+ constructor(taskDefinition: string, logger: Logger.Interface);
11
13
  /**
12
14
  * Adds a task to the cache.
13
15
  * @param {TTask} item - The task input data to be cached.
14
16
  */
15
17
  cacheTask(item: TTask): void;
16
18
  /**
17
- * Triggers all cached tasks using the provided context and parent task.
18
- * @param {HcmsBulkActionsContext} context - The context used to trigger the tasks.
19
+ * Triggers all cached tasks using the provided TriggerTaskUseCase and parent task.
20
+ * @param {TriggerTaskUseCase.Interface} triggerTask - The use case used to trigger the tasks.
19
21
  * @param {ITask} parent - The parent task to associate with the triggered tasks.
20
22
  */
21
- triggerTask(context: HcmsBulkActionsContext, parent: TaskDefinition.Task): Promise<void>;
23
+ triggerTask(triggerTask: TriggerTaskUseCase.Interface, parent: TaskDefinition.Task): Promise<void>;
22
24
  /**
23
25
  * Retrieves the cached tasks length.
24
26
  * @returns number
@@ -1,22 +1,28 @@
1
1
  class TaskCache {
2
- constructor(taskDefinition){
2
+ constructor(taskDefinition, logger){
3
3
  this.taskCache = [];
4
4
  this.taskDefinition = taskDefinition;
5
+ this.logger = logger;
5
6
  }
6
7
  cacheTask(item) {
7
8
  this.taskCache.push(item);
8
9
  }
9
- async triggerTask(context, parent) {
10
+ async triggerTask(triggerTask, parent) {
10
11
  const tasks = this.getTasks();
11
12
  if (0 === tasks.length) return;
12
13
  for (const task of tasks)try {
13
- await context.tasks.trigger({
14
+ const result = await triggerTask.execute({
14
15
  definition: this.taskDefinition,
15
16
  parent,
16
17
  input: task
17
18
  });
19
+ if (result.isFail()) this.logger.error({
20
+ error: result.error
21
+ }, "Error triggering task.");
18
22
  } catch (error) {
19
- console.error("Error triggering task.", error);
23
+ this.logger.error({
24
+ error
25
+ }, "Error triggering task.");
20
26
  }
21
27
  this.clearTasks();
22
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/EntriesBulkAction/internals/TaskCache.js","sources":["../../../../src/features/EntriesBulkAction/internals/TaskCache.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport type { HcmsBulkActionsContext } from \"~/types.js\";\n\n/**\n * TaskCache class for managing and triggering cached tasks.\n * @template TTask - Task input data.\n */\nexport class TaskCache<TTask extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {\n private readonly taskDefinition: string;\n private taskCache: TTask[] = [];\n\n constructor(taskDefinition: string) {\n this.taskDefinition = taskDefinition;\n }\n\n /**\n * Adds a task to the cache.\n * @param {TTask} item - The task input data to be cached.\n */\n cacheTask(item: TTask) {\n this.taskCache.push(item);\n }\n\n /**\n * Triggers all cached tasks using the provided context and parent task.\n * @param {HcmsBulkActionsContext} context - The context used to trigger the tasks.\n * @param {ITask} parent - The parent task to associate with the triggered tasks.\n */\n async triggerTask(context: HcmsBulkActionsContext, parent: TaskDefinition.Task) {\n const tasks = this.getTasks();\n\n if (tasks.length === 0) {\n return;\n }\n\n for (const task of tasks) {\n try {\n await context.tasks.trigger<TTask>({\n definition: this.taskDefinition,\n parent,\n input: task\n });\n } catch (error) {\n console.error(`Error triggering task.`, error);\n }\n }\n\n // Clear the cache after processing\n this.clearTasks();\n }\n\n /**\n * Retrieves the cached tasks length.\n * @returns number\n */\n getTasksLength() {\n return this.getTasks().length;\n }\n\n /**\n * Retrieves the cached tasks.\n * @returns {TTask[]} The list of cached tasks.\n */\n private getTasks() {\n return this.taskCache;\n }\n\n /**\n * Clears all cached tasks.\n */\n private clearTasks() {\n this.taskCache = [];\n }\n}\n"],"names":["TaskCache","taskDefinition","item","context","parent","tasks","task","error","console"],"mappings":"AAOO,MAAMA;IAIT,YAAYC,cAAsB,CAAE;aAF5B,SAAS,GAAY,EAAE;QAG3B,IAAI,CAAC,cAAc,GAAGA;IAC1B;IAMA,UAAUC,IAAW,EAAE;QACnB,IAAI,CAAC,SAAS,CAAC,IAAI,CAACA;IACxB;IAOA,MAAM,YAAYC,OAA+B,EAAEC,MAA2B,EAAE;QAC5E,MAAMC,QAAQ,IAAI,CAAC,QAAQ;QAE3B,IAAIA,AAAiB,MAAjBA,MAAM,MAAM,EACZ;QAGJ,KAAK,MAAMC,QAAQD,MACf,IAAI;YACA,MAAMF,QAAQ,KAAK,CAAC,OAAO,CAAQ;gBAC/B,YAAY,IAAI,CAAC,cAAc;gBAC/BC;gBACA,OAAOE;YACX;QACJ,EAAE,OAAOC,OAAO;YACZC,QAAQ,KAAK,CAAC,0BAA0BD;QAC5C;QAIJ,IAAI,CAAC,UAAU;IACnB;IAMA,iBAAiB;QACb,OAAO,IAAI,CAAC,QAAQ,GAAG,MAAM;IACjC;IAMQ,WAAW;QACf,OAAO,IAAI,CAAC,SAAS;IACzB;IAKQ,aAAa;QACjB,IAAI,CAAC,SAAS,GAAG,EAAE;IACvB;AACJ"}
1
+ {"version":3,"file":"features/EntriesBulkAction/internals/TaskCache.js","sources":["../../../../src/features/EntriesBulkAction/internals/TaskCache.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport type { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\nimport type { Logger } from \"@webiny/api-core/features/logger/index.js\";\n\n/**\n * TaskCache class for managing and triggering cached tasks.\n * @template TTask - Task input data.\n */\nexport class TaskCache<TTask extends TaskDefinition.TaskInput = TaskDefinition.TaskInput> {\n private readonly taskDefinition: string;\n private taskCache: TTask[] = [];\n private readonly logger: Logger.Interface;\n\n constructor(taskDefinition: string, logger: Logger.Interface) {\n this.taskDefinition = taskDefinition;\n this.logger = logger;\n }\n\n /**\n * Adds a task to the cache.\n * @param {TTask} item - The task input data to be cached.\n */\n cacheTask(item: TTask) {\n this.taskCache.push(item);\n }\n\n /**\n * Triggers all cached tasks using the provided TriggerTaskUseCase and parent task.\n * @param {TriggerTaskUseCase.Interface} triggerTask - The use case used to trigger the tasks.\n * @param {ITask} parent - The parent task to associate with the triggered tasks.\n */\n async triggerTask(triggerTask: TriggerTaskUseCase.Interface, parent: TaskDefinition.Task) {\n const tasks = this.getTasks();\n\n if (tasks.length === 0) {\n return;\n }\n\n for (const task of tasks) {\n try {\n const result = await triggerTask.execute<TTask>({\n definition: this.taskDefinition,\n parent,\n input: task\n });\n // A failed trigger comes back as a Result as well as a throw; log both.\n if (result.isFail()) {\n this.logger.error({ error: result.error }, \"Error triggering task.\");\n }\n } catch (error) {\n this.logger.error({ error }, \"Error triggering task.\");\n }\n }\n\n // Clear the cache after processing\n this.clearTasks();\n }\n\n /**\n * Retrieves the cached tasks length.\n * @returns number\n */\n getTasksLength() {\n return this.getTasks().length;\n }\n\n /**\n * Retrieves the cached tasks.\n * @returns {TTask[]} The list of cached tasks.\n */\n private getTasks() {\n return this.taskCache;\n }\n\n /**\n * Clears all cached tasks.\n */\n private clearTasks() {\n this.taskCache = [];\n }\n}\n"],"names":["TaskCache","taskDefinition","logger","item","triggerTask","parent","tasks","task","result","error"],"mappings":"AAQO,MAAMA;IAKT,YAAYC,cAAsB,EAAEC,MAAwB,CAAE;aAHtD,SAAS,GAAY,EAAE;QAI3B,IAAI,CAAC,cAAc,GAAGD;QACtB,IAAI,CAAC,MAAM,GAAGC;IAClB;IAMA,UAAUC,IAAW,EAAE;QACnB,IAAI,CAAC,SAAS,CAAC,IAAI,CAACA;IACxB;IAOA,MAAM,YAAYC,WAAyC,EAAEC,MAA2B,EAAE;QACtF,MAAMC,QAAQ,IAAI,CAAC,QAAQ;QAE3B,IAAIA,AAAiB,MAAjBA,MAAM,MAAM,EACZ;QAGJ,KAAK,MAAMC,QAAQD,MACf,IAAI;YACA,MAAME,SAAS,MAAMJ,YAAY,OAAO,CAAQ;gBAC5C,YAAY,IAAI,CAAC,cAAc;gBAC/BC;gBACA,OAAOE;YACX;YAEA,IAAIC,OAAO,MAAM,IACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAOA,OAAO,KAAK;YAAC,GAAG;QAEnD,EAAE,OAAOC,OAAO;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAEA;YAAM,GAAG;QACjC;QAIJ,IAAI,CAAC,UAAU;IACnB;IAMA,iBAAiB;QACb,OAAO,IAAI,CAAC,QAAQ,GAAG,MAAM;IACjC;IAMQ,WAAW;QACf,OAAO,IAAI,CAAC,SAAS;IACzB;IAKQ,aAAa;QACjB,IAAI,CAAC,SAAS,GAAG,EAAE;IACvB;AACJ"}
@@ -0,0 +1,12 @@
1
+ import type { Container } from "@webiny/di";
2
+ import { CmsGraphQLSchemaPlugin, CmsGraphQLSchemaFactory } from "@webiny/api-headless-cms";
3
+ import type { HcmsBulkActionsContext } from "../types.js";
4
+ declare class BulkActionsGraphQLSchemaImpl implements CmsGraphQLSchemaFactory.Interface {
5
+ private readonly container;
6
+ constructor(container: Container);
7
+ execute(): Promise<CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[]>;
8
+ }
9
+ export declare const BulkActionsGraphQLSchema: typeof BulkActionsGraphQLSchemaImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms").ICmsGraphQLSchemaFactory>;
11
+ };
12
+ export {};
@@ -0,0 +1,106 @@
1
+ import { CmsGraphQLSchemaFactory, CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from "@webiny/api-headless-cms";
2
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
3
+ import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
4
+ import { Response } from "@webiny/api-graphql";
5
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
6
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
7
+ import { TriggerTaskUseCase } from "@webiny/background-tasks/api";
8
+ import { EntriesBulkAction } from "../features/EntriesBulkAction/abstractions.js";
9
+ import { BulkActionName } from "../domain/BulkActionName.js";
10
+ import { BULK_ACTION_LIST_TASK_ID } from "../features/EntriesBulkAction/createBulkActionTasks.js";
11
+ import { RequestContainer } from "@webiny/event-handler-core";
12
+ class BulkActionsGraphQLSchemaImpl {
13
+ constructor(container){
14
+ this.container = container;
15
+ }
16
+ async execute() {
17
+ const context = {
18
+ container: this.container
19
+ };
20
+ const tenantCtx = this.container.resolve(TenantContext);
21
+ const tenant = tenantCtx.getTenant();
22
+ if (!await isHeadlessCmsReady(context)) return [];
23
+ const identityCtx = this.container.resolve(IdentityContext);
24
+ const modelsResult = await identityCtx.withoutAuthorization(async ()=>this.container.resolve(ListModelsUseCase).execute());
25
+ if (modelsResult.isFail()) return [];
26
+ const allModels = modelsResult.value.filter((model)=>{
27
+ if (model.isPrivate) return false;
28
+ const tags = Array.isArray(model.tags) ? model.tags : [];
29
+ return !tags.includes(CMS_MODEL_SINGLETON_TAG);
30
+ });
31
+ const bulkActions = this.container.resolveAll(EntriesBulkAction);
32
+ const plugins = [];
33
+ const defaultPlugin = new CmsGraphQLSchemaPlugin({
34
+ typeDefs: `
35
+ type BulkActionResponseData {
36
+ id: String
37
+ }
38
+
39
+ type BulkActionResponse {
40
+ data: BulkActionResponseData
41
+ error: CmsError
42
+ }
43
+ `
44
+ });
45
+ defaultPlugin.name = "headless-cms.graphql.schema.bulkAction.default";
46
+ plugins.push(defaultPlugin);
47
+ for (const model of allModels){
48
+ const applicableActions = bulkActions.filter((action)=>{
49
+ if (action.modelIds?.length) return action.modelIds.includes(model.modelId);
50
+ return true;
51
+ });
52
+ const enumValues = applicableActions.map((action)=>BulkActionName.from(action.name)).join("\n ");
53
+ const modelPlugin = new CmsGraphQLSchemaPlugin({
54
+ typeDefs: `
55
+ enum BulkAction${model.singularApiName}Name {
56
+ _empty
57
+ ${enumValues}
58
+ }
59
+
60
+ extend type Mutation {
61
+ bulkAction${model.singularApiName}(
62
+ action: BulkAction${model.singularApiName}Name!
63
+ where: ${model.singularApiName}ListWhereInput
64
+ search: String
65
+ data: JSON
66
+ ): BulkActionResponse
67
+ }
68
+ `,
69
+ resolvers: {
70
+ Mutation: {
71
+ [`bulkAction${model.singularApiName}`]: async (_, args, context)=>{
72
+ const identity = context.container.resolve(IdentityContext).getIdentity();
73
+ const response = await context.container.resolve(TriggerTaskUseCase).execute({
74
+ definition: BULK_ACTION_LIST_TASK_ID,
75
+ input: {
76
+ actionName: args.action,
77
+ modelId: model.modelId,
78
+ where: args.where,
79
+ search: args.search,
80
+ data: args.data,
81
+ identity
82
+ }
83
+ });
84
+ return new Response({
85
+ id: response.value.id
86
+ });
87
+ }
88
+ }
89
+ },
90
+ isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id
91
+ });
92
+ modelPlugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}`;
93
+ plugins.push(modelPlugin);
94
+ }
95
+ return plugins;
96
+ }
97
+ }
98
+ const BulkActionsGraphQLSchema = CmsGraphQLSchemaFactory.createImplementation({
99
+ implementation: BulkActionsGraphQLSchemaImpl,
100
+ dependencies: [
101
+ RequestContainer
102
+ ]
103
+ });
104
+ export { BulkActionsGraphQLSchema };
105
+
106
+ //# sourceMappingURL=BulkActionsGraphQLSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql/BulkActionsGraphQLSchema.js","sources":["../../src/graphql/BulkActionsGraphQLSchema.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport {\n CmsGraphQLSchemaPlugin,\n CmsGraphQLSchemaFactory,\n isHeadlessCmsReady\n} from \"@webiny/api-headless-cms\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { Response } from \"@webiny/api-graphql\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { BulkActionName } from \"~/domain/BulkActionName.js\";\nimport { BULK_ACTION_LIST_TASK_ID } from \"~/features/EntriesBulkAction/createBulkActionTasks.js\";\nimport { RequestContainer } from \"@webiny/event-handler-core\";\nimport type { HcmsBulkActionsContext } from \"~/types.js\";\n\nclass BulkActionsGraphQLSchemaImpl implements CmsGraphQLSchemaFactory.Interface {\n constructor(private readonly container: Container) {}\n\n async execute() {\n const context = { container: this.container } as HcmsBulkActionsContext;\n const tenantCtx = this.container.resolve(TenantContext);\n const tenant = tenantCtx.getTenant();\n\n if (!(await isHeadlessCmsReady(context))) {\n return [];\n }\n\n const identityCtx = this.container.resolve(IdentityContext);\n const modelsResult = await identityCtx.withoutAuthorization(async () => {\n return this.container.resolve(ListModelsUseCase).execute();\n });\n\n if (modelsResult.isFail()) {\n return [];\n }\n\n const allModels = modelsResult.value.filter(model => {\n if (model.isPrivate) {\n return false;\n }\n const tags = Array.isArray(model.tags) ? model.tags : [];\n return !tags.includes(CMS_MODEL_SINGLETON_TAG);\n });\n\n const bulkActions = this.container.resolveAll(EntriesBulkAction);\n const plugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n const defaultPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type BulkActionResponseData {\n id: String\n }\n\n type BulkActionResponse {\n data: BulkActionResponseData\n error: CmsError\n }\n `\n });\n defaultPlugin.name = \"headless-cms.graphql.schema.bulkAction.default\";\n plugins.push(defaultPlugin);\n\n for (const model of allModels) {\n const applicableActions = bulkActions.filter(action => {\n if (action.modelIds?.length) {\n return action.modelIds.includes(model.modelId);\n }\n return true;\n });\n\n const enumValues = applicableActions\n .map(action => BulkActionName.from(action.name))\n .join(\"\\n \");\n\n const modelPlugin = new CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>({\n typeDefs: /* GraphQL */ `\n enum BulkAction${model.singularApiName}Name {\n _empty\n ${enumValues}\n }\n\n extend type Mutation {\n bulkAction${model.singularApiName}(\n action: BulkAction${model.singularApiName}Name!\n where: ${model.singularApiName}ListWhereInput\n search: String\n data: JSON\n ): BulkActionResponse\n }\n `,\n resolvers: {\n Mutation: {\n [`bulkAction${model.singularApiName}`]: async (_, args, context) => {\n const identity = context.container\n .resolve(IdentityContext)\n .getIdentity();\n\n const response = await context.container\n .resolve(TriggerTaskUseCase)\n .execute({\n definition: BULK_ACTION_LIST_TASK_ID,\n input: {\n actionName: args.action,\n modelId: model.modelId,\n where: args.where,\n search: args.search,\n data: args.data,\n identity\n }\n });\n\n return new Response({\n id: response.value.id\n });\n }\n }\n },\n isApplicable: context =>\n context.container.resolve(TenantContext).getTenant().id === tenant.id\n });\n\n modelPlugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}`;\n plugins.push(modelPlugin);\n }\n\n return plugins;\n }\n}\n\nexport const BulkActionsGraphQLSchema = CmsGraphQLSchemaFactory.createImplementation({\n implementation: BulkActionsGraphQLSchemaImpl,\n dependencies: [RequestContainer]\n});\n"],"names":["BulkActionsGraphQLSchemaImpl","container","context","tenantCtx","TenantContext","tenant","isHeadlessCmsReady","identityCtx","IdentityContext","modelsResult","ListModelsUseCase","allModels","model","tags","Array","CMS_MODEL_SINGLETON_TAG","bulkActions","EntriesBulkAction","plugins","defaultPlugin","CmsGraphQLSchemaPlugin","applicableActions","action","enumValues","BulkActionName","modelPlugin","_","args","identity","response","TriggerTaskUseCase","BULK_ACTION_LIST_TASK_ID","Response","BulkActionsGraphQLSchema","CmsGraphQLSchemaFactory","RequestContainer"],"mappings":";;;;;;;;;;;AAkBA,MAAMA;IACF,YAA6BC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAEpD,MAAM,UAAU;QACZ,MAAMC,UAAU;YAAE,WAAW,IAAI,CAAC,SAAS;QAAC;QAC5C,MAAMC,YAAY,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QACzC,MAAMC,SAASF,UAAU,SAAS;QAElC,IAAI,CAAE,MAAMG,mBAAmBJ,UAC3B,OAAO,EAAE;QAGb,MAAMK,cAAc,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC3C,MAAMC,eAAe,MAAMF,YAAY,oBAAoB,CAAC,UACjD,IAAI,CAAC,SAAS,CAAC,OAAO,CAACG,mBAAmB,OAAO;QAG5D,IAAID,aAAa,MAAM,IACnB,OAAO,EAAE;QAGb,MAAME,YAAYF,aAAa,KAAK,CAAC,MAAM,CAACG,CAAAA;YACxC,IAAIA,MAAM,SAAS,EACf,OAAO;YAEX,MAAMC,OAAOC,MAAM,OAAO,CAACF,MAAM,IAAI,IAAIA,MAAM,IAAI,GAAG,EAAE;YACxD,OAAO,CAACC,KAAK,QAAQ,CAACE;QAC1B;QAEA,MAAMC,cAAc,IAAI,CAAC,SAAS,CAAC,UAAU,CAACC;QAC9C,MAAMC,UAA4D,EAAE;QAEpE,MAAMC,gBAAgB,IAAIC,uBAAuB;YAC7C,UAAwB,CAAC;;;;;;;;;YASzB,CAAC;QACL;QACAD,cAAc,IAAI,GAAG;QACrBD,QAAQ,IAAI,CAACC;QAEb,KAAK,MAAMP,SAASD,UAAW;YAC3B,MAAMU,oBA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;AACJ;AAEO,MAAMe,2BAA2BC,wBAAwB,oBAAoB,CAAC;IACjF,gBAAgBlC;IAChB,cAAc;QAACmC;KAAiB;AACpC"}
@@ -1,19 +1,22 @@
1
- import { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from "@webiny/api-headless-cms";
2
- import { Response } from "@webiny/handler-graphql";
1
+ import { CmsGraphQLSchemaFactory, CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from "@webiny/api-headless-cms";
2
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
3
+ import { Response } from "@webiny/api-graphql";
3
4
  import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
4
5
  import { BulkActionName } from "../domain/BulkActionName.js";
6
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
7
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
8
+ import { TriggerTaskUseCase } from "@webiny/background-tasks/api";
5
9
  const createBulkActionGraphQL = async (context, bulkAction)=>{
6
- const tenant = context.tenancy.getCurrentTenant();
10
+ const tenant = context.container.resolve(TenantContext).getTenant();
7
11
  if (!await isHeadlessCmsReady(context)) return;
8
- const models = await context.security.withoutAuthorization(async ()=>{
9
- const allModels = await context.cms.listModels();
10
- return allModels.filter((model)=>{
11
- if (model.isPrivate) return false;
12
- const tags = Array.isArray(model.tags) ? model.tags : [];
13
- if (tags.includes(CMS_MODEL_SINGLETON_TAG)) return false;
14
- if (bulkAction.modelIds?.length) return bulkAction.modelIds.includes(model.modelId);
15
- return true;
16
- });
12
+ const modelsResult = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
13
+ if (modelsResult.isFail()) return;
14
+ const models = modelsResult.value.filter((model)=>{
15
+ if (model.isPrivate) return false;
16
+ const tags = Array.isArray(model.tags) ? model.tags : [];
17
+ if (tags.includes(CMS_MODEL_SINGLETON_TAG)) return false;
18
+ if (bulkAction.modelIds?.length) return bulkAction.modelIds.includes(model.modelId);
19
+ return true;
17
20
  });
18
21
  const plugins = [];
19
22
  models.forEach((model)=>{
@@ -26,8 +29,8 @@ const createBulkActionGraphQL = async (context, bulkAction)=>{
26
29
  resolvers: {
27
30
  Mutation: {
28
31
  [`bulkAction${model.singularApiName}`]: async (_, args, context)=>{
29
- const identity = context.security.getIdentity();
30
- const response = await context.tasks.trigger({
32
+ const identity = context.container.resolve(IdentityContext).getIdentity();
33
+ const response = await context.container.resolve(TriggerTaskUseCase).execute({
31
34
  definition: `hcmsBulkList${args.action}Entries`,
32
35
  input: {
33
36
  modelId: model.modelId,
@@ -43,14 +46,14 @@ const createBulkActionGraphQL = async (context, bulkAction)=>{
43
46
  }
44
47
  }
45
48
  },
46
- isApplicable: (context)=>context.tenancy.getCurrentTenant().id === tenant.id
49
+ isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id
47
50
  });
48
51
  plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${bulkAction.name}`;
49
52
  plugins.push(plugin);
50
53
  });
51
- context.plugins.register([
52
- ...plugins
53
- ]);
54
+ context.container.registerInstance(CmsGraphQLSchemaFactory, {
55
+ execute: ()=>plugins
56
+ });
54
57
  };
55
58
  export { createBulkActionGraphQL };
56
59
 
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/createBulkActionGraphQL.js","sources":["../../src/graphql/createBulkActionGraphQL.ts"],"sourcesContent":["import type { HcmsBulkActionsContext } from \"~/types.js\";\nimport { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport { Response } from \"@webiny/handler-graphql\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { BulkActionName } from \"~/domain/BulkActionName.js\";\n\nexport const createBulkActionGraphQL = async (\n context: HcmsBulkActionsContext,\n bulkAction: EntriesBulkAction.Interface\n) => {\n const tenant = context.tenancy.getCurrentTenant();\n\n // TODO: once we have GraphSchema plugin via an abstraction, we'll be able to remove this.\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\n\n const models = await context.security.withoutAuthorization(async () => {\n const allModels = await context.cms.listModels();\n return allModels.filter(model => {\n if (model.isPrivate) {\n return false;\n }\n const tags = Array.isArray(model.tags) ? model.tags : [];\n if (tags.includes(CMS_MODEL_SINGLETON_TAG)) {\n return false;\n }\n if (bulkAction.modelIds?.length) {\n return bulkAction.modelIds.includes(model.modelId);\n }\n return true;\n });\n });\n\n const plugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>({\n typeDefs: /* GraphQL */ `\n extend enum BulkAction${model.singularApiName}Name {\n ${BulkActionName.from(bulkAction.name)}\n }\n `,\n resolvers: {\n Mutation: {\n [`bulkAction${model.singularApiName}`]: async (_, args, context) => {\n const identity = context.security.getIdentity();\n\n const response = await context.tasks.trigger({\n definition: `hcmsBulkList${args.action}Entries`,\n input: {\n modelId: model.modelId,\n where: args.where,\n search: args.search,\n data: args.data,\n identity\n }\n });\n\n return new Response({\n id: response.value.id\n });\n }\n }\n },\n isApplicable: context => context.tenancy.getCurrentTenant().id === tenant.id\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${bulkAction.name}`;\n plugins.push(plugin);\n });\n\n context.plugins.register([...plugins]);\n};\n"],"names":["createBulkActionGraphQL","context","bulkAction","tenant","isHeadlessCmsReady","models","allModels","model","tags","Array","CMS_MODEL_SINGLETON_TAG","plugins","plugin","CmsGraphQLSchemaPlugin","BulkActionName","_","args","identity","response","Response"],"mappings":";;;;AAOO,MAAMA,0BAA0B,OACnCC,SACAC;IAEA,MAAMC,SAASF,QAAQ,OAAO,CAAC,gBAAgB;IAG/C,IAAI,CAAE,MAAMG,mBAAmBH,UAC3B;IAGJ,MAAMI,SAAS,M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AS,OAAO,IAAI,GAAG,CAAC,uCAAuC,EAAEL,MAAM,OAAO,CAAC,CAAC,EAAEL,WAAW,IAAI,EAAE;QAC1FS,QAAQ,IAAI,CAACC;IACjB;IAEAX,QAAQ,OAAO,CAAC,QAAQ,CAAC;WAAIU;KAAQ;AACzC"}
1
+ {"version":3,"file":"graphql/createBulkActionGraphQL.js","sources":["../../src/graphql/createBulkActionGraphQL.ts"],"sourcesContent":["import type { HcmsBulkActionsContext } from \"~/types.js\";\nimport {\n CmsGraphQLSchemaPlugin,\n CmsGraphQLSchemaFactory,\n isHeadlessCmsReady\n} from \"@webiny/api-headless-cms\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { Response } from \"@webiny/api-graphql\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\nimport { BulkActionName } from \"~/domain/BulkActionName.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { TriggerTaskUseCase } from \"@webiny/background-tasks/api\";\n\nexport const createBulkActionGraphQL = async (\n context: HcmsBulkActionsContext,\n bulkAction: EntriesBulkAction.Interface\n) => {\n const tenant = context.container.resolve(TenantContext).getTenant();\n\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\n\n const modelsResult = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (modelsResult.isFail()) {\n return;\n }\n const models = modelsResult.value.filter(model => {\n if (model.isPrivate) {\n return false;\n }\n const tags = Array.isArray(model.tags) ? model.tags : [];\n if (tags.includes(CMS_MODEL_SINGLETON_TAG)) {\n return false;\n }\n if (bulkAction.modelIds?.length) {\n return bulkAction.modelIds.includes(model.modelId);\n }\n return true;\n });\n\n const plugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>({\n typeDefs: /* GraphQL */ `\n extend enum BulkAction${model.singularApiName}Name {\n ${BulkActionName.from(bulkAction.name)}\n }\n `,\n resolvers: {\n Mutation: {\n [`bulkAction${model.singularApiName}`]: async (_, args, context) => {\n const identity = context.container.resolve(IdentityContext).getIdentity();\n\n const response = await context.container\n .resolve(TriggerTaskUseCase)\n .execute({\n definition: `hcmsBulkList${args.action}Entries`,\n input: {\n modelId: model.modelId,\n where: args.where,\n search: args.search,\n data: args.data,\n identity\n }\n });\n\n return new Response({\n id: response.value.id\n });\n }\n }\n },\n isApplicable: context =>\n context.container.resolve(TenantContext).getTenant().id === tenant.id\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${bulkAction.name}`;\n plugins.push(plugin);\n });\n\n context.container.registerInstance(CmsGraphQLSchemaFactory, {\n execute: () => plugins\n });\n};\n"],"names":["createBulkActionGraphQL","context","bulkAction","tenant","TenantContext","isHeadlessCmsReady","modelsResult","IdentityContext","ListModelsUseCase","models","model","tags","Array","CMS_MODEL_SINGLETON_TAG","plugins","plugin","CmsGraphQLSchemaPlugin","BulkActionName","_","args","identity","response","TriggerTaskUseCase","Response","CmsGraphQLSchemaFactory"],"mappings":";;;;;;;;AAeO,MAAMA,0BAA0B,OACnCC,SACAC;IAEA,MAAMC,SAASF,QAAQ,SAAS,CAAC,OAAO,CAACG,eAAe,SAAS;IAEjE,IAAI,CAAE,MAAMC,mBAAmBJ,UAC3B;IAGJ,MAAMK,eAAe,MAAML,QAAQ,SAAS,CACvC,OAAO,CAACM,iBACR,oBAAoB,CAAC,UACXN,QAAQ,SAAS,CAAC,OAAO,CAACO,mBAAmB,OAAO;IAEnE,IAAIF,aAAa,MAAM,IACnB;IAEJ,MAAMG,SAASH,aAAa,KAAK,CAAC,MAAM,CAACI,CAAAA;QACrC,IAAIA,MAA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,QAAQ,IAAI,CAACC;IACjB;IAEAd,QAAQ,SAAS,CAAC,gBAAgB,CAACuB,yBAAyB;QACxD,SAAS,IAAMV;IACnB;AACJ"}
@@ -1,3 +1,8 @@
1
1
  import type { HcmsBulkActionsContext } from "../types.js";
2
- import { BeforeHandlerPlugin } from "@webiny/handler/plugins/BeforeHandlerPlugin.js";
3
- export declare const createDefaultGraphQL: () => BeforeHandlerPlugin<HcmsBulkActionsContext>;
2
+ /**
3
+ * Registers the "default" bulk-action GraphQL for every public model: the shared response types plus,
4
+ * per model, an empty `BulkAction<Model>Name` enum + `bulkAction<Model>` mutation skeleton (each
5
+ * action extends the enum via createBulkActionGraphQL). Run per request, since models are only
6
+ * known at request time.
7
+ */
8
+ export declare const registerDefaultBulkActionGraphQL: (context: HcmsBulkActionsContext) => Promise<void>;