feat: marca Uriel Jareth Consulting, API segura para agentes, aprobacion humana y webhooks HMAC
This commit is contained in:
@@ -68,6 +68,17 @@ model Cotizacion {
|
||||
observacionesInternas String?
|
||||
clienteId String
|
||||
asesorId String
|
||||
aprobadaPorId String?
|
||||
aprobadaAt DateTime?
|
||||
aprobacionMetodo String?
|
||||
enviadaAt DateTime?
|
||||
enviadaPor String?
|
||||
enviadaCanal String?
|
||||
enviadaDestino String?
|
||||
aceptadaAt DateTime?
|
||||
rechazadaAt DateTime?
|
||||
vencidaAt DateTime?
|
||||
creadaPorAgente String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -78,6 +89,7 @@ model Cotizacion {
|
||||
registrosHoras RegistroHoras[]
|
||||
propuestasIA PropuestaIA[]
|
||||
programasPago ProgramaPago[]
|
||||
approvalTokens ApprovalToken[]
|
||||
|
||||
@@index([clienteId])
|
||||
@@index([asesorId])
|
||||
@@ -380,3 +392,101 @@ model SuscripcionPush {
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// API para Agentes, Auditoria, Aprobacion, Idempotencia y Webhooks
|
||||
// ============================================================================
|
||||
|
||||
model AgentApiKey {
|
||||
id String @id @default(cuid())
|
||||
nombre String @unique
|
||||
prefijo String
|
||||
keyHash String @unique
|
||||
scopes String[]
|
||||
rateLimitPerMin Int @default(60)
|
||||
activo Boolean @default(true)
|
||||
revokedAt DateTime?
|
||||
lastUsedAt DateTime?
|
||||
createdById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model AuditLog {
|
||||
id String @id @default(cuid())
|
||||
actorTipo String
|
||||
actorId String?
|
||||
actorNombre String
|
||||
accion String
|
||||
recursoTipo String
|
||||
recursoId String?
|
||||
ip String?
|
||||
requestId String?
|
||||
exito Boolean @default(true)
|
||||
detalle Json?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([createdAt])
|
||||
@@index([accion])
|
||||
@@index([recursoTipo, recursoId])
|
||||
@@index([actorNombre])
|
||||
}
|
||||
|
||||
model ApprovalToken {
|
||||
id String @id @default(cuid())
|
||||
cotizacionId String
|
||||
tokenHash String @unique
|
||||
expiraAt DateTime
|
||||
usadoAt DateTime?
|
||||
usadoIp String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
cotizacion Cotizacion @relation(fields: [cotizacionId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([cotizacionId])
|
||||
}
|
||||
|
||||
model IdempotencyKey {
|
||||
id String @id @default(cuid())
|
||||
key String @unique
|
||||
method String
|
||||
path String
|
||||
requestHash String
|
||||
statusCode Int
|
||||
responseBody Json
|
||||
expiraAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([expiraAt])
|
||||
}
|
||||
|
||||
model WebhookEndpoint {
|
||||
id String @id @default(cuid())
|
||||
nombre String @unique
|
||||
url String
|
||||
secret String
|
||||
eventos String[]
|
||||
activo Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
entregas WebhookDelivery[]
|
||||
}
|
||||
|
||||
model WebhookDelivery {
|
||||
id String @id @default(cuid())
|
||||
endpointId String?
|
||||
url String
|
||||
evento String
|
||||
payload Json
|
||||
statusCode Int?
|
||||
exito Boolean @default(false)
|
||||
intentos Int @default(1)
|
||||
error String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
endpoint WebhookEndpoint? @relation(fields: [endpointId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([evento])
|
||||
@@index([createdAt])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user