-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathapi.ts
More file actions
30 lines (26 loc) · 976 Bytes
/
api.ts
File metadata and controls
30 lines (26 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import config from "../config.js";
import { DOMAINS } from "./domains.js";
export async function getLatestO11YBuildInfo(
buildName: string,
projectName: string,
) {
const buildsUrl = `${DOMAINS.API_OBSERVABILITY}/ext/v1/builds/latest?build_name=${encodeURIComponent(
buildName,
)}&project_name=${encodeURIComponent(projectName)}`;
const buildsResponse = await fetch(buildsUrl, {
headers: {
Authorization: `Basic ${Buffer.from(
`${config.browserstackUsername}:${config.browserstackAccessKey}`,
).toString("base64")}`,
},
});
if (!buildsResponse.ok) {
if (buildsResponse.statusText === "Unauthorized") {
throw new Error(
`Failed to fetch builds: ${buildsResponse.statusText}. Please check if the BrowserStack credentials are correctly configured when installing the MCP server.`,
);
}
throw new Error(`Failed to fetch builds: ${buildsResponse.statusText}`);
}
return buildsResponse.json();
}