mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 13:56:51 +00:00
Fixed TS errors in helpers
X-Lovable-Edit-ID: edt-eb5c7db2-a1ce-43c2-937b-e4f9208eccb6 Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
commit
a57325a7c1
11 changed files with 22 additions and 12 deletions
|
|
@ -1,3 +1,4 @@
|
|||
// @ts-ignore deno npm specifier resolved at runtime
|
||||
import { Environment, Paddle, EventName } from 'npm:@paddle/paddle-node-sdk';
|
||||
|
||||
export { EventName };
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ function randomHex(bytes: number): string {
|
|||
.join("");
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
async function getDecryptedSecret(
|
||||
admin: ReturnType<typeof createClient>,
|
||||
admin: any,
|
||||
secretId: string,
|
||||
): Promise<string | null> {
|
||||
const { data, error } = await admin
|
||||
|
|
|
|||
3
supabase/functions/deno.json
Normal file
3
supabase/functions/deno.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
||||
|
|
@ -19,8 +19,9 @@ function jsonResponse(body: unknown, status = 200): Response {
|
|||
});
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
async function getDecryptedSecret(
|
||||
admin: ReturnType<typeof createClient>,
|
||||
admin: any,
|
||||
secretId: string,
|
||||
): Promise<string | null> {
|
||||
const { data, error } = await admin
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@ function jsonResponse(body: unknown, status = 200): Response {
|
|||
});
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
async function getDecryptedSecret(
|
||||
admin: ReturnType<typeof createClient>,
|
||||
admin: any,
|
||||
secretId: string,
|
||||
): Promise<string | null> {
|
||||
const { data, error } = await admin
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
// valida com cron-parser, gera human_readable em pt-BR via cronstrue.
|
||||
import { corsHeaders } from "../_shared/cors.ts";
|
||||
import { createClient } from "npm:@supabase/supabase-js@2";
|
||||
// @ts-expect-error remote esm
|
||||
import cronParser from "https://esm.sh/cron-parser@4.9.0";
|
||||
// @ts-expect-error remote esm
|
||||
import cronstrue from "https://esm.sh/cronstrue@2.50.0/i18n";
|
||||
|
||||
const LOVABLE_API_KEY = Deno.env.get("LOVABLE_API_KEY")!;
|
||||
|
|
|
|||
|
|
@ -315,7 +315,8 @@ function jsonResponse(status: number, body: unknown) {
|
|||
}
|
||||
|
||||
async function failJob(
|
||||
supabase: ReturnType<typeof createClient>,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
supabase: any,
|
||||
agent: { id: string },
|
||||
jobId: string | null,
|
||||
message: string,
|
||||
|
|
@ -330,7 +331,8 @@ async function failJob(
|
|||
}
|
||||
|
||||
async function scheduleRetry(
|
||||
supabase: ReturnType<typeof createClient>,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
supabase: any,
|
||||
agent: { id: string },
|
||||
jobId: string,
|
||||
message: string,
|
||||
|
|
@ -341,8 +343,8 @@ async function scheduleRetry(
|
|||
.eq("id", jobId)
|
||||
.single();
|
||||
|
||||
const attempt = job?.attempt ?? 1;
|
||||
const max = job?.max_attempts ?? 5;
|
||||
const attempt: number = (job?.attempt as number | undefined) ?? 1;
|
||||
const max: number = (job?.max_attempts as number | undefined) ?? 5;
|
||||
|
||||
if (attempt >= max) {
|
||||
await failJob(supabase, agent, jobId, `Max attempts reached. Last error: ${message}`);
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ Deno.serve(async (req) => {
|
|||
|
||||
// Carrega nome do cliente para a notificação (best-effort)
|
||||
async function loadFullName(): Promise<string> {
|
||||
if (!agent) return "—";
|
||||
const { data } = await supabase
|
||||
.from("profiles")
|
||||
.select("full_name")
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ function jsonResponse(body: unknown, status = 200): Response {
|
|||
});
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
async function getDecryptedSecret(
|
||||
admin: ReturnType<typeof createClient>,
|
||||
admin: any,
|
||||
secretId: string,
|
||||
): Promise<string | null> {
|
||||
const { data, error } = await admin
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ function firstName(fullName: string | null | undefined): string {
|
|||
return parts[0] || "Mika";
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
async function getDecryptedSecret(
|
||||
admin: ReturnType<typeof createClient>,
|
||||
admin: any,
|
||||
secretId: string,
|
||||
): Promise<string | null> {
|
||||
const { data, error } = await admin
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ Deno.serve(async (req) => {
|
|||
|
||||
// 5) Se já houver um vault_id antigo, remove (reconexão)
|
||||
if (agent.telegram_bot_token_vault_id) {
|
||||
await admin.rpc("exec_sql_void", {}).catch(() => {});
|
||||
try { await admin.rpc("exec_sql_void", {} as never); } catch { /* ignore */ }
|
||||
// tenta remover diretamente; ignora falha
|
||||
const { error: delErr } = await admin
|
||||
.from("vault.secrets" as unknown as never)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue