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.
- package/.editorconfig +8 -8
- package/.eslintignore +3 -3
- package/.eslintrc.js +347 -273
- package/CHANGELOG.md +127 -106
- package/LICENSE +21 -21
- package/README.md +165 -164
- package/examples/apex.js +70 -70
- package/examples/credentials.js +22 -22
- package/examples/oracledb_example.js +30 -30
- package/examples/sample.js +101 -84
- package/examples/sql/doc_table.sql +13 -13
- package/examples/sql/install.sql +31 -31
- package/examples/sql/sample.pkb +223 -223
- package/examples/sql/sample.pks +24 -24
- package/examples/sql/uninstall.sql +5 -5
- package/examples/static/sample.css +25 -25
- package/jest.config.js +204 -0
- package/package.json +85 -109
- package/src/cgi.ts +95 -95
- package/src/config.ts +97 -97
- package/src/errorPage.ts +286 -286
- package/src/fileUpload.ts +126 -132
- package/src/index.ts +65 -66
- package/src/page.ts +275 -277
- package/src/procedure.ts +360 -359
- package/src/procedureError.ts +27 -27
- package/src/request.ts +139 -139
- package/src/requestError.ts +19 -19
- package/src/stream.ts +26 -26
- package/src/trace.ts +194 -193
- package/test/.eslintrc.json +5 -5
- package/test/{cgi.ts → __tests__/cgi.ts} +96 -95
- package/test/{config.ts → __tests__/config.ts} +41 -41
- package/test/__tests__/errorPage.ts +101 -0
- package/test/{oracledb_mock.ts → __tests__/oracledb_mock.ts} +98 -98
- package/test/{server.ts → __tests__/server.ts} +495 -498
- package/test/{stream.ts → __tests__/stream.ts} +21 -21
- package/test/mock/oracledb.ts +85 -85
- package/test/static/static.html +1 -1
- package/tsconfig.json +24 -23
- package/tsconfig.src.json +23 -22
- package/test/errorPage.ts +0 -101
- package/test/mocha.opts +0 -7
- package/tsconfig.test.json +0 -19
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {streamToBuffer} from '
|
|
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
|
-
|
|
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
|
+
});
|
package/test/mock/oracledb.ts
CHANGED
|
@@ -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?:
|
|
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:
|
|
54
|
-
const connectionPool = new ConnectionPool();
|
|
55
|
-
|
|
56
|
-
return Promise.resolve(connectionPool);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function getConnection(options:
|
|
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;
|
package/test/static/static.html
CHANGED
|
@@ -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
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
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
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
package/tsconfig.test.json
DELETED
|
@@ -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
|
-
}
|