@strapi/utils 4.8.1 → 4.8.2
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/env-helper.js +20 -0
- package/lib/traverse/query-populate.js +9 -3
- package/package.json +2 -2
- package/coverage/clover.xml +0 -638
- package/coverage/coverage-final.json +0 -24
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/lib/async.js.html +0 -223
- package/coverage/lcov-report/lib/content-types.js.html +0 -643
- package/coverage/lcov-report/lib/env-helper.js.html +0 -319
- package/coverage/lcov-report/lib/errors.js.html +0 -397
- package/coverage/lcov-report/lib/format-yup-error.js.html +0 -145
- package/coverage/lcov-report/lib/hooks.js.html +0 -415
- package/coverage/lcov-report/lib/import-default.js.html +0 -115
- package/coverage/lcov-report/lib/index.html +0 -326
- package/coverage/lcov-report/lib/pagination.js.html +0 -382
- package/coverage/lcov-report/lib/parse-type.js.html +0 -385
- package/coverage/lcov-report/lib/policy.js.html +0 -472
- package/coverage/lcov-report/lib/print-value.js.html +0 -241
- package/coverage/lcov-report/lib/provider-factory.js.html +0 -433
- package/coverage/lcov-report/lib/relations.js.html +0 -178
- package/coverage/lcov-report/lib/sanitize/visitors/allowed-fields.js.html +0 -367
- package/coverage/lcov-report/lib/sanitize/visitors/index.html +0 -191
- package/coverage/lcov-report/lib/sanitize/visitors/index.js.html +0 -112
- package/coverage/lcov-report/lib/sanitize/visitors/remove-password.js.html +0 -106
- package/coverage/lcov-report/lib/sanitize/visitors/remove-private.js.html +0 -118
- package/coverage/lcov-report/lib/sanitize/visitors/remove-restricted-relations.js.html +0 -316
- package/coverage/lcov-report/lib/sanitize/visitors/restricted-fields.js.html +0 -181
- package/coverage/lcov-report/lib/string-formatting.js.html +0 -322
- package/coverage/lcov-report/lib/validators.js.html +0 -445
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
package/lib/env-helper.js
CHANGED
|
@@ -71,6 +71,26 @@ const utils = {
|
|
|
71
71
|
const value = process.env[key];
|
|
72
72
|
return new Date(value);
|
|
73
73
|
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Gets a value from env that matches oneOf provided values
|
|
77
|
+
* @param {string} key
|
|
78
|
+
* @param {string[]} expectedValues
|
|
79
|
+
* @param {string|undefined} defaultValue
|
|
80
|
+
* @returns {string|undefined}
|
|
81
|
+
*/
|
|
82
|
+
oneOf(key, expectedValues, defaultValue) {
|
|
83
|
+
if (!expectedValues) {
|
|
84
|
+
throw new Error(`env.oneOf requires expectedValues`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (defaultValue && !expectedValues.includes(defaultValue)) {
|
|
88
|
+
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const rawValue = env(key, defaultValue);
|
|
92
|
+
return expectedValues.includes(rawValue) ? rawValue : defaultValue;
|
|
93
|
+
},
|
|
74
94
|
};
|
|
75
95
|
|
|
76
96
|
Object.assign(env, utils);
|
|
@@ -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.8.
|
|
3
|
+
"version": "4.8.2",
|
|
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": "cc73bed97b19d44f7c7999ab44f1a4288590d7ab"
|
|
50
50
|
}
|