add: expose source report for cloud.

This commit is contained in:
Darshan 2025-05-01 11:22:19 +05:30
parent bf9deb09f5
commit d137b41c0b

View file

@ -34,6 +34,13 @@ class Migrations extends Action
protected Document $project; protected Document $project;
/**
* Accessed on cloud for telemetry.
*
* @type array<string, int>
*/
private array $sourceReport = [];
/** /**
* @var callable * @var callable
*/ */
@ -101,7 +108,7 @@ class Migrations extends Action
$source = $migration->getAttribute('source'); $source = $migration->getAttribute('source');
$credentials = $migration->getAttribute('credentials'); $credentials = $migration->getAttribute('credentials');
return match ($source) { $migrationSource = match ($source) {
Firebase::getName() => new Firebase( Firebase::getName() => new Firebase(
json_decode($credentials['serviceAccount'], true), json_decode($credentials['serviceAccount'], true),
), ),
@ -130,6 +137,10 @@ class Migrations extends Action
), ),
default => throw new \Exception('Invalid source type'), default => throw new \Exception('Invalid source type'),
}; };
$this->sourceReport = $migrationSource->report();
return $migrationSource;
} }
/** /**
@ -381,4 +392,16 @@ class Migrations extends Action
} }
} }
} }
/**
* Returns a report of resources in the source.
*
* Should be called after `processSource()` to ensure the data is populated.
*
* @return array<string, int> Resource type mapped to their counts.
*/
protected function getSourceReport(): array
{
return $this->sourceReport;
}
} }