gemi 0.239.0 → 0.241.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.
- package/dist/ai/Agent.d.ts +3 -3
- package/dist/ai/Agent.d.ts.map +1 -1
- package/dist/ai/client/conformance.d.ts.map +1 -1
- package/dist/ai/client/index.js +88 -40
- package/dist/ai/client/index.js.map +1 -1
- package/dist/ai/client/reducer.d.ts +6 -6
- package/dist/ai/client/reducer.d.ts.map +1 -1
- package/dist/ai/index.js +12 -12
- package/dist/ai/index.js.map +3 -3
- package/dist/ai/providers/anthropicRequest.d.ts +2 -1
- package/dist/ai/providers/anthropicRequest.d.ts.map +1 -1
- package/dist/ai/providers/request.d.ts +11 -0
- package/dist/ai/providers/request.d.ts.map +1 -1
- package/dist/ai/testing/index.js +1 -1
- package/dist/ai/useChat.d.ts.map +1 -1
- package/dist/{chunk-pkew0k7c.js → chunk-2f2t8j4j.js} +1 -1
- package/dist/{chunk-mmc5bbf4.js → chunk-4j0h4q8v.js} +27 -27
- package/dist/{chunk-mmc5bbf4.js.map → chunk-4j0h4q8v.js.map} +3 -3
- package/dist/chunk-8z16b2j2.js +5 -0
- package/dist/{chunk-j3zz8046.js.map → chunk-8z16b2j2.js.map} +3 -3
- package/dist/{chunk-7axcthef.js → chunk-bn2b57qq.js} +1 -1
- package/dist/{chunk-92zmwb33.js → chunk-cfpzhc8n.js} +2 -2
- package/dist/{chunk-92zmwb33.js.map → chunk-cfpzhc8n.js.map} +1 -1
- package/dist/chunk-gpngw61t.js +12 -0
- package/dist/{chunk-m0n0ddd2.js.map → chunk-gpngw61t.js.map} +4 -4
- package/dist/{chunk-sx2gadhs.js → chunk-n1phcznj.js} +1 -1
- package/dist/{chunk-q8pr18w6.js → chunk-n30y9dc5.js} +1 -1
- package/dist/chunks/{RealtimeClient-DRVodyn1.js → RealtimeClient-Di8ozsFv.js} +2 -2
- package/dist/chunks/{RealtimeClient-DRVodyn1.js.map → RealtimeClient-Di8ozsFv.js.map} +1 -1
- package/dist/chunks/{ThemeProvider-1WtAS7dH.js → ThemeProvider-wwhaAveo.js} +28 -9
- package/dist/chunks/ThemeProvider-wwhaAveo.js.map +1 -0
- package/dist/chunks/{fetchFileRequest-CVCelZqS.js → fetchFileRequest-B3dlL_eX.js} +2 -2
- package/dist/chunks/{fetchFileRequest-CVCelZqS.js.map → fetchFileRequest-B3dlL_eX.js.map} +1 -1
- package/dist/chunks/{live-twEh9Qwt.js → live-DZBIdcg7.js} +3 -3
- package/dist/chunks/{live-twEh9Qwt.js.map → live-DZBIdcg7.js.map} +1 -1
- package/dist/chunks/{mutationExtras-CM77Ur-9.js → mutationExtras-CnzA8Ie-.js} +2 -2
- package/dist/chunks/{mutationExtras-CM77Ur-9.js.map → mutationExtras-CnzA8Ie-.js.map} +1 -1
- package/dist/chunks/{subscriptionStream-DQp1Krwi.js → subscriptionStream-DLA3izlS.js} +2 -2
- package/dist/chunks/{subscriptionStream-DQp1Krwi.js.map → subscriptionStream-DLA3izlS.js.map} +1 -1
- package/dist/client/ClientRouter.d.ts.map +1 -1
- package/dist/client/index.js +24 -17
- package/dist/client/index.js.map +1 -1
- package/dist/client/useNavigate.d.ts +8 -0
- package/dist/client/useNavigate.d.ts.map +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/kernel/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/file-storage/drivers/FileSystemDriver.d.ts +55 -7
- package/dist/services/file-storage/drivers/FileSystemDriver.d.ts.map +1 -1
- package/dist/services/index.js +1 -1
- package/dist/testing/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-j3zz8046.js +0 -5
- package/dist/chunk-m0n0ddd2.js +0 -12
- package/dist/chunks/ThemeProvider-1WtAS7dH.js.map +0 -1
- /package/dist/{chunk-pkew0k7c.js.map → chunk-2f2t8j4j.js.map} +0 -0
- /package/dist/{chunk-7axcthef.js.map → chunk-bn2b57qq.js.map} +0 -0
- /package/dist/{chunk-sx2gadhs.js.map → chunk-n1phcznj.js.map} +0 -0
- /package/dist/{chunk-q8pr18w6.js.map → chunk-n30y9dc5.js.map} +0 -0
|
@@ -34,6 +34,14 @@ type RuntimeOptions = {
|
|
|
34
34
|
* than on a type parameter constrained to `ViewPaths`.
|
|
35
35
|
*/
|
|
36
36
|
type NavigateArgs<P extends string> = IsViewPath<P> extends true ? UrlParser<P> extends Record<string, never> ? [options?: Options<P>] : [options: Options<P>] : [options?: RuntimeOptions];
|
|
37
|
+
/**
|
|
38
|
+
* `push` and `replace` keep their identity for the component's lifetime, so an
|
|
39
|
+
* effect can list them as dependencies, and the router's own subscription to
|
|
40
|
+
* the history is not re-made on every navigation (#1383). They read the
|
|
41
|
+
* current locale and router through a ref, which is updated in an insertion
|
|
42
|
+
* effect: before any layout or passive effect of the commit runs, so a
|
|
43
|
+
* navigation sent from one sees the route that commit rendered.
|
|
44
|
+
*/
|
|
37
45
|
export declare function useNavigate(): {
|
|
38
46
|
push: <P extends ViewPaths | (string & {})>(path: P, ...args: NavigateArgs<P>) => Promise<void>;
|
|
39
47
|
replace: <P extends ViewPaths | (string & {})>(path: P, ...args: NavigateArgs<P>) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigate.d.ts","sourceRoot":"","sources":["../../client/useNavigate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAOhE,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;AAK3E,KAAK,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACvE;IACE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD;IACE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN;;;;;;;;GAQG;AACH,KAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,SAAS,IAAI,GAC5D,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACxC,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACtB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACvB,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;AAE/B,wBAAgB,WAAW;
|
|
1
|
+
{"version":3,"file":"useNavigate.d.ts","sourceRoot":"","sources":["../../client/useNavigate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAOhE,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;AAK3E,KAAK,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACvE;IACE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD;IACE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN;;;;;;;;GAQG;AACH,KAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,SAAS,IAAI,GAC5D,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACxC,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACtB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GACvB,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;AAE/B;;;;;;;GAOG;AACH,wBAAgB,WAAW;WAmBT,CAAC,SAAS,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,QACzC,CAAC,WACE,YAAY,CAAC,CAAC,CAAC;cAFZ,CAAC,SAAS,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,QACzC,CAAC,WACE,YAAY,CAAC,CAAC,CAAC;EA2D7B"}
|
package/dist/facades/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$f as j,Bg as q,Mg as r,Ng as s,Og as t,Pg as u,Tf as a,Wf as c,Xf as e,Yf as f,Zf as h,_f as i,gg as k,hg as l,ig as m,jg as n,kg as o,lg as p,yh as v}from"../chunk-
|
|
2
|
+
import{$f as j,Bg as q,Mg as r,Ng as s,Og as t,Pg as u,Tf as a,Wf as c,Xf as e,Yf as f,Zf as h,_f as i,gg as k,hg as l,ig as m,jg as n,kg as o,lg as p,yh as v}from"../chunk-n30y9dc5.js";import"../chunk-vcmwp7pv.js";import"../chunk-c3c37k46.js";import{Bj as d}from"../chunk-8z16b2j2.js";import"../chunk-2g1h9ktj.js";import{Mj as b,Qj as g}from"../chunk-e4adgvd6.js";import"../chunk-0xmk4jyj.js";import"../chunk-8wvh099n.js";import"../chunk-4sv5vkab.js";import"../chunk-768yza4f.js";import"../chunk-9a3wbbr6.js";import"../chunk-0wa8ztk5.js";import"../chunk-6wv3k8ap.js";import"../chunk-ccymw1ed.js";import"../chunk-aczp96k5.js";import"../chunk-3qmhe96e.js";import"../chunk-x68jra5n.js";import"../chunk-3mq0wmq7.js";import"../chunk-wgb26e02.js";import"../chunk-7fh7cfjh.js";import"../chunk-vqmy8jfr.js";import"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import"../chunk-c7hbdsjv.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=F741325AA0CAAD4764756E2164756E21
|
package/dist/http/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$e as v,Ah as ca,Bh as da,Eh as ea,Fh as fa,Gh as ga,Hh as ha,Ih as ia,Jh as ja,Kh as ka,Lh as la,Mh as ma,Nh as na,Oh as oa,Ph as pa,Qh as qa,Rf as K,Rh as ra,Sf as L,Sh as sa,Th as ta,Uf as M,Uh as ua,Vf as N,Vh as va,Xg as aa,Ze as t,_e as u,af as w,bf as x,cf as E,hf as F,lf as G,mf as H,nf as I,of as J,zh as ba}from"../chunk-
|
|
2
|
+
import{$e as v,Ah as ca,Bh as da,Eh as ea,Fh as fa,Gh as ga,Hh as ha,Ih as ia,Jh as ja,Kh as ka,Lh as la,Mh as ma,Nh as na,Oh as oa,Ph as pa,Qh as qa,Rf as K,Rh as ra,Sf as L,Sh as sa,Th as ta,Uf as M,Uh as ua,Vf as N,Vh as va,Xg as aa,Ze as t,_e as u,af as w,bf as x,cf as E,hf as F,lf as G,mf as H,nf as I,of as J,zh as ba}from"../chunk-n30y9dc5.js";import"../chunk-vcmwp7pv.js";import"../chunk-c3c37k46.js";import{$i as C,Ai as e,Bi as f,Ci as g,Di as h,Ei as i,Fi as j,Ii as n,Ni as o,Oi as p,Pi as q,Qi as r,Vi as s,Xi as y,Yi as z,Zi as A,_i as B,aj as D,kj as O,lj as P,mj as Q,nj as R,oj as S,pj as T,qj as U,rj as V,sj as W,ti as a,tj as X,ui as b,uj as Y,vi as d,wj as Z,xj as _,yj as $}from"../chunk-8z16b2j2.js";import{Fj as c}from"../chunk-2g1h9ktj.js";import"../chunk-e4adgvd6.js";import{Tj as k,Uj as l,Vj as m}from"../chunk-0xmk4jyj.js";import"../chunk-8wvh099n.js";import"../chunk-4sv5vkab.js";import"../chunk-768yza4f.js";import"../chunk-9a3wbbr6.js";import"../chunk-0wa8ztk5.js";import"../chunk-6wv3k8ap.js";import"../chunk-ccymw1ed.js";import"../chunk-aczp96k5.js";import"../chunk-3qmhe96e.js";import"../chunk-x68jra5n.js";import"../chunk-3mq0wmq7.js";import"../chunk-wgb26e02.js";import"../chunk-7fh7cfjh.js";import"../chunk-vqmy8jfr.js";import"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import"../chunk-c7hbdsjv.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=74C09A0363F7972064756E2164756E21
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ra as T}from"../chunk-agpty0p6.js";import"../chunk-hke4hzfm.js";import{pb as D}from"../chunk-by0ydsqs.js";import{We as b,Xe as w}from"../chunk-wjjxqw9b.js";import"../chunk-bhycdjcv.js";import{Wf as j}from"../chunk-
|
|
2
|
+
import{ra as T}from"../chunk-agpty0p6.js";import"../chunk-hke4hzfm.js";import{pb as D}from"../chunk-by0ydsqs.js";import{We as b,Xe as w}from"../chunk-wjjxqw9b.js";import"../chunk-bhycdjcv.js";import{Wf as j}from"../chunk-n30y9dc5.js";import"../chunk-vcmwp7pv.js";import"../chunk-c3c37k46.js";import"../chunk-8z16b2j2.js";import"../chunk-2g1h9ktj.js";import"../chunk-e4adgvd6.js";import"../chunk-0xmk4jyj.js";import"../chunk-8wvh099n.js";import"../chunk-4sv5vkab.js";import"../chunk-768yza4f.js";import"../chunk-9a3wbbr6.js";import"../chunk-0wa8ztk5.js";import"../chunk-6wv3k8ap.js";import"../chunk-ccymw1ed.js";import"../chunk-aczp96k5.js";import"../chunk-3qmhe96e.js";import{nm as V,om as X,pm as E,qm as L,rm as R,sm as S}from"../chunk-x68jra5n.js";import"../chunk-3mq0wmq7.js";import"../chunk-wgb26e02.js";import"../chunk-7fh7cfjh.js";import"../chunk-vqmy8jfr.js";import"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import"../chunk-c7hbdsjv.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=2359CBA62B93F5EA64756E2164756E21
|
package/dist/kernel/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ta as E}from"../chunk-7ycjs0xn.js";import{ob as l}from"../chunk-gxre6wnc.js";import{pb as H}from"../chunk-by0ydsqs.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-
|
|
2
|
+
import{Ta as E}from"../chunk-7ycjs0xn.js";import{ob as l}from"../chunk-gxre6wnc.js";import{pb as H}from"../chunk-by0ydsqs.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-2f2t8j4j.js";import"../chunk-4j0h4q8v.js";import"../chunk-samm4h7d.js";import"../chunk-51mz612v.js";import"../chunk-w9v8bbp8.js";import{Qe as h}from"../chunk-6gek696n.js";import"../chunk-wjjxqw9b.js";import"../chunk-bhycdjcv.js";import{Pf as n,Qf as v,oh as w,sh as A,tf as d,uf as s,wh as R}from"../chunk-n30y9dc5.js";import"../chunk-vcmwp7pv.js";import"../chunk-c3c37k46.js";import"../chunk-8z16b2j2.js";import"../chunk-2g1h9ktj.js";import"../chunk-e4adgvd6.js";import"../chunk-0xmk4jyj.js";import"../chunk-8wvh099n.js";import{hk as M}from"../chunk-4sv5vkab.js";import"../chunk-768yza4f.js";import"../chunk-9a3wbbr6.js";import"../chunk-0wa8ztk5.js";import"../chunk-6wv3k8ap.js";import"../chunk-ccymw1ed.js";import"../chunk-aczp96k5.js";import"../chunk-3qmhe96e.js";import"../chunk-rc86ewq1.js";import"../chunk-x68jra5n.js";import{tm as O,vm as J}from"../chunk-3mq0wmq7.js";import"../chunk-wgb26e02.js";import"../chunk-7fh7cfjh.js";import"../chunk-vqmy8jfr.js";import"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import"../chunk-c7hbdsjv.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:
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ra as f}from"../chunk-ba1h9pm6.js";import{Sa as A}from"../chunk-vvq18rrr.js";import{Fm as Q,Hm as q,Im as w,Lm as Z,Mm as P,Nm as y,Om as S,Pm as U}from"../chunk-vqmy8jfr.js";import{Tm as H}from"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import{$m as F}from"../chunk-c7hbdsjv.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-
|
|
2
|
+
import{Ra as f}from"../chunk-ba1h9pm6.js";import{Sa as A}from"../chunk-vvq18rrr.js";import{Fm as Q,Hm as q,Im as w,Lm as Z,Mm as P,Nm as y,Om as S,Pm as U}from"../chunk-vqmy8jfr.js";import{Tm as H}from"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import{$m as F}from"../chunk-c7hbdsjv.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-bn2b57qq.js");this.server=await J(this.app,I)}else{f();let{httpDev:J}=await import("../chunk-n1phcznj.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=FB8C958ED0D5DD0364756E2164756E21
|
|
@@ -25,15 +25,57 @@ export declare class FileSystemDriver extends FileStorageDriver {
|
|
|
25
25
|
* directory it always meant.
|
|
26
26
|
*/
|
|
27
27
|
private get folderPath();
|
|
28
|
+
/**
|
|
29
|
+
* The storage folder with every symbolic link in its own path resolved, so
|
|
30
|
+
* a folder that is itself a link (a directory shared between releases) is
|
|
31
|
+
* used as the directory it points to. A folder that does not exist yet is
|
|
32
|
+
* created for a write and left alone otherwise: nothing below it exists, so
|
|
33
|
+
* there is nothing to check.
|
|
34
|
+
*/
|
|
35
|
+
private realRoot;
|
|
36
|
+
/**
|
|
37
|
+
* Whether an entry from `root` down to `root/rel` is a symbolic link. Only
|
|
38
|
+
* the components that exist are checked; the first missing one ends the
|
|
39
|
+
* walk, since nothing below it can be a link.
|
|
40
|
+
*/
|
|
41
|
+
private passesThroughLink;
|
|
42
|
+
/**
|
|
43
|
+
* Resolves an object name to its path inside the storage folder and refuses
|
|
44
|
+
* it when it climbs out of the folder, contains a NUL byte, or is or passes
|
|
45
|
+
* through a symbolic link below the folder. A refused read is reported like
|
|
46
|
+
* a missing object; a refused write or delete rejects and touches nothing.
|
|
47
|
+
*/
|
|
28
48
|
private resolveObjectPath;
|
|
49
|
+
/**
|
|
50
|
+
* Writes an object through a temporary file next to the target and renames
|
|
51
|
+
* it into place, so an error or an abort halfway leaves no file and a reader
|
|
52
|
+
* never sees a half-written one.
|
|
53
|
+
*
|
|
54
|
+
* The name is checked for symbolic links before the temporary file is
|
|
55
|
+
* created and again before the rename, so a link that appeared at the name
|
|
56
|
+
* or in a parent meanwhile is refused. A link that appears at the name after
|
|
57
|
+
* that second check is replaced by the rename, never written through.
|
|
58
|
+
*/
|
|
59
|
+
private writeThroughTemporary;
|
|
29
60
|
put(params: PutFileParams | Blob, { signal }?: PutFileOptions): Promise<string>;
|
|
30
61
|
/**
|
|
31
|
-
* Writes the stream
|
|
32
|
-
* into place once the stream has ended, so an error or an abort halfway
|
|
33
|
-
* leaves no file, and a reader never sees a half-written one. Memory stays
|
|
62
|
+
* Writes the stream through a temporary file, as `put()` does. Memory stays
|
|
34
63
|
* at one chunk however large the file.
|
|
35
64
|
*/
|
|
36
65
|
putStream({ name, body }: PutStreamParams, { signal }?: PutFileOptions): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Opens an object for reading with `O_NOFOLLOW`, after the per-component
|
|
68
|
+
* link check, so a link swapped in at the final name since that check is
|
|
69
|
+
* refused by the kernel (`ELOOP`) and reported like a missing object, as is
|
|
70
|
+
* anything that is not a regular file. Parent directories cannot be pinned
|
|
71
|
+
* this way; the per-component check is the defence there.
|
|
72
|
+
*/
|
|
73
|
+
private openForRead;
|
|
74
|
+
/**
|
|
75
|
+
* The object as a `Response` whose body streams from a file it has already
|
|
76
|
+
* opened. Consume or cancel the body: a response dropped unread holds the
|
|
77
|
+
* file open until it is garbage-collected.
|
|
78
|
+
*/
|
|
37
79
|
fetch(params: ReadFileParams | string, { signal }?: FetchFileOptions): Promise<Response>;
|
|
38
80
|
read(input: ReadFileParams | string): Promise<ReadResult>;
|
|
39
81
|
size(params: ReadFileParams | string): Promise<number>;
|
|
@@ -42,19 +84,25 @@ export declare class FileSystemDriver extends FileStorageDriver {
|
|
|
42
84
|
* Resolves `prefix` against the storage folder and returns the directory to
|
|
43
85
|
* walk plus the normalized prefix every match must start with. A prefix
|
|
44
86
|
* that climbs out of the folder (`../x`, `a/../../b`) is refused, as in
|
|
45
|
-
* `delete()`.
|
|
87
|
+
* `delete()`. `linked` is true when the directory to walk is, or passes
|
|
88
|
+
* through, a symbolic link below the storage folder.
|
|
46
89
|
*/
|
|
47
90
|
private resolvePrefix;
|
|
48
91
|
/**
|
|
49
92
|
* Walks the storage folder recursively and yields regular files whose path
|
|
50
93
|
* (relative to the folder, `/`-separated) starts with `prefix`, sorted by
|
|
51
|
-
* name like an S3 listing.
|
|
52
|
-
* the walk out of the folder
|
|
94
|
+
* name like an S3 listing. Symbolic links are skipped, never followed, so a
|
|
95
|
+
* link cannot lead the walk out of the folder and the listing names only
|
|
96
|
+
* objects that `read()` serves. A missing directory lists nothing, and so
|
|
97
|
+
* does a prefix whose directory is or passes through a link.
|
|
53
98
|
*/
|
|
54
99
|
objects(prefix: string, { signal }?: ListObjectsOptions): AsyncIterable<StoredObject>;
|
|
55
100
|
/**
|
|
56
101
|
* Unlinks every file under `prefix`, then removes the directories that
|
|
57
|
-
* leaves empty (never the storage folder itself).
|
|
102
|
+
* leaves empty (never the storage folder itself). Symbolic links found
|
|
103
|
+
* during the walk are left in place and their targets untouched, so a
|
|
104
|
+
* directory holding one is not removed. A prefix whose directory is or
|
|
105
|
+
* passes through a link is refused, as `delete()` refuses such a name.
|
|
58
106
|
*/
|
|
59
107
|
deletePrefix(prefix: string, options?: DeletePrefixOptions): Promise<number>;
|
|
60
108
|
private pruneEmptyDirs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystemDriver.d.ts","sourceRoot":"","sources":["../../../../services/file-storage/drivers/FileSystemDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,cAAc,EACd,UAAU,EACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAyB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileSystemDriver.d.ts","sourceRoot":"","sources":["../../../../services/file-storage/drivers/FileSystemDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,cAAc,EACd,UAAU,EACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAyB,MAAM,qBAAqB,CAAC;AAS/E,qBAAa,gBAAiB,SAAQ,iBAAiB;IACrD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;gBAEzB,UAAU,CAAC,EAAE,MAAM;IAK/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,KAAK,UAAU,GAErB;IAED;;;;;;OAMG;YACW,QAAQ;IAqBtB;;;;OAIG;YACW,iBAAiB;IAe/B;;;;;OAKG;YACW,iBAAiB;IAoB/B;;;;;;;;;OASG;YACW,qBAAqB;IA6B7B,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,EAAE,EAAE,MAAM,EAAE,GAAE,cAAmB;IA8BvE;;;OAGG;IACG,SAAS,CACb,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,eAAe,EAC/B,EAAE,MAAM,EAAE,GAAE,cAAmB,GAC9B,OAAO,CAAC,MAAM,CAAC;IAoBlB;;;;;;OAMG;YACW,WAAW;IAqBzB;;;;OAIG;IACG,KAAK,CACT,MAAM,EAAE,cAAc,GAAG,MAAM,EAC/B,EAAE,MAAM,EAAE,GAAE,gBAAqB;IA0B7B,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAyCzD,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM;IAOpC,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM;IAkB9C;;;;;;OAMG;YACW,aAAa;IAgB3B;;;;;;;OAOG;IACI,OAAO,CACZ,MAAM,EAAE,MAAM,EACd,EAAE,MAAM,EAAE,GAAE,kBAAuB,GAClC,aAAa,CAAC,YAAY,CAAC;IA+C9B;;;;;;OAMG;IACG,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC;YAiBJ,cAAc;IAgC5B,yFAAyF;IACnF,IAAI;CAKX"}
|
package/dist/services/index.js
CHANGED
|
@@ -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-pkew0k7c.js";import{lc as d4}from"../chunk-mmc5bbf4.js";import"../chunk-samm4h7d.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-51mz612v.js";import{xe as S9}from"../chunk-w9v8bbp8.js";import{Ae as pZ,Be as dZ,Ce as lZ,De as nZ,Ee as iZ,Fe as sZ,Ge as oZ,He as aZ,Ie as tZ,Je as rZ,Ke as eZ,Le as W9,Me as Z9,Ne as $9,Oe as Q9,Pe as Y9,Qe as K9,Ve as J9,ye as cZ,ze as uZ}from"../chunk-6gek696n.js";import{We as h9,Xe as E9}from"../chunk-wjjxqw9b.js";import"../chunk-bhycdjcv.js";import{$g as TZ,Af as Y8,Ag as GZ,Bf as K8,Cf as J8,Cg as XZ,Df as z8,Dg as BZ,Ef as G8,Eg as jZ,Ff as X8,Fg as MZ,Gf as B8,Gg as FZ,Hf as j8,Hg as LZ,If as Y6,Ig as DZ,Ih as yZ,Jf as M8,Jg as HZ,Jh as AZ,Kf as F8,Kg as NZ,Lf as L8,Lg as UZ,Mf as D8,Nf as H8,Qg as R,Rg as i,Sg as xZ,Tg as SZ,Ug as RZ,Vg as OZ,Wg as _Z,Yg as VZ,Zg as kZ,_g as CZ,ag as T8,bg as P8,bh as PZ,cg as b8,df as V6,dg as w8,ef as e5,eg as q8,eh as bZ,ff as W8,fg as v8,fh as wZ,gf as Z8,gh as qZ,if as $8,jh as vZ,mg as e8,ng as q6,of as k6,og as WZ,oh as IZ,pf as C4,qf as B6,rf as T4,sf as P4,sg as ZZ,sh as fZ,tg as $Z,ug as YZ,wf as f6,wh as i4,xf as y6,xg as KZ,xh as z1,yg as JZ,zf as Q8,zg as zZ}from"../chunk-q8pr18w6.js";import"../chunk-vcmwp7pv.js";import"../chunk-c3c37k46.js";import{$i as Y1,Aj as _8,Bi as k4,Ci as O4,Cj as d1,Di as k1,Vi as h4,Zi as j1,cj as _4,dj as C1,ej as p1,fj as N8,gj as U8,hj as x8,ij as S8,jj as R8,vj as mW,wj as cW,zj as O8}from"../chunk-j3zz8046.js";import"../chunk-2g1h9ktj.js";import{Nj as V8,Oj as k8,Pj as C8}from"../chunk-e4adgvd6.js";import{Rj as q}from"../chunk-0xmk4jyj.js";import{$j as U,Zj as g8,_j as m8,ak as c8,bk as b,ck as u8,dk as p8}from"../chunk-8wvh099n.js";import{jk as A8,kk as h8,lk as E8}from"../chunk-4sv5vkab.js";import"../chunk-768yza4f.js";import{Uk as QZ}from"../chunk-9a3wbbr6.js";import{$k as n8,Wk as I8,Xk as f8,Yk as y8,Zk as d8,_k as l8,al as i8,bl as s8,cl as o8,hl as a8,il as t8,jl as r8}from"../chunk-0wa8ztk5.js";import"../chunk-6wv3k8ap.js";import"../chunk-ccymw1ed.js";import"../chunk-aczp96k5.js";import"../chunk-3qmhe96e.js";import{hm as w4,im as hZ,jm as EZ,km as gZ,mm as mZ}from"../chunk-rc86ewq1.js";import"../chunk-x68jra5n.js";import{wm as C}from"../chunk-3mq0wmq7.js";import"../chunk-wgb26e02.js";import"../chunk-7fh7cfjh.js";import"../chunk-vqmy8jfr.js";import"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import{$m as u1}from"../chunk-c7hbdsjv.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-qb8pjdez.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-2f2t8j4j.js";import{lc as d4}from"../chunk-4j0h4q8v.js";import"../chunk-samm4h7d.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-51mz612v.js";import{xe as S9}from"../chunk-w9v8bbp8.js";import{Ae as pZ,Be as dZ,Ce as lZ,De as nZ,Ee as iZ,Fe as sZ,Ge as oZ,He as aZ,Ie as tZ,Je as rZ,Ke as eZ,Le as W9,Me as Z9,Ne as $9,Oe as Q9,Pe as Y9,Qe as K9,Ve as J9,ye as cZ,ze as uZ}from"../chunk-6gek696n.js";import{We as h9,Xe as E9}from"../chunk-wjjxqw9b.js";import"../chunk-bhycdjcv.js";import{$g as TZ,Af as Y8,Ag as GZ,Bf as K8,Cf as J8,Cg as XZ,Df as z8,Dg as BZ,Ef as G8,Eg as jZ,Ff as X8,Fg as MZ,Gf as B8,Gg as FZ,Hf as j8,Hg as LZ,If as Y6,Ig as DZ,Ih as yZ,Jf as M8,Jg as HZ,Jh as AZ,Kf as F8,Kg as NZ,Lf as L8,Lg as UZ,Mf as D8,Nf as H8,Qg as R,Rg as i,Sg as xZ,Tg as SZ,Ug as RZ,Vg as OZ,Wg as _Z,Yg as VZ,Zg as kZ,_g as CZ,ag as T8,bg as P8,bh as PZ,cg as b8,df as V6,dg as w8,ef as e5,eg as q8,eh as bZ,ff as W8,fg as v8,fh as wZ,gf as Z8,gh as qZ,if as $8,jh as vZ,mg as e8,ng as q6,of as k6,og as WZ,oh as IZ,pf as C4,qf as B6,rf as T4,sf as P4,sg as ZZ,sh as fZ,tg as $Z,ug as YZ,wf as f6,wh as i4,xf as y6,xg as KZ,xh as z1,yg as JZ,zf as Q8,zg as zZ}from"../chunk-n30y9dc5.js";import"../chunk-vcmwp7pv.js";import"../chunk-c3c37k46.js";import{$i as Y1,Aj as _8,Bi as k4,Ci as O4,Cj as d1,Di as k1,Vi as h4,Zi as j1,cj as _4,dj as C1,ej as p1,fj as N8,gj as U8,hj as x8,ij as S8,jj as R8,vj as mW,wj as cW,zj as O8}from"../chunk-8z16b2j2.js";import"../chunk-2g1h9ktj.js";import{Nj as V8,Oj as k8,Pj as C8}from"../chunk-e4adgvd6.js";import{Rj as q}from"../chunk-0xmk4jyj.js";import{$j as U,Zj as g8,_j as m8,ak as c8,bk as b,ck as u8,dk as p8}from"../chunk-8wvh099n.js";import{jk as A8,kk as h8,lk as E8}from"../chunk-4sv5vkab.js";import"../chunk-768yza4f.js";import{Uk as QZ}from"../chunk-9a3wbbr6.js";import{$k as n8,Wk as I8,Xk as f8,Yk as y8,Zk as d8,_k as l8,al as i8,bl as s8,cl as o8,hl as a8,il as t8,jl as r8}from"../chunk-0wa8ztk5.js";import"../chunk-6wv3k8ap.js";import"../chunk-ccymw1ed.js";import"../chunk-aczp96k5.js";import"../chunk-3qmhe96e.js";import{hm as w4,im as hZ,jm as EZ,km as gZ,mm as mZ}from"../chunk-rc86ewq1.js";import"../chunk-x68jra5n.js";import{wm as C}from"../chunk-3mq0wmq7.js";import"../chunk-wgb26e02.js";import"../chunk-7fh7cfjh.js";import"../chunk-vqmy8jfr.js";import"../chunk-zsmwmg8x.js";import"../chunk-4mysb5ej.js";import{$m as u1}from"../chunk-c7hbdsjv.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-qb8pjdez.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/dist/testing/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as toVariantKey, B as ProgressManager, Ct as Subject, G as RealtimeContext, J as liveModule, N as I18nProvider, P as ServerDataContext, c as ClientRouterContext, et as applyParams, i as RouteTransitionProvider, nt as QueryManagerContext, r as m, rt as QueryManagerProvider, t as ThemeProvider } from "../chunks/ThemeProvider-
|
|
1
|
+
import { $ as toVariantKey, B as ProgressManager, Ct as Subject, G as RealtimeContext, J as liveModule, N as I18nProvider, P as ServerDataContext, c as ClientRouterContext, et as applyParams, i as RouteTransitionProvider, nt as QueryManagerContext, r as m, rt as QueryManagerProvider, t as ThemeProvider } from "../chunks/ThemeProvider-wwhaAveo.js";
|
|
2
2
|
import { r as RouteStateProvider } from "../chunks/useParams-BN3XXfmG.js";
|
|
3
3
|
import "../chunks/urlpattern-polyfill-Cc7YrzJf.js";
|
|
4
4
|
import { t as channelKey } from "../chunks/channelKey-CIhHpX6x.js";
|
|
5
|
-
import { t as followLive } from "../chunks/live-
|
|
5
|
+
import { t as followLive } from "../chunks/live-DZBIdcg7.js";
|
|
6
6
|
import { Suspense, createElement, useContext, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { hydrateRoot } from "react-dom/client";
|
package/package.json
CHANGED
package/dist/chunk-j3zz8046.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Fj as C,Gj as J1,Hj as $1}from"./chunk-2g1h9ktj.js";import{Ij as _1,Mj as C0}from"./chunk-e4adgvd6.js";import{Vj as C1,Yj as b}from"./chunk-0xmk4jyj.js";import{sm as e1}from"./chunk-x68jra5n.js";import{wm as r1}from"./chunk-3mq0wmq7.js";import{Tm as $0}from"./chunk-zsmwmg8x.js";import{$m as B4}from"./chunk-c7hbdsjv.js";class x1{static kind="controller";constructor(){}}class _0 extends x1{}function z1(K){let Q=new Map;if(!K)return Q;for(let Z of K.split(";")){let J=Z.indexOf("=");if(J===-1)continue;let $=Z.slice(0,J).trim();if(!$)continue;Q.set($,Z.slice(J+1).trim())}return Q}function w4(K){return z1(K.headers.get("cookie"))}function m(K){if(!/^\d+$/.test(K))return null;let Q=Number(K);return Number.isSafeInteger(Q)?Q:null}function q1(K){if(!K)return null;let Q=K.trim();if(!/^bytes=/i.test(Q))return null;let J=Q.slice(6).split(",").map((V)=>V.trim()).filter((V)=>V!=="");if(J.length!==1)return null;let $=J[0],X=$.indexOf("-");if(X===-1)return null;let Y=$.slice(0,X),W=$.slice(X+1);if(Y===""){let V=m(W);if(V===null)return null;return{kind:"suffix",suffixLength:V}}let G=m(Y);if(G===null)return null;if(W==="")return{kind:"offset",start:G,end:null};let H=m(W);if(H===null||H<G)return null;return{kind:"offset",start:G,end:H}}function b1(K,Q){if(!Number.isFinite(Q)||Q<=0)return null;let Z,J;if(K.kind==="suffix"){if(K.suffixLength<=0)return null;Z=Math.max(0,Q-K.suffixLength),J=Q-1}else{if(K.start>=Q)return null;if(Z=K.start,J=K.end===null?Q-1:Math.min(K.end,Q-1),J<Z)return null}return{start:Z,end:J,length:J-Z+1}}function T4(K){if(K.kind==="suffix")return`bytes=-${K.suffixLength}`;return K.end===null?`bytes=${K.start}-`:`bytes=${K.start}-${K.end}`}function S4(K){if(!K)return null;let Q=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(K.trim());if(!Q)return null;let Z=m(Q[1]),J=m(Q[2]),$=m(Q[3]);if(Z===null||J===null||$===null||J<Z)return null;return{start:Z,end:J,total:$}}function k4(K,Q,Z){return`bytes ${K}-${Q}/${Z}`}function v1(K){return`bytes */${K}`}import{randomBytes as N0}from"crypto";var D1=new WeakMap;function P1(K){let Q=D1.get(K);if(!Q)Q=N0(16).toString("base64"),D1.set(K,Q);return Q}function b4(K){return D1.get(K)}function v4(){let K=b.getStore()?.req?.rawRequest;if(!K)throw Error("cspNonce() is only available while a request is being handled.");return P1(K)}class o extends C{errors={};constructor(K){super("Validation error");this.name="ValidationError",this.errors=K,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:K,status:400}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}function y1(K){let[Q,Z]=K.match(/\d+|\D+/g)??[];if(!Q||!Z)return 0;let J=Number.parseInt(Q);switch(Z){case"B":return J;case"KB":return J*1024;case"MB":return J*1024*1024;case"GB":return J*1024*1024*1024;case"TB":return J*1024*1024*1024*1024;default:return 0}}function I0(K){switch(K){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 K}}function f1(K){if(typeof K==="string"||Array.isArray(K))return K.length;return}function M1(K){return typeof K==="number"&&!Number.isNaN(K)}var A0=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class E extends Error{name="InvalidValidationRuleError"}function Z1(K,Q){let Z=Q===void 0||Q.trim()===""?Number.NaN:Number(Q);if(Number.isNaN(Z))throw new E(`Validation rule "${K}:${Q??""}" needs a number, e.g. "${K}:3"`);return Z}function g1(K){let Q=!1,Z=0;for(let J of Object.values(K)){if(!J||typeof J!=="object")continue;for(let $ of Object.keys(J)){let X=$.indexOf(":"),Y=X===-1?$:$.slice(0,X);if(Y!=="file"&&Y!=="fileType"&&Y!=="fileSize")continue;if(Q=!0,Y==="fileSize")Z+=y1($.slice(X+1))}}return Q?Z:null}function h1(K){let Q=K.indexOf(":"),Z=Q===-1?K:K.slice(0,Q),J=Q===-1?void 0:K.slice(Q+1);switch(Z){case"required":return($)=>{if($ instanceof Blob)return $.size>0;if($===null||$===void 0)return!1;if(typeof $==="string"||Array.isArray($))return $.length>0;return!0};case"string":return($)=>typeof $==="string";case"boolean":return($)=>typeof $==="boolean";case"number":return($)=>M1($);case"password":return($)=>{return typeof $==="string"&&/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test($)};case"min":{let $=Z1(Z,J);return(X)=>{let Y=f1(X);return Y!==void 0&&Y>=$}}case"max":{let $=Z1(Z,J);return(X)=>{let Y=f1(X);return Y!==void 0&&Y<=$}}case"gte":{let $=Z1(Z,J);return(X)=>M1(X)&&X>=$}case"lte":{let $=Z1(Z,J);return(X)=>M1(X)&&X<=$}case"email":return($)=>{return typeof $==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test($)};case"file":return($)=>{return $ instanceof Blob};case"fileType":{if(!J)throw new E('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let $=I0(J);return(X)=>X instanceof Blob&&X.type.startsWith($)}case"fileSize":{let $=y1(J??"");if($===0&&!/^0+(B|KB|MB|GB|TB)$/.test(J??""))throw new E(`Validation rule "fileSize:${J??""}" needs a whole size in B, KB, MB, GB or TB, e.g. "fileSize:5MB"`);return(X)=>X instanceof Blob&&X.size<=$}case"array":return($)=>Array.isArray($);case"object":return($)=>typeof $==="object"&&$!==null&&!Array.isArray($)&&!($ instanceof Blob);case"in":{let $=(J??"").split(",").filter((X)=>X!=="");if($.length===0)throw new E('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return(X)=>typeof X==="string"&&$.includes(X)}default:throw new E(`Unknown validation rule "${K}". Known rules: ${A0.join(", ")}`)}}class R1 extends C{limit;constructor(K){super("The request body is too large.",{status:413});this.limit=K}}var m1={b:1,k:1024,kb:1024,m:1048576,mb:1048576,g:1073741824,gb:1073741824};function c4(K){if(typeof K==="number"){if(Number.isFinite(K)&&K>=0)return Math.floor(K);if(K===1/0)return 1/0}else{let Q=K.trim().toLowerCase();if(Q==="none"||Q==="off")return 1/0;let Z=/^(\d+(?:\.\d+)?)\s*([a-z]*)$/.exec(Q);if(Z&&(Z[2]===""||(Z[2]in m1)))return Math.floor(Number(Z[1])*(m1[Z[2]]??1))}throw Error(`Invalid body limit ${JSON.stringify(K)}. Use a byte count or a size such as "64kb", "1mb" or "none".`)}var p=new WeakMap;function p4(K){return p.has(K)}function u4(K){return p.get(K)?.limit??null}function d4(K){let Q=p.get(K);return Q?Q.read>Q.limit:!1}function w0(K){let Q=K.headers.get("Content-Length");if(Q===null||!/^\s*\d+\s*$/.test(Q))return null;return Number(Q)}function B1(K,Q){let Z=w0(K);if(Z!==null&&Z>Q)throw new R1(Q)}function l4(K,Q,Z={}){let J=Z.uploadLimit??null,$=p.get(K);if($)$.limit=Q,$.uploadLimit=J;else{let X={limit:Q,uploadLimit:J,read:0,stream:void 0,used:!1};p.set(K,X),T0(K,X)}if(Z.checkDeclared!==!1)B1(K,Q)}function p1(K,Q){let Z=p.get(K);if(!Z||Z.uploadLimit===null||Z.used||Z.read>0)return;Z.limit=Math.max(Z.limit,Z.uploadLimit,Q+Z.limit),Z.uploadLimit=null}function F0(K){return Reflect.get(Object.getPrototypeOf(K),"body",K)??null}function U1(K,Q){if(Q.stream!==void 0)return Q.stream;let Z=F0(K);if(!Z)return Q.stream=null;let J;return Q.stream=new ReadableStream({async pull($){J??=Z.getReader();let{done:X,value:Y}=await J.read();if(X){$.close();return}if(Q.read+=Y.byteLength,Q.read>Q.limit){let W=new R1(Q.limit);$.error(W),J.cancel(W).catch(()=>{});return}$.enqueue(Y)},cancel($){return J?J.cancel($):Z.cancel($)}},{highWaterMark:0}),Q.stream}async function c(K,Q){if(B1(K,Q.limit),Q.used||Q.stream?.locked)throw TypeError("Body already used");Q.used=!0;let Z=U1(K,Q);if(!Z)return new Uint8Array(0);let J=Z.getReader(),$=[],X=0;for(;;){let{done:G,value:H}=await J.read();if(G)break;$.push(H),X+=H.byteLength}let Y=new Uint8Array(X),W=0;for(let G of $)Y.set(G,W),W+=G.byteLength;return Y}function c1(K){return K.headers.get("Content-Type")??""}function T0(K,Q){let Z=(J,$)=>Object.defineProperty(K,J,{configurable:!0,...$});Z("body",{get:()=>U1(K,Q)}),Z("bodyUsed",{get:()=>Q.used||Boolean(Q.stream?.locked)||Reflect.get(Object.getPrototypeOf(K),"bodyUsed",K)}),Z("bytes",{value:()=>c(K,Q)}),Z("arrayBuffer",{value:async()=>{let J=await c(K,Q);return J.buffer.slice(J.byteOffset,J.byteOffset+J.byteLength)}}),Z("text",{value:async()=>new TextDecoder().decode(await c(K,Q))}),Z("json",{value:async()=>JSON.parse(new TextDecoder().decode(await c(K,Q)))}),Z("blob",{value:async()=>new Blob([await c(K,Q)],{type:c1(K)})}),Z("formData",{value:async()=>new Response(await c(K,Q),{headers:{"Content-Type":c1(K)}}).formData()}),Z("clone",{value:()=>{B1(K,Q.limit);let J=U1(K,Q),$=null;if(J){let[X,Y]=J.tee();Q.stream=X,$=Y}return new Request(K.url,{method:K.method,headers:K.headers,body:$,signal:K.signal,duplex:"half"})}})}function u1(K){if(typeof K!=="string")return null;let[Q]=K.split(";",1),Z=Q.trim().toLowerCase();return Z===""?null:Z}function d1(K){if(K===null)return!1;if(K==="application/json")return!0;let Q=K.indexOf("/");return Q>0&&K.endsWith("+json")&&K.length>Q+1+5}var a=new WeakMap;function o4(K,Q,Z,J){a.set(K,{clientAddress:Q,...Z?{grant:Object.freeze({...Z,scopes:Object.freeze([...Z.scopes])})}:{},...J?{progress:J}:{}})}function l1(K){return a.get(K)?.progress}function i1(K){return a.get(K)?.grant}function n1(K){return a.has(K)}function a4(K){return a.get(K)?.clientAddress}var o1=new WeakMap;function t4(K,Q){o1.set(K,Q)}function a1(K){return o1.get(K)??null}var L1=new WeakMap;function r4(K,Q){let Z=L1.get(K)??[];if(!Z.includes(Q))L1.set(K,[...Z,Q])}function e4(K){return L1.get(K)??[]}class u{data;constructor(K){this.data=K}get(K){return this.data[K]}has(K){return this.data[K]!==void 0}toJSON(){return this.data}}function s1(K){return typeof K==="object"&&K!==null&&!(K instanceof Blob)}function S0(K,Q){if(!Q.includes(".")||Object.hasOwn(K,Q))return[{path:[Q],value:K[Q]}];let Z=[{path:[],value:K}];for(let J of Q.split(".")){let $=[];for(let{path:X,value:Y}of Z){if(J==="*"){if(Array.isArray(Y))Y.forEach((W,G)=>$.push({path:[...X,G],value:W}));else if(s1(Y))for(let[W,G]of Object.entries(Y))$.push({path:[...X,W],value:G});continue}if(Array.isArray(Y)&&/^\d+$/.test(J)){$.push({path:[...X,Number(J)],value:Y[Number(J)]});continue}$.push({path:[...X,J],value:s1(Y)&&Object.hasOwn(Y,J)?Y[J]:void 0})}Z=$}return Z}function t1(K){return K.join(".")}class k0{kind;rawRequest;headers;cookies;search;schema={};routePath;params;domain;state;constructor(K,Q,Z,J){if(!K){let G=b.getStore().req;this.params=G.params,this.rawRequest=G.rawRequest,this.kind=G.kind,this.routePath=G.routePath,this.domain=G.domain??null,this.state=G.state??new C1}else this.params=Q,this.rawRequest=K,this.routePath=J,this.kind=Z??"api",this.domain=a1(K),this.state=new C1;this.headers=this.rawRequest.headers;let $=z1(this.rawRequest.headers.get("Cookie")),X=new URL(this.rawRequest.url),Y=new Map;for(let[G,H]of X.searchParams)if(Y.has(G)){let V=Y.get(G);if(Array.isArray(V))V.push(H),Y.set(G,V);else Y.set(G,[V,H])}else Y.set(G,H);let W=Object.fromEntries(Y.entries());this.search=new u(W),this.cookies=$}locale(){let K=b.getStore();if(K.locale)return K.locale;let Q=r1(e1);return Q.isLocaleAware?Q.detectLocale(K.req):K.locale}ctx(){return b.getStore()}isModelOriginated(){return n1(this.rawRequest)}mcpGrant(){return i1(this.rawRequest)??null}cspNonce(){return P1(this.rawRequest)}reportProgress(K){let Q=l1(this.rawRequest);if(!Q)return!1;return Q(K),!0}get signal(){return this.rawRequest.signal}range(){return q1(this.rawRequest.headers.get("Range"))}refine(K){return{}}async parseBody(){let K=u1(this.rawRequest.headers.get("Content-Type"));if(d1(K))return new u(await this.parseJsonBody());if(K==="application/x-www-form-urlencoded"||K==="multipart/form-data"){if(K==="multipart/form-data"&&!_1(this.schema)){let J=g1(this.schema??{});if(J!==null)p1(this.rawRequest,J)}let Q;try{Q=await this.rawRequest.formData()}catch(J){if(J instanceof C)throw J;throw new C("The request body could not be read as a form.")}let Z=new Map;for(let[J,$]of Q.entries())if(Z.has(J)){let X=Z.get(J);if(Array.isArray(X))X.push($);else Z.set(J,[X,$])}else Z.set(J,$);return new u(Object.fromEntries(Z.entries()))}return new u({})}async parseJsonBody(){if(!this.rawRequest.body)return{};let K;try{K=await this.rawRequest.text()}catch(Z){if(Z instanceof C)throw Z;throw new C("The request body could not be read.")}if(K.trim()==="")return{};let Q;try{Q=JSON.parse(K)}catch{throw new C("The request body is not valid JSON.")}if(Q===null||typeof Q!=="object")throw new C("The request body must be a JSON object.");return Q}validateInput(K){if(_1(this.schema))return this.validateWithSchema(K);let Q=K.toJSON()??{},Z={},J=Object.entries(this.schema).map(([$,X])=>({key:$,rules:Object.entries(X).map(([Y,W])=>({rule:Y,message:W,check:typeof W==="function"?null:this.ruleFor($,Y)}))}));for(let{key:$,rules:X}of J)for(let{path:Y,value:W}of S0(Q,$)){let G=this.checkField(W,X);if(G.length>0){let H=Z[t1(Y)]??=[];for(let V of G)if(!H.includes(V))H.push(V)}}if(this.addRefinements(Z,Q),Object.keys(Z).length>0)throw new o(Z);return K}checkField(K,Q){let Z=Q.some(({rule:X})=>X==="required"),J=K===void 0||K===null||K==="",$=[];for(let{rule:X,message:Y,check:W}of Q){let G=Y,H=!1;if(typeof Y==="function")G=Y(K),H=typeof G>"u";else H=W(K);if(H)continue;if(J&&!Z)continue;if(X==="required")return[String(G)];if(!$.includes(String(G)))$.push(String(G))}return $}validateWithSchema(K){let Q=this.schema.validate(K.toJSON()),Z={};if("issues"in Q)for(let $ of Q.issues){let X=t1($.path),Y=Z[X]??=[];if(!Y.includes($.message))Y.push($.message)}let J="value"in Q?new u(Q.value):K;if(this.addRefinements(Z,J.toJSON()),Object.keys(Z).length>0)throw new o(Z);return J}addRefinements(K,Q){for(let[Z,J]of Object.entries(this.refine(Q)??{})){let $=K[Z]??[];K[Z]=$.includes(J)?$:[...$,J]}}ruleFor(K,Q){try{return h1(Q)}catch(Z){if(Z instanceof E)throw new E(`${this.constructor.name}.schema.${K}: ${Z.message}`);throw Z}}async input(){return this.validateInput(await this.parseBody())}async safeInput(){let K=await this.parseBody();try{return{isValid:!0,errors:{},input:this.validateInput(K)}}catch(Q){if(!(Q instanceof o))throw Q;return{isValid:!1,errors:Q.errors,input:K}}}}var K0="x-gemi-sign-in";class E0 extends C{error;constructor(K="Not authorized"){super(K);this.name="AuthorizationError",this.error=K,this.payload={api:{status:401,data:{error:$1("authorization",this.error,401)}},view:{}}}}class N1 extends C{static apiStatus=403;error;constructor(K="Insufficient permissions"){super(K);this.name="InsufficientPermissionsError",this.error=K,this.payload={api:{status:N1.apiStatus,data:{error:$1("permission",this.error,N1.apiStatus)}},view:{status:403}}}}class I1 extends C{total;constructor(K){super("Range not satisfiable");this.total=K;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:J1("range_not_satisfiable","Range not satisfiable",416)},headers:{"Content-Range":v1(K),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class x0 extends C{constructor(K="Not found"){super(K);this.name="NotFoundError",this.payload={api:{status:404,data:{error:J1("not_found",K,404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class v extends C{fileName;constructor(K){super("File not found");this.fileName=K;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:J1("not_found","Not found",404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class q0 extends C{constructor(K={}){super("Authentication error");this.name="AuthenticationError";let Q=K.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:$1("authentication","Authentication error",401)},headers:{[K0]:Q}},viewData:{status:200,data:{},headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate"},directive:{kind:"Redirect",path:Q}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:Q}}}}}import{Buffer as b0}from"buffer";function X1(K){if(typeof K!=="string"||/^[\s/.]*$/.test(K))throw Error(`Refusing to delete by prefix ${JSON.stringify(K)}: it would match the whole store`)}class s{async putStream({body:K,...Q},Z={}){Z.signal?.throwIfAborted();let J=[],$=K.getReader();try{for(;;){Z.signal?.throwIfAborted();let{done:X,value:Y}=await $.read();if(X)break;J.push(Y)}}catch(X){throw await $.cancel(X).catch(()=>{}),X}return this.put({...Q,body:b0.concat(J)},Z)}async*objects(K,Q={}){throw Error(`${this.constructor.name} does not implement objects(). Override it to list objects in this backend.`)}async deletePrefix(K,Q={}){X1(K);let Z=[];for await(let J of this.objects(K,Q))Z.push(J.name);for(let J of Z)Q.signal?.throwIfAborted(),await this.delete({name:J,bucket:Q.bucket});return Z.length}async delete(K){throw Error(`${this.constructor.name} does not implement delete(). Override it to remove objects from this backend.`)}async read(K){let Q=typeof K==="string"?{name:K}:K,Z=await this.fetch({name:Q.name,bucket:Q.bucket});if(!Z.ok)throw new v(Q.name);let J=Z.headers.get("Content-Type")??"application/octet-stream",$=Z.headers.get("ETag")??void 0,X=Z.headers.get("Last-Modified"),Y=X?new Date(X):void 0;if(Q.range){let H=await Z.blob();return{body:H,start:0,end:H.size-1,total:H.size,partial:!1,type:J,etag:$,lastModified:Y,name:Q.name}}let W=Number(Z.headers.get("Content-Length")),G=Number.isFinite(W)?W:0;return{body:Z.body,start:0,end:G-1,total:G,partial:!1,type:J,etag:$,lastModified:Y,name:Q.name}}async size(K){let Q=typeof K==="string"?K:K.name,Z=typeof K==="string"?void 0:K.bucket,J=await this.fetch({name:Q,bucket:Z});if(!J.ok)throw new v(Q);let $=Number(J.headers.get("Content-Length"));if(Number.isFinite($))return await J.body?.cancel(),$;return(await J.blob()).size}}function Q0(K,Q){if(!Q)return K;let Z=K.getReader(),J=!1,$,X=()=>{if(J=!0,$)Q.removeEventListener("abort",$)};return new ReadableStream({start(Y){if($=()=>{if(J)return;X(),Y.error(Q.reason),Z.cancel(Q.reason).catch(()=>{})},Q.aborted)$();else Q.addEventListener("abort",$,{once:!0})},async pull(Y){let W;try{W=await Z.read()}catch(G){if(J)return;X(),Y.error(G);return}if(J)return;if(W.done){X(),Y.close();return}Y.enqueue(W.value)},cancel(Y){return X(),Z.cancel(Y)}},{highWaterMark:0})}import{mkdir as v0,open as f0,readdir as A1,rename as y0,rmdir as g0,stat as h0,unlink as Z0}from"fs/promises";import{dirname as m0,isAbsolute as J0,relative as Y1,resolve as G1,sep as y}from"path";class w1 extends s{configured;constructor(K){super();this.configured=K}get folderPath(){return this.configured??`${$0()}/storage`}resolveObjectPath(K,Q){if(!K)throw Error("Object name has to be specified");let Z=G1(this.folderPath),J=G1(Z,K),$=Y1(Z,J),X=K.includes("\x00");if(X||!$||$===".."||$.startsWith(`..${y}`)||J0($)){if(Q==="read")throw new v(K);if(X)throw Error(`Refusing to ${Q} an object name containing a NUL byte`);throw Error(`Refusing to ${Q} "${K}": it is outside the storage folder`)}return J}async put(K,{signal:Q}={}){Q?.throwIfAborted();let Z,J;if(K instanceof Blob)Z=K,J=`${Bun.randomUUIDv7()}.${K.type.split("/")[1].split(";")[0]}`;else Z=K.body,J=K.name;let $=this.resolveObjectPath(J,"write"),X=Z instanceof Buffer?Z:Z instanceof Blob||Z instanceof File?Buffer.from(await Z.arrayBuffer()):"";return Q?.throwIfAborted(),await Bun.write($,X),J}async putStream({name:K,body:Q},{signal:Z}={}){let J=Q.getReader(),$=null;try{Z?.throwIfAborted();let X=this.resolveObjectPath(K,"write");await v0(m0(X),{recursive:!0}),$=`${X}.${Bun.randomUUIDv7()}.partial`;let Y=await f0($,"wx");try{for(;;){Z?.throwIfAborted();let{done:W,value:G}=await J.read();if(W)break;for(let H=0;H<G.byteLength;){let{bytesWritten:V}=await Y.write(G,H);H+=V}}}finally{await Y.close()}return Z?.throwIfAborted(),await y0($,X),K}catch(X){if(await J.cancel(X).catch(()=>{}),$)await Z0($).catch(()=>{});throw X}}async fetch(K,{signal:Q}={}){Q?.throwIfAborted();let Z=typeof K==="string"?K:K.name,J=Bun.file(this.resolveObjectPath(Z,"read")),$=Q0(J.stream(),Q),X=new Date(J.lastModified).toUTCString();return new Response($,{headers:{"Content-Type":J.type,"Content-Length":String(J.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":X}})}async read(K){let Q=typeof K==="string"?{name:K}:K,{name:Z,range:J=null}=Q,$=Bun.file(this.resolveObjectPath(Z,"read"));if(!await $.exists())throw new v(Z);let X=$.size,Y=J?b1(J,X):null;if(J&&!Y)throw new I1(X);let W=Y?.start??0,G=Y?Y.end:X-1;return{body:Y?$.slice(W,G+1):$,start:W,end:G,total:X,partial:Boolean(Y),type:$.type||"application/octet-stream",lastModified:new Date($.lastModified),name:Z}}async size(K){let Q=typeof K==="string"?K:K.name,Z=Bun.file(this.resolveObjectPath(Q,"read"));if(!await Z.exists())throw new v(Q);return Z.size}async delete(K){let Q=typeof K==="string"?K:K.name,Z=this.resolveObjectPath(Q,"delete");try{await Z0(Z)}catch(J){if(J?.code==="ENOENT")return;throw J}}resolvePrefix(K){let Q=G1(this.folderPath),Z=K.lastIndexOf("/"),J=Z===-1?"":K.slice(0,Z),$=Z===-1?K:K.slice(Z+1),X=G1(Q,J),Y=Y1(Q,X);if(Y===".."||Y.startsWith(`..${y}`)||J0(Y))throw Error(`Refusing to list "${K}": it is outside the storage folder`);let W=Y.split(y).join("/");return{root:Q,dir:X,match:W?`${W}/${$}`:$}}async*objects(K,{signal:Q}={}){Q?.throwIfAborted();let{root:Z,dir:J,match:$}=this.resolvePrefix(K),X=[],Y=async(W)=>{let G;try{G=await A1(W,{withFileTypes:!0})}catch(H){if(H?.code==="ENOENT"||H?.code==="ENOTDIR")return;throw H}for(let H of G){let V=`${W}${y}${H.name}`,O=Y1(Z,V).split(y).join("/");if(H.isDirectory()){if(`${O}/`.startsWith($)||$.startsWith(`${O}/`))await Y(V)}else if(H.isFile()&&O.startsWith($))X.push(O)}};await Y(J),X.sort();for(let W of X){Q?.throwIfAborted();let G;try{G=await h0(`${Z}/${W}`)}catch(H){if(H?.code==="ENOENT")continue;throw H}yield{name:W,size:G.size,lastModified:G.mtime}}}async deletePrefix(K,Q={}){X1(K);let{root:Z,match:J}=this.resolvePrefix(K);X1(J);let $=await super.deletePrefix(K,Q);if($>0)await this.pruneEmptyDirs(Z,J);return $}async pruneEmptyDirs(K,Q){let Z=[],J=async($)=>{let X;try{X=await A1($,{withFileTypes:!0})}catch{return}for(let Y of X){if(!Y.isDirectory())continue;let W=`${$}${y}${Y.name}`,G=Y1(K,W).split(y).join("/");if(`${G}/`.startsWith(Q)||Q.startsWith(`${G}/`)){if(await J(W),`${G}/`.startsWith(Q))Z.push(W)}}};await J(K);for(let $ of Z)try{await g0($)}catch{}}async list(){return await A1(this.folderPath)}}var f=30000;function vK(K){return K}function X0(){return{driver:new w1,fetchTimeoutMs:f,fetchIdleTimeoutMs:f}}class F1{static token="filesystem";driver;fetchTimeoutMs;fetchIdleTimeoutMs;constructor(K={}){this.driver=K.driver??X0().driver,this.fetchTimeoutMs=K.fetchTimeoutMs??f,this.fetchIdleTimeoutMs=K.fetchIdleTimeoutMs??f}}class Y0 extends Error{driver;limit;timeoutMs;object;code="storage-fetch-timeout";constructor(K,Q,Z,J){super(Q==="fetchTimeoutMs"?`${K}: no response for "${J}" within ${Z}ms (fetchTimeoutMs)`:`${K}: the body of "${J}" sent nothing for ${Z}ms (fetchIdleTimeoutMs)`);this.driver=K;this.limit=Q;this.timeoutMs=Z;this.object=J;this.name="StorageFetchTimeoutError"}}async function G0(K,Q,Z,J){let{fetchTimeoutMs:$,fetchIdleTimeoutMs:X}=J;if(Z.signal||!$&&!X)return K.fetch(Q,Z);let Y=new AbortController,W=K.constructor?.name||"FileStorageDriver",G=typeof Q==="string"?Q:Q.name,H=(B,z)=>{let P=new Y0(W,B,z,G);return Y.abort(P),P},V=Promise.resolve(K.fetch(Q,{...Z,signal:Y.signal})),O;if($){let B,z=new Promise((P,M)=>{B=setTimeout(()=>M(H("fetchTimeoutMs",$)),$)});try{O=await Promise.race([V,z])}catch(P){if(Y.signal.aborted)throw V.then((M)=>M.body?.cancel(Y.signal.reason).catch(()=>{}),()=>{}),Y.signal.reason;throw P}finally{clearTimeout(B)}}else O=await V;if(!X||!O.body)return O;return new Response(c0(O.body,X,()=>H("fetchIdleTimeoutMs",X)),{status:O.status,statusText:O.statusText,headers:O.headers})}function c0(K,Q,Z){let J=K.getReader();return new ReadableStream({async pull($){let X,Y,W=new Promise((G,H)=>{X=setTimeout(()=>{Y=Z(),H(Y)},Q)});try{let G=await Promise.race([J.read(),W]);if(G.done)$.close();else $.enqueue(G.value)}catch(G){let H=Y??G;$.error(H),J.cancel(H).catch(()=>{})}finally{clearTimeout(X)}},cancel($){return J.cancel($)}},{highWaterMark:0})}class A extends Error{code="safe-fetch";url;constructor(K,Q,Z){super(K,Z);this.name=new.target.name,this.url=Q}}class g extends A{reason;code="invalid-url";constructor(K,Q,Z){super(Z,K);this.reason=Q}}class W1 extends A{host;reason;code="blocked-host";constructor(K,Q,Z){super(Z==="denied"?`Requests to ${Q} are not allowed.`:`${Q} is not on the list of hosts this request may reach.`,K);this.host=Q;this.reason=Z}}class d extends A{host;address;range;code="blocked-address";constructor(K,Q,Z,J){super(Q===Z?`${Z} is not a public address (${J}).`:`${Q} resolves to ${Z}, which is not a public address (${J}).`,K);this.host=Q;this.address=Z;this.range=J}}class H1 extends A{host;code="dns";constructor(K,Q,Z){super(`Couldn't resolve ${Q}.`,K,{cause:Z});this.host=Q}}class V1 extends A{phase;ms;code="timeout";constructor(K,Q,Z){super(Q==="connect"?`Couldn't connect within ${Z} ms.`:`The request didn't finish within ${Z} ms.`,K);this.phase=Q;this.ms=Z}}class O1 extends A{limit;code="too-large";constructor(K,Q){super(`The response is larger than ${Q} bytes.`,K);this.limit=Q}}class t extends A{contentType;allowed;code="content-type";constructor(K,Q,Z){super(`The response is ${Q??"of no content type"}, not ${Z.join(" or ")}.`,K);this.contentType=Q;this.allowed=Z}}class T1 extends A{limit;code="too-many-redirects";constructor(K,Q){super(`More than ${Q} redirects.`,K);this.limit=Q}}class l extends A{code="network";constructor(K,Q){super(`The request failed: ${Q instanceof Error?Q.message:String(Q)}`,K,{cause:Q})}}class S1 extends A{status;code="http-status";constructor(K,Q){super(`The server answered ${Q}.`,K);this.status=Q}}function p0(K){if(K==="")return null;let Q=K.split(".");if(Q.length>1&&Q[Q.length-1]==="")Q.pop();if(Q.length===0||Q.length>4)return null;let Z=[];for(let X of Q){let Y=u0(X);if(Y===null)return null;Z.push(Y)}let J=Z.pop();for(let X of Z)if(X>255)return null;if(J>=256**(4-Z.length))return null;let $=J;return Z.forEach((X,Y)=>{$+=X*256**(3-Y)}),new Uint8Array([Math.floor($/16777216)&255,Math.floor($/65536)&255,Math.floor($/256)&255,$&255])}function u0(K){if(K==="")return null;let Q=K,Z=10;if(/^0x/i.test(Q)){if(Q=Q.slice(2),Z=16,Q==="")return 0}else if(Q.length>1&&Q.startsWith("0"))Q=Q.slice(1),Z=8;if(!(Z===16?/^[0-9a-f]+$/i:Z===8?/^[0-7]+$/:/^[0-9]+$/).test(Q))return null;let $=parseInt(Q,Z);return Number.isSafeInteger($)?$:null}function W0(K){let Q=K;if(Q.startsWith("[")&&Q.endsWith("]"))Q=Q.slice(1,-1);let Z=Q.indexOf("%");if(Z!==-1)Q=Q.slice(0,Z);if(!Q.includes(":"))return null;let J=Q.split("::");if(J.length>2)return null;let $=(H,V)=>{if(H==="")return[];let O=[],B=H.split(":");for(let z=0;z<B.length;z++){let P=B[z];if(V&&z===B.length-1&&P.includes(".")){if(!/^\d{1,3}(\.\d{1,3}){3}$/.test(P))return null;let M=P.split(".").map(Number);if(M.some((w)=>w>255))return null;O.push(M[0]<<8|M[1],M[2]<<8|M[3]);continue}if(!/^[0-9a-f]{1,4}$/i.test(P))return null;O.push(parseInt(P,16))}return O},X=$(J[0],J.length===1),Y=J.length===2?$(J[1],!0):[];if(!X||!Y)return null;let W;if(J.length===2){let H=8-X.length-Y.length;if(H<1)return null;W=[...X,...Array.from({length:H},()=>0),...Y]}else W=X;if(W.length!==8)return null;let G=new Uint8Array(16);return W.forEach((H,V)=>{G[V*2]=H>>8,G[V*2+1]=H&255}),G}function r(K){let Q=W0(K);if(Q)return{family:6,bytes:Q};let Z=p0(K);if(Z)return{family:4,bytes:Z};return null}function h(K){if(K.family===6&&d0(K.bytes))return{family:4,bytes:K.bytes.slice(12)};return K}function d0(K){for(let Q=0;Q<10;Q++)if(K[Q]!==0)return!1;return K[10]===255&&K[11]===255}function e(K){if(K.family===4)return Array.from(K.bytes).join(".");let Q=[];for(let Z=0;Z<16;Z+=2)Q.push((K.bytes[Z]<<8|K.bytes[Z+1]).toString(16));return Q.join(":")}function i(K){let Q=K.lastIndexOf("/"),Z=Q===-1?K:K.slice(0,Q),J=/^[0-9.]+$/.test(Z)?l0(Z):W0(Z);if(!J)return null;let $=h(J.length===4?{family:4,bytes:J}:{family:6,bytes:J}),X=$.family===4?32:128,Y=X;if(Q!==-1){let W=K.slice(Q+1);if(!/^\d{1,3}$/.test(W))return null;if(Y=Number(W),J.length===16&&$.family===4)Y-=96;if(Y<0||Y>X)return null}return{family:$.family,bytes:$.bytes,prefix:Y}}function l0(K){return/^\d{1,3}(\.\d{1,3}){3}$/.test(K)&&K.split(".").every((Q)=>Number(Q)<=255)?new Uint8Array(K.split(".").map(Number)):null}function x(K,Q){let Z=h(K);if(Z.family!==Q.family)return!1;let J=Q.prefix;for(let $=0;J>0;$++){let X=Math.min(8,J),Y=255<<8-X&255;if((Z.bytes[$]&Y)!==(Q.bytes[$]&Y))return!1;J-=X}return!0}var D=(K,Q)=>({cidr:i(K),kind:Q,text:K}),i0=[D("0.0.0.0/8","unspecified"),D("10.0.0.0/8","private"),D("100.64.0.0/10","shared"),D("127.0.0.0/8","loopback"),D("169.254.169.254/32","metadata"),D("169.254.0.0/16","link-local"),D("168.63.129.16/32","metadata"),D("172.16.0.0/12","private"),D("192.0.0.0/24","reserved"),D("192.0.2.0/24","documentation"),D("192.88.99.0/24","reserved"),D("192.168.0.0/16","private"),D("198.18.0.0/15","benchmarking"),D("198.51.100.0/24","documentation"),D("203.0.113.0/24","documentation"),D("224.0.0.0/4","multicast"),D("255.255.255.255/32","broadcast"),D("240.0.0.0/4","reserved")],n0=[D("::/128","unspecified"),D("::1/128","loopback"),D("64:ff9b:1::/48","private"),D("::/8","reserved"),D("100::/64","reserved"),D("2001:db8::/32","documentation"),D("2001::/23","reserved"),D("3fff::/20","documentation"),D("fd00:ec2::254/128","metadata"),D("fc00::/7","unique-local"),D("fe80::/10","link-local"),D("fec0::/10","private"),D("ff00::/8","multicast")],o0=i("64:ff9b::/96"),a0=i("2002::/16"),s0=i("2000::/3");function j1(K){let Q=typeof K==="string"?r(K):K;if(!Q)return{kind:"reserved",range:"not an IP address"};let Z=h(Q);if(Z.family===4){let $=i0.find((X)=>x(Z,X.cidr));return $?{kind:$.kind,range:$.text}:null}if(x(Z,o0))return j1({family:4,bytes:Z.bytes.slice(12)});if(x(Z,a0))return j1({family:4,bytes:Z.bytes.slice(2,6)});let J=n0.find(($)=>x(Z,$.cidr));if(J)return{kind:J.kind,range:J.text};return x(Z,s0)?null:{kind:"reserved",range:"outside 2000::/3"}}function H0(K,Q){let Z=h(K),J=h(Q);return Z.family===J.family&&Z.bytes.every(($,X)=>$===J.bytes[X])}import{lookup as t0}from"dns/promises";import*as r0 from"http";import*as e0 from"https";import*as n from"zlib";class k1 extends Response{#K;#Q;address;constructor(K,Q,Z){super(K,Q);this.#K=Z.url,this.#Q=Z.redirected,this.address=Z.address}get url(){return this.#K}get redirected(){return this.#Q}}var K1={timeout:30000,connectTimeout:1e4,maxSize:10485760,maxRedirects:5,ports:[80,443]},K4=new Set([301,302,303,307,308]),Q4=new Set([101,103,204,205,304]),Z4=["host","connection","content-length","transfer-encoding","keep-alive","upgrade"],J4=["authorization","cookie","proxy-authorization"];async function j0(K,Q={}){let Z=$4(Q),J=Q.signal;J?.throwIfAborted();let $=new AbortController,X=$.signal,Y=String(K),W=(O)=>{if(!X.aborted)$.abort(O)},G=setTimeout(()=>W(new V1(Y,"total",Z.timeout)),Z.timeout),H=()=>W(J.reason);J?.addEventListener("abort",H,{once:!0});let V=()=>{clearTimeout(G),J?.removeEventListener("abort",H)};try{let O=O0(Y,Z),B=(Q.method??"GET").toUpperCase(),z=new Headers(Q.headers);for(let M of Z4)z.delete(M);if(!z.has("accept"))z.set("accept","*/*");if(!z.has("user-agent"))z.set("user-agent","gemi");if(!z.has("accept-encoding"))z.set("accept-encoding","gzip, deflate, br");let P=await W4(B,Q.body,z);for(let M=0;;M++){Y=O.href;let{request:w,response:L,address:S}=await H4(O,B,z,P,Z,X),N=L.statusCode??0,I=L.headers.location;if(K4.has(N)&&I&&Q.redirect!=="manual"){if(w.destroy(),M>=Z.maxRedirects)throw new T1(O.href,Z.maxRedirects);let k;try{k=new URL(I,O)}catch{throw new g(I,"malformed",`The redirect to "${I}" is not a URL.`)}if(N===303?B!=="HEAD":(N===301||N===302)&&B==="POST"){B="GET",P=null;let R=[];z.forEach((U,j)=>{if(j.startsWith("content-"))R.push(j)});for(let U of R)z.delete(U)}if(k.origin!==O.origin)for(let R of J4)z.delete(R);O=O0(k.href,Z);continue}return V4({url:O,hop:M,method:B,request:w,response:L,address:S,policy:Z,signal:X,release:V})}}catch(O){throw V(),X.aborted?X.reason:O}}function $4(K){let Q=(J,$)=>{let X={hosts:[],ranges:[]};for(let Y of J){let W=Y.includes("/")||Y.includes(":")||/^[\d.]+$/.test(Y),G=W?i(Y):null;if(G)X.ranges.push(G);else if(!W&&/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*\.?$/i.test(Y))X.hosts.push(z0(Y));else throw TypeError(`safeFetch: "${Y}" in ${$} is not a host name or an IP range.`)}return X},Z=K.allowPrivate;return{timeout:K.timeout??K1.timeout,connectTimeout:K.connectTimeout??K1.connectTimeout,maxSize:K.maxSize??K1.maxSize,maxRedirects:K.maxRedirects??K1.maxRedirects,ports:K.ports??K1.ports,allow:K.allow&&K.allow.length>0?Q(K.allow,"allow"):null,deny:Q(K.deny??[],"deny"),allowPrivate:Z===!0?!0:Q(Z||[],"allowPrivate").ranges,contentTypes:K.contentTypes?.length?K.contentTypes:null,resolve:K.resolve??X4}}async function X4(K){return(await t0(K,{all:!0,verbatim:!0})).map((Z)=>Z.address)}function z0(K){return K.toLowerCase().replace(/\.$/,"")}function V0(K,Q){return Q.some((Z)=>Z.startsWith("*.")?K.endsWith(Z.slice(1)):K===Z)}function O0(K,Q){let Z;try{Z=new URL(K)}catch{throw new g(K,"malformed",`"${K}" is not a URL.`)}if(Z.protocol!=="http:"&&Z.protocol!=="https:")throw new g(Z.href,"scheme",`Only http and https URLs can be fetched, not ${Z.protocol.slice(0,-1)}.`);if(Z.username||Z.password)throw new g(Z.href,"credentials","The URL has a username or password in it.");let J=D0(Z);if(Q.ports!=="any"&&!Q.ports.includes(J))throw new g(Z.href,"port",`Port ${J} is not allowed.`);return Z}function D0(K){return K.port?Number(K.port):K.protocol==="https:"?443:80}async function Y4(K,Q,Z){let J=z0(K.hostname.replace(/^\[(.*)\]$/,"$1")),$=r(J),X=$!==null&&(J.includes(":")||/^\d+\.\d+\.\d+\.\d+$/.test(J));if(!X&&V0(J,Q.deny.hosts))throw new W1(K.href,J,"denied");let Y=!X&&Q.allow!==null&&V0(J,Q.allow.hosts);if(Q.allow&&!Y&&Q.allow.ranges.length===0)throw new W1(K.href,J,"not-allowed");let W;if(X)W=[$];else{let G;try{G=await G4(Q.resolve(J),Z)}catch(H){if(Z.aborted)throw Z.reason;throw new H1(K.href,J,H)}if(W=G.map((H)=>r(H)).filter((H)=>H!==null),W.length===0)throw new H1(K.href,J)}for(let G of W){let H=e(G);if(Q.deny.ranges.some((O)=>x(G,O)))throw new d(K.href,J,H,"denied");if(Q.allow&&!Y&&!Q.allow.ranges.some((O)=>x(G,O)))throw new d(K.href,J,H,"not-allowed");let V=j1(G);if(V&&Q.allowPrivate!==!0&&!Q.allowPrivate.some((O)=>x(G,O)))throw new d(K.href,J,H,V.kind)}return{host:J,addresses:W,isLiteral:X}}function G4(K,Q){if(Q.aborted)return Promise.reject(Q.reason);return new Promise((Z,J)=>{let $=()=>J(Q.reason);Q.addEventListener("abort",$,{once:!0}),K.then((X)=>{Q.removeEventListener("abort",$),Z(X)},(X)=>{Q.removeEventListener("abort",$),J(X)})})}async function W4(K,Q,Z){if(Q===void 0||Q===null)return null;if(K==="GET"||K==="HEAD")throw TypeError(`safeFetch: a ${K} request can't have a body.`);let J=new Request("http://body.invalid/",{method:"POST",body:Q}),$=J.headers.get("content-type");if($&&!Z.has("content-type"))Z.set("content-type",$);return new Uint8Array(await J.arrayBuffer())}async function H4(K,Q,Z,J,$,X){let Y=new AbortController,W=setTimeout(()=>Y.abort(new V1(K.href,"connect",$.connectTimeout)),$.connectTimeout),G=AbortSignal.any([X,Y.signal]);try{let{host:H,addresses:V,isLiteral:O}=await Y4(K,$,G),B=K.protocol==="https:",z={};if(Z.forEach((P,M)=>{z[M]=P}),J)z["content-length"]=String(J.byteLength);return await new Promise((P,M)=>{let w={method:Q,host:H,port:D0(K),path:`${K.pathname}${K.search}`,headers:z,agent:!1,lookup:(R,U,j)=>{let F=U?.family,_=V.filter((Q1)=>!F||Q1.family===F);if(_.length===0)j(Object.assign(Error(`No IPv${F} address for ${H}`),{code:"ENOTFOUND"}));else if(U?.all)j(null,_.map((Q1)=>({address:e(Q1),family:Q1.family})));else j(null,e(_[0]),_[0].family)}};if(B&&!O)w.servername=H;let L=(B?e0:r0).request(w),S=null,N=(R)=>{G.removeEventListener("abort",I),L.destroy(),M(R)},I=()=>N(G.aborted?G.reason:X.reason);G.addEventListener("abort",I,{once:!0});let k=(R)=>{let U=R?.remoteAddress;if(!U||S!==null)return!0;let j=r(U);if(!j||!V.some((F)=>H0(F,j)))return N(new d(K.href,H,U,"not-allowed")),!1;return S=e(h(j)),!0};L.once("socket",(R)=>{let U=()=>{if(k(R)&&!B)clearTimeout(W)};if(R.connecting)R.once("connect",U);else U();if(B)R.once("secureConnect",()=>clearTimeout(W))}),L.once("response",(R)=>{if(clearTimeout(W),R.on("error",()=>{}),!k(R.socket))return;G.removeEventListener("abort",I),P({request:L,response:R,address:S})}),L.on("error",(R)=>{if(G.aborted)return N(G.reason);N(R instanceof A?R:new l(K.href,R))}),L.end(J??void 0)})}finally{clearTimeout(W)}}function V4({url:K,hop:Q,method:Z,request:J,response:$,address:X,policy:Y,signal:W,release:G}){let H=$.statusCode??0;if(H<200||H>599)throw J.destroy(),new l(K.href,Error(`Unexpected status ${H}`));let V=new Headers,O=$.rawHeaders;for(let U=0;U<O.length;U+=2)V.append(O[U],O[U+1]);if(Y.contentTypes){let U=V.get("content-type")?.split(";")[0].trim().toLowerCase()??null;if(!U||!Y.contentTypes.some((j)=>O4(U,j)))throw J.destroy(),new t(K.href,U,Y.contentTypes)}let B={url:K.href,redirected:Q>0,address:X},z={status:H,statusText:$.statusMessage??"",headers:V};if(Z==="HEAD"||Q4.has(H))return J.destroy(),G(),new k1(null,z,B);let P=V.get("content-encoding")?.trim().toLowerCase(),M=P==="gzip"||P==="x-gzip"?n.createGunzip():P==="deflate"?n.createInflate():P==="br"?n.createBrotliDecompress():null,w=Number(V.get("content-length"));if(!M&&Number.isFinite(w)&&w>Y.maxSize)throw J.destroy(),new O1(K.href,Y.maxSize);if(M)V.delete("content-encoding"),V.delete("content-length");let L=M?$.pipe(M):$,S=0,N=!1,I=()=>{},k=()=>{N=!0,W.removeEventListener("abort",I),G()},R=new ReadableStream({start(U){let j=(_)=>{if(N)return;if(k(),_===void 0)U.close();else J.destroy(),M?.destroy(),U.error(_)};if(I=()=>j(W.reason),W.addEventListener("abort",I,{once:!0}),W.aborted)return I();L.on("data",(_)=>{if(N)return;if(S+=_.byteLength,S>Y.maxSize)return j(new O1(K.href,Y.maxSize));if(U.enqueue(new Uint8Array(_)),(U.desiredSize??1)<=0)L.pause()}),L.once("end",()=>j());let F=(_)=>j(_ instanceof A?_:new l(K.href,_));if(L.on("error",F),M)$.on("error",F);$.once("aborted",()=>j(new l(K.href,Error("The response was cut off."))))},pull(){L.resume()},cancel(){if(N)return;k(),J.destroy(),M?.destroy()}});return new k1(R,z,B)}function O4(K,Q){let Z=Q.toLowerCase();return Z.endsWith("/*")?K.startsWith(Z.slice(0,-1)):K===Z}function M0(K){return D4(K)??M4(K)??U4(K)}var E1=4096,j4={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/avif":"avif","image/heic":"heic","image/heif":"heif","image/bmp":"bmp","image/tiff":"tiff","image/x-icon":"ico","image/svg+xml":"svg","audio/mpeg":"mp3","audio/aac":"aac","audio/mp4":"m4a","audio/ogg":"ogg","audio/flac":"flac","audio/wav":"wav","video/mp4":"mp4","video/quicktime":"mov","video/webm":"webm","video/x-matroska":"mkv","video/x-msvideo":"avi","font/woff":"woff","font/woff2":"woff2","font/ttf":"ttf","font/otf":"otf","application/pdf":"pdf","application/zip":"zip","application/gzip":"gz","application/xml":"xml","text/html":"html","text/plain":"txt","application/octet-stream":"bin"};function U0(K){return j4[K]??"bin"}function T(K,Q,Z=0){if(K.length<Z+Q.length)return!1;return Q.every((J,$)=>K[Z+$]===J)}function q(K,Q,Z){return String.fromCharCode(...K.subarray(Q,Z))}var z4={avif:"image/avif",avis:"image/avif",heic:"image/heic",heix:"image/heic",hevc:"image/heic",hevx:"image/heic",heim:"image/heic",heis:"image/heic",mif1:"image/heif",msf1:"image/heif","qt ":"video/quicktime","M4A ":"audio/mp4","M4B ":"audio/mp4"};function D4(K){if(T(K,[137,80,78,71,13,10,26,10]))return"image/png";if(T(K,[255,216,255]))return"image/jpeg";if(K.length>=6&&(q(K,0,6)==="GIF87a"||q(K,0,6)==="GIF89a"))return"image/gif";if(K.length>=12&&q(K,0,4)==="RIFF"){let Q=q(K,8,12);if(Q==="WEBP")return"image/webp";if(Q==="WAVE")return"audio/wav";if(Q==="AVI ")return"video/x-msvideo"}if(K.length>=12&&q(K,4,8)==="ftyp"){let Q=q(K,8,12);return z4[Q]??"video/mp4"}if(T(K,[73,73,42,0])||T(K,[77,77,0,42]))return"image/tiff";if(T(K,[66,77])&&T(K,[0,0,0,0],6))return"image/bmp";if(T(K,[0,0,1,0])&&K.length>=6&&K[4]>0)return"image/x-icon";if(T(K,[37,80,68,70,45]))return"application/pdf";if(T(K,[80,75,3,4]))return"application/zip";if(T(K,[31,139]))return"application/gzip";if(T(K,[26,69,223,163]))return q(K,0,Math.min(K.length,64)).includes("webm")?"video/webm":"video/x-matroska";if(K.length>=4){let Q=q(K,0,4);if(Q==="OggS")return"audio/ogg";if(Q==="fLaC")return"audio/flac";if(Q==="wOFF")return"font/woff";if(Q==="wOF2")return"font/woff2";if(Q==="OTTO")return"font/otf"}if(T(K,[0,1,0,0,0]))return"font/ttf";if(K.length>=3&&q(K,0,3)==="ID3")return"audio/mpeg";if(K.length>=2&&K[0]===255){if((K[1]&246)===240)return"audio/aac";if((K[1]&224)===224&&(K[1]&6)!==0)return"audio/mpeg"}return null}var P4=["!doctype html","html","head","script","iframe","h1","div","font","table","a","style","title","b","body","br","p","!--"];function M4(K){let Q=new TextDecoder("utf-8",{fatal:!1}).decode(K);if(Q.charCodeAt(0)===65279)Q=Q.slice(1);if(Q=Q.trimStart(),!Q.startsWith("<"))return null;let Z=Q.toLowerCase(),J=Z;for(;;){J=J.trimStart();let $=/^(<\?[\s\S]*?\?>|<!--[\s\S]*?-->|<!doctype[^>]*>)/.exec(J);if(!$)break;J=J.slice($[0].length)}if(/^<svg[\s>/]/.test(J))return"image/svg+xml";for(let $ of P4){if(!Z.startsWith(`<${$}`))continue;if(/^[\s>]/.test(Z.charAt($.length+1)))return"text/html"}if(/^<(html|head|body)[\s>]/.test(J))return"text/html";if(Z.startsWith("<?xml"))return"application/xml";return null}function U4(K){if(K.length===0)return"application/octet-stream";for(let Q of K)if(Q<32&&Q!==9&&Q!==10&&Q!==12&&Q!==13&&Q!==27)return"application/octet-stream";try{return new TextDecoder("utf-8",{fatal:!0}).decode(K,{stream:!0}),"text/plain"}catch{return"application/octet-stream"}}var R4=new Set(["text/html","application/xhtml+xml","image/svg+xml","text/xml","application/xml","text/xsl","application/xslt+xml"]);function P0(K){let Q=K.split(";")[0].trim().toLowerCase();return R4.has(Q)||Q.endsWith("+xml")}function R0(K,Q){let Z=K.split(";")[0].trim().toLowerCase();return Q.some((J)=>{let $=J.split(";")[0].trim().toLowerCase();if($==="*/*"||$==="*")return!P0(Z);if($.endsWith("/*"))return Z.startsWith($.slice(0,-1))&&!P0(Z);return Z===$})}import{Buffer as C4}from"buffer";async function B0(K){try{return(await import("sharp")).default}catch(Q){throw Error(`${K} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:Q})}}async function L0(K,Q,Z={}){let{name:J,directory:$,bucket:X,maxSize:Y,timeout:W,contentTypes:G,signal:H}=Z;if(J!==void 0&&$!==void 0)throw TypeError("Storage.putFromUrl(): pass `name` or `directory`, not both.");if(J!==void 0&&!J)throw TypeError("Storage.putFromUrl(): `name` is empty.");let V=await j0(Q,{...Z.fetch,method:"GET",redirect:"follow",contentTypes:void 0,signal:H,timeout:W,maxSize:Y});if(!V.ok)throw await V.body?.cancel().catch(()=>{}),new S1(V.url,V.status);let O=(V.body??new Response(new Uint8Array).body).getReader(),B=async(j)=>{throw await O.cancel(j).catch(()=>{}),j},z=[],P=0,M=!1;while(P<E1){let{done:j,value:F}=await O.read();if(j){M=!0;break}z.push(F),P+=F.byteLength}let w=L4(z,P),L=M0(w.subarray(0,Math.min(P,E1))),S=G?.length?G:["*/*"];if(!R0(L,S))await B(new t(V.url,L,S));let N=J??[($??"").replace(/\/+$/,""),`${Bun.randomUUIDv7()}.${U0(L)}`].filter(Boolean).join("/"),I=P,k=new ReadableStream({start(j){if(P>0)j.enqueue(w);if(M)j.close()},async pull(j){let{done:F,value:_}=await O.read();if(F){j.close();return}I+=_.byteLength,j.enqueue(_)},cancel(j){return O.cancel(j)}}),R={name:N,bucket:X,body:k,contentType:L},U;try{U=K.putStream?await K.putStream(R,{signal:H}):await s.prototype.putStream.call(K,R,{signal:H})}catch(j){throw await B(j),j}return{name:U,contentType:L,size:I,url:V.url}}function L4(K,Q){if(K.length===1)return K[0];let Z=new Uint8Array(Q),J=0;for(let $ of K)Z.set($,J),J+=$.byteLength;return Z}class _4 extends C0{static getFacadeAccessor(){return F1}static async put(K,Q={}){return this.getFacadeRoot().driver.put(K,Q)}static async putFromUrl(K,Q={}){return L0(this.getFacadeRoot().driver,K,Q)}static async metadata(K){let Q=C4.from(await K.arrayBuffer()),Z=await B0("Storage.metadata()");try{return await Z(Q).metadata()}catch{return{}}}static async fetch(K,Q={}){Q.signal?.throwIfAborted();let Z=this.getFacadeRoot();return G0(Z.driver,K,Q,{fetchTimeoutMs:Z.fetchTimeoutMs??f,fetchIdleTimeoutMs:Z.fetchIdleTimeoutMs??f})}static async read(K,Q={}){let Z=typeof K==="string"?{name:K}:{...K},J="range"in Q?Q.range??null:Z.range!==void 0?Z.range:b.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...Z,range:J})}static list(K){return this.getFacadeRoot().driver.list(K)}static objects(K,Q={}){return this.getFacadeRoot().driver.objects(K,Q)}static async deletePrefix(K,Q={}){return this.getFacadeRoot().driver.deletePrefix(K,Q)}static async delete(K){return this.getFacadeRoot().driver.delete(K)}}class N4{config;static token="redis";instance=null;connectingSince=null;downSince=null;replaceDelay=500;constructor(K={}){this.config=K}get client(){if(this.instance===null)return this.build();let K=this.instance;if(this.isDown(K,Date.now())){this.instance=null;try{K.close()}catch{}return this.build()}return K}set client(K){this.instance=K,this.connectingSince=null,this.downSince=null,this.replaceDelay=500}close(){let K=this.instance;this.instance=null,this.connectingSince=null,this.downSince=null,this.replaceDelay=500,K?.close()}build(){let K=new(I4())(this.config.url,this.config.options);if(this.instance=K,this.downSince=null,this.connectingSince=null,typeof K.connect==="function"){this.connectingSince=Date.now();let Q;try{Q=Promise.resolve(K.connect())}catch(Z){Q=Promise.reject(Z)}Q.then(()=>{if(this.instance!==K)return;this.connectingSince=null,this.replaceDelay=500},()=>{if(this.instance!==K)return;this.connectingSince=null})}return K}isDown(K,Q){if(K.connected!==!1||typeof K.connect!=="function")return this.downSince=null,!1;if(this.connectingSince!==null){let Z=(this.config.options?.connectionTimeout??1e4)+5000;if(Q-this.connectingSince<Z)return!1;this.connectingSince=null}if(this.downSince??=Q,Q-this.downSince<this.replaceDelay)return!1;return this.replaceDelay=Math.min(this.replaceDelay*2,1e4),!0}}function I4(){let K=globalThis.Bun?.RedisClient;if(typeof K!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return K}
|
|
3
|
-
export{x1 as ti,_0 as ui,w4 as vi,u1 as wi,o4 as xi,i1 as yi,a4 as zi,q1 as Ai,b1 as Bi,T4 as Ci,S4 as Di,k4 as Ei,v1 as Fi,P1 as Gi,b4 as Hi,v4 as Ii,t4 as Ji,a1 as Ki,r4 as Li,e4 as Mi,o as Ni,E as Oi,R1 as Pi,c4 as Qi,p4 as Ri,u4 as Si,d4 as Ti,l4 as Ui,k0 as Vi,K0 as Wi,E0 as Xi,N1 as Yi,I1 as Zi,x0 as _i,v as $i,q0 as aj,B0 as bj,X1 as cj,s as dj,Q0 as ej,w1 as fj,vK as gj,X0 as hj,F1 as ij,Y0 as jj,A as kj,g as lj,W1 as mj,d as nj,H1 as oj,V1 as pj,O1 as qj,t as rj,T1 as sj,l as tj,S1 as uj,r as vj,j1 as wj,k1 as xj,j0 as yj,M0 as zj,P0 as Aj,_4 as Bj,N4 as Cj};
|
|
4
|
-
|
|
5
|
-
//# debugId=A228A2FA66CCAE4D64756E2164756E21
|