{"version":3,"sources":["jsdelivr-header.js","/npm/meilisearch@0.63.0/src/types/types.ts","/npm/meilisearch@0.63.0/src/errors/meilisearch-error.ts","/npm/meilisearch@0.63.0/src/errors/meilisearch-api-error.ts","/npm/meilisearch@0.63.0/src/errors/meilisearch-request-error.ts","/npm/meilisearch@0.63.0/src/errors/meilisearch-request-timeout-error.ts","/npm/meilisearch@0.63.0/src/errors/meilisearch-task-timeout-error.ts","/npm/meilisearch@0.63.0/src/utils.ts","/npm/meilisearch@0.63.0/src/http-requests.ts","/npm/meilisearch@0.63.0/src/task.ts","/npm/meilisearch@0.63.0/src/indexes.ts","/npm/meilisearch@0.63.0/src/batch.ts","/npm/meilisearch@0.63.0/src/chat-workspace.ts","/npm/meilisearch@0.63.0/src/meilisearch.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,AC4JA,IAAa,EAAqB,CAChC,IAAK,MACL,KAAM,OACN,UAAW,aAmWA,EAAyD,CACpE,KAAM,mBACN,IAAK,WACL,OAAQ,wBAufG,EAAkB,CAE7B,sBAAuB,wBAGvB,kBAAmB,oBAGnB,qBAAsB,uBAGtB,gBAAiB,kBAGjB,kBAAmB,oBAGnB,qBAAsB,uBAGtB,qBAAsB,uBAGtB,oBAAqB,sBAGrB,cAAe,gBAGf,6BAA8B,+BAG9B,iCAAkC,mCAGlC,0BAA2B,4BAG3B,+BAAgC,gCAGhC,oBAAqB,sBAGrB,oBAAqB,sBAGrB,qBAAsB,uBAGtB,qBAAsB,uBAGtB,wBAAyB,0BAGzB,uBAAwB,yBAGxB,wBAAyB,0BAGzB,wBAAyB,0BAGzB,wBAAyB,0BAGzB,+BAAgC,iCAGhC,kBAAmB,oBAGnB,gBAAiB,kBAGjB,kBAAmB,oBAGnB,wBAAyB,0BAGzB,mBAAoB,qBAGpB,sBAAuB,sBAGvB,gBAAiB,kBAGjB,2BAA4B,6BAG5B,iBAAkB,mBAGlB,sBAAuB,wBAGvB,qBAAsB,uBAGtB,oBAAq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D,CAWA,UAAA,GACE,OAAO,MAAK,EAAsB,KAAK,CACrC,KAAM,SAEV,CAWA,cAAA,GACE,OAAO,MAAK,EAAsB,KAAK,CACrC,KAAM,aAEV,CAkBA,oBAAM,CACJ,GAEA,aAAa,KAAK,YAAY,KAA6B,CACzD,KAAM,kBACN,KAAM,GAEV,CAOA,6BAAM,GACJ,aAAa,KAAK,YAAY,IAAI,CAChC,KAAM,yBAEV,CAGA,gCAAM,CACJ,GAEA,aAAa,KAAK,YAAY,MAAM,CAClC,KAAM,wBACN,KAAM,GAEV,U","file":"/npm/meilisearch@0.63.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/meilisearch@0.63.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// Type definitions for meilisearch\n// Project: https://github.com/meilisearch/meilisearch-js\n// Definitions by: qdequele <quentin@meilisearch.com> <https://github.com/meilisearch>\n// Definitions: https://github.com/meilisearch/meilisearch-js\n// TypeScript Version: ^5.8.2\n\nimport type { InlineRule, SearchMetadata } from \"./search-rules.js\";\nimport type { WaitOptions } from \"./task-and-batch.js\";\n\n// oxlint-disable-next-line no-explicit-any\nexport type RecordAny = Record<string, any>;\n\n/**\n * Shape of allowed record object that can be appended to a\n * {@link URLSearchParams}.\n */\nexport type URLSearchParamsRecord = Record<\n  string,\n  | string\n  | string[]\n  | (string | string[])[]\n  | number\n  | number[]\n  | boolean\n  | Date\n  | null\n  | undefined\n>;\n\n/**\n * {@link RequestInit} without {@link RequestInit.body} and\n * {@link RequestInit.method} properties.\n */\nexport type ExtraRequestInit = Omit<RequestInit, \"body\" | \"method\">;\n\n/** Same as {@link ExtraRequestInit} but without {@link ExtraRequestInit.signal}. */\nexport type BaseRequestInit = Omit<ExtraRequestInit, \"signal\">;\n\n/**\n * Same as {@link BaseRequestInit} but with its headers property forced as a\n * {@link Headers} object.\n */\nexport type HttpRequestsRequestInit = Omit<BaseRequestInit, \"headers\"> & {\n  headers: Headers;\n};\n\n/** Main configuration object for the meilisearch client. */\nexport type Config = {\n  /**\n   * The base URL for reaching a meilisearch instance.\n   *\n   * @remarks\n   * Protocol and trailing slash can be omitted.\n   */\n  host: string;\n  /**\n   * API key for interacting with a meilisearch instance.\n   *\n   * @see {@link https://www.meilisearch.com/docs/learn/security/basic_security}\n   */\n  apiKey?: string;\n  /**\n   * Custom strings that will be concatted to the \"X-Meilisearch-Client\" header\n   * on each request.\n   */\n  clientAgents?: string[];\n  /** Base request options that may override the default ones. */\n  requestInit?: BaseRequestInit;\n  /**\n   * Custom function that can be provided in place of {@link fetch}.\n   *\n   * @remarks\n   * API response errors will have to be handled manually with this as well.\n   * @deprecated This will be removed in a future version. See\n   *   {@link https://github.com/meilisearch/meilisearch-js/issues/1824 | issue}.\n   */\n  httpClient?: (...args: Parameters<typeof fetch>) => Promise<unknown>;\n  /** Timeout in milliseconds for each HTTP request. */\n  timeout?: number;\n  /** Customizable default options for awaiting tasks. */\n  defaultWaitOptions?: WaitOptions;\n};\n\n/** Main options of a request. */\nexport type MainRequestOptions = {\n  /** The path or subpath of the URL to make a request to. */\n  path: string;\n  /** The REST method of the request. */\n  method?: string;\n  /** The search parameters of the URL. */\n  params?: URLSearchParamsRecord;\n  /**\n   * {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type | Content-Type}\n   * passed to request {@link Headers}.\n   */\n  contentType?: string;\n  /**\n   * The body of the request.\n   *\n   * @remarks\n   * This only really supports string for now (any other type gets stringified)\n   * but it could support more in the future.\n   * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit#body}\n   */\n  body?: string | boolean | number | object | null;\n  /**\n   * An extra, more limited {@link RequestInit}, that may override some of the\n   * options.\n   */\n  extraRequestInit?: ExtraRequestInit;\n};\n\n/**\n * {@link MainRequestOptions} without {@link MainRequestOptions.method}, for\n * method functions.\n */\nexport type RequestOptions = Omit<MainRequestOptions, \"method\">;\n\n///\n/// Resources\n///\n\nexport type Pagination = {\n  offset?: number;\n  limit?: number;\n};\n\nexport type ResourceQuery = Pagination & {};\n\nexport type ResourceResults<T> = Pagination & {\n  results: T;\n  total: number;\n};\n\nexport type ResultsWrapper<T> = {\n  results: T;\n};\n\n///\n/// Indexes\n///\n\nexport type IndexOptions = {\n  primaryKey?: string;\n  uid?: string;\n};\n\nexport type IndexObject = {\n  uid: string;\n  primaryKey?: string;\n  createdAt: string;\n  updatedAt: string;\n};\n\nexport type IndexesQuery = ResourceQuery & {};\n\nexport type IndexesResults<T> = ResourceResults<T> & {};\n\n/*\n * SEARCH PARAMETERS\n */\n\nexport const MatchingStrategies = {\n  ALL: \"all\",\n  LAST: \"last\",\n  FREQUENCY: \"frequency\",\n} as const;\n\nexport type MatchingStrategies =\n  (typeof MatchingStrategies)[keyof typeof MatchingStrategies];\n\nexport type Filter = string | (string | string[])[];\n\nexport type Query = {\n  q?: string | null;\n};\n\nexport type Highlight = {\n  attributesToHighlight?: string[];\n  highlightPreTag?: string;\n  highlightPostTag?: string;\n};\n\nexport type Crop = {\n  attributesToCrop?: string[];\n  cropLength?: number;\n  cropMarker?: string;\n};\n\n// `facetName` becomes mandatory when using `searchForFacetValues`\nexport type SearchForFacetValuesParams = Omit<SearchParams, \"facetName\"> & {\n  facetName: string;\n  /**\n   * If true, the facet search will return the exhaustive count of the facet\n   * values.\n   */\n  exhaustiveFacetCount?: boolean;\n};\n\nexport type FacetHit = {\n  value: string;\n  count: number;\n};\n\nexport type SearchForFacetValuesResponse = {\n  facetHits: FacetHit[];\n  facetQuery: string | null;\n  processingTimeMs: number;\n};\n\nexport type HybridSearch = {\n  embedder: string;\n  semanticRatio?: number;\n};\n\nexport type Personalize = {\n  userContext: string;\n};\n\n/**\n * Search request media binary data with explicit MIME\n *\n * @example\n *\n * ```typescript\n * const media: MediaBinary = {\n *   mime: \"image/jpeg\",\n *   data: \"base64-encoded-data\",\n * };\n * ```\n */\nexport type MediaBinary = {\n  /** MIME type of the file */\n  mime: string;\n  /** Base64-encoded data of the file */\n  data: string;\n};\n\n/** Search request media payload with named search fragments */\nexport type MediaPayload = Record<string, Record<string, string | MediaBinary>>;\n\n// https://www.meilisearch.com/docs/reference/api/settings#localized-attributes\nexport type Locale = string;\n\nexport type SearchParams = Query &\n  Pagination &\n  Highlight &\n  Crop & {\n    filter?: Filter;\n    sort?: string[];\n    facets?: string[];\n    attributesToRetrieve?: string[];\n    showMatchesPosition?: boolean;\n    matchingStrategy?: MatchingStrategies;\n    hitsPerPage?: number;\n    page?: number;\n    facetName?: string;\n    facetQuery?: string;\n    vector?: number[] | null;\n    showRankingScore?: boolean;\n    showRankingScoreDetails?: boolean;\n    rankingScoreThreshold?: number;\n    attributesToSearchOn?: string[] | null;\n    hybrid?: HybridSearch;\n    distinct?: string;\n    retrieveVectors?: boolean;\n    locales?: Locale[];\n    media?: MediaPayload;\n    showPerformanceDetails?: boolean;\n    /**\n     * Personalize search results for a given user context.\n     *\n     * Experimental; requires Meilisearch v1.47 or later with the\n     * personalization feature enabled.\n     */\n    personalize?: Personalize;\n    /**\n     * Inline dynamic search rule applied only to this query\n     *\n     * @experimental\n     * @see {@link https://www.meilisearch.com/docs/reference/api/search/search-with-post}\n     */\n    inlineRule?: InlineRule | null;\n  };\n\n// Search parameters for searches made with the GET method\n// Are different than the parameters for the POST method\nexport type SearchRequestGET = Pagination &\n  Query &\n  Omit<Highlight, \"attributesToHighlight\"> &\n  Omit<Crop, \"attributesToCrop\"> & {\n    filter?: string;\n    sort?: string;\n    facets?: string;\n    attributesToRetrieve?: string;\n    attributesToHighlight?: string;\n    attributesToCrop?: string;\n    showMatchesPosition?: boolean;\n    vector?: string | null;\n    attributesToSearchOn?: string | null;\n    hybridEmbedder?: string;\n    hybridSemanticRatio?: number;\n    rankingScoreThreshold?: number;\n    distinct?: string;\n    retrieveVectors?: boolean;\n    locales?: Locale[];\n    showPerformanceDetails?: boolean;\n  };\n\nexport type MergeFacets = {\n  maxValuesPerFacet?: number | null;\n};\n\nexport type FederationOptions = { weight: number; remote?: string };\nexport type MultiSearchFederation = {\n  limit?: number;\n  offset?: number;\n  facetsByIndex?: Record<string, string[]>;\n  mergeFacets?: MergeFacets | null;\n  showPerformanceDetails?: boolean;\n  distinct?: string;\n};\n\nexport type MultiSearchQuery = SearchParams & { indexUid: string };\nexport type MultiSearchQueryWithFederation = MultiSearchQuery & {\n  federationOptions?: FederationOptions;\n};\n\nexport type MultiSearchParams = {\n  queries: MultiSearchQuery[];\n};\nexport type FederatedMultiSearchParams = {\n  federation: MultiSearchFederation;\n  queries: MultiSearchQueryWithFederation[];\n};\n\nexport type CategoriesDistribution = {\n  [category: string]: number;\n};\n\nexport type Facet = string;\nexport type FacetDistribution = Record<Facet, CategoriesDistribution>;\nexport type MatchesPosition<T> = Partial<\n  Record<keyof T, { start: number; length: number; indices?: number[] }[]>\n>;\n\nexport type RankingScoreDetails = {\n  words?: {\n    order: number;\n    matchingWords: number;\n    maxMatchingWords: number;\n    score: number;\n  };\n  typo?: {\n    order: number;\n    typoCount: number;\n    maxTypoCount: number;\n    score: number;\n  };\n  proximity?: {\n    order: number;\n    score: number;\n  };\n  attribute?: {\n    order: number;\n    attributes_ranking_order: number;\n    attributes_query_word_order: number;\n    score: number;\n  };\n  exactness?: {\n    order: number;\n    matchType: string;\n    score: number;\n  };\n  [key: string]: RecordAny | undefined;\n};\n\nexport type FederationDetails = {\n  indexUid: string;\n  queriesPosition: number;\n  weightedRankingScore: number;\n};\n\nexport type Hit<T = RecordAny> = T & {\n  _formatted?: Partial<T>;\n  _matchesPosition?: MatchesPosition<T>;\n  _rankingScore?: number;\n  _rankingScoreDetails?: RankingScoreDetails;\n  _federation?: FederationDetails;\n};\n\nexport type Hits<T = RecordAny> = Hit<T>[];\n\nexport type FacetStat = { min: number; max: number };\nexport type FacetStats = Record<string, FacetStat>;\n\nexport type FacetsByIndex = Record<\n  string,\n  {\n    distribution: FacetDistribution;\n    stats: FacetStats;\n  }\n>;\n\nexport type SearchResponse<\n  T = RecordAny,\n  S extends SearchParams | undefined = undefined,\n> = {\n  hits: Hits<T>;\n  processingTimeMs: number;\n  query: string;\n  facetDistribution?: FacetDistribution;\n  facetStats?: FacetStats;\n  facetsByIndex?: FacetsByIndex;\n  queryVector?: number[];\n  performanceDetails?: RecordAny;\n  /**\n   * Query and index metadata\n   *\n   * Present when the request sends `Meili-Include-Metadata: true`.\n   *\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/search/search-with-post}\n   */\n  metadata?: SearchMetadata;\n} & (undefined extends S\n  ? Partial<FinitePagination & InfinitePagination>\n  : true extends IsFinitePagination<NonNullable<S>>\n    ? FinitePagination\n    : InfinitePagination);\n\ntype FinitePagination = {\n  totalHits: number;\n  hitsPerPage: number;\n  page: number;\n  totalPages: number;\n};\ntype InfinitePagination = {\n  offset: number;\n  limit: number;\n  estimatedTotalHits: number;\n};\n\ntype IsFinitePagination<S extends SearchParams> = Or<\n  HasHitsPerPage<S>,\n  HasPage<S>\n>;\n\ntype Or<A extends boolean, B extends boolean> = true extends A\n  ? true\n  : true extends B\n    ? true\n    : false;\n\ntype HasHitsPerPage<S extends SearchParams> = undefined extends S[\"hitsPerPage\"]\n  ? false\n  : true;\n\ntype HasPage<S extends SearchParams> = undefined extends S[\"page\"]\n  ? false\n  : true;\n\nexport type MultiSearchResult<T> = SearchResponse<T> & { indexUid: string };\n\nexport type MultiSearchResponse<T = RecordAny> = {\n  results: MultiSearchResult<T>[];\n};\n\nexport type MultiSearchResponseOrSearchResponse<\n  T1 extends FederatedMultiSearchParams | MultiSearchParams,\n  T2 extends RecordAny = RecordAny,\n> = T1 extends FederatedMultiSearchParams\n  ? SearchResponse<T2>\n  : MultiSearchResponse<T2>;\n\nexport type FieldDistribution = {\n  [field: string]: number;\n};\n\nexport type SearchSimilarDocumentsParams = {\n  id: string | number;\n  offset?: number;\n  limit?: number;\n  filter?: Filter;\n  embedder?: string;\n  attributesToRetrieve?: string[];\n  showRankingScore?: boolean;\n  showRankingScoreDetails?: boolean;\n  rankingScoreThreshold?: number;\n  showPerformanceDetails?: boolean;\n};\n\n/*\n ** Documents\n */\n\ntype Fields<T = RecordAny> =\n  Extract<keyof T, string>[] | Extract<keyof T, string>;\n\n/** Options for task enqueue that apply to all document write operations. */\nexport type TaskEnqueueOptions = {\n  /**\n   * Arbitrary string attached to the enqueued task. Available on the task\n   * object via the `customMetadata` field.\n   *\n   * @see {@link https://www.meilisearch.com/docs/reference/api/async-task-management/get-task#response-custom-metadata-one-of-0}\n   */\n  customMetadata?: string;\n};\n\nexport type DocumentOptions = TaskEnqueueOptions & {\n  primaryKey?: string;\n  /**\n   * Skip document creation when the document does not already exist in the\n   * index. When `true`, only existing documents will be updated. @see\n   * https://www.meilisearch.com/docs/reference/api/documents/add-or-replace-documents\n   */\n  skipCreation?: boolean;\n};\n\nexport const ContentTypeEnum: Readonly<Record<string, ContentType>> = {\n  JSON: \"application/json\",\n  CSV: \"text/csv\",\n  NDJSON: \"application/x-ndjson\",\n};\n\nexport type ContentType =\n  \"text/csv\" | \"application/x-ndjson\" | \"application/json\";\n\nexport type RawDocumentAdditionOptions = DocumentOptions & {\n  csvDelimiter?: string;\n};\n\nexport type DocumentsQuery<T = RecordAny> = ResourceQuery & {\n  ids?: string[] | number[];\n  fields?: Fields<T>;\n  filter?: Filter;\n  limit?: number;\n  offset?: number;\n  retrieveVectors?: boolean;\n  /**\n   * Array of strings containing the attributes to sort on. Each string should\n   * be in the format \"attribute:direction\" where direction is either \"asc\" or\n   * \"desc\". Example: [\"price:asc\", \"rating:desc\"]\n   */\n  sort?: string[];\n};\n\nexport type DocumentQuery<T = RecordAny> = {\n  fields?: Fields<T>;\n};\n\nexport type DocumentsDeletionQuery = {\n  filter: Filter;\n};\n\nexport type DocumentsIds = string[] | number[];\n\nexport type UpdateDocumentsByFunctionOptions = {\n  function: string;\n  filter?: string | string[];\n  context?: RecordAny;\n};\n\n/*\n ** Settings\n */\n\nexport type GranularFilterableAttribute = {\n  attributePatterns: string[];\n  features: {\n    facetSearch: boolean;\n    filter: { equality: boolean; comparison: boolean };\n  };\n};\n\nexport type FilterableAttributes =\n  (string | GranularFilterableAttribute)[] | null;\nexport type DistinctAttribute = string | null;\nexport type SearchableAttributes = string[] | null;\nexport type SortableAttributes = string[] | null;\nexport type DisplayedAttributes = string[] | null;\nexport type RankingRules = string[] | null;\nexport type StopWords = string[] | null;\nexport type Synonyms = Record<string, string[]> | null;\nexport type TypoTolerance = {\n  enabled?: boolean | null;\n  disableOnAttributes?: string[] | null;\n  disableOnNumbers?: boolean | null;\n  disableOnWords?: string[] | null;\n  minWordSizeForTypos?: {\n    oneTypo?: number | null;\n    twoTypos?: number | null;\n  };\n} | null;\nexport type SeparatorTokens = string[] | null;\nexport type NonSeparatorTokens = string[] | null;\nexport type Dictionary = string[] | null;\nexport type ProximityPrecision = \"byWord\" | \"byAttribute\";\n\nexport type Distribution = {\n  mean: number;\n  sigma: number;\n};\n\nexport type OpenAiEmbedder = {\n  source: \"openAi\";\n  model?: string;\n  apiKey?: string;\n  documentTemplate?: string;\n  dimensions?: number;\n  distribution?: Distribution;\n  url?: string;\n  documentTemplateMaxBytes?: number;\n  binaryQuantized?: boolean;\n};\n\nexport type HuggingFaceEmbedder = {\n  source: \"huggingFace\";\n  model?: string;\n  revision?: string;\n  documentTemplate?: string;\n  distribution?: Distribution;\n  pooling?: \"useModel\" | \"forceMean\" | \"forceCls\";\n  documentTemplateMaxBytes?: number;\n  binaryQuantized?: boolean;\n};\n\nexport type UserProvidedEmbedder = {\n  source: \"userProvided\";\n  dimensions: number;\n  distribution?: Distribution;\n  binaryQuantized?: boolean;\n};\n\n/**\n * Indexing or search fragments\n *\n * @example\n *\n * ```typescript\n * const fragments: EmbedderFragments = {\n *   textAndPoster: {\n *     value: {\n *       content: [\n *         {\n *           type: \"text\",\n *           text: \"A movie titled {{doc.title}} whose description starts with {{doc.overview|truncatewords:20}}.\",\n *         },\n *         {\n *           type: \"image_url\",\n *           image_url: \"{{doc.poster}}\",\n *         },\n *       ],\n *     },\n *   },\n * };\n * ```\n */\nexport type EmbedderFragments = Record<string, { value: RecordAny }>;\n\nexport type RestEmbedder = {\n  source: \"rest\";\n  url: string;\n  apiKey?: string;\n  dimensions?: number;\n  documentTemplate?: string;\n  distribution?: Distribution;\n  request: RecordAny;\n  response: RecordAny;\n  headers?: Record<string, string>;\n  documentTemplateMaxBytes?: number;\n  binaryQuantized?: boolean;\n  indexingFragments?: EmbedderFragments;\n  searchFragments?: EmbedderFragments;\n};\n\nexport type OllamaEmbedder = {\n  source: \"ollama\";\n  url?: string;\n  apiKey?: string;\n  model?: string;\n  documentTemplate?: string;\n  distribution?: Distribution;\n  dimensions?: number;\n  documentTemplateMaxBytes?: number;\n  binaryQuantized?: boolean;\n};\n\nexport type CompositeEmbedder = {\n  source: \"composite\";\n  searchEmbedder: Embedder;\n  indexingEmbedder: Embedder;\n};\n\nexport type Embedder =\n  | OpenAiEmbedder\n  | HuggingFaceEmbedder\n  | UserProvidedEmbedder\n  | RestEmbedder\n  | OllamaEmbedder\n  | CompositeEmbedder\n  | null;\n\nexport type Embedders = Record<string, Embedder> | null;\n\n/** @see {@link https://www.meilisearch.com/docs/reference/api/settings/update-faceting} */\nexport type FacetOrder = \"alpha\" | \"count\" | \"sampledCount\";\n\nexport type Faceting = {\n  maxValuesPerFacet?: number | null;\n  /** Keys are facet attribute names, `\"*\"` is the fallback for all other facets */\n  sortFacetValuesBy?: Record<string, FacetOrder> | null;\n};\n\nexport type PaginationSettings = {\n  maxTotalHits?: number | null;\n};\n\nexport type SearchCutoffMs = number | null;\n\nexport type LocalizedAttribute = {\n  attributePatterns: string[];\n  locales: Locale[];\n};\n\nexport type LocalizedAttributes = LocalizedAttribute[] | null;\n\nexport type ForeignKey = {\n  foreignIndexUid: string;\n  fieldName: string;\n};\n\nexport type ForeignKeys = ForeignKey[] | null;\n\nexport type PrefixSearch = \"indexingTime\" | \"disabled\";\n\nexport type Settings = {\n  filterableAttributes?: FilterableAttributes;\n  distinctAttribute?: DistinctAttribute;\n  sortableAttributes?: SortableAttributes;\n  searchableAttributes?: SearchableAttributes;\n  displayedAttributes?: DisplayedAttributes;\n  rankingRules?: RankingRules;\n  stopWords?: StopWords;\n  synonyms?: Synonyms;\n  typoTolerance?: TypoTolerance;\n  faceting?: Faceting;\n  pagination?: PaginationSettings;\n  separatorTokens?: SeparatorTokens;\n  nonSeparatorTokens?: NonSeparatorTokens;\n  dictionary?: Dictionary;\n  proximityPrecision?: ProximityPrecision;\n  embedders?: Embedders;\n  searchCutoffMs?: SearchCutoffMs;\n  localizedAttributes?: LocalizedAttributes;\n  foreignKeys?: ForeignKeys;\n\n  /**\n   * Enable facet searching on all the filters of an index (requires Meilisearch\n   * 1.12.0 or later)\n   */\n  facetSearch?: boolean;\n  /**\n   * Enable the ability to search a word by prefix on an index (requires\n   * Meilisearch 1.12.0 or later)\n   */\n  prefixSearch?: \"indexingTime\" | \"disabled\";\n};\n\n/*\n *** HEALTH\n */\n\nexport type Health = {\n  status: \"available\";\n};\n\n/*\n *** STATS\n */\n\n/**\n * Query parameters for instance and index stats\n *\n * @see {@link https://www.meilisearch.com/docs/reference/api/stats/get-stats-of-all-indexes}\n * @see {@link https://www.meilisearch.com/docs/reference/api/indexes/get-stats-of-index}\n */\nexport type StatsQuery = {\n  /**\n   * Include {@link IndexStats.internalDatabaseSizes} on each index\n   *\n   * Database names can change between Meilisearch versions.\n   */\n  showInternalDatabaseSizes?: boolean;\n  /**\n   * Format of every size field in the response\n   *\n   * `\"raw\"` returns bytes as numbers. `\"human\"` returns strings with units,\n   * such as `\"19.64 MiB\"`.\n   *\n   * @defaultValue `raw`\n   */\n  sizeFormat?: \"human\" | \"raw\";\n};\n\ntype StatsQuerySizeFormat<Q> = Q extends StatsQuery\n  ? \"sizeFormat\" extends keyof Q\n    ? Q[\"sizeFormat\"]\n    : undefined\n  : undefined;\n\ntype StatsFieldSize<Q> = [StatsQuerySizeFormat<Q>] extends [\"human\"]\n  ? string\n  : [StatsQuerySizeFormat<Q>] extends [\"raw\" | undefined]\n    ? number\n    : string | number;\n\n/**\n * Stats of one index\n *\n * @typeParam Q - Stats query whose `sizeFormat` selects the size field type\n * @see {@link https://www.meilisearch.com/docs/reference/api/indexes/get-stats-of-index}\n */\nexport type IndexStats<Q extends StatsQuery | undefined = undefined> = {\n  /** Number of documents in the index */\n  numberOfDocuments: number;\n  /** Size of the index database */\n  indexSize: StatsFieldSize<Q>;\n  /** Size of the used pages of the index database */\n  usedIndexSize: StatsFieldSize<Q>;\n  /** Whether the index is currently indexing */\n  isIndexing: boolean;\n  /** Number of documents containing each field */\n  fieldDistribution: FieldDistribution;\n  /** Number of documents that contain embeddings */\n  numberOfEmbeddedDocuments: number;\n  /** Number of embeddings in the index */\n  numberOfEmbeddings: number;\n  /** Size of the documents database */\n  rawDocumentDbSize: StatsFieldSize<Q>;\n  /** Average size of a document in the documents database */\n  avgDocumentSize: StatsFieldSize<Q>;\n  /**\n   * On-disk size of each internal database\n   *\n   * Present when {@link StatsQuery.showInternalDatabaseSizes} is `true`. Keys\n   * can change between Meilisearch versions. Values use `sizeFormat`.\n   */\n  internalDatabaseSizes?: Record<string, StatsFieldSize<Q>>;\n};\n\n/**\n * Stats of the instance and each index\n *\n * @typeParam Q - Stats query whose `sizeFormat` selects the size field type\n * @see {@link https://www.meilisearch.com/docs/reference/api/stats/get-stats-of-all-indexes}\n */\nexport type Stats<Q extends StatsQuery | undefined = undefined> = {\n  /** Total disk space used by the database */\n  databaseSize: StatsFieldSize<Q>;\n  /** Actual size of the data in the database */\n  usedDatabaseSize: StatsFieldSize<Q>;\n  /** Date of the last update, in RFC 3339 */\n  lastUpdate: string;\n  /** Stats for each index, keyed by index UID */\n  indexes: {\n    [index: string]: IndexStats<Q>;\n  };\n};\n\n/*\n ** CHATS\n */\n\n/** A chat workspace registered on the instance. */\nexport type ChatWorkspaceObject = { uid: string };\n\n/** Parameters used to paginate the list of chat workspaces. */\nexport type ChatWorkspacesQuery = ResourceQuery & {};\n\n/** Paginated list of chat workspaces. */\nexport type ChatWorkspacesResults = ResourceResults<ChatWorkspaceObject[]> & {};\n\n/** @see https://www.meilisearch.com/docs/reference/api/chats#settings-parameters */\nexport type ChatWorkspaceSettings = {\n  source: \"openAi\" | \"azureOpenAi\" | \"mistral\" | \"gemini\" | \"vLlm\";\n  orgId?: string;\n  projectId?: string;\n  apiVersion?: string;\n  deploymentId?: string;\n  baseUrl?: string;\n  apiKey: string;\n  prompts: {\n    system: string;\n  };\n};\n\nexport type ChatCompletionRequest = {\n  model: string;\n  messages: {\n    role: \"user\" | \"assistant\" | \"system\";\n    content: string;\n  }[];\n  stream: boolean;\n};\n\nexport type ChatSettings = {\n  description: string;\n  documentTemplate: string;\n  documentTemplateMaxBytes: number;\n  searchParameters: SearchParams;\n};\n\nexport type ChatSettingsPayload = {\n  description?: string;\n  documentTemplate?: string;\n  documentTemplateMaxBytes?: number;\n  searchParameters?: Partial<SearchParams>;\n};\n\n/*\n ** RENDER TEMPLATE\n */\n\n/**\n * Template/fragment or input to render. The `kind` field discriminates the\n * source; the remaining fields depend on that kind (kept open via `RecordAny`\n * since this route is experimental and its payload shape may change).\n *\n * @see {@link https://www.meilisearch.com/docs/reference/api/template/render-documents-with-post}\n */\nexport type RenderTemplateSource = {\n  kind:\n    | \"documentTemplate\"\n    | \"indexDocument\"\n    | \"inlineDocumentTemplate\"\n    | \"inlineDocument\"\n    | \"inlineFragment\"\n    | \"searchFragment\"\n    | \"inlineSearch\"\n    | \"chatDocumentTemplate\";\n} & RecordAny;\n\n/** @see {@link https://www.meilisearch.com/docs/reference/api/template/render-documents-with-post} */\nexport type RenderTemplateParams = {\n  /** Template/fragment to fetch for rendering. */\n  template: RenderTemplateSource;\n  /**\n   * Input injected into the template to render the final string/JSON object. If\n   * `null` or missing, the template is not rendered.\n   */\n  input?: RenderTemplateSource | null;\n};\n\n/** @see {@link https://www.meilisearch.com/docs/reference/api/template/render-documents-with-post} */\nexport type RenderTemplateResponse = {\n  /**\n   * Unrendered template or fragment, fetched in index or echoed back from the\n   * inline template in the request.\n   */\n  template: unknown;\n  /**\n   * Result of rendering the template by injecting the `input`. `null` if\n   * `input` was `null` or missing in the request.\n   */\n  rendered?: unknown;\n};\n\n/*\n ** Keys\n */\n\nexport type Key = {\n  uid: string;\n  description: string;\n  name: string | null;\n  key: string;\n  actions: string[];\n  indexes: string[];\n  expiresAt: Date;\n  createdAt: Date;\n  updatedAt: Date;\n};\n\nexport type KeyCreation = {\n  uid?: string;\n  name?: string;\n  description?: string;\n  actions: string[];\n  indexes: string[];\n  expiresAt: Date | null;\n};\n\nexport type KeyUpdate = {\n  name?: string;\n  description?: string;\n};\n\nexport type KeysQuery = ResourceQuery & {};\n\nexport type KeysResults = ResourceResults<Key[]> & {};\n\n/*\n ** version\n */\nexport type Version = {\n  commitSha: string;\n  commitDate: string;\n  pkgVersion: string;\n};\n\n/*\n ** ERROR HANDLER\n */\n\nexport type MeilisearchErrorResponse = {\n  message: string;\n  // https://www.meilisearch.com/docs/reference/errors/error_codes\n  code: string;\n  // https://www.meilisearch.com/docs/reference/errors/overview#errors\n  type: string;\n  link: string;\n};\n\n// @TODO: This doesn't seem to be up to date, and its usefulness comes into question.\nexport const ErrorStatusCode = {\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_creation_failed */\n  INDEX_CREATION_FAILED: \"index_creation_failed\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_index_uid */\n  MISSING_INDEX_UID: \"missing_index_uid\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_already_exists */\n  INDEX_ALREADY_EXISTS: \"index_already_exists\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_not_found */\n  INDEX_NOT_FOUND: \"index_not_found\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_index_uid */\n  INVALID_INDEX_UID: \"invalid_index_uid\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_not_accessible */\n  INDEX_NOT_ACCESSIBLE: \"index_not_accessible\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_index_offset */\n  INVALID_INDEX_OFFSET: \"invalid_index_offset\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_index_limit */\n  INVALID_INDEX_LIMIT: \"invalid_index_limit\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_state */\n  INVALID_STATE: \"invalid_state\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#primary_key_inference_failed */\n  PRIMARY_KEY_INFERENCE_FAILED: \"primary_key_inference_failed\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_primary_key_already_exists */\n  INDEX_PRIMARY_KEY_ALREADY_EXISTS: \"index_primary_key_already_exists\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_index_primary_key */\n  INVALID_INDEX_PRIMARY_KEY: \"invalid_index_primary_key\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#max_fields_limit_exceeded */\n  DOCUMENTS_FIELDS_LIMIT_REACHED: \"document_fields_limit_reached\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_document_id */\n  MISSING_DOCUMENT_ID: \"missing_document_id\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_document_id */\n  INVALID_DOCUMENT_ID: \"invalid_document_id\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_content_type */\n  INVALID_CONTENT_TYPE: \"invalid_content_type\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_content_type */\n  MISSING_CONTENT_TYPE: \"missing_content_type\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_fields */\n  INVALID_DOCUMENT_FIELDS: \"invalid_document_fields\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_limit */\n  INVALID_DOCUMENT_LIMIT: \"invalid_document_limit\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_offset */\n  INVALID_DOCUMENT_OFFSET: \"invalid_document_offset\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_filter */\n  INVALID_DOCUMENT_FILTER: \"invalid_document_filter\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_document_filter */\n  MISSING_DOCUMENT_FILTER: \"missing_document_filter\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_vectors_field */\n  INVALID_DOCUMENT_VECTORS_FIELD: \"invalid_document_vectors_field\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#payload_too_large */\n  PAYLOAD_TOO_LARGE: \"payload_too_large\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_payload */\n  MISSING_PAYLOAD: \"missing_payload\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#malformed_payload */\n  MALFORMED_PAYLOAD: \"malformed_payload\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#no_space_left_on_device */\n  NO_SPACE_LEFT_ON_DEVICE: \"no_space_left_on_device\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_store_file */\n  INVALID_STORE_FILE: \"invalid_store_file\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_ranking_rules */\n  INVALID_RANKING_RULES: \"missing_document_id\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_request */\n  INVALID_REQUEST: \"invalid_request\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_geo_field */\n  INVALID_DOCUMENT_GEO_FIELD: \"invalid_document_geo_field\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_q */\n  INVALID_SEARCH_Q: \"invalid_search_q\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_offset */\n  INVALID_SEARCH_OFFSET: \"invalid_search_offset\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_limit */\n  INVALID_SEARCH_LIMIT: \"invalid_search_limit\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_page */\n  INVALID_SEARCH_PAGE: \"invalid_search_page\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_hits_per_page */\n  INVALID_SEARCH_HITS_PER_PAGE: \"invalid_search_hits_per_page\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_retrieve */\n  INVALID_SEARCH_ATTRIBUTES_TO_RETRIEVE:\n    \"invalid_search_attributes_to_retrieve\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_crop */\n  INVALID_SEARCH_ATTRIBUTES_TO_CROP: \"invalid_search_attributes_to_crop\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_crop_length */\n  INVALID_SEARCH_CROP_LENGTH: \"invalid_search_crop_length\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_highlight */\n  INVALID_SEARCH_ATTRIBUTES_TO_HIGHLIGHT:\n    \"invalid_search_attributes_to_highlight\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_show_matches_position */\n  INVALID_SEARCH_SHOW_MATCHES_POSITION: \"invalid_search_show_matches_position\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_filter */\n  INVALID_SEARCH_FILTER: \"invalid_search_filter\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_sort */\n  INVALID_SEARCH_SORT: \"invalid_search_sort\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_facets */\n  INVALID_SEARCH_FACETS: \"invalid_search_facets\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_highlight_pre_tag */\n  INVALID_SEARCH_HIGHLIGHT_PRE_TAG: \"invalid_search_highlight_pre_tag\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_highlight_post_tag */\n  INVALID_SEARCH_HIGHLIGHT_POST_TAG: \"invalid_search_highlight_post_tag\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_crop_marker */\n  INVALID_SEARCH_CROP_MARKER: \"invalid_search_crop_marker\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_matching_strategy */\n  INVALID_SEARCH_MATCHING_STRATEGY: \"invalid_search_matching_strategy\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_vector */\n  INVALID_SEARCH_VECTOR: \"invalid_search_vector\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_search_on */\n  INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON:\n    \"invalid_search_attributes_to_search_on\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#bad_request */\n  BAD_REQUEST: \"bad_request\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#document_not_found */\n  DOCUMENT_NOT_FOUND: \"document_not_found\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#internal */\n  INTERNAL: \"internal\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key */\n  INVALID_API_KEY: \"invalid_api_key\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_description */\n  INVALID_API_KEY_DESCRIPTION: \"invalid_api_key_description\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_actions */\n  INVALID_API_KEY_ACTIONS: \"invalid_api_key_actions\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_indexes */\n  INVALID_API_KEY_INDEXES: \"invalid_api_key_indexes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_expires_at */\n  INVALID_API_KEY_EXPIRES_AT: \"invalid_api_key_expires_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#api_key_not_found */\n  API_KEY_NOT_FOUND: \"api_key_not_found\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_uid */\n  IMMUTABLE_API_KEY_UID: \"immutable_api_key_uid\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_actions */\n  IMMUTABLE_API_KEY_ACTIONS: \"immutable_api_key_actions\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_indexes */\n  IMMUTABLE_API_KEY_INDEXES: \"immutable_api_key_indexes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_expires_at */\n  IMMUTABLE_API_KEY_EXPIRES_AT: \"immutable_api_key_expires_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_created_at */\n  IMMUTABLE_API_KEY_CREATED_AT: \"immutable_api_key_created_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_updated_at */\n  IMMUTABLE_API_KEY_UPDATED_AT: \"immutable_api_key_updated_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_authorization_header */\n  MISSING_AUTHORIZATION_HEADER: \"missing_authorization_header\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#unretrievable_document */\n  UNRETRIEVABLE_DOCUMENT: \"unretrievable_document\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#database_size_limit_reached */\n  MAX_DATABASE_SIZE_LIMIT_REACHED: \"database_size_limit_reached\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#task_not_found */\n  TASK_NOT_FOUND: \"task_not_found\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#dump_process_failed */\n  DUMP_PROCESS_FAILED: \"dump_process_failed\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#dump_not_found */\n  DUMP_NOT_FOUND: \"dump_not_found\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_swap_duplicate_index_found */\n  INVALID_SWAP_DUPLICATE_INDEX_FOUND: \"invalid_swap_duplicate_index_found\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_swap_indexes */\n  INVALID_SWAP_INDEXES: \"invalid_swap_indexes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_swap_indexes */\n  MISSING_SWAP_INDEXES: \"missing_swap_indexes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_master_key */\n  MISSING_MASTER_KEY: \"missing_master_key\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_types */\n  INVALID_TASK_TYPES: \"invalid_task_types\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_uids */\n  INVALID_TASK_UIDS: \"invalid_task_uids\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_statuses */\n  INVALID_TASK_STATUSES: \"invalid_task_statuses\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_limit */\n  INVALID_TASK_LIMIT: \"invalid_task_limit\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_from */\n  INVALID_TASK_FROM: \"invalid_task_from\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_canceled_by */\n  INVALID_TASK_CANCELED_BY: \"invalid_task_canceled_by\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_task_filters */\n  MISSING_TASK_FILTERS: \"missing_task_filters\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#too_many_open_files */\n  TOO_MANY_OPEN_FILES: \"too_many_open_files\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#io_error */\n  IO_ERROR: \"io_error\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_index_uids */\n  INVALID_TASK_INDEX_UIDS: \"invalid_task_index_uids\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_index_uid */\n  IMMUTABLE_INDEX_UID: \"immutable_index_uid\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_index_created_at */\n  IMMUTABLE_INDEX_CREATED_AT: \"immutable_index_created_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_index_updated_at */\n  IMMUTABLE_INDEX_UPDATED_AT: \"immutable_index_updated_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_displayed_attributes */\n  INVALID_SETTINGS_DISPLAYED_ATTRIBUTES:\n    \"invalid_settings_displayed_attributes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_searchable_attributes */\n  INVALID_SETTINGS_SEARCHABLE_ATTRIBUTES:\n    \"invalid_settings_searchable_attributes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_filterable_attributes */\n  INVALID_SETTINGS_FILTERABLE_ATTRIBUTES:\n    \"invalid_settings_filterable_attributes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_sortable_attributes */\n  INVALID_SETTINGS_SORTABLE_ATTRIBUTES: \"invalid_settings_sortable_attributes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_ranking_rules */\n  INVALID_SETTINGS_RANKING_RULES: \"invalid_settings_ranking_rules\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_stop_words */\n  INVALID_SETTINGS_STOP_WORDS: \"invalid_settings_stop_words\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_synonyms */\n  INVALID_SETTINGS_SYNONYMS: \"invalid_settings_synonyms\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_distinct_attribute */\n  INVALID_SETTINGS_DISTINCT_ATTRIBUTE: \"invalid_settings_distinct_attribute\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_typo_tolerance */\n  INVALID_SETTINGS_TYPO_TOLERANCE: \"invalid_settings_typo_tolerance\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_faceting */\n  INVALID_SETTINGS_FACETING: \"invalid_settings_faceting\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_pagination */\n  INVALID_SETTINGS_PAGINATION: \"invalid_settings_pagination\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_search_cutoff_ms */\n  INVALID_SETTINGS_SEARCH_CUTOFF_MS: \"invalid_settings_search_cutoff_ms\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_search_cutoff_ms */\n  INVALID_SETTINGS_LOCALIZED_ATTRIBUTES:\n    \"invalid_settings_localized_attributes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_before_enqueued_at */\n  INVALID_TASK_BEFORE_ENQUEUED_AT: \"invalid_task_before_enqueued_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_after_enqueued_at */\n  INVALID_TASK_AFTER_ENQUEUED_AT: \"invalid_task_after_enqueued_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_before_started_at */\n  INVALID_TASK_BEFORE_STARTED_AT: \"invalid_task_before_started_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_after_started_at */\n  INVALID_TASK_AFTER_STARTED_AT: \"invalid_task_after_started_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_before_finished_at */\n  INVALID_TASK_BEFORE_FINISHED_AT: \"invalid_task_before_finished_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_after_finished_at */\n  INVALID_TASK_AFTER_FINISHED_AT: \"invalid_task_after_finished_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_api_key_actions */\n  MISSING_API_KEY_ACTIONS: \"missing_api_key_actions\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_api_key_indexes */\n  MISSING_API_KEY_INDEXES: \"missing_api_key_indexes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_api_key_expires_at */\n  MISSING_API_KEY_EXPIRES_AT: \"missing_api_key_expires_at\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_limit */\n  INVALID_API_KEY_LIMIT: \"invalid_api_key_limit\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_offset */\n  INVALID_API_KEY_OFFSET: \"invalid_api_key_offset\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_facet_name */\n  INVALID_FACET_SEARCH_FACET_NAME: \"invalid_facet_search_facet_name\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_facet_search_facet_name */\n  MISSING_FACET_SEARCH_FACET_NAME: \"missing_facet_search_facet_name\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_facet_query */\n  INVALID_FACET_SEARCH_FACET_QUERY: \"invalid_facet_search_facet_query\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_ranking_score_threshold */\n  INVALID_SEARCH_RANKING_SCORE_THRESHOLD:\n    \"invalid_search_ranking_score_threshold\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_similar_ranking_score_threshold */\n  INVALID_SIMILAR_RANKING_SCORE_THRESHOLD:\n    \"invalid_similar_ranking_score_threshold\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#not_leader */\n  NOT_LEADER: \"not_leader\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_network_leader */\n  INVALID_NETWORK_LEADER: \"invalid_network_leader\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_network_remotes */\n  INVALID_NETWORK_REMOTES: \"invalid_network_remotes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_network_search_api_key */\n  INVALID_NETWORK_SEARCH_API_KEY: \"invalid_network_search_api_key\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_network_self */\n  INVALID_NETWORK_SELF: \"invalid_network_self\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_network_shards */\n  INVALID_NETWORK_SHARDS: \"invalid_network_shards\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_network_url */\n  MISSING_NETWORK_URL: \"missing_network_url\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_network_url */\n  INVALID_NETWORK_URL: \"invalid_network_url\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_network_write_api_key */\n  INVALID_NETWORK_WRITE_API_KEY: \"invalid_network_write_api_key\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#network_version_mismatch */\n  NETWORK_VERSION_MISMATCH: \"network_version_mismatch\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#network_version_too_old */\n  NETWORK_VERSION_TOO_OLD: \"network_version_too_old\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#unknown_remote */\n  UNKNOWN_REMOTE: \"unknown_remote\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#unprocessed_network_task */\n  UNPROCESSED_NETWORK_TASK: \"unprocessed_network_task\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#unexpected_network_previous_remotes */\n  UNEXPECTED_NETWORK_PREVIOUS_REMOTES: \"unexpected_network_previous_remotes\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#import_task_already_received */\n  IMPORT_TASK_ALREADY_RECEIVED: \"import_task_already_received\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#import_task_unknown_remote */\n  IMPORT_TASK_UNKNOWN_REMOTE: \"import_task_unknown_remote\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#import_task_without_network_task */\n  IMPORT_TASK_WITHOUT_NETWORK_TASK: \"import_task_without_network_task\",\n\n  /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#receive_import_finished_unknown_remote */\n  RECEIVE_IMPORT_FINISHED_UNKNOWN_REMOTE:\n    \"receive_import_finished_unknown_remote\",\n};\n\nexport type ErrorStatusCode =\n  (typeof ErrorStatusCode)[keyof typeof ErrorStatusCode];\n","export class MeilisearchError extends Error {\n  override name = \"MeilisearchError\";\n}\n","import type { MeilisearchErrorResponse } from \"../types/index.js\";\nimport { MeilisearchError } from \"./meilisearch-error.js\";\n\nexport class MeilisearchApiError extends MeilisearchError {\n  override name = \"MeilisearchApiError\";\n  override cause?: MeilisearchErrorResponse;\n  readonly response: Response;\n\n  constructor(response: Response, responseBody?: MeilisearchErrorResponse) {\n    super(\n      responseBody?.message ?? `${response.status}: ${response.statusText}`,\n    );\n\n    this.response = response;\n\n    if (responseBody !== undefined) {\n      this.cause = responseBody;\n    }\n  }\n}\n","import { MeilisearchError } from \"./meilisearch-error.js\";\n\nexport class MeilisearchRequestError extends MeilisearchError {\n  override name = \"MeilisearchRequestError\";\n\n  constructor(url: string, cause: unknown) {\n    super(`Request to ${url} has failed`, { cause });\n  }\n}\n","import { MeilisearchError } from \"./meilisearch-error.js\";\n\n/** Error thrown when a HTTP request times out. */\nexport class MeilisearchRequestTimeOutError extends MeilisearchError {\n  override name = \"MeilisearchRequestTimeOutError\";\n  override cause: { timeout: number; requestInit: RequestInit };\n\n  /**\n   * Builds a timeout error whose `cause` keeps the request details for\n   * debugging but with the `Authorization` header redacted, so the API key\n   * never leaks into logs or error trackers.\n   */\n  constructor(timeout: number, requestInit: RequestInit) {\n    super(`request timed out after ${timeout}ms`);\n\n    // Never expose credentials: the init headers carry the\n    // `Authorization: Bearer <apiKey>` header, which would otherwise leak\n    // into logs and error trackers via `error.cause`.\n    const headers = new Headers(requestInit.headers);\n    if (headers.has(\"Authorization\")) {\n      headers.set(\"Authorization\", \"<redacted>\");\n    }\n\n    this.cause = { timeout, requestInit: { ...requestInit, headers } };\n  }\n}\n","import { MeilisearchError } from \"./meilisearch-error.js\";\n\n/** Error thrown when a waiting for a task times out. */\nexport class MeilisearchTaskTimeOutError extends MeilisearchError {\n  override name = \"MeilisearchTaskTimeOutError\";\n  override cause: { taskUid: number; timeout: number };\n\n  constructor(taskUid: number, timeout: number) {\n    super(\n      `timeout of ${timeout}ms has exceeded on task ${taskUid} when waiting for it to be resolved.`,\n    );\n\n    this.cause = { taskUid, timeout };\n  }\n}\n","import type { RecordAny } from \"./types/index.js\";\n\nasync function sleep(ms: number): Promise<void> {\n  return await new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction addProtocolIfNotPresent(host: string): string {\n  if (!(host.startsWith(\"https://\") || host.startsWith(\"http://\"))) {\n    return `http://${host}`;\n  }\n  return host;\n}\n\nfunction addTrailingSlash(url: string): string {\n  if (!url.endsWith(\"/\")) {\n    url += \"/\";\n  }\n  return url;\n}\n\n/** Reads a byte stream to completion and decodes it as UTF-8 text. */\nasync function readStreamAsText(\n  stream: ReadableStream<Uint8Array>,\n): Promise<string> {\n  const reader = stream.getReader();\n  const decoder = new TextDecoder();\n  let text = \"\";\n\n  for (;;) {\n    const { done, value } = await reader.read();\n\n    if (done) {\n      break;\n    }\n\n    text += decoder.decode(value, { stream: true });\n  }\n\n  text += decoder.decode();\n\n  return text;\n}\n\n/**\n * Parses task document payloads returned by `tasks/{uid}/documents`.\n *\n * @remarks\n * The endpoint may return either valid JSON (single object or array), NDJSON,\n * or concatenated JSON objects without separators. This parser normalizes all\n * of these formats into a regular document array.\n */\nfunction parseTaskDocuments<D extends RecordAny = RecordAny>(\n  rawDocuments: string,\n): D[] {\n  const payload = rawDocuments.trim();\n\n  if (!payload) {\n    return [];\n  }\n\n  try {\n    const parsed = JSON.parse(payload) as D | D[];\n    return Array.isArray(parsed) ? parsed : [parsed];\n  } catch {\n    return payload\n      .split(/\\r?\\n/)\n      .flatMap((line) => line.split(/(?<=})\\s*(?=\\{)/))\n      .map((chunk) => chunk.trim())\n      .filter((chunk) => chunk.length > 0)\n      .map((chunk) => JSON.parse(chunk) as D);\n  }\n}\n\nexport {\n  sleep,\n  addProtocolIfNotPresent,\n  addTrailingSlash,\n  readStreamAsText,\n  parseTaskDocuments,\n};\n","import type {\n  Config,\n  HttpRequestsRequestInit,\n  RequestOptions,\n  MainRequestOptions,\n  URLSearchParamsRecord,\n  MeilisearchErrorResponse,\n} from \"./types/index.js\";\nimport pkg from \"../package.json\" with { type: \"json\" };\nimport {\n  MeilisearchError,\n  MeilisearchApiError,\n  MeilisearchRequestError,\n  MeilisearchRequestTimeOutError,\n} from \"./errors/index.js\";\nimport { addProtocolIfNotPresent, addTrailingSlash } from \"./utils.js\";\n\n/** Append a set of key value pairs to a {@link URLSearchParams} object. */\nfunction appendRecordToURLSearchParams(\n  searchParams: URLSearchParams,\n  recordToAppend: URLSearchParamsRecord,\n): void {\n  for (const [key, val] of Object.entries(recordToAppend)) {\n    if (val != null) {\n      searchParams.set(\n        key,\n        Array.isArray(val)\n          ? val.join()\n          : val instanceof Date\n            ? val.toISOString()\n            : String(val),\n      );\n    }\n  }\n}\n\n/**\n * Creates a new Headers object from a {@link HeadersInit} and adds various\n * properties to it, some from {@link Config}.\n *\n * @returns A new Headers object\n */\nfunction getHeaders(config: Config, headersInit?: HeadersInit): Headers {\n  const agentHeader = \"X-Meilisearch-Client\";\n  const packageAgent = `Meilisearch JavaScript (v${pkg.version})`;\n  const contentType = \"Content-Type\";\n  const authorization = \"Authorization\";\n\n  const headers = new Headers(headersInit);\n\n  // do not override if user provided the header\n  if (config.apiKey && !headers.has(authorization)) {\n    headers.set(authorization, `Bearer ${config.apiKey}`);\n  }\n\n  if (!headers.has(contentType)) {\n    headers.set(contentType, \"application/json\");\n  }\n\n  // Creates the custom user agent with information on the package used.\n  if (config.clientAgents !== undefined) {\n    const clients = config.clientAgents.concat(packageAgent);\n\n    headers.set(agentHeader, clients.join(\" ; \"));\n  } else {\n    headers.set(agentHeader, packageAgent);\n  }\n\n  return headers;\n}\n\n/** Used to identify whether an error is a timeout error after fetch request. */\nconst TIMEOUT_ID = Symbol(\"<timeout>\");\n\n/** Parses a response body as JSON, returning `undefined` when the body is empty. */\nfunction parseResponseBody<T>(responseBody: string): T | undefined {\n  if (responseBody === \"\") {\n    return undefined;\n  }\n\n  return JSON.parse(responseBody) as T;\n}\n\n/**\n * Attach a timeout signal to a {@link RequestInit}, while preserving original\n * signal functionality, if there is one.\n *\n * @remarks\n * This could be a short few straight forward lines using {@link AbortSignal.any}\n * and {@link AbortSignal.timeout}, but these aren't yet widely supported enough,\n * nor polyfill -able, at the time of writing.\n * @returns A new function which starts the timeout, which then returns another\n *   function that clears the timeout\n */\nfunction getTimeoutFn(\n  requestInit: RequestInit,\n  ms: number,\n): () => (() => void) | void {\n  const { signal } = requestInit;\n  const ac = new AbortController();\n\n  if (signal != null) {\n    let acSignalFn: (() => void) | null = null;\n\n    if (signal.aborted) {\n      ac.abort(signal.reason);\n    } else {\n      const fn = () => ac.abort(signal.reason);\n\n      signal.addEventListener(\"abort\", fn, { once: true });\n\n      acSignalFn = () => signal.removeEventListener(\"abort\", fn);\n      ac.signal.addEventListener(\"abort\", acSignalFn, { once: true });\n    }\n\n    return () => {\n      if (signal.aborted) {\n        return;\n      }\n\n      const to = setTimeout(() => ac.abort(TIMEOUT_ID), ms);\n      const fn = () => {\n        clearTimeout(to);\n\n        if (acSignalFn !== null) {\n          ac.signal.removeEventListener(\"abort\", acSignalFn);\n        }\n      };\n\n      signal.addEventListener(\"abort\", fn, { once: true });\n\n      return () => {\n        signal.removeEventListener(\"abort\", fn);\n        fn();\n      };\n    };\n  }\n\n  requestInit.signal = ac.signal;\n\n  return () => {\n    const to = setTimeout(() => ac.abort(TIMEOUT_ID), ms);\n    return () => clearTimeout(to);\n  };\n}\n\n/** Class used to perform HTTP requests. */\nexport class HttpRequests {\n  #url: URL;\n  #requestInit: HttpRequestsRequestInit;\n  #customRequestFn?: Config[\"httpClient\"];\n  #requestTimeout?: Config[\"timeout\"];\n\n  constructor(config: Config) {\n    const host = addTrailingSlash(addProtocolIfNotPresent(config.host));\n\n    try {\n      this.#url = new URL(host);\n    } catch (error) {\n      throw new MeilisearchError(\"The provided host is not valid\", {\n        cause: error,\n      });\n    }\n\n    this.#requestInit = {\n      ...config.requestInit,\n      headers: getHeaders(config, config.requestInit?.headers),\n    };\n\n    this.#customRequestFn = config.httpClient;\n    this.#requestTimeout = config.timeout;\n  }\n\n  /**\n   * Combines provided extra {@link RequestInit} headers, provided content type\n   * and class instance RequestInit headers, prioritizing them in this order.\n   *\n   * @returns A new Headers object or the main headers of this class if no\n   *   headers are provided\n   */\n  #getHeaders(extraHeaders?: HeadersInit, contentType?: string): Headers {\n    if (extraHeaders === undefined && contentType === undefined) {\n      return this.#requestInit.headers;\n    }\n\n    const headers = new Headers(extraHeaders);\n\n    if (contentType !== undefined && !headers.has(\"Content-Type\")) {\n      headers.set(\"Content-Type\", contentType);\n    }\n\n    for (const [key, val] of this.#requestInit.headers) {\n      if (!headers.has(key)) {\n        headers.set(key, val);\n      }\n    }\n\n    return headers;\n  }\n\n  /**\n   * Prepares common request parameters (URL and RequestInit).\n   *\n   * @returns Object containing the prepared URL and RequestInit\n   */\n  #prepareRequest({\n    path,\n    method,\n    params,\n    contentType,\n    body,\n    extraRequestInit,\n  }: MainRequestOptions): { url: URL; init: RequestInit } {\n    // An empty, \".\" or \"..\" segment would resolve to another route\n    if (\n      path\n        .split(\"/\")\n        .some(\n          (segment) => segment === \"\" || segment === \".\" || segment === \"..\",\n        )\n    ) {\n      throw new MeilisearchError(\n        `The request path \"${path}\" contains an empty, \".\" or \"..\" segment`,\n      );\n    }\n\n    const url = new URL(path, this.#url);\n    if (params !== undefined) {\n      appendRecordToURLSearchParams(url.searchParams, params);\n    }\n\n    const init: RequestInit = {\n      method,\n      body:\n        contentType === undefined || typeof body !== \"string\"\n          ? JSON.stringify(body)\n          : body,\n      ...this.#requestInit,\n      ...extraRequestInit,\n      headers: this.#getHeaders(extraRequestInit?.headers, contentType),\n    };\n\n    return { url, init };\n  }\n\n  /**\n   * Sends a request with {@link fetch} or a custom HTTP client, combining\n   * parameters and class properties.\n   *\n   * @returns A promise containing the response\n   */\n  async #request<T = unknown>(options: MainRequestOptions): Promise<T> {\n    const { url, init } = this.#prepareRequest(options);\n\n    const startTimeout =\n      this.#requestTimeout !== undefined\n        ? getTimeoutFn(init, this.#requestTimeout)\n        : null;\n\n    const stopTimeout = startTimeout?.();\n\n    let response: Response;\n    let responseBody: string;\n    try {\n      if (this.#customRequestFn !== undefined) {\n        // When using a custom HTTP client, the response should already be handled and ready to be returned\n        return (await this.#customRequestFn(url, init)) as T;\n      }\n\n      response = await fetch(url, init);\n      responseBody = await response.text();\n    } catch (error) {\n      throw new MeilisearchRequestError(\n        url.toString(),\n        Object.is(error, TIMEOUT_ID)\n          ? new MeilisearchRequestTimeOutError(this.#requestTimeout!, init)\n          : error,\n      );\n    } finally {\n      stopTimeout?.();\n    }\n\n    let parsedResponse: T | MeilisearchErrorResponse | undefined;\n    try {\n      parsedResponse = parseResponseBody<T | MeilisearchErrorResponse>(\n        responseBody,\n      );\n    } catch (error) {\n      if (response.ok) {\n        throw error;\n      }\n\n      throw new MeilisearchApiError(response);\n    }\n\n    if (!response.ok) {\n      throw new MeilisearchApiError(\n        response,\n        parsedResponse as MeilisearchErrorResponse | undefined,\n      );\n    }\n\n    return parsedResponse as T;\n  }\n\n  /** Request with GET. */\n  get<T = unknown>(options: RequestOptions): Promise<T> {\n    return this.#request<T>(options);\n  }\n\n  /** Request with GET that returns a stream. */\n  getStream(options: RequestOptions): Promise<ReadableStream<Uint8Array>> {\n    return this.#requestStream(options);\n  }\n\n  /** Request with POST. */\n  post<T = unknown>(options: RequestOptions): Promise<T> {\n    return this.#request<T>({ ...options, method: \"POST\" });\n  }\n\n  /** Request with PUT. */\n  put<T = unknown>(options: RequestOptions): Promise<T> {\n    return this.#request<T>({ ...options, method: \"PUT\" });\n  }\n\n  /** Request with PATCH. */\n  patch<T = unknown>(options: RequestOptions): Promise<T> {\n    return this.#request<T>({ ...options, method: \"PATCH\" });\n  }\n\n  /** Request with DELETE. */\n  delete<T = unknown>(options: RequestOptions): Promise<T> {\n    return this.#request<T>({ ...options, method: \"DELETE\" });\n  }\n\n  /** Request with POST that returns a stream. */\n  postStream(options: RequestOptions): Promise<ReadableStream<Uint8Array>> {\n    return this.#requestStream({ ...options, method: \"POST\" });\n  }\n\n  /**\n   * Sends a request that returns a ReadableStream for streaming responses.\n   *\n   * @returns A promise containing the response stream\n   */\n  async #requestStream(\n    options: MainRequestOptions,\n  ): Promise<ReadableStream<Uint8Array>> {\n    const { url, init } = this.#prepareRequest(options);\n\n    const startTimeout =\n      this.#requestTimeout !== undefined\n        ? getTimeoutFn(init, this.#requestTimeout)\n        : null;\n\n    const stopTimeout = startTimeout?.();\n\n    let response: Response;\n    try {\n      if (this.#customRequestFn !== undefined) {\n        const result = await this.#customRequestFn(url, init);\n        if (!(result instanceof ReadableStream)) {\n          throw new MeilisearchError(\n            \"Custom HTTP client must return a ReadableStream for streaming requests\",\n          );\n        }\n        return result as ReadableStream<Uint8Array>;\n      }\n\n      response = await fetch(url, init);\n    } catch (error) {\n      throw new MeilisearchRequestError(\n        url.toString(),\n        Object.is(error, TIMEOUT_ID)\n          ? new MeilisearchRequestTimeOutError(this.#requestTimeout!, init)\n          : error,\n      );\n    } finally {\n      stopTimeout?.();\n    }\n\n    if (!response.ok) {\n      // For error responses, we still need to read the body to get error details\n      const responseBody = await response.text();\n      let parsedResponse: MeilisearchErrorResponse | undefined;\n      try {\n        parsedResponse =\n          parseResponseBody<MeilisearchErrorResponse>(responseBody);\n      } catch {\n        throw new MeilisearchApiError(response);\n      }\n\n      throw new MeilisearchApiError(response, parsedResponse);\n    }\n\n    if (!response.body) {\n      throw new MeilisearchError(\n        \"Response body is null - server did not return a readable stream\",\n      );\n    }\n\n    return response.body;\n  }\n}\n","import { MeilisearchTaskTimeOutError } from \"./errors/index.js\";\nimport type {\n  WaitOptions,\n  TasksOrBatchesQuery,\n  TasksResults,\n  Task,\n  DeleteOrCancelTasksQuery,\n  EnqueuedTask,\n  EnqueuedTaskPromise,\n  TaskUidOrEnqueuedTask,\n  ExtraRequestInit,\n  RecordAny,\n} from \"./types/index.js\";\nimport type { HttpRequests } from \"./http-requests.js\";\nimport { parseTaskDocuments, readStreamAsText } from \"./utils.js\";\n\n/**\n * Used to identify whether an error is a timeout error in\n * {@link TaskClient.waitForTask}.\n */\nconst TIMEOUT_ID = Symbol(\"<task timeout>\");\n\n/**\n * @returns A function which defines an extra function property on a\n *   {@link Promise}, which resolves to {@link EnqueuedTask}, which awaits it and\n *   resolves to a {@link Task}.\n */\nfunction getWaitTaskApplier(\n  taskClient: TaskClient,\n): (enqueuedTaskPromise: Promise<EnqueuedTask>) => EnqueuedTaskPromise {\n  return function (\n    enqueuedTaskPromise: Promise<EnqueuedTask>,\n  ): EnqueuedTaskPromise {\n    return Object.defineProperty(\n      enqueuedTaskPromise,\n      \"waitTask\" satisfies keyof Pick<EnqueuedTaskPromise, \"waitTask\">,\n      {\n        async value(waitOptions?: WaitOptions): Promise<Task> {\n          return await taskClient.waitForTask(\n            await enqueuedTaskPromise,\n            waitOptions,\n          );\n        },\n      },\n    ) as EnqueuedTaskPromise;\n  };\n}\n\nconst getTaskUid = (taskUidOrEnqueuedTask: TaskUidOrEnqueuedTask): number =>\n  typeof taskUidOrEnqueuedTask === \"number\"\n    ? taskUidOrEnqueuedTask\n    : taskUidOrEnqueuedTask.taskUid;\n\n/**\n * Class for handling tasks.\n *\n * @see {@link https://www.meilisearch.com/docs/reference/api/tasks}\n */\nexport class TaskClient {\n  readonly #httpRequest: HttpRequests;\n  readonly #defaultTimeout: number;\n  readonly #defaultInterval: number;\n  readonly #applyWaitTask: ReturnType<typeof getWaitTaskApplier>;\n\n  constructor(httpRequest: HttpRequests, defaultWaitOptions?: WaitOptions) {\n    this.#httpRequest = httpRequest;\n    this.#defaultTimeout = defaultWaitOptions?.timeout ?? 5_000;\n    this.#defaultInterval = defaultWaitOptions?.interval ?? 50;\n    this.#applyWaitTask = getWaitTaskApplier(this);\n  }\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/tasks#get-one-task} */\n  async getTask(\n    uid: number,\n    // TODO: Need to do this for all other methods: https://github.com/meilisearch/meilisearch-js/issues/1476\n    extraRequestInit?: ExtraRequestInit,\n  ): Promise<Task> {\n    return await this.#httpRequest.get({\n      path: `tasks/${encodeURIComponent(uid)}`,\n      extraRequestInit,\n    });\n  }\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/tasks#get-tasks} */\n  async getTasks(params?: TasksOrBatchesQuery): Promise<TasksResults> {\n    return await this.#httpRequest.get({ path: \"tasks\", params });\n  }\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/async-task-management/get-tasks-documents} */\n  async getTaskDocuments<D extends RecordAny = RecordAny>(\n    uid: number,\n    extraRequestInit?: ExtraRequestInit,\n  ): Promise<D[]> {\n    const stream = await this.#httpRequest.getStream({\n      path: `tasks/${encodeURIComponent(uid)}/documents`,\n      extraRequestInit,\n    });\n\n    const rawDocuments = await readStreamAsText(stream);\n    return parseTaskDocuments<D>(rawDocuments);\n  }\n\n  /**\n   * Wait for an enqueued task to be processed. This is done through polling\n   * with {@link TaskClient.getTask}.\n   *\n   * @remarks\n   * If an {@link EnqueuedTask} needs to be awaited instantly, it is recommended\n   * to instead use {@link EnqueuedTaskPromise.waitTask}, which is available on\n   * any method that returns an {@link EnqueuedTaskPromise}.\n   */\n  async waitForTask(\n    taskUidOrEnqueuedTask: TaskUidOrEnqueuedTask,\n    options?: WaitOptions,\n  ): Promise<Task> {\n    const taskUid = getTaskUid(taskUidOrEnqueuedTask);\n    const timeout = options?.timeout ?? this.#defaultTimeout;\n    const interval = options?.interval ?? this.#defaultInterval;\n\n    const ac = timeout > 0 ? new AbortController() : null;\n\n    const toId =\n      ac !== null\n        ? setTimeout(() => {\n            ac.abort(TIMEOUT_ID);\n          }, timeout)\n        : undefined;\n\n    try {\n      for (;;) {\n        const task = await this.getTask(taskUid, { signal: ac?.signal });\n\n        if (task.status !== \"enqueued\" && task.status !== \"processing\") {\n          clearTimeout(toId);\n          return task;\n        }\n\n        if (interval > 0) {\n          await new Promise((resolve) => setTimeout(resolve, interval));\n        }\n      }\n    } catch (error) {\n      throw Object.is((error as Error).cause, TIMEOUT_ID)\n        ? new MeilisearchTaskTimeOutError(taskUid, timeout)\n        : error;\n    }\n  }\n\n  /**\n   * Lazily wait for multiple enqueued tasks to be processed.\n   *\n   * @remarks\n   * In this case {@link WaitOptions.timeout} is the maximum time to wait for any\n   * one task, not for all of the tasks to complete.\n   */\n  async *waitForTasksIter(\n    taskUidsOrEnqueuedTasks:\n      Iterable<TaskUidOrEnqueuedTask> | AsyncIterable<TaskUidOrEnqueuedTask>,\n    options?: WaitOptions,\n  ): AsyncGenerator<Task, void, undefined> {\n    for await (const taskUidOrEnqueuedTask of taskUidsOrEnqueuedTasks) {\n      yield await this.waitForTask(taskUidOrEnqueuedTask, options);\n    }\n  }\n\n  /** Wait for multiple enqueued tasks to be processed. */\n  async waitForTasks(\n    ...params: Parameters<typeof this.waitForTasksIter>\n  ): Promise<Task[]> {\n    const tasks: Task[] = [];\n\n    for await (const task of this.waitForTasksIter(...params)) {\n      tasks.push(task);\n    }\n\n    return tasks;\n  }\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/tasks#cancel-tasks} */\n  cancelTasks(params: DeleteOrCancelTasksQuery): EnqueuedTaskPromise {\n    return this.#applyWaitTask(\n      this.#httpRequest.post({ path: \"tasks/cancel\", params }),\n    );\n  }\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/tasks#delete-tasks} */\n  deleteTasks(params: DeleteOrCancelTasksQuery): EnqueuedTaskPromise {\n    return this.#applyWaitTask(\n      this.#httpRequest.delete({ path: \"tasks\", params }),\n    );\n  }\n}\n\ntype PickedHttpRequestMethods = Pick<\n  HttpRequests,\n  \"post\" | \"put\" | \"patch\" | \"delete\"\n>;\nexport type HttpRequestsWithEnqueuedTaskPromise = {\n  [TKey in keyof PickedHttpRequestMethods]: (\n    ...params: Parameters<PickedHttpRequestMethods[TKey]>\n  ) => EnqueuedTaskPromise;\n};\n\nexport function getHttpRequestsWithEnqueuedTaskPromise(\n  httpRequest: HttpRequests,\n  taskClient: TaskClient,\n): HttpRequestsWithEnqueuedTaskPromise {\n  const applyWaitTask = getWaitTaskApplier(taskClient);\n\n  return {\n    post: (...params) => applyWaitTask(httpRequest.post(...params)),\n    put: (...params) => applyWaitTask(httpRequest.put(...params)),\n    patch: (...params) => applyWaitTask(httpRequest.patch(...params)),\n    delete: (...params) => applyWaitTask(httpRequest.delete(...params)),\n  };\n}\n","/*\n * Bundle: Meilisearch / Indexes\n * Project: Meilisearch - Javascript API\n * Author: Quentin de Quelen <quentin@meilisearch.com>\n * Copyright: 2019, Meilisearch\n */\n\nimport { MeilisearchError } from \"./errors/index.js\";\nimport type {\n  Config,\n  SearchResponse,\n  SearchParams,\n  Filter,\n  SearchRequestGET,\n  IndexObject,\n  IndexOptions,\n  IndexStats,\n  StatsQuery,\n  DocumentsQuery,\n  DocumentQuery,\n  DocumentOptions,\n  Settings,\n  Synonyms,\n  StopWords,\n  RankingRules,\n  DistinctAttribute,\n  FilterableAttributes,\n  SortableAttributes,\n  SearchableAttributes,\n  DisplayedAttributes,\n  TypoTolerance,\n  PaginationSettings,\n  Faceting,\n  ResourceResults,\n  RawDocumentAdditionOptions,\n  ContentType,\n  DocumentsIds,\n  DocumentsDeletionQuery,\n  SearchForFacetValuesParams,\n  SearchForFacetValuesResponse,\n  SeparatorTokens,\n  NonSeparatorTokens,\n  Dictionary,\n  ProximityPrecision,\n  Embedders,\n  SearchCutoffMs,\n  SearchSimilarDocumentsParams,\n  LocalizedAttributes,\n  ForeignKey,\n  ForeignKeys,\n  UpdateDocumentsByFunctionOptions,\n  TaskEnqueueOptions,\n  ExtraRequestInit,\n  PrefixSearch,\n  RecordAny,\n  EnqueuedTaskPromise,\n  ChatSettings,\n  ChatSettingsPayload,\n  FieldsQuery,\n  FieldsResults,\n} from \"./types/index.js\";\nimport { HttpRequests } from \"./http-requests.js\";\nimport {\n  getHttpRequestsWithEnqueuedTaskPromise,\n  TaskClient,\n  type HttpRequestsWithEnqueuedTaskPromise,\n} from \"./task.js\";\n\nexport class Index<T extends RecordAny = RecordAny> {\n  uid: string;\n  primaryKey: string | undefined;\n  createdAt: Date | undefined;\n  updatedAt: Date | undefined;\n  httpRequest: HttpRequests;\n  tasks: TaskClient;\n  readonly #httpRequestsWithTask: HttpRequestsWithEnqueuedTaskPromise;\n\n  /**\n   * @param config - Request configuration options\n   * @param uid - UID of the index\n   * @param primaryKey - Primary Key of the index\n   */\n  constructor(config: Config, uid: string, primaryKey?: string) {\n    this.uid = uid;\n    this.primaryKey = primaryKey;\n    this.httpRequest = new HttpRequests(config);\n    this.tasks = new TaskClient(this.httpRequest, config.defaultWaitOptions);\n    this.#httpRequestsWithTask = getHttpRequestsWithEnqueuedTaskPromise(\n      this.httpRequest,\n      this.tasks,\n    );\n  }\n\n  /** UID of the index, encoded to be used as a URL path segment. */\n  get #encodedUid(): string {\n    return encodeURIComponent(this.uid);\n  }\n\n  ///\n  /// SEARCH\n  ///\n\n  /**\n   * Search for documents into an index\n   *\n   * @param query - Query string\n   * @param options - Search options\n   * @param config - Additional request configuration options\n   * @returns Promise containing the search response\n   */\n  async search<D extends RecordAny = T, S extends SearchParams = SearchParams>(\n    query?: string | null,\n    options?: S,\n    extraRequestInit?: ExtraRequestInit,\n  ): Promise<SearchResponse<D, S>> {\n    return await this.httpRequest.post<SearchResponse<D, S>>({\n      path: `indexes/${this.#encodedUid}/search`,\n      body: { q: query, ...options },\n      extraRequestInit,\n    });\n  }\n\n  /**\n   * Search for documents into an index using the GET method\n   *\n   * @param query - Query string\n   * @param options - Search options\n   * @param config - Additional request configuration options\n   * @returns Promise containing the search response\n   */\n  async searchGet<\n    D extends RecordAny = T,\n    S extends SearchParams = SearchParams,\n  >(\n    query?: string | null,\n    options?: S,\n    extraRequestInit?: ExtraRequestInit,\n  ): Promise<SearchResponse<D, S>> {\n    // TODO: Make this a type thing instead of a runtime thing\n    const parseFilter = (filter?: Filter): string | undefined => {\n      if (typeof filter === \"string\") return filter;\n      else if (Array.isArray(filter))\n        throw new MeilisearchError(\n          \"The filter query parameter should be in string format when using searchGet\",\n        );\n      else return undefined;\n    };\n\n    const getParams: SearchRequestGET = {\n      q: query,\n      ...options,\n      filter: parseFilter(options?.filter),\n      sort: options?.sort?.join(\",\"),\n      facets: options?.facets?.join(\",\"),\n      attributesToRetrieve: options?.attributesToRetrieve?.join(\",\"),\n      attributesToCrop: options?.attributesToCrop?.join(\",\"),\n      attributesToHighlight: options?.attributesToHighlight?.join(\",\"),\n      vector: options?.vector?.join(\",\"),\n      attributesToSearchOn: options?.attributesToSearchOn?.join(\",\"),\n    };\n\n    return await this.httpRequest.get<SearchResponse<D, S>>({\n      path: `indexes/${this.#encodedUid}/search`,\n      params: getParams,\n      extraRequestInit,\n    });\n  }\n\n  /**\n   * Search for facet values\n   *\n   * @param params - Parameters used to search on the facets\n   * @param config - Additional request configuration options\n   * @returns Promise containing the search response\n   */\n  async searchForFacetValues(\n    params: SearchForFacetValuesParams,\n    extraRequestInit?: ExtraRequestInit,\n  ): Promise<SearchForFacetValuesResponse> {\n    return await this.httpRequest.post<SearchForFacetValuesResponse>({\n      path: `indexes/${this.#encodedUid}/facet-search`,\n      body: params,\n      extraRequestInit,\n    });\n  }\n\n  /**\n   * Search for similar documents\n   *\n   * @param params - Parameters used to search for similar documents\n   * @returns Promise containing the search response\n   */\n  async searchSimilarDocuments<\n    D extends RecordAny = T,\n    S extends SearchParams = SearchParams,\n  >(params: SearchSimilarDocumentsParams): Promise<SearchResponse<D, S>> {\n    return await this.httpRequest.post<SearchResponse<D, S>>({\n      path: `indexes/${this.#encodedUid}/similar`,\n      body: params,\n    });\n  }\n\n  ///\n  /// INDEX\n  ///\n\n  /**\n   * Get index information.\n   *\n   * @returns Promise containing index information\n   */\n  async getRawInfo(): Promise<IndexObject> {\n    const res = await this.httpRequest.get<IndexObject>({\n      path: `indexes/${this.#encodedUid}`,\n    });\n    this.primaryKey = res.primaryKey;\n    this.updatedAt = new Date(res.updatedAt);\n    this.createdAt = new Date(res.createdAt);\n    return res;\n  }\n\n  /**\n   * Fetch and update Index information.\n   *\n   * @returns Promise to the current Index object with updated information\n   */\n  async fetchInfo(): Promise<this> {\n    await this.getRawInfo();\n    return this;\n  }\n\n  /**\n   * Get Primary Key.\n   *\n   * @returns Promise containing the Primary Key of the index\n   */\n  async fetchPrimaryKey(): Promise<string | undefined> {\n    this.primaryKey = (await this.getRawInfo()).primaryKey;\n    return this.primaryKey;\n  }\n\n  /**\n   * Create an index.\n   *\n   * @param uid - Unique identifier of the Index\n   * @param options - Index options\n   * @param config - Request configuration options\n   * @returns Newly created Index object\n   */\n  static create(\n    uid: string,\n    options: IndexOptions = {},\n    config: Config,\n  ): EnqueuedTaskPromise {\n    const httpRequests = new HttpRequests(config);\n    return getHttpRequestsWithEnqueuedTaskPromise(\n      httpRequests,\n      new TaskClient(httpRequests),\n    ).post({\n      path: \"indexes\",\n      body: { ...options, uid },\n    });\n  }\n\n  /**\n   * Update an index.\n   *\n   * @param data - Data to update\n   * @returns Promise to the current Index object with updated information\n   */\n  update(data?: IndexOptions): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: `indexes/${this.#encodedUid}`,\n      body: data,\n    });\n  }\n\n  /**\n   * Delete an index.\n   *\n   * @returns Promise which resolves when index is deleted successfully\n   */\n  delete(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}`,\n    });\n  }\n\n  ///\n  /// STATS\n  ///\n\n  /**\n   * Get stats of an index\n   *\n   * Size fields are numbers of bytes by default. `sizeFormat: \"human\"` returns\n   * them as strings with units, such as `\"19.64 MiB\"`.\n   * `showInternalDatabaseSizes` adds each internal database's size.\n   *\n   * @typeParam Q - Stats query whose `sizeFormat` selects the size field type\n   * @param params - Internal database sizes and size formatting\n   * @returns Promise containing stats of the index\n   * @see {@link https://www.meilisearch.com/docs/reference/api/indexes/get-stats-of-index}\n   */\n  async getStats<const Q extends StatsQuery | undefined = undefined>(\n    params?: Q,\n  ): Promise<IndexStats<Q>> {\n    return await this.httpRequest.get<IndexStats<Q>>({\n      path: `indexes/${this.#encodedUid}/stats`,\n      params,\n    });\n  }\n\n  ///\n  /// DOCUMENTS\n  ///\n\n  /**\n   * Get documents of an index.\n   *\n   * @param params - Parameters to browse the documents. Parameters can contain\n   *   the `filter` field only available in Meilisearch v1.2 and newer, and the\n   *   `sort` field available in Meilisearch v1.16 and newer\n   * @returns Promise containing the returned documents\n   */\n  async getDocuments<D extends RecordAny = T>(\n    params?: DocumentsQuery<D>,\n  ): Promise<ResourceResults<D[]>> {\n    const relativeBaseURL = `indexes/${this.#encodedUid}/documents`;\n    // Create a shallow copy so we can safely normalize parameters\n    const normalizedParams = params ? { ...params } : undefined;\n    // Omit empty sort arrays to avoid server-side validation errors\n    if (\n      normalizedParams &&\n      Array.isArray(normalizedParams.sort) &&\n      normalizedParams.sort.length === 0\n    ) {\n      delete (normalizedParams as { sort?: string[] }).sort;\n    }\n\n    return normalizedParams?.filter !== undefined\n      ? // In case `filter` is provided, use `POST /documents/fetch`\n        await this.httpRequest.post<ResourceResults<D[]>>({\n          path: `${relativeBaseURL}/fetch`,\n          body: normalizedParams,\n        })\n      : // Else use `GET /documents` method\n        await this.httpRequest.get<ResourceResults<D[]>>({\n          path: relativeBaseURL,\n          params: normalizedParams,\n        });\n  }\n\n  /**\n   * Get one document\n   *\n   * @param documentId - Document ID\n   * @param parameters - Parameters applied on a document\n   * @returns Promise containing Document response\n   */\n  async getDocument<D extends RecordAny = T>(\n    documentId: string | number,\n    parameters?: DocumentQuery<T>,\n  ): Promise<D> {\n    const fields = Array.isArray(parameters?.fields)\n      ? parameters.fields.join()\n      : parameters?.fields;\n\n    return await this.httpRequest.get<D>({\n      path: `indexes/${this.#encodedUid}/documents/${encodeURIComponent(documentId)}`,\n      params: { ...parameters, fields },\n    });\n  }\n\n  /**\n   * Add or replace multiples documents to an index\n   *\n   * @param documents - Array of Document objects to add/replace\n   * @param options - Options on document addition\n   * @returns Promise containing an EnqueuedTask\n   */\n  addDocuments(documents: T[], options?: DocumentOptions): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.post({\n      path: `indexes/${this.#encodedUid}/documents`,\n      params: options,\n      body: documents,\n    });\n  }\n\n  /**\n   * Add or replace multiples documents in a string format to an index. It only\n   * supports csv, ndjson and json formats.\n   *\n   * @param documents - Documents provided in a string to add/replace\n   * @param contentType - Content type of your document:\n   *   'text/csv'|'application/x-ndjson'|'application/json'\n   * @param options - Options on document addition\n   * @returns Promise containing an EnqueuedTask\n   */\n  addDocumentsFromString(\n    documents: string,\n    contentType: ContentType,\n    queryParams?: RawDocumentAdditionOptions,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.post({\n      path: `indexes/${this.#encodedUid}/documents`,\n      body: documents,\n      params: queryParams,\n      contentType,\n    });\n  }\n\n  /**\n   * Add or replace multiples documents to an index in batches\n   *\n   * @param documents - Array of Document objects to add/replace\n   * @param batchSize - Size of the batch\n   * @param options - Options on document addition\n   * @returns Promise containing array of enqueued task objects for each batch\n   */\n  addDocumentsInBatches(\n    documents: T[],\n    batchSize = 1000,\n    options?: DocumentOptions,\n  ): EnqueuedTaskPromise[] {\n    const updates: EnqueuedTaskPromise[] = [];\n\n    for (let i = 0; i < documents.length; i += batchSize) {\n      updates.push(\n        this.addDocuments(documents.slice(i, i + batchSize), options),\n      );\n    }\n\n    return updates;\n  }\n\n  /**\n   * Add or update multiples documents to an index\n   *\n   * @param documents - Array of Document objects to add/update\n   * @param options - Options on document update\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateDocuments(\n    documents: Partial<T>[],\n    options?: DocumentOptions,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/documents`,\n      params: options,\n      body: documents,\n    });\n  }\n\n  /**\n   * Add or update multiples documents to an index in batches\n   *\n   * @param documents - Array of Document objects to add/update\n   * @param batchSize - Size of the batch\n   * @param options - Options on document update\n   * @returns Promise containing array of enqueued task objects for each batch\n   */\n  updateDocumentsInBatches(\n    documents: Partial<T>[],\n    batchSize = 1000,\n    options?: DocumentOptions,\n  ): EnqueuedTaskPromise[] {\n    const updates: EnqueuedTaskPromise[] = [];\n\n    for (let i = 0; i < documents.length; i += batchSize) {\n      updates.push(\n        this.updateDocuments(documents.slice(i, i + batchSize), options),\n      );\n    }\n\n    return updates;\n  }\n\n  /**\n   * Add or update multiples documents in a string format to an index. It only\n   * supports csv, ndjson and json formats.\n   *\n   * @param documents - Documents provided in a string to add/update\n   * @param contentType - Content type of your document:\n   *   'text/csv'|'application/x-ndjson'|'application/json'\n   * @param queryParams - Options on raw document addition\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateDocumentsFromString(\n    documents: string,\n    contentType: ContentType,\n    queryParams?: RawDocumentAdditionOptions,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/documents`,\n      body: documents,\n      params: queryParams,\n      contentType,\n    });\n  }\n\n  /**\n   * Delete one document\n   *\n   * @param documentId - Id of Document to delete\n   * @param options - Task enqueue options (e.g. customMetadata)\n   * @returns Promise containing an EnqueuedTask\n   */\n  deleteDocument(\n    documentId: string | number,\n    options?: TaskEnqueueOptions,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/documents/${encodeURIComponent(documentId)}`,\n      params: options,\n    });\n  }\n\n  /**\n   * Delete multiples documents of an index.\n   *\n   * @param params - Params value can be:\n   *\n   *   - DocumentsDeletionQuery: An object containing the parameters to customize\n   *       your document deletion. Only available in Meilisearch v1.2 and newer\n   *   - DocumentsIds: An array of document ids to delete\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  deleteDocuments(\n    params: DocumentsDeletionQuery | DocumentsIds,\n    options?: TaskEnqueueOptions,\n  ): EnqueuedTaskPromise {\n    // If params is of type DocumentsDeletionQuery\n    const isDocumentsDeletionQuery =\n      !Array.isArray(params) && typeof params === \"object\";\n    const endpoint = isDocumentsDeletionQuery\n      ? \"documents/delete\"\n      : \"documents/delete-batch\";\n\n    return this.#httpRequestsWithTask.post({\n      path: `indexes/${this.#encodedUid}/${endpoint}`,\n      body: params,\n      params: options,\n    });\n  }\n\n  /**\n   * Delete all documents of an index\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  deleteAllDocuments(options?: TaskEnqueueOptions): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/documents`,\n      params: options,\n    });\n  }\n\n  /**\n   * Compact the index database to reclaim space and improve read performance.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  compact(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.post({\n      path: `indexes/${this.#encodedUid}/compact`,\n    });\n  }\n\n  /**\n   * This is an EXPERIMENTAL feature, which may break without a major version.\n   * It's available after Meilisearch v1.10.\n   *\n   * More info about the feature:\n   * https://github.com/orgs/meilisearch/discussions/762 More info about\n   * experimental features in general:\n   * https://www.meilisearch.com/docs/reference/api/experimental-features\n   *\n   * @param options - Object containing the function string and related options\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateDocumentsByFunction(\n    options: UpdateDocumentsByFunctionOptions,\n    taskOptions?: TaskEnqueueOptions,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.post({\n      path: `indexes/${this.#encodedUid}/documents/edit`,\n      body: options,\n      params: taskOptions,\n    });\n  }\n\n  ///\n  /// SETTINGS\n  ///\n\n  /**\n   * Retrieve all settings\n   *\n   * @returns Promise containing Settings object\n   */\n  async getSettings(): Promise<Settings> {\n    return await this.httpRequest.get<Settings>({\n      path: `indexes/${this.#encodedUid}/settings`,\n    });\n  }\n\n  /**\n   * Update all settings Any parameters not provided will be left unchanged.\n   *\n   * @param settings - Object containing parameters with their updated values\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateSettings(settings: Settings): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: `indexes/${this.#encodedUid}/settings`,\n      body: settings,\n    });\n  }\n\n  /**\n   * Reset settings.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetSettings(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings`,\n    });\n  }\n\n  ///\n  /// PAGINATION SETTINGS\n  ///\n\n  /**\n   * Get the pagination settings.\n   *\n   * @returns Promise containing object of pagination settings\n   */\n  async getPagination(): Promise<PaginationSettings> {\n    return await this.httpRequest.get<PaginationSettings>({\n      path: `indexes/${this.#encodedUid}/settings/pagination`,\n    });\n  }\n\n  /**\n   * Update the pagination settings.\n   *\n   * @param pagination - Pagination object\n   * @returns Promise containing an EnqueuedTask\n   */\n  updatePagination(pagination: PaginationSettings): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: `indexes/${this.#encodedUid}/settings/pagination`,\n      body: pagination,\n    });\n  }\n\n  /**\n   * Reset the pagination settings.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetPagination(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/pagination`,\n    });\n  }\n\n  ///\n  /// SYNONYMS\n  ///\n\n  /**\n   * Get the list of all synonyms\n   *\n   * @returns Promise containing record of synonym mappings\n   */\n  async getSynonyms(): Promise<Record<string, string[]>> {\n    return await this.httpRequest.get<Record<string, string[]>>({\n      path: `indexes/${this.#encodedUid}/settings/synonyms`,\n    });\n  }\n\n  /**\n   * Update the list of synonyms. Overwrite the old list.\n   *\n   * @param synonyms - Mapping of synonyms with their associated words\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateSynonyms(synonyms: Synonyms): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/synonyms`,\n      body: synonyms,\n    });\n  }\n\n  /**\n   * Reset the synonym list to be empty again\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetSynonyms(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/synonyms`,\n    });\n  }\n\n  ///\n  /// STOP WORDS\n  ///\n\n  /**\n   * Get the list of all stop-words\n   *\n   * @returns Promise containing array of stop-words\n   */\n  async getStopWords(): Promise<string[]> {\n    return await this.httpRequest.get<string[]>({\n      path: `indexes/${this.#encodedUid}/settings/stop-words`,\n    });\n  }\n\n  /**\n   * Update the list of stop-words. Overwrite the old list.\n   *\n   * @param stopWords - Array of strings that contains the stop-words.\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateStopWords(stopWords: StopWords): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/stop-words`,\n      body: stopWords,\n    });\n  }\n\n  /**\n   * Reset the stop-words list to be empty again\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetStopWords(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/stop-words`,\n    });\n  }\n\n  ///\n  /// RANKING RULES\n  ///\n\n  /**\n   * Get the list of all ranking-rules\n   *\n   * @returns Promise containing array of ranking-rules\n   */\n  async getRankingRules(): Promise<string[]> {\n    return await this.httpRequest.get<string[]>({\n      path: `indexes/${this.#encodedUid}/settings/ranking-rules`,\n    });\n  }\n\n  /**\n   * Update the list of ranking-rules. Overwrite the old list.\n   *\n   * @param rankingRules - Array that contain ranking rules sorted by order of\n   *   importance.\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateRankingRules(rankingRules: RankingRules): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/ranking-rules`,\n      body: rankingRules,\n    });\n  }\n\n  /**\n   * Reset the ranking rules list to its default value\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetRankingRules(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/ranking-rules`,\n    });\n  }\n\n  ///\n  /// DISTINCT ATTRIBUTE\n  ///\n\n  /**\n   * Get the distinct-attribute\n   *\n   * @returns Promise containing the distinct-attribute of the index\n   */\n  async getDistinctAttribute(): Promise<DistinctAttribute> {\n    return await this.httpRequest.get<DistinctAttribute>({\n      path: `indexes/${this.#encodedUid}/settings/distinct-attribute`,\n    });\n  }\n\n  /**\n   * Update the distinct-attribute.\n   *\n   * @param distinctAttribute - Field name of the distinct-attribute\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateDistinctAttribute(\n    distinctAttribute: DistinctAttribute,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/distinct-attribute`,\n      body: distinctAttribute,\n    });\n  }\n\n  /**\n   * Reset the distinct-attribute.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetDistinctAttribute(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/distinct-attribute`,\n    });\n  }\n\n  ///\n  /// FILTERABLE ATTRIBUTES\n  ///\n\n  /**\n   * Get the filterable-attributes\n   *\n   * @returns Promise containing an array of filterable-attributes\n   */\n  async getFilterableAttributes(): Promise<FilterableAttributes> {\n    return await this.httpRequest.get<FilterableAttributes>({\n      path: `indexes/${this.#encodedUid}/settings/filterable-attributes`,\n    });\n  }\n\n  /**\n   * Update the filterable-attributes.\n   *\n   * @param filterableAttributes - Array of strings containing the attributes\n   *   that can be used as filters at query time\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateFilterableAttributes(\n    filterableAttributes: FilterableAttributes,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/filterable-attributes`,\n      body: filterableAttributes,\n    });\n  }\n\n  /**\n   * Reset the filterable-attributes.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetFilterableAttributes(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/filterable-attributes`,\n    });\n  }\n\n  ///\n  /// SORTABLE ATTRIBUTES\n  ///\n\n  /**\n   * Get the sortable-attributes\n   *\n   * @returns Promise containing array of sortable-attributes\n   */\n  async getSortableAttributes(): Promise<string[]> {\n    return await this.httpRequest.get<string[]>({\n      path: `indexes/${this.#encodedUid}/settings/sortable-attributes`,\n    });\n  }\n\n  /**\n   * Update the sortable-attributes.\n   *\n   * @param sortableAttributes - Array of strings containing the attributes that\n   *   can be used to sort search results at query time\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateSortableAttributes(\n    sortableAttributes: SortableAttributes,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/sortable-attributes`,\n      body: sortableAttributes,\n    });\n  }\n\n  /**\n   * Reset the sortable-attributes.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetSortableAttributes(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/sortable-attributes`,\n    });\n  }\n\n  ///\n  /// SEARCHABLE ATTRIBUTE\n  ///\n\n  /**\n   * Get the searchable-attributes\n   *\n   * @returns Promise containing array of searchable-attributes\n   */\n  async getSearchableAttributes(): Promise<string[]> {\n    return await this.httpRequest.get<string[]>({\n      path: `indexes/${this.#encodedUid}/settings/searchable-attributes`,\n    });\n  }\n\n  /**\n   * Update the searchable-attributes.\n   *\n   * @param searchableAttributes - Array of strings that contains searchable\n   *   attributes sorted by order of importance(most to least important)\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateSearchableAttributes(\n    searchableAttributes: SearchableAttributes,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/searchable-attributes`,\n      body: searchableAttributes,\n    });\n  }\n\n  /**\n   * Reset the searchable-attributes.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetSearchableAttributes(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/searchable-attributes`,\n    });\n  }\n\n  ///\n  /// DISPLAYED ATTRIBUTE\n  ///\n\n  /**\n   * Get the displayed-attributes\n   *\n   * @returns Promise containing array of displayed-attributes\n   */\n  async getDisplayedAttributes(): Promise<string[]> {\n    return await this.httpRequest.get<string[]>({\n      path: `indexes/${this.#encodedUid}/settings/displayed-attributes`,\n    });\n  }\n\n  /**\n   * Update the displayed-attributes.\n   *\n   * @param displayedAttributes - Array of strings that contains attributes of\n   *   an index to display\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateDisplayedAttributes(\n    displayedAttributes: DisplayedAttributes,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/displayed-attributes`,\n      body: displayedAttributes,\n    });\n  }\n\n  /**\n   * Reset the displayed-attributes.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetDisplayedAttributes(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/displayed-attributes`,\n    });\n  }\n\n  ///\n  /// TYPO TOLERANCE\n  ///\n\n  /**\n   * Get the typo tolerance settings.\n   *\n   * @returns Promise containing the typo tolerance settings.\n   */\n  async getTypoTolerance(): Promise<TypoTolerance> {\n    return await this.httpRequest.get<TypoTolerance>({\n      path: `indexes/${this.#encodedUid}/settings/typo-tolerance`,\n    });\n  }\n\n  /**\n   * Update the typo tolerance settings.\n   *\n   * @param typoTolerance - Object containing the custom typo tolerance\n   *   settings.\n   * @returns Promise containing object of the enqueued update\n   */\n  updateTypoTolerance(typoTolerance: TypoTolerance): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: `indexes/${this.#encodedUid}/settings/typo-tolerance`,\n      body: typoTolerance,\n    });\n  }\n\n  /**\n   * Reset the typo tolerance settings.\n   *\n   * @returns Promise containing object of the enqueued update\n   */\n  resetTypoTolerance(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/typo-tolerance`,\n    });\n  }\n\n  ///\n  /// FACETING\n  ///\n\n  /**\n   * Get the faceting settings.\n   *\n   * @returns Promise containing object of faceting index settings\n   */\n  async getFaceting(): Promise<Faceting> {\n    return await this.httpRequest.get<Faceting>({\n      path: `indexes/${this.#encodedUid}/settings/faceting`,\n    });\n  }\n\n  /**\n   * Update the faceting settings.\n   *\n   * @param faceting - Faceting index settings object\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateFaceting(faceting: Faceting): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: `indexes/${this.#encodedUid}/settings/faceting`,\n      body: faceting,\n    });\n  }\n\n  /**\n   * Reset the faceting settings.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetFaceting(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/faceting`,\n    });\n  }\n\n  ///\n  /// SEPARATOR TOKENS\n  ///\n\n  /**\n   * Get the list of all separator tokens.\n   *\n   * @returns Promise containing array of separator tokens\n   */\n  async getSeparatorTokens(): Promise<string[]> {\n    return await this.httpRequest.get<string[]>({\n      path: `indexes/${this.#encodedUid}/settings/separator-tokens`,\n    });\n  }\n\n  /**\n   * Update the list of separator tokens. Overwrite the old list.\n   *\n   * @param separatorTokens - Array that contains separator tokens.\n   * @returns Promise containing an EnqueuedTask or null\n   */\n  updateSeparatorTokens(separatorTokens: SeparatorTokens): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/separator-tokens`,\n      body: separatorTokens,\n    });\n  }\n\n  /**\n   * Reset the separator tokens list to its default value\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetSeparatorTokens(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/separator-tokens`,\n    });\n  }\n\n  ///\n  /// NON-SEPARATOR TOKENS\n  ///\n\n  /**\n   * Get the list of all non-separator tokens.\n   *\n   * @returns Promise containing array of non-separator tokens\n   */\n  async getNonSeparatorTokens(): Promise<string[]> {\n    return await this.httpRequest.get<string[]>({\n      path: `indexes/${this.#encodedUid}/settings/non-separator-tokens`,\n    });\n  }\n\n  /**\n   * Update the list of non-separator tokens. Overwrite the old list.\n   *\n   * @param nonSeparatorTokens - Array that contains non-separator tokens.\n   * @returns Promise containing an EnqueuedTask or null\n   */\n  updateNonSeparatorTokens(\n    nonSeparatorTokens: NonSeparatorTokens,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/non-separator-tokens`,\n      body: nonSeparatorTokens,\n    });\n  }\n\n  /**\n   * Reset the non-separator tokens list to its default value\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetNonSeparatorTokens(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/non-separator-tokens`,\n    });\n  }\n\n  ///\n  /// DICTIONARY\n  ///\n\n  /**\n   * Get the dictionary settings of a Meilisearch index.\n   *\n   * @returns Promise containing the dictionary settings\n   */\n  async getDictionary(): Promise<string[]> {\n    return await this.httpRequest.get<string[]>({\n      path: `indexes/${this.#encodedUid}/settings/dictionary`,\n    });\n  }\n\n  /**\n   * Update the dictionary settings. Overwrite the old settings.\n   *\n   * @param dictionary - Array that contains the new dictionary settings.\n   * @returns Promise containing an EnqueuedTask or null\n   */\n  updateDictionary(dictionary: Dictionary): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/dictionary`,\n      body: dictionary,\n    });\n  }\n\n  /**\n   * Reset the dictionary settings to its default value\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetDictionary(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/dictionary`,\n    });\n  }\n\n  ///\n  /// PROXIMITY PRECISION\n  ///\n\n  /**\n   * Get the proximity precision settings of a Meilisearch index.\n   *\n   * @returns Promise containing the proximity precision settings\n   */\n  async getProximityPrecision(): Promise<ProximityPrecision> {\n    return await this.httpRequest.get<ProximityPrecision>({\n      path: `indexes/${this.#encodedUid}/settings/proximity-precision`,\n    });\n  }\n\n  /**\n   * Update the proximity precision settings. Overwrite the old settings.\n   *\n   * @param proximityPrecision - String that contains the new proximity\n   *   precision settings.\n   * @returns Promise containing an EnqueuedTask or null\n   */\n  updateProximityPrecision(\n    proximityPrecision: ProximityPrecision,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/proximity-precision`,\n      body: proximityPrecision,\n    });\n  }\n\n  /**\n   * Reset the proximity precision settings to its default value\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetProximityPrecision(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/proximity-precision`,\n    });\n  }\n\n  ///\n  /// EMBEDDERS\n  ///\n\n  /**\n   * Get the embedders settings of a Meilisearch index.\n   *\n   * @returns Promise containing the embedders settings\n   */\n  async getEmbedders(): Promise<Embedders> {\n    return await this.httpRequest.get<Embedders>({\n      path: `indexes/${this.#encodedUid}/settings/embedders`,\n    });\n  }\n\n  /**\n   * Update the embedders settings. Overwrite the old settings.\n   *\n   * @param embedders - Object that contains the new embedders settings.\n   * @returns Promise containing an EnqueuedTask or null\n   */\n  updateEmbedders(embedders: Embedders): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: `indexes/${this.#encodedUid}/settings/embedders`,\n      body: embedders,\n    });\n  }\n\n  /**\n   * Reset the embedders settings to its default value\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetEmbedders(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/embedders`,\n    });\n  }\n\n  ///\n  /// SEARCHCUTOFFMS SETTINGS\n  ///\n\n  /**\n   * Get the SearchCutoffMs settings.\n   *\n   * @returns Promise containing object of SearchCutoffMs settings\n   */\n  async getSearchCutoffMs(): Promise<SearchCutoffMs> {\n    return await this.httpRequest.get<SearchCutoffMs>({\n      path: `indexes/${this.#encodedUid}/settings/search-cutoff-ms`,\n    });\n  }\n\n  /**\n   * Update the SearchCutoffMs settings.\n   *\n   * @param searchCutoffMs - Object containing SearchCutoffMsSettings\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateSearchCutoffMs(searchCutoffMs: SearchCutoffMs): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/search-cutoff-ms`,\n      body: searchCutoffMs,\n    });\n  }\n\n  /**\n   * Reset the SearchCutoffMs settings.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetSearchCutoffMs(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/search-cutoff-ms`,\n    });\n  }\n\n  ///\n  /// LOCALIZED ATTRIBUTES SETTINGS\n  ///\n\n  /**\n   * Get the localized attributes settings.\n   *\n   * @returns Promise containing object of localized attributes settings\n   */\n  async getLocalizedAttributes(): Promise<LocalizedAttributes> {\n    return await this.httpRequest.get<LocalizedAttributes>({\n      path: `indexes/${this.#encodedUid}/settings/localized-attributes`,\n    });\n  }\n\n  /**\n   * Update the localized attributes settings.\n   *\n   * @param localizedAttributes - Localized attributes object\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateLocalizedAttributes(\n    localizedAttributes: LocalizedAttributes,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/localized-attributes`,\n      body: localizedAttributes,\n    });\n  }\n\n  /**\n   * Reset the localized attributes settings.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetLocalizedAttributes(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/localized-attributes`,\n    });\n  }\n\n  ///\n  /// FOREIGN KEYS SETTINGS\n  ///\n\n  /**\n   * Get the foreign keys settings.\n   *\n   * @returns Promise containing an array of foreign key settings\n   */\n  async getForeignKeys(): Promise<ForeignKey[]> {\n    return await this.httpRequest.get<ForeignKey[]>({\n      path: `indexes/${this.#encodedUid}/settings/foreign-keys`,\n    });\n  }\n\n  /**\n   * Update the foreign keys settings.\n   *\n   * @param foreignKeys - Foreign keys array\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateForeignKeys(foreignKeys: ForeignKeys): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/foreign-keys`,\n      body: foreignKeys,\n    });\n  }\n\n  /**\n   * Reset the foreign keys settings.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetForeignKeys(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/foreign-keys`,\n    });\n  }\n\n  ///\n  /// FACET SEARCH SETTINGS\n  ///\n\n  /**\n   * Get the facet search settings.\n   *\n   * @returns Promise containing object of facet search settings\n   */\n  async getFacetSearch(): Promise<boolean> {\n    return await this.httpRequest.get<boolean>({\n      path: `indexes/${this.#encodedUid}/settings/facet-search`,\n    });\n  }\n\n  /**\n   * Update the facet search settings.\n   *\n   * @param facetSearch - Boolean value\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateFacetSearch(facetSearch: boolean): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/facet-search`,\n      body: facetSearch,\n    });\n  }\n\n  /**\n   * Reset the facet search settings.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetFacetSearch(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/facet-search`,\n    });\n  }\n\n  ///\n  /// PREFIX SEARCH SETTINGS\n  ///\n\n  /**\n   * Get the prefix search settings.\n   *\n   * @returns Promise containing object of prefix search settings\n   */\n  async getPrefixSearch(): Promise<PrefixSearch> {\n    return await this.httpRequest.get<PrefixSearch>({\n      path: `indexes/${this.#encodedUid}/settings/prefix-search`,\n    });\n  }\n\n  /**\n   * Update the prefix search settings.\n   *\n   * @param prefixSearch - PrefixSearch value\n   * @returns Promise containing an EnqueuedTask\n   */\n  updatePrefixSearch(prefixSearch: PrefixSearch): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.put({\n      path: `indexes/${this.#encodedUid}/settings/prefix-search`,\n      body: prefixSearch,\n    });\n  }\n\n  /**\n   * Reset the prefix search settings.\n   *\n   * @returns Promise containing an EnqueuedTask\n   */\n  resetPrefixSearch(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `indexes/${this.#encodedUid}/settings/prefix-search`,\n    });\n  }\n\n  ///\n  /// CHAT SETTINGS\n  ///\n\n  /**\n   * Get the index's chat settings.\n   *\n   * @returns Promise containing a ChatSettings object\n   */\n  async getChat(): Promise<ChatSettings> {\n    return await this.httpRequest.get<ChatSettings>({\n      path: `indexes/${this.#encodedUid}/settings/chat`,\n    });\n  }\n\n  /**\n   * Update the index's chat settings.\n   *\n   * @param chatSettings - ChatSettingsPayload object\n   * @returns Promise containing an EnqueuedTask\n   */\n  updateChat(chatSettings: ChatSettingsPayload): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: `indexes/${this.#encodedUid}/settings/chat`,\n      body: chatSettings,\n    });\n  }\n\n  ///\n  /// FIELDS\n  ///\n\n  /**\n   * Retrieve fields from an index with optional filtering and pagination. This\n   * endpoint allows you to query fields based on their properties (searchable,\n   * filterable, displayed, sortable, distinct, rankingRule, and localized).\n   *\n   * @param params - Query parameters including pagination and filter options\n   * @param extraRequestInit - Additional request configuration options\n   * @returns Promise containing the fields results with pagination info\n   */\n  async getFields(\n    params?: FieldsQuery,\n    extraRequestInit?: ExtraRequestInit,\n  ): Promise<FieldsResults> {\n    return await this.httpRequest.post<FieldsResults>({\n      path: `indexes/${this.#encodedUid}/fields`,\n      body: params || {},\n      extraRequestInit,\n    });\n  }\n}\n","import type {\n  Batch,\n  BatchesResults,\n  TasksOrBatchesQuery,\n} from \"./types/index.js\";\nimport type { HttpRequests } from \"./http-requests.js\";\n\n/**\n * Class for handling batches.\n *\n * @see {@link https://www.meilisearch.com/docs/reference/api/batches}\n */\nexport class BatchClient {\n  readonly #httpRequest: HttpRequests;\n\n  constructor(httpRequests: HttpRequests) {\n    this.#httpRequest = httpRequests;\n  }\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/batches#get-one-batch} */\n  async getBatch(uid: number): Promise<Batch> {\n    return await this.#httpRequest.get({\n      path: `batches/${encodeURIComponent(uid)}`,\n    });\n  }\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/batches#get-batches} */\n  async getBatches(params?: TasksOrBatchesQuery): Promise<BatchesResults> {\n    return await this.#httpRequest.get({ path: \"batches\", params });\n  }\n}\n","import type { HttpRequests } from \"./http-requests.js\";\nimport type {\n  ChatWorkspaceSettings,\n  ChatCompletionRequest,\n} from \"./types/types.js\";\n\n/**\n * Class for handling chat workspaces.\n *\n * @see {@link https://www.meilisearch.com/docs/reference/api/chats}\n */\nexport class ChatWorkspace {\n  readonly #httpRequest: HttpRequests;\n  readonly #workspace: string;\n\n  constructor(httpRequests: HttpRequests, workspace: string) {\n    this.#httpRequest = httpRequests;\n    this.#workspace = workspace;\n  }\n\n  /**\n   * Get the settings of a chat workspace.\n   *\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/chats#get-chat-workspace-settings}\n   */\n  async get(): Promise<ChatWorkspaceSettings> {\n    return await this.#httpRequest.get({\n      path: `chats/${encodeURIComponent(this.#workspace)}/settings`,\n    });\n  }\n\n  /**\n   * Update the settings of a chat workspace.\n   *\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/chats#update-chat-workspace-settings}\n   */\n  async update(\n    settings: Partial<ChatWorkspaceSettings>,\n  ): Promise<ChatWorkspaceSettings> {\n    return await this.#httpRequest.patch({\n      path: `chats/${encodeURIComponent(this.#workspace)}/settings`,\n      body: settings,\n    });\n  }\n\n  /**\n   * Reset the settings of a chat workspace.\n   *\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/chats#reset-chat-workspace-settings}\n   */\n  async reset(): Promise<void> {\n    await this.#httpRequest.delete({\n      path: `chats/${encodeURIComponent(this.#workspace)}/settings`,\n    });\n  }\n\n  /**\n   * Create a chat completion using an OpenAI-compatible interface.\n   *\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/chats#chat-completions}\n   */\n  async streamCompletion(\n    completion: ChatCompletionRequest,\n  ): Promise<ReadableStream<Uint8Array>> {\n    if (!completion.stream) {\n      throw new Error(\"The SDK only supports streaming\");\n    }\n    return await this.#httpRequest.postStream({\n      path: `chats/${encodeURIComponent(this.#workspace)}/chat/completions`,\n      body: completion,\n    });\n  }\n}\n","/*\n * Bundle: Meilisearch\n * Project: Meilisearch - Javascript API\n * Author: Quentin de Quelen <quentin@meilisearch.com>\n * Copyright: 2019, Meilisearch\n */\n\nimport { Index } from \"./indexes.js\";\nimport type {\n  KeyCreation,\n  Config,\n  IndexOptions,\n  IndexObject,\n  Key,\n  Health,\n  Stats,\n  StatsQuery,\n  Version,\n  KeyUpdate,\n  IndexesQuery,\n  IndexesResults,\n  KeysQuery,\n  KeysResults,\n  IndexSwap,\n  MultiSearchParams,\n  FederatedMultiSearchParams,\n  MultiSearchResponseOrSearchResponse,\n  EnqueuedTask,\n  EnqueuedTaskPromise,\n  ExtraRequestInit,\n  Network,\n  RecordAny,\n  RuntimeTogglableFeatures,\n  ResourceResults,\n  SearchRule,\n  SearchRuleUpdatePayload,\n  SearchRuleListPayload,\n  Remote,\n  Webhook,\n  ResultsWrapper,\n  WebhookCreatePayload,\n  WebhookUpdatePayload,\n  InitializeNetworkOptions,\n  AddRemoteOptions,\n  RemoveRemoteOptions,\n  UpdateNetworkOptions,\n  ShardInitialization,\n  RenderTemplateParams,\n  RenderTemplateResponse,\n  ChatWorkspaceObject,\n  ChatWorkspacesQuery,\n  ChatWorkspacesResults,\n} from \"./types/index.js\";\nimport { ErrorStatusCode } from \"./types/index.js\";\nimport { HttpRequests } from \"./http-requests.js\";\nimport {\n  getHttpRequestsWithEnqueuedTaskPromise,\n  TaskClient,\n  type HttpRequestsWithEnqueuedTaskPromise,\n} from \"./task.js\";\nimport { BatchClient } from \"./batch.js\";\nimport { ChatWorkspace } from \"./chat-workspace.js\";\nimport { MeilisearchError } from \"./errors/index.js\";\n\nexport class Meilisearch {\n  config: Config;\n  httpRequest: HttpRequests;\n\n  readonly #taskClient: TaskClient;\n  get tasks() {\n    return this.#taskClient;\n  }\n\n  readonly #batchClient: BatchClient;\n  get batches() {\n    return this.#batchClient;\n  }\n\n  readonly #httpRequestsWithTask: HttpRequestsWithEnqueuedTaskPromise;\n\n  /**\n   * Creates new Meilisearch instance\n   *\n   * @param config - Configuration object\n   */\n  constructor(config: Config) {\n    this.config = config;\n    this.httpRequest = new HttpRequests(config);\n\n    this.#taskClient = new TaskClient(\n      this.httpRequest,\n      config.defaultWaitOptions,\n    );\n    this.#batchClient = new BatchClient(this.httpRequest);\n\n    this.#httpRequestsWithTask = getHttpRequestsWithEnqueuedTaskPromise(\n      this.httpRequest,\n      this.tasks,\n    );\n  }\n\n  /**\n   * Return an Index instance\n   *\n   * @param indexUid - The index UID\n   * @returns Instance of Index\n   */\n  index<T extends RecordAny = RecordAny>(indexUid: string): Index<T> {\n    return new Index<T>(this.config, indexUid);\n  }\n\n  /**\n   * Gather information about an index by calling Meilisearch and return an\n   * Index instance with the gathered information\n   *\n   * @param indexUid - The index UID\n   * @returns Promise returning Index instance\n   */\n  async getIndex<T extends RecordAny = RecordAny>(\n    indexUid: string,\n  ): Promise<Index<T>> {\n    return new Index<T>(this.config, indexUid).fetchInfo();\n  }\n\n  /**\n   * Gather information about an index by calling Meilisearch and return the raw\n   * JSON response\n   *\n   * @param indexUid - The index UID\n   * @returns Promise returning index information\n   */\n  async getRawIndex(indexUid: string): Promise<IndexObject> {\n    return new Index(this.config, indexUid).getRawInfo();\n  }\n\n  /**\n   * Get all the indexes as Index instances.\n   *\n   * @param parameters - Parameters to browse the indexes\n   * @returns Promise returning array of raw index information\n   */\n  async getIndexes(\n    parameters?: IndexesQuery,\n  ): Promise<IndexesResults<Index[]>> {\n    const rawIndexes = await this.getRawIndexes(parameters);\n    const indexes: Index[] = rawIndexes.results.map(\n      (index) => new Index(this.config, index.uid, index.primaryKey),\n    );\n    return { ...rawIndexes, results: indexes };\n  }\n\n  /**\n   * Get all the indexes in their raw value (no Index instances).\n   *\n   * @param parameters - Parameters to browse the indexes\n   * @returns Promise returning array of raw index information\n   */\n  async getRawIndexes(\n    parameters?: IndexesQuery,\n  ): Promise<IndexesResults<IndexObject[]>> {\n    return await this.httpRequest.get<IndexesResults<IndexObject[]>>({\n      path: \"indexes\",\n      params: parameters,\n    });\n  }\n\n  /**\n   * Create a new index\n   *\n   * @param uid - The index UID\n   * @param options - Index options\n   * @returns Promise returning Index instance\n   */\n  createIndex(uid: string, options?: IndexOptions): EnqueuedTaskPromise {\n    return Index.create(uid, options, this.config);\n  }\n\n  /**\n   * Update an index\n   *\n   * @param uid - The index UID\n   * @param options - Index options to update\n   * @returns Promise returning Index instance after updating\n   */\n  updateIndex(uid: string, options?: IndexOptions): EnqueuedTaskPromise {\n    return new Index(this.config, uid).update(options);\n  }\n\n  /**\n   * Delete an index\n   *\n   * @param uid - The index UID\n   * @returns Promise which resolves when index is deleted successfully\n   */\n  deleteIndex(uid: string): EnqueuedTaskPromise {\n    return new Index(this.config, uid).delete();\n  }\n\n  /**\n   * Deletes an index if it already exists.\n   *\n   * @param uid - The index UID\n   * @returns Promise which resolves to true when index exists and is deleted\n   *   successfully, otherwise false if it does not exist\n   */\n  async deleteIndexIfExists(uid: string): Promise<boolean> {\n    // The HTTP API accepts the deletion of an index that does not exist and\n    // enqueues a task that fails with `index_not_found`, so the outcome is only\n    // known once that task has been processed.\n    const task = await this.deleteIndex(uid).waitTask();\n\n    if (task.status === \"succeeded\") {\n      return true;\n    }\n\n    if (task.error?.code === ErrorStatusCode.INDEX_NOT_FOUND) {\n      return false;\n    }\n\n    throw new MeilisearchError(\n      task.error?.message ?? `Failed to delete index \\`${uid}\\`.`,\n    );\n  }\n\n  /**\n   * Swaps a list of index tuples.\n   *\n   * @param params - List of indexes tuples to swap.\n   * @returns Promise returning object of the enqueued task\n   */\n  swapIndexes(params: IndexSwap[]): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.post({\n      path: \"swap-indexes\",\n      body: params,\n    });\n  }\n\n  ///\n  /// Multi Search\n  ///\n\n  /**\n   * Perform multiple search queries.\n   *\n   * It is possible to make multiple search queries on the same index or on\n   * different ones. With network feature enabled, you can also search across\n   * remote instances.\n   *\n   * @example\n   *\n   * ```ts\n   * client.multiSearch({\n   *   queries: [\n   *     { indexUid: \"movies\", q: \"wonder\" },\n   *     { indexUid: \"books\", q: \"flower\" },\n   *   ],\n   * });\n   *\n   * // Federated search with remote instance (requires network feature enabled)\n   * client.multiSearch({\n   *   federation: {},\n   *   queries: [\n   *     {\n   *       indexUid: \"movies\",\n   *       q: \"wonder\",\n   *       federationOptions: {\n   *         remote: \"meilisearch instance name\",\n   *       },\n   *     },\n   *     {\n   *       indexUid: \"movies\",\n   *       q: \"wonder\",\n   *       federationOptions: {\n   *         remote: \"meilisearch instance name\",\n   *       },\n   *     },\n   *   ],\n   * });\n   * ```\n   *\n   * @param queries - Search queries\n   * @param extraRequestInit - Additional request configuration options\n   * @returns Promise containing the search responses\n   * @see {@link https://www.meilisearch.com/docs/learn/multi_search/implement_sharding#perform-a-search}\n   */\n  async multiSearch<\n    T1 extends MultiSearchParams | FederatedMultiSearchParams,\n    T2 extends RecordAny = RecordAny,\n  >(\n    queries: T1,\n    extraRequestInit?: ExtraRequestInit,\n  ): Promise<MultiSearchResponseOrSearchResponse<T1, T2>> {\n    return await this.httpRequest.post<\n      MultiSearchResponseOrSearchResponse<T1, T2>\n    >({\n      path: \"multi-search\",\n      body: queries,\n      extraRequestInit,\n    });\n  }\n\n  ///\n  /// CHATS\n  ///\n\n  /**\n   * Get a chat workspace instance\n   *\n   * @param workspace - The chat workspace UID\n   * @returns Instance of ChatWorkspace\n   */\n  chat(workspace: string): ChatWorkspace {\n    return new ChatWorkspace(this.httpRequest, workspace);\n  }\n\n  /**\n   * List all chat workspaces\n   *\n   * @param parameters - Parameters to paginate the chat workspaces\n   * @returns Promise returning a paginated list of chat workspaces\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/chats/list-chat-workspaces}\n   */\n  async getChatWorkspaces(\n    parameters?: ChatWorkspacesQuery,\n  ): Promise<ChatWorkspacesResults> {\n    return await this.httpRequest.get({\n      path: \"chats\",\n      params: parameters,\n    });\n  }\n\n  /**\n   * Get a chat workspace\n   *\n   * @param workspace - The chat workspace UID\n   * @returns Promise returning the chat workspace\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/chats/get-a-chat-workspace}\n   */\n  async getChatWorkspace(workspace: string): Promise<ChatWorkspaceObject> {\n    return await this.httpRequest.get({\n      path: `chats/${encodeURIComponent(workspace)}`,\n    });\n  }\n\n  /**\n   * Delete a chat workspace\n   *\n   * @param workspace - The chat workspace UID\n   * @returns Promise returning void\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/chats/delete-a-chat-workspace}\n   */\n  async deleteChatWorkspace(workspace: string): Promise<void> {\n    await this.httpRequest.delete({\n      path: `chats/${encodeURIComponent(workspace)}`,\n    });\n  }\n\n  ///\n  /// DYNAMIC SEARCH RULES\n  ///\n\n  /**\n   * Get all dynamic search rules\n   *\n   * @param parameters - Parameters to browse dynamic search rules\n   * @returns Promise returning an object with dynamic search rules\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/search-rules/list-search-rules}\n   */\n  async getDynamicSearchRules(\n    parameters?: SearchRuleListPayload,\n  ): Promise<ResourceResults<SearchRule[]>> {\n    return await this.httpRequest.post({\n      path: \"dynamic-search-rules\",\n      body: parameters ?? {},\n    });\n  }\n\n  /**\n   * Get a dynamic search rule\n   *\n   * @param uid - Dynamic search rule UID\n   * @returns Promise returning the dynamic search rule\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/search-rules/get-a-search-rule}\n   */\n  async getDynamicSearchRule(uid: string): Promise<SearchRule> {\n    return await this.httpRequest.get({\n      path: `dynamic-search-rules/${encodeURIComponent(uid)}`,\n    });\n  }\n\n  /**\n   * Update a dynamic search rule\n   *\n   * @param uid - Dynamic search rule UID\n   * @param rule - Partial search rule with pin and scale actions\n   * @returns Promise returning an enqueued task\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/search-rules/create-or-update-a-search-rule}\n   */\n  updateDynamicSearchRule(\n    uid: string,\n    rule: SearchRuleUpdatePayload,\n  ): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: `dynamic-search-rules/${encodeURIComponent(uid)}`,\n      body: rule,\n    });\n  }\n\n  /**\n   * Delete a dynamic search rule\n   *\n   * @param uid - Dynamic search rule UID\n   * @returns Promise returning an enqueued task\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/search-rules/delete-a-search-rule}\n   */\n  deleteDynamicSearchRule(uid: string): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: `dynamic-search-rules/${encodeURIComponent(uid)}`,\n    });\n  }\n\n  /**\n   * Delete all dynamic search rules\n   *\n   * @returns Promise returning an enqueued task\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/search-rules/delete-all-search-rules}\n   */\n  deleteAllDynamicSearchRules(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.delete({\n      path: \"dynamic-search-rules\",\n    });\n  }\n\n  ///\n  /// WEBHOOKS\n  ///\n\n  /**\n   * Get all webhooks\n   *\n   * @returns Promise returning an object with webhooks\n   */\n  async getWebhooks(): Promise<ResultsWrapper<Webhook[]>> {\n    return await this.httpRequest.get({ path: \"webhooks\" });\n  }\n\n  /**\n   * Get a webhook\n   *\n   * @param uuid - Webhook UUID\n   * @returns Promise returning the webhook\n   */\n  async getWebhook(uuid: string): Promise<Webhook> {\n    return await this.httpRequest.get({\n      path: `webhooks/${encodeURIComponent(uuid)}`,\n    });\n  }\n\n  /**\n   * Create a webhook\n   *\n   * @param webhook - Webhook to create\n   * @returns Promise returning the created webhook\n   */\n  async createWebhook(webhook: WebhookCreatePayload): Promise<Webhook> {\n    return await this.httpRequest.post({ path: \"webhooks\", body: webhook });\n  }\n\n  /**\n   * Update a webhook\n   *\n   * @param uuid - Webhook UUID\n   * @param webhook - Webhook to update\n   * @returns Promise returning the updated webhook\n   */\n  async updateWebhook(\n    uuid: string,\n    webhook: WebhookUpdatePayload,\n  ): Promise<Webhook> {\n    return await this.httpRequest.patch({\n      path: `webhooks/${encodeURIComponent(uuid)}`,\n      body: webhook,\n    });\n  }\n\n  /**\n   * Delete a webhook\n   *\n   * @param uuid - Webhook UUID\n   * @returns Promise returning void\n   */\n  async deleteWebhook(uuid: string): Promise<void> {\n    await this.httpRequest.delete({\n      path: `webhooks/${encodeURIComponent(uuid)}`,\n    });\n  }\n\n  ///\n  ///  Network\n  ///\n\n  #patchNetwork(body: UpdateNetworkOptions): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.patch({\n      path: \"network\",\n      body,\n    });\n  }\n\n  #validateInitializationShards(\n    remotes: Record<string, Remote>,\n    shards: Record<string, ShardInitialization>,\n  ): Record<string, { remotes: string[] }> {\n    const shardEntries = Object.entries(shards);\n\n    if (shardEntries.length === 0) {\n      throw new TypeError(\n        \"initializeNetwork requires at least one shard when leader is set.\",\n      );\n    }\n\n    const validated: Record<string, { remotes: string[] }> = {};\n\n    for (const [shardName, shard] of shardEntries) {\n      if (!Array.isArray(shard.remotes) || shard.remotes.length === 0) {\n        throw new TypeError(\n          `Shard \"${shardName}\" must have at least one remote.`,\n        );\n      }\n\n      const missingRemotes = shard.remotes.filter(\n        (remoteName) => remotes[remoteName] === undefined,\n      );\n\n      if (missingRemotes.length > 0) {\n        throw new TypeError(\n          `Shard \"${shardName}\" references unknown remotes: ${missingRemotes.join(\n            \", \",\n          )}`,\n        );\n      }\n\n      validated[shardName] = { remotes: [...shard.remotes] };\n    }\n\n    return validated;\n  }\n\n  /**\n   * Get the current network configuration.\n   *\n   * {@link https://www.meilisearch.com/docs/reference/api/network#get-the-network-object}\n   *\n   * @experimental\n   */\n  async getNetwork(): Promise<Network> {\n    return await this.httpRequest.get({ path: \"network\" });\n  }\n\n  /**\n   * Update the network configuration. Must be called on the leader instance\n   * when a leader is configured.\n   *\n   * When a leader is set, returns an enqueued `networkTopologyChange` task.\n   * When clearing the leader (or when no leader is set), returns the updated\n   * network object synchronously.\n   *\n   * {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}\n   *\n   * @param options - Network update options\n   * @returns Promise returning an enqueued task, or the updated network object\n   * @experimental\n   */\n  async updateNetwork(\n    options: UpdateNetworkOptions,\n  ): Promise<EnqueuedTask | Network> {\n    return await this.httpRequest.patch({\n      path: \"network\",\n      body: options,\n    });\n  }\n\n  /**\n   * Initialize a network with sharding enabled. This sets up the current\n   * instance as the leader and configures the initial set of remotes.\n   *\n   * {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}\n   *\n   * @param options - Network initialization options\n   * @returns Promise returning the enqueued task\n   * @experimental\n   */\n  initializeNetwork(options: InitializeNetworkOptions): EnqueuedTaskPromise {\n    const shards = this.#validateInitializationShards(\n      options.remotes,\n      options.shards,\n    );\n\n    return this.#patchNetwork({\n      self: options.self,\n      leader: options.self,\n      remotes: options.remotes,\n      shards,\n    });\n  }\n\n  /**\n   * Add a remote to the network. Must be called on the leader instance.\n   *\n   * {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}\n   *\n   * @param options - Options containing the remote name and configuration\n   * @returns Promise returning the enqueued task\n   * @experimental\n   */\n  addRemote(options: AddRemoteOptions): EnqueuedTaskPromise {\n    return this.#patchNetwork({\n      remotes: {\n        [options.name]: options.remote,\n      },\n    });\n  }\n\n  /**\n   * Remove a remote from the network. Must be called on the leader instance.\n   *\n   * {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}\n   *\n   * @param options - Options containing the remote name to remove\n   * @returns Promise returning the enqueued task\n   * @experimental\n   */\n  removeRemote(options: RemoveRemoteOptions): EnqueuedTaskPromise {\n    return this.#patchNetwork({\n      remotes: {\n        [options.name]: null,\n      },\n    });\n  }\n\n  /**\n   * Add remotes to a shard. Must be called on the leader instance.\n   *\n   * {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}\n   *\n   * @param shardName - Name of the shard to update\n   * @param remotes - Remotes to add\n   * @returns Promise returning the enqueued task\n   * @experimental\n   */\n  addRemotesToShard(shardName: string, remotes: string[]): EnqueuedTaskPromise {\n    return this.#patchNetwork({\n      shards: {\n        [shardName]: { addRemotes: remotes },\n      },\n    });\n  }\n\n  /**\n   * Remove remotes from a shard. Must be called on the leader instance.\n   *\n   * {@link https://www.meilisearch.com/docs/reference/api/network#update-the-network-object}\n   *\n   * @param shardName - Name of the shard to update\n   * @param remotes - Remotes to remove\n   * @returns Promise returning the enqueued task\n   * @experimental\n   */\n  removeRemotesFromShard(\n    shardName: string,\n    remotes: string[],\n  ): EnqueuedTaskPromise {\n    return this.#patchNetwork({\n      shards: {\n        [shardName]: { removeRemotes: remotes },\n      },\n    });\n  }\n\n  ///\n  /// KEYS\n  ///\n\n  /**\n   * Get all API keys\n   *\n   * @param parameters - Parameters to browse the indexes\n   * @returns Promise returning an object with keys\n   */\n  async getKeys(parameters?: KeysQuery): Promise<KeysResults> {\n    const keys = await this.httpRequest.get<KeysResults>({\n      path: \"keys\",\n      params: parameters,\n    });\n\n    keys.results = keys.results.map((key) => ({\n      ...key,\n      createdAt: new Date(key.createdAt),\n      updatedAt: new Date(key.updatedAt),\n    }));\n\n    return keys;\n  }\n\n  /**\n   * Get one API key\n   *\n   * @param keyOrUid - Key or uid of the API key\n   * @returns Promise returning a key\n   */\n  async getKey(keyOrUid: string): Promise<Key> {\n    return await this.httpRequest.get<Key>({\n      path: `keys/${encodeURIComponent(keyOrUid)}`,\n    });\n  }\n\n  /**\n   * Create one API key\n   *\n   * @param options - Key options\n   * @returns Promise returning a key\n   */\n  async createKey(options: KeyCreation): Promise<Key> {\n    return await this.httpRequest.post<Key>({\n      path: \"keys\",\n      body: options,\n    });\n  }\n\n  /**\n   * Update one API key\n   *\n   * @param keyOrUid - Key\n   * @param options - Key options\n   * @returns Promise returning a key\n   */\n  async updateKey(keyOrUid: string, options: KeyUpdate): Promise<Key> {\n    return await this.httpRequest.patch<Key>({\n      path: `keys/${encodeURIComponent(keyOrUid)}`,\n      body: options,\n    });\n  }\n\n  /**\n   * Delete one API key\n   *\n   * @param keyOrUid - Key\n   * @returns\n   */\n  async deleteKey(keyOrUid: string): Promise<void> {\n    await this.httpRequest.delete({\n      path: `keys/${encodeURIComponent(keyOrUid)}`,\n    });\n  }\n\n  ///\n  /// HEALTH\n  ///\n\n  /**\n   * Checks if the server is healthy, otherwise an error will be thrown.\n   *\n   * @returns Promise returning an object with health details\n   */\n  async health(): Promise<Health> {\n    return await this.httpRequest.get<Health>({ path: \"health\" });\n  }\n\n  /**\n   * Checks if the server is healthy, return true or false.\n   *\n   * @returns Promise returning a boolean\n   */\n  async isHealthy(): Promise<boolean> {\n    try {\n      const { status } = await this.health();\n      return status === \"available\";\n    } catch {\n      return false;\n    }\n  }\n\n  ///\n  /// STATS\n  ///\n\n  /**\n   * Get stats of the instance and its indexes\n   *\n   * Size fields are numbers of bytes by default. `sizeFormat: \"human\"` returns\n   * them as strings with units, such as `\"19.64 MiB\"`.\n   * `showInternalDatabaseSizes` adds each index's internal database sizes.\n   *\n   * @typeParam Q - Stats query whose `sizeFormat` selects the size field type\n   * @param params - Internal database sizes and size formatting\n   * @returns Promise containing stats of the instance\n   * @see {@link https://www.meilisearch.com/docs/reference/api/stats/get-stats-of-all-indexes}\n   */\n  async getStats<const Q extends StatsQuery | undefined = undefined>(\n    params?: Q,\n  ): Promise<Stats<Q>> {\n    return await this.httpRequest.get<Stats<Q>>({ path: \"stats\", params });\n  }\n\n  ///\n  /// VERSION\n  ///\n\n  /**\n   * Get the version of Meilisearch\n   *\n   * @returns Promise returning object with version details\n   */\n  async getVersion(): Promise<Version> {\n    return await this.httpRequest.get<Version>({ path: \"version\" });\n  }\n\n  ///\n  /// DUMPS\n  ///\n\n  /**\n   * Creates a dump\n   *\n   * @returns Promise returning object of the enqueued task\n   */\n  createDump(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.post({\n      path: \"dumps\",\n    });\n  }\n\n  ///\n  /// SNAPSHOTS\n  ///\n\n  /**\n   * Creates a snapshot\n   *\n   * @returns Promise returning object of the enqueued task\n   */\n  createSnapshot(): EnqueuedTaskPromise {\n    return this.#httpRequestsWithTask.post({\n      path: \"snapshots\",\n    });\n  }\n\n  ///\n  /// RENDER TEMPLATE\n  ///\n\n  /**\n   * Render a template by injecting the given input.\n   *\n   * This is an experimental feature. Enable the `renderRoute` experimental\n   * feature via {@link Meilisearch.updateExperimentalFeatures} before calling\n   * it.\n   *\n   * @param params - Template/fragment to render and the input to inject\n   * @returns Promise returning the unrendered template and the rendered result\n   * @experimental\n   * @see {@link https://www.meilisearch.com/docs/reference/api/template/render-documents-with-post}\n   */\n  async renderTemplate(\n    params: RenderTemplateParams,\n  ): Promise<RenderTemplateResponse> {\n    return await this.httpRequest.post<RenderTemplateResponse>({\n      path: \"render-template\",\n      body: params,\n    });\n  }\n\n  ///\n  /// EXPERIMENTAL-FEATURES\n  ///\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/experimental_features#get-all-experimental-features} */\n  async getExperimentalFeatures(): Promise<RuntimeTogglableFeatures> {\n    return await this.httpRequest.get({\n      path: \"experimental-features\",\n    });\n  }\n\n  /** {@link https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features} */\n  async updateExperimentalFeatures(\n    runtimeTogglableFeatures: RuntimeTogglableFeatures,\n  ): Promise<RuntimeTogglableFeatures> {\n    return await this.httpRequest.patch({\n      path: \"experimental-features\",\n      body: runtimeTogglableFeatures,\n    });\n  }\n}\n"]}