import { HawkSearchComponents } from '../configuration'; import { RawVariantDocument } from '../models'; import { ItemVariant } from '../models/base.models'; export interface ServiceFieldMappings { description: Array; imageUrl: Array; price: Array; rating: Array; salePrice: Array; sku: Array; title: Array; type: Array; url: Array; brand: Array; } export interface ServiceVariantFieldMappings { color: { name: Array; hex: Array; imageUrl: Array; }; description: Array; id: Array; imageUrl: Array; price: Array; rating: Array; salePrice: Array; sku: Array; title: Array; url: Array; } export declare abstract class BaseService { protected abstract baseUrl: string; protected fieldMappings: ServiceFieldMappings; protected variantFieldMappings: ServiceVariantFieldMappings; queryStringParams: { disableSpellcheck: string; page: string; pageSize: string; query: string; searchWithin: string; sort: string; requestType: string; }; searchUrl: string; protected get onSearchPage(): boolean; constructor(); protected httpPost(relativeUrl: string, body?: any, customHeaders?: any, isAbsoluteUrl?: boolean): Promise; protected getHeaders(): Headers; /** * Builds the request headers for HawkSearch API calls. * * `User-Agent`, `X-Forwarded-For`, `X-HawkSearch-ClientGuid`, and * `X-HawkSearch-IgnoreTracking` are values a server-side HawkSearch SDK * would normally populate automatically. Because this library calls the API * directly from the browser, it reconstructs them here by hand. * * Everything is best-effort and defensive on purpose: * - `User-Agent` is a browser "forbidden header" — `fetch` may silently drop * it or throw when it's set. * - The library also runs in sandboxed iframes (e.g. BigCommerce), SSR / * hydration, and jsdom tests, where `window` / `navigator` / the * `HawkSearch` global may be undefined, or where `new Headers()` / * `headers.set()` themselves can throw. * * These headers are optional enrichment (analytics / geo / tracking), never * required for the request to succeed — so a failure to build any one of * them must never break a search. Each header is resolved and set in its own * try/catch (see {@link setHeaderSafe}): a failing header is logged in debug * mode and skipped while the rest still go out. */ protected getApiHeaders(): Headers; private getHeadersSafe; /** * Best-effort header setter that never throws. * Logs in debug mode if a set fails. */ private safeHeaderSet; private setHeaderSafe; private debugWarn; private getFieldMappings; getVisitorId(): string; getVisitId(): string; protected generateGuid(): string; protected stripHtml(input: string): string; protected getValue(data: object, fieldMappings: Array): Array | undefined; protected getString(data: object, fieldMappings: Array, defaultValue?: string): string | undefined; protected getNumber(data: object, fieldMappings: Array, defaultValue?: number): number | undefined; protected getUrl(data: object, fieldMappings: Array, prefix?: string | undefined): string | undefined; protected getFullUrl(url: string | undefined, prefix: string | undefined): string | undefined; /** @internal */ protected getVariants(document: RawVariantDocument): { items: Array | undefined; selectedItem?: ItemVariant; }; protected triggerBindEvent(component: keyof HawkSearchComponents, data: T, filter?: string): void; protected triggerEvent(name: string, data: T): void; }