TypeScript bindings for the Weave platform. The package ships generated protobuf message types, gRPC service clients, and Postgres query helpers so applications can talk to Weave services and databases from Node.js and modern TypeScript runtimes.
npm install weave-typescriptTypeScript bindings for the Weave platform. The package ships generated protobuf message types, gRPC service clients,
and Postgres query helpers so applications can talk to Weave services and databases from Node.js and modern TypeScript
runtimes.
- gRPC-ready service clients produced from Buf-managed protobuf definitions.
- Strongly-typed SQL helpers generated with sqlc for the WeaveSQL datasets.
``bash`
pnpm add weave-typescriptor
npm install weave-typescriptor
yarn add weave-typescript
The package includes runtime dependencies on @grpc/grpc-js, @bufbuild/protobuf, and pg; no extra installs are
required when using the default export.
`ts
import { credentials } from "@grpc/grpc-js";
import { auth } from "weave-typescript";
const client = new auth.AuthClient(
"api.weave.com:443",
credentials.createSsl()
);
client.initiateOAuth(
{
provider: "github",
redirectUri: "https://example.com/oauth/callback",
state: "csrf-token",
scope: "openid profile email",
providerParams: {},
},
(err, response) => {
if (err) throw err;
console.log(response.authUrl);
}
);
`
Every protobuf module under src/weaveapi/** is re-exported from the root package. Service namespaces expose message@grpc/grpc-js
types, client constructors, and server implementations that the ecosystem expects.
`ts
import { Client } from "pg";
import { getModel } from "weave-typescript/weavesql/llmxdb/models_sql";
const client = new Client({ connectionString: process.env.DATABASE_URL });
await client.connect();
const row = await getModel(client, { slug: "weave/sonnet-3" });
if (!row) {
console.log("model not found");
} else {
console.log(row.name, row.capabilities);
}
`
Each helper follows the sqlc convention: the exported SQL text constants match the query names while the functionspg
perform typed marshalling to and from array results. When you regenerate SQL code, the TypeScript bindings stay in
sync with new database migrations.
`bash`
pnpm install # install dependencies
pnpm build # emit dist/ with JS and type declarations
pnpm test # run sqlc generator unit tests (tools/sqlcgen.test.js)
pnpm generate # rebuild src/index.ts barrel exports
pnpm generate:sqlc-config --schema ../schema/weavesql
# regenerate sqlc.yaml for local schemas
1. Sync the schema/ directory (or point Buf at the shared schema checkout).buf generate
2. Run (Buf picks up buf.gen.yaml and writes into src/).pnpm generate
3. Execute to rebuild the barrel exports.pnpm build
4. Re-run so dist/ reflects the new artifacts.
The tools/sqlcgen.js utility scans schema/weavesql/** (or the directory passed via --schema) and writes ansqlc.yaml that targets the TypeScript sqlc plugin. Regenerate it before running sqlc generate so new databases or
query directories are included.
Follow the project coding guidelines in CODE_STYLE.md`, prefer small focused commits, and keep generated artifacts out
of Git history unless they are part of a release. Pull requests should include regenerated protobufs/SQL bindings when
schemas change and cover the relevant tooling scripts with tests where practical.