@itentialopensource/adapter-salesforce 0.7.4 → 0.9.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 (60) hide show
  1. package/AUTH.md +39 -0
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +454 -0
  4. package/CHANGELOG.md +49 -29
  5. package/CODE_OF_CONDUCT.md +12 -17
  6. package/CONTRIBUTING.md +3 -148
  7. package/ENHANCE.md +69 -0
  8. package/PROPERTIES.md +641 -0
  9. package/README.md +239 -507
  10. package/SUMMARY.md +9 -0
  11. package/SYSTEMINFO.md +11 -0
  12. package/TROUBLESHOOT.md +47 -0
  13. package/adapter.js +423 -304
  14. package/adapterBase.js +854 -408
  15. package/changelogs/changelog.md +94 -0
  16. package/entities/.generic/action.json +110 -5
  17. package/entities/.generic/schema.json +6 -1
  18. package/entities/.system/action.json +4 -4
  19. package/entities/.system/schemaTokenReq.json +33 -4
  20. package/entities/.system/schemaTokenResp.json +1 -34
  21. package/error.json +12 -0
  22. package/metadata.json +49 -0
  23. package/package.json +28 -22
  24. package/pronghorn.json +691 -88
  25. package/propertiesDecorators.json +14 -0
  26. package/propertiesSchema.json +842 -6
  27. package/refs?service=git-upload-pack +0 -0
  28. package/report/adapter-openapi.json +1543 -0
  29. package/report/adapter-openapi.yaml +1201 -0
  30. package/report/adapterInfo.json +10 -0
  31. package/report/updateReport1653403992147.json +120 -0
  32. package/report/updateReport1691511372644.json +120 -0
  33. package/report/updateReport1692202876451.json +120 -0
  34. package/report/updateReport1694464610053.json +120 -0
  35. package/report/updateReport1698421735618.json +120 -0
  36. package/sampleProperties.json +156 -3
  37. package/test/integration/adapterTestBasicGet.js +4 -6
  38. package/test/integration/adapterTestConnectivity.js +91 -42
  39. package/test/integration/adapterTestIntegration.js +158 -104
  40. package/test/unit/adapterBaseTestUnit.js +393 -310
  41. package/test/unit/adapterTestUnit.js +833 -209
  42. package/utils/adapterInfo.js +206 -0
  43. package/utils/addAuth.js +94 -0
  44. package/utils/artifactize.js +1 -1
  45. package/utils/basicGet.js +1 -14
  46. package/utils/checkMigrate.js +1 -1
  47. package/utils/entitiesToDB.js +179 -0
  48. package/utils/findPath.js +1 -1
  49. package/utils/methodDocumentor.js +273 -0
  50. package/utils/modify.js +14 -16
  51. package/utils/packModificationScript.js +2 -2
  52. package/utils/patches2bundledDeps.js +90 -0
  53. package/utils/pre-commit.sh +5 -0
  54. package/utils/removeHooks.js +20 -0
  55. package/utils/taskMover.js +309 -0
  56. package/utils/tbScript.js +129 -53
  57. package/utils/tbUtils.js +152 -35
  58. package/utils/testRunner.js +17 -17
  59. package/utils/troubleshootingAdapter.js +10 -31
  60. package/workflows/README.md +0 -3
