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

@apimatic/core

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apimatic/core - npm Package Compare versions

Comparing version 0.10.10 to 0.10.11

16

es/http/requestBuilder.js

@@ -333,8 +333,9 @@ import { __spreadArray, __read, __assign, __awaiter, __generator, __values } from 'tslib';

result = _a.sent();
if (result.body === '') {
throw new Error('Could not parse body as JSON. The response body is empty.');
}
if (typeof result.body !== 'string') {
throw new Error('Could not parse body as JSON. The response body is not a string.');
}
if (result.body.trim() === '') {
// Try mapping the missing body as null
return [2 /*return*/, this.tryMappingAsNull(schema, result)];
}
try {

@@ -356,2 +357,11 @@ parsed = JSON.parse(result.body);

};
DefaultRequestBuilder.prototype.tryMappingAsNull = function (schema, result) {
var nullMappingResult = validateAndMap(null, schema);
if (nullMappingResult.errors) {
throw new Error('Could not parse body as JSON. The response body is empty.');
}
return __assign(__assign({}, result), {
result: nullMappingResult.result
});
};
DefaultRequestBuilder.prototype.callAsXml = function (rootName, schema, requestOptions) {

@@ -358,0 +368,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -122,2 +122,3 @@ /// <reference types="node" />

callAsJson<T>(schema: Schema<T>, requestOptions?: RequestOptions): Promise<ApiResponse<T>>;
private tryMappingAsNull;
callAsXml<T>(rootName: string, schema: Schema<T, any>, requestOptions?: RequestOptions): Promise<ApiResponse<T>>;

@@ -124,0 +125,0 @@ private _setContentTypeIfNotSet;

14

lib/http/requestBuilder.js

@@ -286,8 +286,9 @@ "use strict";

result = _a.sent();
if (result.body === '') {
throw new Error('Could not parse body as JSON. The response body is empty.');
}
if (typeof result.body !== 'string') {
throw new Error('Could not parse body as JSON. The response body is not a string.');
}
if (result.body.trim() === '') {
// Try mapping the missing body as null
return [2 /*return*/, this.tryMappingAsNull(schema, result)];
}
try {

@@ -308,2 +309,9 @@ parsed = JSON.parse(result.body);

};
DefaultRequestBuilder.prototype.tryMappingAsNull = function (schema, result) {
var nullMappingResult = schema_1.validateAndMap(null, schema);
if (nullMappingResult.errors) {
throw new Error('Could not parse body as JSON. The response body is empty.');
}
return tslib_1.__assign(tslib_1.__assign({}, result), { result: nullMappingResult.result });
};
DefaultRequestBuilder.prototype.callAsXml = function (rootName, schema, requestOptions) {

@@ -310,0 +318,0 @@ return tslib_1.__awaiter(this, void 0, void 0, function () {

{
"name": "@apimatic/core",
"author": "APIMatic Ltd.",
"version": "0.10.10",
"version": "0.10.11",
"license": "MIT",

@@ -86,3 +86,3 @@ "sideEffects": false,

},
"gitHead": "72608da426036b4d63fa4faba97af2c80f9e4acc"
"gitHead": "42e868dae6a8254c16463c5f0f40de55cba4466b"
}

@@ -502,7 +502,2 @@ import JSONBig from '@apimatic/json-bigint';

const result = await this.call(requestOptions);
if (result.body === '') {
throw new Error(
'Could not parse body as JSON. The response body is empty.'
);
}
if (typeof result.body !== 'string') {

@@ -513,2 +508,6 @@ throw new Error(

}
if (result.body.trim() === '') {
// Try mapping the missing body as null
return this.tryMappingAsNull<T>(schema, result);
}
let parsed: unknown;

@@ -526,2 +525,16 @@ try {

}
private tryMappingAsNull<T>(
schema: Schema<T, any>,
result: ApiResponse<void>
) {
const nullMappingResult = validateAndMap(null, schema);
if (nullMappingResult.errors) {
throw new Error(
'Could not parse body as JSON. The response body is empty.'
);
}
return { ...result, result: nullMappingResult.result };
}
public async callAsXml<T>(

@@ -528,0 +541,0 @@ rootName: string,

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