@webiny/api-headless-cms-bulk-actions 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7

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 (80) hide show
  1. package/HcmsBulkActionsFeature.d.ts +7 -0
  2. package/HcmsBulkActionsFeature.js +32 -0
  3. package/HcmsBulkActionsFeature.js.map +1 -0
  4. package/exports/api/cms/entry.d.ts +1 -0
  5. package/exports/api/cms/entry.js +1 -0
  6. package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.d.ts +1 -1
  7. package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.js +1 -0
  8. package/features/DeleteEntriesBulkAction/DeleteEntriesBulkAction.js.map +1 -1
  9. package/features/EntriesBulkAction/abstractions.d.ts +7 -7
  10. package/features/EntriesBulkAction/abstractions.js.map +1 -1
  11. package/features/EntriesBulkAction/createBulkActionTasks.d.ts +66 -4
  12. package/features/EntriesBulkAction/createBulkActionTasks.js +165 -118
  13. package/features/EntriesBulkAction/createBulkActionTasks.js.map +1 -1
  14. package/features/EntriesBulkAction/internals/ChildTasksCleanup.d.ts +9 -6
  15. package/features/EntriesBulkAction/internals/ChildTasksCleanup.js +20 -11
  16. package/features/EntriesBulkAction/internals/ChildTasksCleanup.js.map +1 -1
  17. package/features/EntriesBulkAction/internals/CreateTasksByModel.d.ts +5 -4
  18. package/features/EntriesBulkAction/internals/CreateTasksByModel.js +8 -7
  19. package/features/EntriesBulkAction/internals/CreateTasksByModel.js.map +1 -1
  20. package/features/EntriesBulkAction/internals/ProcessTask.d.ts +4 -2
  21. package/features/EntriesBulkAction/internals/ProcessTask.js +6 -2
  22. package/features/EntriesBulkAction/internals/ProcessTask.js.map +1 -1
  23. package/features/EntriesBulkAction/internals/ProcessTasksByModel.d.ts +3 -3
  24. package/features/EntriesBulkAction/internals/ProcessTasksByModel.js +6 -4
  25. package/features/EntriesBulkAction/internals/ProcessTasksByModel.js.map +1 -1
  26. package/features/EntriesBulkAction/internals/TaskCache.d.ts +7 -5
  27. package/features/EntriesBulkAction/internals/TaskCache.js +10 -4
  28. package/features/EntriesBulkAction/internals/TaskCache.js.map +1 -1
  29. package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.d.ts +1 -1
  30. package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.js +2 -3
  31. package/features/MoveToFolderBulkAction/MoveToFolderBulkAction.js.map +1 -1
  32. package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.d.ts +1 -1
  33. package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.js +1 -0
  34. package/features/MoveToTrashBulkAction/MoveToTrashBulkAction.js.map +1 -1
  35. package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.d.ts +1 -1
  36. package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.js +2 -3
  37. package/features/PublishEntriesBulkAction/PublishEntriesBulkAction.js.map +1 -1
  38. package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.d.ts +1 -1
  39. package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js +1 -0
  40. package/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js.map +1 -1
  41. package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.d.ts +1 -1
  42. package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js +2 -3
  43. package/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js.map +1 -1
  44. package/graphql/BulkActionsGraphQLSchema.d.ts +12 -0
  45. package/graphql/BulkActionsGraphQLSchema.js +106 -0
  46. package/graphql/BulkActionsGraphQLSchema.js.map +1 -0
  47. package/graphql/createBulkActionGraphQL.js +21 -18
  48. package/graphql/createBulkActionGraphQL.js.map +1 -1
  49. package/graphql/createDefaultGraphQL.d.ts +7 -2
  50. package/graphql/createDefaultGraphQL.js +41 -39
  51. package/graphql/createDefaultGraphQL.js.map +1 -1
  52. package/index.d.ts +2 -7
  53. package/index.js +1 -46
  54. package/package.json +19 -17
  55. package/tasks/{EmptyTrashBinTaskDefinition.d.ts → EmptyTrashBinTask.d.ts} +10 -5
  56. package/tasks/{EmptyTrashBinTaskDefinition.js → EmptyTrashBinTask.js} +36 -15
  57. package/tasks/EmptyTrashBinTask.js.map +1 -0
  58. package/types.d.ts +4 -2
  59. package/types.js.map +1 -1
  60. package/features/BulkActionContext/abstractions.d.ts +0 -5
  61. package/features/BulkActionContext/abstractions.js +0 -5
  62. package/features/BulkActionContext/abstractions.js.map +0 -1
  63. package/features/BulkActionContext/index.d.ts +0 -1
  64. package/features/BulkActionContext/index.js +0 -1
  65. package/handlers/eventBridgeEventHandler.d.ts +0 -1
  66. package/handlers/eventBridgeEventHandler.js +0 -28
  67. package/handlers/eventBridgeEventHandler.js.map +0 -1
  68. package/handlers/index.d.ts +0 -1
  69. package/handlers/index.js +0 -9
  70. package/handlers/index.js.map +0 -1
  71. package/handlers/setupEventsTenant.d.ts +0 -1
  72. package/handlers/setupEventsTenant.js +0 -10
  73. package/handlers/setupEventsTenant.js.map +0 -1
  74. package/index.js.map +0 -1
  75. package/tasks/EmptyTrashBinTaskDefinition.js.map +0 -1
  76. package/tasks/createEmptyTrashBinsTask.d.ts +0 -1
  77. package/tasks/createEmptyTrashBinsTask.js +0 -8
  78. package/tasks/createEmptyTrashBinsTask.js.map +0 -1
  79. package/tasks/index.d.ts +0 -1
  80. package/tasks/index.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js","sources":["../../../src/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.ts"],"sourcesContent":["import { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { RestoreEntryFromBinUseCase } from \"@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass RestoreEntriesBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"restore\";\n\n constructor(\n private listDeletedEntries: ListDeletedEntriesUseCase.Interface,\n private restoreEntry: RestoreEntryFromBinUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listDeletedEntries.execute(model, params);\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n const { id: entryId } = parseIdentifier(params.id);\n\n await this.restoreEntry.execute(model, entryId);\n }\n}\n\nexport const RestoreEntriesBulkAction = EntriesBulkAction.createImplementation({\n implementation: RestoreEntriesBulkActionImpl,\n dependencies: [ListDeletedEntriesUseCase, RestoreEntryFromBinUseCase]\n});\n"],"names":["RestoreEntriesBulkActionImpl","listDeletedEntries","restoreEntry","model","params","entriesResult","entryId","parseIdentifier","RestoreEntriesBulkAction","EntriesBulkAction","ListDeletedEntriesUseCase","RestoreEntryFromBinUseCase"],"mappings":";;;;AAKA,MAAMA;IAGF,YACYC,kBAAuD,EACvDC,YAAkD,CAC5D;aAFUD,kBAAkB,GAAlBA;aACAC,YAAY,GAAZA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACF,OAAOC;QAEnE,OAAOC,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFF,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,MAAM,EAAE,IAAIE,OAAO,EAAE,GAAGC,gBAAgBH,OAAO,EAAE;QAEjD,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAACD,OAAOG;IAC3C;AACJ;AAEO,MAAME,2BAA2BC,kBAAkB,oBAAoB,CAAC;IAC3E,gBAAgBT;IAChB,cAAc;QAACU;QAA2BC;KAA2B;AACzE"}
