@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.
@@ -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
- return __awaiter(this, void 0, void 0, function* () {
28
- const config = Object.assign({}, BASE_CONFIG);
29
- config.url = BASE_URL + path;
30
- config.data = data;
31
- try {
32
- const resp = yield (0, axios_1.default)(config);
33
- return Promise.resolve(resp.data);
34
- }
35
- catch (error) {
36
- console.error(`${FlexPLMRequest} error: ${error.message}`);
37
- return Promise.resolve(null);
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
- return __awaiter(this, void 0, void 0, function* () {
18
- if (!config.apiHost || !config.userName || !config.password) {
19
- throw new Error(ConfigDefaults.NEED_CONFIG_VALUES);
20
- }
21
- if ((config === null || config === void 0 ? void 0 : config.itemPreDevelopmentLifecycleStages) && !((config === null || config === void 0 ? void 0 : config.itemPreDevelopmentLifecycleStages) instanceof Array)) {
22
- config.itemPreDevelopmentLifecycleStages = config.itemPreDevelopmentLifecycleStages.split(',');
23
- }
24
- const defaultConfig = {
25
- urlContext: '/Windchill',
26
- sendMode: {
27
- ASYNC_PUBLISH_SEASON: 'vibeiqfile'
28
- },
29
- itemPreDevelopmentLifecycleStages: ['concept'],
30
- identifierAtts: {
31
- LCSProduct: ['itemNumber'],
32
- LCSSeason: ['flexPLMSeasonName'],
33
- LCSSKU: ['itemNumber']
34
- },
35
- csrfEndpoint: '/servlet/rest/security/csrf',
36
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
37
- payloadDefaultAsArray: true
38
- };
39
- const configArr = [defaultConfig];
40
- if (config.configFile) {
41
- const fileConfig = yield ConfigDefaults.getConfigFile(config.configFile);
42
- configArr.push(fileConfig);
43
- }
44
- configArr.push(config);
45
- const outputConfig = util_1.ObjectUtil.mergeDeep({}, ...configArr);
46
- const uName = outputConfig.userName;
47
- const pass = outputConfig.password;
48
- outputConfig.userName = () => uName;
49
- outputConfig.password = () => pass;
50
- outputConfig['OOBvibeEventEndpoint'] = '/rfa/vibeiq/vibeEvents';
51
- console.log('outputConfig: ' + JSON.stringify(outputConfig));
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
- return __awaiter(this, void 0, void 0, function* () {
57
- try {
58
- const options = {
59
- entityName: 'file',
60
- id: fileId,
61
- };
62
- const file = yield new sdk_1.Entities().get(options);
63
- if (!file) {
64
- console.log('failed to find file with id: ' + fileId);
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
- catch (e) {
77
- console.log('Error getting config file: ' + fileId + '- ' + e.message);
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 __awaiter(this, void 0, void 0, function* () {
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
- return __awaiter(this, void 0, void 0, function* () {
36
- if (app_framework_1.Logger.isDebugOn()) {
37
- console.debug('newData: ' + JSON.stringify(newData));
38
- }
39
- dataToSkip = dataToSkip.concat(['updatedOn', 'updatedById', 'createdOn', 'createdById', 'modifiedAt', 'orgId', 'createdAt', 'id', 'typeId', 'workspaceId']);
40
- const data = {};
41
- const typeId = newData === null || newData === void 0 ? void 0 : newData.typeId;
42
- if (!typeId) {
43
- return;
44
- }
45
- data['typePath'] = newData['typePath'];
46
- const type = yield this.typeUtils.getTypeById(typeId);
47
- const typeProps = this.typeUtils.filterTypeProperties(type, newData);
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
- const nd = newData[slug];
66
- let value;
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
- else if ('multi_select' === propertyType) {
88
- value = this.getEnumerationValue(prop, nd);
89
- }
90
- else if ('object_reference' === propertyType) {
91
- value = yield this.getObjectReferenceValue(prop, newData, expandObjRef);
92
- if (app_framework_1.Logger.isDebugOn()) {
93
- console.debug('object_reference: ' + JSON.stringify(value));
94
- }
95
- }
96
- else if ('image' === propertyType) {
97
- }
98
- else if ('formula' === propertyType) {
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 if ('json' === propertyType) {
102
- value = nd;
63
+ else {
64
+ value = null;
103
65
  }
104
- return value;
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
- return __awaiter(this, void 0, void 0, function* () {
147
- const slug = prop['slug'];
148
- console.debug('getObjectReferenceValue-prop: ' + slug);
149
- let value = newData[slug];
150
- const entityType = prop['referencedTypeRootSlug'];
151
- const entityId = newData[slug + 'Id'];
152
- if (!value && expandObjRef) {
153
- if (entityId) {
154
- if (this.objRefCache[entityId]) {
155
- console.log('cache hit: ' + entityId);
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
- if (value) {
169
- const unprocessedValue = value;
170
- const objectClass = this.typeUtils.getEventObjectClass(entityType, newData);
171
- value = yield this.getFlexPLMObjectData(value, [], false);
172
- value['entityReference'] = entityType + ':' + entityId;
173
- value['objectClass'] = objectClass;
174
- value['typePath'] = unprocessedValue['typePath'];
175
- if (this.transformMapFile) {
176
- const wholeMap = yield this.mapFileUtil.getMapFile(this.transformMapFile);
177
- const objClass = this.getMappingClass(unprocessedValue, wholeMap);
178
- const mapping = yield this.mapFileUtil.getMappingSection(this.transformMapFile, objClass, 'vibe2flex');
179
- if (mapping) {
180
- const tasks = transform_data_1.MapFileUtil.getTransformTasks(mapping);
181
- if (tasks.length > 0) {
182
- const convertedArray = transform_data_1.TransformProcessor.transformData([value], tasks);
183
- value = convertedArray[0];
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
- else {
189
- value = {};
190
- }
191
- this.objRefCache[entityId] = value;
192
- return value;
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
- return __awaiter(this, void 0, void 0, function* () {
210
- const type = yield this.typeUtils.getTypeById(entity.typeId);
211
- keysToSkip = keysToSkip.concat(['updatedOn', 'updatedById', 'createdOn', 'createdById', 'modifiedAt', 'orgId', 'createdAt', 'id', 'typeId', 'workspaceId']);
212
- let typeProps = this.typeUtils.filterTypeProperties(type, entity);
213
- typeProps = typeProps.filter(prop => !keysToSkip.includes(prop['slug']));
214
- const dataKeys = Object.getOwnPropertyNames(data);
215
- typeProps = typeProps.filter(prop => dataKeys.includes(prop['slug']));
216
- for (const prop of typeProps) {
217
- const slug = prop['slug'];
218
- entity[slug] = yield this.getEntityValue(prop, data);
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
- return __awaiter(this, void 0, void 0, function* () {
225
- const entityValues = {};
226
- const tco = this.typeUtils.getEntityTypeClientOptions(objectClass, data);
227
- const type = yield this.typeUtils.getByRootAndPath(tco);
228
- const typePath = type['typePath'];
229
- if (typePath && (typePath.startsWith('item') || typePath.startsWith('project-item'))) {
230
- if (['LCSProduct', 'LCSProductSeasonLink'].includes(objectClass)) {
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
- let typeProps = this.typeUtils.filterTypeProperties(type, entityValues);
238
- typeProps = typeProps.filter(prop => !keysToSkip.includes(prop['slug']));
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
- return entityValues;
247
- });
248
- }
249
- getEntityValue(prop, data) {
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 nd = data[slug];
254
- let value;
255
- if (['string', 'text'].includes(propertyType)) {
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
- else if ('formula' === propertyType) {
285
- console.log('TODO');
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 if ('json' === propertyType) {
288
- console.log('TODO');
244
+ else {
245
+ value = null;
289
246
  }
290
- return value;
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'];