import { QueryConfig , DEFAULT_QUERY_CONFIG } from './config' ; import { getEnumerator } from './enumerator' ; import { SpecQueryModel } from './model' ; import { fromKey } from './property' ; import { SpecQuery } from './query/spec' ; import { Schema } from './schema' ; import { stylize } from './stylize' ; export function generate ( specQ , schema , opt = DEFAULT_QUERY_CONFIG ) { const specM = SpecQueryModel . build ( specQ , schema , opt ) ; const wildcardIndex = specM . wildcardIndex ; let answerSet = [ specM ] ; opt . propertyPrecedence . forEach ( ( propKey ) => { const prop = fromKey ( propKey ) ; if ( wildcardIndex . hasProperty ( prop ) ) { const enumerator = getEnumerator ( prop ) ; const reducer = enumerator ( wildcardIndex , schema , opt ) ; answerSet = answerSet . reduce ( reducer , [ ] ) ; } } ) ; if ( opt . stylize ) { if ( opt . nominalColorScaleForHighCardinality !== null || opt . smallRangeStepForHighCardinalityOrFacet !== null || opt . xAxisOnTopForHighYCardinalityWithoutColumn !== null ) { return stylize ( answerSet , schema , opt ) ; } } return answerSet ; }