feat: add domain models and repositories for user, spool presets, and filaments

- Introduced SpoolPreset and User domain models with necessary DTOs and utility functions.
- Created AuthRepository, FilamentRepository, and SpoolPresetRepository interfaces for authentication and data management.
- Implemented UI components for filament display, including ColorSwatch, FilamentCard, and StockBar.
- Developed layout components such as Header and Screen for consistent app structure.
- Added reusable UI components like Badge, Button, Card, and Input for better user interaction.
- Established global constants and theme settings for consistent styling across the application.
- Implemented utility functions for filament calculations and formatting.
- Created Zustand stores for managing authentication, filament, and preset states.
- Configured TypeScript settings for improved development experience.
This commit is contained in:
2026-03-14 10:36:13 -03:00
parent abdc2fe8ce
commit d7fb768d3b
76 changed files with 19681 additions and 0 deletions
@@ -0,0 +1,80 @@
import type { AuthRepository } from '@ports/AuthRepository';
import type { AuthSession, LoginInput, RegisterInput, GoogleOAuthInput } from '@domain/User';
/**
* Caso de uso: Login com e-mail/senha.
*/
export class LoginUseCase {
constructor(private readonly authRepo: AuthRepository) {}
async execute(input: LoginInput): Promise<AuthSession> {
if (!input.email || !input.password) {
throw new Error('E-mail e senha são obrigatórios.');
}
return this.authRepo.login(input);
}
}
/**
* Caso de uso: Cadastro de novo usuário.
*/
export class RegisterUseCase {
constructor(private readonly authRepo: AuthRepository) {}
async execute(input: RegisterInput): Promise<AuthSession> {
if (!input.email || !input.password) {
throw new Error('E-mail e senha são obrigatórios.');
}
if (input.password.length < 8) {
throw new Error('A senha deve ter ao menos 8 caracteres.');
}
return this.authRepo.register(input);
}
}
/**
* Caso de uso: Login via OAuth Google.
*/
export class GoogleLoginUseCase {
constructor(private readonly authRepo: AuthRepository) {}
async execute(input: GoogleOAuthInput): Promise<AuthSession> {
return this.authRepo.loginWithGoogle(input);
}
}
/**
* Caso de uso: Logout.
*/
export class LogoutUseCase {
constructor(private readonly authRepo: AuthRepository) {}
async execute(accessToken: string): Promise<void> {
await this.authRepo.logout(accessToken);
}
}
/**
* Caso de uso: Solicitar redefinição de senha.
*/
export class ForgotPasswordUseCase {
constructor(private readonly authRepo: AuthRepository) {}
async execute(email: string): Promise<void> {
await this.authRepo.forgotPassword(email);
}
}
/**
* Caso de uso: Redefinir senha com token.
*/
export class ResetPasswordUseCase {
constructor(private readonly authRepo: AuthRepository) {}
async execute(token: string, newPassword: string): Promise<void> {
if (newPassword.length < 8) {
throw new Error('A nova senha deve ter ao menos 8 caracteres.');
}
await this.authRepo.resetPassword(token, newPassword);
}
}