gemi 0.4.44 → 0.4.47

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.
Files changed (122) hide show
  1. package/dist/app/App.d.ts.map +1 -1
  2. package/dist/app/index.js +19 -19
  3. package/dist/chunk-00e9dad0734d9761.js +1 -1
  4. package/dist/chunk-00ecc27f03e2e84a.js +2 -0
  5. package/dist/chunk-03c8e645c994d40a.js +1 -1
  6. package/dist/chunk-08e9ab1091d7383e.js +3 -0
  7. package/dist/chunk-0db33ac43bd1d504.js +2 -0
  8. package/dist/chunk-107dbe753ed86605.js +2 -0
  9. package/dist/chunk-132c71db605759c9.js +2 -0
  10. package/dist/chunk-14d5491e97673c7d.js +2 -0
  11. package/dist/chunk-1874b66d572fb0db.js +6 -0
  12. package/dist/chunk-1900e90c372bb1d6.js +1 -1
  13. package/dist/chunk-1d2c062034e3ed2d.js +9 -0
  14. package/dist/chunk-2665dffd37ead1d9.js +2 -0
  15. package/dist/chunk-29c46abebbc0f09b.js +1 -1
  16. package/dist/chunk-2a328e3beda74e4f.js +2 -0
  17. package/dist/chunk-2b3eabd01b2ae3f8.js +1 -1
  18. package/dist/chunk-3bedef94ef8dba4a.js +2 -0
  19. package/dist/chunk-3cbc1c9cdc091b43.js +2 -0
  20. package/dist/chunk-4cc2463d985f6882.js +9 -0
  21. package/dist/chunk-4d80485e7efb826f.js +2 -0
  22. package/dist/chunk-4e5485d3cfe9dc4e.js +2 -0
  23. package/dist/chunk-515c26d532207095.js +2 -0
  24. package/dist/chunk-55f76d4f6116f296.js +9 -0
  25. package/dist/chunk-590bd43a75f48606.js +18 -0
  26. package/dist/chunk-5a75eae6c32c2ba3.js +2 -0
  27. package/dist/chunk-5d51afe60efaf99e.js +2 -0
  28. package/dist/chunk-5d86d49d66db1c22.js +2 -0
  29. package/dist/chunk-5e13846c554dc272.js +2 -0
  30. package/dist/chunk-5fd67245740e3908.js +1 -1
  31. package/dist/chunk-63c5605bcce508ea.js +1 -0
  32. package/dist/chunk-64c89cee4d4bd9a9.js +2 -0
  33. package/dist/chunk-65626c3d72d4e071.js +2 -0
  34. package/dist/chunk-69ff5047661fe699.js +2 -0
  35. package/dist/chunk-6c461d293fa213f1.js +2 -0
  36. package/dist/chunk-6e06660ab4e9d4da.js +6 -0
  37. package/dist/chunk-7195a8718fcd8215.js +1 -0
  38. package/dist/chunk-73fb3bb4d001bb2e.js +1 -0
  39. package/dist/chunk-774337ca540a856d.js +2 -0
  40. package/dist/chunk-782dde0748025b5a.js +2 -0
  41. package/dist/chunk-78d6df0054754d5d.js +2 -0
  42. package/dist/chunk-7de7f34d46c76019.js +18 -0
  43. package/dist/chunk-80b17f9853d76e98.js +2 -0
  44. package/dist/chunk-81f5123a24c19089.js +2 -0
  45. package/dist/chunk-827d2c67c03d1a52.js +2 -0
  46. package/dist/chunk-8581aa9e876d46fb.js +2 -0
  47. package/dist/chunk-869d80d2e475b938.js +3 -0
  48. package/dist/chunk-895d9b1ef7a65211.js +1 -1
  49. package/dist/chunk-8c2b349a7198788f.js +6 -0
  50. package/dist/chunk-90c5196ff1f827a8.js +2 -0
  51. package/dist/chunk-934ebff128f86ef1.js +1 -0
  52. package/dist/chunk-98126e4b5bd19831.js +2 -0
  53. package/dist/chunk-99ba9dfd7c11383b.js +18 -0
  54. package/dist/chunk-a63e13c410e92923.js +2 -0
  55. package/dist/chunk-a7f3e9d5b7cf7c42.js +2 -0
  56. package/dist/chunk-a88c3919c74b7877.js +18 -0
  57. package/dist/chunk-aa1b1fb08828cb24.js +2 -0
  58. package/dist/chunk-acd4530b2ff92aff.js +18 -0
  59. package/dist/chunk-ae50ef54d7de9179.js +2 -0
  60. package/dist/chunk-ae7b1bdf00266d88.js +2 -0
  61. package/dist/chunk-af6b79a6ce7388ee.js +18 -0
  62. package/dist/chunk-b0cc82fa84d5362d.js +1 -1
  63. package/dist/chunk-b2bc43f60314d1a9.js +2 -0
  64. package/dist/chunk-b7b365f7e6038104.js +1 -1
  65. package/dist/chunk-b8d3d76e1dd9affe.js +2 -0
  66. package/dist/chunk-b9f4c1fce7152fc8.js +9 -0
  67. package/dist/chunk-c3e4a396dc7a5fe7.js +2 -0
  68. package/dist/chunk-c609d06153ed09ce.js +1 -1
  69. package/dist/chunk-c882d0c175c22c17.js +2 -0
  70. package/dist/chunk-ccfd101ce72e80bf.js +1 -0
  71. package/dist/chunk-d0806df6defd9dce.js +1 -1
  72. package/dist/chunk-d535b1e3078465f8.js +2 -0
  73. package/dist/chunk-d54843c1d8516c75.js +2 -0
  74. package/dist/chunk-d665d3ee2a62d48b.js +2 -0
  75. package/dist/chunk-d9762bab5df03532.js +2 -0
  76. package/dist/chunk-e1a08bb52ee7ea09.js +1 -1
  77. package/dist/chunk-e3e996b3821027e1.js +2 -0
  78. package/dist/chunk-e4869466459233fa.js +16 -0
  79. package/dist/chunk-e64d5a7b7e0fa2c5.js +6 -0
  80. package/dist/chunk-f077321ef55ea627.js +1 -0
  81. package/dist/chunk-f32726d374c6bee5.js +1 -0
  82. package/dist/chunk-f5200f44395bf49d.js +3 -0
  83. package/dist/chunk-f900b5868b14827e.js +2 -0
  84. package/dist/chunk-f9a17b871b527bff.js +2 -0
  85. package/dist/chunk-feaaa37d30cd1e9b.js +2 -0
  86. package/dist/client/ClientRouter.d.ts.map +1 -1
  87. package/dist/client/ClientRouterContext.d.ts +4 -0
  88. package/dist/client/ClientRouterContext.d.ts.map +1 -1
  89. package/dist/client/Link.d.ts +2 -1
  90. package/dist/client/Link.d.ts.map +1 -1
  91. package/dist/client/ProgressManager.d.ts +16 -0
  92. package/dist/client/ProgressManager.d.ts.map +1 -0
  93. package/dist/client/i18n/I18nContext.d.ts +1 -1
  94. package/dist/client/i18n/I18nContext.d.ts.map +1 -1
  95. package/dist/client/i18n/useScopedTranslator.d.ts +3 -6
  96. package/dist/client/i18n/useScopedTranslator.d.ts.map +1 -1
  97. package/dist/client/index.d.ts +3 -1
  98. package/dist/client/index.d.ts.map +1 -1
  99. package/dist/client/index.js +205 -31
  100. package/dist/client/useIsNavigationPending.d.ts +2 -0
  101. package/dist/client/useIsNavigationPending.d.ts.map +1 -0
  102. package/dist/client/useNavigate.d.ts.map +1 -1
  103. package/dist/client/useNavigationProgress.d.ts +2 -0
  104. package/dist/client/useNavigationProgress.d.ts.map +1 -0
  105. package/dist/facades/I18n.d.ts +4 -2
  106. package/dist/facades/I18n.d.ts.map +1 -1
  107. package/dist/facades/index.js +1 -1
  108. package/dist/http/HttpRequest.d.ts +5 -2
  109. package/dist/http/HttpRequest.d.ts.map +1 -1
  110. package/dist/http/I18nServiceContainer.d.ts +1 -0
  111. package/dist/http/I18nServiceContainer.d.ts.map +1 -1
  112. package/dist/http/index.js +1 -1
  113. package/dist/kernel/index.js +2 -2
  114. package/dist/server/index.js +1 -1
  115. package/dist/storage/index.js +4 -4
  116. package/dist/utils/applyTranslationParams.d.ts +2 -0
  117. package/dist/utils/applyTranslationParams.d.ts.map +1 -0
  118. package/dist/utils/sleep.d.ts +2 -0
  119. package/dist/utils/sleep.d.ts.map +1 -0
  120. package/dist/utils/type.d.ts +3 -0
  121. package/dist/utils/type.d.ts.map +1 -1
  122. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"../chunk-7ce930fe69575c87.js";class T{requests={};static kind="controller";constructor(){}}class C extends T{constructor(){super(...arguments)}}function H(e){return typeof e==="function"&&e.prototype!==void 0}var v=function(e){return H(e)};class u{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(v(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 K{constructor(...e){return new u(...e)}}class P{routes={};middlewares=[];middleware(e){}get(e,t){return new u("GET",e,t)}post(e,t){return new u("POST",e,t)}put(e,t){return new u("PUT",e,t)}patch(e,t){return new u("PATCH",e,t)}delete(e,t){return new u("DELETE",e,t)}resource(e){class t extends P{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 K("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 O{e;children;middlewares=[];handler=()=>({});constructor(e,t,r){this.viewPath=e;if(typeof t==="function")this.handler=t,this.children=class extends d{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 d{routes=r??{}}}else this.children=class extends d{routes=t},this.handler=()=>({})}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class d{middlewares=[];routes={};view(e,t){return new g(e,t)}layout(e,t,r){return new O(e,t,r)}}var W="GEMI_REQUEST_BREAKER_ERROR";class l extends Error{constructor(){super(...arguments)}kind="GEMI_REQUEST_BREAKER_ERROR";payload={api:{},view:{}}}class p 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}}}}import{AsyncLocalStorage as L} from"async_hooks";class h{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 L;class I{cookies=new Set;headers=new Headers;user=null;req=null;constructor(){}setCookie(e,t,r={}){this.cookies.add(new h(e,t,r))}setHeaders(e,t){this.headers.set(e,t)}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 I,e)}}var U=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 R{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 R({});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(!U(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 p(t);else return e}async input(){if(this.rawRequest.method==="GET"){const e=new URL(this.rawRequest.url),t=Object.fromEntries(e.searchParams.entries());return this.validateInput(new R(t))}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 p))throw t;return{isValid:!1,errors:t.errors,input:e}}}async terminate(e){throw"not implemented"}}class x{async run(e){return{}}}function _(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 D} from"async_hooks";var q=new D;class f{static getStore=()=>q.getStore()}class E 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 A 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 y 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"}}}}class S extends x{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 f.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 V{policiesList={};constructor(){const e=this.register();for(let t of e){const r=new t;this.policiesList[t.name]=r}}register(){return[]}}class ${all(e,t){return!0}}class k{dictionary={};supportedLocales=[];defaultLocale="en-US";async init(){}detectLocale(e){return this.defaultLocale}}export{_ as getCookies,d as ViewRouter,p as ValidationError,C as ResourceController,l as RequestBreakerError,V as PoliciesServiceProvider,$ as Policies,b as MiddlewareServiceProvider,x as Middleware,A as InsufficientPermissionsError,k as I18nServiceProvider,M as HttpRequest,T as Controller,E as AuthorizationError,S as AuthenticationMiddleware,y as AuthenticationError,P as ApiRouter};export{T as a,H as b,P as c,d,W as e,l as f,c as g,M as h,b as i,q as j,f as k,E as l,A as m,y as n,V as o,k as p};
2
+ import"../chunk-7ce930fe69575c87.js";class P{requests={};static kind="controller";constructor(){}}class f extends P{constructor(){super(...arguments)}}function H(e){return typeof e==="function"&&e.prototype!==void 0}var L=function(e){return H(e)};class u{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(L(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 K{constructor(...e){return new u(...e)}}class h{routes={};middlewares=[];middleware(e){}get(e,t){return new u("GET",e,t)}post(e,t){return new u("POST",e,t)}put(e,t){return new u("PUT",e,t)}patch(e,t){return new u("PATCH",e,t)}delete(e,t){return new u("DELETE",e,t)}resource(e){class t extends h{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 K("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[n,r]=t,s=new n,o=s[r].bind(s);this.handler=(i)=>{let a=i;return a=s.requests[r]?new s.requests[r](i.rawRequest,i.params):a,o(i)}}}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class O{e;children;middlewares=[];handler=()=>({});constructor(e,t,n){this.viewPath=e;if(typeof t==="function")this.handler=t,this.children=class extends p{routes=n??{}};else if(Array.isArray(t)){const[r,s]=t,o=new r,i=o[s].bind(o);this.handler=(a)=>{let d=a;return d=o.requests[s]?new o.requests[s](a.rawRequest,a.params):d,i(a)},this.children=class extends p{routes=n??{}}}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,n){return new O(e,t,n)}}var Z="GEMI_REQUEST_BREAKER_ERROR";class l extends Error{constructor(){super(...arguments)}kind="GEMI_REQUEST_BREAKER_ERROR";payload={api:{},view:{}}}class c 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}}}}import{AsyncLocalStorage as U} from"async_hooks";class m{e;t;n;constructor(e,t,n={}){this.name=e;this.value=t;this.options=n}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 R=new U;class I{cookies=new Set;headers=new Headers;user=null;req=null;constructor(){}setCookie(e,t,n={}){this.cookies.add(new m(e,t,n))}setHeaders(e,t){this.headers.set(e,t)}setUser(e){this.user=e}setRequest(e){this.req=e}}class y{static getStore(){return R.getStore()}static setRequest(e){R.getStore().req=e}static async run(e){return R.run(new I,e)}}var v=function(e){const[t,n]=e.match(/\d+|\D+/g)??[];if(!t||!n)return 0;const r=parseInt(t);switch(n){case"B":return r;case"KB":return r*1024;case"MB":return r*1024*1024;case"GB":return r*1024*1024*1024;case"TB":return r*1024*1024*1024*1024;default:return 0}},D=function(e){switch(e){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return e}},G=function(e){const[t,n]=e.split(":");switch(t){case"required":return(r)=>{if(r instanceof Blob)return r.size>0;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)};case"file":return(r)=>{return r instanceof Blob};case"fileType":return(r)=>{if(r instanceof Blob){const s=D(n);return r.type.startsWith(s)}};case"fileSize":return(r)=>{if(r instanceof Blob){const s=v(n);return r.size<=s}};default:return()=>!0}};class w{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=y.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 s=n.split(";");for(let o of s){const[i,a]=o.split("=");r.set(i.trim(),a.trim())}}this.cookies=r}refine(e){return{}}async parseBody(){const e=new w({});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 s=e.get(n);if(Array.isArray(s))s.push(r),e.set(n,s);else e.set(n,[s,r])}else e.set(n,r)}return e}validateInput(e){const t={};for(let[n,r]of Object.entries(this.schema))for(let[s,o]of Object.entries(r)){const i=G(s);let a=o,d=!1;if(typeof o==="function")a=o(e.get(n)),d=typeof a==="undefined";else d=i(e.get(n));if(d)continue;if(!t[n])t[n]=[];if(s==="required"){t[n]=[String(a)];break}else t[n].push(String(a))}for(let[n,r]of Object.entries(this.refine(e.toJSON())??{})){if(!t[n])t[n]=[];t[n]=[...t[n],r]}if(Object.keys(t).length>0)throw new c(t);else return e}async input(){if(this.rawRequest.method==="GET"){const e=new URL(this.rawRequest.url),t=Object.fromEntries(e.searchParams.entries());return this.validateInput(new w(t))}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 c))throw t;return{isValid:!1,errors:t.errors,input:e}}}async terminate(e){throw"not implemented"}}class T{async run(e){return{}}}function N(e){const t=e.headers.get("cookie");if(!t)return new Map;const n=new Map,r=t.split(";");for(let s of r){const[o,i]=s.split("=");n.set(o.trim(),i)}return n}class q{aliases={}}import{AsyncLocalStorage as _} from"async_hooks";var b=new _;class C{static getStore=()=>b.getStore()}class E 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 A 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 x 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"}}}}class V extends T{constructor(){super(...arguments)}async run(e){const t=y.getStore(),n=t.req.cookies.get("access_token");if(!n)throw new x;let r=t.user;if(!r){const s=await C.getStore().authenticationServiceProvider.adapter.findSession({token:n,userAgent:t.req.headers.get("User-Agent")});if(!s)throw new x;r=s?.user,t.setUser(r)}return{}}}class ${policiesList={};constructor(){const e=this.register();for(let t of e){const n=new t;this.policiesList[t.name]=n}}register(){return[]}}class k{all(e,t){return!0}}class S{dictionary={};supportedLocales=[];defaultLocale="en-US";async init(){}detectLocale(e){return this.defaultLocale}}export{N as getCookies,p as ViewRouter,c as ValidationError,f as ResourceController,l as RequestBreakerError,$ as PoliciesServiceProvider,k as Policies,q as MiddlewareServiceProvider,T as Middleware,A as InsufficientPermissionsError,S as I18nServiceProvider,M as HttpRequest,P as Controller,E as AuthorizationError,V as AuthenticationMiddleware,x as AuthenticationError,h as ApiRouter};export{P as a,H as b,h as c,p as d,Z as e,l as f,y as g,M as h,q as i,b as j,C as k,E as l,A as m,x as n,$ as o,S as p};