@webiny/api-headless-cms-bulk-actions 6.5.2-beta.0 → 6.5.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,41 @@
|
|
|
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
|
+
import { FolderLevelPermissions } from "@webiny/api-aco/features/flp/FolderLevelPermissions/index.js";
|
|
7
|
+
import { ROOT_FOLDER } from "@webiny/api-aco/constants.js";
|
|
8
|
+
const getRequiredAccess = (action)=>{
|
|
9
|
+
switch(action){
|
|
10
|
+
case "Delete":
|
|
11
|
+
case "MoveToTrash":
|
|
12
|
+
return {
|
|
13
|
+
rwd: "d"
|
|
14
|
+
};
|
|
15
|
+
case "Publish":
|
|
16
|
+
return {
|
|
17
|
+
pw: "p"
|
|
18
|
+
};
|
|
19
|
+
case "Unpublish":
|
|
20
|
+
return {
|
|
21
|
+
pw: "u"
|
|
22
|
+
};
|
|
23
|
+
default:
|
|
24
|
+
return {
|
|
25
|
+
rwd: "w"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const canMoveToFolder = async (context, folderId)=>{
|
|
30
|
+
if (folderId === ROOT_FOLDER) return true;
|
|
31
|
+
const [flp] = context.container.resolveAll(FolderLevelPermissions);
|
|
32
|
+
if (!flp || !flp.canUseFolderLevelPermissions()) return true;
|
|
33
|
+
const permissions = await flp.getFolderLevelPermissions(folderId);
|
|
34
|
+
return flp.canAccessFolderContent({
|
|
35
|
+
permissions,
|
|
36
|
+
rwd: "w"
|
|
37
|
+
});
|
|
38
|
+
};
|
|
5
39
|
const createBulkActionGraphQL = async (context, bulkAction)=>{
|
|
6
40
|
const tenant = context.tenancy.getCurrentTenant();
|
|
7
41
|
if (!await isHeadlessCmsReady(context)) return;
|
|
@@ -26,6 +60,19 @@ const createBulkActionGraphQL = async (context, bulkAction)=>{
|
|
|
26
60
|
resolvers: {
|
|
27
61
|
Mutation: {
|
|
28
62
|
[`bulkAction${model.singularApiName}`]: async (_, args, context)=>{
|
|
63
|
+
const canAccess = await context.cms.accessControl.canAccessEntry({
|
|
64
|
+
model,
|
|
65
|
+
...getRequiredAccess(args.action)
|
|
66
|
+
});
|
|
67
|
+
if (!canAccess) return new ErrorResponse(EntryNotAuthorizedError.fromModel(model));
|
|
68
|
+
if (args.action === BulkActionName.from("moveToFolder")) {
|
|
69
|
+
const folderId = args.data?.folderId;
|
|
70
|
+
if (!folderId) return new ErrorResponse({
|
|
71
|
+
code: "VALIDATION_FAILED",
|
|
72
|
+
message: 'Missing "data.folderId" in the input.'
|
|
73
|
+
});
|
|
74
|
+
if (!await canMoveToFolder(context, folderId)) return new ErrorResponse(EntryNotAuthorizedError.fromModel(model));
|
|
75
|
+
}
|
|
29
76
|
const identity = context.security.getIdentity();
|
|
30
77
|
const response = await context.tasks.trigger({
|
|
31
78
|
definition: `hcmsBulkList${args.action}Entries`,
|
|
@@ -43,7 +90,7 @@ const createBulkActionGraphQL = async (context, bulkAction)=>{
|
|
|
43
90
|
}
|
|
44
91
|
}
|
|
45
92
|
},
|
|
46
|
-
isApplicable: (context)=>context.tenancy.getCurrentTenant().id === tenant.id
|
|
93
|
+
isApplicable: (context)=>context.cms.MANAGE && context.tenancy.getCurrentTenant().id === tenant.id
|
|
47
94
|
});
|
|
48
95
|
plugin.name = `headless-cms.graphql.schema.bulkAction.${model.modelId}.${bulkAction.name}`;
|
|
49
96
|
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":["
|
|
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\";\nimport { FolderLevelPermissions } from \"@webiny/api-aco/features/flp/FolderLevelPermissions/index.js\";\nimport { ROOT_FOLDER } from \"@webiny/api-aco/constants.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\n/**\n * Bulk action tasks run without authorization, so the target folder of a move is checked here,\n * with the same folder-level permission check the single-entry move uses.\n */\nconst canMoveToFolder = async (\n context: HcmsBulkActionsContext,\n folderId: string\n): Promise<boolean> => {\n if (folderId === ROOT_FOLDER) {\n return true;\n }\n\n const [flp] = context.container.resolveAll(FolderLevelPermissions);\n if (!flp || !flp.canUseFolderLevelPermissions()) {\n return true;\n }\n\n const permissions = await flp.getFolderLevelPermissions(folderId);\n return flp.canAccessFolderContent({ permissions, rwd: \"w\" });\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 if (args.action === BulkActionName.from(\"moveToFolder\")) {\n const folderId = args.data?.folderId;\n if (!folderId) {\n return new ErrorResponse({\n code: \"VALIDATION_FAILED\",\n message: `Missing \"data.folderId\" in the input.`\n });\n }\n if (!(await canMoveToFolder(context, folderId))) {\n return new ErrorResponse(EntryNotAuthorizedError.fromModel(model));\n }\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","canMoveToFolder","context","folderId","ROOT_FOLDER","flp","FolderLevelPermissions","permissions","createBulkActionGraphQL","bulkAction","tenant","isHeadlessCmsReady","models","allModels","model","tags","Array","CMS_MODEL_SINGLETON_TAG","plugins","plugin","CmsGraphQLSchemaPlugin","BulkActionName","_","args","canAccess","ErrorResponse","EntryNotAuthorizedError","identity","response","Response"],"mappings":"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"}
|
|
@@ -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;
|
|
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.5.2-beta.
|
|
3
|
+
"version": "6.5.2-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -17,21 +17,22 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@webiny/api-
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/handler
|
|
25
|
-
"@webiny/
|
|
20
|
+
"@webiny/api-aco": "6.5.2-beta.1",
|
|
21
|
+
"@webiny/api-headless-cms": "6.5.2-beta.1",
|
|
22
|
+
"@webiny/background-tasks": "6.5.2-beta.1",
|
|
23
|
+
"@webiny/feature": "6.5.2-beta.1",
|
|
24
|
+
"@webiny/handler": "6.5.2-beta.1",
|
|
25
|
+
"@webiny/handler-aws": "6.5.2-beta.1",
|
|
26
|
+
"@webiny/utils": "6.5.2-beta.1"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@webiny/api": "6.5.2-beta.
|
|
29
|
-
"@webiny/api-core": "6.5.2-beta.
|
|
30
|
-
"@webiny/build-tools": "6.5.2-beta.
|
|
31
|
-
"@webiny/handler-graphql": "6.5.2-beta.
|
|
32
|
-
"@webiny/plugins": "6.5.2-beta.
|
|
33
|
-
"@webiny/project-utils": "6.5.2-beta.
|
|
34
|
-
"@webiny/wcp": "6.5.2-beta.
|
|
29
|
+
"@webiny/api": "6.5.2-beta.1",
|
|
30
|
+
"@webiny/api-core": "6.5.2-beta.1",
|
|
31
|
+
"@webiny/build-tools": "6.5.2-beta.1",
|
|
32
|
+
"@webiny/handler-graphql": "6.5.2-beta.1",
|
|
33
|
+
"@webiny/plugins": "6.5.2-beta.1",
|
|
34
|
+
"@webiny/project-utils": "6.5.2-beta.1",
|
|
35
|
+
"@webiny/wcp": "6.5.2-beta.1",
|
|
35
36
|
"graphql": "16.14.2",
|
|
36
37
|
"typescript": "7.0.2",
|
|
37
38
|
"vitest": "5.0.5"
|