gemi 0.72.0 → 0.72.1

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 (36) hide show
  1. package/dist/ai/index.js +1 -1
  2. package/dist/{chunk-qb1x1r58.js → chunk-0j8v3dd3.js} +1 -1
  3. package/dist/{chunk-c8jt128x.js → chunk-akbawnmg.js} +1 -1
  4. package/dist/{chunk-481t5ewt.js → chunk-ebdtwzzr.js} +1 -1
  5. package/dist/{chunk-fpx20wm3.js → chunk-t2t2qcj4.js} +2 -2
  6. package/dist/{chunk-fpx20wm3.js.map → chunk-t2t2qcj4.js.map} +1 -1
  7. package/dist/chunk-t48gchew.js +5 -0
  8. package/dist/{chunk-3zraw16t.js.map → chunk-t48gchew.js.map} +5 -5
  9. package/dist/{chunk-0x9a9yha.js → chunk-vqxpknyg.js} +1 -1
  10. package/dist/facades/Storage.d.ts +6 -2
  11. package/dist/facades/Storage.d.ts.map +1 -1
  12. package/dist/facades/index.js +1 -1
  13. package/dist/http/index.js +1 -1
  14. package/dist/i18n/index.js +1 -1
  15. package/dist/kernel/index.js +1 -1
  16. package/dist/server/index.js +1 -1
  17. package/dist/services/file-storage/drivers/AzureBlobDriver.d.ts +2 -2
  18. package/dist/services/file-storage/drivers/AzureBlobDriver.d.ts.map +1 -1
  19. package/dist/services/file-storage/drivers/FileStorageDriver.d.ts +11 -1
  20. package/dist/services/file-storage/drivers/FileStorageDriver.d.ts.map +1 -1
  21. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts +2 -1
  22. package/dist/services/file-storage/drivers/FileSystemDriver.d.ts.map +1 -1
  23. package/dist/services/file-storage/drivers/S3Driver.d.ts +2 -1
  24. package/dist/services/file-storage/drivers/S3Driver.d.ts.map +1 -1
  25. package/dist/services/file-storage/drivers/types.d.ts +9 -0
  26. package/dist/services/file-storage/drivers/types.d.ts.map +1 -1
  27. package/dist/services/index.d.ts +1 -1
  28. package/dist/services/index.d.ts.map +1 -1
  29. package/dist/services/index.js +5 -5
  30. package/dist/services/index.js.map +4 -4
  31. package/package.json +1 -1
  32. package/dist/chunk-3zraw16t.js +0 -5
  33. /package/dist/{chunk-qb1x1r58.js.map → chunk-0j8v3dd3.js.map} +0 -0
  34. /package/dist/{chunk-c8jt128x.js.map → chunk-akbawnmg.js.map} +0 -0
  35. /package/dist/{chunk-481t5ewt.js.map → chunk-ebdtwzzr.js.map} +0 -0
  36. /package/dist/{chunk-0x9a9yha.js.map → chunk-vqxpknyg.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemi",
3
- "version": "0.72.0",
3
+ "version": "0.72.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Enes Tufekci <enes@gemijs.dev>",
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{qf as O}from"./chunk-z99bj1mv.js";import{mg as b}from"./chunk-26n9365a.js";import{zg as c}from"./chunk-25a65e4r.js";import{Gg as o}from"./chunk-5fxqzs72.js";class N{static kind="controller";constructor(){}}class h extends N{}function j(H){let R=new Map;if(!H)return R;for(let J of H.split(";")){let K=J.indexOf("=");if(K===-1)continue;let D=J.slice(0,K).trim();if(!D)continue;R.set(D,J.slice(K+1).trim())}return R}function t(H){return j(H.headers.get("cookie"))}function $(H){if(!/^\d+$/.test(H))return null;let R=Number(H);return Number.isSafeInteger(R)?R:null}function z(H){if(!H)return null;let R=H.trim();if(!/^bytes=/i.test(R))return null;let K=R.slice(6).split(",").map((X)=>X.trim()).filter((X)=>X!=="");if(K.length!==1)return null;let D=K[0],G=D.indexOf("-");if(G===-1)return null;let Q=D.slice(0,G),T=D.slice(G+1);if(Q===""){let X=$(T);if(X===null)return null;return{kind:"suffix",suffixLength:X}}let P=$(Q);if(P===null)return null;if(T==="")return{kind:"offset",start:P,end:null};let W=$(T);if(W===null||W<P)return null;return{kind:"offset",start:P,end:W}}function E(H,R){if(!Number.isFinite(R)||R<=0)return null;let J,K;if(H.kind==="suffix"){if(H.suffixLength<=0)return null;J=Math.max(0,R-H.suffixLength),K=R-1}else{if(H.start>=R)return null;if(J=H.start,K=H.end===null?R-1:Math.min(H.end,R-1),K<J)return null}return{start:J,end:K,length:K-J+1}}function a(H){if(H.kind==="suffix")return`bytes=-${H.suffixLength}`;return H.end===null?`bytes=${H.start}-`:`bytes=${H.start}-${H.end}`}function e(H){if(!H)return null;let R=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(H.trim());if(!R)return null;let J=$(R[1]),K=$(R[2]),D=$(R[3]);if(J===null||K===null||D===null||K<J)return null;return{start:J,end:K,total:D}}function HH(H,R,J){return`bytes ${H}-${R}/${J}`}function q(H){return`bytes */${H}`}var RH="GEMI_REQUEST_BREAKER_ERROR";class Y extends Error{kind="GEMI_REQUEST_BREAKER_ERROR";payload={api:{},view:{}}}class U extends Y{errors={};constructor(H){super("Validation error");this.name="ValidationError",this.errors=H,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:H}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}var x=new WeakMap;function PH(H,R){x.set(H,{clientAddress:R})}function I(H){return x.has(H)}function QH(H){return x.get(H)?.clientAddress}var S=new WeakMap;function WH(H,R){S.set(H,R)}function _(H){return S.get(H)??null}function v(H){let[R,J]=H.match(/\d+|\D+/g)??[];if(!R||!J)return 0;let K=Number.parseInt(R);switch(J){case"B":return K;case"KB":return K*1024;case"MB":return K*1024*1024;case"GB":return K*1024*1024*1024;case"TB":return K*1024*1024*1024*1024;default:return 0}}function m(H){switch(H){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 H}}function F(H){if(typeof H==="string"||Array.isArray(H))return H.length;return}function w(H){return typeof H==="number"&&!Number.isNaN(H)}function k(H){let[R,J]=H.split(":");switch(R){case"required":return(K)=>{if(K instanceof Blob)return K.size>0;if(K===null||K===void 0)return!1;if(typeof K==="string"||Array.isArray(K))return K.length>0;return!0};case"password":return(K)=>{return/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(K)};case"number":return(K)=>{if(typeof K!=="number")return!1;return!Number.isNaN(K)};case"min":return(K)=>{let D=F(K);return D!==void 0&&D>=Number.parseInt(J)};case"max":return(K)=>{let D=F(K);return D!==void 0&&D<=Number.parseInt(J)};case"gte":return(K)=>w(K)&&K>=Number(J);case"lte":return(K)=>w(K)&&K<=Number(J);case"email":return(K)=>{return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(K)};case"file":return(K)=>{return K instanceof Blob};case"fileType":return(K)=>{if(K instanceof Blob){let D=m(J);return K.type.startsWith(D)}};case"fileSize":return(K)=>{if(K instanceof Blob){let D=v(J);return K.size<=D}};default:return()=>!0}}class C{data;constructor(H){this.data=H}get(H){return this.data[H]}has(H){return this.data[H]!==void 0}toJSON(){return this.data}}class d{kind;rawRequest;headers;cookies;search;schema={};routePath;params;domain;constructor(H,R,J,K){if(!H){let P=O.getStore().req;this.params=P.params,this.rawRequest=P.rawRequest,this.kind=P.kind,this.routePath=P.routePath,this.domain=P.domain??null}else this.params=R,this.rawRequest=H,this.routePath=K,this.kind=J??"api",this.domain=_(H);this.headers=this.rawRequest.headers;let D=j(this.rawRequest.headers.get("Cookie")),G=new URL(this.rawRequest.url),Q=new Map;for(let[P,W]of G.searchParams)if(Q.has(P)){let X=Q.get(P);if(Array.isArray(X))X.push(W),Q.set(P,X);else Q.set(P,[X,W])}else Q.set(P,W);let T=Object.fromEntries(Q.entries());this.search=new C(T),this.cookies=D}locale(){return O.getStore().locale}ctx(){return O.getStore()}isModelOriginated(){return I(this.rawRequest)}range(){return z(this.rawRequest.headers.get("Range"))}refine(H){return{}}async parseBody(){let H=new C({});if(this.rawRequest.headers.get("Content-Type")==="application/json"){let R=await this.rawRequest.json();H=new C(R)}if(this.rawRequest.headers.get("Content-Type")==="application/x-www-form-urlencoded"){let R=await this.rawRequest.formData();H=new C(R)}if(this.rawRequest.headers.get("Content-Type")?.startsWith("multipart/form-data")){let R=await this.rawRequest.formData(),J=new Map;for(let[K,D]of R.entries())if(J.has(K)){let G=J.get(K);if(Array.isArray(G))G.push(D),J.set(K,G);else J.set(K,[G,D])}else J.set(K,D);H=new C(Object.fromEntries(J.entries()))}return H}validateInput(H){let R={};for(let[J,K]of Object.entries(this.schema))for(let[D,G]of Object.entries(K)){let Q=k(D),T=G,P=!1;if(typeof G==="function")T=G(H.get(J)),P=typeof T>"u";else P=Q(H.get(J));if(P)continue;if(!H.get(J)&&!Object.keys(K).includes("required"))continue;if(!R[J])R[J]=[];if(D==="required"){R[J]=[String(T)];continue}R[J].push(String(T))}for(let[J,K]of Object.entries(this.refine(H.toJSON())??{})){if(!R[J])R[J]=[];R[J]=[...R[J]??[],K]}if(Object.keys(R).length>0)throw new U(R);return H}async input(){return this.validateInput(await this.parseBody())}async safeInput(){let H=await this.parseBody();try{return this.validateInput(H),{isValid:!0,errors:{},input:H}}catch(R){if(!(R instanceof U))throw R;return{isValid:!1,errors:R.errors,input:H}}}}class p extends Y{error;constructor(H="Not authorized"){super(H);this.name="AuthorizationError",this.error=H,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class y extends Y{static apiStatus=403;error;constructor(H="Insufficient permissions"){super(H);this.name="InsufficientPermissionsError",this.error=H,this.payload={api:{status:y.apiStatus,data:{error:this.error}},view:{status:403}}}}class A extends Y{total;constructor(H){super("Range not satisfiable");this.total=H;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:{message:"Range not satisfiable"}},headers:{"Content-Range":q(H),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class Z extends Y{fileName;constructor(H){super("File not found");this.fileName=H;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:{message:"Not found"}},headers:{"Cache-Control":"no-store"}},view:{}}}}class i extends Y{constructor(H={}){super("Authentication error");this.name="AuthenticationError";let R=H.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:"Authentication error"}},viewData:{status:200,data:{},headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate"},directive:{kind:"Redirect",path:R}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:R}}}}}class L{static getFacadeAccessor(){throw Error(`Facade [${this.name}] does not implement getFacadeAccessor().`)}static getFacadeRoot(){return b(this.getFacadeAccessor())}}class B{async read(H){let R=typeof H==="string"?{name:H}:H,J=await this.fetch({name:R.name,bucket:R.bucket});if(!J.ok)throw new Z(R.name);let K=J.headers.get("Content-Type")??"application/octet-stream",D=J.headers.get("ETag")??void 0,G=J.headers.get("Last-Modified"),Q=G?new Date(G):void 0;if(R.range){let W=await J.blob();return{body:W,start:0,end:W.size-1,total:W.size,partial:!1,type:K,etag:D,lastModified:Q,name:R.name}}let T=Number(J.headers.get("Content-Length")),P=Number.isFinite(T)?T:0;return{body:J.body,start:0,end:P-1,total:P,partial:!1,type:K,etag:D,lastModified:Q,name:R.name}}async size(H){let R=typeof H==="string"?H:H.name,J=typeof H==="string"?void 0:H.bucket,K=await this.fetch({name:R,bucket:J});if(!K.ok)throw new Z(R);let D=Number(K.headers.get("Content-Length"));if(Number.isFinite(D))return await K.body?.cancel(),D;return(await K.blob()).size}}import{readdir as u}from"fs/promises";class M extends B{configured;constructor(H){super();this.configured=H}get folderPath(){return this.configured??`${c()}/storage`}async put(H,{signal:R}={}){R?.throwIfAborted();let J,K;if(H instanceof Blob)J=H,K=`${Bun.randomUUIDv7()}.${H.type.split("/")[1].split(";")[0]}`;else J=H.body,K=H.name;let D=J instanceof Buffer?J:J instanceof Blob||J instanceof File?Buffer.from(await J.arrayBuffer()):"",G=`${this.folderPath}/${K}`;return R?.throwIfAborted(),await Bun.write(G,D),K}async fetch(H){let R=process.env.BUCKET_NAME,J;if(typeof H==="string")J=H;else R=H.bucket??R,J=H.name;if(!J)throw Error("Object name has to be specified");let K=`${this.folderPath}/${J}`,D=Bun.file(K),G=Bun.file(K).stream(),Q=new Date(D.lastModified).toUTCString();return new Response(G,{headers:{"Content-Type":D.type,"Content-Length":String(D.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Q}})}async read(H){let R=typeof H==="string"?{name:H}:H,{name:J,range:K=null}=R;if(!J)throw Error("Object name has to be specified");let D=Bun.file(`${this.folderPath}/${J}`);if(!await D.exists())throw new Z(J);let G=D.size,Q=K?E(K,G):null;if(K&&!Q)throw new A(G);let T=Q?.start??0,P=Q?Q.end:G-1;return{body:Q?D.slice(T,P+1):D,start:T,end:P,total:G,partial:Boolean(Q),type:D.type||"application/octet-stream",lastModified:new Date(D.lastModified),name:J}}async size(H){let R=typeof H==="string"?H:H.name,J=Bun.file(`${this.folderPath}/${R}`);if(!await J.exists())throw new Z(R);return J.size}async list(){return await u(this.folderPath)}}function yH(H){return H}function f(){return{driver:new M}}class V{static token="filesystem";driver;constructor(H={}){this.driver=H.driver??f().driver}}import{Buffer as l}from"buffer";async function g(H){try{return(await import("sharp")).default}catch(R){throw Error(`${H} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:R})}}class n extends L{static getFacadeAccessor(){return V}static async put(H,R={}){return this.getFacadeRoot().driver.put(H,R)}static async metadata(H){let R=l.from(await H.arrayBuffer()),J=await g("Storage.metadata()");try{return await J(R).metadata()}catch{return{}}}static async fetch(H){return this.getFacadeRoot().driver.fetch(H)}static async read(H,R={}){let J=typeof H==="string"?{name:H}:{...H},K="range"in R?R.range??null:J.range!==void 0?J.range:O.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...J,range:K})}static list(H){return this.getFacadeRoot().driver.list(H)}static delete(){}}
3
- export{N as Le,h as Me,j as Ne,t as Oe,PH as Pe,QH as Qe,z as Re,E as Se,a as Te,e as Ue,HH as Ve,q as We,WH as Xe,_ as Ye,RH as Ze,Y as _e,U as $e,d as af,p as bf,y as cf,A as df,Z as ef,i as ff,L as gf,g as hf,B as if,M as jf,yH as kf,f as lf,V as mf,n as nf};
4
-
5
- //# debugId=7D1751C797AD711564756E2164756E21