@contrail/flexplm 1.2.1 → 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 (125) 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 +10 -0
  5. package/lib/entity-processor/base-entity-processor.d.ts +42 -42
  6. package/lib/entity-processor/base-entity-processor.js +385 -363
  7. package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -1
  8. package/lib/entity-processor/base-entity-processor.spec.js +397 -302
  9. package/lib/flexplm-request.d.ts +3 -3
  10. package/lib/flexplm-request.js +34 -34
  11. package/lib/flexplm-utils.d.ts +5 -5
  12. package/lib/flexplm-utils.js +33 -33
  13. package/lib/flexplm-utils.spec.d.ts +1 -1
  14. package/lib/flexplm-utils.spec.js +26 -26
  15. package/lib/index.d.ts +22 -22
  16. package/lib/index.js +38 -38
  17. package/lib/interfaces/interfaces.d.ts +105 -105
  18. package/lib/interfaces/interfaces.js +2 -2
  19. package/lib/interfaces/item-family-changes.d.ts +20 -20
  20. package/lib/interfaces/item-family-changes.js +56 -56
  21. package/lib/interfaces/publish-change-data.d.ts +19 -19
  22. package/lib/interfaces/publish-change-data.js +32 -32
  23. package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -9
  24. package/lib/publish/base-process-publish-assortment-callback.js +38 -38
  25. package/lib/publish/base-process-publish-assortment.d.ts +93 -93
  26. package/lib/publish/base-process-publish-assortment.js +944 -944
  27. package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -1
  28. package/lib/publish/base-process-publish-assortment.spec.js +1670 -1670
  29. package/lib/publish/mockData.d.ts +1389 -1389
  30. package/lib/publish/mockData.js +4519 -4519
  31. package/lib/transform/identifier-conversion-spec-mockData.js +444 -444
  32. package/lib/transform/identifier-conversion.d.ts +15 -15
  33. package/lib/transform/identifier-conversion.js +212 -212
  34. package/lib/transform/identifier-conversion.spec.d.ts +1 -1
  35. package/lib/transform/identifier-conversion.spec.js +339 -339
  36. package/lib/util/config-defaults.d.ts +8 -8
  37. package/lib/util/config-defaults.js +85 -85
  38. package/lib/util/config-defaults.spec.d.ts +1 -1
  39. package/lib/util/config-defaults.spec.js +293 -293
  40. package/lib/util/data-converter-spec-mockData.js +205 -205
  41. package/lib/util/data-converter.d.ts +39 -39
  42. package/lib/util/data-converter.js +592 -592
  43. package/lib/util/data-converter.spec.d.ts +1 -1
  44. package/lib/util/data-converter.spec.js +904 -904
  45. package/lib/util/error-response-object.d.ts +4 -4
  46. package/lib/util/error-response-object.js +47 -47
  47. package/lib/util/error-response-object.spec.d.ts +1 -1
  48. package/lib/util/error-response-object.spec.js +99 -99
  49. package/lib/util/event-short-message-status.d.ts +19 -18
  50. package/lib/util/event-short-message-status.js +23 -22
  51. package/lib/util/federation.d.ts +15 -15
  52. package/lib/util/federation.js +149 -149
  53. package/lib/util/flexplm-connect.d.ts +22 -18
  54. package/lib/util/flexplm-connect.js +176 -171
  55. package/lib/util/flexplm-connect.spec.d.ts +1 -0
  56. package/lib/util/flexplm-connect.spec.js +88 -0
  57. package/lib/util/logger-config.d.ts +1 -1
  58. package/lib/util/logger-config.js +26 -26
  59. package/lib/util/map-util-spec-mockData.js +205 -205
  60. package/lib/util/map-utils.d.ts +6 -6
  61. package/lib/util/map-utils.js +15 -15
  62. package/lib/util/map-utils.spec.d.ts +1 -1
  63. package/lib/util/map-utils.spec.js +89 -89
  64. package/lib/util/mockData.d.ts +80 -79
  65. package/lib/util/mockData.js +103 -99
  66. package/lib/util/thumbnail-util.d.ts +34 -19
  67. package/lib/util/thumbnail-util.js +215 -114
  68. package/lib/util/thumbnail-util.spec.d.ts +1 -1
  69. package/lib/util/thumbnail-util.spec.js +434 -242
  70. package/lib/util/type-conversion-utils-spec-mockData.js +259 -241
  71. package/lib/util/type-conversion-utils.d.ts +23 -21
  72. package/lib/util/type-conversion-utils.js +265 -223
  73. package/lib/util/type-conversion-utils.spec.d.ts +1 -1
  74. package/lib/util/type-conversion-utils.spec.js +868 -708
  75. package/lib/util/type-defaults.d.ts +16 -16
  76. package/lib/util/type-defaults.js +221 -221
  77. package/lib/util/type-defaults.spec.d.ts +1 -1
  78. package/lib/util/type-defaults.spec.js +516 -516
  79. package/lib/util/type-utils.d.ts +13 -13
  80. package/lib/util/type-utils.js +114 -114
  81. package/lib/util/type-utils.spec.d.ts +1 -1
  82. package/lib/util/type-utils.spec.js +190 -190
  83. package/package.json +1 -1
  84. package/publish.bat +4 -4
  85. package/publish.sh +4 -4
  86. package/src/entity-processor/base-entity-processor.spec.ts +122 -0
  87. package/src/entity-processor/base-entity-processor.ts +31 -2
  88. package/src/flexplm-request.ts +28 -28
  89. package/src/flexplm-utils.spec.ts +27 -27
  90. package/src/flexplm-utils.ts +29 -29
  91. package/src/index.ts +21 -21
  92. package/src/interfaces/item-family-changes.ts +66 -66
  93. package/src/interfaces/publish-change-data.ts +42 -42
  94. package/src/publish/base-process-publish-assortment-callback.ts +50 -50
  95. package/src/transform/identifier-conversion-spec-mockData.ts +495 -495
  96. package/src/transform/identifier-conversion.spec.ts +353 -353
  97. package/src/transform/identifier-conversion.ts +281 -281
  98. package/src/util/config-defaults.spec.ts +350 -350
  99. package/src/util/config-defaults.ts +92 -92
  100. package/src/util/data-converter-spec-mockData.ts +230 -230
  101. package/src/util/error-response-object.spec.ts +115 -115
  102. package/src/util/error-response-object.ts +49 -49
  103. package/src/util/event-short-message-status.ts +1 -0
  104. package/src/util/federation.ts +172 -172
  105. package/src/util/flexplm-connect.spec.ts +132 -0
  106. package/src/util/flexplm-connect.ts +14 -5
  107. package/src/util/logger-config.ts +19 -19
  108. package/src/util/map-util-spec-mockData.ts +230 -230
  109. package/src/util/map-utils.spec.ts +102 -102
  110. package/src/util/map-utils.ts +40 -40
  111. package/src/util/mockData.ts +101 -97
  112. package/src/util/thumbnail-util.spec.ts +239 -0
  113. package/src/util/thumbnail-util.ts +140 -5
  114. package/src/util/type-conversion-utils-spec-mockData.ts +18 -0
  115. package/src/util/type-conversion-utils.spec.ts +184 -0
  116. package/src/util/type-conversion-utils.ts +75 -1
  117. package/src/util/type-defaults.spec.ts +668 -668
  118. package/src/util/type-defaults.ts +280 -280
  119. package/src/util/type-utils.spec.ts +227 -227
  120. package/src/util/type-utils.ts +144 -144
  121. package/tsconfig.json +23 -26
  122. package/tslint.json +57 -57
  123. package/.claude/settings.local.json +0 -8
  124. package/scripts/output.png +0 -0
  125. package/scripts/test-get-request.ts +0 -35
