meilisearch
Version:
The Meilisearch JS client for Node.js and the browser.
3 lines (2 loc) • 29.3 kB
JavaScript
(function(a,_){typeof exports=="object"&&typeof module!="undefined"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(a=typeof globalThis!="undefined"?globalThis:a||self,_(a.meilisearch={}))})(this,function(a){"use strict";var St=Object.defineProperty,yt=Object.defineProperties;var Nt=Object.getOwnPropertyDescriptors;var ot=Object.getOwnPropertySymbols;var Dt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var at=(a,_)=>(_=Symbol[a])?_:Symbol.for("Symbol."+a),lt=a=>{throw TypeError(a)};var nt=(a,_,d)=>_ in a?St(a,_,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[_]=d,S=(a,_)=>{for(var d in _||(_={}))Dt.call(_,d)&&nt(a,d,_[d]);if(ot)for(var d of ot(_))Rt.call(_,d)&&nt(a,d,_[d]);return a},m=(a,_)=>yt(a,Nt(_));var I=(a,_,d)=>nt(a,typeof _!="symbol"?_+"":_,d),rt=(a,_,d)=>_.has(a)||lt("Cannot "+d);var s=(a,_,d)=>(rt(a,_,"read from private field"),d?d.call(a):_.get(a)),E=(a,_,d)=>_.has(a)?lt("Cannot add the same private member more than once"):_ instanceof WeakSet?_.add(a):_.set(a,d),y=(a,_,d,T)=>(rt(a,_,"write to private field"),T?T.call(a,d):_.set(a,d),d),F=(a,_,d)=>(rt(a,_,"access private method"),d);var n=(a,_,d)=>new Promise((T,p)=>{var g=l=>{try{A(d.next(l))}catch(D){p(D)}},N=l=>{try{A(d.throw(l))}catch(D){p(D)}},A=l=>l.done?T(l.value):Promise.resolve(l.value).then(g,N);A((d=d.apply(a,_)).next())}),W=function(a,_){this[0]=a,this[1]=_},It=(a,_,d)=>{var T=(N,A,l,D)=>{try{var z=d[N](A),Q=(A=z.value)instanceof W,J=z.done;Promise.resolve(Q?A[0]:A).then(f=>Q?T(N==="return"?N:"next",A[1]?{done:f.done,value:f.value}:f,l,D):l({value:f,done:J})).catch(f=>T("throw",f,l,D))}catch(f){D(f)}},p=N=>g[N]=A=>new Promise((l,D)=>T(N,A,l,D)),g={};return d=d.apply(a,_),g[at("asyncIterator")]=()=>g,p("next"),p("throw"),p("return"),g};var _t=(a,_,d)=>(_=a[at("asyncIterator")])?_.call(a):(a=a[at("iterator")](),_={},d=(T,p)=>(p=a[T])&&(_[T]=g=>new Promise((N,A,l)=>(g=p.call(a,g),l=g.done,Promise.resolve(g.value).then(D=>N({value:D,done:l}),A)))),d("next"),d("return"),_);var G,O,q,$,b,pt,K,k,Y,B,U,r,H,X,j,M;const _={ALL:"all",LAST:"last",FREQUENCY:"frequency"},d={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},T={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_SETTINGS_LOCALIZED_ATTRIBUTES:"invalid_settings_localized_attributes",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",INVALID_SEARCH_RANKING_SCORE_THRESHOLD:"invalid_search_ranking_score_threshold",INVALID_SIMILAR_RANKING_SCORE_THRESHOLD:"invalid_similar_ranking_score_threshold"};class p extends Error{constructor(){super(...arguments);I(this,"name","MeiliSearchError")}}class g extends p{constructor(e,i){var h;super((h=i==null?void 0:i.message)!=null?h:`${e.status}: ${e.statusText}`);I(this,"name","MeiliSearchApiError");I(this,"cause");I(this,"response");this.response=e,i!==void 0&&(this.cause=i)}}class N extends p{constructor(e,i){super(`Request to ${e} has failed`,{cause:i});I(this,"name","MeiliSearchRequestError")}}class A extends p{constructor(e,i){super(`request timed out after ${e}ms`);I(this,"name","MeiliSearchRequestTimeOutError");I(this,"cause");this.cause={timeout:e,requestInit:i}}}class l extends p{constructor(e,i){super(`timeout of ${i}ms has exceeded on task ${e} when waiting for it to be resolved.`);I(this,"name","MeiliSearchTaskTimeOutError");I(this,"cause");this.cause={taskUid:e,timeout:i}}}const D="0.51.0";function z(u){return u.startsWith("https://")||u.startsWith("http://")?u:`http://${u}`}function Q(u){return u.endsWith("/")||(u+="/"),u}function J(u,t){for(const[e,i]of Object.entries(t))i!=null&&u.set(e,Array.isArray(i)?i.join():i instanceof Date?i.toISOString():String(i))}function f(u,t){const e="X-Meilisearch-Client",i=`Meilisearch JavaScript (v${D})`,h="Content-Type",c="Authorization",o=new Headers(t);if(u.apiKey&&!o.has(c)&&o.set(c,`Bearer ${u.apiKey}`),o.has(h)||o.set(h,"application/json"),u.clientAgents!==void 0){const L=u.clientAgents.concat(i);o.set(e,L.join(" ; "))}else o.set(e,i);return o}const Z=Symbol("<timeout>");function At(u,t){const{signal:e}=u,i=new AbortController;if(e!=null){let h=null;if(e.aborted)i.abort(e.reason);else{const c=()=>i.abort(e.reason);e.addEventListener("abort",c,{once:!0}),h=()=>e.removeEventListener("abort",c),i.signal.addEventListener("abort",h,{once:!0})}return()=>{if(e.aborted)return;const c=setTimeout(()=>i.abort(Z),t),o=()=>{clearTimeout(c),h!==null&&i.signal.removeEventListener("abort",h)};return e.addEventListener("abort",o,{once:!0}),()=>{e.removeEventListener("abort",o),o()}}}return u.signal=i.signal,()=>{const h=setTimeout(()=>i.abort(Z),t);return()=>clearTimeout(h)}}class tt{constructor(t){E(this,b);E(this,G);E(this,O);E(this,q);E(this,$);var i;const e=Q(z(t.host));try{y(this,G,new URL(e))}catch(h){throw new p("The provided host is not valid",{cause:h})}y(this,O,m(S({},t.requestInit),{headers:f(t,(i=t.requestInit)==null?void 0:i.headers)})),y(this,q,t.httpClient),y(this,$,t.timeout)}get(t){return F(this,b,K).call(this,t)}post(t){return F(this,b,K).call(this,m(S({},t),{method:"POST"}))}put(t){return F(this,b,K).call(this,m(S({},t),{method:"PUT"}))}patch(t){return F(this,b,K).call(this,m(S({},t),{method:"PATCH"}))}delete(t){return F(this,b,K).call(this,m(S({},t),{method:"DELETE"}))}}G=new WeakMap,O=new WeakMap,q=new WeakMap,$=new WeakMap,b=new WeakSet,pt=function(t,e){if(t===void 0&&e===void 0)return s(this,O).headers;const i=new Headers(t);e!==void 0&&!i.has("Content-Type")&&i.set("Content-Type",e);for(const[h,c]of s(this,O).headers)i.has(h)||i.set(h,c);return i},K=function(L){return n(this,arguments,function*({path:t,method:e,params:i,contentType:h,body:c,extraRequestInit:o}){const x=new URL(t,s(this,G));i!==void 0&&J(x.searchParams,i);const w=m(S(S({method:e,body:h===void 0||typeof c!="string"?JSON.stringify(c):c},o),s(this,O)),{headers:F(this,b,pt).call(this,o==null?void 0:o.headers,h)}),R=s(this,$)!==void 0?At(w,s(this,$)):null,C=R==null?void 0:R();let V,P;try{if(s(this,q)!==void 0)return yield s(this,q).call(this,x,w);V=yield fetch(x,w),P=yield V.text()}catch(ct){throw new N(x.toString(),Object.is(ct,Z)?new A(s(this,$),w):ct)}finally{C==null||C()}const ut=P===""?void 0:JSON.parse(P);if(!V.ok)throw new g(V,ut);return ut})};const ht=Symbol("<task timeout>");function dt(u){return function(t){return Object.defineProperty(t,"waitTask",{value(i){return n(this,null,function*(){return yield u.waitForTask(yield t,i)})}})}}const Et=u=>typeof u=="number"?u:u.taskUid;class et{constructor(t,e){E(this,k);E(this,Y);E(this,B);E(this,U);var i,h;y(this,k,t),y(this,Y,(i=e==null?void 0:e.timeout)!=null?i:5e3),y(this,B,(h=e==null?void 0:e.interval)!=null?h:50),y(this,U,dt(this))}getTask(t,e){return n(this,null,function*(){return yield s(this,k).get({path:`tasks/${t}`,extraRequestInit:e})})}getTasks(t){return n(this,null,function*(){return yield s(this,k).get({path:"tasks",params:t})})}waitForTask(t,e){return n(this,null,function*(){var x,w;const i=Et(t),h=(x=e==null?void 0:e.timeout)!=null?x:s(this,Y),c=(w=e==null?void 0:e.interval)!=null?w:s(this,B),o=h>0?new AbortController:null,L=o!==null?setTimeout(()=>void o.abort(ht),h):void 0;try{for(;;){const R=yield this.getTask(i,{signal:o==null?void 0:o.signal});if(R.status!=="enqueued"&&R.status!=="processing")return clearTimeout(L),R;c>0&&(yield new Promise(C=>setTimeout(C,c)))}}catch(R){throw Object.is(R.cause,ht)?new l(i,h):R}})}waitForTasksIter(t,e){return It(this,null,function*(){try{for(var i=_t(t),h,c,o;h=!(c=yield new W(i.next())).done;h=!1){const L=c.value;yield yield new W(this.waitForTask(L,e))}}catch(c){o=[c]}finally{try{h&&(c=i.return)&&(yield new W(c.call(i)))}finally{if(o)throw o[0]}}})}waitForTasks(...t){return n(this,null,function*(){const e=[];try{for(var i=_t(this.waitForTasksIter(...t)),h,c,o;h=!(c=yield i.next()).done;h=!1){const L=c.value;e.push(L)}}catch(c){o=[c]}finally{try{h&&(c=i.return)&&(yield c.call(i))}finally{if(o)throw o[0]}}return e})}cancelTasks(t){return s(this,U).call(this,s(this,k).post({path:"tasks/cancel",params:t}))}deleteTasks(t){return s(this,U).call(this,s(this,k).delete({path:"tasks",params:t}))}}k=new WeakMap,Y=new WeakMap,B=new WeakMap,U=new WeakMap;function it(u,t){const e=dt(t);return{post:(...i)=>e(u.post(...i)),put:(...i)=>e(u.put(...i)),patch:(...i)=>e(u.patch(...i)),delete:(...i)=>e(u.delete(...i))}}class v{constructor(t,e,i){I(this,"uid");I(this,"primaryKey");I(this,"createdAt");I(this,"updatedAt");I(this,"httpRequest");I(this,"tasks");E(this,r);this.uid=e,this.primaryKey=i,this.httpRequest=new tt(t),this.tasks=new et(this.httpRequest,t.defaultWaitOptions),y(this,r,it(this.httpRequest,this.tasks))}search(t,e,i){return n(this,null,function*(){return yield this.httpRequest.post({path:`indexes/${this.uid}/search`,body:S({q:t},e),extraRequestInit:i})})}searchGet(t,e,i){return n(this,null,function*(){var o,L,x,w,R,C,V;const h=P=>{if(typeof P=="string")return P;if(Array.isArray(P))throw new p("The filter query parameter should be in string format when using searchGet")},c=m(S({q:t},e),{filter:h(e==null?void 0:e.filter),sort:(o=e==null?void 0:e.sort)==null?void 0:o.join(","),facets:(L=e==null?void 0:e.facets)==null?void 0:L.join(","),attributesToRetrieve:(x=e==null?void 0:e.attributesToRetrieve)==null?void 0:x.join(","),attributesToCrop:(w=e==null?void 0:e.attributesToCrop)==null?void 0:w.join(","),attributesToHighlight:(R=e==null?void 0:e.attributesToHighlight)==null?void 0:R.join(","),vector:(C=e==null?void 0:e.vector)==null?void 0:C.join(","),attributesToSearchOn:(V=e==null?void 0:e.attributesToSearchOn)==null?void 0:V.join(",")});return yield this.httpRequest.get({path:`indexes/${this.uid}/search`,params:c,extraRequestInit:i})})}searchForFacetValues(t,e){return n(this,null,function*(){return yield this.httpRequest.post({path:`indexes/${this.uid}/facet-search`,body:t,extraRequestInit:e})})}searchSimilarDocuments(t){return n(this,null,function*(){return yield this.httpRequest.post({path:`indexes/${this.uid}/similar`,body:t})})}getRawInfo(){return n(this,null,function*(){const t=yield this.httpRequest.get({path:`indexes/${this.uid}`});return this.primaryKey=t.primaryKey,this.updatedAt=new Date(t.updatedAt),this.createdAt=new Date(t.createdAt),t})}fetchInfo(){return n(this,null,function*(){return yield this.getRawInfo(),this})}fetchPrimaryKey(){return n(this,null,function*(){return this.primaryKey=(yield this.getRawInfo()).primaryKey,this.primaryKey})}static create(t,e={},i){const h=new tt(i);return it(h,new et(h)).post({path:"indexes",body:m(S({},e),{uid:t})})}update(t){return s(this,r).patch({path:`indexes/${this.uid}`,body:t})}delete(){return s(this,r).delete({path:`indexes/${this.uid}`})}getStats(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/stats`})})}getDocuments(t){return n(this,null,function*(){const e=`indexes/${this.uid}/documents`;return(t==null?void 0:t.filter)!==void 0?yield this.httpRequest.post({path:`${e}/fetch`,body:t}):yield this.httpRequest.get({path:e,params:t})})}getDocument(t,e){return n(this,null,function*(){const i=Array.isArray(e==null?void 0:e.fields)?e.fields.join():void 0;return yield this.httpRequest.get({path:`indexes/${this.uid}/documents/${t}`,params:m(S({},e),{fields:i})})})}addDocuments(t,e){return s(this,r).post({path:`indexes/${this.uid}/documents`,params:e,body:t})}addDocumentsFromString(t,e,i){return s(this,r).post({path:`indexes/${this.uid}/documents`,body:t,params:i,contentType:e})}addDocumentsInBatches(t,e=1e3,i){const h=[];for(let c=0;c<t.length;c+=e)h.push(this.addDocuments(t.slice(c,c+e),i));return h}updateDocuments(t,e){return s(this,r).put({path:`indexes/${this.uid}/documents`,params:e,body:t})}updateDocumentsInBatches(t,e=1e3,i){const h=[];for(let c=0;c<t.length;c+=e)h.push(this.updateDocuments(t.slice(c,c+e),i));return h}updateDocumentsFromString(t,e,i){return s(this,r).put({path:`indexes/${this.uid}/documents`,body:t,params:i,contentType:e})}deleteDocument(t){return s(this,r).delete({path:`indexes/${this.uid}/documents/${t}`})}deleteDocuments(t){const i=!Array.isArray(t)&&typeof t=="object"?"documents/delete":"documents/delete-batch";return s(this,r).post({path:`indexes/${this.uid}/${i}`,body:t})}deleteAllDocuments(){return s(this,r).delete({path:`indexes/${this.uid}/documents`})}updateDocumentsByFunction(t){return s(this,r).post({path:`indexes/${this.uid}/documents/edit`,body:t})}getSettings(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings`})})}updateSettings(t){return s(this,r).patch({path:`indexes/${this.uid}/settings`,body:t})}resetSettings(){return s(this,r).delete({path:`indexes/${this.uid}/settings`})}getPagination(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/pagination`})})}updatePagination(t){return s(this,r).patch({path:`indexes/${this.uid}/settings/pagination`,body:t})}resetPagination(){return s(this,r).delete({path:`indexes/${this.uid}/settings/pagination`})}getSynonyms(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/synonyms`})})}updateSynonyms(t){return s(this,r).put({path:`indexes/${this.uid}/settings/synonyms`,body:t})}resetSynonyms(){return s(this,r).delete({path:`indexes/${this.uid}/settings/synonyms`})}getStopWords(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/stop-words`})})}updateStopWords(t){return s(this,r).put({path:`indexes/${this.uid}/settings/stop-words`,body:t})}resetStopWords(){return s(this,r).delete({path:`indexes/${this.uid}/settings/stop-words`})}getRankingRules(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/ranking-rules`})})}updateRankingRules(t){return s(this,r).put({path:`indexes/${this.uid}/settings/ranking-rules`,body:t})}resetRankingRules(){return s(this,r).delete({path:`indexes/${this.uid}/settings/ranking-rules`})}getDistinctAttribute(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/distinct-attribute`})})}updateDistinctAttribute(t){return s(this,r).put({path:`indexes/${this.uid}/settings/distinct-attribute`,body:t})}resetDistinctAttribute(){return s(this,r).delete({path:`indexes/${this.uid}/settings/distinct-attribute`})}getFilterableAttributes(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/filterable-attributes`})})}updateFilterableAttributes(t){return s(this,r).put({path:`indexes/${this.uid}/settings/filterable-attributes`,body:t})}resetFilterableAttributes(){return s(this,r).delete({path:`indexes/${this.uid}/settings/filterable-attributes`})}getSortableAttributes(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/sortable-attributes`})})}updateSortableAttributes(t){return s(this,r).put({path:`indexes/${this.uid}/settings/sortable-attributes`,body:t})}resetSortableAttributes(){return s(this,r).delete({path:`indexes/${this.uid}/settings/sortable-attributes`})}getSearchableAttributes(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/searchable-attributes`})})}updateSearchableAttributes(t){return s(this,r).put({path:`indexes/${this.uid}/settings/searchable-attributes`,body:t})}resetSearchableAttributes(){return s(this,r).delete({path:`indexes/${this.uid}/settings/searchable-attributes`})}getDisplayedAttributes(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/displayed-attributes`})})}updateDisplayedAttributes(t){return s(this,r).put({path:`indexes/${this.uid}/settings/displayed-attributes`,body:t})}resetDisplayedAttributes(){return s(this,r).delete({path:`indexes/${this.uid}/settings/displayed-attributes`})}getTypoTolerance(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/typo-tolerance`})})}updateTypoTolerance(t){return s(this,r).patch({path:`indexes/${this.uid}/settings/typo-tolerance`,body:t})}resetTypoTolerance(){return s(this,r).delete({path:`indexes/${this.uid}/settings/typo-tolerance`})}getFaceting(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/faceting`})})}updateFaceting(t){return s(this,r).patch({path:`indexes/${this.uid}/settings/faceting`,body:t})}resetFaceting(){return s(this,r).delete({path:`indexes/${this.uid}/settings/faceting`})}getSeparatorTokens(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/separator-tokens`})})}updateSeparatorTokens(t){return s(this,r).put({path:`indexes/${this.uid}/settings/separator-tokens`,body:t})}resetSeparatorTokens(){return s(this,r).delete({path:`indexes/${this.uid}/settings/separator-tokens`})}getNonSeparatorTokens(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/non-separator-tokens`})})}updateNonSeparatorTokens(t){return s(this,r).put({path:`indexes/${this.uid}/settings/non-separator-tokens`,body:t})}resetNonSeparatorTokens(){return s(this,r).delete({path:`indexes/${this.uid}/settings/non-separator-tokens`})}getDictionary(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/dictionary`})})}updateDictionary(t){return s(this,r).put({path:`indexes/${this.uid}/settings/dictionary`,body:t})}resetDictionary(){return s(this,r).delete({path:`indexes/${this.uid}/settings/dictionary`})}getProximityPrecision(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/proximity-precision`})})}updateProximityPrecision(t){return s(this,r).put({path:`indexes/${this.uid}/settings/proximity-precision`,body:t})}resetProximityPrecision(){return s(this,r).delete({path:`indexes/${this.uid}/settings/proximity-precision`})}getEmbedders(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/embedders`})})}updateEmbedders(t){return s(this,r).patch({path:`indexes/${this.uid}/settings/embedders`,body:t})}resetEmbedders(){return s(this,r).delete({path:`indexes/${this.uid}/settings/embedders`})}getSearchCutoffMs(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/search-cutoff-ms`})})}updateSearchCutoffMs(t){return s(this,r).put({path:`indexes/${this.uid}/settings/search-cutoff-ms`,body:t})}resetSearchCutoffMs(){return s(this,r).delete({path:`indexes/${this.uid}/settings/search-cutoff-ms`})}getLocalizedAttributes(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/localized-attributes`})})}updateLocalizedAttributes(t){return s(this,r).put({path:`indexes/${this.uid}/settings/localized-attributes`,body:t})}resetLocalizedAttributes(){return s(this,r).delete({path:`indexes/${this.uid}/settings/localized-attributes`})}getFacetSearch(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/facet-search`})})}updateFacetSearch(t){return s(this,r).put({path:`indexes/${this.uid}/settings/facet-search`,body:t})}resetFacetSearch(){return s(this,r).delete({path:`indexes/${this.uid}/settings/facet-search`})}getPrefixSearch(){return n(this,null,function*(){return yield this.httpRequest.get({path:`indexes/${this.uid}/settings/prefix-search`})})}updatePrefixSearch(t){return s(this,r).put({path:`indexes/${this.uid}/settings/prefix-search`,body:t})}resetPrefixSearch(){return s(this,r).delete({path:`indexes/${this.uid}/settings/prefix-search`})}}r=new WeakMap;class Tt{constructor(t){E(this,H);y(this,H,t)}getBatch(t){return n(this,null,function*(){return yield s(this,H).get({path:`batches/${t}`})})}getBatches(t){return n(this,null,function*(){return yield s(this,H).get({path:"batches",params:t})})}}H=new WeakMap;class st{constructor(t){I(this,"config");I(this,"httpRequest");E(this,X);E(this,j);E(this,M);this.config=t,this.httpRequest=new tt(t),y(this,X,new et(this.httpRequest,t.defaultWaitOptions)),y(this,j,new Tt(this.httpRequest)),y(this,M,it(this.httpRequest,this.tasks))}get tasks(){return s(this,X)}get batches(){return s(this,j)}index(t){return new v(this.config,t)}getIndex(t){return n(this,null,function*(){return new v(this.config,t).fetchInfo()})}getRawIndex(t){return n(this,null,function*(){return new v(this.config,t).getRawInfo()})}getIndexes(t){return n(this,null,function*(){const e=yield this.getRawIndexes(t),i=e.results.map(h=>new v(this.config,h.uid,h.primaryKey));return m(S({},e),{results:i})})}getRawIndexes(t){return n(this,null,function*(){return yield this.httpRequest.get({path:"indexes",params:t})})}createIndex(t,e){return v.create(t,e,this.config)}updateIndex(t,e){return new v(this.config,t).update(e)}deleteIndex(t){return new v(this.config,t).delete()}deleteIndexIfExists(t){return n(this,null,function*(){var e;try{return yield this.deleteIndex(t),!0}catch(i){if(((e=i==null?void 0:i.cause)==null?void 0:e.code)===T.INDEX_NOT_FOUND)return!1;throw i}})}swapIndexes(t){return s(this,M).post({path:"/swap-indexes",body:t})}multiSearch(t,e){return n(this,null,function*(){return yield this.httpRequest.post({path:"multi-search",body:t,extraRequestInit:e})})}getNetwork(){return n(this,null,function*(){return yield this.httpRequest.get({path:"network"})})}updateNetwork(t){return n(this,null,function*(){return yield this.httpRequest.patch({path:"network",body:t})})}getKeys(t){return n(this,null,function*(){const e=yield this.httpRequest.get({path:"keys",params:t});return e.results=e.results.map(i=>m(S({},i),{createdAt:new Date(i.createdAt),updatedAt:new Date(i.updatedAt)})),e})}getKey(t){return n(this,null,function*(){return yield this.httpRequest.get({path:`keys/${t}`})})}createKey(t){return n(this,null,function*(){return yield this.httpRequest.post({path:"keys",body:t})})}updateKey(t,e){return n(this,null,function*(){return yield this.httpRequest.patch({path:`keys/${t}`,body:e})})}deleteKey(t){return n(this,null,function*(){yield this.httpRequest.delete({path:`keys/${t}`})})}health(){return n(this,null,function*(){return yield this.httpRequest.get({path:"health"})})}isHealthy(){return n(this,null,function*(){try{const{status:t}=yield this.health();return t==="available"}catch(t){return!1}})}getStats(){return n(this,null,function*(){return yield this.httpRequest.get({path:"stats"})})}getVersion(){return n(this,null,function*(){return yield this.httpRequest.get({path:"version"})})}createDump(){return s(this,M).post({path:"dumps"})}createSnapshot(){return s(this,M).post({path:"snapshots"})}getExperimentalFeatures(){return n(this,null,function*(){return yield this.httpRequest.get({path:"experimental-features"})})}updateExperimentalFeatures(t){return n(this,null,function*(){return yield this.httpRequest.patch({path:"experimental-features",body:t})})}}X=new WeakMap,j=new WeakMap,M=new WeakMap;const gt=st;a.ContentTypeEnum=d,a.ErrorStatusCode=T,a.Index=v,a.MatchingStrategies=_,a.MeiliSearch=st,a.MeiliSearchApiError=g,a.MeiliSearchError=p,a.MeiliSearchRequestError=N,a.MeiliSearchRequestTimeOutError=A,a.MeiliSearchTaskTimeOutError=l,a.Meilisearch=st,a.default=gt,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});(function(){if(typeof self!="undefined"){var a=Object.assign({},self.meilisearch);delete a.default,Object.assign(self,a)}})();
//# sourceMappingURL=index.min.js.map