@contrail/flexplm 1.4.0 → 1.5.0-alpha.14a4f1b

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 (112) hide show
  1. package/lib/cli/commands/compile.d.ts +4 -0
  2. package/lib/cli/commands/compile.js +73 -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 +5 -0
  6. package/lib/cli/commands/create.js +77 -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 +17 -0
  10. package/lib/cli/commands/upload.js +228 -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 +5 -0
  14. package/lib/cli/index.js +70 -0
  15. package/lib/cli/index.spec.d.ts +1 -0
  16. package/lib/cli/index.spec.js +85 -0
  17. package/lib/cli/template/mapping-template.ts.template +62 -0
  18. package/lib/entity-processor/base-entity-processor.d.ts +65 -0
  19. package/lib/entity-processor/base-entity-processor.js +71 -0
  20. package/lib/entity-processor/base-entity-processor.spec.js +1 -0
  21. package/lib/index.d.ts +1 -0
  22. package/lib/index.js +1 -0
  23. package/lib/interfaces/mapping-file.d.ts +460 -0
  24. package/lib/interfaces/mapping-file.js +2 -0
  25. package/lib/publish/base-process-publish-assortment.d.ts +25 -0
  26. package/lib/publish/base-process-publish-assortment.js +60 -6
  27. package/lib/publish/base-process-publish-assortment.spec.js +22 -4
  28. package/lib/publish/mockData.js +5 -0
  29. package/lib/transform/identifier-conversion-spec-mockData.js +34 -6
  30. package/lib/transform/identifier-conversion.d.ts +36 -0
  31. package/lib/transform/identifier-conversion.js +37 -1
  32. package/lib/transform/identifier-conversion.spec.js +35 -0
  33. package/lib/util/config-defaults.d.ts +18 -0
  34. package/lib/util/config-defaults.js +25 -15
  35. package/lib/util/config-defaults.spec.js +56 -0
  36. package/lib/util/data-converter-spec-mockData.js +17 -3
  37. package/lib/util/data-converter.d.ts +102 -0
  38. package/lib/util/data-converter.js +195 -34
  39. package/lib/util/data-converter.spec.js +430 -0
  40. package/lib/util/error-response-object.d.ts +5 -0
  41. package/lib/util/error-response-object.js +7 -0
  42. package/lib/util/event-short-message-status.js +1 -0
  43. package/lib/util/federation.js +8 -0
  44. package/lib/util/flexplm-connect.d.ts +7 -0
  45. package/lib/util/flexplm-connect.js +14 -0
  46. package/lib/util/logger-config.js +1 -0
  47. package/lib/util/map-util-spec-mockData.js +17 -3
  48. package/lib/util/map-utils.d.ts +27 -0
  49. package/lib/util/map-utils.js +27 -0
  50. package/lib/util/thumbnail-util.d.ts +21 -0
  51. package/lib/util/thumbnail-util.js +28 -1
  52. package/lib/util/thumbnail-util.spec.js +6 -0
  53. package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
  54. package/lib/util/type-conversion-utils.d.ts +151 -0
  55. package/lib/util/type-conversion-utils.js +154 -0
  56. package/lib/util/type-defaults.d.ts +69 -0
  57. package/lib/util/type-defaults.js +98 -4
  58. package/lib/util/type-defaults.spec.js +114 -4
  59. package/lib/util/type-utils.d.ts +21 -0
  60. package/lib/util/type-utils.js +23 -0
  61. package/lib/util/type-utils.spec.js +2 -0
  62. package/package.json +21 -6
  63. package/scripts/copy-template.js +10 -0
  64. package/.github/pull_request_template.md +0 -31
  65. package/.github/workflows/flexplm-lib.yml +0 -27
  66. package/.github/workflows/publish-to-npm.yml +0 -121
  67. package/CHANGELOG.md +0 -40
  68. package/publish.bat +0 -5
  69. package/publish.sh +0 -5
  70. package/src/entity-processor/base-entity-processor.spec.ts +0 -689
  71. package/src/entity-processor/base-entity-processor.ts +0 -583
  72. package/src/flexplm-request.ts +0 -28
  73. package/src/flexplm-utils.spec.ts +0 -27
  74. package/src/flexplm-utils.ts +0 -29
  75. package/src/index.ts +0 -22
  76. package/src/interfaces/interfaces.ts +0 -122
  77. package/src/interfaces/item-family-changes.ts +0 -67
  78. package/src/interfaces/publish-change-data.ts +0 -43
  79. package/src/publish/base-process-publish-assortment-callback.ts +0 -50
  80. package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
  81. package/src/publish/base-process-publish-assortment.ts +0 -1134
  82. package/src/publish/mockData.ts +0 -4561
  83. package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
  84. package/src/transform/identifier-conversion.spec.ts +0 -354
  85. package/src/transform/identifier-conversion.ts +0 -282
  86. package/src/util/config-defaults.spec.ts +0 -392
  87. package/src/util/config-defaults.ts +0 -97
  88. package/src/util/data-converter-spec-mockData.ts +0 -231
  89. package/src/util/data-converter.spec.ts +0 -1120
  90. package/src/util/data-converter.ts +0 -766
  91. package/src/util/error-response-object.spec.ts +0 -116
  92. package/src/util/error-response-object.ts +0 -50
  93. package/src/util/event-short-message-status.ts +0 -22
  94. package/src/util/federation.ts +0 -172
  95. package/src/util/flexplm-connect.spec.ts +0 -132
  96. package/src/util/flexplm-connect.ts +0 -208
  97. package/src/util/logger-config.ts +0 -20
  98. package/src/util/map-util-spec-mockData.ts +0 -231
  99. package/src/util/map-utils.spec.ts +0 -103
  100. package/src/util/map-utils.ts +0 -41
  101. package/src/util/mockData.ts +0 -101
  102. package/src/util/thumbnail-util.spec.ts +0 -508
  103. package/src/util/thumbnail-util.ts +0 -272
  104. package/src/util/type-conversion-utils-spec-mockData.ts +0 -272
  105. package/src/util/type-conversion-utils.spec.ts +0 -1031
  106. package/src/util/type-conversion-utils.ts +0 -490
  107. package/src/util/type-defaults.spec.ts +0 -669
  108. package/src/util/type-defaults.ts +0 -281
  109. package/src/util/type-utils.spec.ts +0 -227
  110. package/src/util/type-utils.ts +0 -144
  111. package/tsconfig.json +0 -24
  112. package/tslint.json +0 -57
