Cleanup types

This commit is contained in:
Louis Knight-Webb
2025-06-15 14:39:45 -04:00
parent 3d6b108880
commit a435e3ce5d
15 changed files with 42 additions and 116 deletions

View File

@@ -59,7 +59,7 @@ bloop/
ts-rs allows you to derive TypeScript types from Rust structs/enums. By annotating your Rust types with #[derive(TS)] and related macros, ts-rs will generate .ts declaration files for those types.
When making changes to the types, you can regenerate them using `npm run generate-types`
Do not manually edit shared/types.ts
Do not manually edit shared/types.ts, instead edit backend/src/bin/generate_types.rs
# Working on the frontend AND the backend

View File

@@ -31,39 +31,39 @@ fn main() {
r#"// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
// Auto-generated from Rust backend types using ts-rs
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
{}
export {}
"#,
bloop_backend::models::ApiResponse::<()>::decl(),
bloop_backend::models::project::CreateProject::decl(),
bloop_backend::models::project::Project::decl(),
bloop_backend::models::project::UpdateProject::decl(),
bloop_backend::models::task::CreateTask::decl(),
bloop_backend::models::task::Task::decl(),
bloop_backend::models::task::TaskStatus::decl(),
bloop_backend::models::task::Task::decl(),
bloop_backend::models::task::UpdateTask::decl(),
bloop_backend::models::user::CreateUser::decl(),
bloop_backend::models::user::LoginRequest::decl(),

View File

@@ -4,7 +4,7 @@ import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { LoginRequest, LoginResponse, ApiResponse } from '@/types'
import { LoginRequest, LoginResponse, ApiResponse } from 'shared/types'
import { useAuth } from '@/contexts/auth-context'
import { LogIn, AlertCircle } from 'lucide-react'

View File

@@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Project, ApiResponse } from '@/types'
import { Project, ApiResponse } from 'shared/types'
import { ProjectForm } from './project-form'
import { makeAuthenticatedRequest } from '@/lib/auth'
import { ArrowLeft, Edit, Trash2, Calendar, Clock, User, AlertCircle, Loader2, CheckSquare } from 'lucide-react'

View File

@@ -4,7 +4,7 @@ import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Project, CreateProject, UpdateProject } from '@/types'
import { Project, CreateProject, UpdateProject } from 'shared/types'
import { AlertCircle } from 'lucide-react'
import { makeAuthenticatedRequest } from '@/lib/auth'

View File

@@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Project, ApiResponse } from '@/types'
import { Project, ApiResponse } from 'shared/types'
import { ProjectForm } from './project-form'
import { makeAuthenticatedRequest } from '@/lib/auth'
import { Plus, Edit, Trash2, Calendar, AlertCircle, Loader2, CheckSquare } from 'lucide-react'

View File

@@ -4,7 +4,7 @@ import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { User, CreateUser, UpdateUser } from '@/types'
import { User, CreateUser, UpdateUser } from 'shared/types'
import { makeAuthenticatedRequest, authStorage } from '@/lib/auth'
import { AlertCircle } from 'lucide-react'

View File

@@ -3,7 +3,7 @@ import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { User, ApiResponse } from '@/types'
import { User, ApiResponse } from 'shared/types'
import { UserForm } from './user-form'
import { makeAuthenticatedRequest, authStorage } from '@/lib/auth'
import { Plus, Edit, Trash2, Calendar, AlertCircle, Loader2, Shield, User as UserIcon } from 'lucide-react'

View File

