instantsearch.js 4.41.2 → 4.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/cjs/connectors/rating-menu/connectRatingMenu.js +1 -1
- package/cjs/lib/InstantSearch.js +11 -1
- package/cjs/lib/version.js +1 -1
- package/cjs/types/algoliasearch.js +18 -1
- package/dist/instantsearch.development.d.ts +4 -23
- package/dist/instantsearch.development.js +67 -19
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +4 -23
- package/dist/instantsearch.production.min.d.ts +4 -23
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/geo-search/connectGeoSearch.d.ts +1 -1
- package/es/connectors/rating-menu/connectRatingMenu.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/lib/InstantSearch.js +11 -1
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/types/algoliasearch.d.ts +1 -40
- package/es/types/algoliasearch.js +2 -0
- package/es/types/index.js +1 -0
- package/es/types/results.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## [4.43.1](https://github.com/algolia/instantsearch.js/compare/v4.43.0...v4.43.1) (2022-07-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **errors:** rethrow error as error if it's an object ([#5075](https://github.com/algolia/instantsearch.js/issues/5075)) ([34132bb](https://github.com/algolia/instantsearch.js/commit/34132bba38c05fa2f5e4e54c6889e9335e62e4f4))
|
|
7
|
+
* **ratingMenu:** don't warn if results are artificial ([#5073](https://github.com/algolia/instantsearch.js/issues/5073)) ([d747d23](https://github.com/algolia/instantsearch.js/commit/d747d23b28c380fe82a40eeab06c57359af8004a))
|
|
8
|
+
* **types:** use correct case for _geoloc property ([#5074](https://github.com/algolia/instantsearch.js/issues/5074)) ([6fed7d8](https://github.com/algolia/instantsearch.js/commit/6fed7d870c3607980776d33a3697f8e2789aa08b))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# [4.43.0](https://github.com/algolia/instantsearch.js/compare/v4.42.0...v4.43.0) (2022-06-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **types:** support algoliasearch v5 ([#5066](https://github.com/algolia/instantsearch.js/issues/5066)) ([3eb4dc7](https://github.com/algolia/instantsearch.js/commit/3eb4dc75a5935f2ee4fead8787f39af0150b24c4))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# [4.42.0](https://github.com/algolia/instantsearch.js/compare/v4.41.2...v4.42.0) (2022-06-21)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **es:** update import path for `infiniteHitsCache` in depreciation message ([#5068](https://github.com/algolia/instantsearch.js/issues/5068)) ([545cbaf](https://github.com/algolia/instantsearch.js/commit/545cbafd748bb8be32bff66ac60b5f3f9133a5b4))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* **core:** sort parameters & support client.search for sffv ([#5069](https://github.com/algolia/instantsearch.js/issues/5069)) ([34e2b00](https://github.com/algolia/instantsearch.js/commit/34e2b00cbc93f1bc86ee0abaec6b6e132bd18354))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
1
35
|
## [4.41.2](https://github.com/algolia/instantsearch.js/compare/v4.41.1...v4.41.2) (2022-06-15)
|
|
2
36
|
|
|
3
37
|
|
|
@@ -223,7 +223,7 @@ var connectRatingMenu = function connectRatingMenu(renderFn) {
|
|
|
223
223
|
var maxValuesPerFacet = facetResults.length;
|
|
224
224
|
var maxDecimalPlaces = getFacetsMaxDecimalPlaces(facetResults);
|
|
225
225
|
var maxFacets = Math.pow(10, maxDecimalPlaces) * max;
|
|
226
|
-
process.env.NODE_ENV === 'development' ? (0, _index.warning)(maxFacets <= maxValuesPerFacet, getFacetValuesWarningMessage({
|
|
226
|
+
process.env.NODE_ENV === 'development' ? (0, _index.warning)(maxFacets <= maxValuesPerFacet || Boolean(results.__isArtificial), getFacetValuesWarningMessage({
|
|
227
227
|
maxDecimalPlaces: maxDecimalPlaces,
|
|
228
228
|
maxFacets: maxFacets,
|
|
229
229
|
maxValuesPerFacet: maxValuesPerFacet
|
package/cjs/lib/InstantSearch.js
CHANGED
|
@@ -445,12 +445,22 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
445
445
|
|
|
446
446
|
mainHelper.on('error', function (_ref4) {
|
|
447
447
|
var error = _ref4.error;
|
|
448
|
-
|
|
448
|
+
|
|
449
|
+
if (!(error instanceof Error)) {
|
|
450
|
+
// typescript lies here, error is in some cases { name: string, message: string }
|
|
451
|
+
var err = error;
|
|
452
|
+
error = Object.keys(err).reduce(function (acc, key) {
|
|
453
|
+
acc[key] = err[key];
|
|
454
|
+
return acc;
|
|
455
|
+
}, new Error(err.message));
|
|
456
|
+
} // If an error is emitted, it is re-thrown by events. In previous versions
|
|
449
457
|
// we emitted {error}, which is thrown as:
|
|
450
458
|
// "Uncaught, unspecified \"error\" event. ([object Object])"
|
|
451
459
|
// To avoid breaking changes, we make the error available in both
|
|
452
460
|
// `error` and `error.error`
|
|
453
461
|
// @MAJOR emit only error
|
|
462
|
+
|
|
463
|
+
|
|
454
464
|
error.error = error;
|
|
455
465
|
|
|
456
466
|
_this3.emit('error', error);
|
package/cjs/lib/version.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _algoliasearch = require("algoliasearch-helper/types/algoliasearch.js");
|
|
8
|
+
|
|
9
|
+
Object.keys(_algoliasearch).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _algoliasearch[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _algoliasearch[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
2
|
|
|
3
|
-
import type algoliasearch from 'algoliasearch/lite';
|
|
4
3
|
import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
|
|
5
|
-
import type * as ClientSearch from '@algolia/client-search';
|
|
6
4
|
import EventEmitter from '@algolia/events';
|
|
5
|
+
import { FindAnswersOptions } from 'algoliasearch-helper/types/algoliasearch.js';
|
|
7
6
|
import type { InsightsClient as InsightsClient_2 } from 'search-insights';
|
|
8
7
|
import type { InsightsMethodMap } from 'search-insights';
|
|
9
8
|
import type * as Places from 'places.js';
|
|
10
9
|
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
11
10
|
import { default as qs_2 } from 'qs';
|
|
11
|
+
import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
|
|
12
12
|
import type { SearchParameters } from 'algoliasearch-helper';
|
|
13
13
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
14
14
|
|
|
@@ -34,7 +34,7 @@ declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
_distinctSeqID?: number;
|
|
37
|
-
|
|
37
|
+
_geoloc?: GeoLoc;
|
|
38
38
|
} & THit;
|
|
39
39
|
|
|
40
40
|
declare const analytics: AnalyticsWidget;
|
|
@@ -1075,18 +1075,12 @@ declare type CustomSendEventForHits = (customPayload: any) => void;
|
|
|
1075
1075
|
|
|
1076
1076
|
declare type CustomSendEventForToggle = (customPayload: any) => void;
|
|
1077
1077
|
|
|
1078
|
-
declare type DefaultSearchClient = ReturnType<typeof algoliasearch>;
|
|
1079
|
-
|
|
1080
1078
|
declare type DisposeOptions = {
|
|
1081
1079
|
helper: AlgoliaSearchHelper;
|
|
1082
1080
|
state: SearchParameters;
|
|
1083
1081
|
parent: IndexWidget;
|
|
1084
1082
|
};
|
|
1085
1083
|
|
|
1086
|
-
declare type DummySearchClientV4 = {
|
|
1087
|
-
readonly transporter: any;
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
1084
|
declare const dynamicWidgets: DynamicWidgetsWidget;
|
|
1091
1085
|
|
|
1092
1086
|
declare type DynamicWidgetsConnector = Connector<DynamicWidgetsWidgetDescription, DynamicWidgetsConnectorParams>;
|
|
@@ -1175,9 +1169,7 @@ declare const EXPERIMENTAL_connectDynamicWidgets: DynamicWidgetsConnector;
|
|
|
1175
1169
|
/** @deprecated use dynamicWidgets */
|
|
1176
1170
|
declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
|
|
1177
1171
|
|
|
1178
|
-
declare type
|
|
1179
|
-
|
|
1180
|
-
declare type GeoHit = Hit & Required<Pick<Hit, '_geoLoc'>>;
|
|
1172
|
+
declare type GeoHit = Hit & Required<Pick<Hit, '_geoloc'>>;
|
|
1181
1173
|
|
|
1182
1174
|
declare type GeoLoc = {
|
|
1183
1175
|
lat: number;
|
|
@@ -4582,17 +4574,6 @@ declare type SearchBoxWidgetParams = {
|
|
|
4582
4574
|
queryHook?: (query: string, hook: (value: string) => void) => void;
|
|
4583
4575
|
};
|
|
4584
4576
|
|
|
4585
|
-
declare type SearchClient = {
|
|
4586
|
-
search: DefaultSearchClient['search'];
|
|
4587
|
-
searchForFacetValues: DefaultSearchClient['searchForFacetValues'];
|
|
4588
|
-
addAlgoliaAgent?: DefaultSearchClient['addAlgoliaAgent'];
|
|
4589
|
-
initIndex?: (indexName: string) => SearchIndex extends {
|
|
4590
|
-
findAnswers: any;
|
|
4591
|
-
} ? Partial<Pick<SearchIndex, 'findAnswers'>> : SearchIndex;
|
|
4592
|
-
};
|
|
4593
|
-
|
|
4594
|
-
declare type SearchIndex = ReturnType<DefaultSearchClient['initIndex']>;
|
|
4595
|
-
|
|
4596
4577
|
declare type SendEvent = (...args: [InsightsEvent] | [string, string, string?]) => void;
|
|
4597
4578
|
|
|
4598
4579
|
declare type SendEventForFacet = BuiltInSendEventForFacet & CustomSendEventForFacet;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! InstantSearch.js 4.
|
|
1
|
+
/*! InstantSearch.js 4.43.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch.js */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -3847,6 +3847,17 @@
|
|
|
3847
3847
|
|
|
3848
3848
|
var DerivedHelper_1 = DerivedHelper;
|
|
3849
3849
|
|
|
3850
|
+
function sortObject(obj) {
|
|
3851
|
+
return Object.keys(obj)
|
|
3852
|
+
.sort(function(a, b) {
|
|
3853
|
+
return a.localeCompare(b);
|
|
3854
|
+
})
|
|
3855
|
+
.reduce(function(acc, curr) {
|
|
3856
|
+
acc[curr] = obj[curr];
|
|
3857
|
+
return acc;
|
|
3858
|
+
}, {});
|
|
3859
|
+
}
|
|
3860
|
+
|
|
3850
3861
|
var requestBuilder = {
|
|
3851
3862
|
/**
|
|
3852
3863
|
* Get all the queries to send to the client, those queries can used directly
|
|
@@ -3937,7 +3948,7 @@
|
|
|
3937
3948
|
additionalParams.numericFilters = numericFilters;
|
|
3938
3949
|
}
|
|
3939
3950
|
|
|
3940
|
-
return merge_1({}, state.getQueryParams(), additionalParams);
|
|
3951
|
+
return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
|
|
3941
3952
|
},
|
|
3942
3953
|
|
|
3943
3954
|
/**
|
|
@@ -3952,16 +3963,16 @@
|
|
|
3952
3963
|
var numericFilters = requestBuilder._getNumericFilters(state, facet);
|
|
3953
3964
|
var tagFilters = requestBuilder._getTagFilters(state);
|
|
3954
3965
|
var additionalParams = {
|
|
3955
|
-
hitsPerPage:
|
|
3966
|
+
hitsPerPage: 0,
|
|
3956
3967
|
page: 0,
|
|
3957
|
-
attributesToRetrieve: [],
|
|
3958
|
-
attributesToHighlight: [],
|
|
3959
|
-
attributesToSnippet: [],
|
|
3960
|
-
tagFilters: tagFilters,
|
|
3961
3968
|
analytics: false,
|
|
3962
3969
|
clickAnalytics: false
|
|
3963
3970
|
};
|
|
3964
3971
|
|
|
3972
|
+
if (tagFilters.length > 0) {
|
|
3973
|
+
additionalParams.tagFilters = tagFilters;
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3965
3976
|
var hierarchicalFacet = state.getHierarchicalFacetByName(facet);
|
|
3966
3977
|
|
|
3967
3978
|
if (hierarchicalFacet) {
|
|
@@ -3982,7 +3993,7 @@
|
|
|
3982
3993
|
additionalParams.facetFilters = facetFilters;
|
|
3983
3994
|
}
|
|
3984
3995
|
|
|
3985
|
-
return merge_1({}, state.getQueryParams(), additionalParams);
|
|
3996
|
+
return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
|
|
3986
3997
|
},
|
|
3987
3998
|
|
|
3988
3999
|
/**
|
|
@@ -4175,17 +4186,17 @@
|
|
|
4175
4186
|
if (typeof maxFacetHits === 'number') {
|
|
4176
4187
|
searchForFacetSearchParameters.maxFacetHits = maxFacetHits;
|
|
4177
4188
|
}
|
|
4178
|
-
return merge_1(
|
|
4189
|
+
return sortObject(merge_1(
|
|
4179
4190
|
{},
|
|
4180
4191
|
requestBuilder._getHitsSearchParams(stateForSearchForFacetValues),
|
|
4181
4192
|
searchForFacetSearchParameters
|
|
4182
|
-
);
|
|
4193
|
+
));
|
|
4183
4194
|
}
|
|
4184
4195
|
};
|
|
4185
4196
|
|
|
4186
4197
|
var requestBuilder_1 = requestBuilder;
|
|
4187
4198
|
|
|
4188
|
-
var version = '3.
|
|
4199
|
+
var version = '3.10.0';
|
|
4189
4200
|
|
|
4190
4201
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
4191
4202
|
|
|
@@ -4505,20 +4516,51 @@
|
|
|
4505
4516
|
*/
|
|
4506
4517
|
AlgoliaSearchHelper.prototype.searchForFacetValues = function(facet, query, maxFacetHits, userState) {
|
|
4507
4518
|
var clientHasSFFV = typeof this.client.searchForFacetValues === 'function';
|
|
4519
|
+
var clientHasInitIndex = typeof this.client.initIndex === 'function';
|
|
4508
4520
|
if (
|
|
4509
4521
|
!clientHasSFFV &&
|
|
4510
|
-
|
|
4522
|
+
!clientHasInitIndex &&
|
|
4523
|
+
typeof this.client.search !== 'function'
|
|
4511
4524
|
) {
|
|
4512
4525
|
throw new Error(
|
|
4513
4526
|
'search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues'
|
|
4514
4527
|
);
|
|
4515
4528
|
}
|
|
4529
|
+
|
|
4516
4530
|
var state = this.state.setQueryParameters(userState || {});
|
|
4517
4531
|
var isDisjunctive = state.isDisjunctiveFacet(facet);
|
|
4518
4532
|
var algoliaQuery = requestBuilder_1.getSearchForFacetQuery(facet, query, maxFacetHits, state);
|
|
4519
4533
|
|
|
4520
4534
|
this._currentNbQueries++;
|
|
4521
4535
|
var self = this;
|
|
4536
|
+
var searchForFacetValuesPromise;
|
|
4537
|
+
// newer algoliasearch ^3.27.1 - ~4.0.0
|
|
4538
|
+
if (clientHasSFFV) {
|
|
4539
|
+
searchForFacetValuesPromise = this.client.searchForFacetValues([
|
|
4540
|
+
{indexName: state.index, params: algoliaQuery}
|
|
4541
|
+
]);
|
|
4542
|
+
// algoliasearch < 3.27.1
|
|
4543
|
+
} else if (clientHasInitIndex) {
|
|
4544
|
+
searchForFacetValuesPromise = this.client
|
|
4545
|
+
.initIndex(state.index)
|
|
4546
|
+
.searchForFacetValues(algoliaQuery);
|
|
4547
|
+
// algoliasearch ~5.0.0
|
|
4548
|
+
} else {
|
|
4549
|
+
// @MAJOR only use client.search
|
|
4550
|
+
delete algoliaQuery.facetName;
|
|
4551
|
+
searchForFacetValuesPromise = this.client
|
|
4552
|
+
.search([
|
|
4553
|
+
{
|
|
4554
|
+
type: 'facet',
|
|
4555
|
+
facet: facet,
|
|
4556
|
+
indexName: state.index,
|
|
4557
|
+
params: algoliaQuery
|
|
4558
|
+
}
|
|
4559
|
+
])
|
|
4560
|
+
.then(function processResponse(response) {
|
|
4561
|
+
return response.results[0];
|
|
4562
|
+
});
|
|
4563
|
+
}
|
|
4522
4564
|
|
|
4523
4565
|
this.emit('searchForFacetValues', {
|
|
4524
4566
|
state: state,
|
|
@@ -4526,10 +4568,6 @@
|
|
|
4526
4568
|
query: query
|
|
4527
4569
|
});
|
|
4528
4570
|
|
|
4529
|
-
var searchForFacetValuesPromise = clientHasSFFV
|
|
4530
|
-
? this.client.searchForFacetValues([{indexName: state.index, params: algoliaQuery}])
|
|
4531
|
-
: this.client.initIndex(state.index).searchForFacetValues(algoliaQuery);
|
|
4532
|
-
|
|
4533
4571
|
return searchForFacetValuesPromise.then(function addIsRefined(content) {
|
|
4534
4572
|
self._currentNbQueries--;
|
|
4535
4573
|
if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
|
|
@@ -8565,7 +8603,7 @@
|
|
|
8565
8603
|
instantSearchInstance.renderState = _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState), {}, _defineProperty({}, parentIndexName, _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState[parentIndexName]), renderState)));
|
|
8566
8604
|
}
|
|
8567
8605
|
|
|
8568
|
-
var version$1 = '4.
|
|
8606
|
+
var version$1 = '4.43.1';
|
|
8569
8607
|
|
|
8570
8608
|
var NAMESPACE = 'ais';
|
|
8571
8609
|
var component = function component(componentName) {
|
|
@@ -10439,12 +10477,22 @@
|
|
|
10439
10477
|
|
|
10440
10478
|
mainHelper.on('error', function (_ref4) {
|
|
10441
10479
|
var error = _ref4.error;
|
|
10442
|
-
|
|
10480
|
+
|
|
10481
|
+
if (!(error instanceof Error)) {
|
|
10482
|
+
// typescript lies here, error is in some cases { name: string, message: string }
|
|
10483
|
+
var err = error;
|
|
10484
|
+
error = Object.keys(err).reduce(function (acc, key) {
|
|
10485
|
+
acc[key] = err[key];
|
|
10486
|
+
return acc;
|
|
10487
|
+
}, new Error(err.message));
|
|
10488
|
+
} // If an error is emitted, it is re-thrown by events. In previous versions
|
|
10443
10489
|
// we emitted {error}, which is thrown as:
|
|
10444
10490
|
// "Uncaught, unspecified \"error\" event. ([object Object])"
|
|
10445
10491
|
// To avoid breaking changes, we make the error available in both
|
|
10446
10492
|
// `error` and `error.error`
|
|
10447
10493
|
// @MAJOR emit only error
|
|
10494
|
+
|
|
10495
|
+
|
|
10448
10496
|
error.error = error;
|
|
10449
10497
|
|
|
10450
10498
|
_this3.emit('error', error);
|
|
@@ -13574,7 +13622,7 @@
|
|
|
13574
13622
|
var maxValuesPerFacet = facetResults.length;
|
|
13575
13623
|
var maxDecimalPlaces = getFacetsMaxDecimalPlaces(facetResults);
|
|
13576
13624
|
var maxFacets = Math.pow(10, maxDecimalPlaces) * max;
|
|
13577
|
-
_warning(maxFacets <= maxValuesPerFacet, getFacetValuesWarningMessage({
|
|
13625
|
+
_warning(maxFacets <= maxValuesPerFacet || Boolean(results.__isArtificial), getFacetValuesWarningMessage({
|
|
13578
13626
|
maxDecimalPlaces: maxDecimalPlaces,
|
|
13579
13627
|
maxFacets: maxFacets,
|
|
13580
13628
|
maxValuesPerFacet: maxValuesPerFacet
|