/**
 * Type definitions for Onebox
 */
import type * as servezoneInterfaces from '@serve.zone/interfaces';
export type IServiceTargetPort = servezoneInterfaces.data.IServiceTargetPort;
export type IServiceDomainRoute = servezoneInterfaces.data.IServiceDomainRoute;
export type IServicePublicPortMapping = servezoneInterfaces.data.IServicePublicPortMapping;
export type IServiceSecretFile = servezoneInterfaces.data.IServiceSecretFile;
export interface IService {
    id?: number;
    name: string;
    image: string;
    registry?: string;
    envVars: Record<string, string>;
    containerArgs?: string[];
    secretFiles?: IServiceSecretFile[];
    volumes?: IServiceVolume[];
    publishedPorts?: IServicePublishedPort[];
    targetPorts?: IServiceTargetPort[];
    domains?: IServiceDomainRoute[];
    publicPortMappings?: IServicePublicPortMapping[];
    port: number;
    domain?: string;
    containerID?: string;
    status: 'stopped' | 'starting' | 'running' | 'stopping' | 'failed';
    createdAt: number;
    updatedAt: number;
    useOneboxRegistry?: boolean;
    registryRepository?: string;
    registryImageTag?: string;
    autoUpdateOnPush?: boolean;
    imageDigest?: string;
    imageCleanup?: IServiceImageCleanup;
    platformRequirements?: IPlatformRequirements;
    includeImageInBackup?: boolean;
    appTemplateId?: string;
    appTemplateVersion?: string;
}
export interface IServiceImageCleanup {
    imageName: string;
    candidateReference: string;
    priorReference?: string;
    phase?: 'rollback-pending' | 'candidate-active';
}
export type IHostedAppLifecycleState = servezoneInterfaces.data.IHostedAppLifecycleState;
export interface IHostedAppLifecycleRecord {
    id?: number;
    serviceId: number;
    appInstanceId: string;
    hostType: 'onebox';
    state: IHostedAppLifecycleState;
    createdAt: number;
    updatedAt: number;
}
export interface IServiceSecretBundleRecord {
    serviceId: number;
    valuesEncrypted: string;
    createdAt: number;
    updatedAt: number;
}
export interface IServiceVolume {
    name?: string;
    source?: string;
    mountPath: string;
    storageClass?: string;
    driver?: string;
    readOnly?: boolean;
    backup?: boolean;
    options?: Record<string, string>;
}
export type TStorageTargetKind = 'local' | 'nfs' | 'smb' | 'backup' | 'custom';
export type TStorageClassPurpose = 'runtime' | 'database' | 'backup';
export interface IStorageTargetConfig {
    path?: string;
    server?: string;
    exportPath?: string;
    share?: string;
    username?: string;
    password?: string;
    domain?: string;
    version?: string;
    driver?: string;
    device?: string;
    options?: Record<string, string>;
}
export interface IStorageTarget {
    id?: number;
    name: string;
    displayName: string;
    kind: TStorageTargetKind;
    config: IStorageTargetConfig;
    createdAt: number;
    updatedAt: number;
}
export interface IStorageClass {
    id?: number;
    name: string;
    displayName: string;
    description?: string;
    targetName: string;
    purpose: TStorageClassPurpose;
    isDefault?: boolean;
    driver?: string;
    options?: Record<string, string>;
    createdAt: number;
    updatedAt: number;
}
export type TServicePortProtocol = 'tcp' | 'udp';
export interface IServicePublishedPort {
    targetPort: number;
    targetPortEnd?: number;
    publishedPort?: number;
    publishedPortEnd?: number;
    protocol?: TServicePortProtocol;
    hostIp?: string;
}
export interface IRegistry {
    id?: number;
    url: string;
    username: string;
    passwordEncrypted: string;
    createdAt: number;
}
export interface IRegistryToken {
    id?: number;
    name: string;
    tokenHash: string;
    type: 'global' | 'ci';
    scope: 'all' | string[];
    expiresAt: number | null;
    createdAt: number;
    lastUsedAt: number | null;
    createdBy: string;
}
export interface ICreateRegistryTokenRequest {
    name: string;
    type: 'global' | 'ci';
    scope: 'all' | string[];
    expiresIn: '30d' | '90d' | '365d' | 'never';
}
export interface IRegistryTokenView {
    id: number;
    name: string;
    type: 'global' | 'ci';
    scope: 'all' | string[];
    scopeDisplay: string;
    expiresAt: number | null;
    createdAt: number;
    lastUsedAt: number | null;
    createdBy: string;
    isExpired: boolean;
}
export interface ITokenCreatedResponse {
    token: IRegistryTokenView;
    plainToken: string;
}
export type TPlatformServiceType = 'mongodb' | 'minio' | 'smartstorage' | 'valkey' | 'postgresql' | 'rabbitmq' | 'coretraffic' | 'clickhouse' | 'mariadb';
export type TPlatformResourceType = 'database' | 'bucket' | 'cache' | 'queue';
export type TPlatformServiceStatus = 'stopped' | 'starting' | 'running' | 'stopping' | 'failed';
export interface IPlatformService {
    id?: number;
    name: string;
    type: TPlatformServiceType;
    status: TPlatformServiceStatus;
    containerId?: string;
    config: IPlatformServiceConfig;
    adminCredentialsEncrypted?: string;
    createdAt: number;
    updatedAt: number;
}
export interface IPlatformServiceConfig {
    image: string;
    port: number;
    volumes?: string[];
    storageClass?: string;
    command?: string;
    environment?: Record<string, string>;
}
export interface IPlatformResource {
    id?: number;
    platformServiceId: number;
    serviceId: number;
    resourceType: TPlatformResourceType;
    resourceName: string;
    credentialsEncrypted: string;
    createdAt: number;
}
export interface IPlatformRequirements {
    mongodb?: boolean;
    s3?: boolean;
    clickhouse?: boolean;
    valkey?: boolean;
    mariadb?: boolean;
}
export interface IProvisionedResource {
    type: TPlatformResourceType;
    name: string;
    credentials: Record<string, string>;
    envVars: Record<string, string>;
}
export interface IEnvVarMapping {
    envVar: string;
    credentialPath: string;
}
export interface INginxConfig {
    id?: number;
    serviceId: number;
    domain: string;
    port: number;
    sslEnabled: boolean;
    configTemplate: string;
    createdAt: number;
    updatedAt: number;
}
export interface IDomain {
    id?: number;
    domain: string;
    dnsProvider: 'cloudflare' | 'manual' | 'dcrouter' | null;
    cloudflareZoneId?: string;
    isObsolete: boolean;
    defaultWildcard: boolean;
    createdAt: number;
    updatedAt: number;
}
export interface ICertificate {
    id?: number;
    domainId: number;
    certDomain: string;
    isWildcard: boolean;
    certPem: string;
    keyPem: string;
    fullchainPem: string;
    expiryDate: number;
    issuer: string;
    isValid: boolean;
    createdAt: number;
    updatedAt: number;
}
export interface ICertRequirement {
    id?: number;
    serviceId: number;
    domainId: number;
    subdomain: string;
    certificateId?: number;
    status: 'pending' | 'active' | 'renewing';
    createdAt: number;
    updatedAt: number;
}
export interface IDomainView {
    domain: IDomain;
    certificates: ICertificate[];
    requirements: ICertRequirement[];
    serviceCount: number;
    certificateStatus: 'valid' | 'expiring-soon' | 'expired' | 'pending' | 'none';
    daysRemaining: number | null;
}
export interface ISslCertificate {
    id?: number;
    domain: string;
    certPem: string;
    keyPem: string;
    fullchainPem: string;
    expiryDate: number;
    issuer: string;
    createdAt: number;
    updatedAt: number;
}
export interface IDnsRecord {
    id?: number;
    domain: string;
    type: 'A' | 'AAAA' | 'CNAME';
    value: string;
    cloudflareID?: string;
    createdAt: number;
    updatedAt: number;
}
export interface IMetric {
    id?: number;
    serviceId: number;
    timestamp: number;
    cpuPercent: number;
    memoryUsed: number;
    memoryLimit: number;
    networkRxBytes: number;
    networkTxBytes: number;
}
export interface ILogEntry {
    id?: number;
    serviceId: number;
    timestamp: number;
    message: string;
    level: 'info' | 'warn' | 'error' | 'debug';
    source: 'stdout' | 'stderr';
}
export interface IUser {
    id?: number;
    username: string;
    role: 'admin' | 'user';
    webauthnUserId: string;
    passkeyCredentials: IPasskeyCredential[];
    createdAt: number;
    updatedAt: number;
}
export interface ISetting {
    key: string;
    value: string;
    updatedAt: number;
}
export type TPasskeyTransport = 'ble' | 'cable' | 'hybrid' | 'internal' | 'nfc' | 'smart-card' | 'usb';
export type TPasskeyDeviceType = 'singleDevice' | 'multiDevice';
export interface IPasskeyCredential {
    credentialId: string;
    publicKey: string;
    counter: number;
    transports: TPasskeyTransport[] | null;
    deviceType: TPasskeyDeviceType;
    backedUp: boolean;
    rpId: string;
    origin: string;
    createdAt: number;
    lastUsedAt: number | null;
}
export interface IAppSettings {
    serverIP?: string;
    adminUiDomain?: string;
    cloudflareToken?: string;
    cloudflareZoneId?: string;
    dcrouterMode?: 'managed' | 'external' | 'disabled';
    dcrouterManagedImage?: string;
    dcrouterManagedOpsPort?: number;
    dcrouterManagedHttpPort?: number;
    dcrouterManagedHttpsPort?: number;
    dcrouterManagedDataDir?: string;
    dcrouterGatewayUrl?: string;
    dcrouterGatewayApiToken?: string;
    dcrouterGatewayClientId?: string;
    /** @deprecated Use dcrouterGatewayClientId. */
    dcrouterTargetHost?: string;
    dcrouterTargetPort?: number;
    acmeEmail?: string;
    dataDir?: string;
    httpPort?: number;
    httpsPort?: number;
    metricsInterval?: number;
    autoRenewCerts?: boolean;
    renewalThreshold?: number;
    forceHttps?: boolean;
    logRetentionDays?: number;
}
export interface IContainerStats {
    cpuPercent: number;
    memoryUsed: number;
    memoryLimit: number;
    memoryPercent: number;
    networkRx: number;
    networkTx: number;
}
export interface IServiceDeployOptions {
    name: string;
    image: string;
    registry?: string;
    envVars?: Record<string, string>;
    secretEnvVars?: Record<string, string>;
    containerArgs?: string[];
    secretFiles?: IServiceSecretFile[];
    volumes?: IServiceVolume[];
    publishedPorts?: IServicePublishedPort[];
    targetPorts?: IService['targetPorts'];
    domains?: IService['domains'];
    publicPortMappings?: IService['publicPortMappings'];
    port: number;
    domain?: string;
    autoSSL?: boolean;
    autoDNS?: boolean;
    useOneboxRegistry?: boolean;
    registryImageTag?: string;
    autoUpdateOnPush?: boolean;
    imageDigest?: string;
    enableMongoDB?: boolean;
    enableS3?: boolean;
    enableClickHouse?: boolean;
    enableValkey?: boolean;
    enableMariaDB?: boolean;
    appTemplateId?: string;
    appTemplateVersion?: string;
}
export interface IApiResponse<T = unknown> {
    success: boolean;
    data?: T;
    error?: string;
    message?: string;
}
export interface ICliArgs {
    _: string[];
    [key: string]: unknown;
}
export type TBackupRestoreMode = 'restore' | 'import' | 'clone';
export interface IRetentionPolicy {
    hourly: number;
    daily: number;
    weekly: number;
    monthly: number;
}
export declare const RETENTION_PRESETS: {
    readonly standard: {
        readonly hourly: 0;
        readonly daily: 7;
        readonly weekly: 4;
        readonly monthly: 12;
    };
    readonly frequent: {
        readonly hourly: 24;
        readonly daily: 7;
        readonly weekly: 4;
        readonly monthly: 12;
    };
    readonly minimal: {
        readonly hourly: 0;
        readonly daily: 3;
        readonly weekly: 2;
        readonly monthly: 6;
    };
    readonly longterm: {
        readonly hourly: 0;
        readonly daily: 14;
        readonly weekly: 8;
        readonly monthly: 24;
    };
};
export type TRetentionPreset = keyof typeof RETENTION_PRESETS | 'custom';
export interface IBackup {
    id?: number;
    serviceId: number;
    serviceName: string;
    filename: string;
    snapshotId?: string;
    sizeBytes: number;
    storedSizeBytes?: number;
    createdAt: number;
    includesImage: boolean;
    platformResources: TPlatformServiceType[];
    checksum: string;
    scheduleId?: number;
}
export interface IBackupManifest {
    version: string;
    createdAt: number;
    oneboxVersion: string;
    serviceName: string;
    includesImage: boolean;
    platformResources: TPlatformServiceType[];
    checksum: string;
}
export interface IBackupServiceConfig {
    name: string;
    image: string;
    registry?: string;
    envVars: Record<string, string>;
    /** Machine-key ciphertext. Cross-host restore requires the same ONEBOX_ENCRYPTION_KEY. */
    serviceSecretsEncrypted?: string;
    containerArgs?: string[];
    secretFiles?: IServiceSecretFile[];
    volumes?: IServiceVolume[];
    publishedPorts?: IServicePublishedPort[];
    targetPorts?: IService['targetPorts'];
    domains?: IService['domains'];
    publicPortMappings?: IService['publicPortMappings'];
    port: number;
    domain?: string;
    useOneboxRegistry?: boolean;
    registryRepository?: string;
    registryImageTag?: string;
    autoUpdateOnPush?: boolean;
    platformRequirements?: IPlatformRequirements;
    includeImageInBackup?: boolean;
}
export interface IBackupPlatformResource {
    resourceType: TPlatformResourceType;
    resourceName: string;
    platformServiceType: TPlatformServiceType;
    credentials: Record<string, string>;
}
export interface IBackupResult {
    backup: IBackup;
    filePath?: string;
    snapshotId?: string;
}
export interface IRestoreOptions {
    mode: TBackupRestoreMode;
    newServiceName?: string;
    skipPlatformData?: boolean;
    overwriteExisting?: boolean;
}
export interface IRestoreResult {
    service: IService;
    platformResourcesRestored: number;
    warnings: string[];
}
export type TBackupScheduleScope = 'all' | 'pattern' | 'service';
export interface IBackupSchedule {
    id?: number;
    scopeType: TBackupScheduleScope;
    scopePattern?: string;
    serviceId?: number;
    serviceName?: string;
    cronExpression: string;
    retention: IRetentionPolicy;
    enabled: boolean;
    lastRunAt: number | null;
    nextRunAt: number | null;
    lastStatus: 'success' | 'failed' | null;
    lastError: string | null;
    createdAt: number;
    updatedAt: number;
}
export interface IBackupScheduleCreate {
    scopeType: TBackupScheduleScope;
    scopePattern?: string;
    serviceName?: string;
    cronExpression: string;
    retention: IRetentionPolicy;
    enabled?: boolean;
}
export interface IBackupScheduleUpdate {
    cronExpression?: string;
    retention?: IRetentionPolicy;
    enabled?: boolean;
}
export interface IBackupCreateOptions {
    scheduleId?: number;
}
