PageSourceSearch

https://www.exponent.com/node_modules/meilisearch/dist/index.js

js exponent.com collected 2026-09-24 17:46:52 UTC 32,868 bytes, 1,137 lines download raw bytes

vendor: 7,241 bytes, lines 1-146
1//#region src/types/types.ts
2var e = {
3	ALL: "all",
4	LAST: "last",
5	FREQUENCY: "frequency"
6}, t = {
7	JSON: "application/json",
8	CSV: "text/csv",
9	NDJSON: "application/x-ndjson"
10}, n = {
11	INDEX_CREATION_FAILED: "index_creation_failed",
12	MISSING_INDEX_UID: "missing_index_uid",
13	INDEX_ALREADY_EXISTS: "index_already_exists",
14	INDEX_NOT_FOUND: "index_not_found",
15	INVALID_INDEX_UID: "invalid_index_uid",
16	INDEX_NOT_ACCESSIBLE: "index_not_accessible",
17	INVALID_INDEX_OFFSET: "invalid_index_offset",
18	INVALID_INDEX_LIMIT: "invalid_index_limit",
19	INVALID_STATE: "invalid_state",
20	PRIMARY_KEY_INFERENCE_FAILED: "primary_key_inference_failed",
21	INDEX_PRIMARY_KEY_ALREADY_EXISTS: "index_primary_key_already_exists",
22	INVALID_INDEX_PRIMARY_KEY: "invalid_index_primary_key",
23	DOCUMENTS_FIELDS_LIMIT_REACHED: "document_fields_limit_reached",
24	MISSING_DOCUMENT_ID: "missing_document_id",
25	INVALID_DOCUMENT_ID: "invalid_document_id",
26	INVALID_CONTENT_TYPE: "invalid_content_type",
27	MISSING_CONTENT_TYPE: "missing_content_type",
28	INVALID_DOCUMENT_FIELDS: "invalid_document_fields",
29	INVALID_DOCUMENT_LIMIT: "invalid_document_limit",
30	INVALID_DOCUMENT_OFFSET: "invalid_document_offset",
31	INVALID_DOCUMENT_FILTER: "invalid_document_filter",
32	MISSING_DOCUMENT_FILTER: "missing_document_filter",
33	INVALID_DOCUMENT_VECTORS_FIELD: "invalid_document_vectors_field",
34	PAYLOAD_TOO_LARGE: "payload_too_large",
35	MISSING_PAYLOAD: "missing_payload",
36	MALFORMED_PAYLOAD: "malformed_payload",
37	NO_SPACE_LEFT_ON_DEVICE: "no_space_left_on_device",
38	INVALID_STORE_FILE: "invalid_store_file",
39	INVALID_RANKING_RULES: "missing_document_id",
40	INVALID_REQUEST: "invalid_request",
41	INVALID_DOCUMENT_GEO_FIELD: "invalid_document_geo_field",
42	INVALID_SEARCH_Q: "invalid_search_q",
43	INVALID_SEARCH_OFFSET: "invalid_search_offset",
44	INVALID_SEARCH_LIMIT: "invalid_search_limit",
45	INVALID_SEARCH_PAGE: "invalid_search_page",
46	INVALID_SEARCH_HITS_PER_PAGE: "invalid_search_hits_per_page",
47	INVALID_SEARCH_ATTRIBUTES_TO_RETRIEVE: "invalid_search_attributes_to_retrieve",
48	INVALID_SEARCH_ATTRIBUTES_TO_CROP: "invalid_search_attributes_to_crop",
49	INVALID_SEARCH_CROP_LENGTH: "invalid_search_crop_length",
50	INVALID_SEARCH_ATTRIBUTES_TO_HIGHLIGHT: "invalid_search_attributes_to_highlight",
51	INVALID_SEARCH_SHOW_MATCHES_POSITION: "invalid_search_show_matches_position",
52	INVALID_SEARCH_FILTER: "invalid_search_filter",
53	INVALID_SEARCH_SORT: "invalid_search_sort",
54	INVALID_SEARCH_FACETS: "invalid_search_facets",
55	INVALID_SEARCH_HIGHLIGHT_PRE_TAG: "invalid_search_highlight_pre_tag",
56	INVALID_SEARCH_HIGHLIGHT_POST_TAG: "invalid_search_highlight_post_tag",
57	INVALID_SEARCH_CROP_MARKER: "invalid_search_crop_marker",
58	INVALID_SEARCH_MATCHING_STRATEGY: "invalid_search_matching_strategy",
59	INVALID_SEARCH_VECTOR: "invalid_search_vector",
60	INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON: "invalid_search_attributes_to_search_on",
61	BAD_REQUEST: "bad_request",
62	DOCUMENT_NOT_FOUND: "document_not_found",
63	INTERNAL: "internal",
64	INVALID_API_KEY: "invalid_api_key",
65	INVALID_API_KEY_DESCRIPTION: "invalid_api_key_description",
66	INVALID_API_KEY_ACTIONS: "invalid_api_key_actions",
67	INVALID_API_KEY_INDEXES: "invalid_api_key_indexes",
68	INVALID_API_KEY_EXPIRES_AT: "invalid_api_key_expires_at",
69	API_KEY_NOT_FOUND: "api_key_not_found",
70	IMMUTABLE_API_KEY_UID: "immutable_api_key_uid",
71	IMMUTABLE_API_KEY_ACTIONS: "immutable_api_key_actions",
72	IMMUTABLE_API_KEY_INDEXES: "immutable_api_key_indexes",
73	IMMUTABLE_API_KEY_EXPIRES_AT: "immutable_api_key_expires_at",
74	IMMUTABLE_API_KEY_CREATED_AT: "immutable_api_key_created_at",
75	IMMUTABLE_API_KEY_UPDATED_AT: "immutable_api_key_updated_at",
76	MISSING_AUTHORIZATION_HEADER: "missing_authorization_header",
77	UNRETRIEVABLE_DOCUMENT: "unretrievable_document",
78	MAX_DATABASE_SIZE_LIMIT_REACHED: "database_size_limit_reached",
79	TASK_NOT_FOUND: "task_not_found",
80	DUMP_PROCESS_FAILED: "dump_process_failed",
81	DUMP_NOT_FOUND: "dump_not_found",
82	INVALID_SWAP_DUPLICATE_INDEX_FOUND: "invalid_swap_duplicate_index_found",
83	INVALID_SWAP_INDEXES: "invalid_swap_indexes",
84	MISSING_SWAP_INDEXES: "missing_swap_indexes",
85	MISSING_MASTER_KEY: "missing_master_key",
86	INVALID_TASK_TYPES: "invalid_task_types",
87	INVALID_TASK_UIDS: "invalid_task_uids",
88	INVALID_TASK_STATUSES: "invalid_task_statuses",
89	INVALID_TASK_LIMIT: "invalid_task_limit",
90	INVALID_TASK_FROM: "invalid_task_from",
91	INVALID_TASK_CANCELED_BY: "invalid_task_canceled_by",
92	MISSING_TASK_FILTERS: "missing_task_filters",
93	TOO_MANY_OPEN_FILES: "too_many_open_files",
94	IO_ERROR: "io_error",
95	INVALID_TASK_INDEX_UIDS: "invalid_task_index_uids",
96	IMMUTABLE_INDEX_UID: "immutable_index_uid",
97	IMMUTABLE_INDEX_CREATED_AT: "immutable_index_created_at",
98	IMMUTABLE_INDEX_UPDATED_AT: "immutable_index_updated_at",
99	INVALID_SETTINGS_DISPLAYED_ATTRIBUTES: "invalid_settings_displayed_attributes",
100	INVALID_SETTINGS_SEARCHABLE_ATTRIBUTES: "invalid_settings_searchable_attributes",
101	INVALID_SETTINGS_FILTERABLE_ATTRIBUTES: "invalid_settings_filterable_attributes",
102	INVALID_SETTINGS_SORTABLE_ATTRIBUTES: "invalid_settings_sortable_attributes",
103	INVALID_SETTINGS_RANKING_RULES: "invalid_settings_ranking_rules",
104	INVALID_SETTINGS_STOP_WORDS: "invalid_settings_stop_words",
105	INVALID_SETTINGS_SYNONYMS: "invalid_settings_synonyms",
106	INVALID_SETTINGS_DISTINCT_ATTRIBUTE: "invalid_settings_distinct_attribute",
107	INVALID_SETTINGS_TYPO_TOLERANCE: "invalid_settings_typo_tolerance",
108	INVALID_SETTINGS_FACETING: "invalid_settings_faceting",
109	INVALID_SETTINGS_PAGINATION: "invalid_settings_pagination",
110	INVALID_SETTINGS_SEARCH_CUTOFF_MS: "invalid_settings_search_cutoff_ms",
111	INVALID_SETTINGS_LOCALIZED_ATTRIBUTES: "invalid_settings_localized_attributes",
112	INVALID_TASK_BEFORE_ENQUEUED_AT: "invalid_task_before_enqueued_at",
113	INVALID_TASK_AFTER_ENQUEUED_AT: "invalid_task_after_enqueued_at",
114	INVALID_TASK_BEFORE_STARTED_AT: "invalid_task_before_started_at",
115	INVALID_TASK_AFTER_STARTED_AT: "invalid_task_after_started_at",
116	INVALID_TASK_BEFORE_FINISHED_AT: "invalid_task_before_finished_at",
117	INVALID_TASK_AFTER_FINISHED_AT: "invalid_task_after_finished_at",
118	MISSING_API_KEY_ACTIONS: "missing_api_key_actions",
119	MISSING_API_KEY_INDEXES: "missing_api_key_indexes",
120	MISSING_API_KEY_EXPIRES_AT: "missing_api_key_expires_at",
121	INVALID_API_KEY_LIMIT: "invalid_api_key_limit",
122	INVALID_API_KEY_OFFSET: "invalid_api_key_offset",
123	INVALID_FACET_SEARCH_FACET_NAME: "invalid_facet_search_facet_name",
124	MISSING_FACET_SEARCH_FACET_NAME: "missing_facet_search_facet_name",
125	INVALID_FACET_SEARCH_FACET_QUERY: "invalid_facet_search_facet_query",
126	INVALID_SEARCH_RANKING_SCORE_THRESHOLD: "invalid_search_ranking_score_threshold",
127	INVALID_SIMILAR_RANKING_SCORE_THRESHOLD: "invalid_similar_ranking_score_threshold"
128}, r = class extends Error {
129	name = "MeilisearchError";
130}, i = class extends r {
131	name = "MeilisearchApiError";
132	cause;
133	response;
134	constructor(e, t) {
135		super(t?.message ?? `${e.status}: ${e.statusText}`), this.response = e, t !== void 0 && (this.cause = t);
136	}
137}, a = class extends r {
138	name = "MeilisearchRequestError";
139	constructor(e, t) {
140		super(`Request to ${e} has failed`, { cause: t });
141	}
142}, o = class extends r {
143	name = "MeilisearchRequestTimeOutError";
144	cause;
145	constructor(e, t) {
146		super(`request timed out after ${e}ms`)
vendor: 11,898 bytes, lines 146-620
146, this.cause = {
147			timeout: e,
148			requestInit: t
149		};
150	}
151}, s = class extends r {
152	name = "MeilisearchTaskTimeOutError";
153	cause;
154	constructor(e, t) {
155		super(`timeout of ${t}ms has exceeded on task ${e} when waiting for it to be resolved.`), this.cause = {
156			taskUid: e,
157			timeout: t
158		};
159	}
160}, c = {
161	name: "meilisearch",
162	version: "0.57.0",
163	description: "The Meilisearch JS client for Node.js and the browser.",
164	keywords: [
165		"meilisearch",
166		"search",
167		"instant",
168		"relevant",
169		"client",
170		"wrapper",
171		"meili"
172	],
173	author: "cvermand <[email protected]>",
174	contributors: ["qdequele <[email protected]>"],
175	license: "MIT",
176	type: "module",
177	exports: {
178		".": "./src/index.ts",
179		"./*": "./src/*.ts"
180	},
181	publishConfig: { exports: {
182		".": "./dist/index.js",
183		"./token": "./dist/token.js",
184		"./package.json": "./package.json"
185	} },
186	sideEffects: !1,
187	files: [
188		"src",
189		"dist",
190		"CONTRIBUTING.md"
191	],
192	engines: { node: "^20.19.0 || >=22.12.0" },
193	repository: {
194		type: "git",
195		url: "https://github.com/meilisearch/meilisearch-js.git"
196	},
197	scripts: {
198		"playground:javascript": "vite serve playgrounds/javascript --open",
199		"build:docs": "typedoc",
200		build: "vite build && tsc -p tsconfig.build.json",
201		test: "vitest run",
202		"test:watch": "vitest watch",
203		types: "tsc -p tsconfig.json --noEmit",
204		"types:watch": "pnpm types --watch",
205		fmt: "prettier -c .",
206		"fmt:fix": "prettier -w .",
207		lint: "oxlint --type-aware",
208		"lint:fix": "oxlint --type-aware --fix",
209		style: "pnpm fmt && pnpm lint",
210		"style:fix": "pnpm fmt:fix && pnpm lint:fix",
211		prepare: "husky"
212	},
213	devDependencies: {
214		"@types/node": "24.10.13",
215		"@vitest/coverage-v8": "4.1.0",
216		"eslint-plugin-tsdoc": "0.5.0",
217		globals: "^16.5.0",
218		husky: "^9.1.7",
219		"lint-staged": "16.2.7",
220		oxlint: "1.50.0",
221		"oxlint-tsgolint": "0.14.2",
222		prettier: "^3.8.1",
223		"prettier-plugin-jsdoc": "^1.8.0",
224		typedoc: "^0.28.14",
225		typescript: "5.9.3",
226		vite: "8.0.0",
227		vitest: "4.1.0"
228	},
229	packageManager: "[email protected]"
230};
231//#endregion
232//#region src/utils.ts
233function l(e) {
234	return e.startsWith("https://") || e.startsWith("http://") ? e : `http://${e}`;
235}
236function u(e) {
237	return e.endsWith("/") || (e += "/"), e;
238}
239//#endregion
240//#region src/http-requests.ts
241function d(e, t) {
242	for (let [n, r] of Object.entries(t)) r != null && e.set(n, Array.isArray(r) ? r.join() : r instanceof Date ? r.toISOString() : String(r));
243}
244function f(e, t) {
245	let n = "X-Meilisearch-Client", r = `Meilisearch JavaScript (v${c.version})`, i = "Content-Type", a = "Authorization", o = new Headers(t);
246	if (e.apiKey && !o.has(a) && o.set(a, `Bearer ${e.apiKey}`), o.has(i) || o.set(i, "application/json"), e.clientAgents !== void 0) {
247		let t = e.clientAgents.concat(r);
248		o.set(n, t.join(" ; "));
249	} else o.set(n, r);
250	return o;
251}
252var p = Symbol("<timeout>");
253function m(e, t) {
254	let { signal: n } = e, r = new AbortController();
255	if (n != null) {
256		let e = null;
257		if (n.aborted) r.abort(n.reason);
258		else {
259			let t = () => r.abort(n.reason);
260			n.addEventListener("abort", t, { once: !0 }), e = () => n.removeEventListener("abort", t), r.signal.addEventListener("abort", e, { once: !0 });
261		}
262		return () => {
263			if (n.aborted) return;
264			let i = setTimeout(() => r.abort(p), t), a = () => {
265				clearTimeout(i), e !== null && r.signal.removeEventListener("abort", e);
266			};
267			return n.addEventListener("abort", a, { once: !0 }), () => {
268				n.removeEventListener("abort", a), a();
269			};
270		};
271	}
272	return e.signal = r.signal, () => {
273		let e = setTimeout(() => r.abort(p), t);
274		return () => clearTimeout(e);
275	};
276}
277var h = class {
278	#e;
279	#t;
280	#n;
281	#r;
282	constructor(e) {
283		let t = u(l(e.host));
284		try {
285			this.#e = new URL(t);
286		} catch (e) {
287			throw new r("The provided host is not valid", { cause: e });
288		}
289		this.#t = {
290			...e.requestInit,
291			headers: f(e, e.requestInit?.headers)
292		}, this.#n = e.httpClient, this.#r = e.timeout;
293	}
294	#i(e, t) {
295		if (e === void 0 && t === void 0) return this.#t.headers;
296		let n = new Headers(e);
297		t !== void 0 && !n.has("Content-Type") && n.set("Content-Type", t);
298		for (let [e, t] of this.#t.headers) n.has(e) || n.set(e, t);
299		return n;
300	}
301	#a({ path: e, method: t, params: n, contentType: r, body: i, extraRequestInit: a }) {
302		let o = new URL(e, this.#e);
303		return n !== void 0 && d(o.searchParams, n), {
304			url: o,
305			init: {
306				method: t,
307				body: r === void 0 || typeof i != "string" ? JSON.stringify(i) : i,
308				...a,
309				...this.#t,
310				headers: this.#i(a?.headers, r)
311			}
312		};
313	}
314	async #o(e) {
315		let { url: t, init: n } = this.#a(e), r = (this.#r === void 0 ? null : m(n, this.#r))?.(), s, c;
316		try {
317			if (this.#n !== void 0) return await this.#n(t, n);
318			s = await fetch(t, n), c = await s.text();
319		} catch (e) {
320			throw new a(t.toString(), Object.is(e, p) ? new o(this.#r, n) : e);
321		} finally {
322			r?.();
323		}
324		let l = c === "" ? void 0 : JSON.parse(c);
325		if (!s.ok) throw new i(s, l);
326		return l;
327	}
328	get(e) {
329		return this.#o(e);
330	}
331	post(e) {
332		return this.#o({
333			...e,
334			method: "POST"
335		});
336	}
337	put(e) {
338		return this.#o({
339			...e,
340			method: "PUT"
341		});
342	}
343	patch(e) {
344		return this.#o({
345			...e,
346			method: "PATCH"
347		});
348	}
349	delete(e) {
350		return this.#o({
351			...e,
352			method: "DELETE"
353		});
354	}
355	postStream(e) {
356		return this.#s({
357			...e,
358			method: "POST"
359		});
360	}
361	async #s(e) {
362		let { url: t, init: n } = this.#a(e), s = (this.#r === void 0 ? null : m(n, this.#r))?.(), c;
363		try {
364			if (this.#n !== void 0) {
365				let e = await this.#n(t, n);
366				if (!(e instanceof ReadableStream)) throw new r("Custom HTTP client must return a ReadableStream for streaming requests");
367				return e;
368			}
369			c = await fetch(t, n);
370		} catch (e) {
371			throw new a(t.toString(), Object.is(e, p) ? new o(this.#r, n) : e);
372		} finally {
373			s?.();
374		}
375		if (!c.ok) {
376			let e = await c.text(), t = e === "" ? void 0 : JSON.parse(e);
377			throw new i(c, t);
378		}
379		if (!c.body) throw new r("Response body is null - server did not return a readable stream");
380		return c.body;
381	}
382}, g = Symbol("<task timeout>");
383function _(e) {
384	return function(t) {
385		return Object.defineProperty(t, "waitTask", { async value(n) {
386			return await e.waitForTask(await t, n);
387		} });
388	};
389}
390var v = (e) => typeof e == "number" ? e : e.taskUid, y = class {
391	#e;
392	#t;
393	#n;
394	#r;
395	constructor(e, t) {
396		this.#e = e, this.#t = t?.timeout ?? 5e3, this.#n = t?.interval ?? 50, this.#r = _(this);
397	}
398	async getTask(e, t) {
399		return await this.#e.get({
400			path: `tasks/${e}`,
401			extraRequestInit: t
402		});
403	}
404	async getTasks(e) {
405		return await this.#e.get({
406			path: "tasks",
407			params: e
408		});
409	}
410	async waitForTask(e, t) {
411		let n = v(e), r = t?.timeout ?? this.#t, i = t?.interval ?? this.#n, a = r > 0 ? new AbortController() : null, o = a === null ? void 0 : setTimeout(() => void a.abort(g), r);
412		try {
413			for (;;) {
414				let e = await this.getTask(n, { signal: a?.signal });
415				if (e.status !== "enqueued" && e.status !== "processing") return clearTimeout(o), e;
416				i > 0 && await new Promise((e) => setTimeout(e, i));
417			}
418		} catch (e) {
419			throw Object.is(e.cause, g) ? new s(n, r) : e;
420		}
421	}
422	async *waitForTasksIter(e, t) {
423		for await (let n of e) yield await this.waitForTask(n, t);
424	}
425	async waitForTasks(...e) {
426		let t = [];
427		for await (let n of this.waitForTasksIter(...e)) t.push(n);
428		return t;
429	}
430	cancelTasks(e) {
431		return this.#r(this.#e.post({
432			path: "tasks/cancel",
433			params: e
434		}));
435	}
436	deleteTasks(e) {
437		return this.#r(this.#e.delete({
438			path: "tasks",
439			params: e
440		}));
441	}
442};
443function b(e, t) {
444	let n = _(t);
445	return {
446		post: (...t) => n(e.post(...t)),
447		put: (...t) => n(e.put(...t)),
448		patch: (...t) => n(e.patch(...t)),
449		delete: (...t) => n(e.delete(...t))
450	};
451}
452//#endregion
453//#region src/indexes.ts
454var x = class {
455	uid;
456	primaryKey;
457	createdAt;
458	updatedAt;
459	httpRequest;
460	tasks;
461	#e;
462	constructor(e, t, n) {
463		this.uid = t, this.primaryKey = n, this.httpRequest = new h(e), this.tasks = new y(this.httpRequest, e.defaultWaitOptions), this.#e = b(this.httpRequest, this.tasks);
464	}
465	async search(e, t, n) {
466		return await this.httpRequest.post({
467			path: `indexes/${this.uid}/search`,
468			body: {
469				q: e,
470				...t
471			},
472			extraRequestInit: n
473		});
474	}
475	async searchGet(e, t, n) {
476		let i = (e) => {
477			if (typeof e == "string") return e;
478			if (Array.isArray(e)) throw new r("The filter query parameter should be in string format when using searchGet");
479		}, a = {
480			q: e,
481			...t,
482			filter: i(t?.filter),
483			sort: t?.sort?.join(","),
484			facets: t?.facets?.join(","),
485			attributesToRetrieve: t?.attributesToRetrieve?.join(","),
486			attributesToCrop: t?.attributesToCrop?.join(","),
487			attributesToHighlight: t?.attributesToHighlight?.join(","),
488			vector: t?.vector?.join(","),
489			attributesToSearchOn: t?.attributesToSearchOn?.join(",")
490		};
491		return await this.httpRequest.get({
492			path: `indexes/${this.uid}/search`,
493			params: a,
494			extraRequestInit: n
495		});
496	}
497	async searchForFacetValues(e, t) {
498		return await this.httpRequest.post({
499			path: `indexes/${this.uid}/facet-search`,
500			body: e,
501			extraRequestInit: t
502		});
503	}
504	async searchSimilarDocuments(e) {
505		return await this.httpRequest.post({
506			path: `indexes/${this.uid}/similar`,
507			body: e
508		});
509	}
510	async getRawInfo() {
511		let e = await this.httpRequest.get({ path: `indexes/${this.uid}` });
512		return this.primaryKey = e.primaryKey, this.updatedAt = new Date(e.updatedAt), this.createdAt = new Date(e.createdAt), e;
513	}
514	async fetchInfo() {
515		return await this.getRawInfo(), this;
516	}
517	async fetchPrimaryKey() {
518		return this.primaryKey = (await this.getRawInfo()).primaryKey, this.primaryKey;
519	}
520	static create(e, t = {}, n) {
521		let r = new h(n);
522		return b(r, new y(r)).post({
523			path: "indexes",
524			body: {
525				...t,
526				uid: e
527			}
528		});
529	}
530	update(e) {
531		return this.#e.patch({
532			path: `indexes/${this.uid}`,
533			body: e
534		});
535	}
536	delete() {
537		return this.#e.delete({ path: `indexes/${this.uid}` });
538	}
539	async getStats() {
540		return await this.httpRequest.get({ path: `indexes/${this.uid}/stats` });
541	}
542	async getDocuments(e) {
543		let t = `indexes/${this.uid}/documents`, n = e ? { ...e } : void 0;
544		return n && Array.isArray(n.sort) && n.sort.length === 0 && delete n.sort, n?.filter === void 0 ? await this.httpRequest.get({
545			path: t,
546			params: n
547		}) : await this.httpRequest.post({
548			path: `${t}/fetch`,
549			body: n
550		});
551	}
552	async getDocument(e, t) {
553		let n = Array.isArray(t?.fields) ? t.fields.join() : void 0;
554		return await this.httpRequest.get({
555			path: `indexes/${this.uid}/documents/${e}`,
556			params: {
557				...t,
558				fields: n
559			}
560		});
561	}
562	addDocuments(e, t) {
563		return this.#e.post({
564			path: `indexes/${this.uid}/documents`,
565			params: t,
566			body: e
567		});
568	}
569	addDocumentsFromString(e, t, n) {
570		return this.#e.post({
571			path: `indexes/${this.uid}/documents`,
572			body: e,
573			params: n,
574			contentType: t
575		});
576	}
577	addDocumentsInBatches(e, t = 1e3, n) {
578		let r = [];
579		for (let i = 0; i < e.length; i += t) r.push(this.addDocuments(e.slice(i, i + t), n));
580		return r;
581	}
582	updateDocuments(e, t) {
583		return this.#e.put({
584			path: `indexes/${this.uid}/documents`,
585			params: t,
586			body: e
587		});
588	}
589	updateDocumentsInBatches(e, t = 1e3, n) {
590		let r = [];
591		for (let i = 0; i < e.length; i += t) r.push(this.updateDocuments(e.slice(i, i + t), n));
592		return r;
593	}
594	updateDocumentsFromString(e, t, n) {
595		return this.#e.put({
596			path: `indexes/${this.uid}/documents`,
597			body: e,
598			params: n,
599			contentType: t
600		});
601	}
602	deleteDocument(e, t) {
603		return this.#e.delete({
604			path: `indexes/${this.uid}/documents/${e}`,
605			params: t
606		});
607	}
608	deleteDocuments(e, t) {
609		let n = !Array.isArray(e) && typeof e == "object" ? "documents/delete" : "documents/delete-batch";
610		return this.#e.post({
611			path: `indexes/${this.uid}/${n}`,
612			body: e,
613			params: t
614		});
615	}
616	deleteAllDocuments(e) {
617		return this.#e.delete({
618			path: `indexes/${this.uid}/documents`,
619			params: e
620		
vendor: 7,058 bytes, lines 620-857
620});
621	}
622	updateDocumentsByFunction(e, t) {
623		return this.#e.post({
624			path: `indexes/${this.uid}/documents/edit`,
625			body: e,
626			params: t
627		});
628	}
629	async getSettings() {
630		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings` });
631	}
632	updateSettings(e) {
633		return this.#e.patch({
634			path: `indexes/${this.uid}/settings`,
635			body: e
636		});
637	}
638	resetSettings() {
639		return this.#e.delete({ path: `indexes/${this.uid}/settings` });
640	}
641	async getPagination() {
642		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/pagination` });
643	}
644	updatePagination(e) {
645		return this.#e.patch({
646			path: `indexes/${this.uid}/settings/pagination`,
647			body: e
648		});
649	}
650	resetPagination() {
651		return this.#e.delete({ path: `indexes/${this.uid}/settings/pagination` });
652	}
653	async getSynonyms() {
654		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/synonyms` });
655	}
656	updateSynonyms(e) {
657		return this.#e.put({
658			path: `indexes/${this.uid}/settings/synonyms`,
659			body: e
660		});
661	}
662	resetSynonyms() {
663		return this.#e.delete({ path: `indexes/${this.uid}/settings/synonyms` });
664	}
665	async getStopWords() {
666		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/stop-words` });
667	}
668	updateStopWords(e) {
669		return this.#e.put({
670			path: `indexes/${this.uid}/settings/stop-words`,
671			body: e
672		});
673	}
674	resetStopWords() {
675		return this.#e.delete({ path: `indexes/${this.uid}/settings/stop-words` });
676	}
677	async getRankingRules() {
678		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/ranking-rules` });
679	}
680	updateRankingRules(e) {
681		return this.#e.put({
682			path: `indexes/${this.uid}/settings/ranking-rules`,
683			body: e
684		});
685	}
686	resetRankingRules() {
687		return this.#e.delete({ path: `indexes/${this.uid}/settings/ranking-rules` });
688	}
689	async getDistinctAttribute() {
690		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/distinct-attribute` });
691	}
692	updateDistinctAttribute(e) {
693		return this.#e.put({
694			path: `indexes/${this.uid}/settings/distinct-attribute`,
695			body: e
696		});
697	}
698	resetDistinctAttribute() {
699		return this.#e.delete({ path: `indexes/${this.uid}/settings/distinct-attribute` });
700	}
701	async getFilterableAttributes() {
702		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/filterable-attributes` });
703	}
704	updateFilterableAttributes(e) {
705		return this.#e.put({
706			path: `indexes/${this.uid}/settings/filterable-attributes`,
707			body: e
708		});
709	}
710	resetFilterableAttributes() {
711		return this.#e.delete({ path: `indexes/${this.uid}/settings/filterable-attributes` });
712	}
713	async getSortableAttributes() {
714		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/sortable-attributes` });
715	}
716	updateSortableAttributes(e) {
717		return this.#e.put({
718			path: `indexes/${this.uid}/settings/sortable-attributes`,
719			body: e
720		});
721	}
722	resetSortableAttributes() {
723		return this.#e.delete({ path: `indexes/${this.uid}/settings/sortable-attributes` });
724	}
725	async getSearchableAttributes() {
726		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/searchable-attributes` });
727	}
728	updateSearchableAttributes(e) {
729		return this.#e.put({
730			path: `indexes/${this.uid}/settings/searchable-attributes`,
731			body: e
732		});
733	}
734	resetSearchableAttributes() {
735		return this.#e.delete({ path: `indexes/${this.uid}/settings/searchable-attributes` });
736	}
737	async getDisplayedAttributes() {
738		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/displayed-attributes` });
739	}
740	updateDisplayedAttributes(e) {
741		return this.#e.put({
742			path: `indexes/${this.uid}/settings/displayed-attributes`,
743			body: e
744		});
745	}
746	resetDisplayedAttributes() {
747		return this.#e.delete({ path: `indexes/${this.uid}/settings/displayed-attributes` });
748	}
749	async getTypoTolerance() {
750		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/typo-tolerance` });
751	}
752	updateTypoTolerance(e) {
753		return this.#e.patch({
754			path: `indexes/${this.uid}/settings/typo-tolerance`,
755			body: e
756		});
757	}
758	resetTypoTolerance() {
759		return this.#e.delete({ path: `indexes/${this.uid}/settings/typo-tolerance` });
760	}
761	async getFaceting() {
762		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/faceting` });
763	}
764	updateFaceting(e) {
765		return this.#e.patch({
766			path: `indexes/${this.uid}/settings/faceting`,
767			body: e
768		});
769	}
770	resetFaceting() {
771		return this.#e.delete({ path: `indexes/${this.uid}/settings/faceting` });
772	}
773	async getSeparatorTokens() {
774		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/separator-tokens` });
775	}
776	updateSeparatorTokens(e) {
777		return this.#e.put({
778			path: `indexes/${this.uid}/settings/separator-tokens`,
779			body: e
780		});
781	}
782	resetSeparatorTokens() {
783		return this.#e.delete({ path: `indexes/${this.uid}/settings/separator-tokens` });
784	}
785	async getNonSeparatorTokens() {
786		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/non-separator-tokens` });
787	}
788	updateNonSeparatorTokens(e) {
789		return this.#e.put({
790			path: `indexes/${this.uid}/settings/non-separator-tokens`,
791			body: e
792		});
793	}
794	resetNonSeparatorTokens() {
795		return this.#e.delete({ path: `indexes/${this.uid}/settings/non-separator-tokens` });
796	}
797	async getDictionary() {
798		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/dictionary` });
799	}
800	updateDictionary(e) {
801		return this.#e.put({
802			path: `indexes/${this.uid}/settings/dictionary`,
803			body: e
804		});
805	}
806	resetDictionary() {
807		return this.#e.delete({ path: `indexes/${this.uid}/settings/dictionary` });
808	}
809	async getProximityPrecision() {
810		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/proximity-precision` });
811	}
812	updateProximityPrecision(e) {
813		return this.#e.put({
814			path: `indexes/${this.uid}/settings/proximity-precision`,
815			body: e
816		});
817	}
818	resetProximityPrecision() {
819		return this.#e.delete({ path: `indexes/${this.uid}/settings/proximity-precision` });
820	}
821	async getEmbedders() {
822		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/embedders` });
823	}
824	updateEmbedders(e) {
825		return this.#e.patch({
826			path: `indexes/${this.uid}/settings/embedders`,
827			body: e
828		});
829	}
830	resetEmbedders() {
831		return this.#e.delete({ path: `indexes/${this.uid}/settings/embedders` });
832	}
833	async getSearchCutoffMs() {
834		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/search-cutoff-ms` });
835	}
836	updateSearchCutoffMs(e) {
837		return this.#e.put({
838			path: `indexes/${this.uid}/settings/search-cutoff-ms`,
839			body: e
840		});
841	}
842	resetSearchCutoffMs() {
843		return this.#e.delete({ path: `indexes/${this.uid}/settings/search-cutoff-ms` });
844	}
845	async getLocalizedAttributes() {
846		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/localized-attributes` });
847	}
848	updateLocalizedAttributes(e) {
849		return this.#e.put({
850			path: `indexes/${this.uid}/settings/localized-attributes`,
851			body: e
852		});
853	}
854	resetLocalizedAttributes() {
855		return this.#e.delete({ path: `indexes/${this.uid}/settings/localized-attributes` });
856	}
857	async getF
vendor: 3,032 bytes, lines 857-991
857acetSearch() {
858		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/facet-search` });
859	}
860	updateFacetSearch(e) {
861		return this.#e.put({
862			path: `indexes/${this.uid}/settings/facet-search`,
863			body: e
864		});
865	}
866	resetFacetSearch() {
867		return this.#e.delete({ path: `indexes/${this.uid}/settings/facet-search` });
868	}
869	async getPrefixSearch() {
870		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/prefix-search` });
871	}
872	updatePrefixSearch(e) {
873		return this.#e.put({
874			path: `indexes/${this.uid}/settings/prefix-search`,
875			body: e
876		});
877	}
878	resetPrefixSearch() {
879		return this.#e.delete({ path: `indexes/${this.uid}/settings/prefix-search` });
880	}
881	async getChat() {
882		return await this.httpRequest.get({ path: `indexes/${this.uid}/settings/chat` });
883	}
884	updateChat(e) {
885		return this.#e.patch({
886			path: `indexes/${this.uid}/settings/chat`,
887			body: e
888		});
889	}
890	async getFields(e, t) {
891		return await this.httpRequest.post({
892			path: `indexes/${this.uid}/fields`,
893			body: e || {},
894			extraRequestInit: t
895		});
896	}
897}, S = class {
898	#e;
899	constructor(e) {
900		this.#e = e;
901	}
902	async getBatch(e) {
903		return await this.#e.get({ path: `batches/${e}` });
904	}
905	async getBatches(e) {
906		return await this.#e.get({
907			path: "batches",
908			params: e
909		});
910	}
911}, C = class {
912	#e;
913	#t;
914	constructor(e, t) {
915		this.#e = e, this.#t = t;
916	}
917	async get() {
918		return await this.#e.get({ path: `chats/${this.#t}/settings` });
919	}
920	async update(e) {
921		return await this.#e.patch({
922			path: `chats/${this.#t}/settings`,
923			body: e
924		});
925	}
926	async reset() {
927		await this.#e.delete({ path: `chats/${this.#t}/settings` });
928	}
929	async streamCompletion(e) {
930		if (!e.stream) throw Error("The SDK only supports streaming");
931		return await this.#e.postStream({
932			path: `chats/${this.#t}/chat/completions`,
933			body: e
934		});
935	}
936}, w = class {
937	config;
938	httpRequest;
939	#e;
940	get tasks() {
941		return this.#e;
942	}
943	#t;
944	get batches() {
945		return this.#t;
946	}
947	#n;
948	constructor(e) {
949		this.config = e, this.httpRequest = new h(e), this.#e = new y(this.httpRequest, e.defaultWaitOptions), this.#t = new S(this.httpRequest), this.#n = b(this.httpRequest, this.tasks);
950	}
951	index(e) {
952		return new x(this.config, e);
953	}
954	async getIndex(e) {
955		return new x(this.config, e).fetchInfo();
956	}
957	async getRawIndex(e) {
958		return new x(this.config, e).getRawInfo();
959	}
960	async getIndexes(e) {
961		let t = await this.getRawIndexes(e), n = t.results.map((e) => new x(this.config, e.uid, e.primaryKey));
962		return {
963			...t,
964			results: n
965		};
966	}
967	async getRawIndexes(e) {
968		return await this.httpRequest.get({
969			path: "indexes",
970			params: e
971		});
972	}
973	createIndex(e, t) {
974		return x.create(e, t, this.config);
975	}
976	updateIndex(e, t) {
977		return new x(this.config, e).update(t);
978	}
979	deleteIndex(e) {
980		return new x(this.config, e).delete();
981	}
982	async deleteIndexIfExists(e) {
983		try {
984			return await this.deleteIndex(e), !0;
985		} catch (e) {
986			if (e?.cause?.code === n.INDEX_NOT_FOUND) return !1;
987			throw e;
988		}
989	}
990	swapIndexes(e) {
991		return this.#n.post({
vendor: 3,639 bytes, lines 992-1137
992			path: "swap-indexes",
993			body: e
994		});
995	}
996	async multiSearch(e, t) {
997		return await this.httpRequest.post({
998			path: "multi-search",
999			body: e,
1000			extraRequestInit: t
1001		});
1002	}
1003	chat(e) {
1004		return new C(this.httpRequest, e);
1005	}
1006	async getChatWorkspaces() {
1007		return await this.httpRequest.get({ path: "chats" });
1008	}
1009	async getWebhooks() {
1010		return await this.httpRequest.get({ path: "webhooks" });
1011	}
1012	async getWebhook(e) {
1013		return await this.httpRequest.get({ path: `webhooks/${e}` });
1014	}
1015	async createWebhook(e) {
1016		return await this.httpRequest.post({
1017			path: "webhooks",
1018			body: e
1019		});
1020	}
1021	async updateWebhook(e, t) {
1022		return await this.httpRequest.patch({
1023			path: `webhooks/${e}`,
1024			body: t
1025		});
1026	}
1027	async deleteWebhook(e) {
1028		await this.httpRequest.delete({ path: `webhooks/${e}` });
1029	}
1030	#r(e) {
1031		return this.#n.patch({
1032			path: "network",
1033			body: e
1034		});
1035	}
1036	#i(e, t) {
1037		let n = Object.entries(t);
1038		if (n.length === 0) throw TypeError("initializeNetwork requires at least one shard when leader is set.");
1039		let r = {};
1040		for (let [t, i] of n) {
1041			if (!Array.isArray(i.remotes) || i.remotes.length === 0) throw TypeError(`Shard "${t}" must have at least one remote.`);
1042			let n = i.remotes.filter((t) => e[t] === void 0);
1043			if (n.length > 0) throw TypeError(`Shard "${t}" references unknown remotes: ${n.join(", ")}`);
1044			r[t] = { remotes: [...i.remotes] };
1045		}
1046		return r;
1047	}
1048	async getNetwork() {
1049		return await this.httpRequest.get({ path: "network" });
1050	}
1051	initializeNetwork(e) {
1052		let t = this.#i(e.remotes, e.shards);
1053		return this.#r({
1054			self: e.self,
1055			leader: e.self,
1056			remotes: e.remotes,
1057			shards: t
1058		});
1059	}
1060	addRemote(e) {
1061		return this.#r({ remotes: { [e.name]: e.remote } });
1062	}
1063	removeRemote(e) {
1064		return this.#r({ remotes: { [e.name]: null } });
1065	}
1066	addRemotesToShard(e, t) {
1067		return this.#r({ shards: { [e]: { addRemotes: t } } });
1068	}
1069	removeRemotesFromShard(e, t) {
1070		return this.#r({ shards: { [e]: { removeRemotes: t } } });
1071	}
1072	async getKeys(e) {
1073		let t = await this.httpRequest.get({
1074			path: "keys",
1075			params: e
1076		});
1077		return t.results = t.results.map((e) => ({
1078			...e,
1079			createdAt: new Date(e.createdAt),
1080			updatedAt: new Date(e.updatedAt)
1081		})), t;
1082	}
1083	async getKey(e) {
1084		return await this.httpRequest.get({ path: `keys/${e}` });
1085	}
1086	async createKey(e) {
1087		return await this.httpRequest.post({
1088			path: "keys",
1089			body: e
1090		});
1091	}
1092	async updateKey(e, t) {
1093		return await this.httpRequest.patch({
1094			path: `keys/${e}`,
1095			body: t
1096		});
1097	}
1098	async deleteKey(e) {
1099		await this.httpRequest.delete({ path: `keys/${e}` });
1100	}
1101	async health() {
1102		return await this.httpRequest.get({ path: "health" });
1103	}
1104	async isHealthy() {
1105		try {
1106			let { status: e } = await this.health();
1107			return e === "available";
1108		} catch {
1109			return !1;
1110		}
1111	}
1112	async getStats() {
1113		return await this.httpRequest.get({ path: "stats" });
1114	}
1115	async getVersion() {
1116		return await this.httpRequest.get({ path: "version" });
1117	}
1118	createDump() {
1119		return this.#n.post({ path: "dumps" });
1120	}
1121	createSnapshot() {
1122		return this.#n.post({ path: "snapshots" });
1123	}
1124	async getExperimentalFeatures() {
1125		return await this.httpRequest.get({ path: "experimental-features" });
1126	}
1127	async updateExperimentalFeatures(e) {
1128		return await this.httpRequest.patch({
1129			path: "experimental-features",
1130			body: e
1131		});
1132	}
1133};
1134//#endregion
1135export { t as ContentTypeEnum, n as ErrorStatusCode, x as Index, e as MatchingStrategies, w as Meilisearch, i as MeilisearchApiError, r as MeilisearchError, a as MeilisearchRequestError, o as MeilisearchRequestTimeOutError, s as MeilisearchTaskTimeOutError };
1136
1137//# sourceMappingURL=index.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.