dbgate-filterparser 5.0.8 → 5.1.1

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.
@@ -154,9 +154,20 @@ const binaryCondition = operator => value => ({
154
154
  value,
155
155
  },
156
156
  });
157
+ const unaryCondition = conditionType => () => {
158
+ return {
159
+ conditionType,
160
+ expr: {
161
+ exprType: 'placeholder',
162
+ },
163
+ };
164
+ };
157
165
  const createParser = () => {
158
166
  const langDef = {
159
167
  comma: () => (0, common_1.word)(','),
168
+ not: () => (0, common_1.word)('NOT'),
169
+ notNull: r => r.not.then(r.null).map(unaryCondition('isNotNull')),
170
+ null: () => (0, common_1.word)('NULL').map(unaryCondition('isNull')),
160
171
  yearNum: () => parsimmon_1.default.regexp(/\d\d\d\d/).map(yearCondition()),
161
172
  yearMonthNum: () => parsimmon_1.default.regexp(/\d\d\d\d-\d\d?/).map(yearMonthCondition()),
162
173
  yearMonthDayNum: () => parsimmon_1.default.regexp(/\d\d\d\d-\d\d?-\d\d?/).map(yearMonthDayCondition()),
@@ -196,7 +207,7 @@ const createParser = () => {
196
207
  ge: r => (0, common_1.word)('>=').then(r.valueStart).map(binaryCondition('>=')),
197
208
  lt: r => (0, common_1.word)('<').then(r.valueStart).map(binaryCondition('<')),
198
209
  gt: r => (0, common_1.word)('>').then(r.valueEnd).map(binaryCondition('>')),
199
- element: r => parsimmon_1.default.alt(r.yearMonthDaySecond, r.yearMonthDayMinute, r.yearMonthDayNum, r.yearMonthNum, r.yearNum, r.yesterday, r.today, r.tomorrow, r.lastWeek, r.thisWeek, r.nextWeek, r.lastMonth, r.thisMonth, r.nextMonth, r.lastYear, r.thisYear, r.nextYear, r.le, r.lt, r.ge, r.gt).trim(common_1.whitespace),
210
+ element: r => parsimmon_1.default.alt(r.yearMonthDaySecond, r.yearMonthDayMinute, r.yearMonthDayNum, r.yearMonthNum, r.yearNum, r.yesterday, r.today, r.tomorrow, r.lastWeek, r.thisWeek, r.nextWeek, r.lastMonth, r.thisMonth, r.nextMonth, r.lastYear, r.thisYear, r.nextYear, r.null, r.notNull, r.le, r.lt, r.ge, r.gt).trim(common_1.whitespace),
200
211
  factor: r => r.element.sepBy(common_1.whitespace).map(compoudCondition('$and')),
201
212
  list: r => r.factor.sepBy(r.comma).map(compoudCondition('$or')),
202
213
  };
@@ -1,3 +1,3 @@
1
1
  export declare type FilterMultipleValuesMode = 'is' | 'is_not' | 'contains' | 'begins' | 'ends';
2
- export declare function getFilterValueExpression(value: any, dataType: any): string;
2
+ export declare function getFilterValueExpression(value: any, dataType?: any): string;
3
3
  export declare function createMultiLineFilter(mode: FilterMultipleValuesMode, text: string): string;
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1 +1 @@
1
- export {};
1
+ declare const parseFilter: any;
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const parseFilter_1 = require("./parseFilter");
1
+ const { parseFilter } = require('./parseFilter');
4
2
  test('parse string', () => {
5
- const ast = (0, parseFilter_1.parseFilter)('"123"', 'string');
3
+ const ast = parseFilter('"123"', 'string');
6
4
  console.log(JSON.stringify(ast));
7
5
  expect(ast).toEqual({
8
6
  conditionType: 'like',
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.0.8",
2
+ "version": "5.1.1",
3
3
  "name": "dbgate-filterparser",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -13,16 +13,16 @@
13
13
  "lib"
14
14
  ],
15
15
  "devDependencies": {
16
- "dbgate-types": "^5.0.8",
16
+ "dbgate-types": "^5.1.1",
17
17
  "@types/jest": "^25.1.4",
18
18
  "@types/node": "^13.7.0",
19
- "jest": "^24.9.0",
20
- "ts-jest": "^25.2.1",
19
+ "jest": "^28.1.3",
20
+ "ts-jest": "^28.0.7",
21
21
  "typescript": "^4.4.3"
22
22
  },
23
23
  "dependencies": {
24
24
  "@types/parsimmon": "^1.10.1",
25
- "dbgate-tools": "^5.0.8",
25
+ "dbgate-tools": "^5.1.1",
26
26
  "lodash": "^4.17.21",
27
27
  "moment": "^2.24.0",
28
28
  "parsimmon": "^1.13.0"