@malloydata/malloy-filter 0.0.237-dev250224203840 → 0.0.237-dev250225015031
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/SAMPLES.md +336 -116
- package/SERIALIZE_SAMPLES.md +268 -64
- package/dist/a_simple_parser.js +6 -0
- package/dist/a_simple_parser.js.map +1 -1
- package/dist/base_parser.js +6 -0
- package/dist/base_parser.js.map +1 -1
- package/dist/boolean_parser.js +28 -13
- package/dist/boolean_parser.js.map +1 -1
- package/dist/boolean_serializer.js +12 -6
- package/dist/boolean_serializer.js.map +1 -1
- package/dist/clause_types.d.ts +20 -15
- package/dist/clause_types.js +6 -0
- package/dist/clause_types.js.map +1 -1
- package/dist/date_parser.d.ts +1 -0
- package/dist/date_parser.js +174 -116
- package/dist/date_parser.js.map +1 -1
- package/dist/date_serializer.js +26 -20
- package/dist/date_serializer.js.map +1 -1
- package/dist/date_types.d.ts +21 -21
- package/dist/date_types.js +6 -0
- package/dist/date_types.js.map +1 -1
- package/dist/generate_samples.js +41 -26
- package/dist/generate_samples.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/number_parser.js +43 -25
- package/dist/number_parser.js.map +1 -1
- package/dist/number_serializer.js +10 -4
- package/dist/number_serializer.js.map +1 -1
- package/dist/string_parser.d.ts +0 -1
- package/dist/string_parser.js +47 -79
- package/dist/string_parser.js.map +1 -1
- package/dist/string_serializer.d.ts +1 -0
- package/dist/string_serializer.js +49 -33
- package/dist/string_serializer.js.map +1 -1
- package/dist/token_types.js +6 -0
- package/dist/token_types.js.map +1 -1
- package/dist/tokenizer.js +9 -3
- package/dist/tokenizer.js.map +1 -1
- package/dist/tokenizer.spec.js +13 -7
- package/dist/tokenizer.spec.js.map +1 -1
- package/package.json +2 -2
- package/src/a_simple_parser.ts +7 -0
- package/src/base_parser.ts +7 -0
- package/src/boolean_parser.ts +30 -18
- package/src/boolean_serializer.ts +13 -6
- package/src/clause_types.ts +36 -31
- package/src/date_parser.ts +177 -115
- package/src/date_serializer.ts +27 -20
- package/src/date_types.ts +42 -34
- package/src/generate_samples.ts +42 -26
- package/src/index.ts +17 -0
- package/src/number_parser.ts +45 -26
- package/src/number_serializer.ts +11 -4
- package/src/string_parser.ts +51 -79
- package/src/string_serializer.ts +65 -39
- package/src/token_types.ts +7 -0
- package/src/tokenizer.spec.ts +14 -7
- package/src/tokenizer.ts +10 -3
package/dist/date_serializer.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.DateSerializer = void 0;
|
|
4
10
|
class DateSerializer {
|
|
@@ -11,20 +17,20 @@ class DateSerializer {
|
|
|
11
17
|
return result.trim().replace(/,$/, '');
|
|
12
18
|
}
|
|
13
19
|
static dateMomentToString(moment) {
|
|
14
|
-
if (moment.type === '
|
|
20
|
+
if (moment.type === 'absolute') {
|
|
15
21
|
return moment.date;
|
|
16
22
|
}
|
|
17
|
-
else if (moment.type === '
|
|
23
|
+
else if (moment.type === 'interval') {
|
|
18
24
|
return moment.kind + ' ' + moment.unit;
|
|
19
25
|
}
|
|
20
|
-
else if (moment.type === '
|
|
26
|
+
else if (moment.type === 'named') {
|
|
21
27
|
return moment.name;
|
|
22
28
|
}
|
|
23
|
-
else if (moment.type === '
|
|
24
|
-
const direction = moment.direction === '
|
|
29
|
+
else if (moment.type === 'offset_from_now') {
|
|
30
|
+
const direction = moment.direction === 'from_now' ? 'from now' : 'ago';
|
|
25
31
|
return moment.amount + ' ' + moment.unit + ' ' + direction;
|
|
26
32
|
}
|
|
27
|
-
else if (moment.type === '
|
|
33
|
+
else if (moment.type === 'span_from_now') {
|
|
28
34
|
return moment.direction + ' ' + moment.amount + ' ' + moment.unit;
|
|
29
35
|
}
|
|
30
36
|
else {
|
|
@@ -33,12 +39,12 @@ class DateSerializer {
|
|
|
33
39
|
}
|
|
34
40
|
static goDateBetweenClause(clause) {
|
|
35
41
|
return (DateSerializer.dateMomentToString(clause.from) +
|
|
36
|
-
'
|
|
42
|
+
' to ' +
|
|
37
43
|
DateSerializer.dateMomentToString(clause.to));
|
|
38
44
|
}
|
|
39
45
|
static goDateForClause(clause) {
|
|
40
46
|
return (DateSerializer.dateMomentToString(clause.from) +
|
|
41
|
-
'
|
|
47
|
+
' for ' +
|
|
42
48
|
clause.duration.amount +
|
|
43
49
|
' ' +
|
|
44
50
|
clause.duration.unit);
|
|
@@ -47,28 +53,28 @@ class DateSerializer {
|
|
|
47
53
|
if (!('operator' in clause)) {
|
|
48
54
|
throw new Error('Invalid date clause ' + JSON.stringify(clause));
|
|
49
55
|
}
|
|
50
|
-
if (clause.operator === '
|
|
56
|
+
if (clause.operator === 'to_range') {
|
|
51
57
|
return DateSerializer.goDateBetweenClause(clause);
|
|
52
58
|
}
|
|
53
|
-
else if (clause.operator === '
|
|
59
|
+
else if (clause.operator === 'for_range') {
|
|
54
60
|
return DateSerializer.goDateForClause(clause);
|
|
55
61
|
}
|
|
56
|
-
else if (clause.operator === '
|
|
57
|
-
return '
|
|
62
|
+
else if (clause.operator === 'before') {
|
|
63
|
+
return 'before ' + DateSerializer.dateMomentToString(clause.moment);
|
|
58
64
|
}
|
|
59
|
-
else if (clause.operator === '
|
|
60
|
-
return '
|
|
65
|
+
else if (clause.operator === 'after') {
|
|
66
|
+
return 'after ' + DateSerializer.dateMomentToString(clause.moment);
|
|
61
67
|
}
|
|
62
|
-
else if (clause.operator === '
|
|
68
|
+
else if (clause.operator === 'on') {
|
|
63
69
|
return DateSerializer.dateMomentToString(clause.moment);
|
|
64
70
|
}
|
|
65
|
-
else if (clause.operator === '
|
|
66
|
-
return '
|
|
71
|
+
else if (clause.operator === 'null') {
|
|
72
|
+
return 'null';
|
|
67
73
|
}
|
|
68
|
-
else if (clause.operator === '
|
|
69
|
-
return '-
|
|
74
|
+
else if (clause.operator === 'not_null') {
|
|
75
|
+
return '-null';
|
|
70
76
|
}
|
|
71
|
-
else if (clause.operator === '
|
|
77
|
+
else if (clause.operator === 'duration') {
|
|
72
78
|
return clause.duration.amount + ' ' + clause.duration.unit;
|
|
73
79
|
}
|
|
74
80
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date_serializer.js","sourceRoot":"","sources":["../src/date_serializer.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"date_serializer.js","sourceRoot":"","sources":["../src/date_serializer.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AASH,MAAa,cAAc;IACzB,YAAoB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,SAAS;QACd,MAAM,MAAM,GAAG,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,MAAkB;QAClD,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;YAC9B,OAAO,MAAM,CAAC,IAAI,CAAC;SACpB;aAAM,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;YACrC,OAAO,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC;SACxC;aAAM,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE;YAClC,OAAO,MAAM,CAAC,IAAI,CAAC;SACpB;aAAM,IAAI,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE;YAC5C,MAAM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@
|
|
|
1
|
-
import {
|
|
2
|
-
export type DateTimeUnit = '
|
|
3
|
-
export type DateWeekday = '
|
|
1
|
+
import { FilterLog } from './clause_types';
|
|
2
|
+
export type DateTimeUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'instant';
|
|
3
|
+
export type DateWeekday = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
|
|
4
4
|
export interface Duration {
|
|
5
5
|
amount: number;
|
|
6
6
|
unit: DateTimeUnit;
|
|
7
7
|
}
|
|
8
|
-
export type DateMomentName = '
|
|
8
|
+
export type DateMomentName = 'now' | 'today' | 'yesterday' | 'tomorrow';
|
|
9
9
|
export interface NamedMoment {
|
|
10
|
-
type: '
|
|
10
|
+
type: 'named';
|
|
11
11
|
name: DateMomentName;
|
|
12
12
|
}
|
|
13
|
-
export type DateMomentIntervalOperator = '
|
|
13
|
+
export type DateMomentIntervalOperator = 'last' | 'this' | 'next';
|
|
14
14
|
export interface IntervalMoment {
|
|
15
|
-
type: '
|
|
15
|
+
type: 'interval';
|
|
16
16
|
kind: DateMomentIntervalOperator;
|
|
17
17
|
unit: DateTimeUnit | DateWeekday;
|
|
18
18
|
}
|
|
19
|
-
export type DateMomentOffsetFromNowDirection = '
|
|
19
|
+
export type DateMomentOffsetFromNowDirection = 'ago' | 'from_now';
|
|
20
20
|
export interface OffsetMoment {
|
|
21
|
-
type: '
|
|
21
|
+
type: 'offset_from_now';
|
|
22
22
|
direction: DateMomentOffsetFromNowDirection;
|
|
23
23
|
unit: DateTimeUnit;
|
|
24
24
|
amount: number;
|
|
25
25
|
}
|
|
26
|
-
export type DateMomentSpanFromNowDirection = '
|
|
26
|
+
export type DateMomentSpanFromNowDirection = 'last' | 'next';
|
|
27
27
|
export interface SpanMoment {
|
|
28
|
-
type: '
|
|
28
|
+
type: 'span_from_now';
|
|
29
29
|
direction: DateMomentSpanFromNowDirection;
|
|
30
30
|
unit: DateTimeUnit;
|
|
31
31
|
amount: number;
|
|
32
32
|
}
|
|
33
33
|
export interface AbsoluteMoment {
|
|
34
|
-
type: '
|
|
34
|
+
type: 'absolute';
|
|
35
35
|
date: string;
|
|
36
36
|
unit: DateTimeUnit;
|
|
37
37
|
}
|
|
38
38
|
export type DateMoment = AbsoluteMoment | NamedMoment | IntervalMoment | SpanMoment | OffsetMoment;
|
|
39
39
|
export interface DateAfterClause {
|
|
40
|
-
operator: '
|
|
40
|
+
operator: 'after';
|
|
41
41
|
moment: DateMoment;
|
|
42
42
|
}
|
|
43
43
|
export interface DateBeforeClause {
|
|
44
|
-
operator: '
|
|
44
|
+
operator: 'before';
|
|
45
45
|
moment: DateMoment;
|
|
46
46
|
}
|
|
47
47
|
export interface DateOnClause {
|
|
48
|
-
operator: '
|
|
48
|
+
operator: 'on';
|
|
49
49
|
moment: DateMoment;
|
|
50
50
|
}
|
|
51
51
|
export interface DateBetweenClause {
|
|
52
|
-
operator: '
|
|
52
|
+
operator: 'to_range';
|
|
53
53
|
from: DateMoment;
|
|
54
54
|
to: DateMoment;
|
|
55
55
|
}
|
|
56
56
|
export interface DateForClause {
|
|
57
|
-
operator: '
|
|
57
|
+
operator: 'for_range';
|
|
58
58
|
from: DateMoment;
|
|
59
59
|
duration: Duration;
|
|
60
60
|
}
|
|
61
61
|
export interface DateNullClause {
|
|
62
|
-
operator: '
|
|
62
|
+
operator: 'null';
|
|
63
63
|
}
|
|
64
64
|
export interface DateNotNullClause {
|
|
65
|
-
operator: '
|
|
65
|
+
operator: 'not_null';
|
|
66
66
|
}
|
|
67
67
|
export interface DateDurationClause {
|
|
68
|
-
operator: '
|
|
68
|
+
operator: 'duration';
|
|
69
69
|
duration: Duration;
|
|
70
70
|
}
|
|
71
71
|
export type DateClause = DateAfterClause | DateBeforeClause | DateOnClause | DateBetweenClause | DateForClause | DateNullClause | DateNotNullClause | DateDurationClause;
|
|
72
72
|
export interface DateParserResponse {
|
|
73
73
|
clauses: DateClause[];
|
|
74
|
-
|
|
74
|
+
logs: FilterLog[];
|
|
75
75
|
}
|
package/dist/date_types.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
//# sourceMappingURL=date_types.js.map
|
package/dist/date_types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date_types.js","sourceRoot":"","sources":["../src/date_types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"date_types.js","sourceRoot":"","sources":["../src/date_types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
package/dist/generate_samples.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
9
|
if (k2 === undefined) k2 = k;
|
|
4
10
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -36,6 +42,7 @@ const numberExamples = [
|
|
|
36
42
|
'5',
|
|
37
43
|
'!=5',
|
|
38
44
|
'1, 3, 5, null',
|
|
45
|
+
'1, 3, , 5,',
|
|
39
46
|
'<1, >=100 ',
|
|
40
47
|
'>=1',
|
|
41
48
|
' <= 10 ',
|
|
@@ -68,6 +75,8 @@ const stringExamples = [
|
|
|
68
75
|
'CAT,-NULL',
|
|
69
76
|
'CAT,-"NULL"',
|
|
70
77
|
'CAT,NULL',
|
|
78
|
+
'CAT,,',
|
|
79
|
+
'CAT, , DOG',
|
|
71
80
|
'EMPTY',
|
|
72
81
|
'-EMPTY',
|
|
73
82
|
'CAT,-EMPTY',
|
|
@@ -91,7 +100,8 @@ const booleanExamples = [
|
|
|
91
100
|
'=false',
|
|
92
101
|
'null',
|
|
93
102
|
'-NULL',
|
|
94
|
-
'
|
|
103
|
+
'null,',
|
|
104
|
+
' True , , faLSE,=false,NULl,-null',
|
|
95
105
|
"-'null'",
|
|
96
106
|
'10',
|
|
97
107
|
'nnull',
|
|
@@ -104,14 +114,21 @@ const dateExamples = [
|
|
|
104
114
|
'3 months ago for 2 days',
|
|
105
115
|
'2025 weeks ago',
|
|
106
116
|
'before 3 days ago',
|
|
107
|
-
'
|
|
108
|
-
'
|
|
117
|
+
'Before 2025-08-30 08:30:20',
|
|
118
|
+
'AFTER 2025-10-05',
|
|
109
119
|
'2025-08-30 12:00 to 2025-09-18 14:30',
|
|
110
|
-
'this
|
|
111
|
-
'
|
|
112
|
-
'7 years from
|
|
120
|
+
'this YEAR',
|
|
121
|
+
'Next Tuesday',
|
|
122
|
+
'7 years from Now',
|
|
113
123
|
'2025-01-01 12:00:00 for 3 days',
|
|
124
|
+
'2020-08-12 03:12:56.57',
|
|
125
|
+
'2020-08-12T03:12:56[PST]',
|
|
126
|
+
'2020-08-12 03:12:56',
|
|
127
|
+
'2020-08-12 03:22',
|
|
128
|
+
'2020-08-12 03',
|
|
114
129
|
'2020-08-12',
|
|
130
|
+
'2020-Q3',
|
|
131
|
+
'2020-08-07-wK',
|
|
115
132
|
'2020-08',
|
|
116
133
|
'today',
|
|
117
134
|
'yesterday',
|
|
@@ -126,9 +143,10 @@ const dateExamples = [
|
|
|
126
143
|
' yyesterday ',
|
|
127
144
|
'before',
|
|
128
145
|
'for',
|
|
129
|
-
'
|
|
146
|
+
'12',
|
|
130
147
|
'from now',
|
|
131
148
|
'2025-12-25 12:32:',
|
|
149
|
+
'12:22',
|
|
132
150
|
'after 2025 seconds',
|
|
133
151
|
'',
|
|
134
152
|
];
|
|
@@ -167,8 +185,8 @@ class GenerateSamples {
|
|
|
167
185
|
if (response.clauses && response.clauses.length > 0) {
|
|
168
186
|
GenerateSamples.writeJson(fp, 'Output: ', ...response.clauses);
|
|
169
187
|
}
|
|
170
|
-
if (response.
|
|
171
|
-
GenerateSamples.writeJson(fp, '
|
|
188
|
+
if (response.logs && response.logs.length > 0) {
|
|
189
|
+
GenerateSamples.writeJson(fp, 'Logs: ', ...response.logs);
|
|
172
190
|
}
|
|
173
191
|
GenerateSamples.writeRaw(fp, '');
|
|
174
192
|
}
|
|
@@ -180,8 +198,8 @@ class GenerateSamples {
|
|
|
180
198
|
if (response.clauses && response.clauses.length > 0) {
|
|
181
199
|
GenerateSamples.writeJson(fp, 'Output: ', ...response.clauses);
|
|
182
200
|
}
|
|
183
|
-
if (response.
|
|
184
|
-
GenerateSamples.writeJson(fp, '
|
|
201
|
+
if (response.logs && response.logs.length > 0) {
|
|
202
|
+
GenerateSamples.writeJson(fp, 'Logs: ', ...response.logs);
|
|
185
203
|
}
|
|
186
204
|
GenerateSamples.writeRaw(fp, '');
|
|
187
205
|
}
|
|
@@ -193,8 +211,8 @@ class GenerateSamples {
|
|
|
193
211
|
if (response.clauses && response.clauses.length > 0) {
|
|
194
212
|
GenerateSamples.writeJson(fp, 'Output: ', ...response.clauses);
|
|
195
213
|
}
|
|
196
|
-
if (response.
|
|
197
|
-
GenerateSamples.writeJson(fp, '
|
|
214
|
+
if (response.logs && response.logs.length > 0) {
|
|
215
|
+
GenerateSamples.writeJson(fp, 'Logs: ', ...response.logs);
|
|
198
216
|
}
|
|
199
217
|
GenerateSamples.writeRaw(fp, '');
|
|
200
218
|
}
|
|
@@ -206,11 +224,8 @@ class GenerateSamples {
|
|
|
206
224
|
if (response.clauses && response.clauses.length > 0) {
|
|
207
225
|
GenerateSamples.writeJson(fp, 'Output: ', ...response.clauses);
|
|
208
226
|
}
|
|
209
|
-
if (response.
|
|
210
|
-
GenerateSamples.writeJson(fp, '
|
|
211
|
-
}
|
|
212
|
-
if (response.errors && response.errors.length > 0) {
|
|
213
|
-
GenerateSamples.writeJson(fp, 'Errors: ', ...response.errors);
|
|
227
|
+
if (response.logs && response.logs.length > 0) {
|
|
228
|
+
GenerateSamples.writeJson(fp, 'Logs: ', ...response.logs);
|
|
214
229
|
}
|
|
215
230
|
GenerateSamples.writeRaw(fp, '');
|
|
216
231
|
}
|
|
@@ -222,8 +237,8 @@ class GenerateSamples {
|
|
|
222
237
|
const result = new boolean_serializer_1.BooleanSerializer(response.clauses || []).serialize();
|
|
223
238
|
GenerateSamples.writeRaw(fp, 'Output: ' + result);
|
|
224
239
|
}
|
|
225
|
-
if (response.
|
|
226
|
-
GenerateSamples.writeJson(fp, '
|
|
240
|
+
if (response.logs && response.logs.length > 0) {
|
|
241
|
+
GenerateSamples.writeJson(fp, 'Logs: ', ...response.logs);
|
|
227
242
|
}
|
|
228
243
|
GenerateSamples.writeRaw(fp, '');
|
|
229
244
|
}
|
|
@@ -235,8 +250,8 @@ class GenerateSamples {
|
|
|
235
250
|
const result = new date_serializer_1.DateSerializer(response.clauses || []).serialize();
|
|
236
251
|
GenerateSamples.writeRaw(fp, 'Output: ' + result);
|
|
237
252
|
}
|
|
238
|
-
if (response.
|
|
239
|
-
GenerateSamples.writeJson(fp, '
|
|
253
|
+
if (response.logs && response.logs.length > 0) {
|
|
254
|
+
GenerateSamples.writeJson(fp, 'Logs: ', ...response.logs);
|
|
240
255
|
}
|
|
241
256
|
GenerateSamples.writeRaw(fp, '');
|
|
242
257
|
}
|
|
@@ -248,8 +263,8 @@ class GenerateSamples {
|
|
|
248
263
|
const result = new number_serializer_1.NumberSerializer(response.clauses || []).serialize();
|
|
249
264
|
GenerateSamples.writeRaw(fp, 'Output: ' + result);
|
|
250
265
|
}
|
|
251
|
-
if (response.
|
|
252
|
-
GenerateSamples.writeJson(fp, '
|
|
266
|
+
if (response.logs && response.logs.length > 0) {
|
|
267
|
+
GenerateSamples.writeJson(fp, 'Logs: ', ...response.logs);
|
|
253
268
|
}
|
|
254
269
|
GenerateSamples.writeRaw(fp, '');
|
|
255
270
|
}
|
|
@@ -261,8 +276,8 @@ class GenerateSamples {
|
|
|
261
276
|
const result = new string_serializer_1.StringSerializer(response.clauses || []).serialize();
|
|
262
277
|
GenerateSamples.writeRaw(fp, 'Output: ' + result);
|
|
263
278
|
}
|
|
264
|
-
if (response.
|
|
265
|
-
GenerateSamples.writeJson(fp, '
|
|
279
|
+
if (response.logs && response.logs.length > 0) {
|
|
280
|
+
GenerateSamples.writeJson(fp, 'Logs: ', ...response.logs);
|
|
266
281
|
}
|
|
267
282
|
GenerateSamples.writeRaw(fp, '');
|
|
268
283
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_samples.js","sourceRoot":"","sources":["../src/generate_samples.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"generate_samples.js","sourceRoot":"","sources":["../src/generate_samples.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qDAA+C;AAC/C,mDAA6C;AAC7C,mDAA6C;AAC7C,+CAAyC;AACzC,6DAAuD;AACvD,2DAAqD;AACrD,2DAAqD;AACrD,uDAAiD;AAEjD,MAAM,cAAc,GAAG;IACrB,GAAG;IACH,KAAK;IACL,eAAe;IACf,YAAY;IACZ,YAAY;IACZ,KAAK;IACL,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,iBAAiB;IACjB,mBAAmB;IACnB,eAAe;IACf,+BAA+B;IAC/B,6DAA6D;IAC7D,kBAAkB;IAClB,YAAY;CACb,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,iBAAiB;IACjB,oBAAoB;IACpB,uBAAuB;IACvB,6CAA6C;IAC7C,eAAe;IACf,qCAAqC;IACrC,8BAA8B;IAC9B,eAAe;I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 -0,0 +1,10 @@
|
|
|
1
|
+
export { BooleanParser } from './boolean_parser';
|
|
2
|
+
export { DateParser } from './date_parser';
|
|
3
|
+
export { NumberParser } from './number_parser';
|
|
4
|
+
export { StringParser } from './string_parser';
|
|
5
|
+
export { BooleanSerializer } from './boolean_serializer';
|
|
6
|
+
export { DateSerializer } from './date_serializer';
|
|
7
|
+
export { NumberSerializer } from './number_serializer';
|
|
8
|
+
export { StringSerializer } from './string_serializer';
|
|
9
|
+
export * from './clause_types';
|
|
10
|
+
export * from './date_types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.StringSerializer = exports.NumberSerializer = exports.DateSerializer = exports.BooleanSerializer = exports.StringParser = exports.NumberParser = exports.DateParser = exports.BooleanParser = void 0;
|
|
24
|
+
var boolean_parser_1 = require("./boolean_parser");
|
|
25
|
+
Object.defineProperty(exports, "BooleanParser", { enumerable: true, get: function () { return boolean_parser_1.BooleanParser; } });
|
|
26
|
+
var date_parser_1 = require("./date_parser");
|
|
27
|
+
Object.defineProperty(exports, "DateParser", { enumerable: true, get: function () { return date_parser_1.DateParser; } });
|
|
28
|
+
var number_parser_1 = require("./number_parser");
|
|
29
|
+
Object.defineProperty(exports, "NumberParser", { enumerable: true, get: function () { return number_parser_1.NumberParser; } });
|
|
30
|
+
var string_parser_1 = require("./string_parser");
|
|
31
|
+
Object.defineProperty(exports, "StringParser", { enumerable: true, get: function () { return string_parser_1.StringParser; } });
|
|
32
|
+
var boolean_serializer_1 = require("./boolean_serializer");
|
|
33
|
+
Object.defineProperty(exports, "BooleanSerializer", { enumerable: true, get: function () { return boolean_serializer_1.BooleanSerializer; } });
|
|
34
|
+
var date_serializer_1 = require("./date_serializer");
|
|
35
|
+
Object.defineProperty(exports, "DateSerializer", { enumerable: true, get: function () { return date_serializer_1.DateSerializer; } });
|
|
36
|
+
var number_serializer_1 = require("./number_serializer");
|
|
37
|
+
Object.defineProperty(exports, "NumberSerializer", { enumerable: true, get: function () { return number_serializer_1.NumberSerializer; } });
|
|
38
|
+
var string_serializer_1 = require("./string_serializer");
|
|
39
|
+
Object.defineProperty(exports, "StringSerializer", { enumerable: true, get: function () { return string_serializer_1.StringSerializer; } });
|
|
40
|
+
__exportStar(require("./clause_types"), exports);
|
|
41
|
+
__exportStar(require("./date_types"), exports);
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAEH,mDAA+C;AAAvC,+GAAA,aAAa,OAAA;AACrB,6CAAyC;AAAjC,yGAAA,UAAU,OAAA;AAClB,iDAA6C;AAArC,6GAAA,YAAY,OAAA;AACpB,iDAA6C;AAArC,6GAAA,YAAY,OAAA;AACpB,2DAAuD;AAA/C,uHAAA,iBAAiB,OAAA;AACzB,qDAAiD;AAAzC,iHAAA,cAAc,OAAA;AACtB,yDAAqD;AAA7C,qHAAA,gBAAgB,OAAA;AACxB,yDAAqD;AAA7C,qHAAA,gBAAgB,OAAA;AACxB,iDAA+B;AAC/B,+CAA6B"}
|
package/dist/number_parser.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.NumberParser = void 0;
|
|
4
10
|
const tokenizer_1 = require("./tokenizer");
|
|
@@ -22,8 +28,8 @@ class NumberParser extends base_parser_1.BaseParser {
|
|
|
22
28
|
{ type: '<', value: '<' },
|
|
23
29
|
];
|
|
24
30
|
const specialWords = [
|
|
25
|
-
{ type: '
|
|
26
|
-
{ type: '
|
|
31
|
+
{ type: 'not_null', value: '-null', ignoreCase: true },
|
|
32
|
+
{ type: 'null', value: 'null', ignoreCase: true },
|
|
27
33
|
];
|
|
28
34
|
const params = {
|
|
29
35
|
trimWordWhitespace: true,
|
|
@@ -39,18 +45,26 @@ class NumberParser extends base_parser_1.BaseParser {
|
|
|
39
45
|
this.index = 0;
|
|
40
46
|
this.tokenize();
|
|
41
47
|
let clauses = [];
|
|
42
|
-
const
|
|
48
|
+
const logs = [];
|
|
43
49
|
while (this.index < this.tokens.length) {
|
|
44
50
|
const token = this.getNext();
|
|
45
51
|
if (token.type === ',') {
|
|
52
|
+
if (this.index > 0 && this.tokens[this.index - 1].type === ',') {
|
|
53
|
+
logs.push({
|
|
54
|
+
severity: 'warn',
|
|
55
|
+
message: 'Empty clause',
|
|
56
|
+
startIndex: token.startIndex,
|
|
57
|
+
endIndex: token.endIndex,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
46
60
|
this.index++;
|
|
47
61
|
}
|
|
48
62
|
else if (this.isRangeStart(this.index)) {
|
|
49
|
-
clauses = this.checkRange(token, false, clauses,
|
|
63
|
+
clauses = this.checkRange(token, false, clauses, logs);
|
|
50
64
|
}
|
|
51
65
|
else if (token.type === '!=' && this.isRangeStart(this.index + 1)) {
|
|
52
66
|
this.index++;
|
|
53
|
-
clauses = this.checkRange(token, true, clauses,
|
|
67
|
+
clauses = this.checkRange(token, true, clauses, logs);
|
|
54
68
|
}
|
|
55
69
|
else if (this.checkNull(clauses)) {
|
|
56
70
|
this.index++;
|
|
@@ -67,15 +81,16 @@ class NumberParser extends base_parser_1.BaseParser {
|
|
|
67
81
|
this.index++;
|
|
68
82
|
}
|
|
69
83
|
else {
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
logs.push({
|
|
85
|
+
severity: 'error',
|
|
86
|
+
message: 'Invalid expression: ' + token.value,
|
|
72
87
|
startIndex: token.startIndex,
|
|
73
88
|
endIndex: token.endIndex,
|
|
74
89
|
});
|
|
75
90
|
this.index++;
|
|
76
91
|
}
|
|
77
92
|
}
|
|
78
|
-
return { clauses: NumberParser.groupClauses(clauses),
|
|
93
|
+
return { clauses: NumberParser.groupClauses(clauses), logs };
|
|
79
94
|
}
|
|
80
95
|
static groupClauses(clauses) {
|
|
81
96
|
if (clauses.length < 2) {
|
|
@@ -105,29 +120,30 @@ class NumberParser extends base_parser_1.BaseParser {
|
|
|
105
120
|
matchTokens(candidates) {
|
|
106
121
|
return base_parser_1.BaseParser.matchTokenTypes(candidates, this.index, this.tokens);
|
|
107
122
|
}
|
|
108
|
-
checkRange(token, negated, clauses,
|
|
123
|
+
checkRange(token, negated, clauses, logs) {
|
|
109
124
|
if (this.matchTokens(['[', 'word', ',', 'word', ']'])) {
|
|
110
125
|
return negated
|
|
111
|
-
? this.consumeRange('<', '>', clauses,
|
|
112
|
-
: this.consumeRange('>=', '<=', clauses,
|
|
126
|
+
? this.consumeRange('<', '>', clauses, logs)
|
|
127
|
+
: this.consumeRange('>=', '<=', clauses, logs);
|
|
113
128
|
}
|
|
114
129
|
else if (this.matchTokens(['[', 'word', ',', 'word', ')'])) {
|
|
115
130
|
return negated
|
|
116
|
-
? this.consumeRange('<', '>=', clauses,
|
|
117
|
-
: this.consumeRange('>=', '<', clauses,
|
|
131
|
+
? this.consumeRange('<', '>=', clauses, logs)
|
|
132
|
+
: this.consumeRange('>=', '<', clauses, logs);
|
|
118
133
|
}
|
|
119
134
|
else if (this.matchTokens(['(', 'word', ',', 'word', ']'])) {
|
|
120
135
|
return negated
|
|
121
|
-
? this.consumeRange('<=', '>', clauses,
|
|
122
|
-
: this.consumeRange('>', '<=', clauses,
|
|
136
|
+
? this.consumeRange('<=', '>', clauses, logs)
|
|
137
|
+
: this.consumeRange('>', '<=', clauses, logs);
|
|
123
138
|
}
|
|
124
139
|
else if (this.matchTokens(['(', 'word', ',', 'word', ')'])) {
|
|
125
140
|
return negated
|
|
126
|
-
? this.consumeRange('<=', '>=', clauses,
|
|
127
|
-
: this.consumeRange('>', '<', clauses,
|
|
141
|
+
? this.consumeRange('<=', '>=', clauses, logs)
|
|
142
|
+
: this.consumeRange('>', '<', clauses, logs);
|
|
128
143
|
}
|
|
129
144
|
else {
|
|
130
|
-
|
|
145
|
+
logs.push({
|
|
146
|
+
severity: 'error',
|
|
131
147
|
message: 'Invalid range expression',
|
|
132
148
|
startIndex: token.startIndex,
|
|
133
149
|
endIndex: token.endIndex,
|
|
@@ -157,20 +173,22 @@ class NumberParser extends base_parser_1.BaseParser {
|
|
|
157
173
|
static isValidNumber(value) {
|
|
158
174
|
return Number.isNaN(value) === false;
|
|
159
175
|
}
|
|
160
|
-
consumeRange(startOperator, endOperator, clauses,
|
|
176
|
+
consumeRange(startOperator, endOperator, clauses, logs) {
|
|
161
177
|
const startToken = this.getAt(this.index + 1);
|
|
162
178
|
const endToken = this.getAt(this.index + 3);
|
|
163
179
|
const startValue = NumberParser.parseNumber(startToken.value);
|
|
164
180
|
const endValue = NumberParser.parseNumber(endToken.value);
|
|
165
181
|
if (!NumberParser.isValidNumber(startValue)) {
|
|
166
|
-
|
|
182
|
+
logs.push({
|
|
183
|
+
severity: 'error',
|
|
167
184
|
message: 'Invalid number',
|
|
168
185
|
startIndex: startToken.startIndex,
|
|
169
186
|
endIndex: startToken.endIndex,
|
|
170
187
|
});
|
|
171
188
|
}
|
|
172
189
|
else if (!NumberParser.isValidNumber(endValue)) {
|
|
173
|
-
|
|
190
|
+
logs.push({
|
|
191
|
+
severity: 'error',
|
|
174
192
|
message: 'Invalid number',
|
|
175
193
|
startIndex: endToken.startIndex,
|
|
176
194
|
endIndex: endToken.endIndex,
|
|
@@ -219,12 +237,12 @@ class NumberParser extends base_parser_1.BaseParser {
|
|
|
219
237
|
}
|
|
220
238
|
checkNull(clauses) {
|
|
221
239
|
const type = this.getNext().type;
|
|
222
|
-
if (type === '
|
|
223
|
-
clauses.push({ operator: '
|
|
240
|
+
if (type === 'null') {
|
|
241
|
+
clauses.push({ operator: 'null' });
|
|
224
242
|
return true;
|
|
225
243
|
}
|
|
226
|
-
else if (type === '
|
|
227
|
-
clauses.push({ operator: '
|
|
244
|
+
else if (type === 'not_null') {
|
|
245
|
+
clauses.push({ operator: 'not_null' });
|
|
228
246
|
return true;
|
|
229
247
|
}
|
|
230
248
|
return false;
|