dbgate-tools 6.7.2-alpha.1 → 6.7.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/DatabaseAnalyser.js +5 -0
- package/lib/stringTools.d.ts +1 -1
- package/lib/stringTools.js +34 -12
- package/package.json +3 -3
package/lib/DatabaseAnalyser.js
CHANGED
|
@@ -151,6 +151,11 @@ class DatabaseAnalyser {
|
|
|
151
151
|
}
|
|
152
152
|
const res = {};
|
|
153
153
|
for (const field of STRUCTURE_FIELDS) {
|
|
154
|
+
const isAll = this.modifications.some(x => x.action == 'all' && x.objectTypeField == field);
|
|
155
|
+
if (isAll) {
|
|
156
|
+
res[field] = newlyAnalysed[field] || [];
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
154
159
|
const removedIds = this.modifications
|
|
155
160
|
.filter(x => x.action == 'remove' && x.objectTypeField == field)
|
|
156
161
|
.map(x => x.objectId);
|
package/lib/stringTools.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function base64ToHex(base64String: any): string;
|
|
|
7
7
|
export declare function hexToBase64(hexString: any): string;
|
|
8
8
|
export declare function parseCellValue(value: any, editorTypes?: DataEditorTypesBehaviour): any;
|
|
9
9
|
export declare function stringifyCellValue(value: any, intent: 'gridCellIntent' | 'inlineEditorIntent' | 'multilineEditorIntent' | 'stringConversionIntent' | 'exportIntent' | 'clipboardIntent', editorTypes?: DataEditorTypesBehaviour, gridFormattingOptions?: {
|
|
10
|
-
|
|
10
|
+
thousandsSeparator?: string;
|
|
11
11
|
}, jsonParsedValue?: any): {
|
|
12
12
|
value: string;
|
|
13
13
|
gridStyle?: 'textCellStyle' | 'valueCellStyle' | 'nullCellStyle';
|
package/lib/stringTools.js
CHANGED
|
@@ -37,9 +37,11 @@ function base64ToHex(base64String) {
|
|
|
37
37
|
return '0x' + hexString.toUpperCase();
|
|
38
38
|
}
|
|
39
39
|
exports.base64ToHex = base64ToHex;
|
|
40
|
-
;
|
|
41
40
|
function hexToBase64(hexString) {
|
|
42
|
-
const binaryString = hexString
|
|
41
|
+
const binaryString = hexString
|
|
42
|
+
.match(/.{1,2}/g)
|
|
43
|
+
.map(byte => String.fromCharCode(parseInt(byte, 16)))
|
|
44
|
+
.join('');
|
|
43
45
|
return btoa(binaryString);
|
|
44
46
|
}
|
|
45
47
|
exports.hexToBase64 = hexToBase64;
|
|
@@ -55,8 +57,8 @@ function parseCellValue(value, editorTypes) {
|
|
|
55
57
|
if (mHex) {
|
|
56
58
|
return {
|
|
57
59
|
$binary: {
|
|
58
|
-
base64: hexToBase64(value.substring(2))
|
|
59
|
-
}
|
|
60
|
+
base64: hexToBase64(value.substring(2)),
|
|
61
|
+
},
|
|
60
62
|
};
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -182,6 +184,30 @@ function stringifyJsonToGrid(value) {
|
|
|
182
184
|
}
|
|
183
185
|
return { value: '(JSON)', gridStyle: 'nullCellStyle' };
|
|
184
186
|
}
|
|
187
|
+
function formatNumberCustomSeparator(value, thousandsSeparator) {
|
|
188
|
+
const [intPart, decPart] = value.split('.');
|
|
189
|
+
const intPartWithSeparator = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator);
|
|
190
|
+
return decPart ? `${intPartWithSeparator}.${decPart}` : intPartWithSeparator;
|
|
191
|
+
}
|
|
192
|
+
function formatCellNumber(value, gridFormattingOptions) {
|
|
193
|
+
const separator = gridFormattingOptions === null || gridFormattingOptions === void 0 ? void 0 : gridFormattingOptions.thousandsSeparator;
|
|
194
|
+
if ((0, isNumber_1.default)(value)) {
|
|
195
|
+
if (separator === 'none' || (value < 1000 && value > -1000))
|
|
196
|
+
return value.toString();
|
|
197
|
+
if (separator === 'system')
|
|
198
|
+
return value.toLocaleString();
|
|
199
|
+
}
|
|
200
|
+
// fallback for system locale
|
|
201
|
+
if (separator === 'space' || separator === 'system')
|
|
202
|
+
return formatNumberCustomSeparator(value.toString(), ' ');
|
|
203
|
+
if (separator === 'narrowspace')
|
|
204
|
+
return formatNumberCustomSeparator(value.toString(), '\u202F');
|
|
205
|
+
if (separator === 'comma')
|
|
206
|
+
return formatNumberCustomSeparator(value.toString(), ',');
|
|
207
|
+
if (separator === 'dot')
|
|
208
|
+
return formatNumberCustomSeparator(value.toString(), '.');
|
|
209
|
+
return value.toString();
|
|
210
|
+
}
|
|
185
211
|
function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, jsonParsedValue) {
|
|
186
212
|
var _a, _b;
|
|
187
213
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseSqlNull) {
|
|
@@ -235,13 +261,13 @@ function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, j
|
|
|
235
261
|
}
|
|
236
262
|
if (value === null || value === void 0 ? void 0 : value.$bigint) {
|
|
237
263
|
return {
|
|
238
|
-
value: value.$bigint,
|
|
264
|
+
value: formatCellNumber(value.$bigint, gridFormattingOptions),
|
|
239
265
|
gridStyle: 'valueCellStyle',
|
|
240
266
|
};
|
|
241
267
|
}
|
|
242
268
|
if (typeof value === 'bigint') {
|
|
243
269
|
return {
|
|
244
|
-
value: value.toString(),
|
|
270
|
+
value: formatCellNumber(value.toString(), gridFormattingOptions),
|
|
245
271
|
gridStyle: 'valueCellStyle',
|
|
246
272
|
};
|
|
247
273
|
}
|
|
@@ -310,12 +336,8 @@ function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, j
|
|
|
310
336
|
if ((0, isNumber_1.default)(value)) {
|
|
311
337
|
switch (intent) {
|
|
312
338
|
case 'gridCellIntent':
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
? value.toLocaleString()
|
|
316
|
-
: value.toString(),
|
|
317
|
-
gridStyle: 'valueCellStyle',
|
|
318
|
-
};
|
|
339
|
+
const separator = gridFormattingOptions === null || gridFormattingOptions === void 0 ? void 0 : gridFormattingOptions.thousandsSeparator;
|
|
340
|
+
return { value: formatCellNumber(value, gridFormattingOptions), gridStyle: 'valueCellStyle' };
|
|
319
341
|
default:
|
|
320
342
|
return { value: value.toString() };
|
|
321
343
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "6.7.
|
|
2
|
+
"version": "6.7.3",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^13.7.0",
|
|
29
|
-
"dbgate-types": "^6.7.
|
|
29
|
+
"dbgate-types": "^6.7.3",
|
|
30
30
|
"jest": "^28.1.3",
|
|
31
31
|
"ts-jest": "^28.0.7",
|
|
32
32
|
"typescript": "^4.4.3"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"blueimp-md5": "^2.19.0",
|
|
36
36
|
"dbgate-query-splitter": "^4.11.9",
|
|
37
|
-
"dbgate-sqltree": "^6.7.
|
|
37
|
+
"dbgate-sqltree": "^6.7.3",
|
|
38
38
|
"debug": "^4.3.4",
|
|
39
39
|
"json-stable-stringify": "^1.0.1",
|
|
40
40
|
"lodash": "^4.17.21",
|