Build out the admin panel

- Overview: users, organizations, workspaces, spaces, pages, files and
  storage (org admins see their organization), plus pages open right now,
  the search index size, and version, uptime and database health.
- Users: invite people by email (with resend, revoke and a copyable link
  when mail fails) and send a password-reset email.
- Authentication: sign-up on or off, the email-domain allow-list, and
  sign-in links by email.
- Branding: instance name, accent colour and logo. The web app shows them
  on the sign-in pages and applies the accent colour everywhere.
- Email and Storage: SMTP and S3 settings with test buttons.
- Maintenance: create, download and delete database backups, and a view
  of the background jobs with their last run, duration and errors.

On the server, a small jobs registry records each search-indexing pass,
and "search.rebuild" replaces the separate reindex endpoint. A new
instance package serves the dashboard numbers, health and backups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-10-31 17:34:48 +01:00
1 parent 92cd81fd96
commit ffc6cc4fbc
31 files changed
+2326 -134

No files matched your search

+16 -1
View File
@@ -39,6 +39,10 @@ export type Attachment = Schemas["Attachment"];
export type SearchHit = Schemas["SearchHit"];
export type ShareLink = Schemas["ShareLink"];
export type Comment = Schemas["Comment"];
export type AdminStats = Schemas["AdminStats"];
export type AdminHealth = Schemas["AdminHealth"];
export type Job = Schemas["Job"];
export type Backup = Schemas["Backup"];
export type SharedPage = Schemas["SharedPage"];
export type SearchResult = Schemas["SearchResult"];
export type GroupRequest = Schemas["GroupRequest"];
@@ -200,7 +204,18 @@ export function createClient(opts: ClientOptions) {
update: (patch: InstanceSettingsUpdate) => request<InstanceSettings>("PATCH", "/api/v1/admin/settings", patch),
testEmail: (to: string) => post("/api/v1/admin/settings/test-email", { to }),
testStorage: () => post("/api/v1/admin/settings/test-storage"),
reindexSearch: () => post("/api/v1/admin/search/reindex"),
},
/** Instance administration (the admin panel). */
admin: {
stats: () => request<AdminStats>("GET", "/api/v1/admin/stats"),
health: () => request<AdminHealth>("GET", "/api/v1/admin/health"),
jobs: () => request<Job[]>("GET", "/api/v1/admin/jobs"),
runJob: (name: string) => post(`/api/v1/admin/jobs/${encodeURIComponent(name)}/run`),
backups: () => request<Backup[]>("GET", "/api/v1/admin/backups"),
createBackup: () => post("/api/v1/admin/backups"),
deleteBackup: (key: string) => request<void>("DELETE", `/api/v1/admin/backups/${encodeURIComponent(key)}`),
downloadBackup: (key: string) => download(`/api/v1/admin/backups/${encodeURIComponent(key)}`),
},
users: {
+338 -36
View File
@@ -1146,23 +1146,6 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/v1/admin/search/reindex": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/** Rebuild the search index from the database (superadmin) */
post: operations["reindexSearch"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/pages/{id}/export": {
parameters: {
query?: never;
@@ -1348,6 +1331,117 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/v1/admin/stats": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Dashboard numbers (superadmin - the instance; admin - their organization) */
get: operations["getAdminStats"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/admin/health": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Version, uptime and database health (superadmin) */
get: operations["getAdminHealth"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/admin/jobs": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Background jobs and how their last run went (superadmin) */
get: operations["listJobs"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/admin/jobs/{name}/run": {
parameters: {
query?: never;
header?: never;
path: {
name: string;
};
cookie?: never;
};
get?: never;
put?: never;
/** Start a runnable job now (superadmin) */
post: operations["runJob"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/admin/backups": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Database backups kept by docwell-db (superadmin) */
get: operations["listBackups"];
put?: never;
/**
* Write a new backup of the database and its files (superadmin)
* @description Answers when the archive is complete, which can take a while on large instances.
*/
post: operations["createBackup"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/admin/backups/{key}": {
parameters: {
query?: never;
header?: never;
path: {
key: string;
};
cookie?: never;
};
/** Download a backup archive (superadmin) */
get: operations["downloadBackup"];
put?: never;
post?: never;
/** Delete a backup archive (superadmin) */
delete: operations["deleteBackup"];
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
@@ -1761,6 +1855,60 @@ export interface components {
created: string;
canDelete: boolean;
};
AdminStats: {
/** @enum {string} */
scope: "instance" | "organization";
users: number;
organizations: number;
workspaces: number;
spaces: number;
/** @description Pages outside the trash */
pages: number;
attachments: number;
/** @description Total size of attachments */
storageBytes: number;
/** @description Pages open for editing now (instance scope only) */
rooms: number;
/** @description People connected to those pages (instance scope only) */
editors: number;
/** @description Pages in the search index (instance scope only) */
indexed: number;
};
AdminHealth: {
version: string;
goVersion: string;
/** Format: date-time */
started: string;
uptimeSeconds: number;
database: {
ok: boolean;
latencyMs: number;
error?: string;
};
goroutines: number;
memoryMb: number;
};
Job: {
name: string;
description: string;
/** @description How often it runs on its own (Go duration); empty when only on demand */
every: string;
/** @description Can be started by hand */
runnable: boolean;
running: boolean;
/** @description Runs since the server started */
runs: number;
failures: number;
/** @description RFC 3339; empty before the first run */
lastStarted: string;
lastDurationMs: number;
lastError: string;
};
Backup: {
key: string;
size: number;
modified: string;
};
};
responses: {
/** @description Signed in */
@@ -3837,25 +3985,6 @@ export interface operations {
404: components["responses"]["Error"];
};
};
reindexSearch: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Started */
202: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: components["responses"]["Error"];
};
};
exportPage: {
parameters: {
query?: {
@@ -4171,4 +4300,177 @@ export interface operations {
404: components["responses"]["Error"];
};
};
getAdminStats: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["AdminStats"];
};
};
403: components["responses"]["Error"];
};
};
getAdminHealth: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["AdminHealth"];
};
};
403: components["responses"]["Error"];
};
};
listJobs: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Job"][];
};
};
403: components["responses"]["Error"];
};
};
runJob: {
parameters: {
query?: never;
header?: never;
path: {
name: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Started */
202: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: components["responses"]["Error"];
404: components["responses"]["Error"];
409: components["responses"]["Error"];
};
};
listBackups: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Backup"][];
};
};
403: components["responses"]["Error"];
};
};
createBackup: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Created */
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
400: components["responses"]["Error"];
403: components["responses"]["Error"];
};
};
downloadBackup: {
parameters: {
query?: never;
header?: never;
path: {
key: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description The archive */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/zip": string;
};
};
403: components["responses"]["Error"];
404: components["responses"]["Error"];
};
};
deleteBackup: {
parameters: {
query?: never;
header?: never;
path: {
key: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Deleted */
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: components["responses"]["Error"];
404: components["responses"]["Error"];
};
};
}