import type { TableNamesOf, UntypedSchemaDef } from '../lib/schema.ts'; import type { UntypedTableDef } from '../lib/table.ts'; import type { Values } from '../lib/type_util.ts'; import type { UntypedRemoteModule } from './spacetime_module.ts'; import { type TableCache } from './table_cache.ts'; type TableName = [SchemaDef] extends [UntypedSchemaDef] ? TableNamesOf : string; export type TableDefForTableName> = [SchemaDef] extends [UntypedSchemaDef] ? Values & { accessorName: N; } : UntypedTableDef & { accessorName: N; }; type TableCacheForTableName> = TableCache; /** * This is a helper class that provides a mapping from table names to their corresponding TableCache instances * while preserving the correspondence between the key and value type. */ declare class TableMap { private readonly map; get>(key: K): TableCacheForTableName | undefined; set>(key: K, value: TableCacheForTableName): this; has(key: TableName): boolean; delete(key: TableName): boolean; keys(): IterableIterator; values(): IterableIterator>>; entries(): IterableIterator<[ string, TableCacheForTableName> ]>; [Symbol.iterator](): IterableIterator<[string, TableCacheForTableName>]>; } /** * ClientCache maintains a cache of TableCache instances for each table in the database. * It provides methods to get or create TableCache instances by table name, * ensuring type safety based on the provided SchemaDef. */ export declare class ClientCache { /** * The tables in the database. */ readonly tables: TableMap; /** * Returns the table with the given name. * - If SchemaDef is a concrete schema, `name` is constrained to known table names, * and the return type matches that table. * - If SchemaDef is undefined, `name` is string and the return type is untyped. */ getTable>(name: N): TableCacheForTableName; /** * Returns the table with the given name, creating it if needed. * - Typed mode: `tableTypeInfo.tableName` is constrained to known names and * the return type matches that table. * - Untyped mode: accepts any string and returns an untyped TableCache. */ getOrCreateTable>(tableDef: TableDefForTableName): TableCacheForTableName; } export {}; //# sourceMappingURL=client_cache.d.ts.map