@manyos/smileconnect-api 1.36.0 → 1.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/conf/clients.json +19 -1
- package/conf/scripts/script1.js +1 -1
- package/conf/scripts/scriptPutPost.js +2 -0
- package/conf/scripts/scriptPutPre.js +2 -0
- package/controller/cmdbobjectController.js +15 -1
- package/package.json +1 -1
- package/routes/cmdbObjectRoutes.js +1 -1
- package/util/schemas/fieldMappingSchema.js +16 -1
package/conf/clients.json
CHANGED
|
@@ -165,7 +165,25 @@
|
|
|
165
165
|
"value": "Calbro Services and Weapons"
|
|
166
166
|
}
|
|
167
167
|
],
|
|
168
|
-
"scripts": {
|
|
168
|
+
"scripts": {
|
|
169
|
+
"GET": {
|
|
170
|
+
"preMapping": [
|
|
171
|
+
"script1",
|
|
172
|
+
"script2"
|
|
173
|
+
],
|
|
174
|
+
"postMapping": [
|
|
175
|
+
"script2"
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
"POST": {
|
|
179
|
+
"preMapping": [
|
|
180
|
+
"scriptPutPre"
|
|
181
|
+
],
|
|
182
|
+
"postMapping": [
|
|
183
|
+
"scriptPutPost"
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
}
|
|
169
187
|
},
|
|
170
188
|
"change": {
|
|
171
189
|
"fields": [
|
package/conf/scripts/script1.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//requestData.
|
|
1
|
+
//requestData.Name = "Horstdidü";
|
|
2
2
|
resolve();
|
|
@@ -176,6 +176,15 @@ async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, include
|
|
|
176
176
|
if (deleteClassId === true) {
|
|
177
177
|
delete cmdbObject[CMDBOBJECT];
|
|
178
178
|
}
|
|
179
|
+
|
|
180
|
+
const scripts = clientConfig[CMDBOBJECT].scripts.GET;
|
|
181
|
+
//const fields = clientConfig[ticketConfig.requestType].fields
|
|
182
|
+
|
|
183
|
+
//run preScripts
|
|
184
|
+
if (scripts && scripts.preMapping) {
|
|
185
|
+
await scriptController.runScripts(scripts.preMapping, cmdbObject, clientConfig.clientId);
|
|
186
|
+
}
|
|
187
|
+
|
|
179
188
|
//Apply mapping
|
|
180
189
|
mapping.forEach(function (mappingEntry) {
|
|
181
190
|
try {
|
|
@@ -225,6 +234,11 @@ async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, include
|
|
|
225
234
|
|
|
226
235
|
relationUtil.getRelatedObjectList(cmdbObject, includeArray, globalRelationObjects);
|
|
227
236
|
|
|
237
|
+
//run preScripts
|
|
238
|
+
if (scripts && scripts.postMapping) {
|
|
239
|
+
await scriptController.runScripts(scripts.postMapping, cmdbObject, clientConfig.clientId);
|
|
240
|
+
}
|
|
241
|
+
|
|
228
242
|
return cmdbObject;
|
|
229
243
|
}
|
|
230
244
|
|
|
@@ -361,7 +375,7 @@ async function createCmdbObject(assetConfig, clientConfig, classId, ciData) {
|
|
|
361
375
|
const reconId = getRandomId();
|
|
362
376
|
const instanceId = getRandomId();
|
|
363
377
|
|
|
364
|
-
const scripts = clientConfig[CMDBOBJECT].scripts.
|
|
378
|
+
const scripts = clientConfig[CMDBOBJECT].scripts.POST;
|
|
365
379
|
//const fields = clientConfig[ticketConfig.requestType].fields
|
|
366
380
|
|
|
367
381
|
//run preScripts
|
package/package.json
CHANGED
|
@@ -197,7 +197,7 @@ module.exports = (function () {
|
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
-
cmdbObjectRoutes.post('/', async function (req, res, next) {
|
|
200
|
+
cmdbObjectRoutes.post('/', checkSchema(fieldMappingSchemas.CMDBCreateDataSchema), async function (req, res, next) {
|
|
201
201
|
const classId = req.body.classId;
|
|
202
202
|
const includeString = req.query.include;
|
|
203
203
|
eventLog.setEventData(
|
|
@@ -41,6 +41,21 @@ const fieldMappingItemSchema = {
|
|
|
41
41
|
}*/
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
const CMDBCreateDataSchema = {
|
|
45
|
+
'classId' : {
|
|
46
|
+
in: ['body'],
|
|
47
|
+
exists: {
|
|
48
|
+
errorMessage: 'Is required'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
'data' : {
|
|
52
|
+
in: ['body'],
|
|
53
|
+
exists: {
|
|
54
|
+
errorMessage: 'Is required'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
44
59
|
const validateCMDBDataSchema = {
|
|
45
60
|
'ciChanges' : {
|
|
46
61
|
in: ['body'],
|
|
@@ -207,5 +222,5 @@ const fieldMappingSchema = {
|
|
|
207
222
|
};
|
|
208
223
|
|
|
209
224
|
module.exports = {
|
|
210
|
-
fieldMappingSchema, fieldMappingItemSchema, validateCMDBDataSchema
|
|
225
|
+
fieldMappingSchema, fieldMappingItemSchema, validateCMDBDataSchema, CMDBCreateDataSchema
|
|
211
226
|
};
|