import type { Store, StoreIndexOptions, StoreItem, StoreNamespace, StorePutOptions, StoreSearchOptions } from '../types/store.js'; import type { MigrationResult, SchemaMigration } from '../utils/schema-migrations.js'; import { type SqliteDatabaseLike, type SqliteLikeClient } from './client.js'; import type { SqliteMigrateOptions } from './migrations.js'; /** Options for the SQLite store. */ export interface SqliteStoreOptions { /** Table name. Defaults to `nexus_store`. */ table?: string; /** Enables semantic search by embedding indexed fields on write. */ index?: StoreIndexOptions; /** Replaces the system clock, for tests. */ now?: () => Date; } /** The schema, as statements. */ export declare function sqliteStoreMigration(options?: Pick): string[]; /** The versioned schema, which `migrate()` applies. Version 1 is the 2.0 schema. */ export declare function sqliteStoreMigrations(options?: Pick): SchemaMigration[]; /** * Long-term memory in SQLite, for one machine that needs memory to survive a restart. * * The same contract as `MemoryStore`, `RedisStore`, and `PostgresStore`, checked by the same tests. * The namespace prefix and expiry are matched in SQL; filters, text queries, and semantic ranking * run in the process over the candidates under the prefix, with the same helpers the in-memory store * uses, so every store answers a search identically. */ export declare class SqliteStore implements Store { private readonly options; private readonly client; private readonly table; private readonly now; constructor(database: SqliteLikeClient | SqliteDatabaseLike, options?: SqliteStoreOptions); /** * Applies this store's pending migrations, recorded in `nexus_schema_migrations`, each inside * `BEGIN IMMEDIATE`. Never runs implicitly. Safe on a file an older release created. */ migrate(options?: SqliteMigrateOptions): Promise; /** Stores an item, keeping its original `createdAt` when it replaces one. */ put(namespace: StoreNamespace, key: string, value: V, options?: StorePutOptions): Promise; /** * Stores an item only when the stored one's `version` is `expected`, or, with `expected` `null`, * only when none is stored. One statement, so two processes sharing the file cannot both win. */ putIfVersion(namespace: StoreNamespace, key: string, value: V, expected: number | null): Promise; /** Reads an item, or `undefined` when it does not exist or has expired. */ get(namespace: StoreNamespace, key: string): Promise | undefined>; /** Deletes an item. */ delete(namespace: StoreNamespace, key: string): Promise; /** * Items under a namespace prefix, newest first, or ranked by similarity when a query is given. * Defaults to 20. */ search(namespacePrefix: StoreNamespace, options?: StoreSearchOptions): Promise>>; /** Namespaces under a prefix. Defaults to 100. */ listNamespaces(options?: { prefix?: StoreNamespace; limit?: number; }): Promise; /** Deletes expired items, returning how many went. Reads already hide them. */ sweep(): Promise; private embed; }