@contrail/flexplm 1.2.0-alpha.0 → 1.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/package.json +1 -1
  2. package/scripts/output.png +0 -0
  3. package/scripts/test-get-request.ts +35 -0
  4. package/src/util/flexplm-connect.spec.ts +132 -0
  5. package/src/util/flexplm-connect.ts +14 -5
  6. package/src/util/type-conversion-utils-spec-mockData.ts +18 -0
  7. package/src/util/type-conversion-utils.spec.ts +184 -0
  8. package/src/util/type-conversion-utils.ts +74 -0
  9. package/lib/entity-processor/base-entity-processor.d.ts +0 -42
  10. package/lib/entity-processor/base-entity-processor.js +0 -363
  11. package/lib/entity-processor/base-entity-processor.spec.d.ts +0 -1
  12. package/lib/entity-processor/base-entity-processor.spec.js +0 -302
  13. package/lib/flexplm-request.d.ts +0 -3
  14. package/lib/flexplm-request.js +0 -34
  15. package/lib/flexplm-utils.d.ts +0 -5
  16. package/lib/flexplm-utils.js +0 -33
  17. package/lib/flexplm-utils.spec.d.ts +0 -1
  18. package/lib/flexplm-utils.spec.js +0 -26
  19. package/lib/index.d.ts +0 -22
  20. package/lib/index.js +0 -38
  21. package/lib/interfaces/interfaces.d.ts +0 -105
  22. package/lib/interfaces/interfaces.js +0 -2
  23. package/lib/interfaces/item-family-changes.d.ts +0 -20
  24. package/lib/interfaces/item-family-changes.js +0 -56
  25. package/lib/interfaces/publish-change-data.d.ts +0 -19
  26. package/lib/interfaces/publish-change-data.js +0 -32
  27. package/lib/publish/base-process-publish-assortment-callback.d.ts +0 -9
  28. package/lib/publish/base-process-publish-assortment-callback.js +0 -38
  29. package/lib/publish/base-process-publish-assortment.d.ts +0 -93
  30. package/lib/publish/base-process-publish-assortment.js +0 -944
  31. package/lib/publish/base-process-publish-assortment.spec.d.ts +0 -1
  32. package/lib/publish/base-process-publish-assortment.spec.js +0 -1670
  33. package/lib/publish/mockData.d.ts +0 -1389
  34. package/lib/publish/mockData.js +0 -4519
  35. package/lib/transform/identifier-conversion-spec-mockData.d.ts +0 -0
  36. package/lib/transform/identifier-conversion-spec-mockData.js +0 -444
  37. package/lib/transform/identifier-conversion.d.ts +0 -15
  38. package/lib/transform/identifier-conversion.js +0 -212
  39. package/lib/transform/identifier-conversion.spec.d.ts +0 -1
  40. package/lib/transform/identifier-conversion.spec.js +0 -339
  41. package/lib/util/config-defaults.d.ts +0 -8
  42. package/lib/util/config-defaults.js +0 -85
  43. package/lib/util/config-defaults.spec.d.ts +0 -1
  44. package/lib/util/config-defaults.spec.js +0 -293
  45. package/lib/util/data-converter-spec-mockData.d.ts +0 -0
  46. package/lib/util/data-converter-spec-mockData.js +0 -205
  47. package/lib/util/data-converter.d.ts +0 -39
  48. package/lib/util/data-converter.js +0 -592
  49. package/lib/util/data-converter.spec.d.ts +0 -1
  50. package/lib/util/data-converter.spec.js +0 -904
  51. package/lib/util/error-response-object.d.ts +0 -4
  52. package/lib/util/error-response-object.js +0 -47
  53. package/lib/util/error-response-object.spec.d.ts +0 -1
  54. package/lib/util/error-response-object.spec.js +0 -99
  55. package/lib/util/event-short-message-status.d.ts +0 -18
  56. package/lib/util/event-short-message-status.js +0 -22
  57. package/lib/util/federation.d.ts +0 -15
  58. package/lib/util/federation.js +0 -149
  59. package/lib/util/flexplm-connect.d.ts +0 -18
  60. package/lib/util/flexplm-connect.js +0 -171
  61. package/lib/util/logger-config.d.ts +0 -1
  62. package/lib/util/logger-config.js +0 -26
  63. package/lib/util/map-util-spec-mockData.d.ts +0 -0
  64. package/lib/util/map-util-spec-mockData.js +0 -205
  65. package/lib/util/map-utils.d.ts +0 -6
  66. package/lib/util/map-utils.js +0 -15
  67. package/lib/util/map-utils.spec.d.ts +0 -1
  68. package/lib/util/map-utils.spec.js +0 -89
  69. package/lib/util/mockData.d.ts +0 -79
  70. package/lib/util/mockData.js +0 -99
  71. package/lib/util/thumbnail-util.d.ts +0 -19
  72. package/lib/util/thumbnail-util.js +0 -114
  73. package/lib/util/thumbnail-util.spec.d.ts +0 -1
  74. package/lib/util/thumbnail-util.spec.js +0 -242
  75. package/lib/util/type-conversion-utils-spec-mockData.d.ts +0 -0
  76. package/lib/util/type-conversion-utils-spec-mockData.js +0 -241
  77. package/lib/util/type-conversion-utils.d.ts +0 -21
  78. package/lib/util/type-conversion-utils.js +0 -223
  79. package/lib/util/type-conversion-utils.spec.d.ts +0 -1
  80. package/lib/util/type-conversion-utils.spec.js +0 -708
  81. package/lib/util/type-defaults.d.ts +0 -16
  82. package/lib/util/type-defaults.js +0 -221
  83. package/lib/util/type-defaults.spec.d.ts +0 -1
  84. package/lib/util/type-defaults.spec.js +0 -516
  85. package/lib/util/type-utils.d.ts +0 -13
  86. package/lib/util/type-utils.js +0 -114
  87. package/lib/util/type-utils.spec.d.ts +0 -1
  88. package/lib/util/type-utils.spec.js +0 -190
