feature/file-manager-user-only-read

This commit is contained in:
2026-04-06 07:43:43 -06:00
parent 9439a6a775
commit 1355bf34c4
10 changed files with 614 additions and 12 deletions

View File

@@ -456,6 +456,7 @@ async function fetchBlob(endpoint: string, options: RequestInit = {}): Promise<B
// Métodos HTTP
export const api = {
get: <T = any>(endpoint: string) => fetchApi<T>(endpoint, { method: 'GET' }),
getBlob: (endpoint: string) => fetchBlob(endpoint, { method: 'GET' }),
post: <T = any>(endpoint: string, body: any, options: RequestInit = {}) =>
fetchApi<T>(endpoint, {

View File

@@ -0,0 +1,53 @@
import { api } from '$lib/api';
const BASE_PATH = '/v1/a76/audit-log/files';
export interface AuditFileBreadcrumb {
path: string;
display_name: string;
}
export interface AuditFolderItem {
path: string;
display_name: string;
}
export interface AuditFileItem {
path: string;
display_name: string;
size: number;
last_modified?: string | null;
}
export interface AuditFileListResponse {
current_path: string;
display_path: string;
breadcrumbs: AuditFileBreadcrumb[];
folders: AuditFolderItem[];
files: AuditFileItem[];
next_token?: string | null;
}
export const AuditFilesAPI = {
list: async (params?: {
path?: string;
continuation_token?: string;
max_keys?: number;
}): Promise<AuditFileListResponse> => {
const query = new URLSearchParams();
if (params?.path) query.set('path', params.path);
if (params?.continuation_token) query.set('continuation_token', params.continuation_token);
if (params?.max_keys) query.set('max_keys', String(params.max_keys));
const qs = query.toString();
const endpoint = qs ? `${BASE_PATH}?${qs}` : BASE_PATH;
const response = await api.get<AuditFileListResponse>(endpoint);
if (response.error || !response.data) {
throw new Error(response.error || 'Failed to list tenant files');
}
return response.data;
},
downloadBlob: (path: string) =>
api.getBlob(`${BASE_PATH}/download?path=${encodeURIComponent(path)}`)
};