@manyos/smileconnect-api 1.67.0 → 1.69.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
@@ -1,139 +1,4 @@
1
1
  [
2
- {
3
- "name": "horsti",
4
- "config": {
5
- "cmdbobject": {
6
- "basequery": "1=2",
7
- "fields": [],
8
- "constants": [],
9
- "scripts": {}
10
- },
11
- "change": {
12
- "basequery": "1=2",
13
- "fields": [],
14
- "constants": [],
15
- "scripts": {}
16
- },
17
- "changeWorklog": {
18
- "basequery": "1=2",
19
- "fields": [],
20
- "constants": [],
21
- "scripts": {},
22
- "attachmentScripts": {}
23
- },
24
- "incident": {
25
- "basequery": "1=1",
26
- "fields": [
27
- "Description"
28
- ],
29
- "constants": [],
30
- "scripts": {}
31
- },
32
- "incidentWorklog": {
33
- "basequery": "1=2",
34
- "fields": [],
35
- "constants": [],
36
- "scripts": {},
37
- "attachmentScripts": {}
38
- },
39
- "person": {
40
- "basequery": "1=2",
41
- "fields": [],
42
- "constants": [],
43
- "scripts": {}
44
- },
45
- "problem": {
46
- "basequery": "1=2",
47
- "fields": [],
48
- "constants": [],
49
- "scripts": {}
50
- },
51
- "problemWorklog": {
52
- "basequery": "1=2",
53
- "fields": [],
54
- "constants": [],
55
- "scripts": {},
56
- "attachmentScripts": {}
57
- },
58
- "supportGroup": {
59
- "basequery": "1=2",
60
- "fields": [],
61
- "constants": [],
62
- "scripts": {}
63
- },
64
- "organisation": {
65
- "basequery": "1=2",
66
- "fields": [],
67
- "constants": [],
68
- "scripts": {}
69
- },
70
- "workOrder": {
71
- "basequery": "1=2",
72
- "fields": [],
73
- "constants": [],
74
- "scripts": {}
75
- },
76
- "workOrderWorklog": {
77
- "basequery": "1=2",
78
- "fields": [],
79
- "constants": [],
80
- "scripts": {},
81
- "attachmentScripts": {}
82
- },
83
- "task": {
84
- "basequery": "1=2",
85
- "fields": [],
86
- "constants": [],
87
- "scripts": {}
88
- },
89
- "taskWorklog": {
90
- "basequery": "1=2",
91
- "fields": [],
92
- "constants": [],
93
- "scripts": {},
94
- "attachmentScripts": {}
95
- },
96
- "flowBuilder": {
97
- "basequery": "1=2",
98
- "fields": [],
99
- "constants": [],
100
- "scripts": {}
101
- },
102
- "changeTemplate": {
103
- "basequery": "1=2",
104
- "fields": [],
105
- "constants": [],
106
- "scripts": {}
107
- },
108
- "incidentTemplate": {
109
- "basequery": "1=2",
110
- "fields": [],
111
- "constants": [],
112
- "scripts": {}
113
- },
114
- "problemTemplate": {
115
- "basequery": "1=2",
116
- "fields": [],
117
- "constants": [],
118
- "scripts": {}
119
- },
120
- "workOrderTemplate": {
121
- "basequery": "1=2",
122
- "fields": [],
123
- "constants": [],
124
- "scripts": {}
125
- },
126
- "taskTemplate": {
127
- "basequery": "1=2",
128
- "fields": [],
129
- "constants": [],
130
- "scripts": {}
131
- },
132
- "options": {
133
- "translateSelectionFields": true
134
- }
135
- }
136
- },
137
2
  {
138
3
  "name": "smileconnectGui",
139
4
  "config": {
@@ -2685,5 +2550,140 @@
2685
2550
  "scripts": {}
2686
2551
  }
2687
2552
  }
2553
+ },
2554
+ {
2555
+ "name": "horsti",
2556
+ "config": {
2557
+ "cmdbobject": {
2558
+ "fields": [],
2559
+ "constants": [],
2560
+ "scripts": {},
2561
+ "basequery": ""
2562
+ },
2563
+ "change": {
2564
+ "basequery": "1=2",
2565
+ "fields": [],
2566
+ "constants": [],
2567
+ "scripts": {}
2568
+ },
2569
+ "changeWorklog": {
2570
+ "basequery": "1=2",
2571
+ "fields": [],
2572
+ "constants": [],
2573
+ "scripts": {},
2574
+ "attachmentScripts": {}
2575
+ },
2576
+ "incident": {
2577
+ "basequery": "1=1",
2578
+ "fields": [
2579
+ "Description"
2580
+ ],
2581
+ "constants": [],
2582
+ "scripts": {}
2583
+ },
2584
+ "incidentWorklog": {
2585
+ "basequery": "1=2",
2586
+ "fields": [],
2587
+ "constants": [],
2588
+ "scripts": {},
2589
+ "attachmentScripts": {}
2590
+ },
2591
+ "person": {
2592
+ "basequery": "1=2",
2593
+ "fields": [],
2594
+ "constants": [],
2595
+ "scripts": {}
2596
+ },
2597
+ "problem": {
2598
+ "basequery": "1=2",
2599
+ "fields": [],
2600
+ "constants": [],
2601
+ "scripts": {}
2602
+ },
2603
+ "problemWorklog": {
2604
+ "basequery": "1=2",
2605
+ "fields": [],
2606
+ "constants": [],
2607
+ "scripts": {},
2608
+ "attachmentScripts": {}
2609
+ },
2610
+ "supportGroup": {
2611
+ "basequery": "1=2",
2612
+ "fields": [],
2613
+ "constants": [],
2614
+ "scripts": {}
2615
+ },
2616
+ "organisation": {
2617
+ "basequery": "1=2",
2618
+ "fields": [],
2619
+ "constants": [],
2620
+ "scripts": {}
2621
+ },
2622
+ "workOrder": {
2623
+ "basequery": "1=2",
2624
+ "fields": [],
2625
+ "constants": [],
2626
+ "scripts": {}
2627
+ },
2628
+ "workOrderWorklog": {
2629
+ "basequery": "1=2",
2630
+ "fields": [],
2631
+ "constants": [],
2632
+ "scripts": {},
2633
+ "attachmentScripts": {}
2634
+ },
2635
+ "task": {
2636
+ "basequery": "1=2",
2637
+ "fields": [],
2638
+ "constants": [],
2639
+ "scripts": {}
2640
+ },
2641
+ "taskWorklog": {
2642
+ "basequery": "1=2",
2643
+ "fields": [],
2644
+ "constants": [],
2645
+ "scripts": {},
2646
+ "attachmentScripts": {}
2647
+ },
2648
+ "flowBuilder": {
2649
+ "basequery": "1=2",
2650
+ "fields": [],
2651
+ "constants": [],
2652
+ "scripts": {}
2653
+ },
2654
+ "changeTemplate": {
2655
+ "basequery": "1=2",
2656
+ "fields": [],
2657
+ "constants": [],
2658
+ "scripts": {}
2659
+ },
2660
+ "incidentTemplate": {
2661
+ "basequery": "1=2",
2662
+ "fields": [],
2663
+ "constants": [],
2664
+ "scripts": {}
2665
+ },
2666
+ "problemTemplate": {
2667
+ "basequery": "1=2",
2668
+ "fields": [],
2669
+ "constants": [],
2670
+ "scripts": {}
2671
+ },
2672
+ "workOrderTemplate": {
2673
+ "basequery": "1=2",
2674
+ "fields": [],
2675
+ "constants": [],
2676
+ "scripts": {}
2677
+ },
2678
+ "taskTemplate": {
2679
+ "basequery": "1=2",
2680
+ "fields": [],
2681
+ "constants": [],
2682
+ "scripts": {}
2683
+ },
2684
+ "options": {
2685
+ "translateSelectionFields": true
2686
+ }
2687
+ }
2688
2688
  }
