@contrail/flexplm 1.0.5 → 1.0.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.
- package/lib/flexplm-request.js +12 -23
- package/lib/util/config-defaults.js +57 -70
- package/lib/util/data-converter.js +178 -201
- package/lib/util/federation.js +93 -114
- package/lib/util/flexplm-connect.js +92 -113
- package/lib/util/logger-config.js +20 -31
- package/lib/util/thumbnail-util.js +79 -99
- package/lib/util/type-utils.js +8 -21
- package/package.json +3 -2
package/lib/util/federation.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.Federation = void 0;
|
|
13
4
|
const sdk_1 = require("@contrail/sdk");
|
|
@@ -21,67 +12,61 @@ class Federation {
|
|
|
21
12
|
constructor() {
|
|
22
13
|
this.CHUNK_SIZE = 50;
|
|
23
14
|
}
|
|
24
|
-
getFederatedMappedRefId(entityType, entityId) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
criteria
|
|
35
|
-
});
|
|
36
|
-
const federatedId = (fedRecords[0])
|
|
37
|
-
? fedRecords[0]['mappedReference']
|
|
38
|
-
: '';
|
|
39
|
-
return federatedId;
|
|
15
|
+
async getFederatedMappedRefId(entityType, entityId) {
|
|
16
|
+
const criteria = {
|
|
17
|
+
reference: entityType + ':' + entityId,
|
|
18
|
+
appIdentifier: FED_CONFIG.appIdentifier,
|
|
19
|
+
federationSchema: FED_CONFIG.federationSchema
|
|
20
|
+
};
|
|
21
|
+
console.log('getFederatedMappedRefId: ' + JSON.stringify(criteria));
|
|
22
|
+
const fedRecords = await new sdk_1.Entities().get({
|
|
23
|
+
entityName: 'federation',
|
|
24
|
+
criteria
|
|
40
25
|
});
|
|
26
|
+
const federatedId = (fedRecords[0])
|
|
27
|
+
? fedRecords[0]['mappedReference']
|
|
28
|
+
: '';
|
|
29
|
+
return federatedId;
|
|
41
30
|
}
|
|
42
|
-
createFederatedRecord(eventBody) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const payload = {
|
|
50
|
-
appIdentifier: FED_CONFIG.appIdentifier,
|
|
51
|
-
reference: itemResults[i].entityReference,
|
|
52
|
-
mappedReference: itemResults[i].federatedId,
|
|
53
|
-
federationSchema: FED_CONFIG.federationSchema
|
|
54
|
-
};
|
|
55
|
-
try {
|
|
56
|
-
const results = yield new sdk_1.Entities().create({ entityName: 'federation', object: payload });
|
|
57
|
-
return results;
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
console.log('createFederatedRecord-error: ', error);
|
|
61
|
-
throw new Error('Error creating federation record: ' + error.message);
|
|
62
|
-
}
|
|
31
|
+
async createFederatedRecord(eventBody) {
|
|
32
|
+
const itemResults = eventBody.payload;
|
|
33
|
+
for (let i = 0; i < itemResults.length; i++) {
|
|
34
|
+
if (!itemResults[i].federatedId) {
|
|
35
|
+
continue;
|
|
63
36
|
}
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
getFederationRecordFromMappedRefId(mappedRefId) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const criteria = {
|
|
37
|
+
const payload = {
|
|
69
38
|
appIdentifier: FED_CONFIG.appIdentifier,
|
|
70
|
-
|
|
39
|
+
reference: itemResults[i].entityReference,
|
|
40
|
+
mappedReference: itemResults[i].federatedId,
|
|
71
41
|
federationSchema: FED_CONFIG.federationSchema
|
|
72
42
|
};
|
|
73
43
|
try {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
criteria
|
|
77
|
-
});
|
|
78
|
-
return (fedRecords && fedRecords[0]) ? fedRecords[0] : undefined;
|
|
44
|
+
const results = await new sdk_1.Entities().create({ entityName: 'federation', object: payload });
|
|
45
|
+
return results;
|
|
79
46
|
}
|
|
80
|
-
catch (
|
|
81
|
-
console.log('
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.log('createFederatedRecord-error: ', error);
|
|
49
|
+
throw new Error('Error creating federation record: ' + error.message);
|
|
82
50
|
}
|
|
83
|
-
|
|
84
|
-
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async getFederationRecordFromMappedRefId(mappedRefId) {
|
|
54
|
+
const criteria = {
|
|
55
|
+
appIdentifier: FED_CONFIG.appIdentifier,
|
|
56
|
+
mappedReference: mappedRefId,
|
|
57
|
+
federationSchema: FED_CONFIG.federationSchema
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
const fedRecords = await new sdk_1.Entities().get({
|
|
61
|
+
entityName: 'federation',
|
|
62
|
+
criteria
|
|
63
|
+
});
|
|
64
|
+
return (fedRecords && fedRecords[0]) ? fedRecords[0] : undefined;
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.log('getFederationData-error: ' + e.message);
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
85
70
|
}
|
|
86
71
|
static getEntityId(fedRecord) {
|
|
87
72
|
const entityString = fedRecord['reference'];
|
|
@@ -90,73 +75,67 @@ class Federation {
|
|
|
90
75
|
const entityId = entitySplit[1];
|
|
91
76
|
return { entityType, entityId };
|
|
92
77
|
}
|
|
93
|
-
getEntityFromMappedRefId(mappedRefId) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
78
|
+
async getEntityFromMappedRefId(mappedRefId) {
|
|
79
|
+
const fedRecord = await this.getFederationRecordFromMappedRefId(mappedRefId);
|
|
80
|
+
console.log('fedRecord: ' + JSON.stringify(fedRecord));
|
|
81
|
+
if (!fedRecord) {
|
|
82
|
+
console.log('Federation Record doesnt exist. Cant get entity!');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const { entityType, entityId } = Federation.getEntityId(fedRecord);
|
|
86
|
+
const criteria = {
|
|
87
|
+
id: entityId
|
|
88
|
+
};
|
|
89
|
+
const entities = await new sdk_1.Entities().get({
|
|
90
|
+
entityName: entityType,
|
|
91
|
+
criteria
|
|
92
|
+
});
|
|
93
|
+
const entity = (entities && entities[0]) ? entities[0] : undefined;
|
|
94
|
+
return entity;
|
|
95
|
+
}
|
|
96
|
+
async getFederationRecordsFromIds(ids) {
|
|
97
|
+
const fedRecords = [];
|
|
98
|
+
for (let i = 0; i < ids.length; i++) {
|
|
102
99
|
const criteria = {
|
|
103
|
-
|
|
100
|
+
reference: ids[i],
|
|
101
|
+
appIdentifier: FED_CONFIG.appIdentifier,
|
|
102
|
+
federationSchema: FED_CONFIG.federationSchema
|
|
104
103
|
};
|
|
105
|
-
const
|
|
106
|
-
entityName:
|
|
104
|
+
const recs = await new sdk_1.Entities().get({
|
|
105
|
+
entityName: 'federation',
|
|
107
106
|
criteria
|
|
108
107
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
if (recs[0]) {
|
|
109
|
+
fedRecords.push(recs[0]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return fedRecords;
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
async getFederationRecordsFromIdsBulk(ids) {
|
|
115
|
+
const chunks = this.splitIntoChunksByLen(ids, this.CHUNK_SIZE);
|
|
116
|
+
const fedRecords = [];
|
|
117
|
+
const federatedPromises = [];
|
|
118
|
+
const entities = new sdk_1.Entities();
|
|
119
|
+
for (const chunk of chunks) {
|
|
120
|
+
const fedPromise = limit(async () => {
|
|
117
121
|
const criteria = {
|
|
118
|
-
|
|
122
|
+
references: chunk,
|
|
119
123
|
appIdentifier: FED_CONFIG.appIdentifier,
|
|
120
124
|
federationSchema: FED_CONFIG.federationSchema
|
|
121
125
|
};
|
|
122
|
-
const
|
|
126
|
+
const records = await entities.get({
|
|
123
127
|
entityName: 'federation',
|
|
124
128
|
criteria
|
|
125
129
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
getFederationRecordsFromIdsBulk(ids) {
|
|
134
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
const chunks = this.splitIntoChunksByLen(ids, this.CHUNK_SIZE);
|
|
136
|
-
const fedRecords = [];
|
|
137
|
-
const federatedPromises = [];
|
|
138
|
-
const entities = new sdk_1.Entities();
|
|
139
|
-
for (const chunk of chunks) {
|
|
140
|
-
const fedPromise = limit(() => __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
const criteria = {
|
|
142
|
-
references: chunk,
|
|
143
|
-
appIdentifier: FED_CONFIG.appIdentifier,
|
|
144
|
-
federationSchema: FED_CONFIG.federationSchema
|
|
145
|
-
};
|
|
146
|
-
const records = yield entities.get({
|
|
147
|
-
entityName: 'federation',
|
|
148
|
-
criteria
|
|
149
|
-
});
|
|
150
|
-
fedRecords.push(...records);
|
|
151
|
-
}));
|
|
152
|
-
federatedPromises.push(fedPromise);
|
|
153
|
-
}
|
|
154
|
-
yield Promise.all(federatedPromises);
|
|
155
|
-
return fedRecords;
|
|
156
|
-
});
|
|
130
|
+
fedRecords.push(...records);
|
|
131
|
+
});
|
|
132
|
+
federatedPromises.push(fedPromise);
|
|
133
|
+
}
|
|
134
|
+
await Promise.all(federatedPromises);
|
|
135
|
+
return fedRecords;
|
|
157
136
|
}
|
|
158
137
|
splitIntoChunksByLen(arr, len) {
|
|
159
|
-
const chunks = [], n = arr
|
|
138
|
+
const chunks = [], n = arr?.length;
|
|
160
139
|
let i = 0;
|
|
161
140
|
while (i < n) {
|
|
162
141
|
chunks.push(arr.slice(i, i += len));
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.FlexPLMConnect = void 0;
|
|
13
4
|
const app_framework_1 = require("@contrail/app-framework");
|
|
@@ -24,7 +15,6 @@ class FlexPLMConnect {
|
|
|
24
15
|
: this.config['payloadDefaultAsArray'];
|
|
25
16
|
}
|
|
26
17
|
getRequestOptions(method) {
|
|
27
|
-
var _a;
|
|
28
18
|
const csrfOptions = {
|
|
29
19
|
method,
|
|
30
20
|
headers: {
|
|
@@ -35,117 +25,106 @@ class FlexPLMConnect {
|
|
|
35
25
|
};
|
|
36
26
|
if (app_framework_1.Logger.isInfoOn()) {
|
|
37
27
|
const logOptions = JSON.parse(JSON.stringify(csrfOptions));
|
|
38
|
-
logOptions['headers']['Authorization'] =
|
|
28
|
+
logOptions['headers']['Authorization'] = logOptions?.headers?.Authorization.substring(0, 9);
|
|
39
29
|
console.info('csrfOptions: ' + JSON.stringify(logOptions));
|
|
40
30
|
}
|
|
41
31
|
return csrfOptions;
|
|
42
32
|
}
|
|
43
|
-
getCSRF() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
});
|
|
33
|
+
async getCSRF() {
|
|
34
|
+
const urlContext = this.config.urlContext;
|
|
35
|
+
const csrfEndpoint = this.config.csrfEndpoint;
|
|
36
|
+
const csrfURL = this.config.apiHost + urlContext + csrfEndpoint;
|
|
37
|
+
console.info('csrfURL: ' + csrfURL);
|
|
38
|
+
const csrfOptions = this.getRequestOptions('GET');
|
|
39
|
+
const response = await fetch(csrfURL, csrfOptions);
|
|
40
|
+
if (response.status >= 300) {
|
|
41
|
+
const message = 'Error connecting to FlexPLM:status: ' + response.status;
|
|
42
|
+
console.error(message);
|
|
43
|
+
console.error(await response.text());
|
|
44
|
+
throw new Error(message);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const body = await response.json();
|
|
48
|
+
const nonce_key = body.items[0].attributes.nonce_key;
|
|
49
|
+
const nonce = body.items[0].attributes.nonce;
|
|
50
|
+
console.info('nonce_key: ' + nonce_key);
|
|
51
|
+
console.info('nonce: ' + nonce);
|
|
52
|
+
return {
|
|
53
|
+
nonce_key,
|
|
54
|
+
nonce
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
const message = 'Error connecting to FlexPLM: ' + e.message;
|
|
59
|
+
console.error(message);
|
|
60
|
+
console.error(await response.text());
|
|
61
|
+
throw new Error(message);
|
|
62
|
+
}
|
|
75
63
|
}
|
|
76
|
-
sendRequest(csrf, payload) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const eventResponse = yield fetch(vibeEventsURL, xferOptions);
|
|
96
|
-
return eventResponse;
|
|
97
|
-
});
|
|
64
|
+
async sendRequest(csrf, payload) {
|
|
65
|
+
if (this.payloadSendAsArray && !Array.isArray(payload)) {
|
|
66
|
+
payload = [payload];
|
|
67
|
+
}
|
|
68
|
+
const xferOptions = this.getRequestOptions('POST');
|
|
69
|
+
xferOptions['body'] = JSON.stringify(payload);
|
|
70
|
+
xferOptions.headers[csrf.nonce_key] = csrf.nonce;
|
|
71
|
+
const urlContext = this.config.urlContext;
|
|
72
|
+
const vibeEventsURL = this.config.apiHost + urlContext + '/servlet/rest' + this.vibeEventEndpoint;
|
|
73
|
+
if (app_framework_1.Logger.isInfoOn()) {
|
|
74
|
+
console.info('Request:');
|
|
75
|
+
console.info('vibeEventsURL: ' + vibeEventsURL);
|
|
76
|
+
const logOptions = JSON.parse(JSON.stringify(xferOptions));
|
|
77
|
+
logOptions['headers']['Authorization'] = logOptions?.headers?.Authorization.substring(0, 9);
|
|
78
|
+
console.info('csrfOptions: ' + JSON.stringify(logOptions));
|
|
79
|
+
console.info('Making call to xfer data to FlexPLM');
|
|
80
|
+
}
|
|
81
|
+
const eventResponse = await fetch(vibeEventsURL, xferOptions);
|
|
82
|
+
return eventResponse;
|
|
98
83
|
}
|
|
99
|
-
processRequest(payload) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
});
|
|
84
|
+
async processRequest(payload) {
|
|
85
|
+
if (!payload) {
|
|
86
|
+
const message = 'No payload to send to FlexPLM';
|
|
87
|
+
console.error(message);
|
|
88
|
+
throw new Error(message);
|
|
89
|
+
}
|
|
90
|
+
if (app_framework_1.Logger.isInfoOn()) {
|
|
91
|
+
console.info('payload: ' + JSON.stringify(payload));
|
|
92
|
+
}
|
|
93
|
+
const csrf = await this.getCSRF();
|
|
94
|
+
if (!csrf) {
|
|
95
|
+
const message = 'Failed to get CSRF nonce';
|
|
96
|
+
console.error(message);
|
|
97
|
+
throw new Error(message);
|
|
98
|
+
}
|
|
99
|
+
const response = await this.sendRequest(csrf, payload);
|
|
100
|
+
const status = response.status;
|
|
101
|
+
if (status >= 300) {
|
|
102
|
+
const message = 'Error sending data to FlexPLM:status: ' + response.status;
|
|
103
|
+
console.error(message);
|
|
104
|
+
console.error(await response.text());
|
|
105
|
+
throw new Error(message);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const data = await response.json();
|
|
109
|
+
const res = {
|
|
110
|
+
status,
|
|
111
|
+
data
|
|
112
|
+
};
|
|
113
|
+
console.log('eventResponse.status: ' + status);
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
const message = 'Error getting json data from FlexPLM: ' + e.message;
|
|
118
|
+
console.error(message);
|
|
119
|
+
console.error(await response.text());
|
|
120
|
+
throw new Error(message);
|
|
121
|
+
}
|
|
139
122
|
}
|
|
140
|
-
sendToFlexPLM(payload) {
|
|
141
|
-
return
|
|
142
|
-
return yield this.processRequest(payload);
|
|
143
|
-
});
|
|
123
|
+
async sendToFlexPLM(payload) {
|
|
124
|
+
return await this.processRequest(payload);
|
|
144
125
|
}
|
|
145
|
-
sendMultipleToFlexPLM(payload) {
|
|
146
|
-
return
|
|
147
|
-
return yield this.processRequest(payload);
|
|
148
|
-
});
|
|
126
|
+
async sendMultipleToFlexPLM(payload) {
|
|
127
|
+
return await this.processRequest(payload);
|
|
149
128
|
}
|
|
150
129
|
}
|
|
151
130
|
exports.FlexPLMConnect = FlexPLMConnect;
|
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.setLoggerConfig = void 0;
|
|
13
4
|
const app_framework_1 = require("@contrail/app-framework");
|
|
14
|
-
function setLoggerConfig(appConfig) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
app_framework_1.Logger.setConfig({ logLevel: logLevel });
|
|
35
|
-
});
|
|
5
|
+
async function setLoggerConfig(appConfig) {
|
|
6
|
+
let logLevel = app_framework_1.LogLevel.INFO;
|
|
7
|
+
if (!appConfig.logLevel) {
|
|
8
|
+
}
|
|
9
|
+
else if (appConfig.logLevel === 'error') {
|
|
10
|
+
logLevel = app_framework_1.LogLevel.ERROR;
|
|
11
|
+
}
|
|
12
|
+
else if (appConfig.logLevel === 'warn') {
|
|
13
|
+
logLevel = app_framework_1.LogLevel.WARN;
|
|
14
|
+
}
|
|
15
|
+
else if (appConfig.logLevel === 'info') {
|
|
16
|
+
logLevel = app_framework_1.LogLevel.INFO;
|
|
17
|
+
}
|
|
18
|
+
else if (appConfig.logLevel === 'debug') {
|
|
19
|
+
logLevel = app_framework_1.LogLevel.DEBUG;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.log('could not parse log level:', appConfig);
|
|
23
|
+
}
|
|
24
|
+
app_framework_1.Logger.setConfig({ logLevel: logLevel });
|
|
36
25
|
}
|
|
37
26
|
exports.setLoggerConfig = setLoggerConfig;
|