fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2148 from hey-api/feat/client-build-params

feat(client): export buildClientParams function

authored by

Lubos and committed by
GitHub
f0294b4d 5d81c80e

+667 -12
+10
.changeset/twenty-numbers-talk.md
··· 1 + --- 2 + '@hey-api/client-custom': minor 3 + '@hey-api/client-axios': minor 4 + '@hey-api/client-fetch': minor 5 + '@hey-api/client-core': minor 6 + '@hey-api/client-next': minor 7 + '@hey-api/client-nuxt': minor 8 + --- 9 + 10 + feat: export buildClientParams function
+1
packages/client-axios/src/index.ts
··· 13 13 export { createConfig } from './utils'; 14 14 export type { Auth, QuerySerializerOptions } from '@hey-api/client-core'; 15 15 export { 16 + buildClientParams, 16 17 formDataBodySerializer, 17 18 jsonBodySerializer, 18 19 urlSearchParamsBodySerializer,
+313
packages/client-core/src/__tests__/params.test.ts
··· 1 + import { describe, expect, it } from 'vitest'; 2 + 3 + import type { FieldsConfig } from '../params'; 4 + import { buildClientParams } from '../params'; 5 + 6 + describe('buildClientParams', () => { 7 + const scenarios: ReadonlyArray<{ 8 + args: ReadonlyArray<unknown>; 9 + config: FieldsConfig; 10 + description: string; 11 + params: Record<string, unknown>; 12 + }> = [ 13 + { 14 + args: [1, 2, 3, 4], 15 + config: [ 16 + { 17 + in: 'path', 18 + key: 'foo', 19 + }, 20 + { 21 + in: 'query', 22 + key: 'bar', 23 + }, 24 + { 25 + in: 'headers', 26 + key: 'baz', 27 + }, 28 + { 29 + in: 'body', 30 + key: 'qux', 31 + }, 32 + ], 33 + description: 'positional arguments', 34 + params: { 35 + body: { 36 + qux: 4, 37 + }, 38 + headers: { 39 + baz: 3, 40 + }, 41 + path: { 42 + foo: 1, 43 + }, 44 + query: { 45 + bar: 2, 46 + }, 47 + }, 48 + }, 49 + { 50 + args: [ 51 + { 52 + bar: 2, 53 + baz: 3, 54 + foo: 1, 55 + qux: 4, 56 + }, 57 + ], 58 + config: [ 59 + { 60 + args: [ 61 + { 62 + in: 'path', 63 + key: 'foo', 64 + }, 65 + { 66 + in: 'query', 67 + key: 'bar', 68 + }, 69 + { 70 + in: 'headers', 71 + key: 'baz', 72 + }, 73 + { 74 + in: 'body', 75 + key: 'qux', 76 + }, 77 + ], 78 + }, 79 + ], 80 + description: 'flat arguments', 81 + params: { 82 + body: { 83 + qux: 4, 84 + }, 85 + headers: { 86 + baz: 3, 87 + }, 88 + path: { 89 + foo: 1, 90 + }, 91 + query: { 92 + bar: 2, 93 + }, 94 + }, 95 + }, 96 + { 97 + args: [ 98 + 1, 99 + 2, 100 + { 101 + baz: 3, 102 + qux: 4, 103 + }, 104 + ], 105 + config: [ 106 + { 107 + in: 'path', 108 + key: 'foo', 109 + }, 110 + { 111 + in: 'query', 112 + key: 'bar', 113 + }, 114 + { 115 + args: [ 116 + { 117 + in: 'headers', 118 + key: 'baz', 119 + }, 120 + { 121 + in: 'body', 122 + key: 'qux', 123 + }, 124 + ], 125 + }, 126 + ], 127 + description: 'mixed arguments', 128 + params: { 129 + body: { 130 + qux: 4, 131 + }, 132 + headers: { 133 + baz: 3, 134 + }, 135 + path: { 136 + foo: 1, 137 + }, 138 + query: { 139 + bar: 2, 140 + }, 141 + }, 142 + }, 143 + { 144 + args: [1, 2, 3, 4], 145 + config: [ 146 + { 147 + in: 'path', 148 + key: 'foo', 149 + map: 'f_o_o', 150 + }, 151 + { 152 + in: 'query', 153 + key: 'bar', 154 + map: 'b_a_r', 155 + }, 156 + { 157 + in: 'headers', 158 + key: 'baz', 159 + map: 'b_a_z', 160 + }, 161 + { 162 + in: 'body', 163 + key: 'qux', 164 + map: 'q_u_x', 165 + }, 166 + ], 167 + description: 'positional mapped arguments', 168 + params: { 169 + body: { 170 + q_u_x: 4, 171 + }, 172 + headers: { 173 + b_a_z: 3, 174 + }, 175 + path: { 176 + f_o_o: 1, 177 + }, 178 + query: { 179 + b_a_r: 2, 180 + }, 181 + }, 182 + }, 183 + { 184 + args: [ 185 + { 186 + bar: 2, 187 + baz: 3, 188 + foo: 1, 189 + qux: 4, 190 + }, 191 + ], 192 + config: [ 193 + { 194 + args: [ 195 + { 196 + in: 'path', 197 + key: 'foo', 198 + map: 'f_o_o', 199 + }, 200 + { 201 + in: 'query', 202 + key: 'bar', 203 + map: 'b_a_r', 204 + }, 205 + { 206 + in: 'headers', 207 + key: 'baz', 208 + map: 'b_a_z', 209 + }, 210 + { 211 + in: 'body', 212 + key: 'qux', 213 + map: 'q_u_x', 214 + }, 215 + ], 216 + }, 217 + ], 218 + description: 'flat mapped arguments', 219 + params: { 220 + body: { 221 + q_u_x: 4, 222 + }, 223 + headers: { 224 + b_a_z: 3, 225 + }, 226 + path: { 227 + f_o_o: 1, 228 + }, 229 + query: { 230 + b_a_r: 2, 231 + }, 232 + }, 233 + }, 234 + { 235 + args: [1], 236 + config: [ 237 + { 238 + in: 'body', 239 + }, 240 + ], 241 + description: 'positional primitive body', 242 + params: { 243 + body: 1, 244 + }, 245 + }, 246 + { 247 + args: [ 248 + { 249 + $body_qux: 4, 250 + $headers_baz: 3, 251 + $path_foo: 1, 252 + $query_bar: 2, 253 + }, 254 + ], 255 + config: [ 256 + { 257 + allowExtra: {}, 258 + }, 259 + ], 260 + description: 'namespace extra arguments', 261 + params: { 262 + body: { 263 + qux: 4, 264 + }, 265 + headers: { 266 + baz: 3, 267 + }, 268 + path: { 269 + foo: 1, 270 + }, 271 + query: { 272 + bar: 2, 273 + }, 274 + }, 275 + }, 276 + { 277 + args: [ 278 + { 279 + bar: 2, 280 + baz: 3, 281 + foo: 1, 282 + qux: 4, 283 + }, 284 + ], 285 + config: [ 286 + { 287 + allowExtra: { 288 + query: true, 289 + }, 290 + }, 291 + ], 292 + description: 'slot extra arguments', 293 + params: { 294 + query: { 295 + bar: 2, 296 + baz: 3, 297 + foo: 1, 298 + qux: 4, 299 + }, 300 + }, 301 + }, 302 + { 303 + args: [], 304 + config: [], 305 + description: 'strip empty slots', 306 + params: {}, 307 + }, 308 + ]; 309 + 310 + it.each(scenarios)('$description', async ({ args, config, params }) => { 311 + expect(buildClientParams(args, config)).toEqual(params); 312 + }); 313 + });
+2
packages/client-core/src/index.ts
··· 10 10 jsonBodySerializer, 11 11 urlSearchParamsBodySerializer, 12 12 } from './bodySerializer'; 13 + export type { Field, Fields, FieldsConfig } from './params'; 14 + export { buildClientParams } from './params'; 13 15 export type { 14 16 ArraySeparatorStyle, 15 17 ArrayStyle,
+141
packages/client-core/src/params.ts
··· 1 + type Slot = 'body' | 'headers' | 'path' | 'query'; 2 + 3 + export type Field = 4 + | { 5 + in: Exclude<Slot, 'body'>; 6 + key: string; 7 + map?: string; 8 + } 9 + | { 10 + in: Extract<Slot, 'body'>; 11 + key?: string; 12 + map?: string; 13 + }; 14 + 15 + export interface Fields { 16 + allowExtra?: Partial<Record<Slot, boolean>>; 17 + args?: ReadonlyArray<Field>; 18 + } 19 + 20 + export type FieldsConfig = ReadonlyArray<Field | Fields>; 21 + 22 + const extraPrefixesMap: Record<string, Slot> = { 23 + $body_: 'body', 24 + $headers_: 'headers', 25 + $path_: 'path', 26 + $query_: 'query', 27 + }; 28 + const extraPrefixes = Object.entries(extraPrefixesMap); 29 + 30 + type KeyMap = Map< 31 + string, 32 + { 33 + in: Slot; 34 + map?: string; 35 + } 36 + >; 37 + 38 + const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 39 + if (!map) { 40 + map = new Map(); 41 + } 42 + 43 + for (const config of fields) { 44 + if ('in' in config) { 45 + if (config.key) { 46 + map.set(config.key, { 47 + in: config.in, 48 + map: config.map, 49 + }); 50 + } 51 + } else if (config.args) { 52 + buildKeyMap(config.args, map); 53 + } 54 + } 55 + 56 + return map; 57 + }; 58 + 59 + interface Params { 60 + body: unknown; 61 + headers: Record<string, unknown>; 62 + path: Record<string, unknown>; 63 + query: Record<string, unknown>; 64 + } 65 + 66 + const stripEmptySlots = (params: Params) => { 67 + for (const [slot, value] of Object.entries(params)) { 68 + if (value && typeof value === 'object' && !Object.keys(value).length) { 69 + delete params[slot as Slot]; 70 + } 71 + } 72 + }; 73 + 74 + export const buildClientParams = ( 75 + args: ReadonlyArray<unknown>, 76 + fields: FieldsConfig, 77 + ) => { 78 + const params: Params = { 79 + body: {}, 80 + headers: {}, 81 + path: {}, 82 + query: {}, 83 + }; 84 + 85 + const map = buildKeyMap(fields); 86 + 87 + let config: FieldsConfig[number] | undefined; 88 + 89 + for (const [index, arg] of args.entries()) { 90 + if (fields[index]) { 91 + config = fields[index]; 92 + } 93 + 94 + if (!config) { 95 + continue; 96 + } 97 + 98 + if ('in' in config) { 99 + if (config.key) { 100 + const field = map.get(config.key)!; 101 + const name = field.map || config.key; 102 + (params[field.in] as Record<string, unknown>)[name] = arg; 103 + } else { 104 + params.body = arg; 105 + } 106 + } else { 107 + for (const [key, value] of Object.entries(arg ?? {})) { 108 + const field = map.get(key); 109 + 110 + if (field) { 111 + const name = field.map || key; 112 + (params[field.in] as Record<string, unknown>)[name] = value; 113 + } else { 114 + const extra = extraPrefixes.find(([prefix]) => 115 + key.startsWith(prefix), 116 + ); 117 + 118 + if (extra) { 119 + const [prefix, slot] = extra; 120 + (params[slot] as Record<string, unknown>)[ 121 + key.slice(prefix.length) 122 + ] = value; 123 + } else { 124 + for (const [slot, allowed] of Object.entries( 125 + config.allowExtra ?? {}, 126 + )) { 127 + if (allowed) { 128 + (params[slot as Slot] as Record<string, unknown>)[key] = value; 129 + break; 130 + } 131 + } 132 + } 133 + } 134 + } 135 + } 136 + } 137 + 138 + stripEmptySlots(params); 139 + 140 + return params; 141 + };
+1
packages/client-custom/src/index.ts
··· 13 13 export { createConfig } from './utils'; 14 14 export type { Auth, QuerySerializerOptions } from '@hey-api/client-core'; 15 15 export { 16 + buildClientParams, 16 17 formDataBodySerializer, 17 18 jsonBodySerializer, 18 19 urlSearchParamsBodySerializer,
+1
packages/client-fetch/src/index.ts
··· 14 14 export { createConfig } from './utils'; 15 15 export type { Auth, QuerySerializerOptions } from '@hey-api/client-core'; 16 16 export { 17 + buildClientParams, 17 18 formDataBodySerializer, 18 19 jsonBodySerializer, 19 20 urlSearchParamsBodySerializer,
+1
packages/client-next/src/index.ts
··· 13 13 export { createConfig } from './utils'; 14 14 export type { Auth, QuerySerializerOptions } from '@hey-api/client-core'; 15 15 export { 16 + buildClientParams, 16 17 formDataBodySerializer, 17 18 jsonBodySerializer, 18 19 urlSearchParamsBodySerializer,
+1
packages/client-nuxt/src/index.ts
··· 14 14 export { createConfig } from './utils'; 15 15 export type { Auth, QuerySerializerOptions } from '@hey-api/client-core'; 16 16 export { 17 + buildClientParams, 17 18 formDataBodySerializer, 18 19 jsonBodySerializer, 19 20 urlSearchParamsBodySerializer,
+1 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/bundle/client/index.cjs
··· 1 - 'use strict';var B=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var B__default=/*#__PURE__*/_interopDefault(B);var w=async(t,e)=>{let r=typeof e=="function"?await e(t):e;if(r)return t.scheme==="bearer"?`Bearer ${r}`:t.scheme==="basic"?`Basic ${btoa(r)}`:r},z=(t,e,r)=>{typeof r=="string"||r instanceof Blob?t.append(e,r):t.append(e,JSON.stringify(r));},O=(t,e,r)=>{typeof r=="string"?t.append(e,r):t.append(e,JSON.stringify(r));},j={bodySerializer:t=>{let e=new FormData;return Object.entries(t).forEach(([r,n])=>{n!=null&&(Array.isArray(n)?n.forEach(i=>z(e,r,i)):z(e,r,n));}),e}},k={bodySerializer:t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString():r)},$={bodySerializer:t=>{let e=new URLSearchParams;return Object.entries(t).forEach(([r,n])=>{n!=null&&(Array.isArray(n)?n.forEach(i=>O(e,r,i)):O(e,r,n));}),e.toString()}},q=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},v=t=>{switch(t){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},P=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},m=({allowReserved:t,explode:e,name:r,style:n,value:i})=>{if(!e){let s=(t?i:i.map(a=>encodeURIComponent(a))).join(v(n));switch(n){case "label":return `.${s}`;case "matrix":return `;${r}=${s}`;case "simple":return s;default:return `${r}=${s}`}}let o=q(n),l=i.map(s=>n==="label"||n==="simple"?t?s:encodeURIComponent(s):f({allowReserved:t,name:r,value:s})).join(o);return n==="label"||n==="matrix"?o+l:l},f=({allowReserved:t,name:e,value:r})=>{if(r==null)return "";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${e}=${t?r:encodeURIComponent(r)}`},g=({allowReserved:t,explode:e,name:r,style:n,value:i})=>{if(i instanceof Date)return `${r}=${i.toISOString()}`;if(n!=="deepObject"&&!e){let s=[];Object.entries(i).forEach(([u,d])=>{s=[...s,u,t?d:encodeURIComponent(d)];});let a=s.join(",");switch(n){case "form":return `${r}=${a}`;case "label":return `.${a}`;case "matrix":return `;${r}=${a}`;default:return a}}let o=P(n),l=Object.entries(i).map(([s,a])=>f({allowReserved:t,name:n==="deepObject"?`${r}[${s}]`:s,value:a})).join(o);return n==="label"||n==="matrix"?o+l:l};var T=/\{[^{}]+\}/g,E=({path:t,url:e})=>{let r=e,n=e.match(T);if(n)for(let i of n){let o=false,l=i.substring(1,i.length-1),s="simple";l.endsWith("*")&&(o=true,l=l.substring(0,l.length-1)),l.startsWith(".")?(l=l.substring(1),s="label"):l.startsWith(";")&&(l=l.substring(1),s="matrix");let a=t[l];if(a==null)continue;if(Array.isArray(a)){r=r.replace(i,m({explode:o,name:l,style:s,value:a}));continue}if(typeof a=="object"){r=r.replace(i,g({explode:o,name:l,style:s,value:a}));continue}if(s==="matrix"){r=r.replace(i,`;${f({name:l,value:a})}`);continue}let u=encodeURIComponent(s==="label"?`.${a}`:a);r=r.replace(i,u);}return r},U=({allowReserved:t,array:e,object:r}={})=>i=>{let o=[];if(i&&typeof i=="object")for(let l in i){let s=i[l];if(s!=null)if(Array.isArray(s)){let a=m({allowReserved:t,explode:true,name:l,style:"form",value:s,...e});a&&o.push(a);}else if(typeof s=="object"){let a=g({allowReserved:t,explode:true,name:l,style:"deepObject",value:s,...r});a&&o.push(a);}else {let a=f({allowReserved:t,name:l,value:s});a&&o.push(a);}}return o.join("&")},A=async({security:t,...e})=>{for(let r of t){let n=await w(r,e.auth);if(!n)continue;let i=r.name??"Authorization";switch(r.in){case "query":e.query||(e.query={}),e.query[i]=n;break;case "cookie":{let o=`${i}=${n}`;"Cookie"in e.headers&&e.headers.Cookie?e.headers.Cookie=`${e.headers.Cookie}; ${o}`:e.headers.Cookie=o;break}case "header":default:e.headers[i]=n;break}return}},b=t=>D({path:t.path,query:t.paramsSerializer?void 0:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:U(t.querySerializer),url:t.url}),D=({path:t,query:e,querySerializer:r,url:n})=>{let o=n.startsWith("/")?n:`/${n}`;t&&(o=E({path:t,url:o}));let l=e?r(e):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(o+=`?${l}`),o},C=(t,e)=>{let r={...t,...e};return r.headers=y(t.headers,e.headers),r},H=["common","delete","get","head","patch","post","put"],y=(...t)=>{let e={};for(let r of t){if(!r||typeof r!="object")continue;let n=Object.entries(r);for(let[i,o]of n)if(H.includes(i)&&typeof o=="object")e[i]={...e[i],...o};else if(o===null)delete e[i];else if(Array.isArray(o))for(let l of o)e[i]=[...e[i]??[],l];else o!==void 0&&(e[i]=typeof o=="object"?JSON.stringify(o):o);}return e},S=(t={})=>({...t});var I=(t={})=>{let e=C(S(),t),{auth:r,...n}=e,i=B__default.default.create(n),o=()=>({...e}),l=a=>(e=C(e,a),i.defaults={...i.defaults,...e,headers:y(i.defaults.headers,e.headers)},o()),s=async a=>{let u={...e,...a,axios:a.axios??e.axios??i,headers:y(e.headers,a.headers)};u.security&&await A({...u,security:u.security}),u.body&&u.bodySerializer&&(u.body=u.bodySerializer(u.body));let d=b(u);try{let h=u.axios,{auth:c,...R}=u,x=await h({...R,baseURL:u.baseURL,data:u.body,headers:u.headers,params:u.paramsSerializer?u.query:void 0,url:d}),{data:p}=x;return u.responseType==="json"&&(u.responseValidator&&await u.responseValidator(p),u.responseTransformer&&(p=await u.responseTransformer(p))),{...x,data:p??{}}}catch(h){let c=h;if(u.throwOnError)throw c;return c.error=c.response?.data??{},c}};return {buildUrl:b,delete:a=>s({...a,method:"DELETE"}),get:a=>s({...a,method:"GET"}),getConfig:o,head:a=>s({...a,method:"HEAD"}),instance:i,options:a=>s({...a,method:"OPTIONS"}),patch:a=>s({...a,method:"PATCH"}),post:a=>s({...a,method:"POST"}),put:a=>s({...a,method:"PUT"}),request:s,setConfig:l}};exports.createClient=I;exports.createConfig=S;exports.formDataBodySerializer=j;exports.jsonBodySerializer=k;exports.urlSearchParamsBodySerializer=$;//# sourceMappingURL=index.cjs.map 1 + 'use strict';var L=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var L__default=/*#__PURE__*/_interopDefault(L);var w=async(t,r)=>{let e=typeof r=="function"?await r(t):r;if(e)return t.scheme==="bearer"?`Bearer ${e}`:t.scheme==="basic"?`Basic ${btoa(e)}`:e},O=(t,r,e)=>{typeof e=="string"||e instanceof Blob?t.append(r,e):t.append(r,JSON.stringify(e));},z=(t,r,e)=>{typeof e=="string"?t.append(r,e):t.append(r,JSON.stringify(e));},R={bodySerializer:t=>{let r=new FormData;return Object.entries(t).forEach(([e,s])=>{s!=null&&(Array.isArray(s)?s.forEach(i=>O(r,e,i)):O(r,e,s));}),r}},$={bodySerializer:t=>JSON.stringify(t,(r,e)=>typeof e=="bigint"?e.toString():e)},q={bodySerializer:t=>{let r=new URLSearchParams;return Object.entries(t).forEach(([e,s])=>{s!=null&&(Array.isArray(s)?s.forEach(i=>z(r,e,i)):z(r,e,s));}),r.toString()}},P={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},v=Object.entries(P),A=(t,r)=>{r||(r=new Map);for(let e of t)"in"in e?e.key&&r.set(e.key,{in:e.in,map:e.map}):e.args&&A(e.args,r);return r},T=t=>{for(let[r,e]of Object.entries(t))e&&typeof e=="object"&&!Object.keys(e).length&&delete t[r];},E=(t,r)=>{let e={body:{},headers:{},path:{},query:{}},s=A(r),i;for(let[l,o]of t.entries())if(r[l]&&(i=r[l]),!!i)if("in"in i)if(i.key){let n=s.get(i.key),a=n.map||i.key;e[n.in][a]=o;}else e.body=o;else for(let[n,a]of Object.entries(o??{})){let u=s.get(n);if(u){let c=u.map||n;e[u.in][c]=a;}else {let c=v.find(([f])=>n.startsWith(f));if(c){let[f,d]=c;e[d][n.slice(f.length)]=a;}else for(let[f,d]of Object.entries(i.allowExtra??{}))if(d){e[f][n]=a;break}}}return T(e),e},U=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},D=t=>{switch(t){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},H=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},m=({allowReserved:t,explode:r,name:e,style:s,value:i})=>{if(!r){let n=(t?i:i.map(a=>encodeURIComponent(a))).join(D(s));switch(s){case "label":return `.${n}`;case "matrix":return `;${e}=${n}`;case "simple":return n;default:return `${e}=${n}`}}let l=U(s),o=i.map(n=>s==="label"||s==="simple"?t?n:encodeURIComponent(n):p({allowReserved:t,name:e,value:n})).join(l);return s==="label"||s==="matrix"?l+o:o},p=({allowReserved:t,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}=${t?e:encodeURIComponent(e)}`},g=({allowReserved:t,explode:r,name:e,style:s,value:i})=>{if(i instanceof Date)return `${e}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let n=[];Object.entries(i).forEach(([u,c])=>{n=[...n,u,t?c:encodeURIComponent(c)];});let a=n.join(",");switch(s){case "form":return `${e}=${a}`;case "label":return `.${a}`;case "matrix":return `;${e}=${a}`;default:return a}}let l=H(s),o=Object.entries(i).map(([n,a])=>p({allowReserved:t,name:s==="deepObject"?`${e}[${n}]`:n,value:a})).join(l);return s==="label"||s==="matrix"?l+o:o};var B=/\{[^{}]+\}/g,W=({path:t,url:r})=>{let e=r,s=r.match(B);if(s)for(let i of s){let l=false,o=i.substring(1,i.length-1),n="simple";o.endsWith("*")&&(l=true,o=o.substring(0,o.length-1)),o.startsWith(".")?(o=o.substring(1),n="label"):o.startsWith(";")&&(o=o.substring(1),n="matrix");let a=t[o];if(a==null)continue;if(Array.isArray(a)){e=e.replace(i,m({explode:l,name:o,style:n,value:a}));continue}if(typeof a=="object"){e=e.replace(i,g({explode:l,name:o,style:n,value:a}));continue}if(n==="matrix"){e=e.replace(i,`;${p({name:o,value:a})}`);continue}let u=encodeURIComponent(n==="label"?`.${a}`:a);e=e.replace(i,u);}return e},I=({allowReserved:t,array:r,object:e}={})=>i=>{let l=[];if(i&&typeof i=="object")for(let o in i){let n=i[o];if(n!=null)if(Array.isArray(n)){let a=m({allowReserved:t,explode:true,name:o,style:"form",value:n,...r});a&&l.push(a);}else if(typeof n=="object"){let a=g({allowReserved:t,explode:true,name:o,style:"deepObject",value:n,...e});a&&l.push(a);}else {let a=p({allowReserved:t,name:o,value:n});a&&l.push(a);}}return l.join("&")},j=async({security:t,...r})=>{for(let e of t){let s=await w(e,r.auth);if(!s)continue;let i=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[i]=s;break;case "cookie":{let l=`${i}=${s}`;"Cookie"in r.headers&&r.headers.Cookie?r.headers.Cookie=`${r.headers.Cookie}; ${l}`:r.headers.Cookie=l;break}case "header":default:r.headers[i]=s;break}return}},b=t=>N({path:t.path,query:t.paramsSerializer?void 0:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:I(t.querySerializer),url:t.url}),N=({path:t,query:r,querySerializer:e,url:s})=>{let l=s.startsWith("/")?s:`/${s}`;t&&(l=W({path:t,url:l}));let o=r?e(r):"";return o.startsWith("?")&&(o=o.substring(1)),o&&(l+=`?${o}`),l},C=(t,r)=>{let e={...t,...r};return e.headers=h(t.headers,r.headers),e},Q=["common","delete","get","head","patch","post","put"],h=(...t)=>{let r={};for(let e of t){if(!e||typeof e!="object")continue;let s=Object.entries(e);for(let[i,l]of s)if(Q.includes(i)&&typeof l=="object")r[i]={...r[i],...l};else if(l===null)delete r[i];else if(Array.isArray(l))for(let o of l)r[i]=[...r[i]??[],o];else l!==void 0&&(r[i]=typeof l=="object"?JSON.stringify(l):l);}return r},S=(t={})=>({...t});var _=(t={})=>{let r=C(S(),t),{auth:e,...s}=r,i=L__default.default.create(s),l=()=>({...r}),o=a=>(r=C(r,a),i.defaults={...i.defaults,...r,headers:h(i.defaults.headers,r.headers)},l()),n=async a=>{let u={...r,...a,axios:a.axios??r.axios??i,headers:h(r.headers,a.headers)};u.security&&await j({...u,security:u.security}),u.body&&u.bodySerializer&&(u.body=u.bodySerializer(u.body));let c=b(u);try{let f=u.axios,{auth:d,...k}=u,x=await f({...k,baseURL:u.baseURL,data:u.body,headers:u.headers,params:u.paramsSerializer?u.query:void 0,url:c}),{data:y}=x;return u.responseType==="json"&&(u.responseValidator&&await u.responseValidator(y),u.responseTransformer&&(y=await u.responseTransformer(y))),{...x,data:y??{}}}catch(f){let d=f;if(u.throwOnError)throw d;return d.error=d.response?.data??{},d}};return {buildUrl:b,delete:a=>n({...a,method:"DELETE"}),get:a=>n({...a,method:"GET"}),getConfig:l,head:a=>n({...a,method:"HEAD"}),instance:i,options:a=>n({...a,method:"OPTIONS"}),patch:a=>n({...a,method:"PATCH"}),post:a=>n({...a,method:"POST"}),put:a=>n({...a,method:"PUT"}),request:n,setConfig:o}};exports.buildClientParams=E;exports.createClient=_;exports.createConfig=S;exports.formDataBodySerializer=R;exports.jsonBodySerializer=$;exports.urlSearchParamsBodySerializer=q;//# sourceMappingURL=index.cjs.map 2 2 //# sourceMappingURL=index.cjs.map
+24 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/bundle/client/index.d.cts
··· 44 44 bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string; 45 45 }; 46 46 47 + type Slot = 'body' | 'headers' | 'path' | 'query'; 48 + type Field = { 49 + in: Exclude<Slot, 'body'>; 50 + key: string; 51 + map?: string; 52 + } | { 53 + in: Extract<Slot, 'body'>; 54 + key?: string; 55 + map?: string; 56 + }; 57 + interface Fields { 58 + allowExtra?: Partial<Record<Slot, boolean>>; 59 + args?: ReadonlyArray<Field>; 60 + } 61 + type FieldsConfig = ReadonlyArray<Field | Fields>; 62 + interface Params { 63 + body: unknown; 64 + headers: Record<string, unknown>; 65 + path: Record<string, unknown>; 66 + query: Record<string, unknown>; 67 + } 68 + declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 69 + 47 70 interface Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> { 48 71 /** 49 72 * Returns the final request URL. ··· 204 227 205 228 declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>; 206 229 207 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; 230 + export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
+24 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/bundle/client/index.d.ts
··· 44 44 bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string; 45 45 }; 46 46 47 + type Slot = 'body' | 'headers' | 'path' | 'query'; 48 + type Field = { 49 + in: Exclude<Slot, 'body'>; 50 + key: string; 51 + map?: string; 52 + } | { 53 + in: Extract<Slot, 'body'>; 54 + key?: string; 55 + map?: string; 56 + }; 57 + interface Fields { 58 + allowExtra?: Partial<Record<Slot, boolean>>; 59 + args?: ReadonlyArray<Field>; 60 + } 61 + type FieldsConfig = ReadonlyArray<Field | Fields>; 62 + interface Params { 63 + body: unknown; 64 + headers: Record<string, unknown>; 65 + path: Record<string, unknown>; 66 + query: Record<string, unknown>; 67 + } 68 + declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 69 + 47 70 interface Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> { 48 71 /** 49 72 * Returns the final request URL. ··· 204 227 205 228 declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>; 206 229 207 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; 230 + export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
+1 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/bundle/client/index.cjs
··· 1 - 'use strict';var j=async(s,r)=>{let e=typeof r=="function"?await r(s):r;if(e)return s.scheme==="bearer"?`Bearer ${e}`:s.scheme==="basic"?`Basic ${btoa(e)}`:e},z=(s,r,e)=>{typeof e=="string"||e instanceof Blob?s.append(r,e):s.append(r,JSON.stringify(e));},I=(s,r,e)=>{typeof e=="string"?s.append(r,e):s.append(r,JSON.stringify(e));},k={bodySerializer:s=>{let r=new FormData;return Object.entries(s).forEach(([e,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>z(r,e,a)):z(r,e,i));}),r}},R={bodySerializer:s=>JSON.stringify(s,(r,e)=>typeof e=="bigint"?e.toString():e)},$={bodySerializer:s=>{let r=new URLSearchParams;return Object.entries(s).forEach(([e,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>I(r,e,a)):I(r,e,i));}),r.toString()}},U=s=>{switch(s){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},_=s=>{switch(s){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},D=s=>{switch(s){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},O=({allowReserved:s,explode:r,name:e,style:i,value:a})=>{if(!r){let t=(s?a:a.map(l=>encodeURIComponent(l))).join(_(i));switch(i){case "label":return `.${t}`;case "matrix":return `;${e}=${t}`;case "simple":return t;default:return `${e}=${t}`}}let o=U(i),n=a.map(t=>i==="label"||i==="simple"?s?t:encodeURIComponent(t):h({allowReserved:s,name:e,value:t})).join(o);return i==="label"||i==="matrix"?o+n:n},h=({allowReserved:s,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}=${s?e:encodeURIComponent(e)}`},S=({allowReserved:s,explode:r,name:e,style:i,value:a})=>{if(a instanceof Date)return `${e}=${a.toISOString()}`;if(i!=="deepObject"&&!r){let t=[];Object.entries(a).forEach(([f,p])=>{t=[...t,f,s?p:encodeURIComponent(p)];});let l=t.join(",");switch(i){case "form":return `${e}=${l}`;case "label":return `.${l}`;case "matrix":return `;${e}=${l}`;default:return l}}let o=D(i),n=Object.entries(a).map(([t,l])=>h({allowReserved:s,name:i==="deepObject"?`${e}[${t}]`:t,value:l})).join(o);return i==="label"||i==="matrix"?o+n:n};var H=/\{[^{}]+\}/g,B=({path:s,url:r})=>{let e=r,i=r.match(H);if(i)for(let a of i){let o=false,n=a.substring(1,a.length-1),t="simple";n.endsWith("*")&&(o=true,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),t="label"):n.startsWith(";")&&(n=n.substring(1),t="matrix");let l=s[n];if(l==null)continue;if(Array.isArray(l)){e=e.replace(a,O({explode:o,name:n,style:t,value:l}));continue}if(typeof l=="object"){e=e.replace(a,S({explode:o,name:n,style:t,value:l}));continue}if(t==="matrix"){e=e.replace(a,`;${h({name:n,value:l})}`);continue}let f=encodeURIComponent(t==="label"?`.${l}`:l);e=e.replace(a,f);}return e},A=({allowReserved:s,array:r,object:e}={})=>a=>{let o=[];if(a&&typeof a=="object")for(let n in a){let t=a[n];if(t!=null)if(Array.isArray(t)){let l=O({allowReserved:s,explode:true,name:n,style:"form",value:t,...r});l&&o.push(l);}else if(typeof t=="object"){let l=S({allowReserved:s,explode:true,name:n,style:"deepObject",value:t,...e});l&&o.push(l);}else {let l=h({allowReserved:s,name:n,value:t});l&&o.push(l);}}return o.join("&")},P=s=>{if(!s)return "stream";let r=s.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},E=async({security:s,...r})=>{for(let e of s){let i=await j(e,r.auth);if(!i)continue;let a=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[a]=i;break;case "cookie":r.headers.append("Cookie",`${a}=${i}`);break;case "header":default:r.headers.set(a,i);break}return}},q=s=>W({baseUrl:s.baseUrl,path:s.path,query:s.query,querySerializer:typeof s.querySerializer=="function"?s.querySerializer:A(s.querySerializer),url:s.url}),W=({baseUrl:s,path:r,query:e,querySerializer:i,url:a})=>{let o=a.startsWith("/")?a:`/${a}`,n=(s??"")+o;r&&(n=B({path:r,url:n}));let t=e?i(e):"";return t.startsWith("?")&&(t=t.substring(1)),t&&(n+=`?${t}`),n},x=(s,r)=>{let e={...s,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=C(s.headers,r.headers),e},C=(...s)=>{let r=new Headers;for(let e of s){if(!e||typeof e!="object")continue;let i=e instanceof Headers?e.entries():Object.entries(e);for(let[a,o]of i)if(o===null)r.delete(a);else if(Array.isArray(o))for(let n of o)r.append(a,n);else o!==void 0&&r.set(a,typeof o=="object"?JSON.stringify(o):o);}return r},m=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let i=this.getInterceptorIndex(r);return this._fns[i]?(this._fns[i]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},v=()=>({error:new m,request:new m,response:new m}),N=A({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Q={"Content-Type":"application/json"},w=(s={})=>({...R,headers:Q,parseAs:"auto",querySerializer:N,...s});var J=(s={})=>{let r=x(w(),s),e=()=>({...r}),i=n=>(r=x(r,n),e()),a=v(),o=async n=>{let t={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:C(r.headers,n.headers)};t.security&&await E({...t,security:t.security}),t.body&&t.bodySerializer&&(t.body=t.bodySerializer(t.body)),(t.body===void 0||t.body==="")&&t.headers.delete("Content-Type");let l=q(t),f={redirect:"follow",...t},p=new Request(l,f);for(let u of a.request._fns)u&&(p=await u(p,t));let T=t.fetch,c=await T(p);for(let u of a.response._fns)u&&(c=await u(c,p,t));let g={request:p,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return t.responseStyle==="data"?{}:{data:{},...g};let u=(t.parseAs==="auto"?P(c.headers.get("Content-Type")):t.parseAs)??"json";if(u==="stream")return t.responseStyle==="data"?c.body:{data:c.body,...g};let y=await c[u]();return u==="json"&&(t.responseValidator&&await t.responseValidator(y),t.responseTransformer&&(y=await t.responseTransformer(y))),t.responseStyle==="data"?y:{data:y,...g}}let b=await c.text();try{b=JSON.parse(b);}catch{}let d=b;for(let u of a.error._fns)u&&(d=await u(b,c,p,t));if(d=d||{},t.throwOnError)throw d;return t.responseStyle==="data"?void 0:{error:d,...g}};return {buildUrl:q,connect:n=>o({...n,method:"CONNECT"}),delete:n=>o({...n,method:"DELETE"}),get:n=>o({...n,method:"GET"}),getConfig:e,head:n=>o({...n,method:"HEAD"}),interceptors:a,options:n=>o({...n,method:"OPTIONS"}),patch:n=>o({...n,method:"PATCH"}),post:n=>o({...n,method:"POST"}),put:n=>o({...n,method:"PUT"}),request:o,setConfig:i,trace:n=>o({...n,method:"TRACE"})}};exports.createClient=J;exports.createConfig=w;exports.formDataBodySerializer=k;exports.jsonBodySerializer=R;exports.urlSearchParamsBodySerializer=$;//# sourceMappingURL=index.cjs.map 1 + 'use strict';var I=async(n,r)=>{let e=typeof r=="function"?await r(n):r;if(e)return n.scheme==="bearer"?`Bearer ${e}`:n.scheme==="basic"?`Basic ${btoa(e)}`:e},z=(n,r,e)=>{typeof e=="string"||e instanceof Blob?n.append(r,e):n.append(r,JSON.stringify(e));},A=(n,r,e)=>{typeof e=="string"?n.append(r,e):n.append(r,JSON.stringify(e));},T={bodySerializer:n=>{let r=new FormData;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(i=>z(r,e,i)):z(r,e,a));}),r}},O={bodySerializer:n=>JSON.stringify(n,(r,e)=>typeof e=="bigint"?e.toString():e)},_={bodySerializer:n=>{let r=new URLSearchParams;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(i=>A(r,e,i)):A(r,e,a));}),r.toString()}},U={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},D=Object.entries(U),P=(n,r)=>{r||(r=new Map);for(let e of n)"in"in e?e.key&&r.set(e.key,{in:e.in,map:e.map}):e.args&&P(e.args,r);return r},H=n=>{for(let[r,e]of Object.entries(n))e&&typeof e=="object"&&!Object.keys(e).length&&delete n[r];},W=(n,r)=>{let e={body:{},headers:{},path:{},query:{}},a=P(r),i;for(let[o,s]of n.entries())if(r[o]&&(i=r[o]),!!i)if("in"in i)if(i.key){let t=a.get(i.key),l=t.map||i.key;e[t.in][l]=s;}else e.body=s;else for(let[t,l]of Object.entries(s??{})){let f=a.get(t);if(f){let u=f.map||t;e[f.in][u]=l;}else {let u=D.find(([d])=>t.startsWith(d));if(u){let[d,c]=u;e[c][t.slice(d.length)]=l;}else for(let[d,c]of Object.entries(i.allowExtra??{}))if(c){e[d][t]=l;break}}}return H(e),e},B=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},N=n=>{switch(n){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},Q=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},S=({allowReserved:n,explode:r,name:e,style:a,value:i})=>{if(!r){let t=(n?i:i.map(l=>encodeURIComponent(l))).join(N(a));switch(a){case "label":return `.${t}`;case "matrix":return `;${e}=${t}`;case "simple":return t;default:return `${e}=${t}`}}let o=B(a),s=i.map(t=>a==="label"||a==="simple"?n?t:encodeURIComponent(t):m({allowReserved:n,name:e,value:t})).join(o);return a==="label"||a==="matrix"?o+s:s},m=({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)}`},q=({allowReserved:n,explode:r,name:e,style:a,value:i})=>{if(i instanceof Date)return `${e}=${i.toISOString()}`;if(a!=="deepObject"&&!r){let t=[];Object.entries(i).forEach(([f,u])=>{t=[...t,f,n?u:encodeURIComponent(u)];});let l=t.join(",");switch(a){case "form":return `${e}=${l}`;case "label":return `.${l}`;case "matrix":return `;${e}=${l}`;default:return l}}let o=Q(a),s=Object.entries(i).map(([t,l])=>m({allowReserved:n,name:a==="deepObject"?`${e}[${t}]`:t,value:l})).join(o);return a==="label"||a==="matrix"?o+s:s};var J=/\{[^{}]+\}/g,M=({path:n,url:r})=>{let e=r,a=r.match(J);if(a)for(let i of a){let o=false,s=i.substring(1,i.length-1),t="simple";s.endsWith("*")&&(o=true,s=s.substring(0,s.length-1)),s.startsWith(".")?(s=s.substring(1),t="label"):s.startsWith(";")&&(s=s.substring(1),t="matrix");let l=n[s];if(l==null)continue;if(Array.isArray(l)){e=e.replace(i,S({explode:o,name:s,style:t,value:l}));continue}if(typeof l=="object"){e=e.replace(i,q({explode:o,name:s,style:t,value:l}));continue}if(t==="matrix"){e=e.replace(i,`;${m({name:s,value:l})}`);continue}let f=encodeURIComponent(t==="label"?`.${l}`:l);e=e.replace(i,f);}return e},k=({allowReserved:n,array:r,object:e}={})=>i=>{let o=[];if(i&&typeof i=="object")for(let s in i){let t=i[s];if(t!=null)if(Array.isArray(t)){let l=S({allowReserved:n,explode:true,name:s,style:"form",value:t,...r});l&&o.push(l);}else if(typeof t=="object"){let l=q({allowReserved:n,explode:true,name:s,style:"deepObject",value:t,...e});l&&o.push(l);}else {let l=m({allowReserved:n,name:s,value:t});l&&o.push(l);}}return o.join("&")},E=n=>{if(!n)return "stream";let r=n.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},$=async({security:n,...r})=>{for(let e of n){let a=await I(e,r.auth);if(!a)continue;let i=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[i]=a;break;case "cookie":r.headers.append("Cookie",`${i}=${a}`);break;case "header":default:r.headers.set(i,a);break}return}},C=n=>L({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:k(n.querySerializer),url:n.url}),L=({baseUrl:n,path:r,query:e,querySerializer:a,url:i})=>{let o=i.startsWith("/")?i:`/${i}`,s=(n??"")+o;r&&(s=M({path:r,url:s}));let t=e?a(e):"";return t.startsWith("?")&&(t=t.substring(1)),t&&(s+=`?${t}`),s},x=(n,r)=>{let e={...n,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=j(n.headers,r.headers),e},j=(...n)=>{let r=new Headers;for(let e of n){if(!e||typeof e!="object")continue;let a=e instanceof Headers?e.entries():Object.entries(e);for(let[i,o]of a)if(o===null)r.delete(i);else if(Array.isArray(o))for(let s of o)r.append(i,s);else o!==void 0&&r.set(i,typeof o=="object"?JSON.stringify(o):o);}return r},g=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let a=this.getInterceptorIndex(r);return this._fns[a]?(this._fns[a]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},v=()=>({error:new g,request:new g,response:new g}),V=k({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),F={"Content-Type":"application/json"},w=(n={})=>({...O,headers:F,parseAs:"auto",querySerializer:V,...n});var G=(n={})=>{let r=x(w(),n),e=()=>({...r}),a=s=>(r=x(r,s),e()),i=v(),o=async s=>{let t={...r,...s,fetch:s.fetch??r.fetch??globalThis.fetch,headers:j(r.headers,s.headers)};t.security&&await $({...t,security:t.security}),t.body&&t.bodySerializer&&(t.body=t.bodySerializer(t.body)),(t.body===void 0||t.body==="")&&t.headers.delete("Content-Type");let l=C(t),f={redirect:"follow",...t},u=new Request(l,f);for(let p of i.request._fns)p&&(u=await p(u,t));let d=t.fetch,c=await d(u);for(let p of i.response._fns)p&&(c=await p(c,u,t));let b={request:u,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return t.responseStyle==="data"?{}:{data:{},...b};let p=(t.parseAs==="auto"?E(c.headers.get("Content-Type")):t.parseAs)??"json";if(p==="stream")return t.responseStyle==="data"?c.body:{data:c.body,...b};let h=await c[p]();return p==="json"&&(t.responseValidator&&await t.responseValidator(h),t.responseTransformer&&(h=await t.responseTransformer(h))),t.responseStyle==="data"?h:{data:h,...b}}let R=await c.text();try{R=JSON.parse(R);}catch{}let y=R;for(let p of i.error._fns)p&&(y=await p(R,c,u,t));if(y=y||{},t.throwOnError)throw y;return t.responseStyle==="data"?void 0:{error:y,...b}};return {buildUrl:C,connect:s=>o({...s,method:"CONNECT"}),delete:s=>o({...s,method:"DELETE"}),get:s=>o({...s,method:"GET"}),getConfig:e,head:s=>o({...s,method:"HEAD"}),interceptors:i,options:s=>o({...s,method:"OPTIONS"}),patch:s=>o({...s,method:"PATCH"}),post:s=>o({...s,method:"POST"}),put:s=>o({...s,method:"PUT"}),request:o,setConfig:a,trace:s=>o({...s,method:"TRACE"})}};exports.buildClientParams=W;exports.createClient=G;exports.createConfig=w;exports.formDataBodySerializer=T;exports.jsonBodySerializer=O;exports.urlSearchParamsBodySerializer=_;//# sourceMappingURL=index.cjs.map 2 2 //# sourceMappingURL=index.cjs.map
+24 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/bundle/client/index.d.cts
··· 42 42 bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string; 43 43 }; 44 44 45 + type Slot = 'body' | 'headers' | 'path' | 'query'; 46 + type Field = { 47 + in: Exclude<Slot, 'body'>; 48 + key: string; 49 + map?: string; 50 + } | { 51 + in: Extract<Slot, 'body'>; 52 + key?: string; 53 + map?: string; 54 + }; 55 + interface Fields { 56 + allowExtra?: Partial<Record<Slot, boolean>>; 57 + args?: ReadonlyArray<Field>; 58 + } 59 + type FieldsConfig = ReadonlyArray<Field | Fields>; 60 + interface Params { 61 + body: unknown; 62 + headers: Record<string, unknown>; 63 + path: Record<string, unknown>; 64 + query: Record<string, unknown>; 65 + } 66 + declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 67 + 45 68 interface Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> { 46 69 /** 47 70 * Returns the final request URL. ··· 246 269 247 270 declare const createClient: (config?: Config) => Client; 248 271 249 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type ResponseStyle, type TDataShape, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; 272 + export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type ResponseStyle, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
+24 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/bundle/client/index.d.ts
··· 42 42 bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string; 43 43 }; 44 44 45 + type Slot = 'body' | 'headers' | 'path' | 'query'; 46 + type Field = { 47 + in: Exclude<Slot, 'body'>; 48 + key: string; 49 + map?: string; 50 + } | { 51 + in: Extract<Slot, 'body'>; 52 + key?: string; 53 + map?: string; 54 + }; 55 + interface Fields { 56 + allowExtra?: Partial<Record<Slot, boolean>>; 57 + args?: ReadonlyArray<Field>; 58 + } 59 + type FieldsConfig = ReadonlyArray<Field | Fields>; 60 + interface Params { 61 + body: unknown; 62 + headers: Record<string, unknown>; 63 + path: Record<string, unknown>; 64 + query: Record<string, unknown>; 65 + } 66 + declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 67 + 45 68 interface Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> { 46 69 /** 47 70 * Returns the final request URL. ··· 246 269 247 270 declare const createClient: (config?: Config) => Client; 248 271 249 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type ResponseStyle, type TDataShape, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; 272 + export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type ResponseStyle, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
+1 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/bundle/client/index.cjs
··· 1 - 'use strict';var A=async(n,r)=>{let e=typeof r=="function"?await r(n):r;if(e)return n.scheme==="bearer"?`Bearer ${e}`:n.scheme==="basic"?`Basic ${btoa(e)}`:e},w=(n,r,e)=>{typeof e=="string"||e instanceof Blob?n.append(r,e):n.append(r,JSON.stringify(e));},j=(n,r,e)=>{typeof e=="string"?n.append(r,e):n.append(r,JSON.stringify(e));},v={bodySerializer:n=>{let r=new FormData;return Object.entries(n).forEach(([e,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>w(r,e,a)):w(r,e,i));}),r}},b={bodySerializer:n=>JSON.stringify(n,(r,e)=>typeof e=="bigint"?e.toString():e)},T={bodySerializer:n=>{let r=new URLSearchParams;return Object.entries(n).forEach(([e,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>j(r,e,a)):j(r,e,i));}),r.toString()}},k=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},$=n=>{switch(n){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},U=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},O=({allowReserved:n,explode:r,name:e,style:i,value:a})=>{if(!r){let t=(n?a:a.map(l=>encodeURIComponent(l))).join($(i));switch(i){case "label":return `.${t}`;case "matrix":return `;${e}=${t}`;case "simple":return t;default:return `${e}=${t}`}}let o=k(i),s=a.map(t=>i==="label"||i==="simple"?n?t:encodeURIComponent(t):d({allowReserved:n,name:e,value:t})).join(o);return i==="label"||i==="matrix"?o+s:s},d=({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)}`},S=({allowReserved:n,explode:r,name:e,style:i,value:a})=>{if(a instanceof Date)return `${e}=${a.toISOString()}`;if(i!=="deepObject"&&!r){let t=[];Object.entries(a).forEach(([p,c])=>{t=[...t,p,n?c:encodeURIComponent(c)];});let l=t.join(",");switch(i){case "form":return `${e}=${l}`;case "label":return `.${l}`;case "matrix":return `;${e}=${l}`;default:return l}}let o=U(i),s=Object.entries(a).map(([t,l])=>d({allowReserved:n,name:i==="deepObject"?`${e}[${t}]`:t,value:l})).join(o);return i==="label"||i==="matrix"?o+s:s};var _=/\{[^{}]+\}/g,D=({path:n,url:r})=>{let e=r,i=r.match(_);if(i)for(let a of i){let o=false,s=a.substring(1,a.length-1),t="simple";s.endsWith("*")&&(o=true,s=s.substring(0,s.length-1)),s.startsWith(".")?(s=s.substring(1),t="label"):s.startsWith(";")&&(s=s.substring(1),t="matrix");let l=n[s];if(l==null)continue;if(Array.isArray(l)){e=e.replace(a,O({explode:o,name:s,style:t,value:l}));continue}if(typeof l=="object"){e=e.replace(a,S({explode:o,name:s,style:t,value:l}));continue}if(t==="matrix"){e=e.replace(a,`;${d({name:s,value:l})}`);continue}let p=encodeURIComponent(t==="label"?`.${l}`:l);e=e.replace(a,p);}return e},I=({allowReserved:n,array:r,object:e}={})=>a=>{let o=[];if(a&&typeof a=="object")for(let s in a){let t=a[s];if(t!=null)if(Array.isArray(t)){let l=O({allowReserved:n,explode:true,name:s,style:"form",value:t,...r});l&&o.push(l);}else if(typeof t=="object"){let l=S({allowReserved:n,explode:true,name:s,style:"deepObject",value:t,...e});l&&o.push(l);}else {let l=d({allowReserved:n,name:s,value:t});l&&o.push(l);}}return o.join("&")},q=n=>{if(!n)return "stream";let r=n.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},P=async({security:n,...r})=>{for(let e of n){let i=await A(e,r.auth);if(!i)continue;let a=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[a]=i;break;case "cookie":r.headers.append("Cookie",`${a}=${i}`);break;case "header":default:r.headers.set(a,i);break}return}},x=n=>H({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:I(n.querySerializer),url:n.url}),H=({baseUrl:n,path:r,query:e,querySerializer:i,url:a})=>{let o=a.startsWith("/")?a:`/${a}`,s=(n??"")+o;r&&(s=D({path:r,url:s}));let t=e?i(e):"";return t.startsWith("?")&&(t=t.substring(1)),t&&(s+=`?${t}`),s},C=(n,r)=>{let e={...n,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=R(n.headers,r.headers),e},R=(...n)=>{let r=new Headers;for(let e of n){if(!e||typeof e!="object")continue;let i=e instanceof Headers?e.entries():Object.entries(e);for(let[a,o]of i)if(o===null)r.delete(a);else if(Array.isArray(o))for(let s of o)r.append(a,s);else o!==void 0&&r.set(a,typeof o=="object"?JSON.stringify(o):o);}return r},y=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let i=this.getInterceptorIndex(r);return this._fns[i]?(this._fns[i]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},E=()=>({error:new y,request:new y,response:new y}),B=I({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),W={"Content-Type":"application/json"},z=(n={})=>({...b,headers:W,parseAs:"auto",querySerializer:B,...n});var N=(n={})=>{let r=C(z(),n),e=()=>({...r}),i=s=>(r=C(r,s),e()),a=E(),o=async s=>{let t={...r,...s,fetch:s.fetch??r.fetch??globalThis.fetch,headers:R(r.headers,s.headers)};t.security&&await P({...t,security:t.security}),t.body&&t.bodySerializer&&(t.body=t.bodySerializer(t.body)),(t.body===void 0||t.body==="")&&t.headers.delete("Content-Type");for(let u of a.request._fns)u&&await u(t);let l=x(t),p=t.fetch,c=await p(l,{...t,body:t.body});for(let u of a.response._fns)u&&(c=await u(c,t));let h={response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return {data:{},...h};let u=(t.parseAs==="auto"?q(c.headers.get("Content-Type")):t.parseAs)??"json";if(u==="stream")return {data:c.body,...h};let g=await c[u]();return u==="json"&&(t.responseValidator&&await t.responseValidator(g),t.responseTransformer&&(g=await t.responseTransformer(g))),{data:g,...h}}let m=await c.text();try{m=JSON.parse(m);}catch{}let f=m;for(let u of a.error._fns)u&&(f=await u(m,c,t));if(f=f||{},t.throwOnError)throw f;return {error:f,...h}};return {buildUrl:x,connect:s=>o({...s,method:"CONNECT"}),delete:s=>o({...s,method:"DELETE"}),get:s=>o({...s,method:"GET"}),getConfig:e,head:s=>o({...s,method:"HEAD"}),interceptors:a,options:s=>o({...s,method:"OPTIONS"}),patch:s=>o({...s,method:"PATCH"}),post:s=>o({...s,method:"POST"}),put:s=>o({...s,method:"PUT"}),request:o,setConfig:i,trace:s=>o({...s,method:"TRACE"})}};exports.createClient=N;exports.createConfig=z;exports.formDataBodySerializer=v;exports.jsonBodySerializer=b;exports.urlSearchParamsBodySerializer=T;//# sourceMappingURL=index.cjs.map 1 + 'use strict';var A=async(n,r)=>{let e=typeof r=="function"?await r(n):r;if(e)return n.scheme==="bearer"?`Bearer ${e}`:n.scheme==="basic"?`Basic ${btoa(e)}`:e},w=(n,r,e)=>{typeof e=="string"||e instanceof Blob?n.append(r,e):n.append(r,JSON.stringify(e));},z=(n,r,e)=>{typeof e=="string"?n.append(r,e):n.append(r,JSON.stringify(e));},$={bodySerializer:n=>{let r=new FormData;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(i=>w(r,e,i)):w(r,e,a));}),r}},b={bodySerializer:n=>JSON.stringify(n,(r,e)=>typeof e=="bigint"?e.toString():e)},v={bodySerializer:n=>{let r=new URLSearchParams;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(i=>z(r,e,i)):z(r,e,a));}),r.toString()}},T={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},_=Object.entries(T),I=(n,r)=>{r||(r=new Map);for(let e of n)"in"in e?e.key&&r.set(e.key,{in:e.in,map:e.map}):e.args&&I(e.args,r);return r},U=n=>{for(let[r,e]of Object.entries(n))e&&typeof e=="object"&&!Object.keys(e).length&&delete n[r];},D=(n,r)=>{let e={body:{},headers:{},path:{},query:{}},a=I(r),i;for(let[o,s]of n.entries())if(r[o]&&(i=r[o]),!!i)if("in"in i)if(i.key){let t=a.get(i.key),l=t.map||i.key;e[t.in][l]=s;}else e.body=s;else for(let[t,l]of Object.entries(s??{})){let f=a.get(t);if(f){let c=f.map||t;e[f.in][c]=l;}else {let c=_.find(([p])=>t.startsWith(p));if(c){let[p,d]=c;e[d][t.slice(p.length)]=l;}else for(let[p,d]of Object.entries(i.allowExtra??{}))if(d){e[p][t]=l;break}}}return U(e),e},H=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},W=n=>{switch(n){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},B=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},O=({allowReserved:n,explode:r,name:e,style:a,value:i})=>{if(!r){let t=(n?i:i.map(l=>encodeURIComponent(l))).join(W(a));switch(a){case "label":return `.${t}`;case "matrix":return `;${e}=${t}`;case "simple":return t;default:return `${e}=${t}`}}let o=H(a),s=i.map(t=>a==="label"||a==="simple"?n?t:encodeURIComponent(t):h({allowReserved:n,name:e,value:t})).join(o);return a==="label"||a==="matrix"?o+s:s},h=({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)}`},C=({allowReserved:n,explode:r,name:e,style:a,value:i})=>{if(i instanceof Date)return `${e}=${i.toISOString()}`;if(a!=="deepObject"&&!r){let t=[];Object.entries(i).forEach(([f,c])=>{t=[...t,f,n?c:encodeURIComponent(c)];});let l=t.join(",");switch(a){case "form":return `${e}=${l}`;case "label":return `.${l}`;case "matrix":return `;${e}=${l}`;default:return l}}let o=B(a),s=Object.entries(i).map(([t,l])=>h({allowReserved:n,name:a==="deepObject"?`${e}[${t}]`:t,value:l})).join(o);return a==="label"||a==="matrix"?o+s:s};var N=/\{[^{}]+\}/g,Q=({path:n,url:r})=>{let e=r,a=r.match(N);if(a)for(let i of a){let o=false,s=i.substring(1,i.length-1),t="simple";s.endsWith("*")&&(o=true,s=s.substring(0,s.length-1)),s.startsWith(".")?(s=s.substring(1),t="label"):s.startsWith(";")&&(s=s.substring(1),t="matrix");let l=n[s];if(l==null)continue;if(Array.isArray(l)){e=e.replace(i,O({explode:o,name:s,style:t,value:l}));continue}if(typeof l=="object"){e=e.replace(i,C({explode:o,name:s,style:t,value:l}));continue}if(t==="matrix"){e=e.replace(i,`;${h({name:s,value:l})}`);continue}let f=encodeURIComponent(t==="label"?`.${l}`:l);e=e.replace(i,f);}return e},q=({allowReserved:n,array:r,object:e}={})=>i=>{let o=[];if(i&&typeof i=="object")for(let s in i){let t=i[s];if(t!=null)if(Array.isArray(t)){let l=O({allowReserved:n,explode:true,name:s,style:"form",value:t,...r});l&&o.push(l);}else if(typeof t=="object"){let l=C({allowReserved:n,explode:true,name:s,style:"deepObject",value:t,...e});l&&o.push(l);}else {let l=h({allowReserved:n,name:s,value:t});l&&o.push(l);}}return o.join("&")},P=n=>{if(!n)return "stream";let r=n.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},k=async({security:n,...r})=>{for(let e of n){let a=await A(e,r.auth);if(!a)continue;let i=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[i]=a;break;case "cookie":r.headers.append("Cookie",`${i}=${a}`);break;case "header":default:r.headers.set(i,a);break}return}},S=n=>J({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:q(n.querySerializer),url:n.url}),J=({baseUrl:n,path:r,query:e,querySerializer:a,url:i})=>{let o=i.startsWith("/")?i:`/${i}`,s=(n??"")+o;r&&(s=Q({path:r,url:s}));let t=e?a(e):"";return t.startsWith("?")&&(t=t.substring(1)),t&&(s+=`?${t}`),s},x=(n,r)=>{let e={...n,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=R(n.headers,r.headers),e},R=(...n)=>{let r=new Headers;for(let e of n){if(!e||typeof e!="object")continue;let a=e instanceof Headers?e.entries():Object.entries(e);for(let[i,o]of a)if(o===null)r.delete(i);else if(Array.isArray(o))for(let s of o)r.append(i,s);else o!==void 0&&r.set(i,typeof o=="object"?JSON.stringify(o):o);}return r},m=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let a=this.getInterceptorIndex(r);return this._fns[a]?(this._fns[a]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},E=()=>({error:new m,request:new m,response:new m}),M=q({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),L={"Content-Type":"application/json"},j=(n={})=>({...b,headers:L,parseAs:"auto",querySerializer:M,...n});var V=(n={})=>{let r=x(j(),n),e=()=>({...r}),a=s=>(r=x(r,s),e()),i=E(),o=async s=>{let t={...r,...s,fetch:s.fetch??r.fetch??globalThis.fetch,headers:R(r.headers,s.headers)};t.security&&await k({...t,security:t.security}),t.body&&t.bodySerializer&&(t.body=t.bodySerializer(t.body)),(t.body===void 0||t.body==="")&&t.headers.delete("Content-Type");for(let u of i.request._fns)u&&await u(t);let l=S(t),f=t.fetch,c=await f(l,{...t,body:t.body});for(let u of i.response._fns)u&&(c=await u(c,t));let p={response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return {data:{},...p};let u=(t.parseAs==="auto"?P(c.headers.get("Content-Type")):t.parseAs)??"json";if(u==="stream")return {data:c.body,...p};let g=await c[u]();return u==="json"&&(t.responseValidator&&await t.responseValidator(g),t.responseTransformer&&(g=await t.responseTransformer(g))),{data:g,...p}}let d=await c.text();try{d=JSON.parse(d);}catch{}let y=d;for(let u of i.error._fns)u&&(y=await u(d,c,t));if(y=y||{},t.throwOnError)throw y;return {error:y,...p}};return {buildUrl:S,connect:s=>o({...s,method:"CONNECT"}),delete:s=>o({...s,method:"DELETE"}),get:s=>o({...s,method:"GET"}),getConfig:e,head:s=>o({...s,method:"HEAD"}),interceptors:i,options:s=>o({...s,method:"OPTIONS"}),patch:s=>o({...s,method:"PATCH"}),post:s=>o({...s,method:"POST"}),put:s=>o({...s,method:"PUT"}),request:o,setConfig:a,trace:s=>o({...s,method:"TRACE"})}};exports.buildClientParams=D;exports.createClient=V;exports.createConfig=j;exports.formDataBodySerializer=$;exports.jsonBodySerializer=b;exports.urlSearchParamsBodySerializer=v;//# sourceMappingURL=index.cjs.map 2 2 //# sourceMappingURL=index.cjs.map
+24 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/bundle/client/index.d.cts
··· 42 42 bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string; 43 43 }; 44 44 45 + type Slot = 'body' | 'headers' | 'path' | 'query'; 46 + type Field = { 47 + in: Exclude<Slot, 'body'>; 48 + key: string; 49 + map?: string; 50 + } | { 51 + in: Extract<Slot, 'body'>; 52 + key?: string; 53 + map?: string; 54 + }; 55 + interface Fields { 56 + allowExtra?: Partial<Record<Slot, boolean>>; 57 + args?: ReadonlyArray<Field>; 58 + } 59 + type FieldsConfig = ReadonlyArray<Field | Fields>; 60 + interface Params { 61 + body: unknown; 62 + headers: Record<string, unknown>; 63 + path: Record<string, unknown>; 64 + query: Record<string, unknown>; 65 + } 66 + declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 67 + 45 68 interface Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> { 46 69 /** 47 70 * Returns the final request URL. ··· 228 251 229 252 declare const createClient: (config?: Config) => Client; 230 253 231 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; 254 + export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
+24 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/@hey-api/client-next/bundle/client/index.d.ts
··· 42 42 bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string; 43 43 }; 44 44 45 + type Slot = 'body' | 'headers' | 'path' | 'query'; 46 + type Field = { 47 + in: Exclude<Slot, 'body'>; 48 + key: string; 49 + map?: string; 50 + } | { 51 + in: Extract<Slot, 'body'>; 52 + key?: string; 53 + map?: string; 54 + }; 55 + interface Fields { 56 + allowExtra?: Partial<Record<Slot, boolean>>; 57 + args?: ReadonlyArray<Field>; 58 + } 59 + type FieldsConfig = ReadonlyArray<Field | Fields>; 60 + interface Params { 61 + body: unknown; 62 + headers: Record<string, unknown>; 63 + path: Record<string, unknown>; 64 + query: Record<string, unknown>; 65 + } 66 + declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 67 + 45 68 interface Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> { 46 69 /** 47 70 * Returns the final request URL. ··· 228 251 229 252 declare const createClient: (config?: Config) => Client; 230 253 231 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; 254 + export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
+1 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.cjs
··· 1 - 'use strict';var j=async(t,r)=>{let e=typeof r=="function"?await r(t):r;if(e)return t.scheme==="bearer"?`Bearer ${e}`:t.scheme==="basic"?`Basic ${btoa(e)}`:e},z=(t,r,e)=>{typeof e=="string"||e instanceof Blob?t.append(r,e):t.append(r,JSON.stringify(e));},I=(t,r,e)=>{typeof e=="string"?t.append(r,e):t.append(r,JSON.stringify(e));},k={bodySerializer:t=>{let r=new FormData;return Object.entries(t).forEach(([e,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>z(r,e,a)):z(r,e,i));}),r}},R={bodySerializer:t=>JSON.stringify(t,(r,e)=>typeof e=="bigint"?e.toString():e)},$={bodySerializer:t=>{let r=new URLSearchParams;return Object.entries(t).forEach(([e,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>I(r,e,a)):I(r,e,i));}),r.toString()}},U=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},_=t=>{switch(t){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},D=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},O=({allowReserved:t,explode:r,name:e,style:i,value:a})=>{if(!r){let n=(t?a:a.map(l=>encodeURIComponent(l))).join(_(i));switch(i){case "label":return `.${n}`;case "matrix":return `;${e}=${n}`;case "simple":return n;default:return `${e}=${n}`}}let o=U(i),s=a.map(n=>i==="label"||i==="simple"?t?n:encodeURIComponent(n):y({allowReserved:t,name:e,value:n})).join(o);return i==="label"||i==="matrix"?o+s:s},y=({allowReserved:t,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}=${t?e:encodeURIComponent(e)}`},q=({allowReserved:t,explode:r,name:e,style:i,value:a})=>{if(a instanceof Date)return `${e}=${a.toISOString()}`;if(i!=="deepObject"&&!r){let n=[];Object.entries(a).forEach(([f,p])=>{n=[...n,f,t?p:encodeURIComponent(p)];});let l=n.join(",");switch(i){case "form":return `${e}=${l}`;case "label":return `.${l}`;case "matrix":return `;${e}=${l}`;default:return l}}let o=D(i),s=Object.entries(a).map(([n,l])=>y({allowReserved:t,name:i==="deepObject"?`${e}[${n}]`:n,value:l})).join(o);return i==="label"||i==="matrix"?o+s:s};var H=/\{[^{}]+\}/g,B=({path:t,url:r})=>{let e=r,i=r.match(H);if(i)for(let a of i){let o=false,s=a.substring(1,a.length-1),n="simple";s.endsWith("*")&&(o=true,s=s.substring(0,s.length-1)),s.startsWith(".")?(s=s.substring(1),n="label"):s.startsWith(";")&&(s=s.substring(1),n="matrix");let l=t[s];if(l==null)continue;if(Array.isArray(l)){e=e.replace(a,O({explode:o,name:s,style:n,value:l}));continue}if(typeof l=="object"){e=e.replace(a,q({explode:o,name:s,style:n,value:l}));continue}if(n==="matrix"){e=e.replace(a,`;${y({name:s,value:l})}`);continue}let f=encodeURIComponent(n==="label"?`.${l}`:l);e=e.replace(a,f);}return e},A=({allowReserved:t,array:r,object:e}={})=>a=>{let o=[];if(a&&typeof a=="object")for(let s in a){let n=a[s];if(n!=null)if(Array.isArray(n)){let l=O({allowReserved:t,explode:true,name:s,style:"form",value:n,...r});l&&o.push(l);}else if(typeof n=="object"){let l=q({allowReserved:t,explode:true,name:s,style:"deepObject",value:n,...e});l&&o.push(l);}else {let l=y({allowReserved:t,name:s,value:n});l&&o.push(l);}}return o.join("&")},P=t=>{if(!t)return "stream";let r=t.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},E=async({security:t,...r})=>{for(let e of t){let i=await j(e,r.auth);if(!i)continue;let a=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[a]=i;break;case "cookie":r.headers.append("Cookie",`${a}=${i}`);break;case "header":default:r.headers.set(a,i);break}return}},S=t=>W({baseUrl:t.baseUrl,path:t.path,query:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:A(t.querySerializer),url:t.url}),W=({baseUrl:t,path:r,query:e,querySerializer:i,url:a})=>{let o=a.startsWith("/")?a:`/${a}`,s=(t??"")+o;r&&(s=B({path:r,url:s}));let n=e?i(e):"";return n.startsWith("?")&&(n=n.substring(1)),n&&(s+=`?${n}`),s},x=(t,r)=>{let e={...t,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=C(t.headers,r.headers),e},C=(...t)=>{let r=new Headers;for(let e of t){if(!e||typeof e!="object")continue;let i=e instanceof Headers?e.entries():Object.entries(e);for(let[a,o]of i)if(o===null)r.delete(a);else if(Array.isArray(o))for(let s of o)r.append(a,s);else o!==void 0&&r.set(a,typeof o=="object"?JSON.stringify(o):o);}return r},h=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let i=this.getInterceptorIndex(r);return this._fns[i]?(this._fns[i]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},v=()=>({error:new h,request:new h,response:new h}),N=A({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),Q={"Content-Type":"application/json"},w=(t={})=>({...R,headers:Q,parseAs:"auto",querySerializer:N,...t});var J=(t={})=>{let r=x(w(),t),e=()=>({...r}),i=s=>(r=x(r,s),e()),a=v(),o=async s=>{let n={...r,...s,fetch:s.fetch??r.fetch??globalThis.fetch,headers:C(r.headers,s.headers)};n.security&&await E({...n,security:n.security}),n.body&&n.bodySerializer&&(n.body=n.bodySerializer(n.body)),(n.body===void 0||n.body==="")&&n.headers.delete("Content-Type");let l=S(n),f={redirect:"follow",...n},p=new Request(l,f);for(let c of a.request._fns)c&&(p=await c(p,n));let T=n.fetch,u=await T(p);for(let c of a.response._fns)c&&(u=await c(u,p,n));let m={request:p,response:u};if(u.ok){if(u.status===204||u.headers.get("Content-Length")==="0")return {data:{},...m};let c=(n.parseAs==="auto"?P(u.headers.get("Content-Type")):n.parseAs)??"json";if(c==="stream")return {data:u.body,...m};let b=await u[c]();return c==="json"&&(n.responseValidator&&await n.responseValidator(b),n.responseTransformer&&(b=await n.responseTransformer(b))),{data:b,...m}}let g=await u.text();try{g=JSON.parse(g);}catch{}let d=g;for(let c of a.error._fns)c&&(d=await c(g,u,p,n));if(d=d||{},n.throwOnError)throw d;return {error:d,...m}};return {buildUrl:S,connect:s=>o({...s,method:"CONNECT"}),delete:s=>o({...s,method:"DELETE"}),get:s=>o({...s,method:"GET"}),getConfig:e,head:s=>o({...s,method:"HEAD"}),interceptors:a,options:s=>o({...s,method:"OPTIONS"}),patch:s=>o({...s,method:"PATCH"}),post:s=>o({...s,method:"POST"}),put:s=>o({...s,method:"PUT"}),request:o,setConfig:i,trace:s=>o({...s,method:"TRACE"})}};exports.createClient=J;exports.createConfig=w;exports.formDataBodySerializer=k;exports.jsonBodySerializer=R;exports.urlSearchParamsBodySerializer=$;//# sourceMappingURL=index.cjs.map 1 + 'use strict';var I=async(n,r)=>{let e=typeof r=="function"?await r(n):r;if(e)return n.scheme==="bearer"?`Bearer ${e}`:n.scheme==="basic"?`Basic ${btoa(e)}`:e},z=(n,r,e)=>{typeof e=="string"||e instanceof Blob?n.append(r,e):n.append(r,JSON.stringify(e));},A=(n,r,e)=>{typeof e=="string"?n.append(r,e):n.append(r,JSON.stringify(e));},T={bodySerializer:n=>{let r=new FormData;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(i=>z(r,e,i)):z(r,e,a));}),r}},O={bodySerializer:n=>JSON.stringify(n,(r,e)=>typeof e=="bigint"?e.toString():e)},_={bodySerializer:n=>{let r=new URLSearchParams;return Object.entries(n).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(i=>A(r,e,i)):A(r,e,a));}),r.toString()}},U={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},D=Object.entries(U),P=(n,r)=>{r||(r=new Map);for(let e of n)"in"in e?e.key&&r.set(e.key,{in:e.in,map:e.map}):e.args&&P(e.args,r);return r},H=n=>{for(let[r,e]of Object.entries(n))e&&typeof e=="object"&&!Object.keys(e).length&&delete n[r];},W=(n,r)=>{let e={body:{},headers:{},path:{},query:{}},a=P(r),i;for(let[o,s]of n.entries())if(r[o]&&(i=r[o]),!!i)if("in"in i)if(i.key){let t=a.get(i.key),l=t.map||i.key;e[t.in][l]=s;}else e.body=s;else for(let[t,l]of Object.entries(s??{})){let f=a.get(t);if(f){let u=f.map||t;e[f.in][u]=l;}else {let u=D.find(([d])=>t.startsWith(d));if(u){let[d,c]=u;e[c][t.slice(d.length)]=l;}else for(let[d,c]of Object.entries(i.allowExtra??{}))if(c){e[d][t]=l;break}}}return H(e),e},B=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},N=n=>{switch(n){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},Q=n=>{switch(n){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},q=({allowReserved:n,explode:r,name:e,style:a,value:i})=>{if(!r){let t=(n?i:i.map(l=>encodeURIComponent(l))).join(N(a));switch(a){case "label":return `.${t}`;case "matrix":return `;${e}=${t}`;case "simple":return t;default:return `${e}=${t}`}}let o=B(a),s=i.map(t=>a==="label"||a==="simple"?n?t:encodeURIComponent(t):h({allowReserved:n,name:e,value:t})).join(o);return a==="label"||a==="matrix"?o+s:s},h=({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)}`},C=({allowReserved:n,explode:r,name:e,style:a,value:i})=>{if(i instanceof Date)return `${e}=${i.toISOString()}`;if(a!=="deepObject"&&!r){let t=[];Object.entries(i).forEach(([f,u])=>{t=[...t,f,n?u:encodeURIComponent(u)];});let l=t.join(",");switch(a){case "form":return `${e}=${l}`;case "label":return `.${l}`;case "matrix":return `;${e}=${l}`;default:return l}}let o=Q(a),s=Object.entries(i).map(([t,l])=>h({allowReserved:n,name:a==="deepObject"?`${e}[${t}]`:t,value:l})).join(o);return a==="label"||a==="matrix"?o+s:s};var J=/\{[^{}]+\}/g,M=({path:n,url:r})=>{let e=r,a=r.match(J);if(a)for(let i of a){let o=false,s=i.substring(1,i.length-1),t="simple";s.endsWith("*")&&(o=true,s=s.substring(0,s.length-1)),s.startsWith(".")?(s=s.substring(1),t="label"):s.startsWith(";")&&(s=s.substring(1),t="matrix");let l=n[s];if(l==null)continue;if(Array.isArray(l)){e=e.replace(i,q({explode:o,name:s,style:t,value:l}));continue}if(typeof l=="object"){e=e.replace(i,C({explode:o,name:s,style:t,value:l}));continue}if(t==="matrix"){e=e.replace(i,`;${h({name:s,value:l})}`);continue}let f=encodeURIComponent(t==="label"?`.${l}`:l);e=e.replace(i,f);}return e},k=({allowReserved:n,array:r,object:e}={})=>i=>{let o=[];if(i&&typeof i=="object")for(let s in i){let t=i[s];if(t!=null)if(Array.isArray(t)){let l=q({allowReserved:n,explode:true,name:s,style:"form",value:t,...r});l&&o.push(l);}else if(typeof t=="object"){let l=C({allowReserved:n,explode:true,name:s,style:"deepObject",value:t,...e});l&&o.push(l);}else {let l=h({allowReserved:n,name:s,value:t});l&&o.push(l);}}return o.join("&")},E=n=>{if(!n)return "stream";let r=n.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},$=async({security:n,...r})=>{for(let e of n){let a=await I(e,r.auth);if(!a)continue;let i=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[i]=a;break;case "cookie":r.headers.append("Cookie",`${i}=${a}`);break;case "header":default:r.headers.set(i,a);break}return}},S=n=>L({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:k(n.querySerializer),url:n.url}),L=({baseUrl:n,path:r,query:e,querySerializer:a,url:i})=>{let o=i.startsWith("/")?i:`/${i}`,s=(n??"")+o;r&&(s=M({path:r,url:s}));let t=e?a(e):"";return t.startsWith("?")&&(t=t.substring(1)),t&&(s+=`?${t}`),s},x=(n,r)=>{let e={...n,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=j(n.headers,r.headers),e},j=(...n)=>{let r=new Headers;for(let e of n){if(!e||typeof e!="object")continue;let a=e instanceof Headers?e.entries():Object.entries(e);for(let[i,o]of a)if(o===null)r.delete(i);else if(Array.isArray(o))for(let s of o)r.append(i,s);else o!==void 0&&r.set(i,typeof o=="object"?JSON.stringify(o):o);}return r},m=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let a=this.getInterceptorIndex(r);return this._fns[a]?(this._fns[a]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},v=()=>({error:new m,request:new m,response:new m}),V=k({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),F={"Content-Type":"application/json"},w=(n={})=>({...O,headers:F,parseAs:"auto",querySerializer:V,...n});var G=(n={})=>{let r=x(w(),n),e=()=>({...r}),a=s=>(r=x(r,s),e()),i=v(),o=async s=>{let t={...r,...s,fetch:s.fetch??r.fetch??globalThis.fetch,headers:j(r.headers,s.headers)};t.security&&await $({...t,security:t.security}),t.body&&t.bodySerializer&&(t.body=t.bodySerializer(t.body)),(t.body===void 0||t.body==="")&&t.headers.delete("Content-Type");let l=S(t),f={redirect:"follow",...t},u=new Request(l,f);for(let p of i.request._fns)p&&(u=await p(u,t));let d=t.fetch,c=await d(u);for(let p of i.response._fns)p&&(c=await p(c,u,t));let g={request:u,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return {data:{},...g};let p=(t.parseAs==="auto"?E(c.headers.get("Content-Type")):t.parseAs)??"json";if(p==="stream")return {data:c.body,...g};let R=await c[p]();return p==="json"&&(t.responseValidator&&await t.responseValidator(R),t.responseTransformer&&(R=await t.responseTransformer(R))),{data:R,...g}}let b=await c.text();try{b=JSON.parse(b);}catch{}let y=b;for(let p of i.error._fns)p&&(y=await p(b,c,u,t));if(y=y||{},t.throwOnError)throw y;return {error:y,...g}};return {buildUrl:S,connect:s=>o({...s,method:"CONNECT"}),delete:s=>o({...s,method:"DELETE"}),get:s=>o({...s,method:"GET"}),getConfig:e,head:s=>o({...s,method:"HEAD"}),interceptors:i,options:s=>o({...s,method:"OPTIONS"}),patch:s=>o({...s,method:"PATCH"}),post:s=>o({...s,method:"POST"}),put:s=>o({...s,method:"PUT"}),request:o,setConfig:a,trace:s=>o({...s,method:"TRACE"})}};exports.buildClientParams=W;exports.createClient=G;exports.createConfig=w;exports.formDataBodySerializer=T;exports.jsonBodySerializer=O;exports.urlSearchParamsBodySerializer=_;//# sourceMappingURL=index.cjs.map 2 2 //# sourceMappingURL=index.cjs.map
+24 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts
··· 42 42 bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string; 43 43 }; 44 44 45 + type Slot = 'body' | 'headers' | 'path' | 'query'; 46 + type Field = { 47 + in: Exclude<Slot, 'body'>; 48 + key: string; 49 + map?: string; 50 + } | { 51 + in: Extract<Slot, 'body'>; 52 + key?: string; 53 + map?: string; 54 + }; 55 + interface Fields { 56 + allowExtra?: Partial<Record<Slot, boolean>>; 57 + args?: ReadonlyArray<Field>; 58 + } 59 + type FieldsConfig = ReadonlyArray<Field | Fields>; 60 + interface Params { 61 + body: unknown; 62 + headers: Record<string, unknown>; 63 + path: Record<string, unknown>; 64 + query: Record<string, unknown>; 65 + } 66 + declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 67 + 45 68 interface Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> { 46 69 /** 47 70 * Returns the final request URL. ··· 230 253 231 254 declare const createClient: (config?: Config) => Client; 232 255 233 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; 256 + export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
+24 -1
packages/openapi-ts-tests/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.ts
··· 42 42 bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string; 43 43 }; 44 44 45 + type Slot = 'body' | 'headers' | 'path' | 'query'; 46 + type Field = { 47 + in: Exclude<Slot, 'body'>; 48 + key: string; 49 + map?: string; 50 + } | { 51 + in: Extract<Slot, 'body'>; 52 + key?: string; 53 + map?: string; 54 + }; 55 + interface Fields { 56 + allowExtra?: Partial<Record<Slot, boolean>>; 57 + args?: ReadonlyArray<Field>; 58 + } 59 + type FieldsConfig = ReadonlyArray<Field | Fields>; 60 + interface Params { 61 + body: unknown; 62 + headers: Record<string, unknown>; 63 + path: Record<string, unknown>; 64 + query: Record<string, unknown>; 65 + } 66 + declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 67 + 45 68 interface Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> { 46 69 /** 47 70 * Returns the final request URL. ··· 230 253 231 254 declare const createClient: (config?: Config) => Client; 232 255 233 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; 256 + export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type OptionsLegacyParser, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };