Options
All
  • Public
  • Public/Protected
  • All
Menu

Package @storefront/flux-capacitor

FluxCapacitor

State Management for StoreFront

npm (scoped with tag) license API Reference

Building the package

To build an individual package, run the following command:

yarn build

To build an individual package in response to changes within the src directory, run the following command:

yarn dev

Running tests

To test an individual packages, run the following command:

yarn test

To test an individual package in response to changes within the src and test directories, run the following command:

yarn tdd

Linting

To lint a package, run the following command:

yarn lint

To programmatically fix lint errors within a package, run the following command:

yarn lint:fix

Contributing

Read the contributing file to learn about how to contribute to the StoreFront project.

License

StoreFront and its related packages are MIT licensed.

Index

Modules

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action

Action: UpdateLocation | UpdateSecuredPayload | Action<string, any>

Action

Action

Action: RefreshState

Action

Build

Build: function

Type declaration

    • (type: string, state: State): string
    • Parameters

      • type: string
      • state: State

      Returns string

GenericTransformer

GenericTransformer: function

Type declaration

    • (...arg: T[]): T
    • Parameters

      • Rest ...arg: T[]

      Returns T

Parse

Parse: function

Type declaration

SagaCreator

SagaCreator: function

Type declaration

    • Parameters

      Returns function

        • (): IterableIterator<ForkEffect>
        • Returns IterableIterator<ForkEffect>

State

State

State: Details

State

State: History

State

State

State

State: Page

State

State

State

State

State

State: boolean

State

State: Query

State

State

State: number

State

State: string

State

State: SiteParams[]

State

State: Template

State

State: IsFetching

State

State: boolean

State

State: Session

State

State: UI

State

Variables

Const DEFAULTS

DEFAULTS: State

Const DEFAULTS

DEFAULTS: State = <any>{defaultSkus: [],skus: [],saytPastPurchases: [],products: [],count: {currentRecordCount: 0,allRecordCount: 0,},query: '',sort: PAST_PURCHASE_SORT,navigations: {byId: {},allIds: [],},page: page.DEFAULTS,template: {},siteParams: [],}

Const DEFAULTS

DEFAULTS: State = <any>{suggested: {products: []},}

Const DEFAULT_AREA

DEFAULT_AREA: "Production" = "Production"

Const DEFAULT_COLLECTION

DEFAULT_COLLECTION: "default" = "default"

Const DEFAULT_PAGE_SIZE

DEFAULT_PAGE_SIZE: 10 = 10

Const DEFAULT_PARAMS

DEFAULT_PARAMS: any = []

Const DETAILS_CHANGE_ACTIONS

DETAILS_CHANGE_ACTIONS: string[] = [Actions.UPDATE_DETAILS,]

Const MAX_RECORDS

MAX_RECORDS: 10000 = 10000

Const PAST_PURCHASES_SEARCH_CHANGE_ACTIONS

PAST_PURCHASES_SEARCH_CHANGE_ACTIONS: string[] = [Actions.UPDATE_PAST_PURCHASE_QUERY,Actions.RESET_PAST_PURCHASE_REFINEMENTS,Actions.SELECT_PAST_PURCHASE_REFINEMENT,Actions.SELECT_MULTIPLE_PAST_PURCHASE_REFINEMENTS,Actions.DESELECT_PAST_PURCHASE_REFINEMENT,Actions.SELECT_PAST_PURCHASE_SORT,Actions.UPDATE_PAST_PURCHASE_CURRENT_PAGE,Actions.UPDATE_PAST_PURCHASE_PAGE_SIZE,]

Const PAST_PURCHASE_SKU_ACTIONS

PAST_PURCHASE_SKU_ACTIONS: string[] = [Actions.FETCH_PAST_PURCHASE_PRODUCTS,Actions.FETCH_SAYT_PAST_PURCHASES,]

Const PERSONALIZATION_CHANGE_ACTIONS