@@ -13,6 +13,7 @@ let federatedId = '';
13
13
  jest.mock('../util/data-converter', () => {
14
14
  return {
15
15
  DataConverter: class {
16
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
16
17
  getFlexPLMObjectData(newData, dataToSkip, inflateObjRef) {
17
18
  return newData;
18
19
  }
@@ -95,6 +96,7 @@ describe('getPublishInfo', () => {
95
96
  return { id: assortmentId, name: assortmentName };
96
97
  });
97
98
  const spyyGetSnapshotVersion = jest.spyOn(ppa, 'getSnapshotVersion')
99
+ // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
98
100
  .mockImplementation(async (assortmentId, assortmentPublishChangeId) => {
99
101
  return versionHistoryNumber;
100
102
  });
@@ -120,6 +122,7 @@ describe('getPublishInfo', () => {
120
122
  return { id: assortmentId, name: undefined };
121
123
  });
122
124
  const spyyGetSnapshotVersion = jest.spyOn(ppa, 'getSnapshotVersion')
125
+ // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
123
126
  .mockImplementation(async (assortmentId, assortmentPublishChangeId) => {
124
127
  return versionHistoryNumber;
125
128
  });
@@ -145,6 +148,7 @@ describe('getPublishInfo', () => {
145
148
  return undefined;
146
149
  });
147
150
  const spyyGetSnapshotVersion = jest.spyOn(ppa, 'getSnapshotVersion')
151
+ // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
148
152
  .mockImplementation(async (assortmentId, assortmentPublishChangeId) => {
149
153
  return versionHistoryNumber;
150
154
  });
@@ -179,6 +183,7 @@ describe('getPublishInfo', () => {
179
183
  return { id: assortmentId, name: assortmentName };
180
184
  });
181
185
  const spyyGetSnapshotVersion = jest.spyOn(ppa, 'getSnapshotVersion')
186
+ // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
182
187
  .mockImplementation(async (assortmentId, assortmentPublishChangeId) => {
183
188
  return versionHistoryNumber;
184
189
  });
@@ -203,6 +208,7 @@ describe('getPublishInfo', () => {
203
208
  return { id: assortmentId, name: assortmentName };
204
209
  });
205
210
  const spyyGetSnapshotVersion = jest.spyOn(ppa, 'getSnapshotVersion')
211
+ // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
206
212
  .mockImplementation(async (assortmentId, assortmentPublishChangeId) => {
207
213
  return versionHistoryNumber;
208
214
  });
@@ -229,6 +235,7 @@ describe('getPublishInfo', () => {
229
235
  return { id: assortmentId, name: assortmentName };
230
236
  });
231
237
  const spyyGetSnapshotVersion = jest.spyOn(ppa, 'getSnapshotVersion')
238
+ // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
232
239
  .mockImplementation(async (assortmentId, assortmentPublishChangeId) => {
233
240
  return versionHistoryNumber;
234
241
  });
@@ -255,6 +262,7 @@ describe('getPublishInfo', () => {
255
262
  return { id: assortmentId, name: assortmentName };
256
263
  });
257
264
  const spyyGetSnapshotVersion = jest.spyOn(ppa, 'getSnapshotVersion')
265
+ // eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
258
266
  .mockImplementation(async (assortmentId, assortmentPublishChangeId) => {
259
267
  return versionHistoryNumber;
260
268
  });
@@ -408,6 +416,7 @@ describe('getSnapshotVersion', () => {
408
416
  {
409
417
  id: 'qewrwer',
410
418
  assortmentChangeId: 'bad-id',
419
+ // createdOn: '2023-01-14T19:13:58.902Z',
411
420
  versionNumber
412
421
  }
413
422
  ];
@@ -1140,6 +1149,7 @@ describe('getItemFamilyChanges', () => {
1140
1149
  const ifcs = pcd.itemFamilyChanges;
1141
1150
  expect(ifcs.size).toEqual(1);
1142
1151
  const ifc = ifcs.get(itemFamilyId);
1152
+ // expect(ifc.familyAdd).toBe(true);
1143
1153
  expect(ifc.colorAdds.length).toEqual(1);
1144
1154
  });
1145
1155
  it('Feb 3 - 2+ Option A', () => {
@@ -1169,6 +1179,7 @@ describe('getItemFamilyChanges', () => {
1169
1179
  const ifcs = pcd.itemFamilyChanges;
1170
1180
  expect(ifcs.size).toEqual(1);
1171
1181
  const ifc = ifcs.get(itemFamilyId);
1182
+ // expect(ifc.familyAdd).toBe(true);
1172
1183
  expect(ifc.colorAdds.length).toEqual(2);
1173
1184
  });
1174
1185
  it('Feb 3 - 2+ Option A & Feb 3 - 1 Option A', () => {
@@ -1300,6 +1311,8 @@ describe('getItemFamilyChanges', () => {
1300
1311
  const ifcs = pcd.itemFamilyChanges;
1301
1312
  expect(ifcs.size).toEqual(1);
1302
1313
  const ifc = ifcs.get(itemFamilyId);
1314
+ //TODO fix
1315
+ // expect(ifc.familyDelete).toBe(true);
1303
1316
  expect(ifc.colorAdds.length).toEqual(0);
1304
1317
  expect(ifc.colorDeletes.length).toEqual(1);
1305
1318
  });
@@ -1572,9 +1585,10 @@ describe('getEventsForItemFamilyChanges - conditional eventType', () => {
1572
1585
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['identifier']);
1573
1586
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
1574
1587
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity')
1575
- .mockResolvedValueOnce(true)
1576
- .mockResolvedValueOnce(true);
1588
+ .mockResolvedValueOnce(true) // for family
1589
+ .mockResolvedValueOnce(true); // for SKU
1577
1590
  const events = await bppa.getEventsForItemFamilyChanges(itemFamilyChanges, 'assort123', seasonFed, new Map());
1591
+ // Should have both family and SKU events because familyAssortmentItem is true when colorAdds.length > 0
1578
1592
  expect(events).toHaveLength(2);
1579
1593
  const skuEvent = events.find(e => e.objectClass === 'LCSSKUSeasonLink');
1580
1594
  expect(skuEvent.eventType).toBe('UPSERT_ON_SEASON');
@@ -1613,9 +1627,10 @@ describe('getEventsForItemFamilyChanges - conditional eventType', () => {
1613
1627
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['identifier']);
1614
1628
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
1615
1629
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity')
1616
- .mockResolvedValueOnce(false)
1617
- .mockResolvedValueOnce(false);
1630
+ .mockResolvedValueOnce(false) // for family
1631
+ .mockResolvedValueOnce(false); // for SKU
1618
1632
  const events = await bppa.getEventsForItemFamilyChanges(itemFamilyChanges, 'assort123', seasonFed, new Map());
1633
+ // Should have both family and SKU events because familyAssortmentItem is true when colorUpdates.length > 0
1619
1634
  expect(events).toHaveLength(2);
1620
1635
  const skuEvent = events.find(e => e.objectClass === 'LCSSKUSeasonLink');
1621
1636
  expect(skuEvent.eventType).toBe('UPDATE_ON_SEASON');
@@ -1654,6 +1669,7 @@ describe('getEventsForItemFamilyChanges - conditional eventType', () => {
1654
1669
  jest.spyOn(map_utils_1.MapUtil, 'applyTransformMap').mockResolvedValue({ transformedData: 'value' });
1655
1670
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getIdentifierProperties').mockResolvedValue(['identifier']);
1656
1671
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'getInformationalProperties').mockResolvedValue([]);
1672
+ // Product is creatable (true), SKU is not (false)
1657
1673
  jest.spyOn(type_conversion_utils_1.TypeConversionUtils, 'isOutboundCreatableFromEntity')
1658
1674
  .mockResolvedValueOnce(true)
1659
1675
  .mockResolvedValueOnce(false);
@@ -1664,7 +1680,9 @@ describe('getEventsForItemFamilyChanges - conditional eventType', () => {
1664
1680
  expect(productEvent.eventType).toBe('UPSERT_ON_SEASON');
1665
1681
  expect(skuEvent.eventType).toBe('UPDATE_ON_SEASON');
1666
1682
  expect(type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity).toHaveBeenCalledTimes(2);
1683
+ // Verify product event called with assortment entity
1667
1684
  expect(type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity).toHaveBeenNthCalledWith(1, undefined, mapFileUtil, familyProjectItem, { item: prodEntityData, assortment });
1685
+ // Verify SKU event called with assortment entity
1668
1686
  expect(type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity).toHaveBeenNthCalledWith(2, undefined, mapFileUtil, colorProjectItem, { item: itemData, assortment });
1669
1687
  });
1670
1688
  });
@@ -3399,6 +3399,11 @@ exports.fall_2003_fedMapping = [
3399
3399
  mappedReference: 'VR:com.lcs.wc.product.LCSSKU:372509'
3400
3400
  }
3401
3401
  ];
3402
+ //SYHfQzYWlfXDqK7r - 4 adds
3403
+ //JreGRNvoJ3FsoRZI - 1 delete
3404
+ //NaPUhAdEzKB-5tQ3 - no changes
3405
+ //CHGKSCT358qyh1Nu - 1 delete
3406
+ //H4L4dHziO6WZRIwa - re-add from JreGRNvoJ3FsoRZI
3402
3407
  exports.apc_2bOWR2j9R0QThDVu_delete_history = [
3403
3408
  {
3404
3409
  adds: 4,
@@ -31,6 +31,20 @@ exports.mapping = {
31
31
  }
32
32
  }
33
33
  }
34
+ // flex2vibe: {
35
+ // LCSRevisableEntity: {
36
+ // getMapKey: (object) =>{ return object;}
37
+ // },
38
+ // LCSLast: {
39
+ // getMapKey: (object) => {return object;}
40
+ // },
41
+ // LCSMaterial: {
42
+ // getMapKey: (object) =>{ return object;}
43
+ // },
44
+ // LCSBusinessObject: {
45
+ // getMapKey: (object) => {return object;}
46
+ // }
47
+ // },
34
48
  },
35
49
  LCSSeason: {
36
50
  vibe2flex: {
@@ -54,7 +68,7 @@ exports.mapping = {
54
68
  vibeOwningKeys: ['itemNumber', 'lifecycleStage'],
55
69
  vibe2flex: {
56
70
  getClass: () => 'LCSProduct',
57
- getSoftType: (entity) => {
71
+ getSoftType: (entity /*, dependencies*/) => {
58
72
  const prodType = entity['prodType'];
59
73
  let val = '';
60
74
  switch (prodType) {
@@ -79,7 +93,7 @@ exports.mapping = {
79
93
  vibeIQIdentifier: 'itemNumber'
80
94
  },
81
95
  valueTransform: {
82
- transformEx: (row) => {
96
+ transformEx: (row /*, dependencies*/) => {
83
97
  return row['otherProp'] + 'xxx';
84
98
  }
85
99
  }
@@ -97,7 +111,7 @@ exports.mapping = {
97
111
  vibeOwningKeys: ['itemNumber', 'lifecycleStage'],
98
112
  vibe2flex: {
99
113
  getClass: () => 'LCSSKU',
100
- getSoftType: (entity) => {
114
+ getSoftType: (entity /*, dependencies*/) => {
101
115
  const prodType = entity['prodType'];
102
116
  let val = '';
103
117
  switch (prodType) {
@@ -252,6 +266,20 @@ exports.mapping2 = {
252
266
  }
253
267
  }
254
268
  }
269
+ // flex2vibe: {
270
+ // LCSRevisableEntity: {
271
+ // getMapKey: (object) =>{ return object;}
272
+ // },
273
+ // LCSLast: {
274
+ // getMapKey: (object) => {return object;}
275
+ // },
276
+ // LCSMaterial: {
277
+ // getMapKey: (object) =>{ return object;}
278
+ // },
279
+ // LCSBusinessObject: {
280
+ // getMapKey: (object) => {return object;}
281
+ // }
282
+ // },
255
283
  },
256
284
  LCSSeason: {
257
285
  getIdentifierProperties: () => ['brand', 'year', 'seasonType'],
@@ -274,7 +302,7 @@ exports.mapping2 = {
274
302
  vibeOwningKeys: ['itemNumber', 'lifecycleStage'],
275
303
  vibe2flex: {
276
304
  getClass: () => 'LCSProduct',
277
- getSoftType: (entity) => {
305
+ getSoftType: (entity /*, dependencies*/) => {
278
306
  const prodType = entity['prodType'];
279
307
  let val = '';
280
308
  switch (prodType) {
@@ -299,7 +327,7 @@ exports.mapping2 = {
299
327
  vibeIQIdentifier: 'itemNumber'
300
328
  },
301
329
  valueTransform: {
302
- transformEx: (row) => {
330
+ transformEx: (row /*, dependencies*/) => {
303
331
  return row['otherProp'] + 'xxx';
304
332
  }
305
333
  }
@@ -318,7 +346,7 @@ exports.mapping2 = {
318
346
  getIdentifierProperties: () => ['uniqueIdentifierA', 'uniqueIdentifierB'],
319
347
  vibe2flex: {
320
348
  getClass: () => 'LCSSKU',
321
- getSoftType: (entity) => {
349
+ getSoftType: (entity /*, dependencies*/) => {
322
350
  const prodType = entity['prodType'];
323
351
  let val = '';
324
352
  switch (prodType) {
@@ -5,9 +5,45 @@ export declare class IdentifierConversion {
5
5
  static readonly INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = "IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ";
6
6
  static readonly MISSING_OBJECT = "IdentifierConversion.getEntityCriteriaFromObject(): missing: object";
7
7
  static readonly MISSING_FLEXPLM_OBJECT_CLASS = "IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass";
8
+ /** Takes in an assortment and returns an object to query for an LCSSeason
9
+ * This will only return the identifier properties, and information properties if specified.
10
+ * @param transformMapFile
11
+ * @param mapFileUtil
12
+ * @param dc
13
+ * @param assortment
14
+ * @param includeInformationKeys defaults true
15
+ * @returns
16
+ */
8
17
  static getSeasonIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonFederation>;
18
+ /** Takes in an assortment and returns an object to query for an SeasonGroup
19
+ * This will only return the identifier properties, and information properties if specified.
20
+ * @param transformMapFile
21
+ * @param mapFileUtil
22
+ * @param dc
23
+ * @param assortment
24
+ * @param includeInformationKeys defaults true
25
+ * @returns
26
+ */
9
27
  static getSeasonGroupIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonGroupFederation>;
28
+ /** Takes in an item and returns an object to query for an LCSProduct
29
+ * This will only return the identifier properties, and information properties if specified.
30
+ * @param transformMapFile
31
+ * @param mapFileUtil
32
+ * @param dc
33
+ * @param assortment
34
+ * @param includeInformationKeys defaults true
35
+ * @returns
36
+ */
10
37
  static getProductIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemFamilyObject: any, includeInformationKeys?: boolean): Promise<ProductFederation>;
38
+ /** Takes in an item and returns an object to query for an LCSSKU
39
+ * This will only return the identifier properties, and information properties if specified.
40
+ * @param transformMapFile
41
+ * @param mapFileUtil
42
+ * @param dc
43
+ * @param assortment
44
+ * @param includeInformationKeys defaults true
45
+ * @returns
46
+ */
11
47
  static getSKUIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemObject: any, includeInformationKeys?: boolean): Promise<SkuFederation>;
12
48
  static getEntityCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
13
49
  static getAssortmentCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
@@ -5,6 +5,15 @@ const map_utils_1 = require("../util/map-utils");
5
5
  const type_conversion_utils_1 = require("../util/type-conversion-utils");
6
6
  const event_short_message_status_1 = require("../util/event-short-message-status");
7
7
  class IdentifierConversion {
8
+ /** Takes in an assortment and returns an object to query for an LCSSeason
9
+ * This will only return the identifier properties, and information properties if specified.
10
+ * @param transformMapFile
11
+ * @param mapFileUtil
12
+ * @param dc
13
+ * @param assortment
14
+ * @param includeInformationKeys defaults true
15
+ * @returns
16
+ */
8
17
  static async getSeasonIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
9
18
  if (!assortment) {
10
19
  throw new Error('IdentifierConversion.getSeasonIdentityObject(): assortment must be provided.');
@@ -49,6 +58,15 @@ class IdentifierConversion {
49
58
  }
50
59
  return seasonObj;
51
60
  }
61
+ /** Takes in an assortment and returns an object to query for an SeasonGroup
62
+ * This will only return the identifier properties, and information properties if specified.
63
+ * @param transformMapFile
64
+ * @param mapFileUtil
65
+ * @param dc
66
+ * @param assortment
67
+ * @param includeInformationKeys defaults true
68
+ * @returns
69
+ */
52
70
  static async getSeasonGroupIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
53
71
  if (!assortment) {
54
72
  throw new Error('IdentifierConversion.getSeasonGroupIdentityObject(): assortment must be provided.');
@@ -92,6 +110,15 @@ class IdentifierConversion {
92
110
  }
93
111
  return seasonGroupObj;
94
112
  }
113
+ /** Takes in an item and returns an object to query for an LCSProduct
114
+ * This will only return the identifier properties, and information properties if specified.
115
+ * @param transformMapFile
116
+ * @param mapFileUtil
117
+ * @param dc
118
+ * @param assortment
119
+ * @param includeInformationKeys defaults true
120
+ * @returns
121
+ */
95
122
  static async getProductIdentityObject(transformMapFile, mapFileUtil, dc, itemFamilyObject, includeInformationKeys = true) {
96
123
  if (!itemFamilyObject) {
97
124
  throw new Error('IdentifierConversion.getProductIdentityObject(): itemFamilyObject must be provided.');
@@ -129,6 +156,15 @@ class IdentifierConversion {
129
156
  .applyTransformMap(transformMapFile, mapFileUtil, prodObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
130
157
  return prodObj;
131
158
  }
159
+ /** Takes in an item and returns an object to query for an LCSSKU
160
+ * This will only return the identifier properties, and information properties if specified.
161
+ * @param transformMapFile
162
+ * @param mapFileUtil
163
+ * @param dc
164
+ * @param assortment
165
+ * @param includeInformationKeys defaults true
166
+ * @returns
167
+ */
132
168
  static async getSKUIdentityObject(transformMapFile, mapFileUtil, dc, itemObject, includeInformationKeys = true) {
133
169
  if (!itemObject) {
134
170
  throw new Error('IdentifierConversion.getSKUIdentityObject(): itemObject must be provided.');
@@ -201,7 +237,7 @@ class IdentifierConversion {
201
237
  }
202
238
  static async getItemCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
203
239
  const criteria = await IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
204
- const roles = (object.flexPLMObjectClass === 'LCSProduct') ? 'family' : 'color';
240
+ const roles = (['LCSProduct', 'LCSMaterial'].includes(object.flexPLMObjectClass)) ? 'family' : 'color';
205
241
  criteria['roles'] = roles;
206
242
  return criteria;
207
243
  }
@@ -4,6 +4,7 @@ const transform_data_1 = require("@contrail/transform-data");
4
4
  const identifier_conversion_1 = require("./identifier-conversion");
5
5
  const data_converter_1 = require("../util/data-converter");
6
6
  const sdk_1 = require("@contrail/sdk");
7
+ const type_defaults_1 = require("../util/type-defaults");
7
8
  const mapFile1Data = require('./identifier-conversion-spec-mockData');
8
9
  const mapFile1Mappings = mapFile1Data?.mapping;
9
10
  const mapFile2Mappings = mapFile1Data?.mapping2;
@@ -30,9 +31,11 @@ describe('getAssortmentFromObject', () => {
30
31
  entityValues[key] = value;
31
32
  }
32
33
  else if (Array.isArray(value)) {
34
+ //multi select
33
35
  entityValues[key] = value.map((v) => v.value);
34
36
  }
35
37
  else if (value.value) {
38
+ //single select
36
39
  entityValues[key] = value.value;
37
40
  }
38
41
  }
@@ -166,9 +169,11 @@ describe('getItemCriteriaFromObject', () => {
166
169
  entityValues[key] = value;
167
170
  }
168
171
  else if (Array.isArray(value)) {
172
+ //multi select
169
173
  entityValues[key] = value.map((v) => v.value);
170
174
  }
171
175
  else if (value.value) {
176
+ //single select
172
177
  entityValues[key] = value.value;
173
178
  }
174
179
  }
@@ -296,6 +301,36 @@ describe('getItemCriteriaFromObject', () => {
296
301
  }
297
302
  }
298
303
  });
304
+ it('should return the item family criteria from the object -LCSMaterial', async () => {
305
+ const object = {
306
+ "flexPLMObjectClass": "LCSMaterial",
307
+ "flexPLMTypePath": "Material\\form",
308
+ "itemNumber": "MAT-100"
309
+ };
310
+ const criteriaObject = {
311
+ flexPLMObjectClass: 'LCSMaterial',
312
+ itemNumber: 'MAT-100',
313
+ flexPLMTypePath: 'Material\\form',
314
+ };
315
+ const resultsObject = {
316
+ roles: 'family',
317
+ itemNumber: 'MAT-100'
318
+ };
319
+ let getEntityValuesSpyOn = undefined;
320
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
321
+ try {
322
+ getEntityValuesSpyOn = jest.spyOn(dc, 'getEntityValues');
323
+ const result = await identifier_conversion_1.IdentifierConversion.getItemCriteriaFromObject(transformMapFile1, mapFileUtil, dc, object);
324
+ expect(getEntityValuesSpyOn).toHaveBeenCalledWith('LCSMaterial', criteriaObject, []);
325
+ expect(result).toEqual(resultsObject);
326
+ }
327
+ finally {
328
+ if (getEntityValuesSpyOn) {
329
+ getEntityValuesSpyOn.mockRestore();
330
+ }
331
+ type_defaults_1.TypeDefaults.applyConfig({});
332
+ }
333
+ });
299
334
  it('should return the item option criteria from the object -uniqueIdentifierA, uniqueIdentifierB', async () => {
300
335
  const object = {
301
336
  "flexBoolean": false,
@@ -3,6 +3,24 @@ export declare class ConfigDefaults {
3
3
  static NEED_CONFIG_VALUES: string;
4
4
  static STATIC_CONFIG_CACHE: {};
5
5
  static setConfigDefaults(config: any): Promise<FCConfig>;
6
+ static getDefaultConfig(): {
7
+ urlContext: string;
8
+ sendMode: {
9
+ ASYNC_PUBLISH_SEASON: string;
10
+ };
11
+ itemPreDevelopmentLifecycleStages: string[];
12
+ identifierAtts: {
13
+ LCSProduct: string[];
14
+ LCSSeason: string[];
15
+ LCSSKU: string[];
16
+ };
17
+ LCSMaterial: {
18
+ processAsItem: boolean;
19
+ };
20
+ csrfEndpoint: string;
21
+ vibeEventEndpoint: string;
22
+ payloadDefaultAsArray: boolean;
23
+ };
6
24
  static getConfigFile(fileId: string): Promise<any>;
7
25
  static isPropertyTrue(value: any): boolean;
8
26
  static clearConfigCache(): void;
@@ -3,18 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigDefaults = void 0;
4
4
  const sdk_1 = require("@contrail/sdk");
5
5
  const util_1 = require("@contrail/util");
6
+ const type_defaults_1 = require("./type-defaults");
6
7
  class ConfigDefaults {
7
8
  static async setConfigDefaults(config) {
9
+ //Validate config
8
10
  if (!config.apiHost || !config.userName || !config.password) {
9
11
  throw new Error(ConfigDefaults.NEED_CONFIG_VALUES);
10
12
  }
13
+ //List will be comma separated list in UI, so convert to array
11
14
  if (config?.itemPreDevelopmentLifecycleStages && !(config?.itemPreDevelopmentLifecycleStages instanceof Array)) {
12
15
  config.itemPreDevelopmentLifecycleStages = config.itemPreDevelopmentLifecycleStages.split(',');
13
16
  }
14
17
  else if (Object.keys(config).includes('itemPreDevelopmentLifecycleStages')) {
15
18
  delete config['itemPreDevelopmentLifecycleStages'];
16
19
  }
17
- const defaultConfig = {
20
+ const configArr = [ConfigDefaults.getDefaultConfig()];
21
+ if (config.configFile) {
22
+ const fileConfig = await ConfigDefaults.getConfigFile(config.configFile);
23
+ configArr.push(fileConfig);
24
+ }
25
+ configArr.push(config);
26
+ const outputConfig = util_1.ObjectUtil.mergeDeep({}, ...configArr);
27
+ const uName = outputConfig.userName;
28
+ const pass = outputConfig.password;
29
+ outputConfig.userName = () => uName;
30
+ outputConfig.password = () => pass;
31
+ //Don't allow overwriting this.
32
+ outputConfig['OOBvibeEventEndpoint'] = '/rfa/vibeiq/vibeEvents';
33
+ type_defaults_1.TypeDefaults.applyConfig(outputConfig);
34
+ console.log('outputConfig: ' + JSON.stringify(outputConfig));
35
+ return outputConfig;
36
+ }
37
+ static getDefaultConfig() {
38
+ return {
18
39
  urlContext: '/Windchill',
19
40
  sendMode: {
20
41
  ASYNC_PUBLISH_SEASON: 'vibeiqfile'
@@ -25,24 +46,13 @@ class ConfigDefaults {
25
46
  LCSSeason: ['flexPLMSeasonName'],
26
47
  LCSSKU: ['itemNumber']
27
48
  },
49
+ LCSMaterial: {
50
+ processAsItem: false
51
+ },
28
52
  csrfEndpoint: '/servlet/rest/security/csrf',
29
53
  vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
30
54
  payloadDefaultAsArray: true
31
55
  };
32
- const configArr = [defaultConfig];
33
- if (config.configFile) {
34
- const fileConfig = await ConfigDefaults.getConfigFile(config.configFile);
35
- configArr.push(fileConfig);
36
- }
37
- configArr.push(config);
38
- const outputConfig = util_1.ObjectUtil.mergeDeep({}, ...configArr);
39
- const uName = outputConfig.userName;
40
- const pass = outputConfig.password;
41
- outputConfig.userName = () => uName;
42
- outputConfig.password = () => pass;
43
- outputConfig['OOBvibeEventEndpoint'] = '/rfa/vibeiq/vibeEvents';
44
- console.log('outputConfig: ' + JSON.stringify(outputConfig));
45
- return outputConfig;
46
56
  }
47
57
  static async getConfigFile(fileId) {
48
58
  try {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const config_defaults_1 = require("./config-defaults");
4
+ const type_defaults_1 = require("./type-defaults");
4
5
  let entityObject = {};
5
6
  jest.mock('@contrail/sdk', () => {
6
7
  return {
@@ -21,11 +22,13 @@ describe('all tests', () => {
21
22
  describe('setConfigDefaults - required values', () => {
22
23
  it('missing apiHost', async () => {
23
24
  const config = {
25
+ //apiHost: 'http://test.com',
24
26
  userName: 'vibeiq',
25
27
  password: 'vibeiq',
26
28
  plmEnviornment: 'SB'
27
29
  };
28
30
  try {
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
29
32
  const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(config);
30
33
  }
31
34
  catch (e) {
@@ -35,10 +38,12 @@ describe('all tests', () => {
35
38
  it('missing userName', async () => {
36
39
  const config = {
37
40
  apiHost: 'http://test.com',
41
+ //userName: 'vibeiq',
38
42
  password: 'vibeiq',
39
43
  plmEnviornment: 'SB'
40
44
  };
41
45
  try {
46
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
42
47
  const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(config);
43
48
  }
44
49
  catch (e) {
@@ -49,9 +54,11 @@ describe('all tests', () => {
49
54
  const config = {
50
55
  apiHost: 'http://test.com',
51
56
  userName: 'vibeiq',
57
+ //password: 'vibeiq',
52
58
  plmEnviornment: 'SB'
53
59
  };
54
60
  try {
61
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
55
62
  const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(config);
56
63
  }
57
64
  catch (e) {
@@ -63,8 +70,10 @@ describe('all tests', () => {
63
70
  apiHost: 'http://test.com',
64
71
  userName: 'vibeiq',
65
72
  password: 'vibeiq',
73
+ //plmEnviornment: 'SB'
66
74
  };
67
75
  try {
76
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
68
77
  const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(config);
69
78
  }
70
79
  catch (e) {
@@ -215,6 +224,7 @@ describe('all tests', () => {
215
224
  const startConfig = Object.assign({}, config);
216
225
  const objectClass = 'LCSSeason';
217
226
  const expectedAtts = ['flexPLMSeasonName'];
227
+ // const expectedAtts =['seasonType', 'seasonYear'];
218
228
  const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
219
229
  const identifierAtts = fcConfig.identifierAtts[objectClass];
220
230
  expect(identifierAtts instanceof Array).toBeTruthy();
@@ -296,6 +306,52 @@ describe('all tests', () => {
296
306
  expect(config_defaults_1.ConfigDefaults.isPropertyTrue(1)).toBe(false);
297
307
  });
298
308
  });
309
+ describe('getDefaultConfig', () => {
310
+ it('returns LCSMaterial.processAsItem=false by default', () => {
311
+ const dc = config_defaults_1.ConfigDefaults.getDefaultConfig();
312
+ expect(dc.LCSMaterial).toBeDefined();
313
+ expect(dc.LCSMaterial.processAsItem).toBe(false);
314
+ });
315
+ it('returns a fresh object each call (no shared reference)', () => {
316
+ const a = config_defaults_1.ConfigDefaults.getDefaultConfig();
317
+ const b = config_defaults_1.ConfigDefaults.getDefaultConfig();
318
+ expect(a).not.toBe(b);
319
+ expect(a.LCSMaterial).not.toBe(b.LCSMaterial);
320
+ a.LCSMaterial.processAsItem = true;
321
+ expect(b.LCSMaterial.processAsItem).toBe(false);
322
+ });
323
+ });
324
+ describe('setConfigDefaults - LCSMaterial', () => {
325
+ const config = {
326
+ apiHost: 'http://test.com',
327
+ userName: 'vibeiq',
328
+ password: 'vibeiq'
329
+ };
330
+ it('LCSMaterial.processAsItem-get default', async () => {
331
+ const startConfig = Object.assign({}, config);
332
+ const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
333
+ expect(fcConfig.LCSMaterial.processAsItem).toBe(false);
334
+ });
335
+ it('LCSMaterial.processAsItem-override', async () => {
336
+ const startConfig = Object.assign({}, config);
337
+ startConfig.LCSMaterial = { processAsItem: true };
338
+ const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
339
+ expect(fcConfig.LCSMaterial.processAsItem).toBe(true);
340
+ });
341
+ it('applies LCSMaterial.processAsItem to TypeDefaults', async () => {
342
+ try {
343
+ const startConfig = Object.assign({}, config, { LCSMaterial: { processAsItem: true } });
344
+ await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
345
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(true);
346
+ const defaultStart = Object.assign({}, config);
347
+ await config_defaults_1.ConfigDefaults.setConfigDefaults(defaultStart);
348
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(false);
349
+ }
350
+ finally {
351
+ type_defaults_1.TypeDefaults.applyConfig({});
352
+ }
353
+ });
354
+ });
299
355
  describe('getConfigFile', () => {
300
356
  beforeEach(() => {
301
357
  config_defaults_1.ConfigDefaults.clearConfigCache();