import './assert_dev_env.js';
import type { RouteSpec } from '../http/route_spec.js';
import type { AppServerContext } from '../server/app_server.js';
import type { SessionOptions } from '../auth/session_cookie.js';
import { type EventSpec } from '../realtime/sse.js';
import type { AuditLogEvent } from '../auth/audit_log_schema.js';
import { type SuiteAppOptions, type TestApp, type TestAccount } from './app_server.js';
import { type DbFactory } from './db.js';
import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
/** Config for a single SSE route under test. */
export interface SseRouteTestSpec {
    /** Full HTTP path of the SSE endpoint (e.g., `'/api/zap/subscribe'`). */
    path: string;
    /**
     * Fire an event matching one of the declared `event_specs` that should
     * reach the open stream. Called after the `: connected` comment is observed.
     * The triggered frame must be a JSON-serializable `{method, params}` payload.
     */
    trigger: (ctx: {
        test_app: TestApp;
        account: TestAccount;
    }) => Promise<void>;
    /**
     * Event specs to validate the triggered payload against. When omitted,
     * the payload is only asserted to be well-formed `{method, params}`.
     */
    event_specs?: Array<EventSpec>;
    /**
     * Whether to assert the stream closes after `session_revoke_all`.
     * Default `true`. Set `false` for endpoints that don't wire a close-on-revoke
     * guard (leaves a TODO to fix, rather than silently passing).
     */
    assert_closes_on_revoke?: boolean;
}
/** Options for `describe_sse_route_tests`. */
export interface SseRouteTestOptions {
    /** Session config for cookie-based auth. */
    session_options: SessionOptions<string>;
    /** Route spec factory — same shape as production. */
    create_route_specs: (ctx: AppServerContext) => Array<RouteSpec>;
    /** Optional overrides for `AppServerOptions`. */
    app_options?: SuiteAppOptions;
    /** Database factories to run tests against. Default: pglite only. */
    db_factories?: Array<DbFactory>;
    /**
     * Backend audit event callback — threaded to `create_test_app_server`.
     * Use to wire a close-on-revoke guard for consumer SSE registries
     * (e.g., via `create_sse_auth_guard`) so `session_revoke_all` actually
     * closes the tested streams.
     */
    on_audit_event?: (event: AuditLogEvent) => void;
    /**
     * RPC endpoint specs — required so the close-on-revoke assertion can
     * dispatch `account_session_revoke_all` via RPC (there is no REST
     * equivalent). Hard-fails via `require_rpc_endpoint_path` on setup.
     *
     * Accepts either an array (eager) or a factory
     * `(ctx: AppServerContext) => Array<RpcEndpointSpec>` — the factory form
     * is required when action handlers must close over the per-test
     * `ctx.deps`. The factory must return the same
     * endpoint `path` regardless of ctx — it is invoked once at setup with
     * a stub ctx for path lookup and again per-test by `create_app_server`
     * for live dispatch.
     */
    rpc_endpoints: RpcEndpointsSuiteOption;
    /** SSE routes to exercise. */
    routes: Array<SseRouteTestSpec>;
}
/**
 * Run SSE route validation tests.
 *
 * For each route: opens an authenticated SSE connection, asserts the
 * connected comment, fires the trigger, validates the resulting payload,
 * then asserts close-on-revoke (unless opted out).
 *
 * @throws Error at setup time when `options.rpc_endpoints` is empty — the
 *   close-on-revoke assertion dispatches `account_session_revoke_all` via
 *   RPC. Hard-fails via `require_rpc_endpoint_path`.
 */
export declare const describe_sse_route_tests: (options: SseRouteTestOptions) => void;
//# sourceMappingURL=sse_round_trip.d.ts.map