@contrail/flexplm 1.3.0 → 1.3.1-alpha.585afc1

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 +219 -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 +18 -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 +429 -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,354 +0,0 @@
1
- import { MapFileUtil } from "@contrail/transform-data";
2
- import { IdentifierConversion } from "./identifier-conversion";
3
- import { DataConverter } from "../util/data-converter";
4
- import { FCConfig } from "../interfaces/interfaces";
5
- import { Entities } from "@contrail/sdk";
6
-
7
- const mapFile1Data = require('./identifier-conversion-spec-mockData');
8
- const mapFile1Mappings = mapFile1Data?.mapping;
9
- const mapFile2Mappings = mapFile1Data?.mapping2;
10
- const mappings = {
11
- mapFile1: mapFile1Mappings,
12
- mapFile2: mapFile2Mappings
13
- };
14
-
15
- describe('getAssortmentFromObject', () => {
16
- const transformMapFile1 = 'mapFile1';
17
- const transformMapFile2 = 'mapFile2';
18
- const config = {} as FCConfig;
19
- const mapFileUtil = new MapFileUtil(new Entities());
20
- mapFileUtil.getMapFile = async (fileId: string) => {
21
- return mappings[fileId];
22
- };
23
- const dc = new DataConverter(config, mapFileUtil);
24
- dc.getEntityValues = async (objectClass: string, data: any, keysToSkip: string[] = []) => {
25
- const entityValues = {};
26
- for (const key of Object.keys(data)) {
27
- const value = data[key];
28
- if (value) {
29
- const to = typeof value;
30
- if (['string', 'number', 'boolean'].includes(to)) {
31
- entityValues[key] = value;
32
- } else if (Array.isArray(value)) {
33
- //multi select
34
- entityValues[key] = value.map((v) => v.value);
35
- } else if (value.value) {
36
- //single select
37
- entityValues[key] = value.value;
38
- }
39
- }
40
- }
41
- return entityValues;
42
- };
43
-
44
- it('should error if no object is provided', async () => {
45
- try {
46
- await IdentifierConversion.getAssortmentCriteriaFromObject(transformMapFile1, mapFileUtil, dc, null);
47
- } catch (e) {
48
- expect(e.message).toEqual(expect.stringContaining(IdentifierConversion.MISSING_OBJECT));
49
- }
50
- });
51
-
52
- it('should error if no flexPLMObjectClass is provided', async () => {
53
- try {
54
- await IdentifierConversion.getAssortmentCriteriaFromObject(transformMapFile1, mapFileUtil, dc, {});
55
- } catch (e) {
56
- expect(e.message).toEqual(expect.stringContaining(IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS));
57
- }
58
- });
59
-
60
- it('should return the assortment criteria from the object - flexPLMSeasonName', async () => {
61
- const object = {
62
- "brand": {
63
- "display": "Vibe IQ",
64
- "value": "vibeiq"
65
- },
66
- "flexPLMObjectClass": "LCSSeason",
67
- "flexPLMTypePath": "Season",
68
- "seasonName": "Vibe IQ Spring 2004",
69
- "seasonType": {
70
- "display": "Spring",
71
- "value": "spring"
72
- },
73
- "year": {
74
- "display": "2004",
75
- "value": "2004"
76
- }
77
- };
78
- const criteriaObject = {
79
- flexPLMObjectClass: 'LCSSeason',
80
- flexPLMSeasonName: 'Vibe IQ Spring 2004',
81
- flexPLMTypePath: 'Season'
82
- };
83
- const resultsObject = {
84
- flexPLMSeasonName: 'Vibe IQ Spring 2004'
85
- };
86
- let getEntityValuesSpyOn = undefined
87
- try {
88
-
89
- getEntityValuesSpyOn = jest.spyOn(dc, 'getEntityValues');
90
- const result = await IdentifierConversion.getAssortmentCriteriaFromObject(transformMapFile1, mapFileUtil, dc, object);
91
- expect(getEntityValuesSpyOn).toHaveBeenCalledWith('LCSSeason', criteriaObject, []);
92
- expect(result).toEqual(resultsObject);
93
- } finally {
94
- if (getEntityValuesSpyOn) {
95
- getEntityValuesSpyOn.mockRestore();
96
- }
97
- }
98
- });
99
-
100
- it('should return the assortment criteria from the object - brand,year,seasonType', async () => {
101
- const object = {
102
- brand: {
103
- display: "Vibe IQ",
104
- value: "vibeiq"
105
- },
106
- flexPLMObjectClass: "LCSSeason",
107
- flexPLMTypePath: "Season",
108
- seasonName: "Vibe IQ Spring 2004",
109
- seasonType: {
110
- display: "Spring",
111
- value: "spring"
112
- },
113
- year: {
114
- "display": "2004",
115
- "value": "2004"
116
- }
117
- };
118
- const criteriaObject = {
119
- flexPLMObjectClass: 'LCSSeason',
120
- brand: {
121
- "display": "Vibe IQ",
122
- "value": "vibeiq"
123
- },
124
- year: {
125
- "display": "2004",
126
- "value": "2004"
127
- },
128
- seasonType: {
129
- "display": "Spring",
130
- "value": "spring"
131
- },
132
- flexPLMTypePath: 'Season'
133
- };
134
- const resultsObject = {
135
- brand: 'vibeiq',
136
- year: '2004',
137
- seasonType: 'spring'
138
- };
139
- let getEntityValuesSpyOn = undefined
140
- try {
141
-
142
- getEntityValuesSpyOn = jest.spyOn(dc, 'getEntityValues');
143
- const result = await IdentifierConversion.getAssortmentCriteriaFromObject(transformMapFile2, mapFileUtil, dc, object);
144
- expect(getEntityValuesSpyOn).toHaveBeenCalledWith('LCSSeason', criteriaObject, []);
145
- expect(result).toEqual(resultsObject);
146
- } finally {
147
- if (getEntityValuesSpyOn) {
148
- getEntityValuesSpyOn.mockRestore();
149
- }
150
- }
151
- });
152
-
153
- });
154
-
155
- describe('getItemCriteriaFromObject', () => {
156
- const transformMapFile1 = 'mapFile1';
157
- const transformMapFile2 = 'mapFile2';
158
- const config = {} as FCConfig;
159
- const mapFileUtil = new MapFileUtil(new Entities());
160
- mapFileUtil.getMapFile = async (fileId: string) => {
161
- return mappings[fileId];
162
- };
163
- const dc = new DataConverter(config, mapFileUtil);
164
- dc.getEntityValues = async (objectClass: string, data: any, keysToSkip: string[] = []) => {
165
- const entityValues = {};
166
- for (const key of Object.keys(data)) {
167
- const value = data[key];
168
- if (value) {
169
- const to = typeof value;
170
- if (['string', 'number', 'boolean'].includes(to)) {
171
- entityValues[key] = value;
172
- } else if (Array.isArray(value)) {
173
- //multi select
174
- entityValues[key] = value.map((v) => v.value);
175
- } else if (value.value) {
176
- //single select
177
- entityValues[key] = value.value;
178
- }
179
- }
180
- }
181
- return entityValues;
182
- };
183
-
184
- it('should error if no object is provided', async () => {
185
- try {
186
- await IdentifierConversion.getItemCriteriaFromObject(transformMapFile1, mapFileUtil, dc, null);
187
- } catch (e) {
188
- expect(e.message).toEqual(expect.stringContaining(IdentifierConversion.MISSING_OBJECT));
189
- }
190
- });
191
-
192
- it('should error if no flexPLMObjectClass is provided', async () => {
193
- try {
194
- await IdentifierConversion.getItemCriteriaFromObject(transformMapFile1, mapFileUtil, dc, {});
195
- } catch (e) {
196
- expect(e.message).toEqual(expect.stringContaining(IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS));
197
- }
198
- });
199
-
200
- it('should error if missing identifier properties -itemNumber', async () => {
201
- const object = {
202
- "flexBoolean": false,
203
- "flexMultiSelect": [
204
- ],
205
- "flexNumber": 0,
206
- "flexPLMObjectClass": "LCSProduct",
207
- "flexPLMTypePath": "Product\\Pants",
208
- "flexSingleList": {
209
- "display": "Five",
210
- "value": "five"
211
- },
212
- "productName": "Feb 3 - 1 Option A",
213
- "NotvibeIQIdentifier": 966
214
- };
215
- const criteriaObject = {
216
- flexPLMObjectClass: 'LCSProduct',
217
- flexPLMTypePath: 'Product\\Pants',
218
- };
219
-
220
- let getEntityValuesSpyOn = undefined
221
- try {
222
-
223
- getEntityValuesSpyOn = jest.spyOn(dc, 'getEntityValues');
224
- await IdentifierConversion.getItemCriteriaFromObject(transformMapFile1, mapFileUtil, dc, object);
225
- }catch (e) {
226
- expect(getEntityValuesSpyOn).toHaveBeenCalledWith('LCSProduct', criteriaObject, []);
227
- expect(e.message).toEqual(expect.stringContaining(IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS));
228
-
229
- } finally {
230
- if (getEntityValuesSpyOn) {
231
- getEntityValuesSpyOn.mockRestore();
232
- }
233
- }
234
- });
235
-
236
- it('should return the item family criteria from the object -itemNumber', async () => {
237
- const object = {
238
- "flexBoolean": false,
239
- "flexMultiSelect": [
240
- ],
241
- "flexNumber": 0,
242
- "flexPLMObjectClass": "LCSProduct",
243
- "flexPLMTypePath": "Product\\Pants",
244
- "flexSingleList": {
245
- "display": "Five",
246
- "value": "five"
247
- },
248
- "productName": "Feb 3 - 1 Option A",
249
- "vibeIQIdentifier": 966
250
- };
251
- const criteriaObject = {
252
- flexPLMObjectClass: 'LCSProduct',
253
- itemNumber: 966,
254
- flexPLMTypePath: 'Product\\Pants',
255
- };
256
- const resultsObject = {
257
- roles: 'family',
258
- itemNumber: 966
259
- };
260
- let getEntityValuesSpyOn = undefined
261
- try {
262
-
263
- getEntityValuesSpyOn = jest.spyOn(dc, 'getEntityValues');
264
- const result = await IdentifierConversion.getItemCriteriaFromObject(transformMapFile1, mapFileUtil, dc, object);
265
- expect(getEntityValuesSpyOn).toHaveBeenCalledWith('LCSProduct', criteriaObject, []);
266
- expect(result).toEqual(resultsObject);
267
- } finally {
268
- if (getEntityValuesSpyOn) {
269
- getEntityValuesSpyOn.mockRestore();
270
- }
271
- }
272
- });
273
-
274
- it('should return the item option criteria from the object -itemNumber', async () => {
275
- const object = {
276
- "flexBoolean": false,
277
- "flexMultiSelect": [
278
- ],
279
- "flexNumber": 0,
280
- "flexPLMObjectClass": "LCSSKU",
281
- "flexPLMTypePath": "Product\\Pants",
282
- "flexSingleList": {
283
- "display": "Five",
284
- "value": "five"
285
- },
286
- "productName": "Feb 3 - 1 Option A",
287
- "vibeIQIdentifier": 2876
288
- };
289
- const criteriaObject = {
290
- flexPLMObjectClass: 'LCSSKU',
291
- itemNumber: 2876,
292
- flexPLMTypePath: 'Product\\Pants',
293
- };
294
- const resultsObject = {
295
- roles: 'color',
296
- itemNumber: 2876
297
- };
298
- let getEntityValuesSpyOn = undefined
299
- try {
300
-
301
- getEntityValuesSpyOn = jest.spyOn(dc, 'getEntityValues');
302
- const result = await IdentifierConversion.getItemCriteriaFromObject(transformMapFile1, mapFileUtil, dc, object);
303
- expect(getEntityValuesSpyOn).toHaveBeenCalledWith('LCSSKU', criteriaObject, []);
304
- expect(result).toEqual(resultsObject);
305
- } finally {
306
- if (getEntityValuesSpyOn) {
307
- getEntityValuesSpyOn.mockRestore();
308
- }
309
- }
310
- });
311
-
312
- it('should return the item option criteria from the object -uniqueIdentifierA, uniqueIdentifierB', async () => {
313
- const object = {
314
- "flexBoolean": false,
315
- "flexMultiSelect": [
316
- ],
317
- "flexNumber": 0,
318
- "flexPLMObjectClass": "LCSSKU",
319
- "flexPLMTypePath": "Product\\Pants",
320
- "flexSingleList": {
321
- "display": "Five",
322
- "value": "five"
323
- },
324
- "productName": "Feb 3 - 1 Option A",
325
- uniqueIdentifierA: 28,
326
- uniqueIdentifierB: 29,
327
- "vibeIQIdentifier": 2876
328
- };
329
- const criteriaObject = {
330
- flexPLMObjectClass: 'LCSSKU',
331
- uniqueIdentifierA: 28,
332
- uniqueIdentifierB: 29,
333
- flexPLMTypePath: 'Product\\Pants',
334
- };
335
- const resultsObject = {
336
- roles: 'color',
337
- uniqueIdentifierA: 28,
338
- uniqueIdentifierB: 29,
339
- };
340
- let getEntityValuesSpyOn = undefined
341
- try {
342
-
343
- getEntityValuesSpyOn = jest.spyOn(dc, 'getEntityValues');
344
- const result = await IdentifierConversion.getItemCriteriaFromObject(transformMapFile2, mapFileUtil, dc, object);
345
- expect(getEntityValuesSpyOn).toHaveBeenCalledWith('LCSSKU', criteriaObject, []);
346
- expect(result).toEqual(resultsObject);
347
- } finally {
348
- if (getEntityValuesSpyOn) {
349
- getEntityValuesSpyOn.mockRestore();
350
- }
351
- }
352
- });
353
-
354
- });
@@ -1,282 +0,0 @@
1
- import { MapFileUtil } from "@contrail/transform-data";
2
- import { ProductFederation, SeasonFederation, SeasonGroupFederation, SkuFederation } from "../interfaces/interfaces";
3
- import { MapUtil } from "../util/map-utils";
4
- import { TypeConversionUtils } from "../util/type-conversion-utils";
5
- import { DataConverter } from "../util/data-converter";
6
- import { EventShortMessageStatus } from "../util/event-short-message-status";
7
-
8
- export class IdentifierConversion {
9
- static readonly INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ';
10
-
11
- static readonly MISSING_OBJECT = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: object';
12
-
13
- static readonly MISSING_FLEXPLM_OBJECT_CLASS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass';
14
-
15
- /** Takes in an assortment and returns an object to query for an LCSSeason
16
- * This will only return the identifier properties, and information properties if specified.
17
- * @param transformMapFile
18
- * @param mapFileUtil
19
- * @param dc
20
- * @param assortment
21
- * @param includeInformationKeys defaults true
22
- * @returns
23
- */
24
- static async getSeasonIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment, includeInformationKeys = true): Promise<SeasonFederation>{
25
- if(!assortment){
26
- throw new Error('IdentifierConversion.getSeasonIdentityObject(): assortment must be provided.');
27
- }
28
- assortment['flex2vibeMapKeyRoot'] = 'LCSSeason';
29
- const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
30
-
31
- let seasonObj: any = {
32
- entityReference: 'assortment:' + assortment?.id,
33
- objectClass: 'LCSSeason' as const,
34
- flexPLMTypePath
35
- };
36
-
37
- try{
38
- const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
39
- const identifierKeys: string[] = await TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
40
- for(const key of identifierKeys){
41
- if(assortmentObj[key]){
42
- seasonObj[key] = assortmentObj[key];
43
- }
44
- }
45
- if(includeInformationKeys){
46
- const informationKeys: string[] = await TypeConversionUtils
47
- .getInformationalProperties(transformMapFile, mapFileUtil, assortment);
48
- for(const key of informationKeys){
49
- if(assortmentObj[key]){
50
- seasonObj[key] = assortmentObj[key];
51
- }
52
- }
53
- }
54
-
55
- const objectKeys = Object.keys(seasonObj);
56
- const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
57
- if(!hasAllIdentifiers){
58
- console.error('IdentifierConversion.getSeasonIdentityObject(): doesnt have all identifier properties - '+ identifierKeys);
59
- console.error('assortment: ' + JSON.stringify(assortment));
60
- }
61
-
62
- const mapKey:string = await TypeConversionUtils
63
- .getMapKey(transformMapFile, mapFileUtil, assortment, TypeConversionUtils.VIBE2FLEX_DIRECTION);
64
- seasonObj = await MapUtil
65
- .applyTransformMap(transformMapFile, mapFileUtil, seasonObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
66
- } finally {
67
- delete assortment['flex2vibeMapKeyRoot'];
68
- }
69
-
70
- return seasonObj as SeasonFederation;
71
- }
72
-
73
- /** Takes in an assortment and returns an object to query for an SeasonGroup
74
- * This will only return the identifier properties, and information properties if specified.
75
- * @param transformMapFile
76
- * @param mapFileUtil
77
- * @param dc
78
- * @param assortment
79
- * @param includeInformationKeys defaults true
80
- * @returns
81
- */
82
- static async getSeasonGroupIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment, includeInformationKeys = true): Promise<SeasonGroupFederation> {
83
- if(!assortment){
84
- throw new Error('IdentifierConversion.getSeasonGroupIdentityObject(): assortment must be provided.');
85
- }
86
- assortment['flex2vibeMapKeyRoot'] = 'SeasonGroup';
87
- const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
88
-
89
- let seasonGroupObj = {
90
- entityReference: 'assortment:' + assortment?.id,
91
- objectClass: 'SeasonGroup' as const,
92
- flexPLMTypePath
93
- };
94
-
95
- try {
96
- const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
97
-
98
- const identifierKeys: string[] = await TypeConversionUtils
99
- .getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
100
- for (const key of identifierKeys) {
101
- if (assortmentObj[key]) {
102
- seasonGroupObj[key] = assortmentObj[key];
103
- }
104
- }
105
-
106
- if(includeInformationKeys){
107
- const informationKeys: string[] = await TypeConversionUtils
108
- .getInformationalProperties(transformMapFile, mapFileUtil, assortment);
109
- for (const key of informationKeys) {
110
- if (assortmentObj[key]) {
111
- seasonGroupObj[key] = assortmentObj[key];
112
- }
113
- }
114
-
115
- }
116
- const objectKeys = Object.keys(seasonGroupObj);
117
- const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
118
-
119
- if (!hasAllIdentifiers) {
120
- console.error('IdentifierConversion.getSeasonGroupIdentityObject(): doesnt have all identifier properties - '+ identifierKeys);
121
- console.error('assortment: ' + JSON.stringify(assortment));
122
- }
123
-
124
- const mapKey: string = await TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, assortment, TypeConversionUtils.VIBE2FLEX_DIRECTION);
125
- seasonGroupObj = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, seasonGroupObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
126
-
127
- } finally {
128
- delete assortment['flex2vibeMapKeyRoot'];
129
- }
130
- return seasonGroupObj;
131
- }
132
-
133
- /** Takes in an item and returns an object to query for an LCSProduct
134
- * This will only return the identifier properties, and information properties if specified.
135
- * @param transformMapFile
136
- * @param mapFileUtil
137
- * @param dc
138
- * @param assortment
139
- * @param includeInformationKeys defaults true
140
- * @returns
141
- */
142
- static async getProductIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemFamilyObject, includeInformationKeys = true): Promise<ProductFederation> {
143
- if(!itemFamilyObject){
144
- throw new Error('IdentifierConversion.getProductIdentityObject(): itemFamilyObject must be provided.');
145
- }
146
- const itemObj = await dc.getFlexPLMObjectData(itemFamilyObject, [], true);
147
- const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemFamilyObject);
148
- let prodObj: ProductFederation = {
149
- entityReference: 'item:' + itemFamilyObject?.id,
150
- objectClass: 'LCSProduct' as const,
151
- flexPLMTypePath
152
- };
153
-
154
- const identifierKeys: string[] = await TypeConversionUtils
155
- .getIdentifierProperties(transformMapFile, mapFileUtil, itemFamilyObject);
156
- for (const key of identifierKeys) {
157
- if (itemObj[key]) {
158
- prodObj[key] = itemObj[key];
159
- }
160
- }
161
-
162
- if(includeInformationKeys){
163
- const informationKeys: string[] = await TypeConversionUtils
164
- .getInformationalProperties(transformMapFile, mapFileUtil, itemFamilyObject);
165
- for (const key of informationKeys) {
166
- if (itemObj[key]) {
167
- prodObj[key] = itemObj[key];
168
- }
169
- }
170
- }
171
-
172
- const vibeIQIdentifier = 'vibeIQIdentifier';
173
- if (!prodObj[vibeIQIdentifier]) {
174
- prodObj['vibeIQIdentifier'] = itemFamilyObject['identifier'] || itemFamilyObject['itemNumber'];
175
- }
176
-
177
- const mapKey: string = await TypeConversionUtils
178
- .getMapKey(transformMapFile, mapFileUtil, itemFamilyObject, TypeConversionUtils.VIBE2FLEX_DIRECTION);
179
- prodObj = await MapUtil
180
- .applyTransformMap(transformMapFile, mapFileUtil, prodObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
181
-
182
- return prodObj as ProductFederation;
183
- }
184
-
185
- /** Takes in an item and returns an object to query for an LCSSKU
186
- * This will only return the identifier properties, and information properties if specified.
187
- * @param transformMapFile
188
- * @param mapFileUtil
189
- * @param dc
190
- * @param assortment
191
- * @param includeInformationKeys defaults true
192
- * @returns
193
- */
194
- static async getSKUIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemObject, includeInformationKeys = true): Promise<SkuFederation> {
195
- if(!itemObject){
196
- throw new Error('IdentifierConversion.getSKUIdentityObject(): itemObject must be provided.');
197
- }
198
- const itemObj = await dc.getFlexPLMObjectData(itemObject, [], true);
199
- const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemObject);
200
- let skuObj: SkuFederation = {
201
- entityReference: 'item:' + itemObject?.id,
202
- objectClass: 'LCSSKU' as const,
203
- flexPLMTypePath
204
- };
205
-
206
- const identifierKeys: string[] = await TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, itemObject);
207
- for (const key of identifierKeys) {
208
- if (itemObj[key]) {
209
- skuObj[key] = itemObj[key];
210
- }
211
- }
212
-
213
- if(includeInformationKeys){
214
- const informationKeys: string[] = await TypeConversionUtils.getInformationalProperties(transformMapFile, mapFileUtil, itemObject);
215
- for (const key of informationKeys) {
216
- if (itemObj[key]) {
217
- skuObj[key] = itemObj[key];
218
- }
219
- }
220
- }
221
-
222
- const vibeIQIdentifier = 'vibeIQIdentifier';
223
- if (!skuObj[vibeIQIdentifier]) {
224
- skuObj['vibeIQIdentifier'] = itemObject['identifier'] || itemObject['itemNumber'];
225
- }
226
-
227
- const mapKey: string = await TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, itemObject, TypeConversionUtils.VIBE2FLEX_DIRECTION);
228
- skuObj = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, skuObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
229
-
230
- return skuObj as SkuFederation;
231
- }
232
-
233
- static async getEntityCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
234
- if(!object){
235
- const e =new Error(IdentifierConversion.MISSING_OBJECT)
236
- e['shortStatusMessage'] = EventShortMessageStatus.MISSING_INPUT;
237
- throw e;
238
- } else if(!object.flexPLMObjectClass){
239
- const e = new Error(IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS);
240
- e['shortStatusMessage'] = EventShortMessageStatus.MISSING_INPUT;
241
- throw e;
242
- }
243
- const mapKey: string = await TypeConversionUtils.getMapKeyFromObject(transformMapFile, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
244
-
245
- const identifierKeys: string[] = await TypeConversionUtils.getIdentifierPropertiesFromObject(transformMapFile, mapFileUtil, object);
246
- const objectData = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, object, mapKey, TypeConversionUtils.FLEX2VIBE_DIRECTION);
247
-
248
- let identifierValues = identifierKeys.reduce((acc, key) => {
249
- acc[key] = objectData[key];
250
- return acc;
251
- }, {});
252
- identifierValues['flexPLMObjectClass']= objectData?.flexPLMObjectClass;
253
- identifierValues['flexPLMTypePath']= objectData?.flexPLMTypePath;
254
-
255
- identifierValues = await dc.getEntityValues(objectData?.flexPLMObjectClass, identifierValues, []);
256
-
257
- const entityKeys = Object.keys(identifierValues);
258
- const hasAllIdentifiers = identifierKeys.every(key => entityKeys.includes(key));
259
- if (!hasAllIdentifiers) {
260
- const e = new Error(IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS + identifierKeys);
261
- e['shortStatusMessage'] = EventShortMessageStatus.MISSING_IDENTIFIER_PROPERTIES;
262
-
263
- throw e;
264
- }
265
- const criteria = {};
266
- for (const key of identifierKeys) {
267
- criteria[key] = identifierValues[key];
268
- }
269
- return criteria;
270
- }
271
- static async getAssortmentCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
272
- return IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
273
- }
274
-
275
- static async getItemCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
276
- const criteria = await IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
277
- const roles = (object.flexPLMObjectClass === 'LCSProduct') ? 'family' : 'color';
278
- criteria['roles'] = roles;
279
-
280
- return criteria;
281
- }
282
- }