@contrail/flexplm 1.1.42 → 1.1.43

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.
@@ -92,7 +92,7 @@ class BaseProcessPublishAssortment {
92
92
  return 'unknown';
93
93
  }
94
94
  const createdOnDate = new Date(createdOnString);
95
- createdOnDate.setDate(createdOnDate.getDate() - 1);
95
+ createdOnDate.setMonth(createdOnDate.getMonth() - 1);
96
96
  const createdOnStringMinus1 = createdOnDate.toISOString();
97
97
  const createdOn = 'ISGREATERTHAN ' + createdOnStringMinus1;
98
98
  const snapshots = await new sdk_1.Entities().get({
@@ -108,11 +108,10 @@ class BaseProcessPublishAssortment {
108
108
  if (snapshot && snapshot.versionNumber) {
109
109
  snapshotVersion = snapshot.versionNumber;
110
110
  }
111
- else if (!snapshot) {
111
+ else if (!snapshot && snapshots.length > 0) {
112
112
  const createdOnTime = new Date(createdOnString).getTime();
113
113
  const lastSnapshot = snapshots[snapshots.length - 1];
114
- const lastSnapshotTime = new Date(lastSnapshot.createdOn).getTime();
115
- if (createdOnTime > lastSnapshotTime) {
114
+ if (lastSnapshot?.createdOn && createdOnTime > new Date(lastSnapshot.createdOn).getTime()) {
116
115
  snapshotVersion = 'after: ' + lastSnapshot.versionNumber;
117
116
  }
118
117
  }
@@ -364,6 +364,55 @@ describe('getSnapshotVersion', () => {
364
364
  expect(getOptionsObject['criteria']['entityReference']).toEqual(assortment.createdForReference);
365
365
  expect(getOptionsObject['criteria']['createdOn'].indexOf('ISGREATERTHAN')).toEqual(0);
366
366
  });
367
+ it('doesnt find snapshot version, no snapshots returned', async () => {
368
+ const assortment = {
369
+ id: 'rm35clTNxvS4wm6y',
370
+ name: 'VibeIQ Fall 2023',
371
+ createdForReference: 'plan:w23wre'
372
+ };
373
+ const assortmentChangeId = 'sJbGx1Fpq1v2MmcI';
374
+ const apc = {
375
+ id: assortmentChangeId,
376
+ versionName: 'Version 1',
377
+ versionComments: 'Some Comments',
378
+ createdOn: '2023-01-15T19:13:58.902Z'
379
+ };
380
+ const snapshots = [];
381
+ entityObject = snapshots;
382
+ const versionHistoryNumber = await ppa.getSnapshotVersion(assortment, apc);
383
+ expect(versionHistoryNumber).toEqual('unknown');
384
+ expect(getOptionsObject['entityName']).toEqual('entity-snapshot');
385
+ expect(getOptionsObject['criteria']['entityReference']).toEqual(assortment.createdForReference);
386
+ expect(getOptionsObject['criteria']['createdOn'].indexOf('ISGREATERTHAN')).toEqual(0);
387
+ });
388
+ it('doesnt find snapshot version, last snapshot no createdOn', async () => {
389
+ const assortment = {
390
+ id: 'rm35clTNxvS4wm6y',
391
+ name: 'VibeIQ Fall 2023',
392
+ createdForReference: 'plan:w23wre'
393
+ };
394
+ const assortmentChangeId = 'sJbGx1Fpq1v2MmcI';
395
+ const apc = {
396
+ id: assortmentChangeId,
397
+ versionName: 'Version 1',
398
+ versionComments: 'Some Comments',
399
+ createdOn: '2023-01-15T19:13:58.902Z'
400
+ };
401
+ const versionNumber = 1234;
402
+ const snapshots = [
403
+ {
404
+ id: 'qewrwer',
405
+ assortmentChangeId: 'bad-id',
406
+ versionNumber
407
+ }
408
+ ];
409
+ entityObject = snapshots;
410
+ const versionHistoryNumber = await ppa.getSnapshotVersion(assortment, apc);
411
+ expect(versionHistoryNumber).toEqual('unknown');
412
+ expect(getOptionsObject['entityName']).toEqual('entity-snapshot');
413
+ expect(getOptionsObject['criteria']['entityReference']).toEqual(assortment.createdForReference);
414
+ expect(getOptionsObject['criteria']['createdOn'].indexOf('ISGREATERTHAN')).toEqual(0);
415
+ });
367
416
  });
368
417
  describe('getSeasonFederation', () => {
369
418
  const config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.1.42",
3
+ "version": "1.1.43",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -406,6 +406,66 @@ describe('getSnapshotVersion', () =>{
406
406
  expect(getOptionsObject['criteria']['createdOn'].indexOf('ISGREATERTHAN')).toEqual(0);
407
407
  });
408
408
 
409
+ it('doesnt find snapshot version, no snapshots returned', async () =>{
410
+ const assortment = {
411
+ id: 'rm35clTNxvS4wm6y',
412
+ name: 'VibeIQ Fall 2023',
413
+ createdForReference: 'plan:w23wre'
414
+ };
415
+ const assortmentChangeId = 'sJbGx1Fpq1v2MmcI';
416
+ const apc = {
417
+ id: assortmentChangeId,
418
+ versionName: 'Version 1',
419
+ versionComments: 'Some Comments',
420
+ createdOn: '2023-01-15T19:13:58.902Z'
421
+ };
422
+
423
+ const snapshots = [];
424
+
425
+ entityObject = snapshots;
426
+
427
+ const versionHistoryNumber = await ppa.getSnapshotVersion(assortment, apc);
428
+
429
+ expect(versionHistoryNumber).toEqual('unknown');
430
+ expect(getOptionsObject['entityName']).toEqual('entity-snapshot');
431
+ expect(getOptionsObject['criteria']['entityReference']).toEqual(assortment.createdForReference);
432
+ expect(getOptionsObject['criteria']['createdOn'].indexOf('ISGREATERTHAN')).toEqual(0);
433
+ });
434
+
435
+ it('doesnt find snapshot version, last snapshot no createdOn', async () =>{
436
+ const assortment = {
437
+ id: 'rm35clTNxvS4wm6y',
438
+ name: 'VibeIQ Fall 2023',
439
+ createdForReference: 'plan:w23wre'
440
+ };
441
+ const assortmentChangeId = 'sJbGx1Fpq1v2MmcI';
442
+ const apc = {
443
+ id: assortmentChangeId,
444
+ versionName: 'Version 1',
445
+ versionComments: 'Some Comments',
446
+ createdOn: '2023-01-15T19:13:58.902Z'
447
+ };
448
+
449
+ const versionNumber = 1234;
450
+ const snapshots = [
451
+ {
452
+ id: 'qewrwer',
453
+ assortmentChangeId: 'bad-id',
454
+ // createdOn: '2023-01-14T19:13:58.902Z',
455
+ versionNumber
456
+ }
457
+ ];
458
+
459
+ entityObject = snapshots;
460
+
461
+ const versionHistoryNumber = await ppa.getSnapshotVersion(assortment, apc);
462
+
463
+ expect(versionHistoryNumber).toEqual('unknown');
464
+ expect(getOptionsObject['entityName']).toEqual('entity-snapshot');
465
+ expect(getOptionsObject['criteria']['entityReference']).toEqual(assortment.createdForReference);
466
+ expect(getOptionsObject['criteria']['createdOn'].indexOf('ISGREATERTHAN')).toEqual(0);
467
+ });
468
+
409
469
  });
410
470
 
411
471
  describe('getSeasonFederation', () =>{
@@ -126,7 +126,7 @@ export class BaseProcessPublishAssortment {
126
126
  return 'unknown';
127
127
  }
128
128
  const createdOnDate = new Date(createdOnString);
129
- createdOnDate.setDate(createdOnDate.getDate() - 1);//subtract 1 day
129
+ createdOnDate.setMonth(createdOnDate.getMonth() - 1);//subtract 1 month
130
130
  const createdOnStringMinus1 = createdOnDate.toISOString();
131
131
  const createdOn = 'ISGREATERTHAN ' + createdOnStringMinus1;
132
132
 
@@ -143,11 +143,10 @@ export class BaseProcessPublishAssortment {
143
143
  let snapshotVersion = 'unknown';
144
144
  if(snapshot && snapshot.versionNumber){
145
145
  snapshotVersion = snapshot.versionNumber;
146
- } else if(!snapshot){
146
+ } else if(!snapshot && snapshots.length > 0){
147
147
  const createdOnTime = new Date(createdOnString).getTime();
148
148
  const lastSnapshot = snapshots[snapshots.length - 1];
149
- const lastSnapshotTime = new Date(lastSnapshot.createdOn).getTime();
150
- if(createdOnTime > lastSnapshotTime){
149
+ if(lastSnapshot?.createdOn && createdOnTime > new Date(lastSnapshot.createdOn).getTime()){
151
150
  snapshotVersion = 'after: ' + lastSnapshot.versionNumber;
152
151
  }
153
152