feat: marca Uriel Jareth Consulting, API segura para agentes, aprobacion humana y webhooks HMAC

This commit is contained in:
urieljareth
2026-11-25 00:55:18 -06:00
parent 75180b0fe4
commit 0d4f19f35d
111 changed files with 7167 additions and 1272 deletions
+6 -6
View File
@@ -5,7 +5,7 @@ import math
from fastapi import APIRouter, Depends, HTTPException, Query, status
from asyncpg import Connection
from app.auth import require_auth
from app.auth import require_scope, require_staff_human
from app.dependencies import PaginationParams, get_db
from app.models.cliente import ClienteCreate, ClienteUpdate, ClienteResponse
from app.models.common import PaginatedResponse, Meta, ErrorResponse, OkResponse
@@ -20,7 +20,7 @@ router = APIRouter(prefix="/clientes", tags=["Clientes"])
)
async def list_clientes(
db: Connection = Depends(get_db),
auth: dict = Depends(require_auth),
auth: dict = Depends(require_scope("clientes:leer")),
pagination: PaginationParams = Depends(PaginationParams),
q: str | None = Query(None, description="Search by nombre, empresa, or email"),
):
@@ -79,7 +79,7 @@ async def list_clientes(
async def create_cliente(
body: ClienteCreate,
db: Connection = Depends(get_db),
auth: dict = Depends(require_auth),
auth: dict = Depends(require_scope("clientes:escribir")),
):
row = await db.fetchrow(
'INSERT INTO "Cliente" (nombre, empresa, email, telefono) '
@@ -109,7 +109,7 @@ async def create_cliente(
async def get_cliente(
cliente_id: str,
db: Connection = Depends(get_db),
auth: dict = Depends(require_auth),
auth: dict = Depends(require_scope("clientes:leer")),
):
row = await db.fetchrow('SELECT * FROM "Cliente" WHERE id = $1', cliente_id)
if not row:
@@ -146,7 +146,7 @@ async def update_cliente(
cliente_id: str,
body: ClienteUpdate,
db: Connection = Depends(get_db),
auth: dict = Depends(require_auth),
auth: dict = Depends(require_scope("clientes:escribir")),
):
existing = await db.fetchrow('SELECT id FROM "Cliente" WHERE id = $1', cliente_id)
if not existing:
@@ -192,7 +192,7 @@ async def update_cliente(
async def delete_cliente(
cliente_id: str,
db: Connection = Depends(get_db),
auth: dict = Depends(require_auth),
auth: dict = Depends(require_staff_human),
):
existing = await db.fetchrow('SELECT id FROM "Cliente" WHERE id = $1', cliente_id)
if not existing: