meadow-integration 1.0.31 → 1.0.32

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meadow-integration",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "description": "Meadow Data Integration",
5
5
  "bin": {
6
6
  "mdwint": "source/cli/Meadow-Integration-CLI-Run.js"
@@ -458,7 +458,13 @@ class MeadowSyncEntityInitial extends libFableServiceProviderBase
458
458
  },
459
459
  (fStageComplete) =>
460
460
  {
461
- tmpSyncState.EstimatedRecordCount = tmpSyncState.Server.RecordCount - tmpSyncState.Local.RecordCount;
461
+ // The raw diff can be negative when local has more records
462
+ // than the server (e.g. records were deleted server-side but
463
+ // the local copy still has them). Clamp the estimate to 0
464
+ // so progress trackers and downstream reports never show a
465
+ // negative total.
466
+ let tmpRawEstimate = tmpSyncState.Server.RecordCount - tmpSyncState.Local.RecordCount;
467
+ tmpSyncState.EstimatedRecordCount = Math.max(0, tmpRawEstimate);
462
468
 
463
469
  // Apply MaxRecordsPerEntity cap if configured
464
470
  tmpSyncState.RecordCap = (this.MaxRecordsPerEntity > 0)
@@ -474,6 +480,29 @@ class MeadowSyncEntityInitial extends libFableServiceProviderBase
474
480
  this.operation.createProgressTracker(tmpSyncState.EstimatedRecordCount, `FullSync-${this.EntitySchema.TableName}`);
475
481
  this.operation.printProgressTrackerStatus(`FullSync-${this.EntitySchema.TableName}`);
476
482
 
483
+ // Fast path: if there is nothing new to pull (estimate is
484
+ // zero or negative), skip the download phase entirely.
485
+ // Running the paginated loop would otherwise make one or
486
+ // more requests just to receive an empty response and then
487
+ // short-circuit with an "Error: Records depleted!" log —
488
+ // noisy and a waste of round-trips. Zero out RecordCap
489
+ // as well so the advanced-ID-pagination loop
490
+ // (which gates on RecordCap, not URLPartials) also skips.
491
+ if (tmpSyncState.EstimatedRecordCount <= 0)
492
+ {
493
+ tmpSyncState.URLPartials = [];
494
+ tmpSyncState.RecordCap = 0;
495
+ if (tmpRawEstimate < 0)
496
+ {
497
+ this.fable.log.info(`${this.EntitySchema.TableName}: local has ${-tmpRawEstimate} more record(s) than server (local: ${tmpSyncState.Local.RecordCount}, server: ${tmpSyncState.Server.RecordCount}); nothing to download.`);
498
+ }
499
+ else
500
+ {
501
+ this.fable.log.info(`${this.EntitySchema.TableName}: record counts match (${tmpSyncState.Server.RecordCount}); nothing to download.`);
502
+ }
503
+ return fStageComplete();
504
+ }
505
+
477
506
  if (this.UseAdvancedIDPagination)
478
507
  {
479
508
  this.fable.log.info(`${this.EntitySchema.TableName}: using advanced ID pagination (local: ${tmpSyncState.Local.RecordCount}/${tmpSyncState.Local.MaxIDEntity}, server: ${tmpSyncState.Server.RecordCount}/${tmpSyncState.Server.MaxIDEntity}, estimated new: ${tmpSyncState.EstimatedRecordCount}${this.MaxRecordsPerEntity > 0 ? `, capped at ${this.MaxRecordsPerEntity}` : ''})`);