gemi 0.243.0 → 0.243.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-yc3t7zky.js → chunk-2e6yh7b1.js} +1 -1
- package/dist/{chunk-1dc3kxdd.js → chunk-7mfx5wmb.js} +2 -2
- package/dist/{chunk-1dc3kxdd.js.map → chunk-7mfx5wmb.js.map} +3 -3
- package/dist/{chunk-h7zc2wcs.js → chunk-8hffyvq7.js} +2 -2
- package/dist/{chunk-h7zc2wcs.js.map → chunk-8hffyvq7.js.map} +1 -1
- package/dist/{chunk-3cct08cr.js → chunk-kx5gm42f.js} +1 -1
- package/dist/{chunk-j26v29x8.js → chunk-tdpp8pzp.js} +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/http/createStreamResponse.d.ts.map +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/index.js +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-yc3t7zky.js.map → chunk-2e6yh7b1.js.map} +0 -0
- /package/dist/{chunk-3cct08cr.js.map → chunk-kx5gm42f.js.map} +0 -0
- /package/dist/{chunk-j26v29x8.js.map → chunk-tdpp8pzp.js.map} +0 -0
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-j26v29x8.js";import{lc as d4}from"../chunk-t77xnb8k.js";import"../chunk-11hmhyk5.js";import{he as D9,ie as H9,je as N9,ke as U9,le as x9,me as R9,ne as O9,oe as _9,pe as V9,qe as k9,re as C9,se as T9,te as P9,ue as b9,ve as w9,we as q9}from"../chunk-27f9z8yk.js";import{xe as S9}from"../chunk-w9v8bbp8.js";import{Ae as pZ,Be as dZ,Ce as lZ,Fe as nZ,Ge as iZ,He as sZ,Ie as oZ,Je as aZ,Ke as tZ,Le as rZ,Me as eZ,Ne as W9,Oe as Z9,Pe as $9,Qe as Q9,Re as Y9,Se as K9,Xe as J9,ye as cZ,ze as uZ}from"../chunk-vh6vc4h1.js";import{Ye as h9,Ze as E9}from"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{$g as kZ,Ag as JZ,Bf as Q8,Bg as zZ,Cf as Y8,Cg as GZ,Df as K8,Ef as J8,Eg as XZ,Ff as z8,Fg as BZ,Gf as G8,Gg as jZ,Hf as X8,Hg as MZ,If as B8,Ig as FZ,Jf as j8,Jg as LZ,Kf as Y6,Kg as DZ,Kh as yZ,Lf as M8,Lg as HZ,Lh as AZ,Mf as F8,Mg as NZ,Nf as L8,Ng as UZ,Of as D8,Pf as H8,Sg as R,Tg as i,Ug as xZ,Vg as SZ,Wg as RZ,Xg as OZ,Yg as _Z,_g as VZ,ah as CZ,bh as TZ,cg as T8,dg as P8,dh as PZ,eg as b8,ff as V6,fg as w8,gf as e5,gg as q8,gh as bZ,hf as W8,hg as v8,hh as wZ,if as Z8,ih as qZ,kf as $8,lh as vZ,og as e8,pg as q6,qf as k6,qg as WZ,qh as IZ,rf as C4,sf as B6,tf as T4,uf as P4,ug as ZZ,uh as fZ,vg as $Z,wg as YZ,yf as f6,yh as i4,zf as y6,zg as KZ,zh as z1}from"../chunk-1dc3kxdd.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{$i as j1,Bj as O8,Cj as _8,Di as k4,Ei as O4,Ej as d1,Fi as k1,Xi as h4,bj as Y1,ej as _4,fj as C1,gj as p1,hj as N8,ij as U8,jj as x8,kj as S8,lj as R8,xj as mW,yj as cW}from"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import{Pj as V8,Qj as k8,Rj as C8}from"../chunk-54v3y7mg.js";import{Tj as q}from"../chunk-110ecy3e.js";import{$j as g8,ak as m8,bk as U,ck as c8,dk as b,ek as u8,fk as p8}from"../chunk-26pfh03x.js";import{lk as A8,mk as h8,nk as E8}from"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import{Wk as QZ}from"../chunk-e0e43wvq.js";import{$k as d8,Yk as I8,Zk as f8,_k as y8,al as l8,bl as n8,cl as i8,dl as s8,el as o8,jl as a8,kl as t8,ll as r8}from"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import{jm as w4,km as hZ,lm as EZ,mm as gZ,om as mZ}from"../chunk-kjz6jh54.js";import"../chunk-hhaxacwh.js";import{ym as C}from"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import{bn as u1}from"../chunk-7ztbpqed.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-4y0j6c56.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
|
|
2
|
+
import{rb as z$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,ic as J$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-tdpp8pzp.js";import{lc as d4}from"../chunk-t77xnb8k.js";import"../chunk-11hmhyk5.js";import{he as D9,ie as H9,je as N9,ke as U9,le as x9,me as R9,ne as O9,oe as _9,pe as V9,qe as k9,re as C9,se as T9,te as P9,ue as b9,ve as w9,we as q9}from"../chunk-27f9z8yk.js";import{xe as S9}from"../chunk-w9v8bbp8.js";import{Ae as pZ,Be as dZ,Ce as lZ,Fe as nZ,Ge as iZ,He as sZ,Ie as oZ,Je as aZ,Ke as tZ,Le as rZ,Me as eZ,Ne as W9,Oe as Z9,Pe as $9,Qe as Q9,Re as Y9,Se as K9,Xe as J9,ye as cZ,ze as uZ}from"../chunk-vh6vc4h1.js";import{Ye as h9,Ze as E9}from"../chunk-t67dbfqs.js";import"../chunk-fy4142fv.js";import{$g as kZ,Ag as JZ,Bf as Q8,Bg as zZ,Cf as Y8,Cg as GZ,Df as K8,Ef as J8,Eg as XZ,Ff as z8,Fg as BZ,Gf as G8,Gg as jZ,Hf as X8,Hg as MZ,If as B8,Ig as FZ,Jf as j8,Jg as LZ,Kf as Y6,Kg as DZ,Kh as yZ,Lf as M8,Lg as HZ,Lh as AZ,Mf as F8,Mg as NZ,Nf as L8,Ng as UZ,Of as D8,Pf as H8,Sg as R,Tg as i,Ug as xZ,Vg as SZ,Wg as RZ,Xg as OZ,Yg as _Z,_g as VZ,ah as CZ,bh as TZ,cg as T8,dg as P8,dh as PZ,eg as b8,ff as V6,fg as w8,gf as e5,gg as q8,gh as bZ,hf as W8,hg as v8,hh as wZ,if as Z8,ih as qZ,kf as $8,lh as vZ,og as e8,pg as q6,qf as k6,qg as WZ,qh as IZ,rf as C4,sf as B6,tf as T4,uf as P4,ug as ZZ,uh as fZ,vg as $Z,wg as YZ,yf as f6,yh as i4,zf as y6,zg as KZ,zh as z1}from"../chunk-7mfx5wmb.js";import"../chunk-ye1kbxkx.js";import"../chunk-d39h1mrz.js";import{$i as j1,Bj as O8,Cj as _8,Di as k4,Ei as O4,Ej as d1,Fi as k1,Xi as h4,bj as Y1,ej as _4,fj as C1,gj as p1,hj as N8,ij as U8,jj as x8,kj as S8,lj as R8,xj as mW,yj as cW}from"../chunk-093j5rh8.js";import"../chunk-632nqkza.js";import{Pj as V8,Qj as k8,Rj as C8}from"../chunk-54v3y7mg.js";import{Tj as q}from"../chunk-110ecy3e.js";import{$j as g8,ak as m8,bk as U,ck as c8,dk as b,ek as u8,fk as p8}from"../chunk-26pfh03x.js";import{lk as A8,mk as h8,nk as E8}from"../chunk-t4eeg7j1.js";import"../chunk-zpnxr23b.js";import{Wk as QZ}from"../chunk-e0e43wvq.js";import{$k as d8,Yk as I8,Zk as f8,_k as y8,al as l8,bl as n8,cl as i8,dl as s8,el as o8,jl as a8,kl as t8,ll as r8}from"../chunk-yrna0ajq.js";import"../chunk-jr53em8y.js";import"../chunk-v3ddktnq.js";import"../chunk-rffa9x3d.js";import"../chunk-65m459jb.js";import{jm as w4,km as hZ,lm as EZ,mm as gZ,om as mZ}from"../chunk-kjz6jh54.js";import"../chunk-hhaxacwh.js";import{ym as C}from"../chunk-2g6cmkrn.js";import"../chunk-sp79baph.js";import"../chunk-gqw25apr.js";import"../chunk-3ywtqcxt.js";import"../chunk-9cxs1q57.js";import"../chunk-2yvzc5tq.js";import{bn as u1}from"../chunk-7ztbpqed.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-4y0j6c56.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
|
|
3
3
|
local currentKey = KEYS[1]
|
|
4
4
|
local previousKey = KEYS[2]
|
|
5
5
|
local limit = tonumber(ARGV[1])
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|