meilisearch
Version:
The Meilisearch JS client for Node.js and the browser.
327 lines • 11.4 kB
TypeScript
import { Index } from "./indexes.js";
import type { KeyCreation, Config, IndexOptions, IndexObject, Key, Health, Stats, Version, KeyUpdate, IndexesQuery, IndexesResults, KeysQuery, KeysResults, IndexSwap, MultiSearchParams, FederatedMultiSearchParams, MultiSearchResponseOrSearchResponse, EnqueuedTaskPromise, ExtraRequestInit, Network, RecordAny, RuntimeTogglableFeatures, ResourceResults, Webhook, ResultsWrapper, WebhookCreatePayload, WebhookUpdatePayload, InitializeNetworkOptions, AddRemoteOptions, RemoveRemoteOptions } from "./types/index.js";
import { HttpRequests } from "./http-requests.js";
import { TaskClient } from "./task.js";
import { BatchClient } from "./batch.js";
import { ChatWorkspace } from "./chat-workspace.js";
export declare class Meilisearch {
#private;
config: Config;
httpRequest: HttpRequests;
get tasks(): TaskClient;
get batches(): BatchClient;
/**
* Creates new Meilisearch instance
*
* @param config - Configuration object
*/
constructor(config: Config);
/**
* Return an Index instance
*
* @param indexUid - The index UID
* @returns Instance of Index
*/
index<T extends RecordAny = RecordAny>(indexUid: string): Index<T>;
/**
* Gather information about an index by calling Meilisearch and return an
* Index instance with the gathered information
*
* @param indexUid - The index UID
* @returns Promise returning Index instance
*/
getIndex<T extends RecordAny = RecordAny>(indexUid: string): Promise<Index<T>>;
/**
* Gather information about an index by calling Meilisearch and return the raw
* JSON response
*
* @param indexUid - The index UID
* @returns Promise returning index information
*/
getRawIndex(indexUid: string): Promise<IndexObject>;
/**
* Get all the indexes as Index instances.
*
* @param parameters - Parameters to browse the indexes
* @returns Promise returning array of raw index information
*/
getIndexes(parameters?: IndexesQuery): Promise<IndexesResults<Index[]>>;
/**
* Get all the indexes in their raw value (no Index instances).
*
* @param parameters - Parameters to browse the indexes
* @returns Promise returning array of raw index information
*/
getRawIndexes(parameters?: IndexesQuery): Promise<IndexesResults<IndexObject[]>>;
/**
* Create a new index
*
* @param uid - The index UID
* @param options - Index options
* @returns Promise returning Index instance
*/
createIndex(uid: string, options?: IndexOptions): EnqueuedTaskPromise;
/**
* Update an index
*
* @param uid - The index UID
* @param options - Index options to update
* @returns Promise returning Index instance after updating
*/
updateIndex(uid: string, options?: IndexOptions): EnqueuedTaskPromise;
/**
* Delete an index
*
* @param uid - The index UID
* @returns Promise which resolves when index is deleted successfully
*/
deleteIndex(uid: string): EnqueuedTaskPromise;
/**
* Deletes an index if it already exists.
*
* @param uid - The index UID
* @returns Promise which resolves to true when index exists and is deleted
* successfully, otherwise false if it does not exist
*/
deleteIndexIfExists(uid: string): Promise<boolean>;
/**
* Swaps a list of index tuples.
*
* @param params - List of indexes tuples to swap.
* @returns Promise returning object of the enqueued task
*/
swapIndexes(params: IndexSwap[]): EnqueuedTaskPromise;
/**
* Perform multiple search queries.
*
* It is possible to make multiple search queries on the same index or on
* different ones. With network feature enabled, you can also search across
* remote instances.
*
* @example
*
* ```ts
* client.multiSearch({
* queries: [
* { indexUid: "movies", q: "wonder" },
* { indexUid: "books", q: "flower" },
* ],
* });
*
* // Federated search with remote instance (requires network feature enabled)
* client.multiSearch({
* federation: {},
* queries: [
* {
* indexUid: "movies",
* q: "wonder",
* federationOptions: {
* remote: "meilisearch instance name",
* },
* },
* {
* indexUid: "movies",
* q: "wonder",
* federationOptions: {
* remote: "meilisearch instance name",
* },
* },
* ],
* });
* ```
*
* @param queries - Search queries
* @param extraRequestInit - Additional request configuration options
* @returns Promise containing the search responses
* @see {@link https://www.meilisearch.com/docs/learn/multi_search/implement_sharding#perform-a-search}
*/
multiSearch<T1 extends MultiSearchParams | FederatedMultiSearchParams, T2 extends RecordAny = RecordAny>(queries: T1, extraRequestInit?: ExtraRequestInit): Promise<MultiSearchResponseOrSearchResponse<T1, T2>>;
/**
* Get a chat workspace instance
*
* @param workspace - The chat workspace UID
* @returns Instance of ChatWorkspace
*/
chat(workspace: string): ChatWorkspace;
/**
* Get all chat workspaces
*
* @returns Promise returning an array of chat workspaces UIDs
*/
getChatWorkspaces(): Promise<ResourceResults<{
uid: string;
}[]>>;
/**
* Get all webhooks
*
* @returns Promise returning an object with webhooks
*/
getWebhooks(): Promise<ResultsWrapper<Webhook[]>>;
/**
* Get a webhook
*
* @param uuid - Webhook UUID
* @returns Promise returning the webhook
*/
getWebhook(uuid: string): Promise<Webhook>;
/**
* Create a webhook
*
* @param webhook - Webhook to create
* @returns Promise returning the created webhook
*/
createWebhook(webhook: WebhookCreatePayload): Promise<Webhook>;
/**
* Update a webhook
*
* @param uuid - Webhook UUID
* @param webhook - Webhook to update
* @returns Promise returning the updated webhook
*/
updateWebhook(uuid: string, webhook: WebhookUpdatePayload): Promise<Webhook>;
/**
* Delete a webhook
*
* @param uuid - Webhook UUID
* @returns Promise returning void
*/
deleteWebhook(uuid: string): Promise<void>;
/**
* Get the current network configuration.
*
* {@link https://www.meilisearch.com/docs/reference/api/network#get-the-network-object}
*
* @experimental
*/
getNetwork(): Promise<Network>;
/**
* Initialize a network with sharding enabled. This sets up the current
* instance as the leader and configures the initial set of remotes.
*
* {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}
*
* @param options - Network initialization options
* @returns Promise returning the enqueued task
* @experimental
*/
initializeNetwork(options: InitializeNetworkOptions): EnqueuedTaskPromise;
/**
* Add a remote to the network. Must be called on the leader instance.
*
* {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}
*
* @param options - Options containing the remote name and configuration
* @returns Promise returning the enqueued task
* @experimental
*/
addRemote(options: AddRemoteOptions): EnqueuedTaskPromise;
/**
* Remove a remote from the network. Must be called on the leader instance.
*
* {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}
*
* @param options - Options containing the remote name to remove
* @returns Promise returning the enqueued task
* @experimental
*/
removeRemote(options: RemoveRemoteOptions): EnqueuedTaskPromise;
/**
* Add remotes to a shard. Must be called on the leader instance.
*
* {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}
*
* @param shardName - Name of the shard to update
* @param remotes - Remotes to add
* @returns Promise returning the enqueued task
* @experimental
*/
addRemotesToShard(shardName: string, remotes: string[]): EnqueuedTaskPromise;
/**
* Remove remotes from a shard. Must be called on the leader instance.
*
* {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}
*
* @param shardName - Name of the shard to update
* @param remotes - Remotes to remove
* @returns Promise returning the enqueued task
* @experimental
*/
removeRemotesFromShard(shardName: string, remotes: string[]): EnqueuedTaskPromise;
/**
* Get all API keys
*
* @param parameters - Parameters to browse the indexes
* @returns Promise returning an object with keys
*/
getKeys(parameters?: KeysQuery): Promise<KeysResults>;
/**
* Get one API key
*
* @param keyOrUid - Key or uid of the API key
* @returns Promise returning a key
*/
getKey(keyOrUid: string): Promise<Key>;
/**
* Create one API key
*
* @param options - Key options
* @returns Promise returning a key
*/
createKey(options: KeyCreation): Promise<Key>;
/**
* Update one API key
*
* @param keyOrUid - Key
* @param options - Key options
* @returns Promise returning a key
*/
updateKey(keyOrUid: string, options: KeyUpdate): Promise<Key>;
/**
* Delete one API key
*
* @param keyOrUid - Key
* @returns
*/
deleteKey(keyOrUid: string): Promise<void>;
/**
* Checks if the server is healthy, otherwise an error will be thrown.
*
* @returns Promise returning an object with health details
*/
health(): Promise<Health>;
/**
* Checks if the server is healthy, return true or false.
*
* @returns Promise returning a boolean
*/
isHealthy(): Promise<boolean>;
/**
* Get the stats of all the database
*
* @returns Promise returning object of all the stats
*/
getStats(): Promise<Stats>;
/**
* Get the version of Meilisearch
*
* @returns Promise returning object with version details
*/
getVersion(): Promise<Version>;
/**
* Creates a dump
*
* @returns Promise returning object of the enqueued task
*/
createDump(): EnqueuedTaskPromise;
/**
* Creates a snapshot
*
* @returns Promise returning object of the enqueued task
*/
createSnapshot(): EnqueuedTaskPromise;
/** {@link https://www.meilisearch.com/docs/reference/api/experimental_features#get-all-experimental-features} */
getExperimentalFeatures(): Promise<RuntimeTogglableFeatures>;
/** {@link https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features} */
updateExperimentalFeatures(runtimeTogglableFeatures: RuntimeTogglableFeatures): Promise<RuntimeTogglableFeatures>;
}
//# sourceMappingURL=meilisearch.d.ts.map