@@ -4,11 +4,13 @@
4
4
  "properties": {
5
5
  "host": "salesforce",
6
6
  "port": 443,
7
+ "choosepath": "",
7
8
  "base_path": "/",
8
9
  "version": "",
9
10
  "cache_location": "none",
10
11
  "encode_pathvars": true,
11
- "save_metric": true,
12
+ "encode_queryvars": true,
13
+ "save_metric": false,
12
14
  "stub": true,
13
15
  "protocol": "https",
14
16
  "authentication": {
@@ -21,12 +23,30 @@
21
23
  "invalid_token_error": 401,
22
24
  "auth_field": "header.headers.X-AUTH-TOKEN",
23
25
  "auth_field_format": "{token}",
24
- "auth_logging": false
26
+ "auth_logging": false,
27
+ "client_id": "",
28
+ "client_secret": "",
29
+ "grant_type": "",
30
+ "sensitive": [],
31
+ "sso": {
32
+ "protocol": "",
33
+ "host": "",
34
+ "port": 0
35
+ },
36
+ "multiStepAuthCalls": [
37
+ {
38
+ "name": "",
39
+ "requestFields": {},
40
+ "responseFields": {},
41
+ "successfullResponseCode": 200
42
+ }
43
+ ]
25
44
  },
26
45
  "healthcheck": {
27
46
  "type": "startup",
28
47
  "frequency": 300000,
29
- "query_object": {}
48
+ "query_object": {},
49
+ "addlHeaders": {}
30
50
  },
31
51
  "throttle": {
32
52
  "throttle_enabled": false,
@@ -92,6 +112,139 @@
92
112
  "key_file": "",
93
113
  "cert_file": ""
94
114
  }
115
+ },
116
+ "devicebroker": {
117
+ "getDevice": [
118
+ {
119
+ "path": "/get/devices/{id}",
120
+ "method": "GET",
121
+ "query": {},
122
+ "body": {},
123
+ "headers": {},
124
+ "handleFailure": "ignore",
125
+ "requestFields": {
126
+ "id": "name"
127
+ },
128
+ "responseDatakey": "",
129
+ "responseFields": {
130
+ "name": "host",
131
+ "ostype": "os",
132
+ "ostypePrefix": "system-",
133
+ "ipaddress": "attributes.ipaddr",
134
+ "port": "443"
135
+ }
136
+ }
137
+ ],
138
+ "getDevicesFiltered": [
139
+ {
140
+ "path": "/get/devices",
141
+ "method": "GET",
142
+ "pagination": {
143
+ "offsetVar": "",
144
+ "limitVar": "",
145
+ "incrementBy": "limit",
146
+ "requestLocation": "query"
147
+ },
148
+ "query": {},
149
+ "body": {},
150
+ "headers": {},
151
+ "handleFailure": "ignore",
152
+ "requestFields": {},
153
+ "responseDatakey": "",
154
+ "responseFields": {
155
+ "name": "host",
156
+ "ostype": "os",
157
+ "ostypePrefix": "system-",
158
+ "ipaddress": "attributes.ipaddr",
159
+ "port": "443"
160
+ }
161
+ }
162
+ ],
163
+ "isAlive": [
164
+ {
165
+ "path": "/get/devices/{id}/status",
166
+ "method": "GET",
167
+ "query": {},
168
+ "body": {},
169
+ "headers": {},
170
+ "handleFailure": "ignore",
171
+ "requestFields": {
172
+ "id": "name"
173
+ },
174
+ "responseDatakey": "",
175
+ "responseFields": {
176
+ "status": "status",
177
+ "statusValue": "online"
178
+ }
179
+ }
180
+ ],
181
+ "getConfig": [
182
+ {
183
+ "path": "/get/devices/{id}/configPart1",
184
+ "method": "GET",
185
+ "query": {},
186
+ "body": {},
187
+ "headers": {},
188
+ "handleFailure": "ignore",
189
+ "requestFields": {
190
+ "id": "name"
191
+ },
192
+ "responseDatakey": "",
193
+ "responseFields": {}
194
+ }
195
+ ],
196
+ "getCount": [
197
+ {
198
+ "path": "/get/devices",
199
+ "method": "GET",
200
+ "query": {},
201
+ "body": {},
202
+ "headers": {},
203
+ "handleFailure": "ignore",
204
+ "requestFields": {},
205
+ "responseDatakey": "",
206
+ "responseFields": {}
207
+ }
208
+ ]
209
+ },
210
+ "cache": {
211
+ "enabled": false,
212
+ "entities": [
213
+ {
214
+ "entityType": "",
215
+ "frequency": 1440,
216
+ "flushOnFail": false,
217
+ "limit": 1000,
218
+ "retryAttempts": 5,
219
+ "sort": true,
220
+ "populate": [
221
+ {
222
+ "path": "",
223
+ "method": "GET",
224
+ "pagination": {
225
+ "offsetVar": "",
226
+ "limitVar": "",
227
+ "incrementBy": "limit",
228
+ "requestLocation": "query"
229
+ },
230
+ "query": {},
231
+ "body": {},
232
+ "headers": {},
233
+ "handleFailure": "ignore",
234
+ "requestFields": {},
235
+ "responseDatakey": "",
236
+ "responseFields": {}
237
+ }
238
+ ],
239
+ "cachedTasks": [
240
+ {
241
+ "name": "",
242
+ "filterField": "",
243
+ "filterLoc": ""
244
+ }
245
+ ]
246
+ }
247
+ ]
95
248
  }
96
249
  },
97
250
  "groups": [],
@@ -7,23 +7,21 @@
7
7
  /* eslint import/no-dynamic-require: warn */
8
8
  /* eslint import/no-unresolved: warn */
9
9
 
10
- const mocha = require('mocha');
11
10
  const path = require('path');
12
11
  const assert = require('assert');
12
+ const mocha = require('mocha');
13
13
  const itParam = require('mocha-param');
14
14
 
15
15
  const utils = require('../../utils/tbUtils');
16
16
  const basicGet = require('../../utils/basicGet');
17
- const { name } = require('../../package');
17
+ const { name } = require('../../package.json');
18
18
  const { methods } = require('../../pronghorn.json');
19
19
 
20
20
  const getPronghornProps = (iapDir) => {
21
- const { Discovery } = require('@itential/itential-utils');
22
21
  console.log('Retrieving properties.json file...');
23
22
  const rawProps = require(path.join(iapDir, 'properties.json'));
24
23
  console.log('Decrypting properties...');
25
- const discovery = new Discovery();
26
- const pronghornProps = utils.decryptProperties(rawProps, path.join(__dirname, '..'), discovery);
24
+ const pronghornProps = utils.decryptProperties(rawProps, iapDir);
27
25
  console.log('Found properties.\n');
28
26
  return pronghornProps;
29
27
  };
