# Deploy dos endpoints implementados com arquitetura correta
# Supabase Externo = appointments, doctors, patients, reports
# Nosso Supabase = features extras, KPIs, tracking

Write-Host "🚀 Deployando 12 endpoints implementados..." -ForegroundColor Cyan

$endpoints = @(
    # Endpoints que MESCLAM (Externo + Nosso)
    "doctor-summary",
    "patients-history",
    "reports-list-extended",
    "analytics-heatmap",
    
    # Endpoints 100% NOSSOS
    "waitlist-match",
    "exceptions-list",
    "exceptions-create",
    "queue-checkin",
    "notifications-subscription",
    "accessibility-preferences",
    "audit-list",
    "availability-slots"
)

$total = $endpoints.Count
$current = 0

foreach ($endpoint in $endpoints) {
    $current++
    Write-Host "[$current/$total] Deploying $endpoint..." -ForegroundColor Yellow
    
    pnpx supabase functions deploy $endpoint --no-verify-jwt 2>&1 | Out-Null
    
    if ($LASTEXITCODE -eq 0) {
        Write-Host "  ✅ $endpoint deployed" -ForegroundColor Green
    } else {
        Write-Host "  ❌ $endpoint failed" -ForegroundColor Red
    }
}

Write-Host "`n✨ Deploy concluído! Verificando status..." -ForegroundColor Cyan
pnpx supabase functions list
