@elliemae/ds-query-builder 1.60.0 → 2.0.0-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/cjs/DSQueryBuilder.js +58 -151
- package/cjs/components/AndOrController/AndOrController.js +126 -162
- package/cjs/components/ConditionController/ConditionController.js +40 -60
- package/cjs/components/DisplayOutput/DisplayOutput.js +62 -83
- package/cjs/components/DragContainerController/DragContainerController.js +20 -21
- package/cjs/components/DragControllerRow/DragControllerRow.js +33 -23
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +14 -19
- package/cjs/components/Nestable/Nestable.js +243 -283
- package/cjs/components/Nestable/NestableItem.js +61 -52
- package/cjs/components/Nestable/actions/events.js +53 -35
- package/cjs/components/Nestable/actions/getItemOptions.js +14 -12
- package/cjs/components/Nestable/actions/getPaths.js +46 -38
- package/cjs/components/Nestable/actions/index.js +21 -26
- package/cjs/components/Nestable/actions/moveItem.js +26 -16
- package/cjs/components/Nestable/actions/paths.js +48 -40
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +12 -12
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +14 -14
- package/cjs/components/Nestable/index.js +2 -25
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +1 -2
- package/cjs/components/QueryBuilderImpl.js +216 -283
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +59 -77
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +154 -174
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +16 -11
- package/cjs/components/format/format.js +27 -39
- package/cjs/components/format/sqlFormat.js +35 -32
- package/cjs/components/format/sqlSafeFormat.js +38 -35
- package/cjs/components/format/xmlFormat.js +35 -32
- package/cjs/components/helpers/actions.js +108 -93
- package/cjs/components/helpers/constants.js +3 -4
- package/cjs/components/helpers/dependencies.js +36 -26
- package/cjs/components/helpers/selectors.js +18 -19
- package/cjs/components/helpers/store.js +87 -109
- package/cjs/components/helpers/types.js +9 -10
- package/cjs/index.js +19 -76
- package/cjs/propTypes.js +4 -5
- package/esm/DSQueryBuilder.js +37 -130
- package/esm/components/AndOrController/AndOrController.js +120 -152
- package/esm/components/ConditionController/ConditionController.js +37 -57
- package/esm/components/DisplayOutput/DisplayOutput.js +61 -76
- package/esm/components/DragContainerController/DragContainerController.js +20 -21
- package/esm/components/DragControllerRow/DragControllerRow.js +27 -17
- package/esm/components/FieldControllerRow/FieldControllerRow.js +13 -18
- package/esm/components/Nestable/Nestable.js +235 -268
- package/esm/components/Nestable/NestableItem.js +58 -48
- package/esm/components/Nestable/actions/events.js +52 -34
- package/esm/components/Nestable/actions/getItemOptions.js +14 -12
- package/esm/components/Nestable/actions/getPaths.js +46 -33
- package/esm/components/Nestable/actions/index.js +0 -5
- package/esm/components/Nestable/actions/moveItem.js +23 -13
- package/esm/components/Nestable/actions/paths.js +48 -35
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +12 -12
- package/esm/components/Nestable/actions/tryIncreaseDepth.js +14 -14
- package/esm/components/Nestable/index.js +0 -23
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +1 -2
- package/esm/components/QueryBuilderImpl.js +204 -265
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +52 -70
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +149 -164
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +16 -10
- package/esm/components/format/format.js +19 -27
- package/esm/components/format/sqlFormat.js +34 -31
- package/esm/components/format/sqlSafeFormat.js +37 -34
- package/esm/components/format/xmlFormat.js +34 -31
- package/esm/components/helpers/actions.js +100 -85
- package/esm/components/helpers/constants.js +3 -4
- package/esm/components/helpers/dependencies.js +33 -21
- package/esm/components/helpers/selectors.js +5 -6
- package/esm/components/helpers/store.js +84 -104
- package/esm/components/helpers/types.js +9 -10
- package/esm/index.js +0 -57
- package/esm/propTypes.js +1 -2
- package/package.json +173 -15
- package/types/DSQueryBuilder.d.ts +211 -0
- package/types/components/AndOrController/AndOrController.d.ts +38 -0
- package/types/components/ConditionController/ConditionController.d.ts +16 -0
- package/types/components/DisplayOutput/DisplayOutput.d.ts +7 -0
- package/types/components/DragContainerController/DragContainerController.d.ts +9 -0
- package/types/components/DragControllerRow/DragControllerRow.d.ts +9 -0
- package/types/components/FieldControllerRow/FieldControllerRow.d.ts +9 -0
- package/types/components/Nestable/Nestable.d.ts +51 -0
- package/types/components/Nestable/NestableItem.d.ts +12 -0
- package/types/components/Nestable/actions/events.d.ts +6 -0
- package/types/components/Nestable/actions/getItemOptions.d.ts +11 -0
- package/types/components/Nestable/actions/getPaths.d.ts +5 -0
- package/types/components/Nestable/actions/index.d.ts +6 -0
- package/types/components/Nestable/actions/moveItem.d.ts +5 -0
- package/types/components/Nestable/actions/paths.d.ts +5 -0
- package/types/components/Nestable/actions/tryDecreaseDepth.d.ts +1 -0
- package/types/components/Nestable/actions/tryIncreaseDepth.d.ts +1 -0
- package/types/components/Nestable/index.d.ts +2 -0
- package/types/components/QueryBuilderContext/QueryBuilderContext.d.ts +2 -0
- package/types/components/QueryBuilderImpl.d.ts +49 -0
- package/types/components/QueryBuilderItem/QueryBuilderItem.d.ts +5 -0
- package/types/components/QueryBuilderRow/QueryBuilderRow.d.ts +12 -0
- package/types/components/ToolBarAnimation/ToolBarAnimation.d.ts +3 -0
- package/types/components/format/format.d.ts +26 -0
- package/types/components/format/sqlFormat.d.ts +5 -0
- package/types/components/format/sqlSafeFormat.d.ts +6 -0
- package/types/components/format/xmlFormat.d.ts +5 -0
- package/types/components/helpers/actions.d.ts +63 -0
- package/types/components/helpers/constants.d.ts +3 -0
- package/types/components/helpers/dependencies.d.ts +1 -0
- package/types/components/helpers/selectors.d.ts +20 -0
- package/types/components/helpers/store.d.ts +144 -0
- package/types/components/helpers/types.d.ts +50 -0
- package/types/index.d.ts +2 -0
- package/types/propTypes.d.ts +156 -0
- package/DSQueryBuilder/package.json +0 -10
- package/cjs/DSQueryBuilder.js.map +0 -1
- package/cjs/components/AndOrController/AndOrController.js.map +0 -1
- package/cjs/components/ConditionController/ConditionController.js.map +0 -1
- package/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -1
- package/cjs/components/DragContainerController/DragContainerController.js.map +0 -1
- package/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -1
- package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -1
- package/cjs/components/Nestable/Nestable.js.map +0 -1
- package/cjs/components/Nestable/NestableItem.js.map +0 -1
- package/cjs/components/Nestable/actions/events.js.map +0 -1
- package/cjs/components/Nestable/actions/getItemOptions.js.map +0 -1
- package/cjs/components/Nestable/actions/getPaths.js.map +0 -1
- package/cjs/components/Nestable/actions/index.js.map +0 -1
- package/cjs/components/Nestable/actions/moveItem.js.map +0 -1
- package/cjs/components/Nestable/actions/paths.js.map +0 -1
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -1
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -1
- package/cjs/components/Nestable/index.js.map +0 -1
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -1
- package/cjs/components/QueryBuilderImpl.js.map +0 -1
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -1
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -1
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -1
- package/cjs/components/format/format.js.map +0 -1
- package/cjs/components/format/sqlFormat.js.map +0 -1
- package/cjs/components/format/sqlSafeFormat.js.map +0 -1
- package/cjs/components/format/xmlFormat.js.map +0 -1
- package/cjs/components/helpers/actions.js.map +0 -1
- package/cjs/components/helpers/constants.js.map +0 -1
- package/cjs/components/helpers/dependencies.js.map +0 -1
- package/cjs/components/helpers/selectors.js.map +0 -1
- package/cjs/components/helpers/store.js.map +0 -1
- package/cjs/components/helpers/types.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/propTypes.js.map +0 -1
- package/components/AndOrController/AndOrController/package.json +0 -10
- package/components/ConditionController/ConditionController/package.json +0 -10
- package/components/DisplayOutput/DisplayOutput/package.json +0 -10
- package/components/DragContainerController/DragContainerController/package.json +0 -10
- package/components/DragControllerRow/DragControllerRow/package.json +0 -10
- package/components/FieldControllerRow/FieldControllerRow/package.json +0 -10
- package/components/Nestable/Nestable/package.json +0 -10
- package/components/Nestable/NestableItem/package.json +0 -10
- package/components/Nestable/actions/events/package.json +0 -10
- package/components/Nestable/actions/getItemOptions/package.json +0 -10
- package/components/Nestable/actions/getPaths/package.json +0 -10
- package/components/Nestable/actions/moveItem/package.json +0 -10
- package/components/Nestable/actions/package.json +0 -10
- package/components/Nestable/actions/paths/package.json +0 -10
- package/components/Nestable/actions/tryDecreaseDepth/package.json +0 -10
- package/components/Nestable/actions/tryIncreaseDepth/package.json +0 -10
- package/components/Nestable/package.json +0 -10
- package/components/QueryBuilderContext/QueryBuilderContext/package.json +0 -10
- package/components/QueryBuilderImpl/package.json +0 -10
- package/components/QueryBuilderItem/QueryBuilderItem/package.json +0 -10
- package/components/QueryBuilderRow/QueryBuilderRow/package.json +0 -10
- package/components/ToolBarAnimation/ToolBarAnimation/package.json +0 -10
- package/components/format/format/package.json +0 -10
- package/components/format/sqlFormat/package.json +0 -10
- package/components/format/sqlSafeFormat/package.json +0 -10
- package/components/format/xmlFormat/package.json +0 -10
- package/components/helpers/actions/package.json +0 -10
- package/components/helpers/constants/package.json +0 -10
- package/components/helpers/dependencies/package.json +0 -10
- package/components/helpers/selectors/package.json +0 -10
- package/components/helpers/store/package.json +0 -10
- package/components/helpers/types/package.json +0 -10
- package/esm/DSQueryBuilder.js.map +0 -1
- package/esm/components/AndOrController/AndOrController.js.map +0 -1
- package/esm/components/ConditionController/ConditionController.js.map +0 -1
- package/esm/components/DisplayOutput/DisplayOutput.js.map +0 -1
- package/esm/components/DragContainerController/DragContainerController.js.map +0 -1
- package/esm/components/DragControllerRow/DragControllerRow.js.map +0 -1
- package/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -1
- package/esm/components/Nestable/Nestable.js.map +0 -1
- package/esm/components/Nestable/NestableItem.js.map +0 -1
- package/esm/components/Nestable/actions/events.js.map +0 -1
- package/esm/components/Nestable/actions/getItemOptions.js.map +0 -1
- package/esm/components/Nestable/actions/getPaths.js.map +0 -1
- package/esm/components/Nestable/actions/index.js.map +0 -1
- package/esm/components/Nestable/actions/moveItem.js.map +0 -1
- package/esm/components/Nestable/actions/paths.js.map +0 -1
- package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -1
- package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -1
- package/esm/components/Nestable/index.js.map +0 -1
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -1
- package/esm/components/QueryBuilderImpl.js.map +0 -1
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -1
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -1
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -1
- package/esm/components/format/format.js.map +0 -1
- package/esm/components/format/sqlFormat.js.map +0 -1
- package/esm/components/format/sqlSafeFormat.js.map +0 -1
- package/esm/components/format/xmlFormat.js.map +0 -1
- package/esm/components/helpers/actions.js.map +0 -1
- package/esm/components/helpers/constants.js.map +0 -1
- package/esm/components/helpers/dependencies.js.map +0 -1
- package/esm/components/helpers/selectors.js.map +0 -1
- package/esm/components/helpers/store.js.map +0 -1
- package/esm/components/helpers/types.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/propTypes.js.map +0 -1
- package/propTypes/package.json +0 -10
|
@@ -1,45 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
this.addFormat = function (formatName, format) {
|
|
33
|
-
return _this.format[formatName] = format;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
this.run = function (query, formatName) {
|
|
37
|
-
if (_this.format[formatName]) return _this.format[formatName](query);
|
|
38
|
-
return _this.format[_this.currentFormat](query);
|
|
39
|
-
};
|
|
40
|
-
};
|
|
3
|
+
var sqlFormat = require('./sqlFormat.js');
|
|
4
|
+
var xmlFormat = require('./xmlFormat.js');
|
|
5
|
+
var sqlSafeFormat = require('./sqlSafeFormat.js');
|
|
6
|
+
|
|
7
|
+
class QueryBuilderFormat {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.format = {
|
|
10
|
+
defaultFormat: query => query,
|
|
11
|
+
sqlFormat: sqlFormat.sqlFormat,
|
|
12
|
+
xmlFormat: xmlFormat.xmlFormat,
|
|
13
|
+
sqlSafeFormat: sqlSafeFormat.sqlSafeFormat
|
|
14
|
+
};
|
|
15
|
+
this.currentFormat = 'sqlFormat';
|
|
16
|
+
|
|
17
|
+
this.setDefaultFormat = formatName => {
|
|
18
|
+
if (this.format[formatName]) this.currentFormat = formatName;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
this.addFormat = (formatName, format) => this.format[formatName] = format;
|
|
22
|
+
|
|
23
|
+
this.run = (query, formatName) => {
|
|
24
|
+
if (this.format[formatName]) return this.format[formatName](query);
|
|
25
|
+
return this.format[this.currentFormat](query);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
41
30
|
|
|
42
31
|
var QueryBuilderFormat$1 = new QueryBuilderFormat();
|
|
43
32
|
|
|
44
33
|
module.exports = QueryBuilderFormat$1;
|
|
45
|
-
//# sourceMappingURL=format.js.map
|
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
+
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const conditionSql = (condition, value) => {
|
|
10
|
+
const {
|
|
11
|
+
EQUAL,
|
|
12
|
+
NOT_EQUAL,
|
|
13
|
+
GREATER_THAN,
|
|
14
|
+
LESS_THAN,
|
|
15
|
+
CONTAINS,
|
|
16
|
+
NOT_CONTAINS,
|
|
17
|
+
BETWEEN,
|
|
18
|
+
GREATER_THAN_OR_EQUAL,
|
|
19
|
+
LESS_THAN_OR_EQUAL,
|
|
20
|
+
START_WITH
|
|
21
|
+
} = types.QB_OPERATOR_TYPES;
|
|
20
22
|
if (condition === EQUAL) return " = '".concat(value, "'");
|
|
21
23
|
if (condition === NOT_EQUAL) return " <> '".concat(value, "'");
|
|
22
24
|
if (condition === GREATER_THAN) return " > ".concat(value);
|
|
@@ -30,41 +32,42 @@ var conditionSql = function conditionSql(condition, value) {
|
|
|
30
32
|
return condition;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const renderFilterSQl = filter => {
|
|
36
|
+
const {
|
|
37
|
+
field,
|
|
38
|
+
operator,
|
|
39
|
+
value
|
|
40
|
+
} = filter.element;
|
|
38
41
|
return "".concat(field, " ").concat(conditionSql(operator, value) || '');
|
|
39
42
|
};
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
const sqlFormat = _ref => {
|
|
45
|
+
let {
|
|
46
|
+
main,
|
|
47
|
+
mapGroups,
|
|
48
|
+
items
|
|
49
|
+
} = _ref;
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
const groupSql = (item, idGroup) => {
|
|
47
52
|
if (idGroup === main) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return " ( ".concat(filterSql(item, _groupCondition), " ) "); // eslint-disable-line
|
|
53
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
54
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
54
58
|
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
55
59
|
};
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
const filterSql = (filters, groupCondition) => {
|
|
62
|
+
const filterGroup = filters.map(filter => {
|
|
59
63
|
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
60
64
|
return " ".concat(groupSql(filter) || '', " ");
|
|
61
65
|
});
|
|
62
66
|
return filterGroup.join(groupCondition);
|
|
63
67
|
};
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
66
70
|
return sql;
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
exports.sqlFormat = sqlFormat;
|
|
70
|
-
//# sourceMappingURL=sqlFormat.js.map
|
|
@@ -2,25 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
+
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
const specialChar = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
const conditionSql = (condition, value) => {
|
|
12
|
+
const {
|
|
13
|
+
EQUAL,
|
|
14
|
+
NOT_EQUAL,
|
|
15
|
+
GREATER_THAN,
|
|
16
|
+
LESS_THAN,
|
|
17
|
+
CONTAINS,
|
|
18
|
+
NOT_CONTAINS,
|
|
19
|
+
BETWEEN,
|
|
20
|
+
GREATER_THAN_OR_EQUAL,
|
|
21
|
+
LESS_THAN_OR_EQUAL,
|
|
22
|
+
START_WITH
|
|
23
|
+
} = types.QB_OPERATOR_TYPES; // eslint-disable-next-line no-restricted-globals
|
|
10
24
|
|
|
11
|
-
|
|
12
|
-
var EQUAL = components_helpers_types.QB_OPERATOR_TYPES.EQUAL,
|
|
13
|
-
NOT_EQUAL = components_helpers_types.QB_OPERATOR_TYPES.NOT_EQUAL,
|
|
14
|
-
GREATER_THAN = components_helpers_types.QB_OPERATOR_TYPES.GREATER_THAN,
|
|
15
|
-
LESS_THAN = components_helpers_types.QB_OPERATOR_TYPES.LESS_THAN,
|
|
16
|
-
CONTAINS = components_helpers_types.QB_OPERATOR_TYPES.CONTAINS,
|
|
17
|
-
NOT_CONTAINS = components_helpers_types.QB_OPERATOR_TYPES.NOT_CONTAINS,
|
|
18
|
-
BETWEEN = components_helpers_types.QB_OPERATOR_TYPES.BETWEEN,
|
|
19
|
-
GREATER_THAN_OR_EQUAL = components_helpers_types.QB_OPERATOR_TYPES.GREATER_THAN_OR_EQUAL,
|
|
20
|
-
LESS_THAN_OR_EQUAL = components_helpers_types.QB_OPERATOR_TYPES.LESS_THAN_OR_EQUAL,
|
|
21
|
-
START_WITH = components_helpers_types.QB_OPERATOR_TYPES.START_WITH; // eslint-disable-next-line no-restricted-globals
|
|
22
|
-
|
|
23
|
-
var valueDisplay = isNaN(value) ? "'".concat(value, "'") : value;
|
|
25
|
+
const valueDisplay = isNaN(value) ? "'".concat(value, "'") : value;
|
|
24
26
|
if (condition === EQUAL) return " = ".concat(valueDisplay);
|
|
25
27
|
if (condition === NOT_EQUAL) return " <> ".concat(valueDisplay);
|
|
26
28
|
if (condition === GREATER_THAN) return " > ".concat(valueDisplay);
|
|
@@ -34,45 +36,46 @@ var conditionSql = function conditionSql(condition, value) {
|
|
|
34
36
|
return condition;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const renderFilterSQl = filter => {
|
|
40
|
+
const {
|
|
41
|
+
field,
|
|
42
|
+
operator,
|
|
43
|
+
value
|
|
44
|
+
} = filter.element; // eslint-disable-next-line no-restricted-globals
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
const fieldDisplay = // eslint-disable-next-line no-restricted-globals
|
|
44
47
|
/[.]/.test(field) || !isNaN(field) ? "\\\"".concat(field, "\\\"") : field;
|
|
45
48
|
return "".concat(fieldDisplay, " ").concat(conditionSql(operator, value) || '');
|
|
46
49
|
};
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const sqlSafeFormat = _ref => {
|
|
52
|
+
let {
|
|
53
|
+
main,
|
|
54
|
+
mapGroups,
|
|
55
|
+
items
|
|
56
|
+
} = _ref;
|
|
52
57
|
|
|
53
|
-
|
|
58
|
+
const groupSql = (item, idGroup) => {
|
|
54
59
|
if (idGroup === main) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return " ( ".concat(filterSql(item, _groupCondition), " ) "); // eslint-disable-line
|
|
60
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
61
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
61
65
|
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
62
66
|
};
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
const filterSql = (filters, groupCondition) => {
|
|
69
|
+
const filterGroup = filters.map(filter => {
|
|
66
70
|
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
67
71
|
return " ".concat(groupSql(filter) || '', " ");
|
|
68
72
|
});
|
|
69
73
|
return filterGroup.join(groupCondition);
|
|
70
74
|
};
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
73
77
|
return sql;
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
exports.specialChar = specialChar;
|
|
77
81
|
exports.sqlSafeFormat = sqlSafeFormat;
|
|
78
|
-
//# sourceMappingURL=sqlSafeFormat.js.map
|
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
+
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const conditionSql = (condition, value) => {
|
|
10
|
+
const {
|
|
11
|
+
EQUAL,
|
|
12
|
+
NOT_EQUAL,
|
|
13
|
+
GREATER_THAN,
|
|
14
|
+
LESS_THAN,
|
|
15
|
+
CONTAINS,
|
|
16
|
+
NOT_CONTAINS,
|
|
17
|
+
BETWEEN,
|
|
18
|
+
GREATER_THAN_OR_EQUAL,
|
|
19
|
+
LESS_THAN_OR_EQUAL,
|
|
20
|
+
START_WITH
|
|
21
|
+
} = types.QB_OPERATOR_TYPES;
|
|
20
22
|
if (condition === EQUAL) return "<condition>EQUAL</condition><value>".concat(value, "</value>");
|
|
21
23
|
if (condition === NOT_EQUAL) return "<condition>NOT_EQUAL</condition><value>".concat(value, "</value>");
|
|
22
24
|
if (condition === GREATER_THAN) return "<condition>GREATER_THAN</condition><value>".concat(value, "</value>");
|
|
@@ -30,41 +32,42 @@ var conditionSql = function conditionSql(condition, value) {
|
|
|
30
32
|
return condition;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const renderFilterSQl = filter => {
|
|
36
|
+
const {
|
|
37
|
+
field,
|
|
38
|
+
operator,
|
|
39
|
+
value
|
|
40
|
+
} = filter.element;
|
|
38
41
|
return "<filter><field>".concat(field, "</field>").concat(conditionSql(operator, value) || '', "</filter>");
|
|
39
42
|
};
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
const xmlFormat = _ref => {
|
|
45
|
+
let {
|
|
46
|
+
main,
|
|
47
|
+
mapGroups,
|
|
48
|
+
items
|
|
49
|
+
} = _ref;
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
const groupXML = (item, idGroup) => {
|
|
47
52
|
if (idGroup === main) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return "<group value=\"".concat(_groupCondition, "\">").concat(filterXML(item), "</group>"); // eslint-disable-line
|
|
53
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
54
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item), "</group>"); // eslint-disable-line
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
54
58
|
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item.children), "</group>"); // eslint-disable-line
|
|
55
59
|
};
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
const filterXML = filters => {
|
|
62
|
+
const filterGroup = filters.map(filter => {
|
|
59
63
|
if (filter.element.type === 'filter') return "".concat(renderFilterSQl(filter) || '', " ");
|
|
60
64
|
return " ".concat(groupXML(filter), " ");
|
|
61
65
|
});
|
|
62
66
|
return filterGroup.join('');
|
|
63
67
|
};
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
const xml = "<xml><query>".concat(groupXML(items, main) || '', "</query></xml>");
|
|
66
70
|
return xml;
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
exports.xmlFormat = xmlFormat;
|
|
70
|
-
//# sourceMappingURL=xmlFormat.js.map
|