dbgate-filterparser 4.8.1 → 4.8.4
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/lib/parseFilter.js +27 -12
- package/lib/types.d.ts +1 -1
- package/package.json +3 -3
package/lib/parseFilter.js
CHANGED
|
@@ -215,10 +215,10 @@ const createParser = (filterType) => {
|
|
|
215
215
|
eq: r => (0, common_1.word)('=').then(r.value).map(binaryCondition('=')),
|
|
216
216
|
ne: r => (0, common_1.word)('!=').then(r.value).map(binaryCondition('<>')),
|
|
217
217
|
ne2: r => (0, common_1.word)('<>').then(r.value).map(binaryCondition('<>')),
|
|
218
|
-
lt: r => (0, common_1.word)('<').then(r.value).map(binaryCondition('<')),
|
|
219
|
-
gt: r => (0, common_1.word)('>').then(r.value).map(binaryCondition('>')),
|
|
220
218
|
le: r => (0, common_1.word)('<=').then(r.value).map(binaryCondition('<=')),
|
|
221
219
|
ge: r => (0, common_1.word)('>=').then(r.value).map(binaryCondition('>=')),
|
|
220
|
+
lt: r => (0, common_1.word)('<').then(r.value).map(binaryCondition('<')),
|
|
221
|
+
gt: r => (0, common_1.word)('>').then(r.value).map(binaryCondition('>')),
|
|
222
222
|
startsWith: r => (0, common_1.word)('^').then(r.value).map(likeCondition('like', '#VALUE#%')),
|
|
223
223
|
endsWith: r => (0, common_1.word)('$').then(r.value).map(likeCondition('like', '%#VALUE#')),
|
|
224
224
|
contains: r => (0, common_1.word)('+').then(r.value).map(likeCondition('like', '%#VALUE#%')),
|
|
@@ -230,24 +230,38 @@ const createParser = (filterType) => {
|
|
|
230
230
|
list: r => r.factor.sepBy(r.comma).map(compoudCondition('or')),
|
|
231
231
|
};
|
|
232
232
|
const allowedValues = []; // 'string1', 'string2', 'number', 'noQuotedString'];
|
|
233
|
-
if (filterType == 'string')
|
|
233
|
+
if (filterType == 'string' || filterType == 'eval') {
|
|
234
234
|
allowedValues.push('string1', 'string2', 'noQuotedString');
|
|
235
|
-
|
|
235
|
+
}
|
|
236
|
+
if (filterType == 'number') {
|
|
236
237
|
allowedValues.push('string1Num', 'string2Num', 'number');
|
|
238
|
+
}
|
|
237
239
|
const allowedElements = ['null', 'notNull', 'eq', 'ne', 'ne2'];
|
|
238
|
-
if (filterType == 'number' || filterType == 'datetime')
|
|
239
|
-
allowedElements.push('
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
if (filterType == 'number' || filterType == 'datetime' || filterType == 'eval') {
|
|
241
|
+
allowedElements.push('le', 'ge', 'lt', 'gt');
|
|
242
|
+
}
|
|
243
|
+
if (filterType == 'string') {
|
|
244
|
+
allowedElements.push('empty', 'notEmpty');
|
|
245
|
+
}
|
|
246
|
+
if (filterType == 'eval' || filterType == 'string') {
|
|
247
|
+
allowedElements.push('startsWith', 'endsWith', 'contains', 'startsWithNot', 'endsWithNot', 'containsNot');
|
|
248
|
+
}
|
|
249
|
+
if (filterType == 'logical') {
|
|
243
250
|
allowedElements.push('true', 'false', 'trueNum', 'falseNum');
|
|
244
|
-
|
|
251
|
+
}
|
|
252
|
+
if (filterType == 'eval') {
|
|
253
|
+
allowedElements.push('true', 'false');
|
|
254
|
+
}
|
|
255
|
+
if (filterType == 'datetime') {
|
|
245
256
|
allowedElements.push('yearMonthDaySecond', 'yearMonthDayMinute', 'yearMonthDayNum', 'yearMonthNum', 'yearNum', 'yesterday', 'today', 'tomorrow', 'lastWeek', 'thisWeek', 'nextWeek', 'lastMonth', 'thisMonth', 'nextMonth', 'lastYear', 'thisYear', 'nextYear');
|
|
257
|
+
}
|
|
246
258
|
// must be last
|
|
247
|
-
if (filterType == 'string')
|
|
259
|
+
if (filterType == 'string' || filterType == 'eval') {
|
|
248
260
|
allowedElements.push('valueTestStr');
|
|
249
|
-
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
250
263
|
allowedElements.push('valueTestEq');
|
|
264
|
+
}
|
|
251
265
|
return parsimmon_1.default.createLanguage(langDef);
|
|
252
266
|
};
|
|
253
267
|
const parsers = {
|
|
@@ -255,6 +269,7 @@ const parsers = {
|
|
|
255
269
|
string: createParser('string'),
|
|
256
270
|
datetime: createParser('datetime'),
|
|
257
271
|
logical: createParser('logical'),
|
|
272
|
+
eval: createParser('eval'),
|
|
258
273
|
mongo: mongoParser_1.mongoParser,
|
|
259
274
|
};
|
|
260
275
|
function parseFilter(value, filterType) {
|
package/lib/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare type FilterType = 'number' | 'string' | 'datetime' | 'logical' | 'mongo';
|
|
1
|
+
export declare type FilterType = 'number' | 'string' | 'datetime' | 'logical' | 'eval' | 'mongo';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.8.
|
|
2
|
+
"version": "4.8.4",
|
|
3
3
|
"name": "dbgate-filterparser",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"lib"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"dbgate-types": "^4.8.
|
|
16
|
+
"dbgate-types": "^4.8.4",
|
|
17
17
|
"@types/jest": "^25.1.4",
|
|
18
18
|
"@types/node": "^13.7.0",
|
|
19
19
|
"jest": "^24.9.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@types/parsimmon": "^1.10.1",
|
|
25
|
-
"dbgate-tools": "^4.8.
|
|
25
|
+
"dbgate-tools": "^4.8.4",
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
27
|
"moment": "^2.24.0",
|
|
28
28
|
"parsimmon": "^1.13.0"
|