Skip to content
Closed
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
2,627 changes: 1,531 additions & 1,096 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.1",
"simple-git": "^3.27.0",
"snowflake-sdk": "^2.0.3",
"snowflake-sdk": "^3.3.0",
"split-pane-react": "^0.1.3",
"tar": "^7.4.3",
"uuid": "^11.1.0",
Expand Down
22 changes: 19 additions & 3 deletions src/main/extractor/snowflake.extractor.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
/* eslint-disable no-restricted-syntax, no-await-in-loop, consistent-return */
import snowflake from 'snowflake-sdk';
import { Column, Table } from '../../types/backend';
import { Column, SnowflakeAuthMethod, Table } from '../../types/backend';

export default class SnowflakeExtractor {
private connection: snowflake.Connection;

constructor(config: {
account: string;
username: string;
password: string;
password?: string;
warehouse: string;
database: string;
schema: string;
role?: string;
authMethod?: SnowflakeAuthMethod;
}) {
this.connection = snowflake.createConnection(config);
const authMethod =
config.authMethod === 'web_browser' ? 'web_browser' : 'password';
this.connection = snowflake.createConnection({
account: config.account,
username: config.username,
...(authMethod === 'web_browser'
? {
authenticator: 'OAUTH_AUTHORIZATION_CODE' as const,
clientStoreTemporaryCredential: true, // Use the token cached by the initial connection
}
: { password: config.password }),
warehouse: config.warehouse,
database: config.database,
schema: config.schema,
role: config.role,
});
}

async connect(): Promise<void> {
Expand Down
8 changes: 8 additions & 0 deletions src/main/ipcHandlers/connectors.ipcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ const registerConnectorsHandlers = () => {
return ConnectorsService.testConnection(body);
});

ipcMain.handle('connector:revokeSnowflakeToken', async () => {
return ConnectorsService.revokeSnowflakeToken();
});

ipcMain.handle('connector:hasSnowflakeToken', async () => {
return ConnectorsService.hasSnowflakeToken();
});

ipcMain.handle(
'connector:update',
async (_event, body: UpdateConnectionBody) => {
Expand Down
20 changes: 15 additions & 5 deletions src/main/services/ai/tools/studio/connections.tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import type {
MinIOConfig,
RustfsConfig,
} from '../../../../../types/frontend';
import type {
ConnectorTestResponse,
ConnectionTestResult,
BigQueryTestResponse,
} from '../../../../../types/backend';
import CloudExplorerService from '../../../cloudExplorer.service';
import ConnectorsService from '../../../connectors.service';
import DuckLakeService from '../../../duckLake.service';
Expand All @@ -20,14 +25,19 @@ const STUDIO_CLOUD_CONNECTION_TEST_FLAG = 'studio.cloud.connection_test';

type ConnectionHealth = 'healthy' | 'unhealthy' | 'unknown';

function toHealthLabel(
testResult: boolean | { success: boolean },
): ConnectionHealth {
function toHealthLabel(testResult: ConnectorTestResponse): ConnectionHealth {
if (typeof testResult === 'boolean') {
return testResult ? 'healthy' : 'unhealthy';
}
if (typeof testResult?.success === 'boolean') {
return testResult.success ? 'healthy' : 'unhealthy';
if (typeof testResult === 'object' && testResult !== null) {
if ('ok' in testResult) {
return (testResult as ConnectionTestResult).ok ? 'healthy' : 'unhealthy';
}
if ('success' in testResult) {
return (testResult as BigQueryTestResponse).success
? 'healthy'
: 'unhealthy';
}
}
return 'unknown';
}
Expand Down
24 changes: 18 additions & 6 deletions src/main/services/cloudExplorer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ class CloudExplorerService {
Bucket: bucketName,
Key: objectKey,
});
return await getSignedUrl(client, command, { expiresIn: 3600 });
return await getSignedUrl(client as any, command as any, {
expiresIn: 3600,
});
} catch (error) {
throw new Error(`Error generating S3 signed URL: ${error}`);
}
Expand Down Expand Up @@ -653,7 +655,9 @@ class CloudExplorerService {
Bucket: bucketName,
Key: objectKey,
});
return await getSignedUrl(client, command, { expiresIn: 3600 });
return await getSignedUrl(client as any, command as any, {
expiresIn: 3600,
});
} catch (error) {
throw new Error(`Error generating MinIO signed URL: ${error}`);
}
Expand Down Expand Up @@ -835,7 +839,9 @@ class CloudExplorerService {
Bucket: bucketName,
Key: objectKey,
});
return await getSignedUrl(client, command, { expiresIn: 3600 });
return await getSignedUrl(client as any, command as any, {
expiresIn: 3600,
});
} catch (error) {
throw new Error(`Error generating Cloudflare R2 signed URL: ${error}`);
}
Expand Down Expand Up @@ -1033,7 +1039,9 @@ class CloudExplorerService {
Bucket: bucketName,
Key: objectKey,
});
return await getSignedUrl(client, command, { expiresIn: 3600 });
return await getSignedUrl(client as any, command as any, {
expiresIn: 3600,
});
} catch (error) {
throw new Error(`Error generating Backblaze B2 signed URL: ${error}`);
}
Expand Down Expand Up @@ -1217,7 +1225,9 @@ class CloudExplorerService {
Bucket: bucketName,
Key: objectKey,
});
return await getSignedUrl(client, command, { expiresIn: 3600 });
return await getSignedUrl(client as any, command as any, {
expiresIn: 3600,
});
} catch (error) {
throw new Error(`Error generating rustfs signed URL: ${error}`);
}
Expand Down Expand Up @@ -1403,7 +1413,9 @@ class CloudExplorerService {
Bucket: bucketName,
Key: objectKey,
});
return await getSignedUrl(client, command, { expiresIn: 3600 });
return await getSignedUrl(client as any, command as any, {
expiresIn: 3600,
});
} catch (error) {
throw new Error(`Error generating Garage signed URL: ${error}`);
}
Expand Down
Loading