@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.
@@ -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
- // if (fieldId) {
152
-
153
- // const targetField = fields.find(field => field._id === fieldId);
154
-
155
- // if (targetField?.type === FieldTypes.collection) {
156
- // const flattenedSchema = flattenSchemaTree(targetField.schema);
157
- // const readableIdExists = flattenedSchema.some(schema => schema._id === readableId);
158
-
159
- // if (readableIdExists) {
160
- // console.warn(`validateReadableId: "${readableId}" is invalid - it already exists in fields`);
161
- // return false;
162
- // }
163
- // }
164
-
165
- // } else {
166
-
167
- var duplicateField = fields.find(function (field) {
168
- return field._id === readableId;
169
- });
170
- console.log("duplicateField", duplicateField, readableId);
171
- if (duplicateField && duplicateField.type !== _FieldTypes["default"].collection) {
172
- console.warn("validateReadableId: \"".concat(readableId, "\" is invalid - it already exists in fields"));
173
- return false;
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 (readableIdExists) {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builttocreate/engine-utils",
3
- "version": "2.10.1-beta.v593.17",
3
+ "version": "2.10.1-beta.v593.18",
4
4
  "description": "Utility library for common logic shared across web and mobile",
5
5
  "main": "dist/index.js",
6
6
  "files": [