Socket
Socket
Sign inDemoInstall

meilisearch

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meilisearch - npm Package Compare versions

Comparing version 0.11.2 to 0.11.3

CONTRIBUTING.md

4

dist/types/index.d.ts

@@ -27,3 +27,3 @@ import MeiliAxiosWrapper from './meili-axios-wrapper';

*/
search(query: string, options?: Types.SearchParams): Promise<Types.SearchResponse<T>>;
search<P extends Types.SearchParams<T>>(query: string, options?: P): Promise<Types.SearchResponse<T, P>>;
/**

@@ -58,3 +58,3 @@ * Show index information.

*/
getDocuments(options?: Types.GetDocumentsParams): Promise<Array<Types.Document<T>>>;
getDocuments<P extends Types.GetDocumentsParams<T>>(options?: P): Promise<Types.GetDocumentsResponse<T, P>>;
/**

@@ -61,0 +61,0 @@ * Get one document

@@ -1,6 +0,6 @@

// Type definitions for meilisearch 0.11.2
// Type definitions for meilisearch 0.11.3
// Project: https://github.com/meilisearch/meilisearch-js
// Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch>
// Definitions: https://github.com/meilisearch/meilisearch-js
// TypeScript Version: 3.9.5
// TypeScript Version: 3.9.7

@@ -38,9 +38,9 @@ import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, CancelTokenSource } from 'axios';

export declare type FacetFilter = (string | string[])[];
export interface SearchParams {
export interface SearchParams<T> {
offset?: number;
limit?: number;
attributesToRetrieve?: string[] | string;
attributesToCrop?: string[] | string;
attributesToRetrieve?: Extract<keyof T, string>[] | Extract<keyof T, string>;
attributesToCrop?: (Extract<keyof T, string> | '*')[] | (Extract<keyof T, string> | '*');
cropLength?: number;
attributesToHighlight?: string[] | string;
attributesToHighlight?: (Extract<keyof T, string> | '*')[] | (Extract<keyof T, string> | '*');
filters?: string;

@@ -67,4 +67,4 @@ facetFilters?: string | FacetFilter | FacetFilter[];

};
export interface SearchResponse<T = any> {
hits: Array<Hit<T>>;
export interface SearchResponse<T, P extends SearchParams<T>> {
hits: P['attributesToRetrieve'] extends keyof T ? Array<Hit<Pick<T, Exclude<keyof T, Exclude<keyof T, P['attributesToRetrieve']>>>>> : P['attributesToRetrieve'] extends Array<infer K> ? Array<Hit<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>> : Array<Hit<T>>;
offset: number;

@@ -80,7 +80,8 @@ limit: number;

}
export interface GetDocumentsParams {
export interface GetDocumentsParams<T> {
offset?: number;
limit?: number;
attributesToRetrieve?: string[];
attributesToRetrieve?: Extract<keyof T, string>[] | Extract<keyof T, string>;
}
export declare type GetDocumentsResponse<T, P extends GetDocumentsParams<T>> = P['attributesToRetrieve'] extends keyof T ? Array<Document<Pick<T, Exclude<keyof T, Exclude<keyof T, P['attributesToRetrieve']>>>>> : P['attributesToRetrieve'] extends Array<infer K> ? Array<Document<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>> : Array<Document<T>>;
export declare type DocumentLike = {

@@ -105,3 +106,3 @@ [Key in string]?: DocumentField;

};
indexNewFields?: boolean;
acceptNewFields?: boolean;
}

@@ -195,3 +196,3 @@ export interface EnqueuedUpdate {

getAllUpdateStatus: () => Promise<Update[]>;
search: (query: string, options?: SearchParams) => Promise<SearchResponse<T>>;
search: <P extends SearchParams<T>>(query: string, options?: P) => Promise<SearchResponse<T, P>>;
show: () => Promise<IndexResponse>;

@@ -201,3 +202,3 @@ updateIndex: (indexData: IndexOptions) => Promise<IndexResponse>;

getStats: () => Promise<IndexStats>;
getDocuments: (options?: GetDocumentsParams) => Promise<Array<Document<T>>>;
getDocuments: <P extends GetDocumentsParams<T>>(options?: P) => Promise<GetDocumentsResponse<T, P>>;
getDocument: (documentId: string | number) => Promise<Document<T>>;

@@ -204,0 +205,0 @@ addDocuments: (documents: Array<Document<T>>, options?: AddDocumentParams) => Promise<EnqueuedUpdate>;

{
"name": "meilisearch",
"version": "0.11.2",
"version": "0.11.3",
"description": "The MeiliSearch JS client for Node.js and the browser.",

@@ -62,6 +62,6 @@ "keywords": [

"devDependencies": {
"@rollup/plugin-commonjs": "13.0.0",
"@rollup/plugin-commonjs": "14.0.0",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "8.0.1",
"@types/jest": "26.0.0",
"@rollup/plugin-node-resolve": "8.4.0",
"@types/jest": "26.0.5",
"@types/prettier": "^2.0.0",

@@ -74,3 +74,3 @@ "@typescript-eslint/eslint-plugin": "2.34.0",

"eslint-plugin-import": "2",
"eslint-plugin-jsdoc": "^28.5.1",
"eslint-plugin-jsdoc": "^30.0.0",
"eslint-plugin-node": "11",

@@ -91,4 +91,4 @@ "eslint-plugin-promise": "4",

"ts-jest": "^25.3.0",
"typescript": "3.9.5"
"typescript": "3.9.7"
}
}

@@ -38,3 +38,3 @@ <p align="center">

- [Search](#search)
- [⚙️ Development Workflow](#️-development-workflow)
- [⚙️ Development Workflow and Contributing](#️-development-workflow-and-contributing)
- [📜 API Resources](#-api-resources)

@@ -64,5 +64,5 @@

## Import
### Import <!-- omit in toc -->
### Front end or ESmodule
#### Front End or ESmodule <!-- omit in toc -->

@@ -73,8 +73,8 @@ ```javascript

const client = new MeiliSearch({
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
```
### HTML import
#### HTML Import <!-- omit in toc -->

@@ -94,11 +94,11 @@ ```javascript

### Back-End CommonJs
#### Back-End CommonJs <!-- omit in toc -->
```javascript
const MeiliSearch = require('meilisearch');
const MeiliSearch = require('meilisearch')
const client = new MeiliSearch({
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
```

@@ -201,3 +201,3 @@

```javascript
const index = await client.getIndex('books')
const index = client.getIndex('books')
```

@@ -308,44 +308,8 @@

## ⚙️ Development Workflow
## ⚙️ Development Workflow and Contributing
If you want to contribute, this section describes the steps to follow.
Any new contribution is more than welcome in this project!
Thank you for your interest in a MeiliSearch tool! ♥️
If you want to know more about the development workflow or want to contribute, please visit our [contributing guidelines](/CONTRIBUTING.md) for detailed instructions!
### Install dependencies <!-- omit in toc -->
```bash
$ yarn --dev
```
### Tests and Linter <!-- omit in toc -->
Each PR should pass the tests and the linter to be accepted.
```bash
# Tests
$ docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics
$ yarn test
# Linter
$ yarn style
# Linter with fixing
$ yarn style:fix
# Build the project
$ yarn build
```
### Release <!-- omit in toc -->
MeiliSearch tools follow the [Semantic Versioning Convention](https://semver.org/).
You must do a PR modifying the file [`package.json`](/package.json) with the right version.
```javascript
"version": X.X.X
```
Once the changes are merged on `master`, you can publish the current draft release via the [GitHub interface](https://github.com/meilisearch/meilisearch-js/releases).
A GitHub Action will be triggered and push the package on [npm](https://www.npmjs.com/package/meilisearch).
## 📜 API Resources

@@ -352,0 +316,0 @@

@@ -75,6 +75,6 @@ /*

*/
async search(
async search<P extends Types.SearchParams<T>>(
query: string,
options?: Types.SearchParams
): Promise<Types.SearchResponse<T>> {
options?: P
): Promise<Types.SearchResponse<T, P>> {
const url = `/indexes/${this.uid}/search`

@@ -197,5 +197,5 @@

*/
async getDocuments(
options?: Types.GetDocumentsParams
): Promise<Array<Types.Document<T>>> {
async getDocuments<P extends Types.GetDocumentsParams<T>>(
options?: P
): Promise<Types.GetDocumentsResponse<T, P>> {
const url = `/indexes/${this.uid}/documents`

@@ -202,0 +202,0 @@ let attr

@@ -56,9 +56,13 @@ // Type definitions for meilisearch

export interface SearchParams {
export interface SearchParams<T> {
offset?: number
limit?: number
attributesToRetrieve?: string[] | string
attributesToCrop?: string[] | string
attributesToRetrieve?: Extract<keyof T, string>[] | Extract<keyof T, string>
attributesToCrop?:
| (Extract<keyof T, string> | '*')[]
| (Extract<keyof T, string> | '*')
cropLength?: number
attributesToHighlight?: string[] | string
attributesToHighlight?:
| (Extract<keyof T, string> | '*')[]
| (Extract<keyof T, string> | '*')
filters?: string

@@ -86,4 +90,12 @@ facetFilters?: string | FacetFilter | FacetFilter[]

export interface SearchResponse<T = any> {
hits: Array<Hit<T>>
export interface SearchResponse<T, P extends SearchParams<T>> {
hits: P['attributesToRetrieve'] extends keyof T
? Array<
Hit<
Pick<T, Exclude<keyof T, Exclude<keyof T, P['attributesToRetrieve']>>>
>
>
: P['attributesToRetrieve'] extends Array<infer K>
? Array<Hit<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>>
: Array<Hit<T>>
offset: number

@@ -104,8 +116,21 @@ limit: number

*/
export interface GetDocumentsParams {
export interface GetDocumentsParams<T> {
offset?: number
limit?: number
attributesToRetrieve?: string[]
attributesToRetrieve?: Extract<keyof T, string>[] | Extract<keyof T, string>
}
export type GetDocumentsResponse<
T,
P extends GetDocumentsParams<T>
> = P['attributesToRetrieve'] extends keyof T
? Array<
Document<
Pick<T, Exclude<keyof T, Exclude<keyof T, P['attributesToRetrieve']>>>
>
>
: P['attributesToRetrieve'] extends Array<infer K>
? Array<Document<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>>
: Array<Document<T>>
export type DocumentLike = { [Key in string]?: DocumentField }

@@ -122,5 +147,5 @@ export interface DocumentArray extends Array<DocumentField> {}

export type Document<T> = DocumentLike &
{
[key in keyof T]: T[key]
}
{
[key in keyof T]: T[key]
}

@@ -141,3 +166,3 @@ /*

}
indexNewFields?: boolean
acceptNewFields?: boolean
}

@@ -266,3 +291,6 @@

getAllUpdateStatus: () => Promise<Update[]>
search: (query: string, options?: SearchParams) => Promise<SearchResponse<T>>
search: <P extends SearchParams<T>>(
query: string,
options?: P
) => Promise<SearchResponse<T, P>>
show: () => Promise<IndexResponse>

@@ -272,3 +300,5 @@ updateIndex: (indexData: IndexOptions) => Promise<IndexResponse>

getStats: () => Promise<IndexStats>
getDocuments: (options?: GetDocumentsParams) => Promise<Array<Document<T>>>
getDocuments: <P extends GetDocumentsParams<T>>(
options?: P
) => Promise<GetDocumentsResponse<T, P>>
getDocument: (documentId: string | number) => Promise<Document<T>>

@@ -336,7 +366,7 @@ addDocuments: (

) => Promise<Index<T>>) &
(<T = any, R = AxiosResponse<EnqueuedUpdate>>(
url: string,
data?: T,
config?: AxiosRequestConfig
) => Promise<R>)
(<T = any, R = AxiosResponse<EnqueuedUpdate>>(
url: string,
data?: T,
config?: AxiosRequestConfig
) => Promise<R>)
put: <T = any, R = AxiosResponse<T>>(

@@ -343,0 +373,0 @@ url: string,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc