typedblite
The TypeDBLite command line: an interactive REPL, a file runner, and a one-shot executor for TypeQLite.
Installation
Section titled “Installation”Not on npm yet. Once the first release is out, it runs with nothing to install, or installs globally:
npx typedblite --exec 'define entity person, owns name @key; attribute name, value string;'npm install -g typedbliteIt needs Node.js 22.16 or later. Until then, build it from source:
npm run build # or: npm exec nx -- run typedblite:buildThe compiled binary is at apps/cli/out/main.js.
typedblite [--database <path>] <mode>
Modes: --repl interactive TypeQLite prompt --file <path> run a .typeqlite file and exit --exec '<statement>' run one statement and exit --help print this text
Options: --database <path> file-backed SQLite database (default: :memory:)Interactive REPL
Section titled “Interactive REPL”node apps/cli/out/main.js --repltypedblite — .help for help, .exit to leavein-memory database — nothing is kept when this session endstypedblite> define entity person, owns name @key; attribute name, value string;schema appliedtypedblite> insert $p isa person, has name "Alice";oktypedblite> match $p isa person, has name $n; select $n;n=Alice(1 row)typedblite> .exitStatements end at ;. Multi-line statements are supported — the prompt shows ...> while a statement is incomplete. A bare match …; without a following stage is held at the prompt; TypeQLite requires a projection or write stage to complete the pipeline.
REPL dot commands
Section titled “REPL dot commands”| Command | Action |
|---|---|
.help |
Print usage |
.schema |
Report whether a schema has been applied |
.exit |
Leave (Ctrl-D also works) |
File-backed database
Section titled “File-backed database”node apps/cli/out/main.js --repl --database ./my.dbThe database persists across sessions. Each statement is committed immediately.
Run a file
Section titled “Run a file”node apps/cli/out/main.js --file schema.typeqlite --database ./my.dbStatements are run in order. The first error stops execution and exits with code 1.
One-shot statement
Section titled “One-shot statement”node apps/cli/out/main.js --exec 'match $p isa person, has name $n; select $n;' --database ./my.dbKnown limitations
Section titled “Known limitations”The CLI finds where a statement ends by looking at ; and the keyword the statement starts with.
It does not parse the statement. Two consequences:
- A standalone
insertends at its first;.insert $a isa person, …; $c isa company, …;runs as two statements, and the second fails to parse. Write oneinsertper thing, or start the statement withmatch(match …; insert …;is kept whole). - In the REPL, a
defineblock runs when its first line ends in;. Type adefineon one line, or put the schema in a file and load it with--file, which reads ahead and keeps a multi-linedefinetogether.
The engine has neither limitation. Statements passed to it through the runtime API are parsed whole.
Output format
Section titled “Output format”| Outcome | Output |
|---|---|
define / insert / delete / put |
schema applied or ok |
match … select with rows |
One line per row: var=value var=value |
match … select with no rows |
(no rows) |
| Error | error: <message> |
Piped input
Section titled “Piped input”The REPL accepts piped input:
node apps/cli/out/main.js --repl < my-queries.typeqliteThis works because the REPL is driven by the line event on readline rather than rl.question() — question() silently drops buffered lines when input is piped.
npm exec nx -- run typedblite:testTest files live in test/ with .test.mts extension. The REPL tests (test/repl.test.mts) spawn the actual binary and pipe input into it; they test the real process boundary rather than the module in isolation.
TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.