Add Linear XLSX initial import

This commit is contained in:
Julian Appel 2026-09-30 09:50:58 +02:00
parent c633e78cd4
commit bfdd048269
20 changed files with 932 additions and 85 deletions

View file

@ -39,6 +39,10 @@ import type {
CircuitTreeResponseDto,
ProjectCircuitTreesResponseDto,
ExternalModelConfigurationSnapshotDto,
ExternalInitialImportPlanDto,
ExternalInitialImportResultDto,
ExternalInitialImportStatusDto,
ApplyExternalInitialImportInput,
CreateEstimateBalanceInput,
EstimateBalanceCommandResultDto,
EstimateBalanceDto,
@ -198,6 +202,40 @@ export async function detectExternalModelWorkbook(
);
}
export function getExternalInitialImportStatus(projectId: string) {
return request<ExternalInitialImportStatusDto>(`/api/projects/${projectId}/external-model/import-status`);
}
export async function planExternalInitialImport(
projectId: string,
file: File,
configuration: ExternalModelConfiguration,
expectedRevision: number
) {
return request<ExternalInitialImportPlanDto>(`/api/projects/${projectId}/external-model/initial-import/plan`, {
method: "POST",
body: JSON.stringify({ fileName: file.name, contentBase64: await fileToBase64(file), configuration, expectedRevision }),
});
}
export async function applyExternalInitialImport(
projectId: string,
file: File,
input: Omit<ApplyExternalInitialImportInput, "fileName" | "contentBase64">
) {
return request<ExternalInitialImportResultDto>(`/api/projects/${projectId}/external-model/initial-import/apply`, {
method: "POST",
body: JSON.stringify({ ...input, fileName: file.name, contentBase64: await fileToBase64(file) }),
});
}
async function fileToBase64(file: File) {
const bytes = new Uint8Array(await file.arrayBuffer());
let binary = "";
for (const byte of bytes) binary += String.fromCharCode(byte);
return btoa(binary);
}
export function getProjectHistory(projectId: string) {
return request<ProjectHistoryStateDto>(
`/api/projects/${projectId}/history`