@contrail/flexplm 1.0.6 → 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 +1 -1
package/lib/flexplm-request.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.FlexPLMRequest = void 0;
|
|
13
4
|
const axios_1 = require("axios");
|
|
@@ -23,20 +14,18 @@ const BASE_CONFIG = {
|
|
|
23
14
|
},
|
|
24
15
|
};
|
|
25
16
|
class FlexPLMRequest {
|
|
26
|
-
static request(path, data) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
});
|
|
17
|
+
static async request(path, data) {
|
|
18
|
+
const config = Object.assign({}, BASE_CONFIG);
|
|
19
|
+
config.url = BASE_URL + path;
|
|
20
|
+
config.data = data;
|
|
21
|
+
try {
|
|
22
|
+
const resp = await (0, axios_1.default)(config);
|
|
23
|
+
return Promise.resolve(resp.data);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error(`${FlexPLMRequest} error: ${error.message}`);
|
|
27
|
+
return Promise.resolve(null);
|
|
28
|
+
}
|
|
40
29
|
}
|
|
41
30
|
}
|
|
42
31
|
exports.FlexPLMRequest = FlexPLMRequest;
|
|
@@ -1,83 +1,70 @@
|
|
|
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.ConfigDefaults = void 0;
|
|
13
4
|
const sdk_1 = require("@contrail/sdk");
|
|
14
5
|
const util_1 = require("@contrail/util");
|
|
15
6
|
class ConfigDefaults {
|
|
16
|
-
static setConfigDefaults(config) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return outputConfig;
|
|
53
|
-
});
|
|
7
|
+
static async setConfigDefaults(config) {
|
|
8
|
+
if (!config.apiHost || !config.userName || !config.password) {
|
|
9
|
+
throw new Error(ConfigDefaults.NEED_CONFIG_VALUES);
|
|
10
|
+
}
|
|
11
|
+
if (config?.itemPreDevelopmentLifecycleStages && !(config?.itemPreDevelopmentLifecycleStages instanceof Array)) {
|
|
12
|
+
config.itemPreDevelopmentLifecycleStages = config.itemPreDevelopmentLifecycleStages.split(',');
|
|
13
|
+
}
|
|
14
|
+
const defaultConfig = {
|
|
15
|
+
urlContext: '/Windchill',
|
|
16
|
+
sendMode: {
|
|
17
|
+
ASYNC_PUBLISH_SEASON: 'vibeiqfile'
|
|
18
|
+
},
|
|
19
|
+
itemPreDevelopmentLifecycleStages: ['concept'],
|
|
20
|
+
identifierAtts: {
|
|
21
|
+
LCSProduct: ['itemNumber'],
|
|
22
|
+
LCSSeason: ['flexPLMSeasonName'],
|
|
23
|
+
LCSSKU: ['itemNumber']
|
|
24
|
+
},
|
|
25
|
+
csrfEndpoint: '/servlet/rest/security/csrf',
|
|
26
|
+
vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
|
|
27
|
+
payloadDefaultAsArray: true
|
|
28
|
+
};
|
|
29
|
+
const configArr = [defaultConfig];
|
|
30
|
+
if (config.configFile) {
|
|
31
|
+
const fileConfig = await ConfigDefaults.getConfigFile(config.configFile);
|
|
32
|
+
configArr.push(fileConfig);
|
|
33
|
+
}
|
|
34
|
+
configArr.push(config);
|
|
35
|
+
const outputConfig = util_1.ObjectUtil.mergeDeep({}, ...configArr);
|
|
36
|
+
const uName = outputConfig.userName;
|
|
37
|
+
const pass = outputConfig.password;
|
|
38
|
+
outputConfig.userName = () => uName;
|
|
39
|
+
outputConfig.password = () => pass;
|
|
40
|
+
outputConfig['OOBvibeEventEndpoint'] = '/rfa/vibeiq/vibeEvents';
|
|
41
|
+
console.log('outputConfig: ' + JSON.stringify(outputConfig));
|
|
42
|
+
return outputConfig;
|
|
54
43
|
}
|
|
55
|
-
static getConfigFile(fileId) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return {};
|
|
66
|
-
}
|
|
67
|
-
const downloadUrl = file['downloadUrl'];
|
|
68
|
-
if (!downloadUrl) {
|
|
69
|
-
console.log('file didnt have downloadUrl. fileId: ' + fileId);
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
72
|
-
const response = yield fetch(downloadUrl);
|
|
73
|
-
const config = yield response.json();
|
|
74
|
-
return config ? config : {};
|
|
44
|
+
static async getConfigFile(fileId) {
|
|
45
|
+
try {
|
|
46
|
+
const options = {
|
|
47
|
+
entityName: 'file',
|
|
48
|
+
id: fileId,
|
|
49
|
+
};
|
|
50
|
+
const file = await new sdk_1.Entities().get(options);
|
|
51
|
+
if (!file) {
|
|
52
|
+
console.log('failed to find file with id: ' + fileId);
|
|
53
|
+
return {};
|
|
75
54
|
}
|
|
76
|
-
|
|
77
|
-
|
|
55
|
+
const downloadUrl = file['downloadUrl'];
|
|
56
|
+
if (!downloadUrl) {
|
|
57
|
+
console.log('file didnt have downloadUrl. fileId: ' + fileId);
|
|
78
58
|
return {};
|
|
79
59
|
}
|
|
80
|
-
|
|
60
|
+
const response = await fetch(downloadUrl);
|
|
61
|
+
const config = await response.json();
|
|
62
|
+
return config ? config : {};
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
console.log('Error getting config file: ' + fileId + '- ' + e.message);
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
81
68
|
}
|
|
82
69
|
}
|
|
83
70
|
exports.ConfigDefaults = ConfigDefaults;
|
|
@@ -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.DataConverter = void 0;
|
|
13
4
|
const sdk_1 = require("@contrail/sdk");
|
|
@@ -26,83 +17,77 @@ class DataConverter {
|
|
|
26
17
|
this.useDisplayForEnumerationMatching = this.config['dataConverter']
|
|
27
18
|
&& this.config['dataConverter']['useDisplayForEnumerationMatching'];
|
|
28
19
|
}
|
|
29
|
-
getFlexPLMObjectDataFromEvent(event, dataToSkip) {
|
|
30
|
-
return
|
|
31
|
-
return this.getFlexPLMObjectData(event.newData, dataToSkip, true);
|
|
32
|
-
});
|
|
20
|
+
async getFlexPLMObjectDataFromEvent(event, dataToSkip) {
|
|
21
|
+
return this.getFlexPLMObjectData(event.newData, dataToSkip, true);
|
|
33
22
|
}
|
|
34
|
-
getFlexPLMObjectData(newData, dataToSkip, expandObjRef) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
for (const prop of typeProps) {
|
|
49
|
-
const slug = prop['slug'];
|
|
50
|
-
if (dataToSkip.includes(slug)) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
data[slug] = yield this.getFlexPLMValue(prop, newData, expandObjRef);
|
|
54
|
-
}
|
|
55
|
-
if (app_framework_1.Logger.isDebugOn()) {
|
|
56
|
-
console.debug('getFlexPLMObjectData-data: ' + JSON.stringify(data));
|
|
57
|
-
}
|
|
58
|
-
return data;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
getFlexPLMValue(prop, newData, expandObjRef) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const propertyType = prop['propertyType'];
|
|
23
|
+
async getFlexPLMObjectData(newData, dataToSkip, expandObjRef) {
|
|
24
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
25
|
+
console.debug('newData: ' + JSON.stringify(newData));
|
|
26
|
+
}
|
|
27
|
+
dataToSkip = dataToSkip.concat(['updatedOn', 'updatedById', 'createdOn', 'createdById', 'modifiedAt', 'orgId', 'createdAt', 'id', 'typeId', 'workspaceId']);
|
|
28
|
+
const data = {};
|
|
29
|
+
const typeId = newData?.typeId;
|
|
30
|
+
if (!typeId) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
data['typePath'] = newData['typePath'];
|
|
34
|
+
const type = await this.typeUtils.getTypeById(typeId);
|
|
35
|
+
const typeProps = this.typeUtils.filterTypeProperties(type, newData);
|
|
36
|
+
for (const prop of typeProps) {
|
|
64
37
|
const slug = prop['slug'];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (['string', 'text'].includes(propertyType)) {
|
|
68
|
-
value = nd || '';
|
|
69
|
-
}
|
|
70
|
-
else if (['number', 'currency', 'percent', 'sequence'].includes(propertyType)) {
|
|
71
|
-
value = nd || 0;
|
|
72
|
-
}
|
|
73
|
-
else if ('date' === propertyType) {
|
|
74
|
-
if (nd) {
|
|
75
|
-
value = nd;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
value = null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else if ('boolean' === propertyType) {
|
|
82
|
-
value = (nd) ? true : false;
|
|
83
|
-
}
|
|
84
|
-
else if ('choice' === propertyType) {
|
|
85
|
-
value = this.getEnumerationValue(prop, nd);
|
|
38
|
+
if (dataToSkip.includes(slug)) {
|
|
39
|
+
continue;
|
|
86
40
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
41
|
+
data[slug] = await this.getFlexPLMValue(prop, newData, expandObjRef);
|
|
42
|
+
}
|
|
43
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
44
|
+
console.debug('getFlexPLMObjectData-data: ' + JSON.stringify(data));
|
|
45
|
+
}
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
async getFlexPLMValue(prop, newData, expandObjRef) {
|
|
49
|
+
const propertyType = prop['propertyType'];
|
|
50
|
+
const slug = prop['slug'];
|
|
51
|
+
const nd = newData[slug];
|
|
52
|
+
let value;
|
|
53
|
+
if (['string', 'text'].includes(propertyType)) {
|
|
54
|
+
value = nd || '';
|
|
55
|
+
}
|
|
56
|
+
else if (['number', 'currency', 'percent', 'sequence'].includes(propertyType)) {
|
|
57
|
+
value = nd || 0;
|
|
58
|
+
}
|
|
59
|
+
else if ('date' === propertyType) {
|
|
60
|
+
if (nd) {
|
|
99
61
|
value = nd;
|
|
100
62
|
}
|
|
101
|
-
else
|
|
102
|
-
value =
|
|
63
|
+
else {
|
|
64
|
+
value = null;
|
|
103
65
|
}
|
|
104
|
-
|
|
105
|
-
|
|
66
|
+
}
|
|
67
|
+
else if ('boolean' === propertyType) {
|
|
68
|
+
value = (nd) ? true : false;
|
|
69
|
+
}
|
|
70
|
+
else if ('choice' === propertyType) {
|
|
71
|
+
value = this.getEnumerationValue(prop, nd);
|
|
72
|
+
}
|
|
73
|
+
else if ('multi_select' === propertyType) {
|
|
74
|
+
value = this.getEnumerationValue(prop, nd);
|
|
75
|
+
}
|
|
76
|
+
else if ('object_reference' === propertyType) {
|
|
77
|
+
value = await this.getObjectReferenceValue(prop, newData, expandObjRef);
|
|
78
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
79
|
+
console.debug('object_reference: ' + JSON.stringify(value));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if ('image' === propertyType) {
|
|
83
|
+
}
|
|
84
|
+
else if ('formula' === propertyType) {
|
|
85
|
+
value = nd;
|
|
86
|
+
}
|
|
87
|
+
else if ('json' === propertyType) {
|
|
88
|
+
value = nd;
|
|
89
|
+
}
|
|
90
|
+
return value;
|
|
106
91
|
}
|
|
107
92
|
getEnumerationValue(prop, nd) {
|
|
108
93
|
const propertyType = prop['propertyType'];
|
|
@@ -142,55 +127,53 @@ class DataConverter {
|
|
|
142
127
|
}
|
|
143
128
|
return value;
|
|
144
129
|
}
|
|
145
|
-
getObjectReferenceValue(prop, newData, expandObjRef = false) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (
|
|
153
|
-
if (entityId) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return this.objRefCache[entityId];
|
|
157
|
-
}
|
|
158
|
-
const criteria = {
|
|
159
|
-
id: entityId
|
|
160
|
-
};
|
|
161
|
-
const entities = yield new sdk_1.Entities().get({
|
|
162
|
-
entityName: entityType,
|
|
163
|
-
criteria
|
|
164
|
-
});
|
|
165
|
-
value = (entities && entities[0]) ? entities[0] : undefined;
|
|
130
|
+
async getObjectReferenceValue(prop, newData, expandObjRef = false) {
|
|
131
|
+
const slug = prop['slug'];
|
|
132
|
+
console.debug('getObjectReferenceValue-prop: ' + slug);
|
|
133
|
+
let value = newData[slug];
|
|
134
|
+
const entityType = prop['referencedTypeRootSlug'];
|
|
135
|
+
const entityId = newData[slug + 'Id'];
|
|
136
|
+
if (!value && expandObjRef) {
|
|
137
|
+
if (entityId) {
|
|
138
|
+
if (this.objRefCache[entityId]) {
|
|
139
|
+
console.log('cache hit: ' + entityId);
|
|
140
|
+
return this.objRefCache[entityId];
|
|
166
141
|
}
|
|
142
|
+
const criteria = {
|
|
143
|
+
id: entityId
|
|
144
|
+
};
|
|
145
|
+
const entities = await new sdk_1.Entities().get({
|
|
146
|
+
entityName: entityType,
|
|
147
|
+
criteria
|
|
148
|
+
});
|
|
149
|
+
value = (entities && entities[0]) ? entities[0] : undefined;
|
|
167
150
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
151
|
+
}
|
|
152
|
+
if (value) {
|
|
153
|
+
const unprocessedValue = value;
|
|
154
|
+
const objectClass = this.typeUtils.getEventObjectClass(entityType, newData);
|
|
155
|
+
value = await this.getFlexPLMObjectData(value, [], false);
|
|
156
|
+
value['entityReference'] = entityType + ':' + entityId;
|
|
157
|
+
value['objectClass'] = objectClass;
|
|
158
|
+
value['typePath'] = unprocessedValue['typePath'];
|
|
159
|
+
if (this.transformMapFile) {
|
|
160
|
+
const wholeMap = await this.mapFileUtil.getMapFile(this.transformMapFile);
|
|
161
|
+
const objClass = this.getMappingClass(unprocessedValue, wholeMap);
|
|
162
|
+
const mapping = await this.mapFileUtil.getMappingSection(this.transformMapFile, objClass, 'vibe2flex');
|
|
163
|
+
if (mapping) {
|
|
164
|
+
const tasks = transform_data_1.MapFileUtil.getTransformTasks(mapping);
|
|
165
|
+
if (tasks.length > 0) {
|
|
166
|
+
const convertedArray = transform_data_1.TransformProcessor.transformData([value], tasks);
|
|
167
|
+
value = convertedArray[0];
|
|
185
168
|
}
|
|
186
169
|
}
|
|
187
170
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
value = {};
|
|
174
|
+
}
|
|
175
|
+
this.objRefCache[entityId] = value;
|
|
176
|
+
return value;
|
|
194
177
|
}
|
|
195
178
|
getMappingClass(entity, mapping) {
|
|
196
179
|
const entityTypePath = entity['typePath'];
|
|
@@ -205,90 +188,84 @@ class DataConverter {
|
|
|
205
188
|
}
|
|
206
189
|
return objClass;
|
|
207
190
|
}
|
|
208
|
-
setEntityValues(entity, data, keysToSkip = []) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return entity;
|
|
221
|
-
});
|
|
191
|
+
async setEntityValues(entity, data, keysToSkip = []) {
|
|
192
|
+
const type = await this.typeUtils.getTypeById(entity.typeId);
|
|
193
|
+
keysToSkip = keysToSkip.concat(['updatedOn', 'updatedById', 'createdOn', 'createdById', 'modifiedAt', 'orgId', 'createdAt', 'id', 'typeId', 'workspaceId']);
|
|
194
|
+
let typeProps = this.typeUtils.filterTypeProperties(type, entity);
|
|
195
|
+
typeProps = typeProps.filter(prop => !keysToSkip.includes(prop['slug']));
|
|
196
|
+
const dataKeys = Object.getOwnPropertyNames(data);
|
|
197
|
+
typeProps = typeProps.filter(prop => dataKeys.includes(prop['slug']));
|
|
198
|
+
for (const prop of typeProps) {
|
|
199
|
+
const slug = prop['slug'];
|
|
200
|
+
entity[slug] = await this.getEntityValue(prop, data);
|
|
201
|
+
}
|
|
202
|
+
return entity;
|
|
222
203
|
}
|
|
223
|
-
getEntityValues(objectClass, data, keysToSkip = []) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
entityValues['roles'] = ['family'];
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
entityValues['roles'] = ['color', 'option'];
|
|
235
|
-
}
|
|
204
|
+
async getEntityValues(objectClass, data, keysToSkip = []) {
|
|
205
|
+
const entityValues = {};
|
|
206
|
+
const tco = this.typeUtils.getEntityTypeClientOptions(objectClass, data);
|
|
207
|
+
const type = await this.typeUtils.getByRootAndPath(tco);
|
|
208
|
+
const typePath = type['typePath'];
|
|
209
|
+
if (typePath && (typePath.startsWith('item') || typePath.startsWith('project-item'))) {
|
|
210
|
+
if (['LCSProduct', 'LCSProductSeasonLink'].includes(objectClass)) {
|
|
211
|
+
entityValues['roles'] = ['family'];
|
|
236
212
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
for (const prop of typeProps) {
|
|
240
|
-
const slug = prop['slug'];
|
|
241
|
-
const value = yield this.getEntityValue(prop, data);
|
|
242
|
-
if (value) {
|
|
243
|
-
entityValues[slug] = value;
|
|
244
|
-
}
|
|
213
|
+
else {
|
|
214
|
+
entityValues['roles'] = ['color', 'option'];
|
|
245
215
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
const propertyType = prop['propertyType'];
|
|
216
|
+
}
|
|
217
|
+
let typeProps = this.typeUtils.filterTypeProperties(type, entityValues);
|
|
218
|
+
typeProps = typeProps.filter(prop => !keysToSkip.includes(prop['slug']));
|
|
219
|
+
for (const prop of typeProps) {
|
|
252
220
|
const slug = prop['slug'];
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
value = nd;
|
|
257
|
-
}
|
|
258
|
-
else if (['number', 'currency', 'percent', 'sequence'].includes(propertyType)) {
|
|
259
|
-
value = (null === nd) ? 0 : nd;
|
|
260
|
-
}
|
|
261
|
-
else if ('date' === propertyType) {
|
|
262
|
-
if (nd) {
|
|
263
|
-
const d = new Date(nd);
|
|
264
|
-
value = d.toISOString();
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
value = null;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
else if ('boolean' === propertyType) {
|
|
271
|
-
value = (nd) ? true : false;
|
|
272
|
-
}
|
|
273
|
-
else if ('choice' === propertyType) {
|
|
274
|
-
value = this.setEnumerationKeys(prop, nd, this.useDisplayForEnumerationMatching);
|
|
275
|
-
}
|
|
276
|
-
else if ('multi_select' === propertyType) {
|
|
277
|
-
value = this.setEnumerationKeys(prop, nd, this.useDisplayForEnumerationMatching);
|
|
278
|
-
}
|
|
279
|
-
else if ('object_reference' === propertyType) {
|
|
280
|
-
}
|
|
281
|
-
else if ('image' === propertyType) {
|
|
282
|
-
console.log('TODO');
|
|
221
|
+
const value = await this.getEntityValue(prop, data);
|
|
222
|
+
if (value) {
|
|
223
|
+
entityValues[slug] = value;
|
|
283
224
|
}
|
|
284
|
-
|
|
285
|
-
|
|
225
|
+
}
|
|
226
|
+
return entityValues;
|
|
227
|
+
}
|
|
228
|
+
async getEntityValue(prop, data) {
|
|
229
|
+
const propertyType = prop['propertyType'];
|
|
230
|
+
const slug = prop['slug'];
|
|
231
|
+
const nd = data[slug];
|
|
232
|
+
let value;
|
|
233
|
+
if (['string', 'text'].includes(propertyType)) {
|
|
234
|
+
value = nd;
|
|
235
|
+
}
|
|
236
|
+
else if (['number', 'currency', 'percent', 'sequence'].includes(propertyType)) {
|
|
237
|
+
value = (null === nd) ? 0 : nd;
|
|
238
|
+
}
|
|
239
|
+
else if ('date' === propertyType) {
|
|
240
|
+
if (nd) {
|
|
241
|
+
const d = new Date(nd);
|
|
242
|
+
value = d.toISOString();
|
|
286
243
|
}
|
|
287
|
-
else
|
|
288
|
-
|
|
244
|
+
else {
|
|
245
|
+
value = null;
|
|
289
246
|
}
|
|
290
|
-
|
|
291
|
-
|
|
247
|
+
}
|
|
248
|
+
else if ('boolean' === propertyType) {
|
|
249
|
+
value = (nd) ? true : false;
|
|
250
|
+
}
|
|
251
|
+
else if ('choice' === propertyType) {
|
|
252
|
+
value = this.setEnumerationKeys(prop, nd, this.useDisplayForEnumerationMatching);
|
|
253
|
+
}
|
|
254
|
+
else if ('multi_select' === propertyType) {
|
|
255
|
+
value = this.setEnumerationKeys(prop, nd, this.useDisplayForEnumerationMatching);
|
|
256
|
+
}
|
|
257
|
+
else if ('object_reference' === propertyType) {
|
|
258
|
+
}
|
|
259
|
+
else if ('image' === propertyType) {
|
|
260
|
+
console.log('TODO');
|
|
261
|
+
}
|
|
262
|
+
else if ('formula' === propertyType) {
|
|
263
|
+
console.log('TODO');
|
|
264
|
+
}
|
|
265
|
+
else if ('json' === propertyType) {
|
|
266
|
+
console.log('TODO');
|
|
267
|
+
}
|
|
268
|
+
return value;
|
|
292
269
|
}
|
|
293
270
|
setEnumerationKeys(prop, nd, matchByDisplay) {
|
|
294
271
|
const propertyType = prop['propertyType'];
|