@strapi/utils 4.9.0-exp.90df253ba90fd6879eb56a720a1f80d04ff745b8 → 4.10.0-beta.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.
package/lib/content-types.js
CHANGED
|
@@ -82,6 +82,7 @@ const isVisibleAttribute = (model, attributeName) => {
|
|
|
82
82
|
return getVisibleAttributes(model).includes(attributeName);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
const getOptions = (model) => _.assign({ draftAndPublish: false }, _.get(model, 'options', {}));
|
|
85
86
|
const hasDraftAndPublish = (model) => _.get(model, 'options.draftAndPublish', false) === true;
|
|
86
87
|
|
|
87
88
|
const isDraft = (data, model) =>
|
|
@@ -178,6 +179,7 @@ module.exports = {
|
|
|
178
179
|
getTimestamps,
|
|
179
180
|
isVisibleAttribute,
|
|
180
181
|
hasDraftAndPublish,
|
|
182
|
+
getOptions,
|
|
181
183
|
isDraft,
|
|
182
184
|
isSingleType,
|
|
183
185
|
isCollectionType,
|
package/lib/errors.js
CHANGED
|
@@ -89,6 +89,14 @@ class PolicyError extends ForbiddenError {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
class NotImplementedError extends ApplicationError {
|
|
93
|
+
constructor(message, details) {
|
|
94
|
+
super(message, details);
|
|
95
|
+
this.name = 'NotImplementedError';
|
|
96
|
+
this.message = message || 'This feature is not implemented yet';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
92
100
|
module.exports = {
|
|
93
101
|
HttpError,
|
|
94
102
|
ApplicationError,
|
|
@@ -101,4 +109,5 @@ module.exports = {
|
|
|
101
109
|
RateLimitError,
|
|
102
110
|
PayloadTooLargeError,
|
|
103
111
|
PolicyError,
|
|
112
|
+
NotImplementedError,
|
|
104
113
|
};
|
|
@@ -59,6 +59,12 @@ const defaultSanitizeSort = curry((schema, sort) => {
|
|
|
59
59
|
// Remove non attribute keys
|
|
60
60
|
traverseQuerySort(
|
|
61
61
|
({ key, attribute }, { remove }) => {
|
|
62
|
+
// ID is not an attribute per se, so we need to make
|
|
63
|
+
// an extra check to ensure we're not removing it
|
|
64
|
+
if (key === 'id') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
62
68
|
if (!attribute) {
|
|
63
69
|
remove(key);
|
|
64
70
|
}
|
package/lib/traverse/factory.js
CHANGED
|
@@ -39,7 +39,8 @@ module.exports = () => {
|
|
|
39
39
|
for (const key of keys) {
|
|
40
40
|
const attribute =
|
|
41
41
|
schema?.attributes?.[key] ??
|
|
42
|
-
//
|
|
42
|
+
// FIX: Needed to not break existing behavior on the API.
|
|
43
|
+
// It looks for the attribute in the DB metadata when the key is in snake_case
|
|
43
44
|
schema?.attributes?.[strapi.db.metadata.get(schema?.uid).columnToAttribute[key]];
|
|
44
45
|
|
|
45
46
|
const newPath = { ...path };
|
|
@@ -160,6 +160,8 @@ const populate = traverseFactory()
|
|
|
160
160
|
const { components } = attribute;
|
|
161
161
|
const { on, ...properties } = value;
|
|
162
162
|
|
|
163
|
+
const newValue = {};
|
|
164
|
+
|
|
163
165
|
// Handle legacy DZ params
|
|
164
166
|
let newProperties = properties;
|
|
165
167
|
|
|
@@ -168,11 +170,15 @@ const populate = traverseFactory()
|
|
|
168
170
|
newProperties = await recurse(visitor, { schema: componentSchema, path }, newProperties);
|
|
169
171
|
}
|
|
170
172
|
|
|
173
|
+
Object.assign(newValue, newProperties);
|
|
174
|
+
|
|
171
175
|
// Handle new morph fragment syntax
|
|
172
|
-
|
|
176
|
+
if (on) {
|
|
177
|
+
const newOn = await recurse(visitor, { schema, path }, { on });
|
|
173
178
|
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
// Recompose both syntaxes
|
|
180
|
+
Object.assign(newValue, newOn);
|
|
181
|
+
}
|
|
176
182
|
|
|
177
183
|
set(key, newValue);
|
|
178
184
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0-beta.0",
|
|
4
4
|
"description": "Shared utilities for the Strapi packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"node": ">=14.19.1 <=18.x.x",
|
|
47
47
|
"npm": ">=6.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "1519ef0e56d27b738f24fc88223797651ad47aaf"
|
|
50
50
|
}
|