@itentialopensource/adapter-bmc_helix_itsm 0.3.4 → 0.3.5

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/CALLS.md CHANGED
@@ -310,5 +310,17 @@ Specific adapter calls are built based on the API of the Bmc_helix_itsm. The Ada
310
310
  <td style="padding:15px">{base_path}/{version}/entry/CHG:ChangeInterface/{pathv1}?{query}</td>
311
311
  <td style="padding:15px">Yes</td>
312
312
  </tr>
313
+ <tr>
314
+ <td style="padding:15px">getChangeRequestWorklogs(q, iapMetadata, callback)</td>
315
+ <td style="padding:15px">Retrieve change request worklog entries</td>
316
+ <td style="padding:15px">{base_path}/{version}/entry/CHG:WorkLog?{query}</td>
317
+ <td style="padding:15px">Yes</td>
318
+ </tr>
319
+ <tr>
320
+ <td style="padding:15px">createChangeRequestWorklog(body, iapMetadata, callback)</td>
321
+ <td style="padding:15px">createChangeRequestWorklog</td>
322
+ <td style="padding:15px">{base_path}/{version}/entry/CHG:WorkLog?{query}</td>
323
+ <td style="padding:15px">Yes</td>
324
+ </tr>
313
325
  </table>
314
326
  <br>
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ## 0.3.5 [10-22-2024]
3
+
4
+ * Add worklog calls
5
+
6
+ See merge request itentialopensource/adapters/adapter-bmc_helix_itsm!13
7
+
8
+ ---
9
+
2
10
  ## 0.3.4 [10-15-2024]
3
11
 
4
12
  * Changes made at 2024.10.14_19:48PM
package/adapter.js CHANGED
@@ -2205,6 +2205,207 @@ class BmcHelixItsm extends AdapterBaseCl {
2205
2205
  return callback(null, errorObj);
2206
2206
  }
2207
2207
  }
2208
+
2209
+ /**
2210
+ * @function getChangeRequestWorklogs
2211
+ * @pronghornType method
2212
+ * @name getChangeRequestWorklogs
2213
+ * @summary Retrieve change request worklog entries
2214
+ *
2215
+ * @param {string} [q] - Used to filter worklog entries
2216
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2217
+ * @param {getCallback} callback - a callback function to return the result
2218
+ * @return {object} results - An object containing the response of the action
2219
+ *
2220
+ * @route {POST} /getChangeRequestWorklogs
2221
+ * @roles admin
2222
+ * @task true
2223
+ */
2224
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2225
+ getChangeRequestWorklogs(q, iapMetadata, callback) {
2226
+ const meth = 'adapter-getChangeRequestWorklogs';
2227
+ const origin = `${this.id}-${meth}`;
2228
+ log.trace(origin);
2229
+
2230
+ if (this.suspended && this.suspendMode === 'error') {
2231
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2232
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2233
+ return callback(null, errorObj);
2234
+ }
2235
+
2236
+ /* HERE IS WHERE YOU VALIDATE DATA */
2237
+
2238
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2239
+ const queryParamsAvailable = { q };
2240
+ const queryParams = {};
2241
+ const pathVars = [];
2242
+ const bodyVars = {};
2243
+
2244
+ // loop in template. long callback arg name to avoid identifier conflicts
2245
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2246
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2247
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2248
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2249
+ }
2250
+ });
2251
+
2252
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2253
+ // see adapter code documentation for more information on the request object's fields
2254
+ const reqObj = {
2255
+ payload: bodyVars,
2256
+ uriPathVars: pathVars,
2257
+ uriQuery: queryParams
2258
+ };
2259
+
2260
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2261
+
2262
+ // Merge and add new iapMetadata fields in reqObj
2263
+ if (iapMetadata && typeof iapMetadata === 'object') {
2264
+ Object.keys(iapMetadata).forEach((iapField) => {
2265
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2266
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2267
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2268
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2269
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2270
+ } else {
2271
+ // Otherwise, add new iapMetadata fields to reqObj
2272
+ reqObj[iapField] = iapMetadata[iapField];
2273
+ }
2274
+ }
2275
+ });
2276
+ // Add iapMetadata to reqObj for further work
2277
+ reqObj.iapMetadata = iapMetadata;
2278
+ }
2279
+
2280
+ try {
2281
+ // Make the call -
2282
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2283
+ return this.requestHandlerInst.identifyRequest('ChangeRequest', 'getChangeRequestWorklogs', reqObj, true, (irReturnData, irReturnError) => {
2284
+ // if we received an error or their is no response on the results
2285
+ // return an error
2286
+ if (irReturnError) {
2287
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2288
+ return callback(null, irReturnError);
2289
+ }
2290
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2291
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getChangeRequestWorklogs'], null, null, null);
2292
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2293
+ return callback(null, errorObj);
2294
+ }
2295
+
2296
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2297
+ // return the response
2298
+ return callback(irReturnData, null);
2299
+ });
2300
+ } catch (ex) {
2301
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2302
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2303
+ return callback(null, errorObj);
2304
+ }
2305
+ }
2306
+
2307
+ /**
2308
+ * @function createChangeRequestWorklog
2309
+ * @pronghornType method
2310
+ * @name createChangeRequestWorklog
2311
+ * @summary createChangeRequestWorklog
2312
+ *
2313
+ * @param {object} body - Request body
2314
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2315
+ * @param {getCallback} callback - a callback function to return the result
2316
+ * @return {object} results - An object containing the response of the action
2317
+ *
2318
+ * @route {POST} /createChangeRequestWorklog
2319
+ * @roles admin
2320
+ * @task true
2321
+ */
2322
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2323
+ createChangeRequestWorklog(body, iapMetadata, callback) {
2324
+ const meth = 'adapter-createChangeRequestWorklog';
2325
+ const origin = `${this.id}-${meth}`;
2326
+ log.trace(origin);
2327
+
2328
+ if (this.suspended && this.suspendMode === 'error') {
2329
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2330
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2331
+ return callback(null, errorObj);
2332
+ }
2333
+
2334
+ /* HERE IS WHERE YOU VALIDATE DATA */
2335
+ if (body === undefined || body === null || body === '') {
2336
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2337
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2338
+ return callback(null, errorObj);
2339
+ }
2340
+
2341
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2342
+ const queryParamsAvailable = {};
2343
+ const queryParams = {};
2344
+ const pathVars = [];
2345
+ const bodyVars = body;
2346
+
2347
+ // loop in template. long callback arg name to avoid identifier conflicts
2348
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2349
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2350
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2351
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2352
+ }
2353
+ });
2354
+
2355
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2356
+ // see adapter code documentation for more information on the request object's fields
2357
+ const reqObj = {
2358
+ payload: bodyVars,
2359
+ uriPathVars: pathVars,
2360
+ uriQuery: queryParams
2361
+ };
2362
+
2363
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2364
+
2365
+ // Merge and add new iapMetadata fields in reqObj
2366
+ if (iapMetadata && typeof iapMetadata === 'object') {
2367
+ Object.keys(iapMetadata).forEach((iapField) => {
2368
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2369
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2370
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2371
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2372
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2373
+ } else {
2374
+ // Otherwise, add new iapMetadata fields to reqObj
2375
+ reqObj[iapField] = iapMetadata[iapField];
2376
+ }
2377
+ }
2378
+ });
2379
+ // Add iapMetadata to reqObj for further work
2380
+ reqObj.iapMetadata = iapMetadata;
2381
+ }
2382
+
2383
+ try {
2384
+ // Make the call -
2385
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2386
+ return this.requestHandlerInst.identifyRequest('ChangeRequest', 'createChangeRequestWorklog', reqObj, true, (irReturnData, irReturnError) => {
2387
+ // if we received an error or their is no response on the results
2388
+ // return an error
2389
+ if (irReturnError) {
2390
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2391
+ return callback(null, irReturnError);
2392
+ }
2393
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2394
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createChangeRequestWorklog'], null, null, null);
2395
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2396
+ return callback(null, errorObj);
2397
+ }
2398
+
2399
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2400
+ // return the response
2401
+ return callback(irReturnData, null);
2402
+ });
2403
+ } catch (ex) {
2404
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2405
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2406
+ return callback(null, errorObj);
2407
+ }
2408
+ }
2208
2409
  }
2209
2410
 
2210
2411
  module.exports = BmcHelixItsm;
@@ -79,6 +79,47 @@
79
79
  "mockFile": ""
80
80
  }
81
81
  ]
82
+ },
83
+ {
84
+ "name": "getChangeRequestWorklogs",
85
+ "protocol": "REST",
86
+ "method": "GET",
87
+ "entitypath": "{base_path}/{version}/entry/CHG:WorkLog?{query}",
88
+ "requestSchema": "schema.json",
89
+ "responseSchema": "schema.json",
90
+ "timeout": 0,
91
+ "sendEmpty": false,
92
+ "sendGetBody": false,
93
+ "requestDatatype": "JSON",
94
+ "responseDatatype": "JSON",
95
+ "headers": {},
96
+ "responseObjects": [
97
+ {
98
+ "type": "default",
99
+ "key": "",
100
+ "mockFile": ""
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ "name": "createChangeRequestWorklog",
106
+ "protocol": "REST",
107
+ "method": "POST",
108
+ "entitypath": "{base_path}/{version}/entry/CHG:WorkLog?{query}",
109
+ "requestSchema": "schema.json",
110
+ "responseSchema": "schema.json",
111
+ "timeout": 0,
112
+ "sendEmpty": false,
113
+ "requestDatatype": "JSON",
114
+ "responseDatatype": "JSON",
115
+ "headers": {},
116
+ "responseObjects": [
117
+ {
118
+ "type": "default",
119
+ "key": "",
120
+ "mockFile": ""
121
+ }
122
+ ]
82
123
  }
83
124
  ]
84
125
  }
