We're excited to announce the first release of prism-ts - a TypeScript client library designed to provide full type safety and simplified interaction with prism-py generated APIs.
This library creates a seamless bridge between your database-driven API and frontend applications with zero boilerplate and complete type safety.
Key Features
- 🔒 **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
Installation
bash
Using Deno
deno add jsr/prism-ts
Using npm via deno2node
npm install jsr/prism-ts
Quick Start
typescript
import { BaseClient, Prism } from "jsr/prism-ts";
// Initialize the client pointing to your prism-py API
const client = new BaseClient("http://localhost:8000");
const prism = new Prism(client);
// Initialize and load schema metadata
await prism.initialize();
// Generate TypeScript types (during development)
await prism.generateTypes("./src/types");
// 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",
order_dir: "desc",
limit: 10,
offset: 0,
});
// Create a new record
const newUser = await userOperations.create({
username: "johndoe",
email: "johnexample.com",
status: "active"
});
// Update a record
await userOperations.update(newUser.id, {
status: "inactive"
});
// Delete a record
await userOperations.delete(newUser.id);
The Prism Ecosystem
This release is part of the Prism ecosystem, designed to create a seamless bridge between your database and type-safe client applications:
- **prism-py**: Server-side library for automatic API generation
- **prism-ts**: Client-side library for consuming prism-py APIs with full type safety
Together, these libraries enable end-to-end type safety and eliminate boilerplate code across your full stack.
Notes
- This is an initial release focused on core functionality
- Compatible with prism-py version 0.0.1 and later
- Built for Deno with JSR package distribution
- View operations have some limitations due to server-side issues in prism-py
- Please report any issues or feature requests!
Thank you for trying prism-ts! We're looking forward to your feedback.