@contrail/flexplm 1.1.12 → 1.1.14

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.
Files changed (67) hide show
  1. package/.github/pull_request_template.md +30 -0
  2. package/.github/workflows/flexplm-lib.yml +27 -0
  3. package/lib/flexplm-utils.spec.d.ts +1 -0
  4. package/lib/flexplm-utils.spec.js +26 -0
  5. package/lib/publish/base-process-publish-assortment.js +2 -4
  6. package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -0
  7. package/lib/publish/base-process-publish-assortment.spec.js +1053 -0
  8. package/lib/util/config-defaults.spec.d.ts +1 -0
  9. package/lib/util/config-defaults.spec.js +264 -0
  10. package/lib/util/data-converter.spec.d.ts +1 -0
  11. package/lib/util/data-converter.spec.js +591 -0
  12. package/lib/util/map-utils.d.ts +2 -2
  13. package/lib/util/map-utils.js +5 -28
  14. package/lib/util/map-utils.spec.d.ts +1 -0
  15. package/lib/util/map-utils.spec.js +89 -0
  16. package/lib/util/thumbnail-util.spec.d.ts +1 -0
  17. package/lib/util/thumbnail-util.spec.js +132 -0
  18. package/lib/util/type-conversion-utils-spec-mockData.js +21 -0
  19. package/lib/util/type-conversion-utils.d.ts +7 -0
  20. package/lib/util/type-conversion-utils.js +88 -4
  21. package/lib/util/type-conversion-utils.spec.d.ts +1 -0
  22. package/lib/util/type-conversion-utils.spec.js +547 -0
  23. package/lib/util/type-defaults.d.ts +5 -0
  24. package/lib/util/type-defaults.js +66 -0
  25. package/lib/util/type-defaults.spec.d.ts +1 -0
  26. package/lib/util/type-defaults.spec.js +460 -0
  27. package/lib/util/type-utils.spec.d.ts +1 -0
  28. package/lib/util/type-utils.spec.js +190 -0
  29. package/package.json +2 -2
  30. package/publish.bat +5 -0
  31. package/publish.sh +5 -0
  32. package/src/entity-processor/base-entity-processor.ts +183 -0
  33. package/src/flexplm-request.ts +28 -0
  34. package/src/flexplm-utils.spec.ts +27 -0
  35. package/src/flexplm-utils.ts +29 -0
  36. package/src/index.ts +20 -0
  37. package/src/interfaces/interfaces.ts +120 -0
  38. package/src/interfaces/item-family-changes.ts +67 -0
  39. package/src/interfaces/publish-change-data.ts +43 -0
  40. package/src/publish/base-process-publish-assortment-callback.ts +23 -0
  41. package/src/publish/base-process-publish-assortment.spec.ts +1239 -0
  42. package/src/publish/base-process-publish-assortment.ts +1024 -0
  43. package/src/publish/mockData.ts +4561 -0
  44. package/src/transform/identifier-conversion.ts +226 -0
  45. package/src/util/config-defaults.spec.ts +315 -0
  46. package/src/util/config-defaults.ts +79 -0
  47. package/src/util/data-converter-spec-mockData.ts +231 -0
  48. package/src/util/data-converter.spec.ts +872 -0
  49. package/src/util/data-converter.ts +389 -0
  50. package/src/util/federation.ts +172 -0
  51. package/src/util/flexplm-connect.ts +169 -0
  52. package/src/util/logger-config.ts +20 -0
  53. package/src/util/map-util-spec-mockData.ts +231 -0
  54. package/src/util/map-utils.spec.ts +103 -0
  55. package/src/util/map-utils.ts +40 -0
  56. package/src/util/mockData.ts +98 -0
  57. package/src/util/thumbnail-util.spec.ts +152 -0
  58. package/src/util/thumbnail-util.ts +128 -0
  59. package/src/util/type-conversion-utils-spec-mockData.ts +238 -0
  60. package/src/util/type-conversion-utils.spec.ts +601 -0
  61. package/src/util/type-conversion-utils.ts +345 -0
  62. package/src/util/type-defaults.spec.ts +592 -0
  63. package/src/util/type-defaults.ts +261 -0
  64. package/src/util/type-utils.spec.ts +227 -0
  65. package/src/util/type-utils.ts +124 -0
  66. package/tsconfig.json +27 -0
  67. package/tslint.json +57 -0
@@ -0,0 +1,547 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const transform_data_1 = require("@contrail/transform-data");
4
+ const sdk_1 = require("@contrail/sdk");
5
+ const type_conversion_utils_1 = require("./type-conversion-utils");
6
+ const type_defaults_1 = require("./type-defaults");
7
+ const maps = require('./type-conversion-utils-spec-mockData');
8
+ const mapping = maps['mapping'];
9
+ const TRANSFORM_MAP_FILE = 'test-transformMapping';
10
+ describe('conversion-utils', () => {
11
+ describe('getObjectClass', () => {
12
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
13
+ it('flexPLMObjectClass', async () => {
14
+ const objectClass = 'ObjectClass';
15
+ const entity = {
16
+ flexPLMObjectClass: objectClass
17
+ };
18
+ const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
19
+ expect(results).toEqual(objectClass);
20
+ });
21
+ it('uses mapping-catName', async () => {
22
+ const expectedClass = 'LCSLast';
23
+ const entity = {
24
+ entityType: 'custom-entity',
25
+ typePath: 'custom-entity:catName'
26
+ };
27
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
28
+ .mockImplementation(async () => {
29
+ return mapping;
30
+ });
31
+ try {
32
+ const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
33
+ expect(results).toEqual(expectedClass);
34
+ }
35
+ finally {
36
+ spy.mockRestore();
37
+ }
38
+ });
39
+ it('uses default-noMap', async () => {
40
+ const expectedClass = 'LCSColor';
41
+ const entity = {
42
+ entityType: 'color',
43
+ typePath: 'color:noMap'
44
+ };
45
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
46
+ .mockImplementation(async () => {
47
+ return mapping;
48
+ });
49
+ const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultObjectClass')
50
+ .mockImplementation(() => expectedClass);
51
+ try {
52
+ const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
53
+ expect(results).toEqual(expectedClass);
54
+ expect(spyIdentifiers).toBeCalledTimes(2);
55
+ }
56
+ finally {
57
+ spy.mockRestore();
58
+ spyIdentifiers.mockRestore();
59
+ }
60
+ });
61
+ });
62
+ describe('getObjectTypePath', () => {
63
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
64
+ it('flexPLMTypePath', async () => {
65
+ const typePath = 'Product';
66
+ const entity = {
67
+ flexPLMTypePath: typePath
68
+ };
69
+ const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
70
+ expect(results).toEqual(typePath);
71
+ });
72
+ it('uses mapping-catName', async () => {
73
+ const expectedTypePath = 'Last\\catName';
74
+ const entity = {
75
+ entityType: 'custom-entity',
76
+ typePath: 'custom-entity:catName'
77
+ };
78
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
79
+ .mockImplementation(async () => {
80
+ return mapping;
81
+ });
82
+ try {
83
+ const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
84
+ expect(results).toEqual(expectedTypePath);
85
+ }
86
+ finally {
87
+ spy.mockRestore();
88
+ }
89
+ });
90
+ it('uses default-noMap', async () => {
91
+ const expectedTypePath = 'Color';
92
+ const entity = {
93
+ entityType: 'color',
94
+ typePath: 'color:noMap'
95
+ };
96
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
97
+ .mockImplementation(async () => {
98
+ return mapping;
99
+ });
100
+ const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultObjectTypePath')
101
+ .mockImplementation(() => expectedTypePath);
102
+ try {
103
+ const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
104
+ expect(results).toEqual(expectedTypePath);
105
+ expect(spyIdentifiers).toBeCalledTimes(1);
106
+ }
107
+ finally {
108
+ spy.mockRestore();
109
+ spyIdentifiers.mockRestore();
110
+ }
111
+ });
112
+ });
113
+ describe('getIdentifierProperties', () => {
114
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
115
+ it('flexPLMIdentifierProperties', async () => {
116
+ const properties = ['optionName'];
117
+ const entity = {
118
+ flexPLMIdentifierProperties: properties
119
+ };
120
+ const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
121
+ expect(results).toHaveLength(1);
122
+ expect(results).toEqual(properties);
123
+ });
124
+ it('uses mapping-catName', async () => {
125
+ const properties = ['catName', 'catNumber'];
126
+ const entity = {
127
+ entityType: 'custom-entity',
128
+ typePath: 'custom-entity:catName'
129
+ };
130
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
131
+ .mockImplementation(async () => {
132
+ return mapping;
133
+ });
134
+ try {
135
+ const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
136
+ expect(results).toHaveLength(2);
137
+ expect(results).toEqual(properties);
138
+ }
139
+ finally {
140
+ spy.mockRestore();
141
+ }
142
+ });
143
+ it('uses default-noMap', async () => {
144
+ const properties = ['itemNumber'];
145
+ const entity = {
146
+ entityType: 'item',
147
+ typePath: 'item',
148
+ roles: ['family']
149
+ };
150
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
151
+ .mockImplementation(async () => {
152
+ return mapping;
153
+ });
154
+ const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultIdentifierProperties')
155
+ .mockImplementation(() => properties);
156
+ try {
157
+ const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
158
+ expect(results).toEqual(properties);
159
+ expect(results).toHaveLength(1);
160
+ expect(spyIdentifiers).toBeCalledTimes(1);
161
+ }
162
+ finally {
163
+ spy.mockRestore();
164
+ spyIdentifiers.mockRestore();
165
+ }
166
+ });
167
+ });
168
+ describe('getInformationalProperties', () => {
169
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
170
+ it('flexPLMIdentifierProperties', async () => {
171
+ const properties = ['optionName'];
172
+ const entity = {
173
+ flexPLMInformationalProperties: properties
174
+ };
175
+ const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
176
+ expect(results).toHaveLength(1);
177
+ expect(results).toEqual(properties);
178
+ });
179
+ it('uses mapping-catName', async () => {
180
+ const properties = ['longName'];
181
+ const entity = {
182
+ entityType: 'custom-entity',
183
+ typePath: 'custom-entity:catName'
184
+ };
185
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
186
+ .mockImplementation(async () => {
187
+ return mapping;
188
+ });
189
+ try {
190
+ const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
191
+ expect(results).toHaveLength(1);
192
+ expect(results).toEqual(properties);
193
+ }
194
+ finally {
195
+ spy.mockRestore();
196
+ }
197
+ });
198
+ it('uses default-noMap', async () => {
199
+ const properties = ['optionName', 'description'];
200
+ const entity = {
201
+ entityType: 'item',
202
+ typePath: 'item',
203
+ roles: ['color']
204
+ };
205
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
206
+ .mockImplementation(async () => {
207
+ return mapping;
208
+ });
209
+ const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultInformationalProperties')
210
+ .mockImplementation(() => properties);
211
+ try {
212
+ const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
213
+ expect(results).toEqual(properties);
214
+ expect(results).toHaveLength(2);
215
+ expect(spyIdentifiers).toBeCalledTimes(1);
216
+ }
217
+ finally {
218
+ spy.mockRestore();
219
+ spyIdentifiers.mockRestore();
220
+ }
221
+ });
222
+ });
223
+ describe('getMapKey', () => {
224
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
225
+ it('custom-entity:pack', async () => {
226
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
227
+ .mockImplementation(async () => {
228
+ return mapping;
229
+ });
230
+ const entity = {
231
+ typePath: 'custom-entity:pack',
232
+ entityType: 'custom-entity'
233
+ };
234
+ const expectedMapKey = 'packaging';
235
+ try {
236
+ const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
237
+ expect(results).toEqual(expectedMapKey);
238
+ }
239
+ finally {
240
+ spy.mockRestore();
241
+ }
242
+ });
243
+ it('custom-entity:prefix', async () => {
244
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
245
+ .mockImplementation(async () => {
246
+ return mapping;
247
+ });
248
+ const entity = {
249
+ typePath: 'custom-entity:prefix',
250
+ entityType: 'custom-entity'
251
+ };
252
+ const expectedMapKey = 'prefix';
253
+ try {
254
+ const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
255
+ expect(results).toEqual(expectedMapKey);
256
+ }
257
+ finally {
258
+ spy.mockRestore();
259
+ }
260
+ });
261
+ it('color - no mapping exists', async () => {
262
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
263
+ .mockImplementation(async () => {
264
+ return mapping;
265
+ });
266
+ const entity = {
267
+ typePath: 'color',
268
+ entityType: 'color'
269
+ };
270
+ const expectedMapKey = 'LCSColor';
271
+ try {
272
+ const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
273
+ expect(results).toEqual(expectedMapKey);
274
+ }
275
+ finally {
276
+ spy.mockRestore();
277
+ }
278
+ });
279
+ });
280
+ describe('getEntityClassFromObject', () => {
281
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
282
+ it('vibeIQEntityClass', async () => {
283
+ const objectClass = 'ObjectClass';
284
+ const object = {
285
+ vibeIQEntityClass: objectClass
286
+ };
287
+ const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
288
+ expect(results).toEqual(objectClass);
289
+ });
290
+ it('uses mapping-catName', async () => {
291
+ const expectedClass = 'custom-entity';
292
+ const object = {
293
+ objectClass: 'LCSLast',
294
+ flexPLMTypePath: 'Last\\catName'
295
+ };
296
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
297
+ .mockImplementation(async () => {
298
+ return mapping;
299
+ });
300
+ try {
301
+ const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
302
+ expect(results).toEqual(expectedClass);
303
+ }
304
+ finally {
305
+ spy.mockRestore();
306
+ }
307
+ });
308
+ it('uses default-noMap', async () => {
309
+ const expectedClass = 'color';
310
+ const entity = {
311
+ objectClass: 'LCSColor',
312
+ flexPLMTypePath: 'Color'
313
+ };
314
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
315
+ .mockImplementation(async () => {
316
+ return mapping;
317
+ });
318
+ const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityClass')
319
+ .mockImplementation(() => expectedClass);
320
+ try {
321
+ const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, entity);
322
+ expect(results).toEqual(expectedClass);
323
+ expect(spyIdentifiers).toBeCalledTimes(1);
324
+ }
325
+ finally {
326
+ spy.mockRestore();
327
+ spyIdentifiers.mockRestore();
328
+ }
329
+ });
330
+ });
331
+ describe('getEntityTypePathFromOjbect', () => {
332
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
333
+ it('vibeIQTypePath', async () => {
334
+ const typePath = 'item';
335
+ const entity = {
336
+ vibeIQTypePath: typePath
337
+ };
338
+ const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
339
+ expect(results).toEqual(typePath);
340
+ });
341
+ it('uses mapping-catName', async () => {
342
+ const expectedTypePath = 'custom-entity:catName';
343
+ const entity = {
344
+ objectClass: 'LCSLast',
345
+ flexPLMTypePath: 'Last\\catName'
346
+ };
347
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
348
+ .mockImplementation(async () => {
349
+ return mapping;
350
+ });
351
+ try {
352
+ const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
353
+ expect(results).toEqual(expectedTypePath);
354
+ }
355
+ finally {
356
+ spy.mockRestore();
357
+ }
358
+ });
359
+ it('uses default-noMap', async () => {
360
+ const expectedTypePath = 'color';
361
+ const entity = {
362
+ objectClass: 'LCSColor',
363
+ flexPLMTypePath: 'Color'
364
+ };
365
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
366
+ .mockImplementation(async () => {
367
+ return mapping;
368
+ });
369
+ const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityTypePath')
370
+ .mockImplementation(() => expectedTypePath);
371
+ try {
372
+ const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
373
+ expect(results).toEqual(expectedTypePath);
374
+ expect(spyIdentifiers).toBeCalledTimes(1);
375
+ }
376
+ finally {
377
+ spy.mockRestore();
378
+ spyIdentifiers.mockRestore();
379
+ }
380
+ });
381
+ });
382
+ describe('getIdentifierPropertiesFromObject', () => {
383
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
384
+ it('flexPLMIdentifierProperties', async () => {
385
+ const properties = ['optionName'];
386
+ const object = {
387
+ vibeIQIdentifierProperties: properties
388
+ };
389
+ const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
390
+ expect(results).toHaveLength(1);
391
+ expect(results).toEqual(properties);
392
+ });
393
+ it('uses mapping-catName', async () => {
394
+ const properties = ['catName', 'catNumber'];
395
+ const object = {
396
+ objectClass: 'LCSLast',
397
+ flexPLMTypePath: 'Last\\catName'
398
+ };
399
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
400
+ .mockImplementation(async () => {
401
+ return mapping;
402
+ });
403
+ try {
404
+ const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
405
+ expect(results).toHaveLength(2);
406
+ expect(results).toEqual(properties);
407
+ }
408
+ finally {
409
+ spy.mockRestore();
410
+ }
411
+ });
412
+ it('uses default-noMap', async () => {
413
+ const properties = ['itemNumber'];
414
+ const object = {
415
+ objectClass: 'LCSProduct',
416
+ flexPLMTypePath: 'Product'
417
+ };
418
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
419
+ .mockImplementation(async () => {
420
+ return mapping;
421
+ });
422
+ const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultIdentifierPropertiesFromObject')
423
+ .mockImplementation(() => properties);
424
+ try {
425
+ const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
426
+ expect(results).toEqual(properties);
427
+ expect(results).toHaveLength(1);
428
+ expect(spyIdentifiers).toBeCalledTimes(1);
429
+ }
430
+ finally {
431
+ spy.mockRestore();
432
+ spyIdentifiers.mockRestore();
433
+ }
434
+ });
435
+ });
436
+ describe('getInformationalPropertiesFromObject', () => {
437
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
438
+ it('vibeIQInformationalProperties', async () => {
439
+ const properties = ['optionName'];
440
+ const object = {
441
+ vibeIQInformationalProperties: properties
442
+ };
443
+ const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
444
+ expect(results).toHaveLength(1);
445
+ expect(results).toEqual(properties);
446
+ });
447
+ it('uses mapping-catName', async () => {
448
+ const properties = ['longName'];
449
+ const object = {
450
+ objectClass: 'LCSLast',
451
+ flexPLMTypePath: 'Last\\catName'
452
+ };
453
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
454
+ .mockImplementation(async () => {
455
+ return mapping;
456
+ });
457
+ try {
458
+ const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
459
+ expect(results).toHaveLength(1);
460
+ expect(results).toEqual(properties);
461
+ }
462
+ finally {
463
+ spy.mockRestore();
464
+ }
465
+ });
466
+ it('uses default-noMap', async () => {
467
+ const properties = ['optionName', 'description'];
468
+ const object = {
469
+ objectClass: 'LCSSKU',
470
+ typePath: 'Product'
471
+ };
472
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
473
+ .mockImplementation(async () => {
474
+ return mapping;
475
+ });
476
+ const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultInformationalPropertiesFromObject')
477
+ .mockImplementation(() => properties);
478
+ try {
479
+ const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
480
+ expect(results).toEqual(properties);
481
+ expect(results).toHaveLength(2);
482
+ expect(spyIdentifiers).toBeCalledTimes(1);
483
+ }
484
+ finally {
485
+ spy.mockRestore();
486
+ spyIdentifiers.mockRestore();
487
+ }
488
+ });
489
+ });
490
+ describe('getMapKeyFromObject', () => {
491
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
492
+ it('Revisable Entity\\packaging', async () => {
493
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
494
+ .mockImplementation(async () => {
495
+ return mapping;
496
+ });
497
+ const object = {
498
+ objectClass: 'LCSRevisableEntity',
499
+ flexPLMTypePath: 'Revisable Entity\\packaging'
500
+ };
501
+ const expectedMapKey = 'packaging';
502
+ try {
503
+ const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
504
+ expect(results).toEqual(expectedMapKey);
505
+ }
506
+ finally {
507
+ spy.mockRestore();
508
+ }
509
+ });
510
+ it('Revisable Entity\\prefix', async () => {
511
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
512
+ .mockImplementation(async () => {
513
+ return mapping;
514
+ });
515
+ const object = {
516
+ objectClass: 'LCSRevisableEntity',
517
+ flexPLMTypePath: 'Revisable Entity\\prefix'
518
+ };
519
+ const expectedMapKey = 'prefix';
520
+ try {
521
+ const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
522
+ expect(results).toEqual(expectedMapKey);
523
+ }
524
+ finally {
525
+ spy.mockRestore();
526
+ }
527
+ });
528
+ it('color - no mapping exists', async () => {
529
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
530
+ .mockImplementation(async () => {
531
+ return mapping;
532
+ });
533
+ const object = {
534
+ objectClass: 'LCSColor',
535
+ flexPLMTypePath: 'Color'
536
+ };
537
+ const expectedMapKey = 'LCSColor';
538
+ try {
539
+ const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
540
+ expect(results).toEqual(expectedMapKey);
541
+ }
542
+ finally {
543
+ spy.mockRestore();
544
+ }
545
+ });
546
+ });
547
+ });
@@ -6,4 +6,9 @@ export declare class TypeDefaults {
6
6
  static getDefaultIdentifierProperties(entity: any): string[];
7
7
  static getDefaultInformationalProperties(entity: any): string[];
8
8
  static getEntityType(entity: any): any;
9
+ static getDefaultEntityClass(object: any): string;
10
+ static getDefaultEntityTypePath(object: any): string;
11
+ static getDefaultIdentifierPropertiesFromObject(object: any): string[];
12
+ static getDefaultInformationalPropertiesFromObject(object: any): string[];
13
+ static getObjectClass(object: any): string;
9
14
  }
