Files
FlockPal/backend/src/behaviorSchemas.ts
T
Corey Blais 3237cd7601
Deploy / deploy-prod (push) Skipped
Deploy / deploy-dev (push) Successful in 4m18s
Added behavior journal, adjusted layout, and added some colors
2026-10-05 15:20:00 -04:00

41 lines
1.3 KiB
TypeScript

import { z } from 'zod';
export const behaviorTypeSchema = z.object({
name: z.string().trim().min(1).max(120),
description: z.string().trim().max(2000).nullable().optional(),
});
export const behaviorOccurrenceSchema = z.object({
behaviorTypeId: z.string().uuid(),
occurredAt: z.string().datetime({ offset: true }),
durationSeconds: z.number().finite().positive().max(31536000).nullable().optional(),
severity: z.number().int().min(1).max(5).nullable().optional(),
notes: z.string().trim().max(10000).nullable().optional(),
});
export const behaviorRangeSchema = z.object({
from: z.string().datetime({ offset: true }),
to: z.string().datetime({ offset: true }),
behaviorTypeId: z.string().uuid().optional(),
}).refine(({ from, to }) => Date.parse(to) > Date.parse(from) && Date.parse(to) - Date.parse(from) <= 32 * 86400000, {
message: 'Choose a date range of up to 32 days, with to after from.',
});
export type BehaviorInput = z.infer<typeof behaviorOccurrenceSchema>;
export type BehaviorType = {
id: string;
name: string;
description: string | null;
createdAt: Date;
};
export type BehaviorOccurrence = {
id: string;
birdId: string;
behaviorTypeId: string;
behaviorName: string;
occurredAt: Date;
durationSeconds: number | null;
severity: number | null;
notes: string | null;
createdAt: Date;
updatedAt: Date;
};