@cubejs-backend/server-core 1.5.4 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/src/core/CompilerApi.d.ts +139 -101
  2. package/dist/src/core/CompilerApi.d.ts.map +1 -1
  3. package/dist/src/core/CompilerApi.js +74 -35
  4. package/dist/src/core/CompilerApi.js.map +1 -1
  5. package/dist/src/core/DevServer.d.ts.map +1 -1
  6. package/dist/src/core/DevServer.js +5 -4
  7. package/dist/src/core/DevServer.js.map +1 -1
  8. package/dist/src/core/DriverDependencies.d.ts +3 -33
  9. package/dist/src/core/DriverDependencies.d.ts.map +1 -1
  10. package/dist/src/core/DriverDependencies.js +3 -1
  11. package/dist/src/core/DriverDependencies.js.map +1 -1
  12. package/dist/src/core/OptsHandler.d.ts.map +1 -1
  13. package/dist/src/core/OptsHandler.js +4 -10
  14. package/dist/src/core/OptsHandler.js.map +1 -1
  15. package/dist/src/core/OrchestratorApi.d.ts +1 -1
  16. package/dist/src/core/OrchestratorApi.d.ts.map +1 -1
  17. package/dist/src/core/OrchestratorApi.js +1 -3
  18. package/dist/src/core/OrchestratorApi.js.map +1 -1
  19. package/dist/src/core/OrchestratorStorage.d.ts +1 -1
  20. package/dist/src/core/RefreshScheduler.d.ts +10 -2
  21. package/dist/src/core/RefreshScheduler.d.ts.map +1 -1
  22. package/dist/src/core/logger.d.ts +20 -6
  23. package/dist/src/core/logger.d.ts.map +1 -1
  24. package/dist/src/core/logger.js +41 -43
  25. package/dist/src/core/logger.js.map +1 -1
  26. package/dist/src/core/server.d.ts +1 -1
  27. package/dist/src/core/server.js.map +1 -1
  28. package/dist/src/core/types.d.ts +6 -2
  29. package/dist/src/core/types.d.ts.map +1 -1
  30. package/index.js +1 -1
  31. package/package.json +13 -12
  32. package/playground/vizard/download/react-typescript-antd-table.zip +0 -0
  33. package/playground/vizard/download/react-typescript-chartjs-area+bar+doughnut+line+pie.zip +0 -0
