import type { GraphileConfig } from 'graphile-config'; import type { GetConnectionsInput } from 'graphile-test'; import type { ExecutionResult, GraphQLSchema } from 'graphql'; import type { GetConnectionOpts } from 'pgsql-test'; import type { SeedAdapter } from 'pgsql-test/seed/types'; import type { PgTestClient } from 'pgsql-test/test-client'; /** * Input for creating a realtime test context. */ export interface RealtimeTestInput extends GetConnectionsInput, GetConnectionOpts { /** * Map of table names to smart tags to inject. * The `@realtime` tag is injected automatically for tables listed here. * * Example: `{ items: { realtime: true } }` * * If you only pass table names without tags, use `realtimeTables` instead. */ smartTags?: Record>; /** * Shorthand: list of table names that should get `{ realtime: true }`. * Merged with `smartTags` if both are provided. */ realtimeTables?: string[]; /** * Options for the realtime subscriptions plugin (e.g. overflowThreshold). */ realtimeOptions?: { overflowThreshold?: number; }; } /** * The context returned by `createRealtimeTestContext()`. */ export interface RealtimeTestContext { /** Root pg test client (superuser) */ pg: PgTestClient; /** Database-scoped test client */ db: PgTestClient; /** The built GraphQL schema (includes subscription fields) */ schema: GraphQLSchema; /** The resolved Graphile preset */ resolvedPreset: GraphileConfig.ResolvedPreset; /** * Start a GraphQL subscription and return the async iterator. * * The returned iterator yields `ExecutionResult` events. Call `.return()` * on it when done to clean up. */ subscribe(query: string, variables?: Record, contextOverrides?: Record): Promise | ExecutionResult>; /** * Fire a pg_notify on a realtime channel. * * @param table - Table name (unqualified) * @param operation - DML operation * @param rowIds - Affected row IDs * @param schema - Schema name (default: the first schema from input) */ notifyChange(table: string, operation: 'INSERT' | 'UPDATE' | 'DELETE', rowIds: string[], schema?: string): Promise; /** * Fire an INVALIDATE (overflow) NOTIFY. */ notifyInvalidate(table: string, schema?: string): Promise; /** * Fire a raw pg_notify on a realtime channel. */ notify(table: string, payload: string, schema?: string): Promise; /** Tear down the test context and close connections */ teardown(): Promise; } /** * Create a fully wired realtime test context. * * This sets up: * - A PostgreSQL test database with the given seed * - Smart tag injection via `makeRealtimeSmartTagsPlugin` * - The `RealtimeSubscriptionsPlugin` for subscription field generation * - A built GraphQL schema with subscription support * - Helper functions for subscribing, notifying, and asserting * * @param input - Configuration including schemas, tables, and options * @param seedAdapters - Optional SQL seed adapters (from `pgsql-test`) * @returns A `RealtimeTestContext` with all the helpers */ export declare function createRealtimeTestContext(input: RealtimeTestInput, seedAdapters?: SeedAdapter[]): Promise;