@manyos/smileconnect-api 1.57.2 → 1.58.1

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 CHANGED
@@ -328,6 +328,7 @@ app.use('/v1/customForms/:formAlias', async function(req, res, next) {
328
328
  configName: 'custom_' + formMapping.formName,
329
329
  mapping: formMapping.mapping
330
330
  }
331
+ req.globalScriptParams.formConfig = req.formConfig
331
332
  req.parentEventBase = 'customForm'
332
333
  next();
333
334
  }, customFormRoutes);
package/conf/clients.json CHANGED
@@ -2294,8 +2294,13 @@
2294
2294
  },
2295
2295
  "POST": {
2296
2296
  "preMapping": [],
2297
- "postMapping": [],
2298
- "afterExecution": []
2297
+ "postMapping": [
2298
+ "joinSetId",
2299
+ "setAssetId"
2300
+ ],
2301
+ "afterExecution": [
2302
+ "getAssetId"
2303
+ ]
2299
2304
  }
2300
2305
  }
2301
2306
  },
@@ -22,6 +22,7 @@
22
22
  "customFormTest": {
23
23
  "formName": "MYS:CustomFormTest",
24
24
  "mapping": {
25
+ "Request ID": "id",
25
26
  "Short Description": "shortDescription",
26
27
  "Submitter": "submitter",
27
28
  "Status": "status"
@@ -28,6 +28,7 @@ function getRecords(formConfig, clientConfig, includeString, customOptions, glob
28
28
 
29
29
  async function createRecord(formConfig, clientConfig, data, globalScriptParams) {
30
30
  const idField = getIdField(formConfig)
31
+ globalScriptParams.idField = idField;
31
32
  const allScripts = clientConfig[formConfig.configName].scripts;
32
33
  let scripts
33
34
  if (allScripts) {
@@ -39,8 +40,6 @@ async function createRecord(formConfig, clientConfig, data, globalScriptParams)
39
40
  await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId, globalScriptParams);
40
41
  }
41
42
 
42
- const requestType = formConfig.requestType;
43
-
44
43
  const mapping = formConfig.mapping;
45
44
  log.debug('mapping', mapping);
46
45
 
@@ -56,33 +55,25 @@ async function createRecord(formConfig, clientConfig, data, globalScriptParams)
56
55
  const result = await arquery.createEntry(formConfig.formName, data, clientConfig.options)
57
56
 
58
57
  log.debug('RecordCreateResult', result.data);
59
- let recordCreateId = Object.values(result)[0];
58
+ if (!globalScriptParams.id && Object.values(result)[0]) {
59
+ globalScriptParams.id = Object.values(result)[0];
60
+ }
60
61
  //Find change id
61
- if (!recordCreateId) {
62
- recordCreateId = data[idField]
62
+ if (!globalScriptParams.id) {
63
+ globalScriptParams.id = data[idField]
63
64
  }
64
- if (!recordCreateId) {
65
+ if (!globalScriptParams.id) {
65
66
  throw ({message: `Id of new record could not be determined. Please provide ${idField} for join forms.`})
66
67
  }
67
68
 
68
- log.error(idField)
69
- log.error(recordCreateId)
70
-
71
- //const query = `'${idField}'=\"${recordCreateId}\"`;
69
+ log.debug(idField)
70
+ log.debug(globalScriptParams.recordCreateId)
72
71
 
73
- /*const resultInterfaceCreate = await arquery.executeARQuery(formConfig.formName, null, query, formConfig.ticketIdField, clientConfig.options)
74
- if (resultInterfaceCreate.data && Array.isArray(resultInterfaceCreate.data) && resultInterfaceCreate.data.length > 0) {
75
- const recordCreateId = resultInterfaceCreate.data[0][formConfig.ticketIdField];
76
- } else {
77
- log.error('Cannot create Record', resultInterfaceCreate);
78
- throw({message: 'Cannot create Record', details : resultInterfaceCreate});
79
- }*/
80
- globalScriptParams.id = recordCreateId
81
72
  //run afterExecution
82
73
  if (scripts && scripts.afterExecution) {
83
74
  await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
84
75
  }
85
- return recordCreateId;
76
+ return globalScriptParams.id;
86
77
  }
87
78
 
88
79
  function queryRecords(formConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams) {
@@ -2,6 +2,7 @@ const path = require('path');
2
2
  const log = require('@manyos/logger').setupLog('SMILEcatalog_' + path.basename(__filename));
3
3
  const adapterFoundation = require('@manyos/adapter-foundation');
4
4
  const fs = require('fs');
5
+ const { v4 } = require('uuid');
5
6
 
6
7
  const basePath = 'conf';
7
8
  const basePathGlobalScripts = basePath + '/scripts';
@@ -84,7 +85,8 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
84
85
  script:executeScriptByScript,
85
86
  globalScriptParams,
86
87
  env: process.env,
87
- fetch:fetch
88
+ fetch:fetch,
89
+ uid:v4
88
90
  };
89
91
 
90
92
  sandbox.executedByScript = executedByScript === true;
package/docs/adapter.md CHANGED
@@ -243,8 +243,8 @@ The id of the attachment field
243
243
 
244
244
  Full example:
245
245
  ```javascript
246
- const file = adapter.remedy.getAttachment('CHG:WorkLog', 'CWL000000002484', '1000000353')
247
- const fileName = file.name
246
+ const file = await adapter.remedy.getAttachment('CHG:WorkLog', 'CWL000000002484', '1000000353')
247
+ const fileName = file.fileName
248
248
  const fileData = file.data
249
249
  ```
250
250
 
@@ -282,6 +282,132 @@ const file = {
282
282
  await adapter.remedy.setAttachment('CHG:WorkLog', 'CWL000000002484', '1000000353', file)
283
283
  ```
284
284
 
285
+ ### getMetadata
286
+
287
+ ```javascript
288
+ async getMetadata(form)
289
+ ```
290
+
291
+ Parameter:
292
+
293
+ * form (string):
294
+
295
+ Optional. If provided all fields of the form are returned. If not provided all forms are returned.
296
+
297
+ Sample response formList
298
+ ```javascript
299
+ [
300
+ "AAS:Activity",
301
+ "AAS:Activity2",
302
+ "AAS:ActivityInterface",
303
+ "AAS:ActivityInterface_Create",
304
+ "AAS:ActivityTaskJoin",
305
+ "AAS:AuditFilters",
306
+ "AAS:AuditLog",
307
+ "AAS:AuditLogSystem",
308
+ "AAS:CFG Notification Rules",
309
+ "AAS:CFG Rules",
310
+ "AAS:ConfigurationTicketNumGenerator",
311
+ "AAS:LoadActivity",
312
+ "AAS:LoadCFGNotificationRules",
313
+ "AAS:LoadCFGRules",
314
+ "AAS:LoadTemplate"
315
+ ]
316
+ ```
317
+ Sample response fieldList
318
+ ```javascript
319
+ [
320
+ {
321
+ "entryMode": "System",
322
+ "fieldId": 1,
323
+ "fieldLimit": {
324
+ "QBEMatch": 1,
325
+ "charMenu": "",
326
+ "dataType": 4,
327
+ "fullTextOption": 0,
328
+ "lengthUnits": 0,
329
+ "maxLength": 15,
330
+ "menuStyle": 1,
331
+ "pattern": "",
332
+ "storageOptionForCLOB": 0
333
+ },
334
+ "name": "Request ID",
335
+ "type": "CharacterField",
336
+ "valueMapping": null
337
+ },
338
+ {
339
+ "entryMode": "Required",
340
+ "fieldId": 2,
341
+ "fieldLimit": {
342
+ "QBEMatch": 1,
343
+ "charMenu": "",
344
+ "dataType": 4,
345
+ "fullTextOption": 0,
346
+ "lengthUnits": 0,
347
+ "maxLength": 254,
348
+ "menuStyle": 2,
349
+ "pattern": "",
350
+ "storageOptionForCLOB": 0
351
+ },
352
+ "name": "Creator",
353
+ "type": "CharacterField",
354
+ "valueMapping": null
355
+ },
356
+ {
357
+ "entryMode": "System",
358
+ "fieldId": 3,
359
+ "fieldLimit": null,
360
+ "name": "Create Date",
361
+ "type": "DateTimeField",
362
+ "valueMapping": null
363
+ },
364
+ {
365
+ "entryMode": "Optional",
366
+ "fieldId": 4,
367
+ "fieldLimit": {
368
+ "QBEMatch": 1,
369
+ "charMenu": "",
370
+ "dataType": 4,
371
+ "fullTextOption": 0,
372
+ "lengthUnits": 0,
373
+ "maxLength": 254,
374
+ "menuStyle": 1,
375
+ "pattern": "",
376
+ "storageOptionForCLOB": 0
377
+ },
378
+ "name": "Assigned To",
379
+ "type": "CharacterField",
380
+ "valueMapping": null
381
+ },
382
+ {
383
+ "entryMode": "System",
384
+ "fieldId": 5,
385
+ "fieldLimit": {
386
+ "QBEMatch": 1,
387
+ "charMenu": "",
388
+ "dataType": 4,
389
+ "fullTextOption": 0,
390
+ "lengthUnits": 0,
391
+ "maxLength": 254,
392
+ "menuStyle": 1,
393
+ "pattern": "",
394
+ "storageOptionForCLOB": 0
395
+ },
396
+ "name": "Last Modified By",
397
+ "type": "CharacterField",
398
+ "valueMapping": null
399
+ },
400
+ {
401
+ "entryMode": "System",
402
+ "fieldId": 6,
403
+ "fieldLimit": null,
404
+ "name": "Modified Date",
405
+ "type": "DateTimeField",
406
+ "valueMapping": null
407
+ }
408
+ ]
409
+ ```
410
+
285
411
  ### Options
286
412
 
287
413
  * limit
package/docs/releases.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Release Notes
2
2
 
3
- ## API
3
+ ## API
4
+ ### 1.58.0 - 31.03.22
5
+ Add uid() to scripts
6
+ In customForms(create) make globalScripts.id changeable
7
+ Add getMetaData to Remedy Adapter
8
+ Fix: Issue with special characters in fieldlist of Remedy Adapter Search function
4
9
 
5
10
  ### 1.57.2 - 28.03.22
6
11
  Fix problem with custom ids on custom forms
@@ -9,8 +14,8 @@ Fix problem with custom ids on custom forms
9
14
  Remove misleading error from CustomFormMappings
10
15
 
11
16
  ### 1.57.0 - 25.03.22
12
-
13
17
  Add impersonate to update requests.
18
+ Add user parameter to globalScriptParams
14
19
  Impersonate works not on the following requests:
15
20
  - Add/Read Attachments
16
21
  - Ticket/CI Relations
package/docs/scripts.md CHANGED
@@ -119,8 +119,27 @@ Global script params are set by the application and handed over to the script. T
119
119
 
120
120
  **sourceData**: Contains the original body for PUT/POST request. This can be used scripts to access custom data that was removed during mapping.
121
121
 
122
- **user**: Contains the full configuration of the client. The attribute user.config.options.impersonateUser might be overwritten by the dynamic passed value if user.config.options.allowDynamicImpersonate ist set to true.
122
+ **user**: Contains the full configuration of the client. The attribute user.config.options.impersonateUser might be overwritten by the dynamic passed value if user.config.options.allowDynamicImpersonate ist set to true.
123
123
 
124
+ **formConfig**: Contains the configuration of the cutstom form. *Only available for custom forms*
125
+
126
+ e.g.
127
+ ```json
128
+ "formConfig": {
129
+ "formName": "AST:ComputerSystem",
130
+ "configName": "custom_AST:ComputerSystem",
131
+ "mapping": {
132
+ "Name": "name",
133
+ "DatasetId": "dataSetId",
134
+ "Asset ID+": "id",
135
+ "Reconciliation Identity": "reconId",
136
+ "Instance Id": "instanceId",
137
+ "Short Description": "shortDescription"
138
+ }
139
+ }
140
+ ```
141
+
142
+ Full example:
124
143
  ```json
125
144
  {
126
145
  "query": {
@@ -230,6 +249,15 @@ See https://www.npmjs.com/package/node-fetch for details.
230
249
 
231
250
  Allows to make adapter calls. [See details](../configuration/adapter.md)
232
251
 
252
+ ## uid
253
+
254
+ Generated a new unique id. [See details](https://www.npmjs.com/package/uuid#uuidv4options-buffer-offset)
255
+
256
+ ```javascript
257
+ const myInstanceId = uid();
258
+ requestData['Instance Id'] = myInstanceId;
259
+ ```
260
+
233
261
  # Returning values
234
262
 
235
263
  Values can be returned with the function *resolve()*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manyos/smileconnect-api",
3
- "version": "1.57.2",
3
+ "version": "1.58.1",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -78,7 +78,9 @@ function eventQueueHandler(req, res, next) {
78
78
  res.set('Content-disposition', 'attachment; filename=' + req.downloadResult.fileName);
79
79
  res.status(200).send(req.downloadResult.data);
80
80
  } else {
81
+ log.debug('send http repsonse', req.result)
81
82
  res.status(req.responseStatus || 200).json(req.result)
83
+ log.debug('send http done')
82
84
  }
83
85
  }).catch(error => {
84
86
  next(error);