PERSONALIZATION_CHANGE_ACTIONS: string[] = [Actions.SELECT_REFINEMENT,Actions.ADD_REFINEMENT,]

Const RECALL_CHANGE_ACTIONS

RECALL_CHANGE_ACTIONS: string[] = [Actions.RESET_REFINEMENTS,Actions.UPDATE_QUERY,Actions.ADD_REFINEMENT,Actions.SELECT_REFINEMENT,Actions.SELECT_MULTIPLE_REFINEMENTS,Actions.DESELECT_REFINEMENT,]

Const SAGA_CREATORS

SAGA_CREATORS: (Anonymous function)[] = [autocomplete,collection,productDetails,products,recommendations,refinements,]

Const SAVE_STATE_ACTIONS

SAVE_STATE_ACTIONS: string[] = [...SEARCH_CHANGE_ACTIONS,...PAST_PURCHASES_SEARCH_CHANGE_ACTIONS,...DETAILS_CHANGE_ACTIONS]

Const SEARCH_CHANGE_ACTIONS

SEARCH_CHANGE_ACTIONS: string[] = [...RECALL_CHANGE_ACTIONS,Actions.SELECT_COLLECTION,Actions.SELECT_SORT,Actions.UPDATE_PAGE_SIZE,Actions.UPDATE_CURRENT_PAGE,]

Const STORAGE_KEY

STORAGE_KEY: "gb-personalization" = "gb-personalization"

Const STORAGE_WHITELIST

STORAGE_WHITELIST: string[] = ['biasing']

Const STOREFRONT_APP_ID

STOREFRONT_APP_ID: "GroupBy StoreFront" = "GroupBy StoreFront"

Const UNDOABLE_ACTIONS

UNDOABLE_ACTIONS: string[] = [Actions.RECEIVE_PRODUCTS,Actions.RECEIVE_RECOMMENDATIONS_PRODUCTS,Actions.RECEIVE_COLLECTION_COUNT,Actions.RECEIVE_NAVIGATION_SORT,Actions.RECEIVE_MORE_PAST_PURCHASE_REFINEMENTS,Actions.RECEIVE_MORE_REFINEMENTS,Actions.RECEIVE_PAST_PURCHASE_PRODUCTS,]

Const autocompletePastPurchaseRequest

autocompletePastPurchaseRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.autocompleteProducts, Configuration.pastPurchaseAutocompleteOverrides)

Const autocompleteProductsRequest

autocompleteProductsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.autocompleteProducts, Configuration.autocompleteProductsOverrides)

Const autocompleteSuggestionsRequest

autocompleteSuggestionsRequest: RequestBuilder<AutocompleteConfig & object, AutocompleteConfig & object> = new RequestBuilder<QueryTimeAutocompleteConfig>(RequestHelpers.autocompleteSuggestions, Configuration.autocompleteSuggestionsOverrides)

Const collectionRequest

collectionRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.search, Configuration.collectionOverrides)

fetch

fetch: any

Const pastPurchaseProductsRequest

pastPurchaseProductsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.pastPurchaseProducts, Configuration.pastPurchaseOverrides)

Const personalizationTransform

personalizationTransform: any = createTransform(// transform state coming from redux on its way to being serialized and storedAdapter.transformToBrowser,// configuration options (if any))

Const productDetailsRequest

productDetailsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.productDetails, Configuration.detailsOverrides)

Const productsRequest

productsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.products, Configuration.searchOverrides)

Const recommendationsNavigationsRequest

recommendationsNavigationsRequest: RequestBuilder<RecommendationsBody, RecommendationsBody> = new RequestBuilder<RecommendationsAdapter.RecommendationsBody>(RequestHelpers.recommendationsNavigations, Configuration.recommendationsNavigationsOverrides)

Const recommendationsProductIdsRequest

recommendationsProductIdsRequest: RequestBuilder<RecommendationsRequest, RecommendationsRequest> = new RequestBuilder<RecommendationsAdapter.RecommendationsRequest>(RequestHelpers.recommendationsProductIDs, Configuration.recommendationsIdsOverrides)

