diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8952a91b6..966f4f575 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,7 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume - [How to Contribute](#how-to-contribute) - [Development Workflow](#development-workflow) - [Git Guidelines](#git-guidelines) -- [Release Process (for internal team only)](#release-process-for-internal-team-only) +- [Release Process (for internal team only)](#release-process-for-the-internal-team-only) @@ -42,6 +42,7 @@ To run this project, you will need: You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml). Example of running all the checks with docker: + ```bash docker-compose run --rm package bash -c "yarn install && yarn test && yarn lint" ``` @@ -79,6 +80,7 @@ We do not enforce any branch naming style, but please use something descriptive ### Git Commits As minimal requirements, your commit message should: + - be capitalized - not finish by a dot or any other punctuation character (!,?) - start with a verb so that we can read your commit message this way: "This commit will ...", where "..." is the commit message. @@ -119,11 +121,13 @@ _[Read more about this](https://github.com/meilisearch/integration-guides/blob/m Make a PR modifying the following files with the right version: [`package.json`](/package.json): + ```javascript "version": "X.X.X", ``` [`src/package-version`](/src/package-version.ts) + ```javascript export const PACKAGE_VERSION = 'X.X.X' ``` @@ -137,6 +141,7 @@ GitHub Actions will be triggered and push the package to [npm](https://www.npmjs #### Release a `beta` Version This package is able to create multiple types of betas: + - A standard package beta, working on the latest version of Meilisearch. - A beta implementing the changes of a rc version of Meilisearch. - A beta implementing a specific feature `prototype` of Meilisearch. @@ -159,16 +164,16 @@ Here are the steps to release a beta version of this package depending on its ty 3. Commit and push your code to the newly created branch (step 1). - 4. Go to the [GitHub interface for releasing](https://github.com/meilisearch/meilisearch-js/releases): on this page, click on `Draft a new release`. 5. Create a GitHub pre-release: - - Fill the description with the detailed changelogs - - Fill the title with `vX.X.X-beta.0` - - Fill the tag with `vX.X.X-beta.0` - - ⚠️ Select the `vX.X.X-beta.0` branch and NOT `main` - - ⚠️ Click on the "This is a pre-release" checkbox - - Click on "Publish release" + +- Fill the description with the detailed changelogs +- Fill the title with `vX.X.X-beta.0` +- Fill the tag with `vX.X.X-beta.0` +- ⚠️ Select the `vX.X.X-beta.0` branch and NOT `main` +- ⚠️ Click on the "This is a pre-release" checkbox +- Click on "Publish release"
diff --git a/README.md b/README.md index 1488ff7d8..41e9f25f4 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,7 @@

npm version Tests - - Codecov - + Codecov Prettier License Bors enabled @@ -27,1138 +25,96 @@

⚡ The Meilisearch API client written for JavaScript

-**Meilisearch JavaScript** is the Meilisearch API client for JavaScript developers. +**Meilisearch JavaScript** is the Meilisearch API client for JavaScript +developers. -**Meilisearch** is an open-source search engine. [Learn more about Meilisearch.](https://github.com/meilisearch/meilisearch) +**Meilisearch** is an open-source search engine. +[Learn more about Meilisearch.](https://github.com/meilisearch/meilisearch) -## Table of Contents +## Run Meilisearch -- [📖 Documentation](#-documentation) -- [🔧 Installation](#-installation) -- [🚀 Getting started](#-getting-started) -- [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch) -- [💡 Learn more](#-learn-more) -- [⚙️ Contributing](#️-contributing) -- [📜 API resources](#-api-resources) +⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no +maintenance, no commitment, cancel anytime. +[Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js). -## 📖 Documentation - -This readme and [Meilisearch JS documentation website](https://meilisearch.github.io/meilisearch-js/) contains all the information you need to start using this Meilisearch SDK. - -For general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our [main documentation website](https://www.meilisearch.com/docs/). +🪨 Prefer to self-host? +[Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js) +our fast, open-source search engine on your own infrastructure. ## 🔧 Installation -We recommend installing `meilisearch-js` in your project with your package manager of choice. +Package is published to [npm](https://www.npmjs.com/package/meilisearch). + +Installing with `npm`: ```sh -npm install meilisearch +npm i meilisearch ``` -`meilisearch-js` officially supports `node` versions 18 Maintenance, 20 Maintenance and 22 LTS. - -Instead of using a package manager, you may also import the library directly into your [HTML via a CDN](#include-script-tag). - -### Run Meilisearch - -⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js). - -🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js) our fast, open-source search engine on your own infrastructure. - -### Import - -After installing `meilisearch-js`, you must import it into your application. There are many ways of doing that depending on your development environment. - -> [!WARNING] -> - [default export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#using_the_default_export) is deprecated and will be removed in a future version https://github.com/meilisearch/meilisearch-js/issues/1789 -> - exports will stop being directly available on the global object (usually `window`) https://github.com/meilisearch/meilisearch-js/issues/1806 - -#### `import` syntax - -Usage in an ES module environment: - -```javascript -import { MeiliSearch } from 'meilisearch' +> [!NOTE] +> +> Node.js +> [LTS and Maintenance versions](https://github.com/nodejs/Release?tab=readme-ov-file#release-schedule) +> are supported and tested. Other versions may or may not work. +> [TypeScript has to be set up so that it supports `package.json` `"exports"` field](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports). -const client = new MeiliSearch({ - host: 'http://127.0.0.1:7700', - apiKey: 'masterKey', -}) -``` - -#### ` + ``` -#### `require` syntax - -Usage in a back-end node.js or another environment supporting CommonJS modules: - -```javascript -const { MeiliSearch } = require('meilisearch') - -const client = new MeiliSearch({ - host: 'http://127.0.0.1:7700', - apiKey: 'masterKey', -}) -``` - -#### React Native - -To use `meilisearch-js` with React Native, you must also install [react-native-url-polyfill](https://www.npmjs.com/package/react-native-url-polyfill). - -#### Deno - -Usage in a Deno environment: - -```js -import { MeiliSearch } from "https://esm.sh/meilisearch" - -const client = new MeiliSearch({ - host: 'http://127.0.0.1:7700', - apiKey: 'masterKey', -}) -``` - -## 🚀 Getting started - -Take a look at the [playground](./playgrounds/javascript/src/meilisearch.ts) for a concrete example. - -### Add documents - -```js -const { MeiliSearch } = require('meilisearch') -// Or if you are in a ES environment -import { MeiliSearch } from 'meilisearch' - -;(async () => { - const client = new MeiliSearch({ - host: 'http://127.0.0.1:7700', - apiKey: 'masterKey', - }) - - // An index is where the documents are stored. - const index = client.index('movies') - - const documents = [ - { id: 1, title: 'Carol', genres: ['Romance', 'Drama'] }, - { id: 2, title: 'Wonder Woman', genres: ['Action', 'Adventure'] }, - { id: 3, title: 'Life of Pi', genres: ['Adventure', 'Drama'] }, - { id: 4, title: 'Mad Max: Fury Road', genres: ['Adventure', 'Science Fiction'] }, - { id: 5, title: 'Moana', genres: ['Fantasy', 'Action']}, - { id: 6, title: 'Philadelphia', genres: ['Drama'] }, - ] - - // If the index 'movies' does not exist, Meilisearch creates it when you first add the documents. - let response = await index.addDocuments(documents) - - console.log(response) // => { "uid": 0 } -})() -``` - -Tasks such as document addition always return a unique identifier. You can use this identifier `taskUid` to check the status (`enqueued`, `canceled`, `processing`, `succeeded` or `failed`) of a [task](https://www.meilisearch.com/docs/reference/api/tasks). - -### Basic search - -```javascript -// Meilisearch is typo-tolerant: -const search = await index.search('philoudelphia') -console.log(search) -``` - -Output: - -```json -{ - "hits": [ - { - "id": "6", - "title": "Philadelphia", - "genres": ["Drama"] - } - ], - "offset": 0, - "limit": 20, - "estimatedTotalHits": 1, - "processingTimeMs": 1, - "query": "philoudelphia" -} -``` - -### Using search parameters - -`meilisearch-js` supports all [search parameters](https://www.meilisearch.com/docs/reference/api/search#search-parameters) described in our main documentation website. - -```javascript -await index.search( - 'wonder', - { - attributesToHighlight: ['*'] - } -) -``` - -```json -{ - "hits": [ - { - "id": 2, - "title": "Wonder Woman", - "genres": ["Action", "Adventure"], - "_formatted": { - "id": "2", - "title": "Wonder Woman", - "genres": ["Action", "Adventure"] - } - } - ], - "offset": 0, - "limit": 20, - "estimatedTotalHits": 1, - "processingTimeMs": 0, - "query": "wonder" -} -``` - -### Custom search with filters - -To enable filtering, you must first add your attributes to the [`filterableAttributes` index setting](https://www.meilisearch.com/docs/reference/api/settings#filterable-attributes). - -```js -await index.updateFilterableAttributes([ - 'id', - 'genres' - ]) -``` - -You only need to perform this operation once per index. - -Note that Meilisearch rebuilds your index whenever you update `filterableAttributes`. Depending on the size of your dataset, this might take considerable time. You can track the process using the [tasks API](https://www.meilisearch.com/docs/reference/api/tasks)). - -After you configured `filterableAttributes`, you can use the [`filter` search parameter](https://www.meilisearch.com/docs/reference/api/search#filter) to refine your search: - -```js -await index.search( - 'wonder', - { - filter: ['id > 1 AND genres = Action'] - } -) -``` - -```json -{ - "hits": [ - { - "id": 2, - "title": "Wonder Woman", - "genres": ["Action","Adventure"] - } - ], - "offset": 0, - "limit": 20, - "estimatedTotalHits": 1, - "processingTimeMs": 0, - "query": "wonder" -} -``` - -### Placeholder search - -Placeholder search makes it possible to receive hits based on your parameters without having any query (`q`). For example, in a movies database you can run an empty query to receive all results filtered by `genre`. - -```javascript -await index.search( - '', - { - filter: ['genres = fantasy'], - facets: ['genres'] - } -) -``` - -```json -{ - "hits": [ - { - "id": 2, - "title": "Wonder Woman", - "genres": ["Action","Adventure"] - }, - { - "id": 5, - "title": "Moana", - "genres": ["Fantasy","Action"] - } - ], - "offset": 0, - "limit": 20, - "estimatedTotalHits": 2, - "processingTimeMs": 0, - "query": "", - "facetDistribution": { - "genres": { - "Action": 2, - "Fantasy": 1, - "Adventure": 1 - } - } -} -``` - -Note that to enable faceted search on your dataset you need to add `genres` to the `filterableAttributes` index setting. For more information on filtering and faceting, [consult our documentation settings](https://www.meilisearch.com/docs/learn/fine_tuning_results/faceted_search). - -#### Abortable search - -You can abort a pending search request by providing an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to the request. - -```js -const controller = new AbortController() - -index - .search('wonder', {}, { - signal: controller.signal, - }) - .then((response) => { - /** ... */ - }) - .catch((e) => { - /** Catch AbortError here. */ - }) - -controller.abort() -``` - - -### Using Meilisearch behind a proxy - -#### Custom request config - -You can provide a custom request configuration. for example, with custom headers. +> [!WARNING] +> +> - [default export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#using_the_default_export) +> is deprecated and will be removed in a future version | +> [Issue](https://github.com/meilisearch/meilisearch-js/issues/1789) +> - regarding usage of package's UMD version via `script src`, exports will stop +> being directly available on the +> [global object](https://developer.mozilla.org/en-US/docs/Glossary/Global_object) +> | [Issue](https://github.com/meilisearch/meilisearch-js/issues/1806) -```ts -const client: MeiliSearch = new MeiliSearch({ - host: 'http://localhost:3000/api/meilisearch/proxy', - requestConfig: { - headers: { - Authorization: AUTH_TOKEN - }, - // OR - credentials: 'include' - } -}) -``` +## 📖 Documentation -#### Custom http client +Refer to the +[client library documentation](https://meilisearch.github.io/meilisearch-js/modules.html) +for information on each exported item of this package. -You can use your own HTTP client, for example, with [`axios`](https://github.com/axios/axios). +For general information on how to use Meilisearch—such as our API reference, +tutorials, guides, and in-depth articles—refer to our +[main documentation website](https://www.meilisearch.com/docs/). -```ts -const client: MeiliSearch = new MeiliSearch({ - host: 'http://localhost:3000/api/meilisearch/proxy', - httpClient: async (url, opts) => { - const response = await $axios.request({ - url, - data: opts?.body, - headers: opts?.headers, - method: (opts?.method?.toLocaleUpperCase() as Method) ?? 'GET' - }) +## 🚀 Example code - return response.data - } -}) -``` +Take a look at the [playground](./playgrounds/javascript/src/meilisearch.ts) to +see an example. ## 🤖 Compatibility with Meilisearch -This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-js/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info. - -## 💡 Learn more - -The following sections in our main documentation website may interest you: - -- **Manipulate documents**: see the [API references](https://www.meilisearch.com/docs/reference/api/documents) or read more about [documents](https://www.meilisearch.com/docs/learn/core_concepts/documents). -- **Search**: see the [API references](https://www.meilisearch.com/docs/reference/api/search) or follow our guide on [search parameters](https://www.meilisearch.com/docs/reference/api/search#search-parameters). -- **Manage the indexes**: see the [API references](https://www.meilisearch.com/docs/reference/api/indexes) or read more about [indexes](https://www.meilisearch.com/docs/learn/core_concepts/indexes). -- **Configure the index settings**: see the [API references](https://www.meilisearch.com/docs/reference/api/settings) or follow our guide on [settings parameters](https://www.meilisearch.com/docs/reference/api/settings#settings_parameters). - -This repository also contains [more examples](./examples). +This package guarantees compatibility with the +[latest version of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest). ## ⚙️ Contributing -We welcome all contributions, big and small! If you want to know more about this SDK's development workflow or want to contribute to the repo, please visit our [contributing guidelines](/CONTRIBUTING.md) for detailed instructions. - -## 📜 API resources - -### Search - -#### [Make a search request](https://www.meilisearch.com/docs/reference/api/search) - -```ts -client.index('xxx').search(query: string, options: SearchParams = {}, config?: Partial): Promise> -``` - -#### [Make a search request using the GET method (slower than the search method)](https://www.meilisearch.com/docs/reference/api/search#search-in-an-index-with-get-route) - -```ts -client.index('xxx').searchGet(query: string, options: SearchParams = {}, config?: Partial): Promise> -``` - -### Multi Search - -#### [Make multiple search requests](https://www.meilisearch.com/docs/reference/api/multi_search#multi-search) - -```ts -client.multiSearch(queries?: MultiSearchParams, config?: Partial): Promise>> -``` - -`multiSearch` uses the `POST` method when performing its request to Meilisearch. - -### Search For Facet Values - -#### [Search for facet values](https://www.meilisearch.com/docs/reference/api/facet_search#perform-a-facet-search) - -```ts -client.index('myIndex').searchForFacetValues(params: SearchForFacetValuesParams, config?: Partial): Promise -``` - -### Documents - -#### [Add or replace multiple documents](https://www.meilisearch.com/docs/reference/api/documents#add-or-replace-documents) - -```ts -client.index('myIndex').addDocuments(documents: Document[]): Promise -``` - -#### [Add or replace multiple documents in string format](https://www.meilisearch.com/docs/reference/api/documents#add-or-update-documents) - -```ts -client.index('myIndex').addDocumentsFromString(documents: string, contentType: ContentType, queryParams: RawDocumentAdditionOptions): Promise -``` - -#### [Add or replace multiple documents in batches](https://www.meilisearch.com/docs/reference/api/documents#add-or-replace-documents) - -```ts -client.index('myIndex').addDocumentsInBatches(documents: Document[], batchSize = 1000): Promise -``` - -#### [Add or update multiple documents](https://www.meilisearch.com/docs/reference/api/documents#add-or-update-documents) - -```ts -client.index('myIndex').updateDocuments(documents: Array>>): Promise -``` - -#### [Add or update multiple documents in string format](https://www.meilisearch.com/docs/reference/api/documents#add-or-update-documents) - -```ts -client.index('myIndex').updateDocumentsFromString(documents: string, contentType: ContentType, queryParams: RawDocumentAdditionOptions): Promise -``` - -#### [Add or update multiple documents in batches](https://www.meilisearch.com/docs/reference/api/documents#add-or-update-documents) - -```ts -client.index('myIndex').updateDocumentsInBatches(documents: Array>>, batchSize = 1000): Promise -``` - -#### [Get Documents](https://www.meilisearch.com/docs/reference/api/documents#get-documents) - -```ts -client.index.getDocuments(parameters: DocumentsQuery = {}): Promise>> -``` - -#### [Get one document](https://www.meilisearch.com/docs/reference/api/documents#get-one-document) - -```ts -client.index('myIndex').getDocument(documentId: string): Promise> -``` - -#### [Delete one document](https://www.meilisearch.com/docs/reference/api/documents#delete-one-document) - -```ts -client.index('myIndex').deleteDocument(documentId: string | number): Promise -``` - -#### [Delete multiple documents](https://www.meilisearch.com/docs/reference/api/documents#delete-documents) - -```ts -client.index('myIndex').deleteDocuments(params: DocumentsDeletionQuery | DocumentsIds): Promise -``` - -#### [Delete all documents](https://www.meilisearch.com/docs/reference/api/documents#delete-all-documents) - -```ts -client.index('myIndex').deleteAllDocuments(): Promise -``` - -### Tasks - -#### [Get all tasks](https://www.meilisearch.com/docs/reference/api/tasks#get-all-tasks) - -```ts -client.getTasks(parameters: TasksQuery): Promise -``` - -#### [Get one task](https://www.meilisearch.com/docs/reference/api/tasks) - -```ts -client.getTask(uid: number): Promise -``` - -#### [Delete tasks](https://www.meilisearch.com/docs/reference/api/tasks#delete-tasks) - -```ts -client.deleteTasks(parameters: DeleteTasksQuery = {}): Promise -``` - -#### [Cancel tasks](https://www.meilisearch.com/docs/reference/api/tasks#cancel-tasks) - -```ts -client.cancelTasks(parameters: CancelTasksQuery = {}): Promise -``` - -#### [Get all tasks of an index](https://www.meilisearch.com/docs/reference/api/tasks#get-all-tasks-by-index) - -```ts -client.index('myIndex').getTasks(parameters: TasksQuery): Promise -``` - -#### [Get one task of an index](https://www.meilisearch.com/docs/reference/api/tasks) - -```ts -client.index('myIndex').getTask(uid: number): Promise -``` - - -#### Wait for one task - - -##### Using the client - -```ts -client.waitForTask(uid: number, { timeOutMs?: number, intervalMs?: number }): Promise -``` - -##### Using the index - -```ts -client.index('myIndex').waitForTask(uid: number, { timeOutMs?: number, intervalMs?: number }): Promise -``` - -#### Wait for multiple tasks - -##### Using the client - -```ts -client.waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise -``` - -##### Using the index - -```ts -client.index('myIndex').waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise -``` - -### Batches - -#### [Get one batch](https://www.meilisearch.com/docs/reference/api/batches#get-one-batch) - -```ts -client.getBatch(uid: number): Promise -``` - -#### [Get all batches](https://www.meilisearch.com/docs/reference/api/batchess#get-batches) - -```ts -client.getBatches(parameters: BatchesQuery = {}): Promise -``` - -### Indexes - -#### [Get all indexes in Index instances](https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes) - -```ts -client.getIndexes(parameters: IndexesQuery): Promise> -``` - -#### [Get all indexes](https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes) - -```ts -client.getRawIndexes(parameters: IndexesQuery): Promise> -``` - - -#### [Create a new index](https://www.meilisearch.com/docs/reference/api/indexes#create-an-index) - -```ts -client.createIndex(uid: string, options?: IndexOptions): Promise -``` - -#### Create a local reference to an index - -```ts -client.index(uid: string): Index -``` - -#### [Get an index instance completed with information fetched from Meilisearch](https://www.meilisearch.com/docs/reference/api/indexes#get-one-index) - -```ts -client.getIndex(uid: string): Promise> -``` - -#### [Get the raw index JSON response from Meilisearch](https://www.meilisearch.com/docs/reference/api/indexes#get-one-index) - -```ts -client.getRawIndex(uid: string): Promise -``` - -#### [Get an object with information about the index](https://www.meilisearch.com/docs/reference/api/indexes#get-one-index) - -```ts -client.index('myIndex').getRawInfo(): Promise -``` - -#### [Update Index](https://www.meilisearch.com/docs/reference/api/indexes#update-an-index) - -##### Using the client - -```ts -client.updateIndex(uid: string, options: IndexOptions): Promise -``` - -##### Using the index object - -```ts -client.index('myIndex').update(data: IndexOptions): Promise -``` - -#### [Delete index](https://www.meilisearch.com/docs/reference/api/indexes#delete-an-index) - -##### Using the client -```ts -client.deleteIndex(uid): Promise -``` - -##### Using the index object -```ts -client.index('myIndex').delete(): Promise -``` - -#### [Get specific index stats](https://www.meilisearch.com/docs/reference/api/stats#get-stats-of-an-index) - -```ts -client.index('myIndex').getStats(): Promise -``` - -##### Return Index instance with updated information - -```ts -client.index('myIndex').fetchInfo(): Promise -``` - -##### Get Primary Key of an Index - -```ts -client.index('myIndex').fetchPrimaryKey(): Promise -``` - -##### Swap two indexes - -```ts -client.swapIndexes(params: SwapIndexesParams): Promise -``` - -### Settings - -#### [Get settings](https://www.meilisearch.com/docs/reference/api/settings#get-settings) - -```ts -client.index('myIndex').getSettings(): Promise -``` - -#### [Update settings](https://www.meilisearch.com/docs/reference/api/settings#update-settings) - -```ts -client.index('myIndex').updateSettings(settings: Settings): Promise -``` - -#### [Reset settings](https://www.meilisearch.com/docs/reference/api/settings#reset-settings) - -```ts -client.index('myIndex').resetSettings(): Promise -``` - -### Pagination Settings - -#### [Get pagination](https://www.meilisearch.com/docs/reference/api/settings#get-pagination-settings) - -```ts -client.index('myIndex').getPagination(): Promise -``` - -#### [Update pagination](https://www.meilisearch.com/docs/reference/api/settings#update-pagination-settings) - -```ts -client.index('myIndex').updatePagination(pagination: PaginationSettings): Promise -``` - -#### [Reset pagination](https://www.meilisearch.com/docs/reference/api/settings#reset-pagination-settings) - -```ts -client.index('myIndex').resetPagination(): Promise -``` - -### Synonyms - -#### [Get synonyms](https://www.meilisearch.com/docs/reference/api/settings#get-synonyms) - -```ts -client.index('myIndex').getSynonyms(): Promise -``` - -#### [Update synonyms](https://www.meilisearch.com/docs/reference/api/settings#update-synonyms) - -```ts -client.index('myIndex').updateSynonyms(synonyms: Synonyms): Promise -``` - -#### [Reset synonyms](https://www.meilisearch.com/docs/reference/api/settings#reset-synonyms) - -```ts -client.index('myIndex').resetSynonyms(): Promise -``` - -### Stop words - -#### [Get stop words](https://www.meilisearch.com/docs/reference/api/settings#get-stop-words) - -```ts -client.index('myIndex').getStopWords(): Promise -``` - -#### [Update stop words](https://www.meilisearch.com/docs/reference/api/settings#update-stop-words) - -```ts -client.index('myIndex').updateStopWords(stopWords: string[] | null ): Promise -``` - -#### [Reset stop words](https://www.meilisearch.com/docs/reference/api/settings#reset-stop-words) - -```ts -client.index('myIndex').resetStopWords(): Promise -``` - -### Ranking rules - -#### [Get ranking rules](https://www.meilisearch.com/docs/reference/api/settings#get-ranking-rules) - -```ts -client.index('myIndex').getRankingRules(): Promise -``` - -#### [Update ranking rules](https://www.meilisearch.com/docs/reference/api/settings#update-ranking-rules) - -```ts -client.index('myIndex').updateRankingRules(rankingRules: string[] | null): Promise -``` - -#### [Reset ranking rules](https://www.meilisearch.com/docs/reference/api/settings#reset-ranking-rules) - -```ts -client.index('myIndex').resetRankingRules(): Promise -``` - -### Distinct Attribute - -#### [Get distinct attribute](https://www.meilisearch.com/docs/reference/api/settings#get-distinct-attribute) - -```ts -client.index('myIndex').getDistinctAttribute(): Promise -``` - -#### [Update distinct attribute](https://www.meilisearch.com/docs/reference/api/settings#update-distinct-attribute) - -```ts -client.index('myIndex').updateDistinctAttribute(distinctAttribute: string | null): Promise -``` - -#### [Reset distinct attribute](https://www.meilisearch.com/docs/reference/api/settings#reset-distinct-attribute) - -```ts -client.index('myIndex').resetDistinctAttribute(): Promise -``` - -### Searchable attributes - -#### [Get searchable attributes](https://www.meilisearch.com/docs/reference/api/settings#get-searchable-attributes) - -```ts -client.index('myIndex').getSearchableAttributes(): Promise -``` - -#### [Update searchable attributes](https://www.meilisearch.com/docs/reference/api/settings#update-searchable-attributes) - -```ts -client.index('myIndex').updateSearchableAttributes(searchableAttributes: string[] | null): Promise -``` - -#### [Reset searchable attributes](https://www.meilisearch.com/docs/reference/api/settings#reset-searchable-attributes) - -```ts -client.index('myIndex').resetSearchableAttributes(): Promise -``` - -### Displayed attributes - -#### [Get displayed attributes](https://www.meilisearch.com/docs/reference/api/settings#get-displayed-attributes) - -```ts -client.index('myIndex').getDisplayedAttributes(): Promise -``` - -#### [Update displayed attributes](https://www.meilisearch.com/docs/reference/api/settings#update-displayed-attributes) - -```ts -client.index('myIndex').updateDisplayedAttributes(displayedAttributes: string[] | null): Promise -``` - -#### [Reset displayed attributes](https://www.meilisearch.com/docs/reference/api/settings#reset-displayed-attributes) - -```ts -client.index('myIndex').resetDisplayedAttributes(): Promise -``` - -### Filterable attributes - -#### [Get filterable attributes](https://www.meilisearch.com/docs/reference/api/settings#get-filterable-attributes) - -```ts -client.index('myIndex').getFilterableAttributes(): Promise -``` - -#### [Update filterable attributes](https://www.meilisearch.com/docs/reference/api/settings#update-filterable-attributes) - -```ts -client.index('myIndex').updateFilterableAttributes(filterableAttributes: string[] | null): Promise -``` - -#### [Reset filterable attributes](https://www.meilisearch.com/docs/reference/api/settings#reset-filterable-attributes) - -```ts -client.index('myIndex').resetFilterableAttributes(): Promise -``` - -### Sortable attributes - -#### [Get sortable attributes](https://www.meilisearch.com/docs/reference/api/settings#get-sortable-attributes) - -```ts -client.index('myIndex').getSortableAttributes(): Promise -``` - -#### [Update sortable attributes](https://www.meilisearch.com/docs/reference/api/settings#update-sortable-attributes) - -```ts -client.index('myIndex').updateSortableAttributes(sortableAttributes: string[] | null): Promise -``` - -#### [Reset sortable attributes](https://www.meilisearch.com/docs/reference/api/settings#reset-sortable-attributes) - -```ts -client.index('myIndex').resetSortableAttributes(): Promise -``` - -### Faceting - -#### [Get faceting](https://www.meilisearch.com/docs/reference/api/settings#get-faceting-settings) - -```ts -client.index('myIndex').getFaceting(): Promise -``` - -#### [Update faceting](https://www.meilisearch.com/docs/reference/api/settings#update-faceting-settings) - -```ts -client.index('myIndex').updateFaceting(faceting: Faceting): Promise -``` - -#### [Reset faceting](https://www.meilisearch.com/docs/reference/api/settings#reset-faceting-settings) - -```ts -client.index('myIndex').resetFaceting(): Promise -``` - -### Typo tolerance - -#### [Get typo tolerance](https://www.meilisearch.com/docs/reference/api/settings#get-typo-tolerance-settings) - -```ts -client.index('myIndex').getTypoTolerance(): Promise -``` - -#### [Update typo tolerance](https://www.meilisearch.com/docs/reference/api/settings#update-typo-tolerance-settings) - -```ts -client.index('myIndex').updateTypoTolerance(typoTolerance: TypoTolerance | null): Promise -``` - -#### [Reset typo tolerance](https://www.meilisearch.com/docs/reference/api/settings#reset-typo-tolerance-settings) - -```ts -client.index('myIndex').resetTypoTolerance(): Promise -``` - - -### Separator tokens - -#### [Get separator tokens](https://www.meilisearch.com/docs/reference/api/settings#get-separator-tokens) - -```ts -client.index('myIndex').getSeparatorTokens(): Promise -``` - -#### [Update separator tokens](https://www.meilisearch.com/docs/reference/api/settings#update-separator-tokens) - -```ts -client.index('myIndex').updateSeparatorTokens(separatorTokens: SeparatorTokens | null): Promise -``` - -#### [Reset separator tokens](https://www.meilisearch.com/docs/reference/api/settings#reset-separator-tokens) - -```ts -client.index('myIndex').resetSeparatorTokens(): Promise -``` - -### Non Separator tokens - -#### [Get non separator tokens](https://www.meilisearch.com/docs/reference/api/settings#get-non-separator-tokens) - -```ts -client.index('myIndex').getNonSeparatorTokens(): Promise -``` - -#### [Update non separator tokens](https://www.meilisearch.com/docs/reference/api/settings#update-non-separator-tokens) - -```ts -client.index('myIndex').updateNonSeparatorTokens(nonSeparatorTokens: NonSeparatorTokens | null): Promise -``` - -#### [Reset non separator tokens](https://www.meilisearch.com/docs/reference/api/settings#reset-non-separator-tokens) - -```ts -client.index('myIndex').resetNonSeparatorTokens(): Promise -``` - -### Dictionary - -#### [Get dictionary](https://www.meilisearch.com/docs/reference/api/settings#get-dictionary) - -```ts -client.index('myIndex').getDictionary(): Promise -``` - -#### [Update dictionary](https://www.meilisearch.com/docs/reference/api/settings#update-dictionary) - -```ts -client.index('myIndex').updateDictionary(dictionary: Dictionary | null): Promise -``` - -#### [Reset dictionary](https://www.meilisearch.com/docs/reference/api/settings#reset-dictionary) - -```ts -client.index('myIndex').resetDictionary(): Promise -``` - -### Proximity Precision - -#### [Get proximity precision](https://www.meilisearch.com/docs/reference/api/settings#get-proximity-precision-settings) - -```ts -client.index('myIndex').getProximityPrecision(): Promise -``` - -#### [Update proximity precision](https://www.meilisearch.com/docs/reference/api/settings#update-proximity-precision-settings) - -```ts -client.index('myIndex').updateProximityPrecision(proximityPrecision: ProximityPrecision): Promise -``` - -#### [Reset proximity precision](https://www.meilisearch.com/docs/reference/api/settings#reset-proximity-precision-settings) - -```ts -client.index('myIndex').resetProximityPrecision(): Promise -``` - -### Facet search settings - -#### [Get facet search settings](https://www.meilisearch.com/docs/reference/api/settings#get-facet-search-settings) - -```ts -client.index('myIndex').getFacetSearch(): Promise -``` - -#### [Update facet search settings](https://www.meilisearch.com/docs/reference/api/settings#update-facet-search-settings) - -```ts -client.index('myIndex').updateFacetSearch(enabled: boolean): Promise -``` - -#### [Reset facet search settings](https://www.meilisearch.com/docs/reference/api/settings#reset-facet-search-settings) - -```ts -client.index('myIndex').resetFacetSearch(): Promise -``` - -### Prefix search settings - -#### [Get prefix search settings](https://www.meilisearch.com/docs/reference/api/settings#get-prefix-search-settings) - -```ts -client.index('myIndex').getPrefixSearch(): Promise -``` - -#### [Update prefix search settings](https://www.meilisearch.com/docs/reference/api/settings#update-prefix-search-settings) - -```ts -client.index('myIndex').updatePrefixSearch(prefixSearch: PrefixSearch): Promise -``` - -#### [Reset prefix search settings](https://www.meilisearch.com/docs/reference/api/settings#reset-prefix-search-settings) - -```ts -client.index('myIndex').resetPrefixSearch(): Promise -``` - -### Embedders - -⚠️ This feature is experimental. Activate the [`vectorStore` experimental feature to use it](https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features) +We welcome all contributions, big and small! If you want to know more about this +SDK's development workflow or want to contribute to the repo, please visit our +[contributing guidelines](/CONTRIBUTING.md) for detailed instructions. -#### Get embedders - -```ts -client.index('myIndex').getEmbedders(): Promise -``` - -#### Update embedders - -```ts -client.index('myIndex').updateEmbedders(embedders: Embedders): Promise -``` - -#### Reset embedders - -```ts -client.index('myIndex').resetEmbedders(): Promise -``` - -### SearchCutoffMs - -#### [Get SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#get-search-cutoff) - -```ts -client.index('myIndex').getSearchCutoffMs(): Promise -``` - -#### [Update SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#update-search-cutoff) - -```ts -client.index('myIndex').updateSearchCutoffMs(searchCutoffMs: SearchCutoffMs): Promise -``` - -#### [Reset SearchCutoffMs](https://www.meilisearch.com/docs/reference/api/settings#reset-search-cutoff) - -```ts -client.index('myIndex').resetSearchCutoffMs(): Promise -``` - -### Keys - -#### [Get keys](https://www.meilisearch.com/docs/reference/api/keys#get-all-keys) - -```ts -client.getKeys(parameters: KeysQuery): Promise -``` - -#### [Get one key](https://www.meilisearch.com/docs/reference/api/keys#get-one-key) - -```ts -client.getKey(keyOrUid: string): Promise -``` - -#### [Create a key](https://www.meilisearch.com/docs/reference/api/keys#create-a-key) - -```ts -client.createKey(options: KeyCreation): Promise -``` - -#### [Update a key](https://www.meilisearch.com/docs/reference/api/keys#update-a-key) - -```ts -client.updateKey(keyOrUid: string, options: KeyUpdate): Promise -``` - -#### [Delete a key](https://www.meilisearch.com/docs/reference/api/keys#delete-a-key) - -```ts -client.deleteKey(keyOrUid: string): Promise -``` - -### `isHealthy` - -#### [Return `true` or `false` depending on the health of the server](https://www.meilisearch.com/docs/reference/api/health#get-health) - -```ts -client.isHealthy(): Promise -``` - -### Health - -#### [Check if the server is healthy](https://www.meilisearch.com/docs/reference/api/health#get-health) - -```ts -client.health(): Promise -``` - -### Stats - -#### [Get database stats](https://www.meilisearch.com/docs/reference/api/stats#get-stats-of-all-indexes) - -```ts -client.getStats(): Promise -``` - -### Version - -#### [Get binary version](https://www.meilisearch.com/docs/reference/api/version#get-version-of-meilisearch) - -```ts -client.getVersion(): Promise -``` - -### Dumps - -#### [Trigger a dump creation process](https://www.meilisearch.com/docs/reference/api/dump#create-a-dump) - -```ts -client.createDump(): Promise -``` - -### Snapshots - -#### [Trigger a snapshot on-demand process](https://www.meilisearch.com/docs/reference/api/snapshots#create-a-snapshot) - -```ts -client.createSnapshot(): Promise -``` --- -Meilisearch provides and maintains many SDKs and integration tools like this one. We want to provide everyone with an **amazing search experience for any kind of project**. For a full overview of everything we create and maintain, take a look at the [integration-guides](https://github.com/meilisearch/integration-guides) repository. +Meilisearch provides and maintains many SDKs and integration tools like this +one. We want to provide everyone with an **amazing search experience for any +kind of project**. For a full overview of everything we create and maintain, +take a look at the +[integration-guides](https://github.com/meilisearch/integration-guides) +repository. diff --git a/package.json b/package.json index abfbeafef..d0cdaf161 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "build": "vite build && tsc -p tsconfig.build.json && vite --mode production-umd build", "postbuild": "node scripts/build.js", "test": "vitest run --coverage", - "types": "tsc -p tsconfig.json --noEmit", + "types": "tsc --noEmit", "types:watch": "yarn types --watch", "test:env:browser": "yarn build && node scripts/copy-umd-file.js --to ./tests/env/express/public && yarn --cwd tests/env/express && yarn --cwd tests/env/express test", "test:watch": "vitest watch", diff --git a/tsconfig.json b/tsconfig.json index dbcb92138..6c14d173d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,10 +2,11 @@ "compilerOptions": { // We don't want to check node_modules "skipLibCheck": true, - "module": "node16", + "module": "nodenext", // Node.js 18 supports up to ES2022 according to https://www.npmjs.com/package/@tsconfig/node18 "target": "es2022", "lib": ["ESNext", "dom"], + "resolveJsonModule": true, "strict": true, "verbatimModuleSyntax": true } diff --git a/vite.config.js b/vite.config.ts similarity index 100% rename from vite.config.js rename to vite.config.ts