gemi 0.4.37 → 0.4.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-00f16704831dd8b0.js +2 -0
- package/dist/chunk-11a75566ff74db17.js +6 -0
- package/dist/chunk-2672477bf396bad8.js +2 -0
- package/dist/chunk-28bb1e70f39736ee.js +2 -0
- package/dist/chunk-2a101fb25d52469b.js +2 -0
- package/dist/chunk-2a48e0098ccd4249.js +1 -1
- package/dist/chunk-38237d1b01b0db25.js +3 -0
- package/dist/chunk-3a9fcddbd219223b.js +3 -0
- package/dist/chunk-3c83d6762f7e56b3.js +2 -0
- package/dist/chunk-442a5b1ec74c72f8.js +2 -0
- package/dist/chunk-5128de1a65ba6ce1.js +2 -0
- package/dist/chunk-5190b38f06507ee1.js +18 -0
- package/dist/chunk-552bdaee8c03e091.js +1 -1
- package/dist/chunk-59e951812cb019e6.js +2 -0
- package/dist/chunk-5b54843712abde58.js +2 -0
- package/dist/chunk-5c2a5156f6bef0f5.js +2 -0
- package/dist/chunk-5defd55c3c97bdb2.js +2 -0
- package/dist/chunk-648dff766091372e.js +2 -0
- package/dist/chunk-682b01231754a121.js +1 -1
- package/dist/chunk-6afe097e13ebdf55.js +1 -1
- package/dist/chunk-733513f9c9e8b50f.js +2 -0
- package/dist/chunk-73c97da8ac4f1d30.js +1 -0
- package/dist/chunk-73c9d39f58a30fe2.js +6 -0
- package/dist/chunk-8b944ecefa1b832c.js +18 -0
- package/dist/chunk-8f547b919361fdf4.js +2 -0
- package/dist/chunk-9238196d4889d660.js +1 -0
- package/dist/chunk-92a55add20b5d7ac.js +9 -0
- package/dist/chunk-9f6199bc705fc395.js +18 -0
- package/dist/chunk-a02b2d564bdb603d.js +6 -0
- package/dist/chunk-a8310ad9bad32329.js +1 -1
- package/dist/chunk-aafdd9bfb5bde8bf.js +2 -0
- package/dist/chunk-ab79a2f0d89fbeae.js +1 -0
- package/dist/chunk-abd0b68c299eebfc.js +1 -1
- package/dist/chunk-b66a9e50afbac035.js +9 -0
- package/dist/chunk-bee6075c5738d87a.js +1 -1
- package/dist/chunk-bf4fa1d9864332a8.js +2 -0
- package/dist/chunk-c8b00b645df96ed5.js +1 -1
- package/dist/chunk-cb65fe402653c65e.js +1 -1
- package/dist/chunk-cce7de7e81895807.js +2 -0
- package/dist/chunk-d7457cb6aae3b29b.js +2 -0
- package/dist/chunk-dad55fcc32d05b69.js +2 -0
- package/dist/chunk-dd21f367f8029793.js +2 -0
- package/dist/chunk-ee4ff285d7f4ccdf.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +5 -2
- package/dist/client/types.d.ts.map +1 -1
- package/dist/http/ViewRouter.d.ts +1 -1
- package/dist/http/ViewRouter.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/storage/index.js +3 -3
- package/package.json +2 -2
package/dist/http/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"../chunk-a5c18c07abe8fd9c.js";class
|
|
2
|
+
import"../chunk-a5c18c07abe8fd9c.js";class h{requests={};static kind="controller";constructor(){}}class C extends h{constructor(){super(...arguments)}}function f(e){return typeof e==="function"&&e.prototype!==void 0}var $=function(e){return f(e)};class l{e;t;r;middlewares=[];constructor(e,t,r){this.method=e;this.handler=t;this.methodName=r;this.handler=t,this.methodName=r,this.method=e}run(e){let t=e;if($(this.handler)){const r=new this.handler,n=r[this.methodName].bind(r);return t=r.requests[this.methodName]?new r.requests[this.methodName](e.rawRequest,e.params):t,n(t)}else return this.handler(e)}middleware(e){return this.middlewares=e,this}}class H{constructor(...e){return new l(...e)}}class x{routes={};middlewares=[];middleware(e){}get(e,t){return new l("GET",e,t)}post(e,t){return new l("POST",e,t)}put(e,t){return new l("PUT",e,t)}patch(e,t){return new l("PATCH",e,t)}delete(e,t){return new l("DELETE",e,t)}resource(e){class t extends x{constructor(){super(...arguments)}routes={"/":{list:this.get(e,"list"),create:this.post(e,"create")},"/:id":{show:this.get(e,"show"),update:this.put(e,"update"),delete:this.delete(e,"delete")}}}return t}file(e,t){return new H("GET",e,t)}}class g{e;middlewares=[];handler;constructor(e,t){this.viewPath=e;if(!t)this.handler=()=>({});else if(typeof t==="function")this.handler=t;else{const[r,n]=t,s=new r,o=s[n].bind(s);this.handler=(a)=>{let i=a;return i=s.requests[n]?new s.requests[n](a.rawRequest,a.params):i,o(a)}}}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class K{e;children;middlewares=[];handler=()=>({});constructor(e,t,r){this.viewPath=e;if(typeof t==="function")this.handler=t,this.children=class extends p{routes=r??{}};else if(Array.isArray(t)){const[n,s]=t,o=new n,a=o[s].bind(o);this.handler=(i)=>{let w=i;return w=o.requests[s]?new o.requests[s](i.rawRequest,i.params):w,a(i)},this.children=class extends p{routes=r??{}}}else this.children=class extends p{routes=t},this.handler=()=>({})}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class p{middlewares=[];routes={};view(e,t){return new g(e,t)}layout(e,t,r){return new K(e,t,r)}}var J="GEMI_REQUEST_BREAKER_ERROR";class u extends Error{constructor(){super(...arguments)}kind="GEMI_REQUEST_BREAKER_ERROR";payload={api:{},view:{}}}class d extends u{errors={};constructor(e){super("Validation error");this.name="ValidationError",this.errors=e,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:e}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}import{AsyncLocalStorage as v} from"async_hooks";class P{e;t;r;constructor(e,t,r={}){this.name=e;this.value=t;this.options=r}toString(){return[`${this.name}=${this.value}`,this.options.maxAge?`Max-Age=${this.options.maxAge}`:"",this.options.httpOnly?"HttpOnly":"",this.options.secure?"Secure":"",this.options.sameSite?`SameSite=${this.options.sameSite}`:"SameSite=Strict",this.options.path?`Path=${this.options.path}`:"Path=/",this.options.domain?`Domain=${this.options.domain}`:"",this.options.expires?`Expires=${this.options.expires.toUTCString()}`:"",this.options.partitioned?"Partitioned":""].filter((e)=>e!=="").join("; ")}}var m=new v;class O{cookies=new Set;user=null;req=null;constructor(){}setCookie(e,t,r={}){this.cookies.add(new P(e,t,r))}setUser(e){this.user=e}setRequest(e){this.req=e}}class c{static getStore(){return m.getStore()}static setRequest(e){m.getStore().req=e}static async run(e){return m.run(new O,e)}}var L=function(e){const[t,r]=e.split(":");switch(t){case"required":return(n)=>{return n!==null&&n!==void 0&&n?.length>0};case"password":return(n)=>{return/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(n)};case"number":return(n)=>{if(typeof n!=="number")return!1;return!isNaN(n)};case"min":return(n)=>{return n?.length>=parseInt(r)};case"max":return(n)=>{return n?.length<=parseInt(r)};case"email":return(n)=>{return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)};default:return()=>!0}};class I{e;constructor(e){this.data=e}get(e){return this.data[e]}set(e,t){this.data[e]=t}has(e){return this.data[e]!==void 0}toJSON(){return this.data}}class M{rawRequest;headers;cookies;schema={};params;ctx=c.getStore();constructor(e,t){this.params=t,this.rawRequest=e,this.headers=e.headers;const r=this.rawRequest.headers.get("Cookie"),n=new Map;if(r){const s=r.split(";");for(let o of s){const[a,i]=o.split("=");n.set(a.trim(),i.trim())}}this.cookies=n}refine(e){return{}}async parseBody(){const e=new I({});if(this.rawRequest.headers.get("Content-Type")==="application/json"){const t=await this.rawRequest.json();for(let[r,n]of Object.entries(t))e.set(r,n)}if(this.rawRequest.headers.get("Content-Type")==="application/x-www-form-urlencoded"){const t=await this.rawRequest.formData();for(let[r,n]of t)e.set(r,n)}if(this.rawRequest.headers.get("Content-Type").startsWith("multipart/form-data")){const t=await this.rawRequest.formData();for(let[r,n]of t)if(e.has(r)){const s=e.get(r);if(Array.isArray(s))s.push(n),e.set(r,s);else e.set(r,[s,n])}else e.set(r,n)}return e}validateInput(e){const t={};for(let[r,n]of Object.entries(this.schema))for(let[s,o]of Object.entries(n))if(!L(s)(e.get(r))){if(!t[r])t[r]=[];if(s==="required"){t[r]=[String(o)];break}else t[r].push(String(o))}for(let[r,n]of Object.entries(this.refine(e.toJSON())??{})){if(!t[r])t[r]=[];t[r]=[...t[r],n]}if(Object.keys(t).length>0)throw new d(t);else return e}async input(){return this.validateInput(await this.parseBody())}async safeInput(){const e=await this.parseBody();try{return this.validateInput(e),{isValid:!0,errors:{},input:e}}catch(t){if(!(t instanceof d))throw t;return{isValid:!1,errors:t.errors,input:e}}}async terminate(e){throw"not implemented"}}class T{async run(e){return{}}}function U(e){const t=e.headers.get("cookie");if(!t)return new Map;const r=new Map,n=t.split(";");for(let s of n){const[o,a]=s.split("=");r.set(o.trim(),a)}return r}class b{aliases={}}import{AsyncLocalStorage as _} from"async_hooks";var q=new _;class R{static getStore=()=>q.getStore()}class E extends u{error;constructor(e="Not authorized"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class A extends u{error;constructor(e="Insufficient permissions"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class y extends u{constructor(){super("Authentication error");this.name="AuthenticationError"}payload={api:{status:401,data:{error:"Authentication error"}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:"/auth/sign-in"}}}}class V extends T{constructor(){super(...arguments)}async run(e){const t=c.getStore(),r=t.req.cookies.get("access_token");if(!r)throw new y;let n=t.user;if(!n){const s=await R.getStore().authenticationServiceProvider.adapter.findSession({token:r,userAgent:t.req.headers.get("User-Agent")});if(!s)throw new y;n=s?.user,t.setUser(n)}return{}}}class S{policiesList={};constructor(){const e=this.register();for(let t of e){const r=new t;this.policiesList[t.name]=r}}register(){return[]}}class k{all(e,t){return!0}}export{U as getCookies,p as ViewRouter,d as ValidationError,C as ResourceController,u as RequestBreakerError,S as PoliciesServiceProvider,k as Policies,b as MiddlewareServiceProvider,T as Middleware,A as InsufficientPermissionsError,M as HttpRequest,h as Controller,E as AuthorizationError,V as AuthenticationMiddleware,y as AuthenticationError,x as ApiRouter};export{h as a,f as b,x as c,p as d,J as e,u as f,c as g,M as h,b as i,q as j,R as k,E as l,A as m,y as n,S as o};
|
package/dist/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{v as T,w as C} from"../chunk-d9a84b9122601b72.js";import{x as E} from"../chunk-a5c18c07abe8fd9c.js";import{
|
|
2
|
+
import{v as T,w as C} from"../chunk-d9a84b9122601b72.js";import{x as E} from"../chunk-a5c18c07abe8fd9c.js";import{va as L} from"../chunk-7399f06d840a1449.js";import S from"path";function g(r){return r.map((t,c)=>{if(t.isDev)return x("style",{type:"text/css","data-vite-dev-id":t.id,children:t.content},t.id,!1,void 0,this);else return x("style",{type:"text/css",children:t.content},c,!1,void 0,this)})}import{jsxDEV as x} from"react/jsx-dev-runtime";var P=E(L(),1);async function w(r){const t=new URL(r.url),c=t.searchParams.get("url"),u=Number(t.searchParams.get("w")),s=Number(t.searchParams.get("h")),i=t.searchParams.get("fit")??"cover",o=Number(t.searchParams.get("q"));if(!c)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});const p=`${c.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${c}`,e=await fetch(p);if(!e.ok)return new Response(JSON.stringify({error:"Image not found",info:p}),{headers:{"Content-Type":"application/json"},status:404});const n=Buffer.from(await e.arrayBuffer()),f=await P.default(n).resize(u>0?u:void 0,s>0?s:void 0,{fit:i}).webp({quality:o>0?o:80,force:!0}).toBuffer();return e.headers.delete("Content-Type"),e.headers.delete("Content-Length"),new Response(f,{headers:{"Content-Type":"image/webp","Content-Length":`${f.byteLength}`,...e.headers.toJSON()}})}function R(r){return`
|
|
3
3
|
<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|