Skip to content

Commit c507965

Browse files
committed
fix(methods): remove deprecated helper methods (#6402)
* fix(methods): remove addDisjunctiveRefine BREAKING CHANGE: addDisjunctiveRefine is replaced with addDisjunctiveFacetRefinement * fix(methods): remove removeDisjunctiveRefine BREAKING CHANGE: removeDisjunctiveRefine is replaced with removeDisjunctiveFacetRefinement * fix(methods): remove addRefine BREAKING CHANGE: addRefine is replaced with addFacetRefinement * fix(methods): remove addExclude BREAKING CHANGE: addExclude is replaced with addFacetExclusion * fix(methods): remove removeRefine BREAKING CHANGE: removeRefine is replaced with removeFacetRefinement * fix(methods): remove removeExclude BREAKING CHANGE: removeExclude is replaced with removeFacetExclusion * fix(methods): remove toggleExclude BREAKING CHANGE: toggleExclude is replaced with toggleFacetExclusion * fix(methods): remove toggleRefine BREAKING CHANGE: toggleRefine is replaced with toggleFacetRefinement * fix(methods): remove toggleRefinement BREAKING CHANGE: toggleRefinement is replaced with toggleFacetRefinement * fix(methods): remove isExcluded, isDisjunctiveRefined, hasTag, isTagRefined These methods are available from the SearchParameters / helper.state instead BREAKING CHANGE: replace helper.isExcluded with helper.state.isExcludeRefined BREAKING CHANGE: replace helper.isDisjunctiveRefined with helper.state.isDisjunctiveFacetRefined BREAKING CHANGE: replace helper.hasTag with helper.state.isTagRefined BREAKING CHANGE: replace helper.isTagRefined with helper.state.isTagRefined * fix(methods): remove setCurrentPage BREAKING CHANGE: setCurrentPage is replaced with setPage * fix(methods): remove getCurrentPage BREAKING CHANGE: getCurrentPage is replaced with getPage * fix(methods): remove getFacetByName BREAKING CHANGE: getFacetByName (on search results) is replaced by calling results.xxxfacets.find(f => f.name === name) yourself (where xxxfacets is facets, disjunctiveFacets or hierarchicalFacets depending on your use case) * fix(methods): remove containsRefinement BREAKING CHANGE: containsRefinement is removed. Instead check the length of the arguments directly.
1 parent 342d1ef commit c507965

35 files changed

+214
-506
lines changed

packages/algoliasearch-helper/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ angular.module('searchApp', ['ngSanitize', 'algoliasearch'])
111111
$scope.content = event.results;
112112
});
113113
});
114-
$scope.toggleRefine = function($event, facet, value) {
114+
$scope.toggleFacetRefinement = function($event, facet, value) {
115115
$event.preventDefault();
116-
$scope.helper.toggleRefine(facet, value).search();
116+
$scope.helper.toggleFacetRefinement(facet, value).search();
117117
};
118118
$scope.$watch('q', function(q) {
119119
$scope.helper.setQuery(q).search();

packages/algoliasearch-helper/documentation-src/content/reference.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,6 @@ The facet exclusions are not a type of facets by themselves, they are conjunctiv
385385

386386
{{> jsdoc jsdoc/helper/hasRefinements}}
387387

388-
{{> jsdoc jsdoc/helper/isExcluded}}
389-
390388
### Numeric filters
391389

392390
The numeric filters don't require any configuration. However they require that the attribute is stored as a number in Algolia.
@@ -409,8 +407,6 @@ The tag filters don't require any configuration. However, they require to be sto
409407

410408
{{> jsdoc jsdoc/helper/toggleTag}}
411409

412-
{{> jsdoc jsdoc/helper/hasTag}}
413-
414410
{{> jsdoc jsdoc/helper/getTags}}
415411

416412
### State management

packages/algoliasearch-helper/index.d.ts

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -237,26 +237,14 @@ declare namespace algoliasearchHelper {
237237
setIndex(name: string): this;
238238

239239
addDisjunctiveFacetRefinement(facet: string, value: string): this;
240-
/**
241-
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addDisjunctiveFacetRefinement}
242-
*/
243-
addDisjunctiveRefine(facet: string, value: string): this;
244240
addHierarchicalFacetRefinement(facet: string, path: string): this;
245241
addNumericRefinement(
246242
facet: string,
247243
operator?: SearchParameters.Operator,
248244
value?: number | number[]
249245
): this;
250246
addFacetRefinement(facet: string, value: string): this;
251-
/**
252-
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addFacetRefinement}
253-
*/
254-
addRefine: AlgoliaSearchHelper['addFacetRefinement'];
255247
addFacetExclusion(facet: string, value: string): this;
256-
/**
257-
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addFacetExclusion}
258-
*/
259-
addExclude: AlgoliaSearchHelper['addFacetExclusion'];
260248
addTag(tag: string): this;
261249
addFrequentlyBoughtTogether(
262250
params: RecommendParametersWithId<FrequentlyBoughtTogetherQuery>
@@ -279,49 +267,21 @@ declare namespace algoliasearchHelper {
279267
value?: number | number[]
280268
): this;
281269
removeDisjunctiveFacetRefinement(facet: string, value?: string): this;
282-
/**
283-
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeDisjunctiveFacetRefinement}
284-
*/
285-
removeDisjunctiveRefine(facet: string, value?: string): this;
286270
removeHierarchicalFacetRefinement(facet: string): this;
287271
removeFacetRefinement(facet: string, value?: string): this;
288-
/**
289-
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeFacetRefinement}
290-
*/
291-
removeRefine(facet: string, value: string): this;
292272
removeFacetExclusion(facet: string, value: string): this;
293-
/**
294-
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeFacetExclusion}
295-
*/
296-
removeExclude(facet: string, value: string): this;
297273
removeTag(value: string): this;
298274
removeFrequentlyBoughtTogether(id: number): this;
299275
removeRelatedProducts(id: number): this;
300276
removeTrendingItems(id: number): this;
301277
removeTrendingFacets(id: number): this;
302278
removeLookingSimilar(id: number): this;
303279
toggleFacetExclusion(facet: string, value: string): this;
304-
/**
305-
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#toggleFacetExclusion}
306-
*/
307-
toggleExclude(facet: string, value: string): this;
308280
toggleFacetRefinement(facet: string, value: string): this;
309-
/**
310-
* @deprecated since version 2.19.0, see {@link AlgoliaSearchHelper#toggleFacetRefinement}
311-
*/
312-
toggleRefinement(facet: string, value: string): this;
313-
/**
314-
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#toggleFacetRefinement}
315-
*/
316-
toggleRefine(facet: string, value: string): this;
317281
toggleTag(tag: string): this;
318282
nextPage(): this;
319283
previousPage(): this;
320284
setPage(page: number): this;
321-
/**
322-
* @deprecated
323-
*/
324-
setCurrentPage(page: number): this;
325285
setQueryParameter<SearchParameter extends keyof PlainSearchParameters>(
326286
parameter: SearchParameter,
327287
value: PlainSearchParameters[SearchParameter]
@@ -338,30 +298,12 @@ declare namespace algoliasearchHelper {
338298

339299
overrideStateWithoutTriggeringChangeEvent: AlgoliaSearchHelper['setState'];
340300
hasRefinements(facet: string): boolean;
341-
isExcluded: SearchParameters['isExcludeRefined'];
342-
/**
343-
* @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasRefinements}
344-
*/
345-
isDisjunctiveRefined: SearchParameters['isDisjunctiveFacetRefined'];
346-
hasTag: SearchParameters['isTagRefined'];
347-
/**
348-
* @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasTag}
349-
*/
350-
isTagRefined: SearchParameters['isTagRefined'];
351301
getIndex(): string;
352-
/**
353-
* @deprecated
354-
*/
355-
getCurrentPage(): number;
356302
getPage(): number;
357303
getTags(): string[];
358304
getRefinements(facetName: string): any[];
359305
getNumericRefinement: SearchParameters['getNumericRefinement'];
360306
getHierarchicalFacetBreadcrumb: SearchParameters['getHierarchicalFacetBreadcrumb'];
361-
/**
362-
* @deprecated
363-
*/
364-
containsRefinement(...any: any[]): any;
365307
clearCache(): this;
366308
setClient(client: SearchClient): this;
367309
getClient(): SearchClient;
@@ -1382,14 +1324,6 @@ declare namespace algoliasearchHelper {
13821324
options?: SearchResultsOptions
13831325
);
13841326

1385-
/**
1386-
* Get a facet object with its name
1387-
* @deprecated
1388-
* @param name name of the faceted attribute
1389-
* @return the facet object
1390-
*/
1391-
getFacetByName(name: string): SearchResults.Facet;
1392-
13931327
/**
13941328
* Get a the list of values for a given facet attribute. Those values are sorted
13951329
* refinement first, descending count (bigger value on top), and name ascending

packages/algoliasearch-helper/src/SearchParameters/index.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,18 +1049,6 @@ SearchParameters.prototype = {
10491049

10501050
return this.setQueryParameters(modification);
10511051
},
1052-
/**
1053-
* Generic toggle refinement method to use with facet, disjunctive facets
1054-
* and hierarchical facets
1055-
* @param {string} facet the facet to refine
1056-
* @param {string} value the associated value
1057-
* @return {SearchParameters} new instance
1058-
* @throws will throw an error if the facet is not declared in the settings of the helper
1059-
* @deprecated since version 2.19.0, see {@link SearchParameters#toggleFacetRefinement}
1060-
*/
1061-
toggleRefinement: function toggleRefinement(facet, value) {
1062-
return this.toggleFacetRefinement(facet, value);
1063-
},
10641052
/**
10651053
* Generic toggle refinement method to use with facet, disjunctive facets
10661054
* and hierarchical facets
@@ -1190,11 +1178,11 @@ SearchParameters.prototype = {
11901178
this.hierarchicalFacetsRefinements[facet] !== undefined &&
11911179
this.hierarchicalFacetsRefinements[facet].length > 0 &&
11921180
// remove current refinement:
1193-
// refinement was 'beer > IPA', call is toggleRefine('beer > IPA'), refinement should be `beer`
1181+
// refinement was 'beer > IPA', call is toggleFacetRefinement('beer > IPA'), refinement should be `beer`
11941182
(this.hierarchicalFacetsRefinements[facet][0] === value ||
11951183
// remove a parent refinement of the current refinement:
11961184
// - refinement was 'beer > IPA > Flying dog'
1197-
// - call is toggleRefine('beer > IPA')
1185+
// - call is toggleFacetRefinement('beer > IPA')
11981186
// - refinement should be `beer`
11991187
this.hierarchicalFacetsRefinements[facet][0].indexOf(
12001188
value + separator

packages/algoliasearch-helper/src/SearchResults/index.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -660,24 +660,6 @@ function SearchResults(state, results, options) {
660660
this._state = state;
661661
}
662662

663-
/**
664-
* Get a facet object with its name
665-
* @deprecated
666-
* @param {string} name name of the faceted attribute
667-
* @return {SearchResults.Facet} the facet object
668-
*/
669-
SearchResults.prototype.getFacetByName = function (name) {
670-
function predicate(facet) {
671-
return facet.name === name;
672-
}
673-
674-
return (
675-
find(this.facets, predicate) ||
676-
find(this.disjunctiveFacets, predicate) ||
677-
find(this.hierarchicalFacets, predicate)
678-
);
679-
};
680-
681663
/**
682664
* Get the facet values of a specified attribute from a SearchResults object.
683665
* @private

0 commit comments

Comments
 (0)