diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index b6afbf8..b48b08f 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -113,6 +113,17 @@ export interface ProposalResponse { branch: string; } +export interface BuildResponse { + status: string; +} + +export interface DryRunBuildResponse { + dataset_name: string; + dataset_version: string; + dry_run: boolean; + rows: DataRow[]; +} + export async function fetchDatasets(): Promise { const body = await apiFetch<{ datasets: DatasetSummary[] }>("/datasets"); return body.datasets; @@ -134,6 +145,40 @@ export function fetchData( ); } +// real build: builds missing timestamps in [start, end] and writes them to the +// db. synchronous server-side, so this can take a while for large ranges +export function triggerBuild( + name: string, + version: string, + start: string, + end: string, +): Promise { + return apiFetch( + `/build/${encodeURIComponent(name)}/${encodeURIComponent(version)}`, + { + method: "POST", + params: { start, end }, + }, + ); +} + +// dry run: rebuilds the whole dependency graph in-memory and returns the +// produced rows; nothing is written to the db +export function dryRunBuild( + name: string, + version: string, + start: string, + end: string, +): Promise { + return apiFetch( + `/build/${encodeURIComponent(name)}/${encodeURIComponent(version)}`, + { + method: "POST", + params: { start, end, "dry-run": "true" }, + }, + ); +} + // nothing is written to the server: the backend validates the submission and // opens a github pr; the dataset goes live after review + merge + restart export function proposeDataset(