@visulima/storage 1.0.11 → 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 +17 -0
  2. package/LICENSE.md +159 -19
  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-gEhWlpfS.js +0 -1
  268. package/dist/packem_shared/GCStorage-CRd5vjok.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-B7g1sgkq.js +0 -1
  288. package/dist/packem_shared/Rest-BrEMYgxZ.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-C9F78Sqq.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 +1 @@
1
- import{Input as c,BufferSource as u,ALL_FORMATS as m,Output as d,BufferTarget as h,Conversion as l,Mp3OutputFormat as f,WavOutputFormat as w,OggOutputFormat as g,FlacOutputFormat as y,AdtsOutputFormat as b}from"mediabunny";import O from"../packem_shared/BaseTransformer-Buw5lX_3.js";import{isValidMediaType as F,getFormatFromContentType as T}from"../packem_shared/getFormatFromContentType-DCTTPQHm.js";class R extends O{constructor(t,e={}){const a=e.logger||t.logger,r={cacheTtl:3600,defaultBitrate:128e3,defaultCodec:"aac",maxAudioSize:100*1024*1024,maxCacheSize:100,supportedFormats:["mp3","wav","ogg","aac","flac","m4a","wma","aiff"],...e};super(t,r,a)}async resample(t,e){return this.transform(t,[{options:e,type:"resample"}])}async mixChannels(t,e){return this.transform(t,[{options:e,type:"channels"}])}async convertFormat(t,e,a={}){return this.transform(t,[{options:{...a,format:e},type:"format"}])}async transcode(t,e,a={}){return this.transform(t,[{options:{...a,codec:e},type:"codec"}])}async transform(t,e){const a={id:t},r=this.generateCacheKey(t,e);if(this.cache){const s=await Promise.resolve(this.cache.get(r));if(s)return this.logger?.debug("Returning cached transformed audio for %s",t),s}const o=await this.storage.get(a);await this.validateAudio(o);const i=await this.applyTransformations(o.content,e),n=await this.createTransformResult(i,o);return this.cache&&this.cache.set(r,n),n}async applyTransformations(t,e){const a=new c({formats:m,source:new u(t)}),r=this.determineOutputFormat(e),o=new d({format:r,target:new h}),i=this.stepsToAudioOptions(e),n=await l.init({audio:i,input:a,output:o});if(!n.isValid){const s=n.discardedTracks.map(p=>p.reason).join(", ");throw new Error(`Audio transformation failed: ${s}`)}return await n.execute(),Buffer.from(o.target.buffer)}stepsToAudioOptions(t){const e={};for(const a of t)switch(a.type){case"bitrate":{const r=a.options;r.bitrate&&(e.bitrate=r.bitrate);break}case"channels":{const r=a.options;r.numberOfChannels&&(e.numberOfChannels=r.numberOfChannels);break}case"codec":{const r=a.options;r.codec&&(e.codec=r.codec),r.bitrate&&(e.bitrate=r.bitrate);break}case"resample":{const r=a.options;r.sampleRate&&(e.sampleRate=r.sampleRate);break}}return e}determineOutputFormat(t){for(const e of t)if(e.type==="format"&&e.options.format)return this.formatStringToOutputFormat(e.options.format);return new f}formatStringToOutputFormat(t){switch(t.toLowerCase()){case"aac":return new b;case"flac":return new y;case"mp3":return new f;case"ogg":return new g;case"wav":return new w;default:return new f}}async validateAudio(t){const e=typeof t.size=="string"?Number.parseInt(t.size,10):t.size;if(this.config?.maxAudioSize&&e>this.config.maxAudioSize)throw new Error(`Audio size ${e} exceeds maximum allowed size ${this.config.maxAudioSize}`);if(!F(t.contentType,"audio"))throw new Error(`File is not audio: ${t.contentType}`);const a=T(t.contentType);if(this.config?.supportedFormats&&a&&!this.config.supportedFormats.includes(a))throw new Error(`Unsupported audio format: ${a}`);try{if(!await new c({formats:m,source:new u(t.content)}).getPrimaryAudioTrack())throw new Error("No audio track found")}catch(r){throw new Error(`Invalid audio file: ${r}`)}}async createTransformResult(t,e){const a=new c({formats:m,source:new u(t)}),r=await a.getPrimaryAudioTrack(),o=await a.computeDuration();return{bitrate:this.config.defaultBitrate,buffer:t,duration:o,format:"mp3",numberOfChannels:r?.numberOfChannels||2,originalFile:e,sampleRate:r?.sampleRate||44100,size:t.length}}generateCacheKey(t,e){const a=e.map(r=>`${r.type}:${JSON.stringify(r.options)}`).join("|");return`${t}:${a}`}}export{R as default};
1
+ import{Input as c,BufferSource as u,ALL_FORMATS as m,Output as d,BufferTarget as h,Conversion as l,Mp3OutputFormat as p,WavOutputFormat as w,OggOutputFormat as g,FlacOutputFormat as y,AdtsOutputFormat as O}from"mediabunny";import T from"../packem_shared/BaseTransformer-ByIAKnn8.js";import{isValidMediaType as F,getFormatFromContentType as b}from"../packem_shared/getFormatFromContentType-BAVdaQ0o.js";class x extends T{constructor(t,e={}){const o=e.logger||t.logger,r={cacheTtl:3600,defaultBitrate:128e3,defaultCodec:"aac",maxAudioSize:100*1024*1024,maxCacheSize:100,supportedFormats:["mp3","wav","ogg","aac","flac","m4a","wma","aiff"],...e};super(t,r,o)}async resample(t,e){return this.transform(t,[{options:e,type:"resample"}])}async mixChannels(t,e){return this.transform(t,[{options:e,type:"channels"}])}async convertFormat(t,e,o={}){return this.transform(t,[{options:{...o,format:e},type:"format"}])}async transcode(t,e,o={}){return this.transform(t,[{options:{...o,codec:e},type:"codec"}])}async transform(t,e){const o={id:t},r=this.generateCacheKey(t,e);if(this.cache){const s=await Promise.resolve(this.cache.get(r));if(s)return this.logger?.debug("Returning cached transformed audio for %s",t),s}const a=await this.storage.get(o);await this.validateAudio(a);const i=await this.applyTransformations(a.content,e),n=await this.createTransformResult(i,a);return this.cache&&this.cache.set(r,n),n}async applyTransformations(t,e){const o=new c({formats:m,source:new u(t)}),r=this.determineOutputFormat(e),a=new d({format:r,target:new h}),i=this.stepsToAudioOptions(e),n=await l.init({audio:i,input:o,output:a});if(!n.isValid){const s=n.discardedTracks.map(f=>f.reason).join(", ");throw new Error(`Audio transformation failed: ${s}`)}return await n.execute(),Buffer.from(a.target.buffer)}stepsToAudioOptions(t){const e={};for(const o of t)switch(o.type){case"bitrate":{const r=o.options;r.bitrate&&(e.bitrate=r.bitrate);break}case"channels":{const r=o.options;r.numberOfChannels&&(e.numberOfChannels=r.numberOfChannels);break}case"codec":{const r=o.options;r.codec&&(e.codec=r.codec),r.bitrate&&(e.bitrate=r.bitrate);break}case"resample":{const r=o.options;r.sampleRate&&(e.sampleRate=r.sampleRate);break}}return e}determineOutputFormat(t){for(const e of t)if(e.type==="format"&&e.options.format)return this.formatStringToOutputFormat(e.options.format);return new p}formatStringToOutputFormat(t){switch(t.toLowerCase()){case"aac":return new O;case"flac":return new y;case"mp3":return new p;case"ogg":return new g;case"wav":return new w;default:return new p}}async validateAudio(t){const e=typeof t.size=="string"?Number.parseInt(t.size,10):t.size;if(this.config?.maxAudioSize&&e>this.config.maxAudioSize)throw new Error(`Audio size ${e} exceeds maximum allowed size ${this.config.maxAudioSize}`);if(!F(t.contentType,"audio"))throw new Error(`File is not audio: ${t.contentType}`);const o=b(t.contentType);if(this.config?.supportedFormats&&o&&!this.config.supportedFormats.includes(o))throw new Error(`Unsupported audio format: ${o}`);try{if(!await new c({formats:m,source:new u(t.content)}).getPrimaryAudioTrack())throw new Error("No audio track found")}catch(r){throw new Error(`Invalid audio file: ${r}`)}}async createTransformResult(t,e){const o=new c({formats:m,source:new u(t)}),r=await o.getPrimaryAudioTrack(),a=await o.computeDuration();return{bitrate:this.config.defaultBitrate,buffer:t,duration:a,format:"mp3",numberOfChannels:r?.numberOfChannels||2,originalFile:e,sampleRate:r?.sampleRate||44100,size:t.length}}generateCacheKey(t,e){const o=e.map(r=>`${r.type}:${JSON.stringify(r.options)}`).join("|");return`${t}:${o}`}}export{x as default};
@@ -1,6 +1,6 @@
1
1
  import { Readable } from 'node:stream';
