Corrección 1 — Delete de proceso restaurado + Corrección 2 — Patrón userId en repos

This commit is contained in:
2026-05-28 01:13:28 -03:00
parent 1bc80e190f
commit 0a3c60cd09
26 changed files with 1650 additions and 25844 deletions

View File

@@ -1,12 +1,6 @@
import { supabase } from '@/lib/supabase'
import type { ProcessGroup } from '@/domain/types'
async function getCurrentUserId(): Promise<string> {
const { data: { session } } = await supabase.auth.getSession()
if (!session?.user) throw new Error('Usuario no autenticado')
return session.user.id
}
function fromRow(row: Record<string, unknown>): ProcessGroup {
return {
id: row.id as string,
@@ -17,8 +11,7 @@ function fromRow(row: Record<string, unknown>): ProcessGroup {
}
export const supabaseGroupRepo = {
async save(group: ProcessGroup): Promise<void> {
const userId = await getCurrentUserId()
async save(group: ProcessGroup, userId: string): Promise<void> {
const { error } = await supabase.from('process_groups').upsert({
id: group.id,
name: group.name,

View File

@@ -2,12 +2,6 @@ import { supabase } from '@/lib/supabase'
import { db } from '@/persistence/db'
import type { Process } from '@/domain/types'
async function getCurrentUserId(): Promise<string> {
const { data: { session } } = await supabase.auth.getSession()
if (!session?.user) throw new Error('Usuario no autenticado')
return session.user.id
}
function toRow(process: Process, userId: string) {
return {
id: process.id,
@@ -47,8 +41,7 @@ function fromRow(row: Record<string, unknown>): Process {
}
export const supabaseProcessRepo = {
async save(process: Process): Promise<void> {
const userId = await getCurrentUserId()
async save(process: Process, userId: string): Promise<void> {
const { error } = await supabase.from('processes').upsert(toRow(process, userId))
if (error) throw error
},