import type { RxDatabase, RxCollection } from 'rxdb';

export interface StorageConfig {
  databaseName: string;
  enableEncryption: boolean;
  enableCRDT: boolean;
  migrationStrategy: 'drop' | 'migrate';
}

export interface CollectionSchema {
  version: number;
  title: string;
  type: 'object';
  properties: Record<string, any>;
  required?: string[];
  indexes?: string[];
  migrationStrategies?: Record<number, MigrationStrategy>;
  conflictResolution?: ConflictResolutionStrategy;
}

export type MigrationStrategy = (oldDoc: any) => any;

export interface ConflictResolutionStrategy {
  type: 'crdt' | 'lww' | 'custom';
  resolver?: (conflicts: any[]) => any;
}

export interface DatabaseInstance {
  database: RxDatabase;
  collections: Record<string, RxCollection>;
}

export interface EncryptedFileMetadata {
  id: string;
  filename: string;
  mimeType: string;
  size: number;
  encryptedPath: string;
  keyReference: string;
  createdAt: string;
  updatedAt: string;
}