gemi 0.243.0 → 0.244.0

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.
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{$f as h,Ah as v,Dg as q,Og as r,Pg as s,Qg as t,Rg as u,Vf as a,Yf as c,Zf as e,_f as f,ag as i,bg as j,ig as k,jg as l,kg as m,lg as n,mg as o,ng as p}from"../chunk-1dc3kxdd.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{Dj as d}from"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import{Oj as b,Sj as g}from"../chunk-54v3y7mg.js";import"../chunk-110ecy3e.js";import"../chunk-26pfh03x.js";import"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import"../chunk-e0e43wvq.js";import"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import"../chunk-hhaxacwh.js";import"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import"../chunk-7ztbpqed.js";export{f as Url,d as Storage,r as Runs,j as Redis,a as Redirect,l as RateLimiter,e as Query,h as Meta,g as Log,m as Lock,c as Lang,s as Features,b as Facade,u as DB,n as Crypt,i as Cookie,o as Connections,t as ConnectionQueries,p as ChangeFeed,k as Cache,q as Broadcast,v as Auth};
2
+ import{$f as h,Ah as v,Dg as q,Og as r,Pg as s,Qg as t,Rg as u,Vf as a,Yf as c,Zf as e,_f as f,ag as i,bg as j,ig as k,jg as l,kg as m,lg as n,mg as o,ng as p}from"../chunk-v040m0k2.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{Dj as d}from"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import{Oj as b,Sj as g}from"../chunk-54v3y7mg.js";import"../chunk-110ecy3e.js";import"../chunk-26pfh03x.js";import"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import"../chunk-e0e43wvq.js";import"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import"../chunk-hhaxacwh.js";import"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import"../chunk-7ztbpqed.js";export{f as Url,d as Storage,r as Runs,j as Redis,a as Redirect,l as RateLimiter,e as Query,h as Meta,g as Log,m as Lock,c as Lang,s as Features,b as Facade,u as DB,n as Crypt,i as Cookie,o as Connections,t as ConnectionQueries,p as ChangeFeed,k as Cache,q as Broadcast,v as Auth};
3
3
 
4
4
  //# debugId=6F46750519274BB664756E2164756E21
@@ -7,11 +7,13 @@ export declare const SAME_SITE_BOUNCE_PARAM = "gemi_same_site";
7
7
  * another site: an OAuth connection's callback, a payment provider's return
8
8
  * URL.
9
9
  *
10
- * The `access_token` cookie is `SameSite=Strict`, so the browser leaves it off
11
- * a top-level navigation that another site started — the provider's redirect
12
- * back included. `auth` then sees nobody and sends a signed-in user to the
13
- * sign-in page. Listed ahead of `auth`, this answers such a request with a
14
- * tiny page that loads the same URL again from this origin
10
+ * gemi writes `access_token` `SameSite=Lax`, which a top-level `GET` from
11
+ * another site carries. A cookie written `SameSite=Strict` (by gemi before it
12
+ * switched to `Lax`, until the session is next written; or by an app that
13
+ * overrides `accessTokenCookieOptions`) is left off such a navigation — the
14
+ * provider's redirect back included. `auth` then sees nobody and sends a
15
+ * signed-in user to the sign-in page. Listed ahead of `auth`, this answers
16
+ * such a request with a tiny page that loads the same URL again from this origin
15
17
  * (`<meta http-equiv="refresh">`, no script). That second navigation is
16
18
  * same-site, the cookie goes with it, and `auth` runs as usual.
17
19
  *
