@elysiajs/eden
Advanced tools
Comparing version 0.7.6 to 0.7.7
@@ -1,1 +0,1 @@ | ||
"use strict";var Eden=(()=>{var O=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var V=(r,e)=>{for(var t in e)O(r,t,{get:e[t],enumerable:!0})},z=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of J(e))!U.call(r,a)&&a!==t&&O(r,a,{get:()=>e[a],enumerable:!(n=D(e,a))||n.enumerable});return r};var B=r=>z(O({},"__esModule",{value:!0}),r);var H={};V(H,{edenFetch:()=>P,edenTreaty:()=>I});var S=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var C=(r,e,t)=>{if(r.endsWith("/")||(r+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${r}${e}`;let n="";for(let[a,s]of Object.entries(t))n+=`${a}=${s}&`;return`${r}${e}?${n.slice(0,-1)}`};var N=typeof FileList>"u",K=r=>N?r instanceof Blob:r instanceof FileList||r instanceof File,G=r=>{if(!r)return!1;for(let e in r){if(K(r[e]))return!0;if(Array.isArray(r[e])&&r[e].find(t=>K(t)))return!0}return!1},j=r=>N?r:new Promise(e=>{let t=new FileReader;t.onload=()=>{let n=new File([t.result],r.name,{lastModified:r.lastModified,type:r.type});e(n)},t.readAsArrayBuffer(r)}),L=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,n){return this.addEventListener(e,t,n)}off(e,t,n){return this.ws.removeEventListener(e,t,n),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,n){return this.ws.addEventListener(e,a=>{if(e==="message"){let s=a.data.toString(),o=s.charCodeAt(0);if(o===47||o===123)try{s=JSON.parse(s)}catch{}else Number.isNaN(+s)?s==="true"?s=!0:s==="fase"&&(s=!1):s=+s;t({...a,data:s})}else t(a)},n),this}removeEventListener(e,t,n){return this.off(e,t,n),this}close(){return this.ws.close(),this}},M=(r,e="",t)=>new Proxy(()=>{},{get(n,a,s){return M(r,`${e}/${a.toString()}`,t)},apply(n,a,[s,o={}]=[{},{}]){let y=s!==void 0&&(typeof s!="object"||Array.isArray(s))?s:void 0,{$query:A,$fetch:x,$headers:w,$transform:i,...l}=s??{};y??=l;let d=e.lastIndexOf("/"),k=e.slice(d+1).toUpperCase(),F=C(r,d===-1?"/":e.slice(0,d),Object.assign(o.query??{},A)),q=t.fetcher??fetch,E=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,$=i?Array.isArray(i)?i:[i]:void 0;return $&&(E?E=$.concat(E):E=$),k==="SUBSCRIBE"?new L(F.replace(/^([^]+):\/\//,F.startsWith("https://")?"wss://":"ws://")):(async()=>{let p,W={...t.$fetch?.headers,...x?.headers,...o.headers,...w};if(k!=="GET"&&k!=="HEAD"){p=Object.keys(y).length||Array.isArray(y)?y:void 0;let f=typeof p=="object"||Array.isArray(y);if(f&&G(p)){let b=new FormData;for(let[v,u]of Object.entries(p))if(N)b.append(v,u);else if(u instanceof File)b.append(v,await j(u));else if(u instanceof FileList)for(let m=0;m<u.length;m++)b.append(v,await j(u[m]));else if(Array.isArray(u))for(let m=0;m<u.length;m++){let T=u[m];b.append(v,T instanceof File?j(T):T)}else b.append(v,u);p=b}else W["content-type"]=f?"application/json":"text/plain",p=f?JSON.stringify(p):y}let c=await q(F,{method:k,body:p,...t.$fetch,...o.fetch,...x,headers:W}),g;switch(c.headers.get("Content-Type")?.split(";")[0]){case"application/json":g=await c.json();break;default:g=await c.text().then(f=>Number.isNaN(+f)?f==="true"?!0:f==="false"?!1:f:+f)}let R=c.status>=300||c.status<200?new S(c.status,g):null;if(E)for(let f of E){let h=f({data:g,status:c.status,headers:c.headers,response:c,error:R});h instanceof Promise&&(h=await h),h!=null&&(g=h)}return{data:g,error:R,response:c,status:c.status,headers:c.headers}})()}}),I=(r,e={fetcher:fetch})=>new Proxy({},{get(t,n){return M(r,n,e)}});var P=(r,e)=>(t,{query:n,params:a,body:s,...o}={})=>{a&&Object.entries(a).forEach(([i,l])=>{t=t.replace(`:${i}`,l)});let y=o.headers?.["Content-Type"];if(!y||y==="application/json")try{s=JSON.stringify(s)}catch{}let A=e?.fetcher||globalThis.fetch,x=n?`?${new URLSearchParams(n).toString()}`:"",w=()=>A(r+t+x,{...o,method:o.method?.toUpperCase()||"GET",headers:s?{"content-type":"application/json",...o.headers}:o.headers,body:s}).then(async i=>{let l;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":l=await i.json();break;default:l=await i.text().then(d=>Number.isNaN(+d)?d==="true"?!0:d==="false"?!1:d:+d);break}return i.status>300?{data:null,status:i.status,headers:i.headers,retry:w,error:new S(i.status,l)}:{data:l,error:null,status:i.status,headers:i.headers,retry:w}});return w()};return B(H);})(); | ||
"use strict";var Eden=(()=>{var R=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(r,e)=>{for(var t in e)R(r,t,{get:e[t],enumerable:!0})},G=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of V(e))!z.call(r,a)&&a!==t&&R(r,a,{get:()=>e[a],enumerable:!(s=U(e,a))||s.enumerable});return r};var H=r=>G(R({},"__esModule",{value:!0}),r);var Q={};B(Q,{edenFetch:()=>q,edenTreaty:()=>I});var w=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var K=(r,e,t)=>{if(r.endsWith("/")||(r+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${r}${e}`;let s="";for(let[a,n]of Object.entries(t))s+=`${a}=${n}&`;return`${r}${e}?${s.slice(0,-1)}`};var N=typeof FileList>"u",M=r=>N?r instanceof Blob:r instanceof FileList||r instanceof File,_=r=>{if(!r)return!1;for(let e in r){if(M(r[e]))return!0;if(Array.isArray(r[e])&&r[e].find(t=>M(t)))return!0}return!1},j=r=>N?r:new Promise(e=>{let t=new FileReader;t.onload=()=>{let s=new File([t.result],r.name,{lastModified:r.lastModified,type:r.type});e(s)},t.readAsArrayBuffer(r)}),L=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,s){return this.addEventListener(e,t,s)}off(e,t,s){return this.ws.removeEventListener(e,t,s),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,s){return this.ws.addEventListener(e,a=>{if(e==="message"){let n=a.data.toString(),c=n.charCodeAt(0);if(c===47||c===123)try{n=JSON.parse(n)}catch{}else Number.isNaN(+n)?n==="true"?n=!0:n==="false"&&(n=!1):n=+n;t({...a,data:n})}else t(a)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}},P=(r,e="",t)=>new Proxy(()=>{},{get(s,a,n){return P(r,`${e}/${a.toString()}`,t)},apply(s,a,[n,c={}]=[{},{}]){let y=n!==void 0&&(typeof n!="object"||Array.isArray(n))?n:void 0,{$query:A,$fetch:v,$headers:S,$transform:i,getRaw:d,...p}=n??{};y??=p;let T=e.lastIndexOf("/"),k=e.slice(T+1).toUpperCase(),F=K(r,T===-1?"/":e.slice(0,T),Object.assign(c.query??{},A)),D=t.fetcher??fetch,E=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,$=i?Array.isArray(i)?i:[i]:void 0;return $&&(E?E=$.concat(E):E=$),k==="SUBSCRIBE"?new L(F.replace(/^([^]+):\/\//,F.startsWith("https://")?"wss://":"ws://")):(async J=>{let l,W={...t.$fetch?.headers,...v?.headers,...c.headers,...S};if(k!=="GET"&&k!=="HEAD"){l=Object.keys(y).length||Array.isArray(y)?y:void 0;let f=typeof l=="object"||Array.isArray(y);if(f&&_(l)){let b=new FormData;for(let[x,u]of Object.entries(l))if(N)b.append(x,u);else if(u instanceof File)b.append(x,await j(u));else if(u instanceof FileList)for(let m=0;m<u.length;m++)b.append(x,await j(u[m]));else if(Array.isArray(u))for(let m=0;m<u.length;m++){let O=u[m];b.append(x,O instanceof File?await j(O):O)}else b.append(x,u);l=b}else W["content-type"]=f?"application/json":"text/plain",l=f?JSON.stringify(l):y}let o=await D(F,{method:k,body:l,...t.$fetch,...c.fetch,...v,headers:W}),g;if(J.getRaw)return o;switch(o.headers.get("Content-Type")?.split(";")[0]){case"application/json":g=await o.json();break;default:g=await o.text().then(f=>Number.isNaN(+f)?f==="true"?!0:f==="false"?!1:f:+f)}let C=o.status>=300||o.status<200?new w(o.status,g):null;if(E)for(let f of E){let h=f({data:g,status:o.status,headers:o.headers,response:o,error:C});h instanceof Promise&&(h=await h),h!=null&&(g=h)}return{data:g,error:C,response:o,status:o.status,headers:o.headers}})({getRaw:d})}}),I=(r,e={fetcher:fetch})=>new Proxy({},{get(t,s){return P(r,s,e)}});var q=(r,e)=>(t,{query:s,params:a,body:n,...c}={})=>{a&&Object.entries(a).forEach(([i,d])=>{t=t.replace(`:${i}`,d)});let y=c.headers?.["Content-Type"];if(!y||y==="application/json")try{n=JSON.stringify(n)}catch{}let A=e?.fetcher||globalThis.fetch,v=s?`?${new URLSearchParams(s).toString()}`:"",S=()=>A(r+t+v,{...c,method:c.method?.toUpperCase()||"GET",headers:n?{"content-type":"application/json",...c.headers}:c.headers,body:n}).then(async i=>{let d;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await i.json();break;default:d=await i.text().then(p=>Number.isNaN(+p)?p==="true"?!0:p==="false"?!1:p:+p);break}return i.status>300?{data:null,status:i.status,headers:i.headers,retry:S,error:new w(i.status,d)}:{data:d,error:null,status:i.status,headers:i.headers,retry:S}});return S()};return H(Q);})(); |
@@ -1,1 +0,1 @@ | ||
"use strict";var O=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var V=(r,e)=>{for(var t in e)O(r,t,{get:e[t],enumerable:!0})},z=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of J(e))!U.call(r,a)&&a!==t&&O(r,a,{get:()=>e[a],enumerable:!(n=D(e,a))||n.enumerable});return r};var B=r=>z(O({},"__esModule",{value:!0}),r);var H={};V(H,{edenFetch:()=>P,edenTreaty:()=>I});module.exports=B(H);var S=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var C=(r,e,t)=>{if(r.endsWith("/")||(r+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${r}${e}`;let n="";for(let[a,s]of Object.entries(t))n+=`${a}=${s}&`;return`${r}${e}?${n.slice(0,-1)}`};var N=typeof FileList>"u",K=r=>N?r instanceof Blob:r instanceof FileList||r instanceof File,G=r=>{if(!r)return!1;for(let e in r){if(K(r[e]))return!0;if(Array.isArray(r[e])&&r[e].find(t=>K(t)))return!0}return!1},j=r=>N?r:new Promise(e=>{let t=new FileReader;t.onload=()=>{let n=new File([t.result],r.name,{lastModified:r.lastModified,type:r.type});e(n)},t.readAsArrayBuffer(r)}),L=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,n){return this.addEventListener(e,t,n)}off(e,t,n){return this.ws.removeEventListener(e,t,n),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,n){return this.ws.addEventListener(e,a=>{if(e==="message"){let s=a.data.toString(),o=s.charCodeAt(0);if(o===47||o===123)try{s=JSON.parse(s)}catch{}else Number.isNaN(+s)?s==="true"?s=!0:s==="fase"&&(s=!1):s=+s;t({...a,data:s})}else t(a)},n),this}removeEventListener(e,t,n){return this.off(e,t,n),this}close(){return this.ws.close(),this}},M=(r,e="",t)=>new Proxy(()=>{},{get(n,a,s){return M(r,`${e}/${a.toString()}`,t)},apply(n,a,[s,o={}]=[{},{}]){let y=s!==void 0&&(typeof s!="object"||Array.isArray(s))?s:void 0,{$query:A,$fetch:x,$headers:w,$transform:i,...l}=s??{};y??=l;let d=e.lastIndexOf("/"),k=e.slice(d+1).toUpperCase(),F=C(r,d===-1?"/":e.slice(0,d),Object.assign(o.query??{},A)),q=t.fetcher??fetch,E=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,$=i?Array.isArray(i)?i:[i]:void 0;return $&&(E?E=$.concat(E):E=$),k==="SUBSCRIBE"?new L(F.replace(/^([^]+):\/\//,F.startsWith("https://")?"wss://":"ws://")):(async()=>{let p,W={...t.$fetch?.headers,...x?.headers,...o.headers,...w};if(k!=="GET"&&k!=="HEAD"){p=Object.keys(y).length||Array.isArray(y)?y:void 0;let f=typeof p=="object"||Array.isArray(y);if(f&&G(p)){let b=new FormData;for(let[v,u]of Object.entries(p))if(N)b.append(v,u);else if(u instanceof File)b.append(v,await j(u));else if(u instanceof FileList)for(let m=0;m<u.length;m++)b.append(v,await j(u[m]));else if(Array.isArray(u))for(let m=0;m<u.length;m++){let T=u[m];b.append(v,T instanceof File?j(T):T)}else b.append(v,u);p=b}else W["content-type"]=f?"application/json":"text/plain",p=f?JSON.stringify(p):y}let c=await q(F,{method:k,body:p,...t.$fetch,...o.fetch,...x,headers:W}),g;switch(c.headers.get("Content-Type")?.split(";")[0]){case"application/json":g=await c.json();break;default:g=await c.text().then(f=>Number.isNaN(+f)?f==="true"?!0:f==="false"?!1:f:+f)}let R=c.status>=300||c.status<200?new S(c.status,g):null;if(E)for(let f of E){let h=f({data:g,status:c.status,headers:c.headers,response:c,error:R});h instanceof Promise&&(h=await h),h!=null&&(g=h)}return{data:g,error:R,response:c,status:c.status,headers:c.headers}})()}}),I=(r,e={fetcher:fetch})=>new Proxy({},{get(t,n){return M(r,n,e)}});var P=(r,e)=>(t,{query:n,params:a,body:s,...o}={})=>{a&&Object.entries(a).forEach(([i,l])=>{t=t.replace(`:${i}`,l)});let y=o.headers?.["Content-Type"];if(!y||y==="application/json")try{s=JSON.stringify(s)}catch{}let A=e?.fetcher||globalThis.fetch,x=n?`?${new URLSearchParams(n).toString()}`:"",w=()=>A(r+t+x,{...o,method:o.method?.toUpperCase()||"GET",headers:s?{"content-type":"application/json",...o.headers}:o.headers,body:s}).then(async i=>{let l;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":l=await i.json();break;default:l=await i.text().then(d=>Number.isNaN(+d)?d==="true"?!0:d==="false"?!1:d:+d);break}return i.status>300?{data:null,status:i.status,headers:i.headers,retry:w,error:new S(i.status,l)}:{data:l,error:null,status:i.status,headers:i.headers,retry:w}});return w()};0&&(module.exports={edenFetch,edenTreaty}); | ||
"use strict";var R=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(r,e)=>{for(var t in e)R(r,t,{get:e[t],enumerable:!0})},G=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of V(e))!z.call(r,a)&&a!==t&&R(r,a,{get:()=>e[a],enumerable:!(s=U(e,a))||s.enumerable});return r};var H=r=>G(R({},"__esModule",{value:!0}),r);var Q={};B(Q,{edenFetch:()=>q,edenTreaty:()=>I});module.exports=H(Q);var w=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var K=(r,e,t)=>{if(r.endsWith("/")||(r+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${r}${e}`;let s="";for(let[a,n]of Object.entries(t))s+=`${a}=${n}&`;return`${r}${e}?${s.slice(0,-1)}`};var N=typeof FileList>"u",M=r=>N?r instanceof Blob:r instanceof FileList||r instanceof File,_=r=>{if(!r)return!1;for(let e in r){if(M(r[e]))return!0;if(Array.isArray(r[e])&&r[e].find(t=>M(t)))return!0}return!1},j=r=>N?r:new Promise(e=>{let t=new FileReader;t.onload=()=>{let s=new File([t.result],r.name,{lastModified:r.lastModified,type:r.type});e(s)},t.readAsArrayBuffer(r)}),L=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,s){return this.addEventListener(e,t,s)}off(e,t,s){return this.ws.removeEventListener(e,t,s),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,s){return this.ws.addEventListener(e,a=>{if(e==="message"){let n=a.data.toString(),c=n.charCodeAt(0);if(c===47||c===123)try{n=JSON.parse(n)}catch{}else Number.isNaN(+n)?n==="true"?n=!0:n==="false"&&(n=!1):n=+n;t({...a,data:n})}else t(a)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}},P=(r,e="",t)=>new Proxy(()=>{},{get(s,a,n){return P(r,`${e}/${a.toString()}`,t)},apply(s,a,[n,c={}]=[{},{}]){let y=n!==void 0&&(typeof n!="object"||Array.isArray(n))?n:void 0,{$query:A,$fetch:v,$headers:S,$transform:i,getRaw:d,...p}=n??{};y??=p;let T=e.lastIndexOf("/"),k=e.slice(T+1).toUpperCase(),F=K(r,T===-1?"/":e.slice(0,T),Object.assign(c.query??{},A)),D=t.fetcher??fetch,E=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,$=i?Array.isArray(i)?i:[i]:void 0;return $&&(E?E=$.concat(E):E=$),k==="SUBSCRIBE"?new L(F.replace(/^([^]+):\/\//,F.startsWith("https://")?"wss://":"ws://")):(async J=>{let l,W={...t.$fetch?.headers,...v?.headers,...c.headers,...S};if(k!=="GET"&&k!=="HEAD"){l=Object.keys(y).length||Array.isArray(y)?y:void 0;let f=typeof l=="object"||Array.isArray(y);if(f&&_(l)){let b=new FormData;for(let[x,u]of Object.entries(l))if(N)b.append(x,u);else if(u instanceof File)b.append(x,await j(u));else if(u instanceof FileList)for(let m=0;m<u.length;m++)b.append(x,await j(u[m]));else if(Array.isArray(u))for(let m=0;m<u.length;m++){let O=u[m];b.append(x,O instanceof File?await j(O):O)}else b.append(x,u);l=b}else W["content-type"]=f?"application/json":"text/plain",l=f?JSON.stringify(l):y}let o=await D(F,{method:k,body:l,...t.$fetch,...c.fetch,...v,headers:W}),g;if(J.getRaw)return o;switch(o.headers.get("Content-Type")?.split(";")[0]){case"application/json":g=await o.json();break;default:g=await o.text().then(f=>Number.isNaN(+f)?f==="true"?!0:f==="false"?!1:f:+f)}let C=o.status>=300||o.status<200?new w(o.status,g):null;if(E)for(let f of E){let h=f({data:g,status:o.status,headers:o.headers,response:o,error:C});h instanceof Promise&&(h=await h),h!=null&&(g=h)}return{data:g,error:C,response:o,status:o.status,headers:o.headers}})({getRaw:d})}}),I=(r,e={fetcher:fetch})=>new Proxy({},{get(t,s){return P(r,s,e)}});var q=(r,e)=>(t,{query:s,params:a,body:n,...c}={})=>{a&&Object.entries(a).forEach(([i,d])=>{t=t.replace(`:${i}`,d)});let y=c.headers?.["Content-Type"];if(!y||y==="application/json")try{n=JSON.stringify(n)}catch{}let A=e?.fetcher||globalThis.fetch,v=s?`?${new URLSearchParams(s).toString()}`:"",S=()=>A(r+t+v,{...c,method:c.method?.toUpperCase()||"GET",headers:n?{"content-type":"application/json",...c.headers}:c.headers,body:n}).then(async i=>{let d;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await i.json();break;default:d=await i.text().then(p=>Number.isNaN(+p)?p==="true"?!0:p==="false"?!1:p:+p);break}return i.status>300?{data:null,status:i.status,headers:i.headers,retry:S,error:new w(i.status,d)}:{data:d,error:null,status:i.status,headers:i.headers,retry:S}});return S()};0&&(module.exports={edenFetch,edenTreaty}); |
@@ -39,2 +39,9 @@ import { Elysia, InputSchema } from 'elysia'; | ||
} | ||
export type DetailedResponse = { | ||
data: any; | ||
error: any; | ||
response: Response; | ||
status: number; | ||
headers: Headers; | ||
}; | ||
export type Sign<Schema extends Record<string, Record<string, unknown>>, Paths extends (string | number)[] = Split<keyof Schema & string>, Carry extends string = ''> = Paths extends [ | ||
@@ -52,2 +59,3 @@ infer Prefix extends string | number, | ||
$fetch?: RequestInit; | ||
getRaw?: boolean; | ||
} & (IsUnknown<Route['body']> extends false ? Replace<Route['body'], Blob | Blob[], Files> : {}) & (undefined extends Route['query'] ? { | ||
@@ -93,2 +101,6 @@ $query?: Record<string, string>; | ||
} | ||
export type ExecuteOptions = { | ||
getRaw?: boolean; | ||
}; | ||
export type ExecuteReturnType<T extends ExecuteOptions> = T['getRaw'] extends true ? Response : DetailedResponse; | ||
export type WSEvent<K extends keyof WebSocketEventMap, Data = unknown> = K extends 'message' ? OnMessage<Data> : WebSocketEventMap[K]; | ||
@@ -95,0 +107,0 @@ export {}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var Eden=(()=>{var $=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var J=(s,e)=>{for(var t in e)$(s,t,{get:e[t],enumerable:!0})},V=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of q(e))!D.call(s,a)&&a!==t&&$(s,a,{get:()=>e[a],enumerable:!(r=P(e,a))||r.enumerable});return s};var z=s=>V($({},"__esModule",{value:!0}),s);var U={};J(U,{EdenWS:()=>v,edenTreaty:()=>H});var S=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var K=(s,e,t)=>{if(s.endsWith("/")||(s+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${s}${e}`;let r="";for(let[a,n]of Object.entries(t))r+=`${a}=${n}&`;return`${s}${e}?${r.slice(0,-1)}`};var O=typeof FileList>"u",R=s=>O?s instanceof Blob:s instanceof FileList||s instanceof File,B=s=>{if(!s)return!1;for(let e in s){if(R(s[e]))return!0;if(Array.isArray(s[e])&&s[e].find(t=>R(t)))return!0}return!1},F=s=>O?s:new Promise(e=>{let t=new FileReader;t.onload=()=>{let r=new File([t.result],s.name,{lastModified:s.lastModified,type:s.type});e(r)},t.readAsArrayBuffer(s)}),v=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,a=>{if(e==="message"){let n=a.data.toString(),l=n.charCodeAt(0);if(l===47||l===123)try{n=JSON.parse(n)}catch{}else Number.isNaN(+n)?n==="true"?n=!0:n==="fase"&&(n=!1):n=+n;t({...a,data:n})}else t(a)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},j=(s,e="",t)=>new Proxy(()=>{},{get(r,a,n){return j(s,`${e}/${a.toString()}`,t)},apply(r,a,[n,l={}]=[{},{}]){let u=n!==void 0&&(typeof n!="object"||Array.isArray(n))?n:void 0,{$query:N,$fetch:L,$headers:M,$transform:E,...I}=n??{};u??=I;let w=e.lastIndexOf("/"),b=e.slice(w+1).toUpperCase(),k=K(s,w===-1?"/":e.slice(0,w),Object.assign(l.query??{},N)),C=t.fetcher??fetch,p=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,A=E?Array.isArray(E)?E:[E]:void 0;return A&&(p?p=A.concat(p):p=A),b==="SUBSCRIBE"?new v(k.replace(/^([^]+):\/\//,k.startsWith("https://")?"wss://":"ws://")):(async()=>{let f,W={...t.$fetch?.headers,...L?.headers,...l.headers,...M};if(b!=="GET"&&b!=="HEAD"){f=Object.keys(u).length||Array.isArray(u)?u:void 0;let o=typeof f=="object"||Array.isArray(u);if(o&&B(f)){let m=new FormData;for(let[g,c]of Object.entries(f))if(O)m.append(g,c);else if(c instanceof File)m.append(g,await F(c));else if(c instanceof FileList)for(let y=0;y<c.length;y++)m.append(g,await F(c[y]));else if(Array.isArray(c))for(let y=0;y<c.length;y++){let x=c[y];m.append(g,x instanceof File?F(x):x)}else m.append(g,c);f=m}else W["content-type"]=o?"application/json":"text/plain",f=o?JSON.stringify(f):u}let i=await C(k,{method:b,body:f,...t.$fetch,...l.fetch,...L,headers:W}),h;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":h=await i.json();break;default:h=await i.text().then(o=>Number.isNaN(+o)?o==="true"?!0:o==="false"?!1:o:+o)}let T=i.status>=300||i.status<200?new S(i.status,h):null;if(p)for(let o of p){let d=o({data:h,status:i.status,headers:i.headers,response:i,error:T});d instanceof Promise&&(d=await d),d!=null&&(h=d)}return{data:h,error:T,response:i,status:i.status,headers:i.headers}})()}}),H=(s,e={fetcher:fetch})=>new Proxy({},{get(t,r){return j(s,r,e)}});return z(U);})(); | ||
"use strict";var Eden=(()=>{var T=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var z=(s,e)=>{for(var t in e)T(s,t,{get:e[t],enumerable:!0})},B=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of J(e))!V.call(s,a)&&a!==t&&T(s,a,{get:()=>e[a],enumerable:!(r=D(e,a))||r.enumerable});return s};var H=s=>B(T({},"__esModule",{value:!0}),s);var _={};z(_,{EdenWS:()=>S,edenTreaty:()=>G});var w=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var W=(s,e,t)=>{if(s.endsWith("/")||(s+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${s}${e}`;let r="";for(let[a,n]of Object.entries(t))r+=`${a}=${n}&`;return`${s}${e}?${r.slice(0,-1)}`};var O=typeof FileList>"u",K=s=>O?s instanceof Blob:s instanceof FileList||s instanceof File,U=s=>{if(!s)return!1;for(let e in s){if(K(s[e]))return!0;if(Array.isArray(s[e])&&s[e].find(t=>K(t)))return!0}return!1},$=s=>O?s:new Promise(e=>{let t=new FileReader;t.onload=()=>{let r=new File([t.result],s.name,{lastModified:s.lastModified,type:s.type});e(r)},t.readAsArrayBuffer(s)}),S=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,a=>{if(e==="message"){let n=a.data.toString(),l=n.charCodeAt(0);if(l===47||l===123)try{n=JSON.parse(n)}catch{}else Number.isNaN(+n)?n==="true"?n=!0:n==="false"&&(n=!1):n=+n;t({...a,data:n})}else t(a)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},j=(s,e="",t)=>new Proxy(()=>{},{get(r,a,n){return j(s,`${e}/${a.toString()}`,t)},apply(r,a,[n,l={}]=[{},{}]){let u=n!==void 0&&(typeof n!="object"||Array.isArray(n))?n:void 0,{$query:N,$fetch:F,$headers:M,$transform:E,getRaw:I,...P}=n??{};u??=P;let v=e.lastIndexOf("/"),b=e.slice(v+1).toUpperCase(),x=W(s,v===-1?"/":e.slice(0,v),Object.assign(l.query??{},N)),C=t.fetcher??fetch,p=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,k=E?Array.isArray(E)?E:[E]:void 0;return k&&(p?p=k.concat(p):p=k),b==="SUBSCRIBE"?new S(x.replace(/^([^]+):\/\//,x.startsWith("https://")?"wss://":"ws://")):(async q=>{let f,R={...t.$fetch?.headers,...F?.headers,...l.headers,...M};if(b!=="GET"&&b!=="HEAD"){f=Object.keys(u).length||Array.isArray(u)?u:void 0;let o=typeof f=="object"||Array.isArray(u);if(o&&U(f)){let m=new FormData;for(let[g,c]of Object.entries(f))if(O)m.append(g,c);else if(c instanceof File)m.append(g,await $(c));else if(c instanceof FileList)for(let d=0;d<c.length;d++)m.append(g,await $(c[d]));else if(Array.isArray(c))for(let d=0;d<c.length;d++){let A=c[d];m.append(g,A instanceof File?await $(A):A)}else m.append(g,c);f=m}else R["content-type"]=o?"application/json":"text/plain",f=o?JSON.stringify(f):u}let i=await C(x,{method:b,body:f,...t.$fetch,...l.fetch,...F,headers:R}),h;if(q.getRaw)return i;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":h=await i.json();break;default:h=await i.text().then(o=>Number.isNaN(+o)?o==="true"?!0:o==="false"?!1:o:+o)}let L=i.status>=300||i.status<200?new w(i.status,h):null;if(p)for(let o of p){let y=o({data:h,status:i.status,headers:i.headers,response:i,error:L});y instanceof Promise&&(y=await y),y!=null&&(h=y)}return{data:h,error:L,response:i,status:i.status,headers:i.headers}})({getRaw:I})}}),G=(s,e={fetcher:fetch})=>new Proxy({},{get(t,r){return j(s,r,e)}});return H(_);})(); |
@@ -1,1 +0,1 @@ | ||
"use strict";var $=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var J=(s,e)=>{for(var t in e)$(s,t,{get:e[t],enumerable:!0})},V=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of q(e))!D.call(s,a)&&a!==t&&$(s,a,{get:()=>e[a],enumerable:!(r=P(e,a))||r.enumerable});return s};var z=s=>V($({},"__esModule",{value:!0}),s);var U={};J(U,{EdenWS:()=>v,edenTreaty:()=>H});module.exports=z(U);var S=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var K=(s,e,t)=>{if(s.endsWith("/")||(s+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${s}${e}`;let r="";for(let[a,n]of Object.entries(t))r+=`${a}=${n}&`;return`${s}${e}?${r.slice(0,-1)}`};var O=typeof FileList>"u",R=s=>O?s instanceof Blob:s instanceof FileList||s instanceof File,B=s=>{if(!s)return!1;for(let e in s){if(R(s[e]))return!0;if(Array.isArray(s[e])&&s[e].find(t=>R(t)))return!0}return!1},F=s=>O?s:new Promise(e=>{let t=new FileReader;t.onload=()=>{let r=new File([t.result],s.name,{lastModified:s.lastModified,type:s.type});e(r)},t.readAsArrayBuffer(s)}),v=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,a=>{if(e==="message"){let n=a.data.toString(),l=n.charCodeAt(0);if(l===47||l===123)try{n=JSON.parse(n)}catch{}else Number.isNaN(+n)?n==="true"?n=!0:n==="fase"&&(n=!1):n=+n;t({...a,data:n})}else t(a)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},j=(s,e="",t)=>new Proxy(()=>{},{get(r,a,n){return j(s,`${e}/${a.toString()}`,t)},apply(r,a,[n,l={}]=[{},{}]){let u=n!==void 0&&(typeof n!="object"||Array.isArray(n))?n:void 0,{$query:N,$fetch:L,$headers:M,$transform:E,...I}=n??{};u??=I;let w=e.lastIndexOf("/"),b=e.slice(w+1).toUpperCase(),k=K(s,w===-1?"/":e.slice(0,w),Object.assign(l.query??{},N)),C=t.fetcher??fetch,p=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,A=E?Array.isArray(E)?E:[E]:void 0;return A&&(p?p=A.concat(p):p=A),b==="SUBSCRIBE"?new v(k.replace(/^([^]+):\/\//,k.startsWith("https://")?"wss://":"ws://")):(async()=>{let f,W={...t.$fetch?.headers,...L?.headers,...l.headers,...M};if(b!=="GET"&&b!=="HEAD"){f=Object.keys(u).length||Array.isArray(u)?u:void 0;let o=typeof f=="object"||Array.isArray(u);if(o&&B(f)){let m=new FormData;for(let[g,c]of Object.entries(f))if(O)m.append(g,c);else if(c instanceof File)m.append(g,await F(c));else if(c instanceof FileList)for(let y=0;y<c.length;y++)m.append(g,await F(c[y]));else if(Array.isArray(c))for(let y=0;y<c.length;y++){let x=c[y];m.append(g,x instanceof File?F(x):x)}else m.append(g,c);f=m}else W["content-type"]=o?"application/json":"text/plain",f=o?JSON.stringify(f):u}let i=await C(k,{method:b,body:f,...t.$fetch,...l.fetch,...L,headers:W}),h;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":h=await i.json();break;default:h=await i.text().then(o=>Number.isNaN(+o)?o==="true"?!0:o==="false"?!1:o:+o)}let T=i.status>=300||i.status<200?new S(i.status,h):null;if(p)for(let o of p){let d=o({data:h,status:i.status,headers:i.headers,response:i,error:T});d instanceof Promise&&(d=await d),d!=null&&(h=d)}return{data:h,error:T,response:i,status:i.status,headers:i.headers}})()}}),H=(s,e={fetcher:fetch})=>new Proxy({},{get(t,r){return j(s,r,e)}});0&&(module.exports={EdenWS,edenTreaty}); | ||
"use strict";var T=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var z=(s,e)=>{for(var t in e)T(s,t,{get:e[t],enumerable:!0})},B=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of J(e))!V.call(s,a)&&a!==t&&T(s,a,{get:()=>e[a],enumerable:!(r=D(e,a))||r.enumerable});return s};var H=s=>B(T({},"__esModule",{value:!0}),s);var _={};z(_,{EdenWS:()=>S,edenTreaty:()=>G});module.exports=H(_);var w=class extends Error{status;value;constructor(e,t){super(),this.status=e,this.value=t}};var W=(s,e,t)=>{if(s.endsWith("/")||(s+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${s}${e}`;let r="";for(let[a,n]of Object.entries(t))r+=`${a}=${n}&`;return`${s}${e}?${r.slice(0,-1)}`};var O=typeof FileList>"u",K=s=>O?s instanceof Blob:s instanceof FileList||s instanceof File,U=s=>{if(!s)return!1;for(let e in s){if(K(s[e]))return!0;if(Array.isArray(s[e])&&s[e].find(t=>K(t)))return!0}return!1},$=s=>O?s:new Promise(e=>{let t=new FileReader;t.onload=()=>{let r=new File([t.result],s.name,{lastModified:s.lastModified,type:s.type});e(r)},t.readAsArrayBuffer(s)}),S=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,a=>{if(e==="message"){let n=a.data.toString(),l=n.charCodeAt(0);if(l===47||l===123)try{n=JSON.parse(n)}catch{}else Number.isNaN(+n)?n==="true"?n=!0:n==="false"&&(n=!1):n=+n;t({...a,data:n})}else t(a)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},j=(s,e="",t)=>new Proxy(()=>{},{get(r,a,n){return j(s,`${e}/${a.toString()}`,t)},apply(r,a,[n,l={}]=[{},{}]){let u=n!==void 0&&(typeof n!="object"||Array.isArray(n))?n:void 0,{$query:N,$fetch:F,$headers:M,$transform:E,getRaw:I,...P}=n??{};u??=P;let v=e.lastIndexOf("/"),b=e.slice(v+1).toUpperCase(),x=W(s,v===-1?"/":e.slice(0,v),Object.assign(l.query??{},N)),C=t.fetcher??fetch,p=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,k=E?Array.isArray(E)?E:[E]:void 0;return k&&(p?p=k.concat(p):p=k),b==="SUBSCRIBE"?new S(x.replace(/^([^]+):\/\//,x.startsWith("https://")?"wss://":"ws://")):(async q=>{let f,R={...t.$fetch?.headers,...F?.headers,...l.headers,...M};if(b!=="GET"&&b!=="HEAD"){f=Object.keys(u).length||Array.isArray(u)?u:void 0;let o=typeof f=="object"||Array.isArray(u);if(o&&U(f)){let m=new FormData;for(let[g,c]of Object.entries(f))if(O)m.append(g,c);else if(c instanceof File)m.append(g,await $(c));else if(c instanceof FileList)for(let d=0;d<c.length;d++)m.append(g,await $(c[d]));else if(Array.isArray(c))for(let d=0;d<c.length;d++){let A=c[d];m.append(g,A instanceof File?await $(A):A)}else m.append(g,c);f=m}else R["content-type"]=o?"application/json":"text/plain",f=o?JSON.stringify(f):u}let i=await C(x,{method:b,body:f,...t.$fetch,...l.fetch,...F,headers:R}),h;if(q.getRaw)return i;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":h=await i.json();break;default:h=await i.text().then(o=>Number.isNaN(+o)?o==="true"?!0:o==="false"?!1:o:+o)}let L=i.status>=300||i.status<200?new w(i.status,h):null;if(p)for(let o of p){let y=o({data:h,status:i.status,headers:i.headers,response:i,error:L});y instanceof Promise&&(y=await y),y!=null&&(h=y)}return{data:h,error:L,response:i,status:i.status,headers:i.headers}})({getRaw:I})}}),G=(s,e={fetcher:fetch})=>new Proxy({},{get(t,r){return j(s,r,e)}});0&&(module.exports={EdenWS,edenTreaty}); |
@@ -39,2 +39,9 @@ /// <reference lib="dom" /> | ||
} | ||
export type DetailedResponse = { | ||
data: any; | ||
error: any; | ||
response: Response; | ||
status: number; | ||
headers: Headers; | ||
}; | ||
export type Sign<Schema extends Record<string, Record<string, unknown>>, Paths extends (string | number)[] = Split<keyof Schema & string>, Carry extends string = ''> = Paths extends [ | ||
@@ -52,2 +59,3 @@ infer Prefix extends string | number, | ||
$fetch?: RequestInit; | ||
getRaw?: boolean; | ||
} & (IsUnknown<Route['body']> extends false ? Replace<Route['body'], Blob | Blob[], Files> : {}) & (undefined extends Route['query'] ? { | ||
@@ -93,2 +101,6 @@ $query?: Record<string, string>; | ||
} | ||
export type ExecuteOptions = { | ||
getRaw?: boolean; | ||
}; | ||
export type ExecuteReturnType<T extends ExecuteOptions> = T['getRaw'] extends true ? Response : DetailedResponse; | ||
export type WSEvent<K extends keyof WebSocketEventMap, Data = unknown> = K extends 'message' ? OnMessage<Data> : WebSocketEventMap[K]; | ||
@@ -95,0 +107,0 @@ export {}; |
143
package.json
{ | ||
"name": "@elysiajs/eden", | ||
"version": "0.7.6", | ||
"description": "Fully type-safe Elysia client", | ||
"author": { | ||
"name": "saltyAom", | ||
"url": "https://github.com/SaltyAom", | ||
"email": "saltyaom@gmail.com" | ||
"name": "@elysiajs/eden", | ||
"version": "0.7.7", | ||
"description": "Fully type-safe Elysia client", | ||
"author": { | ||
"name": "saltyAom", | ||
"url": "https://github.com/SaltyAom", | ||
"email": "saltyaom@gmail.com" | ||
}, | ||
"main": "./dist/index.js", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs", | ||
"node": "./dist/index.js", | ||
"default": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"main": "./dist/index.js", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs", | ||
"node": "./dist/index.js", | ||
"default": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"./treaty": { | ||
"require": "./dist/treaty.js", | ||
"import": "./dist/treaty.mjs", | ||
"node": "./dist/treaty.js", | ||
"default": "./dist/treaty.js", | ||
"types": "./dist/treaty/index.d.ts" | ||
}, | ||
"./fetch": { | ||
"require": "./dist/fetch.js", | ||
"import": "./dist/fetch.mjs", | ||
"node": "./dist/fetch.js", | ||
"default": "./dist/fetch.js", | ||
"types": "./dist/fetch/index.d.ts" | ||
} | ||
"./treaty": { | ||
"require": "./dist/treaty.js", | ||
"import": "./dist/treaty.mjs", | ||
"node": "./dist/treaty.js", | ||
"default": "./dist/treaty.js", | ||
"types": "./dist/treaty/index.d.ts" | ||
}, | ||
"types": "./src/index.ts", | ||
"keywords": ["elysia", "eden", "connector"], | ||
"homepage": "https://github.com/elysiajs/eden", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/elysiajs/eden" | ||
}, | ||
"bugs": "https://github.com/elysiajs/eden/issues", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "bun run --watch example/index.ts", | ||
"test": "bun test", | ||
"build": "rimraf dist && tsup", | ||
"release": "npm run build && npm run test && npm publish --access public" | ||
}, | ||
"peerDependencies": { | ||
"elysia": ">= 0.7.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@sinclair/typebox": { | ||
"optional": true | ||
} | ||
}, | ||
"devDependencies": { | ||
"@elysiajs/cors": "0.7.0", | ||
"@sinclair/typebox": "^0.31.6", | ||
"@types/node": "^18.15.5", | ||
"bun-types": "^1.0.1", | ||
"elysia": "^0.7.15", | ||
"esbuild": "^0.19.3", | ||
"eslint": "^8.26.0", | ||
"rimraf": "^4.4.1", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
"prettier": { | ||
"semi": false, | ||
"tabWidth": 4, | ||
"singleQuote": true, | ||
"trailingComma": "none" | ||
"./fetch": { | ||
"require": "./dist/fetch.js", | ||
"import": "./dist/fetch.mjs", | ||
"node": "./dist/fetch.js", | ||
"default": "./dist/fetch.js", | ||
"types": "./dist/fetch/index.d.ts" | ||
} | ||
}, | ||
"types": "./src/index.ts", | ||
"keywords": ["elysia", "eden", "connector"], | ||
"homepage": "https://github.com/elysiajs/eden", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/elysiajs/eden" | ||
}, | ||
"bugs": "https://github.com/elysiajs/eden/issues", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "bun run --watch example/index.ts", | ||
"test": "bun test", | ||
"build": "rimraf dist && tsup", | ||
"release": "npm run build && npm run test && npm publish --access public" | ||
}, | ||
"peerDependencies": { | ||
"elysia": ">= 0.7.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@sinclair/typebox": { | ||
"optional": true | ||
} | ||
}, | ||
"devDependencies": { | ||
"@elysiajs/cors": "0.7.0", | ||
"@sinclair/typebox": "^0.31.6", | ||
"@types/node": "^18.15.5", | ||
"bun-types": "^1.0.1", | ||
"elysia": "^0.7.15", | ||
"esbuild": "^0.19.3", | ||
"eslint": "^8.26.0", | ||
"rimraf": "^4.4.1", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
"prettier": { | ||
"semi": false, | ||
"tabWidth": 4, | ||
"singleQuote": true, | ||
"trailingComma": "none" | ||
}, | ||
"dependencies": { | ||
"superjson": "^2.2.1" | ||
} | ||
} |
@@ -128,3 +128,3 @@ import type { Elysia, InputSchema } from 'elysia' | ||
else if (data === 'true') data = true | ||
else if (data === 'fase') data = false | ||
else if (data === 'false') data = false | ||
@@ -179,2 +179,3 @@ listener({ | ||
$query?: Record<string, string> | ||
getRaw?: boolean | ||
}, | ||
@@ -195,3 +196,3 @@ { | ||
const { $query, $fetch, $headers, $transform, ...restBody } = | ||
const { $query, $fetch, $headers, $transform, getRaw, ...restBody } = | ||
initialBody ?? {} | ||
@@ -235,3 +236,3 @@ | ||
const execute = async () => { | ||
const execute = async <T extends EdenTreaty.ExecuteOptions>(modifiers: T): Promise<EdenTreaty.ExecuteReturnType<T>> => { | ||
let body: any | ||
@@ -289,3 +290,3 @@ | ||
value instanceof File | ||
? createNewFile(value) | ||
? await createNewFile(value) | ||
: value | ||
@@ -319,2 +320,3 @@ ) | ||
if (modifiers.getRaw) return response as any | ||
switch (response.headers.get('Content-Type')?.split(';')[0]) { | ||
@@ -360,6 +362,6 @@ case 'application/json': | ||
headers: response.headers | ||
} | ||
} as any | ||
} | ||
return execute() | ||
return execute({ getRaw }) | ||
} | ||
@@ -366,0 +368,0 @@ }) as unknown as Record<string, unknown> |
@@ -86,2 +86,10 @@ /// <reference lib="dom" /> | ||
export type DetailedResponse = { | ||
data: any | ||
error: any | ||
response: Response | ||
status: number | ||
headers: Headers | ||
}; | ||
export type Sign< | ||
@@ -115,2 +123,3 @@ Schema extends Record<string, Record<string, unknown>>, | ||
$fetch?: RequestInit | ||
getRaw?: boolean | ||
} & (IsUnknown<Route['body']> extends false | ||
@@ -203,2 +212,7 @@ ? Replace< | ||
export type ExecuteOptions = { | ||
getRaw?: boolean | ||
}; | ||
export type ExecuteReturnType<T extends ExecuteOptions> = T['getRaw'] extends true ? Response : DetailedResponse; | ||
export type WSEvent< | ||
@@ -205,0 +219,0 @@ K extends keyof WebSocketEventMap, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84417
1260
2
+ Addedsuperjson@^2.2.1
+ Addedcopy-anything@3.0.5(transitive)
+ Addedis-what@4.1.16(transitive)
+ Addedsuperjson@2.2.1(transitive)