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

@hey-api/client-axios

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.2.5 to 0.2.6

2

dist/index.d.ts

@@ -103,2 +103,2 @@ import { CreateAxiosDefaults, AxiosStatic, AxiosInstance, AxiosResponse, AxiosError } from 'axios';

export { type Config, type Options, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
export { type Client, type Config, type Options, type RequestOptionsBase, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
import $ from 'axios';
var b=/\{[^{}]+\}/g,u=({allowReserved:n,name:r,value:e})=>{if(e==null)return "";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${n?e:encodeURIComponent(e)}`},x=n=>{switch(n){case"label":return ".";case"matrix":return ";";case"simple":return ",";default:return "&"}},C=n=>{switch(n){case"form":return ",";case"pipeDelimited":return "|";case"spaceDelimited":return "%20";default:return ","}},j=n=>{switch(n){case"label":return ".";case"matrix":return ";";case"simple":return ",";default:return "&"}},z=({allowReserved:n,explode:r,name:e,style:a,value:s})=>{if(!r){let i=(n?s:s.map(c=>encodeURIComponent(c))).join(C(a));switch(a){case"label":return `.${i}`;case"matrix":return `;${e}=${i}`;case"simple":return i;default:return `${e}=${i}`}}let o=x(a),t=s.map(i=>a==="label"||a==="simple"?n?i:encodeURIComponent(i):u({allowReserved:n,name:e,value:i})).join(o);return a==="label"||a==="matrix"?o+t:t},O=({allowReserved:n,explode:r,name:e,style:a,value:s})=>{if(a!=="deepObject"&&!r){let i=[];Object.entries(s).forEach(([d,p])=>{i=[...i,d,n?p:encodeURIComponent(p)];});let c=i.join(",");switch(a){case"form":return `${e}=${c}`;case"label":return `.${c}`;case"matrix":return `;${e}=${c}`;default:return c}}let o=j(a),t=Object.entries(s).map(([i,c])=>u({allowReserved:n,name:a==="deepObject"?`${e}[${i}]`:i,value:c})).join(o);return a==="label"||a==="matrix"?o+t:t},A=({path:n,url:r})=>{let e=r,a=r.match(b);if(a)for(let s of a){let o=!1,t=s.substring(1,s.length-1),i="simple";t.endsWith("*")&&(o=!0,t=t.substring(0,t.length-1)),t.startsWith(".")?(t=t.substring(1),i="label"):t.startsWith(";")&&(t=t.substring(1),i="matrix");let c=n[t];if(c==null)continue;if(Array.isArray(c)){e=e.replace(s,z({explode:o,name:t,style:i,value:c}));continue}if(typeof c=="object"){e=e.replace(s,O({explode:o,name:t,style:i,value:c}));continue}if(i==="matrix"){e=e.replace(s,`;${u({name:t,value:c})}`);continue}let d=encodeURIComponent(i==="label"?`.${c}`:c);e=e.replace(s,d);}return e},S=({path:n,url:r})=>n?A({path:n,url:r}):r,g=(n,r,e)=>{typeof e=="string"||e instanceof Blob?n.append(r,e):n.append(r,JSON.stringify(e));},m=(n,r)=>{let e={...n,...r};return e.headers=f(n.headers,r.headers),e},f=(...n)=>{let r={};for(let e of n){if(!e||typeof e!="object")continue;let a=Object.entries(e);for(let[s,o]of a)if(o===null)delete r[s];else if(Array.isArray(o))for(let t of o)r[s]=[...r[s]??[],t];else o!==void 0&&(r[s]=typeof o=="object"?JSON.stringify(o):o);}return r},P={bodySerializer:n=>{let r=new FormData;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(s=>g(r,e,s)):g(r,e,a));}),r}},R={bodySerializer:n=>JSON.stringify(n)},h=(n,r,e)=>{typeof e=="string"?n.append(r,e):n.append(r,JSON.stringify(e));},w={bodySerializer:n=>{let r=new URLSearchParams;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(s=>h(r,e,s)):h(r,e,a));}),r}},y=(n={})=>({baseURL:"",...n});var D=n=>{let r=m(y(),n),e=$.create(r),a=()=>({...r}),s=t=>(r=m(r,t),e.defaults={...e.defaults,...r,headers:f(e.defaults.headers,r.headers)},a()),o=async t=>{let i={...r,...t,headers:f(r.headers,t.headers)};i.body&&i.bodySerializer&&(i.body=i.bodySerializer(i.body));let c=S({path:i.path,url:i.url}),d=i.axios||e;try{let p=await d({...i,data:i.body,params:i.query,url:c}),{data:l}=p;return i.responseType==="json"&&i.responseTransformer&&(l=await i.responseTransformer(l)),{...p,data:l??{}}}catch(p){let l=p;if(i.throwOnError)throw l;return l.error=l.response?.data??{},l}};return {delete:t=>o({...t,method:"delete"}),get:t=>o({...t,method:"get"}),getConfig:a,head:t=>o({...t,method:"head"}),instance:e,options:t=>o({...t,method:"options"}),patch:t=>o({...t,method:"patch"}),post:t=>o({...t,method:"post"}),put:t=>o({...t,method:"put"}),request:o,setConfig:s}};
var b=/\{[^{}]+\}/g,u=({allowReserved:n,name:r,value:e})=>{if(e==null)return "";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${n?e:encodeURIComponent(e)}`},x=n=>{switch(n){case"label":return ".";case"matrix":return ";";case"simple":return ",";default:return "&"}},C=n=>{switch(n){case"form":return ",";case"pipeDelimited":return "|";case"spaceDelimited":return "%20";default:return ","}},O=n=>{switch(n){case"label":return ".";case"matrix":return ";";case"simple":return ",";default:return "&"}},j=({allowReserved:n,explode:r,name:e,style:a,value:s})=>{if(!r){let i=(n?s:s.map(c=>encodeURIComponent(c))).join(C(a));switch(a){case"label":return `.${i}`;case"matrix":return `;${e}=${i}`;case"simple":return i;default:return `${e}=${i}`}}let o=x(a),t=s.map(i=>a==="label"||a==="simple"?n?i:encodeURIComponent(i):u({allowReserved:n,name:e,value:i})).join(o);return a==="label"||a==="matrix"?o+t:t},z=({allowReserved:n,explode:r,name:e,style:a,value:s})=>{if(a!=="deepObject"&&!r){let i=[];Object.entries(s).forEach(([d,p])=>{i=[...i,d,n?p:encodeURIComponent(p)];});let c=i.join(",");switch(a){case"form":return `${e}=${c}`;case"label":return `.${c}`;case"matrix":return `;${e}=${c}`;default:return c}}let o=O(a),t=Object.entries(s).map(([i,c])=>u({allowReserved:n,name:a==="deepObject"?`${e}[${i}]`:i,value:c})).join(o);return a==="label"||a==="matrix"?o+t:t},A=({path:n,url:r})=>{let e=r,a=r.match(b);if(a)for(let s of a){let o=!1,t=s.substring(1,s.length-1),i="simple";t.endsWith("*")&&(o=!0,t=t.substring(0,t.length-1)),t.startsWith(".")?(t=t.substring(1),i="label"):t.startsWith(";")&&(t=t.substring(1),i="matrix");let c=n[t];if(c==null)continue;if(Array.isArray(c)){e=e.replace(s,j({explode:o,name:t,style:i,value:c}));continue}if(typeof c=="object"){e=e.replace(s,z({explode:o,name:t,style:i,value:c}));continue}if(i==="matrix"){e=e.replace(s,`;${u({name:t,value:c})}`);continue}let d=encodeURIComponent(i==="label"?`.${c}`:c);e=e.replace(s,d);}return e},S=({path:n,url:r})=>n?A({path:n,url:r}):r,g=(n,r,e)=>{typeof e=="string"||e instanceof Blob?n.append(r,e):n.append(r,JSON.stringify(e));},m=(n,r)=>{let e={...n,...r};return e.headers=f(n.headers,r.headers),e},f=(...n)=>{let r={};for(let e of n){if(!e||typeof e!="object")continue;let a=Object.entries(e);for(let[s,o]of a)if(o===null)delete r[s];else if(Array.isArray(o))for(let t of o)r[s]=[...r[s]??[],t];else o!==void 0&&(r[s]=typeof o=="object"?JSON.stringify(o):o);}return r},P={bodySerializer:n=>{let r=new FormData;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(s=>g(r,e,s)):g(r,e,a));}),r}},R={bodySerializer:n=>JSON.stringify(n)},h=(n,r,e)=>{typeof e=="string"?n.append(r,e):n.append(r,JSON.stringify(e));},w={bodySerializer:n=>{let r=new URLSearchParams;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(s=>h(r,e,s)):h(r,e,a));}),r}},y=(n={})=>({baseURL:"",...n});var q=n=>{let r=m(y(),n),e=$.create(r),a=()=>({...r}),s=t=>(r=m(r,t),e.defaults={...e.defaults,...r,headers:f(e.defaults.headers,r.headers)},a()),o=async t=>{let i={...r,...t,headers:f(r.headers,t.headers)};i.body&&i.bodySerializer&&(i.body=i.bodySerializer(i.body));let c=S({path:i.path,url:i.url}),d=i.axios||e;try{let p=await d({...i,data:i.body,params:i.query,url:c}),{data:l}=p;return i.responseType==="json"&&i.responseTransformer&&(l=await i.responseTransformer(l)),{...p,data:l??{}}}catch(p){let l=p;if(i.throwOnError)throw l;return l.error=l.response?.data??{},l}};return {delete:t=>o({...t,method:"delete"}),get:t=>o({...t,method:"get"}),getConfig:a,head:t=>o({...t,method:"head"}),instance:e,options:t=>o({...t,method:"options"}),patch:t=>o({...t,method:"patch"}),post:t=>o({...t,method:"post"}),put:t=>o({...t,method:"put"}),request:o,setConfig:s}};
export { D as createClient, y as createConfig, P as formDataBodySerializer, R as jsonBodySerializer, w as urlSearchParamsBodySerializer };
export { q as createClient, y as createConfig, P as formDataBodySerializer, R as jsonBodySerializer, w as urlSearchParamsBodySerializer };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map
{
"name": "@hey-api/client-axios",
"version": "0.2.5",
"version": "0.2.6",
"description": "Type-safe Axios client for your @hey-api/openapi-ts types",

@@ -64,4 +64,4 @@ "homepage": "https://heyapi.vercel.app/",

"test": "vitest run",
"typecheck": "tsc --noEmit"
"typecheck": "vitest --typecheck"
}
}

@@ -88,3 +88,3 @@ import type { AxiosError } from 'axios';

export type { Config, Options } from './types';
export type { Client, Config, Options, RequestOptionsBase } from './types';
export {

@@ -91,0 +91,0 @@ createConfig,

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