Project Files
src / types.ts
// ─── Column & Schema Types ────────────────────────────────────────────
export interface ColumnDef {
name: string;
type: "string" | "number" | "boolean" | "date";
required?: boolean;
primaryKey?: boolean;
unique?: boolean;
defaultValue?: unknown;
description?: string;
}
export interface TableSchema {
columns: ColumnDef[];
createdAt: string;
updatedAt?: string;
description?: string;
version?: number;
}
// ─── Validation Types ─────────────────────────────────────────────────
export interface ValidationErrorDetail {
column: string;
message: string;
code: "TYPE_MISMATCH" | "REQUIRED_FIELD" | "INVALID_VALUE";
expected: string;
actual: unknown;
}
export interface ValidationResult {
valid: boolean;
errors: ValidationErrorDetail[];
}
// ─── Table & Database Info ────────────────────────────────────────────
export interface TableMeta {
name: string;
displayName?: string;
createdAt: string;
rowCount: number;
sizeBytes: number;
}
export interface TableInfo {
name: string;
displayName?: string;
rowCount: number;
createdAt: string;
updatedAt: string;
sizeBytes: number;
schemaVersion?: number;
}
export interface DatabaseIndex {
version: number;
name: string;
displayName?: string;
description?: string;
createdAt: string;
updatedAt: string;
tables: Record<string, TableMeta>;
}
export interface DatabaseInfo {
name: string;
displayName?: string;
tableCount: number;
totalSizeBytes: number;
createdAt: string;
updatedAt: string;
}
// ─── Config Types ─────────────────────────────────────────────────────
export interface PluginConfig {
dataRoot: string;
csv: {
delimiter: string;
encoding: string;
bom: boolean;
quoteChar: string;
escapeChar: string;
};
ui: {
locale: string;
dateFormat: string;
};
performance: {
cacheSize: number;
maxRowsPerPage: number;
maxBatchInsert: number;
};
}
// ─── CSV Engine Types ─────────────────────────────────────────────────
export interface ParseOptions {
delimiter?: string;
bom?: boolean;
skipEmptyLines?: boolean;
}
export interface StringifyOptions {
delimiter?: string;
header?: boolean;
quotedString?: boolean;
}
// ─── Tool Parameter Types ─────────────────────────────────────────────
export interface CreateDatabaseParams {
name: string;
displayName?: string;
description?: string;
}
export interface DeleteDatabaseParams {
name: string;
confirm: boolean;
}
export interface DatabaseQueryParams {
name: string;
}
export interface CreateTableParams {
database: string;
table: string;
columns: ColumnDef[];
description?: string;
}
export interface TableQueryParams {
database: string;
table: string;
}
export interface DeleteTableParams {
database: string;
table: string;
confirm: boolean;
}
export interface InsertParams {
database: string;
table: string;
data: Record<string, unknown>;
}
export interface InsertBatchParams {
database: string;
table: string;
rows: Record<string, unknown>[];
}
export interface SelectParams {
database: string;
table: string;
filter?: Record<string, unknown>;
limit?: number;
offset?: number;
}
export interface UpdateParams {
database: string;
table: string;
id: string;
data: Partial<Record<string, unknown>>;
}
export interface DeleteRowParams {
database: string;
table: string;
id: string;
}
export interface QueryFilter {
column: string;
operator:
| "eq"
| "neq"
| "gt"
| "gte"
| "lt"
| "lte"
| "in"
| "contains"
| "startsWith"
| "endsWith";
value: unknown;
}
export interface SearchCondition {
column: string;
query: string;
caseSensitive?: boolean;
}
export interface SortCondition {
column: string;
direction: "asc" | "desc";
}
export interface QueryParams {
database: string;
table: string;
filters?: QueryFilter[];
search?: SearchCondition;
sort?: SortCondition;
limit?: number;
offset?: number;
}
export interface AggregateParams {
database: string;
table: string;
column: string;
operation: "count" | "sum" | "avg" | "min" | "max";
filter?: Record<string, unknown>;
}
// ─── Tool Result Types ────────────────────────────────────────────────
export interface CreateDatabaseResult {
success: boolean;
name: string;
path?: string;
error?: string;
}
export interface DeleteDatabaseResult {
success: boolean;
deletedTables: number;
}
export interface CreateTableResult {
success: boolean;
database: string;
table: string;
columnCount: number;
}
export interface DeleteTableResult {
success: boolean;
deletedFiles: string[];
}
export interface SchemaResult {
database: string;
table: string;
columns: ColumnDef[];
createdAt: string;
description?: string;
}
export interface InsertResult {
success: boolean;
id: string;
table: string;
}
export interface InsertBatchResult {
success: boolean;
inserted: number;
ids: string[];
}
export interface SelectResult {
rows: Record<string, unknown>[];
total: number;
filteredTotal: number;
}
export interface UpdateResult {
success: boolean;
id: string;
updated: string[];
}
export interface DeleteRowResult {
success: boolean;
id: string;
}
export interface GetRowResult {
row: Record<string, unknown> | null;
}
export interface QueryResult {
rows: Record<string, unknown>[];
total: number;
filteredTotal: number;
page: number;
totalPages: number;
}
export interface AggregateResult {
operation: string;
column: string;
result: number;
count: number;
}
// ─── Tool List Result ─────────────────────────────────────────────────
export interface DatabaseListResult {
databases: DatabaseInfo[];
total: number;
}
export interface DatabaseDetailResult {
name: string;
displayName?: string;
tableCount: number;
totalSizeBytes: number;
createdAt: string;
updatedAt: string;
tables: TableInfo[];
}
export interface TableListResult {
database: string;
tables: TableInfo[];
total: number;
}