TypeScript API
The TypeScript runtime client is in development. This page will be expanded when it ships. For now, use the SQL functions directly from any PostgreSQL client.
Current Status
Code generation is available. melange generate client --runtime typescript produces type-safe constants and factory functions. See Generated Code for details.
Runtime library (@pthm/melange) is planned. It will mirror the Go API with TypeScript idioms:
Checkerclass withcheck(),listObjects(),listSubjects()- Bulk check builder
- Cache interface
- Decision overrides
- Contextual tuples
- Error types (
ValidationError,BulkCheckDeniedError)
Using SQL Directly
Until the runtime ships, call the generated SQL functions from any PostgreSQL client:
import { Pool } from 'pg';
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
// Permission check
const { rows } = await pool.query(
'SELECT check_permission($1, $2, $3, $4, $5)',
['user', 'alice', 'can_read', 'repository', '42']
);
const allowed = rows[0].check_permission === 1;
// List accessible objects
const { rows: objects } = await pool.query(
'SELECT * FROM list_accessible_objects($1, $2, $3, $4)',
['user', 'alice', 'can_read', 'repository']
);
const objectIds = objects.map(r => r.object_id);See the SQL API Reference for all available functions and their signatures.
Next Steps
- Generated Code: TypeScript code generation output
- SQL API: calling permission functions directly
- Go API: the Go runtime API (reference for the planned TypeScript API)