feat: add TCO types and repository updates (refs #15)

- Add CostInterval type and PAYMENTS_PER_YEAR constant
- Add 7 TCO fields to Vehicle, CreateVehicleRequest, UpdateVehicleRequest
- Update VehicleResponse and Body types
- Update mapRow() with snake_case to camelCase mapping
- Update create(), update(), batchInsert() for new fields
- Add Zod validation for TCO fields with interval enum

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Eric Gullickson
2026-01-12 19:58:59 -06:00
parent b0d79a26ae
commit 8517b1ded2
3 changed files with 140 additions and 9 deletions

View File

@@ -3,6 +3,15 @@
* @ai-context Core business types, no external dependencies
*/
// TCO cost interval types
export type CostInterval = 'monthly' | 'semi_annual' | 'annual';
export const PAYMENTS_PER_YEAR: Record<CostInterval, number> = {
monthly: 12,
semi_annual: 2,
annual: 1,
} as const;
export interface Vehicle {
id: string;
userId: string;
@@ -28,6 +37,14 @@ export interface Vehicle {
imageFileName?: string;
imageContentType?: string;
imageFileSize?: number;
// TCO fields
purchasePrice?: number;
purchaseDate?: string;
insuranceCost?: number;
insuranceInterval?: CostInterval;
registrationCost?: number;
registrationInterval?: CostInterval;
tcoEnabled?: boolean;
}
export interface CreateVehicleRequest {
@@ -44,6 +61,14 @@ export interface CreateVehicleRequest {
color?: string;
licensePlate?: string;
odometerReading?: number;
// TCO fields
purchasePrice?: number;
purchaseDate?: string;
insuranceCost?: number;
insuranceInterval?: CostInterval;
registrationCost?: number;
registrationInterval?: CostInterval;
tcoEnabled?: boolean;
}
export interface UpdateVehicleRequest {
@@ -60,6 +85,14 @@ export interface UpdateVehicleRequest {
color?: string;
licensePlate?: string;
odometerReading?: number;
// TCO fields
purchasePrice?: number;
purchaseDate?: string;
insuranceCost?: number;
insuranceInterval?: CostInterval;
registrationCost?: number;
registrationInterval?: CostInterval;
tcoEnabled?: boolean;
}
export interface VehicleResponse {
@@ -82,6 +115,14 @@ export interface VehicleResponse {
createdAt: string;
updatedAt: string;
imageUrl?: string;
// TCO fields
purchasePrice?: number;
purchaseDate?: string;
insuranceCost?: number;
insuranceInterval?: CostInterval;
registrationCost?: number;
registrationInterval?: CostInterval;
tcoEnabled?: boolean;
}
export interface VehicleImageMeta {
@@ -116,6 +157,14 @@ export interface CreateVehicleBody {
color?: string;
licensePlate?: string;
odometerReading?: number;
// TCO fields
purchasePrice?: number;
purchaseDate?: string;
insuranceCost?: number;
insuranceInterval?: CostInterval;
registrationCost?: number;
registrationInterval?: CostInterval;
tcoEnabled?: boolean;
}
export interface UpdateVehicleBody {
@@ -132,6 +181,14 @@ export interface UpdateVehicleBody {
color?: string;
licensePlate?: string;
odometerReading?: number;
// TCO fields
purchasePrice?: number;
purchaseDate?: string;
insuranceCost?: number;
insuranceInterval?: CostInterval;
registrationCost?: number;
registrationInterval?: CostInterval;
tcoEnabled?: boolean;
}
export interface VehicleParams {