@dataui/crud-request
Advanced tools
Comparing version 5.1.4-alpha.1 to 5.1.4-alpha.2
@@ -1,2 +0,2 @@ | ||
import { QueryFields, QueryFilter, QueryFilterArr, QueryJoin, QueryJoinArr, QuerySort, QuerySortArr, SCondition } from '../types'; | ||
import { QueryExtra, QueryFields, QueryFilter, QueryFilterArr, QueryJoin, QueryJoinArr, QuerySort, QuerySortArr, SCondition } from '../types'; | ||
export interface CreateQueryParams { | ||
@@ -14,2 +14,3 @@ fields?: QueryFields; | ||
includeDeleted?: number; | ||
extra?: QueryExtra; | ||
} |
import { ObjectLiteral } from '@dataui/crud-util'; | ||
import { ClassTransformOptions } from 'class-transformer'; | ||
import { QueryFields, QueryFilter, QueryJoin, QuerySort, SCondition } from '../types'; | ||
export interface ParsedRequestParams { | ||
export interface ParsedRequestParams<EXTRA = {}> { | ||
fields: QueryFields; | ||
@@ -19,2 +19,3 @@ paramsFilter: QueryFilter[]; | ||
includeDeleted: number; | ||
extra?: EXTRA; | ||
} |
@@ -16,3 +16,4 @@ export interface RequestQueryBuilderOptions { | ||
includeDeleted?: string | string[]; | ||
extra?: string | string[]; | ||
}; | ||
} |
@@ -191,4 +191,5 @@ "use strict"; | ||
includeDeleted: 'include_deleted', | ||
extra: 'extra.', | ||
}, | ||
}; | ||
//# sourceMappingURL=request-query.builder.js.map |
import { ObjectLiteral } from '@dataui/crud-util'; | ||
import { ClassTransformOptions } from 'class-transformer'; | ||
import { CustomOperators, ParamsOptions, ParsedRequestParams } from './interfaces'; | ||
import { QueryFields, QueryFilter, QueryJoin, QuerySort, SCondition, SConditionAND, SFields } from './types'; | ||
import { QueryExtra, QueryFields, QueryFilter, QueryJoin, QuerySort, SCondition, SConditionAND, SFields } from './types'; | ||
export declare class RequestQueryParser implements ParsedRequestParams { | ||
@@ -20,2 +20,3 @@ fields: QueryFields; | ||
includeDeleted: number; | ||
extra?: QueryExtra; | ||
private _params; | ||
@@ -36,2 +37,4 @@ private _query; | ||
private parseQueryParam; | ||
private parseExtraFromQueryParam; | ||
private parseDotChainToObject; | ||
private parseValue; | ||
@@ -38,0 +41,0 @@ private parseValues; |
@@ -41,2 +41,3 @@ "use strict"; | ||
includeDeleted: this.includeDeleted, | ||
extra: this.extra, | ||
}; | ||
@@ -65,2 +66,3 @@ } | ||
this.includeDeleted = this.parseQueryParam('includeDeleted', this.numericParser.bind(this, 'includeDeleted'))[0]; | ||
this.extra = this.parseExtraFromQueryParam(); | ||
} | ||
@@ -126,2 +128,26 @@ } | ||
} | ||
parseExtraFromQueryParam() { | ||
const params = Array.isArray(this._options.paramNamesMap.extra) | ||
? this._options.paramNamesMap.extra | ||
: [this._options.paramNamesMap.extra]; | ||
const extraKeys = Object.keys(this._query || {}) | ||
.filter((k) => params.find((p) => k === null || k === void 0 ? void 0 : k.startsWith(p))) | ||
.reduce((o, k) => { | ||
const key = k.replace('extra.', ''); | ||
this.parseDotChainToObject(this._query[k], key, o); | ||
return o; | ||
}, {}); | ||
return Object.keys(extraKeys).length > 0 ? extraKeys : undefined; | ||
} | ||
parseDotChainToObject(data, key, result = {}) { | ||
if (key.includes('.')) { | ||
const keys = key.split('.'); | ||
const firstKey = keys.shift(); | ||
result[firstKey] = {}; | ||
this.parseDotChainToObject(data, keys.join('.'), result[firstKey]); | ||
} | ||
else { | ||
result[key] = this.parseValue(data); | ||
} | ||
} | ||
parseValue(val) { | ||
@@ -128,0 +154,0 @@ try { |
@@ -17,2 +17,3 @@ export declare type QueryFields = string[]; | ||
} | ||
export declare type QueryExtra = any | undefined; | ||
export declare type QuerySortArr = [string, QuerySortOperator]; | ||
@@ -19,0 +20,0 @@ export declare type QuerySortOperator = 'ASC' | 'DESC'; |
{ | ||
"name": "@dataui/crud-request", | ||
"description": "NestJs CRUD for RESTful APIs - request query builder", | ||
"version": "5.1.4-alpha.1", | ||
"version": "5.1.4-alpha.2", | ||
"license": "MIT", | ||
@@ -51,6 +51,6 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@dataui/crud-util": "^5.1.4-alpha.1", | ||
"@dataui/crud-util": "5.1.4-alpha.2", | ||
"qs": "^6.8.0" | ||
}, | ||
"gitHead": "b9ab6f16de84c6d49164bf362979bfd0a287f6ef" | ||
"gitHead": "35bdb60fb39684563ab07235b3f779993ef58bf1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
68243
940
+ Added@dataui/crud-util@5.1.4-alpha.2(transitive)
- Removed@dataui/crud-util@5.3.4(transitive)