@@ -10,13 +10,29 @@ import type { ErrorReporter } from './ErrorReporter';
1010
1111export type ToString = { toString ( ) : string } ;
1212
13+ export type GranularityDefinition = {
14+ sql ?: ( ...args : any [ ] ) => string ;
15+ title ?: string ;
16+ interval ?: string ;
17+ offset ?: string ;
18+ origin ?: string ;
19+ } ;
20+
21+ export type TimeshiftDefinition = {
22+ interval ?: string ;
23+ type ?: string ;
24+ name ?: string ;
25+ timeDimension ?: ( ...args : any [ ] ) => string ;
26+ } ;
27+
1328export interface CubeDefinition {
1429 name : string ;
1530 extends ?: ( ...args : Array < unknown > ) => { __cubeName : string } ;
16- sql ?: string | ( ( ) => string ) ;
31+ sql ?: string | ( ( ... args : any [ ] ) => string ) ;
1732 // eslint-disable-next-line camelcase
18- sql_table ?: string | ( ( ) => string ) ;
19- sqlTable ?: string | ( ( ) => string ) ;
33+ sql_table ?: string | ( ( ...args : any [ ] ) => string ) ;
34+ sqlTable ?: string | ( ( ...args : any [ ] ) => string ) ;
35+ dataSource ?: string ;
2036 measures ?: Record < string , any > ;
2137 dimensions ?: Record < string , any > ;
2238 segments ?: Record < string , any > ;
@@ -34,9 +50,10 @@ export interface CubeDefinition {
3450 calendar ?: boolean ;
3551 isSplitView ?: boolean ;
3652 includedMembers ?: any [ ] ;
53+ fileName ?: string ;
3754}
3855
39- interface CubeDefinitionExtended extends CubeDefinition {
56+ export interface CubeDefinitionExtended extends CubeDefinition {
4057 allDefinitions : ( type : string ) => Record < string , any > ;
4158 rawFolders : ( ) => any [ ] ;
4259 rawCubes : ( ) => any [ ] ;
@@ -46,6 +63,22 @@ interface SplitViews {
4663 [ key : string ] : any ;
4764}
4865
66+ export type CubeSymbolDefinition = {
67+ type ?: string ;
68+ sql ?: ( ...args : any [ ] ) => string ;
69+ primaryKey ?: boolean ;
70+ granularities ?: Record < string , GranularityDefinition > ;
71+ timeShift ?: TimeshiftDefinition [ ] ;
72+ format ?: string ;
73+ } ;
74+
75+ export interface CubeSymbolsBase {
76+ cubeName : ( ) => string ;
77+ cubeObj : ( ) => CubeDefinitionExtended ;
78+ }
79+
80+ export type CubeSymbolsDefinition = CubeSymbolsBase & Record < string , CubeSymbolDefinition > ;
81+
4982const FunctionRegex = / f u n c t i o n \s + \w + \( ( [ A - Z a - z 0 - 9 _ , ] * ) | \( ( [ \s \S ] * ?) \) \s * = > | \( ? ( \w + ) \) ? \s * = > / ;
5083export const CONTEXT_SYMBOLS = {
5184 SECURITY_CONTEXT : 'securityContext' ,
@@ -61,15 +94,15 @@ export const CONTEXT_SYMBOLS = {
6194export const CURRENT_CUBE_CONSTANTS = [ 'CUBE' , 'TABLE' ] ;
6295
6396export class CubeSymbols {
64- public symbols : Record < string | symbol , any > ;
97+ public symbols : Record < string | symbol , CubeSymbolsDefinition > ;
6598
66- private builtCubes : Record < string , any > ;
99+ private builtCubes : Record < string , CubeDefinitionExtended > ;
67100
68101 private cubeDefinitions : Record < string , CubeDefinition > ;
69102
70103 private funcArgumentsValues : Record < string , string [ ] > ;
71104
72- public cubeList : any [ ] ;
105+ public cubeList : CubeDefinitionExtended [ ] ;
73106
74107 private readonly evaluateViews : boolean ;
75108
@@ -959,7 +992,7 @@ export class CubeSymbols {
959992 ) ,
960993 } ;
961994 }
962- if ( cube [ propertyName ] ) {
995+ if ( cube [ propertyName as string ] ) {
963996 return this . cubeReferenceProxy ( cubeName , joinHints , propertyName ) ;
964997 }
965998 if ( self . symbols [ propertyName ] ) {
@@ -1022,9 +1055,9 @@ export class CubeSymbols {
10221055 if ( propertyName === '_objectWithResolvedProperties' ) {
10231056 return true ;
10241057 }
1025- if ( cube [ propertyName ] ) {
1058+ if ( cube [ propertyName as string ] ) {
10261059 const index = depsResolveFn ( propertyName , parentIndex ) ;
1027- if ( cube [ propertyName ] . type === 'time' ) {
1060+ if ( cube [ propertyName as string ] . type === 'time' ) {
10281061 return this . timeDimDependenciesProxy ( index ) ;
10291062 }
10301063
0 commit comments