dbgate-filterparser 4.2.8 → 4.3.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/lib/mongoParser.js +17 -2
- package/package.json +3 -3
package/lib/mongoParser.js
CHANGED
|
@@ -29,6 +29,19 @@ const numberTestCondition = () => value => ({
|
|
|
29
29
|
},
|
|
30
30
|
],
|
|
31
31
|
});
|
|
32
|
+
const objectIdTestCondition = () => value => ({
|
|
33
|
+
$or: [
|
|
34
|
+
{
|
|
35
|
+
__placeholder__: {
|
|
36
|
+
$regex: `.*${value}.*`,
|
|
37
|
+
$options: 'i',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
__placeholder__: { $oid: value },
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
});
|
|
32
45
|
const testCondition = (operator, value) => () => ({
|
|
33
46
|
__placeholder__: {
|
|
34
47
|
[operator]: value,
|
|
@@ -57,8 +70,10 @@ const createParser = () => {
|
|
|
57
70
|
number: () => common_1.token(parsimmon_1.default.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/))
|
|
58
71
|
.map(Number)
|
|
59
72
|
.desc('number'),
|
|
73
|
+
objectid: () => common_1.token(parsimmon_1.default.regexp(/[0-9a-f]{24}/)).desc('ObjectId'),
|
|
60
74
|
noQuotedString: () => parsimmon_1.default.regexp(/[^\s^,^'^"]+/).desc('string unquoted'),
|
|
61
|
-
value: r => parsimmon_1.default.alt(r.string1, r.string2, r.number, r.noQuotedString),
|
|
75
|
+
value: r => parsimmon_1.default.alt(r.objectid, r.string1, r.string2, r.number, r.noQuotedString),
|
|
76
|
+
valueTestObjectId: r => r.objectid.map(objectIdTestCondition()),
|
|
62
77
|
valueTestNum: r => r.number.map(numberTestCondition()),
|
|
63
78
|
valueTest: r => r.value.map(regexCondition('.*#VALUE#.*')),
|
|
64
79
|
comma: () => common_1.word(','),
|
|
@@ -79,7 +94,7 @@ const createParser = () => {
|
|
|
79
94
|
startsWithNot: r => common_1.word('!^').then(r.value).map(regexCondition('#VALUE#.*')).map(negateCondition),
|
|
80
95
|
endsWithNot: r => common_1.word('!$').then(r.value).map(regexCondition('.*#VALUE#')).map(negateCondition),
|
|
81
96
|
containsNot: r => common_1.word('~').then(r.value).map(regexCondition('.*#VALUE#.*')).map(negateCondition),
|
|
82
|
-
element: r => parsimmon_1.default.alt(r.exists, r.notExists, r.true, r.false, r.eq, r.ne, r.lt, r.gt, r.le, r.ge, r.startsWith, r.endsWith, r.contains, r.startsWithNot, r.endsWithNot, r.containsNot, r.valueTestNum, r.valueTest).trim(common_1.whitespace),
|
|
97
|
+
element: r => parsimmon_1.default.alt(r.exists, r.notExists, r.true, r.false, r.eq, r.ne, r.lt, r.gt, r.le, r.ge, r.startsWith, r.endsWith, r.contains, r.startsWithNot, r.endsWithNot, r.containsNot, r.valueTestObjectId, r.valueTestNum, r.valueTest).trim(common_1.whitespace),
|
|
83
98
|
factor: r => r.element.sepBy(common_1.whitespace).map(compoudCondition('$and')),
|
|
84
99
|
list: r => r.factor.sepBy(r.comma).map(compoudCondition('$or')),
|
|
85
100
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.
|
|
2
|
+
"version": "4.3.0",
|
|
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.
|
|
16
|
+
"dbgate-types": "^4.3.0",
|
|
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.
|
|
25
|
+
"dbgate-tools": "^4.3.0",
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
27
|
"moment": "^2.24.0",
|
|
28
28
|
"parsimmon": "^1.13.0"
|