2689
2689
  ]
@@ -208,6 +208,13 @@ Sample:
208
208
 
209
209
  *MAX_HTTP_SOCKETS=15*
210
210
 
211
+ ### DOC_SERVERS
212
+
213
+ Array of Servers in JSON Format, that are used in the generated openapi specification.
214
+
215
+ Sample:
216
+
217
+ *DOC_SERVERS=[{"url":"https://smileconnect-dev.xyz.com", "description":"dev"}, {"url":"https://smileconnect.xyz.com", "description":"prod"}]*
211
218
 
212
219
  # Event Manager
213
220
 
package/docs/releases.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Release Notes
2
2
 
3
3
  ## API
4
+ ### 1.68.0 - 23.04.24
5
+ Add configurable server names to openapi documentation
6
+
4
7
  ### 1.67.0 - 09.04.24
5
- Add crypto to scripts
8
+ Add crypto & jsonweboken to scripts
6
9
 
7
10
  ### 1.65.2 - 01.03.24
8
11
  Add foundation data to dynamic api spec
@@ -204,6 +207,15 @@ e.g.
204
207
  */v1/incidents?impersonateUser=abc123
205
208
 
206
209
  ## Event Manager
210
+ ### 1.35.0 - 29.04.24
211
+ Add attachment support for outbound mappings
212
+
213
+ ### 1.34.0 - 26.04.24
214
+ Add outbound(custom payload) mapping to webhooks
215
+
216
+ ### 1.33.0 - 10.04.24
217
+ Add crypto & jsonweboken to scripts
218
+
207
219
  ### 1.31.0 - 18.07.23
