@visulima/storage 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (417) hide show
  1. package/CHANGELOG.md +361 -0
  2. package/LICENSE.md +213 -573
  3. package/README.md +83 -470
  4. package/dist/adapter/nuxt/module.d.ts +41 -34
  5. package/dist/adapter/nuxt/module.js +1 -93
  6. package/dist/adapter/nuxt/node_modules/.bin/nuxi +22 -0
  7. package/dist/adapter/nuxt/node_modules/.bin/nuxt +22 -0
  8. package/dist/adapter/nuxt/package.json +0 -6
  9. package/dist/ai/ai-sdk/index.d.ts +113 -0
  10. package/dist/ai/ai-sdk/index.js +1 -0
  11. package/dist/ai/claude/index.d.ts +177 -0
  12. package/dist/ai/claude/index.js +1 -0
  13. package/dist/ai/openai/index.d.ts +205 -0
  14. package/dist/ai/openai/index.js +1 -0
  15. package/dist/ai/tanstack/index.d.ts +115 -0
  16. package/dist/ai/tanstack/index.js +1 -0
  17. package/dist/handler/http/fetch/index.d.ts +303 -4
  18. package/dist/handler/http/fetch/index.js +1 -4
  19. package/dist/handler/http/hono/index.d.ts +73 -64
  20. package/dist/handler/http/hono/index.js +1 -65
  21. package/dist/handler/http/nextjs/index.d.ts +66 -58
  22. package/dist/handler/http/nextjs/index.js +1 -37
  23. package/dist/handler/http/node/index.d.ts +361 -4
  24. package/dist/handler/http/node/index.js +1 -4
  25. package/dist/handler/http/solid-start/index.d.ts +66 -57
  26. package/dist/handler/http/solid-start/index.js +1 -44
  27. package/dist/index.d.ts +58 -17
  28. package/dist/index.js +1 -13
  29. package/dist/openapi/index.d.ts +24 -5
  30. package/dist/openapi/index.js +1 -5
  31. package/dist/packem_shared/AwsLightFile-BSqjc_rD.js +1 -0
  32. package/dist/packem_shared/AwsLightMetaStorage-B-iQbToR.js +1 -0
  33. package/dist/packem_shared/AwsLightStorage-w21RxjUm.js +1 -0
  34. package/dist/packem_shared/AzureFile-Dgj2Tef4.js +1 -0
  35. package/dist/packem_shared/AzureSMetaStorage-CR-lfQNQ.js +1 -0
  36. package/dist/packem_shared/AzureStorage-2kl7JDXs.js +1 -0
  37. package/dist/packem_shared/BaseTransformer-Fpcuz4kj.js +1 -0
  38. package/dist/packem_shared/BoxFile-Be0S4N1L.js +1 -0
  39. package/dist/packem_shared/BoxMetaStorage-DLdXbZaV.js +1 -0
  40. package/dist/packem_shared/BoxStorage-BUeEJoGL.js +1 -0
  41. package/dist/packem_shared/BunS3File-D-SRiyrm.js +1 -0
  42. package/dist/packem_shared/BunS3MetaStorage-Bv_CTTMz.js +1 -0
  43. package/dist/packem_shared/BunS3Storage-WM3rF6Fw.js +1 -0
  44. package/dist/packem_shared/BunnyFile-Dotl-lO9.js +1 -0
  45. package/dist/packem_shared/BunnyMetaStorage-DNMTSeoN.js +1 -0
  46. package/dist/packem_shared/BunnyStorage-D3s2fRB3.js +1 -0
  47. package/dist/packem_shared/CloudinaryFile-B5-m33eS.js +1 -0
  48. package/dist/packem_shared/CloudinaryMetaStorage-DEBk5eQy.js +1 -0
  49. package/dist/packem_shared/CloudinaryStorage-BBE2-aVz.js +1 -0
  50. package/dist/packem_shared/DiskStorage-DL0GiG6k.js +1 -0
  51. package/dist/packem_shared/DiskStorageWithChecksum-BvUTn7O-.js +1 -0
  52. package/dist/packem_shared/DropboxFile-BGVG2kXM.js +1 -0
  53. package/dist/packem_shared/DropboxMetaStorage-C6vj1QDA.js +1 -0
  54. package/dist/packem_shared/DropboxStorage-BL3OIdE_.js +1 -0
  55. package/dist/packem_shared/ERRORS-CyOuSMLY.js +1 -0
  56. package/dist/packem_shared/File-BhfUgJjs.js +1 -0
  57. package/dist/packem_shared/Files-CJh9_N-9.js +1 -0
  58. package/dist/packem_shared/FirebaseFile-JEu3plMP.js +1 -0
  59. package/dist/packem_shared/FirebaseMetaStorage-CzyOim-J.js +1 -0
  60. package/dist/packem_shared/FirebaseStorage-lXMXy3Pm.js +2 -0
  61. package/dist/packem_shared/FtpFile-B8jaICTB.js +1 -0
  62. package/dist/packem_shared/FtpMetaStorage-1Njy0DpU.js +1 -0
  63. package/dist/packem_shared/FtpStorage-Dw94efNW.js +1 -0
  64. package/dist/packem_shared/GCSConfig-BQ0OpVhe.js +1 -0
  65. package/dist/packem_shared/GCSFile-CDQ6IWAz.js +1 -0
  66. package/dist/packem_shared/GCSMetaStorage-udgXA5ia.js +1 -0
  67. package/dist/packem_shared/GCStorage-ChY6uJuO.js +1 -0
  68. package/dist/packem_shared/GoogleDriveFile-D0aGfGbL.js +1 -0
  69. package/dist/packem_shared/GoogleDriveMetaStorage-WGuUZPyx.js +1 -0
  70. package/dist/packem_shared/GoogleDriveStorage-C0NhBBWH.js +1 -0
  71. package/dist/packem_shared/LocalMetaStorage-QMKL7McF.js +1 -0
  72. package/dist/packem_shared/MediaTransformer-D-1c9Q_k.js +1 -0
  73. package/dist/packem_shared/MetaStorage-Y4m1dWgd.js +1 -0
  74. package/dist/packem_shared/Metadata-B6Ir0KO7.js +1 -0
  75. package/dist/packem_shared/Multipart-CIFfQksD.js +1 -0
  76. package/dist/packem_shared/Multipart-D9WIud9R.js +1 -0
  77. package/dist/packem_shared/NetlifyBlobFile-PMZLJ8AC.js +1 -0
  78. package/dist/packem_shared/NetlifyBlobMetaStorage-ClIFdTkT.js +1 -0
  79. package/dist/packem_shared/NetlifyBlobStorage-CO89TGvF.js +1 -0
  80. package/dist/packem_shared/NoOpMetrics-Dky06sf1.js +1 -0
  81. package/dist/packem_shared/OneDriveFile-XbVVKIJh.js +1 -0
  82. package/dist/packem_shared/OneDriveMetaStorage-DS4f83X2.js +1 -0
  83. package/dist/packem_shared/OneDriveStorage-jAN46vRm.js +1 -0
  84. package/dist/packem_shared/OpenTelemetryMetrics-9uxQMSlg.js +1 -0
  85. package/dist/packem_shared/PocketBaseFile-CkAiSBb0.js +1 -0
  86. package/dist/packem_shared/PocketBaseMetaStorage-B6utPncj.js +1 -0
  87. package/dist/packem_shared/PocketBaseStorage-DpOjOKAt.js +1 -0
  88. package/dist/packem_shared/Rest-BuD3ySAg.js +1 -0
  89. package/dist/packem_shared/Rest-URrQ5FYM.js +1 -0
  90. package/dist/packem_shared/S3File-BfmCOET4.js +1 -0
  91. package/dist/packem_shared/S3MetaStorage-vcriiosn.js +1 -0
  92. package/dist/packem_shared/S3Storage-n1ohEZj4.js +1 -0
  93. package/dist/packem_shared/SftpFile-CQCxZNVq.js +1 -0
  94. package/dist/packem_shared/SftpMetaStorage-DYqXwCdM.js +1 -0
  95. package/dist/packem_shared/SftpStorage-Ban-WN8v.js +1 -0
  96. package/dist/packem_shared/SharePointFile-BA6X9Sxr.js +1 -0
  97. package/dist/packem_shared/SharePointMetaStorage-DVM5-X6g.js +1 -0
  98. package/dist/packem_shared/SharePointStorage-BY90zh1c.js +1 -0
  99. package/dist/packem_shared/SupabaseFile-DZ1iv9gM.js +1 -0
  100. package/dist/packem_shared/SupabaseMetaStorage-ivXoYVUu.js +1 -0
  101. package/dist/packem_shared/SupabaseStorage-pNbHAE1Y.js +1 -0
  102. package/dist/packem_shared/TUS_RESUMABLE-B7KtPVeC.js +1 -0
  103. package/dist/packem_shared/Tus-Fp_hx5ug.js +1 -0
  104. package/dist/packem_shared/Tus-TNG9HAY8.js +1 -0
  105. package/dist/packem_shared/UploadThingFile-BpG9mE8K.js +1 -0
  106. package/dist/packem_shared/UploadThingMetaStorage-BvKNzgm7.js +1 -0
  107. package/dist/packem_shared/UploadThingStorage-BcmIE2dI.js +1 -0
  108. package/dist/packem_shared/ValidationError-D8KKJiKA.js +1 -0
  109. package/dist/packem_shared/VercelBlobFile-Cni_1qwD.js +1 -0
  110. package/dist/packem_shared/VercelBlobMetaStorage-CwaqWucZ.js +1 -0
  111. package/dist/packem_shared/VercelBlobStorage-s260zfFo.js +1 -0
  112. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
  113. package/dist/packem_shared/agentsListFiles-R-CnGKc4.js +1 -0
  114. package/dist/packem_shared/akamai-BYS9pP8S.js +1 -0
  115. package/dist/packem_shared/alibaba-BJQ6ijoK.js +1 -0
  116. package/dist/packem_shared/approval-BBeX3o4E.js +1 -0
  117. package/dist/packem_shared/approval.d-CMAYH9GF.d.ts +75 -0
  118. package/dist/packem_shared/aws-light-meta-storage-CstQBYXG.js +4 -0
  119. package/dist/packem_shared/azure-meta-storage-C4SrMtT2.js +1 -0
  120. package/dist/packem_shared/backblaze-CvdtCvJL.js +1 -0
  121. package/dist/packem_shared/base-handler-core-BYDQditz.js +1 -0
  122. package/dist/packem_shared/base-handler-fetch-DWzsPkmV.js +1 -0
  123. package/dist/packem_shared/base-handler-node-Dety2rQB.js +1 -0
  124. package/dist/packem_shared/cache-qV_5Umeq.js +1 -0
  125. package/dist/packem_shared/claudeListFiles-DAezbKEi.js +1 -0
  126. package/dist/packem_shared/cloudflare-Bm_Pg6yx.js +1 -0
  127. package/dist/packem_shared/createResponsesFileTools-BCep-qdO.js +1 -0
  128. package/dist/packem_shared/defaultCloudStorageFileNameValidation-shIZX_7L.js +1 -0
  129. package/dist/packem_shared/detect-file-type-5JhzC9RU.js +1 -0
  130. package/dist/packem_shared/digitalOcean-Lj1NfDzc.js +1 -0
  131. package/dist/packem_shared/disk-storage-CKAJvhcj.js +1 -0
  132. package/dist/packem_shared/disk-storage-with-checksum.d-mHcg2uLw.d.ts +150 -0
  133. package/dist/packem_shared/executors-DG6hGtvm.js +1 -0
  134. package/dist/packem_shared/executors.d-X4hz3zfu.d.ts +65 -0
  135. package/dist/packem_shared/exoscale-O0HzxoDz.js +1 -0
  136. package/dist/packem_shared/filebase-D-urO4Ob.js +1 -0
  137. package/dist/packem_shared/gcs-meta-storage-mZiqlX-9.js +1 -0
  138. package/dist/packem_shared/has-content-Bx2p8Okx.js +1 -0
  139. package/dist/packem_shared/headers-DC2MEOrK.js +27 -0
  140. package/dist/packem_shared/hetzner-DDxE7Gy7.js +1 -0
  141. package/dist/packem_shared/ibmCos-Rx_yku4H.js +1 -0
  142. package/dist/packem_shared/idriveE2-BFhw0Vwy.js +1 -0
  143. package/dist/packem_shared/index-B4ETk0Lu.js +5 -0
  144. package/dist/packem_shared/index.d-C4Fivh4I.d.ts +94 -0
  145. package/dist/packem_shared/is-expired-1JuZjDtb.js +1 -0
  146. package/dist/packem_shared/isRetryableError-BhizNeAz.js +1 -0
  147. package/dist/packem_shared/isValidMediaType-B-2UKjZx.js +1 -0
  148. package/dist/packem_shared/listFiles-B6VF05d-.js +1 -0
  149. package/dist/packem_shared/listFiles-BtP6VnUp.js +1 -0
  150. package/dist/packem_shared/local-meta-storage-Bi0mK6gD.js +1 -0
  151. package/dist/packem_shared/local-meta-storage.d-B11vHYNm.d.ts +21 -0
  152. package/dist/packem_shared/media-transformer.d-C3QvECD7.d.ts +331 -0
  153. package/dist/packem_shared/minio-T_Z3iEy7.js +1 -0
  154. package/dist/packem_shared/multipart-base-BxckfvQf.js +1 -0
  155. package/dist/packem_shared/oauth-refresh-Dg2ybc6_.js +1 -0
  156. package/dist/packem_shared/oracleCloud-D5T9s4JV.js +1 -0
  157. package/dist/packem_shared/ovhCloud-DCwef2fe.js +1 -0
  158. package/dist/packem_shared/part-match-B5fLLmFw.js +1 -0
  159. package/dist/packem_shared/path-D7rMc9nq-B718mbm6.js +1 -0
  160. package/dist/packem_shared/posix-dirname-CiHXPPnw.js +1 -0
  161. package/dist/packem_shared/response-builder-Wdo_fvcF.js +1 -0
  162. package/dist/packem_shared/rest-base-DI7xFXr5.js +1 -0
  163. package/dist/packem_shared/restOpenApiSpec-PaIVbESh.js +1 -0
  164. package/dist/packem_shared/s3-base-storage-Dbexfg7p.js +1 -0
  165. package/dist/packem_shared/s3-base-storage.d-V3N2nKCt.d.ts +260 -0
  166. package/dist/packem_shared/scaleway-ygRXOss9.js +1 -0
  167. package/dist/packem_shared/sharedGet-Ce7WGAsc.js +1 -0
  168. package/dist/packem_shared/storage-Dh0tJh7j.js +1 -0
  169. package/dist/packem_shared/storage.d-RteRC-cG.d.ts +1106 -0
  170. package/dist/packem_shared/storj-CVA9mM-7.js +1 -0
  171. package/dist/packem_shared/tencent-CAcAGaIW.js +1 -0
  172. package/dist/packem_shared/tigris-wmhjfsH2.js +1 -0
  173. package/dist/packem_shared/transformOpenApiSpec-C0vEbDTO.js +1 -0
  174. package/dist/packem_shared/tus-base.d-CygntIPM.d.ts +99 -0
  175. package/dist/packem_shared/tusOpenApiSpec-DF0-hlWV.js +1 -0
  176. package/dist/packem_shared/types.d-ChNXbbHG.d.ts +104 -0
  177. package/dist/packem_shared/types.d-DxonY4XS.d.ts +720 -0
  178. package/dist/packem_shared/types.d-cI_cMxcZ.d.ts +49 -0
  179. package/dist/packem_shared/update-size-DANV7aa2.js +1 -0
  180. package/dist/packem_shared/vultr-lK9L-sFk.js +1 -0
  181. package/dist/packem_shared/waitForStorage-ChSBLhLc.js +1 -0
  182. package/dist/packem_shared/wasabi-JQzxdrFy.js +1 -0
  183. package/dist/packem_shared/xhrOpenApiSpec-nyoboz83.js +1 -0
  184. package/dist/packem_shared/yandex-ZwvE77v4.js +1 -0
  185. package/dist/storage/aws/clients/index.d.ts +612 -6
  186. package/dist/storage/aws/clients/index.js +1 -6
  187. package/dist/storage/aws/index.d.ts +321 -4
  188. package/dist/storage/aws/index.js +1 -3
  189. package/dist/storage/aws-light/index.d.ts +254 -4
  190. package/dist/storage/aws-light/index.js +1 -3
  191. package/dist/storage/azure/index.d.ts +217 -4
  192. package/dist/storage/azure/index.js +1 -3
  193. package/dist/storage/box/index.d.ts +189 -0
  194. package/dist/storage/box/index.js +1 -0
  195. package/dist/storage/bun-s3/index.d.ts +200 -0
  196. package/dist/storage/bun-s3/index.js +1 -0
  197. package/dist/storage/bunny/index.d.ts +119 -0
  198. package/dist/storage/bunny/index.js +1 -0
  199. package/dist/storage/cloudinary/index.d.ts +121 -0
  200. package/dist/storage/cloudinary/index.js +1 -0
  201. package/dist/storage/dropbox/index.d.ts +132 -0
  202. package/dist/storage/dropbox/index.js +1 -0
  203. package/dist/storage/firebase/index.d.ts +192 -0
  204. package/dist/storage/firebase/index.js +1 -0
  205. package/dist/storage/ftp/index.d.ts +85 -0
  206. package/dist/storage/ftp/index.js +1 -0
  207. package/dist/storage/gcs/index.d.ts +181 -5
  208. package/dist/storage/gcs/index.js +1 -4
  209. package/dist/storage/google-drive/index.d.ts +148 -0
  210. package/dist/storage/google-drive/index.js +1 -0
  211. package/dist/storage/local/index.d.ts +7 -4
  212. package/dist/storage/local/index.js +1 -3
  213. package/dist/storage/netlify-blob/index.d.ts +147 -4
  214. package/dist/storage/netlify-blob/index.js +1 -3
  215. package/dist/storage/onedrive/index.d.ts +103 -0
  216. package/dist/storage/onedrive/index.js +1 -0
  217. package/dist/storage/pocketbase/index.d.ts +172 -0
  218. package/dist/storage/pocketbase/index.js +1 -0
  219. package/dist/storage/sftp/index.d.ts +86 -0
  220. package/dist/storage/sftp/index.js +1 -0
  221. package/dist/storage/sharepoint/index.d.ts +180 -0
  222. package/dist/storage/sharepoint/index.js +1 -0
  223. package/dist/storage/supabase/index.d.ts +115 -0
  224. package/dist/storage/supabase/index.js +1 -0
  225. package/dist/storage/uploadthing/index.d.ts +95 -0
  226. package/dist/storage/uploadthing/index.js +1 -0
  227. package/dist/storage/vercel-blob/index.d.ts +189 -4
  228. package/dist/storage/vercel-blob/index.js +1 -3
  229. package/dist/transformer/audio-transformer.d.ts +127 -125
  230. package/dist/transformer/audio-transformer.js +1 -278
  231. package/dist/transformer/image-transformer.d.ts +573 -568
  232. package/dist/transformer/image-transformer.js +1 -1100
  233. package/dist/transformer/index.d.ts +62 -5
  234. package/dist/transformer/index.js +1 -4
  235. package/dist/transformer/video-transformer.d.ts +144 -142
  236. package/dist/transformer/video-transformer.js +1 -310
  237. package/package.json +195 -47
  238. package/dist/handler/base/base-handler-core.d.ts +0 -91
  239. package/dist/handler/base/base-handler-fetch.d.ts +0 -76
  240. package/dist/handler/base/base-handler-node.d.ts +0 -137
  241. package/dist/handler/multipart/multipart-base.d.ts +0 -84
  242. package/dist/handler/multipart/multipart-fetch.d.ts +0 -64
  243. package/dist/handler/multipart/multipart.d.ts +0 -49
  244. package/dist/handler/rest/rest-base.d.ts +0 -106
  245. package/dist/handler/rest/rest-fetch.d.ts +0 -88
  246. package/dist/handler/rest/rest.d.ts +0 -93
  247. package/dist/handler/tus/tus-base.d.ts +0 -152
  248. package/dist/handler/tus/tus-fetch.d.ts +0 -72
  249. package/dist/handler/tus/tus.d.ts +0 -78
  250. package/dist/handler/types.d.ts +0 -53
  251. package/dist/handler/utils/request-parser.d.ts +0 -72
  252. package/dist/handler/utils/response-builder.d.ts +0 -83
  253. package/dist/handler/utils/storage-utils.d.ts +0 -10
  254. package/dist/handler/utils/stream-utils.d.ts +0 -29
  255. package/dist/handler/utils/upload-handlers.d.ts +0 -76
  256. package/dist/metrics/index.d.ts +0 -2
  257. package/dist/metrics/no-op-metrics.d.ts +0 -15
  258. package/dist/metrics/opentelemetry-metrics.d.ts +0 -55
  259. package/dist/openapi/rest.d.ts +0 -7
  260. package/dist/openapi/shared.d.ts +0 -13
  261. package/dist/openapi/transform.d.ts +0 -3
  262. package/dist/openapi/tus.d.ts +0 -7
  263. package/dist/openapi/xhr.d.ts +0 -7
  264. package/dist/packem_shared/AwsLightFile-tTneXZgG.js +0 -11
  265. package/dist/packem_shared/AwsLightMetaStorage-BWSOtVaN.js +0 -4
  266. package/dist/packem_shared/AwsLightStorage-Blv-GP4v.js +0 -133
  267. package/dist/packem_shared/AzureFile-CesgFzps.js +0 -8
  268. package/dist/packem_shared/AzureSMetaStorage-CFs-OYJT.js +0 -88
  269. package/dist/packem_shared/AzureStorage-B0v048hG.js +0 -357
  270. package/dist/packem_shared/BaseTransformer-C2gLib6v.js +0 -82
  271. package/dist/packem_shared/DiskStorage-BlltBst6.js +0 -12
  272. package/dist/packem_shared/DiskStorageWithChecksum-BJTmMklc.js +0 -238
  273. package/dist/packem_shared/ERRORS-D0apMqnc.js +0 -97
  274. package/dist/packem_shared/File-Bb3P23dr.js +0 -69
  275. package/dist/packem_shared/GCSConfig-vPP22kN6.js +0 -11
  276. package/dist/packem_shared/GCSFile-BIEunhAN.js +0 -8
  277. package/dist/packem_shared/GCSMetaStorage-BMFEdzJ7.js +0 -7
  278. package/dist/packem_shared/GCStorage-DnhiwaS9.js +0 -406
  279. package/dist/packem_shared/LocalMetaStorage-CZHhKkMd.js +0 -7
  280. package/dist/packem_shared/MediaTransformer-D6658DL1.js +0 -1197
  281. package/dist/packem_shared/MetaStorage-pECeFOad.js +0 -46
  282. package/dist/packem_shared/Metadata-DRLXeJ0F.js +0 -89
  283. package/dist/packem_shared/Multipart-CNFK_Okz.js +0 -163
  284. package/dist/packem_shared/Multipart-CtUL7BQw.js +0 -128
  285. package/dist/packem_shared/NetlifyBlobFile-CXzyjqrD.js +0 -14
  286. package/dist/packem_shared/NetlifyBlobMetaStorage-DxZ5aDvD.js +0 -9
  287. package/dist/packem_shared/NetlifyBlobStorage-CLPtjHqd.js +0 -376
  288. package/dist/packem_shared/NoOpMetrics-DhAk5rXc.js +0 -10
  289. package/dist/packem_shared/OpenTelemetryMetrics-BnxhqIaH.js +0 -67
  290. package/dist/packem_shared/Rest-CAOAEkOj.js +0 -267
  291. package/dist/packem_shared/Rest-DNuLwBrK.js +0 -228
  292. package/dist/packem_shared/S3File-DZiyk9Qt.js +0 -11
  293. package/dist/packem_shared/S3MetaStorage-Dz9aDabA.js +0 -76
  294. package/dist/packem_shared/S3Storage-DHmTk-hU.js +0 -316
  295. package/dist/packem_shared/TUS_RESUMABLE-GJzZ9R-f.js +0 -434
  296. package/dist/packem_shared/Tus-B8PmlMgR.js +0 -200
  297. package/dist/packem_shared/Tus-C4F1aYOl.js +0 -195
  298. package/dist/packem_shared/ValidationError-BfF1aE4h.js +0 -26
  299. package/dist/packem_shared/VercelBlobFile-BCg4aTEq.js +0 -18
  300. package/dist/packem_shared/VercelBlobMetaStorage-Bd9F-VFm.js +0 -9
  301. package/dist/packem_shared/VercelBlobStorage-DD9LMOS6.js +0 -261
  302. package/dist/packem_shared/_commonjsHelpers-B85MJLTf.js +0 -5
  303. package/dist/packem_shared/aws-light-meta-storage-DKJBgbR6.js +0 -446
  304. package/dist/packem_shared/backblaze-BlMnIcBC.js +0 -20
  305. package/dist/packem_shared/base-handler-core-BKuf4YLT.js +0 -303
  306. package/dist/packem_shared/base-handler-fetch-Cr0hLiqg.js +0 -291
  307. package/dist/packem_shared/base-handler-node-gk5aN9Cx.js +0 -730
  308. package/dist/packem_shared/cache-B88MXQ_2.js +0 -18
  309. package/dist/packem_shared/cloudflare-Bi1q8wXE.js +0 -21
  310. package/dist/packem_shared/defaultCloudStorageFileNameValidation-DUuacjWv.js +0 -11
  311. package/dist/packem_shared/digitalOcean-CWQRJM3L.js +0 -21
  312. package/dist/packem_shared/disk-storage-Bh2wy3YW.js +0 -810
  313. package/dist/packem_shared/gcs-meta-storage-0tgMNnPO.js +0 -158
  314. package/dist/packem_shared/has-content-CY66ehMK.js +0 -3
  315. package/dist/packem_shared/headers-DoS5nwM-.js +0 -3220
  316. package/dist/packem_shared/is-expired-CTThU1q5.js +0 -8
  317. package/dist/packem_shared/isRetryableError-Dycp7127.js +0 -82
  318. package/dist/packem_shared/isValidMediaType-BeDgiObq.js +0 -35
  319. package/dist/packem_shared/local-meta-storage-By-3SNBI.js +0 -649
  320. package/dist/packem_shared/minio-C2YBZQOw.js +0 -22
  321. package/dist/packem_shared/multipart-base-B3i67SSX.js +0 -102
  322. package/dist/packem_shared/part-match-BMNqHDYD.js +0 -96
  323. package/dist/packem_shared/path-CR6YkPXX-7R1-9CMk.js +0 -161
  324. package/dist/packem_shared/response-builder-BtnRiBUI.js +0 -45
  325. package/dist/packem_shared/rest-base-GRCcnan7.js +0 -457
  326. package/dist/packem_shared/restOpenApiSpec-CwcHHY2C.js +0 -800
  327. package/dist/packem_shared/s3-base-storage-C1DIHTYY.js +0 -510
  328. package/dist/packem_shared/sharedGet-Cpo7QUyu.js +0 -1019
  329. package/dist/packem_shared/storage-C6NSXb8h.js +0 -1175
  330. package/dist/packem_shared/tigris-Hac8TKnX.js +0 -21
  331. package/dist/packem_shared/transformOpenApiSpec-DWM5WtnN.js +0 -975
  332. package/dist/packem_shared/tusOpenApiSpec-6ohiToBy.js +0 -740
  333. package/dist/packem_shared/update-size-CCGm6i1J.js +0 -8
  334. package/dist/packem_shared/validator-BeX_lJet.js +0 -78
  335. package/dist/packem_shared/waitForStorage-Cscw85sx.js +0 -18
  336. package/dist/packem_shared/wasabi-DIyflHSd.js +0 -21
  337. package/dist/packem_shared/xhrOpenApiSpec-DS17brnx.js +0 -264
  338. package/dist/storage/aws/clients/backblaze.d.ts +0 -12
  339. package/dist/storage/aws/clients/cloudflare.d.ts +0 -13
  340. package/dist/storage/aws/clients/digital-ocean.d.ts +0 -12
  341. package/dist/storage/aws/clients/minio.d.ts +0 -13
  342. package/dist/storage/aws/clients/tigris.d.ts +0 -12
  343. package/dist/storage/aws/clients/types.d.ts +0 -95
  344. package/dist/storage/aws/clients/wasabi.d.ts +0 -12
  345. package/dist/storage/aws/s3-base-storage.d.ts +0 -248
  346. package/dist/storage/aws/s3-client-adapter.d.ts +0 -110
  347. package/dist/storage/aws/s3-file.d.ts +0 -10
  348. package/dist/storage/aws/s3-meta-storage.d.ts +0 -15
  349. package/dist/storage/aws/s3-storage.d.ts +0 -70
  350. package/dist/storage/aws/types.d.ts +0 -119
  351. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +0 -130
  352. package/dist/storage/aws-light/aws-light-file.d.ts +0 -10
  353. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +0 -19
  354. package/dist/storage/aws-light/aws-light-storage.d.ts +0 -65
  355. package/dist/storage/aws-light/types.d.ts +0 -37
  356. package/dist/storage/azure/azure-file.d.ts +0 -6
  357. package/dist/storage/azure/azure-meta-storage.d.ts +0 -15
  358. package/dist/storage/azure/azure-storage.d.ts +0 -69
  359. package/dist/storage/azure/types.d.ts +0 -62
  360. package/dist/storage/gcs/fetch-error.d.ts +0 -11
  361. package/dist/storage/gcs/gcs-config.d.ts +0 -2
  362. package/dist/storage/gcs/gcs-file.d.ts +0 -6
  363. package/dist/storage/gcs/gcs-meta-storage.d.ts +0 -27
  364. package/dist/storage/gcs/gcs-storage.d.ts +0 -91
  365. package/dist/storage/gcs/types.d.ts +0 -55
  366. package/dist/storage/gcs/utils.d.ts +0 -7
  367. package/dist/storage/local/disk-storage-with-checksum.d.ts +0 -15
  368. package/dist/storage/local/disk-storage.d.ts +0 -135
  369. package/dist/storage/local/local-meta-storage.d.ts +0 -32
  370. package/dist/storage/meta-storage.d.ts +0 -30
  371. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +0 -12
  372. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +0 -7
  373. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +0 -93
  374. package/dist/storage/netlify-blob/types.d.ts +0 -30
  375. package/dist/storage/storage.d.ts +0 -353
  376. package/dist/storage/types.d.ts +0 -221
  377. package/dist/storage/utils/file/file.d.ts +0 -25
  378. package/dist/storage/utils/file/get-file-status.d.ts +0 -9
  379. package/dist/storage/utils/file/has-content.d.ts +0 -9
  380. package/dist/storage/utils/file/index.d.ts +0 -10
  381. package/dist/storage/utils/file/is-expired.d.ts +0 -8
  382. package/dist/storage/utils/file/metadata.d.ts +0 -18
  383. package/dist/storage/utils/file/part-match.d.ts +0 -11
  384. package/dist/storage/utils/file/types.d.ts +0 -37
  385. package/dist/storage/utils/file/update-metadata.d.ts +0 -10
  386. package/dist/storage/utils/file/update-size.d.ts +0 -10
  387. package/dist/storage/vercel-blob/types.d.ts +0 -32
  388. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +0 -16
  389. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +0 -7
  390. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +0 -76
  391. package/dist/transformer/base-transformer.d.ts +0 -63
  392. package/dist/transformer/media-transformer.d.ts +0 -332
  393. package/dist/transformer/types.d.ts +0 -652
  394. package/dist/transformer/utils.d.ts +0 -33
  395. package/dist/transformer/validation-error.d.ts +0 -23
  396. package/dist/utils/cache.d.ts +0 -32
  397. package/dist/utils/chunked-upload.d.ts +0 -65
  398. package/dist/utils/detect-file-type.d.ts +0 -28
  399. package/dist/utils/errors.d.ts +0 -74
  400. package/dist/utils/file-path-url-matcher.d.ts +0 -18
  401. package/dist/utils/headers.d.ts +0 -111
  402. package/dist/utils/http.d.ts +0 -92
  403. package/dist/utils/locker.d.ts +0 -26
  404. package/dist/utils/pipes/stream-checksum.d.ts +0 -47
  405. package/dist/utils/pipes/stream-length.d.ts +0 -22
  406. package/dist/utils/primitives/get-last-one.d.ts +0 -3
  407. package/dist/utils/primitives/is-record.d.ts +0 -2
  408. package/dist/utils/primitives/map-values.d.ts +0 -9
  409. package/dist/utils/primitives/pick.d.ts +0 -2
  410. package/dist/utils/primitives/to-milliseconds.d.ts +0 -12
  411. package/dist/utils/primitives/to-seconds.d.ts +0 -12
  412. package/dist/utils/range-checksum.d.ts +0 -33
  413. package/dist/utils/range-hasher.d.ts +0 -46
  414. package/dist/utils/retry.d.ts +0 -64
  415. package/dist/utils/types.d.ts +0 -108
  416. package/dist/utils/validation-error.d.ts +0 -22
  417. package/dist/utils/validator.d.ts +0 -36
