web_plsql 1.2.0 → 1.3.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/README.md +103 -8
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/frontend/assets/main-C8GKnEhz.js +147 -0
- package/dist/frontend/assets/main-C8GKnEhz.js.br +0 -0
- package/dist/frontend/assets/main-C8GKnEhz.js.gz +0 -0
- package/dist/frontend/assets/main-bU4x_yEW.css +1 -0
- package/dist/frontend/assets/main-bU4x_yEW.css.br +0 -0
- package/dist/frontend/assets/main-bU4x_yEW.css.gz +0 -0
- package/{src/admin → dist/frontend}/index.html +12 -25
- 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 +3559 -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 +48 -32
- package/examples/config-native.js +0 -68
- package/src/admin/client/charts.ts +0 -598
- package/src/admin/client/main.js +0 -3
- package/src/admin/client/tailwind.css +0 -41
- package/src/admin/js/api.ts +0 -170
- package/src/admin/js/app.ts +0 -614
- package/src/admin/js/eslint.config.js +0 -74
- package/src/admin/js/schemas.ts +0 -215
- package/src/admin/js/templates/config.ts +0 -147
- package/src/admin/js/templates/errorRow.ts +0 -21
- package/src/admin/js/templates/index.ts +0 -4
- package/src/admin/js/templates/poolCard.ts +0 -61
- package/src/admin/js/templates/traceRow.ts +0 -24
- package/src/admin/js/tsconfig.json +0 -24
- package/src/admin/js/types.ts +0 -336
- package/src/admin/js/ui/components.ts +0 -44
- package/src/admin/js/ui/table.ts +0 -173
- package/src/admin/js/ui/theme.ts +0 -93
- package/src/admin/js/ui/views.ts +0 -427
- package/src/admin/js/util/format.ts +0 -46
- package/src/admin/js/util/metrics.ts +0 -24
- package/src/admin/lib/chart.bundle.css +0 -1
- package/src/admin/lib/chart.bundle.js +0 -146
- package/src/admin/style.css +0 -1437
- package/src/bin/load-test.js +0 -202
- package/src/handler/handlerAdmin.js +0 -293
- package/src/handler/handlerLogger.js +0 -21
- package/src/handler/handlerUpload.js +0 -26
- package/src/handler/plsql/cgi.js +0 -131
- package/src/handler/plsql/errorPage.js +0 -113
- package/src/handler/plsql/handlerPlSql.js +0 -90
- package/src/handler/plsql/owaPageStream.js +0 -93
- package/src/handler/plsql/parsePage.js +0 -213
- package/src/handler/plsql/procedure.js +0 -426
- package/src/handler/plsql/procedureError.js +0 -40
- package/src/handler/plsql/procedureNamed.js +0 -282
- package/src/handler/plsql/procedureSanitize.js +0 -286
- package/src/handler/plsql/procedureVariable.js +0 -56
- package/src/handler/plsql/request.js +0 -124
- package/src/handler/plsql/requestError.js +0 -23
- package/src/handler/plsql/sendResponse.js +0 -174
- package/src/handler/plsql/stream.js +0 -28
- package/src/handler/plsql/upload.js +0 -109
- package/src/index.js +0 -19
- package/src/server/adminContext.js +0 -23
- package/src/server/config.js +0 -57
- package/src/server/connections.js +0 -40
- package/src/server/server.js +0 -304
- 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/statsManager.js +0 -368
- package/src/util/trace.js +0 -326
- package/src/util/traceManager.js +0 -68
- package/src/util/type.js +0 -6
- package/src/util/util.js +0 -66
- package/src/version.js +0 -5
- package/types/admin/js/schemas.d.ts +0 -384
- package/types/admin/js/types.d.ts +0 -312
- package/types/handler/handlerAdmin.d.ts +0 -79
- package/types/handler/handlerLogger.d.ts +0 -2
- 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/owaPageStream.d.ts +0 -28
- package/types/handler/plsql/parsePage.d.ts +0 -3
- package/types/handler/plsql/procedure.d.ts +0 -13
- 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 -10
- package/types/server/adminContext.d.ts +0 -17
- package/types/server/config.d.ts +0 -2
- package/types/server/server.d.ts +0 -57
- 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/statsManager.d.ts +0 -395
- package/types/util/trace.d.ts +0 -22
- package/types/util/traceManager.d.ts +0 -35
- 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/README.md
CHANGED
|
@@ -59,10 +59,10 @@ Access the console at `http://localhost:<port>/admin` (e.g., `http://localhost:8
|
|
|
59
59
|
# Configuration
|
|
60
60
|
|
|
61
61
|
There are 2 options on how to use the web_plsql express middleware:
|
|
62
|
-
- Use the predefined `startServer` api in `
|
|
63
|
-
- Hand craft a new Express server using the `handlerWebPlSql` middleware in `
|
|
62
|
+
- Use the predefined `startServer` api in `dist/backend/index.js` like in the `examples/config-native.js` example
|
|
63
|
+
- Hand craft a new Express server using the `handlerWebPlSql` middleware in `dist/backend/index.js`
|
|
64
64
|
|
|
65
|
-
## Use the predefined `startServer`
|
|
65
|
+
## Use the predefined `startServer` function
|
|
66
66
|
|
|
67
67
|
The `startServer` api uses the following configuration object:
|
|
68
68
|
|
|
@@ -121,9 +121,104 @@ The `startServer` api uses the following configuration object:
|
|
|
121
121
|
*/
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
## Hand
|
|
124
|
+
## Hand Craft Express Server with Composable Middleware
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
web_plsql exports composable middleware components that can be integrated into any Express application.
|
|
127
|
+
|
|
128
|
+
### Complete Manual Setup
|
|
129
|
+
|
|
130
|
+
For full control over your Express application with PL/SQL routes and admin console:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import express from 'express';
|
|
134
|
+
import path from 'path';
|
|
135
|
+
import {
|
|
136
|
+
handlerWebPlSql,
|
|
137
|
+
handlerAdminConsole,
|
|
138
|
+
AdminContext,
|
|
139
|
+
oracledb,
|
|
140
|
+
type configType,
|
|
141
|
+
type PoolCacheEntry,
|
|
142
|
+
} from 'web_plsql';
|
|
143
|
+
|
|
144
|
+
(async () => {
|
|
145
|
+
const app = express();
|
|
146
|
+
|
|
147
|
+
// 1. Define configuration
|
|
148
|
+
const config: configType = {
|
|
149
|
+
port: 8080,
|
|
150
|
+
routeStatic: [],
|
|
151
|
+
routePlSql: [{
|
|
152
|
+
route: '/myapp',
|
|
153
|
+
user: 'sample',
|
|
154
|
+
password: 'sample',
|
|
155
|
+
connectString: 'localhost:1521/ORCL',
|
|
156
|
+
defaultPage: 'myapp.home',
|
|
157
|
+
documentTable: 'doctable',
|
|
158
|
+
errorStyle: 'debug',
|
|
159
|
+
}],
|
|
160
|
+
uploadFileSizeLimit: 50 * 1024 * 1024,
|
|
161
|
+
loggerFilename: 'access.log',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// 2. Create Oracle connection pool
|
|
165
|
+
const pool = await oracledb.createPool({
|
|
166
|
+
user: config.routePlSql[0].user,
|
|
167
|
+
password: config.routePlSql[0].password,
|
|
168
|
+
connectString: config.routePlSql[0].connectString,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// 3. Create PL/SQL handler
|
|
172
|
+
const plsqlHandler = handlerWebPlSql(pool, {
|
|
173
|
+
defaultPage: config.routePlSql[0].defaultPage,
|
|
174
|
+
documentTable: config.routePlSql[0].documentTable,
|
|
175
|
+
errorStyle: config.routePlSql[0].errorStyle,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// 4. Create AdminContext (required for admin console)
|
|
179
|
+
const caches: PoolCacheEntry[] = [{
|
|
180
|
+
poolName: config.routePlSql[0].route,
|
|
181
|
+
procedureNameCache: plsqlHandler.procedureNameCache,
|
|
182
|
+
argumentCache: plsqlHandler.argumentCache,
|
|
183
|
+
}];
|
|
184
|
+
const adminContext = new AdminContext(config, [pool], caches);
|
|
185
|
+
|
|
186
|
+
// 5. Mount PL/SQL handler with stats tracking
|
|
187
|
+
app.use(config.routePlSql[0].route, (req, res, next) => {
|
|
188
|
+
const start = process.hrtime();
|
|
189
|
+
res.on('finish', () => {
|
|
190
|
+
const [s, ns] = process.hrtime(start);
|
|
191
|
+
adminContext.statsManager.recordRequest(s * 1000 + ns / 1e6, res.statusCode >= 400);
|
|
192
|
+
});
|
|
193
|
+
plsqlHandler(req, res, next);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// 6. Mount admin console
|
|
197
|
+
app.use('/admin', handlerAdminConsole({
|
|
198
|
+
staticDir: path.join(__dirname, 'node_modules/web_plsql/dist/frontend'),
|
|
199
|
+
user: 'admin',
|
|
200
|
+
password: 'secret',
|
|
201
|
+
}, adminContext));
|
|
202
|
+
|
|
203
|
+
// 7. Start server
|
|
204
|
+
app.listen(config.port, () => {
|
|
205
|
+
console.log(`Server running on port ${config.port}`);
|
|
206
|
+
});
|
|
207
|
+
})();
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### AdminContext Requirement
|
|
211
|
+
|
|
212
|
+
The admin console requires an `AdminContext` instance to be passed as the second argument to `handlerAdminConsole`.
|
|
213
|
+
|
|
214
|
+
**Using `startServer()` API:** `AdminContext` is managed automatically.
|
|
215
|
+
|
|
216
|
+
**Using custom Express app:** You must instantiate `AdminContext` and pass it to the handler.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
const adminContext = new AdminContext(config, pools, caches);
|
|
220
|
+
app.use('/admin', handlerAdminConsole(config, adminContext));
|
|
221
|
+
```
|
|
127
222
|
|
|
128
223
|
# Compare with mod_plsql
|
|
129
224
|
|
|
@@ -180,7 +275,7 @@ The following mod_plsql DAD configuration translates to the configuration option
|
|
|
180
275
|
}
|
|
181
276
|
```
|
|
182
277
|
|
|
183
|
-
## Create a custom Express application based on the default server implemented in `src/server.
|
|
278
|
+
## Create a custom Express application based on the default server implemented in `src/backend/server/server.ts`.
|
|
184
279
|
|
|
185
280
|
...
|
|
186
281
|
|
|
@@ -207,8 +302,8 @@ The following mod_plsql DAD configuration translates to the configuration option
|
|
|
207
302
|
## Features that are only available in web_plsql
|
|
208
303
|
- The option `transactionModeType` specifies an optional transaction mode.
|
|
209
304
|
"commit" this automatically commits any open transaction after each request. This is the defaults because this is what mod_plsql and ohs are doing.
|
|
210
|
-
"rollback" this automatically
|
|
211
|
-
"transactionCallbackType" this allows
|
|
305
|
+
"rollback" this automatically rolls back any open transaction after each request.
|
|
306
|
+
"transactionCallbackType" this allows defining a custom handler as a JavaScript function.
|
|
212
307
|
|
|
213
308
|
## Features that are planned to be available in web_plsql
|
|
214
309
|
- Support for APEX 5 or greater.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!no_symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll as t };
|