1
+ {"version":3,"file":"features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.js","sources":["../../../src/features/RestoreEntriesBulkAction/RestoreEntriesBulkAction.ts"],"sourcesContent":["import { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { RestoreEntryFromBinUseCase } from \"@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass RestoreEntriesBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"restore\";\n\n constructor(\n private listDeletedEntries: ListDeletedEntriesUseCase.Interface,\n private restoreEntry: RestoreEntryFromBinUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listDeletedEntries.execute(model, params);\n if (entriesResult.isFail()) {\n throw entriesResult.error;\n }\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n const { id: entryId } = parseIdentifier(params.id);\n\n await this.restoreEntry.execute(model, entryId);\n }\n}\n\nexport const RestoreEntriesBulkAction = EntriesBulkAction.createImplementation({\n implementation: RestoreEntriesBulkActionImpl,\n dependencies: [ListDeletedEntriesUseCase, RestoreEntryFromBinUseCase]\n});\n"],"names":["RestoreEntriesBulkActionImpl","listDeletedEntries","restoreEntry","model","params","entriesResult","entryId","parseIdentifier","RestoreEntriesBulkAction","EntriesBulkAction","ListDeletedEntriesUseCase","RestoreEntryFromBinUseCase"],"mappings":";;;;AAKA,MAAMA;IAGF,YACYC,kBAAuD,EACvDC,YAAkD,CAC5D;aAFUD,kBAAkB,GAAlBA;aACAC,YAAY,GAAZA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACF,OAAOC;QACnE,IAAIC,cAAc,MAAM,IACpB,MAAMA,cAAc,KAAK;QAG7B,OAAOA,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFF,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,MAAM,EAAE,IAAIE,OAAO,EAAE,GAAGC,gBAAgBH,OAAO,EAAE;QAEjD,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAACD,OAAOG;IAC3C;AACJ;AAEO,MAAME,2BAA2BC,kBAAkB,oBAAoB,CAAC;IAC3E,gBAAgBT;IAChB,cAAc;QAACU;QAA2BC;KAA2B;AACzE"}
@@ -10,6 +10,6 @@ declare class UnpublishEntriesBulkActionImpl implements EntriesBulkAction.Interf
10
10
  processData(model: EntriesBulkAction.Model, params: EntriesBulkAction.ProcessParams): Promise<void>;
11
11
  }
12
12
  export declare const UnpublishEntriesBulkAction: typeof UnpublishEntriesBulkActionImpl & {
13
- __abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction>;
13
+ __abstraction: import("@webiny/di").Abstraction<import("~/features/EntriesBulkAction/abstractions.js").IEntriesBulkAction<Record<string, any>>>;
14
14
  };
15
15
  export {};
