@visulima/storage 1.0.0-alpha.9 → 1.0.0

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 (424) hide show
  1. package/CHANGELOG.md +555 -0
  2. package/LICENSE.md +237 -568
  3. package/README.md +82 -466
  4. package/dist/adapter/nuxt/module.d.ts +41 -34
  5. package/dist/adapter/nuxt/module.js +1 -93
  6. package/dist/adapter/nuxt/package.json +0 -6
  7. package/dist/ai/ai-sdk/index.d.ts +113 -0
  8. package/dist/ai/ai-sdk/index.js +1 -0
  9. package/dist/ai/claude/index.d.ts +177 -0
  10. package/dist/ai/claude/index.js +1 -0
  11. package/dist/ai/openai/index.d.ts +205 -0
  12. package/dist/ai/openai/index.js +1 -0
  13. package/dist/ai/tanstack/index.d.ts +115 -0
  14. package/dist/ai/tanstack/index.js +1 -0
  15. package/dist/handler/http/fetch/index.d.ts +303 -4
  16. package/dist/handler/http/fetch/index.js +1 -4
  17. package/dist/handler/http/hono/index.d.ts +73 -64
  18. package/dist/handler/http/hono/index.js +1 -65
  19. package/dist/handler/http/nextjs/index.d.ts +66 -58
  20. package/dist/handler/http/nextjs/index.js +1 -37
  21. package/dist/handler/http/node/index.d.ts +368 -4
  22. package/dist/handler/http/node/index.js +1 -8
  23. package/dist/handler/http/solid-start/index.d.ts +66 -57
  24. package/dist/handler/http/solid-start/index.js +1 -44
  25. package/dist/index.d.ts +106 -17
  26. package/dist/index.js +1 -13
  27. package/dist/openapi/index.d.ts +24 -5
  28. package/dist/openapi/index.js +1 -5
  29. package/dist/packem_shared/AbstractBaseStorage-Ba7cLu-t.js +1 -0
  30. package/dist/packem_shared/AwsLightFile-CpZrubaV.js +1 -0
  31. package/dist/packem_shared/AwsLightMetaStorage-DPqJ9LTr.js +1 -0
  32. package/dist/packem_shared/AwsLightStorage-DTBVxHXO.js +1 -0
  33. package/dist/packem_shared/AzureFile-DFSaVe25.js +1 -0
  34. package/dist/packem_shared/AzureSMetaStorage-ByzM6Aix.js +1 -0
  35. package/dist/packem_shared/AzureStorage-BFsD4qbF.js +1 -0
  36. package/dist/packem_shared/BaseTransformer-Buw5lX_3.js +1 -0
  37. package/dist/packem_shared/BoxFile-CseIoPW1.js +1 -0
  38. package/dist/packem_shared/BoxMetaStorage-DFwhEI9C.js +1 -0
  39. package/dist/packem_shared/BoxStorage-B_t-OVzf.js +1 -0
  40. package/dist/packem_shared/BunS3File-BcYmsz1n.js +1 -0
  41. package/dist/packem_shared/BunS3MetaStorage-DFwhEI9C.js +1 -0
  42. package/dist/packem_shared/BunS3Storage-CB_pZWlV.js +1 -0
  43. package/dist/packem_shared/BunnyFile-BgEOlcYI.js +1 -0
  44. package/dist/packem_shared/BunnyMetaStorage-DFwhEI9C.js +1 -0
  45. package/dist/packem_shared/BunnyStorage-CILSK4_Z.js +1 -0
  46. package/dist/packem_shared/CloudinaryFile-Bo5B-vM1.js +1 -0
  47. package/dist/packem_shared/CloudinaryMetaStorage-D_vNzewL.js +1 -0
  48. package/dist/packem_shared/CloudinaryStorage-DiCbdAi_.js +1 -0
  49. package/dist/packem_shared/DiskStorage-Kp5t3vnF.js +1 -0
  50. package/dist/packem_shared/DiskStorageWithChecksum-Bh6w-Iu8.js +1 -0
  51. package/dist/packem_shared/DropboxFile-BFb7eOzy.js +1 -0
  52. package/dist/packem_shared/DropboxMetaStorage-DFwhEI9C.js +1 -0
  53. package/dist/packem_shared/DropboxStorage-H8bd8hEz.js +1 -0
  54. package/dist/packem_shared/ERRORS-BIBxE2oR.js +1 -0
  55. package/dist/packem_shared/File-W8aOo15X.js +1 -0
  56. package/dist/packem_shared/Files-BA3mpDwz.js +1 -0
  57. package/dist/packem_shared/FirebaseFile-BLaBxa2A.js +1 -0
  58. package/dist/packem_shared/FirebaseMetaStorage-D_vNzewL.js +1 -0
  59. package/dist/packem_shared/FirebaseStorage-Dgk4XyMr.js +2 -0
  60. package/dist/packem_shared/FtpFile-ClWDYnt2.js +1 -0
  61. package/dist/packem_shared/FtpMetaStorage-DFwhEI9C.js +1 -0
  62. package/dist/packem_shared/FtpStorage-g_DjiR-C.js +1 -0
  63. package/dist/packem_shared/GCSConfig-BQ0OpVhe.js +1 -0
  64. package/dist/packem_shared/GCSFile-Cero7qZN.js +1 -0
  65. package/dist/packem_shared/GCSMetaStorage-3fLTlRd4.js +1 -0
  66. package/dist/packem_shared/GCStorage-DUfwVFd3.js +1 -0
  67. package/dist/packem_shared/GoogleDriveFile-DHpLhzg9.js +1 -0
  68. package/dist/packem_shared/GoogleDriveMetaStorage-DqkgoE46.js +1 -0
  69. package/dist/packem_shared/GoogleDriveStorage-D0-5egHE.js +1 -0
  70. package/dist/packem_shared/LocalMetaStorage-Bp5mVc76.js +1 -0
  71. package/dist/packem_shared/MediaTransformer-D2kUsklW.js +1 -0
  72. package/dist/packem_shared/MemoryMetaStorage-Ksgh9pe7.js +1 -0
  73. package/dist/packem_shared/MemoryStorage-DzSTdlAq.js +1 -0
  74. package/dist/packem_shared/MetaStorage-DPEUyWgN.js +1 -0
  75. package/dist/packem_shared/Metadata-B7CcBueg.js +1 -0
  76. package/dist/packem_shared/Multipart-Btj2mo9r.js +1 -0
  77. package/dist/packem_shared/Multipart-C4GpuHMU.js +1 -0
  78. package/dist/packem_shared/NetlifyBlobFile-DoFhkzaH.js +1 -0
  79. package/dist/packem_shared/NetlifyBlobMetaStorage-D_vNzewL.js +1 -0
  80. package/dist/packem_shared/NetlifyBlobStorage-DZdCmOVW.js +1 -0
  81. package/dist/packem_shared/NoOpMetrics-BLo6u4NY.js +1 -0
  82. package/dist/packem_shared/OneDriveFile-CNNJYI43.js +1 -0
  83. package/dist/packem_shared/OneDriveMetaStorage-DqkgoE46.js +1 -0
  84. package/dist/packem_shared/OneDriveStorage-CvJetV7_.js +1 -0
  85. package/dist/packem_shared/OpenTelemetryMetrics-DJDQsNKp.js +1 -0
  86. package/dist/packem_shared/PocketBaseFile-DpJpxl3e.js +1 -0
  87. package/dist/packem_shared/PocketBaseMetaStorage-CpvDRnSu.js +1 -0
  88. package/dist/packem_shared/PocketBaseStorage-BPil-koe.js +1 -0
  89. package/dist/packem_shared/Rest-BehVaxbl.js +1 -0
  90. package/dist/packem_shared/Rest-ymPCZkKR.js +1 -0
  91. package/dist/packem_shared/S3File-CpZrubaV.js +1 -0
  92. package/dist/packem_shared/S3MetaStorage-CMonflzp.js +1 -0
  93. package/dist/packem_shared/S3Storage-wslqssvr.js +1 -0
  94. package/dist/packem_shared/SftpFile-ClWDYnt2.js +1 -0
  95. package/dist/packem_shared/SftpMetaStorage-DFwhEI9C.js +1 -0
  96. package/dist/packem_shared/SftpStorage-BVbMtS2b.js +1 -0
  97. package/dist/packem_shared/SharePointFile-Blz9FS4h.js +1 -0
  98. package/dist/packem_shared/SharePointMetaStorage-DFwhEI9C.js +1 -0
  99. package/dist/packem_shared/SharePointStorage-DWjvR5oZ.js +1 -0
  100. package/dist/packem_shared/SupabaseFile-Bo5B-vM1.js +1 -0
  101. package/dist/packem_shared/SupabaseMetaStorage-DqkgoE46.js +1 -0
  102. package/dist/packem_shared/SupabaseStorage-BiKmYKb6.js +1 -0
  103. package/dist/packem_shared/TUS_RESUMABLE-CyTSRvPU.js +1 -0
  104. package/dist/packem_shared/Tus-BgbON_wQ.js +1 -0
  105. package/dist/packem_shared/Tus-v6jzkaIO.js +1 -0
  106. package/dist/packem_shared/UploadControl-DZJhI9Wh.js +1 -0
  107. package/dist/packem_shared/UploadThingFile-BTFMpcIA.js +1 -0
  108. package/dist/packem_shared/UploadThingMetaStorage-D_vNzewL.js +1 -0
  109. package/dist/packem_shared/UploadThingStorage-jrEnANC5.js +1 -0
  110. package/dist/packem_shared/ValidationError-3B06DFyE.js +1 -0
  111. package/dist/packem_shared/VercelBlobFile-CVQwKlZk.js +1 -0
  112. package/dist/packem_shared/VercelBlobMetaStorage-DFwhEI9C.js +1 -0
  113. package/dist/packem_shared/VercelBlobStorage-Y-cDgH30.js +1 -0
  114. package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +1 -0
  115. package/dist/packem_shared/agentsCopyFile-Dl5iffdH.js +1 -0
  116. package/dist/packem_shared/akamai-DthkaFul.js +1 -0
  117. package/dist/packem_shared/alibaba-BEi25O1g.js +1 -0
  118. package/dist/packem_shared/approval-fVHwBp7u.js +1 -0
  119. package/dist/packem_shared/approval.d-CMAYH9GF.d.ts +75 -0
  120. package/dist/packem_shared/aws-light-meta-storage-DGrn72VJ.js +4 -0
  121. package/dist/packem_shared/azure-meta-storage-ClbEsfI4.js +1 -0
  122. package/dist/packem_shared/backblaze-m1N5NZ9q.js +1 -0
  123. package/dist/packem_shared/base-handler-core-EeV8gZck.js +1 -0
  124. package/dist/packem_shared/base-handler-fetch-CHzsgb7C.js +1 -0
  125. package/dist/packem_shared/base-handler-node-BjpW8pGi.js +1 -0
  126. package/dist/packem_shared/cache-Cw3QjoVN.js +1 -0
  127. package/dist/packem_shared/claudeCopyFile-BX9O4ORk.js +1 -0
  128. package/dist/packem_shared/cloudflare-CdUTErlo.js +1 -0
  129. package/dist/packem_shared/copyFile-49FtxXcm.js +1 -0
  130. package/dist/packem_shared/copyFile-BUPezT_c.js +1 -0
  131. package/dist/packem_shared/createResponsesFileTools-6Tvt2PNr.js +1 -0
  132. package/dist/packem_shared/createRetryWrapper-CxgiV_hH.js +1 -0
  133. package/dist/packem_shared/detect-file-type-BA7UBLKA.js +1 -0
  134. package/dist/packem_shared/digitalOcean-B2uB6pgz.js +1 -0
  135. package/dist/packem_shared/disk-storage-DIn-VnCh.js +1 -0
  136. package/dist/packem_shared/disk-storage-with-checksum.d-B-VGEsfl.d.ts +156 -0
  137. package/dist/packem_shared/executors-BDzMjc4y.js +1 -0
  138. package/dist/packem_shared/executors.d-BZP2rWo3.d.ts +69 -0
  139. package/dist/packem_shared/exoscale-BDa1Gjth.js +1 -0
  140. package/dist/packem_shared/filebase-CsFYJIwB.js +1 -0
  141. package/dist/packem_shared/files.d-CH0iLBNC.d.ts +655 -0
  142. package/dist/packem_shared/gcs-meta-storage-Dy37wCjI.js +1 -0
  143. package/dist/packem_shared/get-file-status-y3wTtDQs.js +1 -0
  144. package/dist/packem_shared/getFormatFromContentType-DCTTPQHm.js +1 -0
  145. package/dist/packem_shared/has-content-50BsqrWw.js +1 -0
  146. package/dist/packem_shared/headers-BAiAKekR.js +26 -0
  147. package/dist/packem_shared/hetzner-BGGFiRGD.js +1 -0
  148. package/dist/packem_shared/ibmCos-j-3TfJ5p.js +1 -0
  149. package/dist/packem_shared/idriveE2-C6pQ5pQ0.js +1 -0
  150. package/dist/packem_shared/index-nZWCQrSe.js +5 -0
  151. package/dist/packem_shared/internal-D_cZIFwI.js +1 -0
  152. package/dist/packem_shared/is-expired-CBEk6XBi.js +1 -0
  153. package/dist/packem_shared/local-meta-storage-C2T92TYb.js +11 -0
  154. package/dist/packem_shared/local-meta-storage.d-D9PBfkn6.d.ts +21 -0
  155. package/dist/packem_shared/media-transformer.d-Quf4ai47.d.ts +331 -0
  156. package/dist/packem_shared/memory-storage.d-4EU1cMt1.d.ts +101 -0
  157. package/dist/packem_shared/minio-NKquuBfS.js +1 -0
  158. package/dist/packem_shared/multipart-base-BOzY19lb.js +1 -0
  159. package/dist/packem_shared/oauth-refresh-EdGzlcOZ.js +1 -0
  160. package/dist/packem_shared/oracleCloud-DslqNpn6.js +1 -0
  161. package/dist/packem_shared/ovhCloud-CMHE6uLV.js +1 -0
  162. package/dist/packem_shared/part-match-D-9dGX42.js +1 -0
  163. package/dist/packem_shared/path-0oTTdkvl-BVg7lYf5.js +1 -0
  164. package/dist/packem_shared/posix-dirname-CfpH5wZi.js +1 -0
  165. package/dist/packem_shared/response-builder-CbSA8qPa.js +1 -0
  166. package/dist/packem_shared/rest-base-CynUg0mH.js +1 -0
  167. package/dist/packem_shared/restOpenApiSpec-Csv513qf.js +1 -0
  168. package/dist/packem_shared/s3-base-storage-DXZYN24h.js +1 -0
  169. package/dist/packem_shared/s3-base-storage.d-BQgP5B-t.d.ts +287 -0
  170. package/dist/packem_shared/scaleway-U1In3v70.js +1 -0
  171. package/dist/packem_shared/sharedErrorSchemaObject-YN65aAKj.js +1 -0
  172. package/dist/packem_shared/storage-Cyy73Y6r.js +1 -0
  173. package/dist/packem_shared/storage.d-CEM1upWM.d.ts +1176 -0
  174. package/dist/packem_shared/storj-Cb59q9kF.js +1 -0
  175. package/dist/packem_shared/sync-DhR3536K.js +1 -0
  176. package/dist/packem_shared/tencent-Q1y2GENc.js +1 -0
  177. package/dist/packem_shared/tigris-BELKoyyp.js +1 -0
  178. package/dist/packem_shared/transformOpenApiSpec-CIEAgpBD.js +1 -0
  179. package/dist/packem_shared/tus-base.d-DLzKE54M.d.ts +106 -0
  180. package/dist/packem_shared/tusOpenApiSpec-D96B03t5.js +1 -0
  181. package/dist/packem_shared/types.d-Bon9GVVe.d.ts +104 -0
  182. package/dist/packem_shared/types.d-CggTCgXr.d.ts +49 -0
  183. package/dist/packem_shared/types.d-CrUWY4On.d.ts +720 -0
  184. package/dist/packem_shared/update-size-DuNuLyxj.js +1 -0
  185. package/dist/packem_shared/vultr-B491cQ4e.js +1 -0
  186. package/dist/packem_shared/waitForStorage-ByQmG4xF.js +1 -0
  187. package/dist/packem_shared/wasabi-DFrwIoab.js +1 -0
  188. package/dist/packem_shared/xhrOpenApiSpec-DQR4h6M8.js +1 -0
  189. package/dist/packem_shared/yandex-CwzHuEKP.js +1 -0
  190. package/dist/storage/aws/clients/index.d.ts +612 -6
  191. package/dist/storage/aws/clients/index.js +1 -6
  192. package/dist/storage/aws/index.d.ts +332 -4
  193. package/dist/storage/aws/index.js +1 -3
  194. package/dist/storage/aws-light/index.d.ts +259 -4
  195. package/dist/storage/aws-light/index.js +1 -3
  196. package/dist/storage/azure/index.d.ts +236 -4
  197. package/dist/storage/azure/index.js +1 -3
  198. package/dist/storage/box/index.d.ts +189 -0
  199. package/dist/storage/box/index.js +1 -0
  200. package/dist/storage/bun-s3/index.d.ts +200 -0
  201. package/dist/storage/bun-s3/index.js +1 -0
  202. package/dist/storage/bunny/index.d.ts +119 -0
  203. package/dist/storage/bunny/index.js +1 -0
  204. package/dist/storage/cloudinary/index.d.ts +121 -0
  205. package/dist/storage/cloudinary/index.js +1 -0
  206. package/dist/storage/dropbox/index.d.ts +132 -0
  207. package/dist/storage/dropbox/index.js +1 -0
  208. package/dist/storage/firebase/index.d.ts +192 -0
  209. package/dist/storage/firebase/index.js +1 -0
  210. package/dist/storage/ftp/index.d.ts +91 -0
  211. package/dist/storage/ftp/index.js +1 -0
  212. package/dist/storage/gcs/index.d.ts +195 -5
  213. package/dist/storage/gcs/index.js +1 -4
  214. package/dist/storage/google-drive/index.d.ts +148 -0
  215. package/dist/storage/google-drive/index.js +1 -0
  216. package/dist/storage/local/index.d.ts +7 -4
  217. package/dist/storage/local/index.js +1 -3
  218. package/dist/storage/memory/index.d.ts +6 -0
  219. package/dist/storage/memory/index.js +1 -0
  220. package/dist/storage/netlify-blob/index.d.ts +147 -4
  221. package/dist/storage/netlify-blob/index.js +1 -3
  222. package/dist/storage/onedrive/index.d.ts +103 -0
  223. package/dist/storage/onedrive/index.js +1 -0
  224. package/dist/storage/pocketbase/index.d.ts +172 -0
  225. package/dist/storage/pocketbase/index.js +1 -0
  226. package/dist/storage/sftp/index.d.ts +92 -0
  227. package/dist/storage/sftp/index.js +1 -0
  228. package/dist/storage/sharepoint/index.d.ts +180 -0
  229. package/dist/storage/sharepoint/index.js +1 -0
  230. package/dist/storage/supabase/index.d.ts +115 -0
  231. package/dist/storage/supabase/index.js +1 -0
  232. package/dist/storage/uploadthing/index.d.ts +95 -0
  233. package/dist/storage/uploadthing/index.js +1 -0
  234. package/dist/storage/vercel-blob/index.d.ts +189 -4
  235. package/dist/storage/vercel-blob/index.js +1 -3
  236. package/dist/transformer/audio-transformer.d.ts +127 -125
  237. package/dist/transformer/audio-transformer.js +1 -278
  238. package/dist/transformer/image-transformer.d.ts +573 -568
  239. package/dist/transformer/image-transformer.js +1 -1100
  240. package/dist/transformer/index.d.ts +62 -5
  241. package/dist/transformer/index.js +1 -4
  242. package/dist/transformer/video-transformer.d.ts +144 -142
  243. package/dist/transformer/video-transformer.js +1 -310
  244. package/package.json +202 -51
  245. package/dist/handler/base/base-handler-core.d.ts +0 -91
  246. package/dist/handler/base/base-handler-fetch.d.ts +0 -76
  247. package/dist/handler/base/base-handler-node.d.ts +0 -137
  248. package/dist/handler/multipart/multipart-base.d.ts +0 -84
  249. package/dist/handler/multipart/multipart-fetch.d.ts +0 -64
  250. package/dist/handler/multipart/multipart.d.ts +0 -49
  251. package/dist/handler/rest/rest-base.d.ts +0 -106
  252. package/dist/handler/rest/rest-fetch.d.ts +0 -88
  253. package/dist/handler/rest/rest.d.ts +0 -93
  254. package/dist/handler/tus/tus-base.d.ts +0 -152
  255. package/dist/handler/tus/tus-fetch.d.ts +0 -72
  256. package/dist/handler/tus/tus.d.ts +0 -78
  257. package/dist/handler/types.d.ts +0 -53
  258. package/dist/handler/utils/request-parser.d.ts +0 -72
  259. package/dist/handler/utils/response-builder.d.ts +0 -83
  260. package/dist/handler/utils/storage-utils.d.ts +0 -10
  261. package/dist/handler/utils/stream-utils.d.ts +0 -29
  262. package/dist/handler/utils/upload-handlers.d.ts +0 -76
  263. package/dist/metrics/index.d.ts +0 -2
  264. package/dist/metrics/no-op-metrics.d.ts +0 -15
  265. package/dist/metrics/opentelemetry-metrics.d.ts +0 -55
  266. package/dist/openapi/rest.d.ts +0 -7
  267. package/dist/openapi/shared.d.ts +0 -13
  268. package/dist/openapi/transform.d.ts +0 -3
  269. package/dist/openapi/tus.d.ts +0 -7
  270. package/dist/openapi/xhr.d.ts +0 -7
  271. package/dist/packem_shared/AwsLightFile-tTneXZgG.js +0 -11
  272. package/dist/packem_shared/AwsLightMetaStorage-BWSOtVaN.js +0 -4
  273. package/dist/packem_shared/AwsLightStorage-Blv-GP4v.js +0 -133
  274. package/dist/packem_shared/AzureFile-CesgFzps.js +0 -8
  275. package/dist/packem_shared/AzureSMetaStorage-CFs-OYJT.js +0 -88
  276. package/dist/packem_shared/AzureStorage-B0v048hG.js +0 -357
  277. package/dist/packem_shared/BaseTransformer-C2gLib6v.js +0 -82
  278. package/dist/packem_shared/DiskStorage-Ck5yGQsq.js +0 -12
  279. package/dist/packem_shared/DiskStorageWithChecksum-BRl-V5x2.js +0 -238
  280. package/dist/packem_shared/ERRORS-D0apMqnc.js +0 -97
  281. package/dist/packem_shared/File-Bb3P23dr.js +0 -69
  282. package/dist/packem_shared/GCSConfig-vPP22kN6.js +0 -11
  283. package/dist/packem_shared/GCSFile-BIEunhAN.js +0 -8
  284. package/dist/packem_shared/GCSMetaStorage-CHZKMe7N.js +0 -7
  285. package/dist/packem_shared/GCStorage-C-gAuP0j.js +0 -406
  286. package/dist/packem_shared/LocalMetaStorage-CZHhKkMd.js +0 -7
  287. package/dist/packem_shared/MediaTransformer-D6658DL1.js +0 -1197
  288. package/dist/packem_shared/MetaStorage-pECeFOad.js +0 -46
  289. package/dist/packem_shared/Metadata-DRLXeJ0F.js +0 -89
  290. package/dist/packem_shared/Multipart-CRV21AUU.js +0 -128
  291. package/dist/packem_shared/Multipart-D2ryPMjD.js +0 -163
  292. package/dist/packem_shared/NetlifyBlobFile-CXzyjqrD.js +0 -14
  293. package/dist/packem_shared/NetlifyBlobMetaStorage-DxZ5aDvD.js +0 -9
  294. package/dist/packem_shared/NetlifyBlobStorage-CLPtjHqd.js +0 -376
  295. package/dist/packem_shared/NoOpMetrics-DhAk5rXc.js +0 -10
  296. package/dist/packem_shared/OpenTelemetryMetrics-BnxhqIaH.js +0 -67
  297. package/dist/packem_shared/Rest-DcxBMBjU.js +0 -228
  298. package/dist/packem_shared/Rest-DjwU3puo.js +0 -267
  299. package/dist/packem_shared/S3File-DZiyk9Qt.js +0 -11
  300. package/dist/packem_shared/S3MetaStorage-Dz9aDabA.js +0 -76
  301. package/dist/packem_shared/S3Storage-DHmTk-hU.js +0 -316
  302. package/dist/packem_shared/TUS_RESUMABLE-Dtfsffnj.js +0 -434
  303. package/dist/packem_shared/Tus-DFVlZHaX.js +0 -200
  304. package/dist/packem_shared/Tus-DaN0FmOy.js +0 -195
  305. package/dist/packem_shared/ValidationError-BfF1aE4h.js +0 -26
  306. package/dist/packem_shared/VercelBlobFile-BCg4aTEq.js +0 -18
  307. package/dist/packem_shared/VercelBlobMetaStorage-Bd9F-VFm.js +0 -9
  308. package/dist/packem_shared/VercelBlobStorage-DD9LMOS6.js +0 -261
  309. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
  310. package/dist/packem_shared/aws-light-meta-storage-DKJBgbR6.js +0 -446
  311. package/dist/packem_shared/backblaze-BlMnIcBC.js +0 -20
  312. package/dist/packem_shared/base-handler-core-BoAqTyz7.js +0 -303
  313. package/dist/packem_shared/base-handler-fetch-D4u2xits.js +0 -291
  314. package/dist/packem_shared/base-handler-node-DGzcHHAy.js +0 -730
  315. package/dist/packem_shared/cache-B88MXQ_2.js +0 -18
  316. package/dist/packem_shared/cloudflare-Bi1q8wXE.js +0 -21
  317. package/dist/packem_shared/defaultCloudStorageFileNameValidation-DUuacjWv.js +0 -11
  318. package/dist/packem_shared/digitalOcean-CWQRJM3L.js +0 -21
  319. package/dist/packem_shared/disk-storage-CD47QI30.js +0 -810
  320. package/dist/packem_shared/gcs-meta-storage-CJ8Uts_d.js +0 -158
  321. package/dist/packem_shared/has-content-CY66ehMK.js +0 -3
  322. package/dist/packem_shared/headers-YLRp1dLo.js +0 -1318
  323. package/dist/packem_shared/is-expired-CTThU1q5.js +0 -8
  324. package/dist/packem_shared/isRetryableError-Dycp7127.js +0 -82
  325. package/dist/packem_shared/isValidMediaType-BeDgiObq.js +0 -35
  326. package/dist/packem_shared/local-meta-storage-By-3SNBI.js +0 -649
  327. package/dist/packem_shared/minio-C2YBZQOw.js +0 -22
  328. package/dist/packem_shared/multipart-base-C994naBi.js +0 -102
  329. package/dist/packem_shared/part-match-BMNqHDYD.js +0 -96
  330. package/dist/packem_shared/path-CR6YkPXX-7R1-9CMk.js +0 -161
  331. package/dist/packem_shared/response-builder-BtnRiBUI.js +0 -45
  332. package/dist/packem_shared/rest-base-D9URIFkc.js +0 -457
  333. package/dist/packem_shared/restOpenApiSpec-D1JC_Jto.js +0 -800
  334. package/dist/packem_shared/s3-base-storage-C1DIHTYY.js +0 -510
  335. package/dist/packem_shared/sharedGet-Cpo7QUyu.js +0 -1019
  336. package/dist/packem_shared/storage-C6NSXb8h.js +0 -1175
  337. package/dist/packem_shared/tigris-Hac8TKnX.js +0 -21
  338. package/dist/packem_shared/transformOpenApiSpec-DWM5WtnN.js +0 -975
  339. package/dist/packem_shared/tusOpenApiSpec-mBZkl7he.js +0 -740
  340. package/dist/packem_shared/update-size-CCGm6i1J.js +0 -8
  341. package/dist/packem_shared/validator-BeX_lJet.js +0 -78
  342. package/dist/packem_shared/waitForStorage-Cscw85sx.js +0 -18
  343. package/dist/packem_shared/wasabi-DIyflHSd.js +0 -21
  344. package/dist/packem_shared/xhrOpenApiSpec-B1V5Dxrj.js +0 -264
  345. package/dist/storage/aws/clients/backblaze.d.ts +0 -12
  346. package/dist/storage/aws/clients/cloudflare.d.ts +0 -13
  347. package/dist/storage/aws/clients/digital-ocean.d.ts +0 -12
  348. package/dist/storage/aws/clients/minio.d.ts +0 -13
  349. package/dist/storage/aws/clients/tigris.d.ts +0 -12
  350. package/dist/storage/aws/clients/types.d.ts +0 -95
  351. package/dist/storage/aws/clients/wasabi.d.ts +0 -12
  352. package/dist/storage/aws/s3-base-storage.d.ts +0 -248
  353. package/dist/storage/aws/s3-client-adapter.d.ts +0 -110
  354. package/dist/storage/aws/s3-file.d.ts +0 -10
  355. package/dist/storage/aws/s3-meta-storage.d.ts +0 -15
  356. package/dist/storage/aws/s3-storage.d.ts +0 -70
  357. package/dist/storage/aws/types.d.ts +0 -119
  358. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +0 -130
  359. package/dist/storage/aws-light/aws-light-file.d.ts +0 -10
  360. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +0 -19
  361. package/dist/storage/aws-light/aws-light-storage.d.ts +0 -65
  362. package/dist/storage/aws-light/types.d.ts +0 -37
  363. package/dist/storage/azure/azure-file.d.ts +0 -6
  364. package/dist/storage/azure/azure-meta-storage.d.ts +0 -15
  365. package/dist/storage/azure/azure-storage.d.ts +0 -69
  366. package/dist/storage/azure/types.d.ts +0 -62
  367. package/dist/storage/gcs/fetch-error.d.ts +0 -11
  368. package/dist/storage/gcs/gcs-config.d.ts +0 -2
  369. package/dist/storage/gcs/gcs-file.d.ts +0 -6
  370. package/dist/storage/gcs/gcs-meta-storage.d.ts +0 -27
  371. package/dist/storage/gcs/gcs-storage.d.ts +0 -91
  372. package/dist/storage/gcs/types.d.ts +0 -55
  373. package/dist/storage/gcs/utils.d.ts +0 -7
  374. package/dist/storage/local/disk-storage-with-checksum.d.ts +0 -15
  375. package/dist/storage/local/disk-storage.d.ts +0 -135
  376. package/dist/storage/local/local-meta-storage.d.ts +0 -32
  377. package/dist/storage/meta-storage.d.ts +0 -30
  378. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +0 -12
  379. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +0 -7
  380. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +0 -93
  381. package/dist/storage/netlify-blob/types.d.ts +0 -30
  382. package/dist/storage/storage.d.ts +0 -353
  383. package/dist/storage/types.d.ts +0 -221
  384. package/dist/storage/utils/file/file.d.ts +0 -25
  385. package/dist/storage/utils/file/get-file-status.d.ts +0 -9
  386. package/dist/storage/utils/file/has-content.d.ts +0 -9
  387. package/dist/storage/utils/file/index.d.ts +0 -10
  388. package/dist/storage/utils/file/is-expired.d.ts +0 -8
  389. package/dist/storage/utils/file/metadata.d.ts +0 -18
  390. package/dist/storage/utils/file/part-match.d.ts +0 -11
  391. package/dist/storage/utils/file/types.d.ts +0 -37
  392. package/dist/storage/utils/file/update-metadata.d.ts +0 -10
  393. package/dist/storage/utils/file/update-size.d.ts +0 -10
  394. package/dist/storage/vercel-blob/types.d.ts +0 -32
  395. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +0 -16
  396. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +0 -7
  397. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +0 -76
  398. package/dist/transformer/base-transformer.d.ts +0 -63
  399. package/dist/transformer/media-transformer.d.ts +0 -332
  400. package/dist/transformer/types.d.ts +0 -652
  401. package/dist/transformer/utils.d.ts +0 -33
  402. package/dist/transformer/validation-error.d.ts +0 -23
  403. package/dist/utils/cache.d.ts +0 -32
  404. package/dist/utils/chunked-upload.d.ts +0 -65
  405. package/dist/utils/detect-file-type.d.ts +0 -28
  406. package/dist/utils/errors.d.ts +0 -74
  407. package/dist/utils/file-path-url-matcher.d.ts +0 -18
  408. package/dist/utils/headers.d.ts +0 -111
  409. package/dist/utils/http.d.ts +0 -92
  410. package/dist/utils/locker.d.ts +0 -26
  411. package/dist/utils/pipes/stream-checksum.d.ts +0 -47
  412. package/dist/utils/pipes/stream-length.d.ts +0 -22
  413. package/dist/utils/primitives/get-last-one.d.ts +0 -3
  414. package/dist/utils/primitives/is-record.d.ts +0 -2
  415. package/dist/utils/primitives/map-values.d.ts +0 -9
  416. package/dist/utils/primitives/pick.d.ts +0 -2
  417. package/dist/utils/primitives/to-milliseconds.d.ts +0 -12
  418. package/dist/utils/primitives/to-seconds.d.ts +0 -12
  419. package/dist/utils/range-checksum.d.ts +0 -33
  420. package/dist/utils/range-hasher.d.ts +0 -46
  421. package/dist/utils/retry.d.ts +0 -64
  422. package/dist/utils/types.d.ts +0 -108
  423. package/dist/utils/validation-error.d.ts +0 -22
  424. package/dist/utils/validator.d.ts +0 -36
