@manyos/smileconnect-api 1.30.2 → 1.31.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.
@@ -0,0 +1,16 @@
1
+ const adapterParams = {
2
+ remedy: {
3
+ type: "remedy",
4
+ arServer: env.AR_SERVER,
5
+ arUser: env.AR_USER,
6
+ arPassword: env.AR_PASSWORD,
7
+ arPort: env.AR_PORT,
8
+ rapiUri: env.BASEURL,
9
+ cacheTime: env.AR_CACHE_TTL || 300,
10
+ limitDefault: env.LIMIT_DEFAULT || 100,
11
+ limitMax: env.LIMIT_MAX
12
+ }
13
+ };
14
+
15
+ // noinspection JSAnnotator
16
+ return adapterParams;
package/conf/clients.json CHANGED
@@ -370,7 +370,7 @@
370
370
  "script2"
371
371
  ],
372
372
  "postMapping": [
373
- "script3"
373
+ "p2"
374
374
  ],
375
375
  "afterExecution": [
376
376
  "script3"
@@ -1 +1,12 @@
1
+ const weatherResponse = await fetch('https://api.openweathermap.org/data/2.5/weather?q=Klagenfurt&appid=bab78e38577c73eeb20ca872998a43dd');
2
+ const remedyResult = await adapter.remedy.search("CTM:People", `'Remedy Login ID' = "Allen"`, "Full Name, Remedy Login ID")
3
+
4
+ if (remedyResult) {
5
+ requestData.remedyQueryResult = remedyResult;
6
+ }
7
+
8
+ if (weatherResponse) {
9
+ requestData.weather = await weatherResponse.json()
10
+ }
11
+
1
12
  resolve();
@@ -1,16 +1,22 @@
1
1
  const path = require('path');
2
2
  const log = require('@manyos/logger').setupLog('SMILEcatalog_' + path.basename(__filename));
3
-
3
+ const adapterFoundation = require('@manyos/adapter-foundation');
4
4
  const fs = require('fs');
5
5
 
6
6
  const basePath = 'conf';
7
7
  const basePathGlobalScripts = basePath + '/scripts';
8
8
 
9
+ const fetch = require('node-fetch');
10
+
9
11
  const {getClients} = require('../util/config');
10
12
 
11
13
  require('dotenv').config();
12
14
  const {NodeVM} = require('vm2');
13
15
 
16
+ const adapterConfigScript = fs.readFileSync('conf/adapterConfig.js',{encoding: 'utf8'});
17
+
18
+ const adapter = adapterFoundation.getAdapter(adapterConfigScript);
19
+
14
20
  //const adapter = require('../util/adapter').getAdapter();
15
21
 
16
22
  function recFindByExt(base,ext,files,result) {
@@ -69,9 +75,11 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
69
75
  const sandbox = {
70
76
  requestData,
71
77
  params,
78
+ adapter,
72
79
  log,
73
80
  script:executeScriptByScript,
74
- env: process.env
81
+ env: process.env,
82
+ fetch:fetch
75
83
  };
76
84
 
77
85
  sandbox.executedByScript = executedByScript === true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manyos/smileconnect-api",
3
- "version": "1.30.2",
3
+ "version": "1.31.0",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -11,6 +11,7 @@
11
11
  "author": "Robert Hannemann",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
+ "@manyos/adapter-foundation": "^1.1.1",
14
15
  "@manyos/logger": "^1.3.0",
15
16
  "bunyan": "^1.8.15",
16
17
  "bunyan-express-serializer": "^1.0.0",
@@ -25,6 +26,7 @@
25
26
  "moment": "^2.29.1",
26
27
  "mongoose": "^5.12.3",
27
28
  "node-cache": "^4.2.1",
29
+ "node-fetch": "^2.6.1",
28
30
  "only": "0.0.2",
29
31
  "p-limit": "^2.3.0",
30
32
  "passport": "^0.4.1",
@@ -162,7 +162,7 @@ module.exports = (function() {
162
162
  }
163
163
  const reqPublic = req.body.data.isPublic;
164
164
  let isPublic = false;
165
- if (reqPublic != null && reqPublic != undefined && reqPublic.toLowerCase() === 'true') {
165
+ if (reqPublic != null && reqPublic != undefined && reqPublic === true) {
166
166
  isPublic = true;
167
167
  }
168
168