itoolkit 1.0.0 → 1.0.2
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/README.md +13 -8
- package/lib/CommandCall.js +2 -16
- package/lib/Connection.js +2 -17
- package/lib/Deprecated.js +5 -26
- package/lib/ProgramCall.js +4 -18
- package/lib/itoolkit.js +2 -16
- package/lib/transports/httpTransport.js +4 -18
- package/lib/transports/idbTransport.js +24 -26
- package/lib/transports/odbcTransport.js +16 -16
- package/lib/transports/sshTransport.js +5 -20
- package/package.json +23 -16
- package/.eslintrc.js +0 -13
- package/.gitattributes +0 -2
- package/.readthedocs.yml +0 -16
- package/CHANGELOG.md +0 -195
- package/contributors.txt +0 -2
- package/test/README.md +0 -46
- package/test/functional/CommandCallFunctional.js +0 -79
- package/test/functional/ProgramCallFunctional.js +0 -166
- package/test/functional/checkObjectExists.js +0 -182
- package/test/functional/config.js +0 -35
- package/test/functional/deprecated/commandsFunctional.js +0 -99
- package/test/functional/deprecated/iDataQueueFunctional.js +0 -104
- package/test/functional/deprecated/iNetworkFunctional.js +0 -160
- package/test/functional/deprecated/iObjFunctional.js +0 -350
- package/test/functional/deprecated/iPgmFunctional.js +0 -140
- package/test/functional/deprecated/iProdFunctional.js +0 -161
- package/test/functional/deprecated/iSqlFunctional.js +0 -455
- package/test/functional/deprecated/iUserSpaceFunctional.js +0 -127
- package/test/functional/deprecated/iWorkFunctional.js +0 -236
- package/test/functional/iDataQueueFunctional.js +0 -84
- package/test/functional/iNetworkFunctional.js +0 -133
- package/test/functional/iObjFunctional.js +0 -327
- package/test/functional/iProdFunctional.js +0 -135
- package/test/functional/iSqlFunctional.js +0 -449
- package/test/functional/iUserSpaceFunctional.js +0 -123
- package/test/functional/iWorkFunctional.js +0 -219
- package/test/unit/CommandCallUnit.js +0 -88
- package/test/unit/ConnectionUnit.js +0 -195
- package/test/unit/ProgamCallUnit.js +0 -279
- package/test/unit/deprecated/commandsUnit.js +0 -88
- package/test/unit/deprecated/iConnUnit.js +0 -162
- package/test/unit/deprecated/iPgmUnit.js +0 -207
- package/test/unit/deprecated/iSqlUnit.js +0 -442
- package/test/unit/deprecated/xmlToJsonUnit.js +0 -203
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- [Tests](#tests)
|
|
17
17
|
- [Contributing](#contributing)
|
|
18
18
|
- [License](#license)
|
|
19
|
+
- [Release](#release)
|
|
19
20
|
|
|
20
21
|
# Introduction
|
|
21
22
|
|
|
@@ -47,11 +48,11 @@ XMLSERVICE will run the command and respond with XML output.
|
|
|
47
48
|
</myscript>
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
`itoolkit
|
|
51
|
+
`itoolkit`, with the help of an XML parser, can run the same CL command with:
|
|
51
52
|
|
|
52
53
|
```js
|
|
53
54
|
const { Connection, CommandCall } = require('itoolkit');
|
|
54
|
-
const {
|
|
55
|
+
const { XMLParser } = require('fast-xml-parser');
|
|
55
56
|
|
|
56
57
|
const connection = new Connection({
|
|
57
58
|
transport: 'ssh',
|
|
@@ -66,12 +67,12 @@ connection.run((error, xmlOutput) => {
|
|
|
66
67
|
if (error) {
|
|
67
68
|
throw error;
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
|
|
71
|
+
const Parser = new XMLParser();
|
|
72
|
+
const result = Parser.parse(xmlOutput);
|
|
73
|
+
|
|
74
|
+
console.log(JSON.stringify(result));
|
|
75
|
+
});
|
|
75
76
|
```
|
|
76
77
|
|
|
77
78
|
The purpose of this package is to simplify the process of creating XMLSERVICE input, invoking XMLSERVICE, and returning XMLSERVICE output from Node.js.
|
|
@@ -97,3 +98,7 @@ Please read the [contribution guidelines](https://github.com/IBM/nodejs-itoolkit
|
|
|
97
98
|
|
|
98
99
|
# License
|
|
99
100
|
[MIT](https://github.com/IBM/nodejs-itoolkit/blob/master/LICENSE)
|
|
101
|
+
|
|
102
|
+
# Release
|
|
103
|
+
|
|
104
|
+
For information on making a release, read [RELEASE.md](docs/RELEASE.md).
|
package/lib/CommandCall.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
// Copyright
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
17
3
|
|
|
18
4
|
const availableCommands = ['sh', 'cl', 'qsh'];
|
|
19
5
|
|
package/lib/Connection.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
// Copyright
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
17
3
|
|
|
18
4
|
const { httpCall } = require('./transports/httpTransport');
|
|
19
5
|
const { idbCall } = require('./transports/idbTransport');
|
|
@@ -129,7 +115,6 @@ class Connection {
|
|
|
129
115
|
return this.verbose;
|
|
130
116
|
}
|
|
131
117
|
|
|
132
|
-
|
|
133
118
|
/**
|
|
134
119
|
* @returns {object} The ``transportOptions`` property from the ``Connection`` object.
|
|
135
120
|
*/
|
package/lib/Deprecated.js
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
// Copyright
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// This file contains the classes that are deprecated in v1.0. The implementations for all of the
|
|
20
|
-
// functions in these classes prior to v1.0 are moved into the other classes. The classes contained
|
|
21
|
-
// in this file are now wrappers for those calls to enable backward compatability with
|
|
22
|
-
// previous versions, but will throw a warning message. When we no longer want to support calling
|
|
23
|
-
// these methods through these deprecated class names, we can simple disable this file.
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
24
3
|
|
|
25
4
|
/* eslint-disable max-classes-per-file */
|
|
5
|
+
/* eslint-disable default-param-last */
|
|
26
6
|
|
|
27
7
|
const deprecate = require('depd');
|
|
28
8
|
const { parseString } = require('xml2js');
|
|
@@ -45,7 +25,6 @@ const { ProgramCall } = require('./ProgramCall');
|
|
|
45
25
|
const { CommandCall } = require('./CommandCall');
|
|
46
26
|
const { Connection } = require('./Connection');
|
|
47
27
|
|
|
48
|
-
|
|
49
28
|
// DEPRECATED: For now, routes call to ProgramCall, but will be removed at a later time.
|
|
50
29
|
class iPgm {
|
|
51
30
|
/**
|
|
@@ -143,6 +122,7 @@ class iPgm {
|
|
|
143
122
|
data[key] = options[key];
|
|
144
123
|
});
|
|
145
124
|
}
|
|
125
|
+
iPgmDeprecate('As of v1.0, \'iPgm.addReturn()\' is deprecated. Please use \'ProgramCall.addReturn()\' instead.');
|
|
146
126
|
return this.ProgramCall.addReturn(data);
|
|
147
127
|
}
|
|
148
128
|
|
|
@@ -588,7 +568,6 @@ class iConn {
|
|
|
588
568
|
return this.connection.debug(flag);
|
|
589
569
|
}
|
|
590
570
|
|
|
591
|
-
|
|
592
571
|
/**
|
|
593
572
|
* @deprecated Replaced by ``Connection.getTransportOptions()`` and will be removed in the
|
|
594
573
|
* next major version.
|
|
@@ -4346,7 +4325,7 @@ function iSh(sh, options) {
|
|
|
4346
4325
|
* @returns {object[]} - The array of result objects.
|
|
4347
4326
|
*/
|
|
4348
4327
|
function xmlToJson(xml) {
|
|
4349
|
-
xmlToJsonDeprecate('As of v1.0, \'xmlToJson\' is deprecated. Use
|
|
4328
|
+
xmlToJsonDeprecate('As of v1.0, \'xmlToJson\' is deprecated. Use the fast-xml-parser npm package instead.');
|
|
4350
4329
|
|
|
4351
4330
|
const cmdRegG = /<cmd.*?>[\s\S]+?<\/cmd>/g;
|
|
4352
4331
|
const shRegG = /<sh.*?>[\s\S]+?<\/sh>/g;
|
package/lib/ProgramCall.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
// Copyright
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
17
3
|
|
|
18
4
|
/* eslint-disable no-underscore-dangle */
|
|
19
5
|
|
|
@@ -103,8 +89,8 @@ class ProgramCall {
|
|
|
103
89
|
* @property {string} value - The value of the data.
|
|
104
90
|
* @property {string} [name] - The name of the parameter.
|
|
105
91
|
* @property {data[]} [fields] - The array of data objects for a ds.
|
|
106
|
-
* @property {string} [io] - Whether the parameter is used for input, output, or
|
|
107
|
-
* Valid values are ``in``, ``out``,
|
|
92
|
+
* @property {string} [io] - Whether the parameter is used for input, output, both, or *OMIT.
|
|
93
|
+
* Valid values are ``in``, ``out``, ``both``, and ``omit``.
|
|
108
94
|
* @property {string} [by] - Whether to pass the parameter by reference or value.
|
|
109
95
|
* Valid values are ``ref`` or ``val``. NOTE: Pass by value requires ``XMLSERVICE >= 1.9.9.3``.
|
|
110
96
|
* @property {string} [dim] - Sets ds array dimension value.
|
package/lib/itoolkit.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
// Copyright
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
17
3
|
|
|
18
4
|
/**
|
|
19
5
|
* main entry point for itoolkit package
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
// Copyright
|
|
2
|
-
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
17
3
|
|
|
18
4
|
const http = require('http');
|
|
19
5
|
|
|
20
|
-
|
|
6
|
+
function httpCall(config, xmlInput, done) {
|
|
21
7
|
const {
|
|
22
8
|
database = '*LOCAL',
|
|
23
9
|
username = null,
|
|
@@ -85,6 +71,6 @@ const httpCall = (config, xmlInput, done) => {
|
|
|
85
71
|
});
|
|
86
72
|
request.write(queryString);
|
|
87
73
|
request.end();
|
|
88
|
-
}
|
|
74
|
+
}
|
|
89
75
|
|
|
90
76
|
exports.httpCall = httpCall;
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
4
|
+
let idb = null;
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
|
-
|
|
18
|
-
const idbCall = (config, xmlInput, cb) => {
|
|
19
|
-
const {
|
|
20
|
-
dbconn, dbstmt, IN, CLOB, CHAR, SQL_ATTR_DBC_SYS_NAMING, SQL_FALSE,
|
|
6
|
+
try {
|
|
7
|
+
/* eslint-disable import/no-unresolved */
|
|
21
8
|
// eslint-disable-next-line global-require
|
|
22
|
-
|
|
9
|
+
idb = require('idb-connector');
|
|
10
|
+
} catch (e) {
|
|
11
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
12
|
+
throw e;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function idbCall(config, xmlInput, cb) {
|
|
17
|
+
// idb transport is not available bail out
|
|
18
|
+
if (idb === null) {
|
|
19
|
+
cb(new Error('idb-connector was not found, ensure idb-connector is installed properly (idb-connector is only available on IBM i).'), null);
|
|
20
|
+
}
|
|
23
21
|
|
|
24
22
|
const {
|
|
25
23
|
database = '*LOCAL',
|
|
@@ -34,9 +32,9 @@ const idbCall = (config, xmlInput, cb) => {
|
|
|
34
32
|
let xmlOutput = '';
|
|
35
33
|
const sql = `call ${xslib}.iPLUGR512K(?,?,?)`;
|
|
36
34
|
// eslint-disable-next-line new-cap
|
|
37
|
-
const conn = new dbconn();
|
|
35
|
+
const conn = new idb.dbconn();
|
|
38
36
|
|
|
39
|
-
conn.setConnAttr(SQL_ATTR_DBC_SYS_NAMING, SQL_FALSE);
|
|
37
|
+
conn.setConnAttr(idb.SQL_ATTR_DBC_SYS_NAMING, idb.SQL_FALSE);
|
|
40
38
|
|
|
41
39
|
if (typeof verbose === 'boolean') {
|
|
42
40
|
conn.debug(verbose);
|
|
@@ -53,12 +51,12 @@ const idbCall = (config, xmlInput, cb) => {
|
|
|
53
51
|
return;
|
|
54
52
|
}
|
|
55
53
|
// eslint-disable-next-line new-cap
|
|
56
|
-
const stmt = new dbstmt(conn);
|
|
54
|
+
const stmt = new idb.dbstmt(conn);
|
|
57
55
|
|
|
58
56
|
const parameters = [
|
|
59
|
-
[ipc, IN, CHAR],
|
|
60
|
-
[ctl, IN, CHAR],
|
|
61
|
-
[xmlInput, IN, CLOB],
|
|
57
|
+
[ipc, idb.IN, idb.CHAR],
|
|
58
|
+
[ctl, idb.IN, idb.CHAR],
|
|
59
|
+
[xmlInput, idb.IN, idb.CLOB],
|
|
62
60
|
];
|
|
63
61
|
|
|
64
62
|
// Before returning to caller, we must clean up
|
|
@@ -106,6 +104,6 @@ const idbCall = (config, xmlInput, cb) => {
|
|
|
106
104
|
});
|
|
107
105
|
});
|
|
108
106
|
});
|
|
109
|
-
}
|
|
107
|
+
}
|
|
110
108
|
|
|
111
109
|
exports.idbCall = idbCall;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
4
|
+
let odbc = null;
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
try {
|
|
7
|
+
/* eslint-disable import/no-unresolved */
|
|
8
|
+
// eslint-disable-next-line global-require
|
|
9
|
+
odbc = require('odbc');
|
|
10
|
+
} catch (e) {
|
|
11
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
12
|
+
throw e;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
17
15
|
|
|
18
16
|
function odbcCall(config, xmlInput, done) {
|
|
19
|
-
//
|
|
20
|
-
|
|
17
|
+
// odbc transport is not available bail out
|
|
18
|
+
if (odbc === null) {
|
|
19
|
+
done(new Error('odbc transport was not found, ensure odbc is installed properly.'), null);
|
|
20
|
+
}
|
|
21
21
|
|
|
22
22
|
const {
|
|
23
23
|
host = 'localhost',
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright contributors to the nodejs-itoolkit project
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
// associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
-
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
-
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
-
// furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
-
// substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
-
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
4
|
+
const { Client } = require('ssh2');
|
|
17
5
|
|
|
18
6
|
function sshCall(config, xmlIn, done) {
|
|
19
|
-
// eslint-disable-next-line global-require
|
|
20
|
-
const { Client } = require('ssh2');
|
|
21
|
-
|
|
22
7
|
const {
|
|
23
8
|
verbose = false,
|
|
24
9
|
} = config;
|
|
@@ -71,12 +56,12 @@ function sshCall(config, xmlIn, done) {
|
|
|
71
56
|
}
|
|
72
57
|
|
|
73
58
|
if (signal) {
|
|
74
|
-
client.emit('error', new Error(`
|
|
59
|
+
client.emit('error', new Error(`xmlservice-cli was signaled with: ${signal}`));
|
|
75
60
|
return;
|
|
76
61
|
}
|
|
77
62
|
|
|
78
63
|
if (code !== 0) {
|
|
79
|
-
client.emit('error', new Error(`
|
|
64
|
+
client.emit('error', new Error(`xmlservice-cli exited abnormally with code: ${code}`));
|
|
80
65
|
return;
|
|
81
66
|
}
|
|
82
67
|
client.end();
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itoolkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "XMLSERVICE wrapper to access to all things IBM i",
|
|
5
5
|
"main": "lib/itoolkit.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib/"
|
|
8
|
+
],
|
|
6
9
|
"directories": {
|
|
7
10
|
"lib": "lib",
|
|
8
11
|
"test": "test"
|
|
9
12
|
},
|
|
10
13
|
"scripts": {
|
|
11
|
-
"test": "./node_modules/mocha/bin/mocha --recursive test/unit",
|
|
12
|
-
"test-integration": "./node_modules/mocha/bin/mocha --timeout 5s test/functional/*.js",
|
|
14
|
+
"test": "./node_modules/mocha/bin/mocha.js --recursive test/unit",
|
|
15
|
+
"test-integration": "./node_modules/mocha/bin/mocha.js --timeout 5s test/functional/*.js",
|
|
13
16
|
"lint": "./node_modules/eslint/bin/eslint.js lib/ test/",
|
|
14
|
-
"
|
|
17
|
+
"lint-fix": "./node_modules/eslint/bin/eslint.js lib/ test/ --fix",
|
|
18
|
+
"release": "./node_modules/release-it/bin/release-it.js"
|
|
15
19
|
},
|
|
16
20
|
"repository": {
|
|
17
21
|
"type": "git",
|
|
@@ -41,22 +45,25 @@
|
|
|
41
45
|
],
|
|
42
46
|
"dependencies": {
|
|
43
47
|
"depd": "^2.0.0",
|
|
44
|
-
"xml2js": "^0.
|
|
48
|
+
"xml2js": "^0.5.0"
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"eslint
|
|
50
|
-
"eslint-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
51
|
+
"@release-it/conventional-changelog": "^7.0.0",
|
|
52
|
+
"chai": "^4.3.6",
|
|
53
|
+
"eslint": "^8.26.0",
|
|
54
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
55
|
+
"eslint-plugin-import": "^2.26.0",
|
|
56
|
+
"eslint-plugin-mocha": "^10.1.0",
|
|
57
|
+
"mocha": "^10.1.0",
|
|
58
|
+
"release-it": "^16.1.0",
|
|
59
|
+
"sinon": "^14.0.1"
|
|
54
60
|
},
|
|
55
61
|
"optionalDependencies": {
|
|
56
|
-
"
|
|
57
|
-
"idb-
|
|
58
|
-
"
|
|
59
|
-
"odbc": "^2.
|
|
62
|
+
"fast-xml-parser": "^4.0.11",
|
|
63
|
+
"idb-connector": "^1.2.18",
|
|
64
|
+
"idb-pconnector": "^1.1.0",
|
|
65
|
+
"odbc": "^2.4.6",
|
|
66
|
+
"ssh2": "^1.11.0"
|
|
60
67
|
},
|
|
61
68
|
"engines": {
|
|
62
69
|
"node": ">= 8.0"
|
package/.eslintrc.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"extends": "airbnb-base",
|
|
3
|
-
env: {
|
|
4
|
-
node: true
|
|
5
|
-
},
|
|
6
|
-
rules: {
|
|
7
|
-
// Tweak rules set by airbnb config
|
|
8
|
-
'no-console': 'off', // allow console
|
|
9
|
-
'import/no-extraneous-dependencies': ["error", {"optionalDependencies": true}], // Allow optional dep import
|
|
10
|
-
// Warn unresolved imports ie: idb-connector import will be unresolved when on non IBM i system.
|
|
11
|
-
'import/no-unresolved': ['off', { commonjs: true }],
|
|
12
|
-
},
|
|
13
|
-
};
|
package/.gitattributes
DELETED
package/.readthedocs.yml
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# .readthedocs.yml
|
|
2
|
-
# Read the Docs configuration file
|
|
3
|
-
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
|
4
|
-
|
|
5
|
-
# Required
|
|
6
|
-
version: 2
|
|
7
|
-
|
|
8
|
-
# Build documentation in the docs/ directory with Sphinx
|
|
9
|
-
sphinx:
|
|
10
|
-
configuration: docs/conf.py
|
|
11
|
-
|
|
12
|
-
# Optionally set the version of Python and requirements required to build your docs
|
|
13
|
-
python:
|
|
14
|
-
version: 3.7
|
|
15
|
-
install:
|
|
16
|
-
- requirements: docs/requirements.txt
|