mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 19:06:34 +00:00
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:
parent
9e7542a424
commit
664e6e1548
3 changed files with 45 additions and 6 deletions
|
|
@ -15,7 +15,7 @@ import {
|
||||||
import { H3, serve } from "h3";
|
import { H3, serve } from "h3";
|
||||||
import type { Server } from "srvx";
|
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 { initDb } from "../../shared/db/init.js";
|
||||||
import type { Repository } from "../../shared/db/repository.js";
|
import type { Repository } from "../../shared/db/repository.js";
|
||||||
import { initSecrets, type SecretsApi } from "../../shared/secrets.js";
|
import { initSecrets, type SecretsApi } from "../../shared/secrets.js";
|
||||||
|
|
@ -39,7 +39,20 @@ import { registerCloudRoutes } from "./routes-cloud.js";
|
||||||
|
|
||||||
const ConfigSchema = av.object(
|
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"),
|
host: av.string().default("127.0.0.1"),
|
||||||
port: av.int().min(1).max(65535).default(18080),
|
port: av.int().min(1).max(65535).default(18080),
|
||||||
// Secrets config (was service-secrets)
|
// Secrets config (was service-secrets)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
import { H3, serve, readBody, getRequestHeader, getRouterParam, createError } from "h3";
|
import { H3, serve, readBody, getRequestHeader, getRouterParam, createError } from "h3";
|
||||||
import type { Server } from "srvx";
|
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 { initDb } from "../../shared/db/init.js";
|
||||||
import type { Repository } from "../../shared/db/repository.js";
|
import type { Repository } from "../../shared/db/repository.js";
|
||||||
import { initSecrets } from "../../shared/secrets.js";
|
import { initSecrets } from "../../shared/secrets.js";
|
||||||
|
|
@ -36,7 +36,20 @@ import type { FirmwareChannel } from "../../shared/types.js";
|
||||||
|
|
||||||
const ConfigSchema = av.object(
|
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"),
|
host: av.string().default("127.0.0.1"),
|
||||||
port: av.int().min(1).max(65535).default(18081),
|
port: av.int().min(1).max(65535).default(18081),
|
||||||
codeTtlSeconds: av.int().min(60).max(3600).default(600),
|
codeTtlSeconds: av.int().min(60).max(3600).default(600),
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { createServer, type IncomingMessage, type Server as HttpServer } from "n
|
||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
import { WebSocketServer, WebSocket } from "ws";
|
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 { initDb } from "../../shared/db/init.js";
|
||||||
import { initSecrets } from "../../shared/secrets.js";
|
import { initSecrets } from "../../shared/secrets.js";
|
||||||
import { createAuth } from "../../shared/auth.js";
|
import { createAuth } from "../../shared/auth.js";
|
||||||
|
|
@ -34,7 +34,20 @@ import { initNoderedBridge, type NoderedBridge } from "../../shared/nodered-brid
|
||||||
|
|
||||||
const ConfigSchema = av.object(
|
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"),
|
host: av.string().default("127.0.0.1"),
|
||||||
port: av.int().min(1).max(65535).default(18082),
|
port: av.int().min(1).max(65535).default(18082),
|
||||||
noderedUrl: av.string().minLength(1).default("http://127.0.0.1:1880"),
|
noderedUrl: av.string().minLength(1).default("http://127.0.0.1:1880"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue