// KBDB Base types. Base depends on D1 only.
// Optional modules add their own bindings (embed: VECTORIZE+AI). Base never references them.

export type Bindings = {
  DB: D1Database;
  ENVIRONMENT: string;
  // Optional embed module (issue #7 / SDD T2.4). Present ONLY when the self-host opened
  // semantic search (kbdb_embed:true → deploy injects [[vectorize]] + [ai]). Base never
  // requires them; code checks `if (env.VECTORIZE && env.AI)` before touching embed.
  VECTORIZE?: VectorizeIndex;
  AI?: Ai;
};

export type EntryType =
  | 'block'
  | 'value'
  | 'template'
  | 'slot'
  | 'project'
  | 'workflow'
  | 'recipe_stat';

export interface Entry {
  id: string;
  content: string | null;
  entry_type: EntryType | string;
  owner_id: string | null;
  parent_id: string | null;
  page_name: string | null;
  refs_json: string;
  tags_json: string;
  task_status: string | null;
  content_hash: string | null;
  is_embedded: number;
  confidence: number | null;
  metadata_json: string | null;
  created_at: number;
  updated_at: number;
}

export interface Template {
  id: string;
  name: string;
  description: string | null;
  slots_json: string;
  created_by: string | null;
  created_at: number;
  updated_at: number;
}

export interface EntryValue {
  id: string;
  record_id: string;
  template_id: string;
  slot_name: string;
  entry_id: string;
  created_at: number;
}
