Skip to content

Commit c995911

Browse files
committed
feat(sdk): make MermaidChart#baseURL public
1 parent c9ba489 commit c995911

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

packages/sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Add `MermaidChart#createDocument(projectID)` function to create a digram in a project.
1313
- Add `MermaidChart#setDocument(document)` function to update a diagram.
1414
- Add `MermaidChart#deleteDocument(documentID)` function to delete a diagram.
15+
- Add `MermaidChart#baseURL` is now public.
1516

1617
### Fixed
1718

packages/sdk/src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const authorizationURLTimeout = 60_000;
1919

2020
export class MermaidChart {
2121
private clientID: string;
22-
private baseURL!: string;
22+
#baseURL!: string;
2323
private axios!: AxiosInstance;
2424
private oauth!: OAuth2Client;
2525
private pendingStates: Record<string, AuthState> = {};
@@ -39,19 +39,19 @@ export class MermaidChart {
3939
}
4040

4141
public setBaseURL(baseURL: string = defaultBaseURL) {
42-
if (this.baseURL && this.baseURL === baseURL) {
42+
if (this.#baseURL && this.#baseURL === baseURL) {
4343
return;
4444
}
45-
this.baseURL = baseURL;
45+
this.#baseURL = baseURL;
4646
this.accessToken = undefined;
4747
this.oauth = new OAuth2Client({
48-
server: this.baseURL,
48+
server: this.#baseURL,
4949
clientId: this.clientID,
5050
tokenEndpoint: URLS.oauth.token,
5151
authorizationEndpoint: URLS.oauth.authorize,
5252
});
5353
this.axios = defaultAxios.create({
54-
baseURL: this.baseURL,
54+
baseURL: this.#baseURL,
5555
});
5656

5757
this.axios.interceptors.response.use((res: AxiosResponse) => {
@@ -63,6 +63,10 @@ export class MermaidChart {
6363
});
6464
}
6565

66+
get baseURL() {
67+
return this.#baseURL;
68+
}
69+
6670
public async getAuthorizationData({
6771
state,
6872
scope = ['email'],
@@ -193,7 +197,7 @@ export class MermaidChart {
193197
public async getEditURL(
194198
document: Pick<MCDocument, 'documentID' | 'major' | 'minor' | 'projectID'>,
195199
) {
196-
const url = `${this.baseURL}${URLS.diagram(document).edit}`;
200+
const url = `${this.#baseURL}${URLS.diagram(document).edit}`;
197201
return url;
198202
}
199203

0 commit comments

Comments
 (0)