dbgate-tools 5.1.0 → 5.1.2
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/nameTools.d.ts +2 -1
- package/lib/nameTools.js +7 -1
- package/lib/stringTools.d.ts +2 -0
- package/lib/stringTools.js +21 -1
- package/package.json +3 -3
package/lib/nameTools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnInfo, DatabaseInfo, DatabaseInfoObjects, SqlDialect, TableInfo } from 'dbgate-types';
|
|
1
|
+
import { ColumnInfo, DatabaseInfo, DatabaseInfoObjects, NamedObjectInfo, SqlDialect, TableInfo } from 'dbgate-types';
|
|
2
2
|
export declare function fullNameFromString(name: any): {
|
|
3
3
|
schemaName: any;
|
|
4
4
|
pureName: any;
|
|
@@ -16,6 +16,7 @@ export declare function quoteFullName(dialect: any, { schemaName, pureName }: {
|
|
|
16
16
|
pureName: any;
|
|
17
17
|
}): string;
|
|
18
18
|
export declare function equalStringLike(s1: any, s2: any): boolean;
|
|
19
|
+
export declare function equalFullName(name1: NamedObjectInfo, name2: NamedObjectInfo): boolean;
|
|
19
20
|
export declare function findObjectLike({ pureName, schemaName }: {
|
|
20
21
|
pureName: any;
|
|
21
22
|
schemaName: any;
|
package/lib/nameTools.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.fillConstraintNames = exports.makeUniqueColumnNames = exports.findForeignKeyForColumn = exports.findObjectLike = exports.equalStringLike = exports.quoteFullName = exports.fullNameToLabel = exports.fullNameToString = exports.fullNameFromString = void 0;
|
|
6
|
+
exports.fillConstraintNames = exports.makeUniqueColumnNames = exports.findForeignKeyForColumn = exports.findObjectLike = exports.equalFullName = exports.equalStringLike = exports.quoteFullName = exports.fullNameToLabel = exports.fullNameToString = exports.fullNameFromString = void 0;
|
|
7
7
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
8
8
|
const isString_1 = __importDefault(require("lodash/isString"));
|
|
9
9
|
function fullNameFromString(name) {
|
|
@@ -44,6 +44,12 @@ function equalStringLike(s1, s2) {
|
|
|
44
44
|
return (s1 || '').toLowerCase().trim() == (s2 || '').toLowerCase().trim();
|
|
45
45
|
}
|
|
46
46
|
exports.equalStringLike = equalStringLike;
|
|
47
|
+
function equalFullName(name1, name2) {
|
|
48
|
+
if (!name1 || !name2)
|
|
49
|
+
return name1 == name2;
|
|
50
|
+
return name1.pureName == name2.pureName && name1.schemaName == name2.schemaName;
|
|
51
|
+
}
|
|
52
|
+
exports.equalFullName = equalFullName;
|
|
47
53
|
function findObjectLike({ pureName, schemaName }, dbinfo, objectTypeField) {
|
|
48
54
|
var _a, _b;
|
|
49
55
|
if (!dbinfo)
|
package/lib/stringTools.d.ts
CHANGED
|
@@ -6,3 +6,5 @@ export declare function safeJsonParse(json: any, defaultValue?: any, logError?:
|
|
|
6
6
|
export declare function isJsonLikeLongString(value: any): RegExpMatchArray;
|
|
7
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";
|
|
8
8
|
export declare function isWktGeometry(s: any): boolean;
|
|
9
|
+
export declare function arrayBufferToBase64(buffer: any): string;
|
|
10
|
+
export declare function getAsImageSrc(obj: any): string;
|
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.isWktGeometry = exports.getIconForRedisType = exports.isJsonLikeLongString = exports.safeJsonParse = exports.stringifyCellValue = exports.parseCellValue = exports.hexStringToArray = exports.arrayToHexString = void 0;
|
|
6
|
+
exports.getAsImageSrc = exports.arrayBufferToBase64 = exports.isWktGeometry = 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"));
|
|
@@ -54,6 +54,9 @@ function stringifyCellValue(value) {
|
|
|
54
54
|
}
|
|
55
55
|
exports.stringifyCellValue = stringifyCellValue;
|
|
56
56
|
function safeJsonParse(json, defaultValue, logError = false) {
|
|
57
|
+
if ((0, isArray_1.default)(json) || (0, isPlainObject_1.default)(json)) {
|
|
58
|
+
return json;
|
|
59
|
+
}
|
|
57
60
|
try {
|
|
58
61
|
return JSON.parse(json);
|
|
59
62
|
}
|
|
@@ -101,3 +104,20 @@ function isWktGeometry(s) {
|
|
|
101
104
|
return !!s.match(/^POINT\s*\(|^LINESTRING\s*\(|^POLYGON\s*\(|^MULTIPOINT\s*\(|^MULTILINESTRING\s*\(|^MULTIPOLYGON\s*\(|^GEOMCOLLECTION\s*\(|^GEOMETRYCOLLECTION\s*\(/);
|
|
102
105
|
}
|
|
103
106
|
exports.isWktGeometry = isWktGeometry;
|
|
107
|
+
function arrayBufferToBase64(buffer) {
|
|
108
|
+
var binary = '';
|
|
109
|
+
var bytes = [].slice.call(new Uint8Array(buffer));
|
|
110
|
+
bytes.forEach(b => (binary += String.fromCharCode(b)));
|
|
111
|
+
return btoa(binary);
|
|
112
|
+
}
|
|
113
|
+
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
114
|
+
function getAsImageSrc(obj) {
|
|
115
|
+
if ((obj === null || obj === void 0 ? void 0 : obj.type) == 'Buffer' && (0, isArray_1.default)(obj === null || obj === void 0 ? void 0 : obj.data)) {
|
|
116
|
+
return `data:image/png;base64, ${arrayBufferToBase64(obj === null || obj === void 0 ? void 0 : obj.data)}`;
|
|
117
|
+
}
|
|
118
|
+
if ((0, isString_1.default)(obj) && (obj.startsWith('http://') || obj.startsWith('https://'))) {
|
|
119
|
+
return obj;
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
exports.getAsImageSrc = getAsImageSrc;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.1.
|
|
2
|
+
"version": "5.1.2",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^13.7.0",
|
|
28
|
-
"dbgate-types": "^5.1.
|
|
28
|
+
"dbgate-types": "^5.1.2",
|
|
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
|
"dbgate-query-splitter": "^4.9.0",
|
|
35
|
-
"dbgate-sqltree": "^5.1.
|
|
35
|
+
"dbgate-sqltree": "^5.1.2",
|
|
36
36
|
"debug": "^4.3.4",
|
|
37
37
|
"json-stable-stringify": "^1.0.1",
|
|
38
38
|
"lodash": "^4.17.21",
|