@builttocreate/engine-utils 2.10.1-beta.v593.17 → 2.10.1-beta.v593.18
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/validateReadableId.js +24 -32
- package/package.json +1 -1
|
@@ -148,43 +148,35 @@ var _default = exports["default"] = function _default(readableId, fields, tableC
|
|
|
148
148
|
//6. Check for duplicateIds
|
|
149
149
|
if (!Array.isArray(fields)) return;
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
if (duplicateField && duplicateField.type === _FieldTypes["default"].collection) {
|
|
176
|
-
var flattenedSchema = (0, _fieldHelper.flattenSchemaTree)(duplicateField.schema);
|
|
177
|
-
var readableIdExists = flattenedSchema.some(function (schema) {
|
|
178
|
-
return schema._id === readableId;
|
|
151
|
+
/**
|
|
152
|
+
* Duplication check for collection fields
|
|
153
|
+
* For the collection fields, we might get the nestedTableReadableId as the readableId, so we need
|
|
154
|
+
* the fieldId to check if the readableId already exists in the collection schema.
|
|
155
|
+
*/
|
|
156
|
+
if (fieldId) {
|
|
157
|
+
var targetField = fields.find(function (field) {
|
|
158
|
+
return field._id === fieldId;
|
|
159
|
+
});
|
|
160
|
+
console.log('fieldId, targetField, readableId in engine utils', fieldId, targetField);
|
|
161
|
+
if ((targetField === null || targetField === void 0 ? void 0 : targetField.type) === _FieldTypes["default"].collection) {
|
|
162
|
+
var flattenedSchema = (0, _fieldHelper.flattenSchemaTree)(targetField.schema);
|
|
163
|
+
var readableIdExists = flattenedSchema.some(function (schema) {
|
|
164
|
+
return schema._id === readableId;
|
|
165
|
+
});
|
|
166
|
+
if (readableIdExists) {
|
|
167
|
+
console.warn("validateReadableId: \"".concat(readableId, "\" is invalid - it already exists in fields"));
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
var duplicateField = fields.find(function (field) {
|
|
173
|
+
return field._id === readableId;
|
|
179
174
|
});
|
|
180
|
-
if (
|
|
175
|
+
if (duplicateField) {
|
|
181
176
|
console.warn("validateReadableId: \"".concat(readableId, "\" is invalid - it already exists in fields"));
|
|
182
177
|
return false;
|
|
183
178
|
}
|
|
184
179
|
}
|
|
185
|
-
|
|
186
|
-
// }
|
|
187
|
-
|
|
188
180
|
if (tableColumns && Array.isArray(tableColumns)) {
|
|
189
181
|
var duplicateColumnId = tableColumns.find(function (column) {
|
|
190
182
|
return column._id === readableId;
|