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

@elysiajs/eden

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elysiajs/eden - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

dist/chunk-FGCQ7BRI.mjs

14

dist/fetch.d.ts
import { Elysia } from 'elysia';
import { T as TreatyToPath, a as IsNever, I as IsUnknown, P as Prettify, M as MapError, E as EdenFetchError } from './types-BQi-Ff9p.js';
import { T as TreatyToPath, a as IsNever, I as IsUnknown, P as Prettify, M as MapError, E as EdenFetchError } from './types-DNydNaKe.js';
declare namespace EdenFetch {
type Create<App extends Elysia<any, any, any, any, any, any>> = App extends {
type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
_routes: infer Schema extends Record<string, unknown>;

@@ -46,4 +46,12 @@ } ? EdenFetch.Fn<TreatyToPath<Schema>> : 'Please install Elysia before using Eden';

declare const edenFetch: <App extends Elysia<any, any, any, any, any, any>>(server: string, config?: EdenFetch.Config) => EdenFetch.Create<App>;
declare const edenFetch: <App extends Elysia<any, any, any, any, any, any, {
decorator: {};
store: {};
derive: {};
resolve: {};
}, {
schema: {};
macro: {};
}>>(server: string, config?: EdenFetch.Config) => EdenFetch.Create<App>;
export { EdenFetch, edenFetch };
import type { Elysia } from 'elysia';
import type { EdenFetch } from './types';
export type { EdenFetch } from './types';
export declare const edenFetch: <App extends Elysia<any, any, any, any, any, any>>(server: string, config?: EdenFetch.Config) => EdenFetch.Create<App>;
export declare const edenFetch: <App extends Elysia<any, any, any, any, any, any, {
decorator: {};
store: {};
derive: {};
resolve: {};
}, {
schema: {};
macro: {};
}>>(server: string, config?: EdenFetch.Config) => EdenFetch.Create<App>;

@@ -5,3 +5,3 @@ import type { Elysia } from 'elysia';

export declare namespace EdenFetch {
type Create<App extends Elysia<any, any, any, any, any, any>> = App extends {
type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
_routes: infer Schema extends Record<string, unknown>;

@@ -8,0 +8,0 @@ } ? EdenFetch.Fn<TreatyToPath<Schema>> : 'Please install Elysia before using Eden';

@@ -0,6 +1,19 @@

import { InputSchema, Elysia } from 'elysia';
import { P as Prettify } from './types-DNydNaKe.js';
export { edenTreaty } from './treaty.js';
import { Elysia } from 'elysia';
import { P as Prettify } from './types-BQi-Ff9p.js';
export { edenFetch } from './fetch.js';
declare class EdenWS<in out Schema extends InputSchema<any> = {}> {
url: string;
ws: WebSocket;
constructor(url: string);
send(data: Schema['body'] | Schema['body'][]): this;
on<K extends keyof WebSocketEventMap>(type: K, listener: (event: Treaty.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
off<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
subscribe(onMessage: (event: Treaty.WSEvent<'message', Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (event: Treaty.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
close(): this;
}
/// <reference lib="dom" />

@@ -14,13 +27,18 @@

type MaybePromise<T> = T | Promise<T>;
declare namespace EdenTreaty2 {
declare namespace Treaty {
interface TreatyParam {
fetch?: RequestInit;
}
export type Create<App extends Elysia<any, any, any, any, any, any>> = App extends {
export type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
_routes: infer Schema extends Record<string, any>;
} ? Prettify<Sign<Schema>> : 'Please install Elysia before using Eden';
export type Sign<in out Route extends Record<string, any>> = {
[K in keyof Route as K extends '' ? 'index' : K extends `:${string}` ? never : K]: Route[K] extends {
[K in keyof Route as K extends '/' | '' ? 'index' : K extends `:${string}` ? never : K]: K extends 'subscribe' ? undefined extends Route['subscribe']['query'] ? (params?: {
query?: Record<string, string>;
}) => EdenWS<Route['subscribe']> : (params: {
query: Route['subscribe']['query'];
}) => EdenWS<Route['subscribe']> : Route[K] extends {
body: infer Body;
headers: infer Headers;
params: any;
query: infer Query;

@@ -36,5 +54,3 @@ response: infer Response extends Record<number, unknown>;

query: Query;
}) extends infer Param ? {} extends Param ? undefined extends Body ? (body?: Body, options?: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : (body: Body extends Record<string, unknown> ? ReplaceBlobWithFiles<Body> : Body, options?: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : (body: Body extends Record<string, unknown> ? ReplaceBlobWithFiles<Body> : Body, options: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : never : keyof Route[K] extends `:${infer Param}` ? (params: {
[param in Param]: string;
}) => Prettify<Prettify<Sign<Route[K]>> & Sign<Route[K][`:${Param}`]>> : Prettify<Sign<Route[K]>>;
}) extends infer Param ? {} extends Param ? undefined extends Body ? (body?: Body, options?: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : (body: Body extends Record<string, unknown> ? ReplaceBlobWithFiles<Body> : Body, options?: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : (body: Body extends Record<string, unknown> ? ReplaceBlobWithFiles<Body> : Body, options: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : never : keyof Route[K] extends `:${infer Param}` ? (params: Record<Param, string>) => Prettify<Prettify<Sign<Route[K]>> & Sign<Route[K][`:${Param}`]>> : Prettify<Sign<Route[K]>>;
};

@@ -70,4 +86,12 @@ export interface Config extends Omit<RequestInit, 'headers'> {

declare const treaty: <const App extends Elysia<any, any, any, any, any, any>>(domain: string | App, config?: EdenTreaty2.Config) => EdenTreaty2.Create<App>;
declare const treaty: <const App extends Elysia<any, any, any, any, any, any, {
decorator: {};
store: {};
derive: {};
resolve: {};
}, {
schema: {};
macro: {};
}>>(domain: string | App, config?: Treaty.Config) => Treaty.Create<App>;
export { treaty };

@@ -1,1 +0,1 @@

"use strict";var Eden=(()=>{var C=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(t,e)=>{for(var n in e)C(t,n,{get:e[n],enumerable:!0})},ne=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of Z(e))!ee.call(t,c)&&c!==n&&C(t,c,{get:()=>e[c],enumerable:!(s=Y(e,c))||s.enumerable});return t};var re=t=>ne(C({},"__esModule",{value:!0}),t);var oe={};te(oe,{edenFetch:()=>z,edenTreaty:()=>_,treaty:()=>V});var S=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var B=(t,e,n)=>{if(t.endsWith("/")||(t+="/"),e==="index"&&(e=""),!n||!Object.keys(n).length)return`${t}${e}`;let s="";for(let[c,r]of Object.entries(n))s+=`${c}=${r}&`;return`${t}${e}?${s.slice(0,-1)}`},v=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var q=typeof FileList>"u",H=t=>q?t instanceof Blob:t instanceof FileList||t instanceof File,se=t=>{if(!t)return!1;for(let e in t){if(H(t[e]))return!0;if(Array.isArray(t[e])&&t[e].find(n=>H(n)))return!0}return!1},I=t=>q?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),P=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let r=c.data.toString(),i=r.charCodeAt(0);if(i===47||i===123)try{r=JSON.parse(r)}catch{}else v(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...c,data:r})}else n(c)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}},U=(t,e="",n)=>new Proxy(()=>{},{get(s,c,r){return U(t,`${e}/${c.toString()}`,n)},apply(s,c,[r,i={}]=[{},{}]){let u=r!==void 0&&(typeof r!="object"||Array.isArray(r))?r:void 0,{$query:L,$fetch:E,$headers:x,$transform:a,getRaw:p,...d}=r??{};u??=d;let R=e.lastIndexOf("/"),b=e.slice(R+1).toUpperCase(),A=B(t,R===-1?"/":e.slice(0,R),Object.assign(i.query??{},L)),h=n.fetcher??fetch,l=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,F=a?Array.isArray(a)?a:[a]:void 0;return F&&(l?l=F.concat(l):l=F),b==="SUBSCRIBE"?new P(A.replace(/^([^]+):\/\//,A.startsWith("https://")?"wss://":"ws://")):(async o=>{let f,m={...n.$fetch?.headers,...E?.headers,...i.headers,...x};if(b!=="GET"&&b!=="HEAD"){f=Object.keys(u).length||Array.isArray(u)?u:void 0;let g=typeof f=="object"||Array.isArray(u);if(g&&se(f)){let W=new FormData;for(let[j,w]of Object.entries(f))if(q)W.append(j,w);else if(w instanceof File)W.append(j,await I(w));else if(w instanceof FileList)for(let O=0;O<w.length;O++)W.append(j,await I(w[O]));else if(Array.isArray(w))for(let O=0;O<w.length;O++){let N=w[O];W.append(j,N instanceof File?await I(N):N)}else W.append(j,w);f=W}else m["content-type"]=g?"application/json":"text/plain",f=g?JSON.stringify(f):u}let y=await h(A,{method:b,body:f,...n.$fetch,...i.fetch,...E,headers:m}),k;if(o.getRaw)return y;switch(y.headers.get("Content-Type")?.split(";")[0]){case"application/json":k=await y.json();break;default:k=await y.text().then(g=>v(g)?+g:g==="true"?!0:g==="false"?!1:g)}let X=y.status>=300||y.status<200?new S(y.status,k):null,M={data:k,error:X,response:y,status:y.status,headers:y.headers};if(l)for(let g of l){let T=g(M);T instanceof Promise&&(T=await T),T!=null&&(M=T)}return M})({getRaw:p})}}),_=(t,e={fetcher:fetch})=>new Proxy({},{get(n,s){return U(t,s,e)}});var $=class{constructor(e){this.url=e;this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let r=c.data.toString(),i=r.charCodeAt(0);if(i===47||i===123)try{r=JSON.parse(r)}catch{}else v(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...c,data:r})}else n(c)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}};var ae=["get","post","put","delete","patch","options","head","connect","subscribe"],D=typeof FileList>"u",G=t=>D?t instanceof Blob:t instanceof FileList||t instanceof File,ie=t=>{if(!t)return!1;for(let e in t)if(G(t[e])||Array.isArray(t[e])&&t[e].find(G))return!0;return!1},J=t=>D?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),K=(t,e,n=[],s)=>new Proxy(()=>{},{get(c,r){return K(t,e,[...n,r],s)},apply(c,r,[i,u]){return!i||u||typeof i=="object"&&Object.keys(i).length!==1||ae.includes(n.at(-1))?(async()=>{let L=n.pop(),E="/"+n.join("/");if(L==="subscribe")return new $(t.replace(/^([^]+):\/\//,t.startsWith("https://")?"wss://":"ws://")+E);let{fetcher:x=fetch,headers:a,onRequest:p,onResponse:d,...R}=e;if(typeof a=="function"&&!(a instanceof Headers))a=a(E,u)??void 0;else if(Array.isArray(a)&&a.every(o=>typeof o=="function"))for(let o of a)a=o(E,u)??void 0;else if(a instanceof Headers){a={};for(let[o,f]of Object.entries(a))a[o]=f}let b=(a instanceof Headers?a.get("content-type"):Array.isArray(a)?a.find(o=>Array.isArray(o)&&o[0]==="headers"?o[1]:!1):typeof a=="function"?a(E,u):a?.contentType)||u?.headers?.contentType;if(!b)if(typeof i=="object")b="application/json",i=JSON.stringify(i);else if(ie(i)){let o=new FormData;for(let[f,m]of Object.entries(i)){if(D){o.append(f,m);continue}if(m instanceof File){o.append(f,await J(m));continue}if(m instanceof FileList){for(let y=0;y<m.length;y++)o.append(f,await J(m[y]));continue}if(Array.isArray(m)){for(let y=0;y<m.length;y++){let k=m[y];o.append(f,k instanceof File?await J(k):k)}continue}o.append(f,m)}i=o}else b="text/plain";let A={method:L,body:i,...R,headers:{...a,"content-type":b}};if(p){Array.isArray(p)||(p=[p]);for(let o of p){let f=await o(E,A);typeof f=="object"&&Object.assign(A,f)}}let h=await(s?.handle(new Request(t+E,A))??x(t+E,A)),l,F;if(d){Array.isArray(d)||(d=[d]);for(let o of d)try{if(l=await o(h.clone()),l!==void 0)break}catch(f){f instanceof S?F=f:F=new S(500,f);break}}if(l===void 0)if(h.status>=300||h.status<200)new S(h.status,l);else switch(h.headers.get("Content-Type")?.split(";")[0]){case"application/json":l=await h.json();break;case"application/octet-stream":l=await h.arrayBuffer();break;default:l=await h.text().then(o=>v(o)?+o:o==="true"?!0:o==="false"?!1:o)}return{data:l,error:F,response:h,status:h.status,headers:h.headers}})():typeof i=="object"?K(t,e,[...n,Object.values(i)[0]],s):K(t,e,n)}}),V=(t,e={})=>typeof t=="string"?(t.includes("://")||(t=(["localhost","127.0.0.1","0.0.0.0"].find(n=>t.includes(n))?"http://":"https://")+t),t.endsWith("/")&&(t=t.slice(0,-1)),K(t,e)):(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",e,[],t));var z=(t,e)=>(n,{query:s,params:c,body:r,...i}={})=>{c&&Object.entries(c).forEach(([a,p])=>{n=n.replace(`:${a}`,p)});let u=i.headers?.["Content-Type"];if(!u||u==="application/json")try{r=JSON.stringify(r)}catch{}let L=e?.fetcher||globalThis.fetch,E=s?`?${new URLSearchParams(s).toString()}`:"",x=()=>L(t+n+E,{...i,method:i.method?.toUpperCase()||"GET",headers:r?{"content-type":"application/json",...i.headers}:i.headers,body:r}).then(async a=>{let p;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":p=await a.json();break;default:p=await a.text().then(d=>v(d)?parseInt(d):d==="true"?!0:d==="false"?!1:d);break}return a.status>300?{data:null,status:a.status,headers:a.headers,retry:x,error:new S(a.status,p)}:{data:p,error:null,status:a.status,headers:a.headers,retry:x}});return x()};return re(oe);})();
"use strict";var Eden=(()=>{var C=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(t,e)=>{for(var n in e)C(t,n,{get:e[n],enumerable:!0})},ne=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of Z(e))!ee.call(t,c)&&c!==n&&C(t,c,{get:()=>e[c],enumerable:!(s=Y(e,c))||s.enumerable});return t};var re=t=>ne(C({},"__esModule",{value:!0}),t);var oe={};te(oe,{edenFetch:()=>z,edenTreaty:()=>V,treaty:()=>U});var B=(t,e,n)=>{if(t.endsWith("/")||(t+="/"),e==="index"&&(e=""),!n||!Object.keys(n).length)return`${t}${e}`;let s="";for(let[c,r]of Object.entries(n))s+=`${c}=${r}&`;return`${t}${e}?${s.slice(0,-1)}`},v=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var S=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var $=class{constructor(e){this.url=e;this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let r=c.data.toString(),i=r.charCodeAt(0);if(i===47||i===123)try{r=JSON.parse(r)}catch{}else v(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...c,data:r})}else n(c)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}};var se=["get","post","put","delete","patch","options","head","connect","subscribe"],P=typeof FileList>"u",H=t=>P?t instanceof Blob:t instanceof FileList||t instanceof File,ae=t=>{if(!t)return!1;for(let e in t)if(H(t[e])||Array.isArray(t[e])&&t[e].find(H))return!0;return!1},I=t=>P?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),K=(t,e,n=[],s)=>new Proxy(()=>{},{get(c,r){return K(t,e,[...n,r],s)},apply(c,r,[i,u]){return!i||u||typeof i=="object"&&Object.keys(i).length!==1||se.includes(n.at(-1))?(async()=>{let L=n.pop(),g="/"+n.join("/");if(L==="subscribe")return new $(t.replace(/^([^]+):\/\//,t.startsWith("https://")?"wss://":"ws://")+g);let{fetcher:x=fetch,headers:a,onRequest:p,onResponse:d,...R}=e;if(typeof a=="function"&&!(a instanceof Headers))a=a(g,u)??void 0;else if(Array.isArray(a)&&a.every(o=>typeof o=="function"))for(let o of a)a=o(g,u)??void 0;else if(a instanceof Headers){a={};for(let[o,f]of Object.entries(a))a[o]=f}let b=(a instanceof Headers?a.get("content-type"):Array.isArray(a)?a.find(o=>Array.isArray(o)&&o[0]==="headers"?o[1]:!1):typeof a=="function"?a(g,u):a?.contentType)||u?.headers?.contentType;if(!b)if(typeof i=="object")b="application/json",i=JSON.stringify(i);else if(ae(i)){let o=new FormData;for(let[f,m]of Object.entries(i)){if(P){o.append(f,m);continue}if(m instanceof File){o.append(f,await I(m));continue}if(m instanceof FileList){for(let y=0;y<m.length;y++)o.append(f,await I(m[y]));continue}if(Array.isArray(m)){for(let y=0;y<m.length;y++){let k=m[y];o.append(f,k instanceof File?await I(k):k)}continue}o.append(f,m)}i=o}else b="text/plain";let A={method:L,body:i,...R,headers:{...a,"content-type":b}};if(p){Array.isArray(p)||(p=[p]);for(let o of p){let f=await o(g,A);typeof f=="object"&&Object.assign(A,f)}}let h=await(s?.handle(new Request(t+g,A))??x(t+g,A)),l,F;if(d){Array.isArray(d)||(d=[d]);for(let o of d)try{if(l=await o(h.clone()),l!==void 0)break}catch(f){f instanceof S?F=f:F=new S(500,f);break}}if(l===void 0)if(h.status>=300||h.status<200)new S(h.status,l);else switch(h.headers.get("Content-Type")?.split(";")[0]){case"application/json":l=await h.json();break;case"application/octet-stream":l=await h.arrayBuffer();break;default:l=await h.text().then(o=>v(o)?+o:o==="true"?!0:o==="false"?!1:o)}return{data:l,error:F,response:h,status:h.status,headers:h.headers}})():typeof i=="object"?K(t,e,[...n,Object.values(i)[0]],s):K(t,e,n)}}),U=(t,e={})=>typeof t=="string"?(t.includes("://")||(t=(["localhost","127.0.0.1","0.0.0.0"].find(n=>t.includes(n))?"http://":"https://")+t),t.endsWith("/")&&(t=t.slice(0,-1)),K(t,e)):(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",e,[],t));var D=typeof FileList>"u",_=t=>D?t instanceof Blob:t instanceof FileList||t instanceof File,ie=t=>{if(!t)return!1;for(let e in t){if(_(t[e]))return!0;if(Array.isArray(t[e])&&t[e].find(n=>_(n)))return!0}return!1},q=t=>D?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),J=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let r=c.data.toString(),i=r.charCodeAt(0);if(i===47||i===123)try{r=JSON.parse(r)}catch{}else v(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...c,data:r})}else n(c)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}},G=(t,e="",n)=>new Proxy(()=>{},{get(s,c,r){return G(t,`${e}/${c.toString()}`,n)},apply(s,c,[r,i={}]=[{},{}]){let u=r!==void 0&&(typeof r!="object"||Array.isArray(r))?r:void 0,{$query:L,$fetch:g,$headers:x,$transform:a,getRaw:p,...d}=r??{};u??=d;let R=e.lastIndexOf("/"),b=e.slice(R+1).toUpperCase(),A=B(t,R===-1?"/":e.slice(0,R),Object.assign(i.query??{},L)),h=n.fetcher??fetch,l=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,F=a?Array.isArray(a)?a:[a]:void 0;return F&&(l?l=F.concat(l):l=F),b==="SUBSCRIBE"?new J(A.replace(/^([^]+):\/\//,A.startsWith("https://")?"wss://":"ws://")):(async o=>{let f,m={...n.$fetch?.headers,...g?.headers,...i.headers,...x};if(b!=="GET"&&b!=="HEAD"){f=Object.keys(u).length||Array.isArray(u)?u:void 0;let E=typeof f=="object"||Array.isArray(u);if(E&&ie(f)){let W=new FormData;for(let[j,w]of Object.entries(f))if(D)W.append(j,w);else if(w instanceof File)W.append(j,await q(w));else if(w instanceof FileList)for(let O=0;O<w.length;O++)W.append(j,await q(w[O]));else if(Array.isArray(w))for(let O=0;O<w.length;O++){let N=w[O];W.append(j,N instanceof File?await q(N):N)}else W.append(j,w);f=W}else m["content-type"]=E?"application/json":"text/plain",f=E?JSON.stringify(f):u}let y=await h(A,{method:b,body:f,...n.$fetch,...i.fetch,...g,headers:m}),k;if(o.getRaw)return y;switch(y.headers.get("Content-Type")?.split(";")[0]){case"application/json":k=await y.json();break;default:k=await y.text().then(E=>v(E)?+E:E==="true"?!0:E==="false"?!1:E)}let X=y.status>=300||y.status<200?new S(y.status,k):null,M={data:k,error:X,response:y,status:y.status,headers:y.headers};if(l)for(let E of l){let T=E(M);T instanceof Promise&&(T=await T),T!=null&&(M=T)}return M})({getRaw:p})}}),V=(t,e={fetcher:fetch})=>new Proxy({},{get(n,s){return G(t,s,e)}});var z=(t,e)=>(n,{query:s,params:c,body:r,...i}={})=>{c&&Object.entries(c).forEach(([a,p])=>{n=n.replace(`:${a}`,p)});let u=i.headers?.["Content-Type"];if(!u||u==="application/json")try{r=JSON.stringify(r)}catch{}let L=e?.fetcher||globalThis.fetch,g=s?`?${new URLSearchParams(s).toString()}`:"",x=()=>L(t+n+g,{...i,method:i.method?.toUpperCase()||"GET",headers:r?{"content-type":"application/json",...i.headers}:i.headers,body:r}).then(async a=>{let p;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":p=await a.json();break;default:p=await a.text().then(d=>v(d)?parseInt(d):d==="true"?!0:d==="false"?!1:d);break}return a.status>300?{data:null,status:a.status,headers:a.headers,retry:x,error:new S(a.status,p)}:{data:p,error:null,status:a.status,headers:a.headers,retry:x}});return x()};return re(oe);})();

@@ -1,1 +0,1 @@

"use strict";var C=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(t,e)=>{for(var n in e)C(t,n,{get:e[n],enumerable:!0})},ne=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of Z(e))!ee.call(t,c)&&c!==n&&C(t,c,{get:()=>e[c],enumerable:!(s=Y(e,c))||s.enumerable});return t};var re=t=>ne(C({},"__esModule",{value:!0}),t);var oe={};te(oe,{edenFetch:()=>z,edenTreaty:()=>_,treaty:()=>V});module.exports=re(oe);var S=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var B=(t,e,n)=>{if(t.endsWith("/")||(t+="/"),e==="index"&&(e=""),!n||!Object.keys(n).length)return`${t}${e}`;let s="";for(let[c,r]of Object.entries(n))s+=`${c}=${r}&`;return`${t}${e}?${s.slice(0,-1)}`},v=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var q=typeof FileList>"u",H=t=>q?t instanceof Blob:t instanceof FileList||t instanceof File,se=t=>{if(!t)return!1;for(let e in t){if(H(t[e]))return!0;if(Array.isArray(t[e])&&t[e].find(n=>H(n)))return!0}return!1},I=t=>q?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),P=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let r=c.data.toString(),i=r.charCodeAt(0);if(i===47||i===123)try{r=JSON.parse(r)}catch{}else v(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...c,data:r})}else n(c)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}},U=(t,e="",n)=>new Proxy(()=>{},{get(s,c,r){return U(t,`${e}/${c.toString()}`,n)},apply(s,c,[r,i={}]=[{},{}]){let u=r!==void 0&&(typeof r!="object"||Array.isArray(r))?r:void 0,{$query:L,$fetch:E,$headers:x,$transform:a,getRaw:p,...d}=r??{};u??=d;let R=e.lastIndexOf("/"),b=e.slice(R+1).toUpperCase(),A=B(t,R===-1?"/":e.slice(0,R),Object.assign(i.query??{},L)),h=n.fetcher??fetch,l=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,F=a?Array.isArray(a)?a:[a]:void 0;return F&&(l?l=F.concat(l):l=F),b==="SUBSCRIBE"?new P(A.replace(/^([^]+):\/\//,A.startsWith("https://")?"wss://":"ws://")):(async o=>{let f,m={...n.$fetch?.headers,...E?.headers,...i.headers,...x};if(b!=="GET"&&b!=="HEAD"){f=Object.keys(u).length||Array.isArray(u)?u:void 0;let g=typeof f=="object"||Array.isArray(u);if(g&&se(f)){let W=new FormData;for(let[j,w]of Object.entries(f))if(q)W.append(j,w);else if(w instanceof File)W.append(j,await I(w));else if(w instanceof FileList)for(let O=0;O<w.length;O++)W.append(j,await I(w[O]));else if(Array.isArray(w))for(let O=0;O<w.length;O++){let N=w[O];W.append(j,N instanceof File?await I(N):N)}else W.append(j,w);f=W}else m["content-type"]=g?"application/json":"text/plain",f=g?JSON.stringify(f):u}let y=await h(A,{method:b,body:f,...n.$fetch,...i.fetch,...E,headers:m}),k;if(o.getRaw)return y;switch(y.headers.get("Content-Type")?.split(";")[0]){case"application/json":k=await y.json();break;default:k=await y.text().then(g=>v(g)?+g:g==="true"?!0:g==="false"?!1:g)}let X=y.status>=300||y.status<200?new S(y.status,k):null,M={data:k,error:X,response:y,status:y.status,headers:y.headers};if(l)for(let g of l){let T=g(M);T instanceof Promise&&(T=await T),T!=null&&(M=T)}return M})({getRaw:p})}}),_=(t,e={fetcher:fetch})=>new Proxy({},{get(n,s){return U(t,s,e)}});var $=class{constructor(e){this.url=e;this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let r=c.data.toString(),i=r.charCodeAt(0);if(i===47||i===123)try{r=JSON.parse(r)}catch{}else v(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...c,data:r})}else n(c)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}};var ae=["get","post","put","delete","patch","options","head","connect","subscribe"],D=typeof FileList>"u",G=t=>D?t instanceof Blob:t instanceof FileList||t instanceof File,ie=t=>{if(!t)return!1;for(let e in t)if(G(t[e])||Array.isArray(t[e])&&t[e].find(G))return!0;return!1},J=t=>D?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),K=(t,e,n=[],s)=>new Proxy(()=>{},{get(c,r){return K(t,e,[...n,r],s)},apply(c,r,[i,u]){return!i||u||typeof i=="object"&&Object.keys(i).length!==1||ae.includes(n.at(-1))?(async()=>{let L=n.pop(),E="/"+n.join("/");if(L==="subscribe")return new $(t.replace(/^([^]+):\/\//,t.startsWith("https://")?"wss://":"ws://")+E);let{fetcher:x=fetch,headers:a,onRequest:p,onResponse:d,...R}=e;if(typeof a=="function"&&!(a instanceof Headers))a=a(E,u)??void 0;else if(Array.isArray(a)&&a.every(o=>typeof o=="function"))for(let o of a)a=o(E,u)??void 0;else if(a instanceof Headers){a={};for(let[o,f]of Object.entries(a))a[o]=f}let b=(a instanceof Headers?a.get("content-type"):Array.isArray(a)?a.find(o=>Array.isArray(o)&&o[0]==="headers"?o[1]:!1):typeof a=="function"?a(E,u):a?.contentType)||u?.headers?.contentType;if(!b)if(typeof i=="object")b="application/json",i=JSON.stringify(i);else if(ie(i)){let o=new FormData;for(let[f,m]of Object.entries(i)){if(D){o.append(f,m);continue}if(m instanceof File){o.append(f,await J(m));continue}if(m instanceof FileList){for(let y=0;y<m.length;y++)o.append(f,await J(m[y]));continue}if(Array.isArray(m)){for(let y=0;y<m.length;y++){let k=m[y];o.append(f,k instanceof File?await J(k):k)}continue}o.append(f,m)}i=o}else b="text/plain";let A={method:L,body:i,...R,headers:{...a,"content-type":b}};if(p){Array.isArray(p)||(p=[p]);for(let o of p){let f=await o(E,A);typeof f=="object"&&Object.assign(A,f)}}let h=await(s?.handle(new Request(t+E,A))??x(t+E,A)),l,F;if(d){Array.isArray(d)||(d=[d]);for(let o of d)try{if(l=await o(h.clone()),l!==void 0)break}catch(f){f instanceof S?F=f:F=new S(500,f);break}}if(l===void 0)if(h.status>=300||h.status<200)new S(h.status,l);else switch(h.headers.get("Content-Type")?.split(";")[0]){case"application/json":l=await h.json();break;case"application/octet-stream":l=await h.arrayBuffer();break;default:l=await h.text().then(o=>v(o)?+o:o==="true"?!0:o==="false"?!1:o)}return{data:l,error:F,response:h,status:h.status,headers:h.headers}})():typeof i=="object"?K(t,e,[...n,Object.values(i)[0]],s):K(t,e,n)}}),V=(t,e={})=>typeof t=="string"?(t.includes("://")||(t=(["localhost","127.0.0.1","0.0.0.0"].find(n=>t.includes(n))?"http://":"https://")+t),t.endsWith("/")&&(t=t.slice(0,-1)),K(t,e)):(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",e,[],t));var z=(t,e)=>(n,{query:s,params:c,body:r,...i}={})=>{c&&Object.entries(c).forEach(([a,p])=>{n=n.replace(`:${a}`,p)});let u=i.headers?.["Content-Type"];if(!u||u==="application/json")try{r=JSON.stringify(r)}catch{}let L=e?.fetcher||globalThis.fetch,E=s?`?${new URLSearchParams(s).toString()}`:"",x=()=>L(t+n+E,{...i,method:i.method?.toUpperCase()||"GET",headers:r?{"content-type":"application/json",...i.headers}:i.headers,body:r}).then(async a=>{let p;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":p=await a.json();break;default:p=await a.text().then(d=>v(d)?parseInt(d):d==="true"?!0:d==="false"?!1:d);break}return a.status>300?{data:null,status:a.status,headers:a.headers,retry:x,error:new S(a.status,p)}:{data:p,error:null,status:a.status,headers:a.headers,retry:x}});return x()};0&&(module.exports={edenFetch,edenTreaty,treaty});
"use strict";var C=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(t,e)=>{for(var n in e)C(t,n,{get:e[n],enumerable:!0})},ne=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of Z(e))!ee.call(t,c)&&c!==n&&C(t,c,{get:()=>e[c],enumerable:!(s=Y(e,c))||s.enumerable});return t};var re=t=>ne(C({},"__esModule",{value:!0}),t);var oe={};te(oe,{edenFetch:()=>z,edenTreaty:()=>V,treaty:()=>U});module.exports=re(oe);var B=(t,e,n)=>{if(t.endsWith("/")||(t+="/"),e==="index"&&(e=""),!n||!Object.keys(n).length)return`${t}${e}`;let s="";for(let[c,r]of Object.entries(n))s+=`${c}=${r}&`;return`${t}${e}?${s.slice(0,-1)}`},v=t=>t.trim().length!==0&&!Number.isNaN(Number(t));var S=class extends Error{constructor(n,s){super(s+"");this.status=n;this.value=s}};var $=class{constructor(e){this.url=e;this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let r=c.data.toString(),i=r.charCodeAt(0);if(i===47||i===123)try{r=JSON.parse(r)}catch{}else v(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...c,data:r})}else n(c)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}};var se=["get","post","put","delete","patch","options","head","connect","subscribe"],P=typeof FileList>"u",H=t=>P?t instanceof Blob:t instanceof FileList||t instanceof File,ae=t=>{if(!t)return!1;for(let e in t)if(H(t[e])||Array.isArray(t[e])&&t[e].find(H))return!0;return!1},I=t=>P?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),K=(t,e,n=[],s)=>new Proxy(()=>{},{get(c,r){return K(t,e,[...n,r],s)},apply(c,r,[i,u]){return!i||u||typeof i=="object"&&Object.keys(i).length!==1||se.includes(n.at(-1))?(async()=>{let L=n.pop(),g="/"+n.join("/");if(L==="subscribe")return new $(t.replace(/^([^]+):\/\//,t.startsWith("https://")?"wss://":"ws://")+g);let{fetcher:x=fetch,headers:a,onRequest:p,onResponse:d,...R}=e;if(typeof a=="function"&&!(a instanceof Headers))a=a(g,u)??void 0;else if(Array.isArray(a)&&a.every(o=>typeof o=="function"))for(let o of a)a=o(g,u)??void 0;else if(a instanceof Headers){a={};for(let[o,f]of Object.entries(a))a[o]=f}let b=(a instanceof Headers?a.get("content-type"):Array.isArray(a)?a.find(o=>Array.isArray(o)&&o[0]==="headers"?o[1]:!1):typeof a=="function"?a(g,u):a?.contentType)||u?.headers?.contentType;if(!b)if(typeof i=="object")b="application/json",i=JSON.stringify(i);else if(ae(i)){let o=new FormData;for(let[f,m]of Object.entries(i)){if(P){o.append(f,m);continue}if(m instanceof File){o.append(f,await I(m));continue}if(m instanceof FileList){for(let y=0;y<m.length;y++)o.append(f,await I(m[y]));continue}if(Array.isArray(m)){for(let y=0;y<m.length;y++){let k=m[y];o.append(f,k instanceof File?await I(k):k)}continue}o.append(f,m)}i=o}else b="text/plain";let A={method:L,body:i,...R,headers:{...a,"content-type":b}};if(p){Array.isArray(p)||(p=[p]);for(let o of p){let f=await o(g,A);typeof f=="object"&&Object.assign(A,f)}}let h=await(s?.handle(new Request(t+g,A))??x(t+g,A)),l,F;if(d){Array.isArray(d)||(d=[d]);for(let o of d)try{if(l=await o(h.clone()),l!==void 0)break}catch(f){f instanceof S?F=f:F=new S(500,f);break}}if(l===void 0)if(h.status>=300||h.status<200)new S(h.status,l);else switch(h.headers.get("Content-Type")?.split(";")[0]){case"application/json":l=await h.json();break;case"application/octet-stream":l=await h.arrayBuffer();break;default:l=await h.text().then(o=>v(o)?+o:o==="true"?!0:o==="false"?!1:o)}return{data:l,error:F,response:h,status:h.status,headers:h.headers}})():typeof i=="object"?K(t,e,[...n,Object.values(i)[0]],s):K(t,e,n)}}),U=(t,e={})=>typeof t=="string"?(t.includes("://")||(t=(["localhost","127.0.0.1","0.0.0.0"].find(n=>t.includes(n))?"http://":"https://")+t),t.endsWith("/")&&(t=t.slice(0,-1)),K(t,e)):(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",e,[],t));var D=typeof FileList>"u",_=t=>D?t instanceof Blob:t instanceof FileList||t instanceof File,ie=t=>{if(!t)return!1;for(let e in t){if(_(t[e]))return!0;if(Array.isArray(t[e])&&t[e].find(n=>_(n)))return!0}return!1},q=t=>D?t:new Promise(e=>{let n=new FileReader;n.onload=()=>{let s=new File([n.result],t.name,{lastModified:t.lastModified,type:t.type});e(s)},n.readAsArrayBuffer(t)}),J=class{ws;url;constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(n=>this.send(n)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,n,s){return this.addEventListener(e,n,s)}off(e,n,s){return this.ws.removeEventListener(e,n,s),this}subscribe(e,n){return this.addEventListener("message",e,n)}addEventListener(e,n,s){return this.ws.addEventListener(e,c=>{if(e==="message"){let r=c.data.toString(),i=r.charCodeAt(0);if(i===47||i===123)try{r=JSON.parse(r)}catch{}else v(r)?r=+r:r==="true"?r=!0:r==="false"&&(r=!1);n({...c,data:r})}else n(c)},s),this}removeEventListener(e,n,s){return this.off(e,n,s),this}close(){return this.ws.close(),this}},G=(t,e="",n)=>new Proxy(()=>{},{get(s,c,r){return G(t,`${e}/${c.toString()}`,n)},apply(s,c,[r,i={}]=[{},{}]){let u=r!==void 0&&(typeof r!="object"||Array.isArray(r))?r:void 0,{$query:L,$fetch:g,$headers:x,$transform:a,getRaw:p,...d}=r??{};u??=d;let R=e.lastIndexOf("/"),b=e.slice(R+1).toUpperCase(),A=B(t,R===-1?"/":e.slice(0,R),Object.assign(i.query??{},L)),h=n.fetcher??fetch,l=n.transform?Array.isArray(n.transform)?n.transform:[n.transform]:void 0,F=a?Array.isArray(a)?a:[a]:void 0;return F&&(l?l=F.concat(l):l=F),b==="SUBSCRIBE"?new J(A.replace(/^([^]+):\/\//,A.startsWith("https://")?"wss://":"ws://")):(async o=>{let f,m={...n.$fetch?.headers,...g?.headers,...i.headers,...x};if(b!=="GET"&&b!=="HEAD"){f=Object.keys(u).length||Array.isArray(u)?u:void 0;let E=typeof f=="object"||Array.isArray(u);if(E&&ie(f)){let W=new FormData;for(let[j,w]of Object.entries(f))if(D)W.append(j,w);else if(w instanceof File)W.append(j,await q(w));else if(w instanceof FileList)for(let O=0;O<w.length;O++)W.append(j,await q(w[O]));else if(Array.isArray(w))for(let O=0;O<w.length;O++){let N=w[O];W.append(j,N instanceof File?await q(N):N)}else W.append(j,w);f=W}else m["content-type"]=E?"application/json":"text/plain",f=E?JSON.stringify(f):u}let y=await h(A,{method:b,body:f,...n.$fetch,...i.fetch,...g,headers:m}),k;if(o.getRaw)return y;switch(y.headers.get("Content-Type")?.split(";")[0]){case"application/json":k=await y.json();break;default:k=await y.text().then(E=>v(E)?+E:E==="true"?!0:E==="false"?!1:E)}let X=y.status>=300||y.status<200?new S(y.status,k):null,M={data:k,error:X,response:y,status:y.status,headers:y.headers};if(l)for(let E of l){let T=E(M);T instanceof Promise&&(T=await T),T!=null&&(M=T)}return M})({getRaw:p})}}),V=(t,e={fetcher:fetch})=>new Proxy({},{get(n,s){return G(t,s,e)}});var z=(t,e)=>(n,{query:s,params:c,body:r,...i}={})=>{c&&Object.entries(c).forEach(([a,p])=>{n=n.replace(`:${a}`,p)});let u=i.headers?.["Content-Type"];if(!u||u==="application/json")try{r=JSON.stringify(r)}catch{}let L=e?.fetcher||globalThis.fetch,g=s?`?${new URLSearchParams(s).toString()}`:"",x=()=>L(t+n+g,{...i,method:i.method?.toUpperCase()||"GET",headers:r?{"content-type":"application/json",...i.headers}:i.headers,body:r}).then(async a=>{let p;switch(a.headers.get("Content-Type")?.split(";")[0]){case"application/json":p=await a.json();break;default:p=await a.text().then(d=>v(d)?parseInt(d):d==="true"?!0:d==="false"?!1:d);break}return a.status>300?{data:null,status:a.status,headers:a.headers,retry:x,error:new S(a.status,p)}:{data:p,error:null,status:a.status,headers:a.headers,retry:x}});return x()};0&&(module.exports={edenFetch,edenTreaty,treaty});
import { Elysia, InputSchema } from 'elysia';
import { P as Prettify, I as IsUnknown, M as MapError, a as IsNever, E as EdenFetchError } from './types-BQi-Ff9p.js';
import { P as Prettify, I as IsUnknown, M as MapError, a as IsNever, E as EdenFetchError } from './types-DNydNaKe.js';

@@ -12,3 +12,3 @@ /// <reference lib="dom" />

declare namespace EdenTreaty {
export type Create<App extends Elysia<any, any, any, any, any, any>> = App extends {
export type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
_routes: infer Schema extends Record<string, unknown>;

@@ -117,4 +117,12 @@ } ? Prettify<Sign<Schema>> : 'Please install Elysia before using Eden';

}
declare const edenTreaty: <App extends Elysia<any, any, any, any, any, any>>(domain: string, config?: EdenTreaty.Config) => EdenTreaty.Create<App>;
declare const edenTreaty: <App extends Elysia<any, any, any, any, any, any, {
decorator: {};
store: {};
derive: {};
resolve: {};
}, {
schema: {};
macro: {};
}>>(domain: string, config?: EdenTreaty.Config) => EdenTreaty.Create<App>;
export { EdenTreaty, EdenWS, edenTreaty };

@@ -16,2 +16,10 @@ import type { Elysia, InputSchema } from 'elysia';

}
export declare const edenTreaty: <App extends Elysia<any, any, any, any, any, any>>(domain: string, config?: EdenTreaty.Config) => EdenTreaty.Create<App>;
export declare const edenTreaty: <App extends Elysia<any, any, any, any, any, any, {
decorator: {};
store: {};
derive: {};
resolve: {};
}, {
schema: {};
macro: {};
}>>(domain: string, config?: EdenTreaty.Config) => EdenTreaty.Create<App>;

@@ -12,3 +12,3 @@ /// <reference lib="dom" />

export declare namespace EdenTreaty {
export type Create<App extends Elysia<any, any, any, any, any, any>> = App extends {
export type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
_routes: infer Schema extends Record<string, unknown>;

@@ -15,0 +15,0 @@ } ? Prettify<Sign<Schema>> : 'Please install Elysia before using Eden';

import type { Elysia } from 'elysia';
import type { EdenTreaty2 } from './types';
export declare const treaty: <const App extends Elysia<any, any, any, any, any, any>>(domain: string | App, config?: EdenTreaty2.Config) => EdenTreaty2.Create<App>;
export type { EdenTreaty2 };
import type { Treaty } from './types';
export declare const treaty: <const App extends Elysia<any, any, any, any, any, any, {
decorator: {};
store: {};
derive: {};
resolve: {};
}, {
schema: {};
macro: {};
}>>(domain: string | App, config?: Treaty.Config) => Treaty.Create<App>;
export type { Treaty };
/// <reference types="bun-types" />
/// <reference lib="dom" />
import type { Elysia } from 'elysia';
import { EdenWS } from './ws';
import type { Prettify } from '../types';

@@ -11,13 +12,18 @@ type Files = File | FileList;

type MaybePromise<T> = T | Promise<T>;
export declare namespace EdenTreaty2 {
export declare namespace Treaty {
interface TreatyParam {
fetch?: RequestInit;
}
export type Create<App extends Elysia<any, any, any, any, any, any>> = App extends {
export type Create<App extends Elysia<any, any, any, any, any, any, any, any>> = App extends {
_routes: infer Schema extends Record<string, any>;
} ? Prettify<Sign<Schema>> : 'Please install Elysia before using Eden';
export type Sign<in out Route extends Record<string, any>> = {
[K in keyof Route as K extends '' ? 'index' : K extends `:${string}` ? never : K]: Route[K] extends {
[K in keyof Route as K extends '/' | '' ? 'index' : K extends `:${string}` ? never : K]: K extends 'subscribe' ? undefined extends Route['subscribe']['query'] ? (params?: {
query?: Record<string, string>;
}) => EdenWS<Route['subscribe']> : (params: {
query: Route['subscribe']['query'];
}) => EdenWS<Route['subscribe']> : Route[K] extends {
body: infer Body;
headers: infer Headers;
params: any;
query: infer Query;

@@ -33,5 +39,3 @@ response: infer Response extends Record<number, unknown>;

query: Query;
}) extends infer Param ? {} extends Param ? undefined extends Body ? (body?: Body, options?: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : (body: Body extends Record<string, unknown> ? ReplaceBlobWithFiles<Body> : Body, options?: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : (body: Body extends Record<string, unknown> ? ReplaceBlobWithFiles<Body> : Body, options: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : never : keyof Route[K] extends `:${infer Param}` ? (params: {
[param in Param]: string;
}) => Prettify<Prettify<Sign<Route[K]>> & Sign<Route[K][`:${Param}`]>> : Prettify<Sign<Route[K]>>;
}) extends infer Param ? {} extends Param ? undefined extends Body ? (body?: Body, options?: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : (body: Body extends Record<string, unknown> ? ReplaceBlobWithFiles<Body> : Body, options?: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : (body: Body extends Record<string, unknown> ? ReplaceBlobWithFiles<Body> : Body, options: Prettify<Param & TreatyParam>) => Promise<TreatyResponse<Response>> : never : keyof Route[K] extends `:${infer Param}` ? (params: Record<Param, string>) => Prettify<Prettify<Sign<Route[K]>> & Sign<Route[K][`:${Param}`]>> : Prettify<Sign<Route[K]>>;
};

@@ -38,0 +42,0 @@ export interface Config extends Omit<RequestInit, 'headers'> {

import type { InputSchema } from 'elysia';
import type { EdenTreaty2 } from './types';
export declare class EdenWS<Schema extends InputSchema<any> = {}> {
import type { Treaty } from './types';
export declare class EdenWS<in out Schema extends InputSchema<any> = {}> {
url: string;

@@ -8,8 +8,8 @@ ws: WebSocket;

send(data: Schema['body'] | Schema['body'][]): this;
on<K extends keyof WebSocketEventMap>(type: K, listener: (event: EdenTreaty2.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
on<K extends keyof WebSocketEventMap>(type: K, listener: (event: Treaty.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
off<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
subscribe(onMessage: (event: EdenTreaty2.WSEvent<'message', Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (event: EdenTreaty2.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
subscribe(onMessage: (event: Treaty.WSEvent<'message', Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (event: Treaty.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
close(): this;
}
{
"name": "@elysiajs/eden",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Fully type-safe Elysia client",

@@ -55,3 +55,3 @@ "author": {

"peerDependencies": {
"elysia": ">= 1.0.0-beta.0"
"elysia": ">= 1.0.0-beta.4"
},

@@ -62,3 +62,3 @@ "devDependencies": {

"@types/node": "^18.15.5",
"elysia": "1.0.0-beta.0",
"elysia": "1.0.0-beta.4",
"esbuild": "^0.19.3",

@@ -65,0 +65,0 @@ "eslint": "^8.26.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc