Multi-tenant platform (182 pages, 228 API routes, ~30 modules) built on a deterministic verification core: clinical-trial claims checked against ClinicalTrials.gov registered results and raw event counts (ARR/NNT/RR+CI recomputed in code, oracle-tested), code-enforced exact-span grounding, and multi-source cross-verification. Auth/RBAC/multi-tenancy, document processing at scale (unpdf + Docling), agentic workflows, Claude Science connector, compliance/audit, billing, public API, and more. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import { z } from "zod";
|
|
|
|
// Boundary validation for the review-workflow APIs. Never trust request bodies
|
|
// or query strings — parse them through these schemas before use.
|
|
|
|
export const REVIEW_STATUSES = [
|
|
"pending",
|
|
"in_review",
|
|
"approved",
|
|
"rejected",
|
|
"cancelled",
|
|
] as const;
|
|
|
|
export const REVIEW_DECISIONS = ["approved", "rejected"] as const;
|
|
|
|
// Body for POST /api/reviews — create/assign a review. At least one of
|
|
// projectId / claimId should identify what is being reviewed.
|
|
export const createReviewSchema = z
|
|
.object({
|
|
projectId: z.string().uuid().nullish(),
|
|
claimId: z.string().uuid().nullish(),
|
|
assigneeId: z.string().uuid().nullish(),
|
|
comment: z.string().max(5000).nullish(),
|
|
dueDate: z.string().datetime().nullish(),
|
|
})
|
|
.refine((v) => Boolean(v.projectId) || Boolean(v.claimId), {
|
|
message: "A review must reference a projectId or claimId.",
|
|
});
|
|
|
|
export type CreateReviewInput = z.infer<typeof createReviewSchema>;
|
|
|
|
// Body for PATCH /api/reviews/[id] — reassign / edit metadata (not decisions).
|
|
export const updateReviewSchema = z
|
|
.object({
|
|
assigneeId: z.string().uuid().nullish(),
|
|
status: z.enum(["pending", "in_review", "cancelled"]).optional(),
|
|
comment: z.string().max(5000).nullish(),
|
|
dueDate: z.string().datetime().nullish(),
|
|
})
|
|
.refine((v) => Object.values(v).some((x) => x !== undefined), {
|
|
message: "No fields to update.",
|
|
});
|
|
|
|
export type UpdateReviewInput = z.infer<typeof updateReviewSchema>;
|
|
|
|
// Body for POST /api/reviews/[id]/decision — approve/reject with comment.
|
|
export const decisionSchema = z.object({
|
|
decision: z.enum(REVIEW_DECISIONS),
|
|
comment: z.string().max(5000).nullish(),
|
|
});
|
|
|
|
export type DecisionInput = z.infer<typeof decisionSchema>;
|
|
|
|
// Query filters for GET /api/reviews.
|
|
export const queueQuerySchema = z.object({
|
|
scope: z.enum(["mine", "all"]).default("all"),
|
|
status: z.enum(REVIEW_STATUSES).optional(),
|
|
});
|
|
|
|
export type QueueQueryInput = z.infer<typeof queueQuerySchema>;
|