Skip to content

Commit 80f4cc4

Browse files
authored
Backport/swc native (#9237)
* fix CI push * backport node_obj_deserializer
1 parent cc4ff97 commit 80f4cc4

File tree

11 files changed

+565
-23
lines changed

11 files changed

+565
-23
lines changed

.github/workflows/push.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ jobs:
103103
# files: ./packages/*/coverage/clover.xml
104104
# flags: cube-backend
105105
# verbose: true # optional (default = false)
106-
107106
lint:
108107
runs-on: ubuntu-20.04
109108
timeout-minutes: 60

packages/cubejs-backend-native/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ minijinja = { version = "1", features = ["json", "loader"] }
3434
once_cell = "1.10"
3535
# python
3636
pyo3 = { version = "0.20.0", features = [], optional = true }
37-
pyo3-asyncio = { version = "0.20.0", features = ["tokio-runtime", "attributes"], optional = true }
37+
pyo3-asyncio = { version = "0.20.0", features = [
38+
"tokio-runtime",
39+
"attributes",
40+
], optional = true }
3841
serde = { version = "1.0.209", features = ["derive"] }
3942
serde_json = "1.0.127"
4043
simple_logger = "1.7.0"

packages/cubejs-backend-native/js/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ export type SQLInterfaceOptions = {
9898
gatewayPort?: number,
9999
};
100100

101+
export interface TransformConfig {
102+
fileName: string;
103+
transpilers: string[];
104+
compilerId: string;
105+
metaData?: {
106+
cubeNames: string[];
107+
cubeSymbols: Record<string, Record<string, boolean>>;
108+
contextSymbols: Record<string, string>;
109+
}
110+
}
111+
112+
export interface TransformResponse {
113+
code: string;
114+
errors: string[];
115+
warnings: string[];
116+
}
117+
101118
export function loadNative() {
102119
// Development version
103120
if (fs.existsSync(path.join(__dirname, '/../../index.node'))) {
@@ -348,6 +365,16 @@ export const buildSqlAndParams = (cubeEvaluator: any): String => {
348365
return native.buildSqlAndParams(cubeEvaluator);
349366
};
350367

368+
export const transpileJs = async (content: String, metadata: TransformConfig): Promise<TransformResponse> => {
369+
const native = loadNative();
370+
371+
if (native.transpileJs) {
372+
return native.transpileJs(content, metadata);
373+
}
374+
375+
throw new Error('TranspileJs native implementation not found!');
376+
};
377+
351378
export interface PyConfiguration {
352379
repositoryFactory?: (ctx: unknown) => Promise<unknown>,
353380
logger?: (msg: string, params: Record<string, any>) => void,

packages/cubejs-backend-native/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod cross;
1111
pub mod gateway;
1212
pub mod logger;
1313
pub mod node_export;
14+
pub mod node_obj_deserializer;
1415
pub mod node_obj_serializer;
1516
#[cfg(feature = "python")]
1617
pub mod python;

0 commit comments

Comments
 (0)