caelum0x 695a365ae4 feat: PaperTrail — enterprise evidence-verification platform
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>
2026-07-08 07:21:22 +03:00

51 lines
2.0 KiB
TypeScript

import { z } from "zod";
// Zod schemas for the reporting & exports module. All external input (request
// bodies, query params) is validated against these before it reaches the SQL or
// document-generation layers — never trust raw JSON from a client.
// The data domains a report or export can target. Kept in sync with the CHECK
// constraints in db/migrations/0008_reports-exports.sql.
export const REPORT_TYPES = ["verifications", "claims", "evidence"] as const;
export type ReportType = (typeof REPORT_TYPES)[number];
export const reportTypeSchema = z.enum(REPORT_TYPES);
// Output formats an export can produce.
export const EXPORT_FORMATS = ["csv", "markdown"] as const;
export type ExportFormat = (typeof EXPORT_FORMATS)[number];
export const exportFormatSchema = z.enum(EXPORT_FORMATS);
// Terminal + transient states an export job can be in.
export const EXPORT_STATUSES = [
"pending",
"processing",
"complete",
"failed",
] as const;
export type ExportStatus = (typeof EXPORT_STATUSES)[number];
// Optional config persisted with a saved report. Mirrors the filters an export
// accepts so a report can be re-run into an export later. Kept permissive.
export const reportConfigSchema = z.object({
project_id: z.string().uuid().nullable().optional(),
format: exportFormatSchema.optional(),
});
export type ReportConfig = z.infer<typeof reportConfigSchema>;
// Body for POST /api/reports.
export const createReportSchema = z.object({
name: z.string().trim().min(1, "Report name is required.").max(200),
type: reportTypeSchema,
project_id: z.string().uuid().nullable().optional(),
config: reportConfigSchema.optional(),
});
export type CreateReportInput = z.infer<typeof createReportSchema>;
// Body for POST /api/exports. project_id narrows the exported rows to one project.
export const createExportSchema = z.object({
type: reportTypeSchema,
format: exportFormatSchema,
project_id: z.string().uuid().nullable().optional(),
});
export type CreateExportInput = z.infer<typeof createExportSchema>;