@strapi/content-type-builder 5.43.0 → 5.45.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.
Files changed (39) hide show
  1. package/dist/admin/components/AIChat/lib/transforms/schemas/fromCTB.js +3 -0
  2. package/dist/admin/components/AIChat/lib/transforms/schemas/fromCTB.js.map +1 -1
  3. package/dist/admin/components/AIChat/lib/transforms/schemas/fromCTB.mjs +3 -0
  4. package/dist/admin/components/AIChat/lib/transforms/schemas/fromCTB.mjs.map +1 -1
  5. package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.js +53 -1
  6. package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.js.map +1 -1
  7. package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.mjs +53 -1
  8. package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.mjs.map +1 -1
  9. package/dist/admin/src/components/AIChat/lib/types/schema.d.ts +2 -0
  10. package/dist/admin/translations/cs.json.js +158 -2
  11. package/dist/admin/translations/cs.json.js.map +1 -1
  12. package/dist/admin/translations/cs.json.mjs +158 -2
  13. package/dist/admin/translations/cs.json.mjs.map +1 -1
  14. package/dist/server/controllers/validation/content-type.js.map +1 -1
  15. package/dist/server/controllers/validation/content-type.mjs.map +1 -1
  16. package/dist/server/controllers/validation/schema.js +5 -2
  17. package/dist/server/controllers/validation/schema.js.map +1 -1
  18. package/dist/server/controllers/validation/schema.mjs +6 -3
  19. package/dist/server/controllers/validation/schema.mjs.map +1 -1
  20. package/dist/server/services/api-handler.js +8 -0
  21. package/dist/server/services/api-handler.js.map +1 -1
  22. package/dist/server/services/api-handler.mjs +8 -0
  23. package/dist/server/services/api-handler.mjs.map +1 -1
  24. package/dist/server/services/schema-builder/content-type-builder.js +3 -2
  25. package/dist/server/services/schema-builder/content-type-builder.js.map +1 -1
  26. package/dist/server/services/schema-builder/content-type-builder.mjs +3 -2
  27. package/dist/server/services/schema-builder/content-type-builder.mjs.map +1 -1
  28. package/dist/server/services/schema.js +8 -6
  29. package/dist/server/services/schema.js.map +1 -1
  30. package/dist/server/services/schema.mjs +8 -6
  31. package/dist/server/services/schema.mjs.map +1 -1
  32. package/dist/server/src/controllers/validation/content-type.d.ts +1 -0
  33. package/dist/server/src/controllers/validation/content-type.d.ts.map +1 -1
  34. package/dist/server/src/controllers/validation/schema.d.ts +9 -1
  35. package/dist/server/src/controllers/validation/schema.d.ts.map +1 -1
  36. package/dist/server/src/services/api-handler.d.ts.map +1 -1
  37. package/dist/server/src/services/schema-builder/content-type-builder.d.ts.map +1 -1
  38. package/dist/server/src/services/schema.d.ts.map +1 -1
  39. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"content-type-builder.mjs","sources":["../../../../server/src/services/schema-builder/content-type-builder.ts"],"sourcesContent":["import path from 'path';\nimport _ from 'lodash';\n\nimport { strings, errors } from '@strapi/utils';\nimport type { Schema, Internal } from '@strapi/types';\nimport { isRelation, isConfigurable } from '../../utils/attributes';\nimport { typeKinds } from '../constants';\nimport createSchemaHandler from './schema-handler';\nimport { CreateContentTypeInput } from '../../controllers/validation/content-type';\nimport type { InternalRelationAttribute, InternalAttribute } from './types';\n\nconst { ApplicationError } = errors;\n\nconst reuseUnsetPreviousProperties = (\n newAttribute: Schema.Attribute.AnyAttribute,\n oldAttribute: Schema.Attribute.AnyAttribute\n) => {\n _.defaults(\n newAttribute,\n _.omit(oldAttribute, [\n 'configurable',\n 'required',\n 'private',\n 'unique',\n 'pluginOptions',\n 'inversedBy',\n 'mappedBy',\n 'conditions', // Don't automatically preserve conditions\n ])\n );\n};\n\nexport default function createComponentBuilder() {\n return {\n setRelation(\n this: any,\n { key, uid, attribute }: { key: string; uid: string; attribute: InternalRelationAttribute }\n ) {\n if (!_.has(attribute, 'target')) {\n return;\n }\n\n const targetCT = this.contentTypes.get(attribute.target);\n\n if (!targetCT) {\n throw new ApplicationError(`Content type ${attribute.target} not found`);\n }\n\n const targetAttribute = targetCT.getAttribute(attribute.targetAttribute);\n\n if (!attribute.targetAttribute) {\n return;\n }\n\n // When generating the inverse relation, preserve existing conditions if they exist\n // If the target attribute already exists and has conditions, preserve them\n const targetAttributeData = targetAttribute || {};\n\n // If the source doesn't have conditions but the target does, preserve target's conditions\n\n targetCT.setAttribute(\n attribute.targetAttribute,\n generateRelation({ key, attribute, uid, targetAttribute: targetAttributeData })\n );\n },\n\n unsetRelation(\n this: any,\n attribute: Schema.Attribute.Relation<Schema.Attribute.RelationKind.Any>\n ) {\n if (!('target' in attribute) || !attribute.target) {\n return;\n }\n\n const targetCT = this.contentTypes.get(attribute.target);\n\n const relationAttribute = attribute as InternalRelationAttribute;\n const targetAttributeName = relationAttribute.inversedBy || relationAttribute.mappedBy;\n const targetAttribute = targetCT.getAttribute(targetAttributeName);\n\n if (!targetAttribute) return;\n\n return targetCT.deleteAttribute(targetAttributeName);\n },\n\n createContentTypeAttributes(\n this: any,\n uid: string,\n attributes: CreateContentTypeInput['attributes']\n ) {\n if (!this.contentTypes.has(uid)) {\n throw new ApplicationError('contentType.notFound');\n }\n\n const contentType = this.contentTypes.get(uid);\n\n // support self referencing content type relation\n Object.keys(attributes).forEach((key) => {\n const { target } = attributes[key];\n if (target === '__self__') {\n attributes[key].target = uid;\n }\n });\n\n contentType.setAttributes(this.convertAttributes(attributes));\n\n Object.keys(attributes).forEach((key) => {\n const attribute = attributes[key] as InternalAttribute;\n\n if (isRelation(attribute)) {\n const relationAttribute = attribute as InternalRelationAttribute;\n if (['manyToMany', 'oneToOne'].includes(relationAttribute.relation)) {\n if (\n relationAttribute.target === uid &&\n relationAttribute.targetAttribute !== undefined\n ) {\n // self referencing relation\n const targetAttribute = attributes[\n relationAttribute.targetAttribute\n ] as InternalRelationAttribute;\n\n if (targetAttribute.dominant === undefined) {\n relationAttribute.dominant = true;\n } else {\n relationAttribute.dominant = false;\n }\n } else {\n relationAttribute.dominant = true;\n }\n }\n\n this.setRelation({\n key,\n uid,\n attribute: relationAttribute,\n });\n }\n });\n\n return contentType;\n },\n\n /**\n * Creates a content type in memory to be written to files later on\n */\n createContentType(this: any, infos: CreateContentTypeInput) {\n // TODO:: check for unique uid / singularName & pluralName & collectionName\n\n if (infos.uid && infos.uid !== createContentTypeUID(infos)) {\n throw new ApplicationError('contentType.invalidUID');\n }\n\n const uid = infos.uid ?? createContentTypeUID(infos);\n\n if (this.contentTypes.has(uid)) {\n throw new ApplicationError('contentType.alreadyExists');\n }\n\n const contentType = createSchemaHandler({\n modelName: infos.singularName,\n dir: path.join(\n strapi.dirs.app.api,\n infos.singularName,\n 'content-types',\n infos.singularName\n ),\n filename: `schema.json`,\n });\n\n this.contentTypes.set(uid, contentType);\n\n contentType\n .setUID(uid)\n .set('kind', infos.kind || typeKinds.COLLECTION_TYPE)\n .set(\n 'collectionName',\n infos.collectionName || strings.nameToCollectionName(infos.pluralName)\n )\n .set('info', {\n singularName: infos.singularName,\n pluralName: infos.pluralName,\n displayName: infos.displayName,\n description: infos.description,\n })\n .set('options', {\n ...(infos.options ?? {}),\n draftAndPublish: infos.draftAndPublish,\n })\n .set('pluginOptions', infos.pluginOptions)\n .set('config', infos.config);\n\n this.createContentTypeAttributes(uid, infos.attributes);\n\n return contentType;\n },\n\n editContentType(this: any, infos: any) {\n const { uid } = infos;\n\n if (!this.contentTypes.has(uid)) {\n throw new ApplicationError('contentType.notFound');\n }\n\n const contentType = this.contentTypes.get(uid);\n\n const oldAttributes = contentType.schema.attributes;\n\n const newAttributes = _.omitBy(infos.attributes, (attr, key) => {\n return _.has(oldAttributes, key) && !isConfigurable(oldAttributes[key]);\n });\n\n const newKeys = _.difference(Object.keys(newAttributes), Object.keys(oldAttributes));\n const deletedKeys = _.difference(Object.keys(oldAttributes), Object.keys(newAttributes));\n const remainingKeys = _.intersection(Object.keys(oldAttributes), Object.keys(newAttributes));\n\n // remove old relations\n deletedKeys.forEach((key) => {\n const attribute = oldAttributes[key];\n\n // if the old relation has a target attribute. we need to remove it in the target type\n if (isConfigurable(attribute) && isRelation(attribute)) {\n const relationAttribute = attribute as InternalRelationAttribute;\n const targetAttributeName = relationAttribute.inversedBy || relationAttribute.mappedBy;\n\n if (targetAttributeName !== null && targetAttributeName !== undefined) {\n this.unsetRelation(attribute);\n }\n }\n });\n\n remainingKeys.forEach((key) => {\n const oldAttribute = oldAttributes[key];\n const newAttribute = newAttributes[key] as InternalAttribute;\n\n if (!isRelation(oldAttribute) && isRelation(newAttribute)) {\n return this.setRelation({\n key,\n uid,\n attribute: newAttribute as InternalRelationAttribute,\n });\n }\n\n if (isRelation(oldAttribute) && !isRelation(newAttribute)) {\n return this.unsetRelation(oldAttribute);\n }\n\n if (isRelation(oldAttribute) && isRelation(newAttribute)) {\n const relationAttribute = newAttribute as InternalRelationAttribute;\n const oldRelationAttribute = oldAttribute as InternalRelationAttribute;\n const oldTargetAttributeName =\n oldRelationAttribute.inversedBy || oldRelationAttribute.mappedBy;\n\n const sameRelation = oldAttribute.relation === relationAttribute.relation;\n const targetAttributeHasChanged =\n oldTargetAttributeName !== relationAttribute.targetAttribute;\n\n if (!sameRelation || targetAttributeHasChanged) {\n this.unsetRelation(oldAttribute);\n }\n\n // keep extra options that were set manually on oldAttribute\n reuseUnsetPreviousProperties(relationAttribute, oldAttribute);\n\n // Handle conditions explicitly - only preserve if present and not undefined in new attribute\n const newAttributeFromInfos = newAttributes[key];\n const hasNewConditions =\n newAttributeFromInfos.conditions !== undefined &&\n newAttributeFromInfos.conditions !== null;\n\n if (oldAttribute.conditions) {\n if (hasNewConditions) {\n // Conditions are still present, keep them\n relationAttribute.conditions = newAttributeFromInfos.conditions;\n } else {\n // Conditions were removed (undefined or null), ensure they're not preserved\n delete relationAttribute.conditions;\n }\n } else if (hasNewConditions) {\n // New conditions added\n relationAttribute.conditions = newAttributeFromInfos.conditions;\n }\n\n if (oldRelationAttribute.inversedBy) {\n relationAttribute.dominant = true;\n } else if (oldRelationAttribute.mappedBy) {\n relationAttribute.dominant = false;\n }\n\n return this.setRelation({\n key,\n uid,\n attribute: relationAttribute,\n });\n }\n });\n\n // add new relations\n newKeys.forEach((key) => {\n const attribute = newAttributes[key] as InternalAttribute;\n\n if (isRelation(attribute)) {\n const relationAttribute = attribute as InternalRelationAttribute;\n if (['manyToMany', 'oneToOne'].includes(relationAttribute.relation)) {\n if (\n relationAttribute.target === uid &&\n relationAttribute.targetAttribute !== undefined\n ) {\n // self referencing relation\n const targetAttribute = newAttributes[\n relationAttribute.targetAttribute\n ] as InternalRelationAttribute;\n\n if (targetAttribute.dominant === undefined) {\n relationAttribute.dominant = true;\n } else {\n relationAttribute.dominant = false;\n }\n } else {\n relationAttribute.dominant = true;\n }\n }\n\n this.setRelation({\n key,\n uid,\n attribute: relationAttribute,\n });\n }\n });\n\n contentType\n .set('kind', infos.kind || contentType.schema.kind)\n .set(['info', 'displayName'], infos.displayName)\n .set(['info', 'description'], infos.description)\n .set('options', {\n ...(infos.options ?? {}),\n draftAndPublish: infos.draftAndPublish,\n })\n .set('pluginOptions', infos.pluginOptions)\n .setAttributes(this.convertAttributes(newAttributes));\n\n return contentType;\n },\n\n deleteContentType(this: any, uid: string) {\n if (!this.contentTypes.has(uid)) {\n throw new ApplicationError('contentType.notFound');\n }\n\n this.components.forEach((compo: any) => {\n compo.removeContentType(uid);\n });\n\n this.contentTypes.forEach((ct: any) => {\n ct.removeContentType(uid);\n });\n\n return this.contentTypes.get(uid).delete();\n },\n };\n}\n\n/**\n * Returns a uid from a content type infos\n *\n * @param {object} options options\n * @param {string} options.singularName content-type singularName\n * @returns {string} uid\n */\nconst createContentTypeUID = ({\n singularName,\n}: {\n singularName: string;\n}): Internal.UID.ContentType => `api::${singularName}.${singularName}`;\n\nconst generateRelation = ({\n key,\n attribute,\n uid,\n targetAttribute = {},\n}: {\n key: string;\n attribute: InternalRelationAttribute;\n uid: string;\n targetAttribute?: Partial<InternalRelationAttribute>;\n}) => {\n const opts: any = {\n type: 'relation',\n target: uid,\n private: targetAttribute.private || undefined,\n pluginOptions: targetAttribute.pluginOptions || undefined,\n // Preserve conditions from targetAttribute if they exist\n // This allows each side of the relation to maintain its own conditions\n ...(targetAttribute.conditions && { conditions: targetAttribute.conditions }),\n };\n\n switch (attribute.relation) {\n case 'oneToOne': {\n opts.relation = 'oneToOne';\n\n if (attribute.dominant) {\n opts.mappedBy = key;\n } else {\n opts.inversedBy = key;\n }\n break;\n }\n case 'oneToMany': {\n opts.relation = 'manyToOne';\n opts.inversedBy = key;\n break;\n }\n case 'manyToOne': {\n opts.relation = 'oneToMany';\n opts.mappedBy = key;\n break;\n }\n case 'manyToMany': {\n opts.relation = 'manyToMany';\n\n if (attribute.dominant) {\n opts.mappedBy = key;\n } else {\n opts.inversedBy = key;\n }\n\n break;\n }\n default:\n }\n\n // we do this just to make sure we have the same key order when writing to files\n const { type, relation, target, ...restOptions } = opts;\n\n const result = {\n type,\n relation,\n target,\n ...restOptions,\n };\n\n return result;\n};\n"],"names":["ApplicationError","errors","reuseUnsetPreviousProperties","newAttribute","oldAttribute","_","defaults","omit","createComponentBuilder","setRelation","key","uid","attribute","has","targetCT","contentTypes","get","target","targetAttribute","getAttribute","targetAttributeData","setAttribute","generateRelation","unsetRelation","relationAttribute","targetAttributeName","inversedBy","mappedBy","deleteAttribute","createContentTypeAttributes","attributes","contentType","Object","keys","forEach","setAttributes","convertAttributes","isRelation","includes","relation","undefined","dominant","createContentType","infos","createContentTypeUID","createSchemaHandler","modelName","singularName","dir","path","join","strapi","dirs","app","api","filename","set","setUID","kind","typeKinds","COLLECTION_TYPE","collectionName","strings","nameToCollectionName","pluralName","displayName","description","options","draftAndPublish","pluginOptions","config","editContentType","oldAttributes","schema","newAttributes","omitBy","attr","isConfigurable","newKeys","difference","deletedKeys","remainingKeys","intersection","oldRelationAttribute","oldTargetAttributeName","sameRelation","targetAttributeHasChanged","newAttributeFromInfos","hasNewConditions","conditions","deleteContentType","components","compo","removeContentType","ct","delete","opts","type","private","restOptions","result"],"mappings":";;;;;;;AAWA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC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AA;AAChB,gBAAA;AACF,YAAA;QACA,KAAK,YAAA;AAAc,YAAA;AACjBsF,gBAAAA,IAAAA,CAAKzD,QAAQ,GAAG,YAAA;gBAEhB,IAAI3B,SAAAA,CAAU6B,QAAQ,EAAE;AACtBuD,oBAAAA,IAAAA,CAAKrE,QAAQ,GAAGjB,GAAAA;gBAClB,CAAA,MAAO;AACLsF,oBAAAA,IAAAA,CAAKtE,UAAU,GAAGhB,GAAAA;AACpB,gBAAA;AAEA,gBAAA;AACF,YAAA;AAEF;;IAGA,MAAM,EAAEuF,IAAI,EAAE1D,QAAQ,EAAEtB,MAAM,EAAE,GAAGkF,WAAAA,EAAa,GAAGH,IAAAA;AAEnD,IAAA,MAAMI,MAAAA,GAAS;AACbH,QAAAA,IAAAA;AACA1D,QAAAA,QAAAA;AACAtB,QAAAA,MAAAA;AACA,QAAA,GAAGkF;AACL,KAAA;IAEA,OAAOC,MAAAA;AACT,CAAA;;;;"}
