import path from 'path-browserify';
import { LocalCollection } from './LocalCollection.js';
export class LocalVectorDB {
    workspace;
    uri;
    embeddingApi;
    constructor(workspace, uri, embeddingApi) {
        this.workspace = workspace;
        this.uri = uri;
        this.embeddingApi = embeddingApi;
    }
    addCollection(name) {
        const collection = new LocalCollection(path.join(this.uri, name), this.embeddingApi, this.workspace);
        collection.save();
        return collection;
    }
    removeCollection(name) {
        try {
            const collection = new LocalCollection(path.join(this.uri, name), this.embeddingApi, this.workspace);
            collection.delete();
        }
        catch {
        }
    }
    listCollections() {
        const names = this.workspace.readdirSync(this.uri).map(entry => entry.name);
        return names.map(name => new LocalCollection(path.join(this.uri, name), this.embeddingApi, this.workspace));
    }
}
