Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/client/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ApiClient {

export interface BugSplatResponse<T = unknown> {
status: number;
body: ReadableStream<Uint8Array> | null;
json: () => Promise<T>;
text: () => Promise<string>;
}
2 changes: 2 additions & 0 deletions src/common/client/bugsplat-api-client/bugsplat-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ export class BugSplatApiClient implements ApiClient {
const url = new URL(route, this._host);
const response = await this._fetch(url.href, init);
const status = response.status;
const body = response.body;

return {
status,
body,
json: async () => response.clone().json(),
text: async () => response.clone().text()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ export class OAuthClientCredentialsClient implements ApiClient {

const response = await this._fetch(url.href, init);
const status = response.status;
const body = response.body;

if (status === 401) {
throw new Error('Could not authenticate, check credentials and try again');
}

return {
status,
body,
json: async () => response.clone().json(),
text: async () => response.clone().text()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ export class TableDataClient {
const pageData = responseData ? responseData[0]?.PageData : {};

const status = response.status;
const body = response.body;
const payload = { rows, pageData } as TableDataResponse<T, U>;
const json = async () => payload;
const text = async () => JSON.stringify(payload);
return {
status,
body,
json,
text
};
Expand Down
2 changes: 2 additions & 0 deletions src/summary/summary-table-data/summary-table-data-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ export class SummaryTableDataClient {
const rows = responseData ? responseData[0]?.Rows : [];
const pageData = responseData ? responseData[0]?.PageData : {};

const body = response.body;
const status = response.status;
const payload = { rows, pageData };
const json = async () => payload;
const text = async () => JSON.stringify(payload);
return {
status,
body,
json,
text
};
Expand Down