| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
TypeScript types for integrating with the DBCode VSCode extension API. This package provides type definitions that allow other VSCode extensions to safely interact with DBCode's database connection management features.
npm install @dbcode/vscode-apiDBCode is a VSCode extension for database management. This types package allows other extensions to:
The API provides three main methods:
The main interface for defining database connections:
interface ConnectionConfig {
connectionId: string; // Unique identifier
name: string; // Display name
connectionType: 'host' | 'socket'; // Connection method
driver: Driver; // Database driver
host?: string; // Server host (for host connections)
port?: number; // Server port (for host connections)
socket?: string; // Socket path (for socket connections)
database?: string; // Database name
username?: string; // Auth username
password?: string; // Auth password
// ... additional options
}Comprehensive database driver support:
type Driver =
| 'postgres' | 'mssql' | 'azure' | 'cockroach' | 'yugabyte' | 'timescale'
| 'mysql' | 'mariadb' | 'mongodb' | 'sqlite' | 'libsql' | 'd1'
| 'redshift' | 'oracle' | 'duckdb' | 'cassandra' | 'snowflake'
| 'motherduck' | 'db2' | 'bigquery' | 'redis' | 'starrocks'
| 'singlestore' | 'doris' | 'excel' | 'csv' | 'greenplum'
| 'clickhouse' | 'dataverse' | 'risingwave' | 'trino' | 'athena'
| 'databricks' | 'elasticsearch' | 'questdb' | 'azuresynapse';Supports 36+ database systems including traditional databases, cloud data warehouses, analytics engines, and data formats.
Main API for connection management:
interface DBCodeAPI {
addConnections(connections: ConnectionConfig[]): Promise<ConnectionOperationResult>;
removeConnections(connectionIds: string[]): Promise<ConnectionOperationResult>;
revealConnection(connectionId?: string): Promise<ConnectionOperationResult>;
}See the example extension file for a complete, commented implementation, or check out the basic usage below:
import * as vscode from 'vscode';
import { DBCodeAPI, ConnectionConfig } from '@dbcode/vscode-api';
export async function activate(context: vscode.ExtensionContext) {
// Get DBCode API
const dbcodeExtension = vscode.extensions.getExtension('dbcode.dbcode');
if (!dbcodeExtension) {
vscode.window.showErrorMessage('DBCode extension not found');
return;
}
await dbcodeExtension.activate();
const dbcodeAPI: DBCodeAPI = dbcodeExtension.exports.api;
// Add a connection
const connection: ConnectionConfig = {
connectionId: 'my-postgres-db',
name: 'My PostgreSQL Database',
connectionType: 'host',
driver: 'postgres',
host: 'localhost',
port: 5432,
database: 'myapp',
username: 'postgres'
};
const result = await dbcodeAPI.addConnections([connection]);
if (result.success) {
vscode.window.showInformationMessage('Connection added successfully!');
// Reveal the connection in the explorer
await dbcodeAPI.revealConnection('my-postgres-db');
}
}Configure secure connections with individual SSL properties:
const connection: ConnectionConfig = {
connectionId: 'secure-connection',
name: 'Secure Database',
driver: 'postgres',
connectionType: 'host',
host: 'localhost',
port: 5432,
ssl: true,
sslTrustCertificate: false,
sslCACert: '/path/to/ca.pem',
sslClientCert: '/path/to/client-cert.pem',
sslClientKey: '/path/to/client-key.pem'
};Use revealConnection() to show the DBCode explorer and navigate to specific connections:
// Reveal the explorer without selecting any specific connection
await dbcodeAPI.revealConnection();
// Reveal and select a specific connection by ID
await dbcodeAPI.revealConnection('my-connection-id');
// Complete example with error handling
const result = await dbcodeAPI.revealConnection('production-db');
if (result.success) {
console.log('Explorer revealed and connection selected');
} else {
console.error('Failed to reveal connection:', result.error);
}Behavior:
Use Cases:
All API methods return ConnectionOperationResult with success/error information:
const result = await dbcodeAPI.addConnections(connections);
if (!result.success) {
console.error('Failed to add connections:', result.error);
}MIT - see LICENSE file for details.
For issues and questions:
| Back | FazBrowse Home | New Git URL |