({
spinner,
path,
endpointId,
endpointHandlerUrl,
resolvedOptions,
apiClient,
}: RefreshOptions & { apiClient: TriggerApi })
| 285 | } |
| 286 | |
| 287 | async function startIndexing({ |
| 288 | spinner, |
| 289 | path, |
| 290 | endpointId, |
| 291 | endpointHandlerUrl, |
| 292 | resolvedOptions, |
| 293 | apiClient, |
| 294 | }: RefreshOptions & { apiClient: TriggerApi }) { |
| 295 | spinner.start(); |
| 296 | const refreshedEndpointId = await getEndpointId(runtime, resolvedOptions.clientId); |
| 297 | |
| 298 | const authorizedKey = await apiClient.whoami(); |
| 299 | if (!authorizedKey) { |
| 300 | telemetryClient.dev.failed("invalid_api_key", resolvedOptions); |
| 301 | throw new AbortError( |
| 302 | "[trigger.dev] The API key you provided is not authorized. Try visiting your dashboard to get a new API key." |
| 303 | ); |
| 304 | } |
| 305 | |
| 306 | telemetryClient.identify( |
| 307 | authorizedKey.organization.id, |
| 308 | authorizedKey.project.id, |
| 309 | authorizedKey.userId |
| 310 | ); |
| 311 | |
| 312 | const result = await refreshEndpoint( |
| 313 | apiClient, |
| 314 | refreshedEndpointId ?? endpointId, |
| 315 | endpointHandlerUrl |
| 316 | ); |
| 317 | |
| 318 | if (!result.success) { |
| 319 | throw new Error(result.error); |
| 320 | } |
| 321 | |
| 322 | return { id: result.data.endpointIndex?.id, updatedAt: new Date(result.data.updatedAt) }; |
| 323 | } |
| 324 | |
| 325 | async function fetchIndexResult({ |
| 326 | indexId, |
no test coverage detected
searching dependent graphs…