web_plsql 0.3.2 → 0.5.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 (44) hide show
  1. package/.editorconfig +8 -8
  2. package/.eslintignore +3 -3
  3. package/.eslintrc.js +347 -273
  4. package/CHANGELOG.md +127 -106
  5. package/LICENSE +21 -21
  6. package/README.md +165 -164
  7. package/examples/apex.js +70 -70
  8. package/examples/credentials.js +22 -22
  9. package/examples/oracledb_example.js +30 -30
  10. package/examples/sample.js +101 -84
  11. package/examples/sql/doc_table.sql +13 -13
  12. package/examples/sql/install.sql +31 -31
  13. package/examples/sql/sample.pkb +223 -223
  14. package/examples/sql/sample.pks +24 -24
  15. package/examples/sql/uninstall.sql +5 -5
  16. package/examples/static/sample.css +25 -25
  17. package/jest.config.js +204 -0
  18. package/package.json +85 -109
  19. package/src/cgi.ts +95 -95
  20. package/src/config.ts +97 -97
  21. package/src/errorPage.ts +286 -286
  22. package/src/fileUpload.ts +126 -132
  23. package/src/index.ts +65 -66
  24. package/src/page.ts +275 -277
  25. package/src/procedure.ts +360 -359
  26. package/src/procedureError.ts +27 -27
  27. package/src/request.ts +139 -139
  28. package/src/requestError.ts +19 -19
  29. package/src/stream.ts +26 -26
  30. package/src/trace.ts +194 -193
  31. package/test/.eslintrc.json +5 -5
  32. package/test/{cgi.ts → __tests__/cgi.ts} +96 -95
  33. package/test/{config.ts → __tests__/config.ts} +41 -41
  34. package/test/__tests__/errorPage.ts +101 -0
  35. package/test/{oracledb_mock.ts → __tests__/oracledb_mock.ts} +98 -98
  36. package/test/{server.ts → __tests__/server.ts} +495 -498
  37. package/test/{stream.ts → __tests__/stream.ts} +21 -21
  38. package/test/mock/oracledb.ts +85 -85
  39. package/test/static/static.html +1 -1
  40. package/tsconfig.json +24 -23
  41. package/tsconfig.src.json +23 -22
  42. package/test/errorPage.ts +0 -101
  43. package/test/mocha.opts +0 -7
  44. package/tsconfig.test.json +0 -19
