@strapi/plugin-graphql 5.13.0-beta.1 → 5.13.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.
- package/dist/admin/package.json.js +6 -6
- package/dist/admin/package.json.mjs +6 -6
- package/dist/server/services/utils/naming.js +1 -1
- package/dist/server/services/utils/naming.js.map +1 -1
- package/dist/server/services/utils/naming.mjs +1 -1
- package/dist/server/services/utils/naming.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@strapi/plugin-graphql";
|
|
6
|
-
var version = "5.12.
|
|
6
|
+
var version = "5.12.7";
|
|
7
7
|
var description = "Adds GraphQL endpoint with default API methods.";
|
|
8
8
|
var repository = {
|
|
9
9
|
type: "git",
|
|
@@ -62,7 +62,7 @@ var dependencies = {
|
|
|
62
62
|
"@koa/cors": "5.0.0",
|
|
63
63
|
"@strapi/design-system": "2.0.0-rc.23",
|
|
64
64
|
"@strapi/icons": "2.0.0-rc.23",
|
|
65
|
-
"@strapi/utils": "5.12.
|
|
65
|
+
"@strapi/utils": "5.12.7",
|
|
66
66
|
graphql: "^16.8.1",
|
|
67
67
|
"graphql-depth-limit": "^1.1.0",
|
|
68
68
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -74,19 +74,19 @@ var dependencies = {
|
|
|
74
74
|
pluralize: "8.0.0"
|
|
75
75
|
};
|
|
76
76
|
var devDependencies = {
|
|
77
|
-
"@strapi/strapi": "5.12.
|
|
78
|
-
"@strapi/types": "5.12.
|
|
77
|
+
"@strapi/strapi": "5.12.7",
|
|
78
|
+
"@strapi/types": "5.12.7",
|
|
79
79
|
"@types/graphql-depth-limit": "1.1.5",
|
|
80
80
|
"@types/koa-bodyparser": "4.3.12",
|
|
81
81
|
"@types/koa__cors": "5.0.0",
|
|
82
82
|
"cross-env": "^7.0.3",
|
|
83
|
-
"eslint-config-custom": "5.12.
|
|
83
|
+
"eslint-config-custom": "5.12.7",
|
|
84
84
|
koa: "2.15.4",
|
|
85
85
|
react: "18.3.1",
|
|
86
86
|
"react-dom": "18.3.1",
|
|
87
87
|
"react-router-dom": "6.22.3",
|
|
88
88
|
"styled-components": "6.1.8",
|
|
89
|
-
tsconfig: "5.12.
|
|
89
|
+
tsconfig: "5.12.7",
|
|
90
90
|
typescript: "5.4.4"
|
|
91
91
|
};
|
|
92
92
|
var peerDependencies = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@strapi/plugin-graphql";
|
|
2
|
-
var version = "5.12.
|
|
2
|
+
var version = "5.12.7";
|
|
3
3
|
var description = "Adds GraphQL endpoint with default API methods.";
|
|
4
4
|
var repository = {
|
|
5
5
|
type: "git",
|
|
@@ -58,7 +58,7 @@ var dependencies = {
|
|
|
58
58
|
"@koa/cors": "5.0.0",
|
|
59
59
|
"@strapi/design-system": "2.0.0-rc.23",
|
|
60
60
|
"@strapi/icons": "2.0.0-rc.23",
|
|
61
|
-
"@strapi/utils": "5.12.
|
|
61
|
+
"@strapi/utils": "5.12.7",
|
|
62
62
|
graphql: "^16.8.1",
|
|
63
63
|
"graphql-depth-limit": "^1.1.0",
|
|
64
64
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -70,19 +70,19 @@ var dependencies = {
|
|
|
70
70
|
pluralize: "8.0.0"
|
|
71
71
|
};
|
|
72
72
|
var devDependencies = {
|
|
73
|
-
"@strapi/strapi": "5.12.
|
|
74
|
-
"@strapi/types": "5.12.
|
|
73
|
+
"@strapi/strapi": "5.12.7",
|
|
74
|
+
"@strapi/types": "5.12.7",
|
|
75
75
|
"@types/graphql-depth-limit": "1.1.5",
|
|
76
76
|
"@types/koa-bodyparser": "4.3.12",
|
|
77
77
|
"@types/koa__cors": "5.0.0",
|
|
78
78
|
"cross-env": "^7.0.3",
|
|
79
|
-
"eslint-config-custom": "5.12.
|
|
79
|
+
"eslint-config-custom": "5.12.7",
|
|
80
80
|
koa: "2.15.4",
|
|
81
81
|
react: "18.3.1",
|
|
82
82
|
"react-dom": "18.3.1",
|
|
83
83
|
"react-router-dom": "6.22.3",
|
|
84
84
|
"styled-components": "6.1.8",
|
|
85
|
-
tsconfig: "5.12.
|
|
85
|
+
tsconfig: "5.12.7",
|
|
86
86
|
typescript: "5.4.4"
|
|
87
87
|
};
|
|
88
88
|
var peerDependencies = {
|
|
@@ -22,7 +22,7 @@ var naming = (({ strapi })=>{
|
|
|
22
22
|
const plugin = fp.get('plugin', contentType);
|
|
23
23
|
const modelName = fp.get('modelName', contentType);
|
|
24
24
|
const name = plurality === 'singular' ? fp.get('info.singularName', contentType) : fp.get('info.pluralName', contentType);
|
|
25
|
-
const transformedPlugin =
|
|
25
|
+
const transformedPlugin = fp.upperFirst(fp.camelCase(plugin));
|
|
26
26
|
const transformedModelName = fp.upperFirst(fp.camelCase(name || pluralize.singular(modelName)));
|
|
27
27
|
return `${transformedPlugin}${transformedModelName}`;
|
|
28
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming.js","sources":["../../../../server/src/services/utils/naming.ts"],"sourcesContent":["import { camelCase, upperFirst, lowerFirst, pipe, get } from 'lodash/fp';\nimport { singular } from 'pluralize';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Schema } from '@strapi/types';\nimport type { Context } from '../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n /**\n * Build a type name for a enum based on a content type & an attribute name\n */\n const getEnumName = (contentType: Struct.Schema, attributeName: string) => {\n const { attributes } = contentType;\n const { enumName } = attributes[attributeName] as Schema.Attribute.Enumeration;\n const { modelType } = contentType;\n\n const typeName =\n modelType === 'component' ? getComponentName(contentType) : getTypeName(contentType);\n\n const defaultEnumName = `ENUM_${typeName.toUpperCase()}_${attributeName.toUpperCase()}`;\n\n return enumName || defaultEnumName;\n };\n\n /**\n * Build the base type name for a given content type\n */\n const getTypeName = (\n contentType: Struct.Schema,\n {\n plurality = 'singular',\n }: {\n plurality?: 'singular' | 'plural';\n } = {}\n ) => {\n const plugin = get('plugin', contentType);\n const modelName = get('modelName', contentType);\n const name =\n plurality === 'singular'\n ? get('info.singularName', contentType)\n : get('info.pluralName', contentType);\n\n const transformedPlugin = plugin ? upperFirst(camelCase(plugin)) : '';\n const transformedModelName = upperFirst(camelCase(name || singular(modelName)));\n\n return `${transformedPlugin}${transformedModelName}`;\n };\n\n /**\n * Build the entity's type name for a given content type\n */\n const getEntityName = (contentType: Struct.Schema) => {\n return `${getTypeName(contentType)}Entity`;\n };\n\n /**\n * Build the entity meta type name for a given content type\n */\n const getEntityMetaName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Meta`;\n };\n\n /**\n * Build the entity response's type name for a given content type\n */\n const getEntityResponseName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Response`;\n };\n\n /**\n * Build the entity response collection's type name for a given content type\n */\n const getEntityResponseCollectionName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}ResponseCollection`;\n };\n\n /**\n * Build the relation response collection's type name for a given content type\n */\n const getRelationResponseCollectionName = (contentType: Struct.Schema) => {\n return `${getTypeName(contentType)}RelationResponseCollection`;\n };\n\n /**\n * Build a component type name based on its definition\n */\n const getComponentName = (contentType: Struct.Schema) => {\n return contentType.globalId;\n };\n\n /**\n * Build a component type name based on a content type's attribute\n */\n const getComponentNameFromAttribute = (attribute: Schema.Attribute.Component) => {\n return strapi.components[attribute.component].globalId;\n };\n\n /**\n * Build a dynamic zone type name based on a content type and an attribute name\n */\n const getDynamicZoneName = (contentType: Struct.Schema, attributeName: string) => {\n const typeName = getTypeName(contentType);\n const dzName = upperFirst(camelCase(attributeName));\n const suffix = 'DynamicZone';\n\n return `${typeName}${dzName}${suffix}`;\n };\n\n /**\n * Build a dynamic zone input type name based on a content type and an attribute name\n */\n const getDynamicZoneInputName = (contentType: Struct.Schema, attributeName: string) => {\n const dzName = getDynamicZoneName(contentType, attributeName);\n\n return `${dzName}Input`;\n };\n\n /**\n * Build a component input type name based on a content type and an attribute name\n */\n const getComponentInputName = (contentType: Struct.Schema) => {\n const componentName = getComponentName(contentType);\n\n return `${componentName}Input`;\n };\n\n /**\n * Build a content type input name based on a content type and an attribute name\n */\n const getContentTypeInputName = (contentType: Struct.Schema) => {\n const typeName = getTypeName(contentType);\n\n return `${typeName}Input`;\n };\n\n /**\n * Build the queries type name for a given content type\n */\n const getEntityQueriesTypeName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Queries`;\n };\n\n /**\n * Build the mutations type name for a given content type\n */\n const getEntityMutationsTypeName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Mutations`;\n };\n\n /**\n * Build the filters type name for a given content type\n */\n const getFiltersInputTypeName = (contentType: Struct.Schema) => {\n const isComponent = contentType.modelType === 'component';\n\n const baseName = isComponent ? getComponentName(contentType) : getTypeName(contentType);\n\n return `${baseName}FiltersInput`;\n };\n\n /**\n * Build a filters type name for a given GraphQL scalar type\n */\n const getScalarFilterInputTypeName = (scalarType: string) => {\n return `${scalarType}FilterInput`;\n };\n\n /**\n * Build a type name for a given content type & polymorphic attribute\n */\n const getMorphRelationTypeName = (contentType: Struct.Schema, attributeName: string) => {\n const typeName = getTypeName(contentType);\n const formattedAttr = upperFirst(camelCase(attributeName));\n\n return `${typeName}${formattedAttr}Morph`;\n };\n\n /**\n * Build a custom type name generator with different customization options\n */\n const buildCustomTypeNameGenerator = (options: {\n prefix?: string;\n suffix?: string;\n firstLetterCase?: 'upper' | 'lower';\n plurality?: 'plural' | 'singular';\n }) => {\n // todo[v4]: use singularName & pluralName is available\n const { prefix = '', suffix = '', plurality = 'singular', firstLetterCase = 'upper' } = options;\n\n if (!['plural', 'singular'].includes(plurality)) {\n throw new ApplicationError(\n `\"plurality\" param must be either \"plural\" or \"singular\", but got: \"${plurality}\"`\n );\n }\n\n const getCustomTypeName = pipe(\n (ct) => getTypeName(ct, { plurality }),\n firstLetterCase === 'upper' ? upperFirst : lowerFirst\n );\n\n return (contentType: Struct.Schema) => `${prefix}${getCustomTypeName(contentType)}${suffix}`;\n };\n\n const getFindQueryName = buildCustomTypeNameGenerator({\n plurality: 'plural',\n firstLetterCase: 'lower',\n });\n\n const getFindConnectionQueryName = (contentType: Struct.Schema) => {\n return `${getFindQueryName(contentType)}_connection`;\n };\n\n const getFindOneQueryName = buildCustomTypeNameGenerator({ firstLetterCase: 'lower' });\n\n const getCreateMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'create',\n firstLetterCase: 'upper',\n });\n\n const getUpdateMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'update',\n firstLetterCase: 'upper',\n });\n\n const getDeleteMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'delete',\n firstLetterCase: 'upper',\n });\n\n return {\n getEnumName,\n getTypeName,\n getEntityName,\n getEntityMetaName,\n getEntityResponseName,\n getEntityResponseCollectionName,\n getRelationResponseCollectionName,\n getComponentName,\n getComponentNameFromAttribute,\n getDynamicZoneName,\n getDynamicZoneInputName,\n getComponentInputName,\n getContentTypeInputName,\n getEntityQueriesTypeName,\n getEntityMutationsTypeName,\n getFiltersInputTypeName,\n getScalarFilterInputTypeName,\n getMorphRelationTypeName,\n buildCustomTypeNameGenerator,\n getFindQueryName,\n getFindOneQueryName,\n getCreateMutationTypeName,\n getUpdateMutationTypeName,\n getDeleteMutationTypeName,\n getFindConnectionQueryName,\n };\n};\n"],"names":["ApplicationError","errors","strapi","getEnumName","contentType","attributeName","attributes","enumName","modelType","typeName","getComponentName","getTypeName","defaultEnumName","toUpperCase","plurality","plugin","get","modelName","name","transformedPlugin","upperFirst","camelCase","transformedModelName","singular","getEntityName","getEntityMetaName","getEntityResponseName","getEntityResponseCollectionName","getRelationResponseCollectionName","globalId","getComponentNameFromAttribute","attribute","components","component","getDynamicZoneName","dzName","suffix","getDynamicZoneInputName","getComponentInputName","componentName","getContentTypeInputName","getEntityQueriesTypeName","getEntityMutationsTypeName","getFiltersInputTypeName","isComponent","baseName","getScalarFilterInputTypeName","scalarType","getMorphRelationTypeName","formattedAttr","buildCustomTypeNameGenerator","options","prefix","firstLetterCase","includes","getCustomTypeName","pipe","ct","lowerFirst","getFindQueryName","getFindConnectionQueryName","getFindOneQueryName","getCreateMutationTypeName","getUpdateMutationTypeName","getDeleteMutationTypeName"],"mappings":";;;;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,aAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC;;MAGA,MAAMC,WAAc,GAAA,CAACC,WAA4BC,EAAAA,aAAAA,GAAAA;QAC/C,MAAM,EAAEC,UAAU,EAAE,GAAGF,WAAAA;AACvB,QAAA,MAAM,EAAEG,QAAQ,EAAE,GAAGD,UAAU,CAACD,aAAc,CAAA;QAC9C,MAAM,EAAEG,SAAS,EAAE,GAAGJ,WAAAA;AAEtB,QAAA,MAAMK,QACJD,GAAAA,SAAAA,KAAc,WAAcE,GAAAA,gBAAAA,CAAiBN,eAAeO,WAAYP,CAAAA,WAAAA,CAAAA;AAE1E,QAAA,MAAMQ,eAAkB,GAAA,CAAC,KAAK,EAAEH,QAASI,CAAAA,WAAW,EAAG,CAAA,CAAC,EAAER,aAAAA,CAAcQ,WAAW,EAAA,CAAG,CAAC;AAEvF,QAAA,OAAON,QAAYK,IAAAA,eAAAA;AACrB,KAAA;AAEA;;MAGA,MAAMD,WAAc,GAAA,CAClBP,WACA,EAAA,EACEU,YAAY,UAAU,EAGvB,GAAG,EAAE,GAAA;QAEN,MAAMC,MAAAA,GAASC,OAAI,QAAUZ,EAAAA,WAAAA,CAAAA;QAC7B,MAAMa,SAAAA,GAAYD,OAAI,WAAaZ,EAAAA,WAAAA,CAAAA;AACnC,QAAA,MAAMc,OACJJ,SAAc,KAAA,UAAA,GACVE,OAAI,mBAAqBZ,EAAAA,WAAAA,CAAAA,GACzBY,OAAI,iBAAmBZ,EAAAA,WAAAA,CAAAA;A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C,QAAAA,uBAAAA;AACAG,QAAAA,4BAAAA;AACAE,QAAAA,wBAAAA;AACAE,QAAAA,4BAAAA;AACAS,QAAAA,gBAAAA;AACAE,QAAAA,mBAAAA;AACAC,QAAAA,yBAAAA;AACAC,QAAAA,yBAAAA;AACAC,QAAAA,yBAAAA;AACAJ,QAAAA;AACF,KAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"naming.js","sources":["../../../../server/src/services/utils/naming.ts"],"sourcesContent":["import { camelCase, upperFirst, lowerFirst, pipe, get } from 'lodash/fp';\nimport { singular } from 'pluralize';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Schema } from '@strapi/types';\nimport type { Context } from '../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n /**\n * Build a type name for a enum based on a content type & an attribute name\n */\n const getEnumName = (contentType: Struct.Schema, attributeName: string) => {\n const { attributes } = contentType;\n const { enumName } = attributes[attributeName] as Schema.Attribute.Enumeration;\n const { modelType } = contentType;\n\n const typeName =\n modelType === 'component' ? getComponentName(contentType) : getTypeName(contentType);\n\n const defaultEnumName = `ENUM_${typeName.toUpperCase()}_${attributeName.toUpperCase()}`;\n\n return enumName || defaultEnumName;\n };\n\n /**\n * Build the base type name for a given content type\n */\n const getTypeName = (\n contentType: Struct.Schema,\n {\n plurality = 'singular',\n }: {\n plurality?: 'singular' | 'plural';\n } = {}\n ) => {\n const plugin = get('plugin', contentType);\n const modelName = get('modelName', contentType);\n const name =\n plurality === 'singular'\n ? get('info.singularName', contentType)\n : get('info.pluralName', contentType);\n\n const transformedPlugin = upperFirst(camelCase(plugin));\n const transformedModelName = upperFirst(camelCase(name || singular(modelName)));\n\n return `${transformedPlugin}${transformedModelName}`;\n };\n\n /**\n * Build the entity's type name for a given content type\n */\n const getEntityName = (contentType: Struct.Schema) => {\n return `${getTypeName(contentType)}Entity`;\n };\n\n /**\n * Build the entity meta type name for a given content type\n */\n const getEntityMetaName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Meta`;\n };\n\n /**\n * Build the entity response's type name for a given content type\n */\n const getEntityResponseName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Response`;\n };\n\n /**\n * Build the entity response collection's type name for a given content type\n */\n const getEntityResponseCollectionName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}ResponseCollection`;\n };\n\n /**\n * Build the relation response collection's type name for a given content type\n */\n const getRelationResponseCollectionName = (contentType: Struct.Schema) => {\n return `${getTypeName(contentType)}RelationResponseCollection`;\n };\n\n /**\n * Build a component type name based on its definition\n */\n const getComponentName = (contentType: Struct.Schema) => {\n return contentType.globalId;\n };\n\n /**\n * Build a component type name based on a content type's attribute\n */\n const getComponentNameFromAttribute = (attribute: Schema.Attribute.Component) => {\n return strapi.components[attribute.component].globalId;\n };\n\n /**\n * Build a dynamic zone type name based on a content type and an attribute name\n */\n const getDynamicZoneName = (contentType: Struct.Schema, attributeName: string) => {\n const typeName = getTypeName(contentType);\n const dzName = upperFirst(camelCase(attributeName));\n const suffix = 'DynamicZone';\n\n return `${typeName}${dzName}${suffix}`;\n };\n\n /**\n * Build a dynamic zone input type name based on a content type and an attribute name\n */\n const getDynamicZoneInputName = (contentType: Struct.Schema, attributeName: string) => {\n const dzName = getDynamicZoneName(contentType, attributeName);\n\n return `${dzName}Input`;\n };\n\n /**\n * Build a component input type name based on a content type and an attribute name\n */\n const getComponentInputName = (contentType: Struct.Schema) => {\n const componentName = getComponentName(contentType);\n\n return `${componentName}Input`;\n };\n\n /**\n * Build a content type input name based on a content type and an attribute name\n */\n const getContentTypeInputName = (contentType: Struct.Schema) => {\n const typeName = getTypeName(contentType);\n\n return `${typeName}Input`;\n };\n\n /**\n * Build the queries type name for a given content type\n */\n const getEntityQueriesTypeName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Queries`;\n };\n\n /**\n * Build the mutations type name for a given content type\n */\n const getEntityMutationsTypeName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Mutations`;\n };\n\n /**\n * Build the filters type name for a given content type\n */\n const getFiltersInputTypeName = (contentType: Struct.Schema) => {\n const isComponent = contentType.modelType === 'component';\n\n const baseName = isComponent ? getComponentName(contentType) : getTypeName(contentType);\n\n return `${baseName}FiltersInput`;\n };\n\n /**\n * Build a filters type name for a given GraphQL scalar type\n */\n const getScalarFilterInputTypeName = (scalarType: string) => {\n return `${scalarType}FilterInput`;\n };\n\n /**\n * Build a type name for a given content type & polymorphic attribute\n */\n const getMorphRelationTypeName = (contentType: Struct.Schema, attributeName: string) => {\n const typeName = getTypeName(contentType);\n const formattedAttr = upperFirst(camelCase(attributeName));\n\n return `${typeName}${formattedAttr}Morph`;\n };\n\n /**\n * Build a custom type name generator with different customization options\n */\n const buildCustomTypeNameGenerator = (options: {\n prefix?: string;\n suffix?: string;\n firstLetterCase?: 'upper' | 'lower';\n plurality?: 'plural' | 'singular';\n }) => {\n // todo[v4]: use singularName & pluralName is available\n const { prefix = '', suffix = '', plurality = 'singular', firstLetterCase = 'upper' } = options;\n\n if (!['plural', 'singular'].includes(plurality)) {\n throw new ApplicationError(\n `\"plurality\" param must be either \"plural\" or \"singular\", but got: \"${plurality}\"`\n );\n }\n\n const getCustomTypeName = pipe(\n (ct) => getTypeName(ct, { plurality }),\n firstLetterCase === 'upper' ? upperFirst : lowerFirst\n );\n\n return (contentType: Struct.Schema) => `${prefix}${getCustomTypeName(contentType)}${suffix}`;\n };\n\n const getFindQueryName = buildCustomTypeNameGenerator({\n plurality: 'plural',\n firstLetterCase: 'lower',\n });\n\n const getFindConnectionQueryName = (contentType: Struct.Schema) => {\n return `${getFindQueryName(contentType)}_connection`;\n };\n\n const getFindOneQueryName = buildCustomTypeNameGenerator({ firstLetterCase: 'lower' });\n\n const getCreateMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'create',\n firstLetterCase: 'upper',\n });\n\n const getUpdateMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'update',\n firstLetterCase: 'upper',\n });\n\n const getDeleteMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'delete',\n firstLetterCase: 'upper',\n });\n\n return {\n getEnumName,\n getTypeName,\n getEntityName,\n getEntityMetaName,\n getEntityResponseName,\n getEntityResponseCollectionName,\n getRelationResponseCollectionName,\n getComponentName,\n getComponentNameFromAttribute,\n getDynamicZoneName,\n getDynamicZoneInputName,\n getComponentInputName,\n getContentTypeInputName,\n getEntityQueriesTypeName,\n getEntityMutationsTypeName,\n getFiltersInputTypeName,\n getScalarFilterInputTypeName,\n getMorphRelationTypeName,\n buildCustomTypeNameGenerator,\n getFindQueryName,\n getFindOneQueryName,\n getCreateMutationTypeName,\n getUpdateMutationTypeName,\n getDeleteMutationTypeName,\n getFindConnectionQueryName,\n };\n};\n"],"names":["ApplicationError","errors","strapi","getEnumName","contentType","attributeName","attributes","enumName","modelType","typeName","getComponentName","getTypeName","defaultEnumName","toUpperCase","plurality","plugin","get","modelName","name","transformedPlugin","upperFirst","camelCase","transformedModelName","singular","getEntityName","getEntityMetaName","getEntityResponseName","getEntityResponseCollectionName","getRelationResponseCollectionName","globalId","getComponentNameFromAttribute","attribute","components","component","getDynamicZoneName","dzName","suffix","getDynamicZoneInputName","getComponentInputName","componentName","getContentTypeInputName","getEntityQueriesTypeName","getEntityMutationsTypeName","getFiltersInputTypeName","isComponent","baseName","getScalarFilterInputTypeName","scalarType","getMorphRelationTypeName","formattedAttr","buildCustomTypeNameGenerator","options","prefix","firstLetterCase","includes","getCustomTypeName","pipe","ct","lowerFirst","getFindQueryName","getFindConnectionQueryName","getFindOneQueryName","getCreateMutationTypeName","getUpdateMutationTypeName","getDeleteMutationTypeName"],"mappings":";;;;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,aAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC;;MAGA,MAAMC,WAAc,GAAA,CAACC,WAA4BC,EAAAA,aAAAA,GAAAA;QAC/C,MAAM,EAAEC,UAAU,EAAE,GAA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AAEA,IAAA,MAAMyD,sBAAsBX,4BAA6B,CAAA;QAAEG,eAAiB,EAAA;AAAQ,KAAA,CAAA;AAEpF,IAAA,MAAMS,4BAA4BZ,4BAA6B,CAAA;QAC7DE,MAAQ,EAAA,QAAA;QACRC,eAAiB,EAAA;AACnB,KAAA,CAAA;AAEA,IAAA,MAAMU,4BAA4Bb,4BAA6B,CAAA;QAC7DE,MAAQ,EAAA,QAAA;QACRC,eAAiB,EAAA;AACnB,KAAA,CAAA;AAEA,IAAA,MAAMW,4BAA4Bd,4BAA6B,CAAA;QAC7DE,MAAQ,EAAA,QAAA;QACRC,eAAiB,EAAA;AACnB,KAAA,CAAA;IAEA,OAAO;AACLlD,QAAAA,WAAAA;AACAQ,QAAAA,WAAAA;AACAa,QAAAA,aAAAA;AACAC,QAAAA,iBAAAA;AACAC,QAAAA,qBAAAA;AACAC,QAAAA,+BAAAA;AACAC,QAAAA,iCAAAA;AACAlB,QAAAA,gBAAAA;AACAoB,QAAAA,6BAAAA;AACAI,QAAAA,kBAAAA;AACAG,QAAAA,uBAAAA;AACAC,QAAAA,qBAAAA;AACAE,QAAAA,uBAAAA;AACAC,QAAAA,wBAAAA;AACAC,QAAAA,0BAAAA;AACAC,QAAAA,uBAAAA;AACAG,QAAAA,4BAAAA;AACAE,QAAAA,wBAAAA;AACAE,QAAAA,4BAAAA;AACAS,QAAAA,gBAAAA;AACAE,QAAAA,mBAAAA;AACAC,QAAAA,yBAAAA;AACAC,QAAAA,yBAAAA;AACAC,QAAAA,yBAAAA;AACAJ,QAAAA;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -20,7 +20,7 @@ var naming = (({ strapi })=>{
|
|
|
20
20
|
const plugin = get('plugin', contentType);
|
|
21
21
|
const modelName = get('modelName', contentType);
|
|
22
22
|
const name = plurality === 'singular' ? get('info.singularName', contentType) : get('info.pluralName', contentType);
|
|
23
|
-
const transformedPlugin =
|
|
23
|
+
const transformedPlugin = upperFirst(camelCase(plugin));
|
|
24
24
|
const transformedModelName = upperFirst(camelCase(name || singular(modelName)));
|
|
25
25
|
return `${transformedPlugin}${transformedModelName}`;
|
|
26
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming.mjs","sources":["../../../../server/src/services/utils/naming.ts"],"sourcesContent":["import { camelCase, upperFirst, lowerFirst, pipe, get } from 'lodash/fp';\nimport { singular } from 'pluralize';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Schema } from '@strapi/types';\nimport type { Context } from '../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n /**\n * Build a type name for a enum based on a content type & an attribute name\n */\n const getEnumName = (contentType: Struct.Schema, attributeName: string) => {\n const { attributes } = contentType;\n const { enumName } = attributes[attributeName] as Schema.Attribute.Enumeration;\n const { modelType } = contentType;\n\n const typeName =\n modelType === 'component' ? getComponentName(contentType) : getTypeName(contentType);\n\n const defaultEnumName = `ENUM_${typeName.toUpperCase()}_${attributeName.toUpperCase()}`;\n\n return enumName || defaultEnumName;\n };\n\n /**\n * Build the base type name for a given content type\n */\n const getTypeName = (\n contentType: Struct.Schema,\n {\n plurality = 'singular',\n }: {\n plurality?: 'singular' | 'plural';\n } = {}\n ) => {\n const plugin = get('plugin', contentType);\n const modelName = get('modelName', contentType);\n const name =\n plurality === 'singular'\n ? get('info.singularName', contentType)\n : get('info.pluralName', contentType);\n\n const transformedPlugin = plugin ? upperFirst(camelCase(plugin)) : '';\n const transformedModelName = upperFirst(camelCase(name || singular(modelName)));\n\n return `${transformedPlugin}${transformedModelName}`;\n };\n\n /**\n * Build the entity's type name for a given content type\n */\n const getEntityName = (contentType: Struct.Schema) => {\n return `${getTypeName(contentType)}Entity`;\n };\n\n /**\n * Build the entity meta type name for a given content type\n */\n const getEntityMetaName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Meta`;\n };\n\n /**\n * Build the entity response's type name for a given content type\n */\n const getEntityResponseName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Response`;\n };\n\n /**\n * Build the entity response collection's type name for a given content type\n */\n const getEntityResponseCollectionName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}ResponseCollection`;\n };\n\n /**\n * Build the relation response collection's type name for a given content type\n */\n const getRelationResponseCollectionName = (contentType: Struct.Schema) => {\n return `${getTypeName(contentType)}RelationResponseCollection`;\n };\n\n /**\n * Build a component type name based on its definition\n */\n const getComponentName = (contentType: Struct.Schema) => {\n return contentType.globalId;\n };\n\n /**\n * Build a component type name based on a content type's attribute\n */\n const getComponentNameFromAttribute = (attribute: Schema.Attribute.Component) => {\n return strapi.components[attribute.component].globalId;\n };\n\n /**\n * Build a dynamic zone type name based on a content type and an attribute name\n */\n const getDynamicZoneName = (contentType: Struct.Schema, attributeName: string) => {\n const typeName = getTypeName(contentType);\n const dzName = upperFirst(camelCase(attributeName));\n const suffix = 'DynamicZone';\n\n return `${typeName}${dzName}${suffix}`;\n };\n\n /**\n * Build a dynamic zone input type name based on a content type and an attribute name\n */\n const getDynamicZoneInputName = (contentType: Struct.Schema, attributeName: string) => {\n const dzName = getDynamicZoneName(contentType, attributeName);\n\n return `${dzName}Input`;\n };\n\n /**\n * Build a component input type name based on a content type and an attribute name\n */\n const getComponentInputName = (contentType: Struct.Schema) => {\n const componentName = getComponentName(contentType);\n\n return `${componentName}Input`;\n };\n\n /**\n * Build a content type input name based on a content type and an attribute name\n */\n const getContentTypeInputName = (contentType: Struct.Schema) => {\n const typeName = getTypeName(contentType);\n\n return `${typeName}Input`;\n };\n\n /**\n * Build the queries type name for a given content type\n */\n const getEntityQueriesTypeName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Queries`;\n };\n\n /**\n * Build the mutations type name for a given content type\n */\n const getEntityMutationsTypeName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Mutations`;\n };\n\n /**\n * Build the filters type name for a given content type\n */\n const getFiltersInputTypeName = (contentType: Struct.Schema) => {\n const isComponent = contentType.modelType === 'component';\n\n const baseName = isComponent ? getComponentName(contentType) : getTypeName(contentType);\n\n return `${baseName}FiltersInput`;\n };\n\n /**\n * Build a filters type name for a given GraphQL scalar type\n */\n const getScalarFilterInputTypeName = (scalarType: string) => {\n return `${scalarType}FilterInput`;\n };\n\n /**\n * Build a type name for a given content type & polymorphic attribute\n */\n const getMorphRelationTypeName = (contentType: Struct.Schema, attributeName: string) => {\n const typeName = getTypeName(contentType);\n const formattedAttr = upperFirst(camelCase(attributeName));\n\n return `${typeName}${formattedAttr}Morph`;\n };\n\n /**\n * Build a custom type name generator with different customization options\n */\n const buildCustomTypeNameGenerator = (options: {\n prefix?: string;\n suffix?: string;\n firstLetterCase?: 'upper' | 'lower';\n plurality?: 'plural' | 'singular';\n }) => {\n // todo[v4]: use singularName & pluralName is available\n const { prefix = '', suffix = '', plurality = 'singular', firstLetterCase = 'upper' } = options;\n\n if (!['plural', 'singular'].includes(plurality)) {\n throw new ApplicationError(\n `\"plurality\" param must be either \"plural\" or \"singular\", but got: \"${plurality}\"`\n );\n }\n\n const getCustomTypeName = pipe(\n (ct) => getTypeName(ct, { plurality }),\n firstLetterCase === 'upper' ? upperFirst : lowerFirst\n );\n\n return (contentType: Struct.Schema) => `${prefix}${getCustomTypeName(contentType)}${suffix}`;\n };\n\n const getFindQueryName = buildCustomTypeNameGenerator({\n plurality: 'plural',\n firstLetterCase: 'lower',\n });\n\n const getFindConnectionQueryName = (contentType: Struct.Schema) => {\n return `${getFindQueryName(contentType)}_connection`;\n };\n\n const getFindOneQueryName = buildCustomTypeNameGenerator({ firstLetterCase: 'lower' });\n\n const getCreateMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'create',\n firstLetterCase: 'upper',\n });\n\n const getUpdateMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'update',\n firstLetterCase: 'upper',\n });\n\n const getDeleteMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'delete',\n firstLetterCase: 'upper',\n });\n\n return {\n getEnumName,\n getTypeName,\n getEntityName,\n getEntityMetaName,\n getEntityResponseName,\n getEntityResponseCollectionName,\n getRelationResponseCollectionName,\n getComponentName,\n getComponentNameFromAttribute,\n getDynamicZoneName,\n getDynamicZoneInputName,\n getComponentInputName,\n getContentTypeInputName,\n getEntityQueriesTypeName,\n getEntityMutationsTypeName,\n getFiltersInputTypeName,\n getScalarFilterInputTypeName,\n getMorphRelationTypeName,\n buildCustomTypeNameGenerator,\n getFindQueryName,\n getFindOneQueryName,\n getCreateMutationTypeName,\n getUpdateMutationTypeName,\n getDeleteMutationTypeName,\n getFindConnectionQueryName,\n };\n};\n"],"names":["ApplicationError","errors","strapi","getEnumName","contentType","attributeName","attributes","enumName","modelType","typeName","getComponentName","getTypeName","defaultEnumName","toUpperCase","plurality","plugin","get","modelName","name","transformedPlugin","upperFirst","camelCase","transformedModelName","singular","getEntityName","getEntityMetaName","getEntityResponseName","getEntityResponseCollectionName","getRelationResponseCollectionName","globalId","getComponentNameFromAttribute","attribute","components","component","getDynamicZoneName","dzName","suffix","getDynamicZoneInputName","getComponentInputName","componentName","getContentTypeInputName","getEntityQueriesTypeName","getEntityMutationsTypeName","getFiltersInputTypeName","isComponent","baseName","getScalarFilterInputTypeName","scalarType","getMorphRelationTypeName","formattedAttr","buildCustomTypeNameGenerator","options","prefix","firstLetterCase","includes","getCustomTypeName","pipe","ct","lowerFirst","getFindQueryName","getFindConnectionQueryName","getFindOneQueryName","getCreateMutationTypeName","getUpdateMutationTypeName","getDeleteMutationTypeName"],"mappings":";;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,aAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC;;MAGA,MAAMC,WAAc,GAAA,CAACC,WAA4BC,EAAAA,aAAAA,GAAAA;QAC/C,MAAM,EAAEC,UAAU,EAAE,GAAGF,WAAAA;AACvB,QAAA,MAAM,EAAEG,QAAQ,EAAE,GAAGD,UAAU,CAACD,aAAc,CAAA;QAC9C,MAAM,EAAEG,SAAS,E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AA,CAAA;AAEpF,IAAA,MAAMS,4BAA4BZ,4BAA6B,CAAA;QAC7DE,MAAQ,EAAA,QAAA;QACRC,eAAiB,EAAA;AACnB,KAAA,CAAA;AAEA,IAAA,MAAMU,4BAA4Bb,4BAA6B,CAAA;QAC7DE,MAAQ,EAAA,QAAA;QACRC,eAAiB,EAAA;AACnB,KAAA,CAAA;AAEA,IAAA,MAAMW,4BAA4Bd,4BAA6B,CAAA;QAC7DE,MAAQ,EAAA,QAAA;QACRC,eAAiB,EAAA;AACnB,KAAA,CAAA;IAEA,OAAO;AACLlD,QAAAA,WAAAA;AACAQ,QAAAA,WAAAA;AACAa,QAAAA,aAAAA;AACAC,QAAAA,iBAAAA;AACAC,QAAAA,qBAAAA;AACAC,QAAAA,+BAAAA;AACAC,QAAAA,iCAAAA;AACAlB,QAAAA,gBAAAA;AACAoB,QAAAA,6BAAAA;AACAI,QAAAA,kBAAAA;AACAG,QAAAA,uBAAAA;AACAC,QAAAA,qBAAAA;AACAE,QAAAA,uBAAAA;AACAC,QAAAA,wBAAAA;AACAC,QAAAA,0BAAAA;AACAC,QAAAA,uBAAAA;AACAG,QAAAA,4BAAAA;AACAE,QAAAA,wBAAAA;AACAE,QAAAA,4BAAAA;AACAS,QAAAA,gBAAAA;AACAE,QAAAA,mBAAAA;AACAC,QAAAA,yBAAAA;AACAC,QAAAA,yBAAAA;AACAC,QAAAA,yBAAAA;AACAJ,QAAAA;AACF,KAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"naming.mjs","sources":["../../../../server/src/services/utils/naming.ts"],"sourcesContent":["import { camelCase, upperFirst, lowerFirst, pipe, get } from 'lodash/fp';\nimport { singular } from 'pluralize';\nimport { errors } from '@strapi/utils';\nimport type { Struct, Schema } from '@strapi/types';\nimport type { Context } from '../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n /**\n * Build a type name for a enum based on a content type & an attribute name\n */\n const getEnumName = (contentType: Struct.Schema, attributeName: string) => {\n const { attributes } = contentType;\n const { enumName } = attributes[attributeName] as Schema.Attribute.Enumeration;\n const { modelType } = contentType;\n\n const typeName =\n modelType === 'component' ? getComponentName(contentType) : getTypeName(contentType);\n\n const defaultEnumName = `ENUM_${typeName.toUpperCase()}_${attributeName.toUpperCase()}`;\n\n return enumName || defaultEnumName;\n };\n\n /**\n * Build the base type name for a given content type\n */\n const getTypeName = (\n contentType: Struct.Schema,\n {\n plurality = 'singular',\n }: {\n plurality?: 'singular' | 'plural';\n } = {}\n ) => {\n const plugin = get('plugin', contentType);\n const modelName = get('modelName', contentType);\n const name =\n plurality === 'singular'\n ? get('info.singularName', contentType)\n : get('info.pluralName', contentType);\n\n const transformedPlugin = upperFirst(camelCase(plugin));\n const transformedModelName = upperFirst(camelCase(name || singular(modelName)));\n\n return `${transformedPlugin}${transformedModelName}`;\n };\n\n /**\n * Build the entity's type name for a given content type\n */\n const getEntityName = (contentType: Struct.Schema) => {\n return `${getTypeName(contentType)}Entity`;\n };\n\n /**\n * Build the entity meta type name for a given content type\n */\n const getEntityMetaName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Meta`;\n };\n\n /**\n * Build the entity response's type name for a given content type\n */\n const getEntityResponseName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Response`;\n };\n\n /**\n * Build the entity response collection's type name for a given content type\n */\n const getEntityResponseCollectionName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}ResponseCollection`;\n };\n\n /**\n * Build the relation response collection's type name for a given content type\n */\n const getRelationResponseCollectionName = (contentType: Struct.Schema) => {\n return `${getTypeName(contentType)}RelationResponseCollection`;\n };\n\n /**\n * Build a component type name based on its definition\n */\n const getComponentName = (contentType: Struct.Schema) => {\n return contentType.globalId;\n };\n\n /**\n * Build a component type name based on a content type's attribute\n */\n const getComponentNameFromAttribute = (attribute: Schema.Attribute.Component) => {\n return strapi.components[attribute.component].globalId;\n };\n\n /**\n * Build a dynamic zone type name based on a content type and an attribute name\n */\n const getDynamicZoneName = (contentType: Struct.Schema, attributeName: string) => {\n const typeName = getTypeName(contentType);\n const dzName = upperFirst(camelCase(attributeName));\n const suffix = 'DynamicZone';\n\n return `${typeName}${dzName}${suffix}`;\n };\n\n /**\n * Build a dynamic zone input type name based on a content type and an attribute name\n */\n const getDynamicZoneInputName = (contentType: Struct.Schema, attributeName: string) => {\n const dzName = getDynamicZoneName(contentType, attributeName);\n\n return `${dzName}Input`;\n };\n\n /**\n * Build a component input type name based on a content type and an attribute name\n */\n const getComponentInputName = (contentType: Struct.Schema) => {\n const componentName = getComponentName(contentType);\n\n return `${componentName}Input`;\n };\n\n /**\n * Build a content type input name based on a content type and an attribute name\n */\n const getContentTypeInputName = (contentType: Struct.Schema) => {\n const typeName = getTypeName(contentType);\n\n return `${typeName}Input`;\n };\n\n /**\n * Build the queries type name for a given content type\n */\n const getEntityQueriesTypeName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Queries`;\n };\n\n /**\n * Build the mutations type name for a given content type\n */\n const getEntityMutationsTypeName = (contentType: Struct.Schema) => {\n return `${getEntityName(contentType)}Mutations`;\n };\n\n /**\n * Build the filters type name for a given content type\n */\n const getFiltersInputTypeName = (contentType: Struct.Schema) => {\n const isComponent = contentType.modelType === 'component';\n\n const baseName = isComponent ? getComponentName(contentType) : getTypeName(contentType);\n\n return `${baseName}FiltersInput`;\n };\n\n /**\n * Build a filters type name for a given GraphQL scalar type\n */\n const getScalarFilterInputTypeName = (scalarType: string) => {\n return `${scalarType}FilterInput`;\n };\n\n /**\n * Build a type name for a given content type & polymorphic attribute\n */\n const getMorphRelationTypeName = (contentType: Struct.Schema, attributeName: string) => {\n const typeName = getTypeName(contentType);\n const formattedAttr = upperFirst(camelCase(attributeName));\n\n return `${typeName}${formattedAttr}Morph`;\n };\n\n /**\n * Build a custom type name generator with different customization options\n */\n const buildCustomTypeNameGenerator = (options: {\n prefix?: string;\n suffix?: string;\n firstLetterCase?: 'upper' | 'lower';\n plurality?: 'plural' | 'singular';\n }) => {\n // todo[v4]: use singularName & pluralName is available\n const { prefix = '', suffix = '', plurality = 'singular', firstLetterCase = 'upper' } = options;\n\n if (!['plural', 'singular'].includes(plurality)) {\n throw new ApplicationError(\n `\"plurality\" param must be either \"plural\" or \"singular\", but got: \"${plurality}\"`\n );\n }\n\n const getCustomTypeName = pipe(\n (ct) => getTypeName(ct, { plurality }),\n firstLetterCase === 'upper' ? upperFirst : lowerFirst\n );\n\n return (contentType: Struct.Schema) => `${prefix}${getCustomTypeName(contentType)}${suffix}`;\n };\n\n const getFindQueryName = buildCustomTypeNameGenerator({\n plurality: 'plural',\n firstLetterCase: 'lower',\n });\n\n const getFindConnectionQueryName = (contentType: Struct.Schema) => {\n return `${getFindQueryName(contentType)}_connection`;\n };\n\n const getFindOneQueryName = buildCustomTypeNameGenerator({ firstLetterCase: 'lower' });\n\n const getCreateMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'create',\n firstLetterCase: 'upper',\n });\n\n const getUpdateMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'update',\n firstLetterCase: 'upper',\n });\n\n const getDeleteMutationTypeName = buildCustomTypeNameGenerator({\n prefix: 'delete',\n firstLetterCase: 'upper',\n });\n\n return {\n getEnumName,\n getTypeName,\n getEntityName,\n getEntityMetaName,\n getEntityResponseName,\n getEntityResponseCollectionName,\n getRelationResponseCollectionName,\n getComponentName,\n getComponentNameFromAttribute,\n getDynamicZoneName,\n getDynamicZoneInputName,\n getComponentInputName,\n getContentTypeInputName,\n getEntityQueriesTypeName,\n getEntityMutationsTypeName,\n getFiltersInputTypeName,\n getScalarFilterInputTypeName,\n getMorphRelationTypeName,\n buildCustomTypeNameGenerator,\n getFindQueryName,\n getFindOneQueryName,\n getCreateMutationTypeName,\n getUpdateMutationTypeName,\n getDeleteMutationTypeName,\n getFindConnectionQueryName,\n };\n};\n"],"names":["ApplicationError","errors","strapi","getEnumName","contentType","attributeName","attributes","enumName","modelType","typeName","getComponentName","getTypeName","defaultEnumName","toUpperCase","plurality","plugin","get","modelName","name","transformedPlugin","upperFirst","camelCase","transformedModelName","singular","getEntityName","getEntityMetaName","getEntityResponseName","getEntityResponseCollectionName","getRelationResponseCollectionName","globalId","getComponentNameFromAttribute","attribute","components","component","getDynamicZoneName","dzName","suffix","getDynamicZoneInputName","getComponentInputName","componentName","getContentTypeInputName","getEntityQueriesTypeName","getEntityMutationsTypeName","getFiltersInputTypeName","isComponent","baseName","getScalarFilterInputTypeName","scalarType","getMorphRelationTypeName","formattedAttr","buildCustomTypeNameGenerator","options","prefix","firstLetterCase","includes","getCustomTypeName","pipe","ct","lowerFirst","getFindQueryName","getFindConnectionQueryName","getFindOneQueryName","getCreateMutationTypeName","getUpdateMutationTypeName","getDeleteMutationTypeName"],"mappings":";;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,aAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC;;MAGA,MAAMC,WAAc,GAAA,CAACC,WAA4BC,EAAAA,aAAAA,GAAAA;QAC/C,MAAM,EAAEC,UAAU,EAAE,GAAGF,WAAAA;AACvB,QAAA,MAAM,EAAEG,QAAQ,EAAE,GAAGD,UAAU,CAACD,aAAc,CAAA;QAC9C,MAAM,EAAEG,SAAS,EAAE,GAAGJ,WAAAA;AAEtB,QAAA,MAAMK,QACJD,GAAAA,SAAAA,KAAc,WAAcE,GAAAA,gBAAAA,CAAiBN,eAAeO,WAAYP,CAAAA,WAAAA,CAAAA;AAE1E,QAAA,MAAMQ,eAAkB,GAAA,CAAC,KAAK,EAAEH,QAASI,CAAAA,WAAW,EAAG,CAAA,CAAC,EAAER,aAAAA,CAAcQ,WAAW,EAAA,CAAG,CAAC;AAEvF,QAAA,OAAON,QAAYK,IAAAA,eAAAA;AACrB,KAAA;AAEA;;MAGA,MAAMD,WAAc,GAAA,CAClBP,WACA,EAAA,EACEU,YAAY,UAAU,EAGvB,GAAG,EAAE,GAAA;QAEN,MAAMC,MAAAA,GAAS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A;AACAC,QAAAA,iCAAAA;AACAlB,QAAAA,gBAAAA;AACAoB,QAAAA,6BAAAA;AACAI,QAAAA,kBAAAA;AACAG,QAAAA,uBAAAA;AACAC,QAAAA,qBAAAA;AACAE,QAAAA,uBAAAA;AACAC,QAAAA,wBAAAA;AACAC,QAAAA,0BAAAA;AACAC,QAAAA,uBAAAA;AACAG,QAAAA,4BAAAA;AACAE,QAAAA,wBAAAA;AACAE,QAAAA,4BAAAA;AACAS,QAAAA,gBAAAA;AACAE,QAAAA,mBAAAA;AACAC,QAAAA,yBAAAA;AACAC,QAAAA,yBAAAA;AACAC,QAAAA,yBAAAA;AACAJ,QAAAA;AACF,KAAA;AACF,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-graphql",
|
|
3
|
-
"version": "5.13.0
|
|
3
|
+
"version": "5.13.0",
|
|
4
4
|
"description": "Adds GraphQL endpoint with default API methods.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@koa/cors": "5.0.0",
|
|
60
60
|
"@strapi/design-system": "2.0.0-rc.23",
|
|
61
61
|
"@strapi/icons": "2.0.0-rc.23",
|
|
62
|
-
"@strapi/utils": "5.13.0
|
|
62
|
+
"@strapi/utils": "5.13.0",
|
|
63
63
|
"graphql": "^16.8.1",
|
|
64
64
|
"graphql-depth-limit": "^1.1.0",
|
|
65
65
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -71,19 +71,19 @@
|
|
|
71
71
|
"pluralize": "8.0.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@strapi/strapi": "5.13.0
|
|
75
|
-
"@strapi/types": "5.13.0
|
|
74
|
+
"@strapi/strapi": "5.13.0",
|
|
75
|
+
"@strapi/types": "5.13.0",
|
|
76
76
|
"@types/graphql-depth-limit": "1.1.5",
|
|
77
77
|
"@types/koa-bodyparser": "4.3.12",
|
|
78
78
|
"@types/koa__cors": "5.0.0",
|
|
79
79
|
"cross-env": "^7.0.3",
|
|
80
|
-
"eslint-config-custom": "5.13.0
|
|
80
|
+
"eslint-config-custom": "5.13.0",
|
|
81
81
|
"koa": "2.15.4",
|
|
82
82
|
"react": "18.3.1",
|
|
83
83
|
"react-dom": "18.3.1",
|
|
84
84
|
"react-router-dom": "6.22.3",
|
|
85
85
|
"styled-components": "6.1.8",
|
|
86
|
-
"tsconfig": "5.13.0
|
|
86
|
+
"tsconfig": "5.13.0",
|
|
87
87
|
"typescript": "5.4.4"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|