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
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
+ }