@@ -1,130 +1,168 @@
1
- export class CompilerApi {
2
- /**
3
- * Class constructor.
4
- * @param {SchemaFileRepository} repository
5
- * @param {DbTypeAsyncFn} dbType
6
- * @param {*} options
7
- */
8
- constructor(repository: SchemaFileRepository, dbType: DbTypeAsyncFn, options: any);
9
- repository: SchemaFileRepository;
10
- dbType: DbTypeAsyncFn;
11
- dialectClass: any;
12
- options: any;
13
- allowNodeRequire: any;
14
- logger: any;
15
- preAggregationsSchema: any;
16
- allowUngroupedWithoutPrimaryKey: any;
17
- convertTzForRawTimeDimension: any;
18
- schemaVersion: any;
19
- contextToRoles: any;
20
- contextToGroups: any;
21
- compileContext: any;
22
- allowJsDuplicatePropsInSchema: any;
23
- sqlCache: any;
24
- standalone: any;
25
- nativeInstance: NativeInstance;
26
- compiledScriptCache: LRUCache<{}, {}, unknown>;
27
- compiledScriptCacheInterval: NodeJS.Timeout;
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import vm from 'vm';
4
+ import { BaseQuery, CanUsePreAggregationFn, Compiler, CubeDefinition, EvaluatedCube, PreAggregationFilters, PreAggregationInfo, PreAggregationReferences, QueryFactory, TransformedQuery } from '@cubejs-backend/schema-compiler';
5
+ import { GraphQLSchema } from 'graphql';
6
+ import { LRUCache } from 'lru-cache';
7
+ import { NativeInstance } from '@cubejs-backend/native';
8
+ import type { SchemaFileRepository } from '@cubejs-backend/shared';
9
+ import { NormalizedQuery } from '@cubejs-backend/api-gateway';
10
+ import { DbTypeAsyncFn, DialectClassFn, LoggerFn } from './types';
11
+ type Context = any;
12
+ export interface CompilerApiOptions {
13
+ dialectClass?: DialectClassFn;
14
+ logger?: LoggerFn;
15
+ preAggregationsSchema?: string | ((context: Context) => string | Promise<string>);
16
+ allowUngroupedWithoutPrimaryKey?: boolean;
17
+ convertTzForRawTimeDimension?: boolean;
18
+ schemaVersion?: () => string | object | Promise<string | object>;
19
+ contextToRoles?: (context: Context) => string[] | Promise<string[]>;
20
+ contextToGroups?: (context: Context) => string[] | Promise<string[]>;
21
+ compileContext?: any;
22
+ allowJsDuplicatePropsInSchema?: boolean;
23
+ sqlCache?: boolean;
24
+ standalone?: boolean;
25
+ compilerCacheSize?: number;
26
+ maxCompilerCacheKeepAlive?: number;
27
+ updateCompilerCacheKeepAlive?: boolean;
28
+ externalDialectClass?: BaseQuery;
29
+ externalDbType?: string;
30
+ devServer?: boolean;
31
+ fastReload?: boolean;
32
+ allowNodeRequire?: boolean;
33
+ }
34
+ export interface GetSqlOptions {
35
+ includeDebugInfo?: boolean;
36
+ exportAnnotatedSql?: boolean;
37
+ requestId?: string;
38
+ }
39
+ export interface SqlResult {
40
+ external: any;
41
+ sql: any;
42
+ lambdaQueries: any;
43
+ timeDimensionAlias?: string;
44
+ timeDimensionField?: string;
45
+ order?: any;
46
+ cacheKeyQueries: any;
47
+ preAggregations: any;
48
+ dataSource: string;
49
+ aliasNameToMember: any;
50
+ rollupMatchResults?: any;
51
+ canUseTransformedQuery: boolean;
52
+ memberNames: string[];
53
+ }
54
+ export interface DataSourceInfo {
55
+ dataSource: string;
56
+ dbType: string;
57
+ }
58
+ export declare class CompilerApi {
59
+ protected readonly repository: SchemaFileRepository;
60
+ protected readonly dbType: DbTypeAsyncFn;
61
+ protected readonly dialectClass?: DialectClassFn;
62
+ readonly options: CompilerApiOptions;
63
+ protected readonly allowNodeRequire: boolean;
64
+ protected readonly logger: (msg: string, params: any) => void;
65
+ protected readonly preAggregationsSchema?: string | ((context: Context) => string | Promise<string>);
66
+ protected readonly allowUngroupedWithoutPrimaryKey?: boolean;
67
+ protected readonly convertTzForRawTimeDimension?: boolean;
68
+ schemaVersion?: () => string | object | Promise<string | object>;
69
+ protected readonly contextToRoles?: (context: Context) => string[] | Promise<string[]>;
70
+ protected readonly contextToGroups?: (context: Context) => string[] | Promise<string[]>;
71
+ protected readonly compileContext?: any;
72
+ protected readonly allowJsDuplicatePropsInSchema?: boolean;
73
+ protected readonly sqlCache?: boolean;
74
+ protected readonly standalone?: boolean;
75
+ protected readonly nativeInstance: NativeInstance;
76
+ protected readonly compiledScriptCache: LRUCache<string, vm.Script>;
77
+ protected readonly compiledYamlCache: LRUCache<string, string>;
78
+ protected readonly compiledJinjaCache: LRUCache<string, string>;
79
+ protected compiledScriptCacheInterval?: NodeJS.Timeout;
80
+ protected graphqlSchema?: GraphQLSchema;
81
+ protected compilers?: Promise<Compiler>;
82
+ protected compilerVersion?: string;
83
+ protected queryFactory?: QueryFactory;
84
+ constructor(repository: SchemaFileRepository, dbType: DbTypeAsyncFn, options: CompilerApiOptions);
28
85
  dispose(): void;
29
- setGraphQLSchema(schema: any): void;
30
- graphqlSchema: any;
31
- getGraphQLSchema(): any;
86
+ setGraphQLSchema(schema: GraphQLSchema): void;
87
+ getGraphQLSchema(): GraphQLSchema;
32
88
  createNativeInstance(): NativeInstance;
33
- getCompilers({ requestId }?: {
34
- requestId: any;
35
- }): Promise<any>;
36
- compilers: any;
37
- compilerVersion: any;
89
+ getCompilers(options?: {
90
+ requestId?: string;
91
+ }): Promise<Compiler>;
38
92
  /**
39
93
  * Creates the compilers instances without model compilation,
40
94
  * because it could fail and no compilers will be returned.
41
95
  */
42
- createCompilerInstances(): {
43
- compiler: import("@cubejs-backend/schema-compiler/dist/src/compiler/DataSchemaCompiler").DataSchemaCompiler;
44
- metaTransformer: import("@cubejs-backend/schema-compiler/dist/src/compiler/CubeToMetaTransformer").CubeToMetaTransformer;
45
- cubeEvaluator: import("@cubejs-backend/schema-compiler/dist/src/compiler/CubeEvaluator").CubeEvaluator;
46
- contextEvaluator: import("@cubejs-backend/schema-compiler/dist/src/compiler/ContextEvaluator").ContextEvaluator;
47
- joinGraph: import("@cubejs-backend/schema-compiler/dist/src/compiler/JoinGraph").JoinGraph;
48
- compilerCache: import("@cubejs-backend/schema-compiler/dist/src/compiler/CompilerCache").CompilerCache;
49
- headCommitId: string;
50
- compilerId: string;
51
- };
52
- compileSchema(compilerVersion: any, requestId: any): Promise<any>;
53
- queryFactory: QueryFactory;
54
- createQueryFactory(compilers: any): Promise<QueryFactory>;
55
- getDbType(dataSource?: string): Promise<any>;
56
- getDialectClass(dataSource: string, dbType: any): any;
57
- getSqlGenerator(query: any, dataSource: any): Promise<{
96
+ createCompilerInstances(): Compiler;
97
+ compileSchema(compilerVersion: string, requestId?: string): Promise<Compiler>;
98
+ createQueryFactory(compilers: Compiler): Promise<QueryFactory>;
99
+ getDbType(dataSource?: string): Promise<string>;
100
+ getDialectClass(dataSource: string, dbType: string): BaseQuery;
101
+ getSqlGenerator(query: NormalizedQuery, dataSource?: string): Promise<{
58
102
  sqlGenerator: any;
59
- compilers: any;
103
+ compilers: Compiler;
60
104
  }>;
61
- getSql(query: any, options?: {}): Promise<any>;
62
- getRolesFromContext(context: any): Promise<Set<any>>;
63
- getGroupsFromContext(context: any): Promise<Set<any>>;
64
- userHasRole(userRoles: any, role: any): any;
65
- userHasGroup(userGroups: any, group: any): any;
66
- roleMeetsConditions(evaluatedConditions: any): any;
67
- getCubesFromQuery(query: any, context: any): Promise<Set<any>>;
68
- hashRequestContext(context: any): any;
69
- getApplicablePolicies(cube: any, context: any, compilers: any): Promise<any>;
70
- evaluateNestedFilter(filter: any, cube: any, context: any, cubeEvaluator: any): {
71
- member: any;
72
- operator: any;
73
- values: any;
74
- or: any;
75
- and: any;
76
- };
105
+ getSql(query: NormalizedQuery, options?: GetSqlOptions): Promise<SqlResult>;
106
+ protected getRolesFromContext(context: Context): Promise<Set<string>>;
107
+ protected getGroupsFromContext(context: Context): Promise<Set<string>>;
108
+ protected userHasRole(userRoles: Set<string>, role: string): boolean;
109
+ protected userHasGroup(userGroups: Set<string>, group: string | string[]): boolean;
110
+ protected roleMeetsConditions(evaluatedConditions?: any[]): boolean;
111
+ protected getCubesFromQuery(query: NormalizedQuery, context?: Context): Promise<Set<string>>;
112
+ protected hashRequestContext(context: Context): string;
113
+ protected getApplicablePolicies(cube: EvaluatedCube, context: Context, compilers: Compiler): Promise<any[]>;
114
+ protected evaluateNestedFilter(filter: any, cube: any, context: Context, cubeEvaluator: any): any;
77
115
  /**
78
116
  * This method rewrites the query according to RBAC row level security policies.
79
117
  *
80
118
  * If RBAC is enabled, it looks at all the Cubes from the query with accessPolicy defined.
81
119
  * It extracts all policies applicable to for the current user context (contextToRoles() + conditions).
82
- * It then generates an rls filter by
120
+ * It then generates a rls filter by
83
121
  * - combining all filters for the same role with AND
84
122
  * - combining all filters for different roles with OR
85
123
  * - combining cube and view filters with AND
86
124
  */
87
- applyRowLevelSecurity(query: any, evaluatedQuery: any, context: any): Promise<{
88
- query: any;
125
+ applyRowLevelSecurity(query: NormalizedQuery, evaluatedQuery: NormalizedQuery, context: Context): Promise<{
126
+ query: NormalizedQuery;
89
127
  denied: boolean;
90
128
  }>;
91
- removeEmptyFilters(filter: any): any;
92
- buildFinalRlsFilter(cubeFiltersPerCubePerRole: any, viewFiltersPerCubePerRole: any, hasAllowAllForCube: any): any;
93
- compilerCacheFn(requestId: any, key: any, path: any): Promise<(subKey: any, cacheFn: any) => any>;
94
- /**
95
- *
96
- * @param {unknown|undefined} filter
97
- * @returns {Promise<Array<PreAggregationInfo>>}
98
- */
99
- preAggregations(filter: unknown | undefined): Promise<Array<PreAggregationInfo>>;
100
- scheduledPreAggregations(): Promise<any>;
101
- createQueryByDataSource(compilers: any, query: any, dataSource: any, dbType: any): Promise<any>;
102
- createQuery(compilers: any, dbType: any, dialectClass: any, query: any): any;
129
+ protected removeEmptyFilters(filter: any): any;
130
+ protected buildFinalRlsFilter(cubeFiltersPerCubePerRole: Record<string, Record<string, any[]>>, viewFiltersPerCubePerRole: Record<string, Record<string, any[]>>, hasAllowAllForCube: Record<string, boolean>): any;
131
+ compilerCacheFn(requestId: string, key: any, path: string[]): Promise<(subKey: string[], cacheFn: () => any) => any>;
132
+ preAggregations(filter?: PreAggregationFilters): Promise<PreAggregationInfo[]>;
133
+ scheduledPreAggregations(): Promise<PreAggregationInfo[]>;
134
+ createQueryByDataSource(compilers: Compiler, query: NormalizedQuery | {}, dataSource?: string, dbType?: string): Promise<BaseQuery>;
135
+ createQuery(compilers: Compiler, dbType: string, dialectClass: BaseQuery, query: NormalizedQuery | {}): BaseQuery;
103
136
  /**
104
137
  * if RBAC is enabled, this method is used to patch isVisible property of cube members
105
138
  * based on access policies.
106
139
  */
107
- patchVisibilityByAccessPolicy(compilers: any, context: any, cubes: any): Promise<{
108
- cubes: any;
109
- visibilityMaskHash: string;
140
+ protected patchVisibilityByAccessPolicy(compilers: Compiler, context: Context, cubes: any[]): Promise<{
141
+ cubes: any[];
142
+ visibilityMaskHash: string | null;
110
143
  }>;
111
- mixInVisibilityMaskHash(compilerId: any, visibilityMaskHash: any): string;
112
- metaConfig(requestContext: any, options?: {}): Promise<any>;
113
- metaConfigExtended(requestContext: any, options: any): Promise<{
144
+ protected mixInVisibilityMaskHash(compilerId: string, visibilityMaskHash: string): string;
145
+ metaConfig(requestContext: Context, options?: {
146
+ includeCompilerId?: boolean;
147
+ requestId?: string;
148
+ }): Promise<any>;
149
+ metaConfigExtended(requestContext: Context, options?: {
150
+ requestId?: string;
151
+ }): Promise<{
114
152
  metaConfig: any;
115
- cubeDefinitions: any;
116
- }>;
117
- compilerId(options?: {}): Promise<any>;
118
- cubeNameToDataSource(query: any): Promise<any>;
119
- memberToDataSource(query: any): Promise<{
120
- [k: string]: any;
153
+ cubeDefinitions: Record<string, CubeDefinition>;
121
154
  }>;
122
- dataSources(orchestratorApi: any, query: any): Promise<{
123
- dataSources: any[];
155
+ compilerId(options?: {
156
+ requestId?: string;
157
+ }): Promise<string>;
158
+ cubeNameToDataSource(query: {
159
+ requestId?: string;
160
+ }): Promise<Record<string, string>>;
161
+ memberToDataSource(query: NormalizedQuery): Promise<Record<string, string>>;
162
+ dataSources(orchestratorApi: any, query?: NormalizedQuery): Promise<{
163
+ dataSources: DataSourceInfo[];
124
164
  }>;
125
- canUsePreAggregationForTransformedQuery(transformedQuery: any, refs: any): import("@cubejs-backend/schema-compiler").CanUsePreAggregationFn;
165
+ canUsePreAggregationForTransformedQuery(transformedQuery: TransformedQuery, refs?: PreAggregationReferences | null): CanUsePreAggregationFn;
126
166
  }
127
- import { NativeInstance } from '@cubejs-backend/native';
128
- import { LRUCache } from 'lru-cache';
129
- import { QueryFactory } from '@cubejs-backend/schema-compiler';
167
+ export {};
130
168
  //# sourceMappingURL=CompilerApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CompilerApi.d.ts","sourceRoot":"","sources":["../../../src/core/CompilerApi.js"],"names":[],"mappings":"AAaA;IACE;;;;;OAKG;IAEH,mFA+BC;IA9BC,iCAA4B;IAC5B,sBAAoB;IACpB,kBAAwC;IACxC,aAA4B;IAC5B,sBAA0F;IAC1F,YAAiC;IACjC,2BAA+D;IAC/D,qCAAmF;IACnF,kCAA6E;IAC7E,mBAA+C;IAC/C,oBAAiD;IACjD,qBAAmD;IACnD,oBAA4C;IAC5C,mCAA0E;IAC1E,cAAgC;IAChC,gBAAoC;IACpC,+BAAiD;IACjD,+CAIE;IAIA,4CAGC;IAIL,gBAIC;IAED,oCAEC;IADC,mBAA2B;IAG7B,wBAEC;IAED,uCAEC;IAED;;qBAwBC;IARG,eAGE;IACF,qBAAsC;IAM1C;;;OAGG;IACH;;;;;;;;;MASC;IAED,kEAkCC;IAlBG,2BAA4D;IAoBhE,0DAcC;IAED,6CAEC;IAED,sDAEC;IAED;;;OAiCC;IAED,+CA6BC;IAED,qDAKC;IAED,sDAKC;IAED,4CAEC;IAED,+CAKC;IAED,mDAUC;IAED,+DAGC;IAED,sCAKC;IAED,6EAkDC;IAED;;;;;;MAoBC;IAED;;;;;;;;;MASE;IACF;;;OAuEC;IAED,qCAUC;IAED,kHAoCC;IAED,kGAOC;IAED;;;;OAIG;IACH,wBAHW,OAAO,GAAC,SAAS,GACf,QAAQ,yBAAyB,CAAC,CAK9C;IAED,yCAGC;IAED,gGAMC;IAED,6EAeC;IAED;;;MAGE;IACF;;;OA4EC;IAED,0EAKC;IAED,4DAoBC;IAED;;;OAWC;IAED,u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EAAE,cAAc,EAAE,CAAA;KAAE,CAAC;IAwBtC,uCAAuC,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,GAAE,wBAAwB,GAAG,IAAW,GAAG,sBAAsB;CAGzJ"}
@@ -9,20 +9,41 @@ const schema_compiler_1 = require("@cubejs-backend/schema-compiler");
9
9
  const uuid_1 = require("uuid");
10
10
  const lru_cache_1 = require("lru-cache");
11
11
  const native_1 = require("@cubejs-backend/native");
12
+ const shared_1 = require("@cubejs-backend/shared");
12
13
  class CompilerApi {
13
- /**
14
- * Class constructor.
15
- * @param {SchemaFileRepository} repository
16
- * @param {DbTypeAsyncFn} dbType
17
- * @param {*} options
18
- */
14
+ repository;
15
+ dbType;
16
+ dialectClass;
17
+ options;
18
+ allowNodeRequire;
19
+ logger;
20
+ preAggregationsSchema;
21
+ allowUngroupedWithoutPrimaryKey;
22
+ convertTzForRawTimeDimension;
23
+ schemaVersion;
24
+ contextToRoles;
25
+ contextToGroups;
26
+ compileContext;
27
+ allowJsDuplicatePropsInSchema;
28
+ sqlCache;
29
+ standalone;
30
+ nativeInstance;
31
+ compiledScriptCache;
32
+ compiledYamlCache;
33
+ compiledJinjaCache;
34
+ compiledScriptCacheInterval;
35
+ graphqlSchema;
36
+ compilers;
37
+ compilerVersion;
38
+ queryFactory;
19
39
  constructor(repository, dbType, options) {
20
40
  this.repository = repository;
21
41
  this.dbType = dbType;
22
42
  this.dialectClass = options.dialectClass;
23
43
  this.options = options || {};
24
44
  this.allowNodeRequire = options.allowNodeRequire == null ? true : options.allowNodeRequire;
25
- this.logger = this.options.logger;
45
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
46
+ this.logger = this.options.logger || (() => { });
26
47
  this.preAggregationsSchema = this.options.preAggregationsSchema;
27
48
  this.allowUngroupedWithoutPrimaryKey = this.options.allowUngroupedWithoutPrimaryKey;
28
49
  this.convertTzForRawTimeDimension = this.options.convertTzForRawTimeDimension;
@@ -34,20 +55,41 @@ class CompilerApi {
34
55
  this.sqlCache = options.sqlCache;
35
56
  this.standalone = options.standalone;
36
57
  this.nativeInstance = this.createNativeInstance();
58
+ // Caching stuff
37
59
  this.compiledScriptCache = new lru_cache_1.LRUCache({
38
60
  max: options.compilerCacheSize || 250,
39
61
  ttl: options.maxCompilerCacheKeepAlive,
40
62
  updateAgeOnGet: options.updateCompilerCacheKeepAlive
41
63
  });
64
+ this.compiledYamlCache = new lru_cache_1.LRUCache({
65
+ max: options.compilerCacheSize || 250,
66
+ ttl: options.maxCompilerCacheKeepAlive,
67
+ updateAgeOnGet: options.updateCompilerCacheKeepAlive
68
+ });
69
+ this.compiledJinjaCache = new lru_cache_1.LRUCache({
70
+ max: options.compilerCacheSize || 250,
71
+ ttl: options.maxCompilerCacheKeepAlive,
72
+ updateAgeOnGet: options.updateCompilerCacheKeepAlive
73
+ });
42
74
  // proactively free up old cache values occasionally
43
75
  if (this.options.maxCompilerCacheKeepAlive) {
44
- this.compiledScriptCacheInterval = setInterval(() => this.compiledScriptCache.purgeStale(), this.options.maxCompilerCacheKeepAlive);
76
+ this.compiledScriptCacheInterval = setInterval(() => {
77
+ this.compiledScriptCache.purgeStale();
78
+ this.compiledYamlCache.purgeStale();
79
+ this.compiledJinjaCache.purgeStale();
80
+ }, this.options.maxCompilerCacheKeepAlive);
45
81
  }
46
82
  }
47
83
  dispose() {
48
84
  if (this.compiledScriptCacheInterval) {
49
85
  clearInterval(this.compiledScriptCacheInterval);
86
+ this.compiledScriptCacheInterval = null;
50
87
  }
88
+ // freeing memory-heavy allocated instances
89
+ // using safeguard for potential dangling references.
90
+ this.compilers = (0, shared_1.disposedProxy)('compilers', 'disposed CompilerApi instance');
91
+ this.queryFactory = (0, shared_1.disposedProxy)('queryFactory', 'disposed CompilerApi instance');
92
+ this.graphqlSchema = undefined;
51
93
  }
52
94
  setGraphQLSchema(schema) {
53
95
  this.graphqlSchema = schema;
@@ -58,7 +100,7 @@ class CompilerApi {
58
100
  createNativeInstance() {
59
101
  return new native_1.NativeInstance();
60
102
  }
61
- async getCompilers({ requestId } = {}) {
103
+ async getCompilers(options = {}) {
62
104
  let compilerVersion = (this.schemaVersion && await this.schemaVersion() ||
63
105
  'default_schema_version');
64
106
  if (typeof compilerVersion === 'object') {
@@ -69,7 +111,7 @@ class CompilerApi {
69
111
  compilerVersion += `_${crypto_1.default.createHash('md5').update(JSON.stringify(files)).digest('hex')}`;
70
112
  }
71
113
  if (!this.compilers || this.compilerVersion !== compilerVersion) {
72
- this.compilers = this.compileSchema(compilerVersion, requestId).catch(e => {
114
+ this.compilers = this.compileSchema(compilerVersion, options.requestId).catch(e => {
73
115
  this.compilers = undefined;
74
116
  throw e;
75
117
  });
@@ -105,6 +147,8 @@ class CompilerApi {
105
147
  standalone: this.standalone,
106
148
  nativeInstance: this.nativeInstance,
107
149
  compiledScriptCache: this.compiledScriptCache,
150
+ compiledJinjaCache: this.compiledJinjaCache,
151
+ compiledYamlCache: this.compiledYamlCache,
108
152
  });
109
153
  this.queryFactory = await this.createQueryFactory(compilers);
110
154
  this.logger('Compiling schema completed', {
@@ -135,7 +179,7 @@ class CompilerApi {
135
179
  return new schema_compiler_1.QueryFactory(cubeToQueryClass);
136
180
  }
137
181
  async getDbType(dataSource = 'default') {
138
- return this.dbType({ dataSource, });
182
+ return this.dbType({ dataSource, securityContext: {}, requestId: '' });
139
183
  }
140
184
  getDialectClass(dataSource = 'default', dbType) {
141
185
  return this.dialectClass?.({ dataSource, dbType });
@@ -225,7 +269,7 @@ class CompilerApi {
225
269
  return true;
226
270
  }
227
271
  async getCubesFromQuery(query, context) {
228
- const sql = await this.getSql(query, { requestId: context.requestId });
272
+ const sql = await this.getSql(query, { requestId: context?.requestId });
229
273
  return new Set(sql.memberNames.map(memberName => memberName.split('.')[0]));
230
274
  }
231
275
  hashRequestContext(context) {
@@ -240,7 +284,7 @@ class CompilerApi {
240
284
  if (!cache.has(cacheKey)) {
241
285
  const userRoles = await this.getRolesFromContext(context);
242
286
  const userGroups = await this.getGroupsFromContext(context);
243
- const policies = cube.accessPolicy.filter(policy => {
287
+ const policies = cube.accessPolicy.filter((policy) => {
244
288
  // Validate that policy doesn't have both role and group/groups - this is invalid
245
289
  if (policy.role && (policy.group || policy.groups)) {
246
290
  const groupValue = policy.group || policy.groups;
@@ -254,7 +298,7 @@ class CompilerApi {
254
298
  const groupsDisplay = Array.isArray(policy.groups) ? policy.groups.join(', ') : policy.groups;
255
299
  throw new Error(`Access policy cannot have both 'group' and 'groups' properties.\nPolicy in cube '${cube.name}' has group '${groupDisplay}' and groups '${groupsDisplay}'.\nUse either 'group' or 'groups', not both.`);
256
300
  }
257
- const evaluatedConditions = (policy.conditions || []).map(condition => compilers.cubeEvaluator.evaluateContextFunction(cube, condition.if, context));
301
+ const evaluatedConditions = (policy.conditions || []).map((condition) => compilers.cubeEvaluator.evaluateContextFunction(cube, condition.if, context));
258
302
  // Check if policy matches by role, group, or groups
259
303
  let hasAccess = false;
260
304
  if (policy.role) {
@@ -286,10 +330,10 @@ class CompilerApi {
286
330
  result.values = evaluatedValues;
287
331
  }
288
332
  if (filter.or) {
289
- result.or = filter.or.map(f => this.evaluateNestedFilter(f, cube, context, cubeEvaluator));
333
+ result.or = filter.or.map((f) => this.evaluateNestedFilter(f, cube, context, cubeEvaluator));
290
334
  }
291
335
  if (filter.and) {
292
- result.and = filter.and.map(f => this.evaluateNestedFilter(f, cube, context, cubeEvaluator));
336
+ result.and = filter.and.map((f) => this.evaluateNestedFilter(f, cube, context, cubeEvaluator));
293
337
  }
294
338
  return result;
295
339
  }
@@ -298,7 +342,7 @@ class CompilerApi {
298
342
  *
299
343
  * If RBAC is enabled, it looks at all the Cubes from the query with accessPolicy defined.
300
344
  * It extracts all policies applicable to for the current user context (contextToRoles() + conditions).
301
- * It then generates an rls filter by
345
+ * It then generates a rls filter by
302
346
  * - combining all filters for the same role with AND
303
347
  * - combining all filters for different roles with OR
304
348
  * - combining cube and view filters with AND
@@ -323,7 +367,7 @@ class CompilerApi {
323
367
  const userPolicies = await this.getApplicablePolicies(cube, context, compilers);
324
368
  for (const policy of userPolicies) {
325
369
  hasAccessPermission = true;
326
- (policy?.rowLevel?.filters || []).forEach(filter => {
370
+ (policy?.rowLevel?.filters || []).forEach((filter) => {
327
371
  filtersMap[cubeName] = filtersMap[cubeName] || {};
328
372
  // Create a unique key for the policy (either role, group, or groups)
329
373
  const groupValue = policy.group || policy.groups;
@@ -335,7 +379,7 @@ class CompilerApi {
335
379
  });
336
380
  if (!policy?.rowLevel || policy?.rowLevel?.allowAll) {
337
381
  hasAllowAllForCube[cubeName] = true;
338
- // We don't have a way to add an "all alloed" filter like `WHERE 1 = 1` or something.
382
+ // We don't have a way to add an "all allowed" filter like `WHERE 1 = 1` or something.
339
383
  // Instead, we'll just mark that the user has "all" access to a given cube and remove
340
384
  // all filters later
341
385
  break;
@@ -363,11 +407,11 @@ class CompilerApi {
363
407
  }
364
408
  removeEmptyFilters(filter) {
365
409
  if (filter?.and) {
366
- const and = filter.and.map(f => this.removeEmptyFilters(f)).filter(f => f);
410
+ const and = filter.and.map((f) => this.removeEmptyFilters(f)).filter((f) => f);
367
411
  return and.length > 1 ? { and } : and.at(0) || null;
368
412
  }
369
413
  if (filter?.or) {
370
- const or = filter.or.map(f => this.removeEmptyFilters(f)).filter(f => f);
414
+ const or = filter.or.map((f) => this.removeEmptyFilters(f)).filter((f) => f);
371
415
  return or.length > 1 ? { or } : or.at(0) || null;
372
416
  }
373
417
  return filter;
@@ -409,11 +453,6 @@ class CompilerApi {
409
453
  return (subKey, cacheFn) => cacheFn();
410
454
  }
411
455
  }
412
- /**
413
- *
414
- * @param {unknown|undefined} filter
415
- * @returns {Promise<Array<PreAggregationInfo>>}
416
- */
417
456
  async preAggregations(filter) {
418
457
  const { cubeEvaluator } = await this.getCompilers();
419
458
  return cubeEvaluator.preAggregations(filter);
@@ -494,10 +533,10 @@ class CompilerApi {
494
533
  public: item.public && isMemberVisibleInContext[item.name]
495
534
  });
496
535
  };
497
- const visibiliyMask = JSON.stringify(isMemberVisibleInContext, Object.keys(isMemberVisibleInContext).sort());
536
+ const visibilityMask = JSON.stringify(isMemberVisibleInContext, Object.keys(isMemberVisibleInContext).sort());
498
537
  // This hash will be returned along the modified meta config and can be used
499
538
  // to distinguish between different "schema versions" after DAP visibility is applied
500
- const visibilityMaskHash = crypto_1.default.createHash('sha256').update(visibiliyMask).digest('hex');
539
+ const visibilityMaskHash = crypto_1.default.createHash('sha256').update(visibilityMask).digest('hex');
501
540
  return {
502
541
  cubes: cubes
503
542
  .map((cube) => ({
@@ -513,7 +552,7 @@ class CompilerApi {
513
552
  };
514
553
  }
515
554
  mixInVisibilityMaskHash(compilerId, visibilityMaskHash) {
516
- const uuidBytes = (0, uuid_1.parse)(compilerId);
555
+ const uuidBytes = Buffer.from((0, uuid_1.parse)(compilerId));
517
556
  const hashBytes = Buffer.from(visibilityMaskHash, 'hex');
518
557
  return (0, uuid_1.v4)({ random: crypto_1.default.createHash('sha256').update(uuidBytes).update(hashBytes).digest()
519
558
  .subarray(0, 16) });
@@ -527,8 +566,8 @@ class CompilerApi {
527
566
  return {
528
567
  cubes: patchedCubes,
529
568
  // This compilerId is primarily used by the cubejs-backend-native or caching purposes.
530
- // By default it doesn't account for member visibility changes introduced above by DAP.
531
- // Here we're modifying the originila compilerId in a way that it's distinct for
569
+ // By default, it doesn't account for member visibility changes introduced above by DAP.
570
+ // Here we're modifying the original compilerId in a way that it's distinct for
532
571
  // distinct schema versions while still being a valid UUID.
533
572
  compilerId: visibilityMaskHash ? this.mixInVisibilityMaskHash(compilers.compilerId, visibilityMaskHash) : compilers.compilerId,
534
573
  };
@@ -560,7 +599,7 @@ class CompilerApi {
560
599
  const cubeDef = cubeEvaluator.cubeFromPath(cube);
561
600
  if (cubeDef.isView) {
562
601
  const viewName = cubeDef.name;
563
- return cubeDef.includedMembers?.map(included => {
602
+ return cubeDef.includedMembers?.map((included) => {
564
603
  const memberName = `${viewName}.${included.name}`;
565
604
  const refCubeDef = cubeEvaluator.cubeFromPath(included.memberPath);
566
605
  const dataSource = refCubeDef.dataSource ?? 'default';
@@ -583,7 +622,7 @@ class CompilerApi {
583
622
  const cubeNameToDataSource = await this.cubeNameToDataSource(query || { requestId: `datasources-${(0, uuid_1.v4)()}` });
584
623
  let dataSources = Object.keys(cubeNameToDataSource).map(c => cubeNameToDataSource[c]);
585
624
  dataSources = [...new Set(dataSources)];
586
- dataSources = await Promise.all(dataSources.map(async (dataSource) => {
625
+ const dataSourcesInfo = await Promise.all(dataSources.map(async (dataSource) => {
587
626
  try {
588
627
  await orchestratorApi.driverFactory(dataSource);
589
628
  const dbType = await this.getDbType(dataSource);
@@ -594,10 +633,10 @@ class CompilerApi {
594
633
  }
595
634
  }));
596
635
  return {
597
- dataSources: dataSources.filter((source) => source),
636
+ dataSources: dataSourcesInfo.filter((source) => !!source),
598
637
  };
599
638
  }
600
- canUsePreAggregationForTransformedQuery(transformedQuery, refs) {
639
+ canUsePreAggregationForTransformedQuery(transformedQuery, refs = null) {
601
640
  return schema_compiler_1.PreAggregations.canUsePreAggregationForTransformedQueryFn(transformedQuery, refs);
602
641
  }
603
642
  }