Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4bbb0c9fc5 | |||
| 03f79a3701 | |||
| 2b92c2ab6c | |||
| e9ad92de01 | |||
| bfe1a29c08 | |||
| 1ad43ce701 | |||
| 96dbb8c41d | |||
| 636fa713e1 | |||
| 6120b96c7c | |||
| eb92f99c4a | |||
| 587fd4ec95 | |||
| 6e2e46daf8 | |||
| 8cf72d926d | |||
| 8721f0b63c | |||
| 027e012a58 | |||
| b3db206588 | |||
| fc072d51f4 | |||
| 6538406db2 | |||
| e2eacbc9fe | |||
| e639cc82d1 | |||
| f2931d7be2 | |||
| d4a4ddce37 | |||
| bd384bdf5c | |||
| c92fb2539d | |||
| 411c42b2c4 | |||
| bf97849324 | |||
| 2a6242d3de | |||
| 7181d41b24 | |||
| 4e9c4c5e08 | |||
| 16c959434b | |||
| 23484dc90a | |||
| 766728865e | |||
| 6a81a52a50 | |||
| 5a4b9a98bd | |||
| f7f88156e1 | |||
| 8af5a49d14 | |||
| 403634eb96 | |||
| 152abfc4d5 | |||
| c8bbb12edb | |||
| ba95088653 | |||
| dd83f29736 | |||
| 185fce8e17 | |||
| 081379c189 | |||
| e01c12a316 |
+26
-2
@@ -57,6 +57,23 @@ const createPetSchema = z.object({
|
|||||||
customFields: z.record(z.string(), z.string()).optional(),
|
customFields: z.record(z.string(), z.string()).optional(),
|
||||||
petSizeCategory: z.enum(["small", "medium", "large", "extra_large"]).optional(),
|
petSizeCategory: z.enum(["small", "medium", "large", "extra_large"]).optional(),
|
||||||
coatType: z.enum(["short", "medium", "long", "double", "wire", "silky", "curly", "hairless"]).optional(),
|
coatType: z.enum(["short", "medium", "long", "double", "wire", "silky", "curly", "hairless"]).optional(),
|
||||||
|
// Extended pet profile fields (api/#39, GRO-1178).
|
||||||
|
// GRO-2172: these were missing from the schema, causing POST/PATCH to
|
||||||
|
// silently drop them even though migrations 0034/0036 and seed data
|
||||||
|
// populate them. GRO-1472 was the original UAT regression.
|
||||||
|
temperamentScore: z.number().int().min(1).max(5).optional(),
|
||||||
|
temperamentFlags: z.array(z.string().max(100)).max(20).optional(),
|
||||||
|
medicalAlerts: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
type: z.string().max(100),
|
||||||
|
description: z.string().max(1000),
|
||||||
|
severity: z.enum(["low", "medium", "high"]),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.max(50)
|
||||||
|
.optional(),
|
||||||
|
preferredCuts: z.array(z.string().max(200)).max(20).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatePetSchema = createPetSchema.partial().omit({ clientId: true });
|
const updatePetSchema = createPetSchema.partial().omit({ clientId: true });
|
||||||
@@ -333,7 +350,8 @@ petsRouter.get("/:id/profile-summary", async (c) => {
|
|||||||
|
|
||||||
petsRouter.post("/", zValidator("json", createPetSchema), async (c) => {
|
petsRouter.post("/", zValidator("json", createPetSchema), async (c) => {
|
||||||
const db = getDb();
|
const db = getDb();
|
||||||
const { weightKg, dateOfBirth, customFields, ...rest } = c.req.valid("json");
|
const { weightKg, dateOfBirth, customFields, medicalAlerts, ...rest } =
|
||||||
|
c.req.valid("json");
|
||||||
const [row] = await db
|
const [row] = await db
|
||||||
.insert(pets)
|
.insert(pets)
|
||||||
.values({
|
.values({
|
||||||
@@ -341,6 +359,10 @@ petsRouter.post("/", zValidator("json", createPetSchema), async (c) => {
|
|||||||
weightKg: weightKg?.toString(),
|
weightKg: weightKg?.toString(),
|
||||||
dateOfBirth: dateOfBirth ? new Date(dateOfBirth) : undefined,
|
dateOfBirth: dateOfBirth ? new Date(dateOfBirth) : undefined,
|
||||||
customFields: customFields ?? {},
|
customFields: customFields ?? {},
|
||||||
|
// GRO-2172: medicalAlerts shape from the API request is
|
||||||
|
// { type, description, severity } — the @groombook/types MedicalAlert
|
||||||
|
// has an optional server-generated `id`, so cast for the jsonb column.
|
||||||
|
medicalAlerts: medicalAlerts as never,
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
return c.json(row, 201);
|
return c.json(row, 201);
|
||||||
@@ -351,7 +373,8 @@ petsRouter.patch(
|
|||||||
zValidator("json", updatePetSchema),
|
zValidator("json", updatePetSchema),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const db = getDb();
|
const db = getDb();
|
||||||
const { weightKg, dateOfBirth, customFields, ...rest } = c.req.valid("json");
|
const { weightKg, dateOfBirth, customFields, medicalAlerts, ...rest } =
|
||||||
|
c.req.valid("json");
|
||||||
const [row] = await db
|
const [row] = await db
|
||||||
.update(pets)
|
.update(pets)
|
||||||
.set({
|
.set({
|
||||||
@@ -359,6 +382,7 @@ petsRouter.patch(
|
|||||||
weightKg: weightKg?.toString(),
|
weightKg: weightKg?.toString(),
|
||||||
dateOfBirth: dateOfBirth ? new Date(dateOfBirth) : undefined,
|
dateOfBirth: dateOfBirth ? new Date(dateOfBirth) : undefined,
|
||||||
...(customFields !== undefined ? { customFields } : {}),
|
...(customFields !== undefined ? { customFields } : {}),
|
||||||
|
medicalAlerts: medicalAlerts as never,
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
})
|
})
|
||||||
.where(eq(pets.id, c.req.param("id")))
|
.where(eq(pets.id, c.req.param("id")))
|
||||||
|
|||||||
Reference in New Issue
Block a user