@gensx/storage
Version:
Cloud storage, blobs, sqlite, and vector database providers/hooks for GenSX.
71 lines (66 loc) • 2.09 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
*/
var config = require('../utils/config.cjs');
var remote = require('./remote.cjs');
/**
* Client for interacting with search functionality outside of JSX context
*/
class SearchClient {
storage;
constructor(options = {}) {
const { project, environment } = config.getProjectAndEnvironment({
project: options.project,
environment: options.environment,
});
this.storage = new remote.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);
}
}
exports.SearchClient = SearchClient;
//# sourceMappingURL=searchClient.cjs.map