208
220
  Introduce advanced logging for events. Each event log record will contain details about the associated event. (e.g. Event Id, Ticketnumber, etc.)
209
221
 
package/docs/scripts.md CHANGED
@@ -286,6 +286,45 @@ Allows custom headers in outbound events.
286
286
  customHeaders['X-API-GATEWAYUSER'] = 'gatewayuser1';
287
287
  ```
288
288
 
289
+ ## customPayload
290
+
291
+ Allows custom payload in outbound events.
292
+
293
+ Options:
294
+ * body
295
+ Allows a custom body to be sent.
296
+ * contentType
297
+ Content Type to sent. Defaults to application/json
298
+ * method
299
+ Method to be used. Defaults to POST. Possible Values are POST, PUT, GET, PATCH, DELETE
300
+ * agent
301
+ Can be used to apply dynamic proxy settings.
302
+
303
+ ```javascript
304
+ const retrunValue = await adapter.smileconnect.getTicket('incidents', 'INC000000004601');
305
+ customData.incident = retrunValue.data;
306
+
307
+ customPayload.body = `{
308
+ "vendorTicketId" :"{{customData.incident.id}}",
309
+ "lastUser": "{{customData.incident.lastModifiedBy}}",
310
+ "shortText": "{{customData.incident.summary}}"
311
+ }`;
312
+
313
+ //Optional Change of Content Type - defaults to application/json
314
+ customPayload.contentType = "text/plain";
315
+
316
+ //Optional Change of method. Defaults to POST
317
+ customPayload.method = 'PUT';
318
+ ```
319
+
320
+ The body field will be rendered with moustache template engine. The following variables can be accessed to dynamically replace values:
321
+ * requestData
322
+ * params
323
+ * clientId
324
+ * customData
325
+
326
+ [See also](https://manyos.it/blog/2024/4/26/new-feature-update-for-smileconnect-enhanced-customization-of-webhook-requests)
327
+
289
328
  # Returning values
290
329
 
291
330
  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.67.0",
3
+ "version": "1.69.0",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {
package/util/config.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const fs = require('fs');
2
2
  const fsPromises = require('fs').promises;
3
+ require('dotenv').config();
3
4
 
4
5
  const path = require('path');
5
6
  const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
@@ -158,6 +159,7 @@ function getConstants(objectType) {
158
159
  }
159
160
 
160
161
  function checkMapping() {
162
+ let updateRequired = false;
161
163
  log.info('check mapping');
162
164
  const mappingDefs = [
163
165
  'cmdbobject',
@@ -187,43 +189,60 @@ function checkMapping() {
187
189
  ];
188
190
  const mappings = getMappings() || {};
189
191
  const mappingKeys = Object.keys(mappings);
192
+ log.info(`check ${mappingKeys.length} mappings`);
190
193
  //delete too many
191
194
  mappingKeys.forEach(key=>{
192
195
  if (!mappingDefs.includes(key) && !key.startsWith('cmdbobject_') && !key.startsWith('custom_')) {
193
- log.info('delete from mapping', key);
196
+ log.warn('delete from mapping', key);
194
197
  delete mappings[key];
198
+ updateRequired = true;
195
199
  }
196
200
  });
197
201
  //add too less
198
202
  mappingDefs.forEach(mappingDef => {
199
203
  if (!mappingKeys.includes(mappingDef)) {
200
- log.info('add to mapping', mappingDef);
204
+ log.warn('add to mapping', mappingDef);
201
205
  mappings[mappingDef] = [];
206
+ updateRequired = true;
202
207
  }
203
208
  });
204
209
  //save
205
- setMappings(mappings);
206
- log.info('check mapping done');
210
+ if (updateRequired === true) {
211
+ log.warn('check mapping done. Mappings update required. New mappings', mappings);
212
+ setMappings(mappings);
213
+ log.warn('check mapping done. Mappings updated.');
214
+ } else {
215
+ log.info('check mapping done. No update required.');
216
+ }
207
217
  }
208
218
 
209
219
  async function checkCustomFormMapping() {
210
220
  log.info('check customForm mapping');
211
221
  const mappings = await getCustomFormMapping();
212
222
  const mappingAliases = Object.keys(mappings)
223
+ log.info(`${mappingAliases.length} customForm mappings found.`);
224
+ let configUpdateRequired = false;
213
225
  mappingAliases.forEach(mappingAlias => {
214
226
  const mappingDef = mappings[mappingAlias]
215
- log.debug('check', mappingDef)
227
+ log.info('check customForm Mapping', mappingDef)
216
228
  if (!mappingDef.formName || !mappingDef.mapping) {
217
- log.error('Remove wrong custom Form mapping', mappingDef)
218
- delete mappings[mappingAlias]
229
+ log.error('Remove wrong custom Form mapping', mappingDef);
230
+ delete mappings[mappingAlias];
231
+ configUpdateRequired = true;
219
232
  }
220
233
  })
221
234
  // save
222
- await setCustomFormMapping(mappings);
223
- log.info('check customForm mapping done');
235
+ if (configUpdateRequired === true) {
236
+ log.warn('Config update required for customFormMapping. New config', mappings);
237
+ await setCustomFormMapping(mappings);
238
+ log.info('check customForm mapping done. customFormMapping updated.');
239
+ } else {
240
+ log.info('check customForm mapping done. No update required.');
241
+ }
224
242
  }
225
243
 
226
244
  function checkClientConfig(client) {
245
+ let updateRequired = false;
227
246
  const clientKeys = [
228
247
  'cmdbobject',
229
248
  'change',
@@ -252,28 +271,34 @@ function checkClientConfig(client) {
252
271
  //delete too many
253
272
  clientConfigKeys.forEach(key=>{
254
273
  if (!clientKeys.includes(key) && !(key === 'options') && !(key.startsWith('custom_'))) {
255
- log.info('delete from clientconfig', key);
274
+ log.warn('delete from clientconfig', key);
256
275
  delete clientConfig[key];
276
+ updateRequired = true;
257
277
  } else if (clientKeys.includes(key) && !(key === 'options')) {
258
- if (!clientConfig[key].basequery) {
278
+ if (!(typeof clientConfig[key].basequery === 'string')) {
259
279
  clientConfig[key].basequery = '';
260
- log.info('add basequery', key);
280
+ log.warn('add basequery', key);
281
+ updateRequired = true;
261
282
  }
262
283
  if (!clientConfig[key].fields) {
263
284
  clientConfig[key].fields = [];
264
- log.info('add fields', key);
285
+ log.warn('add fields', key);
286
+ updateRequired = true;
265
287
  }
266
288
  if (!clientConfig[key].constants) {
267
289
  clientConfig[key].constants = [];
268
- log.info('add constants', key);
290
+ log.warn('add constants', key);
291
+ updateRequired = true;
269
292
  }
270
293
  if (!clientConfig[key].scripts) {
271
294
  clientConfig[key].scripts = {};
272
- log.info('add scripts', key);
295
+ log.warn('add scripts', key);
296
+ updateRequired = true;
273
297
  }
274
298
  if (key.endsWith('Worklog') && !clientConfig[key].attachmentScripts) {
275
299
  clientConfig[key].attachmentScripts = {};
276
- log.info('add attachmentScripts', key);
300
+ log.warn('add attachmentScripts', key);
301
+ updateRequired = true;
277
302
  }
278
303
  }
279
304
  });
@@ -281,22 +306,29 @@ function checkClientConfig(client) {
281
306
  clientKeys.forEach(clientKey => {
282
307
  if (!clientConfigKeys.includes(clientKey)) {
283
308
  log.info('add to mapping', clientKey);
309
+ updateRequired = true;
284
310
  clientConfig[clientKey] = clientConfigItemTemplate;
285
311
  }
286
312
  });
287
313
 
288
314
  if (!clientConfig.options) {
289
315
  clientConfig.options = {};
316
+ updateRequired = true;
290
317
  }
291
318
 
292
319
  if (clientConfig.options.translateSelectionFields === undefined) {
293
320
  clientConfig.options.translateSelectionFields = true;
321
+ updateRequired = true;
294
322
  }
295
323
 
296
- client.config = clientConfig;
297
- //save
298
- setClient(client.name, client);
299
- log.info('check config for client done', client.name);
324
+ if (updateRequired === true) {
325
+ log.warn(`check config for client ${client.name} done. Update required.`);
326
+ client.config = clientConfig;
327
+ //save
328
+ setClient(client.name, client);
329
+ log.warn(`check config for client ${client.name} done. Update done.`);
330
+ }
331
+ log.info(`check config for client ${client.name} done. No update required.`);
300
332
  }
301
333
 
302
334
  function checkClientConfigs() {
@@ -326,16 +358,19 @@ async function getDesignPackage(clientId) {
326
358
  },
327
359
  termsOfService: 'https://manyos.it'
328
360
  }
329
- const servers = [
330
- {
331
- url: "https://url123",
332
- description: "dev"
333
- },
334
- {
335
- url: "https://url12345",
336
- description: "prod"
361
+ let servers = []
362
+
363
+ if (process.env.DOC_SERVERS) {
364
+ try {
365
+ const doc_servers = JSON.parse(process.env.DOC_SERVERS);
366
+ if (doc_servers && Array.isArray(doc_servers)) {
367
+ servers = doc_servers;
368
+ }
369
+ } catch (error) {
370
+ log.error("Can't read server for openapi docs.", error);
337
371
  }
338
- ]
372
+ }
373
+
339
374
  const clientConfig = await getClientConfig(clientId)
340
375
  const schemas = {}
341
376
  let paths = {}
@@ -621,8 +656,7 @@ function getFields(form) {
621
656
  log.debug('get fields for', form);
622
657
  const key = 'fields/' + form;
623
658
  return configCache.get(key, async function () {
624
- const result = await arquery.getMetaData(form);
625
- return result;
659
+ return await arquery.getMetaData(form);
626
660
  });
627
661
  }
628
662
 
package/CHANGELOG.md DELETED
@@ -1,75 +0,0 @@
1
- # CHANGELOG
2
-
3
- This file lists all non-trivial changes to Beautiful Jekyll.
4
-
5
- I often make small changes to documentation, to the demo site, or to the general look-and-feel. These changes will not be listed here. Any other minor changes will also not be listed here.
6
-
7
- **2018-12-24** Add support for Staticman comments (#440) (thanks @VincentTam)
8
-
9
- **2018-10-19** Move Google Analytics to the head (#419) (thanks @jpvicari)
10
-
11
- **2018-06-08** Add support for Facebook comments (#350) (thanks @npes87184)
12
-
13
- **2018-02-22** Automatically generate sitemap (#323) (thanks @JosemyDuarte)
14
-
15
- **2018-01-18** Add clickable tags to each post and a tags index page, works for GitHub sites (#307) (thanks @OCram85)
16
-
17
- **2018-01-14** Redo Dockerfile (#302) (thanks @jennydaman)
18
-
19
- **2018-01-06** More color personalization options (#297 and #299) (thanks @jennydaman)
20
-
21
- **2018-01-05** Abstract the social networks logic (thanks @OCram85)
22
-
23
- **2018-01-03** Avatar image no longer causes a ghost click (thanks @alefi87)
24
-
25
- **2017-10-16** Add GitHub buttons to posts (#265) (thanks @yonicd)
26
-
27
- **2017-09-04** Ability to change colour/image of navbar/footer/body
28
-
29
- **2017-08-17** Add support for notification, error, and warning boxes in markdown (#227) (thanks @OCram85)
30
-
31
- **2017-08-12** Add social buttons for twitch, yelp, and steam (#234) (thanks @TheRealBenForce)
32
-
33
- **2017-03-30** Make the footer contact links friendly for screen readers (thanks @eugenius1)
34
-
35
- **2017-03-30** Started a CHANGELOG file (thanks @eugenius1)
36
-
37
- **2017-01-28** Add Subresource Integrity (SRI) support (#164) (thanks @tony-ho)
38
-
39
- **2017-01-09** Add Google Tag Manager Integration (#157) (thanks @csarigoz)
40
-
41
- **2017-01-06** Add options to configure HTML document title (#154) (thanks @tony-ho)
42
-
43
- **2016-12-25** Allow dynamic images on each blog post (#143) (thanks @bbritten)
44
-
45
- **2016-12-15** Support `title-img` config param to have image in the navbar instead of text
46
-
47
- **2016-12-08** Add support for phone numbers in footer; fix #136
48
-
49
- **2016-12-06** Update gemfile (#134) (thanks @stephentuso)
50
-
51
- **2016-10-09** Add Docker deployment (#114) (thanks @mangar)
52
-
53
- **2016-08-06** Add social share buttons for posts (thanks @rtlee9)
54
-
55
- **2016-07-29** Add CSS styling to code chunks
56
-
57
- **2016-07-27** Add clickable tags that lead to a tag page (doesn't work for GitHub hosted sites) (thanks @epwalsh)
58
-
59
- **2016-07-21** Add support for twitter cards (sharing on Twitter will be better); fixes #70
60
-
61
- **2016-03-18** Support full-width images in page headers; fixes #37
62
-
63
- **2016-03-18** Support menus in navigation bar
64
-
65
- **2016-02-07** Avatar is now conditional (thanks @hristoyankov)
66
-
67
- **2016-02-02** Migrate (forced to...) to jekyll 3
68
-
69
- **2016-01-22** Make sure not to include JQuery twice, fixes #29
70
-
71
- **2015-11-19** Support external links in navigation bar; fixes #3
72
-
73
- ... Many small changes because the site was in its infancy
74
-
75
- **2015-03-12** Beautiful Jekyll version 0.0000001 is released!