All files / web/src/db/schema tts-collected-clips.ts

100% Statements 46/46
100% Branches 1/1
100% Functions 0/0
100% Lines 46/46

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 472x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x  
import { integer, primaryKey, sqliteTable, text } from 'drizzle-orm/sqlite-core'
 
/**
 * Runtime-collected TTS clips.
 *
 * Each row represents a unique clip ID observed during app usage.
 * The client flushes its in-memory collection here periodically.
 * The admin page reads from this table to decide which clips to generate.
 */
export const ttsCollectedClips = sqliteTable('tts_collected_clips', {
  /** Human-readable clip ID (e.g. "student-name", "five-plus-three") */
  id: text('id').primaryKey(),
  /** Freeform tone/instruction string for TTS generation */
  tone: text('tone').notNull(),
  /** Cumulative play count */
  playCount: integer('play_count').notNull().default(0),
  /** ISO timestamp of first observation */
  firstSeenAt: text('first_seen_at').notNull(),
  /** ISO timestamp of most recent observation */
  lastSeenAt: text('last_seen_at').notNull(),
})
 
/**
 * Per-locale fallback text for collected clips.
 *
 * Each row maps a (clipId, locale) pair to the text that should be spoken
 * when the clip mp3 isn't available and the voice chain falls through to
 * browser TTS. Also used as input text for TTS mp3 generation.
 */
export const ttsCollectedClipSay = sqliteTable(
  'tts_collected_clip_say',
  {
    /** References tts_collected_clips.id */
    clipId: text('clip_id').notNull(),
    /** BCP 47 locale tag (e.g. "en-US", "ja") */
    locale: text('locale').notNull(),
    /** The text to speak in this locale */
    text: text('text').notNull(),
  },
  (table) => [primaryKey({ columns: [table.clipId, table.locale] })]
)
 
export type TtsCollectedClip = typeof ttsCollectedClips.$inferSelect
export type NewTtsCollectedClip = typeof ttsCollectedClips.$inferInsert
export type TtsCollectedClipSay = typeof ttsCollectedClipSay.$inferSelect
export type NewTtsCollectedClipSay = typeof ttsCollectedClipSay.$inferInsert