@manyos/smileconnect-api 1.30.0 → 1.30.2

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.
@@ -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) {
@@ -4,6 +4,8 @@ const log = require('@manyos/logger').setupLog('SMILEconnect_' + path.basename(_
4
4
  const orgdata = require('../controller/orgdataController');
5
5
  const cmdbObjectController = require('../controller/cmdbobjectController');
6
6
  const ticketCiRelation = require('./ticketCIRelationController');
7
+ const ticketController = require('./ticketController');
8
+ const config = require('../util/config');
7
9
 
8
10
  async function getRelatedObjects(req, res, next) {
9
11
  log.debug('include Data', req.includeArray);
@@ -85,7 +87,8 @@ async function getRelatedObjects(req, res, next) {
85
87
  for (x=0; x < incidentArray.length; x++) {
86
88
  const id = incidentArray[x];
87
89
  log.debug('searchIncident', id);
88
- const result = await incidentController.getIncident(clientConfig, id);
90
+ const ticketConfig = config.ticketConfig["incidents"];
91
+ const result = await ticketController.getTicket(ticketConfig, clientConfig, id);
89
92
  if (result && result.data) {
90
93
  incidents.push(result.data);
91
94
  }
@@ -100,7 +103,8 @@ async function getRelatedObjects(req, res, next) {
100
103
  for (x=0; x < ticketIdArray.length; x++) {
101
104
  const id = ticketIdArray[x];
102
105
  log.debug('searchWorkOrder', id);
103
- const result = await workOrderController.getWorkOrder(clientConfig, id);
106
+ const ticketConfig = config.ticketConfig["workorders"];
107
+ const result = await ticketController.getTicket(ticketConfig, clientConfig, id);
104
108
  if (result && result.data) {
105
109
  tickets.push(result.data);
106
110
  }
@@ -115,7 +119,8 @@ async function getRelatedObjects(req, res, next) {
115
119
  for (x=0; x < ticketIdArray.length; x++) {
116
120
  const id = ticketIdArray[x];
117
121
  log.debug('searchProblem', id);
118
- const result = await problemController.getProblem(clientConfig, id);
122
+ const ticketConfig = config.ticketConfig["problems"];
123
+ const result = await ticketController.getTicket(ticketConfig, clientConfig, id);
119
124
  if (result && result.data) {
120
125
  tickets.push(result.data);
121
126
  }
@@ -130,7 +135,8 @@ async function getRelatedObjects(req, res, next) {
130
135
  for (x=0; x < ticketIdArray.length; x++) {
131
136
  const id = ticketIdArray[x];
132
137
  log.debug('searchChange', id);
133
- const result = await changeController.getChange(clientConfig, id);
138
+ const ticketConfig = config.ticketConfig["changes"];
139
+ const result = await ticketController.getTicket(ticketConfig, clientConfig, id);
134
140
  if (result && result.data) {
135
141
  tickets.push(result.data);
136
142
  }
@@ -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.0",
3
+ "version": "1.30.2",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -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();