@itentialopensource/adapter-six_connect 0.7.1 → 0.8.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.
Files changed (42) hide show
  1. package/CALLS.md +1302 -0
  2. package/CHANGELOG.md +8 -0
  3. package/CONTRIBUTING.md +1 -160
  4. package/ENHANCE.md +2 -2
  5. package/README.md +32 -23
  6. package/adapter.js +157 -329
  7. package/adapterBase.js +549 -879
  8. package/changelogs/changelog.md +118 -0
  9. package/metadata.json +47 -0
  10. package/package.json +24 -25
  11. package/pronghorn.json +470 -138
  12. package/propertiesSchema.json +431 -31
  13. package/refs?service=git-upload-pack +0 -0
  14. package/report/adapter-openapi.json +9648 -0
  15. package/report/adapter-openapi.yaml +7749 -0
  16. package/report/adapterInfo.json +8 -8
  17. package/report/updateReport1691507699773.json +120 -0
  18. package/report/updateReport1692202699355.json +120 -0
  19. package/report/updateReport1694462737197.json +120 -0
  20. package/report/updateReport1698421248049.json +120 -0
  21. package/sampleProperties.json +63 -2
  22. package/test/integration/adapterTestBasicGet.js +2 -4
  23. package/test/integration/adapterTestConnectivity.js +91 -42
  24. package/test/integration/adapterTestIntegration.js +130 -2
  25. package/test/unit/adapterBaseTestUnit.js +388 -313
  26. package/test/unit/adapterTestUnit.js +338 -112
  27. package/utils/adapterInfo.js +1 -1
  28. package/utils/addAuth.js +1 -1
  29. package/utils/artifactize.js +1 -1
  30. package/utils/checkMigrate.js +1 -1
  31. package/utils/entitiesToDB.js +2 -2
  32. package/utils/findPath.js +1 -1
  33. package/utils/methodDocumentor.js +273 -0
  34. package/utils/modify.js +13 -15
  35. package/utils/packModificationScript.js +1 -1
  36. package/utils/pre-commit.sh +2 -0
  37. package/utils/taskMover.js +309 -0
  38. package/utils/tbScript.js +89 -34
  39. package/utils/tbUtils.js +41 -21
  40. package/utils/testRunner.js +1 -1
  41. package/utils/troubleshootingAdapter.js +9 -6
  42. package/workflows/README.md +0 -3
