feat: add import execution api
This commit is contained in:
@@ -160,6 +160,26 @@ export type CreateRawArtifact = {
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
export type ImportExecutionRequest = {
|
||||
template_name: string;
|
||||
run_id: number;
|
||||
raw_artifact_id: number;
|
||||
rows: Record<string, string | number | null>[];
|
||||
allow_reimport?: boolean;
|
||||
};
|
||||
|
||||
export type ImportExecutionResponse = {
|
||||
template_name: string;
|
||||
target_table: string;
|
||||
run_id: number;
|
||||
raw_artifact_id: number;
|
||||
row_count: number;
|
||||
raw_row_count: number;
|
||||
duplicate_artifact: boolean;
|
||||
previous_run_ids: number[];
|
||||
status: string;
|
||||
};
|
||||
|
||||
const API_BASE_URL =
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL?.replace(/\/$/, "") ?? "http://127.0.0.1:8080";
|
||||
|
||||
@@ -237,6 +257,15 @@ export async function createRawArtifact(payload: CreateRawArtifact): Promise<Raw
|
||||
});
|
||||
}
|
||||
|
||||
export async function executeImport(
|
||||
payload: ImportExecutionRequest,
|
||||
): Promise<ImportExecutionResponse> {
|
||||
return fetchJson("/api/v1/imports/execute", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchJson<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
...init,
|
||||
|
||||
Reference in New Issue
Block a user