diff --git a/src/server.ts b/src/server.ts index a7a4fc6..795d229 100644 --- a/src/server.ts +++ b/src/server.ts @@ -71,7 +71,7 @@ export class WebhookServer { try { const rows = WebhookServer.dbInstance .prepare(`SELECT status, COUNT(*) AS c FROM allowed_groups GROUP BY status`) - .all() as any[]; + .all() as Array<{ status: string; c: number }>; let pending = 0, allowed = 0, blocked = 0; for (const r of rows) { const s = String(r?.status || ''); @@ -101,8 +101,8 @@ export class WebhookServer { // /health?full=1 devuelve JSON con detalles if (url.searchParams.get('full') === '1') { try { - const rowG = WebhookServer.dbInstance.prepare(`SELECT COUNT(*) AS c, MAX(last_verified) AS lv FROM groups WHERE active = 1`).get() as any; - const rowM = WebhookServer.dbInstance.prepare(`SELECT COUNT(*) AS c FROM group_members WHERE is_active = 1`).get() as any; + const rowG = WebhookServer.dbInstance.prepare(`SELECT COUNT(*) AS c, MAX(last_verified) AS lv FROM groups WHERE active = 1`).get() as { c?: number; lv?: string | null } | undefined; + const rowM = WebhookServer.dbInstance.prepare(`SELECT COUNT(*) AS c FROM group_members WHERE is_active = 1`).get() as { c?: number } | undefined; const active_groups = Number(rowG?.c || 0); const active_members = Number(rowM?.c || 0); const lv = rowG?.lv ? String(rowG.lv) : null; diff --git a/src/services/allowed-groups.ts b/src/services/allowed-groups.ts index 1469bd9..153c0a9 100644 --- a/src/services/allowed-groups.ts +++ b/src/services/allowed-groups.ts @@ -28,7 +28,7 @@ export class AllowedGroups { try { const row = this.dbInstance .prepare(`SELECT group_id, label, status FROM allowed_groups WHERE group_id = ?`) - .get(groupId) as any; + .get(groupId) as { group_id?: string; label?: string | null; status?: string } | undefined; if (!row) return null; return { group_id: String(row.group_id), @@ -126,8 +126,8 @@ export class AllowedGroups { ) .all(status) as Array<{ group_id: string; label: string | null }>; return rows.map(r => ({ - group_id: String((r as any).group_id), - label: (r as any).label != null ? String((r as any).label) : null, + group_id: String(r.group_id), + label: r.label != null ? String(r.label) : null, })); } diff --git a/src/services/identity.ts b/src/services/identity.ts index 12369be..671b341 100644 --- a/src/services/identity.ts +++ b/src/services/identity.ts @@ -58,7 +58,7 @@ export class IdentityService { // Después, intentar en la base de datos try { - const row = this.dbInstance.prepare(`SELECT user_id FROM user_aliases WHERE alias = ?`).get(n) as any; + const row = this.dbInstance.prepare(`SELECT user_id FROM user_aliases WHERE alias = ?`).get(n) as { user_id?: string } | undefined; if (row?.user_id) { const v = String(row.user_id); // Mantener caché en memoria para futuras resoluciones rápidas diff --git a/src/services/response-queue.ts b/src/services/response-queue.ts index 05f7077..975b140 100644 --- a/src/services/response-queue.ts +++ b/src/services/response-queue.ts @@ -422,7 +422,7 @@ export const ResponseQueue = { `).run(statusCode ?? null, id); // Recalcular métricas agregadas de onboarding si aplica try { - const row = this.dbInstance.prepare(`SELECT metadata FROM response_queue WHERE id = ?`).get(id) as any; + const row = this.dbInstance.prepare(`SELECT metadata FROM response_queue WHERE id = ?`).get(id) as { metadata?: string | null } | undefined; let meta: any = null; try { meta = row?.metadata ? JSON.parse(String(row.metadata)) : null; } catch {} if (meta && meta.kind === 'onboarding') { @@ -465,7 +465,7 @@ export const ResponseQueue = { SELECT COUNT(*) AS c FROM response_queue WHERE status = 'sent' AND metadata LIKE '%"kind":"onboarding"%' - `).get() as any; + `).get() as { c?: number } | undefined; const sentAbs = Number(sentRow?.c || 0); // Destinatarios únicos con al menos 1 onboarding enviado @@ -473,7 +473,7 @@ export const ResponseQueue = { SELECT COUNT(DISTINCT recipient) AS c FROM response_queue WHERE status = 'sent' AND metadata LIKE '%"kind":"onboarding"%' - `).get() as any; + `).get() as { c?: number } | undefined; const recipientsAbs = Number(rcptRow?.c || 0); // Usuarios convertidos: last_command_at > primer onboarding enviado @@ -488,7 +488,7 @@ export const ResponseQueue = { ) f ON f.recipient = u.id WHERE u.last_command_at IS NOT NULL AND u.last_command_at > f.first_at - `).get() as any; + `).get() as { c?: number } | undefined; const convertedAbs = Number(convRow?.c || 0); const rate = recipientsAbs > 0 ? Math.max(0, Math.min(1, convertedAbs / recipientsAbs)) : 0; diff --git a/src/tasks/service.ts b/src/tasks/service.ts index 86c941c..4ee9342 100644 --- a/src/tasks/service.ts +++ b/src/tasks/service.ts @@ -146,7 +146,7 @@ export class TaskService { id ASC LIMIT ? `) - .all(groupId, limit) as any[]; + .all(groupId, limit) as Array<{ id: number; description: string; due_date: string | null; group_id: string | null; display_code: number | null }>; const getAssignees = this.dbInstance.prepare(` SELECT user_id FROM task_assignments @@ -155,7 +155,7 @@ export class TaskService { `); return rows.map((r) => { - const assigneesRows = getAssignees.all(r.id) as any[]; + const assigneesRows = getAssignees.all(r.id) as Array<{ user_id: string }>; const assignees = assigneesRows.map((a) => String(a.user_id)); return { id: Number(r.id), @@ -190,7 +190,7 @@ export class TaskService { t.id ASC LIMIT ? `) - .all(userId, limit) as any[]; + .all(userId, limit) as Array<{ id: number; description: string; due_date: string | null; group_id: string | null; display_code: number | null }>; const getAssignees = this.dbInstance.prepare(` SELECT user_id FROM task_assignments @@ -199,7 +199,7 @@ export class TaskService { `); return rows.map((r) => { - const assigneesRows = getAssignees.all(r.id) as any[]; + const assigneesRows = getAssignees.all(r.id) as Array<{ user_id: string }>; const assignees = assigneesRows.map((a) => String(a.user_id)); return { id: Number(r.id), @@ -221,7 +221,7 @@ export class TaskService { WHERE group_id = ? AND COALESCE(completed, 0) = 0 AND completed_at IS NULL `) - .get(groupId) as any; + .get(groupId) as { cnt?: number } | undefined; return Number(row?.cnt || 0); } @@ -235,7 +235,7 @@ export class TaskService { WHERE a.user_id = ? AND COALESCE(t.completed, 0) = 0 AND t.completed_at IS NULL `) - .get(userId) as any; + .get(userId) as { cnt?: number } | undefined; return Number(row?.cnt || 0); } @@ -375,7 +375,7 @@ export class TaskService { id ASC LIMIT ? `) - .all(groupId, limit) as any[]; + .all(groupId, limit) as Array<{ id: number; description: string; due_date: string | null; group_id: string | null; display_code: number | null }>; return rows.map((r) => ({ id: Number(r.id), @@ -399,7 +399,7 @@ export class TaskService { SELECT 1 FROM task_assignments a WHERE a.task_id = t.id ) `) - .get(groupId) as any; + .get(groupId) as { cnt?: number } | undefined; return Number(row?.cnt || 0); } @@ -541,7 +541,7 @@ export class TaskService { const cntRow = this.dbInstance .prepare(`SELECT COUNT(*) as cnt FROM task_assignments WHERE task_id = ?`) - .get(taskId) as any; + .get(taskId) as { cnt?: number } | undefined; const remaining = Number(cntRow?.cnt || 0); if (result.changes && result.changes > 0) { @@ -676,7 +676,7 @@ export class TaskService { t.id ASC LIMIT ? `) - .all(limit) as any[]; + .all(limit) as Array<{ id: number; description: string; due_date: string | null; group_id: string | null; display_code: number | null; group_name: string | null }>; return rows.map(r => ({ id: Number(r.id), @@ -702,7 +702,7 @@ export class TaskService { AND COALESCE(g2.is_community,0)=0 )) `) - .get() as any; + .get() as { cnt?: number } | undefined; return Number(row?.cnt || 0); } }