Skip to content

Commit

Permalink
fix(methods): remove deprecated helper methods (#6402)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Haroenv committed Oct 21, 2024
1 parent 5eb908d commit 47e48be
Show file tree
Hide file tree
Showing 35 changed files with 214 additions and 506 deletions.
4 changes: 2 additions & 2 deletions packages/algoliasearch-helper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ angular.module('searchApp', ['ngSanitize', 'algoliasearch'])
$scope.content = event.results;
});
});
$scope.toggleRefine = function($event, facet, value) {
$scope.toggleFacetRefinement = function($event, facet, value) {
$event.preventDefault();
$scope.helper.toggleRefine(facet, value).search();
$scope.helper.toggleFacetRefinement(facet, value).search();
};
$scope.$watch('q', function(q) {
$scope.helper.setQuery(q).search();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,6 @@ The facet exclusions are not a type of facets by themselves, they are conjunctiv

{{> jsdoc jsdoc/helper/hasRefinements}}

{{> jsdoc jsdoc/helper/isExcluded}}

### Numeric filters

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

{{> jsdoc jsdoc/helper/toggleTag}}

{{> jsdoc jsdoc/helper/hasTag}}

{{> jsdoc jsdoc/helper/getTags}}

### State management
Expand Down
66 changes: 0 additions & 66 deletions packages/algoliasearch-helper/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,26 +237,14 @@ declare namespace algoliasearchHelper {
setIndex(name: string): this;

addDisjunctiveFacetRefinement(facet: string, value: string): this;
/**
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addDisjunctiveFacetRefinement}
*/
addDisjunctiveRefine(facet: string, value: string): this;
addHierarchicalFacetRefinement(facet: string, path: string): this;
addNumericRefinement(
facet: string,
operator?: SearchParameters.Operator,
value?: number | number[]
): this;
addFacetRefinement(facet: string, value: string): this;
/**
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addFacetRefinement}
*/
addRefine: AlgoliaSearchHelper['addFacetRefinement'];
addFacetExclusion(facet: string, value: string): this;
/**
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addFacetExclusion}
*/
addExclude: AlgoliaSearchHelper['addFacetExclusion'];
addTag(tag: string): this;
addFrequentlyBoughtTogether(
params: RecommendParametersWithId<FrequentlyBoughtTogetherQuery>
Expand All @@ -279,49 +267,21 @@ declare namespace algoliasearchHelper {
value?: number | number[]
): this;
removeDisjunctiveFacetRefinement(facet: string, value?: string): this;
/**
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeDisjunctiveFacetRefinement}
*/
removeDisjunctiveRefine(facet: string, value?: string): this;
removeHierarchicalFacetRefinement(facet: string): this;
removeFacetRefinement(facet: string, value?: string): this;
/**
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeFacetRefinement}
*/
removeRefine(facet: string, value: string): this;
removeFacetExclusion(facet: string, value: string): this;
/**
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeFacetExclusion}
*/
removeExclude(facet: string, value: string): this;
removeTag(value: string): this;
removeFrequentlyBoughtTogether(id: number): this;
removeRelatedProducts(id: number): this;
removeTrendingItems(id: number): this;
removeTrendingFacets(id: number): this;
removeLookingSimilar(id: number): this;
toggleFacetExclusion(facet: string, value: string): this;
/**
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#toggleFacetExclusion}
*/
toggleExclude(facet: string, value: string): this;
toggleFacetRefinement(facet: string, value: string): this;
/**
* @deprecated since version 2.19.0, see {@link AlgoliaSearchHelper#toggleFacetRefinement}
*/
toggleRefinement(facet: string, value: string): this;
/**
* @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#toggleFacetRefinement}
*/
toggleRefine(facet: string, value: string): this;
toggleTag(tag: string): this;
nextPage(): this;
previousPage(): this;
setPage(page: number): this;
/**
* @deprecated
*/
setCurrentPage(page: number): this;
setQueryParameter<SearchParameter extends keyof PlainSearchParameters>(
parameter: SearchParameter,
value: PlainSearchParameters[SearchParameter]
Expand All @@ -338,30 +298,12 @@ declare namespace algoliasearchHelper {

overrideStateWithoutTriggeringChangeEvent: AlgoliaSearchHelper['setState'];
hasRefinements(facet: string): boolean;
isExcluded: SearchParameters['isExcludeRefined'];
/**
* @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasRefinements}
*/
isDisjunctiveRefined: SearchParameters['isDisjunctiveFacetRefined'];
hasTag: SearchParameters['isTagRefined'];
/**
* @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasTag}
*/
isTagRefined: SearchParameters['isTagRefined'];
getIndex(): string;
/**
* @deprecated
*/
getCurrentPage(): number;
getPage(): number;
getTags(): string[];
getRefinements(facetName: string): any[];
getNumericRefinement: SearchParameters['getNumericRefinement'];
getHierarchicalFacetBreadcrumb: SearchParameters['getHierarchicalFacetBreadcrumb'];
/**
* @deprecated
*/
containsRefinement(...any: any[]): any;
clearCache(): this;
setClient(client: SearchClient): this;
getClient(): SearchClient;
Expand Down Expand Up @@ -1382,14 +1324,6 @@ declare namespace algoliasearchHelper {
options?: SearchResultsOptions
);

/**
* Get a facet object with its name
* @deprecated
* @param name name of the faceted attribute
* @return the facet object
*/
getFacetByName(name: string): SearchResults.Facet;

/**
* Get a the list of values for a given facet attribute. Those values are sorted
* refinement first, descending count (bigger value on top), and name ascending
Expand Down
16 changes: 2 additions & 14 deletions packages/algoliasearch-helper/src/SearchParameters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,18 +1049,6 @@ SearchParameters.prototype = {

return this.setQueryParameters(modification);
},
/**
* Generic toggle refinement method to use with facet, disjunctive facets
* and hierarchical facets
* @param {string} facet the facet to refine
* @param {string} value the associated value
* @return {SearchParameters} new instance
* @throws will throw an error if the facet is not declared in the settings of the helper
* @deprecated since version 2.19.0, see {@link SearchParameters#toggleFacetRefinement}
*/
toggleRefinement: function toggleRefinement(facet, value) {
return this.toggleFacetRefinement(facet, value);
},
/**
* Generic toggle refinement method to use with facet, disjunctive facets
* and hierarchical facets
Expand Down Expand Up @@ -1190,11 +1178,11 @@ SearchParameters.prototype = {
this.hierarchicalFacetsRefinements[facet] !== undefined &&
this.hierarchicalFacetsRefinements[facet].length > 0 &&
// remove current refinement:
// refinement was 'beer > IPA', call is toggleRefine('beer > IPA'), refinement should be `beer`
// refinement was 'beer > IPA', call is toggleFacetRefinement('beer > IPA'), refinement should be `beer`
(this.hierarchicalFacetsRefinements[facet][0] === value ||
// remove a parent refinement of the current refinement:
// - refinement was 'beer > IPA > Flying dog'
// - call is toggleRefine('beer > IPA')
// - call is toggleFacetRefinement('beer > IPA')
// - refinement should be `beer`
this.hierarchicalFacetsRefinements[facet][0].indexOf(
value + separator
Expand Down
18 changes: 0 additions & 18 deletions packages/algoliasearch-helper/src/SearchResults/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,24 +660,6 @@ function SearchResults(state, results, options) {
this._state = state;
}

/**
* Get a facet object with its name
* @deprecated
* @param {string} name name of the faceted attribute
* @return {SearchResults.Facet} the facet object
*/
SearchResults.prototype.getFacetByName = function (name) {
function predicate(facet) {
return facet.name === name;
}

return (
find(this.facets, predicate) ||
find(this.disjunctiveFacets, predicate) ||
find(this.hierarchicalFacets, predicate)
);
};

/**
* Get the facet values of a specified attribute from a SearchResults object.
* @private
Expand Down
Loading

0 comments on commit 47e48be

Please sign in to comment.