Skip to content

Commit 8631d2c

Browse files
committed
move CubeDictionary to ts
1 parent ae142ff commit 8631d2c

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeDictionary.js

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { ErrorReporter } from './ErrorReporter';
2+
import { TranspilerCubeResolver } from './transpilers';
3+
4+
export interface Cube {
5+
name: string;
6+
[key: string]: any;
7+
}
8+
9+
export class CubeDictionary implements TranspilerCubeResolver {
10+
public byId: Record<string, Cube>;
11+
12+
public constructor() {
13+
this.byId = {};
14+
}
15+
16+
public compile(cubes: Cube[], _errorReporter?: ErrorReporter): void {
17+
this.byId = {};
18+
for (const cube of cubes) {
19+
this.byId[cube.name] = cube;
20+
}
21+
}
22+
23+
public resolveCube(name: string): boolean {
24+
return !!this.byId[name];
25+
}
26+
27+
public free(): void {
28+
this.byId = {};
29+
}
30+
}

0 commit comments

Comments
 (0)