/** * Cloudflare Vectorize index management * * Provides functions for: * - Checking if an index exists * - Creating new indexes with proper configuration * - Creating metadata indexes for filtering * - Deleting vectors by metadata filter (e.g., by version) */ /** * Options for index management operations */ export interface IndexManagementOptions { /** Cloudflare account ID */ accountId: string; /** Cloudflare API token */ apiToken: string; /** Show verbose output */ verbose?: boolean; } /** * Configuration for creating a new Vectorize index */ export interface CreateIndexConfig { /** Index name */ indexName: string; /** Embedding dimensions (default: 1024 for bge-m3) */ dimensions?: number; /** Distance metric (default: cosine) */ metric?: 'cosine' | 'euclidean' | 'dot-product'; } /** * Configuration for a metadata index */ export interface MetadataIndexConfig { /** Property name to index */ propertyName: string; /** Property type */ type: 'string' | 'number' | 'boolean'; } /** * Result of index existence check */ export interface IndexExistsResult { exists: boolean; config?: { dimensions: number; metric: string; }; } /** * Check if a Vectorize index exists * * @param indexName - Name of the index to check * @param options - API credentials and options * @returns Object indicating if index exists and its config */ export declare function indexExists(indexName: string, options: IndexManagementOptions): Promise; /** * Create a new Vectorize index * * @param config - Index configuration * @param options - API credentials and options * @returns True if created successfully */ export declare function createIndex(config: CreateIndexConfig, options: IndexManagementOptions): Promise; /** * Create a metadata index for filtering * * @param indexName - Name of the Vectorize index * @param metadataConfig - Metadata property configuration * @param options - API credentials and options * @returns True if created successfully */ export declare function createMetadataIndex(indexName: string, metadataConfig: MetadataIndexConfig, options: IndexManagementOptions): Promise; /** * Create multiple metadata indexes * * @param indexName - Name of the Vectorize index * @param metadataConfigs - Array of metadata property configurations * @param options - API credentials and options */ export declare function createMetadataIndexes(indexName: string, metadataConfigs: MetadataIndexConfig[], options: IndexManagementOptions): Promise; /** * Ensure an index exists, creating it if necessary * * @param config - Index configuration * @param metadataIndexes - Optional metadata indexes to create * @param options - API credentials and options * @returns True if index exists or was created */ export declare function ensureIndex(config: CreateIndexConfig, metadataIndexes: MetadataIndexConfig[] | undefined, options: IndexManagementOptions): Promise; /** * List ALL vector IDs in an index via the paginated list-vectors operation. * * Pagination is snapshot-consistent: vectors inserted after iteration starts * won't appear; vectors deleted mid-iteration may still appear. */ export declare function listAllVectorIds(indexName: string, options: IndexManagementOptions): Promise; /** * Fetch metadata for a set of vector IDs via get_by_ids (batched). */ export declare function getVectorsMetadata(indexName: string, ids: string[], options: IndexManagementOptions): Promise; }>>; /** * Supported filter shape for metadata-based deletion. * Values are either a literal (implicit $eq) or an operator object. */ export type MetadataDeleteFilter = Record; /** * Delete vectors by metadata filter. * * Vectorize has NO server-side delete-by-metadata operation (the previous * implementation POSTed to a nonexistent endpoint and silently deleted * nothing). This implementation scans the index client-side: * list-vectors → get_by_ids (metadata) → delete-by-ids. * * @param indexName - Name of the Vectorize index * @param filter - Metadata filter (e.g., { version: { "$eq": "next" } }); * supports $eq/$ne/$in/$nin and implicit equality * @param options - API credentials and options * @param dryRun - When true, report the match count without deleting * @returns Number of vectors deleted (or that would be deleted in dry-run) */ export declare function deleteByMetadataFilter(indexName: string, filter: MetadataDeleteFilter, options: IndexManagementOptions, dryRun?: boolean): Promise; /** * Delete all vectors whose version is NOT in the keep list. * * Removes stale index generations left behind by version bumps (each index * run stamps a version; without pruning, prior versions accumulate and * duplicate every chunk, crowding real results out of retrieval). * * @param indexName - Name of the Vectorize index * @param opts - site (optional scope) + versions to KEEP * @param options - API credentials and options * @param dryRun - When true, report the match count without deleting * @returns Number of vectors deleted (or that would be deleted in dry-run) */ export declare function pruneStaleVersions(indexName: string, opts: { site?: string; keepVersions: string[]; }, options: IndexManagementOptions, dryRun?: boolean): Promise; /** * Delete every vector in the index that a full run did NOT just write. * * Version-based pruning only removes whole stale generations. It cannot see * dead vectors that carry the CURRENT version: a deleted page, a renamed * heading, or a chunk whose ID changed all leave same-version orphans behind * that no version filter matches. Diffing the index against the set of IDs the * run produced catches all of those, and subsumes pruneStaleVersions (vectors * from other versions have IDs that are not in the current run either). * * ONLY safe after a complete, successful upload — the keep set has to be the * whole corpus. Called with a partial set (a shallow or failed run), this * deletes real content. * * @param indexName - Name of the Vectorize index * @param opts - keepIds (every ID the run wrote) + optional site scope * @param options - API credentials and options * @param dryRun - When true, report the match count without deleting * @returns Number of vectors deleted (or that would be deleted in dry-run) */ export declare function pruneToIdSet(indexName: string, opts: { site?: string; keepIds: Iterable; }, options: IndexManagementOptions, dryRun?: boolean): Promise; /** * Delete all vectors for a specific version * * Convenience wrapper around deleteByMetadataFilter for version-based deletion. * * @param indexName - Name of the Vectorize index * @param version - Version to delete (e.g., "next", "2026.04.01") * @param options - API credentials and options * @returns Number of vectors deleted (if available) */ export declare function deleteByVersion(indexName: string, version: string, options: IndexManagementOptions): Promise; //# sourceMappingURL=index-management.d.ts.map