├── .editorconfig ├── .gitignore ├── .npmrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build.config.ts ├── docus ├── .eslintignore ├── .eslintrc.cjs ├── .gitignore ├── .npmrc ├── README.md ├── app.config.ts ├── components │ └── Logo.vue ├── content │ ├── 0.index.md │ ├── 1.getting-started │ │ ├── 1.setup.md │ │ └── _dir.yml │ ├── 2.Front-Side │ │ ├── 1.Basic.md │ │ ├── 2.Advanced.md │ │ └── _dir.yml │ ├── 3.Server-Side │ │ ├── 1.server.md │ │ ├── 2.exemple.md │ │ └── _dir.yml │ └── 4.Dev-Tools │ │ ├── 1.tools.md │ │ └── _dir.yml ├── nuxt.config.ts ├── package.json ├── pnpm-lock.yaml ├── public │ ├── cover.png │ ├── favicon.ico │ ├── logo-dark.svg │ ├── logo-light.svg │ └── logo.png ├── renovate.json ├── tokens.config.ts └── tsconfig.json ├── eslint.config.mjs ├── package.json ├── playground ├── app.config.ts ├── layouts │ └── default.vue ├── nuxt.config.ts ├── pages │ ├── async.vue │ ├── index.vue │ └── instant.vue ├── server │ └── api │ │ └── exemple.post.ts ├── tsconfig.json └── types.d.ts ├── pnpm-lock.yaml ├── renovate.json ├── src ├── module.ts └── runtime │ ├── composables │ ├── useAsyncMeiliSearch.ts │ ├── useInstantSearch.ts │ ├── useMeiliSearch.ts │ └── useMeiliSearchRef.ts │ ├── server │ └── utils │ │ └── meilisearch.ts │ └── types │ ├── instantsearh.d.ts │ └── nuxtMeilisearch.d.ts └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_size = 2 5 | indent_style = space 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules 3 | # Logs 4 | *.log* 5 | 6 | # Temp directories 7 | .temp 8 | .tmp 9 | .cache 10 | 11 | # meilisearch 12 | /data.ms 13 | /meili_data/ 14 | 15 | # Yarn 16 | **/.yarn/cache 17 | **/.yarn/*state* 18 | 19 | # Generated dirs 20 | dist 21 | 22 | # Nuxt 23 | .nuxt 24 | .output 25 | .vercel_build_output 26 | .build-* 27 | .env 28 | .netlify 29 | 30 | # Env 31 | .env 32 | 33 | # Testing 34 | reports 35 | coverage 36 | *.lcov 37 | .nyc_output 38 | 39 | # VSCode 40 | .vscode 41 | 42 | # Intellij idea 43 | *.iml 44 | .idea 45 | 46 | # OSX 47 | .DS_Store 48 | .AppleDouble 49 | .LSOverride 50 | .AppleDB 51 | .AppleDesktop 52 | Network Trash Folder 53 | Temporary Items 54 | .apdisk 55 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | shamefully-hoist=true 2 | strict-peer-dependencies=false 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ## v1.3.10 6 | 7 | [compare changes](https://github.com/xlanex6/nuxt-meilisearch/compare/v1.3.9...v1.3.10) 8 | 9 | ## v1.3.9 10 | 11 | [compare changes](https://github.com/xlanex6/nuxt-meilisearch/compare/v1.3.8...v1.3.9) 12 | 13 | ## v1.3.8 14 | 15 | [compare changes](https://github.com/xlanex6/nuxt-meilisearch/compare/v1.3.6...v1.3.8) 16 | 17 | ### 🏡 Chore 18 | 19 | - **release:** V1.3.6 ([609769a](https://github.com/xlanex6/nuxt-meilisearch/commit/609769a)) 20 | - **release:** V1.3.7 ([83b3a02](https://github.com/xlanex6/nuxt-meilisearch/commit/83b3a02)) 21 | - Remove unused eslint configuration file and update instantsearch types ([aeae9c3](https://github.com/xlanex6/nuxt-meilisearch/commit/aeae9c3)) 22 | 23 | ### ❤️ Contributors 24 | 25 | - Xlanex6 ([@xlanex6](http://github.com/xlanex6)) 26 | 27 | ## v1.3.7 28 | 29 | [compare changes](https://github.com/xlanex6/nuxt-meilisearch/compare/v1.3.6...v1.3.7) 30 | 31 | ## v1.3.6 32 | 33 | [compare changes](https://github.com/xlanex6/nuxt-meilisearch/compare/v1.3.5...v1.3.6) 34 | 35 | ## v1.3.5 36 | 37 | [compare changes](https://github.com/xlanex6/nuxt-meilisearch/compare/v1.3.4...v1.3.5) 38 | 39 | ## v1.3.4 40 | 41 | [compare changes](https://github.com/xlanex6/nuxt-meilisearch/compare/v1.3.2...v1.3.4) 42 | 43 | ### 🏡 Chore 44 | 45 | - Update package.json version to 1.3.3 and fix dev:prepare script ([ad3b6dc](https://github.com/xlanex6/nuxt-meilisearch/commit/ad3b6dc)) 46 | - Update release script to use pnpm instead of npm ([b2c0bda](https://github.com/xlanex6/nuxt-meilisearch/commit/b2c0bda)) 47 | 48 | ### ❤️ Contributors 49 | 50 | - Xlanex6 ([@xlanex6](http://github.com/xlanex6)) 51 | 52 | ### [0.1.9](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.1.8...v0.1.9) (2023-04-23) 53 | 54 | ### [0.1.8](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.1.7...v0.1.8) (2023-04-04) 55 | 56 | ### [0.1.7](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.1.6...v0.1.7) (2022-12-15) 57 | 58 | ### [0.1.6](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.1.5...v0.1.6) (2022-11-19) 59 | 60 | ### [0.1.5](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.1.4...v0.1.5) (2022-11-18) 61 | 62 | ### [0.1.4](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.1.3...v0.1.4) (2022-11-02) 63 | 64 | ### [0.1.3](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.1.1...v0.1.3) (2022-10-12) 65 | 66 | ### [0.1.1](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.0.8...v0.1.1) (2022-07-15) 67 | 68 | ### [0.0.8](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.0.6...v0.0.8) (2022-05-31) 69 | 70 | ### [0.0.6](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.0.4...v0.0.6) (2022-05-31) 71 | 72 | 73 | ### Bug Fixes 74 | 75 | * **dep:** Freeze dependencies until Stable Nuxt version ([1528157](https://github.com/xlanex6/nuxt-meilisearch/commit/15281570006b4fbd8bfeafd4472780500a6c67ff)) 76 | 77 | ### [0.0.4](https://github.com/xlanex6/nuxt-meilisearch/compare/v0.0.2...v0.0.4) (2022-05-09) 78 | 79 | 80 | ### Features 81 | 82 | * **TS:** Ts config from example ([b6c65e5](https://github.com/xlanex6/nuxt-meilisearch/commit/b6c65e5a7579fec9623de5419221b83487f01eb2)) 83 | 84 | ### 0.0.2 (2022-05-08) 85 | 86 | 87 | ### Features 88 | 89 | * **config:** set default module options ([74d0c29](https://github.com/xlanex6/nuxt-meilisearch/commit/74d0c2917063fd2ce1e04e0b451b80835d541421)) 90 | * meiliSearch client move to composable ([f4e012c](https://github.com/xlanex6/nuxt-meilisearch/commit/f4e012ce4be6c2a06df1ffeddfc3a1ab0f976180)) 91 | * readme ([163fb37](https://github.com/xlanex6/nuxt-meilisearch/commit/163fb377e9fc0a7342624f2c5c016efc3954c4c2)) 92 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022-present - xlanex6 (Alex Duval) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![xlanex6/nuxt-meilisearch](./docus/public/cover.png)](https://nuxt-meilisearch.vercel.app/) 2 | 3 |

