dbgate-filterparser 5.2.1 → 5.2.2-alpha.12

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/filterTool.js CHANGED
@@ -17,6 +17,9 @@ function getFilterValueExpression(value, dataType) {
17
17
  return 'FALSE';
18
18
  if (value.$oid)
19
19
  return `ObjectId("${value.$oid}")`;
20
+ if (value.type == 'Buffer' && Array.isArray(value.data)) {
21
+ return '0x' + (0, dbgate_tools_1.arrayToHexString)(value.data);
22
+ }
20
23
  return `="${value}"`;
21
24
  }
22
25
  exports.getFilterValueExpression = getFilterValueExpression;
@@ -8,6 +8,7 @@ const parsimmon_1 = __importDefault(require("parsimmon"));
8
8
  const common_1 = require("./common");
9
9
  const mongoParser_1 = require("./mongoParser");
10
10
  const datetimeParser_1 = require("./datetimeParser");
11
+ const dbgate_tools_1 = require("dbgate-tools");
11
12
  const binaryCondition = operator => value => ({
12
13
  conditionType: 'binary',
13
14
  operator,
@@ -90,12 +91,19 @@ const createParser = (filterType) => {
90
91
  number: () => (0, common_1.token)(parsimmon_1.default.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/))
91
92
  .map(Number)
92
93
  .desc('number'),
94
+ hexstring: () => (0, common_1.token)(parsimmon_1.default.regexp(/0x(([0-9a-fA-F][0-9a-fA-F])+)/, 1))
95
+ .map(x => ({
96
+ type: 'Buffer',
97
+ data: (0, dbgate_tools_1.hexStringToArray)(x),
98
+ }))
99
+ .desc('hex string'),
93
100
  noQuotedString: () => parsimmon_1.default.regexp(/[^\s^,^'^"]+/).desc('string unquoted'),
94
101
  sql: () => (0, common_1.token)(parsimmon_1.default.regexp(/\{(.*?)\}/, 1))
95
102
  .map(sqlTemplate)
96
103
  .desc('sql literal'),
97
104
  value: r => parsimmon_1.default.alt(...allowedValues.map(x => r[x])),
98
105
  valueTestEq: r => r.value.map(binaryCondition('=')),
106
+ hexTestEq: r => r.hexstring.map(binaryCondition('=')),
99
107
  valueTestStr: r => r.value.map(likeCondition('like', '%#VALUE#%')),
100
108
  comma: () => (0, common_1.word)(','),
101
109
  not: () => (0, common_1.word)('NOT'),
@@ -136,7 +144,7 @@ const createParser = (filterType) => {
136
144
  allowedElements.push('le', 'ge', 'lt', 'gt');
137
145
  }
138
146
  if (filterType == 'string') {
139
- allowedElements.push('empty', 'notEmpty');
147
+ allowedElements.push('empty', 'notEmpty', 'hexTestEq');
140
148
  }
141
149
  if (filterType == 'eval' || filterType == 'string') {
142
150
  allowedElements.push('startsWith', 'endsWith', 'contains', 'startsWithNot', 'endsWithNot', 'containsNot');
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.2.1",
2
+ "version": "5.2.2-alpha.12",
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": "^5.2.1",
16
+ "dbgate-types": "^5.2.2-alpha.12",
17
17
  "@types/jest": "^25.1.4",
18
18
  "@types/node": "^13.7.0",
19
19
  "jest": "^28.1.3",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@types/parsimmon": "^1.10.1",
25
- "dbgate-tools": "^5.2.1",
25
+ "dbgate-tools": "^5.2.2-alpha.12",
26
26
  "lodash": "^4.17.21",
27
27
  "moment": "^2.24.0",
28
28
  "parsimmon": "^1.13.0"