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.
Files changed (45) hide show
  1. package/README.md +13 -8
  2. package/lib/CommandCall.js +2 -16
  3. package/lib/Connection.js +2 -17
  4. package/lib/Deprecated.js +5 -26
  5. package/lib/ProgramCall.js +4 -18
  6. package/lib/itoolkit.js +2 -16
  7. package/lib/transports/httpTransport.js +4 -18
  8. package/lib/transports/idbTransport.js +24 -26
  9. package/lib/transports/odbcTransport.js +16 -16
  10. package/lib/transports/sshTransport.js +5 -20
  11. package/package.json +23 -16
  12. package/.eslintrc.js +0 -13
  13. package/.gitattributes +0 -2
  14. package/.readthedocs.yml +0 -16
  15. package/CHANGELOG.md +0 -195
  16. package/contributors.txt +0 -2
  17. package/test/README.md +0 -46
  18. package/test/functional/CommandCallFunctional.js +0 -79
  19. package/test/functional/ProgramCallFunctional.js +0 -166
  20. package/test/functional/checkObjectExists.js +0 -182
  21. package/test/functional/config.js +0 -35
  22. package/test/functional/deprecated/commandsFunctional.js +0 -99
  23. package/test/functional/deprecated/iDataQueueFunctional.js +0 -104
  24. package/test/functional/deprecated/iNetworkFunctional.js +0 -160
  25. package/test/functional/deprecated/iObjFunctional.js +0 -350
  26. package/test/functional/deprecated/iPgmFunctional.js +0 -140
  27. package/test/functional/deprecated/iProdFunctional.js +0 -161
  28. package/test/functional/deprecated/iSqlFunctional.js +0 -455
  29. package/test/functional/deprecated/iUserSpaceFunctional.js +0 -127
  30. package/test/functional/deprecated/iWorkFunctional.js +0 -236
  31. package/test/functional/iDataQueueFunctional.js +0 -84
  32. package/test/functional/iNetworkFunctional.js +0 -133
  33. package/test/functional/iObjFunctional.js +0 -327
  34. package/test/functional/iProdFunctional.js +0 -135
  35. package/test/functional/iSqlFunctional.js +0 -449
  36. package/test/functional/iUserSpaceFunctional.js +0 -123
  37. package/test/functional/iWorkFunctional.js +0 -219
  38. package/test/unit/CommandCallUnit.js +0 -88
  39. package/test/unit/ConnectionUnit.js +0 -195
  40. package/test/unit/ProgamCallUnit.js +0 -279
  41. package/test/unit/deprecated/commandsUnit.js +0 -88
  42. package/test/unit/deprecated/iConnUnit.js +0 -162
  43. package/test/unit/deprecated/iPgmUnit.js +0 -207
  44. package/test/unit/deprecated/iSqlUnit.js +0 -442
  45. package/test/unit/deprecated/xmlToJsonUnit.js +0 -203
