import type { KVStorageAdapter, ListStorageAdapter, QueryOptions } from './types.js'; /** * JSON 文件键值存储 * 适用于小型应用、本地开发 */ export declare class JsonFileKVStorage implements KVStorageAdapter { private filePath; private cache; constructor(filePath: string); private load; private save; get(key: string): Promise; set(key: string, value: T): Promise; delete(key: string): Promise; exists(key: string): Promise; keys(prefix?: string): Promise; /** 清除缓存(用于重新加载) */ clearCache(): void; } /** * JSON 文件列表存储 * 支持实体 CRUD 操作 */ export declare class JsonFileListStorage implements ListStorageAdapter { private filePath; private data; constructor(filePath: string); private load; private save; list(): Promise; findById(id: number | string): Promise; add(entity: T): Promise; update(id: number | string, data: Partial): Promise; remove(id: number | string): Promise; batch(operations: Array<{ type: 'add' | 'update' | 'delete'; data: T | Partial; id?: number | string; }>): Promise; /** 获取最大 ID */ maxId(): number; /** 清除缓存 */ clearCache(): void; /** 获取文件路径 */ getPath(): string; } /** * 内存键值存储 * 适用于测试、临时数据 */ export declare class InMemoryKVStorage implements KVStorageAdapter { private data; get(key: string): Promise; set(key: string, value: T): Promise; delete(key: string): Promise; exists(key: string): Promise; keys(prefix?: string): Promise; /** 清空所有数据 */ clear(): void; } /** * 内存列表存储 */ export declare class InMemoryListStorage implements ListStorageAdapter { private data; list(): Promise; findById(id: number | string): Promise; add(entity: T): Promise; update(id: number | string, data: Partial): Promise; remove(id: number | string): Promise; /** 清空所有数据 */ clear(): void; } /** * 数据库存储基类 * 应用层继承并实现具体的数据库操作(TypeORM / Prisma / Sequelize 等) */ export declare abstract class DatabaseListStorage implements ListStorageAdapter { abstract list(): Promise; abstract findById(id: number | string): Promise; abstract add(entity: T): Promise; abstract update(id: number | string, data: Partial): Promise; abstract remove(id: number | string): Promise; /** 扩展:带查询条件的列表 */ query(options: QueryOptions): Promise<{ items: T[]; total: number; hasMore: boolean; }>; } /** * 创建 JSON 文件存储 */ export declare function createJsonFileStorage(filePath: string, type: 'kv' | 'list'): KVStorageAdapter | ListStorageAdapter<{ id: number | string; }>; /** * 创建内存存储 */ export declare function createInMemoryStorage(type: 'kv' | 'list'): KVStorageAdapter | ListStorageAdapter<{ id: number | string; }>; //# sourceMappingURL=storage.d.ts.map