/** * In-memory stand-in for `@evershop/postgres-query-builder` and * `lib/postgres/connection.js`, for catalog service tests that must not touch a * database. It understands the query shapes of the variant group code: * select().from().where().and().innerJoin().on().load()/execute(), * insert().given().execute(), update().given().where().and().execute(), and * the transaction helpers. Conditions: `=`, `<>`, `in`, `IS NOT NULL`. * * Every connection that is handed out is counted, and counted again when a * commit or a rollback gives it back, so a test can see a leaked connection. */ type Row = Record; type Cond = [column: string, op: string, value: unknown]; export interface FakeCatalogDb { tables: Record; inserts: Array<{ table: string; data: Row; }>; updates: Array<{ table: string; data: Row; where: Cond[]; }>; tx: { started: number; committed: number; rolledBack: number; /** connections handed out and not yet given back */ open: number; }; /** The next query on this table throws this (to test the error paths). */ failOn: Record; } export declare function createFakeCatalogDb(seed?: Record): FakeCatalogDb; export declare function createFakeCatalogQueryBuilder(db: FakeCatalogDb): { select: (..._columns: string[]) => Record; insert: (table: string) => { given(d: Row): any; execute(): Promise<{ insertId: number; }>; }; update: (table: string) => { given(d: Row): any; where(c: string, op: string, v: unknown): any; and(c: string, op: string, v: unknown): any; execute(): Promise; }; startTransaction(connection: { INTRANSACTION: boolean; }): Promise; commit(): Promise; rollback(): Promise; getConnection(): Promise<{ INTRANSACTION: boolean; id: number; }>; pool: {}; }; export {};