querier-ts 1.0.1 → 1.0.2
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 +1 -1
- package/lib/core/errors/index.d.ts +1 -0
- package/lib/core/errors/index.d.ts.map +1 -0
- package/lib/core/errors/index.js +2 -17
- package/lib/core/errors/index.js.map +1 -0
- package/lib/core/errors/invalid-argument-error.d.ts +1 -0
- package/lib/core/errors/invalid-argument-error.d.ts.map +1 -0
- package/lib/core/errors/invalid-argument-error.js +2 -5
- package/lib/core/errors/invalid-argument-error.js.map +1 -0
- package/lib/core/types/attribute-validation-function.d.ts +1 -0
- package/lib/core/types/attribute-validation-function.d.ts.map +1 -0
- package/lib/core/types/attribute-validation-function.js +2 -2
- package/lib/core/types/attribute-validation-function.js.map +1 -0
- package/lib/core/types/column-condition.d.ts +3 -2
- package/lib/core/types/column-condition.d.ts.map +1 -0
- package/lib/core/types/column-condition.js +2 -2
- package/lib/core/types/column-condition.js.map +1 -0
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/index.d.ts.map +1 -0
- package/lib/core/types/index.js +5 -20
- package/lib/core/types/index.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 -0
- package/lib/core/types/query-conditions-group-nullable.js +2 -2
- package/lib/core/types/query-conditions-group-nullable.js.map +1 -0
- package/lib/core/types/query-conditions-group.d.ts +2 -1
- package/lib/core/types/query-conditions-group.d.ts.map +1 -0
- package/lib/core/types/query-conditions-group.js +2 -2
- package/lib/core/types/query-conditions-group.js.map +1 -0
- package/lib/core/types/query-row-validator-initializer.d.ts +2 -1
- package/lib/core/types/query-row-validator-initializer.d.ts.map +1 -0
- package/lib/core/types/query-row-validator-initializer.js +2 -2
- package/lib/core/types/query-row-validator-initializer.js.map +1 -0
- package/lib/core/validation/decorators/index.d.ts +1 -0
- package/lib/core/validation/decorators/index.d.ts.map +1 -0
- package/lib/core/validation/decorators/index.js +2 -17
- package/lib/core/validation/decorators/index.js.map +1 -0
- package/lib/core/validation/decorators/number-validaton.d.ts +5 -36
- package/lib/core/validation/decorators/number-validaton.d.ts.map +1 -0
- package/lib/core/validation/decorators/number-validaton.js +86 -113
- package/lib/core/validation/decorators/number-validaton.js.map +1 -0
- package/lib/core/validation/index.d.ts +1 -0
- package/lib/core/validation/index.d.ts.map +1 -0
- package/lib/core/validation/index.js +2 -17
- package/lib/core/validation/index.js.map +1 -0
- package/lib/core/validation/query-row-validator.d.ts +2 -1
- package/lib/core/validation/query-row-validator.d.ts.map +1 -0
- package/lib/core/validation/query-row-validator.js +9 -12
- package/lib/core/validation/query-row-validator.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +2 -17
- package/lib/index.js.map +1 -0
- package/lib/query.d.ts +3 -2
- package/lib/query.d.ts.map +1 -0
- package/lib/query.js +20 -28
- package/lib/query.js.map +1 -0
- package/lib/utils/functions/generic/compare-arrays.d.ts +1 -0
- package/lib/utils/functions/generic/compare-arrays.d.ts.map +1 -0
- package/lib/utils/functions/generic/compare-arrays.js +3 -6
- package/lib/utils/functions/generic/compare-arrays.js.map +1 -0
- package/lib/utils/functions/generic/deep-equal.d.ts +1 -0
- package/lib/utils/functions/generic/deep-equal.d.ts.map +1 -0
- package/lib/utils/functions/generic/deep-equal.js +5 -8
- package/lib/utils/functions/generic/deep-equal.js.map +1 -0
- package/lib/utils/functions/generic/get-entries.d.ts +2 -5
- package/lib/utils/functions/generic/get-entries.d.ts.map +1 -0
- package/lib/utils/functions/generic/get-entries.js +3 -9
- package/lib/utils/functions/generic/get-entries.js.map +1 -0
- package/lib/utils/functions/generic/index.d.ts +1 -0
- package/lib/utils/functions/generic/index.d.ts.map +1 -0
- package/lib/utils/functions/generic/index.js +4 -19
- package/lib/utils/functions/generic/index.js.map +1 -0
- package/lib/utils/functions/sort/index.d.ts +1 -0
- package/lib/utils/functions/sort/index.d.ts.map +1 -0
- package/lib/utils/functions/sort/index.js +3 -18
- package/lib/utils/functions/sort/index.js.map +1 -0
- package/lib/utils/functions/sort/sort-by-properties.d.ts +2 -1
- package/lib/utils/functions/sort/sort-by-properties.d.ts.map +1 -0
- package/lib/utils/functions/sort/sort-by-properties.js +4 -7
- package/lib/utils/functions/sort/sort-by-properties.js.map +1 -0
- package/lib/utils/functions/sort/sort-by-property.d.ts +2 -1
- package/lib/utils/functions/sort/sort-by-property.d.ts.map +1 -0
- package/lib/utils/functions/sort/sort-by-property.js +2 -4
- package/lib/utils/functions/sort/sort-by-property.js.map +1 -0
- package/lib/utils/functions/type-guards/index.d.ts +1 -0
- package/lib/utils/functions/type-guards/index.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/index.js +4 -19
- package/lib/utils/functions/type-guards/index.js.map +1 -0
- package/lib/utils/functions/type-guards/is-function.d.ts +1 -0
- package/lib/utils/functions/type-guards/is-function.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/is-function.js +2 -5
- package/lib/utils/functions/type-guards/is-function.js.map +1 -0
- package/lib/utils/functions/type-guards/is-number.d.ts +1 -0
- package/lib/utils/functions/type-guards/is-number.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/is-number.js +2 -5
- package/lib/utils/functions/type-guards/is-number.js.map +1 -0
- package/lib/utils/functions/type-guards/is-object.d.ts +1 -0
- package/lib/utils/functions/type-guards/is-object.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/is-object.js +2 -5
- package/lib/utils/functions/type-guards/is-object.js.map +1 -0
- package/lib/utils/types/add-prefix-to-object.d.ts +1 -0
- package/lib/utils/types/add-prefix-to-object.d.ts.map +1 -0
- package/lib/utils/types/add-prefix-to-object.js +2 -2
- package/lib/utils/types/add-prefix-to-object.js.map +1 -0
- package/lib/utils/types/allowed-names.d.ts +2 -1
- package/lib/utils/types/allowed-names.d.ts.map +1 -0
- package/lib/utils/types/allowed-names.js +2 -2
- package/lib/utils/types/allowed-names.js.map +1 -0
- package/lib/utils/types/flag-excluded-type.d.ts +1 -0
- package/lib/utils/types/flag-excluded-type.d.ts.map +1 -0
- package/lib/utils/types/flag-excluded-type.js +2 -2
- package/lib/utils/types/flag-excluded-type.js.map +1 -0
- package/lib/utils/types/generic-object.d.ts +1 -0
- package/lib/utils/types/generic-object.d.ts.map +1 -0
- package/lib/utils/types/generic-object.js +2 -2
- package/lib/utils/types/generic-object.js.map +1 -0
- package/lib/utils/types/index.d.ts +1 -0
- package/lib/utils/types/index.d.ts.map +1 -0
- package/lib/utils/types/index.js +11 -26
- package/lib/utils/types/index.js.map +1 -0
- package/lib/utils/types/omit-type.d.ts +2 -1
- package/lib/utils/types/omit-type.d.ts.map +1 -0
- package/lib/utils/types/omit-type.js +2 -2
- package/lib/utils/types/omit-type.js.map +1 -0
- package/lib/utils/types/partial-of-properties.d.ts +2 -1
- package/lib/utils/types/partial-of-properties.d.ts.map +1 -0
- package/lib/utils/types/partial-of-properties.js +2 -2
- package/lib/utils/types/partial-of-properties.js.map +1 -0
- package/lib/utils/types/prop-of.d.ts +2 -1
- package/lib/utils/types/prop-of.d.ts.map +1 -0
- package/lib/utils/types/prop-of.js +2 -2
- package/lib/utils/types/prop-of.js.map +1 -0
- package/lib/utils/types/property-only.d.ts +2 -1
- package/lib/utils/types/property-only.d.ts.map +1 -0
- package/lib/utils/types/property-only.js +2 -2
- package/lib/utils/types/property-only.js.map +1 -0
- package/lib/utils/types/recursive-partial.d.ts +1 -0
- package/lib/utils/types/recursive-partial.d.ts.map +1 -0
- package/lib/utils/types/recursive-partial.js +2 -2
- package/lib/utils/types/recursive-partial.js.map +1 -0
- package/lib/utils/types/sort-function.d.ts +1 -0
- package/lib/utils/types/sort-function.d.ts.map +1 -0
- package/lib/utils/types/sort-function.js +2 -2
- package/lib/utils/types/sort-function.js.map +1 -0
- package/lib/utils/types/type.d.ts +1 -0
- package/lib/utils/types/type.d.ts.map +1 -0
- package/lib/utils/types/type.js +2 -2
- package/lib/utils/types/type.js.map +1 -0
- package/package.json +23 -16
- package/lib/base-object.d.ts +0 -6
- package/lib/base-object.js +0 -15
- package/lib/errors/index.d.ts +0 -2
- package/lib/errors/index.js +0 -5
- package/lib/errors/invalid-argument-error.d.ts +0 -10
- package/lib/errors/invalid-argument-error.js +0 -11
- package/lib/query-conditions-group-nullable.d.ts +0 -4
- package/lib/query-conditions-group-nullable.js +0 -2
- package/lib/query-conditions-group.d.ts +0 -4
- package/lib/query-conditions-group.js +0 -2
- package/lib/query-row-validator.d.ts +0 -72
- package/lib/query-row-validator.js +0 -85
- package/lib/utils/decorators/number-validaton.d.ts +0 -36
- package/lib/utils/decorators/number-validaton.js +0 -124
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateNumbers = exports.integer = exports.max = exports.min = void 0;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const errors_1 = require("../../errors");
|
|
6
|
-
const type_guards_1 = require("../functions/type-guards");
|
|
7
|
-
const minMetadataKey = Symbol('min');
|
|
8
|
-
const maxMetadataKey = Symbol('max');
|
|
9
|
-
const integerMetadataKey = Symbol('integer');
|
|
10
|
-
/**
|
|
11
|
-
* Sets a minimal value to be used as argument to the given parameter.
|
|
12
|
-
*
|
|
13
|
-
* @param {number} value Minimal value to set.
|
|
14
|
-
*
|
|
15
|
-
* @returns Decorator function.
|
|
16
|
-
*/
|
|
17
|
-
function min(value) {
|
|
18
|
-
return (target, propertyKey, parameterIndex) => {
|
|
19
|
-
const minParameters = Reflect.getOwnMetadata(minMetadataKey, target, propertyKey) || [];
|
|
20
|
-
minParameters.push({
|
|
21
|
-
value,
|
|
22
|
-
index: parameterIndex,
|
|
23
|
-
});
|
|
24
|
-
Reflect.defineMetadata(minMetadataKey, minParameters, target, propertyKey);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
exports.min = min;
|
|
28
|
-
/**
|
|
29
|
-
* Sets a maximum value to be used as argument to the given parameter.
|
|
30
|
-
*
|
|
31
|
-
* @param {number} value Maximal value to set.
|
|
32
|
-
*
|
|
33
|
-
* @returns Decorator function.
|
|
34
|
-
*/
|
|
35
|
-
function max(value) {
|
|
36
|
-
return (target, propertyKey, parameterIndex) => {
|
|
37
|
-
const maxParameters = Reflect.getOwnMetadata(maxMetadataKey, target, propertyKey) || [];
|
|
38
|
-
maxParameters.push({
|
|
39
|
-
value,
|
|
40
|
-
index: parameterIndex,
|
|
41
|
-
});
|
|
42
|
-
Reflect.defineMetadata(maxMetadataKey, maxParameters, target, propertyKey);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
exports.max = max;
|
|
46
|
-
/**
|
|
47
|
-
* Marks the given parameter as an integer.
|
|
48
|
-
*
|
|
49
|
-
* @param {Object} target Class to which the parameter belongs.
|
|
50
|
-
* @param {string} propertyKey Method name.
|
|
51
|
-
* @param {number} parameterIndex Parameter index.
|
|
52
|
-
*/
|
|
53
|
-
function integer(target, propertyKey, parameterIndex) {
|
|
54
|
-
const integerParameters = Reflect.getOwnMetadata(integerMetadataKey, target, propertyKey) || [];
|
|
55
|
-
integerParameters.push({
|
|
56
|
-
index: parameterIndex,
|
|
57
|
-
});
|
|
58
|
-
Reflect.defineMetadata(integerMetadataKey, integerParameters, target, propertyKey);
|
|
59
|
-
}
|
|
60
|
-
exports.integer = integer;
|
|
61
|
-
/**
|
|
62
|
-
* Validates the property decorators `integer`, `min`, and `max`, throwing and error
|
|
63
|
-
* when the arguments passed to the parameters decorated by them are invalid.
|
|
64
|
-
*
|
|
65
|
-
* @param {any} target Class to which the method belongs.
|
|
66
|
-
* @param {string} propertyName Method name.
|
|
67
|
-
* @param {TypedPropertyDescriptor<any>} descriptor Descriptor object.
|
|
68
|
-
*
|
|
69
|
-
* @throws {InvalidArgumentError} If an argument is invalid.
|
|
70
|
-
*/
|
|
71
|
-
function validateNumbers(target, propertyName, descriptor) {
|
|
72
|
-
const method = descriptor.value;
|
|
73
|
-
descriptor.value = function () {
|
|
74
|
-
const minParams = Reflect.getOwnMetadata(minMetadataKey, target, propertyName) || [];
|
|
75
|
-
const maxParams = Reflect.getOwnMetadata(maxMetadataKey, target, propertyName) || [];
|
|
76
|
-
const integerParams = Reflect.getOwnMetadata(integerMetadataKey, target, propertyName) || [];
|
|
77
|
-
checkMinParams(propertyName, minParams, arguments);
|
|
78
|
-
checkMaxParams(propertyName, maxParams, arguments);
|
|
79
|
-
checkIntegerParams(propertyName, integerParams, arguments);
|
|
80
|
-
return method.apply(this, arguments);
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
exports.validateNumbers = validateNumbers;
|
|
84
|
-
function checkMinParams(methodName, params, actualArguments) {
|
|
85
|
-
for (const parameter of params) {
|
|
86
|
-
const actualValue = actualArguments[parameter.index];
|
|
87
|
-
const minValue = parameter.value;
|
|
88
|
-
if (!(0, type_guards_1.isNumber)(actualValue) || actualValue < minValue) {
|
|
89
|
-
throw new errors_1.InvalidArgumentError({
|
|
90
|
-
method: methodName,
|
|
91
|
-
param: parameter.index,
|
|
92
|
-
argument: actualValue,
|
|
93
|
-
expected: `equal or greater than ${minValue}`,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function checkMaxParams(methodName, params, actualArguments) {
|
|
99
|
-
for (const parameter of params) {
|
|
100
|
-
const actualValue = actualArguments[parameter.index];
|
|
101
|
-
const maxValue = parameter.value;
|
|
102
|
-
if (!(0, type_guards_1.isNumber)(actualValue) || actualValue > maxValue) {
|
|
103
|
-
throw new errors_1.InvalidArgumentError({
|
|
104
|
-
method: methodName,
|
|
105
|
-
param: parameter.index,
|
|
106
|
-
argument: actualValue,
|
|
107
|
-
expected: `equal or less than ${maxValue}`,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function checkIntegerParams(methodName, params, actualArguments) {
|
|
113
|
-
for (const { index } of params) {
|
|
114
|
-
const actualValue = actualArguments[index];
|
|
115
|
-
if (!Number.isSafeInteger(actualValue)) {
|
|
116
|
-
throw new errors_1.InvalidArgumentError({
|
|
117
|
-
method: methodName,
|
|
118
|
-
param: index,
|
|
119
|
-
argument: actualValue,
|
|
120
|
-
expected: 'an integer',
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|