Class: MigrationRegistry
Defined in: electron/services/monitoring/MigrationSystem.ts:342
Registry for migration rules per monitor type.
Remarks
Stores and retrieves migration rules, calculates migration paths, and validates migration feasibility. Used by orchestrators and migration utilities.
Constructors
Constructor
new MigrationRegistry():
MigrationRegistry
Returns
MigrationRegistry
Properties
migrations
privatereadonlymigrations:Map<string,MigrationRule[]>
Defined in: electron/services/monitoring/MigrationSystem.ts:353
Internal
Internal storage for migration rules organized by monitor type.
Remarks
Maps monitor type strings to arrays of MigrationRule objects. Rules are automatically sorted by source version when added via registerMigration.
Methods
canMigrate()
canMigrate(
monitorType:string,fromVersion:string,toVersion:string):boolean
Defined in: electron/services/monitoring/MigrationSystem.ts:374
Determines if migration is possible between two versions for a monitor type.
Parameters
monitorType
string
The monitor type identifier (e.g., "http", "ping", "dns")
fromVersion
string
The source semantic version string (e.g., "1.0.0")
toVersion
string
The target semantic version string (e.g., "1.1.0")
Returns
boolean
True if a valid migration path exists, false if no path is available
Remarks
Returns true if a valid migration path exists, false otherwise. Does not mutate registry state. Internally calls getMigrationPath and catches any exceptions to determine feasibility.
See
getMigrationPath for the underlying path calculation logic
getMigrationPath()
getMigrationPath(
monitorType:string,fromVersion:string,toVersion:string):MigrationRule[]
Defined in: electron/services/monitoring/MigrationSystem.ts:421
Calculates the migration path (sequence of rules) from one version to another.
Parameters
monitorType
string
The monitor type identifier (e.g., "http", "ping", "dns")
fromVersion
string
The source semantic version string (e.g., "1.0.0")
toVersion
string
The target semantic version string (e.g., "1.1.0")
Returns
Array of MigrationRule objects to apply in sequential order
Remarks
Uses a graph traversal algorithm to find the sequence of MigrationRule objects needed to migrate from source to target version. Validates version strings before processing and includes safety checks for circular paths and excessive migration chains.
Algorithm ensures no infinite loops by tracking visited versions and enforces a maximum path length limit defined by MAX_MIGRATION_STEPS to prevent excessive migration chains that could indicate design issues.
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When no migration path exists from source to target version
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When a circular migration path is detected during traversal
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When the migration path exceeds MAX_MIGRATION_STEPS limit
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When version strings are invalid or malformed
See
- validateVersionString for version validation logic
- registerMigration for how migration rules are stored
registerMigration()
registerMigration(
monitorType:string,rule:MigrationRule):void
Defined in: electron/services/monitoring/MigrationSystem.ts:501
Registers a migration rule for a specific monitor type.
Parameters
monitorType
string
The monitor type identifier (e.g., "http", "ping", "dns")
rule
The MigrationRule object containing transformation logic
Returns
void
Remarks
Adds the MigrationRule to the registry and automatically sorts all rules for the monitor type by source version using compareVersions. Creates a new rule array if this is the first rule for the monitor type. Logs the registration using structured logging templates.
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When the migration rules array cannot be created or retrieved for the specified monitor type (should rarely occur)
See
- compareVersions for version sorting logic
- MigrationRule for rule structure requirements
compareVersions()
privatecompareVersions(a:string,b:string):number
Defined in: electron/services/monitoring/MigrationSystem.ts:555
Internal
Compares two semantic version strings for sorting purposes.
Parameters
a
string
First semantic version string to compare (e.g., "1.0.0")
b
string
Second semantic version string to compare (e.g., "1.1.0")
Returns
number
-1 if a < b, 1 if a > b, 0 if versions are equal
Remarks
Implements lexicographic comparison of semantic version components. Validates both version strings using validateVersionString before comparison to prevent NaN comparisons from malformed versions. Uses numeric comparison of major.minor.patch components, treating missing components as 0.
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When either version string is malformed or invalid
See
validateVersionString for version validation logic
validateVersionString()
privatevalidateVersionString(version:string,parameterName:string):void
Defined in: electron/services/monitoring/MigrationSystem.ts:598
Internal
Validates a version string format to ensure safe processing.
Parameters
version
string
The semantic version string to validate (e.g., "1.0.0")
parameterName
string
The parameter name for error reporting context
Returns
void
Remarks
Performs comprehensive validation of semantic version strings using the validator.js isSemVer function for SemVer 2.0.0 compliance. Additionally validates numeric components to prevent overflow conditions and injection attacks. Extracts base version components while ignoring pre-release and build metadata.
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When version is not a non-empty string
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When version does not follow semantic versioning format
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When version contains invalid numeric parts (NaN, negative, or exceeds MAX_SAFE_INTEGER)
See
isSemVer for semantic version format validation