@@ -1,708 +0,0 @@
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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- flexPLMObjectClass: '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
- describe('isInboundCreatableFromObject', () => {
548
- const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
549
- it('Revisable Entity\\packaging', async () => {
550
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
551
- .mockImplementation(async () => {
552
- return mapping;
553
- });
554
- const object = {
555
- flexPLMObjectClass: 'LCSRevisableEntity',
556
- flexPLMTypePath: 'Revisable Entity\\packaging'
557
- };
558
- try {
559
- const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
560
- expect(results).toBeFalsy();
561
- }
562
- finally {
563
- spy.mockRestore();
564
- }
565
- });
566
- it('Revisable Entity\\prefix', async () => {
567
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
568
- .mockImplementation(async () => {
569
- return mapping;
570
- });
571
- const object = {
572
- flexPLMObjectClass: 'LCSRevisableEntity',
573
- flexPLMTypePath: 'Revisable Entity\\prefix'
574
- };
575
- try {
576
- const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
577
- expect(results).toBeTruthy();
578
- }
579
- finally {
580
- spy.mockRestore();
581
- }
582
- });
583
- it('should pass context to isInboundCreatable function', async () => {
584
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
585
- .mockImplementation(async () => {
586
- return mapping;
587
- });
588
- const object = {
589
- flexPLMObjectClass: 'LCSRevisableEntity',
590
- flexPLMTypePath: 'Revisable Entity\\prefix'
591
- };
592
- const context = { skipPrefix: true };
593
- try {
594
- const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, context);
595
- expect(results).toBeFalsy();
596
- }
597
- finally {
598
- spy.mockRestore();
599
- }
600
- });
601
- it('should work without context parameter', async () => {
602
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
603
- .mockImplementation(async () => {
604
- return mapping;
605
- });
606
- const object = {
607
- flexPLMObjectClass: 'LCSRevisableEntity',
608
- flexPLMTypePath: 'Revisable Entity\\prefix'
609
- };
610
- try {
611
- const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
612
- expect(results).toBeTruthy();
613
- }
614
- finally {
615
- spy.mockRestore();
616
- }
617
- });
618
- });
619
- describe('isOutboundCreatableFromEntity', () => {
620
- const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
621
- it('should return false for custom-entity:pack', async () => {
622
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
623
- .mockImplementation(async () => {
624
- return mapping;
625
- });
626
- const entity = {
627
- entityType: 'custom-entity',
628
- typePath: 'custom-entity:pack'
629
- };
630
- try {
631
- const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
632
- expect(results).toBeFalsy();
633
- }
634
- finally {
635
- spy.mockRestore();
636
- }
637
- });
638
- it('should return true for custom-entity:prefix', async () => {
639
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
640
- .mockImplementation(async () => {
641
- return mapping;
642
- });
643
- const entity = {
644
- entityType: 'custom-entity',
645
- typePath: 'custom-entity:prefix'
646
- };
647
- try {
648
- const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
649
- expect(results).toBeTruthy();
650
- }
651
- finally {
652
- spy.mockRestore();
653
- }
654
- });
655
- it('should pass context to isOutboundCreatable function', async () => {
656
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
657
- .mockImplementation(async () => {
658
- return mapping;
659
- });
660
- const entity = {
661
- entityType: 'custom-entity',
662
- typePath: 'custom-entity:prefix'
663
- };
664
- const context = { skipPrefix: true };
665
- try {
666
- const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity, context);
667
- expect(results).toBeFalsy();
668
- }
669
- finally {
670
- spy.mockRestore();
671
- }
672
- });
673
- it('should work without context parameter', async () => {
674
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
675
- .mockImplementation(async () => {
676
- return mapping;
677
- });
678
- const entity = {
679
- entityType: 'custom-entity',
680
- typePath: 'custom-entity:prefix'
681
- };
682
- try {
683
- const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
684
- expect(results).toBeTruthy();
685
- }
686
- finally {
687
- spy.mockRestore();
688
- }
689
- });
690
- it('should default to true when no mapping exists', async () => {
691
- const spy = jest.spyOn(mapFileUtil, 'getMapFile')
692
- .mockImplementation(async () => {
693
- return mapping;
694
- });
695
- const entity = {
696
- entityType: 'custom-entity',
697
- typePath: 'custom-entity:catName'
698
- };
699
- try {
700
- const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
701
- expect(results).toBeTruthy();
702
- }
703
- finally {
704
- spy.mockRestore();
705
- }
706
- });
707
- });
708
- });