// <auto-generated />
// This file is auto-generated from core/vault/src/sql/VaultVersions.ts
// Do not edit this file directly. Run './build.sh' in core/vault to regenerate.
// swiftlint:disable all

import Foundation

/// Vault database version information.
public struct VaultVersion {
    /// The migration revision number.
    public let revision: Int

    /// The internal migration version number that equals the AliasClientDb database version (e.g., "1.5.0").
    public let version: String

    /// Description of changes in this version.
    public let description: String

    /// The AliasVault release that this vault version was introduced in (e.g., "0.14.0").
    public let releaseVersion: String

    /// The last AliasVault release version that the vault was compatible with before requiring this migration.
    public let compatibleUpToVersion: String
}

/// Registry of all vault versions.
public struct VaultVersions {
    /// All vault migrations/versions in chronological order.
    public static let all: [VaultVersion] = [
        VaultVersion(
            revision: 1,
            version: "1.0.0",
            description: "Initial Migration",
            releaseVersion: "0.1.0",
            compatibleUpToVersion: "0.0.0"
        ),
        VaultVersion(
            revision: 2,
            version: "1.0.1",
            description: "Empty Test Migration",
            releaseVersion: "0.2.0",
            compatibleUpToVersion: "0.1.0"
        ),
        VaultVersion(
            revision: 3,
            version: "1.0.2",
            description: "Change Email Column",
            releaseVersion: "0.3.0",
            compatibleUpToVersion: "0.2.0"
        ),
        VaultVersion(
            revision: 4,
            version: "1.1.0",
            description: "Add Pki Tables",
            releaseVersion: "0.4.0",
            compatibleUpToVersion: "0.3.0"
        ),
        VaultVersion(
            revision: 5,
            version: "1.2.0",
            description: "Add Settings Table",
            releaseVersion: "0.4.0",
            compatibleUpToVersion: "0.3.0"
        ),
        VaultVersion(
            revision: 6,
            version: "1.3.0",
            description: "Update Identity Structure",
            releaseVersion: "0.5.0",
            compatibleUpToVersion: "0.4.0"
        ),
        VaultVersion(
            revision: 7,
            version: "1.3.1",
            description: "Make Username Optional",
            releaseVersion: "0.5.0",
            compatibleUpToVersion: "0.4.0"
        ),
        VaultVersion(
            revision: 8,
            version: "1.4.0",
            description: "Add Sync Support",
            releaseVersion: "0.6.0",
            compatibleUpToVersion: "0.5.0"
        ),
        VaultVersion(
            revision: 9,
            version: "1.4.1",
            description: "Rename Attachments Plural",
            releaseVersion: "0.6.0",
            compatibleUpToVersion: "0.13.0"
        ),
        VaultVersion(
            revision: 10,
            version: "1.5.0",
            description: "Add 2FA Tokens to credentials",
            releaseVersion: "0.14.0",
            compatibleUpToVersion: "0.23.0"
        ),
        VaultVersion(
            revision: 11,
            version: "1.6.0",
            description: "Add Passkey support",
            releaseVersion: "0.24.0",
            compatibleUpToVersion: "0.25.0"
        ),
        VaultVersion(
            revision: 12,
            version: "1.7.0",
            description: "Update to Field-Based Data Model",
            releaseVersion: "0.26.0",
            compatibleUpToVersion: "0.26.0"
        )
    ]

    /// Get the latest vault version.
    public static var latest: VaultVersion {
        return all.last!
    }

    /// Get the latest vault version string (e.g., "1.7.0").
    public static var latestVersion: String {
        return latest.version
    }

    /// Get the latest vault revision number.
    public static var latestRevision: Int {
        return latest.revision
    }

    /// Find a vault version by revision number.
    public static func findByRevision(_ revision: Int) -> VaultVersion? {
        return all.first { $0.revision == revision }
    }

    /// Find a vault version by version string.
    public static func findByVersion(_ version: String) -> VaultVersion? {
        return all.first { $0.version == version }
    }
}

// swiftlint:enable all
