stimulsoft-data-adapter 2024.4.5 → 2025.1.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.
@@ -1,189 +1,180 @@
1
1
  /*
2
2
  Stimulsoft.Reports.JS
3
- Version: 2024.4.5
4
- Build date: 2024.11.22
3
+ Version: 2025.1.1
4
+ Build date: 2024.12.12
5
5
  License: https://www.stimulsoft.com/en/licensing/reports
6
6
  */
7
7
  exports.process = function (command, onResult) {
8
- var end = function (result) {
9
- try {
10
- if (db) db.detach();
11
- result.adapterVersion = "2024.4.5";
12
- onResult(result);
13
- }
14
- catch (e) {
15
- }
16
- }
17
-
18
- var onError = function (message) {
19
- end({ success: false, notice: message });
20
- }
21
-
22
- try {
23
- var connect = function () {
24
- Firebird.attach(options, function (error, db1) {
25
- db = db1;
26
- if (error) onError(error.message);
27
- else onConnect();
28
- });
8
+ setTimeout(async () => {
9
+ var db;
10
+
11
+ var end = function (result) {
12
+ try {
13
+ if (db) db.detach();
14
+ result.adapterVersion = "2025.1.1";
15
+ onResult(result);
16
+ }
17
+ catch (e) {
18
+ }
29
19
  }
30
20
 
31
- var query = function (queryString, maxDataRows) {
32
- db.query(queryString, undefined, function (error, recordset) {
33
- if (error) onError(error.message);
34
- else onQuery(recordset, maxDataRows);
35
- db.detach();
36
- });
21
+ var error = function (message) {
22
+ end({ success: false, notice: message });
37
23
  }
38
24
 
39
- var onConnect = function () {
40
- if (command.queryString) {
41
- var queryString = applyQueryParameters(command.queryString, command.parameters, command.escapeQueryParameters);
42
- query(queryString, command.maxDataRows);
25
+ try {
26
+ var connect = async function () {
27
+ db = await firebird.attachDataBase(options);
28
+
29
+ if (command.queryString) {
30
+ var queryString = applyQueryParameters(command.queryString, command.parameters, command.escapeQueryParameters);
31
+ await query(queryString, command.maxDataRows);
32
+ }
33
+ else end({ success: true });
43
34
  }
44
- else end({ success: true });
45
- }
46
35
 
47
- var onQuery = function (recordset, maxDataRows) {
48
- var columns = [];
49
- var rows = [];
50
- var types = [];
51
- var isColumnsFill = false;
52
- for (var recordIndex in recordset) {
53
- var row = [];
54
- for (var columnName in recordset[recordIndex]) {
55
- if (!isColumnsFill) columns.push(columnName);
56
- var columnIndex = columns.indexOf(columnName);
57
- types[columnIndex] = typeof recordset[recordIndex][columnName];
58
- if (recordset[recordIndex][columnName] instanceof Uint8Array ||
59
- recordset[recordIndex][columnName] instanceof Buffer) {
60
- recordset[recordIndex][columnName] = recordset[recordIndex][columnName].toString();
61
- types[columnIndex] = "string";
62
- }
63
- if (recordset[recordIndex][columnName] != null && typeof recordset[recordIndex][columnName].toISOString === "function") {
64
- var dateTime = new Date(recordset[recordIndex][columnName].getTime() - (recordset[recordIndex][columnName].getTimezoneOffset() * 60000)).toISOString();
65
- recordset[recordIndex][columnName] = dateTime.replace("Z", "");
66
- types[columnIndex] = "datetime";
67
- }
36
+ var query = async function (queryString, maxDataRows) {
37
+ var recordset = await db.query(queryString);
38
+
39
+ var columns = [];
40
+ var rows = [];
41
+ var types = [];
42
+ var isColumnsFill = false;
43
+ for (var recordIndex in recordset) {
44
+ var row = [];
45
+ for (var columnName in recordset[recordIndex]) {
46
+ if (!isColumnsFill) columns.push(columnName);
47
+ var columnIndex = columns.indexOf(columnName);
48
+ types[columnIndex] = typeof recordset[recordIndex][columnName];
49
+ if (recordset[recordIndex][columnName] instanceof Uint8Array ||
50
+ recordset[recordIndex][columnName] instanceof Buffer) {
51
+ recordset[recordIndex][columnName] = recordset[recordIndex][columnName].toString();
52
+ types[columnIndex] = "string";
53
+ }
54
+ if (recordset[recordIndex][columnName] != null && typeof recordset[recordIndex][columnName].toISOString === "function") {
55
+ var dateTime = new Date(recordset[recordIndex][columnName].getTime() - (recordset[recordIndex][columnName].getTimezoneOffset() * 60000)).toISOString();
56
+ recordset[recordIndex][columnName] = dateTime.replace("Z", "");
57
+ types[columnIndex] = "datetime";
58
+ }
68
59
 
69
- row[columnIndex] = recordset[recordIndex][columnName];
60
+ row[columnIndex] = recordset[recordIndex][columnName];
61
+ }
62
+ isColumnsFill = true;
63
+ if (maxDataRows != null && maxDataRows <= rows.length) break;
64
+ rows.push(row);
70
65
  }
71
- isColumnsFill = true;
72
- if (maxDataRows != null && maxDataRows <= rows.length) break;
73
- rows.push(row);
74
- }
75
66
 
76
- end({ success: true, columns: columns, rows: rows, types: types });
77
- }
67
+ end({ success: true, columns: columns, rows: rows, types: types });
68
+ }
78
69
 
79
- var getConnectionStringInfo = function (connectionString) {
80
- var info = { host: "localhost", port: "3050" };
81
- var isCorrect = false;
82
- for (var propertyIndex in connectionString.split(";")) {
83
- var property = connectionString.split(";")[propertyIndex];
84
- if (property) {
85
- var match = property.split("=");
86
- if (match && match.length >= 2) {
87
- match[0] = match[0].trim().toLowerCase();
88
- match[1] = match[1].trim();
89
-
90
- switch (match[0]) {
91
- case "server":
92
- case "host":
93
- case "location":
94
- case "datasource":
95
- case "data source":
96
- info["host"] = match[1];
97
- break;
98
-
99
- case "port":
100
- info["port"] = match[1];
101
- break;
102
-
103
- case "database":
104
- info["database"] = match[1];
105
- isCorrect = true;
106
- break;
107
-
108
- case "uid":
109
- case "user":
110
- case "user id":
111
- info["userId"] = match[1];
112
- break;
113
-
114
- case "pwd":
115
- case "password":
116
- info["password"] = match[1];
117
- break;
118
-
119
- case "charset":
120
- info["charset"] = match[1];
121
- break;
70
+ var getConnectionStringInfo = function (connectionString) {
71
+ var info = { host: "localhost", port: "3050" };
72
+ var isCorrect = false;
73
+ for (var propertyIndex in connectionString.split(";")) {
74
+ var property = connectionString.split(";")[propertyIndex];
75
+ if (property) {
76
+ var match = property.split("=");
77
+ if (match && match.length >= 2) {
78
+ match[0] = match[0].trim().toLowerCase();
79
+ match[1] = match[1].trim();
80
+
81
+ switch (match[0]) {
82
+ case "server":
83
+ case "host":
84
+ case "location":
85
+ case "datasource":
86
+ case "data source":
87
+ info["host"] = match[1];
88
+ break;
89
+
90
+ case "port":
91
+ info["port"] = match[1];
92
+ break;
93
+
94
+ case "database":
95
+ info["database"] = match[1];
96
+ isCorrect = true;
97
+ break;
98
+
99
+ case "uid":
100
+ case "user":
101
+ case "user id":
102
+ info["userId"] = match[1];
103
+ break;
104
+
105
+ case "pwd":
106
+ case "password":
107
+ info["password"] = match[1];
108
+ break;
109
+
110
+ case "charset":
111
+ info["charset"] = match[1];
112
+ break;
113
+ }
122
114
  }
123
115
  }
124
116
  }
125
- }
126
- if (!isCorrect) {
127
- onError("Connection String parse error");
128
- return null;
129
- }
130
- return info;
131
- };
117
+ if (!isCorrect) {
118
+ error("Connection String parse error");
119
+ return null;
120
+ }
121
+ return info;
122
+ };
132
123
 
133
- var applyQueryParameters = function (baseSqlCommand, parameters, escapeQueryParameters) {
134
- if (baseSqlCommand == null || baseSqlCommand.indexOf("@") < 0) return baseSqlCommand;
124
+ var applyQueryParameters = function (baseSqlCommand, parameters, escapeQueryParameters) {
125
+ if (baseSqlCommand == null || baseSqlCommand.indexOf("@") < 0) return baseSqlCommand;
135
126
 
136
- var result = "";
137
- while (baseSqlCommand.indexOf("@") >= 0 && parameters != null && parameters.length > 0) {
138
- result += baseSqlCommand.substring(0, baseSqlCommand.indexOf("@"));
139
- baseSqlCommand = baseSqlCommand.substring(baseSqlCommand.indexOf("@") + 1);
127
+ var result = "";
128
+ while (baseSqlCommand.indexOf("@") >= 0 && parameters != null && parameters.length > 0) {
129
+ result += baseSqlCommand.substring(0, baseSqlCommand.indexOf("@"));
130
+ baseSqlCommand = baseSqlCommand.substring(baseSqlCommand.indexOf("@") + 1);
140
131
 
141
- var parameterName = "";
132
+ var parameterName = "";
142
133
 
143
- while (baseSqlCommand.length > 0) {
144
- var char = baseSqlCommand.charAt(0);
145
- if (char.length === 1 && char.match(/[a-zA-Z0-9_-]/i)) {
146
- parameterName += char;
147
- baseSqlCommand = baseSqlCommand.substring(1);
134
+ while (baseSqlCommand.length > 0) {
135
+ var char = baseSqlCommand.charAt(0);
136
+ if (char.length === 1 && char.match(/[a-zA-Z0-9_-]/i)) {
137
+ parameterName += char;
138
+ baseSqlCommand = baseSqlCommand.substring(1);
139
+ }
140
+ else break;
148
141
  }
149
- else break;
150
- }
151
142
 
152
- var parameter = parameters.find(parameter => parameter.name.toLowerCase() == parameterName.toLowerCase());
153
- if (parameter) {
154
- if (parameter.typeGroup != "number") {
155
- if (escapeQueryParameters)
156
- result += "'" + parameter.value.toString().replace(/\\/gi, "\\\\").replace(/\'/gi, "\\\'").replace(/\"/gi, "\\\"") + "'";
143
+ var parameter = parameters.find(parameter => parameter.name.toLowerCase() == parameterName.toLowerCase());
144
+ if (parameter) {
145
+ if (parameter.typeGroup != "number") {
146
+ if (escapeQueryParameters)
147
+ result += "'" + parameter.value.toString().replace(/\\/gi, "\\\\").replace(/\'/gi, "\\\'").replace(/\"/gi, "\\\"") + "'";
148
+ else
149
+ result += "'" + parameter.value.toString() + "'";
150
+ }
157
151
  else
158
- result += "'" + parameter.value.toString() + "'";
152
+ result += parameter.value.toString();
159
153
  }
160
154
  else
161
- result += parameter.value.toString();
155
+ result += "@" + parameterName;
162
156
  }
163
- else
164
- result += "@" + parameterName;
157
+
158
+ return result + baseSqlCommand;
165
159
  }
166
160
 
167
- return result + baseSqlCommand;
161
+ const firebird = require("limber-firebird-client");
162
+ command.connectionStringInfo = getConnectionStringInfo(command.connectionString);
163
+ if (command.connectionStringInfo) {
164
+ var options = {
165
+ host: command.connectionStringInfo.host,
166
+ port: command.connectionStringInfo.port,
167
+ database: command.connectionStringInfo.database,
168
+ user: command.connectionStringInfo.userId,
169
+ password: command.connectionStringInfo.password,
170
+ charset: command.connectionStringInfo.charset,
171
+ };
172
+
173
+ await connect();
174
+ }
168
175
  }
169
-
170
- var Firebird = require('node-firebird');
171
- command.connectionStringInfo = getConnectionStringInfo(command.connectionString);
172
- if (command.connectionStringInfo) {
173
- var options = {
174
- host: command.connectionStringInfo.host,
175
- port: command.connectionStringInfo.port,
176
- database: command.connectionStringInfo.database,
177
- user: command.connectionStringInfo.userId,
178
- password: command.connectionStringInfo.password,
179
- charset: command.connectionStringInfo.charset,
180
- };
181
-
182
- connect();
183
- var db;
176
+ catch (e) {
177
+ error(e.message);
184
178
  }
185
- }
186
- catch (e) {
187
- onError(e.stack);
188
- }
179
+ });
189
180
  }
package/MSSQLAdapter.js CHANGED
@@ -1,14 +1,14 @@
1
1
  /*
2
2
  Stimulsoft.Reports.JS
3
- Version: 2024.4.5
4
- Build date: 2024.11.22
3
+ Version: 2025.1.1
4
+ Build date: 2024.12.12
5
5
  License: https://www.stimulsoft.com/en/licensing/reports
6
6
  */
7
7
  exports.process = function (command, onResult) {
8
8
  var end = function (result) {
9
9
  try {
10
10
  if (connection) connection.close();
11
- result.adapterVersion = "2024.4.5";
11
+ result.adapterVersion = "2025.1.1";
12
12
  onResult(result);
13
13
  }
14
14
  catch (e) {
package/MongoDBAdapter.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Stimulsoft.Reports.JS
3
- Version: 2024.4.5
4
- Build date: 2024.11.22
3
+ Version: 2025.1.1
4
+ Build date: 2024.12.12
5
5
  License: https://www.stimulsoft.com/en/licensing/reports
6
6
  */
7
7
  exports.process = function (command, onResult) {
@@ -127,7 +127,7 @@ exports.process = function (command, onResult) {
127
127
  }
128
128
 
129
129
  client.close();
130
- result.adapterVersion = "2024.4.5";
130
+ result.adapterVersion = "2025.1.1";
131
131
  onResult(result);
132
132
  });
133
133
  }
package/MySQLAdapter.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Stimulsoft.Reports.JS
3
- Version: 2024.4.5
4
- Build date: 2024.11.22
3
+ Version: 2025.1.1
4
+ Build date: 2024.12.12
5
5
  License: https://www.stimulsoft.com/en/licensing/reports
6
6
  */
7
7
  exports.process = function (command, onResult) {
@@ -13,7 +13,7 @@ exports.process = function (command, onResult) {
13
13
  catch (e) {
14
14
  }
15
15
  finally {
16
- result.adapterVersion = "2024.4.5";
16
+ result.adapterVersion = "2025.1.1";
17
17
  onResult(result);
18
18
  }
19
19
  }
@@ -1,14 +1,14 @@
1
1
  /*
2
2
  Stimulsoft.Reports.JS
3
- Version: 2024.4.5
4
- Build date: 2024.11.22
3
+ Version: 2025.1.1
4
+ Build date: 2024.12.12
5
5
  License: https://www.stimulsoft.com/en/licensing/reports
6
6
  */
7
7
  exports.process = function (command, onResult) {
8
8
  var end = function (result) {
9
9
  try {
10
10
  if (client) client.end();
11
- result.adapterVersion = "2024.4.5";
11
+ result.adapterVersion = "2025.1.1";
12
12
  onResult(result);
13
13
  }
14
14
  catch (e) {
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Stimulsoft.Reports.JS
3
- Version: 2024.4.5
4
- Build date: 2024.11.22
3
+ Version: 2025.1.1
4
+ Build date: 2024.12.12
5
5
  License: https://www.stimulsoft.com/en/licensing/reports
6
6
  */
7
7
 
@@ -75,7 +75,7 @@ function getResponse(result) {
75
75
  return result
76
76
  }
77
77
  function onProcess(onResult, encryptData, result) {
78
- result.handlerVersion = "2024.4.5";
78
+ result.handlerVersion = "2025.1.1";
79
79
  result.checkVersion = true;
80
80
  result.encryptData = encryptData;
81
81
  onResult(result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stimulsoft-data-adapter",
3
- "version": "2024.4.5",
3
+ "version": "2025.1.1",
4
4
  "description": "Nodejs data adapter for Stimulsoft Reports.JS",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,12 +11,12 @@
11
11
  "url": "https://github.com/stimulsoft/DataAdapters.JS/tree/main/NodejsDataAdapters"
12
12
  },
13
13
  "dependencies": {
14
- "mongodb": "^6.9.0",
14
+ "limber-firebird-client": "^3.0.17",
15
+ "mongodb": "^6.11.0",
15
16
  "mssql": "^11.0.1",
16
- "mysql2": "^3.11.3",
17
- "node-firebird": "^1.1.9",
18
- "oracledb": "^6.6.0",
19
- "pg": "^8.13.0",
17
+ "mysql2": "^3.11.5",
18
+ "oracledb": "^6.7.0",
19
+ "pg": "^8.13.1",
20
20
  "tzdata": "^1.0.42"
21
21
  },
22
22
  "files": [
@@ -50,4 +50,4 @@
50
50
  ],
51
51
  "license": "Closed Source",
52
52
  "homepage": "https://github.com/stimulsoft/DataAdapters.JS/tree/main/NodejsDataAdapters"
53
- }
53
+ }