@@ -1,6 +1,6 @@
import { createContext, useContext, useState, useEffect, ReactNode } from 'react'
import { isAuthenticated, authStorage, makeAuthenticatedRequest } from '@/lib/auth'
import { User } from '@/types'
import { User } from 'shared/types'
interface AuthContextType {
user: User | null
@@ -39,7 +39,9 @@ export function AuthProvider({ children }: AuthProviderProps) {
const userData: User = {
id: data.data.user_id,
email: data.data.email,
is_admin: data.data.is_admin || false
is_admin: data.data.is_admin || false,
created_at: new Date(),
updated_at: new Date()
}
authStorage.setUser(userData)
setUser(userData)

View File

@@ -1,4 +1,4 @@
import { User } from '@/types'
import { User } from 'shared/types'
const TOKEN_KEY = 'auth_token'
const USER_KEY = 'auth_user'

View File

@@ -10,7 +10,7 @@ import {
} from "@/components/ui/card";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { Badge } from "@/components/ui/badge";
import { ApiResponse } from "@/types";
import { ApiResponse } from "shared/types";
import { authStorage, makeAuthenticatedRequest } from "@/lib/auth";
import {
Heart,

View File

@@ -34,7 +34,7 @@ import {
KanbanCard,
type DragEndEvent
} from '@/components/ui/shadcn-io/kanban'
import type { TaskStatus } from '@/types'
import type { TaskStatus } from 'shared/types'
interface Task {
id: string

View File

@@ -3,7 +3,7 @@ import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { User, ApiResponse } from '@/types'
import { User, ApiResponse } from 'shared/types'
import { UserForm } from '@/components/users/user-form'
import { makeAuthenticatedRequest, authStorage } from '@/lib/auth'
import { Plus, Edit, Trash2, Calendar, AlertCircle, Loader2, Shield, User as UserIcon } from 'lucide-react'

View File

@@ -1,76 +0,0 @@
// Shared types for the frontend application
export interface User {
id: string
email: string
is_admin: boolean
created_at?: Date
updated_at?: Date
}
export interface ApiResponse<T> {
success: boolean
data: T | null
message: string | null
}
export interface LoginRequest {
email: string
password: string
}
export interface LoginResponse {
user: User
token: string
}
export interface Project {
id: string
name: string
owner_id: string
created_at: Date
updated_at: Date
}
export interface CreateProject {
name: string
}
export interface UpdateProject {
name: string | null
}
export interface Task {
id: string
project_id: string
title: string
description: string | null
status: TaskStatus
created_at: string
updated_at: string
}
export type TaskStatus = "todo" | "inprogress" | "inreview" | "done" | "cancelled"
export interface CreateTask {
project_id: string
title: string
description: string | null
}
export interface UpdateTask {
title: string | null
description: string | null
status: TaskStatus | null
}
export interface CreateUser {
email: string
password: string
is_admin: boolean | null
}
export interface UpdateUser {
email: string | null
password: string | null
is_admin: boolean | null
}

View File

@@ -1,28 +1,28 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
// Auto-generated from Rust backend types using ts-rs
type ApiResponse<T> = { success: boolean, data: T | null, message: string | null, };
export type ApiResponse<T> = { success: boolean, data: T | null, message: string | null, };
type CreateProject = { name: string, };
export type CreateProject = { name: string, };
type Project = { id: string, name: string, owner_id: string, created_at: Date, updated_at: Date, };
export type Project = { id: string, name: string, owner_id: string, created_at: Date, updated_at: Date, };
type UpdateProject = { name: string | null, };
export type UpdateProject = { name: string | null, };
type CreateTask = { project_id: string, title: string, description: string | null, };
export type CreateTask = { project_id: string, title: string, description: string | null, };
type Task = { id: string, project_id: string, title: string, description: string | null, status: TaskStatus, created_at: string, updated_at: string, };
export type TaskStatus = "todo" | "inprogress" | "inreview" | "done" | "cancelled";
type TaskStatus = "todo" | "inprogress" | "inreview" | "done" | "cancelled";
export type Task = { id: string, project_id: string, title: string, description: string | null, status: TaskStatus, created_at: string, updated_at: string, };
type UpdateTask = { title: string | null, description: string | null, status: TaskStatus | null, };
export type UpdateTask = { title: string | null, description: string | null, status: TaskStatus | null, };
type CreateUser = { email: string, password: string, is_admin: boolean | null, };
export type CreateUser = { email: string, password: string, is_admin: boolean | null, };
type LoginRequest = { email: string, password: string, };
export type LoginRequest = { email: string, password: string, };
type LoginResponse = { user: User, token: string, };
export type LoginResponse = { user: User, token: string, };
type UpdateUser = { email: string | null, password: string | null, is_admin: boolean | null, };
export type UpdateUser = { email: string | null, password: string | null, is_admin: boolean | null, };
type User = { id: string, email: string, is_admin: boolean, created_at: Date, updated_at: Date, };
export type User = { id: string, email: string, is_admin: boolean, created_at: Date, updated_at: Date, };