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
package/src/config.ts
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Configuration
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {environmentType} from './cgi';
|
|
6
|
-
export type oracleExpressMiddleware$options = {
|
|
7
|
-
defaultPage?: string;
|
|
8
|
-
doctable?: string;
|
|
9
|
-
cgi?: environmentType;
|
|
10
|
-
pathAlias?: {
|
|
11
|
-
alias: string;
|
|
12
|
-
procedure: string;
|
|
13
|
-
};
|
|
14
|
-
errorStyle: 'basic' | 'debug';
|
|
15
|
-
trace: 'on' | 'off' | 'test';
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Validation the configuration options.
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} options - The configuration options.
|
|
22
|
-
* @returns {oracleExpressMiddleware$options} - The validated configuration options.
|
|
23
|
-
*/
|
|
24
|
-
export function validate(options: any): oracleExpressMiddleware$options {
|
|
25
|
-
const validOptions: oracleExpressMiddleware$options = {
|
|
26
|
-
errorStyle: 'basic',
|
|
27
|
-
trace: 'off'
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
if (typeof options !== 'undefined') {
|
|
31
|
-
if (arguments.length !== 1 || typeof options !== 'object' || options === null) {
|
|
32
|
-
throw new TypeError('Invalid configuration object was given');
|
|
33
|
-
}
|
|
34
|
-
Object.keys(options).forEach(option => {
|
|
35
|
-
if (['defaultPage', 'doctable', 'cgi', 'pathAlias', 'errorStyle', 'trace'].indexOf(option) === -1) {
|
|
36
|
-
throw new TypeError(`Invalid configuration options "${option}"`);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
return validOptions;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (typeof options.defaultPage !== 'undefined') {
|
|
44
|
-
if (typeof options.defaultPage === 'string' && options.defaultPage.length > 0) {
|
|
45
|
-
validOptions.defaultPage = options.defaultPage;
|
|
46
|
-
} else {
|
|
47
|
-
throw new TypeError('The option "defaultPage" must be of type string and cannot be empty');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (typeof options.doctable !== 'undefined') {
|
|
52
|
-
if (typeof options.doctable === 'string' && options.doctable.length > 0) {
|
|
53
|
-
validOptions.doctable = options.doctable;
|
|
54
|
-
} else {
|
|
55
|
-
throw new TypeError('The option "doctable" must be of type string and cannot be empty');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (typeof options.cgi !== 'undefined') {
|
|
60
|
-
if (typeof options.cgi === 'object' && Object.keys(options.cgi).every(key => typeof key === 'string') && Object.values(options.cgi).every(value => typeof value === 'string')) {
|
|
61
|
-
validOptions.cgi = Object.assign({}, options.cgi);
|
|
62
|
-
} else {
|
|
63
|
-
throw new TypeError('The option "cgi" must be an object where all keys and values are of type string');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (typeof options.pathAlias !== 'undefined') {
|
|
68
|
-
if (typeof options.pathAlias === 'object' &&
|
|
69
|
-
typeof options.pathAlias.alias === 'string' && options.pathAlias.alias.length > 0 &&
|
|
70
|
-
typeof options.pathAlias.procedure === 'string' && options.pathAlias.procedure.length > 0) {
|
|
71
|
-
validOptions.pathAlias = {
|
|
72
|
-
alias: options.pathAlias.alias,
|
|
73
|
-
procedure: options.pathAlias.procedure
|
|
74
|
-
};
|
|
75
|
-
} else {
|
|
76
|
-
throw new TypeError('The option "pathAlias" must be an object with the non-empty string properties "alias" and "procedure"');
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (typeof options.errorStyle !== 'undefined') {
|
|
81
|
-
if (typeof options.errorStyle !== 'string' || ['basic', 'debug'].indexOf(options.errorStyle) === -1) {
|
|
82
|
-
throw new TypeError('The optional option "errorStyle" must be "basic" or "debug"');
|
|
83
|
-
} else {
|
|
84
|
-
validOptions.errorStyle = options.errorStyle;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (typeof options.trace !== 'undefined') {
|
|
89
|
-
if (typeof options.trace !== 'string' || ['on', 'off', 'test'].indexOf(options.trace.toLowerCase()) === -1) {
|
|
90
|
-
throw new TypeError('The optional option "trace" must be "on" or "off"');
|
|
91
|
-
} else {
|
|
92
|
-
validOptions.trace = options.trace.toLowerCase();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return validOptions;
|
|
97
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {environmentType} from './cgi';
|
|
6
|
+
export type oracleExpressMiddleware$options = {
|
|
7
|
+
defaultPage?: string;
|
|
8
|
+
doctable?: string;
|
|
9
|
+
cgi?: environmentType;
|
|
10
|
+
pathAlias?: {
|
|
11
|
+
alias: string;
|
|
12
|
+
procedure: string;
|
|
13
|
+
};
|
|
14
|
+
errorStyle: 'basic' | 'debug';
|
|
15
|
+
trace: 'on' | 'off' | 'test';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validation the configuration options.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} options - The configuration options.
|
|
22
|
+
* @returns {oracleExpressMiddleware$options} - The validated configuration options.
|
|
23
|
+
*/
|
|
24
|
+
export function validate(options: Record<string, any>): oracleExpressMiddleware$options {
|
|
25
|
+
const validOptions: oracleExpressMiddleware$options = {
|
|
26
|
+
errorStyle: 'basic',
|
|
27
|
+
trace: 'off'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
if (typeof options !== 'undefined') {
|
|
31
|
+
if (arguments.length !== 1 || typeof options !== 'object' || options === null) {
|
|
32
|
+
throw new TypeError('Invalid configuration object was given');
|
|
33
|
+
}
|
|
34
|
+
Object.keys(options).forEach(option => {
|
|
35
|
+
if (['defaultPage', 'doctable', 'cgi', 'pathAlias', 'errorStyle', 'trace'].indexOf(option) === -1) {
|
|
36
|
+
throw new TypeError(`Invalid configuration options "${option}"`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
return validOptions;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof options.defaultPage !== 'undefined') {
|
|
44
|
+
if (typeof options.defaultPage === 'string' && options.defaultPage.length > 0) {
|
|
45
|
+
validOptions.defaultPage = options.defaultPage;
|
|
46
|
+
} else {
|
|
47
|
+
throw new TypeError('The option "defaultPage" must be of type string and cannot be empty');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (typeof options.doctable !== 'undefined') {
|
|
52
|
+
if (typeof options.doctable === 'string' && options.doctable.length > 0) {
|
|
53
|
+
validOptions.doctable = options.doctable;
|
|
54
|
+
} else {
|
|
55
|
+
throw new TypeError('The option "doctable" must be of type string and cannot be empty');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (typeof options.cgi !== 'undefined') {
|
|
60
|
+
if (typeof options.cgi === 'object' && Object.keys(options.cgi).every(key => typeof key === 'string') && Object.values(options.cgi).every(value => typeof value === 'string')) {
|
|
61
|
+
validOptions.cgi = Object.assign({}, options.cgi);
|
|
62
|
+
} else {
|
|
63
|
+
throw new TypeError('The option "cgi" must be an object where all keys and values are of type string');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (typeof options.pathAlias !== 'undefined') {
|
|
68
|
+
if (typeof options.pathAlias === 'object' &&
|
|
69
|
+
typeof options.pathAlias.alias === 'string' && options.pathAlias.alias.length > 0 &&
|
|
70
|
+
typeof options.pathAlias.procedure === 'string' && options.pathAlias.procedure.length > 0) {
|
|
71
|
+
validOptions.pathAlias = {
|
|
72
|
+
alias: options.pathAlias.alias,
|
|
73
|
+
procedure: options.pathAlias.procedure
|
|
74
|
+
};
|
|
75
|
+
} else {
|
|
76
|
+
throw new TypeError('The option "pathAlias" must be an object with the non-empty string properties "alias" and "procedure"');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (typeof options.errorStyle !== 'undefined') {
|
|
81
|
+
if (typeof options.errorStyle !== 'string' || ['basic', 'debug'].indexOf(options.errorStyle) === -1) {
|
|
82
|
+
throw new TypeError('The optional option "errorStyle" must be "basic" or "debug"');
|
|
83
|
+
} else {
|
|
84
|
+
validOptions.errorStyle = options.errorStyle as 'basic' | 'debug';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof options.trace !== 'undefined') {
|
|
89
|
+
if (typeof options.trace !== 'string' || ['on', 'off', 'test'].indexOf(options.trace.toLowerCase()) === -1) {
|
|
90
|
+
throw new TypeError('The optional option "trace" must be "on" or "off"');
|
|
91
|
+
} else {
|
|
92
|
+
validOptions.trace = options.trace.toLowerCase() as 'on' | 'off' | 'test';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return validOptions;
|
|
97
|
+
}
|