import type { ConnectionId } from '../../lib/connection_id.ts'; import { Identity } from '../../lib/identity.ts'; import type { ReducerCtx } from '../../lib/reducers.ts'; import type { UntypedSchemaDef } from '../../lib/schema.ts'; import { Timestamp } from '../../lib/timestamp.ts'; import type { TimeDuration } from '../../lib/time_duration.ts'; import { type HttpRequest, type HttpResponse } from '../../lib/autogen/types.ts'; import type { DbView } from '../db_view.ts'; import type { ProcedureCtx } from '../procedures.ts'; import type { Schema } from '../schema.ts'; import type { AnonymousViewCtx, ViewCtx } from '../views.ts'; import { type Query } from '../query.ts'; declare const nextSeed: unique symbol; export interface ModuleTestHarness { readonly db: DbView; readonly clock: TestClock; readonly rng: TestRng; readonly moduleIdentity: Identity; withReducerTx(auth: TestAuth, body: (ctx: ReducerCtx) => T): T; procedureContext(auth: TestAuth): ProcedureCtx; procedureContextBuilder(auth: TestAuth): ProcedureContextBuilder; viewContext(auth: TestAuth): ViewCtx; anonymousViewContext(): AnonymousViewCtx; runQuery(query: Query): Row[]; } export declare class TestClock { #private; constructor(timestamp?: Timestamp); now(): Timestamp; set(timestamp: Timestamp): void; advance(duration: TimeDuration): void; } export declare class TestRng { #private; constructor(seed?: number | bigint | Uint8Array | null); seed(): number | bigint | Uint8Array | null; setSeed(seed: number | bigint | Uint8Array): void; clearSeed(): void; [nextSeed](): bigint; } declare class TestAuthImpl { readonly kind: 'internal' | 'authenticated'; readonly connectionId: ConnectionId | null; readonly jwtPayload: string | null; private constructor(); static internal(): TestAuthImpl; static fromJwtPayload(jwtPayload: string, connectionId: ConnectionId): TestAuthImpl; } export type TestAuth = TestAuthImpl; export declare const TestAuth: typeof TestAuthImpl; /** * What a test HTTP responder returns: the response's status, headers and * version, plus its body, which `Response.text()`, `.json()` and `.bytes()` * then read. Omitting `body` gives an empty one. */ export type TestHttpResponse = HttpResponse & { body?: string | Uint8Array; }; export type TestHttpResponder = (test: ModuleTestHarness, req: HttpRequest, body: Uint8Array) => TestHttpResponse; export interface ProcedureContextBuilder { http(responder: TestHttpResponder): this; hooks(hooks: ProcedureTestHooks): this; build(): ProcedureCtx; } export declare class ProcedureTestHooks { #private; afterTxCommit(hook: (test: ModuleTestHarness) => void): this; onSleep(hook: (test: ModuleTestHarness, wakeTime: Timestamp) => void): this; runAfterTxCommit(test: ModuleTestHarness): void; runOnSleep(test: ModuleTestHarness, wakeTime: Timestamp): void; } export declare function createProcedureTestHooks(): ProcedureTestHooks; export declare function createModuleTestHarness(schema: Schema, moduleExports: Record, opts?: { moduleIdentity?: Identity; clock?: TestClock; rngSeed?: bigint | number | Uint8Array | null; }): ModuleTestHarness; export {}; //# sourceMappingURL=index.d.ts.map