@manyos/smileconnect-api 1.52.2 → 1.52.4

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/conf/clients.json CHANGED
@@ -233,7 +233,8 @@
233
233
  "Support Group ID 2",
234
234
  "Customer Person ID",
235
235
  "Requested By Person ID",
236
- "Change Target Date"
236
+ "Change Target Date",
237
+ "ServiceCI_ReconID"
237
238
  ],
238
239
  "constants": [
239
240
  {
package/conf/mapping.json CHANGED
@@ -157,6 +157,10 @@
157
157
  {
158
158
  "oldName": "Change Target Date",
159
159
  "newName": "changeTargetDate"
160
+ },
161
+ {
162
+ "oldName": "ServiceCI_ReconID",
163
+ "newName": "serviceReconId"
160
164
  }
161
165
  ],
162
166
  "person": [
@@ -237,6 +241,10 @@
237
241
  {
238
242
  "oldName": "Detailed Description",
239
243
  "newName": "detailedDescription"
244
+ },
245
+ {
246
+ "oldName": "ServiceCI_ReconID",
247
+ "newName": "serviceReconId"
240
248
  }
241
249
  ],
242
250
  "changeWorklog": [
@@ -394,12 +394,23 @@ async function getOppositeAssocTypeByCode(assocCode) {
394
394
  });
395
395
  }
396
396
 
