import { IConnection } from '../../connection/index.js'; import { BatchStats, NodeShardStatus, NodeStats, WeaviateReplicationResponse, WeaviateReplicationType, WeaviateShardingState } from '../../openapi/types.js'; import { DeepRequired } from '../../utils/types.js'; export type Output = 'minimal' | 'verbose' | undefined; export type NodesOptions = { /** The name of the collection to get the status of. */ collection?: string; /** Set the desired output verbosity level. Can be `minimal | verbose | undefined` with `undefined` defaulting to `minimal`. */ output: O; }; export type QueryShardingStateOptions = { /** The name of the shard to query. If not provided, all shards will be queried. */ shard?: string; }; export type ReplicateArgs = { /** The name of the collection in which to replicate a shard. */ collection: string; /** The name of the shard to replicate. */ shard: string; /** The name of the node from which to replicate the shard. */ sourceNode: string; /** The name of the node to which to replicate the shard. */ targetNode: string; /** The type of replication to perform. */ replicationType: WeaviateReplicationType; }; export type ShardingState = DeepRequired; export type ReplicationOperation = DeepRequired; export type QueryReplicationOpsOptions = { /** The name of the collection to query. */ collection?: string; /** The name of the shard to query. */ shard?: string; /** The target node of the op to query. */ targetNode?: string; /** Whether to include the status history in the response. */ includeHistory?: boolean; }; export type GetReplicationOpOptions = { /** Whether to include the status history in the response. Defaults to false. */ includeHistory?: boolean; }; export type Node = { name: string; status: 'HEALTHY' | 'UNHEALTHY' | 'UNAVAILABLE'; version: string; gitHash: string; stats: O extends 'minimal' | undefined ? undefined : Required; batchStats: Required; shards: O extends 'minimal' | undefined ? null : Required[]; }; declare const cluster: (connection: IConnection) => { nodes: (opts?: NodesOptions) => Promise[]>; queryShardingState: (collection: string, opts?: QueryShardingStateOptions) => Promise<{ collection: string; shards: { shard: string; replicas: string[]; }[]; }>; replicate: (args: ReplicateArgs) => Promise; replications: { cancel: (id: string) => Promise; delete: (id: string) => Promise; deleteAll: () => Promise; get: (id: string, opts?: GetReplicationOpOptions) => Promise; query: (opts?: QueryReplicationOpsOptions) => Promise; }; }; export default cluster; export interface Cluster { /** * Get the status of all nodes in the cluster. * * @param {NodesOptions} [opts] The options for the request. * @returns {Promise[]>} The status of all nodes in the cluster. */ nodes: (opts?: NodesOptions) => Promise[]>; /** * Query the sharding state of a specific collection. * * @param {string} collection The name of the collection to query. * @param {QueryShardingStateOptions} [opts] The options for the request. * @returns {Promise} The sharding state of the collection. */ queryShardingState: (collection: string, opts?: QueryShardingStateOptions) => Promise; /** * Replicate a shard from one node to another. * * @param {ReplicateArgs} args The arguments for the replication request. * @returns {Promise} The ID of the replication request. */ replicate: (args: ReplicateArgs) => Promise; /** * Access replication operations. */ replications: Replications; } export interface Replications { /** * Cancel a replication operation. * * @param {string} id The ID of the replication operation to cancel. * @returns {Promise} A promise that resolves when the operation is cancelled. */ cancel: (id: string) => Promise; /** * Delete a replication operation. * * @param {string} id The ID of the replication operation to delete. * @returns {Promise} A promise that resolves when the operation is deleted. */ delete: (id: string) => Promise; /** * Delete all replication operations. * * @returns {Promise} A promise that resolves when all operations are deleted. */ deleteAll: () => Promise; /** * Get a specific replication operation by ID. * * @param {string} id The ID of the replication operation to get. * @param {boolean} [opts.includeHistory=false] Whether to include the status history in the response. * @returns {Promise} The replication operation or null if not found. */ get: (id: string, opts?: { includeHistory?: boolean; }) => Promise; /** * Query all replication operations with optional filters. * * @param {QueryReplicationOpsOptions} [opts] Optional parameters for filtering the query. * @returns {Promise} A list of replication operations matching the query. */ query: (opts?: QueryReplicationOpsOptions) => Promise; }