@mcma/client
Advanced tools
Comparing version 0.14.5 to 0.14.6
@@ -75,3 +75,3 @@ "use strict"; | ||
async request(config) { | ||
var _a; | ||
var _a, _b, _c; | ||
if (!config) { | ||
@@ -126,3 +126,4 @@ throw new core_1.McmaException("HttpClient: Missing configuration for making HTTP request"); | ||
catch (error) { | ||
if (attempts < this.config.maxAttempts - 1) { | ||
// retrying 404 errors as well as 5xx errors. 404 errors can be caused by eventual consistency issues as a resource might be created but not yet available. | ||
if ((((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 404 || ((_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.status) >= 500) && attempts < this.config.maxAttempts - 1) { | ||
await core_1.Utils.sleep(this.config.retryInterval); | ||
@@ -132,3 +133,3 @@ } | ||
let response; | ||
if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) { | ||
if ((_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) { | ||
response = error.response.data; | ||
@@ -135,0 +136,0 @@ } |
import { AxiosResponse } from "axios"; | ||
import { ResourceEndpointProperties } from "@mcma/core"; | ||
import { Http, HttpRequestConfig } from "../http"; | ||
import { Http, HttpClientConfig, HttpRequestConfig } from "../http"; | ||
import { AuthProvider } from "../auth"; | ||
@@ -8,5 +8,6 @@ export declare class ResourceEndpointClient implements Http { | ||
private authProvider; | ||
private httpClientConfig?; | ||
private serviceAuthType?; | ||
private _httpClient; | ||
constructor(resourceEndpoint: ResourceEndpointProperties, authProvider: AuthProvider, serviceAuthType?: string); | ||
constructor(resourceEndpoint: ResourceEndpointProperties, authProvider: AuthProvider, httpClientConfig?: HttpClientConfig, serviceAuthType?: string); | ||
get httpEndpoint(): string; | ||
@@ -13,0 +14,0 @@ private get httpClient(); |
@@ -7,5 +7,6 @@ "use strict"; | ||
class ResourceEndpointClient { | ||
constructor(resourceEndpoint, authProvider, serviceAuthType) { | ||
constructor(resourceEndpoint, authProvider, httpClientConfig, serviceAuthType) { | ||
this.resourceEndpoint = resourceEndpoint; | ||
this.authProvider = authProvider; | ||
this.httpClientConfig = httpClientConfig; | ||
this.serviceAuthType = serviceAuthType; | ||
@@ -26,3 +27,3 @@ if (!resourceEndpoint) { | ||
this.authProvider.get(this.resourceEndpoint.authType || this.serviceAuthType); | ||
this._httpClient = new http_1.HttpClient(authenticator); | ||
this._httpClient = new http_1.HttpClient(authenticator, this.httpClientConfig); | ||
} | ||
@@ -29,0 +30,0 @@ return this._httpClient; |
@@ -35,3 +35,3 @@ "use strict"; | ||
}); | ||
let serviceRegistryClient = new service_client_1.ServiceClient(serviceRegistry, this.authProvider); | ||
let serviceRegistryClient = new service_client_1.ServiceClient(serviceRegistry, this.authProvider, this.config.httpClientConfig); | ||
this.serviceClients.push(serviceRegistryClient); | ||
@@ -45,3 +45,3 @@ let servicesEndpoint = serviceRegistryClient.getResourceEndpointClient("Service"); | ||
} | ||
this.serviceClients.push(new service_client_1.ServiceClient(new core_1.Service(service), this.authProvider)); | ||
this.serviceClients.push(new service_client_1.ServiceClient(new core_1.Service(service), this.authProvider, this.config.httpClientConfig)); | ||
} | ||
@@ -48,0 +48,0 @@ catch (error) { |
import { ServiceProperties } from "@mcma/core"; | ||
import { ResourceEndpointClient } from "./resource-endpoint-client"; | ||
import { AuthProvider } from "../auth/auth-provider"; | ||
import { HttpClientConfig } from "../http"; | ||
export declare class ServiceClient { | ||
private endpointsMap; | ||
constructor(service: ServiceProperties, authProvider: AuthProvider); | ||
constructor(service: ServiceProperties, authProvider: AuthProvider, httpClientConfig?: HttpClientConfig); | ||
private getResourceTypeName; | ||
@@ -8,0 +9,0 @@ hasResourceEndpoint(resourceType: string | Function): boolean; |
@@ -6,7 +6,7 @@ "use strict"; | ||
class ServiceClient { | ||
constructor(service, authProvider) { | ||
constructor(service, authProvider, httpClientConfig) { | ||
this.endpointsMap = {}; | ||
for (const resourceEndpoint of service.resources) { | ||
this.endpointsMap[resourceEndpoint.resourceType] = | ||
new resource_endpoint_client_1.ResourceEndpointClient(resourceEndpoint, authProvider, service.authType); | ||
new resource_endpoint_client_1.ResourceEndpointClient(resourceEndpoint, authProvider, httpClientConfig, service.authType); | ||
} | ||
@@ -13,0 +13,0 @@ } |
{ | ||
"name": "@mcma/client", | ||
"version": "0.14.5", | ||
"version": "0.14.6", | ||
"description": "Node module with classes and functions used to access services in an MCMA environment", | ||
@@ -35,6 +35,6 @@ "engines": { | ||
"peerDependencies": { | ||
"@mcma/core": "0.14.5" | ||
"@mcma/core": "0.14.6" | ||
}, | ||
"devDependencies": { | ||
"@mcma/core": "0.14.5", | ||
"@mcma/core": "0.14.6", | ||
"@types/node": "^14.17.22", | ||
@@ -41,0 +41,0 @@ "jasmine": "^3.3.1" |
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
40013
864