fix(build): inline db config schema for BSB schema extractor

BSB bsb-plugin-cli build extracts schemas statically and cannot
resolve cross-file imports. Inlined the anyvali db config schema
in each plugin's ConfigSchema. Shared DbConfig type stays in
shared/db/config.ts (type-only imports work fine).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mitchell R 2026-05-24 03:22:49 +02:00
parent 9e7542a424
commit 664e6e1548
No known key found for this signature in database
3 changed files with 45 additions and 6 deletions

View file

@ -15,7 +15,7 @@ import {
import { H3, serve } from "h3";
import type { Server } from "srvx";
import { dbConfigSchema, type DbConfig } from "../../shared/db/config.js";
import type { DbConfig } from "../../shared/db/config.js";
import { initDb } from "../../shared/db/init.js";
import type { Repository } from "../../shared/db/repository.js";
import { initSecrets, type SecretsApi } from "../../shared/secrets.js";
@ -39,7 +39,20 @@ import { registerCloudRoutes } from "./routes-cloud.js";
const ConfigSchema = av.object(
{
db: dbConfigSchema,
db: av.object(
{
driver: av.enum_(["sqlite", "postgres"] as const).default("postgres"),
sqlitePath: av.string().minLength(1).default("/var/lib/betterframe/betterframe.db"),
pgUrl: av.string().default(""),
pgHost: av.string().default("postgres"),
pgPort: av.int().min(1).max(65535).default(5432),
pgDatabase: av.string().default("betterframe"),
pgUser: av.string().default("betterframe"),
pgPassword: av.string().default("betterframe"),
pgPoolMax: av.int().min(1).max(1000).default(10),
},
{ unknownKeys: "strip" },
),
host: av.string().default("127.0.0.1"),
port: av.int().min(1).max(65535).default(18080),
// Secrets config (was service-secrets)

View file

@ -15,7 +15,7 @@ import {
import { H3, serve, readBody, getRequestHeader, getRouterParam, createError } from "h3";
import type { Server } from "srvx";
import { dbConfigSchema, type DbConfig } from "../../shared/db/config.js";
import type { DbConfig } from "../../shared/db/config.js";
import { initDb } from "../../shared/db/init.js";
import type { Repository } from "../../shared/db/repository.js";
import { initSecrets } from "../../shared/secrets.js";
@ -36,7 +36,20 @@ import type { FirmwareChannel } from "../../shared/types.js";
const ConfigSchema = av.object(
{
db: dbConfigSchema,
db: av.object(
{
driver: av.enum_(["sqlite", "postgres"] as const).default("postgres"),
sqlitePath: av.string().minLength(1).default("/var/lib/betterframe/betterframe.db"),
pgUrl: av.string().default(""),
pgHost: av.string().default("postgres"),
pgPort: av.int().min(1).max(65535).default(5432),
pgDatabase: av.string().default("betterframe"),
pgUser: av.string().default("betterframe"),
pgPassword: av.string().default("betterframe"),
pgPoolMax: av.int().min(1).max(1000).default(10),
},
{ unknownKeys: "strip" },
),
host: av.string().default("127.0.0.1"),
port: av.int().min(1).max(65535).default(18081),
codeTtlSeconds: av.int().min(60).max(3600).default(600),

View file

@ -23,7 +23,7 @@ import { createServer, type IncomingMessage, type Server as HttpServer } from "n
import { randomUUID } from "node:crypto";
import { WebSocketServer, WebSocket } from "ws";
import { dbConfigSchema, type DbConfig } from "../../shared/db/config.js";
import type { DbConfig } from "../../shared/db/config.js";
import { initDb } from "../../shared/db/init.js";
import { initSecrets } from "../../shared/secrets.js";
import { createAuth } from "../../shared/auth.js";
@ -34,7 +34,20 @@ import { initNoderedBridge, type NoderedBridge } from "../../shared/nodered-brid
const ConfigSchema = av.object(
{
db: dbConfigSchema,
db: av.object(
{
driver: av.enum_(["sqlite", "postgres"] as const).default("postgres"),
sqlitePath: av.string().minLength(1).default("/var/lib/betterframe/betterframe.db"),
pgUrl: av.string().default(""),
pgHost: av.string().default("postgres"),
pgPort: av.int().min(1).max(65535).default(5432),
pgDatabase: av.string().default("betterframe"),
pgUser: av.string().default("betterframe"),
pgPassword: av.string().default("betterframe"),
pgPoolMax: av.int().min(1).max(1000).default(10),
},
{ unknownKeys: "strip" },
),
host: av.string().default("127.0.0.1"),
port: av.int().min(1).max(65535).default(18082),
noderedUrl: av.string().minLength(1).default("http://127.0.0.1:1880"),