Implementation:Langfuse Langfuse Prisma Generated Types
| Knowledge Sources | |
|---|---|
| Domains | Database, TypeScript, Code Generation |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
Auto-generated TypeScript type definitions derived from the Prisma database schema, providing type-safe interfaces for all PostgreSQL tables in the Langfuse application.
Description
This file is automatically generated from the Prisma schema (via pnpm run db:generate in packages/shared/) and contains TypeScript type definitions for all PostgreSQL database tables used by Langfuse. It uses the Kysely ColumnType and Generated utility types to express column-level insert/select/update type constraints.
The file defines:
Utility Types:
Generated<T>-- Marks columns where the insert value is optional (has a database default).Timestamp-- Column type that acceptsDateorstringfor insert/update but returnsDateon select.
Enum Constants (as const objects with matching type aliases):
ApiKeyScope-- ORGANIZATION, PROJECTRole-- OWNER, ADMIN, MEMBER, VIEWER, NONELegacyPrismaObservationType-- SPAN, EVENT, GENERATION, AGENT, TOOL, CHAIN, RETRIEVER, EVALUATOR, EMBEDDING, GUARDRAILLegacyPrismaObservationLevel-- DEBUG, DEFAULT, WARNING, ERRORLegacyPrismaScoreSource-- ANNOTATION, API, EVALScoreConfigDataType-- CATEGORICAL, NUMERIC, BOOLEANAnnotationQueueStatus,AnnotationQueueObjectType,DatasetStatus,CommentObjectType,NotificationChannel,NotificationType,AuditLogRecordType,JobType,JobConfigState,JobExecutionStatus,BlobStorageIntegrationFileType,BlobStorageIntegrationType,BlobStorageExportMode,AnalyticsIntegrationExportSource,DashboardWidgetViews,DashboardWidgetChartType,ActionType,ActionExecutionStatus,SurveyName
Table Types (50+ types):
Includes all major Langfuse entities: Account, Action, AnnotationQueue, ApiKey, AuditLog, Automation, BackgroundMigration, BatchAction, BatchExport, BlobStorageIntegration, Comment, Dashboard, DashboardWidget, Dataset, DatasetItem, DatasetRunItems, DatasetRuns, DefaultLlmModel, EvalTemplate, JobConfiguration, JobExecution, LegacyPrismaObservation, LegacyPrismaScore, LegacyPrismaTrace, LlmApiKeys, LlmSchema, LlmTool, Media, Model, Organization, OrganizationMembership, Price, PricingTier, Project, ProjectMembership, Prompt, ScoreConfig, TraceSession, User, and many more.
Database Interface:
DB-- The master Kysely database interface mapping table names to their corresponding types.
Usage
Use this file when:
- Writing type-safe database queries using Kysely.
- Referencing the shape of any PostgreSQL table in TypeScript code.
- Understanding which columns are auto-generated (have database defaults).
- Checking enum values for database column constraints.
Code Reference
Source Location
- Repository: Langfuse
- File: packages/shared/prisma/generated/types.ts
- Lines: 1-1013
Signature
import type { ColumnType } from "kysely";
export type Generated<T> =
T extends ColumnType<infer S, infer I, infer U>
? ColumnType<S, I | undefined, U>
: ColumnType<T, T | undefined, T>;
export type Timestamp = ColumnType<Date, Date | string, Date | string>;
// Enum examples
export const Role = {
OWNER: "OWNER",
ADMIN: "ADMIN",
MEMBER: "MEMBER",
VIEWER: "VIEWER",
NONE: "NONE",
} as const;
export type Role = (typeof Role)[keyof typeof Role];
// Table type example
export type Project = {
id: string;
org_id: string;
created_at: Generated<Timestamp>;
updated_at: Generated<Timestamp>;
deleted_at: Timestamp | null;
name: string;
retention_days: number | null;
has_traces: Generated<boolean>;
metadata: unknown | null;
};
// Database interface
export type DB = {
projects: Project;
organizations: Organization;
users: User;
traces: LegacyPrismaTrace;
observations: LegacyPrismaObservation;
scores: LegacyPrismaScore;
// ... 50+ more table mappings
};
Import
import type { DB, Project, User, Role, Generated, Timestamp } from "../../prisma/generated/types";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| N/A | N/A | N/A | This is an auto-generated type definition file. It is regenerated from the Prisma schema via pnpm run db:generate.
|
Outputs
| Name | Type | Description |
|---|---|---|
| Enum constants | TypeScript const objects | Runtime enum values (e.g., Role.ADMIN)
|
| Table types | TypeScript type aliases | Row-level type definitions for all PostgreSQL tables |
| DB interface | TypeScript type | Kysely database interface mapping table names to types |
Usage Examples
import type { DB, Project } from "@langfuse/shared/prisma/generated/types";
import { Role } from "@langfuse/shared/prisma/generated/types";
import { Kysely } from "kysely";
// Type-safe database query
const db = new Kysely<DB>({ /* config */ });
const projects = await db
.selectFrom("projects")
.selectAll()
.where("org_id", "=", "my-org-id")
.execute();
// Using enum values
if (membership.role === Role.ADMIN) {
// admin-specific logic
}