feat: add document-vehicle API endpoints and context-aware delete (refs #31)
Updates documents backend service and API to support multi-vehicle insurance documents: - Service: createDocument/updateDocument validate and handle sharedVehicleIds for insurance docs - Service: addVehicleToDocument validates ownership and adds vehicles to shared array - Service: removeVehicleFromDocument with context-aware delete logic: - Shared vehicle only: remove from array - Primary with no shared: soft delete document - Primary with shared: promote first shared to primary - Service: getDocumentsByVehicle returns all docs for a vehicle (primary or shared) - Controller: Added handlers for listByVehicle, addVehicle, removeVehicle with proper error handling - Routes: Added POST/DELETE /documents/:id/vehicles/:vehicleId and GET /documents/by-vehicle/:vehicleId - Validation: Added DocumentVehicleParamsSchema for vehicle management routes Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,10 @@ export const ListQuerySchema = z.object({
|
||||
|
||||
export const IdParamsSchema = z.object({ id: z.string().uuid() });
|
||||
export const VehicleParamsSchema = z.object({ vehicleId: z.string().uuid() });
|
||||
export const DocumentVehicleParamsSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
vehicleId: z.string().uuid()
|
||||
});
|
||||
|
||||
export const CreateBodySchema = CreateDocumentBodySchema;
|
||||
export const UpdateBodySchema = UpdateDocumentBodySchema;
|
||||
@@ -16,6 +20,7 @@ export const UpdateBodySchema = UpdateDocumentBodySchema;
|
||||
export type ListQuery = z.infer<typeof ListQuerySchema>;
|
||||
export type IdParams = z.infer<typeof IdParamsSchema>;
|
||||
export type VehicleParams = z.infer<typeof VehicleParamsSchema>;
|
||||
export type DocumentVehicleParams = z.infer<typeof DocumentVehicleParamsSchema>;
|
||||
export type CreateBody = z.infer<typeof CreateBodySchema>;
|
||||
export type UpdateBody = z.infer<typeof UpdateBodySchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user