@@ -13,7 +13,9 @@
13
13
  "createChangeRequest",
14
14
  "updateChangeRequest",
15
15
  "getChangeRequest",
16
- "getChangeRequests"
16
+ "getChangeRequests",
17
+ "getChangeRequestWorklogs",
18
+ "createChangeRequestWorklog"
17
19
  ],
18
20
  "external_name": "ph_request_type"
19
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-bmc_helix_itsm",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "This adapter integrates with system described as: bmc_helix_itsm",
5
5
  "main": "adapter.js",
6
6
  "wizardVersion": "2.44.7",
package/pronghorn.json CHANGED
@@ -64,13 +64,13 @@
64
64
  }
65
65
  },
66
66
  {
67
- "name" : "replace",
67
+ "name": "replace",
68
68
  "type": "boolean",
69
69
  "info": "True to replace entire mock data, false to merge/append",
70
70
  "required": false,
71
71
  "schema": {
72
72
  "title": "replace",
73
- "type" : "boolean"
73
+ "type": "boolean"
74
74
  }
75
75
  }
76
76
  ],
@@ -1729,7 +1729,95 @@
1729
1729
  "path": "/getChangeRequests"
1730
1730
  },
1731
1731
  "task": true
1732
- }
1732
+ },
1733
+ {
1734
+ "name": "getChangeRequestWorklogs",
1735
+ "summary": "Retrieve change request worklog entries",
1736
+ "description": "Retrieve change request worklog entries",
1737
+ "input": [
1738
+ {
1739
+ "name": "q",
1740
+ "type": "string",
1741
+ "info": "Used to filter worklog entries: string",
1742
+ "required": false,
1743
+ "schema": {
1744
+ "title": "q",
1745
+ "type": "string"
1746
+ }
1747
+ },
1748
+ {
1749
+ "name": "iapMetadata",
1750
+ "type": "object",
1751
+ "info": "IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.",
1752
+ "required": false,
1753
+ "schema": {
1754
+ "title": "iapMetadata",
1755
+ "type": "object"
1756
+ }
1757
+ }
1758
+ ],
1759
+ "output": {
1760
+ "name": "result",
1761
+ "type": "object",
1762
+ "description": "A JSON Object containing status, code and the result",
1763
+ "schema": {
1764
+ "title": "result",
1765
+ "type": "object"
1766
+ }
1767
+ },
1768
+ "roles": [
1769
+ "admin"
1770
+ ],
1771
+ "route": {
1772
+ "verb": "POST",
1773
+ "path": "/getChangeRequestWorklogs"
1774
+ },
1775
+ "task": true
1776
+ },
1777
+ {
1778
+ "name": "createChangeRequestWorklog",
1779
+ "summary": "createChangeRequestWorklog",
1780
+ "description": "createChangeRequestWorklog",
1781
+ "input": [
1782
+ {
1783
+ "name": "body",
1784
+ "type": "object",
1785
+ "info": "Request body: object",
1786
+ "required": true,
1787
+ "schema": {
1788
+ "title": "body",
1789
+ "type": "object"
1790
+ }
1791
+ },
1792
+ {
1793
+ "name": "iapMetadata",
1794
+ "type": "object",
1795
+ "info": "IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.",
1796
+ "required": false,
1797
+ "schema": {
1798
+ "title": "iapMetadata",
1799
+ "type": "object"
1800
+ }
1801
+ }
1802
+ ],
1803
+ "output": {
1804
+ "name": "result",
1805
+ "type": "object",
1806
+ "description": "A JSON Object containing status, code and the result",
1807
+ "schema": {
1808
+ "title": "result",
1809
+ "type": "object"
1810
+ }
1811
+ },
1812
+ "roles": [
1813
+ "admin"
1814
+ ],
1815
+ "route": {
1816
+ "verb": "POST",
1817
+ "path": "/createChangeRequestWorklog"
1818
+ },
1819
+ "task": true
1820
+ }
1733
1821
  ],
1734
1822
  "views": []
1735
1823
  }
