querier-ts 0.0.0
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/LICENSE +21 -0
- package/README.md +234 -0
- package/lib/base-object.d.ts +6 -0
- package/lib/base-object.js +15 -0
- package/lib/errors/index.d.ts +2 -0
- package/lib/errors/index.js +5 -0
- package/lib/errors/invalid-argument-error.d.ts +10 -0
- package/lib/errors/invalid-argument-error.js +11 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +5 -0
- package/lib/query-conditions-group-nullable.d.ts +4 -0
- package/lib/query-conditions-group-nullable.js +2 -0
- package/lib/query-conditions-group.d.ts +4 -0
- package/lib/query-conditions-group.js +2 -0
- package/lib/query-row-validator.d.ts +72 -0
- package/lib/query-row-validator.js +85 -0
- package/lib/query.d.ts +215 -0
- package/lib/query.js +331 -0
- package/lib/utils/decorators/number-validaton.d.ts +36 -0
- package/lib/utils/decorators/number-validaton.js +124 -0
- package/lib/utils/functions/generic/compare-arrays.d.ts +9 -0
- package/lib/utils/functions/generic/compare-arrays.js +13 -0
- package/lib/utils/functions/generic/get-entries.d.ts +8 -0
- package/lib/utils/functions/generic/get-entries.js +12 -0
- package/lib/utils/functions/generic/index.d.ts +3 -0
- package/lib/utils/functions/generic/index.js +7 -0
- package/lib/utils/functions/sort/index.d.ts +3 -0
- package/lib/utils/functions/sort/index.js +7 -0
- package/lib/utils/functions/sort/sort-by-properties.d.ts +2 -0
- package/lib/utils/functions/sort/sort-by-properties.js +17 -0
- package/lib/utils/functions/sort/sort-by-property.d.ts +2 -0
- package/lib/utils/functions/sort/sort-by-property.js +15 -0
- package/lib/utils/functions/type-guards/index.d.ts +4 -0
- package/lib/utils/functions/type-guards/index.js +9 -0
- package/lib/utils/functions/type-guards/is-function.d.ts +8 -0
- package/lib/utils/functions/type-guards/is-function.js +12 -0
- package/lib/utils/functions/type-guards/is-number.d.ts +8 -0
- package/lib/utils/functions/type-guards/is-number.js +12 -0
- package/lib/utils/functions/type-guards/is-object.d.ts +8 -0
- package/lib/utils/functions/type-guards/is-object.js +12 -0
- package/lib/utils/types/add-prefix-to-object.d.ts +3 -0
- package/lib/utils/types/add-prefix-to-object.js +2 -0
- package/lib/utils/types/allowed-names.d.ts +5 -0
- package/lib/utils/types/allowed-names.js +2 -0
- package/lib/utils/types/flag-excluded-type.d.ts +6 -0
- package/lib/utils/types/flag-excluded-type.js +2 -0
- package/lib/utils/types/generic-object.d.ts +3 -0
- package/lib/utils/types/generic-object.js +3 -0
- package/lib/utils/types/index.d.ts +10 -0
- package/lib/utils/types/index.js +2 -0
- package/lib/utils/types/omit-type.d.ts +5 -0
- package/lib/utils/types/omit-type.js +2 -0
- package/lib/utils/types/partial-of-properties.d.ts +2 -0
- package/lib/utils/types/partial-of-properties.js +2 -0
- package/lib/utils/types/prop-of.d.ts +5 -0
- package/lib/utils/types/prop-of.js +2 -0
- package/lib/utils/types/property-only.d.ts +4 -0
- package/lib/utils/types/property-only.js +2 -0
- package/lib/utils/types/recursive-partial.d.ts +3 -0
- package/lib/utils/types/recursive-partial.js +2 -0
- package/lib/utils/types/type.d.ts +4 -0
- package/lib/utils/types/type.js +2 -0
- package/package.json +52 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareArrays = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compares two arrays.
|
|
6
|
+
*
|
|
7
|
+
* @param {any[]} a First array to compare.
|
|
8
|
+
* @param {any[]} b Second array to compare.
|
|
9
|
+
*
|
|
10
|
+
* @returns {boolean} Validation result.
|
|
11
|
+
*/
|
|
12
|
+
const compareArrays = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
13
|
+
exports.compareArrays = compareArrays;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntries = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the entries of an object.
|
|
6
|
+
*
|
|
7
|
+
* @param {object} obj The object to retrieve entries.
|
|
8
|
+
*
|
|
9
|
+
* @returns {[string, any]} The entries of the object.
|
|
10
|
+
*/
|
|
11
|
+
const getEntries = (obj) => Object.entries(obj);
|
|
12
|
+
exports.getEntries = getEntries;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntries = exports.compareArrays = void 0;
|
|
4
|
+
const compare_arrays_1 = require("./compare-arrays");
|
|
5
|
+
Object.defineProperty(exports, "compareArrays", { enumerable: true, get: function () { return compare_arrays_1.compareArrays; } });
|
|
6
|
+
const get_entries_1 = require("./get-entries");
|
|
7
|
+
Object.defineProperty(exports, "getEntries", { enumerable: true, get: function () { return get_entries_1.getEntries; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortByProperty = exports.sortByProperties = void 0;
|
|
4
|
+
const sort_by_properties_1 = require("./sort-by-properties");
|
|
5
|
+
Object.defineProperty(exports, "sortByProperties", { enumerable: true, get: function () { return sort_by_properties_1.sortByProperties; } });
|
|
6
|
+
const sort_by_property_1 = require("./sort-by-property");
|
|
7
|
+
Object.defineProperty(exports, "sortByProperty", { enumerable: true, get: function () { return sort_by_property_1.sortByProperty; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortByProperties = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
function sortByProperties(...props) {
|
|
6
|
+
return (obj1, obj2) => {
|
|
7
|
+
const numberOfProperties = props.length;
|
|
8
|
+
let result = 0;
|
|
9
|
+
let i = 0;
|
|
10
|
+
while (result === 0 && i < numberOfProperties) {
|
|
11
|
+
result = (0, _1.sortByProperty)(props[i])(obj1, obj2);
|
|
12
|
+
i++;
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.sortByProperties = sortByProperties;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortByProperty = void 0;
|
|
4
|
+
function sortByProperty(property) {
|
|
5
|
+
let sortOrder = 1;
|
|
6
|
+
if (property.startsWith('-')) {
|
|
7
|
+
sortOrder = -1;
|
|
8
|
+
property = property.substring(1);
|
|
9
|
+
}
|
|
10
|
+
return (a, b) => {
|
|
11
|
+
const result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;
|
|
12
|
+
return result * sortOrder;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.sortByProperty = sortByProperty;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObject = exports.isNumber = exports.isFunction = void 0;
|
|
4
|
+
const is_function_1 = require("./is-function");
|
|
5
|
+
Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return is_function_1.isFunction; } });
|
|
6
|
+
const is_number_1 = require("./is-number");
|
|
7
|
+
Object.defineProperty(exports, "isNumber", { enumerable: true, get: function () { return is_number_1.isNumber; } });
|
|
8
|
+
const is_object_1 = require("./is-object");
|
|
9
|
+
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return is_object_1.isObject; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFunction = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Determines if the given value is a function.
|
|
6
|
+
*
|
|
7
|
+
* @param {any} value The value to check.
|
|
8
|
+
*
|
|
9
|
+
* @returns {boolean} Validation result.
|
|
10
|
+
*/
|
|
11
|
+
const isFunction = (value) => typeof value === 'function';
|
|
12
|
+
exports.isFunction = isFunction;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNumber = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Determines if the given value is a number.
|
|
6
|
+
*
|
|
7
|
+
* @param {any} value The value to check.
|
|
8
|
+
*
|
|
9
|
+
* @returns {boolean} Validation result.
|
|
10
|
+
*/
|
|
11
|
+
const isNumber = (value) => typeof value === 'number';
|
|
12
|
+
exports.isNumber = isNumber;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObject = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Determines if the given value is an object.
|
|
6
|
+
*
|
|
7
|
+
* @param {any} value The value to check.
|
|
8
|
+
*
|
|
9
|
+
* @returns {boolean} Validation result.
|
|
10
|
+
*/
|
|
11
|
+
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
12
|
+
exports.isObject = isObject;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { addPrefixToObject } from './add-prefix-to-object';
|
|
2
|
+
import { AllowedNames } from './allowed-names';
|
|
3
|
+
import { FlagExcludedType } from './flag-excluded-type';
|
|
4
|
+
import { GenericObject } from './generic-object';
|
|
5
|
+
import { OmitType } from './omit-type';
|
|
6
|
+
import { PartialOfProperties } from './partial-of-properties';
|
|
7
|
+
import { PropertyOnly } from './property-only';
|
|
8
|
+
import { PropOf } from './prop-of';
|
|
9
|
+
import { RecursivePartial } from './recursive-partial';
|
|
10
|
+
export { addPrefixToObject, AllowedNames, FlagExcludedType, GenericObject, OmitType, PartialOfProperties, PropertyOnly, PropOf, RecursivePartial, };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "querier-ts",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Query tool for analysing arrays of objects",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest --config jestconfig.json",
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"format": "prettier --write \"src/*.ts\"",
|
|
11
|
+
"lint": "tslint -p tsconfig.json",
|
|
12
|
+
"prepare": "npm run build",
|
|
13
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
14
|
+
"preversion": "npm run lint",
|
|
15
|
+
"version": "npm run format && git add -A src",
|
|
16
|
+
"postversion": "git push && git push --tags"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/luizfilipezs/query-ts.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"query",
|
|
24
|
+
"data filtering"
|
|
25
|
+
],
|
|
26
|
+
"author": {
|
|
27
|
+
"name": "Luiz Filipe da Silva",
|
|
28
|
+
"email": "filipeluiz.bs@gmail.com",
|
|
29
|
+
"url": "https://blogdolipe.com.br"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/luizfilipezs/query-ts/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/luizfilipezs/query-ts#readme",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/jest": "^27.4.0",
|
|
38
|
+
"jest": "^27.5.0",
|
|
39
|
+
"prettier": "^2.5.1",
|
|
40
|
+
"ts-jest": "^27.1.3",
|
|
41
|
+
"tslint": "^6.1.3",
|
|
42
|
+
"tslint-config-prettier": "^1.18.0",
|
|
43
|
+
"typescript": "~4.5.2"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"lib/**/*"
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"reflect-metadata": "^0.1.13",
|
|
50
|
+
"utility-types": "^3.10.0"
|
|
51
|
+
}
|
|
52
|
+
}
|