@strapi/utils 4.3.0-beta.2 → 4.3.2-alpha.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.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Converts the standard Strapi REST query params to a more usable format for querying
|
|
5
5
|
* You can read more here: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#filters
|
|
6
6
|
*/
|
|
7
|
-
const { has, isEmpty, isObject, isPlainObject, cloneDeep, get } = require('lodash/fp');
|
|
7
|
+
const { has, isEmpty, isObject, isPlainObject, cloneDeep, get, mergeAll } = require('lodash/fp');
|
|
8
8
|
const _ = require('lodash');
|
|
9
9
|
const parseType = require('./parse-type');
|
|
10
10
|
const contentTypesUtils = require('./content-types');
|
|
@@ -170,17 +170,13 @@ const convertPopulateObject = (populate, schema) => {
|
|
|
170
170
|
// FIXME: This is a temporary solution for dynamic zones that should be
|
|
171
171
|
// fixed when we'll implement a more accurate way to query them
|
|
172
172
|
if (attribute.type === 'dynamiczone') {
|
|
173
|
-
const
|
|
174
|
-
uid
|
|
175
|
-
|
|
176
|
-
.sort()
|
|
177
|
-
.map(uid => strapi.getModel(uid).attributes)
|
|
178
|
-
.reduce((acc, componentAttributes) => ({ ...acc, ...componentAttributes }), {}),
|
|
179
|
-
};
|
|
173
|
+
const populates = attribute.components
|
|
174
|
+
.map(uid => strapi.getModel(uid))
|
|
175
|
+
.map(schema => convertNestedPopulate(subPopulate, schema));
|
|
180
176
|
|
|
181
177
|
return {
|
|
182
178
|
...acc,
|
|
183
|
-
[key]:
|
|
179
|
+
[key]: mergeAll(populates),
|
|
184
180
|
};
|
|
185
181
|
}
|
|
186
182
|
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const ACTIONS_TO_VERIFY = ['find'];
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
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.3.
|
|
3
|
+
"version": "4.3.2-alpha.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": "
|
|
48
|
+
"gitHead": "8ab2db1497c3a5a805173b2d92248648b40a6f65"
|
|
49
49
|
}
|