Skip to content

Commit d010711

Browse files
authored
Fix JS WrappedTokenResponse type (#1997)
* Fix JS WrappedTokenResponse type * Fix JS WrappedTokenResponse type * Remove ts-ignore
1 parent 777cc31 commit d010711

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

js/sdk/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "r2r-js",
3-
"version": "0.4.27",
3+
"version": "0.4.28",
44
"description": "",
55
"main": "dist/index.js",
66
"browser": "dist/index.browser.js",

js/sdk/src/r2rClient.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,9 @@ export class r2rClient extends BaseClient {
154154

155155
// Attempt refresh
156156
try {
157-
//@ts-ignore
158157
const refreshResponse = await this.users.refreshAccessToken();
159-
//@ts-ignore
160-
const newAccessToken = refreshResponse.results.accessToken?.token;
161-
//@ts-ignore
162-
const newRefreshToken = refreshResponse.results.refreshToken?.token;
158+
const newAccessToken = refreshResponse.results.accessToken.token;
159+
const newRefreshToken = refreshResponse.results.refreshToken.token;
163160

164161
// set new tokens
165162
this.setTokens(newAccessToken, newRefreshToken);

js/sdk/src/types.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,16 @@ export interface SettingsResponse {
278278

279279
// User types
280280

281+
export type TokenType = "access" | "refresh";
282+
281283
export interface Token {
282-
accessToken: string;
283-
refreshToken: string;
284+
token: string;
285+
tokenType: TokenType;
286+
}
287+
288+
export interface TokenResponse {
289+
accessToken: Token;
290+
refreshToken: Token;
284291
}
285292

286293
export interface User {
@@ -424,7 +431,7 @@ export type WrappedSettingsResponse = ResultsWrapper<SettingsResponse>;
424431
export type WrappedServerStatsResponse = ResultsWrapper<ServerStats>;
425432

426433
// User Responses
427-
export type WrappedTokenResponse = ResultsWrapper<Token>;
434+
export type WrappedTokenResponse = ResultsWrapper<TokenResponse>;
428435
export type WrappedUserResponse = ResultsWrapper<User>;
429436
export type WrappedUsersResponse = PaginatedResultsWrapper<User[]>;
430437
export type WrappedLimitsResponse = ResultsWrapper<LimitsResponse>;

js/sdk/src/v3/clients/collections.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,16 @@ export class CollectionsClient {
328328
* @param name The name of the collection to retrieve.
329329
* @returns A promise that resolves with the collection details.
330330
*/
331-
async retrieveByName(options: { name: string; ownerId?: string }): Promise<WrappedCollectionResponse> {
331+
async retrieveByName(options: {
332+
name: string;
333+
ownerId?: string;
334+
}): Promise<WrappedCollectionResponse> {
332335
const queryParams: Record<string, any> = {};
333336
if (options.ownerId) {
334337
queryParams.owner_id = options.ownerId;
335338
}
336-
return this.client.makeRequest("GET", `collections/name/${options.name}`, { params: queryParams });
339+
return this.client.makeRequest("GET", `collections/name/${options.name}`, {
340+
params: queryParams,
341+
});
337342
}
338343
}

0 commit comments

Comments
 (0)