Variables
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
autocomplete
PastPurchaseRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.autocompleteProducts, Configuration.pastPurchaseAutocompleteOverrides)
Const autocompleteProductsRequest
autocomplete
ProductsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.autocompleteProducts, Configuration.autocompleteProductsOverrides)
Const autocompleteSuggestionsRequest
autocomplete
SuggestionsRequest: RequestBuilder<AutocompleteConfig & object, AutocompleteConfig & object> = new RequestBuilder<QueryTimeAutocompleteConfig>(RequestHelpers.autocompleteSuggestions, Configuration.autocompleteSuggestionsOverrides)
Const collectionRequest
collection
Request: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.search, Configuration.collectionOverrides)
Const pastPurchaseProductsRequest
past
PurchaseProductsRequest: 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
product
DetailsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.productDetails, Configuration.detailsOverrides)
Const productsRequest
products
Request: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.products, Configuration.searchOverrides)
Const recommendationsNavigationsRequest
Const recommendationsProductIdsRequest
Const recommendationsProductsRequest
recommendations
ProductsRequest: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.search, Configuration.recommendationsProductsOverrides)
Const recommendationsSuggestionsRequest
Const refinementsRequest
refinements
Request: RequestBuilder<Request, Request> = new RequestBuilder<Request>(RequestHelpers.products, Configuration.refinementsOverrides)
Object literals
Const DEFAULT
DEFAULT: object
biasing
biasing: object
allIds
allIds: undefined[] = []
Const DEFAULTS
DEFAULTS: object
allIds
allIds: string[] = [DEFAULT_COLLECTION]
byId
byId: object
__computed
__computed: object
name
name: string = DEFAULT_COLLECTION
Const DEFAULTS
DEFAULTS: object
shouldFetch
shouldFetch: false = false
Const DEFAULTS
DEFAULTS: object
isFetchingBackward
isFetchingBackward: false = false
isFetchingForward
isFetchingForward: false = false
Const DEFAULTS
DEFAULTS: object
allIds
allIds: undefined[] = []
sort
sort: undefined[] = []
Const DEFAULTS
DEFAULTS: object
current
current: 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
-
Parameters
-
__namedParameters: object
-
indices: number[]
-
navigationId: string
-
Returns 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
-
Parameters
-
__namedParameters: object
-
indices: number[]
-
navigationId: string
-
Returns boolean
Const hasSelectedPastPurchaseRefinements
hasSelectedPastPurchaseRefinements: object
msg
msg: string = "no refinements to clear"
func
- func(_: any, state: State): boolean
-
Parameters
Returns boolean
Const hasSelectedPastPurchaseRefinementsByField
hasSelectedPastPurchaseRefinementsByField: object
msg
msg: string = "no refinements to clear for field"
func
- func(field: string, state: State): boolean
-
Parameters
Returns boolean
Const hasSelectedRefinements
hasSelectedRefinements: object
msg
msg: string = "no refinements to clear"
func
- func(_: any, state: State): boolean
-
Parameters
Returns boolean
Const hasSelectedRefinementsByField
hasSelectedRefinementsByField: object
msg
msg: string = "no refinements to clear for field"
func
- func(field: string, state: State): boolean
-
Parameters
Returns boolean
Const hasValidLabels
hasValidLabels: object
msg
msg: string = "if present, labels must be an array of strings"
func
- func(__namedParameters: object): boolean
-
Parameters
-
__namedParameters: object
Returns boolean
Const hasValidOptions
hasValidOptions: object
msg
msg: string = "must be an array of valid sort options"
func
- func(__namedParameters: object): boolean
-
Parameters
-
__namedParameters: object
Returns boolean
Const hasValidSelected
hasValidSelected: object
msg
msg: string = "if present, must be an index of the options array`"
func
- func(payload: Sort): boolean
-
Parameters
Returns boolean
Const isCollectionDeselected
isCollectionDeselected: object
msg
msg: string = "collection is already selected"
func
- func(id: string, state: State): boolean
-
Parameters
Returns boolean
Const isDifferentAutocompleteQuery
isDifferentAutocompleteQuery: object
msg
msg: string = "suggestions for query have already been requested"
func
- func(query: string, state: State): boolean
-
Parameters
Returns boolean
Const isDifferentPageSize
isDifferentPageSize: object
msg
msg: string = "page size is already selected"
func
- func(size: number, state: State): boolean
-
Parameters
Returns boolean
Const isDifferentPastPurchasePageSize
isDifferentPastPurchasePageSize: object
msg
msg: string = "page size is already selected"
func
- func(size: number, state: State): boolean
-
Parameters
Returns boolean
Const isNotFetching
isNotFetching: object
msg
msg: string = "is already fetching"
func
- func(forward: boolean, state: State): boolean
-
Parameters
Returns boolean
Const isNotFullRange
isNotFullRange: object
msg
msg: string = "range must be smaller than full range"
func
- func(__namedParameters: object, state: State): boolean
-
Parameters
-
__namedParameters: object
-
high: number
-
low: number
-
navigationId: string
-
range: boolean
-
Returns boolean
Const isOnDifferentPage
isOnDifferentPage: object
msg
msg: string = "page is already selected"
func
- func(page: number, state: State): boolean
-
Parameters
Returns boolean
Const isOnDifferentPastPurchasePage
isOnDifferentPastPurchasePage: object
msg
msg: string = "page is already selected"
func
- func(page: number, state: State): boolean
-
Parameters
Returns boolean
Const isPastPurchaseRefinementDeselectedByIndex
isPastPurchaseRefinementDeselectedByIndex: object
msg
msg: string = "navigation does not exist or refinement is already selected"
func
- func(__namedParameters: object, state: State): boolean
-
Parameters
-
__namedParameters: object
-
index: number
-
navigationId: string
-
Returns boolean
Const isPastPurchaseRefinementSelectedByIndex
isPastPurchaseRefinementSelectedByIndex: object
msg
msg: string = "navigation does not exist or refinement is not selected"
func
- func(__namedParameters: object, state: State): boolean
-
Parameters
-
__namedParameters: object
-
index: number
-
navigationId: string
-
Returns 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
-
Parameters
Returns boolean
Const isRangeRefinement
isRangeRefinement: object
msg
msg: string = "low and high values must be numeric"
func
- func(__namedParameters: object): boolean
-
Parameters
-
__namedParameters: object
-
high: number
-
low: number
-
range: boolean
Returns boolean
Const isRefinementDeselectedByIndex
isRefinementDeselectedByIndex: object
msg
msg: string = "navigation does not exist or refinements are already selected"
func
- func(__namedParameters: object, state: State): boolean
-
Parameters
-
__namedParameters: object
-
index: number
-
navigationId: string
-
Returns boolean
Const isRefinementDeselectedByValue
isRefinementDeselectedByValue: object
msg
msg: string = "refinement is already selected"
func
-
Parameters
Returns boolean
Const isRefinementSelectedByIndex
isRefinementSelectedByIndex: object
msg
msg: string = "navigation does not exist or refinement is not selected"
func
- func(__namedParameters: object, state: State): boolean
-
Parameters
-
__namedParameters: object
-
index: number
-
navigationId: string
-
Returns 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
-
Parameters
Returns boolean
Const isString
isString: object
msg
msg: string = "must be a non-empty string"
func
- func(value: any): boolean
-
Parameters
Returns boolean
Const isValidBias
isValidBias: object
msg
msg: string = "bias is invalid"
func
-
Parameters
Returns boolean
Const isValidClearField
isValidClearField: object
msg
msg: string = "clear must be a string or true"
func
- func(field: string | false | true): boolean
-
Parameters
-
field: string | false | true
Returns boolean
Const isValidPage
isValidPage: object
msg
msg: string = "page is invalid"
func
- func(page: number, state: State): boolean
-
Parameters
Returns boolean
Const isValidPastPurchasePage
isValidPastPurchasePage: object
msg
msg: string = "page is invalid"
func
- func(page: number, state: State): boolean
-
Parameters
Returns boolean
Const isValidQuery
isValidQuery: object
msg
msg: string = "search term is empty"
func
- func(query: string): boolean
-
Parameters
Returns boolean
Const isValidRange
isValidRange: object
msg
msg: string = "low value must be lower than high"
func
- func(__namedParameters: object): boolean
-
Parameters
-
__namedParameters: object
-
high: number
-
low: number
-
range: boolean
Returns boolean
Const isValueRefinement
isValueRefinement: object
msg
msg: string = `value ${isString.msg}`
func
- func(__namedParameters: object): boolean
-
Parameters
-
__namedParameters: object
-
range: boolean
-
value: string
Returns boolean
Const notOnFirstPage
notOnFirstPage: object
msg
msg: string = "page must not be on first page"
func
- func(_: any, state: State): boolean
-
Parameters
Returns boolean
Const notOnFirstPastPurchasePage
notOnFirstPastPurchasePage: object
msg
msg: string = "page must not be on first page"
func
- func(_: any, state: State): boolean
-
Parameters
Returns boolean
FluxCapacitor
State Management for StoreFront
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
andtest
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.