@visulima/storage 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE.md +130 -1
  3. package/dist/adapter/nuxt/module.d.ts +5 -5
  4. package/dist/adapter/nuxt/module.js +1 -1
  5. package/dist/ai/ai-sdk/index.d.ts +7 -7
  6. package/dist/ai/ai-sdk/index.js +1 -1
  7. package/dist/ai/claude/index.d.ts +5 -5
  8. package/dist/ai/claude/index.js +1 -1
  9. package/dist/ai/openai/index.d.ts +13 -5
  10. package/dist/ai/openai/index.js +1 -1
  11. package/dist/ai/tanstack/index.d.ts +6 -6
  12. package/dist/ai/tanstack/index.js +1 -1
  13. package/dist/handler/http/fetch/index.d.ts +8 -8
  14. package/dist/handler/http/fetch/index.js +1 -1
  15. package/dist/handler/http/hono/index.d.ts +7 -7
  16. package/dist/handler/http/hono/index.js +1 -1
  17. package/dist/handler/http/nextjs/index.d.ts +7 -7
  18. package/dist/handler/http/nextjs/index.js +1 -1
  19. package/dist/handler/http/node/index.d.ts +7 -7
  20. package/dist/handler/http/node/index.js +1 -1
  21. package/dist/handler/http/solid-start/index.d.ts +7 -7
  22. package/dist/handler/http/solid-start/index.js +1 -1
  23. package/dist/index.d.ts +8 -8
  24. package/dist/index.js +1 -1
  25. package/dist/openapi/index.js +1 -1
  26. package/dist/packem_shared/AbstractBaseStorage-CcIPoAES.js +1 -0
  27. package/dist/packem_shared/AwsLightFile-CqeZ6M7o.js +1 -0
  28. package/dist/packem_shared/AwsLightMetaStorage-Cb4xIpax.js +1 -0
  29. package/dist/packem_shared/AwsLightStorage-Bhg6C3fo.js +1 -0
  30. package/dist/packem_shared/AzureFile-DoUVXQMI.js +1 -0
  31. package/dist/packem_shared/AzureSMetaStorage-ByKDwgWo.js +1 -0
  32. package/dist/packem_shared/AzureStorage-BzYWVRnX.js +1 -0
  33. package/dist/packem_shared/BaseTransformer-ByIAKnn8.js +1 -0
  34. package/dist/packem_shared/BoxFile-CKKRYACc.js +1 -0
  35. package/dist/packem_shared/BoxMetaStorage-BI-G6aeO.js +1 -0
  36. package/dist/packem_shared/BoxStorage-Bmzt-OTx.js +1 -0
  37. package/dist/packem_shared/BunS3File-B2rczbY_.js +1 -0
  38. package/dist/packem_shared/BunS3MetaStorage-BI-G6aeO.js +1 -0
  39. package/dist/packem_shared/{BunS3Storage-B_roVJ29.js → BunS3Storage-uJ-u5wpg.js} +1 -1
  40. package/dist/packem_shared/BunnyFile-CBJdpNcB.js +1 -0
  41. package/dist/packem_shared/BunnyMetaStorage-BI-G6aeO.js +1 -0
  42. package/dist/packem_shared/BunnyStorage-9fw8VeuO.js +1 -0
  43. package/dist/packem_shared/CloudinaryFile-Dl8cnbJo.js +1 -0
  44. package/dist/packem_shared/CloudinaryMetaStorage-CYWznm7F.js +1 -0
  45. package/dist/packem_shared/CloudinaryStorage-CRVFUrEK.js +1 -0
  46. package/dist/packem_shared/DiskStorage-Wm6PC8Rc.js +1 -0
  47. package/dist/packem_shared/DiskStorageWithChecksum-CyhRDK5M.js +1 -0
  48. package/dist/packem_shared/DropboxFile-BUSubTWW.js +1 -0
  49. package/dist/packem_shared/DropboxMetaStorage-BYbJBJXr.js +1 -0
  50. package/dist/packem_shared/DropboxStorage-ZfgP7IMo.js +1 -0
  51. package/dist/packem_shared/{ERRORS-BIBxE2oR.js → ERRORS-olUcTqo2.js} +1 -1
  52. package/dist/packem_shared/File-DLAa0hBv.js +1 -0
  53. package/dist/packem_shared/Files-NF7wRh5C.js +1 -0
  54. package/dist/packem_shared/FirebaseFile-Dl8cnbJo.js +1 -0
  55. package/dist/packem_shared/FirebaseMetaStorage-DX1-58UY.js +1 -0
  56. package/dist/packem_shared/FirebaseStorage-D8NgHiZh.js +2 -0
  57. package/dist/packem_shared/FtpFile-H8EmE3S_.js +1 -0
  58. package/dist/packem_shared/FtpMetaStorage-BI-G6aeO.js +1 -0
  59. package/dist/packem_shared/FtpStorage-BjBdLfTV.js +1 -0
  60. package/dist/packem_shared/GCSFile-mFuZfcTW.js +1 -0
  61. package/dist/packem_shared/GCSMetaStorage-Dm8m-iJT.js +1 -0
  62. package/dist/packem_shared/GCStorage-BWV6QQqd.js +1 -0
  63. package/dist/packem_shared/GoogleDriveFile-fDYE1aaN.js +1 -0
  64. package/dist/packem_shared/GoogleDriveMetaStorage-CEleJNZZ.js +1 -0
  65. package/dist/packem_shared/{GoogleDriveStorage-Du7uBhSm.js → GoogleDriveStorage-CS9nWKP5.js} +1 -1
  66. package/dist/packem_shared/LocalMetaStorage-EnWCLyKq.js +1 -0
  67. package/dist/packem_shared/MediaTransformer-GqBUkOvz.js +1 -0
  68. package/dist/packem_shared/MemoryMetaStorage-DdAIGIVO.js +1 -0
  69. package/dist/packem_shared/{MemoryStorage-ChKyI6OY.js → MemoryStorage-CJw7SAlG.js} +1 -1
  70. package/dist/packem_shared/Metadata-BeQVDFer.js +1 -0
  71. package/dist/packem_shared/{Multipart-V64Bg5dt.js → Multipart-C3ve9Z0D.js} +1 -1
  72. package/dist/packem_shared/Multipart-PlMON60C.js +1 -0
  73. package/dist/packem_shared/NetlifyBlobFile-Br5HPqlC.js +1 -0
  74. package/dist/packem_shared/NetlifyBlobMetaStorage-DD5mbms5.js +1 -0
  75. package/dist/packem_shared/NetlifyBlobStorage-DVpJgN3v.js +1 -0
  76. package/dist/packem_shared/NoOpMetrics-CWqe9gwp.js +1 -0
  77. package/dist/packem_shared/OneDriveFile-Ccv5bkno.js +1 -0
  78. package/dist/packem_shared/OneDriveMetaStorage-D0GzJ0FC.js +1 -0
  79. package/dist/packem_shared/OneDriveStorage-CTYdWnnf.js +1 -0
  80. package/dist/packem_shared/OpenTelemetryMetrics-opDTaCRp.js +1 -0
  81. package/dist/packem_shared/PocketBaseFile-Dl8cnbJo.js +1 -0
  82. package/dist/packem_shared/PocketBaseMetaStorage-DgKNhi2j.js +1 -0
  83. package/dist/packem_shared/PocketBaseStorage-CHQVk7lR.js +1 -0
  84. package/dist/packem_shared/Rest-DQRxx8yQ.js +1 -0
  85. package/dist/packem_shared/Rest-DYXzbF-Q.js +1 -0
  86. package/dist/packem_shared/S3File-CyL0Q6Nx.js +1 -0
  87. package/dist/packem_shared/S3MetaStorage-DszTVQMa.js +1 -0
  88. package/dist/packem_shared/S3Storage-Bdns7a3N.js +1 -0
  89. package/dist/packem_shared/SftpFile-H8EmE3S_.js +1 -0
  90. package/dist/packem_shared/SftpMetaStorage-BI-G6aeO.js +1 -0
  91. package/dist/packem_shared/SftpStorage-D08to8f6.js +1 -0
  92. package/dist/packem_shared/SharePointFile-BWfd3Rel.js +1 -0
  93. package/dist/packem_shared/SharePointMetaStorage-BI-G6aeO.js +1 -0
  94. package/dist/packem_shared/{SharePointStorage-Dtnt5-wk.js → SharePointStorage-PtgEmyCY.js} +1 -1
  95. package/dist/packem_shared/SupabaseFile-CI0eFAyo.js +1 -0
  96. package/dist/packem_shared/SupabaseMetaStorage-CRw0xTXk.js +1 -0
  97. package/dist/packem_shared/SupabaseStorage-DJe4YZJD.js +1 -0
  98. package/dist/packem_shared/TUS_RESUMABLE-Dsxqcx-u.js +1 -0
  99. package/dist/packem_shared/{Tus-CJBgnJrn.js → Tus-C800fRBi.js} +1 -1
  100. package/dist/packem_shared/Tus-Vttn79I2.js +1 -0
  101. package/dist/packem_shared/UploadThingFile-DP4kNmpS.js +1 -0
  102. package/dist/packem_shared/UploadThingMetaStorage-CYWznm7F.js +1 -0
  103. package/dist/packem_shared/UploadThingStorage-S3iYzJ8Z.js +1 -0
  104. package/dist/packem_shared/ValidationError-SzFFFHiN.js +1 -0
  105. package/dist/packem_shared/VercelBlobFile-Censq2sD.js +1 -0
  106. package/dist/packem_shared/VercelBlobMetaStorage-DgKNhi2j.js +1 -0
  107. package/dist/packem_shared/VercelBlobStorage-D1eytZwU.js +1 -0
  108. package/dist/packem_shared/_commonjsHelpers-CqkleIqs.js +1 -0
  109. package/dist/packem_shared/agentsCopyFile-BMTcfVHg.js +1 -0
  110. package/dist/packem_shared/akamai-BPAk4688.js +1 -0
  111. package/dist/packem_shared/alibaba-CPhhkaQs.js +1 -0
  112. package/dist/packem_shared/approval-DcuhtQKs.js +1 -0
  113. package/dist/packem_shared/aws-light-meta-storage-CgGLgB8g.js +4 -0
  114. package/dist/packem_shared/azure-meta-storage-DmBO5MmP.js +1 -0
  115. package/dist/packem_shared/backblaze-CjeWkpeg.js +1 -0
  116. package/dist/packem_shared/base-handler-core-BvNgdV-9.js +1 -0
  117. package/dist/packem_shared/base-handler-fetch-DDSPIzWT.js +1 -0
  118. package/dist/packem_shared/base-handler-node-C83nCFpv.js +1 -0
  119. package/dist/packem_shared/claudeCopyFile-CMKFZHFh.js +1 -0
  120. package/dist/packem_shared/cloudflare-CijqmNaq.js +1 -0
  121. package/dist/packem_shared/copyFile-B7PNh9O7.js +1 -0
  122. package/dist/packem_shared/copyFile-Q5eYZIU5.js +1 -0
  123. package/dist/packem_shared/createResponsesFileTools-SU-K9JG4.js +1 -0
  124. package/dist/packem_shared/createRetryWrapper-BM8PL0cI.js +1 -0
  125. package/dist/packem_shared/detect-file-type-go3r-MOD.js +1 -0
  126. package/dist/packem_shared/digitalOcean-BE_d_CcF.js +1 -0
  127. package/dist/packem_shared/disk-storage-DEOi12bM.js +1 -0
  128. package/dist/packem_shared/{executors-BDzMjc4y.js → executors-DgKT6b1T.js} +1 -1
  129. package/dist/packem_shared/{executors.d-B9dIy3NT.d.ts → executors.d-HWHR3Ids.d.ts} +1 -6
  130. package/dist/packem_shared/exoscale-BzXbsZ3A.js +1 -0
  131. package/dist/packem_shared/{filebase-CsFYJIwB.js → filebase-pfolz904.js} +1 -1
  132. package/dist/packem_shared/{files.d-CmSZi3M0.d.ts → files.d-DuIceNg2.d.ts} +1 -1
  133. package/dist/packem_shared/gcs-meta-storage-A5uvIda3.js +1 -0
  134. package/dist/packem_shared/{get-file-status-y3wTtDQs.js → get-file-status-B8WmWzcM.js} +1 -1
  135. package/dist/packem_shared/getFormatFromContentType-BAVdaQ0o.js +1 -0
  136. package/dist/packem_shared/has-content-96mmyLn2.js +1 -0
  137. package/dist/packem_shared/headers-erjZrwbT.js +26 -0
  138. package/dist/packem_shared/hetzner-CaLW6ANw.js +1 -0
  139. package/dist/packem_shared/{ibmCos-j-3TfJ5p.js → ibmCos-Dbcs7XEJ.js} +1 -1
  140. package/dist/packem_shared/idriveE2-BiiGl7tr.js +1 -0
  141. package/dist/packem_shared/index-DKzU1HON.js +5 -0
  142. package/dist/packem_shared/internal-Zb__DDsV.js +1 -0
  143. package/dist/packem_shared/is-expired-CZlgTFFz.js +1 -0
  144. package/dist/packem_shared/local-meta-storage-Ca6WrUmN.js +1 -0
  145. package/dist/packem_shared/{local-meta-storage.d-cRTXr1kb.d.ts → local-meta-storage.d-CYWYyCUo.d.ts} +1 -2
  146. package/dist/packem_shared/{media-transformer.d-C8tn4J2Z.d.ts → media-transformer.d-Co37isNg.d.ts} +2 -2
  147. package/dist/packem_shared/minio-CC_RGR-q.js +1 -0
  148. package/dist/packem_shared/multipart-base-0AXqLN-B.js +1 -0
  149. package/dist/packem_shared/oauth-refresh-Cf1z47zf.js +1 -0
  150. package/dist/packem_shared/{oracleCloud-DslqNpn6.js → oracleCloud-eAWm6voZ.js} +1 -1
  151. package/dist/packem_shared/{ovhCloud-CMHE6uLV.js → ovhCloud-D00DprwO.js} +1 -1
  152. package/dist/packem_shared/part-match-Cb6xL9eN.js +1 -0
  153. package/dist/packem_shared/path-CxEa27Rz-DSh0_A5o.js +1 -0
  154. package/dist/packem_shared/posix-dirname-CSjB98Q5.js +1 -0
  155. package/dist/packem_shared/response-builder-tJ84C7n4.js +1 -0
  156. package/dist/packem_shared/rest-base-CzhSrUnH.js +1 -0
  157. package/dist/packem_shared/{restOpenApiSpec-Csv513qf.js → restOpenApiSpec-BNBrZFuE.js} +1 -1
  158. package/dist/packem_shared/s3-base-storage-DuHVKzSw.js +1 -0
  159. package/dist/packem_shared/{s3-base-storage.d-ks99NSs-.d.ts → s3-base-storage.d-BmuspwCF.d.ts} +1 -1
  160. package/dist/packem_shared/scaleway-Dms2IqTd.js +1 -0
  161. package/dist/packem_shared/{sharedErrorSchemaObject-YN65aAKj.js → sharedErrorSchemaObject-GTCM7U0s.js} +1 -1
  162. package/dist/packem_shared/{storage-DR7qdwBN.js → storage-uypoNkqu.js} +1 -1
  163. package/dist/packem_shared/{storage.d-DwdJrArF.d.ts → storage.d-C9EdfTf1.d.ts} +1 -1
  164. package/dist/packem_shared/storj-DzEePQoh.js +1 -0
  165. package/dist/packem_shared/sync-ClnPrYjk.js +1 -0
  166. package/dist/packem_shared/tencent-7P8z8AwE.js +1 -0
  167. package/dist/packem_shared/tigris-DlNWhmsM.js +1 -0
  168. package/dist/packem_shared/{transformOpenApiSpec-CIEAgpBD.js → transformOpenApiSpec-Bcnw9LVy.js} +1 -1
  169. package/dist/packem_shared/{tus-base.d-BKBoJVy0.d.ts → tus-base.d-Dgnbivbj.d.ts} +3 -8
  170. package/dist/packem_shared/{tusOpenApiSpec-D96B03t5.js → tusOpenApiSpec-BU8nhLH2.js} +1 -1
  171. package/dist/packem_shared/{types.d-BEUv414z.d.ts → types.d-D1TIRqKW.d.ts} +1 -1
  172. package/dist/packem_shared/{types.d-D7Zlz5RE.d.ts → types.d-D6Jkz0Sp.d.ts} +2 -2
  173. package/dist/packem_shared/{types.d-B1_xZIhu.d.ts → types.d-ZrDWKyVi.d.ts} +1 -2
  174. package/dist/packem_shared/update-size-Dxc1hvbI.js +1 -0
  175. package/dist/packem_shared/vultr-Crvmg314.js +1 -0
  176. package/dist/packem_shared/waitForStorage-afkqWeuz.js +1 -0
  177. package/dist/packem_shared/wasabi-CyCMxoUT.js +1 -0
  178. package/dist/packem_shared/{xhrOpenApiSpec-DQR4h6M8.js → xhrOpenApiSpec-xDSkxm2d.js} +1 -1
  179. package/dist/packem_shared/yandex-D1HwCz7g.js +1 -0
  180. package/dist/storage/aws/clients/index.js +1 -1
  181. package/dist/storage/aws/index.d.ts +3 -3
  182. package/dist/storage/aws/index.js +1 -1
  183. package/dist/storage/aws-light/index.d.ts +2 -2
  184. package/dist/storage/aws-light/index.js +1 -1
  185. package/dist/storage/azure/index.d.ts +2 -2
  186. package/dist/storage/azure/index.js +1 -1
  187. package/dist/storage/box/index.d.ts +3 -3
  188. package/dist/storage/box/index.js +1 -1
  189. package/dist/storage/bun-s3/index.d.ts +2 -2
  190. package/dist/storage/bun-s3/index.js +1 -1
  191. package/dist/storage/bunny/index.d.ts +3 -3
  192. package/dist/storage/bunny/index.js +1 -1
  193. package/dist/storage/cloudinary/index.d.ts +3 -3
  194. package/dist/storage/cloudinary/index.js +1 -1
  195. package/dist/storage/dropbox/index.d.ts +3 -3
  196. package/dist/storage/dropbox/index.js +1 -1
  197. package/dist/storage/firebase/index.d.ts +2 -2
  198. package/dist/storage/firebase/index.js +1 -1
  199. package/dist/storage/ftp/index.d.ts +3 -3
  200. package/dist/storage/ftp/index.js +1 -1
  201. package/dist/storage/gcs/index.d.ts +2 -2
  202. package/dist/storage/gcs/index.js +1 -1
  203. package/dist/storage/google-drive/index.d.ts +3 -3
  204. package/dist/storage/google-drive/index.js +1 -1
  205. package/dist/storage/local/index.d.ts +148 -4
  206. package/dist/storage/local/index.js +1 -1
  207. package/dist/storage/memory/index.d.ts +93 -3
  208. package/dist/storage/memory/index.js +1 -1
  209. package/dist/storage/netlify-blob/index.d.ts +3 -3
  210. package/dist/storage/netlify-blob/index.js +1 -1
  211. package/dist/storage/onedrive/index.d.ts +4 -4
  212. package/dist/storage/onedrive/index.js +1 -1
  213. package/dist/storage/pocketbase/index.d.ts +2 -2
  214. package/dist/storage/pocketbase/index.js +1 -1
  215. package/dist/storage/sftp/index.d.ts +3 -3
  216. package/dist/storage/sftp/index.js +1 -1
  217. package/dist/storage/sharepoint/index.d.ts +3 -3
  218. package/dist/storage/sharepoint/index.js +1 -1
  219. package/dist/storage/supabase/index.d.ts +3 -3
  220. package/dist/storage/supabase/index.js +1 -1
  221. package/dist/storage/uploadthing/index.d.ts +2 -2
  222. package/dist/storage/uploadthing/index.js +1 -1
  223. package/dist/storage/vercel-blob/index.d.ts +3 -3
  224. package/dist/storage/vercel-blob/index.js +1 -1
  225. package/dist/transformer/audio-transformer.d.ts +2 -2
  226. package/dist/transformer/audio-transformer.js +1 -1
  227. package/dist/transformer/image-transformer.d.ts +2 -2
  228. package/dist/transformer/image-transformer.js +1 -1
  229. package/dist/transformer/index.d.ts +3 -3
  230. package/dist/transformer/index.js +1 -1
  231. package/dist/transformer/video-transformer.d.ts +2 -2
  232. package/dist/transformer/video-transformer.js +1 -1
  233. package/package.json +19 -18
  234. package/dist/packem_shared/AbstractBaseStorage-CLsYmMZg.js +0 -1
  235. package/dist/packem_shared/AwsLightFile-CpZrubaV.js +0 -1
  236. package/dist/packem_shared/AwsLightMetaStorage-DPqJ9LTr.js +0 -1
  237. package/dist/packem_shared/AwsLightStorage-DGSPFUqr.js +0 -1
  238. package/dist/packem_shared/AzureFile-DFSaVe25.js +0 -1
  239. package/dist/packem_shared/AzureSMetaStorage-ByzM6Aix.js +0 -1
  240. package/dist/packem_shared/AzureStorage-DvKk_hhz.js +0 -1
  241. package/dist/packem_shared/BaseTransformer-Buw5lX_3.js +0 -1
  242. package/dist/packem_shared/BoxFile-CseIoPW1.js +0 -1
  243. package/dist/packem_shared/BoxMetaStorage-CJsyeQ63.js +0 -1
  244. package/dist/packem_shared/BoxStorage-CmM95wi2.js +0 -1
  245. package/dist/packem_shared/BunS3File-BcYmsz1n.js +0 -1
  246. package/dist/packem_shared/BunS3MetaStorage-CJsyeQ63.js +0 -1
  247. package/dist/packem_shared/BunnyFile-BgEOlcYI.js +0 -1
  248. package/dist/packem_shared/BunnyMetaStorage-CJsyeQ63.js +0 -1
  249. package/dist/packem_shared/BunnyStorage-eZ1QDVaY.js +0 -1
  250. package/dist/packem_shared/CloudinaryFile-Bo5B-vM1.js +0 -1
  251. package/dist/packem_shared/CloudinaryMetaStorage-Bv_YCZ0Q.js +0 -1
  252. package/dist/packem_shared/CloudinaryStorage-CpH2f0Fv.js +0 -1
  253. package/dist/packem_shared/DiskStorage-DzjjqCzo.js +0 -1
  254. package/dist/packem_shared/DiskStorageWithChecksum-MZkDEyts.js +0 -1
  255. package/dist/packem_shared/DropboxFile-BFb7eOzy.js +0 -1
  256. package/dist/packem_shared/DropboxMetaStorage-CJsyeQ63.js +0 -1
  257. package/dist/packem_shared/DropboxStorage-BB9NoWK2.js +0 -1
  258. package/dist/packem_shared/File-W8aOo15X.js +0 -1
  259. package/dist/packem_shared/Files-DyMJ9FPN.js +0 -1
  260. package/dist/packem_shared/FirebaseFile-BLaBxa2A.js +0 -1
  261. package/dist/packem_shared/FirebaseMetaStorage-Bv_YCZ0Q.js +0 -1
  262. package/dist/packem_shared/FirebaseStorage-BgbxzYNC.js +0 -2
  263. package/dist/packem_shared/FtpFile-ClWDYnt2.js +0 -1
  264. package/dist/packem_shared/FtpMetaStorage-CJsyeQ63.js +0 -1
  265. package/dist/packem_shared/FtpStorage-CNqXDz7P.js +0 -1
  266. package/dist/packem_shared/GCSFile-Cero7qZN.js +0 -1
  267. package/dist/packem_shared/GCSMetaStorage-Cm_XzR0C.js +0 -1
  268. package/dist/packem_shared/GCStorage-DcvsI7eu.js +0 -1
  269. package/dist/packem_shared/GoogleDriveFile-DHpLhzg9.js +0 -1
  270. package/dist/packem_shared/GoogleDriveMetaStorage-B0gLF7Io.js +0 -1
  271. package/dist/packem_shared/LocalMetaStorage-CcGfFG39.js +0 -1
  272. package/dist/packem_shared/MediaTransformer-D2kUsklW.js +0 -1
  273. package/dist/packem_shared/MemoryMetaStorage-Ksgh9pe7.js +0 -1
  274. package/dist/packem_shared/Metadata-B7CcBueg.js +0 -1
  275. package/dist/packem_shared/Multipart-C35TR2qL.js +0 -1
  276. package/dist/packem_shared/NetlifyBlobFile-DoFhkzaH.js +0 -1
  277. package/dist/packem_shared/NetlifyBlobMetaStorage-Bv_YCZ0Q.js +0 -1
  278. package/dist/packem_shared/NetlifyBlobStorage-CZsr_0DF.js +0 -1
  279. package/dist/packem_shared/NoOpMetrics-BLo6u4NY.js +0 -1
  280. package/dist/packem_shared/OneDriveFile-CNNJYI43.js +0 -1
  281. package/dist/packem_shared/OneDriveMetaStorage-B0gLF7Io.js +0 -1
  282. package/dist/packem_shared/OneDriveStorage-B8qFgMq1.js +0 -1
  283. package/dist/packem_shared/OpenTelemetryMetrics-DJDQsNKp.js +0 -1
  284. package/dist/packem_shared/PocketBaseFile-DpJpxl3e.js +0 -1
  285. package/dist/packem_shared/PocketBaseMetaStorage-Cm3v8g1-.js +0 -1
  286. package/dist/packem_shared/PocketBaseStorage-D2vMN-oY.js +0 -1
  287. package/dist/packem_shared/Rest-BrEMYgxZ.js +0 -1
  288. package/dist/packem_shared/Rest-aPVP2ww1.js +0 -1
  289. package/dist/packem_shared/S3File-CpZrubaV.js +0 -1
  290. package/dist/packem_shared/S3MetaStorage-CMonflzp.js +0 -1
  291. package/dist/packem_shared/S3Storage-CTe_BMDl.js +0 -1
  292. package/dist/packem_shared/SftpFile-ClWDYnt2.js +0 -1
  293. package/dist/packem_shared/SftpMetaStorage-CJsyeQ63.js +0 -1
  294. package/dist/packem_shared/SftpStorage-BKeAzuej.js +0 -1
  295. package/dist/packem_shared/SharePointFile-Blz9FS4h.js +0 -1
  296. package/dist/packem_shared/SharePointMetaStorage-CJsyeQ63.js +0 -1
  297. package/dist/packem_shared/SupabaseFile-Bo5B-vM1.js +0 -1
  298. package/dist/packem_shared/SupabaseMetaStorage-B0gLF7Io.js +0 -1
  299. package/dist/packem_shared/SupabaseStorage-CmGQjqXf.js +0 -1
  300. package/dist/packem_shared/TUS_RESUMABLE-CyTSRvPU.js +0 -1
  301. package/dist/packem_shared/Tus-D9c7KDnl.js +0 -1
  302. package/dist/packem_shared/UploadThingFile-BTFMpcIA.js +0 -1
  303. package/dist/packem_shared/UploadThingMetaStorage-Bv_YCZ0Q.js +0 -1
  304. package/dist/packem_shared/UploadThingStorage-DZ4zNvDH.js +0 -1
  305. package/dist/packem_shared/ValidationError-3B06DFyE.js +0 -1
  306. package/dist/packem_shared/VercelBlobFile-CVQwKlZk.js +0 -1
  307. package/dist/packem_shared/VercelBlobMetaStorage-CJsyeQ63.js +0 -1
  308. package/dist/packem_shared/VercelBlobStorage-DDNEofR3.js +0 -1
  309. package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +0 -1
  310. package/dist/packem_shared/agentsCopyFile-Dl5iffdH.js +0 -1
  311. package/dist/packem_shared/akamai-DthkaFul.js +0 -1
  312. package/dist/packem_shared/alibaba-BEi25O1g.js +0 -1
  313. package/dist/packem_shared/approval-fVHwBp7u.js +0 -1
  314. package/dist/packem_shared/aws-light-meta-storage-DGrn72VJ.js +0 -4
  315. package/dist/packem_shared/azure-meta-storage-ClbEsfI4.js +0 -1
  316. package/dist/packem_shared/backblaze-m1N5NZ9q.js +0 -1
  317. package/dist/packem_shared/base-handler-core-BJP9jHCE.js +0 -1
  318. package/dist/packem_shared/base-handler-fetch-yrYrukwL.js +0 -1
  319. package/dist/packem_shared/base-handler-node-C8P9rkaH.js +0 -1
  320. package/dist/packem_shared/claudeCopyFile-BX9O4ORk.js +0 -1
  321. package/dist/packem_shared/cloudflare-CdUTErlo.js +0 -1
  322. package/dist/packem_shared/copyFile-49FtxXcm.js +0 -1
  323. package/dist/packem_shared/copyFile-BUPezT_c.js +0 -1
  324. package/dist/packem_shared/createResponsesFileTools-6Tvt2PNr.js +0 -1
  325. package/dist/packem_shared/createRetryWrapper-DgmeHPNF.js +0 -1
  326. package/dist/packem_shared/detect-file-type-BA7UBLKA.js +0 -1
  327. package/dist/packem_shared/digitalOcean-B2uB6pgz.js +0 -1
  328. package/dist/packem_shared/disk-storage-DqnnFQAQ.js +0 -1
  329. package/dist/packem_shared/disk-storage-with-checksum.d-Dgwyza8a.d.ts +0 -146
  330. package/dist/packem_shared/exoscale-BDa1Gjth.js +0 -1
  331. package/dist/packem_shared/gcs-meta-storage-Bu2upyHK.js +0 -1
  332. package/dist/packem_shared/getFormatFromContentType-DCTTPQHm.js +0 -1
  333. package/dist/packem_shared/has-content-50BsqrWw.js +0 -1
  334. package/dist/packem_shared/headers-BAiAKekR.js +0 -26
  335. package/dist/packem_shared/hetzner-BGGFiRGD.js +0 -1
  336. package/dist/packem_shared/idriveE2-C6pQ5pQ0.js +0 -1
  337. package/dist/packem_shared/index-nZWCQrSe.js +0 -5
  338. package/dist/packem_shared/internal-D_cZIFwI.js +0 -1
  339. package/dist/packem_shared/is-expired-CBEk6XBi.js +0 -1
  340. package/dist/packem_shared/local-meta-storage-BELb1YwO.js +0 -11
  341. package/dist/packem_shared/memory-storage.d-BNZvDG1b.d.ts +0 -93
  342. package/dist/packem_shared/minio-NKquuBfS.js +0 -1
  343. package/dist/packem_shared/multipart-base-BOzY19lb.js +0 -1
  344. package/dist/packem_shared/oauth-refresh-EdGzlcOZ.js +0 -1
  345. package/dist/packem_shared/part-match-D-9dGX42.js +0 -1
  346. package/dist/packem_shared/path-C-OWflAo-_mqb5p5d.js +0 -1
  347. package/dist/packem_shared/posix-dirname-CfpH5wZi.js +0 -1
  348. package/dist/packem_shared/response-builder-CbSA8qPa.js +0 -1
  349. package/dist/packem_shared/rest-base-BQ_dhWyV.js +0 -1
  350. package/dist/packem_shared/s3-base-storage-CX94H-Za.js +0 -1
  351. package/dist/packem_shared/scaleway-U1In3v70.js +0 -1
  352. package/dist/packem_shared/storj-Cb59q9kF.js +0 -1
  353. package/dist/packem_shared/sync-DhR3536K.js +0 -1
  354. package/dist/packem_shared/tencent-Q1y2GENc.js +0 -1
  355. package/dist/packem_shared/tigris-BELKoyyp.js +0 -1
  356. package/dist/packem_shared/update-size-DuNuLyxj.js +0 -1
  357. package/dist/packem_shared/vultr-B491cQ4e.js +0 -1
  358. package/dist/packem_shared/waitForStorage-ByQmG4xF.js +0 -1
  359. package/dist/packem_shared/wasabi-DFrwIoab.js +0 -1
  360. package/dist/packem_shared/yandex-CwzHuEKP.js +0 -1