Const recommendationsProductsRequest

recommendationsProductsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.search, Configuration.recommendationsProductsOverrides)

Const recommendationsSuggestionsRequest

recommendationsSuggestionsRequest: RequestBuilder<RecommendationsBody & object | RecommendationsRequest & object, RecommendationsBody | RecommendationsRequest> = new RequestBuilder<RecommendationsAdapter.Request & { query: string }, RecommendationsAdapter.Request>(RequestHelpers.recommendationsSuggestions, Configuration.recommendationsSuggestionsOverrides)

Const refinementsRequest

refinementsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.products, Configuration.refinementsOverrides)

Functions

Const addRefinement

  • addRefinement(state: State, __namedParameters: object): object

Const applyMoreRefinementsReducer

  • applyMoreRefinementsReducer(state: State, __namedParameters: object, reducer: Function): object

Const applyNavigationReducer

  • applyNavigationReducer(state: State, __namedParameters: object, reducer: Function): object

Const applyPageReducer

  • applyPageReducer(state: State, __namedParameters: object, reducer: Function): object

Const applySorts

  • applySorts(state: State, __namedParameters: object): object

Const applySortsReducer

  • applySortsReducer(state: State, __namedParameters: object, reducer: Function): object

Const clearComponentState

Const createAction

  • createAction<T, P>(type: T, payload?: P, validator?: object): Action<T, P>

Const createComponentState

  • createComponentState(state: State, __namedParameters: object): object

createSagas

Const deselectRefinement

Const doneFetching

  • doneFetching(state: State, section: string): object

filterState

  • filterState(state: State, actionPayload: State): object

Const generateNavigation

  • generateNavigation(state: State, navigationId: string, refinement: any, index: number): object | object

Const handleError

  • handleError(errorAction: Action<any>, actionCreator: function): any

Const insertSorted

  • insertSorted(allIds: BiasKey[], __namedParameters: object): BiasKey[]

normalizeToFunction

Const rayify

  • rayify<T>(arr: T | T[]): T[]

Const receiveCount

  • receiveCount(state: State, __namedParameters: object): object

Const receiveMoreRefinements

Const receiveNavigationSort

Const receiveNavigations

receivePage

  • receivePage(state: State, __namedParameters: object): object
  • Parameters

    • state: State
    • __namedParameters: object
      • current: number
      • from: number
      • last: number
      • next: number
      • previous: number
      • to: number

    Returns object

    • current: number
    • from: number
    • last: number
    • next: number
    • previous: number
    • to: number

Const receiveProductRecords

Const receiveQuery

  • receiveQuery(state: State, __namedParameters: object): object
  • Parameters

    • state: State
    • __namedParameters: object
      • corrected: string
      • didYouMean: string[]
      • original: string
      • related: string[]
      • rewrites: string[]

    Returns object

    • corrected: string
    • didYouMean: string[]
    • original: string
    • related: string[]
    • rewrites: string[]

Const receiveSuggestions

  • receiveSuggestions(state: State, __namedParameters: object): object

Const receiveTemplate

Const refinementPayload

  • refinementPayload(field: string, valueOrLow: any, high?: any): object | object

Const removeComponentState

  • removeComponentState(state: State, __namedParameters: object): object

resetPage

Const resetRefinements

  • resetRefinements(state: State, navigationId: boolean | string): object

Const rootReducer

  • rootReducer(state: any, action: any): State

Const selectMultipleRefinements

  • selectMultipleRefinements(state: State, __namedParameters: object): object

Const selectRefinement

  • selectRefinement(state: State, __namedParameters: object): object

Const setSessionId

Const shouldResetRefinements

  • shouldResetRefinements(__namedParameters: object, state: State): boolean

Const sortBasedOn

  • sortBasedOn<T, S>(toBeSorted: T[], basisArray: S[], callback?: function): T[]
  • Type parameters

    • T

    • S

    Parameters

    • toBeSorted: T[]
    • basisArray: S[]
    • Optional callback: function
        • (sorted: T, unsorted: S): boolean
        • Parameters

          • sorted: T
          • unsorted: S

          Returns boolean

    Returns T[]

Const startFetching

  • startFetching(state: State, section: string): object

Const undoWithoutHistory

  • undoWithoutHistory(store: any): (Anonymous function)

Const update

  • update(state: State, __namedParameters: object): object

Const update

updateArea

  • updateArea(state?: string): string

updateAutocomplete

Const updateBiasing

updateCollections

updateCurrent

  • updateCurrent(state: State, current: number): object

updateDetails

Const updateFetching

  • updateFetching(state: State, __namedParameters: object): object

updateHistory

Const updateHistoryState

  • updateHistoryState(state: any, __namedParameters?: object): any

updateInfiniteScroll

updateIsFetching

updateIsRunning

Const updateMorePastPurchaseProducts

updateMoreProducts

updateNavigations

updatePage

updateParams

Const updatePastPurchaseAllRecordCount

  • updatePastPurchaseAllRecordCount(state: State, __namedParameters: object): object

Const updatePastPurchaseCurrentRecordCount

  • updatePastPurchaseCurrentRecordCount(state: State, __namedParameters: object): object

Const updatePastPurchaseProducts

  • updatePastPurchaseProducts(state: State, __namedParameters: object): object

Const updatePastPurchaseQuery

  • updatePastPurchaseQuery(state: State, __namedParameters: object): object

Const updatePastPurchaseSiteParams

  • updatePastPurchaseSiteParams(state: State, __namedParameters: object): object

Const updatePastPurchaseSkus

  • updatePastPurchaseSkus(state: State, __namedParameters: object): object

Const updatePastPurchaseSortSelected

  • updatePastPurchaseSortSelected(state: State, __namedParameters: object): object

Const updatePastPurchaseTemplate

  • updatePastPurchaseTemplate(state: State, __namedParameters: object): object

updatePastPurchases

updatePersonalization

updateProducts

updateProductsLoaded

updateQuery

Const updateQuery

  • updateQuery(state: State, query: string): object

updateRecommendations

Const updateRecommendationsProducts

  • updateRecommendationsProducts(state: State, __namedParameters: object): object

updateRecordCount

updateRedirect

Const updateSaytPastPurchases

  • updateSaytPastPurchases(state: State, __namedParameters: object): object

Const updateSection

  • updateSection(state: State, value: any, section: string): object

Const updateSecuredPayload

  • updateSecuredPayload(state: any, securedPayload: SecuredPayload): any

Const updateSelected

  • updateSelected(state: State, selected: string): object

Const updateSelected

  • updateSelected(state: State, selected: number): object

updateSession

updateSize

  • updateSize(state: State, size: number): Page

updateSorts

Const updateState

  • updateState(state: State, __namedParameters: object): any

updateTemplate

updateUi

  • updateUi(state?: State, __namedParameters: object): State

Object literals

Const DEFAULT

DEFAULT: object

biasing

biasing: object

allIds

allIds: undefined[] = []

byId

byId: object

Type declaration

Const DEFAULTS

DEFAULTS: object

allIds

allIds: string[] = [DEFAULT_COLLECTION]

byId

byId: object

__computed

__computed: object

name

name: string = DEFAULT_COLLECTION

Const DEFAULTS

DEFAULTS: object

request

request: object

Type declaration

route

route: string = ""

shouldFetch

shouldFetch: false = false

url

url: string = ""

Const DEFAULTS

DEFAULTS: object

isFetchingBackward

isFetchingBackward: false = false

isFetchingForward

isFetchingForward: false = false

Const DEFAULTS

DEFAULTS: object

allIds

allIds: undefined[] = []

byId

byId: object

Type declaration

sort

sort: undefined[] = []

Const DEFAULTS

DEFAULTS: object

current

current: number = 1

first

first: 1 = 1

from

