@merkl/api 0.10.130 → 0.10.132

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/dist/src/modules/v4/blacklist/blacklist.controller.js +2 -6
  2. package/dist/src/modules/v4/campaign/campaign.controller.js +6 -18
  3. package/dist/src/modules/v4/chain/chain.controller.js +3 -6
  4. package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +1 -4
  5. package/dist/src/modules/v4/merklRoot/merklRoot.controller.js +2 -6
  6. package/dist/src/modules/v4/opportunity/opportunity.controller.js +3 -9
  7. package/dist/src/modules/v4/participate/participate.controller.js +5 -3
  8. package/dist/src/modules/v4/price/price.controller.js +11 -21
  9. package/dist/src/modules/v4/status/status.controller.js +6 -18
  10. package/dist/src/modules/v4/token/token.controller.js +3 -6
  11. package/dist/tsconfig.package.tsbuildinfo +1 -1
  12. package/package.json +3 -3
  13. package/dist/node_modules/@elysiajs/eden/eden/LICENSE +0 -7
  14. package/dist/node_modules/@elysiajs/eden/eden/README.md +0 -46
  15. package/dist/node_modules/@elysiajs/eden/eden/bunfig.toml +0 -2
  16. package/dist/node_modules/@elysiajs/eden/eden/dist/chunk-2IHGLN7W.mjs +0 -1
  17. package/dist/node_modules/@elysiajs/eden/eden/dist/chunk-7WO4HTSU.mjs +0 -1
  18. package/dist/node_modules/@elysiajs/eden/eden/dist/chunk-XYW4OUFN.mjs +0 -1
  19. package/dist/node_modules/@elysiajs/eden/eden/dist/chunk-YAG46HFR.mjs +0 -1
  20. package/dist/node_modules/@elysiajs/eden/eden/dist/errors.d.ts +0 -5
  21. package/dist/node_modules/@elysiajs/eden/eden/dist/fetch/index.d.ts +0 -4
  22. package/dist/node_modules/@elysiajs/eden/eden/dist/fetch/types.d.ts +0 -44
  23. package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.d.mts +0 -48
  24. package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.d.ts +0 -48
  25. package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.global.js +0 -1
  26. package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.js +0 -1
  27. package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.mjs +0 -1
  28. package/dist/node_modules/@elysiajs/eden/eden/dist/index.d.mts +0 -5
  29. package/dist/node_modules/@elysiajs/eden/eden/dist/index.d.ts +0 -5
  30. package/dist/node_modules/@elysiajs/eden/eden/dist/index.global.js +0 -1
  31. package/dist/node_modules/@elysiajs/eden/eden/dist/index.js +0 -1
  32. package/dist/node_modules/@elysiajs/eden/eden/dist/index.mjs +0 -1
  33. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty/index.d.ts +0 -17
  34. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty/types.d.ts +0 -99
  35. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty/utils.d.ts +0 -1
  36. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.d.mts +0 -114
  37. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.d.ts +0 -114
  38. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.global.js +0 -1
  39. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.js +0 -1
  40. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.mjs +0 -1
  41. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2/index.d.ts +0 -5
  42. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2/types.d.ts +0 -86
  43. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2/ws.d.ts +0 -14
  44. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.d.mts +0 -103
  45. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.d.ts +0 -103
  46. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.global.js +0 -1
  47. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.js +0 -1
  48. package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.mjs +0 -1
  49. package/dist/node_modules/@elysiajs/eden/eden/dist/types-C41kuZ-K.d.mts +0 -44
  50. package/dist/node_modules/@elysiajs/eden/eden/dist/types-C41kuZ-K.d.ts +0 -44
  51. package/dist/node_modules/@elysiajs/eden/eden/dist/types.d.ts +0 -39
  52. package/dist/node_modules/@elysiajs/eden/eden/dist/utils/parsingUtils.d.ts +0 -6
  53. package/dist/node_modules/@elysiajs/eden/eden/package.json +0 -85
  54. package/dist/package.json +0 -91
  55. package/dist/src/modules/v4/apr/apr.controller.d.ts +0 -0
  56. package/dist/src/modules/v4/apr/apr.controller.js +0 -1
  57. package/dist/src/modules/v4/tvl/tvl.controller.d.ts +0 -0
  58. package/dist/src/modules/v4/tvl/tvl.controller.js +0 -1
package/package.json CHANGED
@@ -33,6 +33,7 @@
33
33
  "@elysiajs/cors": "^0.7.2",
34
34
  "@elysiajs/opentelemetry": "^1.1.7",
35
35
  "@elysiajs/swagger": "^0.7.4",
36
+ "@elysiajs/eden": "^1.1.3",
36
37
  "@ethersproject/abi": "^5.7.0",
37
38
  "@prisma/client": "6.0.1",
38
39
  "@sinclair/typebox": "^0.33.4",
@@ -63,8 +64,7 @@
63
64
  "treeify": "^1.1.0",
64
65
  "tscpaths": "^0.0.9",
65
66
  "uuid": "^9.0.1",
66
- "viem": "^2.21.27",
67
- "@elysiajs/eden": "1.0.9"
67
+ "viem": "^2.21.27"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@biomejs/biome": "^1.6.3",
@@ -87,5 +87,5 @@
87
87
  "access": "public",
88
88
  "registry": "https://registry.npmjs.org/"
89
89
  },
90
- "version": "v0.10.130"
90
+ "version": "v0.10.132"
91
91
  }
@@ -1,7 +0,0 @@
1
- Copyright 2023 saltyAom
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,46 +0,0 @@
1
- # @elysiajs/eden
2
- Fully type-safe Elysia client refers to the [documentation](https://elysiajs.com/eden/overview)
3
-
4
- ## Installation
5
- ```bash
6
- bun add elysia @elysiajs/eden
7
- ```
8
-
9
- ## Example
10
- ```typescript
11
- // server.ts
12
- import { Elysia, t } from 'elysia'
13
-
14
- const app = new Elysia()
15
- .get('/', () => 'Hi Elysia')
16
- .get('/id/:id', ({ params: { id } }) => id)
17
- .post('/mirror', ({ body }) => body, {
18
- schema: {
19
- body: t.Object({
20
- id: t.Number(),
21
- name: t.String()
22
- })
23
- }
24
- })
25
- .listen(8080)
26
-
27
- export type App = typeof app
28
-
29
- // client.ts
30
- import { edenTreaty } from '@elysiajs/eden'
31
- import type { App } from './server'
32
-
33
- const app = edenTreaty<App>('http://localhost:8080')
34
-
35
- // data: Hi Elysia (fully type-safe)
36
- const { data: pong } = app.index.get()
37
-
38
- // data: 1895
39
- const { data: id } = client.id.1895.get()
40
-
41
- // data: { id: 1895, name: 'Skadi' }
42
- const { data: nendoroid } = app.mirror.post({
43
- id: 1895,
44
- name: 'Skadi'
45
- })
46
- ```
@@ -1,2 +0,0 @@
1
- [install]
2
- registry = "https://registry.npmjs.org/"
@@ -1 +0,0 @@
1
- import{a as O,b as L,c as W}from"./chunk-XYW4OUFN.mjs";var K=(n,e,t)=>{if(n.endsWith("/")||(n+="/"),e==="index"&&(e=""),!t||!Object.keys(t).length)return`${n}${e}`;let s="";for(let[c,a]of Object.entries(t))s+=`${c}=${a}&`;return`${n}${e}?${s.slice(0,-1)}`};var $=typeof FileList>"u",M=n=>$?n instanceof Blob:n instanceof FileList||n instanceof File,H=n=>{if(!n)return!1;for(let e in n){if(M(n[e]))return!0;if(Array.isArray(n[e])&&n[e].find(t=>M(t)))return!0}return!1},x=n=>$?n:new Promise(e=>{let t=new FileReader;t.onload=()=>{let s=new File([t.result],n.name,{lastModified:n.lastModified,type:n.type});e(s)},t.readAsArrayBuffer(n)}),T=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,c=>{if(e==="message"){let a=W(c);t({...c,data:a})}else t(c)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}},j=(n,e="",t)=>new Proxy(()=>{},{get(s,c,a){return j(n,`${e}/${c.toString()}`,t)},apply(s,c,[a,b={}]=[{},{}]){let y=a!==void 0&&(typeof a!="object"||Array.isArray(a))?a:void 0,{$query:I,$fetch:F,$headers:P,$transform:m,getRaw:C,...q}=a??{};y??=q;let w=e.lastIndexOf("/"),E=e.slice(w+1).toUpperCase(),v=K(n,w===-1?"/":e.slice(0,w),Object.assign(b.query??{},I)),D=t.fetcher??fetch,l=t.transform?Array.isArray(t.transform)?t.transform:[t.transform]:void 0,S=m?Array.isArray(m)?m:[m]:void 0;return S&&(l?l=S.concat(l):l=S),E==="SUBSCRIBE"?new T(v.replace(/^([^]+):\/\//,v.startsWith("https://")?"wss://":"ws://")):(async N=>{let r,R={...t.$fetch?.headers,...F?.headers,...b.headers,...P};if(E!=="GET"&&E!=="HEAD"){r=Object.keys(y).length||Array.isArray(y)?y:void 0;let p=r&&(typeof r=="object"||Array.isArray(y));if(p&&H(r)){let u=new FormData;for(let[h,o]of Object.entries(r))if($)u.append(h,o);else if(o instanceof File)u.append(h,await x(o));else if(o instanceof FileList)for(let d=0;d<o.length;d++)u.append(h,await x(o[d]));else if(Array.isArray(o))for(let d=0;d<o.length;d++){let k=o[d];u.append(h,k instanceof File?await x(k):k)}else u.append(h,o);r=u}else r!=null&&(R["content-type"]=p?"application/json":"text/plain",r=p?JSON.stringify(r):y)}let i=await D(v,{method:E,body:r,...t.$fetch,...b.fetch,...F,headers:R}),g;if(N.getRaw)return i;switch(i.headers.get("Content-Type")?.split(";")[0]){case"application/json":g=await i.json();break;default:g=await i.text().then(L)}let B=i.status>=300||i.status<200?new O(i.status,g):null,A={data:g,error:B,response:i,status:i.status,headers:i.headers};if(l)for(let p of l){let f=p(A);f instanceof Promise&&(f=await f),f!=null&&(A=f)}return A})({getRaw:C})}}),z=(n,e={fetcher:fetch})=>new Proxy({},{get(t,s){return j(n,s,e)}});export{T as a,z as b};
@@ -1 +0,0 @@
1
- import{a as x,b as O,c as M}from"./chunk-XYW4OUFN.mjs";var F=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,s){return this.addEventListener(t,n,s)}off(t,n,s){return this.ws.removeEventListener(t,n,s),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,s){return this.ws.addEventListener(t,c=>{if(t==="message"){let f=M(c);n({...c,data:f})}else n(c)},s),this}removeEventListener(t,n,s){return this.off(t,n,s),this}close(){return this.ws.close(),this}};var N=["get","post","put","delete","patch","options","head","connect","subscribe"],I=["localhost","127.0.0.1","0.0.0.0"],C=typeof FileList>"u",q=e=>C?e instanceof Blob:e instanceof FileList||e instanceof File,P=e=>{if(!e)return!1;for(let t in e)if(q(e[t])||Array.isArray(e[t])&&e[t].find(q))return!0;return!1},j=e=>C?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(s)},n.readAsArrayBuffer(e)}),b=(e,t,n={},s={})=>{if(Array.isArray(e)){for(let c of e)if(!Array.isArray(c))s=b(c,t,n,s);else{let f=c[0];if(typeof f=="string")s[f.toLowerCase()]=c[1];else for(let[a,w]of f)s[a.toLowerCase()]=w}return s}if(!e)return s;switch(typeof e){case"function":if(e instanceof Headers)return b(e,t,n,s);let c=e(t,n);return c?b(c,t,n,s):s;case"object":if(e instanceof Headers)return e.forEach((f,a)=>{s[a.toLowerCase()]=f}),s;for(let[f,a]of Object.entries(e))s[f.toLowerCase()]=a;return s;default:return s}};async function*U(e){let t=e.body;if(!t)return;let n=t.getReader(),s=new TextDecoder;try{for(;;){let{done:c,value:f}=await n.read();if(c)break;let a=s.decode(f);yield O(a)}}finally{n.releaseLock()}}var A=(e,t,n=[],s)=>new Proxy(()=>{},{get(c,f){return A(e,t,f==="index"?n:[...n,f],s)},apply(c,f,[a,w]){if(!a||w||typeof a=="object"&&Object.keys(a).length!==1||N.includes(n.at(-1))){let K=[...n],k=K.pop(),g="/"+K.join("/"),{fetcher:D=fetch,headers:L,onRequest:p,onResponse:E,fetch:H}=t,m=k==="get"||k==="head"||k==="subscribe";L=b(L,g,w);let T=m?a?.query:w?.query,R="";if(T){let r=(h,d)=>{R+=(R?"&":"?")+`${encodeURIComponent(h)}=${encodeURIComponent(d)}`};for(let[h,d]of Object.entries(T)){if(Array.isArray(d)){for(let o of d)r(h,o);continue}if(typeof d=="object"){r(h,JSON.stringify(d));continue}r(h,`${d}`)}}if(k==="subscribe"){let r=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||I.find(h=>e.includes(h))?"ws://":"wss://")+g+R;return new F(r)}return(async()=>{let r={method:k?.toUpperCase(),body:a,...H,headers:L};r.headers={...L,...b(m?a?.headers:w?.headers,g,r)};let h=m&&typeof a=="object"?a.fetch:w?.fetch;if(r={...r,...h},m&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let y of p){let i=await y(g,r);typeof i=="object"&&(r={...r,...i,headers:{...r.headers,...b(i.headers,g,r)}})}}if(m&&delete r.body,P(a)){let y=new FormData;for(let[i,u]of Object.entries(r.body)){if(C){y.append(i,u);continue}if(u instanceof File){y.append(i,await j(u));continue}if(u instanceof FileList){for(let v=0;v<u.length;v++)y.append(i,await j(u[v]));continue}if(Array.isArray(u)){for(let v=0;v<u.length;v++){let W=u[v];y.append(i,W instanceof File?await j(W):W)}continue}y.append(i,u)}r.body=y}else typeof a=="object"?(r.headers["content-type"]="application/json",r.body=JSON.stringify(a)):a!=null&&(r.headers["content-type"]="text/plain");if(m&&delete r.body,p){Array.isArray(p)||(p=[p]);for(let y of p){let i=await y(g,r);typeof i=="object"&&(r={...r,...i,headers:{...r.headers,...b(i.headers,g,r)}})}}let d=e+g+R,o=await(s?.handle(new Request(d,r))??D(d,r)),l=null,S=null;if(E){Array.isArray(E)||(E=[E]);for(let y of E)try{let i=await y(o.clone());if(i!=null){l=i;break}}catch(i){i instanceof x?S=i:S=new x(422,i);break}}if(l!==null)return{data:l,error:S,response:o,status:o.status,headers:o.headers};switch(o.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":l=U(o);break;case"application/json":l=await o.json();break;case"application/octet-stream":l=await o.arrayBuffer();break;case"multipart/form-data":let y=await o.formData();l={},y.forEach((i,u)=>{l[u]=i});break;default:l=await o.text().then(O)}return(o.status>=300||o.status<200)&&(S=new x(o.status,l),l=null),{data:l,error:S,response:o,status:o.status,headers:o.headers}})()}return typeof a=="object"?A(e,t,[...n,Object.values(a)[0]],s):A(e,t,n)}}),V=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(I.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),A(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),A("http://e.ly",t,[],e));export{U as a,V as b};
@@ -1 +0,0 @@
1
- var s=class extends Error{constructor(e,n){super(n+"");this.status=e;this.value=n}};var i=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,o=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,c=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,u=t=>t.trim().length!==0&&!Number.isNaN(Number(t)),d=t=>{if(typeof t!="string")return null;let r=t.replace(/"/g,"");if(i.test(r)||o.test(r)||c.test(r)){let e=new Date(r);if(!Number.isNaN(e.getTime()))return e}return null},a=t=>{let r=t.charCodeAt(0),e=t.charCodeAt(t.length-1);return r===123&&e===125||r===91&&e===93},p=t=>JSON.parse(t,(r,e)=>{let n=d(e);return n||e}),g=t=>{if(!t)return t;if(u(t))return+t;if(t==="true")return!0;if(t==="false")return!1;let r=d(t);if(r)return r;if(a(t))try{return p(t)}catch{}return t},S=t=>{let r=t.data.toString();return r==="null"?null:g(r)};export{s as a,g as b,S as c};
@@ -1 +0,0 @@
1
- import{a as y,b as p}from"./chunk-XYW4OUFN.mjs";var g=async t=>{switch(t.headers.get("Content-Type")?.split(";")[0]){case"application/json":return t.json();case"application/octet-stream":return t.arrayBuffer();case"multipart/form-data":{let e=await t.formData(),r={};return e.forEach((c,a)=>{r[a]=c}),r}}return t.text().then(p)},T=async(t,n)=>{let e=await g(t);return t.status>300?{data:null,status:t.status,headers:t.headers,retry:n,error:new y(t.status,e)}:{data:e,error:null,status:t.status,headers:t.headers,retry:n}},w=(t,n)=>(e,{query:r,params:c,body:a,...s}={})=>{c&&Object.entries(c).forEach(([o,E])=>{e=e.replace(`:${o}`,E)});let i=s.headers?.["Content-Type"];if(!i||i==="application/json")try{a=JSON.stringify(a)}catch{}let f=n?.fetcher||globalThis.fetch,d=r?`?${new URLSearchParams(r).toString()}`:"",u=`${t}${e}${d}`,l=a?{"content-type":"application/json",...s.headers}:s.headers,m={...s,method:s.method?.toUpperCase()||"GET",headers:l,body:a},h=()=>f(u,m).then(o=>T(o,h));return h()};export{w as a};
@@ -1,5 +0,0 @@
1
- export declare class EdenFetchError<Status extends number = number, Value = unknown> extends Error {
2
- status: Status;
3
- value: Value;
4
- constructor(status: Status, value: Value);
5
- }
@@ -1,4 +0,0 @@
1
- import type { Elysia } from 'elysia';
2
- import type { EdenFetch } from './types';
3
- export type { EdenFetch } from './types';
4
- export declare const edenFetch: <App extends Elysia<any, any, any, any, any, any, any, any>>(server: string, config?: EdenFetch.Config) => EdenFetch.Create<App>;
@@ -1,44 +0,0 @@
1
- import type { Elysia } from 'elysia';
2
- import type { EdenFetchError } from '../errors';
3
- import type { MapError, IsUnknown, IsNever, Prettify, TreatyToPath } from '../types';
4
- export declare namespace EdenFetch {
5
- type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
6
- _routes: infer Schema extends Record<string, unknown>;
7
- } ? EdenFetch.Fn<TreatyToPath<Schema>> : 'Please install Elysia before using Eden';
8
- interface Config extends RequestInit {
9
- fetcher?: typeof globalThis.fetch;
10
- }
11
- type Fn<Schema extends Record<string, any>> = <Endpoint extends keyof Schema, Method extends Uppercase<Extract<keyof Schema[Endpoint], string>>, Route extends Schema[Endpoint][Lowercase<Method>]>(endpoint: Endpoint, options: Omit<RequestInit, 'body' | 'method' | 'headers'> & ('GET' extends Method ? {
12
- method?: Method;
13
- } : {
14
- method: Method;
15
- }) & (IsNever<keyof Route['params']> extends true ? {
16
- params?: Record<never, string>;
17
- } : {
18
- params: Route['params'];
19
- }) & (IsNever<keyof Route['query']> extends true ? {
20
- query?: Record<never, string>;
21
- } : {
22
- query: Route['query'];
23
- }) & (undefined extends Route['headers'] ? {
24
- headers?: Record<string, string>;
25
- } : {
26
- headers: Route['headers'];
27
- }) & (IsUnknown<Route['body']> extends false ? {
28
- body: Route['body'];
29
- } : {
30
- body?: unknown;
31
- })) => Promise<Prettify<{
32
- data: Awaited<Route['response'][200]>;
33
- error: null;
34
- status: number;
35
- headers: Record<string, unknown>;
36
- retry(): Promise<void>;
37
- } | {
38
- data: null;
39
- error: MapError<Route['response']> extends infer Errors ? IsNever<Errors> extends true ? EdenFetchError<number, string> : Errors : EdenFetchError<number, string>;
40
- status: number;
41
- headers: Record<string, unknown>;
42
- retry(): Promise<void>;
43
- }>>;
44
- }
@@ -1,48 +0,0 @@
1
- import { Elysia } from 'elysia';
2
- import { T as TreatyToPath, a as IsNever, I as IsUnknown, P as Prettify, M as MapError, E as EdenFetchError } from './types-C41kuZ-K.mjs';
3
-
4
- declare namespace EdenFetch {
5
- type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
6
- _routes: infer Schema extends Record<string, unknown>;
7
- } ? EdenFetch.Fn<TreatyToPath<Schema>> : 'Please install Elysia before using Eden';
8
- interface Config extends RequestInit {
9
- fetcher?: typeof globalThis.fetch;
10
- }
11
- type Fn<Schema extends Record<string, any>> = <Endpoint extends keyof Schema, Method extends Uppercase<Extract<keyof Schema[Endpoint], string>>, Route extends Schema[Endpoint][Lowercase<Method>]>(endpoint: Endpoint, options: Omit<RequestInit, 'body' | 'method' | 'headers'> & ('GET' extends Method ? {
12
- method?: Method;
13
- } : {
14
- method: Method;
15
- }) & (IsNever<keyof Route['params']> extends true ? {
16
- params?: Record<never, string>;
17
- } : {
18
- params: Route['params'];
19
- }) & (IsNever<keyof Route['query']> extends true ? {
20
- query?: Record<never, string>;
21
- } : {
22
- query: Route['query'];
23
- }) & (undefined extends Route['headers'] ? {
24
- headers?: Record<string, string>;
25
- } : {
26
- headers: Route['headers'];
27
- }) & (IsUnknown<Route['body']> extends false ? {
28
- body: Route['body'];
29
- } : {
30
- body?: unknown;
31
- })) => Promise<Prettify<{
32
- data: Awaited<Route['response'][200]>;
33
- error: null;
34
- status: number;
35
- headers: Record<string, unknown>;
36
- retry(): Promise<void>;
37
- } | {
38
- data: null;
39
- error: MapError<Route['response']> extends infer Errors ? IsNever<Errors> extends true ? EdenFetchError<number, string> : Errors : EdenFetchError<number, string>;
40
- status: number;
41
- headers: Record<string, unknown>;
42
- retry(): Promise<void>;
43
- }>>;
44
- }
45
-
46
- declare const edenFetch: <App extends Elysia<any, any, any, any, any, any, any, any>>(server: string, config?: EdenFetch.Config) => EdenFetch.Create<App>;
47
-
48
- export { EdenFetch, edenFetch };
@@ -1,48 +0,0 @@
1
- import { Elysia } from 'elysia';
2
- import { T as TreatyToPath, a as IsNever, I as IsUnknown, P as Prettify, M as MapError, E as EdenFetchError } from './types-C41kuZ-K.js';
3
-
4
- declare namespace EdenFetch {
5
- type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
6
- _routes: infer Schema extends Record<string, unknown>;
7
- } ? EdenFetch.Fn<TreatyToPath<Schema>> : 'Please install Elysia before using Eden';
8
- interface Config extends RequestInit {
9
- fetcher?: typeof globalThis.fetch;
10
- }
11
- type Fn<Schema extends Record<string, any>> = <Endpoint extends keyof Schema, Method extends Uppercase<Extract<keyof Schema[Endpoint], string>>, Route extends Schema[Endpoint][Lowercase<Method>]>(endpoint: Endpoint, options: Omit<RequestInit, 'body' | 'method' | 'headers'> & ('GET' extends Method ? {
12
- method?: Method;
13
- } : {
14
- method: Method;
15
- }) & (IsNever<keyof Route['params']> extends true ? {
16
- params?: Record<never, string>;
17
- } : {
18
- params: Route['params'];
19
- }) & (IsNever<keyof Route['query']> extends true ? {
20
- query?: Record<never, string>;
21
- } : {
22
- query: Route['query'];
23
- }) & (undefined extends Route['headers'] ? {
24
- headers?: Record<string, string>;
25
- } : {
26
- headers: Route['headers'];
27
- }) & (IsUnknown<Route['body']> extends false ? {
28
- body: Route['body'];
29
- } : {
30
- body?: unknown;
31
- })) => Promise<Prettify<{
32
- data: Awaited<Route['response'][200]>;
33
- error: null;
34
- status: number;
35
- headers: Record<string, unknown>;
36
- retry(): Promise<void>;
37
- } | {
38
- data: null;
39
- error: MapError<Route['response']> extends infer Errors ? IsNever<Errors> extends true ? EdenFetchError<number, string> : Errors : EdenFetchError<number, string>;
40
- status: number;
41
- headers: Record<string, unknown>;
42
- retry(): Promise<void>;
43
- }>>;
44
- }
45
-
46
- declare const edenFetch: <App extends Elysia<any, any, any, any, any, any, any, any>>(server: string, config?: EdenFetch.Config) => EdenFetch.Create<App>;
47
-
48
- export { EdenFetch, edenFetch };
@@ -1 +0,0 @@
1
- "use strict";var Eden=(()=>{var d=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},F=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of E(e))!N.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(n=T(e,s))||n.enumerable});return t};var j=t=>F(d({},"__esModule",{value:!0}),t);var V={};b(V,{edenFetch:()=>R});var o=class extends Error{constructor(r,n){super(n+"");this.status=r;this.value=n}};var w=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,A=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,C=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,D=t=>t.trim().length!==0&&!Number.isNaN(Number(t)),f=t=>{if(typeof t!="string")return null;let e=t.replace(/"/g,"");if(w.test(e)||A.test(e)||C.test(e)){let r=new Date(e);if(!Number.isNaN(r.getTime()))return r}return null},M=t=>{let e=t.charCodeAt(0),r=t.charCodeAt(t.length-1);return e===123&&r===125||e===91&&r===93},O=t=>JSON.parse(t,(e,r)=>{let n=f(r);return n||r}),h=t=>{if(!t)return t;if(D(t))return+t;if(t==="true")return!0;if(t==="false")return!1;let e=f(t);if(e)return e;if(M(t))try{return O(t)}catch{}return t};var $=async t=>{switch(t.headers.get("Content-Type")?.split(";")[0]){case"application/json":return t.json();case"application/octet-stream":return t.arrayBuffer();case"multipart/form-data":{let r=await t.formData(),n={};return r.forEach((s,a)=>{n[a]=s}),n}}return t.text().then(h)},J=async(t,e)=>{let r=await $(t);return t.status>300?{data:null,status:t.status,headers:t.headers,retry:e,error:new o(t.status,r)}:{data:r,error:null,status:t.status,headers:t.headers,retry:e}},R=(t,e)=>(r,{query:n,params:s,body:a,...c}={})=>{s&&Object.entries(s).forEach(([i,x])=>{r=r.replace(`:${i}`,x)});let u=c.headers?.["Content-Type"];if(!u||u==="application/json")try{a=JSON.stringify(a)}catch{}let y=e?.fetcher||globalThis.fetch,g=n?`?${new URLSearchParams(n).toString()}`:"",l=`${t}${r}${g}`,m=a?{"content-type":"application/json",...c.headers}:c.headers,S={...c,method:c.method?.toUpperCase()||"GET",headers:m,body:a},p=()=>y(l,S).then(i=>J(i,p));return p()};return j(V);})();
@@ -1 +0,0 @@
1
- "use strict";var d=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},F=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of E(e))!N.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(n=T(e,s))||n.enumerable});return t};var j=t=>F(d({},"__esModule",{value:!0}),t);var V={};b(V,{edenFetch:()=>R});module.exports=j(V);var o=class extends Error{constructor(r,n){super(n+"");this.status=r;this.value=n}};var w=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,A=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,C=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,D=t=>t.trim().length!==0&&!Number.isNaN(Number(t)),f=t=>{if(typeof t!="string")return null;let e=t.replace(/"/g,"");if(w.test(e)||A.test(e)||C.test(e)){let r=new Date(e);if(!Number.isNaN(r.getTime()))return r}return null},M=t=>{let e=t.charCodeAt(0),r=t.charCodeAt(t.length-1);return e===123&&r===125||e===91&&r===93},O=t=>JSON.parse(t,(e,r)=>{let n=f(r);return n||r}),h=t=>{if(!t)return t;if(D(t))return+t;if(t==="true")return!0;if(t==="false")return!1;let e=f(t);if(e)return e;if(M(t))try{return O(t)}catch{}return t};var $=async t=>{switch(t.headers.get("Content-Type")?.split(";")[0]){case"application/json":return t.json();case"application/octet-stream":return t.arrayBuffer();case"multipart/form-data":{let r=await t.formData(),n={};return r.forEach((s,a)=>{n[a]=s}),n}}return t.text().then(h)},J=async(t,e)=>{let r=await $(t);return t.status>300?{data:null,status:t.status,headers:t.headers,retry:e,error:new o(t.status,r)}:{data:r,error:null,status:t.status,headers:t.headers,retry:e}},R=(t,e)=>(r,{query:n,params:s,body:a,...c}={})=>{s&&Object.entries(s).forEach(([i,x])=>{r=r.replace(`:${i}`,x)});let u=c.headers?.["Content-Type"];if(!u||u==="application/json")try{a=JSON.stringify(a)}catch{}let y=e?.fetcher||globalThis.fetch,g=n?`?${new URLSearchParams(n).toString()}`:"",l=`${t}${r}${g}`,m=a?{"content-type":"application/json",...c.headers}:c.headers,S={...c,method:c.method?.toUpperCase()||"GET",headers:m,body:a},p=()=>y(l,S).then(i=>J(i,p));return p()};0&&(module.exports={edenFetch});
@@ -1 +0,0 @@
1
- import{a}from"./chunk-YAG46HFR.mjs";import"./chunk-XYW4OUFN.mjs";export{a as edenFetch};
@@ -1,5 +0,0 @@
1
- export { Treaty, treaty } from './treaty2.mjs';
2
- export { edenTreaty } from './treaty.mjs';
3
- export { edenFetch } from './fetch.mjs';
4
- import 'elysia';
5
- import './types-C41kuZ-K.mjs';
@@ -1,5 +0,0 @@
1
- export { Treaty, treaty } from './treaty2.js';
2
- export { edenTreaty } from './treaty.js';
3
- export { edenFetch } from './fetch.js';
4
- import 'elysia';
5
- import './types-C41kuZ-K.js';
@@ -1 +0,0 @@
1
- "use strict";var Eden=(()=>{var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of re(t))!se.call(e,s)&&s!==n&&P(e,s,{get:()=>t[s],enumerable:!(r=ne(t,s))||r.enumerable});return e};var oe=e=>ie(P({},"__esModule",{value:!0}),e);var be={};ae(be,{edenFetch:()=>te,edenTreaty:()=>ee,treaty:()=>z});var T=class extends Error{constructor(n,r){super(r+"");this.status=n;this.value=r}};var ce=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,fe=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,de=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,ye=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),_=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(ce.test(t)||fe.test(t)||de.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},ue=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},pe=e=>JSON.parse(e,(t,n)=>{let r=_(n);return r||n}),L=e=>{if(!e)return e;if(ye(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=_(e);if(t)return t;if(ue(e))try{return pe(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:L(t)};var I=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let i=D(s);n({...s,data:i})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}};var le=["get","post","put","delete","patch","options","head","connect","subscribe"],Z=["localhost","127.0.0.1","0.0.0.0"],U=typeof FileList>"u",G=e=>U?e instanceof Blob:e instanceof FileList||e instanceof File,he=e=>{if(!e)return!1;for(let t in e)if(G(e[t])||Array.isArray(e[t])&&e[t].find(G))return!0;return!1},J=e=>U?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),j=(e,t,n={},r={})=>{if(Array.isArray(e)){for(let s of e)if(!Array.isArray(s))r=j(s,t,n,r);else{let i=s[0];if(typeof i=="string")r[i.toLowerCase()]=s[1];else for(let[o,y]of i)r[o.toLowerCase()]=y}return r}if(!e)return r;switch(typeof e){case"function":if(e instanceof Headers)return j(e,t,n,r);let s=e(t,n);return s?j(s,t,n,r):r;case"object":if(e instanceof Headers)return e.forEach((i,o)=>{r[o.toLowerCase()]=i}),r;for(let[i,o]of Object.entries(e))r[i.toLowerCase()]=o;return r;default:return r}};async function*ge(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder;try{for(;;){let{done:s,value:i}=await n.read();if(s)break;let o=r.decode(i);yield L(o)}}finally{n.releaseLock()}}var K=(e,t,n=[],r)=>new Proxy(()=>{},{get(s,i){return K(e,t,i==="index"?n:[...n,i],r)},apply(s,i,[o,y]){if(!o||y||typeof o=="object"&&Object.keys(o).length!==1||le.includes(n.at(-1))){let M=[...n],v=M.pop(),E="/"+M.join("/"),{fetcher:F=fetch,headers:R,onRequest:l,onResponse:g,fetch:O}=t,x=v==="get"||v==="head"||v==="subscribe";R=j(R,E,y);let N=x?o?.query:y?.query,b="";if(N){let a=(A,w)=>{b+=(b?"&":"?")+`${encodeURIComponent(A)}=${encodeURIComponent(w)}`};for(let[A,w]of Object.entries(N)){if(Array.isArray(w)){for(let c of w)a(A,c);continue}if(typeof w=="object"){a(A,JSON.stringify(w));continue}a(A,`${w}`)}}if(v==="subscribe"){let a=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||Z.find(A=>e.includes(A))?"ws://":"wss://")+E+b;return new I(a)}return(async()=>{let a={method:v?.toUpperCase(),body:o,...O,headers:R};a.headers={...R,...j(x?o?.headers:y?.headers,E,a)};let A=x&&typeof o=="object"?o.fetch:y?.fetch;if(a={...a,...A},x&&delete a.body,l){Array.isArray(l)||(l=[l]);for(let d of l){let f=await d(E,a);typeof f=="object"&&(a={...a,...f,headers:{...a.headers,...j(f.headers,E,a)}})}}if(x&&delete a.body,he(o)){let d=new FormData;for(let[f,p]of Object.entries(a.body)){if(U){d.append(f,p);continue}if(p instanceof File){d.append(f,await J(p));continue}if(p instanceof FileList){for(let m=0;m<p.length;m++)d.append(f,await J(p[m]));continue}if(Array.isArray(p)){for(let m=0;m<p.length;m++){let S=p[m];d.append(f,S instanceof File?await J(S):S)}continue}d.append(f,p)}a.body=d}else typeof o=="object"?(a.headers["content-type"]="application/json",a.body=JSON.stringify(o)):o!=null&&(a.headers["content-type"]="text/plain");if(x&&delete a.body,l){Array.isArray(l)||(l=[l]);for(let d of l){let f=await d(E,a);typeof f=="object"&&(a={...a,...f,headers:{...a.headers,...j(f.headers,E,a)}})}}let w=e+E+b,c=await(r?.handle(new Request(w,a))??F(w,a)),h=null,u=null;if(g){Array.isArray(g)||(g=[g]);for(let d of g)try{let f=await d(c.clone());if(f!=null){h=f;break}}catch(f){f instanceof T?u=f:u=new T(422,f);break}}if(h!==null)return{data:h,error:u,response:c,status:c.status,headers:c.headers};switch(c.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":h=ge(c);break;case"application/json":h=await c.json();break;case"application/octet-stream":h=await c.arrayBuffer();break;case"multipart/form-data":let d=await c.formData();h={},d.forEach((f,p)=>{h[p]=f});break;default:h=await c.text().then(L)}return(c.status>=300||c.status<200)&&(u=new T(c.status,h),h=null),{data:h,error:u,response:c,status:c.status,headers:c.headers}})()}return typeof o=="object"?K(e,t,[...n,Object.values(o)[0]],r):K(e,t,n)}}),z=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(Z.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),K(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),K("http://e.ly",t,[],e));var Q=(e,t,n)=>{if(e.endsWith("/")||(e+="/"),t==="index"&&(t=""),!n||!Object.keys(n).length)return`${e}${t}`;let r="";for(let[s,i]of Object.entries(n))r+=`${s}=${i}&`;return`${e}${t}?${r.slice(0,-1)}`};var V=typeof FileList>"u",X=e=>V?e instanceof Blob:e instanceof FileList||e instanceof File,me=e=>{if(!e)return!1;for(let t in e){if(X(e[t]))return!0;if(Array.isArray(e[t])&&e[t].find(n=>X(n)))return!0}return!1},B=e=>V?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),H=class{ws;url;constructor(t){this.ws=new WebSocket(t),this.url=t}send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let i=D(s);n({...s,data:i})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}},Y=(e,t="",n)=>new Proxy(()=>{},{get(r,s,i){return Y(e,`${t}/${s.toString()}`,n)},apply(r,s,[i,o={}]=[{},{}]){let y=i!==void 0&&(typeof i!="object"||Array.isArray(i))?i:void 0,{$query:M,$fetch:v,$headers:E,$transform:F,getRaw:R,...l}=i??{};y??=l;let g=t.lastIndexOf("/"),O=t.slice(g+1).toUpperCase(),x=Q(e,g===-1?"/":t.slice(0,g),Object.assign(o.query??{},M)),N=n.fetcher??fetch,b=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,a=F?Array.isArray(F)?F:[F]:void 0;return a&&(b?b=a.concat(b):b=a),O==="SUBSCRIBE"?new H(x.replace(/^([^]+):\/\//,x.startsWith("https://")?"wss://":"ws://")):(async w=>{let c,h={...n.$fetch?.headers,...v?.headers,...o.headers,...E};if(O!=="GET"&&O!=="HEAD"){c=Object.keys(y).length||Array.isArray(y)?y:void 0;let m=c&&(typeof c=="object"||Array.isArray(y));if(m&&me(c)){let $=new FormData;for(let[C,k]of Object.entries(c))if(V)$.append(C,k);else if(k instanceof File)$.append(C,await B(k));else if(k instanceof FileList)for(let W=0;W<k.length;W++)$.append(C,await B(k[W]));else if(Array.isArray(k))for(let W=0;W<k.length;W++){let q=k[W];$.append(C,q instanceof File?await B(q):q)}else $.append(C,k);c=$}else c!=null&&(h["content-type"]=m?"application/json":"text/plain",c=m?JSON.stringify(c):y)}let u=await N(x,{method:O,body:c,...n.$fetch,...o.fetch,...v,headers:h}),d;if(w.getRaw)return u;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await u.json();break;default:d=await u.text().then(L)}let f=u.status>=300||u.status<200?new T(u.status,d):null,p={data:d,error:f,response:u,status:u.status,headers:u.headers};if(b)for(let m of b){let S=m(p);S instanceof Promise&&(S=await S),S!=null&&(p=S)}return p})({getRaw:R})}}),ee=(e,t={fetcher:fetch})=>new Proxy({},{get(n,r){return Y(e,r,t)}});var Ee=async e=>{switch(e.headers.get("Content-Type")?.split(";")[0]){case"application/json":return e.json();case"application/octet-stream":return e.arrayBuffer();case"multipart/form-data":{let n=await e.formData(),r={};return n.forEach((s,i)=>{r[i]=s}),r}}return e.text().then(L)},we=async(e,t)=>{let n=await Ee(e);return e.status>300?{data:null,status:e.status,headers:e.headers,retry:t,error:new T(e.status,n)}:{data:n,error:null,status:e.status,headers:e.headers,retry:t}},te=(e,t)=>(n,{query:r,params:s,body:i,...o}={})=>{s&&Object.entries(s).forEach(([g,O])=>{n=n.replace(`:${g}`,O)});let y=o.headers?.["Content-Type"];if(!y||y==="application/json")try{i=JSON.stringify(i)}catch{}let M=t?.fetcher||globalThis.fetch,v=r?`?${new URLSearchParams(r).toString()}`:"",E=`${e}${n}${v}`,F=i?{"content-type":"application/json",...o.headers}:o.headers,R={...o,method:o.method?.toUpperCase()||"GET",headers:F,body:i},l=()=>M(E,R).then(g=>we(g,l));return l()};return oe(be);})();
@@ -1 +0,0 @@
1
- "use strict";var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of re(t))!se.call(e,s)&&s!==n&&P(e,s,{get:()=>t[s],enumerable:!(r=ne(t,s))||r.enumerable});return e};var oe=e=>ie(P({},"__esModule",{value:!0}),e);var be={};ae(be,{edenFetch:()=>te,edenTreaty:()=>ee,treaty:()=>z});module.exports=oe(be);var T=class extends Error{constructor(n,r){super(r+"");this.status=n;this.value=r}};var ce=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,fe=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,de=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,ye=e=>e.trim().length!==0&&!Number.isNaN(Number(e)),_=e=>{if(typeof e!="string")return null;let t=e.replace(/"/g,"");if(ce.test(t)||fe.test(t)||de.test(t)){let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null},ue=e=>{let t=e.charCodeAt(0),n=e.charCodeAt(e.length-1);return t===123&&n===125||t===91&&n===93},pe=e=>JSON.parse(e,(t,n)=>{let r=_(n);return r||n}),L=e=>{if(!e)return e;if(ye(e))return+e;if(e==="true")return!0;if(e==="false")return!1;let t=_(e);if(t)return t;if(ue(e))try{return pe(e)}catch{}return e},D=e=>{let t=e.data.toString();return t==="null"?null:L(t)};var I=class{constructor(t){this.url=t;this.ws=new WebSocket(t)}ws;send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let i=D(s);n({...s,data:i})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}};var le=["get","post","put","delete","patch","options","head","connect","subscribe"],Z=["localhost","127.0.0.1","0.0.0.0"],U=typeof FileList>"u",G=e=>U?e instanceof Blob:e instanceof FileList||e instanceof File,he=e=>{if(!e)return!1;for(let t in e)if(G(e[t])||Array.isArray(e[t])&&e[t].find(G))return!0;return!1},J=e=>U?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),j=(e,t,n={},r={})=>{if(Array.isArray(e)){for(let s of e)if(!Array.isArray(s))r=j(s,t,n,r);else{let i=s[0];if(typeof i=="string")r[i.toLowerCase()]=s[1];else for(let[o,y]of i)r[o.toLowerCase()]=y}return r}if(!e)return r;switch(typeof e){case"function":if(e instanceof Headers)return j(e,t,n,r);let s=e(t,n);return s?j(s,t,n,r):r;case"object":if(e instanceof Headers)return e.forEach((i,o)=>{r[o.toLowerCase()]=i}),r;for(let[i,o]of Object.entries(e))r[i.toLowerCase()]=o;return r;default:return r}};async function*ge(e){let t=e.body;if(!t)return;let n=t.getReader(),r=new TextDecoder;try{for(;;){let{done:s,value:i}=await n.read();if(s)break;let o=r.decode(i);yield L(o)}}finally{n.releaseLock()}}var K=(e,t,n=[],r)=>new Proxy(()=>{},{get(s,i){return K(e,t,i==="index"?n:[...n,i],r)},apply(s,i,[o,y]){if(!o||y||typeof o=="object"&&Object.keys(o).length!==1||le.includes(n.at(-1))){let M=[...n],v=M.pop(),E="/"+M.join("/"),{fetcher:F=fetch,headers:R,onRequest:l,onResponse:g,fetch:O}=t,x=v==="get"||v==="head"||v==="subscribe";R=j(R,E,y);let N=x?o?.query:y?.query,b="";if(N){let a=(A,w)=>{b+=(b?"&":"?")+`${encodeURIComponent(A)}=${encodeURIComponent(w)}`};for(let[A,w]of Object.entries(N)){if(Array.isArray(w)){for(let c of w)a(A,c);continue}if(typeof w=="object"){a(A,JSON.stringify(w));continue}a(A,`${w}`)}}if(v==="subscribe"){let a=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||Z.find(A=>e.includes(A))?"ws://":"wss://")+E+b;return new I(a)}return(async()=>{let a={method:v?.toUpperCase(),body:o,...O,headers:R};a.headers={...R,...j(x?o?.headers:y?.headers,E,a)};let A=x&&typeof o=="object"?o.fetch:y?.fetch;if(a={...a,...A},x&&delete a.body,l){Array.isArray(l)||(l=[l]);for(let d of l){let f=await d(E,a);typeof f=="object"&&(a={...a,...f,headers:{...a.headers,...j(f.headers,E,a)}})}}if(x&&delete a.body,he(o)){let d=new FormData;for(let[f,p]of Object.entries(a.body)){if(U){d.append(f,p);continue}if(p instanceof File){d.append(f,await J(p));continue}if(p instanceof FileList){for(let m=0;m<p.length;m++)d.append(f,await J(p[m]));continue}if(Array.isArray(p)){for(let m=0;m<p.length;m++){let S=p[m];d.append(f,S instanceof File?await J(S):S)}continue}d.append(f,p)}a.body=d}else typeof o=="object"?(a.headers["content-type"]="application/json",a.body=JSON.stringify(o)):o!=null&&(a.headers["content-type"]="text/plain");if(x&&delete a.body,l){Array.isArray(l)||(l=[l]);for(let d of l){let f=await d(E,a);typeof f=="object"&&(a={...a,...f,headers:{...a.headers,...j(f.headers,E,a)}})}}let w=e+E+b,c=await(r?.handle(new Request(w,a))??F(w,a)),h=null,u=null;if(g){Array.isArray(g)||(g=[g]);for(let d of g)try{let f=await d(c.clone());if(f!=null){h=f;break}}catch(f){f instanceof T?u=f:u=new T(422,f);break}}if(h!==null)return{data:h,error:u,response:c,status:c.status,headers:c.headers};switch(c.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":h=ge(c);break;case"application/json":h=await c.json();break;case"application/octet-stream":h=await c.arrayBuffer();break;case"multipart/form-data":let d=await c.formData();h={},d.forEach((f,p)=>{h[p]=f});break;default:h=await c.text().then(L)}return(c.status>=300||c.status<200)&&(u=new T(c.status,h),h=null),{data:h,error:u,response:c,status:c.status,headers:c.headers}})()}return typeof o=="object"?K(e,t,[...n,Object.values(o)[0]],r):K(e,t,n)}}),z=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(Z.find(n=>e.includes(n))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),K(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),K("http://e.ly",t,[],e));var Q=(e,t,n)=>{if(e.endsWith("/")||(e+="/"),t==="index"&&(t=""),!n||!Object.keys(n).length)return`${e}${t}`;let r="";for(let[s,i]of Object.entries(n))r+=`${s}=${i}&`;return`${e}${t}?${r.slice(0,-1)}`};var V=typeof FileList>"u",X=e=>V?e instanceof Blob:e instanceof FileList||e instanceof File,me=e=>{if(!e)return!1;for(let t in e){if(X(e[t]))return!0;if(Array.isArray(e[t])&&e[t].find(n=>X(n)))return!0}return!1},B=e=>V?e:new Promise(t=>{let n=new FileReader;n.onload=()=>{let r=new File([n.result],e.name,{lastModified:e.lastModified,type:e.type});t(r)},n.readAsArrayBuffer(e)}),H=class{ws;url;constructor(t){this.ws=new WebSocket(t),this.url=t}send(t){return Array.isArray(t)?(t.forEach(n=>this.send(n)),this):(this.ws.send(typeof t=="object"?JSON.stringify(t):t.toString()),this)}on(t,n,r){return this.addEventListener(t,n,r)}off(t,n,r){return this.ws.removeEventListener(t,n,r),this}subscribe(t,n){return this.addEventListener("message",t,n)}addEventListener(t,n,r){return this.ws.addEventListener(t,s=>{if(t==="message"){let i=D(s);n({...s,data:i})}else n(s)},r),this}removeEventListener(t,n,r){return this.off(t,n,r),this}close(){return this.ws.close(),this}},Y=(e,t="",n)=>new Proxy(()=>{},{get(r,s,i){return Y(e,`${t}/${s.toString()}`,n)},apply(r,s,[i,o={}]=[{},{}]){let y=i!==void 0&&(typeof i!="object"||Array.isArray(i))?i:void 0,{$query:M,$fetch:v,$headers:E,$transform:F,getRaw:R,...l}=i??{};y??=l;let g=t.lastIndexOf("/"),O=t.slice(g+1).toUpperCase(),x=Q(e,g===-1?"/":t.slice(0,g),Object.assign(o.query??{},M)),N=n.fetcher??fetch,b=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,a=F?Array.isArray(F)?F:[F]:void 0;return a&&(b?b=a.concat(b):b=a),O==="SUBSCRIBE"?new H(x.replace(/^([^]+):\/\//,x.startsWith("https://")?"wss://":"ws://")):(async w=>{let c,h={...n.$fetch?.headers,...v?.headers,...o.headers,...E};if(O!=="GET"&&O!=="HEAD"){c=Object.keys(y).length||Array.isArray(y)?y:void 0;let m=c&&(typeof c=="object"||Array.isArray(y));if(m&&me(c)){let $=new FormData;for(let[C,k]of Object.entries(c))if(V)$.append(C,k);else if(k instanceof File)$.append(C,await B(k));else if(k instanceof FileList)for(let W=0;W<k.length;W++)$.append(C,await B(k[W]));else if(Array.isArray(k))for(let W=0;W<k.length;W++){let q=k[W];$.append(C,q instanceof File?await B(q):q)}else $.append(C,k);c=$}else c!=null&&(h["content-type"]=m?"application/json":"text/plain",c=m?JSON.stringify(c):y)}let u=await N(x,{method:O,body:c,...n.$fetch,...o.fetch,...v,headers:h}),d;if(w.getRaw)return u;switch(u.headers.get("Content-Type")?.split(";")[0]){case"application/json":d=await u.json();break;default:d=await u.text().then(L)}let f=u.status>=300||u.status<200?new T(u.status,d):null,p={data:d,error:f,response:u,status:u.status,headers:u.headers};if(b)for(let m of b){let S=m(p);S instanceof Promise&&(S=await S),S!=null&&(p=S)}return p})({getRaw:R})}}),ee=(e,t={fetcher:fetch})=>new Proxy({},{get(n,r){return Y(e,r,t)}});var Ee=async e=>{switch(e.headers.get("Content-Type")?.split(";")[0]){case"application/json":return e.json();case"application/octet-stream":return e.arrayBuffer();case"multipart/form-data":{let n=await e.formData(),r={};return n.forEach((s,i)=>{r[i]=s}),r}}return e.text().then(L)},we=async(e,t)=>{let n=await Ee(e);return e.status>300?{data:null,status:e.status,headers:e.headers,retry:t,error:new T(e.status,n)}:{data:n,error:null,status:e.status,headers:e.headers,retry:t}},te=(e,t)=>(n,{query:r,params:s,body:i,...o}={})=>{s&&Object.entries(s).forEach(([g,O])=>{n=n.replace(`:${g}`,O)});let y=o.headers?.["Content-Type"];if(!y||y==="application/json")try{i=JSON.stringify(i)}catch{}let M=t?.fetcher||globalThis.fetch,v=r?`?${new URLSearchParams(r).toString()}`:"",E=`${e}${n}${v}`,F=i?{"content-type":"application/json",...o.headers}:o.headers,R={...o,method:o.method?.toUpperCase()||"GET",headers:F,body:i},l=()=>M(E,R).then(g=>we(g,l));return l()};0&&(module.exports={edenFetch,edenTreaty,treaty});
@@ -1 +0,0 @@
1
- import{b as r}from"./chunk-2IHGLN7W.mjs";import{b as e}from"./chunk-7WO4HTSU.mjs";import{a as t}from"./chunk-YAG46HFR.mjs";import"./chunk-XYW4OUFN.mjs";export{t as edenFetch,r as edenTreaty,e as treaty};
@@ -1,17 +0,0 @@
1
- import type { Elysia, InputSchema } from 'elysia';
2
- import type { EdenTreaty } from './types';
3
- export type { EdenTreaty } from './types';
4
- type MaybeArray<T> = T | T[];
5
- export declare class EdenWS<Schema extends InputSchema<any> = InputSchema> {
6
- ws: WebSocket;
7
- url: string;
8
- constructor(url: string);
9
- send(data: MaybeArray<Schema['body']>): this;
10
- on<K extends keyof WebSocketEventMap>(type: K, listener: (event: EdenTreaty.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
11
- off<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
12
- subscribe(onMessage: (event: EdenTreaty.WSEvent<'message', Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
13
- addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (event: EdenTreaty.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
14
- removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
15
- close(): this;
16
- }
17
- export declare const edenTreaty: <App extends Elysia<any, any, any, any, any, any, any, any>>(domain: string, config?: EdenTreaty.Config) => EdenTreaty.Create<App>;
@@ -1,99 +0,0 @@
1
- import { Elysia } from 'elysia';
2
- import type { EdenWS } from './index';
3
- import type { IsUnknown, IsNever, MapError, Prettify } from '../types';
4
- import type { EdenFetchError } from '../errors';
5
- type Files = File | FileList;
6
- type Replace<RecordType, TargetType, GenericType> = {
7
- [K in keyof RecordType]: RecordType[K] extends TargetType ? GenericType : RecordType[K];
8
- };
9
- type MaybeArray<T> = T | T[];
10
- export declare namespace EdenTreaty {
11
- export type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
12
- _routes: infer Schema extends Record<string, unknown>;
13
- } ? Prettify<Sign<Schema>> : 'Please install Elysia before using Eden';
14
- export type Sign<Route extends Record<string, any>> = {
15
- [K in keyof Route as K extends `:${string}` ? (string & {}) | number | K : K extends '' | '/' ? 'index' : K]: Route[K] extends {
16
- body: infer Body;
17
- headers: infer Headers;
18
- query: infer Query;
19
- params: unknown;
20
- response: infer Response;
21
- } ? K extends 'subscribe' ? undefined extends Route['query'] ? (params?: {
22
- $query?: Record<string, string>;
23
- }) => EdenWS<Route> : (params: {
24
- $query: Route['query'];
25
- }) => EdenWS<Route['subscribe']> : ((params: Prettify<{
26
- $fetch?: RequestInit;
27
- getRaw?: boolean;
28
- $transform?: Transform;
29
- } & (IsUnknown<Body> extends false ? Replace<Body, Blob | Blob[], Files> : {}) & (undefined extends Query ? {
30
- $query?: Record<string, string>;
31
- } : {
32
- $query: Query;
33
- }) & (undefined extends Headers ? {
34
- $headers?: Record<string, unknown>;
35
- } : {
36
- $headers: Headers;
37
- })>) => Promise<({
38
- data: Response extends {
39
- 200: infer ReturnedType;
40
- } ? Awaited<ReturnedType> : unknown;
41
- error: null;
42
- } | {
43
- data: null;
44
- error: Response extends Record<number, unknown> ? MapError<Response> extends infer Errors ? IsNever<Errors> extends true ? EdenFetchError<number, string> : Errors : EdenFetchError<number, string> : EdenFetchError<number, unknown>;
45
- }) & {
46
- status: number;
47
- response: Response;
48
- headers: Record<string, string>;
49
- }>) extends (params: infer Params) => infer Response ? {
50
- $params: undefined;
51
- $headers: undefined;
52
- $query: undefined;
53
- } extends Params ? (params?: Params, options?: {
54
- fetch?: RequestInit;
55
- transform?: EdenTreaty.Transform<Response>;
56
- query?: Params['query'];
57
- headers?: Params['headers'];
58
- }) => Response : (params: Params, options?: {
59
- fetch?: RequestInit;
60
- transform?: EdenTreaty.Transform<Response>;
61
- query?: Params['query'];
62
- headers?: Params['headers'];
63
- }) => Response : never : Prettify<Sign<Route[K]>>;
64
- };
65
- type UnwrapPromise<T> = T extends Promise<infer A> ? A : T;
66
- export type Transform<T = unknown> = MaybeArray<(response: unknown extends T ? {
67
- data: any;
68
- error: any;
69
- response: Response;
70
- status: number;
71
- headers: Headers;
72
- } : UnwrapPromise<T>) => UnwrapPromise<T> | void>;
73
- export interface Config {
74
- /**
75
- * Default options to pass to fetch
76
- */
77
- $fetch?: RequestInit;
78
- fetcher?: typeof fetch;
79
- transform?: Transform;
80
- }
81
- export type DetailedResponse = {
82
- data: any;
83
- error: any;
84
- response: Response;
85
- status: number;
86
- headers: Headers;
87
- };
88
- export interface OnMessage<Data = unknown> extends MessageEvent {
89
- data: Data;
90
- rawData: MessageEvent['data'];
91
- }
92
- export type ExecuteOptions = {
93
- getRaw?: boolean;
94
- };
95
- export type ExecuteReturnType<T extends ExecuteOptions> = T['getRaw'] extends true ? Response : DetailedResponse;
96
- export type WSEvent<K extends keyof WebSocketEventMap, Data = unknown> = K extends 'message' ? OnMessage<Data> : WebSocketEventMap[K];
97
- export {};
98
- }
99
- export {};
@@ -1 +0,0 @@
1
- export declare const composePath: (domain: string, path: string, query: Record<string, string> | undefined) => string;
@@ -1,114 +0,0 @@
1
- import { Elysia, InputSchema } from 'elysia';
2
- import { P as Prettify, I as IsUnknown, M as MapError, a as IsNever, E as EdenFetchError } from './types-C41kuZ-K.mjs';
3
-
4
- type Files = File | FileList;
5
- type Replace<RecordType, TargetType, GenericType> = {
6
- [K in keyof RecordType]: RecordType[K] extends TargetType ? GenericType : RecordType[K];
7
- };
8
- type MaybeArray$1<T> = T | T[];
9
- declare namespace EdenTreaty {
10
- export type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
11
- _routes: infer Schema extends Record<string, unknown>;
12
- } ? Prettify<Sign<Schema>> : 'Please install Elysia before using Eden';
13
- export type Sign<Route extends Record<string, any>> = {
14
- [K in keyof Route as K extends `:${string}` ? (string & {}) | number | K : K extends '' | '/' ? 'index' : K]: Route[K] extends {
15
- body: infer Body;
16
- headers: infer Headers;
17
- query: infer Query;
18
- params: unknown;
19
- response: infer Response;
20
- } ? K extends 'subscribe' ? undefined extends Route['query'] ? (params?: {
21
- $query?: Record<string, string>;
22
- }) => EdenWS<Route> : (params: {
23
- $query: Route['query'];
24
- }) => EdenWS<Route['subscribe']> : ((params: Prettify<{
25
- $fetch?: RequestInit;
26
- getRaw?: boolean;
27
- $transform?: Transform;
28
- } & (IsUnknown<Body> extends false ? Replace<Body, Blob | Blob[], Files> : {}) & (undefined extends Query ? {
29
- $query?: Record<string, string>;
30
- } : {
31
- $query: Query;
32
- }) & (undefined extends Headers ? {
33
- $headers?: Record<string, unknown>;
34
- } : {
35
- $headers: Headers;
36
- })>) => Promise<({
37
- data: Response extends {
38
- 200: infer ReturnedType;
39
- } ? Awaited<ReturnedType> : unknown;
40
- error: null;
41
- } | {
42
- data: null;
43
- error: Response extends Record<number, unknown> ? MapError<Response> extends infer Errors ? IsNever<Errors> extends true ? EdenFetchError<number, string> : Errors : EdenFetchError<number, string> : EdenFetchError<number, unknown>;
44
- }) & {
45
- status: number;
46
- response: Response;
47
- headers: Record<string, string>;
48
- }>) extends (params: infer Params) => infer Response ? {
49
- $params: undefined;
50
- $headers: undefined;
51
- $query: undefined;
52
- } extends Params ? (params?: Params, options?: {
53
- fetch?: RequestInit;
54
- transform?: EdenTreaty.Transform<Response>;
55
- query?: Params['query'];
56
- headers?: Params['headers'];
57
- }) => Response : (params: Params, options?: {
58
- fetch?: RequestInit;
59
- transform?: EdenTreaty.Transform<Response>;
60
- query?: Params['query'];
61
- headers?: Params['headers'];
62
- }) => Response : never : Prettify<Sign<Route[K]>>;
63
- };
64
- type UnwrapPromise<T> = T extends Promise<infer A> ? A : T;
65
- export type Transform<T = unknown> = MaybeArray$1<(response: unknown extends T ? {
66
- data: any;
67
- error: any;
68
- response: Response;
69
- status: number;
70
- headers: Headers;
71
- } : UnwrapPromise<T>) => UnwrapPromise<T> | void>;
72
- export interface Config {
73
- /**
74
- * Default options to pass to fetch
75
- */
76
- $fetch?: RequestInit;
77
- fetcher?: typeof fetch;
78
- transform?: Transform;
79
- }
80
- export type DetailedResponse = {
81
- data: any;
82
- error: any;
83
- response: Response;
84
- status: number;
85
- headers: Headers;
86
- };
87
- export interface OnMessage<Data = unknown> extends MessageEvent {
88
- data: Data;
89
- rawData: MessageEvent['data'];
90
- }
91
- export type ExecuteOptions = {
92
- getRaw?: boolean;
93
- };
94
- export type ExecuteReturnType<T extends ExecuteOptions> = T['getRaw'] extends true ? Response : DetailedResponse;
95
- export type WSEvent<K extends keyof WebSocketEventMap, Data = unknown> = K extends 'message' ? OnMessage<Data> : WebSocketEventMap[K];
96
- export { };
97
- }
98
-
99
- type MaybeArray<T> = T | T[];
100
- declare class EdenWS<Schema extends InputSchema<any> = InputSchema> {
101
- ws: WebSocket;
102
- url: string;
103
- constructor(url: string);
104
- send(data: MaybeArray<Schema['body']>): this;
105
- on<K extends keyof WebSocketEventMap>(type: K, listener: (event: EdenTreaty.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
106
- off<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
107
- subscribe(onMessage: (event: EdenTreaty.WSEvent<'message', Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
108
- addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (event: EdenTreaty.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
109
- removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
110
- close(): this;
111
- }
112
- declare const edenTreaty: <App extends Elysia<any, any, any, any, any, any, any, any>>(domain: string, config?: EdenTreaty.Config) => EdenTreaty.Create<App>;
113
-
114
- export { EdenTreaty, EdenWS, edenTreaty };