@@ -1,203 +0,0 @@
1
- // Copyright (c) International Business Machines Corp. 2019
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
- /* eslint-env mocha */
19
-
20
- const { expect } = require('chai');
21
- const { xmlToJson } = require('../../../lib/itoolkit');
22
-
23
- describe('xmlToJson Tests', () => {
24
- it('converts CL command XML output to js object', () => {
25
- const xmlOut = '<?xml version=\'1.0\'?><myscript><cmd exec=\'rexx\' error=\'fast\'>'
26
- + '<success>+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)</success>'
27
- + '<row><data desc=\'USRLIBL\'>QGPL QTEMP QDEVELOP QBLDSYS'
28
- + ' QBLDSYSR</data></row><row><data desc=\'SYSLIBL\'>QSYS'
29
- + ' QSYS2 QHLPSYS QUSRSYS</data></row></cmd></myscript>';
30
-
31
- const result = xmlToJson(xmlOut);
32
- expect(result).to.be.an('array');
33
- expect(result.length).to.equal(1);
34
- expect(result[0]).to.be.an('object');
35
- expect(result[0]).to.haveOwnProperty('type').and.to.equal('cmd');
36
- const cmd = 'RTVJOBA USRLIBL(?) SYSLIBL(?)';
37
- expect(result[0]).to.haveOwnProperty('cmd').and.to.equal(cmd);
38
- expect(result[0]).to.haveOwnProperty('data');
39
- expect(result[0].data).to.be.an('array');
40
- expect(result[0].data.length).to.equal(2);
41
- expect(result[0].data[0]).to.be.an('object');
42
- const name = 'USRLIBL';
43
- expect(result[0].data[0]).to.haveOwnProperty('name').and.to.equal(name);
44
- const value = 'QGPL QTEMP QDEVELOP QBLDSYS QBLDSYSR';
45
- expect(result[0].data[0]).to.haveOwnProperty('value').and.to.equal(value);
46
- });
47
-
48
- it('converts sh command XML output to js object', () => {
49
- const xmlOut = '<?xml version=\'1.0\'?><myscript><sh error=\'fast\'>\n'
50
- + 'bin\n'
51
- + 'ccs\n'
52
- + 'icu4c\n'
53
- + 'includ\n'
54
- + 'lbin\n'
55
- + 'lib\n'
56
- + 'lib64\n'
57
- + 'lpp\n'
58
- + 'sbin\n'
59
- + 'share\n'
60
- + 'vacpp\n'
61
- + '</sh>\n'
62
- + '</myscript>';
63
-
64
- const result = xmlToJson(xmlOut);
65
- expect(result).to.be.an('array');
66
- expect(result.length).to.equal(1);
67
- expect(result[0]).to.be.an('object');
68
- expect(result[0]).to.haveOwnProperty('type').and.to.equal('sh');
69
- const data = '\nbin\nccs\nicu4c\ninclud\nlbin\nlib\nlib64\nlpp\nsbin\n'
70
- + 'share\nvacpp\n';
71
- expect(result[0]).to.haveOwnProperty('data').and.to.equal(data);
72
- });
73
-
74
-
75
- it('converts qsh command XML output to js object', () => {
76
- const xmlOut = '<?xml version=\'1.0\'?><myscript><qsh error=\'fast\'>\n'
77
- + 'bin\n'
78
- + 'ccs\n'
79
- + 'icu4c\n'
80
- + 'includ\n'
81
- + 'lbin\n'
82
- + 'lib\n'
83
- + 'lib64\n'
84
- + 'lpp\n'
85
- + 'sbin\n'
86
- + 'share\n'
87
- + 'vacpp\n'
88
- + '</qsh>\n'
89
- + '</myscript>';
90
-
91
- const result = xmlToJson(xmlOut);
92
- expect(result).to.be.an('array');
93
- expect(result.length).to.equal(1);
94
- expect(result[0]).to.be.an('object');
95
- expect(result[0]).to.haveOwnProperty('type').and.to.equal('qsh');
96
- const data = '\nbin\nccs\nicu4c\ninclud\nlbin\nlib\nlib64\nlpp\nsbin\n'
97
- + 'share\nvacpp\n';
98
- expect(result[0]).to.haveOwnProperty('data').and.to.equal(data);
99
- });
100
-
101
- it('converts pgm command XML output to js object', () => {
102
- const xmlOut = `<?xml version='1.0'?><myscript><pgm name='QWCRSVAL' lib='QSYS' error='fast'>
103
- <parm io='out'>
104
- <ds len='rec1'>
105
- <data type='10i0'>1</data>
106
- <data type='10i0'>8</data>
107
- <data type='10A'>QCENTURY</data>
108
- <data type='1A'>C</data>
109
- <data type='1A'></data>
110
- <data type='10i0'>1</data>
111
- <data type='4A'>1</data>
112
- </ds>
113
- </parm>
114
- <parm>
115
- <data type='10i0' setlen='rec1'>28</data>
116
- </parm>
117
- <parm>
118
- <data type='10i0'>1</data>
119
- </parm>
120
- <parm>
121
- <data type='10A'>QCENTURY</data>
122
- </parm>
123
- <parm io='both'>
124
- <ds len='rec2'>
125
- <data type='10i0'>0</data>
126
- <data type='10i0' setlen='rec2'>16</data>
127
- <data type='7A'></data>
128
- <data type='1A'></data>
129
- </ds>
130
- </parm>
131
- <success><![CDATA[+++ success QSYS QWCRSVAL ]]></success>
132
- </pgm>
133
- </myscript>`;
134
-
135
- const result = xmlToJson(xmlOut);
136
-
137
- expect(result).to.be.an('array');
138
- expect(result.length).to.equal(1);
139
- expect(result[0]).to.be.an('object');
140
- expect(result[0]).to.haveOwnProperty('type').and.to.equal('pgm');
141
- expect(result[0]).to.haveOwnProperty('success').and.to.equal(true);
142
- expect(result[0]).to.haveOwnProperty('pgm').and.to.equal('QWCRSVAL');
143
- expect(result[0]).to.haveOwnProperty('lib').and.to.equal('QSYS');
144
- expect(result[0]).to.haveOwnProperty('data');
145
- expect(result[0].data).to.be.an('array');
146
- expect(result[0].data.length).to.equal(14);
147
-
148
- result[0].data.forEach((part) => {
149
- expect(part).to.be.an('object');
150
- expect(result[0].data[0]).to.haveOwnProperty('value');
151
- expect(result[0].data[0]).to.haveOwnProperty('type');
152
- });
153
- });
154
-
155
- it('converts sql command XML output to js object', () => {
156
- const xmlOut = `<?xml version='1.0'?><myscript><sql>
157
- <query error='fast' conn='conn1' stmt='stmt1'>
158
- <success><![CDATA[+++ success SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT]]></success>
159
- </query>
160
- <fetch block='all' desc='on' stmt='stmt1'>
161
- <row><data desc='LSTNAM'>Henning</data><data desc='STATE'>TX</data></row>
162
- <row><data desc='LSTNAM'>Jones</data><data desc='STATE'>NY</data></row>
163
- <row><data desc='LSTNAM'>Vine</data><data desc='STATE'>VT</data></row>
164
- <row><data desc='LSTNAM'>Johnson</data><data desc='STATE'>GA</data></row>
165
- <row><data desc='LSTNAM'>Tyron</data><data desc='STATE'>NY</data></row>
166
- <row><data desc='LSTNAM'>Stevens</data><data desc='STATE'>CO</data></row>
167
- <row><data desc='LSTNAM'>Alison</data><data desc='STATE'>MN</data></row>
168
- <row><data desc='LSTNAM'>Doe</data><data desc='STATE'>CA</data></row>
169
- <row><data desc='LSTNAM'>Thomas</data><data desc='STATE'>WY</data></row>
170
- <row><data desc='LSTNAM'>Williams</data><data desc='STATE'>TX</data></row>
171
- <row><data desc='LSTNAM'>Lee</data><data desc='STATE'>NY</data></row>
172
- <row><data desc='LSTNAM'>Abraham</data><data desc='STATE'>MN</data></row>
173
- <success>+++ success stmt1</success>
174
- </fetch>
175
- <free><success>+++ success </success>
176
- </free>
177
- </sql>
178
- </myscript>`;
179
-
180
- const result = xmlToJson(xmlOut);
181
-
182
- expect(result).to.be.an('array');
183
- expect(result.length).to.equal(1);
184
- expect(result[0]).to.be.an('object');
185
- expect(result[0]).to.haveOwnProperty('type').and.to.equal('sql');
186
- expect(result[0]).to.haveOwnProperty('success').and.to.equal(true);
187
- const stmt = 'SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT';
188
- expect(result[0]).to.haveOwnProperty('stmt').and.to.equal(stmt);
189
- expect(result[0]).to.haveOwnProperty('result');
190
- expect(result[0].result).to.be.an('array');
191
- expect(result[0].result.length).to.equal(12);
192
-
193
- // result is 2D array: each of its element is another array of objects
194
- // Propose to simplify for result to be 1D array of objects
195
- result[0].result.forEach((childArray) => {
196
- expect(childArray).to.be.an('array');
197
- childArray.forEach((element) => {
198
- expect(element).to.haveOwnProperty('desc');
199
- expect(element).to.haveOwnProperty('value');
200
- });
201
- });
202
- });
203
- });