@gensx/storage
Version:
Cloud storage, blobs, sqlite, and vector database providers/hooks for GenSX.
69 lines (65 loc) • 2.07 kB
JavaScript
/**
* Check out the docs at https://www.gensx.com/docs
* Find us on Github https://github.com/gensx-inc/gensx
* Find us on Discord https://discord.gg/F5BSU8Kc
*/
import { getProjectAndEnvironment } from '../utils/config.js';
import { SearchStorage } from './remote.js';
/**
* Client for interacting with search functionality outside of JSX context
*/
class SearchClient {
storage;
constructor(options = {}) {
const { project, environment } = getProjectAndEnvironment({
project: options.project,
environment: options.environment,
});
this.storage = new SearchStorage(project, environment);
}
/**
* Get a namespace (ensures it exists first)
* @param name The namespace name
* @returns A Promise resolving to a Namespace
*/
async getNamespace(name) {
if (!this.storage.hasEnsuredNamespace(name)) {
await this.storage.ensureNamespace(name);
}
return this.storage.getNamespace(name);
}
/**
* Ensure a namespace exists
* @param name The namespace name
* @returns A Promise resolving to the ensure result
*/
async ensureNamespace(name) {
return this.storage.ensureNamespace(name);
}
/**
* List all namespaces
* @param options Options for listing namespaces
* @returns A Promise resolving to an array of namespace names
*/
async listNamespaces(options) {
return this.storage.listNamespaces(options);
}
/**
* Delete a namespace
* @param name The namespace name
* @returns A Promise resolving to the deletion result
*/
async deleteNamespace(name) {
return this.storage.deleteNamespace(name);
}
/**
* Check if a namespace exists
* @param name The namespace name
* @returns A Promise resolving to a boolean indicating if the namespace exists
*/
async namespaceExists(name) {
return this.storage.namespaceExists(name);
}
}
export { SearchClient };
//# sourceMappingURL=searchClient.js.map