@manyos/smileconnect-api 1.57.1 → 1.58.0

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 CHANGED
@@ -2178,6 +2178,18 @@
2178
2178
  "constants": [],
2179
2179
  "scripts": {}
2180
2180
  },
2181
+ "custom_MYS:CustomFormTest": {
2182
+ "basequery": "1=1",
2183
+ "fields": [
2184
+ "Request ID",
2185
+ "Short Description",
2186
+ "Submitter",
2187
+ "Status",
2188
+ "Submitter"
2189
+ ],
2190
+ "constants": [],
2191
+ "scripts": {}
2192
+ },
2181
2193
  "changeWorklog": {
2182
2194
  "fields": [
2183
2195
  "Description",
@@ -2255,6 +2267,43 @@
2255
2267
  "basequery": "",
2256
2268
  "scripts": {}
2257
2269
  },
2270
+ "custom_AST:ComputerSystem": {
2271
+ "basequery": "1=1",
2272
+ "fields": [
2273
+ "Instance Id",
2274
+ "Reconciliation Identity",
2275
+ "Name",
2276
+ "Short Description",
2277
+ "Asset ID+"
2278
+ ],
2279
+ "constants": [
2280
+ {
2281
+ "name": "Data Set Id",
2282
+ "value": "BMC.ASSET"
2283
+ }
2284
+ ],
2285
+ "scripts": {
2286
+ "GET": {
2287
+ "preMapping": [],
2288
+ "postMapping": []
2289
+ },
2290
+ "PUT": {
2291
+ "preMapping": [],
2292
+ "postMapping": [],
2293
+ "afterExecution": []
2294
+ },
2295
+ "POST": {
2296
+ "preMapping": [],
2297
+ "postMapping": [
2298
+ "joinSetId",
2299
+ "setAssetId"
2300
+ ],
2301
+ "afterExecution": [
2302
+ "getAssetId"
2303
+ ]
2304
+ }
2305
+ }
2306
+ },
2258
2307
  "incident": {
2259
2308
  "fields": [
2260
2309
  "Incident Number",
@@ -2317,10 +2366,10 @@
2317
2366
  "basequery": "1=1",
2318
2367
  "scripts": {
2319
2368
  "GET": {
2320
- "preMapping": [
2369
+ "preMapping": [],
2370
+ "postMapping": [
2321
2371
  "createRecord"
2322
2372
  ],
2323
- "postMapping": [],
2324
2373
  "afterExecution": []
2325
2374
  },
2326
2375
  "POST": {
@@ -19,6 +19,15 @@
19
19
  "Department": "Department"
20
20
  }
21
21
  },
22
+ "customFormTest": {
23
+ "formName": "MYS:CustomFormTest",
24
+ "mapping": {
25
+ "Request ID": "id",
26
+ "Short Description": "shortDescription",
27
+ "Submitter": "submitter",
28
+ "Status": "status"
29
+ }
30
+ },
22
31
  "Tasks": {
23
32
  "formName": "TMS:Task",
24
33
  "mapping": {
@@ -71,5 +80,16 @@
71
80
  "Class Id": "class",
72
81
  "Class Id2": "class4"
73
82
  }
83
+ },
84
+ "computerSystem": {
85
+ "formName": "AST:ComputerSystem",
86
+ "mapping": {
87
+ "Name": "name",
88
+ "DatasetId": "dataSetId",
89
+ "Asset ID+": "id",
90
+ "Reconciliation Identity": "reconId",
91
+ "Instance Id": "instanceId",
92
+ "Short Description": "shortDescription"
93
+ }
74
94
  }
75
95
  }
@@ -27,6 +27,8 @@ function getRecords(formConfig, clientConfig, includeString, customOptions, glob
27
27
  }
28
28
 
29
29
  async function createRecord(formConfig, clientConfig, data, globalScriptParams) {
30
+ const idField = getIdField(formConfig)
31
+ globalScriptParams.idField = idField;
30
32
  const allScripts = clientConfig[formConfig.configName].scripts;
31
33
  let scripts
32
34
  if (allScripts) {
@@ -38,8 +40,6 @@ async function createRecord(formConfig, clientConfig, data, globalScriptParams)
38
40
  await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId, globalScriptParams);
39
41
  }
40
42
 
41
- const requestType = formConfig.requestType;
42
-
43
43
  const mapping = formConfig.mapping;
44
44
  log.debug('mapping', mapping);
45
45
 
@@ -55,21 +55,25 @@ async function createRecord(formConfig, clientConfig, data, globalScriptParams)
55
55
  const result = await arquery.createEntry(formConfig.formName, data, clientConfig.options)
56
56
 
57
57
  log.debug('RecordCreateResult', result.data);
58
- const recordCreateId = Object.values(result)[0];
58
+ if (!globalScriptParams.id && Object.values(result)[0]) {
59
+ globalScriptParams.id = Object.values(result)[0];
60
+ }
59
61
  //Find change id
60
- const resultInterfaceCreate = await arquery.executeARQuery(formConfig.formName, null, "'1'=\"" + recordCreateId + "\"", formConfig.ticketIdField, clientConfig.options)
61
- if (resultInterfaceCreate.data && Array.isArray(resultInterfaceCreate.data) && resultInterfaceCreate.data.length > 0) {
62
- const recordCreateId = resultInterfaceCreate.data[0][formConfig.ticketIdField];
63
- } else {
64
- log.error('Cannot create Record', resultInterfaceCreate);
65
- throw({message: 'Cannot create Record', details : resultInterfaceCreate});
66
- }
67
- globalScriptParams.id = recordCreateId
62
+ if (!globalScriptParams.id) {
63
+ globalScriptParams.id = data[idField]
64
+ }
65
+ if (!globalScriptParams.id) {
66
+ throw ({message: `Id of new record could not be determined. Please provide ${idField} for join forms.`})
67
+ }
68
+
69
+ log.debug(idField)
70
+ log.debug(globalScriptParams.recordCreateId)
71
+
68
72
  //run afterExecution
69
73
  if (scripts && scripts.afterExecution) {
70
74
  await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
71
75
  }
72
- return recordCreateId;
76
+ return globalScriptParams.id;
73
77
  }
74
78
 
75
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,13 +1,21 @@
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
9
+
10
+ ### 1.57.2 - 28.03.22
11
+ Fix problem with custom ids on custom forms
4
12
 
5
13
  ### 1.57.1 - 25.03.22
6
14
  Remove misleading error from CustomFormMappings
7
15
 
8
16
  ### 1.57.0 - 25.03.22
9
-
10
17
  Add impersonate to update requests.
18
+ Add user parameter to globalScriptParams
11
19
  Impersonate works not on the following requests:
12
20
  - Add/Read Attachments
13
21
  - Ticket/CI Relations
package/docs/scripts.md CHANGED
@@ -230,6 +230,15 @@ See https://www.npmjs.com/package/node-fetch for details.
230
230
 
231
231
  Allows to make adapter calls. [See details](../configuration/adapter.md)
232
232
 
233
+ ## uid
234
+
235
+ Generated a new unique id. [See details](https://www.npmjs.com/package/uuid#uuidv4options-buffer-offset)
236
+
237
+ ```javascript
238
+ const myInstanceId = uid();
239
+ requestData['Instance Id'] = myInstanceId;
240
+ ```
241
+
233
242
  # Returning values
234
243
 
235
244
  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.1",
3
+ "version": "1.58.0",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {