|
| 1 | +Migrating from itoolkit v0.x to v1.x |
| 2 | +************************************ |
| 3 | + |
| 4 | +If you are upgrading an existing application its a great idea to have |
| 5 | +good test coverage before upgrading. |
| 6 | + |
| 7 | +Most applications applications using a version < 1.0.0 should continue |
| 8 | +to work but it’s still highly recommended to test your application |
| 9 | +first. |
| 10 | + |
| 11 | +.. WARNING:: |
| 12 | + **BREAKING CHANGES** |
| 13 | + |
| 14 | +BREAKING CHANGES |
| 15 | +================ |
| 16 | + |
| 17 | +Sync Mode Operations |
| 18 | +-------------------- |
| 19 | + |
| 20 | +``iConn.run()`` no longer supports sync mode. Sync mode is not reccommended and since it did not work properly it was removed. |
| 21 | +See (`#32 <https://github.com/IBM/nodejs-itoolkit/issues/32>`__) for more details. |
| 22 | + |
| 23 | +``iConn.setTimeout()`` is removed. This function was used to set the timeout for ``iConn.run`` |
| 24 | +sync mode. |
| 25 | + |
| 26 | +iSql Authentication |
| 27 | +------------------- |
| 28 | + |
| 29 | +``iSql.connect()`` and ``iSql.setOptions()`` are removed. These functions were used in conjunction |
| 30 | +for XMLSERVICE user |
| 31 | +authentication. The transports already handle user authentication. |
| 32 | + |
| 33 | +New Features |
| 34 | +============ |
| 35 | + |
| 36 | +SSH and ODBC transports |
| 37 | +----------------------- |
| 38 | + |
| 39 | +Users can now use ``ssh`` and ``odbc`` transports. This will allow users |
| 40 | +more ways to use itoolkit on their local machine. |
| 41 | + |
| 42 | +Support error first callbacks |
| 43 | +----------------------------- |
| 44 | + |
| 45 | +- ``iConn.run()`` did not return errors to the run callback. |
| 46 | + ``Connection.run()`` follows Node.js convention of `error first |
| 47 | + callbacks <https://nodejs.org/api/errors.html#errors_error_first_callbacks>`__. |
| 48 | + ``Connection`` still has a compatability option ``returnError`` to |
| 49 | + behave like ``iConn.run()`` and return the xml output as the first |
| 50 | + parameter of the run callback. See the :ref:`iconn-to-connection-run` section. |
| 51 | + |
| 52 | + |
| 53 | +Support DS types within addReturn |
| 54 | +--------------------------------- |
| 55 | + |
| 56 | +- ``iPgm.addReturn`` did not support the DS data type, |
| 57 | + ``ProgramCall.addReturn`` added support. |
| 58 | + |
| 59 | +Deprecated Classes and Functions |
| 60 | +================================ |
| 61 | + |
| 62 | +iConn |
| 63 | +----- |
| 64 | + |
| 65 | +The ``iConn`` class was replaced with the ``Connection`` class and it |
| 66 | +will be removed in ``v2.x``. |
| 67 | + |
| 68 | +Differences |
| 69 | +^^^^^^^^^^^ |
| 70 | + |
| 71 | +- ``Connection`` constructor accepts single object parameter. |
| 72 | +- ``Connection.run()`` follows Node.js convention of error first `error |
| 73 | + first |
| 74 | + callbacks <https://nodejs.org/api/errors.html#errors_error_first_callbacks>`__. |
| 75 | + |
| 76 | +Migrating from ``iConn`` to ``Connection`` |
| 77 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 78 | + |
| 79 | +.. WARNING:: |
| 80 | + Beware that the Connection and iConn classes differ in how they call the callbacks |
| 81 | + passed to their run methods. You cannot simply replace iConn with Connection without adjusting |
| 82 | + your callbacks. See the :ref:`iconn-to-connection-run` section. |
| 83 | + |
| 84 | +When connecting using idb-connector, ``iConn`` takes 3 arguments: ``database``, ``username``, |
| 85 | +and ``password``. These can be passed as attributes on the ``transportOptions`` attribute of the |
| 86 | +object passed to ``Connection`` and specify the transport is ``idb``. eg. |
| 87 | + |
| 88 | +.. code:: js |
| 89 | +
|
| 90 | + // const conn = new iConn('*LOCAL', 'myuser', 'mypassword'); |
| 91 | +
|
| 92 | + const conn = new Connection({ |
| 93 | + transport: 'idb', |
| 94 | + transportOptions: { database: '*LOCAL', username: 'myuser', password: 'mypassword' } |
| 95 | + }); |
| 96 | +
|
| 97 | +When connecting using rest, ``iConn`` takes 4 arguments: ``database``, ``username``, ``password``, |
| 98 | +and ``options``. The options object included ``host``, ``port``, and ``path`` to |
| 99 | +generate the url string. Instead specify ``database``, ``username``, ``password``, and ``url`` |
| 100 | +on the ``transportOptions`` attribute of the object passed to ``Connection`` and specify the |
| 101 | +transport is ``rest``. eg. |
| 102 | + |
| 103 | +.. code:: js |
| 104 | +
|
| 105 | + // const restConfig = { host: 'myhost.example.com', port: 80, path: '/cgi-bin/xmlcgi.pgm' } |
| 106 | + // const conn = new iConn('*LOCAL', 'myuser', 'mypassword', restConfig); |
| 107 | +
|
| 108 | + const conn = new Connection({ |
| 109 | + transport: 'rest', |
| 110 | + transportOptions: { |
| 111 | + database: '*LOCAL', |
| 112 | + username: 'myuser', |
| 113 | + password: 'mypassword', |
| 114 | + url: 'http://myhost.example.com/cgi-bin/xmlcgi.pgm', |
| 115 | + } |
| 116 | + }); |
| 117 | +
|
| 118 | +.. _iconn-to-connection-run: |
| 119 | + |
| 120 | +Migrating from ``iConn.run()`` to ``Connection.run()`` |
| 121 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 122 | + |
| 123 | +1. Create an instance of Connection with ``returnError`` set to false. |
| 124 | + This is a compatabilty option to behave like ``iConn.run()`` and |
| 125 | + return the xml output as the first parameter of the run callback. |
| 126 | + |
| 127 | +.. code:: js |
| 128 | +
|
| 129 | + // const conn = new iConn("*LOCAL", "myuser", "mypassword"); |
| 130 | +
|
| 131 | + const conn = new Connection({ |
| 132 | + transport: 'idb', |
| 133 | + returnError: false, |
| 134 | + transportOptions: { database: '*LOCAL', username: 'myuser', password: 'mypassword' } |
| 135 | + }); |
| 136 | +
|
| 137 | + conn.add(...) |
| 138 | +
|
| 139 | + conn.run((xmlOutput) => { |
| 140 | + ... |
| 141 | + }) |
| 142 | +
|
| 143 | +2. Test your application still works as expected using this instance of |
| 144 | + ``Connection``. |
| 145 | + |
| 146 | +3. Update ``Connection.run()`` callbacks to expect an error as the first |
| 147 | + parameter. |
| 148 | + |
| 149 | +.. code:: js |
| 150 | +
|
| 151 | + conn.run((error, xmlOutput) => { |
| 152 | + if (error) { throw error; } |
| 153 | + }); |
| 154 | +
|
| 155 | +4. Remove ``returnError`` property from the ``Connection`` constructor. |
| 156 | + The default behavior is to return error first callbacks. |
| 157 | + |
| 158 | +.. code:: js |
| 159 | +
|
| 160 | + const conn = new Connection({ |
| 161 | + transport: 'idb', |
| 162 | + transportOptions: { database: '*LOCAL', username: 'myuser', password: 'mypassword' } |
| 163 | + }); |
| 164 | +
|
| 165 | +iPgm |
| 166 | +---- |
| 167 | + |
| 168 | +``iPgm`` was replaced by the ``ProgramCall`` and will be removed in |
| 169 | +``v2.x``. |
| 170 | + |
| 171 | +Differences |
| 172 | +^^^^^^^^^^^ |
| 173 | + |
| 174 | +- Data and data structures and are now defined as objects. |
| 175 | +- ``ProgramCall.addParam()`` now accepts a single object parameter. |
| 176 | +- ``ProgramCall.addReturn()`` now accepts a single object parameter, |
| 177 | +- ``ProgramCall.addReturn()`` now supports DS as return type. |
| 178 | + |
| 179 | +Migrating from ``iPgm.addParam()`` to ``ProgramCall.addParam()`` |
| 180 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 181 | + |
| 182 | +Parameter and data options are passed with the object parameter. Ensure |
| 183 | +the data type is specified; defaulting to use ``1024a`` is deprecated. |
| 184 | + |
| 185 | +.. code:: js |
| 186 | +
|
| 187 | + // iPgm.addParam('0', '10i0', { io: 'in', setlen: 'rec1' }) |
| 188 | +
|
| 189 | + ProgramCall.addParam({ type: '10i0', io: 'in', setlen: 'rec1', value: 0 }) |
| 190 | +
|
| 191 | +Data structures have type ``ds`` and an additional ``fields`` property |
| 192 | +which is an array of data or ds objects. |
| 193 | + |
| 194 | +.. code:: js |
| 195 | +
|
| 196 | + /* |
| 197 | + const ds = [ |
| 198 | + [0, '10i0'], |
| 199 | + [0, '10i0', { setlen: 'rec2' }], |
| 200 | + ['', '36h'], |
| 201 | + ['', '10A'], |
| 202 | + ['', '1A'], |
| 203 | + ['', '1A'], |
| 204 | + [0, '10i0'], |
| 205 | + [0, '10i0'], |
| 206 | + ]; |
| 207 | + */ |
| 208 | +
|
| 209 | + // iPgm.addParam(ds, { io: 'out', dim: '1' }); |
| 210 | +
|
| 211 | + const ds = { |
| 212 | + type: 'ds', |
| 213 | + dim: '1', |
| 214 | + io: 'out', |
| 215 | + fields: [ |
| 216 | + { type: '10i0', value: 0 }, |
| 217 | + { type: '10i0', value: 0, setlen: 'rec2' }, |
| 218 | + { type: '36h', value: '' }, |
| 219 | + { type: '10A', value: '' }, |
| 220 | + { type: '1A', value: ''}, |
| 221 | + { type: '1A', value: ''}, |
| 222 | + { type: '10i0', value: 0 }, |
| 223 | + { type: '10i0', value: 0 }, |
| 224 | + ] |
| 225 | + }; |
| 226 | +
|
| 227 | + ProgramCall.addParam(ds); |
| 228 | +
|
| 229 | +Migrating from ``iPgm.addReturn()`` to ``ProgramCall.addReturn()`` |
| 230 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 231 | + |
| 232 | +Data previously defined as: |
| 233 | + |
| 234 | +``addReturn('', '10A', { varying: '4' })`` |
| 235 | + |
| 236 | +Will now be defined as: |
| 237 | + |
| 238 | +``addReturn({type: '10A', value: '', varying: '4' })`` |
| 239 | + |
| 240 | +iCmd |
| 241 | +---- |
| 242 | + |
| 243 | +``iCmd`` is replaced by ``CommandCall`` and will be removed in ``v2.x``. |
| 244 | + |
| 245 | +A command previously generated with: |
| 246 | + |
| 247 | +``const command = iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)')`` |
| 248 | + |
| 249 | +Will now be generated with: |
| 250 | + |
| 251 | +``const command = new CommandCall({type: 'cl', command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)' })`` |
| 252 | + |
| 253 | +iQsh |
| 254 | +---- |
| 255 | + |
| 256 | +``iQsh`` is replaced by ``CommandCall`` and will be removed in ``v2.x``. |
| 257 | + |
| 258 | +A command previously generated with: |
| 259 | + |
| 260 | +``const command = iQsh('system wrksyssts')`` |
| 261 | + |
| 262 | +Will now be generated with: |
| 263 | + |
| 264 | +``const command = new CommandCall({type: 'qsh', command: 'system wrksyssts' })`` |
| 265 | + |
| 266 | +iSh |
| 267 | +--- |
| 268 | + |
| 269 | +``iSh`` is replaced by ``CommandCall`` and will be removed in ``v2.x``. |
| 270 | + |
| 271 | +A command previously generated with: |
| 272 | + |
| 273 | +``const command = iSh('ls /home')`` |
| 274 | + |
| 275 | +Will now be generated with: |
| 276 | + |
| 277 | +``const command = new CommandCall({type: 'sh', command: 'ls /home' })`` |
| 278 | + |
| 279 | +iSql |
| 280 | +---- |
| 281 | + |
| 282 | +``iSql`` class is deprecated and will be removed in ``v2.x``. The |
| 283 | +`odbc <https://www.npmjs.com/package/odbc>`__, |
| 284 | +`idb-connector <https://www.npmjs.com/package/idb-connector>`__, and |
| 285 | +`idb-pconnector <https://www.npmjs.com/package/idb-pconnector>`__ npm |
| 286 | +packages are much better SQL interfaces for IBM i and should be used |
| 287 | +instead. |
| 288 | + |
| 289 | +``iSql.connect`` and ``iSql.setOptions`` are no longer available. |
| 290 | + |
| 291 | +xmlToJson |
| 292 | +--------- |
| 293 | + |
| 294 | +``xmlToJson`` is deprecated and will be removed in ``v2.x``. Use |
| 295 | +`xml2js <https://www.npmjs.com/package/xml2js>`__ instead. |
| 296 | + |
| 297 | +iDataQueue |
| 298 | +---------- |
| 299 | + |
| 300 | +The ``iDataQueue`` class is deprecated and will be removed in ``v2.x``. |
| 301 | + |
| 302 | +iNetwork |
| 303 | +-------- |
| 304 | + |
| 305 | +The ``iNetwork`` class is deprecated and will be removed in ``v2.x``. |
| 306 | + |
| 307 | +iObj |
| 308 | +---- |
| 309 | + |
| 310 | +The ``iObj`` class is deprecated and will be removed in ``v2.x``. |
| 311 | + |
| 312 | +iProd |
| 313 | +----- |
| 314 | + |
| 315 | +The ``iProd`` class is deprecated and will be removed in ``v2.x``. |
| 316 | + |
| 317 | +iUserSpace |
| 318 | +---------- |
| 319 | + |
| 320 | +The ``iUserSpace`` class is deprecated and will be removed in ``v2.x``. |
| 321 | + |
| 322 | +iWork |
| 323 | +----- |
| 324 | + |
| 325 | +The ``iWork`` class is deprecated and will be removed in ``v2.x``. |
0 commit comments