@@ -34,7 +32,7 @@ describe('[integration] Adapter BasicGET Test', () => {
34
32
  context('Testing GET calls without query parameters', () => {
35
33
  before(async () => {
36
34
  const iapDir = path.join(__dirname, '../../../../../');
37
- if (!utils.withinIAP(iapDir)) {
35
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
38
36
  const sampleProperties = require('../../sampleProperties.json');
39
37
  const adapter = { properties: sampleProperties };
40
38
  a = basicGet.getAdapterInstance(adapter);
@@ -3,9 +3,12 @@
3
3
  /* global describe it context before after */
4
4
  /* eslint no-unused-vars: warn */
5
5
 
6
- const mocha = require('mocha');
7
6
  const assert = require('assert');
8
- const diagnostics = require('network-diagnostics');
7
+ const http = require('http');
8
+ const https = require('https');
9
+ const mocha = require('mocha');
10
+ const ping = require('ping');
11
+ const dnsLookup = require('dns-lookup-promise');
9
12
 
10
13
  let host;
11
14
  process.argv.forEach((val) => {
@@ -16,78 +19,124 @@ process.argv.forEach((val) => {
16
19
 
17
20
  describe('[integration] Adapter Test', () => {
18
21
  context(`Testing network connection on ${host}`, () => {
19
- before(() => {
20
- diagnostics.setTestURL(host);
21
- });
22
-
23
22
  after((done) => {
24
23
  done();
25
24
  });
26
25
 
27
26
  it('DNS resolve', (done) => {
28
- diagnostics.haveDNS((result) => {
29
- try {
30
- assert.equal(result, true);
31
- done();
32
- } catch (error) {
33
- done(error);
34
- }
35
- });
27
+ dnsLookup(host)
28
+ .then((addresses) => {
29
+ try {
30
+ assert.ok(addresses.length > 0);
31
+ done();
32
+ } catch (error) {
33
+ done(error);
34
+ }
35
+ })
36
+ .catch((err) => {
37
+ done(err);
38
+ });
36
39
  });
37
40
 
38
41
  it('Responds to ping', (done) => {
39
- diagnostics.havePing((result) => {
40
- try {
41
- assert.equal(result, true);
42
- done();
43
- } catch (error) {
44
- done(error);
45
- }
46
- });
42
+ ping.promise.probe(host)
43
+ .then((result) => {
44
+ try {
45
+ assert.ok(result.alive);
46
+ done();
47
+ } catch (error) {
48
+ done(error);
49
+ }
50
+ })
51
+ .catch((err) => {
52
+ done(err);
53
+ });
47
54
  });
48
55
 
49
56
  it('Support HTTP on port 80', (done) => {
50
- diagnostics.haveHTTP((result) => {
57
+ const requestOptions = {
58
+ host,
59
+ port: 80,
60
+ method: 'HEAD'
61
+ };
62
+
63
+ const req = http.request(requestOptions, (res) => {
51
64
  try {
52
- assert.equal(result, true);
65
+ assert.ok(res.statusCode >= 200 && res.statusCode < 400);
53
66
  done();
54
67
  } catch (error) {
55
68
  done(error);
56
69
  }
57
70
  });
71
+
72
+ req.on('error', (err) => {
73
+ done(err);
74
+ });
75
+
76
+ req.end();
58
77
  });
59
78
 
60
79
  it('Support HTTPS on port 443', (done) => {
61
- diagnostics.haveHTTPS((result) => {
80
+ const requestOptions = {
81
+ host,
82
+ port: 443,
83
+ method: 'HEAD'
84
+ };
85
+
86
+ const req = https.request(requestOptions, (res) => {
62
87
  try {
63
- assert.equal(result, true);
88
+ assert.ok(res.statusCode >= 200 && res.statusCode < 400);
64
89
  done();
65
90
  } catch (error) {
66
91
  done(error);
67
92
  }
68
93
  });
94
+
95
+ req.on('error', (err) => {
96
+ done(err);
97
+ });
98
+
99
+ req.end();
69
100
  });
70
101
 
71
102
  it('Support IPv4', (done) => {
72
- diagnostics.haveIPv4Async((result) => {
73
- try {
74
- assert.equal(result, true);
75
- done();
76
- } catch (error) {
77
- done(error);
78
- }
79
- });
103
+ const options = {
104
+ family: 4,
105
+ hints: dnsLookup.ADDRCONFIG
106
+ };
107
+
108
+ dnsLookup.lookup(host, options)
109
+ .then((address, family) => {
110
+ try {
111
+ assert.ok(address !== null && family === 4);
112
+ done();
113
+ } catch (error) {
114
+ done(error);
115
+ }
116
+ })
117
+ .catch((err) => {
118
+ done(err);
119
+ });
80
120
  });
81
121
 
82
122
  it('Support IPv6', (done) => {
83
- diagnostics.haveIPv6Async((result) => {
84
- try {
85
- assert.equal(result, true);
86
- done();
87
- } catch (error) {
88
- done(error);
89
- }
90
- });
123
+ const options = {
124
+ family: 6,
125
+ hints: dnsLookup.ADDRCONFIG
126
+ };
127
+
128
+ dnsLookup.lookup(host, options)
129
+ .then((address, family) => {
130
+ try {
131
+ assert.ok(address !== null && family === 6);
132
+ done();
133
+ } catch (error) {
134
+ done(error);
135
+ }
136
+ })
137
+ .catch((err) => {
138
+ done(err);
139
+ });
91
140
  });
92
141
  });
93
142
  });