feat(documents): entity-aggregated query params + signing-details API
GET /api/v1/files?entityType=client&entityId=… and the same params on
the documents route return the owner-aggregated projection
{ groups: [{ label, source, files|workflows, total }] }. folderId
remains for direct-folder listing; the two modes are mutually
exclusive (zod refine).
GET /api/v1/documents/[id]/signing-details returns
{ workflow, signers, events } for the "view signing details" dialog
on signed-PDF rows.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,13 +3,23 @@ import { NextResponse } from 'next/server';
|
||||
import { withAuth, withPermission } from '@/lib/api/helpers';
|
||||
import { parseQuery } from '@/lib/api/route-helpers';
|
||||
import { errorResponse } from '@/lib/errors';
|
||||
import { listFiles } from '@/lib/services/files';
|
||||
import { listFiles, listFilesAggregatedByEntity } from '@/lib/services/files';
|
||||
import { listFilesSchema } from '@/lib/validators/files';
|
||||
|
||||
export const GET = withAuth(
|
||||
withPermission('files', 'view', async (req, ctx) => {
|
||||
try {
|
||||
const query = parseQuery(req, listFilesSchema);
|
||||
|
||||
if (query.entityType && query.entityId) {
|
||||
const result = await listFilesAggregatedByEntity(
|
||||
ctx.portId,
|
||||
query.entityType,
|
||||
query.entityId,
|
||||
);
|
||||
return NextResponse.json({ data: result });
|
||||
}
|
||||
|
||||
const result = await listFiles(ctx.portId, query);
|
||||
|
||||
const { page, limit } = query;
|
||||
|
||||
Reference in New Issue
Block a user