import { StorageStrategy, QueryMatcher } from './storage-strategy'; interface DurableObjectStorage { get(key: string): Promise; get(keys: string[]): Promise>; put(key: string, value: T): Promise; put(entries: Record): Promise; delete(key: string): Promise; delete(keys: string[]): Promise; list(options?: { start?: string; end?: string; prefix?: string; reverse?: boolean; limit?: number; }): Promise>; deleteAll(): Promise; } interface DurableObjectState { storage: DurableObjectStorage; blockConcurrencyWhile(callback: () => Promise): void; } /** * Durable Object Storage Strategy * * Uses Cloudflare Durable Objects' Key-Value storage API for persistence. * Provides strong consistency within a single Durable Object instance. * * Key structure: * - Documents: `doc:${modelName}:${id}` * - Indexes: `idx:${modelName}:${indexKey}:${compositeValue}` -> array of doc IDs * - Metadata: `meta:${modelName}:indexes` -> index definitions * * @example * ```typescript * // In your Durable Object class * export class MyDurableObject extends DurableObject { * constructor(ctx: DurableObjectState, env: Env) { * super(ctx, env) * const storage = new DurableObjectStorageStrategy(ctx, 'User') * const User = new Model(userSchema, undefined, storage) * } * } * ``` */ export declare class DurableObjectStorageStrategy implements StorageStrategy { private modelName; private ctx; private indexes; private initialized; private _data; lastOperationTime: number; constructor(ctx: DurableObjectState, modelName: string); /** * Extract plain data from document, removing circular references * Uses JSON serialization to ensure clean data */ private toPlainObject; /** * Initialize the storage strategy * Loads index metadata and all documents into memory */ initialize(): Promise; /** * Get all documents for this model */ getAll(): Promise; /** * Add a single document */ add(doc: T): Promise; /** * Add multiple documents */ addMany(docs: T[]): Promise; /** * Update a document */ update(oldDoc: T, newDoc: T): Promise; /** * Remove a single document */ remove(doc: T): Promise; /** * Remove multiple documents */ removeMany(docs: T[]): Promise; /** * Clear all documents */ clear(): Promise; /** * Create an index */ createIndex(fields: keyof T | Array, options?: { unique?: boolean; }): Promise; /** * Rebuild all indexes */ rebuildIndexes(): Promise; /** * Update indexes for a document change (synchronous) * Note: For Durable Objects, index updates are handled in async methods */ updateIndexForDocument(oldDoc: T | null, newDoc: T | null): void; /** * Check unique constraints (synchronous) * Uses in-memory data for synchronous checking */ checkUniqueConstraints(doc: Partial, excludeDoc?: T): void; /** * Find documents using indexes when possible (synchronous) * Uses in-memory data for synchronous queries */ findDocuments(matcher: QueryMatcher, indexHint?: { fields: Array; values: Record; }): T[]; /** * Save index metadata to storage */ private _saveIndexMetadata; /** * Update indexes when a document changes */ private _updateIndexes; /** * Add a document to an index */ private _addToIndex; /** * Remove a document from an index */ private _removeFromIndex; } export {}; //# sourceMappingURL=durable-object-strategy.d.ts.map