@strapi/content-type-builder 5.55.1 → 5.57.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 (152) hide show
  1. package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.js +117 -13
  2. package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.js.map +1 -1
  3. package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.mjs +118 -13
  4. package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.mjs.map +1 -1
  5. package/dist/admin/components/AIChat/providers/SchemaProvider.js +31 -19
  6. package/dist/admin/components/AIChat/providers/SchemaProvider.js.map +1 -1
  7. package/dist/admin/components/AIChat/providers/SchemaProvider.mjs +31 -19
  8. package/dist/admin/components/AIChat/providers/SchemaProvider.mjs.map +1 -1
  9. package/dist/admin/components/DataManager/DataManagerContext.js.map +1 -1
  10. package/dist/admin/components/DataManager/DataManagerContext.mjs.map +1 -1
  11. package/dist/admin/components/DataManager/DataManagerProvider.js +166 -6
  12. package/dist/admin/components/DataManager/DataManagerProvider.js.map +1 -1
  13. package/dist/admin/components/DataManager/DataManagerProvider.mjs +165 -7
  14. package/dist/admin/components/DataManager/DataManagerProvider.mjs.map +1 -1
  15. package/dist/admin/components/DataManager/RenameMigrationModal.js +285 -0
  16. package/dist/admin/components/DataManager/RenameMigrationModal.js.map +1 -0
  17. package/dist/admin/components/DataManager/RenameMigrationModal.mjs +257 -0
  18. package/dist/admin/components/DataManager/RenameMigrationModal.mjs.map +1 -0
  19. package/dist/admin/components/DataManager/reducer.js +107 -2
  20. package/dist/admin/components/DataManager/reducer.js.map +1 -1
  21. package/dist/admin/components/DataManager/reducer.mjs +106 -2
  22. package/dist/admin/components/DataManager/reducer.mjs.map +1 -1
  23. package/dist/admin/components/DataManager/utils/cleanData.js +8 -1
  24. package/dist/admin/components/DataManager/utils/cleanData.js.map +1 -1
  25. package/dist/admin/components/DataManager/utils/cleanData.mjs +8 -1
  26. package/dist/admin/components/DataManager/utils/cleanData.mjs.map +1 -1
  27. package/dist/admin/components/DataManager/utils/groupRenameChains.js +86 -0
  28. package/dist/admin/components/DataManager/utils/groupRenameChains.js.map +1 -0
  29. package/dist/admin/components/DataManager/utils/groupRenameChains.mjs +84 -0
  30. package/dist/admin/components/DataManager/utils/groupRenameChains.mjs.map +1 -0
  31. package/dist/admin/components/DataManager/utils/isStorageCompatibleRename.js +29 -0
  32. package/dist/admin/components/DataManager/utils/isStorageCompatibleRename.js.map +1 -0
  33. package/dist/admin/components/DataManager/utils/isStorageCompatibleRename.mjs +27 -0
  34. package/dist/admin/components/DataManager/utils/isStorageCompatibleRename.mjs.map +1 -0
  35. package/dist/admin/components/DataManager/utils/resolveAfterEditRenameConsent.js +35 -0
  36. package/dist/admin/components/DataManager/utils/resolveAfterEditRenameConsent.js.map +1 -0
  37. package/dist/admin/components/DataManager/utils/resolveAfterEditRenameConsent.mjs +33 -0
  38. package/dist/admin/components/DataManager/utils/resolveAfterEditRenameConsent.mjs.map +1 -0
  39. package/dist/admin/components/DataManager/utils/splitChainsByInheritedConsent.js +48 -0
  40. package/dist/admin/components/DataManager/utils/splitChainsByInheritedConsent.js.map +1 -0
  41. package/dist/admin/components/DataManager/utils/splitChainsByInheritedConsent.mjs +45 -0
  42. package/dist/admin/components/DataManager/utils/splitChainsByInheritedConsent.mjs.map +1 -0
  43. package/dist/admin/components/FormModal/FormModal.js +143 -9
  44. package/dist/admin/components/FormModal/FormModal.js.map +1 -1
  45. package/dist/admin/components/FormModal/FormModal.mjs +144 -10
  46. package/dist/admin/components/FormModal/FormModal.mjs.map +1 -1
  47. package/dist/admin/components/FormModal/attributes/validation/common.js +6 -5
  48. package/dist/admin/components/FormModal/attributes/validation/common.js.map +1 -1
  49. package/dist/admin/components/FormModal/attributes/validation/common.mjs +1 -1
  50. package/dist/admin/components/FormModal/attributes/validation/common.mjs.map +1 -1
  51. package/dist/admin/components/FormModal/component/createComponentSchema.js +10 -7
  52. package/dist/admin/components/FormModal/component/createComponentSchema.js.map +1 -1
  53. package/dist/admin/components/FormModal/component/createComponentSchema.mjs +1 -1
  54. package/dist/admin/components/FormModal/component/createComponentSchema.mjs.map +1 -1
  55. package/dist/admin/components/FormModal/contentType/createContentTypeSchema.js +24 -21
  56. package/dist/admin/components/FormModal/contentType/createContentTypeSchema.js.map +1 -1
  57. package/dist/admin/components/FormModal/contentType/createContentTypeSchema.mjs +1 -1
  58. package/dist/admin/components/FormModal/contentType/createContentTypeSchema.mjs.map +1 -1
  59. package/dist/admin/components/FormModal/forms/utils/createCollectionName.js +3 -2
  60. package/dist/admin/components/FormModal/forms/utils/createCollectionName.js.map +1 -1
  61. package/dist/admin/components/FormModal/forms/utils/createCollectionName.mjs +1 -1
  62. package/dist/admin/components/FormModal/forms/utils/createCollectionName.mjs.map +1 -1
  63. package/dist/admin/components/FormModal/utils/getRenameStorageChange.js +73 -0
  64. package/dist/admin/components/FormModal/utils/getRenameStorageChange.js.map +1 -0
  65. package/dist/admin/components/FormModal/utils/getRenameStorageChange.mjs +70 -0
  66. package/dist/admin/components/FormModal/utils/getRenameStorageChange.mjs.map +1 -0
  67. package/dist/admin/src/components/AIChat/components/AnimatedBox.d.ts +2 -2
  68. package/dist/admin/src/components/AIChat/components/Input.d.ts +2 -2
  69. package/dist/admin/src/components/AIChat/lib/transforms/schemas/toCTB.d.ts +4 -3
  70. package/dist/admin/src/components/AIChat/lib/types/schema.d.ts +6 -1
  71. package/dist/admin/src/components/AttributeOptions/OptionBoxWrapper.d.ts +2 -2
  72. package/dist/admin/src/components/ComponentRow.d.ts +2 -2
  73. package/dist/admin/src/components/DataManager/DataManagerContext.d.ts +28 -2
  74. package/dist/admin/src/components/DataManager/RenameMigrationModal.d.ts +73 -0
  75. package/dist/admin/src/components/DataManager/reducer.d.ts +17 -2
  76. package/dist/admin/src/components/DataManager/utils/cleanData.d.ts +16 -0
  77. package/dist/admin/src/components/DataManager/utils/groupRenameChains.d.ts +31 -0
  78. package/dist/admin/src/components/DataManager/utils/isStorageCompatibleRename.d.ts +10 -0
  79. package/dist/admin/src/components/DataManager/utils/resolveAfterEditRenameConsent.d.ts +24 -0
  80. package/dist/admin/src/components/DataManager/utils/splitChainsByInheritedConsent.d.ts +26 -0
  81. package/dist/admin/src/components/FormModal/utils/getRenameStorageChange.d.ts +40 -0
  82. package/dist/admin/src/components/List.d.ts +2 -2
  83. package/dist/admin/src/components/Relation/RelationNaturePicker/Components.d.ts +4 -4
  84. package/dist/admin/src/types.d.ts +23 -0
  85. package/dist/admin/translations/en.json.js +12 -0
  86. package/dist/admin/translations/en.json.js.map +1 -1
  87. package/dist/admin/translations/en.json.mjs +12 -0
  88. package/dist/admin/translations/en.json.mjs.map +1 -1
  89. package/dist/server/config.js +24 -3
  90. package/dist/server/config.js.map +1 -1
  91. package/dist/server/config.mjs +21 -3
  92. package/dist/server/config.mjs.map +1 -1
  93. package/dist/server/controllers/schema.js +2 -2
  94. package/dist/server/controllers/schema.js.map +1 -1
  95. package/dist/server/controllers/schema.mjs +1 -1
  96. package/dist/server/controllers/schema.mjs.map +1 -1
  97. package/dist/server/controllers/validation/content-type.js +9 -11
  98. package/dist/server/controllers/validation/content-type.js.map +1 -1
  99. package/dist/server/controllers/validation/content-type.mjs +7 -9
  100. package/dist/server/controllers/validation/content-type.mjs.map +1 -1
  101. package/dist/server/controllers/validation/model-schema.js +2 -3
  102. package/dist/server/controllers/validation/model-schema.js.map +1 -1
  103. package/dist/server/controllers/validation/model-schema.mjs +1 -2
  104. package/dist/server/controllers/validation/model-schema.mjs.map +1 -1
  105. package/dist/server/controllers/validation/relations.js +1 -2
  106. package/dist/server/controllers/validation/relations.js.map +1 -1
  107. package/dist/server/controllers/validation/relations.mjs +1 -2
  108. package/dist/server/controllers/validation/relations.mjs.map +1 -1
  109. package/dist/server/controllers/validation/schema.js +42 -23
  110. package/dist/server/controllers/validation/schema.js.map +1 -1
  111. package/dist/server/controllers/validation/schema.mjs +43 -24
  112. package/dist/server/controllers/validation/schema.mjs.map +1 -1
  113. package/dist/server/index.js +1 -1
  114. package/dist/server/index.js.map +1 -1
  115. package/dist/server/services/content-types.js +1 -2
  116. package/dist/server/services/content-types.js.map +1 -1
  117. package/dist/server/services/content-types.mjs +2 -3
  118. package/dist/server/services/content-types.mjs.map +1 -1
  119. package/dist/server/services/migration-builder/index.js +580 -0
  120. package/dist/server/services/migration-builder/index.js.map +1 -0
  121. package/dist/server/services/migration-builder/index.mjs +573 -0
  122. package/dist/server/services/migration-builder/index.mjs.map +1 -0
  123. package/dist/server/services/schema-builder/content-type-builder.js +31 -1
  124. package/dist/server/services/schema-builder/content-type-builder.js.map +1 -1
  125. package/dist/server/services/schema-builder/content-type-builder.mjs +31 -1
  126. package/dist/server/services/schema-builder/content-type-builder.mjs.map +1 -1
  127. package/dist/server/services/schema-mutation.js +30 -2
  128. package/dist/server/services/schema-mutation.js.map +1 -1
  129. package/dist/server/services/schema-mutation.mjs +10 -2
  130. package/dist/server/services/schema-mutation.mjs.map +1 -1
  131. package/dist/server/services/schema.js +259 -15
  132. package/dist/server/services/schema.js.map +1 -1
  133. package/dist/server/services/schema.mjs +252 -9
  134. package/dist/server/services/schema.mjs.map +1 -1
  135. package/dist/server/src/config.d.ts +23 -2
  136. package/dist/server/src/config.d.ts.map +1 -1
  137. package/dist/server/src/controllers/validation/content-type.d.ts +0 -1
  138. package/dist/server/src/controllers/validation/content-type.d.ts.map +1 -1
  139. package/dist/server/src/controllers/validation/relations.d.ts.map +1 -1
  140. package/dist/server/src/controllers/validation/schema.d.ts +28 -0
  141. package/dist/server/src/controllers/validation/schema.d.ts.map +1 -1
  142. package/dist/server/src/index.d.ts +10 -2
  143. package/dist/server/src/index.d.ts.map +1 -1
  144. package/dist/server/src/services/content-types.d.ts.map +1 -1
  145. package/dist/server/src/services/migration-builder/index.d.ts +83 -0
  146. package/dist/server/src/services/migration-builder/index.d.ts.map +1 -0
  147. package/dist/server/src/services/schema-builder/content-type-builder.d.ts.map +1 -1
  148. package/dist/server/src/services/schema-mutation.d.ts +4 -2
  149. package/dist/server/src/services/schema-mutation.d.ts.map +1 -1
  150. package/dist/server/src/services/schema.d.ts +19 -0
  151. package/dist/server/src/services/schema.d.ts.map +1 -1
  152. package/package.json +11 -10
