querier-ts 2.3.0 → 2.3.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/CHANGELOG.md +136 -0
- package/dist/index.cjs +1 -0
- package/{lib/query.d.ts → dist/index.d.cts} +32 -5
- package/dist/index.d.ts +292 -0
- package/dist/index.js +1 -0
- package/package.json +38 -27
- package/lib/core/errors/index.d.ts +0 -2
- package/lib/core/errors/index.d.ts.map +0 -1
- package/lib/core/errors/index.js +0 -2
- package/lib/core/errors/index.js.map +0 -1
- package/lib/core/errors/invalid-argument-error.d.ts +0 -4
- package/lib/core/errors/invalid-argument-error.d.ts.map +0 -1
- package/lib/core/errors/invalid-argument-error.js +0 -7
- package/lib/core/errors/invalid-argument-error.js.map +0 -1
- package/lib/core/types/attribute-validation-function.d.ts +0 -2
- package/lib/core/types/attribute-validation-function.d.ts.map +0 -1
- package/lib/core/types/attribute-validation-function.js +0 -2
- package/lib/core/types/attribute-validation-function.js.map +0 -1
- package/lib/core/types/column-condition.d.ts +0 -7
- package/lib/core/types/column-condition.d.ts.map +0 -1
- package/lib/core/types/column-condition.js +0 -2
- package/lib/core/types/column-condition.js.map +0 -1
- package/lib/core/types/index.d.ts +0 -5
- package/lib/core/types/index.d.ts.map +0 -1
- package/lib/core/types/index.js +0 -5
- package/lib/core/types/index.js.map +0 -1
- package/lib/core/types/nullable-condition.d.ts +0 -2
- package/lib/core/types/nullable-condition.d.ts.map +0 -1
- package/lib/core/types/nullable-condition.js +0 -2
- package/lib/core/types/nullable-condition.js.map +0 -1
- package/lib/core/types/ordering-column.d.ts +0 -3
- package/lib/core/types/ordering-column.d.ts.map +0 -1
- package/lib/core/types/ordering-column.js +0 -2
- package/lib/core/types/ordering-column.js.map +0 -1
- package/lib/core/types/query-conditions-group-nullable.d.ts +0 -6
- package/lib/core/types/query-conditions-group-nullable.d.ts.map +0 -1
- package/lib/core/types/query-conditions-group-nullable.js +0 -2
- package/lib/core/types/query-conditions-group-nullable.js.map +0 -1
- package/lib/core/types/query-conditions-group.d.ts +0 -5
- package/lib/core/types/query-conditions-group.d.ts.map +0 -1
- package/lib/core/types/query-conditions-group.js +0 -2
- package/lib/core/types/query-conditions-group.js.map +0 -1
- package/lib/core/types/query-row-validator-initializer.d.ts +0 -9
- package/lib/core/types/query-row-validator-initializer.d.ts.map +0 -1
- package/lib/core/types/query-row-validator-initializer.js +0 -2
- package/lib/core/types/query-row-validator-initializer.js.map +0 -1
- package/lib/core/types/validation-options.d.ts +0 -4
- package/lib/core/types/validation-options.d.ts.map +0 -1
- package/lib/core/types/validation-options.js +0 -2
- package/lib/core/types/validation-options.js.map +0 -1
- package/lib/core/validation/decorators/index.d.ts +0 -2
- package/lib/core/validation/decorators/index.d.ts.map +0 -1
- package/lib/core/validation/decorators/index.js +0 -2
- package/lib/core/validation/decorators/index.js.map +0 -1
- package/lib/core/validation/decorators/number-validaton.d.ts +0 -5
- package/lib/core/validation/decorators/number-validaton.d.ts.map +0 -1
- package/lib/core/validation/decorators/number-validaton.js +0 -84
- package/lib/core/validation/decorators/number-validaton.js.map +0 -1
- package/lib/core/validation/index.d.ts +0 -2
- package/lib/core/validation/index.d.ts.map +0 -1
- package/lib/core/validation/index.js +0 -2
- package/lib/core/validation/index.js.map +0 -1
- package/lib/core/validation/query-row-validator.d.ts +0 -24
- package/lib/core/validation/query-row-validator.d.ts.map +0 -1
- package/lib/core/validation/query-row-validator.js +0 -59
- package/lib/core/validation/query-row-validator.js.map +0 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/query.d.ts.map +0 -1
- package/lib/query.js +0 -393
- package/lib/query.js.map +0 -1
- package/lib/utils/functions/generic/compare-arrays.d.ts +0 -2
- package/lib/utils/functions/generic/compare-arrays.d.ts.map +0 -1
- package/lib/utils/functions/generic/compare-arrays.js +0 -3
- package/lib/utils/functions/generic/compare-arrays.js.map +0 -1
- package/lib/utils/functions/generic/deep-equal.d.ts +0 -2
- package/lib/utils/functions/generic/deep-equal.d.ts.map +0 -1
- package/lib/utils/functions/generic/deep-equal.js +0 -20
- package/lib/utils/functions/generic/deep-equal.js.map +0 -1
- package/lib/utils/functions/generic/get-entries.d.ts +0 -2
- package/lib/utils/functions/generic/get-entries.d.ts.map +0 -1
- package/lib/utils/functions/generic/get-entries.js +0 -4
- package/lib/utils/functions/generic/get-entries.js.map +0 -1
- package/lib/utils/functions/generic/get-object-property-names.d.ts +0 -3
- package/lib/utils/functions/generic/get-object-property-names.d.ts.map +0 -1
- package/lib/utils/functions/generic/get-object-property-names.js +0 -4
- package/lib/utils/functions/generic/get-object-property-names.js.map +0 -1
- package/lib/utils/functions/generic/index.d.ts +0 -4
- package/lib/utils/functions/generic/index.d.ts.map +0 -1
- package/lib/utils/functions/generic/index.js +0 -4
- package/lib/utils/functions/generic/index.js.map +0 -1
- package/lib/utils/functions/sort/index.d.ts +0 -3
- package/lib/utils/functions/sort/index.d.ts.map +0 -1
- package/lib/utils/functions/sort/index.js +0 -3
- package/lib/utils/functions/sort/index.js.map +0 -1
- package/lib/utils/functions/sort/sort-by-properties.d.ts +0 -3
- package/lib/utils/functions/sort/sort-by-properties.d.ts.map +0 -1
- package/lib/utils/functions/sort/sort-by-properties.js +0 -16
- package/lib/utils/functions/sort/sort-by-properties.js.map +0 -1
- package/lib/utils/functions/sort/sort-by-property.d.ts +0 -3
- package/lib/utils/functions/sort/sort-by-property.d.ts.map +0 -1
- package/lib/utils/functions/sort/sort-by-property.js +0 -25
- package/lib/utils/functions/sort/sort-by-property.js.map +0 -1
- package/lib/utils/functions/type-guards/index.d.ts +0 -4
- package/lib/utils/functions/type-guards/index.d.ts.map +0 -1
- package/lib/utils/functions/type-guards/index.js +0 -4
- package/lib/utils/functions/type-guards/index.js.map +0 -1
- package/lib/utils/functions/type-guards/is-function.d.ts +0 -10
- package/lib/utils/functions/type-guards/is-function.d.ts.map +0 -1
- package/lib/utils/functions/type-guards/is-function.js +0 -11
- package/lib/utils/functions/type-guards/is-function.js.map +0 -1
- package/lib/utils/functions/type-guards/is-number.d.ts +0 -9
- package/lib/utils/functions/type-guards/is-number.d.ts.map +0 -1
- package/lib/utils/functions/type-guards/is-number.js +0 -9
- package/lib/utils/functions/type-guards/is-number.js.map +0 -1
- package/lib/utils/functions/type-guards/is-object.d.ts +0 -9
- package/lib/utils/functions/type-guards/is-object.d.ts.map +0 -1
- package/lib/utils/functions/type-guards/is-object.js +0 -9
- package/lib/utils/functions/type-guards/is-object.js.map +0 -1
- package/lib/utils/types/add-prefix-to-object.d.ts +0 -4
- package/lib/utils/types/add-prefix-to-object.d.ts.map +0 -1
- package/lib/utils/types/add-prefix-to-object.js +0 -2
- package/lib/utils/types/add-prefix-to-object.js.map +0 -1
- package/lib/utils/types/allowed-names.d.ts +0 -6
- package/lib/utils/types/allowed-names.d.ts.map +0 -1
- package/lib/utils/types/allowed-names.js +0 -2
- package/lib/utils/types/allowed-names.js.map +0 -1
- package/lib/utils/types/flag-excluded-type.d.ts +0 -7
- package/lib/utils/types/flag-excluded-type.d.ts.map +0 -1
- package/lib/utils/types/flag-excluded-type.js +0 -2
- package/lib/utils/types/flag-excluded-type.js.map +0 -1
- package/lib/utils/types/generic-object.d.ts +0 -4
- package/lib/utils/types/generic-object.d.ts.map +0 -1
- package/lib/utils/types/generic-object.js +0 -2
- package/lib/utils/types/generic-object.js.map +0 -1
- package/lib/utils/types/index.d.ts +0 -11
- package/lib/utils/types/index.d.ts.map +0 -1
- package/lib/utils/types/index.js +0 -11
- package/lib/utils/types/index.js.map +0 -1
- package/lib/utils/types/omit-type.d.ts +0 -6
- package/lib/utils/types/omit-type.d.ts.map +0 -1
- package/lib/utils/types/omit-type.js +0 -2
- package/lib/utils/types/omit-type.js.map +0 -1
- package/lib/utils/types/partial-of-properties.d.ts +0 -3
- package/lib/utils/types/partial-of-properties.d.ts.map +0 -1
- package/lib/utils/types/partial-of-properties.js +0 -2
- package/lib/utils/types/partial-of-properties.js.map +0 -1
- package/lib/utils/types/prop-of.d.ts +0 -6
- package/lib/utils/types/prop-of.d.ts.map +0 -1
- package/lib/utils/types/prop-of.js +0 -2
- package/lib/utils/types/prop-of.js.map +0 -1
- package/lib/utils/types/property-only.d.ts +0 -5
- package/lib/utils/types/property-only.d.ts.map +0 -1
- package/lib/utils/types/property-only.js +0 -2
- package/lib/utils/types/property-only.js.map +0 -1
- package/lib/utils/types/recursive-partial.d.ts +0 -4
- package/lib/utils/types/recursive-partial.d.ts.map +0 -1
- package/lib/utils/types/recursive-partial.js +0 -2
- package/lib/utils/types/recursive-partial.js.map +0 -1
- package/lib/utils/types/sort-function.d.ts +0 -2
- package/lib/utils/types/sort-function.d.ts.map +0 -1
- package/lib/utils/types/sort-function.js +0 -2
- package/lib/utils/types/sort-function.js.map +0 -1
- package/lib/utils/types/type.d.ts +0 -5
- package/lib/utils/types/type.d.ts.map +0 -1
- package/lib/utils/types/type.js +0 -2
- package/lib/utils/types/type.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v2.3.1
|
|
4
|
+
|
|
5
|
+
- Optimize build process with [tsup](https://tsup.egoist.dev/), tree-shaking and minification.
|
|
6
|
+
|
|
7
|
+
## v2.3.0
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- Added optional `mapFn` to `groupBy()` method to transform grouped values.
|
|
12
|
+
|
|
13
|
+
## v2.2.0
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
- Added an overload to `groupBy()` supporting both property keys and custom grouping functions.
|
|
18
|
+
|
|
19
|
+
### Improvements
|
|
20
|
+
|
|
21
|
+
- Internal code refactoring with no functional changes.
|
|
22
|
+
- Updated the build process to ignore test files.
|
|
23
|
+
- Updated `.npmignore` file contents.
|
|
24
|
+
|
|
25
|
+
## v2.1.1
|
|
26
|
+
|
|
27
|
+
- Rebuild v2.1.0, for `lib` was outdated.
|
|
28
|
+
|
|
29
|
+
## v2.1.0
|
|
30
|
+
|
|
31
|
+
- Added method `map()` to `Query`, intended for data projection, but more flexible and better suited for complex transformations.
|
|
32
|
+
|
|
33
|
+
## v2.0.2
|
|
34
|
+
|
|
35
|
+
This release includes minor internal refactoring. There are no new features or breaking changes.
|
|
36
|
+
|
|
37
|
+
## Improvementskv
|
|
38
|
+
|
|
39
|
+
- Performed micro-optimizations on array operations.
|
|
40
|
+
|
|
41
|
+
## v2.0.1
|
|
42
|
+
|
|
43
|
+
This release includes minor internal refactoring. There are no new features or breaking changes.
|
|
44
|
+
|
|
45
|
+
## Improvements
|
|
46
|
+
|
|
47
|
+
- Avoid repeated instantiation of `QueryRowValidator` during row validation by leveraging static members.
|
|
48
|
+
- Replace `Array.prototype.every()` with a `for...of` loop for improved performance.
|
|
49
|
+
|
|
50
|
+
## v2.0.0
|
|
51
|
+
|
|
52
|
+
### Changes
|
|
53
|
+
|
|
54
|
+
* Updated the `select()` method to return a new `Query` instance containing only the selected columns.
|
|
55
|
+
* Added a new `groupBy()` method, which returns a `Map` with results grouped by the specified column.
|
|
56
|
+
* Added an optional `column` parameter to the `column()` method, allowing you to specify which column's values should be returned.
|
|
57
|
+
* Updated the `orderBy()` method to sort query results immediately, restoring the behavior from previous versions.
|
|
58
|
+
|
|
59
|
+
### Other Improvements
|
|
60
|
+
|
|
61
|
+
* Replaced Jest with Vitest, improving test performance.
|
|
62
|
+
* Added test coverage reporting.
|
|
63
|
+
* Expanded the test suite to cover more execution paths.
|
|
64
|
+
|
|
65
|
+
## v1.0.2
|
|
66
|
+
|
|
67
|
+
Impacts:
|
|
68
|
+
|
|
69
|
+
### Production
|
|
70
|
+
|
|
71
|
+
- Code refactory: replaced legacy code with modern alternatives without modifying behavior.
|
|
72
|
+
- Removed `reflect-metadata` from dependencies list.
|
|
73
|
+
|
|
74
|
+
### Development
|
|
75
|
+
|
|
76
|
+
- Replaced `tslint` by `eslint`.
|
|
77
|
+
- Updated `tsconfig.json` with stricter options.
|
|
78
|
+
|
|
79
|
+
## v1.0.1
|
|
80
|
+
|
|
81
|
+
### Ensure rows immutability in `orderBy()`
|
|
82
|
+
|
|
83
|
+
`orderBy()` behavior was updated to register the ordering option and apply it only to the results instead of sorting the actual rows immediately.
|
|
84
|
+
|
|
85
|
+
Before:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
const results = Query.from(users)
|
|
89
|
+
.orderBy('-name') // rows would be sorted immediately
|
|
90
|
+
// ...
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
One problem with the former approach is that it was not possible to override the sorting by calling `orderBy` a second time; instead, the rows would only be sorted again.
|
|
94
|
+
|
|
95
|
+
Now:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const results = Query.from(users)
|
|
99
|
+
.orderBy('-name')
|
|
100
|
+
.orderBy('name') // the overriden orderBy option is the only one applied,
|
|
101
|
+
// affecting only the final results
|
|
102
|
+
// ...
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The new approach ensures that the inner rows always remain the same, maintaining their original order.
|
|
106
|
+
|
|
107
|
+
It is also possible to clear the ordering now:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const results = Query.from(users)
|
|
111
|
+
.orderBy('name')
|
|
112
|
+
.orderBy() // no sorting logic will be applied to the rows
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Fix Jest configuration
|
|
116
|
+
|
|
117
|
+
Update match to include `__tests__/*.spec.ts` files only. The previous configuration enabled testing JS and TS type files too, causing errors.
|
|
118
|
+
|
|
119
|
+
### Other improvements
|
|
120
|
+
|
|
121
|
+
- Create a `.prettierignore` file.
|
|
122
|
+
- Update `.npmignore` file contents.
|
|
123
|
+
|
|
124
|
+
## v1.0.0
|
|
125
|
+
|
|
126
|
+
Updates:
|
|
127
|
+
|
|
128
|
+
- Dependencies updated.
|
|
129
|
+
- Code refactored keeping previous behavior.
|
|
130
|
+
- Unit tests created or reviewed to cover the whole codebase.
|
|
131
|
+
- Migrated from npm to pnpm.
|
|
132
|
+
- Prettier configuration updated and integrated with Visual Studio Code.
|
|
133
|
+
|
|
134
|
+
## v0.0.0
|
|
135
|
+
|
|
136
|
+
Create initial project.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var M=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var N=o=>{throw TypeError(o)};var x=(o,t,e,r)=>{for(var n=q(t,e),s=o.length-1,i;s>=0;s--)(i=o[s])&&(n=(i(t,e,n))||n);return n&&M(t,e,n),n},b=(o,t)=>(e,r)=>t(e,r,o);var V=(o,t,e)=>t.has(o)||N("Cannot "+e);var l=(o,t,e)=>(V(o,t,"read from private field"),e?e.call(o):t.get(o)),T=(o,t,e)=>t.has(o)?N("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),p=(o,t,e,r)=>(V(o,t,"write to private field"),t.set(o,e),e);var O=o=>typeof o=="number";var y=class extends Error{constructor(t){super(t),this.name="InvalidArgumentError";}};var v=new WeakMap;function A(o,t){let e=v.get(o);e||(e=new Map,v.set(o,e));let r=e.get(t);return r||(r=[],e.set(t,r)),r}function P(o){return function(t,e,r){let n=A(t,e),s=n.find(i=>i.index===r);s?s.min=o:n.push({index:r,min:o});}}function k(o,t,e){let r=A(o,t),n=r.find(s=>s.index===e);n?n.integer=true:r.push({index:e,integer:true});}function C(o,t,e){let r=e.value;e.value=function(...n){let s=v.get(o)?.get(t)??[];for(let i of s){let u=n[i.index];if(i.min!==void 0&&(!O(u)||u<i.min))throw new y(`${String(u)} is not a valid argument to param ${i.index} on ${t}(). Expected value to be equal or greater than ${i.min}.`);if(i.max!==void 0&&(!O(u)||u>i.max))throw new y(`${String(u)} is not a valid argument to param ${i.index} on ${t}(). Expected value to be equal or less than ${i.max}.`);if(i.integer&&!Number.isSafeInteger(u))throw new y(`${String(u)} is not a valid argument to param ${i.index} on ${t}(). Expected value to be an integer.`)}return r.apply(this,n)};}var d=o=>typeof o=="object"&&o!==null;var j=(o,t)=>{if(o===t)return true;if(!d(o)||!d(t)||Array.isArray(o)!==Array.isArray(t))return false;let e=Object.keys(o),r=Object.keys(t);return e.length!==r.length?false:e.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&j(o[n],t[n]))};var G=(o,t)=>o.length===t.length&&o.every((e,r)=>j(e,t[r]));function B(o){return Object.entries(o)}var h=o=>typeof o=="function";var w,g=class{static validate(t,e,r){for(let[n,s]of B(e))if(!this.validateColumnCondition(t,n,s,r??l(this,w)))return false;return true}static validateColumnCondition(t,e,r,n){if(n.ignoreNullValues&&r==null)return true;let s=t[e];return h(r)?r(s):Array.isArray(r)?Array.isArray(s)?G(s,r):false:d(r)?d(s)?this.validate(s,r):false:s===r}};w=new WeakMap,T(g,w,{ignoreNullValues:false});function S(o){return Object.keys(o).filter(t=>typeof o[t]!="function")}function $(o){let t=1,e=o;e.startsWith("-")&&(t=-1,e=e.slice(1));let r=e;return (n,s)=>{let i=n[r],u=s[r];return i==null&&u==null?0:i==null?1*t:u==null||i<u?-1*t:i>u?1*t:0}}function E(...o){return (t,e)=>{if(o.length===0)return 0;for(let r of o){let n=$(r)(t,e);if(n!==0)return n}return 0}}var a,f,c,m=class m{constructor(t){T(this,a,[]);T(this,f,0);T(this,c,null);p(this,a,[...t]);}static from(t){return new m(t)}select(...t){let e=[];for(let n of l(this,a)){let s={};for(let i of t)s[i]=n[i];e.push(s);}let r=new m(e);return this.cloneStateInto(r),r}map(t){let e=[];for(let n of l(this,a))e.push(t(n));let r=new m(e);return this.cloneStateInto(r),r}where(t){return this.filterRows(t),this}filterWhere(t){return this.filterRows(t,{ignoreNullValues:true}),this}orderBy(...t){return p(this,a,l(this,a).sort(E(...t))),this}skip(t){return p(this,f,t),this}limit(t){return p(this,c,t),this}groupBy(t,e){let r=this.getLimitedRows(),n=new Map,s=h(t);for(let i of r){let u=s?t(i):i[t],F=e?e(i):i;n.has(u)?n.get(u).push(F):n.set(u,[F]);}return n}all(){return this.getLimitedRows()}first(){let t=this.getLimitedRows();return t.length>0?t[0]:null}last(){let t=this.getLimitedRows();return t[t.length-1]??null}scalar(){let t=this.first(),e=this.getFirstColumn();return t&&e?t[e]:false}column(t){if(t===void 0){let e=this.getFirstColumn();if(!e)return [];t=e;}return this.getLimitedRows().map(e=>e[t])}values(){let t=[];for(let e of this.getLimitedRows())t.push(Object.values(e));return t}count(){return this.getLimitedRows().length}exists(){return this.count()>0}filterRows(t,e){let r=l(this,a),n=[];if(h(t))for(let s=0;s<r.length;s++){let i=r[s];t(i)&&n.push(i);}else for(let s=0;s<r.length;s++){let i=r[s];g.validate(i,t,e)&&n.push(i);}p(this,a,n);}getFirstColumn(){let t=this.first();if(!t)return null;let e=S(t);return e.length>0?e[0]:null}getLimitedRows(){let t=[...l(this,a)];return t.slice(l(this,f),l(this,f)+(l(this,c)??t.length))}cloneStateInto(t){p(t,f,l(this,f)),p(t,c,l(this,c));}};a=new WeakMap,f=new WeakMap,c=new WeakMap,x([C,b(0,k),b(0,P(0))],m.prototype,"skip"),x([C,b(0,k),b(0,P(0))],m.prototype,"limit");var R=m;exports.Query=R;
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type addPrefixToObject<T, P extends string> = {
|
|
2
|
+
[K in keyof T as K extends string ? `${P}${K}` : never]: T[K];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
type NonFunctionKeys<T extends object> = {
|
|
6
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? never : K;
|
|
7
|
+
}[keyof T];
|
|
8
|
+
|
|
9
|
+
type PropertyOnly<T extends object> = {
|
|
10
|
+
[P in NonFunctionKeys<T>]: T[P];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents a property of a class or interface.
|
|
15
|
+
*/
|
|
16
|
+
type PropOf<T extends object> = keyof PropertyOnly<T>;
|
|
17
|
+
|
|
18
|
+
type OrderingColumn<T extends object> = PropOf<T> | keyof addPrefixToObject<PropertyOnly<T>, '-'>;
|
|
19
|
+
|
|
20
|
+
type QueryConditionsGroup<T extends object> = {
|
|
21
|
+
[P in keyof PropertyOnly<T>]?: T[P] extends object ? QueryConditionsGroup<T[P]> : T[P] | ((value: T[P]) => boolean);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type NullableCondition<T> = T | ((value: T) => boolean) | null | undefined;
|
|
25
|
+
|
|
26
|
+
type QueryConditionsGroupNullable<T extends object> = {
|
|
27
|
+
[P in keyof PropertyOnly<T>]?: T[P] extends object ? QueryConditionsGroupNullable<T[P]> : NullableCondition<T[P]>;
|
|
28
|
+
};
|
|
29
|
+
|
|
4
30
|
/**
|
|
5
31
|
* Allows filtering data from an array of objects.
|
|
6
32
|
*
|
|
@@ -47,7 +73,7 @@ import type { PropOf } from './utils/types';
|
|
|
47
73
|
* const numberOfUsers = Query.from(users).count();
|
|
48
74
|
* ```
|
|
49
75
|
*/
|
|
50
|
-
|
|
76
|
+
declare class Query<T extends object> {
|
|
51
77
|
#private;
|
|
52
78
|
/**
|
|
53
79
|
* Initializes the query.
|
|
@@ -262,4 +288,5 @@ export declare class Query<T extends object> {
|
|
|
262
288
|
*/
|
|
263
289
|
private cloneStateInto;
|
|
264
290
|
}
|
|
265
|
-
|
|
291
|
+
|
|
292
|
+
export { Query };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
type addPrefixToObject<T, P extends string> = {
|
|
2
|
+
[K in keyof T as K extends string ? `${P}${K}` : never]: T[K];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
type NonFunctionKeys<T extends object> = {
|
|
6
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? never : K;
|
|
7
|
+
}[keyof T];
|
|
8
|
+
|
|
9
|
+
type PropertyOnly<T extends object> = {
|
|
10
|
+
[P in NonFunctionKeys<T>]: T[P];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents a property of a class or interface.
|
|
15
|
+
*/
|
|
16
|
+
type PropOf<T extends object> = keyof PropertyOnly<T>;
|
|
17
|
+
|
|
18
|
+
type OrderingColumn<T extends object> = PropOf<T> | keyof addPrefixToObject<PropertyOnly<T>, '-'>;
|
|
19
|
+
|
|
20
|
+
type QueryConditionsGroup<T extends object> = {
|
|
21
|
+
[P in keyof PropertyOnly<T>]?: T[P] extends object ? QueryConditionsGroup<T[P]> : T[P] | ((value: T[P]) => boolean);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type NullableCondition<T> = T | ((value: T) => boolean) | null | undefined;
|
|
25
|
+
|
|
26
|
+
type QueryConditionsGroupNullable<T extends object> = {
|
|
27
|
+
[P in keyof PropertyOnly<T>]?: T[P] extends object ? QueryConditionsGroupNullable<T[P]> : NullableCondition<T[P]>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Allows filtering data from an array of objects.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* interface User {
|
|
36
|
+
* id: string;
|
|
37
|
+
* email: string;
|
|
38
|
+
* isActive: boolean;
|
|
39
|
+
* createdAt: string;
|
|
40
|
+
* updatedAt: string;
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* const users: User[] = [];
|
|
44
|
+
*
|
|
45
|
+
* // Filtering objects
|
|
46
|
+
*
|
|
47
|
+
* const activeGmailUsers = Query.from(users)
|
|
48
|
+
* .where({
|
|
49
|
+
* isActive: true,
|
|
50
|
+
* email: (email) => email.endsWith('@gmail.com'),
|
|
51
|
+
* })
|
|
52
|
+
* .all();
|
|
53
|
+
*
|
|
54
|
+
* // Selecting specific data
|
|
55
|
+
*
|
|
56
|
+
* const userEmails = Query.from(users)
|
|
57
|
+
* .select('email')
|
|
58
|
+
* .column();
|
|
59
|
+
*
|
|
60
|
+
* const lastUserId = Query.from(users)
|
|
61
|
+
* .select('id')
|
|
62
|
+
* .orderBy('-createdAt')
|
|
63
|
+
* .scalar();
|
|
64
|
+
*
|
|
65
|
+
* // Checking information
|
|
66
|
+
*
|
|
67
|
+
* const userExists = Query.from(users)
|
|
68
|
+
* .where({
|
|
69
|
+
* id: 'some-id',
|
|
70
|
+
* })
|
|
71
|
+
* .exists();
|
|
72
|
+
*
|
|
73
|
+
* const numberOfUsers = Query.from(users).count();
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare class Query<T extends object> {
|
|
77
|
+
#private;
|
|
78
|
+
/**
|
|
79
|
+
* Initializes the query.
|
|
80
|
+
*
|
|
81
|
+
* @param rows Rows to be queried.
|
|
82
|
+
*/
|
|
83
|
+
private constructor();
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new query based on the given data.
|
|
86
|
+
*
|
|
87
|
+
* @param rows Rows to be queried.
|
|
88
|
+
*
|
|
89
|
+
* @returns Query to the given rows.
|
|
90
|
+
*/
|
|
91
|
+
static from<T extends object>(rows: T[]): Query<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Defines specific columns to be returned on the final results.
|
|
94
|
+
*
|
|
95
|
+
* @param columns Selected columns.
|
|
96
|
+
*
|
|
97
|
+
* @returns Current query.
|
|
98
|
+
*/
|
|
99
|
+
select<TColumns extends PropOf<T>[]>(...columns: TColumns): Query<{
|
|
100
|
+
[P in TColumns[number]]: T[P];
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Maps each row to a new object and returns a new query.
|
|
104
|
+
*
|
|
105
|
+
* @param callback Function to be called for each row.
|
|
106
|
+
* @returns New query with the mapped rows.
|
|
107
|
+
*/
|
|
108
|
+
map<TReturn extends object>(callback: (obj: T) => TReturn): Query<TReturn>;
|
|
109
|
+
/**
|
|
110
|
+
* Applies conditions to the query.
|
|
111
|
+
*
|
|
112
|
+
* @param condition Filter to be applied to the query.
|
|
113
|
+
*
|
|
114
|
+
* If a callback function is provided, it must return a boolean value.
|
|
115
|
+
*
|
|
116
|
+
* If an object is provided, its properties must be attributes of `T` and their
|
|
117
|
+
* corresponding values must be the expected values for the attributes or a
|
|
118
|
+
* callback functions that return boolean values.
|
|
119
|
+
*
|
|
120
|
+
* @returns Current query.
|
|
121
|
+
*/
|
|
122
|
+
where(condition: QueryConditionsGroup<T> | ((obj: T) => boolean)): this;
|
|
123
|
+
/**
|
|
124
|
+
* Applies a set of conditions to the query ignoring `null` and `undefined`
|
|
125
|
+
* values as conditions.
|
|
126
|
+
*
|
|
127
|
+
* @param condition An object where each property represents an attribute
|
|
128
|
+
* to be validated. The values can be literal or callback functions that
|
|
129
|
+
* return a boolean. If `null` or `undefined` is passed, that condition
|
|
130
|
+
* will be skipped.
|
|
131
|
+
*
|
|
132
|
+
* @returns Current query.
|
|
133
|
+
*/
|
|
134
|
+
filterWhere(condition: QueryConditionsGroupNullable<T>): this;
|
|
135
|
+
/**
|
|
136
|
+
* Adds ordering to the results.
|
|
137
|
+
*
|
|
138
|
+
* This method should be called after `select()`; otherwise, the ordering will
|
|
139
|
+
* be applied only to the selected columns.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* // ❌ "age" will not be ordered, because it is not part of the selected columns
|
|
144
|
+
* const query = Query.from(users)
|
|
145
|
+
* .orderBy('-age')
|
|
146
|
+
* .select('name');
|
|
147
|
+
*
|
|
148
|
+
* // ✅ "age" will be ordered
|
|
149
|
+
* const query = Query.from(users)
|
|
150
|
+
* .select('name', 'age')
|
|
151
|
+
* .orderBy('-age');
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @param columns Ascending or descending columns. To mark a field as
|
|
155
|
+
* descending, prefix it with `-`.
|
|
156
|
+
*
|
|
157
|
+
* @returns Current query.
|
|
158
|
+
*/
|
|
159
|
+
orderBy(...columns: OrderingColumn<T>[]): this;
|
|
160
|
+
/**
|
|
161
|
+
* Defines the number of rows to skip.
|
|
162
|
+
*
|
|
163
|
+
* @param numberOfRows Numbers of rows to skip. Only non negative integer numbers
|
|
164
|
+
* are allowed.
|
|
165
|
+
*
|
|
166
|
+
* @returns Current query.
|
|
167
|
+
*
|
|
168
|
+
* @throws {InvalidArgumentError} If the given number is less than 0.
|
|
169
|
+
*/
|
|
170
|
+
skip(numberOfRows: number): this;
|
|
171
|
+
/**
|
|
172
|
+
* Defines a limit for the number of results.
|
|
173
|
+
*
|
|
174
|
+
* @param limit Limit of results. Only non negative integer numbers are allowed.
|
|
175
|
+
*
|
|
176
|
+
* @returns Current query.
|
|
177
|
+
*
|
|
178
|
+
* @throws {InvalidArgumentError} If the given limit is less than 0.
|
|
179
|
+
*/
|
|
180
|
+
limit(limit: number): this;
|
|
181
|
+
/**
|
|
182
|
+
* Groups the results by a specific key.
|
|
183
|
+
*
|
|
184
|
+
* @param key Key to group by.
|
|
185
|
+
*
|
|
186
|
+
* @returns Grouped results.
|
|
187
|
+
*/
|
|
188
|
+
groupBy<K extends keyof T>(key: K): Map<T[K], T[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Groups the results by a specific key.
|
|
191
|
+
*
|
|
192
|
+
* @param key Key to group by.
|
|
193
|
+
* @param mapFn Callback to map each row to a new value.
|
|
194
|
+
*
|
|
195
|
+
* @returns Grouped results.
|
|
196
|
+
*/
|
|
197
|
+
groupBy<K extends keyof T, TReturn>(key: K, mapFn: (row: T) => TReturn): Map<T[K], TReturn[]>;
|
|
198
|
+
/**
|
|
199
|
+
* Groups the results by a callback.
|
|
200
|
+
*
|
|
201
|
+
* @param groupFn Callback to group by.
|
|
202
|
+
*
|
|
203
|
+
* @returns Grouped results.
|
|
204
|
+
*/
|
|
205
|
+
groupBy<TGrouper>(groupFn: (row: T) => TGrouper): Map<TGrouper, T[]>;
|
|
206
|
+
/**
|
|
207
|
+
* Groups the results by a callback.
|
|
208
|
+
*
|
|
209
|
+
* @param groupFn Callback to group by.
|
|
210
|
+
*
|
|
211
|
+
* @returns Grouped results.
|
|
212
|
+
*/
|
|
213
|
+
groupBy<TGrouper, TReturn>(groupFn: (row: T) => TGrouper, mapFn: (row: T) => TReturn): Map<TGrouper, TReturn[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Returns all results.
|
|
216
|
+
*
|
|
217
|
+
* @returns All filtered rows.
|
|
218
|
+
*/
|
|
219
|
+
all(): T[];
|
|
220
|
+
/**
|
|
221
|
+
* Returns the first result.
|
|
222
|
+
*
|
|
223
|
+
* @returns The first result.
|
|
224
|
+
*/
|
|
225
|
+
first(): T | null;
|
|
226
|
+
/**
|
|
227
|
+
* Returns the last result.
|
|
228
|
+
*
|
|
229
|
+
* @returns The last result.
|
|
230
|
+
*/
|
|
231
|
+
last(): T | null;
|
|
232
|
+
/**
|
|
233
|
+
* Returns the value of the first (selected) column of the first row.
|
|
234
|
+
*
|
|
235
|
+
* @returns First value or `false`, if none row exists.
|
|
236
|
+
*/
|
|
237
|
+
scalar(): T[PropOf<T>] | false;
|
|
238
|
+
/**
|
|
239
|
+
* Returns the values of the first (selected) column of all rows.
|
|
240
|
+
*
|
|
241
|
+
* @param column (Optional) The column to get the values from.
|
|
242
|
+
*
|
|
243
|
+
* @returns Values from the first (selected) column.
|
|
244
|
+
*/
|
|
245
|
+
column(): T[PropOf<T>][];
|
|
246
|
+
column<TColumn extends PropOf<T>>(column: TColumn): T[TColumn][];
|
|
247
|
+
/**
|
|
248
|
+
* Returns the values of the rows. If there are selected columns, only their
|
|
249
|
+
* values will be returned.
|
|
250
|
+
*
|
|
251
|
+
* @returns Array with the values of all rows.
|
|
252
|
+
*/
|
|
253
|
+
values(): T[PropOf<T>][][];
|
|
254
|
+
/**
|
|
255
|
+
* Returns the current number of rows.
|
|
256
|
+
*
|
|
257
|
+
* @return Filtered rows count.
|
|
258
|
+
*/
|
|
259
|
+
count(): number;
|
|
260
|
+
/**
|
|
261
|
+
* Checks if there is at least one row compatible with the query.
|
|
262
|
+
*
|
|
263
|
+
* @returns Whether any row exists after filtering.
|
|
264
|
+
*/
|
|
265
|
+
exists(): boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Filters the rows according to the given conditions.
|
|
268
|
+
*
|
|
269
|
+
* @param condition Object or callback function.
|
|
270
|
+
*/
|
|
271
|
+
private filterRows;
|
|
272
|
+
/**
|
|
273
|
+
* Returns the first selected column or the first key of some row.
|
|
274
|
+
*
|
|
275
|
+
* @returns The first column or `null`, if none is selected or there is no row.
|
|
276
|
+
*/
|
|
277
|
+
private getFirstColumn;
|
|
278
|
+
/**
|
|
279
|
+
* Returns the rows that should be used in the final results.
|
|
280
|
+
*
|
|
281
|
+
* @returns Rows within the specified limit.
|
|
282
|
+
*/
|
|
283
|
+
private getLimitedRows;
|
|
284
|
+
/**
|
|
285
|
+
* Copies the state of the current query into the given query.
|
|
286
|
+
*
|
|
287
|
+
* @param query Query to copy the state into.
|
|
288
|
+
*/
|
|
289
|
+
private cloneStateInto;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export { Query };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var M=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var N=o=>{throw TypeError(o)};var x=(o,t,e,r)=>{for(var n=q(t,e),s=o.length-1,i;s>=0;s--)(i=o[s])&&(n=(i(t,e,n))||n);return n&&M(t,e,n),n},b=(o,t)=>(e,r)=>t(e,r,o);var V=(o,t,e)=>t.has(o)||N("Cannot "+e);var l=(o,t,e)=>(V(o,t,"read from private field"),e?e.call(o):t.get(o)),T=(o,t,e)=>t.has(o)?N("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),p=(o,t,e,r)=>(V(o,t,"write to private field"),t.set(o,e),e);var O=o=>typeof o=="number";var y=class extends Error{constructor(t){super(t),this.name="InvalidArgumentError";}};var v=new WeakMap;function A(o,t){let e=v.get(o);e||(e=new Map,v.set(o,e));let r=e.get(t);return r||(r=[],e.set(t,r)),r}function P(o){return function(t,e,r){let n=A(t,e),s=n.find(i=>i.index===r);s?s.min=o:n.push({index:r,min:o});}}function k(o,t,e){let r=A(o,t),n=r.find(s=>s.index===e);n?n.integer=true:r.push({index:e,integer:true});}function C(o,t,e){let r=e.value;e.value=function(...n){let s=v.get(o)?.get(t)??[];for(let i of s){let u=n[i.index];if(i.min!==void 0&&(!O(u)||u<i.min))throw new y(`${String(u)} is not a valid argument to param ${i.index} on ${t}(). Expected value to be equal or greater than ${i.min}.`);if(i.max!==void 0&&(!O(u)||u>i.max))throw new y(`${String(u)} is not a valid argument to param ${i.index} on ${t}(). Expected value to be equal or less than ${i.max}.`);if(i.integer&&!Number.isSafeInteger(u))throw new y(`${String(u)} is not a valid argument to param ${i.index} on ${t}(). Expected value to be an integer.`)}return r.apply(this,n)};}var d=o=>typeof o=="object"&&o!==null;var j=(o,t)=>{if(o===t)return true;if(!d(o)||!d(t)||Array.isArray(o)!==Array.isArray(t))return false;let e=Object.keys(o),r=Object.keys(t);return e.length!==r.length?false:e.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&j(o[n],t[n]))};var G=(o,t)=>o.length===t.length&&o.every((e,r)=>j(e,t[r]));function B(o){return Object.entries(o)}var h=o=>typeof o=="function";var w,g=class{static validate(t,e,r){for(let[n,s]of B(e))if(!this.validateColumnCondition(t,n,s,r??l(this,w)))return false;return true}static validateColumnCondition(t,e,r,n){if(n.ignoreNullValues&&r==null)return true;let s=t[e];return h(r)?r(s):Array.isArray(r)?Array.isArray(s)?G(s,r):false:d(r)?d(s)?this.validate(s,r):false:s===r}};w=new WeakMap,T(g,w,{ignoreNullValues:false});function S(o){return Object.keys(o).filter(t=>typeof o[t]!="function")}function $(o){let t=1,e=o;e.startsWith("-")&&(t=-1,e=e.slice(1));let r=e;return (n,s)=>{let i=n[r],u=s[r];return i==null&&u==null?0:i==null?1*t:u==null||i<u?-1*t:i>u?1*t:0}}function E(...o){return (t,e)=>{if(o.length===0)return 0;for(let r of o){let n=$(r)(t,e);if(n!==0)return n}return 0}}var a,f,c,m=class m{constructor(t){T(this,a,[]);T(this,f,0);T(this,c,null);p(this,a,[...t]);}static from(t){return new m(t)}select(...t){let e=[];for(let n of l(this,a)){let s={};for(let i of t)s[i]=n[i];e.push(s);}let r=new m(e);return this.cloneStateInto(r),r}map(t){let e=[];for(let n of l(this,a))e.push(t(n));let r=new m(e);return this.cloneStateInto(r),r}where(t){return this.filterRows(t),this}filterWhere(t){return this.filterRows(t,{ignoreNullValues:true}),this}orderBy(...t){return p(this,a,l(this,a).sort(E(...t))),this}skip(t){return p(this,f,t),this}limit(t){return p(this,c,t),this}groupBy(t,e){let r=this.getLimitedRows(),n=new Map,s=h(t);for(let i of r){let u=s?t(i):i[t],F=e?e(i):i;n.has(u)?n.get(u).push(F):n.set(u,[F]);}return n}all(){return this.getLimitedRows()}first(){let t=this.getLimitedRows();return t.length>0?t[0]:null}last(){let t=this.getLimitedRows();return t[t.length-1]??null}scalar(){let t=this.first(),e=this.getFirstColumn();return t&&e?t[e]:false}column(t){if(t===void 0){let e=this.getFirstColumn();if(!e)return [];t=e;}return this.getLimitedRows().map(e=>e[t])}values(){let t=[];for(let e of this.getLimitedRows())t.push(Object.values(e));return t}count(){return this.getLimitedRows().length}exists(){return this.count()>0}filterRows(t,e){let r=l(this,a),n=[];if(h(t))for(let s=0;s<r.length;s++){let i=r[s];t(i)&&n.push(i);}else for(let s=0;s<r.length;s++){let i=r[s];g.validate(i,t,e)&&n.push(i);}p(this,a,n);}getFirstColumn(){let t=this.first();if(!t)return null;let e=S(t);return e.length>0?e[0]:null}getLimitedRows(){let t=[...l(this,a)];return t.slice(l(this,f),l(this,f)+(l(this,c)??t.length))}cloneStateInto(t){p(t,f,l(this,f)),p(t,c,l(this,c));}};a=new WeakMap,f=new WeakMap,c=new WeakMap,x([C,b(0,k),b(0,P(0))],m.prototype,"skip"),x([C,b(0,k),b(0,P(0))],m.prototype,"limit");var R=m;export{R as Query};
|
package/package.json
CHANGED
|
@@ -1,16 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "querier-ts",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.3.1",
|
|
5
|
+
"description": "A lightweight, type-safe in-memory query engine for JavaScript and TypeScript",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/luizfilipezs/query-ts.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"query",
|
|
12
|
+
"data filtering",
|
|
13
|
+
"in-memory"
|
|
14
|
+
],
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Luiz Filipe da Silva",
|
|
17
|
+
"email": "luizfilipezs@proton.me",
|
|
18
|
+
"url": "https://github.com/luizfilipezs"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/luizfilipezs/query-ts/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/luizfilipezs/query-ts#readme",
|
|
7
25
|
"files": [
|
|
8
|
-
"
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"CHANGELOG.md"
|
|
9
30
|
],
|
|
31
|
+
"main": "./dist/index.cjs",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"import": "./dist/index.js",
|
|
37
|
+
"require": "./dist/index.cjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"sideEffects": false,
|
|
10
41
|
"scripts": {
|
|
11
42
|
"test": "vitest",
|
|
12
43
|
"test:cov": "vitest --coverage",
|
|
13
|
-
"build": "
|
|
44
|
+
"build": "tsup",
|
|
14
45
|
"type-check": "tsc --noEmit",
|
|
15
46
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
16
47
|
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
@@ -26,27 +57,6 @@
|
|
|
26
57
|
"eslint --fix"
|
|
27
58
|
]
|
|
28
59
|
},
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/luizfilipezs/query-ts.git"
|
|
32
|
-
},
|
|
33
|
-
"keywords": [
|
|
34
|
-
"query",
|
|
35
|
-
"data filtering"
|
|
36
|
-
],
|
|
37
|
-
"author": {
|
|
38
|
-
"name": "Luiz Filipe da Silva",
|
|
39
|
-
"email": "filipeluiz.bs@gmail.com",
|
|
40
|
-
"url": "https://blogdolipe.com.br"
|
|
41
|
-
},
|
|
42
|
-
"license": "MIT",
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/luizfilipezs/query-ts/issues"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://github.com/luizfilipezs/query-ts#readme",
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"utility-types": "^3.11.0"
|
|
49
|
-
},
|
|
50
60
|
"devDependencies": {
|
|
51
61
|
"@eslint/js": "^10.0.1",
|
|
52
62
|
"@vitest/coverage-v8": "^4.1.2",
|
|
@@ -59,6 +69,7 @@
|
|
|
59
69
|
"lint-staged": "^16.4.0",
|
|
60
70
|
"prettier": "^3.8.1",
|
|
61
71
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
72
|
+
"tsup": "^8.5.1",
|
|
62
73
|
"typescript": "~5.9.3",
|
|
63
74
|
"typescript-eslint": "^8.57.1",
|
|
64
75
|
"vitest": "^4.1.2"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/lib/core/errors/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-argument-error.d.ts","sourceRoot":"","sources":["../../../src/core/errors/invalid-argument-error.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-argument-error.js","sourceRoot":"","sources":["../../../src/core/errors/invalid-argument-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attribute-validation-function.d.ts","sourceRoot":"","sources":["../../../src/core/types/attribute-validation-function.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,CACrC,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IACzB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attribute-validation-function.js","sourceRoot":"","sources":["../../../src/core/types/attribute-validation-function.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AttributeValidationFunction } from './attribute-validation-function';
|
|
2
|
-
import type { QueryConditionsGroupNullable } from './query-conditions-group-nullable';
|
|
3
|
-
/**
|
|
4
|
-
* Condition to apply to a row column.
|
|
5
|
-
*/
|
|
6
|
-
export type ColumnCondition<T extends object, P extends keyof T> = T[P] extends object ? QueryConditionsGroupNullable<T[P]> | undefined : T[P] | AttributeValidationFunction<T, P> | null | undefined;
|
|
7
|
-
//# sourceMappingURL=column-condition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"column-condition.d.ts","sourceRoot":"","sources":["../../../src/core/types/column-condition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEtF;;GAEG;AACH,MAAM,MAAM,eAAe,CACzB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,MAAM,CAAC,IACf,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACnB,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAC9C,CAAC,CAAC,CAAC,CAAC,GAAG,2BAA2B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"column-condition.js","sourceRoot":"","sources":["../../../src/core/types/column-condition.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC"}
|