strapi-utils
Advanced tools
Comparing version 3.6.0-next.0 to 3.6.0
@@ -114,12 +114,12 @@ 'use strict'; | ||
return whereClauses | ||
.filter(({ value }) => !_.isNull(value)) | ||
.filter(({ field, value }) => { | ||
if (_.isNull(value)) { | ||
return false; | ||
} else if (_.isUndefined(value)) { | ||
strapi.log.warn(`The value of field: '${field}', in your where filter, is undefined.`); | ||
return false; | ||
} | ||
return true; | ||
}) | ||
.map(({ field, operator, value }) => { | ||
if (_.isUndefined(value)) { | ||
const err = new Error( | ||
`The value of field: '${field}', in your where filter, is undefined.` | ||
); | ||
err.status = 400; | ||
throw err; | ||
} | ||
if (BOOLEAN_OPERATORS.includes(operator)) { | ||
@@ -126,0 +126,0 @@ return { |
@@ -195,2 +195,11 @@ 'use strict'; | ||
/** | ||
* Checks if an attribute is of type `type` | ||
* @param {object} attribute | ||
* @param {string} type | ||
*/ | ||
const isTypedAttribute = (attribute, type) => { | ||
return _.has(attribute, 'type') && attribute.type === type; | ||
}; | ||
/** | ||
* Returns a route prefix for a contentType | ||
@@ -210,2 +219,3 @@ * @param {object} contentType | ||
isRelationalAttribute, | ||
isTypedAttribute, | ||
getPrivateAttributes, | ||
@@ -212,0 +222,0 @@ getTimestampsAttributes, |
@@ -50,3 +50,6 @@ 'use strict'; | ||
const whereParams = _.omit(params, ['_sort', '_start', '_limit', '_where', '_publicationState']); | ||
const whereParams = convertExtraRootParams( | ||
_.omit(params, ['_sort', '_start', '_limit', '_where', '_publicationState']) | ||
); | ||
const whereClauses = []; | ||
@@ -68,2 +71,20 @@ | ||
/** | ||
* Convert params prefixed with _ by removing the prefix after we have handle the internal params | ||
* NOTE: This is only a temporary patch for v3 to handle extra params coming from plugins | ||
* @param {object} params | ||
* @returns {object} | ||
*/ | ||
const convertExtraRootParams = params => { | ||
return Object.entries(params).reduce((acc, [key, value]) => { | ||
if (_.startsWith(key, '_') && !QUERY_OPERATORS.includes(key)) { | ||
acc[key.slice(1)] = value; | ||
} else { | ||
acc[key] = value; | ||
} | ||
return acc; | ||
}, {}); | ||
}; | ||
/** | ||
* Sort query parser | ||
@@ -70,0 +91,0 @@ * @param {string} sortQuery - ex: id:asc,price:desc |
{ | ||
"name": "strapi-utils", | ||
"version": "3.6.0-next.0", | ||
"version": "3.6.0", | ||
"description": "Shared utilities for the Strapi packages", | ||
@@ -19,3 +19,3 @@ "homepage": "https://strapi.io", | ||
"date-fns": "^2.19.0", | ||
"lodash": "4.17.20", | ||
"lodash": "4.17.21", | ||
"pino": "^4.7.1", | ||
@@ -49,3 +49,3 @@ "pluralize": "^8.0.0", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"gitHead": "fd18d2a67aec0bd2c76a375297ac30d4c3c0dfb7" | ||
"gitHead": "4ab210eec65d7f1a4f6334cdef4c797b4e6b9531" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
68288
2025
0
1
+ Addedlodash@4.17.21(transitive)
- Removedlodash@4.17.20(transitive)
Updatedlodash@4.17.21