@webiny/api-headless-cms 5.34.6-beta.6 → 5.34.7-beta.0
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.
|
@@ -161,8 +161,8 @@ const cmsRoutes = new _handler.RoutePlugin(({
|
|
|
161
161
|
type: context.cms.type
|
|
162
162
|
});
|
|
163
163
|
} catch (ex) {
|
|
164
|
-
console.
|
|
165
|
-
console.
|
|
164
|
+
console.error(`Error while generating the schema.`);
|
|
165
|
+
console.error(formatErrorPayload(ex));
|
|
166
166
|
throw ex;
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -171,8 +171,8 @@ const cmsRoutes = new _handler.RoutePlugin(({
|
|
|
171
171
|
try {
|
|
172
172
|
body = createRequestBody(request.body);
|
|
173
173
|
} catch (ex) {
|
|
174
|
-
console.
|
|
175
|
-
console.
|
|
174
|
+
console.error(`Error while creating the body request.`);
|
|
175
|
+
console.error(formatErrorPayload(ex));
|
|
176
176
|
throw ex;
|
|
177
177
|
}
|
|
178
178
|
|
|
@@ -180,8 +180,8 @@ const cmsRoutes = new _handler.RoutePlugin(({
|
|
|
180
180
|
const result = await (0, _processRequestBody.default)(body, schema, context);
|
|
181
181
|
return reply.code(200).send(result);
|
|
182
182
|
} catch (ex) {
|
|
183
|
-
console.
|
|
184
|
-
console.
|
|
183
|
+
console.error(`Error while processing the body request.`);
|
|
184
|
+
console.error(formatErrorPayload(ex));
|
|
185
185
|
throw ex;
|
|
186
186
|
}
|
|
187
187
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createRequestBody","body","JSON","parse","schemaList","Map","generateCacheKey","args","context","locale","type","lastModelChange","cms","getModelLastChange","code","toISOString","join","getSchema","params","tenantId","tenancy","getCurrentTenant","id","cacheKey","cachedSchema","get","key","schema","security","disableAuthorization","models","listModels","filter","model","isPrivate","enableAuthorization","generateSchema","set","err","Array","isArray","locations","WebinyError","message","data","location","invalidSegment","codeFrame","source","line","column","frameSize","checkEndpointAccess","permission","getPermission","NotAuthorizedError","reason","formatErrorPayload","error","stringify","name","stack","cmsRoutes","RoutePlugin","onPost","onOptions","request","reply","ex","send","getLocale","console","log","result","processRequestBody","_","status","hijack","graphQLHandlerFactory","debug","debugPlugins"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import { GraphQLSchema } from \"graphql\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport debugPlugins from \"@webiny/handler-graphql/debugPlugins\";\nimport processRequestBody from \"@webiny/handler-graphql/processRequestBody\";\nimport { GraphQLRequestBody } from \"@webiny/handler-graphql/types\";\nimport { RoutePlugin } from \"@webiny/handler\";\nimport WebinyError from \"@webiny/error\";\n// @ts-ignore `code-frame` has no types\nimport codeFrame from \"code-frame\";\nimport { generateSchema } from \"~/graphql/generateSchema\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n locale: I18NLocale;\n}\n\nconst createRequestBody = (body: unknown): GraphQLRequestBody | GraphQLRequestBody[] => {\n /**\n * We are trusting that the body payload is correct.\n * The `processRequestBody` will fail if it is not.\n */\n return typeof body === \"string\" ? JSON.parse(body) : body;\n};\n\nconst schemaList = new Map<string, SchemaCache>();\n\nconst generateCacheKey = async (args: GetSchemaParams): Promise<string> => {\n const { context, locale, type } = args;\n const lastModelChange = await context.cms.getModelLastChange();\n return [locale.code, type, lastModelChange.toISOString()].join(\"#\");\n};\n\n/**\n * Gets an existing schema or rewrites existing one or creates a completely new one\n * depending on the schemaId created from type and locale parameters\n */\nconst getSchema = async (params: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context, type, locale } = params;\n const tenantId = context.tenancy.getCurrentTenant().id;\n const id = `${tenantId}#${type}#${locale.code}`;\n\n const cacheKey = await generateCacheKey(params);\n const cachedSchema = schemaList.get(id);\n if (cachedSchema?.key === cacheKey) {\n return cachedSchema.schema;\n }\n // Load model data\n context.security.disableAuthorization();\n const models = (await context.cms.listModels()).filter(model => model.isPrivate !== true);\n context.security.enableAuthorization();\n try {\n const schema = await generateSchema({\n ...params,\n models\n });\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n } catch (err) {\n if (!Array.isArray(err.locations)) {\n throw new WebinyError({\n message: err.message,\n code: err.code || \"INVALID_GRAPHQL_SCHEMA_LOCATIONS\",\n data: {\n ...(err.data || {}),\n locations: err.locations\n }\n });\n }\n const [location] = err.locations;\n\n throw new WebinyError({\n code: \"INVALID_GRAPHQL_SCHEMA\",\n message: err.message,\n data: {\n invalidSegment: codeFrame(err.source.body, location.line, location.column, {\n frameSize: 15\n })\n }\n });\n }\n};\n\nconst checkEndpointAccess = async (context: CmsContext): Promise<void> => {\n const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access \"${context.cms.type}\" endpoint.`\n }\n });\n }\n};\n\nconst formatErrorPayload = (error: Error): string => {\n if (error instanceof WebinyError) {\n return JSON.stringify({\n type: \"CmsGraphQLWebinyError\",\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return JSON.stringify({\n type: \"Error\",\n name: error.name,\n message: error.message,\n stack: error.stack\n });\n};\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nconst cmsRoutes = new RoutePlugin<CmsContext>(({ onPost, onOptions, context }) => {\n onPost(\"/cms/:type(^manage|preview|read$)/:locale\", async (request, reply) => {\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n let schema: GraphQLSchema;\n try {\n schema = await getSchema({\n context,\n locale: context.cms.getLocale(),\n type: context.cms.type as ApiEndpoint\n });\n } catch (ex) {\n console.log(`Error while generating the schema.`);\n console.log(formatErrorPayload(ex));\n throw ex;\n }\n\n let body: GraphQLRequestBody | GraphQLRequestBody[] = [];\n try {\n body = createRequestBody(request.body);\n } catch (ex) {\n console.log(`Error while creating the body request.`);\n console.log(formatErrorPayload(ex));\n throw ex;\n }\n\n try {\n const result = await processRequestBody(body, schema, context);\n return reply.code(200).send(result);\n } catch (ex) {\n console.log(`Error while processing the body request.`);\n console.log(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n onOptions(\"/cms/:type(^manage|preview|read$)/:locale\", async (_, reply) => {\n return reply.status(204).send({}).hijack();\n });\n});\n\ncmsRoutes.name = \"headless-cms.graphql.route.default\";\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n return [\n ...(debug ? debugPlugins() : []),\n cmsRoutes,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":";;;;;;;;;;;AAGA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAFA;AAcA,MAAMA,iBAAiB,GAAIC,IAAD,IAA8D;EACpF;AACJ;AACA;AACA;EACI,OAAO,OAAOA,IAAP,KAAgB,QAAhB,GAA2BC,IAAI,CAACC,KAAL,CAAWF,IAAX,CAA3B,GAA8CA,IAArD;AACH,CAND;;AAQA,MAAMG,UAAU,GAAG,IAAIC,GAAJ,EAAnB;;AAEA,MAAMC,gBAAgB,GAAG,MAAOC,IAAP,IAAkD;EACvE,MAAM;IAAEC,OAAF;IAAWC,MAAX;IAAmBC;EAAnB,IAA4BH,IAAlC;EACA,MAAMI,eAAe,GAAG,MAAMH,OAAO,CAACI,GAAR,CAAYC,kBAAZ,EAA9B;EACA,OAAO,CAACJ,MAAM,CAACK,IAAR,EAAcJ,IAAd,EAAoBC,eAAe,CAACI,WAAhB,EAApB,EAAmDC,IAAnD,CAAwD,GAAxD,CAAP;AACH,CAJD;AA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O,CAACjE,IAAT,CAAxB;IACH,CAFD,CAEE,OAAOmE,EAAP,EAAW;MACTG,OAAO,CAACC,GAAR,CAAa,wCAAb;MACAD,OAAO,CAACC,GAAR,CAAYf,kBAAkB,CAACW,EAAD,CAA9B;MACA,MAAMA,EAAN;IACH;;IAED,IAAI;MACA,MAAMK,MAAM,GAAG,MAAM,IAAAC,2BAAA,EAAmBzE,IAAnB,EAAyB0B,MAAzB,EAAiCnB,OAAjC,CAArB;MACA,OAAO2D,KAAK,CAACrD,IAAN,CAAW,GAAX,EAAgBuD,IAAhB,CAAqBI,MAArB,CAAP;IACH,CAHD,CAGE,OAAOL,EAAP,EAAW;MACTG,OAAO,CAACC,GAAR,CAAa,0CAAb;MACAD,OAAO,CAACC,GAAR,CAAYf,kBAAkB,CAACW,EAAD,CAA9B;MACA,MAAMA,EAAN;IACH;EACJ,CA7CK,CAAN;EA+CAH,SAAS,CAAC,2CAAD,EAA8C,OAAOU,CAAP,EAAUR,KAAV,KAAoB;IACvE,OAAOA,KAAK,CAACS,MAAN,CAAa,GAAb,EAAkBP,IAAlB,CAAuB,EAAvB,EAA2BQ,MAA3B,EAAP;EACH,CAFQ,CAAT;AAGH,CAnDiB,CAAlB;AAqDAf,SAAS,CAACF,IAAV,GAAiB,oCAAjB;;AAEO,MAAMkB,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA8D;EAC/F,OAAO,CACH,IAAIA,KAAK,GAAG,IAAAC,qBAAA,GAAH,GAAoB,EAA7B,CADG,EAEHlB,SAFG,EAGH;IACIpD,IAAI,EAAE;EADV,CAHG,CAAP;AAOH,CARM"}
|
|
1
|
+
{"version":3,"names":["createRequestBody","body","JSON","parse","schemaList","Map","generateCacheKey","args","context","locale","type","lastModelChange","cms","getModelLastChange","code","toISOString","join","getSchema","params","tenantId","tenancy","getCurrentTenant","id","cacheKey","cachedSchema","get","key","schema","security","disableAuthorization","models","listModels","filter","model","isPrivate","enableAuthorization","generateSchema","set","err","Array","isArray","locations","WebinyError","message","data","location","invalidSegment","codeFrame","source","line","column","frameSize","checkEndpointAccess","permission","getPermission","NotAuthorizedError","reason","formatErrorPayload","error","stringify","name","stack","cmsRoutes","RoutePlugin","onPost","onOptions","request","reply","ex","send","getLocale","console","result","processRequestBody","_","status","hijack","graphQLHandlerFactory","debug","debugPlugins"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import { GraphQLSchema } from \"graphql\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport debugPlugins from \"@webiny/handler-graphql/debugPlugins\";\nimport processRequestBody from \"@webiny/handler-graphql/processRequestBody\";\nimport { GraphQLRequestBody } from \"@webiny/handler-graphql/types\";\nimport { RoutePlugin } from \"@webiny/handler\";\nimport WebinyError from \"@webiny/error\";\n// @ts-ignore `code-frame` has no types\nimport codeFrame from \"code-frame\";\nimport { generateSchema } from \"~/graphql/generateSchema\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n locale: I18NLocale;\n}\n\nconst createRequestBody = (body: unknown): GraphQLRequestBody | GraphQLRequestBody[] => {\n /**\n * We are trusting that the body payload is correct.\n * The `processRequestBody` will fail if it is not.\n */\n return typeof body === \"string\" ? JSON.parse(body) : body;\n};\n\nconst schemaList = new Map<string, SchemaCache>();\n\nconst generateCacheKey = async (args: GetSchemaParams): Promise<string> => {\n const { context, locale, type } = args;\n const lastModelChange = await context.cms.getModelLastChange();\n return [locale.code, type, lastModelChange.toISOString()].join(\"#\");\n};\n\n/**\n * Gets an existing schema or rewrites existing one or creates a completely new one\n * depending on the schemaId created from type and locale parameters\n */\nconst getSchema = async (params: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context, type, locale } = params;\n const tenantId = context.tenancy.getCurrentTenant().id;\n const id = `${tenantId}#${type}#${locale.code}`;\n\n const cacheKey = await generateCacheKey(params);\n const cachedSchema = schemaList.get(id);\n if (cachedSchema?.key === cacheKey) {\n return cachedSchema.schema;\n }\n // Load model data\n context.security.disableAuthorization();\n const models = (await context.cms.listModels()).filter(model => model.isPrivate !== true);\n context.security.enableAuthorization();\n try {\n const schema = await generateSchema({\n ...params,\n models\n });\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n } catch (err) {\n if (!Array.isArray(err.locations)) {\n throw new WebinyError({\n message: err.message,\n code: err.code || \"INVALID_GRAPHQL_SCHEMA_LOCATIONS\",\n data: {\n ...(err.data || {}),\n locations: err.locations\n }\n });\n }\n const [location] = err.locations;\n\n throw new WebinyError({\n code: \"INVALID_GRAPHQL_SCHEMA\",\n message: err.message,\n data: {\n invalidSegment: codeFrame(err.source.body, location.line, location.column, {\n frameSize: 15\n })\n }\n });\n }\n};\n\nconst checkEndpointAccess = async (context: CmsContext): Promise<void> => {\n const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access \"${context.cms.type}\" endpoint.`\n }\n });\n }\n};\n\nconst formatErrorPayload = (error: Error): string => {\n if (error instanceof WebinyError) {\n return JSON.stringify({\n type: \"CmsGraphQLWebinyError\",\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return JSON.stringify({\n type: \"Error\",\n name: error.name,\n message: error.message,\n stack: error.stack\n });\n};\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nconst cmsRoutes = new RoutePlugin<CmsContext>(({ onPost, onOptions, context }) => {\n onPost(\"/cms/:type(^manage|preview|read$)/:locale\", async (request, reply) => {\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n let schema: GraphQLSchema;\n try {\n schema = await getSchema({\n context,\n locale: context.cms.getLocale(),\n type: context.cms.type as ApiEndpoint\n });\n } catch (ex) {\n console.error(`Error while generating the schema.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n\n let body: GraphQLRequestBody | GraphQLRequestBody[] = [];\n try {\n body = createRequestBody(request.body);\n } catch (ex) {\n console.error(`Error while creating the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n\n try {\n const result = await processRequestBody(body, schema, context);\n return reply.code(200).send(result);\n } catch (ex) {\n console.error(`Error while processing the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n onOptions(\"/cms/:type(^manage|preview|read$)/:locale\", async (_, reply) => {\n return reply.status(204).send({}).hijack();\n });\n});\n\ncmsRoutes.name = \"headless-cms.graphql.route.default\";\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n return [\n ...(debug ? debugPlugins() : []),\n cmsRoutes,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":";;;;;;;;;;;AAGA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAFA;AAcA,MAAMA,iBAAiB,GAAIC,IAAD,IAA8D;EACpF;AACJ;AACA;AACA;EACI,OAAO,OAAOA,IAAP,KAAgB,QAAhB,GAA2BC,IAAI,CAACC,KAAL,CAAWF,IAAX,CAA3B,GAA8CA,IAArD;AACH,CAND;;AAQA,MAAMG,UAAU,GAAG,IAAIC,GAAJ,EAAnB;;AAEA,MAAMC,gBAAgB,GAAG,MAAOC,IAAP,IAAkD;EACvE,MAAM;IAAEC,OAAF;IAAWC,MAAX;IAAmBC;EAAnB,IAA4BH,IAAlC;EACA,MAAMI,eAAe,GAAG,MAAMH,OAAO,CAACI,GAAR,CAAYC,kBAAZ,EAA9B;EACA,OAAO,CAACJ,MAAM,CAACK,IAAR,EAAcJ,IAAd,EAAoBC,eAAe,CAACI,WAAhB,EAApB,EAAmDC,I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;MACAA,IAAI,GAAGD,iBAAiB,CAACkE,OAAO,CAACjE,IAAT,CAAxB;IACH,CAFD,CAEE,OAAOmE,EAAP,EAAW;MACTG,OAAO,CAACb,KAAR,CAAe,wCAAf;MACAa,OAAO,CAACb,KAAR,CAAcD,kBAAkB,CAACW,EAAD,CAAhC;MACA,MAAMA,EAAN;IACH;;IAED,IAAI;MACA,MAAMI,MAAM,GAAG,MAAM,IAAAC,2BAAA,EAAmBxE,IAAnB,EAAyB0B,MAAzB,EAAiCnB,OAAjC,CAArB;MACA,OAAO2D,KAAK,CAACrD,IAAN,CAAW,GAAX,EAAgBuD,IAAhB,CAAqBG,MAArB,CAAP;IACH,CAHD,CAGE,OAAOJ,EAAP,EAAW;MACTG,OAAO,CAACb,KAAR,CAAe,0CAAf;MACAa,OAAO,CAACb,KAAR,CAAcD,kBAAkB,CAACW,EAAD,CAAhC;MACA,MAAMA,EAAN;IACH;EACJ,CA7CK,CAAN;EA+CAH,SAAS,CAAC,2CAAD,EAA8C,OAAOS,CAAP,EAAUP,KAAV,KAAoB;IACvE,OAAOA,KAAK,CAACQ,MAAN,CAAa,GAAb,EAAkBN,IAAlB,CAAuB,EAAvB,EAA2BO,MAA3B,EAAP;EACH,CAFQ,CAAT;AAGH,CAnDiB,CAAlB;AAqDAd,SAAS,CAACF,IAAV,GAAiB,oCAAjB;;AAEO,MAAMiB,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA8D;EAC/F,OAAO,CACH,IAAIA,KAAK,GAAG,IAAAC,qBAAA,GAAH,GAAoB,EAA7B,CADG,EAEHjB,SAFG,EAGH;IACIpD,IAAI,EAAE;EADV,CAHG,CAAP;AAOH,CARM"}
|
package/graphql/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { GraphQLHandlerFactoryParams } from "./graphQLHandlerFactory";
|
|
2
2
|
export declare type CreateGraphQLParams = GraphQLHandlerFactoryParams;
|
|
3
|
-
export declare const createGraphQL: (params: CreateGraphQLParams) => (import("@webiny/
|
|
3
|
+
export declare const createGraphQL: (params: CreateGraphQLParams) => (import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("../types").CmsContext> | import("@webiny/api").ContextPlugin<import("../types").CmsContext> | import("@webiny/plugins/types").PluginCollection)[];
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { CreateGraphQLParams } from "./graphql";
|
|
|
2
2
|
import { CrudParams } from "./context";
|
|
3
3
|
import { entryFieldFromStorageTransform, entryFromStorageTransform, entryToStorageTransform } from "./utils/entryStorage";
|
|
4
4
|
export declare type CreateHeadlessCmsGraphQLParams = CreateGraphQLParams;
|
|
5
|
-
export declare const createHeadlessCmsGraphQL: (params?: CreateHeadlessCmsGraphQLParams) => (import("./plugins").CmsParametersPlugin | (import("@webiny/
|
|
5
|
+
export declare const createHeadlessCmsGraphQL: (params?: CreateHeadlessCmsGraphQLParams) => (import("./plugins").CmsParametersPlugin | (import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("./types").CmsContext> | import("@webiny/api").ContextPlugin<import("./types").CmsContext> | import("@webiny/plugins/types").PluginCollection)[])[];
|
|
6
6
|
export declare type ContentContextParams = CrudParams;
|
|
7
7
|
export declare const createHeadlessCmsContext: (params: ContentContextParams) => (import("./types").ModelManagerPlugin | import("./plugins").StorageTransformPlugin<any, any, import("./types").CmsModelField> | import("@webiny/api").ContextPlugin<import("./types").CmsContext> | import("@webiny/api-upgrade").UpgradePlugin<import("./types").CmsContext>[] | import("./plugins").StorageTransformPlugin<any, any, import("./types").CmsModelDynamicZoneField> | import("./types").CmsModelFieldToGraphQLPlugin<any>[] | (import("./types").CmsModelFieldValidatorPlugin | import("./types").CmsModelFieldPatternValidatorPlugin[])[] | (import("./fieldConverters/CmsModelObjectFieldConverterPlugin").CmsModelObjectFieldConverterPlugin | import("./fieldConverters/CmsModelDefaultFieldConverterPlugin").CmsModelDefaultFieldConverterPlugin | import("./fieldConverters/CmsModelDynamicZoneFieldConverterPlugin").CmsModelDynamicZoneFieldConverterPlugin)[])[];
|
|
8
8
|
export * from "./graphqlFields";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "5.34.
|
|
3
|
+
"version": "5.34.7-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms:base"
|
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
"@babel/runtime": "7.19.0",
|
|
22
22
|
"@commodo/fields": "1.1.2-beta.20",
|
|
23
23
|
"@graphql-tools/schema": "7.1.5",
|
|
24
|
-
"@webiny/api": "5.34.
|
|
25
|
-
"@webiny/api-file-manager": "5.34.
|
|
26
|
-
"@webiny/api-i18n": "5.34.
|
|
27
|
-
"@webiny/api-i18n-ddb": "5.34.
|
|
28
|
-
"@webiny/api-security": "5.34.
|
|
29
|
-
"@webiny/api-tenancy": "5.34.
|
|
30
|
-
"@webiny/api-upgrade": "5.34.
|
|
31
|
-
"@webiny/error": "5.34.
|
|
32
|
-
"@webiny/handler": "5.34.
|
|
33
|
-
"@webiny/handler-aws": "5.34.
|
|
34
|
-
"@webiny/handler-db": "5.34.
|
|
35
|
-
"@webiny/handler-graphql": "5.34.
|
|
36
|
-
"@webiny/plugins": "5.34.
|
|
37
|
-
"@webiny/pubsub": "5.34.
|
|
38
|
-
"@webiny/utils": "5.34.
|
|
39
|
-
"@webiny/validation": "5.34.
|
|
24
|
+
"@webiny/api": "5.34.7-beta.0",
|
|
25
|
+
"@webiny/api-file-manager": "5.34.7-beta.0",
|
|
26
|
+
"@webiny/api-i18n": "5.34.7-beta.0",
|
|
27
|
+
"@webiny/api-i18n-ddb": "5.34.7-beta.0",
|
|
28
|
+
"@webiny/api-security": "5.34.7-beta.0",
|
|
29
|
+
"@webiny/api-tenancy": "5.34.7-beta.0",
|
|
30
|
+
"@webiny/api-upgrade": "5.34.7-beta.0",
|
|
31
|
+
"@webiny/error": "5.34.7-beta.0",
|
|
32
|
+
"@webiny/handler": "5.34.7-beta.0",
|
|
33
|
+
"@webiny/handler-aws": "5.34.7-beta.0",
|
|
34
|
+
"@webiny/handler-db": "5.34.7-beta.0",
|
|
35
|
+
"@webiny/handler-graphql": "5.34.7-beta.0",
|
|
36
|
+
"@webiny/plugins": "5.34.7-beta.0",
|
|
37
|
+
"@webiny/pubsub": "5.34.7-beta.0",
|
|
38
|
+
"@webiny/utils": "5.34.7-beta.0",
|
|
39
|
+
"@webiny/validation": "5.34.7-beta.0",
|
|
40
40
|
"code-frame": "5.0.0",
|
|
41
41
|
"commodo-fields-object": "1.0.6",
|
|
42
42
|
"dataloader": "2.1.0",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@babel/cli": "^7.19.3",
|
|
54
54
|
"@babel/core": "^7.19.3",
|
|
55
55
|
"@babel/preset-env": "^7.19.4",
|
|
56
|
-
"@webiny/api-security-so-ddb": "^5.34.
|
|
57
|
-
"@webiny/api-tenancy-so-ddb": "^5.34.
|
|
58
|
-
"@webiny/api-wcp": "^5.34.
|
|
59
|
-
"@webiny/cli": "^5.34.
|
|
60
|
-
"@webiny/project-utils": "^5.34.
|
|
56
|
+
"@webiny/api-security-so-ddb": "^5.34.7-beta.0",
|
|
57
|
+
"@webiny/api-tenancy-so-ddb": "^5.34.7-beta.0",
|
|
58
|
+
"@webiny/api-wcp": "^5.34.7-beta.0",
|
|
59
|
+
"@webiny/cli": "^5.34.7-beta.0",
|
|
60
|
+
"@webiny/project-utils": "^5.34.7-beta.0",
|
|
61
61
|
"apollo-graphql": "^0.9.5",
|
|
62
62
|
"get-yarn-workspaces": "^1.0.2",
|
|
63
63
|
"graphql": "^15.7.2",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"build": "yarn webiny run build",
|
|
78
78
|
"watch": "yarn webiny run watch"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "2c03fc00765915c54923ebeb825d3f7d044912ba"
|
|
81
81
|
}
|