chore: atualizações de dependências, lint fixes e ajustes menores

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Felipe Coutinho
2026-02-15 21:35:39 +00:00
parent 2362a70b9d
commit b9f788312c
35 changed files with 637 additions and 824 deletions

View File

@@ -585,7 +585,10 @@ export async function generateInsightsAction(
const selectedModel = AVAILABLE_MODELS.find((m) => m.id === modelId);
// Se não encontrou na lista e não tem "/" (formato OpenRouter), é inválido
if (!selectedModel && !modelId.includes("/")) {
const isOpenRouterFormat = /^[a-zA-Z0-9_-]+\/[a-zA-Z0-9._-]+$/.test(
modelId,
);
if (!selectedModel && !isOpenRouterFormat) {
return {
success: false,
error: "Modelo inválido.",
@@ -599,7 +602,7 @@ export async function generateInsightsAction(
let model;
// Se o modelo tem "/" é OpenRouter (formato: provider/model)
if (modelId.includes("/")) {
if (isOpenRouterFormat && !selectedModel) {
const apiKey = process.env.OPENROUTER_API_KEY;
if (!apiKey) {
return {
@@ -675,10 +678,7 @@ Responda APENAS com um JSON válido seguindo exatamente o schema especificado.`,
console.error("Error generating insights:", error);
return {
success: false,
error:
error instanceof Error
? error.message
: "Erro ao gerar insights. Tente novamente.",
error: "Erro ao gerar insights. Tente novamente.",
};
}
}
@@ -776,10 +776,7 @@ export async function saveInsightsAction(
console.error("Error saving insights:", error);
return {
success: false,
error:
error instanceof Error
? error.message
: "Erro ao salvar análise. Tente novamente.",
error: "Erro ao salvar análise. Tente novamente.",
};
}
}
@@ -837,10 +834,7 @@ export async function loadSavedInsightsAction(period: string): Promise<
console.error("Error loading saved insights:", error);
return {
success: false,
error:
error instanceof Error
? error.message
: "Erro ao carregar análise salva. Tente novamente.",
error: "Erro ao carregar análise salva. Tente novamente.",
};
}
}
@@ -871,10 +865,7 @@ export async function deleteSavedInsightsAction(
console.error("Error deleting saved insights:", error);
return {
success: false,
error:
error instanceof Error
? error.message
: "Erro ao remover análise. Tente novamente.",
error: "Erro ao remover análise. Tente novamente.",
};
}
}

View File

@@ -62,7 +62,12 @@ export async function markInboxAsProcessedAction(
processedAt: new Date(),
updatedAt: new Date(),
})
.where(eq(preLancamentos.id, data.inboxItemId));
.where(
and(
eq(preLancamentos.id, data.inboxItemId),
eq(preLancamentos.userId, user.id),
),
);
revalidateInbox();
@@ -104,7 +109,12 @@ export async function discardInboxItemAction(
discardedAt: new Date(),
updatedAt: new Date(),
})
.where(eq(preLancamentos.id, data.inboxItemId));
.where(
and(
eq(preLancamentos.id, data.inboxItemId),
eq(preLancamentos.userId, user.id),
),
);
revalidateInbox();

View File

@@ -1,4 +1,4 @@
import { desc, eq } from "drizzle-orm";
import { and, desc, eq, isNull } from "drizzle-orm";
import { headers } from "next/headers";
import { NextResponse } from "next/server";
import { tokensApi } from "@/db/schema";
@@ -15,7 +15,7 @@ export async function GET() {
}
// Buscar tokens ativos do usuário
const tokens = await db
const activeTokens = await db
.select({
id: tokensApi.id,
name: tokensApi.name,
@@ -26,14 +26,11 @@ export async function GET() {
createdAt: tokensApi.createdAt,
})
.from(tokensApi)
.where(eq(tokensApi.userId, session.user.id))
.where(
and(eq(tokensApi.userId, session.user.id), isNull(tokensApi.revokedAt)),
)
.orderBy(desc(tokensApi.createdAt));
// Separar tokens ativos e revogados
const activeTokens = tokens.filter(
(t) => !t.expiresAt || new Date(t.expiresAt) > new Date(),
);
return NextResponse.json({ tokens: activeTokens });
} catch (error) {
console.error("[API] Error listing device tokens:", error);

View File

@@ -36,8 +36,7 @@ export async function GET() {
name: "OpenSheets",
version: APP_VERSION,
timestamp: new Date().toISOString(),
message:
error instanceof Error ? error.message : "Database connection failed",
message: "Database connection failed",
},
{ status: 503 },
);