meilisearch
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -1,31 +0,15 @@ | ||
# Change Log | ||
## V0.10 (released) | ||
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. | ||
<a name="0.0.9"></a> | ||
## [0.0.9](https://github.com/qdequele/meili-api/compare/v0.0.8...v0.0.9) (2019-10-09) | ||
<a name="0.0.8"></a> | ||
## [0.0.8](https://github.com/qdequele/meili-api/compare/v0.0.7...v0.0.8) (2019-10-09) | ||
<a name="0.0.7"></a> | ||
## [0.0.7](https://github.com/qdequele/meili-api/compare/v0.0.6...v0.0.7) (2019-10-09) | ||
<a name="0.0.6"></a> | ||
## [0.0.6](https://github.com/qdequele/meili-api/compare/v0.0.5...v0.0.6) (2019-10-08) | ||
<a name="0.0.5"></a> | ||
## [0.0.5](https://github.com/qdequele/meili-api/compare/v0.0.4...v0.0.5) (2019-10-08) | ||
<a name="0.0.4"></a> | ||
## [0.0.4](https://github.com/qdequele/meili-api/compare/v0.0.3...v0.0.4) (2019-10-08) | ||
<a name="0.0.3"></a> | ||
## 0.0.3 (2019-10-08) | ||
- Build is done 100% with rollup, tsc has been removed #318. Rollup has been updated #283 | ||
- Moved tests to own folder at root #283 | ||
- Error handled created with two new custom errors: `MeiliSearchApiError` `MeiliSearchTimeoutError` #283 & #311 & #318 | ||
- Removed linting with TSLINT and replaced with eslint #283 | ||
- Improved tests #299 #301 #302 | ||
- Created WaitForPendingUpdate function #311 | ||
- Made module compatible with MeiliSearch v0.10 #312 | ||
- Changed prototypes in README #314 | ||
- `Class Indexes` has been renamed to `Class Index` #315 | ||
- createIndex now returns an instance of the Index class #315 (BREAKING) | ||
- Main file renamed from index.ts to meilisearch.ts #315 | ||
- Replaced all sleeps in test with waitForPendingUpdate #316 | ||
- Improved types and exportation of types #318 #283 |
{ | ||
"name": "meilisearch", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "The MeiliSearch JS client for Node.js and the browser.", | ||
@@ -14,6 +14,13 @@ "keywords": [ | ||
], | ||
"main": "./bundles/index.umd.js", | ||
"module": "./esm5/index.js", | ||
"es2015": "./esm2015/index.js", | ||
"typings": "./types/index.d.ts", | ||
"author": "cvermand <charlotte@meilisearch.com>", | ||
"contributors": [ | ||
"qdequele <quentin@meilisearch.com>" | ||
], | ||
"license": "MIT", | ||
"main": "./dist/bundles/meilisearch.cjs.js", | ||
"module": "./dist/bundles/meilisearch.esm.js", | ||
"browser": "./dist/bundles/meilisearch.umd.js", | ||
"typings": "./dist/types/types.d.ts", | ||
"types": "./dist/types/types.d.ts", | ||
"jsnext:main": "./dist/bundles/meilisearch.esm.js", | ||
"sideEffects": false, | ||
@@ -24,15 +31,63 @@ "repository": { | ||
}, | ||
"author": "qdequele <quentin@meilisearch.com>", | ||
"license": "MIT", | ||
"resolutions": { | ||
"rollup-plugin-node-builtins/browserify-fs/levelup/semver": "^6.0.0", | ||
"rollup-plugin-node-builtins/browserify-fs/levelup/bl": "^4.0.0" | ||
"scripts": { | ||
"cleanup": "shx rm -rf dist/", | ||
"build": "yarn cleanup && rollup -c && rollup -c --environment NODE_ENV:production", | ||
"postbuild": "yarn size && yarn typingsheader", | ||
"test": "jest --runInBand", | ||
"test:watch": "yarn test --watch", | ||
"test:coverage": "yarn test --coverage", | ||
"test:ci": "yarn test --ci", | ||
"size": "node scripts/file-size ./dist/bundles/meilisearch.umd.min.js ./dist/bundles/meilisearch.esm.min.js", | ||
"style": "yarn format:fix && yarn lint", | ||
"style:fix": "yarn format:fix && yarn lint:fix", | ||
"prettier": "prettier \"**/*.{ts,tsx,js,jsx,css,scss,sass,less,md}\"", | ||
"format": "yarn prettier --debug-check", | ||
"format:fix": "yarn prettier --write", | ||
"lint": "eslint '{src,types}/**/*.{ts,js}'", | ||
"lint:fix": "yarn lint --fix", | ||
"typingsheader": "node scripts/build.js" | ||
}, | ||
"peerDependencies": { | ||
"tslib": ">=1.10.0" | ||
"lint-staged": { | ||
"**/*.{ts,tsx,js,jsx,css,scss,sass,less,md}": [ | ||
"prettier --write", | ||
"git add" | ||
], | ||
"src/**/*.{ts,tsx}": [ | ||
"yarn lint:fix", | ||
"git add" | ||
] | ||
}, | ||
"dependencies": { | ||
"axios": "0.19.2", | ||
"tslib": "1.11.1" | ||
"axios": "^0.19.2" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@types/jest": "^25.2.1", | ||
"@types/prettier": "^2.0.0", | ||
"@typescript-eslint/eslint-plugin": "2", | ||
"@typescript-eslint/parser": "^2.29.0", | ||
"brotli-size": "^4.0.0", | ||
"eslint": "6", | ||
"eslint-config-standard-with-typescript": "^16.0.0", | ||
"eslint-plugin-import": "2", | ||
"eslint-plugin-jsdoc": "^24.0.0", | ||
"eslint-plugin-node": "11", | ||
"eslint-plugin-promise": "4", | ||
"eslint-plugin-standard": "4", | ||
"gzip-size": "^5.1.1", | ||
"jest": "^25.2.4", | ||
"jest-watch-typeahead": "^0.4.2", | ||
"kleur": "^3.0.3", | ||
"lint-staged": "^10.1.0", | ||
"prettier": "^2.0.2", | ||
"pretty-bytes": "^5.3.0", | ||
"rollup": "^2.2.0", | ||
"rollup-plugin-terser": "^5.3.0", | ||
"rollup-plugin-typescript2": "^0.27.0", | ||
"shx": "^0.3.2", | ||
"ts-jest": "^25.3.0", | ||
"typescript": "^3.8.3" | ||
} | ||
} | ||
} |
236
README.md
@@ -1,14 +0,28 @@ | ||
# MeiliSearch Javascript Client | ||
<p align="center"> | ||
<img src="https://res.cloudinary.com/meilisearch/image/upload/v1587402338/SDKs/meilisearch_js.svg" alt="MeiliSearch-JavaScript" width="200" height="200" /> | ||
</p> | ||
[![NPM version](https://img.shields.io/npm/v/meilisearch.svg)](https://www.npmjs.com/package/meilisearch) | ||
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) | ||
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://img.shields.io/badge/licence-MIT-blue.svg) | ||
<h1 align="center">MeiliSearch JavaScript</h1> | ||
The Javascript client for MeiliSearch API. | ||
<h4 align="center"> | ||
<a href="https://github.com/meilisearch/MeiliSearch">MeiliSearch</a> | | ||
<a href="https://www.meilisearch.com">Website</a> | | ||
<a href="https://blog.meilisearch.com">Blog</a> | | ||
<a href="https://twitter.com/meilisearch">Twitter</a> | | ||
<a href="https://docs.meilisearch.com">Documentation</a> | | ||
<a href="https://docs.meilisearch.com/resources/faq.html">FAQ</a> | ||
</h4> | ||
MeiliSearch provides an ultra relevant and instant full-text search. Our solution is open-source and you can check out [our repository here](https://github.com/meilisearch/MeiliSearch). | ||
<p align="center"> | ||
<a href="https://www.npmjs.com/package/meilisearch"><img src="https://img.shields.io/npm/v/meilisearch.svg" alt="NPM version"></a> | ||
<a href="https://github.com/conventional-changelog/standard-version"><img src="https://img.shields.io/badge/release-standard%20version-brightgreen.svg" alt="Standard Version"></a> | ||
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="Prettier"></a> | ||
<a href="https://github.com/meilisearch/meilisearch-js/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a> | ||
<a href="https://slack.meilisearch.com"><img src="https://img.shields.io/badge/slack-MeiliSearch-blue.svg?logo=slack" alt="Slack"></a> | ||
</p> | ||
Here is the [MeiliSearch documentation](https://docs.meilisearch.com/) š | ||
<p align="center">ā” Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine MeiliSearch client written in JavaScript</p> | ||
**MeiliSearch JavaScript** is a client for **MeiliSearch** written in JavaScript. **MeiliSearch** is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box. | ||
## Table of Contents <!-- omit in toc --> | ||
@@ -42,3 +56,3 @@ | ||
```bash | ||
$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest --api-key=apiKey | ||
$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest --master-key=masterKey | ||
``` | ||
@@ -53,28 +67,30 @@ | ||
```js | ||
const MeiliSearch = require('meilisearch') // import MeiliSearch from 'meilisearch' | ||
const MeiliSearch = require('meilisearch') | ||
// Or if you are on a front-end environment: | ||
import MeiliSearch from 'meilisearch' | ||
;(async () => { | ||
const client = new MeiliSearch({ | ||
host: 'http://127.0.0.1:7700', | ||
apiKey: 'masterKey', | ||
}) | ||
// Credentials of your MeiliSearch Instance | ||
const config = { | ||
host: 'http://127.0.0.1:7700', | ||
apiKey: 'masterKey', | ||
} | ||
const index = await client.createIndex({ uid: 'books' }) // If your index does not exists | ||
// OR | ||
const index = client.getIndex('books') // If your index exists | ||
const meili = new MeiliSearch(config) | ||
const documents = [ | ||
{ book_id: 123, title: 'Pride and Prejudice' }, | ||
{ book_id: 456, title: 'Le Petit Prince' }, | ||
{ book_id: 1, title: 'Alice In Wonderland' }, | ||
{ book_id: 1344, title: 'The Hobbit' }, | ||
{ book_id: 4, title: 'Harry Potter and the Half-Blood Prince' }, | ||
{ book_id: 42, title: "The Hitchhiker's Guide to the Galaxy" }, | ||
] | ||
await meili.createIndex({ uid: 'books' }) // if your index does not exist | ||
const index = await meili.getIndex('books'); | ||
const documents = [ | ||
{ book_id: 123, title: 'Pride and Prejudice' }, | ||
{ book_id: 456, title: 'Le Petit Prince' }, | ||
{ book_id: 1, title: 'Alice In Wonderland' }, | ||
{ book_id: 1344, title: 'The Hobbit' }, | ||
{ book_id: 4, title: 'Harry Potter and the Half-Blood Prince' }, | ||
{ book_id: 42, title: "The Hitchhiker's Guide to the Galaxy" }, | ||
] | ||
await index.addOrReplaceDocuments(documents) // { "updateId": 0 } | ||
let response = await index.addDocuments(documents) | ||
console.log(response) // => { "updateId": 0 } | ||
})() | ||
``` | ||
With the `updateId`, you can check the status (`processed` of `failed`) of your documents addition thanks to this [method](#update-status). | ||
With the `updateId`, you can check the status (`processed` or `failed`) of your documents addition thanks to this [method](#update-status). | ||
@@ -85,3 +101,4 @@ #### Search in index | ||
// MeiliSearch is typo-tolerant: | ||
await index.search('harry pottre') | ||
const search = await index.search('harry pottre') | ||
console.log(search) | ||
``` | ||
@@ -113,2 +130,4 @@ | ||
In this section, the examples contain the [`await` keyword](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await). | ||
### Indexes | ||
@@ -120,5 +139,5 @@ | ||
// Create an index | ||
meili.createIndex({ uid: 'books' }) // if your index does not exist | ||
const index = await client.createIndex({ uid: 'books' }) | ||
// Create an index and give the primary-key | ||
meili.createIndex({ uid: 'books', primaryKey: 'book_id' }) // if your index does not exist | ||
const index = await client.createIndex({ uid: 'books', primaryKey: 'book_id' }) | ||
``` | ||
@@ -129,3 +148,3 @@ | ||
```javascript | ||
await meili.listIndexes() | ||
const indexes = await client.listIndexes() | ||
``` | ||
@@ -136,3 +155,3 @@ | ||
```javascript | ||
const index = await meili.getIndex('books') | ||
const index = await client.getIndex('books') | ||
``` | ||
@@ -146,6 +165,6 @@ | ||
// Get one document | ||
let myDocument = await index.getDocument(123) | ||
const document = await index.getDocument(123) | ||
// Get documents by batch | ||
let myDocuments = await index.getDocuments({ offset: 4, limit: 20 }) | ||
const documents = await index.getDocuments({ offset: 4, limit: 20 }) | ||
``` | ||
@@ -156,3 +175,3 @@ | ||
```javascript | ||
index.addOrReplaceDocuments([{ book_id: 2, title: 'Madame Bovary' }]) | ||
await index.addDocuments([{ book_id: 2, title: 'Madame Bovary' }]) | ||
``` | ||
@@ -174,7 +193,7 @@ | ||
// Delete one document | ||
index.deleteDocument(2) | ||
await index.deleteDocument(2) | ||
// Delete several documents | ||
index.deleteDocuments([1, 42]) | ||
await index.deleteDocuments([1, 42]) | ||
// Delete all documents /!\ | ||
index.deleteAllDocuments() | ||
await index.deleteAllDocuments() | ||
``` | ||
@@ -197,3 +216,3 @@ | ||
```javascript | ||
await index.search('prince') | ||
const search = await index.search('prince') | ||
``` | ||
@@ -298,5 +317,5 @@ | ||
This package works for MeiliSearch `v0.9.x`. | ||
This package works for MeiliSearch `>=0.10.x`. | ||
## š API Ressources | ||
## š API Resources | ||
@@ -307,3 +326,3 @@ ### Search | ||
`meili.getIndex('xxx').search(query: string, options?: Types.SearchParams): Promise<Types.SearchResponse>` | ||
`client.getIndex('xxx').search(query: string, options?: SearchParams): Promise<SearchResponse>` | ||
@@ -314,19 +333,19 @@ ### Indexes | ||
`meili.listIndexes(): Promise<object[]>` | ||
`client.listIndexes(): Promise<IndexResponse[]>` | ||
- Create new index: | ||
`meili.createIndex(data: Types.CreateIndexRequest): Promise<Types.CreateIndexResponse>` | ||
`client.createIndex(data: IndexRequest): Promise<Index>` | ||
- Get index object: | ||
`meili.getIndex(uid: string)` | ||
`client.getIndex(uid: string): Indexes` | ||
- Show Index information: | ||
`index.show(): Promise<Types.index>` | ||
`index.show(): Promise<IndexResponse>` | ||
- Update Index: | ||
`index.updateIndex(data: Types.UpdateIndexRequest): Promise<Types.index>` | ||
`index.updateIndex(data: UpdateIndexRequest): Promise<IndexResponse>` | ||
@@ -339,3 +358,3 @@ - Delete Index: | ||
`index.getStats(): Promise<object>` | ||
`index.getStats(): Promise<IndexStats>` | ||
@@ -346,8 +365,12 @@ ### Updates | ||
`index.getUpdateStatus(updateId: number): Promise<object>` | ||
`index.getUpdateStatus(updateId: number): Promise<Update>` | ||
- Get all updates info: | ||
`index.getAllUpdateStatus(): Promise<object[]>` | ||
`index.getAllUpdateStatus(): Promise<Update[]>` | ||
- Wait for pending update: | ||
`index.waitForPendingUpdate(updateId: number, { timeOutMs?: number, intervalMs?: number }): Promise<Update>` | ||
### Documents | ||
@@ -357,11 +380,11 @@ | ||
`index.addDocuments(documents: object[]): Promise<Types.AsyncUpdateId>` | ||
`index.addDocuments(documents: object[]): Promise<EnqueuedUpdate>` | ||
- Add or update multiple documents: | ||
`index.updateDocuments(documents: object[]): Promise<Types.AsyncUpdateId>` | ||
`index.updateDocuments(documents: object[]): Promise<EnqueuedUpdate>` | ||
- Get Documents: | ||
`index.getDocuments(params: Types.getDocumentsParams): Promise<object[]>` | ||
`index.getDocuments(params: getDocumentsParams): Promise<object[]>` | ||
@@ -374,7 +397,7 @@ - Get one document: | ||
`index.deleteDocument(documentId: string): Promise<Types.AsyncUpdateId>` | ||
`index.deleteDocument(documentId: string): Promise<EnqueuedUpdate>` | ||
- Delete multiple documents: | ||
`index.deleteDocuments(documentsIds: string[]): Promise<Types.AsyncUpdateId>` | ||
`index.deleteDocuments(documentsIds: string[]): Promise<EnqueuedUpdate>` | ||
@@ -385,40 +408,95 @@ ### Settings | ||
`index.getSettings(): Promise<object>` | ||
`index.getSettings(): Promise<Settings>` | ||
- Update settings: | ||
`index.updateSettings(settings: object): Promise<void>` | ||
`index.updateSettings(settings: Settings): Promise<EnqueuedUpdate>` | ||
- Reset settings: | ||
`index.resetSettings(): Promise<EnqueuedUpdate>` | ||
### Synonyms | ||
- List all synonyms: | ||
- Get synonyms: | ||
`index.listSynonyms(): Promise<object[]>` | ||
`index.getSynonyms(): Promise<object>` | ||
- Add a synonyms: | ||
- Update synonyms: | ||
`index.createSynonym(input: string, synonyms: string[]): Promise<object>` | ||
`index.updateSynonym(synonyms: object): Promise<EnqueuedUpdate>` | ||
#### Stop-words | ||
- Reset synonyms: | ||
Waiting on MeiliSearch v0.9.0 | ||
`index.resetSynonym(): Promise<EnqueuedUpdate>` | ||
### Healthy | ||
### Stop-words | ||
- Check if the server is healthy | ||
- Get Stop Words | ||
`index.getStopWords(): Promise<string[]>` | ||
`meili.isHealthy(): Promise<void>` | ||
- Update Stop Words | ||
`index.updateStopWords(string[]): Promise<EnqueuedUpdate>` | ||
- Set the server healthy | ||
- Reset Stop Words | ||
`index.updateStopWords(): Promise<EnqueuedUpdate>` | ||
`meili.setHealthy(): Promise<void>` | ||
### Ranking rules | ||
- Set the server unhealthy | ||
- Get Ranking Rules | ||
`index.getRankingRules(): Promise<string[]>` | ||
`meili.setUnhealthy(): Promise<void>` | ||
- Update Ranking Rules | ||
`index.updateRankingRules(rankingRules: string[]): Promise<EnqueuedUpdate>` | ||
- Change the server healthyness | ||
- Reset Ranking Rules | ||
`index.resetRankingRules(): Promise<EnqueuedUpdate>` | ||
`meili.changeHealthTo(health: boolean): Promise<void>` | ||
### Distinct Attribute | ||
- Get Distinct Attribute | ||
`index.getDistinctAttribute(): Promise<string | void>` | ||
- Update Distinct Attribute | ||
`index.updateDistinctAttribute(distinctAttribute: string): Promise<EnqueuedUpdate>` | ||
- Reset Distinct Attribute | ||
`index.resetDistinctAttribute(): Promise<EnqueuedUpdate>` | ||
### Searchable Attributes | ||
- Get Searchable Attributes | ||
`index.getSearchableAttributes(): Promise<string[]>` | ||
- Update Searchable Attributes | ||
`index.updateSearchableAttributes(searchableAttributes: string[]): Promise<EnqueuedUpdate>` | ||
- Reset Searchable Attributes | ||
`index.resetSearchableAttributes(): Promise<EnqueuedUpdate>` | ||
### Displayed Attributes | ||
- Get Displayed Attributes | ||
`index.getDisplayedAttributes(): Promise<string[]>` | ||
- Update Displayed Attributes | ||
`index.updateDisplayedAttributes(displayedAttributes: string[]): Promise<EnqueuedUpdate>` | ||
- Reset Displayed Attributes | ||
`index.resetDisplayedAttributes(): Promise<EnqueuedUpdate>` | ||
### Accept new fields | ||
- Get Accept new fields | ||
`index.getAcceptNewFields(): Promise<boolean>` | ||
- Update Accept new fields | ||
`index.updateAcceptNewFields(acceptNewFields: boolean): Promise<EnqueuedUpdate>` | ||
### Healthy | ||
- Check if the server is healthy | ||
`client.isHealthy(): Promise<void>` | ||
### Stats | ||
@@ -428,3 +506,3 @@ | ||
`meili.databaseStats(): Promise<object>` | ||
`client.stats(): Promise<Stats>` | ||
@@ -435,3 +513,3 @@ ### Version | ||
`meili.version(): Promise<object>` | ||
`client.version(): Promise<Version>` | ||
@@ -442,6 +520,6 @@ ### System | ||
`meili.systemInformation(): Promise<object>` | ||
`client.systemInformation(): Promise<SysInfo>` | ||
- Get system information (pretty mode) | ||
`meili.systemInformationPretty(): Promise<object>` | ||
`client.systemInformationPretty(): Promise<SysInfoPretty>` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 8 instances in 1 package
1
34
504
0
1
305596
28
1
5869
4
- Removedtslib@1.11.1
- Removedtslib@1.11.1(transitive)
Updatedaxios@^0.19.2