@contrail/flexplm 1.3.2-alpha.328325d → 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.
Files changed (111) hide show
  1. package/lib/cli/commands/compile.d.ts +4 -0
  2. package/lib/cli/commands/compile.js +73 -0
  3. package/lib/cli/commands/compile.spec.d.ts +1 -0
  4. package/lib/cli/commands/compile.spec.js +80 -0
  5. package/lib/cli/commands/create.d.ts +5 -0
  6. package/lib/cli/commands/create.js +77 -0
  7. package/lib/cli/commands/create.spec.d.ts +1 -0
  8. package/lib/cli/commands/create.spec.js +78 -0
  9. package/lib/cli/commands/upload.d.ts +17 -0
  10. package/lib/cli/commands/upload.js +228 -0
  11. package/lib/cli/commands/upload.spec.d.ts +1 -0
  12. package/lib/cli/commands/upload.spec.js +88 -0
  13. package/lib/cli/index.d.ts +5 -0
  14. package/lib/cli/index.js +70 -0
  15. package/lib/cli/index.spec.d.ts +1 -0
  16. package/lib/cli/index.spec.js +85 -0
  17. package/lib/cli/template/mapping-template.ts.template +62 -0
  18. package/lib/entity-processor/base-entity-processor.d.ts +47 -5
  19. package/lib/entity-processor/base-entity-processor.js +53 -28
  20. package/lib/entity-processor/base-entity-processor.spec.js +1 -103
  21. package/lib/index.d.ts +1 -0
  22. package/lib/index.js +1 -0
  23. package/lib/interfaces/mapping-file.d.ts +460 -0
  24. package/lib/interfaces/mapping-file.js +2 -0
  25. package/lib/publish/base-process-publish-assortment.d.ts +25 -0
  26. package/lib/publish/base-process-publish-assortment.js +60 -6
  27. package/lib/publish/base-process-publish-assortment.spec.js +22 -4
  28. package/lib/publish/mockData.js +5 -0
  29. package/lib/transform/identifier-conversion-spec-mockData.js +34 -6
  30. package/lib/transform/identifier-conversion.d.ts +36 -0
  31. package/lib/transform/identifier-conversion.js +36 -0
  32. package/lib/transform/identifier-conversion.spec.js +4 -0
  33. package/lib/util/config-defaults.js +3 -0
  34. package/lib/util/config-defaults.spec.js +9 -0
  35. package/lib/util/data-converter-spec-mockData.js +17 -3
  36. package/lib/util/data-converter.d.ts +97 -0
  37. package/lib/util/data-converter.js +133 -1
  38. package/lib/util/data-converter.spec.js +68 -0
  39. package/lib/util/error-response-object.d.ts +5 -0
  40. package/lib/util/error-response-object.js +7 -0
  41. package/lib/util/event-short-message-status.js +1 -0
  42. package/lib/util/federation.js +8 -0
  43. package/lib/util/flexplm-connect.d.ts +7 -0
  44. package/lib/util/flexplm-connect.js +14 -0
  45. package/lib/util/logger-config.js +1 -0
  46. package/lib/util/map-util-spec-mockData.js +17 -3
  47. package/lib/util/map-utils.d.ts +27 -0
  48. package/lib/util/map-utils.js +27 -0
  49. package/lib/util/thumbnail-util.d.ts +21 -0
  50. package/lib/util/thumbnail-util.js +28 -1
  51. package/lib/util/thumbnail-util.spec.js +6 -0
  52. package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
  53. package/lib/util/type-conversion-utils.d.ts +140 -0
  54. package/lib/util/type-conversion-utils.js +143 -0
  55. package/lib/util/type-defaults.d.ts +58 -0
  56. package/lib/util/type-defaults.js +58 -0
  57. package/lib/util/type-defaults.spec.js +5 -5
  58. package/lib/util/type-utils.d.ts +21 -0
  59. package/lib/util/type-utils.js +23 -0
  60. package/lib/util/type-utils.spec.js +2 -0
  61. package/package.json +21 -6
  62. package/scripts/copy-template.js +10 -0
  63. package/.github/pull_request_template.md +0 -31
  64. package/.github/workflows/flexplm-lib.yml +0 -27
  65. package/.github/workflows/publish-to-npm.yml +0 -121
  66. package/CHANGELOG.md +0 -35
  67. package/publish.bat +0 -5
  68. package/publish.sh +0 -5
  69. package/src/entity-processor/base-entity-processor.spec.ts +0 -582
  70. package/src/entity-processor/base-entity-processor.ts +0 -565
  71. package/src/flexplm-request.ts +0 -28
  72. package/src/flexplm-utils.spec.ts +0 -27
  73. package/src/flexplm-utils.ts +0 -29
  74. package/src/index.ts +0 -22
  75. package/src/interfaces/interfaces.ts +0 -122
  76. package/src/interfaces/item-family-changes.ts +0 -67
  77. package/src/interfaces/publish-change-data.ts +0 -43
  78. package/src/publish/base-process-publish-assortment-callback.ts +0 -50
  79. package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
  80. package/src/publish/base-process-publish-assortment.ts +0 -1134
  81. package/src/publish/mockData.ts +0 -4561
  82. package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
  83. package/src/transform/identifier-conversion.spec.ts +0 -354
  84. package/src/transform/identifier-conversion.ts +0 -282
  85. package/src/util/config-defaults.spec.ts +0 -350
  86. package/src/util/config-defaults.ts +0 -93
  87. package/src/util/data-converter-spec-mockData.ts +0 -231
  88. package/src/util/data-converter.spec.ts +0 -1041
  89. package/src/util/data-converter.ts +0 -762
  90. package/src/util/error-response-object.spec.ts +0 -116
  91. package/src/util/error-response-object.ts +0 -50
  92. package/src/util/event-short-message-status.ts +0 -22
  93. package/src/util/federation.ts +0 -172
  94. package/src/util/flexplm-connect.spec.ts +0 -132
  95. package/src/util/flexplm-connect.ts +0 -208
  96. package/src/util/logger-config.ts +0 -20
  97. package/src/util/map-util-spec-mockData.ts +0 -231
  98. package/src/util/map-utils.spec.ts +0 -103
  99. package/src/util/map-utils.ts +0 -41
  100. package/src/util/mockData.ts +0 -101
  101. package/src/util/thumbnail-util.spec.ts +0 -508
  102. package/src/util/thumbnail-util.ts +0 -272
  103. package/src/util/type-conversion-utils-spec-mockData.ts +0 -271
  104. package/src/util/type-conversion-utils.spec.ts +0 -968
  105. package/src/util/type-conversion-utils.ts +0 -460
  106. package/src/util/type-defaults.spec.ts +0 -669
  107. package/src/util/type-defaults.ts +0 -281
  108. package/src/util/type-utils.spec.ts +0 -227
  109. package/src/util/type-utils.ts +0 -144
  110. package/tsconfig.json +0 -24
  111. package/tslint.json +0 -57
