Skip to content

Commit 3cde171

Browse files
committed
refactor: Centralize type definitions
Simplifies type definitions by consolidating them into a single `app.d.ts` file.
1 parent 3a45b7d commit 3cde171

File tree

21 files changed

+81
-65
lines changed

21 files changed

+81
-65
lines changed

tools/server/webui/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_BASE_URL=http://localhost:8080
1+
VITE_BASE_URL = "http://localhost:8080"

tools/server/webui/src/app.d.ts

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,39 @@
22
// for information about these interfaces
33

44
// Import chat types from dedicated module
5+
6+
import type {
7+
ApiChatCompletionRequest,
8+
ApiChatCompletionResponse,
9+
ApiChatCompletionStreamChunk,
10+
ApiChatMessageData,
11+
ApiChatMessageContentPart,
12+
ApiLlamaCppServerProps,
13+
} from '$lib/types/api';
14+
515
import type {
6-
ChatMessageData,
7-
ChatCompletionRequest,
8-
ChatCompletionResponse,
9-
ChatCompletionStreamChunk
16+
ChatMessageType,
17+
ChatRole,
18+
ChatUploadedFile,
1019
} from '$lib/types/chat';
1120

21+
import type {
22+
DatabaseAppSettings,
23+
DatabaseConversation,
24+
DatabaseMessage,
25+
DatabaseMessageExtra,
26+
DatabaseMessageExtraAudioFile,
27+
DatabaseMessageExtraImageFile,
28+
DatabaseMessageExtraTextFile,
29+
DatabaseMessageExtraPdfFile,
30+
} from '$lib/types/database';
31+
32+
import type {
33+
SettingsConfigValue,
34+
SettingsFieldConfig,
35+
SettingsConfigType,
36+
} from '$lib/types/settings';
37+
1238
declare global {
1339
// namespace App {
1440
// interface Error {}
@@ -18,10 +44,27 @@ declare global {
1844
// interface Platform {}
1945
// }
2046

21-
export type {
47+
export {
48+
ApiChatCompletionRequest,
49+
ApiChatCompletionResponse,
50+
ApiChatCompletionStreamChunk,
51+
ApiChatMessageData,
52+
ApiChatMessageContentPart,
53+
ApiLlamaCppServerProps,
2254
ChatMessageData,
23-
ChatCompletionRequest,
24-
ChatCompletionResponse,
25-
ChatCompletionStreamChunk
26-
};
55+
ChatMessageType,
56+
ChatRole,
57+
ChatUploadedFile,
58+
DatabaseAppSettings,
59+
DatabaseConversation,
60+
DatabaseMessage,
61+
DatabaseMessageExtra,
62+
DatabaseMessageExtraAudioFile,
63+
DatabaseMessageExtraImageFile,
64+
DatabaseMessageExtraTextFile,
65+
DatabaseMessageExtraPdfFile,
66+
SettingsConfigValue,
67+
SettingsFieldConfig,
68+
SettingsConfigType,
69+
}
2770
}

tools/server/webui/src/lib/app.d.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

tools/server/webui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentPreviewDialog.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<script lang="ts">
22
import * as Dialog from '$lib/components/ui/dialog';
33
import { FileText, Image, Music, FileIcon } from '@lucide/svelte';
4-
import type { DatabaseMessageExtra } from '$lib/types/database.d.ts';
5-
import type { ChatUploadedFile } from '$lib/types/chat.d.ts';
64
75
interface Props {
86
open: boolean;

tools/server/webui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<script lang="ts">
22
import { ChatAttachmentImagePreview, ChatAttachmentFilePreview } from '$lib/components/app';
33
import ChatAttachmentPreviewDialog from './ChatAttachmentPreviewDialog.svelte';
4-
import type { ChatUploadedFile } from '$lib/types/chat.d.ts';
5-
import type { DatabaseMessageExtra } from '$lib/types/database.d.ts';
64
75
interface Props {
86
class?: string;

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatForm.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script lang="ts">
2-
import type { ChatUploadedFile } from '$lib/types/chat.d.ts';
32
import { ChatAttachmentsList } from '$lib/components/app';
43
import { ChatFormActionButtons, ChatFormFileInput, ChatFormHelperText, ChatFormTextarea } from '$lib/components/app';
54
import { inputClasses } from '$lib/constants/input-classes';

tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessage.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import { Button } from '$lib/components/ui/button';
55
import { ChatAttachmentsList, ChatMessageThinkingBlock, MarkdownContent } from '$lib/components/app';
66
import { Tooltip, TooltipContent, TooltipTrigger } from '$lib/components/ui/tooltip';
7-
import type { ChatRole } from '$lib/types/chat';
8-
import type { DatabaseMessage } from '$lib/types/database';
97
import { copyToClipboard } from '$lib/utils/copy';
108
import { parseThinkingContent } from '$lib/utils/thinking';
119

tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessages.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script lang="ts">
2-
import type { DatabaseMessage } from '$lib/types/database';
32
import { updateMessage, regenerateMessage } from '$lib/stores/chat.svelte';
43
import { ChatMessage } from '$lib/components/app';
54

tools/server/webui/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import { onMount } from 'svelte';
1212
import { fade, fly, slide } from 'svelte/transition';
1313
import { Upload } from '@lucide/svelte';
14-
import type { ChatUploadedFile } from '$lib/types/chat.d.ts';
15-
import type { DatabaseMessageExtra } from '$lib/types/database.d.ts';
1614
import {
1715
convertPDFToText,
1816
isLikelyTextFile,

tools/server/webui/src/lib/components/app/chat/ChatSettings/ChatSettingsDialog.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
updateMultipleConfig,
1313
resetConfig
1414
} from '$lib/stores/settings.svelte';
15-
import { type SettingsConfigType, type FieldConfig } from '$lib/types/settings';
1615
1716
interface Props {
1817
onOpenChange?: (open: boolean) => void;
@@ -52,7 +51,7 @@
5251
const settingSections: Array<{
5352
title: string;
5453
icon: any;
55-
fields: FieldConfig[];
54+
fields: SettingsFieldConfig[];
5655
}> = [
5756
{
5857
title: 'General',

0 commit comments

Comments
 (0)