CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-superset-ui--generator-superset

Yeoman generator that scaffolds Superset visualization plugins and packages with proper structure and boilerplate code

63

1.21x
Overview
Eval results
Files

task.mdevals/scenario-2/

Database Connection Manager

Build a database connection manager that validates and tests database connections for a data analytics application.

Requirements

The connection manager should support configuring database connections with proper validation and testing capabilities. It should handle connection strings, validate configuration parameters, and provide feedback on connection health.

Connection Configuration

  • Accept database connection parameters including connection URI, database type, and optional SSH tunnel settings
  • Validate that required connection parameters are present and properly formatted
  • Support common database types (PostgreSQL, MySQL, SQLite)

Connection Testing

  • Provide a function to test if a database connection is valid and accessible
  • Return connection status information including success/failure and any error messages
  • Handle connection timeouts gracefully

Security Features

  • Ensure sensitive credentials are not logged or exposed in error messages
  • Support optional SSH tunnel configuration for secure connections
  • Validate SSL/TLS settings if provided

Test Cases

  • Given valid PostgreSQL connection parameters, the connection test succeeds and returns success status @test
  • Given invalid connection URI, the validation fails with appropriate error message @test
  • Given connection parameters for an unreachable database, the connection test fails gracefully with timeout error @test
  • Given connection parameters with SSH tunnel settings, the configuration is validated properly @test

Implementation

@generates

API

/**
 * Validates database connection parameters
 *
 * @param {Object} config - Database configuration object
 * @param {string} config.uri - Database connection URI
 * @param {string} config.type - Database type (postgres, mysql, sqlite)
 * @param {Object} [config.sshTunnel] - Optional SSH tunnel configuration
 * @returns {Object} Validation result with isValid flag and errors array
 */
function validateConnectionConfig(config) {
  // IMPLEMENTATION HERE
}

/**
 * Tests a database connection
 *
 * @param {Object} config - Database configuration object
 * @param {number} [timeout=5000] - Connection timeout in milliseconds
 * @returns {Promise<Object>} Connection test result with status and message
 */
async function testConnection(config, timeout) {
  // IMPLEMENTATION HERE
}

/**
 * Creates a secure connection string with masked credentials
 *
 * @param {string} uri - Database connection URI with credentials
 * @returns {string} URI with credentials masked for logging
 */
function maskCredentials(uri) {
  // IMPLEMENTATION HERE
}

module.exports = {
  validateConnectionConfig,
  testConnection,
  maskCredentials
};

Dependencies { .dependencies }

apache-superset { .dependency }

Provides database connectivity and integration capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-superset-ui--generator-superset

tile.json