@shapediver/sdk.geometry-api-sdk-core
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -38,2 +38,4 @@ import { SdkConfigInternal } from "../config/ShapeDiverSdkConfig"; | ||
private static convertErrorResponseData; | ||
private static parseResponse; | ||
head(url: string, options?: Omit<ShapeDiverSdkApiRequestOptions, "responseType">): Promise<[Record<string, any>, number]>; | ||
get<T>(url: string, options?: ShapeDiverSdkApiRequestOptions): Promise<[Record<string, any>, T]>; | ||
@@ -40,0 +42,0 @@ post<T>(url: string, data?: any, options?: ShapeDiverSdkApiRequestOptions): Promise<[Record<string, any>, T]>; |
@@ -18,2 +18,3 @@ "use strict"; | ||
const ShapeDiverErrors_1 = require("../ShapeDiverErrors"); | ||
const utils_1 = require("../utils"); | ||
var Method; | ||
@@ -23,2 +24,3 @@ (function (Method) { | ||
Method["GET"] = "GET"; | ||
Method["HEAD"] = "HEAD"; | ||
Method["PATCH"] = "PATCH"; | ||
@@ -145,2 +147,29 @@ Method["POST"] = "POST"; | ||
} | ||
static parseResponse(data, requestedType) { | ||
switch (requestedType) { | ||
case ShapeDiverSdkApiResponseType.TEXT: | ||
case ShapeDiverSdkApiResponseType.JSON: | ||
// For now, we do not validate or parse those responses | ||
return data; | ||
case ShapeDiverSdkApiResponseType.DATA: | ||
// This is required to support Node.js as well as Browsers | ||
return (data instanceof ArrayBuffer) ? data : Uint8Array.from(data).buffer; | ||
default: | ||
// Force the compiler to make the switch block exhaustive | ||
(0, utils_1.sdAssertUnreachable)(requestedType); | ||
} | ||
} | ||
head(url, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fullOptions = Object.assign(Object.assign({}, options), { responseType: ShapeDiverSdkApiResponseType.JSON }); | ||
const config = this.buildRequestConfig(Method.HEAD, fullOptions, undefined); | ||
try { | ||
const response = yield (0, axios_1.default)(this.buildUrl(url), config); | ||
return [response.headers, response.status]; | ||
} | ||
catch (e) { | ||
return yield ShapeDiverSdkApi.processError(e, fullOptions.responseType); | ||
} | ||
}); | ||
} | ||
get(url, options = { | ||
@@ -154,3 +183,6 @@ contentType: "application/json", | ||
const response = yield (0, axios_1.default)(this.buildUrl(url), config); | ||
return [response.headers, response.data]; | ||
return [ | ||
response.headers, | ||
ShapeDiverSdkApi.parseResponse(response.data, options.responseType), | ||
]; | ||
} | ||
@@ -170,3 +202,6 @@ catch (e) { | ||
const response = yield (0, axios_1.default)(this.buildUrl(url), config); | ||
return [response.headers, response.data]; | ||
return [ | ||
response.headers, | ||
ShapeDiverSdkApi.parseResponse(response.data, options.responseType), | ||
]; | ||
} | ||
@@ -186,3 +221,6 @@ catch (e) { | ||
const response = yield (0, axios_1.default)(this.buildUrl(url), config); | ||
return [response.headers, response.data]; | ||
return [ | ||
response.headers, | ||
ShapeDiverSdkApi.parseResponse(response.data, options.responseType), | ||
]; | ||
} | ||
@@ -202,3 +240,6 @@ catch (e) { | ||
const response = yield (0, axios_1.default)(this.buildUrl(url), config); | ||
return [response.headers, response.data]; | ||
return [ | ||
response.headers, | ||
ShapeDiverSdkApi.parseResponse(response.data, options.responseType), | ||
]; | ||
} | ||
@@ -218,3 +259,6 @@ catch (e) { | ||
const response = yield (0, axios_1.default)(this.buildUrl(url), config); | ||
return [response.headers, response.data]; | ||
return [ | ||
response.headers, | ||
ShapeDiverSdkApi.parseResponse(response.data, options.responseType), | ||
]; | ||
} | ||
@@ -221,0 +265,0 @@ catch (e) { |
@@ -15,3 +15,3 @@ /** ShapeDiver configuration object */ | ||
} | ||
export declare type RequestHeader = Record<string, string>; | ||
export type RequestHeader = Record<string, string>; | ||
/** Private interface of the ShapeDiver configuration object */ | ||
@@ -18,0 +18,0 @@ export declare class SdkConfigInternal { |
{ | ||
"name": "@shapediver/sdk.geometry-api-sdk-core", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Core-library for SDK-packages to communicate with the Geometry API", | ||
@@ -38,9 +38,9 @@ "keywords": [], | ||
"dependencies": { | ||
"axios": "^0.27.2" | ||
"axios": "^1.1.3" | ||
}, | ||
"devDependencies": { | ||
"jest": "^29.0.3", | ||
"jest": "^29.3.1", | ||
"lerna": "3.22.1", | ||
"typescript": "^4.8.3" | ||
"typescript": "^4.9.3" | ||
} | ||
} |
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
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
44445
31
651
+ Addedaxios@1.7.7(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
- Removedaxios@0.27.2(transitive)
Updatedaxios@^1.1.3