Registry / database / ts-sqlite-generator

ts-sqlite-generator

JSON →
library0.0.26jsnpmunverified

TypeScript interface to SQLite schema generator. v0.0.26 generates CREATE TABLE, INSERT, and REPLACE statements from interfaces tagged with @sqlite_entry. Requires TypeScript >=3.7. Outputs typed helper functions. Low release cadence; experimental. Differentiator: type-safe SQL generation at compile time via TypeScript compiler API, supports enums, union types, and nested interfaces.

npm install ts-sqlite-generator
INSTALL
IMPORT
SIG · TS-SQLITE-GENERATO
T
ts-sqlite-generator
databasejavascriptv0.0.26
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.

generator
import { generator } from 'ts-sqlite-generator'
import { generator } from 'ts-sqlite-generator typescript'
Do not include 'typescript' in the import; it's a separate peer dependency.
generator
const { generator } = require('ts-sqlite-generator')
CommonJS require works if your project uses CJS.
generator
import { generator } from 'ts-sqlite-generator'
import generator from 'ts-sqlite-generator'
Only named export; no default export.

Generates SQLite schema and helper files from interface definitions.

// script/generate.ts import path from 'path'; import { generator } from 'ts-sqlite-generator'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); generator( [path.join(__dirname, 'models.ts')], path.join(__dirname, '../tsconfig.json'), path.join(__dirname, '__generated__/schema.ts'), path.join(__dirname, '__generated__/helpers.ts') ); // models.ts - must have @sqlite_entry JSDoc tag /** * @sqlite_entry */ interface User { id: number; name: string; email: string; } // Run: npx ts-node -T script/generate.ts
Debug
Known issues
breakingMissing @sqlite_entry JSDoc tag on any interface causes no tables to be generated (silent failure).
fix
Ensure at least one interface has /** @sqlite_entry */ JSDoc comment.
affects: >=0.0.0
gotchaOutput directory must exist. No automatic creation of __generated__ folder.
fix
Create the output directory manually before running generator.
affects: >=0.0.0
deprecatedThe example script incorrectly uses 'ts-sqlite-generator typescript' in import path; this is not a valid import.
fix
Import only 'ts-sqlite-generator', not with appended ' typescript'.
affects: >=0.0.0
gotchaTsconfig path must be absolute or relative to the current working directory.
fix
Use path.resolve(__dirname, '../tsconfig.json') to ensure correct path.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: generator is not a function
Incorrect import: default import instead of named import.
fix
Use { generator } from 'ts-sqlite-generator'.
Cannot find module 'ts-sqlite-generator typescript'
Extra ' typescript' in import string
fix
Remove ' typescript' from import: import { generator } from 'ts-sqlite-generator'.
ENOENT: no such file or directory, open '.../__generated__/schema.ts'
Output directory does not exist.
fix
Create __generated__ directory before running the script.
No interfaces found with @sqlite_entry tag
Missing JSDoc tag on any interface in the input file.
fix
Add /** @sqlite_entry */ to at least one interface.
Upgrade
Version history
0.0.26latest on npm
Audit
Dependencies
typescriptrequiredpeer dependency required for compilation and type checking
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
ts-sqlite-generator — npm install ts-sqlite-generator · libregistry