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>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { z } from "zod";
|
|
|
|
// Zod schemas for the claims module. All external input (request bodies, query
|
|
// params) is validated against these before it reaches the SQL layer — never trust
|
|
// raw JSON from a client.
|
|
|
|
// The lifecycle states a claim can be in. Kept in sync with the CHECK constraint
|
|
// in db/migrations/0004_claims.sql.
|
|
export const CLAIM_STATUSES = [
|
|
"draft",
|
|
"submitted",
|
|
"verifying",
|
|
"verified",
|
|
"flagged",
|
|
"archived",
|
|
] as const;
|
|
|
|
export type ClaimStatus = (typeof CLAIM_STATUSES)[number];
|
|
|
|
export const claimStatusSchema = z.enum(CLAIM_STATUSES);
|
|
|
|
// Body for POST /api/claims. project_id and cited_source_url are optional.
|
|
export const createClaimSchema = z.object({
|
|
text: z.string().trim().min(1, "Claim text is required.").max(5000),
|
|
project_id: z.string().uuid().nullable().optional(),
|
|
cited_source_url: z.string().url().max(2000).nullable().optional(),
|
|
status: claimStatusSchema.optional(),
|
|
});
|
|
|
|
export type CreateClaimInput = z.infer<typeof createClaimSchema>;
|
|
|
|
// Body for PATCH /api/claims/[id]. Every field optional; at least one required.
|
|
export const updateClaimSchema = z
|
|
.object({
|
|
text: z.string().trim().min(1).max(5000).optional(),
|
|
project_id: z.string().uuid().nullable().optional(),
|
|
cited_source_url: z.string().url().max(2000).nullable().optional(),
|
|
status: claimStatusSchema.optional(),
|
|
})
|
|
.refine((v) => Object.keys(v).length > 0, {
|
|
message: "At least one field must be provided.",
|
|
});
|
|
|
|
export type UpdateClaimInput = z.infer<typeof updateClaimSchema>;
|
|
|
|
// Validated list filters parsed from query params.
|
|
export const listClaimsFilterSchema = z.object({
|
|
project_id: z.string().uuid().optional(),
|
|
status: claimStatusSchema.optional(),
|
|
q: z.string().trim().min(1).max(200).optional(),
|
|
});
|
|
|
|
export type ListClaimsFilter = z.infer<typeof listClaimsFilterSchema>;
|