(queryParams: ListCommitsQueryParams)
| 141 | } |
| 142 | |
| 143 | export const listCommits = async (queryParams: ListCommitsQueryParams): Promise<ListCommitsResponse | ServiceError> => { |
| 144 | const url = new URL("/api/commits", window.location.origin); |
| 145 | for (const [key, value] of Object.entries(queryParams)) { |
| 146 | if (value !== undefined && value !== '') { |
| 147 | url.searchParams.set(key, value.toString()); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | const response = await fetch(url, { |
| 152 | method: "GET", |
| 153 | headers: { |
| 154 | "X-Sourcebot-Client-Source": "sourcebot-web-client", |
| 155 | }, |
| 156 | }); |
| 157 | |
| 158 | const result = await response.json(); |
| 159 | if (isServiceError(result)) { |
| 160 | return result; |
| 161 | } |
| 162 | |
| 163 | const totalCount = parseInt(response.headers.get('X-Total-Count') ?? '0', 10); |
| 164 | return { commits: result as Commit[], totalCount }; |
| 165 | } |
| 166 | |
| 167 | export const getFiles = async (body: GetFilesRequest): Promise<GetFilesResponse | ServiceError> => { |
| 168 | const result = await fetch("/api/files", { |
no test coverage detected