( organizationId: string | null, projectId: string, gitBranch: string, baseUrl: string, authToken: string )
| 162 | } |
| 163 | |
| 164 | async function fetchManifest( |
| 165 | organizationId: string | null, |
| 166 | projectId: string, |
| 167 | gitBranch: string, |
| 168 | baseUrl: string, |
| 169 | authToken: string |
| 170 | ): Promise<ManifestResponse> { |
| 171 | const url = new URL(`${baseUrl}/api/code-indexing/manifest`); |
| 172 | if (organizationId) url.searchParams.set('organizationId', organizationId); |
| 173 | url.searchParams.set('projectId', projectId); |
| 174 | url.searchParams.set('gitBranch', gitBranch); |
| 175 | |
| 176 | const response = await fetch(url.toString(), { |
| 177 | method: 'GET', |
| 178 | headers: { |
| 179 | Authorization: `Bearer ${authToken}`, |
| 180 | }, |
| 181 | }); |
| 182 | |
| 183 | if (!response.ok) { |
| 184 | // If manifest doesn't exist yet (404), return empty manifest |
| 185 | if (response.status === 404 || response.status === 400) { |
| 186 | return { |
| 187 | organizationId, |
| 188 | projectId, |
| 189 | gitBranch, |
| 190 | files: {}, |
| 191 | totalFiles: 0, |
| 192 | lastUpdated: new Date().toISOString(), |
| 193 | }; |
| 194 | } |
| 195 | const errorData = await response.json().catch(() => ({ error: 'Unknown error' })); |
| 196 | throw new Error(errorData.error || errorData.message || `HTTP ${response.status}`); |
| 197 | } |
| 198 | |
| 199 | return response.json() as Promise<ManifestResponse>; |
| 200 | } |
| 201 | |
| 202 | async function performSearch( |
| 203 | query: string, |
no test coverage detected