querier-ts 1.0.1 → 2.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/README.md +76 -70
- 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/ordering-column.d.ts +3 -0
- package/lib/core/types/ordering-column.d.ts.map +1 -0
- package/lib/core/types/ordering-column.js +2 -0
- package/lib/core/types/ordering-column.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 +34 -5
- package/lib/query.d.ts.map +1 -0
- package/lib/query.js +117 -62
- 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/get-object-property-names.d.ts +3 -0
- package/lib/utils/functions/generic/get-object-property-names.d.ts.map +1 -0
- package/lib/utils/functions/generic/get-object-property-names.js +4 -0
- package/lib/utils/functions/generic/get-object-property-names.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 -10
- 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
package/README.md
CHANGED
|
@@ -1,49 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
interface UserPermissions {
|
|
11
|
-
useCookies: boolean;
|
|
12
|
-
sendNotifications: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
class User {
|
|
16
|
-
id: number;
|
|
17
|
-
name: string;
|
|
18
|
-
permissions: UserPermissions;
|
|
19
|
-
isActive: boolean;
|
|
20
|
-
createdAt: Date;
|
|
21
|
-
updatedAt: Date;
|
|
22
|
-
|
|
23
|
-
isAdmin(): boolean {
|
|
24
|
-
...
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const users: User[] = [
|
|
29
|
-
...
|
|
30
|
-
];
|
|
31
|
-
```
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
querier-ts
|
|
3
|
+
</h1>
|
|
4
|
+
<p align="center">
|
|
5
|
+
A lightweight, type-safe in-memory query engine for JavaScript and TypeScript.
|
|
6
|
+
<p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://npmx.dev/package/querier-ts"><img src="https://img.shields.io/npm/v/querier-ts?color=729B1B&label=" alt="current querier-ts version badge"></a>
|
|
9
|
+
<p>
|
|
32
10
|
|
|
33
11
|
## `Query`
|
|
34
12
|
|
|
35
|
-
|
|
13
|
+
You can create a `Query` instance like this:
|
|
36
14
|
|
|
37
15
|
```ts
|
|
38
16
|
const usersQuery = Query.from(users);
|
|
39
17
|
```
|
|
40
18
|
|
|
41
|
-
TypeScript will automatically
|
|
19
|
+
TypeScript will automatically infer the query data type. You can also make it explicit:
|
|
42
20
|
|
|
43
21
|
```ts
|
|
44
22
|
const usersQuery = Query.from<User>(users);
|
|
45
23
|
```
|
|
46
24
|
|
|
25
|
+
---
|
|
26
|
+
|
|
47
27
|
### Getting results
|
|
48
28
|
|
|
49
29
|
#### `all()`
|
|
@@ -66,16 +46,18 @@ Returns the number of results.
|
|
|
66
46
|
|
|
67
47
|
Returns a boolean indicating whether any results exist.
|
|
68
48
|
|
|
49
|
+
---
|
|
50
|
+
|
|
69
51
|
### Filtering data
|
|
70
52
|
|
|
71
53
|
#### `where(condition)`
|
|
72
54
|
|
|
73
|
-
|
|
55
|
+
This method accepts two types of parameters:
|
|
74
56
|
|
|
75
|
-
1. An object where each property represents
|
|
76
|
-
2. A callback function that returns a boolean
|
|
57
|
+
1. An object, where each property represents a field to be validated.
|
|
58
|
+
2. A callback function that returns a boolean.
|
|
77
59
|
|
|
78
|
-
When
|
|
60
|
+
When passing an object, each property can be either a literal value or a callback function used for validation.
|
|
79
61
|
|
|
80
62
|
```ts
|
|
81
63
|
const activeGmailUsers = Query.from(users)
|
|
@@ -83,60 +65,68 @@ const activeGmailUsers = Query.from(users)
|
|
|
83
65
|
isActive: true,
|
|
84
66
|
email: (email) => email.endsWith('@gmail.com'),
|
|
85
67
|
})
|
|
86
|
-
.where((user) => (
|
|
87
|
-
!user.isAdmin()
|
|
88
|
-
))
|
|
68
|
+
.where((user) => !user.isAdmin())
|
|
89
69
|
.all();
|
|
90
70
|
```
|
|
91
71
|
|
|
92
|
-
It also
|
|
72
|
+
It also supports nested objects:
|
|
93
73
|
|
|
94
74
|
```ts
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
75
|
+
.where({
|
|
76
|
+
permissions: {
|
|
77
|
+
sendNotifications: true,
|
|
78
|
+
},
|
|
79
|
+
})
|
|
100
80
|
```
|
|
101
81
|
|
|
82
|
+
---
|
|
83
|
+
|
|
102
84
|
#### `filterWhere(condition)`
|
|
103
85
|
|
|
104
|
-
|
|
86
|
+
Unlike `where()`, `filterWhere()`:
|
|
87
|
+
|
|
88
|
+
* Accepts only an object
|
|
89
|
+
* Ignores properties whose values are `null` or `undefined`
|
|
105
90
|
|
|
106
91
|
```ts
|
|
107
|
-
let isActive:
|
|
92
|
+
let isActive: boolean; // undefined
|
|
108
93
|
|
|
109
94
|
const filteredUsers = Query.from(users)
|
|
110
95
|
.filterWhere({
|
|
111
96
|
id: 1,
|
|
112
|
-
isActive: isActive, //
|
|
97
|
+
isActive: isActive, // ignored
|
|
113
98
|
})
|
|
114
99
|
.all();
|
|
115
100
|
```
|
|
116
101
|
|
|
117
|
-
|
|
102
|
+
> **Note:** If you need to explicitly check for `null` or `undefined`, use `where()` instead.
|
|
103
|
+
|
|
104
|
+
---
|
|
118
105
|
|
|
119
106
|
### Selecting specific data
|
|
120
107
|
|
|
121
108
|
#### `select(columns)`
|
|
122
109
|
|
|
123
|
-
|
|
110
|
+
Defines which columns should be selected.
|
|
111
|
+
It can be combined with `scalar()`, `column()`, or `values()`.
|
|
124
112
|
|
|
125
|
-
|
|
113
|
+
Accepts either a string (single column) or an array of column names.
|
|
126
114
|
|
|
127
115
|
```ts
|
|
128
|
-
|
|
116
|
+
.select('id')
|
|
129
117
|
```
|
|
130
118
|
|
|
119
|
+
---
|
|
120
|
+
|
|
131
121
|
#### `scalar()`
|
|
132
122
|
|
|
133
|
-
|
|
123
|
+
Returns the value of the first property of the first result.
|
|
134
124
|
|
|
135
125
|
```ts
|
|
136
126
|
const firstId = Query.from(users).scalar();
|
|
137
127
|
```
|
|
138
128
|
|
|
139
|
-
|
|
129
|
+
You can combine it with `select()` to retrieve a specific property:
|
|
140
130
|
|
|
141
131
|
```ts
|
|
142
132
|
const firstEmail = Query.from(users)
|
|
@@ -144,17 +134,25 @@ const firstEmail = Query.from(users)
|
|
|
144
134
|
.scalar();
|
|
145
135
|
```
|
|
146
136
|
|
|
147
|
-
`false`
|
|
137
|
+
Returns `false` if no value is found.
|
|
138
|
+
|
|
139
|
+
---
|
|
148
140
|
|
|
149
141
|
#### `column()`
|
|
150
142
|
|
|
151
|
-
|
|
143
|
+
Returns the values of the first property from all results by default.
|
|
152
144
|
|
|
153
145
|
```ts
|
|
154
146
|
const ids = Query.from(users).column();
|
|
155
147
|
```
|
|
156
148
|
|
|
157
|
-
You can
|
|
149
|
+
You can specify a column:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
const emails = Query.from(users).column('email');
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Or combine it with `select()`:
|
|
158
156
|
|
|
159
157
|
```ts
|
|
160
158
|
const emails = Query.from(users)
|
|
@@ -162,9 +160,11 @@ const emails = Query.from(users)
|
|
|
162
160
|
.column();
|
|
163
161
|
```
|
|
164
162
|
|
|
163
|
+
---
|
|
164
|
+
|
|
165
165
|
#### `values()`
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
Returns all results as arrays of values.
|
|
168
168
|
|
|
169
169
|
```ts
|
|
170
170
|
const data = Query.from(users)
|
|
@@ -172,7 +172,7 @@ const data = Query.from(users)
|
|
|
172
172
|
.values();
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
Example output:
|
|
176
176
|
|
|
177
177
|
```ts
|
|
178
178
|
[
|
|
@@ -181,19 +181,21 @@ const data = Query.from(users)
|
|
|
181
181
|
]
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
+
---
|
|
185
|
+
|
|
184
186
|
### Ordering results
|
|
185
187
|
|
|
186
188
|
#### `orderBy(...columns)`
|
|
187
189
|
|
|
188
|
-
Sorts the results. You can pass multiple
|
|
190
|
+
Sorts the results. You can pass multiple columns.
|
|
189
191
|
|
|
190
192
|
```ts
|
|
191
|
-
|
|
193
|
+
.orderBy('name', 'id')
|
|
192
194
|
```
|
|
193
195
|
|
|
194
|
-
In
|
|
196
|
+
In this example, `name` has higher priority than `id`.
|
|
195
197
|
|
|
196
|
-
|
|
198
|
+
You can also sort in descending order by prefixing the column with `-`:
|
|
197
199
|
|
|
198
200
|
```ts
|
|
199
201
|
const lastId = Query.from(users)
|
|
@@ -202,24 +204,28 @@ const lastId = Query.from(users)
|
|
|
202
204
|
.scalar();
|
|
203
205
|
```
|
|
204
206
|
|
|
207
|
+
---
|
|
208
|
+
|
|
205
209
|
### Limiting results
|
|
206
210
|
|
|
207
211
|
#### `limit(limit)`
|
|
208
212
|
|
|
209
|
-
|
|
213
|
+
Limits the number of results returned.
|
|
210
214
|
|
|
211
215
|
```ts
|
|
212
|
-
|
|
216
|
+
.limit(100)
|
|
213
217
|
```
|
|
214
218
|
|
|
215
|
-
>Passing a
|
|
219
|
+
> Passing a non-integer or a negative number will throw an `InvalidArgumentError`.
|
|
220
|
+
|
|
221
|
+
---
|
|
216
222
|
|
|
217
223
|
#### `skip(numberOfRows)`
|
|
218
224
|
|
|
219
225
|
Skips the first results.
|
|
220
226
|
|
|
221
227
|
```ts
|
|
222
|
-
|
|
228
|
+
.skip(5)
|
|
223
229
|
```
|
|
224
230
|
|
|
225
231
|
Example:
|
|
@@ -227,8 +233,8 @@ Example:
|
|
|
227
233
|
```ts
|
|
228
234
|
const secondId = Query.from(users)
|
|
229
235
|
.select('id')
|
|
230
|
-
.skip(1)
|
|
236
|
+
.skip(1)
|
|
231
237
|
.scalar();
|
|
232
238
|
```
|
|
233
239
|
|
|
234
|
-
>Passing a
|
|
240
|
+
> Passing a non-integer or a negative number will throw an `InvalidArgumentError`.
|
|
@@ -0,0 +1 @@
|
|
|
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
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./invalid-argument-error"), exports);
|
|
1
|
+
export * from './invalid-argument-error';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-argument-error.d.ts","sourceRoot":"","sources":["../../../src/core/errors/invalid-argument-error.ts"],"names":[],"mappings":"AAAA,UAAU,0BAA0B;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvC,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAClC,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,EACV,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,0BAA0B;CAc9B"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidArgumentError = void 0;
|
|
4
|
-
class InvalidArgumentError extends Error {
|
|
1
|
+
export class InvalidArgumentError extends Error {
|
|
5
2
|
constructor({ method, param, argument, expected, }) {
|
|
6
3
|
super(`${String(argument)} is not a valid argument to param ${param} on ${method}(). ` +
|
|
7
4
|
`It should be ${expected}.`);
|
|
@@ -13,4 +10,4 @@ class InvalidArgumentError extends Error {
|
|
|
13
10
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
|
|
13
|
+
//# sourceMappingURL=invalid-argument-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-argument-error.js","sourceRoot":"","sources":["../../../src/core/errors/invalid-argument-error.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAM7C,YAAY,EACV,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,GACmB;QAC3B,KAAK,CACH,GAAG,MAAM,CAAC,QAAQ,CAAC,qCAAqC,KAAK,OAAO,MAAM,MAAM;YAC9E,gBAAgB,QAAQ,GAAG,CAC9B,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
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,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=attribute-validation-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-validation-function.js","sourceRoot":"","sources":["../../../src/core/types/attribute-validation-function.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { AttributeValidationFunction } from './attribute-validation-function';
|
|
2
|
-
import { QueryConditionsGroupNullable } from './query-conditions-group-nullable';
|
|
1
|
+
import type { AttributeValidationFunction } from './attribute-validation-function';
|
|
2
|
+
import type { QueryConditionsGroupNullable } from './query-conditions-group-nullable';
|
|
3
3
|
/**
|
|
4
4
|
* Condition to apply to a row column.
|
|
5
5
|
*/
|
|
6
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
|
|
@@ -0,0 +1 @@
|
|
|
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,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=column-condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-condition.js","sourceRoot":"","sources":["../../../src/core/types/column-condition.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/lib/core/types/index.js
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./attribute-validation-function"), exports);
|
|
18
|
-
__exportStar(require("./query-conditions-group"), exports);
|
|
19
|
-
__exportStar(require("./query-conditions-group-nullable"), exports);
|
|
20
|
-
__exportStar(require("./query-row-validator-initializer"), exports);
|
|
1
|
+
export * from './attribute-validation-function';
|
|
2
|
+
export * from './query-conditions-group';
|
|
3
|
+
export * from './query-conditions-group-nullable';
|
|
4
|
+
export * from './query-row-validator-initializer';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordering-column.d.ts","sourceRoot":"","sources":["../../../src/core/types/ordering-column.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACP,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IACvC,MAAM,CAAC,CAAC,CAAC,GACT,MAAM,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordering-column.js","sourceRoot":"","sources":["../../../src/core/types/ordering-column.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PropertyOnly } from '../../utils/types';
|
|
1
|
+
import type { PropertyOnly } from '../../utils/types';
|
|
2
2
|
export type QueryConditionsGroupNullable<T extends object> = {
|
|
3
3
|
[P in keyof PropertyOnly<T>]?: T[P] extends object ? QueryConditionsGroupNullable<T[P]> : T[P] | ((value: T[P]) => boolean) | null;
|
|
4
4
|
};
|
|
5
|
+
//# sourceMappingURL=query-conditions-group-nullable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-conditions-group-nullable.d.ts","sourceRoot":"","sources":["../../../src/core/types/query-conditions-group-nullable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,MAAM,IAAI;KAC1D,CAAC,IAAI,MAAM,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAC9C,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAClC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,GAAG,IAAI;CAC7C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=query-conditions-group-nullable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-conditions-group-nullable.js","sourceRoot":"","sources":["../../../src/core/types/query-conditions-group-nullable.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PropertyOnly } from '../../utils/types';
|
|
1
|
+
import type { PropertyOnly } from '../../utils/types';
|
|
2
2
|
export type QueryConditionsGroup<T extends object> = {
|
|
3
3
|
[P in keyof PropertyOnly<T>]?: T[P] extends object ? QueryConditionsGroup<T[P]> : T[P] | ((value: T[P]) => boolean);
|
|
4
4
|
};
|
|
5
|
+
//# sourceMappingURL=query-conditions-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-conditions-group.d.ts","sourceRoot":"","sources":["../../../src/core/types/query-conditions-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI;KAClD,CAAC,IAAI,MAAM,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAC9C,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC1B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC;CACtC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=query-conditions-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-conditions-group.js","sourceRoot":"","sources":["../../../src/core/types/query-conditions-group.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueryConditionsGroupNullable } from './query-conditions-group-nullable';
|
|
1
|
+
import type { QueryConditionsGroupNullable } from './query-conditions-group-nullable';
|
|
2
2
|
/**
|
|
3
3
|
* Validator configuration.
|
|
4
4
|
*/
|
|
@@ -6,3 +6,4 @@ export interface QueryRowValidatorInitializer<T extends object> {
|
|
|
6
6
|
conditionsObject: QueryConditionsGroupNullable<T>;
|
|
7
7
|
ignoreNullValues: boolean;
|
|
8
8
|
}
|
|
9
|
+
//# sourceMappingURL=query-row-validator-initializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-row-validator-initializer.d.ts","sourceRoot":"","sources":["../../../src/core/types/query-row-validator-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,4BAA4B,CAAC,CAAC,SAAS,MAAM;IAC5D,gBAAgB,EAAE,4BAA4B,CAAC,CAAC,CAAC,CAAC;IAClD,gBAAgB,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=query-row-validator-initializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-row-validator-initializer.js","sourceRoot":"","sources":["../../../src/core/types/query-row-validator-initializer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./number-validaton"), exports);
|
|
1
|
+
export * from './number-validaton';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/validation/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,36 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* @returns Decorator function.
|
|
8
|
-
*/
|
|
9
|
-
export declare function min(value: number): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Sets a maximum value to be used as argument to the given parameter.
|
|
12
|
-
*
|
|
13
|
-
* @param value Maximal value to set.
|
|
14
|
-
*
|
|
15
|
-
* @returns Decorator function.
|
|
16
|
-
*/
|
|
17
|
-
export declare function max(value: number): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Marks the given parameter as an integer.
|
|
20
|
-
*
|
|
21
|
-
* @param target Class to which the parameter belongs.
|
|
22
|
-
* @param propertyKey Method name.
|
|
23
|
-
* @param parameterIndex Parameter index.
|
|
24
|
-
*/
|
|
25
|
-
export declare function integer(target: object, propertyKey: string | symbol, parameterIndex: number): void;
|
|
26
|
-
/**
|
|
27
|
-
* Validates the property decorators `integer`, `min`, and `max`, throwing and error
|
|
28
|
-
* when the arguments passed to the parameters decorated by them are invalid.
|
|
29
|
-
*
|
|
30
|
-
* @param target Class to which the method belongs.
|
|
31
|
-
* @param propertyName Method name.
|
|
32
|
-
* @param descriptor Descriptor object.
|
|
33
|
-
*
|
|
34
|
-
* @throws {InvalidArgumentError} If an argument is invalid.
|
|
35
|
-
*/
|
|
36
|
-
export declare function validateNumbers(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>): void;
|
|
1
|
+
export declare function min(value: number): (target: object, propertyKey: string | symbol, index: number) => void;
|
|
2
|
+
export declare function max(value: number): (target: object, propertyKey: string | symbol, index: number) => void;
|
|
3
|
+
export declare function integer(target: object, propertyKey: string | symbol, index: number): void;
|
|
4
|
+
export declare function validateNumbers(target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): void;
|
|
5
|
+
//# sourceMappingURL=number-validaton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-validaton.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/decorators/number-validaton.ts"],"names":[],"mappings":"AAiCA,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,IAE7B,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,OAAO,MAAM,KACZ,IAAI,CAWR;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,IAE7B,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,OAAO,MAAM,KACZ,IAAI,CAWR;AAED,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,KAAK,EAAE,MAAM,GACZ,IAAI,CAUN;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EAEnB,UAAU,EAAE,uBAAuB,CAAC,GAAG,CAAC,GACvC,IAAI,CAgDN"}
|