@manyos/smileconnect-api 1.63.3 → 1.64.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 +11 -3
- package/conf/clients.json +8 -33
- package/controller/cmdbobjectController.js +2 -2
- package/controller/customFormController.js +1 -1
- package/controller/eventLogController.js +6 -8
- package/controller/orgdataController.js +1 -1
- package/controller/relatedObjectsController.js +3 -1
- package/controller/scriptController.js +2 -2
- package/controller/taskController.js +2 -2
- package/controller/templateController.js +1 -1
- package/controller/ticketCIRelationController.js +31 -22
- package/controller/ticketController.js +26 -22
- package/controller/ticketWorkLogController.js +1 -1
- package/docs/releases.md +6 -0
- package/package.json +1 -1
- package/routes/appConfigRoutes.js +1 -1
- package/routes/ciRelationRoutes.js +1 -1
- package/routes/cmdbObjectRoutes.js +1 -1
- package/routes/customFormRoutes.js +1 -1
- package/routes/organisationRoutes.js +1 -1
- package/routes/peopleRelationRoutes.js +1 -1
- package/routes/personRoutes.js +1 -1
- package/routes/scriptRoutes.js +1 -1
- package/routes/supportgroupRoutes.js +1 -1
- package/routes/taskRoutes.js +1 -1
- package/routes/templateRoutes.js +1 -1
- package/routes/ticketRoutes.js +16 -6
- package/routes/ticketWorkLogRoutes.js +1 -1
- package/test/changeTest.js +2 -2
- package/test/incidentTest.js +2 -2
- package/test/problemTest.js +2 -2
- package/test/workorderTest.js +2 -2
- package/util/arquery.js +16 -5
- package/util/auth.js +1 -1
- package/util/cache.service.js +1 -1
- package/util/config.js +1 -1
- package/util/eventLog.js +16 -0
- package/util/mappingUtil.js +11 -7
- package/util/paramHelper.js +1 -1
- package/util/relationUtil.js +1 -1
- package/util/responsehandler.js +11 -3
- package/util/searchUtil.js +1 -1
- package/util/ticketValidationUtil.js +1 -1
- package/screwdriver.yaml +0 -52
package/app.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const app = require('express')();
|
|
3
3
|
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const log = require('@manyos/logger').setupLog('
|
|
5
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
6
6
|
|
|
7
7
|
const passport = require('passport');
|
|
8
8
|
const JwtStrategy = require('passport-jwt').Strategy,
|
|
@@ -202,6 +202,12 @@ app.use(fileUpload({
|
|
|
202
202
|
debug: true
|
|
203
203
|
}));
|
|
204
204
|
|
|
205
|
+
//add initial logger
|
|
206
|
+
app.use(function (req, res, next) {
|
|
207
|
+
req.log = log.child({requestId: req.id});
|
|
208
|
+
next();
|
|
209
|
+
});
|
|
210
|
+
|
|
205
211
|
//global check for compatibility
|
|
206
212
|
app.use(function (req, res, next) {
|
|
207
213
|
if (req.query.include && req.query.includeObjects) {
|
|
@@ -268,9 +274,11 @@ app.use(function (req, res, next) {
|
|
|
268
274
|
app.use(function (req, res, next) {
|
|
269
275
|
req.globalScriptParams = {
|
|
270
276
|
query: req.query,
|
|
271
|
-
user: req.user
|
|
272
|
-
log: log.child({req_id: req.id, clientId:req.clientId}, true)
|
|
277
|
+
user: req.user
|
|
273
278
|
}
|
|
279
|
+
req.log = req.log.child({
|
|
280
|
+
clientId: req.clientId
|
|
281
|
+
});
|
|
274
282
|
// Für Scripte einen globalen parameter bereitstellen, der den org. Body enthält. Damit hat man auch noch in Post Scripten Zugriff auf customAttributes die beim Mapping entfernt werden.
|
|
275
283
|
if (req.body) {
|
|
276
284
|
try {
|
package/conf/clients.json
CHANGED
|
@@ -1989,7 +1989,6 @@
|
|
|
1989
1989
|
"clientLimit": 100000,
|
|
1990
1990
|
"impersonateUser": "rhannemann",
|
|
1991
1991
|
"allowDynamicImpersonate": true,
|
|
1992
|
-
"translateSelectionFieldsX": false,
|
|
1993
1992
|
"translateSelectionFields": true
|
|
1994
1993
|
},
|
|
1995
1994
|
"custom_Sample:Enrollments": {
|
|
@@ -2101,9 +2100,7 @@
|
|
|
2101
2100
|
},
|
|
2102
2101
|
"PUT": {
|
|
2103
2102
|
"preMapping": [],
|
|
2104
|
-
"postMapping": [
|
|
2105
|
-
"notfetchresult"
|
|
2106
|
-
]
|
|
2103
|
+
"postMapping": []
|
|
2107
2104
|
}
|
|
2108
2105
|
}
|
|
2109
2106
|
},
|
|
@@ -2299,9 +2296,7 @@
|
|
|
2299
2296
|
},
|
|
2300
2297
|
"PUT": {
|
|
2301
2298
|
"preMapping": [],
|
|
2302
|
-
"postMapping": [
|
|
2303
|
-
"notFetchResult"
|
|
2304
|
-
],
|
|
2299
|
+
"postMapping": [],
|
|
2305
2300
|
"afterExecution": []
|
|
2306
2301
|
},
|
|
2307
2302
|
"POST": {
|
|
@@ -2388,9 +2383,7 @@
|
|
|
2388
2383
|
"preMapping": [
|
|
2389
2384
|
"p2"
|
|
2390
2385
|
],
|
|
2391
|
-
"postMapping": [
|
|
2392
|
-
"notFetchResult"
|
|
2393
|
-
],
|
|
2386
|
+
"postMapping": [],
|
|
2394
2387
|
"afterExecution": [
|
|
2395
2388
|
"INC_CreateWorklog_OnCreate"
|
|
2396
2389
|
]
|
|
@@ -2437,10 +2430,6 @@
|
|
|
2437
2430
|
"name": "Urgency",
|
|
2438
2431
|
"value": "4000"
|
|
2439
2432
|
},
|
|
2440
|
-
{
|
|
2441
|
-
"name": "Status",
|
|
2442
|
-
"value": "0"
|
|
2443
|
-
},
|
|
2444
2433
|
{
|
|
2445
2434
|
"name": "Investigation Driver",
|
|
2446
2435
|
"value": "High Impact Incident"
|
|
@@ -2508,9 +2497,7 @@
|
|
|
2508
2497
|
"scripts": {
|
|
2509
2498
|
"POST": {
|
|
2510
2499
|
"preMapping": [],
|
|
2511
|
-
"postMapping": [
|
|
2512
|
-
"notFetchResult"
|
|
2513
|
-
],
|
|
2500
|
+
"postMapping": [],
|
|
2514
2501
|
"afterExecution": []
|
|
2515
2502
|
}
|
|
2516
2503
|
},
|
|
@@ -2578,25 +2565,17 @@
|
|
|
2578
2565
|
{
|
|
2579
2566
|
"name": "TaskType",
|
|
2580
2567
|
"value": "2000"
|
|
2581
|
-
},
|
|
2582
|
-
{
|
|
2583
|
-
"name": "Status",
|
|
2584
|
-
"value": "1000"
|
|
2585
2568
|
}
|
|
2586
2569
|
],
|
|
2587
2570
|
"scripts": {
|
|
2588
2571
|
"POST": {
|
|
2589
2572
|
"preMapping": [],
|
|
2590
|
-
"postMapping": [
|
|
2591
|
-
"notFetchResult"
|
|
2592
|
-
],
|
|
2573
|
+
"postMapping": [],
|
|
2593
2574
|
"afterExecution": []
|
|
2594
2575
|
},
|
|
2595
2576
|
"PUT": {
|
|
2596
2577
|
"preMapping": [],
|
|
2597
|
-
"postMapping": [
|
|
2598
|
-
"notFetchResult"
|
|
2599
|
-
],
|
|
2578
|
+
"postMapping": [],
|
|
2600
2579
|
"afterExecution": []
|
|
2601
2580
|
}
|
|
2602
2581
|
}
|
|
@@ -2625,16 +2604,12 @@
|
|
|
2625
2604
|
"scripts": {
|
|
2626
2605
|
"POST": {
|
|
2627
2606
|
"preMapping": [],
|
|
2628
|
-
"postMapping": [
|
|
2629
|
-
"notFetchResult"
|
|
2630
|
-
],
|
|
2607
|
+
"postMapping": [],
|
|
2631
2608
|
"afterExecution": []
|
|
2632
2609
|
},
|
|
2633
2610
|
"PUT": {
|
|
2634
2611
|
"preMapping": [],
|
|
2635
|
-
"postMapping": [
|
|
2636
|
-
"notFetchResult"
|
|
2637
|
-
],
|
|
2612
|
+
"postMapping": [],
|
|
2638
2613
|
"afterExecution": []
|
|
2639
2614
|
}
|
|
2640
2615
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -207,7 +207,7 @@ async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, include
|
|
|
207
207
|
cmdbObject.relations.ciRelations = relations;
|
|
208
208
|
}
|
|
209
209
|
if (includeArray.includes('ticketRelations')) {
|
|
210
|
-
const relations = await ticketCIRelationController.getCITicketRelations(cmdbObject.id);
|
|
210
|
+
const relations = await ticketCIRelationController.getCITicketRelations(cmdbObject.id, undefined, log);
|
|
211
211
|
cmdbObject.relations.ticketRelations = relations;
|
|
212
212
|
}
|
|
213
213
|
if (includeArray.includes('personRelations')) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('SMILEconnect_' + path.basename(__filename));
|
|
4
2
|
const arquery = require('../util/arquery');
|
|
5
3
|
const eventForm = 'MYS:SMILEconnect_QueueData';
|
|
6
4
|
|
|
7
|
-
function createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, status, errorMsg, jsonData, ticketNumber2, ticketNumber3) {
|
|
5
|
+
function createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, status, errorMsg, jsonData, ticketNumber2, ticketNumber3, eventLog) {
|
|
8
6
|
return new Promise((resolve, reject) => {
|
|
9
7
|
let enable = process.env.EVENTLOG_ENABLE;
|
|
10
8
|
if (enable != null && enable != undefined && enable.toLowerCase() == 'true') {
|
|
@@ -24,7 +22,7 @@ function createEventLog(smileId, client, ticketNumber, schemaName, eventName, ur
|
|
|
24
22
|
if (jsonData != null && jsonData != undefined) {
|
|
25
23
|
data['JsonValue'] = JSON.stringify(jsonData, null, 2);
|
|
26
24
|
}
|
|
27
|
-
arquery.createEntry(eventForm, data).then(function (result) {
|
|
25
|
+
arquery.createEntry(eventForm, data, undefined, eventLog).then(function (result) {
|
|
28
26
|
resolve(result);
|
|
29
27
|
}).catch(error => {
|
|
30
28
|
reject(error);
|
|
@@ -35,12 +33,12 @@ function createEventLog(smileId, client, ticketNumber, schemaName, eventName, ur
|
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
function createErrorLog(smileId, client, ticketNumber, schemaName, eventName, url, errorMsg, jsonData, ticketNumber2, ticketNumber3) {
|
|
39
|
-
return createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, 'Error', errorMsg, jsonData, ticketNumber2, ticketNumber3);
|
|
36
|
+
function createErrorLog(smileId, client, ticketNumber, schemaName, eventName, url, errorMsg, jsonData, ticketNumber2, ticketNumber3, eventLog) {
|
|
37
|
+
return createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, 'Error', errorMsg, jsonData, ticketNumber2, ticketNumber3, eventLog);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
function createSuccessLog(smileId, client, ticketNumber, schemaName, eventName, url, jsonData, ticketNumber2, ticketNumber3) {
|
|
43
|
-
return createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, 'Done', null, jsonData, ticketNumber2, ticketNumber3);
|
|
40
|
+
function createSuccessLog(smileId, client, ticketNumber, schemaName, eventName, url, jsonData, ticketNumber2, ticketNumber3, eventLog) {
|
|
41
|
+
return createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, 'Done', null, jsonData, ticketNumber2, ticketNumber3, eventLog);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
/*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
|
|
3
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const orgdata = require('../controller/orgdataController');
|
|
5
5
|
const cmdbObjectController = require('../controller/cmdbobjectController');
|
|
6
6
|
const ticketCiRelation = require('./ticketCIRelationController');
|
|
7
7
|
const ticketController = require('./ticketController');
|
|
8
8
|
const config = require('../util/config');
|
|
9
|
+
const {getEventLog} = require("../util/eventLog");
|
|
9
10
|
|
|
10
11
|
async function getRelatedObjects(req, res, next) {
|
|
12
|
+
const log = getEventLog(req.log, path.basename(__filename));
|
|
11
13
|
log.debug('include Data', req.includeArray);
|
|
12
14
|
log.debug('include Objects', req.includeObjectsList);
|
|
13
15
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const adapterFoundation = require('@manyos/adapter-foundation');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const { v4 } = require('uuid');
|
|
@@ -86,7 +86,7 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
|
|
|
86
86
|
requestData,
|
|
87
87
|
params,
|
|
88
88
|
adapter,
|
|
89
|
-
log:
|
|
89
|
+
log: log.child({script: scriptId}, true),
|
|
90
90
|
clientId,
|
|
91
91
|
xmlParser,
|
|
92
92
|
script:executeScriptByScript,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -315,7 +315,7 @@ function queryTasks(clientConfig, query, globalScriptParams, includeString) {
|
|
|
315
315
|
element.relations = {};
|
|
316
316
|
if (includeArray.includes('ciRelations')) {
|
|
317
317
|
log.debug('Read relations for task', )
|
|
318
|
-
const relations = await ticketCIRelationController.getTicketCIRelations(element['InstanceId']);
|
|
318
|
+
const relations = await ticketCIRelationController.getTicketCIRelations(element['InstanceId'], log);
|
|
319
319
|
element.relations.ciRelations = relations;
|
|
320
320
|
}
|
|
321
321
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
|
|
2
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const CONSTANTS = require('../util/constants');
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const {getLinkCI, applyMapping} = require('../util/paramHelper');
|
|
7
7
|
//const cmdbObjectController = require('./cmdbobjectController');
|
|
8
8
|
const {ticketConfig} = require ('../util/config');
|
|
9
|
+
const {getEventLog} = require("../util/eventLog");
|
|
9
10
|
|
|
10
11
|
const utilCache = new CacheService(process.env.CACHETTL_TICKETCIRELATIONS || 600); // Create a new cache service instance
|
|
11
12
|
|
|
@@ -27,8 +28,8 @@ function getSchemaName(lookupKeyword) {
|
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
async function getTicketCIRelations(ticketId) {
|
|
31
|
-
const relations = await getCITicketRelations(null, ticketId);
|
|
31
|
+
async function getTicketCIRelations(ticketId, eventLog) {
|
|
32
|
+
const relations = await getCITicketRelations(null, ticketId, eventLog);
|
|
32
33
|
if (relations && Array.isArray(relations)) {
|
|
33
34
|
let x=0;
|
|
34
35
|
for (x=0;x<relations.length;x++) {
|
|
@@ -43,7 +44,8 @@ async function getTicketCIRelations(ticketId) {
|
|
|
43
44
|
return relations;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
async function getCITicketRelations(ciInstanceId, ticketId) {
|
|
47
|
+
async function getCITicketRelations(ciInstanceId, ticketId, eventLog) {
|
|
48
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
47
49
|
let ci2ticketOnly = false;
|
|
48
50
|
if (ticketId === null || ticketId === undefined) {
|
|
49
51
|
ci2ticketOnly = true;
|
|
@@ -64,7 +66,7 @@ async function getCITicketRelations(ciInstanceId, ticketId) {
|
|
|
64
66
|
}
|
|
65
67
|
const form = CONSTANTS.FORM_ASSET_TICKET_ASSOC;
|
|
66
68
|
|
|
67
|
-
const result = await arquery.executeARQuery(form, null, query, ['Request ID02', 'Request ID01', 'Association Type01', 'Request Type01', 'Request Description01']);
|
|
69
|
+
const result = await arquery.executeARQuery(form, null, query, ['Request ID02', 'Request ID01', 'Association Type01', 'Request Type01', 'Request Description01'], undefined, log);
|
|
68
70
|
const relations = [];
|
|
69
71
|
for (const relationData of result.data) {
|
|
70
72
|
let relation = {};
|
|
@@ -76,7 +78,7 @@ async function getCITicketRelations(ciInstanceId, ticketId) {
|
|
|
76
78
|
relationType: relationData['Association Type01']
|
|
77
79
|
};
|
|
78
80
|
} else {
|
|
79
|
-
const ci = await getCiByReconId(relationData['Request ID02']);
|
|
81
|
+
const ci = await getCiByReconId(relationData['Request ID02'], log);
|
|
80
82
|
relation = {
|
|
81
83
|
ciId: ci['Instance Id'],
|
|
82
84
|
ciName: ci['Name'],
|
|
@@ -116,7 +118,8 @@ async function getAssocLookup(ticketForm, relationObject, assocType) {
|
|
|
116
118
|
});
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
async function createTicketCIRelation(ticketConfig, ticketId, ciInstanceId, assocType, ticketSummary) {
|
|
121
|
+
async function createTicketCIRelation(ticketConfig, ticketId, ciInstanceId, assocType, ticketSummary, eventLog) {
|
|
122
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
120
123
|
if (ticketSummary === null || ticketSummary === undefined) {
|
|
121
124
|
ticketSummary = 'summary';
|
|
122
125
|
}
|
|
@@ -176,12 +179,13 @@ async function createTicketCIRelation(ticketConfig, ticketId, ciInstanceId, asso
|
|
|
176
179
|
|
|
177
180
|
log.debug('Create CI Ticket Relation', ticketRelationFormData);
|
|
178
181
|
//todo: implement impersonate
|
|
179
|
-
const ticketRelation = await arquery.createEntry(ticketRelationForm, ticketRelationFormData);
|
|
180
|
-
const assetRelation = await arquery.createEntry(CONSTANTS.FORM_ASSET_TICKET_ASSOC, assetRelationFormData);
|
|
182
|
+
const ticketRelation = await arquery.createEntry(ticketRelationForm, ticketRelationFormData, undefined, log);
|
|
183
|
+
const assetRelation = await arquery.createEntry(CONSTANTS.FORM_ASSET_TICKET_ASSOC, assetRelationFormData, undefined, log);
|
|
181
184
|
return {ticketRelation, assetRelation}
|
|
182
185
|
}
|
|
183
186
|
|
|
184
|
-
async function createTicket2TicketRelation(ticketConfig, ticketId1, ticketConfig2, ticketId2, assocType, ticketSummary) {
|
|
187
|
+
async function createTicket2TicketRelation(ticketConfig, ticketId1, ticketConfig2, ticketId2, assocType, ticketSummary, eventLog) {
|
|
188
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
185
189
|
//todo fix request description
|
|
186
190
|
if (ticketSummary === null || ticketSummary === undefined) {
|
|
187
191
|
ticketSummary = 'summary';
|
|
@@ -216,13 +220,14 @@ async function createTicket2TicketRelation(ticketConfig, ticketId1, ticketConfig
|
|
|
216
220
|
|
|
217
221
|
//todo: implement impersonate
|
|
218
222
|
log.debug('Create Ticket 2 Ticket Relation', ticketRelationFormData1, ticketRelationFormData2);
|
|
219
|
-
const ticketRelation1 = await arquery.createEntry(ticketConfig.forms.assoc, ticketRelationFormData1);
|
|
220
|
-
const ticketRelation2 = await arquery.createEntry(ticketConfig2.forms.assoc, ticketRelationFormData2);
|
|
223
|
+
const ticketRelation1 = await arquery.createEntry(ticketConfig.forms.assoc, ticketRelationFormData1, undefined, log);
|
|
224
|
+
const ticketRelation2 = await arquery.createEntry(ticketConfig2.forms.assoc, ticketRelationFormData2, undefined, log);
|
|
221
225
|
return {ticketRelation1, ticketRelation2}
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
|
|
225
|
-
async function deleteTicketCIRelation(ticketConfig, ticketId, ciInstanceId) {
|
|
229
|
+
async function deleteTicketCIRelation(ticketConfig, ticketId, ciInstanceId, eventLog) {
|
|
230
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
226
231
|
const ticketRelationForm = ticketConfig.forms.assoc;
|
|
227
232
|
const ciData = await getCIData(ciInstanceId);
|
|
228
233
|
let ticketRelationQuery = `'Request ID02'= "${ticketId}" AND 'Request ID01' = "${ciData.ReconciliationIdentity}"`;
|
|
@@ -394,7 +399,8 @@ async function getOppositeAssocTypeByCode(assocCode) {
|
|
|
394
399
|
});
|
|
395
400
|
}
|
|
396
401
|
|
|
397
|
-
function doesCIRelationExists(ticketRelations, newRelation, keepCIs) {
|
|
402
|
+
function doesCIRelationExists(ticketRelations, newRelation, keepCIs, eventLog) {
|
|
403
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
398
404
|
log.debug('check for relation old', ticketRelations)
|
|
399
405
|
log.debug('check for relation new', newRelation)
|
|
400
406
|
const relationFound = ticketRelations.find(relation => {
|
|
@@ -431,7 +437,8 @@ function doesTicketRelationExists(ticketRelations, newRelation) {
|
|
|
431
437
|
}
|
|
432
438
|
}
|
|
433
439
|
|
|
434
|
-
async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
440
|
+
async function updateRelations(ticketConfig, userConfig, ticketId, relations, eventLog) {
|
|
441
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
435
442
|
// Wenn CIs vom Löschen ausgeschlossen werden sollen, dann kann unter relations.keepCIs ein Array mit Recon/InstanceId gesetzt werden.
|
|
436
443
|
log.debug('Checker', {ticketConfig, userConfig, ticketId, relations});
|
|
437
444
|
// Remove Ticket Relations if task
|
|
@@ -444,7 +451,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
444
451
|
|
|
445
452
|
//Check CI Relations
|
|
446
453
|
if (relations && relations.ciRelations && Array.isArray(relations.ciRelations)) {
|
|
447
|
-
const existingRelations = await getTicketCIRelations(ticketId);
|
|
454
|
+
const existingRelations = await getTicketCIRelations(ticketId, log);
|
|
448
455
|
log.debug('foundRelations', existingRelations);
|
|
449
456
|
let x=0;
|
|
450
457
|
//check for missiong relations
|
|
@@ -455,7 +462,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
455
462
|
log.debug('createRelation, already exists', relation, relationsExists);
|
|
456
463
|
if (!relationsExists) {
|
|
457
464
|
try {
|
|
458
|
-
await createTicketCIRelation(ticketConfig, ticketId, relation.ciId, relation.relationType);
|
|
465
|
+
await createTicketCIRelation(ticketConfig, ticketId, relation.ciId, relation.relationType, undefined, log);
|
|
459
466
|
} catch (e) {
|
|
460
467
|
errors.push(e);
|
|
461
468
|
}
|
|
@@ -466,11 +473,11 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
466
473
|
if (existingRelations && Array.isArray(existingRelations)) {
|
|
467
474
|
for (x=0; x<existingRelations.length; x++) {
|
|
468
475
|
const relation = existingRelations[x];
|
|
469
|
-
const shouldRelationsExists = doesCIRelationExists(relations.ciRelations, relation, relations.keepCIs);
|
|
476
|
+
const shouldRelationsExists = doesCIRelationExists(relations.ciRelations, relation, relations.keepCIs, log);
|
|
470
477
|
log.debug('deleteRelation, already exists', relation, shouldRelationsExists);
|
|
471
478
|
if (shouldRelationsExists !== true) {
|
|
472
479
|
try {
|
|
473
|
-
await deleteTicketCIRelation(ticketConfig, ticketId, relation.ciId);
|
|
480
|
+
await deleteTicketCIRelation(ticketConfig, ticketId, relation.ciId, log);
|
|
474
481
|
} catch (e) {
|
|
475
482
|
errors.push(e);
|
|
476
483
|
}
|
|
@@ -494,7 +501,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
494
501
|
if (ticketConfig2 === null || ticketConfig2 === undefined) {
|
|
495
502
|
throw new Error(`TicketConfig for ${relation.ticketType} not found.`);
|
|
496
503
|
}
|
|
497
|
-
await createTicket2TicketRelation(ticketConfig, ticketId, ticketConfig2, relation.ticketId, relation.relationType);
|
|
504
|
+
await createTicket2TicketRelation(ticketConfig, ticketId, ticketConfig2, relation.ticketId, relation.relationType, undefined, log);
|
|
498
505
|
}
|
|
499
506
|
}
|
|
500
507
|
}
|
|
@@ -515,6 +522,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
515
522
|
}
|
|
516
523
|
}
|
|
517
524
|
}
|
|
525
|
+
log.error('relationErrors', errors);
|
|
518
526
|
if (errors && errors.length > 0) {
|
|
519
527
|
errors = errors.map(item => item.message)
|
|
520
528
|
}
|
|
@@ -552,12 +560,13 @@ function getCIData(instanceId) {
|
|
|
552
560
|
});
|
|
553
561
|
}
|
|
554
562
|
|
|
555
|
-
async function getCiByReconId(reconId) {
|
|
563
|
+
async function getCiByReconId(reconId, eventLog) {
|
|
564
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
556
565
|
log.debug('Search for CI', reconId);
|
|
557
566
|
//get only CIs with recon
|
|
558
567
|
const query = `'Reconciliation Identity'="${reconId}" AND 'Data Set Id' = "BMC.ASSET"`;
|
|
559
568
|
const form = CONSTANTS.FORM_CMDB_AST_BASE;
|
|
560
|
-
const result = await arquery.executeARQuery(form, null, query, ['InstanceId', 'AssetLifecycleStatus', 'Name', 'Class Id', 'Instance Id']);
|
|
569
|
+
const result = await arquery.executeARQuery(form, null, query, ['InstanceId', 'AssetLifecycleStatus', 'Name', 'Class Id', 'Instance Id'], undefined, log);
|
|
561
570
|
if (result !== null && result !== undefined && result.data !== undefined) {
|
|
562
571
|
return result.data[0];
|
|
563
572
|
} else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
|
|
3
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -11,15 +11,17 @@ const relationUtil = require('../util/relationUtil');
|
|
|
11
11
|
const ticketCIRelationController = require('./ticketCIRelationController');
|
|
12
12
|
const scriptController = require('./scriptController');
|
|
13
13
|
const mappingUtil = require('../util/mappingUtil');
|
|
14
|
+
const {getEventLog} = require("../util/eventLog");
|
|
14
15
|
|
|
15
16
|
const ticketCache = new CacheService(process.env.CACHETTL_TICKETS || 0); // Create a new cache service instance
|
|
16
17
|
|
|
17
|
-
function getTickets(ticketConfig, config, includeString, customOptions, globalScriptParams) {
|
|
18
|
+
function getTickets(ticketConfig, config, includeString, customOptions, globalScriptParams, log) {
|
|
18
19
|
let query = '1=1';
|
|
19
|
-
return queryTickets(ticketConfig, config, query, null, null, customOptions, includeString, globalScriptParams);
|
|
20
|
+
return queryTickets(ticketConfig, config, query, null, null, customOptions, includeString, globalScriptParams, log);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
async function createTicket(ticketConfig, clientConfig, data, globalScriptParams) {
|
|
23
|
+
async function createTicket(ticketConfig, clientConfig, data, globalScriptParams, eventLog) {
|
|
24
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
23
25
|
let relationErrors;
|
|
24
26
|
const scripts = clientConfig[ticketConfig.requestType].scripts.POST;
|
|
25
27
|
const relations = data.relations || {}
|
|
@@ -36,19 +38,19 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
36
38
|
|
|
37
39
|
const fields = mappingUtil.getFieldsForCreate(config.getMapping(requestType), mapping, clientConfig[requestType].fields)
|
|
38
40
|
|
|
39
|
-
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConfig[ticketConfig.requestType].constants, fields);
|
|
41
|
+
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConfig[ticketConfig.requestType].constants, fields, log);
|
|
40
42
|
|
|
41
43
|
//run postScripts
|
|
42
44
|
if (scripts && scripts.postMapping) {
|
|
43
45
|
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
const result = await arquery.createEntry(ticketConfig.forms.new, data, clientConfig.options)
|
|
48
|
+
const result = await arquery.createEntry(ticketConfig.forms.new, data, clientConfig.options, log)
|
|
47
49
|
|
|
48
50
|
log.debug('TicketCreateResult', result);
|
|
49
51
|
const ticketCreateId = Object.values(result)[0];
|
|
50
52
|
//Find change id
|
|
51
|
-
const resultInterfaceCreate = await arquery.executeARQuery(ticketConfig.forms.new, null, "'1'=\"" + ticketCreateId + "\"", ticketConfig.ticketIdField, clientConfig.options)
|
|
53
|
+
const resultInterfaceCreate = await arquery.executeARQuery(ticketConfig.forms.new, null, "'1'=\"" + ticketCreateId + "\"", ticketConfig.ticketIdField, clientConfig.options, log)
|
|
52
54
|
if (resultInterfaceCreate.data && Array.isArray(resultInterfaceCreate.data) && resultInterfaceCreate.data.length && resultInterfaceCreate.data[0][ticketConfig.ticketIdField]) {
|
|
53
55
|
const ticketId = resultInterfaceCreate.data[0][ticketConfig.ticketIdField];
|
|
54
56
|
globalScriptParams.id = ticketId
|
|
@@ -58,7 +60,7 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
58
60
|
if (data[ticketConfig.businessServiceReconIdField] && relations) {
|
|
59
61
|
relations.keepCIs = [data[ticketConfig.businessServiceReconIdField]]
|
|
60
62
|
}
|
|
61
|
-
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, ticketId, relations);
|
|
63
|
+
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, ticketId, relations, log);
|
|
62
64
|
|
|
63
65
|
} else {
|
|
64
66
|
log.error('Cannot create Ticket', resultInterfaceCreate);
|
|
@@ -72,7 +74,8 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
72
74
|
return {createResult: resultInterfaceCreate, relationErrors};
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams) {
|
|
77
|
+
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams, eventLog) {
|
|
78
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
76
79
|
log.debug('config', ticketConfig);
|
|
77
80
|
const includeArray = getIncludeArray(includeString);
|
|
78
81
|
log.debug('ticketConfig.requestType', ticketConfig.requestType);
|
|
@@ -99,7 +102,7 @@ function queryTickets(ticketConfig, clientConfig, query, mapping, customFields,
|
|
|
99
102
|
log.debug('mapping', mapping);
|
|
100
103
|
|
|
101
104
|
return ticketCache.get(key, async function () {
|
|
102
|
-
const result = await arquery.executeARQuery(ticketConfig.forms.regular, baseQuery || null, query, fields.toString() || '1', options);
|
|
105
|
+
const result = await arquery.executeARQuery(ticketConfig.forms.regular, baseQuery || null, query, fields.toString() || '1', options, log);
|
|
103
106
|
const globalRelationObjects = relationUtil.prepareGlobalRelationObject();
|
|
104
107
|
const tickets = [];
|
|
105
108
|
if (result && result.data && result.data.length) {
|
|
@@ -154,7 +157,7 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
154
157
|
|
|
155
158
|
ticket.relations = {};
|
|
156
159
|
if (includeArray.includes('ciRelations')) {
|
|
157
|
-
const relations = await ticketCIRelationController.getTicketCIRelations(ticket.id);
|
|
160
|
+
const relations = await ticketCIRelationController.getTicketCIRelations(ticket.id, log);
|
|
158
161
|
ticket.relations.ciRelations = relations;
|
|
159
162
|
}
|
|
160
163
|
if (includeArray.includes('ticketRelations')) {
|
|
@@ -267,7 +270,8 @@ function checkFieldsProblem(problem, globalRelationObjects) {
|
|
|
267
270
|
}
|
|
268
271
|
|
|
269
272
|
|
|
270
|
-
async function getTicket(ticketConfig, config, id, mapping, includeString, globalScriptParams) {
|
|
273
|
+
async function getTicket(ticketConfig, config, id, mapping, includeString, globalScriptParams, eventLog) {
|
|
274
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
271
275
|
let query = '1=2';
|
|
272
276
|
const requestType = ticketConfig.requestType;
|
|
273
277
|
if (requestType === 'incident') {
|
|
@@ -279,12 +283,13 @@ async function getTicket(ticketConfig, config, id, mapping, includeString, globa
|
|
|
279
283
|
} else if (requestType === 'workOrder') {
|
|
280
284
|
query = `'Work Order ID'=\"${id}\"`;
|
|
281
285
|
}
|
|
282
|
-
const returnValue = await queryTickets(ticketConfig, config, query, mapping, null, null, includeString, globalScriptParams);
|
|
286
|
+
const returnValue = await queryTickets(ticketConfig, config, query, mapping, null, null, includeString, globalScriptParams, log);
|
|
283
287
|
const ticket = returnValue.data[0];
|
|
284
288
|
return {data: ticket, included: returnValue.included};
|
|
285
289
|
}
|
|
286
290
|
|
|
287
|
-
async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams) {
|
|
291
|
+
async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams, eventLog) {
|
|
292
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
288
293
|
let relationErrors;
|
|
289
294
|
const scripts = clientConfig[ticketConfig.requestType].scripts.PUT;
|
|
290
295
|
const fields = clientConfig[ticketConfig.requestType].fields
|
|
@@ -295,22 +300,21 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
295
300
|
await scriptController.runScripts(scripts.preMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
296
301
|
}
|
|
297
302
|
|
|
298
|
-
log.debug(clientConfig[ticketConfig.requestType]);
|
|
303
|
+
log.debug('requestType', clientConfig[ticketConfig.requestType]);
|
|
299
304
|
const myClientConfig = {};
|
|
300
305
|
myClientConfig[ticketConfig.requestType] = {baseQuery: clientConfig[ticketConfig.requestType].baseQuery, fields: [1, ticketConfig.businessServiceReconIdField]};
|
|
301
306
|
const myMapping = [{"oldName":ticketConfig.requestIdField, "newName" : "internalId"}, {"oldName":ticketConfig.businessServiceReconIdField, "newName" : "serviceReconId"}];
|
|
302
307
|
|
|
303
308
|
const mapping = config.getMapping(ticketConfig.requestType);
|
|
304
|
-
|
|
305
309
|
//Constants work only on new.
|
|
306
|
-
ticketData = mappingUtil.applyMapping2Remedy(ticketData, mapping, undefined, fields);
|
|
310
|
+
ticketData = mappingUtil.applyMapping2Remedy(ticketData, mapping, undefined, fields, log);
|
|
307
311
|
|
|
308
312
|
//run postMapping
|
|
309
313
|
if (scripts && scripts.postMapping) {
|
|
310
314
|
await scriptController.runScripts(scripts.postMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
311
315
|
}
|
|
312
316
|
|
|
313
|
-
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping, undefined, globalScriptParams);
|
|
317
|
+
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping, undefined, globalScriptParams, log);
|
|
314
318
|
log.debug('Ticket to Update', ticket);
|
|
315
319
|
//keep businessService CI Relation
|
|
316
320
|
if (ticket && ticket.data && ticket.data.serviceReconId && relations) {
|
|
@@ -321,8 +325,8 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
321
325
|
delete ticketData[ticketConfig.ticketIdField];
|
|
322
326
|
|
|
323
327
|
//todo Abfangen wenn getTicket nichts liefert.
|
|
324
|
-
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData, clientConfig.options);
|
|
325
|
-
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, id, relations);
|
|
328
|
+
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData, clientConfig.options, log);
|
|
329
|
+
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, id, relations, log);
|
|
326
330
|
//run afterExecution
|
|
327
331
|
if (scripts && scripts.afterExecution) {
|
|
328
332
|
await scriptController.runScripts(scripts.afterExecution, ticketData, clientConfig.clientId, globalScriptParams);
|
|
@@ -330,12 +334,12 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
330
334
|
return {updateResult: update, relationErrors};
|
|
331
335
|
}
|
|
332
336
|
|
|
333
|
-
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams) {
|
|
337
|
+
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams, eventLog) {
|
|
334
338
|
const mapping = config.getMapping(ticketConfig.requestType);
|
|
335
339
|
const mappedString = searchUtil.applyMapping(searchString, mapping);
|
|
336
340
|
const customFields = searchUtil.getCustomFields(clientConfig[ticketConfig.requestType].fields, mapping, fields);
|
|
337
341
|
options.sort = searchUtil.applySortMapping(options.sort, mapping);
|
|
338
|
-
return queryTickets(ticketConfig, clientConfig, mappedString, null, customFields, options, includeString, globalScriptParams);
|
|
342
|
+
return queryTickets(ticketConfig, clientConfig, mappedString, null, customFields, options, includeString, globalScriptParams, eventLog);
|
|
339
343
|
}
|
|
340
344
|
|
|
341
345
|
module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
package/docs/releases.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
3
|
## API
|
|
4
|
+
### 1.64.0 - 19.07.23
|
|
5
|
+
Introduce Enhanced Logging for Tickets. More objects in later releases.
|
|
6
|
+
|
|
4
7
|
### 1.63.0 - 10.01.23
|
|
5
8
|
Security fix for jsonwebtoken https://github.com/advisories/GHSA-27h2-hvpr-p74q
|
|
6
9
|
|
|
@@ -185,6 +188,9 @@ e.g.
|
|
|
185
188
|
*/v1/incidents?impersonateUser=abc123
|
|
186
189
|
|
|
187
190
|
## Event Manager
|
|
191
|
+
### 1.31.0 - 18.07.23
|
|
192
|
+
Introduce advanced logging for events. Each event log record will contain details about the associated event. (e.g. Event Id, Ticketnumber, etc.)
|
|
193
|
+
|
|
188
194
|
### 1.29.1 - 10.01.23
|
|
189
195
|
Security fix for jsonwebtoken https://github.com/advisories/GHSA-27h2-hvpr-p74q
|
|
190
196
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const {body, validationResult, oneOf, checkSchema} = require('express-validator/check');
|
|
4
4
|
const {setEventData} = require('../controller/eventLogController');
|
|
5
5
|
const CONSTANTS = require('../util/constants');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog(path.basename(__filename));
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const passport = require('passport');
|
|
4
4
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
5
5
|
const cmdbobjects = require('../controller/cmdbobjectController');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const passport = require('passport');
|
|
4
4
|
const {body, validationResult, checkSchema} = require('express-validator/check');
|
|
5
5
|
const cmdbobjects = require('../controller/cmdbobjectController');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
4
4
|
const customFormController = require('../controller/customFormController');
|
|
5
5
|
const eventLog = require('../controller/eventLogController');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const passport = require('passport');
|
|
4
4
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
5
5
|
const orgdata = require('../controller/orgdataController');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const passport = require('passport');
|
|
4
4
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
5
5
|
const cmdbobjects = require('../controller/cmdbobjectController');
|
package/routes/personRoutes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const passport = require('passport');
|
|
4
4
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
5
5
|
const orgdata = require('../controller/orgdataController');
|
package/routes/scriptRoutes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const scriptController = require('../controller/scriptController');
|
|
4
4
|
const eventLog = require('../controller/eventLogController');
|
|
5
5
|
const CONSTANTS = require('../util/constants');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const passport = require('passport');
|
|
4
4
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
5
5
|
const orgdata = require('../controller/orgdataController');
|
package/routes/taskRoutes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
4
4
|
const task = require('../controller/taskController');
|
|
5
5
|
const eventLog = require('../controller/eventLogController');
|
package/routes/templateRoutes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const templateController = require('../controller/templateController');
|
|
4
4
|
const eventLog = require('../controller/eventLogController');
|
|
5
5
|
const CONSTANTS = require('../util/constants');
|
package/routes/ticketRoutes.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
|
|
2
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
|
+
const {getEventLog} = require('../util/eventLog');
|
|
3
4
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
4
5
|
const ticketController = require('../controller/ticketController');
|
|
5
6
|
const templateController = require('../controller/templateController');
|
|
@@ -15,7 +16,13 @@ module.exports = (function() {
|
|
|
15
16
|
return `${location}[${param}]: ${msg}`;
|
|
16
17
|
};
|
|
17
18
|
|
|
19
|
+
ticketRoutes.use(function (req, res, next) {
|
|
20
|
+
log = getEventLog(req.log, path.basename(__filename))
|
|
21
|
+
next();
|
|
22
|
+
});
|
|
23
|
+
|
|
18
24
|
ticketRoutes.get('/', function (req, res, next) {
|
|
25
|
+
log = getEventLog(req.log, path.basename(__filename));
|
|
19
26
|
eventLog.setEventData(
|
|
20
27
|
req,
|
|
21
28
|
req.parentEventBase,
|
|
@@ -46,6 +53,7 @@ module.exports = (function() {
|
|
|
46
53
|
});
|
|
47
54
|
|
|
48
55
|
ticketRoutes.post('/', function (req, res, next) {
|
|
56
|
+
log = getEventLog(req.log, path.basename(__filename));
|
|
49
57
|
//todo Errorhandling prüfen. Wenn parameter fehlen, wird nicht zurückgegeben welche
|
|
50
58
|
const origData = JSON.parse(JSON.stringify(req.body));
|
|
51
59
|
const includeString = req.query.include;
|
|
@@ -63,7 +71,7 @@ module.exports = (function() {
|
|
|
63
71
|
next(errors.array());
|
|
64
72
|
} else {
|
|
65
73
|
//const relations = req.body.data.relations;
|
|
66
|
-
ticketController.createTicket(req.ticketConfig, req.user.config, req.body.data, req.globalScriptParams).then(async function (result) {
|
|
74
|
+
ticketController.createTicket(req.ticketConfig, req.user.config, req.body.data, req.globalScriptParams, req.log).then(async function (result) {
|
|
67
75
|
const createResult = result.createResult;
|
|
68
76
|
const relationErrors = result.relationErrors;
|
|
69
77
|
if (relationErrors && Array.isArray(relationErrors) && relationErrors.length > 0) {
|
|
@@ -88,7 +96,7 @@ module.exports = (function() {
|
|
|
88
96
|
ticketRoutes.post('/search', [
|
|
89
97
|
body('searchString').isLength({ min: 1})
|
|
90
98
|
], function (req, res, next) {
|
|
91
|
-
|
|
99
|
+
log = getEventLog(req.log, path.basename(__filename));
|
|
92
100
|
const origData = JSON.parse(JSON.stringify(req.body));
|
|
93
101
|
const includeString = req.query.include;
|
|
94
102
|
eventLog.setEventData(
|
|
@@ -119,7 +127,7 @@ module.exports = (function() {
|
|
|
119
127
|
if (!valResult.isEmpty()) {
|
|
120
128
|
next(valResult.array());
|
|
121
129
|
} else {
|
|
122
|
-
ticketController.searchTicket(req.ticketConfig, req.user.config, req.body.searchString, req.body.fields, options, includeString, req.globalScriptParams).then(function (result) {
|
|
130
|
+
ticketController.searchTicket(req.ticketConfig, req.user.config, req.body.searchString, req.body.fields, options, includeString, req.globalScriptParams, req.log).then(function (result) {
|
|
123
131
|
log.debug('result', result);
|
|
124
132
|
req.includeObjectsList = result.included;
|
|
125
133
|
req.result = {data:result.data};
|
|
@@ -146,8 +154,9 @@ module.exports = (function() {
|
|
|
146
154
|
});
|
|
147
155
|
|
|
148
156
|
function getTicket(req, res, next, clientConfig, id, mapping, includeString, additionalData) {
|
|
157
|
+
log = getEventLog(req.log, path.basename(__filename));
|
|
149
158
|
req.globalScriptParams.id = id
|
|
150
|
-
ticketController.getTicket(req.ticketConfig, clientConfig, id, mapping, includeString, req.globalScriptParams).then(function (result) {
|
|
159
|
+
ticketController.getTicket(req.ticketConfig, clientConfig, id, mapping, includeString, req.globalScriptParams, log).then(function (result) {
|
|
151
160
|
log.debug('result', result);
|
|
152
161
|
req.includeObjectsList = result.included;
|
|
153
162
|
req.result = {data:result.data || {}};
|
|
@@ -164,6 +173,7 @@ module.exports = (function() {
|
|
|
164
173
|
}
|
|
165
174
|
|
|
166
175
|
ticketRoutes.put('/:id', function (req, res, next) {
|
|
176
|
+
log = getEventLog(req.log, path.basename(__filename));
|
|
167
177
|
const id = req.params.id;
|
|
168
178
|
req.globalScriptParams.id = id
|
|
169
179
|
const origData = JSON.parse(JSON.stringify(req.body));
|
|
@@ -182,7 +192,7 @@ module.exports = (function() {
|
|
|
182
192
|
next(errors.array());
|
|
183
193
|
} else {
|
|
184
194
|
const relations = req.body.data.relations;
|
|
185
|
-
ticketController.updateTicket(req.ticketConfig, req.user.config, id, req.body.data, req.globalScriptParams)
|
|
195
|
+
ticketController.updateTicket(req.ticketConfig, req.user.config, id, req.body.data, req.globalScriptParams, log)
|
|
186
196
|
.then(async function (result) {
|
|
187
197
|
const relationErrors = result.relationErrors;
|
|
188
198
|
if (relationErrors && Array.isArray(relationErrors) && relationErrors.length > 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const {body, validationResult, oneOf} = require('express-validator/check');
|
|
4
4
|
const ticketWorkLogController = require('../controller/ticketWorkLogController');
|
|
5
5
|
const ticketValidationUtil = require('../util/ticketValidationUtil');
|
package/test/changeTest.js
CHANGED
|
@@ -209,7 +209,7 @@ describe('Integration Tests - Change', function () {
|
|
|
209
209
|
}
|
|
210
210
|
})
|
|
211
211
|
.end(function(err, res) {
|
|
212
|
-
res.should.have.status(
|
|
212
|
+
res.should.have.status(422);
|
|
213
213
|
done();
|
|
214
214
|
})
|
|
215
215
|
})
|
|
@@ -232,7 +232,7 @@ describe('Integration Tests - Change', function () {
|
|
|
232
232
|
}
|
|
233
233
|
})
|
|
234
234
|
.end(function(err, res) {
|
|
235
|
-
res.should.have.status(
|
|
235
|
+
res.should.have.status(422);
|
|
236
236
|
done();
|
|
237
237
|
})
|
|
238
238
|
})
|
package/test/incidentTest.js
CHANGED
|
@@ -158,7 +158,7 @@ describe('Integration Tests - Incidents', function () {
|
|
|
158
158
|
}
|
|
159
159
|
})
|
|
160
160
|
.end(function(err, res) {
|
|
161
|
-
res.should.have.status(
|
|
161
|
+
res.should.have.status(422);
|
|
162
162
|
done();
|
|
163
163
|
})
|
|
164
164
|
})
|
|
@@ -181,7 +181,7 @@ describe('Integration Tests - Incidents', function () {
|
|
|
181
181
|
}
|
|
182
182
|
})
|
|
183
183
|
.end(function(err, res) {
|
|
184
|
-
res.should.have.status(
|
|
184
|
+
res.should.have.status(422);
|
|
185
185
|
done();
|
|
186
186
|
})
|
|
187
187
|
})
|
package/test/problemTest.js
CHANGED
|
@@ -181,7 +181,7 @@ describe('Integration Tests - Problems', function () {
|
|
|
181
181
|
}
|
|
182
182
|
})
|
|
183
183
|
.end(function(err, res) {
|
|
184
|
-
res.should.have.status(
|
|
184
|
+
res.should.have.status(422);
|
|
185
185
|
done();
|
|
186
186
|
})
|
|
187
187
|
})
|
|
@@ -204,7 +204,7 @@ describe('Integration Tests - Problems', function () {
|
|
|
204
204
|
}
|
|
205
205
|
})
|
|
206
206
|
.end(function(err, res) {
|
|
207
|
-
res.should.have.status(
|
|
207
|
+
res.should.have.status(422);
|
|
208
208
|
done();
|
|
209
209
|
})
|
|
210
210
|
})
|
package/test/workorderTest.js
CHANGED
|
@@ -199,7 +199,7 @@ describe('Integration Tests - Workorders', function () {
|
|
|
199
199
|
}
|
|
200
200
|
})
|
|
201
201
|
.end(function(err, res) {
|
|
202
|
-
res.should.have.status(
|
|
202
|
+
res.should.have.status(422);
|
|
203
203
|
done();
|
|
204
204
|
})
|
|
205
205
|
})
|
|
@@ -222,7 +222,7 @@ describe('Integration Tests - Workorders', function () {
|
|
|
222
222
|
}
|
|
223
223
|
})
|
|
224
224
|
.end(function(err, res) {
|
|
225
|
-
res.should.have.status(
|
|
225
|
+
res.should.have.status(422);
|
|
226
226
|
done();
|
|
227
227
|
})
|
|
228
228
|
})
|
package/util/arquery.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const request = require('request-promise-native');
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const
|
|
4
|
+
const {getEventLog} = require("./eventLog");
|
|
5
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
5
6
|
|
|
6
7
|
async function deleteEntries(form, baseQuery, query) {
|
|
7
8
|
let fullQuery = query;
|
|
@@ -36,7 +37,9 @@ async function deleteEntries(form, baseQuery, query) {
|
|
|
36
37
|
return value;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
async function executeARQuery(form, baseQuery, query, fields, options) {
|
|
40
|
+
async function executeARQuery(form, baseQuery, query, fields, options, eventLog) {
|
|
41
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
42
|
+
log = log.child({form});
|
|
40
43
|
let fullQuery = query;
|
|
41
44
|
if (baseQuery)
|
|
42
45
|
fullQuery = "(" + baseQuery + ") AND " + query;
|
|
@@ -178,7 +181,9 @@ function prepareSortString(sortOptions) {
|
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
//todo add impersonate
|
|
181
|
-
function createEntry(form, entryData, clientOptions) {
|
|
184
|
+
function createEntry(form, entryData, clientOptions, eventLog) {
|
|
185
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
186
|
+
log = log.child({form});
|
|
182
187
|
let port = 0;
|
|
183
188
|
if (process.env.AR_PORT && process.env.AR_PORT != undefined)
|
|
184
189
|
port = process.env.AR_PORT;
|
|
@@ -362,7 +367,9 @@ function applyMapping(entryData, mapping, constants) {
|
|
|
362
367
|
return entryData;
|
|
363
368
|
}
|
|
364
369
|
|
|
365
|
-
function updateEntry(form, id, entryData, clientOptions) {
|
|
370
|
+
function updateEntry(form, id, entryData, clientOptions, eventLog) {
|
|
371
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
372
|
+
log = log.child({form});
|
|
366
373
|
let port = 0;
|
|
367
374
|
if (process.env.AR_PORT && process.env.AR_PORT != undefined)
|
|
368
375
|
port = process.env.AR_PORT;
|
|
@@ -405,7 +412,11 @@ function updateEntry(form, id, entryData, clientOptions) {
|
|
|
405
412
|
}
|
|
406
413
|
}
|
|
407
414
|
//TODO check for status and reject if Error
|
|
408
|
-
|
|
415
|
+
if (response && response.startsWith('[message:error')) {
|
|
416
|
+
reject ('Could not update entry: ' + response);
|
|
417
|
+
} else {
|
|
418
|
+
resolve(response);
|
|
419
|
+
}
|
|
409
420
|
})
|
|
410
421
|
.catch(function (error) {
|
|
411
422
|
log.error(error);
|
package/util/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
|
|
5
5
|
function isAuthorizedAdmin(req, res, next) {
|
|
6
6
|
log.debug(req.user);
|
package/util/cache.service.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const NodeCache = require ('node-cache/index');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
|
|
5
5
|
class Cache {
|
|
6
6
|
|
package/util/config.js
CHANGED
|
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const fsPromises = require('fs').promises;
|
|
3
3
|
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const log = require('@manyos/logger').setupLog('
|
|
5
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
6
6
|
|
|
7
7
|
const clientConfigFile = 'conf/clients.json';
|
|
8
8
|
const arquery = require('../util/arquery');
|
package/util/eventLog.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
|
+
|
|
4
|
+
function getEventLog(eventLog, file, options) {
|
|
5
|
+
if (!eventLog) {
|
|
6
|
+
eventLog = log;
|
|
7
|
+
}
|
|
8
|
+
eventLog = eventLog.child({
|
|
9
|
+
file
|
|
10
|
+
});
|
|
11
|
+
return eventLog;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
getEventLog
|
|
16
|
+
};
|
package/util/mappingUtil.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const {getFields} = require("./config");
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
function applyMapping2Remedy(entryData, mapping, constants, fields) {
|
|
3
|
+
const {getEventLog} = require("./eventLog");
|
|
4
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
6
5
|
|
|
6
|
+
function applyMapping2Remedy(entryData, mapping, constants, fields, eventLog) {
|
|
7
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
7
8
|
//todo add array handling
|
|
8
9
|
if (!Array.isArray(entryData)) {
|
|
9
|
-
return applyMappingInternal(entryData, mapping, constants, fields);
|
|
10
|
+
return applyMappingInternal(entryData, mapping, constants, fields, log);
|
|
10
11
|
} else {
|
|
11
12
|
const entries = [];
|
|
12
13
|
entryData.forEach(entry => {
|
|
@@ -17,7 +18,8 @@ function applyMapping2Remedy(entryData, mapping, constants, fields) {
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
function applyMappingInternal(entryData, mapping, constants, fields) {
|
|
21
|
+
function applyMappingInternal(entryData, mapping, constants, fields, eventLog) {
|
|
22
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
21
23
|
Object.keys(entryData).forEach(function (objectKey) {
|
|
22
24
|
const found = mapping.find(function(element) {
|
|
23
25
|
return element.newName === objectKey;
|
|
@@ -105,7 +107,8 @@ function getFieldsForCreate(mapping, mappingNew, clientFields) {
|
|
|
105
107
|
return remedyField;
|
|
106
108
|
}*/
|
|
107
109
|
|
|
108
|
-
function applyCustomFormMapping(object, mapping, requestIdField) {
|
|
110
|
+
function applyCustomFormMapping(object, mapping, requestIdField, eventLog) {
|
|
111
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
109
112
|
//log.debug('apply mapping', object, mapping)
|
|
110
113
|
//Apply mapping
|
|
111
114
|
Object.keys(mapping).forEach(remedyName => {
|
|
@@ -128,7 +131,8 @@ function applyCustomFormMapping(object, mapping, requestIdField) {
|
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
|
|
131
|
-
function applyCustomFormMapping2Remedy(entryData, mapping, constants, fields) {
|
|
134
|
+
function applyCustomFormMapping2Remedy(entryData, mapping, constants, fields, eventLog) {
|
|
135
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
132
136
|
//delete unmapped entries
|
|
133
137
|
const mappedFields = Object.values(mapping)
|
|
134
138
|
|
package/util/paramHelper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
|
|
4
4
|
function getIncludeArray(includeString) {
|
|
5
5
|
log.debug('transform includeString', includeString);
|
package/util/relationUtil.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
|
|
4
4
|
const CONSTANTS = require('../util/constants');
|
|
5
5
|
|
package/util/responsehandler.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
|
|
2
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const eventLog = require('../controller/eventLogController');
|
|
4
|
+
const {getEventLog} = require("./eventLog");
|
|
4
5
|
|
|
5
6
|
const VERSION = process.env.version;
|
|
6
7
|
|
|
@@ -21,6 +22,7 @@ function logRequest (req, res, next) {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
function logErrors(err, req, res, next) {
|
|
25
|
+
log = getEventLog(req.log, path.basename(__filename));
|
|
24
26
|
/*log.error({
|
|
25
27
|
smileId : req.smileId,
|
|
26
28
|
error : err.stack || String(err)
|
|
@@ -39,13 +41,15 @@ function logErrors(err, req, res, next) {
|
|
|
39
41
|
JSON.stringify(err, null, 2) || String(err),
|
|
40
42
|
eventData.jsonData,
|
|
41
43
|
eventData.ticketNumber2,
|
|
42
|
-
eventData.ticketNumber3
|
|
44
|
+
eventData.ticketNumber3,
|
|
45
|
+
req.log);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
next(err);
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
function errorHandler(err, req, res, next) {
|
|
52
|
+
log = getEventLog(req.log, path.basename(__filename));
|
|
49
53
|
const errorStack = err.stack;
|
|
50
54
|
const errorStatus = err.status || req.errorStatus || 500;
|
|
51
55
|
if (errorStatus == 401) {
|
|
@@ -66,6 +70,7 @@ function errorHandler(err, req, res, next) {
|
|
|
66
70
|
|
|
67
71
|
//createSuccessLog(client, ticketNumber, schemaName, eventName, url, jsonData) {
|
|
68
72
|
function eventQueueHandler(req, res, next) {
|
|
73
|
+
log = getEventLog(req.log, path.basename(__filename));
|
|
69
74
|
//add version to header as debug info
|
|
70
75
|
res.setHeader('x-smileconnect-version', VERSION || '0.0.0');
|
|
71
76
|
log.debug({req:req}, 'start');
|
|
@@ -93,7 +98,10 @@ function eventQueueHandler(req, res, next) {
|
|
|
93
98
|
eventData.event,
|
|
94
99
|
req.method + ':' + req.url,
|
|
95
100
|
eventData.jsonData,
|
|
96
|
-
eventData.ticketNumber2
|
|
101
|
+
eventData.ticketNumber2,
|
|
102
|
+
eventData.ticketNumber3,
|
|
103
|
+
req.log
|
|
104
|
+
).then( success => {
|
|
97
105
|
if (req.downloadResult) {
|
|
98
106
|
res.set('Content-disposition', 'attachment; filename=' + req.downloadResult.fileName);
|
|
99
107
|
res.status(200).send(req.downloadResult.data);
|
package/util/searchUtil.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
|
|
4
4
|
function applyMapping(searchString, mapping) {
|
|
5
5
|
log.debug('Apply mapping on', searchString, mapping);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const ticketController = require("../controller/ticketController");
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
async function checkTicket(ticketConfig, id, globalScriptParams) {
|
package/screwdriver.yaml
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# Shared definition block
|
|
2
|
-
shared:
|
|
3
|
-
# Source: https://hub.docker.com/r/library/buildpack-deps/
|
|
4
|
-
image: node:10
|
|
5
|
-
secrets:
|
|
6
|
-
- SCM_ACCESS_TOKEN
|
|
7
|
-
- SCM_USERNAME
|
|
8
|
-
# Job definition block
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
requires: [~pr, ~commit]
|
|
12
|
-
# Steps definition block.
|
|
13
|
-
environment:
|
|
14
|
-
SSO_ISSUER: https://sso.manyos.it/auth/realms/itsmproxy
|
|
15
|
-
SSO_PUBLIC_KEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk6LRzGvjoxuHGnA4MT8D73O/GMSA1hJz1syqsBJY+F2OZRcKz/+gEnlnB3EPAxF7Luoz4nFh1Aaz21DkN2bL8W544+MV4JGl61f4N5HAnBT1635rN5xkbubgmuNQCnKKFu7OlAD3QxiDwecg1bJvFhJW9Qj5YhOwGuX5/4sOSCjmdTcKT1mCHL61FJ5mzxtbrct97zVwXmi4F4KDKj2PsW+qxUg0Jz/06iTVjtv2H1yBq16tqvCyq9WR6nZELmSsDNyyiTuKGJeiF+LXfIjtI9WZgPTGvIWQ3RIqObBm50bEBLHL5aHm2iSGDKoSMOGf/3aQ5NnZEgjMNdkTEjkWVQIDAQAB
|
|
16
|
-
BASEURL: https://rapi.port.manyos.io
|
|
17
|
-
AR_SERVER: pier1
|
|
18
|
-
AR_PORT: 9502
|
|
19
|
-
LOGLEVEL: debug
|
|
20
|
-
EVENTLOG_ENABLE: false
|
|
21
|
-
steps:
|
|
22
|
-
- init: npm install
|
|
23
|
-
- runtest: npm test
|
|
24
|
-
- generate-artifacts: find ./artifacts -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
|
|
25
|
-
- copy-to-artifacts-dir: echo $SD_ARTIFACTS_DIR && cp -r ./artifacts $SD_ARTIFACTS_DIR
|
|
26
|
-
secrets:
|
|
27
|
-
- TEST_ID
|
|
28
|
-
- TEST_SECRET
|
|
29
|
-
- AR_USER
|
|
30
|
-
- AR_PASSWORD
|
|
31
|
-
|
|
32
|
-
# test:
|
|
33
|
-
# requires: [main] # second_job will run after main job is done
|
|
34
|
-
# environment:
|
|
35
|
-
# - SSO_ISSUER: https://sso.manyos.it/auth/realms/itsmproxy
|
|
36
|
-
# - SSO_PUBLIC_KEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk6LRzGvjoxuHGnA4MT8D73O/GMSA1hJz1syqsBJY+F2OZRcKz/+gEnlnB3EPAxF7Luoz4nFh1Aaz21DkN2bL8W544+MV4JGl61f4N5HAnBT1635rN5xkbubgmuNQCnKKFu7OlAD3QxiDwecg1bJvFhJW9Qj5YhOwGuX5/4sOSCjmdTcKT1mCHL61FJ5mzxtbrct97zVwXmi4F4KDKj2PsW+qxUg0Jz/06iTVjtv2H1yBq16tqvCyq9WR6nZELmSsDNyyiTuKGJeiF+LXfIjtI9WZgPTGvIWQ3RIqObBm50bEBLHL5aHm2iSGDKoSMOGf/3aQ5NnZEgjMNdkTEjkWVQIDAQAB
|
|
37
|
-
# - BASEURL: https://rapi.port.manyos.io
|
|
38
|
-
# - AR_SERVER: pier1
|
|
39
|
-
# - AR_PORT: 9502
|
|
40
|
-
# - LOGLEVEL: debug
|
|
41
|
-
# - EVENTLOG_ENABLE: false
|
|
42
|
-
# steps:
|
|
43
|
-
# - install: npm install
|
|
44
|
-
# - build: npm test
|
|
45
|
-
# - get-metadata: meta get example
|
|
46
|
-
# secrets:
|
|
47
|
-
# - SCM_ACCESS_TOKEN
|
|
48
|
-
# - SCM_USERNAME
|
|
49
|
-
# - TEST_ID
|
|
50
|
-
# - TEST_USERNAME
|
|
51
|
-
# - AR_USER
|
|
52
|
-
# - AR_PASSWORD
|