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:
@@ -6,6 +6,9 @@
|
||||
import { z } from 'zod';
|
||||
import { isValidVIN } from '../../../shared-minimal/utils/validators';
|
||||
|
||||
// Cost interval enum for TCO recurring costs
|
||||
const costIntervalSchema = z.enum(['monthly', 'semi_annual', 'annual']);
|
||||
|
||||
export const createVehicleSchema = z.object({
|
||||
vin: z.string()
|
||||
.length(17, 'VIN must be exactly 17 characters')
|
||||
@@ -14,6 +17,14 @@ export const createVehicleSchema = z.object({
|
||||
color: z.string().min(1).max(50).optional(),
|
||||
licensePlate: z.string().min(1).max(20).optional(),
|
||||
odometerReading: z.number().min(0).max(9999999).optional(),
|
||||
// TCO fields
|
||||
purchasePrice: z.number().min(0).max(99999999.99).optional(),
|
||||
purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Date must be YYYY-MM-DD').optional(),
|
||||
insuranceCost: z.number().min(0).max(9999999.99).optional(),
|
||||
insuranceInterval: costIntervalSchema.optional(),
|
||||
registrationCost: z.number().min(0).max(9999999.99).optional(),
|
||||
registrationInterval: costIntervalSchema.optional(),
|
||||
tcoEnabled: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const updateVehicleSchema = z.object({
|
||||
@@ -30,6 +41,14 @@ export const updateVehicleSchema = z.object({
|
||||
color: z.string().min(1).max(50).optional(),
|
||||
licensePlate: z.string().min(1).max(20).optional(),
|
||||
odometerReading: z.number().min(0).max(9999999).optional(),
|
||||
// TCO fields
|
||||
purchasePrice: z.number().min(0).max(99999999.99).optional().nullable(),
|
||||
purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Date must be YYYY-MM-DD').optional().nullable(),
|
||||
insuranceCost: z.number().min(0).max(9999999.99).optional().nullable(),
|
||||
insuranceInterval: costIntervalSchema.optional().nullable(),
|
||||
registrationCost: z.number().min(0).max(9999999.99).optional().nullable(),
|
||||
registrationInterval: costIntervalSchema.optional().nullable(),
|
||||
tcoEnabled: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const vehicleIdSchema = z.object({
|
||||
|
||||
Reference in New Issue
Block a user