2
- import { F as File, g as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-DwdJrArF.js";
3
- import { I as ImageTransformerConfig, T as TransformResult, R as ResizeOptions, C as CropOptions, g as RotateOptions, h as ImageFormat, i as TransformOptions, S as SharpenOptions, j as BlurOptions, k as MedianOptions, l as CLAHEOptions, m as ConvolveOptions, n as ThresholdOptions, o as BooleanOptions, L as LinearOptions, p as RecombineOptions, q as ModulateOptions, r as TintOptions, G as GreyscaleOptions, s as ColourspaceOptions, E as ExtractChannelOptions, J as JoinChannelOptions, t as BandboolOptions, u as AffineOptions, D as DilateOptions, v as ErodeOptions, P as PipelineColourspaceOptions, w as ToColourspaceOptions, x as RemoveAlphaOptions, y as EnsureAlphaOptions, z as TransformationStep, B as BaseTransformer } from "../packem_shared/types.d-BEUv414z.js";
2
+ import { F as File, g as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-C9EdfTf1.js";
3
+ import { I as ImageTransformerConfig, T as TransformResult, R as ResizeOptions, C as CropOptions, g as RotateOptions, h as ImageFormat, i as TransformOptions, S as SharpenOptions, j as BlurOptions, k as MedianOptions, l as CLAHEOptions, m as ConvolveOptions, n as ThresholdOptions, o as BooleanOptions, L as LinearOptions, p as RecombineOptions, q as ModulateOptions, r as TintOptions, G as GreyscaleOptions, s as ColourspaceOptions, E as ExtractChannelOptions, J as JoinChannelOptions, t as BandboolOptions, u as AffineOptions, D as DilateOptions, v as ErodeOptions, P as PipelineColourspaceOptions, w as ToColourspaceOptions, x as RemoveAlphaOptions, y as EnsureAlphaOptions, z as TransformationStep, B as BaseTransformer } from "../packem_shared/types.d-D1TIRqKW.js";
4
4
  import 'node:timers';
5
5
  import 'node:crypto';
6
6
  import 'node:http';
@@ -1 +1 @@
1
- import{Readable as u}from"node:stream";import y from"sharp";import g from"../packem_shared/BaseTransformer-Buw5lX_3.js";import{isValidMediaType as d,getFormatFromContentType as f}from"../packem_shared/getFormatFromContentType-DCTTPQHm.js";class C extends g{constructor(e,a={}){const t=a.logger||e.logger,n={cacheTtl:3600,failOn:"warning",limitInputPixels:268435456,maxCacheSize:100,maxImageSize:50*1024*1024,supportedFormats:["jpeg","png","webp","avif","tiff","gif","svg"],...a};super(e,n,t)}openImage(e){return y(e,{failOn:this.config?.failOn??"warning",limitInputPixels:this.config?.limitInputPixels??268435456})}async resize(e,a){return this.transform(e,[{options:a,type:"resize"}])}async crop(e,a){return this.transform(e,[{options:a,type:"crop"}])}async rotate(e,a){return this.transform(e,[{options:a,type:"rotate"}])}async convertFormat(e,a,t={}){return this.transform(e,[{options:{...t,format:a},type:"format"}])}async sharpen(e,a={}){return this.transform(e,[{options:a,type:"sharpen"}])}async blur(e,a={}){return this.transform(e,[{options:a,type:"blur"}])}async median(e,a={}){return this.transform(e,[{options:a,type:"median"}])}async clahe(e,a={}){return this.transform(e,[{options:a,type:"clahe"}])}async convolve(e,a){return this.transform(e,[{options:a,type:"convolve"}])}async threshold(e,a={}){return this.transform(e,[{options:a,type:"threshold"}])}async boolean(e,a){return this.transform(e,[{options:a,type:"boolean"}])}async linear(e,a){return this.transform(e,[{options:a,type:"linear"}])}async recombine(e,a){return this.transform(e,[{options:a,type:"recombine"}])}async modulate(e,a){return this.transform(e,[{options:a,type:"modulate"}])}async tint(e,a){return this.transform(e,[{options:a,type:"tint"}])}async greyscale(e,a={}){return this.transform(e,[{options:a,type:"greyscale"}])}async colourspace(e,a){return this.transform(e,[{options:a,type:"colourspace"}])}async extractChannel(e,a){return this.transform(e,[{options:a,type:"extractChannel"}])}async joinChannel(e,a){return this.transform(e,[{options:a,type:"joinChannel"}])}async bandbool(e,a){return this.transform(e,[{options:a,type:"bandbool"}])}async autoOrient(e,a={}){return this.transform(e,[{options:a,type:"autoOrient"}])}async flip(e,a={}){return this.transform(e,[{options:a,type:"flip"}])}async flop(e,a={}){return this.transform(e,[{options:a,type:"flop"}])}async flatten(e,a={}){return this.transform(e,[{options:a,type:"flatten"}])}async unflatten(e,a={}){return this.transform(e,[{options:a,type:"unflatten"}])}async gamma(e,a={}){return this.transform(e,[{options:a,type:"gamma"}])}async negate(e,a={}){return this.transform(e,[{options:a,type:"negate"}])}async normalise(e,a={}){return this.transform(e,[{options:a,type:"normalise"}])}async affine(e,a){return this.transform(e,[{options:a,type:"affine"}])}async dilate(e,a={}){return this.transform(e,[{options:a,type:"dilate"}])}async erode(e,a={}){return this.transform(e,[{options:a,type:"erode"}])}async pipelineColourspace(e,a){return this.transform(e,[{options:a,type:"pipelineColourspace"}])}async toColourspace(e,a){return this.transform(e,[{options:a,type:"toColourspace"}])}async removeAlpha(e,a={}){return this.transform(e,[{options:a,type:"removeAlpha"}])}async ensureAlpha(e,a={}){return this.transform(e,[{options:a,type:"ensureAlpha"}])}async transform(e,a){const t={id:e},n=this.generateCacheKey(e,a),o=this.cache?await Promise.resolve(this.cache.get(n)):void 0;if(o)return this.logger?.debug("Returning cached transformed image for %s",e),o;const r=await this.storage.get(t);await this.validateImage(r);const s=await this.applyTransformations(r.content,a),i=await this.createTransformResult(s,r);return this.cache&&this.cache.set(n,i),i}async transformStream(e,a){const t=await this.transform(e,a);return{headers:{"Content-Length":t.buffer.length.toString(),"Content-Type":this.getContentTypeFromResult(t),"X-Image-Height":t.height?.toString(),"X-Image-Width":t.width?.toString()},size:t.buffer.length,stream:u.from(t.buffer)}}async applyTransformations(e,a){let t=this.openImage(e);for(const n of a)switch(n.type){case"affine":{t=this.applyAffine(t,n.options);break}case"autoOrient":{t=t.rotate();break}case"bandbool":{t=this.applyBandbool(t,n.options);break}case"blur":{t=this.applyBlur(t,n.options);break}case"boolean":{t=this.applyBoolean(t,n.options);break}case"clahe":{t=this.applyCLAHE(t,n.options);break}case"colourspace":{t=this.applyColourspace(t,n.options);break}case"convolve":{t=this.applyConvolve(t,n.options);break}case"crop":{t=this.applyCrop(t,n.options);break}case"dilate":{t=this.applyDilate(t,n.options);break}case"ensureAlpha":{t=this.applyEnsureAlpha(t,n.options);break}case"erode":{t=this.applyErode(t,n.options);break}case"extractChannel":{t=this.applyExtractChannel(t,n.options);break}case"flatten":{t=t.flatten();break}case"flip":{t=t.flip();break}case"flop":{t=t.flop();break}case"format":case"quality":{t=this.applyFormatAndQuality(t,n.options);break}case"gamma":{t=t.gamma();break}case"greyscale":{t=this.applyGreyscale(t,n.options);break}case"joinChannel":{t=this.applyJoinChannel(t,n.options);break}case"linear":{t=this.applyLinear(t,n.options);break}case"median":{t=this.applyMedian(t,n.options);break}case"modulate":{t=this.applyModulate(t,n.options);break}case"negate":{t=t.negate();break}case"normalise":case"normalize":{t=t.normalise();break}case"pipelineColourspace":{t=this.applyPipelineColourspace(t,n.options);break}case"recombine":{t=this.applyRecombine(t,n.options);break}case"removeAlpha":{t=this.applyRemoveAlpha(t,n.options);break}case"resize":{t=this.applyResize(t,n.options);break}case"rotate":{t=this.applyRotate(t,n.options);break}case"sharpen":{t=this.applySharpen(t,n.options);break}case"threshold":{t=this.applyThreshold(t,n.options);break}case"tint":{t=this.applyTint(t,n.options);break}case"toColourspace":{t=this.applyToColourspace(t,n.options);break}case"unflatten":{t=t.unflatten();break}default:throw new Error(`Unknown transformation type: ${n.type}`)}return t.toBuffer()}applyResize(e,a){const{background:t,fastShrinkOnLoad:n,fit:o="cover",height:r,kernel:s,position:i,width:l,withoutEnlargement:p,withoutReduction:m,...c}=a;let h={background:t||"transparent",fastShrinkOnLoad:n,fit:o,height:r,kernel:s,position:i,width:l,withoutEnlargement:p,withoutReduction:m};return Object.keys(c).length>0&&(h={...h,...this.getFormatOptions(c)}),e.resize(h)}applyCrop(e,a){const{height:t,left:n,top:o,width:r,...s}=a;let i=e.extract({height:t,left:n,top:o,width:r});return Object.keys(s).length>0&&(i=this.applyFormatAndQuality(i,s)),i}applyRotate(e,a){const{angle:t,background:n,...o}=a;let r=e.rotate(t,{background:n||"transparent"});return Object.keys(o).length>0&&(r=this.applyFormatAndQuality(r,o)),r}applySharpen(e,a){const{sigma:t,...n}=a,o={};t!==void 0&&(o.sigma=t);let r=e.sharpen(o);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyBlur(e,a){const{sigma:t,...n}=a;let o=e.blur(t===void 0?!0:t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyMedian(e,a){const{size:t,...n}=a;let o=e.median(t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyCLAHE(e,a){const{height:t,maxSlope:n,width:o,...r}=a;if(o===void 0||t===void 0)throw new Error("CLAHE transformation requires both `width` and `height`.");let s=e.clahe({height:t,maxSlope:n,width:o});return Object.keys(r).length>0&&(s=this.applyFormatAndQuality(s,r)),s}applyConvolve(e,a){const{height:t,kernel:n,offset:o,scale:r,width:s,...i}=a;if(s===void 0||t===void 0||n===void 0)throw new Error("Convolve transformation requires `width`, `height`, and `kernel`.");let l=e.convolve({height:t,kernel:n,offset:o,scale:r,width:s});return Object.keys(i).length>0&&(l=this.applyFormatAndQuality(l,i)),l}applyThreshold(e,a){const{grayscale:t,greyscale:n,threshold:o=128,...r}=a;let s=e.threshold(o,{greyscale:n||t});return Object.keys(r).length>0&&(s=this.applyFormatAndQuality(s,r)),s}applyBoolean(e,a){const{operand:t,operator:n,raw:o,...r}=a;let s=e.boolean(t,n,o);return Object.keys(r).length>0&&(s=this.applyFormatAndQuality(s,r)),s}applyLinear(e,a){const{a:t,b:n,...o}=a;let r=e.linear(t,n);return Object.keys(o).length>0&&(r=this.applyFormatAndQuality(r,o)),r}applyRecombine(e,a){const{matrix:t,...n}=a;let o=e.recomb(t.flat());return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyModulate(e,a){const{brightness:t,hue:n,lightness:o,saturation:r,...s}=a;let i=e.modulate({brightness:t,hue:n,lightness:o,saturation:r});return Object.keys(s).length>0&&(i=this.applyFormatAndQuality(i,s)),i}applyTint(e,a){const{rgb:t,...n}=a;let o=e.tint(Array.isArray(t)?{b:t[2],g:t[1],r:t[0]}:t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyGreyscale(e,a){const{grayscale:t,greyscale:n,...o}=a;let r=e.greyscale(n||t);return Object.keys(o).length>0&&(r=this.applyFormatAndQuality(r,o)),r}applyColourspace(e,a){const{colourspace:t,...n}=a;let o=e.toColourspace(t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyExtractChannel(e,a){const{channel:t,...n}=a;let o=e.extractChannel(t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyJoinChannel(e,a){const{images:t,...n}=a;let o=e.joinChannel(t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyBandbool(e,a){const{operator:t,...n}=a;let o=e.bandbool(t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyAffine(e,a){const{background:t,interpolation:n,matrix:o,...r}=a;let s=e.affine(o,{background:t||"transparent",interpolator:n||"bicubic"});return Object.keys(r).length>0&&(s=this.applyFormatAndQuality(s,r)),s}applyDilate(e,a){const{kernelSize:t,...n}=a;let o=t?e.dilate(t):e.dilate();return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyErode(e,a){const{kernelSize:t,...n}=a;let o=t?e.erode(t):e.erode();return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyPipelineColourspace(e,a){const{colourspace:t,...n}=a;let o=e.pipelineColourspace(t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyToColourspace(e,a){const{colourspace:t,...n}=a;let o=e.toColourspace(t);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyRemoveAlpha(e,a){const{background:t,...n}=a;let o=e.removeAlpha();return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyEnsureAlpha(e,a){const{alpha:t,...n}=a;let o=e.ensureAlpha();return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyFormatAndQuality(e,a){const t=this.getFormatOptions(a);return a.format?e.toFormat(a.format,t):Object.keys(t).length>0?e.jpeg(t).png(t).webp(t):e}getFormatOptions(e){const{alphaQuality:a,compressionLevel:t,delay:n,effort:o,loop:r,lossless:s,progressive:i,quality:l}=e,p={};return l!==void 0&&(p.quality=l),i!==void 0&&(p.progressive=i),s!==void 0&&(p.lossless=s),t!==void 0&&(p.compressionLevel=t),o!==void 0&&(p.effort=o),a!==void 0&&(p.alphaQuality=a),r!==void 0&&(p.loop=r),n!==void 0&&(p.delay=n),p}async validateImage(e){const a=typeof e.size=="string"?Number.parseInt(e.size,10):e.size;if(this.config?.maxImageSize&&a>this.config.maxImageSize)throw new Error(`Image size ${a} exceeds maximum allowed size ${this.config.maxImageSize}`);if(!d(e.contentType,"image"))throw new Error(`File is not an image: ${e.contentType}`);const t=f(e.contentType);if(this.config?.supportedFormats&&t&&!this.config.supportedFormats.includes(t))throw new Error(`Unsupported image format: ${t}`);try{const n=await this.openImage(e.content).metadata();if(!n.width||!n.height)throw new Error("Invalid image: missing dimensions");const{maxImageHeight:o,maxImageWidth:r}=this.config??{};if(r!==void 0&&n.width>r)throw new Error(`Image width ${n.width}px exceeds maximum ${r}px`);if(o!==void 0&&n.height>o)throw new Error(`Image height ${n.height}px exceeds maximum ${o}px`)}catch(n){throw new Error(`Invalid image file: ${n}`)}}async createTransformResult(e,a){const t=await y(e).metadata();return{buffer:e,format:t.format||"unknown",height:t.height||0,originalFile:a,size:e.length,width:t.width||0}}generateCacheKey(e,a){const t=a.map(n=>`${n.type}:${JSON.stringify(n.options)}`).join("|");return`${e}:${t}`}}export{C as default};
1
+ import{Readable as f}from"node:stream";import y from"sharp";import u from"../packem_shared/BaseTransformer-ByIAKnn8.js";import{isValidMediaType as g,getFormatFromContentType as d}from"../packem_shared/getFormatFromContentType-BAVdaQ0o.js";class A extends u{constructor(e,a={}){const t=a.logger||e.logger,n={cacheTtl:3600,failOn:"warning",limitInputPixels:268435456,maxCacheSize:100,maxImageSize:50*1024*1024,supportedFormats:["jpeg","png","webp","avif","tiff","gif","svg"],...a};super(e,n,t)}openImage(e){return y(e,{failOn:this.config?.failOn??"warning",limitInputPixels:this.config?.limitInputPixels??268435456})}async resize(e,a){return this.transform(e,[{options:a,type:"resize"}])}async crop(e,a){return this.transform(e,[{options:a,type:"crop"}])}async rotate(e,a){return this.transform(e,[{options:a,type:"rotate"}])}async convertFormat(e,a,t={}){return this.transform(e,[{options:{...t,format:a},type:"format"}])}async sharpen(e,a={}){return this.transform(e,[{options:a,type:"sharpen"}])}async blur(e,a={}){return this.transform(e,[{options:a,type:"blur"}])}async median(e,a={}){return this.transform(e,[{options:a,type:"median"}])}async clahe(e,a={}){return this.transform(e,[{options:a,type:"clahe"}])}async convolve(e,a){return this.transform(e,[{options:a,type:"convolve"}])}async threshold(e,a={}){return this.transform(e,[{options:a,type:"threshold"}])}async boolean(e,a){return this.transform(e,[{options:a,type:"boolean"}])}async linear(e,a){return this.transform(e,[{options:a,type:"linear"}])}async recombine(e,a){return this.transform(e,[{options:a,type:"recombine"}])}async modulate(e,a){return this.transform(e,[{options:a,type:"modulate"}])}async tint(e,a){return this.transform(e,[{options:a,type:"tint"}])}async greyscale(e,a={}){return this.transform(e,[{options:a,type:"greyscale"}])}async colourspace(e,a){return this.transform(e,[{options:a,type:"colourspace"}])}async extractChannel(e,a){return this.transform(e,[{options:a,type:"extractChannel"}])}async joinChannel(e,a){return this.transform(e,[{options:a,type:"joinChannel"}])}async bandbool(e,a){return this.transform(e,[{options:a,type:"bandbool"}])}async autoOrient(e,a={}){return this.transform(e,[{options:a,type:"autoOrient"}])}async flip(e,a={}){return this.transform(e,[{options:a,type:"flip"}])}async flop(e,a={}){return this.transform(e,[{options:a,type:"flop"}])}async flatten(e,a={}){return this.transform(e,[{options:a,type:"flatten"}])}async unflatten(e,a={}){return this.transform(e,[{options:a,type:"unflatten"}])}async gamma(e,a={}){return this.transform(e,[{options:a,type:"gamma"}])}async negate(e,a={}){return this.transform(e,[{options:a,type:"negate"}])}async normalise(e,a={}){return this.transform(e,[{options:a,type:"normalise"}])}async affine(e,a){return this.transform(e,[{options:a,type:"affine"}])}async dilate(e,a={}){return this.transform(e,[{options:a,type:"dilate"}])}async erode(e,a={}){return this.transform(e,[{options:a,type:"erode"}])}async pipelineColourspace(e,a){return this.transform(e,[{options:a,type:"pipelineColourspace"}])}async toColourspace(e,a){return this.transform(e,[{options:a,type:"toColourspace"}])}async removeAlpha(e,a={}){return this.transform(e,[{options:a,type:"removeAlpha"}])}async ensureAlpha(e,a={}){return this.transform(e,[{options:a,type:"ensureAlpha"}])}async transform(e,a){const t={id:e},n=this.generateCacheKey(e,a),r=this.cache?await Promise.resolve(this.cache.get(n)):void 0;if(r)return this.logger?.debug("Returning cached transformed image for %s",e),r;const o=await this.storage.get(t);await this.validateImage(o);const s=await this.applyTransformations(o.content,a),i=await this.createTransformResult(s,o);return this.cache&&this.cache.set(n,i),i}async transformStream(e,a){const t=await this.transform(e,a);return{headers:{"Content-Length":t.buffer.length.toString(),"Content-Type":this.getContentTypeFromResult(t),"X-Image-Height":t.height?.toString(),"X-Image-Width":t.width?.toString()},size:t.buffer.length,stream:f.from(t.buffer)}}async applyTransformations(e,a){let t=this.openImage(e);for(const n of a)switch(n.type){case"affine":{t=this.applyAffine(t,n.options);break}case"autoOrient":{t=t.rotate();break}case"bandbool":{t=this.applyBandbool(t,n.options);break}case"blur":{t=this.applyBlur(t,n.options);break}case"boolean":{t=this.applyBoolean(t,n.options);break}case"clahe":{t=this.applyCLAHE(t,n.options);break}case"colourspace":{t=this.applyColourspace(t,n.options);break}case"convolve":{t=this.applyConvolve(t,n.options);break}case"crop":{t=this.applyCrop(t,n.options);break}case"dilate":{t=this.applyDilate(t,n.options);break}case"ensureAlpha":{t=this.applyEnsureAlpha(t,n.options);break}case"erode":{t=this.applyErode(t,n.options);break}case"extractChannel":{t=this.applyExtractChannel(t,n.options);break}case"flatten":{t=t.flatten();break}case"flip":{t=t.flip();break}case"flop":{t=t.flop();break}case"format":case"quality":{t=this.applyFormatAndQuality(t,n.options);break}case"gamma":{t=t.gamma();break}case"greyscale":{t=this.applyGreyscale(t,n.options);break}case"joinChannel":{t=this.applyJoinChannel(t,n.options);break}case"linear":{t=this.applyLinear(t,n.options);break}case"median":{t=this.applyMedian(t,n.options);break}case"modulate":{t=this.applyModulate(t,n.options);break}case"negate":{t=t.negate();break}case"normalise":case"normalize":{t=t.normalise();break}case"pipelineColourspace":{t=this.applyPipelineColourspace(t,n.options);break}case"recombine":{t=this.applyRecombine(t,n.options);break}case"removeAlpha":{t=this.applyRemoveAlpha(t,n.options);break}case"resize":{t=this.applyResize(t,n.options);break}case"rotate":{t=this.applyRotate(t,n.options);break}case"sharpen":{t=this.applySharpen(t,n.options);break}case"threshold":{t=this.applyThreshold(t,n.options);break}case"tint":{t=this.applyTint(t,n.options);break}case"toColourspace":{t=this.applyToColourspace(t,n.options);break}case"unflatten":{t=t.unflatten();break}default:throw new Error(`Unknown transformation type: ${n.type}`)}return t.toBuffer()}applyResize(e,a){const{background:t,fastShrinkOnLoad:n,fit:r="cover",height:o,kernel:s,position:i,width:l,withoutEnlargement:p,withoutReduction:m,...h}=a;let c={background:t||"transparent",fastShrinkOnLoad:n,fit:r,height:o,kernel:s,position:i,width:l,withoutEnlargement:p,withoutReduction:m};return Object.keys(h).length>0&&(c={...c,...this.getFormatOptions(h)}),e.resize(c)}applyCrop(e,a){const{height:t,left:n,top:r,width:o,...s}=a;let i=e.extract({height:t,left:n,top:r,width:o});return Object.keys(s).length>0&&(i=this.applyFormatAndQuality(i,s)),i}applyRotate(e,a){const{angle:t,background:n,...r}=a;let o=e.rotate(t,{background:n||"transparent"});return Object.keys(r).length>0&&(o=this.applyFormatAndQuality(o,r)),o}applySharpen(e,a){const{sigma:t,...n}=a,r={};t!==void 0&&(r.sigma=t);let o=e.sharpen(r);return Object.keys(n).length>0&&(o=this.applyFormatAndQuality(o,n)),o}applyBlur(e,a){const{sigma:t,...n}=a;let r=e.blur(t===void 0?!0:t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyMedian(e,a){const{size:t,...n}=a;let r=e.median(t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyCLAHE(e,a){const{height:t,maxSlope:n,width:r,...o}=a;if(r===void 0||t===void 0)throw new Error("CLAHE transformation requires both `width` and `height`.");let s=e.clahe({height:t,maxSlope:n,width:r});return Object.keys(o).length>0&&(s=this.applyFormatAndQuality(s,o)),s}applyConvolve(e,a){const{height:t,kernel:n,offset:r,scale:o,width:s,...i}=a;if(s===void 0||t===void 0||n===void 0)throw new Error("Convolve transformation requires `width`, `height`, and `kernel`.");let l=e.convolve({height:t,kernel:n,offset:r,scale:o,width:s});return Object.keys(i).length>0&&(l=this.applyFormatAndQuality(l,i)),l}applyThreshold(e,a){const{grayscale:t,greyscale:n,threshold:r=128,...o}=a;let s=e.threshold(r,{greyscale:n||t});return Object.keys(o).length>0&&(s=this.applyFormatAndQuality(s,o)),s}applyBoolean(e,a){const{operand:t,operator:n,raw:r,...o}=a;let s=e.boolean(t,n,r);return Object.keys(o).length>0&&(s=this.applyFormatAndQuality(s,o)),s}applyLinear(e,a){const{a:t,b:n,...r}=a;let o=e.linear(t,n);return Object.keys(r).length>0&&(o=this.applyFormatAndQuality(o,r)),o}applyRecombine(e,a){const{matrix:t,...n}=a;let r=e.recomb(t.flat());return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyModulate(e,a){const{brightness:t,hue:n,lightness:r,saturation:o,...s}=a;let i=e.modulate({brightness:t,hue:n,lightness:r,saturation:o});return Object.keys(s).length>0&&(i=this.applyFormatAndQuality(i,s)),i}applyTint(e,a){const{rgb:t,...n}=a;let r=e.tint(Array.isArray(t)?{b:t[2],g:t[1],r:t[0]}:t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyGreyscale(e,a){const{grayscale:t,greyscale:n,...r}=a;let o=e.greyscale(n||t);return Object.keys(r).length>0&&(o=this.applyFormatAndQuality(o,r)),o}applyColourspace(e,a){const{colourspace:t,...n}=a;let r=e.toColourspace(t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyExtractChannel(e,a){const{channel:t,...n}=a;let r=e.extractChannel(t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyJoinChannel(e,a){const{images:t,...n}=a;let r=e.joinChannel(t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyBandbool(e,a){const{operator:t,...n}=a;let r=e.bandbool(t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyAffine(e,a){const{background:t,interpolation:n,matrix:r,...o}=a;let s=e.affine(r,{background:t||"transparent",interpolator:n||"bicubic"});return Object.keys(o).length>0&&(s=this.applyFormatAndQuality(s,o)),s}applyDilate(e,a){const{kernelSize:t,...n}=a;let r=t?e.dilate(t):e.dilate();return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyErode(e,a){const{kernelSize:t,...n}=a;let r=t?e.erode(t):e.erode();return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyPipelineColourspace(e,a){const{colourspace:t,...n}=a;let r=e.pipelineColourspace(t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyToColourspace(e,a){const{colourspace:t,...n}=a;let r=e.toColourspace(t);return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyRemoveAlpha(e,a){const{background:t,...n}=a;let r=e.removeAlpha();return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyEnsureAlpha(e,a){const{alpha:t,...n}=a;let r=e.ensureAlpha();return Object.keys(n).length>0&&(r=this.applyFormatAndQuality(r,n)),r}applyFormatAndQuality(e,a){const t=this.getFormatOptions(a);return a.format?e.toFormat(a.format,t):Object.keys(t).length>0?e.jpeg(t).png(t).webp(t):e}getFormatOptions(e){const{alphaQuality:a,compressionLevel:t,delay:n,effort:r,loop:o,lossless:s,progressive:i,quality:l}=e,p={};return l!==void 0&&(p.quality=l),i!==void 0&&(p.progressive=i),s!==void 0&&(p.lossless=s),t!==void 0&&(p.compressionLevel=t),r!==void 0&&(p.effort=r),a!==void 0&&(p.alphaQuality=a),o!==void 0&&(p.loop=o),n!==void 0&&(p.delay=n),p}async validateImage(e){const a=typeof e.size=="string"?Number.parseInt(e.size,10):e.size;if(this.config?.maxImageSize&&a>this.config.maxImageSize)throw new Error(`Image size ${a} exceeds maximum allowed size ${this.config.maxImageSize}`);if(!g(e.contentType,"image"))throw new Error(`File is not an image: ${e.contentType}`);const t=d(e.contentType);if(this.config?.supportedFormats&&t&&!this.config.supportedFormats.includes(t))throw new Error(`Unsupported image format: ${t}`);try{const n=await this.openImage(e.content).metadata();if(!n.width||!n.height)throw new Error("Invalid image: missing dimensions");const{maxImageHeight:r,maxImageWidth:o}=this.config??{};if(o!==void 0&&n.width>o)throw new Error(`Image width ${n.width}px exceeds maximum ${o}px`);if(r!==void 0&&n.height>r)throw new Error(`Image height ${n.height}px exceeds maximum ${r}px`)}catch(n){throw new Error(`Invalid image file: ${n}`)}}async createTransformResult(e,a){const t=await y(e).metadata();return{buffer:e,format:t.format||"unknown",height:t.height||0,originalFile:a,size:e.length,width:t.width||0}}generateCacheKey(e,a){const t=a.map(n=>`${n.type}:${JSON.stringify(n.options)}`).join("|");return`${e}:${t}`}}export{A as default};
@@ -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": "1.0.11",
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": "6.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-C9F78Sqq.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-C9F78Sqq.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 B extends Error{constructor(t,s,e){super(t),this.code=s,this.config=e}code;config;name="FetchError"}const $=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 s=t.bucket||process.env.GCS_BUCKET;if(!s)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=s,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:i}=t;this.userProject=i,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:a}=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&&a===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 s=+t.code||500;return{code:`GCS${s}`,message:t.message,name:t.name,retryable:s>=499,statusCode:s}}return{code:"GenericUploadError",message:`[${this.constructor.name}] ${t.message}`,name:t.name,statusCode:500}}async create(t,s){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const a=typeof t.ttl=="string"?S(t.ttl):t.ttl;a!==void 0&&(e.expiredAt=Date.now()+a)}const r=new x(e);r.name=this.namingFunction(r),await this.validate(r);try{const a=await this.getMeta(r.id);return a.bytesWritten=await this.internalWrite(a,s),a}catch{}const i={"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:i,method:"POST",params:{name:r.name,size:r.size,uploadType:"resumable"},url:this.uploadBaseURI},c=await this.makeRequest(n,s);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,s){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:i,stream:n}=await E(t.body);i?.mime&&(e.contentType=i.mime),t.body=n}catch{}e.bytesWritten=await this.internalWrite({...e,...t},s),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},s){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:$},s),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,s,e){return this.instrumentOperation("copy",async()=>{const r=new URL(`/${this.bucket}/${t}`,"file://"),i=new URL(encodeURI(s),r).pathname,[,n,...c]=i.split("/"),o=c.join("/"),a=`${this.storageBaseURI}/${t}/rewriteTo/b/${n}/o/${o}`;let u={};const h={body:"",headers:{"Content-Type":"application/json"},method:"POST",url:a};do h.body=u.rewriteToken?JSON.stringify({rewriteToken:u.rewriteToken}):"",u=(await this.makeRequest(h,e)).data||{};while(u.rewriteToken);return await this.getMeta(s)})}async move(t,s,e){return this.instrumentOperation("move",async()=>{const r=await this.copy(t,s,e),i=`${this.storageBaseURI}/${t}`;return await this.makeRequest({method:"DELETE",url:i},e),r})}async get({id:t},s){return this.instrumentOperation("get",async()=>{const{data:e}=await this.makeRequest({params:{alt:"json"},url:`${this.storageBaseURI}/${t}`},s);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},s)).data;let i;if(typeof r=="string")i=Buffer.from(r,"utf8");else if(r&&typeof r=="object"&&"data"in r){const n=r.data;i=Buffer.from(n)}else i=Buffer.from(r);return{...e,content:i}})}async exists({id:t},s){return this.instrumentOperation("exists",async()=>{try{return await this.getMeta(t),await this.makeRequest({method:"HEAD",url:`${this.storageBaseURI}/${t}`},s),!0}catch{return!1}})}async list(t=1e3,s){return this.instrumentOperation("list",async()=>{const e=[],r=Math.min(t,1e3);let i=!0,n={params:{maxResults:r},url:this.storageBaseURI};for(;i&&e.length<t;)try{const{data:c}=await this.makeRequest(n,s);for(const{name:o,timeCreated:a,updated:u}of c?.items||[]){if(e.length>=t)break;e.push({createdAt:a,id:o,modifiedAt:u})}i=c?.nextPageToken!==void 0,i&&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 s=t?.limit??1e3,e=Math.min(s,1e3),r=[],i=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<s;)try{const{data:o}=await this.makeRequest(c,t);for(const a of o?.prefixes||[])i.add(a);for(const{name:a,timeCreated:u,updated:h}of o?.items||[]){if(r.length>=s)break;r.push({createdAt:u,id:a,modifiedAt:h})}n=o?.nextPageToken!==void 0,n&&r.length<s&&(c={...c,params:{...c.params,maxResults:Math.min(e,s-r.length),pageToken:o.nextPageToken}})}catch(o){const a=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(a),o}return{files:r,prefixes:[...i]}},{limit:t?.limit??1e3})}async internalWrite(t,s){const{body:e,bytesWritten:r,size:i,uri:n=""}=t,c=b(t),o={method:"PUT"};if(e?.on){const a=new AbortController;e.on("aborted",()=>{a.abort()}),o.body=e,o.signal=a.signal,o.retry=!1}o.headers={Accept:"application/json","Content-Range":c,...i===r?{"X-Goog-Upload-Command":"upload, finalize"}:{}};try{const a=await this.makeRequest({url:n,...o},s);if(a.status===308){const u=a.headers.get("range");return u?C(u):0}if(a.status===200)return this.logger?.debug("uploaded %O",a.data),i;throw new B(String(a.data),`GCS${a.status}`,{uri:n})}catch(a){this.logger?.error(n,a);const u=this.normalizeError(a instanceof Error?a:new Error(String(a)));throw await this.onError(u),a}}internalOnComplete=t=>this.deleteMeta(t.id);static buildCallSignal(t,s){const e=[];if(s&&e.push(s),t?.signal&&e.push(t.signal),e.length!==0)return e.length===1?e[0]:AbortSignal.any(e)}async makeRequest(t,s){typeof t.url=="string"&&(t.url=t.url.replaceAll("/:",":"));const e=p.buildCallSignal(s,t.signal);let r=this.retryOptions;if(s?.retries!==void 0){const n=typeof s.retries=="number"?s.retries:s.retries.maxRetries;typeof n=="number"&&(r={...this.retryOptions,retry:n})}const i=typeof s?.timeout=="number"&&s.timeout>0?s.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:s?.retries!==0,retryConfig:r,timeout:i,...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};