@strapi/content-type-builder 5.56.0 → 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 (146) 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 +142 -8
  44. package/dist/admin/components/FormModal/FormModal.js.map +1 -1
  45. package/dist/admin/components/FormModal/FormModal.mjs +143 -9
  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/lib/transforms/schemas/toCTB.d.ts +4 -3
  68. package/dist/admin/src/components/AIChat/lib/types/schema.d.ts +6 -1
  69. package/dist/admin/src/components/DataManager/DataManagerContext.d.ts +28 -2
  70. package/dist/admin/src/components/DataManager/RenameMigrationModal.d.ts +73 -0
  71. package/dist/admin/src/components/DataManager/reducer.d.ts +17 -2
  72. package/dist/admin/src/components/DataManager/utils/cleanData.d.ts +16 -0
  73. package/dist/admin/src/components/DataManager/utils/groupRenameChains.d.ts +31 -0
  74. package/dist/admin/src/components/DataManager/utils/isStorageCompatibleRename.d.ts +10 -0
  75. package/dist/admin/src/components/DataManager/utils/resolveAfterEditRenameConsent.d.ts +24 -0
  76. package/dist/admin/src/components/DataManager/utils/splitChainsByInheritedConsent.d.ts +26 -0
  77. package/dist/admin/src/components/FormModal/utils/getRenameStorageChange.d.ts +40 -0
  78. package/dist/admin/src/types.d.ts +23 -0
  79. package/dist/admin/translations/en.json.js +12 -0
  80. package/dist/admin/translations/en.json.js.map +1 -1
  81. package/dist/admin/translations/en.json.mjs +12 -0
  82. package/dist/admin/translations/en.json.mjs.map +1 -1
  83. package/dist/server/config.js +24 -3
  84. package/dist/server/config.js.map +1 -1
  85. package/dist/server/config.mjs +21 -3
  86. package/dist/server/config.mjs.map +1 -1
  87. package/dist/server/controllers/schema.js +2 -2
  88. package/dist/server/controllers/schema.js.map +1 -1
  89. package/dist/server/controllers/schema.mjs +1 -1
  90. package/dist/server/controllers/schema.mjs.map +1 -1
  91. package/dist/server/controllers/validation/content-type.js +9 -11
  92. package/dist/server/controllers/validation/content-type.js.map +1 -1
  93. package/dist/server/controllers/validation/content-type.mjs +7 -9
  94. package/dist/server/controllers/validation/content-type.mjs.map +1 -1
  95. package/dist/server/controllers/validation/model-schema.js +2 -3
  96. package/dist/server/controllers/validation/model-schema.js.map +1 -1
  97. package/dist/server/controllers/validation/model-schema.mjs +1 -2
  98. package/dist/server/controllers/validation/model-schema.mjs.map +1 -1
  99. package/dist/server/controllers/validation/relations.js +1 -2
  100. package/dist/server/controllers/validation/relations.js.map +1 -1
  101. package/dist/server/controllers/validation/relations.mjs +1 -2
  102. package/dist/server/controllers/validation/relations.mjs.map +1 -1
  103. package/dist/server/controllers/validation/schema.js +42 -23
  104. package/dist/server/controllers/validation/schema.js.map +1 -1
  105. package/dist/server/controllers/validation/schema.mjs +43 -24
  106. package/dist/server/controllers/validation/schema.mjs.map +1 -1
  107. package/dist/server/index.js +1 -1
  108. package/dist/server/index.js.map +1 -1
  109. package/dist/server/services/content-types.js +1 -2
  110. package/dist/server/services/content-types.js.map +1 -1
  111. package/dist/server/services/content-types.mjs +2 -3
  112. package/dist/server/services/content-types.mjs.map +1 -1
  113. package/dist/server/services/migration-builder/index.js +580 -0
  114. package/dist/server/services/migration-builder/index.js.map +1 -0
  115. package/dist/server/services/migration-builder/index.mjs +573 -0
  116. package/dist/server/services/migration-builder/index.mjs.map +1 -0
  117. package/dist/server/services/schema-builder/content-type-builder.js +31 -1
  118. package/dist/server/services/schema-builder/content-type-builder.js.map +1 -1
  119. package/dist/server/services/schema-builder/content-type-builder.mjs +31 -1
  120. package/dist/server/services/schema-builder/content-type-builder.mjs.map +1 -1
  121. package/dist/server/services/schema-mutation.js +30 -2
  122. package/dist/server/services/schema-mutation.js.map +1 -1
  123. package/dist/server/services/schema-mutation.mjs +10 -2
  124. package/dist/server/services/schema-mutation.mjs.map +1 -1
  125. package/dist/server/services/schema.js +259 -15
  126. package/dist/server/services/schema.js.map +1 -1
  127. package/dist/server/services/schema.mjs +252 -9
  128. package/dist/server/services/schema.mjs.map +1 -1
  129. package/dist/server/src/config.d.ts +23 -2
  130. package/dist/server/src/config.d.ts.map +1 -1
  131. package/dist/server/src/controllers/validation/content-type.d.ts +0 -1
  132. package/dist/server/src/controllers/validation/content-type.d.ts.map +1 -1
  133. package/dist/server/src/controllers/validation/relations.d.ts.map +1 -1
  134. package/dist/server/src/controllers/validation/schema.d.ts +28 -0
  135. package/dist/server/src/controllers/validation/schema.d.ts.map +1 -1
  136. package/dist/server/src/index.d.ts +10 -2
  137. package/dist/server/src/index.d.ts.map +1 -1
  138. package/dist/server/src/services/content-types.d.ts.map +1 -1
  139. package/dist/server/src/services/migration-builder/index.d.ts +83 -0
  140. package/dist/server/src/services/migration-builder/index.d.ts.map +1 -0
  141. package/dist/server/src/services/schema-builder/content-type-builder.d.ts.map +1 -1
  142. package/dist/server/src/services/schema-mutation.d.ts +4 -2
  143. package/dist/server/src/services/schema-mutation.d.ts.map +1 -1
  144. package/dist/server/src/services/schema.d.ts +19 -0
  145. package/dist/server/src/services/schema.d.ts.map +1 -1
  146. package/package.json +7 -6
