/**
 * @fileoverview Factory function for creating a storage provider based on application configuration.
 * This module decouples the application from concrete storage implementations, allowing the
 * storage backend to be selected via environment variables. In a serverless environment,
 * it throws a configuration error for unsupported providers.
 * @module src/storage/core/storageFactory
 */
import type { D1Database, KVNamespace, R2Bucket } from '@cloudflare/workers-types';
import type { SupabaseClient } from '@supabase/supabase-js';
import type { AppConfig } from '../../config/index.js';
import type { IStorageProvider } from '../../storage/core/IStorageProvider.js';
import type { Database } from '../../storage/providers/supabase/supabase.types.js';
/**
 * Optional dependencies for storage provider creation.
 * Allows pre-resolved dependencies to be passed in, useful for testing
 * and Worker environments where DI container may not be available.
 */
export interface StorageFactoryDeps {
    /** Cloudflare D1 database binding */
    readonly d1Database?: D1Database;
    /** Cloudflare KV namespace binding */
    readonly kvNamespace?: KVNamespace;
    /** Cloudflare R2 bucket binding */
    readonly r2Bucket?: R2Bucket;
    /** Pre-configured Supabase client */
    readonly supabaseClient?: SupabaseClient<Database>;
}
/**
 * Creates and returns a storage provider instance based on the provided configuration.
 *
 * This factory decouples the application from concrete storage implementations,
 * allowing the backend to be selected via environment configuration. In serverless
 * environments, automatically falls back to in-memory storage for non-compatible providers.
 *
 * Provider Selection Logic:
 * - Serverless environment: Only `in-memory`, `cloudflare-r2`, `cloudflare-kv` allowed
 * - Node environment: All providers available
 * - Missing config: Throws ConfigurationError
 *
 * @param config - The application configuration object, typically resolved from DI container.
 * @param deps - Optional pre-resolved dependencies for providers (useful for testing/Workers).
 * @returns An instance of a class that implements the IStorageProvider interface.
 *
 * @throws {McpError} JsonRpcErrorCode.ConfigurationError - If:
 *   - filesystem provider selected but STORAGE_FILESYSTEM_PATH not set
 *   - supabase provider selected but SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY not set
 *   - cloudflare-r2 provider selected in non-serverless environment
 *   - cloudflare-kv provider selected in non-serverless environment
 *   - unknown provider type specified
 *
 * @example
 * ```typescript
 * // Standard usage — DI container resolves clients and passes via deps
 * const provider = createStorageProvider(config, {
 *   supabaseClient: resolvedSupabaseClient,
 * });
 *
 * // Worker usage with Cloudflare bindings
 * const provider = createStorageProvider(config, {
 *   r2Bucket: env.R2_BUCKET,
 *   kvNamespace: env.KV_NAMESPACE,
 * });
 * ```
 */
export declare function createStorageProvider(config: AppConfig, deps?: StorageFactoryDeps): IStorageProvider;
//# sourceMappingURL=storageFactory.d.ts.map