chore: SDK cleanup (#14763)

This commit is contained in:
Erik
2024-04-25 23:22:47 +00:00
committed by GitHub
parent a3a95a1496
commit d02947f887
7 changed files with 13 additions and 18 deletions
+2 -2
View File
@@ -2,9 +2,9 @@ import axios from "axios";
import axiosRetry from "axios-retry";
import { Bookings } from "./endpoints/bookings";
import { ManagedUsers } from "./endpoints/ee/users";
import { Events } from "./endpoints/events";
import { EventTypes } from "./endpoints/events/event-types";
import { ManagedUsers } from "./endpoints/managed-users";
import { OAuthFlow } from "./endpoints/oauth-flow";
import { Schedules } from "./endpoints/schedules";
import { Slots } from "./endpoints/slots";
@@ -24,7 +24,7 @@ export class CalSdk {
schedules: Schedules;
users: ManagedUsers;
private _secrets: SdkSecrets;
private readonly _secrets: SdkSecrets;
constructor(
public readonly clientId: string,
@@ -6,7 +6,7 @@ import { assert } from "ts-essentials";
import type { CalSdk } from "../cal";
export abstract class EndpointHandler {
constructor(private readonly key: string, private readonly calSdk: CalSdk) {}
protected constructor(private readonly key: string, private readonly calSdk: CalSdk) {}
withForAtomParam(forAtom: boolean, config?: AxiosRequestConfig<unknown>) {
if (!forAtom) return config;
@@ -1,7 +1,7 @@
import type { CalSdk } from "../../../cal";
import { Endpoints } from "../../../lib/endpoints";
import type { BasicPlatformResponse, PaginationOptions } from "../../../types";
import { EndpointHandler } from "../../endpoint-handler";
import type { CalSdk } from "../../cal";
import { Endpoints } from "../../lib/endpoints";
import type { BasicPlatformResponse, PaginationOptions } from "../../types";
import { EndpointHandler } from "../endpoint-handler";
import type { CreateUserArgs, CreateUserResponse, User } from "./types";
export class ManagedUsers extends EndpointHandler {
+3 -5
View File
@@ -35,7 +35,9 @@ export class HttpCaller {
private readonly axiosClient: AxiosInstance,
private readonly options?: HttpCallerOptions
) {
this.setupInterceptors();
if (options?.shouldHandleRefresh) {
this.setupInterceptors();
}
}
private async retryQueuedRequests() {
@@ -161,8 +163,4 @@ export class HttpCaller {
params,
});
}
isAwaitingRefresh() {
return this.awaitingRefresh;
}
}
+2 -5
View File
@@ -58,10 +58,7 @@ export class SdkSecrets {
return !!this.accessToken;
}
public _debug() {
return {
refreshedAt: this.refreshedAt,
accessToken: this.accessToken,
};
public getRefreshedAt(): Date | null {
return this.refreshedAt;
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ export enum ApiVersion {
}
export type SdkAuthOptions = {
clientSecret: string;
clientSecret?: string;
accessToken?: string;
refreshToken?: string;
};