summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib/api.ts
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
-rw-r--r--makima/frontend/src/lib/api.ts89
1 files changed, 85 insertions, 4 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index d68c1ad..2f4ee62 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -3025,6 +3025,20 @@ export interface ChainSummary {
updatedAt: string;
}
+/** Chain repository */
+export interface ChainRepository {
+ id: string;
+ chainId: string;
+ name: string;
+ repositoryUrl: string | null;
+ localPath: string | null;
+ sourceType: string;
+ status: string;
+ isPrimary: boolean;
+ createdAt: string;
+ updatedAt: string;
+}
+
/** Full chain with contracts */
export interface Chain {
id: string;
@@ -3036,8 +3050,6 @@ export interface Chain {
loopMaxIterations: number | null;
loopCurrentIteration: number | null;
loopProgressCheck: string | null;
- repositoryUrl: string | null;
- localPath: string | null;
version: number;
createdAt: string;
updatedAt: string;
@@ -3061,6 +3073,7 @@ export interface ChainContractDetail {
/** Chain with contracts (chain fields are flattened via serde(flatten)) */
export interface ChainWithContracts extends Chain {
contracts: ChainContractDetail[];
+ repositories: ChainRepository[];
}
/** Node in chain graph visualization */
@@ -3105,12 +3118,20 @@ export interface ChainListResponse {
total: number;
}
+/** Add chain repository request */
+export interface AddChainRepositoryRequest {
+ name: string;
+ repositoryUrl?: string;
+ localPath?: string;
+ sourceType?: string;
+ isPrimary?: boolean;
+}
+
/** Create chain request */
export interface CreateChainRequest {
name: string;
description?: string;
- repositoryUrl?: string;
- localPath?: string;
+ repositories?: AddChainRepositoryRequest[];
loopEnabled?: boolean;
loopMaxIterations?: number;
loopProgressCheck?: string;
@@ -3446,3 +3467,63 @@ export async function stopChain(chainId: string): Promise<{ stopped: boolean; st
}
return res.json();
}
+
+// ============================================================================
+// Chain Repository Operations
+// ============================================================================
+
+/** List repositories for a chain */
+export async function listChainRepositories(chainId: string): Promise<ChainRepository[]> {
+ const res = await authFetch(`${API_BASE}/api/v1/chains/${chainId}/repositories`);
+ if (!res.ok) {
+ throw new Error(`Failed to list chain repositories: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+/** Add a repository to a chain */
+export async function addChainRepository(
+ chainId: string,
+ req: AddChainRepositoryRequest
+): Promise<ChainRepository> {
+ const res = await authFetch(`${API_BASE}/api/v1/chains/${chainId}/repositories`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(req),
+ });
+ if (!res.ok) {
+ const error = await res.json().catch(() => ({ message: res.statusText }));
+ throw new Error(error.message || `Failed to add chain repository: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+/** Delete a repository from a chain */
+export async function deleteChainRepository(
+ chainId: string,
+ repositoryId: string
+): Promise<{ deleted: boolean }> {
+ const res = await authFetch(
+ `${API_BASE}/api/v1/chains/${chainId}/repositories/${repositoryId}`,
+ { method: "DELETE" }
+ );
+ if (!res.ok) {
+ throw new Error(`Failed to delete chain repository: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+/** Set a repository as primary for a chain */
+export async function setChainRepositoryPrimary(
+ chainId: string,
+ repositoryId: string
+): Promise<ChainRepository> {
+ const res = await authFetch(
+ `${API_BASE}/api/v1/chains/${chainId}/repositories/${repositoryId}/primary`,
+ { method: "PUT" }
+ );
+ if (!res.ok) {
+ throw new Error(`Failed to set chain repository as primary: ${res.statusText}`);
+ }
+ return res.json();
+}