refactor: rename customOptions to clientOptions
This commit is contained in:
parent
5bc2915655
commit
1eb9ebbdf8
|
@ -74,10 +74,14 @@ export class S5Client {
|
||||||
throwValidationError("portalUrl", portalUrl, "parameter", "string");
|
throwValidationError("portalUrl", portalUrl, "parameter", "string");
|
||||||
}
|
}
|
||||||
this._portalUrl = ensureUrl(portalUrl);
|
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 {
|
get customOptions(): CustomClientOptions {
|
||||||
return this._customOptions;
|
return this._customOptions;
|
||||||
|
|
|
@ -7,7 +7,7 @@ export async function accountPins(
|
||||||
customOptions: CustomClientOptions = {},
|
customOptions: CustomClientOptions = {},
|
||||||
): Promise<AccountPinsResponse> {
|
): Promise<AccountPinsResponse> {
|
||||||
const opts = {
|
const opts = {
|
||||||
...this.customOptions,
|
...this.clientOptions,
|
||||||
...customOptions,
|
...customOptions,
|
||||||
...{
|
...{
|
||||||
endpointPath: "/s5/account/pins",
|
endpointPath: "/s5/account/pins",
|
||||||
|
|
|
@ -52,7 +52,7 @@ const DEFAULT_GET_METADATA_OPTIONS = {};
|
||||||
* Initiates a download of the content of the cid within the browser.
|
* Initiates a download of the content of the cid within the browser.
|
||||||
*
|
*
|
||||||
* @param this - S5Client
|
* @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] - Additional settings that can optionally be set.
|
||||||
* @param [customOptions.endpointDownload="/"] - The relative URL path of the portal endpoint to contact.
|
* @param [customOptions.endpointDownload="/"] - The relative URL path of the portal endpoint to contact.
|
||||||
* @returns - The full URL that was used.
|
* @returns - The full URL that was used.
|
||||||
|
@ -86,7 +86,7 @@ export async function getCidUrl(
|
||||||
cid: string,
|
cid: string,
|
||||||
customOptions: CustomDownloadOptions = {},
|
customOptions: CustomDownloadOptions = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const opt = { ...this.customOptions, customOptions };
|
const opt = { ...this.clientOptions, customOptions };
|
||||||
return addUrlQuery(path.join(this.portalUrl, cid), {
|
return addUrlQuery(path.join(this.portalUrl, cid), {
|
||||||
auth_token: opt.apiKey,
|
auth_token: opt.apiKey,
|
||||||
});
|
});
|
||||||
|
@ -132,7 +132,7 @@ export async function downloadData(
|
||||||
): Promise<ArrayBuffer> {
|
): Promise<ArrayBuffer> {
|
||||||
const opts = {
|
const opts = {
|
||||||
...DEFAULT_DOWNLOAD_OPTIONS,
|
...DEFAULT_DOWNLOAD_OPTIONS,
|
||||||
...this.customOptions,
|
...this.clientOptions,
|
||||||
...customOptions,
|
...customOptions,
|
||||||
download: true,
|
download: true,
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,7 +58,7 @@ export async function subscribeToEntry(
|
||||||
) {
|
) {
|
||||||
const opts = {
|
const opts = {
|
||||||
...DEFAULT_SUBSCRIBE_ENTRY_OPTIONS,
|
...DEFAULT_SUBSCRIBE_ENTRY_OPTIONS,
|
||||||
...this.customOptions,
|
...this.clientOptions,
|
||||||
...customOptions,
|
...customOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ export async function uploadFile(
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const opts = {
|
const opts = {
|
||||||
...DEFAULT_UPLOAD_OPTIONS,
|
...DEFAULT_UPLOAD_OPTIONS,
|
||||||
...this.customOptions,
|
...this.clientOptions,
|
||||||
...customOptions,
|
...customOptions,
|
||||||
} as CustomUploadOptions;
|
} as CustomUploadOptions;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ export function optionsToConfig(
|
||||||
|
|
||||||
const finalOptions = {
|
const finalOptions = {
|
||||||
...def,
|
...def,
|
||||||
...client.customOptions,
|
...client.clientOptions,
|
||||||
...extraOptions,
|
...extraOptions,
|
||||||
} as CustomClientOptions;
|
} as CustomClientOptions;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue