Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@avst-api/commons

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@avst-api/commons - npm Package Compare versions

Comparing version 0.1.10 to 0.2.0

1

index.d.ts

@@ -97,2 +97,3 @@ /// <reference types="runtime" />

export declare function transformToFormData(body: any): FormData;
export declare function performHttpCall<Ok, Err>(connection: string, urlPath: string, method: string, body?: any, additionalHeaders?: HeadersType, skipBodyParsing?: boolean): Promise<Response<Ok | Err>>;
//# sourceMappingURL=index.d.ts.map

@@ -183,2 +183,51 @@ export class HttpError extends Error {

}
export async function performHttpCall(connection, urlPath, method, body, additionalHeaders, skipBodyParsing = false) {
const headers = getHeaders(body, { ...additionalHeaders, 'x-hzn-connection-id': connection });
if (body && !(body instanceof FormData) && !(body instanceof ArrayBuffer)) {
body = JSON.stringify(body);
}
try {
const res = await fetch(urlPath, { method, headers, body });
if (skipBodyParsing) {
const body = await res.text();
return getResponse(res.headers, res.status, res.statusText, body);
}
else {
try {
const text = await res.text();
if (text) {
try {
return getResponse(res.headers, res.status, res.statusText, JSON.parse(text));
}
catch (e) {
if (res.status < 200 || res.status >= 300) {
return getResponse(res.headers, res.status, res.statusText, {});
}
else {
throw new UnexpectedError(e, `Failed to parse body, original body: ${text}`);
}
}
}
else {
return getResponse(res.headers, res.status, res.statusText, {});
}
}
catch (e) {
if (e instanceof UnexpectedError) {
throw e;
}
throw new UnexpectedError(e, `Failed to read body`);
}
}
}
catch (error) {
if (error instanceof Error) {
throw error;
}
else {
// Internal Node errors that are not Errors by default
throw new Error(error);
}
}
}
//# sourceMappingURL=index.js.map

6

package.json
{
"name": "@avst-api/commons",
"version": "0.1.10",
"version": "0.2.0",
"description": "Commons for Adaptavist Managed APIs",

@@ -18,6 +18,6 @@ "main": "index.js",

"author": "Adaptavist",
"license": "ISC",
"license": "UNLICENSED",
"homepage": "https://bitbucket.org/adaptavistlabs/adaptavist-api-common#readme",
"dependencies": {
"@avst-types/runtime": "^0.12.0"
"@avst-types/runtime": "^0.13.0"
},

@@ -24,0 +24,0 @@ "devDependencies": {

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