gemi 0.4.21 → 0.4.23
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/app/index.js +1 -1
- package/dist/auth/adapters/prisma.d.ts.map +1 -1
- package/dist/bin/index.js +56 -488
- package/dist/chunk-8b3d411f441a43ce.js +2 -0
- package/dist/email/index.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/server/index.js +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as l,v as P} from"./chunk-c8f1115d77efc1c0.js";class h{requests={};static kind="controller";constructor(){}}class R extends h{constructor(){super(...arguments)}}function w(e){return typeof e==="function"&&e.prototype!==void 0}var C=function(e){return w(e)};class d{e;t;n;middlewares=[];constructor(e,t,n){this.method=e;this.handler=t;this.methodName=n;this.handler=t,this.methodName=n,this.method=e}run(e){let t=e;if(C(this.handler)){const n=new this.handler,r=n[this.methodName].bind(n);return t=n.requests[this.methodName]?new n.requests[this.methodName](e.rawRequest,e.params):t,r(t)}else return this.handler(e)}middleware(e){return this.middlewares=e,this}}class m{routes={};middlewares=[];middleware(e){}get(e,t){return new d("GET",e,t)}post(e,t){return new d("POST",e,t)}put(e,t){return new d("PUT",e,t)}patch(e,t){return new d("PATCH",e,t)}delete(e,t){return new d("DELETE",e,t)}resource(e){class t extends m{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}}class f{routes={};middlewares=[];middleware(e){}layout(e,t,n){function r(o=[]){let s=n??{};if(t&&t.constructor===Object)s=t;return{exec:async(i)=>{let a=()=>Promise.resolve({data:{[e]:{}},headers:{},head:{}});if(typeof t==="function")a=t;if(Array.isArray(t)){const[T,y]=t,p=new T;a=p[y].bind(p)}const c=await a(i);return{[e]:c}},children:s,viewPath:e,middlewares:o,kind:"layout"}}return{prepare:r,middleware:(o)=>({prepare:()=>r(o)})}}view(e,t,n){function r(o=[]){let s=n??{};if(t&&t.constructor===Object)s=t;return{exec:async(i)=>{let a=()=>Promise.resolve({data:{[e]:{}},headers:{},head:{}});if(typeof t==="function")a=t;if(Array.isArray(t)){const[T,y]=t,p=new T;a=p[y].bind(p)}const c=await a(i);return{[e]:c}},children:s,viewPath:e,middlewares:o,kind:"view"}}return{prepare:r,middleware:(o)=>({prepare:()=>r(o)})}}}class u extends l{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}}}}class H extends l{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 g extends l{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 K extends l{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"}}}}var b=function(e){const[t,n]=e.split(":");switch(t){case"required":return(r)=>{return r!==null&&r!==void 0&&r?.length>0};case"password":return(r)=>{return/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(r)};case"number":return(r)=>{if(typeof r!=="number")return!1;return!isNaN(r)};case"min":return(r)=>{return r?.length>=parseInt(n)};case"max":return(r)=>{return r?.length<=parseInt(n)};case"email":return(r)=>{return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)};default:return()=>!0}};class x{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 O{rawRequest;headers;cookies;schema={};params;ctx=P.getStore();constructor(e,t){this.params=t,this.rawRequest=e,this.headers=e.headers;const n=this.rawRequest.headers.get("Cookie"),r=new Map;if(n){const o=n.split(";");for(let s of o){const[i,a]=s.split("=");r.set(i.trim(),a.trim())}}this.cookies=r}async parseBody(){const e=new x({});if(this.rawRequest.headers.get("Content-Type")==="application/json"){const t=await this.rawRequest.json();for(let[n,r]of Object.entries(t))e.set(n,r)}if(this.rawRequest.headers.get("Content-Type")==="application/x-www-form-urlencoded"){const t=await this.rawRequest.formData();for(let[n,r]of t)e.set(n,r)}if(this.rawRequest.headers.get("Content-Type").startsWith("multipart/form-data")){const t=await this.rawRequest.formData();for(let[n,r]of t)if(e.has(n)){const o=e.get(n);if(Array.isArray(o))o.push(r),e.set(n,o);else e.set(n,[o,r])}else e.set(n,r)}return e}validateInput(e){const t={};for(let[n,r]of Object.entries(this.schema))for(let[o,s]of Object.entries(r))if(!b(o)(e.get(n))){if(!t[n])t[n]=[];if(o==="required"){t[n]=[String(s)];break}else t[n].push(String(s))}if(Object.keys(t).length>0)throw new u(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 u))throw t;return{isValid:!1,errors:t.errors,input:e}}}async terminate(e){throw"not implemented"}}class M{aliases={}}class I{policiesList={};constructor(){const e=this.register();for(let t of e){const n=new t;this.policiesList[t.name]=n}}register(){return[]}}
|
|
2
|
+
export{h as d,R as e,w as f,m as g,f as h,u as i,H as j,g as k,K as l,O as m,M as n,I as o};
|
package/dist/email/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"../facades/index.js";import{b as w,c} from"../kernel/index.js";import"../chunk-
|
|
2
|
+
import"../facades/index.js";import{b as w,c} from"../kernel/index.js";import"../chunk-8b3d411f441a43ce.js";import"../chunk-9350baa090b5a424.js";import"../chunk-c8f1115d77efc1c0.js";import{renderToStaticMarkup as u} from"react-dom/server";var x=(t)=>{return`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">${u(t)}`};class s{static async send(t,r){const e=new t,{to:a=e.to,from:l=e.from,subject:m=e.subject,cc:p=e.cc,bcc:T=e.bcc,attachments:d=e.attachments,data:E}=r,n=x(e.render(E));if(process.env.EMAIL_DEBUG){const o=`${process.env.ROOT_DIR}/.debug/emails/${(new Date()).toISOString()}${m}.html`;await Bun.write(o,n),Bun.spawnSync(["open",o]);return}await c.getContext().emailServiceProvider.send({bcc:T,cc:p,from:l,subject:m,to:a,attachments:d,html:n})}}import{createElement as f,Fragment as g} from"react";class i{from="doe@gemijs.dev";to=["hi@gemijs.dev"];subject="Welcome";cc=[];bcc=[];attachments=[];render(t){return console.log("EmailTemplate"),f(g,null,"EmailTemplate")}}export{i as EmailTemplate,w as EmailServiceProvider,s as Email};
|
package/dist/http/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{d,e as x,g,h as w,i as k,l as n,m as R,n as h,o as C} from"../chunk-
|
|
2
|
+
import{d,e as x,g,h as w,i as k,l as n,m as R,n as h,o as C} from"../chunk-8b3d411f441a43ce.js";import"../chunk-9350baa090b5a424.js";import{u as q,v as a,x as p} from"../chunk-c8f1115d77efc1c0.js";class s{async run(o){return{}}}function l(o){const e=o.headers.get("cookie");if(!e)return new Map;const r=new Map,t=e.split(";");for(let i of t){const[m,f]=i.split("=");r.set(m.trim(),f)}return r}class c extends s{constructor(){super(...arguments)}async run(o){const e=a.getStore(),r=e.req.cookies.get("access_token");if(!r)throw new n;let t=e.user;if(!t){const i=await p.getStore().authenticationServiceProvider.adapter.findSession({token:r,userAgent:e.req.headers.get("User-Agent")});if(!i)throw new n;t=i?.user,e.setUser(t)}return{}}}class u{all(o,e){return!0}}export{l as getCookies,w as ViewRouter,k as ValidationError,x as ResourceController,q as RequestBreakerError,C as PoliciesServiceProvider,u as Policies,h as MiddlewareServiceProvider,s as Middleware,R as HttpRequest,d as Controller,c as AuthenticationMiddleware,n as AuthenticationError,g as ApiRouter};
|