@@ -1 +1 @@
1
- {"version":3,"file":"cleanData.mjs","sources":["../../../../../admin/src/components/DataManager/utils/cleanData.ts"],"sourcesContent":["import camelCase from 'lodash/camelCase';\nimport omit from 'lodash/omit';\nimport sortBy from 'lodash/sortBy';\n\nimport { pluginId } from '../../../pluginId';\n\nimport {\n createEmptyContentStructure,\n hasContentStructureChanged,\n toServerFile,\n} from './contentStructure';\n\nimport type { ContentStructure } from './contentStructure';\nimport type {\n Component,\n Components,\n ContentTypes,\n ContentType,\n AnyAttribute,\n} from '../../../types';\nimport type { UID } from '@strapi/types';\n\nconst sortContentType = (types: ContentTypes) => {\n return sortBy(\n Object.keys(types)\n .map((uid) => ({\n visible: types[uid].visible,\n name: uid as UID.ContentType,\n title: types[uid].info.displayName,\n plugin: types[uid].plugin,\n uid: uid as UID.ContentType,\n to: `/plugins/${pluginId}/content-types/${uid}`,\n kind: types[uid].kind,\n restrictRelationsTo: types[uid].restrictRelationsTo,\n status: types[uid].status,\n }))\n .filter((obj) => obj !== null),\n (obj) => camelCase(obj.title)\n );\n};\n\ntype TrackingEventProperties = {\n newContentTypes: number;\n editedContentTypes: number;\n deletedContentTypes: number;\n newComponents: number;\n editedComponents: number;\n deletedComponents: number;\n newFields: number;\n editedFields: number;\n deletedFields: number;\n};\n\nconst stateToRequestData = ({\n components,\n contentTypes,\n contentStructure = createEmptyContentStructure(),\n initialContentStructure = createEmptyContentStructure(),\n}: {\n components: Components;\n contentTypes: ContentTypes;\n contentStructure?: ContentStructure;\n initialContentStructure?: ContentStructure;\n}) => {\n const trackingEventProperties: TrackingEventProperties = {\n newContentTypes: 0,\n editedContentTypes: 0,\n deletedContentTypes: 0,\n newComponents: 0,\n editedComponents: 0,\n deletedComponents: 0,\n newFields: 0,\n editedFields: 0,\n deletedFields: 0,\n };\n\n const formattedComponents = Object.values(components)\n .filter((compo) => {\n return ['NEW', 'CHANGED', 'REMOVED'].includes(compo.status);\n })\n .map((component) => {\n const requestFormattedComponent = formatTypeForRequest(component);\n\n const eventAction = requestFormattedComponent.action as 'create' | 'update' | 'delete';\n updateEventCounts(\n { ...component, action: eventAction },\n trackingEventProperties,\n 'component'\n );\n\n return requestFormattedComponent;\n });\n\n const formattedContentTypes = Object.values(contentTypes)\n .filter((contentType) => {\n return ['NEW', 'CHANGED', 'REMOVED'].includes(contentType.status);\n })\n .map((contentType) => {\n const requestFormattedContentType = formatTypeForRequest(contentType);\n\n const eventAction = requestFormattedContentType.action as 'create' | 'update' | 'delete';\n updateEventCounts(\n { ...contentType, action: eventAction },\n trackingEventProperties,\n 'contentType'\n );\n\n return requestFormattedContentType;\n });\n\n // Folder changes occur in the same operation as schema changes.\n // Attach the draft structure only when a change has occurred, as the server-side\n // ZOD schema for this payload specifies that the contentStructure property is optional.\n const structureChanged = hasContentStructureChanged(contentStructure, initialContentStructure);\n const contentStructureRequestPayload = structureChanged\n ? { contentStructure: toServerFile(contentStructure) }\n : undefined;\n\n return {\n requestData: {\n components: formattedComponents,\n contentTypes: formattedContentTypes,\n ...contentStructureRequestPayload,\n },\n trackingEventProperties,\n };\n};\n\nconst removeNullKeys = (obj: Record<string, unknown>) => {\n return Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => {\n if (Array.isArray(value)) {\n return value.length > 0;\n }\n if (typeof value === 'object' && value !== null) {\n return Object.keys(value).length > 0;\n }\n return value !== null && value !== undefined;\n })\n );\n};\n\nconst formatAttribute = (attr: AnyAttribute) => {\n if ('customField' in attr) {\n return { ...attr, type: 'customField' };\n }\n\n if ('targetAttribute' in attr) {\n return {\n ...attr,\n targetAttribute: attr.targetAttribute === '-' ? null : attr.targetAttribute,\n // Explicitly preserve conditions for relations\n ...(attr.conditions && { conditions: attr.conditions }),\n };\n }\n\n return attr;\n};\n\nconst formatTypeForRequest = (type: ContentType | Component) => {\n let action;\n // should we do a diff with the initial data instead of trusting the state status ??\n switch (type.status) {\n case 'NEW':\n action = 'create';\n break;\n case 'CHANGED':\n action = 'update';\n break;\n case 'REMOVED':\n return { action: 'delete', uid: type.uid };\n default:\n throw new Error('Invalid status');\n }\n\n return {\n action,\n uid: type.uid,\n category: 'category' in type ? type.category : undefined,\n ...omit(type, ['info', 'options', 'visible', 'uid', 'restrictRelationsTo']),\n ...type.options,\n ...type.info,\n attributes: type.attributes.map((attr) => {\n let action;\n\n switch (attr.status) {\n // NOTE: we want to always send the full data to preserve the order\n\n case 'NEW':\n action = 'create';\n break;\n case 'REMOVED':\n return { action: 'delete', name: attr.name };\n case 'UNCHANGED':\n case 'CHANGED':\n default:\n action = 'update';\n }\n\n return {\n action,\n name: attr.name,\n properties: removeNullKeys(omit(formatAttribute(attr), ['status', 'name'])),\n };\n }),\n };\n};\n\nconst updateEventCounts = (\n type: (ContentType | Component) & { action?: 'create' | 'update' | 'delete' },\n counts: TrackingEventProperties,\n entityType: 'component' | 'contentType'\n) => {\n if (!type || typeof type.action !== 'string') {\n return;\n }\n\n const isContentType = entityType === 'contentType';\n\n switch (type.action) {\n case 'create':\n if (isContentType) {\n counts.newContentTypes++;\n } else {\n counts.newComponents++;\n }\n break;\n case 'update':\n if (isContentType) {\n counts.editedContentTypes++;\n } else {\n counts.editedComponents++;\n }\n break;\n case 'delete':\n if (isContentType) {\n counts.deletedContentTypes++;\n } else {\n counts.deletedComponents++;\n }\n break;\n default:\n break;\n }\n\n if (Array.isArray(type.attributes)) {\n if (type.action === 'delete') {\n counts.deletedFields += type.attributes.length;\n } else {\n type.attributes.forEach((attribute) => {\n if (!attribute || typeof attribute.status !== 'string') {\n return;\n }\n\n switch (attribute.status) {\n case 'NEW':\n counts.newFields++;\n break;\n case 'CHANGED':\n counts.editedFields++;\n break;\n case 'REMOVED':\n counts.deletedFields++;\n break;\n case 'UNCHANGED':\n default:\n break;\n }\n });\n }\n }\n};\n\nexport { stateToRequestData, sortContentType };\n"],"names":["sortContentType","types","sortBy","Object","keys","map","uid","visible","name","title","info","displayName","plugin","to","pluginId","kind","restrictRelationsTo","status","filter","obj","camelCase","stateToRequestData","components","contentTypes","contentStructure","createEmptyContentStructure","initialContentStructure","trackingEventProperties","newContentTypes","editedContentTypes","deletedContentTypes","newComponents","editedComponents","deletedComponents","newFields","editedFields","deletedFields","formattedComponents","values","compo","includes","component","requestFormattedComponent","formatTypeForRequest","eventAction","action","updateEventCounts","formattedContentTypes","contentType","requestFormattedContentType","structureChanged","hasContentStructureChanged","contentStructureRequestPayload","toServerFile","undefined","requestData","removeNullKeys","fromEntries","entries","_","value","Array","isArray","length","formatAttribute","attr","type","targetAttribute","conditions","Error","category","omit","options","attributes","properties","counts","entityType","isContentType","forEach","attribute"],"mappings":";;;;;;AAsBA,MAAMA,kBAAkB,CAACC,KAAAA,GAAAA;IACvB,OAAOC,MAAAA,CACLC,OAAOC,IAAI,CAACH,OACTI,GAAG,CAAC,CAACC,GAAAA,IAAS;AACbC,YAAAA,OAAAA,EAASN,KAAK,CAACK,GAAAA,CAAI,CAACC,OAAO;YAC3BC,IAAAA,EAAMF,GAAAA;AACNG,YAAAA,KAAAA,EAAOR,KAAK,CAACK,GAAAA,CAAI,CAACI,IAAI,CAACC,WAAW;AAClCC,YAAAA,MAAAA,EAAQX,KAAK,CAACK,GAAAA,CAAI,CAACM,MAAM;YACzBN,GAAAA,EAAKA,GAAAA;AACLO,YAAAA,EAAAA,EAAI,CAAC,SAAS,EAAEC,QAAAA,CAAS,eAAe,EAAER,GAAAA,CAAAA,CAAK;AAC/CS,YAAAA,IAAAA,EAAMd,KAAK,CAACK,GAAAA,CAAI,CAACS,IAAI;AACrBC,YAAAA,mBAAAA,EAAqBf,KAAK,CAACK,GAAAA,CAAI,CAACU,mBAAmB;AACnDC,YAAAA,MAAAA,EAAQhB,KAAK,CAACK,GAAAA,CAAI,CAACW;SACrB,CAAA,CAAA,CACCC,MAAM,CAAC,CAACC,GAAAA,GAAQA,GAAAA,KAAQ,IAAA,CAAA,EAC3B,CAACA,GAAAA,GAAQC,SAAAA,CAAUD,GAAAA,CAAIV,KAAK,CAAA,CAAA;AAEhC;AAcA,MAAMY,kBAAAA,GAAqB,CAAC,EAC1BC,UAAU,EACVC,YAAY,EACZC,gBAAAA,GAAmBC,2BAAAA,EAA6B,EAChDC,uBAAAA,GAA0B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K,QAAA;AACH,YAAA,IAAI6C,aAAAA,EAAe;AACjBF,gBAAAA,MAAAA,CAAO7C,mBAAmB,EAAA;YAC5B,CAAA,MAAO;AACL6C,gBAAAA,MAAAA,CAAO1C,iBAAiB,EAAA;AAC1B,YAAA;AACA,YAAA;AAGJ;AAEA,IAAA,IAAI4B,KAAAA,CAAMC,OAAO,CAACI,IAAAA,CAAKO,UAAU,CAAA,EAAG;QAClC,IAAIP,IAAAA,CAAKrB,MAAM,KAAK,QAAA,EAAU;AAC5B8B,YAAAA,MAAAA,CAAOvC,aAAa,IAAI8B,IAAAA,CAAKO,UAAU,CAACV,MAAM;QAChD,CAAA,MAAO;AACLG,YAAAA,IAAAA,CAAKO,UAAU,CAACK,OAAO,CAAC,CAACC,SAAAA,GAAAA;AACvB,gBAAA,IAAI,CAACA,SAAAA,IAAa,OAAOA,SAAAA,CAAU9D,MAAM,KAAK,QAAA,EAAU;AACtD,oBAAA;AACF,gBAAA;AAEA,gBAAA,OAAQ8D,UAAU9D,MAAM;oBACtB,KAAK,KAAA;AACH0D,wBAAAA,MAAAA,CAAOzC,SAAS,EAAA;AAChB,wBAAA;oBACF,KAAK,SAAA;AACHyC,wBAAAA,MAAAA,CAAOxC,YAAY,EAAA;AACnB,wBAAA;oBACF,KAAK,SAAA;AACHwC,wBAAAA,MAAAA,CAAOvC,aAAa,EAAA;AACpB,wBAAA;AAIJ;AACF,YAAA,CAAA,CAAA;AACF,QAAA;AACF,IAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"cleanData.mjs","sources":["../../../../../admin/src/components/DataManager/utils/cleanData.ts"],"sourcesContent":["import camelCase from 'lodash/camelCase';\nimport omit from 'lodash/omit';\nimport sortBy from 'lodash/sortBy';\n\nimport { pluginId } from '../../../pluginId';\n\nimport {\n createEmptyContentStructure,\n hasContentStructureChanged,\n toServerFile,\n} from './contentStructure';\n\nimport type { ContentStructure } from './contentStructure';\nimport type {\n Component,\n Components,\n ContentTypes,\n ContentType,\n AnyAttribute,\n} from '../../../types';\nimport type { UID } from '@strapi/types';\n\nconst sortContentType = (types: ContentTypes) => {\n return sortBy(\n Object.keys(types)\n .map((uid) => ({\n visible: types[uid].visible,\n name: uid as UID.ContentType,\n title: types[uid].info.displayName,\n plugin: types[uid].plugin,\n uid: uid as UID.ContentType,\n to: `/plugins/${pluginId}/content-types/${uid}`,\n kind: types[uid].kind,\n restrictRelationsTo: types[uid].restrictRelationsTo,\n status: types[uid].status,\n }))\n .filter((obj) => obj !== null),\n (obj) => camelCase(obj.title)\n );\n};\n\ntype TrackingEventProperties = {\n newContentTypes: number;\n editedContentTypes: number;\n deletedContentTypes: number;\n newComponents: number;\n editedComponents: number;\n deletedComponents: number;\n newFields: number;\n editedFields: number;\n deletedFields: number;\n};\n\nconst stateToRequestData = ({\n components,\n contentTypes,\n contentStructure = createEmptyContentStructure(),\n initialContentStructure = createEmptyContentStructure(),\n}: {\n components: Components;\n contentTypes: ContentTypes;\n contentStructure?: ContentStructure;\n initialContentStructure?: ContentStructure;\n}) => {\n const trackingEventProperties: TrackingEventProperties = {\n newContentTypes: 0,\n editedContentTypes: 0,\n deletedContentTypes: 0,\n newComponents: 0,\n editedComponents: 0,\n deletedComponents: 0,\n newFields: 0,\n editedFields: 0,\n deletedFields: 0,\n };\n\n const formattedComponents = Object.values(components)\n .filter((compo) => {\n return ['NEW', 'CHANGED', 'REMOVED'].includes(compo.status);\n })\n .map((component) => {\n const requestFormattedComponent = formatTypeForRequest(component);\n\n const eventAction = requestFormattedComponent.action as 'create' | 'update' | 'delete';\n updateEventCounts(\n { ...component, action: eventAction },\n trackingEventProperties,\n 'component'\n );\n\n return requestFormattedComponent;\n });\n\n const formattedContentTypes = Object.values(contentTypes)\n .filter((contentType) => {\n return ['NEW', 'CHANGED', 'REMOVED'].includes(contentType.status);\n })\n .map((contentType) => {\n const requestFormattedContentType = formatTypeForRequest(contentType);\n\n const eventAction = requestFormattedContentType.action as 'create' | 'update' | 'delete';\n updateEventCounts(\n { ...contentType, action: eventAction },\n trackingEventProperties,\n 'contentType'\n );\n\n return requestFormattedContentType;\n });\n\n // Folder changes occur in the same operation as schema changes.\n // Attach the draft structure only when a change has occurred, as the server-side\n // ZOD schema for this payload specifies that the contentStructure property is optional.\n const structureChanged = hasContentStructureChanged(contentStructure, initialContentStructure);\n const contentStructureRequestPayload = structureChanged\n ? { contentStructure: toServerFile(contentStructure) }\n : undefined;\n\n return {\n requestData: {\n components: formattedComponents,\n contentTypes: formattedContentTypes,\n ...contentStructureRequestPayload,\n },\n trackingEventProperties,\n };\n};\n\nconst removeNullKeys = (obj: Record<string, unknown>) => {\n return Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => {\n if (Array.isArray(value)) {\n return value.length > 0;\n }\n if (typeof value === 'object' && value !== null) {\n return Object.keys(value).length > 0;\n }\n return value !== null && value !== undefined;\n })\n );\n};\n\nconst formatAttribute = (attr: AnyAttribute) => {\n if ('customField' in attr) {\n return { ...attr, type: 'customField' };\n }\n\n if ('targetAttribute' in attr) {\n return {\n ...attr,\n targetAttribute: attr.targetAttribute === '-' ? null : attr.targetAttribute,\n // Explicitly preserve conditions for relations\n ...(attr.conditions && { conditions: attr.conditions }),\n };\n }\n\n return attr;\n};\n\nconst formatTypeForRequest = (type: ContentType | Component) => {\n let action;\n // should we do a diff with the initial data instead of trusting the state status ??\n switch (type.status) {\n case 'NEW':\n action = 'create';\n break;\n case 'CHANGED':\n action = 'update';\n break;\n case 'REMOVED':\n return { action: 'delete', uid: type.uid };\n default:\n throw new Error('Invalid status');\n }\n\n return {\n action,\n uid: type.uid,\n category: 'category' in type ? type.category : undefined,\n ...omit(type, [\n 'info',\n 'options',\n 'visible',\n 'uid',\n 'restrictRelationsTo',\n 'renames',\n 'declinedRenameNames',\n ]),\n ...type.options,\n ...type.info,\n // Forward the ordered rename path (existing fields only) so the server can\n // generate a data-preserving migration that replays each hop verbatim.\n ...(action === 'update' && Array.isArray(type.renames) && type.renames.length > 0\n ? { renames: type.renames }\n : {}),\n attributes: type.attributes.map((attr) => {\n let action;\n\n switch (attr.status) {\n // NOTE: we want to always send the full data to preserve the order\n\n case 'NEW':\n action = 'create';\n break;\n case 'REMOVED':\n return { action: 'delete', name: attr.name };\n case 'UNCHANGED':\n case 'CHANGED':\n default:\n action = 'update';\n }\n\n return {\n action,\n name: attr.name,\n properties: removeNullKeys(omit(formatAttribute(attr), ['status', 'name'])),\n };\n }),\n };\n};\n\nconst updateEventCounts = (\n type: (ContentType | Component) & { action?: 'create' | 'update' | 'delete' },\n counts: TrackingEventProperties,\n entityType: 'component' | 'contentType'\n) => {\n if (!type || typeof type.action !== 'string') {\n return;\n }\n\n const isContentType = entityType === 'contentType';\n\n switch (type.action) {\n case 'create':\n if (isContentType) {\n counts.newContentTypes++;\n } else {\n counts.newComponents++;\n }\n break;\n case 'update':\n if (isContentType) {\n counts.editedContentTypes++;\n } else {\n counts.editedComponents++;\n }\n break;\n case 'delete':\n if (isContentType) {\n counts.deletedContentTypes++;\n } else {\n counts.deletedComponents++;\n }\n break;\n default:\n break;\n }\n\n if (Array.isArray(type.attributes)) {\n if (type.action === 'delete') {\n counts.deletedFields += type.attributes.length;\n } else {\n type.attributes.forEach((attribute) => {\n if (!attribute || typeof attribute.status !== 'string') {\n return;\n }\n\n switch (attribute.status) {\n case 'NEW':\n counts.newFields++;\n break;\n case 'CHANGED':\n counts.editedFields++;\n break;\n case 'REMOVED':\n counts.deletedFields++;\n break;\n case 'UNCHANGED':\n default:\n break;\n }\n });\n }\n }\n};\n\nexport { stateToRequestData, sortContentType };\n"],"names":["sortContentType","types","sortBy","Object","keys","map","uid","visible","name","title","info","displayName","plugin","to","pluginId","kind","restrictRelationsTo","status","filter","obj","camelCase","stateToRequestData","components","contentTypes","contentStructure","createEmptyContentStructure","initialContentStructure","trackingEventProperties","newContentTypes","editedContentTypes","deletedContentTypes","newComponents","editedComponents","deletedComponents","newFields","editedFields","deletedFields","formattedComponents","values","compo","includes","component","requestFormattedComponent","formatTypeForRequest","eventAction","action","updateEventCounts","formattedContentTypes","contentType","requestFormattedContentType","structureChanged","hasContentStructureChanged","contentStructureRequestPayload","toServerFile","undefined","requestData","removeNullKeys","fromEntries","entries","_","value","Array","isArray","length","formatAttribute","attr","type","targetAttribute","conditions","Error","category","omit","options","renames","attributes","properties","counts","entityType","isContentType","forEach","attribute"],"mappings":";;;;;;AAsBA,MAAMA,kBAAkB,CAACC,KAAAA,GAAAA;IACvB,OAAOC,MAAAA,CACLC,OAAOC,IAAI,CAACH,OACTI,GAAG,CAAC,CAACC,GAAAA,IAAS;AACbC,YAAAA,OAAAA,EAASN,KAAK,CAACK,GAAAA,CAAI,CAACC,OAAO;YAC3BC,IAAAA,EAAMF,GAAAA;AACNG,YAAAA,KAAAA,EAAOR,KAAK,CAACK,GAAAA,CAAI,CAACI,IAAI,CAACC,WAAW;AAClCC,YAAAA,MAAAA,EAAQX,KAAK,CAACK,GAAAA,CAAI,CAACM,MAAM;YACzBN,GAAAA,EAAKA,GAAAA;AACLO,YAAAA,EAAAA,EAAI,CAAC,SAAS,EAAEC,QAAAA,CAAS,eAAe,EAAER,GAAAA,CAAAA,CAAK;AAC/CS,YAAAA,IAAAA,EAAMd,KAAK,CAACK,GAAAA,CAAI,CAACS,IAAI;AACrBC,YAAAA,mBAAAA,EAAqBf,KAAK,CAACK,GAAAA,CAAI,CAACU,mBAAmB;AACnDC,YAAAA,MAAAA,EAAQhB,KAAK,CAACK,GAAAA,CAAI,CAACW;SACrB,CAAA,CAAA,CACCC,MAAM,CAAC,CAACC,GAAAA,GAAQA,GAAAA,KAAQ,IAAA,CAAA,EAC3B,CAACA,GAAAA,GAAQC,SAAAA,CAAUD,GAAAA,CAAIV,KAAK,CAAA,CAAA;AAEhC;AAcA,MAAMY,kBAAAA,GAAqB,CAAC,EAC1BC,UAAU,EACVC,YAAY,EACZC,gBAAAA,GAAmBC,2BAAAA,EAA6B,EAChDC,uBAAAA,GAA0BD,2BAAAA,EAA6B,EAMxD,GAAA;AACC,IAAA,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+ current = parent.get(current);
7
+ }
8
+ // Path compression keeps repeated lookups cheap on long chains.
9
+ let node = name;
10
+ while(parent.get(node) !== current){
11
+ const next = parent.get(node);
12
+ parent.set(node, current);
13
+ node = next;
14
+ }
15
+ return current;
16
+ };
17
+ const union = (parent, a, b)=>{
18
+ if (!parent.has(a)) {
19
+ parent.set(a, a);
20
+ }
21
+ if (!parent.has(b)) {
22
+ parent.set(b, b);
23
+ }
24
+ const rootA = findRoot(parent, a);
25
+ const rootB = findRoot(parent, b);
26
+ if (rootA !== rootB) {
27
+ parent.set(rootB, rootA);
28
+ }
29
+ };
30
+ const buildChain = (uid, renames, hopIndexes)=>{
31
+ // current name -> original name, seeded lazily: a hop whose `oldName` is not
32
+ // yet tracked starts from an original attribute.
33
+ const originalOf = new Map();
34
+ const firstIndexOf = new Map();
35
+ const intermediates = [];
36
+ hopIndexes.forEach((index)=>{
37
+ const { oldName, newName } = renames[index];
38
+ if (!originalOf.has(oldName)) {
39
+ originalOf.set(oldName, oldName);
40
+ firstIndexOf.set(oldName, index);
41
+ }
42
+ const original = originalOf.get(oldName);
43
+ originalOf.delete(oldName);
44
+ originalOf.set(newName, original);
45
+ intermediates.push(newName);
46
+ });
47
+ const pairs = [
48
+ ...originalOf.entries()
49
+ ].filter(([current, original])=>current !== original).map(([current, original])=>({
50
+ oldName: original,
51
+ newName: current
52
+ })).sort((a, b)=>(firstIndexOf.get(a.oldName) ?? 0) - (firstIndexOf.get(b.oldName) ?? 0));
53
+ const finalNames = new Set(originalOf.keys());
54
+ const via = intermediates.filter((name, position)=>!finalNames.has(name) && !firstIndexOf.has(name) && intermediates.indexOf(name) === position);
55
+ return {
56
+ id: `${uid}:chain:${hopIndexes[0]}`,
57
+ hopIndexes,
58
+ pairs,
59
+ via
60
+ };
61
+ };
62
+ /**
63
+ * Groups a type's ordered `renames[]` into chains (see `RenameChain`). Chains
64
+ * are ordered by their first hop; hops inside a chain keep their index order.
65
+ */ const groupRenameChains = (uid, renames)=>{
66
+ const parent = new Map();
67
+ renames.forEach((hop)=>union(parent, hop.oldName, hop.newName));
68
+ const buckets = new Map();
69
+ renames.forEach((hop, index)=>{
70
+ const root = findRoot(parent, hop.oldName);
71
+ const bucket = buckets.get(root);
72
+ if (bucket) {
73
+ bucket.push(index);
74
+ } else {
75
+ buckets.set(root, [
76
+ index
77
+ ]);
78
+ }
79
+ });
80
+ return [
81
+ ...buckets.values()
82
+ ].sort((a, b)=>a[0] - b[0]).map((hopIndexes)=>buildChain(uid, renames, hopIndexes));
83
+ };
84
+
85
+ exports.groupRenameChains = groupRenameChains;
86
+ //# sourceMappingURL=groupRenameChains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groupRenameChains.js","sources":["../../../../../admin/src/components/DataManager/utils/groupRenameChains.ts"],"sourcesContent":["import type { RenameHop } from '../../../types';\n\nexport interface RenamePair {\n oldName: string;\n newName: string;\n}\n\n/**\n * A group of rename hops on one type that share attribute names, transitively:\n * `a -> b`, `b -> c` is one chain, so is the swap `a -> tmp`, `b -> a`,\n * `tmp -> b`, while `a -> b` and `x -> y` are two chains. Consent to preserve\n * data is given per chain, never per hop, because replaying a partial chain\n * either fails or silently skips hops whose target column still exists.\n */\nexport interface RenameChain {\n /** `${uid}:chain:${firstHopIndex}` — stable key for consent decisions. */\n id: string;\n /** Indexes into the type's ordered `renames[]`, ascending. */\n hopIndexes: number[];\n /** Net effect after replaying the chain's hops, in first-appearance order. */\n pairs: RenamePair[];\n /** Names that only ever appear as intermediates (e.g. `tmp`). */\n via: string[];\n}\n\nconst findRoot = (parent: Map<string, string>, name: string): string => {\n let current = name;\n while (parent.get(current) !== current) {\n current = parent.get(current) as string;\n }\n // Path compression keeps repeated lookups cheap on long chains.\n let node = name;\n while (parent.get(node) !== current) {\n const next = parent.get(node) as string;\n parent.set(node, current);\n node = next;\n }\n return current;\n};\n\nconst union = (parent: Map<string, string>, a: string, b: string): void => {\n if (!parent.has(a)) {\n parent.set(a, a);\n }\n if (!parent.has(b)) {\n parent.set(b, b);\n }\n const rootA = findRoot(parent, a);\n const rootB = findRoot(parent, b);\n if (rootA !== rootB) {\n parent.set(rootB, rootA);\n }\n};\n\nconst buildChain = (uid: string, renames: RenameHop[], hopIndexes: number[]): RenameChain => {\n // current name -> original name, seeded lazily: a hop whose `oldName` is not\n // yet tracked starts from an original attribute.\n const originalOf = new Map<string, string>();\n const firstIndexOf = new Map<string, number>();\n const intermediates: string[] = [];\n\n hopIndexes.forEach((index) => {\n const { oldName, newName } = renames[index];\n\n if (!originalOf.has(oldName)) {\n originalOf.set(oldName, oldName);\n firstIndexOf.set(oldName, index);\n }\n\n const original = originalOf.get(oldName) as string;\n originalOf.delete(oldName);\n originalOf.set(newName, original);\n intermediates.push(newName);\n });\n\n const pairs = [...originalOf.entries()]\n .filter(([current, original]) => current !== original)\n .map(([current, original]) => ({ oldName: original, newName: current }))\n .sort((a, b) => (firstIndexOf.get(a.oldName) ?? 0) - (firstIndexOf.get(b.oldName) ?? 0));\n\n const finalNames = new Set(originalOf.keys());\n const via = intermediates.filter(\n (name, position) =>\n !finalNames.has(name) && !firstIndexOf.has(name) && intermediates.indexOf(name) === position\n );\n\n return { id: `${uid}:chain:${hopIndexes[0]}`, hopIndexes, pairs, via };\n};\n\n/**\n * Groups a type's ordered `renames[]` into chains (see `RenameChain`). Chains\n * are ordered by their first hop; hops inside a chain keep their index order.\n */\nexport const groupRenameChains = (uid: string, renames: RenameHop[]): RenameChain[] => {\n const parent = new Map<string, string>();\n renames.forEach((hop) => union(parent, hop.oldName, hop.newName));\n\n const buckets = new Map<string, number[]>();\n renames.forEach((hop, index) => {\n const root = findRoot(parent, hop.oldName);\n const bucket = buckets.get(root);\n if (bucket) {\n bucket.push(index);\n } else {\n buckets.set(root, [index]);\n }\n });\n\n return [...buckets.values()]\n .sort((a, b) => a[0] - b[0])\n .map((hopIndexes) => buildChain(uid, renames, hopIndexes));\n};\n\n/**\n * Maps every hop index of `renames` to the chain it belongs to.\n */\nexport const chainByHopIndex = (chains: RenameChain[]): Map<number, RenameChain> => {\n const byIndex = new Map<number, RenameChain>();\n chains.forEach((chain) => chain.hopIndexes.forEach((index) => byIndex.set(index, chain)));\n return byIndex;\n};\n"],"names":["findRoot","parent","name","current","get","node","next","set","union","a","b","has","rootA","rootB","buildChain","uid","renames","hopIndexes","originalOf","Map","firstIndexOf","intermediates","forEach","index","oldName","newName","original","delete","push","pairs","entries","filter","map","sort","finalNames","Set","keys","via","position","indexOf","id","groupRenameChains","hop","buckets","root","bucket","values"],"mappings":";;AAyBA,MAAMA,QAAAA,GAAW,CAACC,MAAAA,EAA6BC,IAAAA,GAAAA;AAC7C,IAAA,IAAIC,OAAAA,GAAUD,IAAAA;AACd,IAAA,MAAOD,MAAAA,CAAOG,GAAG,CAACD,OAAAA,CAAAA,KAAaA,OAAAA,CAAS;QACtCA,OAAAA,GAAUF,MAAAA,CAAOG,GAAG,CAACD,OAAAA,CAAAA;AACvB,IAAA;;AAEA,IAAA,IAAIE,IAAAA,GAAOH,IAAAA;AACX,IAAA,MAAOD,MAAAA,CAAOG,GAAG,CAACC,IAAAA,CAAAA,KAAUF,OAAAA,CAAS;QACnC,MAAMG,IAAAA,GAAOL,MAAAA,CAAOG,GAAG,CAACC,IAAAA,CAAAA;QACxBJ,MAAAA,CAAOM,GAAG,CAACF,IAAAA,EAAMF,OAAAA,CAAAA;QACjBE,IAAAA,GAAOC,IAAAA;AACT,IAAA;IACA,OAAOH,OAAAA;AACT,CAAA;AAEA,MAAMK,KAAAA,GAAQ,CAACP,MAAAA,EAA6BQ,CAAAA,EAAWC,CAAAA,GAAAA;AACrD,IAAA,IAAI,CAACT,MAAAA,CAAOU,GAAG,CAACF,CAAAA,CAAAA,EAAI;QAClBR,MAAAA,CAAOM,GAAG,CAACE,CAAAA,EAAGA,CAAAA,CAAAA;AAChB,IAAA;AACA,IAAA,IAAI,CAACR,MAAAA,CAAOU,GAAG,CAACD,CAAAA,CAAAA,EAAI;QAClBT,MAAAA,CAAOM,GAAG,C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AA,EAAAA;IACpBH,OAAAA,CAAQM,OAAO,CAAC,CAACoB,GAAAA,EAAKnB,KAAAA,GAAAA;AACpB,QAAA,MAAMqB,IAAAA,GAAO5C,QAAAA,CAASC,MAAAA,EAAQyC,GAAAA,CAAIlB,OAAO,CAAA;QACzC,MAAMqB,MAAAA,GAASF,OAAAA,CAAQvC,GAAG,CAACwC,IAAAA,CAAAA;AAC3B,QAAA,IAAIC,MAAAA,EAAQ;AACVA,YAAAA,MAAAA,CAAOjB,IAAI,CAACL,KAAAA,CAAAA;QACd,CAAA,MAAO;YACLoB,OAAAA,CAAQpC,GAAG,CAACqC,IAAAA,EAAM;AAACrB,gBAAAA;AAAM,aAAA,CAAA;AAC3B,QAAA;AACF,IAAA,CAAA,CAAA;IAEA,OAAO;AAAIoB,QAAAA,GAAAA,OAAAA,CAAQG,MAAM;AAAG,KAAA,CACzBb,IAAI,CAAC,CAACxB,GAAGC,CAAAA,GAAMD,CAAC,CAAC,CAAA,CAAE,GAAGC,CAAC,CAAC,CAAA,CAAE,EAC1BsB,GAAG,CAAC,CAACf,UAAAA,GAAeH,UAAAA,CAAWC,KAAKC,OAAAA,EAASC,UAAAA,CAAAA,CAAAA;AAClD;;;;"}
@@ -0,0 +1,84 @@
1
+ const findRoot = (parent, name)=>{
2
+ let current = name;
3
+ while(parent.get(current) !== current){
4
+ current = parent.get(current);
5
+ }
6
+ // Path compression keeps repeated lookups cheap on long chains.
7
+ let node = name;
8
+ while(parent.get(node) !== current){
9
+ const next = parent.get(node);
10
+ parent.set(node, current);
11
+ node = next;
12
+ }
13
+ return current;
14
+ };
15
+ const union = (parent, a, b)=>{
16
+ if (!parent.has(a)) {
17
+ parent.set(a, a);
18
+ }
19
+ if (!parent.has(b)) {
20
+ parent.set(b, b);
21
+ }
22
+ const rootA = findRoot(parent, a);
23
+ const rootB = findRoot(parent, b);
24
+ if (rootA !== rootB) {
25
+ parent.set(rootB, rootA);
26
+ }
27
+ };
28
+ const buildChain = (uid, renames, hopIndexes)=>{
29
+ // current name -> original name, seeded lazily: a hop whose `oldName` is not
30
+ // yet tracked starts from an original attribute.
31
+ const originalOf = new Map();
32
+ const firstIndexOf = new Map();
33
+ const intermediates = [];
34
+ hopIndexes.forEach((index)=>{
35
+ const { oldName, newName } = renames[index];
36
+ if (!originalOf.has(oldName)) {
37
+ originalOf.set(oldName, oldName);
38
+ firstIndexOf.set(oldName, index);
39
+ }
40
+ const original = originalOf.get(oldName);
41
+ originalOf.delete(oldName);
42
+ originalOf.set(newName, original);
43
+ intermediates.push(newName);
44
+ });
45
+ const pairs = [
46
+ ...originalOf.entries()
47
+ ].filter(([current, original])=>current !== original).map(([current, original])=>({
48
+ oldName: original,
49
+ newName: current
50
+ })).sort((a, b)=>(firstIndexOf.get(a.oldName) ?? 0) - (firstIndexOf.get(b.oldName) ?? 0));
51
+ const finalNames = new Set(originalOf.keys());
52
+ const via = intermediates.filter((name, position)=>!finalNames.has(name) && !firstIndexOf.has(name) && intermediates.indexOf(name) === position);
53
+ return {
54
+ id: `${uid}:chain:${hopIndexes[0]}`,
55
+ hopIndexes,
56
+ pairs,
57
+ via
58
+ };
59
+ };
60
+ /**
61
+ * Groups a type's ordered `renames[]` into chains (see `RenameChain`). Chains
62
+ * are ordered by their first hop; hops inside a chain keep their index order.
63
+ */ const groupRenameChains = (uid, renames)=>{
64
+ const parent = new Map();
65
+ renames.forEach((hop)=>union(parent, hop.oldName, hop.newName));
66
+ const buckets = new Map();
67
+ renames.forEach((hop, index)=>{
68
+ const root = findRoot(parent, hop.oldName);
69
+ const bucket = buckets.get(root);
70
+ if (bucket) {
71
+ bucket.push(index);
72
+ } else {
73
+ buckets.set(root, [
74
+ index
75
+ ]);
76
+ }
77
+ });
78
+ return [
79
+ ...buckets.values()
80
+ ].sort((a, b)=>a[0] - b[0]).map((hopIndexes)=>buildChain(uid, renames, hopIndexes));
81
+ };
82
+
83
+ export { groupRenameChains };
84
+ //# sourceMappingURL=groupRenameChains.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groupRenameChains.mjs","sources":["../../../../../admin/src/components/DataManager/utils/groupRenameChains.ts"],"sourcesContent":["import type { RenameHop } from '../../../types';\n\nexport interface RenamePair {\n oldName: string;\n newName: string;\n}\n\n/**\n * A group of rename hops on one type that share attribute names, transitively:\n * `a -> b`, `b -> c` is one chain, so is the swap `a -> tmp`, `b -> a`,\n * `tmp -> b`, while `a -> b` and `x -> y` are two chains. Consent to preserve\n * data is given per chain, never per hop, because replaying a partial chain\n * either fails or silently skips hops whose target column still exists.\n */\nexport interface RenameChain {\n /** `${uid}:chain:${firstHopIndex}` — stable key for consent decisions. */\n id: string;\n /** Indexes into the type's ordered `renames[]`, ascending. */\n hopIndexes: number[];\n /** Net effect after replaying the chain's hops, in first-appearance order. */\n pairs: RenamePair[];\n /** Names that only ever appear as intermediates (e.g. `tmp`). */\n via: string[];\n}\n\nconst findRoot = (parent: Map<string, string>, name: string): string => {\n let current = name;\n while (parent.get(current) !== current) {\n current = parent.get(current) as string;\n }\n // Path compression keeps repeated lookups cheap on long chains.\n let node = name;\n while (parent.get(node) !== current) {\n const next = parent.get(node) as string;\n parent.set(node, current);\n node = next;\n }\n return current;\n};\n\nconst union = (parent: Map<string, string>, a: string, b: string): void => {\n if (!parent.has(a)) {\n parent.set(a, a);\n }\n if (!parent.has(b)) {\n parent.set(b, b);\n }\n const rootA = findRoot(parent, a);\n const rootB = findRoot(parent, b);\n if (rootA !== rootB) {\n parent.set(rootB, rootA);\n }\n};\n\nconst buildChain = (uid: string, renames: RenameHop[], hopIndexes: number[]): RenameChain => {\n // current name -> original name, seeded lazily: a hop whose `oldName` is not\n // yet tracked starts from an original attribute.\n const originalOf = new Map<string, string>();\n const firstIndexOf = new Map<string, number>();\n const intermediates: string[] = [];\n\n hopIndexes.forEach((index) => {\n const { oldName, newName } = renames[index];\n\n if (!originalOf.has(oldName)) {\n originalOf.set(oldName, oldName);\n firstIndexOf.set(oldName, index);\n }\n\n const original = originalOf.get(oldName) as string;\n originalOf.delete(oldName);\n originalOf.set(newName, original);\n intermediates.push(newName);\n });\n\n const pairs = [...originalOf.entries()]\n .filter(([current, original]) => current !== original)\n .map(([current, original]) => ({ oldName: original, newName: current }))\n .sort((a, b) => (firstIndexOf.get(a.oldName) ?? 0) - (firstIndexOf.get(b.oldName) ?? 0));\n\n const finalNames = new Set(originalOf.keys());\n const via = intermediates.filter(\n (name, position) =>\n !finalNames.has(name) && !firstIndexOf.has(name) && intermediates.indexOf(name) === position\n );\n\n return { id: `${uid}:chain:${hopIndexes[0]}`, hopIndexes, pairs, via };\n};\n\n/**\n * Groups a type's ordered `renames[]` into chains (see `RenameChain`). Chains\n * are ordered by their first hop; hops inside a chain keep their index order.\n */\nexport const groupRenameChains = (uid: string, renames: RenameHop[]): RenameChain[] => {\n const parent = new Map<string, string>();\n renames.forEach((hop) => union(parent, hop.oldName, hop.newName));\n\n const buckets = new Map<string, number[]>();\n renames.forEach((hop, index) => {\n const root = findRoot(parent, hop.oldName);\n const bucket = buckets.get(root);\n if (bucket) {\n bucket.push(index);\n } else {\n buckets.set(root, [index]);\n }\n });\n\n return [...buckets.values()]\n .sort((a, b) => a[0] - b[0])\n .map((hopIndexes) => buildChain(uid, renames, hopIndexes));\n};\n\n/**\n * Maps every hop index of `renames` to the chain it belongs to.\n */\nexport const chainByHopIndex = (chains: RenameChain[]): Map<number, RenameChain> => {\n const byIndex = new Map<number, RenameChain>();\n chains.forEach((chain) => chain.hopIndexes.forEach((index) => byIndex.set(index, chain)));\n return byIndex;\n};\n"],"names":["findRoot","parent","name","current","get","node","next","set","union","a","b","has","rootA","rootB","buildChain","uid","renames","hopIndexes","originalOf","Map","firstIndexOf","intermediates","forEach","index","oldName","newName","original","delete","push","pairs","entries","filter","map","sort","finalNames","Set","keys","via","position","indexOf","id","groupRenameChains","hop","buckets","root","bucket","values"],"mappings":"AAyBA,MAAMA,QAAAA,GAAW,CAACC,MAAAA,EAA6BC,IAAAA,GAAAA;AAC7C,IAAA,IAA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rB,gBAAAA;AAAM,aAAA,CAAA;AAC3B,QAAA;AACF,IAAA,CAAA,CAAA;IAEA,OAAO;AAAIoB,QAAAA,GAAAA,OAAAA,CAAQG,MAAM;AAAG,KAAA,CACzBb,IAAI,CAAC,CAACxB,GAAGC,CAAAA,GAAMD,CAAC,CAAC,CAAA,CAAE,GAAGC,CAAC,CAAC,CAAA,CAAE,EAC1BsB,GAAG,CAAC,CAACf,UAAAA,GAAeH,UAAAA,CAAWC,KAAKC,OAAAA,EAASC,UAAAA,CAAAA,CAAAA;AAClD;;;;"}
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var getRelationType = require('../../../utils/getRelationType.js');
4
+
5
+ /**
6
+ * Whether `newAttribute` keeps the storage of `previousAttribute`, i.e. whether
7
+ * renaming the underlying database artifact is enough to carry the data over.
8
+ * A type change (or a relation retargeted or its direction switched, or a
9
+ * component swapped) must go through the regular drop-and-recreate path:
10
+ * renaming the column and letting schema sync alter its type in place can fail
11
+ * at startup on Postgres/MySQL.
12
+ */ const isStorageCompatibleRename = (previousAttribute, newAttribute)=>{
13
+ if (previousAttribute.type !== newAttribute.type) {
14
+ return false;
15
+ }
16
+ if (previousAttribute.type === 'relation' && newAttribute.type === 'relation') {
17
+ return previousAttribute.relation === newAttribute.relation && previousAttribute.target === newAttribute.target && // `manyWay` and a bidirectional `oneToMany` share `relation: 'oneToMany'`
18
+ // but own their join table differently, so switching direction is not a
19
+ // plain rename.
20
+ getRelationType.getRelationType(previousAttribute.relation, previousAttribute.targetAttribute) === getRelationType.getRelationType(newAttribute.relation, newAttribute.targetAttribute);
21
+ }
22
+ if (previousAttribute.type === 'component' && newAttribute.type === 'component') {
23
+ return previousAttribute.component === newAttribute.component && Boolean(previousAttribute.repeatable) === Boolean(newAttribute.repeatable);
24
+ }
25
+ return true;
26
+ };
27
+
28
+ exports.isStorageCompatibleRename = isStorageCompatibleRename;
29
+ //# sourceMappingURL=isStorageCompatibleRename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isStorageCompatibleRename.js","sources":["../../../../../admin/src/components/DataManager/utils/isStorageCompatibleRename.ts"],"sourcesContent":["import { getRelationType } from '../../../utils/getRelationType';\n\nimport type { AnyAttribute } from '../../../types';\n\n/**\n * Whether `newAttribute` keeps the storage of `previousAttribute`, i.e. whether\n * renaming the underlying database artifact is enough to carry the data over.\n * A type change (or a relation retargeted or its direction switched, or a\n * component swapped) must go through the regular drop-and-recreate path:\n * renaming the column and letting schema sync alter its type in place can fail\n * at startup on Postgres/MySQL.\n */\nexport const isStorageCompatibleRename = (\n previousAttribute: AnyAttribute,\n newAttribute: AnyAttribute\n): boolean => {\n if (previousAttribute.type !== newAttribute.type) {\n return false;\n }\n\n if (previousAttribute.type === 'relation' && newAttribute.type === 'relation') {\n return (\n previousAttribute.relation === newAttribute.relation &&\n previousAttribute.target === newAttribute.target &&\n // `manyWay` and a bidirectional `oneToMany` share `relation: 'oneToMany'`\n // but own their join table differently, so switching direction is not a\n // plain rename.\n getRelationType(previousAttribute.relation, previousAttribute.targetAttribute) ===\n getRelationType(newAttribute.relation, newAttribute.targetAttribute)\n );\n }\n\n if (previousAttribute.type === 'component' && newAttribute.type === 'component') {\n return (\n previousAttribute.component === newAttribute.component &&\n Boolean(previousAttribute.repeatable) === Boolean(newAttribute.repeatable)\n );\n }\n\n return true;\n};\n"],"names":["isStorageCompatibleRename","previousAttribute","newAttribute","type","relation","target","getRelationType","targetAttribute","component","Boolean","repeatable"],"mappings":";;;;AAIA;;;;;;;AAOC,IACM,MAAMA,yBAAAA,GAA4B,CACvCC,iBAAAA,EACAC,YAAAA,GAAAA;AAEA,IAAA,IAAID,iBAAAA,CAAkBE,IAAI,KAAKD,YAAAA,CAAaC,IAAI,EAAE;QAChD,OAAO,KAAA;AACT,IAAA;AAEA,IAAA,IAAIF,kBAAkBE,IAAI,KAAK,cAAcD,YAAAA,CAAaC,IAAI,KAAK,UAAA,EAAY;AAC7E,QAAA,OACEF,iBAAAA,CAAkBG,QAAQ,KAAKF,YAAAA,CAAaE,QAAQ,IACpDH,iBAAAA,CAAkBI,MAAM,KAAKH,YAAAA,CAAaG,MAAM;;;QAIhDC,+BAAAA,CAAgBL,iBAAAA,CAAkBG,QAAQ,EAAEH,iBAAAA,CAAkBM,eAAe,CAAA,KAC3ED,+BAAAA,CAAgBJ,YAAAA,CAAaE,QAAQ,EAAEF,YAAAA,CAAaK,eAAe,CAAA;AAEzE,IAAA;AAEA,IAAA,IAAIN,kBAAkBE,IAAI,KAAK,eAAeD,YAAAA,CAAaC,IAAI,KAAK,WAAA,EAAa;AAC/E,QAAA,OACEF,iBAAAA,CAAkBO,SAAS,KAAKN,YAAAA,CAAaM,SAAS,IACtDC,OAAAA,CAAQR,iBAAAA,CAAkBS,UAAU,CAAA,KAAMD,OAAAA,CAAQP,YAAAA,CAAaQ,UAAU,CAAA;AAE7E,IAAA;IAEA,OAAO,IAAA;AACT;;;;"}
@@ -0,0 +1,27 @@
1
+ import { getRelationType } from '../../../utils/getRelationType.mjs';
2
+
3
+ /**
4
+ * Whether `newAttribute` keeps the storage of `previousAttribute`, i.e. whether
5
+ * renaming the underlying database artifact is enough to carry the data over.
6
+ * A type change (or a relation retargeted or its direction switched, or a
7
+ * component swapped) must go through the regular drop-and-recreate path:
8
+ * renaming the column and letting schema sync alter its type in place can fail
9
+ * at startup on Postgres/MySQL.
10
+ */ const isStorageCompatibleRename = (previousAttribute, newAttribute)=>{
11
+ if (previousAttribute.type !== newAttribute.type) {
12
+ return false;
13
+ }
14
+ if (previousAttribute.type === 'relation' && newAttribute.type === 'relation') {
15
+ return previousAttribute.relation === newAttribute.relation && previousAttribute.target === newAttribute.target && // `manyWay` and a bidirectional `oneToMany` share `relation: 'oneToMany'`
16
+ // but own their join table differently, so switching direction is not a
17
+ // plain rename.
18
+ getRelationType(previousAttribute.relation, previousAttribute.targetAttribute) === getRelationType(newAttribute.relation, newAttribute.targetAttribute);
19
+ }
20
+ if (previousAttribute.type === 'component' && newAttribute.type === 'component') {
21
+ return previousAttribute.component === newAttribute.component && Boolean(previousAttribute.repeatable) === Boolean(newAttribute.repeatable);
22
+ }
23
+ return true;
24
+ };
25
+
26
+ export { isStorageCompatibleRename };
27
+ //# sourceMappingURL=isStorageCompatibleRename.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isStorageCompatibleRename.mjs","sources":["../../../../../admin/src/components/DataManager/utils/isStorageCompatibleRename.ts"],"sourcesContent":["import { getRelationType } from '../../../utils/getRelationType';\n\nimport type { AnyAttribute } from '../../../types';\n\n/**\n * Whether `newAttribute` keeps the storage of `previousAttribute`, i.e. whether\n * renaming the underlying database artifact is enough to carry the data over.\n * A type change (or a relation retargeted or its direction switched, or a\n * component swapped) must go through the regular drop-and-recreate path:\n * renaming the column and letting schema sync alter its type in place can fail\n * at startup on Postgres/MySQL.\n */\nexport const isStorageCompatibleRename = (\n previousAttribute: AnyAttribute,\n newAttribute: AnyAttribute\n): boolean => {\n if (previousAttribute.type !== newAttribute.type) {\n return false;\n }\n\n if (previousAttribute.type === 'relation' && newAttribute.type === 'relation') {\n return (\n previousAttribute.relation === newAttribute.relation &&\n previousAttribute.target === newAttribute.target &&\n // `manyWay` and a bidirectional `oneToMany` share `relation: 'oneToMany'`\n // but own their join table differently, so switching direction is not a\n // plain rename.\n getRelationType(previousAttribute.relation, previousAttribute.targetAttribute) ===\n getRelationType(newAttribute.relation, newAttribute.targetAttribute)\n );\n }\n\n if (previousAttribute.type === 'component' && newAttribute.type === 'component') {\n return (\n previousAttribute.component === newAttribute.component &&\n Boolean(previousAttribute.repeatable) === Boolean(newAttribute.repeatable)\n );\n }\n\n return true;\n};\n"],"names":["isStorageCompatibleRename","previousAttribute","newAttribute","type","relation","target","getRelationType","targetAttribute","component","Boolean","repeatable"],"mappings":";;AAIA;;;;;;;AAOC,IACM,MAAMA,yBAAAA,GAA4B,CACvCC,iBAAAA,EACAC,YAAAA,GAAAA;AAEA,IAAA,IAAID,iBAAAA,CAAkBE,IAAI,KAAKD,YAAAA,CAAaC,IAAI,EAAE;QAChD,OAAO,KAAA;AACT,IAAA;AAEA,IAAA,IAAIF,kBAAkBE,IAAI,KAAK,cAAcD,YAAAA,CAAaC,IAAI,KAAK,UAAA,EAAY;AAC7E,QAAA,OACEF,iBAAAA,CAAkBG,QAAQ,KAAKF,YAAAA,CAAaE,QAAQ,IACpDH,iBAAAA,CAAkBI,MAAM,KAAKH,YAAAA,CAAaG,MAAM;;;QAIhDC,eAAAA,CAAgBL,iBAAAA,CAAkBG,QAAQ,EAAEH,iBAAAA,CAAkBM,eAAe,CAAA,KAC3ED,eAAAA,CAAgBJ,YAAAA,CAAaE,QAAQ,EAAEF,YAAAA,CAAaK,eAAe,CAAA;AAEzE,IAAA;AAEA,IAAA,IAAIN,kBAAkBE,IAAI,KAAK,eAAeD,YAAAA,CAAaC,IAAI,KAAK,WAAA,EAAa;AAC/E,QAAA,OACEF,iBAAAA,CAAkBO,SAAS,KAAKN,YAAAA,CAAaM,SAAS,IACtDC,OAAAA,CAAQR,iBAAAA,CAAkBS,UAAU,CAAA,KAAMD,OAAAA,CAAQP,YAAAA,CAAaQ,UAAU,CAAA;AAE7E,IAAA;IAEA,OAAO,IAAA;AACT;;;;"}
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var RenameMigrationModal = require('../RenameMigrationModal.js');
4
+
5
+ /**
6
+ * Decides whether a single rename hop (`oldName -> newName`) performed in the
7
+ * attribute form needs the user's consent to preserve data, given the hops
8
+ * already recorded on the type and the names of chains the user has declined.
9
+ *
10
+ * Consent inherits along a chain, so a chain is always accepted or declined as
11
+ * a whole (replaying a partial chain either fails or silently skips hops):
12
+ *
13
+ * 1. A hop that joins an accepted chain — it continues a recorded hop
14
+ * (`oldName` was produced by one) or swaps into a name a recorded hop
15
+ * vacated (`newName`) — is accepted without a prompt.
16
+ * 2. A hop that touches a declined name is declined without a prompt.
17
+ * 3. Otherwise the mode decides; `prompt-after-edit` asks the user.
18
+ */ const resolveAfterEditRenameConsent = ({ renames, declinedRenameNames, oldName, newName, mode })=>{
19
+ const joinsAcceptedChain = renames.some((hop)=>hop.newName === oldName || hop.oldName === newName);
20
+ if (joinsAcceptedChain) {
21
+ return 'accept';
22
+ }
23
+ const declined = new Set(declinedRenameNames);
24
+ if (declined.has(oldName) || declined.has(newName)) {
25
+ return 'decline';
26
+ }
27
+ const decision = RenameMigrationModal.getAttributeRenameDecision(mode);
28
+ if (decision === 'prompt') {
29
+ return 'prompt';
30
+ }
31
+ return decision ? 'accept' : 'decline';
32
+ };
33
+
34
+ exports.resolveAfterEditRenameConsent = resolveAfterEditRenameConsent;
35
+ //# sourceMappingURL=resolveAfterEditRenameConsent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAfterEditRenameConsent.js","sources":["../../../../../admin/src/components/DataManager/utils/resolveAfterEditRenameConsent.ts"],"sourcesContent":["import {\n getAttributeRenameDecision,\n type AttributeRenameMigrationMode,\n} from '../RenameMigrationModal';\n\nimport type { RenameHop } from '../../../types';\n\nexport type AfterEditRenameConsent = 'accept' | 'decline' | 'prompt';\n\n/**\n * Decides whether a single rename hop (`oldName -> newName`) performed in the\n * attribute form needs the user's consent to preserve data, given the hops\n * already recorded on the type and the names of chains the user has declined.\n *\n * Consent inherits along a chain, so a chain is always accepted or declined as\n * a whole (replaying a partial chain either fails or silently skips hops):\n *\n * 1. A hop that joins an accepted chain — it continues a recorded hop\n * (`oldName` was produced by one) or swaps into a name a recorded hop\n * vacated (`newName`) — is accepted without a prompt.\n * 2. A hop that touches a declined name is declined without a prompt.\n * 3. Otherwise the mode decides; `prompt-after-edit` asks the user.\n */\nexport const resolveAfterEditRenameConsent = ({\n renames,\n declinedRenameNames,\n oldName,\n newName,\n mode,\n}: {\n renames: RenameHop[];\n declinedRenameNames: string[];\n oldName: string;\n newName: string;\n mode: AttributeRenameMigrationMode;\n}): AfterEditRenameConsent => {\n const joinsAcceptedChain = renames.some(\n (hop) => hop.newName === oldName || hop.oldName === newName\n );\n if (joinsAcceptedChain) {\n return 'accept';\n }\n\n const declined = new Set(declinedRenameNames);\n if (declined.has(oldName) || declined.has(newName)) {\n return 'decline';\n }\n\n const decision = getAttributeRenameDecision(mode);\n if (decision === 'prompt') {\n return 'prompt';\n }\n\n return decision ? 'accept' : 'decline';\n};\n"],"names":["resolveAfterEditRenameConsent","renames","declinedRenameNames","oldName","newName","mode","joinsAcceptedChain","some","hop","declined","Set","has","decision","getAttributeRenameDecision"],"mappings":";;;;AASA;;;;;;;;;;;;;AAaC,IACM,MAAMA,6BAAAA,GAAgC,CAAC,EAC5CC,OAAO,EACPC,mBAAmB,EACnBC,OAAO,EACPC,OAAO,EACPC,IAAI,EAOL,GAAA;AACC,IAAA,MAAMC,kBAAAA,GAAqBL,OAAAA,CAAQM,IAAI,CACrC,CAACC,GAAAA,GAAQA,GAAAA,CAAIJ,OAAO,KAAKD,OAAAA,IAAWK,GAAAA,CAAIL,OAAO,KAAKC,OAAAA,CAAAA;AAEtD,IAAA,IAAIE,kBAAAA,EAAoB;QACtB,OAAO,QAAA;AACT,IAAA;IAEA,MAAMG,QAAAA,GAAW,IAAIC,GAAAA,CAAIR,mBAAAA,CAAAA;AACzB,IAAA,IAAIO,SAASE,GAAG,CAACR,YAAYM,QAAAA,CAASE,GAAG,CAACP,OAAAA,CAAAA,EAAU;QAClD,OAAO,SAAA;AACT,IAAA;AAEA,IAAA,MAAMQ,WAAWC,+CAAAA,CAA2BR,IAAAA,CAAAA;AAC5C,IAAA,IAAIO,aAAa,QAAA,EAAU;QACzB,OAAO,QAAA;AACT,IAAA;AAEA,IAAA,OAAOA,WAAW,QAAA,GAAW,SAAA;AAC/B;;;;"}
@@ -0,0 +1,33 @@
1
+ import { getAttributeRenameDecision } from '../RenameMigrationModal.mjs';
2
+
3
+ /**
4
+ * Decides whether a single rename hop (`oldName -> newName`) performed in the
5
+ * attribute form needs the user's consent to preserve data, given the hops
6
+ * already recorded on the type and the names of chains the user has declined.
7
+ *
8
+ * Consent inherits along a chain, so a chain is always accepted or declined as
9
+ * a whole (replaying a partial chain either fails or silently skips hops):
10
+ *
11
+ * 1. A hop that joins an accepted chain — it continues a recorded hop
12
+ * (`oldName` was produced by one) or swaps into a name a recorded hop
13
+ * vacated (`newName`) — is accepted without a prompt.
14
+ * 2. A hop that touches a declined name is declined without a prompt.
15
+ * 3. Otherwise the mode decides; `prompt-after-edit` asks the user.
16
+ */ const resolveAfterEditRenameConsent = ({ renames, declinedRenameNames, oldName, newName, mode })=>{
17
+ const joinsAcceptedChain = renames.some((hop)=>hop.newName === oldName || hop.oldName === newName);
18
+ if (joinsAcceptedChain) {
19
+ return 'accept';
20
+ }
21
+ const declined = new Set(declinedRenameNames);
22
+ if (declined.has(oldName) || declined.has(newName)) {
23
+ return 'decline';
24
+ }
25
+ const decision = getAttributeRenameDecision(mode);
26
+ if (decision === 'prompt') {
27
+ return 'prompt';
28
+ }
29
+ return decision ? 'accept' : 'decline';
30
+ };
31
+
32
+ export { resolveAfterEditRenameConsent };
33
+ //# sourceMappingURL=resolveAfterEditRenameConsent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAfterEditRenameConsent.mjs","sources":["../../../../../admin/src/components/DataManager/utils/resolveAfterEditRenameConsent.ts"],"sourcesContent":["import {\n getAttributeRenameDecision,\n type AttributeRenameMigrationMode,\n} from '../RenameMigrationModal';\n\nimport type { RenameHop } from '../../../types';\n\nexport type AfterEditRenameConsent = 'accept' | 'decline' | 'prompt';\n\n/**\n * Decides whether a single rename hop (`oldName -> newName`) performed in the\n * attribute form needs the user's consent to preserve data, given the hops\n * already recorded on the type and the names of chains the user has declined.\n *\n * Consent inherits along a chain, so a chain is always accepted or declined as\n * a whole (replaying a partial chain either fails or silently skips hops):\n *\n * 1. A hop that joins an accepted chain — it continues a recorded hop\n * (`oldName` was produced by one) or swaps into a name a recorded hop\n * vacated (`newName`) — is accepted without a prompt.\n * 2. A hop that touches a declined name is declined without a prompt.\n * 3. Otherwise the mode decides; `prompt-after-edit` asks the user.\n */\nexport const resolveAfterEditRenameConsent = ({\n renames,\n declinedRenameNames,\n oldName,\n newName,\n mode,\n}: {\n renames: RenameHop[];\n declinedRenameNames: string[];\n oldName: string;\n newName: string;\n mode: AttributeRenameMigrationMode;\n}): AfterEditRenameConsent => {\n const joinsAcceptedChain = renames.some(\n (hop) => hop.newName === oldName || hop.oldName === newName\n );\n if (joinsAcceptedChain) {\n return 'accept';\n }\n\n const declined = new Set(declinedRenameNames);\n if (declined.has(oldName) || declined.has(newName)) {\n return 'decline';\n }\n\n const decision = getAttributeRenameDecision(mode);\n if (decision === 'prompt') {\n return 'prompt';\n }\n\n return decision ? 'accept' : 'decline';\n};\n"],"names":["resolveAfterEditRenameConsent","renames","declinedRenameNames","oldName","newName","mode","joinsAcceptedChain","some","hop","declined","Set","has","decision","getAttributeRenameDecision"],"mappings":";;AASA;;;;;;;;;;;;;AAaC,IACM,MAAMA,6BAAAA,GAAgC,CAAC,EAC5CC,OAAO,EACPC,mBAAmB,EACnBC,OAAO,EACPC,OAAO,EACPC,IAAI,EAOL,GAAA;AACC,IAAA,MAAMC,kBAAAA,GAAqBL,OAAAA,CAAQM,IAAI,CACrC,CAACC,GAAAA,GAAQA,GAAAA,CAAIJ,OAAO,KAAKD,OAAAA,IAAWK,GAAAA,CAAIL,OAAO,KAAKC,OAAAA,CAAAA;AAEtD,IAAA,IAAIE,kBAAAA,EAAoB;QACtB,OAAO,QAAA;AACT,IAAA;IAEA,MAAMG,QAAAA,GAAW,IAAIC,GAAAA,CAAIR,mBAAAA,CAAAA;AACzB,IAAA,IAAIO,SAASE,GAAG,CAACR,YAAYM,QAAAA,CAASE,GAAG,CAACP,OAAAA,CAAAA,EAAU;QAClD,OAAO,SAAA;AACT,IAAA;AAEA,IAAA,MAAMQ,WAAWC,0BAAAA,CAA2BR,IAAAA,CAAAA;AAC5C,IAAA,IAAIO,aAAa,QAAA,EAAU;QACzB,OAAO,QAAA;AACT,IAAA;AAEA,IAAA,OAAOA,WAAW,QAAA,GAAW,SAAA;AAC/B;;;;"}
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const hopsOf = (chain, renames)=>chain.hopIndexes.map((index)=>renames[index]);
4
+ /**
5
+ * Buckets incoming rename chains (e.g. declared by the AI chat) by the consent
6
+ * the user already gave for the hops recorded on the type, using the same rules
7
+ * as the per-edit prompt (see `resolveAfterEditRenameConsent`): a chain that
8
+ * continues a recorded hop or swaps into a name one vacated is kept, a chain
9
+ * touching a declined name is declined, anything else needs a prompt.
10
+ */ const splitChainsByInheritedConsent = ({ recorded, declinedRenameNames, chains, renames })=>{
11
+ const declined = new Set(declinedRenameNames);
12
+ const result = {
13
+ keep: [],
14
+ decline: [],
15
+ prompt: []
16
+ };
17
+ chains.forEach((chain)=>{
18
+ const hops = hopsOf(chain, renames);
19
+ const joinsAcceptedChain = hops.some((hop)=>recorded.some((known)=>known.newName === hop.oldName || known.oldName === hop.newName));
20
+ if (joinsAcceptedChain) {
21
+ result.keep.push(chain);
22
+ return;
23
+ }
24
+ const touchesDeclinedName = hops.some((hop)=>declined.has(hop.oldName) || declined.has(hop.newName));
25
+ if (touchesDeclinedName) {
26
+ result.decline.push(chain);
27
+ return;
28
+ }
29
+ result.prompt.push(chain);
30
+ });
31
+ return result;
32
+ };
33
+ /** Every attribute name a set of chains touches, deduplicated, in hop order. */ const namesOfChains = (chains, renames)=>{
34
+ const names = new Set();
35
+ chains.forEach((chain)=>{
36
+ hopsOf(chain, renames).forEach((hop)=>{
37
+ names.add(hop.oldName);
38
+ names.add(hop.newName);
39
+ });
40
+ });
41
+ return [
42
+ ...names
43
+ ];
44
+ };
45
+
46
+ exports.namesOfChains = namesOfChains;
47
+ exports.splitChainsByInheritedConsent = splitChainsByInheritedConsent;
48
+ //# sourceMappingURL=splitChainsByInheritedConsent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitChainsByInheritedConsent.js","sources":["../../../../../admin/src/components/DataManager/utils/splitChainsByInheritedConsent.ts"],"sourcesContent":["import type { RenameChain } from './groupRenameChains';\nimport type { RenameHop } from '../../../types';\n\nexport interface SplitChains {\n /** Chains that join a chain the user already accepted: kept without a prompt. */\n keep: RenameChain[];\n /** Chains touching a name the user already declined: dropped without a prompt. */\n decline: RenameChain[];\n /** Chains with no prior decision: the user has to be asked. */\n prompt: RenameChain[];\n}\n\nconst hopsOf = (chain: RenameChain, renames: RenameHop[]): RenameHop[] =>\n chain.hopIndexes.map((index) => renames[index]);\n\n/**\n * Buckets incoming rename chains (e.g. declared by the AI chat) by the consent\n * the user already gave for the hops recorded on the type, using the same rules\n * as the per-edit prompt (see `resolveAfterEditRenameConsent`): a chain that\n * continues a recorded hop or swaps into a name one vacated is kept, a chain\n * touching a declined name is declined, anything else needs a prompt.\n */\nexport const splitChainsByInheritedConsent = ({\n recorded,\n declinedRenameNames,\n chains,\n renames,\n}: {\n recorded: RenameHop[];\n declinedRenameNames: string[];\n chains: RenameChain[];\n /** The ordered hops the chains index into. */\n renames: RenameHop[];\n}): SplitChains => {\n const declined = new Set(declinedRenameNames);\n const result: SplitChains = { keep: [], decline: [], prompt: [] };\n\n chains.forEach((chain) => {\n const hops = hopsOf(chain, renames);\n\n const joinsAcceptedChain = hops.some((hop) =>\n recorded.some((known) => known.newName === hop.oldName || known.oldName === hop.newName)\n );\n if (joinsAcceptedChain) {\n result.keep.push(chain);\n return;\n }\n\n const touchesDeclinedName = hops.some(\n (hop) => declined.has(hop.oldName) || declined.has(hop.newName)\n );\n if (touchesDeclinedName) {\n result.decline.push(chain);\n return;\n }\n\n result.prompt.push(chain);\n });\n\n return result;\n};\n\n/** Every attribute name a set of chains touches, deduplicated, in hop order. */\nexport const namesOfChains = (chains: RenameChain[], renames: RenameHop[]): string[] => {\n const names = new Set<string>();\n chains.forEach((chain) => {\n hopsOf(chain, renames).forEach((hop) => {\n names.add(hop.oldName);\n names.add(hop.newName);\n });\n });\n return [...names];\n};\n"],"names":["hopsOf","chain","renames","hopIndexes","map","index","splitChainsByInheritedConsent","recorded","declinedRenameNames","chains","declined","Set","result","keep","decline","prompt","forEach","hops","joinsAcceptedChain","some","hop","known","newName","oldName","push","touchesDeclinedName","has","namesOfChains","names","add"],"mappings":";;AAYA,MAAMA,MAAAA,GAAS,CAACC,KAAAA,EAAoBC,OAAAA,GAClCD,KAAAA,CAAME,UAAU,CAACC,GAAG,CAAC,CAACC,KAAAA,GAAUH,OAAO,CAACG,KAAAA,CAAM,CAAA;AAEhD;;;;;;AAMC,IACM,MAAMC,6BAAAA,GAAgC,CAAC,EAC5CC,QAAQ,EACRC,mBAAmB,EACnBC,MAAM,EACNP,OAAO,EAOR,GAAA;IACC,MAAMQ,QAAAA,GAAW,IAAIC,GAAAA,CAAIH,mBAAAA,CAAAA;AACzB,IAAA,MAAMI,MAAAA,GAAsB;AAAEC,QAAAA,IAAAA,EAAM,EAAE;AAAEC,QAAAA,OAAAA,EAAS,EAAE;AAAEC,QAAAA,MAAAA,EAAQ;AAAG,KAAA;IAEhEN,MAAAA,CAAOO,OAAO,CAAC,CAACf,KAAAA,GAAAA;QACd,MAAMgB,IAAAA,GAAOjB,OAAOC,KAAAA,EAAOC,OAAAA,CAAAA;QAE3B,MAAMgB,kBAAAA,GAAqBD,KAAKE,IAAI,CAAC,CAACC,GAAAA,GACpCb,QAAAA,CAASY,IAAI,CAAC,CAACE,QAAUA,KAAAA,CAAMC,OAAO,KAAKF,GAAAA,CAAIG,OAAO,IAAIF,KAAAA,CAAME,OAAO,KAAKH,GAAAA,CAAIE,OAAO,CAAA,CAAA;AAEzF,QAAA,IAAIJ,kBAAAA,EAAoB;YACtBN,MAAAA,CAAOC,IAAI,CAACW,IAAI,CAACvB,KAAAA,CAAAA;AACjB,YAAA;AACF,QAAA;AAEA,QAAA,MAAMwB,sBAAsBR,IAAAA,CAAKE,IAAI,CACnC,CAACC,MAAQV,QAAAA,CAASgB,GAAG,CAACN,GAAAA,CAAIG,OAAO,CAAA,IAAKb,QAAAA,CAASgB,GAAG,CAACN,IAAIE,OAAO,CAAA,CAAA;AAEhE,QAAA,IAAIG,mBAAAA,EAAqB;YACvBb,MAAAA,CAAOE,OAAO,CAACU,IAAI,CAACvB,KAAAA,CAAAA;AACpB,YAAA;AACF,QAAA;QAEAW,MAAAA,CAAOG,MAAM,CAACS,IAAI,CAACvB,KAAAA,CAAAA;AACrB,IAAA,CAAA,CAAA;IAEA,OAAOW,MAAAA;AACT;AAEA,iFACO,MAAMe,aAAAA,GAAgB,CAAClB,MAAAA,EAAuBP,OAAAA,GAAAA;AACnD,IAAA,MAAM0B,QAAQ,IAAIjB,GAAAA,EAAAA;IAClBF,MAAAA,CAAOO,OAAO,CAAC,CAACf,KAAAA,GAAAA;AACdD,QAAAA,MAAAA,CAAOC,KAAAA,EAAOC,OAAAA,CAAAA,CAASc,OAAO,CAAC,CAACI,GAAAA,GAAAA;YAC9BQ,KAAAA,CAAMC,GAAG,CAACT,GAAAA,CAAIG,OAAO,CAAA;YACrBK,KAAAA,CAAMC,GAAG,CAACT,GAAAA,CAAIE,OAAO,CAAA;AACvB,QAAA,CAAA,CAAA;AACF,IAAA,CAAA,CAAA;IACA,OAAO;AAAIM,QAAAA,GAAAA;AAAM,KAAA;AACnB;;;;;"}
@@ -0,0 +1,45 @@
1
+ const hopsOf = (chain, renames)=>chain.hopIndexes.map((index)=>renames[index]);
2
+ /**
3
+ * Buckets incoming rename chains (e.g. declared by the AI chat) by the consent
4
+ * the user already gave for the hops recorded on the type, using the same rules
5
+ * as the per-edit prompt (see `resolveAfterEditRenameConsent`): a chain that
6
+ * continues a recorded hop or swaps into a name one vacated is kept, a chain
7
+ * touching a declined name is declined, anything else needs a prompt.
8
+ */ const splitChainsByInheritedConsent = ({ recorded, declinedRenameNames, chains, renames })=>{
9
+ const declined = new Set(declinedRenameNames);
10
+ const result = {
11
+ keep: [],
12
+ decline: [],
13
+ prompt: []
14
+ };
15
+ chains.forEach((chain)=>{
16
+ const hops = hopsOf(chain, renames);
17
+ const joinsAcceptedChain = hops.some((hop)=>recorded.some((known)=>known.newName === hop.oldName || known.oldName === hop.newName));
18
+ if (joinsAcceptedChain) {
19
+ result.keep.push(chain);
20
+ return;
21
+ }
22
+ const touchesDeclinedName = hops.some((hop)=>declined.has(hop.oldName) || declined.has(hop.newName));
23
+ if (touchesDeclinedName) {
24
+ result.decline.push(chain);
25
+ return;
26
+ }
27
+ result.prompt.push(chain);
28
+ });
29
+ return result;
30
+ };
31
+ /** Every attribute name a set of chains touches, deduplicated, in hop order. */ const namesOfChains = (chains, renames)=>{
32
+ const names = new Set();
33
+ chains.forEach((chain)=>{
34
+ hopsOf(chain, renames).forEach((hop)=>{
35
+ names.add(hop.oldName);
36
+ names.add(hop.newName);
37
+ });
38
+ });
39
+ return [
40
+ ...names
41
+ ];
42
+ };
43
+
44
+ export { namesOfChains, splitChainsByInheritedConsent };
45
+ //# sourceMappingURL=splitChainsByInheritedConsent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitChainsByInheritedConsent.mjs","sources":["../../../../../admin/src/components/DataManager/utils/splitChainsByInheritedConsent.ts"],"sourcesContent":["import type { RenameChain } from './groupRenameChains';\nimport type { RenameHop } from '../../../types';\n\nexport interface SplitChains {\n /** Chains that join a chain the user already accepted: kept without a prompt. */\n keep: RenameChain[];\n /** Chains touching a name the user already declined: dropped without a prompt. */\n decline: RenameChain[];\n /** Chains with no prior decision: the user has to be asked. */\n prompt: RenameChain[];\n}\n\nconst hopsOf = (chain: RenameChain, renames: RenameHop[]): RenameHop[] =>\n chain.hopIndexes.map((index) => renames[index]);\n\n/**\n * Buckets incoming rename chains (e.g. declared by the AI chat) by the consent\n * the user already gave for the hops recorded on the type, using the same rules\n * as the per-edit prompt (see `resolveAfterEditRenameConsent`): a chain that\n * continues a recorded hop or swaps into a name one vacated is kept, a chain\n * touching a declined name is declined, anything else needs a prompt.\n */\nexport const splitChainsByInheritedConsent = ({\n recorded,\n declinedRenameNames,\n chains,\n renames,\n}: {\n recorded: RenameHop[];\n declinedRenameNames: string[];\n chains: RenameChain[];\n /** The ordered hops the chains index into. */\n renames: RenameHop[];\n}): SplitChains => {\n const declined = new Set(declinedRenameNames);\n const result: SplitChains = { keep: [], decline: [], prompt: [] };\n\n chains.forEach((chain) => {\n const hops = hopsOf(chain, renames);\n\n const joinsAcceptedChain = hops.some((hop) =>\n recorded.some((known) => known.newName === hop.oldName || known.oldName === hop.newName)\n );\n if (joinsAcceptedChain) {\n result.keep.push(chain);\n return;\n }\n\n const touchesDeclinedName = hops.some(\n (hop) => declined.has(hop.oldName) || declined.has(hop.newName)\n );\n if (touchesDeclinedName) {\n result.decline.push(chain);\n return;\n }\n\n result.prompt.push(chain);\n });\n\n return result;\n};\n\n/** Every attribute name a set of chains touches, deduplicated, in hop order. */\nexport const namesOfChains = (chains: RenameChain[], renames: RenameHop[]): string[] => {\n const names = new Set<string>();\n chains.forEach((chain) => {\n hopsOf(chain, renames).forEach((hop) => {\n names.add(hop.oldName);\n names.add(hop.newName);\n });\n });\n return [...names];\n};\n"],"names":["hopsOf","chain","renames","hopIndexes","map","index","splitChainsByInheritedConsent","recorded","declinedRenameNames","chains","declined","Set","result","keep","decline","prompt","forEach","hops","joinsAcceptedChain","some","hop","known","newName","oldName","push","touchesDeclinedName","has","namesOfChains","names","add"],"mappings":"AAYA,MAAMA,MAAAA,GAAS,CAACC,KAAAA,EAAoBC,OAAAA,GAClCD,KAAAA,CAAME,UAAU,CAACC,GAAG,CAAC,CAACC,KAAAA,GAAUH,OAAO,CAACG,KAAAA,CAAM,CAAA;AAEhD;;;;;;AAMC,IACM,MAAMC,6BAAAA,GAAgC,CAAC,EAC5CC,QAAQ,EACRC,mBAAmB,EACnBC,MAAM,EACNP,OAAO,EAOR,GAAA;IACC,MAAMQ,QAAAA,GAAW,IAAIC,GAAAA,CAAIH,mBAAAA,CAAAA;AACzB,IAAA,MAAMI,MAAAA,GAAsB;AAAEC,QAAAA,IAAAA,EAAM,EAAE;AAAEC,QAAAA,OAAAA,EAAS,EAAE;A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