Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langfuse Langfuse Prisma Generated Types

From Leeroopedia
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 accepts Date or string for insert/update but returns Date on select.

Enum Constants (as const objects with matching type aliases):

  • ApiKeyScope -- ORGANIZATION, PROJECT
  • Role -- OWNER, ADMIN, MEMBER, VIEWER, NONE
  • LegacyPrismaObservationType -- SPAN, EVENT, GENERATION, AGENT, TOOL, CHAIN, RETRIEVER, EVALUATOR, EMBEDDING, GUARDRAIL
  • LegacyPrismaObservationLevel -- DEBUG, DEFAULT, WARNING, ERROR
  • LegacyPrismaScoreSource -- ANNOTATION, API, EVAL
  • ScoreConfigDataType -- CATEGORICAL, NUMERIC, BOOLEAN
  • AnnotationQueueStatus, 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

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
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment