/**
 * SmartDB/SmartData manager for Onebox.
 *
 * Backend code works with SmartData document instances directly. DTO/plain-object
 * serialization belongs at API boundaries, where doc.toJSON()/doc.toData() is used.
 */
import * as plugins from '../plugins.js';
import type { IBackup, IBackupSchedule, IBackupScheduleUpdate, ICertificate, ICertRequirement, IDomain, IHostedAppLifecycleRecord, IHostedAppLifecycleState, ILogEntry, IMetric, IPasskeyCredential, IPlatformResource, IPlatformService, IRegistry, IRegistryToken, IService, IServiceVolume, ISslCertificate, IStorageClass, IStorageTarget, IUser, TPlatformServiceType, TStorageClassPurpose } from '../types.js';
import { SecretSettingsManager } from './secret-settings.js';
import { ServiceSecretsManager } from './service-secrets.js';
import { BackupDoc, BackupScheduleDoc, CertificateDoc, CertRequirementDoc, DnsRecordDoc, DomainDoc, HostedAppLifecycleDoc, LogEntryDoc, MetadataDoc, MetricDoc, PlatformResourceDoc, PlatformServiceDoc, RegistryDoc, RegistryTokenDoc, SecretSettingDoc, ServiceSecretBundleDoc, ServiceDoc, SettingDoc, StorageClassDoc, StorageTargetDoc, type TDnsRecordWithZone, UserDoc } from './docs.js';
type TSmartDataDocClass<TDoc> = {
    new (dataArg?: Partial<any>): TDoc;
    getInstances(filterArg: Record<string, unknown>): Promise<TDoc[]>;
    getInstance(filterArg: Record<string, unknown>): Promise<TDoc | null>;
};
export declare class OneboxDatabase {
    private localSmartDb;
    private smartdataDb;
    private smartDbPath;
    CMetadata: TSmartDataDocClass<MetadataDoc> & typeof MetadataDoc;
    CService: TSmartDataDocClass<ServiceDoc> & typeof ServiceDoc;
    CServiceSecretBundle: TSmartDataDocClass<ServiceSecretBundleDoc> & typeof ServiceSecretBundleDoc;
    CHostedAppLifecycle: TSmartDataDocClass<HostedAppLifecycleDoc> & typeof HostedAppLifecycleDoc;
    CRegistry: TSmartDataDocClass<RegistryDoc> & typeof RegistryDoc;
    CRegistryToken: TSmartDataDocClass<RegistryTokenDoc> & typeof RegistryTokenDoc;
    CStorageTarget: TSmartDataDocClass<StorageTargetDoc> & typeof StorageTargetDoc;
    CStorageClass: TSmartDataDocClass<StorageClassDoc> & typeof StorageClassDoc;
    CSetting: TSmartDataDocClass<SettingDoc> & typeof SettingDoc;
    CSecretSetting: TSmartDataDocClass<SecretSettingDoc> & typeof SecretSettingDoc;
    CUser: TSmartDataDocClass<UserDoc> & typeof UserDoc;
    CMetric: TSmartDataDocClass<MetricDoc> & typeof MetricDoc;
    CLogEntry: TSmartDataDocClass<LogEntryDoc> & typeof LogEntryDoc;
    CDomain: TSmartDataDocClass<DomainDoc> & typeof DomainDoc;
    CCertificate: TSmartDataDocClass<CertificateDoc> & typeof CertificateDoc;
    CCertRequirement: TSmartDataDocClass<CertRequirementDoc> & typeof CertRequirementDoc;
    CDnsRecord: TSmartDataDocClass<DnsRecordDoc> & typeof DnsRecordDoc;
    CPlatformService: TSmartDataDocClass<PlatformServiceDoc> & typeof PlatformServiceDoc;
    CPlatformResource: TSmartDataDocClass<PlatformResourceDoc> & typeof PlatformResourceDoc;
    CBackup: TSmartDataDocClass<BackupDoc> & typeof BackupDoc;
    CBackupSchedule: TSmartDataDocClass<BackupScheduleDoc> & typeof BackupScheduleDoc;
    secretSettings: SecretSettingsManager;
    serviceSecrets: ServiceSecretsManager;
    constructor(smartDbPath?: string);
    get db(): plugins.smartdata.SmartdataDb;
    init(): Promise<void>;
    close(): Promise<void>;
    private getNextNumericId;
    private createInitializedDoc;
    private createDoc;
    private deleteNumberedDoc;
    private deleteKeyedDoc;
    private normalizeServicePortFields;
    createService(service: Omit<IService, 'id'>): Promise<ServiceDoc>;
    getServiceByName(name: string): Promise<ServiceDoc | null>;
    getServiceByID(id: number): Promise<ServiceDoc | null>;
    getAllServices(): Promise<ServiceDoc[]>;
    updateService(id: number, updates: Partial<Omit<IService, 'containerArgs' | 'secretFiles'>> & {
        containerArgs?: IService['containerArgs'] | null;
        secretFiles?: IService['secretFiles'] | null;
    }): Promise<void>;
    replaceService(idArg: number, serviceArg: IService): Promise<void>;
    deleteService(id: number): Promise<void>;
    markServiceRuntimeCleanupRequired(idArg: number, containerIDArg?: string): Promise<void>;
    clearServiceImageCleanup(idArg: number): Promise<void>;
    upsertHostedAppLifecycle(recordArg: Omit<IHostedAppLifecycleRecord, 'id' | 'createdAt' | 'updatedAt'>): Promise<HostedAppLifecycleDoc>;
    getRawServiceSecrets(serviceIdArg: number): Promise<string | null>;
    setRawServiceSecrets(serviceIdArg: number, encryptedValuesArg: string): Promise<void>;
    deleteRawServiceSecrets(serviceIdArg: number): Promise<void>;
    getHostedAppLifecycleByServiceId(serviceIdArg: number): Promise<HostedAppLifecycleDoc | null>;
    getHostedAppLifecycleByInstanceId(appInstanceIdArg: string): Promise<HostedAppLifecycleDoc | null>;
    updateHostedAppLifecycleState(serviceIdArg: number, stateArg: IHostedAppLifecycleState): Promise<HostedAppLifecycleDoc>;
    createRegistry(registry: Omit<IRegistry, 'id'>): Promise<RegistryDoc>;
    getRegistryByURL(url: string): Promise<RegistryDoc | null>;
    getAllRegistries(): Promise<RegistryDoc[]>;
    deleteRegistry(url: string): Promise<void>;
    private normalizeStorageName;
    private getDefaultBackupPath;
    private getDefaultPlatformDataBaseDir;
    private getStorageVolumeDirectoryName;
    private upsertDefaultStorageTarget;
    private upsertDefaultStorageClass;
    ensureDefaultStorageConfig(): Promise<void>;
    createStorageTarget(targetArg: Omit<IStorageTarget, 'id' | 'createdAt' | 'updatedAt'>): Promise<StorageTargetDoc>;
    upsertStorageTarget(targetArg: Omit<IStorageTarget, 'id' | 'createdAt' | 'updatedAt'> & {
        id?: number;
    }): Promise<StorageTargetDoc>;
    getStorageTargetByName(nameArg: string): Promise<StorageTargetDoc | null>;
    getAllStorageTargets(): Promise<StorageTargetDoc[]>;
    deleteStorageTarget(nameArg: string): Promise<void>;
    createStorageClass(storageClassArg: Omit<IStorageClass, 'id' | 'createdAt' | 'updatedAt'>): Promise<StorageClassDoc>;
    upsertStorageClass(storageClassArg: Omit<IStorageClass, 'id' | 'createdAt' | 'updatedAt'> & {
        id?: number;
    }): Promise<StorageClassDoc>;
    clearDefaultStorageClass(purposeArg: TStorageClassPurpose, exceptIdArg?: number): Promise<void>;
    getStorageClassByName(nameArg: string): Promise<StorageClassDoc | null>;
    getAllStorageClasses(): Promise<StorageClassDoc[]>;
    getDefaultStorageClassName(purposeArg: TStorageClassPurpose): Promise<string>;
    deleteStorageClass(nameArg: string): Promise<void>;
    resolveServiceVolumeStorage(volumeArg: IServiceVolume, purposeArg?: TStorageClassPurpose): Promise<IServiceVolume>;
    private getDockerVolumeDriverConfig;
    getSetting(key: string): Promise<string | null>;
    setSetting(key: string, value: string): Promise<void>;
    deleteSetting(key: string): Promise<void>;
    getAllSettings(): Promise<Record<string, string>>;
    getRawSecretSetting(key: string): Promise<string | null>;
    setRawSecretSetting(key: string, value: string): Promise<void>;
    deleteRawSecretSetting(key: string): Promise<void>;
    getSecretSetting(key: string): Promise<string | null>;
    setSecretSetting(key: string, value: string | null): Promise<void>;
    deleteSecretSetting(key: string): Promise<void>;
    hasSecretSetting(key: string): Promise<boolean>;
    isSecretSettingKey(key: string): boolean;
    getCanonicalSecretSettingKeys(): string[];
    createUser(user: Omit<IUser, 'id'>): Promise<UserDoc>;
    getUserByUsername(username: string): Promise<UserDoc | null>;
    ensurePasskeyAdminUser(username: string, webauthnUserId: string): Promise<UserDoc>;
    getAdminPasskeyCredentialById(username: string, credentialId: string): Promise<{
        user: UserDoc;
        credential: IPasskeyCredential;
    } | null>;
    registerInitialPasskey(username: string, webauthnUserId: string, credential: IPasskeyCredential): Promise<boolean>;
    updatePasskeyCounter(username: string, credentialId: string, expectedCounter: number, newCounter: number): Promise<boolean>;
    resetAdminPasskeys(username: string, newWebauthnUserId: string): Promise<boolean>;
    getAllUsers(): Promise<UserDoc[]>;
    deleteUser(username: string): Promise<void>;
    addMetric(metric: Omit<IMetric, 'id'>): Promise<void>;
    getMetrics(serviceId: number, limit?: number): Promise<MetricDoc[]>;
    deleteMetricsByService(serviceId: number): Promise<void>;
    addLog(log: Omit<ILogEntry, 'id'>): Promise<void>;
    getLogs(serviceId: number, limit?: number): Promise<LogEntryDoc[]>;
    deleteLogsByService(serviceId: number): Promise<void>;
    createSSLCertificate(cert: Omit<ISslCertificate, 'id'>): Promise<ISslCertificate>;
    getSSLCertificate(domain: string): Promise<ISslCertificate | null>;
    getAllSSLCertificates(): Promise<ISslCertificate[]>;
    updateSSLCertificate(domain: string, updates: Partial<ISslCertificate>): Promise<void>;
    deleteSSLCertificate(domain: string): Promise<void>;
    createDomain(domain: Omit<IDomain, 'id'>): Promise<DomainDoc>;
    getDomainByName(domain: string): Promise<DomainDoc | null>;
    getDomainById(id: number): Promise<DomainDoc | null>;
    getAllDomains(): Promise<DomainDoc[]>;
    getDomainsByProvider(provider: NonNullable<IDomain['dnsProvider']>): Promise<DomainDoc[]>;
    updateDomain(id: number, updates: Partial<IDomain>): Promise<void>;
    deleteDomain(id: number): Promise<void>;
    createCertificate(cert: Omit<ICertificate, 'id'>): Promise<CertificateDoc>;
    getCertificateById(id: number): Promise<CertificateDoc | null>;
    getCertificatesByDomain(domainId: number): Promise<CertificateDoc[]>;
    getAllCertificates(): Promise<CertificateDoc[]>;
    updateCertificate(id: number, updates: Partial<ICertificate>): Promise<void>;
    deleteCertificate(id: number): Promise<void>;
    createCertRequirement(req: Omit<ICertRequirement, 'id'>): Promise<CertRequirementDoc>;
    getCertRequirementById(id: number): Promise<CertRequirementDoc | null>;
    getCertRequirementsByService(serviceId: number): Promise<CertRequirementDoc[]>;
    getCertRequirementsByDomain(domainId: number): Promise<CertRequirementDoc[]>;
    getAllCertRequirements(): Promise<CertRequirementDoc[]>;
    updateCertRequirement(id: number, updates: Partial<ICertRequirement>): Promise<void>;
    deleteCertRequirement(id: number): Promise<void>;
    deleteCertRequirementsByService(serviceId: number): Promise<void>;
    createDnsRecord(recordArg: Omit<TDnsRecordWithZone, 'id'>): Promise<DnsRecordDoc>;
    getDnsRecordByDomain(domainArg: string): Promise<DnsRecordDoc | null>;
    getAllDnsRecords(): Promise<DnsRecordDoc[]>;
    deleteDnsRecord(domainArg: string): Promise<void>;
    createRegistryToken(token: Omit<IRegistryToken, 'id'>): Promise<RegistryTokenDoc>;
    getRegistryTokenById(id: number): Promise<RegistryTokenDoc | null>;
    getRegistryTokenByHash(tokenHash: string): Promise<RegistryTokenDoc | null>;
    getAllRegistryTokens(): Promise<RegistryTokenDoc[]>;
    getRegistryTokensByType(type: 'global' | 'ci'): Promise<RegistryTokenDoc[]>;
    updateRegistryTokenLastUsed(id: number): Promise<void>;
    cleanupRegistryTokensForService(serviceNameArg: string): Promise<void>;
    deleteRegistryToken(id: number): Promise<void>;
    createPlatformService(service: Omit<IPlatformService, 'id'>): Promise<PlatformServiceDoc>;
    getPlatformServiceByName(name: string): Promise<PlatformServiceDoc | null>;
    getPlatformServiceById(id: number): Promise<PlatformServiceDoc | null>;
    getPlatformServiceByType(type: TPlatformServiceType): Promise<PlatformServiceDoc | null>;
    getAllPlatformServices(): Promise<PlatformServiceDoc[]>;
    updatePlatformService(id: number, updates: Partial<IPlatformService>): Promise<void>;
    deletePlatformService(id: number): Promise<void>;
    createPlatformResource(resource: Omit<IPlatformResource, 'id'>): Promise<PlatformResourceDoc>;
    persistPlatformResourceRecovery(resourceArg: Omit<IPlatformResource, 'id'>): Promise<void>;
    getPlatformResourceById(id: number): Promise<PlatformResourceDoc | null>;
    getPlatformResourcesByService(serviceId: number): Promise<PlatformResourceDoc[]>;
    getPlatformResourcesByPlatformService(platformServiceId: number): Promise<PlatformResourceDoc[]>;
    getAllPlatformResources(): Promise<PlatformResourceDoc[]>;
    deletePlatformResource(id: number): Promise<void>;
    deletePlatformResourcesByService(serviceId: number): Promise<void>;
    createBackup(backup: Omit<IBackup, 'id'>): Promise<BackupDoc>;
    getBackupById(id: number): Promise<BackupDoc | null>;
    getBackupsByService(serviceId: number): Promise<BackupDoc[]>;
    getAllBackups(): Promise<BackupDoc[]>;
    deleteBackup(id: number): Promise<void>;
    deleteBackupsByService(serviceId: number): Promise<void>;
    getBackupsBySchedule(scheduleId: number): Promise<BackupDoc[]>;
    getBackupBySnapshotId(snapshotId: string): Promise<BackupDoc | null>;
    createBackupSchedule(schedule: Omit<IBackupSchedule, 'id'>): Promise<BackupScheduleDoc>;
    getBackupScheduleById(id: number): Promise<BackupScheduleDoc | null>;
    getBackupSchedulesByService(serviceId: number): Promise<BackupScheduleDoc[]>;
    getEnabledBackupSchedules(): Promise<BackupScheduleDoc[]>;
    getAllBackupSchedules(): Promise<BackupScheduleDoc[]>;
    updateBackupSchedule(id: number, updates: IBackupScheduleUpdate & {
        lastRunAt?: number;
        nextRunAt?: number;
        lastStatus?: 'success' | 'failed' | null;
        lastError?: string | null;
    }): Promise<void>;
    deleteBackupSchedule(id: number): Promise<void>;
    deleteBackupSchedulesByService(serviceId: number): Promise<void>;
}
export {};
