@manyos/smileconnect-api 1.61.1 → 1.63.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/app.js CHANGED
@@ -152,6 +152,8 @@ passport.use(
152
152
  const clientConfig = config.getClientConfig(clientId)
153
153
  clientConfig.clientId = clientId
154
154
 
155
+ req.clientId = clientId;
156
+
155
157
  const user = {
156
158
  'id': jwt_payload.sub,
157
159
  'azp': jwt_payload.azp,
@@ -196,7 +198,8 @@ const maxFilesize = process.env.MAX_FILESIZE || 5;
196
198
 
197
199
  app.use(fileUpload({
198
200
  limits: { fileSize: maxFilesize * 1024 * 1024 },
199
- abortOnLimit: true
201
+ abortOnLimit: true,
202
+ debug: true
200
203
  }));
201
204
 
202
205
  //global check for compatibility
@@ -265,7 +268,8 @@ app.use(function (req, res, next) {
265
268
  app.use(function (req, res, next) {
266
269
  req.globalScriptParams = {
267
270
  query: req.query,
268
- user: req.user
271
+ user: req.user,
272
+ log: log.child({req_id: req.id, clientId:req.clientId}, true)
269
273
  }
270
274
  // Für Scripte einen globalen parameter bereitstellen, der den org. Body enthält. Damit hat man auch noch in Post Scripten Zugriff auf customAttributes die beim Mapping entfernt werden.
271
275
  if (req.body) {
@@ -80,7 +80,7 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
80
80
  requestData,
81
81
  params,
82
82
  adapter,
83
- log,
83
+ log: globalScriptParams.log.child({script: scriptId}, true),
84
84
  clientId,
85
85
  xmlParser,
86
86
  script:executeScriptByScript,
package/docs/adapter.md CHANGED
@@ -40,7 +40,13 @@ const adapterParams = {
40
40
  secret: env.SC_SECRET,
41
41
  ssoUrl: env.SC_SSO_URL,
42
42
  smileConnectUrl: env.SC_SMILECONNECT_URL
43
+ },
44
+ deepl: {
45
+ type: "Deepl",
46
+ authKey: env.DEEPL_KEY,
47
+ url: "https://api-free.deepl.com/v2/translate"
43
48
  }
49
+
44
50
  };
45
51
 
46
52
  // noinspection JSAnnotator
@@ -566,3 +572,107 @@ The SMILEconnect Adapter can be used to do calls against SMILEconnect. It will a
566
572
  The SMILEconnect adapter is an open source project.
567
573
 
568
574
  [Visit the project homepage for details](https://github.com/manyosit/smileconnect-client)
575
+
576
+ # Mail
577
+
578
+ ## Configuration values
579
+
580
+ **host**: The SMTP Host
581
+
582
+ **port**: The SMTP Port
583
+
584
+ **secure**: Is secure communication use? True/False
585
+
586
+ **auth.user**: User for SMTP Authentication
587
+
588
+ **auth.pass**: Pass for SMTP Authentication
589
+
590
+ ## Functions
591
+
592
+ ### sendMail
593
+
594
+ ```javascript
595
+ async sendMail(mailData)
596
+ ```
597
+
598
+ Parameter (mailData):
599
+
600
+ * from
601
+
602
+ The address of the sender.
603
+
604
+ * to
605
+
606
+ The addresses of the receivers.
607
+
608
+ * subject
609
+
610
+ The subject of the mail.
611
+
612
+ * text
613
+
614
+ The plain text body.
615
+
616
+ * html
617
+
618
+ The html body.
619
+
620
+ Full example:
621
+
622
+ ```javascript
623
+ const mailData = {
624
+ from: '"Fred Foo 👻" <foo@example.com>', // sender address
625
+ to: "bar@example.com", // list of receivers
626
+ subject: "Hello ✔", // Subject line
627
+ text: "Hello world?", // plain text body
628
+ html: "<b>Hello world?</b>", // html body
629
+ }
630
+
631
+ const result = adapter.mail.sendMail(mailData);
632
+ ```
633
+
634
+ # DeepL
635
+
636
+ Provides access to the Deepl translation API.
637
+
638
+ ## Configuration values
639
+
640
+ **authKey**: Your Deepl API Key. e.g. d82js82jd-8a14-119d-f8e9-dk2:fx
641
+
642
+ **url**: The url of the deepl endpoint. e.g. https://api-free.deepl.com/v2/translate
643
+
644
+ ## Functions
645
+
646
+ ### Translate
647
+
648
+ ```javascript
649
+ async translate(targetLanguage, text)
650
+ ```
651
+ Runs a query against the ldap Server.
652
+
653
+ Parameter:
654
+
655
+ * targetLanguage
656
+
657
+ Defines the target language that will be used for translation. e.g. DE
658
+
659
+ * text
660
+
661
+ The text that should be translated. Either string or array of string.
662
+
663
+ Full example:
664
+
665
+ ```javascript
666
+ const text = 'Guten Morgen. Hoffe wir sehen uns bald wieder! Viele Grüße';
667
+ const result = await adapter.deepl.translate('EN', text);
668
+ ```
669
+
670
+ Returns an object with an array translated sentences. e.g.
671
+
672
+ ```javascript
673
+ {
674
+ "translations": [
675
+ {"detected_source_language":"DE","text":"Good morning. Hope to see you soon! Many greetings, Robert"}
676
+ ]
677
+ }
678
+ ```
@@ -156,6 +156,10 @@ Sample:
156
156
 
157
157
  Loglevel of the api. Defaults to *error*
158
158
 
159
+ ### LOG_REQUEST
160
+
161
+ If set to true, the incoming request & headers will be written to the JsonValue field in the QueueForm.
162
+
159
163
  ## Rate Limits
160
164
 
161
165
  ### RATE_LIMIT
package/docs/releases.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Release Notes
2
2
 
3
3
  ## API
4
+ ### 1.63.0 - 10.01.23
5
+ Security fix for jsonwebtoken https://github.com/advisories/GHSA-27h2-hvpr-p74q
6
+
7
+ ### 1.62.0 - 18.11.22
8
+ Add Deepl Translation Adapter
9
+
4
10
  ### 1.61.1 - 17.11.22
5
11
  Add HttpsProxyAgent to Scripts
6
12
 
@@ -179,6 +185,12 @@ e.g.
179
185
  */v1/incidents?impersonateUser=abc123
180
186
 
181
187
  ## Event Manager
188
+ ### 1.29.1 - 10.01.23
189
+ Security fix for jsonwebtoken https://github.com/advisories/GHSA-27h2-hvpr-p74q
190
+
191
+ ### 1.29.0 - 18.11.22
192
+ Add Deepl Translation Adapter
193
+
182
194
  ### 1.28.1 - 17.11.22
183
195
  Add HttpsProxyAgent to Scripts
184
196
 
package/docs/scripts.md CHANGED
@@ -311,23 +311,25 @@ This script looks up the previous assignment group if an incident is set to "ass
311
311
  //lookup Previous Assigned Support Group for Incident
312
312
  // and assign this group if status is changed to "assigned", and assignedGroup is not set.
313
313
 
314
+ if ( globalScriptParams && globalScriptParams.id && requestData['status']=="Assigned" && !requestData.hasOwnProperty("assignedGroup") ) {
314
315
 
315
- if ( requestData['id'] && requestData['status']=="Assigned" && !requestData.hasOwnProperty("assignedGroup") ) {
316
- const remedyResult = await adapter.remedy.search("HPD:Help Desk Assignment Log", `'Incident Number' = "${requestData.id}"`, "Submit Date,Assigned Support Company,Assigned Support Organization,Assigned Group,Assigned Group ID")
317
-
318
- if (remedyResult && remedyResult.data && Array.isArray(remedyResult.data)) {
319
- const data = remedyResult.data;
320
- let entry = 0;
321
- if (data.length > 1) {
322
- entry = data.length - 2;
323
- }
324
-
325
- if (data[entry] && data[entry].hasOwnProperty("Assigned Group ID")) {
326
- requestData['assignedGroup'] = data[entry]['Assigned Group ID'];
327
- } else {
328
- reject("could not find previous group. automatic re-ssignement failed. set assigendGroup manually")
316
+ const remedyOptions = {
317
+ limit: 1,
318
+ sort: {
319
+ "Last Date Duration Calculated": -1
329
320
  }
330
-
321
+ }
322
+
323
+ const remedyResult = await adapter.remedy.search("HPD:Help Desk Assignment Log", `'Incident Number' = "${globalScriptParams.id}"`, "Submit Date, Assigned Support Company, Assigned Support Organization, Assigned Group, Assigned Group ID", remedyOptions);
324
+
325
+ if (remedyResult && remedyResult.data && Array.isArray(remedyResult.data) && remedyResult.data.length > 0) {
326
+ const prevGroupData = remedyResult.data[0];
327
+ requestData.assignedGroup = prevGroupData['Assigned Group ID'];
328
+ requestData.assignedCompany = prevGroupData['Assigned Support Company'];
329
+ requestData.assignedSupportOrg = prevGroupData['Assigned Support Organization'];
330
+ requestData.assignedGroupName = prevGroupData['Assigned Group'];
331
+ } else {
332
+ reject("could not find previous group. automatic re-ssignement failed. set assigendGroup manually")
331
333
  }
332
334
  }
333
335
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manyos/smileconnect-api",
3
- "version": "1.61.1",
3
+ "version": "1.63.0",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  "cors": "^2.8.4",
20
20
  "dotenv": "^4.0.0",
21
21
  "express": "^4.17.1",
22
- "express-fileupload": "^1.2.1",
22
+ "express-fileupload": "^1.3.1",
23
23
  "express-rate-limit": "^5.2.6",
24
24
  "express-request-id": "^1.4.1",
25
25
  "express-validator": "^6.10.1",
@@ -72,6 +72,19 @@ function eventQueueHandler(req, res, next) {
72
72
  //write to eventQueue if provided
73
73
  if (req.eventData) {
74
74
  const eventData = req.eventData;
75
+ if (process.env.LOG_REQUEST && (process.env.LOG_REQUEST === true || process.env.LOG_REQUEST.toLowerCase() === 'true')) {
76
+ if (!eventData.jsonData) {
77
+ eventData.jsonData = {};
78
+ }
79
+ eventData.jsonData['req'] = {
80
+ headers: req.headers,
81
+ body: req.body
82
+ }
83
+ // remove auth header
84
+ if (eventData.jsonData.req && eventData.jsonData.req.headers && eventData.jsonData.req.headers.authorization) {
85
+ eventData.jsonData.req.headers.authorization = '*** REMOVED ***';
86
+ }
87
+ }
75
88
  eventLog.createSuccessLog(
76
89
  req.id,
77
90
  req.user.config.clientId,