qail-wasm

raw JSON →
0.17.1 verified Fri May 01 auth: no javascript

qail-wasm provides WebAssembly bindings for QAIL, an AST-native query language that transpiles to SQL. Current stable version is 0.17.1 (npm), but GitHub releases show up to v0.28.0. The package is in alpha and should not be used in production. It has zero runtime dependencies and supports browser and Node.js environments. Key differentiators: type-safe SQL generation from AST rather than string concatenation, preventing SQL injection by construction. Supports PostgreSQL, with MySQL and SQLite planned. The API is currently evolving and may have breaking changes.

error TypeError: parse_and_transpile is not a function
cause init() not called or awaited before using parse_and_transpile.
fix
Call await init() before any other WASM functions.
error Error: Unsupported dialect: mysql
cause Only 'postgres' is currently supported, but user passed 'mysql'.
fix
Use dialect 'postgres' or wait for MySQL support.
error Module parse failed: Unexpected token (1:0) - You may need an appropriate loader to handle this file type.
cause Webpack or bundler not configured to handle .wasm files.
fix
Add a wasm loader (e.g., wasm-loader) or use the package in an environment that supports WebAssembly (Node.js 12+, modern browsers).
breaking API may change drastically before stable release. Do not use in production.
fix Pin a specific version and test after every update.
deprecated The package is alpha software and may have undocumented breaking changes.
fix Monitor changelog and GitHub releases for breaking changes.
gotcha init() must be called and awaited before using parse_and_transpile. Forgetting to await init() results in undefined behavior.
fix Ensure init() is awaited before any other WASM calls.
gotcha Only PostgreSQL dialect is currently supported; MySQL and SQLite are planned but not implemented.
fix Use 'postgres' as the dialect parameter.
npm install qail-wasm
yarn add qail-wasm
pnpm add qail-wasm

Shows basic usage: initialize WASM, parse QAIL query, transpile to PostgreSQL SQL.

import init, { parse_and_transpile } from 'qail-wasm';

await init();

const sql = parse_and_transpile("get users : id, name [ active = true ]", "postgres");
console.log(sql);
// → SELECT id, name FROM users WHERE active = true