New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@springworks/api-client

Package Overview
Dependencies
Maintainers
2
Versions
567
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@springworks/api-client - npm Package Compare versions

Comparing version 3005.329.0 to 3005.332.0

3

build/api-client.d.ts

@@ -13,5 +13,6 @@ import { HTTPStatus } from '@springworks/http-status';

constructor(request_maker: RequestMaker, logger: Logger, source_identifier?: string, circuit_breaker_config?: CircuitBreakerConfig, mtls_config?: Mtls);
sendRequest<T = any>(req_opts: ApiClientRequestOptions, expected_status_codes: HTTPStatus[]): Promise<T>;
sendRequest<T = any>(req_opts: ApiClientRequestOptions, expected_status_codes: HTTPStatus[], retries?: number): Promise<T>;
sendRequestActual<T = any>(req_opts: ApiClientRequestOptions, expected_status_codes: HTTPStatus[]): Promise<T>;
sendRequestWithFullResponse<Body = any, Code extends HTTPStatus = number>(req_opts: ApiClientRequestOptions, expected_status_codes: HTTPStatus[]): Promise<BodyWithFullResponse<Body, Code>>;
}
//# sourceMappingURL=api-client.d.ts.map

@@ -9,3 +9,2 @@ "use strict";

const mtls_helpers_1 = require("./mtls-helpers");
const UNEXPECTED_RESPONSE_STATUS_CODE = 417;
class ApiClient {

@@ -24,3 +23,18 @@ constructor(request_maker, logger, source_identifier, circuit_breaker_config, mtls_config) {

}
async sendRequest(req_opts, expected_status_codes) {
async sendRequest(req_opts, expected_status_codes, retries = 0) {
try {
return await this.sendRequestActual(req_opts, expected_status_codes);
}
catch (error) {
if (!req_opts.retries) {
throw error;
}
if (error instanceof Error && 'code' in error && error.code === http_status_1.HTTP4XX.REQUEST_TIMEOUT && retries < req_opts.retries) {
this.logger.debug({ retries }, 'retrying request');
return this.sendRequest(req_opts, expected_status_codes, retries + 1);
}
throw error;
}
}
async sendRequestActual(req_opts, expected_status_codes) {
return new Promise((resolve, reject) => {

@@ -46,3 +60,3 @@ const validated_expected_status_codes = validateExpectedStatusCodes(expected_status_codes);

if (status_code < 400) {
status_code = UNEXPECTED_RESPONSE_STATUS_CODE;
status_code = http_status_1.HTTP4XX.EXPECTATION_FAILED;
}

@@ -149,3 +163,2 @@ const cause = body;

function loggableRequestOptions(req_opts) {
// eslint-disable-next-line deprecation/deprecation
const { auth: _auth, json: _json, body: _body, form: _form, headers: _headers, agent: _agent, ...rest } = req_opts;

@@ -152,0 +165,0 @@ if (rest.qs === undefined) {

@@ -118,5 +118,11 @@ /// <reference types="node" />

* @default true
* @deprecated use `follow_redirect` (our casing)
*/
followRedirect?: boolean;
/**
* Follow HTTP 3xx responses as redirects.
* @default true
*/
follow_redirect?: boolean;
/**
* When true will result in a response with `{ code: <some-code>, body: <some-body>, headers: {} }`

@@ -129,2 +135,7 @@ */

agent?: Agent;
/**
* If added, we retry the request if we get timeouts. At the most, we _should_ never do this more than once (?)
* @default 0
*/
retries?: number;
}

@@ -131,0 +142,0 @@ export interface BodyWithFullResponse<Body = any, Code extends HTTPStatus = HTTPStatus> {

@@ -42,5 +42,3 @@ "use strict";

const req_options = (_a = validated_params.opt_options) !== null && _a !== void 0 ? _a : {};
const request_maker = new request_maker_1.default(validated_params.base_url, req_options.opt_timeout,
// eslint-disable-next-line deprecation/deprecation
(_b = validated_params.auth) !== null && _b !== void 0 ? _b : req_options.opt_auth, logger);
const request_maker = new request_maker_1.default(validated_params.base_url, req_options.opt_timeout, (_b = validated_params.auth) !== null && _b !== void 0 ? _b : req_options.opt_auth, logger);
return new api_client_1.ApiClient(request_maker, logger, source_identifier, validated_params.circuit_breaker_config, validated_params.mtls);

@@ -47,0 +45,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRequestBody = exports.objectFromHeaders = exports.default_user_agent_string = void 0;
/* eslint-disable deprecation/deprecation */
const url_1 = require("url");

@@ -94,3 +93,3 @@ const node_fetch_1 = require("node-fetch");

getRequestInit(options) {
var _a, _b, _c;
var _a, _b, _c, _d;
return {

@@ -100,4 +99,4 @@ method: (_a = options.method) !== null && _a !== void 0 ? _a : 'GET',

body: getRequestBody(options),
redirect: options.followRedirect !== false ? 'follow' : 'manual',
timeout: (_c = options.timeout) !== null && _c !== void 0 ? _c : this.req_timeout,
redirect: ((_c = options.follow_redirect) !== null && _c !== void 0 ? _c : options.followRedirect) !== false ? 'follow' : 'manual',
timeout: (_d = options.timeout) !== null && _d !== void 0 ? _d : this.req_timeout,
compress: true,

@@ -104,0 +103,0 @@ agent: options.agent,

{
"name": "@springworks/api-client",
"version": "3005.329.0",
"version": "3005.332.0",
"description": "Module for sending requests to other APIs through a circuit breaker",

@@ -32,3 +32,3 @@ "main": "build/main.js",

},
"gitHead": "4af801214f2a5243c9396014b2f838e3c86557d5"
"gitHead": "87e78def17b05027fe32d855184bad8ff90b867f"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc