import type { Run, RunFeedback, RunQuery, RunTree, TraceStore } from '../types/tracing.js'; import type { MigrationResult, SchemaMigration } from '../utils/schema-migrations.js'; import { type PostgresLikeClient } from './client.js'; import type { PostgresMigrateOptions } from './migrations.js'; /** Options for the Postgres trace store. */ export interface PostgresTraceStoreOptions { /** Table name, optionally schema-qualified. Defaults to `nexus_runs`. */ table?: string; } /** The schema, as statements: every migration's, in order. */ export declare function traceStoreMigration(options?: PostgresTraceStoreOptions): string[]; /** * The versioned schema, which `migrate()` and `nexus db migrate` apply. Version 1 is the 2.0 table; * version 2 indexes runs by `metadata.tenantId`, which a tenant-scoped trace store filters on; version * 3 indexes them in query order, start time then id, which a page resumed by cursor seeks to. */ export declare function traceStoreMigrations(options?: PostgresTraceStoreOptions): SchemaMigration[]; /** * Traces in Postgres. * * Every filter of a `RunQuery` — tags, metadata paths, and feedback keys included — becomes one SQL * condition, so paging happens in the database and a query means exactly what it means against the * in-memory store. Feedback is appended in one statement, so two evaluators scoring one run at the * same moment both land. */ export declare class PostgresTraceStore implements TraceStore { private readonly client; private readonly options; private readonly table; constructor(client: PostgresLikeClient, options?: PostgresTraceStoreOptions); /** * Applies this store's pending migrations, recorded in `nexus_schema_migrations`, under a lock. * Never runs implicitly. Safe on a database an older release created: what exists is kept. */ migrate(options?: PostgresMigrateOptions): Promise; /** Stores a run, replacing an earlier version with the same id. */ save(run: Run): Promise; /** Reads a run. */ get(runId: string): Promise; /** Runs matching a query, filtered and ordered in SQL. */ query(query?: RunQuery): Promise; /** A trace's runs, assembled into a tree. */ tree(traceId: string): Promise; /** Appends feedback to a run in one statement. */ addFeedback(runId: string, feedback: RunFeedback): Promise; /** Deletes runs started before an ISO-8601 time, returning how many went. */ prune(before: string): Promise; }