Binary file
@@ -1,10 +1,10 @@
1
1
  {
2
- "version": "0.3.2",
3
- "configLines": 3591,
2
+ "version": "0.3.3",
3
+ "configLines": 3679,
4
4
  "scriptLines": 1783,
5
- "codeLines": 3664,
6
- "testLines": 3788,
7
- "testCases": 178,
8
- "totalCodeLines": 9235,
9
- "wfTasks": 43
5
+ "codeLines": 3865,
6
+ "testLines": 3880,
7
+ "testCases": 183,
8
+ "totalCodeLines": 9528,
9
+ "wfTasks": 45
10
10
  }
@@ -702,5 +702,56 @@ describe('[integration] Bmc_helix_itsm Adapter Test', () => {
702
702
  }
703
703
  }).timeout(attemptTimeout);
704
704
  });
705
+
706
+ describe('#getChangeRequestWorklogs - errors', () => {
707
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
708
+ try {
709
+ a.getChangeRequestWorklogs(null, null, (data, error) => {
710
+ try {
711
+ if (stub) {
712
+ const displayE = 'Error 400 received on request';
713
+ runErrorAsserts(data, error, 'AD.500', 'Test-bmc_helix_itsm-connectorRest-handleEndResponse', displayE);
714
+ } else {
715
+ runCommonAsserts(data, error);
716
+ }
717
+ saveMockData('ChangeRequest', 'getChangeRequestWorklogs', 'default', data);
718
+ done();
719
+ } catch (err) {
720
+ log.error(`Test Failure: ${err}`);
721
+ done(err);
722
+ }
723
+ });
724
+ } catch (error) {
725
+ log.error(`Adapter Exception: ${error}`);
726
+ done(error);
727
+ }
728
+ }).timeout(attemptTimeout);
729
+ });
730
+
731
+ const changeRequestcreateChangeRequestWorklogBodyParam = {};
732
+ describe('#createChangeRequestWorklog - errors', () => {
733
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
734
+ try {
735
+ a.createChangeRequestWorklog(changeRequestcreateChangeRequestWorklogBodyParam, null, (data, error) => {
736
+ try {
737
+ if (stub) {
738
+ const displayE = 'Error 400 received on request';
739
+ runErrorAsserts(data, error, 'AD.500', 'Test-bmc_helix_itsm-connectorRest-handleEndResponse', displayE);
740
+ } else {
741
+ runCommonAsserts(data, error);
742
+ }
743
+ saveMockData('ChangeRequest', 'createChangeRequestWorklog', 'default', data);
744
+ done();
745
+ } catch (err) {
746
+ log.error(`Test Failure: ${err}`);
747
+ done(err);
748
+ }
749
+ });
750
+ } catch (error) {
751
+ log.error(`Adapter Exception: ${error}`);
752
+ done(error);
753
+ }
754
+ }).timeout(attemptTimeout);
755
+ });
705
756
  });
706
757
  });
@@ -1848,5 +1848,46 @@ describe('[unit] Bmc_helix_itsm Adapter Test', () => {
1848
1848
  }
1849
1849
  }).timeout(attemptTimeout);
1850
1850
  });
1851
+
1852
+ describe('#getChangeRequestWorklogs - errors', () => {
1853
+ it('should have a getChangeRequestWorklogs function', (done) => {
1854
+ try {
1855
+ assert.equal(true, typeof a.getChangeRequestWorklogs === 'function');
1856
+ done();
1857
+ } catch (error) {
1858
+ log.error(`Test Failure: ${error}`);
1859
+ done(error);
1860
+ }
1861
+ }).timeout(attemptTimeout);
1862
+ });
1863
+
1864
+ describe('#createChangeRequestWorklog - errors', () => {
1865
+ it('should have a createChangeRequestWorklog function', (done) => {
1866
+ try {
1867
+ assert.equal(true, typeof a.createChangeRequestWorklog === 'function');
1868
+ done();
1869
+ } catch (error) {
1870
+ log.error(`Test Failure: ${error}`);
1871
+ done(error);
1872
+ }
1873
+ }).timeout(attemptTimeout);
1874
+ it('should error if - missing body', (done) => {
1875
+ try {
1876
+ a.createChangeRequestWorklog(null, null, (data, error) => {
1877
+ try {
1878
+ const displayE = 'body is required';
1879
+ runErrorAsserts(data, error, 'AD.300', 'Test-bmc_helix_itsm-adapter-createChangeRequestWorklog', displayE);
1880
+ done();
1881
+ } catch (err) {
1882
+ log.error(`Test Failure: ${err}`);
1883
+ done(err);
1884
+ }
1885
+ });
1886
+ } catch (error) {
1887
+ log.error(`Adapter Exception: ${error}`);
1888
+ done(error);
1889
+ }
1890
+ }).timeout(attemptTimeout);
1891
+ });
1851
1892
  });
1852
1893
  });