@@ -1,968 +0,0 @@
1
- import { MapFileUtil } from '@contrail/transform-data';
2
- import { Entities } from '@contrail/sdk';
3
- import { TypeConversionUtils } from './type-conversion-utils';
4
- import { TypeDefaults } from './type-defaults';
5
-
6
- const maps = require('./type-conversion-utils-spec-mockData');
7
- const mapping = maps['mapping'];
8
-
9
- const TRANSFORM_MAP_FILE = 'test-transformMapping';
10
- describe('conversion-utils', () => {
11
- describe('getObjectClass', () => {
12
- const mapFileUtil = new MapFileUtil(new Entities());
13
-
14
- it('flexPLMObjectClass', async () => {
15
- const objectClass = 'ObjectClass';
16
- const entity = {
17
- flexPLMObjectClass: objectClass
18
- };
19
-
20
- const results = await TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
21
- expect(results).toEqual(objectClass);
22
- });
23
-
24
- it('uses mapping-catName', async () =>{
25
- const expectedClass = 'LCSLast';
26
- const entity = {
27
- entityType: 'custom-entity',
28
- typePath: 'custom-entity:catName'
29
- };
30
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
31
- .mockImplementation(async () =>{
32
- return mapping;
33
- });
34
- try{
35
- const results = await TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
36
- expect(results).toEqual(expectedClass);
37
-
38
- } finally {
39
- spy.mockRestore();
40
- }
41
- });
42
-
43
- it('uses default-noMap', async () =>{
44
- const expectedClass = 'LCSColor';
45
- const entity = {
46
- entityType: 'color',
47
- typePath: 'color:noMap'
48
- };
49
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
50
- .mockImplementation(async () =>{
51
- return mapping;
52
- });
53
- const spyIdentifiers = jest.spyOn(TypeDefaults, 'getDefaultObjectClass')
54
- .mockImplementation(() => expectedClass);
55
- try{
56
- const results = await TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
57
- expect(results).toEqual(expectedClass);
58
- expect(spyIdentifiers).toBeCalledTimes(2);
59
-
60
- } finally {
61
- spy.mockRestore();
62
- spyIdentifiers.mockRestore();
63
- }
64
- });
65
- });
66
-
67
- describe('getObjectTypePath', () =>{
68
- const mapFileUtil = new MapFileUtil(new Entities());
69
-
70
- it('flexPLMTypePath', async () => {
71
- const typePath = 'Product';
72
- const entity = {
73
- flexPLMTypePath: typePath
74
- };
75
-
76
- const results = await TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
77
- expect(results).toEqual(typePath);
78
- });
79
-
80
- it('uses mapping-catName', async () =>{
81
- const expectedTypePath = 'Last\\catName';
82
- const entity = {
83
- entityType: 'custom-entity',
84
- typePath: 'custom-entity:catName'
85
- };
86
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
87
- .mockImplementation(async () =>{
88
- return mapping;
89
- });
90
- try{
91
- const results = await TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
92
- expect(results).toEqual(expectedTypePath);
93
-
94
- } finally {
95
- spy.mockRestore();
96
- }
97
- });
98
-
99
- it('uses default-noMap', async () =>{
100
- const expectedTypePath = 'Color';
101
- const entity = {
102
- entityType: 'color',
103
- typePath: 'color:noMap'
104
- };
105
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
106
- .mockImplementation(async () =>{
107
- return mapping;
108
- });
109
- const spyIdentifiers = jest.spyOn(TypeDefaults, 'getDefaultObjectTypePath')
110
- .mockImplementation(() => expectedTypePath);
111
- try{
112
- const results = await TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
113
- expect(results).toEqual(expectedTypePath);
114
- expect(spyIdentifiers).toBeCalledTimes(1);
115
-
116
- } finally {
117
- spy.mockRestore();
118
- spyIdentifiers.mockRestore();
119
- }
120
- });
121
- });
122
-
123
- describe('getIdentifierProperties', () =>{
124
- const mapFileUtil = new MapFileUtil(new Entities());
125
-
126
- it('flexPLMIdentifierProperties', async () => {
127
- const properties = ['optionName'];
128
- const entity = {
129
- flexPLMIdentifierProperties: properties
130
- };
131
-
132
- const results = await TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
133
- expect(results).toHaveLength(1);
134
- expect(results).toEqual(properties);
135
- });
136
-
137
- it('uses mapping-catName', async () =>{
138
- const properties = ['catName', 'catNumber'];
139
- const entity = {
140
- entityType: 'custom-entity',
141
- typePath: 'custom-entity:catName'
142
- };
143
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
144
- .mockImplementation(async () =>{
145
- return mapping;
146
- });
147
- try{
148
- const results = await TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
149
- expect(results).toHaveLength(2);
150
- expect(results).toEqual(properties);
151
-
152
- } finally {
153
- spy.mockRestore();
154
- }
155
- });
156
-
157
- it('uses default-noMap', async () =>{
158
- const properties = ['itemNumber'];
159
- const entity = {
160
- entityType: 'item',
161
- typePath: 'item',
162
- roles: ['family']
163
- };
164
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
165
- .mockImplementation(async () =>{
166
- return mapping;
167
- });
168
- const spyIdentifiers = jest.spyOn(TypeDefaults, 'getDefaultIdentifierProperties')
169
- .mockImplementation(() => properties);
170
- try{
171
- const results = await TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
172
- expect(results).toEqual(properties);
173
- expect(results).toHaveLength(1);
174
- expect(spyIdentifiers).toBeCalledTimes(1);
175
-
176
- } finally {
177
- spy.mockRestore();
178
- spyIdentifiers.mockRestore();
179
- }
180
- });
181
- });
182
-
183
- describe('getInformationalProperties', () =>{
184
- const mapFileUtil = new MapFileUtil(new Entities());
185
-
186
- it('flexPLMIdentifierProperties', async () => {
187
- const properties = ['optionName'];
188
- const entity = {
189
- flexPLMInformationalProperties: properties
190
- };
191
-
192
- const results = await TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
193
- expect(results).toHaveLength(1);
194
- expect(results).toEqual(properties);
195
- });
196
-
197
- it('uses mapping-catName', async () =>{
198
- const properties = ['longName'];
199
- const entity = {
200
- entityType: 'custom-entity',
201
- typePath: 'custom-entity:catName'
202
- };
203
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
204
- .mockImplementation(async () =>{
205
- return mapping;
206
- });
207
- try{
208
- const results = await TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
209
- expect(results).toHaveLength(1);
210
- expect(results).toEqual(properties);
211
-
212
- } finally {
213
- spy.mockRestore();
214
- }
215
- });
216
-
217
- it('uses default-noMap', async () =>{
218
- const properties = ['optionName', 'description'];
219
- const entity = {
220
- entityType: 'item',
221
- typePath: 'item',
222
- roles: ['color']
223
- };
224
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
225
- .mockImplementation(async () =>{
226
- return mapping;
227
- });
228
- const spyIdentifiers = jest.spyOn(TypeDefaults, 'getDefaultInformationalProperties')
229
- .mockImplementation(() => properties);
230
- try{
231
- const results = await TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
232
- expect(results).toEqual(properties);
233
- expect(results).toHaveLength(2);
234
- expect(spyIdentifiers).toBeCalledTimes(1);
235
-
236
- } finally {
237
- spy.mockRestore();
238
- spyIdentifiers.mockRestore();
239
- }
240
- });
241
- });
242
-
243
- describe('getMapKey', () =>{
244
- const mapFileUtil = new MapFileUtil(new Entities());
245
-
246
- it('custom-entity:pack', async () =>{
247
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
248
- .mockImplementation(async () =>{
249
- return mapping;
250
- });
251
- const entity = {
252
- typePath: 'custom-entity:pack',
253
- entityType: 'custom-entity'
254
- }
255
- const expectedMapKey = 'packaging';
256
-
257
- try{
258
- const results = await TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
259
- expect(results).toEqual(expectedMapKey);
260
-
261
- } finally {
262
- spy.mockRestore();
263
- }
264
- });
265
-
266
- it('custom-entity:prefix', async () =>{
267
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
268
- .mockImplementation(async () =>{
269
- return mapping;
270
- });
271
- const entity = {
272
- typePath: 'custom-entity:prefix',
273
- entityType: 'custom-entity'
274
- }
275
- const expectedMapKey = 'prefix';
276
-
277
- try{
278
- const results = await TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
279
- expect(results).toEqual(expectedMapKey);
280
-
281
- } finally {
282
- spy.mockRestore();
283
- }
284
- });
285
-
286
- it('color - no mapping exists', async () =>{
287
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
288
- .mockImplementation(async () =>{
289
- return mapping;
290
- });
291
- const entity = {
292
- typePath: 'color',
293
- entityType: 'color'
294
- }
295
- const expectedMapKey = 'LCSColor';
296
-
297
- try{
298
- const results = await TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
299
- expect(results).toEqual(expectedMapKey);
300
-
301
- } finally {
302
- spy.mockRestore();
303
- }
304
- });
305
- });
306
-
307
- describe('getEntityClassFromObject', () => {
308
- const mapFileUtil = new MapFileUtil(new Entities());
309
-
310
- it('vibeIQEntityClass', async () => {
311
- const objectClass = 'ObjectClass';
312
- const object = {
313
- vibeIQEntityClass: objectClass
314
- };
315
-
316
- const results = await TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
317
- expect(results).toEqual(objectClass);
318
- });
319
-
320
- it('uses mapping-catName', async () =>{
321
- const expectedClass = 'custom-entity';
322
- const object = {
323
- flexPLMObjectClass: 'LCSLast',
324
- flexPLMTypePath: 'Last\\catName'
325
- };
326
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
327
- .mockImplementation(async () =>{
328
- return mapping;
329
- });
330
- try{
331
- const results = await TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
332
- expect(results).toEqual(expectedClass);
333
-
334
- } finally {
335
- spy.mockRestore();
336
- }
337
- });
338
-
339
- it('uses default-noMap', async () =>{
340
- const expectedClass = 'color';
341
- const entity = {
342
- flexPLMObjectClass: 'LCSColor',
343
- flexPLMTypePath: 'Color'
344
- };
345
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
346
- .mockImplementation(async () =>{
347
- return mapping;
348
- });
349
- const spyIdentifiers = jest.spyOn(TypeDefaults, 'getDefaultEntityClass')
350
- .mockImplementation(() => expectedClass);
351
- try{
352
- const results = await TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, entity);
353
- expect(results).toEqual(expectedClass);
354
- expect(spyIdentifiers).toBeCalledTimes(1);
355
-
356
- } finally {
357
- spy.mockRestore();
358
- spyIdentifiers.mockRestore();
359
- }
360
- });
361
- });
362
-
363
- describe('getEntityTypePathFromOjbect', () =>{
364
- const mapFileUtil = new MapFileUtil(new Entities());
365
-
366
- it('vibeIQTypePath', async () => {
367
- const typePath = 'item';
368
- const entity = {
369
- vibeIQTypePath: typePath
370
- };
371
-
372
- const results = await TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
373
- expect(results).toEqual(typePath);
374
- });
375
-
376
- it('uses mapping-catName', async () =>{
377
- const expectedTypePath = 'custom-entity:catName';
378
- const entity = {
379
- flexPLMObjectClass: 'LCSLast',
380
- flexPLMTypePath: 'Last\\catName'
381
- };
382
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
383
- .mockImplementation(async () =>{
384
- return mapping;
385
- });
386
- try{
387
- const results = await TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
388
- expect(results).toEqual(expectedTypePath);
389
-
390
- } finally {
391
- spy.mockRestore();
392
- }
393
- });
394
-
395
- it('uses default-noMap', async () =>{
396
- const expectedTypePath = 'color';
397
- const entity = {
398
- flexPLMObjectClass: 'LCSColor',
399
- flexPLMTypePath: 'Color'
400
- };
401
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
402
- .mockImplementation(async () =>{
403
- return mapping;
404
- });
405
- const spyIdentifiers = jest.spyOn(TypeDefaults, 'getDefaultEntityTypePath')
406
- .mockImplementation(() => expectedTypePath);
407
- try{
408
- const results = await TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
409
- expect(results).toEqual(expectedTypePath);
410
- expect(spyIdentifiers).toBeCalledTimes(1);
411
-
412
- } finally {
413
- spy.mockRestore();
414
- spyIdentifiers.mockRestore();
415
- }
416
- });
417
- });
418
-
419
- describe('getIdentifierPropertiesFromObject', () =>{
420
- const mapFileUtil = new MapFileUtil(new Entities());
421
-
422
- it('flexPLMIdentifierProperties', async () => {
423
- const properties = ['optionName'];
424
- const object = {
425
- vibeIQIdentifierProperties: properties
426
- };
427
-
428
- const results = await TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
429
- expect(results).toHaveLength(1);
430
- expect(results).toEqual(properties);
431
- });
432
-
433
- it('uses mapping-catName', async () =>{
434
- const properties = ['catName', 'catNumber'];
435
- const object = {
436
- flexPLMObjectClass: 'LCSLast',
437
- flexPLMTypePath: 'Last\\catName'
438
- };
439
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
440
- .mockImplementation(async () =>{
441
- return mapping;
442
- });
443
- try{
444
- const results = await TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
445
- expect(results).toHaveLength(2);
446
- expect(results).toEqual(properties);
447
-
448
- } finally {
449
- spy.mockRestore();
450
- }
451
- });
452
-
453
- it('uses default-noMap', async () =>{
454
- const properties = ['itemNumber'];
455
- const object = {
456
- flexPLMObjectClass: 'LCSProduct',
457
- flexPLMTypePath: 'Product'
458
- };
459
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
460
- .mockImplementation(async () =>{
461
- return mapping;
462
- });
463
- const spyIdentifiers = jest.spyOn(TypeDefaults, 'getDefaultIdentifierPropertiesFromObject')
464
- .mockImplementation(() => properties);
465
- try{
466
- const results = await TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
467
- expect(results).toEqual(properties);
468
- expect(results).toHaveLength(1);
469
- expect(spyIdentifiers).toBeCalledTimes(1);
470
-
471
- } finally {
472
- spy.mockRestore();
473
- spyIdentifiers.mockRestore();
474
- }
475
- });
476
- });
477
-
478
- describe('getInformationalPropertiesFromObject', () =>{
479
- const mapFileUtil = new MapFileUtil(new Entities());
480
-
481
- it('vibeIQInformationalProperties', async () => {
482
- const properties = ['optionName'];
483
- const object = {
484
- vibeIQInformationalProperties: properties
485
- };
486
-
487
- const results = await TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
488
- expect(results).toHaveLength(1);
489
- expect(results).toEqual(properties);
490
- });
491
-
492
- it('uses mapping-catName', async () =>{
493
- const properties = ['longName'];
494
- const object = {
495
- flexPLMObjectClass: 'LCSLast',
496
- flexPLMTypePath: 'Last\\catName'
497
- };
498
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
499
- .mockImplementation(async () =>{
500
- return mapping;
501
- });
502
- try{
503
- const results = await TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
504
- expect(results).toHaveLength(1);
505
- expect(results).toEqual(properties);
506
-
507
- } finally {
508
- spy.mockRestore();
509
- }
510
- });
511
-
512
- it('uses default-noMap', async () =>{
513
- const properties = ['optionName', 'description'];
514
- const object = {
515
- flexPLMObjectClass: 'LCSSKU',
516
- typePath: 'Product'
517
- };
518
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
519
- .mockImplementation(async () =>{
520
- return mapping;
521
- });
522
- const spyIdentifiers = jest.spyOn(TypeDefaults, 'getDefaultInformationalPropertiesFromObject')
523
- .mockImplementation(() => properties);
524
- try{
525
- const results = await TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
526
- expect(results).toEqual(properties);
527
- expect(results).toHaveLength(2);
528
- expect(spyIdentifiers).toBeCalledTimes(1);
529
-
530
- } finally {
531
- spy.mockRestore();
532
- spyIdentifiers.mockRestore();
533
- }
534
- });
535
- });
536
-
537
- describe('getMapKeyFromObject', () =>{
538
- const mapFileUtil = new MapFileUtil(new Entities());
539
-
540
- it('Revisable Entity\\packaging', async () =>{
541
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
542
- .mockImplementation(async () =>{
543
- return mapping;
544
- });
545
- const object = {
546
- flexPLMObjectClass: 'LCSRevisableEntity',
547
- flexPLMTypePath: 'Revisable Entity\\packaging'
548
- }
549
- const expectedMapKey = 'packaging';
550
-
551
- try{
552
- const results = await TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
553
- expect(results).toEqual(expectedMapKey);
554
-
555
- } finally {
556
- spy.mockRestore();
557
- }
558
- });
559
-
560
- it('Revisable Entity\\prefix', async () =>{
561
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
562
- .mockImplementation(async () =>{
563
- return mapping;
564
- });
565
- const object = {
566
- flexPLMObjectClass: 'LCSRevisableEntity',
567
- flexPLMTypePath: 'Revisable Entity\\prefix'
568
- }
569
- const expectedMapKey = 'prefix';
570
-
571
- try{
572
- const results = await TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
573
- expect(results).toEqual(expectedMapKey);
574
-
575
- } finally {
576
- spy.mockRestore();
577
- }
578
- });
579
-
580
- it('color - no mapping exists', async () =>{
581
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
582
- .mockImplementation(async () =>{
583
- return mapping;
584
- });
585
- const object = {
586
- flexPLMObjectClass: 'LCSColor',
587
- flexPLMTypePath: 'Color'
588
- }
589
- const expectedMapKey = 'LCSColor';
590
-
591
- try{
592
- const results = await TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
593
- expect(results).toEqual(expectedMapKey);
594
-
595
- } finally {
596
- spy.mockRestore();
597
- }
598
- });
599
- });
600
-
601
-
602
- describe('isInboundCreatableFromObject', () =>{
603
- const mapFileUtil = new MapFileUtil(new Entities());
604
-
605
- it('Revisable Entity\\packaging', async () =>{
606
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
607
- .mockImplementation(async () =>{
608
- return mapping;
609
- });
610
- const object = {
611
- flexPLMObjectClass: 'LCSRevisableEntity',
612
- flexPLMTypePath: 'Revisable Entity\\packaging'
613
- }
614
-
615
- try{
616
- const results = await TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
617
- expect(results).toBeFalsy();
618
-
619
- } finally {
620
- spy.mockRestore();
621
- }
622
- });
623
-
624
- it('Revisable Entity\\prefix', async () =>{
625
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
626
- .mockImplementation(async () =>{
627
- return mapping;
628
- });
629
- const object = {
630
- flexPLMObjectClass: 'LCSRevisableEntity',
631
- flexPLMTypePath: 'Revisable Entity\\prefix'
632
- }
633
-
634
- try{
635
- const results = await TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
636
- expect(results).toBeTruthy();
637
-
638
- } finally {
639
- spy.mockRestore();
640
- }
641
- });
642
-
643
- it('should pass context to isInboundCreatable function', async () =>{
644
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
645
- .mockImplementation(async () =>{
646
- return mapping;
647
- });
648
- const object = {
649
- flexPLMObjectClass: 'LCSRevisableEntity',
650
- flexPLMTypePath: 'Revisable Entity\\prefix'
651
- }
652
- const context = { skipPrefix: true };
653
-
654
- try{
655
- const results = await TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, context);
656
- expect(results).toBeFalsy();
657
-
658
- } finally {
659
- spy.mockRestore();
660
- }
661
- });
662
-
663
- it('should work without context parameter', async () =>{
664
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
665
- .mockImplementation(async () =>{
666
- return mapping;
667
- });
668
- const object = {
669
- flexPLMObjectClass: 'LCSRevisableEntity',
670
- flexPLMTypePath: 'Revisable Entity\\prefix'
671
- }
672
-
673
- try{
674
- const results = await TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
675
- expect(results).toBeTruthy();
676
-
677
- } finally {
678
- spy.mockRestore();
679
- }
680
- });
681
-
682
- });
683
-
684
- describe('isOutboundCreatableFromEntity', () =>{
685
- const mapFileUtil = new MapFileUtil(new Entities());
686
-
687
- it('should return false for custom-entity:pack', async () =>{
688
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
689
- .mockImplementation(async () =>{
690
- return mapping;
691
- });
692
- const entity = {
693
- entityType: 'custom-entity',
694
- typePath: 'custom-entity:pack'
695
- }
696
-
697
- try{
698
- const results = await TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
699
- expect(results).toBeFalsy();
700
-
701
- } finally {
702
- spy.mockRestore();
703
- }
704
- });
705
-
706
- it('should return true for custom-entity:prefix', async () =>{
707
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
708
- .mockImplementation(async () =>{
709
- return mapping;
710
- });
711
- const entity = {
712
- entityType: 'custom-entity',
713
- typePath: 'custom-entity:prefix'
714
- }
715
-
716
- try{
717
- const results = await TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
718
- expect(results).toBeTruthy();
719
-
720
- } finally {
721
- spy.mockRestore();
722
- }
723
- });
724
-
725
- it('should pass context to isOutboundCreatable function', async () =>{
726
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
727
- .mockImplementation(async () =>{
728
- return mapping;
729
- });
730
- const entity = {
731
- entityType: 'custom-entity',
732
- typePath: 'custom-entity:prefix'
733
- }
734
- const context = { skipPrefix: true };
735
-
736
- try{
737
- const results = await TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity, context);
738
- expect(results).toBeFalsy();
739
-
740
- } finally {
741
- spy.mockRestore();
742
- }
743
- });
744
-
745
- it('should work without context parameter', async () =>{
746
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
747
- .mockImplementation(async () =>{
748
- return mapping;
749
- });
750
- const entity = {
751
- entityType: 'custom-entity',
752
- typePath: 'custom-entity:prefix'
753
- }
754
-
755
- try{
756
- const results = await TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
757
- expect(results).toBeTruthy();
758
-
759
- } finally {
760
- spy.mockRestore();
761
- }
762
- });
763
-
764
- it('should default to true when no mapping exists', async () =>{
765
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
766
- .mockImplementation(async () =>{
767
- return mapping;
768
- });
769
- const entity = {
770
- entityType: 'custom-entity',
771
- typePath: 'custom-entity:catName'
772
- }
773
-
774
- try{
775
- const results = await TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
776
- expect(results).toBeTruthy();
777
-
778
- } finally {
779
- spy.mockRestore();
780
- }
781
- });
782
-
783
- });
784
-
785
- describe('syncInboundImages', () =>{
786
- const mapFileUtil = new MapFileUtil(new Entities());
787
-
788
- it('should return true for Revisable Entity\\packaging (mapping entry true)', async () =>{
789
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
790
- .mockImplementation(async () =>{
791
- return mapping;
792
- });
793
- const obj = {
794
- flexPLMObjectClass: 'LCSRevisableEntity',
795
- flexPLMTypePath: 'Revisable Entity\\packaging'
796
- }
797
-
798
- try{
799
- const results = await TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
800
- expect(results).toBeTruthy();
801
-
802
- } finally {
803
- spy.mockRestore();
804
- }
805
- });
806
-
807
- it('should return true for Revisable Entity\\prefix (mapping entry true)', async () =>{
808
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
809
- .mockImplementation(async () =>{
810
- return mapping;
811
- });
812
- const obj = {
813
- flexPLMObjectClass: 'LCSRevisableEntity',
814
- flexPLMTypePath: 'Revisable Entity\\prefix'
815
- }
816
-
817
- try{
818
- const results = await TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
819
- expect(results).toBeTruthy();
820
-
821
- } finally {
822
- spy.mockRestore();
823
- }
824
- });
825
-
826
- it('should pass context to syncInboundImages function', async () =>{
827
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
828
- .mockImplementation(async () =>{
829
- return mapping;
830
- });
831
- const obj = {
832
- flexPLMObjectClass: 'LCSRevisableEntity',
833
- flexPLMTypePath: 'Revisable Entity\\prefix'
834
- }
835
- const context = { skipImages: true };
836
-
837
- try{
838
- const results = await TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj, context);
839
- expect(results).toBeFalsy();
840
-
841
- } finally {
842
- spy.mockRestore();
843
- }
844
- });
845
-
846
- it('should default to false when no mapping exists', async () =>{
847
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
848
- .mockImplementation(async () =>{
849
- return mapping;
850
- });
851
- const obj = {
852
- flexPLMObjectClass: 'LCSRevisableEntity',
853
- flexPLMTypePath: 'Revisable Entity\\catName'
854
- }
855
-
856
- try{
857
- const results = await TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
858
- expect(results).toBeFalsy();
859
-
860
- } finally {
861
- spy.mockRestore();
862
- }
863
- });
864
-
865
- it('should default to false when no fileId', async () =>{
866
- const obj = {
867
- flexPLMObjectClass: 'LCSRevisableEntity',
868
- flexPLMTypePath: 'Revisable Entity\\pack'
869
- }
870
-
871
- const results = await TypeConversionUtils.syncInboundImages('', mapFileUtil, obj);
872
- expect(results).toBeFalsy();
873
- });
874
-
875
- });
876
-
877
- describe('syncOutboundImages', () =>{
878
- const mapFileUtil = new MapFileUtil(new Entities());
879
-
880
- it('should return false for custom-entity:pack (mapping entry false)', async () =>{
881
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
882
- .mockImplementation(async () =>{
883
- return mapping;
884
- });
885
- const entity = {
886
- entityType: 'custom-entity',
887
- typePath: 'custom-entity:pack'
888
- }
889
-
890
- try{
891
- const results = await TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
892
- expect(results).toBeFalsy();
893
-
894
- } finally {
895
- spy.mockRestore();
896
- }
897
- });
898
-
899
- it('should return true for custom-entity:prefix (mapping entry true)', async () =>{
900
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
901
- .mockImplementation(async () =>{
902
- return mapping;
903
- });
904
- const entity = {
905
- entityType: 'custom-entity',
906
- typePath: 'custom-entity:prefix'
907
- }
908
-
909
- try{
910
- const results = await TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
911
- expect(results).toBeTruthy();
912
-
913
- } finally {
914
- spy.mockRestore();
915
- }
916
- });
917
-
918
- it('should pass context to syncOutboundImages function', async () =>{
919
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
920
- .mockImplementation(async () =>{
921
- return mapping;
922
- });
923
- const entity = {
924
- entityType: 'custom-entity',
925
- typePath: 'custom-entity:prefix'
926
- }
927
- const context = { skipImages: true };
928
-
929
- try{
930
- const results = await TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity, context);
931
- expect(results).toBeFalsy();
932
-
933
- } finally {
934
- spy.mockRestore();
935
- }
936
- });
937
-
938
- it('should default to true when no mapping exists', async () =>{
939
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
940
- .mockImplementation(async () =>{
941
- return mapping;
942
- });
943
- const entity = {
944
- entityType: 'custom-entity',
945
- typePath: 'custom-entity:catName'
946
- }
947
-
948
- try{
949
- const results = await TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
950
- expect(results).toBeTruthy();
951
-
952
- } finally {
953
- spy.mockRestore();
954
- }
955
- });
956
-
957
- it('should default to true when no fileId', async () =>{
958
- const entity = {
959
- entityType: 'custom-entity',
960
- typePath: 'custom-entity:pack'
961
- }
962
-
963
- const results = await TypeConversionUtils.syncOutboundImages('', mapFileUtil, entity);
964
- expect(results).toBeTruthy();
965
- });
966
-
967
- });
968
- });