@@ -0,0 +1,75 @@
1
+ import * as z from 'zod';
2
+ declare const listFilesInputSchema: z.ZodObject<{
3
+ limit: z.ZodOptional<z.ZodNumber>;
4
+ prefix: z.ZodOptional<z.ZodString>;
5
+ }>;
6
+ declare const getFileMetadataInputSchema: z.ZodObject<{
7
+ key: z.ZodString;
8
+ }>;
9
+ declare const downloadFileInputSchema: z.ZodObject<{
10
+ binary: z.ZodOptional<z.ZodBoolean>;
11
+ key: z.ZodString;
12
+ maxBytes: z.ZodOptional<z.ZodNumber>;
13
+ }>;
14
+ declare const getFileUrlInputSchema: z.ZodObject<{
15
+ expiresIn: z.ZodOptional<z.ZodNumber>;
16
+ key: z.ZodString;
17
+ responseContentDisposition: z.ZodOptional<z.ZodString>;
18
+ }>;
19
+ declare const uploadFileInputSchema: z.ZodObject<{
20
+ content: z.ZodString;
21
+ contentType: z.ZodOptional<z.ZodString>;
22
+ encoding: z.ZodOptional<z.ZodEnum<{
23
+ base64: "base64";
24
+ text: "text";
25
+ }>>;
26
+ key: z.ZodString;
27
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
28
+ }>;
29
+ declare const deleteFileInputSchema: z.ZodObject<{
30
+ key: z.ZodString;
31
+ }>;
32
+ declare const copyFileInputSchema: z.ZodObject<{
33
+ from: z.ZodString;
34
+ to: z.ZodString;
35
+ }>;
36
+ declare const signUploadUrlInputSchema: z.ZodObject<{
37
+ contentType: z.ZodOptional<z.ZodString>;
38
+ expiresIn: z.ZodNumber;
39
+ key: z.ZodString;
40
+ }>;
41
+ interface ToolSchema<TInput extends z.ZodObject<z.ZodRawShape>> {
42
+ description: string;
43
+ input: TInput;
44
+ }
45
+ interface ToolSchemaMap {
46
+ copyFile: ToolSchema<typeof copyFileInputSchema>;
47
+ deleteFile: ToolSchema<typeof deleteFileInputSchema>;
48
+ downloadFile: ToolSchema<typeof downloadFileInputSchema>;
49
+ getFileMetadata: ToolSchema<typeof getFileMetadataInputSchema>;
50
+ getFileUrl: ToolSchema<typeof getFileUrlInputSchema>;
51
+ listFiles: ToolSchema<typeof listFilesInputSchema>;
52
+ signUploadUrl: ToolSchema<typeof signUploadUrlInputSchema>;
53
+ uploadFile: ToolSchema<typeof uploadFileInputSchema>;
54
+ }
55
+ declare const TOOL_SCHEMAS: ToolSchemaMap;
56
+ type FileToolName = keyof ToolSchemaMap;
57
+ type FileReadToolName = "downloadFile" | "getFileMetadata" | "getFileUrl" | "listFiles";
58
+ type FileWriteToolName = "copyFile" | "deleteFile" | "signUploadUrl" | "uploadFile";
59
+ type ListFilesInput = z.infer<typeof listFilesInputSchema>;
60
+ type GetFileMetadataInput = z.infer<typeof getFileMetadataInputSchema>;
61
+ type DownloadFileInput = z.infer<typeof downloadFileInputSchema>;
62
+ type GetFileUrlInput = z.infer<typeof getFileUrlInputSchema>;
63
+ type UploadFileInput = z.infer<typeof uploadFileInputSchema>;
64
+ type DeleteFileInput = z.infer<typeof deleteFileInputSchema>;
65
+ type CopyFileInput = z.infer<typeof copyFileInputSchema>;
66
+ type SignUploadUrlInput = z.infer<typeof signUploadUrlInputSchema>;
67
+ /**
68
+ * Whether write operations require user approval.
69
+ *
70
+ * - `true` — all write tools need approval (default)
71
+ * - `false` — no approval needed for any write tool
72
+ * - object — per-tool override; unspecified write tools default to `true`
73
+ */
74
+ type ApprovalConfig = boolean | Partial<Record<FileWriteToolName, boolean>>;
75
+ export { ApprovalConfig as A, CopyFileInput as C, DeleteFileInput as D, FileToolName as F, GetFileMetadataInput as G, ListFilesInput as L, SignUploadUrlInput as S, TOOL_SCHEMAS as T, UploadFileInput as U, DownloadFileInput as a, GetFileUrlInput as b, FileReadToolName as c, FileWriteToolName as d };
@@ -0,0 +1,4 @@
1
+ import y from"./MetaStorage-DPEUyWgN.js";import{parseMetadata as f,stringifyMetadata as b}from"./Metadata-B7CcBueg.js";import{Readable as g}from"node:stream";import{AwsClient as C}from"aws4fetch";import{t as T}from"./is-expired-CBEk6XBi.js";const u=p=>{const t={},o=p.replaceAll(/<\?xml[^>]*\?>/g,"").replaceAll(/xmlns[^=]*="[^"]*"/g,""),a=/<([^>]+)>([^<]*)<\/\1>/g,e=[...o.matchAll(a)];for(const i of e){const[,n,c]=i;n&&c?.trim()&&(t[n]?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(c.trim())):t[n]=c.trim())}const s=/<([^>]+)>([\s\S]*?)<\/\1>/g;let r;for(;(r=s.exec(o))!==null;){const[,i,n]=r;if(i&&n?.includes("<")){const c=u(n);Object.keys(c).length>0&&(t[i]=c)}}return t};class k{aws;bucket;endpoint;constructor(t){this.bucket=t.bucket,this.endpoint=t.endpoint||`https://${t.bucket}.s3.${t.region}.amazonaws.com`,this.aws=new C({accessKeyId:t.accessKeyId,region:t.region,secretAccessKey:t.secretAccessKey,service:t.service||"s3",sessionToken:t.sessionToken})}async createMultipartUpload(t,o){const a={uploads:""},e={};if(t.ContentType&&(e["Content-Type"]=t.ContentType),t.ACL&&(e["x-amz-acl"]=t.ACL),t.Metadata)for(const[d,l]of Object.entries(t.Metadata))e[`x-amz-meta-${d}`]=l;const s=this.buildUrl(t.Key,a),r=await this.aws.fetch(s,{headers:e,method:"POST",signal:o?.signal}),i=await r.text();if(!r.ok)throw new Error(`Failed to create multipart upload: ${r.status} ${i}`);const n=u(i),c=n.UploadId||n.InitiateMultipartUploadResult?.UploadId;if(!c){const d=new Error("Failed to parse UploadId from response");throw d.retryable=!1,d}return{UploadId:c}}async uploadPart(t,o){const a={partNumber:String(t.PartNumber),uploadId:t.UploadId},e={};t.ContentLength&&(e["Content-Length"]=String(t.ContentLength)),t.ContentMD5&&(e["Content-MD5"]=t.ContentMD5);const s=t.Body instanceof g?g.toWeb(t.Body):t.Body,r=this.buildUrl(t.Key,a),i=await this.aws.fetch(r,{body:s,headers:e,method:"PUT",signal:o?.signal});if(!i.ok){const c=await i.text();throw new Error(`Failed to upload part: ${i.status} ${c}`)}const n=i.headers.get("ETag");if(!n)throw new Error("Failed to get ETag from response");return{ETag:n.replaceAll(/(^"|"$)/g,"")}}async completeMultipartUpload(t,o){const a={uploadId:t.UploadId},e=`<?xml version="1.0" encoding="UTF-8"?>
2
+ <CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
3
+ ${t.Parts.map(({ETag:l,PartNumber:h})=>`<Part><PartNumber>${h}</PartNumber><ETag>"${l}"</ETag></Part>`).join("")}
4
+ </CompleteMultipartUpload>`,s=this.buildUrl(t.Key,a),r=await this.aws.fetch(s,{body:e,headers:{"Content-Type":"application/xml"},method:"POST",signal:o?.signal}),i=await r.text();if(!r.ok)throw new Error(`Failed to complete multipart upload: ${r.status} ${i}`);const n=u(i),c=n.CompleteMultipartUploadResult||n,d=c.Location||`${this.endpoint}/${t.Key}`;return{ETag:c.ETag?.replaceAll(/(^"|"$)/g,""),Location:d}}async abortMultipartUpload(t,o){const a={uploadId:t.UploadId},e=this.buildUrl(t.Key,a),s=await this.aws.fetch(e,{method:"DELETE",signal:o?.signal});if(!s.ok){const r=await s.text();throw new Error(`Failed to abort multipart upload: ${s.status} ${r}`)}}async listParts(t,o){const a={uploadId:t.UploadId},e=this.buildUrl(t.Key,a),s=await this.aws.fetch(e,{method:"GET",signal:o?.signal}),r=await s.text();if(!s.ok)throw new Error(`Failed to list parts: ${s.status} ${r}`);const i=u(r),n=i.ListPartsResult||i;let c=[];return n.Part&&(c=Array.isArray(n.Part)?n.Part:[n.Part]),{Parts:c.map(d=>({ETag:d.ETag?.replaceAll(/(^"|"$)/g,""),PartNumber:Number(d.PartNumber)||0,Size:d.Size?Number(d.Size):void 0}))}}async getObject(t,o){const a=this.buildUrl(t.Key),e=await this.aws.fetch(a,{method:"GET",signal:o?.signal});if(!e.ok){const h=await e.text();throw new Error(`Failed to get object: ${e.status} ${h}`)}const s=e.headers.get("Content-Length"),r=e.headers.get("Content-Type"),i=e.headers.get("ETag"),n=e.headers.get("Expires"),c=e.headers.get("Last-Modified"),d={};for(const[h,m]of e.headers.entries())if(h.toLowerCase().startsWith("x-amz-meta-")){const w=h.toLowerCase().replace("x-amz-meta-","");d[w]=m}const{body:l}=e;return{Body:l?this.streamToReadable(l):void 0,ContentLength:s?Number(s):void 0,ContentType:r||void 0,ETag:i?.replaceAll(/(^"|"$)/g,"")||void 0,Expires:n?new Date(n):void 0,LastModified:c?new Date(c):void 0,Metadata:Object.keys(d).length>0?d:void 0}}async headObject(t,o){const a=this.buildUrl(t.Key),e=await this.aws.fetch(a,{method:"HEAD",signal:o?.signal});if(!e.ok){const l=await e.text();throw new Error(`Failed to head object: ${e.status} ${l}`)}const s=e.headers.get("Content-Length"),r=e.headers.get("Content-Type"),i=e.headers.get("ETag"),n=e.headers.get("Expires"),c=e.headers.get("Last-Modified"),d={};for(const[l,h]of e.headers.entries())if(l.toLowerCase().startsWith("x-amz-meta-")){const m=l.toLowerCase().replace("x-amz-meta-","");d[m]=h}return{ContentLength:s?Number(s):void 0,ContentType:r||void 0,ETag:i?.replaceAll(/(^"|"$)/g,"")||void 0,Expires:n?new Date(n):void 0,LastModified:c?new Date(c):void 0,Metadata:Object.keys(d).length>0?d:void 0}}async deleteObject(t,o){const a=this.buildUrl(t.Key),e=await this.aws.fetch(a,{method:"DELETE",signal:o?.signal});if(!e.ok){const s=await e.text();throw new Error(`Failed to delete object: ${e.status} ${s}`)}}async copyObject(t,o){const a={"x-amz-copy-source":t.CopySource};t.StorageClass&&(a["x-amz-storage-class"]=t.StorageClass);let e=this.buildUrl(t.Key);t.Bucket!==this.bucket&&(e=e.replace(this.bucket,t.Bucket));const s=await this.aws.fetch(e,{headers:a,method:"PUT",signal:o?.signal});if(!s.ok){const r=await s.text();throw new Error(`Failed to copy object: ${s.status} ${r}`)}}async listObjectsV2(t,o){const a={"list-type":"2"};t.MaxKeys&&(a["max-keys"]=String(t.MaxKeys)),t.ContinuationToken&&(a["continuation-token"]=t.ContinuationToken),t.Delimiter!==void 0&&(a.delimiter=t.Delimiter),t.Prefix!==void 0&&(a.prefix=t.Prefix);const e=this.buildUrl("",a),s=await this.aws.fetch(e,{method:"GET",signal:o?.signal}),r=await s.text();if(!s.ok)throw new Error(`Failed to list objects: ${s.status} ${r}`);const i=u(r),n=i.ListBucketResult||i,c=n.Contents||(Array.isArray(n.Contents)?n.Contents:[]),d=[];for(const l of r.matchAll(/<CommonPrefixes>\s*<Prefix>([^<]*)<\/Prefix>\s*<\/CommonPrefixes>/g))d.push({Prefix:l[1]});return{CommonPrefixes:d,Contents:Array.isArray(c)?c.map(l=>({Key:l.Key,LastModified:l.LastModified?new Date(String(l.LastModified)):void 0})):[],IsTruncated:n.IsTruncated==="true"||n.IsTruncated===!0,NextContinuationToken:n.NextContinuationToken}}async getPresignedUrl(t){const o={partNumber:String(t.PartNumber),uploadId:t.UploadId,"X-Amz-Expires":String(t.expiresIn)};return this.buildUrl(t.Key,o)}async putObject(t){const o=this.buildUrl(t.Key),a={};if(t.ContentType&&(a["Content-Type"]=t.ContentType),t.ContentLength!==void 0&&(a["Content-Length"]=String(t.ContentLength)),t.Metadata)for(const[r,i]of Object.entries(t.Metadata))a[`x-amz-meta-${r}`]=i;let e;t.Body===void 0?e=void 0:t.Body instanceof Uint8Array?e=new Uint8Array(t.Body):t.Body instanceof ReadableStream?e=t.Body:e=void 0;const s=await this.aws.fetch(o,{body:e,headers:a,method:"PUT"});if(!s.ok){const r=await s.text();throw new Error(`Failed to put object: ${s.status} ${r}`)}}async checkBucketAccess(t){const o=this.buildUrl(""),a=await this.aws.fetch(o,{method:"HEAD"});if(!a.ok&&a.status!==404){const e=await a.text();throw new Error(`Failed to access bucket: ${a.status} ${e}`)}}buildUrl(t,o){const a=new URL(t,this.endpoint);if(o)for(const[e,s]of Object.entries(o))a.searchParams.set(e,s);return a.toString()}streamToReadable(t){return g.fromWeb(t)}}class A extends y{constructor(t){super(t),this.config=t;const o=t.bucket||process.env.S3_BUCKET||process.env.AWS_S3_BUCKET;if(!o)throw new Error("S3 bucket is not defined");this.bucket=o,this.adapter=new k({accessKeyId:t.accessKeyId,bucket:o,endpoint:t.endpoint,region:t.region,secretAccessKey:t.secretAccessKey,service:t.service,sessionToken:t.sessionToken}),this.adapter.checkBucketAccess({Bucket:o}).catch(a=>{throw a})}config;adapter;bucket;async get(t){const o=this.getMetaName(t),{Expires:a,Metadata:e}=await this.adapter.headObject({Bucket:this.bucket,Key:o});if(a&&T({expiredAt:a}))throw await this.delete(o),new Error(`Metafile ${t} not found`);if(e?.metadata!==void 0){const s=JSON.parse(decodeURIComponent(e.metadata));return s.metadata&&typeof s.metadata=="string"&&(s.metadata=f(s.metadata)),s}throw new Error(`Metafile ${t} not found`)}async touch(t,o){return this.save(t,o)}async delete(t){await this.adapter.deleteObject({Bucket:this.bucket,Key:this.getMetaName(t)})}async save(t,o){const a={...o};a.metadata&&(a.metadata=b(o.metadata));const e=encodeURIComponent(JSON.stringify(a));return await this.adapter.putObject({Bucket:this.bucket,ContentLength:0,ContentType:"application/json",Key:this.getMetaName(t),Metadata:{metadata:e}}),o}}export{k as b,A as p};
@@ -0,0 +1 @@
1
+ import{throwErrorCode as c,ERRORS as d}from"./ERRORS-BIBxE2oR.js";import l from"./MetaStorage-DPEUyWgN.js";import{parseMetadata as p,stringifyMetadata as m}from"./Metadata-B7CcBueg.js";import{BlobServiceClient as s,StorageSharedKeyCredential as u,BlobSASPermissions as g,SASProtocol as h}from"@azure/storage-blob";const N=(i,e)=>{const t=e.startsWith("?")?e.slice(1):e;return i.includes("?")?`${i}&${t}`:`${i}?${t}`},y=300*1e3,f=i=>{const e={};for(const t of i.split(";")){const n=t.indexOf("=");n>0&&(e[t.slice(0,n).trim()]=t.slice(n+1).trim())}return e},w=(i,e)=>i||(e?`https://${e}.blob.core.windows.net`:void 0),A=i=>{const e=i.connectionString||process.env.AZURE_STORAGE_CONNECTION_STRING||void 0;if(e){const o=s.fromConnectionString(e);return f(e).AccountKey?{client:o,signer:{kind:"sharedKey"}}:{client:o}}const t=i.accountKey||process.env.AZURE_STORAGE_ACCOUNT_KEY||void 0,n=i.accountName||process.env.AZURE_STORAGE_ACCOUNT||void 0,r=w(i.endpoint,n);if(t){if(!n)throw new Error("Missing required parameter: Azure blob storage account name.");const o=new u(n,t);return{client:new s(r,o),signer:{kind:"sharedKey"}}}if(i.credential){if(!r)throw new Error("Missing required parameter: Azure blob storage account name or endpoint.");const o=new s(r,i.credential);return i.useUserDelegationSas===!1?{client:o}:{client:o,signer:{client:o,kind:"userDelegation"}}}const a=i.sasToken||process.env.AZURE_STORAGE_SAS_TOKEN||void 0;if(a){if(!r)throw new Error("Missing required parameter: Azure blob storage account name or endpoint.");const o=a.startsWith("?")?"":"?";return{client:new s(`${r}${o}${a}`),sasToken:a}}if(!r)throw new Error("Missing required Azure credentials: provide a connectionString, accountKey + accountName, a credential, a sasToken, or an accountName/endpoint for anonymous access.");return{anonymous:!0,client:new s(r)}},E=async(i,e,t)=>{if(i.cachedKey&&i.cachedKey.expiresOn.getTime()>t.getTime())return i.cachedKey.key;if(i.pendingKey&&i.pendingKey.expiresOn.getTime()>t.getTime())return i.pendingKey.promise;const n=new Date(t.getTime()+y),r=i.client.getUserDelegationKey(e,n),a={expiresOn:n,promise:r};i.pendingKey=a;try{const o=await r;return i.cachedKey={expiresOn:n,key:o},o}finally{i.pendingKey===a&&(i.pendingKey=void 0)}},K=async(i,e,t)=>{const n=new Date(Date.now()-6e4),r=new Date(Date.now()+t.expiresIn*1e3),a={expiresOn:r,permissions:g.parse(t.permissions),protocol:h.Https,startsOn:n,...t.contentDisposition&&{contentDisposition:t.contentDisposition},...t.contentType&&{contentType:t.contentType}};if(e.kind==="sharedKey")return i.generateSasUrl(a);const o=await E(e,n,r);return i.generateUserDelegationSasUrl(a,o)};class R extends l{constructor(e){super(e),this.config=e;const{client:t,...n}=e;if(this.client=t===void 0?A(n).client:t,!(n.containerName||process.env.AZURE_STORAGE_CONTAINER))throw new Error("Missing required parameter: Azure container name.");this.containerClient=this.client.getContainerClient(n.containerName)}config;client;containerClient;async get(e){const t=this.containerClient.getAppendBlobClient(this.getMetaName(e));let n;try{n=await t.getProperties()}catch{throw c(d.UNKNOWN_ERROR)}if(!n.metadata)throw c(d.FILE_NOT_FOUND);const r=n.metadata;return r.metadata&&typeof r.metadata=="string"&&(r.metadata=p(r.metadata)),r}async touch(e,t){return this.save(e,t)}async delete(e){await this.containerClient.getBlockBlobClient(this.getMetaName(e)).deleteIfExists()}async save(e,t){const n={...t};return n.metadata&&(n.metadata=m(t.metadata)),await this.containerClient.getAppendBlobClient(this.getMetaName(e)).setMetadata(n,{}),t}async list(){const e=[],t=this.containerClient.listBlobsFlat({prefix:this.prefix});for await(const n of t)e.push(n);return e.filter(n=>n.name.endsWith(this.suffix)).map(n=>({createdAt:n.properties.createdOn,id:this.getIdFromMetaName(n.name)}))}}export{A as a,K as b,R as c,N as d};
@@ -0,0 +1 @@
1
+ const n=e=>{const r=e?.applicationKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.B2_APP_KEY??process.env.BACKBLAZE_APP_KEY,c=e?.applicationKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.B2_APP_KEY_ID??process.env.BACKBLAZE_APP_KEY_ID,s=e?.region??process.env.AWS_REGION??process.env.B2_REGION??process.env.BACKBLAZE_REGION;if(!s||!c||!r)throw new Error("Missing required parameters for Backblaze B2 client.");return{credentials:{accessKeyId:c,secretAccessKey:r},endpoint:`https://s3.${s}.backblazeb2.com`,region:s}};export{n as default};
@@ -0,0 +1 @@
1
+ import{EventEmitter as u}from"node:events";import{format as m}from"node:url";import g from"mime";import{ErrorMap as b}from"./ERRORS-BIBxE2oR.js";import{H as w}from"./headers-BAiAKekR.js";import{Readable as f}from"node:stream";import"type-is";import{B as h}from"./storage-Cyy73Y6r.js";const C=(r,e)=>{const t={};return e.forEach(s=>{t[s]=r[s]}),t},R=r=>r.at(-1),y=r=>{let e="",t="";const s=c(r,"forwarded");return s&&s.split(";").forEach(o=>{const[i,n]=o.split("=");i==="proto"&&(e=n),i==="host"&&(t=n)}),{host:t,proto:e}},P=(r,e="utf8",t)=>new Promise((s,o)=>{const i=[];let n=0;r.on("data",d=>{const a=Buffer.isBuffer(d)?d:Buffer.from(d,e);if(n+=a.length,n>t){o(new Error("Request body length limit exceeded")),r.destroy();return}i.push(a)}),r.once("end",()=>{s(Buffer.concat(i).toString(e))}),r.once("error",o)}),c=(r,e,t=!1)=>{const s=r.headers?.[e.toLowerCase()];if(!s||s.length===0)return"";if(t)return s.toString().trim();const o=Array.isArray(s)?s:s.split(",");return R(o).trim()},E=(r,e,t)=>{const s=[r.getHeader(e),t].flat().filter(Boolean).toString();r.setHeader(e,s)},A=(r,e={})=>{const t=Object.keys(e);t.length>0&&E(r,"Access-Control-Expose-Headers",t),t.forEach(s=>{if(["link","location"].includes(s.toLowerCase())){const o=encodeURI(e[s].toString()).replaceAll("#","%23");r.setHeader(s,o)}else r.setHeader(s,e[s])})},U=r=>c(r,"host")||c(r,"x-forwarded-host"),I=r=>c(r,"x-forwarded-proto").toLowerCase(),L=r=>{let{host:e,proto:t}=y(r);return e||=U(r),t||=I(r),e?t?`${t}://${e}`:`//${e}`:""},H=r=>{let e=(r.originalUrl||r.url||"").split("?")[0];if(!e)throw new TypeError("Invalid request URL");return e.startsWith("/")||(e=`/${e}`),e.startsWith("http")&&(e=new URL(e).pathname),e},$=/^[\da-z]{4,}(?:-[\da-z]{4,}){2,}$/i,k=r=>{const e=H(r).split("/").filter(Boolean);if(e.length===0)throw new Error("Invalid request URL");for(let o=e.length-1;o>=0;o-=1){const i=e[o];if(!i)continue;const n=i.replace(/\.[^/.]+$/,"");if(!["files","metadata","upload","download","http-rest","http-rest-chunked"].includes(n.toLowerCase())&&$.test(n))return h.assertSafeId(n),n}const t=e[e.length-1];if(!t)throw new Error("Invalid request URL");const s=t.replace(/\.[^/.]+$/,"");if(["files","metadata","upload","download","http-rest","http-rest-chunked"].includes(s.toLowerCase()))throw new Error("Invalid request URL");if(s.length<8)throw new Error("Invalid request URL");if(e.length>1)return h.assertSafeId(s),s;throw new Error("Invalid request URL")},W=r=>"body"in r&&r.body&&typeof r.body.getReader=="function"?f.fromWeb(r.body):"body"in r&&r.body&&r.body instanceof Uint8Array?f.from(Buffer.from(r.body)):r instanceof f?r:f.from(new Uint8Array(0));class j extends u{responseType="json";storage;mediaTransformer;disableTerminationForFinishedUploads;logger;get loggerInstance(){return this.logger}internalErrorResponses={};get errorResponses(){return this.internalErrorResponses}constructor({disableTerminationForFinishedUploads:e,mediaTransformer:t,storage:s}){super(),this.storage=s,this.mediaTransformer=t,this.disableTerminationForFinishedUploads=e,this.logger=this.storage?.logger,this.assembleErrors()}set errorResponses(e){this.assembleErrors(e)}assembleErrors=(e={})=>{this.internalErrorResponses={...b,...this.internalErrorResponses,...this.storage.errorResponses,...e}};parseRangeHeader(e,t){if(!e?.startsWith("bytes="))return;const s=e.slice(6).split(",");if(s.length!==1)return;const o=s[0]?.trim();if(!o)return;const i=o.split("-");if(i.length!==2)return;const[n,d]=i;let a,l;if(n&&d)a=Number.parseInt(n,10),l=Number.parseInt(d,10);else if(n&&!d)a=Number.parseInt(n,10),l=t-1;else if(!n&&d){const p=Number.parseInt(d,10);a=Math.max(0,t-p),l=t-1}else return;if(!(Number.isNaN(a)||Number.isNaN(l)||a>=t||l>=t||a>l))return{end:l,start:a}}buildFileUrlFromString(e,t,s){const o=new URL(e,"http://localhost"),{pathname:i}=o,n=Object.fromEntries(o.searchParams.entries()),d=m({pathname:`${i}/${t.id}`,query:n});let a="";return this.storage.config.useRelativeLocation||(/^https?:\/\//iu.test(e)?a=o.origin:s&&(a=L({headers:s}))),`${a}${d}.${g.getExtension(t.contentType)}`}negotiateContentTypeFromHeader(e,t){if(e)return w.getPreferredMediaType(e,t)}checkForUndefinedIdOrPath(e){if(e instanceof Error&&["Id is undefined","Invalid request URL","Path is undefined"].includes(e.message))throw e}}export{W as a,c as b,j as c,C as d,H as e,k as g,P as r,A as s,$ as u};
@@ -0,0 +1 @@
1
+ import{H as u,h as f}from"./headers-BAiAKekR.js";import{ERRORS as p,isUploadError as C}from"./ERRORS-BIBxE2oR.js";import{c as E,d as b}from"./base-handler-core-EeV8gZck.js";import{i as R}from"./storage-Cyy73Y6r.js";import{waitForStorage as O}from"./waitForStorage-ByQmG4xF.js";class A extends E{static methods=["delete","get","head","options","patch","post","put"];registeredHandlers=new Map;constructor(t){super(t),this.compose()}get handlers(){return this.registeredHandlers}async fetch(t){this.logger?.debug("[fetch request]: %s %s",t.method,t.url);const e=this.registeredHandlers.get(t.method||"GET");if(!e)return this.createErrorResponse({UploadErrorCode:p.METHOD_NOT_ALLOWED});try{await O(this.storage)}catch{return this.createErrorResponse({UploadErrorCode:p.STORAGE_ERROR})}try{const o=await e.call(this,t);return this.handleFetchResponse(t,o)}catch(o){const s=o instanceof Error?o:new Error(String(o)),r={...b(s,["name",...Object.getOwnPropertyNames(s)]),request:{headers:Object.fromEntries(t.headers.entries()),method:t.method,url:t.url}};return this.listenerCount("error")>0&&this.emit("error",r),this.logger?.error("[fetch error]: %O",r),this.createErrorResponse(s)}}async handleFetchResponse(t,e){if(t.method==="HEAD"||t.method==="OPTIONS"){const{headers:n,statusCode:d}=e;return new Response(void 0,{headers:this.convertHeaders({...n,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control"}),status:d})}if(t.method==="GET"){const{headers:n,statusCode:d}=e;let c="";return e.content!==void 0?c=new Uint8Array(e.content):typeof e=="object"&&"data"in e&&(c=JSON.stringify(e.data)),new Response(c,{headers:this.convertHeaders({...n,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control"}),status:d})}const{headers:o,statusCode:s,...r}=e;if(r.status!==void 0&&this.listenerCount(r.status)>0&&this.emit(r.status,{...r,request:{headers:Object.fromEntries(t.headers.entries()),method:t.method,url:t.url}}),r.status==="completed"){const n=e;n.headers===void 0&&(n.headers={}),n.statusCode===void 0&&(n.statusCode=200);try{await this.storage.onComplete(r,n)}catch(l){throw this.logger?.error("[onComplete error]: %O",l),l}const{headers:d,statusCode:c,...g}=n,{content:H,stream:w,...y}=g;return this.createResponse({body:y,headers:d||o,statusCode:c||s||200})}const m={...o,...e.headers},a=this.convertHeaders({...m,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control",...r.hash===void 0?{}:{[`X-Range-${r.hash?.algorithm.toUpperCase()}`]:r.hash?.value}}),h=e.headers||{};h.Location&&!a.location&&!a.Location?a.location=String(h.Location):h.location&&!a.location&&!a.Location?a.location=String(h.location):o.Location&&!a.location&&!a.Location?a.location=String(o.Location):o.location&&!a.location&&!a.Location&&(a.location=String(o.location));let i;return s>=200&&s<300&&(i=Object.keys(r).length>0?{...r}:{},"content"in i&&delete i.content,"stream"in i&&delete i.stream,Object.keys(i).length===0&&(i={})),this.createResponse({body:i,headers:a,statusCode:s||200})}convertHeaders(t){const e={};for(const[o,s]of Object.entries(t))e[o]=Array.isArray(s)?s.join(", "):String(s);return e}createResponse(t){const{body:e,headers:o={},statusCode:s}=t;let r;return s===204?r=null:typeof e=="string"?r=e:e instanceof Buffer?r=new Uint8Array(e):e&&typeof e=="object"?(r=JSON.stringify(e),o["Content-Type"]||(o["Content-Type"]=u.createContentType({charset:"utf8",mediaType:"application/json"}))):e===void 0&&s!==void 0&&s>=200&&s<300&&(r="{}",o["Content-Type"]||(o["Content-Type"]=u.createContentType({charset:"utf8",mediaType:"application/json"}))),new Response(r,{headers:this.convertHeaders(o),status:s})}async createErrorResponse(t){let e;C(t)?e=this.internalErrorResponses[t.UploadErrorCode]:!R(t)&&!f.isHttpError(t)?e=this.storage.normalizeError(t):e={...t,code:t.code||t.name,headers:t.headers||{},message:t.message,name:t.name,statusCode:t.statusCode||500},await this.storage.onError(e);let o;return e.body?typeof e.body=="object"&&e.body!==null?o={body:e.body,headers:e.headers,statusCode:e.statusCode}:o={body:{error:{code:e.code||e.name||"Error",message:e.body||e.message||"Unknown error",name:e.name||"Error"}},headers:e.headers,statusCode:e.statusCode||500}:o={body:{error:{code:e.code||e.name||"Error",message:e.message||"Unknown error",name:e.name||"Error"}},headers:e.headers,statusCode:e.statusCode||500},this.createResponse(o)}buildFileUrl(t,e){return this.buildFileUrlFromString(t.url,e)}negotiateContentType(t,e){return super.negotiateContentTypeFromHeader(t.headers.get("accept")||void 0,e)}}export{A as C};
@@ -0,0 +1 @@
1
+ import{paginate as H}from"@visulima/pagination";import{H as b,h as N,n as f}from"./headers-BAiAKekR.js";import T from"mime";import{ERRORS as g,isUploadError as L}from"./ERRORS-BIBxE2oR.js";import{match as z}from"path-to-regexp";import{d as O,c as M,s as S,e as w,u as R}from"./base-handler-core-EeV8gZck.js";import{i as j}from"./storage-Cyy73Y6r.js";import{waitForStorage as k}from"./waitForStorage-ByQmG4xF.js";import{PassThrough as $}from"node:stream";import{e as v}from"./response-builder-CbSA8qPa.js";const P=z(["/:uuid","/*path/:uuid.:ext/:metadata","/*path/:uuid/:metadata","/*path/:uuid.:ext","/*path/:uuid"],{decode:decodeURIComponent}),F=c=>{const e=P(c);if(!e)return;const{params:t}=e;if(!t.uuid)return;const s={uuid:t.uuid};return t.metadata!==void 0&&(s.metadata=t.metadata),t.path!==void 0&&(s.path=t.path),t.ext!==void 0&&(s.ext=t.ext),{params:s,path:e.path}},D=(c,e,t)=>{let s=0,r=0;const o=t-e+1;return new $({highWaterMark:Math.min(64*1024,o),transform(n,d,a){const h=n.length,i=s,p=i+h-1;if(s+=h,p<e){a();return}if(i>t){this.end(),a();return}const u=Math.max(0,e-i),y=Math.min(h,t-i+1);if(u<y){const C=n.subarray(u,y);r+=C.length,this.push(C)||c.pause()}r>=o&&(this.end(),c.destroy()),a()}})},_=(c,e,t)=>{let s=!1;const r=()=>{s||(s=!0,c.destroy())};e.on("drain",()=>{c.resume()}),e.on("close",r),e.on("finish",r),e.on("error",r),c.on("end",()=>{e.end()}),c.on("error",async o=>{s||(await t(e,o),r())}),c.on("data",o=>{e.write(o)||c.pause()}),typeof e.listeners=="function"&&e.listeners("close")?.length===0&&e.on("close",r)},I=(c,e,t)=>{const{headers:s,statusCode:r}=c;e(t,{headers:s,statusCode:r})},X=(c,e,t,s,r,o,n)=>{e.body=c?.data===void 0?c:c.data;const{headers:d,statusCode:a}=c,h=c;if(h.stream)if(typeof s=="function")s();else{const i=n(e.headers.range,h.size||0);o(t,h.stream,{headers:d,range:i||void 0,size:h.size,statusCode:a})}else{let i="";c.content!==void 0?i=c.content:typeof c=="object"&&"data"in c&&(i=c.data),typeof s=="function"?s():r(t,{body:i,headers:d,statusCode:a})}},q=async(c,e,t,s,r,o,n)=>{const{headers:d,statusCode:a,...h}=c;if(typeof s=="function")e._body=!0,e.body=h,s();else{const i=c,p=i.headers?{...i.headers}:{};i.headers===void 0&&(i.headers={}),i.statusCode===void 0&&(i.statusCode=200);try{const u=r.onComplete(h,i,e);u instanceof Promise&&await u}catch(u){throw o?.error&&o.error("[onComplete error]: %O",u),u}Object.keys(i.headers||{}).length===0&&Object.keys(p).length>0?i.headers=p:i.headers&&Object.keys(p).length>0&&(i.headers={...p,...i.headers}),n(e,t,i)}},G=(c,e,t,s)=>{const{headers:r,statusCode:o,...n}=c,d=r||{},a=d["X-Chunked-Upload"]==="true"||d["x-chunked-upload"]==="true";let h;const i={...v(d),...r?v(r):{},...n.hash===void 0?{}:{[`X-Range-${n.hash?.algorithm.toUpperCase()}`]:String(n.hash?.value)}};a&&(h=JSON.stringify(n),!i["Content-Type"]&&!i["content-type"]&&(i["Content-Type"]="application/json; charset=utf-8")),e.method==="HEAD"&&(h=""),s(t,{body:h,headers:i,statusCode:o||200})},W=async(c,e,t,s,r,o,n)=>{const d=c instanceof Error?c:new Error(String(c)),a={...O(d,["name",...Object.getOwnPropertyNames(d)]),request:O(e,["headers","method","url"])};s("error")>0&&t("error",a),r?.error&&r.error("[error]: %O",a),await o(n,d)},m="Content-Type";class x extends M{static methods=["delete","get","head","options","patch","post","put"];registeredHandlers=new Map;constructor(e){super(e),this.compose()}get handlers(){return this.registeredHandlers}handle=async(e,t)=>this.upload(e,t);upload=async(e,t,s)=>{e.on("error",o=>this.logger?.error("[request error]: %O",o)),this.logger?.debug("[request]: %s %s",e.method,e.url);const r=this.registeredHandlers.get(e.method);if(!r){await this.sendError(t,{UploadErrorCode:g.METHOD_NOT_ALLOWED});return}try{await k(this.storage)}catch{await this.sendError(t,{UploadErrorCode:g.STORAGE_ERROR});return}try{const o=await r.call(this,e,t);if(["HEAD","OPTIONS"].includes(e.method))I(o,this.send.bind(this),t);else if(e.method==="GET"){const n=o;n&&X(n,e,t,s,this.send.bind(this),this.sendStream.bind(this),this.parseRangeHeader.bind(this))}else{const{headers:n,statusCode:d,...a}=o;this.logger?.debug("[%s]: %s: %d/%d",a.status,a.name,a.bytesWritten,a.size),a.status!==void 0&&this.listenerCount(a.status)>0&&this.emit(a.status,{...a,request:O(e,["headers","method","url"])}),a.status==="completed"?await q(o,e,t,s,this.storage,this.logger,(h,i,p)=>{this.finish(h,i,p)}):G(o,e,t,(h,i)=>{this.send(h,{body:i.body,headers:i.headers,statusCode:i.statusCode})})}}catch(o){await W(o,e,this.emit.bind(this),this.listenerCount.bind(this),this.logger,this.sendError.bind(this),t)}};send(e,{body:t="",headers:s={},statusCode:r=200}){let o;const n={...s};if(typeof t=="string"){if(o=t,n[m]===void 0)n[m]=b.createContentType({mediaType:"text/plain"});else{const d=Array.isArray(n[m])?n[m].join(", "):String(n[m]);n[m]=b.ensureCharset(d)}n["Content-Length"]===void 0&&(n["Content-Length"]=Buffer.byteLength(t))}else t instanceof Buffer?o=t:(o=JSON.stringify(t),n[m]||(n[m]=b.createContentType({charset:"utf8",mediaType:"application/json"})));S(e,n),e.statusCode=r,e.end(o)}async sendError(e,t){let s;L(t)?s=this.internalErrorResponses[t.UploadErrorCode]:!j(t)&&!N.isHttpError(t)?s=this.storage.normalizeError(t):s={...t,code:t.code||t.name,headers:t.headers||{},message:t.message,name:t.name,statusCode:t.statusCode||500},await this.storage.onError(s);let r;s.body?typeof s.body=="object"&&s.body!==null?r={body:s.body,headers:s.headers,statusCode:s.statusCode}:r={body:{error:{code:s.code||s.name||"Error",message:s.body||s.message||"Unknown error",name:s.name||"Error"}},headers:s.headers,statusCode:s.statusCode||500}:r={body:{error:{code:s.code||s.name||"Error",message:s.message||"Unknown error",name:s.name||"Error"}},headers:s.headers,statusCode:s.statusCode||500},this.send(e,r)}sendStream(e,t,{headers:s={},range:r,size:o,statusCode:n=200}){S(e,s),e.statusCode=n;let d=t;r&&o?(e.statusCode=206,e.setHeader("Content-Range",`bytes ${r.start}-${r.end}/${o}`),e.setHeader("Content-Length",r.end-r.start+1),e.setHeader("Accept-Ranges","bytes"),d=D(t,r.start,r.end)):(o&&e.setHeader("Content-Length",o),e.setHeader("Accept-Ranges","bytes")),_(d,e,(a,h)=>this.sendError(a,h))}finish(e,t,s){const r="id"in s&&"headers"in s&&!("body"in s);let o,n,d;if(r){const a=s,h=a.headers||{},i=a.statusCode||200,{headers:p,statusCode:u,...y}=a;o=y,n={...h},d=i}else{const a=s;o=a.body,n=a.headers||{},d=a.statusCode||200}if(o&&typeof o=="object"&&o.content!==void 0){const{content:a,contentType:h}=o;o=a,n={...n,"Content-Type":h}}this.send(t,{body:o||s,headers:n,statusCode:d})}buildFileUrl(e,t){return this.buildFileUrlFromString(e.originalUrl||e.url,t,e.headers)}negotiateContentType(e,t){return super.negotiateContentTypeFromHeader(e.headers.accept,t)}async options(e,t){return{headers:{"Access-Control-Allow-Methods":(this.constructor.methods||x.methods).map(s=>s.toUpperCase()).join(", ")},statusCode:204}}async get(e,t){const s=F(w(e));if(s?.params.uuid){const{ext:r,metadata:o,uuid:n}=s.params,d=r?n.replace(new RegExp(String.raw`\.${r}$`),""):n;if(o==="metadata"&&w(e).endsWith("/metadata"))try{const a=await this.storage.getMeta(d);return{...a,content:JSON.stringify(a),headers:{"Content-Type":b.createContentType({charset:"utf8",mediaType:"application/json"}),...a.expiredAt===void 0?{}:{"X-Upload-Expires":a.expiredAt.toString()},...a.modifiedAt===void 0?{}:{"Last-Modified":a.modifiedAt.toString()}},statusCode:200}}catch(a){const h=a;throw h.UploadErrorCode===g.FILE_NOT_FOUND||h.UploadErrorCode===g.GONE?f(404,"File metadata not found"):a}if(!R.test(d))return this.list(e,t);try{const a=new URL(e.url||"","http://localhost"),h=Object.fromEntries(a.searchParams.entries());if(Object.keys(h).length>0&&this.mediaTransformer&&this.mediaTransformer)try{const l=await this.mediaTransformer.handle(d,h);return{content:l.buffer,headers:{"Content-Length":String(l.size),"Content-Type":`${l.mediaType}/${l.format}`,"X-Media-Type":l.mediaType,"X-Original-Format":l.originalFile?.contentType?.split("/")[1]||"","X-Transformed-Format":l.format,...l.originalFile?.expiredAt===void 0?{}:{"X-Upload-Expires":l.originalFile.expiredAt.toString()},...l.originalFile?.modifiedAt===void 0?{}:{"Last-Modified":l.originalFile.modifiedAt.toString()},...l.originalFile?.ETag===void 0?{}:{ETag:l.originalFile.ETag}},statusCode:200}}catch(l){if(l.name==="ValidationError")throw f(400,l.message);this.logger?.warn(`Media transformation failed: ${l.message}`)}const i=await this.storage.getMeta(d);if((e.headers.range||i.size&&i.size>1024*1024)&&this.storage.getStream)try{const l=await this.storage.getStream({id:d});let E=l.headers?.["Content-Type"]||i.contentType;return E.includes("image")&&typeof r=="string"&&(E=T.getType(r)||E),{headers:{...l.headers,"Accept-Ranges":"bytes","Content-Type":E},size:l.size,statusCode:200,stream:l.stream,...i,contentType:E}}catch(l){this.logger?.warn(`Streaming failed, falling back to buffer: ${l}`)}const p=await this.storage.get({id:d});let{contentType:u}=p;u.includes("image")&&typeof r=="string"&&(u=T.getType(r)||u);const{ETag:y,expiredAt:C,modifiedAt:U,size:A}=p;return{headers:{"Accept-Ranges":"bytes","Content-Length":String(A),"Content-Type":u,...C===void 0?{}:{"X-Upload-Expires":C.toString()},...U===void 0?{}:{"Last-Modified":U.toString()},...y===void 0?{}:{ETag:y}},statusCode:200,...p,contentType:u}}catch(a){const h=a;throw h.UploadErrorCode===g.FILE_NOT_FOUND||h.UploadErrorCode===g.GONE?f(404,"File not found"):a}}return this.list(e,t)}async list(e,t){const s=new URL(e.url||"","http://localhost"),r=s.searchParams.get("limit"),o=s.searchParams.get("page"),n=await this.storage.list(Number(r||1e3));return n.length===0?{data:[],headers:{},statusCode:200}:o!==void 0&&r!==void 0?{data:H(Number(o),Number(r),n.length,n),headers:{},statusCode:200}:{data:n,headers:{},statusCode:200}}async download(e,t){const s=F(w(e));if(!s?.params.uuid||!R.test(s.params.uuid))throw f(404,"File not found");const{ext:r,uuid:o}=s.params;try{const n=await this.storage.getMeta(o);if(!this.storage.getStream){await this.sendError(t,f(501,"Streaming download not supported"));return}const d=await this.storage.getStream({id:o});let a=d.headers?.["Content-Type"]||n.contentType;a.includes("image")&&typeof r=="string"&&(a=T.getType(r)||a);const h=this.parseRangeHeader(e.headers.range,d.size||0),i={...d.headers,"Accept-Ranges":"bytes","Content-Disposition":b.createContentDisposition({filename:n.originalName||o,type:"attachment"}),"Content-Type":a};this.sendStream(t,d.stream,{headers:i,range:h||void 0,size:d.size,statusCode:h?206:200})}catch(n){const d=n;if(d.UploadErrorCode===g.FILE_NOT_FOUND||d.UploadErrorCode===g.GONE){await this.sendError(t,f(404,"File not found"));return}await this.sendError(t,n)}}checkForUndefinedIdOrPath(e){if(e instanceof Error&&["Id is undefined","Invalid request URL","Path is undefined"].includes(e.message))throw f(404,"File not found")}}export{x as T};
@@ -0,0 +1 @@
1
+ class r{get(){}set(){return!0}delete(){return!0}clear(){}has(){return!1}}export{r as N};
@@ -0,0 +1 @@
1
+ import{tool as a}from"@anthropic-ai/claude-agent-sdk";import{T as i,e as l}from"./executors-BDzMjc4y.js";const s={readOnlyHint:!0},d={destructiveHint:!0,readOnlyHint:!1},r={destructiveHint:!1,idempotentHint:!0,readOnlyHint:!1},p=e=>({content:[{text:typeof e=="string"?e:JSON.stringify(e),type:"text"}]}),F=e=>({content:[{text:e instanceof Error?e.message:String(e),type:"text"}],isError:!0}),o=e=>async t=>{try{return p(await e(t))}catch(n){return F(n)}},g=e=>a("listFiles",i.listFiles.description,i.listFiles.input.shape,o(t=>l.listFiles(e,t)),{annotations:s}),U=e=>a("getFileMetadata",i.getFileMetadata.description,i.getFileMetadata.input.shape,o(t=>l.getFileMetadata(e,t)),{annotations:s}),y=e=>a("downloadFile",i.downloadFile.description,i.downloadFile.input.shape,o(t=>l.downloadFile(e,t)),{annotations:s}),h=e=>a("getFileUrl",i.getFileUrl.description,i.getFileUrl.input.shape,o(t=>l.getFileUrl(e,t)),{annotations:s}),f=(e,{annotations:t=d}={})=>a("uploadFile",i.uploadFile.description,i.uploadFile.input.shape,o(n=>l.uploadFile(e,n)),{annotations:t}),H=(e,{annotations:t=d}={})=>a("deleteFile",i.deleteFile.description,i.deleteFile.input.shape,o(n=>l.deleteFile(e,n)),{annotations:t}),m=(e,{annotations:t=r}={})=>a("copyFile",i.copyFile.description,i.copyFile.input.shape,o(n=>l.copyFile(e,n)),{annotations:t}),w=(e,{annotations:t=r}={})=>a("signUploadUrl",i.signUploadUrl.description,i.signUploadUrl.input.shape,o(n=>l.signUploadUrl(e,n)),{annotations:t});export{m as claudeCopyFile,H as claudeDeleteFile,y as claudeDownloadFile,U as claudeGetFileMetadata,h as claudeGetFileUrl,g as claudeListFiles,w as claudeSignUploadUrl,f as claudeUploadFile};
@@ -0,0 +1 @@
1
+ const o=e=>{const s=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.CLOUDFLARE_ACCESS_KEY_ID??process.env.CLOUDFLARE_ACCESS_KEY,r=e?.accountId??process.env.CLOUDFLARE_ACCOUNT_ID,c=e?.jurisdiction??process.env.CLOUDFLARE_JURISDICTION??process.env.CLOUDFLARE_R2_JURISDICTION,C=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.CLOUDFLARE_SECRET_ACCESS_KEY??process.env.CLOUDFLARE_SECRET_KEY;if(!r||!s||!C)throw new Error("Missing required parameters for Cloudflare R2 client.");return{credentials:{accessKeyId:s,secretAccessKey:C},endpoint:`https://${r}.${c?`${c}.`:""}r2.cloudflarestorage.com`,region:"auto"}};export{o as default};
@@ -0,0 +1 @@
1
+ import{tool as l}from"ai";import{T as e,e as p}from"./executors-BDzMjc4y.js";const a=i=>l({description:e.listFiles.description,execute:t=>p.listFiles(i,t),inputSchema:e.listFiles.input}),r=i=>l({description:e.getFileMetadata.description,execute:t=>p.getFileMetadata(i,t),inputSchema:e.getFileMetadata.input}),s=i=>l({description:e.downloadFile.description,execute:t=>p.downloadFile(i,t),inputSchema:e.downloadFile.input}),c=i=>l({description:e.getFileUrl.description,execute:t=>p.getFileUrl(i,t),inputSchema:e.getFileUrl.input}),u=(i,{needsApproval:t=!0}={})=>l({description:e.uploadFile.description,execute:o=>p.uploadFile(i,o),inputSchema:e.uploadFile.input,needsApproval:t}),F=(i,{needsApproval:t=!0}={})=>l({description:e.deleteFile.description,execute:o=>p.deleteFile(i,o),inputSchema:e.deleteFile.input,needsApproval:t}),g=(i,{needsApproval:t=!0}={})=>l({description:e.copyFile.description,execute:o=>p.copyFile(i,o),inputSchema:e.copyFile.input,needsApproval:t}),m=(i,{needsApproval:t=!0}={})=>l({description:e.signUploadUrl.description,execute:o=>p.signUploadUrl(i,o),inputSchema:e.signUploadUrl.input,needsApproval:t});export{g as copyFile,F as deleteFile,s as downloadFile,r as getFileMetadata,c as getFileUrl,a as listFiles,m as signUploadUrl,u as uploadFile};
@@ -0,0 +1 @@
1
+ import{toolDefinition as t}from"@tanstack/ai";import{T as e,e as p}from"./executors-BDzMjc4y.js";const a=i=>t({description:e.listFiles.description,inputSchema:e.listFiles.input,name:"listFiles"}).server(l=>p.listFiles(i,l)),d=i=>t({description:e.getFileMetadata.description,inputSchema:e.getFileMetadata.input,name:"getFileMetadata"}).server(l=>p.getFileMetadata(i,l)),s=i=>t({description:e.downloadFile.description,inputSchema:e.downloadFile.input,name:"downloadFile"}).server(l=>p.downloadFile(i,l)),F=i=>t({description:e.getFileUrl.description,inputSchema:e.getFileUrl.input,name:"getFileUrl"}).server(l=>p.getFileUrl(i,l)),c=(i,{needsApproval:l=!0}={})=>t({description:e.uploadFile.description,inputSchema:e.uploadFile.input,name:"uploadFile",needsApproval:l}).server(n=>p.uploadFile(i,n)),u=(i,{needsApproval:l=!0}={})=>t({description:e.deleteFile.description,inputSchema:e.deleteFile.input,name:"deleteFile",needsApproval:l}).server(n=>p.deleteFile(i,n)),m=(i,{needsApproval:l=!0}={})=>t({description:e.copyFile.description,inputSchema:e.copyFile.input,name:"copyFile",needsApproval:l}).server(n=>p.copyFile(i,n)),v=(i,{needsApproval:l=!0}={})=>t({description:e.signUploadUrl.description,inputSchema:e.signUploadUrl.input,name:"signUploadUrl",needsApproval:l}).server(n=>p.signUploadUrl(i,n));export{m as copyFile,u as deleteFile,s as downloadFile,d as getFileMetadata,F as getFileUrl,a as listFiles,v as signUploadUrl,c as uploadFile};
@@ -0,0 +1 @@
1
+ import{r as w}from"./approval-fVHwBp7u.js";import{T as d,W as g,e as r}from"./executors-BDzMjc4y.js";import*as y from"zod";const k=t=>{const s=y.toJSONSchema(t),{$schema:l,...e}=s;return e},S=["listFiles","getFileMetadata","downloadFile","getFileUrl","uploadFile","deleteFile","copyFile","signUploadUrl"],p=t=>g.has(t),U=async(t,s,l)=>{const e=d[s].input.safeParse(l);if(!e.success)return{issues:e.error.issues,ok:!1};switch(s){case"copyFile":return{ok:!0,output:await r.copyFile(t,e.data)};case"deleteFile":return{ok:!0,output:await r.deleteFile(t,e.data)};case"downloadFile":return{ok:!0,output:await r.downloadFile(t,e.data)};case"getFileMetadata":return{ok:!0,output:await r.getFileMetadata(t,e.data)};case"getFileUrl":return{ok:!0,output:await r.getFileUrl(t,e.data)};case"listFiles":return{ok:!0,output:await r.listFiles(t,e.data)};case"signUploadUrl":return{ok:!0,output:await r.signUploadUrl(t,e.data)};case"uploadFile":return{ok:!0,output:await r.uploadFile(t,e.data)};default:{const u=s;throw new Error(`Unhandled tool: ${String(u)}`)}}},_=({files:t,overrides:s,readOnly:l=!1,requireApproval:e=!0})=>{const u=S.filter(a=>!(l&&p(a))),F=a=>p(a)?w(a,e):!1,f=u.map(a=>{const o=d[a],i=s?.[a];return{description:i?.description??o.description,name:a,parameters:k(o.input),strict:i?.strict??!1,type:"function"}}),m=new Set(u);return{definitions:f,execute:async a=>{const o=n=>({call_id:a.call_id,output:typeof n=="string"?n:JSON.stringify(n),type:"function_call_output"});if(!m.has(a.name))return o({error:`Unknown tool: ${a.name}`});let i;try{i=JSON.parse(a.arguments)}catch(n){return o({error:`Invalid JSON in arguments: ${n.message}`})}const c=await U(t,a.name,i);return c.ok?o(c.output):o({error:"Argument validation failed",issues:c.issues})},needsApproval:F}};export{_ as createResponsesFileTools};
@@ -0,0 +1 @@
1
+ const l={backoffMultiplier:2,calculateDelay:void 0,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:()=>!1},m=(t,e,r,o)=>{const a=Math.min(e*r**t,o);return Math.floor(Math.random()*a)},R=t=>new Promise(e=>{setTimeout(e,t)}),b=(t,e=l.retryableStatusCodes)=>{if(t instanceof Error){const r=t.code,o=t.name;if(o==="AbortError"||r==="ABORT_ERR")return!1;if(r==="ECONNRESET"||r==="ETIMEDOUT"||r==="ENOTFOUND"||r==="ECONNREFUSED"||r==="EAI_AGAIN"||o==="NetworkError"||o==="TimeoutError")return!0;const a=t;if(a.$metadata){const n=a.$metadata.httpStatusCode;if(n&&e.includes(n)||a.$fault==="server")return!0}if(a.statusCode&&e.includes(a.statusCode))return!0;const{retryable:u}=a;return u===!0||typeof u=="string"&&u==="true"}return!1},D=async(t,e={})=>{const{backoffMultiplier:r=l.backoffMultiplier,calculateDelay:o=l.calculateDelay,initialDelay:a=l.initialDelay,maxDelay:u=l.maxDelay,maxRetries:n=l.maxRetries,onRetry:y,retryableStatusCodes:d=l.retryableStatusCodes,shouldRetry:E=l.shouldRetry}=e;let f;for(let s=0;s<=n;s+=1)try{return await t()}catch(i){if(f=i,s>=n)break;if(!(E(i)||b(i,d)))throw i;const c=o?o(s,i):m(s,a,r,u);if(y)try{y(s+1,i)}catch{}c!==void 0&&c>0&&await R(c)}throw f},h=(t={})=>e=>D(e,t);export{h as createRetryWrapper,b as isRetryableError,D as retry};
@@ -0,0 +1 @@
1
+ import{PassThrough as l,Transform as y}from"node:stream";import{fileTypeFromBuffer as m}from"file-type";const F=async n=>{try{return await m(n)}catch{return}},g=async(n,d)=>{let i;const s=[];let f=0,r=!1,c;const o=new l({highWaterMark:0}),a=new y({flush(e){!r&&s.length>0&&(r=!0,c=m(Buffer.concat(s)).then(t=>(i=t,t)).catch(()=>{})),e()},objectMode:!1,transform(e,t,h){if(!r&&(s.push(e),f+=e.length,f>=4100)){r=!0;const p=Buffer.concat(s);c=m(p).then(u=>(i=u,u)).catch(()=>{})}h(void 0,e)}});return n.pipe(a).pipe(o),n.on("error",e=>{a.destroy(e),o.destroy(e)}),a.on("error",e=>{o.destroyed||o.destroy(e)}),await Promise.race([new Promise(e=>{if(r){e();return}const t=setTimeout(e,10);a.once("data",()=>{clearTimeout(t),e()}),a.once("end",()=>{clearTimeout(t),e()})}),new Promise(e=>{setTimeout(e,10)})]),c&&await Promise.race([c.then(()=>{}),new Promise(e=>{setTimeout(e,150)})]).catch(()=>{}),{fileType:i,stream:o}};export{F as a,g as d};
@@ -0,0 +1 @@
1
+ const n=e=>{const s=e?.key??process.env.AWS_ACCESS_KEY_ID??process.env.SPACES_KEY,r=e?.region??process.env.AWS_REGION??process.env.SPACES_REGION,c=e?.secret??process.env.AWS_SECRET_ACCESS_KEY??process.env.SPACES_SECRET;if(!r||!s||!c)throw new Error("Missing required parameters for DigitalOcean Spaces client.");return{credentials:{accessKeyId:s,secretAccessKey:c},endpoint:`https://${r}.digitaloceanspaces.com`,forcePathStyle:!1,region:"us-east-1"}};export{n as default};
@@ -0,0 +1 @@
1
+ import{createReadStream as _,createWriteStream as C}from"node:fs";import{truncate as P,stat as F,open as L,copyFile as A}from"node:fs/promises";import{PassThrough as W,Transform as x,pipeline as U}from"node:stream";import{y as D,d as I,z as B,l as M,V,x as Q,f as H}from"./local-meta-storage-C2T92TYb.js";import{A as G,m as K}from"./path-0oTTdkvl-BVg7lYf5.js";import{F as X}from"./index-nZWCQrSe.js";import{d as Y}from"./detect-file-type-BA7UBLKA.js";import{throwErrorCode as g,ERRORS as h,isUploadError as q}from"./ERRORS-BIBxE2oR.js";import{createHash as j}from"node:crypto";import{B as J,a as Z,c as $}from"./storage-Cyy73Y6r.js";import tt from"./File-W8aOo15X.js";import{t as k}from"./get-file-status-y3wTtDQs.js";import{t as et}from"./update-size-DuNuLyxj.js";import{i as rt}from"./part-match-D-9dGX42.js";import{e as it}from"./has-content-50BsqrWw.js";class st extends x{constructor(t,e,r="base64"){super(),this.checksum=t,this.algorithm=e,this.encoding=r,this.hash=j(e)}checksum;algorithm;encoding;length=0;digest="";hash;get calculatedDigest(){return this.digest}_transform(t,e,r){this.push(t),this.hash.update(t),this.length+=t.length,r()}_flush(t){this.digest=this.hash.digest(this.encoding),this.checksum&&this.checksum!==this.digest?t(new Error("Checksum mismatch")):t()}}const at=(S,t,e="base64")=>t?new st(S,t,e):new W;class nt extends x{constructor(t=Number.POSITIVE_INFINITY){super(),this.limit=t}limit;length=0;_transform(t,e,r){const a=this.length+t.length;this.limit>=a?(this.push(t),this.length=a,r()):r(new Error("Stream length limit exceeded"))}}class w extends J{static name="disk";checksumTypes=["md5","sha1"];supportsRange=!0;get raw(){return{directory:this.directory}}directory;meta;constructor(t){const e={...t,fileNameValidation:t.fileNameValidation??Z};if(super(e),this.directory=e.directory,e.metaStorage)this.meta=e.metaStorage;else{const r={...e,...e.metaStorageConfig,logger:this.logger};this.meta=new D(r)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(r=>{this.logger?.error("Storage access check failed: %O",r)})}normalizeError(t){return super.normalizeError(t)}async create(t){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const i=typeof t.ttl=="string"?$(t.ttl):t.ttl;i!==void 0&&(e.expiredAt=Date.now()+i)}e.size!==void 0&&Number(e.size)<0&&g(h.REQUEST_ENTITY_TOO_LARGE,"Request entity too large");const r=new tt(e);try{const i=await this.getMeta(r.id);if(i.status==="completed")return i}catch{}r.name=this.namingFunction(r),(r.size===void 0||Number.isNaN(r.size))&&(r.size===void 0||(r.size=this.maxUploadSize)),await this.validate(r);const a=this.getFilePath(r.name);try{await I(a),r.bytesWritten=0}catch(i){const s=this.normalizeError(i instanceof Error?i:new Error(String(i)));await this.onError(s),g(h.FILE_ERROR,s.message)}return r.status=k(r),await this.saveMeta(r),await this.onCreate(r),r})}async write(t){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&&et(e,t.size),!rt(t,e))return g(h.FILE_CONFLICT);const r=this.getFilePath(e.name),a=await this.lock(r);try{const i=t.start||0;if(await I(r),e.bytesWritten===0&&(e.bytesWritten=i),it(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return g(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:u,stream:d}=await Y(t.body);u?.mime&&(e.contentType=u.mime),t.body=d}catch{}const s=t.signal,o={...e,...t,body:t.body};s&&(o.signal=s);const[n,m]=await this.lazyWrite(o);if(m)return await P(r,e.bytesWritten),g(m);const l=i+(t.contentLength||0);e.bytesWritten=Math.max(e.bytesWritten||0,l),e.bytesWritten=Math.max(e.bytesWritten||0,n),e.status=k(e),await this.saveMeta(e)}else await I(r),e.bytesWritten=0;return e}catch(i){if(q(i))throw i;const s=this.normalizeError(i instanceof Error?i:new Error(String(i)));return await this.onError(s),g(h.FILE_ERROR,(typeof s.message=="string"?s.message:String(i))||String(i))}finally{await this.unlock(r,a)}})}async get({id:t},e){return this.instrumentOperation("get",async()=>{const r=await this.checkIfExpired(await this.meta.get(t)),{bytesWritten:a,contentType:i,expiredAt:s,metadata:o,modifiedAt:n,name:m,originalName:l,size:u}=r,d=this.getFilePath(m),E=e?.range,b=async c=>{const y=c;if(y.code==="ENOENT"||y.code==="EPERM"){const p=this.normalizeError(c instanceof Error?c:new Error(y.message||String(c)));return await this.onError(p),g(h.FILE_NOT_FOUND,(typeof p.message=="string"?p.message:String(c))||String(c))}const f=this.normalizeError(c instanceof Error?c:new Error(String(c)));throw await this.onError(f),c};if(E){let c;try{c=await F(d)}catch(R){return b(R)}const y=c.size,f=Math.max(0,E.start),p=E.end===void 0?y-1:Math.min(y-1,E.end);if(f>p||f>=y)return g(h.BAD_REQUEST,`Invalid range ${f}-${E.end??""}`);const N=p-f+1,z=Buffer.allocUnsafe(N);let O;try{O=await L(d,"r"),await O.read(z,0,N,f)}catch(R){return b(R)}finally{await O?.close()}const v=`W/"${y.toString(16)}-${Math.trunc(c.mtimeMs).toString(16)}-${f}-${p}"`;return{content:z,contentType:i,ETag:v,expiredAt:s,id:t,metadata:o,modifiedAt:n,name:m,originalName:l,size:N}}let T;try{T=await B(d,{buffer:!0})}catch(c){return b(c)}return{content:T,contentType:i,ETag:X(T),expiredAt:s,id:t,metadata:o,modifiedAt:n,name:m,originalName:l,size:u||a}})}async exists({id:t}){return this.instrumentOperation("exists",async()=>{try{const e=await this.getMeta(t),r=this.getFilePath(e.name);return await F(r),!0}catch{return!1}})}async getStream({id:t}){return this.instrumentOperation("getStream",async()=>{try{const e=await this.checkIfExpired(await this.meta.get(t)),{bytesWritten:r,contentType:a,expiredAt:i,modifiedAt:s,name:o,size:n}=e,m=_(this.getFilePath(o));return{headers:{"Content-Length":String(n||r),"Content-Type":a,...i&&{"X-Upload-Expires":i.toString()},...s&&{"Last-Modified":s.toString()}},size:n||r,stream:m}}catch(e){const r=this.normalizeError(e instanceof Error?e:new Error(String(e)));throw await this.onError(r),g(h.FILE_NOT_FOUND,(typeof r.message=="string"?r.message:String(e))||String(e))}})}async delete({id:t}){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);await M(this.getFilePath(e.name)),await this.deleteMeta(t);const r={...e,status:"deleted"};return await this.onDelete(r),r})}async copy(t,e){return this.instrumentOperation("copy",async()=>{w.assertSafeId(t),w.assertSafeId(e);const r=await this.getMeta(t);return await A(this.getFilePath(r.name),this.getFilePath(e)),{...r,name:e}})}async move(t,e){return this.instrumentOperation("move",async()=>{w.assertSafeId(t),w.assertSafeId(e);const r=await this.getMeta(t),a=this.getFilePath(r.name),i=this.getFilePath(e);try{await V(a,i)}catch(s){if(s?.code==="EXDEV")await A(a,i),await M(a);else{const o=this.normalizeError(s instanceof Error?s:new Error(String(s)));throw await this.onError(o),s}}return{...r,id:r.id,name:e}})}async list(){return this.instrumentOperation("list",async()=>{const t={followSymlinks:!1,includeDirs:!1,includeFiles:!0,skip:["*.META$"]},e=[],{directory:r}=this,a=s=>s.replaceAll("\\","/"),i=a(r);for await(const s of Q(r,t)){const{suffix:o}=this.meta,{path:n}=s;if(!n.includes(o)){const{birthtime:m,ctime:l,mtime:u}=await F(n),d=a(n),E=d.startsWith(i)?d.slice(i.length):d;e.push({createdAt:m||l,id:E,modifiedAt:u})}}return e})}getFilePath(t){return w.assertSafeId(t),G(t)&&g(h.INVALID_FILE_NAME,`Invalid file id: "${t}"`),K(this.directory,t)}lazyWrite(t){return new Promise((e,r)=>{const a=C(this.getFilePath(t.name),{flags:"r+",start:t.start}),i=new nt(t.contentLength||t.size-t.start),s=at(t.checksum,t.checksumAlgorithm),o=!t.checksum,{signal:n}=t,m=()=>{a.close(),i.destroy(),s.destroy()},l=d=>{m(),e([Number.NaN,d])};if(i.on("error",()=>{l(h.FILE_CONFLICT)}),s.on("error",()=>{l(h.CHECKSUM_MISMATCH)}),t.body.on("aborted",()=>{l(o?void 0:h.REQUEST_ABORTED)}),t.body.on("error",d=>{m(),r(d)}),n?.aborted){l(o?void 0:h.REQUEST_ABORTED);return}let u;n&&(u=()=>{m(),a.destroy(),i.destroy(),s.destroy(),t.body.destroy(),e([Number.NaN,o?void 0:h.REQUEST_ABORTED])},n.addEventListener("abort",u,{once:!0})),U(t.body,i,s,a,d=>{if(n&&u&&n.removeEventListener("abort",u),d){if(m(),n?.aborted){e([Number.NaN,o?void 0:h.REQUEST_ABORTED]);return}e([Number.NaN,h.FILE_ERROR]);return}e([t.start+a.bytesWritten])})})}async accessCheck(){await H(this.directory)}}export{w as F,nt as n,at as s};
@@ -0,0 +1,156 @@
1
+ import { F as File, M as MetaStorage, D as DiskStorageOptions, H as HttpError, d as FileInit, e as FilePart, f as FileQuery, O as OperationOptions, g as FileReturn, i as ERRORS, B as BaseStorage, j as DiskStorageWithChecksumOptions } from "./storage.d-CEM1upWM.js";
2
+ import { Readable } from 'node:stream';
3
+ /**
4
+ * Local disk-based storage implementation.
5
+ * @template TFile The file type used by this storage backend.
6
+ * @remarks
7
+ * ## Error Handling
8
+ * - Filesystem operations throw errors directly (no retry logic)
9
+ * - File not found errors are thrown immediately
10
+ * - Permission errors are propagated as-is
11
+ *
12
+ * ## Retry Behavior
13
+ * - No automatic retries (filesystem operations are typically immediate)
14
+ * - Errors are thrown directly for immediate feedback
15
+ *
16
+ * ## File Paths
17
+ * - Files are stored in the configured directory
18
+ * - Metadata files use the `.META` suffix by default
19
+ * - File paths are resolved relative to the storage directory
20
+ */
21
+ declare class DiskStorage<TFile extends File = File> extends BaseStorage<TFile> {
22
+ static override readonly name: string;
23
+ override checksumTypes: string[];
24
+ override readonly supportsRange: boolean;
25
+ override get raw(): {
26
+ directory: string;
27
+ };
28
+ directory: string;
29
+ meta: MetaStorage<TFile>;
30
+ constructor(config: DiskStorageOptions<TFile>);
31
+ /**
32
+ * Normalizes errors with disk storage context.
33
+ * @param error The error to normalize.
34
+ * @returns Normalized HTTP error.
35
+ */
36
+ override normalizeError(error: Error): HttpError;
37
+ /**
38
+ * Creates a new file upload and saves its metadata.
39
+ * @param fileInit File initialization configuration.
40
+ * @returns Promise resolving to the created file object.
41
+ * @throws {Error} If validation fails or file already exists and is completed.
42
+ * @remarks
43
+ * Supports TTL (time-to-live) option in fileInit.
44
+ * Creates the file on disk if it doesn't exist.
45
+ * Returns existing file if it's already completed.
46
+ */
47
+ create(fileInit: FileInit): Promise<TFile>;
48
+ /**
49
+ * Writes data to a file upload.
50
+ * @param part File part containing data to write, file query, or full file object.
51
+ * @returns Promise resolving to the updated file object.
52
+ * @throws {Error} If file is expired (ERRORS.GONE), locked (ERRORS.FILE_LOCKED), or conflicts occur (ERRORS.FILE_CONFLICT).
53
+ * @remarks
54
+ * Supports chunked uploads with start position.
55
+ * Automatically detects file type from stream on first chunk if contentType is not set.
56
+ * Validates checksum algorithms if provided.
57
+ * Uses file locking to prevent concurrent writes.
58
+ * Updates file status to "completed" when all bytes are written.
59
+ */
60
+ write(part: FilePart | FileQuery | TFile): Promise<TFile>;
61
+ /**
62
+ * Gets an uploaded file by ID.
63
+ * @param query File query containing the file ID to retrieve.
64
+ * @param query.id File ID to retrieve.
65
+ * @returns Promise resolving to the file data including content buffer.
66
+ * @throws {Error} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
67
+ * @remarks
68
+ * Loads the entire file content into memory as a Buffer.
69
+ * For large files, consider using getStream() instead.
70
+ * Includes ETag (MD5 hash) for content verification.
71
+ */
72
+ get({
73
+ id
74
+ }: FileQuery, options?: OperationOptions & {
75
+ range?: {
76
+ end?: number;
77
+ start: number;
78
+ };
79
+ }): Promise<FileReturn>;
80
+ /**
81
+ * Checks if a file exists by verifying both metadata and the actual filesystem file.
82
+ * Returns true only if both the metadata and the file exist.
83
+ * @param query File query containing the file ID to check.
84
+ * @returns Promise resolving to true if both metadata and file exist, false otherwise.
85
+ */
86
+ override exists({
87
+ id
88
+ }: FileQuery): Promise<boolean>;
89
+ /**
90
+ * Gets an uploaded file as a readable stream for efficient large file handling.
91
+ * @param query File query containing the file ID to stream.
92
+ * @param query.id File ID to stream.
93
+ * @returns Promise resolving to an object containing the stream, headers, and size.
94
+ * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
95
+ * @remarks Creates a readable stream directly from the file system for efficient memory usage.
96
+ */
97
+ override getStream({
98
+ id
99
+ }: FileQuery): Promise<{
100
+ headers?: Record<string, string>;
101
+ size?: number;
102
+ stream: Readable;
103
+ }>;
104
+ /**
105
+ * Deletes an upload and its metadata.
106
+ * @param query File query containing the file ID to delete.
107
+ * @param query.id File ID to delete.
108
+ * @returns Promise resolving to the deleted file object with status: "deleted".
109
+ * @throws {UploadError} If the file metadata cannot be found.
110
+ */
111
+ delete({
112
+ id
113
+ }: FileQuery): Promise<TFile>;
114
+ /**
115
+ * Copies an upload file to a new location.
116
+ * @param name Source file name/ID.
117
+ * @param destination Destination file name/ID.
118
+ * @returns Promise resolving to the copied file object.
119
+ * @throws {UploadError} If the source file cannot be found.
120
+ */
121
+ copy(name: string, destination: string): Promise<TFile>;
122
+ /**
123
+ * Moves an upload file to a new location.
124
+ * @param name Source file name/ID.
125
+ * @param destination Destination file name/ID.
126
+ * @returns Promise resolving to the moved file object.
127
+ * @throws {Error} If the source file cannot be found.
128
+ */
129
+ move(name: string, destination: string): Promise<TFile>;
130
+ /**
131
+ * Retrieves a list of uploaded files.
132
+ * @returns Promise resolving to an array of file metadata objects.
133
+ * @remarks Walks the storage directory and returns all files, excluding metadata files.
134
+ */
135
+ override list(): Promise<TFile[]>;
136
+ /**
137
+ * Returns the absolute on-disk path for the uploaded file, always rooted at
138
+ * `this.directory`. Absolute inputs and `..` traversals are rejected.
139
+ */
140
+ protected getFilePath(filename: string): string;
141
+ protected lazyWrite(part: File & FilePart): Promise<[number, ERRORS?]>;
142
+ private accessCheck;
143
+ }
144
+ /**
145
+ * Additionally calculates checksum of the file/range.
146
+ */
147
+ declare class DiskStorageWithChecksum<TFile extends File = File> extends DiskStorage<TFile> {
148
+ private hashes;
149
+ constructor(config: DiskStorageWithChecksumOptions<TFile>);
150
+ override delete({
151
+ id
152
+ }: FileQuery): Promise<TFile>;
153
+ override write(part: FilePart | FileQuery): Promise<TFile>;
154
+ protected override lazyWrite(part: File & FilePart): Promise<[number, ERRORS?]>;
155
+ }
156
+ export { DiskStorage as D, DiskStorageWithChecksum as a };
@@ -0,0 +1 @@
1
+ import*as e from"zod";const p=1024*1024,l=10*1024*1024,y=e.object({limit:e.int().positive().max(1e3).optional().meta({description:"Maximum number of items to return"}),prefix:e.string().trim().optional().meta({description:"Only return keys that start with this prefix"})}),m=e.object({key:e.string().trim().meta({description:"The object key to inspect"})}),u=e.object({binary:e.boolean().optional().meta({description:"When true, returns base64-encoded bytes instead of UTF-8 text"}),key:e.string().trim().meta({description:"The object key to download"}),maxBytes:e.int().positive().max(l).optional().meta({description:`Reject downloads larger than this byte count (default ${p}, maximum ${l}). Verified via head() before transferring.`})}),f=e.object({expiresIn:e.int().positive().optional().meta({description:"Override the adapter default URL expiry in seconds. Ignored by permanent-CDN adapters."}),key:e.string().trim().meta({description:"The object key to build a URL for"}),responseContentDisposition:e.string().trim().optional().meta({description:`Force a Content-Disposition header on the response (e.g. 'attachment; filename="f.txt"'). Strongly recommended for user-uploaded content to prevent inline rendering of HTML/SVG.`})}),g=e.object({content:e.string().meta({description:'File body. Treated as UTF-8 text unless encoding is "base64".'}),contentType:e.string().trim().optional().meta({description:"MIME type recorded with the object"}),encoding:e.enum(["text","base64"]).optional().meta({description:"How to interpret content (default: text)"}),key:e.string().trim().meta({description:"Destination object key"}),metadata:e.record(e.string().trim(),e.string()).optional().meta({description:"Custom string metadata to attach to the object"})}),b=e.object({key:e.string().trim().meta({description:"Object key to delete"})}),h=e.object({from:e.string().trim().meta({description:"Source object key"}),to:e.string().trim().meta({description:"Destination object key"})}),k=e.object({contentType:e.string().trim().optional().meta({description:"Content-Type that the upload must declare"}),expiresIn:e.int().positive().meta({description:"Lifetime of the presigned URL in seconds"}),key:e.string().trim().meta({description:"Destination object key"})}),F={copyFile:{description:"Copy a file to a new key within the configured bucket. The source remains intact.",input:h},deleteFile:{description:"Permanently delete a file from the configured bucket.",input:b},downloadFile:{description:"Download a file and return its contents. Returns UTF-8 text by default; set binary=true to receive base64-encoded bytes. Files larger than maxBytes are rejected before transfer.",input:u},getFileMetadata:{description:"Fetch metadata for a single file (size, content type, etag, custom metadata) without transferring its body.",input:m},getFileUrl:{description:"Return a signed, time-limited URL the caller can use to fetch a file. Adapters that don't support presigning will throw MethodNotAllowed.",input:f},listFiles:{description:"List files in the configured bucket, optionally filtered by key prefix.",input:y},signUploadUrl:{description:"Issue a presigned URL that lets a client upload directly to the configured bucket. Approval-gated by default — the URL grants upload permission until it expires.",input:k},uploadFile:{description:'Upload a file to the configured bucket. Pass content as UTF-8 text by default, or as base64 with encoding="base64" for binary payloads.',input:g}},w=["uploadFile","deleteFile","copyFile","signUploadUrl"],x=new Set(w),d=i=>{if(i!==void 0)return i instanceof Date?i.toISOString():typeof i=="number"?new Date(i).toISOString():i},T={copyFile:async(i,{from:o,to:t})=>{const n=await i.copy(o,t);return{copied:!0,etag:n.etag,from:o,key:n.key,to:t}},deleteFile:async(i,{key:o})=>(await i.delete(o),{deleted:!0,key:o}),downloadFile:async(i,{binary:o,key:t,maxBytes:n})=>{const r=n??p;if(r>l)throw new RangeError(`downloadFile refused: maxBytes (${r}) exceeds the maximum of ${l}. Use getFileUrl to delegate larger downloads to the client.`);const c=await i.head(t);if(typeof c.size=="number"&&c.size>r)throw new RangeError(`downloadFile refused: "${t}" is ${c.size} bytes which exceeds the maxBytes limit of ${r}. Use getFileUrl to delegate to the client, or raise maxBytes.`);const a=await i.download(t);if(a.body.byteLength>r)throw new RangeError(`downloadFile refused: "${t}" returned ${a.body.byteLength} bytes which exceeds the maxBytes limit of ${r}. Use getFileUrl instead.`);return o?{content:a.body.toString("base64"),contentType:a.contentType,encoding:"base64",key:a.key,...typeof a.size=="number"?{size:a.size}:{}}:{content:a.body.toString("utf8"),contentType:a.contentType,encoding:"text",key:a.key,...typeof a.size=="number"?{size:a.size}:{}}},getFileMetadata:async(i,{key:o})=>{const t=await i.head(o);return{contentType:t.contentType,...t.etag?{etag:t.etag}:{},key:t.key,...d(t.lastModified)?{lastModified:d(t.lastModified)}:{},...t.metadata?{metadata:t.metadata}:{},...typeof t.size=="number"?{size:t.size}:{}}},getFileUrl:async(i,{expiresIn:o,key:t,responseContentDisposition:n})=>{const r=await i.url(t,{expiresIn:o,responseContentDisposition:n});return{key:t,url:r}},listFiles:async(i,{limit:o,prefix:t})=>({items:(await i.list({limit:o,prefix:t})).map(n=>({contentType:n.contentType,...n.etag?{etag:n.etag}:{},key:n.key,...d(n.lastModified)?{lastModified:d(n.lastModified)}:{},...typeof n.size=="number"?{size:n.size}:{}}))}),signUploadUrl:async(i,{contentType:o,expiresIn:t,key:n})=>{const r=await i.signedUploadUrl(n,{contentType:o,expiresIn:t});return{key:n,url:r}},uploadFile:async(i,{content:o,contentType:t,encoding:n,key:r,metadata:c})=>{const a=n==="base64"?Buffer.from(o,"base64"):Buffer.from(o,"utf8"),s=await i.upload(r,a,{contentType:t,metadata:c});return{contentType:s.contentType,...s.etag?{etag:s.etag}:{},key:s.key,...d(s.lastModified)?{lastModified:d(s.lastModified)}:{},...typeof s.size=="number"?{size:s.size}:{}}}};export{F as T,x as W,T as e};
@@ -0,0 +1,69 @@
1
+ import { F as Files } from "./files.d-CH0iLBNC.js";
2
+ import 'node:stream';
3
+ import 'node:crypto';
4
+ import 'node:http';
5
+ import 'lru-cache';
6
+ import { C as CopyFileInput, D as DeleteFileInput, a as DownloadFileInput, G as GetFileMetadataInput, b as GetFileUrlInput, L as ListFilesInput, S as SignUploadUrlInput, U as UploadFileInput } from "./approval.d-CMAYH9GF.js";
7
+ interface CopyFileResult {
8
+ copied: true;
9
+ etag: string | undefined;
10
+ from: string;
11
+ key: string;
12
+ to: string;
13
+ }
14
+ interface DeleteFileResult {
15
+ deleted: true;
16
+ key: string;
17
+ }
18
+ interface DownloadFileResult {
19
+ content: string;
20
+ contentType: string | undefined;
21
+ encoding: "base64" | "text";
22
+ key: string;
23
+ size?: number;
24
+ }
25
+ interface FileMetadataResult {
26
+ contentType: string | undefined;
27
+ etag?: string;
28
+ key: string;
29
+ lastModified?: string;
30
+ metadata?: Record<string, unknown>;
31
+ size?: number;
32
+ }
33
+ interface FileUrlResult {
34
+ key: string;
35
+ url: string;
36
+ }
37
+ interface ListFilesItem {
38
+ contentType: string | undefined;
39
+ etag?: string;
40
+ key: string;
41
+ lastModified?: string;
42
+ size?: number;
43
+ }
44
+ interface ListFilesResult {
45
+ items: ListFilesItem[];
46
+ }
47
+ interface SignUploadUrlResult {
48
+ key: string;
49
+ url: string;
50
+ }
51
+ interface UploadFileResult {
52
+ contentType: string | undefined;
53
+ etag?: string;
54
+ key: string;
55
+ lastModified?: string;
56
+ size?: number;
57
+ }
58
+ interface Executors {
59
+ copyFile: (files: Files, input: CopyFileInput) => Promise<CopyFileResult>;
60
+ deleteFile: (files: Files, input: DeleteFileInput) => Promise<DeleteFileResult>;
61
+ downloadFile: (files: Files, input: DownloadFileInput) => Promise<DownloadFileResult>;
62
+ getFileMetadata: (files: Files, input: GetFileMetadataInput) => Promise<FileMetadataResult>;
63
+ getFileUrl: (files: Files, input: GetFileUrlInput) => Promise<FileUrlResult>;
64
+ listFiles: (files: Files, input: ListFilesInput) => Promise<ListFilesResult>;
65
+ signUploadUrl: (files: Files, input: SignUploadUrlInput) => Promise<SignUploadUrlResult>;
66
+ uploadFile: (files: Files, input: UploadFileInput) => Promise<UploadFileResult>;
67
+ }
68
+ declare const executors: Executors;
69
+ export { executors as e };
@@ -0,0 +1 @@
1
+ const c=e=>{const E=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.EXOSCALE_ACCESS_KEY_ID??process.env.EXOSCALE_ACCESS_KEY,r=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.EXOSCALE_SECRET_ACCESS_KEY??process.env.EXOSCALE_SECRET_KEY,s=e?.zone??process.env.EXOSCALE_ZONE;if(!s||!E||!r)throw new Error("Missing required parameters for Exoscale SOS client.");return{credentials:{accessKeyId:E,secretAccessKey:r},endpoint:`https://sos-${s}.exo.io`,forcePathStyle:!1,region:s}};export{c as default};
@@ -0,0 +1 @@
1
+ const c=e=>{const s=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.FILEBASE_ACCESS_KEY_ID??process.env.FILEBASE_ACCESS_KEY,r=e?.endpoint??process.env.FILEBASE_ENDPOINT,E=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.FILEBASE_SECRET_ACCESS_KEY??process.env.FILEBASE_SECRET_KEY;if(!s||!E)throw new Error("Missing required parameters for Filebase client.");return{credentials:{accessKeyId:s,secretAccessKey:E},endpoint:r??"https://s3.filebase.com",forcePathStyle:!0,region:"us-east-1"}};export{c as default};