@andrew_l/search-query-language 0.3.22 → 0.4.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/dist/index.d.mts +259 -268
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +475 -678
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
- package/dist/index.cjs +0 -727
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -478
- package/dist/index.d.ts +0 -478
package/dist/index.d.mts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import { Arrayable } from
|
|
2
|
-
import mongoose from
|
|
3
|
-
|
|
1
|
+
import { Arrayable } from "@andrew_l/toolkit";
|
|
2
|
+
import mongoose from "mongoose";
|
|
4
3
|
interface TokenTypeOptions {
|
|
5
|
-
|
|
4
|
+
keyword?: string;
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
8
7
|
* @group Utils
|
|
9
8
|
*/
|
|
10
9
|
declare class TokenType {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly keyword: string | undefined;
|
|
12
|
+
constructor(label: string, options?: TokenTypeOptions);
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
/**
|
|
17
15
|
* Node types
|
|
18
16
|
* @group Constants
|
|
19
17
|
*/
|
|
20
18
|
declare const NODE: Readonly<{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
PROGRAM: "program";
|
|
20
|
+
IDENTIFIER: "identifier";
|
|
21
|
+
LITERAL: "literal";
|
|
22
|
+
LOGICAL_EXPRESSION: "logical-expression";
|
|
23
|
+
BINARY_EXPRESSION: "binary-expression";
|
|
26
24
|
}>;
|
|
27
25
|
/**
|
|
28
26
|
* Keyword tokens.
|
|
@@ -34,148 +32,145 @@ declare const KEYWORDS: Record<string, TokenType>;
|
|
|
34
32
|
* @group Constants
|
|
35
33
|
*/
|
|
36
34
|
declare const TOKEN: Readonly<{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Start of File token.
|
|
37
|
+
*/
|
|
38
|
+
readonly SOF: TokenType;
|
|
39
|
+
/**
|
|
40
|
+
* End of File token.
|
|
41
|
+
*/
|
|
42
|
+
readonly EOF: TokenType;
|
|
43
|
+
/**
|
|
44
|
+
* Number token.
|
|
45
|
+
*/
|
|
46
|
+
readonly NUM: TokenType;
|
|
47
|
+
/**
|
|
48
|
+
* String token.
|
|
49
|
+
*/
|
|
50
|
+
readonly STRING: TokenType;
|
|
51
|
+
/**
|
|
52
|
+
* Identifier token.
|
|
53
|
+
*/
|
|
54
|
+
readonly NAME: TokenType;
|
|
55
|
+
/**
|
|
56
|
+
* Parenthesis token.
|
|
57
|
+
*/
|
|
58
|
+
readonly PAREN_L: TokenType;
|
|
59
|
+
/**
|
|
60
|
+
* Parenthesis token.
|
|
61
|
+
*/
|
|
62
|
+
readonly PAREN_R: TokenType;
|
|
63
|
+
/**
|
|
64
|
+
* Logical operator token.
|
|
65
|
+
*/
|
|
66
|
+
readonly LOGICAL_OR: TokenType;
|
|
67
|
+
/**
|
|
68
|
+
* Logical operator token.
|
|
69
|
+
*/
|
|
70
|
+
readonly LOGICAL_AND: TokenType;
|
|
71
|
+
/**
|
|
72
|
+
* Equality operator token.
|
|
73
|
+
*/
|
|
74
|
+
readonly EQUALITY: TokenType;
|
|
75
|
+
/**
|
|
76
|
+
* Relational operator token.
|
|
77
|
+
*/
|
|
78
|
+
readonly RELATIONAL: TokenType;
|
|
79
|
+
/**
|
|
80
|
+
* Minus operator token.
|
|
81
|
+
*/
|
|
82
|
+
readonly MINUS: TokenType;
|
|
83
|
+
/**
|
|
84
|
+
* Null literal token.
|
|
85
|
+
*/
|
|
86
|
+
readonly NULL: TokenType;
|
|
87
|
+
/**
|
|
88
|
+
* True literal tokens.
|
|
89
|
+
*/
|
|
90
|
+
readonly TRUE: TokenType;
|
|
91
|
+
/**
|
|
92
|
+
* False literal tokens.
|
|
93
|
+
*/
|
|
94
|
+
readonly FALSE: TokenType;
|
|
97
95
|
}>;
|
|
98
|
-
|
|
99
96
|
interface TokenOptions {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
type: TokenType;
|
|
98
|
+
value: unknown;
|
|
99
|
+
start: number;
|
|
100
|
+
end: number;
|
|
104
101
|
}
|
|
105
102
|
/**
|
|
106
103
|
* @group Utils
|
|
107
104
|
*/
|
|
108
105
|
declare class Token {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
readonly type: TokenType;
|
|
107
|
+
readonly value: unknown;
|
|
108
|
+
readonly start: number;
|
|
109
|
+
readonly end: number;
|
|
110
|
+
constructor(p: TokenOptions);
|
|
114
111
|
}
|
|
115
|
-
|
|
116
112
|
/**
|
|
117
113
|
* @group Utils
|
|
118
114
|
*/
|
|
119
115
|
declare class Tokenizer implements Iterable<Token> {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
116
|
+
protected input: string;
|
|
117
|
+
protected pos: number;
|
|
118
|
+
protected length: number;
|
|
119
|
+
protected state: TokenOptions;
|
|
120
|
+
protected prev: TokenOptions;
|
|
121
|
+
constructor(input: string);
|
|
122
|
+
[Symbol.iterator](): {
|
|
123
|
+
next: () => {
|
|
124
|
+
done: boolean;
|
|
125
|
+
value: Token;
|
|
131
126
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Get the next token.
|
|
130
|
+
*/
|
|
131
|
+
getToken(): Token;
|
|
132
|
+
protected nextToken(): void;
|
|
133
|
+
protected skipSpace(): void;
|
|
134
|
+
protected finishToken(type: TokenType, value?: unknown): void;
|
|
135
|
+
protected finishOp(type: TokenType, size: number): void;
|
|
136
|
+
protected readToken(code: number): void;
|
|
137
|
+
protected getTokenFromCode(code: number): void;
|
|
138
|
+
protected charCodeAtPos(): number;
|
|
139
|
+
protected readEquality(code: number): void;
|
|
140
|
+
protected readLtGt(): void;
|
|
141
|
+
protected readInt(): number | null;
|
|
142
|
+
protected raise(pos: number, message: string): never;
|
|
143
|
+
protected readString(): void;
|
|
144
|
+
protected readWord(): void;
|
|
145
|
+
protected readEscapedChar(): string;
|
|
146
|
+
protected readNumber(): void;
|
|
151
147
|
}
|
|
152
|
-
|
|
153
148
|
/**
|
|
154
149
|
* @group Types
|
|
155
150
|
*/
|
|
156
151
|
interface Node {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Start positions of the node in the source code.
|
|
154
|
+
*/
|
|
155
|
+
start: number;
|
|
156
|
+
/**
|
|
157
|
+
* End positions of the node in the source code.
|
|
158
|
+
*/
|
|
159
|
+
end: number;
|
|
160
|
+
/**
|
|
161
|
+
* Type of the node.
|
|
162
|
+
*/
|
|
163
|
+
type: string;
|
|
169
164
|
}
|
|
170
165
|
/**
|
|
171
166
|
* @group Types
|
|
172
167
|
*/
|
|
173
168
|
type NodeMap = {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
[NODE.PROGRAM]: NodeProgram;
|
|
170
|
+
[NODE.LITERAL]: NodeLiteral;
|
|
171
|
+
[NODE.BINARY_EXPRESSION]: NodeBinaryExpression;
|
|
172
|
+
[NODE.LOGICAL_EXPRESSION]: NodeLogicalExpression;
|
|
173
|
+
[NODE.IDENTIFIER]: NodeIdentifier;
|
|
179
174
|
};
|
|
180
175
|
/**
|
|
181
176
|
* The node type.
|
|
@@ -192,53 +187,53 @@ type NodeExpression = NodeBinaryExpression | NodeLogicalExpression;
|
|
|
192
187
|
* @group Types
|
|
193
188
|
*/
|
|
194
189
|
interface NodeProgram extends Node {
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
type: typeof NODE.PROGRAM;
|
|
191
|
+
body: NodeExpression[];
|
|
197
192
|
}
|
|
198
193
|
/**
|
|
199
194
|
* Literal node of the AST.
|
|
200
195
|
* @group Types
|
|
201
196
|
*/
|
|
202
197
|
interface NodeLiteral extends Node {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
198
|
+
type: typeof NODE.LITERAL;
|
|
199
|
+
/**
|
|
200
|
+
* Value of the literal.
|
|
201
|
+
*/
|
|
202
|
+
value: string | boolean | null | number;
|
|
203
|
+
/**
|
|
204
|
+
* Raw value of the literal.
|
|
205
|
+
*/
|
|
206
|
+
raw?: string;
|
|
212
207
|
}
|
|
213
208
|
/**
|
|
214
209
|
* Identifier node of the AST.
|
|
215
210
|
* @group Types
|
|
216
211
|
*/
|
|
217
212
|
interface NodeIdentifier extends Node {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
213
|
+
type: typeof NODE.IDENTIFIER;
|
|
214
|
+
/**
|
|
215
|
+
* Name of the identifier.
|
|
216
|
+
*/
|
|
217
|
+
name: string;
|
|
223
218
|
}
|
|
224
219
|
/**
|
|
225
220
|
* Binary expression node of the AST.
|
|
226
221
|
* @group Types
|
|
227
222
|
*/
|
|
228
223
|
interface NodeBinaryExpression extends Node {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
224
|
+
type: typeof NODE.BINARY_EXPRESSION;
|
|
225
|
+
/**
|
|
226
|
+
* Operator of the binary expression.
|
|
227
|
+
*/
|
|
228
|
+
operator: BinaryOperator;
|
|
229
|
+
/**
|
|
230
|
+
* Left operand of the binary expression.
|
|
231
|
+
*/
|
|
232
|
+
left: NodeIdentifier;
|
|
233
|
+
/**
|
|
234
|
+
* Right operand of the binary expression.
|
|
235
|
+
*/
|
|
236
|
+
right: NodeLiteral;
|
|
242
237
|
}
|
|
243
238
|
/**
|
|
244
239
|
* Binary operator.
|
|
@@ -253,47 +248,45 @@ type BinaryOperator = '=' | '!=' | '<' | '<=' | '>' | '>=';
|
|
|
253
248
|
* @group Types
|
|
254
249
|
*/
|
|
255
250
|
interface NodeLogicalExpression extends Node {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
251
|
+
type: typeof NODE.LOGICAL_EXPRESSION;
|
|
252
|
+
/**
|
|
253
|
+
* Operator of the logical expression.
|
|
254
|
+
*/
|
|
255
|
+
operator: LogicalOperator;
|
|
256
|
+
/**
|
|
257
|
+
* Left operand of the logical expression.
|
|
258
|
+
*/
|
|
259
|
+
left: NodeExpression;
|
|
260
|
+
/**
|
|
261
|
+
* Right operand of the logical expression.
|
|
262
|
+
*/
|
|
263
|
+
right: NodeExpression;
|
|
269
264
|
}
|
|
270
265
|
/**
|
|
271
266
|
* Logical operator.
|
|
272
267
|
* @group Types
|
|
273
268
|
*/
|
|
274
269
|
type LogicalOperator = 'OR' | 'AND';
|
|
275
|
-
|
|
276
270
|
/**
|
|
277
271
|
* Parse an expression class.
|
|
278
272
|
*
|
|
279
273
|
* @group Utils
|
|
280
274
|
*/
|
|
281
275
|
declare class Expression extends Tokenizer {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
276
|
+
constructor(input: string);
|
|
277
|
+
/**
|
|
278
|
+
* Parse input into a program AST.
|
|
279
|
+
*/
|
|
280
|
+
parse(): NodeProgram;
|
|
281
|
+
protected finishNode<T extends Node>(node: T): T;
|
|
282
|
+
protected parseTopLevel(node: NodeProgram): NodeProgram;
|
|
283
|
+
protected parseExpression(): NodeExpression;
|
|
284
|
+
protected parseExprOp(left: NodeExpression | NodeIdentifier): NodeBinaryExpression | NodeLogicalExpression;
|
|
285
|
+
protected maybeLiteral(): NodeLiteral | null;
|
|
286
|
+
protected maybeIdentifier(): NodeIdentifier | null;
|
|
287
|
+
protected parseExprAtom(): NodeIdentifier | NodeLiteral;
|
|
288
|
+
protected startNode<T extends NodeType>(type: T): NodeMap[T];
|
|
295
289
|
}
|
|
296
|
-
|
|
297
290
|
/**
|
|
298
291
|
* Parses a query string into a NodeProgram representation.
|
|
299
292
|
*
|
|
@@ -318,42 +311,41 @@ declare class Expression extends Tokenizer {
|
|
|
318
311
|
* @group Main
|
|
319
312
|
*/
|
|
320
313
|
declare function parseQuery(value: string): NodeProgram;
|
|
321
|
-
|
|
322
314
|
type ParseToMongoTransformFn = (value: unknown, key: string) => unknown;
|
|
323
315
|
interface ParseToMongoOptions {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
316
|
+
/**
|
|
317
|
+
* Determines whether empty search queries are allowed.
|
|
318
|
+
* If `true`, an empty query will return an unfiltered result.
|
|
319
|
+
* If `false`, an empty query will be rejected.
|
|
320
|
+
*
|
|
321
|
+
* @default false
|
|
322
|
+
*/
|
|
323
|
+
allowEmpty?: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* A list of allowed keys that can be used in the search query.
|
|
326
|
+
* If provided, any query using keys outside this list will be rejected.
|
|
327
|
+
*/
|
|
328
|
+
allowedKeys?: string[];
|
|
329
|
+
/**
|
|
330
|
+
* Max of query ops combination.
|
|
331
|
+
* @default Infinity
|
|
332
|
+
*/
|
|
333
|
+
maxOps?: number;
|
|
334
|
+
/**
|
|
335
|
+
* A transformation function or a mapping of transformation functions
|
|
336
|
+
* to modify query values before they are converted into a MongoDB query.
|
|
337
|
+
*
|
|
338
|
+
* - If an array is provided, all functions in the array will be applied.
|
|
339
|
+
* - If a record object is provided, transformations will be applied
|
|
340
|
+
* based on the corresponding field key.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* {
|
|
344
|
+
'age': MONGO_TRANSFORM.NUMBER
|
|
345
|
+
'customer._id': [MONGO_TRANSFORM.OBJECT_ID, MONGO_TRANSFORM.NOT_NULLABLE]
|
|
354
346
|
}
|
|
355
|
-
|
|
356
|
-
|
|
347
|
+
*/
|
|
348
|
+
transform?: Readonly<Arrayable<ParseToMongoTransformFn>> | Readonly<Record<string, Readonly<Arrayable<ParseToMongoTransformFn>>>>;
|
|
357
349
|
}
|
|
358
350
|
/**
|
|
359
351
|
* Parses a query string and converts it into a MongoDB-compatible query object.
|
|
@@ -383,55 +375,54 @@ interface ParseToMongoOptions {
|
|
|
383
375
|
* @group Main
|
|
384
376
|
*/
|
|
385
377
|
declare function parseToMongo(input: string, options?: ParseToMongoOptions): Record<string, any>;
|
|
386
|
-
|
|
387
378
|
/**
|
|
388
379
|
* Utility transform functions
|
|
389
380
|
* @group Constants
|
|
390
381
|
*/
|
|
391
382
|
declare const MONGO_TRANSFORM: Readonly<{
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
383
|
+
/**
|
|
384
|
+
* Ensures the value is not null.
|
|
385
|
+
* Throws an error if the value is null.
|
|
386
|
+
*
|
|
387
|
+
* @throws {Error} If the value is null.
|
|
388
|
+
*/
|
|
389
|
+
readonly NOT_NULLABLE: ParseToMongoTransformFn;
|
|
390
|
+
/**
|
|
391
|
+
* Validates that the value is a number.
|
|
392
|
+
* If the value is `null`, it returns `null` without throwing an error.
|
|
393
|
+
*
|
|
394
|
+
* @throws {Error} If the value is not a valid number.
|
|
395
|
+
*/
|
|
396
|
+
readonly NUMBER: ParseToMongoTransformFn;
|
|
397
|
+
/**
|
|
398
|
+
* Validates that the value is a string.
|
|
399
|
+
* If the value is `null`, it returns `null` without throwing an error.
|
|
400
|
+
*
|
|
401
|
+
* @throws {Error} If the value is not a valid string.
|
|
402
|
+
*/
|
|
403
|
+
readonly STRING: ParseToMongoTransformFn;
|
|
404
|
+
/**
|
|
405
|
+
* Validates that the value is a boolean.
|
|
406
|
+
* If the value is `null`, it returns `null` without throwing an error.
|
|
407
|
+
*
|
|
408
|
+
* @throws {Error} If the value is not a valid boolean.
|
|
409
|
+
*/
|
|
410
|
+
readonly BOOLEAN: ParseToMongoTransformFn;
|
|
411
|
+
/**
|
|
412
|
+
* Validates and converts the value to a MongoDB ObjectId.
|
|
413
|
+
* If the value is `null`, it returns `null` without throwing an error.
|
|
414
|
+
*
|
|
415
|
+
* @throws {Error} If the value is not a valid ObjectId.
|
|
416
|
+
*/
|
|
417
|
+
readonly OBJECT_ID: ParseToMongoTransformFn;
|
|
418
|
+
/**
|
|
419
|
+
* Validates and converts the value to a Date.
|
|
420
|
+
* Supports string and number inputs for conversion.
|
|
421
|
+
* If the value is `null`, it returns `null` without throwing an error.
|
|
422
|
+
*
|
|
423
|
+
* @throws {Error} If the value is not a valid date.
|
|
424
|
+
*/
|
|
425
|
+
readonly DATE: ParseToMongoTransformFn;
|
|
435
426
|
}>;
|
|
436
427
|
type MongooseSchema = mongoose.Schema;
|
|
437
428
|
type MongooseModel = mongoose.Model<any>;
|
|
@@ -474,5 +465,5 @@ type MongooseModel = mongoose.Model<any>;
|
|
|
474
465
|
* @group Main
|
|
475
466
|
*/
|
|
476
467
|
declare function parseToMongoose(reference: MongooseSchema | MongooseModel, input: string, options?: ParseToMongoOptions): Record<string, any>;
|
|
477
|
-
|
|
478
|
-
|
|
468
|
+
export { BinaryOperator, Expression, KEYWORDS, LogicalOperator, MONGO_TRANSFORM, NODE, Node, NodeBinaryExpression, NodeExpression, NodeIdentifier, NodeLiteral, NodeLogicalExpression, NodeMap, NodeProgram, NodeType, type ParseToMongoOptions, type ParseToMongoTransformFn, TOKEN, Tokenizer, parseQuery, parseToMongo, parseToMongoose };
|
|
469
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["keyword","label","constructor","TokenTypeOptions","options","Readonly","PROGRAM","IDENTIFIER","LITERAL","LOGICAL_EXPRESSION","BINARY_EXPRESSION","Record","TokenType","SOF","EOF","NUM","STRING","NAME","PAREN_L","PAREN_R","LOGICAL_OR","LOGICAL_AND","EQUALITY","RELATIONAL","MINUS","NULL","TRUE","FALSE","type","TokenType","value","start","end","constructor","TokenOptions","p","Iterable","Token","input","pos","length","state","TokenOptions","prev","constructor","Symbol","iterator","next","done","value","getToken","nextToken","skipSpace","finishToken","TokenType","type","finishOp","size","readToken","code","getTokenFromCode","charCodeAtPos","readEquality","readLtGt","readInt","raise","message","readString","readWord","readEscapedChar","readNumber","start","end","type","NODE","PROGRAM","NodeProgram","LITERAL","NodeLiteral","BINARY_EXPRESSION","NodeBinaryExpression","LOGICAL_EXPRESSION","NodeLogicalExpression","IDENTIFIER","NodeIdentifier","Node","body","NodeExpression","value","raw","name","operator","BinaryOperator","left","right","LogicalOperator","Tokenizer","constructor","input","parse","NodeProgram","finishNode","T","Node","node","parseTopLevel","parseExpression","NodeExpression","parseExprOp","NodeIdentifier","left","NodeBinaryExpression","NodeLogicalExpression","maybeLiteral","NodeLiteral","maybeIdentifier","parseExprAtom","startNode","NodeType","type","NodeMap","value","NodeProgram","value","key","allowEmpty","allowedKeys","maxOps","transform","Readonly","Arrayable","ParseToMongoTransformFn","Record","Set","input","ParseToMongoOptions","options","NodeExpression","node","ParseToMongoOptionsInternal","OpsResource","opsResource","max","uses","constructor","assert","Readonly","NOT_NULLABLE","ParseToMongoTransformFn","NUMBER","STRING","BOOLEAN","OBJECT_ID","DATE","mongoose","Schema","Model","MongooseSchema","MongooseModel","reference","input","ParseToMongoOptions","options","Record"],"sources":["../src/TokenType.d.ts","../src/constants.d.ts","../src/Token.d.ts","../src/Tokenizer.d.ts","../src/types.d.ts","../src/Expression.d.ts","../src/parseQuery.d.ts","../src/parseToMongo.d.ts","../src/parseToMongoose.d.ts"],"mappings":";;UAAiB,gBAAA;EACbA,OAAO;AAAA;AADX;;;AAAA,cAMqB,SAAA;EAAA,SACRC,KAAAA;EAAAA,SACAD,OAAAA;EACTE,WAAAA,CAAYD,KAAAA,UAAeG,OAAAA,GAAU,gBAAgB;AAAA;;;AATzD;;cCKqB,IAAA,EAAM,QAAQ;EAC/BE,OAAAA;EACAC,UAAAA;EACAC,OAAAA;EACAC,kBAAAA;EACAC,iBAAAA;AAAAA;;;;;cAMiB,QAAA,EAAU,MAAM,SAAS,SAAA;;;ADPW;;cCYpC,KAAA,EAAO,QAAA;EAV1B;;;EAAA,SAcWG,GAAAA,EAAK,SAAA;EAnBdP;;;EAAAA,SAuBSQ,GAAAA,EAAK,SAAA;EAnBdJ;;AAAiB;EAAjBA,SAuBSK,GAAAA,EAAK,SAAA;EAjBsC;;;EAAA,SAqB3CC,MAAAA,EAAQ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