1
+ {"version":3,"file":"content-type-builder.mjs","sources":["../../../../server/src/services/schema-builder/content-type-builder.ts"],"sourcesContent":["import path from 'path';\nimport _ from 'lodash';\n\nimport { strings, errors } from '@strapi/utils';\nimport type { Schema, Internal } from '@strapi/types';\nimport { isRelation, isConfigurable } from '../../utils/attributes';\nimport { typeKinds } from '../constants';\nimport createSchemaHandler from './schema-handler';\nimport { CreateContentTypeInput } from '../../controllers/validation/content-type';\nimport type { InternalRelationAttribute, InternalAttribute } from './types';\n\nconst { ApplicationError } = errors;\n\nconst reuseUnsetPreviousProperties = (\n newAttribute: Schema.Attribute.AnyAttribute,\n oldAttribute: Schema.Attribute.AnyAttribute\n) => {\n _.defaults(\n newAttribute,\n _.omit(oldAttribute, [\n 'configurable',\n 'required',\n 'private',\n 'unique',\n 'pluginOptions',\n 'inversedBy',\n 'mappedBy',\n 'conditions', // Don't automatically preserve conditions\n ])\n );\n};\n\nexport default function createComponentBuilder() {\n return {\n setRelation(\n this: any,\n { key, uid, attribute }: { key: string; uid: string; attribute: InternalRelationAttribute }\n ) {\n if (!_.has(attribute, 'target')) {\n return;\n }\n\n const targetCT = this.contentTypes.get(attribute.target);\n\n if (!targetCT) {\n throw new ApplicationError(`Content type ${attribute.target} not found`);\n }\n\n const targetAttribute = targetCT.getAttribute(attribute.targetAttribute);\n\n if (!attribute.targetAttribute) {\n return;\n }\n\n // When generating the inverse relation, preserve existing conditions if they exist\n // If the target attribute already exists and has conditions, preserve them\n const targetAttributeData = targetAttribute || {};\n\n // If the source doesn't have conditions but the target does, preserve target's conditions\n\n targetCT.setAttribute(\n attribute.targetAttribute,\n generateRelation({ key, attribute, uid, targetAttribute: targetAttributeData })\n );\n },\n\n unsetRelation(\n this: any,\n attribute: Schema.Attribute.Relation<Schema.Attribute.RelationKind.Any>\n ) {\n if (!('target' in attribute) || !attribute.target) {\n return;\n }\n\n const targetCT = this.contentTypes.get(attribute.target);\n\n const relationAttribute = attribute as InternalRelationAttribute;\n const targetAttributeName = relationAttribute.inversedBy || relationAttribute.mappedBy;\n const targetAttribute = targetCT.getAttribute(targetAttributeName);\n\n if (!targetAttribute) return;\n\n return targetCT.deleteAttribute(targetAttributeName);\n },\n\n createContentTypeAttributes(\n this: any,\n uid: string,\n attributes: CreateContentTypeInput['attributes']\n ) {\n if (!this.contentTypes.has(uid)) {\n throw new ApplicationError('contentType.notFound');\n }\n\n const contentType = this.contentTypes.get(uid);\n\n // support self referencing content type relation\n Object.keys(attributes).forEach((key) => {\n const { target } = attributes[key];\n if (target === '__self__') {\n attributes[key].target = uid;\n }\n });\n\n contentType.setAttributes(this.convertAttributes(attributes));\n\n Object.keys(attributes).forEach((key) => {\n const attribute = attributes[key] as InternalAttribute;\n\n if (isRelation(attribute)) {\n const relationAttribute = attribute as InternalRelationAttribute;\n if (['manyToMany', 'oneToOne'].includes(relationAttribute.relation)) {\n if (\n relationAttribute.target === uid &&\n relationAttribute.targetAttribute !== undefined\n ) {\n // self referencing relation\n const targetAttribute = attributes[\n relationAttribute.targetAttribute\n ] as InternalRelationAttribute;\n\n if (targetAttribute.dominant === undefined) {\n relationAttribute.dominant = true;\n } else {\n relationAttribute.dominant = false;\n }\n } else {\n relationAttribute.dominant = true;\n }\n }\n\n this.setRelation({\n key,\n uid,\n attribute: relationAttribute,\n });\n }\n });\n\n return contentType;\n },\n\n /**\n * Creates a content type in memory to be written to files later on\n */\n createContentType(this: any, infos: CreateContentTypeInput) {\n // TODO:: check for unique uid / singularName & pluralName & collectionName\n\n if (infos.uid && infos.uid !== createContentTypeUID(infos)) {\n throw new ApplicationError('contentType.invalidUID');\n }\n\n const uid = infos.uid ?? createContentTypeUID(infos);\n\n if (this.contentTypes.has(uid)) {\n throw new ApplicationError('contentType.alreadyExists');\n }\n\n const dir = infos.plugin\n ? path.join(strapi.dirs.app.extensions, infos.plugin, 'content-types', infos.singularName)\n : path.join(strapi.dirs.app.api, infos.singularName, 'content-types', infos.singularName);\n\n const contentType = createSchemaHandler({\n modelName: infos.singularName,\n dir,\n filename: `schema.json`,\n });\n\n this.contentTypes.set(uid, contentType);\n\n contentType\n .setUID(uid)\n .set('kind', infos.kind || typeKinds.COLLECTION_TYPE)\n .set(\n 'collectionName',\n infos.collectionName || strings.nameToCollectionName(infos.pluralName)\n )\n .set('info', {\n singularName: infos.singularName,\n pluralName: infos.pluralName,\n displayName: infos.displayName,\n description: infos.description,\n })\n .set('options', {\n ...(infos.options ?? {}),\n draftAndPublish: infos.draftAndPublish,\n })\n .set('pluginOptions', infos.pluginOptions)\n .set('config', infos.config);\n\n this.createContentTypeAttributes(uid, infos.attributes);\n\n return contentType;\n },\n\n editContentType(this: any, infos: any) {\n const { uid } = infos;\n\n if (!this.contentTypes.has(uid)) {\n throw new ApplicationError('contentType.notFound');\n }\n\n const contentType = this.contentTypes.get(uid);\n\n const oldAttributes = contentType.schema.attributes;\n\n const newAttributes = _.omitBy(infos.attributes, (attr, key) => {\n return _.has(oldAttributes, key) && !isConfigurable(oldAttributes[key]);\n });\n\n const newKeys = _.difference(Object.keys(newAttributes), Object.keys(oldAttributes));\n const deletedKeys = _.difference(Object.keys(oldAttributes), Object.keys(newAttributes));\n const remainingKeys = _.intersection(Object.keys(oldAttributes), Object.keys(newAttributes));\n\n // remove old relations\n deletedKeys.forEach((key) => {\n const attribute = oldAttributes[key];\n\n // if the old relation has a target attribute. we need to remove it in the target type\n if (isConfigurable(attribute) && isRelation(attribute)) {\n const relationAttribute = attribute as InternalRelationAttribute;\n const targetAttributeName = relationAttribute.inversedBy || relationAttribute.mappedBy;\n\n if (targetAttributeName !== null && targetAttributeName !== undefined) {\n this.unsetRelation(attribute);\n }\n }\n });\n\n remainingKeys.forEach((key) => {\n const oldAttribute = oldAttributes[key];\n const newAttribute = newAttributes[key] as InternalAttribute;\n\n if (!isRelation(oldAttribute) && isRelation(newAttribute)) {\n return this.setRelation({\n key,\n uid,\n attribute: newAttribute as InternalRelationAttribute,\n });\n }\n\n if (isRelation(oldAttribute) && !isRelation(newAttribute)) {\n return this.unsetRelation(oldAttribute);\n }\n\n if (isRelation(oldAttribute) && isRelation(newAttribute)) {\n const relationAttribute = newAttribute as InternalRelationAttribute;\n const oldRelationAttribute = oldAttribute as InternalRelationAttribute;\n const oldTargetAttributeName =\n oldRelationAttribute.inversedBy || oldRelationAttribute.mappedBy;\n\n const sameRelation = oldAttribute.relation === relationAttribute.relation;\n const targetAttributeHasChanged =\n oldTargetAttributeName !== relationAttribute.targetAttribute;\n\n if (!sameRelation || targetAttributeHasChanged) {\n this.unsetRelation(oldAttribute);\n }\n\n // keep extra options that were set manually on oldAttribute\n reuseUnsetPreviousProperties(relationAttribute, oldAttribute);\n\n // Handle conditions explicitly - only preserve if present and not undefined in new attribute\n const newAttributeFromInfos = newAttributes[key];\n const hasNewConditions =\n newAttributeFromInfos.conditions !== undefined &&\n newAttributeFromInfos.conditions !== null;\n\n if (oldAttribute.conditions) {\n if (hasNewConditions) {\n // Conditions are still present, keep them\n relationAttribute.conditions = newAttributeFromInfos.conditions;\n } else {\n // Conditions were removed (undefined or null), ensure they're not preserved\n delete relationAttribute.conditions;\n }\n } else if (hasNewConditions) {\n // New conditions added\n relationAttribute.conditions = newAttributeFromInfos.conditions;\n }\n\n if (oldRelationAttribute.inversedBy) {\n relationAttribute.dominant = true;\n } else if (oldRelationAttribute.mappedBy) {\n relationAttribute.dominant = false;\n }\n\n return this.setRelation({\n key,\n uid,\n attribute: relationAttribute,\n });\n }\n });\n\n // add new relations\n newKeys.forEach((key) => {\n const attribute = newAttributes[key] as InternalAttribute;\n\n if (isRelation(attribute)) {\n const relationAttribute = attribute as InternalRelationAttribute;\n if (['manyToMany', 'oneToOne'].includes(relationAttribute.relation)) {\n if (\n relationAttribute.target === uid &&\n relationAttribute.targetAttribute !== undefined\n ) {\n // self referencing relation\n const targetAttribute = newAttributes[\n relationAttribute.targetAttribute\n ] as InternalRelationAttribute;\n\n if (targetAttribute.dominant === undefined) {\n relationAttribute.dominant = true;\n } else {\n relationAttribute.dominant = false;\n }\n } else {\n relationAttribute.dominant = true;\n }\n }\n\n this.setRelation({\n key,\n uid,\n attribute: relationAttribute,\n });\n }\n });\n\n contentType\n .set('kind', infos.kind || contentType.schema.kind)\n .set(['info', 'displayName'], infos.displayName)\n .set(['info', 'description'], infos.description)\n .set('options', {\n ...(infos.options ?? {}),\n draftAndPublish: infos.draftAndPublish,\n })\n .set('pluginOptions', infos.pluginOptions)\n .setAttributes(this.convertAttributes(newAttributes));\n\n return contentType;\n },\n\n deleteContentType(this: any, uid: string) {\n if (!this.contentTypes.has(uid)) {\n throw new ApplicationError('contentType.notFound');\n }\n\n this.components.forEach((compo: any) => {\n compo.removeContentType(uid);\n });\n\n this.contentTypes.forEach((ct: any) => {\n ct.removeContentType(uid);\n });\n\n return this.contentTypes.get(uid).delete();\n },\n };\n}\n\n/**\n * Returns a uid from a content type infos\n *\n * @param {object} options options\n * @param {string} options.singularName content-type singularName\n * @returns {string} uid\n */\nconst createContentTypeUID = ({\n plugin,\n singularName,\n}: {\n plugin?: string;\n singularName: string;\n}): Internal.UID.ContentType =>\n `${plugin ? `plugin` : `api`}::${plugin || singularName}.${singularName}`;\n\nconst generateRelation = ({\n key,\n attribute,\n uid,\n targetAttribute = {},\n}: {\n key: string;\n attribute: InternalRelationAttribute;\n uid: string;\n targetAttribute?: Partial<InternalRelationAttribute>;\n}) => {\n const opts: any = {\n type: 'relation',\n target: uid,\n private: targetAttribute.private || undefined,\n pluginOptions: targetAttribute.pluginOptions || undefined,\n // Preserve conditions from targetAttribute if they exist\n // This allows each side of the relation to maintain its own conditions\n ...(targetAttribute.conditions && { conditions: targetAttribute.conditions }),\n };\n\n switch (attribute.relation) {\n case 'oneToOne': {\n opts.relation = 'oneToOne';\n\n if (attribute.dominant) {\n opts.mappedBy = key;\n } else {\n opts.inversedBy = key;\n }\n break;\n }\n case 'oneToMany': {\n opts.relation = 'manyToOne';\n opts.inversedBy = key;\n break;\n }\n case 'manyToOne': {\n opts.relation = 'oneToMany';\n opts.mappedBy = key;\n break;\n }\n case 'manyToMany': {\n opts.relation = 'manyToMany';\n\n if (attribute.dominant) {\n opts.mappedBy = key;\n } else {\n opts.inversedBy = key;\n }\n\n break;\n }\n default:\n }\n\n // we do this just to make sure we have the same key order when writing to files\n const { type, relation, target, ...restOptions } = opts;\n\n const result = {\n type,\n relation,\n target,\n ...restOptions,\n };\n\n return result;\n};\n"],"names":["ApplicationError","errors","reuseUnsetPreviousProperties","newAttribute","oldAttribute","_","defaults","omit","createComponentBuilder","setRelation","key","uid","attribute","has","targetCT","contentTypes","get","target","targetAttribute","getAttribute","targetAttributeData","setAttribute","generateRelation","unsetRelation","relationAttribute","targetAttributeName","inversedBy","mappedBy","deleteAttribute","createContentTypeAttributes","attributes","contentType","Object","keys","forEach","setAttributes","convertAttributes","isRelation","includes","relation","undefined","dominant","createContentType","infos","createContentTypeUID","dir","plugin","path","join","strapi","dirs","app","extensions","singularName","api","createSchemaHandler","modelName","filename","set","setUID","kind","typeKinds","COLLECTION_TYPE","collectionName","strings","nameToCollectionName","pluralName","displayName","description","options","draftAndPublish","pluginOptions","config","editContentType","oldAttributes","schema","newAttributes","omitBy","attr","isConfigurable","newKeys","difference","deletedKeys","remainingKeys","intersection","oldRelationAttribute","oldTargetAttributeName","sameRelation","targetAttributeHasChanged","newAttributeFromInfos","hasNewConditions","conditions","deleteContentType","components","compo","removeContentType","ct","delete","opts","type","private","restOptions","result"],"mappings":";;;;;;;AAWA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,MAAMC,4BAAAA,GAA+B,CACnCC,YAAAA,EACAC,YAAAA,GAAAA;AAEAC,IAAAA,CAAAA,CAAEC,QAAQ,CACRH,YAAAA,EACAE,CAAAA,CAAEE,IAAI,CAACH,YAAAA,EAAc;AACnB,QAAA,cAAA;AACA,QAAA,UAAA;AACA,QAAA,SAAA;AACA,QAAA,QAAA;AACA,QAAA,eAAA;AACA,QAAA,YAAA;AACA,QAAA,UAAA;AACA,QAAA;AACD,KAAA,CAAA,CAAA;AAEL,CAAA;AAEe,SAASI,sBAAAA,GAAAA;IACtB,OAAO;AACLC,QAAAA,WAAAA,CAAAA,CAEE,EAAEC,GAAG,EAAEC,GAAG,EAAEC,SAAS,EAAsE,EAAA;AAE3F,YAAA,IAAI,CAACP,CAAAA,CAAEQ,GAAG,CAACD,WAAW,QAAA,CAAA,EAAW;AAC/B,gBAAA;AACF,YAAA;YAEA,MAAME,QAAAA,GAAW,IAAI,CAACC,YAAY,CAACC,GAAG,CAACJ,UAAUK,MAAM,CAAA;AAEvD,YAAA,IAAI,CAACH,QAAAA,EAAU;gBACb,MAAM,IAAId,iBAAiB,CAAC,aAAa,EAAEY,SAAAA,CAAUK,MAAM,CAAC,UAAU,CAAC,CAAA;AACzE,YAAA;AAEA,YAAA,MAAMC,eAAAA,GAAkBJ,QAAAA,CAASK,YAAY,CAACP,UAAUM,eAAe,CAAA;YAEvE,IAAI,CAACN,SAAAA,CAAUM,eAAe,EAAE;AAC9B,gBAAA;AACF,YAAA;;;YAIA,MAAME,mB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, {}));
144
- await index$1.getService('content-types').generateAPI({
145
- displayName: contentType.displayName,
146
- singularName: contentType.singularName,
147
- pluralName: contentType.pluralName,
148
- kind: contentType.kind
149
- });
144
+ if (!contentType.plugin) {
145
+ await index$1.getService('content-types').generateAPI({
146
+ displayName: contentType.displayName,
147
+ singularName: contentType.singularName,
148
+ pluralName: contentType.pluralName,
149
+ kind: contentType.kind
150
+ });
151
+ }
150
152
  }
