Строгая типизация: TypeScript интерфейсы 1:1 с Pydantic-схемами

- Добавлен MemberBrief для вложенных объектов (author, assignee, reviewer, uploaded_by)
- Task.assignee/reviewer: Member → MemberBrief
- Message.author: Member → MemberBrief
- Step: добавлены task_id, created_at
- Task: добавлены created_at, updated_at
- Member: добавлен is_active
- ProjectFile: uploaded_by теперь MemberBrief вместо string
This commit is contained in:
Markov 2026-02-25 14:03:42 +01:00
parent 9e6cc84965
commit 16f11d6882
2 changed files with 20 additions and 9 deletions

View File

@ -225,7 +225,7 @@ export default function ProjectFiles({ project }: Props) {
{/* Uploader */}
<div className="text-xs text-[var(--muted)] hidden md:block shrink-0">
{f.uploader?.name}
{f.uploaded_by?.name}
</div>
{/* Date */}

View File

@ -44,6 +44,14 @@ async function request<T = any>(path: string, options: RequestInit = {}): Promis
// --- Types ---
// --- Shared types (1:1 with backend Pydantic schemas) ---
export interface MemberBrief {
id: string;
slug: string;
name: string;
}
export interface AgentConfig {
capabilities: string[];
chat_listen: string;
@ -60,6 +68,7 @@ export interface Member {
role: string;
status: string;
avatar_url: string | null;
is_active: boolean;
agent_config: AgentConfig | null;
token?: string | null;
}
@ -84,14 +93,16 @@ export interface ProjectMember {
name: string;
slug: string;
type: "human" | "agent";
role: string; // "owner" | "member"
role: string;
}
export interface Step {
id: string;
task_id: string;
title: string;
done: boolean;
position: number;
created_at: string;
}
export interface Task {
@ -107,14 +118,16 @@ export interface Task {
priority: string;
labels: string[];
assignee_id: string | null;
assignee: Member | null;
assignee: MemberBrief | null;
reviewer_id: string | null;
reviewer: Member | null;
reviewer: MemberBrief | null;
watcher_ids: string[];
depends_on: string[];
position: number;
time_spent: number;
steps: Step[];
created_at: string;
updated_at: string;
}
export interface Attachment {
@ -130,8 +143,8 @@ export interface Message {
task_id: string | null;
parent_id: string | null;
author_type: string;
author_id: string;
author: Member | null;
author_id: string | null;
author: MemberBrief | null;
content: string;
mentions: string[];
voice_url: string | null;
@ -306,13 +319,11 @@ export async function revokeToken(slug: string): Promise<void> {
export interface ProjectFile {
id: string;
project_id: string;
filename: string;
description: string | null;
mime_type: string | null;
size: number;
uploaded_by: string;
uploader: { id: string; slug: string; name: string } | null;
uploaded_by: MemberBrief | null;
created_at: string;
updated_at: string;
}