import type { ColumnType, Generated, Insertable, Selectable, Updateable } from "kysely"; import type { PromptType } from "../prompts"; import type { AudioMetadata, AudioStatus, Stamp, Transcription } from "../audio"; import type { FileMetadata, FileStatus, FileType } from "../file"; import type { LlmProcessingType, LlmProcessingMetadata } from "../llm"; import type { NoteType, NoteLinkMetadata } from "../notes"; export type Timestamp = ColumnType; export type Json = JsonValue; export type JsonArray = JsonValue[]; export type JsonObject = { [x: string]: JsonValue | undefined; }; export type JsonPrimitive = boolean | number | string | null; export type JsonValue = JsonArray | JsonObject | JsonPrimitive; export interface NotesTable { id: Generated; createdAt: Timestamp; title: string | null; content: string | null; flag: Generated; updatedAt: Timestamp; deletedAt: Timestamp | null; userId: string; audioId: string | null; type: Generated; summary: string | null; sceneId: string | null; metadata: NoteLinkMetadata | null; tagId: string | null; raw: string | null; fileId: string | null; } export interface TagsTable { id: Generated; name: string; description: string | null; userId: string; createdAt: Timestamp; autoTag: Generated; promptId: string | null; color: string | null; } export interface NoteKeywordsTable { id: Generated; noteId: string; keyword: string; userId: string; } export interface AudiosTable { id: string; createdAt: Timestamp; userId: string; duration: number; transcription: Transcription | null; metadata: AudioMetadata | null; stamps: Stamp[] | null; speakerMapping: Json | null; status: AudioStatus; sceneId: string | null; startedAt: Timestamp | null; finishedAt: Timestamp | null; vtt: string | null; } export interface FilesTable { id: string; createdAt: Timestamp; userId: string; type: FileType; status: FileStatus; metadata: FileMetadata | null; markdown: string | null; } export interface LlmProcessingTable { id: Generated; createdAt: Generated; userId: string; noteId: string; type: LlmProcessingType; model: string; reasoningEffort: string | null; reasoning: string | null; metadata: LlmProcessingMetadata | null; finishedAt: Timestamp | null; } export interface PromptsTable { id: Generated; createdAt: Timestamp; title: string; description: string | null; prompt: string; userId: Generated; type: Generated; } export interface ScenesTable { id: Generated; createdAt: Timestamp; userId: string; name: string; promptId: string; formattedTitle: string | null; keytermId: string | null; followUp: Generated; } export interface KeytermsTable { id: Generated; content: string | null; userId: string; } export interface SceneTagsTable { id: Generated; sceneId: string; tagId: string; userId: string; } export interface PeopleTable { id: Generated; name: string; metadata: Json | null; userId: string; createdAt: Timestamp; nickname: string | null; persona: string | null; } export interface NotePeopleTable { id: Generated; noteId: string; personId: string; userId: string; } export interface ScenePeopleTable { id: Generated; sceneId: string; personId: string; userId: string; } export type SettingsRole = 'general' | 'contentCreator' | 'consultant' | 'productManager' | 'journalist' | 'entrepreneur'; export interface SettingsTable { id: string; language: Generated; timezone: Generated; role: SettingsRole | null; baseKeyterms: Generated; } export interface ProfilesTable { id: string; subscriptionTier: Generated; subscriptionExpiresAt: Timestamp | null; voiceUsageThisMonth: Generated; usageResetAt: Timestamp | null; subscriptionId: string | null; transactionId: string | null; subscriptionStatus: Generated; lastEventType: string | null; lastEventAt: Timestamp | null; createdAt: Timestamp; updatedAt: Timestamp; } export type NoteTypeFilter = "link" | "voice" | "text"; export interface FolderRules { tags: string[]; people: string[]; keywords: string[]; noteTypes: NoteTypeFilter[]; } export interface FoldersTable { id: Generated; name: string; rules: FolderRules; userId: string; createdAt: Timestamp; } export type ExtensionType = "telegram" | "discord" | "slack" | "notion" | "guionalert" | "api"; export interface TelegramMetadata { username?: string; } export interface DiscordMetadata { username?: string; } export interface SlackMetadata { username?: string; } export interface NotionMetadata { accessToken: string; tokenType: string; botId: string; workspaceId: string; workspaceName?: string; workspaceIcon?: string; grantedPages: Array<{ id: string; title: string; }>; createdAt?: number; updatedAt?: number; } export interface ApiKeyMetadata { prefix: string; lastFour: string; createdAt: number; } export type ExtensionMetadata = TelegramMetadata | DiscordMetadata | SlackMetadata | NotionMetadata | ApiKeyMetadata; export interface TelegramSettings { sendConfirmation: boolean; listenTo?: string[]; } export interface DiscordSettings { } export interface SlackSettings { } export interface NotionSettings { syncDstPageId?: string; databaseId?: string | null; } export type ExtensionSettings = TelegramSettings | DiscordSettings | SlackSettings | NotionSettings; export interface ExtensionsTable { id: Generated; type: ExtensionType; userId: string; platformId: string; metadata: ExtensionMetadata | null; settings: ExtensionSettings | null; } export interface Database { notes: NotesTable; tags: TagsTable; note_keywords: NoteKeywordsTable; audios: AudiosTable; files: FilesTable; llm_processing: LlmProcessingTable; prompts: PromptsTable; scenes: ScenesTable; scene_tags: SceneTagsTable; keyterms: KeytermsTable; people: PeopleTable; note_people: NotePeopleTable; scene_people: ScenePeopleTable; settings: SettingsTable; profiles: ProfilesTable; extensions: ExtensionsTable; folders: FoldersTable; } export type Note = Selectable; export type NewNote = Insertable; export type NoteUpdate = Updateable; export type Tag = Selectable; export type NewTag = Insertable; export type NoteKeyword = Selectable; export type NewNoteKeyword = Insertable; export type Audio = Selectable; export type NewAudio = Insertable; export type AudioUpdate = Updateable; export type File = Selectable; export type NewFile = Insertable; export type FileUpdate = Updateable; export type LlmProcessing = Selectable; export type NewLlmProcessing = Insertable; export type LlmProcessingUpdate = Updateable; export type Prompt = Selectable; export type NewPrompt = Insertable; export type Scene = Selectable; export type NewScene = Insertable; export type Keyterm = Selectable; export type NewKeyterm = Insertable; export type SceneTag = Selectable; export type NewSceneTag = Insertable; export type Person = Selectable; export type NewPerson = Insertable; export type NotePerson = Selectable; export type NewNotePerson = Insertable; export type ScenePerson = Selectable; export type NewScenePerson = Insertable; export type Settings = Selectable; export type NewSettings = Insertable; export type Profile = Selectable; export type NewProfile = Insertable; export type Extension = Selectable; export type NewExtension = Insertable; export type ExtensionUpdate = Updateable; export type Folder = Selectable; export type NewFolder = Insertable; export type FolderUpdate = Updateable;