import { CollectionQuery, Models } from '@triplit/db'; import { DBChanges, CollectionName, KVStoreTransaction, EntityStore, KVStoreOrTransaction, Entity, Update, ApplyChangesOptions, WritePermissionCheck, EntityChangeValidator } from './types.js'; import { Tuple } from './codec.js'; import { DBSchema } from './db.js'; import { DBSession } from './session.js'; import { TypeConverters } from './schema/converters.js'; export interface DBTransactionOptions { entityStore: EntityStore; schema: DBSchema | undefined; kvTx: KVStoreTransaction; systemVars: Record; session: DBSession | undefined; typeConverters: TypeConverters | undefined; checkWritePermission: WritePermissionCheck | undefined; entityChangeValidator: EntityChangeValidator | undefined; skipRules: boolean; } export declare class DBTransaction { readonly kvTx: KVStoreTransaction; readonly entityStore: EntityStoreWithChanges; changes: DBChanges; schema: DBSchema | undefined; systemVars: Record; session: DBSession | undefined; typeConverters: TypeConverters | undefined; skipRules: boolean; checkWritePermission: WritePermissionCheck | undefined; entityChangeValidator: EntityChangeValidator | undefined; constructor(options: DBTransactionOptions); commit(): Promise; cancel(): Promise; fetch(query: CollectionQuery): Promise; fetchOne(query: CollectionQuery): Promise; fetchById(collectionName: string, id: string): Promise; insert(collectionName: string, data: any): Promise; update(collectionName: string, id: string, update: Update | ((entity: Entity) => void | Promise)): Promise; delete(collectionName: string, id: string): Promise; private getOrCreateCollectionChanges; } export declare class EntityStoreWithChanges implements EntityStore { readonly changes: DBChanges; baseStore: EntityStore; constructor(baseStore: EntityStore, changes?: DBChanges); onChange(callback: (changes: DBChanges) => void): () => void; applyChanges(tx: KVStoreTransaction, changes: DBChanges, options: ApplyChangesOptions): Promise; getEntity(storage: KVStoreOrTransaction, collection: string, id: string): Promise; getEntitiesInCollection(storage: KVStoreOrTransaction, collection: CollectionName): AsyncIterable<[Tuple, Entity]>; } export declare function createUpdateProxyAndTrackChanges(entity: any, changes: any): any; export declare function createSetProxy(set: Set, changes: Record): Set;