Skip to content

Scheduling infrastructure for absolutely everyone.

chore: SDK cleanup (#14763)

Erikd02947f88713
diff --git a/packages/platform/sdk/src/cal.ts b/packages/platform/sdk/src/cal.ts
index 14669427f2b..bf27f4a26f5 100644
--- a/packages/platform/sdk/src/cal.ts
+++ b/packages/platform/sdk/src/cal.ts
@@ -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,
diff --git a/packages/platform/sdk/src/endpoints/endpoint-handler.ts b/packages/platform/sdk/src/endpoints/endpoint-handler.ts
index 9d5723a2b60..caf7680c7a8 100644
--- a/packages/platform/sdk/src/endpoints/endpoint-handler.ts
+++ b/packages/platform/sdk/src/endpoints/endpoint-handler.ts
@@ -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;
diff --git a/packages/platform/sdk/src/endpoints/ee/users/index.ts b/packages/platform/sdk/src/endpoints/managed-users/index.ts
similarity index 88%
rename from packages/platform/sdk/src/endpoints/ee/users/index.ts
rename to packages/platform/sdk/src/endpoints/managed-users/index.ts
index a78389fee19..3d35789f1dd 100644
--- a/packages/platform/sdk/src/endpoints/ee/users/index.ts
+++ b/packages/platform/sdk/src/endpoints/managed-users/index.ts
@@ -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 {
diff --git a/packages/platform/sdk/src/endpoints/ee/users/types.ts b/packages/platform/sdk/src/endpoints/managed-users/types.ts
similarity index 100%
rename from packages/platform/sdk/src/endpoints/ee/users/types.ts
rename to packages/platform/sdk/src/endpoints/managed-users/types.ts
diff --git a/packages/platform/sdk/src/lib/http-caller.ts b/packages/platform/sdk/src/lib/http-caller.ts
index bea196cfc91..c55bb7f33c9 100644
--- a/packages/platform/sdk/src/lib/http-caller.ts
+++ b/packages/platform/sdk/src/lib/http-caller.ts
@@ -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;
- }
}
diff --git a/packages/platform/sdk/src/lib/sdk-secrets.ts b/packages/platform/sdk/src/lib/sdk-secrets.ts
index babe6be7e72..44059e29a40 100644
--- a/packages/platform/sdk/src/lib/sdk-secrets.ts
+++ b/packages/platform/sdk/src/lib/sdk-secrets.ts
@@ -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;
}
}
diff --git a/packages/platform/sdk/src/types.ts b/packages/platform/sdk/src/types.ts
index c98c8543fc9..4677cf342dd 100644
--- a/packages/platform/sdk/src/types.ts
+++ b/packages/platform/sdk/src/types.ts
@@ -22,7 +22,7 @@ export enum ApiVersion {
}
export type SdkAuthOptions = {
- clientSecret: string;
+ clientSecret?: string;
accessToken?: string;
refreshToken?: string;
};