web_plsql 1.0.0 → 1.3.0
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/README.md +108 -13
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/frontend/assets/main-0oxRTIkL.js +147 -0
- package/dist/frontend/assets/main-0oxRTIkL.js.br +0 -0
- package/dist/frontend/assets/main-0oxRTIkL.js.gz +0 -0
- package/dist/frontend/assets/main-TYgLak6O.css +1 -0
- package/dist/frontend/assets/main-TYgLak6O.css.br +0 -0
- package/dist/frontend/assets/main-TYgLak6O.css.gz +0 -0
- package/dist/frontend/index.html +516 -0
- package/dist/frontend/index.html.br +0 -0
- package/dist/frontend/index.html.gz +0 -0
- package/dist/index.d.mts +646 -0
- package/dist/index.mjs +3548 -0
- package/dist/index.mjs.map +1 -0
- package/dist/oracledb-mock-Dn8aHtd7.mjs +68 -0
- package/dist/oracledb-mock-Dn8aHtd7.mjs.map +1 -0
- package/examples/config-apex.js +1 -1
- package/examples/config-docker.js +1 -2
- package/package.json +45 -32
- package/examples/config-native.js +0 -68
- package/src/admin/client/charts.ts +0 -299
- package/src/admin/client/main.js +0 -3
- package/src/admin/client/tailwind.css +0 -41
- package/src/admin/index.html +0 -315
- package/src/admin/js/api.ts +0 -95
- package/src/admin/js/app.ts +0 -306
- package/src/admin/js/eslint.config.js +0 -74
- package/src/admin/js/schemas.ts +0 -153
- package/src/admin/js/templates/config.ts +0 -146
- package/src/admin/js/templates/errorRow.ts +0 -18
- package/src/admin/js/templates/index.ts +0 -3
- package/src/admin/js/templates/poolCard.ts +0 -61
- package/src/admin/js/tsconfig.json +0 -24
- package/src/admin/js/types.ts +0 -223
- package/src/admin/js/ui/theme.ts +0 -93
- package/src/admin/js/ui/views.ts +0 -164
- package/src/admin/js/util/format.ts +0 -27
- package/src/admin/lib/assets/main-zpdhQ1gD.css +0 -1
- package/src/admin/lib/chart.bundle.js +0 -139
- package/src/admin/style.css +0 -1321
- package/src/bin/load-test.js +0 -202
- package/src/handler/handlerAdmin.js +0 -198
- package/src/handler/handlerLogger.js +0 -21
- package/src/handler/handlerMetrics.js +0 -68
- package/src/handler/handlerUpload.js +0 -26
- package/src/handler/plsql/cgi.js +0 -131
- package/src/handler/plsql/errorPage.js +0 -117
- package/src/handler/plsql/handlerPlSql.js +0 -90
- package/src/handler/plsql/parsePage.js +0 -213
- package/src/handler/plsql/procedure.js +0 -356
- package/src/handler/plsql/procedureError.js +0 -40
- package/src/handler/plsql/procedureNamed.js +0 -268
- package/src/handler/plsql/procedureSanitize.js +0 -262
- package/src/handler/plsql/procedureVariable.js +0 -54
- package/src/handler/plsql/request.js +0 -124
- package/src/handler/plsql/requestError.js +0 -23
- package/src/handler/plsql/sendResponse.js +0 -136
- package/src/handler/plsql/stream.js +0 -28
- package/src/handler/plsql/upload.js +0 -109
- package/src/index.js +0 -20
- package/src/server/config.js +0 -57
- package/src/server/connections.js +0 -40
- package/src/server/server.js +0 -289
- package/src/types.js +0 -150
- package/src/util/cache.js +0 -123
- package/src/util/errorToString.js +0 -24
- package/src/util/file.js +0 -91
- package/src/util/html.js +0 -53
- package/src/util/jsonLogger.js +0 -47
- package/src/util/oracle.js +0 -80
- package/src/util/shutdown.js +0 -44
- package/src/util/trace.js +0 -325
- package/src/util/type.js +0 -6
- package/src/util/util.js +0 -66
- package/src/version.js +0 -5
- package/types/handler/handlerAdmin.d.ts +0 -9
- package/types/handler/handlerLogger.d.ts +0 -2
- package/types/handler/handlerMetrics.d.ts +0 -25
- package/types/handler/handlerUpload.d.ts +0 -7
- package/types/handler/plsql/cgi.d.ts +0 -4
- package/types/handler/plsql/errorPage.d.ts +0 -11
- package/types/handler/plsql/handlerPlSql.d.ts +0 -13
- package/types/handler/plsql/parsePage.d.ts +0 -3
- package/types/handler/plsql/procedure.d.ts +0 -12
- package/types/handler/plsql/procedureError.d.ts +0 -23
- package/types/handler/plsql/procedureNamed.d.ts +0 -14
- package/types/handler/plsql/procedureSanitize.d.ts +0 -11
- package/types/handler/plsql/procedureVariable.d.ts +0 -10
- package/types/handler/plsql/request.d.ts +0 -9
- package/types/handler/plsql/requestError.d.ts +0 -8
- package/types/handler/plsql/sendResponse.d.ts +0 -6
- package/types/handler/plsql/upload.d.ts +0 -5
- package/types/index.d.ts +0 -11
- package/types/server/config.d.ts +0 -2
- package/types/server/server.d.ts +0 -74
- package/types/types.d.ts +0 -328
- package/types/util/cache.d.ts +0 -69
- package/types/util/errorToString.d.ts +0 -1
- package/types/util/file.d.ts +0 -6
- package/types/util/html.d.ts +0 -3
- package/types/util/jsonLogger.d.ts +0 -45
- package/types/util/oracle.d.ts +0 -5
- package/types/util/shutdown.d.ts +0 -2
- package/types/util/trace.d.ts +0 -22
- package/types/util/type.d.ts +0 -1
- package/types/util/util.d.ts +0 -3
- package/types/version.d.ts +0 -1
- /package/{src/admin/favicon.svg → dist/frontend/assets/favicon-mQAM4tVu.svg} +0 -0
package/src/util/trace.js
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Trace utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as rotatingFileStream from 'rotating-file-stream';
|
|
6
|
-
import express from 'express';
|
|
7
|
-
import util from 'node:util';
|
|
8
|
-
import oracledb from 'oracledb';
|
|
9
|
-
import {escapeHtml, convertAsciiToHtml} from './html.js';
|
|
10
|
-
import {errorToString} from './errorToString.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {import('express').Request} Request
|
|
14
|
-
* @typedef {import('../types.js').BindParameterConfig} BindParameterConfig
|
|
15
|
-
* @typedef {import('../types.js').environmentType} environmentType
|
|
16
|
-
* @typedef {{html: string; text: string}} outputType
|
|
17
|
-
* @typedef {{type: 'error' | 'warning' | 'trace'; message: string; timestamp?: Date | null; req?: Request | null; environment?: environmentType | null, sql?: string | null; bind?: BindParameterConfig | null}} messageType
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const SEPARATOR_H1 = '='.repeat(100);
|
|
21
|
-
const SEPARATOR_H2 = '-'.repeat(30);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Return a string representation of the value.
|
|
25
|
-
*
|
|
26
|
-
* @param {unknown} value - Any value.
|
|
27
|
-
* @param {number | null} depth - Specifies the number of times to recurse while formatting object.
|
|
28
|
-
* @returns {string} - The string representation.
|
|
29
|
-
*/
|
|
30
|
-
export const inspect = (value, depth = null) => {
|
|
31
|
-
try {
|
|
32
|
-
return util.inspect(value, {showHidden: false, depth, colors: false});
|
|
33
|
-
} catch (err) {
|
|
34
|
-
/* empty */
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
return JSON.stringify(value);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
/* empty */
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return 'Unable to convert value to string';
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Return a tabular representation of the values.
|
|
48
|
-
*
|
|
49
|
-
* @param {string[]} head - The header values.
|
|
50
|
-
* @param {string[][]} body - The row values.
|
|
51
|
-
* @returns {outputType} - The output.
|
|
52
|
-
*/
|
|
53
|
-
export const toTable = (head, body) => {
|
|
54
|
-
if (head.length === 0) {
|
|
55
|
-
throw new Error('head cannot be empty');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Calculate column widths
|
|
59
|
-
const widths = head.map((h, i) => {
|
|
60
|
-
const bodyMax = Math.max(0, ...body.map((row) => (row[i] ?? '').length));
|
|
61
|
-
return Math.max(h.length, bodyMax);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Build text representation
|
|
65
|
-
/**
|
|
66
|
-
* @param {string} cell - The string
|
|
67
|
-
* @param {number} width - The width
|
|
68
|
-
* @returns {string} - The result
|
|
69
|
-
*/
|
|
70
|
-
const padCell = (cell, width) => cell.padEnd(width, ' ');
|
|
71
|
-
const textHeader = head.map((h, i) => padCell(h, widths[i] ?? 0)).join(' | ');
|
|
72
|
-
const textSeparator = widths.map((w) => '-'.repeat(w ?? 0)).join('-+-');
|
|
73
|
-
const textRows = body.map((row) => head.map((_, i) => padCell(row[i] ?? '', widths[i] ?? 0)).join(' | '));
|
|
74
|
-
const text = [textHeader, textSeparator, ...textRows].join('\n');
|
|
75
|
-
|
|
76
|
-
const htmlHead = head.map((h) => `<th>${escapeHtml(h)}</th>`).join('');
|
|
77
|
-
const htmlBody = body.map((row) => `<tr>${head.map((_, i) => `<td>${escapeHtml(row[i] ?? '')}</td>`).join('')}</tr>`).join('');
|
|
78
|
-
const html = `<table><thead><tr>${htmlHead}</tr></thead><tbody>${htmlBody}</tbody></table>`;
|
|
79
|
-
|
|
80
|
-
return {text, html};
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Log text to the console and to a file.
|
|
85
|
-
*
|
|
86
|
-
* @param {string} text - Text to log.
|
|
87
|
-
* @returns {void}
|
|
88
|
-
*/
|
|
89
|
-
export const logToFile = (text) => {
|
|
90
|
-
const fs = rotatingFileStream.createStream('trace.log', {
|
|
91
|
-
size: '10M', // rotate every 10 MegaBytes written
|
|
92
|
-
interval: '1d', // rotate daily
|
|
93
|
-
maxFiles: 10, // maximum number of rotated files to keep
|
|
94
|
-
compress: 'gzip', // compress rotated files
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
fs.write(text);
|
|
98
|
-
fs.end();
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Return a string representation of the request.
|
|
103
|
-
*
|
|
104
|
-
* @param {express.Request} req - express.Request.
|
|
105
|
-
* @param {boolean} simple - Set to false to see all public properties of the request.
|
|
106
|
-
* @returns {string} - The string representation.
|
|
107
|
-
*/
|
|
108
|
-
const inspectRequest = (req, simple = true) => {
|
|
109
|
-
/** @type {Record<string, unknown>} */
|
|
110
|
-
const requestData = {};
|
|
111
|
-
|
|
112
|
-
Object.keys(req)
|
|
113
|
-
.filter((prop) =>
|
|
114
|
-
simple ? ['originalUrl', 'params', 'query', 'url', 'method', 'body', 'files', 'secret', 'cookies'].includes(prop) : !prop.startsWith('_'),
|
|
115
|
-
)
|
|
116
|
-
.forEach((prop) => {
|
|
117
|
-
requestData[prop] = req[/** @type {keyof import('express').Request} */ (prop)];
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
return inspect(requestData);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Return a string representation of the bind parameter.
|
|
125
|
-
* @param {number | undefined} dir - The direction.
|
|
126
|
-
* @returns {string} The string.
|
|
127
|
-
*/
|
|
128
|
-
const dirToString = (dir) => {
|
|
129
|
-
switch (dir) {
|
|
130
|
-
case oracledb.BIND_IN:
|
|
131
|
-
return 'IN';
|
|
132
|
-
case oracledb.BIND_OUT:
|
|
133
|
-
return 'OUT';
|
|
134
|
-
case oracledb.BIND_INOUT:
|
|
135
|
-
return 'INOUT';
|
|
136
|
-
default:
|
|
137
|
-
return '';
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Return a string representation of the bind type.
|
|
143
|
-
* @param {oracledb.DbType | string | number | undefined} type - The type.
|
|
144
|
-
* @returns {string} The string.
|
|
145
|
-
*/
|
|
146
|
-
const bindTypeToString = (type) => {
|
|
147
|
-
if (typeof type === 'object' && 'name' in type) {
|
|
148
|
-
return type.name;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (typeof type === 'string') {
|
|
152
|
-
return type;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (typeof type === 'number') {
|
|
156
|
-
return type.toString();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return '';
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Return a string representation of the bind parameter.
|
|
164
|
-
* @param {outputType} output - The output.
|
|
165
|
-
* @param {BindParameterConfig} bind - The bind parameters.
|
|
166
|
-
* @returns {undefined}
|
|
167
|
-
*/
|
|
168
|
-
const inspectBindParameter = (output, bind) => {
|
|
169
|
-
const rows = Object.entries(bind);
|
|
170
|
-
|
|
171
|
-
if (rows.length === 0) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const body = rows.map(([id, row]) => {
|
|
176
|
-
const dir = dirToString(row.dir);
|
|
177
|
-
const maxArraySize = row.maxArraySize ? row.maxArraySize.toString() : '';
|
|
178
|
-
const maxSize = row.maxSize ? row.maxSize.toString() : '';
|
|
179
|
-
const bindType = bindTypeToString(row.type);
|
|
180
|
-
const value = inspect(row.val);
|
|
181
|
-
const valueType = typeof row.val;
|
|
182
|
-
|
|
183
|
-
return [id, dir, maxArraySize, maxSize, bindType, value, valueType];
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
const {html, text} = toTable(['id', 'dir', 'maxArraySize', 'maxSize', 'bind type', 'value', 'value type'], body);
|
|
187
|
-
|
|
188
|
-
output.html += html;
|
|
189
|
-
output.text += text;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Add environment
|
|
194
|
-
* @param {outputType} output - The output.
|
|
195
|
-
* @param {environmentType} environment - The environment.
|
|
196
|
-
*/
|
|
197
|
-
const inspectEnvironment = (output, environment) => {
|
|
198
|
-
const rows = Object.entries(environment);
|
|
199
|
-
|
|
200
|
-
if (rows.length === 0) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const {html, text} = toTable(['key', 'value'], rows);
|
|
205
|
-
|
|
206
|
-
output.html += html;
|
|
207
|
-
output.text += text;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Get a block.
|
|
212
|
-
* @param {string} title - The name.
|
|
213
|
-
* @param {string} body - The name.
|
|
214
|
-
* @returns {string} - The text.
|
|
215
|
-
*/
|
|
216
|
-
export const getBlock = (title, body) => `\n${SEPARATOR_H2}${title.toUpperCase()}${SEPARATOR_H2}\n${body}`;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Get line html
|
|
220
|
-
* @param {string} text - The text.
|
|
221
|
-
* @returns {string} - The line.
|
|
222
|
-
*/
|
|
223
|
-
const getLineHtml = (text) => `<p>${convertAsciiToHtml(text)}</p>`;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Get line text
|
|
227
|
-
* @param {string} text - The text.
|
|
228
|
-
* @returns {string} - The line.
|
|
229
|
-
*/
|
|
230
|
-
const getLineText = (text) => `${text}\n`;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Add line
|
|
234
|
-
* @param {outputType} output - The output.
|
|
235
|
-
* @param {string} text - The text to convert.
|
|
236
|
-
*/
|
|
237
|
-
const addLine = (output, text) => {
|
|
238
|
-
output.html += getLineHtml(text);
|
|
239
|
-
output.text += getLineText(text);
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Add header
|
|
244
|
-
* @param {outputType} output - The output.
|
|
245
|
-
* @param {string} text - The text to convert.
|
|
246
|
-
*/
|
|
247
|
-
const addHeader = (output, text) => {
|
|
248
|
-
output.html += `<h2>${text}</h2>`;
|
|
249
|
-
output.text += `\n${text}\n${'-'.repeat(text.length)}\n`;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Add procedure
|
|
254
|
-
* @param {outputType} output - The output.
|
|
255
|
-
* @param {string} sql - The SQL to execute.
|
|
256
|
-
* @param {BindParameterConfig} bind - The bind parameters.
|
|
257
|
-
*/
|
|
258
|
-
const addProcedure = (output, sql, bind) => {
|
|
259
|
-
output.html += `${sql}<br><br>`;
|
|
260
|
-
output.text += `${sql}\n\n`;
|
|
261
|
-
|
|
262
|
-
try {
|
|
263
|
-
inspectBindParameter(output, bind);
|
|
264
|
-
} catch (err) {
|
|
265
|
-
addLine(output, `Unable to inspect bind parameter: ${errorToString(err)}`);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
output.html += `<br>`;
|
|
269
|
-
output.text += `\n`;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Get a formatted message.
|
|
274
|
-
* @param {messageType} para - The req object represents the HTTP request.
|
|
275
|
-
* @returns {outputType} - The output.
|
|
276
|
-
*/
|
|
277
|
-
export const getFormattedMessage = (para) => {
|
|
278
|
-
const timestamp = para.timestamp ?? new Date();
|
|
279
|
-
|
|
280
|
-
// header
|
|
281
|
-
const url = typeof para.req?.originalUrl === 'string' && para.req.originalUrl.length > 0 ? ` on ${para.req.originalUrl}` : '';
|
|
282
|
-
const header = `${para.type.toUpperCase()} at ${timestamp.toUTCString()}${url}`;
|
|
283
|
-
const output = {
|
|
284
|
-
html: `<h1>${header}</h1>`,
|
|
285
|
-
text: `\n\n${SEPARATOR_H1}\n== ${header}\n${SEPARATOR_H1}\n`,
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
// error
|
|
289
|
-
addHeader(output, 'ERROR');
|
|
290
|
-
addLine(output, para.message);
|
|
291
|
-
|
|
292
|
-
// request
|
|
293
|
-
if (para.req) {
|
|
294
|
-
addHeader(output, 'REQUEST');
|
|
295
|
-
addLine(output, inspectRequest(para.req));
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// parameters
|
|
299
|
-
if (para.sql && para.bind) {
|
|
300
|
-
addHeader(output, 'PROCEDURE');
|
|
301
|
-
addProcedure(output, para.sql, para.bind);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// environment
|
|
305
|
-
if (para.environment) {
|
|
306
|
-
addHeader(output, 'ENVIRONMENT');
|
|
307
|
-
inspectEnvironment(output, para.environment);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return output;
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Log a warning message.
|
|
315
|
-
* @param {messageType} para - The req object represents the HTTP request.
|
|
316
|
-
*/
|
|
317
|
-
export const warningMessage = (para) => {
|
|
318
|
-
const {text} = getFormattedMessage(para);
|
|
319
|
-
|
|
320
|
-
// trace to file
|
|
321
|
-
logToFile(text);
|
|
322
|
-
|
|
323
|
-
// console
|
|
324
|
-
console.warn(text);
|
|
325
|
-
};
|
package/src/util/type.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Is the given value a string or an array of strings
|
|
3
|
-
* @param {unknown} value - The value to check.
|
|
4
|
-
* @returns {value is string | string[]} - True if the value is a string or an array of strings
|
|
5
|
-
*/
|
|
6
|
-
export const isStringOrArrayOfString = (value) => typeof value === 'string' || (Array.isArray(value) && value.every((element) => typeof element === 'string'));
|
package/src/util/util.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get duration as human readable string.
|
|
3
|
-
* @param {number} duration - Milliseconds.
|
|
4
|
-
* @returns {string} String.
|
|
5
|
-
*/
|
|
6
|
-
export const humanDuration = (duration) => {
|
|
7
|
-
if (!Number.isFinite(duration)) return 'invalid';
|
|
8
|
-
|
|
9
|
-
const ms = Math.floor(duration % 1000);
|
|
10
|
-
const s = Math.floor((duration / 1000) % 60);
|
|
11
|
-
const m = Math.floor((duration / (1000 * 60)) % 60);
|
|
12
|
-
const h = Math.floor((duration / (1000 * 60 * 60)) % 24);
|
|
13
|
-
const d = Math.floor(duration / (1000 * 60 * 60 * 24));
|
|
14
|
-
|
|
15
|
-
const parts = [];
|
|
16
|
-
if (d) parts.push(`${d}d`);
|
|
17
|
-
if (h) parts.push(`${h}h`);
|
|
18
|
-
if (m) parts.push(`${m}m`);
|
|
19
|
-
if (s) parts.push(`${s}s`);
|
|
20
|
-
if (ms || !parts.length) parts.push(`${ms}ms`);
|
|
21
|
-
|
|
22
|
-
return parts.join(' ');
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Convert a string to a number
|
|
27
|
-
*
|
|
28
|
-
* @param {unknown} value - The string to convert
|
|
29
|
-
* @returns {number | null} The number or null if the string could not be converted
|
|
30
|
-
*/
|
|
31
|
-
export const stringToNumber = (value) => {
|
|
32
|
-
// is the value already of type number?
|
|
33
|
-
if (typeof value === 'number') {
|
|
34
|
-
return !Number.isNaN(value) && Number.isFinite(value) ? value : null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Test for invalid characters
|
|
38
|
-
if (typeof value !== 'string' || !/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:E[+-]?\d+)?$/i.test(value)) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Convert value to a number
|
|
43
|
-
const num = Number(value);
|
|
44
|
-
return Number.isNaN(num) ? null : num;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Convert a string to a integer
|
|
49
|
-
*
|
|
50
|
-
* @param {unknown} value - The value to convert
|
|
51
|
-
* @returns {number | null} The integer or null if the string could not be converted
|
|
52
|
-
*/
|
|
53
|
-
export const stringToInteger = (value) => {
|
|
54
|
-
// is the value already a "real" integer, we just return the value
|
|
55
|
-
if (typeof value === 'number' && Number.isInteger(value)) {
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// try to convert value to a number
|
|
60
|
-
const num = stringToNumber(value);
|
|
61
|
-
if (num === null || !Number.isInteger(num)) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return num;
|
|
66
|
-
};
|
package/src/version.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import('express').Request} Request
|
|
3
|
-
* @typedef {import('express').Response} Response
|
|
4
|
-
* @typedef {import('express').NextFunction} NextFunction
|
|
5
|
-
*/
|
|
6
|
-
export const handlerAdmin: import("express-serve-static-core").Router;
|
|
7
|
-
export type Request = import("express").Request;
|
|
8
|
-
export type Response = import("express").Response;
|
|
9
|
-
export type NextFunction = import("express").NextFunction;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export function initMetrics(): metricsType;
|
|
2
|
-
export function handlerMetrics(metrics: metricsType): RequestHandler;
|
|
3
|
-
export type RequestHandler = import("express").RequestHandler;
|
|
4
|
-
export type metricsType = {
|
|
5
|
-
/**
|
|
6
|
-
* - When was the server started.
|
|
7
|
-
*/
|
|
8
|
-
started: Date;
|
|
9
|
-
/**
|
|
10
|
-
* - Total number of requests.
|
|
11
|
-
*/
|
|
12
|
-
totalRequests: number;
|
|
13
|
-
/**
|
|
14
|
-
* - Total amount of time in ms in request.
|
|
15
|
-
*/
|
|
16
|
-
totalRequestDuration: number;
|
|
17
|
-
/**
|
|
18
|
-
* - Min amount of time in ms in request.
|
|
19
|
-
*/
|
|
20
|
-
minRequestDuration: number;
|
|
21
|
-
/**
|
|
22
|
-
* - Max amount of time in ms in request.
|
|
23
|
-
*/
|
|
24
|
-
maxRequestDuration: number;
|
|
25
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function handlerUpload(uploadFileSizeLimit?: number): RequestHandler;
|
|
2
|
-
export type RequestHandler = import("express").RequestHandler;
|
|
3
|
-
export type Response = import("express").Response;
|
|
4
|
-
export type NextFunction = import("express").NextFunction;
|
|
5
|
-
export type Pool = import("oracledb").Pool;
|
|
6
|
-
export type environmentType = import("../types.js").environmentType;
|
|
7
|
-
export type configType = import("../types.js").configType;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export function getCGI(req: Request, doctable: string, cgi: environmentType): environmentType;
|
|
2
|
-
export type Request = import("express").Request;
|
|
3
|
-
export type environmentType = import("../../types.js").environmentType;
|
|
4
|
-
export type configPlSqlType = import("../../types.js").configPlSqlType;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function errorPage(req: Request, res: Response, options: configPlSqlHandlerType, error: unknown): void;
|
|
2
|
-
export type Request = import("express").Request;
|
|
3
|
-
export type Response = import("express").Response;
|
|
4
|
-
export type BindParameterConfig = import("../../types.js").BindParameterConfig;
|
|
5
|
-
export type environmentType = import("../../types.js").environmentType;
|
|
6
|
-
export type configPlSqlHandlerType = import("../../types.js").configPlSqlHandlerType;
|
|
7
|
-
export type outputType = {
|
|
8
|
-
html: string;
|
|
9
|
-
text: string;
|
|
10
|
-
};
|
|
11
|
-
export type messageType = import("../../util/trace.js").messageType;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function handlerWebPlSql(connectionPool: Pool, config: configPlSqlHandlerType): WebPlSqlRequestHandler;
|
|
2
|
-
export type RequestHandler = import("express").RequestHandler;
|
|
3
|
-
export type Request = import("express").Request;
|
|
4
|
-
export type Response = import("express").Response;
|
|
5
|
-
export type NextFunction = import("express").NextFunction;
|
|
6
|
-
export type Pool = import("oracledb").Pool;
|
|
7
|
-
export type environmentType = import("../../types.js").environmentType;
|
|
8
|
-
export type configPlSqlHandlerType = import("../../types.js").configPlSqlHandlerType;
|
|
9
|
-
export type WebPlSqlRequestHandler = import("express").RequestHandler & {
|
|
10
|
-
procedureNameCache: Cache<string>;
|
|
11
|
-
argumentCache: Cache<import("./procedureNamed.js").argsType>;
|
|
12
|
-
};
|
|
13
|
-
import { Cache } from '../../util/cache.js';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function invokeProcedure(req: Request, res: Response, argObj: argObjType, cgiObj: environmentType, filesToUpload: fileUploadType[], options: configPlSqlHandlerType, databaseConnection: Connection, procedureNameCache: ProcedureNameCache, argumentCache: ArgumentCache): Promise<void>;
|
|
2
|
-
export type Request = import("express").Request;
|
|
3
|
-
export type Response = import("express").Response;
|
|
4
|
-
export type Connection = import("oracledb").Connection;
|
|
5
|
-
export type Result = import("oracledb").Result<unknown>;
|
|
6
|
-
export type argObjType = import("../../types.js").argObjType;
|
|
7
|
-
export type fileUploadType = import("../../types.js").fileUploadType;
|
|
8
|
-
export type environmentType = import("../../types.js").environmentType;
|
|
9
|
-
export type configPlSqlHandlerType = import("../../types.js").configPlSqlHandlerType;
|
|
10
|
-
export type BindParameterConfig = import("../../types.js").BindParameterConfig;
|
|
11
|
-
export type ProcedureNameCache = import("../../util/cache.js").Cache<string>;
|
|
12
|
-
export type ArgumentCache = import("../../util/cache.js").Cache<import("./procedureNamed.js").argsType>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import('../../types.js').environmentType} environmentType
|
|
3
|
-
* @typedef {import('../../types.js').BindParameterConfig} BindParameterConfig
|
|
4
|
-
*/
|
|
5
|
-
export class ProcedureError extends Error {
|
|
6
|
-
/**
|
|
7
|
-
* @param {string} message - The error message.
|
|
8
|
-
* @param {environmentType} environment - The environment.
|
|
9
|
-
* @param {string} sql - The SQL to execute.
|
|
10
|
-
* @param {BindParameterConfig} bind - The bind parameters.
|
|
11
|
-
*/
|
|
12
|
-
constructor(message: string, environment: environmentType, sql: string, bind: BindParameterConfig);
|
|
13
|
-
/** @type {Date} */
|
|
14
|
-
timestamp: Date;
|
|
15
|
-
/** @type {environmentType} */
|
|
16
|
-
environment: environmentType;
|
|
17
|
-
/** @type {string} */
|
|
18
|
-
sql: string;
|
|
19
|
-
/** @type {BindParameterConfig} */
|
|
20
|
-
bind: BindParameterConfig;
|
|
21
|
-
}
|
|
22
|
-
export type environmentType = import("../../types.js").environmentType;
|
|
23
|
-
export type BindParameterConfig = import("../../types.js").BindParameterConfig;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function getBinding(argName: string, argValue: unknown, argType: string): BindParameter;
|
|
2
|
-
export function getProcedureNamed(req: Request, procName: string, argObj: argObjType, databaseConnection: Connection, argumentCache: ArgumentCache): Promise<{
|
|
3
|
-
sql: string;
|
|
4
|
-
bind: BindParameterConfig;
|
|
5
|
-
}>;
|
|
6
|
-
export type Request = import("express").Request;
|
|
7
|
-
export type Connection = import("oracledb").Connection;
|
|
8
|
-
export type Result = import("oracledb").Result<unknown>;
|
|
9
|
-
export type configPlSqlHandlerType = import("../../types.js").configPlSqlHandlerType;
|
|
10
|
-
export type argObjType = import("../../types.js").argObjType;
|
|
11
|
-
export type BindParameterConfig = import("../../types.js").BindParameterConfig;
|
|
12
|
-
export type BindParameter = import("../../types.js").BindParameter;
|
|
13
|
-
export type argsType = Record<string, string>;
|
|
14
|
-
export type ArgumentCache = import("../../util/cache.js").Cache<argsType>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function sanitizeProcName(procName: string, databaseConnection: Connection, options: configPlSqlHandlerType, procedureNameCache: ProcedureNameCache): Promise<string>;
|
|
2
|
-
export type Request = import("express").Request;
|
|
3
|
-
export type Response = import("express").Response;
|
|
4
|
-
export type Connection = import("oracledb").Connection;
|
|
5
|
-
export type Result = import("oracledb").Result<unknown>;
|
|
6
|
-
export type argObjType = import("../../types.js").argObjType;
|
|
7
|
-
export type fileUploadType = import("../../types.js").fileUploadType;
|
|
8
|
-
export type environmentType = import("../../types.js").environmentType;
|
|
9
|
-
export type configPlSqlHandlerType = import("../../types.js").configPlSqlHandlerType;
|
|
10
|
-
export type BindParameterConfig = import("../../types.js").BindParameterConfig;
|
|
11
|
-
export type ProcedureNameCache = import("../../util/cache.js").Cache<string>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function getProcedureVariable(_req: Request, procName: string, argObj: argObjType): {
|
|
2
|
-
sql: string;
|
|
3
|
-
bind: BindParameterConfig;
|
|
4
|
-
};
|
|
5
|
-
export type Request = import("express").Request;
|
|
6
|
-
export type Connection = import("oracledb").Connection;
|
|
7
|
-
export type Result = import("oracledb").Result<unknown>;
|
|
8
|
-
export type configPlSqlHandlerType = import("../../types.js").configPlSqlHandlerType;
|
|
9
|
-
export type argObjType = import("../../types.js").argObjType;
|
|
10
|
-
export type BindParameterConfig = import("../../types.js").BindParameterConfig;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function processRequest(req: Request, res: Response, options: configPlSqlHandlerType, connectionPool: Pool, procedureNameCache: ProcedureNameCache, argumentCache: ArgumentCache): Promise<void>;
|
|
2
|
-
export type Request = import("express").Request;
|
|
3
|
-
export type Response = import("express").Response;
|
|
4
|
-
export type Pool = import("oracledb").Pool;
|
|
5
|
-
export type Connection = import("oracledb").Connection;
|
|
6
|
-
export type argObjType = import("../../types.js").argObjType;
|
|
7
|
-
export type configPlSqlHandlerType = import("../../types.js").configPlSqlHandlerType;
|
|
8
|
-
export type ProcedureNameCache = import("../../util/cache.js").Cache<string>;
|
|
9
|
-
export type ArgumentCache = import("../../util/cache.js").Cache<import("./procedureNamed.js").argsType>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export function sendResponse(_req: Request, res: Response, page: pageType): Promise<void>;
|
|
2
|
-
export type Request = import("express").Request;
|
|
3
|
-
export type Response = import("express").Response;
|
|
4
|
-
export type CookieOptions = import("express").CookieOptions;
|
|
5
|
-
export type pageType = import("../../types.js").pageType;
|
|
6
|
-
export type cookieType = import("../../types.js").cookieType;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export function getFiles(req: Request): fileUploadType[];
|
|
2
|
-
export function uploadFile(file: fileUploadType, doctable: string, databaseConnection: Connection): Promise<void>;
|
|
3
|
-
export type Request = import("express").Request;
|
|
4
|
-
export type Connection = import("oracledb").Connection;
|
|
5
|
-
export type fileUploadType = import("../../types.js").fileUploadType;
|
package/types/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { oracledb };
|
|
2
|
-
export { getVersion } from "./version.js";
|
|
3
|
-
export * from "./util/shutdown.js";
|
|
4
|
-
export * from "./util/oracle.js";
|
|
5
|
-
export * from "./util/file.js";
|
|
6
|
-
export { handlerWebPlSql } from "./handler/plsql/handlerPlSql.js";
|
|
7
|
-
export { handlerLogger } from "./handler/handlerLogger.js";
|
|
8
|
-
export { handlerUpload } from "./handler/handlerUpload.js";
|
|
9
|
-
export { handlerMetrics } from "./handler/handlerMetrics.js";
|
|
10
|
-
import oracledb from 'oracledb';
|
|
11
|
-
export { createServer, startServer, loadConfig, startServerConfig } from "./server/server.js";
|
package/types/server/config.d.ts
DELETED