@reactionary/provider-algolia 0.3.3 → 0.3.5
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/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/provider-algolia",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@reactionary/core": "0.3.
|
|
8
|
-
"algoliasearch": "^5.
|
|
7
|
+
"@reactionary/core": "0.3.5",
|
|
8
|
+
"algoliasearch": "^5.48.0",
|
|
9
9
|
"zod": "4.1.9"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProductRecommendationsProvider
|
|
3
3
|
} from "@reactionary/core";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
liteClient
|
|
6
|
+
} from "algoliasearch/lite";
|
|
5
7
|
class AlgoliaProductRecommendationsProvider extends ProductRecommendationsProvider {
|
|
6
8
|
constructor(config, cache, context) {
|
|
7
9
|
super(cache, context);
|
|
8
10
|
this.config = config;
|
|
9
|
-
|
|
10
|
-
getRecommendClient() {
|
|
11
|
-
return recommendClient(this.config.appId, this.config.apiKey);
|
|
11
|
+
this.client = liteClient(this.config.appId, this.config.apiKey);
|
|
12
12
|
}
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
14
|
getRecommendationThreshold(_algorithm) {
|
|
@@ -26,9 +26,8 @@ class AlgoliaProductRecommendationsProvider extends ProductRecommendationsProvid
|
|
|
26
26
|
* Get frequently bought together recommendations using Algolia Recommend
|
|
27
27
|
*/
|
|
28
28
|
async getFrequentlyBoughtTogetherRecommendations(query) {
|
|
29
|
-
const client = this.getRecommendClient();
|
|
30
29
|
try {
|
|
31
|
-
const response = await client.getRecommendations({
|
|
30
|
+
const response = await this.client.getRecommendations({
|
|
32
31
|
requests: [
|
|
33
32
|
{
|
|
34
33
|
indexName: this.config.indexName,
|
|
@@ -56,9 +55,8 @@ class AlgoliaProductRecommendationsProvider extends ProductRecommendationsProvid
|
|
|
56
55
|
* Get similar product recommendations using Algolia Recommend
|
|
57
56
|
*/
|
|
58
57
|
async getSimilarProductsRecommendations(query) {
|
|
59
|
-
const client = this.getRecommendClient();
|
|
60
58
|
try {
|
|
61
|
-
const response = await client.getRecommendations({
|
|
59
|
+
const response = await this.client.getRecommendations({
|
|
62
60
|
requests: [
|
|
63
61
|
{
|
|
64
62
|
indexName: this.config.indexName,
|
|
@@ -86,9 +84,8 @@ class AlgoliaProductRecommendationsProvider extends ProductRecommendationsProvid
|
|
|
86
84
|
* Get related product recommendations using Algolia Recommend
|
|
87
85
|
*/
|
|
88
86
|
async getRelatedProductsRecommendations(query) {
|
|
89
|
-
const client = this.getRecommendClient();
|
|
90
87
|
try {
|
|
91
|
-
const response = await client.getRecommendations({
|
|
88
|
+
const response = await this.client.getRecommendations({
|
|
92
89
|
requests: [
|
|
93
90
|
{
|
|
94
91
|
indexName: this.config.indexName,
|
|
@@ -116,9 +113,8 @@ class AlgoliaProductRecommendationsProvider extends ProductRecommendationsProvid
|
|
|
116
113
|
* Get trending in category recommendations using Algolia Recommend
|
|
117
114
|
*/
|
|
118
115
|
async getTrendingInCategoryRecommendations(query) {
|
|
119
|
-
const client = this.getRecommendClient();
|
|
120
116
|
try {
|
|
121
|
-
const response = await client.getRecommendations({
|
|
117
|
+
const response = await this.client.getRecommendations({
|
|
122
118
|
requests: [
|
|
123
119
|
{
|
|
124
120
|
indexName: this.config.indexName,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Cache, ProductRecommendationsProvider, type ProductRecommendation, type ProductRecommendationAlgorithmFrequentlyBoughtTogetherQuery, type ProductRecommendationAlgorithmSimilarProductsQuery, type ProductRecommendationAlgorithmRelatedProductsQuery, type ProductRecommendationAlgorithmTrendingInCategoryQuery, type RequestContext, type ProductRecommendationsQuery } from '@reactionary/core';
|
|
2
|
-
import { type RecommendationsResults, type
|
|
2
|
+
import { type RecommendationsResults, type RecommendSearchParams, type LiteClient } from 'algoliasearch/lite';
|
|
3
3
|
import type { AlgoliaConfiguration } from '../schema/configuration.schema.js';
|
|
4
4
|
import type { AlgoliaProductRecommendationIdentifier } from '../schema/product-recommendation.schema.js';
|
|
5
5
|
interface AlgoliaRecommendHit {
|
|
@@ -18,8 +18,8 @@ interface AlgoliaRecommendHit {
|
|
|
18
18
|
*/
|
|
19
19
|
export declare class AlgoliaProductRecommendationsProvider extends ProductRecommendationsProvider {
|
|
20
20
|
protected config: AlgoliaConfiguration;
|
|
21
|
+
protected client: LiteClient;
|
|
21
22
|
constructor(config: AlgoliaConfiguration, cache: Cache, context: RequestContext);
|
|
22
|
-
protected getRecommendClient(): RecommendClient;
|
|
23
23
|
protected getRecommendationThreshold(_algorithm: string): number;
|
|
24
24
|
protected getQueryParametersForRecommendations(algorithm: string): RecommendSearchParams;
|
|
25
25
|
/**
|