import { AutocompleteCallback, AutocompleteContentCallback, DashboardKeys, FastCategory, FastTurbolinks, PopularSearch } from "./autocomplete"; import { Facet, fullTextCallback, fullTextFacetsCallback, fullTextProductsCallback, Narrow, Product, SortBy } from "./fullTextSearch"; import { CategoryAncestor, RelatedCategory, smartCollectionsCallback, smartCollectionsResults } from "./smartCollections"; import { Report } from "./events"; import { Specs, SRC_TYPES, WidgetCallback } from "./related"; import { ContentSearchProps } from "./content"; import { inventoryCallback } from "./productsInventory"; import { AppReference, DiscoveryCallback, ImageSearchCallback, ImageSendCallback, ProductsByImageCallback, ProductsDiscoveryCallback, ResultType, SimilarStylesCallback } from "./visualDiscovery"; import { DiscoveryProductVisitType } from "../services/visualDiscoveryReporting"; import { ArticleResponse } from "../services/content"; export type AppType = "SPA" | "MPA"; export type SDKStatus = "loading" | "error" | "ready"; type ContentPage = number; type ContentCursor = string; export interface SDKData { uuid: string; storeID: number; cdnKey: number; sessionToken: SessionToken; userToken: string; cartToken: string; dashboard: DashboardKeys; popularProducts: Product[]; categories: FastCategory[]; turbolinks: FastTurbolinks[]; articles: ArticleResponse[]; contentData: Record; withProductVariants?: boolean; withAttributes?: boolean; popularSearches?: PopularSearch[]; abTestingVariations?: { [key: string]: { [key: string]: object; }; }; personalizedProducts?: string | undefined; collectionsPersonalization?: CollectionsPersonalization; searchPersonalization?: boolean; channel?: Channel; collectionProductIds?: { [key: string]: boolean; }; spv?: string | undefined; spv_post_load?: string | undefined; spc?: string | undefined; spc_post_load?: string | undefined; siteState?: number; } export interface AutocompleteResults { totalResults: number; categories?: FastCategory[]; products: Product[]; turbolinks?: FastTurbolinks[]; popularSearches: PopularSearch[]; query: string; } export interface FullTextResults { query: string; products?: Product[]; facets?: Facet[]; totalResults: number; narrow?: Narrow[]; sortBy?: SortBy; isNoResults?: boolean; page?: number; pageCount?: number; ancestors?: CategoryAncestor[]; avoidPrefixList?: string[]; merch?: any; turbolink?: FastTurbolinks; relatedCategories?: RelatedCategory[]; relatedResults?: boolean; error?: boolean; } export interface LandingPageResults { slug: string; products: Product[]; facets?: Facet[]; totalResults: number; narrow?: Narrow[]; sortBy?: SortBy; isNoResults?: boolean; page?: number; pageCount?: number; ancestors?: CategoryAncestor[]; avoidPrefixList?: string[]; bannerHTML?: string; title?: string; } export interface CustomData { productsPerPage?: number; } export interface SDKTemp { autocomplete: AutocompleteResults; fullTextSearch: FullTextResults; smartCollections: smartCollectionsResults; landingPage: LandingPageResults; customData: CustomData; } export interface initProps { storeID: number; uuid: string; type: AppType; onReady?: VoidFunction; onError?: (error: any) => void; cartToken?: string; verbose?: boolean; } export interface instantSearchProps { query: string; callback: AutocompleteCallback; withAttributes?: boolean; withCategories?: boolean; withProductTypes?: boolean; withProductVariants?: boolean; articlesCallback?: AutocompleteContentCallback; } export interface FullTextSearchProps { term: string; page?: number; productsPerPage?: number; sortBy?: SortBy; narrowBy?: Narrow[]; facets?: boolean; callback: fullTextCallback; withAttributes?: boolean; searchWithinSearch?: string; infiniteScrollPage?: number; segments?: string[]; withProductTypes?: boolean; disableMerchandising?: boolean; disableStrategies?: boolean; disableMerchandisingRules?: boolean; onProductsLoaded?: fullTextProductsCallback; onFacetsLoaded?: fullTextFacetsCallback; disableTurbolinks?: boolean; } export type LandingPageCallback = ({}: { action: "products" | "facets and products"; payload: LandingPageResults; }) => void; export interface LandingPageProps { slug: string; page?: number; productsPerPage?: number; sortBy?: SortBy; narrowBy?: Narrow[]; facets?: boolean; callback: LandingPageCallback; withAttributes?: boolean; } export interface smartCollectionsProps { categoryID: string; page?: number; productsPerPage?: number; sortBy?: SortBy; narrowBy?: Narrow[]; facets?: boolean; callback: smartCollectionsCallback; withAttributes?: boolean; searchWithinSearch?: string; infiniteScrollPage?: number; segments?: string[]; inventoryCallback?: inventoryCallback; access_token?: string; shop_url?: string; withProductTypes?: boolean; disableMerchandising?: boolean; disableStrategies?: boolean; disableMerchandisingRules?: boolean; onProductsLoaded?: smartCollectionsCallback; onFacetsLoaded?: smartCollectionsCallback; disableTurbolinks: boolean; } export interface LookALikeProps { viewedProductId: string; callback: (response: LookALikeResponse) => void; } export interface LookALikeResponse { action: "look a like"; payload: Product[]; } export interface RelatedProps { productID: string; specs: Specs[]; callback: WidgetCallback; recent?: string[]; withAttributes?: boolean; src?: SRC_TYPES; } export interface RelatedWidgetProps { productID: string; widgetsIDS: string[]; callback: WidgetCallback; recent?: string[]; withAttributes?: boolean; src?: SRC_TYPES; } export interface GetProductsProps { productIds: string[]; callback?: (products: Product[]) => void; withAttributes?: boolean; direct?: boolean; } export interface SDKUtils { type: AppType; status: SDKStatus; data: SDKData; temp: SDKTemp; callbacks?: (() => any)[]; fsGridCurrentResponse: { status: "loading" | "done"; data: Record; } | Record; viewportImpressions?: any; } export interface PopularProductsProps { withAttributes?: boolean; } export interface SDK { initialization: ({}: initProps) => void; instantSearch: ({}: instantSearchProps) => void; fullTextSearch: ({}: FullTextSearchProps) => void; smartCollections: ({}: smartCollectionsProps) => void; landingPage: ({}: LandingPageProps) => void; lookAlikeProductRecommendation: ({}: LookALikeProps) => void; productRecommendation: ({}: RelatedProps) => void; contentSearch: ({}: ContentSearchProps) => void; event: ({}: Report) => void; getAllCategories: (callback?: (categories: FastCategory[] | null) => void) => Promise; getAllPopularProducts: (callback?: (products: Product[] | null) => void, withAttributes?: boolean) => Promise; getProducts: ({}: GetProductsProps) => Promise; getSetup: ({}: { keys: (Partial)[]; callback: (keys: Partial) => void; }) => void; productRecommendationByWidget: ({}: RelatedWidgetProps) => void; productsByDiscovery: ({}: ProductsDiscoveryInternalProps) => void; discoveryImages: ({}: DiscoveryInternalProps) => void; sendImage: ({}: ImageSendInternalProps) => void; ProductsByImage: ({}: ProductsByImageInternalProps) => void; visualSearch: ({}: ImageSearchInternalProps) => void; similarStyles: ({}: SimilarStylesInternalProps) => void; trackViewportImpression: (element: HTMLElement, productId: string, position: number) => void; } export declare const defaultSDKTemp: SDKTemp; export declare const defaultDashboardData: DashboardKeys; export declare const defaultSDKData: SDKData; export interface SessionToken { start: number; lastActive: number; } export interface BCTokenResponse { id: string; } export interface ShopifyTokenResponse { token: string; } export type Platfrom = "Shopify" | "Bigcommerce" | ""; export interface ProductsDiscoveryInternalProps { imageID: string; mode: ResultType; callback: ProductsDiscoveryCallback; } export interface DiscoveryInternalProps { mode: ResultType; callback: DiscoveryCallback; } export interface ImageSendInternalProps { fileData: File; itemName: string | undefined; callback: ImageSendCallback; } export interface ProductsByImageInternalProps { imageID: string; callback: ProductsByImageCallback; reference?: AppReference; imageBase64?: string | null; bboxCallback: ProductsByImageCallback; itemName?: string | undefined; } export interface ImageSearchInternalProps { fileData: File; itemName: string | undefined; callback: ImageSearchCallback; bboxCallback: ImageSearchCallback; } export interface SimilarStylesInternalProps { productId: string; imageUrl: string; cdnCacheKey: string; callback: SimilarStylesCallback; } export interface CollectionsPersonalization { active: boolean; avoidProducts: string[] | null; avoidCategories: string[]; disableCategories: string[]; recencyLimit: number; maxRecencyLimit: number; } export interface DiscoveryOpenInternalProps { reference: AppReference; } export interface DiscoveryProductVisitInternalProps { type: DiscoveryProductVisitType; origin: string; productId: string; position: number; reference: AppReference; } export interface ProductAddedToCartPropsInternalProps { origin: string; productId: string; position: number; reference: AppReference; } export interface GalleryImageClickedPropsInternalProps { imageId: string; reference: AppReference; } export interface SearchPersonalization { active: boolean; avoidProducts: string[] | null; recencyLimit: number; maxRecencyLimit: number; } export type Channel = "tapcart"; export {};