Add instance settings and mail delivery through PocketBase

Superadmins can now change signup rules (on/off and the domain allow-list)
and branding at runtime; the environment variables only seed the defaults.
Mail and S3 storage settings pass through to PocketBase's own settings, and
docwell-server sends its own emails through a PocketBase hook so there is a
single SMTP configuration. The boot hook no longer wipes SMTP settings that
were not set from the environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-10-31 16:22:53 +01:00
1 parent ba394b8fac
commit e33a99241e
21 files changed
+1714 -25

No files matched your search

+11
View File
@@ -29,6 +29,9 @@ export type Page = Schemas["Page"];
export type TrashedPage = Schemas["TrashedPage"];
export type PageContent = Schemas["PageContent"];
export type PageVersion = Schemas["PageVersion"];
export type PublicSettings = Schemas["PublicSettings"];
export type InstanceSettings = Schemas["InstanceSettings"];
export type InstanceSettingsUpdate = Schemas["InstanceSettingsUpdate"];
export type CreateSpaceRequest = { name: string; description?: string; icon?: string; visibility?: SpaceVisibility };
export type UpdateSpaceRequest = Partial<Pick<Space, "name" | "description" | "icon" | "visibility" | "defaultRole">>;
@@ -116,6 +119,14 @@ export function createClient(opts: ClientOptions) {
confirmVerification: (token: string) => post("/api/v1/auth/verification/confirm", { token }),
},
settings: {
public: () => request<PublicSettings>("GET", "/api/v1/settings/public"),
get: () => request<InstanceSettings>("GET", "/api/v1/admin/settings"),
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"),
},
users: {
list: (params: { page?: number; perPage?: number; q?: string; organization?: string } = {}) =>
request<UserList>("GET", `/api/v1/users${query(params)}`),
+242
View File
@@ -657,6 +657,78 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/v1/settings/public": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Branding and signup availability, for signed-out pages */
get: operations["getPublicSettings"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/admin/settings": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Every instance setting (superadmin) */
get: operations["getInstanceSettings"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
/**
* Change the sections that are present (superadmin)
* @description Mail and storage settings are PocketBase's own. Passwords and secrets are write-only: leave them out to keep the stored value. Environment variables such as DOCWELL_SMTP_HOST are applied again when docwell-db starts.
*/
patch: operations["updateInstanceSettings"];
trace?: never;
};
"/api/v1/admin/settings/test-email": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/** Send a test email with the saved mail settings (superadmin) */
post: operations["sendTestEmail"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/admin/settings/test-storage": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/** Check that the configured S3 bucket is reachable (superadmin) */
post: operations["testStorage"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
@@ -869,6 +941,62 @@ export interface components {
name: string;
version: string;
};
PublicSettings: {
appName: string;
/** @description #rrggbb, or empty for the default */
accentColor: string;
/** @description A data URL */
logo: string;
/** @description Self-service signup is open */
signup: boolean;
};
SignupSettings: {
enabled: boolean;
/** @description Allowed email domains; empty allows all */
domains: string[];
};
BrandingSettings: {
appName: string;
accentColor: string;
/** @description data:image/(png|jpeg|webp|svg+xml);base64,..., at most 256 KB */
logo: string;
};
SmtpSettings: {
enabled: boolean;
host: string;
port: number;
username: string;
/** @description Leave out to keep the stored password */
password?: string;
readonly passwordSet: boolean;
tls: boolean;
senderName: string;
senderAddress: string;
};
StorageSettings: {
/** @description false stores files on docwell-db's disk */
s3: boolean;
bucket: string;
region: string;
endpoint: string;
accessKey: string;
/** @description Leave out to keep the stored secret */
secret?: string;
readonly secretSet: boolean;
forcePathStyle: boolean;
};
InstanceSettings: {
signup: components["schemas"]["SignupSettings"];
branding: components["schemas"]["BrandingSettings"];
smtp: components["schemas"]["SmtpSettings"];
storage: components["schemas"]["StorageSettings"];
};
InstanceSettingsUpdate: {
signup?: components["schemas"]["SignupSettings"];
branding?: components["schemas"]["BrandingSettings"];
smtp?: components["schemas"]["SmtpSettings"];
storage?: components["schemas"]["StorageSettings"];
};
};
responses: {
/** @description Signed in */
@@ -2145,4 +2273,118 @@ export interface operations {
404: components["responses"]["Error"];
};
};
getPublicSettings: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["PublicSettings"];
};
};
};
};
getInstanceSettings: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["InstanceSettings"];
};
};
403: components["responses"]["Error"];
};
};
updateInstanceSettings: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["InstanceSettingsUpdate"];
};
};
responses: {
/** @description Saved */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["InstanceSettings"];
};
};
400: components["responses"]["Error"];
403: components["responses"]["Error"];
};
};
sendTestEmail: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
/** Format: email */
to: string;
};
};
};
responses: {
/** @description Sent */
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
400: components["responses"]["Error"];
403: components["responses"]["Error"];
};
};
testStorage: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Reachable */
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
400: components["responses"]["Error"];
403: components["responses"]["Error"];
};
};
}