from: number = 1

sizes

sizes: object

items

items: number[] = [DEFAULT_PAGE_SIZE]

selected

selected: number = 0

Const DEFAULTS

DEFAULTS: object

items

items: object[] = [{ field: '_relevance', descending: true }]

labels

labels: undefined[] = []

selected

selected: number = 0

Const DEFAULTS

DEFAULTS: object

corrected

corrected: undefined = undefined

didYouMean

didYouMean: undefined[] = []

related

related: undefined[] = []

rewrites

rewrites: undefined[] = []

Const DEFAULTS

DEFAULTS: object

navigations

navigations: undefined[] = []

products

products: undefined[] = []

searchCharMinLimit

searchCharMinLimit: number = 1

showCategoryValuesForFirstMatch

showCategoryValuesForFirstMatch: false = false

suggestions

suggestions: undefined[] = []

template

template: any = <any>{}

category

category: object

values

values: undefined[] = []

Const DEFAULT_FETCHING

DEFAULT_FETCHING: object

autocompleteProducts

autocompleteProducts: boolean = false

autocompleteSuggestions

autocompleteSuggestions: boolean = false

details

details: boolean = false

moreProducts

moreProducts: boolean = false

moreRefinements

moreRefinements: boolean = false

search

search: boolean = false

Const PAST_PURCHASE_SORT

PAST_PURCHASE_SORT: object

items

items: object[] = [{ field: PAST_PURCHASE_SORTS.DEFAULT, descending: true },{ field: PAST_PURCHASE_SORTS.MOST_RECENT, descending: true },{ field: PAST_PURCHASE_SORTS.MOST_PURCHASED, descending: true },]

labels

labels: undefined[] = []

selected

selected: number = 0

Const Routes

Routes: object

DETAILS

DETAILS: string = "details"

NAVIGATION

NAVIGATION: string = "navigation"

PAST_PURCHASE

PAST_PURCHASE: string = "pastpurchase"

SEARCH

SEARCH: string = "search"

Const areMultiplePastPurchaseRefinementsDeselectedByIndex

areMultiplePastPurchaseRefinementsDeselectedByIndex: object

msg

msg: string = "navigation does not exist or all refinements are already selected"

func

  • func(__namedParameters: object, state: State): boolean

Const areMultipleRefinementsDeselectedByIndex

areMultipleRefinementsDeselectedByIndex: object

msg

msg: string = "navigation does not exist or all refinements are already selected"

func

  • func(__namedParameters: object, state: State): boolean

Const hasSelectedPastPurchaseRefinements

hasSelectedPastPurchaseRefinements: object

msg

msg: string = "no refinements to clear"

func

  • func(_: any, state: State): boolean

Const hasSelectedPastPurchaseRefinementsByField

hasSelectedPastPurchaseRefinementsByField: object

msg

msg: string = "no refinements to clear for field"

func

  • func(field: string, state: State): boolean

Const hasSelectedRefinements

hasSelectedRefinements: object

msg

msg: string = "no refinements to clear"

func

  • func(_: any, state: State): boolean

Const hasSelectedRefinementsByField

hasSelectedRefinementsByField: object

msg

msg: string = "no refinements to clear for field"

func

  • func(field: string, state: State): boolean

Const hasValidLabels

hasValidLabels: object

msg

msg: string = "if present, labels must be an array of strings"

func

  • func(__namedParameters: object): boolean

Const hasValidOptions

hasValidOptions: object

msg

msg: string = "must be an array of valid sort options"

func

  • func(__namedParameters: object): boolean

Const hasValidSelected

hasValidSelected: object

msg

msg: string = "if present, must be an index of the options array`"

func

  • func(payload: Sort): boolean

Const isCollectionDeselected

isCollectionDeselected: object

msg

msg: string = "collection is already selected"

func

  • func(id: string, state: State): boolean

Const isDifferentAutocompleteQuery

isDifferentAutocompleteQuery: object

msg

msg: string = "suggestions for query have already been requested"

