Registry / database / blade-compiler

blade-compiler

JSON →
library3.29.10jsnpmunverified

Compiles Blade queries (RONIN) to SQLite statements. Current stable version is 3.29.10. Released continuously via GitHub Actions. Key differentiator: compiles high-level Blade query language to raw SQL, handles query transactions, schema definitions, and result formatting. Ships TypeScript types.

npm install blade-compiler
INSTALL
IMPORT
SIG · BLADE-COMPILER
B
blade-compiler
databasejavascriptv3.29.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Transaction
import { Transaction } from 'blade-compiler'
import Transaction from 'blade-compiler'
Transaction is a named export, not a default export.
ROOT_MODEL
import { ROOT_MODEL } from 'blade-compiler'
const ROOT_MODEL = require('blade-compiler').ROOT_MODEL
ROOT_MODEL is a named constant. ESM import preferred.
type Query, Model, Statement, Result
import type { Query, Model, Statement, Result } from 'blade-compiler'
import { Query, Model, Statement, Result } from 'blade-compiler'
These are TypeScript types, should be imported with 'import type' for isolatedModules.

Shows how to create a root model, define a model schema, and compile a query into SQL statements.

import { Transaction, ROOT_MODEL } from 'blade-compiler'; const transaction = new Transaction([ { create: { model: ROOT_MODEL } }, { create: { model: { slug: 'account', fields: [ { slug: 'name', type: 'string' }, { slug: 'email', type: 'string', unique: true } ] } } }, { get: { accounts: null } } ]); console.log(transaction.statements); // [{ sql: 'CREATE TABLE "ronin_schema" ...', params: [] }, // { sql: 'CREATE TABLE "accounts" ...', params: [] }, // { sql: 'SELECT * FROM "accounts"', params: [], returning: true }]
Debug
Known issues
gotchaTransaction must be created with array of query objects. Ensure queries are properly structured.
fix
Wrap single query in an array: new Transaction([query], options)
affects: >=0.0.0
gotchaRoot model table must exist before any schema-altering statements. Always create ROOT_MODEL first.
fix
Run statements for ROOT_MODEL creation before other schema changes.
affects: >=0.0.0
breakingIn v2, formatResults signature changed. Now expects a callback returning an object with results and raw flag.
fix
Update formatResults usage to return { results, raw: true } from the callback.
affects: >=2.0.0
deprecatedOld pattern of using Transaction without options object is deprecated in v3.
fix
Pass options as second argument even if empty: new Transaction(queries, {})
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: Transaction is not a constructor
Importing Transaction as default export instead of named export.
fix
Use `import { Transaction } from 'blade-compiler'`
Error: Table "ronin_schema" already exists
Creating ROOT_MODEL multiple times in same database.
fix
Check if ronin_schema table exists before creating it, or run ROOT_MODEL creation only once.
TypeError: Cannot read properties of undefined (reading 'sql')
transaction.statements accessed before it is populated, or queries array is empty.
fix
Ensure transaction is initialized with valid queries and access statements after construction.
ERR_REQUIRE_ESM: require() of ES Module not supported
Using require() to import an ESM-only package.
fix
Use `import` syntax or switch to dynamic import(). The package is ESM-only.
Upgrade
Version history
3.29.10latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
blade-compiler — npm install blade-compiler · libregistry