feat(CC-058): add GET /ai-requests/:id with full contextManifest for transparency viewer

This commit is contained in:
admin-valentin 2026-08-01 21:01:56 +00:00
parent 9d58aa90be
commit 8f69f9d95c

View file

@ -1,5 +1,5 @@
import { Controller, Get, Query } from '@nestjs/common';
import { desc, eq, sum, count } from 'drizzle-orm';
import { Controller, Get, NotFoundException, Param, ParseUUIDPipe, Query } from '@nestjs/common';
import { and, desc, eq, sum, count } from 'drizzle-orm';
import { CurrentSession } from '../auth/session.decorator';
import type { AuthenticatedSession } from '../auth/tenant.guard';
import { db } from '../db/client';
@ -72,4 +72,18 @@ export class AiRequestsController {
byStatus,
};
}
@Get(':id')
async getOne(
@CurrentSession() session: AuthenticatedSession,
@Param('id', ParseUUIDPipe) id: string,
) {
const record = await db.query.aiRequests.findFirst({
where: and(eq(aiRequests.id, id), eq(aiRequests.tenantId, session.tenantId)),
});
if (!record) {
throw new NotFoundException('AI request not found');
}
return record;
}
}