4 | 5 | [![Latest Stable Version](https://img.shields.io/npm/v/nuxt-meilisearch.svg?style=for-the-badge)](https://www.npmjs.com/package/nuxt-meilisearch) [![License](https://img.shields.io/npm/l/nuxt-meilisearch.svg?style=for-the-badge)](https://www.npmjs.com/package/nuxt-meilisearch) 6 | [![Twitter Follow](https://img.shields.io/twitter/follow/xlanex6?color=1DA1F2&logo=twitter&style=for-the-badge)](https://twitter.com/xlanex6) 7 | 8 |

9 | 10 | # Nuxt Meilisearch 11 | 12 | Integrate [Meilisearch](https://meilisearch.com/?utm_campaign=oss&utm_source=github&utm_content=nuxt-meilisearch) fast and hyper-relevant search engine in your [Nuxt](https://nuxt.com) application. 13 | 14 | Read [Nuxt Meilisearch documentation](https://nuxt-meilisearch.vercel.app). 15 | 16 | ## Features 17 | 18 | - Nuxt 3 integration 19 | - Auto-imported composables 20 | - Server-side rendering support 21 | - Client & server integration of Meilisearch 22 | - Full TypeScript support 23 | - Compatible with [Instant Meilisearch](https://github.com/meilisearch/instant-meilisearch) 24 | - Vue [Algolia InstantSearch](https://github.com/algolia/instantsearch) components (optional) 25 | 26 | ## Installation 27 | 28 | Add `nuxt-meilisearch` using the Nuxt CLI to your project 29 | 30 | ```bash 31 | npx nuxi@latest module add nuxt-meilisearch 32 | ``` 33 | 34 | or add `nuxt-meilisearch` using your dependency manager 35 | 36 | ```bash 37 | # with npm 38 | npm install nuxt-meilisearch 39 | 40 | # with yarn 41 | yarn add nuxt-meilisearch 42 | 43 | # with pnpm 44 | pnpm add nuxt-meilisearch 45 | ``` 46 | 47 | and then to the `modules` section of `nuxt.config.ts`: 48 | 49 | ```ts 50 | // nuxt.config.ts 51 | export default defineNuxtConfig({ 52 | modules: [ 53 | 'nuxt-meilisearch' 54 | ], 55 | meilisearch: { 56 | hostUrl: '', //required 57 | searchApiKey: '', // required 58 | adminApiKey: '', // optional 59 | serverSideUsage: true // default: false 60 | }) 61 | ``` 62 | 63 | That's it! 🎉 64 | 65 | ## Usage 66 | 67 | This example performs a search in the `books` index: 68 | 69 | ```html 70 | 77 | 78 | 83 | ``` 84 | 85 | Learn more in the [Nuxt Meilisearch documentation](https://nuxt-meilisearch.vercel.app). 86 | 87 | ## Contributing 88 | 89 | Issues and pull requests are welcome. 🫶 90 | 91 | **Local development** 92 | 93 | - Run `npm run dev:prepare` to generate type stubs. 94 | - Use `npm run dev` to start [playground](./playground) in development mode. 95 | 96 | ## Licence 97 | 98 | [MIT Licence](./LICENCE) 99 | 100 | 101 | 102 | 112 | 113 | 125 | -------------------------------------------------------------------------------- /build.config.ts: -------------------------------------------------------------------------------- 1 | import { defineBuildConfig } from 'unbuild' 2 | 3 | export default defineBuildConfig({ 4 | failOnWarn: false, 5 | externals: ['#imports', '#app'], 6 | }) 7 | -------------------------------------------------------------------------------- /docus/.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .output 4 | .nuxt -------------------------------------------------------------------------------- /docus/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@nuxt/eslint-config', 4 | rules: { 5 | 'vue/max-attributes-per-line': 'off', 6 | 'vue/multi-word-component-names': 'off', 7 | }, 8 | } 9 | -------------------------------------------------------------------------------- /docus/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.iml 3 | .idea 4 | *.log* 5 | .nuxt 6 | .vscode 7 | .DS_Store 8 | coverage 9 | dist 10 | sw.* 11 | .env 12 | .output 13 | -------------------------------------------------------------------------------- /docus/.npmrc: -------------------------------------------------------------------------------- 1 | shamefully-hoist=true -------------------------------------------------------------------------------- /docus/README.md: -------------------------------------------------------------------------------- 1 | # Docus Starter 2 | 3 | Starter template for [Docus](https://docus.dev). 4 | 5 | ## Clone 6 | 7 | Clone the repository (using `nuxi`): 8 | 9 | ```bash 10 | npx nuxi init -t themes/docus 11 | ``` 12 | 13 | ## Setup 14 | 15 | Install dependencies: 16 | 17 | ```bash 18 | yarn install 19 | ``` 20 | 21 | ## Development 22 | 23 | ```bash 24 | yarn dev 25 | ``` 26 | 27 | ## Edge Side Rendering 28 | 29 | Can be deployed to Vercel Functions, Netlify Functions, AWS, and most Node-compatible environments. 30 | 31 | Look at all the available presets [here](https://v3.nuxtjs.org/guide/deploy/presets). 32 | 33 | ```bash 34 | yarn build 35 | ``` 36 | 37 | ## Static Generation 38 | 39 | Use the `generate` command to build your application. 40 | 41 | The HTML files will be generated in the .output/public directory and ready to be deployed to any static compatible hosting. 42 | 43 | ```bash 44 | yarn generate 45 | ``` 46 | 47 | ## Preview build 48 | 49 | You might want to preview the result of your build locally, to do so, run the following command: 50 | 51 | ```bash 52 | yarn preview 53 | ``` 54 | 55 | --- 56 | 57 | For a detailed explanation of how things work, check out [Docus](https://docus.dev). 58 | -------------------------------------------------------------------------------- /docus/app.config.ts: -------------------------------------------------------------------------------- 1 | export default defineAppConfig({ 2 | docus: { 3 | title: 'Nuxt Meilisearch', 4 | description: 'Meilisearch integration to enable lightning-fast, and hyper-relevant search engine into Nuxt', 5 | image: '/cover.png', 6 | socials: { 7 | twitter: 'xlanex6', 8 | github: 'xlanex6/nuxt-meilisearch', 9 | }, 10 | // github: { 11 | // dir: '.starters/default/content', 12 | // branch: 'main', 13 | // repo: 'docus', 14 | // owner: 'nuxt-themes', 15 | // edit: true 16 | // }, 17 | aside: { 18 | level: 0, 19 | collapsed: false, 20 | exclude: [], 21 | }, 22 | main: { 23 | padded: true, 24 | fluid: true, 25 | }, 26 | header: { 27 | logo: true, 28 | showLinkIcon: true, 29 | exclude: [], 30 | fluid: true, 31 | }, 32 | }, 33 | }) 34 | -------------------------------------------------------------------------------- /docus/components/Logo.vue: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /docus/content/0.index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Home 3 | navigation: false 4 | layout: page 5 | main: 6 | fluid: false 7 | --- 8 | 100 | 101 | ::block-hero 102 | --- 103 | cta: 104 | - Get Started 105 | - /getting-started/setup 106 | secondary: 107 | - Open on GitHub → 108 | - https://github.com/xlanex6/nuxt-meilisearch 109 | snippet: npm i -D nuxt-meilisearch 110 | features: 111 | - Easy integration with MeilisearchJS lib 112 | - Support for Vue Algolia Vue 3 InstantSearch components (optional) 113 | - Server usage to manage documents and all preferences ( index, preferences ) 114 | --- 115 | 116 | #title 117 | Nuxt Meilisearch 118 | 119 | #description 120 | Easy way to install a blazing-fast search experience with [Meilisearch](https://www.meilisearch.com) into your [Nuxt](https://v3.nuxtjs.org) application 121 | 122 | #extra 123 | 124 | :: 125 | 126 | ::card-grid 127 | #title 128 | 🔎 Searching experience 129 | 130 | #root 131 | :ellipsis 132 | 133 | #default 134 | ::card 135 | #title 136 | Easy integration 137 | #description 138 | Straight forward installation, out of complixity 139 | :: 140 | ::card 141 | #title 142 | Easy composables 143 | #description 144 | `useMeiliSearch` and `useAsyncMeiliSearch` for SSR usage 145 | :: 146 | ::card 147 | #title 148 | Server Side 149 | #description 150 | Server usage with `$meilisearch`. 151 | Manage documents and all preferences ( index, settings, addDocuments... ) 152 | :: 153 | :: 154 | -------------------------------------------------------------------------------- /docus/content/1.getting-started/1.setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Setup 3 | description: Add Nuxt-meilisearch into nuxt 4 | layout: default 5 | --- 6 | 7 | Check the [Nuxt.js documentation](https://nuxtjs.org/api/configuration-modules#the-modules-property) for more information about installing and using modules in Nuxt.js. 8 | 9 | ## Installation 10 | 11 | Add `nuxt-meilisearch` using the Nuxt CLI to your project 12 | 13 | ```bash 14 | npx nuxi@latest module add nuxt-meilisearch 15 | ``` 16 | 17 | or add `nuxt-meilisearch` using your dependency manager 18 | 19 | ```bash 20 | # with npm 21 | npm install nuxt-meilisearch 22 | 23 | # with yarn 24 | yarn add nuxt-meilisearch 25 | 26 | # with pnpm 27 | pnpm add nuxt-meilisearch 28 | ``` 29 | 30 | and then to the `modules` section of `nuxt.config.ts`: 31 | 32 | ```ts{}[nuxt.config.js] 33 | export default defineNuxtConfig({ 34 | ... 35 | modules: [ 36 | 'nuxt-meilisearch' 37 | ], 38 | ... 39 | ``` 40 | 41 | ## Basic Setup 42 | :badge[Client Side only] 43 | 44 | The basic setup is to provide the host url and the search api key. 45 | 46 | ```ts{}[nuxt.config.js] 47 | ... 48 | meilisearch: { 49 | hostUrl: 'http://my-meilisearch-server.domain.com' //reqired 50 | searchApiKey: '' // reqired 51 | } 52 | ... 53 | }) 54 | ``` 55 | 56 | ## Advanced Setup 57 | :badge[Client Side + Server Side] 58 | 59 | You can customization Meilisearch client `meilisearchConfig`. 60 | 61 | Full documentation [on Meiliserch client page](https://github.com/meilisearch/instant-meilisearch#-customization) for more details. 62 | 63 | ```ts{}[nuxt.config.js] 64 | import { defineNuxtConfig } from 'nuxt' 65 | 66 | export default defineNuxtConfig({ 67 | ... 68 | modules: [ 69 | 'nuxt-meilisearch' 70 | ], 71 | meilisearch: { 72 | hostUrl: 'http://my-meilisearch-server.domain.com' 73 | searchApiKey: '', 74 | adminApiKey: '', 75 | instantSearch: true, // default false 76 | serverSideUsage: false// default false 77 | } 78 | ... 79 | }) 80 | ``` 81 | -------------------------------------------------------------------------------- /docus/content/1.getting-started/_dir.yml: -------------------------------------------------------------------------------- 1 | title: Getting Started 2 | icon: heroicons-outline:lightning-bolt 3 | -------------------------------------------------------------------------------- /docus/content/2.Front-Side/1.Basic.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basic 3 | layout: default 4 | --- 5 | 6 | # Basic 7 | 8 | You can use Meilisearch's power with all `composables` available in this package. 9 | 10 | ## useMeiliSearch 11 | 12 | Use this composable to search into the provide index. 13 | ```js{} 14 | 21 | ``` 22 | 23 | ### `search(query: string, options?: SearchParams)` 24 | 25 | It will return a promise with the result of the search. 26 | All options are available [here](https://www.meilisearch.com/docs/reference/api/search#body) 27 | 28 | ### `result` 29 | 30 | It will return the result of the search and will be updated each time you call `search` function. 31 | 32 | Result will be shape like descibe [here](https://www.meilisearch.com/docs/reference/api/search#response) 33 | 34 | ::alert{type="info"} 35 | **Result** will be also set into `useState('#INDEX-search-result')` where `#INDEX` is the index name. 36 | Usefull if you want to use the result in another component. 37 | :: 38 | 39 | Exemple: 40 | ```js{}[child-component.vue] 41 | 44 | ``` 45 | 46 | ## useAsyncMeiliSearch 47 | 48 | This composable is the same as `useMeiliSearch` but it will return a `data` object for SSR usage, with `refresh` function to update the data. 49 | 50 | `index` and `query` are required. 51 | 52 | It will be the intial setup of the search. you can also privide `params` to add some options to the search. 53 | All options are available [here](https://www.meilisearch.com/docs/reference/api/search#body) 54 | 55 | ```js{} 56 | const { data, refresh } = await useAsyncMeiliSearch({ 57 | index: 'books', 58 | query: 'harry', 59 | params: { 60 | limit: 2 61 | } 62 | }) 63 | ``` 64 | 65 | ## useMeiliSearchRef 66 | 67 | Use this composable you have access to meilisearch from you component. 68 | 69 | ```js{} 70 | 73 | ``` 74 | -------------------------------------------------------------------------------- /docus/content/2.Front-Side/2.Advanced.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Advanced 3 | layout: default 4 | --- 5 | 6 | # Advanced with Algolia 7 | 8 | By `Advanced` we mean that you can use Meilisearch with other tools like [Algolia Instantsearch](https://github.com/algolia/instantsearch) 9 | 10 | ### Setup 11 | Activate `instantSearch` option in your `nuxt.config.ts` file. 12 | 13 | ```ts{}[nuxt.config.ts] 14 | meilisearch: { 15 | 16 | instantSearch: true, 17 | // or 18 | instantSearch: { 19 | theme: 'algolia' 20 | }, 21 | ... 22 | } 23 | ``` 24 | Theme valid options are `satellite`, `reset` or `algolia`. 25 | 26 | All `theme` info on [official page](https://www.algolia.com/doc/guides/building-search-ui/widgets/customize-an-existing-widget/vue/#style-your-widgets) 27 | 28 | ### useInstantSearch 29 | 30 | Use this composable to get the `client` instance of Algolia InstantSearch. 31 | 32 | ```js{} 33 | 36 | ``` 37 | 38 | ### Algolia Components 39 | 40 | **ALL** Algolia components will be loaded and available in your app. 41 | 42 | In your components, import Vue instantSearch like so 43 | 44 | ```js{} 45 | import { 46 | AisInstantSearch, 47 | AisHits, 48 | AisSearchBox, 49 | } from 'vue-instantsearch/vue3/es' 50 | ``` 51 | 52 | ### Full Exemple 53 | 54 | On your client side ( Front-end ), you can load Meilisearch client with composables. 55 | 56 | ```vue{} 57 | 67 | 68 | 93 | ``` 94 | -------------------------------------------------------------------------------- /docus/content/2.Front-Side/_dir.yml: -------------------------------------------------------------------------------- 1 | title: Front Side 2 | icon: streamline:programming-browser-search-search-window-glass-app-code-programming-query-find-magnifying-apps 3 | -------------------------------------------------------------------------------- /docus/content/3.Server-Side/1.server.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Config 3 | layout: default 4 | --- 5 | 6 | # Meilisearch Server Side 7 | 8 | ::alert{type="danger"} 9 | 🚨🚨 **Breaking CHANGE** 🚨🚨 10 | :: 11 | 12 | From v0.4.0 and above, you access to Meilisearch with `$meilisearch` instead of event. 13 | 🛑 ~~`const { serverMeilisearchClient } = event.context`~~ 14 | 15 | ✅ `$meilisearch` 16 | 17 | The aim is to optimize performance and avoid to create a new instance for each request, no more `event.context` binding. 18 | 19 | --- 20 | 21 | ### Configuration 22 | 23 | You can to manage documents, indexes or preferences from Nuxt server side. 24 | To do so, first enable it 25 | 26 | ```ts{}[nuxt.config.ts] 27 | meilisearch: { 28 | ... 29 | serverSideUsage: true, // default false 30 | adminApiKey: '', 31 | ... 32 | } 33 | ``` 34 | 35 | ::alert{type="info"} 36 | You need to provide API KEY with **ADMIN ACCESS** 37 | :: 38 | 39 | ### Usage 40 | 41 | Now you can use the `$meilisearch` instance from your server side code. 42 | 43 | Full exemple: 44 | 45 | ```ts{}[my-endpoint.ts] 46 | 47 | export default defineEventHandler(async (event) => { 48 | 49 | // read from body 50 | const body = await readBody(event) 51 | 52 | // Meiliseach is available with $meilisearch 53 | const meilisearchResponse = $meilisearch.index('books').addDocuments(body) 54 | 55 | return meilisearchResponse 56 | 57 | }) 58 | 59 | ``` 60 | 61 | ### Typescript 62 | 63 | `$meilisearch` is full typed so you can enjoy the full power of typescript, autocomplete and intellisense. 64 | -------------------------------------------------------------------------------- /docus/content/3.Server-Side/2.exemple.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Exemple 3 | layout: default 4 | --- 5 | 6 | ### Full example 7 | 8 | From your API server route, you can add a document to specific index. 9 | 10 | ```ts{}[server/api/myRoute] 11 | export default defineEventHandler(async (event) => { 12 | 13 | const addRecordRes = await $meilisearch.index('movies').addDocuments( 14 | { 15 | id: 999999994234, 16 | title: 'Batman Unmasked: The Psychology of the Dark Knight', 17 | poster: 'https://image.tmdb.org/t/p/w1280/jjHu128XLARc2k4cJrblAvZe0HE.jpg', 18 | overview: 'Delve into the world of Batman and the vigilante justice tha', 19 | release_date: '2008-07-15' 20 | } 21 | ) 22 | 23 | return { myCustomResponse: "Document is on the way....", addRecordRes } 24 | } 25 | ``` 26 | 27 | All options from Meiliseach JS SDK are available. 28 | Checkout [Meiliseach full docs](https://www.meilisearch.com/docs/reference/api/overview) 29 | -------------------------------------------------------------------------------- /docus/content/3.Server-Side/_dir.yml: -------------------------------------------------------------------------------- 1 | title: Server Side 2 | icon: charm:cog 3 | -------------------------------------------------------------------------------- /docus/content/4.Dev-Tools/1.tools.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Dev Tools 3 | layout: default 4 | --- 5 | 6 | # Dev Tools Tabs 7 | 8 | If you enable [Nuxt dev tools module](https://devtools.nuxt.com/), you will got a Meiliseach Tab. 9 | 10 | ### Admin demo 11 | It provide a `basic` tab after enter your `admin key`. 12 | 13 | ### Task 14 | 15 | WIP 🚧 16 | -------------------------------------------------------------------------------- /docus/content/4.Dev-Tools/_dir.yml: -------------------------------------------------------------------------------- 1 | title: Dev Tools 2 | icon: ph:code-light 3 | -------------------------------------------------------------------------------- /docus/nuxt.config.ts: -------------------------------------------------------------------------------- 1 | export default defineNuxtConfig({ 2 | // https://github.com/nuxt-themes/docus 3 | extends: '@nuxt-themes/docus', 4 | 5 | modules: [ 6 | // https://github.com/nuxt/devtools 7 | '@nuxt/devtools', 8 | ], 9 | }) 10 | -------------------------------------------------------------------------------- /docus/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docus-starter", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "nuxi dev", 7 | "build": "nuxi build", 8 | "generate": "nuxi generate", 9 | "preview": "nuxi preview", 10 | "lint": "eslint ." 11 | }, 12 | "devDependencies": { 13 | "@nuxt-themes/docus": "1.15.0", 14 | "@nuxt/devtools": "0.6.7", 15 | "@nuxt/eslint-config": "0.2.0", 16 | "@nuxtjs/plausible": "0.2.3", 17 | "@types/node": "20.8.6", 18 | "eslint": "8.51.0", 19 | "nuxt": "3.7.4" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docus/public/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xlanex6/nuxt-meilisearch/6ab71040be7171f2d855afbc2520f1690237fad4/docus/public/cover.png -------------------------------------------------------------------------------- /docus/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xlanex6/nuxt-meilisearch/6ab71040be7171f2d855afbc2520f1690237fad4/docus/public/favicon.ico -------------------------------------------------------------------------------- /docus/public/logo-dark.svg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xlanex6/nuxt-meilisearch/6ab71040be7171f2d855afbc2520f1690237fad4/docus/public/logo-dark.svg -------------------------------------------------------------------------------- /docus/public/logo-light.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docus/public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xlanex6/nuxt-meilisearch/6ab71040be7171f2d855afbc2520f1690237fad4/docus/public/logo.png -------------------------------------------------------------------------------- /docus/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@nuxtjs" 4 | ], 5 | "lockFileMaintenance": { 6 | "enabled": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docus/tokens.config.ts: -------------------------------------------------------------------------------- 1 | import { defineTheme } from 'pinceau' 2 | 3 | export default defineTheme({ 4 | color: { 5 | primary: { 6 | 50: '#fef2f4', 7 | 100: '#fde6eb', 8 | 200: '#fad1db', 9 | 300: '#f5acbd', 10 | 400: '#ef7d9a', 11 | 500: '#e44b76', 12 | 600: '#d02e63', 13 | 700: '#af2154', 14 | 800: '#931e4b', 15 | 900: '#7e1d46', 16 | 950: '#460b22', 17 | }, 18 | }, 19 | }) 20 | -------------------------------------------------------------------------------- /docus/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.nuxt/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | import { createConfigForNuxt } from '@nuxt/eslint-config/flat' 3 | 4 | // Run `npx @eslint/config-inspector` to inspect the resolved config interactively 5 | export default createConfigForNuxt({ 6 | features: { 7 | // Rules for module authors 8 | tooling: true, 9 | // Rules for formatting 10 | stylistic: true, 11 | }, 12 | dirs: { 13 | src: [ 14 | // './playground', 15 | ], 16 | }, 17 | }) 18 | .append( 19 | 20 | ) 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-meilisearch", 3 | "type": "module", 4 | "version": "1.3.10", 5 | "author": "Alex Duval", 6 | "license": "MIT", 7 | "homepage": "https://nuxt-meilisearch.vercel.app", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/xlanex6/nuxt-meilisearch.git" 11 | }, 12 | "contributors": [], 13 | "keywords": [ 14 | "meilisearch", 15 | "search", 16 | "vue-instantsearch", 17 | "nuxt", 18 | "module" 19 | ], 20 | "exports": { 21 | ".": { 22 | "types": "./dist/types.d.ts", 23 | "import": "./dist/module.mjs", 24 | "require": "./dist/module.cjs" 25 | } 26 | }, 27 | "main": "./dist/module.mjs", 28 | "types": "./dist/types.d.ts", 29 | "files": [ 30 | "dist" 31 | ], 32 | "scripts": { 33 | "prepack": "nuxt-module-build build", 34 | "dev": "nuxi dev playground", 35 | "dev:build": "nuxi build playground", 36 | "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground", 37 | "release": "pnpm run prepack && changelogen --release && pnpm publish && git push --follow-tags", 38 | "lint": "eslint .", 39 | "lint:fix": "eslint . --fix", 40 | "test": "vitest run", 41 | "test:watch": "vitest watch", 42 | "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit" 43 | }, 44 | "dependencies": { 45 | "@meilisearch/instant-meilisearch": "0.19.3", 46 | "@nuxt/kit": "3.12.4", 47 | "instantsearch.css": "8.4.0", 48 | "meilisearch": "0.41.0", 49 | "vue-instantsearch": "4.19.2" 50 | }, 51 | "devDependencies": { 52 | "defu": "6.1.4", 53 | "@nuxt/ui": "2.18.4", 54 | "@nuxt/devtools": "1.3.9", 55 | "@nuxt/eslint-config": "0.5.1", 56 | "@nuxt/module-builder": "0.8.3", 57 | "@nuxt/schema": "3.12.4", 58 | "@nuxt/test-utils": "3.14.1", 59 | "@types/node": "22.4.1", 60 | "changelogen": "0.5.5", 61 | "eslint": "9.9.0", 62 | "nuxt": "3.12.4", 63 | "typescript": "latest", 64 | "vitest": "2.0.5", 65 | "vue-tsc": "2.0.29" 66 | }, 67 | "publishConfig": { 68 | "access": "public" 69 | }, 70 | "directories": { 71 | "doc": "docs", 72 | "example": "playground" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /playground/app.config.ts: -------------------------------------------------------------------------------- 1 | export default defineAppConfig({ 2 | ui: { 3 | primary: 'pink', 4 | gray: 'cool', 5 | }, 6 | }) 7 | -------------------------------------------------------------------------------- /playground/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 33 | -------------------------------------------------------------------------------- /playground/nuxt.config.ts: -------------------------------------------------------------------------------- 1 | import { defineNuxtConfig } from 'nuxt/config' 2 | import NuxtMeilisearch from '..' 3 | 4 | export default defineNuxtConfig({ 5 | modules: [ 6 | NuxtMeilisearch, 7 | '@nuxt/ui', 8 | ], 9 | 10 | meilisearch: { 11 | hostUrl: 'http://localhost:7700', 12 | searchApiKey: '2c746b4e6e56e6376588f4952d35c3348487346e3380fd9e12b725bb5c259707', 13 | instantSearch: { 14 | theme: 'satellite', 15 | }, 16 | serverSideUsage: true, 17 | adminApiKey: 'bfcb4330385d222886e29fed1721b8107acdba8043a4bf0738eb6d10ccbb5dfb', 18 | }, 19 | 20 | compatibilityDate: '2024-07-06', 21 | }) -------------------------------------------------------------------------------- /playground/pages/async.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 62 | -------------------------------------------------------------------------------- /playground/pages/index.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 69 | -------------------------------------------------------------------------------- /playground/pages/instant.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 44 | -------------------------------------------------------------------------------- /playground/server/api/exemple.post.ts: -------------------------------------------------------------------------------- 1 | import { defineEventHandler } from 'h3' 2 | 3 | export default defineEventHandler(async (event) => { 4 | // read from body 5 | const body = await readBody(event) 6 | 7 | // Meiliseach is available with $meilisearch 8 | 9 | const recordAddRes = $meilisearch.index('books').addDocuments(body) 10 | 11 | return recordAddRes 12 | }) 13 | -------------------------------------------------------------------------------- /playground/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.nuxt/tsconfig.json", 3 | "exclude": ["playground", "dist"] 4 | } 5 | -------------------------------------------------------------------------------- /playground/types.d.ts: -------------------------------------------------------------------------------- 1 | import './../src/runtime/meilisearch.d.ts' 2 | import './../src/runtime/instantsearch.d.ts' 3 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/module.ts: -------------------------------------------------------------------------------- 1 | import { 2 | addImportsDir, 3 | createResolver, 4 | defineNuxtModule, 5 | } from '@nuxt/kit' 6 | import { addCustomTab } from '@nuxt/devtools-kit' 7 | import { defu } from 'defu' 8 | 9 | import type { ModuleOptions } from './runtime/types/nuxtMeilisearch.js' 10 | 11 | enum InstantSearchThemes { 12 | reset, 13 | algolia, 14 | satellite, 15 | } 16 | 17 | export default defineNuxtModule({ 18 | meta: { 19 | name: 'nuxt-meilisearch', 20 | configKey: 'meilisearch', 21 | compatibility: { 22 | nuxt: '^3.0.0-rc.9', 23 | }, 24 | }, 25 | defaults: { 26 | hostUrl: '', 27 | searchApiKey: '', 28 | serverSideUsage: false, 29 | adminApiKey: '', 30 | instantSearch: false, 31 | 32 | }, 33 | setup(options, nuxt) { 34 | if (!options.hostUrl) 35 | 36 | console.warn('`[nuxt-meilisearch]` Missing hostUrl`') 37 | 38 | if (!options.searchApiKey) 39 | 40 | console.warn('`[nuxt-meilisearch]` Missing `searchApiKey`') 41 | 42 | nuxt.options.runtimeConfig.public.meilisearchClient = defu(nuxt.options.runtimeConfig.public.meilisearchClient, { 43 | hostUrl: options.hostUrl, 44 | searchApiKey: options.searchApiKey, 45 | serverSideUsage: options.serverSideUsage, 46 | instantSearch: options.instantSearch, 47 | }) 48 | 49 | nuxt.options.runtimeConfig.serverMeilisearchClient = defu(nuxt.options.runtimeConfig.serverMeilisearchClient, { 50 | hostUrl: options.hostUrl, 51 | searchApiKey: options.searchApiKey, 52 | serverSideUsage: options.serverSideUsage, 53 | adminApiKey: options.adminApiKey, 54 | instantSearch: options.instantSearch, 55 | }) 56 | 57 | const resolver = createResolver(import.meta.url) 58 | 59 | if (options.instantSearch) { 60 | nuxt.options.build.transpile.push('vue-instantsearch/vue3/es') 61 | 62 | if (typeof options.instantSearch === 'object') { 63 | const { theme } = options.instantSearch 64 | if (theme) { 65 | if (theme in InstantSearchThemes) 66 | nuxt.options.css.push(`instantsearch.css/themes/${theme}.css`) 67 | } 68 | } 69 | } 70 | 71 | addImportsDir(resolver.resolve('./runtime/composables')) 72 | 73 | if (options.serverSideUsage) { 74 | if (!options.adminApiKey) 75 | 76 | console.warn('`[nuxt-meilisearch]` Missing `adminApiKey`') 77 | 78 | nuxt.hook('nitro:config', (config) => { 79 | config.externals = defu(config.externals, { 80 | inline: [resolver.resolve('./runtime/server')], 81 | }) 82 | config.imports = defu(config.imports, { 83 | presets: [ 84 | { 85 | from: resolver.resolve('./runtime/server/utils/meilisearch'), 86 | imports: ['$meilisearch'], 87 | }, 88 | ], 89 | }) 90 | }) 91 | } 92 | 93 | nuxt.hook('prepare:types', ({ references }) => { 94 | references.push({ 95 | path: resolver.resolve('./runtime/types/nuxtMeilisearch.d.ts'), 96 | }, { 97 | path: resolver.resolve('./runtime/instantsearch.d.ts'), 98 | }) 99 | }) 100 | 101 | addCustomTab({ 102 | name: 'meilisearch', 103 | title: 'Meilisearch', 104 | icon: 'https://raw.githubusercontent.com/meilisearch/meilisearch/main/assets/logo.svg', 105 | view: { 106 | type: 'iframe', 107 | src: `${options.hostUrl}`, 108 | }, 109 | }) 110 | }, 111 | 112 | }) 113 | -------------------------------------------------------------------------------- /src/runtime/composables/useAsyncMeiliSearch.ts: -------------------------------------------------------------------------------- 1 | import type { SearchParams } from 'meilisearch' 2 | import { useMeiliSearchRef } from './useMeiliSearchRef' 3 | import { useAsyncData } from '#imports' 4 | 5 | export interface AsyncSearchParams { 6 | index: string 7 | query?: string 8 | params?: SearchParams 9 | } 10 | 11 | export async function useAsyncMeiliSearch({ index, query, params }: AsyncSearchParams) { 12 | if (!index) 13 | throw new Error('`[nuxt-meilisearch]` Cannot search without `index`') 14 | 15 | const client = useMeiliSearchRef() 16 | 17 | const result = await useAsyncData(`${index}-async-search-result`, async () => { 18 | return await client.index(index).search(query, params) as T 19 | }) 20 | 21 | return result as T 22 | } 23 | -------------------------------------------------------------------------------- /src/runtime/composables/useInstantSearch.ts: -------------------------------------------------------------------------------- 1 | import type { MeilisearchConfig } from '@meilisearch/instant-meilisearch' 2 | import { instantMeiliSearch } from '@meilisearch/instant-meilisearch' 3 | import { useNuxtApp, useRuntimeConfig } from '#app' 4 | 5 | export function useInstantSearch() { 6 | const nuxtApp = useNuxtApp() 7 | 8 | const { meilisearchClient: { hostUrl, searchApiKey } } = useRuntimeConfig().public 9 | 10 | if (!nuxtApp._instantSearchClient) { 11 | const instantClient = instantMeiliSearch(hostUrl, searchApiKey) 12 | nuxtApp._instantSearchClient = instantClient.searchClient 13 | } 14 | 15 | return nuxtApp._instantSearchClient as MeilisearchConfig 16 | } 17 | -------------------------------------------------------------------------------- /src/runtime/composables/useMeiliSearch.ts: -------------------------------------------------------------------------------- 1 | import type { SearchParams, SearchResponse } from 'meilisearch' 2 | import { useMeiliSearchRef } from './useMeiliSearchRef' 3 | import { useState } from '#imports' 4 | 5 | export function useMeiliSearch(index: string) { 6 | if (!index) 7 | throw new Error('`[nuxt-meilisearch]` Cannot search without `index`') 8 | 9 | const client = useMeiliSearchRef() 10 | const result = useState(`${index}-search-result`, () => null as SearchResponse | null) 11 | 12 | const search = async (query: string, searchParams?: SearchParams) => { 13 | const resp = await client.index(index).search(query, searchParams) 14 | result.value = resp as SearchResponse 15 | 16 | return resp 17 | } 18 | 19 | return { 20 | search, 21 | result, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/runtime/composables/useMeiliSearchRef.ts: -------------------------------------------------------------------------------- 1 | import { MeiliSearch } from 'meilisearch' 2 | import { useNuxtApp, useRuntimeConfig } from '#app' 3 | 4 | export function useMeiliSearchRef() { 5 | const nuxtApp = useNuxtApp() 6 | 7 | const { meilisearchClient: { hostUrl, searchApiKey } } = useRuntimeConfig().public 8 | 9 | if (!nuxtApp._meilisearchClient) { 10 | nuxtApp._meilisearchClient = new MeiliSearch({ 11 | host: hostUrl, 12 | apiKey: searchApiKey, 13 | }) 14 | } 15 | 16 | return nuxtApp._meilisearchClient as MeiliSearch 17 | } 18 | -------------------------------------------------------------------------------- /src/runtime/server/utils/meilisearch.ts: -------------------------------------------------------------------------------- 1 | import { MeiliSearch } from 'meilisearch' 2 | import { useRuntimeConfig } from '#imports' 3 | 4 | const { serverMeilisearchClient: { hostUrl, adminApiKey } } = useRuntimeConfig() 5 | 6 | export const $meilisearch = new MeiliSearch({ 7 | host: hostUrl, 8 | apiKey: adminApiKey, 9 | }) 10 | -------------------------------------------------------------------------------- /src/runtime/types/instantsearh.d.ts: -------------------------------------------------------------------------------- 1 | /* eslint no-use-before-define: 0 */ 2 | 3 | import type { SearchClient } from 'instantsearch.js' 4 | import type { 5 | MultipleQueriesQuery as AlgoliaMultipleQueriesQuery, 6 | multipleSearchForFacetValues, 7 | } from '@algolia/client-search' 8 | import type { 9 | MultiSearchQuery as MeiliSearchMultiSearchParams, 10 | MultiSearchResult, 11 | Config as MeilisearchConfig, 12 | } from 'meilisearch' 13 | // Type definitions for meilisearch 14 | // Project: https://github.com/meilisearch/meilisearch-js 15 | // Definitions by: qdequele 16 | // Definitions: https://github.com/meilisearch/meilisearch-js 17 | // TypeScript Version: ^3.8.3 18 | 19 | // import type { Task } from '../task' 20 | 21 | export type { AlgoliaMultipleQueriesQuery, MultiSearchResult } 22 | export type { 23 | SearchResponse as AlgoliaSearchResponse, 24 | SearchForFacetValuesResponse as AlgoliaSearchForFacetValuesResponse, 25 | } from '@algolia/client-search' 26 | 27 | export type AlgoliaSearchForFacetValuesRequests = Parameters< 28 | ReturnType 29 | >[0] 30 | 31 | export type AlgoliaSearchForFacetValuesRequest = 32 | AlgoliaSearchForFacetValuesRequests[0] 33 | 34 | export type { 35 | Filter, 36 | FacetDistribution, 37 | MeiliSearch, 38 | FacetStats as MeiliFacetStats, 39 | MultiSearchQuery as MeiliSearchMultiSearchParams, 40 | Config as MeilisearchConfig, 41 | } from 'meilisearch' 42 | 43 | export type InstantSearchParams = AlgoliaMultipleQueriesQuery['params'] 44 | 45 | export const enum MatchingStrategies { 46 | ALL = 'all', 47 | LAST = 'last', 48 | } 49 | 50 | export type InstantMeiliSearchOptions = Pick< 51 | MeilisearchConfig, 52 | 'requestConfig' | 'httpClient' 53 | > & { 54 | placeholderSearch?: boolean 55 | primaryKey?: string 56 | keepZeroFacets?: boolean 57 | clientAgents?: string[] 58 | matchingStrategy?: MatchingStrategies 59 | finitePagination?: boolean 60 | } 61 | 62 | export type InstantMeiliSearchConfig = { 63 | placeholderSearch: boolean 64 | keepZeroFacets: boolean 65 | clientAgents: string[] 66 | finitePagination: boolean 67 | primaryKey?: string 68 | matchingStrategy?: MatchingStrategies 69 | } 70 | 71 | export type SearchCacheInterface = { 72 | getEntry: (key: string) => T | undefined 73 | formatKey: (components: any[]) => string 74 | setEntry: (key: string, searchResponse: T) => void 75 | clearCache: () => void 76 | } 77 | 78 | export type InsideBoundingBox = string | ReadonlyArray 79 | 80 | // Current state of the pagination 81 | export type PaginationState = { 82 | finite: boolean 83 | hitsPerPage: number 84 | page: number 85 | } 86 | 87 | export type InstantSearchPagination = { 88 | hitsPerPage: number 89 | page: number 90 | nbPages: number 91 | } 92 | 93 | export type MeilisearchMultiSearchResult> = 94 | MultiSearchResult & { 95 | pagination: PaginationState 96 | } 97 | 98 | export type SearchContext = Omit & 99 | InstantSearchParams & { 100 | pagination: PaginationState 101 | indexUid: string 102 | placeholderSearch: boolean 103 | keepZeroFacets: boolean 104 | insideBoundingBox?: InsideBoundingBox 105 | cropMarker?: string 106 | sort?: string | string[] 107 | primaryKey?: string 108 | matchingStrategy?: MatchingStrategies 109 | } 110 | 111 | export type InstantSearchGeoParams = { 112 | aroundLatLng?: string 113 | aroundLatLngViaIP?: boolean 114 | aroundRadius?: number | 'all' 115 | aroundPrecision?: number 116 | minimumAroundRadius?: number 117 | insideBoundingBox?: InsideBoundingBox 118 | insidePolygon?: ReadonlyArray 119 | } 120 | 121 | export type InstantMeiliSearchInstance = SearchClient & { 122 | clearCache: () => void 123 | } 124 | 125 | export type MultiSearchResolver = { 126 | multiSearch: ( 127 | searchQueries: MeiliSearchMultiSearchParams[], 128 | instantSearchPagination: PaginationState[] 129 | ) => Promise 130 | } 131 | 132 | export type AlgoliaFacetStats = Record< 133 | string, 134 | { 135 | /** 136 | * The minimum value in the result set. 137 | */ 138 | min: number 139 | /** 140 | * The maximum value in the result set. 141 | */ 142 | max: number 143 | /** 144 | * The average facet value in the result set. 145 | */ 146 | avg: number 147 | /** 148 | * The sum of all values in the result set. 149 | */ 150 | sum: number 151 | } 152 | > 153 | 154 | export type Config = { 155 | host: string 156 | apiKey?: string 157 | clientAgents?: string[] 158 | requestConfig?: Partial> 159 | httpClient?: (input: string, init?: RequestInit) => Promise 160 | timeout?: number 161 | } 162 | 163 | /// 164 | /// Resources 165 | /// 166 | 167 | export type Pagination = { 168 | offset?: number 169 | limit?: number 170 | } 171 | 172 | export type ResourceQuery = Pagination & object 173 | 174 | export type ResourceResults = Pagination & { 175 | results: T 176 | total: number 177 | } 178 | 179 | /// 180 | /// Indexes 181 | /// 182 | 183 | export type IndexOptions = { 184 | primaryKey?: string 185 | } 186 | 187 | export type IndexObject = { 188 | uid: string 189 | primaryKey?: string 190 | createdAt: Date 191 | updatedAt: Date 192 | } 193 | 194 | export type IndexesQuery = ResourceQuery & object 195 | 196 | export type IndexesResults = ResourceResults & object 197 | 198 | /* 199 | * SEARCH PARAMETERS 200 | */ 201 | 202 | export const MatchingStrategies = { 203 | ALL: 'all', 204 | LAST: 'last', 205 | } 206 | 207 | export type MatchingStrategies = typeof MatchingStrategies[keyof typeof MatchingStrategies] 208 | 209 | export type Filter = string | Array 210 | 211 | export type Query = { 212 | q?: string | null 213 | } 214 | 215 | export type Highlight = { 216 | attributesToHighlight?: string[] 217 | highlightPreTag?: string 218 | highlightPostTag?: string 219 | } 220 | 221 | export type Crop = { 222 | attributesToCrop?: string[] 223 | cropLength?: number 224 | cropMarker?: string 225 | } 226 | 227 | // `facetName` becomes mandatory when using `searchForFacetValues` 228 | export type SearchForFacetValuesParams = Omit & { 229 | facetName: string 230 | } 231 | 232 | export type FacetHit = { 233 | value: string 234 | count: number 235 | } 236 | 237 | export type SearchForFacetValuesResponse = { 238 | facetHits: FacetHit[] 239 | facetQuery: string | null 240 | processingTimeMs: number 241 | } 242 | 243 | export type SearchParams = Query & 244 | Pagination & 245 | Highlight & 246 | Crop & { 247 | filter?: Filter 248 | sort?: string[] 249 | facets?: string[] 250 | attributesToRetrieve?: string[] 251 | showMatchesPosition?: boolean 252 | matchingStrategy?: MatchingStrategies 253 | hitsPerPage?: number 254 | page?: number 255 | facetName?: string 256 | facetQuery?: string 257 | vector?: number[] | null 258 | showRankingScore?: boolean 259 | showRankingScoreDetails?: boolean 260 | attributesToSearchOn?: string[] | null 261 | } 262 | 263 | // Search parameters for searches made with the GET method 264 | // Are different than the parameters for the POST method 265 | export type SearchRequestGET = Pagination & 266 | Query & 267 | Omit & 268 | Omit & { 269 | filter?: string 270 | sort?: string 271 | facets?: string 272 | attributesToRetrieve?: string 273 | attributesToHighlight?: string 274 | attributesToCrop?: string 275 | showMatchesPosition?: boolean 276 | vector?: string | null 277 | attributesToSearchOn?: string | null 278 | } 279 | 280 | export type MultiSearchQuery = SearchParams & { indexUid: string } 281 | 282 | export type MultiSearchParams = { 283 | queries: MultiSearchQuery[] 284 | } 285 | 286 | export type CategoriesDistribution = { 287 | [category: string]: number 288 | } 289 | 290 | export type Facet = string 291 | export type FacetDistribution = Record 292 | export type MatchesPosition = Partial< 293 | Record> 294 | > 295 | 296 | export type Hit> = T & { 297 | _formatted?: Partial 298 | _matchesPosition?: MatchesPosition 299 | _rankingScore?: number 300 | _rankingScoreDetails?: RankingScoreDetails 301 | } 302 | 303 | export type RankingScoreDetails = { 304 | words?: { 305 | order: number 306 | matchingWords: number 307 | maxMatchingWords: number 308 | score: number 309 | } 310 | typo?: { 311 | order: number 312 | typoCount: number 313 | maxTypoCount: number 314 | score: number 315 | } 316 | proximity?: { 317 | order: number 318 | score: number 319 | } 320 | attribute?: { 321 | order: number 322 | attributes_ranking_order: number 323 | attributes_query_word_order: number 324 | score: number 325 | } 326 | exactness?: { 327 | order: number 328 | matchType: string 329 | score: number 330 | } 331 | [key: string]: Record | undefined 332 | } 333 | 334 | export type Hits> = Array> 335 | 336 | export type FacetStat = { min: number, max: number } 337 | export type FacetStats = Record 338 | 339 | export type SearchResponse< 340 | T = Record, 341 | S extends SearchParams | undefined = undefined, 342 | > = { 343 | hits: Hits 344 | processingTimeMs: number 345 | query: string 346 | facetDistribution?: FacetDistribution 347 | facetStats?: FacetStats 348 | vector?: number[] 349 | } & (undefined extends S 350 | ? Partial 351 | : true extends IsFinitePagination> 352 | ? FinitePagination 353 | : InfinitePagination) 354 | 355 | type FinitePagination = { 356 | totalHits: number 357 | hitsPerPage: number 358 | page: number 359 | totalPages: number 360 | } 361 | type InfinitePagination = { 362 | offset: number 363 | limit: number 364 | estimatedTotalHits: number 365 | } 366 | 367 | type IsFinitePagination = Or< 368 | HasHitsPerPage, 369 | HasPage 370 | > 371 | 372 | type Or = true extends A 373 | ? true 374 | : true extends B 375 | ? true 376 | : false 377 | 378 | type HasHitsPerPage = undefined extends S['hitsPerPage'] 379 | ? false 380 | : true 381 | 382 | type HasPage = undefined extends S['page'] 383 | ? false 384 | : true 385 | 386 | export type MultiSearchResult = SearchResponse & { indexUid: string } 387 | 388 | export type MultiSearchResponse> = { 389 | results: Array> 390 | } 391 | 392 | export type FieldDistribution = { 393 | [field: string]: number 394 | } 395 | 396 | /* 397 | ** Documents 398 | */ 399 | 400 | type Fields> = 401 | | Array> 402 | | Extract 403 | 404 | export type DocumentOptions = { 405 | primaryKey?: string 406 | } 407 | 408 | export const ContentTypeEnum: Readonly> = { 409 | JSON: 'application/json', 410 | CSV: 'text/csv', 411 | NDJSON: 'application/x-ndjson', 412 | } 413 | 414 | export type ContentType = 415 | | 'text/csv' 416 | | 'application/x-ndjson' 417 | | 'application/json' 418 | 419 | export type RawDocumentAdditionOptions = DocumentOptions & { 420 | csvDelimiter?: string 421 | } 422 | 423 | export type DocumentsQuery> = ResourceQuery & { 424 | fields?: Fields 425 | filter?: Filter 426 | } 427 | 428 | export type DocumentQuery> = { 429 | fields?: Fields 430 | } 431 | 432 | export type DocumentsDeletionQuery = { 433 | filter: Filter 434 | } 435 | 436 | export type DocumentsIds = string[] | number[] 437 | 438 | /* 439 | ** Settings 440 | */ 441 | 442 | export type FilterableAttributes = string[] | null 443 | export type DistinctAttribute = string | null 444 | export type SearchableAttributes = string[] | null 445 | export type SortableAttributes = string[] | null 446 | export type DisplayedAttributes = string[] | null 447 | export type RankingRules = string[] | null 448 | export type StopWords = string[] | null 449 | export type Synonyms = { 450 | [field: string]: string[] 451 | } | null 452 | export type TypoTolerance = { 453 | enabled?: boolean | null 454 | disableOnAttributes?: string[] | null 455 | disableOnWords?: string[] | null 456 | minWordSizeForTypos?: { 457 | oneTypo?: number | null 458 | twoTypos?: number | null 459 | } 460 | } | null 461 | export type SeparatorTokens = string[] | null 462 | export type NonSeparatorTokens = string[] | null 463 | export type Dictionary = string[] | null 464 | 465 | export type FacetOrder = 'alpha' | 'count' 466 | 467 | export type Faceting = { 468 | maxValuesPerFacet?: number | null 469 | sortFacetValuesBy?: Record | null 470 | } 471 | 472 | export type PaginationSettings = { 473 | maxTotalHits?: number | null 474 | } 475 | 476 | export type Settings = { 477 | filterableAttributes?: FilterableAttributes 478 | distinctAttribute?: DistinctAttribute 479 | sortableAttributes?: SortableAttributes 480 | searchableAttributes?: SearchableAttributes 481 | displayedAttributes?: DisplayedAttributes 482 | rankingRules?: RankingRules 483 | stopWords?: StopWords 484 | synonyms?: Synonyms 485 | typoTolerance?: TypoTolerance 486 | faceting?: Faceting 487 | pagination?: PaginationSettings 488 | separatorTokens?: SeparatorTokens 489 | nonSeparatorTokens?: NonSeparatorTokens 490 | dictionary?: Dictionary 491 | } 492 | 493 | /* 494 | ** TASKS 495 | */ 496 | 497 | export const enum TaskStatus { 498 | TASK_SUCCEEDED = 'succeeded', 499 | TASK_PROCESSING = 'processing', 500 | TASK_FAILED = 'failed', 501 | TASK_ENQUEUED = 'enqueued', 502 | TASK_CANCELED = 'canceled', 503 | } 504 | 505 | export const enum TaskTypes { 506 | DOCUMENTS_ADDITION_OR_UPDATE = 'documentAdditionOrUpdate', 507 | DOCUMENT_DELETION = 'documentDeletion', 508 | DUMP_CREATION = 'dumpCreation', 509 | INDEX_CREATION = 'indexCreation', 510 | INDEX_DELETION = 'indexDeletion', 511 | INDEXES_SWAP = 'indexSwap', 512 | INDEX_UPDATE = 'indexUpdate', 513 | SETTINGS_UPDATE = 'settingsUpdate', 514 | SNAPSHOT_CREATION = 'snapshotCreation', 515 | TASK_CANCELATION = 'taskCancelation', 516 | TASK_DELETION = 'taskDeletion', 517 | } 518 | 519 | export type TasksQuery = { 520 | indexUids?: string[] 521 | uids?: number[] 522 | types?: TaskTypes[] 523 | statuses?: TaskStatus[] 524 | canceledBy?: number[] 525 | beforeEnqueuedAt?: Date 526 | afterEnqueuedAt?: Date 527 | beforeStartedAt?: Date 528 | afterStartedAt?: Date 529 | beforeFinishedAt?: Date 530 | afterFinishedAt?: Date 531 | limit?: number 532 | from?: number 533 | } 534 | export type CancelTasksQuery = Omit & object 535 | export type DeleteTasksQuery = Omit & object 536 | 537 | export type EnqueuedTaskObject = { 538 | taskUid: number 539 | indexUid?: string 540 | status: TaskStatus 541 | type: TaskTypes 542 | enqueuedAt: string 543 | canceledBy: number 544 | } 545 | 546 | export type TaskObject = Omit & { 547 | uid: number 548 | details: { 549 | // Number of documents sent 550 | receivedDocuments?: number 551 | 552 | // Number of documents successfully indexed/updated in Meilisearch 553 | indexedDocuments?: number 554 | 555 | // Number of deleted documents 556 | deletedDocuments?: number 557 | 558 | // Number of documents found on a batch-delete 559 | providedIds?: number 560 | 561 | // Primary key on index creation 562 | primaryKey?: string 563 | 564 | // Ranking rules on settings actions 565 | rankingRules?: RankingRules 566 | 567 | // Searchable attributes on settings actions 568 | searchableAttributes?: SearchableAttributes 569 | 570 | // Displayed attributes on settings actions 571 | displayedAttributes?: DisplayedAttributes 572 | 573 | // Filterable attributes on settings actions 574 | filterableAttributes?: FilterableAttributes 575 | 576 | // Sortable attributes on settings actions 577 | sortableAttributes?: SortableAttributes 578 | 579 | // Stop words on settings actions 580 | stopWords?: StopWords 581 | 582 | // Stop words on settings actions 583 | synonyms?: Synonyms 584 | 585 | // Distinct attribute on settings actions 586 | distinctAttribute?: DistinctAttribute 587 | 588 | // Object containing the payload originating the `indexSwap` task creation 589 | swaps?: SwapIndexesParams 590 | 591 | // Number of tasks that matched the originalQuery filter 592 | matchedTasks?: number 593 | 594 | // Number of tasks that were canceled 595 | canceledTasks?: number 596 | 597 | // Number of tasks that were deleted 598 | deletedTasks?: number 599 | 600 | // Query parameters used to filter the tasks 601 | originalFilter?: string 602 | } 603 | error: MeiliSearchErrorInfo | null 604 | duration: string 605 | startedAt: string 606 | finishedAt: string 607 | } 608 | 609 | export type SwapIndexesParams = Array<{ 610 | indexes: string[] 611 | }> 612 | 613 | type CursorResults = { 614 | results: T[] 615 | limit: number 616 | from: number 617 | next: number 618 | total: number 619 | } 620 | 621 | export type TasksResults = CursorResults 622 | export type TasksResultsObject = CursorResults 623 | 624 | export type WaitOptions = { 625 | timeOutMs?: number 626 | intervalMs?: number 627 | } 628 | 629 | /* 630 | *** HEALTH 631 | */ 632 | 633 | export type Health = { 634 | status: 'available' 635 | } 636 | 637 | /* 638 | *** STATS 639 | */ 640 | 641 | export type IndexStats = { 642 | numberOfDocuments: number 643 | isIndexing: boolean 644 | fieldDistribution: FieldDistribution 645 | } 646 | 647 | export type Stats = { 648 | databaseSize: number 649 | lastUpdate: string 650 | indexes: { 651 | [index: string]: IndexStats 652 | } 653 | } 654 | 655 | /* 656 | ** Keys 657 | */ 658 | 659 | export type Key = { 660 | uid: string 661 | description: string 662 | name: string | null 663 | key: string 664 | actions: string[] 665 | indexes: string[] 666 | expiresAt: Date 667 | createdAt: Date 668 | updatedAt: Date 669 | } 670 | 671 | export type KeyCreation = { 672 | uid?: string 673 | name?: string 674 | description?: string 675 | actions: string[] 676 | indexes: string[] 677 | expiresAt: Date | null 678 | } 679 | 680 | export type KeyUpdate = { 681 | name?: string 682 | description?: string 683 | } 684 | 685 | export type KeysQuery = ResourceQuery & object 686 | 687 | export type KeysResults = ResourceResults & object 688 | 689 | /* 690 | ** version 691 | */ 692 | export type Version = { 693 | commitSha: string 694 | commitDate: string 695 | pkgVersion: string 696 | } 697 | 698 | /* 699 | ** ERROR HANDLER 700 | */ 701 | 702 | export interface FetchError extends Error { 703 | type: string 704 | errno: string 705 | code: string 706 | } 707 | 708 | export type MeiliSearchErrorInfo = { 709 | code: string 710 | link: string 711 | message: string 712 | type: string 713 | } 714 | 715 | export const enum ErrorStatusCode { 716 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_creation_failed */ 717 | INDEX_CREATION_FAILED = 'index_creation_failed', 718 | 719 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_index_uid */ 720 | MISSING_INDEX_UID = 'missing_index_uid', 721 | 722 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_already_exists */ 723 | INDEX_ALREADY_EXISTS = 'index_already_exists', 724 | 725 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_not_found */ 726 | INDEX_NOT_FOUND = 'index_not_found', 727 | 728 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_index_uid */ 729 | INVALID_INDEX_UID = 'invalid_index_uid', 730 | 731 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_not_accessible */ 732 | INDEX_NOT_ACCESSIBLE = 'index_not_accessible', 733 | 734 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_index_offset */ 735 | INVALID_INDEX_OFFSET = 'invalid_index_offset', 736 | 737 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_index_limit */ 738 | INVALID_INDEX_LIMIT = 'invalid_index_limit', 739 | 740 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_state */ 741 | INVALID_STATE = 'invalid_state', 742 | 743 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#primary_key_inference_failed */ 744 | PRIMARY_KEY_INFERENCE_FAILED = 'primary_key_inference_failed', 745 | 746 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#index_primary_key_already_exists */ 747 | INDEX_PRIMARY_KEY_ALREADY_EXISTS = 'index_primary_key_already_exists', 748 | 749 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_index_primary_key */ 750 | INVALID_INDEX_PRIMARY_KEY = 'invalid_index_primary_key', 751 | 752 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#max_fields_limit_exceeded */ 753 | DOCUMENTS_FIELDS_LIMIT_REACHED = 'document_fields_limit_reached', 754 | 755 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_document_id */ 756 | MISSING_DOCUMENT_ID = 'missing_document_id', 757 | 758 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_document_id */ 759 | INVALID_DOCUMENT_ID = 'invalid_document_id', 760 | 761 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_content_type */ 762 | INVALID_CONTENT_TYPE = 'invalid_content_type', 763 | 764 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_content_type */ 765 | MISSING_CONTENT_TYPE = 'missing_content_type', 766 | 767 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_fields */ 768 | INVALID_DOCUMENT_FIELDS = 'invalid_document_fields', 769 | 770 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_limit */ 771 | INVALID_DOCUMENT_LIMIT = 'invalid_document_limit', 772 | 773 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_offset */ 774 | INVALID_DOCUMENT_OFFSET = 'invalid_document_offset', 775 | 776 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_filter */ 777 | INVALID_DOCUMENT_FILTER = 'invalid_document_filter', 778 | 779 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_document_filter */ 780 | MISSING_DOCUMENT_FILTER = 'missing_document_filter', 781 | 782 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_vectors_field */ 783 | INVALID_DOCUMENT_VECTORS_FIELD = 'invalid_document_vectors_field', 784 | 785 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#payload_too_large */ 786 | PAYLOAD_TOO_LARGE = 'payload_too_large', 787 | 788 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_payload */ 789 | MISSING_PAYLOAD = 'missing_payload', 790 | 791 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#malformed_payload */ 792 | MALFORMED_PAYLOAD = 'malformed_payload', 793 | 794 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#no_space_left_on_device */ 795 | NO_SPACE_LEFT_ON_DEVICE = 'no_space_left_on_device', 796 | 797 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_store_file */ 798 | INVALID_STORE_FILE = 'invalid_store_file', 799 | 800 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_ranking_rules */ 801 | INVALID_RANKING_RULES = 'missing_document_id', 802 | 803 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_request */ 804 | INVALID_REQUEST = 'invalid_request', 805 | 806 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_geo_field */ 807 | INVALID_DOCUMENT_GEO_FIELD = 'invalid_document_geo_field', 808 | 809 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_q */ 810 | INVALID_SEARCH_Q = 'invalid_search_q', 811 | 812 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_offset */ 813 | INVALID_SEARCH_OFFSET = 'invalid_search_offset', 814 | 815 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_limit */ 816 | INVALID_SEARCH_LIMIT = 'invalid_search_limit', 817 | 818 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_page */ 819 | INVALID_SEARCH_PAGE = 'invalid_search_page', 820 | 821 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_hits_per_page */ 822 | INVALID_SEARCH_HITS_PER_PAGE = 'invalid_search_hits_per_page', 823 | 824 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_retrieve */ 825 | INVALID_SEARCH_ATTRIBUTES_TO_RETRIEVE = 'invalid_search_attributes_to_retrieve', 826 | 827 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_crop */ 828 | INVALID_SEARCH_ATTRIBUTES_TO_CROP = 'invalid_search_attributes_to_crop', 829 | 830 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_crop_length */ 831 | INVALID_SEARCH_CROP_LENGTH = 'invalid_search_crop_length', 832 | 833 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_highlight */ 834 | INVALID_SEARCH_ATTRIBUTES_TO_HIGHLIGHT = 'invalid_search_attributes_to_highlight', 835 | 836 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_show_matches_position */ 837 | INVALID_SEARCH_SHOW_MATCHES_POSITION = 'invalid_search_show_matches_position', 838 | 839 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_filter */ 840 | INVALID_SEARCH_FILTER = 'invalid_search_filter', 841 | 842 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_sort */ 843 | INVALID_SEARCH_SORT = 'invalid_search_sort', 844 | 845 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_facets */ 846 | INVALID_SEARCH_FACETS = 'invalid_search_facets', 847 | 848 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_highlight_pre_tag */ 849 | INVALID_SEARCH_HIGHLIGHT_PRE_TAG = 'invalid_search_highlight_pre_tag', 850 | 851 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_highlight_post_tag */ 852 | INVALID_SEARCH_HIGHLIGHT_POST_TAG = 'invalid_search_highlight_post_tag', 853 | 854 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_crop_marker */ 855 | INVALID_SEARCH_CROP_MARKER = 'invalid_search_crop_marker', 856 | 857 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_matching_strategy */ 858 | INVALID_SEARCH_MATCHING_STRATEGY = 'invalid_search_matching_strategy', 859 | 860 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_vector */ 861 | INVALID_SEARCH_VECTOR = 'invalid_search_vector', 862 | 863 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_search_on */ 864 | INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON = 'invalid_search_attributes_to_search_on', 865 | 866 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#bad_request */ 867 | BAD_REQUEST = 'bad_request', 868 | 869 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#document_not_found */ 870 | DOCUMENT_NOT_FOUND = 'document_not_found', 871 | 872 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#internal */ 873 | INTERNAL = 'internal', 874 | 875 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key */ 876 | INVALID_API_KEY = 'invalid_api_key', 877 | 878 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_description */ 879 | INVALID_API_KEY_DESCRIPTION = 'invalid_api_key_description', 880 | 881 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_actions */ 882 | INVALID_API_KEY_ACTIONS = 'invalid_api_key_actions', 883 | 884 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_indexes */ 885 | INVALID_API_KEY_INDEXES = 'invalid_api_key_indexes', 886 | 887 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_expires_at */ 888 | INVALID_API_KEY_EXPIRES_AT = 'invalid_api_key_expires_at', 889 | 890 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#api_key_not_found */ 891 | API_KEY_NOT_FOUND = 'api_key_not_found', 892 | 893 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_uid */ 894 | IMMUTABLE_API_KEY_UID = 'immutable_api_key_uid', 895 | 896 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_actions */ 897 | IMMUTABLE_API_KEY_ACTIONS = 'immutable_api_key_actions', 898 | 899 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_indexes */ 900 | IMMUTABLE_API_KEY_INDEXES = 'immutable_api_key_indexes', 901 | 902 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_expires_at */ 903 | IMMUTABLE_API_KEY_EXPIRES_AT = 'immutable_api_key_expires_at', 904 | 905 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_created_at */ 906 | IMMUTABLE_API_KEY_CREATED_AT = 'immutable_api_key_created_at', 907 | 908 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_api_key_updated_at */ 909 | IMMUTABLE_API_KEY_UPDATED_AT = 'immutable_api_key_updated_at', 910 | 911 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_authorization_header */ 912 | MISSING_AUTHORIZATION_HEADER = 'missing_authorization_header', 913 | 914 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#unretrievable_document */ 915 | UNRETRIEVABLE_DOCUMENT = 'unretrievable_document', 916 | 917 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#database_size_limit_reached */ 918 | MAX_DATABASE_SIZE_LIMIT_REACHED = 'database_size_limit_reached', 919 | 920 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#task_not_found */ 921 | TASK_NOT_FOUND = 'task_not_found', 922 | 923 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#dump_process_failed */ 924 | DUMP_PROCESS_FAILED = 'dump_process_failed', 925 | 926 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#dump_not_found */ 927 | DUMP_NOT_FOUND = 'dump_not_found', 928 | 929 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_swap_duplicate_index_found */ 930 | INVALID_SWAP_DUPLICATE_INDEX_FOUND = 'invalid_swap_duplicate_index_found', 931 | 932 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_swap_indexes */ 933 | INVALID_SWAP_INDEXES = 'invalid_swap_indexes', 934 | 935 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_swap_indexes */ 936 | MISSING_SWAP_INDEXES = 'missing_swap_indexes', 937 | 938 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_master_key */ 939 | MISSING_MASTER_KEY = 'missing_master_key', 940 | 941 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_types */ 942 | INVALID_TASK_TYPES = 'invalid_task_types', 943 | 944 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_uids */ 945 | INVALID_TASK_UIDS = 'invalid_task_uids', 946 | 947 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_statuses */ 948 | INVALID_TASK_STATUSES = 'invalid_task_statuses', 949 | 950 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_limit */ 951 | INVALID_TASK_LIMIT = 'invalid_task_limit', 952 | 953 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_from */ 954 | INVALID_TASK_FROM = 'invalid_task_from', 955 | 956 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_canceled_by */ 957 | INVALID_TASK_CANCELED_BY = 'invalid_task_canceled_by', 958 | 959 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_task_filters */ 960 | MISSING_TASK_FILTERS = 'missing_task_filters', 961 | 962 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#too_many_open_files */ 963 | TOO_MANY_OPEN_FILES = 'too_many_open_files', 964 | 965 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#io_error */ 966 | IO_ERROR = 'io_error', 967 | 968 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_index_uids */ 969 | INVALID_TASK_INDEX_UIDS = 'invalid_task_index_uids', 970 | 971 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_index_uid */ 972 | IMMUTABLE_INDEX_UID = 'immutable_index_uid', 973 | 974 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_index_created_at */ 975 | IMMUTABLE_INDEX_CREATED_AT = 'immutable_index_created_at', 976 | 977 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#immutable_index_updated_at */ 978 | IMMUTABLE_INDEX_UPDATED_AT = 'immutable_index_updated_at', 979 | 980 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_displayed_attributes */ 981 | INVALID_SETTINGS_DISPLAYED_ATTRIBUTES = 'invalid_settings_displayed_attributes', 982 | 983 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_searchable_attributes */ 984 | INVALID_SETTINGS_SEARCHABLE_ATTRIBUTES = 'invalid_settings_searchable_attributes', 985 | 986 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_filterable_attributes */ 987 | INVALID_SETTINGS_FILTERABLE_ATTRIBUTES = 'invalid_settings_filterable_attributes', 988 | 989 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_sortable_attributes */ 990 | INVALID_SETTINGS_SORTABLE_ATTRIBUTES = 'invalid_settings_sortable_attributes', 991 | 992 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_ranking_rules */ 993 | INVALID_SETTINGS_RANKING_RULES = 'invalid_settings_ranking_rules', 994 | 995 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_stop_words */ 996 | INVALID_SETTINGS_STOP_WORDS = 'invalid_settings_stop_words', 997 | 998 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_synonyms */ 999 | INVALID_SETTINGS_SYNONYMS = 'invalid_settings_synonyms', 1000 | 1001 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_distinct_attribute */ 1002 | INVALID_SETTINGS_DISTINCT_ATTRIBUTE = 'invalid_settings_distinct_attribute', 1003 | 1004 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_typo_tolerance */ 1005 | INVALID_SETTINGS_TYPO_TOLERANCE = 'invalid_settings_typo_tolerance', 1006 | 1007 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_faceting */ 1008 | INVALID_SETTINGS_FACETING = 'invalid_settings_faceting', 1009 | 1010 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_settings_pagination */ 1011 | INVALID_SETTINGS_PAGINATION = 'invalid_settings_pagination', 1012 | 1013 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_before_enqueued_at */ 1014 | INVALID_TASK_BEFORE_ENQUEUED_AT = 'invalid_task_before_enqueued_at', 1015 | 1016 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_after_enqueued_at */ 1017 | INVALID_TASK_AFTER_ENQUEUED_AT = 'invalid_task_after_enqueued_at', 1018 | 1019 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_before_started_at */ 1020 | INVALID_TASK_BEFORE_STARTED_AT = 'invalid_task_before_started_at', 1021 | 1022 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_after_started_at */ 1023 | INVALID_TASK_AFTER_STARTED_AT = 'invalid_task_after_started_at', 1024 | 1025 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_before_finished_at */ 1026 | INVALID_TASK_BEFORE_FINISHED_AT = 'invalid_task_before_finished_at', 1027 | 1028 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_task_after_finished_at */ 1029 | INVALID_TASK_AFTER_FINISHED_AT = 'invalid_task_after_finished_at', 1030 | 1031 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_api_key_actions */ 1032 | MISSING_API_KEY_ACTIONS = 'missing_api_key_actions', 1033 | 1034 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_api_key_indexes */ 1035 | MISSING_API_KEY_INDEXES = 'missing_api_key_indexes', 1036 | 1037 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_api_key_expires_at */ 1038 | MISSING_API_KEY_EXPIRES_AT = 'missing_api_key_expires_at', 1039 | 1040 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_limit */ 1041 | INVALID_API_KEY_LIMIT = 'invalid_api_key_limit', 1042 | 1043 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_offset */ 1044 | INVALID_API_KEY_OFFSET = 'invalid_api_key_offset', 1045 | 1046 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_facet_name */ 1047 | INVALID_FACET_SEARCH_FACET_NAME = 'invalid_facet_search_facet_name', 1048 | 1049 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_facet_search_facet_name */ 1050 | MISSING_FACET_SEARCH_FACET_NAME = 'missing_facet_search_facet_name', 1051 | 1052 | /** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_facet_query */ 1053 | INVALID_FACET_SEARCH_FACET_QUERY = 'invalid_facet_search_facet_query', 1054 | } 1055 | 1056 | export type TokenIndexRules = { 1057 | [field: string]: any 1058 | filter?: Filter 1059 | } 1060 | export type TokenSearchRules = Record | string[] 1061 | 1062 | export type TokenOptions = { 1063 | apiKey?: string 1064 | expiresAt?: Date 1065 | } 1066 | -------------------------------------------------------------------------------- /src/runtime/types/nuxtMeilisearch.d.ts: -------------------------------------------------------------------------------- 1 | enum InstantSearchThemes { 2 | reset, 3 | algolia, 4 | satellite, 5 | } 6 | 7 | export interface ModuleOptions { 8 | hostUrl: string 9 | searchApiKey: string 10 | adminApiKey?: string 11 | serverSideUsage?: boolean 12 | instantSearch?: boolean | { theme: keyof typeof InstantSearchThemes } 13 | // meilisearchConfig?: { 14 | // placeholderSearch?: boolean, 15 | // paginationTotalHits?: number, 16 | // finitePagination?: boolean, 17 | // primaryKey?: string, 18 | // keepZeroFacets?: boolean 19 | // } 20 | } 21 | 22 | // https://github.com/meilisearch/instant-meilisearch/blob/main/packages/instant-meilisearch/src/types/types.ts 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.nuxt/tsconfig.json", 3 | "compilerOptions": { 4 | "moduleResolution": "node", 5 | "esModuleInterop": true 6 | } 7 | } 8 | --------------------------------------------------------------------------------