Baton SQL Extension
A professional-grade VS Code extension providing comprehensive SQL validation, IntelliSense, and schema enforcement for Baton SQL configuration files using the Language Server Protocol (LSP).
Features
Real-time SQL Validation
- 14 validation rules covering SELECT, INSERT, UPDATE statements
- Detects missing commas, typos, unclosed parentheses, invalid JOINs, and more
- Works across all SQL queries in your YAML (list, grants, provisioning, etc.)
Intelligent Auto-completion
- SQL keywords (SELECT, FROM, WHERE, JOIN, etc.)
- SQL functions (COUNT, SUM, AVG, CONCAT, etc.)
- Baton-specific parameters (?<parameter_name>)
- Context-aware suggestions
Inline Documentation (Hover)
- Hover over SQL keywords for documentation
- Hover over Baton parameters for syntax help
- Rich markdown formatting
One-Click Quick Fixes
- Fix misspelled keywords (SELCT → SELECT)
- Add missing commas automatically
- Add closing parentheses
- Add missing FROM clauses
- Quick fix available via lightbulb 💡 or
Cmd+. / Ctrl+.
Go-to-Definition
- Jump to table definitions (F12 or Cmd+Click)
- Navigate to resource type definitions
- Understand query structure instantly
JSON Schema Validation
- Automatic schema application for
baton-sql-*.yaml files
- Validates YAML structure, required fields, property types
- Supports account provisioning, credential rotation, and more
- Helpful tooltips on hover
Installation
Option 1: Install from VSIX (Recommended)
- Download the latest
.vsix file from releases
- Open VS Code
- Go to Extensions panel (⇧⌘X / Ctrl+Shift+X)
- Click "..." menu → "Install from VSIX..."
- Select the downloaded
.vsix file
Option 2: Build from Source
# Clone the repository
git clone https://github.com/yourusername/baton-sql-extension.git
cd baton-sql-extension
# Install dependencies
npm install
# Build and package
npm run build
npm run package
# Install the generated .vsix file
Requirements
- VS Code: 1.80.0 or higher
- Red Hat YAML Extension: Required for schema validation (installed automatically)
Usage
The extension activates automatically when you open files matching:
baton-sql-*.yaml
baton-sql-*.yml
All features work automatically—no configuration needed!
Example: SQL Validation
resource_types:
user:
list:
query: |
SELECT
id,
name
email ← Error: Missing comma
FRO users ← Error: Typo in FROM
You'll see:
- Red squiggles under errors
- Lightbulb 💡 with quick fixes
- Detailed error messages
Example: Auto-completion
Type SE and see suggestions for:
Type ?< to trigger Baton parameter completion.
Example: Go-to-Definition
SELECT * FROM users JOIN orders ON users.id = orders.user_id
WHERE orders.status = 'active'
^^^^^^ Cmd+Click here to jump to JOIN definition
Technical Architecture
Built with the Language Server Protocol for maximum compatibility:
baton-sql-extension/
├── src/
│ ├── client/ # LSP client (VS Code integration)
│ ├── server/ # LSP server (validation logic)
│ │ ├── features/ # Hover, completion, code actions, go-to-def
│ │ └── index/ # Symbol indexing
│ ├── validation/ # 14 SQL validation rules
│ └── utils/ # Shared utilities
├── schemas/
│ └── baton-schema.json # JSON schema definition
└── out/ # Compiled output
Key Benefits of LSP
- Native VS Code support - Install directly from marketplace
- Other LSP editors - Server can be configured for Neovim, Emacs, Sublime Text, etc. (manual setup required)
- Runs in separate process for better performance
- Professional-grade features (hover, completion, quick fixes, navigation)
Development
Run in Development Mode
npm run build
code .
Then press F5 to open a new Extension Development Host window.
Build for Production
npm run build # Compile TypeScript and bundle
npm run package # Create .vsix file
Project Scripts
npm run build - Compile TypeScript + webpack bundle
npm run package - Package as VSIX
npm run watch - Watch mode for development
Validation Rules
The extension includes 14 comprehensive validation rules:
- Missing Comma Rule - Detects missing commas in SELECT, INSERT, UPDATE
- Keyword Spelling Rule - Catches typos in SQL keywords
- Missing FROM Rule - Ensures SELECT has FROM clause
- Unclosed Parentheses Rule - Detects unbalanced parentheses
- Invalid JOIN Rule - Validates JOIN syntax and ON clauses
- Ambiguous Columns Rule - Detects ambiguous column references
- Invalid GROUP BY Rule - Validates GROUP BY with aggregates
- Invalid ORDER BY Rule - Validates ORDER BY references
- Duplicate Aliases Rule - Detects duplicate table aliases
- Property Name Typos Rule - Catches common YAML typos
- Baton Parameter Validation Rule - Validates ? syntax
- Credential Mutual Exclusion Rule - Ensures proper credential config
- Trailing Comma Rule - Detects invalid trailing commas
- Deduplication - Prevents duplicate errors from repeated queries
Schema Support
Supported Properties
app_name, app_description, connect
resource_types with full validation
static_entitlements with provisioning support
entitlements and grants
account_provisioning with schema, credentials, validate, create
credential_rotation for password updates
Credential Types
no_password - SSO-only accounts
random_password - Generate random passwords
encrypted_password - Pre-encrypted passwords
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/YourFeature)
- Commit your changes (
git commit -m 'Add YourFeature')
- Push to the branch (
git push origin feature/YourFeature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter issues or have feature requests:
- Check existing issues on GitHub
- Create a new issue with detailed information
- Include your VS Code version and extension version
Made with ❤️ for the Baton community