import type { PromptHistoryEntry, PromptLabel, PromptStore, PromptVersion } from '../types/prompts.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 prompt store. */ export interface PostgresPromptStoreOptions { /** Table name prefix, optionally schema-qualified. Defaults to `nexus_prompt`, for `nexus_prompt_versions` and so on. */ table?: string; } /** * The versioned schema, which `migrate()` and `nexus db migrate` apply. Version 1 is the 2.0 schema. */ export declare function promptStoreMigrations(options?: PostgresPromptStoreOptions): SchemaMigration[]; /** The schema for the prompt store, as statements. */ export declare function promptStoreMigration(options?: PostgresPromptStoreOptions): string[]; /** * Prompt versions, labels, and history in Postgres. * * Label compare-and-set is a single statement — an insert that does nothing on conflict, or an update * that matches only the expected version — so two workers promoting at once cannot both win. */ export declare class PostgresPromptStore implements PromptStore { private readonly client; private readonly options; private readonly versions; private readonly labels; private readonly history; constructor(client: PostgresLikeClient, options?: PostgresPromptStoreOptions); /** * 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 version, unless one with the same content version exists. */ saveVersion(version: PromptVersion): Promise; /** Reads a version. */ getVersion(name: string, version: string): Promise; /** Versions of a prompt, newest first. Defaults to 50. */ listVersions(name: string, options?: { limit?: number; }): Promise; /** Reads a label. */ getLabel(name: string, label: string): Promise; /** Every label of a prompt, sorted by name. */ listLabels(name: string): Promise; /** Writes a label when it still points at `expected`, in one statement. */ setLabel(label: PromptLabel, expected?: string | null): Promise; /** Removes a label. Resolves true when it existed. */ deleteLabel(name: string, label: string): Promise; /** Records a change. */ appendHistory(entry: PromptHistoryEntry): Promise; /** A prompt's history, newest first, optionally for one label. Defaults to 100. */ listHistory(name: string, options?: { label?: string; limit?: number; }): Promise; /** Every prompt name, sorted. */ listNames(): Promise; }