@@ -1,6 +1,6 @@
1
- export { type d as AudioChannelMixOptions, type c as AudioResampleOptions, type e as AudioTransformOptions, type b as AudioTransformResult, type f as AudioTransformationStep, type A as AudioTransformerConfig, B as BaseTransformer, type C as CropOptions, type h as ImageFormat, type I as ImageTransformerConfig, type U as MediaTransformQuery, type a as MediaTransformResult, type W as MediaTransformationStep, type M as MediaTransformerConfig, type R as ResizeOptions, type g as RotateOptions, type i as TransformOptions, type T as TransformResult, type z as TransformationStep, type K as VideoCropOptions, type H as VideoResizeOptions, type N as VideoRotateOptions, type O as VideoTransformOptions, type F as VideoTransformResult, type Q as VideoTransformationStep, type V as VideoTransformerConfig } from "../packem_shared/types.d-BEUv414z.js";
2
- export { M as MediaTransformer } from "../packem_shared/media-transformer.d-C8tn4J2Z.js";
3
- import { g as FileReturn } from "../packem_shared/storage.d-DwdJrArF.js";
1
+ export { type d as AudioChannelMixOptions, type c as AudioResampleOptions, type e as AudioTransformOptions, type b as AudioTransformResult, type f as AudioTransformationStep, type A as AudioTransformerConfig, B as BaseTransformer, type C as CropOptions, type h as ImageFormat, type I as ImageTransformerConfig, type U as MediaTransformQuery, type a as MediaTransformResult, type W as MediaTransformationStep, type M as MediaTransformerConfig, type R as ResizeOptions, type g as RotateOptions, type i as TransformOptions, type T as TransformResult, type z as TransformationStep, type K as VideoCropOptions, type H as VideoResizeOptions, type N as VideoRotateOptions, type O as VideoTransformOptions, type F as VideoTransformResult, type Q as VideoTransformationStep, type V as VideoTransformerConfig } from "../packem_shared/types.d-D1TIRqKW.js";
2
+ export { M as MediaTransformer } from "../packem_shared/media-transformer.d-Co37isNg.js";
3
+ import { g as FileReturn } from "../packem_shared/storage.d-C9EdfTf1.js";
4
4
  import 'node:stream';
5
5
  import 'node:timers';
6
6
  import 'node:crypto';
