From 0379ea4ae4e9b22ec86ae034e9c15b6fb5836e3f Mon Sep 17 00:00:00 2001 From: Jean Jacques Avril Date: Wed, 12 Mar 2025 06:38:41 +0000 Subject: [PATCH] feat: Add TypeScript type generation and update DTOs to use string for IDs --- backend/Makefile | 22 ++++-------- backend/{tygo.yml => tygo.yaml} | 2 +- docu/deployment_devops.md | 17 ---------- frontend/src/types/dto.ts | 59 +++++++++++++++++++++------------ 4 files changed, 45 insertions(+), 55 deletions(-) rename backend/{tygo.yml => tygo.yaml} (70%) delete mode 100644 docu/deployment_devops.md diff --git a/backend/Makefile b/backend/Makefile index a3eb15b..4846ee1 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -27,6 +27,7 @@ help: @echo " make db-reinit - Re-initialize the database" @echo " make swagger - Generate swagger documentation" @echo " make help - Show this help message" + @echo "" make generate-ts - Generate TypeScript types # Start the database db-start: @@ -95,20 +96,9 @@ swagger: @swag init -g cmd/api/main.go @echo "Swagger documentation generated" +# Generate TypeScript types +generate-ts: + @echo "Generating TypeScript types..." + @tygo generate + @echo "TypeScript types generated" -help: - @echo "Time Tracker Backend Makefile" - @echo "" - @echo "Usage:" - @echo " make db-start - Start the PostgreSQL database container" - @echo " make db-stop - Stop the PostgreSQL database container" - @echo " make db-test - Test the database connection" - @echo " make model-test - Test the database models" - @echo " make run - Run the application" - @echo " make build - Build the application" - @echo " make clean - Remove build artifacts" - @echo " make migrate - Run database migrations" - @echo " make seed - Seed the database with initial data" - @echo " make db-drop-users - Drop the users table" - @echo " make db-reinit - Re-initialize the database" - @echo " make help - Show this help message" diff --git a/backend/tygo.yml b/backend/tygo.yaml similarity index 70% rename from backend/tygo.yml rename to backend/tygo.yaml index 0781f4d..0bc6aa2 100644 --- a/backend/tygo.yml +++ b/backend/tygo.yaml @@ -1,5 +1,5 @@ packages: - - path: github.com/timetracker/backend/dto + - path: github.com/timetracker/backend/internal/dtos type_mappings: "time.Time": "string" "ulid.ULID": "string" diff --git a/docu/deployment_devops.md b/docu/deployment_devops.md deleted file mode 100644 index c757f62..0000000 --- a/docu/deployment_devops.md +++ /dev/null @@ -1,17 +0,0 @@ -# Deployment and DevOps - -## Containerization -- Docker containers for backend and frontend -- Docker Compose for development environment -- Kubernetes manifests for production environment - -## CI/CD Pipeline -- Automated tests (Unit, Integration, E2E) -- Automated deployment -- Version management - -## Monitoring and Logging -- Prometheus for metrics -- Grafana for visualization -- ELK Stack or similar for logging -- Alerting for critical events diff --git a/frontend/src/types/dto.ts b/frontend/src/types/dto.ts index dca372f..044b839 100644 --- a/frontend/src/types/dto.ts +++ b/frontend/src/types/dto.ts @@ -24,6 +24,24 @@ export interface ActivityUpdateDto { billingRate?: number /* float64 */; } +////////// +// source: auth_dto.go + +/** + * LoginDto represents the login request + */ +export interface LoginDto { + email: string; + password: string; +} +/** + * TokenDto represents the response after successful authentication + */ +export interface TokenDto { + token: string; + user: UserDto; +} + ////////// // source: company_dto.go @@ -54,11 +72,11 @@ export interface CustomerDto { updatedAt: string; lastEditorID: string; name: string; - companyId: number /* int */; + companyId: string; } export interface CustomerCreateDto { name: string; - companyId: number /* int */; + companyId: string; } export interface CustomerUpdateDto { id: string; @@ -66,7 +84,7 @@ export interface CustomerUpdateDto { updatedAt?: string; lastEditorID?: string; name?: string; - companyId?: number /* int */; + companyId?: string; } ////////// @@ -78,11 +96,11 @@ export interface ProjectDto { updatedAt: string; lastEditorID: string; name: string; - customerId: number /* int */; + customerId: string; } export interface ProjectCreateDto { name: string; - customerId: number /* int */; + customerId: string; } export interface ProjectUpdateDto { id: string; @@ -90,7 +108,7 @@ export interface ProjectUpdateDto { updatedAt?: string; lastEditorID?: string; name?: string; - customerId?: number /* int */; + customerId?: string; } ////////// @@ -101,18 +119,18 @@ export interface TimeEntryDto { createdAt: string; updatedAt: string; lastEditorID: string; - userId: number /* int */; - projectId: number /* int */; - activityId: number /* int */; + userId: string; + projectId: string; + activityId: string; start: string; end: string; description: string; billable: number /* int */; // Percentage (0-100) } export interface TimeEntryCreateDto { - userId: number /* int */; - projectId: number /* int */; - activityId: number /* int */; + userId: string; + projectId: string; + activityId: string; start: string; end: string; description: string; @@ -123,9 +141,9 @@ export interface TimeEntryUpdateDto { createdAt?: string; updatedAt?: string; lastEditorID?: string; - userId?: number /* int */; - projectId?: number /* int */; - activityId?: number /* int */; + userId?: string; + projectId?: string; + activityId?: string; start?: string; end?: string; description?: string; @@ -141,16 +159,15 @@ export interface UserDto { updatedAt: string; lastEditorID: string; email: string; - password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration. role: string; - companyId: number /* int */; + companyId: string; hourlyRate: number /* float64 */; } export interface UserCreateDto { email: string; - password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration. + password: string; role: string; - companyId: number /* int */; + companyId: string; hourlyRate: number /* float64 */; } export interface UserUpdateDto { @@ -159,8 +176,8 @@ export interface UserUpdateDto { updatedAt?: string; lastEditorID?: string; email?: string; - password?: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration. + password?: string; role?: string; - companyId?: number /* int */; + companyId?: string; hourlyRate?: number /* float64 */; }