Skip to main content

Class: MigrationOrchestrator

Defined in: electron/services/monitoring/MigrationSystem.ts:140

Orchestrates migration of monitor configuration data for a given monitor type.

Remarks

Applies registered migration rules in sequence to upgrade monitor data. Handles errors, warnings, and version updates. Used internally by the migration system and exposed via factory.

Constructors

Constructor

new MigrationOrchestrator(registry: MigrationRegistry, versionManager: VersionManager): MigrationOrchestrator

Defined in: electron/services/monitoring/MigrationSystem.ts:323

Constructs a new MigrationOrchestrator instance.

Parameters

registry

MigrationRegistry

The MigrationRegistry instance containing migration rules

versionManager

VersionManager

The VersionManager instance for tracking version state

Returns

MigrationOrchestrator

Remarks

Creates an orchestrator that coordinates migration operations between the provided registry and version manager. Both dependencies are required for proper migration functionality.

Properties

registry

private readonly registry: MigrationRegistry

Defined in: electron/services/monitoring/MigrationSystem.ts:141


versionManager

private readonly versionManager: VersionManager

Defined in: electron/services/monitoring/MigrationSystem.ts:143

Methods

migrateMonitorData()

migrateMonitorData(monitorType: string, data: UnknownRecord, fromVersion: string, toVersion: string): Promise<{ appliedMigrations: string[]; data?: UnknownRecord; errors: string[]; success: boolean; warnings: string[]; }>

Defined in: electron/services/monitoring/MigrationSystem.ts:198

Migrates monitor configuration data from one version to another.

Parameters

monitorType

string

The monitor type identifier (e.g., "http", "ping", "dns")

data

UnknownRecord

The UnknownRecord monitor configuration data to migrate

fromVersion

string

The current semantic version of the data (e.g., "1.0.0")

toVersion

string

The target semantic version to migrate to (e.g., "1.1.0")

Returns

Promise<{ appliedMigrations: string[]; data?: UnknownRecord; errors: string[]; success: boolean; warnings: string[]; }>

A Promise resolving to an object containing:

  • appliedMigrations: Array of migration identifiers that were applied
  • data: The transformed configuration data (undefined if errors occurred)
  • errors: Array of error messages encountered during migration
  • success: Boolean indicating if all migrations completed successfully
  • warnings: Array of warning messages (e.g., breaking migration notices)

Remarks

Orchestrates the complete migration process by finding the migration path using MigrationRegistry.getMigrationPath, applying each MigrationRule.transform sequentially, and updating version state on success. Uses withErrorHandling for consistent error handling and structured logging throughout the process.

The method accumulates errors and warnings during execution, stopping on the first transformation failure. Version state is only updated if all migrations complete successfully and at least one migration was applied.

Example

const result = await orchestrator.migrateMonitorData(
"http",
{ url: "example.com" },
"1.0.0",
"1.1.0"
);
if (result.success) {
logger.info(`Applied ${result.appliedMigrations.length} migrations`);
}

Throws

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When migration orchestration fails due to unexpected errors not related to individual transformation failures

See