@@ -1 +1 @@
1
- {"version":3,"file":"SameSiteBounceMiddleware.d.ts","sourceRoot":"","sources":["../../http/SameSiteBounceMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,wBAAyB,SAAQ,UAAU;IACtD,GAAG;CAsBJ;AAED,+EAA+E;AAC/E,qBAAa,cAAe,SAAQ,mBAAmB;IAClC,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM;CAiCpC"}
1
+ {"version":3,"file":"SameSiteBounceMiddleware.d.ts","sourceRoot":"","sources":["../../http/SameSiteBounceMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,wBAAyB,SAAQ,UAAU;IACtD,GAAG;CAsBJ;AAED,+EAA+E;AAC/E,qBAAa,cAAe,SAAQ,mBAAmB;IAClC,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM;CAiCpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createStreamResponse.d.ts","sourceRoot":"","sources":["../../http/createStreamResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,UAAU,GAClB,IAAI,GACJ,cAAc,CAAC,UAAU,CAAC,GAC1B,WAAW,GACX,eAAe,CAAC;AAEpB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uGAAuG;IACvG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GACvC,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GACtB,IAAI,GACJ,QAAQ,GACR,gBAAgB,GAChB,IAAI,GACJ,SAAS,CAAC;AA4Bd,4EAA4E;AAC5E,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAcnE;AAyDD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAGxC,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EACrD,OAAO,EAAE;IAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACpD,OAAO,CAAC,QAAQ,CAAC,CAqGnB"}
1
+ {"version":3,"file":"createStreamResponse.d.ts","sourceRoot":"","sources":["../../http/createStreamResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,UAAU,GAClB,IAAI,GACJ,cAAc,CAAC,UAAU,CAAC,GAC1B,WAAW,GACX,eAAe,CAAC;AAEpB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uGAAuG;IACvG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GACvC,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GACtB,IAAI,GACJ,QAAQ,GACR,gBAAgB,GAChB,IAAI,GACJ,SAAS,CAAC;AA4Bd,4EAA4E;AAC5E,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAcnE;AAyDD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAGxC,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EACrD,OAAO,EAAE;IAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACpD,OAAO,CAAC,QAAQ,CAAC,CA0GnB"}
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{$e as t,Bh as ba,Ch as ca,Dh as da,Gh as ea,Hh as fa,Ih as ga,Jh as ha,Kh as ia,Lh as ja,Mh as ka,Nh as la,Oh as ma,Ph as na,Qh as oa,Rh as pa,Sh as qa,Tf as K,Th as ra,Uf as L,Uh as sa,Vh as ta,Wf as M,Wh as ua,Xf as N,Xh as va,Zg as aa,af as u,bf as v,cf as w,df as x,ef as E,jf as F,nf as G,of as H,pf as I,qf as J}from"../chunk-1dc3kxdd.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{$i as A,Aj as $,Ci as e,Di as f,Ei as g,Fi as h,Gi as i,Hi as j,Ki as n,Pi as o,Qi as p,Ri as q,Si as r,Xi as s,Zi as y,_i as z,aj as B,bj as C,cj as D,mj as O,nj as P,oj as Q,pj as R,qj as S,rj as T,sj as U,tj as V,uj as W,vi as a,vj as X,wi as b,wj as Y,xi as d,yj as Z,zj as _}from"../chunk-093j5rh8.js";import{Hj as c}from"../chunk-632nqkza.js";import"../chunk-54v3y7mg.js";import{Vj as k,Wj as l,Xj as m}from"../chunk-110ecy3e.js";import"../chunk-26pfh03x.js";import"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import"../chunk-e0e43wvq.js";import"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import"../chunk-hhaxacwh.js";import"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import"../chunk-7ztbpqed.js";export{g as toRangeHeaderValue,v as toMiddlewareList,k as stateKey,$ as safeFetch,f as resolveRange,e as parseRangeHeader,h as parseContentRange,r as parseByteSize,ja as middlewareConfigDefaults,u as httpError,d as getCookies,j as formatUnsatisfiedContentRange,i as formatContentRange,ra as defineResourcePolicy,ia as defineMiddlewareConfig,n as cspNonce,w as createUnsatisfiableResponse,x as createStreamResponse,M as createFileResponse,I as clientIp,J as clientAddress,Z as classifyAddress,da as authorizeChannel,N as ViewRouter,o as ValidationError,W as TooManyRedirectsError,U as TooLargeError,T as TimeoutError,sa as SitemapError,ta as Sitemap,L as SameSiteBounceMiddleware,_ as SafeResponse,O as SafeFetchError,K as SAME_SITE_BOUNCE_PARAM,ua as RobotsTxt,va as Robots,qa as ResourcePolicy,b as ResourceController,m as RequestState,c as RequestBreakerError,H as RateLimitMiddleware,F as RateLimitExceededError,A as RangeNotSatisfiableError,oa as PoliciesServiceProvider,pa as Policies,q as PayloadTooLargeError,B as NotFoundError,X as NetworkError,l as MissingRequestStateError,G as Middleware,ga as McpToolDeclaration,ha as McpRouter,fa as McpRouteDeclaration,ea as McpModelParam,p as InvalidValidationRuleError,P as InvalidUrlError,z as InsufficientPermissionsError,Y as HttpStatusError,t as HttpResponse,s as HttpRequest,C as FileNotFoundError,S as DnsError,ma as CorsMiddleware,a as Controller,V as ContentTypeError,ca as ChannelRouter,ba as ChannelDeclaration,la as CacheMiddleware,na as CSRFMiddleware,aa as BodyLimitMiddleware,Q as BlockedHostError,R as BlockedAddressError,y as AuthorizationError,ka as AuthenticationMiddleware,D as AuthenticationError,E as ApiRouter};
2
+ import{$e as t,Bh as ba,Ch as ca,Dh as da,Gh as ea,Hh as fa,Ih as ga,Jh as ha,Kh as ia,Lh as ja,Mh as ka,Nh as la,Oh as ma,Ph as na,Qh as oa,Rh as pa,Sh as qa,Tf as K,Th as ra,Uf as L,Uh as sa,Vh as ta,Wf as M,Wh as ua,Xf as N,Xh as va,Zg as aa,af as u,bf as v,cf as w,df as x,ef as E,jf as F,nf as G,of as H,pf as I,qf as J}from"../chunk-v040m0k2.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{$i as A,Aj as $,Ci as e,Di as f,Ei as g,Fi as h,Gi as i,Hi as j,Ki as n,Pi as o,Qi as p,Ri as q,Si as r,Xi as s,Zi as y,_i as z,aj as B,bj as C,cj as D,mj as O,nj as P,oj as Q,pj as R,qj as S,rj as T,sj as U,tj as V,uj as W,vi as a,vj as X,wi as b,wj as Y,xi as d,yj as Z,zj as _}from"../chunk-093j5rh8.js";import{Hj as c}from"../chunk-632nqkza.js";import"../chunk-54v3y7mg.js";import{Vj as k,Wj as l,Xj as m}from"../chunk-110ecy3e.js";import"../chunk-26pfh03x.js";import"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import"../chunk-e0e43wvq.js";import"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import"../chunk-hhaxacwh.js";import"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import"../chunk-7ztbpqed.js";export{g as toRangeHeaderValue,v as toMiddlewareList,k as stateKey,$ as safeFetch,f as resolveRange,e as parseRangeHeader,h as parseContentRange,r as parseByteSize,ja as middlewareConfigDefaults,u as httpError,d as getCookies,j as formatUnsatisfiedContentRange,i as formatContentRange,ra as defineResourcePolicy,ia as defineMiddlewareConfig,n as cspNonce,w as createUnsatisfiableResponse,x as createStreamResponse,M as createFileResponse,I as clientIp,J as clientAddress,Z as classifyAddress,da as authorizeChannel,N as ViewRouter,o as ValidationError,W as TooManyRedirectsError,U as TooLargeError,T as TimeoutError,sa as SitemapError,ta as Sitemap,L as SameSiteBounceMiddleware,_ as SafeResponse,O as SafeFetchError,K as SAME_SITE_BOUNCE_PARAM,ua as RobotsTxt,va as Robots,qa as ResourcePolicy,b as ResourceController,m as RequestState,c as RequestBreakerError,H as RateLimitMiddleware,F as RateLimitExceededError,A as RangeNotSatisfiableError,oa as PoliciesServiceProvider,pa as Policies,q as PayloadTooLargeError,B as NotFoundError,X as NetworkError,l as MissingRequestStateError,G as Middleware,ga as McpToolDeclaration,ha as McpRouter,fa as McpRouteDeclaration,ea as McpModelParam,p as InvalidValidationRuleError,P as InvalidUrlError,z as InsufficientPermissionsError,Y as HttpStatusError,t as HttpResponse,s as HttpRequest,C as FileNotFoundError,S as DnsError,ma as CorsMiddleware,a as Controller,V as ContentTypeError,ca as ChannelRouter,ba as ChannelDeclaration,la as CacheMiddleware,na as CSRFMiddleware,aa as BodyLimitMiddleware,Q as BlockedHostError,R as BlockedAddressError,y as AuthorizationError,ka as AuthenticationMiddleware,D as AuthenticationError,E as ApiRouter};
3
3
 
4
4
  //# debugId=753E70D4855B633664756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{ra as T}from"../chunk-zrqqnfrs.js";import"../chunk-hke4hzfm.js";import{pb as D}from"../chunk-8dga75cv.js";import{Ye as b,Ze as w}from"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{Yf as j}from"../chunk-1dc3kxdd.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import"../chunk-54v3y7mg.js";import"../chunk-110ecy3e.js";import"../chunk-26pfh03x.js";import"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import"../chunk-e0e43wvq.js";import"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import{pm as V,qm as X,rm as E,sm as L,tm as R,um as S}from"../chunk-hhaxacwh.js";import"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import"../chunk-7ztbpqed.js";import{createElement as J,Fragment as M,isValidElement as U}from"react";function $(q,B){let G=Object.values(B).some((z)=>typeof z==="function"&&U(z(""))),Q=/{{([^{}]+?)(?::([^{}\[\]]+?))?(?:\[(.*?)\])?}}/g;if(!G)return q.replace(Q,(W,O,_,Z)=>{let C=O.includes(":")?O.split(":")[0]:O,H=B[C];if(H===void 0)return W;if(typeof H==="function"){let K=H(Z!==void 0?Z:"");if(U(K))throw Error("JSX returned in string context");return String(K)}if(_)switch(_.toLowerCase()){case"number":return Number(H).toString();case"string":return String(H);case"boolean":return Boolean(H).toString();default:return String(H)}return String(H)});else{let z=[],W=0,O=null;while((O=Q.exec(q))!==null){let[_,Z,C,H]=O,F=O.index,K=Z.includes(":")?Z.split(":")[0]:Z;if(F>W)z.push(q.substring(W,F));let Y=B[K];if(Y===void 0)z.push(_);else if(typeof Y==="function"){let A=Y(H!==void 0?H:"");z.push(A)}else if(C)switch(C.toLowerCase()){case"number":z.push(Number(Y).toString());break;case"string":z.push(String(Y));break;case"boolean":z.push(Boolean(Y).toString());break;default:z.push(String(Y))}else z.push(String(Y));W=F+_.length}if(W<q.length)z.push(q.substring(W));return J(M,{},...z)}}class P{name;dictionary;constructor(q,B){this.name=q;this.dictionary=B}reference(q){if(typeof window<"u")throw Error("Cannot use reference in the browser");if(!this.dictionary?.[q])throw Error(`Translation not found for ${String(q)}`);return this.dictionary[q]}render(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B[0]};if(typeof window<"u")throw Error("Cannot use render in the browser");if(!this.dictionary?.[q]?.[G])throw Error(`Translation not found for ${String(q)} in ${String(G)}`);return $(this.dictionary[q][G],Q??{})}static create(q,B){return new P(q,B)}static text(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B?.[0]};if(!q?.[G])throw Error(`Translation not found for ${String(G)}`);return $(q[G],Q??{})}}async function N(q,B,...G){let{locale:Q=j.locale(),params:z}={params:{},...G[0]},O=(await q.load(String(Q)))[B];if(typeof O!=="string")throw Error(`Translation not found for "${B}" in "${String(Q)}" (dictionary ${q.id})`);return $(O,z??{})}export{w as translationConfigDefaults,N as translate,V as resolveLocale,X as negotiateLocale,L as isValidTimeZone,b as defineTranslationConfig,T as defineDictionary,R as createFormatter,S as Translator,D as TranslationServiceProvider,P as Dictionary,E as DEFAULT_TIME_ZONE};
2
+ import{ra as T}from"../chunk-zrqqnfrs.js";import"../chunk-hke4hzfm.js";import{pb as D}from"../chunk-8dga75cv.js";import{Ye as b,Ze as w}from"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{Yf as j}from"../chunk-v040m0k2.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import"../chunk-54v3y7mg.js";import"../chunk-110ecy3e.js";import"../chunk-26pfh03x.js";import"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import"../chunk-e0e43wvq.js";import"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import{pm as V,qm as X,rm as E,sm as L,tm as R,um as S}from"../chunk-hhaxacwh.js";import"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import"../chunk-7ztbpqed.js";import{createElement as J,Fragment as M,isValidElement as U}from"react";function $(q,B){let G=Object.values(B).some((z)=>typeof z==="function"&&U(z(""))),Q=/{{([^{}]+?)(?::([^{}\[\]]+?))?(?:\[(.*?)\])?}}/g;if(!G)return q.replace(Q,(W,O,_,Z)=>{let C=O.includes(":")?O.split(":")[0]:O,H=B[C];if(H===void 0)return W;if(typeof H==="function"){let K=H(Z!==void 0?Z:"");if(U(K))throw Error("JSX returned in string context");return String(K)}if(_)switch(_.toLowerCase()){case"number":return Number(H).toString();case"string":return String(H);case"boolean":return Boolean(H).toString();default:return String(H)}return String(H)});else{let z=[],W=0,O=null;while((O=Q.exec(q))!==null){let[_,Z,C,H]=O,F=O.index,K=Z.includes(":")?Z.split(":")[0]:Z;if(F>W)z.push(q.substring(W,F));let Y=B[K];if(Y===void 0)z.push(_);else if(typeof Y==="function"){let A=Y(H!==void 0?H:"");z.push(A)}else if(C)switch(C.toLowerCase()){case"number":z.push(Number(Y).toString());break;case"string":z.push(String(Y));break;case"boolean":z.push(Boolean(Y).toString());break;default:z.push(String(Y))}else z.push(String(Y));W=F+_.length}if(W<q.length)z.push(q.substring(W));return J(M,{},...z)}}class P{name;dictionary;constructor(q,B){this.name=q;this.dictionary=B}reference(q){if(typeof window<"u")throw Error("Cannot use reference in the browser");if(!this.dictionary?.[q])throw Error(`Translation not found for ${String(q)}`);return this.dictionary[q]}render(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B[0]};if(typeof window<"u")throw Error("Cannot use render in the browser");if(!this.dictionary?.[q]?.[G])throw Error(`Translation not found for ${String(q)} in ${String(G)}`);return $(this.dictionary[q][G],Q??{})}static create(q,B){return new P(q,B)}static text(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B?.[0]};if(!q?.[G])throw Error(`Translation not found for ${String(G)}`);return $(q[G],Q??{})}}async function N(q,B,...G){let{locale:Q=j.locale(),params:z}={params:{},...G[0]},O=(await q.load(String(Q)))[B];if(typeof O!=="string")throw Error(`Translation not found for "${B}" in "${String(Q)}" (dictionary ${q.id})`);return $(O,z??{})}export{w as translationConfigDefaults,N as translate,V as resolveLocale,X as negotiateLocale,L as isValidTimeZone,b as defineTranslationConfig,T as defineDictionary,R as createFormatter,S as Translator,D as TranslationServiceProvider,P as Dictionary,E as DEFAULT_TIME_ZONE};
3
3
 
4
4
  //# debugId=73462ACCF320941B64756E2164756E21
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ta as E}from"../chunk-n537kc55.js";import{ob as l}from"../chunk-s0azv6dd.js";import{pb as H}from"../chunk-8dga75cv.js";import{$b as I,Cb as g,Db as W,Eb as _,Fb as p,Gb as P,Hb as u,Ib as $,Jb as V,Kb as q,Lb as B,Mb as K,Qb as L,Rb as Q,Sb as T,Wb as U,Xb as y,Yb as F,Zb as C,_b as D,dc as b,gc as f,hc as k,ic as m}from"../chunk-j26v29x8.js";import"../chunk-t77xnb8k.js";import"../chunk-11hmhyk5.js";import"../chunk-27f9z8yk.js";import"../chunk-w9v8bbp8.js";import{Se as h}from"../chunk-vh6vc4h1.js";import"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{Rf as n,Sf as v,qh as w,uh as A,vf as d,wf as s,yh as R}from"../chunk-1dc3kxdd.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import"../chunk-54v3y7mg.js";import"../chunk-110ecy3e.js";import"../chunk-26pfh03x.js";import{jk as M}from"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import"../chunk-e0e43wvq.js";import"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import"../chunk-kjz6jh54.js";import"../chunk-hhaxacwh.js";import{vm as O,xm as J}from"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import"../chunk-7ztbpqed.js";var N=[C,I,E,T,L,k,B,Q,D,y,_,U,f,V,F,H,b,K,q,m,$];class S{config={};providers=[];services=[];serviceInstances=[];serviceTokens=new Set;servicesBooted=!1;models=[];app=new J;boot(){if(this.models.length>0)l(...this.models);else a();this.app.config.merge(this.config),J.setInstance(this.app),this.app.registerMany([...N,...this.providers]),this.registerServices()}registerServices(){let j=this.serviceTokens;this.serviceInstances=[],this.serviceTokens=new Set,this.servicesBooted=!1;let X=new Map;for(let z of this.services){let G=typeof z==="function"?new z:z,x=G.constructor;if(!x.token)throw Error(`Service [${x.name}] is listed in \`services\` but does not declare a \`static token\`.`);let Y=X.get(x.token);if(Y)throw Error(`Services [${Y}] and [${x.name}] both declare the token "${x.token}". Tokens are the container's keys, so they must be unique.`);X.set(x.token,x.name);let Z=x;if(!j.has(x.token)&&this.app.bound(Z))throw Error(`Service [${x.name}] declares the token "${x.token}", which is already bound in the container by the framework or a provider. Binding it would replace that service everywhere, so pick a token nothing else owns.`);this.app.instance(Z,G),this.serviceInstances.push(G),this.serviceTokens.add(x.token)}this.app.setShutdownHooks(this.serviceInstances.map((z)=>({name:`${z.constructor.name}.onShutdown`,shutdown:(G)=>z.onShutdown(G)})))}async waitForBoot(){await this.app.boot(),await this.bootServices(),p(this.app)}async bootServices(){if(this.servicesBooted)return;for(let j of this.serviceInstances)await j.boot();this.servicesBooted=!0}shutdown(j){return this.run(()=>this.app.shutdown(j))}run(j){return O.run(this.app,j)}resolve(j){return this.app.make(j)}apiRoutes(){return this.app.make(A)}viewRoutes(){return this.app.make(w)}domains(){return this.app.make(R)}queue(){return this.app.make(h)}mcpHttp(){return this.app.config.get("route.mcp.remote.enabled")===!0?this.app.make(g):null}sockets(){return this.app.config.get("route.channels")?this.app.make(u):null}globalMiddleware(j){return P(j)}destroy(){if(this.app.resolved(W))this.app.make(W).stop();if(this.app.flush(),J.getInstance()===this.app)J.setInstance(void 0);O.disable()}}function a(){if(Bun.env.NODE_ENV==="production")return;let j=M();if(j.length===0)return;console.warn(`[gemi] ${j.length} model${j.length===1?" is":"s are"} registered, but Kernel.models is empty.
2
+ import{Ta as E}from"../chunk-n537kc55.js";import{ob as l}from"../chunk-s0azv6dd.js";import{pb as H}from"../chunk-8dga75cv.js";import{$b as I,Cb as g,Db as W,Eb as _,Fb as p,Gb as P,Hb as u,Ib as $,Jb as V,Kb as q,Lb as B,Mb as K,Qb as L,Rb as Q,Sb as T,Wb as U,Xb as y,Yb as F,Zb as C,_b as D,dc as b,gc as f,hc as k,ic as m}from"../chunk-q94v5skw.js";import"../chunk-t77xnb8k.js";import"../chunk-11hmhyk5.js";import"../chunk-27f9z8yk.js";import"../chunk-w9v8bbp8.js";import{Se as h}from"../chunk-vh6vc4h1.js";import"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{Rf as n,Sf as v,qh as w,uh as A,vf as d,wf as s,yh as R}from"../chunk-v040m0k2.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import"../chunk-54v3y7mg.js";import"../chunk-110ecy3e.js";import"../chunk-26pfh03x.js";import{jk as M}from"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import"../chunk-e0e43wvq.js";import"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import"../chunk-kjz6jh54.js";import"../chunk-hhaxacwh.js";import{vm as O,xm as J}from"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import"../chunk-7ztbpqed.js";var N=[C,I,E,T,L,k,B,Q,D,y,_,U,f,V,F,H,b,K,q,m,$];class S{config={};providers=[];services=[];serviceInstances=[];serviceTokens=new Set;servicesBooted=!1;models=[];app=new J;boot(){if(this.models.length>0)l(...this.models);else a();this.app.config.merge(this.config),J.setInstance(this.app),this.app.registerMany([...N,...this.providers]),this.registerServices()}registerServices(){let j=this.serviceTokens;this.serviceInstances=[],this.serviceTokens=new Set,this.servicesBooted=!1;let X=new Map;for(let z of this.services){let G=typeof z==="function"?new z:z,x=G.constructor;if(!x.token)throw Error(`Service [${x.name}] is listed in \`services\` but does not declare a \`static token\`.`);let Y=X.get(x.token);if(Y)throw Error(`Services [${Y}] and [${x.name}] both declare the token "${x.token}". Tokens are the container's keys, so they must be unique.`);X.set(x.token,x.name);let Z=x;if(!j.has(x.token)&&this.app.bound(Z))throw Error(`Service [${x.name}] declares the token "${x.token}", which is already bound in the container by the framework or a provider. Binding it would replace that service everywhere, so pick a token nothing else owns.`);this.app.instance(Z,G),this.serviceInstances.push(G),this.serviceTokens.add(x.token)}this.app.setShutdownHooks(this.serviceInstances.map((z)=>({name:`${z.constructor.name}.onShutdown`,shutdown:(G)=>z.onShutdown(G)})))}async waitForBoot(){await this.app.boot(),await this.bootServices(),p(this.app)}async bootServices(){if(this.servicesBooted)return;for(let j of this.serviceInstances)await j.boot();this.servicesBooted=!0}shutdown(j){return this.run(()=>this.app.shutdown(j))}run(j){return O.run(this.app,j)}resolve(j){return this.app.make(j)}apiRoutes(){return this.app.make(A)}viewRoutes(){return this.app.make(w)}domains(){return this.app.make(R)}queue(){return this.app.make(h)}mcpHttp(){return this.app.config.get("route.mcp.remote.enabled")===!0?this.app.make(g):null}sockets(){return this.app.config.get("route.channels")?this.app.make(u):null}globalMiddleware(j){return P(j)}destroy(){if(this.app.resolved(W))this.app.make(W).stop();if(this.app.flush(),J.getInstance()===this.app)J.setInstance(void 0);O.disable()}}function a(){if(Bun.env.NODE_ENV==="production")return;let j=M();if(j.length===0)return;console.warn(`[gemi] ${j.length} model${j.length===1?" is":"s are"} registered, but Kernel.models is empty.
3
3
  Nested relation reads resolve a model by name, so a policy on a subclass that does not own its
4
4
  `+" name is skipped inside every include \u2014 scoped at the root, "+`unscoped in an include, with nothing
5
5
  to notice it. Declaring the modules registers each class under its own name and audits the set:
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Ra as f}from"../chunk-ba1h9pm6.js";import{Sa as A}from"../chunk-5pfbqc1c.js";import{Hm as Q,Jm as q,Km as w,Nm as Z,Om as P,Pm as y,Qm as S,Rm as U}from"../chunk-3ywtqcxt.js";import{Vm as H}from"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import{bn as F}from"../chunk-7ztbpqed.js";var x="/__gemi__/health",$=Symbol.for("gemi.server.health");function V(){let z=globalThis;return z[$]??={lagMs:0,consecutiveBreaches:0,degraded:!1,timer:void 0},z[$]}function W(){let z=V(),B=Q();return{healthy:!B&&!z.degraded,shuttingDown:B,lagMs:z.lagMs,consecutiveBreaches:z.consecutiveBreaches}}function E(z,B){let I=V();I.lagMs=z,I.consecutiveBreaches=z>B.maxLagMs?I.consecutiveBreaches+1:0;let J=I.consecutiveBreaches>=B.breaches;if(J&&!I.degraded)console.warn(`[gemi] Health: degraded (event-loop lag ${Math.round(z)}ms, ${I.consecutiveBreaches} samples in a row over ${B.maxLagMs}ms).`);else if(!J&&I.degraded)console.log(`[gemi] Health: recovered (event-loop lag ${Math.round(z)}ms).`);I.degraded=J}function G(z){let B=V();if(B.timer)return;let I=performance.now()+z.intervalMs;B.timer=setInterval(()=>{let J=performance.now();E(Math.max(0,J-I),z),I=J+z.intervalMs},z.intervalMs),B.timer.unref?.()}function _(z=process.env){return{paths:D(z.GEMI_HEALTH_PATH),intervalMs:O("GEMI_HEALTH_INTERVAL_MS",z.GEMI_HEALTH_INTERVAL_MS,500),maxLagMs:O("GEMI_HEALTH_MAX_LAG_MS",z.GEMI_HEALTH_MAX_LAG_MS,1000),breaches:Math.ceil(O("GEMI_HEALTH_BREACHES",z.GEMI_HEALTH_BREACHES,3))}}function D(z){if(z===void 0||z.trim()==="")return[x];if(z.trim().toLowerCase()==="off")return[];let B=z.split(",").map((J)=>J.trim()).filter(Boolean);if(B.filter((J)=>!J.startsWith("/")).length>0)throw Error(`GEMI_HEALTH_PATH: expected comma-separated paths starting with "/", or "off"; got ${JSON.stringify(z)}.`);return B}function O(z,B,I){if(B===void 0||B.trim()==="")return I;let J=Number(B);if(Number.isFinite(J)&&J>0)return J;return console.warn(`[gemi] Ignoring ${z}="${B}": expected a positive number.`),I}function j(z,B){if(B.length===0)return z;let I=new Set(B);return async(J,K)=>{if(!B.some((b)=>J.url.includes(b))||!I.has(new URL(J.url).pathname))return z(J,K);return y(R(J.method))}}function R(z){let B={"Cache-Control":"no-store","Content-Type":"text/plain; charset=utf-8"};if(z!=="GET"&&z!=="HEAD")return new Response("Method Not Allowed",{status:405,headers:{...B,Allow:"GET, HEAD"}});let{healthy:I,shuttingDown:J}=W();return new Response(z==="HEAD"?null:I?"ok":J?"shutting down":"degraded",{status:I?200:503,headers:B})}var L=Symbol.for("gemi.server.devGeneration"),X={graceMs:1e4,providerTimeoutMs:5000};class Y{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,I)=>{this.inFlight++;try{return await z(B,I)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(I){C(I)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let I=()=>{clearTimeout(J),this.waiters.delete(I),B()},J=setTimeout(I,z);this.waiters.add(I)})}wake(){for(let z of this.waiters)z()}}function N(z,B=X){let I=globalThis,J=I[L];if(I[L]=z,!J||J===z||typeof J.retire!=="function")return Promise.resolve();let K=J.retire.bind(J);return Promise.resolve().then(()=>K(B)).catch(C)}function C(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class k{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=S(z.instrumentation??((B,I)=>I(B)))}async start(){process.env.ROOT_DIR=H();let z=Bun.env.NODE_ENV==="production",B=_();if(z)G(B);let I=j(this.instrumentation,B.paths);if(z){if(this.handleSignals)U(()=>this.stop());this.settings=Z()}try{await this.app.waitForBoot()}catch(J){if(!z)this.app.shutdown({timeoutMs:X.providerTimeoutMs});throw J}if(z){let{httpProd:J}=await import("../chunk-3cct08cr.js");this.server=await J(this.app,I)}else{f();let{httpDev:J}=await import("../chunk-yc3t7zky.js"),K=new Y(this.app);this.server=await J(this.app,K.track(I)),N(K)}return this.server}stop(z={}){let B=this.app.sockets();return this.stopping??=P({server:this.server,closeSockets:B?()=>B.shutdown():void 0,shutdownProviders:(I)=>this.app.shutdown(I),settings:{...this.settings??Z(),...z}}),this.stopping}}export{q as shutdownSignal,W as liveness,Q as isShuttingDown,w as holdShutdown,k as Server};
2
+ import{Ra as f}from"../chunk-ba1h9pm6.js";import{Sa as A}from"../chunk-5pfbqc1c.js";import{Hm as Q,Jm as q,Km as w,Nm as Z,Om as P,Pm as y,Qm as S,Rm as U}from"../chunk-3ywtqcxt.js";import{Vm as H}from"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import{bn as F}from"../chunk-7ztbpqed.js";var x="/__gemi__/health",$=Symbol.for("gemi.server.health");function V(){let z=globalThis;return z[$]??={lagMs:0,consecutiveBreaches:0,degraded:!1,timer:void 0},z[$]}function W(){let z=V(),B=Q();return{healthy:!B&&!z.degraded,shuttingDown:B,lagMs:z.lagMs,consecutiveBreaches:z.consecutiveBreaches}}function E(z,B){let I=V();I.lagMs=z,I.consecutiveBreaches=z>B.maxLagMs?I.consecutiveBreaches+1:0;let J=I.consecutiveBreaches>=B.breaches;if(J&&!I.degraded)console.warn(`[gemi] Health: degraded (event-loop lag ${Math.round(z)}ms, ${I.consecutiveBreaches} samples in a row over ${B.maxLagMs}ms).`);else if(!J&&I.degraded)console.log(`[gemi] Health: recovered (event-loop lag ${Math.round(z)}ms).`);I.degraded=J}function G(z){let B=V();if(B.timer)return;let I=performance.now()+z.intervalMs;B.timer=setInterval(()=>{let J=performance.now();E(Math.max(0,J-I),z),I=J+z.intervalMs},z.intervalMs),B.timer.unref?.()}function _(z=process.env){return{paths:D(z.GEMI_HEALTH_PATH),intervalMs:O("GEMI_HEALTH_INTERVAL_MS",z.GEMI_HEALTH_INTERVAL_MS,500),maxLagMs:O("GEMI_HEALTH_MAX_LAG_MS",z.GEMI_HEALTH_MAX_LAG_MS,1000),breaches:Math.ceil(O("GEMI_HEALTH_BREACHES",z.GEMI_HEALTH_BREACHES,3))}}function D(z){if(z===void 0||z.trim()==="")return[x];if(z.trim().toLowerCase()==="off")return[];let B=z.split(",").map((J)=>J.trim()).filter(Boolean);if(B.filter((J)=>!J.startsWith("/")).length>0)throw Error(`GEMI_HEALTH_PATH: expected comma-separated paths starting with "/", or "off"; got ${JSON.stringify(z)}.`);return B}function O(z,B,I){if(B===void 0||B.trim()==="")return I;let J=Number(B);if(Number.isFinite(J)&&J>0)return J;return console.warn(`[gemi] Ignoring ${z}="${B}": expected a positive number.`),I}function j(z,B){if(B.length===0)return z;let I=new Set(B);return async(J,K)=>{if(!B.some((b)=>J.url.includes(b))||!I.has(new URL(J.url).pathname))return z(J,K);return y(R(J.method))}}function R(z){let B={"Cache-Control":"no-store","Content-Type":"text/plain; charset=utf-8"};if(z!=="GET"&&z!=="HEAD")return new Response("Method Not Allowed",{status:405,headers:{...B,Allow:"GET, HEAD"}});let{healthy:I,shuttingDown:J}=W();return new Response(z==="HEAD"?null:I?"ok":J?"shutting down":"degraded",{status:I?200:503,headers:B})}var L=Symbol.for("gemi.server.devGeneration"),X={graceMs:1e4,providerTimeoutMs:5000};class Y{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,I)=>{this.inFlight++;try{return await z(B,I)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(I){C(I)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let I=()=>{clearTimeout(J),this.waiters.delete(I),B()},J=setTimeout(I,z);this.waiters.add(I)})}wake(){for(let z of this.waiters)z()}}function N(z,B=X){let I=globalThis,J=I[L];if(I[L]=z,!J||J===z||typeof J.retire!=="function")return Promise.resolve();let K=J.retire.bind(J);return Promise.resolve().then(()=>K(B)).catch(C)}function C(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class k{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=S(z.instrumentation??((B,I)=>I(B)))}async start(){process.env.ROOT_DIR=H();let z=Bun.env.NODE_ENV==="production",B=_();if(z)G(B);let I=j(this.instrumentation,B.paths);if(z){if(this.handleSignals)U(()=>this.stop());this.settings=Z()}try{await this.app.waitForBoot()}catch(J){if(!z)this.app.shutdown({timeoutMs:X.providerTimeoutMs});throw J}if(z){let{httpProd:J}=await import("../chunk-2mtm1yt6.js");this.server=await J(this.app,I)}else{f();let{httpDev:J}=await import("../chunk-fwmzms6e.js"),K=new Y(this.app);this.server=await J(this.app,K.track(I)),N(K)}return this.server}stop(z={}){let B=this.app.sockets();return this.stopping??=P({server:this.server,closeSockets:B?()=>B.shutdown():void 0,shutdownProviders:(I)=>this.app.shutdown(I),settings:{...this.settings??Z(),...z}}),this.stopping}}export{q as shutdownSignal,W as liveness,Q as isShuttingDown,w as holdShutdown,k as Server};
3
3
 
4
4
  //# debugId=E7CDDBF367A7809664756E2164756E21
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{rb as z$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,ic as J$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-j26v29x8.js";import{lc as d4}from"../chunk-t77xnb8k.js";import"../chunk-11hmhyk5.js";import{he as D9,ie as H9,je as N9,ke as U9,le as x9,me as R9,ne as O9,oe as _9,pe as V9,qe as k9,re as C9,se as T9,te as P9,ue as b9,ve as w9,we as q9}from"../chunk-27f9z8yk.js";import{xe as S9}from"../chunk-w9v8bbp8.js";import{Ae as pZ,Be as dZ,Ce as lZ,Fe as nZ,Ge as iZ,He as sZ,Ie as oZ,Je as aZ,Ke as tZ,Le as rZ,Me as eZ,Ne as W9,Oe as Z9,Pe as $9,Qe as Q9,Re as Y9,Se as K9,Xe as J9,ye as cZ,ze as uZ}from"../chunk-vh6vc4h1.js";import{Ye as h9,Ze as E9}from"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{$g as kZ,Ag as JZ,Bf as Q8,Bg as zZ,Cf as Y8,Cg as GZ,Df as K8,Ef as J8,Eg as XZ,Ff as z8,Fg as BZ,Gf as G8,Gg as jZ,Hf as X8,Hg as MZ,If as B8,Ig as FZ,Jf as j8,Jg as LZ,Kf as Y6,Kg as DZ,Kh as yZ,Lf as M8,Lg as HZ,Lh as AZ,Mf as F8,Mg as NZ,Nf as L8,Ng as UZ,Of as D8,Pf as H8,Sg as R,Tg as i,Ug as xZ,Vg as SZ,Wg as RZ,Xg as OZ,Yg as _Z,_g as VZ,ah as CZ,bh as TZ,cg as T8,dg as P8,dh as PZ,eg as b8,ff as V6,fg as w8,gf as e5,gg as q8,gh as bZ,hf as W8,hg as v8,hh as wZ,if as Z8,ih as qZ,kf as $8,lh as vZ,og as e8,pg as q6,qf as k6,qg as WZ,qh as IZ,rf as C4,sf as B6,tf as T4,uf as P4,ug as ZZ,uh as fZ,vg as $Z,wg as YZ,yf as f6,yh as i4,zf as y6,zg as KZ,zh as z1}from"../chunk-1dc3kxdd.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{$i as j1,Bj as O8,Cj as _8,Di as k4,Ei as O4,Ej as d1,Fi as k1,Xi as h4,bj as Y1,ej as _4,fj as C1,gj as p1,hj as N8,ij as U8,jj as x8,kj as S8,lj as R8,xj as mW,yj as cW}from"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import{Pj as V8,Qj as k8,Rj as C8}from"../chunk-54v3y7mg.js";import{Tj as q}from"../chunk-110ecy3e.js";import{$j as g8,ak as m8,bk as U,ck as c8,dk as b,ek as u8,fk as p8}from"../chunk-26pfh03x.js";import{lk as A8,mk as h8,nk as E8}from"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import{Wk as QZ}from"../chunk-e0e43wvq.js";import{$k as d8,Yk as I8,Zk as f8,_k as y8,al as l8,bl as n8,cl as i8,dl as s8,el as o8,jl as a8,kl as t8,ll as r8}from"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import{jm as w4,km as hZ,lm as EZ,mm as gZ,om as mZ}from"../chunk-kjz6jh54.js";import"../chunk-hhaxacwh.js";import{ym as C}from"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import{bn as u1}from"../chunk-7ztbpqed.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-4y0j6c56.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
2
+ import{rb as z$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,ic as J$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-q94v5skw.js";import{lc as d4}from"../chunk-t77xnb8k.js";import"../chunk-11hmhyk5.js";import{he as D9,ie as H9,je as N9,ke as U9,le as x9,me as R9,ne as O9,oe as _9,pe as V9,qe as k9,re as C9,se as T9,te as P9,ue as b9,ve as w9,we as q9}from"../chunk-27f9z8yk.js";import{xe as S9}from"../chunk-w9v8bbp8.js";import{Ae as pZ,Be as dZ,Ce as lZ,Fe as nZ,Ge as iZ,He as sZ,Ie as oZ,Je as aZ,Ke as tZ,Le as rZ,Me as eZ,Ne as W9,Oe as Z9,Pe as $9,Qe as Q9,Re as Y9,Se as K9,Xe as J9,ye as cZ,ze as uZ}from"../chunk-vh6vc4h1.js";import{Ye as h9,Ze as E9}from"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{$g as kZ,Ag as JZ,Bf as Q8,Bg as zZ,Cf as Y8,Cg as GZ,Df as K8,Ef as J8,Eg as XZ,Ff as z8,Fg as BZ,Gf as G8,Gg as jZ,Hf as X8,Hg as MZ,If as B8,Ig as FZ,Jf as j8,Jg as LZ,Kf as Y6,Kg as DZ,Kh as yZ,Lf as M8,Lg as HZ,Lh as AZ,Mf as F8,Mg as NZ,Nf as L8,Ng as UZ,Of as D8,Pf as H8,Sg as R,Tg as i,Ug as xZ,Vg as SZ,Wg as RZ,Xg as OZ,Yg as _Z,_g as VZ,ah as CZ,bh as TZ,cg as T8,dg as P8,dh as PZ,eg as b8,ff as V6,fg as w8,gf as e5,gg as q8,gh as bZ,hf as W8,hg as v8,hh as wZ,if as Z8,ih as qZ,kf as $8,lh as vZ,og as e8,pg as q6,qf as k6,qg as WZ,qh as IZ,rf as C4,sf as B6,tf as T4,uf as P4,ug as ZZ,uh as fZ,vg as $Z,wg as YZ,yf as f6,yh as i4,zf as y6,zg as KZ,zh as z1}from"../chunk-v040m0k2.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{$i as j1,Bj as O8,Cj as _8,Di as k4,Ei as O4,Ej as d1,Fi as k1,Xi as h4,bj as Y1,ej as _4,fj as C1,gj as p1,hj as N8,ij as U8,jj as x8,kj as S8,lj as R8,xj as mW,yj as cW}from"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import{Pj as V8,Qj as k8,Rj as C8}from"../chunk-54v3y7mg.js";import{Tj as q}from"../chunk-110ecy3e.js";import{$j as g8,ak as m8,bk as U,ck as c8,dk as b,ek as u8,fk as p8}from"../chunk-26pfh03x.js";import{lk as A8,mk as h8,nk as E8}from"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import{Wk as QZ}from"../chunk-e0e43wvq.js";import{$k as d8,Yk as I8,Zk as f8,_k as y8,al as l8,bl as n8,cl as i8,dl as s8,el as o8,jl as a8,kl as t8,ll as r8}from"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import{jm as w4,km as hZ,lm as EZ,mm as gZ,om as mZ}from"../chunk-kjz6jh54.js";import"../chunk-hhaxacwh.js";import{ym as C}from"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import{bn as u1}from"../chunk-7ztbpqed.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-4y0j6c56.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
3
3
  local currentKey = KEYS[1]
4
4
  local previousKey = KEYS[2]
5
5
  local limit = tonumber(ARGV[1])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemi",
3
- "version": "0.243.0",
3
+ "version": "0.244.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Enes Tufekci <enes@gemijs.dev>",