Comparing version 0.2.1 to 0.2.2
@@ -15,3 +15,12 @@ "use strict"; | ||
options !== null && options !== void 0 ? options : (options = {}); | ||
const mergeWithGlobalOptions = (data) => { | ||
if (options.defaultPath) { | ||
data.defaultPath = options.defaultPath; | ||
} | ||
return data; | ||
}; | ||
const output = {}; | ||
if (options.defaultPath) { | ||
output.defaultPath = options.defaultPath; | ||
} | ||
let relations; | ||
@@ -40,3 +49,3 @@ const keys = [ | ||
if (value || options[constants_1.Parameter.FIELDS]) { | ||
output[constants_1.Parameter.FIELDS] = (0, parameter_1.parseQueryParameter)(key, value, options[constants_1.Parameter.FIELDS], relations); | ||
output[constants_1.Parameter.FIELDS] = (0, parameter_1.parseQueryParameter)(key, value, mergeWithGlobalOptions(options[constants_1.Parameter.FIELDS]), relations); | ||
} | ||
@@ -48,3 +57,3 @@ break; | ||
if (value || options[constants_1.Parameter.FILTERS]) { | ||
output[constants_1.Parameter.FILTERS] = (0, parameter_1.parseQueryParameter)(key, value, options[constants_1.Parameter.FILTERS], relations); | ||
output[constants_1.Parameter.FILTERS] = (0, parameter_1.parseQueryParameter)(key, value, mergeWithGlobalOptions(options[constants_1.Parameter.FILTERS]), relations); | ||
} | ||
@@ -63,3 +72,3 @@ break; | ||
if (value || options[constants_1.Parameter.SORT]) { | ||
output[constants_1.Parameter.SORT] = (0, parameter_1.parseQueryParameter)(key, value, options[constants_1.Parameter.SORT], relations); | ||
output[constants_1.Parameter.SORT] = (0, parameter_1.parseQueryParameter)(key, value, mergeWithGlobalOptions(options[constants_1.Parameter.SORT]), relations); | ||
} | ||
@@ -66,0 +75,0 @@ break; |
@@ -8,5 +8,9 @@ import { Parameter, URLParameter } from '../constants'; | ||
[K in `${Parameter}`]?: ParseParameterOptions<K>; | ||
} & { | ||
defaultPath?: string; | ||
}; | ||
export declare type ParseOutput = { | ||
[K in `${Parameter}`]?: ParseParameterOutput<K>; | ||
} & { | ||
defaultPath?: string; | ||
}; |
{ | ||
"name": "rapiq", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A tiny library which provides utility types/functions for request and response query handling.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -263,8 +263,7 @@ # rapiq 🌈 | ||
const output: ParseOutput = parseQuery(req.query, { | ||
defaultPath: 'user', | ||
fields: { | ||
defaultAlias: 'user', | ||
allowed: ['id', 'name', 'realm.id', 'realm.name'], | ||
}, | ||
filters: { | ||
defaultAlias: 'user', | ||
allowed: ['id', 'name', 'realm.id'], | ||
@@ -279,3 +278,2 @@ }, | ||
sort: { | ||
defaultAlias: 'user', | ||
allowed: ['id', 'name', 'realm.id'], | ||
@@ -282,0 +280,0 @@ } |
Sorry, the diff of this file is not supported yet
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
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
168361
2494
311