@manyos/smileconnect-api 1.59.3 → 1.59.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/app.js +1 -0
- package/conf/clients.json +34 -5
- package/controller/customFormController.js +5 -1
- package/controller/relatedObjectsController.js +25 -1
- package/controller/ticketController.js +2 -3
- package/controller/ticketWorkLogController.js +3 -0
- package/docs/configuration/config.md +12 -0
- package/docs/releases.md +6 -0
- package/package.json +1 -1
- package/routes/customFormRoutes.js +12 -2
- package/routes/taskRoutes.js +24 -14
- package/routes/ticketRoutes.js +12 -2
- package/routes/ticketWorkLogRoutes.js +9 -4
package/app.js
CHANGED
|
@@ -371,6 +371,7 @@ app.use('/v1/:requestType/:parentId/tasks', function(req, res, next) {
|
|
|
371
371
|
}, taskRoutes);
|
|
372
372
|
|
|
373
373
|
app.use(relatedObjectsController.getRelatedObjects);
|
|
374
|
+
app.use(relatedObjectsController.addLinks);
|
|
374
375
|
|
|
375
376
|
app.use(responseHandler.eventQueueHandler);
|
|
376
377
|
|
package/conf/clients.json
CHANGED
|
@@ -2289,7 +2289,9 @@
|
|
|
2289
2289
|
},
|
|
2290
2290
|
"PUT": {
|
|
2291
2291
|
"preMapping": [],
|
|
2292
|
-
"postMapping": [
|
|
2292
|
+
"postMapping": [
|
|
2293
|
+
"notFetchResult"
|
|
2294
|
+
],
|
|
2293
2295
|
"afterExecution": []
|
|
2294
2296
|
},
|
|
2295
2297
|
"POST": {
|
|
@@ -2376,14 +2378,18 @@
|
|
|
2376
2378
|
"preMapping": [
|
|
2377
2379
|
"p2"
|
|
2378
2380
|
],
|
|
2379
|
-
"postMapping": [
|
|
2381
|
+
"postMapping": [
|
|
2382
|
+
"notFetchResult"
|
|
2383
|
+
],
|
|
2380
2384
|
"afterExecution": [
|
|
2381
2385
|
"INC_CreateWorklog_OnCreate"
|
|
2382
2386
|
]
|
|
2383
2387
|
},
|
|
2384
2388
|
"PUT": {
|
|
2385
2389
|
"preMapping": [],
|
|
2386
|
-
"postMapping": [
|
|
2390
|
+
"postMapping": [
|
|
2391
|
+
"notFetchResult"
|
|
2392
|
+
],
|
|
2387
2393
|
"afterExecution": []
|
|
2388
2394
|
}
|
|
2389
2395
|
}
|
|
@@ -2491,7 +2497,15 @@
|
|
|
2491
2497
|
}
|
|
2492
2498
|
],
|
|
2493
2499
|
"basequery": "",
|
|
2494
|
-
"scripts": {
|
|
2500
|
+
"scripts": {
|
|
2501
|
+
"POST": {
|
|
2502
|
+
"preMapping": [],
|
|
2503
|
+
"postMapping": [
|
|
2504
|
+
"notFetchResult"
|
|
2505
|
+
],
|
|
2506
|
+
"afterExecution": []
|
|
2507
|
+
}
|
|
2508
|
+
},
|
|
2495
2509
|
"attachmentScripts": {}
|
|
2496
2510
|
},
|
|
2497
2511
|
"problemWorklog": {
|
|
@@ -2562,7 +2576,22 @@
|
|
|
2562
2576
|
"value": "1000"
|
|
2563
2577
|
}
|
|
2564
2578
|
],
|
|
2565
|
-
"scripts": {
|
|
2579
|
+
"scripts": {
|
|
2580
|
+
"POST": {
|
|
2581
|
+
"preMapping": [],
|
|
2582
|
+
"postMapping": [
|
|
2583
|
+
"notFetchResult"
|
|
2584
|
+
],
|
|
2585
|
+
"afterExecution": []
|
|
2586
|
+
},
|
|
2587
|
+
"PUT": {
|
|
2588
|
+
"preMapping": [],
|
|
2589
|
+
"postMapping": [
|
|
2590
|
+
"notFetchResult"
|
|
2591
|
+
],
|
|
2592
|
+
"afterExecution": []
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2566
2595
|
},
|
|
2567
2596
|
"taskWorklog": {
|
|
2568
2597
|
"fields": [
|
|
@@ -155,7 +155,11 @@ async function handleRecord(formConfig, record, mapping, clientConfig, includeAr
|
|
|
155
155
|
|
|
156
156
|
async function getRecord(formConfig, clientConfig, id, mapping, includeString, globalScriptParams) {
|
|
157
157
|
const idField = getIdField(formConfig)
|
|
158
|
-
|
|
158
|
+
let query = `'${idField}'=\"${id}\"`;
|
|
159
|
+
if (globalScriptParams.recordQuery) {
|
|
160
|
+
query = globalScriptParams.recordQuery;
|
|
161
|
+
log.debug('Set custom record query to', globalScriptParams.recordQuery);
|
|
162
|
+
}
|
|
159
163
|
const returnValue = await queryRecords(formConfig, clientConfig, query, mapping, null, {limit:1}, includeString, globalScriptParams);
|
|
160
164
|
const record = returnValue.data[0];
|
|
161
165
|
return {data: record};
|
|
@@ -10,6 +10,7 @@ const config = require('../util/config');
|
|
|
10
10
|
async function getRelatedObjects(req, res, next) {
|
|
11
11
|
log.debug('include Data', req.includeArray);
|
|
12
12
|
log.debug('include Objects', req.includeObjectsList);
|
|
13
|
+
|
|
13
14
|
if (req.result && req.includeObjectsList && req.includeArray) {
|
|
14
15
|
let result = {};
|
|
15
16
|
const includedObjects = req.includeObjectsList;
|
|
@@ -195,6 +196,29 @@ function replaceObjectKeys(item) {
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
|
|
199
|
+
async function addLinks(req, res, next) {
|
|
200
|
+
if (!req.globalScriptParams) {
|
|
201
|
+
req.globalScriptParams = {};
|
|
202
|
+
}
|
|
203
|
+
const id = req.globalScriptParams.id2 || req.globalScriptParams.id;
|
|
204
|
+
const urlStart = req.url.split('?')[0];
|
|
205
|
+
if (req.result && id) {
|
|
206
|
+
let selfUrl = '';
|
|
207
|
+
if (urlStart.endsWith(id)) {
|
|
208
|
+
selfUrl = urlStart;
|
|
209
|
+
} else {
|
|
210
|
+
selfUrl = urlStart + '/' + id;
|
|
211
|
+
}
|
|
212
|
+
req.result.links = {
|
|
213
|
+
self: {
|
|
214
|
+
id: id,
|
|
215
|
+
href: selfUrl
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
next();
|
|
220
|
+
}
|
|
221
|
+
|
|
198
222
|
module.exports = {
|
|
199
|
-
getRelatedObjects
|
|
223
|
+
getRelatedObjects, addLinks
|
|
200
224
|
}
|
|
@@ -124,7 +124,8 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
124
124
|
scripts = allScripts.GET || [];
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
//TODO: Check if needed
|
|
128
|
+
//globalScriptParams.id = ticket[ticketConfig.requestIdField]
|
|
128
129
|
|
|
129
130
|
const requestType = ticketConfig.requestType;
|
|
130
131
|
if (requestType === 'incident') {
|
|
@@ -308,7 +309,6 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
308
309
|
if (scripts && scripts.postMapping) {
|
|
309
310
|
await scriptController.runScripts(scripts.postMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
310
311
|
}
|
|
311
|
-
|
|
312
312
|
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping, undefined, globalScriptParams);
|
|
313
313
|
log.debug('Ticket to Update', ticket);
|
|
314
314
|
//keep businessService CI Relation
|
|
@@ -322,7 +322,6 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
322
322
|
if (scripts && scripts.afterExecution) {
|
|
323
323
|
await scriptController.runScripts(scripts.afterExecution, ticketData, clientConfig.clientId, globalScriptParams);
|
|
324
324
|
}
|
|
325
|
-
|
|
326
325
|
return {updateResult: update, relationErrors};
|
|
327
326
|
}
|
|
328
327
|
|
|
@@ -49,6 +49,9 @@ async function createWorklog(ticketConfig, clientConfig, ticketId, data, globalS
|
|
|
49
49
|
)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
//todo Hier prüfen ob das Ticket existiert
|
|
53
|
+
|
|
54
|
+
|
|
52
55
|
const clientConstants = clientConfig[ticketConfig.requestTypeWorkLog].constants;
|
|
53
56
|
const viewAccessConstant = clientConstants.find(element => element.name === "View Access")
|
|
54
57
|
//run only if isPublic is set and no Constant is defined
|
|
@@ -249,6 +249,18 @@ Sample:
|
|
|
249
249
|
|
|
250
250
|
*AR_PASSWORD=password*
|
|
251
251
|
|
|
252
|
+
### BASEQUERY
|
|
253
|
+
|
|
254
|
+
Allows advanced control of the events that are handled by this Event Manager Engine.
|
|
255
|
+
|
|
256
|
+
e.g. Add a delay before events are processed
|
|
257
|
+
|
|
258
|
+
*BASEQUERY='Create Date' + 60 < $TIMESTAMP$*
|
|
259
|
+
|
|
260
|
+
e.g. Handle specific client events only
|
|
261
|
+
|
|
262
|
+
*BASEQUERY='VendorID' = "abc123"*
|
|
263
|
+
|
|
252
264
|
## SSO Connection
|
|
253
265
|
|
|
254
266
|
For a minimum configuration only the SSO Public Key is required.
|
package/docs/releases.md
CHANGED
package/package.json
CHANGED
|
@@ -63,7 +63,12 @@ module.exports = (function() {
|
|
|
63
63
|
const recordId = createResult;
|
|
64
64
|
eventLog.setTicketId(req, recordId);
|
|
65
65
|
req.eventData.ticketNumber = recordId;
|
|
66
|
-
|
|
66
|
+
if (req.globalScriptParams && req.globalScriptParams.notFetchResult && req.globalScriptParams.notFetchResult === true) {
|
|
67
|
+
req.result = {};
|
|
68
|
+
next()
|
|
69
|
+
} else {
|
|
70
|
+
getRecord(req, res, next, req.user.config, recordId, null, includeString);
|
|
71
|
+
}
|
|
67
72
|
}).catch(function (reason) {
|
|
68
73
|
next(reason);
|
|
69
74
|
});
|
|
@@ -164,7 +169,12 @@ module.exports = (function() {
|
|
|
164
169
|
} else {
|
|
165
170
|
customFormController.updateRecord(req.formConfig, req.user.config, id, req.body.data, req.globalScriptParams)
|
|
166
171
|
.then(async function (updateResult) {
|
|
167
|
-
|
|
172
|
+
if (req.globalScriptParams && req.globalScriptParams.notFetchResult && req.globalScriptParams.notFetchResult === true) {
|
|
173
|
+
req.result = {};
|
|
174
|
+
next()
|
|
175
|
+
} else {
|
|
176
|
+
getRecord(req, res, next, req.user.config, id, null, includeString);
|
|
177
|
+
}
|
|
168
178
|
}).catch(function (reason) {
|
|
169
179
|
next(reason);
|
|
170
180
|
});
|
package/routes/taskRoutes.js
CHANGED
|
@@ -76,13 +76,18 @@ module.exports = (function () {
|
|
|
76
76
|
log.debug('Add ciRelations to task', taskId, taskInstanceId, relations)
|
|
77
77
|
await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, taskInstanceId, relations);
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
req.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
if (req.globalScriptParams && req.globalScriptParams.notFetchResult && req.globalScriptParams.notFetchResult === true) {
|
|
80
|
+
req.result = {};
|
|
81
|
+
next()
|
|
82
|
+
} else {
|
|
83
|
+
task.getTaskByRootRequest(req.user.config, req.parentId, taskId, req.globalScriptParams, includeString).then(function (result) {
|
|
84
|
+
req.includeObjectsList = result.included;
|
|
85
|
+
req.result = {data: result.data || {}};
|
|
86
|
+
next();
|
|
87
|
+
}).catch(function (reason) {
|
|
88
|
+
next(reason);
|
|
89
|
+
})
|
|
90
|
+
}
|
|
86
91
|
}
|
|
87
92
|
}).catch(function (reason) {
|
|
88
93
|
next(reason);
|
|
@@ -139,13 +144,18 @@ module.exports = (function () {
|
|
|
139
144
|
log.debug('Add ciRelations to task', taskId, taskInstanceId, relations)
|
|
140
145
|
await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, taskInstanceId, relations);
|
|
141
146
|
}
|
|
142
|
-
|
|
143
|
-
req.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
if (req.globalScriptParams && req.globalScriptParams.notFetchResult && req.globalScriptParams.notFetchResult === true) {
|
|
148
|
+
req.result = {};
|
|
149
|
+
next()
|
|
150
|
+
} else {
|
|
151
|
+
task.getTaskByRootRequest(req.user.config, req.parentId, taskId, req.globalScriptParams, includeString).then(function (result) {
|
|
152
|
+
req.includeObjectsList = result.included;
|
|
153
|
+
req.result = {data: result.data || {}};
|
|
154
|
+
next();
|
|
155
|
+
}).catch(function (reason) {
|
|
156
|
+
next(reason);
|
|
157
|
+
})
|
|
158
|
+
}
|
|
149
159
|
}).catch(function (reason) {
|
|
150
160
|
next(reason);
|
|
151
161
|
});
|
package/routes/ticketRoutes.js
CHANGED
|
@@ -73,7 +73,12 @@ module.exports = (function() {
|
|
|
73
73
|
eventLog.setTicketId(req, ticketId);
|
|
74
74
|
req.eventData.ticketNumber = ticketId;
|
|
75
75
|
//await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, ticketId, relations);
|
|
76
|
-
|
|
76
|
+
if (req.globalScriptParams && req.globalScriptParams.notFetchResult && req.globalScriptParams.notFetchResult === true) {
|
|
77
|
+
req.result = {};
|
|
78
|
+
next()
|
|
79
|
+
} else {
|
|
80
|
+
getTicket(req, res, next, req.user.config, ticketId, null, includeString, {errors: {ciRelationErrors: relationErrors}});
|
|
81
|
+
}
|
|
77
82
|
}).catch(function (reason) {
|
|
78
83
|
next(reason);
|
|
79
84
|
});
|
|
@@ -184,7 +189,12 @@ module.exports = (function() {
|
|
|
184
189
|
req.responseStatus = 422;
|
|
185
190
|
}
|
|
186
191
|
//await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, id, relations);
|
|
187
|
-
|
|
192
|
+
if (req.globalScriptParams && req.globalScriptParams.notFetchResult && req.globalScriptParams.notFetchResult === true) {
|
|
193
|
+
req.result = {};
|
|
194
|
+
next()
|
|
195
|
+
} else {
|
|
196
|
+
getTicket(req, res, next, req.user.config, id, null, includeString, {errors: {ciRelationErrors: relationErrors}});
|
|
197
|
+
}
|
|
188
198
|
}).catch(function (reason) {
|
|
189
199
|
next(reason);
|
|
190
200
|
});
|
|
@@ -173,10 +173,15 @@ module.exports = (function() {
|
|
|
173
173
|
req.globalScriptParams.id = ticketId
|
|
174
174
|
req.globalScriptParams.id2 = worklogId
|
|
175
175
|
log.debug('WorkLog created', worklogId);
|
|
176
|
-
|
|
177
|
-
req.result =
|
|
178
|
-
next()
|
|
179
|
-
}
|
|
176
|
+
if (req.globalScriptParams && req.globalScriptParams.notFetchResult && req.globalScriptParams.notFetchResult === true) {
|
|
177
|
+
req.result = {};
|
|
178
|
+
next()
|
|
179
|
+
} else {
|
|
180
|
+
ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId, undefined, req.globalScriptParams).then(worklogResult => {
|
|
181
|
+
req.result = worklogResult;
|
|
182
|
+
next();
|
|
183
|
+
});
|
|
184
|
+
}
|
|
180
185
|
})
|
|
181
186
|
.catch(error => {
|
|
182
187
|
next(error);
|