feat(items): add server field and improve item management
refactor(ai): enhance item structure generation with schema validation feat(ai): add token usage tracking and cost calculation fix(ui): improve item card number formatting with locale support docs(items): add documentation for item value separation test(items): add tests for value field validation
This commit is contained in:
1 parent
dc169f9eba
commit
d3704602fd
22 files changed
+1317
-95
No files matched your search
@@ -129,6 +129,7 @@ export async function POST(request: NextRequest) {
|
||||
const body = await request.json();
|
||||
const name = typeof body?.name === "string" ? body.name.trim() : "";
|
||||
const category = typeof body?.category === "string" ? body.category.trim().toLowerCase() : "";
|
||||
const originServer = typeof body?.server === "string" ? body.server.trim() || null : null;
|
||||
|
||||
if (!name || !category) {
|
||||
return NextResponse.json(
|
||||
@@ -150,11 +151,19 @@ export async function POST(request: NextRequest) {
|
||||
...dynamicFields,
|
||||
} as Record<string, unknown>;
|
||||
|
||||
// Se enviado servidor de origem, inclui na linha do SQLite e garante presença na lista de servidores do item
|
||||
if (originServer) {
|
||||
sqliteData.server = originServer;
|
||||
}
|
||||
|
||||
const sqliteId = insertCategoryItem({ category, data: sqliteData });
|
||||
|
||||
const metadataBase = typeof body?.metadata === "object" && body.metadata !== null ? body.metadata : {};
|
||||
const metadata = { ...metadataBase, ...dynamicFields } as Record<string, unknown>;
|
||||
|
||||
const itemServers = parseList(body?.servers);
|
||||
const finalServers = originServer ? Array.from(new Set([originServer, ...itemServers])) : itemServers;
|
||||
|
||||
const item = await createAdminItem({
|
||||
item_name: name,
|
||||
category,
|
||||
@@ -165,7 +174,7 @@ export async function POST(request: NextRequest) {
|
||||
weight: typeof body?.weight === "number" ? body.weight : null,
|
||||
slots: typeof body?.slots === "number" ? body.slots : null,
|
||||
skill: typeof body?.skill === "string" ? body.skill.trim() || null : null,
|
||||
servers: parseList(body?.servers),
|
||||
servers: finalServers,
|
||||
tags: parseList(body?.tags),
|
||||
description:
|
||||
typeof body?.description === "string" ? body.description.trim() || null : null,
|
||||
|
||||
Reference in new issue
Block a user