@contrail/flexplm 1.1.25 → 1.1.26

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.
@@ -374,20 +374,53 @@ class DataConverter {
374
374
  }
375
375
  }
376
376
  if (!objectReferenceId) {
377
- console.warn(`The passed in object reference criteria ${JSON.stringify(combinedCriteria)} not found.`);
377
+ console.warn(`The passed in object reference criteria ${JSON.stringify(combinedCriteria)} didn't match any entities.`);
378
378
  return objectReferenceId;
379
379
  }
380
380
  this.objRefCache[cacheKey] = objectReferenceId;
381
381
  return objectReferenceId;
382
382
  }
383
383
  async getAllObjectReferences(entityType, rootTypeCriteria) {
384
+ const entities = new sdk_1.Entities();
384
385
  let loads = [];
385
386
  let nextPageKey;
387
+ let usedV2 = false;
386
388
  do {
387
- const loadPage = await new sdk_1.Entities().get({ entityName: entityType, criteria: rootTypeCriteria, apiVersion: sdk_1.API_VERSION.V2, nextPageKey });
388
- nextPageKey = loadPage.nextPageKey;
389
- loads.push(...loadPage.results);
389
+ const loadPage = await entities.get({
390
+ entityName: entityType,
391
+ criteria: rootTypeCriteria,
392
+ apiVersion: sdk_1.API_VERSION.V2,
393
+ nextPageKey,
394
+ });
395
+ nextPageKey = loadPage?.nextPageKey;
396
+ if (Object.keys(loadPage).includes('results')) {
397
+ usedV2 = true;
398
+ loads.push(...loadPage.results);
399
+ }
400
+ else {
401
+ nextPageKey = null;
402
+ }
390
403
  } while (nextPageKey);
404
+ if (!usedV2) {
405
+ const take = 1000;
406
+ let skip = 0;
407
+ let done = false;
408
+ while (!done) {
409
+ const loadPage = await entities.get({
410
+ entityName: entityType,
411
+ criteria: rootTypeCriteria,
412
+ take,
413
+ skip,
414
+ });
415
+ loads.push(...loadPage);
416
+ if (loadPage.length !== take) {
417
+ done = true;
418
+ }
419
+ else {
420
+ skip += take;
421
+ }
422
+ }
423
+ }
391
424
  return loads;
392
425
  }
393
426
  checkKeysAndValues(criteria, arrayOfObjects, entityTypePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -458,7 +458,7 @@ export class DataConverter {
458
458
  }
459
459
 
460
460
  if (!objectReferenceId) {
461
- console.warn(`The passed in object reference criteria ${JSON.stringify(combinedCriteria)} not found.`);
461
+ console.warn(`The passed in object reference criteria ${JSON.stringify(combinedCriteria)} didn't match any entities.`);
462
462
  return objectReferenceId;
463
463
  }
464
464
 
@@ -475,13 +475,47 @@ export class DataConverter {
475
475
  * @returns {Promise<Array>} A Promise that resolves to an array containing all object references.
476
476
  */
477
477
  async getAllObjectReferences(entityType, rootTypeCriteria) {
478
- let loads = []
478
+ const entities = new Entities();
479
+ let loads = [];
479
480
  let nextPageKey;
481
+ let usedV2 = false;
480
482
  do {
481
- const loadPage = await new Entities().get({ entityName: entityType, criteria: rootTypeCriteria, apiVersion: API_VERSION.V2, nextPageKey })
482
- nextPageKey = loadPage.nextPageKey;
483
- loads.push(...loadPage.results);
483
+ const loadPage = await entities.get({
484
+ entityName: entityType,
485
+ criteria: rootTypeCriteria,
486
+ apiVersion: API_VERSION.V2,
487
+ nextPageKey,
488
+ });
489
+ nextPageKey = loadPage?.nextPageKey;
490
+ if (Object.keys(loadPage).includes('results')) {
491
+ usedV2 = true;
492
+ loads.push(...loadPage.results);
493
+ } else {
494
+ nextPageKey = null;
495
+ }
484
496
  } while (nextPageKey);
497
+
498
+ if (!usedV2) {
499
+ const take = 1000;
500
+ let skip = 0;
501
+ let done = false;
502
+ while (!done) {
503
+ const loadPage = await entities.get({
504
+ entityName: entityType,
505
+ criteria: rootTypeCriteria,
506
+ take,
507
+ skip,
508
+ });
509
+ loads.push(...loadPage);
510
+
511
+ if (loadPage.length !== take) {
512
+ done = true;
513
+ } else {
514
+ skip += take;
515
+ }
516
+ }
517
+ }
518
+
485
519
  return loads;
486
520
  }
487
521