@strapi/utils 5.0.6 → 5.1.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/convert-query-params.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _ from "lodash";
|
|
2
2
|
import ___default, { kebabCase } from "lodash";
|
|
3
3
|
import * as dates$1 from "date-fns";
|
|
4
|
-
import { has, union, getOr, assoc, assign, cloneDeep, remove, eq, curry, isObject, isNil, clone, isArray, isEmpty, toPath, defaults, isString,
|
|
4
|
+
import { has, union, getOr, assoc, assign, cloneDeep, remove, eq, curry, isObject, isNil, clone, isArray, isEmpty, toPath, defaults, isString, toNumber, get, isInteger, isBoolean, pick, omit, trim, pipe as pipe$1, split, map as map$1, flatten, first, identity, constant, join, merge, trimChars, trimCharsEnd, trimCharsStart, isNumber } from "lodash/fp";
|
|
5
5
|
import { randomUUID } from "crypto";
|
|
6
6
|
import { machineIdSync } from "node-machine-id";
|
|
7
7
|
import * as yup$1 from "yup";
|
|
@@ -943,14 +943,14 @@ const createTransformer = ({ getModel }) => {
|
|
|
943
943
|
return transformedSort;
|
|
944
944
|
};
|
|
945
945
|
const convertStartQueryParams = (startQuery) => {
|
|
946
|
-
const startAsANumber =
|
|
946
|
+
const startAsANumber = toNumber(startQuery);
|
|
947
947
|
if (!___default.isInteger(startAsANumber) || startAsANumber < 0) {
|
|
948
948
|
throw new Error(`convertStartQueryParams expected a positive integer got ${startAsANumber}`);
|
|
949
949
|
}
|
|
950
950
|
return startAsANumber;
|
|
951
951
|
};
|
|
952
952
|
const convertLimitQueryParams = (limitQuery) => {
|
|
953
|
-
const limitAsANumber =
|
|
953
|
+
const limitAsANumber = toNumber(limitQuery);
|
|
954
954
|
if (!___default.isInteger(limitAsANumber) || limitAsANumber !== -1 && limitAsANumber < 0) {
|
|
955
955
|
throw new Error(`convertLimitQueryParams expected a positive integer got ${limitAsANumber}`);
|
|
956
956
|
}
|
|
@@ -1029,7 +1029,7 @@ const createTransformer = ({ getModel }) => {
|
|
|
1029
1029
|
if (___default.isString(subPopulate)) {
|
|
1030
1030
|
try {
|
|
1031
1031
|
const subPopulateAsBoolean = parseType({ type: "boolean", value: subPopulate });
|
|
1032
|
-
return subPopulateAsBoolean
|
|
1032
|
+
return subPopulateAsBoolean ? { ...acc, [key]: true } : acc;
|
|
1033
1033
|
} catch {
|
|
1034
1034
|
}
|
|
1035
1035
|
}
|
|
@@ -1043,14 +1043,22 @@ const createTransformer = ({ getModel }) => {
|
|
|
1043
1043
|
const isMorphLikeRelationalAttribute = isDynamicZoneAttribute(attribute) || isMorphToRelationalAttribute(attribute);
|
|
1044
1044
|
if (isMorphLikeRelationalAttribute) {
|
|
1045
1045
|
const hasInvalidProperties = Object.keys(subPopulate).some(
|
|
1046
|
-
(key2) => !["on", "count"].includes(key2)
|
|
1046
|
+
(key2) => !["populate", "on", "count"].includes(key2)
|
|
1047
1047
|
);
|
|
1048
1048
|
if (hasInvalidProperties) {
|
|
1049
1049
|
throw new Error(
|
|
1050
1050
|
`Invalid nested populate for ${schema.info?.singularName}.${key} (${schema.uid}). Expected a fragment ("on") or "count" but found ${JSON.stringify(subPopulate)}`
|
|
1051
1051
|
);
|
|
1052
1052
|
}
|
|
1053
|
+
if ("populate" in subPopulate && subPopulate.populate !== "*") {
|
|
1054
|
+
throw new Error(
|
|
1055
|
+
`Invalid nested population query detected. When using 'populate' within polymorphic structures, its value must be '*' to indicate all second level links. Specific field targeting is not supported here. Consider using the fragment API for more granular population control.`
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1053
1058
|
const newSubPopulate = {};
|
|
1059
|
+
if ("populate" in subPopulate) {
|
|
1060
|
+
Object.assign(newSubPopulate, { populate: true });
|
|
1061
|
+
}
|
|
1054
1062
|
if (hasPopulateFragmentDefined(subPopulate)) {
|
|
1055
1063
|
Object.assign(newSubPopulate, {
|
|
1056
1064
|
on: Object.entries(subPopulate.on).reduce(
|