@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.
- package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.js +117 -13
- package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.js.map +1 -1
- package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.mjs +118 -13
- package/dist/admin/components/AIChat/lib/transforms/schemas/toCTB.mjs.map +1 -1
- package/dist/admin/components/AIChat/providers/SchemaProvider.js +31 -19
- package/dist/admin/components/AIChat/providers/SchemaProvider.js.map +1 -1
- package/dist/admin/components/AIChat/providers/SchemaProvider.mjs +31 -19
- package/dist/admin/components/AIChat/providers/SchemaProvider.mjs.map +1 -1
- package/dist/admin/components/DataManager/DataManagerContext.js.map +1 -1
- package/dist/admin/components/DataManager/DataManagerContext.mjs.map +1 -1
- package/dist/admin/components/DataManager/DataManagerProvider.js +166 -6
- package/dist/admin/components/DataManager/DataManagerProvider.js.map +1 -1
- package/dist/admin/components/DataManager/DataManagerProvider.mjs +165 -7
- package/dist/admin/components/DataManager/DataManagerProvider.mjs.map +1 -1
- package/dist/admin/components/DataManager/RenameMigrationModal.js +285 -0
- package/dist/admin/components/DataManager/RenameMigrationModal.js.map +1 -0
- package/dist/admin/components/DataManager/RenameMigrationModal.mjs +257 -0
- package/dist/admin/components/DataManager/RenameMigrationModal.mjs.map +1 -0
- package/dist/admin/components/DataManager/reducer.js +107 -2
- package/dist/admin/components/DataManager/reducer.js.map +1 -1
- package/dist/admin/components/DataManager/reducer.mjs +106 -2
- package/dist/admin/components/DataManager/reducer.mjs.map +1 -1
- package/dist/admin/components/DataManager/utils/cleanData.js +8 -1
- package/dist/admin/components/DataManager/utils/cleanData.js.map +1 -1
- package/dist/admin/components/DataManager/utils/cleanData.mjs +8 -1
- package/dist/admin/components/DataManager/utils/cleanData.mjs.map +1 -1
- package/dist/admin/components/DataManager/utils/groupRenameChains.js +86 -0
- package/dist/admin/components/DataManager/utils/groupRenameChains.js.map +1 -0
- package/dist/admin/components/DataManager/utils/groupRenameChains.mjs +84 -0
- package/dist/admin/components/DataManager/utils/groupRenameChains.mjs.map +1 -0
- package/dist/admin/components/DataManager/utils/isStorageCompatibleRename.js +29 -0
- package/dist/admin/components/DataManager/utils/isStorageCompatibleRename.js.map +1 -0
- package/dist/admin/components/DataManager/utils/isStorageCompatibleRename.mjs +27 -0
- package/dist/admin/components/DataManager/utils/isStorageCompatibleRename.mjs.map +1 -0
- package/dist/admin/components/DataManager/utils/resolveAfterEditRenameConsent.js +35 -0
- package/dist/admin/components/DataManager/utils/resolveAfterEditRenameConsent.js.map +1 -0
- package/dist/admin/components/DataManager/utils/resolveAfterEditRenameConsent.mjs +33 -0
- package/dist/admin/components/DataManager/utils/resolveAfterEditRenameConsent.mjs.map +1 -0
- package/dist/admin/components/DataManager/utils/splitChainsByInheritedConsent.js +48 -0
- package/dist/admin/components/DataManager/utils/splitChainsByInheritedConsent.js.map +1 -0
- package/dist/admin/components/DataManager/utils/splitChainsByInheritedConsent.mjs +45 -0
- package/dist/admin/components/DataManager/utils/splitChainsByInheritedConsent.mjs.map +1 -0
- package/dist/admin/components/FormModal/FormModal.js +143 -9
- package/dist/admin/components/FormModal/FormModal.js.map +1 -1
- package/dist/admin/components/FormModal/FormModal.mjs +144 -10
- package/dist/admin/components/FormModal/FormModal.mjs.map +1 -1
- package/dist/admin/components/FormModal/attributes/validation/common.js +6 -5
- package/dist/admin/components/FormModal/attributes/validation/common.js.map +1 -1
- package/dist/admin/components/FormModal/attributes/validation/common.mjs +1 -1
- package/dist/admin/components/FormModal/attributes/validation/common.mjs.map +1 -1
- package/dist/admin/components/FormModal/component/createComponentSchema.js +10 -7
- package/dist/admin/components/FormModal/component/createComponentSchema.js.map +1 -1
- package/dist/admin/components/FormModal/component/createComponentSchema.mjs +1 -1
- package/dist/admin/components/FormModal/component/createComponentSchema.mjs.map +1 -1
- package/dist/admin/components/FormModal/contentType/createContentTypeSchema.js +24 -21
- package/dist/admin/components/FormModal/contentType/createContentTypeSchema.js.map +1 -1
- package/dist/admin/components/FormModal/contentType/createContentTypeSchema.mjs +1 -1
- package/dist/admin/components/FormModal/contentType/createContentTypeSchema.mjs.map +1 -1
- package/dist/admin/components/FormModal/forms/utils/createCollectionName.js +3 -2
- package/dist/admin/components/FormModal/forms/utils/createCollectionName.js.map +1 -1
- package/dist/admin/components/FormModal/forms/utils/createCollectionName.mjs +1 -1
- package/dist/admin/components/FormModal/forms/utils/createCollectionName.mjs.map +1 -1
- package/dist/admin/components/FormModal/utils/getRenameStorageChange.js +73 -0
- package/dist/admin/components/FormModal/utils/getRenameStorageChange.js.map +1 -0
- package/dist/admin/components/FormModal/utils/getRenameStorageChange.mjs +70 -0
- package/dist/admin/components/FormModal/utils/getRenameStorageChange.mjs.map +1 -0
- package/dist/admin/src/components/AIChat/components/AnimatedBox.d.ts +2 -2
- package/dist/admin/src/components/AIChat/components/Input.d.ts +2 -2
- package/dist/admin/src/components/AIChat/lib/transforms/schemas/toCTB.d.ts +4 -3
- package/dist/admin/src/components/AIChat/lib/types/schema.d.ts +6 -1
- package/dist/admin/src/components/AttributeOptions/OptionBoxWrapper.d.ts +2 -2
- package/dist/admin/src/components/ComponentRow.d.ts +2 -2
- package/dist/admin/src/components/DataManager/DataManagerContext.d.ts +28 -2
- package/dist/admin/src/components/DataManager/RenameMigrationModal.d.ts +73 -0
- package/dist/admin/src/components/DataManager/reducer.d.ts +17 -2
- package/dist/admin/src/components/DataManager/utils/cleanData.d.ts +16 -0
- package/dist/admin/src/components/DataManager/utils/groupRenameChains.d.ts +31 -0
- package/dist/admin/src/components/DataManager/utils/isStorageCompatibleRename.d.ts +10 -0
- package/dist/admin/src/components/DataManager/utils/resolveAfterEditRenameConsent.d.ts +24 -0
- package/dist/admin/src/components/DataManager/utils/splitChainsByInheritedConsent.d.ts +26 -0
- package/dist/admin/src/components/FormModal/utils/getRenameStorageChange.d.ts +40 -0
- package/dist/admin/src/components/List.d.ts +2 -2
- package/dist/admin/src/components/Relation/RelationNaturePicker/Components.d.ts +4 -4
- package/dist/admin/src/types.d.ts +23 -0
- package/dist/admin/translations/en.json.js +12 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +12 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/server/config.js +24 -3
- package/dist/server/config.js.map +1 -1
- package/dist/server/config.mjs +21 -3
- package/dist/server/config.mjs.map +1 -1
- package/dist/server/controllers/schema.js +2 -2
- package/dist/server/controllers/schema.js.map +1 -1
- package/dist/server/controllers/schema.mjs +1 -1
- package/dist/server/controllers/schema.mjs.map +1 -1
- package/dist/server/controllers/validation/content-type.js +9 -11
- package/dist/server/controllers/validation/content-type.js.map +1 -1
- package/dist/server/controllers/validation/content-type.mjs +7 -9
- package/dist/server/controllers/validation/content-type.mjs.map +1 -1
- package/dist/server/controllers/validation/model-schema.js +2 -3
- package/dist/server/controllers/validation/model-schema.js.map +1 -1
- package/dist/server/controllers/validation/model-schema.mjs +1 -2
- package/dist/server/controllers/validation/model-schema.mjs.map +1 -1
- package/dist/server/controllers/validation/relations.js +1 -2
- package/dist/server/controllers/validation/relations.js.map +1 -1
- package/dist/server/controllers/validation/relations.mjs +1 -2
- package/dist/server/controllers/validation/relations.mjs.map +1 -1
- package/dist/server/controllers/validation/schema.js +42 -23
- package/dist/server/controllers/validation/schema.js.map +1 -1
- package/dist/server/controllers/validation/schema.mjs +43 -24
- package/dist/server/controllers/validation/schema.mjs.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/services/content-types.js +1 -2
- package/dist/server/services/content-types.js.map +1 -1
- package/dist/server/services/content-types.mjs +2 -3
- package/dist/server/services/content-types.mjs.map +1 -1
- package/dist/server/services/migration-builder/index.js +580 -0
- package/dist/server/services/migration-builder/index.js.map +1 -0
- package/dist/server/services/migration-builder/index.mjs +573 -0
- package/dist/server/services/migration-builder/index.mjs.map +1 -0
- package/dist/server/services/schema-builder/content-type-builder.js +31 -1
- package/dist/server/services/schema-builder/content-type-builder.js.map +1 -1
- package/dist/server/services/schema-builder/content-type-builder.mjs +31 -1
- package/dist/server/services/schema-builder/content-type-builder.mjs.map +1 -1
- package/dist/server/services/schema-mutation.js +30 -2
- package/dist/server/services/schema-mutation.js.map +1 -1
- package/dist/server/services/schema-mutation.mjs +10 -2
- package/dist/server/services/schema-mutation.mjs.map +1 -1
- package/dist/server/services/schema.js +259 -15
- package/dist/server/services/schema.js.map +1 -1
- package/dist/server/services/schema.mjs +252 -9
- package/dist/server/services/schema.mjs.map +1 -1
- package/dist/server/src/config.d.ts +23 -2
- package/dist/server/src/config.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/content-type.d.ts +0 -1
- package/dist/server/src/controllers/validation/content-type.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/schema.d.ts +28 -0
- package/dist/server/src/controllers/validation/schema.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +10 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/content-types.d.ts.map +1 -1
- package/dist/server/src/services/migration-builder/index.d.ts +83 -0
- package/dist/server/src/services/migration-builder/index.d.ts.map +1 -0
- package/dist/server/src/services/schema-builder/content-type-builder.d.ts.map +1 -1
- package/dist/server/src/services/schema-mutation.d.ts +4 -2
- package/dist/server/src/services/schema-mutation.d.ts.map +1 -1
- package/dist/server/src/services/schema.d.ts +19 -0
- package/dist/server/src/services/schema.d.ts.map +1 -1
- package/package.json +11 -10
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { errors, contentTypes } from '@strapi/utils';
|
|
2
|
-
import { mapValues } from 'lodash
|
|
2
|
+
import { mapValues } from 'lodash';
|
|
3
3
|
import createBuilder from './schema-builder/index.mjs';
|
|
4
|
+
import { createMigrationBuilder } from './migration-builder/index.mjs';
|
|
4
5
|
import { rollbackSchemaMutation, finalizeSchemaMutation } from './schema-mutation.mjs';
|
|
5
6
|
import { getService } from '../utils/index.mjs';
|
|
7
|
+
import { validateUpdateSchema } from '../controllers/validation/schema.mjs';
|
|
6
8
|
import { getRestrictRelationsTo, isContentTypeVisible, assertCTBOwnedApplicationContentType } from './content-types.mjs';
|
|
7
9
|
|
|
8
10
|
const removeEmptyDefaultsOnUpdates = (schema)=>{
|
|
@@ -48,6 +50,238 @@ const removeDeletedUIDTargetFieldsOnUpdates = (schema)=>{
|
|
|
48
50
|
});
|
|
49
51
|
});
|
|
50
52
|
};
|
|
53
|
+
const getAttributeRenameMigrationMode = ()=>{
|
|
54
|
+
return strapi.plugin('content-type-builder').config('renameMigrations.attributes', 'prompt-before-save');
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Collects attribute renames from the update-schema payload. The admin sends an
|
|
58
|
+
* ordered `renames` array per updated content-type / component: the exact path
|
|
59
|
+
* of rename hops the user performed (e.g. `a -> tmp`, `b -> a`, `tmp -> b` for a
|
|
60
|
+
* swap). Order is preserved so the generated migration can replay each hop
|
|
61
|
+
* verbatim — which is inherently collision-free because the Content-Type Builder
|
|
62
|
+
* never allows two fields to share a name at any instant.
|
|
63
|
+
*/ const collectRenames = (schema)=>{
|
|
64
|
+
const renames = [];
|
|
65
|
+
const collectFrom = (entries)=>{
|
|
66
|
+
entries.filter((entry)=>entry.action === 'update' && Array.isArray(entry.renames)).forEach((entry)=>{
|
|
67
|
+
// Only the last hop onto a name produces the field that carries the
|
|
68
|
+
// final definition: in `a -> b, b -> c, x -> b` the first `b` is `a`'s
|
|
69
|
+
// intermediate name and the final `b` is `x`'s field.
|
|
70
|
+
const lastHopByNewName = new Map();
|
|
71
|
+
entry.renames.forEach((hop, index)=>{
|
|
72
|
+
if (hop.newName) {
|
|
73
|
+
lastHopByNewName.set(hop.newName, index);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
entry.renames.forEach((hop, index)=>{
|
|
77
|
+
if (hop.oldName && hop.newName && hop.oldName !== hop.newName) {
|
|
78
|
+
// The definition the field ends up with in this save, so the builder
|
|
79
|
+
// can refuse hops that also change the field's storage (type,
|
|
80
|
+
// relation target, component…). Intermediate hops of a chain get no
|
|
81
|
+
// definition and are checked when the chain completes.
|
|
82
|
+
const newAttribute = lastHopByNewName.get(hop.newName) === index ? entry.attributes?.find((attribute)=>attribute.action !== 'delete' && attribute.name === hop.newName)?.properties : undefined;
|
|
83
|
+
renames.push({
|
|
84
|
+
uid: entry.uid,
|
|
85
|
+
oldName: hop.oldName,
|
|
86
|
+
newName: hop.newName,
|
|
87
|
+
newAttribute
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
collectFrom(schema.contentTypes);
|
|
94
|
+
collectFrom(schema.components);
|
|
95
|
+
return renames;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Drops renames whose final name is not an attribute after this save (it was
|
|
99
|
+
* deleted in the same save), so no store is pointed at a field that is gone.
|
|
100
|
+
*/ const keepSavedAttributes = (schema, mapping)=>{
|
|
101
|
+
const entries = [
|
|
102
|
+
...schema.contentTypes,
|
|
103
|
+
...schema.components
|
|
104
|
+
];
|
|
105
|
+
const result = {};
|
|
106
|
+
for (const [uid, renames] of Object.entries(mapping)){
|
|
107
|
+
const entry = entries.find((candidate)=>candidate.uid === uid);
|
|
108
|
+
const saved = new Set((entry?.attributes ?? []).filter((attribute)=>attribute.action !== 'delete' && attribute.name).map((attribute)=>attribute.name));
|
|
109
|
+
for (const [origin, final] of Object.entries(renames)){
|
|
110
|
+
if (saved.has(final)) {
|
|
111
|
+
var _result, _uid;
|
|
112
|
+
(_result = result)[_uid = uid] ?? (_result[_uid] = {});
|
|
113
|
+
result[uid][origin] = final;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
};
|
|
119
|
+
const describeUnsupportedReason = (reason)=>{
|
|
120
|
+
switch(reason){
|
|
121
|
+
case 'type-changed':
|
|
122
|
+
return 'the field type, relation or component also changed';
|
|
123
|
+
case 'unsupported-type':
|
|
124
|
+
return 'the field type cannot be migrated (e.g. polymorphic relation)';
|
|
125
|
+
case 'attribute-not-found':
|
|
126
|
+
return 'the field is not in the current schema';
|
|
127
|
+
case 'target-occupied':
|
|
128
|
+
return 'the target field still exists in the current schema';
|
|
129
|
+
case 'model-not-found':
|
|
130
|
+
default:
|
|
131
|
+
return 'the type is not in the current schema';
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Generates a single data-preserving rename migration for the accepted renames
|
|
136
|
+
* in this save. Must run before the server reloads, while `strapi.db.metadata`
|
|
137
|
+
* still reflects the old (pre-rename) schema. Resolves to the written file's
|
|
138
|
+
* path (so a failed save can remove it), or `null` when nothing was written.
|
|
139
|
+
*/ const generateRenameMigrations = async (schema)=>{
|
|
140
|
+
// In prompt modes the admin strips refused renames before sending the payload.
|
|
141
|
+
if (getAttributeRenameMigrationMode() === 'never') {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const renames = collectRenames(schema);
|
|
145
|
+
if (renames.length === 0) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
const migrationBuilder = createMigrationBuilder({
|
|
149
|
+
strapi
|
|
150
|
+
});
|
|
151
|
+
for (const { uid, oldName, newName, newAttribute } of renames){
|
|
152
|
+
migrationBuilder.addRenameAttribute(uid, {
|
|
153
|
+
oldName,
|
|
154
|
+
newName,
|
|
155
|
+
newAttribute
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const attributeRenames = keepSavedAttributes(schema, migrationBuilder.attributeRenamesMapping());
|
|
159
|
+
if (Object.keys(attributeRenames).length > 0) {
|
|
160
|
+
migrationBuilder.addAttributeRenames(attributeRenames);
|
|
161
|
+
}
|
|
162
|
+
const unsupported = migrationBuilder.getUnsupported();
|
|
163
|
+
if (unsupported.length > 0) {
|
|
164
|
+
const fields = unsupported.map((u)=>`${u.uid}.${u.oldName} (${describeUnsupportedReason(u.reason)})`).join(', ');
|
|
165
|
+
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.`);
|
|
166
|
+
}
|
|
167
|
+
if (migrationBuilder.hasChanges()) {
|
|
168
|
+
return migrationBuilder.writeFiles();
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Renames a single attribute on a content-type or component and generates the
|
|
174
|
+
* data-preserving migration in one step. Used by the `strapi rename:field` CLI
|
|
175
|
+
* command so scripted / non-UI workflows get the same behaviour as the admin.
|
|
176
|
+
*
|
|
177
|
+
* It reuses the regular `updateSchema` path (and therefore the same rename
|
|
178
|
+
* resolver via `generateRenameMigrations`), so the migration is resolved against
|
|
179
|
+
* the pre-reload `strapi.db.metadata` exactly like the admin save. The caller is
|
|
180
|
+
* responsible for not reloading before this resolves (the CLI simply exits).
|
|
181
|
+
*
|
|
182
|
+
* Unlike the admin, there is no one to confirm a data-losing rename, so it
|
|
183
|
+
* refuses before touching the schema when the rename cannot be migrated.
|
|
184
|
+
*/ const renameAttribute = async (uid, oldName, newName)=>{
|
|
185
|
+
const { ApplicationError } = errors;
|
|
186
|
+
if (!oldName || !newName) {
|
|
187
|
+
throw new ApplicationError('Both an old and a new attribute name are required');
|
|
188
|
+
}
|
|
189
|
+
if (oldName === newName) {
|
|
190
|
+
throw new ApplicationError(`Cannot rename "${oldName}" to itself`);
|
|
191
|
+
}
|
|
192
|
+
if (getAttributeRenameMigrationMode() === 'never') {
|
|
193
|
+
throw new ApplicationError('Rename migrations are disabled (`renameMigrations.attributes: never`); rename the field in the Content-Type Builder instead');
|
|
194
|
+
}
|
|
195
|
+
const contentType = strapi.contentTypes[uid];
|
|
196
|
+
const component = strapi.components[uid];
|
|
197
|
+
const model = contentType ?? component;
|
|
198
|
+
if (!model) {
|
|
199
|
+
throw new ApplicationError(`No content-type or component found for uid "${uid}"`);
|
|
200
|
+
}
|
|
201
|
+
if (!model.attributes?.[oldName]) {
|
|
202
|
+
throw new ApplicationError(`Attribute "${oldName}" does not exist on "${uid}"`);
|
|
203
|
+
}
|
|
204
|
+
if (model.attributes?.[newName]) {
|
|
205
|
+
throw new ApplicationError(`Attribute "${newName}" already exists on "${uid}"`);
|
|
206
|
+
}
|
|
207
|
+
// Reuse the formatted, CTB-visible attributes (same shape the admin sends) so
|
|
208
|
+
// the schema edit matches an admin save and the renamed key is the only change.
|
|
209
|
+
const formattedSchema = await getSchema();
|
|
210
|
+
const isComponent = Boolean(component);
|
|
211
|
+
const entry = isComponent ? formattedSchema.components[uid] : formattedSchema.contentTypes[uid];
|
|
212
|
+
// Custom fields are exposed with their underlying type; the admin sends them
|
|
213
|
+
// back as `customField` so the schema file keeps them as custom fields.
|
|
214
|
+
const toPayloadProperties = (properties)=>properties.customField ? {
|
|
215
|
+
...properties,
|
|
216
|
+
type: 'customField'
|
|
217
|
+
} : properties;
|
|
218
|
+
const attributes = entry.attributes.map(({ name, ...properties })=>({
|
|
219
|
+
action: 'update',
|
|
220
|
+
name: name === oldName ? newName : name,
|
|
221
|
+
properties: toPayloadProperties(properties)
|
|
222
|
+
}));
|
|
223
|
+
// Dry run: the field keeps its definition, so only the rename itself can be
|
|
224
|
+
// refused (system attribute, unsupported relation, occupied target…).
|
|
225
|
+
const { name: _name, ...oldProperties } = entry.attributes.find((attribute)=>attribute.name === oldName) ?? {
|
|
226
|
+
name: oldName
|
|
227
|
+
};
|
|
228
|
+
const probe = createMigrationBuilder({
|
|
229
|
+
strapi
|
|
230
|
+
});
|
|
231
|
+
probe.addRenameAttribute(uid, {
|
|
232
|
+
oldName,
|
|
233
|
+
newName,
|
|
234
|
+
newAttribute: toPayloadProperties(oldProperties)
|
|
235
|
+
});
|
|
236
|
+
const refused = probe.getUnsupported();
|
|
237
|
+
if (refused.length > 0) {
|
|
238
|
+
throw new ApplicationError(`Cannot rename "${oldName}" on "${uid}" without losing its data: ${refused.map(({ reason })=>describeUnsupportedReason(reason)).join(', ')}`);
|
|
239
|
+
}
|
|
240
|
+
const renames = [
|
|
241
|
+
{
|
|
242
|
+
oldName,
|
|
243
|
+
newName
|
|
244
|
+
}
|
|
245
|
+
];
|
|
246
|
+
const payload = isComponent ? {
|
|
247
|
+
contentTypes: [],
|
|
248
|
+
components: [
|
|
249
|
+
{
|
|
250
|
+
action: 'update',
|
|
251
|
+
uid,
|
|
252
|
+
category: model.category,
|
|
253
|
+
displayName: model.info?.displayName,
|
|
254
|
+
icon: model.info?.icon,
|
|
255
|
+
description: model.info?.description,
|
|
256
|
+
pluginOptions: model.pluginOptions,
|
|
257
|
+
renames,
|
|
258
|
+
attributes
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
} : {
|
|
262
|
+
contentTypes: [
|
|
263
|
+
{
|
|
264
|
+
action: 'update',
|
|
265
|
+
uid,
|
|
266
|
+
kind: model.kind,
|
|
267
|
+
displayName: model.info?.displayName,
|
|
268
|
+
description: model.info?.description,
|
|
269
|
+
draftAndPublish: Boolean(model.options?.draftAndPublish),
|
|
270
|
+
options: model.options,
|
|
271
|
+
pluginOptions: model.pluginOptions,
|
|
272
|
+
renames,
|
|
273
|
+
attributes
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
components: []
|
|
277
|
+
};
|
|
278
|
+
// Same checks as an admin save (name rules, reserved names, snake-case
|
|
279
|
+
// uniqueness: `fooBar` next to an existing `foo_bar` would share a column).
|
|
280
|
+
const { data } = await validateUpdateSchema({
|
|
281
|
+
data: payload
|
|
282
|
+
});
|
|
283
|
+
await updateSchema(data);
|
|
284
|
+
};
|
|
51
285
|
const formatAttributes = (model)=>{
|
|
52
286
|
const { getVisibleAttributes } = contentTypes;
|
|
53
287
|
// only get attributes that can be seen in the CTB
|
|
@@ -72,7 +306,7 @@ const formatAttribute = (attribute)=>{
|
|
|
72
306
|
return attribute;
|
|
73
307
|
};
|
|
74
308
|
const getSchema = async ()=>{
|
|
75
|
-
const contentTypes = mapValues((contentType)=>{
|
|
309
|
+
const contentTypes = mapValues(strapi.contentTypes, (contentType)=>{
|
|
76
310
|
const { uid, options, globalId, pluginOptions, kind, modelName, plugin, collectionName, info, modelType } = contentType;
|
|
77
311
|
return {
|
|
78
312
|
uid,
|
|
@@ -89,8 +323,8 @@ const getSchema = async ()=>{
|
|
|
89
323
|
visible: isContentTypeVisible(contentType),
|
|
90
324
|
restrictRelationsTo: getRestrictRelationsTo(contentType)
|
|
91
325
|
};
|
|
92
|
-
}
|
|
93
|
-
const components = mapValues((component)=>{
|
|
326
|
+
});
|
|
327
|
+
const components = mapValues(strapi.components, (component)=>{
|
|
94
328
|
const { uid, globalId, modelName, collectionName, info, category, modelType } = component;
|
|
95
329
|
return {
|
|
96
330
|
uid,
|
|
@@ -102,13 +336,18 @@ const getSchema = async ()=>{
|
|
|
102
336
|
info,
|
|
103
337
|
attributes: formatAttributes(component)
|
|
104
338
|
};
|
|
105
|
-
}
|
|
339
|
+
});
|
|
106
340
|
const coreContentStructure = strapi.get('content-structure');
|
|
107
341
|
const contentStructure = await coreContentStructure.getCleanedFile();
|
|
108
342
|
return {
|
|
109
343
|
contentStructure,
|
|
110
344
|
contentTypes,
|
|
111
|
-
components
|
|
345
|
+
components,
|
|
346
|
+
settings: {
|
|
347
|
+
renameMigrations: {
|
|
348
|
+
attributes: getAttributeRenameMigrationMode()
|
|
349
|
+
}
|
|
350
|
+
}
|
|
112
351
|
};
|
|
113
352
|
};
|
|
114
353
|
const updateSchema = async (schema)=>{
|
|
@@ -126,6 +365,7 @@ const updateSchema = async (schema)=>{
|
|
|
126
365
|
const generatedApiNames = [];
|
|
127
366
|
const backedUpApiUids = [];
|
|
128
367
|
let schemaAlreadyRolledBack = false;
|
|
368
|
+
let migrationFilePath = null;
|
|
129
369
|
const APIsToDelete = contentTypes.filter((contentType)=>contentType.action === 'delete').map((contentType)=>contentType.uid);
|
|
130
370
|
try {
|
|
131
371
|
for (const contentType of contentTypes){
|
|
@@ -185,7 +425,6 @@ const updateSchema = async (schema)=>{
|
|
|
185
425
|
builder.editContentType({
|
|
186
426
|
...contentType,
|
|
187
427
|
attributes: contentType.attributes.reduce((acc, attr)=>{
|
|
188
|
-
// NOTE: handle renaming migrations here by comparing attr name & attr.properties.name
|
|
189
428
|
if (attr.action === 'delete') {
|
|
190
429
|
return acc;
|
|
191
430
|
}
|
|
@@ -230,6 +469,9 @@ const updateSchema = async (schema)=>{
|
|
|
230
469
|
// Components target existing components
|
|
231
470
|
// Nested components target existing components
|
|
232
471
|
// Dynamic zones target existing components
|
|
472
|
+
// Generate rename migrations before reloading, while strapi.db.metadata still
|
|
473
|
+
// reflects the pre-rename schema (the controller triggers the reload after this).
|
|
474
|
+
migrationFilePath = await generateRenameMigrations(schema);
|
|
233
475
|
const schemaFilesWritten = await builder.writeFiles();
|
|
234
476
|
if (!schemaFilesWritten) {
|
|
235
477
|
schemaAlreadyRolledBack = true;
|
|
@@ -251,7 +493,8 @@ const updateSchema = async (schema)=>{
|
|
|
251
493
|
apiHandler,
|
|
252
494
|
backedUpApiUids,
|
|
253
495
|
generatedApiNames,
|
|
254
|
-
schemaAlreadyRolledBack
|
|
496
|
+
schemaAlreadyRolledBack,
|
|
497
|
+
migrationFilePath
|
|
255
498
|
});
|
|
256
499
|
throw error;
|
|
257
500
|
}
|
|
@@ -299,5 +542,5 @@ const updateSchema = async (schema)=>{
|
|
|
299
542
|
}
|
|
300
543
|
};
|
|
301
544
|
|
|
302
|
-
export { formatAttribute, getSchema, updateSchema };
|
|
545
|
+
export { formatAttribute, getSchema, renameAttribute, updateSchema };
|
|
303
546
|
//# sourceMappingURL=schema.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.mjs","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;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,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,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.mjs","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,IA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"prompt-after-edit", "prompt-before-save"];
|
|
2
|
+
export type AttributeRenameMigrationMode = (typeof ATTRIBUTE_RENAME_MIGRATION_MODES)[number];
|
|
3
|
+
export interface RenameMigrationsConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Attribute rename behavior. A contentTypes setting can be added alongside
|
|
6
|
+
* this later without changing the public configuration shape.
|
|
7
|
+
*/
|
|
8
|
+
attributes: AttributeRenameMigrationMode;
|
|
9
|
+
}
|
|
10
|
+
export interface ContentTypeBuilderConfig {
|
|
11
|
+
renameMigrations: RenameMigrationsConfig;
|
|
12
|
+
}
|
|
13
|
+
type ContentTypeBuilderUserConfig = {
|
|
14
|
+
renameMigrations?: {
|
|
15
|
+
attributes?: AttributeRenameMigrationMode;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
1
18
|
declare const _default: {
|
|
2
|
-
default: {
|
|
3
|
-
|
|
19
|
+
default: {
|
|
20
|
+
renameMigrations: {
|
|
21
|
+
attributes: "prompt-before-save";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
validator(config: ContentTypeBuilderUserConfig): void;
|
|
4
25
|
};
|
|
5
26
|
export default _default;
|
|
6
27
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../server/src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../server/src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,yEAKnC,CAAC;AAEX,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,gCAAgC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7F,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,UAAU,EAAE,4BAA4B,CAAC;CAC1C;AAED,MAAM,WAAW,wBAAwB;IACvC,gBAAgB,EAAE,sBAAsB,CAAC;CAC1C;AAED,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,CAAC,EAAE;QACjB,UAAU,CAAC,EAAE,4BAA4B,CAAC;KAC3C,CAAC;CACH,CAAC;;;;;;;sBAQkB,4BAA4B;;AANhD,wBAuBE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-type.d.ts","sourceRoot":"","sources":["../../../../../server/src/controllers/validation/content-type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content-type.d.ts","sourceRoot":"","sources":["../../../../../server/src/controllers/validation/content-type.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAqB,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAS3D,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACxF,UAAU,CAAC,EAAE,KAAK,CAChB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAA;KAAE,CACnE,CAAC;IACF,YAAY,EAAE,MAAM,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;IAC3D,UAAU,EAAE,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1D,IAAI,EAAE,MAAM,CAAC,eAAe,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IAC/D,UAAU,EAAE,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACvD,WAAW,EAAE,MAAM,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAkFF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,sBAAsB;;;GAEpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,GAAI,MAAM,sBAAsB;;;GAe1E,CAAC;AAqEF,eAAO,MAAM,YAAY,uEAAgC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../../../../server/src/controllers/validation/relations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../../../../server/src/controllers/validation/relations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,KAAK,EAAE,MAAM,EAAO,MAAM,eAAe,CAAC;AA8BjD,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,CAAC,SAAS,CAAC,QAAQ,EACpC,kBAAkB,aAAa,CAAC,MAAM,CAAC;;;;;;;;;;;;;;GAmCxC,CAAC"}
|
|
@@ -6,6 +6,10 @@ type ContentTypeSchemaAction = {
|
|
|
6
6
|
action: 'create' | 'update' | 'delete';
|
|
7
7
|
draftAndPublish?: boolean;
|
|
8
8
|
uid?: UID.ContentType;
|
|
9
|
+
renames?: Array<{
|
|
10
|
+
oldName: string;
|
|
11
|
+
newName: string;
|
|
12
|
+
}>;
|
|
9
13
|
attributes?: Array<{
|
|
10
14
|
action: 'create' | 'update' | 'delete';
|
|
11
15
|
name: string;
|
|
@@ -948,6 +952,10 @@ declare const updateComponentSchema: z.ZodObject<{
|
|
|
948
952
|
pluginOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
949
953
|
action: z.ZodLiteral<"update">;
|
|
950
954
|
category: z.ZodOptional<z.ZodString>;
|
|
955
|
+
renames: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
956
|
+
oldName: z.ZodString;
|
|
957
|
+
newName: z.ZodString;
|
|
958
|
+
}, z.core.$strip>>>;
|
|
951
959
|
attributes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
952
960
|
action: z.ZodLiteral<"create">;
|
|
953
961
|
name: z.ZodString;
|
|
@@ -4657,6 +4665,10 @@ declare const updateSingleTypeSchema: z.ZodObject<{
|
|
|
4657
4665
|
options: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
4658
4666
|
pluginOptions: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
4659
4667
|
action: z.ZodLiteral<"update">;
|
|
4668
|
+
renames: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4669
|
+
oldName: z.ZodString;
|
|
4670
|
+
newName: z.ZodString;
|
|
4671
|
+
}, z.core.$strip>>>;
|
|
4660
4672
|
kind: z.ZodOptional<z.ZodLiteral<"singleType">>;
|
|
4661
4673
|
attributes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4662
4674
|
action: z.ZodLiteral<"create">;
|
|
@@ -6501,6 +6513,10 @@ declare const updateCollectionTypeSchema: z.ZodObject<{
|
|
|
6501
6513
|
options: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
6502
6514
|
pluginOptions: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
6503
6515
|
action: z.ZodLiteral<"update">;
|
|
6516
|
+
renames: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
6517
|
+
oldName: z.ZodString;
|
|
6518
|
+
newName: z.ZodString;
|
|
6519
|
+
}, z.core.$strip>>>;
|
|
6504
6520
|
kind: z.ZodOptional<z.ZodLiteral<"collectionType">>;
|
|
6505
6521
|
attributes: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
6506
6522
|
action: z.ZodLiteral<"create">;
|
|
@@ -9593,6 +9609,10 @@ export declare const validateUpdateSchema: (data: unknown, errorMessage?: string
|
|
|
9593
9609
|
description?: string | undefined;
|
|
9594
9610
|
pluginOptions?: Record<string, unknown> | undefined;
|
|
9595
9611
|
category?: string | undefined;
|
|
9612
|
+
renames?: {
|
|
9613
|
+
oldName: string;
|
|
9614
|
+
newName: string;
|
|
9615
|
+
}[] | undefined;
|
|
9596
9616
|
} | {
|
|
9597
9617
|
action: "delete";
|
|
9598
9618
|
uid: `${string}.${string}`;
|
|
@@ -11259,6 +11279,10 @@ export declare const validateUpdateSchema: (data: unknown, errorMessage?: string
|
|
|
11259
11279
|
name: string;
|
|
11260
11280
|
})[];
|
|
11261
11281
|
description?: string | undefined;
|
|
11282
|
+
renames?: {
|
|
11283
|
+
oldName: string;
|
|
11284
|
+
newName: string;
|
|
11285
|
+
}[] | undefined;
|
|
11262
11286
|
kind?: "singleType" | undefined;
|
|
11263
11287
|
} | {
|
|
11264
11288
|
uid: UID.ContentType;
|
|
@@ -12082,6 +12106,10 @@ export declare const validateUpdateSchema: (data: unknown, errorMessage?: string
|
|
|
12082
12106
|
name: string;
|
|
12083
12107
|
})[];
|
|
12084
12108
|
description?: string | undefined;
|
|
12109
|
+
renames?: {
|
|
12110
|
+
oldName: string;
|
|
12111
|
+
newName: string;
|
|
12112
|
+
}[] | undefined;
|
|
12085
12113
|
kind?: "collectionType" | undefined;
|
|
12086
12114
|
} | {
|
|
12087
12115
|
action: "delete";
|