import { type AnyColumn, type Table } from "drizzle-orm"; import { type MigrationEntry } from "../db/migrations.js"; import { type ResourceChangeSource } from "../resource-changes/store.js"; /** The change-feed consumer name the search index subscribes as. */ export declare const SEARCH_CHANGE_CONSUMER = "search"; /** What one resource contributes to the index. */ export interface SearchableResourceDocument { id: string; title: string; /** A short description, ranked between the title and the body. */ summary?: string | null; body?: string | null; modifiedAt?: string | Date | null; } export interface SearchableResourceRegistration { /** The app that owns the table, e.g. "content". */ app: string; /** Matches the shareable resource type, e.g. "document". */ type: string; /** The Drizzle table whose rows are indexed. */ table: Table; /** Its primary key column. */ idColumn: AnyColumn; /** * Bump when `load` changes what it returns. A higher version rebuilds the * index; searches use the app's fallback until the rebuild completes. */ version: number; /** * Loads the searchable text for a batch of ids. Omit an id whose row no * longer exists and it is removed from the index. Index every row the app * might search; access and filters are checked live at query time. */ load(ids: string[]): Promise; } /** * Makes an app table searchable through the core index. Pair it with * `searchIndexMigration()` in the app's `runMigrations` list, which installs * the triggers that keep the index fresh. */ export declare function registerSearchableResource(registration: SearchableResourceRegistration): SearchableResourceRegistration; export declare function getSearchableResource(app: string, type: string): SearchableResourceRegistration | undefined; export declare function listSearchableResources(): SearchableResourceRegistration[]; /** Removes a registration. Tests use it to isolate cases. */ export declare function unregisterSearchableResource(app: string, type: string): void; export declare function searchableResourceSource(registration: SearchableResourceRegistration): ResourceChangeSource; /** * A named migration that creates the search tables, raises the index's * target to the registration's version, and installs change capture on the * registration's table. Add it to the app's `runMigrations` * list with the app's next version number. It's recorded under `name` plus a * fingerprint of the capture SQL, so a release that changes that SQL installs * it again. */ export declare function searchIndexMigration(registration: SearchableResourceRegistration, entry: { version: number; name: string; }): MigrationEntry;