@visulima/storage 1.0.0-alpha.32 → 1.0.0-alpha.33
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/CHANGELOG.md +24 -0
- package/README.md +1 -1
- package/dist/adapter/nuxt/module.d.ts +4 -4
- package/dist/adapter/nuxt/node_modules/.bin/nuxi +2 -2
- package/dist/adapter/nuxt/node_modules/.bin/nuxt +2 -2
- package/dist/ai/ai-sdk/index.d.ts +5 -5
- package/dist/ai/ai-sdk/index.js +1 -1
- package/dist/ai/claude/index.d.ts +4 -4
- package/dist/ai/claude/index.js +1 -1
- package/dist/ai/openai/index.d.ts +5 -5
- package/dist/ai/openai/index.js +1 -1
- package/dist/ai/tanstack/index.d.ts +4 -4
- package/dist/ai/tanstack/index.js +1 -1
- package/dist/handler/http/fetch/index.d.ts +7 -7
- package/dist/handler/http/fetch/index.js +1 -1
- package/dist/handler/http/hono/index.d.ts +4 -4
- package/dist/handler/http/hono/index.js +1 -1
- package/dist/handler/http/nextjs/index.d.ts +4 -4
- package/dist/handler/http/nextjs/index.js +1 -1
- package/dist/handler/http/node/index.d.ts +7 -7
- package/dist/handler/http/node/index.js +1 -1
- package/dist/handler/http/solid-start/index.d.ts +4 -4
- package/dist/handler/http/solid-start/index.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/packem_shared/{AwsLightMetaStorage-B-iQbToR.js → AwsLightMetaStorage-Cj7ym1qI.js} +1 -1
- package/dist/packem_shared/{AwsLightStorage-B1jNF7sv.js → AwsLightStorage-6Z1ovz9R.js} +1 -1
- package/dist/packem_shared/AzureSMetaStorage-YCj-X8a1.js +1 -0
- package/dist/packem_shared/AzureStorage-CbAN4vPm.js +1 -0
- package/dist/packem_shared/{BoxMetaStorage-nESVquA1.js → BoxMetaStorage-BGBPZWoL.js} +1 -1
- package/dist/packem_shared/{BoxStorage-CHYDrcxw.js → BoxStorage-DitlyKVB.js} +1 -1
- package/dist/packem_shared/{BunS3MetaStorage-BkZx5q4w.js → BunS3MetaStorage-DAskpG_G.js} +1 -1
- package/dist/packem_shared/BunS3Storage-D1gxh5Tt.js +1 -0
- package/dist/packem_shared/{BunnyMetaStorage-bB8NXGUI.js → BunnyMetaStorage-ByUvvuPc.js} +1 -1
- package/dist/packem_shared/BunnyStorage-r6DptjUt.js +1 -0
- package/dist/packem_shared/{CloudinaryMetaStorage-BzibHydK.js → CloudinaryMetaStorage-DsJyN0iQ.js} +1 -1
- package/dist/packem_shared/{CloudinaryStorage-Cj00ZXWV.js → CloudinaryStorage-BR8CZhlL.js} +1 -1
- package/dist/packem_shared/{DiskStorage-BrAb28Je.js → DiskStorage-DHcHDZeO.js} +1 -1
- package/dist/packem_shared/{DiskStorageWithChecksum-BX85CHJ6.js → DiskStorageWithChecksum--U7zOz-0.js} +1 -1
- package/dist/packem_shared/{DropboxMetaStorage-Bfm5bblb.js → DropboxMetaStorage-B7eY16fU.js} +1 -1
- package/dist/packem_shared/{DropboxStorage-Btz9h9Mj.js → DropboxStorage-9-jj7H8C.js} +1 -1
- package/dist/packem_shared/ERRORS-vMSqlI69.js +1 -0
- package/dist/packem_shared/{FirebaseMetaStorage-CshnJMb0.js → FirebaseMetaStorage-BpYykWhG.js} +1 -1
- package/dist/packem_shared/FirebaseStorage-DB87abIF.js +2 -0
- package/dist/packem_shared/{FtpMetaStorage-CoyWJafY.js → FtpMetaStorage-v2wXTwqX.js} +1 -1
- package/dist/packem_shared/FtpStorage-DdRf0Wg6.js +1 -0
- package/dist/packem_shared/{GCSMetaStorage-CfZj52hQ.js → GCSMetaStorage-BMtou9o7.js} +1 -1
- package/dist/packem_shared/GCStorage-CRVpuZ5_.js +1 -0
- package/dist/packem_shared/{GoogleDriveMetaStorage-CBSdEQr6.js → GoogleDriveMetaStorage-BT9N1Wji.js} +1 -1
- package/dist/packem_shared/GoogleDriveStorage-BzuSZZzN.js +1 -0
- package/dist/packem_shared/LocalMetaStorage-BFQz8VPm.js +1 -0
- package/dist/packem_shared/MemoryStorage-BuNY963D.js +1 -0
- package/dist/packem_shared/{Multipart-qaEOWKz1.js → Multipart-IE3j_gAJ.js} +1 -1
- package/dist/packem_shared/{Multipart-kQ5wJQaV.js → Multipart-UIRqOPCf.js} +1 -1
- package/dist/packem_shared/{NetlifyBlobMetaStorage-CqluIgV0.js → NetlifyBlobMetaStorage-DNgncijZ.js} +1 -1
- package/dist/packem_shared/{NetlifyBlobStorage-CkMw9Uyv.js → NetlifyBlobStorage-eP0pkR0o.js} +1 -1
- package/dist/packem_shared/{OneDriveMetaStorage-DPTNMpeq.js → OneDriveMetaStorage-CkaFJFHe.js} +1 -1
- package/dist/packem_shared/OneDriveStorage-3Iq5vBfd.js +1 -0
- package/dist/packem_shared/{PocketBaseMetaStorage-CemTT_01.js → PocketBaseMetaStorage-CxnGde_n.js} +1 -1
- package/dist/packem_shared/{PocketBaseStorage-BZNzWj09.js → PocketBaseStorage-DHphg8yi.js} +1 -1
- package/dist/packem_shared/{Rest-DukkeDZe.js → Rest-B_E4TrqF.js} +1 -1
- package/dist/packem_shared/{Rest-BAcUFAgk.js → Rest-DItHKz-N.js} +1 -1
- package/dist/packem_shared/S3Storage-Bc9eq5vJ.js +1 -0
- package/dist/packem_shared/{SftpMetaStorage-Cs8b7uBO.js → SftpMetaStorage-CBcUhZRU.js} +1 -1
- package/dist/packem_shared/SftpStorage-DSsMhTZC.js +1 -0
- package/dist/packem_shared/{SharePointMetaStorage-DTVKAx6f.js → SharePointMetaStorage-yzxvwgKr.js} +1 -1
- package/dist/packem_shared/{SharePointStorage-D1cWu-14.js → SharePointStorage-C6KIGN2r.js} +1 -1
- package/dist/packem_shared/{SupabaseMetaStorage-D_fGv0d6.js → SupabaseMetaStorage-D26wob-R.js} +1 -1
- package/dist/packem_shared/SupabaseStorage-B_knTpFQ.js +1 -0
- package/dist/packem_shared/{Tus-BrP4RFTg.js → Tus-CAestp2j.js} +1 -1
- package/dist/packem_shared/{Tus-BYTcw17H.js → Tus-KQ8J2WF3.js} +1 -1
- package/dist/packem_shared/UploadControl-Otw_5jxw.js +1 -0
- package/dist/packem_shared/{UploadThingMetaStorage-CAQ1uTfv.js → UploadThingMetaStorage-DPIokkHa.js} +1 -1
- package/dist/packem_shared/UploadThingStorage-B3aIKSMh.js +1 -0
- package/dist/packem_shared/{VercelBlobMetaStorage-DY4zAB6M.js → VercelBlobMetaStorage-Bx0l9Xt6.js} +1 -1
- package/dist/packem_shared/{VercelBlobStorage-u6xmp8ox.js → VercelBlobStorage-CGxoGkv4.js} +1 -1
- package/dist/packem_shared/{agentsListFiles-R-CnGKc4.js → agentsListFiles-Bl2TOnMy.js} +1 -1
- package/dist/packem_shared/{approval.d-CMAYH9GF.d.ts → approval.d-3sw7wbPG.d.ts} +1 -1
- package/dist/packem_shared/aws-light-meta-storage-CXIZfLXR.js +4 -0
- package/dist/packem_shared/{azure-meta-storage-C4SrMtT2.js → azure-meta-storage-B-D-tBVw.js} +1 -1
- package/dist/packem_shared/{base-handler-core-Ccvdhx-k.js → base-handler-core-OdTz4-Pm.js} +1 -1
- package/dist/packem_shared/{base-handler-fetch-DzbThEWy.js → base-handler-fetch-B0FWPun7.js} +1 -1
- package/dist/packem_shared/{base-handler-node-CmCpLlBt.js → base-handler-node-CR2Bg43M.js} +1 -1
- package/dist/packem_shared/{claudeListFiles-DAezbKEi.js → claudeListFiles-yLqM5iFS.js} +1 -1
- package/dist/packem_shared/{createResponsesFileTools-BCep-qdO.js → createResponsesFileTools-DFFHq35s.js} +1 -1
- package/dist/packem_shared/{defaultCloudStorageFileNameValidation-DwDn0XB5.js → defaultCloudStorageFileNameValidation-De0HFP7m.js} +1 -1
- package/dist/packem_shared/disk-storage-CklneE2m.js +1 -0
- package/dist/packem_shared/{disk-storage-with-checksum.d-aYBmkg45.d.ts → disk-storage-with-checksum.d-Z_Z-OQpm.d.ts} +1 -1
- package/dist/packem_shared/executors-MzQbS9FT.js +1 -0
- package/dist/packem_shared/{executors.d-WGJGPSZs.d.ts → executors.d-CRI3jlk4.d.ts} +2 -2
- package/dist/packem_shared/{gcs-meta-storage-COq32th7.js → gcs-meta-storage-Dh0TAqB_.js} +1 -1
- package/dist/packem_shared/{index.d-CYdFIB-w.d.ts → index.d-C4o9jVLx.d.ts} +229 -12
- package/dist/packem_shared/{listFiles-BtP6VnUp.js → listFiles-BNGQbV_d.js} +1 -1
- package/dist/packem_shared/{listFiles-B6VF05d-.js → listFiles-BdBngq3i.js} +1 -1
- package/dist/packem_shared/local-meta-storage-Bvl0Flac.js +1 -0
- package/dist/packem_shared/{local-meta-storage.d-CuvN-KQ3.d.ts → local-meta-storage.d-CobcjyWu.d.ts} +1 -1
- package/dist/packem_shared/{media-transformer.d-DfU7VbFl.d.ts → media-transformer.d-B5cQJz30.d.ts} +2 -2
- package/dist/packem_shared/{memory-storage.d-DRbE0WMO.d.ts → memory-storage.d-CunLnxmE.d.ts} +1 -1
- package/dist/packem_shared/{path-D7rMc9nq-CPbxyMDy.js → path-D7rMc9nq-B718mbm6.js} +1 -1
- package/dist/packem_shared/{rest-base-xrnOBxS9.js → rest-base-DHkzq0rj.js} +1 -1
- package/dist/packem_shared/s3-base-storage-o_zkj15Y.js +1 -0
- package/dist/packem_shared/{s3-base-storage.d-BrHiKWFw.d.ts → s3-base-storage.d-ByfwKeid.d.ts} +21 -1
- package/dist/packem_shared/storage-z0o24zmZ.js +1 -0
- package/dist/packem_shared/{storage.d-X6TimMHY.d.ts → storage.d-D5UN5mRz.d.ts} +43 -1
- package/dist/packem_shared/{tus-base.d-Ds7xYAJC.d.ts → tus-base.d-D7UPhqdW.d.ts} +3 -3
- package/dist/packem_shared/{types.d-C4QumoP1.d.ts → types.d-BsjUOfBJ.d.ts} +2 -2
- package/dist/packem_shared/{types.d-B72PbsLY.d.ts → types.d-CPUyyEj9.d.ts} +2 -2
- package/dist/packem_shared/{types.d-a1grKnaX.d.ts → types.d-GogSTfRh.d.ts} +1 -1
- package/dist/storage/aws/index.d.ts +7 -2
- package/dist/storage/aws/index.js +1 -1
- package/dist/storage/aws-light/index.d.ts +7 -2
- package/dist/storage/aws-light/index.js +1 -1
- package/dist/storage/azure/index.d.ts +26 -7
- package/dist/storage/azure/index.js +1 -1
- package/dist/storage/box/index.d.ts +2 -2
- package/dist/storage/box/index.js +1 -1
- package/dist/storage/bun-s3/index.d.ts +2 -2
- package/dist/storage/bun-s3/index.js +1 -1
- package/dist/storage/bunny/index.d.ts +2 -2
- package/dist/storage/bunny/index.js +1 -1
- package/dist/storage/cloudinary/index.d.ts +2 -2
- package/dist/storage/cloudinary/index.js +1 -1
- package/dist/storage/dropbox/index.d.ts +2 -2
- package/dist/storage/dropbox/index.js +1 -1
- package/dist/storage/firebase/index.d.ts +2 -2
- package/dist/storage/firebase/index.js +1 -1
- package/dist/storage/ftp/index.d.ts +9 -3
- package/dist/storage/ftp/index.js +1 -1
- package/dist/storage/gcs/index.d.ts +15 -1
- package/dist/storage/gcs/index.js +1 -1
- package/dist/storage/google-drive/index.d.ts +2 -2
- package/dist/storage/google-drive/index.js +1 -1
- package/dist/storage/local/index.d.ts +3 -3
- package/dist/storage/local/index.js +1 -1
- package/dist/storage/memory/index.d.ts +2 -2
- package/dist/storage/memory/index.js +1 -1
- package/dist/storage/netlify-blob/index.d.ts +2 -2
- package/dist/storage/netlify-blob/index.js +1 -1
- package/dist/storage/onedrive/index.d.ts +4 -4
- package/dist/storage/onedrive/index.js +1 -1
- package/dist/storage/pocketbase/index.d.ts +2 -2
- package/dist/storage/pocketbase/index.js +1 -1
- package/dist/storage/sftp/index.d.ts +9 -3
- package/dist/storage/sftp/index.js +1 -1
- package/dist/storage/sharepoint/index.d.ts +3 -3
- package/dist/storage/sharepoint/index.js +1 -1
- package/dist/storage/supabase/index.d.ts +3 -3
- package/dist/storage/supabase/index.js +1 -1
- package/dist/storage/uploadthing/index.d.ts +2 -2
- package/dist/storage/uploadthing/index.js +1 -1
- package/dist/storage/vercel-blob/index.d.ts +2 -2
- package/dist/storage/vercel-blob/index.js +1 -1
- package/dist/transformer/audio-transformer.d.ts +2 -2
- package/dist/transformer/image-transformer.d.ts +2 -2
- package/dist/transformer/index.d.ts +3 -3
- package/dist/transformer/video-transformer.d.ts +2 -2
- package/package.json +1 -1
- package/dist/packem_shared/AzureSMetaStorage-CR-lfQNQ.js +0 -1
- package/dist/packem_shared/AzureStorage-B4E6VLn5.js +0 -1
- package/dist/packem_shared/BunS3Storage-BopE7kmX.js +0 -1
- package/dist/packem_shared/BunnyStorage-C3IBxJqr.js +0 -1
- package/dist/packem_shared/ERRORS-CyOuSMLY.js +0 -1
- package/dist/packem_shared/Files-tnc_buzM.js +0 -1
- package/dist/packem_shared/FirebaseStorage-Y9P6Dx8I.js +0 -2
- package/dist/packem_shared/FtpStorage-DCKPMX0z.js +0 -1
- package/dist/packem_shared/GCStorage-hfL1u2KQ.js +0 -1
- package/dist/packem_shared/GoogleDriveStorage-C7iuV7qb.js +0 -1
- package/dist/packem_shared/LocalMetaStorage-DSwsmdt7.js +0 -1
- package/dist/packem_shared/OneDriveStorage-CEGYb6OC.js +0 -1
- package/dist/packem_shared/S3Storage-7hG3izjU.js +0 -1
- package/dist/packem_shared/SftpStorage-DnigT9GT.js +0 -1
- package/dist/packem_shared/SupabaseStorage-DbIUa6NZ.js +0 -1
- package/dist/packem_shared/UploadThingStorage-B1qw1GrM.js +0 -1
- package/dist/packem_shared/aws-light-meta-storage-CstQBYXG.js +0 -4
- package/dist/packem_shared/default-BrhEhSqN.js +0 -1
- package/dist/packem_shared/disk-storage-fWizVrge.js +0 -1
- package/dist/packem_shared/executors-DG6hGtvm.js +0 -1
- package/dist/packem_shared/local-meta-storage-Dr891Iy7.js +0 -1
- package/dist/packem_shared/s3-base-storage-CqAyWHR6.js +0 -1
- package/dist/packem_shared/storage-uhIhcN-O.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var ut=Object.defineProperty;var h=(e,t)=>ut(e,"name",{value:t,configurable:!0});import{createReadStream as mt,createWriteStream as dt}from"node:fs";import{truncate as ht,stat as B,copyFile as U}from"node:fs/promises";import{Transform as q,PassThrough as yt,pipeline as ft}from"node:stream";import{f as C,l as gt,w as K,V as b,P as v,L as P,_ as pt,B as wt,X as bt,a as vt,i as Et,v as $t,b as St,y as V}from"./local-meta-storage-Dr891Iy7.js";import{createRequire as M}from"node:module";import{O as Ot,M as Tt}from"./path-D7rMc9nq-CPbxyMDy.js";import{S as Ft}from"./index-B4ETk0Lu.js";import{d as kt}from"./detect-file-type-5JhzC9RU.js";import{throwErrorCode as w,ERRORS as y,isUploadError as Nt}from"./ERRORS-CyOuSMLY.js";import{createHash as Pt}from"node:crypto";import{B as Dt,a as _t,t as Mt}from"./storage-uhIhcN-O.js";import It from"./File-BhfUgJjs.js";import{o as X}from"./get-file-status-DLS18Zvd.js";import{u as Rt}from"./update-size-DANV7aa2.js";import{r as xt}from"./part-match-D_NwyoF3.js";import{o as Lt}from"./has-content-Bx2p8Okx.js";var jt=Object.defineProperty,At=h((e,t)=>jt(e,"name",{value:t,configurable:!0}),"i$4"),Ct=Object.defineProperty,Y=At((e,t)=>Ct(e,"name",{value:t,configurable:!0}),"t");const zt=M(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Wt=Y(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[t,r]=F.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return F.getBuiltinModule(e)}return zt(e)},"__cjs_getBuiltinModule"),{lstat:Bt,writeFile:Ut}=Wt("node:fs/promises");var Vt=Object.defineProperty,Xt=Y((e,t)=>Vt(e,"name",{value:t,configurable:!0}),"o");const j=Xt(async e=>{C(e);try{const t=await Bt(e);if(!t.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(gt(t))}'`)}catch(t){if(t.code==="ENOENT"){await K(b(v(e))),await Ut(e,new Uint8Array);return}throw t}},"ensureFile");var Qt=Object.defineProperty,G=h((e,t)=>Qt(e,"name",{value:t,configurable:!0}),"t$1"),Ht=Object.defineProperty,J=G((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"t"),qt=Object.defineProperty,Kt=J((e,t)=>qt(e,"name",{value:t,configurable:!0}),"t");let Q=class extends Error{static{h(this,"l")}static{G(this,"c")}static{J(this,"i")}static{Kt(this,"WalkError")}root;constructor(t,r){super(`${t instanceof Error?t.message:String(t)} for path "${r}"`),this.cause=t,this.root=r}get name(){return"WalkError"}set name(t){throw new Error("Cannot overwrite name of WalkError")}};var Yt=Object.defineProperty,Gt=h((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"l$1"),Jt=Object.defineProperty,Z=Gt((e,t)=>Jt(e,"name",{value:t,configurable:!0}),"t"),Zt=Object.defineProperty,te=Z((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"g");const H=te(e=>{const t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,String.raw`\.`).replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},"globToRegExp");var ee=Object.defineProperty,re=Z((e,t)=>ee(e,"name",{value:t,configurable:!0}),"t");const _=re((e,t,r,i)=>{if(Array.isArray(t)&&t.length>0&&!t.some(a=>e.endsWith(a)))return!1;const n=e.includes("\\")?e.replaceAll("\\","/"):e;return r&&!r.some(a=>a.test(n))?!1:!i?.some(a=>a.test(n))},"walkInclude");var ie=Object.defineProperty,tt=h((e,t)=>ie(e,"name",{value:t,configurable:!0}),"f$1"),ae=Object.defineProperty,z=tt((e,t)=>ae(e,"name",{value:t,configurable:!0}),"y");const se=M(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=z(e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,r]=k.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return k.getBuiltinModule(e)}return se(e)},"__cjs_getBuiltinModule"),{readdir:oe,realpath:ce,stat:le}=ne("node:fs/promises");var ue=Object.defineProperty,p=z((e,t)=>ue(e,"name",{value:t,configurable:!0}),"r");const me=p(async e=>{const t=wt(e),r=bt(t),i=await le(t);return{isDirectory:p(()=>i.isDirectory(),"isDirectory"),isFile:p(()=>i.isFile(),"isFile"),isSymbolicLink:p(()=>i.isSymbolicLink(),"isSymbolicLink"),name:r,path:t}},"_createWalkEntry");async function*D(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:a=!0,match:s,maxDepth:l=Number.POSITIVE_INFINITY,skip:m}={}){if(C(e),l<0)return;const u=s?s.map(c=>typeof c=="string"?H(c):c):void 0,d=m?m.map(c=>typeof c=="string"?H(c):c):void 0;if(e=P(v(e)),i&&_(e,t,u,d)&&(yield await me(e)),!(l<1||!_(e,void 0,void 0,d)))try{const c=await oe(e,{withFileTypes:!0});for(const o of c){let g=pt(e,o.name);if(o.isSymbolicLink())if(r)g=await ce(g);else if(a&&_(g,t,u,d)){yield{isDirectory:p(()=>o.isDirectory(),"isDirectory"),isFile:p(()=>o.isFile(),"isFile"),isSymbolicLink:p(()=>o.isSymbolicLink(),"isSymbolicLink"),name:o.name,path:g};continue}else continue;o.isDirectory()?yield*D(g,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:a,match:u,maxDepth:l-1,skip:d}):o.isFile()&&n&&_(g,t,u,d)&&(yield{isDirectory:p(()=>o.isDirectory(),"isDirectory"),isFile:p(()=>o.isFile(),"isFile"),isSymbolicLink:p(()=>o.isSymbolicLink(),"isSymbolicLink"),name:o.name,path:g})}}catch(c){throw c instanceof Q?c:new Q(c,e)}}h(D,"p$2");tt(D,"D");z(D,"g");p(D,"walk");var de=Object.defineProperty,et=h((e,t)=>de(e,"name",{value:t,configurable:!0}),"t"),he=Object.defineProperty,W=et((e,t)=>he(e,"name",{value:t,configurable:!0}),"t");const ye=M(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fe=W(e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,r]=N.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return N.getBuiltinModule(e)}return ye(e)},"__cjs_getBuiltinModule"),{accessSync:ge}=fe("node:fs");var pe=Object.defineProperty,we=W((e,t)=>pe(e,"name",{value:t,configurable:!0}),"o");function I(e,t=vt){C(e),e=v(e);try{return ge(e,t),!0}catch{return!1}}h(I,"i$1");et(I,"d");W(I,"m");we(I,"isAccessibleSync");var be=Object.defineProperty,rt=h((e,t)=>be(e,"name",{value:t,configurable:!0}),"v"),ve=Object.defineProperty,T=rt((e,t)=>ve(e,"name",{value:t,configurable:!0}),"i");const Ee=M(import.meta.url),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,it=T(e=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[t,r]=S.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return S.getBuiltinModule(e)}return Ee(e)},"__cjs_getBuiltinModule"),{cwd:R}=S,{mkdir:$e,rename:Se,copyFile:Oe,unlink:Te}=it("node:fs/promises"),{mkdirSync:Fe,renameSync:ke,copyFileSync:Ne,unlinkSync:Pe}=it("node:fs");var De=Object.defineProperty,at=T((e,t)=>De(e,"name",{value:t,configurable:!0}),"o");class _e extends Error{static{h(this,"V")}static{rt(this,"O")}static{T(this,"a")}static{at(this,"SameDirectoryError")}constructor(t,r){super(`Source directory "${b(t)}" does not match destination directory "${b(r)}"`),this.name="SameDirectoryError"}}const st=at((e,t)=>{if(!e||!t)throw new Error("Source and destination paths must not be empty");if(b(e)!==b(t))throw new _e(e,t)},"validateSameDirectory");var Me=Object.defineProperty,Ie=T((e,t)=>Me(e,"name",{value:t,configurable:!0}),"m$1");const nt=Ie(async(e,t,{cwd:r,directoryMode:i,overwrite:n,validateDirectory:a})=>{if(r&&(e=P(r,e),t=P(r,t)),a&&st(e,t),!n&&await Et(t))throw new Error(`The destination file exists: ${t}`);await $e(b(t),{mode:i,recursive:!0});try{await Se(e,t)}catch(s){if(s.code==="EXDEV")await Oe(e,t),await Te(e);else throw s}},"internalMoveFile");var Re=Object.defineProperty,xe=T((e,t)=>Re(e,"name",{value:t,configurable:!0}),"m");const ot=xe((e,t,{cwd:r,directoryMode:i,overwrite:n,validateDirectory:a})=>{if(r&&(e=P(r,e),t=P(r,t)),a&&st(e,t),!n&&I(t))throw new Error(`The destination file exists: ${t}`);Fe(b(t),{mode:i,recursive:!0});try{ke(e,t)}catch(s){if(s.code==="EXDEV")Ne(e,t),Pe(e);else throw s}},"internalMoveFileSync");var Le=Object.defineProperty,x=T((e,t)=>Le(e,"name",{value:t,configurable:!0}),"i");const je=x(async(e,t,r={})=>{const i={overwrite:!0,validateDirectory:!1,...r,cwd:r.cwd?v(r.cwd):R()};await nt(e,t,i)},"move");x((e,t,r)=>{const i={overwrite:!0,validateDirectory:!1,...r};i.cwd=i.cwd?v(i.cwd):R(),ot(e,t,i)},"moveSync");x(async(e,t,r)=>{const i={overwrite:!0,...r,validateDirectory:!0};i.cwd=i.cwd?v(i.cwd):R(),await nt(e,t,i)},"rename");x((e,t,r)=>{const i={overwrite:!0,...r,validateDirectory:!0};i.cwd=i.cwd?v(i.cwd):R(),ot(e,t,i)},"renameSync");var Ae=Object.defineProperty,ct=h((e,t)=>Ae(e,"name",{value:t,configurable:!0}),"r");class Ce extends q{static{h(this,"StreamChecksum")}constructor(t,r,i="base64"){super(),this.checksum=t,this.algorithm=r,this.encoding=i,this.hash=Pt(r)}checksum;algorithm;encoding;static{ct(this,"StreamChecksum")}length=0;digest="";hash;get calculatedDigest(){return this.digest}_transform(t,r,i){this.push(t),this.hash.update(t),this.length+=t.length,i()}_flush(t){this.digest=this.hash.digest(this.encoding),this.checksum&&this.checksum!==this.digest?t(new Error("Checksum mismatch")):t()}}const ze=ct((e,t,r="base64")=>t?new Ce(e,t,r):new yt,"streamChecksum");var We=Object.defineProperty,Be=h((e,t)=>We(e,"name",{value:t,configurable:!0}),"o");class Ue extends q{static{h(this,"m")}constructor(t=Number.POSITIVE_INFINITY){super(),this.limit=t}limit;static{Be(this,"StreamLength")}length=0;_transform(t,r,i){const n=this.length+t.length;this.limit>=n?(this.push(t),this.length=n,i()):i(new Error("Stream length limit exceeded"))}}var Ve=Object.defineProperty,A=h((e,t)=>Ve(e,"name",{value:t,configurable:!0}),"F");class O extends Dt{static name="disk";checksumTypes=["md5","sha1"];supportsRange=!0;get raw(){return{directory:this.directory}}directory;meta;constructor(t){const r={...t,fileNameValidation:t.fileNameValidation??_t};if(super(r),this.directory=r.directory,r.metaStorage)this.meta=r.metaStorage;else{const i={...r,...r.metaStorageConfig,logger:this.logger};this.meta=new $t(i)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(i=>{this.logger?.error("Storage access check failed: %O",i)})}normalizeError(t){return super.normalizeError(t)}async create(t){return this.instrumentOperation("create",async()=>{const r={...t};if(t.ttl){const a=typeof t.ttl=="string"?Mt(t.ttl):t.ttl;a!==void 0&&(r.expiredAt=Date.now()+a)}r.size!==void 0&&Number(r.size)<0&&w(y.REQUEST_ENTITY_TOO_LARGE,"Request entity too large");const i=new It(r);try{const a=await this.getMeta(i.id);if(a.status==="completed")return a}catch{}i.name=this.namingFunction(i),(i.size===void 0||Number.isNaN(i.size))&&(i.size===void 0||(i.size=this.maxUploadSize)),await this.validate(i);const n=this.getFilePath(i.name);try{await j(n),i.bytesWritten=0}catch(a){const s=this.normalizeError(a instanceof Error?a:new Error(String(a)));await this.onError(s),w(y.FILE_ERROR,s.message)}return i.status=X(i),await this.saveMeta(i),await this.onCreate(i),i})}async write(t){return this.instrumentOperation("write",async()=>{let r;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?r=t:(r=await this.getMeta(t.id),await this.checkIfExpired(r)),r.status==="completed")return r;if(t.size!==void 0&&Rt(r,t.size),!xt(t,r))return w(y.FILE_CONFLICT);const i=this.getFilePath(r.name),n=await this.lock(i);try{const a=t.start||0;if(await j(i),r.bytesWritten===0&&(r.bytesWritten=a),Lt(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return w(y.UNSUPPORTED_CHECKSUM_ALGORITHM);if((t.start===0||t.start===void 0)&&(r.bytesWritten===0||Number.isNaN(r.bytesWritten))&&(!r.contentType||r.contentType==="application/octet-stream"))try{const{fileType:c,stream:o}=await kt(t.body);c?.mime&&(r.contentType=c.mime),t.body=o}catch{}const s=t.signal,l={...r,...t,body:t.body};s&&(l.signal=s);const[m,u]=await this.lazyWrite(l);if(u)return await ht(i,r.bytesWritten),w(u);const d=a+(t.contentLength||0);r.bytesWritten=Math.max(r.bytesWritten||0,d),r.bytesWritten=Math.max(r.bytesWritten||0,m),r.status=X(r),await this.saveMeta(r)}else await j(i),r.bytesWritten=0;return r}catch(a){if(Nt(a))throw a;const s=this.normalizeError(a instanceof Error?a:new Error(String(a)));return await this.onError(s),w(y.FILE_ERROR,(typeof s.message=="string"?s.message:String(a))||String(a))}finally{await this.unlock(i,n)}})}async get({id:t},r){return this.instrumentOperation("get",async()=>{const i=await this.checkIfExpired(await this.meta.get(t)),{bytesWritten:n,contentType:a,expiredAt:s,metadata:l,modifiedAt:m,name:u,originalName:d,size:c}=i;let o;try{o=await St(this.getFilePath(u),{buffer:!0})}catch(f){const $=f;if($.code==="ENOENT"||$.code==="EPERM"){const L=this.normalizeError(f instanceof Error?f:new Error($.message||String(f)));return await this.onError(L),w(y.FILE_NOT_FOUND,(typeof L.message=="string"?L.message:String(f))||String(f))}const lt=this.normalizeError(f instanceof Error?f:new Error(String(f)));throw await this.onError(lt),f}const g=Ft(o),E=r?.range;if(E){const f=Math.max(0,E.start),$=E.end===void 0?o.length-1:Math.min(o.length-1,E.end);if(f>$||f>=o.length)return w(y.BAD_REQUEST,`Invalid range ${f}-${E.end??""}`);o=o.subarray(f,$+1)}return{content:o,contentType:a,ETag:g,expiredAt:s,id:t,metadata:l,modifiedAt:m,name:u,originalName:d,size:E?o.length:c||n}})}async exists({id:t}){return this.instrumentOperation("exists",async()=>{try{const r=await this.getMeta(t),i=this.getFilePath(r.name);return await B(i),!0}catch{return!1}})}async getStream({id:t}){return this.instrumentOperation("getStream",async()=>{try{const r=await this.checkIfExpired(await this.meta.get(t)),{bytesWritten:i,contentType:n,expiredAt:a,modifiedAt:s,name:l,size:m}=r,u=mt(this.getFilePath(l));return{headers:{"Content-Length":String(m||i),"Content-Type":n,...a&&{"X-Upload-Expires":a.toString()},...s&&{"Last-Modified":s.toString()}},size:m||i,stream:u}}catch(r){const i=this.normalizeError(r instanceof Error?r:new Error(String(r)));throw await this.onError(i),w(y.FILE_NOT_FOUND,(typeof i.message=="string"?i.message:String(r))||String(r))}})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{const r=await this.getMeta(t);await V(this.getFilePath(r.name)),await this.deleteMeta(t);const i={...r,status:"deleted"};return await this.onDelete(i),i})}async copy(t,r){return this.instrumentOperation("copy",async()=>{O.assertSafeId(t),O.assertSafeId(r);const i=await this.getMeta(t);return await U(this.getFilePath(i.name),this.getFilePath(r)),{...i,name:r}})}async move(t,r){return this.instrumentOperation("move",async()=>{O.assertSafeId(t),O.assertSafeId(r);const i=await this.getMeta(t),n=this.getFilePath(i.name),a=this.getFilePath(r);try{await je(n,a)}catch(s){if(s?.code==="EXDEV")await U(n,a),await V(n);else{const l=this.normalizeError(s instanceof Error?s:new Error(String(s)));throw await this.onError(l),s}}return{...i,id:i.id,name:r}})}async list(){return this.instrumentOperation("list",async()=>{const t={followSymlinks:!1,includeDirs:!1,includeFiles:!0,skip:["*.META$"]},r=[],{directory:i}=this,n=A(s=>s.replaceAll("\\","/"),"toPosix"),a=n(i);for await(const s of D(i,t)){const{suffix:l}=this.meta,{path:m}=s;if(!m.includes(l)){const{birthtime:u,ctime:d,mtime:c}=await B(m),o=n(m),g=o.startsWith(a)?o.slice(a.length):o;r.push({createdAt:u||d,id:g,modifiedAt:c})}}return r})}getFilePath(t){return O.assertSafeId(t),Ot(t)&&w(y.INVALID_FILE_NAME,`Invalid file id: "${t}"`),Tt(this.directory,t)}lazyWrite(t){return new Promise((r,i)=>{const n=dt(this.getFilePath(t.name),{flags:"r+",start:t.start}),a=new Ue(t.contentLength||t.size-t.start),s=ze(t.checksum,t.checksumAlgorithm),l=!t.checksum,{signal:m}=t,u=A(()=>{n.close(),a.destroy(),s.destroy()},"cleanupStreams"),d=A(c=>{u(),r([Number.NaN,c])},"failWithCode");if(a.on("error",()=>{d(y.FILE_CONFLICT)}),s.on("error",()=>{d(y.CHECKSUM_MISMATCH)}),t.body.on("aborted",()=>{d(l?void 0:y.REQUEST_ABORTED)}),t.body.on("error",c=>{u(),i(c)}),m?.aborted){d(l?void 0:y.REQUEST_ABORTED);return}m&&m.addEventListener("abort",()=>{u(),n.destroy(),a.destroy(),s.destroy(),t.body.destroy(),r([Number.NaN,l?void 0:y.REQUEST_ABORTED])}),ft(t.body,a,s,n,c=>{if(c){if(u(),m?.aborted){r([Number.NaN,l?void 0:y.REQUEST_ABORTED]);return}r([Number.NaN,y.FILE_ERROR]);return}r([t.start+n.bytesWritten])})})}async accessCheck(){await K(this.directory)}}export{Ue as m,O as p,ze as s,j as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var m=Object.defineProperty;var p=(t,n)=>m(t,"name",{value:n,configurable:!0});import*as e from"zod";const y=1024*1024,u=e.object({limit:e.int().positive().max(1e3).optional().meta({description:"Maximum number of items to return"}),prefix:e.string().trim().optional().meta({description:"Only return keys that start with this prefix"})}),f=e.object({key:e.string().trim().meta({description:"The object key to inspect"})}),g=e.object({binary:e.boolean().optional().meta({description:"When true, returns base64-encoded bytes instead of UTF-8 text"}),key:e.string().trim().meta({description:"The object key to download"}),maxBytes:e.int().positive().optional().meta({description:`Reject downloads larger than this byte count (default ${y}). Verified via head() before transferring.`})}),b=e.object({expiresIn:e.int().positive().optional().meta({description:"Override the adapter default URL expiry in seconds. Ignored by permanent-CDN adapters."}),key:e.string().trim().meta({description:"The object key to build a URL for"}),responseContentDisposition:e.string().trim().optional().meta({description:`Force a Content-Disposition header on the response (e.g. 'attachment; filename="f.txt"'). Strongly recommended for user-uploaded content to prevent inline rendering of HTML/SVG.`})}),h=e.object({content:e.string().meta({description:'File body. Treated as UTF-8 text unless encoding is "base64".'}),contentType:e.string().trim().optional().meta({description:"MIME type recorded with the object"}),encoding:e.enum(["text","base64"]).optional().meta({description:"How to interpret content (default: text)"}),key:e.string().trim().meta({description:"Destination object key"}),metadata:e.record(e.string().trim(),e.string()).optional().meta({description:"Custom string metadata to attach to the object"})}),F=e.object({key:e.string().trim().meta({description:"Object key to delete"})}),k=e.object({from:e.string().trim().meta({description:"Source object key"}),to:e.string().trim().meta({description:"Destination object key"})}),w=e.object({contentType:e.string().trim().optional().meta({description:"Content-Type that the upload must declare"}),expiresIn:e.int().positive().meta({description:"Lifetime of the presigned URL in seconds"}),key:e.string().trim().meta({description:"Destination object key"})}),M={copyFile:{description:"Copy a file to a new key within the configured bucket. The source remains intact.",input:k},deleteFile:{description:"Permanently delete a file from the configured bucket.",input:F},downloadFile:{description:"Download a file and return its contents. Returns UTF-8 text by default; set binary=true to receive base64-encoded bytes. Files larger than maxBytes are rejected before transfer.",input:g},getFileMetadata:{description:"Fetch metadata for a single file (size, content type, etag, custom metadata) without transferring its body.",input:f},getFileUrl:{description:"Return a signed, time-limited URL the caller can use to fetch a file. Adapters that don't support presigning will throw MethodNotAllowed.",input:b},listFiles:{description:"List files in the configured bucket, optionally filtered by key prefix.",input:u},signUploadUrl:{description:"Issue a presigned URL that lets a client upload directly to the configured bucket. Approval-gated by default — the URL grants upload permission until it expires.",input:w},uploadFile:{description:'Upload a file to the configured bucket. Pass content as UTF-8 text by default, or as base64 with encoding="base64" for binary payloads.',input:h}},T=["uploadFile","deleteFile","copyFile","signUploadUrl"],S=new Set(T);var x=Object.defineProperty,s=p((t,n)=>x(t,"name",{value:n,configurable:!0}),"r");const l=s(t=>{if(t!==void 0)return t instanceof Date?t.toISOString():typeof t=="number"?new Date(t).toISOString():t},"serializeLastModified"),j={copyFile:s(async(t,{from:n,to:i})=>{const o=await t.copy(n,i);return{copied:!0,etag:o.etag,from:n,key:o.key,to:i}},"copyFile"),deleteFile:s(async(t,{key:n})=>(await t.delete(n),{deleted:!0,key:n}),"deleteFile"),downloadFile:s(async(t,{binary:n,key:i,maxBytes:o})=>{const r=o??y,c=await t.head(i);if(typeof c.size=="number"&&c.size>r)throw new RangeError(`downloadFile refused: "${i}" is ${c.size} bytes which exceeds the maxBytes limit of ${r}. Use getFileUrl to delegate to the client, or raise maxBytes.`);const a=await t.download(i);if(a.body.byteLength>r)throw new RangeError(`downloadFile refused: "${i}" returned ${a.body.byteLength} bytes which exceeds the maxBytes limit of ${r}. Use getFileUrl instead.`);return n?{content:a.body.toString("base64"),contentType:a.contentType,encoding:"base64",key:a.key,...typeof a.size=="number"?{size:a.size}:{}}:{content:a.body.toString("utf8"),contentType:a.contentType,encoding:"text",key:a.key,...typeof a.size=="number"?{size:a.size}:{}}},"downloadFile"),getFileMetadata:s(async(t,{key:n})=>{const i=await t.head(n);return{contentType:i.contentType,...i.etag?{etag:i.etag}:{},key:i.key,...l(i.lastModified)?{lastModified:l(i.lastModified)}:{},...i.metadata?{metadata:i.metadata}:{},...typeof i.size=="number"?{size:i.size}:{}}},"getFileMetadata"),getFileUrl:s(async(t,{expiresIn:n,key:i,responseContentDisposition:o})=>{const r=await t.url(i,{expiresIn:n,responseContentDisposition:o});return{key:i,url:r}},"getFileUrl"),listFiles:s(async(t,{limit:n,prefix:i})=>({items:(await t.list({limit:n,prefix:i})).map(o=>({contentType:o.contentType,...o.etag?{etag:o.etag}:{},key:o.key,...l(o.lastModified)?{lastModified:l(o.lastModified)}:{},...typeof o.size=="number"?{size:o.size}:{}}))}),"listFiles"),signUploadUrl:s(async(t,{contentType:n,expiresIn:i,key:o})=>{const r=await t.signedUploadUrl(o,{contentType:n,expiresIn:i});return{key:o,url:r}},"signUploadUrl"),uploadFile:s(async(t,{content:n,contentType:i,encoding:o,key:r,metadata:c})=>{const a=o==="base64"?Buffer.from(n,"base64"):Buffer.from(n,"utf8"),d=await t.upload(r,a,{contentType:i,metadata:c});return{contentType:d.contentType,...d.etag?{etag:d.etag}:{},key:d.key,...l(d.lastModified)?{lastModified:l(d.lastModified)}:{},...typeof d.size=="number"?{size:d.size}:{}}},"uploadFile")};export{M as T,S as W,j as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var kr=Object.defineProperty;var h=(e,t)=>kr(e,"name",{value:t,configurable:!0});import{utimes as _r}from"node:fs/promises";import{tmpdir as Ar}from"node:os";import{createRequire as R}from"node:module";import{L as _e,M as Tr}from"./path-D7rMc9nq-CPbxyMDy.js";import{throwErrorCode as ne,ERRORS as oe}from"./ERRORS-CyOuSMLY.js";import Br from"./MetaStorage-Y4m1dWgd.js";import{stringifyMetadata as Rr,parseMetadata as Sr}from"./Metadata-B6Ir0KO7.js";const ie=0,Fr=4;var Ir=Object.defineProperty,Nr=h((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"t$6"),Lr=Object.defineProperty,Cr=Nr((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"t"),Dr=Object.defineProperty,Wr=Cr((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"n");const G=Wr(e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var Ur=Object.defineProperty,qr=h((e,t)=>Ur(e,"name",{value:t,configurable:!0}),"i$8"),Zr=Object.defineProperty,Vr=qr((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"r"),Gr=Object.defineProperty,Jr=Vr((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"i");const Ae=Jr(e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"},"getFileInfoType");var Xr=Object.defineProperty,Yr=h((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"i$7"),Hr=Object.defineProperty,Le=Yr((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"s");const Kr=R(import.meta.url),C=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Qr=Le(e=>{if(typeof C<"u"&&C.versions&&C.versions.node){const[t,o]=C.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return C.getBuiltinModule(e)}return Kr(e)},"__cjs_getBuiltinModule"),{lstat:Te,mkdir:en}=Qr("node:fs/promises");var tn=Object.defineProperty,rn=Le((e,t)=>tn(e,"name",{value:t,configurable:!0}),"o");const nn=rn(async e=>{G(e);try{const t=await Te(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(Ae(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{await en(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const o=await Te(e);if(!o.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(Ae(o))}'`,{cause:t})}},"ensureDir");var on=Object.defineProperty,c=h((e,t)=>on(e,"name",{value:t,configurable:!0}),"s$4");let Be=c(()=>{var e=(()=>{var t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,m=c((r,n)=>{for(var a in n)t(r,a,{get:n[a],enumerable:!0})},"ne"),y=c((r,n,a,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of l(n))!d.call(r,s)&&s!==a&&t(r,s,{get:c(()=>n[s],"get"),enumerable:!(i=o(n,s))||i.enumerable});return r},"ae"),v=c(r=>y(t({},"__esModule",{value:!0}),r),"oe"),k={};m(k,{zeptomatch:c(()=>ke,"zeptomatch")});var S=c(r=>{const n=new Set,a=[r];for(let i=0;i<a.length;i++){const s=a[i];if(n.has(s))continue;n.add(s);const{children:u}=s;if(u?.length)for(let f=0,g=u.length;f<g;f++)a.push(u[f])}return Array.from(n)},"M"),J=c(r=>{let n="";const a=S(r);for(let i=0,s=a.length;i<s;i++){const u=a[i];if(!u.regex)continue;const f=u.regex.flags;if(n||(n=f),n!==f)throw new Error(`Inconsistent RegExp flags used: "${n}" and "${f}"`)}return n},"se"),fe=c((r,n,a)=>{const i=a.get(r);if(i!==void 0)return i;const s=r.partial??n;let u="";if(r.regex&&(u+=s?"(?:$|":"",u+=r.regex.source),r.children?.length){const f=ot(r.children.map(g=>fe(g,n,a)).filter(Boolean));if(f?.length){const g=r.children.some(N=>!N.regex||!(N.partial??n)),$=f.length>1||s&&(!u.length||g);u+=$?s?"(?:$|":"(?:":"",u+=f.join("|"),u+=$?")":""}}return r.regex&&(u+=s?")":""),a.set(r,u),u},"O"),nt=c((r,n)=>{const a=new Map,i=S(r);for(let s=i.length-1;s>=0;s--){const u=fe(i[s],n,a);if(!(s>0))return u}return""},"ie"),ot=c(r=>Array.from(new Set(r)),"ue"),H=c((r,n,a)=>H.compile(r,a).test(n),"R");H.compile=(r,n)=>{const a=n?.partial??!1,i=nt(r,a),s=J(r);return new RegExp(`^(?:${i})$`,s)};var at=H,st=c((r,n)=>{const a=at.compile(r,n),i=`${a.source.slice(0,-1)}[\\\\/]?$`,s=a.flags;return new RegExp(i,s)},"le"),it=st,lt=c(r=>{const n=r.map(i=>i.source).join("|")||"$^",a=r[0]?.flags;return new RegExp(n,a)},"ve"),ct=lt,pe=c(r=>Array.isArray(r),"j"),F=c(r=>typeof r=="function","_"),ut=c(r=>r.length===0,"he"),ft=(()=>{const{toString:r}=Function.prototype,n=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return a=>(a.length===0||a.length===1)&&n.test(r.call(a))})(),pt=c(r=>typeof r=="number","de"),dt=c(r=>typeof r=="object"&&r!==null,"xe"),gt=c(r=>r instanceof RegExp,"me"),mt=(()=>{const r=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return n=>r.test(n.source)})(),ht=(()=>{const r=/^[a-zA-Z0-9_-]+$/;return n=>r.test(n.source)&&!n.flags.includes("i")})(),de=c(r=>typeof r=="string","A"),P=c(r=>r===void 0,"f"),bt=c(r=>{const n=new Map;return a=>{const i=n.get(a);if(i!==void 0)return i;const s=r(a);return n.set(a,s),s}},"ye"),ge=c((r,n,a={})=>{const i={cache:{},input:r,index:0,indexBacktrackMax:0,options:a,output:[]},s=E(n)(i),u=Math.max(i.index,i.indexBacktrackMax);if(s&&i.index===r.length)return i.output;throw new Error(`Failed to parse at index ${u}`)},"I"),p=c((r,n)=>pe(r)?$t(r,n):de(r)?me(r,n):vt(r,n),"i"),$t=c((r,n)=>{const a={};for(const i of r){if(i.length!==1)throw new Error(`Invalid character: "${i}"`);const s=i.charCodeAt(0);a[s]=!0}return i=>{const s=i.input;let u=i.index,f=u;for(;f<s.length&&s.charCodeAt(f)in a;)f+=1;if(f>u){if(!P(n)&&!i.options.silent){const g=s.slice(u,f),$=F(n)?n(g,s,`${u}`):n;P($)||i.output.push($)}i.index=f}return!0}},"we"),vt=c((r,n)=>{if(ht(r))return me(r.source,n);{const a=r.source,i=r.flags.replace(/y|$/,"y"),s=new RegExp(a,i);return mt(r)&&F(n)&&!ft(n)?yt(s,n):wt(s,n)}},"$e"),yt=c((r,n)=>a=>{const i=a.index,s=a.input;r.lastIndex=i;const u=r.exec(s);if(u){const f=r.lastIndex;if(!a.options.silent){const g=n(...u,s,`${i}`);P(g)||a.output.push(g)}return a.index=f,!0}else return!1},"Ee"),wt=c((r,n)=>a=>{const i=a.index,s=a.input;if(r.lastIndex=i,r.test(s)){const u=r.lastIndex;if(!P(n)&&!a.options.silent){const f=F(n)?n(s.slice(i,u),s,`${i}`):n;P(f)||a.output.push(f)}return a.index=u,!0}else return!1},"Ce"),me=c((r,n)=>a=>{const i=a.index,s=a.input;if(s.startsWith(r,i)){if(!P(n)&&!a.options.silent){const u=F(n)?n(r,s,`${i}`):n;P(u)||a.output.push(u)}return a.index+=r.length,!0}else return!1},"F"),K=c((r,n,a,i)=>{const s=E(r),u=n>1;return ee(Q(be(f=>{let g=0;for(;g<a;){const $=f.index;if(!s(f)||(g+=1,f.index===$))break}return g>=n},u),i))},"k"),he=c((r,n)=>K(r,0,1,n),"L"),X=c((r,n)=>K(r,0,1/0,n),"$"),xt=c((r,n)=>K(r,1,1/0,n),"Re"),A=c((r,n)=>{const a=r.map(E);return ee(Q(be(i=>{for(let s=0,u=a.length;s<u;s++)if(!a[s](i))return!1;return!0}),n))},"x"),x=c((r,n)=>{const a=r.map(E);return ee(Q(i=>{for(let s=0,u=a.length;s<u;s++)if(a[s](i))return!0;return!1},n))},"p"),be=c((r,n=!0,a=!1)=>{const i=E(r);return n?s=>{const u=s.index,f=s.output.length,g=i(s);return!g&&!a&&(s.indexBacktrackMax=Math.max(s.indexBacktrackMax,s.index)),(!g||a)&&(s.index=u,s.output.length!==f&&(s.output.length=f)),g}:i},"q"),Q=c((r,n)=>{const a=E(r);return n?i=>{if(i.options.silent)return a(i);const s=i.output.length;if(a(i)){const u=i.output.splice(s,1/0),f=n(u);return P(f)||i.output.push(f),!0}else return!1}:a},"B"),ee=(()=>{let r=0;return n=>{const a=E(n),i=r+=1;return s=>{var u;if(s.options.memoization===!1)return a(s);const f=s.index,g=(u=s.cache)[i]||(u[i]={indexMax:-1,queue:[]}),$=g.queue;if(f<=g.indexMax){const L=g.store||(g.store=new Map);if($.length){for(let B=0,Er=$.length;B<Er;B+=2){const Mr=$[B*2],zr=$[B*2+1];L.set(Mr,zr)}$.length=0}const j=L.get(f);if(j===!1)return!1;if(pt(j))return s.index=j,!0;if(j)return s.index=j.index,j.output?.length&&s.output.push(...j.output),!0}const N=s.output.length,Pr=a(s);if(g.indexMax=Math.max(g.indexMax,f),Pr){const L=s.index,j=s.output.length;if(j>N){const B=s.output.slice(N,j);$.push(f,{index:L,output:B})}else $.push(f,L);return!0}else return $.push(f,!1),!1}}})(),$e=c(r=>{let n;return a=>(n||(n=E(r())),n(a))},"G"),E=bt(r=>{if(F(r))return ut(r)?$e(r):r;if(de(r)||gt(r))return p(r);if(pe(r))return A(r);if(dt(r))return x(Object.values(r));throw new Error("Invalid rule")}),_=c(r=>r,"d"),jt=c(r=>typeof r=="string","ke"),Ot=c(r=>{const n=new WeakMap,a=new WeakMap;return(i,s)=>{const u=s?.partial?a:n,f=u.get(i);if(f!==void 0)return f;const g=r(i,s);return u.set(i,g),g}},"Be"),Pt=c(r=>{const n={},a={};return(i,s)=>{const u=s?.partial?a:n;return u[i]??(u[i]=r(i,s))}},"Pe"),Et=p(/\\./,_),Mt=p(/./,_),zt=p(/\*\*\*+/,"*"),kt=p(/([^/{[(!])\*\*/,(r,n)=>`${n}*`),_t=p(/(^|.)\*\*(?=[^*/)\]}])/,(r,n)=>`${n}*`),At=X(x([Et,zt,kt,_t,Mt])),Tt=At,Bt=c(r=>ge(r,Tt,{memoization:!1}).join(""),"Ie"),Rt=Bt,ve="abcdefghijklmnopqrstuvwxyz",St=c(r=>{let n="";for(;r>0;){const a=(r-1)%26;n=ve[a]+n,r=Math.floor((r-1)/26)}return n},"Le"),ye=c(r=>{let n=0;for(let a=0,i=r.length;a<i;a++)n=n*26+ve.indexOf(r[a])+1;return n},"V"),te=c((r,n)=>{if(n<r)return te(n,r);const a=[];for(;r<=n;)a.push(r++);return a},"b"),Ft=c((r,n,a)=>te(r,n).map(i=>String(i).padStart(a,"0")),"qe"),we=c((r,n)=>te(ye(r),ye(n)).map(St),"W"),b=c(r=>({partial:!1,regex:new RegExp(r,"s"),children:[]}),"c"),I=c(r=>({children:r}),"y"),T=(()=>{const r=c((n,a,i)=>{if(i.has(n))return;i.add(n);const{children:s}=n;if(!s.length)s.push(a);else for(let u=0,f=s.length;u<f;u++)r(s[u],a,i)},"e");return n=>{if(!n.length)return I([]);for(let a=n.length-1;a>=1;a--){const i=new Set,s=n[a-1],u=n[a];r(s,u,i)}return n[0]}})(),M=c(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),It=p(/\\./,b),Nt=p(/[$.*+?^(){}[\]\|]/,r=>b(`\\${r}`)),Lt=p(/[\\\/]/,M),Ct=p(/[^$.*+?^(){}[\]\|\\\/]+/,b),Dt=p(/^(?:!!)*!(.*)$/,(r,n)=>b(`(?!^${ke.compile(n).source}$).*?`)),Wt=p(/^(!!)+/),Ut=x([Dt,Wt]),qt=p(/\/(\*\*\/)+/,()=>I([T([M(),b(".+?"),M()]),M()])),Zt=p(/^(\*\*\/)+/,()=>I([b("^"),T([b(".*?"),M()])])),Vt=p(/\/(\*\*)$/,()=>I([T([M(),b(".*?")]),b("$")])),Gt=p(/\*\*/,()=>b(".*?")),xe=x([qt,Zt,Vt,Gt]),Jt=p(/\*\/(?!\*\*\/|\*$)/,()=>T([b("[^\\\\/]*?"),M()])),Xt=p(/\*/,()=>b("[^\\\\/]*")),je=x([Jt,Xt]),Oe=p("?",()=>b("[^\\\\/]")),Yt=p("[",_),Ht=p("]",_),Kt=p(/[!^]/,"^\\\\/"),Qt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,_),er=p(/\\./,_),tr=p(/[$.*+?^(){}[\|]/,r=>`\\${r}`),rr=p(/[\\\/]/,"\\\\/"),nr=p(/[^$.*+?^(){}[\]\|\\\/]+/,_),or=x([er,tr,rr,Qt,nr]),Pe=A([Yt,he(Kt),X(or),Ht],r=>b(r.join(""))),ar=p("{","(?:"),sr=p("}",")"),ir=p(/(\d+)\.\.(\d+)/,(r,n,a)=>Ft(+n,+a,Math.min(n.length,a.length)).join("|")),lr=p(/([a-z]+)\.\.([a-z]+)/,(r,n,a)=>we(n,a).join("|")),cr=p(/([A-Z]+)\.\.([A-Z]+)/,(r,n,a)=>we(n.toLowerCase(),a.toLowerCase()).join("|").toUpperCase()),ur=x([ir,lr,cr]),Ee=A([ar,ur,sr],r=>b(r.join(""))),fr=p("{"),pr=p("}"),dr=p(","),gr=p(/\\./,b),mr=p(/[$.*+?^(){[\]\|]/,r=>b(`\\${r}`)),hr=p(/[\\\/]/,M),br=p(/[^$.*+?^(){}[\]\|\\\/,]+/,b),$r=$e(()=>ze),vr=p("",()=>b("(?:)")),yr=xt(x([xe,je,Oe,Pe,Ee,$r,gr,mr,hr,br]),T),Me=x([yr,vr]),ze=A([fr,he(A([Me,X(A([dr,Me]))])),pr],I),wr=X(x([Ut,xe,je,Oe,Pe,Ee,ze,It,Nt,Lt,Ct]),T),xr=wr,jr=c(r=>ge(r,xr,{memoization:!1})[0],"kr"),Or=jr,re=c((r,n,a)=>re.compile(r,a).test(n),"N");re.compile=(()=>{const r=Pt((a,i)=>it(Or(Rt(a)),i)),n=Ot((a,i)=>ct(a.map(s=>r(s,i))));return(a,i)=>jt(a)?r(a,i):n(a,i)})();var ke=re;return v(k)})();return e.default||e},"_lazyMatch"),ae;const an=c((e,t)=>(ae||(ae=Be(),Be=null),ae(e,t)),"zeptomatch"),sn=/^[A-Z]:\//i,O=c((e="")=>e&&e.replaceAll("\\","/").replace(sn,t=>t.toUpperCase()),"normalizeWindowsPath"),ln=/^[/\\]{2}/,cn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Ce=/^[A-Z]:$/i,Re=/^\/([A-Z]:)?$/i,un=/.(\.[^./]+)$/,fn=/^[/\\]|^[a-z]:[/\\]/i,pn=/\/$/,dn=c(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),De=c((e,t)=>{let o="",l=0,d=-1,m=0,y;for(let v=0;v<=e.length;++v){if(v<e.length)y=e[v];else{if(y==="/")break;y="/"}if(y==="/"){if(!(d===v-1||m===1))if(m===2){if(o.length<2||l!==2||!o.endsWith(".")||o.at(-2)!=="."){if(o.length>2){const k=o.lastIndexOf("/");k===-1?(o="",l=0):(o=o.slice(0,k),l=o.length-1-o.lastIndexOf("/")),d=v,m=0;continue}else if(o.length>0){o="",l=0,d=v,m=0;continue}}t&&(o+=o.length>0?"/..":"..",l=2)}else o.length>0?o+=`/${e.slice(d+1,v)}`:o=e.slice(d+1,v),l=v-d-1;d=v,m=0}else y==="."&&m!==-1?++m:m=-1}return o},"normalizeString"),V=c(e=>cn.test(e),"isAbsolute"),We=c(function(e){if(e.length===0)return".";e=O(e);const t=ln.exec(e),o=V(e),l=e.at(-1)==="/";return e=De(e,!o),e.length===0?o?"/":l?"./":".":(l&&(e+="/"),Ce.test(e)&&(e+="/"),t?o?`//${e}`:`//./${e}`:o&&!V(e)?`/${e}`:e)},"normalize"),Ue=c((...e)=>{let t="";for(const o of e)if(o)if(t.length>0){const l=t.at(-1)==="/",d=o[0]==="/";l&&d?t+=o.slice(1):t+=l||d?o:`/${o}`}else t+=o;return We(t)},"join"),le=c(function(...e){e=e.map(l=>O(l));let t="",o=!1;for(let l=e.length-1;l>=-1&&!o;l--){const d=l>=0?e[l]:dn();!d||d.length===0||(t=`${d}/${t}`,o=V(d))}return t=De(t,!o),o&&!V(t)?`/${t}`:t.length>0?t:"."},"resolve");c(function(e){return O(e)},"toNamespacedPath");const qe=c(function(e){return un.exec(O(e))?.[1]??""},"extname");c(function(e,t){const o=le(e).replace(Re,"$1").split("/"),l=le(t).replace(Re,"$1").split("/");if(l[0][1]===":"&&o[0][1]===":"&&o[0]!==l[0])return l.join("/");const d=[...o];for(const m of d){if(l[0]!==m)break;o.shift(),l.shift()}return[...o.map(()=>".."),...l].join("/")},"relative");const Ze=c(e=>{const t=O(e).replace(pn,"").split("/").slice(0,-1);return t.length===1&&Ce.test(t[0])&&(t[0]=`${t[0]}/`),t.join("/")||(V(e)?"/":".")},"dirname");c(function(e){const t=[e.root,e.dir,e.base??e.name+e.ext].filter(Boolean);return O(e.root?le(...t):t.join("/"))},"format");const gn=c((e,t)=>{const o=O(e).split("/").pop();return t&&o.endsWith(t)?o.slice(0,-t.length):o},"basename");c(function(e){const t=fn.exec(e)?.[0]?.replaceAll("\\","/")??"",o=gn(e),l=qe(o);return{base:o,dir:Ze(e),ext:l,name:o.slice(0,o.length-l.length),root:t}},"parse");c((e,t)=>an(t,We(e)),"matchesGlob");var mn=Object.defineProperty,w=h((e,t)=>mn(e,"name",{value:t,configurable:!0}),"i$6");const hn=R(import.meta.url),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,bn=w(e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[t,o]=D.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return D.getBuiltinModule(e)}return hn(e)},"__cjs_getBuiltinModule"),{fileURLToPath:$n}=bn("node:url");function Ve(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}h(Ve,"w$2");w(Ve,"getDefaultExportFromCjs");var Se,Fe;function Ge(){return Fe||(Fe=1,Se=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Se}h(Ge,"y$2");w(Ge,"requireBinaryExtensions");var vn=Ge();const yn=Ve(vn),wn=new Set(yn),xn=new Set(["/","\\",void 0]),Ie=Symbol.for("pathe:normalizedAlias"),jn=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,On=w((e,t)=>t.split("/").length-e.split("/").length,"compareAliases"),Y=w((e="/")=>{const t=e.at(-1);return t==="/"||t==="\\"},"hasTrailingSlash"),Je=w(e=>{if(e[Ie])return e;const t=Object.fromEntries(Object.entries(e).toSorted(([o],[l])=>On(o,l)));for(const o in t)for(const l in t)l===o||o.startsWith(l)||t[o].startsWith(l)&&xn.has(t[o][l.length])&&(t[o]=t[l]+t[o].slice(l.length));return Object.defineProperty(t,Ie,{enumerable:!1,value:!0}),t},"normalizeAliases");w((e,t)=>{e=O(e),t=Je(t);for(const[o,l]of Object.entries(t)){if(!e.startsWith(o))continue;const d=Y(o)?o.slice(0,-1):o;if(Y(e[d.length]))return Ue(l,e.slice(o.length))}return e},"resolveAlias");w(e=>jn.exec(e)?.[2],"filename");w((e,t)=>{e=O(e),t=Je(t);for(const[o,l]of Object.entries(t).toReversed()){if(!e.startsWith(l))continue;const d=Y(l)?l.slice(0,-1):l;if(Y(e[d.length]))return Ue(o,e.slice(l.length))}return e},"reverseResolveAlias");const Pn=/^(?:\.?\.[/\\]|\.\.\B)/,En=/^(?:msys|cygwin)$/;w(e=>Pn.test(e)||e==="..","isRelative");w(e=>wn.has(qe(e).slice(1).toLowerCase()),"isBinaryPath");const ce=w(e=>O(e instanceof URL?$n(e):e),"toPath");w(()=>{if(!globalThis.process)return!1;if(globalThis.process.platform==="win32"||globalThis.process.platform==="cygwin")return!0;const e=globalThis.process.env.OSTYPE;return typeof e!="string"?!1:En.test(e)},"isWindows");var Mn=Object.defineProperty,Xe=h((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"t$4"),zn=Object.defineProperty,ue=Xe((e,t)=>zn(e,"name",{value:t,configurable:!0}),"s");const kn=R(import.meta.url),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_n=ue(e=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[t,o]=W.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return W.getBuiltinModule(e)}return kn(e)},"__cjs_getBuiltinModule"),{access:An}=_n("node:fs/promises");var Tn=Object.defineProperty,Bn=ue((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"o");async function z(e,t=ie){G(e),e=ce(e);try{return await An(e,t),!0}catch{return!1}}h(z,"i$5");Xe(z,"d");ue(z,"m");Bn(z,"isAccessible");var Rn=Object.defineProperty,Ye=h((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"t$3"),Sn=Object.defineProperty,He=Ye((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"t"),Fn=Object.defineProperty,In=He((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"o");let Nn=class extends Error{static{h(this,"c")}static{Ye(this,"i")}static{He(this,"n")}static{In(this,"PermissionError")}constructor(t){super(`EPERM: Operation not permitted, ${t}`)}get code(){return"EPERM"}set code(t){throw new Error("Cannot overwrite code EPERM")}get name(){return"PermissionError"}set name(t){throw new Error("Cannot overwrite name of PermissionError")}};var Ln=Object.defineProperty,Cn=h((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"f$4"),Dn=Object.defineProperty,Ke=Cn((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"i");const Wn=R(import.meta.url),U=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Qe=Ke(e=>{if(typeof U<"u"&&U.versions&&U.versions.node){const[t,o]=U.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return U.getBuiltinModule(e)}return Wn(e)},"__cjs_getBuiltinModule"),{readFile:Un}=Qe("node:fs/promises"),{unzip:qn,brotliDecompress:Zn}=Qe("node:zlib");var Vn=Object.defineProperty,et=Ke((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"n");const Gn={brotli:Zn,gzip:qn,none:et((e,t)=>{t(null,e)},"none")},Jn=et(async(e,t)=>{if(G(e),e=ce(e),!await z(e))throw new Nn(`unable to read the non-accessible file: ${e}`);if(!await z(e,Fr))throw new Error(`Unable to read the non-readable file: ${e}`);const{buffer:o,compression:l,encoding:d,flag:m}=t??{};return await Un(e,m?{encoding:d,flag:m}:{encoding:d}).then(async y=>await new Promise((v,k)=>{Gn[l??"none"](y,(S,J)=>{S?k(S):v(o?J:J.toString())})})).catch(y=>{throw y})},"readFile");var Xn=Object.defineProperty,Yn=h((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"a$4"),Hn=Object.defineProperty,Kn=Yn((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"t"),Qn=Object.defineProperty,eo=Kn((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"t");const to=eo(e=>{const t={force:!0,recursive:!0};return e?.maxRetries!==void 0&&(t.maxRetries=e.maxRetries),e?.retryDelay!==void 0&&(t.retryDelay=e.retryDelay),t},"buildRmOptions");var ro=Object.defineProperty,no=h((e,t)=>ro(e,"name",{value:t,configurable:!0}),"i$2"),oo=Object.defineProperty,tt=no((e,t)=>oo(e,"name",{value:t,configurable:!0}),"s");const ao=R(import.meta.url),q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,so=tt(e=>{if(typeof q<"u"&&q.versions&&q.versions.node){const[t,o]=q.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return q.getBuiltinModule(e)}return ao(e)},"__cjs_getBuiltinModule"),{unlink:io,rm:lo}=so("node:fs/promises");var co=Object.defineProperty,uo=tt((e,t)=>co(e,"name",{value:t,configurable:!0}),"i");const fo=uo(async(e,t={})=>{G(e);try{await io(e)}catch{}try{await lo(e,to(t))}catch{}},"remove");var po=Object.defineProperty,go=h((e,t)=>po(e,"name",{value:t,configurable:!0}),"a$2"),mo=Object.defineProperty,ho=go((e,t)=>mo(e,"name",{value:t,configurable:!0}),"t"),bo=Object.defineProperty,$o=ho((e,t)=>bo(e,"name",{value:t,configurable:!0}),"e");const vo=$o(e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},"assertValidFileContents");var yo=Object.defineProperty,wo=h((e,t)=>yo(e,"name",{value:t,configurable:!0}),"t"),xo=Object.defineProperty,jo=wo((e,t)=>xo(e,"name",{value:t,configurable:!0}),"r"),Oo=Object.defineProperty,Po=jo((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"f");const Eo=new TextEncoder,Mo=Po(e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Eo.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){const t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},"toUint8Array");var zo=Object.defineProperty,ko=h((e,t)=>zo(e,"name",{value:t,configurable:!0}),"m"),_o=Object.defineProperty,rt=ko((e,t)=>_o(e,"name",{value:t,configurable:!0}),"s");const Ao=R(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,To=rt(e=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[t,o]=Z.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return Z.getBuiltinModule(e)}return Ao(e)},"__cjs_getBuiltinModule"),{mkdir:Bo,writeFile:Ro,stat:So,rename:Ne,chown:Fo,chmod:Io,unlink:No}=To("node:fs/promises");var Lo=Object.defineProperty,Co=rt((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"d");const Do=Co(async(e,t,o)=>{o={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...o},G(e),vo(t),e=ce(e);const l=`${e}.tmp`;try{const d=await z(e,ie);if(!d&&o.recursive){const y=Ze(e);await z(y,ie)||await Bo(y,{recursive:!0})}let m;if(await Ro(l,Mo(t),{encoding:o.encoding,flag:o.flag}),d&&!o.overwrite&&(m=await So(e),o.chown??={gid:m.gid,uid:m.uid},await Ne(e,`${e}.bak`)),o.chown)try{await Fo(l,o.chown.uid,o.chown.gid)}catch{}await Io(l,m&&!o.mode?m.mode:o.mode??438),await Ne(l,e)}catch(d){throw new Error(`Failed to write file at: ${e} - ${d.message}`,{cause:d})}finally{await z(l)&&await No(`${e}.tmp`)}},"writeFile");var Wo=Object.defineProperty,se=h((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"a");let Ko=class extends Br{static{h(this,"v")}static{se(this,"LocalMetaStorage")}directory;constructor(t){super(t),this.directory=_e(t?.directory||Tr(Ar(),"Upload_meta")),this.accessCheck().catch(o=>{this.logger?.error("Metadata storage access check failed: %O",o)})}getMetaPath=se(t=>{const o=_e(`${this.directory}/${this.prefix}${t}${this.suffix}`),l=this.directory.endsWith("/")?this.directory:`${this.directory}/`;return o.startsWith(l)?o:ne(oe.INVALID_FILE_NAME,`Invalid id: "${t}" resolves outside the meta directory`)},"getMetaPath");getIdFromPath=se(t=>t.slice(`${this.directory}/${this.prefix}`.length,-this.suffix.length),"getIdFromPath");async save(t,o){await this.accessCheck();const l={...o};return l.metadata&&(l.metadata=Rr(o.metadata)),await Do(this.getMetaPath(t),JSON.stringify(l),{recursive:!0}),o}async touch(t,o){const l=new Date;return await _r(this.getMetaPath(t),l,l),o}async get(t){try{const o=await Jn(this.getMetaPath(t));if(o===void 0)throw ne(oe.FILE_NOT_FOUND);const l=JSON.parse(o);return l.metadata&&typeof l.metadata=="string"&&(l.metadata=Sr(l.metadata)),l}catch(o){const l=o,d=o instanceof SyntaxError;throw l.code==="ENOENT"||d?ne(oe.FILE_NOT_FOUND):o}}async delete(t){await fo(this.getMetaPath(t))}async accessCheck(){await nn(this.directory)}};export{We as B,le as L,ce as P,Ze as V,gn as X,Ue as _,ie as a,Jn as b,G as f,z as i,Ae as l,Ko as v,nn as w,fo as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var M=Object.defineProperty;var p=(o,t)=>M(o,"name",{value:t,configurable:!0});import{Readable as S}from"node:stream";import{z as C,B as R,$ as A,t as T}from"./storage-uhIhcN-O.js";import{d as I}from"./detect-file-type-5JhzC9RU.js";import{throwErrorCode as m,ERRORS as y}from"./ERRORS-CyOuSMLY.js";import{createRetryWrapper as v}from"./isRetryableError-CBZ65V6T.js";import{v as P}from"./local-meta-storage-Dr891Iy7.js";import{u as z}from"./update-size-DANV7aa2.js";import{r as x}from"./part-match-D_NwyoF3.js";import{o as B}from"./has-content-Bx2p8Okx.js";import{o as U}from"./get-file-status-DLS18Zvd.js";var L=Object.defineProperty,N=p((o,t)=>L(o,"name",{value:t,configurable:!0}),"o$1");const $=N((o,t)=>{const a={};return Object.keys(o).forEach(e=>{a[e]=t(o[e])}),a},"mapValues");var K=Object.defineProperty,j=p((o,t)=>K(o,"name",{value:t,configurable:!0}),"t");const D=j(o=>o===Number(o)?o:(C(o)??0)/1e3,"toSeconds");var F=Object.defineProperty,f=p((o,t)=>F(o,"name",{value:t,configurable:!0}),"g");const W=5*1024*1024,_=16*1024*1024,q=f(o=>{if(o)return`bytes=${Math.max(0,o.start)}-${o.end===void 0?"":o.end}`},"buildRangeHeader");class k extends R{static{p(this,"S3BaseStorage")}static{f(this,"S3BaseStorage")}checksumTypes=["md5","crc32","crc32c","sha1","sha256"];supportsRange=!0;bucket;meta;MAX_PARTS=1e4;partSize;retry;resolvedRetryConfig;constructor(t){if(super(t),this.bucket=t.bucket,this.partSize=typeof t.partSize=="string"?A(t.partSize):t.partSize||_,this.partSize<W)throw new Error("Minimum allowed partSize value is 5MB");const a={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:f(i=>{const s=i;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)?!0:s.retryable??!1},"shouldRetry"),...t.retryConfig};this.retry=v(a),this.resolvedRetryConfig=a;const{metaStorage:e,metaStorageConfig:r}=t;if(e)this.meta=e;else{const i={...t,...r,logger:this.logger};"directory"in i?(this.logger?.debug("Using local meta storage"),this.meta=new P(i)):this.meta=new P(i)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(i=>{this.logger?.error("Storage access check failed: %O",i)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,a){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const n=typeof t.ttl=="string"?T(t.ttl):t.ttl;n!==void 0&&(e.expiredAt=Date.now()+n)}const r=new(this.getFileClass())(e);r.name=this.namingFunction(r),await this.validate(r);try{const n=await this.getMeta(r.id);if(n.bytesWritten>=0)return n}catch{}const i=this.getS3Api();let s;try{s=await this.runOperation(a,n=>i.createMultipartUpload({ACL:this.getAcl(),Bucket:this.bucket,ContentType:r.contentType,Key:r.name,Metadata:$({originalName:r.originalName,...r.metadata},l=>encodeURI(String(l)))},{signal:n}))}catch{return m(y.FILE_ERROR,"s3 create upload error")}const{UploadId:c}=s||{};return c?(r.UploadId=c,r.bytesWritten=0,this.config.clientDirectUpload&&(r.partSize??=this.partSize),await this.saveMeta(r),r.status="created",await this.onCreate(r),this.config.clientDirectUpload?this.buildPresigned(r):r):m(y.FILE_ERROR,"s3 create upload error")})}async write(t,a){return this.instrumentOperation("write",async()=>{let e;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?e=t:(e=await this.getMeta(t.id),await this.checkIfExpired(e)),e.status==="completed")return e;if(typeof t.size=="number"&&t.size>0&&z(e,t.size),!x(t,e))return m(y.FILE_CONFLICT);if(this.config.clientDirectUpload)return this.buildPresigned(e);e.Parts??=await this.getParts(e),e.bytesWritten=e.Parts.map(i=>i.Size||0).reduce((i,s)=>i+s,0);const r=await this.lock(t.id);try{if(B(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return m(y.UNSUPPORTED_CHECKSUM_ALGORITHM);if(e.Parts.length===0&&(!e.contentType||e.contentType==="application/octet-stream"))try{const u=t.body instanceof S?t.body:S.fromWeb(t.body),{fileType:g,stream:w}=await I(u);g?.mime&&(e.contentType=g.mime),t.body=w}catch{}if(e.Parts.length>this.MAX_PARTS)throw new Error(`Exceeded ${this.MAX_PARTS} as part of the upload to ${this.bucket}.`);const i=e.Parts.length+1,s=this.getS3Api(),c=e.UploadId;if(!c)throw new Error("UploadId is required");const n=t.body,l=n instanceof Uint8Array,{ETag:h}=await this.runOperation(a,u=>s.uploadPart({Body:n,Bucket:this.bucket,ContentLength:t.contentLength||0,Key:e.name,PartNumber:i,UploadId:c,...t.checksumAlgorithm==="md5"?{ContentMD5:t.checksum}:{}},{signal:u}),{replayable:l}),b={ETag:h,PartNumber:i,Size:t.contentLength};e.Parts=[...e.Parts,b],e.bytesWritten+=t.contentLength||0}if(this.cache.set(e.id,e),e.status=U(e),e.status==="completed"){const[i]=await this.internalOnComplete(e);delete e.Parts,e.uri=i.Location,e.ETag=i.ETag}}finally{await this.unlock(t.id,r)}return e})}async delete({id:t},a){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.abortMultipartUpload(e,a),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,a,e){return this.instrumentOperation("copy",async()=>{k.assertSafeId(t),k.assertSafeId(a);const r=await this.getMeta(t),i=`${this.bucket}/${t}`,s=this.bucket,c=a,n=this.getS3Api();return await this.runOperation(e,l=>n.copyObject({Bucket:s,CopySource:i,Key:c,...e?.storageClass&&{StorageClass:e.storageClass}},{signal:l})),{...r,id:c,name:c}})}async move(t,a,e){return this.instrumentOperation("move",async()=>{await this.copy(t,a,e);const r=this.getS3Api();return await this.runOperation(e,i=>r.deleteObject({Bucket:this.bucket,Key:t},{signal:i})),await this.getMeta(a)})}async list(t=1e3,a){return this.instrumentOperation("list",async()=>{const e=this.getS3Api(),r=Math.min(t,1e3);let i={Bucket:this.bucket,MaxKeys:r};const s=[];let c=!0;for(;c&&s.length<t;)try{const n=await this.runOperation(a,l=>e.listObjectsV2(i,{signal:l}));for(const{Key:l,LastModified:h}of n?.Contents||[]){if(s.length>=t)break;l!==void 0&&s.push({id:l,...h&&{createdAt:h}})}c=n.IsTruncated||!1,c&&n.NextContinuationToken&&s.length<t&&(i={...i,ContinuationToken:n.NextContinuationToken,MaxKeys:Math.min(r,t-s.length)})}catch(n){const l=this.normalizeError(n instanceof Error?n:new Error(String(n)));throw await this.onError(l),n}return s},{limit:t})}async exists({id:t},a){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.getS3Api();return await this.runOperation(a,r=>e.headObject({Bucket:this.bucket,Key:t},{signal:r})),!0}catch{return!1}})}async get({id:t},a){return this.instrumentOperation("get",async()=>{const e=this.getS3Api(),r=q(a?.range),{Body:i,ContentLength:s,ContentType:c,ETag:n,Expires:l,LastModified:h,Metadata:b}=await this.runOperation(a,d=>e.getObject({Bucket:this.bucket,Key:t,...r!==void 0&&{Range:r}},{signal:d}));await this.checkIfExpired({expiredAt:l});const u=[];if(i)if(i instanceof S)for await(const d of i)u.push(d instanceof Uint8Array?d:new Uint8Array(d));else{const d=i.getReader();for(;;){const{done:E,value:O}=await d.read();if(E)break;u.push(O)}}const{originalName:g,...w}=b||{};return{content:Buffer.concat(u),contentType:c,ETag:n,expiredAt:l,id:t,metadata:w,modifiedAt:h,name:t,originalName:g||t,size:Number(s)}})}async buildPresigned(t){const a=t;if(a.Parts?.length||(a.Parts=await this.getParts(t)),a.bytesWritten=a.Parts.map(e=>e.Size||0).reduce((e,r)=>e+r,0),t.status=U(a),a.partsUrls?.length||(a.partsUrls=await this.getPartsPresignedUrls(t)),t.status==="completed"){const[e]=await this.internalOnComplete(t);return delete a.Parts,a.uri=e.Location,t}return t}async getPartsPresignedUrls(t){t.partSize??=this.partSize;const a=t.UploadId;if(!a)throw new Error("UploadId is required for getting presigned URLs");const e=Math.trunc(t.size/this.partSize)+1,r=[],i=Math.trunc(D(this.config.expiration?.maxAge||"6hrs")),s=this.getS3Api();for(let c=0;c<e;c++)r.push(s.getPresignedUrl({Bucket:this.bucket,expiresIn:i,Key:t.name,PartNumber:c+1,UploadId:a}));return Promise.all(r)}async getParts(t){const a=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const{Parts:r=[]}=await this.runOperation(void 0,i=>a.listParts({Bucket:this.bucket,Key:t.name,UploadId:e},{signal:i}));return r}completeMultipartUpload(t){const a=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const r=t.Parts?.map(({ETag:i,PartNumber:s})=>{if(!i||!s)throw new Error("ETag and PartNumber are required");return{ETag:i,PartNumber:s}})||[];return this.runOperation(void 0,i=>a.completeMultipartUpload({Bucket:this.bucket,Key:t.name,Parts:r,UploadId:e},{signal:i}))}async abortMultipartUpload(t,a){if(t.status!=="completed")try{const e=this.getS3Api(),r=t.UploadId;if(!r)return;await this.runOperation(a,i=>e.abortMultipartUpload({Bucket:this.bucket,Key:t.name,UploadId:r},{signal:i}))}catch(e){this.logger?.error("abortMultipartUploadError: ",e);const r=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(r)}}internalOnComplete=f(async t=>{const[a]=await Promise.all([this.completeMultipartUpload(t),this.deleteMeta(t.id)]);return[a,t]},"internalOnComplete")}export{k as S,q as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var H=Object.defineProperty;var p=(t,e)=>H(t,"name",{value:e,configurable:!0});import{Readable as X}from"node:stream";import{setInterval as J}from"node:timers";import{inspect as Q}from"node:util";import{L as ee,O as I}from"./path-D7rMc9nq-CPbxyMDy.js";import te from"type-is";import re from"./NoOpMetrics-Dky06sf1.js";import{N as oe}from"./cache-qV_5Umeq.js";import{ErrorMap as M,throwErrorCode as E,ERRORS as $}from"./ERRORS-CyOuSMLY.js";import{randomUUID as se}from"node:crypto";import{LRUCache as ae}from"lru-cache";import{retry as ie}from"./isRetryableError-CBZ65V6T.js";import{o as ne}from"./is-expired-1JuZjDtb.js";var ce=Object.defineProperty,le=p((t,e)=>ce(t,"name",{value:e,configurable:!0}),"y$3"),ue=Object.defineProperty,me=le((t,e)=>ue(t,"name",{value:e,configurable:!0}),"y"),ge=Object.defineProperty,C=me((t,e)=>ge(t,"name",{value:e,configurable:!0}),"i");const de=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,he=/^KIBI/,pe=/^MIBI/,fe=/^GIBI/,ye=/^TEBI/,be=/^PEBI/,we=/^EXBI/,ve=/^ZEBI/,Ee=/^YIBI/,$e=/^(.)IB$/,R={iec:[{long:"Bytes",short:"B"},{long:"Kibibytes",short:"KiB"},{long:"Mebibytes",short:"MiB"},{long:"Gibibytes",short:"GiB"},{long:"Tebibytes",short:"TiB"},{long:"Pebibytes",short:"PiB"},{long:"Exbibytes",short:"EiB"},{long:"Zebibytes",short:"ZiB"},{long:"Yobibytes",short:"YiB"}],iec_octet:[{long:"Octets",short:"o"},{long:"Kibioctets",short:"Kio"},{long:"Mebioctets",short:"Mio"},{long:"Gibioctets",short:"Gio"},{long:"Tebioctets",short:"Tio"},{long:"Pebioctets",short:"Pio"},{long:"Exbioctets",short:"Eio"},{long:"Zebioctets",short:"Zio"},{long:"Yobioctets",short:"Yio"}],metric:[{long:"Bytes",short:"Bytes"},{long:"Kilobytes",short:"KB"},{long:"Megabytes",short:"MB"},{long:"Gigabytes",short:"GB"},{long:"Terabytes",short:"TB"},{long:"Petabytes",short:"PB"},{long:"Exabytes",short:"EB"},{long:"Zettabytes",short:"ZB"},{long:"Yottabytes",short:"YB"}],metric_octet:[{long:"Octets",short:"o"},{long:"Kilo-octets",short:"ko"},{long:"Mega-octets",short:"Mo"},{long:"Giga-octets",short:"Go"},{long:"Tera-octets",short:"To"},{long:"Peta-octets",short:"Po"},{long:"Exa-octets",short:"Eo"},{long:"Zetta-octets",short:"Zo"},{long:"Yotta-octets",short:"Yo"}]},xe=C((t,e)=>{const r=new Intl.NumberFormat(e).format(11111).replaceAll(new RegExp("\\p{Number}","gu"),""),o=new Intl.NumberFormat(e).format(1.1).replaceAll(new RegExp("\\p{Number}","gu"),"");return Number.parseFloat(t.replaceAll(new RegExp(`\\${r}`,"g"),"").replace(new RegExp(`\\${o}`),"."))},"parseLocalizedNumber"),_=C(t=>{switch(t){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},"fromBase"),j=C((t,e)=>{const r={base:2,locale:"en-US",units:"metric",...e};if(typeof t!="string"||t.length===0)throw new TypeError("Value is not a string or is empty.");if(t.length>100)throw new TypeError("Value exceeds the maximum length of 100 characters.");const o=de.exec(t)?.groups;if(!o)return Number.NaN;const s=xe(o.value,r.locale),a=(o.type??"Bytes").toUpperCase().replace(he,"KILO").replace(pe,"MEGA").replace(fe,"GIGA").replace(ye,"TERA").replace(be,"PETA").replace(we,"EXA").replace(ve,"ZETTA").replace(Ee,"YOTTA").replace($e,"$1B"),i=R[r.units].findIndex(u=>u.short[0].toUpperCase()===a[0]),l=_(r.base);return s*l**i},"parseBytes");C((t,e)=>{if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("Bytesize is not a number.");const{base:r,decimals:o,locale:s,long:a,unit:i,units:l,...u}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...e},n=_(r),m=Math.abs(t),g=e?.space??!0?" ":"",c=R[l],d=c.findIndex(w=>w.short===i);if(t===0){const w=Math.min(0,Math.max(d,c.length-1));return"0"+g+c[w][a?"long":"short"]}const h=d===-1?Math.min(Math.floor(Math.log(m)/Math.log(n)),c.length-1):d,N=c[h][a?"long":"short"],O=t/n**h,v=o<0?void 0:o;return new Intl.NumberFormat(s,{maximumFractionDigits:v,minimumFractionDigits:v,...u}).format(O)+g+N},"formatBytes");var Me=Object.defineProperty,Ne=p((t,e)=>Me(t,"name",{value:e,configurable:!0}),"u$3"),Oe=Object.defineProperty,Ae=Ne((t,e)=>Oe(t,"name",{value:e,configurable:!0}),"v"),Te=Object.defineProperty,Ce=Ae((t,e)=>Te(t,"name",{value:e,configurable:!0}),"D");const Se=Ce((t,e,r,o,s,a,i,l,u,n,m,g,c,d)=>{const h={d:o,h:s,m:a,mo:e,ms:l,s:i,w:r,y:t};return u!==void 0&&(h.future=u),n!==void 0&&(h.past=n),m!==void 0&&(h.decimal=m),g!==void 0&&(h.unitMap=g),c!==void 0&&(h.groupSeparator=c),d!==void 0&&(h.placeholderSeparator=d),h},"createDurationLanguage"),F={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Ie=Se(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",F,",","_");var Pe=Object.defineProperty,Be=p((t,e)=>Pe(t,"name",{value:e,configurable:!0}),"o"),Ue=Object.defineProperty,De=Be((t,e)=>Ue(t,"name",{value:e,configurable:!0}),"o"),ze=Object.defineProperty,je=De((t,e)=>ze(t,"name",{value:e,configurable:!0}),"o");const ke=je(t=>{const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const o of e)if(!Object.hasOwn(t,o))throw new TypeError(`Missing required property: ${o}`);if(typeof t.future!="string"||typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const r=["y","mo","w","d","h","m","s","ms"];for(const o of r)if(typeof t[o]!="string"&&typeof t[o]!="function")throw new TypeError(`Property ${o} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(o=>typeof o!="string"))throw new TypeError("All values in unitMap must be of type string")},"validateDurationLanguage");var Re=Object.defineProperty,_e=p((t,e)=>Re(t,"name",{value:e,configurable:!0}),"w"),Fe=Object.defineProperty,Le=_e((t,e)=>Fe(t,"name",{value:e,configurable:!0}),"S"),Ve=Object.defineProperty,Ge=Le((t,e)=>Ve(t,"name",{value:e,configurable:!0}),"h");const k={d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},A=/[-/\\^$*+?.()|[\]{}]/g,Ye=/^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/i,Ze=/^(?:(\d+):)?(?:(\d+):)?(\d+)$/,Ke=/^[+-]?\d+(?:\.\d+)?$/,We=/^[-+]/,qe=Ge((t,e)=>{if(typeof t!="string"||t.length===0)return;const{defaultUnit:r="ms",language:o=Ie}=e??{};ke(o);const s=o.decimal??".",a=o.groupSeparator??",",i=o.placeholderSeparator??"_",l=s.replaceAll(A,String.raw`\$&`),u=a.replaceAll(A,String.raw`\$&`),n=i.replaceAll(A,String.raw`\$&`),m=o.unitMap??F;let g=t.replaceAll(new RegExp(String.raw`(\d)[${n}${u}](\d)`,"g"),"$1$2");if(s!=="."&&(g=g.replace(l,".")),Ke.test(t)){const f=Number.parseFloat(g.trim());if(!Number.isNaN(f)){const y=m[r];if(y!==void 0)return f*k[y]}return}const c=Ye.exec(t);if(c){const f=Number.parseInt(c[1]??"0",10),y=Number.parseInt(c[2]??"0",10),x=Number.parseInt(c[3]??"0",10);return f*36e5+y*6e4+x*1e3}const d=Ze.exec(t);if(d){let f=0,y=0;d[2]!==void 0?(f=Number.parseInt(d[1]??"0",10),y=Number.parseInt(d[2],10)):d[1]!==void 0&&(y=Number.parseInt(d[1],10));const x=Number.parseInt(d[3]??"0",10);return f*36e5+y*6e4+x*1e3}const h=Object.keys(m).toSorted((f,y)=>y.length-f.length).map(f=>f.replaceAll(A,String.raw`\$&`)).join("|"),N=new RegExp(String.raw`(-?\d*\.?\d+)\s*(${h})`,"gi");let O=0,v,w=!1,B=-1,U=0;for(N.lastIndex=0;(v=N.exec(g))!==null;){w||(B=v.index),w=!0;const f=v[1],y=v[2];if(!f||!y)continue;const x=f.trim(),K=x.startsWith("-")?-1:1,W=x.replace(We,""),D=Number.parseFloat(W),z=m[y.toLowerCase()];if(z===void 0)continue;const q=k[z];if(Number.isNaN(D))return;O+=K*D*q,U=N.lastIndex}const Y=g.slice(0,B).trim(),Z=g.slice(U).trim();if(!(w&&(Y.length>0||Z.length>0))&&w)return O},"parseDuration");var He=Object.defineProperty,Xe=p((t,e)=>He(t,"name",{value:e,configurable:!0}),"n$1");let Je=class extends ae{static{p(this,"u")}static{Xe(this,"Locker")}constructor(e){super({ttl:3e4,ttlAutopurge:!0,...e})}lock(e){if(this.get(e)!==void 0)throw new Error(`${e} is locked`);const r=se();return this.set(e,r),r}unlock(e,r){return this.get(e)!==r?!1:this.delete(e)}};var Qe=Object.defineProperty,et=p((t,e)=>Qe(t,"name",{value:e,configurable:!0}),"e$1");const T=et(t=>{if(t===Number(t))return t;if(!t)return;const e=qe(t);if(e!==void 0)return e},"toMilliseconds");var tt=Object.defineProperty,rt=p((t,e)=>tt(t,"name",{value:e,configurable:!0}),"t");let ot=class extends Error{static{p(this,"d")}static{rt(this,"ValidationError")}code;statusCode;body;headers;name="ValidationError";constructor(e,r,o,s){const a=typeof o=="string"?o:o?.message||"Validation error";super(a),this.code=e,this.statusCode=r,this.body=o,this.headers=s}};var st=Object.defineProperty,S=p((t,e)=>st(t,"name",{value:e,configurable:!0}),"e");const at=S(t=>t&&t[0].toUpperCase()+t.slice(1),"capitalize"),it=S(t=>{if(!Array.isArray(t))return t;const[e,r,o]=t;return{body:r,headers:o,statusCode:e}},"toResponse");class nt{static{p(this,"Validator")}constructor(e="ValidationError"){this.prefix=e}prefix;static{S(this,"Validator")}validators={};add(e){Object.entries(e).forEach(([r,o])=>{const s=`${this.prefix}${at(r)}`;if(this.validators[s]={...this.validators[s],...o},typeof this.validators[s].isValid!="function")throw new TypeError('Validation config "isValid" is missing, or it is not a function!')})}async verify(e){for(const[r,o]of Object.entries(this.validators))if(!await o.isValid(e)){const s=o.response||(r in M?M[r]:M.UnknownError),a=it(s),{body:i,headers:l,message:u,statusCode:n}=a;throw new ot(r,n,i||u,l)}}}const St=S(t=>t.name==="ValidationError","isValidationError");var ct=Object.defineProperty,P=p((t,e)=>ct(t,"name",{value:e,configurable:!0}),"i");const lt=P(t=>{if(typeof t.name=="string")return t.name;if(typeof t.title=="string")return t.title;if(typeof t.originalName=="string")return t.originalName;if(typeof t.filename=="string")return t.filename},"extractOriginalName"),L=P((t,e)=>{const r={...t};return Object.keys(e).forEach(o=>{const s=e[o];if(s!==null&&typeof s=="object"&&!Array.isArray(s)){const a=r[o],i=a&&typeof a=="object"&&!Array.isArray(a)?a:{};r[o]=L(i,s)}else r[o]=s}),r},"deepMerge"),ut=P((t,e)=>{const r=L(t,e);Object.assign(t,r),t.originalName=lt(t.metadata)||t.originalName},"updateMetadata");var mt=Object.defineProperty,b=p((t,e)=>mt(t,"name",{value:e,configurable:!0}),"d");const gt=/(secret|password|passwd|pwd|token|api[_-]?key|credential|authorization|sas|signature|sessiontoken|connectionstring)/i,V=b(t=>{const e={};for(const[r,o]of Object.entries(t))typeof o=="string"&>.test(r)?e[r]="[REDACTED]":o&&typeof o=="object"&&!Array.isArray(o)&&o.constructor===Object?e[r]=V(o):e[r]=o;return e},"redactSecrets"),dt={allowMIME:["*/*"],filename:b(({id:t})=>t,"filename"),maxMetadataSize:"8MB",maxUploadSize:"5TB",onComplete:b(()=>{},"onComplete"),onCreate:b(()=>{},"onCreate"),onDelete:b(()=>{},"onDelete"),onError:b(()=>{},"onError"),onUpdate:b(()=>{},"onUpdate"),useRelativeLocation:!1,validation:{}},ht=b(t=>!t||t.length<3||t.length>255||I(t)?!1:!(t.toUpperCase().includes("../")||t.includes("\0")),"defaultCloudStorageFileNameValidation"),It=b(t=>{if(!t||t.length<3||t.length>255||I(t))return!1;const e=t.toUpperCase();return!['"',"*",":","<",">","?","\\","|","../","\0"].some(r=>e.includes(r))},"defaultFilesystemFileNameValidation");class G{static{p(this,"BaseStorage")}static{b(this,"BaseStorage")}onCreate;onUpdate;onComplete;onDelete;onError;isReady=!0;errorResponses={};cache;logger;metrics;genericConfig;maxMetadataSize;checksumTypes=[];supportsRange=!1;reportsUploadProgress=!1;maxUploadSize;expiration;locker;namingFunction;validation=new nt;assetFolder=void 0;concurrency;constructor(e){const r={...dt,...e};this.onCreate=r.onCreate,this.onUpdate=r.onUpdate,this.onComplete=r.onComplete,this.onDelete=r.onDelete,this.onError=r.onError,this.namingFunction=r.filename,this.maxUploadSize=typeof r.maxUploadSize=="string"?j(r.maxUploadSize):r.maxUploadSize,this.maxMetadataSize=typeof r.maxMetadataSize=="string"?j(r.maxMetadataSize):r.maxMetadataSize,this.expiration=r.expiration,this.genericConfig=r,r.assetFolder!==void 0&&(this.assetFolder=ee(r.assetFolder)),this.locker=new Je({max:1e3,ttl:3e4,ttlAutopurge:!0}),this.cache=r.cache??new oe,this.logger=r.logger,this.metrics=r.metrics??new re,this.logger?.debug(`${this.constructor.name} config: ${Q(V({...e,logger:this.logger.constructor}))}`);const o=T(r.expiration?.purgeInterval);o&&this.startAutoPurge(o);const s={isValid(u){if(u.size===void 0)return!0;const n=u.size;if(n==null)return!1;const m=typeof n=="number"?n:Number(n);if(Number.isNaN(m)||m<0)return!1;const g=typeof this.value=="number"?this.value:Number(this.value);return!Number.isNaN(g)&&m<=g},response:M.RequestEntityTooLarge,value:this.maxUploadSize},a={isValid(u){return!!te.is(u.contentType,this.value)},response:M.UnsupportedMediaType,value:r.allowMIME},i=r.fileNameValidation??ht,l={isValid(u){return i(u.name)},response:M.InvalidFileName};this.validation.add({filename:l,mime:a,size:s}),this.validation.add({...r.validation})}get raw(){}async getReadUrl(e,r){return E($.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getReadUrl()`)}async getUploadUrl(e,r){return E($.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getUploadUrl()`)}get tusExtension(){const e=["creation","creation-with-upload","termination","checksum","creation-defer-length","concatenation"];return this.expiration&&e.push("expiration"),e}async validate(e){await this.validation.verify(e)}async exists(e,r){return this.instrumentOperation("exists",async()=>{try{return await this.getMeta(e.id,r),!0}catch{return!1}})}normalizeError(e){const r={code:e.name,message:e.message,name:e.name,statusCode:500};return{...r,message:`[${this.constructor.name}] ${r.message}`}}get config(){return this.genericConfig}async saveMeta(e){return G.assertSafeId(e.id),this.updateTimestamps(e),this.cache.set(e.id,e),this.meta.save(e.id,e)}static assertSafeId(e){(!e||typeof e!="string"||e.includes("\0")||e.includes("../")||e.includes("..\\")||e===".."||e.startsWith("../")||e.startsWith("..\\")||I(e)||/^[A-Z]:[/\\]/i.test(e))&&E($.INVALID_FILE_NAME,`Invalid file id: "${e}"`)}async deleteMeta(e){return this.cache.delete(e),this.meta.delete(e)}async getMeta(e,r){try{const o=await this.meta.get(e);return this.cache.set(o.id,o),{...o}}catch(o){const s=this.normalizeError(o instanceof Error?o:new Error(String(o)));return await this.onError(s),E($.FILE_NOT_FOUND)}}async checkIfExpired(e){return ne(e)?(this.delete(e).catch(()=>{}),this.deleteMeta(e.id).catch(()=>{}),E($.GONE)):e}async purge(e){return this.instrumentOperation("purge",async()=>{const r=T(e||this.expiration?.maxAge),o={items:[],maxAgeMs:r};if(r){const s=Date.now()-r,a=(await this.list()).filter(i=>Number(new Date(this.expiration?.rolling&&i.modifiedAt||i.createdAt))<s);for await(const{id:i,...l}of a)try{const u=await this.delete({id:i});o.items.push({...u,...l})}catch(u){this.logger?.warn(`Failed to delete file ${i} during purge: ${u instanceof Error?u.message:String(u)}`)}o.items.length>0&&(this.logger?.info(`Purge: removed ${o.items.length} uploads`),this.metrics.gauge("storage.operations.purge.items_count",o.items.length,{storage:this.constructor.name.toLowerCase().replace("storage","")}))}return o})}async getStream({id:e}){return this.instrumentOperation("getStream",async()=>{const r=await this.get({id:e}),o=X.from(r.content);return{headers:{"Content-Length":String(r.size),"Content-Type":r.contentType,...r.ETag&&{ETag:r.ETag},...r.modifiedAt&&{"Last-Modified":r.modifiedAt.toString()}},size:typeof r.size=="number"?r.size:void 0,stream:o}})}async list(e=1e3,r){return this.instrumentOperation("list",async()=>{throw new Error("Not implemented")})}async update({id:e},r){return this.instrumentOperation("update",async()=>{const o=await this.getMeta(e),s={...r};if("ttl"in s&&s.ttl!==void 0){const i=s.ttl,l=typeof i=="string"?T(i):i;l!==void 0&&(s.expiredAt=Date.now()+l),delete s.ttl}ut(o,s),await this.saveMeta(o);const a={...o,status:"updated"};return await this.onUpdate(a),a})}async deleteBatch(e,r){const o=Date.now(),s=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.delete.count",1,{batch_size:e.length,storage:s});const a=[],i=[],l=e.map(async m=>{try{return{file:await this.delete({id:m},r),id:m,success:!0}}catch(g){const c=g instanceof Error?g.message:"Delete failed";return this.metrics.increment("storage.operations.delete.error.count",1,{error:c,storage:s}),{error:c,id:m,success:!1}}}),u=await Promise.allSettled(l);for(const m of u)m.status==="fulfilled"?m.value.success?a.push(m.value.file):i.push({error:m.value.error,id:m.value.id}):i.push({error:m.reason?.message||"Delete failed",id:""});const n=Date.now()-o;return this.metrics.timing("storage.operations.batch.delete.duration",n,{batch_size:e.length,storage:s}),this.metrics.gauge("storage.operations.batch.delete.success_count",a.length,{storage:s}),this.metrics.gauge("storage.operations.batch.delete.failed_count",i.length,{storage:s}),{failed:i,failedCount:i.length,successful:a,successfulCount:a.length}}async copyBatch(e){const r=Date.now(),o=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.copy.count",1,{batch_size:e.length,storage:o});const s=[],a=[],i=e.map(async({destination:n,options:m,source:g})=>{try{return{file:await this.copy(g,n,m),id:n,success:!0}}catch(c){const d=c instanceof Error?c.message:"Copy failed";return this.metrics.increment("storage.operations.copy.error.count",1,{error:d,storage:o}),{error:d,id:n,success:!1}}}),l=await Promise.allSettled(i);for(const n of l)n.status==="fulfilled"?n.value.success&&n.value.file?s.push(n.value.file):a.push({error:n.value.error||"Copy failed",id:n.value.id}):a.push({error:n.reason?.message||"Copy failed",id:""});const u=Date.now()-r;return this.metrics.timing("storage.operations.batch.copy.duration",u,{batch_size:e.length,storage:o}),this.metrics.gauge("storage.operations.batch.copy.success_count",s.length,{storage:o}),this.metrics.gauge("storage.operations.batch.copy.failed_count",a.length,{storage:o}),{failed:a,failedCount:a.length,successful:s,successfulCount:s.length}}async moveBatch(e){const r=Date.now(),o=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.move.count",1,{batch_size:e.length,storage:o});const s=[],a=[],i=e.map(async({destination:n,source:m})=>{try{return{file:await this.move(m,n),id:n,success:!0}}catch(g){const c=g instanceof Error?g.message:"Move failed";return this.metrics.increment("storage.operations.move.error.count",1,{error:c,storage:o}),{error:c,id:n,success:!1}}}),l=await Promise.allSettled(i);for(const n of l)n.status==="fulfilled"?n.value.success&&n.value.file?s.push(n.value.file):a.push({error:n.value.error||"Move failed",id:n.value.id}):a.push({error:n.reason?.message||"Move failed",id:n.reason?.id||""});const u=Date.now()-r;return this.metrics.timing("storage.operations.batch.move.duration",u,{batch_size:e.length,storage:o}),this.metrics.gauge("storage.operations.batch.move.success_count",s.length,{storage:o}),this.metrics.gauge("storage.operations.batch.move.failed_count",a.length,{storage:o}),{failed:a,failedCount:a.length,successful:s,successfulCount:s.length}}async lock(e){const r=[...this.locker.keys()];return r.includes(e)?E($.FILE_LOCKED):this.config.concurrency&&typeof this.config.concurrency=="number"&&this.config.concurrency<r.length?E($.STORAGE_BUSY):this.locker.lock(e)}async unlock(e,r){if(r===void 0){this.locker.delete(e);return}this.locker.unlock(e,r)}async withLock(e,r){const o=await this.lock(e);try{return await r()}finally{await this.unlock(e,o)}}isUnsupportedChecksum(e=""){return!!e&&!this.checksumTypes.includes(e)}startAutoPurge(e){if(e>=2147483647)throw new Error("“purgeInterval” must be less than 2147483647 ms");J(()=>{this.purge().catch(r=>this.logger?.error(r))},e)}updateTimestamps(e){e.createdAt??=new Date().toISOString();const r=T(this.expiration?.maxAge);return r&&!e.expiredAt&&(e.expiredAt=this.expiration?.rolling?Date.now()+r:+new Date(e.createdAt)+r),e}getRetryConfig(){}runOperation(e,r,o){let s;typeof e?.retries=="number"?s={maxRetries:e.retries}:e?.retries&&(s=e.retries);const a={...this.getRetryConfig(),...s};o?.replayable===!1&&(a.maxRetries=0);const i=[];this.genericConfig.defaultSignal&&i.push(this.genericConfig.defaultSignal),e?.signal&&i.push(e.signal);let l;i.length===1?[l]=i:i.length>1&&(l=AbortSignal.any(i));const u=typeof e?.timeout=="number"?e.timeout:this.genericConfig.defaultTimeout,n=typeof u=="number"&&u>0?u:void 0,m=a.shouldRetry;a.shouldRetry=c=>l?.aborted||c instanceof Error&&c.name==="AbortError"?!1:m?m(c):!1;const g=b(c=>{if(c instanceof Error&&c.name==="AbortError")return c;const d=c instanceof Error&&c.message?c.message:"The operation was aborted",h=new Error(d,{cause:c});return h.name="AbortError",h},"toAbortError");return ie(async()=>{if(l?.aborted)throw g(l.reason);let c,d;if(n===void 0)d=l;else{const h=new AbortController;c=setTimeout(()=>{h.abort(new DOMException(`The operation timed out after ${n}ms`,"TimeoutError"))},n),d=l?AbortSignal.any([l,h.signal]):h.signal}try{return await r(d)}catch(h){throw d?.aborted?g(h):h}finally{c&&clearTimeout(c)}},a)}async instrumentOperation(e,r,o){const s=Date.now(),a={storage:this.constructor.name.toLowerCase().replace("storage",""),...o};try{this.metrics.increment(`storage.operations.${e}.count`,1,a);const i=await r(),l=Date.now()-s;return this.metrics.timing(`storage.operations.${e}.duration`,l,a),i&&typeof i=="object"&&"size"in i&&typeof i.size=="number"&&this.metrics.gauge("storage.files.size",i.size,{...a,operation:e}),i}catch(i){const l=Date.now()-s,u=i instanceof Error?i.message:"Unknown error";throw this.metrics.timing(`storage.operations.${e}.duration`,l,{...a,error:"true"}),this.metrics.increment(`storage.operations.${e}.error.count`,1,{...a,error:u}),i}}}export{j as $,G as B,It as a,ot as b,ht as d,St as i,T as t,ut as u,qe as z};
|