@@ -0,0 +1,1106 @@
1
+ import { Transform, Readable } from 'node:stream';
2
+ import { BinaryToTextEncoding, Hash } from 'node:crypto';
3
+ import { IncomingMessage } from 'node:http';
4
+ import { LRUCache } from 'lru-cache';
5
+ /**
6
+ * Simple cache interface that any cache implementation can follow
7
+ */
8
+ interface Cache<K = string, V = unknown> {
9
+ /** Clear all cache entries */
10
+ clear: () => void | Promise<void>;
11
+ /** Delete a value from cache */
12
+ delete: (key: K) => boolean | Promise<boolean>;
13
+ /** Get a value from cache */
14
+ get: (key: K) => V | undefined | Promise<V | undefined>;
15
+ /** Check if a key exists in cache */
16
+ has: (key: K) => boolean | Promise<boolean>;
17
+ /**
18
+ * Optional. Iterate over the cache's current keys. Required for prefix-based
19
+ * eviction (`clearCache(fileId)` in transformers) — when absent, per-file
20
+ * clear falls back to a full `clear()`. `LRUCache` from `lru-cache`
21
+ * satisfies this out of the box.
22
+ */
23
+ keys?: () => Iterable<K>;
24
+ /** Set a value in cache */
25
+ set: (key: K, value: V, options?: CacheOptions) => boolean | Promise<boolean>;
26
+ }
27
+ /**
28
+ * Options for cache operations
29
+ */
30
+ interface CacheOptions {
31
+ /** TTL in milliseconds */
32
+ ttl?: number;
33
+ }
34
+ /**
35
+ * Transform that computes a rolling checksum for a stream while passing
36
+ * data through unchanged.
37
+ */
38
+ interface RangeChecksum extends Transform {
39
+ /** Return the current digest in the selected encoding. */
40
+ digest: (encoding: BinaryToTextEncoding) => string;
41
+ hash: Hash;
42
+ path: string;
43
+ reset: () => void;
44
+ }
45
+ /**
46
+ * LRU-backed map of rolling hashers keyed by file path. Used to compute
47
+ * hex/base64 digests and resume hashing from an offset.
48
+ */
49
+ interface RangeHasher extends LRUCache<string, Hash> {
50
+ algorithm: "md5" | "sha1";
51
+ base64: (path: string) => string;
52
+ digester: (path: string) => RangeChecksum;
53
+ hex: (path: string) => string;
54
+ init: (path: string, start: number) => Promise<Hash>;
55
+ updateFromFs: (path: string, start: number, initial?: Hash) => Promise<Hash>;
56
+ }
57
+ /**
58
+ * Normalized HTTP error payload returned by handlers and storage backends.
59
+ */
60
+ interface HttpErrorBody {
61
+ code: string;
62
+ detail?: Record<string, unknown> | string;
63
+ message: string;
64
+ name?: string;
65
+ retryable?: boolean;
66
+ UploadErrorCode?: string;
67
+ }
68
+ /**
69
+ * Rich HTTP error including status code and optional headers/body.
70
+ */
71
+ interface HttpError<T = HttpErrorBody> extends UploadResponse<T> {
72
+ statusCode: number;
73
+ }
74
+ /**
75
+ * Node.js IncomingMessage with an optional parsed body attached.
76
+ */
77
+ interface IncomingMessageWithBody<T = unknown> extends IncomingMessage {
78
+ _body?: boolean;
79
+ body?: T;
80
+ }
81
+ type Header = string[] | number | string;
82
+ type Headers = Record<string, Header>;
83
+ type ResponseBody = Record<string, unknown> | string | Buffer | Uint8Array;
84
+ type ResponseBodyType = "json" | "text";
85
+ /**
86
+ * Tuple form for quick response definitions: [status, body, headers].
87
+ */
88
+ type ResponseTuple<T = ResponseBody> = [statusCode: number, body?: T, headers?: Headers];
89
+ /**
90
+ * Structured response used across handlers and storage operations.
91
+ */
92
+ interface UploadResponse<T = ResponseBody> extends Record<string, unknown> {
93
+ body?: T;
94
+ headers?: Headers;
95
+ statusCode?: number;
96
+ }
97
+ /**
98
+ * Declarative validator configuration for a single rule.
99
+ */
100
+ interface ValidatorConfig<T> {
101
+ isValid?: (t: T) => Promise<boolean> | boolean;
102
+ response?: HttpError | ResponseTuple;
103
+ value?: unknown;
104
+ }
105
+ /** Map of rule-name -> validator configuration. */
106
+ type Validation<T> = Record<string, ValidatorConfig<T>>;
107
+ /** Narrowed error response shape for validation failures. */
108
+ interface ValidationError extends HttpError {
109
+ code: string;
110
+ }
111
+ /**
112
+ * Metrics interface for observability.
113
+ * Provides counters, timers, and gauges for tracking storage operations.
114
+ */
115
+ interface Metrics {
116
+ /**
117
+ * Set a gauge metric value.
118
+ * @param name Metric name (e.g., "storage.files.size")
119
+ * @param value Gauge value
120
+ * @param attributes Optional attributes/labels
121
+ */
122
+ gauge: (name: string, value: number, attributes?: Record<string, string | number>) => void;
123
+ /**
124
+ * Increment a counter metric.
125
+ * @param name Metric name (e.g., "storage.operations.create.count")
126
+ * @param value Increment value (default: 1)
127
+ * @param attributes Optional attributes/labels (e.g., { storage: "s3", operation: "create" })
128
+ */
129
+ increment: (name: string, value?: number, attributes?: Record<string, string | number>) => void;
130
+ /**
131
+ * Record a duration/timing metric in milliseconds.
132
+ * @param name Metric name (e.g., "storage.operations.write.duration")
133
+ * @param duration Duration in milliseconds
134
+ * @param attributes Optional attributes/labels
135
+ */
136
+ timing: (name: string, duration: number, attributes?: Record<string, string | number>) => void;
137
+ }
138
+ /**
139
+ * Canonical error codes used across handlers and storage adapters.
140
+ * These codes map to standardized HTTP status codes and error messages.
141
+ */
142
+ declare enum ERRORS {
143
+ BAD_REQUEST = "BadRequest",
144
+ CHECKSUM_MISMATCH = "ChecksumMismatch",
145
+ FILE_CONFLICT = "FileConflict",
146
+ FILE_ERROR = "FileError",
147
+ FILE_LOCKED = "FileLocked",
148
+ FILE_NOT_ALLOWED = "FileNotAllowed",
149
+ FILE_NOT_FOUND = "FileNotFound",
150
+ FORBIDDEN = "Forbidden",
151
+ GONE = "Gone",
152
+ INVALID_FILE_NAME = "InvalidFileName",
153
+ INVALID_FILE_SIZE = "InvalidFileSize",
154
+ INVALID_RANGE = "InvalidRange",
155
+ INVALID_TYPE = "Invalidtype",
156
+ METHOD_NOT_ALLOWED = "MethodNotAllowed",
157
+ REQUEST_ABORTED = "RequestAborted",
158
+ REQUEST_ENTITY_TOO_LARGE = "RequestEntityTooLarge",
159
+ STORAGE_BUSY = "StorageBusy",
160
+ STORAGE_ERROR = "StorageError",
161
+ TOO_MANY_REQUESTS = "TooManyRequests",
162
+ UNKNOWN_ERROR = "UnknownError",
163
+ UNPROCESSABLE_ENTITY = "UnprocessableEntity",
164
+ UNSUPPORTED_CHECKSUM_ALGORITHM = "UnsupportedChecksumAlgorithm",
165
+ UNSUPPORTED_MEDIA_TYPE = "UnsupportedMediaType",
166
+ }
167
+ /**
168
+ * Type mapping of error codes to standardized HTTP error responses.
169
+ * @template T - The error code type (defaults to string)
170
+ */
171
+ type ErrorResponses<T extends string = string> = { [K in T]: HttpError };
172
+ /**
173
+ * Mapping of error codes to HttpError response objects.
174
+ * @returns Map of error codes to standardized HTTP error responses
175
+ */
176
+ declare const ErrorMap: ErrorResponses<ERRORS>;
177
+ /**
178
+ * Error subclass carrying a stable error code and optional detail.
179
+ * Provides structured error information for upload operations.
180
+ */
181
+ declare class UploadError extends Error {
182
+ override name: string;
183
+ /** The standardized error code from the ERRORS enum */
184
+ UploadErrorCode: ERRORS;
185
+ /** Optional additional error details */
186
+ detail?: unknown;
187
+ /**
188
+ * Creates a new UploadError instance.
189
+ * @param code Standardized error code (defaults to UNKNOWN_ERROR)
190
+ * @param message Human-readable error message (defaults to the code)
191
+ * @param detail Optional additional error details
192
+ */
193
+ constructor(code?: ERRORS, message?: string, detail?: unknown);
194
+ }
195
+ /**
196
+ * Type guard to check if an error is an UploadError instance.
197
+ * @param error Error to check
198
+ * @returns True if the error is an UploadError with a valid error code
199
+ */
200
+ declare const isUploadError: (error: unknown) => error is UploadError;
201
+ /**
202
+ * Best-effort extraction of an HTTP status from a native SDK error.
203
+ *
204
+ * Covers the shapes used by the consumer-provider SDKs:
205
+ * - Dropbox `DropboxResponseError` → `error.status`
206
+ * - Box `BoxAPIError` / Microsoft Graph errors → `error.statusCode`
207
+ * - googleapis errors → `error.code` (numeric) or `error.response.status`
208
+ * - Supabase / fetch-style errors → `error.status` or `error.response.status`
209
+ */
210
+ declare const extractHttpStatus: (error: unknown) => number | undefined;
211
+ /**
212
+ * Map an HTTP status code to the closest canonical ERRORS value.
213
+ *
214
+ * Returns STORAGE_ERROR for unknown/5xx and BAD_REQUEST for unmapped 4xx.
215
+ * 401 (unauthenticated) collapses to FORBIDDEN because the ERRORS enum has
216
+ * no dedicated UNAUTHORIZED value; callers needing to distinguish the two
217
+ * should inspect the native error on `UploadError.detail`.
218
+ */
219
+ declare const mapStatusToErrorCode: (status?: number) => ERRORS;
220
+ /**
221
+ * Normalize a native storage-SDK error into an `UploadError`.
222
+ *
223
+ * The native error is preserved on `.detail` so advanced callers can drop down
224
+ * to provider-specific shapes when needed. Already-wrapped `UploadError`
225
+ * instances pass through unchanged.
226
+ * @example
227
+ * ```ts
228
+ * try {
229
+ * await client.filesCopyV2({ from_path, to_path });
230
+ * } catch (error) {
231
+ * throw wrapStorageError(error, { adapter: "Dropbox", operation: "copy" });
232
+ * }
233
+ * ```
234
+ */
235
+ declare const wrapStorageError: (error: unknown, options: {
236
+ adapter: string;
237
+ code?: ERRORS;
238
+ message?: string;
239
+ operation: string;
240
+ status?: number;
241
+ }) => UploadError;
242
+ /**
243
+ * Convenience function to throw an UploadError from a string error code.
244
+ * Looks up the appropriate error message from ErrorMap.
245
+ * @param UploadErrorCode String error code to convert to UploadError
246
+ * @param detail Optional additional error details
247
+ * @throws UploadError with the specified code and message
248
+ */
249
+ declare const throwErrorCode: (UploadErrorCode: ERRORS | string, detail?: string) => never;
250
+ /**
251
+ * A simple lock map keyed by strings, backed by LRUCache. Locks
252
+ * automatically expire according to the configured TTL preventing deadlocks.
253
+ *
254
+ * Each successful `lock()` returns a unique token; the corresponding `unlock(key, token)`
255
+ * call only releases the lock when the token matches the current holder. This prevents a
256
+ * stale lock owner (e.g. one whose entry TTL'd out and was re-acquired by another caller)
257
+ * from releasing another caller's lock by accident.
258
+ */
259
+ declare class Locker<K extends string = string> extends LRUCache<K, string, number> {
260
+ constructor(options?: LRUCache.Options<K, string, number>);
261
+ /**
262
+ * Acquires a lock for the specified key.
263
+ * @returns A unique token identifying the lock holder.
264
+ * @throws Error if the key is already locked.
265
+ */
266
+ lock(key: K): string;
267
+ /**
268
+ * Releases the lock for the specified key, but only if the token matches the current holder.
269
+ * Silently no-ops when the lock has expired or is owned by someone else — releasing somebody
270
+ * else's lock is worse than leaving a stale entry to TTL out on its own.
271
+ * @returns true if the lock was released, false if it was already gone or owned by another caller.
272
+ */
273
+ unlock(key: K, token: string): boolean;
274
+ }
275
+ /**
276
+ * Retry configuration options for storage operations
277
+ */
278
+ interface RetryConfig {
279
+ /**
280
+ * Multiplier for exponential backoff (e.g., 2 means delays double each retry)
281
+ * @default 2
282
+ */
283
+ backoffMultiplier?: number;
284
+ /**
285
+ * Custom function to calculate delay for a specific retry attempt
286
+ * @param attempt The current retry attempt (0-indexed)
287
+ * @param error The error that occurred
288
+ * @returns Delay in milliseconds, or undefined to use default exponential backoff
289
+ */
290
+ calculateDelay?: (attempt: number, error: unknown) => number | undefined;
291
+ /**
292
+ * Initial delay in milliseconds before first retry
293
+ * @default 1000
294
+ */
295
+ initialDelay?: number;
296
+ /**
297
+ * Maximum delay in milliseconds between retries
298
+ * @default 30000
299
+ */
300
+ maxDelay?: number;
301
+ /**
302
+ * Maximum number of retry attempts
303
+ * @default 3
304
+ */
305
+ maxRetries?: number;
306
+ /**
307
+ * HTTP status codes that should trigger a retry
308
+ * @default [408, 429, 500, 502, 503, 504]
309
+ */
310
+ retryableStatusCodes?: number[];
311
+ /**
312
+ * Custom function to determine if an error should be retried
313
+ * @param error The error that occurred
314
+ * @returns true if the error should be retried, false otherwise
315
+ */
316
+ shouldRetry?: (error: unknown) => boolean;
317
+ }
318
+ /**
319
+ * Determines if an error is retryable based on common patterns
320
+ * @param error The error to check
321
+ * @param retryableStatusCodes HTTP status codes that should trigger retry
322
+ * @returns true if the error is retryable
323
+ */
324
+ declare const isRetryableError: (error: unknown, retryableStatusCodes?: number[]) => boolean;
325
+ /**
326
+ * Retry an async operation with exponential backoff
327
+ * @param fn The async function to retry
328
+ * @param config Retry configuration
329
+ * @returns The result of the function
330
+ * @throws The last error if all retries are exhausted
331
+ */
332
+ declare const retry: <T>(function_: () => Promise<T>, config?: RetryConfig) => Promise<T>;
333
+ /**
334
+ * Create a retry wrapper function with pre-configured settings.
335
+ * @param config Retry configuration
336
+ * @returns A function that wraps async operations with retry logic
337
+ */
338
+ declare const createRetryWrapper: (config?: RetryConfig) => <T>(function_: () => Promise<T>) => Promise<T>;
339
+ /**
340
+ * Configurable validation system for file upload constraints.
341
+ * Supports multiple validation rules with custom error responses.
342
+ * @template T - The type being validated
343
+ */
344
+ declare class Validator<T> {
345
+ private prefix;
346
+ private validators;
347
+ /**
348
+ * Creates a new Validator instance.
349
+ * @param prefix Prefix for generated error codes (default: "ValidationError")
350
+ */
351
+ constructor(prefix?: string);
352
+ /**
353
+ * Adds validation rules to the validator.
354
+ * Each rule must include an `isValid` function.
355
+ * @param config Validation configuration object
356
+ * @throws TypeError if any validator is missing the isValid function
357
+ */
358
+ add(config: Validation<T>): void;
359
+ /**
360
+ * Verifies an object against all configured validation rules.
361
+ * Throws ValidationError on first validation failure.
362
+ * @param t Object to validate
363
+ * @throws ValidationError if validation fails
364
+ */
365
+ verify(t: T): Promise<never | void>;
366
+ }
367
+ interface MetaStorageOptions {
368
+ logger?: Console;
369
+ prefix?: string;
370
+ suffix?: string;
371
+ }
372
+ interface LocalMetaStorageOptions extends MetaStorageOptions {
373
+ /**
374
+ * Where the upload metadata should be stored
375
+ */
376
+ directory?: string;
377
+ }
378
+ declare class Metadata {
379
+ [key: string]: unknown;
380
+ psize?: number | string;
381
+ pname?: string;
382
+ pfiletype?: string;
383
+ ptype?: string;
384
+ pmimeType?: string;
385
+ pcontentType?: string;
386
+ ptitle?: string;
387
+ pfilename?: string;
388
+ poriginalName?: string;
389
+ plastModified?: number | string;
390
+ }
391
+ interface FileInit {
392
+ contentType?: string;
393
+ expiredAt?: Date | number | string;
394
+ /**
395
+ * Explicit identifier. When provided, the File constructor uses it directly
396
+ * instead of deriving an id from originalName/size/mtime. Lets callers map a
397
+ * user-chosen storage key (e.g. `"avatars/abc.png"`) onto the metadata id.
398
+ */
399
+ id?: string;
400
+ metadata: Metadata;
401
+ originalName?: string;
402
+ size?: number | string;
403
+ storageClass?: string;
404
+ ttl?: number | string;
405
+ }
406
+ interface FileReturn extends Omit<Required<FileInit>, "id" | "storageClass" | "ttl" | "expiredAt"> {
407
+ content: Buffer;
408
+ ETag?: string;
409
+ expiredAt?: Date | number | string;
410
+ id: string;
411
+ modifiedAt?: Date | number | string;
412
+ name: string;
413
+ storageClass?: string;
414
+ }
415
+ type UploadEventTypeValue = "completed" | "created" | "deleted" | "part" | "updated";
416
+ type UploadEventType = UploadEventTypeValue;
417
+ interface FileQuery {
418
+ id: string;
419
+ name?: string;
420
+ size?: number;
421
+ }
422
+ interface Checksum {
423
+ checksum?: string;
424
+ checksumAlgorithm?: string;
425
+ }
426
+ interface FilePart extends Checksum, FileQuery {
427
+ body: Readable;
428
+ contentLength?: number;
429
+ start: number;
430
+ }
431
+ type DateType = Date | number | string;
432
+ declare class File implements FileInit {
433
+ bytesWritten: number;
434
+ contentType: string;
435
+ originalName: string;
436
+ id: string;
437
+ metadata: Metadata;
438
+ name: string;
439
+ size?: number;
440
+ status?: UploadEventType;
441
+ expiredAt?: DateType;
442
+ createdAt?: DateType;
443
+ modifiedAt?: DateType;
444
+ hash?: {
445
+ algorithm: string;
446
+ value: string;
447
+ };
448
+ content?: Buffer;
449
+ ETag?: string;
450
+ constructor({
451
+ contentType,
452
+ expiredAt,
453
+ id,
454
+ metadata,
455
+ originalName,
456
+ size
457
+ }: FileInit);
458
+ }
459
+ type UploadFile = Readonly<File>;
460
+ /**
461
+ * Stores upload metadata.
462
+ */
463
+ declare class MetaStorage<T extends File = File> {
464
+ prefix: string;
465
+ suffix: string;
466
+ protected readonly logger?: Console;
467
+ constructor(config?: MetaStorageOptions);
468
+ /**
469
+ * Saves upload metadata.
470
+ */
471
+ save(_id: string, file: T): Promise<T>;
472
+ /**
473
+ * Deletes an upload metadata.
474
+ */
475
+ delete(_id: string): Promise<void>;
476
+ /**
477
+ * Retrieves upload metadata.
478
+ */
479
+ get(_id: string): Promise<T>;
480
+ /**
481
+ * Marks upload active.
482
+ */
483
+ touch(_id: string, _file: T): Promise<T>;
484
+ getMetaName(id: string): string;
485
+ getIdFromMetaName(name: string): string;
486
+ }
487
+ type OnCreate<TFile extends File = File> = (file: TFile) => Promise<void> | void;
488
+ type OnUpdate<TFile extends File = File> = (file: TFile) => Promise<void> | void;
489
+ type OnComplete<TFile extends File = File, TResponse = unknown, TRequest = unknown> = (file: TFile, response: TResponse, request?: TRequest) => Promise<void> | void;
490
+ type OnDelete<TFile extends File = File> = (file: TFile) => Promise<void> | void;
491
+ type OnError<TBody = HttpErrorBody> = (error: HttpError<TBody>) => Promise<void> | void;
492
+ interface PurgeList {
493
+ items: UploadFile[];
494
+ maxAgeMs: number;
495
+ }
496
+ interface ExpirationOptions {
497
+ /**
498
+ * Age of the upload, after which it is considered expired and can be deleted
499
+ */
500
+ maxAge: number | string;
501
+ /**
502
+ * Auto purging interval for expired upload
503
+ */
504
+ purgeInterval?: number | string;
505
+ /**
506
+ * Auto prolong expiring upload
507
+ */
508
+ rolling?: boolean;
509
+ }
510
+ interface BaseStorageOptions<T extends File = File> extends GenericStorageConfig {
511
+ /** Allowed MIME types */
512
+ allowMIME?: string[];
513
+ /** The full path of the folder where the uploaded asset will be stored. */
514
+ assetFolder?: string;
515
+ /** Cache instance to use for caching */
516
+ cache?: Cache;
517
+ /**
518
+ * Automatic cleaning of abandoned and completed upload
519
+ * @example
520
+ * ```ts
521
+ * app.use(
522
+ * '/upload',
523
+ * Upload.upload({
524
+ * directory: 'upload',
525
+ * expiration: { maxAge: '6h', purgeInterval: '30min' },
526
+ * onComplete
527
+ * })
528
+ * );
529
+ * ```
530
+ */
531
+ expiration?: ExpirationOptions;
532
+ /** File naming function */
533
+ filename?: (file: T) => string;
534
+ /**
535
+ * File name validation function.
536
+ * Returns true if the filename is valid, false otherwise.
537
+ * @default Cloud storage platforms: permissive (only blocks path traversal and null bytes)
538
+ * @default DiskStorage: strict (blocks filesystem-incompatible characters)
539
+ * @example
540
+ * ```ts
541
+ * fileNameValidation: (name: string) => {
542
+ * // Custom validation logic
543
+ * return name.length > 0 && !name.includes('../');
544
+ * }
545
+ * ```
546
+ */
547
+ fileNameValidation?: (name: string) => boolean;
548
+ /** Logger injection */
549
+ logger?: Console;
550
+ /** Limiting the size of custom metadata */
551
+ maxMetadataSize?: number | string;
552
+ /** File size limit */
553
+ maxUploadSize?: number | string;
554
+ /** Provide custom meta storage */
555
+ metaStorage?: MetaStorage<T>;
556
+ /** Metrics injection for observability */
557
+ metrics?: Metrics;
558
+ /** Callback function that is called when an upload is completed */
559
+ onComplete?: OnComplete<T>;
560
+ /** Callback function that is called when a new upload is created */
561
+ onCreate?: OnCreate<T>;
562
+ /** Callback function that is called when an upload is cancelled */
563
+ onDelete?: OnDelete<T>;
564
+ /** Customize error response */
565
+ onError?: OnError;
566
+ /** Callback function that is called when an upload is updated */
567
+ onUpdate?: OnUpdate<T>;
568
+ /** Force relative URI in Location header */
569
+ useRelativeLocation?: boolean;
570
+ /** Upload validation options */
571
+ validation?: Validation<T>;
572
+ }
573
+ type DiskStorageOptions<T extends File> = BaseStorageOptions<T> & {
574
+ /**
575
+ * Uploads directory.
576
+ */
577
+ directory: string;
578
+ /**
579
+ * Configuring metafile storage on the local disk
580
+ * @example
581
+ * ```ts
582
+ * const storage = new DiskStorage({
583
+ * directory: 'upload',
584
+ * metaStorageConfig: { directory: '/tmp/upload-metafiles', prefix: '.' }
585
+ * });
586
+ * ```
587
+ */
588
+ metaStorageConfig?: LocalMetaStorageOptions;
589
+ };
590
+ type DiskStorageWithChecksumOptions<T extends File> = DiskStorageOptions<T> & {
591
+ /**
592
+ * Enable/disable file/range checksum calculation
593
+ */
594
+ checksum?: boolean | "md5" | "sha1";
595
+ };
596
+ /**
597
+ * Unified storage configuration
598
+ */
599
+ interface GenericStorageConfig {
600
+ /** Allow additional properties for specific storage backends */
601
+ [key: string]: unknown;
602
+ /** Base path/prefix for all operations */
603
+ basePath?: string;
604
+ /** Cache TTL */
605
+ cacheTTL?: number;
606
+ /** Supported checksum algorithms */
607
+ checksumTypes?: string[];
608
+ /**
609
+ * Default abort signal merged into every operation. A per-call
610
+ * `OperationOptions.signal` is combined with this, not replaced — either
611
+ * one aborts the call. Note this signal lives for the storage instance's
612
+ * lifetime: once it aborts, every subsequent operation fails fast.
613
+ */
614
+ defaultSignal?: AbortSignal;
615
+ /**
616
+ * Default per-operation timeout in milliseconds, applied per retry
617
+ * attempt when a call omits `OperationOptions.timeout`. A per-call
618
+ * `timeout` (including `0` to explicitly disable) takes precedence.
619
+ */
620
+ defaultTimeout?: number;
621
+ /** Logger instance */
622
+ logger?: Console;
623
+ /** Maximum file size */
624
+ maxFileSize?: number | string;
625
+ /** Metrics instance for observability */
626
+ metrics?: Metrics;
627
+ /** Retry configuration for transient failures */
628
+ retryConfig?: RetryConfig;
629
+ }
630
+ /**
631
+ * Per-operation overrides for cancellation, deadlines and retries.
632
+ *
633
+ * Threaded through the public storage operations down to the backend SDK call.
634
+ * Backends that wrap an SDK with native cancellation honour `signal`/`timeout`
635
+ * directly; backends without a cancellation primitive still fail fast at the
636
+ * storage layer, but the provider request may continue in the background.
637
+ */
638
+ interface OperationOptions {
639
+ /**
640
+ * Retry override for this call. A number is treated as `maxRetries`; an
641
+ * object is shallow-merged over the backend's configured `RetryConfig`.
642
+ * Aborted and timed-out operations are never retried regardless of this.
643
+ */
644
+ retries?: number | RetryConfig;
645
+ /**
646
+ * Abort the operation when this signal fires. Merged with any
647
+ * per-call `timeout` via `AbortSignal.any`.
648
+ */
649
+ signal?: AbortSignal;
650
+ /**
651
+ * Per-operation timeout in milliseconds. `0` or a negative value
652
+ * disables the timeout. Applied per retry attempt.
653
+ */
654
+ timeout?: number;
655
+ }
656
+ /**
657
+ * Batch operation result for a single file
658
+ */
659
+ interface BatchOperationResult<T extends File = File> {
660
+ /** Error message if operation failed */
661
+ error?: string;
662
+ /** File that was successfully operated on */
663
+ file?: T;
664
+ /** File ID */
665
+ id: string;
666
+ /** Whether the operation was successful */
667
+ success: boolean;
668
+ }
669
+ /**
670
+ * Response from batch operations (deleteBatch, copyBatch, moveBatch)
671
+ */
672
+ interface BatchOperationResponse<T extends File = File> {
673
+ /** Failed operations with error details */
674
+ failed: {
675
+ error: string;
676
+ id: string;
677
+ }[];
678
+ /** Total number of failed operations */
679
+ failedCount: number;
680
+ /** Successfully processed files */
681
+ successful: T[];
682
+ /** Total number of successful operations */
683
+ successfulCount: number;
684
+ }
685
+ /**
686
+ * Default filename validation for cloud storage platforms.
687
+ * Permissive validation that only blocks dangerous patterns (path traversal, null bytes).
688
+ * Cloud storage platforms (S3, Azure, GCS) accept most special characters and handle URL encoding automatically.
689
+ */
690
+ declare const defaultCloudStorageFileNameValidation: (name: string) => boolean;
691
+ /**
692
+ * Default filename validation for local filesystems.
693
+ * Stricter validation that blocks filesystem-incompatible characters.
694
+ */
695
+ declare const defaultFilesystemFileNameValidation: (name: string) => boolean;
696
+ /**
697
+ * Abstract base class for all storage backends.
698
+ * @template TFile The file type used by this storage backend.
699
+ * @template TFileReturn The return type for file retrieval operations.
700
+ * @remarks
701
+ * ## Error Handling
702
+ *
703
+ * All storage operations follow consistent error handling patterns:
704
+ * - Operations throw `UploadError` with specific error codes (see ERRORS enum)
705
+ * - Common error codes: FILE_NOT_FOUND, GONE (expired), FILE_LOCKED, STORAGE_BUSY
706
+ * - Errors are normalized with storage class context via `normalizeError()`
707
+ * - Batch operations capture individual failures without stopping the batch
708
+ *
709
+ * ## Retry Behavior
710
+ *
711
+ * Storage implementations handle retries differently:
712
+ *
713
+ * ### Cloud Storage (S3, GCS, Azure, Netlify Blob)
714
+ * - Use configurable retry wrappers via `retryConfig` option
715
+ * - Default retryable status codes: 408, 429, 500, 502, 503, 504
716
+ * - Retry logic handles transient network errors and rate limiting
717
+ * - Custom `shouldRetry` functions can be provided for advanced retry logic
718
+ *
719
+ * ### Local Storage (DiskStorage)
720
+ * - No automatic retries (filesystem operations are typically immediate)
721
+ * - Errors are thrown directly for immediate feedback
722
+ *
723
+ * ## Operation Instrumentation
724
+ *
725
+ * All public operations are automatically instrumented via `instrumentOperation()`:
726
+ * - Metrics are recorded for operation count, duration, and errors
727
+ * - File sizes are tracked for operations that return file objects
728
+ * - Error metrics include error messages for debugging
729
+ *
730
+ * ## Metadata Caching
731
+ *
732
+ * File metadata is automatically cached to reduce storage API calls:
733
+ * - Cache is updated on save, delete, and get operations
734
+ * - Cache is invalidated when metadata is deleted
735
+ * - Implementations can override caching behavior if needed
736
+ */
737
+ declare abstract class BaseStorage<TFile extends File = File, TFileReturn extends FileReturn = FileReturn> {
738
+ /**
739
+ * Hook called when a new file is created.
740
+ * @param file The newly created file object.
741
+ * @remarks This hook is called after file metadata is saved but before returning the file.
742
+ * Can be used for side effects like logging, notifications, or custom processing.
743
+ */
744
+ onCreate: (file: TFile) => Promise<void> | void;
745
+ /**
746
+ * Hook called when file metadata is updated.
747
+ * @param file The updated file object.
748
+ * @remarks This hook is called after metadata is updated and saved.
749
+ * Can be used for side effects like logging or custom processing.
750
+ */
751
+ onUpdate: (file: TFile) => Promise<void> | void;
752
+ /**
753
+ * Hook called when a file upload is completed.
754
+ * @param file The completed file object.
755
+ * @param response The response object that can be modified in place (headers, statusCode, body).
756
+ * @param request Optional request object for additional context.
757
+ * @remarks This hook is called when file status becomes "completed".
758
+ * The response object can be modified directly to add headers or change the status code.
759
+ */
760
+ onComplete: (file: TFile, response: unknown, request?: unknown) => Promise<void> | void;
761
+ /**
762
+ * Hook called when a file is deleted.
763
+ * @param file The deleted file object.
764
+ * @remarks This hook is called after the file is deleted but before returning.
765
+ * Can be used for side effects like cleanup or logging.
766
+ */
767
+ onDelete: (file: TFile) => Promise<void> | void;
768
+ /**
769
+ * Hook called when an error occurs during storage operations.
770
+ * @param error The HTTP error object that can be modified in place.
771
+ * @remarks This hook allows customizing error responses by modifying the error object.
772
+ * The error object can be modified to change headers, statusCode, or body properties.
773
+ * Error formatting happens in handlers after this hook is called.
774
+ */
775
+ onError: (error: HttpError) => Promise<void> | void;
776
+ isReady: boolean;
777
+ errorResponses: ErrorResponses;
778
+ cache: Cache<string, TFile>;
779
+ readonly logger?: Console;
780
+ readonly metrics: Metrics;
781
+ readonly genericConfig: BaseStorageOptions<TFile>;
782
+ maxMetadataSize: number;
783
+ checksumTypes: string[];
784
+ maxUploadSize: number;
785
+ protected expiration?: {
786
+ maxAge?: string | number;
787
+ purgeInterval?: string | number;
788
+ rolling?: boolean;
789
+ };
790
+ protected locker: Locker;
791
+ protected namingFunction: (file: TFile) => string;
792
+ protected validation: Validator<TFile>;
793
+ protected abstract meta: MetaStorage<TFile>;
794
+ protected assetFolder: string | undefined;
795
+ /**
796
+ * Limits the number of concurrent upload requests
797
+ */
798
+ protected concurrency?: number;
799
+ protected constructor(config: BaseStorageOptions<TFile>);
800
+ /**
801
+ * Escape hatch returning the underlying native client (S3Client, BlobServiceClient, etc.)
802
+ * for provider-specific operations not covered by the unified API.
803
+ * Returns `undefined` when no native client is available (e.g. DiskStorage).
804
+ */
805
+ get raw(): unknown;
806
+ /**
807
+ * Returns a presigned URL for downloading the object at `key`.
808
+ * Throws `ERRORS.METHOD_NOT_ALLOWED` when the adapter has no native presign support.
809
+ * @param _key Storage key.
810
+ * @param _options Optional expiry and response overrides.
811
+ */
812
+ getReadUrl(_key: string, _options?: {
813
+ expiresIn?: number;
814
+ responseContentDisposition?: string;
815
+ responseContentType?: string;
816
+ }): Promise<string>;
817
+ /**
818
+ * Returns a presigned URL for uploading a single object to `key`.
819
+ * Throws `ERRORS.METHOD_NOT_ALLOWED` when the adapter has no native presign support.
820
+ * @param _key Storage key.
821
+ * @param _options Optional content type, expiry, and content length hints.
822
+ */
823
+ getUploadUrl(_key: string, _options?: {
824
+ contentLength?: number;
825
+ contentType?: string;
826
+ expiresIn?: number;
827
+ }): Promise<string>;
828
+ get tusExtension(): string[];
829
+ /**
830
+ * Validates a file against configured validation rules.
831
+ * @param file File object to validate.
832
+ * @returns Promise resolving to undefined if file is valid, throws ValidationError otherwise.
833
+ * @throws {ValidationError} If validation fails
834
+ */
835
+ validate(file: TFile): Promise<void>;
836
+ /**
837
+ * Checks if a file exists by querying its metadata.
838
+ * @param query File query containing the file ID to check.
839
+ * @param query.id File ID to check.
840
+ * @returns Promise resolving to true if file exists, false otherwise.
841
+ * @remarks This method does not throw errors - it returns false if the file is not found.
842
+ */
843
+ exists(query: FileQuery): Promise<boolean>;
844
+ /**
845
+ * Normalizes errors with storage-specific context.
846
+ * @param error The error to normalize.
847
+ * @returns Normalized HTTP error with storage class context added to the message.
848
+ * @remarks Errors are enhanced with the storage class name for better debugging.
849
+ */
850
+ normalizeError(error: Error): HttpError;
851
+ /**
852
+ * Gets the storage configuration.
853
+ * @returns The current storage configuration options.
854
+ */
855
+ get config(): BaseStorageOptions<TFile>;
856
+ /**
857
+ * Saves upload metadata to the metadata storage.
858
+ * @param file File object containing metadata to save.
859
+ * @returns Promise resolving to the saved file object.
860
+ * @remarks Updates timestamps and caches the file metadata.
861
+ * @throws {UploadError} If `file.id` contains path-traversal sequences, null bytes, or is an absolute path — patterns that could let a local MetaStorage implementation write outside its directory.
862
+ */
863
+ saveMeta(file: TFile): Promise<TFile>;
864
+ /**
865
+ * Rejects ids containing `..` segments, null bytes, or absolute paths — defense-in-depth
866
+ * so any MetaStorage / facade / handler that uses `id` as part of a filesystem path or
867
+ * cross-bucket lookup can't be escaped. Public so the `Files` facade and Fetch handlers
868
+ * can validate user-supplied keys before any adapter call.
869
+ */
870
+ static assertSafeId(id: string): void;
871
+ /**
872
+ * Deletes upload metadata from the metadata storage.
873
+ * @param id File ID whose metadata should be deleted.
874
+ * @returns Promise resolving when metadata is deleted.
875
+ * @remarks Also removes the file from the cache.
876
+ */
877
+ deleteMeta(id: string): Promise<void>;
878
+ /**
879
+ * Retrieves upload metadata by file ID.
880
+ * @param id File ID to retrieve metadata for.
881
+ * @returns Promise resolving to the file metadata object.
882
+ * @throws {UploadError} If the file metadata cannot be found (ERRORS.FILE_NOT_FOUND).
883
+ * @remarks Caches the retrieved metadata for faster subsequent access.
884
+ */
885
+ getMeta(id: string): Promise<TFile>;
886
+ /**
887
+ * Checks if a file has expired and deletes it if so.
888
+ * @param file File object to check for expiration.
889
+ * @returns Promise resolving to the file object if not expired.
890
+ * @throws {UploadError} If the file has expired (ERRORS.GONE).
891
+ * @remarks If the file is expired, it is automatically deleted and the metadata is removed.
892
+ */
893
+ checkIfExpired(file: TFile): Promise<TFile>;
894
+ /**
895
+ * Searches for and purges expired uploads.
896
+ * @param maxAge Maximum age of files to keep (files older than this will be purged).
897
+ * Can be a number (milliseconds) or string (e.g., "1h", "30m", "7d").
898
+ * If not provided, uses the expiration.maxAge from configuration.
899
+ * @returns Promise resolving to a list of purged files.
900
+ * @remarks
901
+ * Errors during individual file deletions are logged but do not stop the purge process.
902
+ * Files with corrupted metadata are skipped with a warning.
903
+ * Uses rolling expiration if configured (based on modifiedAt) or fixed expiration (based on createdAt).
904
+ */
905
+ purge(maxAge?: number | string): Promise<PurgeList>;
906
+ /**
907
+ * Gets an uploaded file by ID.
908
+ * @param query File query containing the file ID to retrieve.
909
+ * @param query.id File ID to retrieve.
910
+ * @returns Promise resolving to the file data including content.
911
+ * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
912
+ * @remarks This method loads the entire file content into memory. For large files, use getStream() instead.
913
+ */
914
+ abstract get({
915
+ id
916
+ }: FileQuery): Promise<TFileReturn>;
917
+ /**
918
+ * Gets an uploaded file as a readable stream for efficient large file handling.
919
+ * @param query File query containing the file ID to stream.
920
+ * @param query.id File ID to stream.
921
+ * @returns Promise resolving to an object containing the stream, headers, and size.
922
+ * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
923
+ * @remarks
924
+ * Default implementation falls back to get() and creates a stream from the buffer.
925
+ * Storage implementations should override this for better streaming performance.
926
+ * Headers include Content-Type, Content-Length, ETag, and Last-Modified.
927
+ */
928
+ getStream({
929
+ id
930
+ }: FileQuery): Promise<{
931
+ headers?: Record<string, string>;
932
+ size?: number;
933
+ stream: Readable;
934
+ }>;
935
+ /**
936
+ * Retrieves a list of uploaded files.
937
+ * @param _limit Maximum number of files to return (default: 1000).
938
+ * @returns Promise resolving to an array of file metadata objects.
939
+ * @throws {Error} If not implemented by the storage backend.
940
+ * @remarks Storage implementations must override this method.
941
+ */
942
+ list(_limit?: number): Promise<TFile[]>;
943
+ /**
944
+ * Updates file metadata with user-provided key-value pairs.
945
+ * @param query File query containing the file ID to update.
946
+ * @param query.id File ID to update.
947
+ * @param metadata Partial file object containing fields to update.
948
+ * @returns Promise resolving to the updated file object.
949
+ * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND).
950
+ * @remarks
951
+ * Supports TTL (time-to-live) option: if metadata contains a 'ttl' field,
952
+ * it will be converted to an 'expiredAt' timestamp.
953
+ * TTL can be a number (milliseconds) or string (e.g., "1h", "30m", "7d").
954
+ */
955
+ update({
956
+ id
957
+ }: FileQuery, metadata: Partial<File>): Promise<TFile>;
958
+ /**
959
+ * Creates a new upload and saves its metadata.
960
+ * @param file File initialization configuration.
961
+ * @returns Promise resolving to the created file object.
962
+ */
963
+ abstract create(file: FileInit): Promise<TFile>;
964
+ /**
965
+ * Writes part and/or returns status of an upload.
966
+ * @param part File part, query, or full file object to write.
967
+ * @returns Promise resolving to the updated file object.
968
+ */
969
+ abstract write(part: FilePart | FileQuery | TFile): Promise<TFile>;
970
+ /**
971
+ * Deletes an upload and its metadata.
972
+ * @param query File query containing the file ID to delete.
973
+ * @param query.id File ID to delete.
974
+ * @returns Promise resolving to the deleted file object with status: "deleted".
975
+ * @throws {UploadError} If the file metadata cannot be found.
976
+ */
977
+ abstract delete(query: FileQuery): Promise<TFile>;
978
+ /**
979
+ * Copies an upload file to a new location.
980
+ * @param name Source file name/ID.
981
+ * @param destination Destination file name/ID.
982
+ * @param options Optional copy options including storage class.
983
+ * @returns Promise resolving to the copied file object.
984
+ * @throws {UploadError} If the source file cannot be found.
985
+ */
986
+ abstract copy(name: string, destination: string, options?: {
987
+ storageClass?: string;
988
+ }): Promise<TFile>;
989
+ /**
990
+ * Moves an upload file to a new location.
991
+ * @param name Source file name/ID.
992
+ * @param destination Destination file name/ID.
993
+ * @returns Promise resolving to the moved file object.
994
+ * @throws {UploadError} If the source file cannot be found.
995
+ */
996
+ abstract move(name: string, destination: string): Promise<TFile>;
997
+ /**
998
+ * Deletes multiple files in a single batch operation.
999
+ * @param ids Array of file IDs to delete.
1000
+ * @returns Promise resolving to batch operation response with successful and failed deletions.
1001
+ * @remarks
1002
+ * Processes all deletions in parallel using Promise.allSettled.
1003
+ * Individual failures do not stop the batch operation.
1004
+ * Each deletion is wrapped in error handling to capture failures.
1005
+ * Metrics are recorded for the batch operation and individual failures.
1006
+ * Returns both successful and failed operations with detailed error information.
1007
+ */
1008
+ deleteBatch(ids: string[]): Promise<BatchOperationResponse<TFile>>;
1009
+ /**
1010
+ * Copies multiple files in a single batch operation.
1011
+ * @param operations Array of copy operations, each containing:
1012
+ * source: Source file ID.
1013
+ * destination: Destination file ID or path.
1014
+ * options: Optional copy options including storage class.
1015
+ * @returns Promise resolving to batch operation response with successful and failed copies.
1016
+ * @remarks
1017
+ * Processes all copies in parallel using Promise.allSettled.
1018
+ * Individual failures do not stop the batch operation.
1019
+ * Each copy operation is wrapped in error handling to capture failures.
1020
+ * Metrics are recorded for the batch operation and individual failures.
1021
+ * Returns both successful and failed operations with detailed error information.
1022
+ */
1023
+ copyBatch(operations: {
1024
+ destination: string;
1025
+ options?: {
1026
+ storageClass?: string;
1027
+ };
1028
+ source: string;
1029
+ }[]): Promise<BatchOperationResponse<TFile>>;
1030
+ /**
1031
+ * Moves multiple files in a single batch operation.
1032
+ * @param operations Array of move operations, each containing:
1033
+ * source: Source file ID.
1034
+ * destination: Destination file ID or path.
1035
+ * @returns Promise resolving to batch operation response with successful and failed moves.
1036
+ * @remarks
1037
+ * Processes all moves in parallel using Promise.allSettled.
1038
+ * Individual failures do not stop the batch operation.
1039
+ * Each move operation is wrapped in error handling to capture failures.
1040
+ * Metrics are recorded for the batch operation and individual failures.
1041
+ * Returns both successful and failed operations with detailed error information.
1042
+ */
1043
+ moveBatch(operations: {
1044
+ destination: string;
1045
+ source: string;
1046
+ }[]): Promise<BatchOperationResponse<TFile>>;
1047
+ /**
1048
+ * Prevent upload from being accessed by multiple requests.
1049
+ * Returns a unique token that must be passed back to `unlock()` so a caller whose lock TTL'd
1050
+ * out cannot accidentally release a newly-acquired lock held by another request.
1051
+ */
1052
+ protected lock(key: string): Promise<string>;
1053
+ protected unlock(key: string, token?: string): Promise<void>;
1054
+ /**
1055
+ * Run a function while holding the lock for `key`. The lock is released even if `fn` throws,
1056
+ * and only released when the caller still owns the lock (token-verified). Public so that
1057
+ * handlers can serialize cross-call read-modify-write sequences on the same upload (e.g.
1058
+ * appending to `_chunks` during chunked PATCH).
1059
+ */
1060
+ withLock<R>(key: string, function_: () => Promise<R>): Promise<R>;
1061
+ protected isUnsupportedChecksum(algorithm?: string): boolean;
1062
+ protected startAutoPurge(purgeInterval: number): void;
1063
+ protected updateTimestamps(file: TFile): TFile;
1064
+ /**
1065
+ * Backend-resolved retry configuration that {@link runOperation} layers
1066
+ * per-call overrides on top of. Subclasses that build a `RetryConfig`
1067
+ * (S3, Azure, Netlify, …) override this; the default (`undefined`) makes
1068
+ * `runOperation` fall back to the retry engine's own defaults.
1069
+ */
1070
+ protected getRetryConfig(): RetryConfig | undefined;
1071
+ /**
1072
+ * Runs a backend SDK call with per-operation cancellation, timeout and
1073
+ * retry handling.
1074
+ *
1075
+ * The provided `signal` is the merge of the caller's `options.signal` and
1076
+ * a fresh per-attempt `options.timeout` deadline (via `AbortSignal.any` /
1077
+ * `AbortSignal.timeout`). Pass it to the underlying SDK so the provider
1078
+ * request is actually cancelled rather than merely abandoned.
1079
+ *
1080
+ * Aborted or timed-out calls are never retried. Pass
1081
+ * `{ replayable: false }` for operations whose body is a one-shot stream —
1082
+ * a consumed `Readable`/`ReadableStream` cannot be safely re-sent, so the
1083
+ * retry count is forced to zero.
1084
+ * @param options Per-call overrides (`signal`, `timeout`, `retries`).
1085
+ * @param function_ Receives the merged abort signal for the attempt.
1086
+ * @param operationConfig `replayable: false` disables retries for non-replayable bodies.
1087
+ */
1088
+ protected runOperation<T>(options: OperationOptions | undefined, function_: (signal: AbortSignal | undefined) => Promise<T>, operationConfig?: {
1089
+ replayable?: boolean;
1090
+ }): Promise<T>;
1091
+ /**
1092
+ * Instruments a storage operation with metrics and error tracking.
1093
+ * @param operation Operation name (e.g., "create", "delete", "copy").
1094
+ * @param function_ The operation function to execute.
1095
+ * @param attributes Additional attributes to include in metrics.
1096
+ * @returns Promise resolving to the operation result.
1097
+ * @throws Re-throws any errors from the operation function.
1098
+ * @remarks
1099
+ * Records operation count, duration, and error metrics.
1100
+ * Tracks file sizes for operations returning file objects.
1101
+ * Error metrics include error messages for debugging.
1102
+ * All public methods should use this wrapper for consistent instrumentation.
1103
+ */
1104
+ protected instrumentOperation<T>(operation: string, function_: () => Promise<T>, attributes?: Record<string, string | number>): Promise<T>;
1105
+ }
1106
+ export { throwErrorCode as $, RangeChecksum as A, BaseStorage as B, RangeHasher as C, DiskStorageOptions as D, ERRORS as E, File as F, ResponseBody as G, HttpError as H, IncomingMessageWithBody as I, ResponseTuple as J, UploadResponse as K, LocalMetaStorageOptions as L, MetaStorage as M, ValidationError as N, OperationOptions as O, PurgeList as P, ValidatorConfig as Q, RetryConfig as R, defaultCloudStorageFileNameValidation as S, defaultFilesystemFileNameValidation as T, UploadFile as U, Validation as V, extractHttpStatus as W, isRetryableError as X, isUploadError as Y, mapStatusToErrorCode as Z, retry as _, FileReturn as a, wrapStorageError as a0, Cache as a1, UploadError as b, UploadEventType as c, createRetryWrapper as d, FileInit as e, FilePart as f, FileQuery as g, DiskStorageWithChecksumOptions as h, BaseStorageOptions as i, ResponseBodyType as j, ErrorResponses as k, Metrics as l, BatchOperationResponse as m, BatchOperationResult as n, ErrorMap as o, ExpirationOptions as p, Header as q, Headers as r, HttpErrorBody as s, MetaStorageOptions as t, Metadata as u, OnComplete as v, OnCreate as w, OnDelete as x, OnError as y, OnUpdate as z };