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
@@ -211,11 +211,38 @@ export interface UpsertItemInput {
|
||||
data: Record<string, unknown>;
|
||||
}
|
||||
|
||||
function ensureServerColumn(category: string) {
|
||||
const db = getDatabase();
|
||||
const normalized = category.trim().toLowerCase();
|
||||
validateCategoryName(normalized);
|
||||
|
||||
const pragma = db.prepare(`PRAGMA table_info(${normalized})`).all() as Array<{
|
||||
name: string;
|
||||
type: string;
|
||||
notnull: number;
|
||||
pk: number;
|
||||
}>;
|
||||
|
||||
const hasServer = pragma.some((col) => col.name === "server");
|
||||
if (!hasServer) {
|
||||
// Adiciona coluna 'server' como TEXT opcional
|
||||
addColumnToCategory({
|
||||
category: normalized,
|
||||
column: { name: "server", type: "TEXT", notNull: false, editable: true },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function insertCategoryItem(input: UpsertItemInput): number {
|
||||
const db = getDatabase();
|
||||
const category = input.category.trim().toLowerCase();
|
||||
validateCategoryName(category);
|
||||
|
||||
// Garante que a coluna 'server' exista na tabela de destino.
|
||||
try {
|
||||
ensureServerColumn(category);
|
||||
} catch {}
|
||||
|
||||
const data = { ...input.data };
|
||||
delete data.id;
|
||||
|
||||
|
||||
Reference in new issue
Block a user