@contrail/flexplm 1.3.0-alpha.0 → 1.3.0-alpha.04c91a9

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 (126) hide show
  1. package/.github/pull_request_template.md +31 -31
  2. package/.github/workflows/flexplm-lib.yml +27 -27
  3. package/.github/workflows/publish-to-npm.yml +131 -0
  4. package/CHANGELOG.md +11 -1
  5. package/lib/entity-processor/base-entity-processor.d.ts +42 -0
  6. package/lib/entity-processor/base-entity-processor.js +385 -0
  7. package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -0
  8. package/lib/entity-processor/base-entity-processor.spec.js +397 -0
  9. package/lib/flexplm-request.d.ts +3 -0
  10. package/lib/flexplm-request.js +34 -0
  11. package/lib/flexplm-utils.d.ts +5 -0
  12. package/lib/flexplm-utils.js +33 -0
  13. package/lib/flexplm-utils.spec.d.ts +1 -0
  14. package/lib/flexplm-utils.spec.js +26 -0
  15. package/lib/index.d.ts +22 -0
  16. package/lib/index.js +38 -0
  17. package/lib/interfaces/interfaces.d.ts +105 -0
  18. package/lib/interfaces/interfaces.js +2 -0
  19. package/lib/interfaces/item-family-changes.d.ts +20 -0
  20. package/lib/interfaces/item-family-changes.js +56 -0
  21. package/lib/interfaces/publish-change-data.d.ts +19 -0
  22. package/lib/interfaces/publish-change-data.js +32 -0
  23. package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -0
  24. package/lib/publish/base-process-publish-assortment-callback.js +38 -0
  25. package/lib/publish/base-process-publish-assortment.d.ts +93 -0
  26. package/lib/publish/base-process-publish-assortment.js +944 -0
  27. package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -0
  28. package/lib/publish/base-process-publish-assortment.spec.js +1670 -0
  29. package/lib/publish/mockData.d.ts +1389 -0
  30. package/lib/publish/mockData.js +4519 -0
  31. package/lib/transform/identifier-conversion-spec-mockData.d.ts +0 -0
  32. package/lib/transform/identifier-conversion-spec-mockData.js +444 -0
  33. package/lib/transform/identifier-conversion.d.ts +15 -0
  34. package/lib/transform/identifier-conversion.js +212 -0
  35. package/lib/transform/identifier-conversion.spec.d.ts +1 -0
  36. package/lib/transform/identifier-conversion.spec.js +339 -0
  37. package/lib/util/config-defaults.d.ts +8 -0
  38. package/lib/util/config-defaults.js +85 -0
  39. package/lib/util/config-defaults.spec.d.ts +1 -0
  40. package/lib/util/config-defaults.spec.js +293 -0
  41. package/lib/util/data-converter-spec-mockData.d.ts +0 -0
  42. package/lib/util/data-converter-spec-mockData.js +205 -0
  43. package/lib/util/data-converter.d.ts +39 -0
  44. package/lib/util/data-converter.js +592 -0
  45. package/lib/util/data-converter.spec.d.ts +1 -0
  46. package/lib/util/data-converter.spec.js +904 -0
  47. package/lib/util/error-response-object.d.ts +4 -0
  48. package/lib/util/error-response-object.js +47 -0
  49. package/lib/util/error-response-object.spec.d.ts +1 -0
  50. package/lib/util/error-response-object.spec.js +99 -0
  51. package/lib/util/event-short-message-status.d.ts +19 -0
  52. package/lib/util/event-short-message-status.js +23 -0
  53. package/lib/util/federation.d.ts +15 -0
  54. package/lib/util/federation.js +149 -0
  55. package/lib/util/flexplm-connect.d.ts +22 -0
  56. package/lib/util/flexplm-connect.js +176 -0
  57. package/lib/util/flexplm-connect.spec.d.ts +1 -0
  58. package/lib/util/flexplm-connect.spec.js +88 -0
  59. package/lib/util/logger-config.d.ts +1 -0
  60. package/lib/util/logger-config.js +26 -0
  61. package/lib/util/map-util-spec-mockData.d.ts +0 -0
  62. package/lib/util/map-util-spec-mockData.js +205 -0
  63. package/lib/util/map-utils.d.ts +6 -0
  64. package/lib/util/map-utils.js +15 -0
  65. package/lib/util/map-utils.spec.d.ts +1 -0
  66. package/lib/util/map-utils.spec.js +89 -0
  67. package/lib/util/mockData.d.ts +80 -0
  68. package/lib/util/mockData.js +103 -0
  69. package/lib/util/thumbnail-util.d.ts +34 -0
  70. package/lib/util/thumbnail-util.js +215 -0
  71. package/lib/util/thumbnail-util.spec.d.ts +1 -0
  72. package/lib/util/thumbnail-util.spec.js +434 -0
  73. package/lib/util/type-conversion-utils-spec-mockData.d.ts +0 -0
  74. package/lib/util/type-conversion-utils-spec-mockData.js +259 -0
  75. package/lib/util/type-conversion-utils.d.ts +23 -0
  76. package/lib/util/type-conversion-utils.js +265 -0
  77. package/lib/util/type-conversion-utils.spec.d.ts +1 -0
  78. package/lib/util/type-conversion-utils.spec.js +868 -0
  79. package/lib/util/type-defaults.d.ts +16 -0
  80. package/lib/util/type-defaults.js +221 -0
  81. package/lib/util/type-defaults.spec.d.ts +1 -0
  82. package/lib/util/type-defaults.spec.js +516 -0
  83. package/lib/util/type-utils.d.ts +13 -0
  84. package/lib/util/type-utils.js +114 -0
  85. package/lib/util/type-utils.spec.d.ts +1 -0
  86. package/lib/util/type-utils.spec.js +190 -0
  87. package/package.json +1 -1
  88. package/publish.bat +4 -4
  89. package/publish.sh +4 -4
  90. package/src/entity-processor/base-entity-processor.spec.ts +122 -0
  91. package/src/entity-processor/base-entity-processor.ts +31 -2
  92. package/src/flexplm-request.ts +28 -28
  93. package/src/flexplm-utils.spec.ts +27 -27
  94. package/src/flexplm-utils.ts +29 -29
  95. package/src/index.ts +21 -21
  96. package/src/interfaces/item-family-changes.ts +66 -66
  97. package/src/interfaces/publish-change-data.ts +42 -42
  98. package/src/publish/base-process-publish-assortment-callback.ts +50 -50
  99. package/src/transform/identifier-conversion-spec-mockData.ts +495 -495
  100. package/src/transform/identifier-conversion.spec.ts +353 -353
  101. package/src/transform/identifier-conversion.ts +281 -281
  102. package/src/util/config-defaults.spec.ts +350 -350
  103. package/src/util/config-defaults.ts +92 -92
  104. package/src/util/data-converter-spec-mockData.ts +230 -230
  105. package/src/util/error-response-object.spec.ts +115 -115
  106. package/src/util/error-response-object.ts +49 -49
  107. package/src/util/event-short-message-status.ts +1 -0
  108. package/src/util/federation.ts +172 -172
  109. package/src/util/logger-config.ts +19 -19
  110. package/src/util/map-util-spec-mockData.ts +230 -230
  111. package/src/util/map-utils.spec.ts +102 -102
  112. package/src/util/map-utils.ts +40 -40
  113. package/src/util/mockData.ts +101 -97
  114. package/src/util/thumbnail-util.spec.ts +239 -0
  115. package/src/util/thumbnail-util.ts +140 -5
  116. package/src/util/type-conversion-utils.spec.ts +25 -25
  117. package/src/util/type-conversion-utils.ts +10 -10
  118. package/src/util/type-defaults.spec.ts +668 -668
  119. package/src/util/type-defaults.ts +280 -280
  120. package/src/util/type-utils.spec.ts +227 -227
  121. package/src/util/type-utils.ts +144 -144
  122. package/tsconfig.json +23 -26
  123. package/tslint.json +57 -57
  124. package/.claude/settings.local.json +0 -7
  125. package/scripts/output.png +0 -0
  126. package/scripts/test-get-request.ts +0 -35
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const type_utils_1 = require("./type-utils");
4
+ describe('TypeUtils.getEventObjectClass() tests', () => {
5
+ const tu = new type_utils_1.TypeUtils();
6
+ it('LCSProduct', () => {
7
+ const entityType = 'item';
8
+ const newData = {
9
+ roles: ['family']
10
+ };
11
+ const objectClass = tu.getEventObjectClass(entityType, newData);
12
+ expect(objectClass).toEqual('LCSProduct');
13
+ });
14
+ it('LCSSKU', () => {
15
+ const entityType = 'item';
16
+ const newData = {
17
+ roles: ['color']
18
+ };
19
+ const objectClass = tu.getEventObjectClass(entityType, newData);
20
+ expect(objectClass).toEqual('LCSSKU');
21
+ });
22
+ it('LCSProductSeasonLink', () => {
23
+ const entityType = 'project-item';
24
+ const newData = {
25
+ roles: ['family']
26
+ };
27
+ const objectClass = tu.getEventObjectClass(entityType, newData);
28
+ expect(objectClass).toEqual('LCSProductSeasonLink');
29
+ });
30
+ it('LCSSKUSeasonLink', () => {
31
+ const entityType = 'project-item';
32
+ const newData = {
33
+ roles: ['color']
34
+ };
35
+ const objectClass = tu.getEventObjectClass(entityType, newData);
36
+ expect(objectClass).toEqual('LCSSKUSeasonLink');
37
+ });
38
+ it('LCSColor', () => {
39
+ const entityType = 'color';
40
+ const newData = {};
41
+ const objectClass = tu.getEventObjectClass(entityType, newData);
42
+ expect(objectClass).toEqual('LCSColor');
43
+ });
44
+ it('LCSRevisableEntity', () => {
45
+ const entityType = 'custom-entity';
46
+ const newData = {};
47
+ const objectClass = tu.getEventObjectClass(entityType, newData);
48
+ expect(objectClass).toEqual('LCSRevisableEntity');
49
+ });
50
+ });
51
+ describe('filterProperties-item', () => {
52
+ const itemType = {
53
+ typePath: 'item'
54
+ };
55
+ itemType['typeProperties'] = [
56
+ {
57
+ id: 'H4NazLloHdUVhc71',
58
+ slug: 'null',
59
+ propertyLevel: null
60
+ },
61
+ {
62
+ id: 'H4NazLloHdUVhc71',
63
+ slug: 'family',
64
+ propertyLevel: 'family'
65
+ },
66
+ {
67
+ id: 'H4NazLloHdUVhc71',
68
+ slug: 'option',
69
+ propertyLevel: 'option'
70
+ },
71
+ {
72
+ id: 'H4NazLloHdUVhc71',
73
+ slug: 'overridable',
74
+ propertyLevel: 'overridable'
75
+ },
76
+ {
77
+ id: 'H4NazLloHdUVhc71',
78
+ slug: 'all',
79
+ propertyLevel: 'all'
80
+ },
81
+ ];
82
+ const tu = new type_utils_1.TypeUtils();
83
+ it('item-family', () => {
84
+ const len = 4;
85
+ const newData = {
86
+ roles: ['family']
87
+ };
88
+ const filteredProps = tu.filterTypeProperties(itemType, newData);
89
+ expect(filteredProps.length).toEqual(len);
90
+ });
91
+ it('item-option', () => {
92
+ const len = 4;
93
+ const newData = {
94
+ roles: ['option']
95
+ };
96
+ const filteredProps = tu.filterTypeProperties(itemType, newData);
97
+ expect(filteredProps.length).toEqual(len);
98
+ });
99
+ it('item-no-roles', () => {
100
+ const len = 5;
101
+ const newData = {};
102
+ const filteredProps = tu.filterTypeProperties(itemType, newData);
103
+ expect(filteredProps.length).toEqual(len);
104
+ });
105
+ });
106
+ describe('filterProperties-project-item', () => {
107
+ const projectItemType = {
108
+ typePath: 'project-item'
109
+ };
110
+ projectItemType['typeProperties'] = [
111
+ {
112
+ id: 'H4NazLloHdUVhc71',
113
+ slug: 'null',
114
+ propertyLevel: null
115
+ },
116
+ {
117
+ id: 'H4NazLloHdUVhc71',
118
+ slug: 'family',
119
+ propertyLevel: 'family'
120
+ },
121
+ {
122
+ id: 'H4NazLloHdUVhc71',
123
+ slug: 'option',
124
+ propertyLevel: 'option'
125
+ },
126
+ {
127
+ id: 'H4NazLloHdUVhc71',
128
+ slug: 'overridable',
129
+ propertyLevel: 'overridable'
130
+ },
131
+ {
132
+ id: 'H4NazLloHdUVhc71',
133
+ slug: 'all',
134
+ propertyLevel: 'all'
135
+ },
136
+ ];
137
+ const tu = new type_utils_1.TypeUtils();
138
+ it('item-family', () => {
139
+ const len = 4;
140
+ const newData = {
141
+ roles: ['family']
142
+ };
143
+ const filteredProps = tu.filterTypeProperties(projectItemType, newData);
144
+ expect(filteredProps.length).toEqual(len);
145
+ });
146
+ it('item-option', () => {
147
+ const len = 4;
148
+ const newData = {
149
+ roles: ['option']
150
+ };
151
+ const filteredProps = tu.filterTypeProperties(projectItemType, newData);
152
+ expect(filteredProps.length).toEqual(len);
153
+ });
154
+ });
155
+ describe('filterProperties-color', () => {
156
+ const colorType = {
157
+ typePath: 'color'
158
+ };
159
+ colorType['typeProperties'] = [
160
+ {
161
+ id: 'H4NazLloHdUVhc71',
162
+ slug: 'null',
163
+ },
164
+ {
165
+ id: 'H4NazLloHdUVhc71',
166
+ slug: 'family',
167
+ },
168
+ {
169
+ id: 'H4NazLloHdUVhc71',
170
+ slug: 'option',
171
+ },
172
+ {
173
+ id: 'H4NazLloHdUVhc71',
174
+ slug: 'overridable',
175
+ },
176
+ {
177
+ id: 'H4NazLloHdUVhc71',
178
+ slug: 'all',
179
+ },
180
+ ];
181
+ const tu = new type_utils_1.TypeUtils();
182
+ it('color', () => {
183
+ const len = 5;
184
+ const newData = {
185
+ roles: ['family']
186
+ };
187
+ const filteredProps = tu.filterTypeProperties(colorType, newData);
188
+ expect(filteredProps.length).toEqual(len);
189
+ });
190
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.3.0-alpha.0",
3
+ "version": "1.3.0-alpha.04c91a9",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/publish.bat CHANGED
@@ -1,5 +1,5 @@
1
- rd /s /q lib
2
- call npm install
3
- call npm run build
4
- call npm version patch
1
+ rd /s /q lib
2
+ call npm install
3
+ call npm run build
4
+ call npm version patch
5
5
  call npm publish
package/publish.sh CHANGED
@@ -1,5 +1,5 @@
1
- rm -rf lib;
2
- npm install;
3
- npm run build;
4
- npm version patch;
1
+ rm -rf lib;
2
+ npm install;
3
+ npm run build;
4
+ npm version patch;
5
5
  npm publish;
@@ -3,6 +3,8 @@ import { MapFileUtil } from "@contrail/transform-data";
3
3
  import { EntityPayloadType, FCConfig } from "../interfaces/interfaces";
4
4
  import { DataConverter } from "../util/data-converter";
5
5
  import { BaseEntityProcessor, IncomingEntityResponse } from "./base-entity-processor";
6
+ import { TypeConversionUtils } from "../util/type-conversion-utils";
7
+ import { ThumbnailUtil } from "../util/thumbnail-util";
6
8
 
7
9
  const mockRootType = {
8
10
  typeProperties: [
@@ -335,4 +337,124 @@ describe('BaseEntityProcessor', () =>{
335
337
 
336
338
  });
337
339
 
340
+ describe('handleIncomingUpsert - inbound image sync', () =>{
341
+ const config = {} as FCConfig;
342
+ const mapFileUtil = new MapFileUtil(new Entities());
343
+ const dc = new DataConverter(config, mapFileUtil);
344
+ const mockEvent = { objectClass: 'TestClass', federatedId: 'fed-123', data: { name: 'test' }, entityReference: 'ref-1', eventType: 'PERSIST' } as EntityPayloadType;
345
+ const mockInboundData = { name: 'transformed-test' };
346
+ const mockCreatedEntity = { id: 'created-1', name: 'created', primaryViewableId: 'pv-created' };
347
+ const mockUpdatedEntity = { id: 'updated-1', name: 'updated', primaryViewableId: 'pv-updated' };
348
+ const mockExistingEntity = { id: 'existing-1', name: 'existing', typeId: 'type-1', roles: [] };
349
+
350
+ let btep: TestBaseEntityProcessor;
351
+ let syncInboundImagesSpy: jest.SpyInstance;
352
+ let syncThumbnailSpy: jest.SpyInstance;
353
+
354
+ beforeEach(() =>{
355
+ jest.clearAllMocks();
356
+ btep = new TestBaseEntityProcessor(config, dc, mapFileUtil, 'test');
357
+ jest.spyOn(btep, 'getTransformedData').mockResolvedValue(mockInboundData);
358
+ syncInboundImagesSpy = jest.spyOn(TypeConversionUtils, 'syncInboundImages');
359
+ syncThumbnailSpy = jest.spyOn(ThumbnailUtil.prototype, 'syncThumbnailToVibeIQ').mockResolvedValue(undefined);
360
+ });
361
+
362
+ it('should call syncThumbnailToVibeIQ with entity after create when syncInboundImages returns true', async () =>{
363
+ jest.spyOn(btep, 'getIncomingEntity' as any).mockResolvedValue({ entity: null });
364
+ jest.spyOn(btep, 'getCreateEntity' as any).mockResolvedValue({ entity: { name: 'new' } });
365
+ jest.spyOn(btep, 'createEntity').mockResolvedValue(mockCreatedEntity);
366
+ syncInboundImagesSpy.mockResolvedValue(true);
367
+
368
+ const result = await btep.handleIncomingUpsert(mockEvent);
369
+
370
+ expect(syncThumbnailSpy).toBeCalledTimes(1);
371
+ expect(syncThumbnailSpy).toBeCalledWith({ entityId: 'created-1', primaryViewableId: 'pv-created', event: mockEvent, entityName: 'test' });
372
+ expect(result).toBe(mockCreatedEntity);
373
+ });
374
+
375
+ it('should not sync images after create when syncInboundImages returns false', async () =>{
376
+ jest.spyOn(btep, 'getIncomingEntity' as any).mockResolvedValue({ entity: null });
377
+ jest.spyOn(btep, 'getCreateEntity' as any).mockResolvedValue({ entity: { name: 'new' } });
378
+ jest.spyOn(btep, 'createEntity').mockResolvedValue(mockCreatedEntity);
379
+ syncInboundImagesSpy.mockResolvedValue(false);
380
+
381
+ const result = await btep.handleIncomingUpsert(mockEvent);
382
+
383
+ expect(syncInboundImagesSpy).toBeCalledTimes(1);
384
+ expect(syncThumbnailSpy).toBeCalledTimes(0);
385
+ expect(result).toBe(mockCreatedEntity);
386
+ });
387
+
388
+ it('should call syncThumbnailToVibeIQ with entity and update with property diffs on update', async () =>{
389
+ jest.spyOn(btep, 'getIncomingEntity' as any).mockResolvedValue({ entity: mockExistingEntity });
390
+ jest.spyOn(btep, 'getUpdatesForEntity').mockResolvedValue({ name: 'changed' });
391
+ const updateEntitySpy = jest.spyOn(btep, 'updateEntity').mockResolvedValue(mockUpdatedEntity);
392
+ syncInboundImagesSpy.mockResolvedValue(true);
393
+
394
+ const result = await btep.handleIncomingUpsert(mockEvent);
395
+
396
+ expect(syncThumbnailSpy).toBeCalledTimes(1);
397
+ expect(syncThumbnailSpy).toBeCalledWith({ entityId: 'existing-1', primaryViewableId: undefined, event: mockEvent, entityName: 'test' });
398
+ expect(updateEntitySpy).toBeCalledWith('test', mockExistingEntity, { name: 'changed' });
399
+ expect(result).toBe(mockUpdatedEntity);
400
+ });
401
+
402
+ it('should not sync images on update when syncInboundImages returns false', async () =>{
403
+ jest.spyOn(btep, 'getIncomingEntity' as any).mockResolvedValue({ entity: mockExistingEntity });
404
+ jest.spyOn(btep, 'getUpdatesForEntity').mockResolvedValue({ name: 'changed' });
405
+ jest.spyOn(btep, 'updateEntity').mockResolvedValue(mockUpdatedEntity);
406
+ syncInboundImagesSpy.mockResolvedValue(false);
407
+
408
+ const result = await btep.handleIncomingUpsert(mockEvent);
409
+
410
+ expect(syncInboundImagesSpy).toBeCalledTimes(1);
411
+ expect(syncThumbnailSpy).toBeCalledTimes(0);
412
+ expect(result).toBe(mockUpdatedEntity);
413
+ });
414
+
415
+ it('should not sync images on early return from getIncomingEntity', async () =>{
416
+ jest.spyOn(btep, 'getIncomingEntity' as any).mockResolvedValue({
417
+ earlyReturn: { status: 400, data: { message: 'error' }, shortStatusMessage: 'FAIL' }
418
+ });
419
+
420
+ await btep.handleIncomingUpsert(mockEvent);
421
+
422
+ expect(syncInboundImagesSpy).toBeCalledTimes(0);
423
+ expect(syncThumbnailSpy).toBeCalledTimes(0);
424
+ });
425
+
426
+ it('should not sync images on early return from getCreateEntity', async () =>{
427
+ jest.spyOn(btep, 'getIncomingEntity' as any).mockResolvedValue({ entity: null });
428
+ jest.spyOn(btep, 'getCreateEntity' as any).mockResolvedValue({
429
+ earlyReturn: { status: 400, data: { message: 'not creatable' }, shortStatusMessage: 'NOT_CREATABLE' }
430
+ });
431
+
432
+ await btep.handleIncomingUpsert(mockEvent);
433
+
434
+ expect(syncInboundImagesSpy).toBeCalledTimes(0);
435
+ expect(syncThumbnailSpy).toBeCalledTimes(0);
436
+ });
437
+
438
+ it('should return no changes when no property diffs and no thumbnail updates', async () =>{
439
+ jest.spyOn(btep, 'getIncomingEntity' as any).mockResolvedValue({ entity: mockExistingEntity });
440
+ jest.spyOn(btep, 'getUpdatesForEntity').mockResolvedValue({});
441
+ syncInboundImagesSpy.mockResolvedValue(true);
442
+ syncThumbnailSpy.mockResolvedValue(undefined);
443
+
444
+ const result = await btep.handleIncomingUpsert(mockEvent);
445
+
446
+ expect(result).toEqual({ status: 200, data: { message: 'No Changes to persist for entity: existing-1' } });
447
+ });
448
+
449
+ it('should return no changes when syncInboundImages is false and no property diffs', async () =>{
450
+ jest.spyOn(btep, 'getIncomingEntity' as any).mockResolvedValue({ entity: mockExistingEntity });
451
+ jest.spyOn(btep, 'getUpdatesForEntity').mockResolvedValue({});
452
+ syncInboundImagesSpy.mockResolvedValue(false);
453
+
454
+ const result = await btep.handleIncomingUpsert(mockEvent);
455
+
456
+ expect(result).toEqual({ status: 200, data: { message: 'No Changes to persist for entity: existing-1' } });
457
+ });
458
+ });
459
+
338
460
  });
@@ -7,6 +7,7 @@ import { MapFileUtil } from '@contrail/transform-data';
7
7
  import { Entities } from '@contrail/sdk';
8
8
  import { TypeProperty } from '@contrail/types';
9
9
  import { TypeConversionUtils } from '../util/type-conversion-utils';
10
+ import { ThumbnailUtil } from '../util/thumbnail-util';
10
11
  import { EventShortMessageStatus } from '../util/event-short-message-status';
11
12
 
12
13
  const UNSUPPORTED_TYPE = 'Unsupported eventType.';
@@ -83,7 +84,13 @@ export abstract class BaseEntityProcessor {
83
84
  console.log(statusMsg);
84
85
  return createEntityResponse.earlyReturn;
85
86
  }
86
- const createdEntity = await this.createEntity(this.baseType, createEntityResponse.entity);
87
+ let createdEntity = await this.createEntity(this.baseType, createEntityResponse.entity);
88
+ const shouldSyncThumbnail = await TypeConversionUtils.syncInboundImages(
89
+ this.transformMapFile, this.mapFileUtil, event.data
90
+ );
91
+ if (shouldSyncThumbnail) {
92
+ createdEntity = await new ThumbnailUtil(this.config).syncThumbnailToVibeIQ({ entityId: createdEntity.id, primaryViewableId: createdEntity.primaryViewableId, event, entityName: this.baseType }) || createdEntity;
93
+ }
87
94
  const statusMsg = this.getInboundStatusMessage({
88
95
  status: EventShortMessageStatus.SUCCESS,
89
96
  statusMessage: EventShortMessageStatus.CREATED,
@@ -96,7 +103,29 @@ export abstract class BaseEntityProcessor {
96
103
  }
97
104
 
98
105
  const diffs = await this.getUpdatesForEntity(entity, inboundData);
99
- if(Object.getOwnPropertyNames(diffs).length == 0){
106
+ const shouldSyncThumbnail = await TypeConversionUtils.syncInboundImages(
107
+ this.transformMapFile, this.mapFileUtil, event.data
108
+ );
109
+ let thumbnailEntity;
110
+ if (shouldSyncThumbnail) {
111
+ thumbnailEntity = await new ThumbnailUtil(this.config).syncThumbnailToVibeIQ({ entityId: entity.id, primaryViewableId: entity.primaryViewableId, event, entityName: this.baseType });
112
+ }
113
+
114
+ const hasPropertyChanges = Object.getOwnPropertyNames(diffs).length > 0;
115
+
116
+ if (!hasPropertyChanges && thumbnailEntity) {
117
+ const statusMsg = this.getInboundStatusMessage({
118
+ status: EventShortMessageStatus.SUCCESS,
119
+ statusMessage: EventShortMessageStatus.PRIMARY_CONTENT_UPDATED,
120
+ objectClass: event.objectClass,
121
+ entityId: entity.id,
122
+ federatedId: event.federatedId
123
+ });
124
+ console.log(statusMsg);
125
+ return thumbnailEntity;
126
+ }
127
+
128
+ if (!hasPropertyChanges) {
100
129
  const statusMsg = this.getInboundStatusMessage({
101
130
  status: EventShortMessageStatus.SUCCESS,
102
131
  statusMessage: EventShortMessageStatus.NO_CHANGES,
@@ -1,28 +1,28 @@
1
- import axios, { AxiosRequestConfig } from 'axios';
2
-
3
- const BASE_URL: string = 'https://PP-2006031951wo.portal.ptc.io/Windchill/servlet/rest/cdee';
4
- const BASE_CONFIG: AxiosRequestConfig = {
5
- method: 'POST',
6
- headers: {
7
- 'Accept': 'application/json',
8
- 'Content-Type': 'application/json',
9
- 'CSRF_NONCE': '2OaLp+0dWNBtrkTwtdDC491zaacu6Hykvqi/lpl6bZgJ/QXBrK/B1J5FErMkmAmktr/I3thcbO1Xn3HJ7Ne/l9kpaedUmn7H75Xey4ZbNLsenW+anM3vxIZ7ELosk3k=',
10
- 'Authorization': 'Basic d2NhZG1pbjpSZXRhaWwyMDIwLQ==',
11
- 'Cookie': 'JSESSIONID=36D5B3C74C1F963C6C73E9AF5B6BDA78.tomcat1; JSESSIONID=B8090C802D8548EA773C97F5886FAB79.tomcat1',
12
- },
13
- };
14
-
15
- export class FlexPLMRequest {
16
- static async request(path: string, data: any){
17
- const config = Object.assign({}, BASE_CONFIG);
18
- config.url = BASE_URL + path;
19
- config.data = data;
20
- try {
21
- const resp = await axios(config);
22
- return Promise.resolve(resp.data);
23
- } catch (error) {
24
- console.error(`${FlexPLMRequest} error: ${error.message}`);
25
- return Promise.resolve(null);
26
- }
27
- }
28
- }
1
+ import axios, { AxiosRequestConfig } from 'axios';
2
+
3
+ const BASE_URL: string = 'https://PP-2006031951wo.portal.ptc.io/Windchill/servlet/rest/cdee';
4
+ const BASE_CONFIG: AxiosRequestConfig = {
5
+ method: 'POST',
6
+ headers: {
7
+ 'Accept': 'application/json',
8
+ 'Content-Type': 'application/json',
9
+ 'CSRF_NONCE': '2OaLp+0dWNBtrkTwtdDC491zaacu6Hykvqi/lpl6bZgJ/QXBrK/B1J5FErMkmAmktr/I3thcbO1Xn3HJ7Ne/l9kpaedUmn7H75Xey4ZbNLsenW+anM3vxIZ7ELosk3k=',
10
+ 'Authorization': 'Basic d2NhZG1pbjpSZXRhaWwyMDIwLQ==',
11
+ 'Cookie': 'JSESSIONID=36D5B3C74C1F963C6C73E9AF5B6BDA78.tomcat1; JSESSIONID=B8090C802D8548EA773C97F5886FAB79.tomcat1',
12
+ },
13
+ };
14
+
15
+ export class FlexPLMRequest {
16
+ static async request(path: string, data: any){
17
+ const config = Object.assign({}, BASE_CONFIG);
18
+ config.url = BASE_URL + path;
19
+ config.data = data;
20
+ try {
21
+ const resp = await axios(config);
22
+ return Promise.resolve(resp.data);
23
+ } catch (error) {
24
+ console.error(`${FlexPLMRequest} error: ${error.message}`);
25
+ return Promise.resolve(null);
26
+ }
27
+ }
28
+ }
@@ -1,27 +1,27 @@
1
- import { FlexPLMUtils } from './flexplm-utils';
2
-
3
- describe('Types Controller', () => {
4
-
5
- beforeEach(async () => {
6
- });
7
-
8
- it('should convert a type path', () => {
9
- expect(FlexPLMUtils.convertTypePath('Product')).toEqual('product');
10
- expect(FlexPLMUtils.convertTypePath('Product\\Apparel')).toEqual('product:apparel');
11
- expect(FlexPLMUtils.convertTypePath('Product\\Skin Care')).toEqual('product:skin_care');
12
- expect(FlexPLMUtils.convertTypePath('Product\\Apparel\\Shirt')).toEqual('product:apparel:shirt');
13
- expect(FlexPLMUtils.convertTypePath('Product\\Apparel\\[Shirt]')).toEqual('product:apparel:*shirt*');
14
- expect(FlexPLMUtils.convertTypePath('')).toBeNull();
15
- });
16
- it('should compute level in tree', () => {
17
- expect(FlexPLMUtils.computeLevelFromPath('product')).toEqual(1);
18
- expect(FlexPLMUtils.computeLevelFromPath('product:apparel')).toEqual(2);
19
- expect(FlexPLMUtils.computeLevelFromPath('product:apparel:dress:mini')).toEqual(4);
20
- });
21
- it('should get a parent type path', () => {
22
- expect(FlexPLMUtils.getParentTypePath('product')).toBeNull();
23
- expect(FlexPLMUtils.getParentTypePath('product:apparel')).toEqual('product');
24
- expect(FlexPLMUtils.getParentTypePath('product:apparel:stuff')).toEqual('product:apparel');
25
- expect(FlexPLMUtils.getParentTypePath('Product\\Apparel')).toEqual('product');
26
- });
27
- });
1
+ import { FlexPLMUtils } from './flexplm-utils';
2
+
3
+ describe('Types Controller', () => {
4
+
5
+ beforeEach(async () => {
6
+ });
7
+
8
+ it('should convert a type path', () => {
9
+ expect(FlexPLMUtils.convertTypePath('Product')).toEqual('product');
10
+ expect(FlexPLMUtils.convertTypePath('Product\\Apparel')).toEqual('product:apparel');
11
+ expect(FlexPLMUtils.convertTypePath('Product\\Skin Care')).toEqual('product:skin_care');
12
+ expect(FlexPLMUtils.convertTypePath('Product\\Apparel\\Shirt')).toEqual('product:apparel:shirt');
13
+ expect(FlexPLMUtils.convertTypePath('Product\\Apparel\\[Shirt]')).toEqual('product:apparel:*shirt*');
14
+ expect(FlexPLMUtils.convertTypePath('')).toBeNull();
15
+ });
16
+ it('should compute level in tree', () => {
17
+ expect(FlexPLMUtils.computeLevelFromPath('product')).toEqual(1);
18
+ expect(FlexPLMUtils.computeLevelFromPath('product:apparel')).toEqual(2);
19
+ expect(FlexPLMUtils.computeLevelFromPath('product:apparel:dress:mini')).toEqual(4);
20
+ });
21
+ it('should get a parent type path', () => {
22
+ expect(FlexPLMUtils.getParentTypePath('product')).toBeNull();
23
+ expect(FlexPLMUtils.getParentTypePath('product:apparel')).toEqual('product');
24
+ expect(FlexPLMUtils.getParentTypePath('product:apparel:stuff')).toEqual('product:apparel');
25
+ expect(FlexPLMUtils.getParentTypePath('Product\\Apparel')).toEqual('product');
26
+ });
27
+ });
@@ -1,29 +1,29 @@
1
- export class FlexPLMUtils {
2
- static convertTypePath = (path: string): string => {
3
- if (!path) { return null; }
4
- let newPath = path;
5
- while (newPath.indexOf('\\') > 1) {
6
- newPath = newPath.replace('\\', ':');
7
- }
8
- while (newPath.indexOf('[') > 1) {
9
- newPath = newPath.replace('[', '*');
10
- }
11
- while (newPath.indexOf(']') > 1) {
12
- newPath = newPath.replace(']', '*');
13
- }
14
- while (newPath.indexOf(' ') > 1) {
15
- newPath = newPath.replace(' ', '_');
16
- }
17
- newPath = newPath.toLowerCase();
18
- return newPath;
19
- }
20
-
21
- static getParentTypePath = (path: string): string => {
22
- const newPath = FlexPLMUtils.convertTypePath(path);
23
- return (!newPath || newPath.indexOf(':') < 0) ? null : newPath.substring(0, newPath.lastIndexOf(':'));
24
- }
25
-
26
- static computeLevelFromPath(path: string) {
27
- return (path.match(/:/g) || []).length + 1;
28
- }
29
- }
1
+ export class FlexPLMUtils {
2
+ static convertTypePath = (path: string): string => {
3
+ if (!path) { return null; }
4
+ let newPath = path;
5
+ while (newPath.indexOf('\\') > 1) {
6
+ newPath = newPath.replace('\\', ':');
7
+ }
8
+ while (newPath.indexOf('[') > 1) {
9
+ newPath = newPath.replace('[', '*');
10
+ }
11
+ while (newPath.indexOf(']') > 1) {
12
+ newPath = newPath.replace(']', '*');
13
+ }
14
+ while (newPath.indexOf(' ') > 1) {
15
+ newPath = newPath.replace(' ', '_');
16
+ }
17
+ newPath = newPath.toLowerCase();
18
+ return newPath;
19
+ }
20
+
21
+ static getParentTypePath = (path: string): string => {
22
+ const newPath = FlexPLMUtils.convertTypePath(path);
23
+ return (!newPath || newPath.indexOf(':') < 0) ? null : newPath.substring(0, newPath.lastIndexOf(':'));
24
+ }
25
+
26
+ static computeLevelFromPath(path: string) {
27
+ return (path.match(/:/g) || []).length + 1;
28
+ }
29
+ }
package/src/index.ts CHANGED
@@ -1,22 +1,22 @@
1
- export * from './flexplm-request';
2
- export * from './flexplm-utils';
3
- export * from './util/config-defaults';
4
- export * from './util/data-converter';
5
- export * from './util/error-response-object';
6
- export * from './util/event-short-message-status';
7
- export * from './util/federation';
8
- export * from './util/flexplm-connect';
9
- export * from './interfaces/interfaces';
10
- export * from './util/logger-config';
11
- export * from './util/thumbnail-util';
12
- export * from './util/type-conversion-utils';
13
- export * from './util/type-defaults';
14
- export * from './util/type-utils';
15
- export * from './util/map-utils';
16
- export * from './interfaces/interfaces';
17
- export * from './interfaces/item-family-changes';
18
- export * from './interfaces/publish-change-data';
19
- export * from './publish/base-process-publish-assortment';
20
- export * from './publish/base-process-publish-assortment-callback';
21
- export * from './entity-processor/base-entity-processor';
1
+ export * from './flexplm-request';
2
+ export * from './flexplm-utils';
3
+ export * from './util/config-defaults';
4
+ export * from './util/data-converter';
5
+ export * from './util/error-response-object';
6
+ export * from './util/event-short-message-status';
7
+ export * from './util/federation';
8
+ export * from './util/flexplm-connect';
9
+ export * from './interfaces/interfaces';
10
+ export * from './util/logger-config';
11
+ export * from './util/thumbnail-util';
12
+ export * from './util/type-conversion-utils';
13
+ export * from './util/type-defaults';
14
+ export * from './util/type-utils';
15
+ export * from './util/map-utils';
16
+ export * from './interfaces/interfaces';
17
+ export * from './interfaces/item-family-changes';
18
+ export * from './interfaces/publish-change-data';
19
+ export * from './publish/base-process-publish-assortment';
20
+ export * from './publish/base-process-publish-assortment-callback';
21
+ export * from './entity-processor/base-entity-processor';
22
22
  export * from './transform/identifier-conversion';