From 1a693eeab8a9bfc1a1146bfa7d15ee44e742f32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Brabec?= Date: Tue, 1 Apr 2025 17:38:15 +0200 Subject: [PATCH] Made ApiClient internal methods protected, exposed readonly databaseId --- src/api-client.js | 4 ++-- src/index.d.ts | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api-client.js b/src/api-client.js index 06ee4f6..1ed2f3c 100644 --- a/src/api-client.js +++ b/src/api-client.js @@ -17,7 +17,7 @@ class ApiClient { this.databaseId = databaseId; this.publicToken = publicToken; this.options = options || {}; - this.baseUri = this._getBaseUri(); + this.baseUri = this.getBaseUri(); this.useHttps = 'useHttps' in this.options ? this.options.useHttps : true; this.async = 'async' in this.options ? this.options.async : true; this.future_v6_fetch = 'future_v6_fetch' in this.options ? this.options.future_v6_fetch : false; @@ -40,7 +40,7 @@ class ApiClient { return uri; } - _getBaseUri() { + getBaseUri() { let baseUri = this.options.baseUri; if (this.options.region) { if (baseUri) { diff --git a/src/index.d.ts b/src/index.d.ts index 87504f5..6a4359e 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -123,10 +123,12 @@ declare module 'recombee-js-api-client' { * @param options - Other custom options. */ constructor(databaseId: string, publicToken: string, options?: ApiClientOptions); + public readonly databaseId: string + publicToken: string - _getRegionalBaseUri(region: string): string; + protected _getRegionalBaseUri(region: string): string; - _getBaseUri(): string; + getBaseUri(): string; /** * Send the request to Recombee @@ -142,7 +144,7 @@ declare module 'recombee-js-api-client' { ) // @ts-expect-error private member : Promise; - _signUrl(req_part: string): string; + protected _signUrl(req_part: string): string; } export type Recommendation = {