@shapediver/sdk.geometry-api-sdk-v2
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -0,8 +1,14 @@ | ||
import { RawAxiosRequestConfig } from 'axios'; | ||
import { Configuration as ClientConfig, ConfigurationParameters as ClientConfigParams } from './client/configuration'; | ||
export interface ConfigurationParameters extends ClientConfigParams { | ||
export interface ConfigurationParameters extends Pick<ClientConfigParams, 'accessToken' | 'basePath'> { | ||
baseOptions?: RawAxiosRequestConfig; | ||
useCustomAxios?: boolean; | ||
maxRetries?: number; | ||
} | ||
export declare class Configuration extends ClientConfig { | ||
protected readonly sdkVersion = "2.0.1"; | ||
protected readonly sdkVersion = "2.1.0"; | ||
readonly useCustomAxios: boolean; | ||
readonly maxRetries: number; | ||
constructor(param?: ConfigurationParameters); | ||
} | ||
//# sourceMappingURL=configuration.d.ts.map |
@@ -7,7 +7,9 @@ "use strict"; | ||
constructor(param = {}) { | ||
var _a, _b; | ||
var _a, _b, _c, _d; | ||
super(param); | ||
this.sdkVersion = '2.0.1'; | ||
this.baseOptions = (_a = this.baseOptions) !== null && _a !== void 0 ? _a : {}; | ||
this.baseOptions.headers = (_b = this.baseOptions.headers) !== null && _b !== void 0 ? _b : {}; | ||
this.sdkVersion = '2.1.0'; | ||
this.useCustomAxios = (_a = param.useCustomAxios) !== null && _a !== void 0 ? _a : true; | ||
this.maxRetries = (_b = param.maxRetries) !== null && _b !== void 0 ? _b : 5; | ||
this.baseOptions = (_c = this.baseOptions) !== null && _c !== void 0 ? _c : {}; | ||
this.baseOptions.headers = (_d = this.baseOptions.headers) !== null && _d !== void 0 ? _d : {}; | ||
const userAgent = `sd-sdk/typescript/${this.sdkVersion}`; | ||
@@ -14,0 +16,0 @@ if (typeof process === 'object' && !this.baseOptions.headers['User-Agent']) { |
@@ -6,7 +6,22 @@ import { AxiosInstance, AxiosPromise, RawAxiosRequestConfig } from 'axios'; | ||
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance); | ||
upload(url: string, data: string | Record<string, any> | ArrayBuffer | File, contentType: string, filename?: string, options?: RawAxiosRequestConfig): AxiosPromise<unknown>; | ||
uploadAsset(url: string, data: string | Record<string, any> | ArrayBuffer | File, headers: ResAssetUploadHeaders, options?: RawAxiosRequestConfig): AxiosPromise<unknown>; | ||
download(url: string, options?: RawAxiosRequestConfig): AxiosPromise<File>; | ||
downloadAsset(url: string, options?: RawAxiosRequestConfig): [AxiosPromise<File>, 'export' | 'output' | 'texture']; | ||
downloadImage(sessionId: string, url: string, options?: RawAxiosRequestConfig): AxiosPromise<File>; | ||
upload(url: string, data: any, contentType: string, filename?: string, options?: RawAxiosRequestConfig): AxiosPromise<unknown>; | ||
uploadAsset(url: string, data: any, headers: ResAssetUploadHeaders, options?: RawAxiosRequestConfig): AxiosPromise<unknown>; | ||
download(url: string, options: { | ||
responseType: 'arraybuffer' | 'blob'; | ||
} & RawAxiosRequestConfig): AxiosPromise<File>; | ||
download(url: string, options: { | ||
responseType: 'json'; | ||
} & RawAxiosRequestConfig): AxiosPromise<Record<string, unknown>>; | ||
download(url: string, options: { | ||
responseType: 'text'; | ||
} & RawAxiosRequestConfig): AxiosPromise<string>; | ||
download(url: string, options?: RawAxiosRequestConfig): AxiosPromise<unknown>; | ||
downloadAsset(url: string, options: { | ||
responseType: 'arraybuffer' | 'blob'; | ||
} & RawAxiosRequestConfig): [AxiosPromise<File>, 'export' | 'output' | 'texture']; | ||
downloadAsset(url: string, options?: RawAxiosRequestConfig): [AxiosPromise<unknown>, 'export' | 'output' | 'texture']; | ||
downloadImage(sessionId: string, url: string, options: { | ||
responseType: 'arraybuffer' | 'blob'; | ||
} & RawAxiosRequestConfig): AxiosPromise<File>; | ||
downloadImage(sessionId: string, url: string, options?: RawAxiosRequestConfig): AxiosPromise<unknown>; | ||
submitAndWaitForOutput(sessionId: string, body: ReqCustomization, maxWaitMsec?: number, options?: RawAxiosRequestConfig): Promise<ResComputeOutputs>; | ||
@@ -13,0 +28,0 @@ submitAndWaitForExport(sessionId: string, body: ReqExport, maxWaitMsec?: number, options?: RawAxiosRequestConfig): Promise<ResComputeExports>; |
@@ -172,4 +172,7 @@ "use strict"; | ||
} | ||
const configuration = this.configuration && url.startsWith('http') | ||
? new client_1.Configuration(Object.assign(Object.assign({}, this.configuration), { basePath: undefined })) | ||
: this.configuration; | ||
const axiosArgs = { url, options: reqOptions }; | ||
return (0, common_1.createRequestFunction)(axiosArgs, this.axios, basePath, this.configuration).bind(this.axios); | ||
return (0, common_1.createRequestFunction)(axiosArgs, this.axios, basePath, configuration).bind(this.axios); | ||
}; | ||
@@ -176,0 +179,0 @@ } |
{ | ||
"name": "@shapediver/sdk.geometry-api-sdk-v2", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "SDK to communicate with the Geometry API version 2", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -0,1 +1,2 @@ | ||
import { RawAxiosRequestConfig } from 'axios'; | ||
import { | ||
@@ -6,9 +7,41 @@ Configuration as ClientConfig, | ||
export interface ConfigurationParameters extends ClientConfigParams {} | ||
export interface ConfigurationParameters | ||
extends Pick<ClientConfigParams, 'accessToken' | 'basePath'> { | ||
/** | ||
* Base options for Axios calls. | ||
* | ||
* @type {RawAxiosRequestConfig} | ||
* @memberof ConfigurationParameters | ||
*/ | ||
baseOptions?: RawAxiosRequestConfig; | ||
/** | ||
* Enables the use of a custom Axios instance for all API requests by default, instead of the | ||
* global Axios instance. This custom instance includes additional functionality to | ||
* automatically retry requests on `429` and `502` status codes. | ||
* | ||
* Default: `true`. | ||
*/ | ||
useCustomAxios?: boolean; | ||
/** | ||
* Specifies the maximum number of automatic HTTP retries for failed requests. | ||
* | ||
* **Note:** This setting is only applicable when using a custom Axios instance. | ||
* | ||
* Default: `5` | ||
*/ | ||
maxRetries?: number; | ||
} | ||
export class Configuration extends ClientConfig { | ||
protected readonly sdkVersion = '2.0.1'; // WARNING: This value is updated automatically! | ||
protected readonly sdkVersion = '2.1.0'; // WARNING: This value is updated automatically! | ||
public readonly useCustomAxios: boolean; | ||
public readonly maxRetries: number; | ||
constructor(param: ConfigurationParameters = {}) { | ||
super(param); | ||
this.useCustomAxios = param.useCustomAxios ?? true; | ||
this.maxRetries = param.maxRetries ?? 5; | ||
@@ -15,0 +48,0 @@ this.baseOptions = this.baseOptions ?? {}; |
@@ -45,3 +45,3 @@ import { AxiosInstance, AxiosPromise, RawAxiosRequestConfig, RawAxiosRequestHeaders } from 'axios'; | ||
* @param {string} url The target URL of the upload request. | ||
* @param {string | Record<string, any> | ArrayBuffer | File} data The data that should be uploaded. Warning: Type `File` in Node.js might lead to problems! | ||
* @param {*} data The data that should be uploaded. | ||
* @param {string} contentType Indicate the original media type of the resource. | ||
@@ -53,3 +53,3 @@ * @param {string} [filename] The name of the file to be uploaded. When a filename has been specified in the request-upload call, then the same filename has to be specified for the upload as well. | ||
url: string, | ||
data: string | Record<string, any> | ArrayBuffer | File, | ||
data: any, | ||
contentType: string, | ||
@@ -76,3 +76,3 @@ filename?: string, | ||
* @param {string} url The target URL of the upload request. | ||
* @param {string | Record<string, any> | ArrayBuffer | File} data The data that should be uploaded. Warning: Type `File` in Node.js might lead to problems! | ||
* @param {*} data The data that should be uploaded. | ||
* @param {ResAssetUploadHeaders} headers The headers object that was returned from the request-upload call. | ||
@@ -83,3 +83,3 @@ * @param {*} [options] Override http request option. | ||
url: string, | ||
data: string | Record<string, any> | ArrayBuffer | File, | ||
data: any, | ||
headers: ResAssetUploadHeaders, | ||
@@ -105,6 +105,21 @@ options?: RawAxiosRequestConfig | ||
* Download from the specified URL. | ||
* | ||
* The response type can be controlled by setting the `responseType` in the `options` object. | ||
* @param {string} url The target URL of the download request. | ||
* @param {*} [options] Override http request option. | ||
*/ | ||
public download(url: string, options?: RawAxiosRequestConfig): AxiosPromise<File> { | ||
public download( | ||
url: string, | ||
options: { responseType: 'arraybuffer' | 'blob' } & RawAxiosRequestConfig | ||
): AxiosPromise<File>; | ||
public download( | ||
url: string, | ||
options: { responseType: 'json' } & RawAxiosRequestConfig | ||
): AxiosPromise<Record<string, unknown>>; | ||
public download( | ||
url: string, | ||
options: { responseType: 'text' } & RawAxiosRequestConfig | ||
): AxiosPromise<string>; | ||
public download(url: string, options?: RawAxiosRequestConfig): AxiosPromise<unknown>; | ||
public download(url: string, options?: RawAxiosRequestConfig): AxiosPromise<unknown> { | ||
const request = this.buildRequest('GET', url, undefined, options)(); | ||
@@ -117,2 +132,4 @@ return request(); | ||
* the asset is determined by the URL and returned with the promise. | ||
* | ||
* The response type can be controlled by setting the `responseType` in the `options` object. | ||
* @param {string} url The URL of the asset to download. | ||
@@ -124,4 +141,12 @@ * @param {*} [options] Override http request option. | ||
url: string, | ||
options: { responseType: 'arraybuffer' | 'blob' } & RawAxiosRequestConfig | ||
): [AxiosPromise<File>, 'export' | 'output' | 'texture']; | ||
public downloadAsset( | ||
url: string, | ||
options?: RawAxiosRequestConfig | ||
): [AxiosPromise<File>, 'export' | 'output' | 'texture'] { | ||
): [AxiosPromise<unknown>, 'export' | 'output' | 'texture']; | ||
public downloadAsset( | ||
url: string, | ||
options?: RawAxiosRequestConfig | ||
): [AxiosPromise<unknown>, 'export' | 'output' | 'texture'] { | ||
let type: 'output' | 'export' | 'texture'; | ||
@@ -140,3 +165,3 @@ this.disableAuthHeaderForShapeDiverUris(url, options); | ||
return [this.download(url, options), type]; | ||
return [this.download(url, options) as any, type]; | ||
} | ||
@@ -147,2 +172,4 @@ | ||
* URLs to the `AssetsApi.downloadImage` endpoint to avoid CORS issues. | ||
* | ||
* The response type can be controlled by setting the `responseType` in the `options` object. | ||
* @param {string} sessionId The session ID. | ||
@@ -155,4 +182,14 @@ * @param {string} url The URL of the image to download. | ||
url: string, | ||
options: { responseType: 'arraybuffer' | 'blob' } & RawAxiosRequestConfig | ||
): AxiosPromise<File>; | ||
public downloadImage( | ||
sessionId: string, | ||
url: string, | ||
options?: RawAxiosRequestConfig | ||
): AxiosPromise<File> { | ||
): AxiosPromise<unknown>; | ||
public downloadImage( | ||
sessionId: string, | ||
url: string, | ||
options?: RawAxiosRequestConfig | ||
): AxiosPromise<unknown> { | ||
this.disableAuthHeaderForShapeDiverUris(url, options); | ||
@@ -166,3 +203,3 @@ | ||
// Call ShapeDiver texture-asset URLs directly | ||
return this.download(url, options); | ||
return this.download(url, options) as any; | ||
} else { | ||
@@ -385,4 +422,10 @@ // All other source URLs are called via the download-image endpoint | ||
// Remove the base path configuration if the URL is a full URL. | ||
const configuration = | ||
this.configuration && url.startsWith('http') | ||
? new Configuration({ ...this.configuration, basePath: undefined }) | ||
: this.configuration; | ||
const axiosArgs: RequestArgs = { url, options: reqOptions }; | ||
return createRequestFunction(axiosArgs, this.axios, basePath, this.configuration).bind( | ||
return createRequestFunction(axiosArgs, this.axios, basePath, configuration).bind( | ||
this.axios | ||
@@ -389,0 +432,0 @@ ); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1235925
58
20755