import type { AnyEntity, EntityClass, EntitySchema } from "@mikro-orm/core"; import { MikroORM, SqliteDriver } from "@mikro-orm/sql"; import type { Options, SqlEntityManager } from "@mikro-orm/sql"; import type { SqlExecutor, SqlStorageAdapter, SqlStorageContext } from "../../../../contracts/storage/sql.js"; /** MikroORM entity-manager type used by the Node SQLite dialect. */ export type MikroOrmSqliteEntityManager = SqlEntityManager; /** MikroORM root instance configured with the generic Node SQLite driver. */ export type MikroOrmSqlite = MikroORM; /** Entity metadata accepted by the SQLite-backed MikroORM integration. */ export type MikroOrmSqliteEntity = string | EntityClass | EntitySchema; /** Optional MikroORM settings owned by the host application. */ export type MikroOrmSqliteConfiguration = Omit>, "dbName" | "driver" | "driverOptions" | "entities">; /** Inputs for creating the SQLite ORM instance that typed-sheets will use. */ export interface InitializeMikroOrmSqliteAdapterOptions { /** SQLite file path, exact `:memory:`, or a `:memory:`-prefixed value (normalized to in-memory). */ readonly dbName: string; /** Application entities managed by the dedicated Sheets-side MikroORM instance. */ readonly entities: readonly MikroOrmSqliteEntity[]; /** Optional MikroORM settings that do not select a different database or driver. */ readonly configuration?: MikroOrmSqliteConfiguration; } /** Explicit native mutation capability used only by the inbound observation bridge. */ export interface MikroOrmNativeEntityWriter { findOne(entityName: unknown, where: Record): Promise; insert(entityName: unknown, data: Record): Promise; nativeUpdate(entityName: unknown, where: Record, data: Record): Promise; nativeDelete(entityName: unknown, where: Record): Promise; } /** * Adapter-specific transaction context for code that intentionally needs * MikroORM entity lifecycle operations alongside typed-sheets storage SQL. * * Core storage must use `sql`; `entityManager` and `nativeWriter` are explicit * escape hatches for integration code and never appear in the adapter-neutral contract. */ export interface MikroOrmSqliteTransaction extends SqlStorageContext { readonly entityManager: MikroOrmSqliteEntityManager; /** Explicit native mutation capability used by inbound observation writes. */ readonly nativeWriter: MikroOrmNativeEntityWriter; } /** * Connects typed-sheets storage SQL to one MikroORM-managed SQLite database. * * The adapter never opens a second `node:sqlite` connection. Raw storage SQL * and MikroORM entity changes therefore share the same transaction context. */ export declare class MikroOrmSqliteAdapter implements SqlStorageAdapter { private readonly orm; constructor(orm: MikroOrmSqlite); /** Creates a clean manager for one provider read or lifecycle transaction. */ forkEntityManager(): MikroOrmSqliteEntityManager; /** Creates a SQL executor bound to the supplied manager's active transaction. */ createSqlExecutor(entityManager: MikroOrmSqliteEntityManager): SqlExecutor; /** Runs a read through a fresh EntityManager to avoid stale identity-map state. */ read(operation: (context: SqlStorageContext) => Promise): Promise; /** Runs adapter-neutral storage work in one MikroORM transaction. */ transaction(operation: (context: SqlStorageContext) => Promise): Promise; /** * Runs integration work that needs both the active MikroORM EntityManager and * the transaction-bound storage SQL executor. */ transactional(operation: (context: MikroOrmSqliteTransaction) => Promise): Promise; /** Closes the SQLite connection owned by this adapter. */ close(force?: boolean): Promise; /** * Creates missing entity tables and applies only non-destructive entity-schema updates. * * This is intentionally explicit instead of running during adapter creation: * a production process must opt into changing its SQLite schema at startup. */ migrateEntitySchema(): Promise; } /** Creates a typed-sheets storage adapter around an application-owned MikroORM instance. */ export declare function createMikroOrmSqliteAdapter(orm: MikroOrmSqlite): MikroOrmSqliteAdapter; /** * Opens the dedicated SQLite MikroORM instance used for Sheets-backed entities. * * This intentionally creates a separate ORM from any application-owned MySQL * instance, so Sheet entities cannot accidentally write to the primary database. */ export declare function initializeMikroOrmSqliteAdapter(options: InitializeMikroOrmSqliteAdapterOptions): Promise; //# sourceMappingURL=MikroOrmSqliteAdapter.d.ts.map