import { Store as ReduxStore } from 'redux'; import FluxCapacitor from '../../flux-capacitor'; import Actions from '../actions'; import Configuration from '../configuration'; export { ReduxStore }; declare namespace Store { function create(flux: FluxCapacitor, listener?: (store: ReduxStore) => () => void): ReduxStore; interface State { isRunning: boolean; isFetching: IsFetching; session: Session; data: { past: Data[]; present: Data; future: Data[]; }; ui: UI; } interface Data { area: string; query: Query; sorts: LabeledSelectableList; products: ProductWithMetadata[]; productsLoaded: boolean; collections: Indexed.Selectable; navigations: AvailableNavigations; autocomplete: Autocomplete; history: History; page: Page; template?: Template; details: Details; recommendations: Recommendations; personalization?: Personalization; pastPurchases: PastPurchase; infiniteScroll: InfiniteScroll; recordCount: number; redirect?: string; fields: string[]; siteParams: SiteParams[]; errors: string[]; warnings: string[]; } interface History { url: string; route: string; request: any; shouldFetch: boolean; } interface UI { [tagName: string]: { global?: any; [tagId: number]: any; }; } interface Query { original?: string; corrected?: string; related: string[]; didYouMean: string[]; rewrites: string[]; } interface Collection { /** * byId key */ name: string; total?: number; } interface Sort { field: string; descending?: boolean; } interface Page { /** * number of products per page */ sizes: SelectableList; /** * current page number */ current: number; /** * number of first page */ first: 1; /** * number of next page */ previous?: number; /** * number of previous page */ next?: number; /** * number of last page */ last?: number; /** * start of displayed products */ from?: number; /** * end of displayed products */ to?: number; } interface Template { name: string; rule: string; zones: { [zoneName: string]: Zone; }; } interface Session { recallId?: string; searchId?: string; pastPurchaseId?: string; detailsId?: string; location?: Geolocation; origin?: Actions.Metadata.Tag; config?: Configuration; sessionId?: SessionId; } interface IsFetching { moreRefinements: boolean; moreProducts: boolean; search: boolean; autocompleteSuggestions: boolean; autocompleteProducts: boolean; details: boolean; } type Zone = ContentZone | RichContentZone | ProductsZone; namespace Zone { type Type = typeof Type.CONTENT | typeof Type.RICH_CONTENT | typeof Type.PRODUCTS; namespace Type { const CONTENT = "content"; const RICH_CONTENT = "rich_content"; const PRODUCTS = "products"; } } interface BaseZone { name: string; type: Zone.Type; } interface ContentZone extends BaseZone { type: typeof Zone.Type.CONTENT; content: string; } interface RichContentZone extends BaseZone { type: typeof Zone.Type.RICH_CONTENT; content: string; } interface ProductsZone extends BaseZone { type: typeof Zone.Type.PRODUCTS; query: string; products: Product[]; } interface Details { data?: Product; template?: Template; siteParams?: SiteParams[]; } interface Recommendations { suggested: { products: ProductWithMetadata[]; }; } type AvailableNavigations = Indexed & { sort: Recommendations.Navigation[]; }; namespace Recommendations { interface Navigation { name: string; values: RecommendationRefinement[]; lows?: any[]; highs?: any[]; } interface RecommendationRefinement { value: string; count: number; } } interface PastPurchase { defaultSkus: PastPurchases.PastPurchaseProduct[]; skus: PastPurchases.PastPurchaseProduct[]; saytPastPurchases: ProductWithMetadata[]; products: ProductWithMetadata[]; count: PastPurchases.PastPurchaseCount; navigations: Indexed; query: string; sort?: LabeledSelectableList; page: Page; template?: Template; siteParams?: SiteParams[]; } namespace PastPurchases { interface PastPurchaseSort extends Sort { type: number; } interface PastPurchaseProduct { sku: string; quantity: number; lastPurchased: number; } interface PastPurchaseRefinement { field: string; value: string; count: number; } interface PastPurchaseCount { allRecordCount: number; currentRecordCount: number; } } interface InfiniteScroll { isFetchingForward: boolean; isFetchingBackward: boolean; } interface Product { id: string; [key: string]: any; } interface ProductWithMetadata { data: Product; index: number; meta: { collection: string; }; } interface Navigation { /** * byId key */ field: string; label: string; boolean?: boolean; more?: boolean; range?: boolean; max?: number; min?: number; or?: boolean; selected: number[]; show?: number[]; refinements: Refinement[]; sort?: Sort; metadata: { [key: string]: string; }; } interface BaseRefinement { total: number; display?: string; } type Refinement = ValueRefinement | RangeRefinement; interface ValueRefinement extends BaseRefinement { value: string; } interface RangeRefinement extends BaseRefinement { low: number; high: number; } interface Autocomplete { query?: string; suggestions: Autocomplete.Suggestion[]; category: Autocomplete.Category; showCategoryValuesForFirstMatch: boolean; navigations: Autocomplete.Navigation[]; products: ProductWithMetadata[]; template?: Template; searchCharMinLimit?: number; } namespace Autocomplete { interface Category { field?: string; values: string[]; } interface Navigation { field: string; label: string; refinements: string[]; } interface Suggestion { value: string; trending?: boolean; } } interface SelectableList { items: T[]; selected?: number; } interface LabeledSelectableList extends SelectableList { labels?: string[]; } interface Indexed { byId: { [key: string]: T; }; allIds: string[]; } namespace Indexed { interface Selectable extends Indexed { selected?: string; } } interface Geolocation { latitude: number; longitude: number; } type SessionId = string; interface Personalization { biasing: Personalization.Biasing; } namespace Personalization { interface Biasing { allIds: Personalization.BiasKey[]; byId: Personalization.BiasById; } interface BiasById { [field: string]: { [value: string]: SingleBias; }; } interface BiasKey { field: string; value: string; } interface SingleBias { lastUsed: number; } } interface SiteParams { key: string; value: string; } } export default Store;