Mezlca de migraciones mas recientes

This commit is contained in:
2026-04-07 16:13:01 -05:00
120 changed files with 5446 additions and 1215 deletions

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)}`)
};

View File

@@ -1,6 +1,24 @@
import { api } from '$lib/api';
import { companyStore } from '$lib/stores/company.svelte'; // <--- NUEVO: Importamos el store para el fallback
import type { ApiResponse } from '$lib/api';
import { getToken } from '$lib/auth';
export type VuUploadFileKind =
| 'certificate'
| 'key'
| 'cove'
| 'doda_certificate'
| 'doda_key'
| 'doda_cove';
export interface CustomsBrokerVuUploadResult {
message: string;
file_kind: string;
field: string;
path: string;
broker_key: string;
company_id: number;
}
export interface CustomsBroker {
id: number;
@@ -165,4 +183,40 @@ export const customsBrokersApi = {
data
);
}
};
};
/**
* Sube CER, KEY o COVE del VU al bucket (MinIO: tenants/.../customs_brokers/...).
*/
export async function uploadCustomsBrokerVuFile(
brokerKey: string,
companyId: string,
fileKind: VuUploadFileKind,
file: File
): Promise<ApiResponse<CustomsBrokerVuUploadResult>> {
const formData = new FormData();
formData.append('file', file);
const token = getToken();
const API_BASE_URL = (import.meta.env.VITE_API_URL || '').replace(/\/+$/, '');
const q = new URLSearchParams({
company_id: companyId,
file_kind: fileKind
});
const response = await fetch(
`${API_BASE_URL}/v1/a76/customs-brokers/${encodeURIComponent(brokerKey)}/vu/upload?${q.toString()}`,
{
method: 'POST',
headers: token ? { Authorization: `Bearer ${token}` } : {},
body: formData,
credentials: 'include'
}
);
const data = await response.json().catch(() => ({}));
if (!response.ok) {
return {
error: (data as { detail?: string }).detail || (data as { message?: string }).message || 'Error al subir el archivo VU',
status: response.status
};
}
return { data: data as CustomsBrokerVuUploadResult, status: response.status };
}

View File

@@ -1,5 +1,6 @@
import { api } from '$lib/api';
import type { ApiResponse } from '$lib/api';
import { getToken } from '$lib/auth';
export interface CompanyAddress {
id?: number;
@@ -450,14 +451,12 @@ export async function uploadCompanyLogo(id: number, file: File): Promise<ApiResp
// Para FormData, usamos fetch directamente ya que necesitamos omitir Content-Type
// para que el navegador establezca el boundary automáticamente
const token = localStorage.getItem('access_token');
const token = getToken();
const API_BASE_URL = (import.meta.env.VITE_API_URL || '').replace(/\/+$/, '');
const response = await fetch(`${API_BASE_URL}/v1/a76/company/${id}/upload-logo`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
},
headers: token ? { Authorization: `Bearer ${token}` } : {},
body: formData,
credentials: 'include'
});
@@ -484,14 +483,12 @@ export async function uploadCompanyCertificate(id: number, type: string, file: F
formData.append('password', password);
}
const token = localStorage.getItem('access_token');
const token = getToken();
const API_BASE_URL = (import.meta.env.VITE_API_URL || '').replace(/\/+$/, '');
const response = await fetch(`${API_BASE_URL}/v1/a76/company/${id}/upload-certificate?certificate_type=${type}`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
},
headers: token ? { Authorization: `Bearer ${token}` } : {},
body: formData,
credentials: 'include'
});

View File

@@ -124,7 +124,9 @@ export interface InvoiceLogistics {
id?: number;
invoice_id?: number;
carrier_id?: string | null;
carrier_int_id?: number | null;
transport_id?: string | null;
transport_int_id?: number | null;
transport_us_id?: string | null;
transport_type?: TransportType | null;
transport_num?: string | null;
@@ -136,6 +138,7 @@ export interface InvoiceLogistics {
license_plate?: string | null;
license_plate_complete?: string | null;
trailer_num?: string | null;
trailer_int_id?: number | null;
seal_number?: string | null;
guide_number?: string | null;
bill_number?: string | null;

View File

@@ -2,6 +2,7 @@ import { api, type ApiResponse } from '$lib/api';
export interface Trailer {
trailer_number: string;
trailer_id?: number;
ace_trailer_number?: string;
trailer_type_key?: string;
seal?: string;

View File

@@ -2,6 +2,7 @@ import { api, type ApiResponse } from '$lib/api';
export interface Transporter {
transporter_key: string;
transporter_id?: number;
name?: string;
short_name?: string;
responsible?: string;

View File

@@ -2,6 +2,7 @@ import { api, type ApiResponse } from '$lib/api';
export interface Vehicle {
vehicle_key: string;
vehicle_id?: number;
ace_vehicle_key?: string;
transporter_key?: string;
transport_identifier?: string;