@visulima/storage 1.0.0-alpha.33 → 1.0.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/adapter/nuxt/module.d.ts +4 -4
  3. package/dist/ai/ai-sdk/index.d.ts +5 -5
  4. package/dist/ai/claude/index.d.ts +4 -4
  5. package/dist/ai/openai/index.d.ts +5 -5
  6. package/dist/ai/tanstack/index.d.ts +4 -4
  7. package/dist/handler/http/fetch/index.d.ts +7 -7
  8. package/dist/handler/http/fetch/index.js +1 -1
  9. package/dist/handler/http/hono/index.d.ts +4 -4
  10. package/dist/handler/http/hono/index.js +1 -1
  11. package/dist/handler/http/nextjs/index.d.ts +4 -4
  12. package/dist/handler/http/nextjs/index.js +1 -1
  13. package/dist/handler/http/node/index.d.ts +7 -7
  14. package/dist/handler/http/node/index.js +1 -1
  15. package/dist/handler/http/solid-start/index.d.ts +4 -4
  16. package/dist/handler/http/solid-start/index.js +1 -1
  17. package/dist/index.d.ts +6 -6
  18. package/dist/index.js +1 -1
  19. package/dist/packem_shared/{AwsLightStorage-6Z1ovz9R.js → AwsLightStorage-CWBRVcn5.js} +1 -1
  20. package/dist/packem_shared/{AzureStorage-CbAN4vPm.js → AzureStorage-nhAojuEU.js} +1 -1
  21. package/dist/packem_shared/{BoxMetaStorage-BGBPZWoL.js → BoxMetaStorage-XMZn5yvp.js} +1 -1
  22. package/dist/packem_shared/{BoxStorage-DitlyKVB.js → BoxStorage-C3--16du.js} +1 -1
  23. package/dist/packem_shared/{BunS3MetaStorage-DAskpG_G.js → BunS3MetaStorage-DomG8mVK.js} +1 -1
  24. package/dist/packem_shared/{BunS3Storage-D1gxh5Tt.js → BunS3Storage-0oYNi2Os.js} +1 -1
  25. package/dist/packem_shared/{BunnyMetaStorage-ByUvvuPc.js → BunnyMetaStorage-luemw1pL.js} +1 -1
  26. package/dist/packem_shared/{BunnyStorage-r6DptjUt.js → BunnyStorage-CIkpp1Rc.js} +1 -1
  27. package/dist/packem_shared/{CloudinaryMetaStorage-DsJyN0iQ.js → CloudinaryMetaStorage-DpxjshXZ.js} +1 -1
  28. package/dist/packem_shared/{CloudinaryStorage-BR8CZhlL.js → CloudinaryStorage-9Y1Gq0gr.js} +1 -1
  29. package/dist/packem_shared/DiskStorage-BkP8c0MY.js +1 -0
  30. package/dist/packem_shared/{DiskStorageWithChecksum--U7zOz-0.js → DiskStorageWithChecksum-CUXj5mE9.js} +1 -1
  31. package/dist/packem_shared/{DropboxMetaStorage-B7eY16fU.js → DropboxMetaStorage-h0eTJuk5.js} +1 -1
  32. package/dist/packem_shared/{DropboxStorage-9-jj7H8C.js → DropboxStorage-CuA9MkpH.js} +1 -1
  33. package/dist/packem_shared/{FirebaseMetaStorage-BpYykWhG.js → FirebaseMetaStorage-CCBnEE8_.js} +1 -1
  34. package/dist/packem_shared/{FirebaseStorage-DB87abIF.js → FirebaseStorage-DUskfjh_.js} +1 -1
  35. package/dist/packem_shared/{FtpMetaStorage-v2wXTwqX.js → FtpMetaStorage-DxHcXk9x.js} +1 -1
  36. package/dist/packem_shared/{FtpStorage-DdRf0Wg6.js → FtpStorage-DMpDY7oG.js} +1 -1
  37. package/dist/packem_shared/{GCSMetaStorage-BMtou9o7.js → GCSMetaStorage-DCBR02C7.js} +1 -1
  38. package/dist/packem_shared/{GCStorage-CRVpuZ5_.js → GCStorage-RCw58CoD.js} +1 -1
  39. package/dist/packem_shared/{GoogleDriveMetaStorage-BT9N1Wji.js → GoogleDriveMetaStorage-koEiYfFw.js} +1 -1
  40. package/dist/packem_shared/{GoogleDriveStorage-BzuSZZzN.js → GoogleDriveStorage-DNlVE5Uo.js} +1 -1
  41. package/dist/packem_shared/{LocalMetaStorage-BFQz8VPm.js → LocalMetaStorage-BKC34woF.js} +1 -1
  42. package/dist/packem_shared/{MemoryStorage-BuNY963D.js → MemoryStorage-CgEFb9yw.js} +1 -1
  43. package/dist/packem_shared/{Multipart-IE3j_gAJ.js → Multipart-D2eF0kMq.js} +1 -1
  44. package/dist/packem_shared/{Multipart-UIRqOPCf.js → Multipart-mlcj2Wm8.js} +1 -1
  45. package/dist/packem_shared/{NetlifyBlobMetaStorage-DNgncijZ.js → NetlifyBlobMetaStorage-DLJLr0fD.js} +1 -1
  46. package/dist/packem_shared/{NetlifyBlobStorage-eP0pkR0o.js → NetlifyBlobStorage-DqeW_OGE.js} +1 -1
  47. package/dist/packem_shared/{OneDriveMetaStorage-CkaFJFHe.js → OneDriveMetaStorage-Cuw5g3cr.js} +1 -1
  48. package/dist/packem_shared/{OneDriveStorage-3Iq5vBfd.js → OneDriveStorage-D41BZtkz.js} +1 -1
  49. package/dist/packem_shared/{PocketBaseMetaStorage-CxnGde_n.js → PocketBaseMetaStorage-BkzeMDP0.js} +1 -1
  50. package/dist/packem_shared/{PocketBaseStorage-DHphg8yi.js → PocketBaseStorage-CdvEL3YX.js} +1 -1
  51. package/dist/packem_shared/{Rest-DItHKz-N.js → Rest-08Oi3-WZ.js} +1 -1
  52. package/dist/packem_shared/{Rest-B_E4TrqF.js → Rest-BpyZYW-e.js} +1 -1
  53. package/dist/packem_shared/{S3Storage-Bc9eq5vJ.js → S3Storage-adY1XLfH.js} +1 -1
  54. package/dist/packem_shared/{SftpMetaStorage-CBcUhZRU.js → SftpMetaStorage-DN00oxqH.js} +1 -1
  55. package/dist/packem_shared/{SftpStorage-DSsMhTZC.js → SftpStorage-CDKtnw6a.js} +1 -1
  56. package/dist/packem_shared/{SharePointMetaStorage-yzxvwgKr.js → SharePointMetaStorage-WkQcni-I.js} +1 -1
  57. package/dist/packem_shared/{SharePointStorage-C6KIGN2r.js → SharePointStorage-CZkO7FSl.js} +1 -1
  58. package/dist/packem_shared/{SupabaseMetaStorage-D26wob-R.js → SupabaseMetaStorage-FaEVpmT5.js} +1 -1
  59. package/dist/packem_shared/{SupabaseStorage-B_knTpFQ.js → SupabaseStorage-O29RNXWx.js} +1 -1
  60. package/dist/packem_shared/{Tus-KQ8J2WF3.js → Tus-B7k9LUeY.js} +1 -1
  61. package/dist/packem_shared/{Tus-CAestp2j.js → Tus-BZT2Jhl5.js} +1 -1
  62. package/dist/packem_shared/UploadControl-jgusdgDN.js +1 -0
  63. package/dist/packem_shared/{UploadThingMetaStorage-DPIokkHa.js → UploadThingMetaStorage-CdDfhiyy.js} +1 -1
  64. package/dist/packem_shared/{UploadThingStorage-B3aIKSMh.js → UploadThingStorage-ByryGerX.js} +1 -1
  65. package/dist/packem_shared/{VercelBlobMetaStorage-Bx0l9Xt6.js → VercelBlobMetaStorage-CC1zy35k.js} +1 -1
  66. package/dist/packem_shared/{VercelBlobStorage-CGxoGkv4.js → VercelBlobStorage-C4QUjBfu.js} +1 -1
  67. package/dist/packem_shared/{approval.d-3sw7wbPG.d.ts → approval.d-CMAYH9GF.d.ts} +1 -1
  68. package/dist/packem_shared/{base-handler-core-OdTz4-Pm.js → base-handler-core-ty4J6Ji6.js} +1 -1
  69. package/dist/packem_shared/{base-handler-fetch-B0FWPun7.js → base-handler-fetch-BAjJyP84.js} +1 -1
  70. package/dist/packem_shared/{base-handler-node-CR2Bg43M.js → base-handler-node-BCqhH22o.js} +1 -1
  71. package/dist/packem_shared/{defaultCloudStorageFileNameValidation-De0HFP7m.js → defaultCloudStorageFileNameValidation-DSAf6C4S.js} +1 -1
  72. package/dist/packem_shared/detect-file-type-DRWGvQW4.js +1 -0
  73. package/dist/packem_shared/disk-storage-DJ2Nic2v.js +1 -0
  74. package/dist/packem_shared/{disk-storage-with-checksum.d-Z_Z-OQpm.d.ts → disk-storage-with-checksum.d-BT_ll5b8.d.ts} +1 -1
  75. package/dist/packem_shared/{executors.d-CRI3jlk4.d.ts → executors.d-D8esmhum.d.ts} +2 -2
  76. package/dist/packem_shared/{gcs-meta-storage-Dh0TAqB_.js → gcs-meta-storage-BXcsC7xV.js} +1 -1
  77. package/dist/packem_shared/{index.d-C4o9jVLx.d.ts → index.d-DB1VD8RP.d.ts} +1 -1
  78. package/dist/packem_shared/{local-meta-storage-Bvl0Flac.js → local-meta-storage-tayO1ARY.js} +1 -1
  79. package/dist/packem_shared/{local-meta-storage.d-CobcjyWu.d.ts → local-meta-storage.d-DUuLtPik.d.ts} +1 -1
  80. package/dist/packem_shared/{media-transformer.d-B5cQJz30.d.ts → media-transformer.d-B9dfBdoV.d.ts} +2 -2
  81. package/dist/packem_shared/{memory-storage.d-CunLnxmE.d.ts → memory-storage.d-BpxSYO-D.d.ts} +1 -1
  82. package/dist/packem_shared/{rest-base-DHkzq0rj.js → rest-base-BG0e-6E0.js} +1 -1
  83. package/dist/packem_shared/{s3-base-storage-o_zkj15Y.js → s3-base-storage-FiC4s91g.js} +1 -1
  84. package/dist/packem_shared/{s3-base-storage.d-ByfwKeid.d.ts → s3-base-storage.d-CoYAf_hG.d.ts} +1 -1
  85. package/dist/packem_shared/storage-CI88PmRw.js +1 -0
  86. package/dist/packem_shared/{storage.d-D5UN5mRz.d.ts → storage.d-C6HtvSoY.d.ts} +1 -1
  87. package/dist/packem_shared/{tus-base.d-D7UPhqdW.d.ts → tus-base.d-Dv25OXL0.d.ts} +3 -3
  88. package/dist/packem_shared/{types.d-GogSTfRh.d.ts → types.d-Cd2-3e-F.d.ts} +1 -1
  89. package/dist/packem_shared/{types.d-CPUyyEj9.d.ts → types.d-CmBrgo0d.d.ts} +2 -2
  90. package/dist/packem_shared/{types.d-BsjUOfBJ.d.ts → types.d-CmT_ubPu.d.ts} +2 -2
  91. package/dist/storage/aws/index.d.ts +2 -2
  92. package/dist/storage/aws/index.js +1 -1
  93. package/dist/storage/aws-light/index.d.ts +2 -2
  94. package/dist/storage/aws-light/index.js +1 -1
  95. package/dist/storage/azure/index.d.ts +1 -1
  96. package/dist/storage/azure/index.js +1 -1
  97. package/dist/storage/box/index.d.ts +2 -2
  98. package/dist/storage/box/index.js +1 -1
  99. package/dist/storage/bun-s3/index.d.ts +2 -2
  100. package/dist/storage/bun-s3/index.js +1 -1
  101. package/dist/storage/bunny/index.d.ts +2 -2
  102. package/dist/storage/bunny/index.js +1 -1
  103. package/dist/storage/cloudinary/index.d.ts +2 -2
  104. package/dist/storage/cloudinary/index.js +1 -1
  105. package/dist/storage/dropbox/index.d.ts +2 -2
  106. package/dist/storage/dropbox/index.js +1 -1
  107. package/dist/storage/firebase/index.d.ts +2 -2
  108. package/dist/storage/firebase/index.js +1 -1
  109. package/dist/storage/ftp/index.d.ts +2 -2
  110. package/dist/storage/ftp/index.js +1 -1
  111. package/dist/storage/gcs/index.d.ts +1 -1
  112. package/dist/storage/gcs/index.js +1 -1
  113. package/dist/storage/google-drive/index.d.ts +2 -2
  114. package/dist/storage/google-drive/index.js +1 -1
  115. package/dist/storage/local/index.d.ts +3 -3
  116. package/dist/storage/local/index.js +1 -1
  117. package/dist/storage/memory/index.d.ts +2 -2
  118. package/dist/storage/memory/index.js +1 -1
  119. package/dist/storage/netlify-blob/index.d.ts +2 -2
  120. package/dist/storage/netlify-blob/index.js +1 -1
  121. package/dist/storage/onedrive/index.d.ts +4 -4
  122. package/dist/storage/onedrive/index.js +1 -1
  123. package/dist/storage/pocketbase/index.d.ts +2 -2
  124. package/dist/storage/pocketbase/index.js +1 -1
  125. package/dist/storage/sftp/index.d.ts +2 -2
  126. package/dist/storage/sftp/index.js +1 -1
  127. package/dist/storage/sharepoint/index.d.ts +3 -3
  128. package/dist/storage/sharepoint/index.js +1 -1
  129. package/dist/storage/supabase/index.d.ts +2 -2
  130. package/dist/storage/supabase/index.js +1 -1
  131. package/dist/storage/uploadthing/index.d.ts +2 -2
  132. package/dist/storage/uploadthing/index.js +1 -1
  133. package/dist/storage/vercel-blob/index.d.ts +2 -2
  134. package/dist/storage/vercel-blob/index.js +1 -1
  135. package/dist/transformer/audio-transformer.d.ts +2 -2
  136. package/dist/transformer/image-transformer.d.ts +2 -2
  137. package/dist/transformer/index.d.ts +3 -3
  138. package/dist/transformer/video-transformer.d.ts +2 -2
  139. package/package.json +2 -2
  140. package/dist/packem_shared/DiskStorage-DHcHDZeO.js +0 -1
  141. package/dist/packem_shared/UploadControl-Otw_5jxw.js +0 -1
  142. package/dist/packem_shared/detect-file-type-5JhzC9RU.js +0 -1
  143. package/dist/packem_shared/disk-storage-CklneE2m.js +0 -1
  144. package/dist/packem_shared/storage-z0o24zmZ.js +0 -1
@@ -1,5 +1,5 @@
1
- import { F as Files } from "./index.d-C4o9jVLx.js";
2
- import { C as CopyFileInput, D as DeleteFileInput, a as DownloadFileInput, G as GetFileMetadataInput, b as GetFileUrlInput, L as ListFilesInput, S as SignUploadUrlInput, U as UploadFileInput } from "./approval.d-3sw7wbPG.js";
1
+ import { F as Files } from "./index.d-DB1VD8RP.js";
2
+ import { C as CopyFileInput, D as DeleteFileInput, a as DownloadFileInput, G as GetFileMetadataInput, b as GetFileUrlInput, L as ListFilesInput, S as SignUploadUrlInput, U as UploadFileInput } from "./approval.d-CMAYH9GF.js";
3
3
  interface CopyFileResult {
4
4
  copied: true;
5
5
  etag: string | undefined;
@@ -1 +1 @@
1
- var g=Object.defineProperty;var o=(s,t)=>g(s,"name",{value:t,configurable:!0});import{randomUUID as y}from"node:crypto";import{request as f}from"gaxios";import{GoogleAuth as C}from"google-auth-library";import v from"./MetaStorage-Y4m1dWgd.js";import{stringifyMetadata as R,parseMetadata as E}from"./Metadata-B6Ir0KO7.js";import n from"./GCSConfig-BQ0OpVhe.js";import{o as $}from"./has-content-Bx2p8Okx.js";var I="@visulima/storage",P="1.0.0-alpha.32";const i={name:I,version:P};var A=Object.defineProperty,u=o((s,t)=>A(s,"name",{value:t,configurable:!0}),"n");const T=u(s=>{const t=s.match(/(\d+)-(\d+)/),e=t?.[2]?+t[2]:0;return e>0?e+1:0},"getRangeEnd"),G=u(s=>{if($(s)){const t=s.contentLength?s.start+s.contentLength-1:"*";return`bytes ${s.start}-${t}/${s.size??"*"}`}return`bytes */${s.size??"*"}`},"buildContentRange"),U=u(s=>{if(s.response!==void 0){const{response:t}=s;return t?.data?.error?.errors?.map(({reason:e=""})=>e==="rateLimitExceeded"||e==="userRateLimitExceeded"?!0:!!(e&&e.includes("EAI_AGAIN"))).includes(!0)}return!1},"shouldRetry"),w={retry:3,shouldRetry:U,statusCodesToRetry:[[408,429,500,502,503,504],[100,199],[429],[500,599]]};var b=Object.defineProperty,j=o((s,t)=>b(s,"name",{value:t,configurable:!0}),"p");class N extends v{static{o(this,"E")}constructor(t){super(t),this.config=t;const{authClient:e,...a}=t,r=a.bucket||process.env.GCS_BUCKET;if(e===void 0){if(!r)throw new Error("GCS bucket is not defined");if(!a.projectId)throw new Error("Sorry, we cannot connect to Cloud Services without a project ID.");a.scopes||=n.authScopes,this.authClient=new C(a)}else this.authClient=e;this.storageBaseURI=`${a.storageAPI||n.storageAPI}/${r}/o`,this.uploadBaseURI=`${a.uploadAPI||n.uploadAPI}/${r}/o`;const h=["storage.googleapis.com"],d=new URL(this.storageBaseURI).hostname;this.isCustomEndpoint=!h.includes(d);const{retryOptions:m,useAuthWithCustomEndpoint:p,userProject:l}=t;this.userProject=l,this.useAuthWithCustomEndpoint=p||!1,this.retryOptions={...w,...m},e===void 0&&this.accessCheck().catch(c=>{throw c.code==="404"?new Error(`Bucket ${r} does not exist`):c})}config;static{j(this,"GCSMetaStorage")}authClient;storageBaseURI;uploadBaseURI;isCustomEndpoint=!1;retryOptions={};useAuthWithCustomEndpoint;userProject;async save(t,e){const a={...e};return a.metadata&&(a.metadata=R(e.metadata)),await this.makeRequest({body:JSON.stringify(a),headers:{"Content-Type":"application/json; charset=utf-8"},method:"POST",params:{name:encodeURIComponent(this.getMetaName(t)),uploadType:"media"},url:this.uploadBaseURI}),e}async delete(t){const e=this.getMetaPath(t);await this.makeRequest({method:"DELETE",url:e})}async get(t){const e=this.getMetaPath(t),{data:a}=await this.makeRequest({params:{alt:"media"},url:e});return a.metadata&&typeof a.metadata=="string"&&(a.metadata=E(a.metadata)),a}async touch(t,e){return this.save(t,e)}async accessCheck(){return this.makeRequest({url:this.storageBaseURI.replace("/o","")})}getMetaPath(t){return`${this.storageBaseURI}/${this.getMetaName(t)}`}async makeRequest(t){return typeof t.url=="string"&&(t.url=t.url.replaceAll("/:",":")),t={...t,headers:{"User-Agent":`${i.name}/${i.version}`,"x-goog-api-client":`gl-node/${process.versions.node} gccl/${i.version} gccl-invocation-id/${y()}`},params:{...this.userProject===void 0?{}:{userProject:this.userProject}},retry:!0,retryConfig:this.retryOptions,timeout:6e4},this.isCustomEndpoint&&!this.useAuthWithCustomEndpoint?f(t):this.authClient.request(t)}}export{N as E,G as b,i as d,T as g,w as r};
1
+ var g=Object.defineProperty;var o=(s,t)=>g(s,"name",{value:t,configurable:!0});import{randomUUID as y}from"node:crypto";import{request as f}from"gaxios";import{GoogleAuth as C}from"google-auth-library";import v from"./MetaStorage-Y4m1dWgd.js";import{stringifyMetadata as R,parseMetadata as E}from"./Metadata-B6Ir0KO7.js";import n from"./GCSConfig-BQ0OpVhe.js";import{o as $}from"./has-content-Bx2p8Okx.js";var I="@visulima/storage",P="1.0.0-alpha.33";const i={name:I,version:P};var A=Object.defineProperty,u=o((s,t)=>A(s,"name",{value:t,configurable:!0}),"n");const T=u(s=>{const t=s.match(/(\d+)-(\d+)/),e=t?.[2]?+t[2]:0;return e>0?e+1:0},"getRangeEnd"),G=u(s=>{if($(s)){const t=s.contentLength?s.start+s.contentLength-1:"*";return`bytes ${s.start}-${t}/${s.size??"*"}`}return`bytes */${s.size??"*"}`},"buildContentRange"),U=u(s=>{if(s.response!==void 0){const{response:t}=s;return t?.data?.error?.errors?.map(({reason:e=""})=>e==="rateLimitExceeded"||e==="userRateLimitExceeded"?!0:!!(e&&e.includes("EAI_AGAIN"))).includes(!0)}return!1},"shouldRetry"),w={retry:3,shouldRetry:U,statusCodesToRetry:[[408,429,500,502,503,504],[100,199],[429],[500,599]]};var b=Object.defineProperty,j=o((s,t)=>b(s,"name",{value:t,configurable:!0}),"p");class N extends v{static{o(this,"E")}constructor(t){super(t),this.config=t;const{authClient:e,...a}=t,r=a.bucket||process.env.GCS_BUCKET;if(e===void 0){if(!r)throw new Error("GCS bucket is not defined");if(!a.projectId)throw new Error("Sorry, we cannot connect to Cloud Services without a project ID.");a.scopes||=n.authScopes,this.authClient=new C(a)}else this.authClient=e;this.storageBaseURI=`${a.storageAPI||n.storageAPI}/${r}/o`,this.uploadBaseURI=`${a.uploadAPI||n.uploadAPI}/${r}/o`;const h=["storage.googleapis.com"],d=new URL(this.storageBaseURI).hostname;this.isCustomEndpoint=!h.includes(d);const{retryOptions:m,useAuthWithCustomEndpoint:p,userProject:l}=t;this.userProject=l,this.useAuthWithCustomEndpoint=p||!1,this.retryOptions={...w,...m},e===void 0&&this.accessCheck().catch(c=>{throw c.code==="404"?new Error(`Bucket ${r} does not exist`):c})}config;static{j(this,"GCSMetaStorage")}authClient;storageBaseURI;uploadBaseURI;isCustomEndpoint=!1;retryOptions={};useAuthWithCustomEndpoint;userProject;async save(t,e){const a={...e};return a.metadata&&(a.metadata=R(e.metadata)),await this.makeRequest({body:JSON.stringify(a),headers:{"Content-Type":"application/json; charset=utf-8"},method:"POST",params:{name:encodeURIComponent(this.getMetaName(t)),uploadType:"media"},url:this.uploadBaseURI}),e}async delete(t){const e=this.getMetaPath(t);await this.makeRequest({method:"DELETE",url:e})}async get(t){const e=this.getMetaPath(t),{data:a}=await this.makeRequest({params:{alt:"media"},url:e});return a.metadata&&typeof a.metadata=="string"&&(a.metadata=E(a.metadata)),a}async touch(t,e){return this.save(t,e)}async accessCheck(){return this.makeRequest({url:this.storageBaseURI.replace("/o","")})}getMetaPath(t){return`${this.storageBaseURI}/${this.getMetaName(t)}`}async makeRequest(t){return typeof t.url=="string"&&(t.url=t.url.replaceAll("/:",":")),t={...t,headers:{"User-Agent":`${i.name}/${i.version}`,"x-goog-api-client":`gl-node/${process.versions.node} gccl/${i.version} gccl-invocation-id/${y()}`},params:{...this.userProject===void 0?{}:{userProject:this.userProject}},retry:!0,retryConfig:this.retryOptions,timeout:6e4},this.isCustomEndpoint&&!this.useAuthWithCustomEndpoint?f(t):this.authClient.request(t)}}export{N as E,G as b,i as d,T as g,w as r};
@@ -1,4 +1,4 @@
1
- import { O as OperationOptions, B as BaseStorage } from "./storage.d-D5UN5mRz.js";
1
+ import { O as OperationOptions, B as BaseStorage } from "./storage.d-C6HtvSoY.js";
2
2
  /**
3
3
  * Web-standard and Node-native body types accepted by {@link Files.upload}.
4
4
  */
@@ -1 +1 @@
1
- var re=Object.defineProperty;var o=(e,t)=>re(e,"name",{value:t,configurable:!0});import{utimes as ae}from"node:fs/promises";import{tmpdir as oe}from"node:os";import{createRequire as m}from"node:module";import{A as T,M as _,J as ie,K as ne,L as R}from"./path-D7rMc9nq-B718mbm6.js";import{throwErrorCode as j,ERRORS as P}from"./ERRORS-vMSqlI69.js";import se from"./MetaStorage-Y4m1dWgd.js";import{stringifyMetadata as ce,parseMetadata as ue}from"./Metadata-B6Ir0KO7.js";const E=0,le=4;var fe=Object.defineProperty,pe=o((e,t)=>fe(e,"name",{value:t,configurable:!0}),"t$6"),me=Object.defineProperty,de=pe((e,t)=>me(e,"name",{value:t,configurable:!0}),"t"),ge=Object.defineProperty,be=de((e,t)=>ge(e,"name",{value:t,configurable:!0}),"n");const $=be(e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var ve=Object.defineProperty,ye=o((e,t)=>ve(e,"name",{value:t,configurable:!0}),"i$8"),he=Object.defineProperty,$e=ye((e,t)=>he(e,"name",{value:t,configurable:!0}),"r"),we=Object.defineProperty,Oe=$e((e,t)=>we(e,"name",{value:t,configurable:!0}),"i");const S=Oe(e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"},"getFileInfoType");var je=Object.defineProperty,Pe=o((e,t)=>je(e,"name",{value:t,configurable:!0}),"i$7"),xe=Object.defineProperty,q=Pe((e,t)=>xe(e,"name",{value:t,configurable:!0}),"s");const Ee=m(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Te=q(e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,r]=d.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return d.getBuiltinModule(e)}return Ee(e)},"__cjs_getBuiltinModule"),{lstat:I,mkdir:_e}=Te("node:fs/promises");var Me=Object.defineProperty,ke=q((e,t)=>Me(e,"name",{value:t,configurable:!0}),"o");const Ne=ke(async e=>{$(e);try{const t=await I(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(S(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{await _e(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const r=await I(e);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(S(r))}'`,{cause:t})}},"ensureDir");var ze=Object.defineProperty,l=o((e,t)=>ze(e,"name",{value:t,configurable:!0}),"n$7"),Be=Object.defineProperty,s=l((e,t)=>Be(e,"name",{value:t,configurable:!0}),"a");const Fe=m(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ae=s(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return Fe(e)},"__cjs_getBuiltinModule"),{fileURLToPath:De}=Ae("node:url");var Re=Object.defineProperty,p=s((e,t)=>Re(e,"name",{value:t,configurable:!0}),"t$1");function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(O,"m$4");l(O,"d");s(O,"getDefaultExportFromCjs");p(O,"getDefaultExportFromCjs");function M(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(M,"h$1");l(M,"O");s(M,"getDefaultExportFromNamespaceIfPresent");p(M,"getDefaultExportFromNamespaceIfPresent");function k(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.keys(e).length===1?e.default:e}o(k,"x");l(k,"P");s(k,"getDefaultExportFromNamespaceIfNotNamed");p(k,"getDefaultExportFromNamespaceIfNotNamed");function N(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=p(s(l(o(function a(){var i=!1;try{i=this instanceof a}catch{}return i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)},"a"),"s"),"a"),"a");r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,i.get?i:{enumerable:!0,get:p(function(){return e[a]},"get")})}),r}o(N,"y$2");l(N,"_");s(N,"getAugmentedNamespace");p(N,"getAugmentedNamespace");var L,U;function z(){return U||(U=1,L=["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"]),L}o(z,"w$2");l(z,"k");s(z,"requireBinaryExtensions");var Se=z();const Ie=O(Se);var Le=Object.defineProperty,n=s((e,t)=>Le(e,"name",{value:t,configurable:!0}),"r");const Ue=new Set(Ie),Ce=new Set(["/","\\",void 0]),C=Symbol.for("pathe:normalizedAlias"),We=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,qe=n((e,t)=>t.split("/").length-e.split("/").length,"compareAliases"),w=n((e="/")=>{const t=e.at(-1);return t==="/"||t==="\\"},"hasTrailingSlash"),V=n(e=>{if(e[C])return e;const t=Object.fromEntries(Object.entries(e).toSorted(([r],[a])=>qe(r,a)));for(const r in t)for(const a in t)a===r||r.startsWith(a)||t[r].startsWith(a)&&Ce.has(t[r][a.length])&&(t[r]=t[a]+t[r].slice(a.length));return Object.defineProperty(t,C,{enumerable:!1,value:!0}),t},"normalizeAliases");n((e,t)=>{e=T(e),t=V(t);for(const[r,a]of Object.entries(t)){if(!e.startsWith(r))continue;const i=w(r)?r.slice(0,-1):r;if(w(e[i.length]))return _(a,e.slice(r.length))}return e},"resolveAlias");n(e=>We.exec(e)?.[2],"filename");n((e,t)=>{e=T(e),t=V(t);for(const[r,a]of Object.entries(t).toReversed()){if(!e.startsWith(a))continue;const i=w(a)?a.slice(0,-1):a;if(w(e[i.length]))return _(r,e.slice(a.length))}return e},"reverseResolveAlias");const Ve=/^(?:\.?\.[/\\]|\.\.\B)/,Je=/^(?:msys|cygwin)$/;n(e=>Ve.test(e)||e==="..","isRelative");n(e=>Ue.has(ie(e).slice(1).toLowerCase()),"isBinaryPath");const B=n(e=>T(e instanceof URL?De(e):e),"toPath");n(()=>{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:Je.test(e)},"isWindows");var Ke=Object.defineProperty,J=o((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"t$4"),Xe=Object.defineProperty,F=J((e,t)=>Xe(e,"name",{value:t,configurable:!0}),"s");const Ye=m(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ge=F(e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,r]=b.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return b.getBuiltinModule(e)}return Ye(e)},"__cjs_getBuiltinModule"),{access:He}=Ge("node:fs/promises");var Qe=Object.defineProperty,Ze=F((e,t)=>Qe(e,"name",{value:t,configurable:!0}),"o");async function u(e,t=E){$(e),e=B(e);try{return await He(e,t),!0}catch{return!1}}o(u,"i$5");J(u,"d");F(u,"m");Ze(u,"isAccessible");var et=Object.defineProperty,K=o((e,t)=>et(e,"name",{value:t,configurable:!0}),"t$3"),tt=Object.defineProperty,X=K((e,t)=>tt(e,"name",{value:t,configurable:!0}),"t"),rt=Object.defineProperty,at=X((e,t)=>rt(e,"name",{value:t,configurable:!0}),"o");let ot=class extends Error{static{o(this,"c")}static{K(this,"i")}static{X(this,"n")}static{at(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 it=Object.defineProperty,nt=o((e,t)=>it(e,"name",{value:t,configurable:!0}),"f$4"),st=Object.defineProperty,Y=nt((e,t)=>st(e,"name",{value:t,configurable:!0}),"i");const ct=m(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=Y(e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,r]=v.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return v.getBuiltinModule(e)}return ct(e)},"__cjs_getBuiltinModule"),{readFile:ut}=G("node:fs/promises"),{unzip:lt,brotliDecompress:ft}=G("node:zlib");var pt=Object.defineProperty,H=Y((e,t)=>pt(e,"name",{value:t,configurable:!0}),"n");const mt={brotli:ft,gzip:lt,none:H((e,t)=>{t(null,e)},"none")},dt=H(async(e,t)=>{if($(e),e=B(e),!await u(e))throw new ot(`unable to read the non-accessible file: ${e}`);if(!await u(e,le))throw new Error(`Unable to read the non-readable file: ${e}`);const{buffer:r,compression:a,encoding:i,flag:c}=t??{};return await ut(e,c?{encoding:i,flag:c}:{encoding:i}).then(async f=>await new Promise((ee,te)=>{mt[a??"none"](f,(A,D)=>{A?te(A):ee(r?D:D.toString())})})).catch(f=>{throw f})},"readFile");var gt=Object.defineProperty,bt=o((e,t)=>gt(e,"name",{value:t,configurable:!0}),"a$4"),vt=Object.defineProperty,yt=bt((e,t)=>vt(e,"name",{value:t,configurable:!0}),"t"),ht=Object.defineProperty,$t=yt((e,t)=>ht(e,"name",{value:t,configurable:!0}),"t");const wt=$t(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 Ot=Object.defineProperty,jt=o((e,t)=>Ot(e,"name",{value:t,configurable:!0}),"i$2"),Pt=Object.defineProperty,Q=jt((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"s");const xt=m(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Et=Q(e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[t,r]=y.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return y.getBuiltinModule(e)}return xt(e)},"__cjs_getBuiltinModule"),{unlink:Tt,rm:_t}=Et("node:fs/promises");var Mt=Object.defineProperty,kt=Q((e,t)=>Mt(e,"name",{value:t,configurable:!0}),"i");const Nt=kt(async(e,t={})=>{$(e);try{await Tt(e)}catch{}try{await _t(e,wt(t))}catch{}},"remove");var zt=Object.defineProperty,Bt=o((e,t)=>zt(e,"name",{value:t,configurable:!0}),"a$2"),Ft=Object.defineProperty,At=Bt((e,t)=>Ft(e,"name",{value:t,configurable:!0}),"t"),Dt=Object.defineProperty,Rt=At((e,t)=>Dt(e,"name",{value:t,configurable:!0}),"e");const St=Rt(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 It=Object.defineProperty,Lt=o((e,t)=>It(e,"name",{value:t,configurable:!0}),"t"),Ut=Object.defineProperty,Ct=Lt((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"r"),Wt=Object.defineProperty,qt=Ct((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"f");const Vt=new TextEncoder,Jt=qt(e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Vt.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 Kt=Object.defineProperty,Xt=o((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"m"),Yt=Object.defineProperty,Z=Xt((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"s");const Gt=m(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ht=Z(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,r]=h.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return h.getBuiltinModule(e)}return Gt(e)},"__cjs_getBuiltinModule"),{mkdir:Qt,writeFile:Zt,stat:er,rename:W,chown:tr,chmod:rr,unlink:ar}=Ht("node:fs/promises");var or=Object.defineProperty,ir=Z((e,t)=>or(e,"name",{value:t,configurable:!0}),"d");const nr=ir(async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},$(e),St(t),e=B(e);const a=`${e}.tmp`;try{const i=await u(e,E);if(!i&&r.recursive){const f=ne(e);await u(f,E)||await Qt(f,{recursive:!0})}let c;if(await Zt(a,Jt(t),{encoding:r.encoding,flag:r.flag}),i&&!r.overwrite&&(c=await er(e),r.chown??={gid:c.gid,uid:c.uid},await W(e,`${e}.bak`)),r.chown)try{await tr(a,r.chown.uid,r.chown.gid)}catch{}await rr(a,c&&!r.mode?c.mode:r.mode??438),await W(a,e)}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await u(a)&&await ar(`${e}.tmp`)}},"writeFile");var sr=Object.defineProperty,x=o((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a");let vr=class extends se{static{o(this,"v")}static{x(this,"LocalMetaStorage")}directory;constructor(t){super(t),this.directory=R(t?.directory||_(oe(),"Upload_meta")),this.accessCheck().catch(r=>{this.logger?.error("Metadata storage access check failed: %O",r)})}getMetaPath=x(t=>{const r=R(`${this.directory}/${this.prefix}${t}${this.suffix}`),a=this.directory.endsWith("/")?this.directory:`${this.directory}/`;return r.startsWith(a)?r:j(P.INVALID_FILE_NAME,`Invalid id: "${t}" resolves outside the meta directory`)},"getMetaPath");getIdFromPath=x(t=>t.slice(`${this.directory}/${this.prefix}`.length,-this.suffix.length),"getIdFromPath");async save(t,r){await this.accessCheck();const a={...r};return a.metadata&&(a.metadata=ce(r.metadata)),await nr(this.getMetaPath(t),JSON.stringify(a),{recursive:!0}),r}async touch(t,r){const a=new Date;return await ae(this.getMetaPath(t),a,a),r}async get(t){try{const r=await dt(this.getMetaPath(t));if(r===void 0)throw j(P.FILE_NOT_FOUND);const a=JSON.parse(r);return a.metadata&&typeof a.metadata=="string"&&(a.metadata=ue(a.metadata)),a}catch(r){const a=r,i=r instanceof SyntaxError;throw a.code==="ENOENT"||i?j(P.FILE_NOT_FOUND):r}}async delete(t){await Nt(this.getMetaPath(t))}async accessCheck(){await Ne(this.directory)}};export{dt as B,B as U,E as _,$ as f,u as i,S as l,vr as v,Ne as w,Nt as y};
1
+ var re=Object.defineProperty;var o=(e,t)=>re(e,"name",{value:t,configurable:!0});import{utimes as ae}from"node:fs/promises";import{tmpdir as oe}from"node:os";import{createRequire as m}from"node:module";import{A as T,M as _,J as ie,K as ne,L as R}from"./path-D7rMc9nq-B718mbm6.js";import{throwErrorCode as j,ERRORS as P}from"./ERRORS-vMSqlI69.js";import se from"./MetaStorage-Y4m1dWgd.js";import{stringifyMetadata as ce,parseMetadata as ue}from"./Metadata-B6Ir0KO7.js";const E=0,le=4;var fe=Object.defineProperty,pe=o((e,t)=>fe(e,"name",{value:t,configurable:!0}),"t$6"),me=Object.defineProperty,de=pe((e,t)=>me(e,"name",{value:t,configurable:!0}),"t"),ge=Object.defineProperty,be=de((e,t)=>ge(e,"name",{value:t,configurable:!0}),"n");const $=be(e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var ve=Object.defineProperty,ye=o((e,t)=>ve(e,"name",{value:t,configurable:!0}),"i$8"),he=Object.defineProperty,$e=ye((e,t)=>he(e,"name",{value:t,configurable:!0}),"r"),we=Object.defineProperty,Oe=$e((e,t)=>we(e,"name",{value:t,configurable:!0}),"i");const S=Oe(e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"},"getFileInfoType");var je=Object.defineProperty,Pe=o((e,t)=>je(e,"name",{value:t,configurable:!0}),"i$7"),xe=Object.defineProperty,q=Pe((e,t)=>xe(e,"name",{value:t,configurable:!0}),"s");const Ee=m(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Te=q(e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,r]=d.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return d.getBuiltinModule(e)}return Ee(e)},"__cjs_getBuiltinModule"),{lstat:I,mkdir:_e}=Te("node:fs/promises");var Me=Object.defineProperty,ke=q((e,t)=>Me(e,"name",{value:t,configurable:!0}),"o");const Ne=ke(async e=>{$(e);try{const t=await I(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(S(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{await _e(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const r=await I(e);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(S(r))}'`,{cause:t})}},"ensureDir");var ze=Object.defineProperty,l=o((e,t)=>ze(e,"name",{value:t,configurable:!0}),"n$6"),Be=Object.defineProperty,s=l((e,t)=>Be(e,"name",{value:t,configurable:!0}),"a");const Fe=m(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ae=s(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return Fe(e)},"__cjs_getBuiltinModule"),{fileURLToPath:De}=Ae("node:url");var Re=Object.defineProperty,p=s((e,t)=>Re(e,"name",{value:t,configurable:!0}),"t$1");function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(O,"m$2");l(O,"d");s(O,"getDefaultExportFromCjs");p(O,"getDefaultExportFromCjs");function M(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(M,"h$1");l(M,"O");s(M,"getDefaultExportFromNamespaceIfPresent");p(M,"getDefaultExportFromNamespaceIfPresent");function k(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.keys(e).length===1?e.default:e}o(k,"x");l(k,"P");s(k,"getDefaultExportFromNamespaceIfNotNamed");p(k,"getDefaultExportFromNamespaceIfNotNamed");function N(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=p(s(l(o(function a(){var i=!1;try{i=this instanceof a}catch{}return i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)},"a"),"s"),"a"),"a");r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,i.get?i:{enumerable:!0,get:p(function(){return e[a]},"get")})}),r}o(N,"y$2");l(N,"_");s(N,"getAugmentedNamespace");p(N,"getAugmentedNamespace");var L,U;function z(){return U||(U=1,L=["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"]),L}o(z,"w$2");l(z,"k");s(z,"requireBinaryExtensions");var Se=z();const Ie=O(Se);var Le=Object.defineProperty,n=s((e,t)=>Le(e,"name",{value:t,configurable:!0}),"r");const Ue=new Set(Ie),Ce=new Set(["/","\\",void 0]),C=Symbol.for("pathe:normalizedAlias"),We=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,qe=n((e,t)=>t.split("/").length-e.split("/").length,"compareAliases"),w=n((e="/")=>{const t=e.at(-1);return t==="/"||t==="\\"},"hasTrailingSlash"),V=n(e=>{if(e[C])return e;const t=Object.fromEntries(Object.entries(e).toSorted(([r],[a])=>qe(r,a)));for(const r in t)for(const a in t)a===r||r.startsWith(a)||t[r].startsWith(a)&&Ce.has(t[r][a.length])&&(t[r]=t[a]+t[r].slice(a.length));return Object.defineProperty(t,C,{enumerable:!1,value:!0}),t},"normalizeAliases");n((e,t)=>{e=T(e),t=V(t);for(const[r,a]of Object.entries(t)){if(!e.startsWith(r))continue;const i=w(r)?r.slice(0,-1):r;if(w(e[i.length]))return _(a,e.slice(r.length))}return e},"resolveAlias");n(e=>We.exec(e)?.[2],"filename");n((e,t)=>{e=T(e),t=V(t);for(const[r,a]of Object.entries(t).toReversed()){if(!e.startsWith(a))continue;const i=w(a)?a.slice(0,-1):a;if(w(e[i.length]))return _(r,e.slice(a.length))}return e},"reverseResolveAlias");const Ve=/^(?:\.?\.[/\\]|\.\.\B)/,Je=/^(?:msys|cygwin)$/;n(e=>Ve.test(e)||e==="..","isRelative");n(e=>Ue.has(ie(e).slice(1).toLowerCase()),"isBinaryPath");const B=n(e=>T(e instanceof URL?De(e):e),"toPath");n(()=>{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:Je.test(e)},"isWindows");var Ke=Object.defineProperty,J=o((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"t$4"),Xe=Object.defineProperty,F=J((e,t)=>Xe(e,"name",{value:t,configurable:!0}),"s");const Ye=m(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ge=F(e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,r]=b.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return b.getBuiltinModule(e)}return Ye(e)},"__cjs_getBuiltinModule"),{access:He}=Ge("node:fs/promises");var Qe=Object.defineProperty,Ze=F((e,t)=>Qe(e,"name",{value:t,configurable:!0}),"o");async function u(e,t=E){$(e),e=B(e);try{return await He(e,t),!0}catch{return!1}}o(u,"i$5");J(u,"d");F(u,"m");Ze(u,"isAccessible");var et=Object.defineProperty,K=o((e,t)=>et(e,"name",{value:t,configurable:!0}),"t$3"),tt=Object.defineProperty,X=K((e,t)=>tt(e,"name",{value:t,configurable:!0}),"t"),rt=Object.defineProperty,at=X((e,t)=>rt(e,"name",{value:t,configurable:!0}),"o");let ot=class extends Error{static{o(this,"c")}static{K(this,"i")}static{X(this,"n")}static{at(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 it=Object.defineProperty,nt=o((e,t)=>it(e,"name",{value:t,configurable:!0}),"l$2"),st=Object.defineProperty,Y=nt((e,t)=>st(e,"name",{value:t,configurable:!0}),"i");const ct=m(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=Y(e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,r]=v.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return v.getBuiltinModule(e)}return ct(e)},"__cjs_getBuiltinModule"),{readFile:ut}=G("node:fs/promises"),{unzip:lt,brotliDecompress:ft}=G("node:zlib");var pt=Object.defineProperty,H=Y((e,t)=>pt(e,"name",{value:t,configurable:!0}),"n");const mt={brotli:ft,gzip:lt,none:H((e,t)=>{t(null,e)},"none")},dt=H(async(e,t)=>{if($(e),e=B(e),!await u(e))throw new ot(`unable to read the non-accessible file: ${e}`);if(!await u(e,le))throw new Error(`Unable to read the non-readable file: ${e}`);const{buffer:r,compression:a,encoding:i,flag:c}=t??{};return await ut(e,c?{flag:c}:{}).then(async f=>await new Promise((ee,te)=>{mt[a??"none"](f,(A,D)=>{A?te(A):ee(r?D:D.toString(i??"utf8"))})})).catch(f=>{throw f})},"readFile");var gt=Object.defineProperty,bt=o((e,t)=>gt(e,"name",{value:t,configurable:!0}),"a$4"),vt=Object.defineProperty,yt=bt((e,t)=>vt(e,"name",{value:t,configurable:!0}),"t"),ht=Object.defineProperty,$t=yt((e,t)=>ht(e,"name",{value:t,configurable:!0}),"t");const wt=$t(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 Ot=Object.defineProperty,jt=o((e,t)=>Ot(e,"name",{value:t,configurable:!0}),"i$2"),Pt=Object.defineProperty,Q=jt((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"s");const xt=m(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Et=Q(e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[t,r]=y.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return y.getBuiltinModule(e)}return xt(e)},"__cjs_getBuiltinModule"),{unlink:Tt,rm:_t}=Et("node:fs/promises");var Mt=Object.defineProperty,kt=Q((e,t)=>Mt(e,"name",{value:t,configurable:!0}),"i");const Nt=kt(async(e,t={})=>{$(e);try{await Tt(e)}catch{}try{await _t(e,wt(t))}catch{}},"remove");var zt=Object.defineProperty,Bt=o((e,t)=>zt(e,"name",{value:t,configurable:!0}),"a$2"),Ft=Object.defineProperty,At=Bt((e,t)=>Ft(e,"name",{value:t,configurable:!0}),"t"),Dt=Object.defineProperty,Rt=At((e,t)=>Dt(e,"name",{value:t,configurable:!0}),"e");const St=Rt(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 It=Object.defineProperty,Lt=o((e,t)=>It(e,"name",{value:t,configurable:!0}),"t"),Ut=Object.defineProperty,Ct=Lt((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"r"),Wt=Object.defineProperty,qt=Ct((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"f");const Vt=new TextEncoder,Jt=qt(e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Vt.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 Kt=Object.defineProperty,Xt=o((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"c"),Yt=Object.defineProperty,Z=Xt((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"n");const Gt=m(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ht=Z(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,r]=h.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return h.getBuiltinModule(e)}return Gt(e)},"__cjs_getBuiltinModule"),{mkdir:Qt,writeFile:Zt,stat:er,rename:W,chown:tr,chmod:rr,unlink:ar}=Ht("node:fs/promises");var or=Object.defineProperty,ir=Z((e,t)=>or(e,"name",{value:t,configurable:!0}),"w");const nr=ir(async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},$(e),St(t),e=B(e);const a=`${e}.tmp`;try{const i=await u(e,E);if(!i&&r.recursive){const f=ne(e);await u(f,E)||await Qt(f,{recursive:!0})}let c;if(await Zt(a,typeof t=="string"?Buffer.from(t,r.encoding??"utf8"):Jt(t),{flag:r.flag}),i&&!r.overwrite&&(c=await er(e),r.chown??={gid:c.gid,uid:c.uid},await W(e,`${e}.bak`)),r.chown)try{await tr(a,r.chown.uid,r.chown.gid)}catch{}await rr(a,c&&!r.mode?c.mode:r.mode??438),await W(a,e)}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await u(a)&&await ar(`${e}.tmp`)}},"writeFile");var sr=Object.defineProperty,x=o((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a");let vr=class extends se{static{o(this,"v")}static{x(this,"LocalMetaStorage")}directory;constructor(t){super(t),this.directory=R(t?.directory||_(oe(),"Upload_meta")),this.accessCheck().catch(r=>{this.logger?.error("Metadata storage access check failed: %O",r)})}getMetaPath=x(t=>{const r=R(`${this.directory}/${this.prefix}${t}${this.suffix}`),a=this.directory.endsWith("/")?this.directory:`${this.directory}/`;return r.startsWith(a)?r:j(P.INVALID_FILE_NAME,`Invalid id: "${t}" resolves outside the meta directory`)},"getMetaPath");getIdFromPath=x(t=>t.slice(`${this.directory}/${this.prefix}`.length,-this.suffix.length),"getIdFromPath");async save(t,r){await this.accessCheck();const a={...r};return a.metadata&&(a.metadata=ce(r.metadata)),await nr(this.getMetaPath(t),JSON.stringify(a),{recursive:!0}),r}async touch(t,r){const a=new Date;return await ae(this.getMetaPath(t),a,a),r}async get(t){try{const r=await dt(this.getMetaPath(t));if(r===void 0)throw j(P.FILE_NOT_FOUND);const a=JSON.parse(r);return a.metadata&&typeof a.metadata=="string"&&(a.metadata=ue(a.metadata)),a}catch(r){const a=r,i=r instanceof SyntaxError;throw a.code==="ENOENT"||i?j(P.FILE_NOT_FOUND):r}}async delete(t){await Nt(this.getMetaPath(t))}async accessCheck(){await Ne(this.directory)}};export{dt as E,B as U,E as _,$ as f,u as i,S as l,vr as v,Ne as w,Nt as y};
@@ -1,4 +1,4 @@
1
- import { F as File, L as LocalMetaStorageOptions, M as MetaStorage } from "./storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, M as MetaStorage } from "./storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
3
  /**
4
4
  * Stores upload metafiles on local disk
@@ -1,5 +1,5 @@
1
- import { F as File, a as FileReturn, B as BaseStorage } from "./storage.d-D5UN5mRz.js";
2
- import { M as MediaTransformerConfig, l as MediaTransformResult } from "./types.d-BsjUOfBJ.js";
1
+ import { F as File, a as FileReturn, B as BaseStorage } from "./storage.d-C6HtvSoY.js";
2
+ import { O as MediaTransformerConfig, Q as MediaTransformResult } from "./types.d-CmT_ubPu.js";
3
3
  /**
4
4
  * Unified media transformer that automatically detects media type and routes to appropriate transformer.
5
5
  * @template TFile The file type used by this transformer.
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'node:stream';
2
- import { F as File, i as MetaStorageOptions, M as MetaStorage, j as BaseStorageOptions, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "./storage.d-D5UN5mRz.js";
2
+ import { F as File, i as MetaStorageOptions, M as MetaStorage, j as BaseStorageOptions, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "./storage.d-C6HtvSoY.js";
3
3
  /**
4
4
  * Map-backed metadata storage used by {@link MemoryStorage}. Holds a deep-copied
5
5
  * snapshot of each `File` so callers can mutate the returned object without leaking
@@ -1 +1 @@
1
- var E=Object.defineProperty;var y=(a,t)=>E(a,"name",{value:t,configurable:!0});import{n as u}from"./headers-DC2MEOrK.js";import{hasBody as X}from"type-is";import{a as c}from"./base-handler-core-OdTz4-Pm.js";import{ERRORS as A}from"./ERRORS-vMSqlI69.js";import{b,a as z,c as v,d as L}from"./response-builder-Wdo_fvcF.js";var T=Object.defineProperty,f=y((a,t)=>T(a,"name",{value:t,configurable:!0}),"a$1");const D=f((a,t={})=>{const e=c(a,"x-file-metadata",!0);if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}},"parseMetadata"),P=f(a=>{if(!a)return;const t=2e3,e=a.length>t?a.slice(0,Math.max(0,t)):a,r=e.toLowerCase().indexOf("filename");if(r===-1)return;let s=r+8;for(;s<e.length&&(e[s]==="*"||e[s]===" "||e[s]===" ");)s++;if(s>=e.length||e[s]!=="=")return;for(s++;s<e.length&&(e[s]===" "||e[s]===" ");)s++;if(s>=e.length)return;let n=s,o;const i=e[s];return i==='"'||i==="'"?(n=s+1,o=e.indexOf(i,n),o===-1&&(o=e.indexOf(";",n),o===-1&&(o=e.length))):(o=e.indexOf(";",n),o===-1&&(o=e.length)),n>=o?void 0:e.substring(n,o).trim()||void 0},"parseContentDispositionValue"),I=f(a=>{const t=c(a,"content-disposition",!0);return P(t)},"parseContentDisposition"),R=f(a=>{const t=c(a,"x-chunked-upload",!0)==="true",e=c(a,"x-chunk-offset",!0),r=c(a,"x-total-size",!0),s={isChunkedUpload:t};if(e){const n=Number.parseInt(e,10);!Number.isNaN(n)&&n>=0&&(s.chunkOffset=n)}if(r){const n=Number.parseInt(r,10);!Number.isNaN(n)&&n>0&&(s.totalSize=n)}return s},"parseChunkHeaders"),Z=f((a,t=!1)=>{const e=c(a,"x-chunked-upload",!0)==="true";if(!(t&&e)){if(!X(a))throw u(400,"Request body is required");if(Number.parseInt(c(a,"content-length")||"0",10)===0&&!e)throw u(400,"Content-Length is required and must be greater than 0")}},"validateRequestBody"),ee=f((a,t=!1,e)=>{const r=c(a,"x-chunked-upload",!0)==="true",s=Number.parseInt(c(a,"content-length")||"0",10);if(!t&&!r&&s===0)throw u(400,"Content-Length is required and must be greater than 0");if(e!==void 0&&s>e)throw u(413,`File size exceeds maximum allowed size of ${e} bytes`);return s},"validateContentLength"),te=f((a,t,e="application/octet-stream")=>{const r=I(a),s=D(a),{isChunkedUpload:n,totalSize:o}=R(a),i=n&&o?o:t;return n&&o&&(s._chunkedUpload=!0,s._chunks=[],s._totalSize=o),{contentType:e,metadata:s,originalName:r,size:i}},"extractFileInit");f((a,t,e)=>{if(Number.isNaN(a)||a<0)throw u(400,"X-Chunk-Offset must be a valid non-negative number");if(a+t>e)throw u(400,`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk");f((a,t="application/octet-stream")=>c(a,"content-type")||t,"getContentType");var W=Object.defineProperty,g=y((a,t)=>W(a,"name",{value:t,configurable:!0}),"a");const N=g((a,t)=>{if(a.length===0)return!1;const e=[...a].toSorted((n,o)=>n.offset-o.offset),r=e[0];if(r?.offset!==0)return!1;let s=r.length;for(let n=1;n<e.length;n+=1){const o=e[n];if(o){if(o.offset>s)return!1;s=Math.max(s,o.offset+o.length)}}return s>=t},"isUploadComplete"),H=g((a,t,e,r)=>{if(Number.isNaN(a)||a<0)throw new Error("Chunk offset must be a valid non-negative number");if(t<=0)throw new Error("Chunk length must be greater than 0");if(r!==void 0&&t>r)throw new Error(`Chunk size exceeds maximum allowed size of ${r} bytes`);if(a+t>e)throw new Error(`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk"),B=g((a,t)=>{const e=a.find(r=>r.offset===t.offset&&r.length===t.length);return e?t.checksum&&e.checksum!==t.checksum?a.map(r=>r.offset===t.offset?{...r,checksum:t.checksum}:r):a:[...a,t]},"trackChunk"),j=g((a,t)=>{if(a.length===0||t===0)return{bytesWritten:0,percentage:0};const e=[...a].toSorted((o,i)=>o.offset-i.offset);let r=0,s=0;for(const o of e){const i=o.offset+o.length;o.offset<=s?r=Math.max(r,i):r+=o.length,s=Math.max(s,i)}r=Math.min(r,t);const n=t>0?r/t*100:0;return{bytesWritten:r,percentage:n}},"calculateUploadProgress");g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&Array.isArray(t._chunks)){const e=typeof t._totalSize=="number"?t._totalSize:a.size||0;return j(t._chunks,e).bytesWritten}return a.bytesWritten||0},"getBytesWritten");const _=g(a=>(a.metadata||{})._chunkedUpload===!0,"isChunkedUpload"),U=g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&typeof t._totalSize=="number")return t._totalSize},"getTotalSize");var q=Object.defineProperty,$=y((a,t)=>q(a,"name",{value:t,configurable:!0}),"y");class ae{static{y(this,"M")}static{$(this,"RestBase")}async deleteSingle(t){const e=await this.storage.delete({id:t});if(e.status===void 0)throw u(404,"File not found");return{...e,headers:{},statusCode:204}}async handlePost(t,e,r,s,n){if(e&&t.size!==void 0){const d=typeof t.size=="number"?t.size:Number.parseInt(String(t.size),10);if(d>0&&d>this.storage.maxUploadSize)throw u(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`)}const o=await this.storage.create(t);if(e){const d=this.buildFileUrl(r,o);return b(o,{...z(o,d),"X-Chunked-Upload":"true","X-Upload-ID":o.id},201)}const i=await this.storage.write({body:s,contentLength:n,id:o.id,start:0}),h=this.buildFileUrl(r,i);return b(i,z(i,h),201)}async handlePut(t,e,r,s,n,o){let i,h=!1;try{await this.storage.getMeta(t),h=!0,o&&await this.storage.update({id:t},{metadata:o}),i=await this.storage.write({body:s,contentLength:n,id:t,start:0})}catch(m){const S=m;if(S.UploadErrorCode===A.FILE_NOT_FOUND||S.code==="ENOENT")try{const w=await this.storage.create(e);i=await this.storage.write({body:s,contentLength:n,id:w.id,start:0})}catch(w){throw w}else throw m}const d=this.buildFileUrl(r,i);return b(i,z(i,d),h?200:201)}async handlePatch(t,e,r,s,n,o){let i=await this.storage.getMeta(t);const h=i.metadata||{},d=_(i);if(d){const l=U(i);l&&i.size!==l&&(i={...i,size:l})}const m=typeof h._totalSize=="number"?h._totalSize:i.size||0;if(!d)throw u(400,"File is not a chunked upload. Use POST or PUT for full file uploads.");const S=100*1024*1024;try{H(e,r,m,S)}catch(l){throw l instanceof Error&&l.message.includes("exceeds maximum")?u(413,l.message):u(400,l instanceof Error?l.message:String(l))}if(i.status==="completed"){const l=this.buildFileUrl(n,i);return b(i,{...z(i,l),"X-Upload-Complete":"true"},200)}const w=await this.storage.withLock(`chunks:${t}`,async()=>{const l=(await this.storage.getMeta(t)).metadata??{},M=Array.isArray(l._chunks)?l._chunks:[],x=B(M,{checksum:s,length:r,offset:e});return await this.storage.update({id:t},{metadata:{...l,_chunks:x}}),x});let p=await this.storage.write({body:o,contentLength:r,id:t,start:e}),C=p.bytesWritten>=m;d&&(C=N(w,m),p.status==="completed"&&!C&&(await this.storage.update({id:t},{status:"part"}),p={...p,status:"part"}));const k=C&&p.bytesWritten!==m?{...p,bytesWritten:m}:p,F=this.buildFileUrl(n,k),O={...z(k,F),...v(k,C),"x-upload-offset":String(k.bytesWritten||0)};return b(k,O,C?200:202)}async handleHead(t){let e=await this.storage.getMeta(t);const r=_(e);if(r){const n=U(e);n&&e.size!==n&&(e={...e,size:n})}const s={...L(e)};if(r){const n=e.metadata||{},o=U(e)||e.size||0,i=Array.isArray(n._chunks)?n._chunks:[],h=N(i,o);Object.assign(s,v(e,h))}return b(e,s,200)}handleOptions(t,e){return{headers:{"Access-Control-Allow-Headers":"Authorization, Content-Type, Content-Length, Content-Disposition, X-File-Metadata, X-Chunked-Upload, X-Total-Size, X-Chunk-Offset, X-Chunk-Checksum","Access-Control-Allow-Methods":t.map(r=>r.toUpperCase()).join(", "),"Access-Control-Max-Age":86400,"X-Max-Upload-Size":String(e)},statusCode:204}}async deleteBatch(t){const e=await this.storage.deleteBatch(t);if(e.successfulCount===0&&e.failedCount>0){const r=e.failed.map(s=>s.id).join(", ");throw u(404,`Failed to delete files: ${r}`)}return{data:e.successful,headers:e.failedCount>0?{"X-Delete-Errors":JSON.stringify(e.failed),"X-Delete-Failed":String(e.failedCount),"X-Delete-Successful":String(e.successfulCount)}:{"X-Delete-Successful":String(e.successfulCount)},statusCode:e.successfulCount===t.length?204:207}}get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,e){throw new Error("buildFileUrl must be implemented")}}export{ae as M,ee as a,R as b,P as c,te as e,I as p,Z as v};
1
+ var E=Object.defineProperty;var y=(a,t)=>E(a,"name",{value:t,configurable:!0});import{n as u}from"./headers-DC2MEOrK.js";import{hasBody as X}from"type-is";import{a as c}from"./base-handler-core-ty4J6Ji6.js";import{ERRORS as A}from"./ERRORS-vMSqlI69.js";import{b,a as z,c as v,d as L}from"./response-builder-Wdo_fvcF.js";var T=Object.defineProperty,f=y((a,t)=>T(a,"name",{value:t,configurable:!0}),"a$1");const D=f((a,t={})=>{const e=c(a,"x-file-metadata",!0);if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}},"parseMetadata"),P=f(a=>{if(!a)return;const t=2e3,e=a.length>t?a.slice(0,Math.max(0,t)):a,r=e.toLowerCase().indexOf("filename");if(r===-1)return;let s=r+8;for(;s<e.length&&(e[s]==="*"||e[s]===" "||e[s]===" ");)s++;if(s>=e.length||e[s]!=="=")return;for(s++;s<e.length&&(e[s]===" "||e[s]===" ");)s++;if(s>=e.length)return;let n=s,o;const i=e[s];return i==='"'||i==="'"?(n=s+1,o=e.indexOf(i,n),o===-1&&(o=e.indexOf(";",n),o===-1&&(o=e.length))):(o=e.indexOf(";",n),o===-1&&(o=e.length)),n>=o?void 0:e.substring(n,o).trim()||void 0},"parseContentDispositionValue"),I=f(a=>{const t=c(a,"content-disposition",!0);return P(t)},"parseContentDisposition"),R=f(a=>{const t=c(a,"x-chunked-upload",!0)==="true",e=c(a,"x-chunk-offset",!0),r=c(a,"x-total-size",!0),s={isChunkedUpload:t};if(e){const n=Number.parseInt(e,10);!Number.isNaN(n)&&n>=0&&(s.chunkOffset=n)}if(r){const n=Number.parseInt(r,10);!Number.isNaN(n)&&n>0&&(s.totalSize=n)}return s},"parseChunkHeaders"),Z=f((a,t=!1)=>{const e=c(a,"x-chunked-upload",!0)==="true";if(!(t&&e)){if(!X(a))throw u(400,"Request body is required");if(Number.parseInt(c(a,"content-length")||"0",10)===0&&!e)throw u(400,"Content-Length is required and must be greater than 0")}},"validateRequestBody"),ee=f((a,t=!1,e)=>{const r=c(a,"x-chunked-upload",!0)==="true",s=Number.parseInt(c(a,"content-length")||"0",10);if(!t&&!r&&s===0)throw u(400,"Content-Length is required and must be greater than 0");if(e!==void 0&&s>e)throw u(413,`File size exceeds maximum allowed size of ${e} bytes`);return s},"validateContentLength"),te=f((a,t,e="application/octet-stream")=>{const r=I(a),s=D(a),{isChunkedUpload:n,totalSize:o}=R(a),i=n&&o?o:t;return n&&o&&(s._chunkedUpload=!0,s._chunks=[],s._totalSize=o),{contentType:e,metadata:s,originalName:r,size:i}},"extractFileInit");f((a,t,e)=>{if(Number.isNaN(a)||a<0)throw u(400,"X-Chunk-Offset must be a valid non-negative number");if(a+t>e)throw u(400,`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk");f((a,t="application/octet-stream")=>c(a,"content-type")||t,"getContentType");var W=Object.defineProperty,g=y((a,t)=>W(a,"name",{value:t,configurable:!0}),"a");const N=g((a,t)=>{if(a.length===0)return!1;const e=[...a].toSorted((n,o)=>n.offset-o.offset),r=e[0];if(r?.offset!==0)return!1;let s=r.length;for(let n=1;n<e.length;n+=1){const o=e[n];if(o){if(o.offset>s)return!1;s=Math.max(s,o.offset+o.length)}}return s>=t},"isUploadComplete"),H=g((a,t,e,r)=>{if(Number.isNaN(a)||a<0)throw new Error("Chunk offset must be a valid non-negative number");if(t<=0)throw new Error("Chunk length must be greater than 0");if(r!==void 0&&t>r)throw new Error(`Chunk size exceeds maximum allowed size of ${r} bytes`);if(a+t>e)throw new Error(`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk"),B=g((a,t)=>{const e=a.find(r=>r.offset===t.offset&&r.length===t.length);return e?t.checksum&&e.checksum!==t.checksum?a.map(r=>r.offset===t.offset?{...r,checksum:t.checksum}:r):a:[...a,t]},"trackChunk"),j=g((a,t)=>{if(a.length===0||t===0)return{bytesWritten:0,percentage:0};const e=[...a].toSorted((o,i)=>o.offset-i.offset);let r=0,s=0;for(const o of e){const i=o.offset+o.length;o.offset<=s?r=Math.max(r,i):r+=o.length,s=Math.max(s,i)}r=Math.min(r,t);const n=t>0?r/t*100:0;return{bytesWritten:r,percentage:n}},"calculateUploadProgress");g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&Array.isArray(t._chunks)){const e=typeof t._totalSize=="number"?t._totalSize:a.size||0;return j(t._chunks,e).bytesWritten}return a.bytesWritten||0},"getBytesWritten");const _=g(a=>(a.metadata||{})._chunkedUpload===!0,"isChunkedUpload"),U=g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&typeof t._totalSize=="number")return t._totalSize},"getTotalSize");var q=Object.defineProperty,$=y((a,t)=>q(a,"name",{value:t,configurable:!0}),"y");class ae{static{y(this,"M")}static{$(this,"RestBase")}async deleteSingle(t){const e=await this.storage.delete({id:t});if(e.status===void 0)throw u(404,"File not found");return{...e,headers:{},statusCode:204}}async handlePost(t,e,r,s,n){if(e&&t.size!==void 0){const d=typeof t.size=="number"?t.size:Number.parseInt(String(t.size),10);if(d>0&&d>this.storage.maxUploadSize)throw u(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`)}const o=await this.storage.create(t);if(e){const d=this.buildFileUrl(r,o);return b(o,{...z(o,d),"X-Chunked-Upload":"true","X-Upload-ID":o.id},201)}const i=await this.storage.write({body:s,contentLength:n,id:o.id,start:0}),h=this.buildFileUrl(r,i);return b(i,z(i,h),201)}async handlePut(t,e,r,s,n,o){let i,h=!1;try{await this.storage.getMeta(t),h=!0,o&&await this.storage.update({id:t},{metadata:o}),i=await this.storage.write({body:s,contentLength:n,id:t,start:0})}catch(m){const S=m;if(S.UploadErrorCode===A.FILE_NOT_FOUND||S.code==="ENOENT")try{const w=await this.storage.create(e);i=await this.storage.write({body:s,contentLength:n,id:w.id,start:0})}catch(w){throw w}else throw m}const d=this.buildFileUrl(r,i);return b(i,z(i,d),h?200:201)}async handlePatch(t,e,r,s,n,o){let i=await this.storage.getMeta(t);const h=i.metadata||{},d=_(i);if(d){const l=U(i);l&&i.size!==l&&(i={...i,size:l})}const m=typeof h._totalSize=="number"?h._totalSize:i.size||0;if(!d)throw u(400,"File is not a chunked upload. Use POST or PUT for full file uploads.");const S=100*1024*1024;try{H(e,r,m,S)}catch(l){throw l instanceof Error&&l.message.includes("exceeds maximum")?u(413,l.message):u(400,l instanceof Error?l.message:String(l))}if(i.status==="completed"){const l=this.buildFileUrl(n,i);return b(i,{...z(i,l),"X-Upload-Complete":"true"},200)}const w=await this.storage.withLock(`chunks:${t}`,async()=>{const l=(await this.storage.getMeta(t)).metadata??{},M=Array.isArray(l._chunks)?l._chunks:[],x=B(M,{checksum:s,length:r,offset:e});return await this.storage.update({id:t},{metadata:{...l,_chunks:x}}),x});let p=await this.storage.write({body:o,contentLength:r,id:t,start:e}),C=p.bytesWritten>=m;d&&(C=N(w,m),p.status==="completed"&&!C&&(await this.storage.update({id:t},{status:"part"}),p={...p,status:"part"}));const k=C&&p.bytesWritten!==m?{...p,bytesWritten:m}:p,F=this.buildFileUrl(n,k),O={...z(k,F),...v(k,C),"x-upload-offset":String(k.bytesWritten||0)};return b(k,O,C?200:202)}async handleHead(t){let e=await this.storage.getMeta(t);const r=_(e);if(r){const n=U(e);n&&e.size!==n&&(e={...e,size:n})}const s={...L(e)};if(r){const n=e.metadata||{},o=U(e)||e.size||0,i=Array.isArray(n._chunks)?n._chunks:[],h=N(i,o);Object.assign(s,v(e,h))}return b(e,s,200)}handleOptions(t,e){return{headers:{"Access-Control-Allow-Headers":"Authorization, Content-Type, Content-Length, Content-Disposition, X-File-Metadata, X-Chunked-Upload, X-Total-Size, X-Chunk-Offset, X-Chunk-Checksum","Access-Control-Allow-Methods":t.map(r=>r.toUpperCase()).join(", "),"Access-Control-Max-Age":86400,"X-Max-Upload-Size":String(e)},statusCode:204}}async deleteBatch(t){const e=await this.storage.deleteBatch(t);if(e.successfulCount===0&&e.failedCount>0){const r=e.failed.map(s=>s.id).join(", ");throw u(404,`Failed to delete files: ${r}`)}return{data:e.successful,headers:e.failedCount>0?{"X-Delete-Errors":JSON.stringify(e.failed),"X-Delete-Failed":String(e.failedCount),"X-Delete-Successful":String(e.successfulCount)}:{"X-Delete-Successful":String(e.successfulCount)},statusCode:e.successfulCount===t.length?204:207}}get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,e){throw new Error("buildFileUrl must be implemented")}}export{ae as M,ee as a,R as b,P as c,te as e,I as p,Z as v};
@@ -1 +1 @@
1
- var U=Object.defineProperty;var g=(l,t)=>U(l,"name",{value:t,configurable:!0});import{Readable as k}from"node:stream";import{z as C,B as T,$ as A,t as R}from"./storage-z0o24zmZ.js";import{d as x}from"./detect-file-type-5JhzC9RU.js";import{throwErrorCode as y,ERRORS as f}from"./ERRORS-vMSqlI69.js";import{createRetryWrapper as v}from"./isRetryableError-CBZ65V6T.js";import{v as P}from"./local-meta-storage-Bvl0Flac.js";import{u as I}from"./update-size-DANV7aa2.js";import{r as z}from"./part-match-D_NwyoF3.js";import{o as B}from"./has-content-Bx2p8Okx.js";import{o as E}from"./get-file-status-DLS18Zvd.js";var K=Object.defineProperty,N=g((l,t)=>K(l,"name",{value:t,configurable:!0}),"o$1");const L=N((l,t)=>{const i={};return Object.keys(l).forEach(e=>{i[e]=t(l[e])}),i},"mapValues");var $=Object.defineProperty,D=g((l,t)=>$(l,"name",{value:t,configurable:!0}),"t");const j=D(l=>l===Number(l)?l:(C(l)??0)/1e3,"toSeconds");var F=Object.defineProperty,b=g((l,t)=>F(l,"name",{value:t,configurable:!0}),"m");const W=5*1024*1024,_=16*1024*1024,q=b(l=>{if(l)return`bytes=${Math.max(0,l.start)}-${l.end===void 0?"":l.end}`},"buildRangeHeader");class S extends T{static{g(this,"S3BaseStorage")}static{b(this,"S3BaseStorage")}checksumTypes=["md5","crc32","crc32c","sha1","sha256"];supportsRange=!0;supportsDelimiter=!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 i={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:b(a=>{const s=a;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)?!0:s.retryable??!1},"shouldRetry"),...t.retryConfig};this.retry=v(i),this.resolvedRetryConfig=i;const{metaStorage:e,metaStorageConfig:r}=t;if(e)this.meta=e;else{const a={...t,...r,logger:this.logger};"directory"in a?(this.logger?.debug("Using local meta storage"),this.meta=new P(a)):this.meta=new P(a)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(a=>{this.logger?.error("Storage access check failed: %O",a)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,i){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const n=typeof t.ttl=="string"?R(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 a=this.getS3Api();let s;try{s=await this.runOperation(i,n=>a.createMultipartUpload({ACL:this.getAcl(),Bucket:this.bucket,ContentType:r.contentType,Key:r.name,Metadata:L({originalName:r.originalName,...r.metadata},o=>encodeURI(String(o)))},{signal:n}))}catch{return y(f.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):y(f.FILE_ERROR,"s3 create upload error")})}async write(t,i){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&&I(e,t.size),!z(t,e))return y(f.FILE_CONFLICT);if(this.config.clientDirectUpload)return this.buildPresigned(e);e.Parts??=await this.getParts(e),e.bytesWritten=e.Parts.map(a=>a.Size||0).reduce((a,s)=>a+s,0);const r=await this.lock(t.id);try{if(B(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return y(f.UNSUPPORTED_CHECKSUM_ALGORITHM);if(e.Parts.length===0&&(!e.contentType||e.contentType==="application/octet-stream"))try{const d=t.body instanceof k?t.body:k.fromWeb(t.body),{fileType:m,stream:w}=await x(d);m?.mime&&(e.contentType=m.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 a=e.Parts.length+1,s=this.getS3Api(),c=e.UploadId;if(!c)throw new Error("UploadId is required");const n=t.body,o=n instanceof Uint8Array,{ETag:u}=await this.runOperation(i,d=>s.uploadPart({Body:n,Bucket:this.bucket,ContentLength:t.contentLength||0,Key:e.name,PartNumber:a,UploadId:c,...t.checksumAlgorithm==="md5"?{ContentMD5:t.checksum}:{}},{signal:d}),{replayable:o}),p={ETag:u,PartNumber:a,Size:t.contentLength};e.Parts=[...e.Parts,p],e.bytesWritten+=t.contentLength||0}if(this.cache.set(e.id,e),e.status=E(e),e.status==="completed"){const[a]=await this.internalOnComplete(e);delete e.Parts,e.uri=a.Location,e.ETag=a.ETag}}finally{await this.unlock(t.id,r)}return e})}async delete({id:t},i){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.abortMultipartUpload(e,i),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,i,e){return this.instrumentOperation("copy",async()=>{S.assertSafeId(t),S.assertSafeId(i);const r=await this.getMeta(t),a=`${this.bucket}/${t}`,s=this.bucket,c=i,n=this.getS3Api();return await this.runOperation(e,o=>n.copyObject({Bucket:s,CopySource:a,Key:c,...e?.storageClass&&{StorageClass:e.storageClass}},{signal:o})),{...r,id:c,name:c}})}async move(t,i,e){return this.instrumentOperation("move",async()=>{await this.copy(t,i,e);const r=this.getS3Api();return await this.runOperation(e,a=>r.deleteObject({Bucket:this.bucket,Key:t},{signal:a})),await this.getMeta(i)})}async list(t=1e3,i){return this.instrumentOperation("list",async()=>{const e=this.getS3Api(),r=Math.min(t,1e3);let a={Bucket:this.bucket,MaxKeys:r};const s=[];let c=!0;for(;c&&s.length<t;)try{const n=await this.runOperation(i,o=>e.listObjectsV2(a,{signal:o}));for(const{Key:o,LastModified:u}of n?.Contents||[]){if(s.length>=t)break;o!==void 0&&s.push({id:o,...u&&{createdAt:u}})}c=n.IsTruncated||!1,c&&n.NextContinuationToken&&s.length<t&&(a={...a,ContinuationToken:n.NextContinuationToken,MaxKeys:Math.min(r,t-s.length)})}catch(n){const o=this.normalizeError(n instanceof Error?n:new Error(String(n)));throw await this.onError(o),n}return s},{limit:t})}async listDirectory(t){return this.instrumentOperation("listDirectory",async()=>{const i=this.getS3Api(),e=t?.limit??1e3,r=Math.min(e,1e3);let a={Bucket:this.bucket,Delimiter:t?.delimiter,MaxKeys:r,...t?.prefix!==void 0&&{Prefix:t.prefix}};const s=[],c=new Set;let n=!0;for(;n&&s.length<e;)try{const o=await this.runOperation(t,u=>i.listObjectsV2(a,{signal:u}));for(const{Prefix:u}of o?.CommonPrefixes||[])u!==void 0&&c.add(u);for(const{Key:u,LastModified:p}of o?.Contents||[]){if(s.length>=e)break;u!==void 0&&s.push({id:u,...p&&{createdAt:p}})}n=o.IsTruncated||!1,n&&o.NextContinuationToken&&s.length<e&&(a={...a,ContinuationToken:o.NextContinuationToken,MaxKeys:Math.min(r,e-s.length)})}catch(o){const u=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(u),o}return{files:s,prefixes:[...c]}},{limit:t?.limit??1e3})}async exists({id:t},i){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.getS3Api();return await this.runOperation(i,r=>e.headObject({Bucket:this.bucket,Key:t},{signal:r})),!0}catch{return!1}})}async get({id:t},i){return this.instrumentOperation("get",async()=>{const e=this.getS3Api(),r=q(i?.range),{Body:a,ContentLength:s,ContentType:c,ETag:n,Expires:o,LastModified:u,Metadata:p}=await this.runOperation(i,h=>e.getObject({Bucket:this.bucket,Key:t,...r!==void 0&&{Range:r}},{signal:h}));await this.checkIfExpired({expiredAt:o});const d=[];if(a)if(a instanceof k)for await(const h of a)d.push(h instanceof Uint8Array?h:new Uint8Array(h));else{const h=a.getReader();for(;;){const{done:M,value:O}=await h.read();if(M)break;d.push(O)}}const{originalName:m,...w}=p||{};return{content:Buffer.concat(d),contentType:c,ETag:n,expiredAt:o,id:t,metadata:w,modifiedAt:u,name:t,originalName:m||t,size:Number(s)}})}async buildPresigned(t){const i=t;if(i.Parts?.length||(i.Parts=await this.getParts(t)),i.bytesWritten=i.Parts.map(e=>e.Size||0).reduce((e,r)=>e+r,0),t.status=E(i),i.partsUrls?.length||(i.partsUrls=await this.getPartsPresignedUrls(t)),t.status==="completed"){const[e]=await this.internalOnComplete(t);return delete i.Parts,i.uri=e.Location,t}return t}async getPartsPresignedUrls(t){t.partSize??=this.partSize;const i=t.UploadId;if(!i)throw new Error("UploadId is required for getting presigned URLs");const e=Math.trunc(t.size/this.partSize)+1,r=[],a=Math.trunc(j(this.config.expiration?.maxAge||"6hrs")),s=this.getS3Api();for(let c=0;c<e;c++)r.push(s.getPresignedUrl({Bucket:this.bucket,expiresIn:a,Key:t.name,PartNumber:c+1,UploadId:i}));return Promise.all(r)}async getParts(t){const i=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const{Parts:r=[]}=await this.runOperation(void 0,a=>i.listParts({Bucket:this.bucket,Key:t.name,UploadId:e},{signal:a}));return r}completeMultipartUpload(t){const i=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const r=t.Parts?.map(({ETag:a,PartNumber:s})=>{if(!a||!s)throw new Error("ETag and PartNumber are required");return{ETag:a,PartNumber:s}})||[];return this.runOperation(void 0,a=>i.completeMultipartUpload({Bucket:this.bucket,Key:t.name,Parts:r,UploadId:e},{signal:a}))}async abortMultipartUpload(t,i){if(t.status!=="completed")try{const e=this.getS3Api(),r=t.UploadId;if(!r)return;await this.runOperation(i,a=>e.abortMultipartUpload({Bucket:this.bucket,Key:t.name,UploadId:r},{signal:a}))}catch(e){this.logger?.error("abortMultipartUploadError: ",e);const r=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(r)}}internalOnComplete=b(async t=>{const[i]=await Promise.all([this.completeMultipartUpload(t),this.deleteMeta(t.id)]);return[i,t]},"internalOnComplete")}export{S,q as b};
1
+ var U=Object.defineProperty;var g=(l,t)=>U(l,"name",{value:t,configurable:!0});import{Readable as k}from"node:stream";import{c as C,B as T,$ as A,t as R}from"./storage-CI88PmRw.js";import{d as x}from"./detect-file-type-DRWGvQW4.js";import{throwErrorCode as y,ERRORS as f}from"./ERRORS-vMSqlI69.js";import{createRetryWrapper as v}from"./isRetryableError-CBZ65V6T.js";import{v as P}from"./local-meta-storage-tayO1ARY.js";import{u as I}from"./update-size-DANV7aa2.js";import{r as z}from"./part-match-D_NwyoF3.js";import{o as B}from"./has-content-Bx2p8Okx.js";import{o as E}from"./get-file-status-DLS18Zvd.js";var K=Object.defineProperty,L=g((l,t)=>K(l,"name",{value:t,configurable:!0}),"o$1");const N=L((l,t)=>{const i={};return Object.keys(l).forEach(e=>{i[e]=t(l[e])}),i},"mapValues");var $=Object.defineProperty,D=g((l,t)=>$(l,"name",{value:t,configurable:!0}),"t");const j=D(l=>l===Number(l)?l:(C(l)??0)/1e3,"toSeconds");var F=Object.defineProperty,b=g((l,t)=>F(l,"name",{value:t,configurable:!0}),"m");const W=5*1024*1024,_=16*1024*1024,q=b(l=>{if(l)return`bytes=${Math.max(0,l.start)}-${l.end===void 0?"":l.end}`},"buildRangeHeader");class S extends T{static{g(this,"S3BaseStorage")}static{b(this,"S3BaseStorage")}checksumTypes=["md5","crc32","crc32c","sha1","sha256"];supportsRange=!0;supportsDelimiter=!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 i={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:b(a=>{const s=a;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)?!0:s.retryable??!1},"shouldRetry"),...t.retryConfig};this.retry=v(i),this.resolvedRetryConfig=i;const{metaStorage:e,metaStorageConfig:r}=t;if(e)this.meta=e;else{const a={...t,...r,logger:this.logger};"directory"in a?(this.logger?.debug("Using local meta storage"),this.meta=new P(a)):this.meta=new P(a)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(a=>{this.logger?.error("Storage access check failed: %O",a)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,i){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const n=typeof t.ttl=="string"?R(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 a=this.getS3Api();let s;try{s=await this.runOperation(i,n=>a.createMultipartUpload({ACL:this.getAcl(),Bucket:this.bucket,ContentType:r.contentType,Key:r.name,Metadata:N({originalName:r.originalName,...r.metadata},o=>encodeURI(String(o)))},{signal:n}))}catch{return y(f.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):y(f.FILE_ERROR,"s3 create upload error")})}async write(t,i){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&&I(e,t.size),!z(t,e))return y(f.FILE_CONFLICT);if(this.config.clientDirectUpload)return this.buildPresigned(e);e.Parts??=await this.getParts(e),e.bytesWritten=e.Parts.map(a=>a.Size||0).reduce((a,s)=>a+s,0);const r=await this.lock(t.id);try{if(B(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return y(f.UNSUPPORTED_CHECKSUM_ALGORITHM);if(e.Parts.length===0&&(!e.contentType||e.contentType==="application/octet-stream"))try{const h=t.body instanceof k?t.body:k.fromWeb(t.body),{fileType:m,stream:w}=await x(h);m?.mime&&(e.contentType=m.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 a=e.Parts.length+1,s=this.getS3Api(),c=e.UploadId;if(!c)throw new Error("UploadId is required");const n=t.body,o=n instanceof Uint8Array,{ETag:u}=await this.runOperation(i,h=>s.uploadPart({Body:n,Bucket:this.bucket,ContentLength:t.contentLength||0,Key:e.name,PartNumber:a,UploadId:c,...t.checksumAlgorithm==="md5"?{ContentMD5:t.checksum}:{}},{signal:h}),{replayable:o}),p={ETag:u,PartNumber:a,Size:t.contentLength};e.Parts=[...e.Parts,p],e.bytesWritten+=t.contentLength||0}if(this.cache.set(e.id,e),e.status=E(e),e.status==="completed"){const[a]=await this.internalOnComplete(e);delete e.Parts,e.uri=a.Location,e.ETag=a.ETag}}finally{await this.unlock(t.id,r)}return e})}async delete({id:t},i){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.abortMultipartUpload(e,i),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,i,e){return this.instrumentOperation("copy",async()=>{S.assertSafeId(t),S.assertSafeId(i);const r=await this.getMeta(t),a=`${this.bucket}/${t}`,s=this.bucket,c=i,n=this.getS3Api();return await this.runOperation(e,o=>n.copyObject({Bucket:s,CopySource:a,Key:c,...e?.storageClass&&{StorageClass:e.storageClass}},{signal:o})),{...r,id:c,name:c}})}async move(t,i,e){return this.instrumentOperation("move",async()=>{await this.copy(t,i,e);const r=this.getS3Api();return await this.runOperation(e,a=>r.deleteObject({Bucket:this.bucket,Key:t},{signal:a})),await this.getMeta(i)})}async list(t=1e3,i){return this.instrumentOperation("list",async()=>{const e=this.getS3Api(),r=Math.min(t,1e3);let a={Bucket:this.bucket,MaxKeys:r};const s=[];let c=!0;for(;c&&s.length<t;)try{const n=await this.runOperation(i,o=>e.listObjectsV2(a,{signal:o}));for(const{Key:o,LastModified:u}of n?.Contents||[]){if(s.length>=t)break;o!==void 0&&s.push({id:o,...u&&{createdAt:u}})}c=n.IsTruncated||!1,c&&n.NextContinuationToken&&s.length<t&&(a={...a,ContinuationToken:n.NextContinuationToken,MaxKeys:Math.min(r,t-s.length)})}catch(n){const o=this.normalizeError(n instanceof Error?n:new Error(String(n)));throw await this.onError(o),n}return s},{limit:t})}async listDirectory(t){return this.instrumentOperation("listDirectory",async()=>{const i=this.getS3Api(),e=t?.limit??1e3,r=Math.min(e,1e3);let a={Bucket:this.bucket,Delimiter:t?.delimiter,MaxKeys:r,...t?.prefix!==void 0&&{Prefix:t.prefix}};const s=[],c=new Set;let n=!0;for(;n&&s.length<e;)try{const o=await this.runOperation(t,u=>i.listObjectsV2(a,{signal:u}));for(const{Prefix:u}of o?.CommonPrefixes||[])u!==void 0&&c.add(u);for(const{Key:u,LastModified:p}of o?.Contents||[]){if(s.length>=e)break;u!==void 0&&s.push({id:u,...p&&{createdAt:p}})}n=o.IsTruncated||!1,n&&o.NextContinuationToken&&s.length<e&&(a={...a,ContinuationToken:o.NextContinuationToken,MaxKeys:Math.min(r,e-s.length)})}catch(o){const u=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(u),o}return{files:s,prefixes:[...c]}},{limit:t?.limit??1e3})}async exists({id:t},i){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.getS3Api();return await this.runOperation(i,r=>e.headObject({Bucket:this.bucket,Key:t},{signal:r})),!0}catch{return!1}})}async get({id:t},i){return this.instrumentOperation("get",async()=>{const e=this.getS3Api(),r=q(i?.range),{Body:a,ContentLength:s,ContentType:c,ETag:n,Expires:o,LastModified:u,Metadata:p}=await this.runOperation(i,d=>e.getObject({Bucket:this.bucket,Key:t,...r!==void 0&&{Range:r}},{signal:d}));await this.checkIfExpired({expiredAt:o});const h=[];if(a)if(a instanceof k)for await(const d of a)h.push(d instanceof Uint8Array?d:new Uint8Array(d));else{const d=a.getReader();try{for(;;){const{done:M,value:O}=await d.read();if(M)break;h.push(O)}}finally{d.releaseLock()}}const{originalName:m,...w}=p||{};return{content:Buffer.concat(h),contentType:c,ETag:n,expiredAt:o,id:t,metadata:w,modifiedAt:u,name:t,originalName:m||t,size:Number(s)}})}async buildPresigned(t){const i=t;if(i.Parts?.length||(i.Parts=await this.getParts(t)),i.bytesWritten=i.Parts.map(e=>e.Size||0).reduce((e,r)=>e+r,0),t.status=E(i),i.partsUrls?.length||(i.partsUrls=await this.getPartsPresignedUrls(t)),t.status==="completed"){const[e]=await this.internalOnComplete(t);return delete i.Parts,i.uri=e.Location,t}return t}async getPartsPresignedUrls(t){t.partSize??=this.partSize;const i=t.UploadId;if(!i)throw new Error("UploadId is required for getting presigned URLs");const e=Math.trunc(t.size/this.partSize)+1,r=[],a=Math.trunc(j(this.config.expiration?.maxAge||"6hrs")),s=this.getS3Api();for(let c=0;c<e;c++)r.push(s.getPresignedUrl({Bucket:this.bucket,expiresIn:a,Key:t.name,PartNumber:c+1,UploadId:i}));return Promise.all(r)}async getParts(t){const i=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const{Parts:r=[]}=await this.runOperation(void 0,a=>i.listParts({Bucket:this.bucket,Key:t.name,UploadId:e},{signal:a}));return r}completeMultipartUpload(t){const i=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const r=t.Parts?.map(({ETag:a,PartNumber:s})=>{if(!a||!s)throw new Error("ETag and PartNumber are required");return{ETag:a,PartNumber:s}})||[];return this.runOperation(void 0,a=>i.completeMultipartUpload({Bucket:this.bucket,Key:t.name,Parts:r,UploadId:e},{signal:a}))}async abortMultipartUpload(t,i){if(t.status!=="completed")try{const e=this.getS3Api(),r=t.UploadId;if(!r)return;await this.runOperation(i,a=>e.abortMultipartUpload({Bucket:this.bucket,Key:t.name,UploadId:r},{signal:a}))}catch(e){this.logger?.error("abortMultipartUploadError: ",e);const r=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(r)}}internalOnComplete=b(async t=>{const[i]=await Promise.all([this.completeMultipartUpload(t),this.deleteMeta(t.id)]);return[i,t]},"internalOnComplete")}export{S,q as b};
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'node:stream';
2
- import { F as File, M as MetaStorage, d as createRetryWrapper, R as RetryConfig, e as FileInit, B as BaseStorage, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn } from "./storage.d-D5UN5mRz.js";
2
+ import { F as File, M as MetaStorage, c as createRetryWrapper, R as RetryConfig, b as FileInit, B as BaseStorage, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn } from "./storage.d-C6HtvSoY.js";
3
3
  /**
4
4
  * Part interface for multipart uploads.
5
5
  */
@@ -0,0 +1 @@
1
+ var q=Object.defineProperty;var f=(t,e)=>q(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-B718mbm6.js";import te from"type-is";import re from"./NoOpMetrics-Dky06sf1.js";import{N as oe}from"./cache-qV_5Umeq.js";import{ErrorMap as N,throwErrorCode as v,ERRORS as E}from"./ERRORS-vMSqlI69.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=f((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}),"a");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$/,_={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"),R=C(t=>{switch(t){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},"fromBase"),z=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.units].findIndex(l=>l.short.toUpperCase()===a||l.long.toUpperCase()===a);if(i===-1)return Number.NaN;const u=R(r.base);return s*u**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:u,...l}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...e},n=R(r),m=Math.abs(t),d=e?.space??!0?" ":"",c=_[u],h=c.findIndex(M=>M.short===i);if(t===0){const M=h===-1?0:Math.min(h,c.length-1);return"0"+d+c[M][a?"long":"short"]}const g=h===-1?Math.min(Math.floor(Math.log(m)/Math.log(n)),c.length-1):h,O=c[g][a?"long":"short"],x=t/n**g,$=o<0?void 0:o;return new Intl.NumberFormat(s,{maximumFractionDigits:$,minimumFractionDigits:$,...l}).format(x)+d+O},"formatBytes");var Me=Object.defineProperty,Ne=f((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,u,l,n,m,d,c,h)=>{const g={d:o,h:s,m:a,mo:e,ms:u,s:i,w:r,y:t};return l!==void 0&&(g.future=l),n!==void 0&&(g.past=n),m!==void 0&&(g.decimal=m),d!==void 0&&(g.unitMap=d),c!==void 0&&(g.groupSeparator=c),h!==void 0&&(g.placeholderSeparator=h),g},"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=f((t,e)=>Pe(t,"name",{value:e,configurable:!0}),"o"),De=Object.defineProperty,Ue=Be((t,e)=>De(t,"name",{value:e,configurable:!0}),"o"),ze=Object.defineProperty,je=Ue((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 _e=Object.defineProperty,Re=f((t,e)=>_e(t,"name",{value:e,configurable:!0}),"w"),Fe=Object.defineProperty,Le=Re((t,e)=>Fe(t,"name",{value:e,configurable:!0}),"v"),Ve=Object.defineProperty,Ge=Le((t,e)=>Ve(t,"name",{value:e,configurable:!0}),"h");const j={d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},A=/[-/\\^$*+?.()|[\]{}]/g,k=new WeakMap,Ye=/^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/i,Ze=/^(?:(\d+):)?(?:(\d+):)?(\d+)$/,Ke=/^[+-]?\d+(?:\.\d+)?$/,We=/^[-+]/,He=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??"_",u=s.replaceAll(A,String.raw`\$&`),l=a.replaceAll(A,String.raw`\$&`),n=i.replaceAll(A,String.raw`\$&`),m=o.unitMap??F;let d=t.replaceAll(new RegExp(String.raw`(\d)[${n}${l}](\d)`,"g"),"$1$2");if(s!=="."&&(d=d.replace(u,".")),Ke.test(t)){const y=Number.parseFloat(d.trim());if(!Number.isNaN(y)){const p=m[r];if(p!==void 0)return y*j[p]}return}const c=Ye.exec(t);if(c&&(c[1]!==void 0||c[2]!==void 0||c[3]!==void 0)){const y=Number.parseInt(c[1]??"0",10),p=Number.parseInt(c[2]??"0",10),w=Number.parseInt(c[3]??"0",10);return y*36e5+p*6e4+w*1e3}const h=Ze.exec(t);if(h){let y=0,p=0;h[2]!==void 0?(y=Number.parseInt(h[1]??"0",10),p=Number.parseInt(h[2],10)):h[1]!==void 0&&(p=Number.parseInt(h[1],10));const w=Number.parseInt(h[3]??"0",10);return y*36e5+p*6e4+w*1e3}let g=k.get(m);if(g===void 0){const y=Object.keys(m).toSorted((p,w)=>w.length-p.length).map(p=>p.replaceAll(A,String.raw`\$&`)).join("|");g=new RegExp(String.raw`(-?\d*\.?\d+)\s*(${y})`,"gi"),k.set(m,g)}let O=0,x,$=!1,M=-1,B=0;for(g.lastIndex=0;(x=g.exec(d))!==null;){$||(M=x.index),$=!0;const y=x[1],p=x[2];if(!y||!p)continue;const w=y.trim(),K=w.startsWith("-")?-1:1,W=w.replace(We,""),D=Number.parseFloat(W),U=m[p.toLowerCase()];if(U===void 0)continue;const H=j[U];if(Number.isNaN(D))return;O+=K*D*H,B=g.lastIndex}const Y=d.slice(0,M).trim(),Z=d.slice(B).trim();if(!($&&(Y.length>0||Z.length>0))&&$)return O},"parseDuration");var qe=Object.defineProperty,Xe=f((t,e)=>qe(t,"name",{value:e,configurable:!0}),"n$1");let Je=class extends ae{static{f(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=f((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=He(t);if(e!==void 0)return e},"toMilliseconds");var tt=Object.defineProperty,rt=f((t,e)=>tt(t,"name",{value:e,configurable:!0}),"t");let ot=class extends Error{static{f(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=f((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{f(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 N?N[r]:N.UnknownError),a=it(s),{body:i,headers:u,message:l,statusCode:n}=a;throw new ot(r,n,i||l,u)}}}const St=S(t=>t.name==="ValidationError","isValidationError");var ct=Object.defineProperty,P=f((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=f((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"&&gt.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{f(this,"BaseStorage")}static{b(this,"BaseStorage")}onCreate;onUpdate;onComplete;onDelete;onError;isReady=!0;errorResponses={};cache;logger;metrics;genericConfig;maxMetadataSize;checksumTypes=[];supportsRange=!1;supportsMetadata=!0;supportsCacheControl=!1;supportsDelimiter=!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"?z(r.maxUploadSize):r.maxUploadSize,this.maxMetadataSize=typeof r.maxMetadataSize=="string"?z(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(l){if(l.size===void 0)return!0;const n=l.size;if(n==null)return!1;const m=typeof n=="number"?n:Number(n);if(Number.isNaN(m)||m<0)return!1;const d=typeof this.value=="number"?this.value:Number(this.value);return!Number.isNaN(d)&&m<=d},response:N.RequestEntityTooLarge,value:this.maxUploadSize},a={isValid(l){return!!te.is(l.contentType,this.value)},response:N.UnsupportedMediaType,value:r.allowMIME},i=r.fileNameValidation??ht,u={isValid(l){return i(l.name)},response:N.InvalidFileName};this.validation.add({filename:u,mime:a,size:s}),this.validation.add({...r.validation})}get raw(){}async getReadUrl(e,r){return v(E.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getReadUrl()`)}async getUploadUrl(e,r){return v(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))&&v(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),v(E.FILE_NOT_FOUND)}}async checkIfExpired(e){return ne(e)?(this.delete(e).catch(()=>{}),this.deleteMeta(e.id).catch(()=>{}),v(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,...u}of a)try{const l=await this.delete({id:i});o.items.push({...l,...u})}catch(l){this.logger?.warn(`Failed to delete file ${i} during purge: ${l instanceof Error?l.message:String(l)}`)}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 listDirectory(e){return v(E.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement listDirectory()`)}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,u=typeof i=="string"?T(i):i;u!==void 0&&(s.expiredAt=Date.now()+u),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=[],u=e.map(async m=>{try{return{file:await this.delete({id:m},r),id:m,success:!0}}catch(d){const c=d instanceof Error?d.message:"Delete failed";return this.metrics.increment("storage.operations.delete.error.count",1,{error:c,storage:s}),{error:c,id:m,success:!1}}}),l=await Promise.allSettled(u);for(const m of l)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:d})=>{try{return{file:await this.copy(d,n,m),id:n,success:!0}}catch(c){const h=c instanceof Error?c.message:"Copy failed";return this.metrics.increment("storage.operations.copy.error.count",1,{error:h,storage:o}),{error:h,id:n,success:!1}}}),u=await Promise.allSettled(i);for(const n of u)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 l=Date.now()-r;return this.metrics.timing("storage.operations.batch.copy.duration",l,{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(d){const c=d instanceof Error?d.message:"Move failed";return this.metrics.increment("storage.operations.move.error.count",1,{error:c,storage:o}),{error:c,id:n,success:!1}}}),u=await Promise.allSettled(i);for(const n of u)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 l=Date.now()-r;return this.metrics.timing("storage.operations.batch.move.duration",l,{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)?v(E.FILE_LOCKED):this.config.concurrency&&typeof this.config.concurrency=="number"&&this.config.concurrency<=r.length?v(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 u;i.length===1?[u]=i:i.length>1&&(u=AbortSignal.any(i));const l=typeof e?.timeout=="number"?e.timeout:this.genericConfig.defaultTimeout,n=typeof l=="number"&&l>0?l:void 0,m=a.shouldRetry;a.shouldRetry=c=>u?.aborted||c instanceof Error&&c.name==="AbortError"?!1:m?m(c):!1;const d=b(c=>{if(c instanceof Error&&c.name==="AbortError")return c;const h=c instanceof Error&&c.message?c.message:"The operation was aborted",g=new Error(h,{cause:c});return g.name="AbortError",g},"toAbortError");return ie(async()=>{if(u?.aborted)throw d(u.reason);let c,h;if(n===void 0)h=u;else{const g=new AbortController;c=setTimeout(()=>{g.abort(new DOMException(`The operation timed out after ${n}ms`,"TimeoutError"))},n),h=u?AbortSignal.any([u,g.signal]):g.signal}try{return await r(h)}catch(g){throw h?.aborted?d(g):g}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(),u=Date.now()-s;return this.metrics.timing(`storage.operations.${e}.duration`,u,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 u=Date.now()-s,l=i instanceof Error?i.message:"Unknown error";throw this.metrics.timing(`storage.operations.${e}.duration`,u,{...a,error:"true"}),this.metrics.increment(`storage.operations.${e}.error.count`,1,{...a,error:l}),i}}}export{z as $,G as B,It as a,ot as b,He as c,ht as d,St as i,T as t,ut as u};
@@ -1172,4 +1172,4 @@ declare abstract class BaseStorage<TFile extends File = File, TFileReturn extend
1172
1172
  */
1173
1173
  protected instrumentOperation<T>(operation: string, function_: () => Promise<T>, attributes?: Record<string, string | number>): Promise<T>;
1174
1174
  }
1175
- export { throwErrorCode as $, RangeChecksum as A, BaseStorage as B, RangeHasher as C, DiskStorageOptions as D, ERRORS as E, File as F, ResponseBody as G, HttpError as H, IncomingMessageWithBody as I, ResponseTuple as J, UploadResponse as K, LocalMetaStorageOptions as L, MetaStorage as M, ValidationError as N, OperationOptions as O, PurgeList as P, ValidatorConfig as Q, RetryConfig as R, defaultCloudStorageFileNameValidation as S, defaultFilesystemFileNameValidation as T, UploadFile as U, Validation as V, extractHttpStatus as W, isRetryableError as X, isUploadError as Y, mapStatusToErrorCode as Z, retry as _, FileReturn as a, wrapStorageError as a0, Cache as a1, UploadError as b, UploadEventType as c, createRetryWrapper as d, FileInit as e, FilePart as f, FileQuery as g, DiskStorageWithChecksumOptions as h, MetaStorageOptions as i, BaseStorageOptions as j, ResponseBodyType as k, ErrorResponses as l, Metrics as m, BatchOperationResponse as n, BatchOperationResult as o, ErrorMap as p, ExpirationOptions as q, Header as r, Headers as s, HttpErrorBody as t, Metadata as u, OnComplete as v, OnCreate as w, OnDelete as x, OnError as y, OnUpdate as z };
1175
+ export { throwErrorCode as $, RangeChecksum as A, BaseStorage as B, RangeHasher as C, DiskStorageOptions as D, ERRORS as E, File as F, ResponseBody as G, HttpError as H, IncomingMessageWithBody as I, ResponseTuple as J, UploadResponse as K, LocalMetaStorageOptions as L, MetaStorage as M, ValidationError as N, OperationOptions as O, PurgeList as P, ValidatorConfig as Q, RetryConfig as R, defaultCloudStorageFileNameValidation as S, defaultFilesystemFileNameValidation as T, UploadFile as U, Validation as V, extractHttpStatus as W, isRetryableError as X, isUploadError as Y, mapStatusToErrorCode as Z, retry as _, FileReturn as a, wrapStorageError as a0, Cache as a1, FileInit as b, createRetryWrapper as c, FilePart as d, FileQuery as e, UploadError as f, UploadEventType as g, DiskStorageWithChecksumOptions as h, MetaStorageOptions as i, BaseStorageOptions as j, ResponseBodyType as k, ErrorResponses as l, Metrics as m, BatchOperationResponse as n, BatchOperationResult as o, ErrorMap as p, ExpirationOptions as q, Header as r, Headers as s, HttpErrorBody as t, Metadata as u, OnComplete as v, OnCreate as w, OnDelete as x, OnError as y, OnUpdate as z };
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'node:events';
2
- import { U as UploadFile, k as ResponseBodyType, B as BaseStorage, l as ErrorResponses } from "./storage.d-D5UN5mRz.js";
2
+ import { U as UploadFile, k as ResponseBodyType, B as BaseStorage, l as ErrorResponses } from "./storage.d-C6HtvSoY.js";
3
3
  import 'node:stream';
4
- import { M as MediaTransformer } from "./media-transformer.d-B5cQJz30.js";
5
- import { U as UploadOptions } from "./types.d-CPUyyEj9.js";
4
+ import { M as MediaTransformer } from "./media-transformer.d-B9dfBdoV.js";
5
+ import { U as UploadOptions } from "./types.d-CmBrgo0d.js";
6
6
  import 'node:crypto';
7
7
  import 'node:http';
8
8
  import 'lru-cache';
@@ -1,4 +1,4 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions } from "./storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions } from "./storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
3
  import { Client } from '@microsoft/microsoft-graph-client';
4
4
  declare class OneDriveFile extends File {
@@ -2,8 +2,8 @@ import { EventEmitter } from 'node:events';
2
2
  import { IncomingMessage } from 'node:http';
3
3
  import { Readable } from 'node:stream';
4
4
  import { PaginationResult } from '@visulima/pagination';
5
- import { U as UploadFile, B as BaseStorage, b as UploadError, c as UploadEventType } from "./storage.d-D5UN5mRz.js";
6
- import { M as MediaTransformer } from "./media-transformer.d-B5cQJz30.js";
5
+ import { U as UploadFile, f as UploadError, g as UploadEventType, B as BaseStorage } from "./storage.d-C6HtvSoY.js";
6
+ import { M as MediaTransformer } from "./media-transformer.d-B9dfBdoV.js";
7
7
  type WebRequest = globalThis.Request;
8
8
  type WebResponse = globalThis.Response;
9
9
  interface BaseResponse {
@@ -1,4 +1,4 @@
1
- import { a1 as Cache, F as File, a as FileReturn, B as BaseStorage } from "./storage.d-D5UN5mRz.js";
1
+ import { a1 as Cache, F as File, a as FileReturn, B as BaseStorage } from "./storage.d-C6HtvSoY.js";
2
2
  import { Readable } from 'node:stream';
3
3
  /**
4
4
  * Base transformer configuration with common properties
@@ -717,4 +717,4 @@ interface AudioTransformerConfig extends BaseTransformerConfig {
717
717
  /** Maximum audio size to process (in bytes) */
718
718
  maxAudioSize?: number;
719
719
  }
720
- export { AudioTransformerConfig as A, BaseTransformer as B, CropOptions as C, AffineOptions as D, ExtractChannelOptions as E, DilateOptions as F, GreyscaleOptions as G, ErodeOptions as H, ImageTransformerConfig as I, JoinChannelOptions as J, ToColourspaceOptions as K, LinearOptions as L, MediaTransformerConfig as M, RemoveAlphaOptions as N, EnsureAlphaOptions as O, PipelineColourspaceOptions as P, TransformationStep as Q, ResizeOptions as R, SharpenOptions as S, TransformResult as T, MediaTransformQuery as U, VideoTransformerConfig as V, MediaTransformationStep as W, AudioTransformResult as a, AudioResampleOptions as b, AudioChannelMixOptions as c, AudioTransformOptions as d, AudioTransformationStep as e, VideoTransformResult as f, VideoResizeOptions as g, VideoCropOptions as h, VideoRotateOptions as i, VideoTransformOptions as j, VideoTransformationStep as k, MediaTransformResult as l, RotateOptions as m, ImageFormat as n, TransformOptions as o, BlurOptions as p, MedianOptions as q, CLAHEOptions as r, ConvolveOptions as s, ThresholdOptions as t, BooleanOptions as u, RecombineOptions as v, ModulateOptions as w, TintOptions as x, ColourspaceOptions as y, BandboolOptions as z };
720
+ export { AudioTransformerConfig as A, BaseTransformer as B, CropOptions as C, DilateOptions as D, ExtractChannelOptions as E, ToColourspaceOptions as F, GreyscaleOptions as G, RemoveAlphaOptions as H, ImageTransformerConfig as I, JoinChannelOptions as J, EnsureAlphaOptions as K, LinearOptions as L, MedianOptions as M, TransformationStep as N, MediaTransformerConfig as O, PipelineColourspaceOptions as P, MediaTransformResult as Q, ResizeOptions as R, SharpenOptions as S, TransformResult as T, MediaTransformQuery as U, VideoTransformerConfig as V, MediaTransformationStep as W, AudioTransformResult as a, AudioResampleOptions as b, AudioChannelMixOptions as c, AudioTransformOptions as d, AudioTransformationStep as e, VideoTransformResult as f, VideoResizeOptions as g, VideoCropOptions as h, VideoRotateOptions as i, VideoTransformOptions as j, VideoTransformationStep as k, RotateOptions as l, ImageFormat as m, TransformOptions as n, BlurOptions as o, CLAHEOptions as p, ConvolveOptions as q, ThresholdOptions as r, BooleanOptions as s, RecombineOptions as t, ModulateOptions as u, TintOptions as v, ColourspaceOptions as w, BandboolOptions as x, AffineOptions as y, ErodeOptions as z };
@@ -1,6 +1,6 @@
1
- import { F as File, i as MetaStorageOptions, j as BaseStorageOptions, L as LocalMetaStorageOptions, M as MetaStorage, H as HttpError, g as FileQuery, O as OperationOptions, e as FileInit } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, i as MetaStorageOptions, j as BaseStorageOptions, L as LocalMetaStorageOptions, M as MetaStorage, H as HttpError, e as FileQuery, O as OperationOptions, b as FileInit } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import { Readable } from 'node:stream';
3
- import { P as Part, S as S3CallOptions, a as S3ApiOperations, b as S3BaseStorage } from "../../packem_shared/s3-base-storage.d-ByfwKeid.js";
3
+ import { P as Part, S as S3CallOptions, a as S3ApiOperations, b as S3BaseStorage } from "../../packem_shared/s3-base-storage.d-CoYAf_hG.js";
4
4
  import { S3ClientConfig, ObjectCannedACL, S3Client } from '@aws-sdk/client-s3';
5
5
  import { ResponseMetadata } from '@aws-sdk/types';
6
6
  import 'node:crypto';
@@ -1 +1 @@
1
- import{default as t}from"../../packem_shared/S3File-BfmCOET4.js";import{default as r}from"../../packem_shared/S3MetaStorage-vcriiosn.js";import{default as S}from"../../packem_shared/S3Storage-Bc9eq5vJ.js";export{t as S3File,r as S3MetaStorage,S as S3Storage};
1
+ import{default as t}from"../../packem_shared/S3File-BfmCOET4.js";import{default as r}from"../../packem_shared/S3MetaStorage-vcriiosn.js";import{default as S}from"../../packem_shared/S3Storage-adY1XLfH.js";export{t as S3File,r as S3MetaStorage,S as S3Storage};
@@ -1,5 +1,5 @@
1
- import { P as Part, S as S3CallOptions, a as S3ApiOperations, b as S3BaseStorage } from "../../packem_shared/s3-base-storage.d-ByfwKeid.js";
2
- import { F as File, i as MetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, H as HttpError, g as FileQuery, O as OperationOptions, e as FileInit } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { P as Part, S as S3CallOptions, a as S3ApiOperations, b as S3BaseStorage } from "../../packem_shared/s3-base-storage.d-CoYAf_hG.js";
2
+ import { F as File, i as MetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, H as HttpError, e as FileQuery, O as OperationOptions, b as FileInit } from "../../packem_shared/storage.d-C6HtvSoY.js";
3
3
  import { Readable } from 'node:stream';
4
4
  import { AwsClient } from 'aws4fetch';
5
5
  import 'node:crypto';
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/AwsLightFile-BSqjc_rD.js";import{l as r}from"../../packem_shared/aws-light-meta-storage-CXIZfLXR.js";import{default as f}from"../../packem_shared/AwsLightStorage-6Z1ovz9R.js";export{a as AwsLightFile,r as AwsLightMetaStorage,f as AwsLightStorage};
1
+ import{default as a}from"../../packem_shared/AwsLightFile-BSqjc_rD.js";import{l as r}from"../../packem_shared/aws-light-meta-storage-CXIZfLXR.js";import{default as f}from"../../packem_shared/AwsLightStorage-CWBRVcn5.js";export{a as AwsLightFile,r as AwsLightMetaStorage,f as AwsLightStorage};
@@ -1,4 +1,4 @@
1
- import { F as File, i as MetaStorageOptions, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, R as RetryConfig, e as FileInit, O as OperationOptions, g as FileQuery, n as BatchOperationResponse, f as FilePart, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, i as MetaStorageOptions, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, R as RetryConfig, b as FileInit, O as OperationOptions, e as FileQuery, n as BatchOperationResponse, d as FilePart, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
3
  import { TokenCredential } from '@azure/core-auth';
4
4
  import { BlobServiceClient } from '@azure/storage-blob';
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/AzureFile-Dgj2Tef4.js";import{b as t}from"../../packem_shared/azure-meta-storage-B-D-tBVw.js";import{default as u}from"../../packem_shared/AzureStorage-CbAN4vPm.js";export{a as AzureFile,t as AzureSMetaStorage,u as AzureStorage};
1
+ import{default as a}from"../../packem_shared/AzureFile-Dgj2Tef4.js";import{b as t}from"../../packem_shared/azure-meta-storage-B-D-tBVw.js";import{default as u}from"../../packem_shared/AzureStorage-nhAojuEU.js";export{a as AzureFile,t as AzureSMetaStorage,u as AzureStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { BoxClient } from 'box-typescript-sdk-gen';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/BoxFile-Be0S4N1L.js";import{default as r}from"../../packem_shared/BoxMetaStorage-BGBPZWoL.js";import{default as x}from"../../packem_shared/BoxStorage-DitlyKVB.js";export{a as BoxFile,r as BoxMetaStorage,x as BoxStorage};
1
+ import{default as a}from"../../packem_shared/BoxFile-Be0S4N1L.js";import{default as r}from"../../packem_shared/BoxMetaStorage-XMZn5yvp.js";import{default as x}from"../../packem_shared/BoxStorage-C3--16du.js";export{a as BoxFile,r as BoxMetaStorage,x as BoxStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import { Readable } from 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import 'node:crypto';
5
5
  import 'node:http';
6
6
  import 'lru-cache';
@@ -1 +1 @@
1
- import{default as t}from"../../packem_shared/BunS3File-D-SRiyrm.js";import{default as r}from"../../packem_shared/BunS3MetaStorage-DAskpG_G.js";import{default as u}from"../../packem_shared/BunS3Storage-D1gxh5Tt.js";export{t as BunS3File,r as BunS3MetaStorage,u as BunS3Storage};
1
+ import{default as t}from"../../packem_shared/BunS3File-D-SRiyrm.js";import{default as r}from"../../packem_shared/BunS3MetaStorage-DomG8mVK.js";import{default as u}from"../../packem_shared/BunS3Storage-0oYNi2Os.js";export{t as BunS3File,r as BunS3MetaStorage,u as BunS3Storage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import * as BunnyStorageSDK from '@bunny.net/storage-sdk';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as t}from"../../packem_shared/BunnyFile-Dotl-lO9.js";import{default as r}from"../../packem_shared/BunnyMetaStorage-ByUvvuPc.js";import{default as n}from"../../packem_shared/BunnyStorage-r6DptjUt.js";export{t as BunnyFile,r as BunnyMetaStorage,n as BunnyStorage};
1
+ import{default as t}from"../../packem_shared/BunnyFile-Dotl-lO9.js";import{default as r}from"../../packem_shared/BunnyMetaStorage-luemw1pL.js";import{default as n}from"../../packem_shared/BunnyStorage-CIkpp1Rc.js";export{t as BunnyFile,r as BunnyMetaStorage,n as BunnyStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { v2 } from 'cloudinary';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/CloudinaryFile-B5-m33eS.js";import{default as t}from"../../packem_shared/CloudinaryMetaStorage-DsJyN0iQ.js";import{default as d}from"../../packem_shared/CloudinaryStorage-BR8CZhlL.js";export{r as CloudinaryFile,t as CloudinaryMetaStorage,d as CloudinaryStorage};
1
+ import{default as r}from"../../packem_shared/CloudinaryFile-B5-m33eS.js";import{default as t}from"../../packem_shared/CloudinaryMetaStorage-DpxjshXZ.js";import{default as d}from"../../packem_shared/CloudinaryStorage-9Y1Gq0gr.js";export{r as CloudinaryFile,t as CloudinaryMetaStorage,d as CloudinaryStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { Dropbox } from 'dropbox';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/DropboxFile-BGVG2kXM.js";import{default as t}from"../../packem_shared/DropboxMetaStorage-B7eY16fU.js";import{default as p}from"../../packem_shared/DropboxStorage-9-jj7H8C.js";export{e as DropboxFile,t as DropboxMetaStorage,p as DropboxStorage};
1
+ import{default as e}from"../../packem_shared/DropboxFile-BGVG2kXM.js";import{default as t}from"../../packem_shared/DropboxMetaStorage-h0eTJuk5.js";import{default as p}from"../../packem_shared/DropboxStorage-CuA9MkpH.js";export{e as DropboxFile,t as DropboxMetaStorage,p as DropboxStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import 'node:crypto';
5
5
  import 'node:http';
6
6
  import 'lru-cache';
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/FirebaseFile-JEu3plMP.js";import{default as o}from"../../packem_shared/FirebaseMetaStorage-BpYykWhG.js";import{default as s}from"../../packem_shared/FirebaseStorage-DB87abIF.js";export{r as FirebaseFile,o as FirebaseMetaStorage,s as FirebaseStorage};
1
+ import{default as r}from"../../packem_shared/FirebaseFile-JEu3plMP.js";import{default as o}from"../../packem_shared/FirebaseMetaStorage-CCBnEE8_.js";import{default as s}from"../../packem_shared/FirebaseStorage-DUskfjh_.js";export{r as FirebaseFile,o as FirebaseMetaStorage,s as FirebaseStorage};
@@ -1,6 +1,6 @@
1
- import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
- import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CobcjyWu.js";
3
+ import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DUuLtPik.js";
4
4
  import { AccessOptions } from 'basic-ftp';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/FtpFile-B8jaICTB.js";import{default as r}from"../../packem_shared/FtpMetaStorage-v2wXTwqX.js";import{default as p}from"../../packem_shared/FtpStorage-DdRf0Wg6.js";export{a as FtpFile,r as FtpMetaStorage,p as FtpStorage};
1
+ import{default as a}from"../../packem_shared/FtpFile-B8jaICTB.js";import{default as r}from"../../packem_shared/FtpMetaStorage-DxHcXk9x.js";import{default as p}from"../../packem_shared/FtpStorage-DMpDY7oG.js";export{a as FtpFile,r as FtpMetaStorage,p as FtpStorage};
@@ -1,4 +1,4 @@
1
- import { F as File, i as MetaStorageOptions, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, H as HttpError, e as FileInit, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-D5UN5mRz.js";
1
+ import { F as File, i as MetaStorageOptions, L as LocalMetaStorageOptions, j as BaseStorageOptions, M as MetaStorage, H as HttpError, b as FileInit, O as OperationOptions, d as FilePart, e as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C6HtvSoY.js";
2
2
  import 'node:stream';
3
3
  import { RetryConfig } from 'gaxios';
4
4
  import { GoogleAuthOptions, GoogleAuth } from 'google-auth-library';
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/GCSConfig-BQ0OpVhe.js";import{default as t}from"../../packem_shared/GCSFile-CDQ6IWAz.js";import{E as C}from"../../packem_shared/gcs-meta-storage-Dh0TAqB_.js";import{default as l}from"../../packem_shared/GCStorage-CRVpuZ5_.js";export{a as GCSConfig,t as GCSFile,C as GCSMetaStorage,l as GCStorage};
1
+ import{default as a}from"../../packem_shared/GCSConfig-BQ0OpVhe.js";import{default as t}from"../../packem_shared/GCSFile-CDQ6IWAz.js";import{E as C}from"../../packem_shared/gcs-meta-storage-BXcsC7xV.js";import{default as l}from"../../packem_shared/GCStorage-RCw58CoD.js";export{a as GCSConfig,t as GCSFile,C as GCSMetaStorage,l as GCStorage};