@@ -1 +1 @@
1
- import{default as a}from"../packem_shared/BaseTransformer-Buw5lX_3.js";import{default as t}from"../packem_shared/MediaTransformer-D2kUsklW.js";import{getFormatFromContentType as d,isKnownContentType as f,isValidMediaType as n,validateMediaFile as m}from"../packem_shared/getFormatFromContentType-DCTTPQHm.js";import{default as l}from"../packem_shared/ValidationError-3B06DFyE.js";export{a as BaseTransformer,t as MediaTransformer,l as ValidationError,d as getFormatFromContentType,f as isKnownContentType,n as isValidMediaType,m as validateMediaFile};
1
+ import{default as a}from"../packem_shared/BaseTransformer-ByIAKnn8.js";import{default as t}from"../packem_shared/MediaTransformer-GqBUkOvz.js";import{getFormatFromContentType as d,isKnownContentType as f,isValidMediaType as n,validateMediaFile as m}from"../packem_shared/getFormatFromContentType-BAVdaQ0o.js";import{default as l}from"../packem_shared/ValidationError-SzFFFHiN.js";export{a as BaseTransformer,t as MediaTransformer,l as ValidationError,d as getFormatFromContentType,f as isKnownContentType,n as isValidMediaType,m as validateMediaFile};
@@ -1,5 +1,5 @@
1
- import { F as File, g as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-DwdJrArF.js";
2
- import { V as VideoTransformerConfig, F as VideoTransformResult, H as VideoResizeOptions, K as VideoCropOptions, N as VideoRotateOptions, O as VideoTransformOptions, Q as VideoTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-BEUv414z.js";
1
+ import { F as File, g as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-C9EdfTf1.js";
2
+ import { V as VideoTransformerConfig, F as VideoTransformResult, H as VideoResizeOptions, K as VideoCropOptions, N as VideoRotateOptions, O as VideoTransformOptions, Q as VideoTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-D1TIRqKW.js";
3
3
  import 'node:stream';
4
4
  import 'node:timers';
5
5
  import 'node:crypto';
@@ -1 +1 @@
1
- import{Input as c,BufferSource as p,ALL_FORMATS as f,Output as d,BufferTarget as h,Conversion as w,Mp4OutputFormat as m,WebMOutputFormat as g,OggOutputFormat as l,MkvOutputFormat as y}from"mediabunny";import b from"../packem_shared/BaseTransformer-Buw5lX_3.js";import{isValidMediaType as v,getFormatFromContentType as T}from"../packem_shared/getFormatFromContentType-DCTTPQHm.js";class V extends b{constructor(o,t={}){const r=t.logger||o.logger,e={cacheTtl:3600,defaultBitrate:2e6,defaultCodec:"avc",maxCacheSize:50,maxVideoSize:500*1024*1024,supportedFormats:["mp4","webm","mkv","avi","mov","flv","wmv"],...t};super(o,e,r)}async resize(o,t){return this.transform(o,[{options:t,type:"resize"}])}async crop(o,t){return this.transform(o,[{options:t,type:"crop"}])}async rotate(o,t){return this.transform(o,[{options:t,type:"rotate"}])}async convertFormat(o,t,r={}){return this.transform(o,[{options:{...r,format:t},type:"format"}])}async transcode(o,t,r={}){return this.transform(o,[{options:{...r,codec:t},type:"codec"}])}async transform(o,t){const r={id:o},e=this.generateCacheKey(o,t);if(this.cache){const n=await Promise.resolve(this.cache.get(e));if(n)return this.logger?.debug("Returning cached transformed video for %s",o),n}const i=await this.storage.get(r);await this.validateVideo(i);const s=await this.applyTransformations(i.content,t),a=await this.createTransformResult(s,i);return this.cache&&this.cache.set(e,a),a}async applyTransformations(o,t){const r=new c({formats:f,source:new p(o)}),e=this.determineOutputFormat(t),i=new d({format:e,target:new h}),s=this.stepsToVideoOptions(t),a=await w.init({input:r,output:i,video:s});if(!a.isValid){const n=a.discardedTracks.map(u=>u.reason).join(", ");throw new Error(`Video transformation failed: ${n}`)}return await a.execute(),Buffer.from(i.target.buffer)}stepsToVideoOptions(o){const t={};for(const r of o)switch(r.type){case"bitrate":{const e=r.options;e.bitrate&&(t.bitrate=e.bitrate);break}case"codec":{const e=r.options;e.codec&&(t.codec=e.codec),e.bitrate&&(t.bitrate=e.bitrate);break}case"crop":{const e=r.options;t.crop={height:e.height,left:e.left,top:e.top,width:e.width};break}case"frameRate":{const e=r.options;e.frameRate&&(t.frameRate=e.frameRate);break}case"resize":{const e=r.options;t.width=e.width,t.height=e.height,t.fit=e.fit,e.position!==void 0&&(t.position=e.position);break}case"rotate":{const e=r.options;t.rotate=e.angle,e.background&&(t.background=e.background);break}}return t}determineOutputFormat(o){for(const t of o)if(t.type==="format"&&t.options.format)return this.formatStringToOutputFormat(t.options.format);return new m}formatStringToOutputFormat(o){switch(o.toLowerCase()){case"mkv":return new y;case"mp4":return new m;case"ogg":return new l;case"webm":return new g;default:return new m}}async validateVideo(o){const t=typeof o.size=="string"?Number.parseInt(o.size,10):o.size;if(this.config?.maxVideoSize&&t>this.config.maxVideoSize)throw new Error(`Video size ${t} exceeds maximum allowed size ${this.config.maxVideoSize}`);if(!v(o.contentType,"video"))throw new Error(`File is not a video: ${o.contentType}`);const r=T(o.contentType);if(this.config?.supportedFormats&&r&&!this.config.supportedFormats.includes(r))throw new Error(`Unsupported video format: ${r}`);try{if(!await new c({formats:f,source:new p(o.content)}).getPrimaryVideoTrack())throw new Error("No video track found")}catch(e){throw new Error(`Invalid video file: ${e}`)}}async createTransformResult(o,t){const r=new c({formats:f,source:new p(o)}),e=await r.getPrimaryVideoTrack(),i=await r.computeDuration();return{bitrate:this.config.defaultBitrate,buffer:o,duration:i,format:"mp4",height:e?.displayHeight||0,originalFile:t,size:o.length,width:e?.displayWidth||0}}generateCacheKey(o,t){const r=t.map(e=>`${e.type}:${JSON.stringify(e.options)}`).join("|");return`${o}:${r}`}}export{V as default};
1
+ import{Input as c,BufferSource as p,ALL_FORMATS as m,Output as d,BufferTarget as h,Conversion as w,Mp4OutputFormat as u,WebMOutputFormat as g,OggOutputFormat as y,MkvOutputFormat as l}from"mediabunny";import v from"../packem_shared/BaseTransformer-ByIAKnn8.js";import{isValidMediaType as T,getFormatFromContentType as b}from"../packem_shared/getFormatFromContentType-BAVdaQ0o.js";class V extends v{constructor(o,t={}){const r=t.logger||o.logger,e={cacheTtl:3600,defaultBitrate:2e6,defaultCodec:"avc",maxCacheSize:50,maxVideoSize:500*1024*1024,supportedFormats:["mp4","webm","mkv","avi","mov","flv","wmv"],...t};super(o,e,r)}async resize(o,t){return this.transform(o,[{options:t,type:"resize"}])}async crop(o,t){return this.transform(o,[{options:t,type:"crop"}])}async rotate(o,t){return this.transform(o,[{options:t,type:"rotate"}])}async convertFormat(o,t,r={}){return this.transform(o,[{options:{...r,format:t},type:"format"}])}async transcode(o,t,r={}){return this.transform(o,[{options:{...r,codec:t},type:"codec"}])}async transform(o,t){const r={id:o},e=this.generateCacheKey(o,t);if(this.cache){const n=await Promise.resolve(this.cache.get(e));if(n)return this.logger?.debug("Returning cached transformed video for %s",o),n}const i=await this.storage.get(r);await this.validateVideo(i);const s=await this.applyTransformations(i.content,t),a=await this.createTransformResult(s,i);return this.cache&&this.cache.set(e,a),a}async applyTransformations(o,t){const r=new c({formats:m,source:new p(o)}),e=this.determineOutputFormat(t),i=new d({format:e,target:new h}),s=this.stepsToVideoOptions(t),a=await w.init({input:r,output:i,video:s});if(!a.isValid){const n=a.discardedTracks.map(f=>f.reason).join(", ");throw new Error(`Video transformation failed: ${n}`)}return await a.execute(),Buffer.from(i.target.buffer)}stepsToVideoOptions(o){const t={};for(const r of o)switch(r.type){case"bitrate":{const e=r.options;e.bitrate&&(t.bitrate=e.bitrate);break}case"codec":{const e=r.options;e.codec&&(t.codec=e.codec),e.bitrate&&(t.bitrate=e.bitrate);break}case"crop":{const e=r.options;t.crop={height:e.height,left:e.left,top:e.top,width:e.width};break}case"frameRate":{const e=r.options;e.frameRate&&(t.frameRate=e.frameRate);break}case"resize":{const e=r.options;t.width=e.width,t.height=e.height,t.fit=e.fit,e.position!==void 0&&(t.position=e.position);break}case"rotate":{const e=r.options;t.rotate=e.angle,e.background&&(t.background=e.background);break}}return t}determineOutputFormat(o){for(const t of o)if(t.type==="format"&&t.options.format)return this.formatStringToOutputFormat(t.options.format);return new u}formatStringToOutputFormat(o){switch(o.toLowerCase()){case"mkv":return new l;case"mp4":return new u;case"ogg":return new y;case"webm":return new g;default:return new u}}async validateVideo(o){const t=typeof o.size=="string"?Number.parseInt(o.size,10):o.size;if(this.config?.maxVideoSize&&t>this.config.maxVideoSize)throw new Error(`Video size ${t} exceeds maximum allowed size ${this.config.maxVideoSize}`);if(!T(o.contentType,"video"))throw new Error(`File is not a video: ${o.contentType}`);const r=b(o.contentType);if(this.config?.supportedFormats&&r&&!this.config.supportedFormats.includes(r))throw new Error(`Unsupported video format: ${r}`);try{if(!await new c({formats:m,source:new p(o.content)}).getPrimaryVideoTrack())throw new Error("No video track found")}catch(e){throw new Error(`Invalid video file: ${e}`)}}async createTransformResult(o,t){const r=new c({formats:m,source:new p(o)}),e=await r.getPrimaryVideoTrack(),i=await r.computeDuration();return{bitrate:this.config.defaultBitrate,buffer:o,duration:i,format:"mp4",height:e?.displayHeight||0,originalFile:t,size:o.length,width:e?.displayWidth||0}}generateCacheKey(o,t){const r=t.map(e=>`${e.type}:${JSON.stringify(e.options)}`).join("|");return`${o}:${r}`}}export{V as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/storage",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Server-side file-storage abstraction - store files in a web-accessible location via a simplified API. Includes S3, Azure, GCS, local filesystem and 20+ other backends with TUS/multipart/REST upload handlers and the most convenient features of each.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -61,11 +61,6 @@
61
61
  "visulima"
62
62
  ],
63
63
  "homepage": "https://visulima.com/packages/storage",
64
- "license": "MIT",
65
- "author": {
66
- "name": "Daniel Bannert",
67
- "email": "d.bannert@anolilab.de"
68
- },
69
64
  "repository": {
70
65
  "type": "git",
71
66
  "url": "https://github.com/visulima/visulima.git",
@@ -81,14 +76,13 @@
81
76
  "url": "https://anolilab.com/support"
82
77
  }
83
78
  ],
84
- "files": [
85
- "dist/**",
86
- "README.md",
87
- "CHANGELOG.md",
88
- "LICENSE.md"
89
- ],
90
- "type": "module",
79
+ "license": "MIT",
80
+ "author": {
81
+ "name": "Daniel Bannert",
82
+ "email": "d.bannert@anolilab.de"
83
+ },
91
84
  "sideEffects": false,
85
+ "type": "module",
92
86
  "exports": {
93
87
  ".": {
94
88
  "types": "./dist/index.d.ts",
@@ -264,18 +258,21 @@
264
258
  },
265
259
  "./package.json": "./package.json"
266
260
  },
267
- "publishConfig": {
268
- "access": "public",
269
- "provenance": true
270
- },
261
+ "files": [
262
+ "dist/**",
263
+ "README.md",
264
+ "CHANGELOG.md",
265
+ "LICENSE.md"
266
+ ],
271
267
  "dependencies": {
272
268
  "@remix-run/multipart-parser": "0.16.3",
273
269
  "@sindresorhus/fnv1a": "3.1.0",
274
- "@visulima/pagination": "7.0.0",
270
+ "@visulima/pagination": "7.0.1",
275
271
  "file-type": "22.0.1",
276
272
  "lru-cache": "11.5.1",
277
273
  "mime": "^4.1.0",
278
274
  "nanoid": "5.1.16",
275
+ "openapi-types": "^12.1.3",
279
276
  "path-to-regexp": "8.4.2",
280
277
  "type-is": "^2.1.0",
281
278
  "zod": "4.4.3"
@@ -434,5 +431,9 @@
434
431
  },
435
432
  "engines": {
436
433
  "node": "^22.14.0 || >=24.10.0"
434
+ },
435
+ "publishConfig": {
436
+ "access": "public",
437
+ "provenance": true
437
438
  }
438
439
  }
@@ -1 +0,0 @@
1
- import"node:stream";import"node:timers";import"node:util";import{B as u,d as F,a as g}from"./storage-DR7qdwBN.js";import"./path-C-OWflAo-_mqb5p5d.js";import"type-is";import"./NoOpMetrics-BLo6u4NY.js";import"./cache-Cw3QjoVN.js";import"./ERRORS-BIBxE2oR.js";import"./createRetryWrapper-DgmeHPNF.js";import"./is-expired-CBEk6XBi.js";export{u as BaseStorage,F as defaultCloudStorageFileNameValidation,g as defaultFilesystemFileNameValidation};
@@ -1 +0,0 @@
1
- import r from"./File-W8aOo15X.js";class s extends r{Parts;UploadId;uri;partsUrls;partSize}export{s as default};
@@ -1 +0,0 @@
1
- import"./MetaStorage-DPEUyWgN.js";import"./Metadata-B7CcBueg.js";import{p as i}from"./aws-light-meta-storage-DGrn72VJ.js";import"./is-expired-CBEk6XBi.js";export{i as default};
@@ -1 +0,0 @@
1
- import{Readable as u}from"node:stream";import{S as m}from"./s3-base-storage-CX94H-Za.js";import{b as h,p as l}from"./aws-light-meta-storage-DGrn72VJ.js";import f from"./AwsLightFile-CpZrubaV.js";class b extends m{static name="aws-light";s3Api;constructor(e){const{bucket:t=process.env.S3_BUCKET||process.env.AWS_S3_BUCKET,region:r}=e;if(!t)throw new Error("S3 bucket is not defined");if(!r)throw new Error("S3 region is not defined");if(!e.accessKeyId)throw new Error("accessKeyId is required");if(!e.secretAccessKey)throw new Error("secretAccessKey is required");super({bucket:t,clientDirectUpload:e.clientDirectUpload,expiration:e.expiration?.maxAge?{maxAge:String(e.expiration.maxAge)}:void 0,filename:e.filename,logger:e.logger,metaStorage:e.metaStorage,metaStorageConfig:e.metaStorageConfig?{...e.metaStorageConfig,...e}:{...e},partSize:e.partSize,retryConfig:{...e.retryConfig,shouldRetry:o=>{const s=o;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)||s.retryable===!0?!0:void 0}}}),this.s3Api=new h({accessKeyId:e.accessKeyId,bucket:t,endpoint:e.endpoint,region:r,secretAccessKey:e.secretAccessKey,service:e.service,sessionToken:e.sessionToken});const{metaStorage:i,metaStorageConfig:a}=e;if(!i){const o={...e,...a,logger:this.logger};this.meta=new l(o)}}normalizeError(e){const t=e;return t.statusCode||t.code?{code:t.code||t.name,message:t.message,name:t.name,statusCode:t.statusCode||500}:super.normalizeError(e)}async update({id:e},t){if(this.config.clientDirectUpload){const r=await this.getMeta(e);return this.buildPresigned({...r,...t})}return super.update({id:e},t)}async getStream({id:e},t){return this.instrumentOperation("getStream",async()=>{const r=this.getS3Api(),{Body:i,ContentLength:a,ContentType:o,ETag:s,Expires:c,LastModified:g}=await this.runOperation(t,n=>r.getObject({Bucket:this.bucket,Key:e},{signal:n}));await this.checkIfExpired({expiredAt:c});const d=i instanceof ReadableStream?u.fromWeb(i):i,p=new u({read(){d.on("data",n=>{this.push(n)}),d.on("end",()=>{this.push(null)}),d.on("error",n=>{this.destroy(n)})}});return{headers:{"Content-Length":a?.toString()??"0","Content-Type":o,...s&&{ETag:s},...c&&{"X-Upload-Expires":c.toString()},...g&&{"Last-Modified":g.toString()}},size:Number(a),stream:p}})}get raw(){return this.s3Api.aws}getS3Api(){return this.s3Api}getFileClass(){return f}getAcl(){}async accessCheck(e=30){await this.s3Api.checkBucketAccess({Bucket:this.bucket})}}export{b as default};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class t extends e{requestId;uri}export{t as default};
@@ -1 +0,0 @@
1
- import"./ERRORS-BIBxE2oR.js";import"./MetaStorage-DPEUyWgN.js";import"./Metadata-B7CcBueg.js";import{c as i}from"./azure-meta-storage-ClbEsfI4.js";export{i as default};
@@ -1 +0,0 @@
1
- import{W as f}from"./path-C-OWflAo-_mqb5p5d.js";import{d as b}from"./detect-file-type-BA7UBLKA.js";import{throwErrorCode as u,ERRORS as h}from"./ERRORS-BIBxE2oR.js";import{B as C,c as w}from"./storage-DR7qdwBN.js";import{y as T}from"./local-meta-storage-BELb1YwO.js";import{a as O,c as S,b as m,d as y}from"./azure-meta-storage-ClbEsfI4.js";import k from"./AzureFile-DFSaVe25.js";import{i as E}from"./part-match-D-9dGX42.js";import{e as B}from"./has-content-50BsqrWw.js";import{t as F}from"./get-file-status-y3wTtDQs.js";class z extends C{static name="azure";checksumTypes=["md5"];get raw(){return this.client}meta;client;containerClient;root;resolvedRetryConfig;signer;sasToken;anonymous;constructor(t){if(super(t),!t.containerName)throw new Error("Missing required parameter: Azure container name.");const{anonymous:r,client:e,sasToken:n,signer:s}=O(t);this.client=e,this.signer=s,this.sasToken=n,this.anonymous=r,this.containerClient=this.client.getContainerClient(t.containerName),this.root=t.root?f(t.root).replace(/^\//,""):"";const o={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:i=>{const a=i;if(a.statusCode&&[408,429,500,502,503,504].includes(a.statusCode))return!0;if(i instanceof Error){const l=a.code;if(l==="ECONNRESET"||l==="ETIMEDOUT"||l==="ENOTFOUND"||l==="ECONNREFUSED")return!0}},...t.retryConfig};if(this.resolvedRetryConfig=o,t.metaStorage)this.meta=t.metaStorage;else{let i={...t,...t.metaStorageConfig,logger:this.logger};if("directory"in i)this.logger?.debug("Using local meta storage"),this.meta=new T(i);else{const a=t.metaStorageConfig;a&&["accountKey","accountName","connectionString","credential","endpoint","sasToken"].some(l=>l in a)||(i={...i,client:this.client}),this.meta=new S(i)}}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(i=>{this.logger?.error("Storage access check failed: %O",i)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,r){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const a=typeof t.ttl=="string"?w(t.ttl):t.ttl;a!==void 0&&(e.expiredAt=Date.now()+a)}const n=new k(e);n.name=this.namingFunction(n),await this.validate(n);try{const a=await this.getMeta(n.id);if(a.bytesWritten>=0)return a}catch{}const s=this.containerClient.getBlockBlobClient(this.getFullPath(n.name)),o={};for(const[a,l]of Object.entries(n.metadata||{}))o[a]=JSON.stringify(l);const i=await this.runOperation(r,a=>s.uploadData(Buffer.from(""),{abortSignal:a,blobHTTPHeaders:{blobContentType:n.contentType},metadata:{name:n.name,originalName:n.originalName,...o}}));return i.requestId===void 0?u(h.FILE_ERROR,"azure create upload error"):(n.requestId=i.requestId,n.uri=i._response.headers.get("location"),n.bytesWritten=0,await this.saveMeta(n),n.status="created",await this.onCreate(n),n)})}async delete({id:t},r){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.runOperation(r,s=>this.containerClient.getBlockBlobClient(this.getFullPath(e.name)).deleteIfExists({abortSignal:s})),await this.deleteMeta(e.id);const n={...e};return await this.onDelete(n),n})}async deleteBatch(t,r){if(t.length===0)return{failed:[],failedCount:0,successful:[],successfulCount:0};const e=256;try{const n=this.client.getBlobBatchClient(),s=[],o=[];for(let i=0;i<t.length;i+=e){const a=t.slice(i,i+e),l=a.map(c=>this.containerClient.getBlockBlobClient(this.getFullPath(c))),d=await this.runOperation(r,c=>n.deleteBlobs(l,{abortSignal:c}));for(const[c,p]of d.subResponses.entries()){const g=a[c];p.status===202||p.status===404?s.push({id:g,name:g,status:"deleted"}):o.push({error:p.errorCode??`HTTP ${p.status}`,id:g})}}return await Promise.all(s.map(async i=>{try{await this.deleteMeta(i.id),await this.onDelete(i)}catch{}})),{failed:o,failedCount:o.length,successful:s,successfulCount:s.length}}catch(n){return this.logger?.warn(`Azure Blob Batch delete unavailable, falling back to per-key delete: ${n instanceof Error?n.message:String(n)}`),super.deleteBatch(t,r)}}async move(t,r,e){return this.instrumentOperation("move",async()=>{const n=await this.copy(t,r,e),s=this.getFullPath(t);return await this.runOperation(e,o=>this.containerClient.getBlockBlobClient(s).deleteIfExists({abortSignal:o})),n})}async write(t,r){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(!E(t,e))return u(h.FILE_CONFLICT);const n=await this.lock(t.id);try{if(B(t)){if((e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(!e.contentType||e.contentType==="application/octet-stream"))try{const{fileType:a,stream:l}=await b(t.body);a?.mime&&(e.contentType=a.mime),t.body=l}catch{}const s=this.containerClient.getBlockBlobClient(this.getFullPath(e.name)),o=new AbortController;t.body.on("error",()=>{o.abort()});const i=await this.runOperation(r,a=>{const l=a?AbortSignal.any([o.signal,a]):o.signal;return s.uploadStream(t.body,void 0,void 0,{abortSignal:l,blobHTTPHeaders:{blobContentType:e.contentType??"application/octet-stream"},metadata:e.metadata})},{replayable:!1});if(i.requestId===void 0)return u(h.FILE_ERROR,"azure write upload error");e.requestId=i.requestId,e.bytesWritten+=t.contentLength||0,e.status=F(e),e.status==="completed"&&(e.uri=i._response.headers.get("location"),await this.deleteMeta(e.id))}}finally{await this.unlock(t.id,n)}return e})}async get({id:t},r){return this.instrumentOperation("get",async()=>{const e=this.containerClient.getBlockBlobClient(this.getFullPath(t));if(!await this.runOperation(r,c=>e.exists({abortSignal:c})))try{return await this.getMeta(t),u(h.GONE)}catch{return u(h.FILE_NOT_FOUND)}const n=await this.runOperation(r,c=>e.getProperties({abortSignal:c})),{contentLength:s,contentType:o,etag:i,expiresOn:a,lastModified:l,metadata:d}=n;return{content:await this.runOperation(r,c=>e.downloadToBuffer(0,void 0,{abortSignal:c})),contentType:o,ETag:i,expiredAt:a,id:t,metadata:d||{},modifiedAt:l,name:d?.name||t,originalName:d?.originalName||"",size:s}})}async exists({id:t},r){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.containerClient.getBlockBlobClient(this.getFullPath(t));return await this.runOperation(r,n=>e.exists({abortSignal:n}))}catch{return!1}})}async copy(t,r,e){return this.instrumentOperation("copy",async()=>{const n=this.containerClient.getBlockBlobClient(this.getFullPath(t));if(!await this.runOperation(e,a=>n.exists({abortSignal:a})))try{return await this.getMeta(t),u(h.GONE)}catch{return u(h.FILE_NOT_FOUND)}const s=this.containerClient.getBlockBlobClient(this.getFullPath(r));let o=n.url;this.signer?.kind==="userDelegation"?o=await m(this.containerClient.getBlobClient(this.getFullPath(t)),this.signer,{expiresIn:300,permissions:"r"}):this.sasToken&&(o=y(n.url,this.sasToken));const i=await this.runOperation(e,a=>s.beginCopyFromURL(o,{abortSignal:a}));return await this.runOperation(e,()=>i.pollUntilDone()),{...await this.getMeta(t),id:r,name:r}})}async list(t=1e3,r){return this.instrumentOperation("list",async()=>{const e=[];let n=!0,s;for(;n&&e.length<t;)try{const o=Math.min(t-e.length,1e3),i=(await this.runOperation(r,a=>this.containerClient.listBlobsFlat({abortSignal:a,includeMetadata:!0,prefix:this.root}).byPage({continuationToken:s,maxPageSize:o}).next())).value;if(i!==void 0&&"segment"in i){for(const a of i.segment.blobItems)if(!a.deleted&&(e.push({createdAt:a.properties.createdOn,id:a.name,modifiedAt:a.properties.lastModified}),e.length>=t))break}n=i?.continuationToken!==void 0,n&&(s=i.continuationToken)}catch(o){const i=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(i),o}return e},{limit:t})}async getReadUrl(t,r){const e=this.containerClient.getBlobClient(this.getFullPath(t));return this.signer?m(e,this.signer,{expiresIn:r?.expiresIn??3600,permissions:"r",...r?.responseContentDisposition&&{contentDisposition:r.responseContentDisposition},...r?.responseContentType&&{contentType:r.responseContentType}}):r?.responseContentDisposition!==void 0||r?.responseContentType!==void 0?u(h.BAD_REQUEST,"azure: `responseContentDisposition`/`responseContentType` require a freshly minted SAS (construct with a shared key or Microsoft Entra credential). A pre-issued `sasToken` or anonymous public-container URL has no signature in which to bind the override, so it cannot be enforced."):this.sasToken?y(e.url,this.sasToken):this.anonymous?e.url:u(h.METHOD_NOT_ALLOWED,"azure: cannot produce a read URL without a shared key, Microsoft Entra credential, or SAS token. Construct the adapter with accountKey + accountName, a connectionString containing an account key, a credential + accountName, or a sasToken.")}async getUploadUrl(t,r){if(r?.contentType!==void 0||r?.contentLength!==void 0)return u(h.BAD_REQUEST,"azure: `contentType`/`contentLength` are not supported for upload URLs. An Azure SAS does not bind the request Content-Type into the signature and cannot enforce a size limit; validate both at your application gateway/proxy before issuing the SAS, or omit them and accept the unbounded PUT.");const e=this.containerClient.getBlobClient(this.getFullPath(t));return this.signer?m(e,this.signer,{expiresIn:r?.expiresIn??3600,permissions:"cw"}):this.sasToken?y(e.url,this.sasToken):u(h.METHOD_NOT_ALLOWED,"azure: cannot produce an upload URL without a shared key, Microsoft Entra credential, or SAS token. Anonymous (public-container) access is read-only.")}getFullPath(t){return this.assetFolder!==void 0?`${this.assetFolder}/${t}`:t}async accessCheck(){await this.runOperation(void 0,t=>this.containerClient.getProperties({abortSignal:t}))}}export{z as default};
@@ -1 +0,0 @@
1
- import{Readable as o}from"node:stream";import s from"mime";import{N as n}from"./cache-Cw3QjoVN.js";class l{constructor(t,r,e){this.storage=t,this.config=r,this.logger=e,this.cache=r.cache??new n}storage;config;logger;cache;async transformStream(t,r){const e=await this.transform(t,r);if(e&&"buffer"in e){const{buffer:a}=e;return{headers:{"Content-Length":a.length.toString(),"Content-Type":this.getContentTypeFromResult(e)},size:a.length,stream:o.from(a)}}throw new Error("Streaming transformation not supported for this transformer")}clearCache(t){if(!t){this.cache?.clear?.();return}if(!this.cache)return;if(typeof this.cache.keys!="function"){this.logger?.warn?.("clearCache(fileId) cannot scope its invalidation because the cache does not implement keys(); falling back to full clear()"),this.cache.clear?.();return}const r=`${t}:`;for(const e of this.cache.keys())typeof e=="string"&&(e===t||e.startsWith(r))&&this.cache.delete(e)}getCacheStats(){return{maxSize:-1,size:this.cache?.size??0}}getContentTypeFromResult(t){if(t?.format){const r=s.getType(t.format);if(r)return r}return"application/octet-stream"}}export{l as default};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class o extends e{boxFileId;eTag;publicUrl}export{o as default};
@@ -1 +0,0 @@
1
- import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
@@ -1 +0,0 @@
1
- import{Readable as x}from"node:stream";import{BoxDeveloperTokenAuth as I,BoxClient as u,OAuthConfig as E,BoxOAuth as O,CcgConfig as T,BoxCcgAuth as b,BoxJwtAuth as U,JwtConfig as F}from"box-typescript-sdk-gen";import{throwErrorCode as C,ERRORS as B}from"./ERRORS-BIBxE2oR.js";import{B as L}from"./storage-DR7qdwBN.js";import p from"./BoxFile-CseIoPW1.js";import S from"./BoxMetaStorage-CJsyeQ63.js";import{t as v}from"./get-file-status-y3wTtDQs.js";import{t as D}from"./update-size-DuNuLyxj.js";import{i as H}from"./part-match-D-9dGX42.js";import{e as R}from"./has-content-50BsqrWw.js";const _="0",A=50*1024*1024,w={ensureReady:()=>Promise.resolve()},M=a=>{let e=0,i=a.length;for(;e<i&&a[e]==="/";)e+=1;for(;i>e&&a[i-1]==="/";)i-=1;return e===0&&i===a.length?a:a.slice(e,i)},m=a=>{const e=M(a);if(!e)throw new Error("Box: key must not be empty");const i=e.split("/").filter(r=>r.length>0),t=i.pop()??"";if(!t)throw new Error(`Box: key "${a}" has no file name segment`);return{leaf:t,parents:i}},N=async a=>{const e=[];for await(const i of a)e.push(Buffer.from(i));return Buffer.concat(e)},g=a=>x.from(a),j=a=>"configJsonString"in a?F.fromConfigJsonString(a.configJsonString):F.fromConfigFile(a.configFilePath),z=a=>[a.developerToken,a.oauth,a.ccg,a.jwt].filter(e=>e!==void 0).length,P=a=>{if(a.client)return{authHandle:w,client:a.client};if(z(a)>1)throw new Error("Box storage: pass exactly one of `developerToken`, `oauth`, `ccg`, or `jwt`.");if(a.developerToken!==void 0){const i=new I({token:a.developerToken});return{authHandle:w,client:new u({auth:i})}}if(a.oauth){const{clientId:i,clientSecret:t,refreshToken:r}=a.oauth,s=new E({clientId:i,clientSecret:t}),n=new O({config:s});let l;const o=async()=>{await n.tokenStorage.store({accessToken:"",refreshToken:r})};return{authHandle:{ensureReady:()=>(l||(l=o()),l)},client:new u({auth:n})}}if(a.ccg){const{clientId:i,clientSecret:t,enterpriseId:r,userId:s}=a.ccg;if(!r&&!s)throw new Error("Box storage: `ccg` auth requires either `enterpriseId` or `userId`.");const n=new T({clientId:i,clientSecret:t,...r!==void 0&&{enterpriseId:r},...s!==void 0&&{userId:s}}),l=new b({config:n});return{authHandle:w,client:new u({auth:l})}}if(a.jwt){const i=j(a.jwt),t=new U({config:i});return{authHandle:w,client:new u({auth:t})}}const e=process.env.BOX_DEVELOPER_TOKEN;if(e){const i=new I({token:e});return{authHandle:w,client:new u({auth:i})}}throw new Error("Box storage: missing auth. Pass `client`, `developerToken`, `oauth`, `ccg`, or `jwt`. Env fallback: BOX_DEVELOPER_TOKEN.")},J=a=>{if(a&&typeof a=="object"){const e=a,i=e.responseInfo?.code??e.responseInfo?.body?.code;return e.responseInfo?.statusCode===404||i==="not_found"||i==="file_not_found"||i==="folder_not_found"||i==="trashed"}return!1},k=a=>{if(a&&typeof a=="object"){const e=a,i=e.responseInfo?.code??e.responseInfo?.body?.code;return e.responseInfo?.statusCode===409||i==="item_name_in_use"||i==="conflict"}return!1};class ee extends L{static name="box";checksumTypes=[];meta;authHandle;client;fileIdCache;folderIdCache;publicByDefault;rootFolderId;constructor(e){super(e),this.rootFolderId=e.rootFolderId??_,this.publicByDefault=e.publicByDefault??!1;const i=P(e);this.client=i.client,this.authHandle=i.authHandle,this.folderIdCache=new Map,this.fileIdCache=new Map,this.meta=e.metaStorage??new S(e.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(e,i){return this.instrumentOperation("create",async()=>{const t=new p(e);t.name=this.namingFunction(t),await this.validate(t);try{const r=await this.getMeta(t.id);if(r.bytesWritten>=0)return r}catch{}return t.bytesWritten=0,t.status=v(t),await this.saveMeta(t),await this.onCreate(t),t})}async write(e,i){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&D(t,e.size),!H(e,t))throw new Error("File part does not match");const r=await this.lock(e.id);try{if(R(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");await this.authHandle.ensureReady();const s=await N(e.body),n=t.name||t.id,{leaf:l,parents:o}=m(n),d=await this.resolveFolderId(o,{create:!0},i),c=await this.resolveExistingFileForUpload(n,d,l,i),h=await this.performUpload(c,d,l,s,i);h.id&&(this.fileIdCache.set(n,h.id),this.publicByDefault&&await this.ensureSharedLink(h.id,i)),t.bytesWritten=s.length,t.size=s.length,t.boxFileId=h.id,t.eTag=h.etag??void 0,t.ETag=h.etag??void 0}return t.status=v(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,r)}})}async delete({id:e},i){return this.instrumentOperation("delete",async()=>{let t;try{t=await this.getMeta(e)}catch{}const r=t?.name??e;await this.authHandle.ensureReady();try{const s=t?.boxFileId??await this.resolveFileId(r,i);await this.runOperation(i,()=>this.client.files.deleteFileById(s)),this.fileIdCache.delete(r)}catch(s){if(!J(s))throw s}return t?(t.status="deleted",await this.deleteMeta(t.id),await this.onDelete(t),t):Object.assign(new p({contentType:"application/octet-stream",metadata:{},originalName:e}),{id:e,name:e,status:"deleted"})})}async get({id:e},i){return this.instrumentOperation("get",async()=>{let t,r=e;try{t=await this.checkIfExpired(await this.getMeta(e)),r=t.name??e}catch{}await this.authHandle.ensureReady();const s=t?.boxFileId??await this.resolveFileId(r,i),n=await this.runOperation(i,()=>this.client.files.getFileById(s)),l=await this.runOperation(i,()=>this.client.downloads.getDownloadFileUrl(s)),o=await this.runOperation(i,()=>fetch(l));if(!o.ok)throw new Error(`Box: download fetch failed (${o.status})`);const d=await this.runOperation(i,()=>o.arrayBuffer()),c=Buffer.from(d);return{content:c,contentType:t?.contentType??"application/octet-stream",ETag:t?.ETag??n.etag??void 0,expiredAt:t?.expiredAt,id:e,metadata:t?.metadata??{},modifiedAt:t?.modifiedAt??n.modifiedAt??n.contentModifiedAt??void 0,name:t?.name??n.name??r,originalName:t?.originalName??n.name??r,size:t?.size??n.size??c.length}})}async copy(e,i,t){return this.instrumentOperation("copy",async()=>{await this.authHandle.ensureReady();const r=await this.resolveFileId(e,t),{leaf:s,parents:n}=m(i),l=await this.resolveFolderId(n,{create:!0},t),o=await this.runOperation(t,()=>this.client.files.copyFile(r,{name:s,parent:{id:l}}));o.id&&this.fileIdCache.set(i,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:i});return d.id=i,d.name=i,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0,d})}async move(e,i,t){return this.instrumentOperation("move",async()=>{await this.authHandle.ensureReady();const r=await this.resolveFileId(e,t),{leaf:s,parents:n}=m(i),l=await this.resolveFolderId(n,{create:!0},t),o=await this.runOperation(t,()=>this.client.files.updateFileById(r,{requestBody:{name:s,parent:{id:l}}}));this.fileIdCache.delete(e),o.id&&this.fileIdCache.set(i,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:i});d.id=i,d.name=i,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0;try{await this.deleteMeta(e)}catch{}return d})}async list(e=1e3,i){return this.instrumentOperation("list",async()=>{await this.authHandle.ensureReady();const t=[];let r=0;const s=Math.min(e,1e3);for(;t.length<e;){const n=(await this.runOperation(i,()=>this.client.folders.getFolderItems(this.rootFolderId,{queryParams:{fields:["id","name","size","modified_at","etag","type"],limit:s,offset:r}}))).entries??[];for(const l of n){const o=l;if(o.type!=="file"||!o.id||!o.name)continue;this.fileIdCache.set(o.name,o.id);const d=new p({contentType:"application/octet-stream",metadata:{},originalName:o.name});if(d.id=o.name,d.name=o.name,d.boxFileId=o.id,d.eTag=o.etag??void 0,d.ETag=o.etag??void 0,d.size=o.size??0,d.modifiedAt=o.modifiedAt??o.contentModifiedAt??void 0,t.push(d),t.length>=e)break}if(n.length<s)break;r+=n.length}return t},{limit:e})}async getReadUrl(e,i){if(i?.responseContentDisposition||i?.responseContentType)return C(B.METHOD_NOT_ALLOWED,"Box: `responseContentDisposition` / `responseContentType` are not supported — Box download URLs and shared-link URLs have no overrides.");await this.authHandle.ensureReady();const t=await this.resolveFileId(e);return this.publicByDefault?this.ensureSharedLink(t):this.client.downloads.getDownloadFileUrl(t)}async getUploadUrl(e,i){return C(B.METHOD_NOT_ALLOWED,"Box: `getUploadUrl` is not supported. Box uploads require a multipart POST with an `attributes` JSON part and a file bytes part; this doesn't fit the PUT-style upload-url contract. Use `write()` server-side, or the Box UI Elements / Box Content Uploader for browser flows.")}async findChildByName(e,i,t){let r=0;const s=1e3;for(;;){const n=(await this.runOperation(t,()=>this.client.folders.getFolderItems(e,{queryParams:{fields:["id","name","type"],limit:s,offset:r}}))).entries??[];for(const l of n){const o=l;if(o.name===i&&o.id&&o.type)return{id:o.id,type:o.type}}if(n.length<s)return;r+=n.length}}folderCacheKey(e){return e.join("/")}async resolveFolderId(e,i,t){if(e.length===0)return this.rootFolderId;const r=this.folderCacheKey(e),s=this.folderIdCache.get(r);if(s)return s;let n=this.rootFolderId;const l=[];for(const o of e){l.push(o);const d=this.folderCacheKey(l),c=this.folderIdCache.get(d);if(c){n=c;continue}const h=await this.findChildByName(n,o,t);if(h&&h.type==="folder"){n=h.id,this.folderIdCache.set(d,n);continue}if(h&&h.type!=="folder")throw new Error(`Box: path segment "${o}" exists but is not a folder`);if(!i.create)throw new Error(`Box: folder "${l.join("/")}" not found`);try{const f=await this.runOperation(t,()=>this.client.folders.createFolder({name:o,parent:{id:n}}));if(!f.id)throw new Error(`Box: createFolder did not return an id for "${o}"`);n=f.id,this.folderIdCache.set(d,n)}catch(f){if(k(f)){const y=await this.findChildByName(n,o,t);if(y&&y.type==="folder"){n=y.id,this.folderIdCache.set(d,n);continue}}throw f}}return this.folderIdCache.set(r,n),n}async resolveFileId(e,i){const t=this.fileIdCache.get(e);if(t)return t;const{leaf:r,parents:s}=m(e),n=await this.resolveFolderId(s,{create:!1},i),l=await this.findChildByName(n,r,i);if(!l||l.type!=="file")throw new Error(`Box: file "${e}" not found`);return this.fileIdCache.set(e,l.id),l.id}async resolveExistingFileForUpload(e,i,t,r){const s=this.fileIdCache.get(e);if(s)return s;const n=await this.findChildByName(i,t,r);if(n){if(n.type==="file")return this.fileIdCache.set(e,n.id),n.id;throw new Error(`Box: "${e}" already exists as a non-file (${n.type})`)}}async performUpload(e,i,t,r,s){if(r.byteLength>A)return await this.runOperation(s,()=>this.client.chunkedUploads.uploadBigFile(g(r),t,r.byteLength,i));if(e){const l=((await this.runOperation(s,()=>this.client.uploads.uploadFileVersion(e,{attributes:{name:t},file:g(r)}))).entries??[])[0];if(!l)throw new Error("Box: uploadFileVersion returned no file");return l}const n=((await this.runOperation(s,()=>this.client.uploads.uploadFile({attributes:{name:t,parent:{id:i}},file:g(r)}))).entries??[])[0];if(!n)throw new Error("Box: uploadFile returned no file");return n}async ensureSharedLink(e,i){try{const t=(await this.runOperation(i,()=>this.client.sharedLinksFiles.addShareLinkToFile(e,{sharedLink:{access:"open"}},{fields:"shared_link"}))).sharedLink;return(t?.downloadUrl??t?.url)||this.fetchSharedLinkUrl(e,i)}catch(t){if(k(t))return this.fetchSharedLinkUrl(e,i);throw t}}async fetchSharedLinkUrl(e,i){const t=(await this.runOperation(i,()=>this.client.sharedLinksFiles.getSharedLinkForFile(e,{fields:"shared_link"}))).sharedLink,r=t?.downloadUrl??t?.url;if(!r)throw new Error("Box: file has no shared link. Call write() with publicByDefault: true, or addShareLinkToFile via storage.raw.");return r}internalOnComplete=e=>this.deleteMeta(e.id)}export{ee as default};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class t extends e{bunS3ETag;bunS3Key}export{t as default};
@@ -1 +0,0 @@
1
- import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class t extends e{bunnyChecksum;bunnyPath}export{t as default};
@@ -1 +0,0 @@
1
- import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
@@ -1 +0,0 @@
1
- import*as c from"@bunny.net/storage-sdk";import{throwErrorCode as d,ERRORS as y,wrapStorageError as l}from"./ERRORS-BIBxE2oR.js";import{B as O}from"./storage-DR7qdwBN.js";import m from"./BunnyFile-BgEOlcYI.js";import T from"./BunnyMetaStorage-CJsyeQ63.js";import{t as w}from"./get-file-status-y3wTtDQs.js";import{t as N}from"./update-size-DuNuLyxj.js";import{i as A}from"./part-match-D-9dGX42.js";import{e as _}from"./has-content-50BsqrWw.js";const f=new Set(Object.values(c.regions.StorageRegion)),h=r=>`/${r.replace(/^\/+/u,"")}`,g=r=>r.replace(/^\/+/u,""),B=(r,t)=>{const n=r.replace(/\/+$/u,""),e=t.replace(/^\/+/u,"");return`${n}/${e}`},b=async r=>{const t=[];for await(const n of r)t.push(Buffer.from(n));return Buffer.concat(t)},E=r=>new ReadableStream({start(t){t.enqueue(new Uint8Array(r)),t.close()}}),R=r=>{if(r){if(!f.has(r))throw new Error(`Bunny Storage: unsupported region "${r}". Pass one of ${[...f].join(", ")}.`);return r}},C=r=>{if(r.client)return r.client;const t=r.zone??process.env.BUNNY_STORAGE_ZONE??process.env.STORAGE_ZONE,n=r.accessKey??process.env.BUNNY_STORAGE_ACCESS_KEY??process.env.BUNNY_ACCESS_KEY??process.env.STORAGE_ACCESS_KEY,e=R(r.region??process.env.BUNNY_STORAGE_REGION??process.env.STORAGE_REGION);if(!t||!n||!e)throw new Error("Bunny Storage: missing credentials. Pass `zone` + `accessKey` + `region`, or set BUNNY_STORAGE_ZONE / BUNNY_STORAGE_ACCESS_KEY / BUNNY_STORAGE_REGION (SDK aliases: STORAGE_ZONE / STORAGE_ACCESS_KEY / STORAGE_REGION).");return c.zone.connect_with_accesskey(e,t,n)},U=async r=>Buffer.from(await new Response(r).arrayBuffer()),p=(r,t)=>{const n=r?.message,e=typeof n=="string"?n:"";return/^file not found/iu.test(e)?l(r,{adapter:"Bunny Storage",operation:t,status:404}):/^unauthorized access/iu.test(e)?l(r,{adapter:"Bunny Storage",operation:t,status:401}):/^unable to upload file/iu.test(e)?l(r,{adapter:"Bunny Storage",operation:t,status:400}):l(r,{adapter:"Bunny Storage",operation:t})};class M extends O{static name="bunny";checksumTypes=["SHA256"];meta;client;publicBaseUrl;zoneName;constructor(t){super(t),this.client=C(t),this.zoneName=c.zone.name(this.client),this.publicBaseUrl=t.publicBaseUrl,this.meta=t.metaStorage??new T(t.metaStorageConfig),this.isReady=!0}get raw(){return this.client}get zone(){return this.zoneName}async create(t,n){return this.instrumentOperation("create",async()=>{const e=new m(t);e.name=this.namingFunction(e),e.bunnyPath=h(e.name),await this.validate(e);try{const a=await this.getMeta(e.id);if(a.bytesWritten>=0)return a}catch{}return e.bytesWritten=0,e.status=w(e),await this.saveMeta(e),await this.onCreate(e),e})}async write(t,n){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(t.size!==void 0&&N(e,t.size),!A(t,e))throw new Error("File part does not match");const a=await this.lock(t.id);try{if(_(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const i=await b(t.body),o=h(e.name||e.id);try{await this.runOperation(n,()=>c.file.upload(this.client,o,E(i),{contentType:e.contentType,...t.checksum&&t.checksumAlgorithm==="sha256"&&{sha256Checksum:t.checksum}}))}catch(s){throw p(s,"upload")}e.bytesWritten=i.length,e.size=i.length,e.bunnyPath=o}return e.status=w(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,a)}})}async delete({id:t},n){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const a=e?.bunnyPath??h(e?.name??t);try{await this.runOperation(n,()=>c.file.remove(this.client,a))}catch(o){throw p(o,"delete")}if(e)return e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e;const i=new m({contentType:"application/octet-stream",metadata:{},originalName:t});return i.id=t,i.name=t,i.bunnyPath=a,i.status="deleted",i})}async get({id:t},n){return this.instrumentOperation("get",async()=>{let e,a;try{e=await this.checkIfExpired(await this.getMeta(t)),a=e.bunnyPath??h(e.name??t)}catch{a=h(t)}let i;try{i=await this.runOperation(n,()=>c.file.get(this.client,a))}catch(s){throw p(s,"get")}let o;try{const s=await this.runOperation(n,()=>i.data());o=await U(s.stream)}catch(s){throw p(s,"download")}return{content:o,contentType:e?.contentType??i.contentType??"application/octet-stream",ETag:e?.ETag??i.checksum??void 0,expiredAt:e?.expiredAt,id:t,metadata:e?.metadata??{},modifiedAt:e?.modifiedAt??i.lastChanged?.toISOString(),name:e?.name??g(a),originalName:e?.originalName??g(a),size:e?.size??i.length??o.length}})}async copy(t,n,e){return this.instrumentOperation("copy",async()=>{const a=await this.get({id:t},e),i=h(n),o=a.content,s=typeof a.size=="string"?Number(a.size):a.size??o.length;try{await this.runOperation(e,()=>c.file.upload(this.client,i,E(o),{contentType:a.contentType}))}catch(S){throw p(S,"copy")}const u=new m({contentType:a.contentType,metadata:{},originalName:n});return u.id=n,u.name=n,u.bunnyPath=i,u.size=s,u.ETag=a.ETag,u.bunnyChecksum=a.ETag,u})}async move(t,n,e){return this.instrumentOperation("move",async()=>{const a=await this.copy(t,n,e);return await this.delete({id:t},e),a})}async list(t=1e3,n){return this.instrumentOperation("list",async()=>{let e;try{e=await this.runOperation(n,()=>c.file.list(this.client,"/"))}catch(a){throw p(a,"list")}return e.filter(a=>!a.isDirectory).slice(0,t).map(a=>{const i=a.path.endsWith(a.objectName)||!a.objectName?a.path:`${a.path.replace(/\/+$/u,"")}/${a.objectName}`,o=g(i),s=new m({contentType:a.contentType||"application/octet-stream",metadata:{},originalName:o});return s.id=o,s.name=o,s.bunnyPath=h(o),s.bunnyChecksum=a.checksum??void 0,s.ETag=a.checksum??void 0,s.size=a.length,s.modifiedAt=a.lastChanged?.toISOString(),s})},{limit:t})}async getReadUrl(t,n){return n?.responseContentDisposition!==void 0||n?.responseContentType!==void 0?d(y.METHOD_NOT_ALLOWED,"Bunny Storage: `responseContentDisposition`/`responseContentType` are not supported — no override exists on Bunny Storage / Pull Zone URLs."):this.publicBaseUrl?B(this.publicBaseUrl,t):d(y.METHOD_NOT_ALLOWED,"Bunny Storage: `getReadUrl` requires `publicBaseUrl` (for example a Bunny Pull Zone or custom CDN hostname). The Storage API URL itself requires an AccessKey header and cannot be handed out as a public URL.")}async getUploadUrl(t,n){return d(y.METHOD_NOT_ALLOWED,"Bunny Storage: presigned PUT URLs are not supported — writes go through the Storage API with an AccessKey header. Upload server-side via the SDK or proxy through your application.")}internalOnComplete=t=>this.deleteMeta(t.id)}export{M as default};
@@ -1 +0,0 @@
1
- import t from"./File-W8aOo15X.js";class a extends t{bucket;path;publicUrl}export{a as default};
@@ -1 +0,0 @@
1
- import{y as s}from"./local-meta-storage-BELb1YwO.js";class o extends s{constructor(r){super(r)}}export{o as default};
@@ -1 +0,0 @@
1
- import{v2 as p}from"cloudinary";import{throwErrorCode as u,ERRORS as l}from"./ERRORS-BIBxE2oR.js";import{B as d}from"./storage-DR7qdwBN.js";import c from"./CloudinaryFile-Bo5B-vM1.js";import h from"./CloudinaryMetaStorage-Bv_YCZ0Q.js";import{t as y}from"./get-file-status-y3wTtDQs.js";import{t as m}from"./update-size-DuNuLyxj.js";import{i as f}from"./part-match-D-9dGX42.js";import{e as w}from"./has-content-50BsqrWw.js";const v=async o=>{const e=[];for await(const a of o)e.push(Buffer.from(a));return Buffer.concat(e)},_=o=>{if(!o)return{};const e=o.match(/^cloudinary:\/\/([^:]+):([^@]+)@(.+)$/);return e?{apiKey:e[1],apiSecret:e[2],cloudName:e[3]}:{}};class M extends d{static name="cloudinary";checksumTypes=[];meta;client;defaultUrlExpiresIn;deliveryType;resourceType;secure;constructor(e){if(super(e),this.resourceType=e.resourceType??"raw",this.deliveryType=e.type??"upload",this.secure=e.secure??!0,this.defaultUrlExpiresIn=e.defaultUrlExpiresIn??3600,e.client)this.client=e.client;else{const a=_(process.env.CLOUDINARY_URL),t=e.cloudName??process.env.CLOUDINARY_CLOUD_NAME??a.cloudName,r=e.apiKey??process.env.CLOUDINARY_API_KEY??a.apiKey,i=e.apiSecret??process.env.CLOUDINARY_API_SECRET??a.apiSecret;if(!t)throw new Error("Cloudinary storage: `cloudName` is required (or set CLOUDINARY_CLOUD_NAME / CLOUDINARY_URL).");p.config({api_key:r,api_secret:i,cloud_name:t,secure:this.secure}),this.client=p}this.meta=e.metaStorage??new h(e.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(e,a){return this.instrumentOperation("create",async()=>{const t=new c(e);t.name=this.namingFunction(t),t.path=t.name,await this.validate(t);try{const r=await this.getMeta(t.id);if(r.bytesWritten>=0)return r}catch{}return t.bytesWritten=0,t.status=y(t),await this.saveMeta(t),await this.onCreate(t),t})}async write(e,a){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&m(t,e.size),!f(e,t))throw new Error("File part does not match");const r=await this.lock(e.id);try{if(w(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const i=await v(e.body),s=t.path??t.name,n=await this.runOperation(a,()=>this.uploadBuffer(s,i));t.bytesWritten=i.length,t.size=i.length,t.path=n.public_id??s,t.publicUrl=n.secure_url??n.url,t.ETag=n.version===void 0?void 0:String(n.version)}return t.status=y(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id,r)}})}async delete({id:e},a){return this.instrumentOperation("delete",async()=>{let t;try{t=await this.getMeta(e)}catch{}const r=t?.path??t?.name??e;return await this.runOperation(a,()=>this.client.uploader.destroy(r,{invalidate:!0,resource_type:this.resourceType,type:this.deliveryType})),t?(t.status="deleted",await this.deleteMeta(t.id),await this.onDelete(t),t):Object.assign(new c({contentType:"application/octet-stream",metadata:{},originalName:e}),{id:e,name:e,path:r,status:"deleted"})})}async exists({id:e},a){return this.instrumentOperation("exists",async()=>{let t=e;try{t=(await this.getMeta(e)).path??e}catch{}try{return await this.runOperation(a,()=>this.client.api.resource(t,{resource_type:this.resourceType,type:this.deliveryType})),!0}catch{return!1}})}async get({id:e},a){return this.instrumentOperation("get",async()=>{let t=e,r;try{r=await this.checkIfExpired(await this.getMeta(e)),t=r.path??r.name??e}catch{}const i=await this.runOperation(a,()=>this.client.api.resource(t,{resource_type:this.resourceType,type:this.deliveryType})),s=await this.runOperation(a,()=>fetch(this.client.url(t,{resource_type:this.resourceType,secure:this.secure,type:this.deliveryType})));if(!s.ok)throw new Error(`Cloudinary: object not found at "${t}"`);const n=Buffer.from(await s.arrayBuffer());return{content:n,contentType:r?.contentType??(i.resource_type&&i.format?`${i.resource_type}/${i.format}`:void 0)??"application/octet-stream",ETag:r?.ETag??(i.version===void 0?void 0:String(i.version)),expiredAt:r?.expiredAt,id:e,metadata:r?.metadata??{},modifiedAt:r?.modifiedAt,name:r?.name??t,originalName:r?.originalName??t,size:r?.size??(typeof i.bytes=="number"?i.bytes:n.length)}})}async copy(e,a,t){return this.instrumentOperation("copy",async()=>{const r=(await this.getMetaSafe(e))?.path??e,i=this.client.url(r,{resource_type:this.resourceType,secure:this.secure,type:this.deliveryType});await this.runOperation(t,()=>this.client.uploader.upload(i,{overwrite:!0,public_id:a,resource_type:this.resourceType,type:this.deliveryType}));const s=new c({contentType:"application/octet-stream",metadata:{},originalName:a});return s.id=a,s.name=a,s.path=a,s})}async move(e,a,t){return this.instrumentOperation("move",async()=>{const r=(await this.getMetaSafe(e))?.path??e;await this.runOperation(t,()=>this.client.uploader.rename(r,a,{resource_type:this.resourceType}));const i=new c({contentType:"application/octet-stream",metadata:{},originalName:a});i.id=a,i.name=a,i.path=a;try{await this.deleteMeta(e)}catch{}return i})}async list(e=1e3,a){return this.instrumentOperation("list",async()=>{const{resources:t}=await this.runOperation(a,()=>this.client.api.resources({max_results:e,resource_type:this.resourceType,type:this.deliveryType}));return(t??[]).map(r=>{const i=new c({contentType:r.resource_type&&r.format?`${r.resource_type}/${r.format}`:"application/octet-stream",metadata:{},originalName:r.public_id});return i.id=r.public_id,i.name=r.public_id,i.path=r.public_id,i.size=typeof r.bytes=="number"?r.bytes:void 0,i.createdAt=r.created_at??void 0,i.ETag=r.version===void 0?void 0:String(r.version),i})},{limit:e})}async getReadUrl(e,a){if(a?.responseContentDisposition!==void 0||a?.responseContentType!==void 0)return u(l.BAD_REQUEST,"cloudinary: `responseContentDisposition`/`responseContentType` are not supported. A public delivery URL has no signature in which to bind the override, and Cloudinary's signed download URL cannot pin an arbitrary Content-Disposition/Content-Type; set the disposition via a Cloudinary delivery transformation instead.");if(this.deliveryType==="upload")return this.client.url(e,{resource_type:this.resourceType,secure:this.secure,type:this.deliveryType});const t=a?.expiresIn??this.defaultUrlExpiresIn,r=e.lastIndexOf("."),i=r>0?e.slice(r+1):"";try{return this.client.utils.private_download_url(e,i,{expires_at:Math.floor(Date.now()/1e3)+t,resource_type:this.resourceType,type:this.deliveryType})}catch(s){return u(l.METHOD_NOT_ALLOWED,s instanceof Error?s.message:"Cloudinary: private_download_url failed")}}uploadBuffer(e,a){return new Promise((t,r)=>{this.client.uploader.upload_stream({overwrite:!0,public_id:e,resource_type:this.resourceType,type:this.deliveryType},(i,s)=>{if(i||!s){r(i instanceof Error?i:new Error(i?.message??"Cloudinary: upload failed"));return}t(s)}).end(a)})}async getMetaSafe(e){try{return await this.getMeta(e)}catch{return}}internalOnComplete=e=>this.deleteMeta(e.id)}export{M as default};
@@ -1 +0,0 @@
1
- import"node:fs";import"node:fs/promises";import"node:stream";import"./local-meta-storage-BELb1YwO.js";import"./path-C-OWflAo-_mqb5p5d.js";import"./index-nZWCQrSe.js";import"./detect-file-type-BA7UBLKA.js";import"./ERRORS-BIBxE2oR.js";import{w as c}from"./disk-storage-DqnnFQAQ.js";import"./storage-DR7qdwBN.js";import"./File-W8aOo15X.js";import"./get-file-status-y3wTtDQs.js";import"./update-size-DuNuLyxj.js";import"./part-match-D-9dGX42.js";import"./has-content-50BsqrWw.js";export{c as default};
@@ -1 +0,0 @@
1
- import{createReadStream as l,createWriteStream as y}from"node:fs";import{truncate as g}from"node:fs/promises";import{Transform as f,pipeline as w}from"node:stream";import{u as b,h as E}from"./local-meta-storage-BELb1YwO.js";import{d as F}from"./detect-file-type-BA7UBLKA.js";import{throwErrorCode as c,ERRORS as h}from"./ERRORS-BIBxE2oR.js";import{w as C,n as T,s as W}from"./disk-storage-DqnnFQAQ.js";import{LRUCache as N}from"lru-cache";import{createHash as S}from"node:crypto";import{t as R}from"./update-size-DuNuLyxj.js";import{i as x}from"./part-match-D-9dGX42.js";import{e as M}from"./has-content-50BsqrWw.js";import{t as _}from"./get-file-status-y3wTtDQs.js";class k extends f{constructor(t,e){super(),this.path=e,this.hashes=t,this.hash=this.hashes.get(e)||S(this.hashes.algorithm),this.hashCopy=this.hash.copy()}path;hash;hashCopy;hashes;reset(){this.hashes.set(this.path,this.hashCopy)}digest(t="hex"){return this.hash.copy().digest(t)}_transform(t,e,s){this.push(t),this.hash.update(t),s()}_flush(t){t()}}class I extends N{constructor(t="sha1",e){super({ttl:1e3,ttlAutopurge:!0,...e}),this.algorithm=t}algorithm;hex(t){return this.get(t)?.copy().digest("hex")||""}base64(t){return this.get(t)?.copy().digest("base64")||""}async init(t,e=0){return this.get(t)?.copy()||this.updateFromFs(t,e)}digester(t){return new k(this,t)}async updateFromFs(t,e=0,s){const r=await this.fromFs(t,e,s);return this.set(t,r),r}fromFs(t,e=0,s){return new Promise((r,i)=>{const a=this.digester(t);s!==void 0&&(a.hash=s),l(t,{start:e}).on("error",i).on("end",()=>{r(a.hash)}).pipe(a).resume()})}}class j extends C{hashes;constructor(t){super(t),this.hashes=new I(t?.checksum==="sha1"?"sha1":"md5")}async delete({id:t}){try{const e=await this.getMeta(t),s=this.getFilePath(e.name);this.hashes.delete(s),await b(s),await this.deleteMeta(t);const r={...e,status:"deleted"};return await this.onDelete(r),r}catch(e){this.logger?.error("[error]: Could not delete file: %O",e);const s=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(s)}return{id:t}}async write(t){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(t.size!==void 0&&R(e,t.size),!x(t,e))return c(h.FILE_CONFLICT);const s=this.getFilePath(e.name);try{const r=t.start||0;if(await E(s),(e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(e.bytesWritten=r),await this.hashes.init(s),M(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return c(h.UNSUPPORTED_CHECKSUM_ALGORITHM);if((t.start===0||t.start===void 0)&&(e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(!e.contentType||e.contentType==="application/octet-stream"))try{const{fileType:o,stream:n}=await F(t.body);o?.mime&&(e.contentType=o.mime),t.body=n}catch{}const[i,a]=await this.lazyWrite({...t,...e});if(a)return await g(s,e.bytesWritten),c(a);typeof i!="number"&&await this.hashes.updateFromFs(s,e.bytesWritten),e.bytesWritten=i}return e.status=_(e),e.hash={algorithm:this.hashes.algorithm,value:this.hashes.hex(s)},e.status==="completed"&&this.hashes.delete(s),await this.saveMeta(e),e}catch(r){await this.hashes.updateFromFs(s,e.bytesWritten);const i=this.normalizeError(r instanceof Error?r:new Error(String(r)));return await this.onError(i),c(h.FILE_ERROR,(typeof i.message=="string"?i.message:String(r))||String(r))}}lazyWrite(t){return new Promise((e,s)=>{const r=this.getFilePath(t.name),i=y(r,{flags:"r+",start:t.start}),a=new T(t.contentLength||Number(t.size)-t.start),o=W(t.checksum,t.checksumAlgorithm),n=this.hashes.digester(r),d=!t.checksum,u=m=>{n.reset(),i.close(),e([Number.NaN,m])};a.on("error",()=>{u(h.FILE_CONFLICT)}),o.on("error",()=>{u(h.CHECKSUM_MISMATCH)}),t.body.on("aborted",()=>{u(d?void 0:h.REQUEST_ABORTED)}),w(t.body,a,o,n,i,m=>{if(m){n.reset(),s(m);return}e([t.start+i.bytesWritten])})})}}export{j as default};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class t extends e{path;publicUrl;rev}export{t as default};
@@ -1 +0,0 @@
1
- import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
@@ -1 +0,0 @@
1
- import{DropboxResponseError as _,DropboxAuth as u,Dropbox as d}from"dropbox";import{throwErrorCode as m,ERRORS as y}from"./ERRORS-BIBxE2oR.js";import{c as E}from"./oauth-refresh-EdGzlcOZ.js";import{B as v}from"./storage-DR7qdwBN.js";import l from"./DropboxFile-BFb7eOzy.js";import A from"./DropboxMetaStorage-CJsyeQ63.js";import{t as g}from"./get-file-status-y3wTtDQs.js";import{t as D}from"./update-size-DuNuLyxj.js";import{i as S}from"./part-match-D-9dGX42.js";import{e as x}from"./has-content-50BsqrWw.js";const w=14400,B=150*1024*1024,p=8*1024*1024,k=(r,t)=>{r.auth.setAccessToken(t)},R=r=>r.auth.getAccessToken(),T=r=>{let t=0,n=r.length;for(;t<n&&r[t]==="/";)t+=1;for(;n>t&&r[n-1]==="/";)n-=1;return t===0&&n===r.length?r:r.slice(t,n)},H=async r=>{const t=[];for await(const n of r)t.push(Buffer.from(n));return Buffer.concat(t)},O=r=>r.includes("?dl=0")?r.replace("?dl=0","?dl=1"):r.includes("?dl=")?r:r+(r.includes("?")?"&dl=1":"?dl=1"),b=(r,t)=>(k(r,t),{ensureAccessToken:()=>Promise.resolve(),getAccessToken:()=>Promise.resolve(t)}),U=(r,t)=>{const n=async()=>{const e=await t();return k(r,e),e};return{async ensureAccessToken(){await n()},getAccessToken:n}},P=(r,t)=>{const n=E({buildBody:()=>new URLSearchParams({client_id:t.appKey,grant_type:"refresh_token",refresh_token:t.refreshToken,...t.appSecret&&{client_secret:t.appSecret}}),onRefresh:e=>{k(r,e)},provider:"Dropbox",tokenUrl:"https://api.dropboxapi.com/oauth2/token"});return{async ensureAccessToken(){await n.getAccessToken()},getAccessToken:()=>n.getAccessToken()}},C=r=>{if(r.client){const i=r.client;return{authHandle:{ensureAccessToken:()=>Promise.resolve(),getAccessToken:()=>Promise.resolve(R(i))},client:i}}const t=r.accessToken,n=r.refreshToken!==void 0||r.appKey!==void 0||r.appSecret!==void 0;if(t!==void 0&&n)throw new Error("Dropbox storage: pass exactly one of `accessToken` or `refreshToken` (with `appKey`).");if(t!==void 0){const i=new u({accessToken:typeof t=="string"?t:void 0}),s=new d({auth:i});return{authHandle:typeof t=="function"?U(s,t):b(s,t),client:s}}if(n){if(!r.refreshToken||!r.appKey)throw new Error("Dropbox storage: refresh-token auth requires both `refreshToken` and `appKey`.");const i=new u({}),s=new d({auth:i});return{authHandle:P(s,{appKey:r.appKey,...r.appSecret&&{appSecret:r.appSecret},refreshToken:r.refreshToken}),client:s}}const e=process.env.DROPBOX_ACCESS_TOKEN;if(e){const i=new u({accessToken:e}),s=new d({auth:i});return{authHandle:b(s,e),client:s}}const o=process.env.DROPBOX_REFRESH_TOKEN,a=process.env.DROPBOX_APP_KEY;if(o&&a){const i=process.env.DROPBOX_APP_SECRET,s=new u({}),h=new d({auth:s});return{authHandle:P(h,{appKey:a,...i&&{appSecret:i},refreshToken:o}),client:h}}throw new Error("Dropbox storage: missing auth. Pass `client`, `accessToken`, or `refreshToken` + `appKey`. Env fallbacks: DROPBOX_ACCESS_TOKEN, or DROPBOX_REFRESH_TOKEN + DROPBOX_APP_KEY (+ DROPBOX_APP_SECRET).")};class q extends v{static name="dropbox";checksumTypes=[];meta;authHandle;client;defaultUrlExpiresIn;publicByDefault;rootFolderPath;constructor(t){super(t),this.rootFolderPath=T(t.rootFolderPath??""),this.publicByDefault=t.publicByDefault??!1,this.defaultUrlExpiresIn=Math.min(t.defaultUrlExpiresIn??3600,w);const n=C(t);this.client=n.client,this.authHandle=n.authHandle,this.meta=t.metaStorage??new A(t.metaStorageConfig),this.isReady=!0}get raw(){return this.client}async create(t,n){return this.instrumentOperation("create",async()=>{const e=new l(t);e.name=this.namingFunction(e),e.path=this.keyToPath(e.name),await this.validate(e);try{const o=await this.getMeta(e.id);if(o.bytesWritten>=0)return o}catch{}return e.bytesWritten=0,e.status=g(e),await this.saveMeta(e),await this.onCreate(e),e})}async write(t,n){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(t.size!==void 0&&D(e,t.size),!S(t,e))throw new Error("File part does not match");const o=await this.lock(t.id);try{if(x(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const a=await H(t.body),i=e.path??this.keyToPath(e.name||e.id);await this.authHandle.ensureAccessToken();const s=a.byteLength<=B?await this.uploadSimple(i,a,n):await this.uploadSession(i,a,n);e.bytesWritten=a.length,e.size=a.length,e.path=s.path_display??i,e.rev=s.rev,e.ETag=s.rev}return e.status=g(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,o)}})}async delete({id:t},n){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const o=e?.path??this.keyToPath(e?.name??t);await this.authHandle.ensureAccessToken();try{await this.runOperation(n,()=>this.client.filesDeleteV2({path:o}))}catch(a){if(!L(a))throw a}return e?(e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e):Object.assign(new l({contentType:"application/octet-stream",metadata:{},originalName:t}),{id:t,name:t,path:o,status:"deleted"})})}async get({id:t},n){return this.instrumentOperation("get",async()=>{let e,o=this.keyToPath(t);try{e=await this.checkIfExpired(await this.getMeta(t)),o=e.path??this.keyToPath(e.name??t)}catch{}await this.authHandle.ensureAccessToken();const a=(await this.runOperation(n,()=>this.client.filesDownload({path:o}))).result;let i;if(a.fileBinary instanceof Uint8Array)i=Buffer.from(a.fileBinary.buffer,a.fileBinary.byteOffset,a.fileBinary.byteLength);else if(a.fileBlob instanceof Blob)i=Buffer.from(await a.fileBlob.arrayBuffer());else throw new TypeError("Dropbox: unexpected download response shape — neither fileBinary nor fileBlob present");return{content:i,contentType:e?.contentType??"application/octet-stream",ETag:e?.ETag??a.rev,expiredAt:e?.expiredAt,id:t,metadata:e?.metadata??{},modifiedAt:e?.modifiedAt??a.server_modified,name:e?.name??a.name,originalName:e?.originalName??a.name,size:e?.size??a.size??i.length}})}async copy(t,n,e){return this.instrumentOperation("copy",async()=>{const o=this.keyToPath(t),a=this.keyToPath(n);await this.authHandle.ensureAccessToken(),await this.runOperation(e,()=>this.client.filesCopyV2({from_path:o,to_path:a}));const i=new l({contentType:"application/octet-stream",metadata:{},originalName:n});return i.id=n,i.name=n,i.path=a,i})}async move(t,n,e){return this.instrumentOperation("move",async()=>{const o=this.keyToPath(t),a=this.keyToPath(n);await this.authHandle.ensureAccessToken(),await this.runOperation(e,()=>this.client.filesMoveV2({from_path:o,to_path:a}));const i=new l({contentType:"application/octet-stream",metadata:{},originalName:n});i.id=n,i.name=n,i.path=a;try{await this.deleteMeta(t)}catch{}return i})}async list(t=1e3,n){return this.instrumentOperation("list",async()=>{await this.authHandle.ensureAccessToken();const e=await this.runOperation(n,()=>this.client.filesListFolder({limit:t,path:this.rootFolderPath?`/${this.rootFolderPath}`:"",recursive:!0})),{result:o}=e,a=[];for(const i of o.entries){if(i[".tag"]!=="file")continue;const s=i,h=s.path_display??s.path_lower??`/${s.name}`,f=this.pathToKey(h);if(!f)continue;const c=new l({contentType:"application/octet-stream",metadata:{},originalName:s.name});c.id=f,c.name=f,c.path=h,c.size=s.size,c.rev=s.rev,c.ETag=s.rev,c.modifiedAt=s.server_modified,a.push(c)}return a},{limit:t})}async getReadUrl(t,n){if(n?.responseContentDisposition!==void 0||n?.responseContentType!==void 0)return m(y.METHOD_NOT_ALLOWED,"Dropbox: `responseContentDisposition`/`responseContentType` are not supported — Dropbox temporary links have no Content-Disposition/Content-Type override.");const e=n?.expiresIn??this.defaultUrlExpiresIn;return e>w?m(y.METHOD_NOT_ALLOWED,`Dropbox: \`expiresIn\` of ${e}s exceeds the ${w}s (4h) maximum. Use \`publicByDefault: true\` for a permanent shared link.`):(await this.authHandle.ensureAccessToken(),this.publicByDefault?await this.createPublicSharedLink(t):(await this.client.filesGetTemporaryLink({path:this.keyToPath(t)})).result.link)}async getUploadUrl(t,n){return m(y.METHOD_NOT_ALLOWED,"Dropbox: presigned upload URLs use POST with a raw body, which doesn't fit the PUT-style upload-url contract. Use `write()` or `storage.raw.filesGetTemporaryUploadLink(...)` directly.")}keyToPath(t){const n=T(t),e=[];return this.rootFolderPath&&e.push(this.rootFolderPath),n&&e.push(n),e.length===0?"":`/${e.join("/")}`}pathToKey(t){const n=T(t);if(!this.rootFolderPath)return n;if(n===this.rootFolderPath)return"";const e=`${this.rootFolderPath}/`;return n.startsWith(e)?n.slice(e.length):n}async uploadSimple(t,n,e){return(await this.runOperation(e,()=>this.client.filesUpload({contents:n,mode:{".tag":"overwrite"},mute:!0,path:t}))).result}async uploadSession(t,n,e){const o=n.byteLength;let a=0;const i=(await this.runOperation(e,()=>this.client.filesUploadSessionStart({close:!1,contents:n.subarray(a,Math.min(a+p,o))}))).result.session_id;for(a=Math.min(a+p,o);o-a>p;){const h=n.subarray(a,a+p);await this.runOperation(e,()=>this.client.filesUploadSessionAppendV2({close:!1,contents:h,cursor:{offset:a,session_id:i}})),a+=p}const s=n.subarray(a,o);return(await this.runOperation(e,()=>this.client.filesUploadSessionFinish({commit:{mode:{".tag":"overwrite"},mute:!0,path:t},contents:s,cursor:{offset:a,session_id:i}}))).result}async createPublicSharedLink(t){try{const n=await this.client.sharingCreateSharedLinkWithSettings({path:this.keyToPath(t),settings:{requested_visibility:{".tag":"public"}}});return O(n.result.url)}catch(n){if(n instanceof _){const e=n.error?.shared_link_already_exists?.metadata?.url;if(typeof e=="string"&&e.length>0)return O(e)}throw n}}internalOnComplete=t=>this.deleteMeta(t.id)}const L=r=>{if(!(r instanceof _))return!1;if(r.status===404)return!0;const t=[],n=(e,o)=>{if(o>6||e===null||typeof e!="object")return;const a=e,i=a[".tag"];typeof i=="string"&&t.push(i);for(const s of Object.values(a))s&&typeof s=="object"&&n(s,o+1)};return n(r.error,0),t.includes("not_found")||t.includes("not_file")||t.includes("not_folder")};export{q as default};
@@ -1 +0,0 @@
1
- import p from"@sindresorhus/fnv1a";import{nanoid as f}from"nanoid";const y=t=>p(t,{size:64}).toString(16),d=t=>{if(typeof t.mimeType=="string")return t.mimeType;if(typeof t.type=="string")return t.type;if(typeof t.filetype=="string")return t.filetype},g=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},l=t=>{const{metadata:r,originalName:n,size:a}=t,e=String(r.lastModified??Date.now());return[n,a,e].filter(Boolean).map(String).map(s=>y(s)).join("-")};class c{bytesWritten=Number.NaN;contentType;originalName;id;metadata;name="";size;status;expiredAt;createdAt;modifiedAt;hash;content;ETag;constructor({contentType:r,expiredAt:n,id:a,metadata:e,originalName:s,size:o}){this.metadata=e;let i=a||void 0,m=s||g(e);m||(i??=f(),m=i),i!==void 0&&(this.id=i),this.originalName=m,this.contentType=r||d(e)||"application/octet-stream",this.expiredAt=n,typeof o=="string"||typeof o=="number"?this.size=Number(o):(typeof e.size=="string"||typeof e.size=="number")&&(this.size=Number(e.size)),typeof this.size=="number"&&this.size<=0&&(this.size=void 0),this.id||=l(this)}}export{c as default};
@@ -1 +0,0 @@
1
- import{PassThrough as K}from"node:stream";import{B as f}from"./storage-DR7qdwBN.js";import{throwErrorCode as R,ERRORS as P}from"./ERRORS-BIBxE2oR.js";import{n as D,a as H,m as z,b as L,s as T,r as O,t as u,c as w,D as v}from"./internal-D_cZIFwI.js";class U{adapter;defaults;hooks;prefix;readonlyMode;constructor(t){this.adapter=t.adapter,this.defaults=t.defaults??{},this.hooks=t.hooks??{},this.prefix=D(t.prefix??""),this.readonlyMode=t.readonly??!1}get capabilities(){return{cacheControl:this.adapter.supportsCacheControl,metadata:this.adapter.supportsMetadata,range:this.adapter.supportsRange,readonly:this.readonlyMode}}readonly(){return new U({adapter:this.adapter,defaults:this.defaults,hooks:this.hooks,prefix:this.prefix,readonly:!0})}assertWritable(){this.readonlyMode&&R(P.READ_ONLY,"This Files instance is read-only")}get raw(){return this.adapter.raw}resolveKey(t){const e=t.replace(/^\/+/u,"");return H(e,"key"),this.prefix?`${this.prefix}/${e}`:e}stripPrefix(t){const e=t.startsWith("/")?t.slice(1):t;if(!this.prefix)return e;const s=`${this.prefix}/`;return e.startsWith(s)?e.slice(s.length):null}mergeOptions(t,e){const s=z(this.defaults,t);if(!e||!this.hooks.onRetry)return s;const i=s?.retries,r=typeof i=="number"?{maxRetries:i}:{...i},p=r.onRetry,c=this.hooks.onRetry;return r.onRetry=(a,o)=>{if(p)try{p(a,o)}catch{}try{const n=typeof o=="string"?o:"Unknown error",l=o instanceof Error?o:new Error(n,{cause:o});c({...e,attempt:a,error:l})}catch{}},{...s,retries:r}}emitAction(t,e){if(this.hooks.onAction)try{this.hooks.onAction({type:t,...e})}catch{}}emitError(t,e,s){if(this.hooks.onError)try{this.hooks.onError({error:s,type:t,...e})}catch{}}async withHooks(t,e,s){const i=Date.now();try{const r=await s();return this.emitAction(t,{...e,durationMs:Date.now()-i}),r}catch(r){const p=typeof r=="string"?r:"Unknown error",c=r instanceof Error?r:new Error(p,{cause:r});throw this.emitError(t,{...e,durationMs:Date.now()-i},c),c}}async upload(t,e,s){return Array.isArray(t)?this.uploadMany(t,e):this.uploadOne(t,e,s)}async uploadOne(t,e,s){this.assertWritable(),s?.metadata&&Object.keys(s.metadata).length>0&&!this.adapter.supportsMetadata&&R(P.METHOD_NOT_ALLOWED,`Adapter ${this.adapter.constructor.name} does not persist custom metadata`);const i=s?.control;return this.withHooks("upload",{key:t},async()=>{const r=this.resolveKey(t);f.assertSafeId(r);const{size:p,stream:c}=await L(e,s?.size),a=s?.size??p,o={...s?.metadata??{},name:r,...s?.contentType?{type:s.contentType}:{},...a===void 0?{}:{size:a}},n=i?{...s,signal:s?.signal?AbortSignal.any([s.signal,i.signal]):i.signal}:s,l=this.mergeOptions(n,{key:t,type:"upload"}),d=s?.multipart;i?._bind(c,t);const h=await this.adapter.create({contentType:s?.contentType,id:r,metadata:o,originalName:r,size:a,storageClass:s?.storageClass},l),y=this.adapter.reportsUploadProgress,g=s?.onProgress,x=!!g||!!i;let m=c;if(x&&!y){let M=0;const C=new K;a!==void 0&&g&&T(g,{loaded:0,total:a}),c.on("data",b=>{const I=typeof b=="string"?Buffer.byteLength(b):b.byteLength;M+=I,i?._progress(M),g&&T(g,{loaded:M,total:a})}),c.pipe(C),m=C}const k={body:m,contentLength:a,id:h.id,start:0,...s?.checksum!==void 0&&{checksum:s.checksum},...s?.checksumAlgorithm!==void 0&&{checksumAlgorithm:s.checksumAlgorithm},...d!==void 0&&{multipart:d},...y&&g&&{onProgress:g}},A=await this.adapter.write(k,l);i?._complete();const E=w(A,r),S=this.stripPrefix(E.key);return S!==null&&(E.key=S),E})}async uploadMany(t,e){this.assertWritable();const{concurrency:s=v,multipart:i,onProgress:r,stopOnError:p=!1,...c}=e??{},a=await O(t,async({body:l,key:d,...h})=>{const y=h.onProgress??(r?g=>{r({...g,key:d})}:void 0);return this.uploadOne(d,l,{...c,multipart:i,...h,...y&&{onProgress:y}})},{concurrency:s,signal:c.signal,stopOnError:p}),o=[],n=[];for(const[l,d]of a.entries()){const h=t[l];if(!d){n.push(u(h.key,new Error("Operation skipped (stopOnError)")));continue}d.status==="fulfilled"?o.push(d.value):n.push(u(h.key,d.reason))}return n.length>0?{errors:n,uploaded:o}:{uploaded:o}}async download(t,e){return Array.isArray(t)?this.downloadMany(t,e):this.downloadOne(t,e)}assertRangeSupported(t){if(t){if(!Number.isFinite(t.start)||t.start<0)throw new TypeError(`Invalid range.start: ${String(t.start)}`);if(t.end!==void 0&&(!Number.isFinite(t.end)||t.end<t.start))throw new TypeError(`Invalid range.end: ${String(t.end)}`);if(!this.adapter.supportsRange)throw new Error(`Adapter ${this.adapter.constructor.name} does not support range downloads`)}}async downloadOne(t,e){return this.withHooks("download",{key:t},async()=>{const s=this.resolveKey(t);f.assertSafeId(s),this.assertRangeSupported(e?.range);const i=this.mergeOptions(e,{key:t,type:"download"})??{},r=e?.range?{...i,range:e.range}:i,p=await this.adapter.get({id:s},r);return{body:p.content,contentType:p.contentType??"application/octet-stream",etag:p.ETag,key:t,lastModified:p.modifiedAt,metadata:p.metadata,size:typeof p.size=="number"?p.size:void 0}})}async downloadMany(t,e){const{concurrency:s=v,range:i,stopOnError:r=!1,...p}=e??{},c=await O(t,async n=>this.downloadOne(n,i?{...p,range:i}:p),{concurrency:s,signal:p.signal,stopOnError:r}),a=[],o=[];for(const[n,l]of c.entries()){const d=t[n];if(!l){o.push(u(d,new Error("Operation skipped (stopOnError)")));continue}l.status==="fulfilled"?a.push(l.value):o.push(u(d,l.reason))}return o.length>0?{downloaded:a,errors:o}:{downloaded:a}}async downloadStream(t,e){return this.withHooks("download",{key:t},async()=>{const s=this.resolveKey(t);f.assertSafeId(s);const i=this.mergeOptions(e,{key:t,type:"download"}),{headers:r,size:p,stream:c}=await this.adapter.getStream({id:s},i),a=l=>r?Object.entries(r).find(([d])=>d.toLowerCase()===l.toLowerCase())?.[1]:void 0,o=a("Content-Length"),n=p??(o===void 0?void 0:Number(o));return{body:c,contentType:a("Content-Type")??"application/octet-stream",etag:a("ETag"),key:t,lastModified:a("Last-Modified"),size:typeof n=="number"&&Number.isFinite(n)?n:void 0}})}async head(t,e){return Array.isArray(t)?this.headMany(t,e):this.headOne(t,e)}async headOne(t,e){return this.withHooks("head",{key:t},async()=>{const s=this.resolveKey(t);f.assertSafeId(s);const i=await this.adapter.getMeta(s,this.mergeOptions(e,{key:t,type:"head"})),r=w(i,s);return r.key=t,r})}async headMany(t,e){const{concurrency:s=v,stopOnError:i=!1,...r}=e??{},p=await O(t,async o=>this.headOne(o,r),{concurrency:s,signal:r.signal,stopOnError:i}),c=[],a=[];for(const[o,n]of p.entries()){const l=t[o];if(!n){a.push(u(l,new Error("Operation skipped (stopOnError)")));continue}n.status==="fulfilled"?c.push(n.value):a.push(u(l,n.reason))}return a.length>0?{errors:a,files:c}:{files:c}}async exists(t,e){return Array.isArray(t)?this.existsMany(t,e):this.existsOne(t,e)}async existsOne(t,e){return this.withHooks("exists",{key:t},async()=>{const s=this.resolveKey(t);return f.assertSafeId(s),this.adapter.exists({id:s},this.mergeOptions(e,{key:t,type:"exists"}))})}async existsMany(t,e){const{concurrency:s=v,stopOnError:i=!1,...r}=e??{},p=await O(t,async n=>this.existsOne(n,r),{concurrency:s,signal:r.signal,stopOnError:i}),c=[],a=[],o=[];for(const[n,l]of p.entries()){const d=t[n];if(!l){o.push(u(d,new Error("Operation skipped (stopOnError)")));continue}l.status==="fulfilled"?l.value?c.push(d):a.push(d):o.push(u(d,l.reason))}return o.length>0?{errors:o,existing:c,missing:a}:{existing:c,missing:a}}async delete(t,e){if(this.assertWritable(),Array.isArray(t))return this.deleteMany(t,e);await this.deleteOne(t,e)}async deleteOne(t,e){await this.withHooks("delete",{key:t},async()=>{const s=this.resolveKey(t);f.assertSafeId(s),await this.adapter.delete({id:s},this.mergeOptions(e,{key:t,type:"delete"}))})}async deleteMany(t,e){const{concurrency:s=v,stopOnError:i=!1,...r}=e??{},p=this.mergeOptions(r,{keys:t,type:"delete"});if(!i&&typeof this.adapter.deleteBatch=="function"){const n=[],l=[],d=[];for(const h of t)try{const y=this.resolveKey(h);f.assertSafeId(y),n.push(h),l.push(y)}catch(y){d.push(u(h,y))}return this.withHooks("delete",{keys:n},async()=>{const h=l.length>0?await this.adapter.deleteBatch(l,p):{failed:[],successful:[]},y=new Map(l.map((m,k)=>[m,k])),g=h.successful.map(m=>this.stripPrefix(m.id)??m.id),x=[...d,...h.failed.map(({error:m,id:k})=>{const A=y.get(k),E=A===void 0?k:n[A];return u(E,new Error(m))})];return x.length>0?{deleted:g,errors:x}:{deleted:g}})}const c=await O(t,async n=>this.deleteOne(n,r),{concurrency:s,signal:r.signal,stopOnError:i}),a=[],o=[];for(const[n,l]of c.entries()){const d=t[n];if(!l){o.push(u(d,new Error("Operation skipped (stopOnError)")));continue}l.status==="fulfilled"?a.push(d):o.push(u(d,l.reason))}return o.length>0?{deleted:a,errors:o}:{deleted:a}}async copy(t,e,s){return this.assertWritable(),this.withHooks("copy",{from:t,to:e},async()=>{const i=this.resolveKey(t),r=this.resolveKey(e);f.assertSafeId(i),f.assertSafeId(r);const p=await this.adapter.copy(i,r,{...this.mergeOptions(s,{from:t,to:e,type:"copy"}),storageClass:s?.storageClass}),c=w(p,r);return c.key=e,c})}async move(t,e,s){return this.assertWritable(),Array.isArray(t)?this.moveMany(t,e):this.moveOne(t,e,s)}async moveOne(t,e,s){return this.withHooks("move",{from:t,to:e},async()=>{const i=this.resolveKey(t);if(f.assertSafeId(i),t===e){const o=await this.adapter.getMeta(i,this.mergeOptions(s,{from:t,to:e,type:"move"})),n=w(o,i);return n.key=t,n}const r=this.resolveKey(e);f.assertSafeId(r);const p={...this.mergeOptions(s,{from:t,to:e,type:"move"}),...s?.storageClass!==void 0&&{storageClass:s.storageClass}},c=await this.adapter.move(i,r,p),a=w(c,r);return a.key=e,a})}async moveMany(t,e){const{concurrency:s=v,stopOnError:i=!1,...r}=e??{},p=await O(t,async({from:o,to:n})=>this.moveOne(o,n,r),{concurrency:s,signal:r.signal,stopOnError:i}),c=[],a=[];for(const[o,n]of p.entries()){const l=t[o];if(!n){a.push(u(l.from,new Error("Operation skipped (stopOnError)")));continue}n.status==="fulfilled"?c.push(n.value):a.push(u(l.from,n.reason))}return a.length>0?{errors:a,moved:c}:{moved:c}}async list(t={}){return this.withHooks("list",{},async()=>{const{delimiter:e,limit:s,prefix:i,...r}=t;if(e!==void 0&&this.adapter.supportsDelimiter)return this.listDirectoryNative(e,i,s,r);const p=await this.adapter.list(s??1e3,this.mergeOptions(r,{type:"list"})),c=[];for(const d of p){const h=w(d),y=this.stripPrefix(h.key);y!==null&&(h.key=y,c.push(h))}const a=i?c.filter(d=>d.key.startsWith(i)):c;if(e===void 0)return a;const o=i??"",n=[],l=new Set;for(const d of a){const h=d.key.slice(o.length),y=h.indexOf(e);y===-1?n.push(d):l.add(o+h.slice(0,y+e.length))}return{files:n,prefixes:[...l].toSorted()}})}async listDirectoryNative(t,e,s,i){const r=[this.prefix,e].filter(Boolean).join("/"),{files:p,prefixes:c}=await this.adapter.listDirectory({delimiter:t,...s!==void 0&&{limit:s},...r&&{prefix:r},...this.mergeOptions(i,{type:"list"})}),a=[];for(const n of p){const l=w(n),d=this.stripPrefix(l.key);d!==null&&(l.key=d,a.push(l))}const o=[];for(const n of c){const l=this.stripPrefix(n);l!==null&&o.push(l)}return{files:a,prefixes:o.toSorted()}}async*listAll(t={}){const{limit:e,prefix:s,...i}=t,r=Math.max(1,e??1e3),p=Date.now(),c=new Set;let a;try{for(;;){const o=await this.adapter.list(r,this.mergeOptions(i,{type:"listAll"}));let n=0;for(const l of o){const d=w(l),h=this.stripPrefix(d.key);h!==null&&(d.key=h,!(s&&!d.key.startsWith(s))&&(c.has(d.key)||(c.add(d.key),n+=1,yield d)))}if(n===0||o.length<r)break}}catch(o){const n=typeof o=="string"?o:"Unknown error";throw a=o instanceof Error?o:new Error(n,{cause:o}),a}finally{const o=Date.now()-p;a?this.emitError("listAll",{durationMs:o},a):this.emitAction("listAll",{durationMs:o})}}async url(t,e){return this.withHooks("url",{key:t},async()=>{const s=this.resolveKey(t);return f.assertSafeId(s),this.adapter.getReadUrl(s,{...this.mergeOptions(e,{key:t,type:"url"}),...e})})}async signedUploadUrl(t,e){return this.assertWritable(),this.withHooks("signedUploadUrl",{key:t},async()=>{const s=this.resolveKey(t);return f.assertSafeId(s),this.adapter.getUploadUrl(s,{...this.mergeOptions(e,{key:t,type:"signedUploadUrl"}),...e})})}}export{U as Files};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class c extends e{bucket;path;publicUrl}export{c as default};
@@ -1 +0,0 @@
1
- import{y as s}from"./local-meta-storage-BELb1YwO.js";class o extends s{constructor(r){super(r)}}export{o as default};
@@ -1,2 +0,0 @@
1
- import{readFileSync as y}from"node:fs";import{getApps as g,getApp as m,initializeApp as E,cert as w}from"firebase-admin/app";import{getStorage as b}from"firebase-admin/storage";import{throwErrorCode as u,ERRORS as l}from"./ERRORS-BIBxE2oR.js";import{B as O}from"./storage-DR7qdwBN.js";import c from"./FirebaseFile-BLaBxa2A.js";import T from"./FirebaseMetaStorage-Bv_YCZ0Q.js";import{t as d}from"./get-file-status-y3wTtDQs.js";import{t as k}from"./update-size-DuNuLyxj.js";import{i as A}from"./part-match-D-9dGX42.js";import{e as I}from"./has-content-50BsqrWw.js";const v=3600,S=async o=>{const t=[];for await(const a of o)t.push(Buffer.from(a));return Buffer.concat(t)},U=o=>typeof o=="object"&&o!==null&&typeof o.file=="function"&&typeof o.getFiles=="function";class f extends O{static name="firebase";checksumTypes=[];meta;bucket;bucketName;defaultUrlExpiresIn;publicBaseUrl;constructor(t){if(super(t),this.defaultUrlExpiresIn=t.defaultUrlExpiresIn??v,this.publicBaseUrl=t.publicBaseUrl?.replace(/\/+$/,""),t.app&&U(t.app))this.bucket=t.app,this.bucketName=t.app.name??"";else{const a=t.bucket??process.env.FIREBASE_STORAGE_BUCKET;if(!a)throw new Error("Firebase storage: `bucket` is required (or set FIREBASE_STORAGE_BUCKET).");this.bucketName=a;const e=t.app??f.resolveApp(t,a);this.bucket=b(e).bucket(a)}this.meta=t.metaStorage??new T(t.metaStorageConfig),this.isReady=!0}get raw(){return this.bucket}async create(t,a){return this.instrumentOperation("create",async()=>{const e=new c(t);e.name=this.namingFunction(e),e.bucket=this.bucketName,e.path=e.name,await this.validate(e);try{const i=await this.getMeta(e.id);if(i.bytesWritten>=0)return i}catch{}return e.bytesWritten=0,e.status=d(e),await this.saveMeta(e),await this.onCreate(e),e})}async write(t,a){return this.instrumentOperation("write",async()=>{let e;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?e=t:(e=await this.getMeta(t.id),await this.checkIfExpired(e)),e.status==="completed")return e;if(t.size!==void 0&&k(e,t.size),!A(t,e))throw new Error("File part does not match");const i=await this.lock(t.id);try{if(I(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const n=await S(t.body),s=e.path??e.name;await this.runOperation(a,()=>this.bucket.file(s).save(n,{contentType:e.contentType,resumable:!1})),e.bytesWritten=n.length,e.size=n.length,e.path=s}return e.status=d(e),e.status==="completed"&&await this.internalOnComplete(e),await this.saveMeta(e),e}finally{await this.unlock(t.id,i)}})}async delete({id:t},a){return this.instrumentOperation("delete",async()=>{let e;try{e=await this.getMeta(t)}catch{}const i=e?.path??e?.name??t;return await this.runOperation(a,()=>this.bucket.file(i).delete({ignoreNotFound:!0})),e?(e.status="deleted",await this.deleteMeta(e.id),await this.onDelete(e),e):Object.assign(new c({contentType:"application/octet-stream",metadata:{},originalName:t}),{bucket:this.bucketName,id:t,name:t,path:i,status:"deleted"})})}async exists({id:t},a){return this.instrumentOperation("exists",async()=>{let e=t;try{e=(await this.getMeta(t)).path??t}catch{}try{const[i]=await this.runOperation(a,()=>this.bucket.file(e).exists());return i}catch{return!1}})}async get({id:t},a){return this.instrumentOperation("get",async()=>{let e=t,i;try{i=await this.checkIfExpired(await this.getMeta(t)),e=i.path??i.name??t}catch{}const n=this.bucket.file(e),[s]=await this.runOperation(a,()=>n.download());let r={};try{[r]=await this.runOperation(a,()=>n.getMetadata())}catch{}return{content:s,contentType:i?.contentType??r.contentType??"application/octet-stream",ETag:i?.ETag??r.etag,expiredAt:i?.expiredAt,id:t,metadata:i?.metadata??{},modifiedAt:i?.modifiedAt??r.updated,name:i?.name??e,originalName:i?.originalName??e,size:i?.size??(r.size===void 0?s.length:Number(r.size))}})}async copy(t,a,e){return this.instrumentOperation("copy",async()=>{const i=(await this.getMetaSafe(t))?.path??t;await this.runOperation(e,()=>this.bucket.file(i).copy(this.bucket.file(a)));const n=new c({contentType:"application/octet-stream",metadata:{},originalName:a});return n.id=a,n.name=a,n.path=a,n.bucket=this.bucketName,n})}async move(t,a,e){return this.instrumentOperation("move",async()=>{const i=(await this.getMetaSafe(t))?.path??t;await this.runOperation(e,()=>this.bucket.file(i).move(a));const n=new c({contentType:"application/octet-stream",metadata:{},originalName:a});n.id=a,n.name=a,n.path=a,n.bucket=this.bucketName;try{await this.deleteMeta(t)}catch{}return n})}async list(t=1e3,a){return this.instrumentOperation("list",async()=>{const[e]=await this.runOperation(a,()=>this.bucket.getFiles({maxResults:t}));return(e??[]).map(i=>{const n=new c({contentType:"application/octet-stream",metadata:{},originalName:i.name});return n.id=i.name,n.name=i.name,n.path=i.name,n.bucket=this.bucketName,n})},{limit:t})}async getReadUrl(t,a){if(this.publicBaseUrl)return a?.responseContentDisposition!==void 0||a?.responseContentType!==void 0?u(l.BAD_REQUEST,"Firebase: `responseContentDisposition`/`responseContentType` are not supported when `publicBaseUrl` is configured — a static public URL has no signature in which to bind the override."):`${this.publicBaseUrl}/${t}`;const e=a?.expiresIn??this.defaultUrlExpiresIn;try{const[i]=await this.bucket.file(t).getSignedUrl({action:"read",expires:Date.now()+e*1e3,...a?.responseContentDisposition!==void 0&&{responseDisposition:a.responseContentDisposition},...a?.responseContentType!==void 0&&{responseType:a.responseContentType}});return i}catch(i){return u(l.METHOD_NOT_ALLOWED,i instanceof Error?i.message:"Firebase: getSignedUrl failed")}}async getUploadUrl(t,a){if(a?.contentLength!==void 0)return u(l.BAD_REQUEST,"Firebase: `contentLength` is not supported for upload URLs. A GCS signed PUT has no content-length-range policy, so the cap would not bind; enforce size limits at your application gateway/proxy before issuing the URL.");const e=a?.expiresIn??this.defaultUrlExpiresIn;try{const[i]=await this.bucket.file(t).getSignedUrl({action:"write",contentType:a?.contentType,expires:Date.now()+e*1e3});return i}catch(i){return u(l.METHOD_NOT_ALLOWED,i instanceof Error?i.message:"Firebase: getSignedUrl failed")}}static resolveApp(t,a){const{appName:e}=t,i=g();if(e?i.find(p=>p.name===e):i[0])return e?m(e):m();const n=t.projectId??process.env.FIREBASE_PROJECT_ID??process.env.GOOGLE_CLOUD_PROJECT??process.env.GCLOUD_PROJECT;let s=t.credentials?.clientEmail??process.env.FIREBASE_CLIENT_EMAIL,r=t.credentials?.privateKey??process.env.FIREBASE_PRIVATE_KEY;const h=t.serviceAccountPath??process.env.GOOGLE_APPLICATION_CREDENTIALS;if((!s||!r)&&h){const p=JSON.parse(y(h,"utf8"));s??=p.client_email,r??=p.private_key}if(!s||!r)throw new Error("Firebase storage: service-account credentials are required. Provide `credentials` ({ clientEmail, privateKey }), `serviceAccountPath`, or set FIREBASE_CLIENT_EMAIL / FIREBASE_PRIVATE_KEY / GOOGLE_APPLICATION_CREDENTIALS.");return E({credential:w({clientEmail:s,privateKey:r.replaceAll(String.raw`\n`,`
2
- `),projectId:n}),projectId:n,storageBucket:a},e)}async getMetaSafe(t){try{return await this.getMeta(t)}catch{return}}internalOnComplete=t=>this.deleteMeta(t.id)}export{f as default};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class s extends e{path}export{s as default};
@@ -1 +0,0 @@
1
- import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(e){super(e)}}export{o as default};
@@ -1 +0,0 @@
1
- import{Readable as y,Writable as E}from"node:stream";import{Client as F}from"basic-ftp";import{F as T}from"./index-nZWCQrSe.js";import{throwErrorCode as u,ERRORS as m}from"./ERRORS-BIBxE2oR.js";import{B as O}from"./storage-DR7qdwBN.js";import k from"./FtpFile-ClWDYnt2.js";import b from"./FtpMetaStorage-CJsyeQ63.js";import{r as l,t as v,e as M}from"./posix-dirname-CfpH5wZi.js";import{t as P}from"./get-file-status-y3wTtDQs.js";import{t as A}from"./update-size-DuNuLyxj.js";import{i as R}from"./part-match-D-9dGX42.js";import{e as D}from"./has-content-50BsqrWw.js";const d=h=>{const a=h?.code;if(a===550||a===450||a===553)return!0;const e=h instanceof Error?h.message:String(h);return/no such file|not exist|cannot find|file unavailable/i.test(e)},f=h=>{if(h instanceof Error&&h.name==="AbortError")return h;const a=new Error(h instanceof Error&&h.message?h.message:"The operation was aborted",{cause:h});return a.name="AbortError",a},g=async(h,a,e)=>{const t=[],n=new E({write(i,r,s){t.push(Buffer.from(i)),s()}});return await h.downloadTo(n,a,e&&e>0?e:void 0),Buffer.concat(t)};class H extends O{static name="ftp";checksumTypes=[];supportsRange=!0;meta;connection;rootFolderPath;constructor(a){super(a),this.connection=a.connection,this.rootFolderPath=l(a.rootFolderPath??""),this.meta=a.metaStorage??new b(a.metaStorageConfig),this.isReady=!0}async create(a,e){return this.instrumentOperation("create",async()=>{const t=new k(a);t.name=this.namingFunction(t),t.path=this.keyToPath(t.name),await this.validate(t);try{const n=await this.getMeta(t.id);if(n.status==="completed")return n}catch{}return t.bytesWritten=0,t.status=P(t),await this.saveMeta(t),await this.onCreate(t),t})}async write(a,e){return this.instrumentOperation("write",async()=>{let t;if("contentType"in a&&"metadata"in a&&!("body"in a)&&!("start"in a)?t=a:(t=await this.getMeta(a.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(a.size!==void 0&&A(t,a.size),!R(a,t))return u(m.FILE_CONFLICT);const n=await this.lock(a.id);try{if(D(a)){if(this.isUnsupportedChecksum(a.checksumAlgorithm))return u(m.UNSUPPORTED_CHECKSUM_ALGORITHM);if(a.start>0)return u(m.METHOD_NOT_ALLOWED,"FTP storage does not support chunked or resumable uploads; send the file in a single request.");const i=await v(a.body),r=t.path??this.keyToPath(t.name||t.id);await this.runOperation(e,s=>this.run(s,async o=>{await this.ensureRemoteDirectory(o,r),await o.uploadFrom(y.from(i),r)})),t.bytesWritten=i.length,t.size=i.length,t.path=r,t.ETag=T(i)}return t.status=P(t),await this.saveMeta(t),t}finally{await this.unlock(a.id,n)}})}async get({id:a},e){return this.instrumentOperation("get",async()=>{const t=await this.checkIfExpired(await this.getMeta(a)),n=t.path??this.keyToPath(t.name||a),{range:i}=e??{},r=await this.runOperation(e,s=>this.run(s,async o=>{try{const c=await g(o,n,i?.start);return i?.end!==void 0?c.subarray(0,i.end-i.start+1):c}catch(c){if(d(c))return u(m.FILE_NOT_FOUND);throw c}}));return{content:r,contentType:t.contentType,ETag:t.ETag??T(r),expiredAt:t.expiredAt,id:a,metadata:t.metadata,modifiedAt:t.modifiedAt,name:t.name,originalName:t.originalName,size:i?r.length:t.size??r.length}})}async delete({id:a},e){return this.instrumentOperation("delete",async()=>{const t=await this.getMeta(a),n=t.path??this.keyToPath(t.name||a);await this.runOperation(e,r=>this.run(r,async s=>{try{await s.remove(n)}catch(o){if(!d(o))throw o}})),await this.deleteMeta(a);const i={...t,status:"deleted"};return await this.onDelete(i),i})}async copy(a,e,t){return this.instrumentOperation("copy",async()=>{const n=await this.getMeta(a),i=n.path??this.keyToPath(n.name||a),r=this.keyToPath(e);await this.runOperation(t,o=>this.run(o,async c=>{const p=await g(c,i);await this.ensureRemoteDirectory(c,r),await c.uploadFrom(y.from(p),r)}));const s={...n,id:e,name:e,path:r};return await this.saveMeta(s),s})}async move(a,e,t){return this.instrumentOperation("move",async()=>{const n=await this.getMeta(a),i=n.path??this.keyToPath(n.name||a),r=this.keyToPath(e);await this.runOperation(t,o=>this.run(o,async c=>{try{await this.ensureRemoteDirectory(c,r),await c.rename(i,r)}catch(p){try{const w=await g(c,i);await this.ensureRemoteDirectory(c,r),await c.uploadFrom(y.from(w),r),await c.remove(i)}catch(w){throw new AggregateError([p,w],`FTP move failed: rename and copy+delete fallback both failed for "${i}" → "${r}"`)}}}));const s={...n,id:e,name:e,path:r};await this.saveMeta(s);try{await this.deleteMeta(a)}catch{}return s})}async list(a=1e3,e){return this.instrumentOperation("list",async()=>{const t=this.keyToPath("");return this.runOperation(e,n=>this.run(n,async i=>{const r=[];return await this.walkList(i,t,r),r}))})}async exists({id:a},e){return this.instrumentOperation("exists",async()=>{let t;try{t=await this.getMeta(a)}catch{return!1}const n=t.path??this.keyToPath(t.name||a);return this.runOperation(e,i=>this.run(i,async r=>{try{return await r.size(n),!0}catch(s){if(d(s))return!1;throw s}}))})}async walkList(a,e,t){let n;try{n=await a.list(e||".")}catch(i){if(d(i))return;throw i}for(const i of n){const r=e?`${e}/${i.name}`:i.name;if(i.isDirectory){await this.walkList(a,r,t);continue}if(!i.isFile)continue;const s=this.pathToKey(r);if(!s)continue;const o=new k({contentType:"application/octet-stream",metadata:{},originalName:i.name});o.id=s,o.name=s,o.path=r,o.size=i.size,i.modifiedAt&&(o.modifiedAt=i.modifiedAt.toISOString()),t.push(o)}}async run(a,e){const t=new F;if(a?.aborted)throw f(a.reason);const n=()=>{t.close()};a?.addEventListener("abort",n,{once:!0});try{if(await t.access(this.connection),a?.aborted)throw f(a.reason);return await e(t)}catch(i){throw a?.aborted?f(i):i}finally{a?.removeEventListener("abort",n),t.close()}}async ensureRemoteDirectory(a,e){const t=M(e);t&&(await a.ensureDir(t),await a.cd("/"))}keyToPath(a){const e=l(a);e&&O.assertSafeId(e);const t=[];return this.rootFolderPath&&t.push(this.rootFolderPath),e&&t.push(e),t.length===0?"":`/${t.join("/")}`}pathToKey(a){const e=l(a);if(!this.rootFolderPath)return e;if(e===this.rootFolderPath)return"";const t=`${this.rootFolderPath}/`;return e.startsWith(t)?e.slice(t.length):e}}export{H as default};
@@ -1 +0,0 @@
1
- import a from"./File-W8aOo15X.js";class o extends a{GCSUploadURI;uri}export{o as default};
@@ -1 +0,0 @@
1
- import"node:crypto";import"gaxios";import"google-auth-library";import{v as f}from"./gcs-meta-storage-Bu2upyHK.js";import"./MetaStorage-DPEUyWgN.js";import"./Metadata-B7CcBueg.js";import"./GCSConfig-BQ0OpVhe.js";export{f as default};
@@ -1 +0,0 @@
1
- import{randomUUID as g}from"node:crypto";import{request as f}from"gaxios";import{GoogleAuth as y}from"google-auth-library";import{r as w,v as R,g as C,m,b}from"./gcs-meta-storage-Bu2upyHK.js";import{d as E}from"./detect-file-type-BA7UBLKA.js";import{throwErrorCode as k,ERRORS as U}from"./ERRORS-BIBxE2oR.js";import{B as I,c as S}from"./storage-DR7qdwBN.js";import{y as T}from"./local-meta-storage-BELb1YwO.js";import d from"./GCSConfig-BQ0OpVhe.js";import x from"./GCSFile-Cero7qZN.js";import{i as O}from"./part-match-D-9dGX42.js";import{e as v}from"./has-content-50BsqrWw.js";import{t as A}from"./get-file-status-y3wTtDQs.js";class $ extends Error{constructor(t,a,e){super(t),this.code=a,this.config=e}code;config;name="FetchError"}const B=l=>l>=200&&l<300||l===308||l===499;class p extends I{static name="gcs";checksumTypes=["md5","crc32c"];supportsDelimiter=!0;get raw(){return this.authClient}meta;bucket;authClient;storageBaseURI;uploadBaseURI;isCustomEndpoint=!1;retryOptions={};useAuthWithCustomEndpoint;userProject;constructor(t){super(t);const a=t.bucket||process.env.GCS_BUCKET;if(!a)throw new Error("GCS bucket is not defined");if(!t.projectId)throw new Error("Sorry, we cannot connect to Cloud Services without a project ID.");this.bucket=a,this.storageBaseURI=`${t.storageAPI||d.storageAPI}/${this.bucket}/o`,this.uploadBaseURI=`${t.uploadAPI||d.uploadAPI}/${this.bucket}/o`,this.isCustomEndpoint=new URL(this.storageBaseURI).hostname!=="storage.googleapis.com";const{retryOptions:e,useAuthWithCustomEndpoint:r,userProject:s}=t;this.userProject=s,this.useAuthWithCustomEndpoint=r||!1,this.retryOptions={...w,...e},t.scopes||=d.authScopes,this.authClient=new y(t);const{bucket:n,metaStorage:c,metaStorageConfig:o,projectId:i}=t;if(c)this.meta=c;else{let u={...t,...o,logger:this.logger};"directory"in u?(this.logger?.debug("Using local meta storage"),this.meta=new T(u)):(n===u.bucket&&i===u.projectId&&(u={...u,authClient:this.authClient}),this.meta=new R(u))}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(u=>{this.logger?.error("Storage access check failed: %O",u)})}normalizeError(t){if(t.config){const a=+t.code||500;return{code:`GCS${a}`,message:t.message,name:t.name,retryable:a>=499,statusCode:a}}return{code:"GenericUploadError",message:`[${this.constructor.name}] ${t.message}`,name:t.name,statusCode:500}}async create(t,a){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const i=typeof t.ttl=="string"?S(t.ttl):t.ttl;i!==void 0&&(e.expiredAt=Date.now()+i)}const r=new x(e);r.name=this.namingFunction(r),await this.validate(r);try{const i=await this.getMeta(r.id);return i.bytesWritten=await this.internalWrite(i,a),i}catch{}const s={"Content-Type":"application/json; charset=utf-8","X-Goog-Upload-Command":"start","X-Goog-Upload-Protocol":"resumable","X-Upload-Content-Length":r.size.toString(),"X-Upload-Content-Type":r.contentType},n={body:JSON.stringify({metadata:r.metadata}),headers:s,method:"POST",params:{name:r.name,size:r.size,uploadType:"resumable"},url:this.uploadBaseURI},c=await this.makeRequest(n,a);if(c.status!==200)throw new Error("Expected 200 response from GCS");const o=c.headers.get("X-Goog-Upload-Status")||c.headers.get("x-goog-upload-status");if(o!=="active")throw new Error(`X-Goog-Upload-Status response header expected 'active' got: ${o}`);return r.uri=c.headers.get("location"),this.config.clientDirectUpload?(r.GCSUploadURI=r.uri,this.logger?.debug("send uploadURI to client: %s",r.GCSUploadURI),r.status="created",r):(r.bytesWritten=0,await this.saveMeta(r),r.status="created",await this.onCreate(r),r)})}async write(t,a){return this.instrumentOperation("write",async()=>{let e;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?e=t:(e=await this.getMeta(t.id),await this.checkIfExpired(e)),e.status==="completed")return e;if(!O(t,e))return k(U.FILE_CONFLICT);const r=await this.lock(t.id);try{if(v(t)&&(e.bytesWritten===0||Number.isNaN(e.bytesWritten))&&(!e.contentType||e.contentType==="application/octet-stream"))try{const{fileType:s,stream:n}=await E(t.body);s?.mime&&(e.contentType=s.mime),t.body=n}catch{}e.bytesWritten=await this.internalWrite({...e,...t},a),e.status=A(e),e.status==="completed"&&(e.uri=`${this.storageBaseURI}/${e.name}`,await this.internalOnComplete(e))}finally{await this.unlock(t.id,r)}return e})}async delete({id:t},a){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);if(!e.uri)throw new Error(`File ${t} does not have a valid URI`);e.status="deleted",await this.makeRequest({method:"DELETE",url:e.uri,validateStatus:B},a),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,a,e){return this.instrumentOperation("copy",async()=>{const r=new URL(`/${this.bucket}/${t}`,"file://"),s=new URL(encodeURI(a),r).pathname,[,n,...c]=s.split("/"),o=c.join("/"),i=`${this.storageBaseURI}/${t}/rewriteTo/b/${n}/o/${o}`;let u={};const h={body:"",headers:{"Content-Type":"application/json"},method:"POST",url:i};do h.body=u.rewriteToken?JSON.stringify({rewriteToken:u.rewriteToken}):"",u=(await this.makeRequest(h,e)).data||{};while(u.rewriteToken);return await this.getMeta(a)})}async move(t,a,e){return this.instrumentOperation("move",async()=>{const r=await this.copy(t,a,e),s=`${this.storageBaseURI}/${t}`;return await this.makeRequest({method:"DELETE",url:s},e),r})}async get({id:t},a){return this.instrumentOperation("get",async()=>{const{data:e}=await this.makeRequest({params:{alt:"json"},url:`${this.storageBaseURI}/${t}`},a);if(await this.checkIfExpired({expiredAt:e.timeDeleted}),!e.uri)throw new Error("File URI not found");const r=(await this.makeRequest({params:{alt:"media"},url:e.uri},a)).data;let s;if(typeof r=="string")s=Buffer.from(r,"utf8");else if(r&&typeof r=="object"&&"data"in r){const n=r.data;s=Buffer.from(n)}else s=Buffer.from(r);return{...e,content:s}})}async exists({id:t},a){return this.instrumentOperation("exists",async()=>{try{return await this.getMeta(t),await this.makeRequest({method:"HEAD",url:`${this.storageBaseURI}/${t}`},a),!0}catch{return!1}})}async list(t=1e3,a){return this.instrumentOperation("list",async()=>{const e=[],r=Math.min(t,1e3);let s=!0,n={params:{maxResults:r},url:this.storageBaseURI};for(;s&&e.length<t;)try{const{data:c}=await this.makeRequest(n,a);for(const{name:o,timeCreated:i,updated:u}of c?.items||[]){if(e.length>=t)break;e.push({createdAt:i,id:o,modifiedAt:u})}s=c?.nextPageToken!==void 0,s&&e.length<t&&(n={...n,params:{...n.params,maxResults:Math.min(r,t-e.length),pageToken:c.nextPageToken}})}catch(c){const o=this.normalizeError(c instanceof Error?c:new Error(String(c)));throw await this.onError(o),c}return e},{limit:t})}async listDirectory(t){return this.instrumentOperation("listDirectory",async()=>{const a=t?.limit??1e3,e=Math.min(a,1e3),r=[],s=new Set;let n=!0,c={params:{delimiter:t?.delimiter,maxResults:e,...t?.prefix!==void 0&&{prefix:t.prefix}},url:this.storageBaseURI};for(;n&&r.length<a;)try{const{data:o}=await this.makeRequest(c,t);for(const i of o?.prefixes||[])s.add(i);for(const{name:i,timeCreated:u,updated:h}of o?.items||[]){if(r.length>=a)break;r.push({createdAt:u,id:i,modifiedAt:h})}n=o?.nextPageToken!==void 0,n&&r.length<a&&(c={...c,params:{...c.params,maxResults:Math.min(e,a-r.length),pageToken:o.nextPageToken}})}catch(o){const i=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(i),o}return{files:r,prefixes:[...s]}},{limit:t?.limit??1e3})}async internalWrite(t,a){const{body:e,bytesWritten:r,size:s,uri:n=""}=t,c=b(t),o={method:"PUT"};if(e?.on){const i=new AbortController;e.on("aborted",()=>{i.abort()}),o.body=e,o.signal=i.signal,o.retry=!1}o.headers={Accept:"application/json","Content-Range":c,...s===r?{"X-Goog-Upload-Command":"upload, finalize"}:{}};try{const i=await this.makeRequest({url:n,...o},a);if(i.status===308){const u=i.headers.get("range");return u?C(u):0}if(i.status===200)return this.logger?.debug("uploaded %O",i.data),s;throw new $(String(i.data),`GCS${i.status}`,{uri:n})}catch(i){this.logger?.error(n,i);const u=this.normalizeError(i instanceof Error?i:new Error(String(i)));throw await this.onError(u),i}}internalOnComplete=t=>this.deleteMeta(t.id);static buildCallSignal(t,a){const e=[];if(a&&e.push(a),t?.signal&&e.push(t.signal),e.length!==0)return e.length===1?e[0]:AbortSignal.any(e)}async makeRequest(t,a){typeof t.url=="string"&&(t.url=t.url.replaceAll("/:",":"));const e=p.buildCallSignal(a,t.signal);let r=this.retryOptions;if(a?.retries!==void 0){const n=typeof a.retries=="number"?a.retries:a.retries.maxRetries;typeof n=="number"&&(r={...this.retryOptions,retry:n})}const s=typeof a?.timeout=="number"&&a.timeout>0?a.timeout:6e4;return t={...t,headers:{"User-Agent":`${m.name}/${m.version}`,"x-goog-api-client":`gl-node/${process.versions.node} gccl/${m.version} gccl-invocation-id/${g()}`,...t.headers},params:{...this.userProject===void 0?{}:{userProject:this.userProject},...t.params},retry:t.retry===!1?!1:a?.retries!==0,retryConfig:r,timeout:s,...e?{signal:e}:{}},this.isCustomEndpoint&&!this.useAuthWithCustomEndpoint?f(t):this.authClient.request(t)}async accessCheck(){return this.makeRequest({url:this.storageBaseURI.replace("/o","")})}}export{p as default};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class r extends e{driveFileId;mimeType;publicUrl}export{r as default};
@@ -1 +0,0 @@
1
- import{y as r}from"./local-meta-storage-BELb1YwO.js";class o extends r{constructor(t){super(t)}}export{o as default};
@@ -1 +0,0 @@
1
- import"node:fs/promises";import"node:os";import{y as f}from"./local-meta-storage-BELb1YwO.js";import"./path-C-OWflAo-_mqb5p5d.js";import"./ERRORS-BIBxE2oR.js";import"./MetaStorage-DPEUyWgN.js";import"./Metadata-B7CcBueg.js";export{f as default};
@@ -1 +0,0 @@
1
- import{createHash as l}from"node:crypto";import{Readable as f}from"node:stream";import d from"mime";import{N as p}from"./cache-Cw3QjoVN.js";import{isKnownContentType as u}from"./getFormatFromContentType-DCTTPQHm.js";import s from"./ValidationError-3B06DFyE.js";class T{constructor(e,t={}){if(this.storage=e,this.logger=t.logger||this.storage.logger,this.config={audioBitrate:128e3,audioCodec:"aac",cache:t.cache??new p,cacheTtl:3600,maxAudioSize:100*1024*1024,maxImageSize:10*1024*1024,maxVideoSize:500*1024*1024,saveTransformedFiles:!1,supportedAudioFormats:[],supportedImageFormats:[],supportedVideoFormats:[],videoBitrate:2e6,videoCodec:"avc",...t},t.ImageTransformer&&((!Array.isArray(this.config.supportedImageFormats)||this.config.supportedImageFormats.length===0)&&(this.config.supportedImageFormats=["jpeg","png","webp","avif","tiff","gif","svg"]),this.imageTransformer=new t.ImageTransformer(this.storage,{cache:this.config.cache,cacheTtl:this.config.cacheTtl,logger:this.logger,maxImageSize:this.config.maxImageSize,supportedFormats:this.config.supportedImageFormats})),t.VideoTransformer&&((!Array.isArray(this.config.supportedVideoFormats)||this.config.supportedVideoFormats.length===0)&&(this.config.supportedVideoFormats=["mp4","webm","mkv","avi","mov","flv","wmv"]),this.videoTransformer=new t.VideoTransformer(this.storage,{cache:this.config.cache,cacheTtl:this.config.cacheTtl,defaultBitrate:this.config.videoBitrate,defaultCodec:this.config.videoCodec,logger:this.logger,maxVideoSize:this.config.maxVideoSize,supportedFormats:this.config.supportedVideoFormats})),t.AudioTransformer&&((!Array.isArray(this.config.supportedAudioFormats)||this.config.supportedAudioFormats.length===0)&&(this.config.supportedAudioFormats=["mp3","wav","ogg","aac","flac","m4a","wma","aiff"]),this.audioTransformer=new t.AudioTransformer(this.storage,{cache:this.config.cache,cacheTtl:this.config.cacheTtl,defaultBitrate:this.config.audioBitrate,defaultCodec:this.config.audioCodec,logger:this.logger,maxAudioSize:this.config.maxAudioSize,supportedFormats:this.config.supportedAudioFormats})),t.AudioTransformer===void 0&&t.ImageTransformer===void 0&&t.VideoTransformer===void 0)throw new Error("MediaTransformer initialization failed: No transformers are configured. At least one transformer (AudioTransformer, ImageTransformer, or VideoTransformer) must be provided in the configuration to enable media processing functionality.")}storage;imageTransformer;videoTransformer;audioTransformer;config;logger;supportedFormats(){return[...this.config.supportedAudioFormats,...this.config.supportedImageFormats,...this.config.supportedVideoFormats]}async handle(e,t){const a=this.parseQuery(t),r={id:e},o=await this.storage.get(r),n=this.detectMediaType(o.contentType);if(this.validateQueryParameters(a,n),this.config.saveTransformedFiles&&this.hasTransformations(a)){const h=this.generateTransformedFileId(e,a,n);try{const m=await this.storage.get({id:h});return this.logger?.debug?.(`Serving cached transformed file: ${h}`),this.createMediaTransformResult(m,n,o)}catch{this.logger?.debug?.(`Transformed file not found, processing: ${h}`)}}let i;switch(n){case"audio":{if(!this.audioTransformer)throw new Error("Audio transformer not available. Please install audio transformation dependencies or provide an audio transformer instance.");i=await this.handleAudioTransformation(e,a);break}case"image":{if(!this.imageTransformer)throw new Error("Image transformer not available. Please install image transformation dependencies or provide an image transformer instance.");i=await this.handleImageTransformation(e,a);break}case"video":{if(!this.videoTransformer)throw new Error("Video transformer not available. Please install video transformation dependencies or provide a video transformer instance.");i=await this.handleVideoTransformation(e,a);break}default:throw new Error(`Unsupported media type: ${o.contentType}`)}return this.config.saveTransformedFiles&&this.hasTransformations(a)&&await this.saveTransformedFile(i,e,a,n),i}async fetch(e,t){const a=new URLSearchParams(t);return this.handle(e,a)}clearCache(e){this.imageTransformer?.clearCache(e),this.videoTransformer?.clearCache(e),this.audioTransformer?.clearCache(e)}async clearSavedTransformedFiles(){if(this.config.saveTransformedFiles)try{this.logger?.warn?.("clearSavedTransformedFiles requires custom storage implementation to find and delete transformed files")}catch(e){this.logger?.error?.(`Failed to clear saved transformed files: ${e}`)}}async clearSavedTransformedFilesForFile(e){if(this.config.saveTransformedFiles)try{this.logger?.warn?.("clearSavedTransformedFilesForFile requires custom storage implementation")}catch(t){this.logger?.error?.(`Failed to clear saved transformed files for ${e}: ${t}`)}}getCacheStats(){const e={audio:this.audioTransformer?.getCacheStats(),image:this.imageTransformer?.getCacheStats(),video:this.videoTransformer?.getCacheStats()};return e.image===void 0&&delete e.image,e.video===void 0&&delete e.video,e.audio===void 0&&delete e.audio,e}validateQueryParameters(e,t){switch(t){case"audio":{this.validateAudioQueryParameters(e);break}case"image":{this.validateImageQueryParameters(e);break}case"video":{this.validateVideoQueryParameters(e);break}}}validateImageQueryParameters(e){const t=new Set(["alphaQuality","angle","background","bandbool","blur","boolean","brightness","channel","clahe","colourspace","compressionLevel","convolve","cropHeight","cropWidth","delay","dilate","effort","erode","extractChannel","fastShrinkOnLoad","fit","flatten","flip","flop","format","frameRate","gamma","grayscale","greyscale","height","hue","joinChannel","kernel","left","lightness","linear","loop","maxSlope","median","modulate","negate","normalise","normalize","position","quality","recombine","saturation","sharpen","threshold","tint","top","unflatten","width","withoutEnlargement","withoutReduction"]),a=new Set(["bitrate","codec","frameRate","keyFrameInterval","numberOfChannels","sampleRate"]),r=[];for(const i of a)e[i]!==void 0&&r.push(i);if(r.length>0){const i=[...r].toSorted();throw new s(`Invalid query parameters for image transformation: ${i.join(", ")}. Images support: ${[...t].toSorted().join(", ")}. Video/audio parameters (${i.join(", ")}) are not supported for images.`,"INVALID_PARAMS_FOR_IMAGE","image",i,[...t].toSorted())}if(e.fit&&!["contain","cover","fill","inside","outside"].includes(e.fit))throw new s(`Invalid fit value: "${e.fit}". Supported values: "cover", "contain", "fill", "inside", "outside"`,"INVALID_FIT_VALUE","image",["fit"],["cover","contain","fill","inside","outside"]);if(e.format&&!["avif","gif","jpeg","png","tiff","webp"].includes(e.format))throw new s(`Invalid format for image: "${e.format}". Supported formats: jpeg, png, webp, avif, tiff, gif`,"INVALID_FORMAT","image",["format"],["jpeg","png","webp","avif","tiff","gif"]);const o=["left","top","cropWidth","cropHeight"],n=o.filter(i=>e[i]!==void 0);if(n.length>0&&n.length!==o.length)throw new s(`Incomplete crop parameters: ${n.join(", ")}. All crop parameters must be provided: left, top, cropWidth, cropHeight`,"INCOMPLETE_CROP_PARAMS","image",n,o)}validateVideoQueryParameters(e){const t=new Set(["angle","background","bitrate","codec","cropHeight","cropWidth","fit","format","frameRate","height","keyFrameInterval","left","position","quality","top","width","withoutEnlargement","withoutReduction"]),a=new Set(["numberOfChannels","sampleRate"]),r=[];for(const i of a)e[i]!==void 0&&r.push(i);if(r.length>0){const i=[...r].toSorted();throw new s(`Invalid query parameters for video transformation: ${i.join(", ")}. Videos support: ${[...t].toSorted().join(", ")}. Audio-only parameters (${i.join(", ")}) are not supported for videos.`,"INVALID_PARAMS_FOR_VIDEO","video",i,[...t].toSorted())}if(e.fit&&!["contain","cover","fill","inside","outside"].includes(e.fit))throw new s(`Invalid fit value: "${e.fit}". Supported values: "cover", "contain", "fill", "inside", "outside"`,"INVALID_FIT_VALUE","video",["fit"],["cover","contain","fill","inside","outside"]);if(e.codec&&!["av1","avc","hevc","vp8","vp9"].includes(e.codec))throw new s(`Invalid codec for video: "${e.codec}". Supported codecs: avc, hevc, vp8, vp9, av1`,"INVALID_VIDEO_CODEC","video",["codec"],["avc","hevc","vp8","vp9","av1"]);if(e.format&&!["mkv","mp4","ogg","webm"].includes(e.format))throw new s(`Invalid format for video: "${e.format}". Supported formats: mp4, webm, mkv, ogg`,"INVALID_VIDEO_FORMAT","video",["format"],["mp4","webm","mkv","ogg"]);const o=["left","top","cropWidth","cropHeight"],n=o.filter(i=>e[i]!==void 0);if(n.length>0&&n.length!==o.length)throw new s(`Incomplete crop parameters: ${n.join(", ")}. All crop parameters must be provided: left, top, cropWidth, cropHeight`,"INCOMPLETE_CROP_PARAMS","video",n,o);if(e.width!==void 0&&(typeof e.width!="number"||e.width<=0))throw new s(`Invalid width: ${e.width}. Must be a positive number.`,"INVALID_WIDTH","video",["width"],[]);if(e.height!==void 0&&(typeof e.height!="number"||e.height<=0))throw new s(`Invalid height: ${e.height}. Must be a positive number.`,"INVALID_HEIGHT","video",["height"],[]);if(e.bitrate!==void 0&&(typeof e.bitrate!="number"||e.bitrate<=0))throw new s(`Invalid bitrate: ${e.bitrate}. Must be a positive number.`,"INVALID_BITRATE","video",["bitrate"],[]);if(e.frameRate!==void 0&&(typeof e.frameRate!="number"||e.frameRate<=0))throw new s(`Invalid frameRate: ${e.frameRate}. Must be a positive number.`,"INVALID_FRAME_RATE","video",["frameRate"],[]);if(e.keyFrameInterval!==void 0&&(typeof e.keyFrameInterval!="number"||e.keyFrameInterval<=0))throw new s(`Invalid keyFrameInterval: ${e.keyFrameInterval}. Must be a positive number.`,"INVALID_KEY_FRAME_INTERVAL","video",["keyFrameInterval"],[])}generateTransformedFileId(e,t,a){const r=Object.keys(t).filter(i=>t[i]!==void 0).toSorted().map(i=>`${i}:${t[i]}`).join("|"),o=`${e}|${a}|${r}`,n=l("sha256").update(o).digest("hex").slice(0,32);return`${e}_transformed_${n}`}hasTransformations(e){return this.hasImageTransformations(e)||this.hasVideoTransformations(e)||this.hasAudioTransformations(e)}createMediaTransformResult(e,t,a){const r={buffer:e.content,format:this.getFormatFromContentType(e.contentType||""),mediaType:t,originalFile:a,size:e.content.length};switch(t){case"audio":return{...r,bitrate:e.bitrate,duration:e.duration,mediaType:"audio",numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate};case"image":return{...r,height:e.height,mediaType:"image",width:e.width};case"video":return{...r,bitrate:e.bitrate,duration:e.duration,height:e.height,mediaType:"video",width:e.width};default:return r}}getFormatFromContentType(e){return e?d.getExtension(e)||"application/octet-stream":""}async saveTransformedFile(e,t,a,r){try{const o=this.generateTransformedFileId(t,a,r),n={format:e.format,mediaType:r,originalFileId:t,size:e.size,transformation:a,transformedAt:new Date().toISOString()};r==="image"&&e.width&&e.height?(n.width=e.width,n.height=e.height):r==="video"&&e.width&&e.height?(n.width=e.width,n.height=e.height,n.duration=e.duration,n.bitrate=e.bitrate):r==="audio"&&(n.duration=e.duration,n.numberOfChannels=e.numberOfChannels,n.sampleRate=e.sampleRate,n.bitrate=e.bitrate);const i=await this.storage.create({contentType:d.getType(e.format)??void 0,id:o,metadata:n,originalName:`${o}.${e.format}`,size:e.size});await this.storage.write({body:f.from(e.buffer),contentLength:e.size,id:i.id,start:0}),this.logger?.debug?.(`Saved transformed file: ${o}`)}catch(o){this.logger?.error?.(`Failed to save transformed file: ${o}`)}}validateAudioQueryParameters(e){const t=new Set(["bitrate","codec","format","numberOfChannels","quality","sampleRate"]),a=new Set(["angle","background","cropHeight","cropWidth","fit","frameRate","height","keyFrameInterval","left","position","top","width","withoutEnlargement","withoutReduction"]),r=[];for(const o of a)e[o]!==void 0&&r.push(o);if(r.length>0){const o=[...r].toSorted();throw new s(`Invalid query parameters for audio transformation: ${o.join(", ")}. Audio supports: ${[...t].toSorted().join(", ")}. Video-only parameters (${o.join(", ")}) are not supported for audio.`,"INVALID_PARAMS_FOR_AUDIO","audio",o,[...t].toSorted())}if(e.codec&&!["aac","flac","mp3","opus","vorbis"].includes(e.codec))throw new s(`Invalid codec for audio: "${e.codec}". Supported codecs: aac, opus, mp3, vorbis, flac`,"INVALID_AUDIO_CODEC","audio",["codec"],["aac","opus","mp3","vorbis","flac"]);if(e.format&&!["aac","flac","mp3","ogg","wav"].includes(e.format))throw new s(`Invalid format for audio: "${e.format}". Supported formats: mp3, wav, ogg, aac, flac`,"INVALID_AUDIO_FORMAT","audio",["format"],["mp3","wav","ogg","aac","flac"]);if(e.bitrate!==void 0&&(typeof e.bitrate!="number"||e.bitrate<=0))throw new s(`Invalid bitrate: ${e.bitrate}. Must be a positive number.`,"INVALID_BITRATE","audio",["bitrate"],[]);if(e.numberOfChannels!==void 0&&(typeof e.numberOfChannels!="number"||e.numberOfChannels<=0||e.numberOfChannels>8))throw new s(`Invalid numberOfChannels: ${e.numberOfChannels}. Must be a number between 1 and 8.`,"INVALID_CHANNEL_COUNT","audio",["numberOfChannels"],["1","2","3","4","5","6","7","8"]);if(e.sampleRate!==void 0){const o=[8e3,11025,16e3,22050,32e3,44100,48e3,88200,96e3,192e3];if(typeof e.sampleRate!="number"||!o.includes(e.sampleRate))throw new s(`Invalid sampleRate: ${e.sampleRate}. Supported sample rates: ${o.join(", ")}`,"INVALID_SAMPLE_RATE","audio",["sampleRate"],o.map(String))}}async handleImageTransformation(e,t){const a=[];this.hasImageTransformations(t)&&((t.width||t.height||t.fit)&&a.push({options:{fit:t.fit,height:t.height,position:t.position,width:t.width,withoutEnlargement:t.withoutEnlargement,withoutReduction:t.withoutReduction},type:"resize"}),t.left!==void 0&&t.top!==void 0&&t.cropWidth&&t.cropHeight&&a.push({options:{height:t.cropHeight,left:t.left,top:t.top,width:t.cropWidth},type:"crop"}),t.angle&&a.push({options:{angle:t.angle,background:t.background},type:"rotate"}),t.format?a.push({options:{format:t.format,quality:t.quality},type:"format"}):t.quality&&a.push({options:{quality:t.quality},type:"quality"}));const r=a.length>0?await this.imageTransformer.transform(e,a):await this.imageTransformer.transform(e,[]);return this.convertImageResult(r)}async handleVideoTransformation(e,t){const a=[];this.hasVideoTransformations(t)&&((t.width||t.height||t.fit)&&a.push({options:{fit:t.fit,height:t.height,position:t.position,width:t.width,withoutEnlargement:t.withoutEnlargement,withoutReduction:t.withoutReduction},type:"resize"}),t.left!==void 0&&t.top!==void 0&&t.cropWidth&&t.cropHeight&&a.push({options:{height:Number(t.cropHeight),left:t.left,top:t.top,width:t.cropWidth},type:"crop"}),t.angle&&a.push({options:{angle:t.angle,background:t.background},type:"rotate"}),(t.codec||t.bitrate)&&a.push({options:{bitrate:t.bitrate||t.quality,codec:t.codec,frameRate:t.frameRate,keyFrameInterval:t.keyFrameInterval},type:"codec"}),t.format&&a.push({options:{format:t.format},type:"format"}));const r=a.length>0?await this.videoTransformer.transform(e,a):await this.videoTransformer.transform(e,[]);return this.convertVideoResult(r)}async handleAudioTransformation(e,t){const a=[];this.hasAudioTransformations(t)&&(t.sampleRate&&a.push({options:{sampleRate:t.sampleRate},type:"resample"}),t.numberOfChannels&&a.push({options:{numberOfChannels:t.numberOfChannels},type:"channels"}),(t.codec||t.bitrate)&&a.push({options:{bitrate:t.bitrate||t.quality,codec:t.codec},type:"codec"}),t.format&&a.push({options:{format:t.format},type:"format"}));const r=a.length>0?await this.audioTransformer.transform(e,a):await this.audioTransformer.transform(e,[]);return this.convertAudioResult(r)}parseQuery(e){if(typeof e=="string")return this.parseURLSearchParams(new URLSearchParams(e));if(e instanceof URLSearchParams)return this.parseURLSearchParams(e);const t=e;return e.left&&(t.left=Number.parseInt(e.left,10)),e.top&&(t.top=Number.parseInt(e.top,10)),e.cropWidth&&(t.cropWidth=Number.parseInt(e.cropWidth,10)),e.cropHeight&&(t.cropHeight=Number.parseInt(e.cropHeight,10)),e.angle&&(t.angle=Number.parseInt(e.angle,10)),e.quality&&(t.quality=Number.parseInt(e.quality,10)),e.width&&(t.width=Number.parseInt(e.width,10)),e.height&&(t.height=Number.parseInt(e.height,10)),e.bitrate&&(t.bitrate=Number.parseInt(e.bitrate,10)),e.frameRate&&(t.frameRate=Number.parseInt(e.frameRate,10)),e.keyFrameInterval&&(t.keyFrameInterval=Number.parseInt(e.keyFrameInterval,10)),e.numberOfChannels&&(t.numberOfChannels=Number.parseInt(e.numberOfChannels,10)),e.sampleRate&&(t.sampleRate=Number.parseInt(e.sampleRate,10)),t}parseBooleanParameter(e){if(e!==null)return e==="true"||e==="1"}parseURLSearchParams(e){const t={};if(e.has("format")&&(t.format=e.get("format")??void 0),e.has("quality")&&(t.quality=e.get("quality")?Number.parseInt(e.get("quality"),10):void 0),e.has("width")&&(t.width=e.get("width")?Number.parseInt(e.get("width"),10):void 0),e.has("height")&&(t.height=e.get("height")?Number.parseInt(e.get("height"),10):void 0),e.has("fit")){const a=e.get("fit");a&&["contain","cover","fill","inside","outside"].includes(a)&&(t.fit=a)}if(e.has("position")&&(t.position=e.get("position")??void 0),e.has("withoutEnlargement")){const a=e.get("withoutEnlargement");t.withoutEnlargement=a==="true"?!0:void 0}if(e.has("withoutReduction")){const a=e.get("withoutReduction");t.withoutReduction=a==="true"?!0:void 0}if(e.has("left")&&(t.left=e.get("left")?Number.parseInt(e.get("left"),10):void 0),e.has("top")&&(t.top=e.get("top")?Number.parseInt(e.get("top"),10):void 0),e.has("cropWidth")&&(t.cropWidth=e.get("cropWidth")?Number.parseInt(e.get("cropWidth"),10):void 0),e.has("cropHeight")&&(t.cropHeight=e.get("cropHeight")?Number.parseInt(e.get("cropHeight"),10):void 0),e.has("angle")){const a=e.get("angle")?Number.parseInt(e.get("angle"),10):void 0;a!==void 0&&(t.angle=a)}if(e.has("background")&&(t.background=e.get("background")??void 0),e.has("blur")&&(t.blur=this.parseBooleanParameter(e.get("blur"))),e.has("sharpen")&&(t.sharpen=this.parseBooleanParameter(e.get("sharpen"))),e.has("median")&&(t.median=e.get("median")?Number.parseInt(e.get("median"),10):void 0),e.has("clahe")&&(t.clahe=this.parseBooleanParameter(e.get("clahe"))),e.has("threshold")&&(t.threshold=e.get("threshold")?Number.parseInt(e.get("threshold"),10):void 0),e.has("gamma")&&(t.gamma=this.parseBooleanParameter(e.get("gamma"))),e.has("negate")&&(t.negate=this.parseBooleanParameter(e.get("negate"))),(e.has("normalise")||e.has("normalize"))&&(t.normalise=this.parseBooleanParameter(e.get("normalise"))||this.parseBooleanParameter(e.get("normalize"))),e.has("flatten")&&(t.flatten=this.parseBooleanParameter(e.get("flatten"))),e.has("unflatten")&&(t.unflatten=this.parseBooleanParameter(e.get("unflatten"))),e.has("flip")&&(t.flip=this.parseBooleanParameter(e.get("flip"))),e.has("flop")&&(t.flop=this.parseBooleanParameter(e.get("flop"))),e.has("affine")&&(t.affine=this.parseBooleanParameter(e.get("affine"))),e.has("dilate")&&(t.dilate=this.parseBooleanParameter(e.get("dilate"))),e.has("erode")&&(t.erode=this.parseBooleanParameter(e.get("erode"))),e.has("pipelineColourspace")&&(t.pipelineColourspace=this.parseBooleanParameter(e.get("pipelineColourspace"))),e.has("toColourspace")&&(t.toColourspace=this.parseBooleanParameter(e.get("toColourspace"))),e.has("removeAlpha")&&(t.removeAlpha=this.parseBooleanParameter(e.get("removeAlpha"))),e.has("ensureAlpha")&&(t.ensureAlpha=this.parseBooleanParameter(e.get("ensureAlpha"))),(e.has("greyscale")||e.has("grayscale"))&&(t.greyscale=this.parseBooleanParameter(e.get("greyscale"))||this.parseBooleanParameter(e.get("grayscale"))),e.has("modulate")&&(t.modulate=this.parseBooleanParameter(e.get("modulate"))),e.has("tint")&&(t.tint=this.parseBooleanParameter(e.get("tint"))),e.has("brightness")&&(t.brightness=e.get("brightness")?Number.parseFloat(e.get("brightness")):void 0),e.has("saturation")&&(t.saturation=e.get("saturation")?Number.parseFloat(e.get("saturation")):void 0),e.has("hue")&&(t.hue=e.get("hue")?Number.parseInt(e.get("hue"),10):void 0),e.has("lightness")&&(t.lightness=e.get("lightness")?Number.parseInt(e.get("lightness"),10):void 0),e.has("kernel")&&(t.kernel=e.get("kernel")??void 0),e.has("fastShrinkOnLoad")&&(t.fastShrinkOnLoad=e.get("fastShrinkOnLoad")==="true"),e.has("codec")){const a=e.get("codec");a&&["avc","hevc","vp8","vp9","av1","aac","opus","mp3","vorbis","flac"].includes(a)&&(t.codec=a)}return e.has("bitrate")&&(t.bitrate=e.get("bitrate")?Number.parseInt(e.get("bitrate"),10):void 0),e.has("frameRate")&&(t.frameRate=e.get("frameRate")?Number.parseInt(e.get("frameRate"),10):void 0),e.has("keyFrameInterval")&&(t.keyFrameInterval=e.get("keyFrameInterval")?Number.parseInt(e.get("keyFrameInterval"),10):void 0),e.has("numberOfChannels")&&(t.numberOfChannels=e.get("numberOfChannels")?Number.parseInt(e.get("numberOfChannels"),10):void 0),e.has("sampleRate")&&(t.sampleRate=e.get("sampleRate")?Number.parseInt(e.get("sampleRate"),10):void 0),t}detectMediaType(e){if(!e)throw new Error("Cannot detect media type: no content type provided");if(!u(e))throw new Error(`Unknown or invalid content type: ${e}`);if(e.startsWith("image/"))return"image";if(e.startsWith("video/"))return"video";if(e.startsWith("audio/"))return"audio";throw new Error(`Unsupported media type for content type: ${e}`)}hasImageTransformations(e){return!!(e.width||e.height||e.fit||e.position||e.withoutEnlargement||e.withoutReduction||e.left!==void 0||e.top!==void 0||e.cropWidth||e.cropHeight||e.angle!==void 0||e.background||e.blur||e.sharpen||e.median||e.clahe||e.threshold!==void 0||e.gamma||e.negate||e.normalise||e.flatten||e.unflatten||e.flip||e.flop||e.greyscale||e.modulate||e.tint||e.brightness!==void 0||e.saturation!==void 0||e.hue!==void 0||e.lightness!==void 0||e.kernel||e.fastShrinkOnLoad||e.affine||e.dilate||e.erode||e.pipelineColourspace||e.toColourspace||e.removeAlpha||e.ensureAlpha||e.format||e.quality)}hasVideoTransformations(e){return!!(e.width||e.height||e.fit||e.position||e.withoutEnlargement||e.withoutReduction||e.left!==void 0||e.top!==void 0||e.cropWidth||e.cropHeight||e.angle||e.background||e.codec||e.bitrate||e.frameRate||e.keyFrameInterval||e.format||e.quality)}hasAudioTransformations(e){return!!(e.sampleRate||e.numberOfChannels||e.codec||e.bitrate||e.format||e.quality)}convertImageResult(e){return{buffer:e.buffer,format:e.format,height:e.height,mediaType:"image",originalFile:e.originalFile,size:e.size,width:e.width}}convertVideoResult(e){return{bitrate:e.bitrate,buffer:e.buffer,duration:e.duration,format:e.format,height:e.height,mediaType:"video",originalFile:e.originalFile,size:e.size,width:e.width}}convertAudioResult(e){return{bitrate:e.bitrate,buffer:e.buffer,duration:e.duration,format:e.format,mediaType:"audio",numberOfChannels:e.numberOfChannels,originalFile:e.originalFile,sampleRate:e.sampleRate,size:e.size}}}export{T as default};
@@ -1 +0,0 @@
1
- import s from"./MetaStorage-DPEUyWgN.js";class n extends s{store;constructor(t){super(t),this.store=t?.store??new Map}async save(t,e){return this.store.set(t,{...e}),{...e}}async get(t){const e=this.store.get(t);if(!e)throw new Error(`Meta not found for id: ${t}`);return{...e}}async delete(t){this.store.delete(t)}async touch(t,e){return this.save(t,e)}clear(){this.store.clear()}}export{n as default};
@@ -1 +0,0 @@
1
- const l=" ".codePointAt(0)??32,f=",".codePointAt(0)??44,p=/^[\d+/A-Z]*={0,2}$/i,u=e=>{if(typeof e!="string")return!1;const t=Number.parseFloat(e);return!Number.isNaN(t)&&Number.isFinite(t)};class g{psize;pname;pfiletype;ptype;pmimeType;pcontentType;ptitle;pfilename;poriginalName;plastModified}const c=e=>{if(e.length===0)return!1;for(let t=0;t<e.length;t+=1){const r=e.codePointAt(t);if(r>127||r===l||r===f)return!1}return!0},d=e=>e.length%4!==0?!1:p.test(e),m=e=>Object.entries(e).map(([t,r])=>{if(r==null)return t;const n=typeof r=="object"?JSON.stringify(r):String(r),a=Buffer.from(n,"utf8").toString("base64");return`${t} ${a}`}).join(","),h=e=>{const t={};if(!e||e.trim().length===0)throw new Error("Metadata string is not valid");for(const r of e.split(",")){const n=r.split(" "),[a,s]=n;if((n.length===1||n.length===2)&&c(a)&&(n.length===1||d(s))&&!(a in t)){let i="";n.length===1?i=void 0:s&&(i=Buffer.from(s,"base64").toString("utf8"));let o=i;if(i!==void 0)try{o=JSON.parse(i)}catch{i==="true"?o=!0:i==="false"?o=!1:u(i)&&(o=Number(i))}t[a]=o}else throw new Error("Metadata string is not valid")}return t};export{g as Metadata,h as parseMetadata,m as stringifyMetadata,c as validateKey,d as validateValue};
@@ -1 +0,0 @@
1
- import{Readable as s}from"node:stream";import{parseMultipartRequest as n,MaxFileSizeExceededError as d,MultipartParseError as l}from"@remix-run/multipart-parser/node";import{n as i}from"./headers-BAiAKekR.js";import{g as m}from"./base-handler-core-BJP9jHCE.js";import{b as f}from"./storage-DR7qdwBN.js";import{T as u}from"./base-handler-node-C8P9rkaH.js";import{p as h}from"./multipart-base-BOzY19lb.js";const c=/^multipart\/.+|application\/x-www-form-urlencoded$/i;class b extends u{static methods=["delete","download","get","options","post"];multipartBase;maxFileSize;maxHeaderSize;constructor(t){super(t),this.maxFileSize=t.maxFileSize??Math.min(this.storage.maxUploadSize,1024*1024*1024),this.maxHeaderSize=t.maxHeaderSize??64*1024;const e=this;this.multipartBase=new class extends h{get storage(){return e.storage}get maxFileSize(){return e.maxFileSize}get maxHeaderSize(){return e.maxHeaderSize}buildFileUrl(r,a){return e.buildFileUrl({url:r},a)}createStreamFromBytes(r){return r instanceof Uint8Array||Buffer.isBuffer(r)?s.from(Buffer.from(r)):typeof r=="number"?s.from(Buffer.alloc(0)):s.from(Buffer.from(String(r)))}createEmptyStream(){return s.from(new Uint8Array(0))}}}async post(t){if(!c.test(t.headers["content-type"]?.split(";")[0]??""))throw i(400,"Invalid content-type");try{const e=[];for await(const o of n(t,{maxFileSize:this.maxFileSize,maxHeaderSize:this.maxHeaderSize}))e.push(o);const r=e.find(o=>o.isFile);if(!r)throw i(400,"No file found in multipart request");const a=t.originalUrl||t.url||"";return this.multipartBase.handlePost(r,e,a)}catch(e){throw e instanceof d?i(413,"File size limit exceeded"):e instanceof l?i(400,"Invalid multipart request"):e instanceof f&&e.statusCode?i(e.statusCode,e.message||e.body||"Validation failed"):e}}async delete(t){try{const e=m(t);return this.multipartBase.handleDelete(e)}catch(e){throw this.checkForUndefinedIdOrPath(e),e.code==="ENOENT"?i(404,"File not found"):e}}compose(){this.registeredHandlers.set("POST",this.post.bind(this)),this.registeredHandlers.set("DELETE",this.delete.bind(this)),this.registeredHandlers.set("GET",this.get.bind(this)),this.registeredHandlers.set("OPTIONS",this.options.bind(this)),this.logger?.debug("Registered handler: %s",[...this.registeredHandlers.keys()].join(", "))}}export{b as default};
@@ -1 +0,0 @@
1
- import e from"./File-W8aOo15X.js";class r extends e{url;pathname}export{r as default};
@@ -1 +0,0 @@
1
- import{y as s}from"./local-meta-storage-BELb1YwO.js";class o extends s{constructor(r){super(r)}}export{o as default};