dbgate-tools 6.3.3 → 6.4.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.
@@ -91,16 +91,16 @@ class DatabaseAnalyser {
91
91
  });
92
92
  }
93
93
  singleObjectAnalysis(name, typeField) {
94
- var _a, _b;
94
+ var _a, _b, _c;
95
95
  return __awaiter(this, void 0, void 0, function* () {
96
96
  // console.log('Analysing SINGLE OBJECT', name, typeField);
97
97
  this.singleObjectFilter = Object.assign(Object.assign({}, name), { typeField });
98
98
  yield this._computeSingleObjectId();
99
99
  const res = this.addEngineField(yield this._runAnalysis());
100
- // console.log('SINGLE OBJECT RES', res);
100
+ // console.log('SINGLE OBJECT RES', JSON.stringify(res, null, 2));
101
101
  const obj = ((_a = res[typeField]) === null || _a === void 0 ? void 0 : _a.length) == 1
102
- ? res[typeField][0]
103
- : (_b = res[typeField]) === null || _b === void 0 ? void 0 : _b.find(x => x.pureName == name.pureName && x.schemaName == name.schemaName);
102
+ ? (_b = res[typeField]) === null || _b === void 0 ? void 0 : _b.find(x => x.pureName.toLowerCase() == name.pureName.toLowerCase())
103
+ : (_c = res[typeField]) === null || _c === void 0 ? void 0 : _c.find(x => x.pureName == name.pureName && x.schemaName == name.schemaName);
104
104
  // console.log('SINGLE OBJECT', obj);
105
105
  return obj;
106
106
  });
@@ -1,4 +1,17 @@
1
- export declare class ScriptWriter {
1
+ export interface ScriptWriterGeneric {
2
+ allocVariable(prefix?: string): any;
3
+ endLine(): any;
4
+ assign(variableName: string, functionName: string, props: any): any;
5
+ assignValue(variableName: string, jsonValue: any): any;
6
+ requirePackage(packageName: string): any;
7
+ copyStream(sourceVar: string, targetVar: string, colmapVar?: string, progressName?: string): any;
8
+ importDatabase(options: any): any;
9
+ dataReplicator(options: any): any;
10
+ comment(s: string): any;
11
+ zipDirectory(inputDirectory: string, outputFile: string): any;
12
+ getScript(schedule?: any): any;
13
+ }
14
+ export declare class ScriptWriterJavaScript implements ScriptWriterGeneric {
2
15
  s: string;
3
16
  packageNames: string[];
4
17
  varCount: number;
@@ -10,13 +23,17 @@ export declare class ScriptWriter {
10
23
  assign(variableName: any, functionName: any, props: any): void;
11
24
  assignValue(variableName: any, jsonValue: any): void;
12
25
  requirePackage(packageName: any): void;
13
- copyStream(sourceVar: any, targetVar: any, colmapVar?: any, progressName?: string): void;
26
+ copyStream(sourceVar: any, targetVar: any, colmapVar?: any, progressName?: string | {
27
+ name: string;
28
+ runid: string;
29
+ }): void;
14
30
  importDatabase(options: any): void;
15
- dataDuplicator(options: any): void;
31
+ dataReplicator(options: any): void;
16
32
  comment(s: any): void;
17
33
  getScript(schedule?: any): string;
34
+ zipDirectory(inputDirectory: any, outputFile: any): void;
18
35
  }
19
- export declare class ScriptWriterJson {
36
+ export declare class ScriptWriterJson implements ScriptWriterGeneric {
20
37
  s: string;
21
38
  packageNames: string[];
22
39
  varCount: number;
@@ -25,11 +42,16 @@ export declare class ScriptWriterJson {
25
42
  allocVariable(prefix?: string): string;
26
43
  endLine(): void;
27
44
  assign(variableName: any, functionName: any, props: any): void;
45
+ requirePackage(packageName: any): void;
28
46
  assignValue(variableName: any, jsonValue: any): void;
29
- copyStream(sourceVar: any, targetVar: any, colmapVar?: any, progressName?: string): void;
47
+ copyStream(sourceVar: any, targetVar: any, colmapVar?: any, progressName?: string | {
48
+ name: string;
49
+ runid: string;
50
+ }): void;
30
51
  comment(text: any): void;
31
52
  importDatabase(options: any): void;
32
- dataDuplicator(options: any): void;
53
+ dataReplicator(options: any): void;
54
+ zipDirectory(inputDirectory: any, outputFile: any): void;
33
55
  getScript(schedule?: any): {
34
56
  type: string;
35
57
  schedule: any;
@@ -37,4 +59,32 @@ export declare class ScriptWriterJson {
37
59
  packageNames: string[];
38
60
  };
39
61
  }
40
- export declare function jsonScriptToJavascript(json: any): string;
62
+ export declare class ScriptWriterEval implements ScriptWriterGeneric {
63
+ s: string;
64
+ varCount: number;
65
+ commands: any[];
66
+ dbgateApi: any;
67
+ requirePlugin: (name: string) => any;
68
+ variables: {
69
+ [name: string]: any;
70
+ };
71
+ hostConnection: any;
72
+ runid: string;
73
+ constructor(dbgateApi: any, requirePlugin: any, hostConnection: any, runid: any, varCount?: string);
74
+ allocVariable(prefix?: string): string;
75
+ endLine(): void;
76
+ requirePackage(packageName: any): void;
77
+ assign(variableName: any, functionName: any, props: any): Promise<void>;
78
+ assignValue(variableName: any, jsonValue: any): void;
79
+ copyStream(sourceVar: any, targetVar: any, colmapVar?: any, progressName?: string | {
80
+ name: string;
81
+ runid: string;
82
+ }): Promise<void>;
83
+ comment(text: any): void;
84
+ importDatabase(options: any): Promise<void>;
85
+ dataReplicator(options: any): Promise<void>;
86
+ zipDirectory(inputDirectory: any, outputFile: any): Promise<void>;
87
+ getScript(schedule?: any): void;
88
+ }
89
+ export declare function playJsonScriptWriter(json: any, script: ScriptWriterGeneric): Promise<void>;
90
+ export declare function jsonScriptToJavascript(json: any): Promise<string>;
@@ -1,12 +1,22 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.jsonScriptToJavascript = exports.ScriptWriterJson = exports.ScriptWriter = void 0;
15
+ exports.jsonScriptToJavascript = exports.playJsonScriptWriter = exports.ScriptWriterEval = exports.ScriptWriterJson = exports.ScriptWriterJavaScript = void 0;
7
16
  const uniq_1 = __importDefault(require("lodash/uniq"));
17
+ const cloneDeepWith_1 = __importDefault(require("lodash/cloneDeepWith"));
8
18
  const packageTools_1 = require("./packageTools");
9
- class ScriptWriter {
19
+ class ScriptWriterJavaScript {
10
20
  constructor(varCount = '0') {
11
21
  this.s = '';
12
22
  this.packageNames = [];
@@ -28,7 +38,7 @@ class ScriptWriter {
28
38
  this._put(`const ${variableName} = await ${functionName}(${JSON.stringify(props)});`);
29
39
  }
30
40
  assign(variableName, functionName, props) {
31
- this.assignCore(variableName, (0, packageTools_1.extractShellApiFunctionName)(functionName), props);
41
+ this.assignCore(variableName, (0, packageTools_1.compileShellApiFunctionName)(functionName), props);
32
42
  this.packageNames.push(...(0, packageTools_1.extractShellApiPlugins)(functionName, props));
33
43
  }
34
44
  assignValue(variableName, jsonValue) {
@@ -42,15 +52,15 @@ class ScriptWriter {
42
52
  if (colmapVar)
43
53
  opts += `columns: ${colmapVar}, `;
44
54
  if (progressName)
45
- opts += `progressName: "${progressName}", `;
55
+ opts += `progressName: ${JSON.stringify(progressName)}, `;
46
56
  opts += '}';
47
57
  this._put(`await dbgateApi.copyStream(${sourceVar}, ${targetVar}, ${opts});`);
48
58
  }
49
59
  importDatabase(options) {
50
60
  this._put(`await dbgateApi.importDatabase(${JSON.stringify(options)});`);
51
61
  }
52
- dataDuplicator(options) {
53
- this._put(`await dbgateApi.dataDuplicator(${JSON.stringify(options, null, 2)});`);
62
+ dataReplicator(options) {
63
+ this._put(`await dbgateApi.dataReplicator(${JSON.stringify(options, null, 2)});`);
54
64
  }
55
65
  comment(s) {
56
66
  this._put(`// ${s}`);
@@ -66,8 +76,11 @@ class ScriptWriter {
66
76
  prefix += '\n';
67
77
  return prefix + this.s;
68
78
  }
79
+ zipDirectory(inputDirectory, outputFile) {
80
+ this._put(`await dbgateApi.zipDirectory('${inputDirectory}', '${outputFile}');`);
81
+ }
69
82
  }
70
- exports.ScriptWriter = ScriptWriter;
83
+ exports.ScriptWriterJavaScript = ScriptWriterJavaScript;
71
84
  class ScriptWriterJson {
72
85
  constructor(varCount = '0') {
73
86
  this.s = '';
@@ -89,11 +102,14 @@ class ScriptWriterJson {
89
102
  this.commands.push({
90
103
  type: 'assign',
91
104
  variableName,
92
- functionName: (0, packageTools_1.extractShellApiFunctionName)(functionName),
105
+ functionName,
93
106
  props,
94
107
  });
95
108
  this.packageNames.push(...(0, packageTools_1.extractShellApiPlugins)(functionName, props));
96
109
  }
110
+ requirePackage(packageName) {
111
+ this.packageNames.push(packageName);
112
+ }
97
113
  assignValue(variableName, jsonValue) {
98
114
  this.commands.push({
99
115
  type: 'assignValue',
@@ -122,12 +138,19 @@ class ScriptWriterJson {
122
138
  options,
123
139
  });
124
140
  }
125
- dataDuplicator(options) {
141
+ dataReplicator(options) {
126
142
  this.commands.push({
127
- type: 'dataDuplicator',
143
+ type: 'dataReplicator',
128
144
  options,
129
145
  });
130
146
  }
147
+ zipDirectory(inputDirectory, outputFile) {
148
+ this.commands.push({
149
+ type: 'zipDirectory',
150
+ inputDirectory,
151
+ outputFile,
152
+ });
153
+ }
131
154
  getScript(schedule = null) {
132
155
  return {
133
156
  type: 'json',
@@ -138,40 +161,122 @@ class ScriptWriterJson {
138
161
  }
139
162
  }
140
163
  exports.ScriptWriterJson = ScriptWriterJson;
141
- function jsonScriptToJavascript(json) {
142
- const { schedule, commands, packageNames } = json;
143
- const script = new ScriptWriter();
144
- for (const packageName of packageNames) {
145
- if (!/^dbgate-plugin-.*$/.test(packageName)) {
146
- throw new Error('Unallowed package name:' + packageName);
147
- }
148
- script.packageNames.push(packageName);
164
+ class ScriptWriterEval {
165
+ constructor(dbgateApi, requirePlugin, hostConnection, runid, varCount = '0') {
166
+ this.s = '';
167
+ this.varCount = 0;
168
+ this.commands = [];
169
+ this.variables = {};
170
+ this.varCount = parseInt(varCount) || 0;
171
+ this.dbgateApi = dbgateApi;
172
+ this.requirePlugin = requirePlugin;
173
+ this.hostConnection = hostConnection;
174
+ this.runid = runid;
175
+ }
176
+ allocVariable(prefix = 'var') {
177
+ this.varCount += 1;
178
+ return `${prefix}${this.varCount}`;
179
+ }
180
+ endLine() { }
181
+ requirePackage(packageName) { }
182
+ assign(variableName, functionName, props) {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ const func = (0, packageTools_1.evalShellApiFunctionName)(functionName, this.dbgateApi, this.requirePlugin);
185
+ this.variables[variableName] = yield func((0, cloneDeepWith_1.default)(props, node => {
186
+ if (node === null || node === void 0 ? void 0 : node.$hostConnection) {
187
+ return this.hostConnection;
188
+ }
189
+ }));
190
+ });
149
191
  }
150
- for (const cmd of commands) {
192
+ assignValue(variableName, jsonValue) {
193
+ this.variables[variableName] = jsonValue;
194
+ }
195
+ copyStream(sourceVar, targetVar, colmapVar = null, progressName) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ yield this.dbgateApi.copyStream(this.variables[sourceVar], this.variables[targetVar], {
198
+ progressName: (0, cloneDeepWith_1.default)(progressName, node => {
199
+ if (node === null || node === void 0 ? void 0 : node.$runid) {
200
+ if (node === null || node === void 0 ? void 0 : node.$runid) {
201
+ return this.runid;
202
+ }
203
+ }
204
+ }),
205
+ columns: colmapVar ? this.variables[colmapVar] : null,
206
+ });
207
+ });
208
+ }
209
+ comment(text) { }
210
+ importDatabase(options) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ yield this.dbgateApi.importDatabase(options);
213
+ });
214
+ }
215
+ dataReplicator(options) {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ yield this.dbgateApi.dataReplicator(options);
218
+ });
219
+ }
220
+ zipDirectory(inputDirectory, outputFile) {
221
+ return __awaiter(this, void 0, void 0, function* () {
222
+ yield this.dbgateApi.zipDirectory(inputDirectory, outputFile);
223
+ });
224
+ }
225
+ getScript(schedule) {
226
+ throw new Error('Not implemented');
227
+ }
228
+ }
229
+ exports.ScriptWriterEval = ScriptWriterEval;
230
+ function playJsonCommand(cmd, script) {
231
+ return __awaiter(this, void 0, void 0, function* () {
151
232
  switch (cmd.type) {
152
233
  case 'assign':
153
- script.assignCore(cmd.variableName, cmd.functionName, cmd.props);
234
+ yield script.assign(cmd.variableName, cmd.functionName, cmd.props);
154
235
  break;
155
236
  case 'assignValue':
156
- script.assignValue(cmd.variableName, cmd.jsonValue);
237
+ yield script.assignValue(cmd.variableName, cmd.jsonValue);
157
238
  break;
158
239
  case 'copyStream':
159
- script.copyStream(cmd.sourceVar, cmd.targetVar, cmd.colmapVar, cmd.progressName);
240
+ yield script.copyStream(cmd.sourceVar, cmd.targetVar, cmd.colmapVar, cmd.progressName);
160
241
  break;
161
242
  case 'endLine':
162
- script.endLine();
243
+ yield script.endLine();
163
244
  break;
164
245
  case 'comment':
165
- script.comment(cmd.text);
246
+ yield script.comment(cmd.text);
166
247
  break;
167
248
  case 'importDatabase':
168
- script.importDatabase(cmd.options);
249
+ yield script.importDatabase(cmd.options);
169
250
  break;
170
- case 'dataDuplicator':
171
- script.dataDuplicator(cmd.options);
251
+ case 'dataReplicator':
252
+ yield script.dataReplicator(cmd.options);
253
+ break;
254
+ case 'zipDirectory':
255
+ yield script.zipDirectory(cmd.inputDirectory, cmd.outputFile);
172
256
  break;
173
257
  }
174
- }
175
- return script.getScript(schedule);
258
+ });
259
+ }
260
+ function playJsonScriptWriter(json, script) {
261
+ return __awaiter(this, void 0, void 0, function* () {
262
+ for (const cmd of json.commands) {
263
+ yield playJsonCommand(cmd, script);
264
+ }
265
+ });
266
+ }
267
+ exports.playJsonScriptWriter = playJsonScriptWriter;
268
+ function jsonScriptToJavascript(json) {
269
+ return __awaiter(this, void 0, void 0, function* () {
270
+ const { schedule, packageNames } = json;
271
+ const script = new ScriptWriterJavaScript();
272
+ for (const packageName of packageNames) {
273
+ if (!/^dbgate-plugin-.*$/.test(packageName)) {
274
+ throw new Error('Unallowed package name:' + packageName);
275
+ }
276
+ script.packageNames.push(packageName);
277
+ }
278
+ yield playJsonScriptWriter(json, script);
279
+ return script.getScript(schedule);
280
+ });
176
281
  }
177
282
  exports.jsonScriptToJavascript = jsonScriptToJavascript;
@@ -10,7 +10,7 @@ function isTypeNumeric(dataType) {
10
10
  }
11
11
  exports.isTypeNumeric = isTypeNumeric;
12
12
  function isTypeFloat(dataType) {
13
- return dataType && /float|single|double/i.test(dataType);
13
+ return dataType && /float|single|double|number/i.test(dataType);
14
14
  }
15
15
  exports.isTypeFloat = isTypeFloat;
16
16
  function isTypeNumber(dataType) {
@@ -104,7 +104,9 @@ function createBulkInsertStreamBase(driver, stream, dbhan, name, options) {
104
104
  dmp.putRaw(';');
105
105
  // require('fs').writeFileSync('/home/jena/test.sql', dmp.s);
106
106
  // console.log(dmp.s);
107
- yield driver.query(dbhan, dmp.s, { discardResult: true });
107
+ if (rows.length > 0) {
108
+ yield driver.query(dbhan, dmp.s, { discardResult: true });
109
+ }
108
110
  writable.rowsReporter.add(rows.length);
109
111
  }
110
112
  else {
@@ -1,5 +1,6 @@
1
1
  import type { EngineDriver, ExtensionsDirectory } from 'dbgate-types';
2
2
  export declare function extractShellApiPlugins(functionName: any, props: any): string[];
3
3
  export declare function extractPackageName(name: any): string;
4
- export declare function extractShellApiFunctionName(functionName: any): string;
4
+ export declare function compileShellApiFunctionName(functionName: any): string;
5
+ export declare function evalShellApiFunctionName(functionName: any, dbgateApi: any, requirePlugin: any): any;
5
6
  export declare function findEngineDriver(connection: any, extensions: ExtensionsDirectory): EngineDriver;
@@ -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.findEngineDriver = exports.extractShellApiFunctionName = exports.extractPackageName = exports.extractShellApiPlugins = void 0;
6
+ exports.findEngineDriver = exports.evalShellApiFunctionName = exports.compileShellApiFunctionName = exports.extractPackageName = exports.extractShellApiPlugins = void 0;
7
7
  const camelCase_1 = __importDefault(require("lodash/camelCase"));
8
8
  const isString_1 = __importDefault(require("lodash/isString"));
9
9
  const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
@@ -32,14 +32,22 @@ function extractPackageName(name) {
32
32
  return null;
33
33
  }
34
34
  exports.extractPackageName = extractPackageName;
35
- function extractShellApiFunctionName(functionName) {
35
+ function compileShellApiFunctionName(functionName) {
36
36
  const nsMatch = functionName.match(/^([^@]+)@([^@]+)/);
37
37
  if (nsMatch) {
38
38
  return `${(0, camelCase_1.default)(nsMatch[2])}.shellApi.${nsMatch[1]}`;
39
39
  }
40
40
  return `dbgateApi.${functionName}`;
41
41
  }
42
- exports.extractShellApiFunctionName = extractShellApiFunctionName;
42
+ exports.compileShellApiFunctionName = compileShellApiFunctionName;
43
+ function evalShellApiFunctionName(functionName, dbgateApi, requirePlugin) {
44
+ const nsMatch = functionName.match(/^([^@]+)@([^@]+)/);
45
+ if (nsMatch) {
46
+ return requirePlugin(nsMatch[2]).shellApi[nsMatch[1]];
47
+ }
48
+ return dbgateApi[functionName];
49
+ }
50
+ exports.evalShellApiFunctionName = evalShellApiFunctionName;
43
51
  function findEngineDriver(connection, extensions) {
44
52
  if (!extensions) {
45
53
  return null;
@@ -3,7 +3,7 @@ export type EditorDataType = 'null' | 'objectid' | 'string' | 'number' | 'object
3
3
  export declare function arrayToHexString(byteArray: any): any;
4
4
  export declare function hexStringToArray(inputString: any): any[];
5
5
  export declare function parseCellValue(value: any, editorTypes?: DataEditorTypesBehaviour): any;
6
- export declare function stringifyCellValue(value: any, intent: 'gridCellIntent' | 'inlineEditorIntent' | 'multilineEditorIntent' | 'stringConversionIntent' | 'exportIntent', editorTypes?: DataEditorTypesBehaviour, gridFormattingOptions?: {
6
+ export declare function stringifyCellValue(value: any, intent: 'gridCellIntent' | 'inlineEditorIntent' | 'multilineEditorIntent' | 'stringConversionIntent' | 'exportIntent' | 'clipboardIntent', editorTypes?: DataEditorTypesBehaviour, gridFormattingOptions?: {
7
7
  useThousandsSeparator?: boolean;
8
8
  }, jsonParsedValue?: any): {
9
9
  value: string;
@@ -35,3 +35,5 @@ export declare function extractErrorLogData(err: any, additionalFields?: {}): {
35
35
  export declare function safeFormatDate(date: any): any;
36
36
  export declare function getLimitedQuery(sql: string): string;
37
37
  export declare function pinoLogRecordToMessageRecord(logRecord: any, defaultSeverity?: string): any;
38
+ export declare function jsonLinesStringify(jsonArray: any[]): string;
39
+ export declare function jsonLinesParse(jsonLines: string): any[];
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- 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 = void 0;
17
+ 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 = void 0;
18
18
  const isString_1 = __importDefault(require("lodash/isString"));
19
19
  const isArray_1 = __importDefault(require("lodash/isArray"));
20
20
  const isDate_1 = __importDefault(require("lodash/isDate"));
@@ -195,6 +195,7 @@ function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, j
195
195
  switch (intent) {
196
196
  case 'exportIntent':
197
197
  case 'stringConversionIntent':
198
+ case 'clipboardIntent':
198
199
  return { value: dateString };
199
200
  default:
200
201
  const m = dateString.match(dateTimeStorageRegex);
@@ -326,7 +327,7 @@ function shouldOpenMultilineDialog(value) {
326
327
  }
327
328
  exports.shouldOpenMultilineDialog = shouldOpenMultilineDialog;
328
329
  function isJsonLikeLongString(value) {
329
- return (0, isString_1.default)(value) && value.length > 100 && value.match(/^\s*\{.*\}\s*$|^\s*\[.*\]\s*$/);
330
+ return (0, isString_1.default)(value) && value.length > 100 && value.match(/^\s*\{.*\}\s*$|^\s*\[.*\]\s*$/m);
330
331
  }
331
332
  exports.isJsonLikeLongString = isJsonLikeLongString;
332
333
  function getIconForRedisType(type) {
@@ -533,3 +534,22 @@ function pinoLogRecordToMessageRecord(logRecord, defaultSeverity = 'info') {
533
534
  return Object.assign(Object.assign({}, rest), { time, message: msg, severity: (_a = levelToSeverity[level]) !== null && _a !== void 0 ? _a : defaultSeverity });
534
535
  }
535
536
  exports.pinoLogRecordToMessageRecord = pinoLogRecordToMessageRecord;
537
+ function jsonLinesStringify(jsonArray) {
538
+ return jsonArray.map(json => JSON.stringify(json)).join('\n');
539
+ }
540
+ exports.jsonLinesStringify = jsonLinesStringify;
541
+ function jsonLinesParse(jsonLines) {
542
+ return jsonLines
543
+ .split('\n')
544
+ .filter(x => x.trim())
545
+ .map(line => {
546
+ try {
547
+ return JSON.parse(line);
548
+ }
549
+ catch (e) {
550
+ return null;
551
+ }
552
+ })
553
+ .filter(x => x);
554
+ }
555
+ exports.jsonLinesParse = jsonLinesParse;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.3.3",
2
+ "version": "6.4.1",
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.3.3",
29
+ "dbgate-types": "^6.4.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
- "dbgate-query-splitter": "^4.11.3",
36
- "dbgate-sqltree": "^6.3.3",
35
+ "dbgate-query-splitter": "^4.11.4",
36
+ "dbgate-sqltree": "^6.4.1",
37
37
  "debug": "^4.3.4",
38
38
  "json-stable-stringify": "^1.0.1",
39
39
  "lodash": "^4.17.21",