@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.mjs CHANGED
@@ -1326,6 +1326,7 @@ const isOneToAny = (attribute) => isRelationalAttribute(attribute) && ["oneToOne
1326
1326
  const isManyToAny = (attribute) => isRelationalAttribute(attribute) && ["manyToMany", "manyToOne"].includes(attribute.relation);
1327
1327
  const isAnyToOne = (attribute) => isRelationalAttribute(attribute) && ["oneToOne", "manyToOne"].includes(attribute.relation);
1328
1328
  const isAnyToMany = (attribute) => isRelationalAttribute(attribute) && ["oneToMany", "manyToMany"].includes(attribute.relation);
1329
+ const isPolymorphic = (attribute) => ["morphOne", "morphMany", "morphToOne", "morphToMany"].includes(attribute.relation);
1329
1330
  const constants = {
1330
1331
  MANY_RELATIONS
1331
1332
  };
@@ -1340,7 +1341,8 @@ const relations = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
1340
1341
  isAnyToMany,
1341
1342
  isAnyToOne,
1342
1343
  isManyToAny,
1343
- isOneToAny
1344
+ isOneToAny,
1345
+ isPolymorphic
1344
1346
  }, Symbol.toStringTag, { value: "Module" }));
1345
1347
  const ACTIONS_TO_VERIFY$1 = ["find"];
1346
1348
  const { CREATED_BY_ATTRIBUTE: CREATED_BY_ATTRIBUTE$1, UPDATED_BY_ATTRIBUTE: UPDATED_BY_ATTRIBUTE$1 } = constants$1;
@@ -1377,13 +1379,13 @@ const removeRestrictedRelations = (auth) => async ({ data, key, attribute, schem
1377
1379
  }
1378
1380
  });
1379
1381
  newValue.options = filteredOptions;
1382
+ } else {
1383
+ newValue.options = {};
1380
1384
  }
1381
1385
  set(key, newValue);
1382
1386
  } else {
1383
1387
  const newMorphValue = await handleMorphElements(elements);
1384
- if (newMorphValue.length === 0) {
1385
- remove2(key);
1386
- } else {
1388
+ if (newMorphValue.length) {
1387
1389
  set(key, newMorphValue);
1388
1390
  }
1389
1391
  }