/** * Collections API for CortexDB * * Provides methods to create, read, update, and delete collections. * Collections define the schema and structure for records. */ import { Collection, FieldDefinition, CollectionConfig } from "../types"; import { HTTPClient } from "../http/client"; /** * API for managing CortexDB collections */ export declare class CollectionsAPI { private http; private getDefaultDatabase?; private resolveEmbeddingProvider?; /** * Create a new CollectionsAPI instance * * @param http - HTTP client for making requests */ constructor(http: HTTPClient, getDefaultDatabase?: (() => string | undefined) | undefined, resolveEmbeddingProvider?: ((ref: string) => Promise) | undefined); private resolveDatabase; /** * List all collections in the database * * @param database - Database name (required unless default database is set) * @returns Array of all collections * @example * ```typescript * const collections = await client.collections.list('production'); * console.log(`Found ${collections.length} collections`); * ``` */ list(database?: string): Promise; /** * Get a specific collection by name * * @param name - Name of the collection to retrieve * @returns Collection details including schema * @throws {CortexDBNotFoundError} If collection doesn't exist * @example * ```typescript * const collection = await client.collections.get('my_collection'); * console.log(collection.fields); * ``` */ get(name: string, database?: string): Promise; /** * Create a new collection with the specified schema * * @param name - Name for the new collection * @param fields - Array of field definitions * @param embedding_provider - Optional embedding provider ID (required if any field has vectorize=true) * @returns Created collection details * @throws {CortexDBValidationError} If schema is invalid or embedding provider is missing when required * @example * ```typescript * const collection = await client.collections.create('documents', [ * { name: 'title', type: FieldType.STRING }, * { name: 'content', type: FieldType.STRING, vectorize: true } * ], 'embedding-provider-id'); * ``` */ create(name: string, fields: FieldDefinition[], config?: string | CollectionConfig, database?: string): Promise; /** * Update an existing collection's schema * * @param name - Name of the collection to update * @param fields - New field definitions * @returns Updated collection details * @throws {CortexDBNotFoundError} If collection doesn't exist * @example * ```typescript * const updated = await client.collections.update('documents', [ * { name: 'title', type: FieldType.STRING }, * { name: 'description', type: FieldType.STRING } * ]); * ``` */ update(name: string, fields: FieldDefinition[], config?: CollectionConfig, database?: string): Promise; private normalizeConfig; private resolveEmbeddingProviderRef; /** * Delete a collection and all its records * * @param name - Name of the collection to delete * @throws {CortexDBNotFoundError} If collection doesn't exist * @example * ```typescript * await client.collections.delete('old_collection'); * ``` */ delete(name: string, database?: string): Promise; } //# sourceMappingURL=api.d.ts.map