import './assert_dev_env.js';
import type { z } from 'zod';
import type { SessionOptions } from '../auth/session_cookie.js';
import type { MiddlewareSpec } from '../http/middleware_spec.js';
import type { AppDeps } from '../auth/deps.js';
import type { AuditEmitter } from '../auth/audit_emitter.js';
import type { AppServerContext, BootstrapServerOptions } from '../server/app_server.js';
import { Db } from '../db/db.js';
import { type RouteSpec } from '../http/route_spec.js';
import { type AppSurfaceSpec, type RpcEndpointSpec } from '../http/surface.js';
import type { WsEndpointSpec } from '../actions/ws_endpoint_spec.js';
import type { EventSpec } from '../realtime/sse.js';
import { type AuditLogSse } from '../realtime/sse_auth_guard.js';
/**
 * Create a Proxy that throws descriptive errors on any property access or method call.
 *
 * Use for deps that should never be reached during a test. If a test accidentally
 * calls through to a throwing stub, the error message identifies exactly which stub
 * was hit, catching test bugs that would silently pass with `{} as any`.
 *
 * JS-internal probes (`Symbol`, `then`, `constructor`, `$$typeof`) return
 * `undefined` so the proxy doesn't crash framework-level identity checks;
 * `toJSON` returns `"[throwing_stub:label]"` so accidental serialization
 * surfaces the stub's identity in console output rather than silent `"{}"`.
 *
 * @param label - descriptive name for error messages (e.g. `'keyring'`, `'db'`)
 * @throws Error on any non-internal property access, labeled with the stub
 *   name and the offending property.
 */
export declare const create_throwing_stub: <T = any>(label: string) => T;
/**
 * Create a Proxy where every method access returns a no-op async function.
 *
 * Use for deps that may be reached during "correct auth passes guard" tests
 * but whose return values don't matter. Unlike the explicit method listing,
 * this auto-updates when interfaces change.
 *
 * @param label - descriptive name for debug purposes
 * @param overrides - explicit properties to set (e.g. `{db: stub_db}`)
 */
export declare const create_noop_stub: <T = any>(_label: string, overrides?: Record<string, unknown>) => T;
/** Throwing stub — use for deps that should never be reached. */
export declare const stub: any;
/**
 * Create a stub `Db` for handler tests that use `apply_route_specs` with declarative transactions.
 *
 * Returns a real `Db` instance with:
 * - `query` returns empty rows (safety net for unmocked query functions)
 * - `query_one` returns undefined
 * - `transaction(fn)` calls `fn(db)` synchronously (no real transaction)
 */
export declare const create_stub_db: () => Db;
/** Stub handler that returns a 200 response. */
export declare const stub_handler: () => Response;
/** Stub middleware that passes through. */
export declare const stub_mw: (_c: any, next: any) => Promise<void>;
/**
 * Build a no-op `AuditEmitter` for tests that don't assert on audit fan-out.
 *
 * `emit` / `emit_role_grant_target` are no-ops; `emit_pool` resolves
 * immediately; `notify` is a no-op; `on_event_chain` is a frozen empty
 * array — pushing onto it throws at runtime, so a test that wires a
 * listener fails loudly instead of silently never firing. Tests asserting
 * on real audit-row persistence (or on listener fan-out) build a real
 * emitter via `create_audit_emitter` against a stub or real DB —
 * `create_test_app` already does this on the test backend.
 */
export declare const create_test_audit_emitter: () => AuditEmitter;
/**
 * Build a no-op `AuditLogSse` for tests that wire `audit_sse` into the
 * surface helper but don't assert on SSE fan-out or subscriber state.
 *
 * `subscribe` returns a no-op cleanup; `on_audit_event` is a no-op; the
 * `registry` is a fresh `SubscriberRegistry` instance (call sites that
 * inspect `.size` or call `.close_*` see a real registry, so writes are
 * isolated per test). Tests that need real SSE plumbing build it via
 * `create_audit_log_sse` against `create_test_app`.
 */
export declare const create_stub_audit_sse: () => AuditLogSse;
/** Stub `AppDeps` for auth surface tests — throws on any method access. */
export declare const stub_app_deps: AppDeps;
/**
 * Create no-op `AppDeps` for auth surface testing.
 */