func

  • func(query: string, state: State): boolean

Const isDifferentPageSize

isDifferentPageSize: object

msg

msg: string = "page size is already selected"

func

  • func(size: number, state: State): boolean

Const isDifferentPastPurchasePageSize

isDifferentPastPurchasePageSize: object

msg

msg: string = "page size is already selected"

func

  • func(size: number, state: State): boolean

Const isNotFetching

isNotFetching: object

msg

msg: string = "is already fetching"

func

  • func(forward: boolean, state: State): boolean

Const isNotFullRange

isNotFullRange: object

msg

msg: string = "range must be smaller than full range"

func

  • func(__namedParameters: object, state: State): boolean

Const isOnDifferentPage

isOnDifferentPage: object

msg

msg: string = "page is already selected"

func

  • func(page: number, state: State): boolean

Const isOnDifferentPastPurchasePage

isOnDifferentPastPurchasePage: object

msg

msg: string = "page is already selected"

func

  • func(page: number, state: State): boolean

Const isPastPurchaseRefinementDeselectedByIndex

isPastPurchaseRefinementDeselectedByIndex: object

msg

msg: string = "navigation does not exist or refinement is already selected"

func

  • func(__namedParameters: object, state: State): boolean

Const isPastPurchaseRefinementSelectedByIndex

isPastPurchaseRefinementSelectedByIndex: object

msg

msg: string = "navigation does not exist or refinement is not selected"

func

  • func(__namedParameters: object, state: State): boolean

Const isPastPurchasesSortValid

isPastPurchasesSortValid: object

msg

msg: string = "past purchases sort index is not a number or it is not within the bounds of the past purchases sort array"

func

  • func(index: number, state: State): boolean

Const isRangeRefinement

isRangeRefinement: object

msg

msg: string = "low and high values must be numeric"

func

  • func(__namedParameters: object): boolean

Const isRefinementDeselectedByIndex

isRefinementDeselectedByIndex: object

msg

msg: string = "navigation does not exist or refinements are already selected"

func

  • func(__namedParameters: object, state: State): boolean

Const isRefinementDeselectedByValue

isRefinementDeselectedByValue: object

msg

msg: string = "refinement is already selected"

func

Const isRefinementSelectedByIndex

isRefinementSelectedByIndex: object

msg

msg: string = "navigation does not exist or refinement is not selected"

func

  • func(__namedParameters: object, state: State): boolean

Const isSortValid

isSortValid: object

msg

msg: string = "sort index is not a number or it is not within the bounds of the sorts array"

func

  • func(index: number, state: State): boolean

Const isString

isString: object

msg

msg: string = "must be a non-empty string"

func

  • func(value: any): boolean

Const isValidBias

isValidBias: object

msg

msg: string = "bias is invalid"

func

Const isValidClearField

isValidClearField: object

msg

msg: string = "clear must be a string or true"

func

  • func(field: string | false | true): boolean

Const isValidPage

isValidPage: object

msg

msg: string = "page is invalid"

func

  • func(page: number, state: State): boolean

Const isValidPastPurchasePage

isValidPastPurchasePage: object

msg

msg: string = "page is invalid"

func

  • func(page: number, state: State): boolean

Const isValidQuery

isValidQuery: object

msg

msg: string = "search term is empty"

func

  • func(query: string): boolean

Const isValidRange

isValidRange: object

msg

msg: string = "low value must be lower than high"

func

  • func(__namedParameters: object): boolean

Const isValueRefinement

isValueRefinement: object

msg

msg: string = `value ${isString.msg}`

func

  • func(__namedParameters: object): boolean

Const notOnFirstPage

notOnFirstPage: object

msg

msg: string = "page must not be on first page"

func

  • func(_: any, state: State): boolean

Const notOnFirstPastPurchasePage

notOnFirstPastPurchasePage: object

msg

msg: string = "page must not be on first page"

func

  • func(_: any, state: State): boolean

Generated using TypeDoc