package/adapter.js CHANGED
@@ -88,9 +88,6 @@ class SixConnect extends AdapterBaseCl {
88
88
  let myIgnore = [
89
89
  'healthCheck',
90
90
  'iapGetAdapterWorkflowFunctions',
91
- 'iapHasAdapterEntity',
92
- 'iapVerifyAdapterCapability',
93
- 'iapUpdateAdapterEntityCache',
94
91
  'hasEntities',
95
92
  'getAuthorization'
96
93
  ];
@@ -118,29 +115,15 @@ class SixConnect extends AdapterBaseCl {
118
115
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
119
116
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
120
117
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
118
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
121
119
  * @param {Callback} callback - The results of the call
122
120
  */
123
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
121
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
124
122
  const meth = 'adapter-iapUpdateAdapterConfiguration';
125
123
  const origin = `${this.id}-${meth}`;
126
124
  log.trace(origin);
127
125
 
128
- super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
129
- }
130
-
131
- /**
132
- * See if the API path provided is found in this adapter
133
- *
134
- * @function iapFindAdapterPath
135
- * @param {string} apiPath - the api path to check on
136
- * @param {Callback} callback - The results of the call
137
- */
138
- iapFindAdapterPath(apiPath, callback) {
139
- const meth = 'adapter-iapFindAdapterPath';
140
- const origin = `${this.id}-${meth}`;
141
- log.trace(origin);
142
-
143
- super.iapFindAdapterPath(apiPath, callback);
126
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
144
127
  }
145
128
 
146
129
  /**
@@ -182,7 +165,7 @@ class SixConnect extends AdapterBaseCl {
182
165
  }
183
166
 
184
167
  /**
185
- * @summary Get the Adaoter Queue
168
+ * @summary Get the Adapter Queue
186
169
  *
187
170
  * @function iapGetAdapterQueue
188
171
  * @param {Callback} callback - callback function
@@ -195,6 +178,22 @@ class SixConnect extends AdapterBaseCl {
195
178
  return super.iapGetAdapterQueue(callback);
196
179
  }
197
180
 
181
+ /* SCRIPT CALLS */
182
+ /**
183
+ * See if the API path provided is found in this adapter
184
+ *
185
+ * @function iapFindAdapterPath
186
+ * @param {string} apiPath - the api path to check on
187
+ * @param {Callback} callback - The results of the call
188
+ */
189
+ iapFindAdapterPath(apiPath, callback) {
190
+ const meth = 'adapter-iapFindAdapterPath';
191
+ const origin = `${this.id}-${meth}`;
192
+ log.trace(origin);
193
+
194
+ super.iapFindAdapterPath(apiPath, callback);
195
+ }
196
+
198
197
  /**
199
198
  * @summary Runs troubleshoot scripts for adapter
200
199
  *
@@ -295,176 +294,93 @@ class SixConnect extends AdapterBaseCl {
295
294
  }
296
295
  }
297
296
 
298
- /* BROKER CALLS */
299
297
  /**
300
- * @summary Determines if this adapter supports the specific entity
298
+ * @summary Deactivate adapter tasks
301
299
  *
302
- * @function iapHasAdapterEntity
303
- * @param {String} entityType - the entity type to check for
304
- * @param {String/Array} entityId - the specific entity we are looking for
300
+ * @function iapDeactivateTasks
305
301
  *
306
- * @param {Callback} callback - An array of whether the adapter can has the
307
- * desired capability or an error
302
+ * @param {Array} tasks - List of tasks to deactivate
303
+ * @param {Callback} callback
308
304
  */
309
- iapHasAdapterEntity(entityType, entityId, callback) {
310
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
305
+ iapDeactivateTasks(tasks, callback) {
306
+ const meth = 'adapter-iapDeactivateTasks';
307
+ const origin = `${this.id}-${meth}`;
311
308
  log.trace(origin);
312
309
 
313
- // Make the call -
314
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
315
- return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
310
+ try {
311
+ return super.iapDeactivateTasks(tasks, callback);
312
+ } catch (err) {
313
+ log.error(`${origin}: ${err}`);
314
+ return callback(null, err);
315
+ }
316
316
  }
317
317
 
318
318
  /**
319
- * @summary Provides a way for the adapter to tell north bound integrations
320
- * whether the adapter supports type, action and specific entity
319
+ * @summary Activate adapter tasks that have previously been deactivated
321
320
  *
322
- * @function iapVerifyAdapterCapability
323
- * @param {String} entityType - the entity type to check for
324
- * @param {String} actionType - the action type to check for
325
- * @param {String/Array} entityId - the specific entity we are looking for
321
+ * @function iapActivateTasks
326
322
  *
327
- * @param {Callback} callback - An array of whether the adapter can has the
328
- * desired capability or an error
323
+ * @param {Array} tasks - List of tasks to activate
324
+ * @param {Callback} callback
329
325
  */
330
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
331
- const meth = 'adapterBase-iapVerifyAdapterCapability';
326
+ iapActivateTasks(tasks, callback) {
327
+ const meth = 'adapter-iapActivateTasks';
332
328
  const origin = `${this.id}-${meth}`;
333
329
  log.trace(origin);
334
330
 
335
- // if caching
336
- if (this.caching) {
337
- // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
338
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
339
- if (error) {
340
- return callback(null, error);
341
- }
342
-
343
- // if the cache needs to be updated, update and try again
344
- if (results && results[0] === 'needupdate') {
345
- switch (entityType) {
346
- case 'template_entity': {
347
- // if the cache is invalid, update the cache
348
- return this.getEntities(null, null, null, null, (data, err) => {
349
- if (err) {
350
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
351
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
352
- return callback(null, errorObj);
353
- }
354
-
355
- // need to check the cache again since it has been updated
356
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
357
- if (verror) {
358
- return callback(null, verror);
359
- }
360
-
361
- return this.capabilityResults(vcapable, callback);
362
- });
363
- });
364
- }
365
- default: {
366
- // unsupported entity type
367
- const result = [false];
368
-
369
- // put false in array for all entities
370
- if (Array.isArray(entityId)) {
371
- for (let e = 1; e < entityId.length; e += 1) {
372
- result.push(false);
373
- }
374
- }
375
-
376
- return callback(result);
377
- }
378
- }
379
- }
380
-
381
- // return the results
382
- return this.capabilityResults(results, callback);
383
- });
384
- }
385
-
386
- // if no entity id
387
- if (!entityId) {
388
- // need to check the cache again since it has been updated
389
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
390
- if (verror) {
391
- return callback(null, verror);
392
- }
393
-
394
- return this.capabilityResults(vcapable, callback);
395
- });
331
+ try {
332
+ return super.iapActivateTasks(tasks, callback);
333
+ } catch (err) {
334
+ log.error(`${origin}: ${err}`);
335
+ return callback(null, err);
396
336
  }
