@bradsearch/search-sdk
Version:
TypeScript SDK for BradSearch API with JWT authentication, field mapping, and faceted search capabilities
72 lines • 1.91 kB
TypeScript
export type FieldType = "text" | "keyword" | "text_keyword" | "hierarchy" | "variants" | "object" | "url" | "image_url" | "integer";
export interface FieldConfig {
type: FieldType;
filterable?: boolean;
fields?: Record<string, FieldConfig>;
label?: string;
}
export interface ItemMapping {
title?: string;
reference?: string;
link?: string;
imageUrl?: string;
brand?: string;
[key: string]: string | undefined;
}
export interface ApiSdkConfig {
token: string;
baseUrl: string;
fields: Record<string, FieldConfig>;
mapping?: ItemMapping;
}
export interface Item {
id: string;
title: string;
link: string;
imageUrl: {
small: string;
medium: string;
};
reference: string;
brand?: string;
_highlights?: Record<string, string>;
}
export interface FacetValue {
value: string;
count: number;
}
export interface SearchResponse<T = Item> {
limit: number;
total: number;
offset: number;
facets: Record<string, FacetValue[]>;
documents: T[];
}
export interface QueryOptions {
signal?: AbortSignal;
limit?: number;
offset?: number;
sortBy?: string;
locale?: string;
order?: "asc" | "desc";
searchAll?: boolean;
autocomplete?: boolean;
}
export interface Filters {
[fieldName: string]: string | string[];
}
export declare class ApiError extends Error {
statusCode?: number | undefined;
constructor(message: string, statusCode?: number | undefined);
}
export declare class AuthenticationError extends ApiError {
constructor(message?: string);
}
export declare class ValidationError extends ApiError {
constructor(message?: string);
}
export declare class NetworkError extends ApiError {
constructor(message?: string);
}
export declare function filterable(target: any, propertyKey: string): void;
//# sourceMappingURL=index.d.ts.map