web_plsql 0.17.1 → 1.0.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 +24 -4
- package/package.json +21 -8
- package/src/admin/client/charts.ts +299 -0
- package/src/admin/client/main.js +3 -0
- package/src/admin/client/tailwind.css +41 -0
- package/src/admin/favicon.svg +3 -0
- package/src/admin/index.html +315 -0
- package/src/admin/js/api.ts +95 -0
- package/src/admin/js/app.ts +306 -0
- package/src/admin/js/eslint.config.js +74 -0
- package/src/admin/js/schemas.ts +153 -0
- package/src/admin/js/templates/config.ts +146 -0
- package/src/admin/js/templates/errorRow.ts +18 -0
- package/src/admin/js/templates/index.ts +3 -0
- package/src/admin/js/templates/poolCard.ts +61 -0
- package/src/admin/js/tsconfig.json +24 -0
- package/src/admin/js/types.ts +223 -0
- package/src/admin/js/ui/theme.ts +93 -0
- package/src/admin/js/ui/views.ts +164 -0
- package/src/admin/js/util/format.ts +27 -0
- package/src/admin/lib/assets/main-zpdhQ1gD.css +1 -0
- package/src/admin/lib/chart.bundle.js +139 -0
- package/src/admin/style.css +1321 -0
- package/src/bin/load-test.js +202 -0
- package/src/handler/handlerAdmin.js +198 -0
- package/src/handler/plsql/cgi.js +1 -1
- package/src/handler/plsql/errorPage.js +37 -12
- package/src/handler/plsql/handlerPlSql.js +32 -6
- package/src/handler/plsql/parsePage.js +15 -11
- package/src/handler/plsql/procedure.js +81 -33
- package/src/handler/plsql/procedureNamed.js +18 -52
- package/src/handler/plsql/procedureSanitize.js +96 -49
- package/src/handler/plsql/procedureVariable.js +2 -2
- package/src/handler/plsql/request.js +11 -6
- package/src/handler/plsql/sendResponse.js +43 -11
- package/src/handler/plsql/stream.js +1 -1
- package/src/handler/plsql/upload.js +1 -1
- package/src/server/config.js +1 -0
- package/src/server/server.js +108 -2
- package/src/types.js +7 -1
- package/src/util/cache.js +123 -0
- package/src/util/file.js +5 -9
- package/src/util/jsonLogger.js +47 -0
- package/src/util/shutdown.js +6 -2
- package/src/util/trace.js +5 -5
- package/src/version.js +1 -1
- package/types/handler/handlerAdmin.d.ts +9 -0
- package/types/handler/plsql/errorPage.d.ts +1 -0
- package/types/handler/plsql/handlerPlSql.d.ts +6 -1
- package/types/handler/plsql/procedure.d.ts +3 -1
- package/types/handler/plsql/procedureNamed.d.ts +2 -5
- package/types/handler/plsql/procedureSanitize.d.ts +2 -5
- package/types/handler/plsql/procedureVariable.d.ts +1 -1
- package/types/handler/plsql/request.d.ts +3 -1
- package/types/handler/plsql/sendResponse.d.ts +1 -1
- package/types/server/server.d.ts +22 -0
- package/types/types.d.ts +19 -1
- package/types/util/cache.d.ts +69 -0
- package/types/util/jsonLogger.d.ts +45 -0
- package/types/handler/plsql/stream.d.ts +0 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export function processRequest(req: Request, res: Response, options: configPlSqlHandlerType, connectionPool: Pool): Promise<void>;
|
|
1
|
+
export function processRequest(req: Request, res: Response, options: configPlSqlHandlerType, connectionPool: Pool, procedureNameCache: ProcedureNameCache, argumentCache: ArgumentCache): Promise<void>;
|
|
2
2
|
export type Request = import("express").Request;
|
|
3
3
|
export type Response = import("express").Response;
|
|
4
4
|
export type Pool = import("oracledb").Pool;
|
|
5
5
|
export type Connection = import("oracledb").Connection;
|
|
6
6
|
export type argObjType = import("../../types.js").argObjType;
|
|
7
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,4 +1,4 @@
|
|
|
1
|
-
export function sendResponse(
|
|
1
|
+
export function sendResponse(_req: Request, res: Response, page: pageType): Promise<void>;
|
|
2
2
|
export type Request = import("express").Request;
|
|
3
3
|
export type Response = import("express").Response;
|
|
4
4
|
export type CookieOptions = import("express").CookieOptions;
|
package/types/server/server.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
export namespace AdminContext {
|
|
2
|
+
let startTime: Date;
|
|
3
|
+
let config: configType | null;
|
|
4
|
+
let pools: Pool[];
|
|
5
|
+
let caches: Array<{
|
|
6
|
+
poolName: string;
|
|
7
|
+
procedureNameCache: Cache<string>;
|
|
8
|
+
argumentCache: Cache<argsType>;
|
|
9
|
+
}>;
|
|
10
|
+
let paused: boolean;
|
|
11
|
+
namespace metrics {
|
|
12
|
+
let requestCount: number;
|
|
13
|
+
let errorCount: number;
|
|
14
|
+
let totalDuration: number;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
1
17
|
export function createServer(app: Express, ssl?: sslConfig): http.Server | https.Server;
|
|
2
18
|
export function startServer(config: configType, ssl?: sslConfig): Promise<webServer>;
|
|
3
19
|
export function loadConfig(filename?: string): configType;
|
|
@@ -10,6 +26,11 @@ export type NextFunction = import("express").NextFunction;
|
|
|
10
26
|
export type Pool = import("oracledb").Pool;
|
|
11
27
|
export type environmentType = import("../types.js").environmentType;
|
|
12
28
|
export type configType = import("../types.js").configType;
|
|
29
|
+
export type argsType = import("../handler/plsql/procedureNamed.js").argsType;
|
|
30
|
+
export type ExtendedRequestHandler = import("express").RequestHandler & {
|
|
31
|
+
procedureNameCache: Cache<string>;
|
|
32
|
+
argumentCache: Cache<argsType>;
|
|
33
|
+
};
|
|
13
34
|
/**
|
|
14
35
|
* - Web server interface.
|
|
15
36
|
*/
|
|
@@ -48,5 +69,6 @@ export type sslConfig = {
|
|
|
48
69
|
*/
|
|
49
70
|
certFilename: string;
|
|
50
71
|
};
|
|
72
|
+
import { Cache } from '../util/cache.js';
|
|
51
73
|
import http from 'node:http';
|
|
52
74
|
import https from 'node:https';
|
package/types/types.d.ts
CHANGED
|
@@ -92,6 +92,9 @@ export const z$configPlSqlType: z.ZodObject<{
|
|
|
92
92
|
* @property {configPlSqlType[]} routePlSql - The PL/SQL routes.
|
|
93
93
|
* @property {number} [uploadFileSizeLimit] - Maximum size of each uploaded file in bytes or no limit if omitted.
|
|
94
94
|
* @property {string} loggerFilename - name of the request logger filename or '' if not required.
|
|
95
|
+
* @property {string} [adminRoute] - Optional route for the admin console (defaults to /admin).
|
|
96
|
+
* @property {string} [adminUser] - Optional username for admin console basic auth.
|
|
97
|
+
* @property {string} [adminPassword] - Optional password for admin console basic auth.
|
|
95
98
|
*/
|
|
96
99
|
export const z$configType: z.ZodObject<{
|
|
97
100
|
port: z.ZodNumber;
|
|
@@ -118,6 +121,9 @@ export const z$configType: z.ZodObject<{
|
|
|
118
121
|
}, z.core.$strict>>;
|
|
119
122
|
uploadFileSizeLimit: z.ZodOptional<z.ZodNumber>;
|
|
120
123
|
loggerFilename: z.ZodString;
|
|
124
|
+
adminRoute: z.ZodOptional<z.ZodString>;
|
|
125
|
+
adminUser: z.ZodOptional<z.ZodString>;
|
|
126
|
+
adminPassword: z.ZodOptional<z.ZodString>;
|
|
121
127
|
}, z.core.$strict>;
|
|
122
128
|
export type BindParameter = import("oracledb").BindParameter;
|
|
123
129
|
export type Connection = import("oracledb").Connection;
|
|
@@ -217,6 +223,18 @@ export type configType = {
|
|
|
217
223
|
* - name of the request logger filename or '' if not required.
|
|
218
224
|
*/
|
|
219
225
|
loggerFilename: string;
|
|
226
|
+
/**
|
|
227
|
+
* - Optional route for the admin console (defaults to /admin).
|
|
228
|
+
*/
|
|
229
|
+
adminRoute?: string;
|
|
230
|
+
/**
|
|
231
|
+
* - Optional username for admin console basic auth.
|
|
232
|
+
*/
|
|
233
|
+
adminUser?: string;
|
|
234
|
+
/**
|
|
235
|
+
* - Optional password for admin console basic auth.
|
|
236
|
+
*/
|
|
237
|
+
adminPassword?: string;
|
|
220
238
|
};
|
|
221
239
|
/**
|
|
222
240
|
* Environment variables as string key-value pairs
|
|
@@ -304,7 +322,7 @@ export type pageType = {
|
|
|
304
322
|
file: {
|
|
305
323
|
fileType: string | null;
|
|
306
324
|
fileSize: number | null;
|
|
307
|
-
fileBlob: Buffer | null;
|
|
325
|
+
fileBlob: import("node:stream").Readable | Buffer | null;
|
|
308
326
|
};
|
|
309
327
|
};
|
|
310
328
|
import z from 'zod';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @typedef {{hitCount: number, value: T}} cacheEntryType
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generic Cache class with LFU (Least Frequently Used) eviction policy.
|
|
7
|
+
* @template T
|
|
8
|
+
*/
|
|
9
|
+
export class Cache<T> {
|
|
10
|
+
/**
|
|
11
|
+
* @param {number} maxSize - Maximum number of entries in the cache.
|
|
12
|
+
*/
|
|
13
|
+
constructor(maxSize?: number);
|
|
14
|
+
/** @type {Map<string, cacheEntryType<T>>} */
|
|
15
|
+
cache: Map<string, cacheEntryType<T>>;
|
|
16
|
+
maxSize: number;
|
|
17
|
+
hits: number;
|
|
18
|
+
misses: number;
|
|
19
|
+
/**
|
|
20
|
+
* Get an entry from the cache.
|
|
21
|
+
* @param {string} key - The key.
|
|
22
|
+
* @returns {T | undefined} - The value or undefined if not found.
|
|
23
|
+
*/
|
|
24
|
+
get(key: string): T | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Set an entry in the cache.
|
|
27
|
+
* @param {string} key - The key.
|
|
28
|
+
* @param {T} value - The value.
|
|
29
|
+
*/
|
|
30
|
+
set(key: string, value: T): void;
|
|
31
|
+
/**
|
|
32
|
+
* Delete an entry from the cache.
|
|
33
|
+
* @param {string} key - The key.
|
|
34
|
+
*/
|
|
35
|
+
delete(key: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Clear the cache.
|
|
38
|
+
*/
|
|
39
|
+
clear(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Prune the cache by removing the least frequently used entries.
|
|
42
|
+
* Removes 10% of the cache size.
|
|
43
|
+
*/
|
|
44
|
+
prune(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Get the size of the cache.
|
|
47
|
+
* @returns {number} - The size.
|
|
48
|
+
*/
|
|
49
|
+
get size(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Get all keys in the cache.
|
|
52
|
+
* @returns {string[]} - The keys.
|
|
53
|
+
*/
|
|
54
|
+
keys(): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Get cache statistics.
|
|
57
|
+
* @returns {{size: number, maxSize: number, hits: number, misses: number}} - The statistics.
|
|
58
|
+
*/
|
|
59
|
+
getStats(): {
|
|
60
|
+
size: number;
|
|
61
|
+
maxSize: number;
|
|
62
|
+
hits: number;
|
|
63
|
+
misses: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export type cacheEntryType<T> = {
|
|
67
|
+
hitCount: number;
|
|
68
|
+
value: T;
|
|
69
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} LogEntry
|
|
3
|
+
* @property {string} timestamp - ISO string
|
|
4
|
+
* @property {'error'|'info'|'warning'} type - Log level
|
|
5
|
+
* @property {string} message - Error message
|
|
6
|
+
* @property {object} [req] - Request details
|
|
7
|
+
* @property {object} [details] - Additional details (stack, sql, etc)
|
|
8
|
+
*/
|
|
9
|
+
export class JsonLogger {
|
|
10
|
+
constructor(filename?: string);
|
|
11
|
+
stream: rotatingFileStream.RotatingFileStream;
|
|
12
|
+
/**
|
|
13
|
+
* Log an entry as NDJSON.
|
|
14
|
+
* @param {LogEntry} entry - The entry to log.
|
|
15
|
+
*/
|
|
16
|
+
log(entry: LogEntry): void;
|
|
17
|
+
/**
|
|
18
|
+
* Close the stream.
|
|
19
|
+
*/
|
|
20
|
+
close(): void;
|
|
21
|
+
}
|
|
22
|
+
export const jsonLogger: JsonLogger;
|
|
23
|
+
export type LogEntry = {
|
|
24
|
+
/**
|
|
25
|
+
* - ISO string
|
|
26
|
+
*/
|
|
27
|
+
timestamp: string;
|
|
28
|
+
/**
|
|
29
|
+
* - Log level
|
|
30
|
+
*/
|
|
31
|
+
type: "error" | "info" | "warning";
|
|
32
|
+
/**
|
|
33
|
+
* - Error message
|
|
34
|
+
*/
|
|
35
|
+
message: string;
|
|
36
|
+
/**
|
|
37
|
+
* - Request details
|
|
38
|
+
*/
|
|
39
|
+
req?: object;
|
|
40
|
+
/**
|
|
41
|
+
* - Additional details (stack, sql, etc)
|
|
42
|
+
*/
|
|
43
|
+
details?: object;
|
|
44
|
+
};
|
|
45
|
+
import * as rotatingFileStream from 'rotating-file-stream';
|