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

@hey-api/client-fetch

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hey-api/client-fetch - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

5

dist/node/index.d.ts

@@ -35,2 +35,5 @@ type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';

};
declare const urlSearchParamsBodySerializer: {
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => URLSearchParams;
};

@@ -157,2 +160,2 @@ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;

export { type Client, type Options, type RequestResult, client, createClient, formDataBodySerializer, jsonBodySerializer };
export { type Client, type Options, type RequestResult, client, createClient, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };

2

package.json
{
"name": "@hey-api/client-fetch",
"version": "0.1.9",
"version": "0.1.10",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Typesafe Fetch API client for your @hey-api/openapi-ts types",

@@ -72,6 +72,2 @@ import type { Client, Config, RequestOptions } from './types';

};
// remove Content-Type if serialized body is FormData; browser will correctly set Content-Type and boundary expression
if (requestInit.body instanceof FormData) {
requestInit.headers.delete('Content-Type');
}

@@ -78,0 +74,0 @@ let request = new Request(url, requestInit);

export { client, createClient } from '../';
export type { Client, Options, RequestResult } from '../types';
export { formDataBodySerializer, jsonBodySerializer } from '../utils';
export {
formDataBodySerializer,
jsonBodySerializer,
urlSearchParamsBodySerializer,
} from '../utils';

@@ -463,11 +463,7 @@ import type { Config } from './types';

const serializeFormDataPair = (
formData: FormData,
key: string,
value: unknown,
) => {
const serializeFormDataPair = (data: FormData, key: string, value: unknown) => {
if (typeof value === 'string' || value instanceof Blob) {
formData.append(key, value);
data.append(key, value);
} else {
formData.append(key, JSON.stringify(value));
data.append(key, JSON.stringify(value));
}

@@ -480,3 +476,3 @@ };

) => {
const formData = new FormData();
const data = new FormData();

@@ -488,9 +484,9 @@ Object.entries(body).forEach(([key, value]) => {

if (Array.isArray(value)) {
value.forEach((v) => serializeFormDataPair(formData, key, v));
value.forEach((v) => serializeFormDataPair(data, key, v));
} else {
serializeFormDataPair(formData, key, value);
serializeFormDataPair(data, key, value);
}
});
return formData;
return data;
},

@@ -503,2 +499,35 @@ };

const serializeUrlSearchParamsPair = (
data: URLSearchParams,
key: string,
value: unknown,
) => {
if (typeof value === 'string') {
data.append(key, value);
} else {
data.append(key, JSON.stringify(value));
}
};
export const urlSearchParamsBodySerializer = {
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
body: T,
) => {
const data = new URLSearchParams();
Object.entries(body).forEach(([key, value]) => {
if (value === undefined || value === null) {
return;
}
if (Array.isArray(value)) {
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
} else {
serializeUrlSearchParamsPair(data, key, value);
}
});
return data;
},
};
const defaultQuerySerializer = createQuerySerializer({

@@ -505,0 +534,0 @@ allowReserved: false,

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