import SQLite3 from 'better-sqlite3'; import { NymphDriver, type EntityConstructor, type EntityObjectType, type EntityInterface, type EntityInstanceType, type SerializedEntityData, type FormattedSelector, type Options, type Selector } from '@nymphjs/nymph'; import { SQLite3DriverConfig } from './conf/index.js'; declare class InternalStore { link: SQLite3.Database; linkWrite?: SQLite3.Database; connected: boolean; transactionsStarted: number; constructor(link: SQLite3.Database); } /** * The SQLite3 Nymph database driver. */ export default class SQLite3Driver extends NymphDriver { config: SQLite3DriverConfig; protected prefix: string; protected store: InternalStore; static escape(input: string): string; static escapeValue(input: string): string; constructor(config: Partial, store?: InternalStore); /** * This is used internally by Nymph. Don't call it yourself. * * @returns A clone of this instance. */ clone(): SQLite3Driver; /** * Connect to the SQLite3 database. * * @returns Whether this instance is connected to a SQLite3 database. */ connect(): Promise; private _connect; /** * Disconnect from the SQLite3 database. * * @returns Whether this instance is connected to a SQLite3 database. */ disconnect(): Promise; inTransaction(): Promise; /** * Check connection status. * * @returns Whether this instance is connected to a SQLite3 database. */ isConnected(): boolean; private createEntitiesTable; private addTilmeldColumnsAndIndexes; private createEntitiesTilmeldIndexes; private createDataTable; private createReferencesTable; private createTokensTable; private createUniquesTable; /** * Create entity tables in the database. * * @param etype The entity type to create a table for. If this is blank, the default tables are created. */ private createTables; private query; private queryArray; private queryGet; private queryRun; commit(name: string): Promise; deleteEntityByID(guid: string, className?: EntityConstructor | string | null): Promise; deleteUID(name: string): Promise; getIndexes(etype: string): Promise<{ scope: 'data' | 'references' | 'tokens'; name: string; property: string; }[]>; addIndex(etype: string, definition: { scope: 'data' | 'references' | 'tokens'; name: string; property: string; }): Promise; deleteIndex(etype: string, scope: 'data' | 'references' | 'tokens', name: string): Promise; getEtypes(): Promise; exportDataIterator(): AsyncGenerator<{ type: 'comment' | 'uid' | 'entity'; content: string; }, void, false | undefined>; /** * Generate the SQLite3 query. * @param options The options array. * @param formattedSelectors The formatted selector array. * @param etype * @param count Used to track internal params. * @param params Used to store internal params. * @param subquery Whether only a subquery should be returned. * @returns The SQL query. */ private makeEntityQuery; protected performQuery(options: Options, formattedSelectors: FormattedSelector[], etype: string): { result: any; }; getEntities(options: Options & { return: 'count'; }, ...selectors: Selector[]): Promise; getEntities(options: Options & { return: 'guid'; }, ...selectors: Selector[]): Promise; getEntities(options: Options & { return: 'object'; }, ...selectors: Selector[]): Promise[]>; getEntities(options?: Options, ...selectors: Selector[]): Promise[]>; getUID(name: string): Promise; importEntity(entity: { guid: string; cdate: number; mdate: number; tags: string[]; sdata: SerializedEntityData; etype: string; }): Promise; importEntityTokens(entity: { guid: string; cdate: number; mdate: number; tags: string[]; sdata: SerializedEntityData; etype: string; }): Promise; importEntityTilmeldAC(entity: { guid: string; cdate: number; mdate: number; tags: string[]; sdata: SerializedEntityData; etype: string; }): Promise; private importEntityInternal; importUID({ name, value }: { name: string; value: number; }): Promise; newUID(name: string): Promise; renameUID(oldName: string, newName: string): Promise; rollback(name: string): Promise; saveEntity(entity: EntityInterface): Promise; setUID(name: string, curUid: number): Promise; internalTransaction(name: string): Promise; startTransaction(name: string): Promise; private removeTilmeldOldRows; needsMigration(): Promise<'json' | 'tokens' | 'tilmeldColumns' | false>; liveMigration(migrationType: 'tokenTables' | 'tilmeldColumns' | 'tilmeldRemoveOldRows'): Promise; } export {};