/**
 * @fileoverview Test utilities for MCP server development.
 * Provides `createMockContext()` for testing tool and resource handlers
 * against the unified Context interface, plus `createMockLogger()` and
 * `createInMemoryStorage()` for unit-testing services in isolation.
 * @module src/testing/index
 */
import type { ContentBlock, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
import type { z } from 'zod';
import type { AuthContext, Context, ContextLogger } from '../core/context.js';
import { StorageService } from '../storage/core/StorageService.js';
import { type InMemoryProviderOptions } from '../storage/providers/inMemory/inMemoryProvider.js';
import type { ErrorContract } from '../types-global/errors.js';
export interface MockContextOptions {
    /** Auth context. */
    auth?: AuthContext;
    /**
     * Mock elicitation handler for form-mode elicitation. When provided, the
     * mock context's `ctx.elicit` is set to this function with a default no-op
     * `.url(...)` stub attached — tests that only exercise form-mode elicitation
     * don't need to supply `.url` explicitly.
     */
    elicit?: (message: string, schema: z.ZodObject<z.ZodRawShape>) => Promise<ElicitResult>;
    /**
     * Error contract to attach a typed `ctx.fail` against. Pass the definition's
     * own `errors` array (`createMockContext({ errors: myTool.errors })`) so the
     * mock's `fail` matches what the production handler factory wires up. Tests
     * can then assert on `data.reason` without manually composing `createFail`.
     */
    errors?: readonly ErrorContract[];
    /** Mock prompt list changed notifier. */
    notifyPromptListChanged?: () => void;
    /** Mock resource list changed notifier. */
    notifyResourceListChanged?: () => void;
    /** Mock resource updated notifier. */
    notifyResourceUpdated?: (uri: string) => void;
    /** Mock tool list changed notifier. */
    notifyToolListChanged?: () => void;
    /** Enable task progress (creates a mock ContextProgress). */
    progress?: boolean;
    /** Request ID override. Defaults to 'test-request-id'. */
    requestId?: string;
    /**
     * HTTP session ID. Defaults to undefined. Set to exercise handlers that
     * branch on `ctx.sessionId` — mirrors what a stateful HTTP request would
     * surface, or what the opt-in `exposeStatelessSessionId` path produces.
     */
    sessionId?: string;
    /** Custom AbortSignal. Defaults to a fresh AbortController's signal. */
    signal?: AbortSignal;
    /** Tenant ID. Enables ctx.state operations when provided. */
    tenantId?: string;
    /** Resource URI for resource handler testing. */
    uri?: URL;
}
/** A `ContextLogger` that records every call to an inspectable `calls` array. */
export type MockContextLogger = ContextLogger & {
    /** Every log call in insertion order. `data` is the per-call metadata argument. */
    calls: Array<{
        level: string;
        msg: string;
        data?: unknown;
    }>;
};
/**
 * Create a `ContextLogger` whose calls are recorded for inspection.
 * Useful when unit-testing code that accepts a `ContextLogger` directly.
 *
 * @example
 * ```ts
 * import { createMockLogger } from '@cyanheads/mcp-ts-core/testing';
 *
 * const log = createMockLogger();
 * log.info('started', { step: 1 });
 * expect(log.calls).toEqual([{ level: 'info', msg: 'started', data: { step: 1 } }]);
 * ```
 */
export declare function createMockLogger(): MockContextLogger;
/**
 * Creates a mock Context for testing tool and resource handlers.
 *
 * @example
 * ```ts
 * // Minimal — works for most tests
 * const ctx = createMockContext();
 *
 * // With tenant (for tools that use ctx.state)
 * const ctx = createMockContext({ tenantId: 'test-tenant' });
 *
 * // With task progress
 * const ctx = createMockContext({ progress: true });
 * ```
 */
export declare function createMockContext(options?: MockContextOptions): Context;
/**
 * Reads the enrichment a handler accumulated via `ctx.enrich(...)` on a mock
 * context, for assertions. Returns the merged field values (empty object when
 * nothing was enriched).
 *
 * @example
 * ```ts
 * const ctx = createMockContext();
 * await search.handler(search.input.parse({ query: 'x' }), ctx);
 * expect(getEnrichment(ctx)).toMatchObject({ effectiveQuery: 'x', totalCount: 0 });
 * ```
 */
export declare function getEnrichment(ctx: Context): Record<string, unknown>;
/**
 * Reads the content blocks a handler emitted via `ctx.content(...)` on a mock
 * context, for assertions. Returns them in insertion order (empty array when none
 * were emitted) — the same blocks the handler factory prepends to `content[]`,
 * never placed in `structuredContent`.
 *
 * @example
 * ```ts
 * const ctx = createMockContext();
 * await render.handler(render.input.parse({ text: 'hi' }), ctx);
 * expect(getContentBlocks(ctx)).toEqual([{ type: 'image', data: '...', mimeType: 'image/png' }]);
 * ```
 */
export declare function getContentBlocks(ctx: Context): ContentBlock[];
/**
 * Build a real `StorageService` backed by an in-memory provider, suitable for
 * unit-testing services that accept a `StorageService` dependency.
 *
 * Because this uses the production `StorageService` + `InMemoryProvider`, the
 * behavior (tenant isolation, TTL, validation, list pagination) matches what
 * you'd see in a running server — no hand-rolled fake required.
 *
 * @example
 * ```ts
 * import { createInMemoryStorage, createMockContext } from '@cyanheads/mcp-ts-core/testing';
 *
 * const storage = createInMemoryStorage();
 * const svc = new MyService(config, storage);
 * const ctx = createMockContext({ tenantId: 'test-tenant' });
 * await svc.doWork(input, ctx);
 * ```
 */
export declare function createInMemoryStorage(options?: InMemoryProviderOptions): StorageService;
//# sourceMappingURL=index.d.ts.map