Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(RequestQueryBuilder._options.paramNamesMap).forEach((key) => {
const name = RequestQueryBuilder._options.paramNamesMap[key];
this.paramNames[key] = isString(name) ? (name as string) : (name[0] as string);
});
}
sortBy(s: QuerySort | QuerySortArr | Array): this {
if (!isNil(s)) {
const param = this.checkQueryObjectParam('sort', []);
this.queryObject[param] = [
...this.queryObject[param],
...(Array.isArray(s) && !isString(s[0])
? (s as Array).map((o) => this.addSortBy(o))
: [this.addSortBy(s as QuerySort | QuerySortArr)]),
];
}
return this;
}
private setCondition(
f: QueryFilter | QueryFilterArr | Array,
cond: 'filter' | 'or',
): void {
if (!isNil(f)) {
const param = this.checkQueryObjectParam(cond, []);
this.queryObject[param] = [
...this.queryObject[param],
...(Array.isArray(f) && !isString(f[0])
? (f as Array).map((o) => this.cond(o, cond))
: [this.cond(f as QueryFilter | QueryFilterArr, cond)]),
];
}
}
return this._paramNames.filter((p) => {
const name = this._options.paramNamesMap[type];
return isString(name) ? name === p : (name as string[]).some((m) => m === p);
});
}
setJoin(j: QueryJoin | QueryJoinArr | Array): this {
if (!isNil(j)) {
const param = this.checkQueryObjectParam('join', []);
this.queryObject[param] = [
...this.queryObject[param],
...(Array.isArray(j) && !isString(j[0])
? (j as Array).map((o) => this.addJoin(o))
: [this.addJoin(j as QueryJoin | QueryJoinArr)]),
];
}
return this;
}
const name = (n) => {
const selected = qbOptions.paramNamesMap[n];
return isString(selected) ? selected : selected[0];
};