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:Helicone Helicone Database Types

From Leeroopedia
Revision as of 12:56, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Helicone_Helicone_Database_Types.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Database, TypeSystem
Last Updated 2026-02-14 06:32 GMT

Overview

Auto-generated Supabase/PostgreSQL TypeScript type definitions providing compile-time type safety for all database operations across the Helicone web application.

Description

database.types.ts is a ~3,169-line auto-generated file produced by the Supabase CLI that maps the entire PostgreSQL database schema to TypeScript interfaces. It exports two fundamental types:

  • Json -- A recursive union type representing valid JSON values (string | number | boolean | null | { [key: string]: Json | undefined } | Json[]).
  • Database -- The top-level interface containing the public schema with Tables, Views, Functions, Enums, and CompositeTypes namespaces.

Each table definition includes three variants:

  • Row -- Full row type with all columns (used for SELECT results)
  • Insert -- Insertion type with optional columns that have defaults
  • Update -- Partial update type where all columns are optional
  • Relationships -- Foreign key relationship metadata

Key Tables (selected from ~60+ tables):

Table Purpose
organization Core multi-tenant organization entity with tier, limits, and settings
helicone_api_keys API keys for authenticating with Helicone services
helicone_proxy_keys Proxy keys for routing LLM requests through Helicone
alert Alert configurations with metrics, thresholds, and notification channels
evaluator Evaluator definitions for scoring LLM outputs
experiment_v3 Experiment tracking and management
helicone_dataset / helicone_dataset_row Dataset storage for fine-tuning and evaluation
prompt_v2 Prompt template definitions
prompts_2025 / prompts_2025_versions / prompts_2025_inputs 2025-generation prompt management system
properties Custom properties attached to requests
provider_keys Encrypted provider API keys
score_attribute / score_value Scoring system for request evaluation
webhook_subscriptions / webhooks Webhook configuration and event delivery
organization_member Organization membership and role assignments
feature_flags Feature flag configuration per organization
layout / organization_layout Dashboard layout preferences
user_settings Per-user application settings
organization_auto_topoff Auto top-off credit configuration

Key Views:

  • decrypted_provider_keys_v2 -- Decrypted view of provider keys for runtime use
  • users_view -- User information view

Key Functions:

  • check_request_access -- Validates request access permissions
  • ensure_one_demo_org -- Ensures demo organization exists
  • http, http_head, http_patch, http_put -- HTTP helper functions for external calls
  • insert_feedback_and_update_response -- Atomic feedback insertion

Usage

Import the Database type to get type-safe access to any table's Row, Insert, or Update types. This file should never be manually edited -- it is regenerated from the database schema using the Supabase CLI.

Code Reference

Source Location

Signature

export type Json =
  | string
  | number
  | boolean
  | null
  | { [key: string]: Json | undefined }
  | Json[]

export type Database = {
  public: {
    Tables: {
      admins: { Row: {...}; Insert: {...}; Update: {...}; Relationships: [...] };
      alert: { Row: {...}; Insert: {...}; Update: {...}; Relationships: [...] };
      organization: { Row: {...}; Insert: {...}; Update: {...}; Relationships: [...] };
      helicone_api_keys: { Row: {...}; Insert: {...}; Update: {...}; Relationships: [...] };
      // ... 60+ tables
    };
    Views: {
      decrypted_provider_keys_v2: { Row: {...} };
      users_view: { Row: {...} };
    };
    Functions: {
      check_request_access: { Args: {...}; Returns: {...} };
      // ... additional functions
    };
    Enums: { [key: string]: never };
    CompositeTypes: { [key: string]: never };
  };
};

Import

import { Database } from "@/db/database.types";

// Access specific table types
type Organization = Database["public"]["Tables"]["organization"]["Row"];
type OrganizationInsert = Database["public"]["Tables"]["organization"]["Insert"];
type AlertRow = Database["public"]["Tables"]["alert"]["Row"];

I/O Contract

Key Table Structures

Table Key Columns Description
organization id, name, tier, stripe_customer_id, is_personal, limits, created_at Core organization entity
helicone_api_keys api_key_hash, api_key_name, organization_id, soft_delete API key storage
alert id, name, metric, threshold, org_id, emails, slack_channels Alert configuration
prompt_v2 id, user_defined_id, description, organization Prompt template storage
prompts_2025_versions id, prompt_id, major_version, minor_version, model Prompt version tracking
properties id, request_id, key, value, organization_id Custom request properties

Usage Examples

import { Database } from "@/db/database.types";

// Type-safe row access
type OrgRow = Database["public"]["Tables"]["organization"]["Row"];

function getOrgName(org: OrgRow): string {
  return org.name;
}

// Type-safe insert
type AlertInsert = Database["public"]["Tables"]["alert"]["Insert"];

const newAlert: AlertInsert = {
  name: "High Latency Alert",
  metric: "latency",
  threshold: 5000,
  org_id: "org-123",
  emails: ["admin@example.com"],
  time_window: 3600,
};

// Using with Supabase client
const { data, error } = await supabase
  .from("organization")
  .select("*")
  .eq("id", orgId)
  .single();

// data is typed as OrgRow | null

Related Pages

Page Connections

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