From 1eb9ebbdf83ac6b058560a82d4bbaff4b2daebe8 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 18 Mar 2024 09:14:34 -0400 Subject: [PATCH] refactor: rename customOptions to clientOptions --- src/client.ts | 8 ++++++-- src/methods/account.ts | 2 +- src/methods/download.ts | 6 +++--- src/methods/registry.ts | 2 +- src/methods/upload.ts | 2 +- src/utils/options.ts | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/client.ts b/src/client.ts index e1a599c..2f82d5d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -74,10 +74,14 @@ export class S5Client { throwValidationError("portalUrl", portalUrl, "parameter", "string"); } this._portalUrl = ensureUrl(portalUrl); - this._customOptions = customOptions; + this._clientOptions = customOptions; } - private _customOptions: CustomClientOptions; + private _clientOptions: CustomClientOptions; + + get clientOptions(): CustomClientOptions { + return this._clientOptions; + } get customOptions(): CustomClientOptions { return this._customOptions; diff --git a/src/methods/account.ts b/src/methods/account.ts index 2d37e36..50489a6 100644 --- a/src/methods/account.ts +++ b/src/methods/account.ts @@ -7,7 +7,7 @@ export async function accountPins( customOptions: CustomClientOptions = {}, ): Promise { const opts = { - ...this.customOptions, + ...this.clientOptions, ...customOptions, ...{ endpointPath: "/s5/account/pins", diff --git a/src/methods/download.ts b/src/methods/download.ts index 8cef3ad..39713ac 100644 --- a/src/methods/download.ts +++ b/src/methods/download.ts @@ -52,7 +52,7 @@ const DEFAULT_GET_METADATA_OPTIONS = {}; * Initiates a download of the content of the cid within the browser. * * @param this - S5Client - * @param cid - 46-character cid, or a valid cid URL. Can be followed by a path. Note that the cid will not be encoded, so if your path might contain special characters, consider using `customOptions.path`. + * @param cid - 46-character cid, or a valid cid URL. Can be followed by a path. Note that the cid will not be encoded, so if your path might contain special characters, consider using `clientOptions.path`. * @param [customOptions] - Additional settings that can optionally be set. * @param [customOptions.endpointDownload="/"] - The relative URL path of the portal endpoint to contact. * @returns - The full URL that was used. @@ -86,7 +86,7 @@ export async function getCidUrl( cid: string, customOptions: CustomDownloadOptions = {}, ): Promise { - const opt = { ...this.customOptions, customOptions }; + const opt = { ...this.clientOptions, customOptions }; return addUrlQuery(path.join(this.portalUrl, cid), { auth_token: opt.apiKey, }); @@ -132,7 +132,7 @@ export async function downloadData( ): Promise { const opts = { ...DEFAULT_DOWNLOAD_OPTIONS, - ...this.customOptions, + ...this.clientOptions, ...customOptions, download: true, }; diff --git a/src/methods/registry.ts b/src/methods/registry.ts index 7b673ff..bfd8c7e 100644 --- a/src/methods/registry.ts +++ b/src/methods/registry.ts @@ -58,7 +58,7 @@ export async function subscribeToEntry( ) { const opts = { ...DEFAULT_SUBSCRIBE_ENTRY_OPTIONS, - ...this.customOptions, + ...this.clientOptions, ...customOptions, }; diff --git a/src/methods/upload.ts b/src/methods/upload.ts index 2c6b278..a2170c6 100644 --- a/src/methods/upload.ts +++ b/src/methods/upload.ts @@ -90,7 +90,7 @@ export async function uploadFile( ): Promise { const opts = { ...DEFAULT_UPLOAD_OPTIONS, - ...this.customOptions, + ...this.clientOptions, ...customOptions, } as CustomUploadOptions; diff --git a/src/utils/options.ts b/src/utils/options.ts index 70ff074..c55f36d 100644 --- a/src/utils/options.ts +++ b/src/utils/options.ts @@ -37,7 +37,7 @@ export function optionsToConfig( const finalOptions = { ...def, - ...client.customOptions, + ...client.clientOptions, ...extraOptions, } as CustomClientOptions;