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

75 lines
1.8 KiB
TypeScript

// Shared types for the billing module (plans, subscriptions, usage, invoices).
// These are the JSON shapes returned by the module's /api/billing routes and
// consumed by its console pages. Subscription/usage/invoice data is org-scoped;
// plans are a global catalog.
// A quota limit map: quota kind -> monthly cap. -1 (or a missing kind) means
// unlimited.
export type PlanLimits = Record<string, number>;
// A plan in the global catalog.
export interface Plan {
id: string;
key: string;
name: string;
limits: PlanLimits;
priceCents: number;
}
export type SubscriptionStatus =
| "active"
| "trialing"
| "past_due"
| "canceled";
// An org's current subscription, joined with its plan for display.
export interface Subscription {
id: string;
planId: string;
planKey: string;
planName: string;
priceCents: number;
status: SubscriptionStatus;
seats: number;
currentPeriodEnd: string | null;
createdAt: string;
}
// A single quota meter: how much of a kind's cap has been consumed this period.
export interface UsageMeter {
kind: string;
used: number;
// Plan cap for this kind. null means unlimited.
limit: number | null;
// Fraction 0..1 of the cap used (0 when unlimited).
ratio: number;
}
// The full usage snapshot for the current org's active period.
export interface UsageSummary {
periodStart: string;
periodEnd: string | null;
meters: UsageMeter[];
}
// The result of a pre-spend quota check.
export interface QuotaDecision {
kind: string;
allowed: boolean;
used: number;
// Plan cap for this kind. null means unlimited.
limit: number | null;
remaining: number | null;
}
export type InvoiceStatus = "open" | "paid" | "void" | "uncollectible";
export interface Invoice {
id: string;
amountCents: number;
status: InvoiceStatus;
periodStart: string;
periodEnd: string;
createdAt: string;
}