diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index e2461b5..b08c640 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -91,6 +91,7 @@ jobs: - name: Build and push API image uses: docker/build-push-action@v6 with: + provenance: false context: . file: Dockerfile target: runner @@ -105,6 +106,7 @@ jobs: - name: Build and push Migrate image uses: docker/build-push-action@v6 with: + provenance: false context: . file: Dockerfile target: migrate @@ -119,6 +121,7 @@ jobs: - name: Build and push Seed image uses: docker/build-push-action@v6 with: + provenance: false context: . file: Dockerfile target: seed @@ -133,6 +136,7 @@ jobs: - name: Build and push Reset image uses: docker/build-push-action@v6 with: + provenance: false context: . file: Dockerfile target: reset diff --git a/apps/api/src/routes/admin/seed.ts b/apps/api/src/routes/admin/seed.ts index a5ac911..0f3dbe2 100644 --- a/apps/api/src/routes/admin/seed.ts +++ b/apps/api/src/routes/admin/seed.ts @@ -40,12 +40,13 @@ const UAT_CLIENT = { name: "UAT Customer", email: "uat-customer@groombook.dev", phone: "555-0100", + address: "1 UAT Lane, Test City, CA 90210", status: "active" as const, }; const UAT_PETS = [ - { name: "Bella", species: "Dog", breed: "Poodle", coatType: "curly" as const }, - { name: "Max", species: "Dog", breed: "Labrador Retriever", coatType: "short" as const }, + { name: "Bella", species: "Dog", breed: "Poodle", coatType: "curly" as const, weightKg: "20.00" }, + { name: "Max", species: "Dog", breed: "Labrador Retriever", coatType: "short" as const, weightKg: "30.00" }, ]; const DEMO_SERVICES = [ @@ -55,7 +56,7 @@ const DEMO_SERVICES = [ { id: "b0000001-0000-0000-0000-000000000004", name: "Nail Trim", description: "Nail clipping and filing", basePriceCents: 1500, durationMinutes: 15 }, ]; -adminSeedRouter.post("/seed", async (c) => { +adminSeedRouter.post("/", async (c) => { // Refuse to run when AUTH_DISABLED — dev environments use direct-DB seeding if (process.env.AUTH_DISABLED === "true") { return c.json( @@ -156,7 +157,7 @@ adminSeedRouter.post("/seed", async (c) => { results.push(`Created client '${UAT_CLIENT.name}' (id: ${uatClientId})`); } - // ── Pets: UAT Customer Pets ─────────────────────────────────────────────── + // ── Pets: UAT Customer's Pets ───────────────────────────────────────────── const existingUatPets = await db .select() .from(pets) @@ -177,6 +178,8 @@ adminSeedRouter.post("/seed", async (c) => { species: uatPet.species, breed: uatPet.breed, coatType: uatPet.coatType, + weightKg: uatPet.weightKg, + dateOfBirth: new Date("2019-01-01T00:00:00Z"), }) .returning(); results.push(`Created pet '${uatPet.name}' for UAT Customer (id: ${created!.id})`); @@ -191,4 +194,4 @@ adminSeedRouter.post("/seed", async (c) => { staffOidcSub: KNOWN_STAFF.oidcSub, }, }); -}); +}); \ No newline at end of file diff --git a/src/routes/admin/seed.ts b/src/routes/admin/seed.ts index efd461e..114461f 100644 --- a/src/routes/admin/seed.ts +++ b/src/routes/admin/seed.ts @@ -36,6 +36,19 @@ const DEMO_PET = { weightKg: "30.00", }; +const UAT_CLIENT = { + name: "UAT Customer", + email: "uat-customer@groombook.dev", + phone: "555-0100", + address: "1 UAT Lane, Test City, CA 90210", + status: "active" as const, +}; + +const UAT_PETS = [ + { name: "Bella", species: "Dog", breed: "Poodle", coatType: "curly", weightKg: "20.00" }, + { name: "Max", species: "Dog", breed: "Labrador Retriever", coatType: "short", weightKg: "30.00" }, +]; + const DEMO_SERVICES = [ { id: "b0000001-0000-0000-0000-000000000001", name: "Bath & Brush", description: "Full bath, blow-dry, brush out, and ear cleaning", basePriceCents: 4500, durationMinutes: 45 }, { id: "b0000001-0000-0000-0000-000000000002", name: "Full Groom — Small", description: "Complete grooming for dogs under 25 lbs", basePriceCents: 6500, durationMinutes: 60 }, @@ -43,7 +56,7 @@ const DEMO_SERVICES = [ { id: "b0000001-0000-0000-0000-000000000004", name: "Nail Trim", description: "Nail clipping and filing", basePriceCents: 1500, durationMinutes: 15 }, ]; -adminSeedRouter.post("/seed", async (c) => { +adminSeedRouter.post("/", async (c) => { // Refuse to run when AUTH_DISABLED — dev environments use direct-DB seeding if (process.env.AUTH_DISABLED === "true") { return c.json( @@ -128,6 +141,51 @@ adminSeedRouter.post("/seed", async (c) => { results.push(`Created pet '${DEMO_PET.name}' for Demo Client (id: ${created!.id})`); } + // ── Client: UAT Customer ────────────────────────────────────────────────── + const [existingUatClient] = await db + .select() + .from(clients) + .where(eq(clients.email, UAT_CLIENT.email)); + + let uatClientId: string; + if (existingUatClient) { + uatClientId = existingUatClient.id; + results.push(`Client '${UAT_CLIENT.name}' already exists (id: ${uatClientId})`); + } else { + const [created] = await db.insert(clients).values(UAT_CLIENT).returning(); + uatClientId = created!.id; + results.push(`Created client '${UAT_CLIENT.name}' (id: ${uatClientId})`); + } + + // ── Pets: UAT Customer's Pets ───────────────────────────────────────────── + const existingUatPets = await db + .select() + .from(pets) + .where(eq(pets.clientId, uatClientId)); + + for (const uatPet of UAT_PETS) { + const existing = existingUatPets.find( + (p) => p.name === uatPet.name && p.species === uatPet.species + ); + if (existing) { + results.push(`Pet '${uatPet.name}' already exists for UAT Customer (id: ${existing.id})`); + } else { + const [created] = await db + .insert(pets) + .values({ + clientId: uatClientId, + name: uatPet.name, + species: uatPet.species, + breed: uatPet.breed, + coatType: uatPet.coatType as any, + weightKg: uatPet.weightKg, + dateOfBirth: new Date("2019-01-01T00:00:00Z"), + }) + .returning(); + results.push(`Created pet '${uatPet.name}' for UAT Customer (id: ${created!.id})`); + } + } + return c.json({ message: "Seed complete", details: results,