@strapi/utils 4.2.3 → 4.3.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.
@@ -2,8 +2,9 @@
2
2
 
3
3
  const ACTIONS_TO_VERIFY = ['find'];
4
4
 
5
- // FIXME: Support populating creator fields
6
- module.exports = auth => async ({ data, key, attribute }, { remove, set }) => {
5
+ const { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = require('../../content-types').constants;
6
+
7
+ module.exports = auth => async ({ data, key, attribute, schema }, { remove, set }) => {
7
8
  const isRelation = attribute.type === 'relation';
8
9
 
9
10
  if (!isRelation) {
@@ -42,16 +43,22 @@ module.exports = auth => async ({ data, key, attribute }, { remove, set }) => {
42
43
  };
43
44
 
44
45
  const isMorphRelation = attribute.relation.toLowerCase().startsWith('morph');
46
+ const isCreatorRelation = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(key);
45
47
 
46
48
  // Polymorphic relations
47
49
  if (isMorphRelation) {
48
50
  await handleMorphRelation();
51
+ return;
49
52
  }
50
53
 
51
- // Regular relations
52
- else {
53
- await handleRegularRelation();
54
+ // Creator relations
55
+ if (isCreatorRelation && schema.options.populateCreatorFields) {
56
+ // do nothing
57
+ return;
54
58
  }
59
+
60
+ // Regular relations
61
+ await handleRegularRelation();
55
62
  };
56
63
 
57
64
  const hasAccessToSomeScopes = async (scopes, auth) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/utils",
3
- "version": "4.2.3",
3
+ "version": "4.3.0",
4
4
  "description": "Shared utilities for the Strapi packages",
5
5
  "keywords": [
6
6
  "strapi",
@@ -45,5 +45,5 @@
45
45
  "node": ">=14.19.1 <=16.x.x",
46
46
  "npm": ">=6.0.0"
47
47
  },
48
- "gitHead": "fe296baf71cb932d45183d5335285eaf30a6fad6"
48
+ "gitHead": "74a2b908df75bc8001d72f9dc8571c4b7a2da337"
49
49
  }