import { z } from 'zod'; import { signupInputSchema } from './auth'; /** * First-run setup wizard (issue #80, deployment.md §Configuration): a fresh * instance exposes only `/setup/*` until the wizard completes; completing it * locks the wizard permanently (steps answer 410 afterwards). */ /** Step 1 — the Site Admin account; same field rules as regular signup. */ export const setupAdminInputSchema = signupInputSchema; export type SetupAdminInput = z.infer; /** Step 2 — instance identity. Mirrors the instance_settings validations. */ export const setupInstanceInputSchema = z.object({ name: z.string().trim().min(1, 'validation.required').max(60), defaultLocale: z.enum(['de', 'en']), }); export type SetupInstanceInput = z.infer; /** * Step 3 — SMTP relay. Optional: skipping it is allowed, the instance then * sends no mail (signup verification, password reset) until configured. * Saving runs a live delivery test first; failures block the step. */ export const setupSmtpInputSchema = z.object({ host: z.string().trim().min(1, 'validation.required').max(255), // The wizard form feeds this through valueAsNumber — an empty input // arrives as NaN, so the type error doubles as the "required" message. port: z.number({ invalid_type_error: 'validation.required' }).int().min(1).max(65535), secure: z.boolean(), user: z.string().max(255).optional(), pass: z.string().max(1024).optional(), from: z.string().trim().min(3, 'validation.required').max(255), }); export type SetupSmtpInput = z.infer; /** Step 4 — who may self-register (ADR 0007). */ export const setupRegistrationInputSchema = z.object({ mode: z.enum(['open', 'closed']), }); export type SetupRegistrationInput = z.infer; /** What `GET /setup` reports; the wizard UI (#81) renders its steps from this. */ export interface SetupStatusView { status: 'required' | 'completed'; adminCreated: boolean; smtpConfigured: boolean; }