@contrail/flexplm 1.3.2-alpha.30ca8bf → 1.3.2-alpha.3ffe557
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/cli/commands/compile.d.ts +4 -0
- package/lib/cli/commands/compile.js +73 -0
- package/lib/cli/commands/compile.spec.d.ts +1 -0
- package/lib/cli/commands/compile.spec.js +80 -0
- package/lib/cli/commands/create.d.ts +5 -0
- package/lib/cli/commands/create.js +77 -0
- package/lib/cli/commands/create.spec.d.ts +1 -0
- package/lib/cli/commands/create.spec.js +78 -0
- package/lib/cli/commands/upload.d.ts +17 -0
- package/lib/cli/commands/upload.js +228 -0
- package/lib/cli/commands/upload.spec.d.ts +1 -0
- package/lib/cli/commands/upload.spec.js +88 -0
- package/lib/cli/index.d.ts +5 -0
- package/lib/cli/index.js +70 -0
- package/lib/cli/index.spec.d.ts +1 -0
- package/lib/cli/index.spec.js +85 -0
- package/lib/cli/template/mapping-template.ts.template +62 -0
- package/lib/entity-processor/base-entity-processor.d.ts +47 -10
- package/lib/entity-processor/base-entity-processor.js +53 -34
- package/lib/entity-processor/base-entity-processor.spec.js +1 -191
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/interfaces/mapping-file.d.ts +460 -0
- package/lib/interfaces/mapping-file.js +2 -0
- package/lib/publish/base-process-publish-assortment.d.ts +25 -0
- package/lib/publish/base-process-publish-assortment.js +60 -6
- package/lib/publish/base-process-publish-assortment.spec.js +22 -4
- package/lib/publish/mockData.js +5 -0
- package/lib/transform/identifier-conversion-spec-mockData.js +34 -6
- package/lib/transform/identifier-conversion.d.ts +36 -0
- package/lib/transform/identifier-conversion.js +36 -0
- package/lib/transform/identifier-conversion.spec.js +4 -0
- package/lib/util/config-defaults.d.ts +0 -1
- package/lib/util/config-defaults.js +3 -3
- package/lib/util/config-defaults.spec.js +9 -32
- package/lib/util/data-converter-spec-mockData.js +17 -3
- package/lib/util/data-converter.d.ts +97 -0
- package/lib/util/data-converter.js +133 -1
- package/lib/util/data-converter.spec.js +68 -0
- package/lib/util/error-response-object.d.ts +5 -0
- package/lib/util/error-response-object.js +7 -0
- package/lib/util/event-short-message-status.js +1 -0
- package/lib/util/federation.js +8 -0
- package/lib/util/flexplm-connect.d.ts +7 -0
- package/lib/util/flexplm-connect.js +14 -0
- package/lib/util/logger-config.js +1 -0
- package/lib/util/map-util-spec-mockData.js +17 -3
- package/lib/util/map-utils.d.ts +27 -0
- package/lib/util/map-utils.js +27 -0
- package/lib/util/thumbnail-util.d.ts +21 -0
- package/lib/util/thumbnail-util.js +28 -1
- package/lib/util/thumbnail-util.spec.js +6 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +3 -4
- package/lib/util/type-conversion-utils.d.ts +140 -1
- package/lib/util/type-conversion-utils.js +143 -16
- package/lib/util/type-conversion-utils.spec.js +0 -59
- package/lib/util/type-defaults.d.ts +58 -0
- package/lib/util/type-defaults.js +58 -0
- package/lib/util/type-defaults.spec.js +5 -5
- package/lib/util/type-utils.d.ts +21 -0
- package/lib/util/type-utils.js +23 -0
- package/lib/util/type-utils.spec.js +2 -0
- package/package.json +21 -6
- package/scripts/copy-template.js +10 -0
- package/.github/pull_request_template.md +0 -31
- package/.github/workflows/flexplm-lib.yml +0 -27
- package/.github/workflows/publish-to-npm.yml +0 -121
- package/CHANGELOG.md +0 -36
- package/publish.bat +0 -5
- package/publish.sh +0 -5
- package/src/entity-processor/base-entity-processor.spec.ts +0 -689
- package/src/entity-processor/base-entity-processor.ts +0 -583
- package/src/flexplm-request.ts +0 -28
- package/src/flexplm-utils.spec.ts +0 -27
- package/src/flexplm-utils.ts +0 -29
- package/src/index.ts +0 -22
- package/src/interfaces/interfaces.ts +0 -122
- package/src/interfaces/item-family-changes.ts +0 -67
- package/src/interfaces/publish-change-data.ts +0 -43
- package/src/publish/base-process-publish-assortment-callback.ts +0 -50
- package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
- package/src/publish/base-process-publish-assortment.ts +0 -1134
- package/src/publish/mockData.ts +0 -4561
- package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
- package/src/transform/identifier-conversion.spec.ts +0 -354
- package/src/transform/identifier-conversion.ts +0 -282
- package/src/util/config-defaults.spec.ts +0 -392
- package/src/util/config-defaults.ts +0 -97
- package/src/util/data-converter-spec-mockData.ts +0 -231
- package/src/util/data-converter.spec.ts +0 -1041
- package/src/util/data-converter.ts +0 -762
- package/src/util/error-response-object.spec.ts +0 -116
- package/src/util/error-response-object.ts +0 -50
- package/src/util/event-short-message-status.ts +0 -22
- package/src/util/federation.ts +0 -172
- package/src/util/flexplm-connect.spec.ts +0 -132
- package/src/util/flexplm-connect.ts +0 -208
- package/src/util/logger-config.ts +0 -20
- package/src/util/map-util-spec-mockData.ts +0 -231
- package/src/util/map-utils.spec.ts +0 -103
- package/src/util/map-utils.ts +0 -41
- package/src/util/mockData.ts +0 -101
- package/src/util/thumbnail-util.spec.ts +0 -508
- package/src/util/thumbnail-util.ts +0 -272
- package/src/util/type-conversion-utils-spec-mockData.ts +0 -272
- package/src/util/type-conversion-utils.spec.ts +0 -1031
- package/src/util/type-conversion-utils.ts +0 -490
- package/src/util/type-defaults.spec.ts +0 -669
- package/src/util/type-defaults.ts +0 -281
- package/src/util/type-utils.spec.ts +0 -227
- package/src/util/type-utils.ts +0 -144
- package/tsconfig.json +0 -24
- package/tslint.json +0 -57
|
@@ -3,9 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TypeConversionUtils = void 0;
|
|
4
4
|
const type_defaults_1 = require("./type-defaults");
|
|
5
5
|
const map_utils_1 = require("./map-utils");
|
|
6
|
+
/** This class is helper functions to get the data for converting
|
|
7
|
+
* VibeIQ entities to / from FlexPLM Objects
|
|
8
|
+
*/
|
|
6
9
|
class TypeConversionUtils {
|
|
7
10
|
constructor() {
|
|
8
11
|
}
|
|
12
|
+
/** Takes in a VibeIQ entity object and returns the correct FlexPLM
|
|
13
|
+
* object class associated to the entity. Order of precedence
|
|
14
|
+
* Property 'flexPLMObjectClass'
|
|
15
|
+
* Map file entry in 'typeConversion:vibe2flex:<value>:getObjectClass()'
|
|
16
|
+
* for value from 'entityClass' or root from 'typePath'
|
|
17
|
+
* TypeDefaults.getDefaultObjectClass() function
|
|
18
|
+
* @param transformMapFile id for mapFile
|
|
19
|
+
* @param mapFileUtil class to get mapfile
|
|
20
|
+
* @param entity
|
|
21
|
+
* @returns Promise<string>
|
|
22
|
+
*/
|
|
9
23
|
static async getObjectClass(transformMapFile, mapFileUtil, entity) {
|
|
10
24
|
let objectClass = entity['flexPLMObjectClass'];
|
|
11
25
|
if (objectClass) {
|
|
@@ -23,6 +37,18 @@ class TypeConversionUtils {
|
|
|
23
37
|
}
|
|
24
38
|
return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
|
|
25
39
|
}
|
|
40
|
+
/** Takes in a VibeIQ entity object and returns the correct FlexPLM
|
|
41
|
+
* FlexType associated to the entity. Order of precedence
|
|
42
|
+
* Property 'flexPLMTypePath'
|
|
43
|
+
* Map file entry in 'typeConversion:vibe2flex:<value>:getSoftType()'
|
|
44
|
+
* for value from 'entityClass' or root from 'typePath'
|
|
45
|
+
* TypeDefaults.getDefaultObjectTypePath() function
|
|
46
|
+
*
|
|
47
|
+
* @param transformMapFile id for mapFile
|
|
48
|
+
* @param mapFileUtil class to get mapfile
|
|
49
|
+
* @param entity VibeIQ entity
|
|
50
|
+
* @returns Promise<string>
|
|
51
|
+
*/
|
|
26
52
|
static async getObjectTypePath(transformMapFile, mapFileUtil, entity) {
|
|
27
53
|
let typePath = entity['flexPLMTypePath'];
|
|
28
54
|
if (typePath) {
|
|
@@ -40,6 +66,18 @@ class TypeConversionUtils {
|
|
|
40
66
|
}
|
|
41
67
|
return type_defaults_1.TypeDefaults.getDefaultObjectTypePath(entity);
|
|
42
68
|
}
|
|
69
|
+
/**Takes in a VibeIQ entity object and returns the correct
|
|
70
|
+
* identifier properties. Order of precedence
|
|
71
|
+
* Property 'flexPLMIdentifierProperties'
|
|
72
|
+
* Map file entry in 'typeConversion:vibe2flex:<value>:getIdentifierProperties()'
|
|
73
|
+
* for value from 'entityClass' or root from 'typePath'
|
|
74
|
+
* TypeDefaults.getDefaultIdentifierProperties() function
|
|
75
|
+
*
|
|
76
|
+
* @param transformMapFile id for mapFile
|
|
77
|
+
* @param mapFileUtil class to get mapfile
|
|
78
|
+
* @param entity
|
|
79
|
+
* @returns Promise<string[]>
|
|
80
|
+
*/
|
|
43
81
|
static async getIdentifierProperties(transformMapFile, mapFileUtil, entity) {
|
|
44
82
|
let identifiers = entity['flexPLMIdentifierProperties'];
|
|
45
83
|
if (identifiers) {
|
|
@@ -57,6 +95,18 @@ class TypeConversionUtils {
|
|
|
57
95
|
}
|
|
58
96
|
return type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(entity);
|
|
59
97
|
}
|
|
98
|
+
/**Takes in a VibeIQ entity object and returns the correct
|
|
99
|
+
* informational properties. Order of precedence
|
|
100
|
+
* Property 'flexPLMInformationalProperties'
|
|
101
|
+
* Map file entry in 'typeConversion:vibe2flex:<value>:getInformationalProperties()'
|
|
102
|
+
* for value from 'entityClass' or root from 'typePath'
|
|
103
|
+
* TypeDefaults.getDefaultObjectTypePath() function
|
|
104
|
+
*
|
|
105
|
+
* @param transformMapFile id for mapFile
|
|
106
|
+
* @param mapFileUtil class to get mapfile
|
|
107
|
+
* @param entity
|
|
108
|
+
* @returns string
|
|
109
|
+
*/
|
|
60
110
|
static async getInformationalProperties(transformMapFile, mapFileUtil, entity) {
|
|
61
111
|
let identifiers = entity['flexPLMInformationalProperties'];
|
|
62
112
|
if (identifiers) {
|
|
@@ -74,6 +124,19 @@ class TypeConversionUtils {
|
|
|
74
124
|
}
|
|
75
125
|
return type_defaults_1.TypeDefaults.getDefaultInformationalProperties(entity);
|
|
76
126
|
}
|
|
127
|
+
/**Takes in a VibeIQ entity object and returns the correct mapKey
|
|
128
|
+
* Order of precedence:
|
|
129
|
+
* Map file entry in 'typeConversion:<direction>:<value>:getObjectClass()'
|
|
130
|
+
* for value from 'entityClass' or root from 'typePath'
|
|
131
|
+
* TypeDefaults.getDefaultObjectClass() function
|
|
132
|
+
*
|
|
133
|
+
* @param transformMapFile
|
|
134
|
+
* @param mapFileUtil
|
|
135
|
+
* @param entity
|
|
136
|
+
* @param type
|
|
137
|
+
* @param direction
|
|
138
|
+
* @returns
|
|
139
|
+
*/
|
|
77
140
|
static async getMapKey(transformMapFile, mapFileUtil, entity, direction) {
|
|
78
141
|
if (transformMapFile) {
|
|
79
142
|
const type = this.getEntityType(entity);
|
|
@@ -85,6 +148,12 @@ class TypeConversionUtils {
|
|
|
85
148
|
}
|
|
86
149
|
return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
|
|
87
150
|
}
|
|
151
|
+
/** Returns the VibeIQ entity type from an entity.
|
|
152
|
+
* Throws error if it can't determine the entity type
|
|
153
|
+
*
|
|
154
|
+
* @param entity
|
|
155
|
+
* @returns string
|
|
156
|
+
*/
|
|
88
157
|
static getEntityType(entity) {
|
|
89
158
|
let entityType = entity['entityType'];
|
|
90
159
|
if (!entityType) {
|
|
@@ -101,6 +170,18 @@ class TypeConversionUtils {
|
|
|
101
170
|
}
|
|
102
171
|
return entityType;
|
|
103
172
|
}
|
|
173
|
+
/** Takes in a FlexPLM object and returns the correct VibeIQ entity
|
|
174
|
+
* class associated to the object. Order of precedence
|
|
175
|
+
* Property 'vibeIQEntityClass'
|
|
176
|
+
* Map file entry in 'typeConversion:flex2vibe:<value>:getObjectClass()'
|
|
177
|
+
* for value from 'objectClass'
|
|
178
|
+
* TypeDefaults.getDefaultEntityClass() function
|
|
179
|
+
*
|
|
180
|
+
* @param fileId id for mapFile
|
|
181
|
+
* @param mapFileUtil class to get mapfile
|
|
182
|
+
* @param object FlexPLM object
|
|
183
|
+
* @returns Promise<string>
|
|
184
|
+
*/
|
|
104
185
|
static async getEntityClassFromObject(fileId, mapFileUtil, object) {
|
|
105
186
|
let entityClass = object['vibeIQEntityClass'];
|
|
106
187
|
if (entityClass) {
|
|
@@ -118,23 +199,22 @@ class TypeConversionUtils {
|
|
|
118
199
|
}
|
|
119
200
|
return type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
120
201
|
}
|
|
121
|
-
static async getUniquenessPoolKeyFromObject(fileId, mapFileUtil, object) {
|
|
122
|
-
let uniquenessPool;
|
|
123
|
-
if (fileId) {
|
|
124
|
-
const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
125
|
-
if (mapKey) {
|
|
126
|
-
const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
|
|
127
|
-
if (mapData && mapData['uniquenessPool']) {
|
|
128
|
-
uniquenessPool = mapData['uniquenessPool'];
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (uniquenessPool) {
|
|
133
|
-
return uniquenessPool;
|
|
134
|
-
}
|
|
135
|
-
return type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
136
|
-
}
|
|
137
202
|
static async getEntityTypePathFromOjbect(fileId, mapFileUtil, object) {
|
|
203
|
+
return await this.getEntityTypePathFromObject(fileId, mapFileUtil, object);
|
|
204
|
+
}
|
|
205
|
+
/** Takes in a FlexPLM object and returns the correct VibeIQ
|
|
206
|
+
* type associated to the object. Order of precedence
|
|
207
|
+
* Property 'vibeIQTypePath'
|
|
208
|
+
* Map file entry in 'typeConversion:flex2vibe:<value>:getSoftType()'
|
|
209
|
+
* for value from 'objectClass' or root from 'flexPLMTypePath'
|
|
210
|
+
* TypeDefaults.getDefaultEntityTypePath() function
|
|
211
|
+
*
|
|
212
|
+
* @param transformMapFile id for mapFile
|
|
213
|
+
* @param mapFileUtil class to get mapfile
|
|
214
|
+
* @param entity VibeIQ entity
|
|
215
|
+
* @returns Promise<string>
|
|
216
|
+
*/
|
|
217
|
+
static async getEntityTypePathFromObject(fileId, mapFileUtil, object) {
|
|
138
218
|
let typePath = object['vibeIQTypePath'];
|
|
139
219
|
if (typePath) {
|
|
140
220
|
return typePath;
|
|
@@ -151,6 +231,18 @@ class TypeConversionUtils {
|
|
|
151
231
|
}
|
|
152
232
|
return type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
153
233
|
}
|
|
234
|
+
/**Takes in a FlexPLM object and returns the correct
|
|
235
|
+
* identifier properties. Order of precedence
|
|
236
|
+
* Property 'vibeIQIdentifierProperties'
|
|
237
|
+
* Map file entry in 'typeConversion:flex2vibe:<value>:getIdentifierProperties()'
|
|
238
|
+
* for value from 'objectClass'
|
|
239
|
+
* TypeDefaults.getDefaultIdentifierPropertiesFromObject() function
|
|
240
|
+
*
|
|
241
|
+
* @param transformMapFile id for mapFile
|
|
242
|
+
* @param mapFileUtil class to get mapfile
|
|
243
|
+
* @param object
|
|
244
|
+
* @returns Promise<string[]>
|
|
245
|
+
*/
|
|
154
246
|
static async getIdentifierPropertiesFromObject(fileId, mapFileUtil, object) {
|
|
155
247
|
let identifiers = object['vibeIQIdentifierProperties'];
|
|
156
248
|
if (identifiers) {
|
|
@@ -168,6 +260,18 @@ class TypeConversionUtils {
|
|
|
168
260
|
}
|
|
169
261
|
return type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
|
|
170
262
|
}
|
|
263
|
+
/**Takes in a FlexPLM object and returns the correct
|
|
264
|
+
* identifier properties. Order of precedence
|
|
265
|
+
* Property 'vibeIQIdentifierProperties'
|
|
266
|
+
* Map file entry in 'typeConversion:flex2vibe:<value>:getInformationalProperties()'
|
|
267
|
+
* for value from 'objectClass'
|
|
268
|
+
* TypeDefaults.getDefaultIdentifierPropertiesFromObject() function
|
|
269
|
+
*
|
|
270
|
+
* @param transformMapFile id for mapFile
|
|
271
|
+
* @param mapFileUtil class to get mapfile
|
|
272
|
+
* @param object
|
|
273
|
+
* @returns Promise<string[]>
|
|
274
|
+
*/
|
|
171
275
|
static async getInformationalPropertiesFromObject(fileId, mapFileUtil, object) {
|
|
172
276
|
let identifiers = object['vibeIQInformationalProperties'];
|
|
173
277
|
if (identifiers) {
|
|
@@ -195,6 +299,7 @@ class TypeConversionUtils {
|
|
|
195
299
|
}
|
|
196
300
|
return type;
|
|
197
301
|
}
|
|
302
|
+
//TODO use TypeDefaults?
|
|
198
303
|
}
|
|
199
304
|
static async isInboundCreatableFromObject(fileId, mapFileUtil, object, context) {
|
|
200
305
|
let isInboundCreatable = false;
|
|
@@ -228,6 +333,17 @@ class TypeConversionUtils {
|
|
|
228
333
|
}
|
|
229
334
|
return isOutboundCreatable;
|
|
230
335
|
}
|
|
336
|
+
/** Takes in a FlexPLM object and determines whether inbound
|
|
337
|
+
* images should be synced. In most cases, the creation owning system
|
|
338
|
+
* will also control image syncing. Defaults to false if no mapping exists.
|
|
339
|
+
* Map file entry in '<mapKey>:syncInboundImages()'
|
|
340
|
+
*
|
|
341
|
+
* @param fileId id for mapFile
|
|
342
|
+
* @param mapFileUtil class to get mapfile
|
|
343
|
+
* @param object FlexPLM object
|
|
344
|
+
* @param context optional context object
|
|
345
|
+
* @returns Promise<boolean>
|
|
346
|
+
*/
|
|
231
347
|
static async syncInboundImages(fileId, mapFileUtil, object, context) {
|
|
232
348
|
let syncImages = false;
|
|
233
349
|
if (!fileId) {
|
|
@@ -249,6 +365,17 @@ class TypeConversionUtils {
|
|
|
249
365
|
}
|
|
250
366
|
return syncImages;
|
|
251
367
|
}
|
|
368
|
+
/** Takes in a VibeIQ entity object and determines whether outbound
|
|
369
|
+
* images should be synced. In most cases, the creation owning system
|
|
370
|
+
* will also control image syncing. Defaults to true if no mapping exists.
|
|
371
|
+
* Map file entry in '<mapKey>:syncOutboundImages()'
|
|
372
|
+
*
|
|
373
|
+
* @param fileId id for mapFile
|
|
374
|
+
* @param mapFileUtil class to get mapfile
|
|
375
|
+
* @param entity VibeIQ entity
|
|
376
|
+
* @param context optional context object
|
|
377
|
+
* @returns Promise<boolean>
|
|
378
|
+
*/
|
|
252
379
|
static async syncOutboundImages(fileId, mapFileUtil, entity, context) {
|
|
253
380
|
let syncImages = true;
|
|
254
381
|
if (!fileId) {
|
|
@@ -328,65 +328,6 @@ describe('conversion-utils', () => {
|
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
});
|
|
331
|
-
describe('getUniquenessPoolKeyFromObject', () => {
|
|
332
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
333
|
-
it('uses mapping-catName', async () => {
|
|
334
|
-
const expectedPool = 'catName-pool';
|
|
335
|
-
const object = {
|
|
336
|
-
flexPLMObjectClass: 'LCSLast',
|
|
337
|
-
flexPLMTypePath: 'Last\\catName'
|
|
338
|
-
};
|
|
339
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
340
|
-
.mockImplementation(async () => {
|
|
341
|
-
return mapping;
|
|
342
|
-
});
|
|
343
|
-
try {
|
|
344
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getUniquenessPoolKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
345
|
-
expect(results).toEqual(expectedPool);
|
|
346
|
-
}
|
|
347
|
-
finally {
|
|
348
|
-
spy.mockRestore();
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
it('uses default-noMap', async () => {
|
|
352
|
-
const expectedClass = 'color';
|
|
353
|
-
const object = {
|
|
354
|
-
flexPLMObjectClass: 'LCSColor',
|
|
355
|
-
flexPLMTypePath: 'Color'
|
|
356
|
-
};
|
|
357
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
358
|
-
.mockImplementation(async () => {
|
|
359
|
-
return mapping;
|
|
360
|
-
});
|
|
361
|
-
const spyDefaults = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityClass')
|
|
362
|
-
.mockImplementation(() => expectedClass);
|
|
363
|
-
try {
|
|
364
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getUniquenessPoolKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
365
|
-
expect(results).toEqual(expectedClass);
|
|
366
|
-
expect(spyDefaults).toBeCalledTimes(1);
|
|
367
|
-
}
|
|
368
|
-
finally {
|
|
369
|
-
spy.mockRestore();
|
|
370
|
-
spyDefaults.mockRestore();
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
it('uses default-noFileId', async () => {
|
|
374
|
-
const expectedClass = 'color';
|
|
375
|
-
const object = {
|
|
376
|
-
flexPLMObjectClass: 'LCSColor',
|
|
377
|
-
};
|
|
378
|
-
const spyDefaults = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityClass')
|
|
379
|
-
.mockImplementation(() => expectedClass);
|
|
380
|
-
try {
|
|
381
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getUniquenessPoolKeyFromObject(null, mapFileUtil, object);
|
|
382
|
-
expect(results).toEqual(expectedClass);
|
|
383
|
-
expect(spyDefaults).toBeCalledTimes(1);
|
|
384
|
-
}
|
|
385
|
-
finally {
|
|
386
|
-
spyDefaults.mockRestore();
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
331
|
describe('getEntityTypePathFromOjbect', () => {
|
|
391
332
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
392
333
|
it('vibeIQTypePath', async () => {
|
|
@@ -3,14 +3,72 @@ export declare class TypeDefaults {
|
|
|
3
3
|
static NO_OBJECT_CLASS: string;
|
|
4
4
|
static NO_TYPE_PATH: string;
|
|
5
5
|
constructor();
|
|
6
|
+
/**Takes in full entity and returs the default FlexPLM
|
|
7
|
+
* object class.
|
|
8
|
+
*
|
|
9
|
+
* @param entity
|
|
10
|
+
* @returns string
|
|
11
|
+
*/
|
|
6
12
|
static getDefaultObjectClass(entity: any): string;
|
|
13
|
+
/**Takes in full entity and returns the default FlexPLM type path
|
|
14
|
+
* object class.
|
|
15
|
+
*
|
|
16
|
+
* @param entity
|
|
17
|
+
* @returns string
|
|
18
|
+
*/
|
|
7
19
|
static getDefaultObjectTypePath(entity: any): string;
|
|
20
|
+
/**Takes in full entity and returns the slugs for the default identifier
|
|
21
|
+
* properties. These properties are used when searching for an entity
|
|
22
|
+
* object class.
|
|
23
|
+
*
|
|
24
|
+
* @param entity
|
|
25
|
+
* @returns string[]
|
|
26
|
+
*/
|
|
8
27
|
static getDefaultIdentifierProperties(entity: any): string[];
|
|
28
|
+
/** Takes in full entity and returns the slugs for informational
|
|
29
|
+
* properties. These properties are helpful when debugging issues
|
|
30
|
+
* where the identifier properties don't find a match.
|
|
31
|
+
*
|
|
32
|
+
* @param entity
|
|
33
|
+
* @returns string[]
|
|
34
|
+
*/
|
|
9
35
|
static getDefaultInformationalProperties(entity: any): string[];
|
|
36
|
+
/** Returns the VibeIQ entity type from an entity.
|
|
37
|
+
* Throws error if it can't determine the entity type
|
|
38
|
+
*
|
|
39
|
+
* @param entity
|
|
40
|
+
* @returns string
|
|
41
|
+
*/
|
|
10
42
|
static getEntityType(entity: any): any;
|
|
43
|
+
/**Takes in full object and returns the default VibeIQ
|
|
44
|
+
* entity class.
|
|
45
|
+
*
|
|
46
|
+
* @param entity
|
|
47
|
+
* @returns string
|
|
48
|
+
*/
|
|
11
49
|
static getDefaultEntityClass(object: any): string;
|
|
50
|
+
/**Takes in full object and returns the default VibeIQ type path
|
|
51
|
+
* object class.
|
|
52
|
+
*
|
|
53
|
+
* @param object
|
|
54
|
+
* @returns string
|
|
55
|
+
*/
|
|
12
56
|
static getDefaultEntityTypePath(object: any): string;
|
|
57
|
+
/**Takes in full entity and returns the slugs for the default identifier
|
|
58
|
+
* properties. These properties are used when searching for an entity
|
|
59
|
+
* object class.
|
|
60
|
+
*
|
|
61
|
+
* @param entity
|
|
62
|
+
* @returns string[]
|
|
63
|
+
*/
|
|
13
64
|
static getDefaultIdentifierPropertiesFromObject(object: any): string[];
|
|
65
|
+
/** Takes in full object and returns the slugs for informational
|
|
66
|
+
* properties. These properties are helpful when debugging issues
|
|
67
|
+
* where the identifier properties don't find a match.
|
|
68
|
+
*
|
|
69
|
+
* @param object
|
|
70
|
+
* @returns string[]
|
|
71
|
+
*/
|
|
14
72
|
static getDefaultInformationalPropertiesFromObject(object: any): string[];
|
|
15
73
|
static getObjectClass(object: any): string;
|
|
16
74
|
}
|
|
@@ -4,6 +4,12 @@ exports.TypeDefaults = void 0;
|
|
|
4
4
|
class TypeDefaults {
|
|
5
5
|
constructor() {
|
|
6
6
|
}
|
|
7
|
+
/**Takes in full entity and returs the default FlexPLM
|
|
8
|
+
* object class.
|
|
9
|
+
*
|
|
10
|
+
* @param entity
|
|
11
|
+
* @returns string
|
|
12
|
+
*/
|
|
7
13
|
static getDefaultObjectClass(entity) {
|
|
8
14
|
const entityType = this.getEntityType(entity);
|
|
9
15
|
let objectClass = '';
|
|
@@ -42,6 +48,12 @@ class TypeDefaults {
|
|
|
42
48
|
}
|
|
43
49
|
return objectClass;
|
|
44
50
|
}
|
|
51
|
+
/**Takes in full entity and returns the default FlexPLM type path
|
|
52
|
+
* object class.
|
|
53
|
+
*
|
|
54
|
+
* @param entity
|
|
55
|
+
* @returns string
|
|
56
|
+
*/
|
|
45
57
|
static getDefaultObjectTypePath(entity) {
|
|
46
58
|
let typePath = '';
|
|
47
59
|
const entityType = this.getEntityType(entity);
|
|
@@ -70,6 +82,13 @@ class TypeDefaults {
|
|
|
70
82
|
}
|
|
71
83
|
return typePath;
|
|
72
84
|
}
|
|
85
|
+
/**Takes in full entity and returns the slugs for the default identifier
|
|
86
|
+
* properties. These properties are used when searching for an entity
|
|
87
|
+
* object class.
|
|
88
|
+
*
|
|
89
|
+
* @param entity
|
|
90
|
+
* @returns string[]
|
|
91
|
+
*/
|
|
73
92
|
static getDefaultIdentifierProperties(entity) {
|
|
74
93
|
const identifierProps = [];
|
|
75
94
|
const entityType = this.getEntityType(entity);
|
|
@@ -95,6 +114,13 @@ class TypeDefaults {
|
|
|
95
114
|
}
|
|
96
115
|
return identifierProps;
|
|
97
116
|
}
|
|
117
|
+
/** Takes in full entity and returns the slugs for informational
|
|
118
|
+
* properties. These properties are helpful when debugging issues
|
|
119
|
+
* where the identifier properties don't find a match.
|
|
120
|
+
*
|
|
121
|
+
* @param entity
|
|
122
|
+
* @returns string[]
|
|
123
|
+
*/
|
|
98
124
|
static getDefaultInformationalProperties(entity) {
|
|
99
125
|
const entityType = this.getEntityType(entity);
|
|
100
126
|
let properties = [];
|
|
@@ -111,6 +137,12 @@ class TypeDefaults {
|
|
|
111
137
|
}
|
|
112
138
|
return properties;
|
|
113
139
|
}
|
|
140
|
+
/** Returns the VibeIQ entity type from an entity.
|
|
141
|
+
* Throws error if it can't determine the entity type
|
|
142
|
+
*
|
|
143
|
+
* @param entity
|
|
144
|
+
* @returns string
|
|
145
|
+
*/
|
|
114
146
|
static getEntityType(entity) {
|
|
115
147
|
let entityType = entity['entityType'];
|
|
116
148
|
if (!entityType) {
|
|
@@ -127,6 +159,12 @@ class TypeDefaults {
|
|
|
127
159
|
}
|
|
128
160
|
return entityType;
|
|
129
161
|
}
|
|
162
|
+
/**Takes in full object and returns the default VibeIQ
|
|
163
|
+
* entity class.
|
|
164
|
+
*
|
|
165
|
+
* @param entity
|
|
166
|
+
* @returns string
|
|
167
|
+
*/
|
|
130
168
|
static getDefaultEntityClass(object) {
|
|
131
169
|
let entityClass = '';
|
|
132
170
|
let objectClass = TypeDefaults.getObjectClass(object);
|
|
@@ -149,6 +187,12 @@ class TypeDefaults {
|
|
|
149
187
|
throw Error(TypeDefaults.NO_OBJECT_CLASS);
|
|
150
188
|
return entityClass;
|
|
151
189
|
}
|
|
190
|
+
/**Takes in full object and returns the default VibeIQ type path
|
|
191
|
+
* object class.
|
|
192
|
+
*
|
|
193
|
+
* @param object
|
|
194
|
+
* @returns string
|
|
195
|
+
*/
|
|
152
196
|
static getDefaultEntityTypePath(object) {
|
|
153
197
|
let typePath = '';
|
|
154
198
|
const objectClass = TypeDefaults.getObjectClass(object);
|
|
@@ -173,6 +217,13 @@ class TypeDefaults {
|
|
|
173
217
|
throw Error(TypeDefaults.NO_TYPE_PATH);
|
|
174
218
|
return typePath;
|
|
175
219
|
}
|
|
220
|
+
/**Takes in full entity and returns the slugs for the default identifier
|
|
221
|
+
* properties. These properties are used when searching for an entity
|
|
222
|
+
* object class.
|
|
223
|
+
*
|
|
224
|
+
* @param entity
|
|
225
|
+
* @returns string[]
|
|
226
|
+
*/
|
|
176
227
|
static getDefaultIdentifierPropertiesFromObject(object) {
|
|
177
228
|
const identifierProps = [];
|
|
178
229
|
const objectClass = TypeDefaults.getObjectClass(object);
|
|
@@ -197,6 +248,13 @@ class TypeDefaults {
|
|
|
197
248
|
}
|
|
198
249
|
return identifierProps;
|
|
199
250
|
}
|
|
251
|
+
/** Takes in full object and returns the slugs for informational
|
|
252
|
+
* properties. These properties are helpful when debugging issues
|
|
253
|
+
* where the identifier properties don't find a match.
|
|
254
|
+
*
|
|
255
|
+
* @param object
|
|
256
|
+
* @returns string[]
|
|
257
|
+
*/
|
|
200
258
|
static getDefaultInformationalPropertiesFromObject(object) {
|
|
201
259
|
const objectClass = TypeDefaults.getObjectClass(object);
|
|
202
260
|
let properties = [];
|
|
@@ -304,7 +304,7 @@ describe('Type Defaults', () => {
|
|
|
304
304
|
expect(() => type_defaults_1.TypeDefaults.getEntityType(entity)).toThrowError();
|
|
305
305
|
expect(() => type_defaults_1.TypeDefaults.getEntityType(entity)).toThrow(type_defaults_1.TypeDefaults.NO_ENTITY_TYPE);
|
|
306
306
|
});
|
|
307
|
-
});
|
|
307
|
+
}); //getEntityType
|
|
308
308
|
describe('getDefaultEntityClass', () => {
|
|
309
309
|
it('item - LCSProduct', () => {
|
|
310
310
|
const object = {
|
|
@@ -369,7 +369,7 @@ describe('Type Defaults', () => {
|
|
|
369
369
|
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
370
370
|
expect(entityClass).toBe('custom-entity');
|
|
371
371
|
});
|
|
372
|
-
});
|
|
372
|
+
}); //getDefaultEntityClass
|
|
373
373
|
describe('getDefaultEntityTypePath', () => {
|
|
374
374
|
it('LCSProduct', () => {
|
|
375
375
|
const object = {
|
|
@@ -420,7 +420,7 @@ describe('Type Defaults', () => {
|
|
|
420
420
|
const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
421
421
|
expect(typePath).toBe('assortment');
|
|
422
422
|
});
|
|
423
|
-
});
|
|
423
|
+
}); //getDefaultEntityTypePath
|
|
424
424
|
describe('getDefaultIdentifierPropertiesFromObject', () => {
|
|
425
425
|
it('LCSProduct', () => {
|
|
426
426
|
const object = {
|
|
@@ -478,7 +478,7 @@ describe('Type Defaults', () => {
|
|
|
478
478
|
expect(defaultIdentifiers).toContain('name');
|
|
479
479
|
expect(defaultIdentifiers).toHaveLength(1);
|
|
480
480
|
});
|
|
481
|
-
});
|
|
481
|
+
}); //getDefaultIdentifierPropertiesFromObject
|
|
482
482
|
describe('getDefaultInformationalPropertiesFromObject', () => {
|
|
483
483
|
it('LCSProduct', () => {
|
|
484
484
|
const object = {
|
|
@@ -512,5 +512,5 @@ describe('Type Defaults', () => {
|
|
|
512
512
|
expect(defaultIdentifiers).toContain('name');
|
|
513
513
|
expect(defaultIdentifiers).toHaveLength(1);
|
|
514
514
|
});
|
|
515
|
-
});
|
|
515
|
+
}); //getDefaultInformationalPropertiesFromObject
|
|
516
516
|
});
|
package/lib/util/type-utils.d.ts
CHANGED
|
@@ -5,9 +5,30 @@ export declare class TypeUtils {
|
|
|
5
5
|
constructor();
|
|
6
6
|
getTypeById(id: any): Promise<import("@contrail/types").Type>;
|
|
7
7
|
getByRootAndPath(options: TypeClientOptions): Promise<import("@contrail/types").Type>;
|
|
8
|
+
/** Deprecated: use TypeConversionUtils.getObjectTypePath() */
|
|
8
9
|
static getFlexPLMTypePath(entity: any): any;
|
|
10
|
+
/** Deprecated: use TypeConversionUtils.getObjectClass()
|
|
11
|
+
*
|
|
12
|
+
* @param entityType
|
|
13
|
+
* @param newData
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
9
16
|
getEventObjectClass(entityType: string, newData: any): string;
|
|
17
|
+
/** Gets the VibeIQ entity type for the object data
|
|
18
|
+
* @param data: object data
|
|
19
|
+
*/
|
|
10
20
|
getEntityTypeClientOptionsUsingMapping(transformMapFile: any, mapFileUtil: any, data: any): Promise<TypeClientOptions>;
|
|
21
|
+
/** Gets the VibeIQ entity type for the object data
|
|
22
|
+
* @param objectClass: string object class
|
|
23
|
+
* @param data: object data
|
|
24
|
+
*/
|
|
11
25
|
getEntityTypeClientOptions(objectClass: string, data: any): TypeClientOptions;
|
|
26
|
+
/** This will filter the properties based the newData entity.
|
|
27
|
+
* It is assumed the type is correct for the entity
|
|
28
|
+
*
|
|
29
|
+
* @param type entire type object
|
|
30
|
+
* @param newData the entity being processed
|
|
31
|
+
* @returns TypeProperty[] of applicable properties
|
|
32
|
+
*/
|
|
12
33
|
filterTypeProperties(type: any, newData: any): TypeProperty[];
|
|
13
34
|
}
|
package/lib/util/type-utils.js
CHANGED
|
@@ -9,6 +9,7 @@ class TypeUtils {
|
|
|
9
9
|
this.typesObj = new sdk_1.Types();
|
|
10
10
|
}
|
|
11
11
|
async getTypeById(id) {
|
|
12
|
+
// this.logger.log('!-getTypeById: ' + id);
|
|
12
13
|
const type = await this.typesObj.getType({
|
|
13
14
|
id,
|
|
14
15
|
relations: ['typeProperties', 'typeInterfaces']
|
|
@@ -19,9 +20,16 @@ class TypeUtils {
|
|
|
19
20
|
const type = await this.typesObj.getByRootAndPath(options);
|
|
20
21
|
return type;
|
|
21
22
|
}
|
|
23
|
+
/** Deprecated: use TypeConversionUtils.getObjectTypePath() */
|
|
22
24
|
static getFlexPLMTypePath(entity) {
|
|
23
25
|
return entity['flexPLMTypePath'] || entity['flexTypePath'] || '';
|
|
24
26
|
}
|
|
27
|
+
/** Deprecated: use TypeConversionUtils.getObjectClass()
|
|
28
|
+
*
|
|
29
|
+
* @param entityType
|
|
30
|
+
* @param newData
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
25
33
|
getEventObjectClass(entityType, newData) {
|
|
26
34
|
let objectClass = '';
|
|
27
35
|
if ('item' === entityType) {
|
|
@@ -48,6 +56,9 @@ class TypeUtils {
|
|
|
48
56
|
}
|
|
49
57
|
return objectClass;
|
|
50
58
|
}
|
|
59
|
+
/** Gets the VibeIQ entity type for the object data
|
|
60
|
+
* @param data: object data
|
|
61
|
+
*/
|
|
51
62
|
async getEntityTypeClientOptionsUsingMapping(transformMapFile, mapFileUtil, data) {
|
|
52
63
|
const root = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(transformMapFile, mapFileUtil, data);
|
|
53
64
|
const path = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(transformMapFile, mapFileUtil, data);
|
|
@@ -57,6 +68,10 @@ class TypeUtils {
|
|
|
57
68
|
};
|
|
58
69
|
return tco;
|
|
59
70
|
}
|
|
71
|
+
/** Gets the VibeIQ entity type for the object data
|
|
72
|
+
* @param objectClass: string object class
|
|
73
|
+
* @param data: object data
|
|
74
|
+
*/
|
|
60
75
|
getEntityTypeClientOptions(objectClass, data) {
|
|
61
76
|
let tco;
|
|
62
77
|
if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
|
|
@@ -75,6 +90,7 @@ class TypeUtils {
|
|
|
75
90
|
};
|
|
76
91
|
}
|
|
77
92
|
else if (['LCSBusinessObject', 'LCSRevisableEntity', 'LCSLast'].includes(objectClass)) {
|
|
93
|
+
//TODO need to write logic using mapping file
|
|
78
94
|
tco = {
|
|
79
95
|
root: 'custom-entity'
|
|
80
96
|
};
|
|
@@ -82,6 +98,13 @@ class TypeUtils {
|
|
|
82
98
|
}
|
|
83
99
|
return tco;
|
|
84
100
|
}
|
|
101
|
+
/** This will filter the properties based the newData entity.
|
|
102
|
+
* It is assumed the type is correct for the entity
|
|
103
|
+
*
|
|
104
|
+
* @param type entire type object
|
|
105
|
+
* @param newData the entity being processed
|
|
106
|
+
* @returns TypeProperty[] of applicable properties
|
|
107
|
+
*/
|
|
85
108
|
filterTypeProperties(type, newData) {
|
|
86
109
|
let filteredProps = type['typeProperties'];
|
|
87
110
|
const typePath = type['typePath'];
|
|
@@ -103,6 +103,7 @@ describe('filterProperties-item', () => {
|
|
|
103
103
|
expect(filteredProps.length).toEqual(len);
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
|
+
//project-item
|
|
106
107
|
describe('filterProperties-project-item', () => {
|
|
107
108
|
const projectItemType = {
|
|
108
109
|
typePath: 'project-item'
|
|
@@ -152,6 +153,7 @@ describe('filterProperties-project-item', () => {
|
|
|
152
153
|
expect(filteredProps.length).toEqual(len);
|
|
153
154
|
});
|
|
154
155
|
});
|
|
156
|
+
//color
|
|
155
157
|
describe('filterProperties-color', () => {
|
|
156
158
|
const colorType = {
|
|
157
159
|
typePath: 'color'
|