querier-ts 0.0.0 → 1.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/lib/__tests__/query.spec.d.ts +1 -0
- package/lib/__tests__/query.spec.js +149 -0
- package/lib/core/errors/__tests__/invalid-argument-error.spec.d.ts +1 -0
- package/lib/core/errors/__tests__/invalid-argument-error.spec.js +54 -0
- package/lib/core/errors/index.d.ts +1 -0
- package/lib/core/errors/index.js +17 -0
- package/lib/core/errors/invalid-argument-error.d.ts +14 -0
- package/lib/core/errors/invalid-argument-error.js +16 -0
- package/lib/core/types/attribute-validation-function.d.ts +1 -0
- package/lib/core/types/attribute-validation-function.js +2 -0
- package/lib/core/types/column-condition.d.ts +6 -0
- package/lib/core/types/column-condition.js +2 -0
- package/lib/core/types/index.d.ts +4 -0
- package/lib/core/types/index.js +20 -0
- package/lib/core/types/query-conditions-group-nullable.d.ts +4 -0
- package/lib/core/types/query-conditions-group-nullable.js +2 -0
- package/lib/core/types/query-conditions-group.d.ts +4 -0
- package/lib/core/types/query-conditions-group.js +2 -0
- package/lib/core/types/query-row-validator-initializer.d.ts +8 -0
- package/lib/core/types/query-row-validator-initializer.js +2 -0
- package/lib/core/validation/__tests__/query-row-validator.spec.d.ts +1 -0
- package/lib/core/validation/__tests__/query-row-validator.spec.js +195 -0
- package/lib/core/validation/decorators/__tests__/number-validation.spec.d.ts +1 -0
- package/lib/core/validation/decorators/__tests__/number-validation.spec.js +114 -0
- package/lib/core/validation/decorators/index.d.ts +1 -0
- package/lib/core/validation/decorators/index.js +17 -0
- package/lib/core/validation/decorators/number-validaton.d.ts +36 -0
- package/lib/core/validation/decorators/number-validaton.js +123 -0
- package/lib/core/validation/index.d.ts +1 -0
- package/lib/core/validation/index.js +17 -0
- package/lib/core/validation/query-row-validator.d.ts +57 -0
- package/lib/core/validation/query-row-validator.js +84 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +15 -3
- package/lib/query.d.ts +33 -38
- package/lib/query.js +51 -50
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.js +21 -0
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.js +82 -0
- package/lib/utils/functions/generic/__tests__/get-entries.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/get-entries.spec.js +55 -0
- package/lib/utils/functions/generic/compare-arrays.d.ts +1 -9
- package/lib/utils/functions/generic/compare-arrays.js +2 -9
- package/lib/utils/functions/generic/deep-equal.d.ts +1 -0
- package/lib/utils/functions/generic/deep-equal.js +23 -0
- package/lib/utils/functions/generic/get-entries.d.ts +5 -8
- package/lib/utils/functions/generic/get-entries.js +7 -9
- package/lib/utils/functions/generic/index.d.ts +3 -3
- package/lib/utils/functions/generic/index.js +17 -5
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.d.ts +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.js +69 -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.js +63 -0
- package/lib/utils/functions/sort/index.d.ts +2 -3
- package/lib/utils/functions/sort/index.js +16 -5
- package/lib/utils/functions/sort/sort-by-properties.d.ts +2 -2
- package/lib/utils/functions/sort/sort-by-properties.js +11 -9
- package/lib/utils/functions/sort/sort-by-property.d.ts +2 -2
- package/lib/utils/functions/sort/sort-by-property.js +18 -6
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.d.ts +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.js +38 -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.js +35 -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.js +38 -0
- package/lib/utils/functions/type-guards/index.d.ts +3 -4
- package/lib/utils/functions/type-guards/index.js +17 -7
- package/lib/utils/functions/type-guards/is-function.d.ts +3 -3
- package/lib/utils/functions/type-guards/is-function.js +2 -2
- package/lib/utils/functions/type-guards/is-number.d.ts +3 -3
- package/lib/utils/functions/type-guards/is-number.js +2 -2
- package/lib/utils/functions/type-guards/is-object.d.ts +3 -3
- package/lib/utils/functions/type-guards/is-object.js +2 -2
- package/lib/utils/types/add-prefix-to-object.d.ts +1 -1
- package/lib/utils/types/allowed-names.d.ts +1 -1
- package/lib/utils/types/flag-excluded-type.d.ts +1 -1
- package/lib/utils/types/generic-object.d.ts +1 -1
- package/lib/utils/types/generic-object.js +0 -1
- package/lib/utils/types/index.d.ts +9 -10
- package/lib/utils/types/index.js +23 -0
- package/lib/utils/types/omit-type.d.ts +1 -1
- package/lib/utils/types/partial-of-properties.d.ts +1 -1
- package/lib/utils/types/prop-of.d.ts +1 -1
- package/lib/utils/types/property-only.d.ts +1 -1
- package/lib/utils/types/recursive-partial.d.ts +1 -1
- package/lib/utils/types/type.d.ts +1 -1
- package/package.json +23 -24
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sort_by_property_1 = require("../sort-by-property");
|
|
4
|
+
describe('sortByProperty (improved)', () => {
|
|
5
|
+
describe('ascending order', () => {
|
|
6
|
+
it('sorts by numeric property', () => {
|
|
7
|
+
const data = [{ id: 3 }, { id: 1 }, { id: 2 }];
|
|
8
|
+
data.sort((0, sort_by_property_1.sortByProperty)('id'));
|
|
9
|
+
expect(data).toEqual([{ id: 1 }, { id: 2 }, { id: 3 }]);
|
|
10
|
+
});
|
|
11
|
+
it('sorts by string property', () => {
|
|
12
|
+
const data = [{ name: 'Charlie' }, { name: 'Alice' }, { name: 'Bob' }];
|
|
13
|
+
data.sort((0, sort_by_property_1.sortByProperty)('name'));
|
|
14
|
+
expect(data).toEqual([
|
|
15
|
+
{ name: 'Alice' },
|
|
16
|
+
{ name: 'Bob' },
|
|
17
|
+
{ name: 'Charlie' },
|
|
18
|
+
]);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe('descending order', () => {
|
|
22
|
+
it('sorts by numeric property descending', () => {
|
|
23
|
+
const data = [{ score: 10 }, { score: 30 }, { score: 20 }];
|
|
24
|
+
data.sort((0, sort_by_property_1.sortByProperty)('-score'));
|
|
25
|
+
expect(data).toEqual([{ score: 30 }, { score: 20 }, { score: 10 }]);
|
|
26
|
+
});
|
|
27
|
+
it('sorts by string property descending', () => {
|
|
28
|
+
const data = [{ name: 'Alice' }, { name: 'Charlie' }, { name: 'Bob' }];
|
|
29
|
+
data.sort((0, sort_by_property_1.sortByProperty)('-name'));
|
|
30
|
+
expect(data).toEqual([
|
|
31
|
+
{ name: 'Charlie' },
|
|
32
|
+
{ name: 'Bob' },
|
|
33
|
+
{ name: 'Alice' },
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('null and undefined handling', () => {
|
|
38
|
+
it('places undefined values last', () => {
|
|
39
|
+
const data = [{ value: 2 }, { value: undefined }, { value: 1 }];
|
|
40
|
+
data.sort((0, sort_by_property_1.sortByProperty)('value'));
|
|
41
|
+
expect(data).toEqual([{ value: 1 }, { value: 2 }, { value: undefined }]);
|
|
42
|
+
});
|
|
43
|
+
it('places null values last', () => {
|
|
44
|
+
const data = [{ value: 2 }, { value: null }, { value: 1 }];
|
|
45
|
+
data.sort((0, sort_by_property_1.sortByProperty)('value'));
|
|
46
|
+
expect(data).toEqual([{ value: 1 }, { value: 2 }, { value: null }]);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe('equal values', () => {
|
|
50
|
+
it('returns 0 for equal property values', () => {
|
|
51
|
+
const comparator = (0, sort_by_property_1.sortByProperty)('id');
|
|
52
|
+
expect(comparator({ id: 1 }, { id: 1 })).toBe(0);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('type safety (compile-time)', () => {
|
|
56
|
+
it('does not allow invalid properties', () => {
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
(0, sort_by_property_1.sortByProperty)('invalid');
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
(0, sort_by_property_1.sortByProperty)('-invalid');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { sortByProperties, sortByProperty, };
|
|
1
|
+
export * from './sort-by-properties';
|
|
2
|
+
export * from './sort-by-property';
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
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; } });
|
|
17
|
+
__exportStar(require("./sort-by-properties"), exports);
|
|
18
|
+
__exportStar(require("./sort-by-property"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function sortByProperties(...props:
|
|
1
|
+
import { addPrefixToObject, PropertyOnly, PropOf } from '../../types';
|
|
2
|
+
export declare function sortByProperties<T extends object>(...props: (PropOf<T> | keyof addPrefixToObject<PropertyOnly<T>, '-'>)[]): (a: T, b: T) => number;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortByProperties =
|
|
3
|
+
exports.sortByProperties = sortByProperties;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
function sortByProperties(...props) {
|
|
6
|
-
return (
|
|
7
|
-
|
|
6
|
+
return (a, b) => {
|
|
7
|
+
if (props.length === 0) {
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
8
10
|
let result = 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
result
|
|
12
|
-
|
|
11
|
+
for (const prop of props) {
|
|
12
|
+
result = (0, _1.sortByProperty)(prop)(a, b);
|
|
13
|
+
if (result !== 0) {
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
13
16
|
}
|
|
14
|
-
return
|
|
17
|
+
return 0;
|
|
15
18
|
};
|
|
16
19
|
}
|
|
17
|
-
exports.sortByProperties = sortByProperties;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function sortByProperty(property:
|
|
1
|
+
import { addPrefixToObject, PropertyOnly, PropOf } from '../../types';
|
|
2
|
+
export declare function sortByProperty<T extends object>(property: PropOf<T> | keyof addPrefixToObject<PropertyOnly<T>, '-'>): (a: T, b: T) => number;
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortByProperty =
|
|
3
|
+
exports.sortByProperty = sortByProperty;
|
|
4
4
|
function sortByProperty(property) {
|
|
5
5
|
let sortOrder = 1;
|
|
6
|
-
|
|
6
|
+
let prop = property;
|
|
7
|
+
if (prop.startsWith('-')) {
|
|
7
8
|
sortOrder = -1;
|
|
8
|
-
|
|
9
|
+
prop = prop.slice(1);
|
|
9
10
|
}
|
|
11
|
+
const key = prop;
|
|
10
12
|
return (a, b) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
+
const valueA = a[key];
|
|
14
|
+
const valueB = b[key];
|
|
15
|
+
if (valueA == null && valueB == null)
|
|
16
|
+
return 0;
|
|
17
|
+
if (valueA == null)
|
|
18
|
+
return 1 * sortOrder;
|
|
19
|
+
if (valueB == null)
|
|
20
|
+
return -1 * sortOrder;
|
|
21
|
+
if (valueA < valueB)
|
|
22
|
+
return -1 * sortOrder;
|
|
23
|
+
if (valueA > valueB)
|
|
24
|
+
return 1 * sortOrder;
|
|
25
|
+
return 0;
|
|
13
26
|
};
|
|
14
27
|
}
|
|
15
|
-
exports.sortByProperty = sortByProperty;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const is_function_1 = require("../is-function");
|
|
4
|
+
describe('isFunction', () => {
|
|
5
|
+
it('should return true for regular functions', () => {
|
|
6
|
+
const fn = () => { };
|
|
7
|
+
expect((0, is_function_1.isFunction)(fn)).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
it('should return true for async functions', () => {
|
|
10
|
+
const fn = async () => { };
|
|
11
|
+
expect((0, is_function_1.isFunction)(fn)).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
it('should return true for class constructors', () => {
|
|
14
|
+
class Test {
|
|
15
|
+
}
|
|
16
|
+
expect((0, is_function_1.isFunction)(Test)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
it('should return false for non-function values', () => {
|
|
19
|
+
expect((0, is_function_1.isFunction)(123)).toBe(false);
|
|
20
|
+
expect((0, is_function_1.isFunction)('string')).toBe(false);
|
|
21
|
+
expect((0, is_function_1.isFunction)(null)).toBe(false);
|
|
22
|
+
expect((0, is_function_1.isFunction)(undefined)).toBe(false);
|
|
23
|
+
expect((0, is_function_1.isFunction)({})).toBe(false);
|
|
24
|
+
expect((0, is_function_1.isFunction)([])).toBe(false);
|
|
25
|
+
expect((0, is_function_1.isFunction)(true)).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
it('should narrow the type when returning true (type guard)', () => {
|
|
28
|
+
const value = () => 'hello';
|
|
29
|
+
if ((0, is_function_1.isFunction)(value)) {
|
|
30
|
+
// If this compiles, the type guard works
|
|
31
|
+
const result = value();
|
|
32
|
+
expect(result).toBe('hello');
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
fail('Expected value to be a function');
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const is_number_1 = require("../is-number");
|
|
4
|
+
describe('isNumber', () => {
|
|
5
|
+
it('should return true for valid numbers', () => {
|
|
6
|
+
expect((0, is_number_1.isNumber)(0)).toBe(true);
|
|
7
|
+
expect((0, is_number_1.isNumber)(42)).toBe(true);
|
|
8
|
+
expect((0, is_number_1.isNumber)(-10)).toBe(true);
|
|
9
|
+
expect((0, is_number_1.isNumber)(3.14)).toBe(true);
|
|
10
|
+
expect((0, is_number_1.isNumber)(NaN)).toBe(true); // typeof NaN === 'number'
|
|
11
|
+
expect((0, is_number_1.isNumber)(Infinity)).toBe(true);
|
|
12
|
+
expect((0, is_number_1.isNumber)(-Infinity)).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
it('should return false for non-number values', () => {
|
|
15
|
+
expect((0, is_number_1.isNumber)('123')).toBe(false);
|
|
16
|
+
expect((0, is_number_1.isNumber)(null)).toBe(false);
|
|
17
|
+
expect((0, is_number_1.isNumber)(undefined)).toBe(false);
|
|
18
|
+
expect((0, is_number_1.isNumber)({})).toBe(false);
|
|
19
|
+
expect((0, is_number_1.isNumber)([])).toBe(false);
|
|
20
|
+
expect((0, is_number_1.isNumber)(true)).toBe(false);
|
|
21
|
+
expect((0, is_number_1.isNumber)(false)).toBe(false);
|
|
22
|
+
expect((0, is_number_1.isNumber)(() => 1)).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
it('should narrow the type when returning true (type guard)', () => {
|
|
25
|
+
const value = 123;
|
|
26
|
+
if ((0, is_number_1.isNumber)(value)) {
|
|
27
|
+
// If this compiles, the type guard works
|
|
28
|
+
const result = value + 1;
|
|
29
|
+
expect(result).toBe(124);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
fail('Expected value to be a number');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const is_object_1 = require("../is-object");
|
|
4
|
+
describe('isObject', () => {
|
|
5
|
+
it('should return true for plain objects', () => {
|
|
6
|
+
expect((0, is_object_1.isObject)({})).toBe(true);
|
|
7
|
+
expect((0, is_object_1.isObject)({ a: 1 })).toBe(true);
|
|
8
|
+
expect((0, is_object_1.isObject)(Object.create(null))).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it('should return true for non-plain objects (by design)', () => {
|
|
11
|
+
expect((0, is_object_1.isObject)([])).toBe(true); // arrays are objects
|
|
12
|
+
expect((0, is_object_1.isObject)(new Date())).toBe(true); // Date is an object
|
|
13
|
+
expect((0, is_object_1.isObject)(/regex/)).toBe(true); // RegExp is an object
|
|
14
|
+
expect((0, is_object_1.isObject)(new Map())).toBe(true);
|
|
15
|
+
expect((0, is_object_1.isObject)(new Set())).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
it('should return false for null', () => {
|
|
18
|
+
expect((0, is_object_1.isObject)(null)).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
it('should return false for non-object types', () => {
|
|
21
|
+
expect((0, is_object_1.isObject)(undefined)).toBe(false);
|
|
22
|
+
expect((0, is_object_1.isObject)(123)).toBe(false);
|
|
23
|
+
expect((0, is_object_1.isObject)('string')).toBe(false);
|
|
24
|
+
expect((0, is_object_1.isObject)(true)).toBe(false);
|
|
25
|
+
expect((0, is_object_1.isObject)(false)).toBe(false);
|
|
26
|
+
expect((0, is_object_1.isObject)(() => { })).toBe(false); // functions are not objects
|
|
27
|
+
});
|
|
28
|
+
it('should narrow the type when returning true (type guard)', () => {
|
|
29
|
+
const value = { a: 1 };
|
|
30
|
+
if ((0, is_object_1.isObject)(value)) {
|
|
31
|
+
// TypeScript now knows value is object
|
|
32
|
+
expect(typeof value).toBe('object');
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
fail('Expected value to be an object');
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { isFunction, isNumber, isObject, };
|
|
1
|
+
export * from './is-function';
|
|
2
|
+
export * from './is-number';
|
|
3
|
+
export * from './is-object';
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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; } });
|
|
17
|
+
__exportStar(require("./is-function"), exports);
|
|
18
|
+
__exportStar(require("./is-number"), exports);
|
|
19
|
+
__exportStar(require("./is-object"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Determines if the given value is a function.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param value The value to check.
|
|
5
5
|
*
|
|
6
|
-
* @returns
|
|
6
|
+
* @returns Validation result.
|
|
7
7
|
*/
|
|
8
|
-
export declare const isFunction: (value:
|
|
8
|
+
export declare const isFunction: <T>(value: unknown) => value is T;
|
|
@@ -4,9 +4,9 @@ exports.isFunction = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Determines if the given value is a function.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param value The value to check.
|
|
8
8
|
*
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns Validation result.
|
|
10
10
|
*/
|
|
11
11
|
const isFunction = (value) => typeof value === 'function';
|
|
12
12
|
exports.isFunction = isFunction;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Determines if the given value is a number.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param value The value to check.
|
|
5
5
|
*
|
|
6
|
-
* @returns
|
|
6
|
+
* @returns Validation result.
|
|
7
7
|
*/
|
|
8
|
-
export declare const isNumber: (value:
|
|
8
|
+
export declare const isNumber: (value: unknown) => value is number;
|
|
@@ -4,9 +4,9 @@ exports.isNumber = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Determines if the given value is a number.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param value The value to check.
|
|
8
8
|
*
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns Validation result.
|
|
10
10
|
*/
|
|
11
11
|
const isNumber = (value) => typeof value === 'number';
|
|
12
12
|
exports.isNumber = isNumber;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Determines if the given value is an object.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param value The value to check.
|
|
5
5
|
*
|
|
6
|
-
* @returns
|
|
6
|
+
* @returns Validation result.
|
|
7
7
|
*/
|
|
8
|
-
export declare const isObject: (value:
|
|
8
|
+
export declare const isObject: (value: unknown) => value is object;
|
|
@@ -4,9 +4,9 @@ exports.isObject = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Determines if the given value is an object.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param value The value to check.
|
|
8
8
|
*
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns Validation result.
|
|
10
10
|
*/
|
|
11
11
|
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
12
12
|
exports.isObject = isObject;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export { addPrefixToObject, AllowedNames, FlagExcludedType, GenericObject, OmitType, PartialOfProperties, PropertyOnly, PropOf, RecursivePartial, };
|
|
1
|
+
export * from './add-prefix-to-object';
|
|
2
|
+
export * from './allowed-names';
|
|
3
|
+
export * from './flag-excluded-type';
|
|
4
|
+
export * from './generic-object';
|
|
5
|
+
export * from './omit-type';
|
|
6
|
+
export * from './partial-of-properties';
|
|
7
|
+
export * from './prop-of';
|
|
8
|
+
export * from './property-only';
|
|
9
|
+
export * from './recursive-partial';
|
package/lib/utils/types/index.js
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./add-prefix-to-object"), exports);
|
|
18
|
+
__exportStar(require("./allowed-names"), exports);
|
|
19
|
+
__exportStar(require("./flag-excluded-type"), exports);
|
|
20
|
+
__exportStar(require("./generic-object"), exports);
|
|
21
|
+
__exportStar(require("./omit-type"), exports);
|
|
22
|
+
__exportStar(require("./partial-of-properties"), exports);
|
|
23
|
+
__exportStar(require("./prop-of"), exports);
|
|
24
|
+
__exportStar(require("./property-only"), exports);
|
|
25
|
+
__exportStar(require("./recursive-partial"), exports);
|
|
@@ -2,4 +2,4 @@ import { AllowedNames } from '.';
|
|
|
2
2
|
/**
|
|
3
3
|
* Use this with a simple Pick to get the right interface, excluding the undesired type.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type OmitType<Base, Type> = Pick<Base, AllowedNames<Base, Type>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PropertyOnly } from '.';
|
|
2
|
-
export
|
|
2
|
+
export type PartialOfProperties<T extends object> = Partial<PropertyOnly<T>>;
|
package/package.json
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "querier-ts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Query tool for analysing arrays of objects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
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
|
-
},
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*"
|
|
9
|
+
],
|
|
18
10
|
"repository": {
|
|
19
11
|
"type": "git",
|
|
20
12
|
"url": "git+https://github.com/luizfilipezs/query-ts.git"
|
|
@@ -33,20 +25,27 @@
|
|
|
33
25
|
"url": "https://github.com/luizfilipezs/query-ts/issues"
|
|
34
26
|
},
|
|
35
27
|
"homepage": "https://github.com/luizfilipezs/query-ts#readme",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"reflect-metadata": "^0.2.2",
|
|
30
|
+
"utility-types": "^3.11.0"
|
|
31
|
+
},
|
|
36
32
|
"devDependencies": {
|
|
37
|
-
"@types/jest": "^
|
|
38
|
-
"jest": "^
|
|
39
|
-
"prettier": "^
|
|
40
|
-
"
|
|
33
|
+
"@types/jest": "^30.0.0",
|
|
34
|
+
"jest": "^30.2.0",
|
|
35
|
+
"prettier": "^3.8.1",
|
|
36
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
37
|
+
"ts-jest": "^29.4.6",
|
|
41
38
|
"tslint": "^6.1.3",
|
|
42
39
|
"tslint-config-prettier": "^1.18.0",
|
|
43
|
-
"typescript": "~
|
|
40
|
+
"typescript": "~5.9.3"
|
|
44
41
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
42
|
+
"scripts": {
|
|
43
|
+
"test": "jest --config jestconfig.json",
|
|
44
|
+
"build": "tsc",
|
|
45
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
46
|
+
"lint": "tslint -p tsconfig.json",
|
|
47
|
+
"preversion": "pnpm lint",
|
|
48
|
+
"version": "pnpm format && git add -A src",
|
|
49
|
+
"postversion": "git push && git push --tags"
|
|
51
50
|
}
|
|
52
|
-
}
|
|
51
|
+
}
|