@manyos/smileconnect-api 1.59.2 → 1.59.3
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.
|
@@ -440,7 +440,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
//Set error array
|
|
443
|
-
|
|
443
|
+
let errors = [];
|
|
444
444
|
|
|
445
445
|
//Check CI Relations
|
|
446
446
|
if (relations && relations.ciRelations && Array.isArray(relations.ciRelations)) {
|
|
@@ -515,6 +515,9 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
+
if (errors && errors.length > 0) {
|
|
519
|
+
errors = errors.map(item => item.message)
|
|
520
|
+
}
|
|
518
521
|
return errors;
|
|
519
522
|
}
|
|
520
523
|
|
|
@@ -20,6 +20,7 @@ function getTickets(ticketConfig, config, includeString, customOptions, globalSc
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async function createTicket(ticketConfig, clientConfig, data, globalScriptParams) {
|
|
23
|
+
let relationErrors;
|
|
23
24
|
const scripts = clientConfig[ticketConfig.requestType].scripts.POST;
|
|
24
25
|
const relations = data.relations || {}
|
|
25
26
|
//run preScripts
|
|
@@ -57,11 +58,7 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
57
58
|
if (data[ticketConfig.businessServiceReconIdField] && relations) {
|
|
58
59
|
relations.keepCIs = [data[ticketConfig.businessServiceReconIdField]]
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
if (relationErrors && relationErrors.length > 0) {
|
|
62
|
-
log.error(relationErrors)
|
|
63
|
-
throw relationErrors;
|
|
64
|
-
}
|
|
61
|
+
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, ticketId, relations);
|
|
65
62
|
|
|
66
63
|
} else {
|
|
67
64
|
log.error('Cannot create Ticket', resultInterfaceCreate);
|
|
@@ -72,7 +69,7 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
72
69
|
if (scripts && scripts.afterExecution) {
|
|
73
70
|
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
74
71
|
}
|
|
75
|
-
return resultInterfaceCreate;
|
|
72
|
+
return {createResult: resultInterfaceCreate, relationErrors};
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams) {
|
|
@@ -287,6 +284,7 @@ async function getTicket(ticketConfig, config, id, mapping, includeString, globa
|
|
|
287
284
|
}
|
|
288
285
|
|
|
289
286
|
async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams) {
|
|
287
|
+
let relationErrors;
|
|
290
288
|
const scripts = clientConfig[ticketConfig.requestType].scripts.PUT;
|
|
291
289
|
const fields = clientConfig[ticketConfig.requestType].fields
|
|
292
290
|
const relations = ticketData.relations || {}
|
|
@@ -319,17 +317,13 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
319
317
|
}
|
|
320
318
|
//todo Abfangen wenn getTicket nichts liefert.
|
|
321
319
|
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData, clientConfig.options);
|
|
322
|
-
|
|
323
|
-
if (relationErrors && relationErrors.length > 0) {
|
|
324
|
-
log.error(relationErrors)
|
|
325
|
-
throw relationErrors;
|
|
326
|
-
}
|
|
320
|
+
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, id, relations);
|
|
327
321
|
//run afterExecution
|
|
328
322
|
if (scripts && scripts.afterExecution) {
|
|
329
323
|
await scriptController.runScripts(scripts.afterExecution, ticketData, clientConfig.clientId, globalScriptParams);
|
|
330
324
|
}
|
|
331
325
|
|
|
332
|
-
return update;
|
|
326
|
+
return {updateResult: update, relationErrors};
|
|
333
327
|
}
|
|
334
328
|
|
|
335
329
|
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams) {
|
package/docs/releases.md
CHANGED
package/package.json
CHANGED
package/routes/ticketRoutes.js
CHANGED
|
@@ -63,12 +63,17 @@ module.exports = (function() {
|
|
|
63
63
|
next(errors.array());
|
|
64
64
|
} else {
|
|
65
65
|
//const relations = req.body.data.relations;
|
|
66
|
-
ticketController.createTicket(req.ticketConfig, req.user.config, req.body.data, req.globalScriptParams).then(async function (
|
|
66
|
+
ticketController.createTicket(req.ticketConfig, req.user.config, req.body.data, req.globalScriptParams).then(async function (result) {
|
|
67
|
+
const createResult = result.createResult;
|
|
68
|
+
const relationErrors = result.relationErrors;
|
|
69
|
+
if (relationErrors && Array.isArray(relationErrors) && relationErrors.length > 0) {
|
|
70
|
+
req.responseStatus = 422;
|
|
71
|
+
}
|
|
67
72
|
const ticketId = createResult.data[0][req.ticketConfig.ticketIdField];
|
|
68
73
|
eventLog.setTicketId(req, ticketId);
|
|
69
74
|
req.eventData.ticketNumber = ticketId;
|
|
70
75
|
//await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, ticketId, relations);
|
|
71
|
-
getTicket(req, res, next, req.user.config, ticketId, null, includeString);
|
|
76
|
+
getTicket(req, res, next, req.user.config, ticketId, null, includeString, {errors:{ciRelationErrors:relationErrors}});
|
|
72
77
|
}).catch(function (reason) {
|
|
73
78
|
next(reason);
|
|
74
79
|
});
|
|
@@ -135,12 +140,15 @@ module.exports = (function() {
|
|
|
135
140
|
|
|
136
141
|
});
|
|
137
142
|
|
|
138
|
-
function getTicket(req, res, next, clientConfig, id, mapping, includeString) {
|
|
143
|
+
function getTicket(req, res, next, clientConfig, id, mapping, includeString, additionalData) {
|
|
139
144
|
req.globalScriptParams.id = id
|
|
140
145
|
ticketController.getTicket(req.ticketConfig, clientConfig, id, mapping, includeString, req.globalScriptParams).then(function (result) {
|
|
141
146
|
log.debug('result', result);
|
|
142
147
|
req.includeObjectsList = result.included;
|
|
143
148
|
req.result = {data:result.data || {}};
|
|
149
|
+
if (additionalData) {
|
|
150
|
+
req.result = {...req.result, ...additionalData};
|
|
151
|
+
}
|
|
144
152
|
if (!result.data) {
|
|
145
153
|
req.responseStatus = 404;
|
|
146
154
|
}
|
|
@@ -170,9 +178,13 @@ module.exports = (function() {
|
|
|
170
178
|
} else {
|
|
171
179
|
const relations = req.body.data.relations;
|
|
172
180
|
ticketController.updateTicket(req.ticketConfig, req.user.config, id, req.body.data, req.globalScriptParams)
|
|
173
|
-
.then(async function (
|
|
181
|
+
.then(async function (result) {
|
|
182
|
+
const relationErrors = result.relationErrors;
|
|
183
|
+
if (relationErrors && Array.isArray(relationErrors) && relationErrors.length > 0) {
|
|
184
|
+
req.responseStatus = 422;
|
|
185
|
+
}
|
|
174
186
|
//await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, id, relations);
|
|
175
|
-
getTicket(req, res, next, req.user.config, id, null, includeString);
|
|
187
|
+
getTicket(req, res, next, req.user.config, id, null, includeString, {errors:{ciRelationErrors:relationErrors}});
|
|
176
188
|
}).catch(function (reason) {
|
|
177
189
|
next(reason);
|
|
178
190
|
});
|