yaveon.ecm.d3dwebhooks 0.7.6 → 0.7.7
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,49 +1,12 @@
|
|
|
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");
|
|
5
4
|
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '1';
|
|
6
5
|
let runWebHook = async (req, res) => {
|
|
7
6
|
let reqBody = req.json();
|
|
8
7
|
let doc = reqBody.doc;
|
|
9
8
|
let resultMsg = '';
|
|
10
9
|
let resultState = 200;
|
|
11
|
-
let whClient = new Yaveon_ECM_d3d_Webhook_Client_1.D3dWebhookClient(req.get('x-dv-baseuri'), req.get('x-dv-repository-id'), 'Bearer ' + req.get('Authorization').replace('Bearer ', ''));
|
|
12
|
-
let config = await whClient.getConfiguration();
|
|
13
|
-
await whClient.blockConfiguration();
|
|
14
|
-
let alterationText = "";
|
|
15
|
-
try {
|
|
16
|
-
let configNeedsUpdate = false;
|
|
17
|
-
let numberRangeInformation = whClient.getNumberRangeInformation(doc, config);
|
|
18
|
-
for (const numberRangeInfo of numberRangeInformation) {
|
|
19
|
-
let property = doc.properties.find((p) => p.id === numberRangeInfo.numberRangePropertyGuid);
|
|
20
|
-
if (property.value === null || property.value === "") {
|
|
21
|
-
property.value = numberRangeInfo.nextValue.toString();
|
|
22
|
-
numberRangeInfo.nextValue += 1;
|
|
23
|
-
configNeedsUpdate = true;
|
|
24
|
-
alterationText += "incremented number range for " + numberRangeInfo.numberRangePropertyName + ": " + numberRangeInfo.nextValue + ". ";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (configNeedsUpdate) {
|
|
28
|
-
let updateResponse = await whClient.updateConfiguration(config, alterationText);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (ex) {
|
|
32
|
-
alterationText = '';
|
|
33
|
-
resultState = 400;
|
|
34
|
-
if (ex.response.data) {
|
|
35
|
-
resultMsg = ex.response.data;
|
|
36
|
-
}
|
|
37
|
-
else if (ex.Message) {
|
|
38
|
-
resultMsg = ex.Message;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
resultMsg = ex;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
finally {
|
|
45
|
-
await whClient.releaseConfiguration(alterationText.trim());
|
|
46
|
-
}
|
|
47
10
|
res.status(resultState).set(req.get()).send((resultState === 200 ? Buffer.from(JSON.stringify(reqBody)) : resultMsg));
|
|
48
11
|
};
|
|
49
12
|
exports.runWebHook = runWebHook;
|