@@ -27,6 +27,7 @@ import {
2727 TABLE_SESSIONS ,
2828 tagSchema as baseTagSchema ,
2929 templateSchema as baseTemplateSchema ,
30+ transcriptSchema as baseTranscriptSchema ,
3031 wordSchema ,
3132} from "@hypr/db" ;
3233import { createBroadcastChannelSynchronizer } from "tinybase/synchronizers/synchronizer-broadcast-channel/with-schemas" ;
@@ -67,6 +68,10 @@ export const sessionSchema = baseSessionSchema.omit({ id: true }).extend({
6768 folder_id : z . preprocess ( val => val ?? undefined , z . string ( ) . optional ( ) ) ,
6869} ) ;
6970
71+ export const transcriptSchema = baseTranscriptSchema . omit ( { id : true } ) . extend ( {
72+ created_at : z . string ( ) ,
73+ } ) ;
74+
7075export const mappingSessionParticipantSchema = baseMappingSessionParticipantSchema . omit ( { id : true } ) . extend ( {
7176 created_at : z . string ( ) ,
7277} ) ;
@@ -99,6 +104,7 @@ export const chatMessageSchema = baseChatMessageSchema.omit({ id: true }).extend
99104export const wordSchemaOverride = wordSchema . omit ( { id : true } ) . extend ( {
100105 created_at : z . string ( ) ,
101106 speaker : z . preprocess ( val => val ?? undefined , z . string ( ) . optional ( ) ) ,
107+ transcript_id : z . string ( ) ,
102108} ) ;
103109
104110export type Human = z . infer < typeof humanSchema > ;
@@ -107,6 +113,7 @@ export type Calendar = z.infer<typeof calendarSchema>;
107113export type Organization = z . infer < typeof organizationSchema > ;
108114export type Folder = z . infer < typeof folderSchema > ;
109115export type Session = z . infer < typeof sessionSchema > ;
116+ export type Transcript = z . infer < typeof transcriptSchema > ;
110117export type Word = z . infer < typeof wordSchemaOverride > ;
111118export type mappingSessionParticipant = z . infer < typeof mappingSessionParticipantSchema > ;
112119export type Tag = z . infer < typeof tagSchema > ;
@@ -117,6 +124,7 @@ export type ChatGroup = z.infer<typeof chatGroupSchema>;
117124export type ChatMessage = z . infer < typeof chatMessageSchema > ;
118125
119126export type SessionStorage = ToStorageType < typeof sessionSchema > ;
127+ export type TranscriptStorage = ToStorageType < typeof transcriptSchema > ;
120128export type TemplateStorage = ToStorageType < typeof templateSchema > ;
121129export type ChatMessageStorage = ToStorageType < typeof chatMessageSchema > ;
122130
@@ -138,14 +146,19 @@ const SCHEMA = {
138146 raw_md : { type : "string" } ,
139147 enhanced_md : { type : "string" } ,
140148 } satisfies InferTinyBaseSchema < typeof sessionSchema > ,
149+ transcripts : {
150+ user_id : { type : "string" } ,
151+ created_at : { type : "string" } ,
152+ session_id : { type : "string" } ,
153+ } satisfies InferTinyBaseSchema < typeof transcriptSchema > ,
141154 words : {
142155 user_id : { type : "string" } ,
143156 created_at : { type : "string" } ,
144157 text : { type : "string" } ,
145- session_id : { type : "string" } ,
158+ transcript_id : { type : "string" } ,
146159 start_ms : { type : "number" } ,
147160 end_ms : { type : "number" } ,
148- speaker : { type : "string " } ,
161+ channel : { type : "number " } ,
149162 } satisfies InferTinyBaseSchema < typeof wordSchema > ,
150163 humans : {
151164 user_id : { type : "string" } ,
@@ -318,6 +331,18 @@ export const StoreComponent = () => {
318331 "folders" ,
319332 "parent_folder_id" ,
320333 )
334+ . setRelationshipDefinition (
335+ "transcriptToSession" ,
336+ "transcripts" ,
337+ "sessions" ,
338+ "session_id" ,
339+ )
340+ . setRelationshipDefinition (
341+ "wordToTranscript" ,
342+ "words" ,
343+ "transcripts" ,
344+ "transcript_id" ,
345+ )
321346 . setRelationshipDefinition (
322347 "sessionParticipantToHuman" ,
323348 "mapping_session_participant" ,
@@ -436,6 +461,8 @@ export const StoreComponent = () => {
436461 . setIndexDefinition ( INDEXES . sessionsByHuman , "mapping_session_participant" , "human_id" )
437462 . setIndexDefinition ( INDEXES . foldersByParent , "folders" , "parent_folder_id" , "name" )
438463 . setIndexDefinition ( INDEXES . sessionsByFolder , "sessions" , "folder_id" , "created_at" )
464+ . setIndexDefinition ( INDEXES . transcriptsBySession , "transcripts" , "session_id" )
465+ . setIndexDefinition ( INDEXES . wordsByTranscript , "words" , "transcript_id" , "start_ms" )
439466 . setIndexDefinition ( INDEXES . eventsByCalendar , "events" , "calendar_id" , "started_at" )
440467 . setIndexDefinition (
441468 INDEXES . eventsByDate ,
@@ -529,6 +556,8 @@ export const INDEXES = {
529556 sessionParticipantsBySession : "sessionParticipantsBySession" ,
530557 foldersByParent : "foldersByParent" ,
531558 sessionsByFolder : "sessionsByFolder" ,
559+ transcriptsBySession : "transcriptsBySession" ,
560+ wordsByTranscript : "wordsByTranscript" ,
532561 eventsByCalendar : "eventsByCalendar" ,
533562 eventsByDate : "eventsByDate" ,
534563 sessionByDateWithoutEvent : "sessionByDateWithoutEvent" ,
0 commit comments