A TypeScript library designed provides full type safety, automatic type generation, and a comprehensive set of utilities for interacting with your database-driven API.
Note: This library is part of the Prism ecosystem, which includes prism-py, a Python library that generates APIs from database schemas.
- 🔒 Type-Safe API Client: Fully typed requests and responses
- 🔄 Code Generation: Generate TypeScript interfaces from database schemas
- 📚 Metadata Explorer: Explore your API structure programmatically
- 🔧 CRUD Operations: Standardized operations for all database tables
- 🔍 Type Inference: Leverages TypeScript's type system for excellent IDE support
- 📝 Query Builder: Type-safe filter construction for API requests
- 🧩 Zero Configuration: Works out of the box with prism-py APIs
# Using Deno
deno add @jsr/prism-ts
# Using npm via deno2node
npm install @jsr/prism-tsimport { BaseClient, PrismTs } from "@jsr/prism-ts";
// Initialize the client pointing to your prism-py API
const client = new BaseClient("http://localhost:8000");
const prism = new PrismTs(client);
// Initialize and load schema metadata
await prism.initialize();
// Generate TypeScript types (during development)
await prism.generateTypes();
// Get type-safe operations for a specific table
const userOperations = await prism.getTableOperations("public", "users");
// Fetch with filtering, sorting, and pagination
const activeUsers = await userOperations.findMany({
where: { status: "active" },
orderBy: { created_at: "desc" },
limit: 10,
offset: 0,
});
// Create a new record
const newUser = await userOperations.create({
username: "johndoe",
email: "[email protected]",
status: "active",
});
// Update a record
await userOperations.update(newUser.id, {
status: "inactive",
});
// Delete a record
await userOperations.delete(newUser.id);prism-ts can automatically generate TypeScript interfaces from your prism-py API:
import { BaseClient, PrismTs } from "@jsr/prism-ts";
const client = new BaseClient("http://localhost:8000");
const prism = new PrismTs(client);
// Generate all types to a directory
await prism.generateTypes("./src/types");
// Now you can import these generated types
import { Product, User } from "./src/types";- End-to-End Type Safety: From database to frontend
- Zero Boilerplate: No manual typing of API responses
- Automatic Updates: Types stay in sync with database changes
- Developer Experience: Great IDE integration with auto-completion
- Database-First Development: Build your API around your data model
prism-ts is designed to work seamlessly with prism-py, a Python library that generates APIs from database schemas. Together, they provide a complete solution for rapid, type-safe application development:
- Define your database schema
- Generate an API with prism-py
- Connect to the API with prism-ts
- Build your frontend with full type safety