Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
`The filter "${filterType}" is not valid.`)
}
}
// Attach include option.
if (reservedKeys.include in query) {
request.include = (Array.isArray(query[reservedKeys.include]) ?
query[reservedKeys.include] :
query[reservedKeys.include].split(','))
.map(i => i.split('.').map(x => inflect(x)).slice(0, includeLimit))
// Manually expand nested includes.
for (const path of request.include)
for (let i = path.length - 1; i > 0; i--) {
const j = path.slice(0, i)
if (!request.include.some(deepEqual.bind(null, j)))
request.include.push(j)
}
}
// Attach sort option.
if (reservedKeys.sort in query)
request.options.sort = (Array.isArray(query.sort) ?
query.sort : query.sort.split(','))
.reduce((sort, field) => {
if (field.charAt(0) === '-') sort[inflect(field.slice(1))] = false
else sort[inflect(field)] = true
return sort
}, {})
// Attach offset option.
if (pageOffset in query)
value = castString.get(fields[field][keys.type])(value, options)
request.options.match[field] = value
}
}
// Attach include option.
if (reservedKeys.include in query) {
request.include = (Array.isArray(query[reservedKeys.include]) ?
query[reservedKeys.include] : [ query[reservedKeys.include] ])
.map(i => i.split('.').slice(0, includeLimit))
// Manually expand nested includes.
for (let path of request.include) {
for (let i = path.length - 1; i > 0; i--) {
const j = path.slice(0, i)
if (!request.include.some(deepEqual.bind(null, j)))
request.include.push(j)
}
}
}
// Attach sort option.
if (reservedKeys.sort in query) {
let sort = query.sort
if (!Array.isArray(sort)) sort = [ sort ]
request.options.sort = sort.reduce((sort, field) => {
const firstChar = field.charAt(0)
if (firstChar === '-') sort[field.slice(1)] = false
else sort[field] = true