@contrail/flexplm 1.5.0-alpha.98b8b06 → 1.5.0
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/.github/pull_request_template.md +31 -0
- package/.github/workflows/flexplm-lib.yml +27 -0
- package/.github/workflows/publish-to-npm.yml +121 -0
- package/CHANGELOG.md +45 -0
- package/lib/entity-processor/base-entity-processor.d.ts +0 -65
- package/lib/entity-processor/base-entity-processor.js +0 -71
- package/lib/entity-processor/base-entity-processor.spec.js +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/publish/base-process-publish-assortment.d.ts +0 -25
- package/lib/publish/base-process-publish-assortment.js +6 -60
- package/lib/publish/base-process-publish-assortment.spec.js +4 -22
- package/lib/publish/mockData.js +0 -5
- package/lib/transform/identifier-conversion-spec-mockData.js +6 -34
- package/lib/transform/identifier-conversion.d.ts +0 -36
- package/lib/transform/identifier-conversion.js +0 -36
- package/lib/transform/identifier-conversion.spec.js +0 -4
- package/lib/util/config-defaults.js +0 -3
- package/lib/util/config-defaults.spec.js +0 -9
- package/lib/util/data-converter-spec-mockData.js +3 -17
- package/lib/util/data-converter.d.ts +0 -97
- package/lib/util/data-converter.js +1 -127
- package/lib/util/data-converter.spec.js +0 -2
- package/lib/util/error-response-object.d.ts +0 -5
- package/lib/util/error-response-object.js +0 -7
- package/lib/util/event-short-message-status.js +0 -1
- package/lib/util/federation.js +0 -8
- package/lib/util/flexplm-connect.d.ts +0 -7
- package/lib/util/flexplm-connect.js +0 -14
- package/lib/util/logger-config.js +0 -1
- package/lib/util/map-util-spec-mockData.js +3 -17
- package/lib/util/map-utils.d.ts +0 -27
- package/lib/util/map-utils.js +0 -27
- package/lib/util/thumbnail-util.d.ts +0 -21
- package/lib/util/thumbnail-util.js +1 -28
- package/lib/util/thumbnail-util.spec.js +0 -6
- package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
- package/lib/util/type-conversion-utils.d.ts +1 -152
- package/lib/util/type-conversion-utils.js +1 -155
- package/lib/util/type-defaults.d.ts +0 -66
- package/lib/util/type-defaults.js +0 -66
- package/lib/util/type-defaults.spec.js +5 -5
- package/lib/util/type-utils.d.ts +0 -21
- package/lib/util/type-utils.js +0 -23
- package/lib/util/type-utils.spec.js +0 -2
- package/package.json +6 -21
- package/publish.bat +5 -0
- package/publish.sh +5 -0
- package/src/entity-processor/base-entity-processor.spec.ts +689 -0
- package/src/entity-processor/base-entity-processor.ts +583 -0
- package/src/flexplm-request.ts +28 -0
- package/src/flexplm-utils.spec.ts +27 -0
- package/src/flexplm-utils.ts +29 -0
- package/src/index.ts +22 -0
- package/src/interfaces/interfaces.ts +122 -0
- package/src/interfaces/item-family-changes.ts +67 -0
- package/src/interfaces/publish-change-data.ts +43 -0
- package/src/publish/base-process-publish-assortment-callback.ts +50 -0
- package/src/publish/base-process-publish-assortment.spec.ts +1992 -0
- package/src/publish/base-process-publish-assortment.ts +1134 -0
- package/src/publish/mockData.ts +4561 -0
- package/src/transform/identifier-conversion-spec-mockData.ts +496 -0
- package/src/transform/identifier-conversion.spec.ts +386 -0
- package/src/transform/identifier-conversion.ts +282 -0
- package/src/util/config-defaults.spec.ts +445 -0
- package/src/util/config-defaults.ts +106 -0
- package/src/util/data-converter-spec-mockData.ts +231 -0
- package/src/util/data-converter.spec.ts +1622 -0
- package/src/util/data-converter.ts +819 -0
- package/src/util/error-response-object.spec.ts +116 -0
- package/src/util/error-response-object.ts +50 -0
- package/src/util/event-short-message-status.ts +22 -0
- package/src/util/federation.ts +172 -0
- package/src/util/flexplm-connect.spec.ts +132 -0
- package/src/util/flexplm-connect.ts +208 -0
- package/src/util/logger-config.ts +20 -0
- package/src/util/map-util-spec-mockData.ts +231 -0
- package/src/util/map-utils.spec.ts +103 -0
- package/src/util/map-utils.ts +41 -0
- package/src/util/mockData.ts +101 -0
- package/src/util/thumbnail-util.spec.ts +508 -0
- package/src/util/thumbnail-util.ts +272 -0
- package/src/util/type-conversion-utils-spec-mockData.ts +272 -0
- package/src/util/type-conversion-utils.spec.ts +1031 -0
- package/src/util/type-conversion-utils.ts +490 -0
- package/src/util/type-defaults.spec.ts +797 -0
- package/src/util/type-defaults.ts +320 -0
- package/src/util/type-utils.spec.ts +227 -0
- package/src/util/type-utils.ts +144 -0
- package/tsconfig.json +24 -0
- package/tslint.json +57 -0
- package/lib/cli/commands/compile.d.ts +0 -4
- package/lib/cli/commands/compile.js +0 -73
- package/lib/cli/commands/compile.spec.d.ts +0 -1
- package/lib/cli/commands/compile.spec.js +0 -80
- package/lib/cli/commands/create.d.ts +0 -5
- package/lib/cli/commands/create.js +0 -77
- package/lib/cli/commands/create.spec.d.ts +0 -1
- package/lib/cli/commands/create.spec.js +0 -78
- package/lib/cli/commands/upload.d.ts +0 -17
- package/lib/cli/commands/upload.js +0 -228
- package/lib/cli/commands/upload.spec.d.ts +0 -1
- package/lib/cli/commands/upload.spec.js +0 -88
- package/lib/cli/index.d.ts +0 -5
- package/lib/cli/index.js +0 -70
- package/lib/cli/index.spec.d.ts +0 -1
- package/lib/cli/index.spec.js +0 -85
- package/lib/cli/template/mapping-template.ts.template +0 -62
- package/lib/interfaces/mapping-file.d.ts +0 -460
- package/lib/interfaces/mapping-file.js +0 -2
- package/scripts/copy-template.js +0 -10
|
@@ -31,26 +31,12 @@ exports.mapping = {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
// flex2vibe: {
|
|
35
|
-
// LCSRevisableEntity: {
|
|
36
|
-
// getMapKey: (object) =>{ return object;}
|
|
37
|
-
// },
|
|
38
|
-
// LCSLast: {
|
|
39
|
-
// getMapKey: (object) => {return object;}
|
|
40
|
-
// },
|
|
41
|
-
// LCSMaterial: {
|
|
42
|
-
// getMapKey: (object) =>{ return object;}
|
|
43
|
-
// },
|
|
44
|
-
// LCSBusinessObject: {
|
|
45
|
-
// getMapKey: (object) => {return object;}
|
|
46
|
-
// }
|
|
47
|
-
// },
|
|
48
34
|
},
|
|
49
35
|
LCSProduct: {
|
|
50
36
|
vibeOwningKeys: ['itemNumber', 'lifecycleStage'],
|
|
51
37
|
vibe2flex: {
|
|
52
38
|
getClass: () => 'LCSProduct',
|
|
53
|
-
getSoftType: (entity
|
|
39
|
+
getSoftType: (entity) => {
|
|
54
40
|
const prodType = entity['prodType'];
|
|
55
41
|
let val = '';
|
|
56
42
|
switch (prodType) {
|
|
@@ -75,7 +61,7 @@ exports.mapping = {
|
|
|
75
61
|
vibeIQIdentifier: 'itemNumber'
|
|
76
62
|
},
|
|
77
63
|
valueTransform: {
|
|
78
|
-
transformEx: (row
|
|
64
|
+
transformEx: (row) => {
|
|
79
65
|
return row['otherProp'] + 'xxx';
|
|
80
66
|
}
|
|
81
67
|
}
|
|
@@ -93,7 +79,7 @@ exports.mapping = {
|
|
|
93
79
|
vibeOwningKeys: ['itemNumber', 'lifecycleStage'],
|
|
94
80
|
vibe2flex: {
|
|
95
81
|
getClass: () => 'LCSSKU',
|
|
96
|
-
getSoftType: (entity
|
|
82
|
+
getSoftType: (entity) => {
|
|
97
83
|
const prodType = entity['prodType'];
|
|
98
84
|
let val = '';
|
|
99
85
|
switch (prodType) {
|
|
@@ -19,123 +19,26 @@ export declare class DataConverter {
|
|
|
19
19
|
getFlexPLMObjectDataFromEvent(event: any, dataToSkip: string[]): Promise<{}>;
|
|
20
20
|
getFlexPLMObjectData(newData: any, dataToSkip: string[], inflateObjRef: boolean): Promise<{}>;
|
|
21
21
|
getFlexPLMValue(prop: any, newData: any, inflateObjRef: boolean): Promise<any>;
|
|
22
|
-
/** Returns the display values for list properties (choice & multi_select)
|
|
23
|
-
*
|
|
24
|
-
* @param prop
|
|
25
|
-
* @param newData
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
22
|
getEnumerationValue(prop: any, nd: any): any;
|
|
29
23
|
getObjectReferenceValue(prop: any, newData: any, inflateObjRef?: boolean): Promise<any>;
|
|
30
|
-
/** (Deprecated) Use TypeConversionUtils.getMapKey()
|
|
31
|
-
* Will return the class to use to get mapping.
|
|
32
|
-
* This is needed because mappings will be different for different sub types
|
|
33
|
-
* of custom-entity
|
|
34
|
-
*
|
|
35
|
-
* @param obj: Entity being checked
|
|
36
|
-
* @param mapping: The whole mapping file
|
|
37
|
-
*/
|
|
38
24
|
getMappingClass(entity: object, mapping: any): string;
|
|
39
|
-
/** Sets entity values from FlexPLM data passed in
|
|
40
|
-
* Assumes the entity has a VibeIQ typeId and 'roles' value to filter if necessary.
|
|
41
|
-
* @param entity the entity to update
|
|
42
|
-
* @param data the FlexPLM data
|
|
43
|
-
* @param keysToSkip properties to skip
|
|
44
|
-
* @returns the modified entity with VibeIQ values
|
|
45
|
-
*/
|
|
46
25
|
setEntityValues(entity: any, data: any, keysToSkip?: string[]): Promise<any>;
|
|
47
|
-
/** Gets the entity values from FlexPLM data
|
|
48
|
-
* Assumes there isn't a VibeIQ typeId, so uses FlexPLM data to determine type
|
|
49
|
-
* @param objectClass FlexPLM object class
|
|
50
|
-
* @param data object data
|
|
51
|
-
* @param keysToSkip type properties to not process
|
|
52
|
-
* @returns object with VibeIQ values
|
|
53
|
-
*/
|
|
54
26
|
getEntityValues(objectClass: string, data: any, keysToSkip?: string[]): Promise<{}>;
|
|
55
|
-
/** Gets the VibeIQ value for the property from data
|
|
56
|
-
*
|
|
57
|
-
* @param prop the VibeIQ property
|
|
58
|
-
* @param data the FlexPLM data
|
|
59
|
-
* @returns value to be set in VibeIQ
|
|
60
|
-
*/
|
|
61
27
|
getEntityValue(prop: any, data: any): Promise<any>;
|
|
62
28
|
setEnumerationKeys(prop: any, nd: any, matchByDisplay: any): any;
|
|
63
|
-
/** Compares the potential changes to the entity and returns only the actual differences.
|
|
64
|
-
*
|
|
65
|
-
* @param entity the full entity
|
|
66
|
-
* @param changes the potential changes
|
|
67
|
-
* @returns only the change values that are different from the entity's value
|
|
68
|
-
*/
|
|
69
29
|
getPersistableChanges(entity: object, changes: object): object;
|
|
70
|
-
/** Sets object reference value from FlexPLM data passed in
|
|
71
|
-
*
|
|
72
|
-
* @param prop the VibeIQ property
|
|
73
|
-
* @param nd the VibeIQ data
|
|
74
|
-
* @returns the object reference id from VibeIQ
|
|
75
|
-
*/
|
|
76
30
|
setObjectReferenceValue(prop: any, nd: any): Promise<any>;
|
|
77
31
|
private applyInboundTransformMap;
|
|
78
32
|
private buildObjectReferenceContext;
|
|
79
33
|
private lookupObjectReferenceViaIdentityService;
|
|
80
34
|
private lookupObjectReferenceViaQuery;
|
|
81
35
|
private pickSingleResult;
|
|
82
|
-
/**
|
|
83
|
-
* Retrieves all object references of a specified entity type based on the provided criteria.
|
|
84
|
-
* This function handles pagination and asynchronously fetches object references until there are no more pages.
|
|
85
|
-
* @param {string} entityType - The type of entity for which object references are to be retrieved.
|
|
86
|
-
* @param {object} rootTypeCriteria - The criteria used to filter object references.
|
|
87
|
-
* @returns {Promise<Array>} A Promise that resolves to an array containing all object references.
|
|
88
|
-
*/
|
|
89
36
|
getAllObjectReferences(entityType: string, rootTypeCriteria: any, postProcessCriteria?: any): Promise<any[]>;
|
|
90
|
-
/**
|
|
91
|
-
* Checks if all keys and values of a given object are present in an array of objects.
|
|
92
|
-
* @param {Object} criteria - The object whose keys and values are to be checked in the array of objects.
|
|
93
|
-
* @param {Array<Object>} arrayOfObjects - The array of objects to be searched for matching keys and values.
|
|
94
|
-
* @param {string} entityTypePath - The type / subtype for the property; objects must be this type or a sub type of it.
|
|
95
|
-
* @returns {(Object|boolean)} Returns the array of objects that matches all keys and values of the provided object.
|
|
96
|
-
* If no match is found, returns empty array.
|
|
97
|
-
*/
|
|
98
37
|
checkKeysAndValues(criteria: any, arrayOfObjects: any, entityTypePath: any): any[];
|
|
99
|
-
/** Filters out archived and trashed entities from the provided array of entities.
|
|
100
|
-
*
|
|
101
|
-
* @param entities
|
|
102
|
-
* @returns
|
|
103
|
-
*/
|
|
104
38
|
filterOutArchivedAndTrashedEntities(entities: any[]): any[];
|
|
105
|
-
/** Sets userListId value from FlexPLM data passed in
|
|
106
|
-
*
|
|
107
|
-
* @param prop the VibeIQ property
|
|
108
|
-
* @param nd the VibeIQ data
|
|
109
|
-
* @returns the modified entity with FlexPLM values
|
|
110
|
-
*/
|
|
111
39
|
setUserListValue(prop: any, nd: any): Promise<any>;
|
|
112
|
-
/** Makes batch calls of 1000 of user-org entities until
|
|
113
|
-
* it find one with userEmail of passed in nd.email.
|
|
114
|
-
* Maxes out after querying for 15,000 user-org entities
|
|
115
|
-
*
|
|
116
|
-
* @param nd
|
|
117
|
-
* @returns
|
|
118
|
-
*/
|
|
119
40
|
getUserByEmail(nd: any): Promise<any>;
|
|
120
|
-
/** Shows warning if user email address not present in group associated to property
|
|
121
|
-
*
|
|
122
|
-
* @param prop the VibeIQ property
|
|
123
|
-
* @param userEmail user email address
|
|
124
|
-
*/
|
|
125
41
|
processGroupMemberCheck(prop: any, userEmail: any): Promise<void>;
|
|
126
|
-
/** Gets the VibeIQ value for the userList property from data
|
|
127
|
-
*
|
|
128
|
-
* @param prop the VibeIQ property
|
|
129
|
-
* @param newData the FlexPLM data
|
|
130
|
-
* @returns value to be set in VibeIQ
|
|
131
|
-
*/
|
|
132
42
|
getUserListValue(prop: any, newData: any): Promise<any>;
|
|
133
|
-
/** Makes batch calls of 1000 of user-org entities until
|
|
134
|
-
* it find one with user.id of passed in userId.
|
|
135
|
-
* Maxes out after querying for 15,000 user-org entities
|
|
136
|
-
*
|
|
137
|
-
* @param userId
|
|
138
|
-
* @returns
|
|
139
|
-
*/
|
|
140
43
|
getUserById(userId: any): Promise<any>;
|
|
141
44
|
}
|
|
@@ -45,22 +45,16 @@ class DataConverter {
|
|
|
45
45
|
if (this.isVerboseDebugOn()) {
|
|
46
46
|
console.debug('newData: ' + JSON.stringify(newData));
|
|
47
47
|
}
|
|
48
|
-
//Using event to get propertyDiffs to find emptied values
|
|
49
|
-
//Add standard atts to skip
|
|
50
48
|
dataToSkip = dataToSkip.concat(['updatedOn', 'updatedById', 'createdOn', 'createdById', 'modifiedAt', 'orgId', 'createdAt', 'id', 'typeId', 'workspaceId']);
|
|
51
|
-
// const oldData = event.oldData;
|
|
52
49
|
const data = {};
|
|
53
50
|
const typeId = newData?.typeId;
|
|
54
51
|
if (!typeId) {
|
|
55
|
-
return;
|
|
52
|
+
return;
|
|
56
53
|
}
|
|
57
54
|
data['typePath'] = newData['typePath'];
|
|
58
55
|
const type = await this.typeUtils.getTypeById(typeId);
|
|
59
56
|
const typeProps = this.typeUtils.filterTypeProperties(type, newData);
|
|
60
57
|
for (const prop of typeProps) {
|
|
61
|
-
// if(this.logger.isTraceOn()){
|
|
62
|
-
// this.logger.log('prop: ' + JSON.stringify(prop));
|
|
63
|
-
// }
|
|
64
58
|
const slug = prop['slug'];
|
|
65
59
|
if (dataToSkip.includes(slug)) {
|
|
66
60
|
continue;
|
|
@@ -76,7 +70,6 @@ class DataConverter {
|
|
|
76
70
|
const propertyType = prop['propertyType'];
|
|
77
71
|
const slug = prop['slug'];
|
|
78
72
|
const nd = newData[slug];
|
|
79
|
-
// console.log('getFlexPLMValue: ' + propertyType + ', ' +slug + ', ' + nd + ', ' + od);
|
|
80
73
|
let value;
|
|
81
74
|
if (['string', 'text'].includes(propertyType)) {
|
|
82
75
|
value = nd || '';
|
|
@@ -87,10 +80,6 @@ class DataConverter {
|
|
|
87
80
|
else if ('date' === propertyType) {
|
|
88
81
|
if (nd) {
|
|
89
82
|
value = nd;
|
|
90
|
-
// const d = new Date(nd);
|
|
91
|
-
// console.log('Date.getTimezoneOffset(): ' + d.getTimezoneOffset());
|
|
92
|
-
// value = d.toISOString();
|
|
93
|
-
// console.log('date: ' + nd + ' -- ' + value);
|
|
94
83
|
}
|
|
95
84
|
else {
|
|
96
85
|
value = null;
|
|
@@ -112,13 +101,11 @@ class DataConverter {
|
|
|
112
101
|
}
|
|
113
102
|
}
|
|
114
103
|
else if ('image' === propertyType) {
|
|
115
|
-
// console.log('image-TODO');
|
|
116
104
|
}
|
|
117
105
|
else if ('formula' === propertyType) {
|
|
118
106
|
value = nd;
|
|
119
107
|
}
|
|
120
108
|
else if ('json' === propertyType) {
|
|
121
|
-
// console.log('json-TODO');
|
|
122
109
|
value = nd;
|
|
123
110
|
}
|
|
124
111
|
else if ('userList' === propertyType) {
|
|
@@ -129,12 +116,6 @@ class DataConverter {
|
|
|
129
116
|
}
|
|
130
117
|
return value;
|
|
131
118
|
}
|
|
132
|
-
/** Returns the display values for list properties (choice & multi_select)
|
|
133
|
-
*
|
|
134
|
-
* @param prop
|
|
135
|
-
* @param newData
|
|
136
|
-
* @returns
|
|
137
|
-
*/
|
|
138
119
|
getEnumerationValue(prop, nd) {
|
|
139
120
|
const propertyType = prop['propertyType'];
|
|
140
121
|
let value;
|
|
@@ -218,14 +199,6 @@ class DataConverter {
|
|
|
218
199
|
this.objRefCache[entityId] = value;
|
|
219
200
|
return value;
|
|
220
201
|
}
|
|
221
|
-
/** (Deprecated) Use TypeConversionUtils.getMapKey()
|
|
222
|
-
* Will return the class to use to get mapping.
|
|
223
|
-
* This is needed because mappings will be different for different sub types
|
|
224
|
-
* of custom-entity
|
|
225
|
-
*
|
|
226
|
-
* @param obj: Entity being checked
|
|
227
|
-
* @param mapping: The whole mapping file
|
|
228
|
-
*/
|
|
229
202
|
getMappingClass(entity, mapping) {
|
|
230
203
|
const entityTypePath = entity['typePath'];
|
|
231
204
|
const typeMapKey = mapping['typeMapKey'];
|
|
@@ -239,22 +212,11 @@ class DataConverter {
|
|
|
239
212
|
}
|
|
240
213
|
return objClass;
|
|
241
214
|
}
|
|
242
|
-
/** Sets entity values from FlexPLM data passed in
|
|
243
|
-
* Assumes the entity has a VibeIQ typeId and 'roles' value to filter if necessary.
|
|
244
|
-
* @param entity the entity to update
|
|
245
|
-
* @param data the FlexPLM data
|
|
246
|
-
* @param keysToSkip properties to skip
|
|
247
|
-
* @returns the modified entity with VibeIQ values
|
|
248
|
-
*/
|
|
249
215
|
async setEntityValues(entity, data, keysToSkip = []) {
|
|
250
|
-
// this.logger.log('setEntityValues: ' + JSON.stringify(entity));
|
|
251
|
-
// this.logger.log('data: ' + JSON.stringify(data));
|
|
252
216
|
const type = await this.typeUtils.getTypeById(entity.typeId);
|
|
253
217
|
keysToSkip = keysToSkip.concat(['updatedOn', 'updatedById', 'createdOn', 'createdById', 'modifiedAt', 'orgId', 'createdAt', 'id', 'typeId', 'typePath', 'workspaceId']);
|
|
254
218
|
let typeProps = this.typeUtils.filterTypeProperties(type, entity);
|
|
255
219
|
typeProps = typeProps.filter(prop => !keysToSkip.includes(prop['slug']));
|
|
256
|
-
//Only process properties that had a value sent; to not accidentally clear out values
|
|
257
|
-
//for properties that weren't sent.
|
|
258
220
|
const dataKeys = Object.getOwnPropertyNames(data);
|
|
259
221
|
typeProps = typeProps.filter(prop => dataKeys.includes(prop['slug']));
|
|
260
222
|
for (const prop of typeProps) {
|
|
@@ -265,17 +227,9 @@ class DataConverter {
|
|
|
265
227
|
keyName = slug + 'Id';
|
|
266
228
|
}
|
|
267
229
|
entity[keyName] = await this.getEntityValue(prop, data);
|
|
268
|
-
// console.log('entity[slug]: ' + entity[slug]);
|
|
269
230
|
}
|
|
270
231
|
return entity;
|
|
271
232
|
}
|
|
272
|
-
/** Gets the entity values from FlexPLM data
|
|
273
|
-
* Assumes there isn't a VibeIQ typeId, so uses FlexPLM data to determine type
|
|
274
|
-
* @param objectClass FlexPLM object class
|
|
275
|
-
* @param data object data
|
|
276
|
-
* @param keysToSkip type properties to not process
|
|
277
|
-
* @returns object with VibeIQ values
|
|
278
|
-
*/
|
|
279
233
|
async getEntityValues(objectClass, data, keysToSkip = []) {
|
|
280
234
|
const entityValues = {};
|
|
281
235
|
const tco = await this.typeUtils.getEntityTypeClientOptionsUsingMapping(this.transformMapFile, this.mapFileUtil, data);
|
|
@@ -300,17 +254,10 @@ class DataConverter {
|
|
|
300
254
|
}
|
|
301
255
|
return entityValues;
|
|
302
256
|
}
|
|
303
|
-
/** Gets the VibeIQ value for the property from data
|
|
304
|
-
*
|
|
305
|
-
* @param prop the VibeIQ property
|
|
306
|
-
* @param data the FlexPLM data
|
|
307
|
-
* @returns value to be set in VibeIQ
|
|
308
|
-
*/
|
|
309
257
|
async getEntityValue(prop, data) {
|
|
310
258
|
const propertyType = prop['propertyType'];
|
|
311
259
|
const slug = prop['slug'];
|
|
312
260
|
const nd = data[slug];
|
|
313
|
-
// this.logger.log('getValue: ' + propertyType + ', ' +slug + ', ' + nd);
|
|
314
261
|
let value;
|
|
315
262
|
if (['string', 'text'].includes(propertyType)) {
|
|
316
263
|
value = nd;
|
|
@@ -320,11 +267,6 @@ class DataConverter {
|
|
|
320
267
|
}
|
|
321
268
|
else if ('date' === propertyType) {
|
|
322
269
|
if (nd) {
|
|
323
|
-
// const offset = new Date(nd).getTimezoneOffset() * 60 * 1_000;
|
|
324
|
-
// this.logger.log('nd: ' + nd);
|
|
325
|
-
// this.logger.log(offset);
|
|
326
|
-
// this.logger.log('No Offset: ' + new Date(nd).toISOString());
|
|
327
|
-
// const d = new Date(nd + offset);// Take system Timezone into account.
|
|
328
270
|
const d = new Date(nd);
|
|
329
271
|
value = d.toISOString();
|
|
330
272
|
}
|
|
@@ -345,13 +287,10 @@ class DataConverter {
|
|
|
345
287
|
value = await this.setObjectReferenceValue(prop, nd);
|
|
346
288
|
}
|
|
347
289
|
else if ('image' === propertyType) {
|
|
348
|
-
// console.log('TODO-image');
|
|
349
290
|
}
|
|
350
291
|
else if ('formula' === propertyType) {
|
|
351
|
-
// console.log('TODO-formula');
|
|
352
292
|
}
|
|
353
293
|
else if ('json' === propertyType) {
|
|
354
|
-
// console.log('TODO-json');
|
|
355
294
|
}
|
|
356
295
|
else if ('userList' === propertyType) {
|
|
357
296
|
value = await this.setUserListValue(prop, nd);
|
|
@@ -359,14 +298,12 @@ class DataConverter {
|
|
|
359
298
|
else if ('size_range' === propertyType) {
|
|
360
299
|
value = nd;
|
|
361
300
|
}
|
|
362
|
-
// console.log(value);
|
|
363
301
|
return value;
|
|
364
302
|
}
|
|
365
303
|
setEnumerationKeys(prop, nd, matchByDisplay) {
|
|
366
304
|
const propertyType = prop['propertyType'];
|
|
367
305
|
let value;
|
|
368
306
|
if (['choice', 'multi_select'].includes(propertyType)) {
|
|
369
|
-
//If there are no options, use empty array to not error out and don't set anything
|
|
370
307
|
const options = prop['options'] || [];
|
|
371
308
|
if ('choice' === propertyType) {
|
|
372
309
|
if (nd) {
|
|
@@ -396,12 +333,6 @@ class DataConverter {
|
|
|
396
333
|
}
|
|
397
334
|
return value;
|
|
398
335
|
}
|
|
399
|
-
/** Compares the potential changes to the entity and returns only the actual differences.
|
|
400
|
-
*
|
|
401
|
-
* @param entity the full entity
|
|
402
|
-
* @param changes the potential changes
|
|
403
|
-
* @returns only the change values that are different from the entity's value
|
|
404
|
-
*/
|
|
405
336
|
getPersistableChanges(entity, changes) {
|
|
406
337
|
const entityCompareValues = {};
|
|
407
338
|
for (const key of (Object.getOwnPropertyNames(changes))) {
|
|
@@ -416,12 +347,6 @@ class DataConverter {
|
|
|
416
347
|
}
|
|
417
348
|
return diffValues;
|
|
418
349
|
}
|
|
419
|
-
/** Sets object reference value from FlexPLM data passed in
|
|
420
|
-
*
|
|
421
|
-
* @param prop the VibeIQ property
|
|
422
|
-
* @param nd the VibeIQ data
|
|
423
|
-
* @returns the object reference id from VibeIQ
|
|
424
|
-
*/
|
|
425
350
|
async setObjectReferenceValue(prop, nd) {
|
|
426
351
|
if (!nd) {
|
|
427
352
|
return "";
|
|
@@ -514,13 +439,6 @@ class DataConverter {
|
|
|
514
439
|
}
|
|
515
440
|
return results[0];
|
|
516
441
|
}
|
|
517
|
-
/**
|
|
518
|
-
* Retrieves all object references of a specified entity type based on the provided criteria.
|
|
519
|
-
* This function handles pagination and asynchronously fetches object references until there are no more pages.
|
|
520
|
-
* @param {string} entityType - The type of entity for which object references are to be retrieved.
|
|
521
|
-
* @param {object} rootTypeCriteria - The criteria used to filter object references.
|
|
522
|
-
* @returns {Promise<Array>} A Promise that resolves to an array containing all object references.
|
|
523
|
-
*/
|
|
524
442
|
async getAllObjectReferences(entityType, rootTypeCriteria, postProcessCriteria = null) {
|
|
525
443
|
const entities = new sdk_1.Entities();
|
|
526
444
|
let loads = [];
|
|
@@ -576,14 +494,6 @@ class DataConverter {
|
|
|
576
494
|
}
|
|
577
495
|
return loads;
|
|
578
496
|
}
|
|
579
|
-
/**
|
|
580
|
-
* Checks if all keys and values of a given object are present in an array of objects.
|
|
581
|
-
* @param {Object} criteria - The object whose keys and values are to be checked in the array of objects.
|
|
582
|
-
* @param {Array<Object>} arrayOfObjects - The array of objects to be searched for matching keys and values.
|
|
583
|
-
* @param {string} entityTypePath - The type / subtype for the property; objects must be this type or a sub type of it.
|
|
584
|
-
* @returns {(Object|boolean)} Returns the array of objects that matches all keys and values of the provided object.
|
|
585
|
-
* If no match is found, returns empty array.
|
|
586
|
-
*/
|
|
587
497
|
checkKeysAndValues(criteria, arrayOfObjects, entityTypePath) {
|
|
588
498
|
let arrOfMatchObjects = [];
|
|
589
499
|
for (let i = 0; i < arrayOfObjects.length; i++) {
|
|
@@ -607,11 +517,6 @@ class DataConverter {
|
|
|
607
517
|
}
|
|
608
518
|
return arrOfMatchObjects;
|
|
609
519
|
}
|
|
610
|
-
/** Filters out archived and trashed entities from the provided array of entities.
|
|
611
|
-
*
|
|
612
|
-
* @param entities
|
|
613
|
-
* @returns
|
|
614
|
-
*/
|
|
615
520
|
filterOutArchivedAndTrashedEntities(entities) {
|
|
616
521
|
if (!entities || !Array.isArray(entities) || entities.length === 0) {
|
|
617
522
|
return [];
|
|
@@ -622,12 +527,6 @@ class DataConverter {
|
|
|
622
527
|
return !isArchived && !isTrashed;
|
|
623
528
|
});
|
|
624
529
|
}
|
|
625
|
-
/** Sets userListId value from FlexPLM data passed in
|
|
626
|
-
*
|
|
627
|
-
* @param prop the VibeIQ property
|
|
628
|
-
* @param nd the VibeIQ data
|
|
629
|
-
* @returns the modified entity with FlexPLM values
|
|
630
|
-
*/
|
|
631
530
|
async setUserListValue(prop, nd) {
|
|
632
531
|
if (!nd?.email) {
|
|
633
532
|
return "";
|
|
@@ -648,13 +547,6 @@ class DataConverter {
|
|
|
648
547
|
}
|
|
649
548
|
return userId;
|
|
650
549
|
}
|
|
651
|
-
/** Makes batch calls of 1000 of user-org entities until
|
|
652
|
-
* it find one with userEmail of passed in nd.email.
|
|
653
|
-
* Maxes out after querying for 15,000 user-org entities
|
|
654
|
-
*
|
|
655
|
-
* @param nd
|
|
656
|
-
* @returns
|
|
657
|
-
*/
|
|
658
550
|
async getUserByEmail(nd) {
|
|
659
551
|
let userOrg = undefined;
|
|
660
552
|
let count = 0;
|
|
@@ -671,11 +563,6 @@ class DataConverter {
|
|
|
671
563
|
} while (!userOrg && size == getOptionsCriteria.take && count < 15);
|
|
672
564
|
return userOrg?.user;
|
|
673
565
|
}
|
|
674
|
-
/** Shows warning if user email address not present in group associated to property
|
|
675
|
-
*
|
|
676
|
-
* @param prop the VibeIQ property
|
|
677
|
-
* @param userEmail user email address
|
|
678
|
-
*/
|
|
679
566
|
async processGroupMemberCheck(prop, userEmail) {
|
|
680
567
|
let arrUserList = [];
|
|
681
568
|
if (this.userRefCache[prop.typePropertyUserListId]) {
|
|
@@ -698,12 +585,6 @@ class DataConverter {
|
|
|
698
585
|
}
|
|
699
586
|
}
|
|
700
587
|
}
|
|
701
|
-
/** Gets the VibeIQ value for the userList property from data
|
|
702
|
-
*
|
|
703
|
-
* @param prop the VibeIQ property
|
|
704
|
-
* @param newData the FlexPLM data
|
|
705
|
-
* @returns value to be set in VibeIQ
|
|
706
|
-
*/
|
|
707
588
|
async getUserListValue(prop, newData) {
|
|
708
589
|
const slug = prop['slug'];
|
|
709
590
|
if (app_framework_1.Logger.isDebugOn()) {
|
|
@@ -732,13 +613,6 @@ class DataConverter {
|
|
|
732
613
|
}
|
|
733
614
|
return value;
|
|
734
615
|
}
|
|
735
|
-
/** Makes batch calls of 1000 of user-org entities until
|
|
736
|
-
* it find one with user.id of passed in userId.
|
|
737
|
-
* Maxes out after querying for 15,000 user-org entities
|
|
738
|
-
*
|
|
739
|
-
* @param userId
|
|
740
|
-
* @returns
|
|
741
|
-
*/
|
|
742
616
|
async getUserById(userId) {
|
|
743
617
|
let userOrg = undefined;
|
|
744
618
|
let count = 0;
|
|
@@ -1037,7 +1037,6 @@ describe('checkKeysAndValues', () => {
|
|
|
1037
1037
|
{ name: 'Group 4', typePath: 'custom-entity:grouping:sub' },
|
|
1038
1038
|
{ name: 'Group 5', typePath: 'custom-entity:grouping:sub' }
|
|
1039
1039
|
];
|
|
1040
|
-
//item:product:newBalance:accessories, item:product:newBalance:apparel
|
|
1041
1040
|
it('Group 1', () => {
|
|
1042
1041
|
const criteria = {
|
|
1043
1042
|
name: 'Group 1'
|
|
@@ -1259,7 +1258,6 @@ describe('getUserListValue', () => {
|
|
|
1259
1258
|
];
|
|
1260
1259
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
1261
1260
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
1262
|
-
//getUserById
|
|
1263
1261
|
let spyGetUserById = jest.spyOn(dc, 'getUserById')
|
|
1264
1262
|
.mockImplementation(async (nd) => {
|
|
1265
1263
|
return userEmailMapping.find((user) => user.id === nd);
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { AppActionCallBack } from "@contrail/app-framework";
|
|
2
2
|
export declare class ErrorResponseObject {
|
|
3
|
-
/** Returns a response, checking for multiple possible error details
|
|
4
|
-
*
|
|
5
|
-
* @param e
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
3
|
static getResponse(e: any): AppActionCallBack;
|
|
9
4
|
}
|
|
@@ -3,11 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ErrorResponseObject = void 0;
|
|
4
4
|
const app_framework_1 = require("@contrail/app-framework");
|
|
5
5
|
class ErrorResponseObject {
|
|
6
|
-
/** Returns a response, checking for multiple possible error details
|
|
7
|
-
*
|
|
8
|
-
* @param e
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
6
|
static getResponse(e) {
|
|
12
7
|
if (!e) {
|
|
13
8
|
const response = {
|
|
@@ -25,7 +20,6 @@ class ErrorResponseObject {
|
|
|
25
20
|
}
|
|
26
21
|
};
|
|
27
22
|
const output = response.output;
|
|
28
|
-
//Errors when persisting in VibeIQ
|
|
29
23
|
if (e.details)
|
|
30
24
|
output.errorDetails = e.details;
|
|
31
25
|
if (e.code)
|
|
@@ -36,7 +30,6 @@ class ErrorResponseObject {
|
|
|
36
30
|
output.type = e.type;
|
|
37
31
|
if (e.name)
|
|
38
32
|
output.errorName = e.name;
|
|
39
|
-
//Has original cause
|
|
40
33
|
if (e.cause) {
|
|
41
34
|
output.cause = {};
|
|
42
35
|
const cause = output.cause;
|
|
@@ -16,7 +16,6 @@ var EventShortMessageStatus;
|
|
|
16
16
|
EventShortMessageStatus["PRIMARY_CONTENT_UPDATED"] = "Primary_Content_Updated";
|
|
17
17
|
EventShortMessageStatus["TOO_MANY_ENTITIES_FOUND"] = "Too_Many_Entities_Found";
|
|
18
18
|
EventShortMessageStatus["UPDATED"] = "Updated";
|
|
19
|
-
//Publish
|
|
20
19
|
EventShortMessageStatus["NOT_PUBLISHABLE"] = "Not_Publishable";
|
|
21
20
|
EventShortMessageStatus["NO_FEDERATION_INFO"] = "No_Federation_Information";
|
|
22
21
|
EventShortMessageStatus["NO_EVENTS_TO_SEND"] = "No_Events_to_Send";
|
package/lib/util/federation.js
CHANGED
|
@@ -43,11 +43,9 @@ class Federation {
|
|
|
43
43
|
mappedReference: itemResults[i].federatedId,
|
|
44
44
|
federationSchema: FED_CONFIG.federationSchema
|
|
45
45
|
};
|
|
46
|
-
// console.log('createFederatedRecord: ' + JSON.stringify(payload));
|
|
47
46
|
try {
|
|
48
47
|
const results = await new sdk_1.Entities().create({ entityName: 'federation', object: payload });
|
|
49
48
|
return results;
|
|
50
|
-
// console.log(JSON.stringify(results));
|
|
51
49
|
}
|
|
52
50
|
catch (error) {
|
|
53
51
|
console.log('createFederatedRecord-error: ', error);
|
|
@@ -81,16 +79,13 @@ class Federation {
|
|
|
81
79
|
return { entityType, entityId };
|
|
82
80
|
}
|
|
83
81
|
async getEntityFromMappedRefId(mappedRefId) {
|
|
84
|
-
// console.log('!---getEntityFromMappedRefId: ' + mappedRefId);
|
|
85
82
|
const fedRecord = await this.getFederationRecordFromMappedRefId(mappedRefId);
|
|
86
83
|
console.log('fedRecord: ' + JSON.stringify(fedRecord));
|
|
87
84
|
if (!fedRecord) {
|
|
88
|
-
//Not creating from FlexPLM at this time.
|
|
89
85
|
console.log('Federation Record doesnt exist. Cant get entity!');
|
|
90
86
|
return;
|
|
91
87
|
}
|
|
92
88
|
const { entityType, entityId } = Federation.getEntityId(fedRecord);
|
|
93
|
-
// console.log(entityType + ':' + entityId);
|
|
94
89
|
const criteria = {
|
|
95
90
|
id: entityId
|
|
96
91
|
};
|
|
@@ -99,7 +94,6 @@ class Federation {
|
|
|
99
94
|
criteria
|
|
100
95
|
});
|
|
101
96
|
const entity = (entities && entities[0]) ? entities[0] : undefined;
|
|
102
|
-
// console.log(' entities: ' +JSON.stringify(entities));
|
|
103
97
|
return entity;
|
|
104
98
|
}
|
|
105
99
|
async getFederationRecordsFromIds(ids) {
|
|
@@ -110,7 +104,6 @@ class Federation {
|
|
|
110
104
|
appIdentifier: FED_CONFIG.appIdentifier,
|
|
111
105
|
federationSchema: FED_CONFIG.federationSchema
|
|
112
106
|
};
|
|
113
|
-
// this.logger.log('getFederatedMappedRefId: ' + JSON.stringify(criteria));
|
|
114
107
|
const recs = await new sdk_1.Entities().get({
|
|
115
108
|
entityName: 'federation',
|
|
116
109
|
criteria
|
|
@@ -133,7 +126,6 @@ class Federation {
|
|
|
133
126
|
appIdentifier: FED_CONFIG.appIdentifier,
|
|
134
127
|
federationSchema: FED_CONFIG.federationSchema
|
|
135
128
|
};
|
|
136
|
-
// this.logger.log('getFederatedMappedRefId: ' + JSON.stringify(criteria));
|
|
137
129
|
const records = await entities.get({
|
|
138
130
|
entityName: 'federation',
|
|
139
131
|
criteria
|
|
@@ -14,13 +14,6 @@ export declare class FlexPLMConnect {
|
|
|
14
14
|
protected processRequest(payload: any): Promise<FlexPLMResponseData>;
|
|
15
15
|
sendToFlexPLM(payload: PayloadType): Promise<FlexPLMResponseData>;
|
|
16
16
|
sendMultipleToFlexPLM(payload: PayloadType[]): Promise<FlexPLMResponseData>;
|
|
17
|
-
/** Runs a GET request to FlexPLM.
|
|
18
|
-
* @param params - Optional configuration for the request.
|
|
19
|
-
* @param params.urlPath - Custom URL path to use instead of the default `/servlet/rest` + endpoint.
|
|
20
|
-
* @param params.includeUrlContext - Whether to include the urlContext in the URL. Defaults to `true`.
|
|
21
|
-
* @param params.returnFullResponse - If `true`, returns the raw `Response` object instead of parsed JSON. Defaults to `false`.
|
|
22
|
-
* @returns The parsed JSON response body, or the raw `Response` object if `returnFullResponse` is `true`.
|
|
23
|
-
*/
|
|
24
17
|
getRequest(params?: {
|
|
25
18
|
urlPath?: string;
|
|
26
19
|
includeUrlContext?: boolean;
|
|
@@ -18,9 +18,6 @@ class FlexPLMConnect {
|
|
|
18
18
|
this.staticHeaders = this.config?.flexplmConnect?.staticHeaders;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
/////////////////////////////////////////////////////////////////////////////
|
|
22
|
-
///////// Custom getRequestOptions: start
|
|
23
|
-
/////////////////////////////////////////////////////////////////////////////
|
|
24
21
|
getRequestOptions(method) {
|
|
25
22
|
const csrfOptions = {
|
|
26
23
|
method,
|
|
@@ -40,9 +37,6 @@ class FlexPLMConnect {
|
|
|
40
37
|
}
|
|
41
38
|
return csrfOptions;
|
|
42
39
|
}
|
|
43
|
-
/////////////////////////////////////////////////////////////////////////////
|
|
44
|
-
///////// Custom getRequestOptions: end
|
|
45
|
-
/////////////////////////////////////////////////////////////////////////////
|
|
46
40
|
async getCSRF() {
|
|
47
41
|
const urlContext = this.config.urlContext;
|
|
48
42
|
const csrfEndpoint = this.config.csrfEndpoint;
|
|
@@ -136,7 +130,6 @@ class FlexPLMConnect {
|
|
|
136
130
|
}
|
|
137
131
|
}
|
|
138
132
|
console.log('eventResponse.status: ' + status);
|
|
139
|
-
// console.log('eventBody: ', JSON.stringify(data));
|
|
140
133
|
return res;
|
|
141
134
|
}
|
|
142
135
|
catch (e) {
|
|
@@ -152,13 +145,6 @@ class FlexPLMConnect {
|
|
|
152
145
|
async sendMultipleToFlexPLM(payload) {
|
|
153
146
|
return await this.processRequest(payload);
|
|
154
147
|
}
|
|
155
|
-
/** Runs a GET request to FlexPLM.
|
|
156
|
-
* @param params - Optional configuration for the request.
|
|
157
|
-
* @param params.urlPath - Custom URL path to use instead of the default `/servlet/rest` + endpoint.
|
|
158
|
-
* @param params.includeUrlContext - Whether to include the urlContext in the URL. Defaults to `true`.
|
|
159
|
-
* @param params.returnFullResponse - If `true`, returns the raw `Response` object instead of parsed JSON. Defaults to `false`.
|
|
160
|
-
* @returns The parsed JSON response body, or the raw `Response` object if `returnFullResponse` is `true`.
|
|
161
|
-
*/
|
|
162
148
|
async getRequest(params) {
|
|
163
149
|
const { urlPath, includeUrlContext = true, returnFullResponse = false } = params || {};
|
|
164
150
|
const urlContext = includeUrlContext ? this.config.urlContext : '';
|
|
@@ -5,7 +5,6 @@ const app_framework_1 = require("@contrail/app-framework");
|
|
|
5
5
|
async function setLoggerConfig(appConfig) {
|
|
6
6
|
let logLevel = app_framework_1.LogLevel.INFO;
|
|
7
7
|
if (!appConfig.logLevel) {
|
|
8
|
-
//pass
|
|
9
8
|
}
|
|
10
9
|
else if (appConfig.logLevel === 'error') {
|
|
11
10
|
logLevel = app_framework_1.LogLevel.ERROR;
|