@malloydata/malloy-filter 0.0.237-dev250224215546 → 0.0.237-dev250225144145

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.
Files changed (58) hide show
  1. package/SAMPLES.md +336 -114
  2. package/SERIALIZE_SAMPLES.md +268 -64
  3. package/dist/a_simple_parser.js +6 -0
  4. package/dist/a_simple_parser.js.map +1 -1
  5. package/dist/base_parser.js +6 -0
  6. package/dist/base_parser.js.map +1 -1
  7. package/dist/boolean_parser.js +28 -13
  8. package/dist/boolean_parser.js.map +1 -1
  9. package/dist/boolean_serializer.js +12 -6
  10. package/dist/boolean_serializer.js.map +1 -1
  11. package/dist/clause_types.d.ts +20 -15
  12. package/dist/clause_types.js +6 -0
  13. package/dist/clause_types.js.map +1 -1
  14. package/dist/date_parser.js +135 -116
  15. package/dist/date_parser.js.map +1 -1
  16. package/dist/date_serializer.js +26 -20
  17. package/dist/date_serializer.js.map +1 -1
  18. package/dist/date_types.d.ts +21 -21
  19. package/dist/date_types.js +6 -0
  20. package/dist/date_types.js.map +1 -1
  21. package/dist/generate_samples.js +32 -25
  22. package/dist/generate_samples.js.map +1 -1
  23. package/dist/index.js +6 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/number_parser.js +43 -25
  26. package/dist/number_parser.js.map +1 -1
  27. package/dist/number_serializer.js +10 -4
  28. package/dist/number_serializer.js.map +1 -1
  29. package/dist/string_parser.d.ts +0 -1
  30. package/dist/string_parser.js +47 -79
  31. package/dist/string_parser.js.map +1 -1
  32. package/dist/string_serializer.d.ts +1 -0
  33. package/dist/string_serializer.js +49 -33
  34. package/dist/string_serializer.js.map +1 -1
  35. package/dist/token_types.js +6 -0
  36. package/dist/token_types.js.map +1 -1
  37. package/dist/tokenizer.js +9 -3
  38. package/dist/tokenizer.js.map +1 -1
  39. package/dist/tokenizer.spec.js +13 -7
  40. package/dist/tokenizer.spec.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/a_simple_parser.ts +7 -0
  43. package/src/base_parser.ts +7 -0
  44. package/src/boolean_parser.ts +30 -18
  45. package/src/boolean_serializer.ts +13 -6
  46. package/src/clause_types.ts +36 -31
  47. package/src/date_parser.ts +136 -118
  48. package/src/date_serializer.ts +27 -20
  49. package/src/date_types.ts +42 -34
  50. package/src/generate_samples.ts +33 -25
  51. package/src/index.ts +7 -0
  52. package/src/number_parser.ts +45 -26
  53. package/src/number_serializer.ts +11 -4
  54. package/src/string_parser.ts +51 -79
  55. package/src/string_serializer.ts +65 -39
  56. package/src/token_types.ts +7 -0
  57. package/src/tokenizer.spec.ts +14 -7
  58. package/src/tokenizer.ts +10 -3
package/SAMPLES.md CHANGED
@@ -14,7 +14,16 @@ Input: !=5
14
14
  Output: { operator: '!=', values: [ 5 ] }
15
15
 
16
16
  Input: 1, 3, 5, null
17
- Output: { operator: '=', values: [ 1, 3, 5 ] } { operator: 'NULL' }
17
+ Output: { operator: '=', values: [ 1, 3, 5 ] } { operator: 'null' }
18
+
19
+ Input: 1, 3, , 5,
20
+ Output: { operator: '=', values: [ 1, 3, 5 ] }
21
+ Logs: {
22
+ severity: 'warn',
23
+ message: 'Empty clause',
24
+ startIndex: 6,
25
+ endIndex: 7
26
+ }
18
27
 
19
28
  Input: <1, >=100
20
29
  Output: { operator: '<', values: [ 1 ] } { operator: '>=', values: [ 100 ] }
@@ -26,10 +35,10 @@ Input: <= 10
26
35
  Output: { operator: '<=', values: [ 10 ] }
27
36
 
28
37
  Input: NULL
29
- Output: { operator: 'NULL' }
38
+ Output: { operator: 'null' }
30
39
 
31
40
  Input: -NULL
32
- Output: { operator: 'NOTNULL' }
41
+ Output: { operator: 'not_null' }
33
42
 
