Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ jobs:
# files: ./packages/*/coverage/clover.xml
# flags: cube-backend
# verbose: true # optional (default = false)

lint:
runs-on: ubuntu-20.04
timeout-minutes: 60
Expand Down
5 changes: 4 additions & 1 deletion packages/cubejs-backend-native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ minijinja = { version = "1", features = ["json", "loader"] }
once_cell = "1.10"
# python
pyo3 = { version = "0.20.0", features = [], optional = true }
pyo3-asyncio = { version = "0.20.0", features = ["tokio-runtime", "attributes"], optional = true }
pyo3-asyncio = { version = "0.20.0", features = [
"tokio-runtime",
"attributes",
], optional = true }
serde = { version = "1.0.209", features = ["derive"] }
serde_json = "1.0.127"
simple_logger = "1.7.0"
Expand Down
27 changes: 27 additions & 0 deletions packages/cubejs-backend-native/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ export type SQLInterfaceOptions = {
gatewayPort?: number,
};

export interface TransformConfig {
fileName: string;
transpilers: string[];
compilerId: string;
metaData?: {
cubeNames: string[];
cubeSymbols: Record<string, Record<string, boolean>>;
contextSymbols: Record<string, string>;
}
}

export interface TransformResponse {
code: string;
errors: string[];
warnings: string[];
}

export function loadNative() {
// Development version
if (fs.existsSync(path.join(__dirname, '/../../index.node'))) {
Expand Down Expand Up @@ -348,6 +365,16 @@ export const buildSqlAndParams = (cubeEvaluator: any): String => {
return native.buildSqlAndParams(cubeEvaluator);
};

export const transpileJs = async (content: String, metadata: TransformConfig): Promise<TransformResponse> => {
const native = loadNative();

if (native.transpileJs) {
return native.transpileJs(content, metadata);
}

throw new Error('TranspileJs native implementation not found!');
};

export interface PyConfiguration {
repositoryFactory?: (ctx: unknown) => Promise<unknown>,
logger?: (msg: string, params: Record<string, any>) => void,
Expand Down
1 change: 1 addition & 0 deletions packages/cubejs-backend-native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod cross;
pub mod gateway;
pub mod logger;
pub mod node_export;
pub mod node_obj_deserializer;
pub mod node_obj_serializer;
#[cfg(feature = "python")]
pub mod python;
Expand Down
Loading
Loading