337
+ }
397
338
 
398
- // if not caching
399
- switch (entityType) {
400
- case 'template_entity': {
401
- // need to get the entities to check
402
- return this.getEntities(null, null, null, null, (data, err) => {
403
- if (err) {
404
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
405
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
406
- return callback(null, errorObj);
407
- }
408
-
409
- // need to check the cache again since it has been updated
410
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
411
- if (verror) {
412
- return callback(null, verror);
413
- }
414
-
415
- // is the entity in the list?
416
- const isEntity = this.entityInList(entityId, data.response, callback);
417
- const res = [];
418
-
419
- // not found
420
- for (let i = 0; i < isEntity.length; i += 1) {
421
- if (vcapable) {
422
- res.push(isEntity[i]);
423
- } else {
424
- res.push(false);
425
- }
426
- }
427
-
428
- return callback(res);
429
- });
430
- });
431
- }
432
- default: {
433
- // unsupported entity type
434
- const result = [false];
435
-
436
- // put false in array for all entities
437
- if (Array.isArray(entityId)) {
438
- for (let e = 1; e < entityId.length; e += 1) {
439
- result.push(false);
440
- }
441
- }
339
+ /* CACHE CALLS */
340
+ /**
341
+ * @summary Populate the cache for the given entities
342
+ *
343
+ * @function iapPopulateEntityCache
344
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
345
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
346
+ *
347
+ * @returns status of the populate
348
+ */
349
+ iapPopulateEntityCache(entityTypes, callback) {
350
+ const meth = 'adapter-iapPopulateEntityCache';
351
+ const origin = `${this.id}-${meth}`;
352
+ log.trace(origin);
442
353
 
443
- return callback(result);
444
- }
354
+ try {
355
+ return super.iapPopulateEntityCache(entityTypes, callback);
356
+ } catch (err) {
357
+ log.error(`${origin}: ${err}`);
358
+ return callback(null, err);
445
359
  }
446
360
  }
447
361
 
448
362
  /**
449
- * @summary Updates the cache for all entities by call the get All entity method
450
- *
451
- * @function iapUpdateAdapterEntityCache
363
+ * @summary Retrieves data from cache for specified entity type
452
364
  *
365
+ * @function iapRetrieveEntitiesCache
366
+ * @param {String} entityType - entity of which to retrieve
367
+ * @param {Object} options - settings of which data to return and how to return it
368
+ * @param {Callback} callback - the data if it was retrieved
453
369
  */