34
43
  Input: (1, 7)
35
44
  Output: {
@@ -89,7 +98,7 @@ Output: {
89
98
  startValue: 0,
90
99
  endOperator: '<=',
91
100
  endValue: 10
92
- } { operator: '=', values: [ 20 ] } { operator: 'NULL' } {
101
+ } { operator: '=', values: [ 20 ] } { operator: 'null' } {
93
102
  operator: 'range',
94
103
  startOperator: '>',
95
104
  startValue: 72,
@@ -98,15 +107,79 @@ Output: {
98
107
  }
99
108
 
100
109
  Input: , notanumber,, "null", apple pear orange, nulle, nnull, >=,
101
- Errors: { message: 'Invalid expression', startIndex: 2, endIndex: 12 } { message: 'Invalid expression', startIndex: 15, endIndex: 21 } { message: 'Invalid expression', startIndex: 23, endIndex: 28 } { message: 'Invalid expression', startIndex: 29, endIndex: 33 } { message: 'Invalid expression', startIndex: 34, endIndex: 40 } { message: 'Invalid expression', startIndex: 42, endIndex: 47 } { message: 'Invalid expression', startIndex: 49, endIndex: 54 } { message: 'Invalid expression', startIndex: 56, endIndex: 58 }
110
+ Logs: {
111
+ severity: 'error',
112
+ message: 'Invalid expression: notanumber',
113
+ startIndex: 2,
114
+ endIndex: 12
115
+ } {
116
+ severity: 'warn',
117
+ message: 'Empty clause',
118
+ startIndex: 13,
119
+ endIndex: 14
120
+ } {
121
+ severity: 'error',
122
+ message: 'Invalid expression: "null"',
123
+ startIndex: 15,
124
+ endIndex: 21
125
+ } {
126
+ severity: 'error',
127
+ message: 'Invalid expression: apple',
128
+ startIndex: 23,
129
+ endIndex: 28
130
+ } {
131
+ severity: 'error',
132
+ message: 'Invalid expression: pear',
133
+ startIndex: 29,
134
+ endIndex: 33
135
+ } {
136
+ severity: 'error',
137
+ message: 'Invalid expression: orange',
138
+ startIndex: 34,
139
+ endIndex: 40
140
+ } {
141
+ severity: 'error',
142
+ message: 'Invalid expression: nulle',
143
+ startIndex: 42,
144
+ endIndex: 47
145
+ } {
146
+ severity: 'error',
147
+ message: 'Invalid expression: nnull',
148
+ startIndex: 49,
149
+ endIndex: 54
150
+ } {
151
+ severity: 'error',
152
+ message: 'Invalid expression: >=',
153
+ startIndex: 56,
154
+ endIndex: 58
155
+ }
102
156
 
103
157
  Input: [cat, 100], <cat
104
- Errors: { message: 'Invalid number', startIndex: 1, endIndex: 4 } { message: 'Invalid expression', startIndex: 12, endIndex: 13 } { message: 'Invalid expression', startIndex: 13, endIndex: 16 }
158
+ Logs: {
159
+ severity: 'error',
160
+ message: 'Invalid number',
161
+ startIndex: 1,
162
+ endIndex: 4
163
+ } {
164
+ severity: 'error',
165
+ message: 'Invalid expression: <',
166
+ startIndex: 12,
167
+ endIndex: 13
168
+ } {
169
+ severity: 'error',
170
+ message: 'Invalid expression: cat',
171
+ startIndex: 13,
172
+ endIndex: 16
173
+ }
105
174
 
106
175
  Input: -5.5 to 10
107
176
  Output: { operator: '=', values: [ -5.5, 10 ] }
108
- Errors: { message: 'Invalid expression', startIndex: 5, endIndex: 7 }
109
-
177
+ Logs: {
178
+ severity: 'error',
179
+ message: 'Invalid expression: to',
180
+ startIndex: 5,
181
+ endIndex: 7
182
+ }
110
183
  ```
111
184
 
112
185
  -------------------------------------------------------------------------
@@ -121,64 +194,84 @@ Output: { operator: '!=', values: [ 'CAT', 'DOG', 'mouse' ] }
121
194
 
122
195
  Input: CAT,-"DOG",m o u s e
123
196
  Output: { operator: '=', values: [ 'CAT' ] } { operator: '!=', values: [ '"DOG"' ] } { operator: '=', values: [ 'm o u s e' ] }
124
- Quotes: DOUBLE
125
197
 
126
198
  Input: -CAT,-DOG,mouse, bird, zebra, -horse, -goat
127
199
  Output: { operator: '!=', values: [ 'CAT', 'DOG' ] } { operator: '=', values: [ 'mouse', 'bird', 'zebra' ] } { operator: '!=', values: [ 'horse', 'goat' ] }
128
200
 
129
201
  Input: Missing ,NULL
130
- Output: { operator: '=', values: [ 'Missing' ] } { operator: 'NULL' }
202
+ Output: { operator: '=', values: [ 'Missing' ] } { operator: 'null' }
131
203
 
132
204
  Input: CAT%, D%OG, %ous%, %ira_f%, %_oat,
133
- Output: { operator: 'starts', values: [ 'CAT' ] } { operator: '~', values: [ 'D%OG' ] } { operator: 'contains', values: [ 'ous' ] } { operator: '~', values: [ '%ira_f%', '%_oat' ] }
134
- Errors: { message: 'Invalid expression', startIndex: 34, endIndex: 35 }
205
+ Output: { operator: 'starts', values: [ 'CAT' ] } { operator: '~', escaped_values: [ 'D%OG' ] } { operator: 'contains', values: [ 'ous' ] } { operator: '~', escaped_values: [ '%ira_f%', '%_oat' ] }
206
+ Logs: {
207
+ severity: 'warn',
208
+ message: 'Empty clause',
209
+ startIndex: 34,
210
+ endIndex: 35
211
+ }
135
212
 
136
213
  Input: -CAT%,-D%OG,-%mouse,-%zebra%
137
- Output: { operator: 'notStarts', values: [ 'CAT' ] } { operator: '!~', values: [ 'D%OG' ] } { operator: 'notEnds', values: [ 'mouse' ] } { operator: 'notContains', values: [ 'zebra' ] }
214
+ Output: { operator: 'not_starts', values: [ 'CAT' ] } { operator: '!~', escaped_values: [ 'D%OG' ] } { operator: 'not_ends', values: [ 'mouse' ] } { operator: 'not_contains', values: [ 'zebra' ] }
138
215
 
139
216
  Input: CAT%,-CATALOG
140
217
  Output: { operator: 'starts', values: [ 'CAT' ] } { operator: '!=', values: [ 'CATALOG' ] }
141
218
 
142
219
  Input: %,_,%%,%a%
143
- Output: { operator: '~', values: [ '%', '_', '%%' ] } { operator: 'contains', values: [ 'a' ] }
220
+ Output: { operator: '~', escaped_values: [ '%', '_', '%%' ] } { operator: 'contains', values: [ 'a' ] }
144
221
 
145
222
  Input: %\_X
146
223
  Output: { operator: 'ends', values: [ '_X' ] }
147
224
 
148
225
  Input: _\_X
149
- Output: { operator: '~', values: [ '_\\_X' ] }
226
+ Output: { operator: '~', escaped_values: [ '_\\_X' ] }
150
227
 
151
228
  Input: _CAT,D_G,mouse_
152
- Output: { operator: '~', values: [ '_CAT', 'D_G', 'mouse_' ] }
229
+ Output: { operator: '~', escaped_values: [ '_CAT', 'D_G', 'mouse_' ] }
153
230
 
154
231
  Input: \_CAT,D\%G,\mouse
155
232
  Output: { operator: '=', values: [ '_CAT', 'D%G', 'mouse' ] }
156
233
 
157
234
  Input: CAT,-NULL
158
- Output: { operator: '=', values: [ 'CAT' ] } { operator: 'NOTNULL' }
235
+ Output: { operator: '=', values: [ 'CAT' ] } { operator: 'not_null' }
159
236
 
160
237
  Input: CAT,-"NULL"
161
238
  Output: { operator: '=', values: [ 'CAT' ] } { operator: '!=', values: [ '"NULL"' ] }
162
- Quotes: DOUBLE
163
239
 
164
240
  Input: CAT,NULL
165
- Output: { operator: '=', values: [ 'CAT' ] } { operator: 'NULL' }
241
+ Output: { operator: '=', values: [ 'CAT' ] } { operator: 'null' }
242
+
243
+ Input: CAT,,
244
+ Output: { operator: '=', values: [ 'CAT' ] }
245
+ Logs: {
246
+ severity: 'warn',
247
+ message: 'Empty clause',
248
+ startIndex: 4,
249
+ endIndex: 5
250
+ }
251
+
252
+ Input: CAT, , DOG
253
+ Output: { operator: '=', values: [ 'CAT', 'DOG' ] }
254
+ Logs: {
255
+ severity: 'warn',
256
+ message: 'Empty clause',
257
+ startIndex: 4,
258
+ endIndex: 5
259
+ }
166
260
 
167
261
  Input: EMPTY
168
- Output: { operator: 'EMPTY' }
262
+ Output: { operator: 'empty' }
169
263
 
170
264
  Input: -EMPTY
171
- Output: { operator: 'NOTEMPTY' }
265
+ Output: { operator: 'not_empty' }
172
266
 
173
267
  Input: CAT,-EMPTY
174
- Output: { operator: '=', values: [ 'CAT' ] } { operator: 'NOTEMPTY' }
268
+ Output: { operator: '=', values: [ 'CAT' ] } { operator: 'not_empty' }
175
269
 
176
270
  Input: "CAT,DOG',mo`use,zeb'''ra,g"""t,g\"ir\`af\'e
177
271
  Output: {
178
272
  operator: '=',
179
273
  values: [ '"CAT', "DOG'", 'mo`use', "zeb'''ra", 'g"""t', 'g"ir`af\'e' ]
180
274
  }
181
- Quotes: DOUBLE SINGLE BACKTICK TRIPLESINGLE TRIPLEDOUBLE ESCAPEDDOUBLE ESCAPEDBACKTICK ESCAPEDSINGLE
182
275
 
183
276
  Input: CAT\,DOG
184
277
  Output: { operator: '=', values: [ 'CAT,DOG' ] }
@@ -188,13 +281,18 @@ Output: { operator: '=', values: [ 'CAT', 'DOG', '-', '-' ] }
188
281
 
189
282
  Input: --CAT,DOG,\
190
283
  Output: { operator: '!=', values: [ '-CAT' ] } { operator: '=', values: [ 'DOG' ] }
191
- Errors: { message: 'Invalid expression', startIndex: 10, endIndex: 11 }
284
+ Logs: {
285
+ severity: 'warn',
286
+ message: 'Empty clause',
287
+ startIndex: 10,
288
+ endIndex: 11
289
+ }
192
290
 
193
291
  Input: CAT\ DOG
194
292
  Output: { operator: '=', values: [ 'CAT DOG' ] }
195
293
 
196
294
  Input: _\_CAT
197
- Output: { operator: '~', values: [ '_\\_CAT' ] }
295
+ Output: { operator: '~', escaped_values: [ '_\\_CAT' ] }
198
296
 
199
297
  Input: \NULL
200
298
  Output: { operator: '=', values: [ 'NULL' ] }
@@ -213,10 +311,9 @@ Output: {
213
311
  operator: '=',
214
312
  values: [ 'hello world', 'foo="bar baz"', 'qux=quux' ]
215
313
  }
216
- Quotes: DOUBLE
217
314
 
218
315
  Input: one ,Null , Empty,E M P T Y Y,EEmpty, emptIEs
219
- Output: { operator: '=', values: [ 'one' ] } { operator: 'NULL' } { operator: 'EMPTY' } { operator: '=', values: [ 'E M P T Y Y', 'EEmpty', 'emptIEs' ] }
316
+ Output: { operator: '=', values: [ 'one' ] } { operator: 'null' } { operator: 'empty' } { operator: '=', values: [ 'E M P T Y Y', 'EEmpty', 'emptIEs' ] }
220
317
 
221
318
  Input:
222
319
 
@@ -227,35 +324,63 @@ Input:
227
324
 
228
325
  ```code
229
326
  Input: true
230
- Output: { operator: 'TRUE' }
327
+ Output: { operator: 'true' }
231
328
 
232
329
  Input: FALSE
233
- Output: { operator: 'FALSEORNULL' }
330
+ Output: { operator: 'false_or_null' }
234
331
 
235
332
  Input: =false
236
- Output: { operator: 'FALSE' }
333
+ Output: { operator: 'false' }
237
334
 
238
335
  Input: null
239
- Output: { operator: 'NULL' }
336
+ Output: { operator: 'null' }
240
337
 
241
338
  Input: -NULL
242
- Output: { operator: 'NOTNULL' }
243
-
244
- Input: True , faLSE,=false,NULl,-null
245
- Output: { operator: 'TRUE' } { operator: 'FALSEORNULL' } { operator: 'FALSE' } { operator: 'NULL' } { operator: 'NOTNULL' }
339
+ Output: { operator: 'not_null' }
340
+
341
+ Input: null,
342
+ Output: { operator: 'null' }
343
+
344
+ Input: True , , faLSE,=false,NULl,-null
345
+ Output: { operator: 'true' } { operator: 'false_or_null' } { operator: 'false' } { operator: 'null' } { operator: 'not_null' }
346
+ Logs: {
347
+ severity: 'warn',
348
+ message: 'Empty clause',
349
+ startIndex: 8,
350
+ endIndex: 9
351
+ }
246
352
 
247
353
  Input: -'null'
248
- Errors: { message: "Invalid token -'null'", startIndex: 0, endIndex: 7 }
354
+ Logs: {
355
+ severity: 'error',
356
+ message: "Invalid token -'null'",
357
+ startIndex: 0,
358
+ endIndex: 7
359
+ }
249
360
 
250
361
  Input: 10
251
- Errors: { message: 'Invalid token 10', startIndex: 0, endIndex: 2 }
362
+ Logs: {
363
+ severity: 'error',
364
+ message: 'Invalid token 10',
365
+ startIndex: 0,
366
+ endIndex: 2
367
+ }
252
368
 
253
369
  Input: nnull
254
- Errors: { message: 'Invalid token nnull', startIndex: 0, endIndex: 5 }
370
+ Logs: {
371
+ severity: 'error',
372
+ message: 'Invalid token nnull',
373
+ startIndex: 0,
374
+ endIndex: 5
375
+ }
255
376
 
256
377
  Input: truee
257
- Errors: { message: 'Invalid token truee', startIndex: 1, endIndex: 6 }
258
-
378
+ Logs: {
379
+ severity: 'error',
380
+ message: 'Invalid token truee',
381
+ startIndex: 1,
382
+ endIndex: 6
383
+ }
259
384
  ```
260
385
 
261
386
  -------------------------------------------------------------------------
@@ -264,194 +389,291 @@ Errors: { message: 'Invalid token truee', startIndex: 1, endIndex: 6 }
264
389
  ```code
265
390
  Input: this month
266
391
  Output: {
267
- operator: 'ON',
268
- moment: { type: 'INTERVAL', kind: 'THIS', unit: 'MONTH' }
392
+ operator: 'on',
393
+ moment: { type: 'interval', kind: 'this', unit: 'month' }
269
394
  }
270
395
 
271
396
  Input: 3 days
272
- Output: { operator: 'DURATION', duration: { amount: 3, unit: 'DAYS' } }
397
+ Output: { operator: 'duration', duration: { amount: 3, unit: 'days' } }
273
398
 
274
399
  Input: 3 days ago
275
400
  Output: {
276
- operator: 'ON',
401
+ operator: 'on',
277
402
  moment: {
278
- type: 'OFFSET_FROM_NOW',
279
- direction: 'AGO',
403
+ type: 'offset_from_now',
404
+ direction: 'ago',
280
405
  amount: 3,
281
- unit: 'DAYS'
406
+ unit: 'days'
282
407
  }
283
408
  }
284
409
 
285
410
  Input: 3 months ago for 2 days
286
411
  Output: {
287
- operator: 'FOR_RANGE',
412
+ operator: 'for_range',
288
413
  from: {
289
- type: 'OFFSET_FROM_NOW',
290
- direction: 'AGO',
414
+ type: 'offset_from_now',
415
+ direction: 'ago',
291
416
  amount: 3,
292
- unit: 'MONTHS'
417
+ unit: 'months'
293
418
  },
294
- duration: { amount: 2, unit: 'DAYS' }
419
+ duration: { amount: 2, unit: 'days' }
295
420
  }
296
421
 
297
422
  Input: 2025 weeks ago
298
423
  Output: {
299
- operator: 'ON',
424
+ operator: 'on',
300
425
  moment: {
301
- type: 'OFFSET_FROM_NOW',
302
- direction: 'AGO',
426
+ type: 'offset_from_now',
427
+ direction: 'ago',
303
428
  amount: 2025,
304
- unit: 'WEEKS'
429
+ unit: 'weeks'
305
430
  }
306
431
  }
307
432
 
308
433
  Input: before 3 days ago
309
434
  Output: {
310
- operator: 'BEFORE',
435
+ operator: 'before',
311
436
  moment: {
312
- type: 'OFFSET_FROM_NOW',
313
- direction: 'AGO',
437
+ type: 'offset_from_now',
438
+ direction: 'ago',
314
439
  amount: 3,
315
- unit: 'DAYS'
440
+ unit: 'days'
316
441
  }
317
442
  }
318
443
 
319
444
  Input: before 2025-08-30 08:30:20
320
445
  Output: {
321
- operator: 'BEFORE',
322
- moment: { type: 'ABSOLUTE', date: '2025-08-30 08:30:20', unit: 'SECOND' }
446
+ operator: 'before',
447
+ moment: { type: 'absolute', date: '2025-08-30 08:30:20', unit: 'second' }
323
448
  }
324
449
 
325
450
  Input: after 2025-10-05
326
451
  Output: {
327
- operator: 'AFTER',
328
- moment: { type: 'ABSOLUTE', date: '2025-10-05', unit: 'DAY' }
452
+ operator: 'after',
453
+ moment: { type: 'absolute', date: '2025-10-05', unit: 'day' }
329
454
  }
330
455
 
331
456
  Input: 2025-08-30 12:00 to 2025-09-18 14:30
332
457
  Output: {
333
- operator: 'TO_RANGE',
334
- from: { type: 'ABSOLUTE', date: '2025-08-30 12:00', unit: 'MINUTE' },
335
- to: { type: 'ABSOLUTE', date: '2025-09-18 14:30', unit: 'MINUTE' }
458
+ operator: 'to_range',
459
+ from: { type: 'absolute', date: '2025-08-30 12:00', unit: 'minute' },
460
+ to: { type: 'absolute', date: '2025-09-18 14:30', unit: 'minute' }
336
461
  }
337
462
 
338
463
  Input: this year
339
464
  Output: {
340
- operator: 'ON',
341
- moment: { type: 'INTERVAL', kind: 'THIS', unit: 'YEAR' }
465
+ operator: 'on',
466
+ moment: { type: 'interval', kind: 'this', unit: 'year' }
342
467
  }
343
468
 
344
469
  Input: next tuesday
345
470
  Output: {
346
- operator: 'ON',
347
- moment: { type: 'INTERVAL', kind: 'NEXT', unit: 'TUESDAY' }
471
+ operator: 'on',
472
+ moment: { type: 'interval', kind: 'next', unit: 'tuesday' }
348
473
  }
349
474
 
350
475
  Input: 7 years from now
351
476
  Output: {
352
- operator: 'ON',
477
+ operator: 'on',
353
478
  moment: {
354
- type: 'OFFSET_FROM_NOW',
355
- direction: 'FROMNOW',
479
+ type: 'offset_from_now',
480
+ direction: 'from_now',
356
481
  amount: 7,
357
- unit: 'YEARS'
482
+ unit: 'years'
358
483
  }
359
484
  }
360
485
 
361
486
  Input: 2025-01-01 12:00:00 for 3 days
362
487
  Output: {
363
- operator: 'FOR_RANGE',
364
- from: { type: 'ABSOLUTE', date: '2025-01-01 12:00:00', unit: 'SECOND' },
365
- duration: { amount: 3, unit: 'DAYS' }
488
+ operator: 'for_range',
489
+ from: { type: 'absolute', date: '2025-01-01 12:00:00', unit: 'second' },
490
+ duration: { amount: 3, unit: 'days' }
491
+ }
492
+
493
+ Input: 2020-08-12 03:12:56.57
494
+ Output: {
495
+ operator: 'on',
496
+ moment: { type: 'absolute', date: '2020-08-12 03:12:56.57', unit: 'instant' }
497
+ }
498
+
499
+ Input: 2020-08-12T03:12:56[PST]
500
+ Output: {
501
+ operator: 'on',
502
+ moment: {
503
+ type: 'absolute',
504
+ date: '2020-08-12T03:12:56[PST]',
505
+ unit: 'instant'
506
+ }
507
+ }
508
+
509
+ Input: 2020-08-12 03:12:56
510
+ Output: {
511
+ operator: 'on',
512
+ moment: { type: 'absolute', date: '2020-08-12 03:12:56', unit: 'second' }
513
+ }
514
+
515
+ Input: 2020-08-12 03:22
516
+ Output: {
517
+ operator: 'on',
518
+ moment: { type: 'absolute', date: '2020-08-12 03:22', unit: 'minute' }
519
+ }
520
+
521
+ Input: 2020-08-12 03
522
+ Output: {
523
+ operator: 'on',
524
+ moment: { type: 'absolute', date: '2020-08-12 03', unit: 'hour' }
366
525
  }
367
526
 
368
527
  Input: 2020-08-12
369
528
  Output: {
370
- operator: 'ON',
371
- moment: { type: 'ABSOLUTE', date: '2020-08-12', unit: 'DAY' }
529
+ operator: 'on',
530
+ moment: { type: 'absolute', date: '2020-08-12', unit: 'day' }
531
+ }
532
+
533
+ Input: 2020-Q3
534
+ Output: {
535
+ operator: 'on',
536
+ moment: { type: 'absolute', date: '2020-Q3', unit: 'quarter' }
537
+ }
538
+
539
+ Input: 2020-08-07-wK
540
+ Logs: {
541
+ severity: 'error',
542
+ message: 'Invalid token 2020-08-07-wk',
543
+ startIndex: 0,
544
+ endIndex: 13
372
545
  }
373
546
 
374
547
  Input: 2020-08
375
548
  Output: {
376
- operator: 'ON',
377
- moment: { type: 'ABSOLUTE', date: '2020-08', unit: 'MONTH' }
549
+ operator: 'on',
550
+ moment: { type: 'absolute', date: '2020-08', unit: 'month' }
378
551
  }
379
552
 
380
553
  Input: today
381
- Output: { operator: 'ON', moment: { type: 'NAMED', name: 'TODAY' } }
554
+ Output: { operator: 'on', moment: { type: 'named', name: 'today' } }
382
555
 
383
556
  Input: yesterday
384
- Output: { operator: 'ON', moment: { type: 'NAMED', name: 'YESTERDAY' } }
557
+ Output: { operator: 'on', moment: { type: 'named', name: 'yesterday' } }
385
558
 
386
559
  Input: tomorrow
387
- Output: { operator: 'ON', moment: { type: 'NAMED', name: 'TOMORROW' } }
560
+ Output: { operator: 'on', moment: { type: 'named', name: 'tomorrow' } }
388
561
 
389
562
  Input: TODay,Yesterday, TOMORROW , ,TODay ,,
390
- Output: { operator: 'ON', moment: { type: 'NAMED', name: 'TODAY' } } { operator: 'ON', moment: { type: 'NAMED', name: 'YESTERDAY' } } { operator: 'ON', moment: { type: 'NAMED', name: 'TOMORROW' } } { operator: 'ON', moment: { type: 'NAMED', name: 'TODAY' } }
563
+ Output: { operator: 'on', moment: { type: 'named', name: 'today' } } { operator: 'on', moment: { type: 'named', name: 'yesterday' } } { operator: 'on', moment: { type: 'named', name: 'tomorrow' } } { operator: 'on', moment: { type: 'named', name: 'today' } }
564
+ Logs: {
565
+ severity: 'warn',
566
+ message: 'Empty clause',
567
+ startIndex: 28,
568
+ endIndex: 29
569
+ } {
570
+ severity: 'warn',
571
+ message: 'Empty clause',
572
+ startIndex: 36,
573
+ endIndex: 37
574
+ }
391
575
 
392
576
  Input: 2010 to 2011, 2015 to 2016 , 2018, 2020
393
577
  Output: {
394
- operator: 'TO_RANGE',
395
- from: { type: 'ABSOLUTE', date: '2010', unit: 'YEAR' },
396
- to: { type: 'ABSOLUTE', date: '2011', unit: 'YEAR' }
578
+ operator: 'to_range',
579
+ from: { type: 'absolute', date: '2010', unit: 'year' },
580
+ to: { type: 'absolute', date: '2011', unit: 'year' }
397
581
  } {
398
- operator: 'TO_RANGE',
399
- from: { type: 'ABSOLUTE', date: '2015', unit: 'YEAR' },
400
- to: { type: 'ABSOLUTE', date: '2016', unit: 'YEAR' }
582
+ operator: 'to_range',
583
+ from: { type: 'absolute', date: '2015', unit: 'year' },
584
+ to: { type: 'absolute', date: '2016', unit: 'year' }
401
585
  } {
402
- operator: 'ON',
403
- moment: { type: 'ABSOLUTE', date: '2018', unit: 'YEAR' }
586
+ operator: 'on',
587
+ moment: { type: 'absolute', date: '2018', unit: 'year' }
404
588
  } {
405
- operator: 'ON',
406
- moment: { type: 'ABSOLUTE', date: '2020', unit: 'YEAR' }
589
+ operator: 'on',
590
+ moment: { type: 'absolute', date: '2020', unit: 'year' }
407
591
  }
408
592
 
409
593
  Input: next week
410
594
  Output: {
411
- operator: 'ON',
412
- moment: { type: 'INTERVAL', kind: 'NEXT', unit: 'WEEK' }
595
+ operator: 'on',
596
+ moment: { type: 'interval', kind: 'next', unit: 'week' }
413
597
  }
414
598
 
415
599
  Input: now
416
- Output: { operator: 'ON', moment: { type: 'NAMED', name: 'NOW' } }
600
+ Output: { operator: 'on', moment: { type: 'named', name: 'now' } }
417
601
 
418
602
  Input: now to next month
419
603
  Output: {
420
- operator: 'TO_RANGE',
421
- from: { type: 'NAMED', name: 'NOW' },
422
- to: { type: 'INTERVAL', kind: 'NEXT', unit: 'MONTH' }
604
+ operator: 'to_range',
605
+ from: { type: 'named', name: 'now' },
606
+ to: { type: 'interval', kind: 'next', unit: 'month' }
423
607
  }
424
608
 
425
609
  Input: null
426
- Output: { operator: 'NULL' }
610
+ Output: { operator: 'null' }
427
611
 
428
612
  Input: -null,
429
- Output: { operator: 'NOTNULL' }
613
+ Output: { operator: 'not_null' }
430
614
 
431
615
  Input: yyesterday
432
- Errors: { message: 'Invalid token yyesterday', startIndex: 1, endIndex: 11 }
616
+ Logs: {
617
+ severity: 'error',
618
+ message: 'Invalid token yyesterday',
619
+ startIndex: 1,
620
+ endIndex: 11
621
+ }
433
622
 
434
623
  Input: before
435
624
 
436
625
  Input: for
437
- Errors: { message: 'Invalid token FOR', startIndex: 0, endIndex: 3 }
626
+ Logs: {
627
+ severity: 'error',
628
+ message: 'Invalid token for',
629
+ startIndex: 0,
630
+ endIndex: 3
631
+ }
438
632
 
439
- Input: 7
440
- Errors: { message: 'Invalid token 7', startIndex: 0, endIndex: 1 }
633
+ Input: 12
634
+ Logs: {
635
+ severity: 'error',
636
+ message: 'Invalid token 12',
637
+ startIndex: 0,
638
+ endIndex: 2
639
+ }
441
640
 
442
641
  Input: from now
443
- Output: { operator: 'ON', moment: { type: 'NAMED', name: 'NOW' } }
444
- Errors: { message: 'Invalid token FROM', startIndex: 0, endIndex: 4 }
642
+ Output: { operator: 'on', moment: { type: 'named', name: 'now' } }
643
+ Logs: {
644
+ severity: 'error',
645
+ message: 'Invalid token from',
646
+ startIndex: 0,
647
+ endIndex: 4
648
+ }
445
649
 
446
650
  Input: 2025-12-25 12:32:
447
651
  Output: {
448
- operator: 'ON',
449
- moment: { type: 'ABSOLUTE', date: '2025-12-25', unit: 'DAY' }
652
+ operator: 'on',
653
+ moment: { type: 'absolute', date: '2025-12-25', unit: 'day' }
654
+ }
655
+ Logs: {
656
+ severity: 'error',
657
+ message: 'Invalid token 12:32:',
658
+ startIndex: 11,
659
+ endIndex: 17
660
+ }
661
+
662
+ Input: 12:22
663
+ Logs: {
664
+ severity: 'error',
665
+ message: 'Invalid token 12:22',
666
+ startIndex: 0,
667
+ endIndex: 5
450
668
  }
451
- Errors: { message: 'Invalid token 12:32:', startIndex: 11, endIndex: 17 }
452
669
 
453
670
  Input: after 2025 seconds
454
- Errors: { message: 'Invalid token ', startIndex: 6, endIndex: 18 }
671
+ Logs: {
672
+ severity: 'error',
673
+ message: 'Invalid token ',
674
+ startIndex: 6,
675
+ endIndex: 18
676
+ }
455
677
 
456
678
  Input:
457
679