/**
 * @fileoverview Implements the IStorageProvider interface for Cloudflare D1.
 * Provides SQL-based key-value storage with multi-tenancy, TTL support, and batch operations.
 * @module src/storage/providers/cloudflare/d1Provider
 */
import type { D1Database } from '@cloudflare/workers-types';
import type { IStorageProvider, ListOptions, ListResult, StorageOptions } from '../../../storage/core/IStorageProvider.js';
import type { RequestContext } from '../../../utils/internal/requestContext.js';
/**
 * Cloudflare D1 storage provider implementation.
 *
 * Features:
 * - SQL-based key-value storage with multi-tenancy
 * - TTL support via expires_at column (Unix timestamp in milliseconds)
 * - Batch operations using D1's batch() API for transactional writes
 * - Cursor-based pagination with tenant-bound security
 * - Strong consistency (vs KV's eventual consistency)
 *
 * Schema Requirements:
 * - Table: kv_store (tenant_id, key, value, expires_at)
 * - See docs/cloudflare-d1-schema.sql for setup
 *
 * Performance Characteristics:
 * - Reads: ~50-100ms (depends on query complexity)
 * - Writes: ~50-200ms (single), ~100-500ms (batch)
 * - List operations: Efficient with proper indexes
 * - Batch operations: 20-100x faster than individual calls
 */
export declare class D1Provider implements IStorageProvider {
    private readonly db;
    private readonly tableName;
    /**
     * Creates a new D1Provider instance.
     *
     * @param db - The D1Database binding from Cloudflare Workers
     * @param tableName - The name of the kv_store table (default: 'kv_store')
     * @throws {McpError} If db is not provided or invalid
     */
    private static readonly SAFE_TABLE_NAME;
    constructor(db: D1Database, tableName?: string);
    /**
     * Helper to get current timestamp in milliseconds.
     */
    private getNow;
    /**
     * Helper to check if a value has expired based on expires_at timestamp.
     */
    private isExpired;
    /**
     * Retrieves a value from the D1 database.
     * Returns null if the key doesn't exist or has expired.
     */
    get<T>(tenantId: string, key: string, context: RequestContext): Promise<T | null>;
    /**
     * Stores a value in the D1 database.
     * Uses UPSERT (INSERT OR REPLACE) to handle both new and existing keys.
     */
    set(tenantId: string, key: string, value: unknown, context: RequestContext, options?: StorageOptions): Promise<void>;
    /**
     * Deletes a key from the D1 database.
     * Returns true if the key existed, false otherwise.
     */
    delete(tenantId: string, key: string, context: RequestContext): Promise<boolean>;
    /**
     * Lists keys matching a prefix with pagination support.
     * Filters out expired keys based on TTL.
     */
    list(tenantId: string, prefix: string, context: RequestContext, options?: ListOptions): Promise<ListResult>;
    /**
     * Retrieves multiple values in a single operation.
     * More efficient than multiple individual get() calls.
     * Uses SQL IN clause for batch fetching.
     */
    getMany<T>(tenantId: string, keys: string[], context: RequestContext): Promise<Map<string, T>>;
    /**
     * Stores multiple key-value pairs in a single transaction.
     * Uses D1's batch() API for atomic, transactional writes.
     * Significantly faster than individual set() calls (20-100x).
     */
    setMany(tenantId: string, entries: Map<string, unknown>, context: RequestContext, options?: StorageOptions): Promise<void>;
    /**
     * Deletes multiple keys in a single transaction.
     * Uses D1's batch() API for atomic deletion.
     * Returns the count of successfully deleted keys.
     */
    deleteMany(tenantId: string, keys: string[], context: RequestContext): Promise<number>;
    /**
     * Clears all keys for a given tenant.
     * WARNING: This is a destructive operation that cannot be undone.
     * Useful for testing or tenant cleanup operations.
     */
    clear(tenantId: string, context: RequestContext): Promise<number>;
}
//# sourceMappingURL=d1Provider.d.ts.map