@manyos/smileconnect-api 1.59.1 → 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,7 +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
|
-
await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, ticketId, relations);
|
|
61
|
+
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, ticketId, relations);
|
|
61
62
|
|
|
62
63
|
} else {
|
|
63
64
|
log.error('Cannot create Ticket', resultInterfaceCreate);
|
|
@@ -68,7 +69,7 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
68
69
|
if (scripts && scripts.afterExecution) {
|
|
69
70
|
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
70
71
|
}
|
|
71
|
-
return resultInterfaceCreate;
|
|
72
|
+
return {createResult: resultInterfaceCreate, relationErrors};
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams) {
|
|
@@ -283,6 +284,7 @@ async function getTicket(ticketConfig, config, id, mapping, includeString, globa
|
|
|
283
284
|
}
|
|
284
285
|
|
|
285
286
|
async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams) {
|
|
287
|
+
let relationErrors;
|
|
286
288
|
const scripts = clientConfig[ticketConfig.requestType].scripts.PUT;
|
|
287
289
|
const fields = clientConfig[ticketConfig.requestType].fields
|
|
288
290
|
const relations = ticketData.relations || {}
|
|
@@ -315,17 +317,13 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
315
317
|
}
|
|
316
318
|
//todo Abfangen wenn getTicket nichts liefert.
|
|
317
319
|
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData, clientConfig.options);
|
|
318
|
-
|
|
319
|
-
if (relationErrors && relationErrors.length > 0) {
|
|
320
|
-
log.error(relationErrors)
|
|
321
|
-
throw relationErrors;
|
|
322
|
-
}
|
|
320
|
+
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, id, relations);
|
|
323
321
|
//run afterExecution
|
|
324
322
|
if (scripts && scripts.afterExecution) {
|
|
325
323
|
await scriptController.runScripts(scripts.afterExecution, ticketData, clientConfig.clientId, globalScriptParams);
|
|
326
324
|
}
|
|
327
325
|
|
|
328
|
-
return update;
|
|
326
|
+
return {updateResult: update, relationErrors};
|
|
329
327
|
}
|
|
330
328
|
|
|
331
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
|
});
|