File tree Expand file tree Collapse file tree 3 files changed +48
-36
lines changed
packages/cubejs-schema-compiler/src/compiler Expand file tree Collapse file tree 3 files changed +48
-36
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { CubeEvaluator } from './CubeEvaluator' ;
2+ import { ErrorReporter } from './ErrorReporter' ;
3+
4+ export type ContextDefinition = {
5+ name : string ;
6+ contextMembers : string | string [ ] ;
7+ } ;
8+
9+ export class ContextEvaluator {
10+ private cubeEvaluator : CubeEvaluator ;
11+
12+ private contextDefinitions : Record < string , ContextDefinition > ;
13+
14+ public constructor ( cubeEvaluator : CubeEvaluator ) {
15+ this . cubeEvaluator = cubeEvaluator ;
16+ this . contextDefinitions = { } ;
17+ }
18+
19+ public compile ( contexts : any , errorReporter : ErrorReporter ) {
20+ if ( contexts . length === 0 ) {
21+ return ;
22+ }
23+
24+ const definitions : Record < string , ContextDefinition > = { } ;
25+
26+ for ( const v of contexts ) {
27+ if ( definitions [ v . name ] ) {
28+ errorReporter . error ( `Duplicate context name found: '${ v . name } '` ) ;
29+ } else {
30+ definitions [ v . name ] = this . compileContext ( v ) ;
31+ }
32+ }
33+
34+ this . contextDefinitions = definitions ;
35+ }
36+
37+ private compileContext ( context : any ) : ContextDefinition {
38+ return {
39+ name : context . name ,
40+ contextMembers : this . cubeEvaluator . evaluateReferences ( null , context . contextMembers )
41+ } ;
42+ }
43+
44+ public get contextList ( ) : string [ ] {
45+ return Object . keys ( this . contextDefinitions ) ;
46+ }
47+ }
Original file line number Diff line number Diff line change @@ -833,7 +833,7 @@ export class CubeSymbols {
833833 } ) ;
834834 }
835835
836- protected evaluateReferences < T extends ToString | Array < ToString > > (
836+ public evaluateReferences < T extends ToString | Array < ToString > > (
837837 cube : string | null ,
838838 referencesFn : ( ...args : Array < unknown > ) => T ,
839839 options : { collectJoinHints ?: boolean , originalSorting ?: boolean } = { }
You can’t perform that action at this time.
0 commit comments