feat: add import center dashboard
This commit is contained in:
@@ -85,6 +85,52 @@ export type CreateWatchlistItem = {
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
export type DataSource = {
|
||||
source_id: number;
|
||||
name: string;
|
||||
source_type: string;
|
||||
url: string | null;
|
||||
cadence: string | null;
|
||||
reliability: string;
|
||||
notes: string;
|
||||
created_at: string;
|
||||
};
|
||||
|
||||
export type CreateDataSource = {
|
||||
name: string;
|
||||
source_type: string;
|
||||
url?: string;
|
||||
cadence?: string;
|
||||
reliability?: string;
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
export type IngestionRun = {
|
||||
run_id: number;
|
||||
source_id: number | null;
|
||||
source_name: string | null;
|
||||
status: string;
|
||||
started_at: string;
|
||||
finished_at: string | null;
|
||||
raw_uri: string | null;
|
||||
row_count: number | null;
|
||||
error_message: string | null;
|
||||
};
|
||||
|
||||
export type CreateIngestionRun = {
|
||||
source_id?: number;
|
||||
status?: string;
|
||||
raw_uri?: string;
|
||||
row_count?: number;
|
||||
error_message?: string;
|
||||
};
|
||||
|
||||
export type FinishIngestionRun = {
|
||||
status: "succeeded" | "failed";
|
||||
row_count?: number;
|
||||
error_message?: string;
|
||||
};
|
||||
|
||||
const API_BASE_URL =
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL?.replace(/\/$/, "") ?? "http://127.0.0.1:8080";
|
||||
|
||||
@@ -119,6 +165,38 @@ export async function archiveWatchlistItem(id: number): Promise<WatchlistItem> {
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchDataSources(): Promise<DataSource[]> {
|
||||
return fetchJson("/api/v1/data-sources");
|
||||
}
|
||||
|
||||
export async function createDataSource(payload: CreateDataSource): Promise<DataSource> {
|
||||
return fetchJson("/api/v1/data-sources", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchIngestionRuns(): Promise<IngestionRun[]> {
|
||||
return fetchJson("/api/v1/ingestion-runs");
|
||||
}
|
||||
|
||||
export async function createIngestionRun(payload: CreateIngestionRun): Promise<IngestionRun> {
|
||||
return fetchJson("/api/v1/ingestion-runs", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function finishIngestionRun(
|
||||
id: number,
|
||||
payload: FinishIngestionRun,
|
||||
): Promise<IngestionRun> {
|
||||
return fetchJson(`/api/v1/ingestion-runs/${id}/finish`, {
|
||||
method: "PATCH",
|
||||
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