fix: Complete schema adaptation for all tool modules

- auth.ts: Use suspendedAt instead of isSuspended, role instead of isAdmin
- comments.ts: Use role='admin' for admin user queries
- documents.ts: Use suspendedAt IS NULL for active users
- events.ts: Return actorRole instead of actorIsAdmin
- shares.ts: Use role='admin' for admin user queries

All queries validated against Outline v0.78 schema (10/10 tests pass).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 13:34:53 +00:00
parent 6f5d17516b
commit 7116722d73
5 changed files with 10 additions and 10 deletions

View File

@@ -31,8 +31,8 @@ const getAuthInfo: BaseTool<Record<string, never>> = {
const statsQuery = await pgClient.query(` const statsQuery = await pgClient.query(`
SELECT SELECT
(SELECT COUNT(*) FROM users WHERE "deletedAt" IS NULL) as total_users, (SELECT COUNT(*) FROM users WHERE "deletedAt" IS NULL) as total_users,
(SELECT COUNT(*) FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL) as admin_users, (SELECT COUNT(*) FROM users WHERE role = 'admin' AND "deletedAt" IS NULL) as admin_users,
(SELECT COUNT(*) FROM users WHERE "isSuspended" = true) as suspended_users, (SELECT COUNT(*) FROM users WHERE "suspendedAt" IS NOT NULL) as suspended_users,
(SELECT COUNT(*) FROM teams) as total_teams, (SELECT COUNT(*) FROM teams) as total_teams,
(SELECT COUNT(*) FROM oauth_clients) as oauth_clients, (SELECT COUNT(*) FROM oauth_clients) as oauth_clients,
(SELECT COUNT(*) FROM oauth_authentications) as oauth_authentications (SELECT COUNT(*) FROM oauth_authentications) as oauth_authentications
@@ -48,8 +48,8 @@ const getAuthInfo: BaseTool<Record<string, never>> = {
u.email, u.email,
u."lastActiveAt", u."lastActiveAt",
u."lastSignedInAt", u."lastSignedInAt",
u."isAdmin", u.role,
u."isSuspended" u."suspendedAt"
FROM users u FROM users u
WHERE u."deletedAt" IS NULL WHERE u."deletedAt" IS NULL
ORDER BY u."lastActiveAt" DESC NULLS LAST ORDER BY u."lastActiveAt" DESC NULLS LAST

View File

@@ -252,7 +252,7 @@ const createComment: BaseTool<CreateCommentArgs> = {
// Note: In real implementation, createdById should come from authentication context // Note: In real implementation, createdById should come from authentication context
// For now, we'll get the first admin user // For now, we'll get the first admin user
const userQuery = await pgClient.query( const userQuery = await pgClient.query(
'SELECT id FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL LIMIT 1' `SELECT id FROM users WHERE role = 'admin' AND "deletedAt" IS NULL LIMIT 1`
); );
if (userQuery.rows.length === 0) { if (userQuery.rows.length === 0) {
@@ -427,7 +427,7 @@ const resolveComment: BaseTool<GetCommentArgs> = {
// Get first admin user as resolver // Get first admin user as resolver
const userQuery = await pgClient.query( const userQuery = await pgClient.query(
'SELECT id FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL LIMIT 1' `SELECT id FROM users WHERE role = 'admin' AND "deletedAt" IS NULL LIMIT 1`
); );
if (userQuery.rows.length === 0) { if (userQuery.rows.length === 0) {

View File

@@ -217,7 +217,7 @@ const createDocument: BaseTool<CreateDocumentArgs> = {
// Obter primeiro utilizador activo como createdById (necessário) // Obter primeiro utilizador activo como createdById (necessário)
const userResult = await pgClient.query( const userResult = await pgClient.query(
`SELECT id FROM users WHERE "deletedAt" IS NULL AND "isSuspended" = false LIMIT 1` `SELECT id FROM users WHERE "deletedAt" IS NULL AND "suspendedAt" IS NULL LIMIT 1`
); );
if (userResult.rows.length === 0) { if (userResult.rows.length === 0) {

View File

@@ -202,7 +202,7 @@ const getEvent: BaseTool<{ id: string }> = {
e."createdAt", e."createdAt",
actor.name as "actorName", actor.name as "actorName",
actor.email as "actorEmail", actor.email as "actorEmail",
actor."isAdmin" as "actorIsAdmin", actor.role as "actorRole",
u.name as "userName", u.name as "userName",
u.email as "userEmail", u.email as "userEmail",
c.name as "collectionName", c.name as "collectionName",

View File

@@ -260,7 +260,7 @@ const createShare: BaseTool<CreateShareArgs> = {
// Get first admin user as creator // Get first admin user as creator
const userQuery = await pgClient.query( const userQuery = await pgClient.query(
'SELECT id FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL LIMIT 1' `SELECT id FROM users WHERE role = 'admin' AND "deletedAt" IS NULL LIMIT 1`
); );
if (userQuery.rows.length === 0) { if (userQuery.rows.length === 0) {
@@ -416,7 +416,7 @@ const revokeShare: BaseTool<GetShareArgs> = {
// Get first admin user as revoker // Get first admin user as revoker
const userQuery = await pgClient.query( const userQuery = await pgClient.query(
'SELECT id FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL LIMIT 1' `SELECT id FROM users WHERE role = 'admin' AND "deletedAt" IS NULL LIMIT 1`
); );
if (userQuery.rows.length === 0) { if (userQuery.rows.length === 0) {