Documentation Index
Fetch the complete documentation index at: https://docs-terra.withunify.org/llms.txt
Use this file to discover all available pages before exploring further.
Server Actions
Terra uses Next.js Server Actions for all data mutations.
Action Files
| File | Purpose |
|---|
airtable.ts | Airtable OAuth and sync |
notifications.ts | Email/SMS sending |
insights.ts | Analytics queries |
applicants.ts | Applicant management |
status.ts | Submission status |
domains.ts | Custom domain config |
workspaces.ts | Folder management |
agencies.ts | Agency management |
form-versions.ts | Draft/publish |
webhooks.ts | Webhook config |
team.ts | Permissions |
settings.ts | Org settings |
Common Patterns
Permission Check
"use server";
export async function updateSubmission(id: string, data: Data) {
const user = await requireAdmin(); // Throws if unauthorized
await supabaseAdmin
.from("form_submissions")
.update(data)
.eq("id", id);
await logAudit(user.id, "submission.updated", { id });
return { success: true };
}
ActionResult Pattern
type ActionResult<T> =
| { success: true; data: T }
| { success: false; error: string };
export async function createForm(data: FormData): Promise<ActionResult<Form>> {
try {
const user = await requireAdmin();
const form = await insertForm(data);
return { success: true, data: form };
} catch (error) {
return { success: false, error: error.message };
}
}
Revalidation
import { revalidatePath } from "next/cache";
export async function publishForm(id: string) {
await updateFormStatus(id, "published");
revalidatePath(`/forms/${id}`);
revalidatePath("/forms");
}
Database Schema
Table reference
Authorization
Permission checks