Skip to content

Commit

Permalink
Merge branch 'feat/automatic-user-token' into feat/send-events
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjae-lee committed Aug 24, 2020
2 parents 77b77a9 + f34170d commit cc3874d
Show file tree
Hide file tree
Showing 32 changed files with 404 additions and 969 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
name: Update dependencies
command: |
yarn remove @algolia/client-search
yarn add @types/[email protected].8 [email protected]
yarn add @types/[email protected].10 [email protected]
- run:
name: Type Checking
command: yarn run type-check
Expand Down
14 changes: 7 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ module.exports = {
extends: ['algolia', 'algolia/jest', 'algolia/react', 'algolia/typescript'],
plugins: ['react-hooks'],
rules: {
'no-param-reassign': 0,
'import/no-extraneous-dependencies': 0,
'no-param-reassign': 'off',
'import/no-extraneous-dependencies': 'off',
'new-cap': [
'error',
{
capIsNewExceptions: [
'EXPERIMENTAL_use',
'EXPERIMENTAL_configureRelatedItems',
'EXPERIMENTAL_connectConfigureRelatedItems',
'EXPERIMENTAL_configureRelatedItems',
],
},
],
'react/no-string-refs': 1,
'react/no-string-refs': 'error',
// Avoid errors about `UNSAFE` lifecycles (e.g. `UNSAFE_componentWillMount`)
'react/no-deprecated': 0,
'react/no-deprecated': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'jest/no-test-callback': 0,
'jest/no-test-callback': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
Expand All @@ -40,7 +40,7 @@ module.exports = {
{
files: ['*.ts', '*.tsx'],
rules: {
'valid-jsdoc': 0,
'valid-jsdoc': 'off',
},
},
],
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# [4.7.1](https://github.com/algolia/instantsearch.js/compare/v4.7.0...v4.7.1) (2020-08-19)


### Bug Fixes

* **configureRelatedItems:** support nested attributes ([#4480](https://github.com/algolia/instantsearch.js/issues/4480)) ([2266004](https://github.com/algolia/instantsearch.js/commit/2266004f274138b45640f000a5da8aa14e419e6c))
* **connectToggleRefinement:** fix onFacetValue/offFacetValue on render when using arrays for on/off ([#4449](https://github.com/algolia/instantsearch.js/issues/4449)) ([fd3e83f](https://github.com/algolia/instantsearch.js/commit/fd3e83f2cf2e5b44b7d29eb4c67526e55c18d708))
* **index:** don't show a development warning for inconsistent UI state in `connectRange` ([#4440](https://github.com/algolia/instantsearch.js/issues/4440)) ([eb8c8b3](https://github.com/algolia/instantsearch.js/commit/eb8c8b3494cb66dbef1d03e7d74374dc49059345)), closes [#4437](https://github.com/algolia/instantsearch.js/issues/4437)
* **infiniteHits:** work with controlled mode ([#4435](https://github.com/algolia/instantsearch.js/issues/4435)) ([68b20f4](https://github.com/algolia/instantsearch.js/commit/68b20f487fcd54fd7dec11b4c494b6aa94a18516))
* **typescript:** correct dummy v4 client ([#4459](https://github.com/algolia/instantsearch.js/issues/4459)) ([ca0c394](https://github.com/algolia/instantsearch.js/commit/ca0c3946608bb8ec5dcf5378d8d382d809a4d86f))
* **typescript:** jsDoc comments which conform to Connector definition ([#4458](https://github.com/algolia/instantsearch.js/issues/4458)) ([5209bdb](https://github.com/algolia/instantsearch.js/commit/5209bdb9189e7cbbf9514b62fde55f923b2b3273))
* **typescript:** export correct types ([#4476](https://github.com/algolia/instantsearch.js/issues/4476)) ([5fb4c5b](https://github.com/algolia/instantsearch.js/commit/5fb4c5b9d6ac75636e94514598ef5d5a86affafd))



# [4.7.0](https://github.com/algolia/instantsearch.js/compare/v4.6.0...v4.7.0) (2020-06-15)


Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ InstantSearch.js is a vanilla JavaScript library that lets you create an instant
- [Demos](#demos)
- [Playground](#playground)
- [Browser support](#browser-support)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)

Expand Down
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instantsearch.js",
"version": "4.7.0",
"version": "4.7.1",
"description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
"homepage": "https://community.algolia.com/instantsearch.js/",
"types": "es/index.d.ts",
Expand Down Expand Up @@ -53,7 +53,7 @@
],
"dependencies": {
"@types/googlemaps": "^3.39.6",
"algoliasearch-helper": "^3.2.1",
"algoliasearch-helper": "^3.2.2",
"classnames": "^2.2.5",
"events": "^1.1.0",
"hogan.js": "^3.0.2",
Expand All @@ -62,15 +62,15 @@
"qs": "^6.5.1"
},
"devDependencies": {
"@algolia/client-search": "4.0.0-beta.15",
"@algolia/client-search": "4.3.1",
"@babel/cli": "7.8.3",
"@babel/core": "7.8.3",
"@babel/plugin-proposal-class-properties": "7.8.3",
"@babel/plugin-transform-react-constant-elements": "7.8.3",
"@babel/preset-env": "7.8.3",
"@babel/preset-react": "7.8.3",
"@babel/preset-typescript": "7.8.3",
"@microsoft/api-extractor": "7.7.13",
"@microsoft/api-extractor": "7.9.2",
"@storybook/addon-actions": "5.3.9",
"@storybook/html": "5.3.9",
"@storybook/theming": "5.3.9",
Expand All @@ -92,15 +92,15 @@
"@wdio/selenium-standalone-service": "5.16.5",
"@wdio/spec-reporter": "5.16.5",
"@wdio/static-server-service": "5.16.5",
"algoliasearch": "4.1.0",
"algoliasearch": "4.3.1",
"algoliasearch-v3": "npm:algoliasearch@3",
"babel-eslint": "10.0.3",
"babel-jest": "24.9.0",
"babel-loader": "8.0.6",
"babel-plugin-inline-replace-variables": "1.3.1",
"babel-plugin-transform-react-pure-class-to-function": "1.0.1",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"bundlesize": "0.18.0",
"colors": "1.4.0",
"conventional-changelog-cli": "2.0.31",
"doctoc": "1.4.0",
"enzyme": "3.11.0",
Expand All @@ -109,14 +109,12 @@
"eslint": "6.8.0",
"eslint-config-algolia": "13.4.0",
"eslint-config-prettier": "6.9.0",
"eslint-import-resolver-webpack": "0.12.1",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jasmine": "4.1.0",
"eslint-plugin-jest": "23.6.0",
"eslint-plugin-prettier": "3.1.2",
"eslint-plugin-react": "7.18.0",
"eslint-plugin-react-hooks": "2.3.0",
"inquirer": "7.0.3",
"instantsearch-e2e-tests": "algolia/instantsearch-e2e-tests#1.3.0",
"jest": "25.1.0",
"jest-diff": "25.1.0",
Expand All @@ -125,7 +123,6 @@
"jest-watch-typeahead": "0.4.2",
"jscodeshift": "0.7.0",
"jsdom-global": "3.0.2",
"mversion": "1.13.0",
"places.js": "1.17.1",
"prettier": "1.19.1",
"rollup": "1.29.1",
Expand All @@ -139,7 +136,7 @@
"semver": "6.3.0",
"shelljs": "0.8.3",
"shipjs": "0.16.0",
"typescript": "3.7.5",
"typescript": "3.8.3",
"webpack": "4.41.5"
},
"bundlesize": [
Expand Down
12 changes: 11 additions & 1 deletion scripts/build/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ const fs = require('fs');
const path = require('path');
const shell = require('shelljs');

console.log(`Compiling definitions...`);

shell.exec(`tsc -p tsconfig.declaration.json --outDir es/`);

// replace block ts-ignore comments with line ones to support TS < 3.9
shell.sed(
'-i',
/\*\* @ts-ignore/g,
'/ @ts-ignore',
path.join(__dirname, '../../es/**/*.d.ts')
);

console.log();
console.log(`Validating definitions...`);

Expand All @@ -16,7 +26,7 @@ const { Extractor, ExtractorConfig } = require('@microsoft/api-extractor');
const publicExports = [
// 'components' -> does not contains index.d.ts yet
'connectors',
// 'lib', -> Api extrator "import * as ___ from ___;" is not supported yet for local files
// 'lib', -> Api extractor "import * as ___ from ___;" is not supported yet for local files
// 'middleware',
'helpers',
'types',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ exports[`RefinementList rendering with facets from search 1`] = `
class="input"
maxlength="512"
placeholder="Search"
spellcheck="false"
type="search"
/>
<button
Expand Down Expand Up @@ -180,6 +181,7 @@ exports[`RefinementList rendering without facets from search 1`] = `
class="input"
maxlength="512"
placeholder="Search"
spellcheck="false"
type="search"
/>
<button
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchBox/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class SearchBox extends Component {
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck={false}
spellCheck="false"
maxLength={512}
onInput={this.onInput}
onBlur={this.onBlur}
Expand Down
14 changes: 14 additions & 0 deletions src/components/SearchBox/__tests__/SearchBox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,20 @@ describe('SearchBox', () => {
expect(mount(<SearchBox {...defaultProps} />)).toMatchSnapshot();
});

test('sets search input attributes', () => {
const res = render(
<SearchBox {...defaultProps} autofocus={true} query="sample query" />
);
const input = res.getByDisplayValue('sample query');

expect(input).toHaveAttribute('autofocus', 'true');
expect(input).toHaveAttribute('autocomplete', 'off');
expect(input).toHaveAttribute('autocorrect', 'off');
expect(input).toHaveAttribute('autocapitalize', 'off');
expect(input).toHaveAttribute('spellcheck', 'false');
expect(input).toHaveAttribute('maxlength', '512');
});

test('with custom templates', () => {
const props = {
...defaultProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Array [
onFocus={[Function]}
onInput={[Function]}
placeholder=""
spellCheck={false}
spellCheck="false"
type="search"
value=""
/>
Expand Down Expand Up @@ -96,7 +96,7 @@ Array [
onFocus={[Function]}
onInput={[Function]}
placeholder=""
spellCheck={false}
spellCheck="false"
type="search"
value=""
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,43 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/configure-r
]);
});

test('sets the optionalFilters search parameter based on matchingPatterns with nested attributes', () => {
const searchClient = createSearchClient();
const search = instantsearch({
indexName: 'indexName',
searchClient,
});
const configureRelatedItems = connectConfigureRelatedItems(noop);

search.addWidgets([
configureRelatedItems({
hit,
matchingPatterns: {
brand: { score: 3 },
'hierarchicalCategories.lvl0': { score: 2 },
},
}),
]);
search.start();

expect(searchClient.search).toHaveBeenCalledTimes(1);
expect(searchClient.search).toHaveBeenCalledWith([
{
indexName: 'indexName',
params: {
facets: [],
facetFilters: ['objectID:-1'],
tagFilters: '',
sumOrFiltersScores: true,
optionalFilters: [
'brand:Amazon<score=3>',
'hierarchicalCategories.lvl0:TV & Home Theater<score=2>',
],
},
},
]);
});

test('sets transformed search parameters based on transformSearchParameters', () => {
const searchClient = createSearchClient();
const search = instantsearch({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createDocumentationMessageGenerator,
getObjectType,
warning,
getPropertyByPath,
} from '../../lib/utils';
import connectConfigure, {
ConfigureRendererOptions,
Expand Down Expand Up @@ -79,7 +80,7 @@ const connectConfigureRelatedItems: ConfigureRelatedItemsConnector = function co
Array<string | string[]>
>((acc, attributeName) => {
const attribute = matchingPatterns[attributeName];
const attributeValue = hit[attributeName];
const attributeValue = getPropertyByPath(hit, attributeName);
const attributeScore = attribute.score;

if (Array.isArray(attributeValue)) {
Expand Down
8 changes: 4 additions & 4 deletions src/connectors/hierarchical-menu/connectHierarchicalMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const withUsage = createDocumentationMessageGenerator({
* levels deep.
*
* @type {Connector}
* @param {function(HierarchicalMenuRenderingOptions)} renderFn Rendering function for the custom **HierarchicalMenu** widget.
* @param {function(HierarchicalMenuRenderingOptions, boolean)} renderFn Rendering function for the custom **HierarchicalMenu** widget.
* @param {function} unmountFn Unmount function called when the widget is disposed.
* @return {function(CustomHierarchicalMenuWidgetOptions)} Re-usable widget factory for a custom **HierarchicalMenu** widget.
*/
Expand Down Expand Up @@ -205,10 +205,10 @@ export default function connectHierarchicalMenu(renderFn, unmountFn = noop) {
);
},

// eslint-disable-next-line valid-jsdoc
/**
* @param {Object} param0
* @param {import('algoliasearch-helper').SearchParameters} param0.state
* @param {Object} param0 cleanup arguments
* @param {any} param0.state current search parameters
* @returns {any} next search parameters
*/
dispose({ state }) {
unmountFn();
Expand Down
2 changes: 1 addition & 1 deletion src/connectors/hits-per-page/connectHitsPerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type HitsPerPageConnectorParams = {
/**
* Function to transform the items passed to the templates.
*/
transformItems?: TransformItems<HitsPerPageConnectorParamsItem>;
transformItems?: TransformItems<HitsPerPageRendererOptionsItem>;
};

export type HitsPerPageRendererOptions = {
Expand Down
16 changes: 15 additions & 1 deletion src/connectors/hits/connectHitsWithInsights.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { withInsights } from '../../lib/insights';
import connectHits from './connectHits';
import connectHits, {
HitsRendererOptions,
HitsConnectorParams,
} from './connectHits';
import { Connector } from '../../types';

/**
* Due to https://github.com/microsoft/web-build-tools/issues/1050, we need
* Connector<...> imported in this file, even though it is only used implicitly.
* This _uses_ Connector<...> so it is not accidentally removed by someone.
*/
declare type ImportWorkaround = Connector<
HitsRendererOptions,
HitsConnectorParams
>;

const connectHitsWithInsights = withInsights(connectHits);

Expand Down
16 changes: 15 additions & 1 deletion src/connectors/infinite-hits/connectInfiniteHitsWithInsights.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { withInsights } from '../../lib/insights';
import connectInfiniteHits from './connectInfiniteHits';
import connectInfiniteHits, {
InfiniteHitsRendererOptions,
InfiniteHitsConnectorParams,
} from './connectInfiniteHits';
import { Connector } from '../../types';

/**
* Due to https://github.com/microsoft/web-build-tools/issues/1050, we need
* Connector<...> imported in this file, even though it is only used implicitly.
* This _uses_ Connector<...> so it is not accidentally removed by someone.
*/
declare type ImportWorkaround = Connector<
InfiniteHitsRendererOptions,
InfiniteHitsConnectorParams
>;

const connectInfiniteHitsWithInsights = withInsights(connectInfiniteHits);

Expand Down
Loading

0 comments on commit cc3874d

Please sign in to comment.