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.
Files changed (108) hide show
  1. package/README.md +108 -13
  2. package/dist/chunk-DQk6qfdC.mjs +18 -0
  3. package/dist/frontend/assets/main-0oxRTIkL.js +147 -0
  4. package/dist/frontend/assets/main-0oxRTIkL.js.br +0 -0
  5. package/dist/frontend/assets/main-0oxRTIkL.js.gz +0 -0
  6. package/dist/frontend/assets/main-TYgLak6O.css +1 -0
  7. package/dist/frontend/assets/main-TYgLak6O.css.br +0 -0
  8. package/dist/frontend/assets/main-TYgLak6O.css.gz +0 -0
  9. package/dist/frontend/index.html +516 -0
  10. package/dist/frontend/index.html.br +0 -0
  11. package/dist/frontend/index.html.gz +0 -0
  12. package/dist/index.d.mts +646 -0
  13. package/dist/index.mjs +3548 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/dist/oracledb-mock-Dn8aHtd7.mjs +68 -0
  16. package/dist/oracledb-mock-Dn8aHtd7.mjs.map +1 -0
  17. package/examples/config-apex.js +1 -1
  18. package/examples/config-docker.js +1 -2
  19. package/package.json +45 -32
  20. package/examples/config-native.js +0 -68
  21. package/src/admin/client/charts.ts +0 -299
  22. package/src/admin/client/main.js +0 -3
  23. package/src/admin/client/tailwind.css +0 -41
  24. package/src/admin/index.html +0 -315
  25. package/src/admin/js/api.ts +0 -95
  26. package/src/admin/js/app.ts +0 -306
  27. package/src/admin/js/eslint.config.js +0 -74
  28. package/src/admin/js/schemas.ts +0 -153
  29. package/src/admin/js/templates/config.ts +0 -146
  30. package/src/admin/js/templates/errorRow.ts +0 -18
  31. package/src/admin/js/templates/index.ts +0 -3
  32. package/src/admin/js/templates/poolCard.ts +0 -61
  33. package/src/admin/js/tsconfig.json +0 -24
  34. package/src/admin/js/types.ts +0 -223
  35. package/src/admin/js/ui/theme.ts +0 -93
  36. package/src/admin/js/ui/views.ts +0 -164
  37. package/src/admin/js/util/format.ts +0 -27
  38. package/src/admin/lib/assets/main-zpdhQ1gD.css +0 -1
  39. package/src/admin/lib/chart.bundle.js +0 -139
  40. package/src/admin/style.css +0 -1321
  41. package/src/bin/load-test.js +0 -202
  42. package/src/handler/handlerAdmin.js +0 -198
  43. package/src/handler/handlerLogger.js +0 -21
  44. package/src/handler/handlerMetrics.js +0 -68
  45. package/src/handler/handlerUpload.js +0 -26
  46. package/src/handler/plsql/cgi.js +0 -131
  47. package/src/handler/plsql/errorPage.js +0 -117
  48. package/src/handler/plsql/handlerPlSql.js +0 -90
  49. package/src/handler/plsql/parsePage.js +0 -213
  50. package/src/handler/plsql/procedure.js +0 -356
  51. package/src/handler/plsql/procedureError.js +0 -40
  52. package/src/handler/plsql/procedureNamed.js +0 -268
  53. package/src/handler/plsql/procedureSanitize.js +0 -262
  54. package/src/handler/plsql/procedureVariable.js +0 -54
  55. package/src/handler/plsql/request.js +0 -124
  56. package/src/handler/plsql/requestError.js +0 -23
  57. package/src/handler/plsql/sendResponse.js +0 -136
  58. package/src/handler/plsql/stream.js +0 -28
  59. package/src/handler/plsql/upload.js +0 -109
  60. package/src/index.js +0 -20
  61. package/src/server/config.js +0 -57
  62. package/src/server/connections.js +0 -40
  63. package/src/server/server.js +0 -289
  64. package/src/types.js +0 -150
  65. package/src/util/cache.js +0 -123
  66. package/src/util/errorToString.js +0 -24
  67. package/src/util/file.js +0 -91
  68. package/src/util/html.js +0 -53
  69. package/src/util/jsonLogger.js +0 -47
  70. package/src/util/oracle.js +0 -80
  71. package/src/util/shutdown.js +0 -44
  72. package/src/util/trace.js +0 -325
  73. package/src/util/type.js +0 -6
  74. package/src/util/util.js +0 -66
  75. package/src/version.js +0 -5
  76. package/types/handler/handlerAdmin.d.ts +0 -9
  77. package/types/handler/handlerLogger.d.ts +0 -2
  78. package/types/handler/handlerMetrics.d.ts +0 -25
  79. package/types/handler/handlerUpload.d.ts +0 -7
  80. package/types/handler/plsql/cgi.d.ts +0 -4
  81. package/types/handler/plsql/errorPage.d.ts +0 -11
  82. package/types/handler/plsql/handlerPlSql.d.ts +0 -13
  83. package/types/handler/plsql/parsePage.d.ts +0 -3
  84. package/types/handler/plsql/procedure.d.ts +0 -12
  85. package/types/handler/plsql/procedureError.d.ts +0 -23
  86. package/types/handler/plsql/procedureNamed.d.ts +0 -14
  87. package/types/handler/plsql/procedureSanitize.d.ts +0 -11
  88. package/types/handler/plsql/procedureVariable.d.ts +0 -10
  89. package/types/handler/plsql/request.d.ts +0 -9
  90. package/types/handler/plsql/requestError.d.ts +0 -8
  91. package/types/handler/plsql/sendResponse.d.ts +0 -6
  92. package/types/handler/plsql/upload.d.ts +0 -5
  93. package/types/index.d.ts +0 -11
  94. package/types/server/config.d.ts +0 -2
  95. package/types/server/server.d.ts +0 -74
  96. package/types/types.d.ts +0 -328
  97. package/types/util/cache.d.ts +0 -69
  98. package/types/util/errorToString.d.ts +0 -1
  99. package/types/util/file.d.ts +0 -6
  100. package/types/util/html.d.ts +0 -3
  101. package/types/util/jsonLogger.d.ts +0 -45
  102. package/types/util/oracle.d.ts +0 -5
  103. package/types/util/shutdown.d.ts +0 -2
  104. package/types/util/trace.d.ts +0 -22
  105. package/types/util/type.d.ts +0 -1
  106. package/types/util/util.d.ts +0 -3
  107. package/types/version.d.ts +0 -1
  108. /package/{src/admin/favicon.svg → dist/frontend/assets/favicon-mQAM4tVu.svg} +0 -0
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  [![NPM Version][npm-image]][npm-url]
2
2
  [![NPM Downloads][downloads-image]][downloads-url]