151
153
  if (action === 'update') {
152
154
  builder.editContentType({
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sources":["../../../server/src/services/schema.ts"],"sourcesContent":["import utils from '@strapi/utils';\nimport { mapValues } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\n\nimport createBuilder from './schema-builder';\nimport { getService } from '../utils';\nimport type { Schema as CTBSchema } from '../controllers/validation/schema';\nimport { getRestrictRelationsTo, isContentTypeVisible } from './content-types';\n\nconst removeEmptyDefaultsOnUpdates = (schema: CTBSchema) => {\n schema.components.forEach((component) => {\n if (component.action === 'delete') {\n return;\n }\n\n component.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if ('default' in properties && properties.default === '') {\n properties.default = undefined;\n }\n }\n });\n });\n\n schema.contentTypes.forEach((contentType) => {\n if (contentType.action === 'delete') {\n return;\n }\n\n contentType.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if ('default' in properties && properties.default === '') {\n properties.default = undefined;\n }\n }\n });\n });\n};\n\nconst removeDeletedUIDTargetFieldsOnUpdates = (schema: CTBSchema) => {\n schema.contentTypes.forEach((contentType) => {\n if (contentType.action === 'delete') {\n return;\n }\n\n contentType.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if (\n properties.type === 'uid' &&\n properties.targetField &&\n !contentType.attributes.find((attr) => attr.name === properties.targetField)\n ) {\n properties.targetField = undefined;\n }\n }\n });\n });\n};\n\nconst formatAttributes = (model: any) => {\n const { getVisibleAttributes } = utils.contentTypes;\n\n // only get attributes that can be seen in the CTB\n return getVisibleAttributes(model).map((key) => {\n return { ...formatAttribute(model.attributes[key]), name: key };\n });\n};\n\nexport const formatAttribute = (attribute: Schema.Attribute.AnyAttribute & Record<string, any>) => {\n if (attribute.type === 'relation') {\n return {\n ...attribute,\n targetAttribute: attribute.inversedBy || attribute.mappedBy || null,\n // Explicitly preserve conditions if they exist\n ...(attribute.conditions && { conditions: attribute.conditions }),\n };\n }\n\n return attribute;\n};\n\nexport const getSchema = async () => {\n const contentTypes = mapValues((contentType) => {\n const {\n uid,\n options,\n globalId,\n pluginOptions,\n kind,\n modelName,\n plugin,\n collectionName,\n info,\n modelType,\n } = contentType;\n\n return {\n uid,\n modelName,\n kind,\n globalId,\n options,\n pluginOptions,\n plugin,\n collectionName,\n info,\n modelType,\n attributes: formatAttributes(contentType),\n visible: isContentTypeVisible(contentType),\n restrictRelationsTo: getRestrictRelationsTo(contentType),\n };\n }, strapi.contentTypes);\n\n const components = mapValues((component) => {\n const { uid, globalId, modelName, collectionName, info, category, modelType } = component;\n\n return {\n uid,\n modelName,\n globalId,\n modelType,\n collectionName,\n category,\n info,\n attributes: formatAttributes(component),\n };\n }, strapi.components);\n\n return {\n contentTypes,\n components,\n };\n};\n\nexport const updateSchema = async (schema: CTBSchema) => {\n const builder = createBuilder();\n const apiHandler = getService('api-handler');\n\n const { components, contentTypes } = schema;\n\n // pre-process data\n removeEmptyDefaultsOnUpdates(schema);\n removeDeletedUIDTargetFieldsOnUpdates(schema);\n\n // we pre create empty typesk\n for (const contentType of contentTypes) {\n if (contentType.action === 'create') {\n builder.createContentType({\n ...contentType,\n attributes: {},\n });\n }\n }\n\n // we pre create empty types\n for (const component of components) {\n if (component.action === 'create') {\n builder.createComponent({\n ...component,\n attributes: {},\n });\n }\n }\n\n for (const contentType of contentTypes) {\n const { action, uid } = contentType;\n\n if (action === 'create') {\n builder.createContentTypeAttributes(\n uid,\n contentType.attributes.reduce((acc: any, attr: any) => {\n acc[attr.name] = attr.properties;\n return acc;\n }, {})\n );\n\n await getService('content-types').generateAPI({\n displayName: contentType!.displayName,\n singularName: contentType!.singularName,\n pluralName: contentType!.pluralName,\n kind: contentType!.kind,\n });\n }\n\n if (action === 'update') {\n builder.editContentType({\n ...contentType,\n attributes: contentType.attributes.reduce((acc: any, attr: any) => {\n // NOTE: handle renaming migrations here by comparing attr name & attr.properties.name\n\n if (attr.action === 'delete') {\n return acc;\n }\n\n acc[attr.name] = attr.properties;\n return acc;\n }, {}),\n });\n }\n\n if (action === 'delete') {\n builder.deleteContentType(uid);\n await apiHandler.backup(uid);\n }\n }\n\n for (const component of components) {\n const { action, uid } = component;\n\n if (action === 'create') {\n builder.createComponentAttributes(\n uid,\n component.attributes.reduce((acc: any, attr: any) => {\n acc[attr.name] = attr.properties;\n return acc;\n }, {})\n );\n }\n\n if (action === 'update') {\n builder.editComponent({\n ...component,\n attributes: component.attributes.reduce((acc: any, attr: any) => {\n if (attr.action === 'delete') {\n return acc;\n }\n\n acc[attr.name] = attr.properties;\n return acc;\n }, {}),\n });\n }\n\n if (action === 'delete') {\n builder.deleteComponent(uid);\n }\n }\n\n // run sanity checks on the schema\n // Relations target existing types\n // Bidirectional relation have their counterpart in the schema\n // Components target existing components\n // Nested components target existing components\n // Dynamic zones target existing components\n\n const APIsToDelete = contentTypes\n .filter((ct: any) => ct.action === 'delete')\n .map((ct: any) => ct.uid);\n\n await builder.writeFiles();\n\n try {\n for (const uid of APIsToDelete) {\n await apiHandler.clear(uid);\n }\n } catch (error) {\n strapi.log.error(error);\n for (const uid of APIsToDelete) {\n await apiHandler.rollback(uid);\n }\n }\n\n for (const contentType of contentTypes) {\n if (contentType.action === 'delete') {\n strapi.eventHub.emit('content-type.delete', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n\n if (contentType.action === 'update') {\n strapi.eventHub.emit('content-type.update', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n\n if (contentType.action === 'create') {\n strapi.eventHub.emit('content-type.create', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n }\n\n for (const component of components) {\n if (component.action === 'delete') {\n strapi.eventHub.emit('component.delete', {\n component: builder.components.get(component.uid),\n });\n }\n\n if (component.action === 'update') {\n strapi.eventHub.emit('component.update', {\n component: builder.components.get(component.uid),\n });\n }\n\n if (component.action === 'create') {\n strapi.eventHub.emit('component.create', {\n component: builder.components.get(component.uid),\n });\n }\n }\n};\n"],"names":["removeEmptyDefaultsOnUpdates","schema","components","forEach","component","action","attributes","attribute","properties","default","undefined","contentTypes","contentType","removeDeletedUIDTargetFieldsOnUpdates","type","targetField","find","attr","name","formatAttributes","model","getVisibleAttributes","utils","map","key","formatAttribute","targetAttribute","inversedBy","mappedBy","conditions","getSchema","mapValues","uid","options","globalId","pluginOptions","kind","modelName","plugin","collectionName","info","modelType","visible","isContentTypeVisible","restrictRelationsTo","getRestrictRelationsTo","strapi","category","updateSchema","builder","createBuilder","apiHandler","getService","createContentType","createComponent","createContentTypeAttributes","reduce","acc","generateAPI","displayName","singularName","pluralName","editContentType","deleteContentType","backup","createComponentAttributes","editComponent","deleteComponent","APIsToDelete","filter","ct","writeFiles","clear","error","log","rollback","eventHub","emit","get"],"mappings":";;;;;;;;AAUA,MAAMA,+BAA+B,CAACC,MAAAA,GAAAA;AACpCA,IAAAA,MAAAA,CAAOC,UAAU,CAACC,OAAO,CAAC,CAACC,SAAAA,GAAAA;QACzB,IAAIA,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjC,YAAA;AACF,QAAA;AAEAD,QAAAA,SAAAA,CAAUE,UAAU,CAACH,OAAO,CAAC,CAACI,SAAAA,GAAAA;YAC5B,IAAIA,SAAAA,CAAUF,MAAM,KAAK,QAAA,EAAU;gBACjC,MAAM,EAAEG,UAAU,EAAE,GAAGD,SAAAA;AAEvB,gBAAA,IAAI,SAAA,IAAaC,UAAAA,IAAcA,UAAAA,CAAWC,OAAO,KAAK,EAAA,EAAI;AACxDD,oBAAAA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,GAAG,CAAClE,YAAYoB,GAAG;AACvD,aAAA,CAAA;AACF,QAAA;QAEA,IAAIpB,WAAAA,CAAYP,MAAM,KAAK,QAAA,EAAU;AACnCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,qBAAA,EAAuB;AAC1CjE,gBAAAA,WAAAA,EAAaqC,QAAQtC,YAAY,CAACmE,GAAG,CAAClE,YAAYoB,GAAG;AACvD,aAAA,CAAA;AACF,QAAA;AACF,IAAA;IAEA,KAAK,MAAM5B,aAAaF,UAAAA,CAAY;QAClC,IAAIE,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;QAEA,IAAI5B,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;QAEA,IAAI5B,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;AACF,IAAA;AACF;;;;;;"}
1
+ {"version":3,"file":"schema.js","sources":["../../../server/src/services/schema.ts"],"sourcesContent":["import utils from '@strapi/utils';\nimport { mapValues } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\n\nimport createBuilder from './schema-builder';\nimport { getService } from '../utils';\nimport type { Schema as CTBSchema } from '../controllers/validation/schema';\nimport { getRestrictRelationsTo, isContentTypeVisible } from './content-types';\n\nconst removeEmptyDefaultsOnUpdates = (schema: CTBSchema) => {\n schema.components.forEach((component) => {\n if (component.action === 'delete') {\n return;\n }\n\n component.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if ('default' in properties && properties.default === '') {\n properties.default = undefined;\n }\n }\n });\n });\n\n schema.contentTypes.forEach((contentType) => {\n if (contentType.action === 'delete') {\n return;\n }\n\n contentType.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if ('default' in properties && properties.default === '') {\n properties.default = undefined;\n }\n }\n });\n });\n};\n\nconst removeDeletedUIDTargetFieldsOnUpdates = (schema: CTBSchema) => {\n schema.contentTypes.forEach((contentType) => {\n if (contentType.action === 'delete') {\n return;\n }\n\n contentType.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if (\n properties.type === 'uid' &&\n properties.targetField &&\n !contentType.attributes.find((attr) => attr.name === properties.targetField)\n ) {\n properties.targetField = undefined;\n }\n }\n });\n });\n};\n\nconst formatAttributes = (model: any) => {\n const { getVisibleAttributes } = utils.contentTypes;\n\n // only get attributes that can be seen in the CTB\n return getVisibleAttributes(model).map((key) => {\n return { ...formatAttribute(model.attributes[key]), name: key };\n });\n};\n\nexport const formatAttribute = (attribute: Schema.Attribute.AnyAttribute & Record<string, any>) => {\n if (attribute.type === 'relation') {\n return {\n ...attribute,\n targetAttribute: attribute.inversedBy || attribute.mappedBy || null,\n // Explicitly preserve conditions if they exist\n ...(attribute.conditions && { conditions: attribute.conditions }),\n };\n }\n\n return attribute;\n};\n\nexport const getSchema = async () => {\n const contentTypes = mapValues((contentType) => {\n const {\n uid,\n options,\n globalId,\n pluginOptions,\n kind,\n modelName,\n plugin,\n collectionName,\n info,\n modelType,\n } = contentType;\n\n return {\n uid,\n modelName,\n kind,\n globalId,\n options,\n pluginOptions,\n plugin,\n collectionName,\n info,\n modelType,\n attributes: formatAttributes(contentType),\n visible: isContentTypeVisible(contentType),\n restrictRelationsTo: getRestrictRelationsTo(contentType),\n };\n }, strapi.contentTypes);\n\n const components = mapValues((component) => {\n const { uid, globalId, modelName, collectionName, info, category, modelType } = component;\n\n return {\n uid,\n modelName,\n globalId,\n modelType,\n collectionName,\n category,\n info,\n attributes: formatAttributes(component),\n };\n }, strapi.components);\n\n return {\n contentTypes,\n components,\n };\n};\n\nexport const updateSchema = async (schema: CTBSchema) => {\n const builder = createBuilder();\n const apiHandler = getService('api-handler');\n\n const { components, contentTypes } = schema;\n\n // pre-process data\n removeEmptyDefaultsOnUpdates(schema);\n removeDeletedUIDTargetFieldsOnUpdates(schema);\n\n // we pre create empty typesk\n for (const contentType of contentTypes) {\n if (contentType.action === 'create') {\n builder.createContentType({\n ...contentType,\n attributes: {},\n });\n }\n }\n\n // we pre create empty types\n for (const component of components) {\n if (component.action === 'create') {\n builder.createComponent({\n ...component,\n attributes: {},\n });\n }\n }\n\n for (const contentType of contentTypes) {\n const { action, uid } = contentType;\n\n if (action === 'create') {\n builder.createContentTypeAttributes(\n uid,\n contentType.attributes.reduce((acc: any, attr: any) => {\n acc[attr.name] = attr.properties;\n return acc;\n }, {})\n );\n\n if (!contentType.plugin) {\n await getService('content-types').generateAPI({\n displayName: contentType!.displayName,\n singularName: contentType!.singularName,\n pluralName: contentType!.pluralName,\n kind: contentType!.kind,\n });\n }\n }\n\n if (action === 'update') {\n builder.editContentType({\n ...contentType,\n attributes: contentType.attributes.reduce((acc: any, attr: any) => {\n // NOTE: handle renaming migrations here by comparing attr name & attr.properties.name\n\n if (attr.action === 'delete') {\n return acc;\n }\n\n acc[attr.name] = attr.properties;\n return acc;\n }, {}),\n });\n }\n\n if (action === 'delete') {\n builder.deleteContentType(uid);\n await apiHandler.backup(uid);\n }\n }\n\n for (const component of components) {\n const { action, uid } = component;\n\n if (action === 'create') {\n builder.createComponentAttributes(\n uid,\n component.attributes.reduce((acc: any, attr: any) => {\n acc[attr.name] = attr.properties;\n return acc;\n }, {})\n );\n }\n\n if (action === 'update') {\n builder.editComponent({\n ...component,\n attributes: component.attributes.reduce((acc: any, attr: any) => {\n if (attr.action === 'delete') {\n return acc;\n }\n\n acc[attr.name] = attr.properties;\n return acc;\n }, {}),\n });\n }\n\n if (action === 'delete') {\n builder.deleteComponent(uid);\n }\n }\n\n // run sanity checks on the schema\n // Relations target existing types\n // Bidirectional relation have their counterpart in the schema\n // Components target existing components\n // Nested components target existing components\n // Dynamic zones target existing components\n\n const APIsToDelete = contentTypes\n .filter((ct: any) => ct.action === 'delete')\n .map((ct: any) => ct.uid);\n\n await builder.writeFiles();\n\n try {\n for (const uid of APIsToDelete) {\n await apiHandler.clear(uid);\n }\n } catch (error) {\n strapi.log.error(error);\n for (const uid of APIsToDelete) {\n await apiHandler.rollback(uid);\n }\n }\n\n for (const contentType of contentTypes) {\n if (contentType.action === 'delete') {\n strapi.eventHub.emit('content-type.delete', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n\n if (contentType.action === 'update') {\n strapi.eventHub.emit('content-type.update', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n\n if (contentType.action === 'create') {\n strapi.eventHub.emit('content-type.create', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n }\n\n for (const component of components) {\n if (component.action === 'delete') {\n strapi.eventHub.emit('component.delete', {\n component: builder.components.get(component.uid),\n });\n }\n\n if (component.action === 'update') {\n strapi.eventHub.emit('component.update', {\n component: builder.components.get(component.uid),\n });\n }\n\n if (component.action === 'create') {\n strapi.eventHub.emit('component.create', {\n component: builder.components.get(component.uid),\n });\n }\n }\n};\n"],"names":["removeEmptyDefaultsOnUpdates","schema","components","forEach","component","action","attributes","attribute","properties","default","undefined","contentTypes","contentType","removeDeletedUIDTargetFieldsOnUpdates","type","targetField","find","attr","name","formatAttributes","model","getVisibleAttributes","utils","map","key","formatAttribute","targetAttribute","inversedBy","mappedBy","conditions","getSchema","mapValues","uid","options","globalId","pluginOptions","kind","modelName","plugin","collectionName","info","modelType","visible","isContentTypeVisible","restrictRelationsTo","getRestrictRelationsTo","strapi","category","updateSchema","builder","createBuilder","apiHandler","getService","createContentType","createComponent","createContentTypeAttributes","reduce","acc","generateAPI","displayName","singularName","pluralName","editContentType","deleteContentType","backup","createComponentAttributes","editComponent","deleteComponent","APIsToDelete","filter","ct","writeFiles","clear","error","log","rollback","eventHub","emit","get"],"mappings":";;;;;;;;AAUA,MAAMA,+BAA+B,CAACC,MAAAA,GAAAA;AACpCA,IAAAA,MAAAA,CAAOC,UAAU,CAACC,OAAO,CAAC,CAACC,SAAAA,GAAAA;QACzB,IAAIA,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjC,YAAA;AACF,QAAA;AAEAD,QAAAA,SAAAA,CAAUE,UAAU,CAACH,OAAO,CAAC,CAACI,SAAAA,GAAAA;YAC5B,IAAIA,SAAAA,CAAUF,MAAM,KAAK,QAAA,EAAU;gBACjC,MAAM,EAAEG,UAAU,EAAE,GAAGD,SAAAA;AAEvB,gBAAA,IAAI,SAAA,IAAaC,UAAAA,IAAcA,UAAAA,CAAWC,OAAO,KAAK,EAAA,EAAI;AACxDD,oBAAAA,UAAAA,CAAWC,OAAO,GAAGC,SAAAA;AACvB,gBAAA;AACF,YAAA;AACF,QAAA,CAAA,CAAA;AACF,IAAA,CAAA,CAAA;AAEAT,IAAAA,MAAAA,CAAOU,YAAY,CAACR,OAAO,CAAC,CAACS,WAAAA,GAAAA;QAC3B,IAAIA,WAAAA,CAAYP,MAAM,KAAK,QAAA,EAAU;AACnC,YAAA;AACF,QAAA;AAEAO,QAAAA,WAAAA,CAAYN,UAAU,CAACH,OAAO,CAAC,CAACI,SAAAA,GAAAA;YAC9B,IAAIA,SAAAA,CAAUF,MAAM,KAAK,QAAA,EAAU;gBACjC,MAAM,EAAEG,UAAU,EAAE,GAAGD,SAAAA;AAEvB,gBAAA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KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;QAEA,IAAI5B,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;QAEA,IAAI5B,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;AACF,IAAA;AACF;;;;;;"}
@@ -139,12 +139,14 @@ const updateSchema = async (schema)=>{
139
139
  acc[attr.name] = attr.properties;
140
140
  return acc;
141
141
  }, {}));
