@contrail/flexplm 1.1.48 → 1.1.50

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.
@@ -19,6 +19,7 @@ export interface FCConfig {
19
19
  [key: string]: string[];
20
20
  };
21
21
  propertyMapping?: object;
22
+ [key: string]: any;
22
23
  }
23
24
  export interface ProductFederation {
24
25
  entityReference: string;
@@ -31,14 +31,14 @@ export declare class BaseProcessPublishAssortment {
31
31
  getSinceDate(assortmentId: any, assortmentPublishChangeId: any, apcHistory: object[]): Promise<Date>;
32
32
  getApcHistory(assortmentId: any): Promise<any>;
33
33
  protected updatedSinceDate(entity: any, sinceDate: Date): boolean;
34
- getSinceDateFromAPCSpecificDate(apcHistory: object[], assortmentPublishChangeId: string, specificDate: Date): Date;
35
- getSinceDateDaysPrevious(apcHistory: object[], assortmentPublishChangeId: string, daysBack: any): Date;
34
+ getSinceDateFromAPCSpecificDate(apcHistory: any[], assortmentPublishChangeId: string, specificDate: Date): Date;
35
+ getSinceDateDaysPrevious(apcHistory: any[], assortmentPublishChangeId: string, daysBack: any): Date;
36
36
  getSinceDateFromAPCs(apcHistory: any[], assortmentPublishChangeId: string, pastPublishCount?: number): Date;
37
37
  protected getPublisher(assortmentPublishChange: any): {};
38
38
  downloadAssortmentPublishChange(assortmentId: string, assortmentPublishChangeId: string): Promise<any>;
39
39
  downloadHydratedChangeDetail(assortmentPublishChange: any): Promise<any>;
40
40
  downloadAssortmentBaseline(assortmentPublishChange: any): Promise<any>;
41
- getDeleteChanges(assortmentPublishChange: any, apcHistory: object[], assortmentBaseline: any, sinceDate: Date): Promise<[]>;
41
+ getDeleteChanges(assortmentPublishChange: any, apcHistory: any[], assortmentBaseline: any, sinceDate: Date): Promise<[]>;
42
42
  getBaselineItemIds(assortmentBaseline: any): string[];
43
43
  downloadDeleteChanges(apc: any): Promise<any>;
44
44
  buildDeleteChanges(apc: any, previousApc: any): Promise<any>;
@@ -19,7 +19,7 @@ class BaseProcessPublishAssortment {
19
19
  this.config = _config;
20
20
  this.dc = _dc;
21
21
  this.mapFileUtil = _mapFileUtil;
22
- this.transformMapFile = this.config['transformMapFile'];
22
+ this.transformMapFile = this.config?.transformMapFile;
23
23
  }
24
24
  async process(event) {
25
25
  const assortmentPublishChangeId = event.assortmentPublishChangeId;
@@ -157,8 +157,8 @@ class BaseProcessPublishAssortment {
157
157
  async getSinceDate(assortmentId, assortmentPublishChangeId, apcHistory) {
158
158
  let sinceDate = null;
159
159
  let pastPublishCount = 1;
160
- if (this.config['sinceDate']) {
161
- const sinceDateString = '' + this.config['sinceDate'];
160
+ if (this.config?.sinceDate) {
161
+ const sinceDateString = '' + this.config?.sinceDate;
162
162
  if (sinceDateString && sinceDateString.indexOf('-') > 0) {
163
163
  const sinceDateParts = sinceDateString.split('-');
164
164
  if (sinceDateParts.length == 3) {
@@ -205,14 +205,14 @@ class BaseProcessPublishAssortment {
205
205
  return (updatedOn && new Date(updatedOn) > sinceDate);
206
206
  }
207
207
  getSinceDateFromAPCSpecificDate(apcHistory, assortmentPublishChangeId, specificDate) {
208
- const apc = apcHistory.find(apc => apc['id'] === assortmentPublishChangeId);
209
- const apcDate = new Date(apc['createdOn']);
208
+ const apc = apcHistory.find(apc => apc?.id === assortmentPublishChangeId);
209
+ const apcDate = new Date(apc?.createdOn);
210
210
  let afterDate = apcDate;
211
211
  let beforeDate = new Date(0);
212
212
  const sinceDate = specificDate;
213
213
  for (const tempapc of apcHistory) {
214
- if (assortmentPublishChangeId !== tempapc['id']) {
215
- const tempDate = new Date(tempapc['createdOn']);
214
+ if (assortmentPublishChangeId !== tempapc?.id) {
215
+ const tempDate = new Date(tempapc?.createdOn);
216
216
  if (tempDate < apcDate) {
217
217
  if (tempDate > sinceDate && tempDate < afterDate) {
218
218
  afterDate = tempDate;
@@ -227,14 +227,14 @@ class BaseProcessPublishAssortment {
227
227
  return selectedDate;
228
228
  }
229
229
  getSinceDateDaysPrevious(apcHistory, assortmentPublishChangeId, daysBack) {
230
- const apc = apcHistory.find(apc => apc['id'] === assortmentPublishChangeId);
231
- const apcDate = new Date(apc['createdOn']);
230
+ const apc = apcHistory.find(apc => apc?.id === assortmentPublishChangeId);
231
+ const apcDate = new Date(apc?.createdOn);
232
232
  let afterDate = apcDate;
233
233
  let beforeDate = new Date(0);
234
234
  const sinceDate = new Date(apcDate.getUTCFullYear(), apcDate.getUTCMonth(), apcDate.getUTCDate() - daysBack, 0, (0 - apcDate.getTimezoneOffset()), 0);
235
235
  for (const tempapc of apcHistory) {
236
- if (assortmentPublishChangeId !== tempapc['id']) {
237
- const tempDate = new Date(tempapc['createdOn']);
236
+ if (assortmentPublishChangeId !== tempapc?.id) {
237
+ const tempDate = new Date(tempapc?.createdOn);
238
238
  if (tempDate < apcDate) {
239
239
  if (tempDate > sinceDate && tempDate < afterDate) {
240
240
  afterDate = tempDate;
@@ -257,12 +257,12 @@ class BaseProcessPublishAssortment {
257
257
  return new Date(0);
258
258
  }
259
259
  const apc = apcHistory[apcIndex];
260
- const apcDate = new Date(apc['createdOn']);
260
+ const apcDate = new Date(apc?.createdOn);
261
261
  let sinceDate = new Date(0);
262
262
  const dateArray = [];
263
263
  for (const tempapc of apcHistory) {
264
- if (assortmentPublishChangeId !== tempapc['id']) {
265
- const tempDate = new Date(tempapc['createdOn']);
264
+ if (assortmentPublishChangeId !== tempapc?.id) {
265
+ const tempDate = new Date(tempapc?.createdOn);
266
266
  if (tempDate < apcDate) {
267
267
  dateArray.push(tempDate);
268
268
  }
@@ -321,16 +321,15 @@ class BaseProcessPublishAssortment {
321
321
  return undefined;
322
322
  }
323
323
  async getDeleteChanges(assortmentPublishChange, apcHistory, assortmentBaseline, sinceDate) {
324
- console.info('getDeleteChanges(): ' + assortmentPublishChange['id']);
324
+ console.info('getDeleteChanges(): ' + assortmentPublishChange?.id);
325
325
  console.info(sinceDate);
326
- const currentAPCIndex = apcHistory.findIndex(pc => pc['id'] === assortmentPublishChange['id']);
326
+ const currentAPCIndex = apcHistory.findIndex(pc => pc?.id === assortmentPublishChange?.id);
327
327
  console.info(' currentAPCIndex: ' + currentAPCIndex);
328
328
  if (currentAPCIndex == 0) {
329
329
  return [];
330
330
  }
331
331
  const previousApcIndex = (currentAPCIndex > 0) ? currentAPCIndex - 1 : 0;
332
- const apcCreatedOn = apcHistory[previousApcIndex]['createdOn'];
333
- console.info('apcCreatedOn: ' + apcCreatedOn);
332
+ const apcCreatedOn = apcHistory[previousApcIndex]?.createdOn;
334
333
  const apcDeletes = await this.downloadDeleteChanges(assortmentPublishChange);
335
334
  let previousApcDate = Date.parse(apcCreatedOn);
336
335
  const sinceDateMilliseconds = sinceDate.getTime();
@@ -345,21 +344,21 @@ class BaseProcessPublishAssortment {
345
344
  const currentAssortmentItemIds = this.getBaselineItemIds(assortmentBaseline);
346
345
  const deleteIds = (apcDeletes.length === 0)
347
346
  ? []
348
- : apcDeletes.map(item => item['itemId']);
347
+ : apcDeletes.map(item => item?.itemId);
349
348
  for (let i = currentAPCIndex - 1; i > 0; i--) {
350
349
  const workingAPC = apcHistory[i];
351
- previousApcDate = Date.parse(workingAPC['createdOn']);
350
+ previousApcDate = Date.parse(workingAPC?.createdOn);
352
351
  if (sinceDateMilliseconds === previousApcDate) {
353
352
  break;
354
353
  }
355
- if (workingAPC['deletes'] > 0) {
354
+ if (workingAPC?.deletes > 0) {
356
355
  const previousApc = (i > 0)
357
356
  ? apcHistory[i - 1]
358
357
  : undefined;
359
358
  const deleteChanges = await this.buildDeleteChanges(workingAPC, previousApc);
360
359
  console.info('checking deleteChanges');
361
360
  for (const dItem of deleteChanges) {
362
- const dItemId = dItem['itemId'];
361
+ const dItemId = dItem?.itemId;
363
362
  console.info(dItemId);
364
363
  if (!currentAssortmentItemIds.includes(dItemId) && !deleteIds.includes(dItemId)) {
365
364
  console.info('adding');
@@ -376,16 +375,16 @@ class BaseProcessPublishAssortment {
376
375
  }
377
376
  getBaselineItemIds(assortmentBaseline) {
378
377
  const itemIds = [];
379
- const assortmentItemsArray = assortmentBaseline['assortmentItems'];
378
+ const assortmentItemsArray = assortmentBaseline?.assortmentItems;
380
379
  for (const aItem of assortmentItemsArray) {
381
- itemIds.push(aItem['itemId']);
380
+ itemIds.push(aItem?.itemId);
382
381
  }
383
382
  return itemIds;
384
383
  }
385
384
  async downloadDeleteChanges(apc) {
386
385
  console.info('deleteDataDownloadLink-start');
387
386
  try {
388
- const link = apc['deleteDataDownloadLink'];
387
+ const link = apc?.deleteDataDownloadLink;
389
388
  const response = await fetch(link);
390
389
  const data = await response.json();
391
390
  return data;
@@ -397,15 +396,15 @@ class BaseProcessPublishAssortment {
397
396
  }
398
397
  async buildDeleteChanges(apc, previousApc) {
399
398
  console.info('buildDeleteChanges()');
400
- if (apc['deleteDataDownloadLink']) {
399
+ if (apc?.deleteDataDownloadLink) {
401
400
  const deleteChanges = await this.downloadDeleteChanges(apc);
402
401
  if (deleteChanges) {
403
402
  return deleteChanges;
404
403
  }
405
404
  }
406
405
  console.info('pulling down full APC');
407
- apc = await this.downloadAssortmentPublishChange(apc['assortmentId'], apc['id']);
408
- if (apc['deleteDataDownloadLink']) {
406
+ apc = await this.downloadAssortmentPublishChange(apc?.assortmentId, apc?.id);
407
+ if (apc?.deleteDataDownloadLink) {
409
408
  const deleteChanges = await this.downloadDeleteChanges(apc);
410
409
  if (deleteChanges) {
411
410
  return deleteChanges;
@@ -416,16 +415,16 @@ class BaseProcessPublishAssortment {
416
415
  }
417
416
  let previousBaseline;
418
417
  console.info('check previousApc');
419
- if (previousApc['assortmentBaselineDownloadLink']) {
418
+ if (previousApc?.assortmentBaselineDownloadLink) {
420
419
  previousBaseline = await this.downloadAssortmentBaseline(previousApc);
421
420
  }
422
421
  else {
423
422
  console.info('previousApc pulling down full APC');
424
- previousApc = await this.downloadAssortmentPublishChange(previousApc['assortmentId'], previousApc['id']);
423
+ previousApc = await this.downloadAssortmentPublishChange(previousApc?.assortmentId, previousApc?.id);
425
424
  previousBaseline = await this.downloadAssortmentBaseline(previousApc);
426
425
  }
427
- const deleteIds = apc['detail']['deletes'].map(dItem => dItem['id']);
428
- const deleteArray = previousBaseline['assortmentItems'].filter(aItem => deleteIds.includes(aItem['itemId']));
426
+ const deleteIds = apc?.detail?.deletes.map(dItem => dItem?.id);
427
+ const deleteArray = previousBaseline?.assortmentItems.filter(aItem => deleteIds.includes(aItem?.itemId));
429
428
  console.info('deleteArray.length: ' + deleteArray.length);
430
429
  return deleteArray;
431
430
  }
@@ -445,7 +444,7 @@ class BaseProcessPublishAssortment {
445
444
  getDeleteChangesAssortmentMap(deleteChanges) {
446
445
  const deleteItems = new Map();
447
446
  for (const dItem of deleteChanges) {
448
- deleteItems.set(dItem['itemId'], dItem);
447
+ deleteItems.set(dItem?.itemId, dItem);
449
448
  }
450
449
  return deleteItems;
451
450
  }
@@ -453,16 +452,13 @@ class BaseProcessPublishAssortment {
453
452
  console.info('getReleasedForDevelopmentItemAndFamilyIds');
454
453
  const releasedForDevelopmentItemIds = [];
455
454
  const itemFamilySet = new Set();
456
- const assortmentItemsArray = fullChange['assortmentItems'];
455
+ const assortmentItemsArray = fullChange?.assortmentItems;
457
456
  for (const aItem of assortmentItemsArray) {
458
457
  const meetsCriteria = this.meetsCriteria(aItem);
459
458
  const item = aItem?.item;
460
459
  const itemId = item?.id;
461
460
  const itemFamilyId = item?.itemFamilyId;
462
- console.debug('itemId: ' + item?.id);
463
- if (item && meetsCriteria) {
464
- console.debug('adding item to releasedForDevelopmentItemIds');
465
- console.debug('itemFamilyId: ' + item['itemFamilyId']);
461
+ if (meetsCriteria) {
466
462
  releasedForDevelopmentItemIds.push(itemId);
467
463
  if (!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId) {
468
464
  const familyItem = item?.itemFamily;
@@ -479,8 +475,7 @@ class BaseProcessPublishAssortment {
479
475
  const item = dItem?.item;
480
476
  const itemId = item?.id;
481
477
  const itemFamilyId = item?.itemFamilyId;
482
- console.debug('itemId: ' + item?.id);
483
- if (item && meetsCriteria) {
478
+ if (meetsCriteria) {
484
479
  releasedForDevelopmentItemIds.push(itemId);
485
480
  if (!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId) {
486
481
  const familyItem = item?.itemFamily;
@@ -497,11 +492,13 @@ class BaseProcessPublishAssortment {
497
492
  }
498
493
  }
499
494
  }
495
+ console.info('releasedForDevelopmentItemIds: ' + releasedForDevelopmentItemIds);
500
496
  return releasedForDevelopmentItemIds;
501
497
  }
502
498
  meetsCriteria(aItem) {
503
- const lifecycleStage = aItem?.item?.lifecycleStage;
504
- return lifecycleStage && !this.config.itemPreDevelopmentLifecycleStages.includes(lifecycleStage);
499
+ const item = aItem?.item;
500
+ const lifecycleStage = item?.lifecycleStage;
501
+ return !!lifecycleStage && !this.config.itemPreDevelopmentLifecycleStages.includes(lifecycleStage);
505
502
  }
506
503
  async processPublish(pcd, changeDetail, fullChange, deleteChanges) {
507
504
  console.info('processPublish-start');
@@ -523,7 +520,7 @@ class BaseProcessPublishAssortment {
523
520
  async sendEvents(events) {
524
521
  console.info('sendEvents()');
525
522
  const eventType = 'ASYNC_PUBLISH_SEASON';
526
- const sendMode = (this.config['sendMode'][eventType] || '').toLowerCase();
523
+ const sendMode = (this.config?.sendMode[eventType] || '').toLowerCase();
527
524
  switch (sendMode) {
528
525
  case 'sendtoflexplm':
529
526
  return this.sendToFlexPLM(events, eventType);
@@ -668,8 +665,8 @@ class BaseProcessPublishAssortment {
668
665
  }
669
666
  }
670
667
  for (const [itemId, delEntity] of assortmentItemDeleteMap) {
671
- const itemFamilyId = delEntity['item']['itemFamilyId'];
672
- const item = delEntity['item'];
668
+ const itemFamilyId = delEntity?.item?.itemFamilyId;
669
+ const item = delEntity?.item;
673
670
  if (!pcd.releasedForDevelopmentItemIds.includes(itemFamilyId) || !pcd.releasedForDevelopmentItemIds.includes(itemId)) {
674
671
  continue;
675
672
  }
@@ -734,7 +731,7 @@ class BaseProcessPublishAssortment {
734
731
  if (familyAssortmentItem) {
735
732
  const entityReference = itemFamilyChanges.itemFamilyId;
736
733
  const prodEntityData = (itemFamilyChanges.assortmentItemFullChangeMap.has(entityReference))
737
- ? itemFamilyChanges.assortmentItemFullChangeMap.get(entityReference)['item']
734
+ ? itemFamilyChanges.assortmentItemFullChangeMap.get(entityReference)?.item
738
735
  : itemFamilyChanges.itemFamilyObject;
739
736
  let seasonalData = await this.getSeasonalData(projectItem);
740
737
  seasonalData = await map_utils_1.MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, seasonalData, 'LCSProductSeasonLink', 'vibe2flex');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.1.48",
3
+ "version": "1.1.50",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -19,6 +19,7 @@ export interface FCConfig {
19
19
  [key:string]: string[]
20
20
  };
21
21
  propertyMapping?: object;
22
+ [key: string]: any;
22
23
  }
23
24
 
24
25
  export interface ProductFederation {
@@ -31,7 +31,7 @@ export class BaseProcessPublishAssortment {
31
31
  this.config = _config;
32
32
  this.dc = _dc;
33
33
  this.mapFileUtil = _mapFileUtil;
34
- this.transformMapFile = this.config['transformMapFile'];
34
+ this.transformMapFile = this.config?.transformMapFile;
35
35
  }
36
36
 
37
37
  public async process(event) {
@@ -204,8 +204,8 @@ export class BaseProcessPublishAssortment {
204
204
  let sinceDate = null;
205
205
 
206
206
  let pastPublishCount = 1;
207
- if (this.config['sinceDate']) {
208
- const sinceDateString = '' + this.config['sinceDate'];
207
+ if (this.config?.sinceDate) {
208
+ const sinceDateString = '' + this.config?.sinceDate;
209
209
  if(sinceDateString && sinceDateString.indexOf('-') > 0){
210
210
  const sinceDateParts = sinceDateString.split('-');
211
211
  if(sinceDateParts.length == 3){
@@ -254,15 +254,15 @@ export class BaseProcessPublishAssortment {
254
254
  return (updatedOn && new Date(updatedOn) > sinceDate);
255
255
  }
256
256
 
257
- getSinceDateFromAPCSpecificDate(apcHistory: object[], assortmentPublishChangeId: string, specificDate: Date):Date {
258
- const apc = apcHistory.find(apc => apc['id'] === assortmentPublishChangeId);
259
- const apcDate = new Date(apc['createdOn']);
257
+ getSinceDateFromAPCSpecificDate(apcHistory: any[], assortmentPublishChangeId: string, specificDate: Date):Date {
258
+ const apc = apcHistory.find(apc => apc?.id === assortmentPublishChangeId);
259
+ const apcDate = new Date(apc?.createdOn);
260
260
  let afterDate = apcDate;
261
261
  let beforeDate = new Date(0);
262
262
  const sinceDate = specificDate;
263
263
  for (const tempapc of apcHistory) {
264
- if (assortmentPublishChangeId !== tempapc['id']) {
265
- const tempDate = new Date(tempapc['createdOn']);
264
+ if (assortmentPublishChangeId !== tempapc?.id) {
265
+ const tempDate = new Date(tempapc?.createdOn);
266
266
  if (tempDate < apcDate) {
267
267
  if(tempDate > sinceDate && tempDate < afterDate){
268
268
  afterDate = tempDate;
@@ -275,9 +275,9 @@ export class BaseProcessPublishAssortment {
275
275
  const selectedDate = (beforeDate.getTime() !== 0)?beforeDate : afterDate;
276
276
  return selectedDate;
277
277
  }
278
- getSinceDateDaysPrevious(apcHistory: object[], assortmentPublishChangeId: string, daysBack):Date {
279
- const apc = apcHistory.find(apc => apc['id'] === assortmentPublishChangeId);
280
- const apcDate = new Date(apc['createdOn']);
278
+ getSinceDateDaysPrevious(apcHistory: any[], assortmentPublishChangeId: string, daysBack):Date {
279
+ const apc = apcHistory.find(apc => apc?.id === assortmentPublishChangeId);
280
+ const apcDate = new Date(apc?.createdOn);
281
281
  let afterDate = apcDate;
282
282
  let beforeDate = new Date(0);
283
283
  const sinceDate = new Date(
@@ -289,8 +289,8 @@ export class BaseProcessPublishAssortment {
289
289
  0);
290
290
 
291
291
  for (const tempapc of apcHistory) {
292
- if (assortmentPublishChangeId !== tempapc['id']) {
293
- const tempDate = new Date(tempapc['createdOn']);
292
+ if (assortmentPublishChangeId !== tempapc?.id) {
293
+ const tempDate = new Date(tempapc?.createdOn);
294
294
  if (tempDate < apcDate) {
295
295
  if(tempDate > sinceDate && tempDate < afterDate){
296
296
  afterDate = tempDate;
@@ -313,12 +313,12 @@ export class BaseProcessPublishAssortment {
313
313
  return new Date(0);
314
314
  }
315
315
  const apc = apcHistory[apcIndex];
316
- const apcDate = new Date(apc['createdOn']);
316
+ const apcDate = new Date(apc?.createdOn);
317
317
  let sinceDate = new Date(0);
318
318
  const dateArray = [];
319
319
  for (const tempapc of apcHistory) {
320
- if (assortmentPublishChangeId !== tempapc['id']) {
321
- const tempDate = new Date(tempapc['createdOn']);
320
+ if (assortmentPublishChangeId !== tempapc?.id) {
321
+ const tempDate = new Date(tempapc?.createdOn);
322
322
  if (tempDate < apcDate) {
323
323
  dateArray.push(tempDate);
324
324
  }
@@ -385,18 +385,17 @@ export class BaseProcessPublishAssortment {
385
385
  return undefined;
386
386
  }
387
387
 
388
- async getDeleteChanges(assortmentPublishChange, apcHistory: object[], assortmentBaseline, sinceDate: Date): Promise<[]>{
389
- console.info('getDeleteChanges(): ' + assortmentPublishChange['id']);
388
+ async getDeleteChanges(assortmentPublishChange, apcHistory: any[], assortmentBaseline, sinceDate: Date): Promise<[]>{
389
+ console.info('getDeleteChanges(): ' + assortmentPublishChange?.id);
390
390
  console.info(sinceDate);
391
- const currentAPCIndex = apcHistory.findIndex(pc => pc['id'] === assortmentPublishChange['id']);
391
+ const currentAPCIndex = apcHistory.findIndex(pc => pc?.id === assortmentPublishChange?.id);
392
392
  console.info(' currentAPCIndex: ' + currentAPCIndex);
393
393
  if(currentAPCIndex == 0){
394
394
  return [];
395
395
  }
396
396
  const previousApcIndex = (currentAPCIndex > 0)? currentAPCIndex-1: 0;
397
397
 
398
- const apcCreatedOn = apcHistory[previousApcIndex]['createdOn'];
399
- console.info('apcCreatedOn: ' + apcCreatedOn);
398
+ const apcCreatedOn = apcHistory[previousApcIndex]?.createdOn;
400
399
  const apcDeletes = await this.downloadDeleteChanges(assortmentPublishChange);
401
400
 
402
401
  let previousApcDate = Date.parse(apcCreatedOn);
@@ -413,24 +412,22 @@ export class BaseProcessPublishAssortment {
413
412
  const currentAssortmentItemIds = this.getBaselineItemIds(assortmentBaseline);
414
413
  const deleteIds = (apcDeletes.length === 0)
415
414
  ?[]
416
- :apcDeletes.map(item => item['itemId']);
417
- // console.log('currentAssortmentItemIds: ' + currentAssortmentItemIds);
418
- // console.log('deleteIds: ' + deleteIds);
415
+ :apcDeletes.map(item => item?.itemId);
419
416
 
420
417
  for(let i = currentAPCIndex -1; i > 0; i--) {
421
418
  const workingAPC = apcHistory[i];
422
- previousApcDate = Date.parse(workingAPC['createdOn']);
419
+ previousApcDate = Date.parse(workingAPC?.createdOn);
423
420
  if(sinceDateMilliseconds === previousApcDate){
424
421
  break;
425
422
  }
426
- if(workingAPC['deletes'] > 0){
423
+ if(workingAPC?.deletes > 0){
427
424
  const previousApc = (i > 0)
428
425
  ?apcHistory[i-1]
429
426
  :undefined;
430
427
  const deleteChanges = await this.buildDeleteChanges(workingAPC, previousApc);
431
428
  console.info('checking deleteChanges');
432
429
  for(const dItem of deleteChanges){
433
- const dItemId = dItem['itemId'];
430
+ const dItemId = dItem?.itemId;
434
431
  console.info(dItemId);
435
432
  if(!currentAssortmentItemIds.includes(dItemId) && !deleteIds.includes(dItemId)){
436
433
  console.info('adding');
@@ -449,10 +446,10 @@ export class BaseProcessPublishAssortment {
449
446
 
450
447
  getBaselineItemIds(assortmentBaseline): string[]{
451
448
  const itemIds = [];
452
- const assortmentItemsArray = assortmentBaseline['assortmentItems'];
449
+ const assortmentItemsArray = assortmentBaseline?.assortmentItems;
453
450
 
454
451
  for (const aItem of assortmentItemsArray) {
455
- itemIds.push(aItem['itemId']);
452
+ itemIds.push(aItem?.itemId);
456
453
  }
457
454
 
458
455
  return itemIds;
@@ -461,12 +458,9 @@ export class BaseProcessPublishAssortment {
461
458
  async downloadDeleteChanges(apc) {
462
459
  console.info('deleteDataDownloadLink-start');
463
460
  try {
464
- const link = apc['deleteDataDownloadLink'];
465
- // console.info('link: ' + link);
461
+ const link = apc?.deleteDataDownloadLink;
466
462
  const response = await fetch(link);
467
- // console.debug('Got deleteDataDownloadLink: ');
468
463
  const data = await response.json();
469
- // console.debug(JSON.stringify(data));
470
464
  return data;
471
465
 
472
466
  } catch (e) {
@@ -478,15 +472,15 @@ export class BaseProcessPublishAssortment {
478
472
  async buildDeleteChanges(apc, previousApc) {
479
473
  console.info('buildDeleteChanges()');
480
474
 
481
- if(apc['deleteDataDownloadLink']){
475
+ if(apc?.deleteDataDownloadLink){
482
476
  const deleteChanges = await this.downloadDeleteChanges(apc);
483
477
  if(deleteChanges){
484
478
  return deleteChanges;
485
479
  }
486
480
  }
487
481
  console.info('pulling down full APC');
488
- apc = await this.downloadAssortmentPublishChange(apc['assortmentId'], apc['id']);
489
- if(apc['deleteDataDownloadLink']){
482
+ apc = await this.downloadAssortmentPublishChange(apc?.assortmentId, apc?.id);
483
+ if(apc?.deleteDataDownloadLink){
490
484
  const deleteChanges = await this.downloadDeleteChanges(apc);
491
485
  if(deleteChanges){
492
486
  return deleteChanges;
@@ -498,18 +492,18 @@ export class BaseProcessPublishAssortment {
498
492
 
499
493
  let previousBaseline;
500
494
  console.info('check previousApc');
501
- if(previousApc['assortmentBaselineDownloadLink']){
495
+ if(previousApc?.assortmentBaselineDownloadLink){
502
496
  previousBaseline = await this.downloadAssortmentBaseline(previousApc);
503
497
  }else {
504
498
  console.info('previousApc pulling down full APC');
505
- previousApc = await this.downloadAssortmentPublishChange(previousApc['assortmentId'], previousApc['id']);
499
+ previousApc = await this.downloadAssortmentPublishChange(previousApc?.assortmentId, previousApc?.id);
506
500
  previousBaseline = await this.downloadAssortmentBaseline(previousApc);
507
501
  }
508
502
 
509
- const deleteIds = apc['detail']['deletes'].map(dItem => dItem['id']);
503
+ const deleteIds = apc?.detail?.deletes.map(dItem => dItem?.id);
510
504
 
511
505
  //building deletes based on previous baseline; because some APCs don't have delete data
512
- const deleteArray = previousBaseline['assortmentItems'].filter(aItem => deleteIds.includes(aItem['itemId']));
506
+ const deleteArray = previousBaseline?.assortmentItems.filter(aItem => deleteIds.includes(aItem?.itemId));
513
507
  console.info('deleteArray.length: ' + deleteArray.length);
514
508
  return deleteArray;
515
509
  }
@@ -550,7 +544,7 @@ export class BaseProcessPublishAssortment {
550
544
  const deleteItems = new Map<string, object>();
551
545
 
552
546
  for (const dItem of deleteChanges) {
553
- deleteItems.set(dItem['itemId'], dItem);
547
+ deleteItems.set(dItem?.itemId, dItem);
554
548
  }
555
549
 
556
550
  return deleteItems;
@@ -560,17 +554,14 @@ export class BaseProcessPublishAssortment {
560
554
  console.info('getReleasedForDevelopmentItemAndFamilyIds');
561
555
  const releasedForDevelopmentItemIds:string[] = [];
562
556
  const itemFamilySet = new Set<string>();
563
- const assortmentItemsArray = fullChange['assortmentItems'];
557
+ const assortmentItemsArray = fullChange?.assortmentItems;
564
558
 
565
559
  for (const aItem of assortmentItemsArray) {
566
560
  const meetsCriteria= this.meetsCriteria(aItem);
567
561
  const item = aItem?.item;
568
562
  const itemId = item?.id;
569
563
  const itemFamilyId = item?.itemFamilyId;
570
- console.debug('itemId: ' + item?.id);
571
- if(item && meetsCriteria){
572
- console.debug('adding item to releasedForDevelopmentItemIds');
573
- console.debug('itemFamilyId: ' + item['itemFamilyId']);
564
+ if(meetsCriteria){
574
565
  releasedForDevelopmentItemIds.push(itemId);
575
566
  if(!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId){
576
567
  const familyItem = item?.itemFamily;
@@ -588,8 +579,7 @@ export class BaseProcessPublishAssortment {
588
579
  const item = dItem?.item;
589
580
  const itemId = item?.id;
590
581
  const itemFamilyId = item?.itemFamilyId;
591
- console.debug('itemId: ' + item?.id);
592
- if(item && meetsCriteria) {
582
+ if(meetsCriteria) {
593
583
  releasedForDevelopmentItemIds.push(itemId);
594
584
  if(!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId){
595
585
  const familyItem = item?.itemFamily;
@@ -605,13 +595,15 @@ export class BaseProcessPublishAssortment {
605
595
  }
606
596
  }
607
597
  }
598
+ console.info('releasedForDevelopmentItemIds: ' + releasedForDevelopmentItemIds);
608
599
  return releasedForDevelopmentItemIds;
609
600
  }
610
601
 
611
602
  meetsCriteria(aItem): boolean {
612
- const lifecycleStage = aItem?.item?.lifecycleStage;
603
+ const item = aItem?.item;
604
+ const lifecycleStage = item?.lifecycleStage;
613
605
 
614
- return lifecycleStage && !this.config.itemPreDevelopmentLifecycleStages.includes(lifecycleStage);
606
+ return !!lifecycleStage && !this.config.itemPreDevelopmentLifecycleStages.includes(lifecycleStage);
615
607
  }
616
608
  async processPublish(pcd: PublishChangeData, changeDetail, fullChange, deleteChanges) {
617
609
  console.info('processPublish-start');
@@ -637,7 +629,7 @@ export class BaseProcessPublishAssortment {
637
629
  private async sendEvents(events: SeasonalPayload[]): Promise<any> {
638
630
  console.info('sendEvents()');
639
631
  const eventType = 'ASYNC_PUBLISH_SEASON';
640
- const sendMode = (this.config['sendMode'][eventType] || '').toLowerCase();
632
+ const sendMode = (this.config?.sendMode[eventType] || '').toLowerCase();
641
633
 
642
634
  switch (sendMode) {
643
635
  case 'sendtoflexplm':
@@ -794,9 +786,9 @@ export class BaseProcessPublishAssortment {
794
786
  }
795
787
 
796
788
  for(const [itemId, delEntity] of assortmentItemDeleteMap){
797
- const itemFamilyId = delEntity['item']['itemFamilyId'];
789
+ const itemFamilyId = delEntity?.item?.itemFamilyId;
798
790
 
799
- const item = delEntity['item'];
791
+ const item = delEntity?.item;
800
792
  if(!pcd.releasedForDevelopmentItemIds.includes(itemFamilyId) || !pcd.releasedForDevelopmentItemIds.includes(itemId)){
801
793
  continue;
802
794
  } else {
@@ -886,7 +878,7 @@ export class BaseProcessPublishAssortment {
886
878
  //Product-season add
887
879
  const entityReference = itemFamilyChanges.itemFamilyId;
888
880
  const prodEntityData = (itemFamilyChanges.assortmentItemFullChangeMap.has(entityReference))
889
- ? itemFamilyChanges.assortmentItemFullChangeMap.get(entityReference)['item']
881
+ ? itemFamilyChanges.assortmentItemFullChangeMap.get(entityReference)?.item
890
882
  : itemFamilyChanges.itemFamilyObject;
891
883
 
892
884
  let seasonalData = await this.getSeasonalData(projectItem);