itoolkit 1.0.0-rc.1 → 1.0.1
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/.eslintrc.js +37 -11
- package/CHANGELOG.md +76 -2
- package/README.md +8 -8
- package/lib/Connection.js +0 -1
- package/lib/Deprecated.js +3 -4
- package/lib/ProgramCall.js +2 -2
- package/lib/transports/httpTransport.js +2 -2
- package/lib/transports/idbTransport.js +23 -11
- package/lib/transports/odbcTransport.js +16 -2
- package/lib/transports/sshTransport.js +4 -5
- package/package.json +15 -14
- package/test/README.md +2 -4
- package/test/functional/CommandCallFunctional.js +20 -12
- package/test/functional/ProgramCallFunctional.js +6 -66
- package/test/functional/checkObjectExists.js +12 -1
- package/test/functional/checkVersion.js +17 -0
- package/test/functional/deprecated/commandsFunctional.js +20 -11
- package/test/functional/deprecated/iDataQueueFunctional.js +10 -11
- package/test/functional/deprecated/iNetworkFunctional.js +8 -9
- package/test/functional/deprecated/iObjFunctional.js +18 -19
- package/test/functional/deprecated/iPgmFunctional.js +6 -42
- package/test/functional/deprecated/iProdFunctional.js +10 -11
- package/test/functional/deprecated/iSqlFunctional.js +30 -32
- package/test/functional/deprecated/iUserSpaceFunctional.js +29 -18
- package/test/functional/deprecated/iWorkFunctional.js +61 -59
- package/test/functional/iDataQueueFunctional.js +8 -9
- package/test/functional/iNetworkFunctional.js +6 -8
- package/test/functional/iObjFunctional.js +16 -17
- package/test/functional/iProdFunctional.js +8 -9
- package/test/functional/iSqlFunctional.js +30 -31
- package/test/functional/iUserSpaceFunctional.js +27 -16
- package/test/functional/iWorkFunctional.js +29 -33
- package/test/unit/CommandCallUnit.js +10 -11
- package/test/unit/ConnectionUnit.js +12 -19
- package/test/unit/ProgamCallUnit.js +27 -25
- package/test/unit/deprecated/commandsUnit.js +10 -11
- package/test/unit/deprecated/iConnUnit.js +12 -16
- package/test/unit/deprecated/iPgmUnit.js +25 -21
- package/test/unit/deprecated/iSqlUnit.js +69 -70
- package/test/unit/deprecated/xmlToJsonUnit.js +6 -9
- package/docs/CommandCall.rst +0 -22
- package/docs/Connection.rst +0 -133
- package/docs/Makefile +0 -20
- package/docs/ProgramCall.rst +0 -30
- package/docs/conf.py +0 -63
- package/docs/deprecated/examples/addQuery.js +0 -27
- package/docs/deprecated/examples/addToLibraryList.js +0 -15
- package/docs/deprecated/examples/callProcedure.js +0 -28
- package/docs/deprecated/examples/clearDataQueue.js +0 -15
- package/docs/deprecated/examples/createUserSpace.js +0 -15
- package/docs/deprecated/examples/deleteUserSpace.js +0 -15
- package/docs/deprecated/examples/getDataArea.js +0 -15
- package/docs/deprecated/examples/getInstalledProducts.js +0 -15
- package/docs/deprecated/examples/getJobInfo.js +0 -15
- package/docs/deprecated/examples/getJobStatus.js +0 -15
- package/docs/deprecated/examples/getNetInterfaceData.js +0 -15
- package/docs/deprecated/examples/getPTFInfo.js +0 -15
- package/docs/deprecated/examples/getProductInfo.js +0 -15
- package/docs/deprecated/examples/getSysStatus.js +0 -15
- package/docs/deprecated/examples/getSysStatusExt.js +0 -15
- package/docs/deprecated/examples/getSysValue.js +0 -15
- package/docs/deprecated/examples/getTCPIPAttr.js +0 -15
- package/docs/deprecated/examples/getUserSpaceData.js +0 -15
- package/docs/deprecated/examples/receiveFromDataQueue.js +0 -15
- package/docs/deprecated/examples/retrCmdInfo.js +0 -15
- package/docs/deprecated/examples/retrPgmInfo.js +0 -15
- package/docs/deprecated/examples/retrSrvPgmInfo.js +0 -16
- package/docs/deprecated/examples/retrUserAuthToObj.js +0 -15
- package/docs/deprecated/examples/retrUserInfo.js +0 -15
- package/docs/deprecated/examples/retrUsrAuth.js +0 -15
- package/docs/deprecated/examples/sendToDataQueue.js +0 -15
- package/docs/deprecated/examples/setUserSpaceData.js +0 -15
- package/docs/deprecated/iCmd.rst +0 -7
- package/docs/deprecated/iConn.rst +0 -9
- package/docs/deprecated/iDataQueue.rst +0 -33
- package/docs/deprecated/iNetwork.rst +0 -27
- package/docs/deprecated/iObj.rst +0 -64
- package/docs/deprecated/iPgm.rst +0 -9
- package/docs/deprecated/iProd.rst +0 -36
- package/docs/deprecated/iQsh.rst +0 -7
- package/docs/deprecated/iSh.rst +0 -7
- package/docs/deprecated/iSql.rst +0 -30
- package/docs/deprecated/iUserSpace.rst +0 -38
- package/docs/deprecated/iWork.rst +0 -58
- package/docs/deprecated.rst +0 -21
- package/docs/examples/cosine.js +0 -27
- package/docs/examples/qusrobjd.js +0 -80
- package/docs/examples/rtvjoba.js +0 -24
- package/docs/features.rst +0 -12
- package/docs/index.rst +0 -71
- package/docs/migratation-guide-v1.0.rst +0 -325
- package/docs/requirements.txt +0 -1
package/.eslintrc.js
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
module.exports =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: 'airbnb-base',
|
|
3
|
+
plugins: [
|
|
4
|
+
'mocha',
|
|
5
|
+
],
|
|
6
|
+
env: {
|
|
7
|
+
node: true,
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
// Tweak rules set by airbnb config
|
|
11
|
+
// We need to allow use of console.log for verbose mode
|
|
12
|
+
'no-console': 'off',
|
|
13
|
+
// airbnb config forbids optionalDependencies
|
|
14
|
+
// https://github.com/airbnb/javascript/blob/c5bee75b1b358a3749f1a6d38ee6fad73de28e29/packages/eslint-config-airbnb-base/rules/imports.js#L95
|
|
15
|
+
"import/no-extraneous-dependencies": [ "error", { "optionalDependencies": true }],
|
|
16
|
+
// Project uses opt deps like odbc and idb-connector which may not exist
|
|
17
|
+
"import/no-unresolved": 'off',
|
|
18
|
+
},
|
|
19
|
+
overrides: [
|
|
20
|
+
{
|
|
21
|
+
files: ['test/**/*.js'],
|
|
22
|
+
env: {
|
|
23
|
+
node: true,
|
|
24
|
+
mocha: true,
|
|
25
|
+
},
|
|
26
|
+
extends: 'plugin:mocha/recommended',
|
|
27
|
+
rules: {
|
|
28
|
+
// These are set by airbnb-base, but go against Mocha conventions
|
|
29
|
+
// See https://mochajs.org/#arrow-functions
|
|
30
|
+
// and https://github.com/airbnb/javascript/issues/433
|
|
31
|
+
'func-names': 'off',
|
|
32
|
+
'prefer-arrow-callback': 'off',
|
|
33
|
+
|
|
34
|
+
// The following rules cause problems for our existing tests, so they are disabled for now:
|
|
35
|
+
'mocha/no-skipped-tests': 'off',
|
|
12
36
|
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
13
39
|
};
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,81 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## [1.0.1](https://github.com/IBM/nodejs-itoolkit/compare/v1.0.0...v1.0.1) (2022-10-31)
|
|
4
|
+
|
|
5
|
+
- fix: Missing braces in README Example (#286)
|
|
6
|
+
- fix: Typo in ssh transport error message (#287)
|
|
7
|
+
- test: Remove redundant ProgramCall test (#284)
|
|
8
|
+
- test: Constrain eslint rules
|
|
9
|
+
- test: Fix eslint errors issues in eslintrc
|
|
10
|
+
- test: Configure tests to use Mocha env in eslintrc
|
|
11
|
+
- test: Adjust AirBnB rules for Mocha tests
|
|
12
|
+
- test: Use eslint-plugin-mocha for tests
|
|
13
|
+
- test: Remove arrow functions from mocha functions (#283)
|
|
14
|
+
- ci: Add eslint action (#244)
|
|
15
|
+
- docs: Update setup transport interface links (#292)
|
|
16
|
+
- fix: Emit deprecation warning for iPgm.addReturn (#295)
|
|
17
|
+
- build(deps-dev): bump standard-version from 7.1.0 to 8.0.1 (#299)
|
|
18
|
+
- build(deps): bump lodash from 4.17.15 to 4.17.19 (#302)
|
|
19
|
+
- chore: Unmark as stale if issue has been updated (#311)
|
|
20
|
+
- fix: Make exempt labels plural for stale action (#312)
|
|
21
|
+
- test: Check the XMLSERVICE version for QSH support (#303)
|
|
22
|
+
- fix: Update standard-version to resolve CVE-2020-8116 (#310)
|
|
23
|
+
- refactor: Handle optional dependencies better (#306)
|
|
24
|
+
- test: Fix mocha/no-identical-title eslint issue (#296)
|
|
25
|
+
- test: Fix mocha/no-hooks-for-single-case eslint issue (#297)
|
|
26
|
+
- fix: eslint GH action failure (#336)
|
|
27
|
+
- docs: Add comma to separate password and url key
|
|
28
|
+
- build(deps): Update deps to the latest version (#347)
|
|
29
|
+
- docs: Add omit as valid value for io (#346)
|
|
30
|
+
- docs: Reference alternate XML parser (#345)
|
|
31
|
+
- build: readthedocs build error (#349)
|
|
32
|
+
- build(deps): Add fast-xml-parser (#351)
|
|
33
|
+
- build(deps): Upgrade ssh2 to latest version (#355)
|
|
34
|
+
- fix: Better optional deps handling (#353)
|
|
35
|
+
- ci: Add npm publish action (#358)
|
|
36
|
+
- docs: Update cosine example to pass by value (#359)
|
|
37
|
+
|
|
38
|
+
## [1.0.0](https://github.com/IBM/nodejs-itoolkit/compare/1.0.0-alpha.1...1.0.0) (2020-05-08)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### ⚠ BREAKING CHANGES
|
|
42
|
+
|
|
43
|
+
* Remove iSql.connect() and iSql.setOptions()
|
|
44
|
+
* Remove iConn.setTimeout()
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
* Allow DS for service program return value ([#217](https://github.com/IBM/nodejs-itoolkit/issues/217)) ([30e9f8a](https://github.com/IBM/nodejs-itoolkit/commit/30e9f8a69da829935dcee72dbd394032feef0e27))
|
|
49
|
+
* Specify supported Node versions ([#264](https://github.com/IBM/nodejs-itoolkit/issues/264)) ([63ec53c](https://github.com/IBM/nodejs-itoolkit/commit/63ec53c0ac17e9d4130b79074a61075ce0ac897e))
|
|
50
|
+
* use standard-version [#85](https://github.com/IBM/nodejs-itoolkit/issues/85) ([45f66a7](https://github.com/IBM/nodejs-itoolkit/commit/45f66a7f9ac5b5d37c907f5d088cb517cd4d3d66))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Bug Fixes
|
|
54
|
+
|
|
55
|
+
* Add missing '?' in xml prolog ([bff8649](https://github.com/IBM/nodejs-itoolkit/commit/bff864991f73f5789c5dec563821c86eb1aab3fa))
|
|
56
|
+
* data type issue in Toolkit.getSysStatus and Toolkit.getSysStatusExt ([#190](https://github.com/IBM/nodejs-itoolkit/issues/190)) ([15397c2](https://github.com/IBM/nodejs-itoolkit/commit/15397c279d51b9282ef948b7d61d7d403690ce6f))
|
|
57
|
+
* Define errno structure correctly ([#192](https://github.com/IBM/nodejs-itoolkit/issues/192)) ([b1561f7](https://github.com/IBM/nodejs-itoolkit/commit/b1561f76e5803409c485f8b965745a060462852b)), closes [#191](https://github.com/IBM/nodejs-itoolkit/issues/191)
|
|
58
|
+
* Deprecated functional tests rest transport options ([#255](https://github.com/IBM/nodejs-itoolkit/issues/255)) ([903dd3f](https://github.com/IBM/nodejs-itoolkit/commit/903dd3f70f635f37bb2abba4a61b5a99a4f16ba3))
|
|
59
|
+
* eslint errors ([#243](https://github.com/IBM/nodejs-itoolkit/issues/243)) ([df40eb0](https://github.com/IBM/nodejs-itoolkit/commit/df40eb0c4898214493b22b9054d9eea57e6bccd9))
|
|
60
|
+
* Faulty error thrown by ProgramCall.addParam ([#124](https://github.com/IBM/nodejs-itoolkit/issues/124)) ([75d081c](https://github.com/IBM/nodejs-itoolkit/commit/75d081c86ae35f0557ea7b5a1f8886018de6ff36))
|
|
61
|
+
* Formatting errors in bug report template ([24a9262](https://github.com/IBM/nodejs-itoolkit/commit/24a92626e97f407dc7de998e2c65d6500d289eaf))
|
|
62
|
+
* Homepage link in package.json ([#267](https://github.com/IBM/nodejs-itoolkit/issues/267)) ([d5787ce](https://github.com/IBM/nodejs-itoolkit/commit/d5787cef2ade2d8fa298986a73040158dd2b6f84))
|
|
63
|
+
* HTTP transport should take a URL ([#252](https://github.com/IBM/nodejs-itoolkit/issues/252)) ([34e4e37](https://github.com/IBM/nodejs-itoolkit/commit/34e4e3765667a6060d82bd6dabf2bcd4569aa765))
|
|
64
|
+
* iConn unit test failure ([52f0330](https://github.com/IBM/nodejs-itoolkit/commit/52f0330801a8b5bbdbac19af4ff60ee80927a9e3))
|
|
65
|
+
* iConn unit test failure ([#274](https://github.com/IBM/nodejs-itoolkit/issues/274)) ([9e72857](https://github.com/IBM/nodejs-itoolkit/commit/9e728572fcfd734059d3a09e6934760518183250))
|
|
66
|
+
* Improper TOC nesting in main README ([#175](https://github.com/IBM/nodejs-itoolkit/issues/175)) ([db5d44c](https://github.com/IBM/nodejs-itoolkit/commit/db5d44cdcc79dbded8d3fa6f0717ed268d5d7606))
|
|
67
|
+
* minimist CVE ([#231](https://github.com/IBM/nodejs-itoolkit/issues/231)) ([6d02c43](https://github.com/IBM/nodejs-itoolkit/commit/6d02c43c38cf3c5fcc2e5ee559ea123ba97b12f2))
|
|
68
|
+
* Move iConn compatibility code to iConn itself ([#218](https://github.com/IBM/nodejs-itoolkit/issues/218)) ([73d798d](https://github.com/IBM/nodejs-itoolkit/commit/73d798deaf1ca840d2c0d5742ded40712fe33955))
|
|
69
|
+
* ssh transport econnreset ([#272](https://github.com/IBM/nodejs-itoolkit/issues/272)) ([d5e71c1](https://github.com/IBM/nodejs-itoolkit/commit/d5e71c159319574a937ee415df4c636d7f347ba7))
|
|
70
|
+
* ssh transport silent failure ([#225](https://github.com/IBM/nodejs-itoolkit/issues/225)) ([6e3b8a0](https://github.com/IBM/nodejs-itoolkit/commit/6e3b8a0f11539ee04540cf12d97cd6b67b3ed967))
|
|
71
|
+
* Test hooks timeout when using rest transport ([#253](https://github.com/IBM/nodejs-itoolkit/issues/253)) ([60fdd5b](https://github.com/IBM/nodejs-itoolkit/commit/60fdd5b75ba165646d8f888344aa1924c39272b1))
|
|
72
|
+
* TODOs in Deprecated.js ([#240](https://github.com/IBM/nodejs-itoolkit/issues/240)) ([cd47476](https://github.com/IBM/nodejs-itoolkit/commit/cd474766d769d7832cf38fca40a5ed14b19f4bfa))
|
|
73
|
+
* **idb:** Improve cleanup handling ([#233](https://github.com/IBM/nodejs-itoolkit/issues/233)) ([c2bb115](https://github.com/IBM/nodejs-itoolkit/commit/c2bb1152e13785a975597da41d6ca7df94bf4c09))
|
|
74
|
+
* Use encodeURIComponent for URL params ([2c98b22](https://github.com/IBM/nodejs-itoolkit/commit/2c98b229148adbc3475d2eba1c1f397cd7367447)), closes [#72](https://github.com/IBM/nodejs-itoolkit/issues/72) [#71](https://github.com/IBM/nodejs-itoolkit/issues/71)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
* Remove iConn.setTimeout() ([c978c41](https://github.com/IBM/nodejs-itoolkit/commit/c978c41ad28f5e4db152bd4bd5e56ba3824ea650))
|
|
78
|
+
* Remove iSql.connect() and iSql.setOptions() ([066e8ba](https://github.com/IBM/nodejs-itoolkit/commit/066e8ba43e0c68ff6165b4be8f1d00eac1242f38))
|
|
4
79
|
|
|
5
80
|
## [1.0.0-alpha.1](https://github.com/IBM/nodejs-itoolkit/compare/1.0.0-alpha.0...1.0.0-alpha.1) (2019-07-10)
|
|
6
81
|
|
|
@@ -151,4 +226,3 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
151
226
|
### [0.1.5](https://github.com/IBM/nodejs-itoolkit/compare/0.1.4...0.1.5) (2019-01-08)
|
|
152
227
|
|
|
153
228
|
### 0.1.4 (2018-09-17)
|
|
154
|
-
|
package/README.md
CHANGED
|
@@ -47,11 +47,11 @@ XMLSERVICE will run the command and respond with XML output.
|
|
|
47
47
|
</myscript>
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
`itoolkit
|
|
50
|
+
`itoolkit`, with the help of an XML parser, can run the same CL command with:
|
|
51
51
|
|
|
52
52
|
```js
|
|
53
53
|
const { Connection, CommandCall } = require('itoolkit');
|
|
54
|
-
const {
|
|
54
|
+
const { XMLParser } = require('fast-xml-parser');
|
|
55
55
|
|
|
56
56
|
const connection = new Connection({
|
|
57
57
|
transport: 'ssh',
|
|
@@ -66,12 +66,12 @@ connection.run((error, xmlOutput) => {
|
|
|
66
66
|
if (error) {
|
|
67
67
|
throw error;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
|
|
70
|
+
const Parser = new XMLParser();
|
|
71
|
+
const result = Parser.parse(xmlOutput);
|
|
72
|
+
|
|
73
|
+
console.log(JSON.stringify(result));
|
|
74
|
+
});
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
The purpose of this package is to simplify the process of creating XMLSERVICE input, invoking XMLSERVICE, and returning XMLSERVICE output from Node.js.
|
package/lib/Connection.js
CHANGED
package/lib/Deprecated.js
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
16
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
// This file contains the classes that are deprecated in v1.0. The implementations for all of the
|
|
20
19
|
// functions in these classes prior to v1.0 are moved into the other classes. The classes contained
|
|
21
20
|
// in this file are now wrappers for those calls to enable backward compatability with
|
|
@@ -23,6 +22,7 @@
|
|
|
23
22
|
// these methods through these deprecated class names, we can simple disable this file.
|
|
24
23
|
|
|
25
24
|
/* eslint-disable max-classes-per-file */
|
|
25
|
+
/* eslint-disable default-param-last */
|
|
26
26
|
|
|
27
27
|
const deprecate = require('depd');
|
|
28
28
|
const { parseString } = require('xml2js');
|
|
@@ -45,7 +45,6 @@ const { ProgramCall } = require('./ProgramCall');
|
|
|
45
45
|
const { CommandCall } = require('./CommandCall');
|
|
46
46
|
const { Connection } = require('./Connection');
|
|
47
47
|
|
|
48
|
-
|
|
49
48
|
// DEPRECATED: For now, routes call to ProgramCall, but will be removed at a later time.
|
|
50
49
|
class iPgm {
|
|
51
50
|
/**
|
|
@@ -143,6 +142,7 @@ class iPgm {
|
|
|
143
142
|
data[key] = options[key];
|
|
144
143
|
});
|
|
145
144
|
}
|
|
145
|
+
iPgmDeprecate('As of v1.0, \'iPgm.addReturn()\' is deprecated. Please use \'ProgramCall.addReturn()\' instead.');
|
|
146
146
|
return this.ProgramCall.addReturn(data);
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -588,7 +588,6 @@ class iConn {
|
|
|
588
588
|
return this.connection.debug(flag);
|
|
589
589
|
}
|
|
590
590
|
|
|
591
|
-
|
|
592
591
|
/**
|
|
593
592
|
* @deprecated Replaced by ``Connection.getTransportOptions()`` and will be removed in the
|
|
594
593
|
* next major version.
|
|
@@ -4346,7 +4345,7 @@ function iSh(sh, options) {
|
|
|
4346
4345
|
* @returns {object[]} - The array of result objects.
|
|
4347
4346
|
*/
|
|
4348
4347
|
function xmlToJson(xml) {
|
|
4349
|
-
xmlToJsonDeprecate('As of v1.0, \'xmlToJson\' is deprecated. Use
|
|
4348
|
+
xmlToJsonDeprecate('As of v1.0, \'xmlToJson\' is deprecated. Use the fast-xml-parser npm package instead.');
|
|
4350
4349
|
|
|
4351
4350
|
const cmdRegG = /<cmd.*?>[\s\S]+?<\/cmd>/g;
|
|
4352
4351
|
const shRegG = /<sh.*?>[\s\S]+?<\/sh>/g;
|
package/lib/ProgramCall.js
CHANGED
|
@@ -103,8 +103,8 @@ class ProgramCall {
|
|
|
103
103
|
* @property {string} value - The value of the data.
|
|
104
104
|
* @property {string} [name] - The name of the parameter.
|
|
105
105
|
* @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``,
|
|
106
|
+
* @property {string} [io] - Whether the parameter is used for input, output, both, or *OMIT.
|
|
107
|
+
* Valid values are ``in``, ``out``, ``both``, and ``omit``.
|
|
108
108
|
* @property {string} [by] - Whether to pass the parameter by reference or value.
|
|
109
109
|
* Valid values are ``ref`` or ``val``. NOTE: Pass by value requires ``XMLSERVICE >= 1.9.9.3``.
|
|
110
110
|
* @property {string} [dim] - Sets ds array dimension value.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
const http = require('http');
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
function httpCall(config, xmlInput, done) {
|
|
21
21
|
const {
|
|
22
22
|
database = '*LOCAL',
|
|
23
23
|
username = null,
|
|
@@ -85,6 +85,6 @@ const httpCall = (config, xmlInput, done) => {
|
|
|
85
85
|
});
|
|
86
86
|
request.write(queryString);
|
|
87
87
|
request.end();
|
|
88
|
-
}
|
|
88
|
+
}
|
|
89
89
|
|
|
90
90
|
exports.httpCall = httpCall;
|
|
@@ -15,11 +15,23 @@
|
|
|
15
15
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
16
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
let idb = null;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
/* eslint-disable import/no-unresolved */
|
|
21
22
|
// eslint-disable-next-line global-require
|
|
22
|
-
|
|
23
|
+
idb = require('idb-connector');
|
|
24
|
+
} catch (e) {
|
|
25
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
26
|
+
throw e;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function idbCall(config, xmlInput, cb) {
|
|
31
|
+
// idb transport is not available bail out
|
|
32
|
+
if (idb === null) {
|
|
33
|
+
cb(new Error('idb-connector was not found, ensure idb-connector is installed properly (idb-connector is only available on IBM i).'), null);
|
|
34
|
+
}
|
|
23
35
|
|
|
24
36
|
const {
|
|
25
37
|
database = '*LOCAL',
|
|
@@ -34,9 +46,9 @@ const idbCall = (config, xmlInput, cb) => {
|
|
|
34
46
|
let xmlOutput = '';
|
|
35
47
|
const sql = `call ${xslib}.iPLUGR512K(?,?,?)`;
|
|
36
48
|
// eslint-disable-next-line new-cap
|
|
37
|
-
const conn = new dbconn();
|
|
49
|
+
const conn = new idb.dbconn();
|
|
38
50
|
|
|
39
|
-
conn.setConnAttr(SQL_ATTR_DBC_SYS_NAMING, SQL_FALSE);
|
|
51
|
+
conn.setConnAttr(idb.SQL_ATTR_DBC_SYS_NAMING, idb.SQL_FALSE);
|
|
40
52
|
|
|
41
53
|
if (typeof verbose === 'boolean') {
|
|
42
54
|
conn.debug(verbose);
|
|
@@ -53,12 +65,12 @@ const idbCall = (config, xmlInput, cb) => {
|
|
|
53
65
|
return;
|
|
54
66
|
}
|
|
55
67
|
// eslint-disable-next-line new-cap
|
|
56
|
-
const stmt = new dbstmt(conn);
|
|
68
|
+
const stmt = new idb.dbstmt(conn);
|
|
57
69
|
|
|
58
70
|
const parameters = [
|
|
59
|
-
[ipc, IN, CHAR],
|
|
60
|
-
[ctl, IN, CHAR],
|
|
61
|
-
[xmlInput, IN, CLOB],
|
|
71
|
+
[ipc, idb.IN, idb.CHAR],
|
|
72
|
+
[ctl, idb.IN, idb.CHAR],
|
|
73
|
+
[xmlInput, idb.IN, idb.CLOB],
|
|
62
74
|
];
|
|
63
75
|
|
|
64
76
|
// Before returning to caller, we must clean up
|
|
@@ -106,6 +118,6 @@ const idbCall = (config, xmlInput, cb) => {
|
|
|
106
118
|
});
|
|
107
119
|
});
|
|
108
120
|
});
|
|
109
|
-
}
|
|
121
|
+
}
|
|
110
122
|
|
|
111
123
|
exports.idbCall = idbCall;
|
|
@@ -15,9 +15,23 @@
|
|
|
15
15
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
16
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
let odbc = null;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
/* eslint-disable import/no-unresolved */
|
|
19
22
|
// eslint-disable-next-line global-require
|
|
20
|
-
|
|
23
|
+
odbc = require('odbc');
|
|
24
|
+
} catch (e) {
|
|
25
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
26
|
+
throw e;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function odbcCall(config, xmlInput, done) {
|
|
31
|
+
// odbc transport is not available bail out
|
|
32
|
+
if (odbc === null) {
|
|
33
|
+
done(new Error('odbc transport was not found, ensure odbc is installed properly.'), null);
|
|
34
|
+
}
|
|
21
35
|
|
|
22
36
|
const {
|
|
23
37
|
host = 'localhost',
|
|
@@ -15,10 +15,9 @@
|
|
|
15
15
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
16
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line global-require
|
|
20
|
-
const { Client } = require('ssh2');
|
|
18
|
+
const { Client } = require('ssh2');
|
|
21
19
|
|
|
20
|
+
function sshCall(config, xmlIn, done) {
|
|
22
21
|
const {
|
|
23
22
|
verbose = false,
|
|
24
23
|
} = config;
|
|
@@ -71,12 +70,12 @@ function sshCall(config, xmlIn, done) {
|
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
if (signal) {
|
|
74
|
-
client.emit('error', new Error(`
|
|
73
|
+
client.emit('error', new Error(`xmlservice-cli was signaled with: ${signal}`));
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
if (code !== 0) {
|
|
79
|
-
client.emit('error', new Error(`
|
|
78
|
+
client.emit('error', new Error(`xmlservice-cli exited abnormally with code: ${code}`));
|
|
80
79
|
return;
|
|
81
80
|
}
|
|
82
81
|
client.end();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itoolkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "XMLSERVICE wrapper to access to all things IBM i",
|
|
5
5
|
"main": "lib/itoolkit.js",
|
|
6
6
|
"directories": {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"test": "test"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "./node_modules/mocha/bin/mocha --recursive test/unit",
|
|
12
|
-
"test-integration": "./node_modules/mocha/bin/mocha --timeout 5s test/functional/*.js",
|
|
11
|
+
"test": "./node_modules/mocha/bin/mocha.js --recursive test/unit",
|
|
12
|
+
"test-integration": "./node_modules/mocha/bin/mocha.js --timeout 5s test/functional/*.js",
|
|
13
13
|
"lint": "./node_modules/eslint/bin/eslint.js lib/ test/",
|
|
14
14
|
"release": "standard-version"
|
|
15
15
|
},
|
|
@@ -44,19 +44,20 @@
|
|
|
44
44
|
"xml2js": "^0.4.23"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"chai": "^4.
|
|
48
|
-
"eslint": "^
|
|
49
|
-
"eslint-config-airbnb-base": "^
|
|
50
|
-
"eslint-plugin-import": "^2.
|
|
51
|
-
"mocha": "^
|
|
52
|
-
"
|
|
53
|
-
"
|
|
47
|
+
"chai": "^4.3.6",
|
|
48
|
+
"eslint": "^8.26.0",
|
|
49
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
50
|
+
"eslint-plugin-import": "^2.26.0",
|
|
51
|
+
"eslint-plugin-mocha": "^10.1.0",
|
|
52
|
+
"mocha": "^10.1.0",
|
|
53
|
+
"sinon": "^14.0.1"
|
|
54
54
|
},
|
|
55
55
|
"optionalDependencies": {
|
|
56
|
-
"idb-connector": "^1.2.
|
|
57
|
-
"idb-pconnector": "^1.0
|
|
58
|
-
"
|
|
59
|
-
"
|
|
56
|
+
"idb-connector": "^1.2.18",
|
|
57
|
+
"idb-pconnector": "^1.1.0",
|
|
58
|
+
"odbc": "^2.4.6",
|
|
59
|
+
"ssh2": "^1.11.0",
|
|
60
|
+
"fast-xml-parser": "^4.0.11"
|
|
60
61
|
},
|
|
61
62
|
"engines": {
|
|
62
63
|
"node": ">= 8.0"
|
package/test/README.md
CHANGED
|
@@ -12,11 +12,9 @@ Ensure dependencies are installed by running `npm install` from the project root
|
|
|
12
12
|
|
|
13
13
|
Integration tests require additional setup and configuration. Some tests require objects to preexist on the IBM i. The test case will check if the object exists and log instructions if the object is not found.
|
|
14
14
|
|
|
15
|
-
## Setup Rest interface
|
|
16
|
-
- view the [README](../README.md#rest)
|
|
15
|
+
## [Setup Rest interface](https://nodejs-itoolkit.readthedocs.io/en/latest/Connection.html#rest)
|
|
17
16
|
|
|
18
|
-
## Setup SSH interface
|
|
19
|
-
- view the [README](../README.md#ssh)
|
|
17
|
+
## [Setup SSH interface](https://nodejs-itoolkit.readthedocs.io/en/latest/Connection.html#ssh)
|
|
20
18
|
|
|
21
19
|
## Configuring Tests
|
|
22
20
|
|
|
@@ -15,21 +15,19 @@
|
|
|
15
15
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
16
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
17
|
|
|
18
|
-
/* eslint-env mocha */
|
|
19
|
-
|
|
20
18
|
const { expect } = require('chai');
|
|
21
19
|
const { parseString } = require('xml2js');
|
|
22
|
-
const { CommandCall, Connection } = require('../../lib/itoolkit');
|
|
20
|
+
const { CommandCall, Connection, ProgramCall } = require('../../lib/itoolkit');
|
|
23
21
|
const { config, printConfig } = require('./config');
|
|
22
|
+
const { isQSHSupported } = require('./checkVersion');
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
before(() => {
|
|
24
|
+
describe('CommandCall Functional Tests', function () {
|
|
25
|
+
before(function () {
|
|
28
26
|
printConfig();
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
describe('CL command tests', ()
|
|
32
|
-
it('calls CL command', (done)
|
|
29
|
+
describe('CL command tests', function () {
|
|
30
|
+
it('calls CL command', function (done) {
|
|
33
31
|
const connection = new Connection(config);
|
|
34
32
|
connection.add(new CommandCall({ command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)', type: 'cl' }));
|
|
35
33
|
connection.run((error, xmlOut) => {
|
|
@@ -43,8 +41,8 @@ describe('CommandCall Functional Tests', () => {
|
|
|
43
41
|
});
|
|
44
42
|
});
|
|
45
43
|
|
|
46
|
-
describe('SH command tests', ()
|
|
47
|
-
it('calls PASE shell command', (done)
|
|
44
|
+
describe('SH command tests', function () {
|
|
45
|
+
it('calls PASE shell command', function (done) {
|
|
48
46
|
const connection = new Connection(config);
|
|
49
47
|
connection.add(new CommandCall({ command: 'system -i wrksyssts', type: 'sh' }));
|
|
50
48
|
connection.run((error, xmlOut) => {
|
|
@@ -60,9 +58,10 @@ describe('CommandCall Functional Tests', () => {
|
|
|
60
58
|
});
|
|
61
59
|
});
|
|
62
60
|
|
|
63
|
-
describe('QSH command tests', ()
|
|
64
|
-
it('calls QSH command', (done)
|
|
61
|
+
describe('QSH command tests', function () {
|
|
62
|
+
it('calls QSH command', function (done) {
|
|
65
63
|
const connection = new Connection(config);
|
|
64
|
+
connection.add(new ProgramCall('MYPGMTOOLONG'));
|
|
66
65
|
connection.add(new CommandCall({ command: 'system wrksyssts', type: 'qsh' }));
|
|
67
66
|
connection.run((error, xmlOut) => {
|
|
68
67
|
expect(error).to.equal(null);
|
|
@@ -70,6 +69,15 @@ describe('CommandCall Functional Tests', () => {
|
|
|
70
69
|
// but on error sh or qsh node will not have any inner data
|
|
71
70
|
parseString(xmlOut, (parseError, result) => {
|
|
72
71
|
expect(parseError).to.equal(null);
|
|
72
|
+
const match = result.myscript.pgm[0].version[0].match(/\d\.\d\.\d/);
|
|
73
|
+
if (!match) {
|
|
74
|
+
throw Error('Unable to determine XMLSERVICE version');
|
|
75
|
+
}
|
|
76
|
+
if (!isQSHSupported(match[0])) {
|
|
77
|
+
// skip if QSH is unsupported
|
|
78
|
+
console.log(`XMLSERVICE version ${match[0]} does not support QSH`);
|
|
79
|
+
this.skip();
|
|
80
|
+
}
|
|
73
81
|
expect(result.myscript.qsh[0]._).to.match(/(System\sStatus\sInformation)/);
|
|
74
82
|
done();
|
|
75
83
|
});
|
|
@@ -15,77 +15,18 @@
|
|
|
15
15
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
16
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
17
|
|
|
18
|
-
/* eslint-env mocha */
|
|
19
|
-
|
|
20
18
|
const { expect } = require('chai');
|
|
21
19
|
const { parseString } = require('xml2js');
|
|
22
20
|
const { ProgramCall, Connection } = require('../../lib/itoolkit');
|
|
23
21
|
const { config, printConfig } = require('./config');
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
before(() => {
|
|
23
|
+
describe('ProgramCall Functional Tests', function () {
|
|
24
|
+
before(function () {
|
|
28
25
|
printConfig();
|
|
29
26
|
});
|
|
30
27
|
|
|
31
|
-
describe('
|
|
32
|
-
it('calls QWCRSVAL program checks if it ran successfully', (done)
|
|
33
|
-
const connection = new Connection(config);
|
|
34
|
-
|
|
35
|
-
const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' });
|
|
36
|
-
|
|
37
|
-
const outBuf = {
|
|
38
|
-
type: 'ds',
|
|
39
|
-
io: 'out',
|
|
40
|
-
fields: [
|
|
41
|
-
{ type: '10i0', value: 0 },
|
|
42
|
-
{ type: '10i0', value: 0 },
|
|
43
|
-
{ type: '36h', value: '' },
|
|
44
|
-
{ type: '10A', value: '' },
|
|
45
|
-
{ type: '1A', value: '' },
|
|
46
|
-
{ type: '1A', value: '' },
|
|
47
|
-
{ type: '10i0', value: 0 },
|
|
48
|
-
{ type: '10i0', value: 0 },
|
|
49
|
-
],
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const errno = {
|
|
53
|
-
type: 'ds',
|
|
54
|
-
io: 'both',
|
|
55
|
-
len: 'rec2',
|
|
56
|
-
fields: [
|
|
57
|
-
{
|
|
58
|
-
name: 'bytes_provided',
|
|
59
|
-
type: '10i0',
|
|
60
|
-
value: 0,
|
|
61
|
-
setlen: 'rec2',
|
|
62
|
-
},
|
|
63
|
-
{ name: 'bytes_available', type: '10i0', value: 0 },
|
|
64
|
-
{ name: 'msgid', type: '7A', value: '' },
|
|
65
|
-
{ type: '1A', value: '' },
|
|
66
|
-
],
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
program.addParam(outBuf);
|
|
70
|
-
program.addParam({ type: '10i0', value: 66 });
|
|
71
|
-
program.addParam({ type: '10i0', value: 1 });
|
|
72
|
-
program.addParam({ type: '10A', value: 'QCCSID' });
|
|
73
|
-
program.addParam(errno);
|
|
74
|
-
connection.add(program);
|
|
75
|
-
connection.run((error, xmlOut) => {
|
|
76
|
-
expect(error).to.equal(null);
|
|
77
|
-
parseString(xmlOut, (parseError, result) => {
|
|
78
|
-
expect(parseError).to.equal(null);
|
|
79
|
-
expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL');
|
|
80
|
-
done();
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
describe('Test ProgramCall()', () => {
|
|
88
|
-
it('calls QWCRSVAL program and returns arbitrarily named parameter', (done) => {
|
|
28
|
+
describe('addParam', function () {
|
|
29
|
+
it('calls QWCRSVAL program checks if it ran successfully', function (done) {
|
|
89
30
|
const connection = new Connection(config);
|
|
90
31
|
|
|
91
32
|
const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' });
|
|
@@ -106,7 +47,6 @@ describe('ProgramCall Functional Tests', () => {
|
|
|
106
47
|
};
|
|
107
48
|
|
|
108
49
|
const errno = {
|
|
109
|
-
name: 'errno',
|
|
110
50
|
type: 'ds',
|
|
111
51
|
io: 'both',
|
|
112
52
|
len: 'rec2',
|
|
@@ -140,10 +80,10 @@ describe('ProgramCall Functional Tests', () => {
|
|
|
140
80
|
});
|
|
141
81
|
});
|
|
142
82
|
|
|
143
|
-
describe.skip('
|
|
83
|
+
describe.skip('addReturn', function () {
|
|
144
84
|
// ZZSRV6 program requires XMLSERVICE built with tests
|
|
145
85
|
// Skip for now, we need to add before hook to check ZZSRV6 is available
|
|
146
|
-
it.skip('
|
|
86
|
+
it.skip('calls ZZVARY4 and checks the return value', function (done) {
|
|
147
87
|
const connection = new Connection(config);
|
|
148
88
|
|
|
149
89
|
const program = new ProgramCall('ZZSRV6', { lib: 'XMLSERVICE', func: 'ZZVARY4' });
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
/* eslint-disable default-param-last */
|
|
2
|
+
|
|
1
3
|
const lib = 'NODETKTEST';
|
|
2
4
|
const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test Node.js toolkit')`;
|
|
3
5
|
const findLib = `SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = '${lib}'`;
|
|
4
6
|
|
|
5
7
|
function checkObjectExistsSSH(config, object = {}, callback) {
|
|
6
|
-
|
|
8
|
+
// ssh2 is an optional dependency, since users may not use this transport
|
|
9
|
+
// thus we can't globally require it
|
|
10
|
+
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
7
11
|
const { Client } = require('ssh2');
|
|
8
12
|
|
|
9
13
|
const client = new Client();
|
|
@@ -68,6 +72,9 @@ function checkObjectExistsSSH(config, object = {}, callback) {
|
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
function checkObjectExistsODBC(config, object = {}, callback) {
|
|
75
|
+
// odbc is an optional dependency, since users may not use this transport
|
|
76
|
+
// thus we can't globally require it
|
|
77
|
+
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
71
78
|
const odbc = require('odbc');
|
|
72
79
|
|
|
73
80
|
const connectionString = config.dsn || `DRIVER=IBM i Access ODBC Driver;SYSTEM=${config.host};UID=${config.username};PWD=${config.password};`;
|
|
@@ -110,6 +117,10 @@ function checkObjectExistsODBC(config, object = {}, callback) {
|
|
|
110
117
|
}
|
|
111
118
|
|
|
112
119
|
function checkObjectExistsIDB(config, object = {}, callback) {
|
|
120
|
+
// idb-connector is an optional dependency, since users may not use this transport
|
|
121
|
+
// thus we can't globally require it
|
|
122
|
+
// eslint-disable-next-line max-len
|
|
123
|
+
// eslint-disable-next-line global-require, import/no-extraneous-dependencies, import/no-unresolved
|
|
113
124
|
const { dbconn, dbstmt } = require('idb-connector');
|
|
114
125
|
|
|
115
126
|
/* eslint-disable new-cap */
|