import { apiRequestData } from "./http"; export type MigrationRun = { id: string; runType: "employees" | "departments" | "budgets" | "masterdata_validation"; status: string; sourceFilename: string; summaryJson: Record | null; errorJson: Record | null; createdAt: string | null; createdBy: string | null; }; export type CutoverScope = { id: string; scopeType: "department" | "legal_entity" | "domain"; scopeKey: string; enabled: boolean; startsAt: string | null; notes: string | null; createdAt: string | null; updatedAt: string | null; updatedBy: string | null; }; export async function fetchMigrationRuns() { return apiRequestData<{ items: MigrationRun[] }>("/api/migration-runs"); } export async function fetchMigrationRun(id: string) { return apiRequestData<{ item: MigrationRun }>(`/api/migration-runs/${id}`); } export async function dryRunMigration(payload: { runType: MigrationRun["runType"]; file: File }) { const formData = new FormData(); formData.append("runType", payload.runType); formData.append("file", payload.file); return apiRequestData<{ item: MigrationRun }>("/api/migration-runs/dry-run", { method: "POST", body: formData, }); } export async function fetchCutoverScopes() { return apiRequestData<{ items: CutoverScope[] }>("/api/cutover/scopes"); } export async function createCutoverScope(payload: { scopeType: CutoverScope["scopeType"]; scopeKey: string; enabled?: boolean; startsAt?: string | null; notes?: string | null; }) { return apiRequestData<{ item: CutoverScope }>("/api/cutover/scopes", { method: "POST", body: JSON.stringify(payload), }); } export async function updateCutoverScope(id: string, payload: Partial<{ scopeType: CutoverScope["scopeType"]; scopeKey: string; enabled: boolean; startsAt: string | null; notes: string | null; }>) { return apiRequestData<{ item: CutoverScope }>(`/api/cutover/scopes/${id}`, { method: "PATCH", body: JSON.stringify(payload), }); }