@@ -1,3 +1,5 @@
1
+ import * as fse from 'fs-extra';
2
+
1
3
  const finalizeSchemaMutation = async ({ apiHandler, backedUpApiUids = [] })=>{
2
4
  const errors = [];
3
5
  for (const uid of backedUpApiUids){
@@ -10,10 +12,11 @@ const finalizeSchemaMutation = async ({ apiHandler, backedUpApiUids = [] })=>{
10
12
  return errors;
11
13
  };
12
14
  /**
13
- * Restores the filesystem artifacts touched before content-structure reconciliation.
15
+ * Restores the filesystem artifacts touched before content-structure reconciliation: the
16
+ * generated rename migration, generated APIs, the schema files and API backups.
14
17
  * Folder reconciliation is deliberately the final mutation, so groups.json never needs a
15
18
  * compensating write when an earlier schema or API operation fails.
16
- */ const rollbackSchemaMutation = async ({ builder, apiHandler, backedUpApiUids = [], generatedApiNames = [], schemaAlreadyRolledBack = false })=>{
19
+ */ const rollbackSchemaMutation = async ({ builder, apiHandler, backedUpApiUids = [], generatedApiNames = [], schemaAlreadyRolledBack = false, migrationFilePath = null })=>{
17
20
  const errors = [];
18
21
  const attempt = async (operation)=>{
19
22
  try {
@@ -22,6 +25,11 @@ const finalizeSchemaMutation = async ({ apiHandler, backedUpApiUids = [] })=>{
22
25
  errors.push(error);
23
26
  }
24
27
  };
28
+ // The rename migration is written before the schema files. Remove it first so a rejected
29
+ // save never leaves a migration that would rename columns on the next boot.
30
+ if (migrationFilePath) {
31
+ await attempt(()=>fse.remove(migrationFilePath));
32
+ }
25
33
  // A generator can fail before a schema directory exists, so remove its partial API before
26
34
  // asking the schema handler to roll back. Every action is attempted even if an earlier one
27
35
  // fails, ensuring compensation is best-effort rather than short-circuiting.
@@ -1 +1 @@
1
- {"version":3,"file":"schema-mutation.mjs","sources":["../../../server/src/services/schema-mutation.ts"],"sourcesContent":["type SchemaBuilder = {\n rollback(): Promise<unknown>;\n};\n\ntype ApiHandler = {\n rollback(uid: string): Promise<void>;\n clearGenerated(apiName: string): Promise<void>;\n finalize(uid: string): Promise<void>;\n};\n\nexport const finalizeSchemaMutation = async ({\n apiHandler,\n backedUpApiUids = [],\n}: {\n apiHandler: ApiHandler;\n backedUpApiUids?: string[];\n}) => {\n const errors: unknown[] = [];\n\n for (const uid of backedUpApiUids) {\n try {\n await apiHandler.finalize(uid);\n } catch (error) {\n errors.push(error);\n }\n }\n\n return errors;\n};\n\n/**\n * Restores the filesystem artifacts touched before content-structure reconciliation.\n * Folder reconciliation is deliberately the final mutation, so groups.json never needs a\n * compensating write when an earlier schema or API operation fails.\n */\nexport const rollbackSchemaMutation = async ({\n builder,\n apiHandler,\n backedUpApiUids = [],\n generatedApiNames = [],\n schemaAlreadyRolledBack = false,\n}: {\n builder: SchemaBuilder;\n apiHandler: ApiHandler;\n backedUpApiUids?: string[];\n generatedApiNames?: string[];\n schemaAlreadyRolledBack?: boolean;\n}) => {\n const errors: unknown[] = [];\n const attempt = async (operation: () => Promise<unknown>) => {\n try {\n await operation();\n } catch (error) {\n errors.push(error);\n }\n };\n\n // A generator can fail before a schema directory exists, so remove its partial API before\n // asking the schema handler to roll back. Every action is attempted even if an earlier one\n // fails, ensuring compensation is best-effort rather than short-circuiting.\n for (const apiName of generatedApiNames) {\n await attempt(() => apiHandler.clearGenerated(apiName));\n }\n\n if (!schemaAlreadyRolledBack) {\n await attempt(() => builder.rollback());\n }\n\n for (const uid of backedUpApiUids) {\n await attempt(() => apiHandler.rollback(uid));\n }\n\n if (errors.length > 0) {\n throw errors[0];\n }\n};\n"],"names":["finalizeSchemaMutation","apiHandler","backedUpApiUids","errors","uid","finalize","error","push","rollbackSchemaMutation","builder","generatedApiNames","schemaAlreadyRolledBack","attempt","operation","apiName","clearGenerated","rollback","length"],"mappings":"AAUO,MAAMA,yBAAyB,OAAO,EAC3CC,UAAU,EACVC,eAAAA,GAAkB,EAAE,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;AACF;;;;"}
1
+ {"version":3,"file":"schema-mutation.mjs","sources":["../../../server/src/services/schema-mutation.ts"],"sourcesContent":["import * as fse from 'fs-extra';\n\ntype SchemaBuilder = {\n rollback(): Promise<unknown>;\n};\n\ntype ApiHandler = {\n rollback(uid: string): Promise<void>;\n clearGenerated(apiName: string): Promise<void>;\n finalize(uid: string): Promise<void>;\n};\n\nexport const finalizeSchemaMutation = async ({\n apiHandler,\n backedUpApiUids = [],\n}: {\n apiHandler: ApiHandler;\n backedUpApiUids?: string[];\n}) => {\n const errors: unknown[] = [];\n\n for (const uid of backedUpApiUids) {\n try {\n await apiHandler.finalize(uid);\n } catch (error) {\n errors.push(error);\n }\n }\n\n return errors;\n};\n\n/**\n * Restores the filesystem artifacts touched before content-structure reconciliation: the\n * generated rename migration, generated APIs, the schema files and API backups.\n * Folder reconciliation is deliberately the final mutation, so groups.json never needs a\n * compensating write when an earlier schema or API operation fails.\n */\nexport const rollbackSchemaMutation = async ({\n builder,\n apiHandler,\n backedUpApiUids = [],\n generatedApiNames = [],\n schemaAlreadyRolledBack = false,\n migrationFilePath = null,\n}: {\n builder: SchemaBuilder;\n apiHandler: ApiHandler;\n backedUpApiUids?: string[];\n generatedApiNames?: string[];\n schemaAlreadyRolledBack?: boolean;\n migrationFilePath?: string | null;\n}) => {\n const errors: unknown[] = [];\n const attempt = async (operation: () => Promise<unknown>) => {\n try {\n await operation();\n } catch (error) {\n errors.push(error);\n }\n };\n\n // The rename migration is written before the schema files. Remove it first so a rejected\n // save never leaves a migration that would rename columns on the next boot.\n if (migrationFilePath) {\n await attempt(() => fse.remove(migrationFilePath));\n }\n\n // A generator can fail before a schema directory exists, so remove its partial API before\n // asking the schema handler to roll back. Every action is attempted even if an earlier one\n // fails, ensuring compensation is best-effort rather than short-circuiting.\n for (const apiName of generatedApiNames) {\n await attempt(() => apiHandler.clearGenerated(apiName));\n }\n\n if (!schemaAlreadyRolledBack) {\n await attempt(() => builder.rollback());\n }\n\n for (const uid of backedUpApiUids) {\n await attempt(() => apiHandler.rollback(uid));\n }\n\n if (errors.length > 0) {\n throw errors[0];\n }\n};\n"],"names":["finalizeSchemaMutation","apiHandler","backedUpApiUids","errors","uid","finalize","error","push","rollbackSchemaMutation","builder","generatedApiNames","schemaAlreadyRolledBack","migrationFilePath","attempt","operation","fse","remove","apiName","clearGenerated","rollback","length"],"mappings":";;AAYO,MAAMA,yBAAyB,OAAO,EAC3CC,UAAU,EACVC,eAAAA,GAAkB,EAAE,EAIrB,GAAA;AACC,IAAA,MAAMC,SAAoB,EAAE;IAE5B,KAAK,MAAMC,OAAOF,eAAAA,CAAiB;QACjC,IAAI;YACF,MAAMD,UAAAA,CAAWI,QAAQ,CAACD,GAAAA,CAAAA;AAC5B,QAAA,CAAA,CAAE,OAAOE,KAAAA,EAAO;AACdH,YAAAA,MAAAA,CAAOI,IAAI,CAACD,KAAAA,CAAAA;AACd,QAAA;AACF,IAAA;IAEA,OAAOH,MAAAA;AACT;AAEA;;;;;UAMaK,sBAAAA,GAAyB,OAAO,EAC3CC,OAAO,EACPR,UAAU,EACVC,eAAAA,GAAkB,EAAE,EACpBQ,iBAAAA,GAAoB,EAAE,EACtBC,uBAAAA,GAA0B,KAAK,EAC/BC,iBAAAA,GAAoB,IAAI,EAQzB,GAAA;AACC,IAAA,MAAMT,SAAoB,EAAE;AAC5B,IAAA,MAAMU,UAAU,OAAOC,SAAAA,GAAAA;QACrB,IAAI;YACF,MAAMA,SAAAA,EAAAA;AACR,QAAA,CAAA,CAAE,OAAOR,KAAAA,EAAO;AACdH,YAAAA,MAAAA,CAAOI,IAAI,CAACD,KAAAA,CAAAA;AACd,QAAA;AACF,IAAA,CAAA;;;AAIA,IAAA,IAAIM,iBAAAA,EAAmB;AACrB,QAAA,MAAMC,OAAAA,CAAQ,IAAME,GAAAA,CAAIC,MAAM,CAACJ,iBAAAA,CAAAA,CAAAA;AACjC,IAAA;;;;IAKA,KAAK,MAAMK,WAAWP,iBAAAA,CAAmB;AACvC,QAAA,MAAMG,OAAAA,CAAQ,IAAMZ,UAAAA,CAAWiB,cAAc,CAACD,OAAAA,CAAAA,CAAAA;AAChD,IAAA;AAEA,IAAA,IAAI,CAACN,uBAAAA,EAAyB;QAC5B,MAAME,OAAAA,CAAQ,IAAMJ,OAAAA,CAAQU,QAAQ,EAAA,CAAA;AACtC,IAAA;IAEA,KAAK,MAAMf,OAAOF,eAAAA,CAAiB;AACjC,QAAA,MAAMW,OAAAA,CAAQ,IAAMZ,UAAAA,CAAWkB,QAAQ,CAACf,GAAAA,CAAAA,CAAAA;AAC1C,IAAA;IAEA,IAAID,MAAAA,CAAOiB,MAAM,GAAG,CAAA,EAAG;QACrB,MAAMjB,MAAM,CAAC,CAAA,CAAE;AACjB,IAAA;AACF;;;;"}
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@strapi/utils');
4
- var fp = require('lodash/fp');
5
- var index = require('./schema-builder/index.js');
4
+ var _ = require('lodash');
5
+ var index$1 = require('./schema-builder/index.js');
6
+ var index = require('./migration-builder/index.js');
6
7
  var schemaMutation = require('./schema-mutation.js');
7
- var index$1 = require('../utils/index.js');
8
+ var index$2 = require('../utils/index.js');
9
+ var schema = require('../controllers/validation/schema.js');
8
10
  var contentTypes = require('./content-types.js');
9
11
 
10
12
  const removeEmptyDefaultsOnUpdates = (schema)=>{
@@ -50,6 +52,238 @@ const removeDeletedUIDTargetFieldsOnUpdates = (schema)=>{
50
52
  });
51
53
  });
52
54
  };
55
+ const getAttributeRenameMigrationMode = ()=>{
56
+ return strapi.plugin('content-type-builder').config('renameMigrations.attributes', 'prompt-before-save');
57
+ };
58
+ /**
59
+ * Collects attribute renames from the update-schema payload. The admin sends an
60
+ * ordered `renames` array per updated content-type / component: the exact path
61
+ * of rename hops the user performed (e.g. `a -> tmp`, `b -> a`, `tmp -> b` for a
62
+ * swap). Order is preserved so the generated migration can replay each hop
63
+ * verbatim — which is inherently collision-free because the Content-Type Builder
64
+ * never allows two fields to share a name at any instant.
65
+ */ const collectRenames = (schema)=>{
66
+ const renames = [];
67
+ const collectFrom = (entries)=>{
68
+ entries.filter((entry)=>entry.action === 'update' && Array.isArray(entry.renames)).forEach((entry)=>{
69
+ // Only the last hop onto a name produces the field that carries the
70
+ // final definition: in `a -> b, b -> c, x -> b` the first `b` is `a`'s
71
+ // intermediate name and the final `b` is `x`'s field.
72
+ const lastHopByNewName = new Map();
73
+ entry.renames.forEach((hop, index)=>{
74
+ if (hop.newName) {
75
+ lastHopByNewName.set(hop.newName, index);
76
+ }
77
+ });
78
+ entry.renames.forEach((hop, index)=>{
79
+ if (hop.oldName && hop.newName && hop.oldName !== hop.newName) {
80
+ // The definition the field ends up with in this save, so the builder
81
+ // can refuse hops that also change the field's storage (type,
82
+ // relation target, component…). Intermediate hops of a chain get no
83
+ // definition and are checked when the chain completes.
84
+ const newAttribute = lastHopByNewName.get(hop.newName) === index ? entry.attributes?.find((attribute)=>attribute.action !== 'delete' && attribute.name === hop.newName)?.properties : undefined;
85
+ renames.push({
86
+ uid: entry.uid,
87
+ oldName: hop.oldName,
88
+ newName: hop.newName,
89
+ newAttribute
90
+ });
91
+ }
92
+ });
93
+ });
94
+ };
95
+ collectFrom(schema.contentTypes);
96
+ collectFrom(schema.components);
97
+ return renames;
98
+ };
99
+ /**
100
+ * Drops renames whose final name is not an attribute after this save (it was
101
+ * deleted in the same save), so no store is pointed at a field that is gone.
102
+ */ const keepSavedAttributes = (schema, mapping)=>{
103
+ const entries = [
104
+ ...schema.contentTypes,
105
+ ...schema.components
106
+ ];
107
+ const result = {};
108
+ for (const [uid, renames] of Object.entries(mapping)){
109
+ const entry = entries.find((candidate)=>candidate.uid === uid);
110
+ const saved = new Set((entry?.attributes ?? []).filter((attribute)=>attribute.action !== 'delete' && attribute.name).map((attribute)=>attribute.name));
111
+ for (const [origin, final] of Object.entries(renames)){
112
+ if (saved.has(final)) {
113
+ var _result, _uid;
114
+ (_result = result)[_uid = uid] ?? (_result[_uid] = {});
115
+ result[uid][origin] = final;
116
+ }
117
+ }
118
+ }
119
+ return result;
120
+ };
121
+ const describeUnsupportedReason = (reason)=>{
122
+ switch(reason){
123
+ case 'type-changed':
124
+ return 'the field type, relation or component also changed';
125
+ case 'unsupported-type':
126
+ return 'the field type cannot be migrated (e.g. polymorphic relation)';
127
+ case 'attribute-not-found':
128
+ return 'the field is not in the current schema';
129
+ case 'target-occupied':
130
+ return 'the target field still exists in the current schema';
131
+ case 'model-not-found':
132
+ default:
133
+ return 'the type is not in the current schema';
134
+ }
135
+ };
136
+ /**
137
+ * Generates a single data-preserving rename migration for the accepted renames
138
+ * in this save. Must run before the server reloads, while `strapi.db.metadata`
139
+ * still reflects the old (pre-rename) schema. Resolves to the written file's
140
+ * path (so a failed save can remove it), or `null` when nothing was written.
141
+ */ const generateRenameMigrations = async (schema)=>{
142
+ // In prompt modes the admin strips refused renames before sending the payload.
143
+ if (getAttributeRenameMigrationMode() === 'never') {
144
+ return null;
145
+ }
146
+ const renames = collectRenames(schema);
147
+ if (renames.length === 0) {
148
+ return null;
149
+ }
150
+ const migrationBuilder = index.createMigrationBuilder({
151
+ strapi
152
+ });
153
+ for (const { uid, oldName, newName, newAttribute } of renames){
154
+ migrationBuilder.addRenameAttribute(uid, {
155
+ oldName,
156
+ newName,
157
+ newAttribute
158
+ });
159
+ }
160
+ const attributeRenames = keepSavedAttributes(schema, migrationBuilder.attributeRenamesMapping());
161
+ if (Object.keys(attributeRenames).length > 0) {
162
+ migrationBuilder.addAttributeRenames(attributeRenames);
163
+ }
164
+ const unsupported = migrationBuilder.getUnsupported();
165
+ if (unsupported.length > 0) {
166
+ const fields = unsupported.map((u)=>`${u.uid}.${u.oldName} (${describeUnsupportedReason(u.reason)})`).join(', ');
167
+ strapi.log.warn(`[content-type-builder] Could not generate a rename migration for ${unsupported.length} field(s): ${fields}. Data in these fields may not be preserved.`);
168
+ }
169
+ if (migrationBuilder.hasChanges()) {
170
+ return migrationBuilder.writeFiles();
171
+ }
172
+ return null;
173
+ };
174
+ /**
175
+ * Renames a single attribute on a content-type or component and generates the
176
+ * data-preserving migration in one step. Used by the `strapi rename:field` CLI
177
+ * command so scripted / non-UI workflows get the same behaviour as the admin.
178
+ *
179
+ * It reuses the regular `updateSchema` path (and therefore the same rename
180
+ * resolver via `generateRenameMigrations`), so the migration is resolved against
181
+ * the pre-reload `strapi.db.metadata` exactly like the admin save. The caller is
182
+ * responsible for not reloading before this resolves (the CLI simply exits).
183
+ *
184
+ * Unlike the admin, there is no one to confirm a data-losing rename, so it
185
+ * refuses before touching the schema when the rename cannot be migrated.
186
+ */ const renameAttribute = async (uid, oldName, newName)=>{
187
+ const { ApplicationError } = utils.errors;
188
+ if (!oldName || !newName) {
189
+ throw new ApplicationError('Both an old and a new attribute name are required');
190
+ }
191
+ if (oldName === newName) {
192
+ throw new ApplicationError(`Cannot rename "${oldName}" to itself`);
193
+ }
194
+ if (getAttributeRenameMigrationMode() === 'never') {
195
+ throw new ApplicationError('Rename migrations are disabled (`renameMigrations.attributes: never`); rename the field in the Content-Type Builder instead');
196
+ }
197
+ const contentType = strapi.contentTypes[uid];
198
+ const component = strapi.components[uid];
199
+ const model = contentType ?? component;
200
+ if (!model) {
201
+ throw new ApplicationError(`No content-type or component found for uid "${uid}"`);
202
+ }
203
+ if (!model.attributes?.[oldName]) {
204
+ throw new ApplicationError(`Attribute "${oldName}" does not exist on "${uid}"`);
205
+ }
206
+ if (model.attributes?.[newName]) {
207
+ throw new ApplicationError(`Attribute "${newName}" already exists on "${uid}"`);
208
+ }
209
+ // Reuse the formatted, CTB-visible attributes (same shape the admin sends) so
210
+ // the schema edit matches an admin save and the renamed key is the only change.
211
+ const formattedSchema = await getSchema();
212
+ const isComponent = Boolean(component);
213
+ const entry = isComponent ? formattedSchema.components[uid] : formattedSchema.contentTypes[uid];
214
+ // Custom fields are exposed with their underlying type; the admin sends them
215
+ // back as `customField` so the schema file keeps them as custom fields.
216
+ const toPayloadProperties = (properties)=>properties.customField ? {
217
+ ...properties,
218
+ type: 'customField'
219
+ } : properties;
220
+ const attributes = entry.attributes.map(({ name, ...properties })=>({
221
+ action: 'update',
222
+ name: name === oldName ? newName : name,
223
+ properties: toPayloadProperties(properties)
224
+ }));
225
+ // Dry run: the field keeps its definition, so only the rename itself can be
226
+ // refused (system attribute, unsupported relation, occupied target…).
227
+ const { name: _name, ...oldProperties } = entry.attributes.find((attribute)=>attribute.name === oldName) ?? {
228
+ name: oldName
229
+ };
230
+ const probe = index.createMigrationBuilder({
231
+ strapi
232
+ });
233
+ probe.addRenameAttribute(uid, {
234
+ oldName,
235
+ newName,
236
+ newAttribute: toPayloadProperties(oldProperties)
237
+ });
238
+ const refused = probe.getUnsupported();
239
+ if (refused.length > 0) {
240
+ throw new ApplicationError(`Cannot rename "${oldName}" on "${uid}" without losing its data: ${refused.map(({ reason })=>describeUnsupportedReason(reason)).join(', ')}`);
241
+ }
242
+ const renames = [
243
+ {
244
+ oldName,
245
+ newName
246
+ }
247
+ ];
248
+ const payload = isComponent ? {
249
+ contentTypes: [],
250
+ components: [
251
+ {
252
+ action: 'update',
253
+ uid,
254
+ category: model.category,
255
+ displayName: model.info?.displayName,
256
+ icon: model.info?.icon,
257
+ description: model.info?.description,
258
+ pluginOptions: model.pluginOptions,
259
+ renames,
260
+ attributes
261
+ }
262
+ ]
263
+ } : {
264
+ contentTypes: [
265
+ {
266
+ action: 'update',
267
+ uid,
268
+ kind: model.kind,
269
+ displayName: model.info?.displayName,
270
+ description: model.info?.description,
271
+ draftAndPublish: Boolean(model.options?.draftAndPublish),
272
+ options: model.options,
273
+ pluginOptions: model.pluginOptions,
274
+ renames,
275
+ attributes
276
+ }
277
+ ],
278
+ components: []
279
+ };
280
+ // Same checks as an admin save (name rules, reserved names, snake-case
281
+ // uniqueness: `fooBar` next to an existing `foo_bar` would share a column).
282
+ const { data } = await schema.validateUpdateSchema({
283
+ data: payload
284
+ });
285
+ await updateSchema(data);
286
+ };
53
287
  const formatAttributes = (model)=>{
54
288
  const { getVisibleAttributes } = utils.contentTypes;
55
289
  // only get attributes that can be seen in the CTB
@@ -74,7 +308,7 @@ const formatAttribute = (attribute)=>{
74
308
  return attribute;
75
309
  };
76
310
  const getSchema = async ()=>{
77
- const contentTypes$1 = fp.mapValues((contentType)=>{
311
+ const contentTypes$1 = _.mapValues(strapi.contentTypes, (contentType)=>{
78
312
  const { uid, options, globalId, pluginOptions, kind, modelName, plugin, collectionName, info, modelType } = contentType;
79
313
  return {
80
314
  uid,
@@ -91,8 +325,8 @@ const getSchema = async ()=>{
91
325
  visible: contentTypes.isContentTypeVisible(contentType),
92
326
  restrictRelationsTo: contentTypes.getRestrictRelationsTo(contentType)
93
327
  };
94
- }, strapi.contentTypes);
95
- const components = fp.mapValues((component)=>{
328
+ });
329
+ const components = _.mapValues(strapi.components, (component)=>{
96
330
  const { uid, globalId, modelName, collectionName, info, category, modelType } = component;
97
331
  return {
98
332
  uid,
@@ -104,18 +338,23 @@ const getSchema = async ()=>{
104
338
  info,
105
339
  attributes: formatAttributes(component)
106
340
  };
107
- }, strapi.components);
341
+ });
108
342
  const coreContentStructure = strapi.get('content-structure');
109
343
  const contentStructure = await coreContentStructure.getCleanedFile();
110
344
  return {
111
345
  contentStructure,
112
346
  contentTypes: contentTypes$1,
113
- components
347
+ components,
348
+ settings: {
349
+ renameMigrations: {
350
+ attributes: getAttributeRenameMigrationMode()
351
+ }
352
+ }
114
353
  };
115
354
  };
116
355
  const updateSchema = async (schema)=>{
117
- const builder = index();
118
- const apiHandler = index$1.getService('api-handler');
356
+ const builder = index$1();
357
+ const apiHandler = index$2.getService('api-handler');
119
358
  const { components, contentTypes: contentTypes$1, contentStructure } = schema;
120
359
  // Reject protected/plugin deletes before builders, API backups, or folder reconciliation can
121
360
  // mutate anything. This is the server-side invariant for crafted update requests.
@@ -128,6 +367,7 @@ const updateSchema = async (schema)=>{
128
367
  const generatedApiNames = [];
129
368
  const backedUpApiUids = [];
130
369
  let schemaAlreadyRolledBack = false;
370
+ let migrationFilePath = null;
131
371
  const APIsToDelete = contentTypes$1.filter((contentType)=>contentType.action === 'delete').map((contentType)=>contentType.uid);
132
372
  try {
133
373
  for (const contentType of contentTypes$1){
@@ -142,7 +382,7 @@ const updateSchema = async (schema)=>{
142
382
  }
143
383
  }
144
384
  // Validate folder references before anything is written. This will throw if invalid.
145
- index$1.getService('content-structure').validateFromUpdate({
385
+ index$2.getService('content-structure').validateFromUpdate({
146
386
  incomingStructure: contentStructure,
147
387
  upsertedUids,
148
388
  deletedUids
@@ -175,7 +415,7 @@ const updateSchema = async (schema)=>{
175
415
  if (!contentType.plugin) {
176
416
  // Track before generation because a generator failure can leave a partial skeleton.
177
417
  generatedApiNames.push(contentType.singularName);
178
- await index$1.getService('content-types').generateAPI({
418
+ await index$2.getService('content-types').generateAPI({
179
419
  displayName: contentType.displayName,
180
420
  singularName: contentType.singularName,
181
421
  pluralName: contentType.pluralName,
@@ -187,7 +427,6 @@ const updateSchema = async (schema)=>{
187
427
  builder.editContentType({
188
428
  ...contentType,
189
429
  attributes: contentType.attributes.reduce((acc, attr)=>{
190
- // NOTE: handle renaming migrations here by comparing attr name & attr.properties.name
191
430
  if (attr.action === 'delete') {
192
431
  return acc;
193
432
  }
@@ -232,6 +471,9 @@ const updateSchema = async (schema)=>{
232
471
  // Components target existing components
233
472
  // Nested components target existing components
234
473
  // Dynamic zones target existing components
474
+ // Generate rename migrations before reloading, while strapi.db.metadata still
475
+ // reflects the pre-rename schema (the controller triggers the reload after this).
476
+ migrationFilePath = await generateRenameMigrations(schema);
235
477
  const schemaFilesWritten = await builder.writeFiles();
236
478
  if (!schemaFilesWritten) {
237
479
  schemaAlreadyRolledBack = true;
@@ -243,7 +485,7 @@ const updateSchema = async (schema)=>{
243
485
  });
244
486
  }
245
487
  // Commit the single folder file last. Every preceding filesystem mutation can be restored.
246
- await index$1.getService('content-structure').commitFromUpdate({
488
+ await index$2.getService('content-structure').commitFromUpdate({
247
489
  incomingStructure: contentStructure,
248
490
  deletedUids
249
491
  });
@@ -253,7 +495,8 @@ const updateSchema = async (schema)=>{
253
495
  apiHandler,
254
496
  backedUpApiUids,
255
497
  generatedApiNames,
256
- schemaAlreadyRolledBack
498
+ schemaAlreadyRolledBack,
499
+ migrationFilePath
257
500
  });
258
501
  throw error;
259
502
  }
@@ -303,5 +546,6 @@ const updateSchema = async (schema)=>{
303
546
 
304
547
  exports.formatAttribute = formatAttribute;
305
548
  exports.getSchema = getSchema;
549
+ exports.renameAttribute = renameAttribute;
306
550
  exports.updateSchema = updateSchema;
307
551
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sources":["../../../server/src/services/schema.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils, errors } from '@strapi/utils';\nimport { mapValues } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\n\nimport createBuilder from './schema-builder';\nimport { finalizeSchemaMutation, rollbackSchemaMutation } from './schema-mutation';\nimport { getService } from '../utils';\nimport type { Schema as CTBSchema } from '../controllers/validation/schema';\nimport {\n assertCTBOwnedApplicationContentType,\n getRestrictRelationsTo,\n isContentTypeVisible,\n} from './content-types';\nimport type { CoreContentStructureService } from './content-structure';\n\ntype ContentTypeKind = 'collectionType' | 'singleType';\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 } = contentTypesUtils;\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 const coreContentStructure: CoreContentStructureService = strapi.get('content-structure');\n const contentStructure = await coreContentStructure.getCleanedFile();\n\n return {\n contentStructure,\n contentTypes,\n components,\n };\n};\n\nexport const updateSchema = async (schema: CTBSchema) => {\n const builder = createBuilder();\n const apiHandler = getService('api-handler') as typeof import('./api-handler');\n\n const { components, contentTypes, contentStructure } = schema;\n\n // Reject protected/plugin deletes before builders, API backups, or folder reconciliation can\n // mutate anything. This is the server-side invariant for crafted update requests.\n contentTypes\n .filter((contentType) => contentType.action === 'delete')\n .forEach((contentType) => assertCTBOwnedApplicationContentType(contentType.uid));\n\n // pre-process data\n removeEmptyDefaultsOnUpdates(schema);\n removeDeletedUIDTargetFieldsOnUpdates(schema);\n\n const upsertedUids = new Map<string, ContentTypeKind>();\n const deletedUids = new Set<string>();\n const generatedApiNames: string[] = [];\n const backedUpApiUids: string[] = [];\n let schemaAlreadyRolledBack = false;\n const APIsToDelete = contentTypes\n .filter((contentType) => contentType.action === 'delete')\n .map((contentType) => contentType.uid);\n\n try {\n for (const contentType of contentTypes) {\n if (contentType.action === 'create') {\n upsertedUids.set(contentType.uid, contentType.kind ?? 'collectionType');\n } else if (contentType.action === 'update' && contentType.kind) {\n // A kind switch in the same save must override the registry's stale kind,\n // otherwise a folder assignment into the new section fails validation.\n upsertedUids.set(contentType.uid, contentType.kind);\n } else if (contentType.action === 'delete') {\n deletedUids.add(contentType.uid);\n }\n }\n\n // Validate folder references before anything is written. This will throw if invalid.\n getService('content-structure').validateFromUpdate({\n incomingStructure: contentStructure,\n upsertedUids,\n deletedUids,\n });\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 // Track before generation because a generator failure can leave a partial skeleton.\n generatedApiNames.push(contentType.singularName);\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 backedUpApiUids.push(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 schemaFilesWritten = await builder.writeFiles();\n\n if (!schemaFilesWritten) {\n schemaAlreadyRolledBack = true;\n throw new errors.ApplicationError('Invalid schema edition');\n }\n\n for (const uid of APIsToDelete) {\n await apiHandler.clear(uid, { preserveBackup: true });\n }\n\n // Commit the single folder file last. Every preceding filesystem mutation can be restored.\n await getService('content-structure').commitFromUpdate({\n incomingStructure: contentStructure,\n deletedUids,\n });\n } catch (error) {\n await rollbackSchemaMutation({\n builder,\n apiHandler,\n backedUpApiUids,\n generatedApiNames,\n schemaAlreadyRolledBack,\n });\n\n throw error;\n }\n\n // Backup cleanup is deliberately outside the compensating boundary: at this point all\n // user-visible artifacts, including groups.json, have committed.\n for (const error of await finalizeSchemaMutation({ apiHandler, backedUpApiUids })) {\n strapi.log.error(error);\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","contentTypesUtils","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","coreContentStructure","get","contentStructure","getCleanedFile","updateSchema","builder","createBuilder","apiHandler","getService","filter","assertCTBOwnedApplicationContentType","upsertedUids","Map","deletedUids","Set","generatedApiNames","backedUpApiUids","schemaAlreadyRolledBack","APIsToDelete","set","add","validateFromUpdate","incomingStructure","createContentType","createComponent","createContentTypeAttributes","reduce","acc","push","singularName","generateAPI","displayName","pluralName","editContentType","deleteContentType","backup","createComponentAttributes","editComponent","deleteComponent","schemaFilesWritten","writeFiles","errors","ApplicationError","clear","preserveBackup","commitFromUpdate","error","rollbackSchemaMutation","finalizeSchemaMutation","log","eventHub","emit"],"mappings":";;;;;;;;;AAkBA,MAAMA,+BAA+B,CAACC,MAAAA,GAAAA;AACpCA,IAAAA,MAAAA,CAAOC,UAAU,CAACC,OAAO,CAAC,CAACC,SAAAA,GAAAA;QAC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WAAAA,CAAYP,MAAM,KAAK,QAAA,EAAU;AACnCyC,YAAAA,MAAAA,CAAOoD,QAAQ,CAACC,IAAI,CAAC,qBAAA,EAAuB;AAC1CvF,gBAAAA,WAAAA,EAAayC,QAAQ1C,YAAY,CAACsC,GAAG,CAACrC,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,CAAOoD,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvC/F,gBAAAA,SAAAA,EAAWiD,QAAQnD,UAAU,CAAC+C,GAAG,CAAC7C,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;QAEA,IAAI5B,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAOoD,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvC/F,gBAAAA,SAAAA,EAAWiD,QAAQnD,UAAU,CAAC+C,GAAG,CAAC7C,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;QAEA,IAAI5B,SAAAA,CAAUC,MAAM,KAAK,QAAA,EAAU;AACjCyC,YAAAA,MAAAA,CAAOoD,QAAQ,CAACC,IAAI,CAAC,kBAAA,EAAoB;AACvC/F,gBAAAA,SAAAA,EAAWiD,QAAQnD,UAAU,CAAC+C,GAAG,CAAC7C,UAAU4B,GAAG;AACjD,aAAA,CAAA;AACF,QAAA;AACF,IAAA;AACF;;;;;;"}
1
+ {"version":3,"file":"schema.js","sources":["../../../server/src/services/schema.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils, errors } from '@strapi/utils';\nimport { mapValues } from 'lodash';\n\nimport type { Schema } from '@strapi/types';\n\nimport createBuilder from './schema-builder';\nimport { createMigrationBuilder } from './migration-builder';\nimport type {\n AttributeRenamesMapping,\n RenameAttributeDefinition,\n UnsupportedRename,\n} from './migration-builder';\nimport { finalizeSchemaMutation, rollbackSchemaMutation } from './schema-mutation';\nimport { getService } from '../utils';\nimport { validateUpdateSchema } from '../controllers/validation/schema';\nimport type { Schema as CTBSchema } from '../controllers/validation/schema';\nimport type { AttributeRenameMigrationMode } from '../config';\nimport {\n assertCTBOwnedApplicationContentType,\n getRestrictRelationsTo,\n isContentTypeVisible,\n} from './content-types';\nimport type { CoreContentStructureService } from './content-structure';\n\ntype ContentTypeKind = 'collectionType' | 'singleType';\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\ninterface CollectedRename {\n uid: string;\n oldName: string;\n newName: string;\n newAttribute?: RenameAttributeDefinition;\n}\n\nconst getAttributeRenameMigrationMode = (): AttributeRenameMigrationMode => {\n return strapi\n .plugin('content-type-builder')\n .config('renameMigrations.attributes', 'prompt-before-save');\n};\n\n/**\n * Collects attribute renames from the update-schema payload. The admin sends an\n * ordered `renames` array per updated content-type / component: the exact path\n * of rename hops the user performed (e.g. `a -> tmp`, `b -> a`, `tmp -> b` for a\n * swap). Order is preserved so the generated migration can replay each hop\n * verbatim — which is inherently collision-free because the Content-Type Builder\n * never allows two fields to share a name at any instant.\n */\nconst collectRenames = (schema: CTBSchema): CollectedRename[] => {\n const renames: CollectedRename[] = [];\n\n type RenameHop = { oldName?: string; newName?: string };\n type AttributeEntry = { action?: string; name?: string; properties?: RenameAttributeDefinition };\n type RenameAwareEntry = {\n action?: string;\n uid: string;\n renames?: RenameHop[];\n attributes?: AttributeEntry[];\n };\n\n const collectFrom = (entries: RenameAwareEntry[]) => {\n entries\n .filter((entry) => entry.action === 'update' && Array.isArray(entry.renames))\n .forEach((entry) => {\n // Only the last hop onto a name produces the field that carries the\n // final definition: in `a -> b, b -> c, x -> b` the first `b` is `a`'s\n // intermediate name and the final `b` is `x`'s field.\n const lastHopByNewName = new Map<string, number>();\n entry.renames!.forEach((hop, index) => {\n if (hop.newName) {\n lastHopByNewName.set(hop.newName, index);\n }\n });\n\n entry.renames!.forEach((hop, index) => {\n if (hop.oldName && hop.newName && hop.oldName !== hop.newName) {\n // The definition the field ends up with in this save, so the builder\n // can refuse hops that also change the field's storage (type,\n // relation target, component…). Intermediate hops of a chain get no\n // definition and are checked when the chain completes.\n const newAttribute =\n lastHopByNewName.get(hop.newName) === index\n ? entry.attributes?.find(\n (attribute) => attribute.action !== 'delete' && attribute.name === hop.newName\n )?.properties\n : undefined;\n\n renames.push({\n uid: entry.uid,\n oldName: hop.oldName,\n newName: hop.newName,\n newAttribute,\n });\n }\n });\n });\n };\n\n collectFrom(schema.contentTypes as unknown as RenameAwareEntry[]);\n collectFrom(schema.components as unknown as RenameAwareEntry[]);\n\n return renames;\n};\n\n/**\n * Drops renames whose final name is not an attribute after this save (it was\n * deleted in the same save), so no store is pointed at a field that is gone.\n */\nconst keepSavedAttributes = (\n schema: CTBSchema,\n mapping: AttributeRenamesMapping\n): AttributeRenamesMapping => {\n type Entry = { action?: string; uid: string; attributes?: { action?: string; name?: string }[] };\n const entries = [\n ...(schema.contentTypes as unknown as Entry[]),\n ...(schema.components as unknown as Entry[]),\n ];\n\n const result: AttributeRenamesMapping = {};\n\n for (const [uid, renames] of Object.entries(mapping)) {\n const entry = entries.find((candidate) => candidate.uid === uid);\n const saved = new Set(\n (entry?.attributes ?? [])\n .filter((attribute) => attribute.action !== 'delete' && attribute.name)\n .map((attribute) => attribute.name as string)\n );\n\n for (const [origin, final] of Object.entries(renames)) {\n if (saved.has(final)) {\n result[uid] ??= {};\n result[uid][origin] = final;\n }\n }\n }\n\n return result;\n};\n\nconst describeUnsupportedReason = (reason: UnsupportedRename['reason']): string => {\n switch (reason) {\n case 'type-changed':\n return 'the field type, relation or component also changed';\n case 'unsupported-type':\n return 'the field type cannot be migrated (e.g. polymorphic relation)';\n case 'attribute-not-found':\n return 'the field is not in the current schema';\n case 'target-occupied':\n return 'the target field still exists in the current schema';\n case 'model-not-found':\n default:\n return 'the type is not in the current schema';\n }\n};\n\n/**\n * Generates a single data-preserving rename migration for the accepted renames\n * in this save. Must run before the server reloads, while `strapi.db.metadata`\n * still reflects the old (pre-rename) schema. Resolves to the written file's\n * path (so a failed save can remove it), or `null` when nothing was written.\n */\nconst generateRenameMigrations = async (schema: CTBSchema): Promise<string | null> => {\n // In prompt modes the admin strips refused renames before sending the payload.\n if (getAttributeRenameMigrationMode() === 'never') {\n return null;\n }\n\n const renames = collectRenames(schema);\n if (renames.length === 0) {\n return null;\n }\n\n const migrationBuilder = createMigrationBuilder({ strapi });\n\n for (const { uid, oldName, newName, newAttribute } of renames) {\n migrationBuilder.addRenameAttribute(uid, { oldName, newName, newAttribute });\n }\n\n const attributeRenames = keepSavedAttributes(schema, migrationBuilder.attributeRenamesMapping());\n if (Object.keys(attributeRenames).length > 0) {\n migrationBuilder.addAttributeRenames(attributeRenames);\n }\n\n const unsupported = migrationBuilder.getUnsupported();\n if (unsupported.length > 0) {\n const fields = unsupported\n .map((u) => `${u.uid}.${u.oldName} (${describeUnsupportedReason(u.reason)})`)\n .join(', ');\n strapi.log.warn(\n `[content-type-builder] Could not generate a rename migration for ${unsupported.length} field(s): ${fields}. Data in these fields may not be preserved.`\n );\n }\n\n if (migrationBuilder.hasChanges()) {\n return migrationBuilder.writeFiles();\n }\n\n return null;\n};\n\n/**\n * Renames a single attribute on a content-type or component and generates the\n * data-preserving migration in one step. Used by the `strapi rename:field` CLI\n * command so scripted / non-UI workflows get the same behaviour as the admin.\n *\n * It reuses the regular `updateSchema` path (and therefore the same rename\n * resolver via `generateRenameMigrations`), so the migration is resolved against\n * the pre-reload `strapi.db.metadata` exactly like the admin save. The caller is\n * responsible for not reloading before this resolves (the CLI simply exits).\n *\n * Unlike the admin, there is no one to confirm a data-losing rename, so it\n * refuses before touching the schema when the rename cannot be migrated.\n */\nexport const renameAttribute = async (\n uid: string,\n oldName: string,\n newName: string\n): Promise<void> => {\n const { ApplicationError } = errors;\n\n if (!oldName || !newName) {\n throw new ApplicationError('Both an old and a new attribute name are required');\n }\n\n if (oldName === newName) {\n throw new ApplicationError(`Cannot rename \"${oldName}\" to itself`);\n }\n\n if (getAttributeRenameMigrationMode() === 'never') {\n throw new ApplicationError(\n 'Rename migrations are disabled (`renameMigrations.attributes: never`); rename the field in the Content-Type Builder instead'\n );\n }\n\n const contentType = (strapi.contentTypes as Record<string, any>)[uid];\n const component = (strapi.components as Record<string, any>)[uid];\n const model = contentType ?? component;\n\n if (!model) {\n throw new ApplicationError(`No content-type or component found for uid \"${uid}\"`);\n }\n\n if (!model.attributes?.[oldName]) {\n throw new ApplicationError(`Attribute \"${oldName}\" does not exist on \"${uid}\"`);\n }\n\n if (model.attributes?.[newName]) {\n throw new ApplicationError(`Attribute \"${newName}\" already exists on \"${uid}\"`);\n }\n\n // Reuse the formatted, CTB-visible attributes (same shape the admin sends) so\n // the schema edit matches an admin save and the renamed key is the only change.\n const formattedSchema = await getSchema();\n const isComponent = Boolean(component);\n const entry = isComponent\n ? (formattedSchema.components as Record<string, any>)[uid]\n : (formattedSchema.contentTypes as Record<string, any>)[uid];\n\n // Custom fields are exposed with their underlying type; the admin sends them\n // back as `customField` so the schema file keeps them as custom fields.\n const toPayloadProperties = (properties: Record<string, any>) =>\n properties.customField ? { ...properties, type: 'customField' } : properties;\n\n const attributes = entry.attributes.map(({ name, ...properties }: Record<string, any>) => ({\n action: 'update',\n name: name === oldName ? newName : name,\n properties: toPayloadProperties(properties),\n }));\n\n // Dry run: the field keeps its definition, so only the rename itself can be\n // refused (system attribute, unsupported relation, occupied target…).\n const { name: _name, ...oldProperties } = entry.attributes.find(\n (attribute: Record<string, any>) => attribute.name === oldName\n ) ?? { name: oldName };\n const probe = createMigrationBuilder({ strapi });\n probe.addRenameAttribute(uid, {\n oldName,\n newName,\n newAttribute: toPayloadProperties(oldProperties),\n });\n\n const refused = probe.getUnsupported();\n if (refused.length > 0) {\n throw new ApplicationError(\n `Cannot rename \"${oldName}\" on \"${uid}\" without losing its data: ${refused\n .map(({ reason }) => describeUnsupportedReason(reason))\n .join(', ')}`\n );\n }\n\n const renames = [{ oldName, newName }];\n\n const payload = isComponent\n ? {\n contentTypes: [],\n components: [\n {\n action: 'update',\n uid,\n category: model.category,\n displayName: model.info?.displayName,\n icon: model.info?.icon,\n description: model.info?.description,\n pluginOptions: model.pluginOptions,\n renames,\n attributes,\n },\n ],\n }\n : {\n contentTypes: [\n {\n action: 'update',\n uid,\n kind: model.kind,\n displayName: model.info?.displayName,\n description: model.info?.description,\n draftAndPublish: Boolean(model.options?.draftAndPublish),\n options: model.options,\n pluginOptions: model.pluginOptions,\n renames,\n attributes,\n },\n ],\n components: [],\n };\n\n // Same checks as an admin save (name rules, reserved names, snake-case\n // uniqueness: `fooBar` next to an existing `foo_bar` would share a column).\n const { data } = await validateUpdateSchema({ data: payload });\n\n await updateSchema(data as CTBSchema);\n};\n\nconst formatAttributes = (model: any) => {\n const { getVisibleAttributes } = contentTypesUtils;\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(strapi.contentTypes, (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 });\n\n const components = mapValues(strapi.components, (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 });\n\n const coreContentStructure: CoreContentStructureService = strapi.get('content-structure');\n const contentStructure = await coreContentStructure.getCleanedFile();\n\n return {\n contentStructure,\n contentTypes,\n components,\n settings: {\n renameMigrations: {\n attributes: getAttributeRenameMigrationMode(),\n },\n },\n };\n};\n\nexport const updateSchema = async (schema: CTBSchema) => {\n const builder = createBuilder();\n const apiHandler = getService('api-handler') as typeof import('./api-handler');\n\n const { components, contentTypes, contentStructure } = schema;\n\n // Reject protected/plugin deletes before builders, API backups, or folder reconciliation can\n // mutate anything. This is the server-side invariant for crafted update requests.\n contentTypes\n .filter((contentType) => contentType.action === 'delete')\n .forEach((contentType) => assertCTBOwnedApplicationContentType(contentType.uid));\n\n // pre-process data\n removeEmptyDefaultsOnUpdates(schema);\n removeDeletedUIDTargetFieldsOnUpdates(schema);\n\n const upsertedUids = new Map<string, ContentTypeKind>();\n const deletedUids = new Set<string>();\n const generatedApiNames: string[] = [];\n const backedUpApiUids: string[] = [];\n let schemaAlreadyRolledBack = false;\n let migrationFilePath: string | null = null;\n const APIsToDelete = contentTypes\n .filter((contentType) => contentType.action === 'delete')\n .map((contentType) => contentType.uid);\n\n try {\n for (const contentType of contentTypes) {\n if (contentType.action === 'create') {\n upsertedUids.set(contentType.uid, contentType.kind ?? 'collectionType');\n } else if (contentType.action === 'update' && contentType.kind) {\n // A kind switch in the same save must override the registry's stale kind,\n // otherwise a folder assignment into the new section fails validation.\n upsertedUids.set(contentType.uid, contentType.kind);\n } else if (contentType.action === 'delete') {\n deletedUids.add(contentType.uid);\n }\n }\n\n // Validate folder references before anything is written. This will throw if invalid.\n getService('content-structure').validateFromUpdate({\n incomingStructure: contentStructure,\n upsertedUids,\n deletedUids,\n });\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 // Track before generation because a generator failure can leave a partial skeleton.\n generatedApiNames.push(contentType.singularName);\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 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 backedUpApiUids.push(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 // Generate rename migrations before reloading, while strapi.db.metadata still\n // reflects the pre-rename schema (the controller triggers the reload after this).\n migrationFilePath = await generateRenameMigrations(schema);\n\n const schemaFilesWritten = await builder.writeFiles();\n\n if (!schemaFilesWritten) {\n schemaAlreadyRolledBack = true;\n throw new errors.ApplicationError('Invalid schema edition');\n }\n\n for (const uid of APIsToDelete) {\n await apiHandler.clear(uid, { preserveBackup: true });\n }\n\n // Commit the single folder file last. Every preceding filesystem mutation can be restored.\n await getService('content-structure').commitFromUpdate({\n incomingStructure: contentStructure,\n deletedUids,\n });\n } catch (error) {\n await rollbackSchemaMutation({\n builder,\n apiHandler,\n backedUpApiUids,\n generatedApiNames,\n schemaAlreadyRolledBack,\n migrationFilePath,\n });\n\n throw error;\n }\n\n // Backup cleanup is deliberately outside the compensating boundary: at this point all\n // user-visible artifacts, including groups.json, have committed.\n for (const error of await finalizeSchemaMutation({ apiHandler, backedUpApiUids })) {\n strapi.log.error(error);\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","getAttributeRenameMigrationMode","strapi","plugin","config","collectRenames","renames","collectFrom","entries","filter","entry","Array","isArray","lastHopByNewName","Map","hop","index","newName","set","oldName","newAttribute","get","push","uid","keepSavedAttributes","mapping","result","Object","candidate","saved","Set","map","origin","final","has","describeUnsupportedReason","reason","generateRenameMigrations","length","migrationBuilder","createMigrationBuilder","addRenameAttribute","attributeRenames","attributeRenamesMapping","keys","addAttributeRenames","unsupported","getUnsupported","fields","u","join","log","warn","hasChanges","writeFiles","renameAttribute","ApplicationError","errors","model","formattedSchema","getSchema","isComponent","Boolean","toPayloadProperties","customField","_name","oldProperties","probe","refused","payload","category","displayName","info","icon","description","pluginOptions","kind","draftAndPublish","options","data","validateUpdateSchema","updateSchema","formatAttributes","getVisibleAttributes","contentTypesUtils","key","formatAttribute","targetAttribute","inversedBy","mappedBy","conditions","mapValues","globalId","modelName","collectionName","modelType","visible","isContentTypeVisible","restrictRelationsTo","getRestrictRelationsTo","coreContentStructure","contentStructure","getCleanedFile","settings","renameMigrations","builder","createBuilder","apiHandler","getService","assertCTBOwnedApplicationContentType","upsertedUids","deletedUids","generatedApiNames","backedUpApiUids","schemaAlreadyRolledBack","migrationFilePath","APIsToDelete","add","validateFromUpdate","incomingStructure","createContentType","createComponent","createContentTypeAttributes","reduce","acc","singularName","generateAPI","pluralName","editContentType","deleteContentType","backup","createComponentAttributes","editComponent","deleteComponent","schemaFilesWritten","clear","preserveBackup","commitFromUpdate","error","rollbackSchemaMutation","finalizeSchemaMutation","eventHub","emit"],"mappings":";;;;;;;;;;;AA0BA,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,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;AACF,CAAA;AAEA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