@axiomdb/ts-plugin
v0.1.1
Published
TypeScript language service plugin for AxiomDB — validates SQL templates and provides type info
Readme
@axiomdb/ts-plugin
TypeScript language service plugin for AxiomDB.
Installation
npm install @axiomdb/ts-pluginOverview
Provides inline SQL validation and type information for sql tagged templates directly in your editor. Validates SQL syntax, reports errors, and infers result types from your database schema.
Setup
Add to your tsconfig.json:
{
"compilerOptions": {
"plugins": [{ "name": "@axiomdb/ts-plugin" }]
}
}Or use the AxiomDB VS Code extension which configures this automatically.
Features
Semantic diagnostics
Validates SQL syntax inside sql, client.psql, client.mysql, and client.mssql tagged templates. Syntax errors appear as inline diagnostics in your editor.
Hover information
Hover over a query to see the inferred result type. Hover over SQL keywords to see documentation for the keyword, specific to the dialect in use (PostgreSQL, MySQL, or MSSQL).
Completions
Table and column name completions inside SQL templates, powered by your schema file.
Go to definition
Ctrl/Cmd+click on table or column names to jump to their definition in the schema.
Semantic coloring
SQL keywords, identifiers, and literals are semantically classified for syntax coloring within tagged templates.
Document highlights and outlining
Matching references are highlighted, and SQL template regions support code folding.
Schema file
The plugin loads axiomdb-schema.json to provide type inference and table/column completions. It searches these locations in order:
<project root>/axiomdb-schema.json<project root>/src/axiomdb-schema.json<project root>/generated/axiomdb-schema.json
Generate this file using @axiomdb/schema:
npx axiomdb-schema generate --adapter postgres --connection-string $DATABASE_URLThe plugin watches for file changes and reloads automatically. Without a schema file, SQL syntax validation still works but type inference and table/column completions are unavailable.
Usage with VS Code
For VS Code users, the AxiomDB extension bundles this plugin and adds SQL syntax highlighting. The extension configures the TypeScript server plugin automatically — no tsconfig.json change needed.
For other editors that support TypeScript language service plugins, use the tsconfig.json setup above.
License
MIT
