@shapediver/sdk.geometry-api-sdk-core
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -19,20 +19,3 @@ import { SdkConfigInternal } from "../config/ShapeDiverSdkConfig"; | ||
private buildUrl; | ||
/** | ||
* Processes the given Axios error, maps it content and throws the | ||
* respective ShapeDiver error. | ||
* | ||
* @param error | ||
* @param responseType | ||
* @throws | ||
* @private | ||
*/ | ||
private static processError; | ||
/** | ||
* Axios returns errors in the same type that we where using to specify the | ||
* data response type of the happy-path. Thus, we have to convert them | ||
* manually. | ||
* | ||
* @param data | ||
* @private | ||
*/ | ||
private static convertErrorResponseData; | ||
@@ -39,0 +22,0 @@ private static parseResponse; |
@@ -45,9 +45,7 @@ "use strict"; | ||
}; | ||
// Process HTTP headers | ||
if (!options.disableCustomHeaders) | ||
request.headers = Object.assign({}, this.config.headers); | ||
// Process HTTP authorization header | ||
if (options.disableAuthorization) { | ||
delete request.headers["Authorization"]; | ||
delete request.headers["authorization"]; // config.headers might use lower case | ||
delete request.headers["authorization"]; | ||
} | ||
@@ -57,3 +55,2 @@ else if (this.config.jwt) { | ||
} | ||
// Set data and convert depending on content-type | ||
if (options.contentType) { | ||
@@ -63,3 +60,2 @@ request.headers["Content-Type"] = options.contentType; | ||
} | ||
// Set the HTTP Accept header if specified | ||
if (options.accept) { | ||
@@ -84,11 +80,2 @@ request.headers["Accept"] = options.accept; | ||
} | ||
/** | ||
* Processes the given Axios error, maps it content and throws the | ||
* respective ShapeDiver error. | ||
* | ||
* @param error | ||
* @param responseType | ||
* @throws | ||
* @private | ||
*/ | ||
static processError(error, responseType) { | ||
@@ -98,3 +85,2 @@ var _a, _b, _c; | ||
if (error.response) { | ||
// Request was made and server responded with 4xx or 5xx | ||
const resp = error.response; | ||
@@ -111,7 +97,5 @@ let data; | ||
else if (error.request) { | ||
// The request was made but no response was received | ||
throw new ShapeDiverErrors_1.ShapeDiverRequestError("Could not send request.", "The request was made but no response was received"); | ||
} | ||
else { | ||
// Something happened in setting up the request that triggered an Error | ||
throw new ShapeDiverErrors_1.ShapeDiverError(error.message); | ||
@@ -121,18 +105,8 @@ } | ||
} | ||
/** | ||
* Axios returns errors in the same type that we where using to specify the | ||
* data response type of the happy-path. Thus, we have to convert them | ||
* manually. | ||
* | ||
* @param data | ||
* @private | ||
*/ | ||
static convertErrorResponseData(data) { | ||
let stringData; | ||
if (typeof window === "undefined") { | ||
// NodeJs | ||
stringData = Buffer.from(data).toString(); | ||
} | ||
else if (window.TextDecoder) { | ||
// Browser + TextDecoder support | ||
stringData = new TextDecoder("utf-8").decode(new Uint8Array(data)); | ||
@@ -144,7 +118,5 @@ } | ||
try { | ||
// This should work for the ShapeDiver backend | ||
return JSON.parse(stringData); | ||
} | ||
catch (_) { | ||
// This might be an XML when calling another system (e.g. S3) | ||
return { message: stringData }; | ||
@@ -157,9 +129,6 @@ } | ||
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); | ||
@@ -166,0 +135,0 @@ } |
@@ -6,18 +6,6 @@ import { ShapeDiverSdkApi } from "./api/ShapeDiverSdkApi"; | ||
protected readonly sdkApi: ShapeDiverSdkApi; | ||
/** | ||
* ShapeDiverSDK constructor | ||
* | ||
* @param baseUrl - the URL of the target system | ||
*/ | ||
protected constructor(baseUrl: string); | ||
/** | ||
* Set a specific configuration value. | ||
* | ||
* @param type | ||
* @param value | ||
*/ | ||
setConfigurationValue(type: ShapeDiverSdkConfigType, value: any): void; | ||
/** Get the ShapeDiver configuration object */ | ||
get configuration(): ShapeDiverSdkConfig; | ||
} | ||
//# sourceMappingURL=BaseShapeDiverSdk.d.ts.map |
@@ -7,7 +7,2 @@ "use strict"; | ||
class BaseShapeDiverSdk { | ||
/** | ||
* ShapeDiverSDK constructor | ||
* | ||
* @param baseUrl - the URL of the target system | ||
*/ | ||
constructor(baseUrl) { | ||
@@ -17,12 +12,5 @@ this.sdkConfig = new ShapeDiverSdkConfig_1.SdkConfigInternal(baseUrl); | ||
} | ||
/** | ||
* Set a specific configuration value. | ||
* | ||
* @param type | ||
* @param value | ||
*/ | ||
setConfigurationValue(type, value) { | ||
this.sdkConfig.setConfigValue(type, value); | ||
} | ||
/** Get the ShapeDiver configuration object */ | ||
get configuration() { | ||
@@ -29,0 +17,0 @@ return this.sdkConfig.toConfig(); |
@@ -1,2 +0,1 @@ | ||
/** ShapeDiver configuration object */ | ||
export interface ShapeDiverSdkConfig { | ||
@@ -9,3 +8,2 @@ baseUrl: string; | ||
} | ||
/** Supported types of the ShapeDiver configuration object */ | ||
export declare enum ShapeDiverSdkConfigType { | ||
@@ -17,3 +15,2 @@ BASE_URL = "BASE_URL", | ||
export type RequestHeader = Record<string, string>; | ||
/** Private interface of the ShapeDiver configuration object */ | ||
export declare class SdkConfigInternal { | ||
@@ -20,0 +17,0 @@ private _baseUrl; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const ShapeDiverErrors_1 = require("../ShapeDiverErrors"); | ||
/** Supported types of the ShapeDiver configuration object */ | ||
var ShapeDiverSdkConfigType; | ||
@@ -13,3 +12,2 @@ (function (ShapeDiverSdkConfigType) { | ||
})(ShapeDiverSdkConfigType || (exports.ShapeDiverSdkConfigType = ShapeDiverSdkConfigType = {})); | ||
/** Private interface of the ShapeDiver configuration object */ | ||
class SdkConfigInternal { | ||
@@ -16,0 +14,0 @@ constructor(baseUrl) { |
@@ -6,48 +6,10 @@ import { ShapeDiverSdkApi } from ".."; | ||
protected constructor(api: ShapeDiverSdkApi); | ||
/** | ||
* Create the URI for analytics-based controller endpoints. | ||
* | ||
* @protected | ||
*/ | ||
protected buildAnalyticsUri(): string; | ||
/** | ||
* Create the URI for AR-scene-based controller endpoints. | ||
* | ||
* @protected | ||
*/ | ||
protected buildArSceneUri(): string; | ||
/** | ||
* Create the URI for auth_group-based controller endpoints. | ||
* | ||
* @protected | ||
*/ | ||
protected buildAuthGroupUri(): string; | ||
/** | ||
* Create the URI for ticket-based controller endpoints. | ||
* | ||
* @param ticketId | ||
* @protected | ||
*/ | ||
protected buildTicketUri(ticketId: string): string; | ||
/** | ||
* Create the URI for session-based controller endpoints. | ||
* | ||
* @param sessionId | ||
* @protected | ||
*/ | ||
protected buildSessionUri(sessionId: string): string; | ||
/** | ||
* Create the URI for model-based controller endpoints. | ||
* | ||
* @param modelId | ||
* @protected | ||
*/ | ||
protected buildModelUri(modelId: string): string; | ||
/** | ||
* Create the URI for system-based controller endpoints. | ||
* | ||
* @protected | ||
*/ | ||
protected buildSystemUri(): string; | ||
} | ||
//# sourceMappingURL=BaseResourceApi.d.ts.map |
@@ -9,58 +9,20 @@ "use strict"; | ||
} | ||
/** | ||
* Create the URI for analytics-based controller endpoints. | ||
* | ||
* @protected | ||
*/ | ||
buildAnalyticsUri() { | ||
return `${this.commonPath}/analytics`; | ||
} | ||
/** | ||
* Create the URI for AR-scene-based controller endpoints. | ||
* | ||
* @protected | ||
*/ | ||
buildArSceneUri() { | ||
return `${this.commonPath}/ar-scene`; | ||
} | ||
/** | ||
* Create the URI for auth_group-based controller endpoints. | ||
* | ||
* @protected | ||
*/ | ||
buildAuthGroupUri() { | ||
return `${this.commonPath}/auth_group`; | ||
} | ||
/** | ||
* Create the URI for ticket-based controller endpoints. | ||
* | ||
* @param ticketId | ||
* @protected | ||
*/ | ||
buildTicketUri(ticketId) { | ||
return `${this.commonPath}/ticket/${ticketId}`; | ||
} | ||
/** | ||
* Create the URI for session-based controller endpoints. | ||
* | ||
* @param sessionId | ||
* @protected | ||
*/ | ||
buildSessionUri(sessionId) { | ||
return `${this.commonPath}/session/${sessionId}`; | ||
} | ||
/** | ||
* Create the URI for model-based controller endpoints. | ||
* | ||
* @param modelId | ||
* @protected | ||
*/ | ||
buildModelUri(modelId) { | ||
return `${this.commonPath}/model/${modelId}`; | ||
} | ||
/** | ||
* Create the URI for system-based controller endpoints. | ||
* | ||
* @protected | ||
*/ | ||
buildSystemUri() { | ||
@@ -67,0 +29,0 @@ return `${this.commonPath}/system`; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sdAssertUnreachable = void 0; | ||
/** | ||
* Function to indicate unreachable paths to the TypeScript compiler. | ||
* @param _ | ||
* @throws {@link ShapeDiverError} if called. | ||
*/ | ||
const ShapeDiverErrors_1 = require("./ShapeDiverErrors"); | ||
@@ -10,0 +5,0 @@ function sdAssertUnreachable(_) { |
{ | ||
"name": "@shapediver/sdk.geometry-api-sdk-core", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Core-library for SDK-packages to communicate with the Geometry API", | ||
@@ -40,9 +40,9 @@ "keywords": [], | ||
"dependencies": { | ||
"axios": "~1.4.0" | ||
"axios": "~1.6.7" | ||
}, | ||
"devDependencies": { | ||
"jest": "~29.6.2", | ||
"lerna": "~7.1.5", | ||
"typescript": "~5.1.6" | ||
"jest": "~29.7.0", | ||
"lerna": "~8.1.2", | ||
"typescript": "~5.3.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
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 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
41420
512
+ Addedaxios@1.6.8(transitive)
- Removedaxios@1.4.0(transitive)
Updatedaxios@~1.6.7