@manyos/smileconnect-api 1.30.1 → 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();
@@ -20,7 +20,7 @@ function getRandomId() {
20
20
  return v4();
21
21
  }
22
22
 
23
- function getCmdbObjects(config, category, ciIds, includeString) {
23
+ function getCmdbObjects(config, category, ciIds, includeString, options) {
24
24
  let query = '1=1';
25
25
  if (category)
26
26
  query = `'Category' = \"${category}\"`;
@@ -36,7 +36,7 @@ function getCmdbObjects(config, category, ciIds, includeString) {
36
36
  query = query + ciQuery + ')';
37
37
  log.error('query', query);
38
38
  }
39
- return queryCMDBObject(config, query, null, null, includeString);
39
+ return queryCMDBObject(config, query, null, options, includeString);
40
40
  }
41
41
 
42
42
  function getCIRelations(clientConfig, id) {
@@ -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;
@@ -169,12 +169,12 @@ async function queryWorklogs(ticketConfig, clientConfig, query, mapping) {
169
169
  const element = result.data[x];
170
170
  //run preScripts
171
171
  if (scripts && scripts.preMapping) {
172
- await scriptController.runScripts(scripts.preMapping, data);
172
+ await scriptController.runScripts(scripts.preMapping, result.data);
173
173
  }
174
174
  applyMapping(element, mapping, 'Entry ID');
175
175
  //run postScripts
176
176
  if (scripts && scripts.postMapping) {
177
- await scriptController.runScripts(scripts.postMapping, data);
177
+ await scriptController.runScripts(scripts.postMapping, result.data);
178
178
  }
179
179
  }
180
180
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manyos/smileconnect-api",
3
- "version": "1.30.1",
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",
@@ -83,7 +83,18 @@ module.exports = (function () {
83
83
  if (typeof ciIds === 'string')
84
84
  ciIds = ciIds.split(',');
85
85
 
86
- cmdbobjects.getCmdbObjects(req.user.config, category, ciIds, includeString).then(function (result) {
86
+ const options = {};
87
+ const limit = req.query.limit;
88
+ if (limit != null && limit != undefined) {
89
+ options.limit = Number.parseInt(limit);
90
+ }
91
+
92
+ const offset = req.query.offset;
93
+ if (offset != null && offset != undefined) {
94
+ options.offset = Number.parseInt(offset);
95
+ }
96
+
97
+ cmdbobjects.getCmdbObjects(req.user.config, category, ciIds, includeString, options).then(function (result) {
87
98
  log.debug('result', result);
88
99
  req.includeObjectsList = result.included;
89
100
  req.result = {data:result.data || []};
@@ -108,7 +108,18 @@ module.exports = (function() {
108
108
  CONSTANTS.EVENT_ACTION_QUERY,
109
109
  CONSTANTS.FORM_ORGANISATION
110
110
  );
111
- orgdata.getOrganisations(req.user.config, null, include).then(function (result) {
111
+ const options = {};
112
+ const limit = req.query.limit;
113
+ if (limit != null && limit != undefined) {
114
+ options.limit = Number.parseInt(limit);
115
+ }
116
+
117
+ const offset = req.query.offset;
118
+ if (offset != null && offset != undefined) {
119
+ options.offset = Number.parseInt(offset);
120
+ }
121
+
122
+ orgdata.getOrganisations(req.user.config, null, include, options).then(function (result) {
112
123
  req.includeObjectsList = result.included;
113
124
  req.result = {data:result.data || {}};
114
125
  next();
@@ -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