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.37.0 to 0.38.0-v1.7.0-pre-release.0

2

dist/bundles/meilisearch.esm.min.js

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

import t from"crypto";const e={ALL:"all",LAST:"last"},i={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"},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"},r={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_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"};function o(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{u(s.next(t))}catch(t){r(t)}}function d(t){try{u(s.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,d)}u((s=s.apply(t,e||[])).next())}))}class d extends Error{constructor(t){super(t),Object.setPrototypeOf(this,d.prototype),this.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}class u extends d{constructor(t,e,i,s){var n,r,o;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),s?(this.stack=s,this.stack=null===(n=this.stack)||void 0===n?void 0:n.replace(/(TypeError|FetchError)/,this.name),this.stack=null===(r=this.stack)||void 0===r?void 0:r.replace("Failed to fetch",`request to ${i} failed, reason: connect ECONNREFUSED`),this.stack=null===(o=this.stack)||void 0===o?void 0:o.replace("Not Found",`Not Found: ${i}`)):Error.captureStackTrace&&Error.captureStackTrace(this,u)}}const a=class extends d{constructor(t,e){super(t.message),Object.setPrototypeOf(this,a.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,a)}};function h(t){return o(this,void 0,void 0,(function*(){if(!t.ok){let e;try{e=yield t.json()}catch(e){throw new u(t.statusText,t,t.url)}throw new a(e,t.status)}return t}))}function c(t,e,i){if("MeiliSearchApiError"!==t.name)throw new u(t.message,t,i,e);throw t}class _ extends d{constructor(t){super(t),Object.setPrototypeOf(this,_.prototype),this.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(this,_)}}function l(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 v(t){return Object.entries(t).reduce(((t,e)=>{const[i,s]=e;return void 0!==s&&(t[i]=s),t}),{})}function p(t){return o(this,void 0,void 0,(function*(){return yield new Promise((e=>setTimeout(e,t)))}))}function A(t){return Object.keys(t).reduce(((e,i)=>{const s=t[i];return void 0===s?e:Array.isArray(s)?Object.assign(Object.assign({},e),{[i]:s.join(",")}):s instanceof Date?Object.assign(Object.assign({},e),{[i]:s.toISOString()}):Object.assign(Object.assign({},e),{[i]:s})}),{})}function I(t){var e,i;const s="X-Meilisearch-Client",n="Meilisearch JavaScript (v0.37.0)",r=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,i)=>e[i]=t)),e}return Object.assign({},t)}(null!==(i=null===(e=t.requestConfig)||void 0===e?void 0:e.headers)&&void 0!==i?i:{});if(t.apiKey&&!r.Authorization&&(r.Authorization=`Bearer ${t.apiKey}`),r["Content-Type"]||(r["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){const e=t.clientAgents.concat(n);r[s]=e.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new d(`Meilisearch: The header "${s}" should be an array of string(s).\n`);r[s]=n}return r}class f{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 d("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new d("The provided host is not valid.")}}request({method:t,url:e,params:i,body:s,config:n={}}){var r;return o(this,void 0,void 0,(function*(){"undefined"==typeof fetch&&require("cross-fetch/polyfill");const o=new URL(e,this.url);if(i){const t=new URLSearchParams;Object.keys(i).filter((t=>null!==i[t])).map((e=>t.set(e,i[e]))),o.search=t.toString()}(null===(r=n.headers)||void 0===r?void 0:r["Content-Type"])||(s=JSON.stringify(s));const d=Object.assign(Object.assign({},this.headers),n.headers);try{const e=this.fetchWithTimeout(o.toString(),Object.assign(Object.assign(Object.assign({},n),this.requestConfig),{method:t,body:s,headers:d}),this.requestTimeout);if(this.httpClient)return yield e;const i=yield e.then((t=>h(t)));return yield i.json().catch((()=>{}))}catch(t){c(t,t.stack,o.toString())}}))}fetchWithTimeout(t,e,i){return o(this,void 0,void 0,(function*(){return new Promise(((s,n)=>{const r=[(this.httpClient?this.httpClient:fetch)(t,e)];let o;if(i){const t=new Promise(((t,e)=>{o=setTimeout((()=>{e(new Error("Error: Request Timed Out"))}),i)}));r.push(t)}Promise.race(r).then(s).catch(n).finally((()=>{clearTimeout(o)}))}))}))}get(t,e,i){return o(this,void 0,void 0,(function*(){return yield this.request({method:"GET",url:t,params:e,config:i})}))}post(t,e,i,s){return o(this,void 0,void 0,(function*(){return yield this.request({method:"POST",url:t,body:e,params:i,config:s})}))}put(t,e,i,s){return o(this,void 0,void 0,(function*(){return yield this.request({method:"PUT",url:t,body:e,params:i,config:s})}))}patch(t,e,i,s){return o(this,void 0,void 0,(function*(){return yield this.request({method:"PATCH",url:t,body:e,params:i,config:s})}))}delete(t,e,i,s){return o(this,void 0,void 0,(function*(){return yield this.request({method:"DELETE",url:t,body:e,params:i,config:s})}))}}class T{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{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{constructor(t){this.httpRequest=new f(t)}getTask(t){return o(this,void 0,void 0,(function*(){const e=`tasks/${t}`,i=yield this.httpRequest.get(e);return new y(i)}))}getTasks(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.httpRequest.get("tasks",A(t));return Object.assign(Object.assign({},e),{results:e.results.map((t=>new y(t)))})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){const n=Date.now();for(;Date.now()-n<e;){const e=yield this.getTask(t);if(![s.TASK_ENQUEUED,s.TASK_PROCESSING].includes(e.status))return e;yield p(i)}throw new _(`timeout of ${e}ms has exceeded on process ${t} when waiting a task to be resolved.`)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=yield this.waitForTask(n,{timeOutMs:e,intervalMs:i});s.push(t)}return s}))}cancelTasks(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.httpRequest.post("tasks/cancel",{},A(t));return new T(e)}))}deleteTasks(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.httpRequest.delete("tasks",{},A(t));return new T(e)}))}}class g{constructor(t,e,i){this.uid=e,this.primaryKey=i,this.httpRequest=new f(t),this.tasks=new E(t)}search(t,e,i){return o(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/search`;return yield this.httpRequest.post(s,v(Object.assign({q:t},e)),void 0,i)}))}searchGet(t,e,i){var s,n,r,u,a,h,c;return o(this,void 0,void 0,(function*(){const o=`indexes/${this.uid}/search`,_=Object.assign(Object.assign({q:t},e),{filter:(t=>{if("string"==typeof t)return t;if(Array.isArray(t))throw new d("The filter query parameter should be in string format when using searchGet")})(null==e?void 0:e.filter),sort:null===(s=null==e?void 0:e.sort)||void 0===s?void 0:s.join(","),facets:null===(n=null==e?void 0:e.facets)||void 0===n?void 0:n.join(","),attributesToRetrieve:null===(r=null==e?void 0:e.attributesToRetrieve)||void 0===r?void 0:r.join(","),attributesToCrop:null===(u=null==e?void 0:e.attributesToCrop)||void 0===u?void 0:u.join(","),attributesToHighlight:null===(a=null==e?void 0:e.attributesToHighlight)||void 0===a?void 0:a.join(","),vector:null===(h=null==e?void 0:e.vector)||void 0===h?void 0:h.join(","),attributesToSearchOn:null===(c=null==e?void 0:e.attributesToSearchOn)||void 0===c?void 0:c.join(",")});return yield this.httpRequest.get(o,v(_),i)}))}searchForFacetValues(t,e){return o(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/facet-search`;return yield this.httpRequest.post(i,v(t),void 0,e)}))}getRawInfo(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}`,e=yield this.httpRequest.get(t);return this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),e}))}fetchInfo(){return o(this,void 0,void 0,(function*(){return yield this.getRawInfo(),this}))}fetchPrimaryKey(){return o(this,void 0,void 0,(function*(){return this.primaryKey=(yield this.getRawInfo()).primaryKey,this.primaryKey}))}static create(t,e={},i){return o(this,void 0,void 0,(function*(){const s=new f(i),n=yield s.post("indexes",Object.assign(Object.assign({},e),{uid:t}));return new T(n)}))}update(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}`,i=yield this.httpRequest.patch(e,t);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}delete(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}`,e=yield this.httpRequest.delete(t);return new T(e)}))}getTasks(t={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.getTasks(Object.assign(Object.assign({},t),{indexUids:[this.uid]}))}))}getTask(t){return o(this,void 0,void 0,(function*(){return yield this.tasks.getTask(t)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:i})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:i})}))}getStats(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/stats`;return yield this.httpRequest.get(t)}))}getDocuments(t={}){var e;return o(this,void 0,void 0,(function*(){if(void 0===(t=v(t)).filter){const i=`indexes/${this.uid}/documents`,s=Array.isArray(null==t?void 0:t.fields)?{fields:null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}:{};return yield this.httpRequest.get(i,Object.assign(Object.assign({},t),s))}try{const e=`indexes/${this.uid}/documents/fetch`;return yield this.httpRequest.post(e,t)}catch(t){throw(t instanceof u||t instanceof a)&&(t.message=l(t.message,"getDocuments")),t}}))}getDocument(t,e){return o(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents/${t}`,s=(()=>{var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")})();return yield this.httpRequest.get(i,v(Object.assign(Object.assign({},e),{fields:s})))}))}addDocuments(t,e){return o(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents`,s=yield this.httpRequest.post(i,t,e);return new T(s)}))}addDocumentsFromString(t,e,i){return o(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/documents`,n=yield this.httpRequest.post(s,t,i,{headers:{"Content-Type":e}});return new T(n)}))}addDocumentsInBatches(t,e=1e3,i){return o(this,void 0,void 0,(function*(){const s=[];for(let n=0;n<t.length;n+=e)s.push(yield this.addDocuments(t.slice(n,n+e),i));return s}))}updateDocuments(t,e){return o(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents`,s=yield this.httpRequest.put(i,t,e);return new T(s)}))}updateDocumentsInBatches(t,e=1e3,i){return o(this,void 0,void 0,(function*(){const s=[];for(let n=0;n<t.length;n+=e)s.push(yield this.updateDocuments(t.slice(n,n+e),i));return s}))}updateDocumentsFromString(t,e,i){return o(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/documents`,n=yield this.httpRequest.put(s,t,i,{headers:{"Content-Type":e}});return new T(n)}))}deleteDocument(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/documents/${t}`,i=yield this.httpRequest.delete(e);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}deleteDocuments(t){return o(this,void 0,void 0,(function*(){const e=!Array.isArray(t)&&"object"==typeof t,i=e?"documents/delete":"documents/delete-batch",s=`indexes/${this.uid}/${i}`;try{const e=yield this.httpRequest.post(s,t);return new T(e)}catch(t){throw(t instanceof u&&e||t instanceof a)&&(t.message=l(t.message,"deleteDocuments")),t}}))}deleteAllDocuments(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/documents`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSettings(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings`;return yield this.httpRequest.get(t)}))}updateSettings(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings`,i=yield this.httpRequest.patch(e,t);return i.enqueued=new Date(i.enqueuedAt),i}))}resetSettings(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getPagination(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/pagination`;return yield this.httpRequest.get(t)}))}updatePagination(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/pagination`,i=yield this.httpRequest.patch(e,t);return new T(i)}))}resetPagination(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/pagination`,e=yield this.httpRequest.delete(t);return new T(e)}))}getSynonyms(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/synonyms`;return yield this.httpRequest.get(t)}))}updateSynonyms(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/synonyms`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetSynonyms(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/synonyms`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getStopWords(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/stop-words`;return yield this.httpRequest.get(t)}))}updateStopWords(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/stop-words`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetStopWords(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/stop-words`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getRankingRules(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/ranking-rules`;return yield this.httpRequest.get(t)}))}updateRankingRules(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/ranking-rules`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetRankingRules(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/ranking-rules`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getDistinctAttribute(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/distinct-attribute`;return yield this.httpRequest.get(t)}))}updateDistinctAttribute(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/distinct-attribute`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetDistinctAttribute(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/distinct-attribute`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getFilterableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/filterable-attributes`;return yield this.httpRequest.get(t)}))}updateFilterableAttributes(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/filterable-attributes`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetFilterableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/filterable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSortableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/sortable-attributes`;return yield this.httpRequest.get(t)}))}updateSortableAttributes(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/sortable-attributes`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetSortableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/sortable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSearchableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/searchable-attributes`;return yield this.httpRequest.get(t)}))}updateSearchableAttributes(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/searchable-attributes`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetSearchableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/searchable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getDisplayedAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/displayed-attributes`;return yield this.httpRequest.get(t)}))}updateDisplayedAttributes(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/displayed-attributes`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetDisplayedAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/displayed-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getTypoTolerance(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/typo-tolerance`;return yield this.httpRequest.get(t)}))}updateTypoTolerance(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/typo-tolerance`,i=yield this.httpRequest.patch(e,t);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}resetTypoTolerance(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/typo-tolerance`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getFaceting(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/faceting`;return yield this.httpRequest.get(t)}))}updateFaceting(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/faceting`,i=yield this.httpRequest.patch(e,t);return new T(i)}))}resetFaceting(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/faceting`,e=yield this.httpRequest.delete(t);return new T(e)}))}getSeparatorTokens(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/separator-tokens`;return yield this.httpRequest.get(t)}))}updateSeparatorTokens(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/separator-tokens`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetSeparatorTokens(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/separator-tokens`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getNonSeparatorTokens(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/non-separator-tokens`;return yield this.httpRequest.get(t)}))}updateNonSeparatorTokens(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/non-separator-tokens`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetNonSeparatorTokens(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/non-separator-tokens`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getDictionary(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/dictionary`;return yield this.httpRequest.get(t)}))}updateDictionary(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/dictionary`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetDictionary(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/dictionary`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getProximityPrecision(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/proximity-precision`;return yield this.httpRequest.get(t)}))}updateProximityPrecision(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/proximity-precision`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetProximityPrecision(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/proximity-precision`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getEmbedders(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/embedders`;return yield this.httpRequest.get(t)}))}updateEmbedders(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/embedders`,i=yield this.httpRequest.patch(e,t);return new T(i)}))}resetEmbedders(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/embedders`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}}function S(t){return Buffer.from(JSON.stringify(t)).toString("base64")}class D{constructor(t){this.config=t}generateTenantToken(e,i,s){const n=(null==s?void 0:s.apiKey)||this.config.apiKey||"",r=e||"",o=null==s?void 0:s.expiresAt;!function(t){const{searchRules:e,uid:i,apiKey:s,expiresAt:n}=t;if(n){if(!(n instanceof Date))throw new d("Meilisearch: The expiredAt field must be an instance of Date.");if(n.getTime()<Date.now())throw new d("Meilisearch: The expiresAt field must be a date in the future.")}if(e&&"object"!=typeof e&&!Array.isArray(e))throw new d("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!s||"string"!=typeof s)throw new d("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!i||"string"!=typeof i)throw new d("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(i))throw new d("Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().")}({apiKey:n,uid:r,expiresAt:o,searchRules:i});const u=S({alg:"HS256",typ:"JWT"}).replace(/=/g,""),a=function(t){const{searchRules:e,uid:i,expiresAt:s}=t;return S({searchRules:e,apiKeyUid:i,exp:s?Math.floor(s.getTime()/1e3):void 0}).replace(/=/g,"")}({searchRules:i,uid:r,expiresAt:o}),h=function(e,i,s){return t.createHmac("sha256",e).update(`${i}.${s}`).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(n,u,a);return`${u}.${a}.${h}`}}class R extends class{constructor(t){this.config=t,this.httpRequest=new f(t),this.tasks=new E(t)}index(t){return new g(this.config,t)}getIndex(t){return o(this,void 0,void 0,(function*(){return new g(this.config,t).fetchInfo()}))}getRawIndex(t){return o(this,void 0,void 0,(function*(){return new g(this.config,t).getRawInfo()}))}getIndexes(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.getRawIndexes(t),i=e.results.map((t=>new g(this.config,t.uid,t.primaryKey)));return Object.assign(Object.assign({},e),{results:i})}))}getRawIndexes(t={}){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.get("indexes",t)}))}createIndex(t,e={}){return o(this,void 0,void 0,(function*(){return yield g.create(t,e,this.config)}))}updateIndex(t,e={}){return o(this,void 0,void 0,(function*(){return yield new g(this.config,t).update(e)}))}deleteIndex(t){return o(this,void 0,void 0,(function*(){return yield new g(this.config,t).delete()}))}deleteIndexIfExists(t){return o(this,void 0,void 0,(function*(){try{return yield this.deleteIndex(t),!0}catch(t){if(t.code===r.INDEX_NOT_FOUND)return!1;throw t}}))}swapIndexes(t){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.post("/swap-indexes",t)}))}multiSearch(t,e){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.post("multi-search",t,void 0,e)}))}getTasks(t={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.getTasks(t)}))}getTask(t){return o(this,void 0,void 0,(function*(){return yield this.tasks.getTask(t)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:i})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:i})}))}cancelTasks(t){return o(this,void 0,void 0,(function*(){return yield this.tasks.cancelTasks(t)}))}deleteTasks(t={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.deleteTasks(t)}))}getKeys(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.httpRequest.get("keys",t);return e.results=e.results.map((t=>Object.assign(Object.assign({},t),{createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)}))),e}))}getKey(t){return o(this,void 0,void 0,(function*(){const e=`keys/${t}`;return yield this.httpRequest.get(e)}))}createKey(t){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.post("keys",t)}))}updateKey(t,e){return o(this,void 0,void 0,(function*(){const i=`keys/${t}`;return yield this.httpRequest.patch(i,e)}))}deleteKey(t){return o(this,void 0,void 0,(function*(){const e=`keys/${t}`;return yield this.httpRequest.delete(e)}))}health(){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.get("health")}))}isHealthy(){return o(this,void 0,void 0,(function*(){try{const t="health";return yield this.httpRequest.get(t),!0}catch(t){return!1}}))}getStats(){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.get("stats")}))}getVersion(){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.get("version")}))}createDump(){return o(this,void 0,void 0,(function*(){const t=yield this.httpRequest.post("dumps");return new T(t)}))}createSnapshot(){return o(this,void 0,void 0,(function*(){const t=yield this.httpRequest.post("snapshots");return new T(t)}))}generateTenantToken(t,e,i){const s=new Error;throw new Error(`Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ${s.stack}.`)}}{constructor(t){super(t),this.tokens=new D(t)}generateTenantToken(t,e,i){return"undefined"==typeof window?this.tokens.generateTenantToken(t,e,i):super.generateTenantToken(t,e,i)}}export{i as ContentTypeEnum,T as EnqueuedTask,r as ErrorStatusCode,g as Index,e as MatchingStrategies,R as MeiliSearch,a as MeiliSearchApiError,u as MeiliSearchCommunicationError,d as MeiliSearchError,_ as MeiliSearchTimeOutError,R as Meilisearch,y as Task,E as TaskClient,s as TaskStatus,n as TaskTypes,R as default,c as httpErrorHandler,h as httpResponseErrorHandler,l as versionErrorHintMessage};
import t from"crypto";const e={ALL:"all",LAST:"last"},i={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"},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"},r={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_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"};function o(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{u(s.next(t))}catch(t){r(t)}}function d(t){try{u(s.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,d)}u((s=s.apply(t,e||[])).next())}))}class d extends Error{constructor(t){super(t),Object.setPrototypeOf(this,d.prototype),this.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}class u extends d{constructor(t,e,i,s){var n,r,o;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),s?(this.stack=s,this.stack=null===(n=this.stack)||void 0===n?void 0:n.replace(/(TypeError|FetchError)/,this.name),this.stack=null===(r=this.stack)||void 0===r?void 0:r.replace("Failed to fetch",`request to ${i} failed, reason: connect ECONNREFUSED`),this.stack=null===(o=this.stack)||void 0===o?void 0:o.replace("Not Found",`Not Found: ${i}`)):Error.captureStackTrace&&Error.captureStackTrace(this,u)}}const a=class extends d{constructor(t,e){super(t.message),Object.setPrototypeOf(this,a.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,a)}};function h(t){return o(this,void 0,void 0,(function*(){if(!t.ok){let e;try{e=yield t.json()}catch(e){throw new u(t.statusText,t,t.url)}throw new a(e,t.status)}return t}))}function c(t,e,i){if("MeiliSearchApiError"!==t.name)throw new u(t.message,t,i,e);throw t}class _ extends d{constructor(t){super(t),Object.setPrototypeOf(this,_.prototype),this.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(this,_)}}function l(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 v(t){return Object.entries(t).reduce(((t,e)=>{const[i,s]=e;return void 0!==s&&(t[i]=s),t}),{})}function p(t){return o(this,void 0,void 0,(function*(){return yield new Promise((e=>setTimeout(e,t)))}))}function A(t){return Object.keys(t).reduce(((e,i)=>{const s=t[i];return void 0===s?e:Array.isArray(s)?Object.assign(Object.assign({},e),{[i]:s.join(",")}):s instanceof Date?Object.assign(Object.assign({},e),{[i]:s.toISOString()}):Object.assign(Object.assign({},e),{[i]:s})}),{})}function I(t){var e,i;const s="X-Meilisearch-Client",n="Meilisearch JavaScript (v0.38.0-v1.7.0-pre-release.0)",r=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,i)=>e[i]=t)),e}return Object.assign({},t)}(null!==(i=null===(e=t.requestConfig)||void 0===e?void 0:e.headers)&&void 0!==i?i:{});if(t.apiKey&&!r.Authorization&&(r.Authorization=`Bearer ${t.apiKey}`),r["Content-Type"]||(r["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){const e=t.clientAgents.concat(n);r[s]=e.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new d(`Meilisearch: The header "${s}" should be an array of string(s).\n`);r[s]=n}return r}class f{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 d("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new d("The provided host is not valid.")}}request({method:t,url:e,params:i,body:s,config:n={}}){var r;return o(this,void 0,void 0,(function*(){"undefined"==typeof fetch&&require("cross-fetch/polyfill");const o=new URL(e,this.url);if(i){const t=new URLSearchParams;Object.keys(i).filter((t=>null!==i[t])).map((e=>t.set(e,i[e]))),o.search=t.toString()}(null===(r=n.headers)||void 0===r?void 0:r["Content-Type"])||(s=JSON.stringify(s));const d=Object.assign(Object.assign({},this.headers),n.headers);try{const e=this.fetchWithTimeout(o.toString(),Object.assign(Object.assign(Object.assign({},n),this.requestConfig),{method:t,body:s,headers:d}),this.requestTimeout);if(this.httpClient)return yield e;const i=yield e.then((t=>h(t)));return yield i.json().catch((()=>{}))}catch(t){c(t,t.stack,o.toString())}}))}fetchWithTimeout(t,e,i){return o(this,void 0,void 0,(function*(){return new Promise(((s,n)=>{const r=[(this.httpClient?this.httpClient:fetch)(t,e)];let o;if(i){const t=new Promise(((t,e)=>{o=setTimeout((()=>{e(new Error("Error: Request Timed Out"))}),i)}));r.push(t)}Promise.race(r).then(s).catch(n).finally((()=>{clearTimeout(o)}))}))}))}get(t,e,i){return o(this,void 0,void 0,(function*(){return yield this.request({method:"GET",url:t,params:e,config:i})}))}post(t,e,i,s){return o(this,void 0,void 0,(function*(){return yield this.request({method:"POST",url:t,body:e,params:i,config:s})}))}put(t,e,i,s){return o(this,void 0,void 0,(function*(){return yield this.request({method:"PUT",url:t,body:e,params:i,config:s})}))}patch(t,e,i,s){return o(this,void 0,void 0,(function*(){return yield this.request({method:"PATCH",url:t,body:e,params:i,config:s})}))}delete(t,e,i,s){return o(this,void 0,void 0,(function*(){return yield this.request({method:"DELETE",url:t,body:e,params:i,config:s})}))}}class T{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{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{constructor(t){this.httpRequest=new f(t)}getTask(t){return o(this,void 0,void 0,(function*(){const e=`tasks/${t}`,i=yield this.httpRequest.get(e);return new y(i)}))}getTasks(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.httpRequest.get("tasks",A(t));return Object.assign(Object.assign({},e),{results:e.results.map((t=>new y(t)))})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){const n=Date.now();for(;Date.now()-n<e;){const e=yield this.getTask(t);if(![s.TASK_ENQUEUED,s.TASK_PROCESSING].includes(e.status))return e;yield p(i)}throw new _(`timeout of ${e}ms has exceeded on process ${t} when waiting a task to be resolved.`)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=yield this.waitForTask(n,{timeOutMs:e,intervalMs:i});s.push(t)}return s}))}cancelTasks(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.httpRequest.post("tasks/cancel",{},A(t));return new T(e)}))}deleteTasks(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.httpRequest.delete("tasks",{},A(t));return new T(e)}))}}class g{constructor(t,e,i){this.uid=e,this.primaryKey=i,this.httpRequest=new f(t),this.tasks=new E(t)}search(t,e,i){return o(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/search`;return yield this.httpRequest.post(s,v(Object.assign({q:t},e)),void 0,i)}))}searchGet(t,e,i){var s,n,r,u,a,h,c;return o(this,void 0,void 0,(function*(){const o=`indexes/${this.uid}/search`,_=Object.assign(Object.assign({q:t},e),{filter:(t=>{if("string"==typeof t)return t;if(Array.isArray(t))throw new d("The filter query parameter should be in string format when using searchGet")})(null==e?void 0:e.filter),sort:null===(s=null==e?void 0:e.sort)||void 0===s?void 0:s.join(","),facets:null===(n=null==e?void 0:e.facets)||void 0===n?void 0:n.join(","),attributesToRetrieve:null===(r=null==e?void 0:e.attributesToRetrieve)||void 0===r?void 0:r.join(","),attributesToCrop:null===(u=null==e?void 0:e.attributesToCrop)||void 0===u?void 0:u.join(","),attributesToHighlight:null===(a=null==e?void 0:e.attributesToHighlight)||void 0===a?void 0:a.join(","),vector:null===(h=null==e?void 0:e.vector)||void 0===h?void 0:h.join(","),attributesToSearchOn:null===(c=null==e?void 0:e.attributesToSearchOn)||void 0===c?void 0:c.join(",")});return yield this.httpRequest.get(o,v(_),i)}))}searchForFacetValues(t,e){return o(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/facet-search`;return yield this.httpRequest.post(i,v(t),void 0,e)}))}getRawInfo(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}`,e=yield this.httpRequest.get(t);return this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),e}))}fetchInfo(){return o(this,void 0,void 0,(function*(){return yield this.getRawInfo(),this}))}fetchPrimaryKey(){return o(this,void 0,void 0,(function*(){return this.primaryKey=(yield this.getRawInfo()).primaryKey,this.primaryKey}))}static create(t,e={},i){return o(this,void 0,void 0,(function*(){const s=new f(i),n=yield s.post("indexes",Object.assign(Object.assign({},e),{uid:t}));return new T(n)}))}update(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}`,i=yield this.httpRequest.patch(e,t);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}delete(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}`,e=yield this.httpRequest.delete(t);return new T(e)}))}getTasks(t={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.getTasks(Object.assign(Object.assign({},t),{indexUids:[this.uid]}))}))}getTask(t){return o(this,void 0,void 0,(function*(){return yield this.tasks.getTask(t)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:i})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:i})}))}getStats(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/stats`;return yield this.httpRequest.get(t)}))}getDocuments(t={}){var e;return o(this,void 0,void 0,(function*(){if(void 0===(t=v(t)).filter){const i=`indexes/${this.uid}/documents`,s=Array.isArray(null==t?void 0:t.fields)?{fields:null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}:{};return yield this.httpRequest.get(i,Object.assign(Object.assign({},t),s))}try{const e=`indexes/${this.uid}/documents/fetch`;return yield this.httpRequest.post(e,t)}catch(t){throw(t instanceof u||t instanceof a)&&(t.message=l(t.message,"getDocuments")),t}}))}getDocument(t,e){return o(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents/${t}`,s=(()=>{var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")})();return yield this.httpRequest.get(i,v(Object.assign(Object.assign({},e),{fields:s})))}))}addDocuments(t,e){return o(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents`,s=yield this.httpRequest.post(i,t,e);return new T(s)}))}addDocumentsFromString(t,e,i){return o(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/documents`,n=yield this.httpRequest.post(s,t,i,{headers:{"Content-Type":e}});return new T(n)}))}addDocumentsInBatches(t,e=1e3,i){return o(this,void 0,void 0,(function*(){const s=[];for(let n=0;n<t.length;n+=e)s.push(yield this.addDocuments(t.slice(n,n+e),i));return s}))}updateDocuments(t,e){return o(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents`,s=yield this.httpRequest.put(i,t,e);return new T(s)}))}updateDocumentsInBatches(t,e=1e3,i){return o(this,void 0,void 0,(function*(){const s=[];for(let n=0;n<t.length;n+=e)s.push(yield this.updateDocuments(t.slice(n,n+e),i));return s}))}updateDocumentsFromString(t,e,i){return o(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/documents`,n=yield this.httpRequest.put(s,t,i,{headers:{"Content-Type":e}});return new T(n)}))}deleteDocument(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/documents/${t}`,i=yield this.httpRequest.delete(e);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}deleteDocuments(t){return o(this,void 0,void 0,(function*(){const e=!Array.isArray(t)&&"object"==typeof t,i=e?"documents/delete":"documents/delete-batch",s=`indexes/${this.uid}/${i}`;try{const e=yield this.httpRequest.post(s,t);return new T(e)}catch(t){throw(t instanceof u&&e||t instanceof a)&&(t.message=l(t.message,"deleteDocuments")),t}}))}deleteAllDocuments(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/documents`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSettings(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings`;return yield this.httpRequest.get(t)}))}updateSettings(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings`,i=yield this.httpRequest.patch(e,t);return i.enqueued=new Date(i.enqueuedAt),i}))}resetSettings(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getPagination(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/pagination`;return yield this.httpRequest.get(t)}))}updatePagination(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/pagination`,i=yield this.httpRequest.patch(e,t);return new T(i)}))}resetPagination(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/pagination`,e=yield this.httpRequest.delete(t);return new T(e)}))}getSynonyms(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/synonyms`;return yield this.httpRequest.get(t)}))}updateSynonyms(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/synonyms`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetSynonyms(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/synonyms`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getStopWords(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/stop-words`;return yield this.httpRequest.get(t)}))}updateStopWords(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/stop-words`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetStopWords(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/stop-words`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getRankingRules(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/ranking-rules`;return yield this.httpRequest.get(t)}))}updateRankingRules(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/ranking-rules`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetRankingRules(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/ranking-rules`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getDistinctAttribute(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/distinct-attribute`;return yield this.httpRequest.get(t)}))}updateDistinctAttribute(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/distinct-attribute`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetDistinctAttribute(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/distinct-attribute`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getFilterableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/filterable-attributes`;return yield this.httpRequest.get(t)}))}updateFilterableAttributes(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/filterable-attributes`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetFilterableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/filterable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSortableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/sortable-attributes`;return yield this.httpRequest.get(t)}))}updateSortableAttributes(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/sortable-attributes`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetSortableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/sortable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSearchableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/searchable-attributes`;return yield this.httpRequest.get(t)}))}updateSearchableAttributes(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/searchable-attributes`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetSearchableAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/searchable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getDisplayedAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/displayed-attributes`;return yield this.httpRequest.get(t)}))}updateDisplayedAttributes(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/displayed-attributes`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetDisplayedAttributes(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/displayed-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getTypoTolerance(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/typo-tolerance`;return yield this.httpRequest.get(t)}))}updateTypoTolerance(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/typo-tolerance`,i=yield this.httpRequest.patch(e,t);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}resetTypoTolerance(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/typo-tolerance`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getFaceting(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/faceting`;return yield this.httpRequest.get(t)}))}updateFaceting(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/faceting`,i=yield this.httpRequest.patch(e,t);return new T(i)}))}resetFaceting(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/faceting`,e=yield this.httpRequest.delete(t);return new T(e)}))}getSeparatorTokens(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/separator-tokens`;return yield this.httpRequest.get(t)}))}updateSeparatorTokens(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/separator-tokens`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetSeparatorTokens(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/separator-tokens`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getNonSeparatorTokens(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/non-separator-tokens`;return yield this.httpRequest.get(t)}))}updateNonSeparatorTokens(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/non-separator-tokens`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetNonSeparatorTokens(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/non-separator-tokens`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getDictionary(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/dictionary`;return yield this.httpRequest.get(t)}))}updateDictionary(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/dictionary`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetDictionary(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/dictionary`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getProximityPrecision(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/proximity-precision`;return yield this.httpRequest.get(t)}))}updateProximityPrecision(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/proximity-precision`,i=yield this.httpRequest.put(e,t);return new T(i)}))}resetProximityPrecision(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/proximity-precision`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getEmbedders(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/embedders`;return yield this.httpRequest.get(t)}))}updateEmbedders(t){return o(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/embedders`,i=yield this.httpRequest.patch(e,t);return new T(i)}))}resetEmbedders(){return o(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/embedders`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}}function S(t){return Buffer.from(JSON.stringify(t)).toString("base64")}class D{constructor(t){this.config=t}generateTenantToken(e,i,s){const n=(null==s?void 0:s.apiKey)||this.config.apiKey||"",r=e||"",o=null==s?void 0:s.expiresAt;!function(t){const{searchRules:e,uid:i,apiKey:s,expiresAt:n}=t;if(n){if(!(n instanceof Date))throw new d("Meilisearch: The expiredAt field must be an instance of Date.");if(n.getTime()<Date.now())throw new d("Meilisearch: The expiresAt field must be a date in the future.")}if(e&&"object"!=typeof e&&!Array.isArray(e))throw new d("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!s||"string"!=typeof s)throw new d("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!i||"string"!=typeof i)throw new d("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(i))throw new d("Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().")}({apiKey:n,uid:r,expiresAt:o,searchRules:i});const u=S({alg:"HS256",typ:"JWT"}).replace(/=/g,""),a=function(t){const{searchRules:e,uid:i,expiresAt:s}=t;return S({searchRules:e,apiKeyUid:i,exp:s?Math.floor(s.getTime()/1e3):void 0}).replace(/=/g,"")}({searchRules:i,uid:r,expiresAt:o}),h=function(e,i,s){return t.createHmac("sha256",e).update(`${i}.${s}`).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(n,u,a);return`${u}.${a}.${h}`}}class R extends class{constructor(t){this.config=t,this.httpRequest=new f(t),this.tasks=new E(t)}index(t){return new g(this.config,t)}getIndex(t){return o(this,void 0,void 0,(function*(){return new g(this.config,t).fetchInfo()}))}getRawIndex(t){return o(this,void 0,void 0,(function*(){return new g(this.config,t).getRawInfo()}))}getIndexes(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.getRawIndexes(t),i=e.results.map((t=>new g(this.config,t.uid,t.primaryKey)));return Object.assign(Object.assign({},e),{results:i})}))}getRawIndexes(t={}){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.get("indexes",t)}))}createIndex(t,e={}){return o(this,void 0,void 0,(function*(){return yield g.create(t,e,this.config)}))}updateIndex(t,e={}){return o(this,void 0,void 0,(function*(){return yield new g(this.config,t).update(e)}))}deleteIndex(t){return o(this,void 0,void 0,(function*(){return yield new g(this.config,t).delete()}))}deleteIndexIfExists(t){return o(this,void 0,void 0,(function*(){try{return yield this.deleteIndex(t),!0}catch(t){if(t.code===r.INDEX_NOT_FOUND)return!1;throw t}}))}swapIndexes(t){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.post("/swap-indexes",t)}))}multiSearch(t,e){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.post("multi-search",t,void 0,e)}))}getTasks(t={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.getTasks(t)}))}getTask(t){return o(this,void 0,void 0,(function*(){return yield this.tasks.getTask(t)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:i})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:i})}))}cancelTasks(t){return o(this,void 0,void 0,(function*(){return yield this.tasks.cancelTasks(t)}))}deleteTasks(t={}){return o(this,void 0,void 0,(function*(){return yield this.tasks.deleteTasks(t)}))}getKeys(t={}){return o(this,void 0,void 0,(function*(){const e=yield this.httpRequest.get("keys",t);return e.results=e.results.map((t=>Object.assign(Object.assign({},t),{createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)}))),e}))}getKey(t){return o(this,void 0,void 0,(function*(){const e=`keys/${t}`;return yield this.httpRequest.get(e)}))}createKey(t){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.post("keys",t)}))}updateKey(t,e){return o(this,void 0,void 0,(function*(){const i=`keys/${t}`;return yield this.httpRequest.patch(i,e)}))}deleteKey(t){return o(this,void 0,void 0,(function*(){const e=`keys/${t}`;return yield this.httpRequest.delete(e)}))}health(){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.get("health")}))}isHealthy(){return o(this,void 0,void 0,(function*(){try{const t="health";return yield this.httpRequest.get(t),!0}catch(t){return!1}}))}getStats(){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.get("stats")}))}getVersion(){return o(this,void 0,void 0,(function*(){return yield this.httpRequest.get("version")}))}createDump(){return o(this,void 0,void 0,(function*(){const t=yield this.httpRequest.post("dumps");return new T(t)}))}createSnapshot(){return o(this,void 0,void 0,(function*(){const t=yield this.httpRequest.post("snapshots");return new T(t)}))}generateTenantToken(t,e,i){const s=new Error;throw new Error(`Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ${s.stack}.`)}}{constructor(t){super(t),this.tokens=new D(t)}generateTenantToken(t,e,i){return"undefined"==typeof window?this.tokens.generateTenantToken(t,e,i):super.generateTenantToken(t,e,i)}}export{i as ContentTypeEnum,T as EnqueuedTask,r as ErrorStatusCode,g as Index,e as MatchingStrategies,R as MeiliSearch,a as MeiliSearchApiError,u as MeiliSearchCommunicationError,d as MeiliSearchError,_ as MeiliSearchTimeOutError,R as Meilisearch,y as Task,E as TaskClient,s as TaskStatus,n as TaskTypes,R as default,c as httpErrorHandler,h as httpResponseErrorHandler,l as versionErrorHintMessage};
//# sourceMappingURL=meilisearch.esm.min.js.map

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

// Type definitions for meilisearch 0.37.0
// Type definitions for meilisearch 0.38.0-v1.7.0-pre-release.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.37.0";
export declare const PACKAGE_VERSION = "0.38.0-v1.7.0-pre-release.0";
//# sourceMappingURL=package-version.d.ts.map

@@ -196,2 +196,4 @@ import { Task } from '../task';

filter?: Filter;
limit?: number;
offset?: number;
};

@@ -233,2 +235,3 @@ export type DocumentQuery<T = Record<string, any>> = {

documentTemplate?: string;
dimensions?: number;
};

@@ -235,0 +238,0 @@ export type HuggingFaceEmbedder = {

{
"name": "meilisearch",
"version": "0.37.0",
"version": "0.38.0-v1.7.0-pre-release.0",
"description": "The Meilisearch JS client for Node.js and the browser.",

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

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

<a href="https://github.com/meilisearch/meilisearch-js/actions"><img src="https://github.com/meilisearch/meilisearch-js/workflows/Tests/badge.svg" alt="Tests"></a>
<a href="https://codecov.io/gh/meilisearch/meilisearch-python">
<a href="https://codecov.io/gh/meilisearch/meilisearch-js">
<img src="https://codecov.io/github/meilisearch/meilisearch-js/coverage.svg?branch=main" alt="Codecov">

@@ -987,3 +987,3 @@ </a>

⚠️ This feature is experimental. Activate the `vectorStore` experimental feature to use it](https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features)
⚠️ This feature is experimental. Activate the [`vectorStore` experimental feature to use it](https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features)

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

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

export const PACKAGE_VERSION = '0.37.0'
export const PACKAGE_VERSION = '0.38.0-v1.7.0-pre-release.0'

@@ -289,2 +289,4 @@ // Type definitions for meilisearch

filter?: Filter
limit?: number
offset?: number
}

@@ -335,2 +337,3 @@

documentTemplate?: string
dimensions?: number
}

@@ -349,2 +352,3 @@

}
export type Embedder =

@@ -351,0 +355,0 @@ | OpenAiEmbedder

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

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