Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bundle clients from compiled index file #1600

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

mrlubos
Copy link
Member

@mrlubos mrlubos commented Jan 21, 2025

No description provided.

Copy link

stackblitz bot commented Jan 21, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Jan 21, 2025

🦋 Changeset detected

Latest commit: 0432418

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@hey-api/client-axios Patch
@hey-api/client-fetch Patch
@hey-api/client-nuxt Patch
@hey-api/openapi-ts Patch
@example/openapi-ts-axios Patch
@example/openapi-ts-fastify Patch
@example/openapi-ts-fetch Patch
@example/openapi-ts-sample Patch
@example/openapi-ts-tanstack-angular-query-experimental Patch
@example/openapi-ts-tanstack-react-query Patch
@example/openapi-ts-tanstack-svelte-query Patch
@example/openapi-ts-tanstack-vue-query Patch
@example/openapi-ts-nuxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 7:12am

@mrlubos mrlubos marked this pull request as ready for review January 21, 2025 06:33
@@ -0,0 +1,2 @@
'use strict';var app=require('nuxt/app'),vue=require('vue');var $=async(r,t)=>{let e=typeof t=="function"?await t(r):t;if(e)return r.scheme==="bearer"?`Bearer ${e}`:r.scheme==="basic"?`Basic ${btoa(e)}`:e},P=(r,t,e)=>{typeof e=="string"||e instanceof Blob?r.append(t,e):r.append(t,JSON.stringify(e));},U=(r,t,e)=>{typeof e=="string"?r.append(t,e):r.append(t,JSON.stringify(e));},L={bodySerializer:r=>{let t=new FormData;return Object.entries(r).forEach(([e,s])=>{s!=null&&(Array.isArray(s)?s.forEach(o=>P(t,e,o)):P(t,e,s));}),t}},R={bodySerializer:r=>JSON.stringify(r)},H={bodySerializer:r=>{let t=new URLSearchParams;return Object.entries(r).forEach(([e,s])=>{s!=null&&(Array.isArray(s)?s.forEach(o=>U(t,e,o)):U(t,e,s));}),t}},D=r=>{switch(r){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},N=r=>{switch(r){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},I=r=>{switch(r){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},S=({allowReserved:r,explode:t,name:e,style:s,value:o})=>{if(!t){let n=(r?o:o.map(u=>encodeURIComponent(u))).join(N(s));switch(s){case "label":return `.${n}`;case "matrix":return `;${e}=${n}`;case "simple":return n;default:return `${e}=${n}`}}let a=D(s),i=o.map(n=>s==="label"||s==="simple"?r?n:encodeURIComponent(n):y({allowReserved:r,name:e,value:n})).join(a);return s==="label"||s==="matrix"?a+i:i},y=({allowReserved:r,name:t,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 `${t}=${r?e:encodeURIComponent(e)}`},A=({allowReserved:r,explode:t,name:e,style:s,value:o})=>{if(o instanceof Date)return `${e}=${o.toISOString()}`;if(s!=="deepObject"&&!t){let n=[];Object.entries(o).forEach(([l,p])=>{n=[...n,l,r?p:encodeURIComponent(p)];});let u=n.join(",");switch(s){case "form":return `${e}=${u}`;case "label":return `.${u}`;case "matrix":return `;${e}=${u}`;default:return u}}let a=I(s),i=Object.entries(o).map(([n,u])=>y({allowReserved:r,name:s==="deepObject"?`${e}[${n}]`:n,value:u})).join(a);return s==="label"||s==="matrix"?a+i:i};var Q=/\{[^{}]+\}/g,V=({path:r,url:t})=>{let e=t,s=t.match(Q);if(s)for(let o of s){let a=false,i=o.substring(1,o.length-1),n="simple";i.endsWith("*")&&(a=true,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),n="label"):i.startsWith(";")&&(i=i.substring(1),n="matrix");let u=vue.toValue(vue.toValue(r)[i]);if(u==null)continue;if(Array.isArray(u)){e=e.replace(o,S({explode:a,name:i,style:n,value:u}));continue}if(typeof u=="object"){e=e.replace(o,A({explode:a,name:i,style:n,value:u}));continue}if(n==="matrix"){e=e.replace(o,`;${y({name:i,value:u})}`);continue}let l=encodeURIComponent(n==="label"?`.${u}`:u);e=e.replace(o,l);}return e},E=({allowReserved:r,array:t,object:e}={})=>o=>{let a=[],i=vue.toValue(o);if(i&&typeof i=="object")for(let n in i){let u=vue.toValue(i[n]);if(u!=null){if(Array.isArray(u)){a=[...a,S({allowReserved:r,explode:true,name:n,style:"form",value:u,...t})];continue}if(typeof u=="object"){a=[...a,A({allowReserved:r,explode:true,name:n,style:"deepObject",value:u,...e})];continue}a=[...a,y({allowReserved:r,name:n,value:u})];}}return a.join("&")},k=async({security:r,...t})=>{for(let e of r){let s=await $(e,t.auth);if(!s)continue;let o=e.name??"Authorization";switch(e.in){case "query":t.query||(t.query={}),vue.toValue(t.query)[o]=s;break;case "header":default:t.headers.set(o,s);break}return}},d=r=>F({baseUrl:r.baseURL??"",path:r.path,query:r.query,querySerializer:typeof r.querySerializer=="function"?r.querySerializer:E(r.querySerializer),url:r.url}),F=({baseUrl:r,path:t,query:e,querySerializer:s,url:o})=>{let a=o.startsWith("/")?o:`/${o}`,i=r+a;t&&(i=V({path:t,url:i}));let n=e?s(e):"";return n.startsWith("?")&&(n=n.substring(1)),n&&(i+=`?${n}`),i},C=(r,t)=>{let e={...r,...t};return e.baseURL?.endsWith("/")&&(e.baseURL=e.baseURL.substring(0,e.baseURL.length-1)),e.headers=T(r.headers,t.headers),e},T=(...r)=>{let t=new Headers;for(let e of r){if(!e||typeof e!="object")continue;let s=e;vue.isRef(s)&&(s=vue.unref(s));let o=s instanceof Headers?s.entries():Object.entries(s);for(let[a,i]of o)if(i===null)t.delete(a);else if(Array.isArray(i))for(let n of i)t.append(a,f(n));else if(i!==undefined){let n=f(i);t.set(a,typeof n=="object"?JSON.stringify(n):n);}}return t},w=(...r)=>r.reduce((t,e)=>{if(typeof e=="function")t.push(e);else if(Array.isArray(e))return t.concat(e);return t},[]),W=E({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),J={"Content-Type":"application/json"},q=(r={})=>({...R,baseURL:"",headers:J,querySerializer:W,...r}),f=r=>{if(r===null||typeof r!="object"||r instanceof Headers)return vue.isRef(r)?vue.unref(r):r;if(Array.isArray(r))return r.map(e=>f(e));if(vue.isRef(r))return f(vue.unref(r));let t={};for(let e in r)t[e]=f(r[e]);return t};var re=(r={})=>{let t=C(q(),r),e=()=>({...t}),s=a=>(t=C(t,a),e()),o=({asyncDataOptions:a,composable:i,key:n,...u})=>{let l={...t,...u,$fetch:u.$fetch??t.$fetch??$fetch,headers:T(t.headers,u.headers),onRequest:w(t.onRequest,u.onRequest),onResponse:w(t.onResponse,u.onResponse)},{responseTransformer:p,responseValidator:g,security:j}=l;j&&(l.onRequest=[async({options:c})=>{await k({auth:l.auth,headers:c.headers,query:c.query,security:j});},...l.onRequest]),(p||g)&&(l.onResponse=[...l.onResponse,async({options:c,response:b})=>{c.responseType&&c.responseType!=="json"||(g&&await g(b._data),p&&(b._data=await p(b._data)));}]),l.body&&l.bodySerializer&&(l.body=l.bodySerializer(f(l.body))),l.body||l.headers.delete("Content-Type");let O=l.$fetch;if(i==="$fetch"){let c=d(l);return O(c,f(l))}if(i==="useFetch"){let c=d(l);return app.useFetch(c,l)}if(i==="useLazyFetch"){let c=d(l);return app.useLazyFetch(c,l)}let h=()=>{let c=d(l);return O(c,f(l))};if(i==="useAsyncData")return n?app.useAsyncData(n,h,a):app.useAsyncData(h,a);if(i==="useLazyAsyncData")return n?app.useLazyAsyncData(n,h,a):app.useLazyAsyncData(h,a)};return {buildUrl:d,connect:a=>o({...a,method:"CONNECT"}),delete:a=>o({...a,method:"DELETE"}),get:a=>o({...a,method:"GET"}),getConfig:e,head:a=>o({...a,method:"HEAD"}),options:a=>o({...a,method:"OPTIONS"}),patch:a=>o({...a,method:"PATCH"}),post:a=>o({...a,method:"POST"}),put:a=>o({...a,method:"PUT"}),request:o,setConfig:s,trace:a=>o({...a,method:"TRACE"})}};exports.createClient=re;exports.createConfig=q;exports.formDataBodySerializer=L;exports.jsonBodySerializer=R;exports.urlSearchParamsBodySerializer=H;//# sourceMappingURL=index.cjs.map

Check notice

Code scanning / CodeQL

Semicolon insertion Note test

Avoid automated semicolon insertion (90% of all statements in
the enclosing function
have an explicit semicolon).
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 56.32%. Comparing base (7eebbef) to head (0432418).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
packages/openapi-ts/src/generate/client.ts 0.00% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1600   +/-   ##
=======================================
  Coverage   56.32%   56.32%           
=======================================
  Files         158      158           
  Lines       24817    24814    -3     
  Branches     1815     1815           
=======================================
  Hits        13977    13977           
+ Misses      10830    10827    -3     
  Partials       10       10           
Flag Coverage Δ
unittests 56.32% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

pkg-pr-new bot commented Jan 21, 2025

Open in Stackblitz

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/client-axios@1600
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/client-nuxt@1600
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/client-fetch@1600
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@1600

commit: 0432418

@mrlubos mrlubos merged commit 1b73773 into main Jan 21, 2025
16 of 17 checks passed
@mrlubos mrlubos deleted the refactor/client-bundle-index branch January 21, 2025 07:19
@github-actions github-actions bot mentioned this pull request Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant