Skip to content

Commit

Permalink
feat(search): fetch recommendations directly from algoliasearch (#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhayab committed Mar 6, 2024
1 parent 252228a commit 8087b28
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -98,7 +98,7 @@
"bundlesize": [
{
"path": "packages/algoliasearch/dist/algoliasearch.umd.js",
"maxSize": "8.2KB"
"maxSize": "8.4KB"
},
{
"path": "packages/algoliasearch/dist/algoliasearch-lite.umd.js",
Expand Down
1 change: 1 addition & 0 deletions packages/algoliasearch/package.json
Expand Up @@ -35,6 +35,7 @@
"@algolia/client-search": "4.22.1",
"@algolia/logger-common": "4.22.1",
"@algolia/logger-console": "4.22.1",
"@algolia/recommend": "4.22.1",
"@algolia/requester-browser-xhr": "4.22.1",
"@algolia/requester-common": "4.22.1",
"@algolia/requester-node-http": "4.22.1",
Expand Down
26 changes: 26 additions & 0 deletions packages/algoliasearch/src/builds/browser.ts
Expand Up @@ -190,6 +190,16 @@ import {
} from '@algolia/client-search';
import { LogLevelEnum } from '@algolia/logger-common';
import { createConsoleLogger } from '@algolia/logger-console';
import {
getFrequentlyBoughtTogether,
getLookingSimilar,
getRecommendations,
getRecommendedForYou,
getRelatedProducts,
getTrendingFacets,
getTrendingItems,
WithRecommendMethods,
} from '@algolia/recommend';
import { createBrowserXhrRequester } from '@algolia/requester-browser-xhr';
import { createUserAgent, Request, RequestOptions } from '@algolia/transporter';

Expand Down Expand Up @@ -343,6 +353,13 @@ export default function algoliasearch(

return initPersonalization()(clientOptions);
},
getRecommendations,
getFrequentlyBoughtTogether,
getLookingSimilar,
getRecommendedForYou,
getRelatedProducts,
getTrendingFacets,
getTrendingItems,
},
});
}
Expand Down Expand Up @@ -689,6 +706,15 @@ export type SearchClient = BaseSearchClient & {
* @deprecated Use `initPersonalization` instead.
*/
readonly initRecommendation: (options?: InitPersonalizationOptions) => PersonalizationClient;
readonly getRecommendations: WithRecommendMethods<BaseSearchClient>['getRecommendations'];
readonly getFrequentlyBoughtTogether: WithRecommendMethods<
BaseSearchClient
>['getFrequentlyBoughtTogether'];
readonly getLookingSimilar: WithRecommendMethods<BaseSearchClient>['getLookingSimilar'];
readonly getRecommendedForYou: WithRecommendMethods<BaseSearchClient>['getRecommendedForYou'];
readonly getRelatedProducts: WithRecommendMethods<BaseSearchClient>['getRelatedProducts'];
readonly getTrendingFacets: WithRecommendMethods<BaseSearchClient>['getTrendingFacets'];
readonly getTrendingItems: WithRecommendMethods<BaseSearchClient>['getTrendingItems'];
};

export * from '../types';
3 changes: 3 additions & 0 deletions packages/algoliasearch/src/builds/browserLite.ts
Expand Up @@ -25,6 +25,7 @@ import {
} from '@algolia/client-search';
import { LogLevelEnum } from '@algolia/logger-common';
import { createConsoleLogger } from '@algolia/logger-console';
import { getRecommendations, WithRecommendMethods } from '@algolia/recommend';
import { createBrowserXhrRequester } from '@algolia/requester-browser-xhr';
import { createUserAgent, Request, RequestOptions } from '@algolia/transporter';

Expand Down Expand Up @@ -74,6 +75,7 @@ export default function algoliasearch(
methods: { search, searchForFacetValues, findAnswers },
});
},
getRecommendations,
},
});
}
Expand Down Expand Up @@ -115,6 +117,7 @@ export type SearchClient = BaseSearchClient & {
request: Request,
requestOptions?: RequestOptions
) => Readonly<Promise<TResponse>>;
readonly getRecommendations: WithRecommendMethods<BaseSearchClient>['getRecommendations'];
};

export { WithoutCredentials, AlgoliaSearchOptions } from '../types';
26 changes: 26 additions & 0 deletions packages/algoliasearch/src/builds/node.ts
Expand Up @@ -191,6 +191,16 @@ import {
waitTask,
} from '@algolia/client-search';
import { createNullLogger } from '@algolia/logger-common';
import {
getFrequentlyBoughtTogether,
getLookingSimilar,
getRecommendations,
getRecommendedForYou,
getRelatedProducts,
getTrendingFacets,
getTrendingItems,
WithRecommendMethods,
} from '@algolia/recommend';
import { Destroyable } from '@algolia/requester-common';
import { createNodeHttpRequester } from '@algolia/requester-node-http';
import { createUserAgent, Request, RequestOptions } from '@algolia/transporter';
Expand Down Expand Up @@ -346,6 +356,13 @@ export default function algoliasearch(

return initPersonalization()(clientOptions);
},
getRecommendations,
getFrequentlyBoughtTogether,
getLookingSimilar,
getRecommendedForYou,
getRelatedProducts,
getTrendingFacets,
getTrendingItems,
},
});
}
Expand Down Expand Up @@ -697,6 +714,15 @@ export type SearchClient = BaseSearchClient & {
* @deprecated Use `initPersonalization` instead.
*/
readonly initRecommendation: (options?: InitPersonalizationOptions) => PersonalizationClient;
readonly getRecommendations: WithRecommendMethods<BaseSearchClient>['getRecommendations'];
readonly getFrequentlyBoughtTogether: WithRecommendMethods<
BaseSearchClient
>['getFrequentlyBoughtTogether'];
readonly getLookingSimilar: WithRecommendMethods<BaseSearchClient>['getLookingSimilar'];
readonly getRecommendedForYou: WithRecommendMethods<BaseSearchClient>['getRecommendedForYou'];
readonly getRelatedProducts: WithRecommendMethods<BaseSearchClient>['getRelatedProducts'];
readonly getTrendingFacets: WithRecommendMethods<BaseSearchClient>['getTrendingFacets'];
readonly getTrendingItems: WithRecommendMethods<BaseSearchClient>['getTrendingItems'];
} & Destroyable;

export * from '../types';

0 comments on commit 8087b28

Please sign in to comment.