mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-28 09:43:06 +08:00
feat: implement connection and database types
This commit is contained in:
@ -2,5 +2,7 @@ import { Id } from "./common";
|
||||
|
||||
export interface Chat {
|
||||
id: string;
|
||||
connectionId: Id;
|
||||
databaseName: string;
|
||||
assistantId: Id;
|
||||
}
|
||||
|
@ -1,2 +1,4 @@
|
||||
export type Id = string;
|
||||
export type Timestamp = number;
|
||||
|
||||
export const UNKNOWN_ID = "unknown";
|
||||
|
18
types/connection.ts
Normal file
18
types/connection.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Id } from "./common";
|
||||
|
||||
enum Engine {
|
||||
MySQL = "MYSQL",
|
||||
PostgreSQL = "POSTGRESQL",
|
||||
}
|
||||
|
||||
export interface Connection {
|
||||
id: Id;
|
||||
title: string;
|
||||
engineType: Engine;
|
||||
host: string;
|
||||
port: string;
|
||||
username: string;
|
||||
password: string;
|
||||
// database is only required for PostgreSQL.
|
||||
database?: string;
|
||||
}
|
14
types/database.ts
Normal file
14
types/database.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Id } from "./common";
|
||||
|
||||
export interface Database {
|
||||
connectionId: Id;
|
||||
name: string;
|
||||
tableList: Table[];
|
||||
}
|
||||
|
||||
interface Table {
|
||||
name: string;
|
||||
// structure is a string of the table structure.
|
||||
// It's mainly used for providing a chat context for the assistant.
|
||||
structure: string;
|
||||
}
|
@ -1,9 +1,16 @@
|
||||
import { Id, Timestamp } from "./";
|
||||
|
||||
export enum CreatorRole {
|
||||
System = "system",
|
||||
User = "user",
|
||||
Assistant = "assistant",
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
id: Id;
|
||||
chatId: string;
|
||||
creatorId: Id;
|
||||
creatorRole: CreatorRole;
|
||||
createdAt: Timestamp;
|
||||
content: string;
|
||||
}
|
||||
|
@ -1,13 +1,6 @@
|
||||
export enum UserRole {
|
||||
System = "system",
|
||||
User = "user",
|
||||
Assistant = "assistant",
|
||||
}
|
||||
|
||||
export interface User {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
avatar: string;
|
||||
role: UserRole;
|
||||
}
|
||||
|
Reference in New Issue
Block a user