export declare const create_stub_app_deps: () => AppDeps;
/** Create the API middleware stub array matching `create_auth_middleware_specs` output. */
export declare const create_stub_api_middleware: (options?: {
    /** Include the daemon_token middleware layer. */
    include_daemon_token?: boolean;
}) => Array<MiddlewareSpec>;
/**
 * Create a stub `AppServerContext` for attack surface testing.
 *
 * Provides sensible defaults for all fields. Pass `session_options` since
 * it varies per consumer; other fields use stubs/nulls.
 *
 * @param session_options - consumer's session config (required — varies per app)
 */
export declare const create_stub_app_server_context: (session_options: SessionOptions<string>) => AppServerContext;
/** Options for `create_test_app_surface_spec`. */
export interface CreateTestAppSurfaceSpecOptions {
    /** Consumer's session config (required — varies per app). */
    session_options: SessionOptions<string>;
    /** Consumer's route factory — receives the same `AppServerContext` as production. */
    create_route_specs: (ctx: AppServerContext) => Array<RouteSpec>;
    /** Env schema for surface generation (default: `BaseServerEnv`). */
    env_schema?: z.ZodObject;
    /** SSE event specs for surface generation. */
    event_specs?: Array<EventSpec>;
    /**
     * RPC endpoint specs for surface generation.
     *
     * Accepts either an array (eager) or a factory
     * `(ctx: AppServerContext) => Array<RpcEndpointSpec>` — symmetric with
     * `create_app_server`'s `rpc_endpoints` option, so consumers can pass
     * the same factory to both entry points. The factory runs once against
     * the stub `AppServerContext` this helper already builds.
     */
    rpc_endpoints?: Array<RpcEndpointSpec> | ((ctx: AppServerContext) => Array<RpcEndpointSpec>);
    /**
     * WebSocket endpoint specs for surface generation. Symmetric with
     * `create_app_server`'s `ws_endpoints` option — pass the same value
     * to both entry points so the attack surface tests see the same WS
     * endpoints production auto-mounts. The factory runs once against
     * the stub `AppServerContext` this helper already builds. No
     * `upgradeWebSocket` needed — this helper produces an `AppSurfaceSpec`
     * only, never mounts.
     */
    ws_endpoints?: ReadonlyArray<WsEndpointSpec> | ((ctx: AppServerContext) => ReadonlyArray<WsEndpointSpec>);
    /** Transform middleware array (e.g., zap's `extend_middleware_for_zap_binary`). */
    transform_middleware?: (specs: Array<MiddlewareSpec>) => Array<MiddlewareSpec>;
    /**
     * Bootstrap config — symmetric with `AppServerOptions.bootstrap`. Discriminated
     * by `mode`: `'disabled'` skips the route (same as omission), `'surface_only'`
     * mounts the route shape, `'live'` accepts a `token_path` for production
     * symmetry (surface assembly only uses it for shape symmetry; the value is a
     * live-execution concern handled by `create_test_app` → `create_app_server`).
     *
     * Surface assembly only reads `route_prefix` (default `'/api/account'`).
     */
    bootstrap?: BootstrapServerOptions;
}
/**
 * Create an `AppSurfaceSpec` for the standard testing suites.
 *
 * Used by both in-process and cross-process tests as the schema source —
 * the cross-process-ness lives in the transport + per-test fixture, not
 * here. The on-disk `*_attack_surface.json` snapshot is observability
 * (gen-time drift detection via `assert_surface_matches_snapshot`); the
 * suites consume the spec object this function returns, not the JSON
 * file.
 *
 * Mirrors `create_app_server`'s route assembly: consumer routes +
 * factory-managed bootstrap routes + surface generation. If
 * `create_app_server` changes how it wires routes, update this helper
 * to stay in sync (single source of truth for all consumers).
 *
 * @param options - surface spec options
 * @returns the surface spec for the standard suites
 */
export declare const create_test_app_surface_spec: (options: CreateTestAppSurfaceSpecOptions) => AppSurfaceSpec;
//# sourceMappingURL=stubs.d.ts.map