@@ -1,21 +1,21 @@
1
- import {assert} from 'chai';
2
- import {streamToBuffer} from '../src/stream';
3
- import fs from 'fs';
4
-
5
- describe('stream', () => {
6
- it('should convert a stream to a buffer', async () => {
7
- const buffer = Buffer.from('Hey there', 'utf8');
8
-
9
- const filename = 'file.tmp';
10
- const file = fs.openSync(filename, 'w+');
11
- fs.writeSync(file, buffer, 0, buffer.length, 0);
12
- fs.closeSync(file);
13
-
14
- const readStream = fs.createReadStream('file.tmp');
15
- const readBuffer = await streamToBuffer(readStream);
16
-
17
- assert.isTrue(buffer.equals(readBuffer));
18
-
19
- fs.unlinkSync(filename);
20
- });
21
- });
1
+ import {describe, it, expect} from '@jest/globals';
2
+ import {streamToBuffer} from '../../src/stream';
3
+ import fs from 'fs';
4
+
5
+ describe('stream', () => {
6
+ it('should convert a stream to a buffer', async () => {
7
+ const buffer = Buffer.from('Hey there', 'utf8');
8
+
9
+ const filename = 'file.tmp';
10
+ const file = fs.openSync(filename, 'w+');
11
+ fs.writeSync(file, buffer, 0, buffer.length, 0);
12
+ fs.closeSync(file);
13
+
14
+ const readStream = fs.createReadStream('file.tmp');
15
+ const readBuffer = await streamToBuffer(readStream);
16
+
17
+ expect(buffer.equals(readBuffer)).toBeTruthy();
18
+
19
+ fs.unlinkSync(filename);
20
+ });
21
+ });
@@ -1,85 +1,85 @@
1
- /* eslint-disable class-methods-use-this, @typescript-eslint/no-unused-vars */
2
-
3
- type executeCallbackType = (sql: string, bindParams?: any) => any;
4
-
5
- let _executeCallback: executeCallbackType | null = null;
6
-
7
- export function setExecuteCallback(callback: executeCallbackType | null = null) {
8
- _executeCallback = callback;
9
- }
10
-
11
- export class Lob {
12
- type: number;
13
-
14
- constructor(type: number) {
15
- this.type = type;
16
- }
17
- close() {
18
- return Promise.resolve();
19
- }
20
- }
21
-
22
- export class Connection {
23
- execute(sql: string, bindParams?: any, options?: any): Promise<any> {
24
- return Promise.resolve(_executeCallback ? _executeCallback(sql, bindParams) : {});
25
- }
26
- createLob(type: number): Promise<Lob> {
27
- const lob = new Lob(type);
28
- return Promise.resolve(lob);
29
- }
30
- release(): Promise<void> {
31
- return Promise.resolve();
32
- }
33
- }
34
-
35
- export class ConnectionPool {
36
- onExecuteCallback: ((sql: string, bindParams: any) => any) | null;
37
-
38
- constructor() {
39
- this.onExecuteCallback = null;
40
- }
41
-
42
- getConnection(): Promise<Connection> {
43
- const connection = new Connection();
44
-
45
- return Promise.resolve(connection);
46
- }
47
-
48
- close(): Promise<void> {
49
- return Promise.resolve();
50
- }
51
- }
52
-
53
- export function createPool(options: any): Promise<ConnectionPool> {
54
- const connectionPool = new ConnectionPool();
55
-
56
- return Promise.resolve(connectionPool);
57
- }
58
-
59
- export function getConnection(options: any): Promise<Connection> {
60
- const connection = new Connection();
61
-
62
- return Promise.resolve(connection);
63
- }
64
-
65
- export const BIND_IN = 1;
66
- export const BIND_INOUT = 2;
67
- export const BIND_OUT = 3;
68
-
69
- export const STRING = 4;
70
- export const NUMBER = 5;
71
- export const DATE = 6;
72
- export const CURSOR = 7;
73
- export const BUFFER = 8;
74
- export const CLOB = 9;
75
- export const BLOB = 10;
76
-
77
- export const poolMin = 1;
78
- export const poolMax = 1;
79
- export const poolIncrement = 1;
80
- export const poolTimeout = 1;
81
- export const prefetchRows = 1;
82
- export const stmtCacheSize = 1;
83
-
84
- export const version = 0;
85
- export const oracleClientVersion = 0;
1
+ /* eslint-disable class-methods-use-this, @typescript-eslint/no-unused-vars */
2
+
3
+ type executeCallbackType = (sql: string, bindParams?: any) => any;
4
+
5
+ let _executeCallback: executeCallbackType | null = null;
6
+
7
+ export function setExecuteCallback(callback: executeCallbackType | null = null): void {
8
+ _executeCallback = callback;
9
+ }
10
+
11
+ export class Lob {
12
+ type: number;
13
+
14
+ constructor(type: number) {
15
+ this.type = type;
16
+ }
17
+ close(): Promise<void> {
18
+ return Promise.resolve();
19
+ }
20
+ }
21
+
22
+ export class Connection {
23
+ execute(sql: string, bindParams?: Record<string, unknown>, options?: Record<string, unknown>): Promise<any> {
24
+ return Promise.resolve(_executeCallback ? _executeCallback(sql, bindParams) : {});
25
+ }
26
+ createLob(type: number): Promise<Lob> {
27
+ const lob = new Lob(type);
28
+ return Promise.resolve(lob);
29
+ }
30
+ release(): Promise<void> {
31
+ return Promise.resolve();
32
+ }
33
+ }
34
+
35
+ export class ConnectionPool {
36
+ onExecuteCallback: ((sql: string, bindParams: any) => any) | null;
37
+
38
+ constructor() {
39
+ this.onExecuteCallback = null;
40
+ }
41
+
42
+ getConnection(): Promise<Connection> {
43
+ const connection = new Connection();
44
+
45
+ return Promise.resolve(connection);
46
+ }
47
+
48
+ close(): Promise<void> {
49
+ return Promise.resolve();
50
+ }
51
+ }
52
+
53
+ export function createPool(options: Record<string, unknown>): Promise<ConnectionPool> {
54
+ const connectionPool = new ConnectionPool();
55
+
56
+ return Promise.resolve(connectionPool);
57
+ }
58
+
59
+ export function getConnection(options: Record<string, unknown>): Promise<Connection> {
60
+ const connection = new Connection();
61
+
62
+ return Promise.resolve(connection);
63
+ }
64
+
65
+ export const BIND_IN = 1;
66
+ export const BIND_INOUT = 2;
67
+ export const BIND_OUT = 3;
68
+
69
+ export const STRING = 4;
70
+ export const NUMBER = 5;
71
+ export const DATE = 6;
72
+ export const CURSOR = 7;
73
+ export const BUFFER = 8;
74
+ export const CLOB = 9;
75
+ export const BLOB = 10;
76
+
77
+ export const poolMin = 1;
78
+ export const poolMax = 1;
79
+ export const poolIncrement = 1;
80
+ export const poolTimeout = 1;
81
+ export const prefetchRows = 1;
82
+ export const stmtCacheSize = 1;
83
+
84
+ export const version = 0;
85
+ export const oracleClientVersion = 0;
@@ -1 +1 @@
1
- <html><body><p>static</p></body></html>
1
+ <html><body><p>static</p></body></html>
package/tsconfig.json CHANGED
@@ -1,23 +1,24 @@
1
- {
2
- "compilerOptions": {
3
- "moduleResolution": "node",
4
- "baseUrl": ".",
5
- "outDir": "lib",
6
- "target": "es6",
7
- "lib": [
8
- "es2015",
9
- "es2016",
10
- "es2017",
11
- "es2018"
12
- ],
13
- "module": "commonjs",
14
- "sourceMap": true,
15
- "strict": true,
16
- "alwaysStrict": true,
17
- "esModuleInterop": true
18
- },
19
- "include": [
20
- "src/**/*",
21
- "test/**/*"
22
- ]
23
- }
1
+ {
2
+ "compilerOptions": {
3
+ "skipLibCheck": true,
4
+ "moduleResolution": "node",
5
+ "baseUrl": ".",
6
+ "outDir": "lib",
7
+ "target": "es6",
8
+ "lib": [
9
+ "es2015",
10
+ "es2016",
11
+ "es2017",
12
+ "es2018"
13
+ ],
14
+ "module": "commonjs",
15
+ "sourceMap": true,
16
+ "strict": true,
17
+ "alwaysStrict": true,
18
+ "esModuleInterop": true
19
+ },
20
+ "include": [
21
+ "src/**/*",
22
+ "test/**/*"
23
+ ]
24
+ }
package/tsconfig.src.json CHANGED
@@ -1,22 +1,23 @@
1
- {
2
- "compilerOptions": {
3
- "moduleResolution": "node",
4
- "baseUrl": ".",
5
- "outDir": "lib",
6
- "target": "es6",
7
- "lib": [
8
- "es2015",
9
- "es2016",
10
- "es2017",
11
- "es2018"
12
- ],
13
- "module": "commonjs",
14
- "sourceMap": true,
15
- "strict": true,
16
- "alwaysStrict": true,
17
- "esModuleInterop": true
18
- },
19
- "include": [
20
- "src/**/*"
21
- ]
22
- }
1
+ {
2
+ "compilerOptions": {
3
+ "skipLibCheck": true,
4
+ "moduleResolution": "node",
5
+ "baseUrl": ".",
6
+ "outDir": "lib",
7
+ "target": "es6",
8
+ "lib": [
9
+ "es2015",
10
+ "es2016",
11
+ "es2017",
12
+ "es2018"
13
+ ],
14
+ "module": "commonjs",
15
+ "sourceMap": true,
16
+ "strict": true,
17
+ "alwaysStrict": true,
18
+ "esModuleInterop": true
19
+ },
20
+ "include": [
21
+ "src/**/*"
22
+ ]
23
+ }
package/test/errorPage.ts DELETED
@@ -1,101 +0,0 @@
1
- import {assert} from 'chai';
2
- import {errorPage} from '../src/errorPage';
3
- import {RequestError} from '../src/requestError';
4
- import {ProcedureError} from '../src/procedureError';
5
- import {oracleExpressMiddleware$options} from '../src/config';
6
-
7
- describe('errorPage', () => {
8
- let errorSave: any;
9
-
10
- before(() => {
11
- errorSave = console.error;
12
- console.error = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
13
- });
14
-
15
- after(() => {
16
- console.error = errorSave;
17
- });
18
-
19
- let errorText = '';
20
- let errorHtml = '';
21
-
22
- const options: oracleExpressMiddleware$options = {
23
- errorStyle: 'debug',
24
- trace: 'off'
25
- };
26
-
27
- const req: any = {};
28
- const res: any = {
29
- status() {
30
- return this;
31
- },
32
- send(error: string) {
33
- errorHtml = error;
34
- return this;
35
- }
36
- };
37
- const trace: any = {
38
- write(error: string) {
39
- errorText = error;
40
- }
41
- };
42
-
43
- it('should report a "error message" in text and html format', () => {
44
- errorPage(req, res, options, trace, new Error('error message'));
45
-
46
- assert.isTrue(/error message/.test(errorText), 'text: error message');
47
- assert.isTrue(/ERROR/.test(errorText), 'text: ERROR');
48
- assert.isTrue(/REQUEST/.test(errorText), 'text: REQUEST');
49
- assert.isTrue(/error message/.test(errorHtml), 'html: error message');
50
- assert.isTrue(/TIMESTAMP/.test(errorHtml), 'html: TIMESTAMP');
51
- assert.isTrue(/ERROR/.test(errorHtml), 'html: ERROR');
52
- });
53
-
54
- it('should report a "Error" in text and html format', () => {
55
- errorPage(req, res, options, trace, new Error('throw Error'));
56
-
57
- assert.isTrue(/throw Error/.test(errorText), 'text: exception message');
58
- assert.isTrue(/ERROR/.test(errorText), 'text: ERROR');
59
- assert.isTrue(/REQUEST/.test(errorText), 'text: REQUEST');
60
- assert.isTrue(/throw Error/.test(errorHtml), 'html: exception message');
61
- assert.isTrue(/TIMESTAMP/.test(errorHtml), 'html: TIMESTAMP');
62
- assert.isTrue(/ERROR/.test(errorHtml), 'html: ERROR');
63
- });
64
-
65
- it('should report a "RequestError" in text and html format', () => {
66
- errorPage(req, res, options, trace, new RequestError('throw RequestError'));
67
-
68
- assert.isTrue(/throw RequestError/.test(errorText), 'text: exception message');
69
- assert.isTrue(/ERROR/.test(errorText), 'text: ERROR');
70
- assert.isTrue(/REQUEST/.test(errorText), 'text: REQUEST');
71
- assert.isTrue(/throw RequestError/.test(errorHtml), 'html: exception message');
72
- assert.isTrue(/TIMESTAMP/.test(errorHtml), 'html: TIMESTAMP');
73
- assert.isTrue(/ERROR/.test(errorHtml), 'html: ERROR');
74
- });
75
-
76
- it('should report a "ProcedureError" in text and html format', () => {
77
- const environment = {dad: 'dad'};
78
- const sql = 'sql';
79
- const bind = {p1: '1'};
80
-
81
- errorPage(req, res, options, trace, new ProcedureError('throw ProcedureError', environment, sql, bind));
82
-
83
- assert.isTrue(/throw ProcedureError/.test(errorText), 'text: exception message');
84
- assert.isTrue(/ERROR/.test(errorText), 'text: ERROR');
85
- assert.isTrue(/REQUEST/.test(errorText), 'text: REQUEST');
86
- assert.isTrue(/PROCEDURE/.test(errorText), 'text: PROCEDURE');
87
- assert.isTrue(/ENVIRONMENT/.test(errorText), 'text: ENVIRONMENT');
88
- assert.isTrue(/throw ProcedureError/.test(errorHtml), 'html: exception message');
89
- assert.isTrue(/TIMESTAMP/.test(errorHtml), 'html: TIMESTAMP');
90
- assert.isTrue(/ERROR/.test(errorHtml), 'html: ERROR');
91
- assert.isTrue(/PROCEDURE/.test(errorHtml), 'html: REQUEST');
92
- assert.isTrue(/ENVIRONMENT/.test(errorHtml), 'text: ENVIRONMENT');
93
- });
94
-
95
- it('should only report a "404" error when in basic mode', () => {
96
- options.errorStyle = 'basic';
97
- errorPage(req, res, options, trace, new Error('error message'));
98
-
99
- assert.isTrue(/error message/.test(errorText), 'Page not found');
100
- });
101
- });
package/test/mocha.opts DELETED
@@ -1,7 +0,0 @@
1
- --project ./tsconfig.test.json
2
- --require ts-node/register
3
- --require source-map-support/register
4
- --check-leaks
5
- --full-trace
6
- --bail
7
- ./test/*.ts
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "moduleResolution": "node",
4
- "baseUrl": ".",
5
- "outDir": "lib",
6
- "target": "es6",
7
- "lib": [
8
- "es2015",
9
- "es2016",
10
- "es2017",
11
- "es2018"
12
- ],
13
- "module": "commonjs",
14
- "sourceMap": true,
15
- "strict": true,
16
- "alwaysStrict": true,
17
- "esModuleInterop": true
18
- }
19
- }