Строгая типизация: 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 */} {/* Uploader */}
<div className="text-xs text-[var(--muted)] hidden md:block shrink-0"> <div className="text-xs text-[var(--muted)] hidden md:block shrink-0">
{f.uploader?.name} {f.uploaded_by?.name}
</div> </div>
{/* Date */} {/* Date */}

View File

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