142
- await getService('content-types').generateAPI({
143
- displayName: contentType.displayName,
144
- singularName: contentType.singularName,
145
- pluralName: contentType.pluralName,
146
- kind: contentType.kind
147
- });
142
+ if (!contentType.plugin) {
143
+ await getService('content-types').generateAPI({
144
+ displayName: contentType.displayName,
145
+ singularName: contentType.singularName,
146
+ pluralName: contentType.pluralName,
147
+ kind: contentType.kind
148
+ });
149
+ }
148
150
  }
149
151
  if (action === 'update') {
150
152
  builder.editContentType({
@@ -1 +1 @@
1
- {"version":3,"file":"schema.mjs","sources":["../../../server/src/services/schema.ts"],"sourcesContent":["import utils from '@strapi/utils';\nimport { mapValues } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\n\nimport createBuilder from './schema-builder';\nimport { getService } from '../utils';\nimport type { Schema as CTBSchema } from '../controllers/validation/schema';\nimport { getRestrictRelationsTo, isContentTypeVisible } from './content-types';\n\nconst removeEmptyDefaultsOnUpdates = (schema: CTBSchema) => {\n schema.components.forEach((component) => {\n if (component.action === 'delete') {\n return;\n }\n\n component.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if ('default' in properties && properties.default === '') {\n properties.default = undefined;\n }\n }\n });\n });\n\n schema.contentTypes.forEach((contentType) => {\n if (contentType.action === 'delete') {\n return;\n }\n\n contentType.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if ('default' in properties && properties.default === '') {\n properties.default = undefined;\n }\n }\n });\n });\n};\n\nconst removeDeletedUIDTargetFieldsOnUpdates = (schema: CTBSchema) => {\n schema.contentTypes.forEach((contentType) => {\n if (contentType.action === 'delete') {\n return;\n }\n\n contentType.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if (\n properties.type === 'uid' &&\n properties.targetField &&\n !contentType.attributes.find((attr) => attr.name === properties.targetField)\n ) {\n properties.targetField = undefined;\n }\n }\n });\n });\n};\n\nconst formatAttributes = (model: any) => {\n const { getVisibleAttributes } = utils.contentTypes;\n\n // only get attributes that can be seen in the CTB\n return getVisibleAttributes(model).map((key) => {\n return { ...formatAttribute(model.attributes[key]), name: key };\n });\n};\n\nexport const formatAttribute = (attribute: Schema.Attribute.AnyAttribute & Record<string, any>) => {\n if (attribute.type === 'relation') {\n return {\n ...attribute,\n targetAttribute: attribute.inversedBy || attribute.mappedBy || null,\n // Explicitly preserve conditions if they exist\n ...(attribute.conditions && { conditions: attribute.conditions }),\n };\n }\n\n return attribute;\n};\n\nexport const getSchema = async () => {\n const contentTypes = mapValues((contentType) => {\n const {\n uid,\n options,\n globalId,\n pluginOptions,\n kind,\n modelName,\n plugin,\n collectionName,\n info,\n modelType,\n } = contentType;\n\n return {\n uid,\n modelName,\n kind,\n globalId,\n options,\n pluginOptions,\n plugin,\n collectionName,\n info,\n modelType,\n attributes: formatAttributes(contentType),\n visible: isContentTypeVisible(contentType),\n restrictRelationsTo: getRestrictRelationsTo(contentType),\n };\n }, strapi.contentTypes);\n\n const components = mapValues((component) => {\n const { uid, globalId, modelName, collectionName, info, category, modelType } = component;\n\n return {\n uid,\n modelName,\n globalId,\n modelType,\n collectionName,\n category,\n info,\n attributes: formatAttributes(component),\n };\n }, strapi.components);\n\n return {\n contentTypes,\n components,\n };\n};\n\nexport const updateSchema = async (schema: CTBSchema) => {\n const builder = createBuilder();\n const apiHandler = getService('api-handler');\n\n const { components, contentTypes } = schema;\n\n // pre-process data\n removeEmptyDefaultsOnUpdates(schema);\n removeDeletedUIDTargetFieldsOnUpdates(schema);\n\n // we pre create empty typesk\n for (const contentType of contentTypes) {\n if (contentType.action === 'create') {\n builder.createContentType({\n ...contentType,\n attributes: {},\n });\n }\n }\n\n // we pre create empty types\n for (const component of components) {\n if (component.action === 'create') {\n builder.createComponent({\n ...component,\n attributes: {},\n });\n }\n }\n\n for (const contentType of contentTypes) {\n const { action, uid } = contentType;\n\n if (action === 'create') {\n builder.createContentTypeAttributes(\n uid,\n contentType.attributes.reduce((acc: any, attr: any) => {\n acc[attr.name] = attr.properties;\n return acc;\n }, {})\n );\n\n await getService('content-types').generateAPI({\n displayName: contentType!.displayName,\n singularName: contentType!.singularName,\n pluralName: contentType!.pluralName,\n kind: contentType!.kind,\n });\n }\n\n if (action === 'update') {\n builder.editContentType({\n ...contentType,\n attributes: contentType.attributes.reduce((acc: any, attr: any) => {\n // NOTE: handle renaming migrations here by comparing attr name & attr.properties.name\n\n if (attr.action === 'delete') {\n return acc;\n }\n\n acc[attr.name] = attr.properties;\n return acc;\n }, {}),\n });\n }\n\n if (action === 'delete') {\n builder.deleteContentType(uid);\n await apiHandler.backup(uid);\n }\n }\n\n for (const component of components) {\n const { action, uid } = component;\n\n if (action === 'create') {\n builder.createComponentAttributes(\n uid,\n component.attributes.reduce((acc: any, attr: any) => {\n acc[attr.name] = attr.properties;\n return acc;\n }, {})\n );\n }\n\n if (action === 'update') {\n builder.editComponent({\n ...component,\n attributes: component.attributes.reduce((acc: any, attr: any) => {\n if (attr.action === 'delete') {\n return acc;\n }\n\n acc[attr.name] = attr.properties;\n return acc;\n }, {}),\n });\n }\n\n if (action === 'delete') {\n builder.deleteComponent(uid);\n }\n }\n\n // run sanity checks on the schema\n // Relations target existing types\n // Bidirectional relation have their counterpart in the schema\n // Components target existing components\n // Nested components target existing components\n // Dynamic zones target existing components\n\n const APIsToDelete = contentTypes\n .filter((ct: any) => ct.action === 'delete')\n .map((ct: any) => ct.uid);\n\n await builder.writeFiles();\n\n try {\n for (const uid of APIsToDelete) {\n await apiHandler.clear(uid);\n }\n } catch (error) {\n strapi.log.error(error);\n for (const uid of APIsToDelete) {\n await apiHandler.rollback(uid);\n }\n }\n\n for (const contentType of contentTypes) {\n if (contentType.action === 'delete') {\n strapi.eventHub.emit('content-type.delete', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n\n if (contentType.action === 'update') {\n strapi.eventHub.emit('content-type.update', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n\n if (contentType.action === 'create') {\n strapi.eventHub.emit('content-type.create', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n }\n\n for (const component of components) {\n if (component.action === 'delete') {\n strapi.eventHub.emit('component.delete', {\n component: builder.components.get(component.uid),\n });\n }\n\n if (component.action === 'update') {\n strapi.eventHub.emit('component.update', {\n component: builder.components.get(component.uid),\n });\n }\n\n if (component.action === 'create') {\n strapi.eventHub.emit('component.create', {\n component: builder.components.get(component.uid),\n });\n }\n }\n};\n"],"names":["removeEmptyDefaultsOnUpdates","schema","components","forEach","component","action","attributes","attribute","properties","default","undefined","contentTypes","contentType","removeDeletedUIDTargetFieldsOnUpdates","type","targetField","find","attr","name","formatAttributes","model","getVisibleAttributes","utils","map","key","formatAttribute","targetAttribute","inversedBy","mappedBy","conditions","getSchema","mapValues","uid","options","globalId","pluginOptions","kind","modelName","plugin","collectionName","info","modelType","visible","isContentTypeVisible","restrictRelationsTo","getRestrictRelationsTo","strapi","category","updateSchema","builder","createBuilder","apiHandler","getService","createContentType","createComponent","createContentTypeAttributes","reduce","acc","generateAPI","displayName","singularName","pluralName","editContentType","deleteContentType","backup","createComponentAttributes","editComponent","deleteComponent","APIsToDelete","filter","ct","writeFiles","clear","error","log","rollback","eventHub","emit","get"],"mappings":";;;;;;AAUA,MAAMA,+BAA+B,CAACC,MAAAA,GAAAA;AACpCA,IAAAA,MAAAA,CAAOC,UAAU,CAACC,OAAO,CAAC,CAACC,SAAAA,GAAAA;QACzB,IAAIA,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjC,YAAA;AACF,QAAA;AAEAD,QAAAA,SAAAA,CAAUE,UAAU,CAACH,OAAO,CAAC,CAACI,SAAAA,GAAAA;YAC5B,IAAIA,SAAAA,CAAUF,MAAM,KAAK,QAAA,EAAU;gBACjC,MAAM,EAAEG,UAAU,EAAE,GAAGD,SAAAA;AAEvB,gBAAA,IAAI,SAAA,IAAaC,UAAAA,IAAcA,UAAAA,CAAWC,OAAO,KAAK,EAAA,EAAI;AACxDD,oBAAAA,UAAAA,CAAWC,OAAO,GAAGC,SAAAA;AACvB,gBAAA;AACF,YAAA;AACF,QAAA,CAAA,CAAA;AACF,IAAA,CAAA,CAAA;AAEAT,IAAAA,MAAAA,CAAOU,YAAY,CAACR,OAAO,CAAC,CAACS,WAAAA,GAAAA;QAC3B,IAAIA,WAAAA,CAAYP,MAAM,KAAK,QAAA,EAAU;AACnC,YAAA;AACF,QAAA;AAEAO,QAAAA,WAAAA,CAAYN,UAAU,CAACH,OAAO,CAAC,CAACI,SAAAA,GAAAA;YAC9B,IAAIA,SAAAA,CAAUF,MAAM,KAAK,QAAA,EAAU;gBACjC,MAAM,EAAEG,UAAU,EAAE,GAAGD,SAAAA;AAEvB,gBAAA,IAAI,SAAA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AA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;QAEA,IAAI5B,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;QAEA,IAAI5B,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;AACF,IAAA;AACF;;;;"}
1
+ {"version":3,"file":"schema.mjs","sources":["../../../server/src/services/schema.ts"],"sourcesContent":["import utils from '@strapi/utils';\nimport { mapValues } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\n\nimport createBuilder from './schema-builder';\nimport { getService } from '../utils';\nimport type { Schema as CTBSchema } from '../controllers/validation/schema';\nimport { getRestrictRelationsTo, isContentTypeVisible } from './content-types';\n\nconst removeEmptyDefaultsOnUpdates = (schema: CTBSchema) => {\n schema.components.forEach((component) => {\n if (component.action === 'delete') {\n return;\n }\n\n component.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if ('default' in properties && properties.default === '') {\n properties.default = undefined;\n }\n }\n });\n });\n\n schema.contentTypes.forEach((contentType) => {\n if (contentType.action === 'delete') {\n return;\n }\n\n contentType.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if ('default' in properties && properties.default === '') {\n properties.default = undefined;\n }\n }\n });\n });\n};\n\nconst removeDeletedUIDTargetFieldsOnUpdates = (schema: CTBSchema) => {\n schema.contentTypes.forEach((contentType) => {\n if (contentType.action === 'delete') {\n return;\n }\n\n contentType.attributes.forEach((attribute) => {\n if (attribute.action === 'update') {\n const { properties } = attribute;\n\n if (\n properties.type === 'uid' &&\n properties.targetField &&\n !contentType.attributes.find((attr) => attr.name === properties.targetField)\n ) {\n properties.targetField = undefined;\n }\n }\n });\n });\n};\n\nconst formatAttributes = (model: any) => {\n const { getVisibleAttributes } = utils.contentTypes;\n\n // only get attributes that can be seen in the CTB\n return getVisibleAttributes(model).map((key) => {\n return { ...formatAttribute(model.attributes[key]), name: key };\n });\n};\n\nexport const formatAttribute = (attribute: Schema.Attribute.AnyAttribute & Record<string, any>) => {\n if (attribute.type === 'relation') {\n return {\n ...attribute,\n targetAttribute: attribute.inversedBy || attribute.mappedBy || null,\n // Explicitly preserve conditions if they exist\n ...(attribute.conditions && { conditions: attribute.conditions }),\n };\n }\n\n return attribute;\n};\n\nexport const getSchema = async () => {\n const contentTypes = mapValues((contentType) => {\n const {\n uid,\n options,\n globalId,\n pluginOptions,\n kind,\n modelName,\n plugin,\n collectionName,\n info,\n modelType,\n } = contentType;\n\n return {\n uid,\n modelName,\n kind,\n globalId,\n options,\n pluginOptions,\n plugin,\n collectionName,\n info,\n modelType,\n attributes: formatAttributes(contentType),\n visible: isContentTypeVisible(contentType),\n restrictRelationsTo: getRestrictRelationsTo(contentType),\n };\n }, strapi.contentTypes);\n\n const components = mapValues((component) => {\n const { uid, globalId, modelName, collectionName, info, category, modelType } = component;\n\n return {\n uid,\n modelName,\n globalId,\n modelType,\n collectionName,\n category,\n info,\n attributes: formatAttributes(component),\n };\n }, strapi.components);\n\n return {\n contentTypes,\n components,\n };\n};\n\nexport const updateSchema = async (schema: CTBSchema) => {\n const builder = createBuilder();\n const apiHandler = getService('api-handler');\n\n const { components, contentTypes } = schema;\n\n // pre-process data\n removeEmptyDefaultsOnUpdates(schema);\n removeDeletedUIDTargetFieldsOnUpdates(schema);\n\n // we pre create empty typesk\n for (const contentType of contentTypes) {\n if (contentType.action === 'create') {\n builder.createContentType({\n ...contentType,\n attributes: {},\n });\n }\n }\n\n // we pre create empty types\n for (const component of components) {\n if (component.action === 'create') {\n builder.createComponent({\n ...component,\n attributes: {},\n });\n }\n }\n\n for (const contentType of contentTypes) {\n const { action, uid } = contentType;\n\n if (action === 'create') {\n builder.createContentTypeAttributes(\n uid,\n contentType.attributes.reduce((acc: any, attr: any) => {\n acc[attr.name] = attr.properties;\n return acc;\n }, {})\n );\n\n if (!contentType.plugin) {\n await getService('content-types').generateAPI({\n displayName: contentType!.displayName,\n singularName: contentType!.singularName,\n pluralName: contentType!.pluralName,\n kind: contentType!.kind,\n });\n }\n }\n\n if (action === 'update') {\n builder.editContentType({\n ...contentType,\n attributes: contentType.attributes.reduce((acc: any, attr: any) => {\n // NOTE: handle renaming migrations here by comparing attr name & attr.properties.name\n\n if (attr.action === 'delete') {\n return acc;\n }\n\n acc[attr.name] = attr.properties;\n return acc;\n }, {}),\n });\n }\n\n if (action === 'delete') {\n builder.deleteContentType(uid);\n await apiHandler.backup(uid);\n }\n }\n\n for (const component of components) {\n const { action, uid } = component;\n\n if (action === 'create') {\n builder.createComponentAttributes(\n uid,\n component.attributes.reduce((acc: any, attr: any) => {\n acc[attr.name] = attr.properties;\n return acc;\n }, {})\n );\n }\n\n if (action === 'update') {\n builder.editComponent({\n ...component,\n attributes: component.attributes.reduce((acc: any, attr: any) => {\n if (attr.action === 'delete') {\n return acc;\n }\n\n acc[attr.name] = attr.properties;\n return acc;\n }, {}),\n });\n }\n\n if (action === 'delete') {\n builder.deleteComponent(uid);\n }\n }\n\n // run sanity checks on the schema\n // Relations target existing types\n // Bidirectional relation have their counterpart in the schema\n // Components target existing components\n // Nested components target existing components\n // Dynamic zones target existing components\n\n const APIsToDelete = contentTypes\n .filter((ct: any) => ct.action === 'delete')\n .map((ct: any) => ct.uid);\n\n await builder.writeFiles();\n\n try {\n for (const uid of APIsToDelete) {\n await apiHandler.clear(uid);\n }\n } catch (error) {\n strapi.log.error(error);\n for (const uid of APIsToDelete) {\n await apiHandler.rollback(uid);\n }\n }\n\n for (const contentType of contentTypes) {\n if (contentType.action === 'delete') {\n strapi.eventHub.emit('content-type.delete', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n\n if (contentType.action === 'update') {\n strapi.eventHub.emit('content-type.update', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n\n if (contentType.action === 'create') {\n strapi.eventHub.emit('content-type.create', {\n contentType: builder.contentTypes.get(contentType.uid),\n });\n }\n }\n\n for (const component of components) {\n if (component.action === 'delete') {\n strapi.eventHub.emit('component.delete', {\n component: builder.components.get(component.uid),\n });\n }\n\n if (component.action === 'update') {\n strapi.eventHub.emit('component.update', {\n component: builder.components.get(component.uid),\n });\n }\n\n if (component.action === 'create') {\n strapi.eventHub.emit('component.create', {\n component: builder.components.get(component.uid),\n });\n }\n }\n};\n"],"names":["removeEmptyDefaultsOnUpdates","schema","components","forEach","component","action","attributes","attribute","properties","default","undefined","contentTypes","contentType","removeDeletedUIDTargetFieldsOnUpdates","type","targetField","find","attr","name","formatAttributes","model","getVisibleAttributes","utils","map","key","formatAttribute","targetAttribute","inversedBy","mappedBy","conditions","getSchema","mapValues","uid","options","globalId","pluginOptions","kind","modelName","plugin","collectionName","info","modelType","visible","isContentTypeVisible","restrictRelationsTo","getRestrictRelationsTo","strapi","category","updateSchema","builder","createBuilder","apiHandler","getService","createContentType","createComponent","createContentTypeAttributes","reduce","acc","generateAPI","displayName","singularName","pluralName","editContentType","deleteContentType","backup","createComponentAttributes","editComponent","deleteComponent","APIsToDelete","filter","ct","writeFiles","clear","error","log","rollback","eventHub","emit","get"],"mappings":";;;;;;AAUA,MAAMA,+BAA+B,CAACC,MAAAA,GAAAA;AACpCA,IAAAA,MAAAA,CAAOC,UAAU,CAACC,OAAO,CAAC,CAACC,SAAAA,GAAAA;QACzB,IAAIA,SAAA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CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAO8B,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvCzE,gBAAAA,SAAAA,EAAW6C,QAAQ/C,UAAU,CAAC4E,GAAG,CAAC1E,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;AACF,IAAA;AACF;;;;"}
@@ -18,6 +18,7 @@ export type CreateContentTypeInput = {
18
18
  draftAndPublish?: Struct.SchemaOptions['draftAndPublish'];
19
19
  pluginOptions?: Struct.ContentTypeSchema['pluginOptions'];
20
20
  config?: object;
21
+ plugin?: string;
21
22
  };
22
23
  /**
23
24
  * Validator for content type creation
@@ -1 +1 @@
1
- {"version":3,"file":"content-type.d.ts","sourceRoot":"","sources":["../../../../../server/src/controllers/validation/content-type.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,GAAG,EAAqB,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAS3D,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACxF,UAAU,CAAC,EAAE,KAAK,CAChB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAA;KAAE,CACnE,CAAC;IACF,YAAY,EAAE,MAAM,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;IAC3D,UAAU,EAAE,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1D,IAAI,EAAE,MAAM,CAAC,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AE,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAA;KAAE,CACnE,CAAC;IACF,YAAY,EAAE,MAAM,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;IAC3D,UAAU,EAAE,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1D,IAAI,EAAE,MAAM,CAAC,eAAe,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IAC/D,UAAU,EAAE,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACvD,WAAW,EAAE,MAAM,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAkFF;;GAEG;AACH,eAAO,MAAM,wBAAwB,SAAU,sBAAsB;;;GAEpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,SAAU,sBAAsB;;;GAe1E,CAAC;AAsEF,eAAO,MAAM,YAAY,mFAAgC,CAAC"}
@@ -32895,6 +32895,7 @@ declare const createSingleTypeSchema: z.ZodObject<{
32895
32895
  options: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
32896
32896
  pluginOptions: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
32897
32897
  action: z.ZodLiteral<"create">;
32898
+ plugin: z.ZodOptional<z.ZodString>;
32898
32899
  collectionName: z.ZodOptional<z.ZodString>;
32899
32900
  singularName: z.ZodEffects<z.ZodString, string, string>;
32900
32901
  pluralName: z.ZodEffects<z.ZodString, string, string>;
@@ -44223,6 +44224,7 @@ declare const createSingleTypeSchema: z.ZodObject<{
44223
44224
  displayName: string;
44224
44225
  draftAndPublish: boolean;
44225
44226
  action: "create";
44227
+ plugin?: string | undefined;
44226
44228
  collectionName?: string | undefined;
44227
44229
  description?: string | undefined;
44228
44230
  config?: Record<string, unknown> | undefined;
@@ -44552,6 +44554,7 @@ declare const createSingleTypeSchema: z.ZodObject<{
44552
44554
  displayName: string;
44553
44555
  draftAndPublish: boolean;
44554
44556
  action: "create";
44557
+ plugin?: string | undefined;
44555
44558
  options?: Record<string, unknown> | undefined;
44556
44559
  pluginOptions?: Record<string, unknown> | undefined;
44557
44560
  collectionName?: string | undefined;
@@ -44566,6 +44569,7 @@ declare const createCollectionTypeSchema: z.ZodObject<{
44566
44569
  options: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
44567
44570
  pluginOptions: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
44568
44571
  action: z.ZodLiteral<"create">;
44572
+ plugin: z.ZodOptional<z.ZodString>;
44569
44573
  collectionName: z.ZodOptional<z.ZodString>;
44570
44574
  singularName: z.ZodEffects<z.ZodString, string, string>;
44571
44575
  pluralName: z.ZodEffects<z.ZodString, string, string>;
@@ -55894,6 +55898,7 @@ declare const createCollectionTypeSchema: z.ZodObject<{
55894
55898
  displayName: string;
55895
55899
  draftAndPublish: boolean;
55896
55900
  action: "create";
55901
+ plugin?: string | undefined;
55897
55902
  collectionName?: string | undefined;
55898
55903
  description?: string | undefined;
55899
55904
  config?: Record<string, unknown> | undefined;
@@ -56223,6 +56228,7 @@ declare const createCollectionTypeSchema: z.ZodObject<{
56223
56228
  displayName: string;
56224
56229
  draftAndPublish: boolean;
56225
56230
  action: "create";
56231
+ plugin?: string | undefined;
56226
56232
  options?: Record<string, unknown> | undefined;
56227
56233
  pluginOptions?: Record<string, unknown> | undefined;
56228
56234
  collectionName?: string | undefined;
@@ -102877,7 +102883,7 @@ export type Schema = {
102877
102883
  components: Array<CreateComponentType | UpdateComponentType | DeleteComponentType>;
102878
102884
  contentTypes: Array<CreateSingleType | CreateCollectionType | UpdateSingleType | UpdateCollectionType | DeleteContentType>;
102879
102885
  };
102880
- export declare const validateUpdateSchema: (data: unknown) => {
102886
+ export declare const validateUpdateSchema: (data: unknown, errorMessage?: string | undefined) => {
102881
102887
  data: {
102882
102888
  components: ({
102883
102889
  uid: `${string}.${string}`;
@@ -104432,6 +104438,7 @@ export declare const validateUpdateSchema: (data: unknown) => {
104432
104438
  displayName: string;
104433
104439
  draftAndPublish: boolean;
104434
104440
  action: "create";
104441
+ plugin?: string | undefined;
104435
104442
  collectionName?: string | undefined;
104436
104443
  description?: string | undefined;
104437
104444
  config?: Record<string, unknown> | undefined;
@@ -104825,6 +104832,7 @@ export declare const validateUpdateSchema: (data: unknown) => {
104825
104832
  displayName: string;
104826
104833
  draftAndPublish: boolean;
104827
104834
  action: "create";
104835
+ plugin?: string | undefined;
104828
104836
  collectionName?: string | undefined;
104829
104837
  description?: string | undefined;
104830
104838
  config?: Record<string, unknown> | undefined;