@webiny/api-headless-cms-bulk-actions 6.4.12-beta.6 → 6.4.12-beta.8

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.
@@ -1,7 +1,29 @@
1
1
  import { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from "@webiny/api-headless-cms";
2
- import { Response } from "@webiny/handler-graphql";
2
+ import { ErrorResponse, Response } from "@webiny/handler-graphql";
3
+ import { EntryNotAuthorizedError } from "@webiny/api-headless-cms/domain/contentEntry/errors.js";
3
4
  import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
4
5
  import { BulkActionName } from "../domain/BulkActionName.js";
6
+ const getRequiredAccess = (action)=>{
7
+ switch(action){
8
+ case "Delete":
9
+ case "MoveToTrash":
10
+ return {
11
+ rwd: "d"
12
+ };
13
+ case "Publish":
14
+ return {
15
+ pw: "p"
16
+ };
17
+ case "Unpublish":
18
+ return {
19
+ pw: "u"
20
+ };
21
+ default:
22
+ return {
23
+ rwd: "w"
24
+ };
25
+ }
26
+ };
5
27
  const createBulkActionGraphQL = async (context, bulkAction)=>{
6
28
  const tenant = context.tenancy.getCurrentTenant();
7
29
  if (!await isHeadlessCmsReady(context)) return;
@@ -26,6 +48,11 @@ const createBulkActionGraphQL = async (context, bulkAction)=>{
26
48
  resolvers: {
27
49
  Mutation: {
28
50
  [`bulkAction${model.singularApiName}`]: async (_, args, context)=>{
51
+ const canAccess = await context.cms.accessControl.canAccessEntry({
52
+ model,
53
+ ...getRequiredAccess(args.action)
54
+ });
55
+ if (!canAccess) return new ErrorResponse(EntryNotAuthorizedError.fromModel(model));
29
56
  const identity = context.security.getIdentity();
30
57
  const response = await context.tasks.trigger({
31
58
  definition: `hcmsBulkList${args.action}Entries`,
@@ -43,7 +70,7 @@ const createBulkActionGraphQL = async (context, bulkAction)=>{
43
70
  }
44
71
  }
45
72
  },
46
- isApplicable: (context)=>context.tenancy.getCurrentTenant().id === tenant.id
73
+ isApplicable: (context)=>context.cms.MANAGE && context.tenancy.getCurrentTenant().id === tenant.id
47
74
  });
48
75
  plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${bulkAction.name}`;
49
76
  plugins.push(plugin);
@@ -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 { CmsGraphQLSchemaPlugin, isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { EntryNotAuthorizedError } from \"@webiny/api-headless-cms/domain/contentEntry/errors.js\";\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\n/**\n * The permission each bulk action requires on the model, matching the single-entry use case it runs.\n * Custom bulk actions require write access.\n */\nconst getRequiredAccess = (action: string): { rwd?: string; pw?: string } => {\n switch (action) {\n case \"Delete\":\n case \"MoveToTrash\":\n return { rwd: \"d\" };\n case \"Publish\":\n return { pw: \"p\" };\n case \"Unpublish\":\n return { pw: \"u\" };\n default:\n return { rwd: \"w\" };\n }\n};\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 canAccess = await context.cms.accessControl.canAccessEntry({\n model,\n ...getRequiredAccess(args.action)\n });\n if (!canAccess) {\n return new ErrorResponse(EntryNotAuthorizedError.fromModel(model));\n }\n\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 // Bulk actions change entries, so they are only part of the manage API.\n isApplicable: context => {\n return context.cms.MANAGE && context.tenancy.getCurrentTenant().id === tenant.id;\n }\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":["getRequiredAccess","action","createBulkActionGraphQL","context","bulkAction","tenant","isHeadlessCmsReady","models","allModels","model","tags","Array","CMS_MODEL_SINGLETON_TAG","plugins","plugin","CmsGraphQLSchemaPlugin","BulkActionName","_","args","canAccess","ErrorResponse","EntryNotAuthorizedError","identity","response","Response"],"mappings":";;;;;AAYA,MAAMA,oBAAoB,CAACC;IACvB,OAAQA;QACJ,KAAK;QACL,KAAK;YACD,OAAO;gBAAE,KAAK;YAAI;QACtB,KAAK;YACD,OAAO;gBAAE,IAAI;YAAI;QACrB,KAAK;YACD,OAAO;gBAAE,IAAI;YAAI;QACrB;YACI,OAAO;gBAAE,KAAK;YAAI;IAC1B;AACJ;AAEO,MAAMC,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,YAAY,MAAMhB,QAAQ,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC;4BAC7DM;4BACA,GAAGT,kBAAkBkB,KAAK,MAAM,CAAC;wBACrC;wBACA,IAAI,CAACC,WACD,OAAO,IAAIC,cAAcC,wBAAwB,SAAS,CAACZ;wBAG/D,MAAMa,WAAWnB,QAAQ,QAAQ,CAAC,WAAW;wBAE7C,MAAMoB,WAAW,MAAMpB,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;gCACfI;4BACJ;wBACJ;wBAEA,OAAO,IAAIE,SAAS;4BAChB,IAAID,SAAS,KAAK,CAAC,EAAE;wBACzB;oBACJ;gBACJ;YACJ;YAEA,cAAcpB,CAAAA,UACHA,QAAQ,GAAG,CAAC,MAAM,IAAIA,QAAQ,OAAO,CAAC,gBAAgB,GAAG,EAAE,KAAKE,OAAO,EAAE;QAExF;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"}
@@ -43,7 +43,7 @@ const createDefaultGraphQL = ()=>new BeforeHandlerPlugin(async (context)=>{
43
43
  ): BulkActionResponse
44
44
  }
45
45
  `,
46
- isApplicable: (context)=>context.tenancy.getCurrentTenant().id === tenant.id
46
+ isApplicable: (context)=>context.cms.MANAGE && context.tenancy.getCurrentTenant().id === tenant.id
47
47
  });
48
48
  plugin.name = `headless-cms.graphql.schema.bulkAction.default.${model.modelId}`;
49
49
  modelPlugins.push(plugin);
@@ -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 { 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 // Bulk actions change entries, so they are only part of the manage API.\n isApplicable: context => {\n return (\n context.cms.MANAGE && context.tenancy.getCurrentTenant().id === tenant.id\n );\n }\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;gBAED,cAAcP,CAAAA,UAENA,QAAQ,GAAG,CAAC,MAAM,IAAIA,QAAQ,OAAO,CAAC,gBAAgB,GAAG,EAAE,KAAKC,OAAO,EAAE;YAGrF;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-bulk-actions",
3
- "version": "6.4.12-beta.6",
3
+ "version": "6.4.12-beta.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,24 +17,24 @@
17
17
  },
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@webiny/api-headless-cms": "6.4.12-beta.6",
21
- "@webiny/background-tasks": "6.4.12-beta.6",
22
- "@webiny/feature": "6.4.12-beta.6",
23
- "@webiny/handler": "6.4.12-beta.6",
24
- "@webiny/handler-aws": "6.4.12-beta.6",
25
- "@webiny/utils": "6.4.12-beta.6"
20
+ "@webiny/api-headless-cms": "6.4.12-beta.8",
21
+ "@webiny/background-tasks": "6.4.12-beta.8",
22
+ "@webiny/feature": "6.4.12-beta.8",
23
+ "@webiny/handler": "6.4.12-beta.8",
24
+ "@webiny/handler-aws": "6.4.12-beta.8",
25
+ "@webiny/utils": "6.4.12-beta.8"
26
26
  },
27
27
  "devDependencies": {
28
- "@webiny/api": "6.4.12-beta.6",
29
- "@webiny/api-core": "6.4.12-beta.6",
30
- "@webiny/build-tools": "6.4.12-beta.6",
31
- "@webiny/handler-graphql": "6.4.12-beta.6",
32
- "@webiny/plugins": "6.4.12-beta.6",
33
- "@webiny/project-utils": "6.4.12-beta.6",
34
- "@webiny/wcp": "6.4.12-beta.6",
35
- "graphql": "16.14.2",
28
+ "@webiny/api": "6.4.12-beta.8",
29
+ "@webiny/api-core": "6.4.12-beta.8",
30
+ "@webiny/build-tools": "6.4.12-beta.8",
31
+ "@webiny/handler-graphql": "6.4.12-beta.8",
32
+ "@webiny/plugins": "6.4.12-beta.8",
33
+ "@webiny/project-utils": "6.4.12-beta.8",
34
+ "@webiny/wcp": "6.4.12-beta.8",
35
+ "graphql": "16.15.0",
36
36
  "typescript": "6.0.3",
37
- "vitest": "5.0.1"
37
+ "vitest": "5.1.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { Context as TasksContext, ITaskIdentity } from \"@webiny/background-tasks/api/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {}\n\n/**\n * Bulk Action Operation\n */\n\nexport interface IBulkActionOperationInput {\n modelId: string;\n ids: string[];\n data?: Record<string, any>;\n identity: ITaskIdentity;\n done?: string[];\n failed?: string[];\n}\n\nexport interface IBulkActionOperationOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n>;\n\n/**\n * Bulk Action Operation By Model\n */\n\nexport enum BulkActionOperationByModelAction {\n CREATE_SUBTASKS = \"CREATE_SUBTASKS\",\n CHECK_MORE_SUBTASKS = \"CHECK_MORE_SUBTASKS\",\n PROCESS_SUBTASKS = \"PROCESS_SUBTASKS\",\n END_TASK = \"END_TASK\"\n}\n\nexport interface IBulkActionOperationByModelInput {\n modelId: string;\n identity?: ITaskIdentity;\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n data?: Record<string, any>;\n action?: BulkActionOperationByModelAction;\n}\n\nexport interface IBulkActionOperationByModelOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationByModelTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n>;\n\n/**\n * Empty Trash Bin\n */\n\nexport interface IEmptyTrashBinsInput {\n executedTenantIds?: string[] | null;\n}\n\nexport type IEmptyTrashBinsOutput = TaskDefinition.ResultDone;\n\nexport type IEmptyTrashBinsTaskParams = TaskDefinition.RunParams<\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n>;\n"],"names":["BulkActionOperationByModelAction"],"mappings":"AAkCO,IAAKA,yCAAgCA,WAAAA,GAAAA,SAAhCA,gCAAgC;;;;;WAAhCA"}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { Context as TasksContext, ITaskIdentity } from \"@webiny/background-tasks/api/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface HcmsBulkActionsContext extends BaseContext, CmsContext, TasksContext {}\n\n/**\n * Bulk Action Operation\n */\n\nexport interface IBulkActionOperationInput {\n modelId: string;\n ids: string[];\n data?: Record<string, any>;\n identity: ITaskIdentity;\n done?: string[];\n failed?: string[];\n}\n\nexport interface IBulkActionOperationOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationInput,\n IBulkActionOperationOutput\n>;\n\n/**\n * Bulk Action Operation By Model\n */\n\nexport enum BulkActionOperationByModelAction {\n CREATE_SUBTASKS = \"CREATE_SUBTASKS\",\n CHECK_MORE_SUBTASKS = \"CHECK_MORE_SUBTASKS\",\n PROCESS_SUBTASKS = \"PROCESS_SUBTASKS\",\n END_TASK = \"END_TASK\"\n}\n\nexport interface IBulkActionOperationByModelInput {\n modelId: string;\n identity?: ITaskIdentity;\n where?: Record<string, any>;\n search?: string;\n after?: string | null;\n data?: Record<string, any>;\n action?: BulkActionOperationByModelAction;\n}\n\nexport interface IBulkActionOperationByModelOutput {\n done: string[];\n failed: string[];\n}\n\nexport type IBulkActionOperationByModelTaskParams = TaskDefinition.RunParams<\n IBulkActionOperationByModelInput,\n IBulkActionOperationByModelOutput\n>;\n\n/**\n * Empty Trash Bin\n */\n\nexport interface IEmptyTrashBinsInput {\n executedTenantIds?: string[] | null;\n}\n\nexport type IEmptyTrashBinsOutput = TaskDefinition.ResultDone;\n\nexport type IEmptyTrashBinsTaskParams = TaskDefinition.RunParams<\n IEmptyTrashBinsInput,\n IEmptyTrashBinsOutput\n>;\n"],"names":["BulkActionOperationByModelAction"],"mappings":"AAkCO,IAAKA,yCAAgCA,WAAAA,GAAAA,SAAAA,gCAAAA"}