@itentialopensource/adapter-microsoft_graph 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/CALLS.md CHANGED
@@ -628,6 +628,12 @@ Specific adapter calls are built based on the API of the Microsoft_graph. The Ad
628
628
  <td style="padding:15px">{base_path}/{version}/v1.0/me/sendMail?{query}</td>
629
629
  <td style="padding:15px">Yes</td>
630
630
  </tr>
631
+ <tr>
632
+ <td style="padding:15px">sendmailApplication(body, userId, callback)</td>
633
+ <td style="padding:15px">Send mail with client credentials</td>
634
+ <td style="padding:15px">{base_path}/{version}/v1.0/users/{pathv1}/sendMail?{query}</td>
635
+ <td style="padding:15px">Yes</td>
636
+ </tr>
631
637
  <tr>
632
638
  <td style="padding:15px">getmailboxsettings(callback)</td>
633
639
  <td style="padding:15px">Get mailbox settings</td>
package/CHANGELOG.md CHANGED
@@ -1,4 +1,20 @@
1
1
 
2
+ ## 1.2.0 [11-07-2023]
3
+
4
+ * More Migration Changes
5
+
6
+ See merge request itentialopensource/adapters/cloud/adapter-microsoft_graph!5
7
+
8
+ ---
9
+
10
+ ## 1.1.1 [10-11-2023]
11
+
12
+ * Patch/adapt 2935
13
+
14
+ See merge request itentialopensource/adapters/cloud/adapter-microsoft_graph!4
15
+
16
+ ---
17
+
2
18
  ## 1.1.0 [09-26-2023]
3
19
 
4
20
  * 2023 Adapter Migration
package/adapter.js CHANGED
@@ -7039,6 +7039,95 @@ class MicrosoftGraph extends AdapterBaseCl {
7039
7039
  }
7040
7040
  }
7041
7041
 
7042
+ /**
7043
+ * @function sendmailApplication
7044
+ * @pronghornType method
7045
+ * @name sendmailApplication
7046
+ * @summary Send mail
7047
+ *
7048
+ * @param {object} body - body param
7049
+ * @param {string} userId - user id or userPrincipalName to sendmail from
7050
+ * @param {getCallback} callback - a callback function to return the result
7051
+ * @return {object} results - An object containing the response of the action
7052
+ *
7053
+ * @route {POST} /sendmailApplication
7054
+ * @roles admin
7055
+ * @task true
7056
+ */
7057
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
7058
+ sendmailApplication(body, userId, callback) {
7059
+ const meth = 'adapter-sendmailApplication';
7060
+ const origin = `${this.id}-${meth}`;
7061
+ log.trace(origin);
7062
+
7063
+ if (this.suspended && this.suspendMode === 'error') {
7064
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
7065
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7066
+ return callback(null, errorObj);
7067
+ }
7068
+
7069
+ /* HERE IS WHERE YOU VALIDATE DATA */
7070
+ if (body === undefined || body === null || body === '') {
7071
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
7072
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7073
+ return callback(null, errorObj);
7074
+ }
7075
+ /* HERE IS WHERE YOU VALIDATE DATA */
7076
+ if (userId === undefined || userId === null || userId === '') {
7077
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['userId'], null, null, null);
7078
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7079
+ return callback(null, errorObj);
7080
+ }
7081
+
7082
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
7083
+ const queryParamsAvailable = {};
7084
+ const queryParams = {};
7085
+ const pathVars = [userId];
7086
+ const bodyVars = body;
7087
+
7088
+ // loop in template. long callback arg name to avoid identifier conflicts
7089
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
7090
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
7091
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
7092
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
7093
+ }
7094
+ });
7095
+
7096
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
7097
+ // see adapter code documentation for more information on the request object's fields
7098
+ const reqObj = {
7099
+ payload: bodyVars,
7100
+ uriPathVars: pathVars,
7101
+ uriQuery: queryParams
7102
+ };
7103
+
7104
+ try {
7105
+ // Make the call -
7106
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
7107
+ return this.requestHandlerInst.identifyRequest('Mail', 'sendmailApplication', reqObj, true, (irReturnData, irReturnError) => {
7108
+ // if we received an error or their is no response on the results
7109
+ // return an error
7110
+ if (irReturnError) {
7111
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
7112
+ return callback(null, irReturnError);
7113
+ }
7114
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
7115
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['sendmail'], null, null, null);
7116
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7117
+ return callback(null, errorObj);
7118
+ }
7119
+
7120
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
7121
+ // return the response
7122
+ return callback(irReturnData, null);
7123
+ });
7124
+ } catch (ex) {
7125
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
7126
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7127
+ return callback(null, errorObj);
7128
+ }
7129
+ }
7130
+
7042
7131
  /**
7043
7132
  * @function getmailboxsettings
7044
7133
  * @pronghornType method
@@ -125,6 +125,26 @@
125
125
  }
126
126
  ]
127
127
  },
128
+ {
129
+ "name": "sendmailApplication",
130
+ "protocol": "REST",
131
+ "method": "POST",
132
+ "entitypath": "{base_path}/{version}/v1.0/users/{pathv1}/sendMail?{query}",
133
+ "requestSchema": "schema.json",
134
+ "responseSchema": "schema.json",
135
+ "timeout": 0,
136
+ "sendEmpty": false,
137
+ "requestDatatype": "JSON",
138
+ "responseDatatype": "JSON",
139
+ "headers": {},
140
+ "responseObjects": [
141
+ {
142
+ "type": "default",
143
+ "key": "",
144
+ "mockFile": ""
145
+ }
146
+ ]
147
+ },
128
148
  {
129
149
  "name": "getmailboxsettings",
130
150
  "protocol": "REST",
@@ -16,6 +16,7 @@
16
16
  "getmymailboxrules",
17
17
  "getmycategories",
18
18
  "sendmail",
19
+ "sendmailApplication",
19
20
  "getmailboxsettings",
20
21
  "setautomaticreplies",
21
22
  "getauserSmessages",
package/metadata.json CHANGED
@@ -15,9 +15,7 @@
15
15
  ],
16
16
  "method": "REST",
17
17
  "type": "Adapter",
18
- "domains": [
19
- "Cloud"
20
- ],
18
+ "domains": [],
21
19
  "tags": [],
22
20
  "useCases": [],
23
21
  "deprecated": {
@@ -27,7 +25,7 @@
27
25
  "documentation": {
28
26
  "storeLink": "",
29
27
  "npmLink": "https://www.npmjs.com/package/@itentialopensource/adapter-microsoft_graph",
30
- "repoLink": "https://gitlab.com/itentialopensource/adapters/cloud/adapter-microsoft_graph.git",
28
+ "repoLink": "https://gitlab.com/itentialopensource/adapters/cloud/adapter-microsoft_graph",
31
29
  "docLink": "https://docs.itential.com/opensource/docs/microsoft-graph",
32
30
  "demoLinks": [],
33
31
  "faqLink": "https://docs.itential.com/opensource/docs/troubleshooting-an-adapter",
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-microsoft_graph",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "This adapter integrates with system described as: microsoftGraph.",
5
5
  "main": "adapter.js",
6
6
  "wizardVersion": "2.44.7",
7
- "engineVersion": "1.67.8",
7
+ "engineVersion": "1.67.10",
8
8
  "adapterType": "http",
9
9
  "scripts": {
10
10
  "artifactize": "npm i && node utils/packModificationScript.js",
@@ -54,7 +54,7 @@
54
54
  "author": "Itential",
55
55
  "homepage": "https://gitlab.com/itentialopensource/adapters/cloud/adapter-microsoft_graph#readme",
56
56
  "dependencies": {
57
- "@itentialopensource/adapter-utils": "^5.1.7",
57
+ "@itentialopensource/adapter-utils": "^5.3.0",
58
58
  "acorn": "^8.10.0",
59
59
  "ajv": "^8.12.0",
60
60
  "axios": "^1.4.0",
package/pronghorn.json CHANGED
@@ -3819,6 +3819,80 @@
3819
3819
  },
3820
3820
  "task": true
3821
3821
  },
3822
+ {
3823
+ "name": "sendmailApplication",
3824
+ "summary": "Send mail with client credentials",
3825
+ "description": "Send mail with client credentials",
3826
+ "input": [
3827
+ {
3828
+ "name": "body",
3829
+ "type": "object",
3830
+ "info": ": object",
3831
+ "required": true,
3832
+ "schema": {
3833
+ "allOf": [
3834
+ {
3835
+ "type": "object"
3836
+ },
3837
+ {
3838
+ "example": {
3839
+ "message": {
3840
+ "subject": "Meet for lunch?",
3841
+ "body": {
3842
+ "contentType": "Text",
3843
+ "content": "The new cafeteria is open."
3844
+ },
3845
+ "toRecipients": [
3846
+ {
3847
+ "emailAddress": {
3848
+ "address": "{{UserName}}"
3849
+ }
3850
+ }
3851
+ ],
3852
+ "ccRecipients": [
3853
+ {
3854
+ "emailAddress": {
3855
+ "address": "{{UserName}}"
3856
+ }
3857
+ }
3858
+ ]
3859
+ },
3860
+ "saveToSentItems": "false"
3861
+ }
3862
+ }
3863
+ ],
3864
+ "definitions": {}
3865
+ }
3866
+ },
3867
+ {
3868
+ "name": "userId",
3869
+ "type": "string",
3870
+ "info": ": string",
3871
+ "required": true,
3872
+ "schema": {
3873
+ "title": "userId",
3874
+ "type": "string"
3875
+ }
3876
+ }
3877
+ ],
3878
+ "output": {
3879
+ "name": "result",
3880
+ "type": "object",
3881
+ "description": "A JSON Object containing status, code and the result",
3882
+ "schema": {
3883
+ "title": "result",
3884
+ "type": "object"
3885
+ }
3886
+ },
3887
+ "roles": [
3888
+ "admin"
3889
+ ],
3890
+ "route": {
3891
+ "verb": "POST",
3892
+ "path": "/sendmailApplication"
3893
+ },
3894
+ "task": true
3895
+ },
3822
3896
  {
3823
3897
  "name": "getmailboxsettings",
3824
3898
  "summary": "Get mailbox settings",
@@ -109,6 +109,14 @@
109
109
  },
110
110
  "cache": {
111
111
  "$ref": "#/definitions/cache"
112
+ },
113
+ "service": {
114
+ "type": "string",
115
+ "description": "Service we are integrating with -- used with AWS Authentication",
116
+ "examples": [
117
+ "ec2",
118
+ "route53"
119
+ ]
112
120
  }
113
121
  },
114
122
  "required": [
@@ -131,7 +139,8 @@
131
139
  "jwt_token",
132
140
  "request_token",
133
141
  "no_authentication",
134
- "multi_step_authentication"
142
+ "multi_step_authentication",
143
+ "aws_authentication"
135
144
  ]
136
145
  },
137
146
  "username": {
Binary file
@@ -1,10 +1,10 @@
1
1
  {
2
- "version": "1.0.2",
3
- "configLines": 10828,
2
+ "version": "1.1.1",
3
+ "configLines": 10911,
4
4
  "scriptLines": 1783,
5
- "codeLines": 20081,
5
+ "codeLines": 20170,
6
6
  "testLines": 15130,
7
7
  "testCases": 772,
8
- "totalCodeLines": 36994,
9
- "wfTasks": 227
8
+ "totalCodeLines": 37083,
9
+ "wfTasks": 228
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.3.0"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 77
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": 7690
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 491
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 6188
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 211
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": 15331
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 702
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -77,6 +77,7 @@ function readFileUsingLib(filename, descriptionObj, workflowObj, functionList) {
77
77
  // parsing the file to get the function and class declarations.
78
78
  const aFileFuncArgs = acorn.parse(aFile, { ecmaVersion: 2020 });
79
79
 
80
+ let callName = 'identifyRequest';
80
81
  // Looping through all the declarations parsed:
81
82
  aFileFuncArgs.body.forEach((e) => {
82
83
  // Getting only the class declaration as it has our required functions.
@@ -89,8 +90,10 @@ function readFileUsingLib(filename, descriptionObj, workflowObj, functionList) {
89
90
  method.value.params.forEach((param) => {
90
91
  if (param.type === 'Identifier') {
91
92
  funcArgs.push(param.name);
93
+ } else if (param.type === 'RestElement') {
94
+ funcArgs.push(`...${param.argument.name}`);
92
95
  } else {
93
- const args = `${param.left.name} = ${param.right.value}`;
96
+ const args = `${param.left.name} = ${param.right.raw}`;
94
97
  funcArgs.push(args);
95
98
  }
96
99
  });
@@ -102,7 +105,7 @@ function readFileUsingLib(filename, descriptionObj, workflowObj, functionList) {
102
105
  });
103
106
  const requests = [];
104
107
  for (let i = 0; i < callList.length; i += 1) {
105
- if (callList[i].callee.property && callList[i].callee.property.name === 'identifyRequest') {
108
+ if (callList[i].callee.property && callList[i].callee.property.name === callName) {
106
109
  requests.push(callList[i]);
107
110
  }
108
111
  }
@@ -114,7 +117,16 @@ function readFileUsingLib(filename, descriptionObj, workflowObj, functionList) {
114
117
  const entity = expr.arguments[0].value;
115
118
  const actionName = expr.arguments[1].value;
116
119
  if (expr !== undefined && (expr.arguments[0].type !== 'Literal' || expr.arguments[1].type !== 'Literal')) {
117
- throw new Error(`Bad inputs in method ${funcName}`);
120
+ const param1 = method.value.params[0];
121
+ const param2 = method.value.params[1];
122
+ if (param1.type !== 'Identifier' || param2.type !== 'Identifier'
123
+ || expr.arguments[0].type !== 'Identifier' || expr.arguments[1].type !== 'Identifier'
124
+ || param1.name !== expr.arguments[0].name || param2.name !== expr.arguments[1].name) {
125
+ throw new Error(`identifyRequest proxy method ${funcName} unknown format`);
126
+ } else if (callName !== 'identifyRequest') {
127
+ throw new Error(`MethodDocumentor not yet programmed to handle multiple helper methods: 1) ${callName}, 2) ${funcName}`);
128
+ }
129
+ callName = funcName;
118
130
  }
119
131
  const entityPath = getPathFromEntity(entity, actionName);
120
132
 
@@ -197,6 +209,7 @@ function readMDFile(filename, functionList) {
197
209
  // Creating the tags for each method to be appended to the file.
198
210
  const tdBeginTag = ' <td style="padding:15px">';
199
211
  const tdEndTag = '</td>';
212
+
200
213
  functionList.forEach((func) => {
201
214
  const signCommand = `${tdBeginTag}${func.method_signature}${tdEndTag}`;
202
215
  const descCommand = `${tdBeginTag}${func.description}${tdEndTag}`;