import axios from 'axios';
const api = axios.create({
baseURL: '/api',
});
// Repos API
export const reposApi = {
list: () => api.get('/repos'),
getRefs: (repo: string) => api.get(`/repos/${repo}/refs`),
getVersions: (repo: string) => api.get(`/repos/${repo}/versions`),
};
// Extraction API
export const extractionApi = {
extract: (repo: string, ref: string, force?: boolean) =>
api.post('/extract', { repo, ref, force }),
extractAll: (options?: { force?: boolean; repos?: string; shallow?: boolean; refs?: string }) =>
api.post('/extract/all', options),
getStatus: (jobId: string) => api.get(`/extract/status/${jobId}`),
};
// Query API
export const queryApi = {
nips: () => api.get('/query/nips'),
flows: () => api.get('/query/flows'),
types: (params?: { repo?: string; name?: string; kind?: string; limit?: number }) =>
api.get('/query/types', { params }),
sharedTypes: (params?: { minSimilarity?: number; limit?: number }) =>
api.get('/query/shared-types', { params }),
dataFlow: () => api.get('/query/data-flow'),
};
// Diagram API
export const diagramApi = {
generate: (repo?: string) => api.get('/diagrams', { params: { repo } }),
generateC4: (params?: { repo?: string; type?: string; detailed?: boolean; export?: boolean }) =>
api.get('/diagrams/c4', { params }),
generateNipFlow: (params?: { eventKind?: number; format?: 'flowchart' | 'sequence' }) =>
api.get('/diagrams/nip-flow', { params }),
};
// Comparison API
export const comparisonApi = {
prImpact: (repo: string, fromRef: string, toRef: string) =>
api.post('/pr-impact', { repo, from_ref: fromRef, to_ref: toRef }),
diff: (fromRef: string, toRef: string, repo?: string, extractor?: string) =>
api.post('/diff', { from_ref: fromRef, to_ref: toRef, repo, extractor }),
staleDeps: (params?: { minSimilarity?: number; focusRepo?: string }) =>
api.get('/stale-deps', { params }),
};
// Health API
export const healthApi = {
check: () => api.get('/health'),
};