querier-ts 2.0.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -78
- package/lib/__tests__/query.spec.d.ts +1 -0
- package/lib/__tests__/query.spec.d.ts.map +1 -0
- package/lib/__tests__/query.spec.js +193 -87
- package/lib/__tests__/query.spec.js.map +1 -0
- package/lib/core/errors/__tests__/invalid-argument-error.spec.d.ts +1 -0
- package/lib/core/errors/__tests__/invalid-argument-error.spec.d.ts.map +1 -0
- package/lib/core/errors/__tests__/invalid-argument-error.spec.js +7 -45
- package/lib/core/errors/__tests__/invalid-argument-error.spec.js.map +1 -0
- package/lib/core/errors/invalid-argument-error.d.ts +1 -12
- package/lib/core/errors/invalid-argument-error.d.ts.map +1 -1
- package/lib/core/errors/invalid-argument-error.js +2 -8
- package/lib/core/errors/invalid-argument-error.js.map +1 -1
- package/lib/core/types/nullable-condition.d.ts +2 -0
- package/lib/core/types/nullable-condition.d.ts.map +1 -0
- package/lib/core/types/nullable-condition.js +2 -0
- package/lib/core/types/nullable-condition.js.map +1 -0
- package/lib/core/types/query-conditions-group-nullable.d.ts +2 -1
- package/lib/core/types/query-conditions-group-nullable.d.ts.map +1 -1
- package/lib/core/types/validation-options.d.ts +4 -0
- package/lib/core/types/validation-options.d.ts.map +1 -0
- package/lib/core/types/validation-options.js +2 -0
- package/lib/core/types/validation-options.js.map +1 -0
- package/lib/core/validation/__tests__/query-row-validator.spec.d.ts +1 -0
- package/lib/core/validation/__tests__/query-row-validator.spec.d.ts.map +1 -0
- package/lib/core/validation/__tests__/query-row-validator.spec.js +48 -87
- package/lib/core/validation/__tests__/query-row-validator.spec.js.map +1 -0
- package/lib/core/validation/decorators/__tests__/number-validation.spec.d.ts +2 -1
- package/lib/core/validation/decorators/__tests__/number-validation.spec.d.ts.map +1 -0
- package/lib/core/validation/decorators/__tests__/number-validation.spec.js +40 -24
- package/lib/core/validation/decorators/__tests__/number-validation.spec.js.map +1 -0
- package/lib/core/validation/decorators/number-validaton.d.ts.map +1 -1
- package/lib/core/validation/decorators/number-validaton.js +6 -18
- package/lib/core/validation/decorators/number-validaton.js.map +1 -1
- package/lib/core/validation/query-row-validator.d.ts +6 -40
- package/lib/core/validation/query-row-validator.d.ts.map +1 -1
- package/lib/core/validation/query-row-validator.js +22 -44
- package/lib/core/validation/query-row-validator.js.map +1 -1
- package/lib/query.d.ts +18 -17
- package/lib/query.d.ts.map +1 -1
- package/lib/query.js +57 -59
- package/lib/query.js.map +1 -1
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.d.ts.map +1 -0
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.js +6 -7
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.js.map +1 -0
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.d.ts.map +1 -0
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.js +25 -26
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.js.map +1 -0
- package/lib/utils/functions/generic/__tests__/get-entries.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/get-entries.spec.d.ts.map +1 -0
- package/lib/utils/functions/generic/__tests__/get-entries.spec.js +7 -8
- package/lib/utils/functions/generic/__tests__/get-entries.spec.js.map +1 -0
- package/lib/utils/functions/generic/__tests__/get-object-property-names.spec.d.ts +2 -0
- package/lib/utils/functions/generic/__tests__/get-object-property-names.spec.d.ts.map +1 -0
- package/lib/utils/functions/generic/__tests__/get-object-property-names.spec.js +82 -0
- package/lib/utils/functions/generic/__tests__/get-object-property-names.spec.js.map +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.d.ts +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.d.ts.map +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.js +10 -11
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.js.map +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-property.spec.d.ts +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-property.spec.d.ts.map +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-property.spec.js +24 -12
- package/lib/utils/functions/sort/__tests__/sort-by-property.spec.js.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.d.ts +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.js +14 -15
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.js.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-number.spec.d.ts +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-number.spec.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-number.spec.js +19 -20
- package/lib/utils/functions/type-guards/__tests__/is-number.spec.js.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-object.spec.d.ts +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-object.spec.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-object.spec.js +19 -20
- package/lib/utils/functions/type-guards/__tests__/is-object.spec.js.map +1 -0
- package/package.json +15 -13
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { QueryConditionsGroupNullable } from '../types';
|
|
2
|
+
import type { ValidationOptions } from '../types/validation-options';
|
|
2
3
|
/**
|
|
3
4
|
* Validates a row in the query.
|
|
4
5
|
*/
|
|
5
|
-
export declare class QueryRowValidator
|
|
6
|
-
|
|
7
|
-
* Row to be validated.
|
|
8
|
-
*/
|
|
9
|
-
private row;
|
|
10
|
-
/**
|
|
11
|
-
* Conditions to be applied to the row.
|
|
12
|
-
*/
|
|
13
|
-
private conditionsObject;
|
|
14
|
-
/**
|
|
15
|
-
* Indicates whether conditions with `null` and `undefined` values should be
|
|
16
|
-
* skipped.
|
|
17
|
-
*/
|
|
18
|
-
private ignoreNullValues;
|
|
19
|
-
/**
|
|
20
|
-
* Initializes the validator.
|
|
21
|
-
*
|
|
22
|
-
* @param row Row to validated.
|
|
23
|
-
* @param config Validator configuration.
|
|
24
|
-
*/
|
|
25
|
-
private constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Validates a row.
|
|
28
|
-
*
|
|
29
|
-
* @param row Row to validated.
|
|
30
|
-
* @param config Validator configuration.
|
|
31
|
-
*/
|
|
32
|
-
static validate<T extends object>(row: T, config: QueryRowValidatorInitializer<T>): boolean;
|
|
6
|
+
export declare class QueryRowValidator {
|
|
7
|
+
#private;
|
|
33
8
|
/**
|
|
34
9
|
* Validates all conditions of the row.
|
|
35
10
|
*
|
|
36
11
|
* @returns Validation result.
|
|
37
12
|
*/
|
|
38
|
-
|
|
13
|
+
static validate<T extends object>(row: T, condition: QueryConditionsGroupNullable<T>, options?: ValidationOptions): boolean;
|
|
39
14
|
/**
|
|
40
15
|
* Validate a condition to a specific column.
|
|
41
16
|
*
|
|
@@ -44,15 +19,6 @@ export declare class QueryRowValidator<T extends object> {
|
|
|
44
19
|
*
|
|
45
20
|
* @returns Validation result.
|
|
46
21
|
*/
|
|
47
|
-
private validateColumnCondition;
|
|
48
|
-
/**
|
|
49
|
-
* Validates an object inside the row.
|
|
50
|
-
*
|
|
51
|
-
* @param obj Object to validated.
|
|
52
|
-
* @param conditionsObject Conditions to be applied to the object.
|
|
53
|
-
*
|
|
54
|
-
* @returns Validation result.
|
|
55
|
-
*/
|
|
56
|
-
private validateInnerObject;
|
|
22
|
+
private static validateColumnCondition;
|
|
57
23
|
}
|
|
58
24
|
//# sourceMappingURL=query-row-validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-row-validator.d.ts","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"query-row-validator.d.ts","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;GAEG;AACH,qBAAa,iBAAiB;;IAK5B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,EAC9B,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,4BAA4B,CAAC,CAAC,CAAC,EAC1C,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO;IAiBV;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAkCvC"}
|
|
@@ -1,38 +1,28 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _a, _QueryRowValidator_defaultOptions;
|
|
1
7
|
import { compareArrays, getEntries } from '../../utils/functions/generic';
|
|
2
8
|
import { isFunction, isObject } from '../../utils/functions/type-guards';
|
|
3
9
|
/**
|
|
4
10
|
* Validates a row in the query.
|
|
5
11
|
*/
|
|
6
12
|
export class QueryRowValidator {
|
|
7
|
-
/**
|
|
8
|
-
* Initializes the validator.
|
|
9
|
-
*
|
|
10
|
-
* @param row Row to validated.
|
|
11
|
-
* @param config Validator configuration.
|
|
12
|
-
*/
|
|
13
|
-
constructor(row, config) {
|
|
14
|
-
this.row = row;
|
|
15
|
-
this.conditionsObject = config.conditionsObject;
|
|
16
|
-
this.ignoreNullValues = config.ignoreNullValues;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Validates a row.
|
|
20
|
-
*
|
|
21
|
-
* @param row Row to validated.
|
|
22
|
-
* @param config Validator configuration.
|
|
23
|
-
*/
|
|
24
|
-
static validate(row, config) {
|
|
25
|
-
const validator = new QueryRowValidator(row, config);
|
|
26
|
-
return validator.validate();
|
|
27
|
-
}
|
|
28
13
|
/**
|
|
29
14
|
* Validates all conditions of the row.
|
|
30
15
|
*
|
|
31
16
|
* @returns Validation result.
|
|
32
17
|
*/
|
|
33
|
-
validate() {
|
|
34
|
-
const
|
|
35
|
-
|
|
18
|
+
static validate(row, condition, options) {
|
|
19
|
+
for (const [column, columnCondition] of getEntries(condition)) {
|
|
20
|
+
const validated = this.validateColumnCondition(row, column, columnCondition, options ?? __classPrivateFieldGet(this, _a, "f", _QueryRowValidator_defaultOptions));
|
|
21
|
+
if (!validated) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
36
26
|
}
|
|
37
27
|
/**
|
|
38
28
|
* Validate a condition to a specific column.
|
|
@@ -42,12 +32,12 @@ export class QueryRowValidator {
|
|
|
42
32
|
*
|
|
43
33
|
* @returns Validation result.
|
|
44
34
|
*/
|
|
45
|
-
validateColumnCondition(
|
|
46
|
-
if (
|
|
35
|
+
static validateColumnCondition(row, column, condition, options) {
|
|
36
|
+
if (options.ignoreNullValues &&
|
|
47
37
|
(condition === null || condition === undefined)) {
|
|
48
38
|
return true;
|
|
49
39
|
}
|
|
50
|
-
const cellValue =
|
|
40
|
+
const cellValue = row[column];
|
|
51
41
|
if (isFunction(condition)) {
|
|
52
42
|
return condition(cellValue);
|
|
53
43
|
}
|
|
@@ -57,25 +47,13 @@ export class QueryRowValidator {
|
|
|
57
47
|
: false;
|
|
58
48
|
}
|
|
59
49
|
if (isObject(condition)) {
|
|
60
|
-
return isObject(cellValue)
|
|
61
|
-
? this.validateInnerObject(cellValue, condition)
|
|
62
|
-
: false;
|
|
50
|
+
return isObject(cellValue) ? this.validate(cellValue, condition) : false;
|
|
63
51
|
}
|
|
64
52
|
return cellValue === condition;
|
|
65
53
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Validates an object inside the row.
|
|
68
|
-
*
|
|
69
|
-
* @param obj Object to validated.
|
|
70
|
-
* @param conditionsObject Conditions to be applied to the object.
|
|
71
|
-
*
|
|
72
|
-
* @returns Validation result.
|
|
73
|
-
*/
|
|
74
|
-
validateInnerObject(obj, conditionsObject) {
|
|
75
|
-
return QueryRowValidator.validate(obj, {
|
|
76
|
-
conditionsObject,
|
|
77
|
-
ignoreNullValues: this.ignoreNullValues,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
54
|
}
|
|
55
|
+
_a = QueryRowValidator;
|
|
56
|
+
_QueryRowValidator_defaultOptions = { value: {
|
|
57
|
+
ignoreNullValues: false,
|
|
58
|
+
} };
|
|
81
59
|
//# sourceMappingURL=query-row-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-row-validator.js","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAQzE;;GAEG;AACH,MAAM,OAAO,iBAAiB;
|
|
1
|
+
{"version":3,"file":"query-row-validator.js","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAQzE;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAK5B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CACb,GAAM,EACN,SAA0C,EAC1C,OAA2B;QAE3B,KAAK,MAAM,CAAC,MAAM,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ts
CHANGED
|
@@ -49,11 +49,6 @@ import type { PropOf } from './utils/types';
|
|
|
49
49
|
*/
|
|
50
50
|
export declare class Query<T extends object> {
|
|
51
51
|
#private;
|
|
52
|
-
/**
|
|
53
|
-
* Indicates whether conditions with `null` and `undefined` values should be
|
|
54
|
-
* skipped.
|
|
55
|
-
*/
|
|
56
|
-
private ignoreNullValues;
|
|
57
52
|
/**
|
|
58
53
|
* Initializes the query.
|
|
59
54
|
*
|
|
@@ -78,6 +73,13 @@ export declare class Query<T extends object> {
|
|
|
78
73
|
select<TColumns extends PropOf<T>[]>(...columns: TColumns): Query<{
|
|
79
74
|
[P in TColumns[number]]: T[P];
|
|
80
75
|
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Maps each row to a new object and returns a new query.
|
|
78
|
+
*
|
|
79
|
+
* @param callback Function to be called for each row.
|
|
80
|
+
* @returns New query with the mapped rows.
|
|
81
|
+
*/
|
|
82
|
+
map<TReturn extends object>(callback: (obj: T) => TReturn): Query<TReturn>;
|
|
81
83
|
/**
|
|
82
84
|
* Applies conditions to the query.
|
|
83
85
|
*
|
|
@@ -176,6 +178,8 @@ export declare class Query<T extends object> {
|
|
|
176
178
|
/**
|
|
177
179
|
* Returns the values of the first (selected) column of all rows.
|
|
178
180
|
*
|
|
181
|
+
* @param column (Optional) The column to get the values from.
|
|
182
|
+
*
|
|
179
183
|
* @returns Values from the first (selected) column.
|
|
180
184
|
*/
|
|
181
185
|
column(): T[PropOf<T>][];
|
|
@@ -209,11 +213,11 @@ export declare class Query<T extends object> {
|
|
|
209
213
|
*/
|
|
210
214
|
limit(limit: number): this;
|
|
211
215
|
/**
|
|
212
|
-
*
|
|
216
|
+
* Filters the rows according to the given conditions.
|
|
213
217
|
*
|
|
214
|
-
* @
|
|
218
|
+
* @param condition Object or callback function.
|
|
215
219
|
*/
|
|
216
|
-
private
|
|
220
|
+
private filterRows;
|
|
217
221
|
/**
|
|
218
222
|
* Returns the first selected column or the first key of some row.
|
|
219
223
|
*
|
|
@@ -221,19 +225,16 @@ export declare class Query<T extends object> {
|
|
|
221
225
|
*/
|
|
222
226
|
private getFirstColumn;
|
|
223
227
|
/**
|
|
224
|
-
*
|
|
228
|
+
* Returns the rows that should be used in the final results.
|
|
225
229
|
*
|
|
226
|
-
* @
|
|
230
|
+
* @returns Rows within the specified limit.
|
|
227
231
|
*/
|
|
228
|
-
private
|
|
232
|
+
private getLimitedRows;
|
|
229
233
|
/**
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* @param row Row to validate.
|
|
233
|
-
* @param condition Conditions object.
|
|
234
|
+
* Copies the state of the current query into the given query.
|
|
234
235
|
*
|
|
235
|
-
* @
|
|
236
|
+
* @param query Query to copy the state into.
|
|
236
237
|
*/
|
|
237
|
-
private
|
|
238
|
+
private cloneStateInto;
|
|
238
239
|
}
|
|
239
240
|
//# sourceMappingURL=query.d.ts.map
|
package/lib/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAOnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBAAa,KAAK,CAAC,CAAC,SAAS,MAAM;;IAgBjC;;;;OAIG;IACH,OAAO;IAIP;;;;;;OAMG;IACH,MAAM,CAAC,IAAI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CAAC,CAAC,CAAC,GAAG,KAAK;IAO9B;;;;;;OAMG;IACH,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IACxB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE;IAehE;;;;;OAKG;IACH,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;IAY1B;;;;;;;;;OASG;IAEH,IAAI,CAAkB,YAAY,EAAE,MAAM,GAAG,IAAI;IAMjD;;;;;;;;OAQG;IAEH,KAAK,CAAkB,KAAK,EAAE,MAAM,GAAG,IAAI;IAM3C;;;;OAIG;IACH,OAAO,CAAC,UAAU;IA4BlB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAgBtB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAStB;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAIvB"}
|
package/lib/query.js
CHANGED
|
@@ -18,7 +18,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
18
18
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
19
19
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
20
|
};
|
|
21
|
-
var _Query_rows, _Query_startAt,
|
|
21
|
+
var _Query_rows, _Query_startAt, _Query_limit;
|
|
22
22
|
import { QueryRowValidator } from './core/validation';
|
|
23
23
|
import { integer, min, validateNumbers } from './core/validation/decorators';
|
|
24
24
|
import { getObjectPropertyNames } from './utils/functions/generic/get-object-property-names';
|
|
@@ -85,19 +85,10 @@ export class Query {
|
|
|
85
85
|
* Number of results to skip.
|
|
86
86
|
*/
|
|
87
87
|
_Query_startAt.set(this, 0);
|
|
88
|
-
/**
|
|
89
|
-
* Columns to order the results by.
|
|
90
|
-
*/
|
|
91
|
-
_Query_orderBy.set(this, []);
|
|
92
88
|
/**
|
|
93
89
|
* Limit of results.
|
|
94
90
|
*/
|
|
95
91
|
_Query_limit.set(this, null);
|
|
96
|
-
/**
|
|
97
|
-
* Indicates whether conditions with `null` and `undefined` values should be
|
|
98
|
-
* skipped.
|
|
99
|
-
*/
|
|
100
|
-
this.ignoreNullValues = false;
|
|
101
92
|
__classPrivateFieldSet(this, _Query_rows, [...rows], "f");
|
|
102
93
|
}
|
|
103
94
|
/**
|
|
@@ -129,27 +120,24 @@ export class Query {
|
|
|
129
120
|
}
|
|
130
121
|
// create new query
|
|
131
122
|
const query = new Query(rows);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
__classPrivateFieldSet(query, _Query_orderBy, orderBy, "f");
|
|
123
|
+
this.cloneStateInto(query);
|
|
124
|
+
return query;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Maps each row to a new object and returns a new query.
|
|
128
|
+
*
|
|
129
|
+
* @param callback Function to be called for each row.
|
|
130
|
+
* @returns New query with the mapped rows.
|
|
131
|
+
*/
|
|
132
|
+
map(callback) {
|
|
133
|
+
// map rows
|
|
134
|
+
const rows = [];
|
|
135
|
+
for (const row of __classPrivateFieldGet(this, _Query_rows, "f")) {
|
|
136
|
+
rows.push(callback(row));
|
|
149
137
|
}
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
138
|
+
// create new query
|
|
139
|
+
const query = new Query(rows);
|
|
140
|
+
this.cloneStateInto(query);
|
|
153
141
|
return query;
|
|
154
142
|
}
|
|
155
143
|
/**
|
|
@@ -181,9 +169,7 @@ export class Query {
|
|
|
181
169
|
* @returns Current query.
|
|
182
170
|
*/
|
|
183
171
|
filterWhere(condition) {
|
|
184
|
-
this.ignoreNullValues
|
|
185
|
-
this.filterRows(condition);
|
|
186
|
-
this.ignoreNullValues = false;
|
|
172
|
+
this.filterRows(condition, { ignoreNullValues: true });
|
|
187
173
|
return this;
|
|
188
174
|
}
|
|
189
175
|
/**
|
|
@@ -211,7 +197,7 @@ export class Query {
|
|
|
211
197
|
* @returns Current query.
|
|
212
198
|
*/
|
|
213
199
|
orderBy(...columns) {
|
|
214
|
-
__classPrivateFieldSet(this,
|
|
200
|
+
__classPrivateFieldSet(this, _Query_rows, __classPrivateFieldGet(this, _Query_rows, "f").sort(sortByProperties(...columns)), "f");
|
|
215
201
|
return this;
|
|
216
202
|
}
|
|
217
203
|
/**
|
|
@@ -304,7 +290,11 @@ export class Query {
|
|
|
304
290
|
* @returns Array with the values of all rows.
|
|
305
291
|
*/
|
|
306
292
|
values() {
|
|
307
|
-
|
|
293
|
+
const rows = [];
|
|
294
|
+
for (const row of this.getLimitedRows()) {
|
|
295
|
+
rows.push(Object.values(row));
|
|
296
|
+
}
|
|
297
|
+
return rows;
|
|
308
298
|
}
|
|
309
299
|
/**
|
|
310
300
|
* Defines the number of rows to skip.
|
|
@@ -334,16 +324,30 @@ export class Query {
|
|
|
334
324
|
return this;
|
|
335
325
|
}
|
|
336
326
|
/**
|
|
337
|
-
*
|
|
327
|
+
* Filters the rows according to the given conditions.
|
|
338
328
|
*
|
|
339
|
-
* @
|
|
329
|
+
* @param condition Object or callback function.
|
|
340
330
|
*/
|
|
341
|
-
|
|
342
|
-
const rows =
|
|
343
|
-
|
|
344
|
-
|
|
331
|
+
filterRows(condition, options) {
|
|
332
|
+
const rows = __classPrivateFieldGet(this, _Query_rows, "f");
|
|
333
|
+
const result = [];
|
|
334
|
+
if (isFunction(condition)) {
|
|
335
|
+
for (let i = 0; i < rows.length; i++) {
|
|
336
|
+
const row = rows[i];
|
|
337
|
+
if (condition(row)) {
|
|
338
|
+
result.push(row);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
345
341
|
}
|
|
346
|
-
|
|
342
|
+
else {
|
|
343
|
+
for (let i = 0; i < rows.length; i++) {
|
|
344
|
+
const row = rows[i];
|
|
345
|
+
if (QueryRowValidator.validate(row, condition, options)) {
|
|
346
|
+
result.push(row);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
__classPrivateFieldSet(this, _Query_rows, result, "f");
|
|
347
351
|
}
|
|
348
352
|
/**
|
|
349
353
|
* Returns the first selected column or the first key of some row.
|
|
@@ -362,31 +366,25 @@ export class Query {
|
|
|
362
366
|
return null;
|
|
363
367
|
}
|
|
364
368
|
/**
|
|
365
|
-
*
|
|
369
|
+
* Returns the rows that should be used in the final results.
|
|
366
370
|
*
|
|
367
|
-
* @
|
|
371
|
+
* @returns Rows within the specified limit.
|
|
368
372
|
*/
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
: this.validateRow(row, condition)), "f");
|
|
373
|
+
getLimitedRows() {
|
|
374
|
+
const rows = [...__classPrivateFieldGet(this, _Query_rows, "f")];
|
|
375
|
+
return rows.slice(__classPrivateFieldGet(this, _Query_startAt, "f"), __classPrivateFieldGet(this, _Query_startAt, "f") + (__classPrivateFieldGet(this, _Query_limit, "f") ?? rows.length));
|
|
373
376
|
}
|
|
374
377
|
/**
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* @param row Row to validate.
|
|
378
|
-
* @param condition Conditions object.
|
|
378
|
+
* Copies the state of the current query into the given query.
|
|
379
379
|
*
|
|
380
|
-
* @
|
|
380
|
+
* @param query Query to copy the state into.
|
|
381
381
|
*/
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
ignoreNullValues: this.ignoreNullValues,
|
|
386
|
-
});
|
|
382
|
+
cloneStateInto(query) {
|
|
383
|
+
__classPrivateFieldSet(query, _Query_startAt, __classPrivateFieldGet(this, _Query_startAt, "f"), "f");
|
|
384
|
+
__classPrivateFieldSet(query, _Query_limit, __classPrivateFieldGet(this, _Query_limit, "f"), "f");
|
|
387
385
|
}
|
|
388
386
|
}
|
|
389
|
-
_Query_rows = new WeakMap(), _Query_startAt = new WeakMap(),
|
|
387
|
+
_Query_rows = new WeakMap(), _Query_startAt = new WeakMap(), _Query_limit = new WeakMap();
|
|
390
388
|
__decorate([
|
|
391
389
|
validateNumbers,
|
|
392
390
|
__param(0, integer),
|
package/lib/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,OAAO,KAAK;IAgBhB;;;;OAIG;IACH,YAAoB,IAAS;QApB7B;;WAEG;QACH,sBAAa,EAAE,EAAC;QAEhB;;WAEG;QACH,yBAAW,CAAC,EAAC;QAEb;;WAEG;QACH,uBAAwB,IAAI,EAAC;QAQ3B,uBAAA,IAAI,eAAS,CAAC,GAAG,IAAI,CAAC,MAAA,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAmB,IAAS;QACrC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,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QACrB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACK,cAAc;QACpB,MAAM,IAAI,GAAG,CAAC,GAAG,uBAAA,IAAI,mBAAM,CAAC,CAAC;QAE7B,OAAO,IAAI,CAAC,KAAK,CACf,uBAAA,IAAI,sBAAS,EACb,uBAAA,IAAI,sBAAS,GAAG,CAAC,uBAAA,IAAI,oBAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAC7C,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAmB,KAAe;QACtD,uBAAA,KAAK,kBAAY,uBAAA,IAAI,sBAAS,MAAA,CAAC;QAC/B,uBAAA,KAAK,gBAAU,uBAAA,IAAI,oBAAO,MAAA,CAAC;IAC7B,CAAC;CACF;;AAnGC;IADC,eAAe;IACV,WAAA,OAAO,CAAA;IAAE,WAAA,GAAG,CAAC,CAAC,CAAC,CAAA;iCAIpB;AAYD;IADC,eAAe;IACT,WAAA,OAAO,CAAA;IAAE,WAAA,GAAG,CAAC,CAAC,CAAC,CAAA;kCAIrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-arrays.spec.d.ts","sourceRoot":"","sources":["../../../../../src/utils/functions/generic/__tests__/compare-arrays.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const compare_arrays_1 = require("../compare-arrays");
|
|
1
|
+
import { compareArrays } from '../compare-arrays';
|
|
4
2
|
describe('compareArrays', () => {
|
|
5
3
|
it('returns true for ly equal arrays', () => {
|
|
6
4
|
const a = [{ x: 1 }, { y: 2 }];
|
|
7
5
|
const b = [{ x: 1 }, { y: 2 }];
|
|
8
|
-
expect(
|
|
6
|
+
expect(compareArrays(a, b)).toBe(true);
|
|
9
7
|
});
|
|
10
8
|
it('returns false for ly different arrays', () => {
|
|
11
|
-
expect(
|
|
9
|
+
expect(compareArrays([{ x: 1 }], [{ x: 2 }])).toBe(false);
|
|
12
10
|
});
|
|
13
11
|
it('returns false when order differs', () => {
|
|
14
|
-
expect(
|
|
12
|
+
expect(compareArrays([{ a: 1 }, { b: 2 }], [{ b: 2 }, { a: 1 }])).toBe(false);
|
|
15
13
|
});
|
|
16
14
|
it('works with nested objects', () => {
|
|
17
15
|
const a = [{ x: { y: 1 } }];
|
|
18
16
|
const b = [{ x: { y: 1 } }];
|
|
19
|
-
expect(
|
|
17
|
+
expect(compareArrays(a, b)).toBe(true);
|
|
20
18
|
});
|
|
21
19
|
});
|
|
20
|
+
//# sourceMappingURL=compare-arrays.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-arrays.spec.js","sourceRoot":"","sources":["../../../../../src/utils/functions/generic/__tests__/compare-arrays.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAE/B,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC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