Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 473868579b | |||
| 4a0dd5ed2a | |||
| bf064b3ada | |||
| 4df7d96020 |
@@ -118,17 +118,6 @@ jobs:
|
|||||||
cache-from: type=registry,ref=git.farh.net/groombook/cache:migrate
|
cache-from: type=registry,ref=git.farh.net/groombook/cache:migrate
|
||||||
cache-to: type=registry,ref=git.farh.net/groombook/cache:migrate,mode=max
|
cache-to: type=registry,ref=git.farh.net/groombook/cache:migrate,mode=max
|
||||||
|
|
||||||
- name: Smoke test migrate image (blackhole npmjs.org)
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
IMAGE="git.farh.net/groombook/migrate:${{ steps.version.outputs.tag }}"
|
|
||||||
docker pull "$IMAGE"
|
|
||||||
docker run --rm \
|
|
||||||
--add-host registry.npmjs.org:127.0.0.1 \
|
|
||||||
--entrypoint="" \
|
|
||||||
"$IMAGE" \
|
|
||||||
pnpm --version
|
|
||||||
|
|
||||||
- name: Build and push Seed image
|
- name: Build and push Seed image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
|
|||||||
+4
-9
@@ -1,7 +1,5 @@
|
|||||||
FROM node:22-alpine AS base
|
FROM node:22-alpine AS base
|
||||||
RUN corepack enable && corepack install -g pnpm@9.15.4
|
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||||
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
|
||||||
ENV COREPACK_ENABLE_STRICT=0
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install deps
|
# Install deps
|
||||||
@@ -13,6 +11,7 @@ RUN pnpm install --frozen-lockfile
|
|||||||
|
|
||||||
# Build
|
# Build
|
||||||
FROM deps AS builder
|
FROM deps AS builder
|
||||||
|
RUN mkdir -p /home/node/.cache/node/corepack
|
||||||
COPY packages/ packages/
|
COPY packages/ packages/
|
||||||
COPY src/ src/
|
COPY src/ src/
|
||||||
COPY tsconfig.json ./
|
COPY tsconfig.json ./
|
||||||
@@ -22,9 +21,7 @@ RUN pnpm --filter @groombook/types build && \
|
|||||||
|
|
||||||
# Runtime
|
# Runtime
|
||||||
FROM node:22-alpine AS runner
|
FROM node:22-alpine AS runner
|
||||||
RUN corepack enable && corepack install -g pnpm@9.15.4
|
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||||
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
|
||||||
ENV COREPACK_ENABLE_STRICT=0
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
@@ -53,7 +50,5 @@ CMD ["pnpm", "--filter", "@groombook/db", "seed"]
|
|||||||
|
|
||||||
# Reset stage — drops all tables, re-runs migrations, and re-seeds
|
# Reset stage — drops all tables, re-runs migrations, and re-seeds
|
||||||
FROM builder AS reset
|
FROM builder AS reset
|
||||||
RUN corepack enable && corepack install -g pnpm@9.15.4
|
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||||
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
|
||||||
ENV COREPACK_ENABLE_STRICT=0
|
|
||||||
CMD ["pnpm", "--filter", "@groombook/db", "reset"]
|
CMD ["pnpm", "--filter", "@groombook/db", "reset"]
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
-- Migration: 0035_add_short_to_coat_type_enum.sql
|
|
||||||
-- GRO-1953: Adds missing "short" value to the coat_type enum so that seed data
|
|
||||||
-- (which uses coatTypePool including "short") can be inserted without error.
|
|
||||||
--
|
|
||||||
-- The seed file defines coatTypePool as:
|
|
||||||
-- ["short", "medium", "long", "double", "wire", "silky", "curly", "hairless"]
|
|
||||||
-- but migration 0031 created the enum without "short", causing:
|
|
||||||
-- PostgresError: invalid input value for enum coat_type: "short"
|
|
||||||
|
|
||||||
BEGIN;
|
|
||||||
|
|
||||||
ALTER TYPE "coat_type" ADD VALUE IF NOT EXISTS 'short';
|
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
@@ -246,13 +246,6 @@
|
|||||||
"when": 1751140800000,
|
"when": 1751140800000,
|
||||||
"tag": "0034_extend_pet_profile_columns",
|
"tag": "0034_extend_pet_profile_columns",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
|
||||||
{
|
|
||||||
"idx": 35,
|
|
||||||
"version": "7",
|
|
||||||
"when": 1751140800000,
|
|
||||||
"tag": "0035_add_short_to_coat_type_enum",
|
|
||||||
"breakpoints": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -270,10 +270,6 @@ const medicalAlertPool: MedicalAlert[] = [
|
|||||||
{ id: "", type: "other", description: "Seizure history — avoid flashing lights", severity: "high" },
|
{ id: "", type: "other", description: "Seizure history — avoid flashing lights", severity: "high" },
|
||||||
{ id: "", type: "other", description: "Luxating patella — short walks only", severity: "medium" },
|
{ id: "", type: "other", description: "Luxating patella — short walks only", severity: "medium" },
|
||||||
{ id: "", type: "other", description: "Ear infections — dry thoroughly after bath", severity: "low" },
|
{ id: "", type: "other", description: "Ear infections — dry thoroughly after bath", severity: "low" },
|
||||||
{ id: "", type: "behavioral", description: "Anxiety — calm environment preferred", severity: "low" },
|
|
||||||
{ id: "", type: "behavioral", description: "Fear-based aggression — approach with caution", severity: "high" },
|
|
||||||
{ id: "", type: "skin", description: "Contact dermatitis — avoid harsh chemicals", severity: "medium" },
|
|
||||||
{ id: "", type: "skin", description: "Hot spots — monitor and report any worsening", severity: "high" },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const preferredCutPool: string[] = [
|
const preferredCutPool: string[] = [
|
||||||
@@ -1062,14 +1058,6 @@ async function seed() {
|
|||||||
temperamentScore: randInt(1, 5),
|
temperamentScore: randInt(1, 5),
|
||||||
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
temperamentFlags: pickN(temperamentFlagPool, randInt(1, 3)),
|
||||||
medicalAlerts: (() => {
|
medicalAlerts: (() => {
|
||||||
// Deterministic alerts for UAT AC pets
|
|
||||||
if (uc.petName === "TestCooper") {
|
|
||||||
return pickN(medicalAlertPool.filter((a) => a.type === "behavioral"), 1).map((a) => ({ ...a, id: uuid() }));
|
|
||||||
}
|
|
||||||
if (uc.petName === "TestRocky") {
|
|
||||||
return pickN(medicalAlertPool.filter((a) => a.type === "skin"), 1).map((a) => ({ ...a, id: uuid() }));
|
|
||||||
}
|
|
||||||
// Other UAT pets: random
|
|
||||||
if (rand() < 0.3) {
|
if (rand() < 0.3) {
|
||||||
const count = rand() < 0.7 ? 1 : 2;
|
const count = rand() < 0.7 ? 1 : 2;
|
||||||
return pickN(medicalAlertPool, count).map((a) => ({ ...a, id: uuid() }));
|
return pickN(medicalAlertPool, count).map((a) => ({ ...a, id: uuid() }));
|
||||||
|
|||||||
+1
-113
@@ -1,19 +1,7 @@
|
|||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import { z } from "zod/v3";
|
import { z } from "zod/v3";
|
||||||
import {
|
import { and, eq, exists, getDb, or, pets, appointments } from "@groombook/db";
|
||||||
and,
|
|
||||||
desc,
|
|
||||||
eq,
|
|
||||||
exists,
|
|
||||||
getDb,
|
|
||||||
or,
|
|
||||||
pets,
|
|
||||||
appointments,
|
|
||||||
staff,
|
|
||||||
services,
|
|
||||||
sql,
|
|
||||||
} from "@groombook/db";
|
|
||||||
import type { AppEnv } from "../middleware/rbac.js";
|
import type { AppEnv } from "../middleware/rbac.js";
|
||||||
import {
|
import {
|
||||||
getPresignedUploadUrl,
|
getPresignedUploadUrl,
|
||||||
@@ -109,106 +97,6 @@ petsRouter.get("/:id", async (c) => {
|
|||||||
return c.json(row);
|
return c.json(row);
|
||||||
});
|
});
|
||||||
|
|
||||||
petsRouter.get("/:id/profile-summary", async (c) => {
|
|
||||||
const db = getDb();
|
|
||||||
const petId = c.req.param("id");
|
|
||||||
const staffRow = c.get("staff");
|
|
||||||
const isGroomer = staffRow?.role === "groomer";
|
|
||||||
|
|
||||||
// Fetch the pet
|
|
||||||
const [pet] = await db.select().from(pets).where(eq(pets.id, petId));
|
|
||||||
if (!pet) return c.json({ error: "Not found" }, 404);
|
|
||||||
|
|
||||||
// Groomer RBAC: check appointment linkage to this pet's client
|
|
||||||
if (isGroomer) {
|
|
||||||
const [linkage] = await db
|
|
||||||
.select({ id: appointments.id })
|
|
||||||
.from(appointments)
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(appointments.clientId, pet.clientId),
|
|
||||||
or(
|
|
||||||
eq(appointments.staffId, staffRow.id),
|
|
||||||
eq(appointments.batherStaffId, staffRow.id)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.limit(1);
|
|
||||||
if (!linkage) return c.json({ error: "Forbidden" }, 403);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recent grooming history — last 10 completed appointments
|
|
||||||
const recentHistory = await db
|
|
||||||
.select({
|
|
||||||
id: appointments.id,
|
|
||||||
startTime: appointments.startTime,
|
|
||||||
notes: appointments.notes,
|
|
||||||
serviceName: services.name,
|
|
||||||
staffName: staff.name,
|
|
||||||
})
|
|
||||||
.from(appointments)
|
|
||||||
.innerJoin(services, eq(appointments.serviceId, services.id))
|
|
||||||
.leftJoin(staff, eq(appointments.staffId, staff.id))
|
|
||||||
.where(and(eq(appointments.petId, petId), eq(appointments.status, "completed")))
|
|
||||||
.orderBy(desc(appointments.startTime))
|
|
||||||
.limit(10);
|
|
||||||
|
|
||||||
// Visit count (completed appointments)
|
|
||||||
const [countRow] = await db
|
|
||||||
.select({ count: sql<number>`count(*)::int` })
|
|
||||||
.from(appointments)
|
|
||||||
.where(and(eq(appointments.petId, petId), eq(appointments.status, "completed")));
|
|
||||||
const visitCount = countRow?.count ?? 0;
|
|
||||||
|
|
||||||
// Upcoming appointment (next scheduled or confirmed)
|
|
||||||
const [upcoming] = await db
|
|
||||||
.select({
|
|
||||||
id: appointments.id,
|
|
||||||
startTime: appointments.startTime,
|
|
||||||
notes: appointments.notes,
|
|
||||||
confirmationStatus: appointments.confirmationStatus,
|
|
||||||
serviceName: services.name,
|
|
||||||
})
|
|
||||||
.from(appointments)
|
|
||||||
.innerJoin(services, eq(appointments.serviceId, services.id))
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(appointments.petId, petId),
|
|
||||||
or(eq(appointments.status, "scheduled"), eq(appointments.status, "confirmed"))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.orderBy(appointments.startTime)
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
return c.json({
|
|
||||||
id: pet.id,
|
|
||||||
name: pet.name,
|
|
||||||
species: pet.species,
|
|
||||||
breed: pet.breed,
|
|
||||||
coatType: pet.coatType,
|
|
||||||
petSizeCategory: pet.petSizeCategory,
|
|
||||||
weightKg: pet.weightKg,
|
|
||||||
dateOfBirth: pet.dateOfBirth,
|
|
||||||
recentGroomingHistory: recentHistory.map((h) => ({
|
|
||||||
id: h.id,
|
|
||||||
startTime: h.startTime,
|
|
||||||
notes: h.notes,
|
|
||||||
serviceName: h.serviceName,
|
|
||||||
staffName: h.staffName,
|
|
||||||
})),
|
|
||||||
visitCount,
|
|
||||||
upcomingAppointment: upcoming
|
|
||||||
? {
|
|
||||||
id: upcoming.id,
|
|
||||||
startTime: upcoming.startTime,
|
|
||||||
notes: upcoming.notes,
|
|
||||||
confirmationStatus: upcoming.confirmationStatus,
|
|
||||||
serviceName: upcoming.serviceName,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
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, ...rest } = c.req.valid("json");
|
||||||
|
|||||||
Reference in New Issue
Block a user