@strapi/content-type-builder 5.4.2 → 5.5.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/_chunks/{ListView-B-HL7krE.js → ListView-B8sInwpb.js} +2 -2
- package/dist/_chunks/{ListView-B-HL7krE.js.map → ListView-B8sInwpb.js.map} +1 -1
- package/dist/_chunks/{ListView-CpLjBWJ4.mjs → ListView-DPzmWFi5.mjs} +2 -2
- package/dist/_chunks/{ListView-CpLjBWJ4.mjs.map → ListView-DPzmWFi5.mjs.map} +1 -1
- package/dist/_chunks/{index-SDJgON5S.js → index-BKtm7tvi.js} +22 -17
- package/dist/_chunks/{index-SDJgON5S.js.map → index-BKtm7tvi.js.map} +1 -1
- package/dist/_chunks/{index-DoD5A25S.js → index-CD3IaMB6.js} +8 -12
- package/dist/_chunks/{index-DoD5A25S.js.map → index-CD3IaMB6.js.map} +1 -1
- package/dist/_chunks/{index-CvbyAgJs.mjs → index-Dj0FBBTu.mjs} +21 -15
- package/dist/_chunks/{index-CvbyAgJs.mjs.map → index-Dj0FBBTu.mjs.map} +1 -1
- package/dist/_chunks/{index-BdUS6fSR.mjs → index-OzcYkX5o.mjs} +7 -10
- package/dist/_chunks/{index-BdUS6fSR.mjs.map → index-OzcYkX5o.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +16 -32
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +15 -30
- package/dist/server/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/server/index.mjs
CHANGED
|
@@ -81,8 +81,7 @@ const replaceTemporaryUIDs = (uidMap) => (schema) => {
|
|
|
81
81
|
acc[key] = {
|
|
82
82
|
...attr,
|
|
83
83
|
components: attr.components.map((value) => {
|
|
84
|
-
if (_.has(uidMap, value))
|
|
85
|
-
return uidMap[value];
|
|
84
|
+
if (_.has(uidMap, value)) return uidMap[value];
|
|
86
85
|
if (!_.has(strapi.components, value)) {
|
|
87
86
|
throw new ApplicationError$3("component.notFound");
|
|
88
87
|
}
|
|
@@ -158,8 +157,7 @@ function createSchemaHandler(infos) {
|
|
|
158
157
|
},
|
|
159
158
|
// set a particular path inside the schema
|
|
160
159
|
set(path2, val) {
|
|
161
|
-
if (!state.schema)
|
|
162
|
-
return this;
|
|
160
|
+
if (!state.schema) return this;
|
|
163
161
|
modified = true;
|
|
164
162
|
const value = _.defaultTo(val, _.get(state.schema, path2));
|
|
165
163
|
_.set(state.schema, path2, value);
|
|
@@ -185,8 +183,7 @@ function createSchemaHandler(infos) {
|
|
|
185
183
|
return this.unset(["attributes", key]);
|
|
186
184
|
},
|
|
187
185
|
setAttributes(newAttributes) {
|
|
188
|
-
if (!this.schema)
|
|
189
|
-
return this;
|
|
186
|
+
if (!this.schema) return this;
|
|
190
187
|
for (const key in this.schema.attributes) {
|
|
191
188
|
if (isConfigurable(this.schema.attributes[key])) {
|
|
192
189
|
this.deleteAttribute(key);
|
|
@@ -198,8 +195,7 @@ function createSchemaHandler(infos) {
|
|
|
198
195
|
return this;
|
|
199
196
|
},
|
|
200
197
|
removeContentType(uid2) {
|
|
201
|
-
if (!state.schema)
|
|
202
|
-
return this;
|
|
198
|
+
if (!state.schema) return this;
|
|
203
199
|
const attributes = state.schema.attributes;
|
|
204
200
|
Object.keys(attributes).forEach((key) => {
|
|
205
201
|
const attribute = attributes[key];
|
|
@@ -211,8 +207,7 @@ function createSchemaHandler(infos) {
|
|
|
211
207
|
},
|
|
212
208
|
// utils
|
|
213
209
|
removeComponent(uid2) {
|
|
214
|
-
if (!state.schema)
|
|
215
|
-
return this;
|
|
210
|
+
if (!state.schema) return this;
|
|
216
211
|
const attributes = state.schema.attributes;
|
|
217
212
|
Object.keys(attributes).forEach((key) => {
|
|
218
213
|
const attr = attributes[key];
|
|
@@ -229,8 +224,7 @@ function createSchemaHandler(infos) {
|
|
|
229
224
|
return this;
|
|
230
225
|
},
|
|
231
226
|
updateComponent(uid2, newUID) {
|
|
232
|
-
if (!state.schema)
|
|
233
|
-
return this;
|
|
227
|
+
if (!state.schema) return this;
|
|
234
228
|
const attributes = state.schema.attributes;
|
|
235
229
|
Object.keys(attributes).forEach((key) => {
|
|
236
230
|
const attr = attributes[key];
|
|
@@ -262,8 +256,7 @@ function createSchemaHandler(infos) {
|
|
|
262
256
|
return;
|
|
263
257
|
}
|
|
264
258
|
if (modified) {
|
|
265
|
-
if (!state.schema)
|
|
266
|
-
return Promise.resolve();
|
|
259
|
+
if (!state.schema) return Promise.resolve();
|
|
267
260
|
await fse__default.ensureFile(filePath);
|
|
268
261
|
await fse__default.writeJSON(
|
|
269
262
|
filePath,
|
|
@@ -482,8 +475,7 @@ function createComponentBuilder() {
|
|
|
482
475
|
const targetCT = this.contentTypes.get(attribute.target);
|
|
483
476
|
const targetAttributeName = attribute.inversedBy || attribute.mappedBy;
|
|
484
477
|
const targetAttribute = targetCT.getAttribute(targetAttributeName);
|
|
485
|
-
if (!targetAttribute)
|
|
486
|
-
return;
|
|
478
|
+
if (!targetAttribute) return;
|
|
487
479
|
return targetCT.deleteAttribute(targetAttributeName);
|
|
488
480
|
},
|
|
489
481
|
/**
|
|
@@ -1089,8 +1081,7 @@ const components$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.define
|
|
|
1089
1081
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1090
1082
|
const editCategory = async (name, infos) => {
|
|
1091
1083
|
const newName = strings.nameToSlug(infos.name);
|
|
1092
|
-
if (name === newName)
|
|
1093
|
-
return;
|
|
1084
|
+
if (name === newName) return;
|
|
1094
1085
|
if (!categoryExists(name)) {
|
|
1095
1086
|
throw new errors.ApplicationError("category not found");
|
|
1096
1087
|
}
|
|
@@ -1101,8 +1092,7 @@ const editCategory = async (name, infos) => {
|
|
|
1101
1092
|
builder2.components.forEach((component) => {
|
|
1102
1093
|
const oldUID = component.uid;
|
|
1103
1094
|
const newUID = `${newName}.${component.modelName}`;
|
|
1104
|
-
if (component.category !== name)
|
|
1105
|
-
return;
|
|
1095
|
+
if (component.category !== name) return;
|
|
1106
1096
|
component.setUID(newUID).setDir(join(strapi.dirs.app.components, newName));
|
|
1107
1097
|
builder2.components.forEach((compo) => {
|
|
1108
1098
|
compo.updateComponent(oldUID, newUID);
|
|
@@ -1666,8 +1656,7 @@ const createAttributesValidator = ({ types, modelType, relations }) => {
|
|
|
1666
1656
|
const isConflictingKey = (key, attributes) => {
|
|
1667
1657
|
const snakeCaseKey = snakeCase(key);
|
|
1668
1658
|
return Object.keys(attributes).some((existingKey) => {
|
|
1669
|
-
if (existingKey === key)
|
|
1670
|
-
return false;
|
|
1659
|
+
if (existingKey === key) return false;
|
|
1671
1660
|
return snakeCase(existingKey) === snakeCaseKey;
|
|
1672
1661
|
});
|
|
1673
1662
|
};
|
|
@@ -1732,10 +1721,8 @@ const nestedComponentSchema = yup.array().of(
|
|
|
1732
1721
|
name: "mustHaveUIDOrTmpUID",
|
|
1733
1722
|
message: "Component must have a uid or a tmpUID",
|
|
1734
1723
|
test(attr) {
|
|
1735
|
-
if (_.has(attr, "uid") && _.has(attr, "tmpUID"))
|
|
1736
|
-
|
|
1737
|
-
if (!_.has(attr, "uid") && !_.has(attr, "tmpUID"))
|
|
1738
|
-
return false;
|
|
1724
|
+
if (_.has(attr, "uid") && _.has(attr, "tmpUID")) return false;
|
|
1725
|
+
if (!_.has(attr, "uid") && !_.has(attr, "tmpUID")) return false;
|
|
1739
1726
|
return true;
|
|
1740
1727
|
}
|
|
1741
1728
|
}).required().noUnknown()
|
|
@@ -1955,8 +1942,7 @@ const nameIsAvailable = (isEdition) => {
|
|
|
1955
1942
|
name: "nameAlreadyUsed",
|
|
1956
1943
|
message: "contentType: name `${value}` is already being used by another content type.",
|
|
1957
1944
|
test(value) {
|
|
1958
|
-
if (isEdition)
|
|
1959
|
-
return true;
|
|
1945
|
+
if (isEdition) return true;
|
|
1960
1946
|
if (typeof value !== "string") {
|
|
1961
1947
|
return true;
|
|
1962
1948
|
}
|
|
@@ -1972,8 +1958,7 @@ const nameIsNotExistingCollectionName = (isEdition) => {
|
|
|
1972
1958
|
name: "nameAlreadyUsed",
|
|
1973
1959
|
message: "contentType: name `${value}` is already being used by another content type.",
|
|
1974
1960
|
test(value) {
|
|
1975
|
-
if (isEdition)
|
|
1976
|
-
return true;
|
|
1961
|
+
if (isEdition) return true;
|
|
1977
1962
|
if (typeof value !== "string") {
|
|
1978
1963
|
return true;
|
|
1979
1964
|
}
|