@itentialopensource/adapter-meraki 1.1.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  {
2
- "version": "1.0.4",
3
- "configLines": 62990,
2
+ "version": "1.2.1",
3
+ "configLines": 63054,
4
4
  "scriptLines": 1783,
5
- "codeLines": 53766,
6
- "testLines": 43439,
5
+ "codeLines": 53869,
6
+ "testLines": 43445,
7
7
  "testCases": 2230,
8
- "totalCodeLines": 98988,
8
+ "totalCodeLines": 99097,
9
9
  "wfTasks": 611
10
10
  }
@@ -0,0 +1,120 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 0
8
+ },
9
+ {
10
+ "owner": "errorJson",
11
+ "description": "Adapter errors no longer available for use",
12
+ "value": 0
13
+ },
14
+ {
15
+ "owner": "errorJson",
16
+ "description": "Adapter errors that have been updated (e.g. recommendation changes)",
17
+ "value": 31
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 17
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 6
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 22
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^5.1.0"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 76
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 343
48
+ },
49
+ {
50
+ "owner": "markdown",
51
+ "description": "Number of lines in the SUMMARY.md",
52
+ "value": 9
53
+ },
54
+ {
55
+ "owner": "markdown",
56
+ "description": "Number of lines in the PROPERTIES.md",
57
+ "value": 642
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the TROUBLESHOOT.md",
62
+ "value": 48
63
+ },
64
+ {
65
+ "owner": "markdown",
66
+ "description": "Number of lines in the ENHANCE.md",
67
+ "value": 70
68
+ },
69
+ {
70
+ "owner": "markdown",
71
+ "description": "Number of lines in the BROKER.md",
72
+ "value": 70
73
+ },
74
+ {
75
+ "owner": "unitTestJS",
76
+ "description": "Number of lines of code in unit tests",
77
+ "value": 24022
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 1565
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 18165
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 595
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of lines of code in adapterBase.js",
97
+ "value": 1350
98
+ },
99
+ {
100
+ "owner": "staticFile",
101
+ "description": "Number of static files added",
102
+ "value": 36
103
+ },
104
+ {
105
+ "owner": "Overall",
106
+ "description": "Total lines of Code",
107
+ "value": 43537
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 2160
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 0
8
+ },
9
+ {
10
+ "owner": "errorJson",
11
+ "description": "Adapter errors no longer available for use",
12
+ "value": 0
13
+ },
14
+ {
15
+ "owner": "errorJson",
16
+ "description": "Adapter errors that have been updated (e.g. recommendation changes)",
17
+ "value": 31
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 17
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 6
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 22
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^5.1.7"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 76
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 347
48
+ },
49
+ {
50
+ "owner": "markdown",
51
+ "description": "Number of lines in the SUMMARY.md",
52
+ "value": 9
53
+ },
54
+ {
55
+ "owner": "markdown",
56
+ "description": "Number of lines in the PROPERTIES.md",
57
+ "value": 642
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the TROUBLESHOOT.md",
62
+ "value": 48
63
+ },
64
+ {
65
+ "owner": "markdown",
66
+ "description": "Number of lines in the ENHANCE.md",
67
+ "value": 70
68
+ },
69
+ {
70
+ "owner": "markdown",
71
+ "description": "Number of lines in the BROKER.md",
72
+ "value": 70
73
+ },
74
+ {
75
+ "owner": "unitTestJS",
76
+ "description": "Number of lines of code in unit tests",
77
+ "value": 24028
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 1565
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 18165
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 595
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of lines of code in adapterBase.js",
97
+ "value": 1453
98
+ },
99
+ {
100
+ "owner": "staticFile",
101
+ "description": "Number of static files added",
102
+ "value": 36
103
+ },
104
+ {
105
+ "owner": "Overall",
106
+ "description": "Total lines of Code",
107
+ "value": 43646
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 2160
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 0
8
+ },
9
+ {
10
+ "owner": "errorJson",
11
+ "description": "Adapter errors no longer available for use",
12
+ "value": 0
13
+ },
14
+ {
15
+ "owner": "errorJson",
16
+ "description": "Adapter errors that have been updated (e.g. recommendation changes)",
17
+ "value": 31
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 17
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 6
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 22
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^5.1.7"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 76
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 347
48
+ },
49
+ {
50
+ "owner": "markdown",
51
+ "description": "Number of lines in the SUMMARY.md",
52
+ "value": 9
53
+ },
54
+ {
55
+ "owner": "markdown",
56
+ "description": "Number of lines in the PROPERTIES.md",
57
+ "value": 642
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the TROUBLESHOOT.md",
62
+ "value": 48
63
+ },
64
+ {
65
+ "owner": "markdown",
66
+ "description": "Number of lines in the ENHANCE.md",
67
+ "value": 70
68
+ },
69
+ {
70
+ "owner": "markdown",
71
+ "description": "Number of lines in the BROKER.md",
72
+ "value": 70
73
+ },
74
+ {
75
+ "owner": "unitTestJS",
76
+ "description": "Number of lines of code in unit tests",
77
+ "value": 24028
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 1565
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 18165
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 595
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of lines of code in adapterBase.js",
97
+ "value": 1453
98
+ },
99
+ {
100
+ "owner": "staticFile",
101
+ "description": "Number of static files added",
102
+ "value": 36
103
+ },
104
+ {
105
+ "owner": "Overall",
106
+ "description": "Total lines of Code",
107
+ "value": 43646
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 2160
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -144,6 +144,12 @@
144
144
  {
145
145
  "path": "/organizations/{orgID}/devices",
146
146
  "method": "GET",
147
+ "pagination": {
148
+ "offsetVar": "",
149
+ "limitVar": "",
150
+ "incrementBy": "limit",
151
+ "requestLocation": "query"
152
+ },
147
153
  "query": {},
148
154
  "body": {},
149
155
  "headers": {},
@@ -229,6 +235,12 @@
229
235
  {
230
236
  "path": "/organizations/{orgID}/devices",
231
237
  "method": "GET",
238
+ "pagination": {
239
+ "offsetVar": "",
240
+ "limitVar": "",
241
+ "incrementBy": "limit",
242
+ "requestLocation": "query"
243
+ },
232
244
  "query": {},
233
245
  "body": {},
234
246
  "headers": {},
@@ -391,12 +391,12 @@ describe('[unit] Adapter Base Test', () => {
391
391
  });
392
392
  it('should return a list of functions', (done) => {
393
393
  const returnedFunctions = ['checkActionFiles', 'checkProperties', 'connect', 'encryptProperty', 'genericAdapterRequest', 'genericAdapterRequestNoBasePath',
394
- 'getAllFunctions', 'getConfig', 'getDevice', 'getDevicesFiltered', 'hasEntities', 'healthCheck', 'iapActivateTasks', 'iapDeactivateTasks',
395
- 'iapExpandedGenericAdapterRequest', 'iapFindAdapterPath', 'iapGetAdapterInventory', 'iapGetAdapterQueue', 'iapGetAdapterWorkflowFunctions', 'iapGetDeviceCount',
396
- 'iapMoveAdapterEntitiesToDB', 'iapPopulateEntityCache', 'iapRetrieveEntitiesCache', 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck',
397
- 'iapRunAdapterLint', 'iapRunAdapterTests', 'iapSuspendAdapter', 'iapTroubleshootAdapter', 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration',
398
- 'isAlive', 'refreshProperties', 'addListener', 'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once',
399
- 'prependListener', 'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
394
+ 'getAllFunctions', 'getConfig', 'getConfigAuth', 'getDevice', 'getDeviceAuth', 'getDevicesFiltered', 'getDevicesFilteredAuth', 'hasEntities', 'hasEntitiesAuth',
395
+ 'healthCheck', 'iapActivateTasks', 'iapDeactivateTasks', 'iapExpandedGenericAdapterRequest', 'iapFindAdapterPath', 'iapGetAdapterInventory', 'iapGetAdapterQueue',
396
+ 'iapGetAdapterWorkflowFunctions', 'iapGetDeviceCount', 'iapGetDeviceCountAuth', 'iapMoveAdapterEntitiesToDB', 'iapPopulateEntityCache', 'iapRetrieveEntitiesCache',
397
+ 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapRunAdapterLint', 'iapRunAdapterTests', 'iapSuspendAdapter', 'iapTroubleshootAdapter',
398
+ 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'isAlive', 'isAliveAuth', 'refreshProperties', 'addListener', 'emit', 'eventNames', 'getMaxListeners',
399
+ 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener', 'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
400
400
  try {
401
401
  const expectedFunctions = a.getAllFunctions();
402
402
  try {
@@ -887,6 +887,8 @@ describe('[unit] Meraki Adapter Test', () => {
887
887
  assert.notEqual(undefined, sampleDotJson.properties.devicebroker.isAlive);
888
888
  assert.notEqual(undefined, sampleDotJson.properties.devicebroker.getConfig);
889
889
  assert.notEqual(undefined, sampleDotJson.properties.devicebroker.getCount);
890
+ assert.notEqual(undefined, sampleDotJson.properties.cache);
891
+ assert.notEqual(undefined, sampleDotJson.properties.cache.entities);
890
892
  done();
891
893
  } catch (error) {
892
894
  log.error(`Test Failure: ${error}`);
@@ -1453,6 +1455,10 @@ describe('[unit] Meraki Adapter Test', () => {
1453
1455
  try {
1454
1456
  const metadataDotJson = require('../../metadata.json');
1455
1457
  assert.equal('adapter-meraki', metadataDotJson.name);
1458
+ assert.notEqual(undefined, metadataDotJson.webName);
1459
+ assert.notEqual(null, metadataDotJson.webName);
1460
+ assert.notEqual('', metadataDotJson.webName);
1461
+ assert.equal('Adapter', metadataDotJson.type);
1456
1462
  done();
1457
1463
  } catch (error) {
1458
1464
  log.error(`Test Failure: ${error}`);
@@ -1480,9 +1486,9 @@ describe('[unit] Meraki Adapter Test', () => {
1480
1486
  assert.notEqual(undefined, metadataDotJson.relatedItems.adapters);
1481
1487
  assert.notEqual(undefined, metadataDotJson.relatedItems.integrations);
1482
1488
  assert.notEqual(undefined, metadataDotJson.relatedItems.ecosystemApplications);
1483
- assert.notEqual(undefined, metadataDotJson.relatedItems.automations);
1484
- assert.notEqual(undefined, metadataDotJson.relatedItems.transformations);
1485
- assert.notEqual(undefined, metadataDotJson.relatedItems.useCases);
1489
+ assert.notEqual(undefined, metadataDotJson.relatedItems.workflowProjects);
1490
+ assert.notEqual(undefined, metadataDotJson.relatedItems.transformationProjects);
1491
+ assert.notEqual(undefined, metadataDotJson.relatedItems.exampleProjects);
1486
1492
  done();
1487
1493
  } catch (error) {
1488
1494
  log.error(`Test Failure: ${error}`);
@@ -3,7 +3,7 @@
3
3
  /* eslint no-param-reassign:warn */
4
4
 
5
5
  const fs = require('fs-extra');
6
- const esprima = require('esprima');
6
+ const acorn = require('acorn');
7
7
 
8
8
  // Getting the base directory:
9
9
  let adaptdir = __dirname;
@@ -44,18 +44,38 @@ function getPathFromEntity(entity, funcName) {
44
44
  const actionJSON = require(entityPath);
45
45
  actionJSON.actions.forEach((action) => {
46
46
  if (action.name === funcName) {
47
- epath = action.entitypath;
47
+ if (typeof action.entitypath === 'object') {
48
+ epath = '';
49
+ const keys = Object.keys(action.entitypath);
50
+ for (let k = 0; k < keys.length; k += 1) {
51
+ epath += `${keys[k]}:${action.entitypath[keys[k]]} <br /> `;
52
+ }
53
+ epath = epath.substring(0, epath.length - 8);
54
+ } else {
55
+ epath = action.entitypath;
56
+ }
48
57
  }
49
58
  });
50
59
  }
51
60
  return epath;
52
61
  }
53
62
 
63
+ function recurseCallExpressions(statement, callList) {
64
+ // Recursively finds all CallExpressions in the syntax tree
65
+ if (statement.type === 'CallExpression') callList.push(statement);
66
+ const keys = Object.keys(statement);
67
+ for (let k = 0; k < keys.length; k += 1) {
68
+ if (typeof statement[keys[k]] === 'object' && statement[keys[k]] !== null) {
69
+ recurseCallExpressions(statement[keys[k]], callList);
70
+ }
71
+ }
72
+ }
73
+
54
74
  function readFileUsingLib(filename, descriptionObj, workflowObj, functionList) {
55
75
  // read the file
56
76
  const aFile = fs.readFileSync(filename, 'utf8');
57
77
  // parsing the file to get the function and class declarations.
58
- const aFileFuncArgs = esprima.parseScript(aFile);
78
+ const aFileFuncArgs = acorn.parse(aFile, { ecmaVersion: 2020 });
59
79
 
60
80
  // Looping through all the declarations parsed:
61
81
  aFileFuncArgs.body.forEach((e) => {
@@ -76,25 +96,40 @@ function readFileUsingLib(filename, descriptionObj, workflowObj, functionList) {
76
96
  });
77
97
 
78
98
  // Getting the entity for the method:
79
- let entity;
80
- method.value.body.body.forEach((statementType) => {
81
- if (statementType.type === 'TryStatement') {
82
- entity = statementType.block.body[0].argument.arguments[0].value;
83
- }
99
+ const callList = [];
100
+ method.value.body.body.forEach((statement) => {
101
+ recurseCallExpressions(statement, callList);
84
102
  });
85
- const entityPath = getPathFromEntity(entity, funcName);
86
-
87
- // Creating and storing the object for the method.
88
- if (entityPath !== undefined) {
89
- functionList.push(
90
- createObjectForFunction(
91
- funcName,
92
- funcArgs,
93
- entityPath,
94
- descriptionObj[funcName],
95
- workflowObj[funcName]
96
- )
97
- );
103
+ const requests = [];
104
+ for (let i = 0; i < callList.length; i += 1) {
105
+ if (callList[i].callee.property && callList[i].callee.property.name === 'identifyRequest') {
106
+ requests.push(callList[i]);
107
+ }
108
+ }
109
+ if (requests.length > 0) {
110
+ const expr = requests[0];
111
+ if (expr.arguments.length < 2) {
112
+ throw new Error(`Bad inputs in method ${funcName}`);
113
+ }
114
+ const entity = expr.arguments[0].value;
115
+ const actionName = expr.arguments[1].value;
116
+ if (expr !== undefined && (expr.arguments[0].type !== 'Literal' || expr.arguments[1].type !== 'Literal')) {
117
+ throw new Error(`Bad inputs in method ${funcName}`);
118
+ }
119
+ const entityPath = getPathFromEntity(entity, actionName);
120
+
121
+ // Creating and storing the object for the method.
122
+ if (entityPath !== undefined) {
123
+ functionList.push(
124
+ createObjectForFunction(
125
+ funcName,
126
+ funcArgs,
127
+ entityPath,
128
+ descriptionObj[funcName],
129
+ workflowObj[funcName]
130
+ )
131
+ );
132
+ }
98
133
  }
99
134
  });
100
135
  }
@@ -109,7 +144,7 @@ function readJSONFile(filename, descriptionObj, workflowObj) {
109
144
  methodArray.forEach((methodName) => {
110
145
  // Getting the method description and workflow:
111
146
  const funcName = methodName.name;
112
- descriptionObj[funcName] = methodName.description;
147
+ descriptionObj[funcName] = methodName.summary ? methodName.summary : methodName.description;
113
148
  workflowObj[funcName] = methodName.task ? 'Yes' : 'No';
114
149
  });
115
150
  }