454
- iapUpdateAdapterEntityCache() {
455
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
370
+ iapRetrieveEntitiesCache(entityType, options, callback) {
371
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
372
+ const origin = `${this.id}-${meth}`;
456
373
  log.trace(origin);
457
374
 
458
- if (this.caching) {
459
- // if the cache is invalid, update the cache
460
- this.getEntities(null, null, null, null, (data, err) => {
461
- if (err) {
462
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
463
- }
464
- });
375
+ try {
376
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
377
+ } catch (err) {
378
+ log.error(`${origin}: ${err}`);
379
+ return callback(null, err);
465
380
  }
466
381
  }
467
382
 
383
+ /* BROKER CALLS */
468
384
  /**
469
385
  * @summary Determines if this adapter supports any in a list of entities
470
386
  *
@@ -599,6 +515,38 @@ class SixConnect extends AdapterBaseCl {
599
515
  }
600
516
 
601
517
  /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
518
+ /**
519
+ * Makes the requested generic call
520
+ *
521
+ * @function iapExpandedGenericAdapterRequest
522
+ * @param {Object} metadata - metadata for the call (optional).
523
+ * Can be a stringified Object.
524
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
525
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
526
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
527
+ * Can be a stringified Object.
528
+ * @param {Object} queryData - the parameters to be put on the url (optional).
529
+ * Can be a stringified Object.
530
+ * @param {Object} requestBody - the body to add to the request (optional).
531
+ * Can be a stringified Object.
532
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
533
+ * Can be a stringified Object.
534
+ * @param {getCallback} callback - a callback function to return the result (Generics)
535
+ * or the error
536
+ */
537
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
538
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
539
+ const origin = `${this.id}-${meth}`;
540
+ log.trace(origin);
541
+
542
+ try {
543
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
544
+ } catch (err) {
545
+ log.error(`${origin}: ${err}`);
546
+ return callback(null, err);
547
+ }
548
+ }
549
+
602
550
  /**
603
551
  * Makes the requested generic call
604
552
  *
@@ -619,93 +567,11 @@ class SixConnect extends AdapterBaseCl {
619
567
  const origin = `${this.id}-${meth}`;
620
568
  log.trace(origin);
621
569
 
622
- if (this.suspended && this.suspendMode === 'error') {
623
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
624
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
625
- return callback(null, errorObj);
626
- }
627
-
628
- /* HERE IS WHERE YOU VALIDATE DATA */
629
- if (uriPath === undefined || uriPath === null || uriPath === '') {
630
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
631
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
632
- return callback(null, errorObj);
633
- }
634
- if (restMethod === undefined || restMethod === null || restMethod === '') {
635
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
636
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
637
- return callback(null, errorObj);
638
- }
639
-
640
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
641
- // remove any leading / and split the uripath into path variables
642
- let myPath = uriPath;
643
- while (myPath.indexOf('/') === 0) {
644
- myPath = myPath.substring(1);
645
- }
646
- const pathVars = myPath.split('/');
647
- const queryParamsAvailable = queryData;
648
- const queryParams = {};
649
- const bodyVars = requestBody;
650
-
651
- // loop in template. long callback arg name to avoid identifier conflicts
652
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
653
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
654
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
655
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
656
- }
657
- });
658
-
659
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
660
- const reqObj = {
661
- payload: bodyVars,
662
- uriPathVars: pathVars,
663
- uriQuery: queryParams,
664
- uriOptions: {}
665
- };
666
- // add headers if provided
667
- if (addlHeaders) {
668
- reqObj.addlHeaders = addlHeaders;
669
- }
670
-
671
- // determine the call and return flag
672
- let action = 'getGenerics';
673
- let returnF = true;
674
- if (restMethod.toUpperCase() === 'POST') {
675
- action = 'createGeneric';
676
- } else if (restMethod.toUpperCase() === 'PUT') {
677
- action = 'updateGeneric';
678
- } else if (restMethod.toUpperCase() === 'PATCH') {
679
- action = 'patchGeneric';
680
- } else if (restMethod.toUpperCase() === 'DELETE') {
681
- action = 'deleteGeneric';
682
- returnF = false;
683
- }
684
-
685
570
  try {
686
- // Make the call -
687
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
688
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
689
- // if we received an error or their is no response on the results
690
- // return an error
691
- if (irReturnError) {
692
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
693
- return callback(null, irReturnError);
694
- }
695
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
696
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
697
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
698
- return callback(null, errorObj);
699
- }
700
-
701
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
702
- // return the response
703
- return callback(irReturnData, null);
704
- });
705
- } catch (ex) {
706
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
707
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
708
- return callback(null, errorObj);
571
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
572
+ } catch (err) {
573
+ log.error(`${origin}: ${err}`);
574
+ return callback(null, err);
709
575
  }
710
576
  }
711
577
 
@@ -729,94 +595,56 @@ class SixConnect extends AdapterBaseCl {
729
595
  const origin = `${this.id}-${meth}`;
730
596
  log.trace(origin);
731
597
 
732
- if (this.suspended && this.suspendMode === 'error') {
733
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
734
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
735
- return callback(null, errorObj);
736
- }
737
-
738
- /* HERE IS WHERE YOU VALIDATE DATA */
739
- if (uriPath === undefined || uriPath === null || uriPath === '') {
740
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
741
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
742
- return callback(null, errorObj);
743
- }
744
- if (restMethod === undefined || restMethod === null || restMethod === '') {
745
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
746
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
747
- return callback(null, errorObj);
598
+ try {
599
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
600
+ } catch (err) {
601
+ log.error(`${origin}: ${err}`);
602
+ return callback(null, err);
748
603
  }
604
+ }
749
605
 
750
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
751
- // remove any leading / and split the uripath into path variables
752
- let myPath = uriPath;
753
- while (myPath.indexOf('/') === 0) {
754
- myPath = myPath.substring(1);
755
- }
756
- const pathVars = myPath.split('/');
757
- const queryParamsAvailable = queryData;
758
- const queryParams = {};
759
- const bodyVars = requestBody;
606
+ /* INVENTORY CALLS */
607
+ /**
608
+ * @summary run the adapter lint script to return the results.
609
+ *
610
+ * @function iapRunAdapterLint
611
+ * @param {Callback} callback - callback function
612
+ */
613
+ iapRunAdapterLint(callback) {
614
+ const meth = 'adapter-iapRunAdapterLint';
615
+ const origin = `${this.id}-${meth}`;
616
+ log.trace(origin);
760
617
 
761
- // loop in template. long callback arg name to avoid identifier conflicts
762
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
763
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
764
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
765
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
766
- }
767
- });
618
+ return super.iapRunAdapterLint(callback);
619
+ }
768
620
 
769
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
770
- const reqObj = {
771
- payload: bodyVars,
772
- uriPathVars: pathVars,
773
- uriQuery: queryParams,
774
- uriOptions: {}
775
- };
776
- // add headers if provided
777
- if (addlHeaders) {
778
- reqObj.addlHeaders = addlHeaders;
779
- }
621
+ /**
622
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
623
+ * can not run integration as there can be implications with that.
624
+ *
625
+ * @function iapRunAdapterTests
626
+ * @param {Callback} callback - callback function
627
+ */
628
+ iapRunAdapterTests(callback) {
629
+ const meth = 'adapter-iapRunAdapterTests';
630
+ const origin = `${this.id}-${meth}`;
631
+ log.trace(origin);
780
632
 
781
- // determine the call and return flag
782
- let action = 'getGenericsNoBase';
783
- let returnF = true;
784
- if (restMethod.toUpperCase() === 'POST') {
785
- action = 'createGenericNoBase';
786
- } else if (restMethod.toUpperCase() === 'PUT') {
787
- action = 'updateGenericNoBase';
788
- } else if (restMethod.toUpperCase() === 'PATCH') {
789
- action = 'patchGenericNoBase';
790
- } else if (restMethod.toUpperCase() === 'DELETE') {
791
- action = 'deleteGenericNoBase';
792
- returnF = false;
793
- }
633
+ return super.iapRunAdapterTests(callback);
634
+ }
794
635
 
795
- try {
796
- // Make the call -
797
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
798
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
799
- // if we received an error or their is no response on the results
800
- // return an error
801
- if (irReturnError) {
802
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
803
- return callback(null, irReturnError);
804
- }
805
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
806
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
807
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
808
- return callback(null, errorObj);
809
- }
636
+ /**
637
+ * @summary provide inventory information abbout the adapter
638
+ *
639
+ * @function iapGetAdapterInventory
640
+ * @param {Callback} callback - callback function
641
+ */
642
+ iapGetAdapterInventory(callback) {
643
+ const meth = 'adapter-iapGetAdapterInventory';
644
+ const origin = `${this.id}-${meth}`;
645
+ log.trace(origin);
810
646
 
811
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
812
- // return the response
813
- return callback(irReturnData, null);
814
- });
815
- } catch (ex) {
816
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
817
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
818
- return callback(null, errorObj);
819
- }
647
+ return super.iapGetAdapterInventory(callback);
820
648
  }
821
649
 
822
650
  /**