@@ -127,6 +127,72 @@ class TypeDefaults {
127
127
  }
128
128
  return entityType;
129
129
  }
130
+ static getDefaultEntityClass(object) {
131
+ let entityClass = '';
132
+ let objectClass = TypeDefaults.getObjectClass(object);
133
+ if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
134
+ entityClass = 'item';
135
+ }
136
+ else if ('LCSColor' === objectClass) {
137
+ entityClass = 'color';
138
+ }
139
+ return entityClass;
140
+ }
141
+ static getDefaultEntityTypePath(object) {
142
+ let typePath = '';
143
+ const objectClass = TypeDefaults.getObjectClass(object);
144
+ switch (objectClass) {
145
+ case 'LCSProduct':
146
+ case 'LCSSKU':
147
+ case 'LCSProductSeasonLink':
148
+ case 'LCSSKUSeasonLink':
149
+ typePath = 'item';
150
+ break;
151
+ case 'LCSColor':
152
+ typePath = 'color';
153
+ break;
154
+ }
155
+ return typePath;
156
+ }
157
+ static getDefaultIdentifierPropertiesFromObject(object) {
158
+ const identifierProps = [];
159
+ const objectClass = TypeDefaults.getObjectClass(object);
160
+ switch (objectClass) {
161
+ case 'LCSProduct':
162
+ case 'LCSSKU':
163
+ identifierProps.push('itemNumber');
164
+ break;
165
+ case 'LCSSeason':
166
+ identifierProps.push('flexPLMSeasonName');
167
+ break;
168
+ case 'SeasonGroup':
169
+ identifierProps.push('seasonGroupName');
170
+ break;
171
+ case 'LCSColor':
172
+ case 'LCSRevisableEntity':
173
+ case 'LCSLifecycleManaged':
174
+ identifierProps.push('name');
175
+ break;
176
+ }
177
+ return identifierProps;
178
+ }
179
+ static getDefaultInformationalPropertiesFromObject(object) {
180
+ const objectClass = TypeDefaults.getObjectClass(object);
181
+ let properties = [];
182
+ if ('LCSProduct' === objectClass) {
183
+ properties.push('name');
184
+ }
185
+ else if ('LCSSKU' === objectClass) {
186
+ properties.push('optionName');
187
+ }
188
+ else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
189
+ properties.push('name');
190
+ }
191
+ return properties;
192
+ }
193
+ static getObjectClass(object) {
194
+ return (object) ? object['objectClass'] : '';
195
+ }
130
196
  }
131
197
  exports.TypeDefaults = TypeDefaults;
132
198
  TypeDefaults.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
@@ -0,0 +1 @@
1
+ export {};