Files
est-frame/node_modules/@algolia/recommend/dist/recommend.d.ts
2025-10-22 05:38:27 +00:00

263 lines
9.9 KiB
TypeScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { AuthModeType } from '@algolia/client-common';
import { ClientTransporterOptions } from '@algolia/client-common';
import { Destroyable } from '@algolia/requester-common';
import { RecommendSearchOptions as RecommendSearchOptions_2 } from '@algolia/recommend';
import { RequestOptions } from '@algolia/transporter';
import { SearchOptions } from '@algolia/client-search';
import { SearchResponse } from '@algolia/client-search';
import { Transporter } from '@algolia/transporter';
export declare type BaseRecommendClient = {
/**
* The application id.
*/
readonly appId: string;
/**
* The underlying transporter.
*/
readonly transporter: Transporter;
/**
* Mutates the transporter, adding the given user agent.
*/
readonly addAlgoliaAgent: (segment: string, version?: string) => void;
/**
* Clears both requests and responses caches.
*/
readonly clearCache: () => Readonly<Promise<void>>;
};
export declare type FrequentlyBoughtTogetherQuery = Omit<RecommendationsQuery, 'model' | 'fallbackParameters'>;
declare type GetFrequentlyBoughtTogether = (base: BaseRecommendClient) => WithRecommendMethods<BaseRecommendClient>['getFrequentlyBoughtTogether'];
export declare const getFrequentlyBoughtTogether: GetFrequentlyBoughtTogether;
declare type GetLookingSimilar = (base: BaseRecommendClient) => WithRecommendMethods<BaseRecommendClient>['getLookingSimilar'];
export declare const getLookingSimilar: GetLookingSimilar;
declare type GetRecommendations = (base: BaseRecommendClient) => WithRecommendMethods<BaseRecommendClient>['getRecommendations'];
export declare const getRecommendations: GetRecommendations;
declare type GetRecommendedForYou = (base: BaseRecommendClient) => WithRecommendMethods<BaseRecommendClient>['getRecommendedForYou'];
export declare const getRecommendedForYou: GetRecommendedForYou;
declare type GetRelatedProducts = (base: BaseRecommendClient) => WithRecommendMethods<BaseRecommendClient>['getRelatedProducts'];
export declare const getRelatedProducts: GetRelatedProducts;
declare type GetTrendingFacets = (base: BaseRecommendClient) => WithRecommendMethods<BaseRecommendClient>['getTrendingFacets'];
export declare const getTrendingFacets: GetTrendingFacets;
declare type GetTrendingItems = (base: BaseRecommendClient) => WithRecommendMethods<BaseRecommendClient>['getTrendingItems'];
export declare const getTrendingItems: GetTrendingItems;
export declare type LookingSimilarQuery = Omit<RecommendationsQuery, 'model'>;
declare function recommend(appId: string, apiKey: string, options?: RecommendOptions): RecommendClient;
declare namespace recommend {
var version: string;
}
export default recommend;
export declare type RecommendationsQuery = {
/**
* The name of the target index.
*/
readonly indexName: string;
/**
* The name of the Recommendation model to use.
*/
readonly model: 'related-products' | 'bought-together' | 'looking-similar';
/**
* The `objectID` of the item to get recommendations for.
*/
readonly objectID: string;
/**
* Threshold for the recommendations confidence score (between 0 and 100). Only recommendations with a greater score are returned.
*/
readonly threshold?: number;
/**
* How many recommendations to retrieve.
*/
readonly maxRecommendations?: number;
/**
* List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
*/
readonly queryParameters?: RecommendSearchOptions;
/**
* List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
*
* Additional filters to use as fallback when there arent enough recommendations.
*/
readonly fallbackParameters?: RecommendSearchOptions;
};
export declare type RecommendClient = WithRecommendMethods<BaseRecommendClient> & Destroyable;
export declare type RecommendClientOptions = {
/**
* The application id.
*/
readonly appId: string;
/**
* The api key.
*/
readonly apiKey: string;
/**
* The auth mode type. In browser environments credentials may
* be passed within the headers.
*/
readonly authMode?: AuthModeType;
};
/**
* The parameters used for `getRecommendedForYou` method.
*/
export declare type RecommendedForYouParams = Omit<RecommendedForYouQuery, 'model'>;
export declare type RecommendedForYouQuery = Omit<RecommendationsQuery, 'model' | 'objectID' | 'queryParameters'> & {
readonly model: 'recommended-for-you';
/**
* List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
*/
readonly queryParameters: Omit<RecommendSearchOptions, 'userToken'> & {
/**
* A user identifier.
* Format: alpha numeric string [a-zA-Z0-9_-]
* Length: between 1 and 64 characters.
*/
readonly userToken: string;
};
};
export declare type RecommendModel = 'related-products' | 'bought-together' | 'looking-similar' | 'recommended-for-you' | TrendingModel;
export declare type RecommendOptions = Partial<ClientTransporterOptions>;
export declare type RecommendQueriesResponse<TObject> = {
/**
* The list of results.
*/
readonly results: ReadonlyArray<SearchResponse<TObject>>;
};
export declare type RecommendSearchOptions = Omit<SearchOptions, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
export declare type RecommendTrendingFacetsQueriesResponse = {
/**
* The list of results.
*/
readonly results: readonly TrendingFacetsResponse[];
};
export declare type RelatedProductsQuery = Omit<RecommendationsQuery, 'model'>;
export declare type TrendingFacetHit = {
readonly _score: number;
readonly facetName: string;
readonly facetValue: string;
};
export declare type TrendingFacetsQuery = {
/**
* The name of the target index.
*/
readonly indexName: string;
/**
* Threshold for the recommendations confidence score (between 0 and 100). Only recommendations with a greater score are returned.
*/
readonly threshold?: number;
/**
* How many recommendations to retrieve.
*/
readonly maxRecommendations?: number;
/**
* The facet attribute to get recommendations for.
*/
readonly facetName: string;
};
export declare type TrendingFacetsResponse = Omit<SearchResponse, 'hits'> & {
readonly hits: readonly TrendingFacetHit[];
};
export declare type TrendingItemsQuery = {
/**
* The name of the target index.
*/
readonly indexName: string;
/**
* Threshold for the recommendations confidence score (between 0 and 100). Only recommendations with a greater score are returned.
*/
readonly threshold?: number;
/**
* How many recommendations to retrieve.
*/
readonly maxRecommendations?: number;
/**
* List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
*/
readonly queryParameters?: RecommendSearchOptions_2;
/**
* List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
*
* Additional filters to use as fallback when there arent enough recommendations.
*/
readonly fallbackParameters?: RecommendSearchOptions_2;
/**
* The facet attribute to get recommendations for.
*/
readonly facetName?: string;
/**
* The value of the target facet.
*/
readonly facetValue?: string;
};
export declare type TrendingModel = 'trending-items' | 'trending-facets';
export declare type TrendingQuery = (TrendingItemsQuery & {
readonly model: TrendingModel;
}) | (TrendingFacetsQuery & {
readonly model: TrendingModel;
});
export declare type WithRecommendMethods<TType> = TType & {
/**
* Returns recommendations.
*/
readonly getRecommendations: <TObject>(queries: ReadonlyArray<RecommendationsQuery | TrendingQuery | RecommendedForYouQuery>, requestOptions?: RequestOptions & SearchOptions) => Readonly<Promise<RecommendQueriesResponse<TObject>>>;
/**
* Returns [Related Products](https://algolia.com/doc/guides/algolia-ai/recommend/#related-products).
*/
readonly getRelatedProducts: <TObject>(queries: readonly RelatedProductsQuery[], requestOptions?: RequestOptions & SearchOptions) => Readonly<Promise<RecommendQueriesResponse<TObject>>>;
/**
* Returns [Frequently Bought Together](https://algolia.com/doc/guides/algolia-ai/recommend/#frequently-bought-together) products.
*/
readonly getFrequentlyBoughtTogether: <TObject>(queries: readonly FrequentlyBoughtTogetherQuery[], requestOptions?: RequestOptions & SearchOptions) => Readonly<Promise<RecommendQueriesResponse<TObject>>>;
/**
* Returns trending items
*/
readonly getTrendingItems: <TObject>(queries: readonly TrendingItemsQuery[], requestOptions?: RequestOptions & SearchOptions) => Readonly<Promise<RecommendQueriesResponse<TObject>>>;
/**
* Returns trending items per facet
*/
readonly getTrendingFacets: <TObject>(queries: readonly TrendingFacetsQuery[], requestOptions?: RequestOptions & SearchOptions) => Readonly<Promise<RecommendTrendingFacetsQueriesResponse>>;
/**
* Returns Looking Similar
*/
readonly getLookingSimilar: <TObject>(queries: readonly LookingSimilarQuery[], requestOptions?: RequestOptions & SearchOptions) => Readonly<Promise<RecommendQueriesResponse<TObject>>>;
/**
* Returns Recommended for you
*/
readonly getRecommendedForYou: <TObject>(queries: readonly RecommendedForYouParams[], requestOptions?: RequestOptions & SearchOptions) => Readonly<Promise<RecommendQueriesResponse<TObject>>>;
};
export { }