@strapi/utils 5.3.0 → 5.4.1

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/index.js CHANGED
@@ -1353,6 +1353,7 @@ const isOneToAny = (attribute) => isRelationalAttribute(attribute) && ["oneToOne
1353
1353
  const isManyToAny = (attribute) => isRelationalAttribute(attribute) && ["manyToMany", "manyToOne"].includes(attribute.relation);
1354
1354
  const isAnyToOne = (attribute) => isRelationalAttribute(attribute) && ["oneToOne", "manyToOne"].includes(attribute.relation);
1355
1355
  const isAnyToMany = (attribute) => isRelationalAttribute(attribute) && ["oneToMany", "manyToMany"].includes(attribute.relation);
1356
+ const isPolymorphic = (attribute) => ["morphOne", "morphMany", "morphToOne", "morphToMany"].includes(attribute.relation);
1356
1357
  const constants = {
1357
1358
  MANY_RELATIONS
1358
1359
  };
@@ -1367,7 +1368,8 @@ const relations = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
1367
1368
  isAnyToMany,
1368
1369
  isAnyToOne,
1369
1370
  isManyToAny,
1370
- isOneToAny
1371
+ isOneToAny,
1372
+ isPolymorphic
1371
1373
  }, Symbol.toStringTag, { value: "Module" }));
1372
1374
  const ACTIONS_TO_VERIFY$1 = ["find"];
1373
1375
  const { CREATED_BY_ATTRIBUTE: CREATED_BY_ATTRIBUTE$1, UPDATED_BY_ATTRIBUTE: UPDATED_BY_ATTRIBUTE$1 } = constants$1;
@@ -1404,13 +1406,13 @@ const removeRestrictedRelations = (auth) => async ({ data, key, attribute, schem
1404
1406
  }
1405
1407
  });
1406
1408
  newValue.options = filteredOptions;
1409
+ } else {
1410
+ newValue.options = {};
1407
1411
  }
1408
1412
  set(key, newValue);
1409
1413
  } else {
1410
1414
  const newMorphValue = await handleMorphElements(elements);
1411
- if (newMorphValue.length === 0) {
1412
- remove(key);
1413
- } else {
1415
+ if (newMorphValue.length) {
1414
1416
  set(key, newMorphValue);
1415
1417
  }
1416
1418
  }