forked from jappel/leistungsbilanz-ts
Harden Linear XLSX end to end
This commit is contained in:
parent
2581beee3c
commit
4ff01b2ccd
26 changed files with 522 additions and 246 deletions
|
|
@ -20,6 +20,7 @@ import { projects } from "../schema/projects.js";
|
|||
import { rooms } from "../schema/rooms.js";
|
||||
import { executeProjectCommandTransaction } from "./project-command-transaction.persistence.js";
|
||||
import { ExternalModelStateRepository } from "./external-model-state.repository.js";
|
||||
import { insertManyInBatches } from "./batched-insert.persistence.js";
|
||||
|
||||
export class ExternalInitialImportProjectCommandRepository implements ExternalInitialImportProjectCommandStore {
|
||||
constructor(private readonly database: AppDatabase) {}
|
||||
|
|
@ -76,9 +77,9 @@ function replaceState(database: AppDatabase, projectId: string, target: External
|
|||
database.delete(externalModelSources).where(eq(externalModelSources.projectId, projectId)).run();
|
||||
if (!target.source) return;
|
||||
database.insert(externalModelSources).values(target.source).run();
|
||||
database.insert(externalImportBatches).values(target.importBatches.map(({ originalContentBase64, ...batch }) => ({ ...batch, originalBytes: originalContentBase64 === null ? null : Buffer.from(originalContentBase64, "base64") }))).run();
|
||||
if (target.roomMappings.length) database.insert(externalRoomMappings).values(target.roomMappings).run();
|
||||
if (target.objects.length) database.insert(externalModelObjects).values(target.objects).run();
|
||||
insertManyInBatches(database, externalImportBatches, target.importBatches.map(({ originalContentBase64, ...batch }) => ({ ...batch, originalBytes: originalContentBase64 === null ? null : Buffer.from(originalContentBase64, "base64") })));
|
||||
insertManyInBatches(database, externalRoomMappings, target.roomMappings);
|
||||
insertManyInBatches(database, externalModelObjects, target.objects);
|
||||
}
|
||||
|
||||
function decodeCanonicalBase64(value: string) { const bytes = Buffer.from(value, "base64"); if (bytes.toString("base64") !== value) throw new Error("Der XLSX-Inhalt ist nicht kanonisch Base64-kodiert."); return bytes; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue