dbgate-tools 4.7.3 → 4.7.4-alpha.3
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/createBulkInsertStreamBase.js +1 -1
- package/lib/driverBase.d.ts +2 -0
- package/lib/driverBase.js +57 -2
- package/lib/stringTools.d.ts +1 -0
- package/lib/stringTools.js +26 -1
- package/package.json +4 -3
|
@@ -25,7 +25,7 @@ function createBulkInsertStreamBase(driver, stream, pool, name, options) {
|
|
|
25
25
|
writable.buffer = [];
|
|
26
26
|
writable.structure = null;
|
|
27
27
|
writable.columnNames = null;
|
|
28
|
-
writable.requireFixedStructure =
|
|
28
|
+
writable.requireFixedStructure = driver.databaseEngineTypes.includes('sql');
|
|
29
29
|
writable.addRow = (row) => __awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
if (writable.structure) {
|
|
31
31
|
writable.buffer.push(row);
|
package/lib/driverBase.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const driverBase: {
|
|
|
14
14
|
isPersisted: boolean;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
+
databaseEngineTypes: string[];
|
|
17
18
|
analyseFull(pool: any, version: any): Promise<any>;
|
|
18
19
|
analyseSingleObject(pool: any, name: any, typeField?: string): Promise<any>;
|
|
19
20
|
analyseSingleTable(pool: any, name: any): any;
|
|
@@ -24,4 +25,5 @@ export declare const driverBase: {
|
|
|
24
25
|
label: string;
|
|
25
26
|
sql: string;
|
|
26
27
|
}[];
|
|
28
|
+
loadFieldValues(pool: any, name: any, columnName: any, search: any): Promise<any>;
|
|
27
29
|
};
|
package/lib/driverBase.js
CHANGED
|
@@ -8,10 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.driverBase = void 0;
|
|
16
|
+
const compact_1 = __importDefault(require("lodash/compact"));
|
|
13
17
|
const SqlDumper_1 = require("./SqlDumper");
|
|
14
18
|
const dbgate_query_splitter_1 = require("dbgate-query-splitter");
|
|
19
|
+
const dbgate_sqltree_1 = require("dbgate-sqltree");
|
|
15
20
|
const dialect = {
|
|
16
21
|
limitSelect: true,
|
|
17
22
|
rangeSelect: true,
|
|
@@ -30,6 +35,7 @@ exports.driverBase = {
|
|
|
30
35
|
analyserClass: null,
|
|
31
36
|
dumperClass: SqlDumper_1.SqlDumper,
|
|
32
37
|
dialect,
|
|
38
|
+
databaseEngineTypes: ['sql'],
|
|
33
39
|
analyseFull(pool, version) {
|
|
34
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
41
|
const analyser = new this.analyserClass(pool, this, version);
|
|
@@ -62,10 +68,59 @@ exports.driverBase = {
|
|
|
62
68
|
});
|
|
63
69
|
},
|
|
64
70
|
getNewObjectTemplates() {
|
|
65
|
-
|
|
66
|
-
if (!((_a = this.dialect) === null || _a === void 0 ? void 0 : _a.nosql)) {
|
|
71
|
+
if (this.databaseEngineTypes.includes('sql')) {
|
|
67
72
|
return [{ label: 'New view', sql: 'CREATE VIEW myview\nAS\nSELECT * FROM table1' }];
|
|
68
73
|
}
|
|
69
74
|
return [];
|
|
70
75
|
},
|
|
76
|
+
loadFieldValues(pool, name, columnName, search) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const dmp = this.createDumper();
|
|
79
|
+
const select = {
|
|
80
|
+
commandType: 'select',
|
|
81
|
+
distinct: true,
|
|
82
|
+
topRecords: 100,
|
|
83
|
+
from: {
|
|
84
|
+
name,
|
|
85
|
+
},
|
|
86
|
+
columns: [
|
|
87
|
+
{
|
|
88
|
+
exprType: 'column',
|
|
89
|
+
columnName,
|
|
90
|
+
alias: 'value',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
orderBy: [
|
|
94
|
+
{
|
|
95
|
+
exprType: 'column',
|
|
96
|
+
columnName,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
if (search) {
|
|
101
|
+
const tokens = (0, compact_1.default)(search.split(' ').map(x => x.trim()));
|
|
102
|
+
if (tokens.length > 0) {
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
select.where = {
|
|
105
|
+
conditionType: 'and',
|
|
106
|
+
conditions: tokens.map(token => ({
|
|
107
|
+
conditionType: 'like',
|
|
108
|
+
left: {
|
|
109
|
+
exprType: 'column',
|
|
110
|
+
columnName,
|
|
111
|
+
},
|
|
112
|
+
right: {
|
|
113
|
+
exprType: 'value',
|
|
114
|
+
value: `%${token}%`,
|
|
115
|
+
},
|
|
116
|
+
})),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
(0, dbgate_sqltree_1.dumpSqlSelect)(dmp, select);
|
|
122
|
+
const resp = yield this.query(pool, dmp.s);
|
|
123
|
+
return resp.rows;
|
|
124
|
+
});
|
|
125
|
+
},
|
|
71
126
|
};
|
package/lib/stringTools.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare function parseCellValue(value: any): any;
|
|
|
4
4
|
export declare function stringifyCellValue(value: any): any;
|
|
5
5
|
export declare function safeJsonParse(json: any, defaultValue?: any, logError?: boolean): any;
|
|
6
6
|
export declare function isJsonLikeLongString(value: any): RegExpMatchArray;
|
|
7
|
+
export declare function getIconForRedisType(type: any): "img folder" | "img type-string" | "img type-hash" | "img type-set" | "img type-list" | "img type-zset" | "img type-stream" | "img type-binary" | "img type-rejson";
|
package/lib/stringTools.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isJsonLikeLongString = exports.safeJsonParse = exports.stringifyCellValue = exports.parseCellValue = exports.hexStringToArray = exports.arrayToHexString = void 0;
|
|
6
|
+
exports.getIconForRedisType = exports.isJsonLikeLongString = exports.safeJsonParse = exports.stringifyCellValue = exports.parseCellValue = exports.hexStringToArray = exports.arrayToHexString = void 0;
|
|
7
7
|
const isString_1 = __importDefault(require("lodash/isString"));
|
|
8
8
|
const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
9
9
|
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
@@ -69,3 +69,28 @@ function isJsonLikeLongString(value) {
|
|
|
69
69
|
return (0, isString_1.default)(value) && value.length > 100 && value.match(/^\s*\{.*\}\s*$|^\s*\[.*\]\s*$/);
|
|
70
70
|
}
|
|
71
71
|
exports.isJsonLikeLongString = isJsonLikeLongString;
|
|
72
|
+
function getIconForRedisType(type) {
|
|
73
|
+
switch (type) {
|
|
74
|
+
case 'dir':
|
|
75
|
+
return 'img folder';
|
|
76
|
+
case 'string':
|
|
77
|
+
return 'img type-string';
|
|
78
|
+
case 'hash':
|
|
79
|
+
return 'img type-hash';
|
|
80
|
+
case 'set':
|
|
81
|
+
return 'img type-set';
|
|
82
|
+
case 'list':
|
|
83
|
+
return 'img type-list';
|
|
84
|
+
case 'zset':
|
|
85
|
+
return 'img type-zset';
|
|
86
|
+
case 'stream':
|
|
87
|
+
return 'img type-stream';
|
|
88
|
+
case 'binary':
|
|
89
|
+
return 'img type-binary';
|
|
90
|
+
case 'ReJSON-RL':
|
|
91
|
+
return 'img type-rejson';
|
|
92
|
+
default:
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.getIconForRedisType = getIconForRedisType;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.7.3",
|
|
2
|
+
"version": "4.7.4-alpha.3",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -25,14 +25,15 @@
|
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^13.7.0",
|
|
28
|
-
"dbgate-types": "^4.7.3",
|
|
28
|
+
"dbgate-types": "^4.7.4-alpha.3",
|
|
29
29
|
"jest": "^24.9.0",
|
|
30
30
|
"ts-jest": "^25.2.1",
|
|
31
31
|
"typescript": "^4.4.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
|
-
"dbgate-query-splitter": "^4.7.3",
|
|
35
|
+
"dbgate-query-splitter": "^4.7.4-alpha.3",
|
|
36
|
+
"dbgate-sqltree": "^4.7.4-alpha.3",
|
|
36
37
|
"uuid": "^3.4.0"
|
|
37
38
|
}
|
|
38
39
|
}
|