@@ -1,6 +1,5 @@
1
1
  import { ListPublishedEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
2
2
  import { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/index.js";
3
- import { parseIdentifier } from "@webiny/utils";
4
3
  import { EntriesBulkAction } from "../EntriesBulkAction/abstractions.js";
5
4
  class UnpublishEntriesBulkActionImpl {
6
5
  constructor(listPublishedEntries, unpublishEntry){
@@ -10,11 +9,11 @@ class UnpublishEntriesBulkActionImpl {
10
9
  }
11
10
  async loadData(model, params) {
12
11
  const entriesResult = await this.listPublishedEntries.execute(model, params);
12
+ if (entriesResult.isFail()) throw entriesResult.error;
13
13
  return entriesResult.value;
14
14
  }
15
15
  async processData(model, params) {
16
- const { id: entryId } = parseIdentifier(params.id);
17
- await this.unpublishEntry.execute(model, entryId);
16
+ await this.unpublishEntry.execute(model, params.id);
18
17
  }
19
18
  }
20
19
  const UnpublishEntriesBulkAction = EntriesBulkAction.createImplementation({
@@ -1 +1 @@
1
- {"version":3,"file":"features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js","sources":["../../../src/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.ts"],"sourcesContent":["import { ListPublishedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { UnpublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass UnpublishEntriesBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"unpublish\";\n\n constructor(\n private listPublishedEntries: ListPublishedEntriesUseCase.Interface,\n private unpublishEntry: UnpublishEntryUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listPublishedEntries.execute(model, params);\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n const { id: entryId } = parseIdentifier(params.id);\n\n await this.unpublishEntry.execute(model, entryId);\n }\n}\n\nexport const UnpublishEntriesBulkAction = EntriesBulkAction.createImplementation({\n implementation: UnpublishEntriesBulkActionImpl,\n dependencies: [ListPublishedEntriesUseCase, UnpublishEntryUseCase]\n});\n"],"names":["UnpublishEntriesBulkActionImpl","listPublishedEntries","unpublishEntry","model","params","entriesResult","entryId","parseIdentifier","UnpublishEntriesBulkAction","EntriesBulkAction","ListPublishedEntriesUseCase","UnpublishEntryUseCase"],"mappings":";;;;AAKA,MAAMA;IAGF,YACYC,oBAA2D,EAC3DC,cAA+C,CACzD;aAFUD,oBAAoB,GAApBA;aACAC,cAAc,GAAdA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACF,OAAOC;QAErE,OAAOC,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFF,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,MAAM,EAAE,IAAIE,OAAO,EAAE,GAAGC,gBAAgBH,OAAO,EAAE;QAEjD,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACD,OAAOG;IAC7C;AACJ;AAEO,MAAME,6BAA6BC,kBAAkB,oBAAoB,CAAC;IAC7E,gBAAgBT;IAChB,cAAc;QAACU;QAA6BC;KAAsB;AACtE"}
1
+ {"version":3,"file":"features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.js","sources":["../../../src/features/UnpublishEntriesBulkAction/UnpublishEntriesBulkAction.ts"],"sourcesContent":["import { ListPublishedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { UnpublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UnpublishEntry/index.js\";\nimport { EntriesBulkAction } from \"~/features/EntriesBulkAction/abstractions.js\";\n\nclass UnpublishEntriesBulkActionImpl implements EntriesBulkAction.Interface {\n readonly name = \"unpublish\";\n\n constructor(\n private listPublishedEntries: ListPublishedEntriesUseCase.Interface,\n private unpublishEntry: UnpublishEntryUseCase.Interface\n ) {}\n\n async loadData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.LoadDataParams\n ): Promise<EntriesBulkAction.LoadDataResult> {\n const entriesResult = await this.listPublishedEntries.execute(model, params);\n if (entriesResult.isFail()) {\n throw entriesResult.error;\n }\n\n return entriesResult.value;\n }\n\n async processData(\n model: EntriesBulkAction.Model,\n params: EntriesBulkAction.ProcessParams\n ): Promise<void> {\n await this.unpublishEntry.execute(model, params.id);\n }\n}\n\nexport const UnpublishEntriesBulkAction = EntriesBulkAction.createImplementation({\n implementation: UnpublishEntriesBulkActionImpl,\n dependencies: [ListPublishedEntriesUseCase, UnpublishEntryUseCase]\n});\n"],"names":["UnpublishEntriesBulkActionImpl","listPublishedEntries","unpublishEntry","model","params","entriesResult","UnpublishEntriesBulkAction","EntriesBulkAction","ListPublishedEntriesUseCase","UnpublishEntryUseCase"],"mappings":";;;AAIA,MAAMA;IAGF,YACYC,oBAA2D,EAC3DC,cAA+C,CACzD;aAFUD,oBAAoB,GAApBA;aACAC,cAAc,GAAdA;aAJH,IAAI,GAAG;IAKb;IAEH,MAAM,SACFC,KAA8B,EAC9BC,MAAwC,EACC;QACzC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACF,OAAOC;QACrE,IAAIC,cAAc,MAAM,IACpB,MAAMA,cAAc,KAAK;QAG7B,OAAOA,cAAc,KAAK;IAC9B;IAEA,MAAM,YACFF,KAA8B,EAC9BC,MAAuC,EAC1B;QACb,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACD,OAAOC,OAAO,EAAE;IACtD;AACJ;AAEO,MAAME,6BAA6BC,kBAAkB,oBAAoB,CAAC;IAC7E,gBAAgBP;IAChB,cAAc;QAACQ;QAA6BC;KAAsB;AACtE"}
@@ -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,oBAAoBL,YAAY,MAAM,CAACM,CAAAA;gBACzC,IAAIA,OAAO,QAAQ,EAAE,QACjB,OAAOA,OAAO,QAAQ,CAAC,QAAQ,CAACV,MAAM,OAAO;gBAEjD,OAAO;YACX;YAEA,MAAMW,aAAaF,kBACd,GAAG,CAACC,CAAAA,SAAUE,eAAe,IAAI,CAACF,OAAO,IAAI,GAC7C,IAAI,CAAC;YAEV,MAAMG,cAAc,IAAIL,uBAA+C;gBACnE,UAAwB,CAAC;mCACN,EAAER,MAAM,eAAe,CAAC;;wBAEnC,EAAEW,WAAW;;;;kCAIH,EAAEX,MAAM,eAAe,CAAC;8CACZ,EAAEA,MAAM,eAAe,CAAC;mCACnC,EAAEA,MAAM,eAAe,CAAC;;;;;gBAK3C,CAAC;gBACD,WAAW;oBACP,UAAU;wBACN,CAAC,CAAC,UAAU,EAAEA,MAAM,eAAe,EAAE,CAAC,EAAE,OAAOc,GAAGC,MAAMzB;4BACpD,MAAM0B,WAAW1B,QAAQ,SAAS,CAC7B,OAAO,CAACM,iBACR,WAAW;4BAEhB,MAAMqB,WAAW,MAAM3B,QAAQ,SAAS,CACnC,OAAO,CAAC4B,oBACR,OAAO,CAAC;gCACL,YAAYC;gCACZ,OAAO;oCACH,YAAYJ,KAAK,MAAM;oCACvB,SAASf,MAAM,OAAO;oCACtB,OAAOe,KAAK,KAAK;oCACjB,QAAQA,KAAK,MAAM;oCACnB,MAAMA,KAAK,IAAI;oCACfC;gCACJ;4BACJ;4BAEJ,OAAO,IAAII,SAAS;gCAChB,IAAIH,SAAS,KAAK,CAAC,EAAE;4BACzB;wBACJ;oBACJ;gBACJ;gBACA,cAAc3B,CAAAA,UACVA,QAAQ,SAAS,CAAC,OAAO,CAACE,eAAe,SAAS,GAAG,EAAE,KAAKC,OAAO,EAAE;YAC7E;YAEAoB,YAAY,IAAI,GAAG,CAAC,uCAAuC,EAAEb,MAAM,OAAO,EAAE;YAC5EM,QAAQ,IAAI,CAACO;QACjB;QAEA,OAAOP;IACX;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,MAAMJ,QAAQ,QAAQ,CAAC,oBAAoB,CAAC;QACvD,MAAMK,YAAY,MAAML,QAAQ,GAAG,CAAC,UAAU;QAC9C,OAAOK,UAAU,MAAM,CAACC,CAAAA;YACpB,IAAIA,MAAM,SAAS,EACf,OAAO;YAEX,MAAMC,OAAOC,MAAM,OAAO,CAACF,MAAM,IAAI,IAAIA,MAAM,IAAI,GAAG,EAAE;YACxD,IAAIC,KAAK,QAAQ,CAACE,0BACd,OAAO;YAEX,IAAIR,WAAW,QAAQ,EAAE,QACrB,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAACK,MAAM,OAAO;YAErD,OAAO;QACX;IACJ;IAEA,MAAMI,UAA4D,EAAE;IAEpEN,OAAO,OAAO,CAACE,CAAAA;QACX,MAAMK,SAAS,IAAIC,uBAA+C;YAC9D,UAAwB,CAAC;2CACM,EAAEN,MAAM,eAAe,CAAC;wBAC3C,EAAEO,eAAe,IAAI,CAACZ,WAAW,IAAI,EAAE;;gBAE/C,CAAC;YACL,WAAW;gBACP,UAAU;oBACN,CAAC,CAAC,UAAU,EAAEK,MAAM,eAAe,EAAE,CAAC,EAAE,OAAOQ,GAAGC,MAAMf;wBACpD,MAAMgB,WAAWhB,QAAQ,QAAQ,CAAC,WAAW;wBAE7C,MAAMiB,WAAW,MAAMjB,QAAQ,KAAK,CAAC,OAAO,CAAC;4BACzC,YAAY,CAAC,YAAY,EAAEe,KAAK,MAAM,CAAC,OAAO,CAAC;4BAC/C,OAAO;gCACH,SAAST,MAAM,OAAO;gCACtB,OAAOS,KAAK,KAAK;gCACjB,QAAQA,KAAK,MAAM;gCACnB,MAAMA,KAAK,IAAI;gCACfC;4BACJ;wBACJ;wBAEA,OAAO,IAAIE,SAAS;4BAChB,IAAID,SAAS,KAAK,CAAC,EAAE;wBACzB;oBACJ;gBACJ;YACJ;YACA,cAAcjB,CAAAA,UAAWA,QAAQ,OAAO,CAAC,gBAAgB,GAAG,EAAE,KAAKE,OAAO,EAAE;QAChF;QAEAS,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,MAAM,SAAS,EACf,OAAO;QAEX,MAAMC,OAAOC,MAAM,OAAO,CAACF,MAAM,IAAI,IAAIA,MAAM,IAAI,GAAG,EAAE;QACxD,IAAIC,KAAK,QAAQ,CAACE,0BACd,OAAO;QAEX,IAAIX,WAAW,QAAQ,EAAE,QACrB,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAACQ,MAAM,OAAO;QAErD,OAAO;IACX;IAEA,MAAMI,UAA4D,EAAE;IAEpEL,OAAO,OAAO,CAACC,CAAAA;QACX,MAAMK,SAAS,IAAIC,uBAA+C;YAC9D,UAAwB,CAAC;2CACM,EAAEN,MAAM,eAAe,CAAC;wBAC3C,EAAEO,eAAe,IAAI,CAACf,WAAW,IAAI,EAAE;;gBAE/C,CAAC;YACL,WAAW;gBACP,UAAU;oBACN,CAAC,CAAC,UAAU,EAAEQ,MAAM,eAAe,EAAE,CAAC,EAAE,OAAOQ,GAAGC,MAAMlB;wBACpD,MAAMmB,WAAWnB,QAAQ,SAAS,CAAC,OAAO,CAACM,iBAAiB,WAAW;wBAEvE,MAAMc,WAAW,MAAMpB,QAAQ,SAAS,CACnC,OAAO,CAACqB,oBACR,OAAO,CAAC;4BACL,YAAY,CAAC,YAAY,EAAEH,KAAK,MAAM,CAAC,OAAO,CAAC;4BAC/C,OAAO;gCACH,SAAST,MAAM,OAAO;gCACtB,OAAOS,KAAK,KAAK;gCACjB,QAAQA,KAAK,MAAM;gCACnB,MAAMA,KAAK,IAAI;gCACfC;4BACJ;wBACJ;wBAEJ,OAAO,IAAIG,SAAS;4BAChB,IAAIF,SAAS,KAAK,CAAC,EAAE;wBACzB;oBACJ;gBACJ;YACJ;YACA,cAAcpB,CAAAA,UACVA,QAAQ,SAAS,CAAC,OAAO,CAACG,eAAe,SAAS,GAAG,EAAE,KAAKD,OAAO,EAAE;QAC7E;QAEAY,OAAO,IAAI,GAAG,CAAC,uCAAuC,EAAEL,MAAM,OAAO,CAAC,CAAC,EAAER,WAAW,IAAI,EAAE;QAC1FY,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>;
@@ -1,35 +1,35 @@
1
- import { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from "@webiny/api-headless-cms";
1
+ import { CmsGraphQLSchemaFactory, CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from "@webiny/api-headless-cms";
2
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
2
3
  import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
3
- import { BeforeHandlerPlugin } from "@webiny/handler/plugins/BeforeHandlerPlugin.js";
4
- const createDefaultGraphQL = ()=>new BeforeHandlerPlugin(async (context)=>{
5
- const tenant = context.tenancy.getCurrentTenant();
6
- if (!await isHeadlessCmsReady(context)) return;
7
- const defaultPlugin = new CmsGraphQLSchemaPlugin({
8
- typeDefs: `
9
- type BulkActionResponseData {
10
- id: String
11
- }
4
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
5
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
6
+ const registerDefaultBulkActionGraphQL = async (context)=>{
7
+ const tenant = context.container.resolve(TenantContext).getTenant();
8
+ if (!await isHeadlessCmsReady(context)) return;
9
+ const defaultPlugin = new CmsGraphQLSchemaPlugin({
10
+ typeDefs: `
11
+ type BulkActionResponseData {
12
+ id: String
13
+ }
12
14
 
13
- type BulkActionResponse {
14
- data: BulkActionResponseData
15
- error: CmsError
16
- }
17
- `
18
- });
19
- defaultPlugin.name = "headless-cms.graphql.schema.bulkAction.default";
20
- const models = await context.security.withoutAuthorization(async ()=>{
21
- const allModels = await context.cms.listModels();
22
- return allModels.filter((model)=>{
23
- if (model.isPrivate) return false;
24
- const tags = Array.isArray(model.tags) ? model.tags : [];
25
- if (tags.includes(CMS_MODEL_SINGLETON_TAG)) return false;
26
- return true;
27
- });
28
- });
29
- const modelPlugins = [];
30
- models.forEach((model)=>{
31
- const plugin = new CmsGraphQLSchemaPlugin({
32
- typeDefs: `
15
+ type BulkActionResponse {
16
+ data: BulkActionResponseData
17
+ error: CmsError
18
+ }
19
+ `
20
+ });
21
+ defaultPlugin.name = "headless-cms.graphql.schema.bulkAction.default";
22
+ const modelsResult = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
23
+ if (modelsResult.isFail()) return;
24
+ const models = modelsResult.value.filter((model)=>{
25
+ if (model.isPrivate) return false;
26
+ const tags = Array.isArray(model.tags) ? model.tags : [];
27
+ return !tags.includes(CMS_MODEL_SINGLETON_TAG);
28
+ });
29
+ const modelPlugins = [];
30
+ models.forEach((model)=>{
31
+ const plugin = new CmsGraphQLSchemaPlugin({
32
+ typeDefs: `
33
33
  enum BulkAction${model.singularApiName}Name {
34
34
  _empty
35
35
  }
@@ -43,16 +43,18 @@ const createDefaultGraphQL = ()=>new BeforeHandlerPlugin(async (context)=>{
43
43
  ): BulkActionResponse
44
44
  }
45
45
  `,
46
- isApplicable: (context)=>context.tenancy.getCurrentTenant().id === tenant.id
47
- });
48
- plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;
49
- modelPlugins.push(plugin);
46
+ isApplicable: (context)=>context.container.resolve(TenantContext).getTenant().id === tenant.id
50
47
  });
51
- context.plugins.register([
52
- defaultPlugin,
53
- ...modelPlugins
54
- ]);
48
+ plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;
49
+ modelPlugins.push(plugin);
50
+ });
51
+ context.container.registerInstance(CmsGraphQLSchemaFactory, {
52
+ execute: ()=>[
53
+ defaultPlugin,
54
+ ...modelPlugins
55
+ ]
55
56
  });
56
- export { createDefaultGraphQL };
57
+ };
58
+ export { registerDefaultBulkActionGraphQL };
57
59
 
58
60
  //# sourceMappingURL=createDefaultGraphQL.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/createDefaultGraphQL.js","sources":["../../src/graphql/createDefaultGraphQL.ts"],"sourcesContent":["import type { HcmsBulkActionsContext } from \"~/types.js\";\nimport { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { BeforeHandlerPlugin } from \"@webiny/handler/plugins/BeforeHandlerPlugin.js\";\n\nexport const createDefaultGraphQL = () => {\n return new BeforeHandlerPlugin<HcmsBulkActionsContext>(async context => {\n const tenant = context.tenancy.getCurrentTenant();\n\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\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\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 return true;\n });\n });\n\n const modelPlugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n enum BulkAction${model.singularApiName}Name {\n _empty\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 isApplicable: context => context.tenancy.getCurrentTenant().id === tenant.id\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;\n modelPlugins.push(plugin);\n });\n\n context.plugins.register([defaultPlugin, ...modelPlugins]);\n });\n};\n"],"names":["createDefaultGraphQL","BeforeHandlerPlugin","context","tenant","isHeadlessCmsReady","defaultPlugin","CmsGraphQLSchemaPlugin","models","allModels","model","tags","Array","CMS_MODEL_SINGLETON_TAG","modelPlugins","plugin"],"mappings":";;;AAKO,MAAMA,uBAAuB,IACzB,IAAIC,oBAA4C,OAAMC;QACzD,MAAMC,SAASD,QAAQ,OAAO,CAAC,gBAAgB;QAE/C,IAAI,CAAE,MAAME,mBAAmBF,UAC3B;QAGJ,MAAMG,gBAAgB,IAAIC,uBAAuB;YAC7C,UAAwB,CAAC;;;;;;;;;YASzB,CAAC;QACL;QACAD,cAAc,IAAI,GAAG;QAErB,MAAME,SAAS,MAAML,QAAQ,QAAQ,CAAC,oBAAoB,CAAC;YACvD,MAAMM,YAAY,MAAMN,QAAQ,GAAG,CAAC,UAAU;YAC9C,OAAOM,UAAU,MAAM,CAACC,CAAAA;gBACpB,IAAIA,MAAM,SAAS,EACf,OAAO;gBAEX,MAAMC,OAAOC,MAAM,OAAO,CAACF,MAAM,IAAI,IAAIA,MAAM,IAAI,GAAG,EAAE;gBACxD,IAAIC,KAAK,QAAQ,CAACE,0BACd,OAAO;gBAEX,OAAO;YACX;QACJ;QAEA,MAAMC,eAAiE,EAAE;QAEzEN,OAAO,OAAO,CAACE,CAAAA;YACX,MAAMK,SAAS,IAAIR,uBAAuB;gBACtC,UAAwB,CAAC;mCACN,EAAEG,MAAM,eAAe,CAAC;;;;;kCAKzB,EAAEA,MAAM,eAAe,CAAC;8CACZ,EAAEA,MAAM,eAAe,CAAC;mCACnC,EAAEA,MAAM,eAAe,CAAC;;;;;gBAK3C,CAAC;gBACD,cAAcP,CAAAA,UAAWA,QAAQ,OAAO,CAAC,gBAAgB,GAAG,EAAE,KAAKC,OAAO,EAAE;YAChF;YAEAW,OAAO,IAAI,GAAG,CAAC,+CAA+C,EAAEL,MAAM,OAAO,EAAE;YAC/EI,aAAa,IAAI,CAACC;QACtB;QAEAZ,QAAQ,OAAO,CAAC,QAAQ,CAAC;YAACG;eAAkBQ;SAAa;IAC7D"}
1
+ {"version":3,"file":"graphql/createDefaultGraphQL.js","sources":["../../src/graphql/createDefaultGraphQL.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 { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\n/**\n * Registers the \"default\" bulk-action GraphQL for every public model: the shared response types plus,\n * per model, an empty `BulkAction<Model>Name` enum + `bulkAction<Model>` mutation skeleton (each\n * action extends the enum via createBulkActionGraphQL). Run per request, since models are only\n * known at request time.\n */\nexport const registerDefaultBulkActionGraphQL = async (context: HcmsBulkActionsContext) => {\n const tenant = context.container.resolve(TenantContext).getTenant();\n\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\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\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 return !tags.includes(CMS_MODEL_SINGLETON_TAG);\n });\n\n const modelPlugins: CmsGraphQLSchemaPlugin<HcmsBulkActionsContext>[] = [];\n\n models.forEach(model => {\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n enum BulkAction${model.singularApiName}Name {\n _empty\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 isApplicable: context =>\n context.container.resolve(TenantContext).getTenant().id === tenant.id\n });\n\n plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;\n modelPlugins.push(plugin);\n });\n\n context.container.registerInstance(CmsGraphQLSchemaFactory, {\n execute: () => [defaultPlugin, ...modelPlugins]\n });\n};\n"],"names":["registerDefaultBulkActionGraphQL","context","tenant","TenantContext","isHeadlessCmsReady","defaultPlugin","CmsGraphQLSchemaPlugin","modelsResult","IdentityContext","ListModelsUseCase","models","model","tags","Array","CMS_MODEL_SINGLETON_TAG","modelPlugins","plugin","CmsGraphQLSchemaFactory"],"mappings":";;;;;AAiBO,MAAMA,mCAAmC,OAAOC;IACnD,MAAMC,SAASD,QAAQ,SAAS,CAAC,OAAO,CAACE,eAAe,SAAS;IAEjE,IAAI,CAAE,MAAMC,mBAAmBH,UAC3B;IAGJ,MAAMI,gBAAgB,IAAIC,uBAAuB;QAC7C,UAAwB,CAAC;;;;;;;;;QASzB,CAAC;IACL;IACAD,cAAc,IAAI,GAAG;IAErB,MAAME,eAAe,MAAMN,QAAQ,SAAS,CACvC,OAAO,CAACO,iBACR,oBAAoB,CAAC,UACXP,QAAQ,SAAS,CAAC,OAAO,CAACQ,mBAAmB,OAAO;IAEnE,IAAIF,aAAa,MAAM,IACnB;IAEJ,MAAMG,SAASH,aAAa,KAAK,CAAC,MAAM,CAACI,CAAAA;QACrC,IAAIA,MAAM,SAAS,EACf,OAAO;QAEX,MAAMC,OAAOC,MAAM,OAAO,CAACF,MAAM,IAAI,IAAIA,MAAM,IAAI,GAAG,EAAE;QACxD,OAAO,CAACC,KAAK,QAAQ,CAACE;IAC1B;IAEA,MAAMC,eAAiE,EAAE;IAEzEL,OAAO,OAAO,CAACC,CAAAA;QACX,MAAMK,SAAS,IAAIV,uBAAuB;YACtC,UAAwB,CAAC;mCACF,EAAEK,MAAM,eAAe,CAAC;;;;;kCAKzB,EAAEA,MAAM,eAAe,CAAC;8CACZ,EAAEA,MAAM,eAAe,CAAC;mCACnC,EAAEA,MAAM,eAAe,CAAC;;;;;gBAK3C,CAAC;YACL,cAAcV,CAAAA,UACVA,QAAQ,SAAS,CAAC,OAAO,CAACE,eAAe,SAAS,GAAG,EAAE,KAAKD,OAAO,EAAE;QAC7E;QAEAc,OAAO,IAAI,GAAG,CAAC,+CAA+C,EAAEL,MAAM,OAAO,EAAE;QAC/EI,aAAa,IAAI,CAACC;IACtB;IAEAf,QAAQ,SAAS,CAAC,gBAAgB,CAACgB,yBAAyB;QACxD,SAAS,IAAM;gBAACZ;mBAAkBU;aAAa;IACnD;AACJ"}
package/index.d.ts CHANGED
@@ -1,8 +1,3 @@
1
- import type { HcmsBulkActionsContext } from "./types.js";
2
1
  export type * from "./abstractions/index.js";
3
- export { createHandlers } from "./handlers/index.js";
4
- export { createEmptyTrashBinsTask } from "./tasks/index.js";
5
- interface BulkActionsConfig {
6
- batchSize?: number;
7
- }
8
- export declare const createHcmsBulkActions: (config?: BulkActionsConfig) => ((import("@webiny/handler-aws/index.js").EventBridgeEventHandler<"WebinyEmptyTrashBin", Record<string, any>, any> | import("@webiny/handler/index.js").HandlerOnRequestPlugin<import("@webiny/handler/types.js").Context>)[] | import("@webiny/handler/index.js").BeforeHandlerPlugin<HcmsBulkActionsContext> | import("@webiny/api").ContextPlugin<import("@webiny/api/types.js").Context>)[];
2
+ export { HcmsBulkActionsFeature } from "./HcmsBulkActionsFeature.js";
3
+ export type { HcmsBulkActionsFeatureConfig } from "./HcmsBulkActionsFeature.js";
package/index.js CHANGED
@@ -1,46 +1 @@
1
- import { createHandlers } from "./handlers/index.js";
2
- import { createBeforeHandlerPlugin } from "@webiny/handler/plugins/BeforeHandlerPlugin.js";
3
- import { EntriesBulkAction, EntriesBulkActionConfig } from "./features/EntriesBulkAction/abstractions.js";
4
- import { BulkActionContext } from "./features/BulkActionContext/index.js";
5
- import { createBulkActionTasks } from "./features/EntriesBulkAction/createBulkActionTasks.js";
6
- import { createDefaultGraphQL } from "./graphql/createDefaultGraphQL.js";
7
- import { createBulkActionGraphQL } from "./graphql/createBulkActionGraphQL.js";
8
- import { createContextPlugin } from "@webiny/api";
9
- import { DeleteEntriesBulkActionFeature } from "./features/DeleteEntriesBulkAction/feature.js";
10
- import { MoveToFolderBulkActionFeature } from "./features/MoveToFolderBulkAction/feature.js";
11
- import { MoveToTrashBulkActionFeature } from "./features/MoveToTrashBulkAction/feature.js";
12
- import { PublishEntriesBulkActionFeature } from "./features/PublishEntriesBulkAction/feature.js";
13
- import { UnpublishEntriesBulkActionFeature } from "./features/UnpublishEntriesBulkAction/feature.js";
14
- import { RestoreEntriesBulkActionFeature } from "./features/RestoreEntriesBulkAction/feature.js";
15
- const createHcmsBulkActions = (config)=>{
16
- const batchSize = config?.batchSize ?? 100;
17
- return [
18
- createHandlers(),
19
- createDefaultGraphQL(),
20
- createContextPlugin((context)=>{
21
- context.container.registerInstance(EntriesBulkActionConfig, {
22
- batchSize
23
- });
24
- DeleteEntriesBulkActionFeature.register(context.container);
25
- MoveToFolderBulkActionFeature.register(context.container);
26
- MoveToTrashBulkActionFeature.register(context.container);
27
- PublishEntriesBulkActionFeature.register(context.container);
28
- UnpublishEntriesBulkActionFeature.register(context.container);
29
- RestoreEntriesBulkActionFeature.register(context.container);
30
- }),
31
- createBeforeHandlerPlugin(async (context)=>{
32
- context.container.registerInstance(BulkActionContext, context);
33
- const bulkActions = context.container.resolveAll(EntriesBulkAction);
34
- const bulkActionsConfig = context.container.resolve(EntriesBulkActionConfig);
35
- for (const bulkAction of bulkActions){
36
- const feature = createBulkActionTasks(bulkAction, bulkActionsConfig);
37
- feature.register(context.container);
38
- await createBulkActionGraphQL(context, bulkAction);
39
- }
40
- })
41
- ];
42
- };
43
- export { createEmptyTrashBinsTask } from "./tasks/index.js";
44
- export { createHandlers, createHcmsBulkActions };
45
-
46
- //# sourceMappingURL=index.js.map
1
+ export { HcmsBulkActionsFeature } from "./HcmsBulkActionsFeature.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-bulk-actions",
3
- "version": "0.0.0-unstable.7be00a75a9",
3
+ "version": "0.0.0-unstable.7c2def32a7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,24 +17,26 @@
17
17
  },
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@webiny/api-headless-cms": "0.0.0-unstable.7be00a75a9",
21
- "@webiny/feature": "0.0.0-unstable.7be00a75a9",
22
- "@webiny/handler": "0.0.0-unstable.7be00a75a9",
23
- "@webiny/handler-aws": "0.0.0-unstable.7be00a75a9",
24
- "@webiny/tasks": "0.0.0-unstable.7be00a75a9",
25
- "@webiny/utils": "0.0.0-unstable.7be00a75a9"
20
+ "@webiny/api-graphql": "0.0.0-unstable.7c2def32a7",
21
+ "@webiny/api-headless-cms": "0.0.0-unstable.7c2def32a7",
22
+ "@webiny/background-tasks": "0.0.0-unstable.7c2def32a7",
23
+ "@webiny/event-handler-core": "0.0.0-unstable.7c2def32a7",
24
+ "@webiny/feature": "0.0.0-unstable.7c2def32a7",
25
+ "@webiny/handler": "0.0.0-unstable.7c2def32a7",
26
+ "@webiny/utils": "0.0.0-unstable.7c2def32a7"
26
27
  },
27
28
  "devDependencies": {
28
- "@webiny/api": "0.0.0-unstable.7be00a75a9",
29
- "@webiny/api-core": "0.0.0-unstable.7be00a75a9",
30
- "@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
31
- "@webiny/handler-graphql": "0.0.0-unstable.7be00a75a9",
32
- "@webiny/plugins": "0.0.0-unstable.7be00a75a9",
33
- "@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
34
- "@webiny/wcp": "0.0.0-unstable.7be00a75a9",
35
- "graphql": "16.14.0",
36
- "typescript": "6.0.3",
37
- "vitest": "4.1.7"
29
+ "@webiny/api": "0.0.0-unstable.7c2def32a7",
30
+ "@webiny/api-core": "0.0.0-unstable.7c2def32a7",
31
+ "@webiny/api-graphql": "0.0.0-unstable.7c2def32a7",
32
+ "@webiny/api-headless-cms-testing": "0.0.0-unstable.7c2def32a7",
33
+ "@webiny/build-tools": "0.0.0-unstable.7c2def32a7",
34
+ "@webiny/di": "2.0.0",
35
+ "@webiny/plugins": "0.0.0-unstable.7c2def32a7",
36
+ "@webiny/wcp": "0.0.0-unstable.7c2def32a7",
37
+ "graphql": "16.14.2",
38
+ "typescript": "7.0.2",
39
+ "vitest": "4.1.11"
38
40
  },
39
41
  "publishConfig": {
40
42
  "access": "public"
@@ -1,25 +1,30 @@
1
1
  import type { IEmptyTrashBinsInput, IEmptyTrashBinsOutput } from "../types.js";
2
- import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
+ import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
3
3
  import { ListTenantsUseCase } from "@webiny/api-core/features/tenancy/ListTenants/index.js";
4
4
  import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
5
5
  import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
6
6
  import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js";
7
7
  import { ListDeletedEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
8
- declare class EmptyTrashBinTask implements TaskDefinition.Interface<IEmptyTrashBinsInput, IEmptyTrashBinsOutput> {
8
+ declare class EmptyTrashBinTaskHandlerImpl implements TaskHandler.Interface<IEmptyTrashBinsInput, IEmptyTrashBinsOutput> {
9
9
  private tenantContext;
10
10
  private listTenants;
11
11
  private listModels;
12
12
  private listDeletedEntries;
13
13
  private deleteEntry;
14
+ constructor(tenantContext: TenantContext.Interface, listTenants: ListTenantsUseCase.Interface, listModels: ListModelsUseCase.Interface, listDeletedEntries: ListDeletedEntriesUseCase.Interface, deleteEntry: DeleteEntryUseCase.Interface);
15
+ run(params: TaskHandler.RunParams<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>): Promise<TaskDefinition.Result<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>>;
16
+ }
17
+ declare class EmptyTrashBinTask implements TaskDefinition.Interface {
14
18
  readonly isPrivate = true;
15
19
  readonly id = "hcmsEntriesEmptyTrashBins";
16
20
  readonly title = "Headless CMS - Empty all trash bins";
17
21
  readonly description = "Delete all entries in the trash bin for each model in the system.";
18
22
  readonly maxIterations = 120;
19
23
  readonly databaseLogs = false;
20
- readonly selfCleanup: ("onSuccess" | "onAbort")[];
21
- constructor(tenantContext: TenantContext.Interface, listTenants: ListTenantsUseCase.Interface, listModels: ListModelsUseCase.Interface, listDeletedEntries: ListDeletedEntriesUseCase.Interface, deleteEntry: DeleteEntryUseCase.Interface);
22
- run(params: TaskDefinition.RunParams<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>): Promise<TaskDefinition.Result<IEmptyTrashBinsInput, IEmptyTrashBinsOutput>>;
24
+ readonly selfCleanup: ("onAbort" | "onSuccess")[];
25
+ handler: typeof EmptyTrashBinTaskHandlerImpl & {
26
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskHandler<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
27
+ };
23
28
  }
24
29
  export declare const EmptyTrashBinTaskDefinition: typeof EmptyTrashBinTask & {
25
30
  __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>>;