import { StateWithHistory } from 'redux-undo' ; import { GenericState , UndoableStateBase } from '../models' ; import { createSelector } from 'reselect' ; import { InlineData } from 'vega-lite/build/src/data' ; import { isArray } from 'vega-util' ; import { State } from '../models' ; import { Bookmark } from '../models/bookmark' ; import { VoyagerConfig } from '../models/config' ; import { CustomWildcardField } from '../models/custom-wildcard-field' ; import { Log } from '../models/log' ; import { RelatedViews } from '../models/related-views' ; import { ShelfPreview } from '../models/shelf-preview' ; import { ShelfFilter , toPredicateFunction } from '../models/shelf/filter' ; import { selectData } from './dataset' ; import { selectFilters } from './shelf' ; export * from './dataset' ; export * from './result' ; export * from './shelf' ; export * from './tab' ; export const selectBookmark = ( state ) : Bookmark => state . persistent . bookmark ; export const selectConfig = ( state ) : VoyagerConfig => state . persistent . config ; export const selectRelatedViews = ( state ) : RelatedViews => state . persistent . relatedViews ; export const selectShelfPreview = ( state ) : ShelfPreview => state . persistent . shelfPreview ; export const selectLog = ( state ) : Log => state . persistent . log ; export const selectCustomWildcardFields = ( state ) : CustomWildcardField [ ] => { return state . undoable . present . customWildcardFields ; } ; export const selectFilteredData = createSelector ( selectData , selectFilters , ( data , filters ) : InlineData => { if ( ! data || filters . length === 0 ) { return data ; } const filter = toPredicateFunction ( filters ) ; if ( ! isArray ( data . values ) ) { throw new Error ( 'Voyager only supports array values' ) ; } const dataVals = data . values as any ; const values = dataVals . filter ( filter ) ; return { values } ; } ) ;