dbgate-tools 6.5.6 → 6.6.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/DatabaseAnalyser.d.ts +3 -3
- package/lib/filterBehaviours.d.ts +1 -0
- package/lib/filterBehaviours.js +26 -2
- package/lib/stringTools.js +53 -0
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DatabaseHandle, DatabaseInfo, DatabaseModification, EngineDriver, SqlDialect } from 'dbgate-types';
|
|
2
2
|
import { type Logger } from 'pinomin';
|
|
3
|
-
export declare class DatabaseAnalyser {
|
|
4
|
-
dbhan: DatabaseHandle
|
|
3
|
+
export declare class DatabaseAnalyser<TClient = any> {
|
|
4
|
+
dbhan: DatabaseHandle<TClient>;
|
|
5
5
|
driver: EngineDriver;
|
|
6
6
|
structure: DatabaseInfo;
|
|
7
7
|
modifications: DatabaseModification[];
|
|
@@ -9,7 +9,7 @@ export declare class DatabaseAnalyser {
|
|
|
9
9
|
singleObjectId: string;
|
|
10
10
|
dialect: SqlDialect;
|
|
11
11
|
logger: Logger;
|
|
12
|
-
constructor(dbhan: DatabaseHandle
|
|
12
|
+
constructor(dbhan: DatabaseHandle<TClient>, driver: EngineDriver, version: any);
|
|
13
13
|
_runAnalysis(): Promise<DatabaseInfo>;
|
|
14
14
|
_getFastSnapshot(): Promise<DatabaseInfo>;
|
|
15
15
|
_computeSingleObjectId(): Promise<void>;
|
|
@@ -5,6 +5,7 @@ export declare const logicalFilterBehaviour: FilterBehaviour;
|
|
|
5
5
|
export declare const datetimeFilterBehaviour: FilterBehaviour;
|
|
6
6
|
export declare const mongoFilterBehaviour: FilterBehaviour;
|
|
7
7
|
export declare const evalFilterBehaviour: FilterBehaviour;
|
|
8
|
+
export declare const firestoreFilterBehaviours: FilterBehaviour;
|
|
8
9
|
export declare const standardFilterBehaviours: {
|
|
9
10
|
[id: string]: FilterBehaviour;
|
|
10
11
|
};
|
package/lib/filterBehaviours.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.standardFilterBehaviours = exports.evalFilterBehaviour = exports.mongoFilterBehaviour = exports.datetimeFilterBehaviour = exports.logicalFilterBehaviour = exports.stringFilterBehaviour = exports.numberFilterBehaviour = void 0;
|
|
3
|
+
exports.standardFilterBehaviours = exports.firestoreFilterBehaviours = exports.evalFilterBehaviour = exports.mongoFilterBehaviour = exports.datetimeFilterBehaviour = exports.logicalFilterBehaviour = exports.stringFilterBehaviour = exports.numberFilterBehaviour = void 0;
|
|
4
4
|
exports.numberFilterBehaviour = {
|
|
5
5
|
supportEquals: true,
|
|
6
6
|
supportNumberLikeComparison: true,
|
|
@@ -21,6 +21,7 @@ exports.stringFilterBehaviour = {
|
|
|
21
21
|
exports.logicalFilterBehaviour = {
|
|
22
22
|
supportBooleanValues: true,
|
|
23
23
|
supportNullTesting: true,
|
|
24
|
+
supportBooleanOrNull: true,
|
|
24
25
|
supportSqlCondition: true,
|
|
25
26
|
};
|
|
26
27
|
exports.datetimeFilterBehaviour = {
|
|
@@ -31,7 +32,8 @@ exports.datetimeFilterBehaviour = {
|
|
|
31
32
|
};
|
|
32
33
|
exports.mongoFilterBehaviour = {
|
|
33
34
|
supportEquals: true,
|
|
34
|
-
|
|
35
|
+
supportEmptyArrayTesting: true,
|
|
36
|
+
supportNotEmptyArrayTesting: true,
|
|
35
37
|
supportNumberLikeComparison: true,
|
|
36
38
|
supportStringInclusion: true,
|
|
37
39
|
supportBooleanValues: true,
|
|
@@ -48,11 +50,33 @@ exports.evalFilterBehaviour = {
|
|
|
48
50
|
supportNullTesting: true,
|
|
49
51
|
allowStringToken: true,
|
|
50
52
|
};
|
|
53
|
+
exports.firestoreFilterBehaviours = {
|
|
54
|
+
supportEquals: true,
|
|
55
|
+
supportEmpty: false,
|
|
56
|
+
supportNumberLikeComparison: true,
|
|
57
|
+
supportDatetimeComparison: false,
|
|
58
|
+
supportNullTesting: true,
|
|
59
|
+
supportBooleanValues: true,
|
|
60
|
+
supportEmptyArrayTesting: true,
|
|
61
|
+
supportStringInclusion: false,
|
|
62
|
+
supportDatetimeSymbols: false,
|
|
63
|
+
supportExistsTesting: false,
|
|
64
|
+
supportSqlCondition: false,
|
|
65
|
+
allowStringToken: true,
|
|
66
|
+
allowNumberToken: true,
|
|
67
|
+
allowHexString: true,
|
|
68
|
+
allowNumberDualTesting: false,
|
|
69
|
+
allowObjectIdTesting: false,
|
|
70
|
+
passBooleans: true,
|
|
71
|
+
passNumbers: true,
|
|
72
|
+
disableOr: true,
|
|
73
|
+
};
|
|
51
74
|
exports.standardFilterBehaviours = {
|
|
52
75
|
numberFilterBehaviour: exports.numberFilterBehaviour,
|
|
53
76
|
stringFilterBehaviour: exports.stringFilterBehaviour,
|
|
54
77
|
logicalFilterBehaviour: exports.logicalFilterBehaviour,
|
|
55
78
|
datetimeFilterBehaviour: exports.datetimeFilterBehaviour,
|
|
56
79
|
mongoFilterBehaviour: exports.mongoFilterBehaviour,
|
|
80
|
+
firestoreFilterBehaviours: exports.firestoreFilterBehaviours,
|
|
57
81
|
evalFilterBehaviour: exports.evalFilterBehaviour,
|
|
58
82
|
};
|
package/lib/stringTools.js
CHANGED
|
@@ -60,6 +60,35 @@ function parseCellValue(value, editorTypes) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseGeopointAsDollar) {
|
|
64
|
+
const m = value.match(/^([\d\.]+)\s*°\s*([NS]),\s*([\d\.]+)\s*°\s*([EW])$/i);
|
|
65
|
+
if (m) {
|
|
66
|
+
let latitude = parseFloat(m[1]);
|
|
67
|
+
const latDir = m[2].toUpperCase();
|
|
68
|
+
let longitude = parseFloat(m[3]);
|
|
69
|
+
const lonDir = m[4].toUpperCase();
|
|
70
|
+
if (latDir === 'S')
|
|
71
|
+
latitude = -latitude;
|
|
72
|
+
if (lonDir === 'W')
|
|
73
|
+
longitude = -longitude;
|
|
74
|
+
return {
|
|
75
|
+
$geoPoint: {
|
|
76
|
+
latitude,
|
|
77
|
+
longitude,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseFsDocumentRefAsDollar) {
|
|
83
|
+
const trimmedValue = value.replace(/\s/g, '');
|
|
84
|
+
if (trimmedValue.startsWith('$ref:')) {
|
|
85
|
+
return {
|
|
86
|
+
$fsDocumentRef: {
|
|
87
|
+
documentPath: trimmedValue.slice(5),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
63
92
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseJsonNull) {
|
|
64
93
|
if (value == 'null')
|
|
65
94
|
return null;
|
|
@@ -140,6 +169,7 @@ function stringifyJsonToGrid(value) {
|
|
|
140
169
|
return { value: '(JSON)', gridStyle: 'nullCellStyle' };
|
|
141
170
|
}
|
|
142
171
|
function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, jsonParsedValue) {
|
|
172
|
+
var _a;
|
|
143
173
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseSqlNull) {
|
|
144
174
|
if (value === null) {
|
|
145
175
|
switch (intent) {
|
|
@@ -214,6 +244,29 @@ function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, j
|
|
|
214
244
|
}
|
|
215
245
|
}
|
|
216
246
|
}
|
|
247
|
+
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseGeopointAsDollar) {
|
|
248
|
+
if (value === null || value === void 0 ? void 0 : value.$geoPoint) {
|
|
249
|
+
const { latitude, longitude } = value.$geoPoint;
|
|
250
|
+
if ((0, isNumber_1.default)(latitude) && (0, isNumber_1.default)(longitude)) {
|
|
251
|
+
const latAbs = Math.abs(latitude);
|
|
252
|
+
const lonAbs = Math.abs(longitude);
|
|
253
|
+
const latDir = latitude >= 0 ? 'N' : 'S';
|
|
254
|
+
const lonDir = longitude >= 0 ? 'E' : 'W';
|
|
255
|
+
return {
|
|
256
|
+
value: `${latAbs}° ${latDir}, ${lonAbs}° ${lonDir}`,
|
|
257
|
+
gridStyle: 'valueCellStyle',
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseFsDocumentRefAsDollar) {
|
|
263
|
+
if (value === null || value === void 0 ? void 0 : value.$fsDocumentRef) {
|
|
264
|
+
return {
|
|
265
|
+
value: `$ref: ${(_a = value.$fsDocumentRef.documentPath) !== null && _a !== void 0 ? _a : ''}`,
|
|
266
|
+
gridStyle: 'valueCellStyle',
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
217
270
|
if ((0, isArray_1.default)(value)) {
|
|
218
271
|
switch (intent) {
|
|
219
272
|
case 'gridCellIntent':
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "6.
|
|
2
|
+
"version": "6.6.0",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^13.7.0",
|
|
29
|
-
"dbgate-types": "^6.
|
|
29
|
+
"dbgate-types": "^6.6.0",
|
|
30
30
|
"jest": "^28.1.3",
|
|
31
31
|
"ts-jest": "^28.0.7",
|
|
32
32
|
"typescript": "^4.4.3"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"dbgate-query-splitter": "^4.11.5",
|
|
36
|
-
"dbgate-sqltree": "^6.
|
|
36
|
+
"dbgate-sqltree": "^6.6.0",
|
|
37
37
|
"debug": "^4.3.4",
|
|
38
38
|
"json-stable-stringify": "^1.0.1",
|
|
39
39
|
"lodash": "^4.17.21",
|