3
- [![Linux Build](https://travis-ci.org/doberkofler/web_plsql.svg?branch=master)](https://travis-ci.org/doberkofler/web_plsql)
4
- [![Build status][appveyor-image]][appveyor-url]
3
+ [![Node.js CI](https://github.com/doberkofler/web_plsql/actions/workflows/node.js.yml/badge.svg)](https://github.com/doberkofler/web_plsql/actions/workflows/node.js.yml)
5
4
  [![Coverage Status](https://coveralls.io/repos/github/doberkofler/web_plsql/badge.svg?branch=master)](https://coveralls.io/github/doberkofler/web_plsql?branch=master)
6
5
 
7
6
  # Oracle PL/SQL Gateway Middleware for the Express web framework for Node.js
@@ -12,6 +11,8 @@ and serve the content using the Express web framework for Node.js.
12
11
 
13
12
  Please feel free to try and suggest any improvements. Your thoughts and ideas are most welcome.
14
13
 
14
+ ![Dashboard](docs/images/admin_console.png)
15
+
15
16
  # Release History
16
17
  See the [changelog](https://github.com/doberkofler/web_plsql/blob/master/CHANGELOG.md).
17
18
 
@@ -58,10 +59,10 @@ Access the console at `http://localhost:<port>/admin` (e.g., `http://localhost:8
58
59
  # Configuration
59
60
 
60
61
  There are 2 options on how to use the web_plsql express middleware:
61
- - Use the predefined `startServer` api in `src/server.js` like in the `examples/config-native.js` example
62
- - Hand craft a new Express server using the `handlerWebPlSql` middleware in `src/handlerPlSql.js`
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`
63
64
 
64
- ## Use the predefined `startServer`
65
+ ## Use the predefined `startServer` function
65
66
 
66
67
  The `startServer` api uses the following configuration object:
67
68
 
@@ -120,9 +121,104 @@ The `startServer` api uses the following configuration object:
120
121
  */
121
122
  ```
122
123
 
123
- ## Hand craft a new Express server using the `handlerWebPlSql` middleware
124
+ ## Hand Craft Express Server with Composable Middleware
125
+
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`.
124
213
 
125
- WIP
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
+ ```
126
222
 
127
223
  # Compare with mod_plsql
128
224
 
@@ -179,7 +275,7 @@ The following mod_plsql DAD configuration translates to the configuration option
179
275
  }
180
276
  ```
181
277
 
182
- ## Create a custom Express application based on the default server implemented in `src/server.js`.
278
+ ## Create a custom Express application based on the default server implemented in `src/backend/server/server.ts`.
183
279
 
184
280
  ...
185
281
 
@@ -200,12 +296,14 @@ The following mod_plsql DAD configuration translates to the configuration option
200
296
  - PlsqlRequestValidationFunction -> routePlSql[].pathAliasProcedure
201
297
  - PlsqlExclusionList
202
298
  - Basic and custom authentication methods, based on the OWA_SEC package and custom packages.
299
+ - Caching of procedure metadata and validation results for high performance.
300
+ - Real-time monitoring and management via a built-in Admin Console.
203
301
 
204
302
  ## Features that are only available in web_plsql
205
303
  - The option `transactionModeType` specifies an optional transaction mode.
206
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.
207
- "rollback" this automatically rolles back any open transaction after each request.
208
- "transactionCallbackType" this allows to defined a custom handler as a JavaScript function.
305
+ "rollback" this automatically rolls back any open transaction after each request.
306
+ "transactionCallbackType" this allows defining a custom handler as a JavaScript function.
209
307
 
210
308
  ## Features that are planned to be available in web_plsql
211
309
  - Support for APEX 5 or greater.
@@ -233,6 +331,3 @@ The following mod_plsql DAD configuration translates to the configuration option
233
331
 
234
332
  [downloads-image]: https://img.shields.io/npm/dm/web_plsql.svg
235
333
  [downloads-url]: https://npmjs.org/package/web_plsql
236
-
237
- [appveyor-image]: https://ci.appveyor.com/api/projects/status/github/doberkofler/web_plsql?branch=master&svg=true
238
- [appveyor-url]: https://ci.appveyor.com/project/doberkofler/web-plsql
@@ -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 };