yaveon.ecm.d3dwebhooks 0.7.13 → 0.7.14

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.
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runWebHook = void 0;
4
+ const Yaveon_ECM_d3d_Webhook_Client_1 = require("./Yaveon.ECM.d3d.Webhook.Client");
4
5
  process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '1';
5
6
  let runWebHook = async (req) => {
6
7
  let webHookResponse = {
@@ -8,6 +9,74 @@ let runWebHook = async (req) => {
8
9
  resultMsg: '',
9
10
  resultState: 200
10
11
  };
12
+ let doc = webHookResponse.reqBody.doc;
13
+ try {
14
+ webHookResponse.resultMsg += 'Creating D3dWebhookClient object... ';
15
+ let whClient = new Yaveon_ECM_d3d_Webhook_Client_1.D3dWebhookClient('https://eppsteinfoils.d-velop.cloud', '67d38001-3b5e-4c5f-8c93-b75121136218', 'Bearer d+XTNLM0/Inax57MUMHCR1NJKWBCaCqavl9Ow4inpslGJ24VW1bKE1I78+DZkzohueq9iHq3knk4qj4Plpj6lMT6GcxujeXut4fkQgYbIac=&_z_A0V5ayCSzD9O9s_-PoKuodwWRXqf8-p6UvSgNEYDuKiSHLeDwY08b1zHHpk9zB1RVXS4xGk73o9Fz1hGDbt2vtQ1tL5TC');
16
+ webHookResponse.resultMsg += 'done\n';
17
+ let alterationText = "";
18
+ try {
19
+ webHookResponse.resultMsg += 'Retrieving configuration... ';
20
+ let config = await whClient.getConfiguration();
21
+ webHookResponse.resultMsg += 'done\n';
22
+ webHookResponse.resultMsg += 'Blocking configuration... ';
23
+ await whClient.blockConfiguration();
24
+ webHookResponse.resultMsg += 'done\n';
25
+ let configNeedsUpdate = false;
26
+ webHookResponse.resultMsg += 'Retrieving number range section... ';
27
+ let numberRangeInformation = whClient.getNumberRangeInformation(doc, config);
28
+ webHookResponse.resultMsg += 'done\n';
29
+ for (const numberRangeInfo of numberRangeInformation) {
30
+ webHookResponse.resultMsg += 'Setting number range id ';
31
+ let property = doc.properties.find((p) => p.id === numberRangeInfo.numberRangePropertyGuid);
32
+ webHookResponse.resultMsg += 'for \'' + property.name + '\'... ';
33
+ if (property.value === null || property.value === "") {
34
+ property.value = numberRangeInfo.nextValue.toString();
35
+ numberRangeInfo.nextValue += 1;
36
+ configNeedsUpdate = true;
37
+ alterationText += 'incremented number range for ' + numberRangeInfo.numberRangePropertyName + ': ' + numberRangeInfo.nextValue + '.';
38
+ }
39
+ webHookResponse.resultMsg += 'done\n';
40
+ }
41
+ if (configNeedsUpdate) {
42
+ webHookResponse.resultMsg += 'Updating configuration... ';
43
+ let updateResponse = await whClient.updateConfiguration(config, alterationText);
44
+ webHookResponse.resultMsg += 'done\n';
45
+ }
46
+ }
47
+ catch (ex) {
48
+ alterationText = '';
49
+ webHookResponse.resultState = 400;
50
+ webHookResponse.resultMsg += 'error\n';
51
+ if (ex.response.data) {
52
+ webHookResponse.resultMsg += ex.response.data;
53
+ }
54
+ else if (ex.Message) {
55
+ webHookResponse.resultMsg += ex.Message;
56
+ }
57
+ else {
58
+ webHookResponse.resultMsg += ex;
59
+ }
60
+ }
61
+ finally {
62
+ webHookResponse.resultMsg += 'Releasing configuration... ';
63
+ await whClient.releaseConfiguration(alterationText.trim());
64
+ webHookResponse.resultMsg += 'done\n';
65
+ }
66
+ }
67
+ catch (ex) {
68
+ webHookResponse.resultState = 400;
69
+ webHookResponse.resultMsg += 'error\n';
70
+ if (ex.response.data) {
71
+ webHookResponse.resultMsg += ex.response.data;
72
+ }
73
+ else if (ex.Message) {
74
+ webHookResponse.resultMsg += ex.Message;
75
+ }
76
+ else {
77
+ webHookResponse.resultMsg += ex;
78
+ }
79
+ }
11
80
  return webHookResponse;
12
81
  };
13
82
  exports.runWebHook = runWebHook;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaveon.ecm.d3dwebhooks",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "description": "Utility files for triggered d3d webhooks",
5
5
  "main": "",
6
6
  "scripts": {