@itentialopensource/adapter-robustel 0.4.5 → 0.5.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/.eslintrc.js +1 -0
- package/AUTH.md +4 -4
- package/BROKER.md +4 -4
- package/CALLS.md +9 -9
- package/ENHANCE.md +3 -3
- package/PROPERTIES.md +24 -9
- package/README.md +24 -23
- package/SUMMARY.md +2 -2
- package/SYSTEMINFO.md +1 -1
- package/TAB1.md +2 -2
- package/TAB2.md +9 -5
- package/TROUBLESHOOT.md +10 -1
- package/UTILITIES.md +473 -0
- package/adapter.js +27 -179
- package/adapterBase.js +52 -16
- package/package.json +25 -29
- package/pronghorn.json +17 -15
- package/propertiesSchema.json +68 -7
- package/report/adapterInfo.json +7 -7
- package/report/auto-adapter-openapi.json +248 -0
- package/report/updateReport1748555069445.json +120 -0
- package/sampleProperties.json +4 -0
- package/test/integration/adapterTestBasicGet.js +88 -54
- package/test/integration/adapterTestConnectivity.js +15 -16
- package/test/integration/adapterTestIntegration.js +1 -38
- package/test/unit/adapterBaseTestUnit.js +641 -39
- package/test/unit/adapterTestUnit.js +17 -54
- package/utils/adapterInfo.js +114 -164
- package/utils/argParser.js +44 -0
- package/utils/checkMigrate.js +77 -38
- package/utils/entitiesToDB.js +53 -42
- package/utils/logger.js +26 -0
- package/utils/modify.js +56 -55
- package/utils/mongoDbConnection.js +79 -0
- package/utils/mongoUtils.js +162 -0
- package/utils/taskMover.js +31 -32
- package/utils/tbScript.js +36 -172
- package/utils/tbUtils.js +84 -226
- package/utils/troubleshootingAdapter.js +68 -84
- package/utils/updateAdapterConfig.js +158 -0
- package/utils/addAuth.js +0 -94
- package/utils/artifactize.js +0 -146
- package/utils/basicGet.js +0 -50
- package/utils/packModificationScript.js +0 -35
- package/utils/patches2bundledDeps.js +0 -90
package/adapter.js
CHANGED
|
@@ -200,16 +200,15 @@ class Robustel extends AdapterBaseCl {
|
|
|
200
200
|
* @function iapTroubleshootAdapter
|
|
201
201
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
202
202
|
*
|
|
203
|
-
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
204
203
|
* @param {Callback} callback - The results of the call
|
|
205
204
|
*/
|
|
206
|
-
iapTroubleshootAdapter(props,
|
|
205
|
+
iapTroubleshootAdapter(props, callback) {
|
|
207
206
|
const meth = 'adapter-iapTroubleshootAdapter';
|
|
208
207
|
const origin = `${this.id}-${meth}`;
|
|
209
208
|
log.trace(origin);
|
|
210
209
|
|
|
211
210
|
try {
|
|
212
|
-
return super.iapTroubleshootAdapter(props,
|
|
211
|
+
return super.iapTroubleshootAdapter(props, this, callback);
|
|
213
212
|
} catch (error) {
|
|
214
213
|
log.error(`${origin}: ${error}`);
|
|
215
214
|
return callback(null, error);
|
|
@@ -259,15 +258,16 @@ class Robustel extends AdapterBaseCl {
|
|
|
259
258
|
* @summary runs basicGet script for adapter
|
|
260
259
|
*
|
|
261
260
|
* @function iapRunAdapterBasicGet
|
|
261
|
+
* @param {number} maxCalls - how many GET endpoints to test (optional)
|
|
262
262
|
* @param {Callback} callback - callback function
|
|
263
263
|
*/
|
|
264
|
-
iapRunAdapterBasicGet(callback) {
|
|
264
|
+
iapRunAdapterBasicGet(maxCalls, callback) {
|
|
265
265
|
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
266
266
|
const origin = `${this.id}-${meth}`;
|
|
267
267
|
log.trace(origin);
|
|
268
268
|
|
|
269
269
|
try {
|
|
270
|
-
return super.iapRunAdapterBasicGet(callback);
|
|
270
|
+
return super.iapRunAdapterBasicGet(maxCalls, callback);
|
|
271
271
|
} catch (error) {
|
|
272
272
|
log.error(`${origin}: ${error}`);
|
|
273
273
|
return callback(null, error);
|
|
@@ -567,48 +567,11 @@ class Robustel extends AdapterBaseCl {
|
|
|
567
567
|
const origin = `${this.id}-${meth}`;
|
|
568
568
|
log.trace(origin);
|
|
569
569
|
|
|
570
|
-
if (this.suspended && this.suspendMode === 'error') {
|
|
571
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
572
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
573
|
-
return callback(null, errorObj);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
577
|
-
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
578
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
579
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
580
|
-
return callback(null, errorObj);
|
|
581
|
-
}
|
|
582
|
-
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
583
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
584
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
585
|
-
return callback(null, errorObj);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
589
|
-
// remove any leading / and split the uripath into path variables
|
|
590
|
-
let myPath = uriPath;
|
|
591
|
-
while (myPath.indexOf('/') === 0) {
|
|
592
|
-
myPath = myPath.substring(1);
|
|
593
|
-
}
|
|
594
|
-
const pathVars = myPath.split('/');
|
|
595
|
-
const queryParamsAvailable = queryData;
|
|
596
|
-
const queryParams = {};
|
|
597
|
-
const bodyVars = requestBody;
|
|
598
|
-
|
|
599
|
-
// loop in template. long callback arg name to avoid identifier conflicts
|
|
600
|
-
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
601
|
-
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
602
|
-
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
603
|
-
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
|
|
607
570
|
let usePath = uriPath;
|
|
608
|
-
if (
|
|
609
|
-
usePath = `${uriPath}?${querystring(queryData)}`;
|
|
571
|
+
if (queryData && Object.keys(queryData).length > 0) {
|
|
572
|
+
usePath = `${uriPath}?${querystring.stringify(queryData)}`;
|
|
610
573
|
}
|
|
611
|
-
const callSign = this.getAuthorization(restMethod, usePath,
|
|
574
|
+
const callSign = this.getAuthorization(restMethod, usePath, requestBody);
|
|
612
575
|
|
|
613
576
|
// if the callAuth was unsuccessful
|
|
614
577
|
if (callSign === -1) {
|
|
@@ -617,57 +580,18 @@ class Robustel extends AdapterBaseCl {
|
|
|
617
580
|
return callback(null, errorObj);
|
|
618
581
|
}
|
|
619
582
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
uriPathVars: pathVars,
|
|
624
|
-
uriQuery: queryParams,
|
|
625
|
-
uriOptions: {},
|
|
626
|
-
addlHeaders: callSign
|
|
627
|
-
};
|
|
628
|
-
// add headers if provided
|
|
629
|
-
if (addlHeaders) {
|
|
630
|
-
reqObj.addlHeaders = addlHeaders;
|
|
583
|
+
if (addlHeaders === undefined || addlHeaders === null || addlHeaders === '') {
|
|
584
|
+
// eslint-disable-next-line no-param-reassign
|
|
585
|
+
addlHeaders = {};
|
|
631
586
|
}
|
|
632
587
|
|
|
633
|
-
|
|
634
|
-
let action = 'getGenerics';
|
|
635
|
-
let returnF = true;
|
|
636
|
-
if (restMethod.toUpperCase() === 'POST') {
|
|
637
|
-
action = 'createGeneric';
|
|
638
|
-
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
639
|
-
action = 'updateGeneric';
|
|
640
|
-
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
641
|
-
action = 'patchGeneric';
|
|
642
|
-
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
643
|
-
action = 'deleteGeneric';
|
|
644
|
-
returnF = false;
|
|
645
|
-
}
|
|
588
|
+
Object.assign(addlHeaders, callSign);
|
|
646
589
|
|
|
647
590
|
try {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
// return an error
|
|
653
|
-
if (irReturnError) {
|
|
654
|
-
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
655
|
-
return callback(null, irReturnError);
|
|
656
|
-
}
|
|
657
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
658
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
659
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
660
|
-
return callback(null, errorObj);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
664
|
-
// return the response
|
|
665
|
-
return callback(irReturnData, null);
|
|
666
|
-
});
|
|
667
|
-
} catch (ex) {
|
|
668
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
669
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
670
|
-
return callback(null, errorObj);
|
|
591
|
+
return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
592
|
+
} catch (err) {
|
|
593
|
+
log.error(`${origin}: ${err}`);
|
|
594
|
+
return callback(null, err);
|
|
671
595
|
}
|
|
672
596
|
}
|
|
673
597
|
|
|
@@ -691,48 +615,11 @@ class Robustel extends AdapterBaseCl {
|
|
|
691
615
|
const origin = `${this.id}-${meth}`;
|
|
692
616
|
log.trace(origin);
|
|
693
617
|
|
|
694
|
-
if (this.suspended && this.suspendMode === 'error') {
|
|
695
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
696
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
697
|
-
return callback(null, errorObj);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
701
|
-
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
702
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
703
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
704
|
-
return callback(null, errorObj);
|
|
705
|
-
}
|
|
706
|
-
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
707
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
708
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
709
|
-
return callback(null, errorObj);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
713
|
-
// remove any leading / and split the uripath into path variables
|
|
714
|
-
let myPath = uriPath;
|
|
715
|
-
while (myPath.indexOf('/') === 0) {
|
|
716
|
-
myPath = myPath.substring(1);
|
|
717
|
-
}
|
|
718
|
-
const pathVars = myPath.split('/');
|
|
719
|
-
const queryParamsAvailable = queryData;
|
|
720
|
-
const queryParams = {};
|
|
721
|
-
const bodyVars = requestBody;
|
|
722
|
-
|
|
723
|
-
// loop in template. long callback arg name to avoid identifier conflicts
|
|
724
|
-
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
725
|
-
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
726
|
-
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
727
|
-
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
|
|
731
618
|
let usePath = uriPath;
|
|
732
|
-
if (
|
|
733
|
-
usePath = `${uriPath}?${querystring(queryData)}`;
|
|
619
|
+
if (queryData && Object.keys(queryData).length > 0) {
|
|
620
|
+
usePath = `${uriPath}?${querystring.stringify(queryData)}`;
|
|
734
621
|
}
|
|
735
|
-
const callSign = this.getAuthorization(restMethod, usePath,
|
|
622
|
+
const callSign = this.getAuthorization(restMethod, usePath, requestBody);
|
|
736
623
|
|
|
737
624
|
// if the callAuth was unsuccessful
|
|
738
625
|
if (callSign === -1) {
|
|
@@ -741,57 +628,18 @@ class Robustel extends AdapterBaseCl {
|
|
|
741
628
|
return callback(null, errorObj);
|
|
742
629
|
}
|
|
743
630
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
uriPathVars: pathVars,
|
|
748
|
-
uriQuery: queryParams,
|
|
749
|
-
uriOptions: {},
|
|
750
|
-
addlHeaders: callSign
|
|
751
|
-
};
|
|
752
|
-
// add headers if provided
|
|
753
|
-
if (addlHeaders) {
|
|
754
|
-
reqObj.addlHeaders = addlHeaders;
|
|
631
|
+
if (addlHeaders === undefined || addlHeaders === null || addlHeaders === '') {
|
|
632
|
+
// eslint-disable-next-line no-param-reassign
|
|
633
|
+
addlHeaders = {};
|
|
755
634
|
}
|
|
756
635
|
|
|
757
|
-
|
|
758
|
-
let action = 'getGenericsNoBase';
|
|
759
|
-
let returnF = true;
|
|
760
|
-
if (restMethod.toUpperCase() === 'POST') {
|
|
761
|
-
action = 'createGenericNoBase';
|
|
762
|
-
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
763
|
-
action = 'updateGenericNoBase';
|
|
764
|
-
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
765
|
-
action = 'patchGenericNoBase';
|
|
766
|
-
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
767
|
-
action = 'deleteGenericNoBase';
|
|
768
|
-
returnF = false;
|
|
769
|
-
}
|
|
636
|
+
Object.assign(addlHeaders, callSign);
|
|
770
637
|
|
|
771
638
|
try {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
// return an error
|
|
777
|
-
if (irReturnError) {
|
|
778
|
-
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
779
|
-
return callback(null, irReturnError);
|
|
780
|
-
}
|
|
781
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
782
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
|
783
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
784
|
-
return callback(null, errorObj);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
788
|
-
// return the response
|
|
789
|
-
return callback(irReturnData, null);
|
|
790
|
-
});
|
|
791
|
-
} catch (ex) {
|
|
792
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
793
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
794
|
-
return callback(null, errorObj);
|
|
639
|
+
return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
640
|
+
} catch (err) {
|
|
641
|
+
log.error(`${origin}: ${err}`);
|
|
642
|
+
return callback(null, err);
|
|
795
643
|
}
|
|
796
644
|
}
|
|
797
645
|
|
package/adapterBase.js
CHANGED
|
@@ -32,6 +32,7 @@ const entitiesToDB = require(path.join(__dirname, 'utils/entitiesToDB'));
|
|
|
32
32
|
const troubleshootingAdapter = require(path.join(__dirname, 'utils/troubleshootingAdapter'));
|
|
33
33
|
const tbUtils = require(path.join(__dirname, 'utils/tbUtils'));
|
|
34
34
|
const taskMover = require(path.join(__dirname, 'utils/taskMover'));
|
|
35
|
+
const { updateMongoDBConfig } = require(path.join(__dirname, 'utils/updateAdapterConfig'));
|
|
35
36
|
|
|
36
37
|
let propUtil = null;
|
|
37
38
|
let choosepath = null;
|
|
@@ -366,7 +367,6 @@ class AdapterBase extends EventEmitterCl {
|
|
|
366
367
|
// if we were healthy, toggle health
|
|
367
368
|
if (this.healthy) {
|
|
368
369
|
this.emit('OFFLINE', { id: this.id });
|
|
369
|
-
this.emit('DEGRADED', { id: this.id });
|
|
370
370
|
this.healthy = false;
|
|
371
371
|
if (typeof error === 'object') {
|
|
372
372
|
log.error(`${origin}: HEALTH CHECK - Error ${JSON.stringify(error)}`);
|
|
@@ -385,7 +385,6 @@ class AdapterBase extends EventEmitterCl {
|
|
|
385
385
|
|
|
386
386
|
// if we were unhealthy, toggle health
|
|
387
387
|
if (!this.healthy) {
|
|
388
|
-
this.emit('FIXED', { id: this.id });
|
|
389
388
|
this.emit('ONLINE', { id: this.id });
|
|
390
389
|
this.healthy = true;
|
|
391
390
|
log.info(`${origin}: HEALTH CHECK SUCCESSFUL`);
|
|
@@ -583,21 +582,32 @@ class AdapterBase extends EventEmitterCl {
|
|
|
583
582
|
|
|
584
583
|
// take action based on type of file being changed
|
|
585
584
|
if (type === 'action') {
|
|
586
|
-
// BACKUP???
|
|
587
585
|
const ares = updateAction(epath, action, changes);
|
|
588
586
|
if (ares) {
|
|
589
587
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${ares}`, [], null, null, null);
|
|
590
588
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
591
589
|
return callback(null, errorObj);
|
|
592
590
|
}
|
|
593
|
-
//
|
|
594
|
-
|
|
591
|
+
// Update MongoDB if possible
|
|
592
|
+
updateMongoDBConfig({
|
|
593
|
+
id: this.id,
|
|
594
|
+
mongoProps: this.allProps.mongo,
|
|
595
|
+
entity,
|
|
596
|
+
type,
|
|
597
|
+
configFile,
|
|
598
|
+
changes,
|
|
599
|
+
action,
|
|
600
|
+
replace
|
|
601
|
+
}).catch((error) => {
|
|
602
|
+
log.error(`${origin}: Error updating MongoDB configuration: ${error.message}`);
|
|
603
|
+
});
|
|
595
604
|
const result = {
|
|
596
605
|
response: `Action updates completed to entity: ${entity} - ${action}`
|
|
597
606
|
};
|
|
598
607
|
log.info(result.response);
|
|
599
608
|
return callback(result, null);
|
|
600
609
|
}
|
|
610
|
+
|
|
601
611
|
if (type === 'schema') {
|
|
602
612
|
const sres = updateSchema(epath, configFile, changes);
|
|
603
613
|
if (sres) {
|
|
@@ -605,12 +615,26 @@ class AdapterBase extends EventEmitterCl {
|
|
|
605
615
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
606
616
|
return callback(null, errorObj);
|
|
607
617
|
}
|
|
618
|
+
// Update MongoDB if possible
|
|
619
|
+
updateMongoDBConfig({
|
|
620
|
+
id: this.id,
|
|
621
|
+
mongoProps: this.allProps.mongo,
|
|
622
|
+
entity,
|
|
623
|
+
type,
|
|
624
|
+
configFile,
|
|
625
|
+
changes,
|
|
626
|
+
action,
|
|
627
|
+
replace
|
|
628
|
+
}).catch((error) => {
|
|
629
|
+
log.error(`${origin}: Error updating MongoDB configuration: ${error.message}`);
|
|
630
|
+
});
|
|
608
631
|
const result = {
|
|
609
632
|
response: `Schema updates completed to entity: ${entity} - ${configFile}`
|
|
610
633
|
};
|
|
611
634
|
log.info(result.response);
|
|
612
635
|
return callback(result, null);
|
|
613
636
|
}
|
|
637
|
+
|
|
614
638
|
if (type === 'mock') {
|
|
615
639
|
// if the mock directory does not exist - error
|
|
616
640
|
const mpath = `${__dirname}/entities/${entity}/mockdatafiles`;
|
|
@@ -624,18 +648,31 @@ class AdapterBase extends EventEmitterCl {
|
|
|
624
648
|
return callback(null, errorObj);
|
|
625
649
|
}
|
|
626
650
|
const mres = updateMock(mpath, configFile, changes, replace);
|
|
627
|
-
|
|
628
651
|
if (mres) {
|
|
629
652
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${mres}`, [], null, null, null);
|
|
630
653
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
631
654
|
return callback(null, errorObj);
|
|
632
655
|
}
|
|
656
|
+
// Update MongoDB if possible
|
|
657
|
+
updateMongoDBConfig({
|
|
658
|
+
id: this.id,
|
|
659
|
+
mongoProps: this.allProps.mongo,
|
|
660
|
+
entity,
|
|
661
|
+
type,
|
|
662
|
+
configFile,
|
|
663
|
+
changes,
|
|
664
|
+
action,
|
|
665
|
+
replace
|
|
666
|
+
}).catch((error) => {
|
|
667
|
+
log.error(`${origin}: Error updating MongoDB configuration: ${error.message}`);
|
|
668
|
+
});
|
|
633
669
|
const result = {
|
|
634
670
|
response: `Mock data updates completed to entity: ${entity} - ${configFile}`
|
|
635
671
|
};
|
|
636
672
|
log.info(result.response);
|
|
637
673
|
return callback(result, null);
|
|
638
674
|
}
|
|
675
|
+
|
|
639
676
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: Unsupported Type - ${type}`, [], null, null, null);
|
|
640
677
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
641
678
|
return callback(null, errorObj);
|
|
@@ -831,14 +868,13 @@ class AdapterBase extends EventEmitterCl {
|
|
|
831
868
|
*
|
|
832
869
|
* @function iapTroubleshootAdapter
|
|
833
870
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
834
|
-
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
835
871
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
836
872
|
* @param {Callback} callback - callback function to return troubleshoot results
|
|
837
873
|
*/
|
|
838
|
-
async iapTroubleshootAdapter(props,
|
|
874
|
+
async iapTroubleshootAdapter(props, adapter, callback) {
|
|
839
875
|
try {
|
|
840
|
-
const result = await troubleshootingAdapter.troubleshoot(props, false,
|
|
841
|
-
if (result.healthCheck && result.connectivity.failCount === 0 && result.basicGet.
|
|
876
|
+
const result = await troubleshootingAdapter.troubleshoot(props, false, adapter);
|
|
877
|
+
if (result.healthCheck && result.connectivity.failCount === 0 && result.basicGet.passCount !== 0) {
|
|
842
878
|
return callback(result);
|
|
843
879
|
}
|
|
844
880
|
return callback(null, result);
|
|
@@ -875,8 +911,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
875
911
|
*/
|
|
876
912
|
async iapRunAdapterConnectivity(callback) {
|
|
877
913
|
try {
|
|
878
|
-
const
|
|
879
|
-
const result = tbUtils.runConnectivity(host, false);
|
|
914
|
+
const result = tbUtils.runConnectivity(this.allProps.host, false);
|
|
880
915
|
if (result.failCount > 0) {
|
|
881
916
|
return callback(null, result);
|
|
882
917
|
}
|
|
@@ -890,12 +925,13 @@ class AdapterBase extends EventEmitterCl {
|
|
|
890
925
|
* @summary runs basicGet script for adapter
|
|
891
926
|
*
|
|
892
927
|
* @function iapRunAdapterBasicGet
|
|
928
|
+
* @param {number} maxCalls - how many GETs to run (optional)
|
|
893
929
|
* @param {Callback} callback - callback function to return basicGet result
|
|
894
930
|
*/
|
|
895
|
-
iapRunAdapterBasicGet(callback) {
|
|
931
|
+
iapRunAdapterBasicGet(maxCalls, callback) {
|
|
896
932
|
try {
|
|
897
|
-
const result = tbUtils.runBasicGet(false);
|
|
898
|
-
if (result.
|
|
933
|
+
const result = tbUtils.runBasicGet(this.allProps, false, maxCalls);
|
|
934
|
+
if (result.passCount === 0) {
|
|
899
935
|
return callback(null, result);
|
|
900
936
|
}
|
|
901
937
|
return callback(result);
|
|
@@ -917,7 +953,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
917
953
|
log.trace(origin);
|
|
918
954
|
|
|
919
955
|
try {
|
|
920
|
-
const result = await entitiesToDB.moveEntitiesToDB(__dirname, { pronghornProps: this.allProps, id: this.id });
|
|
956
|
+
const result = await entitiesToDB.moveEntitiesToDB(__dirname, { pronghornProps: { mongo: this.allProps && this.allProps.mongo }, id: this.id });
|
|
921
957
|
return callback(result, null);
|
|
922
958
|
} catch (err) {
|
|
923
959
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, err);
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itentialopensource/adapter-robustel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "This adapter integrates with system described as: robustel.",
|
|
5
5
|
"main": "adapter.js",
|
|
6
6
|
"wizardVersion": "2.44.7",
|
|
7
|
-
"engineVersion": "1.
|
|
7
|
+
"engineVersion": "1.69.14",
|
|
8
8
|
"adapterType": "http",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"artifactize": "npm i && node utils/packModificationScript.js",
|
|
11
10
|
"preinstall": "node utils/setup.js",
|
|
12
11
|
"deinstall": "node utils/removeHooks.js",
|
|
13
12
|
"lint": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js",
|
|
@@ -17,7 +16,6 @@
|
|
|
17
16
|
"test:integration": "mocha test/integration/adapterTestIntegration.js --LOG=error",
|
|
18
17
|
"adapter:patches2bundled": "node utils/patches2bundledDeps.js",
|
|
19
18
|
"test": "npm run test:baseunit && npm run test:unit && npm run test:integration",
|
|
20
|
-
"adapter:install": "npm i && node utils/tbScript.js install",
|
|
21
19
|
"adapter:checkMigrate": "node utils/checkMigrate.js",
|
|
22
20
|
"adapter:findPath": "node utils/findPath.js",
|
|
23
21
|
"adapter:migrate": "node utils/modify.js -m",
|
|
@@ -32,10 +30,9 @@
|
|
|
32
30
|
},
|
|
33
31
|
"keywords": [
|
|
34
32
|
"Itential",
|
|
35
|
-
"
|
|
33
|
+
"Itential Platform",
|
|
36
34
|
"Automation",
|
|
37
35
|
"Integration",
|
|
38
|
-
"App-Artifacts",
|
|
39
36
|
"Adapter",
|
|
40
37
|
"robustel",
|
|
41
38
|
"Pre-Release"
|
|
@@ -52,31 +49,30 @@
|
|
|
52
49
|
"author": "Itential",
|
|
53
50
|
"homepage": "https://gitlab.com/itentialopensource/adapters/adapter-robustel#readme",
|
|
54
51
|
"dependencies": {
|
|
55
|
-
"@itentialopensource/adapter-utils": "
|
|
56
|
-
"acorn": "
|
|
57
|
-
"ajv": "
|
|
58
|
-
"axios": "
|
|
59
|
-
"commander": "
|
|
60
|
-
"crypto-js": "
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"mocha": "
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"winston": "^3.17.0"
|
|
52
|
+
"@itentialopensource/adapter-utils": "5.10.16",
|
|
53
|
+
"acorn": "8.14.1",
|
|
54
|
+
"ajv": "8.17.1",
|
|
55
|
+
"axios": "1.9.0",
|
|
56
|
+
"commander": "11.1.0",
|
|
57
|
+
"crypto-js": "4.2.0",
|
|
58
|
+
"fs-extra": "11.3.0",
|
|
59
|
+
"json-query": "2.2.2",
|
|
60
|
+
"mocha": "10.8.2",
|
|
61
|
+
"mocha-param": "2.0.1",
|
|
62
|
+
"mongodb": "4.17.2",
|
|
63
|
+
"ping": "0.4.4",
|
|
64
|
+
"prompts": "2.4.2",
|
|
65
|
+
"readline-sync": "1.4.10",
|
|
66
|
+
"semver": "7.7.2",
|
|
67
|
+
"winston": "3.17.0"
|
|
72
68
|
},
|
|
73
69
|
"devDependencies": {
|
|
74
|
-
"chai": "
|
|
75
|
-
"eslint": "
|
|
76
|
-
"eslint-config-airbnb-base": "
|
|
77
|
-
"eslint-plugin-import": "
|
|
78
|
-
"eslint-plugin-json": "
|
|
79
|
-
"testdouble": "
|
|
70
|
+
"chai": "4.5.0",
|
|
71
|
+
"eslint": "8.57.0",
|
|
72
|
+
"eslint-config-airbnb-base": "15.0.0",
|
|
73
|
+
"eslint-plugin-import": "2.31.0",
|
|
74
|
+
"eslint-plugin-json": "3.1.0",
|
|
75
|
+
"testdouble": "3.18.0"
|
|
80
76
|
},
|
|
81
77
|
"private": false
|
|
82
78
|
}
|
package/pronghorn.json
CHANGED
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
"name"
|
|
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"
|
|
73
|
+
"type": "boolean"
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
],
|
|
@@ -226,16 +226,6 @@
|
|
|
226
226
|
"title": "props",
|
|
227
227
|
"type": "object"
|
|
228
228
|
}
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
"name": "persistFlag",
|
|
232
|
-
"type": "boolean",
|
|
233
|
-
"info": "Whether the input properties should be saved",
|
|
234
|
-
"required": true,
|
|
235
|
-
"schema": {
|
|
236
|
-
"title": "persistFlag",
|
|
237
|
-
"type": "boolean"
|
|
238
|
-
}
|
|
239
229
|
}
|
|
240
230
|
],
|
|
241
231
|
"output": {
|
|
@@ -306,7 +296,19 @@
|
|
|
306
296
|
"name": "iapRunAdapterBasicGet",
|
|
307
297
|
"summary": "Runs basicGet script for adapter",
|
|
308
298
|
"description": "Runs basicGet script for adapter",
|
|
309
|
-
"input": [
|
|
299
|
+
"input": [
|
|
300
|
+
{
|
|
301
|
+
"name": "maxCalls",
|
|
302
|
+
"required": false,
|
|
303
|
+
"type": "number",
|
|
304
|
+
"info": "How many GET endpoints to test (defaults to 5)",
|
|
305
|
+
"schema": {
|
|
306
|
+
"title": "maxCalls",
|
|
307
|
+
"type": "number",
|
|
308
|
+
"default": 5
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
],
|
|
310
312
|
"output": {
|
|
311
313
|
"name": "result",
|
|
312
314
|
"type": "object",
|
|
@@ -327,8 +329,8 @@
|
|
|
327
329
|
},
|
|
328
330
|
{
|
|
329
331
|
"name": "iapMoveAdapterEntitiesToDB",
|
|
330
|
-
"summary": "Moves entities from an adapter into the
|
|
331
|
-
"description": "Moves entities from an adapter into the
|
|
332
|
+
"summary": "Moves entities from an adapter into the Itential Platform database",
|
|
333
|
+
"description": "Moves entities from an adapter into the Itential Platform database",
|
|
332
334
|
"input": [],
|
|
333
335
|
"output": {
|
|
334
336
|
"name": "res",
|