@manyos/smileconnect-api 1.69.1 → 1.70.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 +2 -2
- package/conf/mapping.json +1 -1
- package/controller/cmdbobjectController.js +40 -14
- package/docs/releases.md +3 -0
- package/package.json +1 -1
- package/util/responsehandler.js +2 -2
package/app.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
const app = require('express')();
|
|
3
3
|
|
|
4
|
+
require('dotenv').config();
|
|
5
|
+
|
|
4
6
|
const path = require('path');
|
|
5
7
|
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
6
8
|
|
|
@@ -57,8 +59,6 @@ https.globalAgent.maxSockets = maxHTTPSockets;
|
|
|
57
59
|
|
|
58
60
|
log.info('Set max HTTP(S) Sockets to', maxHTTPSockets);
|
|
59
61
|
|
|
60
|
-
require('dotenv').config();
|
|
61
|
-
|
|
62
62
|
// The signals we want to handle
|
|
63
63
|
// NOTE: although it is tempting, the SIGKILL signal (9) cannot be intercepted and handled
|
|
64
64
|
var signals = {
|
package/conf/mapping.json
CHANGED
|
@@ -41,6 +41,7 @@ function getCmdbObjects(config, category, ciIds, includeString, options, globalS
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function getCIRelations(clientConfig, id) {
|
|
44
|
+
log.error('Search relations with', id);
|
|
44
45
|
const query = `('Source.InstanceId'=\"${id}\" OR 'Destination.InstanceId'=\"${id}\")AND('MarkAsDeleted'=$NULL$ OR 'MarkAsDeleted'=\"No\")`;
|
|
45
46
|
return cmdbCache.get(query, function () {
|
|
46
47
|
return new Promise((resolve, reject) => {
|
|
@@ -131,11 +132,35 @@ function queryCMDBObject(clientConfig, query, customFields, customOptions, inclu
|
|
|
131
132
|
fields = customFields;
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
const deleteFields = [];
|
|
136
|
+
|
|
137
|
+
const internalFieldsRequired = ['Class Id', 'Instance Id', 'Reconciliation Identity'];
|
|
138
|
+
|
|
139
|
+
internalFieldsRequired.forEach(internalRequiredField => {
|
|
140
|
+
if (!fields.includes(internalRequiredField)) {
|
|
141
|
+
fields.push(internalRequiredField);
|
|
142
|
+
deleteFields.push(internalRequiredField);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
/*
|
|
134
147
|
if (!fields.includes('Class Id') && includeArray.includes('classAttributes')) {
|
|
135
148
|
fields.push('Class Id');
|
|
136
149
|
deleteClassId = true;
|
|
137
150
|
log.debug('Add classId');
|
|
151
|
+
deleteFields.push('Class Id');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (!fields.includes('Instance Id')) {
|
|
155
|
+
fields.push('Instance Id');
|
|
156
|
+
deleteFields.push('Instance Id');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (!fields.includes('Reconciliation Identity')) {
|
|
160
|
+
fields.push('Reconciliation Identity');
|
|
161
|
+
deleteFields.push('Reconciliation Identity');
|
|
138
162
|
}
|
|
163
|
+
*/
|
|
139
164
|
|
|
140
165
|
const options = {
|
|
141
166
|
...clientConfig.options, ...customOptions
|
|
@@ -158,7 +183,7 @@ function queryCMDBObject(clientConfig, query, customFields, customOptions, inclu
|
|
|
158
183
|
if (result && result.data && result.data.length) {
|
|
159
184
|
let x = 0;
|
|
160
185
|
for (x=0; x< result.data.length; x++) {
|
|
161
|
-
const cmdbObject = await handleCMDBObjectResult(result.data[x], mapping, clientConfig, includeArray, globalRelationObjects,
|
|
186
|
+
const cmdbObject = await handleCMDBObjectResult(result.data[x], mapping, clientConfig, includeArray, globalRelationObjects, deleteFields, globalScriptParams);
|
|
162
187
|
cmdbObjects.push(cmdbObject);
|
|
163
188
|
}
|
|
164
189
|
}
|
|
@@ -170,12 +195,13 @@ function queryCMDBObject(clientConfig, query, customFields, customOptions, inclu
|
|
|
170
195
|
});
|
|
171
196
|
}
|
|
172
197
|
|
|
173
|
-
async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, includeArray, globalRelationObjects,
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
198
|
+
async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, includeArray, globalRelationObjects, deleteFields, globalScriptParams) {
|
|
199
|
+
const internalReconId = cmdbObject['Reconciliation Identity'];
|
|
200
|
+
const internalId = cmdbObject['Instance Id'];
|
|
201
|
+
|
|
202
|
+
deleteFields.forEach(internalRequiredField => {
|
|
203
|
+
delete cmdbObject[internalRequiredField];
|
|
204
|
+
});
|
|
179
205
|
|
|
180
206
|
const scripts = clientConfig[CMDBOBJECT].scripts.GET;
|
|
181
207
|
//const fields = clientConfig[ticketConfig.requestType].fields
|
|
@@ -203,30 +229,30 @@ async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, include
|
|
|
203
229
|
cmdbObject.relations = {};
|
|
204
230
|
|
|
205
231
|
if (includeArray.includes('ciRelations')) {
|
|
206
|
-
const relations = await getCIRelations(clientConfig,
|
|
232
|
+
const relations = await getCIRelations(clientConfig, internalId);
|
|
207
233
|
cmdbObject.relations.ciRelations = relations;
|
|
208
234
|
}
|
|
209
235
|
if (includeArray.includes('ticketRelations')) {
|
|
210
|
-
const relations = await ticketCIRelationController.getCITicketRelations(
|
|
236
|
+
const relations = await ticketCIRelationController.getCITicketRelations(internalId, undefined, log);
|
|
211
237
|
cmdbObject.relations.ticketRelations = relations;
|
|
212
238
|
}
|
|
213
239
|
if (includeArray.includes('personRelations')) {
|
|
214
|
-
const relations = await getPeopleRelations(clientConfig,
|
|
240
|
+
const relations = await getPeopleRelations(clientConfig, internalReconId, 'People');
|
|
215
241
|
cmdbObject.relations.personRelations = relations;
|
|
216
242
|
}
|
|
217
243
|
|
|
218
244
|
if (includeArray.includes('supportGroupRelations')) {
|
|
219
|
-
const relations = await getPeopleRelations(clientConfig,
|
|
245
|
+
const relations = await getPeopleRelations(clientConfig, internalReconId, 'Support Group');
|
|
220
246
|
cmdbObject.relations.supportGroupRelations = relations;
|
|
221
247
|
}
|
|
222
248
|
|
|
223
249
|
if (includeArray.includes('organisationRelations')) {
|
|
224
|
-
const relations = await getPeopleRelations(clientConfig,
|
|
250
|
+
const relations = await getPeopleRelations(clientConfig, internalReconId, 'People Organization');
|
|
225
251
|
cmdbObject.relations.organisationRelations = relations;
|
|
226
252
|
}
|
|
227
253
|
|
|
228
254
|
if (includeArray.includes('classAttributes')) {
|
|
229
|
-
const classAttributes = await getCMDBObjectClassAttributes(
|
|
255
|
+
const classAttributes = await getCMDBObjectClassAttributes(internalId, classId, clientConfig);
|
|
230
256
|
cmdbObject = {
|
|
231
257
|
...cmdbObject, ...classAttributes
|
|
232
258
|
}
|
|
@@ -450,4 +476,4 @@ module.exports = {
|
|
|
450
476
|
applyMapping,
|
|
451
477
|
updateCmdbObject,
|
|
452
478
|
createCmdbObject
|
|
453
|
-
};
|
|
479
|
+
};
|
package/docs/releases.md
CHANGED
package/package.json
CHANGED
package/util/responsehandler.js
CHANGED
|
@@ -81,7 +81,7 @@ function eventQueueHandler(req, res, next) {
|
|
|
81
81
|
if (!eventData.jsonData) {
|
|
82
82
|
eventData.jsonData = {};
|
|
83
83
|
}
|
|
84
|
-
eventData.
|
|
84
|
+
eventData.jsonDas= {
|
|
85
85
|
headers: req.headers,
|
|
86
86
|
body: req.body
|
|
87
87
|
}
|
|
@@ -127,4 +127,4 @@ function throwSchemaError(errors) {
|
|
|
127
127
|
|
|
128
128
|
module.exports = {
|
|
129
129
|
logErrors, errorHandler, eventQueueHandler, logRequest, throwSchemaError
|
|
130
|
-
};
|
|
130
|
+
};
|