@contrail/flexplm 1.3.0 → 1.3.1-alpha.3e8dbdd

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 (149) hide show
  1. package/lib/cli/commands/compile.d.ts +1 -0
  2. package/lib/cli/commands/compile.js +71 -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 +1 -0
  6. package/lib/cli/commands/create.js +75 -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 +10 -0
  10. package/lib/cli/commands/upload.js +226 -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 +2 -0
  14. package/lib/cli/index.js +64 -0
  15. package/lib/cli/index.spec.d.ts +1 -0
  16. package/lib/cli/index.spec.js +79 -0
  17. package/lib/cli/template/mapping-template.ts.template +62 -0
  18. package/lib/entity-processor/base-entity-processor.d.ts +89 -42
  19. package/lib/entity-processor/base-entity-processor.js +438 -385
  20. package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -1
  21. package/lib/entity-processor/base-entity-processor.spec.js +398 -397
  22. package/lib/flexplm-request.d.ts +3 -3
  23. package/lib/flexplm-request.js +34 -34
  24. package/lib/flexplm-utils.d.ts +5 -5
  25. package/lib/flexplm-utils.js +33 -33
  26. package/lib/flexplm-utils.spec.d.ts +1 -1
  27. package/lib/flexplm-utils.spec.js +26 -26
  28. package/lib/index.d.ts +23 -22
  29. package/lib/index.js +39 -38
  30. package/lib/interfaces/interfaces.d.ts +105 -105
  31. package/lib/interfaces/interfaces.js +2 -2
  32. package/lib/interfaces/item-family-changes.d.ts +20 -20
  33. package/lib/interfaces/item-family-changes.js +56 -56
  34. package/lib/interfaces/mapping-file.d.ts +460 -0
  35. package/lib/interfaces/mapping-file.js +2 -0
  36. package/lib/interfaces/publish-change-data.d.ts +19 -19
  37. package/lib/interfaces/publish-change-data.js +32 -32
  38. package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -9
  39. package/lib/publish/base-process-publish-assortment-callback.js +38 -38
  40. package/lib/publish/base-process-publish-assortment.d.ts +118 -93
  41. package/lib/publish/base-process-publish-assortment.js +998 -944
  42. package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -1
  43. package/lib/publish/base-process-publish-assortment.spec.js +1688 -1670
  44. package/lib/publish/mockData.d.ts +1389 -1389
  45. package/lib/publish/mockData.js +4524 -4519
  46. package/lib/transform/identifier-conversion-spec-mockData.js +472 -444
  47. package/lib/transform/identifier-conversion.d.ts +51 -15
  48. package/lib/transform/identifier-conversion.js +248 -212
  49. package/lib/transform/identifier-conversion.spec.d.ts +1 -1
  50. package/lib/transform/identifier-conversion.spec.js +343 -339
  51. package/lib/util/config-defaults.d.ts +8 -8
  52. package/lib/util/config-defaults.js +88 -85
  53. package/lib/util/config-defaults.spec.d.ts +1 -1
  54. package/lib/util/config-defaults.spec.js +302 -293
  55. package/lib/util/data-converter-spec-mockData.js +219 -205
  56. package/lib/util/data-converter.d.ts +136 -39
  57. package/lib/util/data-converter.js +718 -592
  58. package/lib/util/data-converter.spec.d.ts +1 -1
  59. package/lib/util/data-converter.spec.js +906 -904
  60. package/lib/util/error-response-object.d.ts +9 -4
  61. package/lib/util/error-response-object.js +54 -47
  62. package/lib/util/error-response-object.spec.d.ts +1 -1
  63. package/lib/util/error-response-object.spec.js +99 -99
  64. package/lib/util/event-short-message-status.d.ts +19 -19
  65. package/lib/util/event-short-message-status.js +24 -23
  66. package/lib/util/federation.d.ts +15 -15
  67. package/lib/util/federation.js +157 -149
  68. package/lib/util/flexplm-connect.d.ts +29 -22
  69. package/lib/util/flexplm-connect.js +190 -176
  70. package/lib/util/flexplm-connect.spec.d.ts +1 -1
  71. package/lib/util/flexplm-connect.spec.js +88 -88
  72. package/lib/util/logger-config.d.ts +1 -1
  73. package/lib/util/logger-config.js +27 -26
  74. package/lib/util/map-util-spec-mockData.js +219 -205
  75. package/lib/util/map-utils.d.ts +33 -6
  76. package/lib/util/map-utils.js +42 -15
  77. package/lib/util/map-utils.spec.d.ts +1 -1
  78. package/lib/util/map-utils.spec.js +89 -89
  79. package/lib/util/mockData.d.ts +80 -80
  80. package/lib/util/mockData.js +103 -103
  81. package/lib/util/thumbnail-util.d.ts +55 -34
  82. package/lib/util/thumbnail-util.js +242 -215
  83. package/lib/util/thumbnail-util.spec.d.ts +1 -1
  84. package/lib/util/thumbnail-util.spec.js +440 -434
  85. package/lib/util/type-conversion-utils-spec-mockData.js +259 -259
  86. package/lib/util/type-conversion-utils.d.ts +163 -23
  87. package/lib/util/type-conversion-utils.js +408 -265
  88. package/lib/util/type-conversion-utils.spec.d.ts +1 -1
  89. package/lib/util/type-conversion-utils.spec.js +868 -868
  90. package/lib/util/type-defaults.d.ts +74 -16
  91. package/lib/util/type-defaults.js +279 -221
  92. package/lib/util/type-defaults.spec.d.ts +1 -1
  93. package/lib/util/type-defaults.spec.js +516 -516
  94. package/lib/util/type-utils.d.ts +34 -13
  95. package/lib/util/type-utils.js +137 -114
  96. package/lib/util/type-utils.spec.d.ts +1 -1
  97. package/lib/util/type-utils.spec.js +192 -190
  98. package/package.json +21 -6
  99. package/scripts/copy-template.js +10 -0
  100. package/.claude/settings.local.json +0 -8
  101. package/.github/pull_request_template.md +0 -31
  102. package/.github/workflows/flexplm-lib.yml +0 -27
  103. package/.github/workflows/publish-to-npm.yml +0 -124
  104. package/CHANGELOG.md +0 -32
  105. package/publish.bat +0 -5
  106. package/publish.sh +0 -5
  107. package/src/entity-processor/base-entity-processor.spec.ts +0 -460
  108. package/src/entity-processor/base-entity-processor.ts +0 -515
  109. package/src/flexplm-request.ts +0 -28
  110. package/src/flexplm-utils.spec.ts +0 -27
  111. package/src/flexplm-utils.ts +0 -29
  112. package/src/index.ts +0 -22
  113. package/src/interfaces/interfaces.ts +0 -122
  114. package/src/interfaces/item-family-changes.ts +0 -67
  115. package/src/interfaces/publish-change-data.ts +0 -43
  116. package/src/publish/base-process-publish-assortment-callback.ts +0 -50
  117. package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
  118. package/src/publish/base-process-publish-assortment.ts +0 -1134
  119. package/src/publish/mockData.ts +0 -4561
  120. package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
  121. package/src/transform/identifier-conversion.spec.ts +0 -354
  122. package/src/transform/identifier-conversion.ts +0 -282
  123. package/src/util/config-defaults.spec.ts +0 -350
  124. package/src/util/config-defaults.ts +0 -93
  125. package/src/util/data-converter-spec-mockData.ts +0 -231
  126. package/src/util/data-converter.spec.ts +0 -1041
  127. package/src/util/data-converter.ts +0 -762
  128. package/src/util/error-response-object.spec.ts +0 -116
  129. package/src/util/error-response-object.ts +0 -50
  130. package/src/util/event-short-message-status.ts +0 -22
  131. package/src/util/federation.ts +0 -172
  132. package/src/util/flexplm-connect.spec.ts +0 -132
  133. package/src/util/flexplm-connect.ts +0 -208
  134. package/src/util/logger-config.ts +0 -20
  135. package/src/util/map-util-spec-mockData.ts +0 -231
  136. package/src/util/map-utils.spec.ts +0 -103
  137. package/src/util/map-utils.ts +0 -41
  138. package/src/util/mockData.ts +0 -101
  139. package/src/util/thumbnail-util.spec.ts +0 -508
  140. package/src/util/thumbnail-util.ts +0 -272
  141. package/src/util/type-conversion-utils-spec-mockData.ts +0 -271
  142. package/src/util/type-conversion-utils.spec.ts +0 -968
  143. package/src/util/type-conversion-utils.ts +0 -460
  144. package/src/util/type-defaults.spec.ts +0 -669
  145. package/src/util/type-defaults.ts +0 -281
  146. package/src/util/type-utils.spec.ts +0 -227
  147. package/src/util/type-utils.ts +0 -144
  148. package/tsconfig.json +0 -29
  149. 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
- });