62 lines
4.1 KiB
TypeScript
62 lines
4.1 KiB
TypeScript
import { z } from 'zod';
|
|
import { birdGenderSchema, workspaceRoleSchema } from '../schemas.js';
|
|
|
|
const id = z.string().uuid();
|
|
const text = z.string().nullable();
|
|
const date = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
const timestamp = z.string().datetime({ offset: true });
|
|
export const locationResponse = z.object({
|
|
label: text, city: text, region: text, country: text, countryCode: text,
|
|
latitude: z.number().nullable(), longitude: z.number().nullable(),
|
|
precision: z.enum(['city', 'region', 'country']).nullable(), verifiedAt: timestamp, provider: z.literal('mapbox').nullable(), providerPlaceId: text,
|
|
});
|
|
export const workspaceResponse = z.object({
|
|
id: z.number().int(), name: z.string(), workspaceType: z.enum(['standard', 'rescue']), billingEmail: text,
|
|
billingPlan: z.enum(['rescue_free', 'household_basic', 'household_plus', 'household_macaw', 'household_hyacinth_macaw']),
|
|
billingInterval: z.enum(['monthly', 'yearly']),
|
|
subscriptionStatus: z.enum(['active', 'trialing', 'past_due', 'canceled', 'unpaid', 'none']),
|
|
stripeCustomerId: text, stripeSubscriptionId: text,
|
|
rescueVerificationStatus: z.enum(['not_required', 'pending', 'approved', 'rejected']),
|
|
createdAt: timestamp, updatedAt: timestamp,
|
|
});
|
|
export const memberResponse = z.object({
|
|
id, workspaceId: z.number().int(), userId: id.nullable(), inviteEmail: z.string(), name: z.string(),
|
|
role: workspaceRoleSchema, acceptedAt: timestamp.nullable(), createdAt: timestamp,
|
|
});
|
|
export const birdResponse = z.object({
|
|
id, workspaceId: z.number().int(), name: z.string(), tagId: text, species: z.string(),
|
|
motivators: text, demotivators: text, favoriteSnack: text, locationLabel: text,
|
|
locationDetails: locationResponse.nullable(), vetClinicName: text, vetClinicAddress: text,
|
|
vetAccountNumber: text, vetDoctorName: text, gender: birdGenderSchema,
|
|
hatchDay: date.nullable(), dateOfBirth: date.nullable(), gotchaDay: date.nullable(), chartColor: z.string(),
|
|
photoDataUrl: text.describe('Photo URL or legacy data URL. Storage-backed URLs expire; refresh the bird list to obtain a new URL.'),
|
|
photoObjectKey: text, photoContentType: text, photoUpdatedAt: timestamp.nullable(),
|
|
notifyOnDob: z.boolean(), notifyOnGotchaDay: z.boolean(), publicProfileCode: text, publicProfileEnabled: z.boolean(),
|
|
memorializedAt: timestamp.nullable(), memorializedOn: date.nullable(),
|
|
notifyOnMemorialDay: z.boolean(), createdAt: timestamp,
|
|
latestWeightGrams: z.number().nullable(), latestRecordedOn: date.nullable(),
|
|
});
|
|
export const weightResponse = z.object({ id, birdId: id, weightGrams: z.number(), recordedOn: date, notes: text });
|
|
export const vetVisitResponse = z.object({ id, birdId: id, visitedOn: date, clinicName: z.string(), reason: z.string(), notes: text });
|
|
export const medicationResponse = z.object({
|
|
id, birdId: id, name: z.string(), dosage: z.string(),
|
|
frequency: z.enum(['once_daily', 'twice_daily', 'every_8_hours', 'every_6_hours', 'as_needed']),
|
|
doseSchedule: z.array(z.object({ key: z.string(), label: z.string(), time: z.string() })),
|
|
route: text, startDate: date, endDate: date.nullable(), notes: text, remindersEnabled: z.boolean(),
|
|
});
|
|
export const administrationResponse = z.object({
|
|
id, medicationId: id, birdId: id, administeredOn: date, administrationSlot: z.string(),
|
|
status: z.enum(['administered', 'missed']), notes: text, createdByUserId: id.nullable(), createdAt: timestamp,
|
|
});
|
|
export const noteResponse = z.object({
|
|
id, workspaceId: z.number().int(), birdId: id.nullable(), birdName: text, title: z.string(), body: z.string(),
|
|
createdByUserId: id.nullable(), createdByName: text, createdAt: timestamp, updatedAt: timestamp,
|
|
});
|
|
export const timelineResponse = z.object({
|
|
id, birdId: id, eventType: z.enum(['profile_created', 'transferred', 'location_updated', 'owner_changed', 'manual_note', 'removed_from_flock', 'joined_flock']),
|
|
fromWorkspaceId: z.number().int().nullable(), toWorkspaceId: z.number().int().nullable(),
|
|
fromWorkspaceName: text, toWorkspaceName: text, fromOwnerEmail: text, toOwnerEmail: text,
|
|
locationLabel: text, locationDetails: locationResponse.nullable(), note: text, eventDate: date,
|
|
createdByUserId: id.nullable(), createdAt: timestamp,
|
|
});
|