@tetalang/dev
v0.1.3
Published
Developer utilities for rendering, watching, and copying Teta SQL.
Readme
@tetalang/dev
Developer utilities for working with Teta query modules in Node and Bun.
Published as @tetalang/dev on npm and @teta/dev on JSR.
This package depends on @tetalang/teta for the frontend toSql(...) convenience path. It does not depend on the backend package directly. It uses Node APIs plus native clipboard support, so it is not intended for Deno.
Install
Bun
bun add @tetalang/devNode.js
npm install @tetalang/devRender a source module
import { renderSqlFromSource } from "@tetalang/dev";
const sql = await renderSqlFromSource("./queries/users.ts");
console.log(sql);renderSqlFromSource(...) looks for an export named query by default. Pass a custom exportName if your source module uses a different name.
The export may be a SQL string, an opaque Teta Query, or a function returning either one. Query detection uses the public isQuery(...) brand rather than structural fields.
Watch and copy SQL
import { watchQuerySourceToClipboard } from "@tetalang/dev";
const watcher = await watchQuerySourceToClipboard({
source: "./queries/users.ts",
outputFile: "./tmp/users.sql",
});Watch mode copies SQL to the clipboard by default and uses isolated module loading by default. Set copyToClipboard: false if you only want file output or logging.
Copy SQL directly
import { copyTextToClipboard } from "@tetalang/dev";
await copyTextToClipboard("SELECT 1");