dbgate-tools 6.6.12 → 6.7.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.
- package/lib/SqlDumper.js +9 -0
- package/lib/filterBehaviours.js +1 -0
- package/lib/stringTools.d.ts +2 -0
- package/lib/stringTools.js +31 -8
- package/package.json +4 -4
package/lib/SqlDumper.js
CHANGED
|
@@ -51,6 +51,7 @@ class SqlDumper {
|
|
|
51
51
|
this.put('^null');
|
|
52
52
|
}
|
|
53
53
|
putValue(value, dataType = null) {
|
|
54
|
+
var _a;
|
|
54
55
|
if (value === null)
|
|
55
56
|
this.put('^null');
|
|
56
57
|
else if (value === true)
|
|
@@ -65,6 +66,14 @@ class SqlDumper {
|
|
|
65
66
|
this.putStringValue(new Date(value).toISOString());
|
|
66
67
|
else if ((value === null || value === void 0 ? void 0 : value.type) == 'Buffer' && (0, isArray_1.default)(value === null || value === void 0 ? void 0 : value.data))
|
|
67
68
|
this.putByteArrayValue(value === null || value === void 0 ? void 0 : value.data);
|
|
69
|
+
else if ((_a = value === null || value === void 0 ? void 0 : value.$binary) === null || _a === void 0 ? void 0 : _a.base64) {
|
|
70
|
+
const binary = atob(value.$binary.base64);
|
|
71
|
+
const bytes = new Array(binary.length);
|
|
72
|
+
for (let i = 0; i < binary.length; i++) {
|
|
73
|
+
bytes[i] = binary.charCodeAt(i);
|
|
74
|
+
}
|
|
75
|
+
this.putByteArrayValue(bytes);
|
|
76
|
+
}
|
|
68
77
|
else if (value === null || value === void 0 ? void 0 : value.$bigint)
|
|
69
78
|
this.putRaw(value === null || value === void 0 ? void 0 : value.$bigint);
|
|
70
79
|
else if ((0, isPlainObject_1.default)(value) || (0, isArray_1.default)(value))
|
package/lib/filterBehaviours.js
CHANGED
package/lib/stringTools.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export declare const MAX_GRID_TEXT_LENGTH = 1000;
|
|
|
3
3
|
export type EditorDataType = 'null' | 'objectid' | 'string' | 'number' | 'object' | 'date' | 'array' | 'boolean' | 'unknown';
|
|
4
4
|
export declare function arrayToHexString(byteArray: any): any;
|
|
5
5
|
export declare function hexStringToArray(inputString: any): any[];
|
|
6
|
+
export declare function base64ToHex(base64String: any): string;
|
|
7
|
+
export declare function hexToBase64(hexString: any): string;
|
|
6
8
|
export declare function parseCellValue(value: any, editorTypes?: DataEditorTypesBehaviour): any;
|
|
7
9
|
export declare function stringifyCellValue(value: any, intent: 'gridCellIntent' | 'inlineEditorIntent' | 'multilineEditorIntent' | 'stringConversionIntent' | 'exportIntent' | 'clipboardIntent', editorTypes?: DataEditorTypesBehaviour, gridFormattingOptions?: {
|
|
8
10
|
useThousandsSeparator?: boolean;
|
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.shortenIdentifier = exports.setSqlFrontMatter = exports.removeSqlFrontMatter = exports.getSqlFrontMatter = exports.parseNumberSafe = exports.deserializeJsTypesReviver = exports.serializeJsTypesReplacer = exports.deserializeJsTypesFromJsonParse = exports.serializeJsTypesForJsonStringify = exports.jsonLinesParse = exports.jsonLinesStringify = exports.pinoLogRecordToMessageRecord = exports.getLimitedQuery = exports.safeFormatDate = exports.extractErrorLogData = exports.extractErrorStackTrace = exports.extractErrorMessage = exports.getConvertValueMenu = exports.detectTypeIcon = exports.detectCellDataType = exports.parseSqlDefaultValue = exports.getAsImageSrc = exports.arrayBufferToBase64 = exports.isWktGeometry = exports.getIconForRedisType = exports.isJsonLikeLongString = exports.shouldOpenMultilineDialog = exports.safeCompileRegExp = exports.safeJsonParse = exports.stringifyCellValue = exports.parseCellValue = exports.hexStringToArray = exports.arrayToHexString = exports.MAX_GRID_TEXT_LENGTH = void 0;
|
|
6
|
+
exports.shortenIdentifier = exports.setSqlFrontMatter = exports.removeSqlFrontMatter = exports.getSqlFrontMatter = exports.parseNumberSafe = exports.deserializeJsTypesReviver = exports.serializeJsTypesReplacer = exports.deserializeJsTypesFromJsonParse = exports.serializeJsTypesForJsonStringify = exports.jsonLinesParse = exports.jsonLinesStringify = exports.pinoLogRecordToMessageRecord = exports.getLimitedQuery = exports.safeFormatDate = exports.extractErrorLogData = exports.extractErrorStackTrace = exports.extractErrorMessage = exports.getConvertValueMenu = exports.detectTypeIcon = exports.detectCellDataType = exports.parseSqlDefaultValue = exports.getAsImageSrc = exports.arrayBufferToBase64 = exports.isWktGeometry = exports.getIconForRedisType = exports.isJsonLikeLongString = exports.shouldOpenMultilineDialog = exports.safeCompileRegExp = exports.safeJsonParse = exports.stringifyCellValue = exports.parseCellValue = exports.hexToBase64 = exports.base64ToHex = exports.hexStringToArray = exports.arrayToHexString = exports.MAX_GRID_TEXT_LENGTH = void 0;
|
|
7
7
|
const isString_1 = __importDefault(require("lodash/isString"));
|
|
8
8
|
const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
9
9
|
const isDate_1 = __importDefault(require("lodash/isDate"));
|
|
@@ -31,6 +31,18 @@ function hexStringToArray(inputString) {
|
|
|
31
31
|
return res;
|
|
32
32
|
}
|
|
33
33
|
exports.hexStringToArray = hexStringToArray;
|
|
34
|
+
function base64ToHex(base64String) {
|
|
35
|
+
const binaryString = atob(base64String);
|
|
36
|
+
const hexString = Array.from(binaryString, c => c.charCodeAt(0).toString(16).padStart(2, '0')).join('');
|
|
37
|
+
return '0x' + hexString.toUpperCase();
|
|
38
|
+
}
|
|
39
|
+
exports.base64ToHex = base64ToHex;
|
|
40
|
+
;
|
|
41
|
+
function hexToBase64(hexString) {
|
|
42
|
+
const binaryString = hexString.match(/.{1,2}/g).map(byte => String.fromCharCode(parseInt(byte, 16))).join('');
|
|
43
|
+
return btoa(binaryString);
|
|
44
|
+
}
|
|
45
|
+
exports.hexToBase64 = hexToBase64;
|
|
34
46
|
function parseCellValue(value, editorTypes) {
|
|
35
47
|
if (!(0, isString_1.default)(value))
|
|
36
48
|
return value;
|
|
@@ -42,8 +54,9 @@ function parseCellValue(value, editorTypes) {
|
|
|
42
54
|
const mHex = value.match(/^0x([0-9a-fA-F][0-9a-fA-F])+$/);
|
|
43
55
|
if (mHex) {
|
|
44
56
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
$binary: {
|
|
58
|
+
base64: hexToBase64(value.substring(2))
|
|
59
|
+
}
|
|
47
60
|
};
|
|
48
61
|
}
|
|
49
62
|
}
|
|
@@ -170,7 +183,7 @@ function stringifyJsonToGrid(value) {
|
|
|
170
183
|
return { value: '(JSON)', gridStyle: 'nullCellStyle' };
|
|
171
184
|
}
|
|
172
185
|
function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, jsonParsedValue) {
|
|
173
|
-
var _a;
|
|
186
|
+
var _a, _b;
|
|
174
187
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseSqlNull) {
|
|
175
188
|
if (value === null) {
|
|
176
189
|
switch (intent) {
|
|
@@ -198,10 +211,16 @@ function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, j
|
|
|
198
211
|
return { value: 'true', gridStyle: 'valueCellStyle' };
|
|
199
212
|
if (value === false)
|
|
200
213
|
return { value: 'false', gridStyle: 'valueCellStyle' };
|
|
214
|
+
if ((_a = value === null || value === void 0 ? void 0 : value.$binary) === null || _a === void 0 ? void 0 : _a.base64) {
|
|
215
|
+
return {
|
|
216
|
+
value: base64ToHex(value.$binary.base64),
|
|
217
|
+
gridStyle: 'valueCellStyle',
|
|
218
|
+
};
|
|
219
|
+
}
|
|
201
220
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseHexAsBuffer) {
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
}
|
|
221
|
+
// if (value?.type == 'Buffer' && _isArray(value.data)) {
|
|
222
|
+
// return { value: '0x' + arrayToHexString(value.data), gridStyle: 'valueCellStyle' };
|
|
223
|
+
// }
|
|
205
224
|
}
|
|
206
225
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseObjectIdAsDollar) {
|
|
207
226
|
if (value === null || value === void 0 ? void 0 : value.$oid) {
|
|
@@ -263,7 +282,7 @@ function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, j
|
|
|
263
282
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseFsDocumentRefAsDollar) {
|
|
264
283
|
if (value === null || value === void 0 ? void 0 : value.$fsDocumentRef) {
|
|
265
284
|
return {
|
|
266
|
-
value: `$ref: ${(
|
|
285
|
+
value: `$ref: ${(_b = value.$fsDocumentRef.documentPath) !== null && _b !== void 0 ? _b : ''}`,
|
|
267
286
|
gridStyle: 'valueCellStyle',
|
|
268
287
|
};
|
|
269
288
|
}
|
|
@@ -437,9 +456,13 @@ function arrayBufferToBase64(buffer) {
|
|
|
437
456
|
}
|
|
438
457
|
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
439
458
|
function getAsImageSrc(obj) {
|
|
459
|
+
var _a;
|
|
440
460
|
if ((obj === null || obj === void 0 ? void 0 : obj.type) == 'Buffer' && (0, isArray_1.default)(obj === null || obj === void 0 ? void 0 : obj.data)) {
|
|
441
461
|
return `data:image/png;base64, ${arrayBufferToBase64(obj === null || obj === void 0 ? void 0 : obj.data)}`;
|
|
442
462
|
}
|
|
463
|
+
if ((_a = obj === null || obj === void 0 ? void 0 : obj.$binary) === null || _a === void 0 ? void 0 : _a.base64) {
|
|
464
|
+
return `data:image/png;base64, ${obj.$binary.base64}`;
|
|
465
|
+
}
|
|
443
466
|
if ((0, isString_1.default)(obj) && (obj.startsWith('http://') || obj.startsWith('https://'))) {
|
|
444
467
|
return obj;
|
|
445
468
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "6.
|
|
2
|
+
"version": "6.7.1",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^13.7.0",
|
|
29
|
-
"dbgate-types": "^6.
|
|
29
|
+
"dbgate-types": "^6.7.1",
|
|
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
|
"blueimp-md5": "^2.19.0",
|
|
36
|
-
"dbgate-query-splitter": "^4.11.
|
|
37
|
-
"dbgate-sqltree": "^6.
|
|
36
|
+
"dbgate-query-splitter": "^4.11.9",
|
|
37
|
+
"dbgate-sqltree": "^6.7.1",
|
|
38
38
|
"debug": "^4.3.4",
|
|
39
39
|
"json-stable-stringify": "^1.0.1",
|
|
40
40
|
"lodash": "^4.17.21",
|