ai-chatbot/lib/agents/psd-font-settings.ts
Your Name 17dcfcd55d
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
feat: add PSD template font rendering workflow
2026-03-27 11:01:13 +08:00

31 lines
980 B
TypeScript

import "server-only";
import { getDefaultStorageConfig, getSystemSetting } from "@/lib/db/queries";
import {
AGENT_PSD_FONTS_KEY,
parseAgentPsdFonts,
type AgentPsdFont,
} from "@/lib/agents/psd-font-config";
export async function readAgentPsdFonts() {
const setting = await getSystemSetting({ key: AGENT_PSD_FONTS_KEY });
return parseAgentPsdFonts(setting?.value);
}
export async function tryDeleteAgentPsdFontAssets(font: AgentPsdFont) {
if (!font.filePath) return;
try {
const storageConfig = await getDefaultStorageConfig().catch(() => undefined);
if (!storageConfig || storageConfig.type !== "s3") return;
const { deleteS3ObjectByPath, toDbS3UploadConfig } = await import("@/lib/storage/service");
const uploadConfig = toDbS3UploadConfig(storageConfig);
if (!uploadConfig) return;
await deleteS3ObjectByPath(font.filePath, uploadConfig);
} catch (error) {
console.warn("[PSD Font] Failed to delete font asset:", error);
}
}