@@ -1,41 +1,41 @@
1
- import { MapFileUtil } from '@contrail/transform-data';
2
- export class MapUtil {
3
- /** Transforms the data, assumes mapSectionKey has been correctly determined.
4
- *
5
- * @param transformMapFile id of map file
6
- * @param mapFileUtil
7
- * @param data
8
- * @param mapSectionKey key for section of map file
9
- * @param direction vibe2flex or flex2vibe
10
- * @param transformTaskOrderKey key for the list of tasks to be processed. default is 'transformOrder'
11
- * @returns The converted data
12
- */
13
- static async applyTransformMap(transformMapFile, mapFileUtil, data: any, mapSectionKey: string, direction: string, transformTaskOrderKey: string = 'transformOrder'): Promise<any> {
14
- return await mapFileUtil.applyTransformMap(transformMapFile, data, mapSectionKey, direction, transformTaskOrderKey);
15
- }
16
-
17
- /** Returns the mapKey based on the 'typeConversion' section of the map file.
18
- * If the map file doesn't have a section for the type in question, 'undefined' is returned.
19
- *
20
- * @param fileId
21
- * @param mapFileUtil
22
- * @param data The full object
23
- * @param type The entity or object class of the object. The functions are keyed based on this.
24
- * @param direction
25
- * @returns
26
- */
27
- static async getMapKey(transformMapFile, mapFileUtil: MapFileUtil, data: any, type: string, direction: string): Promise<string> {
28
- return await mapFileUtil.getMapKey(transformMapFile, data, type, direction);
29
- }
30
-
31
- /** Returns the full map section with both directions; identifier and informational properties; etc.
32
- *
33
- * @param transformMapFile id if map file
34
- * @param mapFileUtil
35
- * @param mapSectionKey key of the map section
36
- * @returns
37
- */
38
- static async getFullMapSection(transformMapFile: string, mapFileUtil: MapFileUtil, mapSectionKey: string):Promise<any> {
39
- return await mapFileUtil.getFullMapSection(transformMapFile, mapSectionKey);
40
- }
1
+ import { MapFileUtil } from '@contrail/transform-data';
2
+ export class MapUtil {
3
+ /** Transforms the data, assumes mapSectionKey has been correctly determined.
4
+ *
5
+ * @param transformMapFile id of map file
6
+ * @param mapFileUtil
7
+ * @param data
8
+ * @param mapSectionKey key for section of map file
9
+ * @param direction vibe2flex or flex2vibe
10
+ * @param transformTaskOrderKey key for the list of tasks to be processed. default is 'transformOrder'
11
+ * @returns The converted data
12
+ */
13
+ static async applyTransformMap(transformMapFile, mapFileUtil, data: any, mapSectionKey: string, direction: string, transformTaskOrderKey: string = 'transformOrder'): Promise<any> {
14
+ return await mapFileUtil.applyTransformMap(transformMapFile, data, mapSectionKey, direction, transformTaskOrderKey);
15
+ }
16
+
17
+ /** Returns the mapKey based on the 'typeConversion' section of the map file.
18
+ * If the map file doesn't have a section for the type in question, 'undefined' is returned.
19
+ *
20
+ * @param fileId
21
+ * @param mapFileUtil
22
+ * @param data The full object
23
+ * @param type The entity or object class of the object. The functions are keyed based on this.
24
+ * @param direction
25
+ * @returns
26
+ */
27
+ static async getMapKey(transformMapFile, mapFileUtil: MapFileUtil, data: any, type: string, direction: string): Promise<string> {
28
+ return await mapFileUtil.getMapKey(transformMapFile, data, type, direction);
29
+ }
30
+
31
+ /** Returns the full map section with both directions; identifier and informational properties; etc.
32
+ *
33
+ * @param transformMapFile id if map file
34
+ * @param mapFileUtil
35
+ * @param mapSectionKey key of the map section
36
+ * @returns
37
+ */
38
+ static async getFullMapSection(transformMapFile: string, mapFileUtil: MapFileUtil, mapSectionKey: string):Promise<any> {
39
+ return await mapFileUtil.getFullMapSection(transformMapFile, mapSectionKey);
40
+ }
41
41
  }
@@ -1,97 +1,101 @@
1
- export const empty_custom_sizes = [];
2
- export const four_custom_sizes = [
3
- {
4
- size: 1000,
5
- id: '-QwFOWnCs0Gb5jkA',
6
- slug: 'CS_1000'
7
- },
8
- {
9
- size: 300,
10
- id: 'AKXOowvhJRnkerG8',
11
- slug: 'CS_300'
12
- },
13
- {
14
- size: 500,
15
- id: '9asQ65N188RIYgnh',
16
- slug: 'CS_500'
17
- },
18
- {
19
- size: 800,
20
- id: 'xkzhwE4nJ6iRwfvP',
21
- slug: 'CS_800'
22
- }
23
- ];
24
-
25
- export const thumbnail_content_entity = {
26
- fileName: 'JACKET 300_SOLDIER OLIVE.png',
27
- primaryFileId: 'yn2d5oHD4rXHRzyB',
28
- primaryFileUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Ff646d3cd-e23a-4689-bd16-0301d2036720.png',
29
- primaryFile: {
30
- fileName: 'JACKET 300_SOLDIER OLIVE.png',
31
- id: 'yn2d5oHD4rXHRzyB',
32
- size: 1757973
33
- },
34
- tinyViewableId: '6HWzJrQ-Jx1iefmj',
35
- tinyViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb68f8652-f33f-452f-ae34-25397b4521eb.png',
36
- tinyViewable: {
37
- fileName: 'JACKET 300_SOLDIER OLIVE_tiny.png',
38
- id: '6HWzJrQ-Jx1iefmj',
39
- size: 1784
40
- },
41
- smallViewableId: 'D3WRW4iRmjLzp5VX',
42
- smallViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F541c53f8-fd85-418e-ae28-ad7410658b90.png',
43
- smallViewable: {
44
- fileName: 'JACKET 300_SOLDIER OLIVE_small.png',
45
- id: 'D3WRW4iRmjLzp5VX',
46
- size: 8699
47
- },
48
- mediumViewableId: 'AsRvJenpeqxksUNW',
49
- mediumViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fe803c2d3-3e1b-4d9c-9bb9-2c488f1f295b.png',
50
- mediumViewable: {
51
- fileName: 'JACKET 300_SOLDIER OLIVE_medium.png',
52
- id: 'AsRvJenpeqxksUNW',
53
- size: 77558
54
- },
55
- largeViewableId: 'vo4N4mCd-tFrw101',
56
- largeViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb1b7a55c-b8ba-4857-be4e-e1c3f11d8e9a.png',
57
- largeViewable: {
58
- fileName: 'JACKET 300_SOLDIER OLIVE_large.png',
59
- id: 'vo4N4mCd-tFrw101',
60
- size: 1781538
61
- },
62
- CS_300Id: '6A5AG33nVu3Z6ogO',
63
- CS_300Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F3f2ea306-a77f-4cc3-a49a-75fb5d8b113c.png',
64
- CS_300: {
65
- fileName: 'JACKET 300_SOLDIER OLIVE_CS_300.png',
66
- id: '6A5AG33nVu3Z6ogO',
67
- size: 141153
68
- },
69
- CS_500Id: 'rBaHc1J2xdOWdbhI',
70
- CS_500Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F979c8c65-b63f-4220-aa2e-11520f2f68bf.png',
71
- CS_500: {
72
- fileName: 'JACKET 300_SOLDIER OLIVE_CS_500.png',
73
- id: 'rBaHc1J2xdOWdbhI',
74
- size: 382057
75
- },
76
- CS_800Id: 'ZPAeYI3JiqjQ7unY',
77
- CS_800Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fc58eeffa-2592-4698-a058-19281cda447c.png',
78
- CS_800:{
79
- fileName: 'JACKET 300_SOLDIER OLIVE_CS_800.png',
80
- id: 'ZPAeYI3JiqjQ7unY',
81
- size: 1008702
82
- },
83
- CS_1000Id: 'Hg_CthwsD4ozopCb',
84
- CS_1000Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F2c827c7b-361b-4e05-b77d-4280294f9d9c.png',
85
- CS_1000: {
86
- fileName: 'JACKET 300_SOLDIER OLIVE_CS_1000.png',
87
- id: 'Hg_CthwsD4ozopCb',
88
- size: 1605889
89
- },
90
- createdOn: '2023-07-05T15:02:13.950Z',
91
- orgId: '5LZnKVTNxvwMqufy',
92
- id: 'cuRficeyoStwTF-f',
93
- contentType: 'image/png',
94
- createdById: 'SWIFPZeZzkBvrSLD',
95
- updatedById: 'SWIFPZeZzkBvrSLD',
96
- fileSize: 1757973
97
- };
1
+ export const empty_custom_sizes = [];
2
+ export const four_custom_sizes = [
3
+ {
4
+ size: 1000,
5
+ id: '-QwFOWnCs0Gb5jkA',
6
+ slug: 'CS_1000',
7
+ name: 'CS_1000'
8
+ },
9
+ {
10
+ size: 300,
11
+ id: 'AKXOowvhJRnkerG8',
12
+ slug: 'CS_300',
13
+ name: 'CS_300'
14
+ },
15
+ {
16
+ size: 500,
17
+ id: '9asQ65N188RIYgnh',
18
+ slug: 'CS_500',
19
+ name: 'CS_500'
20
+ },
21
+ {
22
+ size: 800,
23
+ id: 'xkzhwE4nJ6iRwfvP',
24
+ slug: 'CS_800',
25
+ name: 'CS_800'
26
+ }
27
+ ];
28
+
29
+ export const thumbnail_content_entity = {
30
+ fileName: 'JACKET 300_SOLDIER OLIVE.png',
31
+ primaryFileId: 'yn2d5oHD4rXHRzyB',
32
+ primaryFileUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Ff646d3cd-e23a-4689-bd16-0301d2036720.png',
33
+ primaryFile: {
34
+ fileName: 'JACKET 300_SOLDIER OLIVE.png',
35
+ id: 'yn2d5oHD4rXHRzyB',
36
+ size: 1757973
37
+ },
38
+ tinyViewableId: '6HWzJrQ-Jx1iefmj',
39
+ tinyViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb68f8652-f33f-452f-ae34-25397b4521eb.png',
40
+ tinyViewable: {
41
+ fileName: 'JACKET 300_SOLDIER OLIVE_tiny.png',
42
+ id: '6HWzJrQ-Jx1iefmj',
43
+ size: 1784
44
+ },
45
+ smallViewableId: 'D3WRW4iRmjLzp5VX',
46
+ smallViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F541c53f8-fd85-418e-ae28-ad7410658b90.png',
47
+ smallViewable: {
48
+ fileName: 'JACKET 300_SOLDIER OLIVE_small.png',
49
+ id: 'D3WRW4iRmjLzp5VX',
50
+ size: 8699
51
+ },
52
+ mediumViewableId: 'AsRvJenpeqxksUNW',
53
+ mediumViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fe803c2d3-3e1b-4d9c-9bb9-2c488f1f295b.png',
54
+ mediumViewable: {
55
+ fileName: 'JACKET 300_SOLDIER OLIVE_medium.png',
56
+ id: 'AsRvJenpeqxksUNW',
57
+ size: 77558
58
+ },
59
+ largeViewableId: 'vo4N4mCd-tFrw101',
60
+ largeViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb1b7a55c-b8ba-4857-be4e-e1c3f11d8e9a.png',
61
+ largeViewable: {
62
+ fileName: 'JACKET 300_SOLDIER OLIVE_large.png',
63
+ id: 'vo4N4mCd-tFrw101',
64
+ size: 1781538
65
+ },
66
+ CS_300Id: '6A5AG33nVu3Z6ogO',
67
+ CS_300Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F3f2ea306-a77f-4cc3-a49a-75fb5d8b113c.png',
68
+ CS_300: {
69
+ fileName: 'JACKET 300_SOLDIER OLIVE_CS_300.png',
70
+ id: '6A5AG33nVu3Z6ogO',
71
+ size: 141153
72
+ },
73
+ CS_500Id: 'rBaHc1J2xdOWdbhI',
74
+ CS_500Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F979c8c65-b63f-4220-aa2e-11520f2f68bf.png',
75
+ CS_500: {
76
+ fileName: 'JACKET 300_SOLDIER OLIVE_CS_500.png',
77
+ id: 'rBaHc1J2xdOWdbhI',
78
+ size: 382057
79
+ },
80
+ CS_800Id: 'ZPAeYI3JiqjQ7unY',
81
+ CS_800Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fc58eeffa-2592-4698-a058-19281cda447c.png',
82
+ CS_800:{
83
+ fileName: 'JACKET 300_SOLDIER OLIVE_CS_800.png',
84
+ id: 'ZPAeYI3JiqjQ7unY',
85
+ size: 1008702
86
+ },
87
+ CS_1000Id: 'Hg_CthwsD4ozopCb',
88
+ CS_1000Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F2c827c7b-361b-4e05-b77d-4280294f9d9c.png',
89
+ CS_1000: {
90
+ fileName: 'JACKET 300_SOLDIER OLIVE_CS_1000.png',
91
+ id: 'Hg_CthwsD4ozopCb',
92
+ size: 1605889
93
+ },
94
+ createdOn: '2023-07-05T15:02:13.950Z',
95
+ orgId: '5LZnKVTNxvwMqufy',
96
+ id: 'cuRficeyoStwTF-f',
97
+ contentType: 'image/png',
98
+ createdById: 'SWIFPZeZzkBvrSLD',
99
+ updatedById: 'SWIFPZeZzkBvrSLD',
100
+ fileSize: 1757973
101
+ };
@@ -3,6 +3,33 @@ import { ThumbnailUtil } from './thumbnail-util';
3
3
 
4
4
  import { empty_custom_sizes, four_custom_sizes, thumbnail_content_entity } from './mockData';
5
5
 
6
+ const mockEntitiesGet = jest.fn();
7
+ const mockEntitiesUpdate = jest.fn();
8
+ const mockEntitiesDelete = jest.fn();
9
+ const mockContentCreate = jest.fn();
10
+
11
+ jest.mock('@contrail/sdk', () => {
12
+ return {
13
+ Entities: jest.fn().mockImplementation(() => ({
14
+ get: mockEntitiesGet,
15
+ update: mockEntitiesUpdate,
16
+ delete: mockEntitiesDelete,
17
+ })),
18
+ Content: jest.fn().mockImplementation(() => ({
19
+ create: mockContentCreate,
20
+ })),
21
+ };
22
+ });
23
+
24
+ const mockGetRequest = jest.fn();
25
+ jest.mock('./flexplm-connect', () => {
26
+ return {
27
+ FlexPLMConnect: jest.fn().mockImplementation(() => ({
28
+ getRequest: mockGetRequest,
29
+ })),
30
+ };
31
+ });
32
+
6
33
  describe('ThumbnailUtil Tests', () =>{
7
34
  const config = {} as FCConfig;
8
35
  describe('setOutboundThumbnail()', () =>{
@@ -266,4 +293,216 @@ describe('ThumbnailUtil Tests', () =>{
266
293
  });
267
294
 
268
295
  });
296
+
297
+ describe('syncThumbnailToVibeIQ', () => {
298
+ let tu: ThumbnailUtil;
299
+
300
+ beforeEach(() => {
301
+ jest.clearAllMocks();
302
+ tu = new ThumbnailUtil(config);
303
+ mockEntitiesGet.mockImplementation((opts) => {
304
+ if (opts.entityName === 'content-custom-size') return Promise.resolve([]);
305
+ return Promise.resolve({});
306
+ });
307
+ mockEntitiesUpdate.mockImplementation((opts) => Promise.resolve({ id: opts.id }));
308
+ mockEntitiesDelete.mockImplementation((opts) => Promise.resolve({ id: opts.id }));
309
+ });
310
+
311
+ it('does not update when no thumbnail IDs in event data', async () => {
312
+ const event = { data: {} };
313
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'color' });
314
+
315
+ expect(mockEntitiesUpdate).not.toHaveBeenCalled();
316
+ expect(mockEntitiesDelete).not.toHaveBeenCalled();
317
+ expect(mockContentCreate).not.toHaveBeenCalled();
318
+ });
319
+
320
+ it('does not update when event.data is undefined', async () => {
321
+ const event = {};
322
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'color' });
323
+
324
+ expect(mockEntitiesUpdate).not.toHaveBeenCalled();
325
+ expect(mockEntitiesDelete).not.toHaveBeenCalled();
326
+ });
327
+
328
+ it('REMOVE_THUMBNAIL with existing primaryViewableId deletes content and updates entity', async () => {
329
+ const event = { data: { [ThumbnailUtil.NEW_THUMBNAIL_ID]: ThumbnailUtil.REMOVE_THUMBNAIL } };
330
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', primaryViewableId: 'pv1', event, entityName: 'color' });
331
+
332
+ expect(mockEntitiesDelete).toHaveBeenCalledWith({ entityName: 'content', id: 'pv1' });
333
+ expect(mockEntitiesUpdate).toHaveBeenCalledWith(expect.objectContaining({ entityName: 'color', id: 'entity1' }));
334
+ });
335
+
336
+ it('REMOVE_THUMBNAIL with no primaryViewableId updates entity without deleting', async () => {
337
+ const event = { data: { [ThumbnailUtil.NEW_THUMBNAIL_ID]: ThumbnailUtil.REMOVE_THUMBNAIL } };
338
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'item' });
339
+
340
+ expect(mockEntitiesDelete).not.toHaveBeenCalled();
341
+ expect(mockEntitiesUpdate).toHaveBeenCalledWith(expect.objectContaining({ entityName: 'item', id: 'entity1' }));
342
+ });
343
+
344
+ it('creates new content when no primaryViewableId exists and updates entity', async () => {
345
+ const mockResponse = {
346
+ arrayBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(8)),
347
+ headers: { get: jest.fn().mockReturnValue('image/png') },
348
+ };
349
+ mockGetRequest.mockResolvedValue(mockResponse);
350
+
351
+ const createdContent = {
352
+ id: 'newContent1',
353
+ contentType: 'image/png',
354
+ fileName: 'thumb.png',
355
+ primaryFileUrl: 'https://files/primary.png',
356
+ largeViewableUrl: 'https://files/large.png',
357
+ mediumLargeViewableUrl: null,
358
+ mediumViewableUrl: null,
359
+ smallViewableUrl: null,
360
+ tinyViewableUrl: null,
361
+ };
362
+ mockContentCreate.mockResolvedValue(createdContent);
363
+
364
+ const event = { data: { [ThumbnailUtil.NEW_THUMBNAIL_ID]: '/rest/thumbnail/thumb.png' } };
365
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'color' });
366
+
367
+ expect(mockGetRequest).toHaveBeenCalledWith({ urlPath: '/rest/thumbnail/thumb.png', includeUrlContext: false, returnFullResponse: true });
368
+ expect(mockContentCreate).toHaveBeenCalledWith(
369
+ expect.objectContaining({
370
+ fileName: 'thumb.png',
371
+ contentType: 'image/png',
372
+ contentHolderReference: 'color:entity1',
373
+ }),
374
+ );
375
+ // Updates content with flexplmThumbnailUrl
376
+ expect(mockEntitiesUpdate).toHaveBeenCalledWith(
377
+ expect.objectContaining({
378
+ entityName: 'content',
379
+ id: 'newContent1',
380
+ object: { flexplmThumbnailUrl: '/rest/thumbnail/thumb.png' },
381
+ }),
382
+ );
383
+ // Updates the main entity
384
+ expect(mockEntitiesUpdate).toHaveBeenCalledWith(
385
+ expect.objectContaining({
386
+ entityName: 'color',
387
+ id: 'entity1',
388
+ }),
389
+ );
390
+ });
391
+
392
+ it('encodes URL path segments with special characters', async () => {
393
+ const mockResponse = {
394
+ arrayBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(8)),
395
+ headers: { get: jest.fn().mockReturnValue('image/png') },
396
+ };
397
+ mockGetRequest.mockResolvedValue(mockResponse);
398
+ mockContentCreate.mockResolvedValue({
399
+ id: 'c1', contentType: 'image/png', fileName: 'my image.png',
400
+ primaryFileUrl: 'https://files/primary.png', largeViewableUrl: null,
401
+ mediumLargeViewableUrl: null, mediumViewableUrl: null, smallViewableUrl: null, tinyViewableUrl: null,
402
+ });
403
+
404
+ const event = { data: { [ThumbnailUtil.NEW_THUMBNAIL_ID]: '/rest/thumbnail/my image.png' } };
405
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'color' });
406
+
407
+ expect(mockGetRequest).toHaveBeenCalledWith({
408
+ urlPath: '/rest/thumbnail/my%20image.png',
409
+ includeUrlContext: false,
410
+ returnFullResponse: true,
411
+ });
412
+ expect(mockContentCreate).toHaveBeenCalledWith(
413
+ expect.objectContaining({ fileName: 'my image.png' }),
414
+ );
415
+ });
416
+
417
+ it('encodes URL path segments with unicode characters', async () => {
418
+ const mockResponse = {
419
+ arrayBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(8)),
420
+ headers: { get: jest.fn().mockReturnValue('image/jpeg') },
421
+ };
422
+ mockGetRequest.mockResolvedValue(mockResponse);
423
+ mockContentCreate.mockResolvedValue({
424
+ id: 'c2', contentType: 'image/jpeg', fileName: 'café-logo.jpg',
425
+ primaryFileUrl: 'https://files/primary.jpg', largeViewableUrl: null,
426
+ mediumLargeViewableUrl: null, mediumViewableUrl: null, smallViewableUrl: null, tinyViewableUrl: null,
427
+ });
428
+
429
+ const event = { data: { [ThumbnailUtil.NEW_THUMBNAIL_ID]: '/rest/thumbnail/café-logo.jpg' } };
430
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', event, entityName: 'item' });
431
+
432
+ expect(mockGetRequest).toHaveBeenCalledWith({
433
+ urlPath: '/rest/thumbnail/caf%C3%A9-logo.jpg',
434
+ includeUrlContext: false,
435
+ returnFullResponse: true,
436
+ });
437
+ expect(mockContentCreate).toHaveBeenCalledWith(
438
+ expect.objectContaining({ fileName: 'café-logo.jpg' }),
439
+ );
440
+ });
441
+
442
+ it('replaces content when primaryViewable.flexplmThumbnailUrl differs and updates entity', async () => {
443
+ mockEntitiesGet.mockImplementation((opts) => {
444
+ if (opts.entityName === 'content-custom-size') return Promise.resolve([]);
445
+ if (opts.entityName === 'content' && opts.id === 'oldPv') {
446
+ return Promise.resolve({ id: 'oldPv', flexplmThumbnailUrl: '/rest/thumbnail/old.png' });
447
+ }
448
+ return Promise.resolve({});
449
+ });
450
+
451
+ const mockResponse = {
452
+ arrayBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(8)),
453
+ headers: { get: jest.fn().mockReturnValue('image/jpeg') },
454
+ };
455
+ mockGetRequest.mockResolvedValue(mockResponse);
456
+
457
+ const createdContent = {
458
+ id: 'newContent2',
459
+ contentType: 'image/jpeg',
460
+ fileName: 'new.jpg',
461
+ primaryFileUrl: 'https://files/new-primary.jpg',
462
+ largeViewableUrl: null,
463
+ mediumLargeViewableUrl: null,
464
+ mediumViewableUrl: null,
465
+ smallViewableUrl: null,
466
+ tinyViewableUrl: null,
467
+ };
468
+ mockContentCreate.mockResolvedValue(createdContent);
469
+
470
+ const event = { data: { [ThumbnailUtil.NEW_THUMBNAIL_ID]: '/rest/thumbnail/new.jpg' } };
471
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', primaryViewableId: 'oldPv', event, entityName: 'item' });
472
+
473
+ // Creates new content
474
+ expect(mockContentCreate).toHaveBeenCalled();
475
+ // Updates new content with flexplmThumbnailUrl
476
+ expect(mockEntitiesUpdate).toHaveBeenCalledWith(
477
+ expect.objectContaining({
478
+ entityName: 'content',
479
+ id: 'newContent2',
480
+ object: { flexplmThumbnailUrl: '/rest/thumbnail/new.jpg' },
481
+ }),
482
+ );
483
+ // Updates the main entity
484
+ expect(mockEntitiesUpdate).toHaveBeenCalledWith(
485
+ expect.objectContaining({ entityName: 'item', id: 'entity1' }),
486
+ );
487
+ // Deletes old content
488
+ expect(mockEntitiesDelete).toHaveBeenCalledWith({ entityName: 'content', id: 'oldPv' });
489
+ });
490
+
491
+ it('does not update when primaryViewable.flexplmThumbnailUrl matches', async () => {
492
+ const thumbnailUrl = '/rest/thumbnail/same.png';
493
+ mockEntitiesGet.mockImplementation((opts) => {
494
+ if (opts.entityName === 'content-custom-size') return Promise.resolve([]);
495
+ if (opts.entityName === 'content' && opts.id === 'pv1') {
496
+ return Promise.resolve({ id: 'pv1', flexplmThumbnailUrl: thumbnailUrl });
497
+ }
498
+ return Promise.resolve({});
499
+ });
500
+
501
+ const event = { data: { [ThumbnailUtil.EXISTING_THUMBNAIL_ID]: thumbnailUrl } };
502
+ await tu.syncThumbnailToVibeIQ({ entityId: 'entity1', primaryViewableId: 'pv1', event, entityName: 'color' });
503
+ expect(mockContentCreate).not.toHaveBeenCalled();
504
+ expect(mockEntitiesUpdate).not.toHaveBeenCalled();
505
+ expect(mockEntitiesDelete).not.toHaveBeenCalled();
506
+ });
507
+ });
269
508
  });