Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

meilisearch

Package Overview
Dependencies
Maintainers
4
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meilisearch - npm Package Compare versions

Comparing version 0.39.0 to 0.40.0

2

dist/bundles/meilisearch.esm.min.js

@@ -1,2 +0,2 @@

import{createHmac as t}from"crypto";const e={ALL:"all",LAST:"last"},s={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},i={TASK_SUCCEEDED:"succeeded",TASK_PROCESSING:"processing",TASK_FAILED:"failed",TASK_ENQUEUED:"enqueued",TASK_CANCELED:"canceled"},n={DOCUMENTS_ADDITION_OR_UPDATE:"documentAdditionOrUpdate",DOCUMENT_DELETION:"documentDeletion",DUMP_CREATION:"dumpCreation",INDEX_CREATION:"indexCreation",INDEX_DELETION:"indexDeletion",INDEXES_SWAP:"indexSwap",INDEX_UPDATE:"indexUpdate",SETTINGS_UPDATE:"settingsUpdate",SNAPSHOT_CREATION:"snapshotCreation",TASK_CANCELATION:"taskCancelation",TASK_DELETION:"taskDeletion"},a={INDEX_CREATION_FAILED:"index_creation_failed",MISSING_INDEX_UID:"missing_index_uid",INDEX_ALREADY_EXISTS:"index_already_exists",INDEX_NOT_FOUND:"index_not_found",INVALID_INDEX_UID:"invalid_index_uid",INDEX_NOT_ACCESSIBLE:"index_not_accessible",INVALID_INDEX_OFFSET:"invalid_index_offset",INVALID_INDEX_LIMIT:"invalid_index_limit",INVALID_STATE:"invalid_state",PRIMARY_KEY_INFERENCE_FAILED:"primary_key_inference_failed",INDEX_PRIMARY_KEY_ALREADY_EXISTS:"index_primary_key_already_exists",INVALID_INDEX_PRIMARY_KEY:"invalid_index_primary_key",DOCUMENTS_FIELDS_LIMIT_REACHED:"document_fields_limit_reached",MISSING_DOCUMENT_ID:"missing_document_id",INVALID_DOCUMENT_ID:"invalid_document_id",INVALID_CONTENT_TYPE:"invalid_content_type",MISSING_CONTENT_TYPE:"missing_content_type",INVALID_DOCUMENT_FIELDS:"invalid_document_fields",INVALID_DOCUMENT_LIMIT:"invalid_document_limit",INVALID_DOCUMENT_OFFSET:"invalid_document_offset",INVALID_DOCUMENT_FILTER:"invalid_document_filter",MISSING_DOCUMENT_FILTER:"missing_document_filter",INVALID_DOCUMENT_VECTORS_FIELD:"invalid_document_vectors_field",PAYLOAD_TOO_LARGE:"payload_too_large",MISSING_PAYLOAD:"missing_payload",MALFORMED_PAYLOAD:"malformed_payload",NO_SPACE_LEFT_ON_DEVICE:"no_space_left_on_device",INVALID_STORE_FILE:"invalid_store_file",INVALID_RANKING_RULES:"missing_document_id",INVALID_REQUEST:"invalid_request",INVALID_DOCUMENT_GEO_FIELD:"invalid_document_geo_field",INVALID_SEARCH_Q:"invalid_search_q",INVALID_SEARCH_OFFSET:"invalid_search_offset",INVALID_SEARCH_LIMIT:"invalid_search_limit",INVALID_SEARCH_PAGE:"invalid_search_page",INVALID_SEARCH_HITS_PER_PAGE:"invalid_search_hits_per_page",INVALID_SEARCH_ATTRIBUTES_TO_RETRIEVE:"invalid_search_attributes_to_retrieve",INVALID_SEARCH_ATTRIBUTES_TO_CROP:"invalid_search_attributes_to_crop",INVALID_SEARCH_CROP_LENGTH:"invalid_search_crop_length",INVALID_SEARCH_ATTRIBUTES_TO_HIGHLIGHT:"invalid_search_attributes_to_highlight",INVALID_SEARCH_SHOW_MATCHES_POSITION:"invalid_search_show_matches_position",INVALID_SEARCH_FILTER:"invalid_search_filter",INVALID_SEARCH_SORT:"invalid_search_sort",INVALID_SEARCH_FACETS:"invalid_search_facets",INVALID_SEARCH_HIGHLIGHT_PRE_TAG:"invalid_search_highlight_pre_tag",INVALID_SEARCH_HIGHLIGHT_POST_TAG:"invalid_search_highlight_post_tag",INVALID_SEARCH_CROP_MARKER:"invalid_search_crop_marker",INVALID_SEARCH_MATCHING_STRATEGY:"invalid_search_matching_strategy",INVALID_SEARCH_VECTOR:"invalid_search_vector",INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON:"invalid_search_attributes_to_search_on",BAD_REQUEST:"bad_request",DOCUMENT_NOT_FOUND:"document_not_found",INTERNAL:"internal",INVALID_API_KEY:"invalid_api_key",INVALID_API_KEY_DESCRIPTION:"invalid_api_key_description",INVALID_API_KEY_ACTIONS:"invalid_api_key_actions",INVALID_API_KEY_INDEXES:"invalid_api_key_indexes",INVALID_API_KEY_EXPIRES_AT:"invalid_api_key_expires_at",API_KEY_NOT_FOUND:"api_key_not_found",IMMUTABLE_API_KEY_UID:"immutable_api_key_uid",IMMUTABLE_API_KEY_ACTIONS:"immutable_api_key_actions",IMMUTABLE_API_KEY_INDEXES:"immutable_api_key_indexes",IMMUTABLE_API_KEY_EXPIRES_AT:"immutable_api_key_expires_at",IMMUTABLE_API_KEY_CREATED_AT:"immutable_api_key_created_at",IMMUTABLE_API_KEY_UPDATED_AT:"immutable_api_key_updated_at",MISSING_AUTHORIZATION_HEADER:"missing_authorization_header",UNRETRIEVABLE_DOCUMENT:"unretrievable_document",MAX_DATABASE_SIZE_LIMIT_REACHED:"database_size_limit_reached",TASK_NOT_FOUND:"task_not_found",DUMP_PROCESS_FAILED:"dump_process_failed",DUMP_NOT_FOUND:"dump_not_found",INVALID_SWAP_DUPLICATE_INDEX_FOUND:"invalid_swap_duplicate_index_found",INVALID_SWAP_INDEXES:"invalid_swap_indexes",MISSING_SWAP_INDEXES:"missing_swap_indexes",MISSING_MASTER_KEY:"missing_master_key",INVALID_TASK_TYPES:"invalid_task_types",INVALID_TASK_UIDS:"invalid_task_uids",INVALID_TASK_STATUSES:"invalid_task_statuses",INVALID_TASK_LIMIT:"invalid_task_limit",INVALID_TASK_FROM:"invalid_task_from",INVALID_TASK_CANCELED_BY:"invalid_task_canceled_by",MISSING_TASK_FILTERS:"missing_task_filters",TOO_MANY_OPEN_FILES:"too_many_open_files",IO_ERROR:"io_error",INVALID_TASK_INDEX_UIDS:"invalid_task_index_uids",IMMUTABLE_INDEX_UID:"immutable_index_uid",IMMUTABLE_INDEX_CREATED_AT:"immutable_index_created_at",IMMUTABLE_INDEX_UPDATED_AT:"immutable_index_updated_at",INVALID_SETTINGS_DISPLAYED_ATTRIBUTES:"invalid_settings_displayed_attributes",INVALID_SETTINGS_SEARCHABLE_ATTRIBUTES:"invalid_settings_searchable_attributes",INVALID_SETTINGS_FILTERABLE_ATTRIBUTES:"invalid_settings_filterable_attributes",INVALID_SETTINGS_SORTABLE_ATTRIBUTES:"invalid_settings_sortable_attributes",INVALID_SETTINGS_RANKING_RULES:"invalid_settings_ranking_rules",INVALID_SETTINGS_STOP_WORDS:"invalid_settings_stop_words",INVALID_SETTINGS_SYNONYMS:"invalid_settings_synonyms",INVALID_SETTINGS_DISTINCT_ATTRIBUTE:"invalid_settings_distinct_attribute",INVALID_SETTINGS_TYPO_TOLERANCE:"invalid_settings_typo_tolerance",INVALID_SETTINGS_FACETING:"invalid_settings_faceting",INVALID_SETTINGS_PAGINATION:"invalid_settings_pagination",INVALID_SETTINGS_SEARCH_CUTOFF_MS:"invalid_settings_search_cutoff_ms",INVALID_TASK_BEFORE_ENQUEUED_AT:"invalid_task_before_enqueued_at",INVALID_TASK_AFTER_ENQUEUED_AT:"invalid_task_after_enqueued_at",INVALID_TASK_BEFORE_STARTED_AT:"invalid_task_before_started_at",INVALID_TASK_AFTER_STARTED_AT:"invalid_task_after_started_at",INVALID_TASK_BEFORE_FINISHED_AT:"invalid_task_before_finished_at",INVALID_TASK_AFTER_FINISHED_AT:"invalid_task_after_finished_at",MISSING_API_KEY_ACTIONS:"missing_api_key_actions",MISSING_API_KEY_INDEXES:"missing_api_key_indexes",MISSING_API_KEY_EXPIRES_AT:"missing_api_key_expires_at",INVALID_API_KEY_LIMIT:"invalid_api_key_limit",INVALID_API_KEY_OFFSET:"invalid_api_key_offset",INVALID_FACET_SEARCH_FACET_NAME:"invalid_facet_search_facet_name",MISSING_FACET_SEARCH_FACET_NAME:"missing_facet_search_facet_name",INVALID_FACET_SEARCH_FACET_QUERY:"invalid_facet_search_facet_query"};class r extends Error{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype),this.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(this,r)}}class u extends r{statusCode;errno;code;stack;constructor(t,e,s,i){super(t),Object.setPrototypeOf(this,u.prototype),this.name="MeiliSearchCommunicationError",e instanceof Response&&(this.message=e.statusText,this.statusCode=e.status),e instanceof Error&&(this.errno=e.errno,this.code=e.code),i?(this.stack=i,this.stack=this.stack?.replace(/(TypeError|FetchError)/,this.name),this.stack=this.stack?.replace("Failed to fetch",`request to ${s} failed, reason: connect ECONNREFUSED`),this.stack=this.stack?.replace("Not Found",`Not Found: ${s}`)):Error.captureStackTrace&&Error.captureStackTrace(this,u)}}const o=class extends r{httpStatus;code;link;type;stack;constructor(t,e){super(t.message),Object.setPrototypeOf(this,o.prototype),this.name="MeiliSearchApiError",this.code=t.code,this.type=t.type,this.link=t.link,this.message=t.message,this.httpStatus=e,Error.captureStackTrace&&Error.captureStackTrace(this,o)}};async function c(t){if(!t.ok){let e;try{e=await t.json()}catch(e){throw new u(t.statusText,t,t.url)}throw new o(e,t.status)}return t}function d(t,e,s){if("MeiliSearchApiError"!==t.name)throw new u(t.message,t,s,e);throw t}class _ extends r{constructor(t){super(t),Object.setPrototypeOf(this,_.prototype),this.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(this,_)}}function h(t,e){return`${t}\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ${e} call requires.`}function p(t){return Object.entries(t).reduce(((t,e)=>{const[s,i]=e;return void 0!==i&&(t[s]=i),t}),{})}async function A(t){return await new Promise((e=>setTimeout(e,t)))}function l(t){return Object.keys(t).reduce(((e,s)=>{const i=t[s];return void 0===i?e:Array.isArray(i)?{...e,[s]:i.join(",")}:i instanceof Date?{...e,[s]:i.toISOString()}:{...e,[s]:i}}),{})}function I(t){const e="X-Meilisearch-Client",s="Meilisearch JavaScript (v0.39.0)",i=function(t){if(Array.isArray(t))return t.reduce(((t,e)=>(t[e[0]]=e[1],t)),{});if("has"in t){const e={};return t.forEach(((t,s)=>e[s]=t)),e}return Object.assign({},t)}(t.requestConfig?.headers??{});if(t.apiKey&&!i.Authorization&&(i.Authorization=`Bearer ${t.apiKey}`),i["Content-Type"]||(i["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){const n=t.clientAgents.concat(s);i[e]=n.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new r(`Meilisearch: The header "${e}" should be an array of string(s).\n`);i[e]=s}return i}class T{headers;url;requestConfig;httpClient;requestTimeout;constructor(t){this.headers=I(t),this.requestConfig=t.requestConfig,this.httpClient=t.httpClient,this.requestTimeout=t.timeout;try{const e=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:`http://${t}`}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new r("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new r("The provided host is not valid.")}}async request({method:t,url:e,params:s,body:i,config:n={}}){"undefined"==typeof fetch&&require("cross-fetch/polyfill");const a=new URL(e,this.url);if(s){const t=new URLSearchParams;Object.keys(s).filter((t=>null!==s[t])).map((e=>t.set(e,s[e]))),a.search=t.toString()}n.headers?.["Content-Type"]||(i=JSON.stringify(i));const r={...this.headers,...n.headers};try{const e=this.fetchWithTimeout(a.toString(),{...n,...this.requestConfig,method:t,body:i,headers:r},this.requestTimeout);if(this.httpClient)return await e;const s=await e.then((t=>c(t)));return await s.json().catch((()=>{}))}catch(t){d(t,t.stack,a.toString())}}async fetchWithTimeout(t,e,s){return new Promise(((i,n)=>{const a=[(this.httpClient?this.httpClient:fetch)(t,e)];let r;if(s){const t=new Promise(((t,e)=>{r=setTimeout((()=>{e(new Error("Error: Request Timed Out"))}),s)}));a.push(t)}Promise.race(a).then(i).catch(n).finally((()=>{clearTimeout(r)}))}))}async get(t,e,s){return await this.request({method:"GET",url:t,params:e,config:s})}async post(t,e,s,i){return await this.request({method:"POST",url:t,body:e,params:s,config:i})}async put(t,e,s,i){return await this.request({method:"PUT",url:t,body:e,params:s,config:i})}async patch(t,e,s,i){return await this.request({method:"PATCH",url:t,body:e,params:s,config:i})}async delete(t,e,s,i){return await this.request({method:"DELETE",url:t,body:e,params:s,config:i})}}class y{taskUid;indexUid;status;type;enqueuedAt;constructor(t){this.taskUid=t.taskUid,this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.enqueuedAt=new Date(t.enqueuedAt)}}class E{indexUid;status;type;uid;canceledBy;details;error;duration;startedAt;enqueuedAt;finishedAt;constructor(t){this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.uid=t.uid,this.details=t.details,this.canceledBy=t.canceledBy,this.error=t.error,this.duration=t.duration,this.startedAt=new Date(t.startedAt),this.enqueuedAt=new Date(t.enqueuedAt),this.finishedAt=new Date(t.finishedAt)}}class g{httpRequest;constructor(t){this.httpRequest=new T(t)}async getTask(t){const e=`tasks/${t}`,s=await this.httpRequest.get(e);return new E(s)}async getTasks(t={}){const e=await this.httpRequest.get("tasks",l(t));return{...e,results:e.results.map((t=>new E(t)))}}async waitForTask(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){const n=Date.now();for(;Date.now()-n<e;){const e=await this.getTask(t);if(![i.TASK_ENQUEUED,i.TASK_PROCESSING].includes(e.status))return e;await A(s)}throw new _(`timeout of ${e}ms has exceeded on process ${t} when waiting a task to be resolved.`)}async waitForTasks(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){const i=[];for(const n of t){const t=await this.waitForTask(n,{timeOutMs:e,intervalMs:s});i.push(t)}return i}async cancelTasks(t={}){const e=await this.httpRequest.post("tasks/cancel",{},l(t));return new y(e)}async deleteTasks(t={}){const e=await this.httpRequest.delete("tasks",{},l(t));return new y(e)}}class w{uid;primaryKey;createdAt;updatedAt;httpRequest;tasks;constructor(t,e,s){this.uid=e,this.primaryKey=s,this.httpRequest=new T(t),this.tasks=new g(t)}async search(t,e,s){const i=`indexes/${this.uid}/search`;return await this.httpRequest.post(i,p({q:t,...e}),void 0,s)}async searchGet(t,e,s){const i=`indexes/${this.uid}/search`,n={q:t,...e,filter:(t=>{if("string"==typeof t)return t;if(Array.isArray(t))throw new r("The filter query parameter should be in string format when using searchGet")})(e?.filter),sort:e?.sort?.join(","),facets:e?.facets?.join(","),attributesToRetrieve:e?.attributesToRetrieve?.join(","),attributesToCrop:e?.attributesToCrop?.join(","),attributesToHighlight:e?.attributesToHighlight?.join(","),vector:e?.vector?.join(","),attributesToSearchOn:e?.attributesToSearchOn?.join(",")};return await this.httpRequest.get(i,p(n),s)}async searchForFacetValues(t,e){const s=`indexes/${this.uid}/facet-search`;return await this.httpRequest.post(s,p(t),void 0,e)}async getRawInfo(){const t=`indexes/${this.uid}`,e=await this.httpRequest.get(t);return this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),e}async fetchInfo(){return await this.getRawInfo(),this}async fetchPrimaryKey(){return this.primaryKey=(await this.getRawInfo()).primaryKey,this.primaryKey}static async create(t,e={},s){const i=new T(s),n=await i.post("indexes",{...e,uid:t});return new y(n)}async update(t){const e=`indexes/${this.uid}`,s=await this.httpRequest.patch(e,t);return s.enqueuedAt=new Date(s.enqueuedAt),s}async delete(){const t=`indexes/${this.uid}`,e=await this.httpRequest.delete(t);return new y(e)}async getTasks(t={}){return await this.tasks.getTasks({...t,indexUids:[this.uid]})}async getTask(t){return await this.tasks.getTask(t)}async waitForTasks(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){return await this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:s})}async waitForTask(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){return await this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:s})}async getStats(){const t=`indexes/${this.uid}/stats`;return await this.httpRequest.get(t)}async getDocuments(t={}){if(void 0===(t=p(t)).filter){const e=`indexes/${this.uid}/documents`,s=Array.isArray(t?.fields)?{fields:t?.fields?.join(",")}:{};return await this.httpRequest.get(e,{...t,...s})}try{const e=`indexes/${this.uid}/documents/fetch`;return await this.httpRequest.post(e,t)}catch(t){throw(t instanceof u||t instanceof o)&&(t.message=h(t.message,"getDocuments")),t}}async getDocument(t,e){const s=`indexes/${this.uid}/documents/${t}`,i=(()=>{if(Array.isArray(e?.fields))return e?.fields?.join(",")})();return await this.httpRequest.get(s,p({...e,fields:i}))}async addDocuments(t,e){const s=`indexes/${this.uid}/documents`,i=await this.httpRequest.post(s,t,e);return new y(i)}async addDocumentsFromString(t,e,s){const i=`indexes/${this.uid}/documents`,n=await this.httpRequest.post(i,t,s,{headers:{"Content-Type":e}});return new y(n)}async addDocumentsInBatches(t,e=1e3,s){const i=[];for(let n=0;n<t.length;n+=e)i.push(await this.addDocuments(t.slice(n,n+e),s));return i}async updateDocuments(t,e){const s=`indexes/${this.uid}/documents`,i=await this.httpRequest.put(s,t,e);return new y(i)}async updateDocumentsInBatches(t,e=1e3,s){const i=[];for(let n=0;n<t.length;n+=e)i.push(await this.updateDocuments(t.slice(n,n+e),s));return i}async updateDocumentsFromString(t,e,s){const i=`indexes/${this.uid}/documents`,n=await this.httpRequest.put(i,t,s,{headers:{"Content-Type":e}});return new y(n)}async deleteDocument(t){const e=`indexes/${this.uid}/documents/${t}`,s=await this.httpRequest.delete(e);return s.enqueuedAt=new Date(s.enqueuedAt),s}async deleteDocuments(t){const e=!Array.isArray(t)&&"object"==typeof t,s=e?"documents/delete":"documents/delete-batch",i=`indexes/${this.uid}/${s}`;try{const e=await this.httpRequest.post(i,t);return new y(e)}catch(t){throw(t instanceof u&&e||t instanceof o)&&(t.message=h(t.message,"deleteDocuments")),t}}async deleteAllDocuments(){const t=`indexes/${this.uid}/documents`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getSettings(){const t=`indexes/${this.uid}/settings`;return await this.httpRequest.get(t)}async updateSettings(t){const e=`indexes/${this.uid}/settings`,s=await this.httpRequest.patch(e,t);return s.enqueued=new Date(s.enqueuedAt),s}async resetSettings(){const t=`indexes/${this.uid}/settings`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getPagination(){const t=`indexes/${this.uid}/settings/pagination`;return await this.httpRequest.get(t)}async updatePagination(t){const e=`indexes/${this.uid}/settings/pagination`,s=await this.httpRequest.patch(e,t);return new y(s)}async resetPagination(){const t=`indexes/${this.uid}/settings/pagination`,e=await this.httpRequest.delete(t);return new y(e)}async getSynonyms(){const t=`indexes/${this.uid}/settings/synonyms`;return await this.httpRequest.get(t)}async updateSynonyms(t){const e=`indexes/${this.uid}/settings/synonyms`,s=await this.httpRequest.put(e,t);return new y(s)}async resetSynonyms(){const t=`indexes/${this.uid}/settings/synonyms`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getStopWords(){const t=`indexes/${this.uid}/settings/stop-words`;return await this.httpRequest.get(t)}async updateStopWords(t){const e=`indexes/${this.uid}/settings/stop-words`,s=await this.httpRequest.put(e,t);return new y(s)}async resetStopWords(){const t=`indexes/${this.uid}/settings/stop-words`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getRankingRules(){const t=`indexes/${this.uid}/settings/ranking-rules`;return await this.httpRequest.get(t)}async updateRankingRules(t){const e=`indexes/${this.uid}/settings/ranking-rules`,s=await this.httpRequest.put(e,t);return new y(s)}async resetRankingRules(){const t=`indexes/${this.uid}/settings/ranking-rules`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getDistinctAttribute(){const t=`indexes/${this.uid}/settings/distinct-attribute`;return await this.httpRequest.get(t)}async updateDistinctAttribute(t){const e=`indexes/${this.uid}/settings/distinct-attribute`,s=await this.httpRequest.put(e,t);return new y(s)}async resetDistinctAttribute(){const t=`indexes/${this.uid}/settings/distinct-attribute`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getFilterableAttributes(){const t=`indexes/${this.uid}/settings/filterable-attributes`;return await this.httpRequest.get(t)}async updateFilterableAttributes(t){const e=`indexes/${this.uid}/settings/filterable-attributes`,s=await this.httpRequest.put(e,t);return new y(s)}async resetFilterableAttributes(){const t=`indexes/${this.uid}/settings/filterable-attributes`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getSortableAttributes(){const t=`indexes/${this.uid}/settings/sortable-attributes`;return await this.httpRequest.get(t)}async updateSortableAttributes(t){const e=`indexes/${this.uid}/settings/sortable-attributes`,s=await this.httpRequest.put(e,t);return new y(s)}async resetSortableAttributes(){const t=`indexes/${this.uid}/settings/sortable-attributes`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getSearchableAttributes(){const t=`indexes/${this.uid}/settings/searchable-attributes`;return await this.httpRequest.get(t)}async updateSearchableAttributes(t){const e=`indexes/${this.uid}/settings/searchable-attributes`,s=await this.httpRequest.put(e,t);return new y(s)}async resetSearchableAttributes(){const t=`indexes/${this.uid}/settings/searchable-attributes`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getDisplayedAttributes(){const t=`indexes/${this.uid}/settings/displayed-attributes`;return await this.httpRequest.get(t)}async updateDisplayedAttributes(t){const e=`indexes/${this.uid}/settings/displayed-attributes`,s=await this.httpRequest.put(e,t);return new y(s)}async resetDisplayedAttributes(){const t=`indexes/${this.uid}/settings/displayed-attributes`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getTypoTolerance(){const t=`indexes/${this.uid}/settings/typo-tolerance`;return await this.httpRequest.get(t)}async updateTypoTolerance(t){const e=`indexes/${this.uid}/settings/typo-tolerance`,s=await this.httpRequest.patch(e,t);return s.enqueuedAt=new Date(s.enqueuedAt),s}async resetTypoTolerance(){const t=`indexes/${this.uid}/settings/typo-tolerance`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getFaceting(){const t=`indexes/${this.uid}/settings/faceting`;return await this.httpRequest.get(t)}async updateFaceting(t){const e=`indexes/${this.uid}/settings/faceting`,s=await this.httpRequest.patch(e,t);return new y(s)}async resetFaceting(){const t=`indexes/${this.uid}/settings/faceting`,e=await this.httpRequest.delete(t);return new y(e)}async getSeparatorTokens(){const t=`indexes/${this.uid}/settings/separator-tokens`;return await this.httpRequest.get(t)}async updateSeparatorTokens(t){const e=`indexes/${this.uid}/settings/separator-tokens`,s=await this.httpRequest.put(e,t);return new y(s)}async resetSeparatorTokens(){const t=`indexes/${this.uid}/settings/separator-tokens`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getNonSeparatorTokens(){const t=`indexes/${this.uid}/settings/non-separator-tokens`;return await this.httpRequest.get(t)}async updateNonSeparatorTokens(t){const e=`indexes/${this.uid}/settings/non-separator-tokens`,s=await this.httpRequest.put(e,t);return new y(s)}async resetNonSeparatorTokens(){const t=`indexes/${this.uid}/settings/non-separator-tokens`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getDictionary(){const t=`indexes/${this.uid}/settings/dictionary`;return await this.httpRequest.get(t)}async updateDictionary(t){const e=`indexes/${this.uid}/settings/dictionary`,s=await this.httpRequest.put(e,t);return new y(s)}async resetDictionary(){const t=`indexes/${this.uid}/settings/dictionary`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getProximityPrecision(){const t=`indexes/${this.uid}/settings/proximity-precision`;return await this.httpRequest.get(t)}async updateProximityPrecision(t){const e=`indexes/${this.uid}/settings/proximity-precision`,s=await this.httpRequest.put(e,t);return new y(s)}async resetProximityPrecision(){const t=`indexes/${this.uid}/settings/proximity-precision`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getEmbedders(){const t=`indexes/${this.uid}/settings/embedders`;return await this.httpRequest.get(t)}async updateEmbedders(t){const e=`indexes/${this.uid}/settings/embedders`,s=await this.httpRequest.patch(e,t);return new y(s)}async resetEmbedders(){const t=`indexes/${this.uid}/settings/embedders`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getSearchCutoffMs(){const t=`indexes/${this.uid}/settings/search-cutoff-ms`;return await this.httpRequest.get(t)}async updateSearchCutoffMs(t){const e=`indexes/${this.uid}/settings/search-cutoff-ms`,s=await this.httpRequest.put(e,t);return new y(s)}async resetSearchCutoffMs(){const t=`indexes/${this.uid}/settings/search-cutoff-ms`,e=await this.httpRequest.delete(t);return new y(e)}}function S(t){return Buffer.from(JSON.stringify(t)).toString("base64")}class D{config;constructor(t){this.config=t}generateTenantToken(e,s,i){const n=i?.apiKey||this.config.apiKey||"",a=e||"",u=i?.expiresAt;!function(t){const{searchRules:e,uid:s,apiKey:i,expiresAt:n}=t;if(n){if(!(n instanceof Date))throw new r("Meilisearch: The expiredAt field must be an instance of Date.");if(n.getTime()<Date.now())throw new r("Meilisearch: The expiresAt field must be a date in the future.")}if(e&&"object"!=typeof e&&!Array.isArray(e))throw new r("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!i||"string"!=typeof i)throw new r("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!s||"string"!=typeof s)throw new r("Meilisearch: The uid of the api key used for the token generation must exist, be of type string and comply to the uuid4 format.");if(!/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(s))throw new r("Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().")}({apiKey:n,uid:a,expiresAt:u,searchRules:s});const o=S({alg:"HS256",typ:"JWT"}).replace(/=/g,""),c=function(t){const{searchRules:e,uid:s,expiresAt:i}=t;return S({searchRules:e,apiKeyUid:s,exp:i?Math.floor(i.getTime()/1e3):void 0}).replace(/=/g,"")}({searchRules:s,uid:a,expiresAt:u}),d=function(e,s,i){return t("sha256",e).update(`${s}.${i}`).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(n,o,c);return`${o}.${c}.${d}`}}class R extends class{config;httpRequest;tasks;constructor(t){this.config=t,this.httpRequest=new T(t),this.tasks=new g(t)}index(t){return new w(this.config,t)}async getIndex(t){return new w(this.config,t).fetchInfo()}async getRawIndex(t){return new w(this.config,t).getRawInfo()}async getIndexes(t={}){const e=await this.getRawIndexes(t),s=e.results.map((t=>new w(this.config,t.uid,t.primaryKey)));return{...e,results:s}}async getRawIndexes(t={}){return await this.httpRequest.get("indexes",t)}async createIndex(t,e={}){return await w.create(t,e,this.config)}async updateIndex(t,e={}){return await new w(this.config,t).update(e)}async deleteIndex(t){return await new w(this.config,t).delete()}async deleteIndexIfExists(t){try{return await this.deleteIndex(t),!0}catch(t){if(t.code===a.INDEX_NOT_FOUND)return!1;throw t}}async swapIndexes(t){return await this.httpRequest.post("/swap-indexes",t)}async multiSearch(t,e){return await this.httpRequest.post("multi-search",t,void 0,e)}async getTasks(t={}){return await this.tasks.getTasks(t)}async getTask(t){return await this.tasks.getTask(t)}async waitForTasks(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){return await this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:s})}async waitForTask(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){return await this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:s})}async cancelTasks(t){return await this.tasks.cancelTasks(t)}async deleteTasks(t={}){return await this.tasks.deleteTasks(t)}async getKeys(t={}){const e=await this.httpRequest.get("keys",t);return e.results=e.results.map((t=>({...t,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)}))),e}async getKey(t){const e=`keys/${t}`;return await this.httpRequest.get(e)}async createKey(t){return await this.httpRequest.post("keys",t)}async updateKey(t,e){const s=`keys/${t}`;return await this.httpRequest.patch(s,e)}async deleteKey(t){const e=`keys/${t}`;return await this.httpRequest.delete(e)}async health(){return await this.httpRequest.get("health")}async isHealthy(){try{const t="health";return await this.httpRequest.get(t),!0}catch(t){return!1}}async getStats(){return await this.httpRequest.get("stats")}async getVersion(){return await this.httpRequest.get("version")}async createDump(){const t=await this.httpRequest.post("dumps");return new y(t)}async createSnapshot(){const t=await this.httpRequest.post("snapshots");return new y(t)}generateTenantToken(t,e,s){const i=new Error;throw new Error(`Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ${i.stack}.`)}}{tokens;constructor(t){super(t),this.tokens=new D(t)}generateTenantToken(t,e,s){return"undefined"==typeof window?this.tokens.generateTenantToken(t,e,s):super.generateTenantToken(t,e,s)}}export{s as ContentTypeEnum,y as EnqueuedTask,a as ErrorStatusCode,w as Index,e as MatchingStrategies,R as MeiliSearch,o as MeiliSearchApiError,u as MeiliSearchCommunicationError,r as MeiliSearchError,_ as MeiliSearchTimeOutError,R as Meilisearch,E as Task,g as TaskClient,i as TaskStatus,n as TaskTypes,R as default,d as httpErrorHandler,c as httpResponseErrorHandler,h as versionErrorHintMessage};
const t={ALL:"all",LAST:"last"},e={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},s={TASK_SUCCEEDED:"succeeded",TASK_PROCESSING:"processing",TASK_FAILED:"failed",TASK_ENQUEUED:"enqueued",TASK_CANCELED:"canceled"},i={DOCUMENTS_ADDITION_OR_UPDATE:"documentAdditionOrUpdate",DOCUMENT_DELETION:"documentDeletion",DUMP_CREATION:"dumpCreation",INDEX_CREATION:"indexCreation",INDEX_DELETION:"indexDeletion",INDEXES_SWAP:"indexSwap",INDEX_UPDATE:"indexUpdate",SETTINGS_UPDATE:"settingsUpdate",SNAPSHOT_CREATION:"snapshotCreation",TASK_CANCELATION:"taskCancelation",TASK_DELETION:"taskDeletion"},n={INDEX_CREATION_FAILED:"index_creation_failed",MISSING_INDEX_UID:"missing_index_uid",INDEX_ALREADY_EXISTS:"index_already_exists",INDEX_NOT_FOUND:"index_not_found",INVALID_INDEX_UID:"invalid_index_uid",INDEX_NOT_ACCESSIBLE:"index_not_accessible",INVALID_INDEX_OFFSET:"invalid_index_offset",INVALID_INDEX_LIMIT:"invalid_index_limit",INVALID_STATE:"invalid_state",PRIMARY_KEY_INFERENCE_FAILED:"primary_key_inference_failed",INDEX_PRIMARY_KEY_ALREADY_EXISTS:"index_primary_key_already_exists",INVALID_INDEX_PRIMARY_KEY:"invalid_index_primary_key",DOCUMENTS_FIELDS_LIMIT_REACHED:"document_fields_limit_reached",MISSING_DOCUMENT_ID:"missing_document_id",INVALID_DOCUMENT_ID:"invalid_document_id",INVALID_CONTENT_TYPE:"invalid_content_type",MISSING_CONTENT_TYPE:"missing_content_type",INVALID_DOCUMENT_FIELDS:"invalid_document_fields",INVALID_DOCUMENT_LIMIT:"invalid_document_limit",INVALID_DOCUMENT_OFFSET:"invalid_document_offset",INVALID_DOCUMENT_FILTER:"invalid_document_filter",MISSING_DOCUMENT_FILTER:"missing_document_filter",INVALID_DOCUMENT_VECTORS_FIELD:"invalid_document_vectors_field",PAYLOAD_TOO_LARGE:"payload_too_large",MISSING_PAYLOAD:"missing_payload",MALFORMED_PAYLOAD:"malformed_payload",NO_SPACE_LEFT_ON_DEVICE:"no_space_left_on_device",INVALID_STORE_FILE:"invalid_store_file",INVALID_RANKING_RULES:"missing_document_id",INVALID_REQUEST:"invalid_request",INVALID_DOCUMENT_GEO_FIELD:"invalid_document_geo_field",INVALID_SEARCH_Q:"invalid_search_q",INVALID_SEARCH_OFFSET:"invalid_search_offset",INVALID_SEARCH_LIMIT:"invalid_search_limit",INVALID_SEARCH_PAGE:"invalid_search_page",INVALID_SEARCH_HITS_PER_PAGE:"invalid_search_hits_per_page",INVALID_SEARCH_ATTRIBUTES_TO_RETRIEVE:"invalid_search_attributes_to_retrieve",INVALID_SEARCH_ATTRIBUTES_TO_CROP:"invalid_search_attributes_to_crop",INVALID_SEARCH_CROP_LENGTH:"invalid_search_crop_length",INVALID_SEARCH_ATTRIBUTES_TO_HIGHLIGHT:"invalid_search_attributes_to_highlight",INVALID_SEARCH_SHOW_MATCHES_POSITION:"invalid_search_show_matches_position",INVALID_SEARCH_FILTER:"invalid_search_filter",INVALID_SEARCH_SORT:"invalid_search_sort",INVALID_SEARCH_FACETS:"invalid_search_facets",INVALID_SEARCH_HIGHLIGHT_PRE_TAG:"invalid_search_highlight_pre_tag",INVALID_SEARCH_HIGHLIGHT_POST_TAG:"invalid_search_highlight_post_tag",INVALID_SEARCH_CROP_MARKER:"invalid_search_crop_marker",INVALID_SEARCH_MATCHING_STRATEGY:"invalid_search_matching_strategy",INVALID_SEARCH_VECTOR:"invalid_search_vector",INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON:"invalid_search_attributes_to_search_on",BAD_REQUEST:"bad_request",DOCUMENT_NOT_FOUND:"document_not_found",INTERNAL:"internal",INVALID_API_KEY:"invalid_api_key",INVALID_API_KEY_DESCRIPTION:"invalid_api_key_description",INVALID_API_KEY_ACTIONS:"invalid_api_key_actions",INVALID_API_KEY_INDEXES:"invalid_api_key_indexes",INVALID_API_KEY_EXPIRES_AT:"invalid_api_key_expires_at",API_KEY_NOT_FOUND:"api_key_not_found",IMMUTABLE_API_KEY_UID:"immutable_api_key_uid",IMMUTABLE_API_KEY_ACTIONS:"immutable_api_key_actions",IMMUTABLE_API_KEY_INDEXES:"immutable_api_key_indexes",IMMUTABLE_API_KEY_EXPIRES_AT:"immutable_api_key_expires_at",IMMUTABLE_API_KEY_CREATED_AT:"immutable_api_key_created_at",IMMUTABLE_API_KEY_UPDATED_AT:"immutable_api_key_updated_at",MISSING_AUTHORIZATION_HEADER:"missing_authorization_header",UNRETRIEVABLE_DOCUMENT:"unretrievable_document",MAX_DATABASE_SIZE_LIMIT_REACHED:"database_size_limit_reached",TASK_NOT_FOUND:"task_not_found",DUMP_PROCESS_FAILED:"dump_process_failed",DUMP_NOT_FOUND:"dump_not_found",INVALID_SWAP_DUPLICATE_INDEX_FOUND:"invalid_swap_duplicate_index_found",INVALID_SWAP_INDEXES:"invalid_swap_indexes",MISSING_SWAP_INDEXES:"missing_swap_indexes",MISSING_MASTER_KEY:"missing_master_key",INVALID_TASK_TYPES:"invalid_task_types",INVALID_TASK_UIDS:"invalid_task_uids",INVALID_TASK_STATUSES:"invalid_task_statuses",INVALID_TASK_LIMIT:"invalid_task_limit",INVALID_TASK_FROM:"invalid_task_from",INVALID_TASK_CANCELED_BY:"invalid_task_canceled_by",MISSING_TASK_FILTERS:"missing_task_filters",TOO_MANY_OPEN_FILES:"too_many_open_files",IO_ERROR:"io_error",INVALID_TASK_INDEX_UIDS:"invalid_task_index_uids",IMMUTABLE_INDEX_UID:"immutable_index_uid",IMMUTABLE_INDEX_CREATED_AT:"immutable_index_created_at",IMMUTABLE_INDEX_UPDATED_AT:"immutable_index_updated_at",INVALID_SETTINGS_DISPLAYED_ATTRIBUTES:"invalid_settings_displayed_attributes",INVALID_SETTINGS_SEARCHABLE_ATTRIBUTES:"invalid_settings_searchable_attributes",INVALID_SETTINGS_FILTERABLE_ATTRIBUTES:"invalid_settings_filterable_attributes",INVALID_SETTINGS_SORTABLE_ATTRIBUTES:"invalid_settings_sortable_attributes",INVALID_SETTINGS_RANKING_RULES:"invalid_settings_ranking_rules",INVALID_SETTINGS_STOP_WORDS:"invalid_settings_stop_words",INVALID_SETTINGS_SYNONYMS:"invalid_settings_synonyms",INVALID_SETTINGS_DISTINCT_ATTRIBUTE:"invalid_settings_distinct_attribute",INVALID_SETTINGS_TYPO_TOLERANCE:"invalid_settings_typo_tolerance",INVALID_SETTINGS_FACETING:"invalid_settings_faceting",INVALID_SETTINGS_PAGINATION:"invalid_settings_pagination",INVALID_SETTINGS_SEARCH_CUTOFF_MS:"invalid_settings_search_cutoff_ms",INVALID_TASK_BEFORE_ENQUEUED_AT:"invalid_task_before_enqueued_at",INVALID_TASK_AFTER_ENQUEUED_AT:"invalid_task_after_enqueued_at",INVALID_TASK_BEFORE_STARTED_AT:"invalid_task_before_started_at",INVALID_TASK_AFTER_STARTED_AT:"invalid_task_after_started_at",INVALID_TASK_BEFORE_FINISHED_AT:"invalid_task_before_finished_at",INVALID_TASK_AFTER_FINISHED_AT:"invalid_task_after_finished_at",MISSING_API_KEY_ACTIONS:"missing_api_key_actions",MISSING_API_KEY_INDEXES:"missing_api_key_indexes",MISSING_API_KEY_EXPIRES_AT:"missing_api_key_expires_at",INVALID_API_KEY_LIMIT:"invalid_api_key_limit",INVALID_API_KEY_OFFSET:"invalid_api_key_offset",INVALID_FACET_SEARCH_FACET_NAME:"invalid_facet_search_facet_name",MISSING_FACET_SEARCH_FACET_NAME:"missing_facet_search_facet_name",INVALID_FACET_SEARCH_FACET_QUERY:"invalid_facet_search_facet_query"};class a extends Error{constructor(t){super(t),Object.setPrototypeOf(this,a.prototype),this.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(this,a)}}class r extends a{statusCode;errno;code;stack;constructor(t,e,s,i){super(t),Object.setPrototypeOf(this,r.prototype),this.name="MeiliSearchCommunicationError",e instanceof Response&&(this.message=e.statusText,this.statusCode=e.status),e instanceof Error&&(this.errno=e.errno,this.code=e.code),i?(this.stack=i,this.stack=this.stack?.replace(/(TypeError|FetchError)/,this.name),this.stack=this.stack?.replace("Failed to fetch",`request to ${s} failed, reason: connect ECONNREFUSED`),this.stack=this.stack?.replace("Not Found",`Not Found: ${s}`)):Error.captureStackTrace&&Error.captureStackTrace(this,r)}}const u=class extends a{httpStatus;code;link;type;stack;constructor(t,e){super(t.message),Object.setPrototypeOf(this,u.prototype),this.name="MeiliSearchApiError",this.code=t.code,this.type=t.type,this.link=t.link,this.message=t.message,this.httpStatus=e,Error.captureStackTrace&&Error.captureStackTrace(this,u)}};async function o(t){if(!t.ok){let e;try{e=await t.json()}catch(e){throw new r(t.statusText,t,t.url)}throw new u(e,t.status)}return t}function c(t,e,s){if("MeiliSearchApiError"!==t.name)throw new r(t.message,t,s,e);throw t}class d extends a{constructor(t){super(t),Object.setPrototypeOf(this,d.prototype),this.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function _(t,e){return`${t}\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ${e} call requires.`}function h(t){return Object.entries(t).reduce(((t,e)=>{const[s,i]=e;return void 0!==i&&(t[s]=i),t}),{})}async function p(t){return await new Promise((e=>setTimeout(e,t)))}function A(t){return Object.keys(t).reduce(((e,s)=>{const i=t[s];return void 0===i?e:Array.isArray(i)?{...e,[s]:i.join(",")}:i instanceof Date?{...e,[s]:i.toISOString()}:{...e,[s]:i}}),{})}function l(t){const e="X-Meilisearch-Client",s="Meilisearch JavaScript (v0.40.0)",i=function(t){if(Array.isArray(t))return t.reduce(((t,e)=>(t[e[0]]=e[1],t)),{});if("has"in t){const e={};return t.forEach(((t,s)=>e[s]=t)),e}return Object.assign({},t)}(t.requestConfig?.headers??{});if(t.apiKey&&!i.Authorization&&(i.Authorization=`Bearer ${t.apiKey}`),i["Content-Type"]||(i["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){const n=t.clientAgents.concat(s);i[e]=n.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new a(`Meilisearch: The header "${e}" should be an array of string(s).\n`);i[e]=s}return i}class I{headers;url;requestConfig;httpClient;requestTimeout;constructor(t){this.headers=l(t),this.requestConfig=t.requestConfig,this.httpClient=t.httpClient,this.requestTimeout=t.timeout;try{const e=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:`http://${t}`}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new a("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new a("The provided host is not valid.")}}async request({method:t,url:e,params:s,body:i,config:n={}}){"undefined"==typeof fetch&&require("cross-fetch/polyfill");const a=new URL(e,this.url);if(s){const t=new URLSearchParams;Object.keys(s).filter((t=>null!==s[t])).map((e=>t.set(e,s[e]))),a.search=t.toString()}n.headers?.["Content-Type"]||(i=JSON.stringify(i));const r={...this.headers,...n.headers};try{const e=this.fetchWithTimeout(a.toString(),{...n,...this.requestConfig,method:t,body:i,headers:r},this.requestTimeout);if(this.httpClient)return await e;const s=await e.then((t=>o(t)));return await s.json().catch((()=>{}))}catch(t){c(t,t.stack,a.toString())}}async fetchWithTimeout(t,e,s){return new Promise(((i,n)=>{const a=[(this.httpClient?this.httpClient:fetch)(t,e)];let r;if(s){const t=new Promise(((t,e)=>{r=setTimeout((()=>{e(new Error("Error: Request Timed Out"))}),s)}));a.push(t)}Promise.race(a).then(i).catch(n).finally((()=>{clearTimeout(r)}))}))}async get(t,e,s){return await this.request({method:"GET",url:t,params:e,config:s})}async post(t,e,s,i){return await this.request({method:"POST",url:t,body:e,params:s,config:i})}async put(t,e,s,i){return await this.request({method:"PUT",url:t,body:e,params:s,config:i})}async patch(t,e,s,i){return await this.request({method:"PATCH",url:t,body:e,params:s,config:i})}async delete(t,e,s,i){return await this.request({method:"DELETE",url:t,body:e,params:s,config:i})}}class T{taskUid;indexUid;status;type;enqueuedAt;constructor(t){this.taskUid=t.taskUid,this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.enqueuedAt=new Date(t.enqueuedAt)}}class y{indexUid;status;type;uid;canceledBy;details;error;duration;startedAt;enqueuedAt;finishedAt;constructor(t){this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.uid=t.uid,this.details=t.details,this.canceledBy=t.canceledBy,this.error=t.error,this.duration=t.duration,this.startedAt=new Date(t.startedAt),this.enqueuedAt=new Date(t.enqueuedAt),this.finishedAt=new Date(t.finishedAt)}}class E{httpRequest;constructor(t){this.httpRequest=new I(t)}async getTask(t){const e=`tasks/${t}`,s=await this.httpRequest.get(e);return new y(s)}async getTasks(t={}){const e=await this.httpRequest.get("tasks",A(t));return{...e,results:e.results.map((t=>new y(t)))}}async waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){const n=Date.now();for(;Date.now()-n<e;){const e=await this.getTask(t);if(![s.TASK_ENQUEUED,s.TASK_PROCESSING].includes(e.status))return e;await p(i)}throw new d(`timeout of ${e}ms has exceeded on process ${t} when waiting a task to be resolved.`)}async waitForTasks(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){const i=[];for(const n of t){const t=await this.waitForTask(n,{timeOutMs:e,intervalMs:s});i.push(t)}return i}async cancelTasks(t={}){const e=await this.httpRequest.post("tasks/cancel",{},A(t));return new T(e)}async deleteTasks(t={}){const e=await this.httpRequest.delete("tasks",{},A(t));return new T(e)}}class g{uid;primaryKey;createdAt;updatedAt;httpRequest;tasks;constructor(t,e,s){this.uid=e,this.primaryKey=s,this.httpRequest=new I(t),this.tasks=new E(t)}async search(t,e,s){const i=`indexes/${this.uid}/search`;return await this.httpRequest.post(i,h({q:t,...e}),void 0,s)}async searchGet(t,e,s){const i=`indexes/${this.uid}/search`,n={q:t,...e,filter:(t=>{if("string"==typeof t)return t;if(Array.isArray(t))throw new a("The filter query parameter should be in string format when using searchGet")})(e?.filter),sort:e?.sort?.join(","),facets:e?.facets?.join(","),attributesToRetrieve:e?.attributesToRetrieve?.join(","),attributesToCrop:e?.attributesToCrop?.join(","),attributesToHighlight:e?.attributesToHighlight?.join(","),vector:e?.vector?.join(","),attributesToSearchOn:e?.attributesToSearchOn?.join(",")};return await this.httpRequest.get(i,h(n),s)}async searchForFacetValues(t,e){const s=`indexes/${this.uid}/facet-search`;return await this.httpRequest.post(s,h(t),void 0,e)}async getRawInfo(){const t=`indexes/${this.uid}`,e=await this.httpRequest.get(t);return this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),e}async fetchInfo(){return await this.getRawInfo(),this}async fetchPrimaryKey(){return this.primaryKey=(await this.getRawInfo()).primaryKey,this.primaryKey}static async create(t,e={},s){const i=new I(s),n=await i.post("indexes",{...e,uid:t});return new T(n)}async update(t){const e=`indexes/${this.uid}`,s=await this.httpRequest.patch(e,t);return s.enqueuedAt=new Date(s.enqueuedAt),s}async delete(){const t=`indexes/${this.uid}`,e=await this.httpRequest.delete(t);return new T(e)}async getTasks(t={}){return await this.tasks.getTasks({...t,indexUids:[this.uid]})}async getTask(t){return await this.tasks.getTask(t)}async waitForTasks(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){return await this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:s})}async waitForTask(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){return await this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:s})}async getStats(){const t=`indexes/${this.uid}/stats`;return await this.httpRequest.get(t)}async getDocuments(t={}){if(void 0===(t=h(t)).filter){const e=`indexes/${this.uid}/documents`,s=Array.isArray(t?.fields)?{fields:t?.fields?.join(",")}:{};return await this.httpRequest.get(e,{...t,...s})}try{const e=`indexes/${this.uid}/documents/fetch`;return await this.httpRequest.post(e,t)}catch(t){throw(t instanceof r||t instanceof u)&&(t.message=_(t.message,"getDocuments")),t}}async getDocument(t,e){const s=`indexes/${this.uid}/documents/${t}`,i=(()=>{if(Array.isArray(e?.fields))return e?.fields?.join(",")})();return await this.httpRequest.get(s,h({...e,fields:i}))}async addDocuments(t,e){const s=`indexes/${this.uid}/documents`,i=await this.httpRequest.post(s,t,e);return new T(i)}async addDocumentsFromString(t,e,s){const i=`indexes/${this.uid}/documents`,n=await this.httpRequest.post(i,t,s,{headers:{"Content-Type":e}});return new T(n)}async addDocumentsInBatches(t,e=1e3,s){const i=[];for(let n=0;n<t.length;n+=e)i.push(await this.addDocuments(t.slice(n,n+e),s));return i}async updateDocuments(t,e){const s=`indexes/${this.uid}/documents`,i=await this.httpRequest.put(s,t,e);return new T(i)}async updateDocumentsInBatches(t,e=1e3,s){const i=[];for(let n=0;n<t.length;n+=e)i.push(await this.updateDocuments(t.slice(n,n+e),s));return i}async updateDocumentsFromString(t,e,s){const i=`indexes/${this.uid}/documents`,n=await this.httpRequest.put(i,t,s,{headers:{"Content-Type":e}});return new T(n)}async deleteDocument(t){const e=`indexes/${this.uid}/documents/${t}`,s=await this.httpRequest.delete(e);return s.enqueuedAt=new Date(s.enqueuedAt),s}async deleteDocuments(t){const e=!Array.isArray(t)&&"object"==typeof t,s=e?"documents/delete":"documents/delete-batch",i=`indexes/${this.uid}/${s}`;try{const e=await this.httpRequest.post(i,t);return new T(e)}catch(t){throw(t instanceof r&&e||t instanceof u)&&(t.message=_(t.message,"deleteDocuments")),t}}async deleteAllDocuments(){const t=`indexes/${this.uid}/documents`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getSettings(){const t=`indexes/${this.uid}/settings`;return await this.httpRequest.get(t)}async updateSettings(t){const e=`indexes/${this.uid}/settings`,s=await this.httpRequest.patch(e,t);return s.enqueued=new Date(s.enqueuedAt),s}async resetSettings(){const t=`indexes/${this.uid}/settings`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getPagination(){const t=`indexes/${this.uid}/settings/pagination`;return await this.httpRequest.get(t)}async updatePagination(t){const e=`indexes/${this.uid}/settings/pagination`,s=await this.httpRequest.patch(e,t);return new T(s)}async resetPagination(){const t=`indexes/${this.uid}/settings/pagination`,e=await this.httpRequest.delete(t);return new T(e)}async getSynonyms(){const t=`indexes/${this.uid}/settings/synonyms`;return await this.httpRequest.get(t)}async updateSynonyms(t){const e=`indexes/${this.uid}/settings/synonyms`,s=await this.httpRequest.put(e,t);return new T(s)}async resetSynonyms(){const t=`indexes/${this.uid}/settings/synonyms`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getStopWords(){const t=`indexes/${this.uid}/settings/stop-words`;return await this.httpRequest.get(t)}async updateStopWords(t){const e=`indexes/${this.uid}/settings/stop-words`,s=await this.httpRequest.put(e,t);return new T(s)}async resetStopWords(){const t=`indexes/${this.uid}/settings/stop-words`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getRankingRules(){const t=`indexes/${this.uid}/settings/ranking-rules`;return await this.httpRequest.get(t)}async updateRankingRules(t){const e=`indexes/${this.uid}/settings/ranking-rules`,s=await this.httpRequest.put(e,t);return new T(s)}async resetRankingRules(){const t=`indexes/${this.uid}/settings/ranking-rules`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getDistinctAttribute(){const t=`indexes/${this.uid}/settings/distinct-attribute`;return await this.httpRequest.get(t)}async updateDistinctAttribute(t){const e=`indexes/${this.uid}/settings/distinct-attribute`,s=await this.httpRequest.put(e,t);return new T(s)}async resetDistinctAttribute(){const t=`indexes/${this.uid}/settings/distinct-attribute`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getFilterableAttributes(){const t=`indexes/${this.uid}/settings/filterable-attributes`;return await this.httpRequest.get(t)}async updateFilterableAttributes(t){const e=`indexes/${this.uid}/settings/filterable-attributes`,s=await this.httpRequest.put(e,t);return new T(s)}async resetFilterableAttributes(){const t=`indexes/${this.uid}/settings/filterable-attributes`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getSortableAttributes(){const t=`indexes/${this.uid}/settings/sortable-attributes`;return await this.httpRequest.get(t)}async updateSortableAttributes(t){const e=`indexes/${this.uid}/settings/sortable-attributes`,s=await this.httpRequest.put(e,t);return new T(s)}async resetSortableAttributes(){const t=`indexes/${this.uid}/settings/sortable-attributes`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getSearchableAttributes(){const t=`indexes/${this.uid}/settings/searchable-attributes`;return await this.httpRequest.get(t)}async updateSearchableAttributes(t){const e=`indexes/${this.uid}/settings/searchable-attributes`,s=await this.httpRequest.put(e,t);return new T(s)}async resetSearchableAttributes(){const t=`indexes/${this.uid}/settings/searchable-attributes`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getDisplayedAttributes(){const t=`indexes/${this.uid}/settings/displayed-attributes`;return await this.httpRequest.get(t)}async updateDisplayedAttributes(t){const e=`indexes/${this.uid}/settings/displayed-attributes`,s=await this.httpRequest.put(e,t);return new T(s)}async resetDisplayedAttributes(){const t=`indexes/${this.uid}/settings/displayed-attributes`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getTypoTolerance(){const t=`indexes/${this.uid}/settings/typo-tolerance`;return await this.httpRequest.get(t)}async updateTypoTolerance(t){const e=`indexes/${this.uid}/settings/typo-tolerance`,s=await this.httpRequest.patch(e,t);return s.enqueuedAt=new Date(s.enqueuedAt),s}async resetTypoTolerance(){const t=`indexes/${this.uid}/settings/typo-tolerance`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getFaceting(){const t=`indexes/${this.uid}/settings/faceting`;return await this.httpRequest.get(t)}async updateFaceting(t){const e=`indexes/${this.uid}/settings/faceting`,s=await this.httpRequest.patch(e,t);return new T(s)}async resetFaceting(){const t=`indexes/${this.uid}/settings/faceting`,e=await this.httpRequest.delete(t);return new T(e)}async getSeparatorTokens(){const t=`indexes/${this.uid}/settings/separator-tokens`;return await this.httpRequest.get(t)}async updateSeparatorTokens(t){const e=`indexes/${this.uid}/settings/separator-tokens`,s=await this.httpRequest.put(e,t);return new T(s)}async resetSeparatorTokens(){const t=`indexes/${this.uid}/settings/separator-tokens`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getNonSeparatorTokens(){const t=`indexes/${this.uid}/settings/non-separator-tokens`;return await this.httpRequest.get(t)}async updateNonSeparatorTokens(t){const e=`indexes/${this.uid}/settings/non-separator-tokens`,s=await this.httpRequest.put(e,t);return new T(s)}async resetNonSeparatorTokens(){const t=`indexes/${this.uid}/settings/non-separator-tokens`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getDictionary(){const t=`indexes/${this.uid}/settings/dictionary`;return await this.httpRequest.get(t)}async updateDictionary(t){const e=`indexes/${this.uid}/settings/dictionary`,s=await this.httpRequest.put(e,t);return new T(s)}async resetDictionary(){const t=`indexes/${this.uid}/settings/dictionary`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getProximityPrecision(){const t=`indexes/${this.uid}/settings/proximity-precision`;return await this.httpRequest.get(t)}async updateProximityPrecision(t){const e=`indexes/${this.uid}/settings/proximity-precision`,s=await this.httpRequest.put(e,t);return new T(s)}async resetProximityPrecision(){const t=`indexes/${this.uid}/settings/proximity-precision`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getEmbedders(){const t=`indexes/${this.uid}/settings/embedders`;return await this.httpRequest.get(t)}async updateEmbedders(t){const e=`indexes/${this.uid}/settings/embedders`,s=await this.httpRequest.patch(e,t);return new T(s)}async resetEmbedders(){const t=`indexes/${this.uid}/settings/embedders`,e=await this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}async getSearchCutoffMs(){const t=`indexes/${this.uid}/settings/search-cutoff-ms`;return await this.httpRequest.get(t)}async updateSearchCutoffMs(t){const e=`indexes/${this.uid}/settings/search-cutoff-ms`,s=await this.httpRequest.put(e,t);return new T(s)}async resetSearchCutoffMs(){const t=`indexes/${this.uid}/settings/search-cutoff-ms`,e=await this.httpRequest.delete(t);return new T(e)}}function w(t){return Buffer.from(JSON.stringify(t)).toString("base64")}class S{config;constructor(t){this.config=t}async generateTenantToken(t,e,s){const i=s?.apiKey||this.config.apiKey||"",n=t||"",r=s?.expiresAt;!function(t){const{searchRules:e,uid:s,apiKey:i,expiresAt:n}=t;if(n){if(!(n instanceof Date))throw new a("Meilisearch: The expiredAt field must be an instance of Date.");if(n.getTime()<Date.now())throw new a("Meilisearch: The expiresAt field must be a date in the future.")}if(e&&"object"!=typeof e&&!Array.isArray(e))throw new a("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!i||"string"!=typeof i)throw new a("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!s||"string"!=typeof s)throw new a("Meilisearch: The uid of the api key used for the token generation must exist, be of type string and comply to the uuid4 format.");if(!/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(s))throw new a("Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().")}({apiKey:i,uid:n,expiresAt:r,searchRules:e});const u=w({alg:"HS256",typ:"JWT"}).replace(/=/g,""),o=function(t){const{searchRules:e,uid:s,expiresAt:i}=t;return w({searchRules:e,apiKeyUid:s,exp:i?Math.floor(i.getTime()/1e3):void 0}).replace(/=/g,"")}({searchRules:e,uid:n,expiresAt:r}),c=await async function(t,e,s){const{createHmac:i}=await import("crypto");return i("sha256",t).update(`${e}.${s}`).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(i,u,o);return`${u}.${o}.${c}`}}class D extends class{config;httpRequest;tasks;constructor(t){this.config=t,this.httpRequest=new I(t),this.tasks=new E(t)}index(t){return new g(this.config,t)}async getIndex(t){return new g(this.config,t).fetchInfo()}async getRawIndex(t){return new g(this.config,t).getRawInfo()}async getIndexes(t={}){const e=await this.getRawIndexes(t),s=e.results.map((t=>new g(this.config,t.uid,t.primaryKey)));return{...e,results:s}}async getRawIndexes(t={}){return await this.httpRequest.get("indexes",t)}async createIndex(t,e={}){return await g.create(t,e,this.config)}async updateIndex(t,e={}){return await new g(this.config,t).update(e)}async deleteIndex(t){return await new g(this.config,t).delete()}async deleteIndexIfExists(t){try{return await this.deleteIndex(t),!0}catch(t){if(t.code===n.INDEX_NOT_FOUND)return!1;throw t}}async swapIndexes(t){return await this.httpRequest.post("/swap-indexes",t)}async multiSearch(t,e){return await this.httpRequest.post("multi-search",t,void 0,e)}async getTasks(t={}){return await this.tasks.getTasks(t)}async getTask(t){return await this.tasks.getTask(t)}async waitForTasks(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){return await this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:s})}async waitForTask(t,{timeOutMs:e=5e3,intervalMs:s=50}={}){return await this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:s})}async cancelTasks(t){return await this.tasks.cancelTasks(t)}async deleteTasks(t={}){return await this.tasks.deleteTasks(t)}async getKeys(t={}){const e=await this.httpRequest.get("keys",t);return e.results=e.results.map((t=>({...t,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)}))),e}async getKey(t){const e=`keys/${t}`;return await this.httpRequest.get(e)}async createKey(t){return await this.httpRequest.post("keys",t)}async updateKey(t,e){const s=`keys/${t}`;return await this.httpRequest.patch(s,e)}async deleteKey(t){const e=`keys/${t}`;return await this.httpRequest.delete(e)}async health(){return await this.httpRequest.get("health")}async isHealthy(){try{const t="health";return await this.httpRequest.get(t),!0}catch(t){return!1}}async getStats(){return await this.httpRequest.get("stats")}async getVersion(){return await this.httpRequest.get("version")}async createDump(){const t=await this.httpRequest.post("dumps");return new T(t)}async createSnapshot(){const t=await this.httpRequest.post("snapshots");return new T(t)}generateTenantToken(t,e,s){const i=new Error;return i.message=`Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ${i.stack}.`,Promise.reject(i)}}{tokens;constructor(t){super(t),this.tokens=new S(t)}async generateTenantToken(t,e,s){return"undefined"==typeof window?await this.tokens.generateTenantToken(t,e,s):await super.generateTenantToken(t,e,s)}}export{e as ContentTypeEnum,T as EnqueuedTask,n as ErrorStatusCode,g as Index,t as MatchingStrategies,D as MeiliSearch,u as MeiliSearchApiError,r as MeiliSearchCommunicationError,a as MeiliSearchError,d as MeiliSearchTimeOutError,D as Meilisearch,y as Task,E as TaskClient,s as TaskStatus,i as TaskTypes,D as default,c as httpErrorHandler,o as httpResponseErrorHandler,_ as versionErrorHintMessage};
//# sourceMappingURL=meilisearch.esm.min.js.map

@@ -237,5 +237,5 @@ import { Index } from '../indexes';

*/
generateTenantToken(_apiKeyUid: string, _searchRules: TokenSearchRules, _options?: TokenOptions): string;
generateTenantToken(_apiKeyUid: string, _searchRules: TokenSearchRules, _options?: TokenOptions): Promise<string>;
}
export { Client };
//# sourceMappingURL=client.d.ts.map

@@ -15,5 +15,5 @@ import { Client } from './client';

*/
generateTenantToken(apiKeyUid: string, searchRules: TokenSearchRules, options?: TokenOptions): string;
generateTenantToken(apiKeyUid: string, searchRules: TokenSearchRules, options?: TokenOptions): Promise<string>;
}
export { MeiliSearch };
//# sourceMappingURL=node-client.d.ts.map

@@ -1,2 +0,2 @@

// Type definitions for meilisearch 0.39.0
// Type definitions for meilisearch 0.40.0
// Project: https://github.com/meilisearch/meilisearch-js

@@ -3,0 +3,0 @@ // Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch>

@@ -1,2 +0,2 @@

export declare const PACKAGE_VERSION = "0.39.0";
export declare const PACKAGE_VERSION = "0.40.0";
//# sourceMappingURL=package-version.d.ts.map

@@ -13,5 +13,5 @@ import { Config, TokenSearchRules, TokenOptions } from './types';

*/
generateTenantToken(apiKeyUid: string, searchRules: TokenSearchRules, options?: TokenOptions): string;
generateTenantToken(apiKeyUid: string, searchRules: TokenSearchRules, options?: TokenOptions): Promise<string>;
}
export { Token };
//# sourceMappingURL=token.d.ts.map
{
"name": "meilisearch",
"version": "0.39.0",
"version": "0.40.0",
"description": "The Meilisearch JS client for Node.js and the browser.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -966,3 +966,3 @@ <p align="center">

#### [Get proximity precision](https://www.meilisearch.com/docs/reference/api/settings#get-proximity-precision)
#### [Get proximity precision](https://www.meilisearch.com/docs/reference/api/settings#get-proximity-precision-settings)

@@ -973,3 +973,3 @@ ```ts

#### [Update proximity precision](https://www.meilisearch.com/docs/reference/api/settings#update-proximity-precision)
#### [Update proximity precision](https://www.meilisearch.com/docs/reference/api/settings#update-proximity-precision-settings)

@@ -980,3 +980,3 @@ ```ts

#### [Reset proximity precision](https://www.meilisearch.com/docs/reference/api/settings#reset-proximity-precision)
#### [Reset proximity precision](https://www.meilisearch.com/docs/reference/api/settings#reset-proximity-precision-settings)

@@ -991,3 +991,3 @@ ```ts

#### [Get embedders](https://www.meilisearch.com/docs/reference/api/settings#get-embedders)
#### Get embedders

@@ -998,3 +998,3 @@ ```ts

#### [Update embedders](https://www.meilisearch.com/docs/reference/api/settings#update-embedders)
#### Update embedders

@@ -1005,3 +1005,3 @@ ```ts

#### [Reset embedders](https://www.meilisearch.com/docs/reference/api/settings#reset-embedders)
#### Reset embedders

@@ -1014,3 +1014,3 @@ ```ts

#### [Get SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#get-search-cutoff-ms)
#### [Get SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#get-search-cutoff)

@@ -1021,3 +1021,3 @@ ```ts

#### [Update SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#update-search-cutoff-ms)
#### [Update SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#update-search-cutoff)

@@ -1028,3 +1028,3 @@ ```ts

#### [Reset SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#reset-search-cutoff-ms)
#### [Reset SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#reset-search-cutoff)

@@ -1031,0 +1031,0 @@ ```ts

@@ -478,7 +478,7 @@ /*

_options?: TokenOptions
): string {
): Promise<string> {
const error = new Error()
throw new Error(
`Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ${error.stack}.`
)
error.message = `Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ${error.stack}.`
return Promise.reject(error)
}

@@ -485,0 +485,0 @@ }

@@ -21,13 +21,17 @@ import { Client } from './client'

*/
generateTenantToken(
async generateTenantToken(
apiKeyUid: string,
searchRules: TokenSearchRules,
options?: TokenOptions
): string {
): Promise<string> {
if (typeof window === 'undefined') {
return this.tokens.generateTenantToken(apiKeyUid, searchRules, options)
return await this.tokens.generateTenantToken(
apiKeyUid,
searchRules,
options
)
}
return super.generateTenantToken(apiKeyUid, searchRules, options)
return await super.generateTenantToken(apiKeyUid, searchRules, options)
}
}
export { MeiliSearch }

@@ -1,1 +0,1 @@

export const PACKAGE_VERSION = '0.39.0'
export const PACKAGE_VERSION = '0.40.0'
import { Config, TokenSearchRules, TokenOptions } from './types'
import { createHmac } from 'crypto'
import { MeiliSearchError } from './errors'

@@ -18,3 +17,9 @@ import { validateUuid4 } from './utils'

*/
function sign(apiKey: string, encodedHeader: string, encodedPayload: string) {
async function sign(
apiKey: string,
encodedHeader: string,
encodedPayload: string
) {
const { createHmac } = await import('crypto')
return createHmac('sha256', apiKey)

@@ -136,7 +141,7 @@ .update(`${encodedHeader}.${encodedPayload}`)

*/
generateTenantToken(
async generateTenantToken(
apiKeyUid: string,
searchRules: TokenSearchRules,
options?: TokenOptions
): string {
): Promise<string> {
const apiKey = options?.apiKey || this.config.apiKey || ''

@@ -150,3 +155,3 @@ const uid = apiKeyUid || ''

const encodedPayload = createPayload({ searchRules, uid, expiresAt })
const signature = sign(apiKey, encodedHeader, encodedPayload)
const signature = await sign(apiKey, encodedHeader, encodedPayload)

@@ -153,0 +158,0 @@ return `${encodedHeader}.${encodedPayload}.${signature}`

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc