* docs(ST-511): add backlog entry for entity codes feature Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ST-511): add createWithCodeRetry helper to handle P2002 race on auto codes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ST-511): retry on auto-code unique conflict in story and pbi create Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ST-511): surface field errors for code and title in PBI dialog Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ST-511): read create-state errors in Story dialog fieldError Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(ST-512): add backlog entry for REST API code/description/implementation_plan extensions; mark ST-511 done Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(ST-512): extend REST API with code, description and implementation_plan - GET /api/products returns code, description and definition_of_done - GET /api/products/:id/next-story returns story.code and per-task code + implementation_plan - GET /api/sprints/:id/tasks returns description, implementation_plan, story_code and derived per-task code - POST /api/todos accepts and returns optional description (max 2000) All changes are additive — existing clients ignore unknown keys. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(ST-512): mark ST-512 as done Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(ST-513): add backlog entry for API hardening for Claude Code Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(ST-513): add task and story status mappers for API boundary Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(ST-513): expose lowercase status on API and accept lowercase in PATCH /api/tasks Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(ST-513): add metadata JSONB column to StoryLog Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(ST-513): accept optional metadata in story log and switch validation errors to 422 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(ST-513): add GET /api/health endpoint with optional db ping Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(ST-513): add GET /api/products/:id/claude-context bundled endpoint Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(ST-513): add docs/API.md and link from CLAUDE.md specs table Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(ST-513): mark ST-513 as done Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ST-513): split 400 (malformed JSON) from 422 (validation), reject 'review' Codex review on PR #2: - P2.1: routes treated JSON parse failures as 422 instead of 400, breaking the contract in docs/API.md. Replace `request.json().catch(() => null)` with try/catch in 4 routes (tasks, reorder, todos, story-log) so a malformed body returns 400 and only well-formed-but-invalid bodies return 422. - P2.2: PATCH /api/tasks/:id accepted `status: "review"`, but the sprint task list UI does not render REVIEW (no label/color, the cycle helper falls back to TO_DO). Reject `review` at the API until the sprint UI is extended; document the subset in docs/API.md. Tests in __tests__/api updated for the new contract (29 assertions: zod-failures now expect 422, status payloads use lowercase API values, sprint-tasks mocks include the new story relation). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
245 lines
6.6 KiB
Text
245 lines
6.6 KiB
Text
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
generator erd {
|
|
provider = "prisma-erd-generator"
|
|
output = "../docs/erd.svg"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
enum Role {
|
|
PRODUCT_OWNER
|
|
SCRUM_MASTER
|
|
DEVELOPER
|
|
}
|
|
|
|
enum StoryStatus {
|
|
OPEN
|
|
IN_SPRINT
|
|
DONE
|
|
}
|
|
|
|
enum TaskStatus {
|
|
TO_DO
|
|
IN_PROGRESS
|
|
REVIEW
|
|
DONE
|
|
}
|
|
|
|
enum LogType {
|
|
IMPLEMENTATION_PLAN
|
|
TEST_RESULT
|
|
COMMIT
|
|
}
|
|
|
|
enum TestStatus {
|
|
PASSED
|
|
FAILED
|
|
}
|
|
|
|
enum SprintStatus {
|
|
ACTIVE
|
|
COMPLETED
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
email String? @unique
|
|
password_hash String
|
|
is_demo Boolean @default(false)
|
|
bio String? @db.VarChar(160)
|
|
bio_detail String? @db.VarChar(2000)
|
|
avatar_data Bytes?
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
roles UserRole[]
|
|
api_tokens ApiToken[]
|
|
products Product[]
|
|
todos Todo[]
|
|
product_members ProductMember[]
|
|
assigned_stories Story[] @relation("StoryAssignee")
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model UserRole {
|
|
id String @id @default(cuid())
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
user_id String
|
|
role Role
|
|
|
|
@@unique([user_id, role])
|
|
@@map("user_roles")
|
|
}
|
|
|
|
model ApiToken {
|
|
id String @id @default(cuid())
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
user_id String
|
|
token_hash String @unique
|
|
label String?
|
|
created_at DateTime @default(now())
|
|
revoked_at DateTime?
|
|
|
|
@@index([token_hash])
|
|
@@map("api_tokens")
|
|
}
|
|
|
|
model Product {
|
|
id String @id @default(cuid())
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
user_id String
|
|
name String
|
|
code String? @db.VarChar(30)
|
|
description String?
|
|
repo_url String?
|
|
definition_of_done String
|
|
archived Boolean @default(false)
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
pbis Pbi[]
|
|
sprints Sprint[]
|
|
stories Story[]
|
|
todos Todo[]
|
|
members ProductMember[]
|
|
|
|
@@unique([user_id, name])
|
|
@@unique([user_id, code])
|
|
@@index([user_id, archived])
|
|
@@map("products")
|
|
}
|
|
|
|
model Pbi {
|
|
id String @id @default(cuid())
|
|
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
|
product_id String
|
|
code String? @db.VarChar(30)
|
|
title String
|
|
description String?
|
|
priority Int
|
|
sort_order Float
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
stories Story[]
|
|
|
|
@@unique([product_id, code])
|
|
@@index([product_id, priority, sort_order])
|
|
@@map("pbis")
|
|
}
|
|
|
|
model Story {
|
|
id String @id @default(cuid())
|
|
pbi Pbi @relation(fields: [pbi_id], references: [id], onDelete: Cascade)
|
|
pbi_id String
|
|
product Product @relation(fields: [product_id], references: [id])
|
|
product_id String
|
|
sprint Sprint? @relation(fields: [sprint_id], references: [id])
|
|
sprint_id String?
|
|
assignee User? @relation("StoryAssignee", fields: [assignee_id], references: [id], onDelete: SetNull)
|
|
assignee_id String?
|
|
code String? @db.VarChar(30)
|
|
title String
|
|
description String?
|
|
acceptance_criteria String?
|
|
priority Int
|
|
sort_order Float
|
|
status StoryStatus @default(OPEN)
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
logs StoryLog[]
|
|
tasks Task[]
|
|
|
|
@@unique([product_id, code])
|
|
@@index([pbi_id, priority, sort_order])
|
|
@@index([sprint_id, sort_order])
|
|
@@index([product_id, status])
|
|
@@index([sprint_id, assignee_id])
|
|
@@map("stories")
|
|
}
|
|
|
|
model StoryLog {
|
|
id String @id @default(cuid())
|
|
story Story @relation(fields: [story_id], references: [id], onDelete: Cascade)
|
|
story_id String
|
|
type LogType
|
|
content String
|
|
status TestStatus?
|
|
commit_hash String?
|
|
commit_message String?
|
|
metadata Json?
|
|
created_at DateTime @default(now())
|
|
|
|
@@index([story_id, created_at])
|
|
@@map("story_logs")
|
|
}
|
|
|
|
model Sprint {
|
|
id String @id @default(cuid())
|
|
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
|
product_id String
|
|
sprint_goal String
|
|
status SprintStatus @default(ACTIVE)
|
|
created_at DateTime @default(now())
|
|
completed_at DateTime?
|
|
stories Story[]
|
|
tasks Task[]
|
|
|
|
@@index([product_id, status])
|
|
@@map("sprints")
|
|
}
|
|
|
|
model Task {
|
|
id String @id @default(cuid())
|
|
story Story @relation(fields: [story_id], references: [id], onDelete: Cascade)
|
|
story_id String
|
|
sprint Sprint? @relation(fields: [sprint_id], references: [id])
|
|
sprint_id String?
|
|
title String
|
|
description String?
|
|
implementation_plan String?
|
|
priority Int
|
|
sort_order Float
|
|
status TaskStatus @default(TO_DO)
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
@@index([story_id, priority, sort_order])
|
|
@@index([sprint_id, status])
|
|
@@map("tasks")
|
|
}
|
|
|
|
model ProductMember {
|
|
id String @id @default(cuid())
|
|
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
|
product_id String
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
user_id String
|
|
created_at DateTime @default(now())
|
|
|
|
@@unique([product_id, user_id])
|
|
@@index([user_id])
|
|
@@map("product_members")
|
|
}
|
|
|
|
model Todo {
|
|
id String @id @default(cuid())
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
user_id String
|
|
product Product? @relation(fields: [product_id], references: [id], onDelete: SetNull)
|
|
product_id String?
|
|
title String
|
|
description String? @db.VarChar(2000)
|
|
done Boolean @default(false)
|
|
archived Boolean @default(false)
|
|
created_at DateTime @default(now())
|
|
updated_at DateTime @updatedAt
|
|
|
|
@@index([user_id, done, archived])
|
|
@@index([user_id, product_id])
|
|
@@map("todos")
|
|
}
|