@itentialopensource/adapter-utils 4.48.16 → 4.49.0

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/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
1
 
2
+ ## 4.49.0 [05-15-2023]
3
+
4
+ * Resolve ADAPT-2362 - Adapter Inventory from Utils Perspective (still more in AdapterBase)
5
+
6
+ Closes ADAPT-2362
7
+
8
+ See merge request itentialopensource/adapter-utils!257
9
+
10
+ ---
11
+
2
12
  ## 4.48.16 [05-10-2023]
3
13
 
4
14
  * Fix issue of instantiating AJV, also mock data fix for generic call
@@ -1175,6 +1175,103 @@ class RequestHandler {
1175
1175
  return callback(null, errorObj);
1176
1176
  }
1177
1177
  }
1178
+
1179
+ /**
1180
+ * @summary provide inventory information abbout the adapter
1181
+ *
1182
+ * @function getAdapterInventory
1183
+ *
1184
+ * @return {Object} - containing the adapter inventory information
1185
+ */
1186
+ getAdapterInventory(callback) {
1187
+ const origin = `${this.myid}-requestHandler-getAdapterInventory`;
1188
+ log.trace(origin);
1189
+
1190
+ try {
1191
+ const adapterInv = {
1192
+ issues: {}
1193
+ };
1194
+
1195
+ // are the utils within the adapter
1196
+ if (__dirname.indexOf(this.directory) === 0) {
1197
+ adapterInv.issues.embedUtils = true;
1198
+ } else {
1199
+ adapterInv.issues.embedUtils = false;
1200
+ }
1201
+
1202
+ // get the adapter package.json
1203
+ if (fs.existsSync(path.join(this.directory, 'package.json'))) {
1204
+ const adaptPackage = require(path.join(this.directory, 'package.json'));
1205
+
1206
+ // Namespace - package & directory
1207
+ const [tempNS, tempName] = adaptPackage.name.split('/');
1208
+ adapterInv.namespace = tempNS;
1209
+ if (this.directory.indexOf(adapterInv.namespace) > 0) {
1210
+ adapterInv.issues.inNamespace = true;
1211
+ } else {
1212
+ adapterInv.issues.inNamespace = false;
1213
+ }
1214
+
1215
+ // Name - package & directory
1216
+ adapterInv.name = tempName;
1217
+ if (this.directory.indexOf(adapterInv.name) > 0) {
1218
+ adapterInv.issues.inName = true;
1219
+ } else {
1220
+ adapterInv.issues.inName = false;
1221
+ }
1222
+
1223
+ // Version - package
1224
+ adapterInv.version = adaptPackage.version;
1225
+ } else {
1226
+ adapterInv.namespace = 'TBD';
1227
+ adapterInv.issues.inNamespace = false;
1228
+ adapterInv.name = 'TBD';
1229
+ adapterInv.issues.inName = false;
1230
+ adapterInv.version = 'TBD';
1231
+ }
1232
+
1233
+ // get the adapter pronghorn.json
1234
+ adapterInv.brokerDefined = false;
1235
+ adapterInv.cacheDefined = false;
1236
+ if (fs.existsSync(path.join(this.directory, 'pronghorn.json'))) {
1237
+ const adaptPronghorn = require(path.join(this.directory, 'pronghorn.json'));
1238
+
1239
+ // Active WF Tasks - pronghorn.json
1240
+ let wfCount = 0;
1241
+ for (let i = 0; i < adaptPronghorn.methods.length; i += 1) {
1242
+ if (adaptPronghorn.methods[i].task === true) {
1243
+ wfCount += 1;
1244
+ }
1245
+ if (adaptPronghorn.methods[i].name === 'getDevicesFiltered') {
1246
+ adapterInv.brokerDefined = true;
1247
+ }
1248
+ if (adaptPronghorn.methods[i].name === 'iapUpdateAdapterCache') {
1249
+ adapterInv.cacheDefined = true;
1250
+ }
1251
+ }
1252
+ adapterInv.activeWFTasks = wfCount;
1253
+ } else {
1254
+ adapterInv.activeWFTasks = -1;
1255
+ }
1256
+
1257
+ // get the utils package.json
1258
+ if (fs.existsSync('../package.json')) {
1259
+ const utilsPackage = require('../package.json');
1260
+
1261
+ // Version of adapter-utils - utils package
1262
+ adapterInv.utilVersion = utilsPackage.version;
1263
+ } else {
1264
+ adapterInv.utilVersion = 'TBD';
1265
+ }
1266
+
1267
+ // return the results
1268
+ return callback(adapterInv);
1269
+ } catch (e) {
1270
+ // handle any exception
1271
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Issue getting Inventory information');
1272
+ return callback(null, errorObj);
1273
+ }
1274
+ }
1178
1275
  }
1179
1276
 
1180
1277
  module.exports = RequestHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "4.48.16",
3
+ "version": "4.49.0",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",