web_plsql 0.17.0 → 0.17.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/package.json +8 -8
- package/src/handler/plsql/cgi.js +1 -1
- package/src/handler/plsql/procedure.js +29 -41
- package/src/handler/plsql/request.js +6 -1
- package/src/index.js +5 -1
- package/src/server/config.js +1 -1
- package/src/{server/version.js → version.js} +1 -1
- package/types/index.d.ts +3 -1
- /package/types/{server/version.d.ts → version.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web_plsql",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"author": "Dieter Oberkofler <dieter.oberkofler@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The Express Middleware for Oracle PL/SQL",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"test": "node --test --test-concurrency=1 \"./tests/**/*.test.js\"",
|
|
48
48
|
"types": "rm -rf types && tsc --noEmit false --declaration true --declarationDir types --emitDeclarationOnly true --allowJs true --target es2020 --module es2020 --moduleResolution node --allowSyntheticDefaultImports true src/*.js",
|
|
49
49
|
"clean": "shx rm -f *.tgz && shx rm -f *.log",
|
|
50
|
-
"ci": "npm run clean && npm run lint && npm run test && npm run types",
|
|
50
|
+
"ci": "npm run clean && npm run version && npm run lint && npm run test && npm run types",
|
|
51
|
+
"version": "node update-version.js",
|
|
51
52
|
"create-package": "shx rm -f *.tgz && npm pack",
|
|
52
53
|
"image-build": "docker build --no-cache --progress=plain --tag=web_plsql .",
|
|
53
54
|
"image-save": "docker save web_plsql | gzip > web_plsql.tar.gz"
|
|
@@ -56,7 +57,6 @@
|
|
|
56
57
|
"oracledb": "6.10.0"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"basic-auth": "2.0.1",
|
|
60
60
|
"compression": "1.8.1",
|
|
61
61
|
"cookie-parser": "1.4.7",
|
|
62
62
|
"debug": "4.4.3",
|
|
@@ -64,25 +64,25 @@
|
|
|
64
64
|
"http-parser-js": "0.5.10",
|
|
65
65
|
"morgan": "1.10.1",
|
|
66
66
|
"multer": "2.0.2",
|
|
67
|
-
"rotating-file-stream": "3.2.
|
|
67
|
+
"rotating-file-stream": "3.2.8",
|
|
68
68
|
"zod": "4.3.6"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@types/basic-auth": "1.1.8",
|
|
72
71
|
"@types/compression": "1.8.1",
|
|
73
72
|
"@types/cookie-parser": "1.4.10",
|
|
74
73
|
"@types/debug": "4.1.12",
|
|
75
74
|
"@types/morgan": "1.9.10",
|
|
76
75
|
"@types/multer": "2.0.0",
|
|
77
|
-
"@types/node": "25.0
|
|
76
|
+
"@types/node": "25.2.0",
|
|
78
77
|
"@types/oracledb": "6.10.1",
|
|
79
78
|
"@types/supertest": "6.0.3",
|
|
80
79
|
"eslint": "9.39.2",
|
|
81
|
-
"eslint-plugin-jsdoc": "62.
|
|
80
|
+
"eslint-plugin-jsdoc": "62.5.1",
|
|
81
|
+
"oracledb": "6.10.0",
|
|
82
82
|
"prettier": "3.8.1",
|
|
83
83
|
"shx": "0.4.0",
|
|
84
84
|
"supertest": "7.2.2",
|
|
85
85
|
"typescript": "5.9.3",
|
|
86
|
-
"typescript-eslint": "8.
|
|
86
|
+
"typescript-eslint": "8.54.0"
|
|
87
87
|
}
|
|
88
88
|
}
|
package/src/handler/plsql/cgi.js
CHANGED
|
@@ -109,7 +109,7 @@ export const getCGI = (req, doctable, cgi) => {
|
|
|
109
109
|
const CGI = {
|
|
110
110
|
SERVER_PORT: typeof req.socket.localPort === 'number' ? req.socket.localPort.toString() : '',
|
|
111
111
|
REQUEST_METHOD: req.method,
|
|
112
|
-
PATH_INFO: req.params.name,
|
|
112
|
+
PATH_INFO: Array.isArray(req.params.name) ? req.params.name[0] : req.params.name,
|
|
113
113
|
SCRIPT_NAME: PATH.script,
|
|
114
114
|
REMOTE_ADDR: (req.ip ?? '').replace('::ffff:', ''),
|
|
115
115
|
SERVER_PROTOCOL: `${PROTOCOL}/${req.httpVersion}`,
|
|
@@ -82,7 +82,7 @@ const procedurePrepare = async (cgiObj, databaseConnection) => {
|
|
|
82
82
|
try {
|
|
83
83
|
await databaseConnection.execute(sqlStatement);
|
|
84
84
|
} catch (err) {
|
|
85
|
-
throw new ProcedureError(`
|
|
85
|
+
throw new ProcedureError(`procedurePrepare: error when preparing procedure\n${errorToString(err)}`, cgiObj, sqlStatement, {});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// htbuf_len: reduce this limit based on your worst-case character size.
|
|
@@ -99,7 +99,7 @@ const procedurePrepare = async (cgiObj, databaseConnection) => {
|
|
|
99
99
|
try {
|
|
100
100
|
await databaseConnection.execute(sqlStatement, bindParameter);
|
|
101
101
|
} catch (err) {
|
|
102
|
-
throw new ProcedureError(`
|
|
102
|
+
throw new ProcedureError(`procedurePrepare: error when preparing procedure\n${errorToString(err)}`, cgiObj, sqlStatement, bindParameter);
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
@@ -116,7 +116,7 @@ const procedureExecute = async (para, databaseConnection) => {
|
|
|
116
116
|
try {
|
|
117
117
|
await databaseConnection.execute(sqlStatement, para.bind);
|
|
118
118
|
} catch (err) {
|
|
119
|
-
throw new ProcedureError(`
|
|
119
|
+
throw new ProcedureError(`procedureExecute: error when executing procedure:\n${sqlStatement}\n${errorToString(err)}`, {}, para.sql, para.bind);
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
|
|
@@ -144,10 +144,10 @@ const procedureGetPage = async (test, databaseConnection) => {
|
|
|
144
144
|
result = await databaseConnection.execute(sqlStatement, bindParameter);
|
|
145
145
|
} catch (err) {
|
|
146
146
|
if (debug.enabled) {
|
|
147
|
-
debug(getBlock('results', inspect(result)));
|
|
147
|
+
debug(getBlock('procedureGetPage: results', inspect(result)));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
throw new ProcedureError(`
|
|
150
|
+
throw new ProcedureError(`procedureGetPage: error when getting page returned by procedure\n${errorToString(err)}`, {}, sqlStatement, bindParameter);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
const {lines, irows} = z.object({irows: z.number(), lines: z.array(z.string())}).parse(result.outBinds);
|
|
@@ -155,7 +155,7 @@ const procedureGetPage = async (test, databaseConnection) => {
|
|
|
155
155
|
// Make sure that we have retrieved all the rows
|
|
156
156
|
if (irows > MAX_IROWS) {
|
|
157
157
|
/* istanbul ignore next */
|
|
158
|
-
throw new ProcedureError(`
|
|
158
|
+
throw new ProcedureError(`procedureGetPage: error when retrieving rows. irows="${irows}"`, {}, sqlStatement, bindParameter);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
return lines.join('');
|
|
@@ -199,10 +199,10 @@ END;
|
|
|
199
199
|
result = await databaseConnection.execute(sqlStatement, bindParameter);
|
|
200
200
|
} catch (err) {
|
|
201
201
|
if (debug.enabled) {
|
|
202
|
-
debug(getBlock('results', inspect(result)));
|
|
202
|
+
debug(getBlock('procedureDownloadFiles: results', inspect(result)));
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
throw new ProcedureError(`
|
|
205
|
+
throw new ProcedureError(`procedureDownloadFiles: error when downloading files\n${errorToString(err)}`, {}, sqlStatement, bindParameter);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
return z
|
|
@@ -233,12 +233,9 @@ END;
|
|
|
233
233
|
* @returns {Promise<void>} Promise resolving to the page content generated by the executed procedure
|
|
234
234
|
*/
|
|
235
235
|
export const invokeProcedure = async (req, res, argObj, cgiObj, filesToUpload, options, databaseConnection) => {
|
|
236
|
-
debug('invokeProcedure:
|
|
237
|
-
|
|
238
|
-
//
|
|
239
|
-
// UPLOAD FILES
|
|
240
|
-
//
|
|
236
|
+
debug('invokeProcedure: begin');
|
|
241
237
|
|
|
238
|
+
// 1) upload files
|
|
242
239
|
debug(`invokeProcedure: upload "${filesToUpload.length}" files`);
|
|
243
240
|
if (filesToUpload.length > 0) {
|
|
244
241
|
if (typeof options.documentTable === 'string' && options.documentTable.length > 0) {
|
|
@@ -250,48 +247,41 @@ export const invokeProcedure = async (req, res, argObj, cgiObj, filesToUpload, o
|
|
|
250
247
|
}
|
|
251
248
|
}
|
|
252
249
|
|
|
253
|
-
//
|
|
254
|
-
// GET SQL STATEMENT AND ARGUMENTS
|
|
255
|
-
//
|
|
250
|
+
// 2) get procedure to execute and the arguments
|
|
256
251
|
|
|
257
|
-
|
|
252
|
+
debug('invokeProcedure: get procedure to execute and the arguments');
|
|
253
|
+
const para = await getProcedure(req, Array.isArray(req.params.name) ? req.params.name[0] : req.params.name, argObj, options, databaseConnection);
|
|
258
254
|
|
|
259
|
-
//
|
|
260
|
-
// PROCEDURE PREPARE
|
|
261
|
-
//
|
|
255
|
+
// 3) prepare the session
|
|
262
256
|
|
|
257
|
+
debug('invokeProcedure: prepare the session');
|
|
263
258
|
await procedurePrepare(cgiObj, databaseConnection);
|
|
264
259
|
|
|
265
|
-
//
|
|
266
|
-
// PROCEDURE EXECUTE
|
|
267
|
-
//
|
|
260
|
+
// 4) execute the procedure
|
|
268
261
|
|
|
262
|
+
debug('invokeProcedure: execute the session');
|
|
269
263
|
await procedureExecute(para, databaseConnection);
|
|
270
264
|
|
|
271
|
-
//
|
|
272
|
-
// PROCEDURE GET PAGE
|
|
273
|
-
//
|
|
265
|
+
// 5) get the page returned from the procedure
|
|
274
266
|
|
|
267
|
+
debug('invokeProcedure: get the page returned from the procedure');
|
|
275
268
|
const lines = await procedureGetPage(true, databaseConnection);
|
|
276
269
|
if (debug.enabled) {
|
|
277
270
|
debug(getBlock('data', lines));
|
|
278
271
|
}
|
|
279
272
|
|
|
280
|
-
//
|
|
281
|
-
// PROCEDURE DOWNLOAD FILE
|
|
282
|
-
//
|
|
273
|
+
// 6) download files
|
|
283
274
|
|
|
275
|
+
debug('invokeProcedure: download files');
|
|
284
276
|
const fileBlob = await databaseConnection.createLob(oracledb.BLOB);
|
|
285
277
|
const fileDownload = await procedureDownloadFiles(fileBlob, databaseConnection);
|
|
286
278
|
if (debug.enabled) {
|
|
287
|
-
debug(getBlock('
|
|
279
|
+
debug(getBlock('fileDownload', inspect({fileType: fileDownload.fileType, fileSize: fileDownload.fileSize})));
|
|
288
280
|
}
|
|
289
281
|
|
|
290
|
-
//
|
|
291
|
-
// PARSE PAGE
|
|
292
|
-
//
|
|
282
|
+
// 7) parse the page
|
|
293
283
|
|
|
294
|
-
|
|
284
|
+
debug('invokeProcedure: parse the page');
|
|
295
285
|
const pageComponents = parsePage(lines);
|
|
296
286
|
|
|
297
287
|
// add "Server" header
|
|
@@ -304,17 +294,15 @@ export const invokeProcedure = async (req, res, argObj, cgiObj, filesToUpload, o
|
|
|
304
294
|
pageComponents.file.fileBlob = await streamToBuffer(fileDownload.fileBlob);
|
|
305
295
|
}
|
|
306
296
|
|
|
307
|
-
//
|
|
308
|
-
// SEND THE RESPONSE
|
|
309
|
-
//
|
|
297
|
+
// 8) send the page to browser
|
|
310
298
|
|
|
299
|
+
debug('invokeProcedure: send the page to browser');
|
|
311
300
|
sendResponse(req, res, pageComponents);
|
|
312
301
|
|
|
313
|
-
//
|
|
314
|
-
// CLEANUP
|
|
315
|
-
//
|
|
302
|
+
// 9) cleanup
|
|
316
303
|
|
|
304
|
+
debug('invokeProcedure: cleanup');
|
|
317
305
|
fileBlob.destroy();
|
|
318
306
|
|
|
319
|
-
debug('invokeProcedure:
|
|
307
|
+
debug('invokeProcedure: end');
|
|
320
308
|
};
|
|
@@ -33,6 +33,11 @@ import {isStringOrArrayOfString} from '../../util/type.js';
|
|
|
33
33
|
export const processRequest = async (req, res, options, connectionPool) => {
|
|
34
34
|
debug('processRequest: ENTER');
|
|
35
35
|
|
|
36
|
+
//
|
|
37
|
+
if (Array.isArray(req.params.name)) {
|
|
38
|
+
console.warn(`processRequest: WARNING: the req.params.name is not a string but an array of string: ${req.params.name.join(',')}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
// open database connection
|
|
37
42
|
const connection = await connectionPool.getConnection();
|
|
38
43
|
|
|
@@ -68,7 +73,7 @@ export const processRequest = async (req, res, options, connectionPool) => {
|
|
|
68
73
|
await connection.rollback();
|
|
69
74
|
} else if (typeof options.transactionMode === 'function') {
|
|
70
75
|
debug('transactionMode: callback');
|
|
71
|
-
const result = options.transactionMode(connection, req.params.name);
|
|
76
|
+
const result = options.transactionMode(connection, Array.isArray(req.params.name) ? req.params.name[0] : req.params.name);
|
|
72
77
|
debug('transactionMode: callback restult', result);
|
|
73
78
|
if (result && typeof result.then === 'function') {
|
|
74
79
|
await result;
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
// libraries
|
|
2
|
+
import oracledb from 'oracledb';
|
|
3
|
+
export {oracledb};
|
|
4
|
+
|
|
1
5
|
// server
|
|
2
|
-
export {getVersion} from './
|
|
6
|
+
export {getVersion} from './version.js';
|
|
3
7
|
export {createServer, startServer, loadConfig, startServerConfig} from './server/server.js';
|
|
4
8
|
export * from './util/shutdown.js';
|
|
5
9
|
|
package/src/server/config.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { oracledb };
|
|
2
|
+
export { getVersion } from "./version.js";
|
|
2
3
|
export * from "./util/shutdown.js";
|
|
3
4
|
export * from "./util/oracle.js";
|
|
4
5
|
export * from "./util/file.js";
|
|
@@ -6,4 +7,5 @@ export { handlerWebPlSql } from "./handler/plsql/handlerPlSql.js";
|
|
|
6
7
|
export { handlerLogger } from "./handler/handlerLogger.js";
|
|
7
8
|
export { handlerUpload } from "./handler/handlerUpload.js";
|
|
8
9
|
export { handlerMetrics } from "./handler/handlerMetrics.js";
|
|
10
|
+
import oracledb from 'oracledb';
|
|
9
11
|
export { createServer, startServer, loadConfig, startServerConfig } from "./server/server.js";
|
|
File without changes
|