397
- function doesCIRelationExists(ticketRelations, newRelation) {
397
+ function doesCIRelationExists(ticketRelations, newRelation, keepCIs) {
398
398
  log.debug('check for relation old', ticketRelations)
399
399
  log.debug('check for relation new', newRelation)
400
400
  const relationFound = ticketRelations.find(relation => {
401
- return ((relation.ciId === newRelation.ciId || relation.ciId === newRelation.ciReconId || relation.ciReconId === newRelation.ciId) &&
402
- relation.relationType === newRelation.relationType);
401
+ let found = (relation.ciId === newRelation.ciId || relation.ciId === newRelation.ciReconId || relation.ciReconId === newRelation.ciId) && relation.relationType === newRelation.relationType
402
+ //check keepCIs only if not found
403
+ log.debug('relation found', found)
404
+ if (!found && keepCIs && Array.isArray(keepCIs)) {
405
+ log.debug('keep CI check', keepCIs)
406
+ keepCIs.forEach(keepCI => {
407
+ if (newRelation.ciId === keepCI || newRelation.ciReconId === keepCI) {
408
+ found = true
409
+ log.debug('Relation found in Keep', keepCI, found)
410
+ }
411
+ })
412
+ }
413
+ return found
403
414
  });
404
415
  if (relationFound) {
405
416
  return true;
@@ -421,6 +432,7 @@ function doesTicketRelationExists(ticketRelations, newRelation) {
421
432
  }
422
433
 
423
434
  async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
435
+ // Wenn CIs vom Löschen ausgeschlossen werden sollen, dann kann unter relations.keepCIs ein Array mit Recon/InstanceId gesetzt werden.
424
436
  log.debug('Checker', {ticketConfig, userConfig, ticketId, relations});
425
437
  // Remove Ticket Relations if task
426
438
  if (ticketConfig.assocTicketType === 'Task') {
@@ -436,7 +448,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
436
448
  if (relations.ciRelations && Array.isArray(relations.ciRelations)) {
437
449
  for (x=0; x<relations.ciRelations.length; x++) {
438
450
  const relation = relations.ciRelations[x];
439
- const relationsExists = doesCIRelationExists(existingRelations, relation);
451
+ const relationsExists = doesCIRelationExists(existingRelations, relation, relations.keepCIs);
440
452
  log.debug('createRelation, already exists', relation, relationsExists);
441
453
  if (!relationsExists) {
442
454
  await createTicketCIRelation(ticketConfig, ticketId, relation.ciId, relation.relationType);
@@ -447,9 +459,9 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
447
459
  if (existingRelations && Array.isArray(existingRelations)) {
448
460
  for (x=0; x<existingRelations.length; x++) {
449
461
  const relation = existingRelations[x];
450
- const shouldRelationsExists = doesCIRelationExists(relations.ciRelations, relation);
462
+ const shouldRelationsExists = doesCIRelationExists(relations.ciRelations, relation, relations.keepCIs);
451
463
  log.debug('deleteRelation, already exists', relation, shouldRelationsExists);
452
- if (!shouldRelationsExists) {
464
+ if (shouldRelationsExists !== true) {
453
465
  await deleteTicketCIRelation(ticketConfig, ticketId, relation.ciId);
454
466
  }
455
467
  }
@@ -21,7 +21,7 @@ function getTickets(ticketConfig, config, includeString, customOptions, globalSc
21
21
 
22
22
  async function createTicket(ticketConfig, clientConfig, data, globalScriptParams) {
23
23
  const scripts = clientConfig[ticketConfig.requestType].scripts.POST;
24
-
24
+ const relations = data.relations || {}
25
25
  //run preScripts
26
26
  if (scripts && scripts.preMapping) {
27
27
  await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId);
@@ -51,6 +51,14 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
51
51
  if (resultInterfaceCreate.data && Array.isArray(resultInterfaceCreate.data) && resultInterfaceCreate.data.length && resultInterfaceCreate.data[0][ticketConfig.ticketIdField]) {
52
52
  const ticketId = resultInterfaceCreate.data[0][ticketConfig.ticketIdField];
53
53
  globalScriptParams.id = ticketId
54
+
55
+ //do relation stuff here
56
+ //keep businessService CI Relation
57
+ if (data[ticketConfig.businessServiceReconIdField] && relations) {
58
+ relations.keepCIs = [data[ticketConfig.businessServiceReconIdField]]
59
+ }
60
+ await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, ticketId, relations);
61
+
54
62
  } else {
55
63
  log.error('Cannot create Ticket', resultInterfaceCreate);
56
64
  throw({message: 'Cannot create Ticket', details : resultInterfaceCreate});
@@ -275,6 +283,7 @@ async function getTicket(ticketConfig, config, id, mapping, includeString, globa
275
283
  async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams) {
276
284
  const scripts = clientConfig[ticketConfig.requestType].scripts.PUT;
277
285
  const fields = clientConfig[ticketConfig.requestType].fields
286
+ const relations = ticketData.relations || {}
278
287
 
279
288
  //run preScripts
280
289
  if (scripts && scripts.preMapping) {
@@ -283,8 +292,8 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
283
292
 
284
293
  log.debug(clientConfig[ticketConfig.requestType]);
285
294
  const myClientConfig = {};
286
- myClientConfig[ticketConfig.requestType] = {baseQuery: clientConfig[ticketConfig.requestType].baseQuery, fields: [1]};
287
- const myMapping = [{"oldName":ticketConfig.requestIdField, "newName" : "internalId"}];
295
+ myClientConfig[ticketConfig.requestType] = {baseQuery: clientConfig[ticketConfig.requestType].baseQuery, fields: [1, ticketConfig.businessServiceReconIdField]};
296
+ const myMapping = [{"oldName":ticketConfig.requestIdField, "newName" : "internalId"}, {"oldName":ticketConfig.businessServiceReconIdField, "newName" : "serviceReconId"}];
288
297
 
289
298
  const mapping = config.getMapping(ticketConfig.requestType);
290
299
 
@@ -298,12 +307,16 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
298
307
 
299
308
  const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping, undefined, globalScriptParams);
300
309
  log.debug('Ticket to Update', ticket);
310
+ //keep businessService CI Relation
311
+ if (ticket && ticket.data && ticket.data.serviceReconId && relations) {
312
+ relations.keepCIs = [ticket.data.serviceReconId]
313
+ }
301
314
  //todo Abfangen wenn getTicket nichts liefert.
302
315
  const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData);
303
-
316
+ await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, id, relations);
304
317
  //run afterExecution
305
318
  if (scripts && scripts.afterExecution) {
306
- await scriptController.runScripts(scripts.afterExecution, ticketData, clientConfig.clientId);
319
+ await scriptController.runScripts(scripts.afterExecution, ticketData, clientConfig.clientId, globalScriptParams);
307
320
  }
308
321
 
309
322
  return update;
package/docs/releases.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## API
4
4
 
5
+ ### 1.52.4 - 17.11.11
6
+ Fix issue: Keep invisible ServiceCi Relation in Tickets during CI Relation Update
7
+
8
+ ### 1.52.3 - 16.11.11
9
+ Fix issue: Add globalParams to update ticket
10
+
5
11
  ### 1.52.2 - 16.11.11
6
12
  Fix issue: Inbound Events Names missed 'Worklog' for Task Worklogs
7
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manyos/smileconnect-api",
3
- "version": "1.52.2",
3
+ "version": "1.52.4",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -62,12 +62,12 @@ module.exports = (function() {
62
62
  req.errorStatus = 422;
63
63
  next(errors.array());
64
64
  } else {
65
- const relations = req.body.data.relations;
65
+ //const relations = req.body.data.relations;
66
66
  ticketController.createTicket(req.ticketConfig, req.user.config, req.body.data, req.globalScriptParams).then(async function (createResult) {
67
67
  const ticketId = createResult.data[0][req.ticketConfig.ticketIdField];
68
68
  eventLog.setTicketId(req, ticketId);
69
69
  req.eventData.ticketNumber = ticketId;
70
- await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, ticketId, relations);
70
+ //await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, ticketId, relations);
71
71
  getTicket(req, res, next, req.user.config, ticketId, null, includeString);
72
72
  }).catch(function (reason) {
73
73
  next(reason);
@@ -171,7 +171,7 @@ module.exports = (function() {
171
171
  const relations = req.body.data.relations;
172
172
  ticketController.updateTicket(req.ticketConfig, req.user.config, id, req.body.data, req.globalScriptParams)
173
173
  .then(async function (updateResult) {
174
- await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, id, relations);
174
+ //await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, id, relations);
175
175
  getTicket(req, res, next, req.user.config, id, null, includeString);
176
176
  }).catch(function (reason) {
177
177
  next(reason);
package/util/config.js CHANGED
@@ -544,6 +544,7 @@ const ticketConfig = {
544
544
  "requestIdField": "Request ID",
545
545
  "requestType": "workOrder",
546
546
  "ticketIdField": "WorkOrder_ID",
547
+ "businessServiceReconIdField": "CI_ReconId",
547
548
  "requestTypeWorkLog": "workOrderWorklog",
548
549
  "requestTemplate": "workOrderTemplate",
549
550
  "baseURI": "/v1/workorders",
@@ -562,6 +563,7 @@ const ticketConfig = {
562
563
  "requestIdField": "Entry ID",
563
564
  "requestType": "incident",
564
565
  "ticketIdField": "Incident Number",
566
+ businessServiceReconIdField: "ServiceCI_ReconID",
565
567
  "requestTypeWorkLog": "incidentWorklog",
566
568
  "requestTemplate": "incidentTemplate",
567
569
  "baseURI": "/v1/incidents",
@@ -580,6 +582,7 @@ const ticketConfig = {
580
582
  "requestIdField": "Request ID",
581
583
  "requestType": "change",
582
584
  "ticketIdField": "Infrastructure Change Id",
585
+ businessServiceReconIdField: "ServiceCI_ReconID",
583
586
  "requestTypeWorkLog": "changeWorklog",
584
587
  "requestTemplate": "changeTemplate",
585
588
  "baseURI": "/v1/changes",
@@ -598,6 +601,7 @@ const ticketConfig = {
598
601
  "requestIdField": "Sys-Problem Investigation ID",
599
602
  "requestType": "problem",
600
603
  "ticketIdField": "Problem Investigation ID",
604
+ businessServiceReconIdField: "ServiceCI_ReconID",
601
605
  "requestTypeWorkLog": "problemWorklog",
602
606
  "requestTemplate": "problemTemplate",
603
607
  "baseURI": "/v1/problems",