Skip to content

Commit

Permalink
Upgrade dependencies, lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbosco committed Apr 23, 2021
1 parent 1958093 commit 2869aa0
Show file tree
Hide file tree
Showing 41 changed files with 3,667 additions and 2,856 deletions.
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
coverage/
dist/
lib/
test/support/testground/

.cache
.parcel-cache

test/support/data/
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"env": {
"browser": true,
"es6": true
"amd": true,
"node": true
},
"extends": ["plugin:prettier/recommended", "prettier/standard"],
"extends": ["eslint:recommended", "prettier"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
141 changes: 70 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ Since this is an adapter, it **will not install** the Instantsearch library auto
- [vue-instantsearch](https://github.com/algolia/vue-instantsearch)
- [angular-instantsearch](https://github.com/algolia/angular-instantsearch)

You'll find information on how to get started with each of the above libraries in their respective repos.
You'll find information on how to get started with each of the above libraries in their respective repos.

We'd also recommend checking out [create-instantsearch-app](https://github.com/algolia/create-instantsearch-app) to create your Search UI from a starter template.

## Usage
## Usage

### With [instantsearch.js](https://github.com/algolia/instantsearch.js)

```javascript
import instantsearch from "instantsearch.js";
import { searchBox, hits } from "instantsearch.js/es/widgets";
Expand All @@ -75,27 +76,26 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
{
host: "localhost",
port: "8108",
protocol: "http"
}
]
protocol: "http",
},
],
},
// The following parameters are directly passed to Typesense's search API endpoint.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
additionalSearchParameters: {
queryBy: "name,description,categories"
}
queryBy: "name,description,categories",
},
});
const searchClient = typesenseInstantsearchAdapter.searchClient;


const search = instantsearch({
searchClient,
indexName: "products"
indexName: "products",
});
search.addWidgets([
searchBox({
container: "#searchbox"
container: "#searchbox",
}),
hits({
container: "#hits",
Expand All @@ -104,9 +104,9 @@ search.addWidgets([
<div class="hit-name">
{{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}}
</div>
`
}
})
`,
},
}),
]);

search.start();
Expand All @@ -117,10 +117,11 @@ You can add any of the Instantsearch widgets [here](https://www.algolia.com/doc/
You'll also find a working example in [test/support/testground](test/support/testground). To run it, run `npm run testground` from the project root folder.

### With [react-instantsearch](https://github.com/algolia/react-instantsearch)

```jsx harmony
import React from 'react';
import ReactDOM from 'react-dom';
import { SearchBox } from 'react-instantsearch-dom';
import React from "react";
import ReactDOM from "react-dom";
import { SearchBox } from "react-instantsearch-dom";
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
Expand All @@ -130,24 +131,21 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
{
host: "localhost",
port: "8108",
protocol: "http"
}
]
protocol: "http",
},
],
},
// The following parameters are directly passed to Typesense's search API endpoint.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
additionalSearchParameters: {
queryBy: "name,description,categories"
}
queryBy: "name,description,categories",
},
});
const searchClient = typesenseInstantsearchAdapter.searchClient;

const App = () => (
<InstantSearch
indexName="products"
searchClient={searchClient}
>
<InstantSearch indexName="products" searchClient={searchClient}>
<SearchBox />
<Hits />
</InstantSearch>
Expand Down Expand Up @@ -182,16 +180,16 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
{
host: "localhost",
port: "8108",
protocol: "http"
}
]
protocol: "http",
},
],
},
// The following parameters are directly passed to Typesense's search API endpoint.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
additionalSearchParameters: {
queryBy: "name,description,categories"
}
queryBy: "name,description,categories",
},
});
const searchClient = typesenseInstantsearchAdapter.searchClient;
Expand All @@ -208,9 +206,10 @@ export default {
You can then add any of the Instantsearch widgets [here](https://www.algolia.com/doc/guides/building-search-ui/widgets/showcase/vue/) that are [supported](#widget-compatibility) by the adapter.

### With [angular-instantsearch](https://github.com/algolia/angular-instantsearch)

```javascript
// app.component.ts
import { Component } from '@angular/core';
import { Component } from "@angular/core";
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
Expand All @@ -220,28 +219,28 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
{
host: "localhost",
port: "8108",
protocol: "http"
}
]
protocol: "http",
},
],
},
// The following parameters are directly passed to Typesense's search API endpoint.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
// So you can pass any parameters supported by the search endpoint below.
// queryBy is required.
additionalSearchParameters: {
queryBy: "name,description,categories"
}
queryBy: "name,description,categories",
},
});
const searchClient = typesenseInstantsearchAdapter.searchClient;

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
config = {
indexName: 'products',
searchClient
indexName: "products",
searchClient,
};
}
```
Expand All @@ -254,7 +253,7 @@ You can then add any of the Instantsearch widgets [here](https://www.algolia.com

For this widget, you want to create independent fields in the collection's schema with this specific naming convention:

- `field.lvl0`
- `field.lvl0`
- `field.lvl1`
- `field.lvl2`

Expand All @@ -269,14 +268,14 @@ When instantiating this widget, you want to set the value of the index name to t
```javascript
search.addWidgets([
sortBy({
container: "#sort-by",
items: [
{ label: "Default", value: "products" },
{ label: "Price (asc)", value: "products/sort/price:asc" },
{ label: "Price (desc)", value: "products/sort/price:desc" }
]
})
])
container: "#sort-by",
items: [
{ label: "Default", value: "products" },
{ label: "Price (asc)", value: "products/sort/price:asc" },
{ label: "Price (desc)", value: "products/sort/price:desc" },
],
}),
]);
```

The generalized pattern for the value attribute is: `<index_name>[/sort/<sort_by>]`. The adapter will use the value in `<sort_by>` as the value for the `sort_by` search parameter.
Expand All @@ -293,21 +292,21 @@ For Federated / Multi-Index Search, you'd need to use the `index` widget. To the
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
apiKey: "abcd", // Be sure to use an API key that only allows search operations
nodes: [{ host: "localhost", port: "8108", protocol: "http" }]
nodes: [{ host: "localhost", port: "8108", protocol: "http" }],
},
// Search parameters that are common to all collections/indices go here:
additionalSearchParameters: {
numTypos: 3
numTypos: 3,
},
// Search parameters that need to be *overridden* on a per-collection-basis go here:
collectionSpecificSearchParameters: {
products: {
queryBy: "name,description,categories"
queryBy: "name,description,categories",
},
brands: {
queryBy: "name"
}
}
queryBy: "name",
},
},
});
const searchClient = typesenseInstantsearchAdapter.searchClient;
```
Expand All @@ -317,12 +316,12 @@ Essentially, any parameters set in `collectionSpecificSearchParameters` will be
## Compatibility

| Typesense Server | typesense-instantsearch-adapter | instantsearch.js | react-instantsearch | vue-instantsearch | angular-instantsearch |
|------------------|----------------|----------------|----------------|----------------|----------------|
| \>= v0.19 | \>= v1.0.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| \>= v0.15 | \>= v0.3.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| \>= v0.14 | \>= v0.2.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| \>= v0.13 | \>= v0.1.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| \>= v0.12 | \>= v0.0.4 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| ---------------- | ------------------------------- | ---------------- | ------------------- | ----------------- | --------------------- |
| \>= v0.19 | \>= v1.0.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| \>= v0.15 | \>= v0.3.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| \>= v0.14 | \>= v0.2.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| \>= v0.13 | \>= v0.1.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
| \>= v0.12 | \>= v0.0.4 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |

If a particular version of the above libraries don't work with the adapter, please open a Github issue with details.

Expand Down Expand Up @@ -351,7 +350,7 @@ To release a new version, we use the [np](https://github.com/sindresorhus/np) pa

```shell
$ npm install --global np
$ np
$ np

# Follow instructions that np shows you

Expand Down
2 changes: 1 addition & 1 deletion dist/typesense-instantsearch-adapter.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/typesense-instantsearch-adapter.min.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ module.exports = {
// headless: process.env.HEADLESS === "true" || process.env.CI === "true",
headless: true,
slowMo: 10,
defaultViewport: null
defaultViewport: null,
// devtools: true
},
server: [
{
command: "npm run testground",
port: 3000,
launchTimeout: 120 * 1000,
debug: false
debug: false,
},
{
command: "npm run typesenseServer",
port: 8108,
launchTimeout: 60 * 1000,
debug: false
}
]
debug: false,
},
],
};
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,5 @@ module.exports = {
// Whether to use watchman for file crawling
// watchman: true,

testTimeout: 30000
testTimeout: 30000,
};
2 changes: 1 addition & 1 deletion lib/Configuration.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2869aa0

Please sign in to comment.