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

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 +385 -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-DbQrK9m7.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-Cmr0nPDq.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-DYzAYPIr.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-BvaFeKeu.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-DsQndiy5.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-DiK0T7N7.js +1 -0
  50. package/dist/packem_shared/DiskStorage-RvZNMWe7.js +1 -0
  51. package/dist/packem_shared/DiskStorageWithChecksum-eGOV3leX.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-Dfd78aJL.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-CtggibJ-.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-C-FwZOYA.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-DzaP89bG.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-DFIjFmn-.js +1 -0
  67. package/dist/packem_shared/GCStorage-1vA3xkFO.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-D_RaKV_j.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-C6Mw7V9W.js +1 -0
  76. package/dist/packem_shared/Multipart-DkH4QwNs.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-C-IkXF0_.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-C7rqK2Wp.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-Cdgr5w88.js +1 -0
  88. package/dist/packem_shared/Rest-DWrS4Z_j.js +1 -0
  89. package/dist/packem_shared/Rest-DY1neM_3.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-Dn3l4WkO.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-CBW6MBLV.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-r934t5HX.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-DMRhLPNo.js +1 -0
  102. package/dist/packem_shared/TUS_RESUMABLE-B7KtPVeC.js +1 -0
  103. package/dist/packem_shared/Tus-BMd67Cnb.js +1 -0
  104. package/dist/packem_shared/Tus-d2hPK5nV.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-BjF_gRMY.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-Dx2jywjl.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-Cwd9uq_E.js +1 -0
  122. package/dist/packem_shared/base-handler-fetch-_BD4V1W2.js +1 -0
  123. package/dist/packem_shared/base-handler-node-BDNRnVIc.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-hWLdEgOD.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-Bmvawf-b.js +1 -0
  132. package/dist/packem_shared/disk-storage-with-checksum.d-Dm4agCey.d.ts +150 -0
  133. package/dist/packem_shared/executors-DG6hGtvm.js +1 -0
  134. package/dist/packem_shared/executors.d-Cut3Gstb.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-Bwts-MUe.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-DSZjPbvW.d.ts +230 -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-qZQI1JUe.d.ts +21 -0
  152. package/dist/packem_shared/media-transformer.d-lQ_RUjb5.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-C-a7pXUc.js +1 -0
  163. package/dist/packem_shared/restOpenApiSpec-PaIVbESh.js +1 -0
  164. package/dist/packem_shared/s3-base-storage-Ek1HinGR.js +1 -0
  165. package/dist/packem_shared/s3-base-storage.d-CDIOMTpp.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-B-NDsI-o.js +1 -0
  169. package/dist/packem_shared/storage.d-BoJgdi1n.d.ts +1111 -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-C28C_AY9.d.ts +99 -0
  175. package/dist/packem_shared/tusOpenApiSpec-DF0-hlWV.js +1 -0
  176. package/dist/packem_shared/types.d-C0MDnUYc.d.ts +104 -0
  177. package/dist/packem_shared/types.d-CPxJpoPH.d.ts +49 -0
  178. package/dist/packem_shared/types.d-DCPQvHDI.d.ts +720 -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 @@
1
+ var d=Object.defineProperty;var o=(e,t)=>d(e,"name",{value:t,configurable:!0});var h=Object.defineProperty,a=o((e,t)=>h(e,"name",{value:t,configurable:!0}),"r");const k=a(e=>{let t;const c=e.leewayMs??6e4;return{getAccessToken:a(async()=>{const s=Date.now();if(t&&t.expiresOnMs-c>s)return t.token;const n=await fetch(e.tokenUrl,{body:e.buildBody(),headers:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST"});if(!n.ok){const i=await n.text().catch(()=>"");throw new Error(`${e.provider}: token exchange failed (${n.status}): ${i||n.statusText}`)}const r=await n.json();if(!r.access_token)throw new Error(`${e.provider}: token response missing access_token`);return t={expiresOnMs:s+(r.expires_in??3600)*1e3,token:r.access_token},e.onRefresh?.(r.access_token),r.access_token},"refresh")}},"createOAuthRefreshHandle");export{k as c};
@@ -0,0 +1 @@
1
+ var E=Object.defineProperty;var C=(e,r)=>E(e,"name",{value:r,configurable:!0});var t=Object.defineProperty,n=C((e,r)=>t(e,"name",{value:r,configurable:!0}),"C");const a=n(e=>{const r=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.ORACLE_CLOUD_ACCESS_KEY_ID??process.env.ORACLE_CLOUD_ACCESS_KEY,c=e?.namespace??process.env.ORACLE_CLOUD_NAMESPACE,s=e?.region??process.env.ORACLE_CLOUD_REGION,o=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.ORACLE_CLOUD_SECRET_ACCESS_KEY??process.env.ORACLE_CLOUD_SECRET_KEY;if(!c||!s||!r||!o)throw new Error("Missing required parameters for Oracle Cloud Object Storage client.");return{credentials:{accessKeyId:r,secretAccessKey:o},endpoint:`https://${c}.compat.objectstorage.${s}.oraclecloud.com`,forcePathStyle:!0,region:s}},"oracleCloud");export{a as default};
@@ -0,0 +1 @@
1
+ var C=Object.defineProperty;var n=(e,s)=>C(e,"name",{value:s,configurable:!0});var E=Object.defineProperty,_=n((e,s)=>E(e,"name",{value:s,configurable:!0}),"r");const S=_(e=>{const s=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.OVHCLOUD_ACCESS_KEY_ID??process.env.OVHCLOUD_ACCESS_KEY,t=e?.endpoint??process.env.OVHCLOUD_ENDPOINT,r=e?.region??process.env.OVHCLOUD_REGION,o=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.OVHCLOUD_SECRET_ACCESS_KEY??process.env.OVHCLOUD_SECRET_KEY;if(!r||!s||!o)throw new Error("Missing required parameters for OVHcloud Object Storage client.");const c=r.toLowerCase();return{credentials:{accessKeyId:s,secretAccessKey:o},endpoint:t??`https://s3.${c}.io.cloud.ovh.net`,forcePathStyle:!1,region:c}},"ovhCloud");export{S as default};
@@ -0,0 +1 @@
1
+ var i=Object.defineProperty;var r=(e,t)=>i(e,"name",{value:t,configurable:!0});var a=Object.defineProperty,s=r((e,t)=>a(e,"name",{value:t,configurable:!0}),"t");const v=s(e=>e.bytesWritten===e.size?"completed":e.createdAt?"part":"created","getFileStatus");var n=Object.defineProperty,o=r((e,t)=>n(e,"name",{value:t,configurable:!0}),"i");const z=o((e,t)=>e.size!==void 0&&t.size!==void 0&&e.size>0&&t.size>0&&e.size>t.size?!1:t.size===void 0?!0:(e.start||0)+(e.contentLength||0)<=t.size,"partMatch");export{v as o,z as r};
@@ -0,0 +1 @@
1
+ var Vt=Object.defineProperty;var he=(s,u)=>Vt(s,"name",{value:u,configurable:!0});var Ht=Object.defineProperty,Jt=he((s,u)=>Ht(s,"name",{value:u,configurable:!0}),"$e"),Kt=Object.defineProperty,V=Jt((s,u)=>Kt(s,"name",{value:u,configurable:!0}),"W"),Qt=Object.defineProperty,a=V((s,u)=>Qt(s,"name",{value:u,configurable:!0}),"u$1");let ge=a(()=>{var s=(()=>{var u=Object.defineProperty,c=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,b=a((e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},"ne"),A=a((e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of p(t))!g.call(e,r)&&r!==n&&u(e,r,{get:a(()=>t[r],"get"),enumerable:!(o=c(t,r))||o.enumerable});return e},"ae"),m=a(e=>A(u({},"__esModule",{value:!0}),e),"oe"),P={};b(P,{zeptomatch:a(()=>pe,"zeptomatch")});var H=a(e=>{const t=new Set,n=[e];for(let o=0;o<n.length;o++){const r=n[o];if(t.has(r))continue;t.add(r);const{children:l}=r;if(l?.length)for(let i=0,h=l.length;i<h;i++)n.push(l[i])}return Array.from(t)},"M"),be=a(e=>{let t="";const n=H(e);for(let o=0,r=n.length;o<r;o++){const l=n[o];if(!l.regex)continue;const i=l.regex.flags;if(t||(t=i),t!==i)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${i}"`)}return t},"se"),J=a((e,t,n)=>{const o=n.get(e);if(o!==void 0)return o;const r=e.partial??t;let l="";if(e.regex&&(l+=r?"(?:$|":"",l+=e.regex.source),e.children?.length){const i=ve(e.children.map(h=>J(h,t,n)).filter(Boolean));if(i?.length){const h=e.children.some(W=>!W.regex||!(W.partial??t)),x=i.length>1||r&&(!l.length||h);l+=x?r?"(?:$|":"(?:":"",l+=i.join("|"),l+=x?")":""}}return e.regex&&(l+=r?")":""),n.set(e,l),l},"O"),we=a((e,t)=>{const n=new Map,o=H(e);for(let r=o.length-1;r>=0;r--){const l=J(o[r],t,n);if(!(r>0))return l}return""},"ie"),ve=a(e=>Array.from(new Set(e)),"ue"),S=a((e,t,n)=>S.compile(e,n).test(t),"R");S.compile=(e,t)=>{const n=t?.partial??!1,o=we(e,n),r=be(e);return new RegExp(`^(?:${o})$`,r)};var ye=S,je=a((e,t)=>{const n=ye.compile(e,t),o=`${n.source.slice(0,-1)}[\\\\/]?$`,r=n.flags;return new RegExp(o,r)},"le"),Me=je,Ae=a(e=>{const t=e.map(o=>o.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),ze=Ae,K=a(e=>Array.isArray(e),"j"),R=a(e=>typeof e=="function","_"),ke=a(e=>e.length===0,"he"),Oe=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),Ee=a(e=>typeof e=="number","de"),Ie=a(e=>typeof e=="object"&&e!==null,"xe"),Pe=a(e=>e instanceof RegExp,"me"),Re=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),Be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),Q=a(e=>typeof e=="string","A"),y=a(e=>e===void 0,"f"),We=a(e=>{const t=new Map;return n=>{const o=t.get(n);if(o!==void 0)return o;const r=e(n);return t.set(n,r),r}},"ye"),T=a((e,t,n={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},r=j(t)(o),l=Math.max(o.index,o.indexBacktrackMax);if(r&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${l}`)},"I"),f=a((e,t)=>K(e)?Ze(e,t):Q(e)?X(e,t):_e(e,t),"i"),Ze=a((e,t)=>{const n={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const r=o.charCodeAt(0);n[r]=!0}return o=>{const r=o.input;let l=o.index,i=l;for(;i<r.length&&r.charCodeAt(i)in n;)i+=1;if(i>l){if(!y(t)&&!o.options.silent){const h=r.slice(l,i),x=R(t)?t(h,r,`${l}`):t;y(x)||o.output.push(x)}o.index=i}return!0}},"we"),_e=a((e,t)=>{if(Be(e))return X(e.source,t);{const n=e.source,o=e.flags.replace(/y|$/,"y"),r=new RegExp(n,o);return Re(e)&&R(t)&&!Oe(t)?Ce(r,t):Se(r,t)}},"$e"),Ce=a((e,t)=>n=>{const o=n.index,r=n.input;e.lastIndex=o;const l=e.exec(r);if(l){const i=e.lastIndex;if(!n.options.silent){const h=t(...l,r,`${o}`);y(h)||n.output.push(h)}return n.index=i,!0}else return!1},"Ee"),Se=a((e,t)=>n=>{const o=n.index,r=n.input;if(e.lastIndex=o,e.test(r)){const l=e.lastIndex;if(!y(t)&&!n.options.silent){const i=R(t)?t(r.slice(o,l),r,`${o}`):t;y(i)||n.output.push(i)}return n.index=l,!0}else return!1},"Ce"),X=a((e,t)=>n=>{const o=n.index,r=n.input;if(r.startsWith(e,o)){if(!y(t)&&!n.options.silent){const l=R(t)?t(e,r,`${o}`):t;y(l)||n.output.push(l)}return n.index+=e.length,!0}else return!1},"F"),q=a((e,t,n,o)=>{const r=j(e),l=t>1;return F(L(ee(i=>{let h=0;for(;h<n;){const x=i.index;if(!r(i)||(h+=1,i.index===x))break}return h>=t},l),o))},"k"),Y=a((e,t)=>q(e,0,1,t),"L"),C=a((e,t)=>q(e,0,1/0,t),"$"),qe=a((e,t)=>q(e,1,1/0,t),"Re"),O=a((e,t)=>{const n=e.map(j);return F(L(ee(o=>{for(let r=0,l=n.length;r<l;r++)if(!n[r](o))return!1;return!0}),t))},"x"),w=a((e,t)=>{const n=e.map(j);return F(L(o=>{for(let r=0,l=n.length;r<l;r++)if(n[r](o))return!0;return!1},t))},"p"),ee=a((e,t=!0,n=!1)=>{const o=j(e);return t?r=>{const l=r.index,i=r.output.length,h=o(r);return!h&&!n&&(r.indexBacktrackMax=Math.max(r.indexBacktrackMax,r.index)),(!h||n)&&(r.index=l,r.output.length!==i&&(r.output.length=i)),h}:o},"q"),L=a((e,t)=>{const n=j(e);return t?o=>{if(o.options.silent)return n(o);const r=o.output.length;if(n(o)){const l=o.output.splice(r,1/0),i=t(l);return y(i)||o.output.push(i),!0}else return!1}:n},"B"),F=(()=>{let e=0;return t=>{const n=j(t),o=e+=1;return r=>{var l;if(r.options.memoization===!1)return n(r);const i=r.index,h=(l=r.cache)[o]||(l[o]={indexMax:-1,queue:[]}),x=h.queue;if(i<=h.indexMax){const Z=h.store||(h.store=new Map);if(x.length){for(let I=0,Gt=x.length;I<Gt;I+=2){const Ut=x[I*2],Dt=x[I*2+1];Z.set(Ut,Dt)}x.length=0}const v=Z.get(i);if(v===!1)return!1;if(Ee(v))return r.index=v,!0;if(v)return r.index=v.index,v.output?.length&&r.output.push(...v.output),!0}const W=r.output.length,Nt=n(r);if(h.indexMax=Math.max(h.indexMax,i),Nt){const Z=r.index,v=r.output.length;if(v>W){const I=r.output.slice(W,v);x.push(i,{index:Z,output:I})}else x.push(i,Z);return!0}else return x.push(i,!1),!1}}})(),te=a(e=>{let t;return n=>(t||(t=j(e())),t(n))},"G"),j=We(e=>{if(R(e))return ke(e)?te(e):e;if(Q(e)||Pe(e))return f(e);if(K(e))return O(e);if(Ie(e))return w(Object.values(e));throw new Error("Invalid rule")}),z=a(e=>e,"d"),Le=a(e=>typeof e=="string","ke"),Fe=a(e=>{const t=new WeakMap,n=new WeakMap;return(o,r)=>{const l=r?.partial?n:t,i=l.get(o);if(i!==void 0)return i;const h=e(o,r);return l.set(o,h),h}},"Be"),Ne=a(e=>{const t={},n={};return(o,r)=>{const l=r?.partial?n:t;return l[o]??(l[o]=e(o,r))}},"Pe"),Ge=f(/\\./,z),Ue=f(/./,z),De=f(/\*\*\*+/,"*"),Ve=f(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),He=f(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),Je=C(w([Ge,De,Ve,He,Ue])),Ke=Je,Qe=a(e=>T(e,Ke,{memoization:!1}).join(""),"Ie"),Te=Qe,ne="abcdefghijklmnopqrstuvwxyz",Xe=a(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ne[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),re=a(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t=t*26+ne.indexOf(e[n])+1;return t},"V"),N=a((e,t)=>{if(t<e)return N(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),Ye=a((e,t,n)=>N(e,t).map(o=>String(o).padStart(n,"0")),"qe"),oe=a((e,t)=>N(re(e),re(t)).map(Xe),"W"),d=a(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),B=a(e=>({children:e}),"y"),E=(()=>{const e=a((t,n,o)=>{if(o.has(t))return;o.add(t);const{children:r}=t;if(!r.length)r.push(n);else for(let l=0,i=r.length;l<i;l++)e(r[l],n,o)},"e");return t=>{if(!t.length)return B([]);for(let n=t.length-1;n>=1;n--){const o=new Set,r=t[n-1],l=t[n];e(r,l,o)}return t[0]}})(),M=a(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),et=f(/\\./,d),tt=f(/[$.*+?^(){}[\]\|]/,e=>d(`\\${e}`)),nt=f(/[\\\/]/,M),rt=f(/[^$.*+?^(){}[\]\|\\\/]+/,d),ot=f(/^(?:!!)*!(.*)$/,(e,t)=>d(`(?!^${pe.compile(t).source}$).*?`)),st=f(/^(!!)+/),lt=w([ot,st]),ut=f(/\/(\*\*\/)+/,()=>B([E([M(),d(".+?"),M()]),M()])),at=f(/^(\*\*\/)+/,()=>B([d("^"),E([d(".*?"),M()])])),ct=f(/\/(\*\*)$/,()=>B([E([M(),d(".*?")]),d("$")])),it=f(/\*\*/,()=>d(".*?")),se=w([ut,at,ct,it]),ft=f(/\*\/(?!\*\*\/|\*$)/,()=>E([d("[^\\\\/]*?"),M()])),pt=f(/\*/,()=>d("[^\\\\/]*")),le=w([ft,pt]),ue=f("?",()=>d("[^\\\\/]")),ht=f("[",z),gt=f("]",z),dt=f(/[!^]/,"^\\\\/"),xt=f(/[a-z]-[a-z]|[0-9]-[0-9]/i,z),$t=f(/\\./,z),mt=f(/[$.*+?^(){}[\|]/,e=>`\\${e}`),bt=f(/[\\\/]/,"\\\\/"),wt=f(/[^$.*+?^(){}[\]\|\\\/]+/,z),vt=w([$t,mt,bt,xt,wt]),ae=O([ht,Y(dt),C(vt),gt],e=>d(e.join(""))),yt=f("{","(?:"),jt=f("}",")"),Mt=f(/(\d+)\.\.(\d+)/,(e,t,n)=>Ye(+t,+n,Math.min(t.length,n.length)).join("|")),At=f(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>oe(t,n).join("|")),zt=f(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>oe(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),kt=w([Mt,At,zt]),ce=O([yt,kt,jt],e=>d(e.join(""))),Ot=f("{"),Et=f("}"),It=f(","),Pt=f(/\\./,d),Rt=f(/[$.*+?^(){[\]\|]/,e=>d(`\\${e}`)),Bt=f(/[\\\/]/,M),Wt=f(/[^$.*+?^(){}[\]\|\\\/,]+/,d),Zt=te(()=>fe),_t=f("",()=>d("(?:)")),Ct=qe(w([se,le,ue,ae,ce,Zt,Pt,Rt,Bt,Wt]),E),ie=w([Ct,_t]),fe=O([Ot,Y(O([ie,C(O([It,ie]))])),Et],B),St=C(w([lt,se,le,ue,ae,ce,fe,et,tt,nt,rt]),E),qt=St,Lt=a(e=>T(e,qt,{memoization:!1})[0],"kr"),Ft=Lt,G=a((e,t,n)=>G.compile(e,n).test(t),"N");G.compile=(()=>{const e=Ne((n,o)=>Me(Ft(Te(n)),o)),t=Fe((n,o)=>ze(n.map(r=>e(r,o))));return(n,o)=>Le(n)?e(n,o):t(n,o)})();var pe=G;return m(P)})();return s.default||s},"_lazyMatch"),U;const Tt=a((s,u)=>(U||(U=ge(),ge=null),U(s,u)),"default");var Xt=Object.defineProperty,Yt=V((s,u)=>Xt(s,"name",{value:u,configurable:!0}),"t$1");const en=/^[A-Z]:\//i,k=Yt((s="")=>s&&s.replaceAll("\\","/").replace(en,u=>u.toUpperCase()),"normalizeWindowsPath");var tn=Object.defineProperty,$=V((s,u)=>tn(s,"name",{value:u,configurable:!0}),"r");const nn=/^[/\\]{2}/,rn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,xe=/^[A-Z]:$/i,de=/^\/([A-Z]:)?$/i,on=/.(\.[^./]+)$/,sn=/^[/\\]|^[a-z]:[/\\]/i,ln=/\/$/,un=$(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),$e=$((s,u)=>{let c="",p=0,g=-1,b=0,A;for(let m=0;m<=s.length;++m){if(m<s.length)A=s[m];else{if(A==="/")break;A="/"}if(A==="/"){if(!(g===m-1||b===1))if(b===2){if(c.length<2||p!==2||!c.endsWith(".")||c.at(-2)!=="."){if(c.length>2){const P=c.lastIndexOf("/");P===-1?(c="",p=0):(c=c.slice(0,P),p=c.length-1-c.lastIndexOf("/")),g=m,b=0;continue}else if(c.length>0){c="",p=0,g=m,b=0;continue}}u&&(c+=c.length>0?"/..":"..",p=2)}else c.length>0?c+=`/${s.slice(g+1,m)}`:c=s.slice(g+1,m),p=m-g-1;g=m,b=0}else A==="."&&b!==-1?++b:b=-1}return c},"normalizeString"),_=$(s=>rn.test(s),"isAbsolute"),me=$(function(s){if(s.length===0)return".";s=k(s);const u=nn.exec(s),c=_(s),p=s.at(-1)==="/";return s=$e(s,!c),s.length===0?c?"/":p?"./":".":(p&&(s+="/"),xe.test(s)&&(s+="/"),u?c?`//${s}`:`//./${s}`:c&&!_(s)?`/${s}`:s)},"normalize"),hn=$((...s)=>{let u="";for(const c of s)if(c)if(u.length>0){const p=u.at(-1)==="/",g=c[0]==="/";p&&g?u+=c.slice(1):u+=p||g?c:`/${c}`}else u+=c;return me(u)},"join"),D=$(function(...s){s=s.map(p=>k(p));let u="",c=!1;for(let p=s.length-1;p>=-1&&!c;p--){const g=p>=0?s[p]:un();!g||g.length===0||(u=`${g}/${u}`,c=_(g))}return u=$e(u,!c),c&&!_(u)?`/${u}`:u.length>0?u:"."},"resolve");$(function(s){return k(s)},"toNamespacedPath");const an=$(function(s){return on.exec(k(s))?.[1]??""},"extname");$(function(s,u){const c=D(s).replace(de,"$1").split("/"),p=D(u).replace(de,"$1").split("/");if(p[0][1]===":"&&c[0][1]===":"&&c[0]!==p[0])return p.join("/");const g=[...c];for(const b of g){if(p[0]!==b)break;c.shift(),p.shift()}return[...c.map(()=>".."),...p].join("/")},"relative");const cn=$(s=>{const u=k(s).replace(ln,"").split("/").slice(0,-1);return u.length===1&&xe.test(u[0])&&(u[0]=`${u[0]}/`),u.join("/")||(_(s)?"/":".")},"dirname");$(function(s){const u=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return k(s.root?D(...u):u.join("/"))},"format");const fn=$((s,u)=>{const c=k(s).split("/").pop();return u&&c.endsWith(u)?c.slice(0,-u.length):c},"basename");$(function(s){const u=sn.exec(s)?.[0]?.replaceAll("\\","/")??"",c=fn(s),p=an(c);return{base:c,dir:cn(s),ext:p,name:c.slice(0,c.length-p.length),root:u}},"parse");$((s,u)=>Tt(u,me(s)),"matchesGlob");export{k as A,D as C,an as J,cn as K,me as L,hn as M,_ as O,fn as Q};
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var a=(r,e)=>n(r,"name",{value:e,configurable:!0});var o=Object.defineProperty,s=a((r,e)=>o(r,"name",{value:e,configurable:!0}),"e$1");const m=s(async r=>{const e=[];for await(const t of r)e.push(Buffer.from(t));return Buffer.concat(e)},"collectStream");var c=Object.defineProperty,i=a((r,e)=>c(r,"name",{value:e,configurable:!0}),"r");const f=i(r=>{let e=0,t=r.length;for(;e<t&&r[e]==="/";)e+=1;for(;t>e&&r[t-1]==="/";)t-=1;return e===0&&t===r.length?r:r.slice(e,t)},"trimSlashes");var l=Object.defineProperty,u=a((r,e)=>l(r,"name",{value:e,configurable:!0}),"i");const b=u(r=>{const e=f(r),t=e.lastIndexOf("/");return t<=0?r.startsWith("/")&&t===0?"/":"":r.startsWith("/")?`/${e.slice(0,t)}`:e.slice(0,t)},"posixDirname");export{f as i,m as n,b as o};
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var l=(e,r)=>u(e,"name",{value:r,configurable:!0});import g from"mime";import{H as s}from"./headers-DC2MEOrK.js";var f=Object.defineProperty,o=l((e,r)=>f(e,"name",{value:r,configurable:!0}),"i");const a="Content-Type",b=o((e,r={},t=200)=>({...e,headers:r,statusCode:t}),"buildResponseFile"),T=o((e,r,t={})=>({Location:r,...e.expiredAt===void 0?{}:{"X-Upload-Expires":e.expiredAt.toString()},...e.ETag===void 0?{}:{ETag:e.ETag},...t}),"buildFileHeaders"),v=o((e,r)=>{const t=e.metadata||{},n={"x-chunked-upload":"true","x-upload-complete":r?"true":"false","x-upload-offset":String(e.bytesWritten||0)};return Array.isArray(t._chunks)&&t._chunks.length>0&&(n["x-received-chunks"]=JSON.stringify(t._chunks)),n},"buildChunkedUploadHeaders");o((e,r,t,n,i)=>{const c=new URL(e||"/","http://localhost"),{pathname:p}=c,d=`${p}/${r}.${g.getExtension(t)}`;return n?d:`${i||""}${d}`},"buildLocationHeader");const x=o(e=>({"Content-Length":String(e.size||0),"Content-Type":e.contentType,...e.expiredAt===void 0?{}:{"X-Upload-Expires":e.expiredAt.toString()},...e.modifiedAt===void 0?{}:{"Last-Modified":e.modifiedAt.toString()},...e.ETag===void 0?{}:{ETag:e.ETag}}),"buildFileMetadataHeaders"),E=o(e=>{const r={};for(const[t,n]of Object.entries(e))r[t]=Array.isArray(n)?n.join(", "):String(n);return r},"convertHeadersToString");o(e=>({error:{code:e.code||e.name||"Error",message:e.message||"Unknown error",name:e.name||"Error"}}),"buildErrorResponseBody");o((e,r={})=>{const t={...r};let n;if(typeof e=="string"){if(n=e,t[a]===void 0)t[a]=s.createContentType({mediaType:"text/plain"});else{const i=Array.isArray(t[a])?t[a].join(", "):String(t[a]);t[a]=s.ensureCharset(i)}t["Content-Length"]===void 0&&(t["Content-Length"]=Buffer.byteLength(e))}else e instanceof Buffer?n=e:(n=JSON.stringify(e||{}),t[a]||(t[a]=s.createContentType({charset:"utf8",mediaType:"application/json"})));return{data:n,headers:t}},"prepareResponseBody");o(e=>{const r={...e};return"content"in r&&delete r.content,"stream"in r&&delete r.stream,r},"cleanFileData");export{T as a,b,v as c,x as d,E as e};
@@ -0,0 +1 @@
1
+ var E=Object.defineProperty;var y=(a,t)=>E(a,"name",{value:t,configurable:!0});import{n as u}from"./headers-DC2MEOrK.js";import{hasBody as X}from"type-is";import{a as c}from"./base-handler-core-Cwd9uq_E.js";import{ERRORS as A}from"./ERRORS-CyOuSMLY.js";import{b,a as z,c as v,d as L}from"./response-builder-Wdo_fvcF.js";var T=Object.defineProperty,f=y((a,t)=>T(a,"name",{value:t,configurable:!0}),"a$1");const D=f((a,t={})=>{const e=c(a,"x-file-metadata",!0);if(!e)return t;try{return{...t,...JSON.parse(e)}}catch{return t}},"parseMetadata"),P=f(a=>{if(!a)return;const t=2e3,e=a.length>t?a.slice(0,Math.max(0,t)):a,r=e.toLowerCase().indexOf("filename");if(r===-1)return;let s=r+8;for(;s<e.length&&(e[s]==="*"||e[s]===" "||e[s]===" ");)s++;if(s>=e.length||e[s]!=="=")return;for(s++;s<e.length&&(e[s]===" "||e[s]===" ");)s++;if(s>=e.length)return;let n=s,o;const i=e[s];return i==='"'||i==="'"?(n=s+1,o=e.indexOf(i,n),o===-1&&(o=e.indexOf(";",n),o===-1&&(o=e.length))):(o=e.indexOf(";",n),o===-1&&(o=e.length)),n>=o?void 0:e.substring(n,o).trim()||void 0},"parseContentDispositionValue"),I=f(a=>{const t=c(a,"content-disposition",!0);return P(t)},"parseContentDisposition"),R=f(a=>{const t=c(a,"x-chunked-upload",!0)==="true",e=c(a,"x-chunk-offset",!0),r=c(a,"x-total-size",!0),s={isChunkedUpload:t};if(e){const n=Number.parseInt(e,10);!Number.isNaN(n)&&n>=0&&(s.chunkOffset=n)}if(r){const n=Number.parseInt(r,10);!Number.isNaN(n)&&n>0&&(s.totalSize=n)}return s},"parseChunkHeaders"),Z=f((a,t=!1)=>{const e=c(a,"x-chunked-upload",!0)==="true";if(!(t&&e)){if(!X(a))throw u(400,"Request body is required");if(Number.parseInt(c(a,"content-length")||"0",10)===0&&!e)throw u(400,"Content-Length is required and must be greater than 0")}},"validateRequestBody"),ee=f((a,t=!1,e)=>{const r=c(a,"x-chunked-upload",!0)==="true",s=Number.parseInt(c(a,"content-length")||"0",10);if(!t&&!r&&s===0)throw u(400,"Content-Length is required and must be greater than 0");if(e!==void 0&&s>e)throw u(413,`File size exceeds maximum allowed size of ${e} bytes`);return s},"validateContentLength"),te=f((a,t,e="application/octet-stream")=>{const r=I(a),s=D(a),{isChunkedUpload:n,totalSize:o}=R(a),i=n&&o?o:t;return n&&o&&(s._chunkedUpload=!0,s._chunks=[],s._totalSize=o),{contentType:e,metadata:s,originalName:r,size:i}},"extractFileInit");f((a,t,e)=>{if(Number.isNaN(a)||a<0)throw u(400,"X-Chunk-Offset must be a valid non-negative number");if(a+t>e)throw u(400,`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk");f((a,t="application/octet-stream")=>c(a,"content-type")||t,"getContentType");var W=Object.defineProperty,g=y((a,t)=>W(a,"name",{value:t,configurable:!0}),"a");const N=g((a,t)=>{if(a.length===0)return!1;const e=[...a].toSorted((n,o)=>n.offset-o.offset),r=e[0];if(r?.offset!==0)return!1;let s=r.length;for(let n=1;n<e.length;n+=1){const o=e[n];if(o){if(o.offset>s)return!1;s=Math.max(s,o.offset+o.length)}}return s>=t},"isUploadComplete"),H=g((a,t,e,r)=>{if(Number.isNaN(a)||a<0)throw new Error("Chunk offset must be a valid non-negative number");if(t<=0)throw new Error("Chunk length must be greater than 0");if(r!==void 0&&t>r)throw new Error(`Chunk size exceeds maximum allowed size of ${r} bytes`);if(a+t>e)throw new Error(`Chunk exceeds file size. Offset: ${a}, Size: ${t}, Total: ${e}`)},"validateChunk"),B=g((a,t)=>{const e=a.find(r=>r.offset===t.offset&&r.length===t.length);return e?t.checksum&&e.checksum!==t.checksum?a.map(r=>r.offset===t.offset?{...r,checksum:t.checksum}:r):a:[...a,t]},"trackChunk"),j=g((a,t)=>{if(a.length===0||t===0)return{bytesWritten:0,percentage:0};const e=[...a].toSorted((o,i)=>o.offset-i.offset);let r=0,s=0;for(const o of e){const i=o.offset+o.length;o.offset<=s?r=Math.max(r,i):r+=o.length,s=Math.max(s,i)}r=Math.min(r,t);const n=t>0?r/t*100:0;return{bytesWritten:r,percentage:n}},"calculateUploadProgress");g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&Array.isArray(t._chunks)){const e=typeof t._totalSize=="number"?t._totalSize:a.size||0;return j(t._chunks,e).bytesWritten}return a.bytesWritten||0},"getBytesWritten");const _=g(a=>(a.metadata||{})._chunkedUpload===!0,"isChunkedUpload"),U=g(a=>{const t=a.metadata||{};if(t._chunkedUpload===!0&&typeof t._totalSize=="number")return t._totalSize},"getTotalSize");var q=Object.defineProperty,$=y((a,t)=>q(a,"name",{value:t,configurable:!0}),"y");class ae{static{y(this,"M")}static{$(this,"RestBase")}async deleteSingle(t){const e=await this.storage.delete({id:t});if(e.status===void 0)throw u(404,"File not found");return{...e,headers:{},statusCode:204}}async handlePost(t,e,r,s,n){if(e&&t.size!==void 0){const d=typeof t.size=="number"?t.size:Number.parseInt(String(t.size),10);if(d>0&&d>this.storage.maxUploadSize)throw u(413,`File size exceeds maximum allowed size of ${this.storage.maxUploadSize} bytes`)}const o=await this.storage.create(t);if(e){const d=this.buildFileUrl(r,o);return b(o,{...z(o,d),"X-Chunked-Upload":"true","X-Upload-ID":o.id},201)}const i=await this.storage.write({body:s,contentLength:n,id:o.id,start:0}),h=this.buildFileUrl(r,i);return b(i,z(i,h),201)}async handlePut(t,e,r,s,n,o){let i,h=!1;try{await this.storage.getMeta(t),h=!0,o&&await this.storage.update({id:t},{metadata:o}),i=await this.storage.write({body:s,contentLength:n,id:t,start:0})}catch(m){const S=m;if(S.UploadErrorCode===A.FILE_NOT_FOUND||S.code==="ENOENT")try{const w=await this.storage.create(e);i=await this.storage.write({body:s,contentLength:n,id:w.id,start:0})}catch(w){throw w}else throw m}const d=this.buildFileUrl(r,i);return b(i,z(i,d),h?200:201)}async handlePatch(t,e,r,s,n,o){let i=await this.storage.getMeta(t);const h=i.metadata||{},d=_(i);if(d){const l=U(i);l&&i.size!==l&&(i={...i,size:l})}const m=typeof h._totalSize=="number"?h._totalSize:i.size||0;if(!d)throw u(400,"File is not a chunked upload. Use POST or PUT for full file uploads.");const S=100*1024*1024;try{H(e,r,m,S)}catch(l){throw l instanceof Error&&l.message.includes("exceeds maximum")?u(413,l.message):u(400,l instanceof Error?l.message:String(l))}if(i.status==="completed"){const l=this.buildFileUrl(n,i);return b(i,{...z(i,l),"X-Upload-Complete":"true"},200)}const w=await this.storage.withLock(`chunks:${t}`,async()=>{const l=(await this.storage.getMeta(t)).metadata??{},M=Array.isArray(l._chunks)?l._chunks:[],x=B(M,{checksum:s,length:r,offset:e});return await this.storage.update({id:t},{metadata:{...l,_chunks:x}}),x});let p=await this.storage.write({body:o,contentLength:r,id:t,start:e}),C=p.bytesWritten>=m;d&&(C=N(w,m),p.status==="completed"&&!C&&(await this.storage.update({id:t},{status:"part"}),p={...p,status:"part"}));const k=C&&p.bytesWritten!==m?{...p,bytesWritten:m}:p,F=this.buildFileUrl(n,k),O={...z(k,F),...v(k,C),"x-upload-offset":String(k.bytesWritten||0)};return b(k,O,C?200:202)}async handleHead(t){let e=await this.storage.getMeta(t);const r=_(e);if(r){const n=U(e);n&&e.size!==n&&(e={...e,size:n})}const s={...L(e)};if(r){const n=e.metadata||{},o=U(e)||e.size||0,i=Array.isArray(n._chunks)?n._chunks:[],h=N(i,o);Object.assign(s,v(e,h))}return b(e,s,200)}handleOptions(t,e){return{headers:{"Access-Control-Allow-Headers":"Authorization, Content-Type, Content-Length, Content-Disposition, X-File-Metadata, X-Chunked-Upload, X-Total-Size, X-Chunk-Offset, X-Chunk-Checksum","Access-Control-Allow-Methods":t.map(r=>r.toUpperCase()).join(", "),"Access-Control-Max-Age":86400,"X-Max-Upload-Size":String(e)},statusCode:204}}async deleteBatch(t){const e=await this.storage.deleteBatch(t);if(e.successfulCount===0&&e.failedCount>0){const r=e.failed.map(s=>s.id).join(", ");throw u(404,`Failed to delete files: ${r}`)}return{data:e.successful,headers:e.failedCount>0?{"X-Delete-Errors":JSON.stringify(e.failed),"X-Delete-Failed":String(e.failedCount),"X-Delete-Successful":String(e.successfulCount)}:{"X-Delete-Successful":String(e.successfulCount)},statusCode:e.successfulCount===t.length?204:207}}get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,e){throw new Error("buildFileUrl must be implemented")}}export{ae as M,ee as a,R as b,P as c,te as e,I as p,Z as v};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var i=(t,e)=>d(t,"name",{value:e,configurable:!0});import{createHash as p}from"node:crypto";import{createPaginationMetaSchemaObject as c,createPaginationSchemaObject as l}from"@visulima/pagination";import{sharedFileMetaSchemaObject as m,sharedErrorSchemaObject as u,sharedFileMetaExampleObject as h,sharedGetList as f,sharedGet as y,sharedGetMeta as g}from"./sharedGet-Ce7WGAsc.js";var k=Object.defineProperty,U=i((t,e)=>k(t,"name",{value:e,configurable:!0}),"o");const R=U((t,e,o)=>{const{supportedTransformerFormat:r,tags:s,transformer:n}={tags:["REST"],transformer:!1,...o},a=p("sha256").update(e).digest("base64");return{components:{examples:h,parameters:{UploadIDinPath:{description:"Upload ID",in:"path",name:"id",schema:{type:"string"}}},responses:{404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"Not found"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"}},schemas:{"X-Chunk-Checksum":{description:"SHA256 checksum of the chunk data for validation. Format: 'sha256 <base64-encoded-checksum>'.",type:"string"},"X-Chunk-Offset":{description:"Byte offset for the chunk being uploaded. Required for PATCH requests in chunked uploads.",type:"integer"},"X-Chunked-Upload":{description:"Header to indicate chunked upload initialization. Set to 'true' to initialize a chunked upload session.",enum:["true"],type:"string"},"X-Chunked-Upload-Response":{description:"Indicates this is a chunked upload session. Returned in HEAD responses.",enum:["true"],type:"string"},"X-Received-Chunks":{description:"JSON array of received chunk offsets. Used for resumable uploads.",type:"string"},"X-Total-Size":{description:"Total size of the file in bytes for chunked uploads. Required when X-Chunked-Upload is 'true'.",type:"integer"},"X-Upload-Complete":{description:"Indicates if the upload is complete. Set to 'true' when all chunks have been uploaded.",enum:["true","false"],type:"string"},"X-Upload-Offset":{description:"Current upload offset in bytes. Returned in responses for chunked uploads.",type:"integer"},...l("FileMetaPagination",{$ref:"#/components/schemas/PaginationMeta"},"#/components/schemas/PaginationMeta"),...c("PaginationMeta"),...u,...m}},paths:{[`${e.replace(/\/$/,"")}/{id}/metadata`]:{get:g(`${a}RestGetFileMeta`,s)},[`${e.replace(/\/$/,"")}/{id}`]:{delete:{description:"Delete a single file",operationId:`${a}RestDeleteFile`,parameters:[{$ref:"#/components/parameters/UploadIDinPath"}],responses:{204:{description:"No Content - File deleted successfully"},404:{$ref:"#/components/responses/404"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Delete file",tags:s},get:y(`${a}RestGetFile`,s,n,r),head:{description:"Get file metadata and upload progress. For chunked uploads, returns progress information including current offset and completion status.",operationId:`${a}RestHeadFile`,parameters:[{$ref:"#/components/parameters/UploadIDinPath"}],responses:{200:{description:"OK",headers:{"Content-Length":{description:"File size in bytes",schema:{type:"integer"}},"Content-Type":{description:"MIME type of the file",schema:{type:"string"}},ETag:{description:"Entity tag for caching",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},"Last-Modified":{description:"Last modified date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},"X-Chunked-Upload":{description:"Indicates this is a chunked upload session",schema:{$ref:"#/components/schemas/X-Chunked-Upload-Response"}},"X-Received-Chunks":{description:"JSON array of received chunk offsets (chunked uploads only)",schema:{$ref:"#/components/schemas/X-Received-Chunks"}},"X-Upload-Complete":{description:"Indicates if upload is complete (chunked uploads only)",schema:{$ref:"#/components/schemas/X-Upload-Complete"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},"X-Upload-Offset":{description:"Current upload offset in bytes (chunked uploads only)",schema:{$ref:"#/components/schemas/X-Upload-Offset"}}}},404:{$ref:"#/components/responses/404"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Get file metadata",tags:s},patch:{description:"Upload a chunk for chunked uploads. Requires X-Chunk-Offset header and chunk data in the request body.",operationId:`${a}RestPatchChunk`,parameters:[{$ref:"#/components/parameters/UploadIDinPath"},{description:"Byte offset for this chunk",in:"header",name:"X-Chunk-Offset",required:!0,schema:{$ref:"#/components/schemas/X-Chunk-Offset"}},{description:"SHA256 checksum of the chunk (optional)",in:"header",name:"X-Chunk-Checksum",required:!1,schema:{$ref:"#/components/schemas/X-Chunk-Checksum"}}],requestBody:{content:{"application/octet-stream":{description:"Chunk data as raw binary",schema:{format:"binary",type:"string"}}},description:"Chunk data",required:!0},responses:{200:{description:"Chunk uploaded successfully",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${t}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Complete":{description:"Indicates if upload is complete",schema:{$ref:"#/components/schemas/X-Upload-Complete"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},"X-Upload-Offset":{description:"Current upload offset after this chunk",schema:{$ref:"#/components/schemas/X-Upload-Offset"}}}},201:{description:"Upload completed (all chunks received)",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${t}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Complete":{description:"Upload is complete",schema:{enum:["true"],type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},400:{content:{"application/json":{example:{error:{code:"BadRequest",message:"X-Chunk-Offset header is required"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Bad Request"},404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"Upload session not found"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"},413:{content:{"application/json":{example:{error:{code:"RequestEntityTooLarge",message:"Chunk size exceeds maximum allowed size of 104857600 bytes"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Request Entity Too Large"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Upload chunk",tags:s},put:{description:"Create or update a file. Requires file ID in the URL path. If file exists, it will be overwritten.",operationId:`${a}RestPutFile`,parameters:[{$ref:"#/components/parameters/UploadIDinPath"}],requestBody:{content:{"application/octet-stream":{description:"File data as raw binary",schema:{format:"binary",type:"string"}}},description:"File data",required:!0},responses:{200:{description:"File updated successfully",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${t}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},201:{description:"File created successfully",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${t}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},400:{content:{"application/json":{example:{error:{code:"BadRequest",message:"Request body is required"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Bad Request"},413:{content:{"application/json":{example:{error:{code:"RequestEntityTooLarge",message:"File size exceeds maximum allowed size"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Request Entity Too Large"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Create or update file",tags:s}},[e.trimEnd()]:{delete:{description:'Delete multiple files. Supports batch delete via query parameter (?ids=id1,id2,id3) or JSON body ({ids: ["id1", "id2"]} or ["id1", "id2"]).',operationId:`${a}RestBatchDelete`,parameters:[{description:"Comma-separated list of file IDs to delete",in:"query",name:"ids",required:!1,schema:{example:"id1,id2,id3",type:"string"}}],requestBody:{content:{"application/json":{schema:{oneOf:[{properties:{ids:{description:"Array of file IDs to delete",items:{type:"string"},type:"array"}},required:["ids"],type:"object"},{description:"Array of file IDs to delete",items:{type:"string"},type:"array"}]}}},description:"File IDs to delete (optional if using query parameter)",required:!1},responses:{204:{description:"All files deleted successfully"},207:{description:"Multi-Status - Some files deleted successfully",headers:{"X-Delete-Errors":{description:"JSON array of deletion errors",schema:{type:"string"}},"X-Delete-Failed":{description:"Number of files that failed to delete",schema:{type:"integer"}},"X-Delete-Successful":{description:"Number of files successfully deleted",schema:{type:"integer"}}}},400:{content:{"application/json":{example:{error:{code:"BadRequest",message:"No file IDs provided"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Bad Request"},404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"Failed to delete files: id1, id2"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Batch delete files",tags:s},get:f(`${a}RestGetList`,s),post:{description:"Upload a file with raw binary data or initialize a chunked upload session. For chunked uploads, set X-Chunked-Upload: true and X-Total-Size headers.",operationId:`${a}RestPostFile`,parameters:[{description:"Set to 'true' to initialize a chunked upload session",in:"header",name:"X-Chunked-Upload",required:!1,schema:{$ref:"#/components/schemas/X-Chunked-Upload"}},{description:"Total size of the file in bytes (required for chunked uploads)",in:"header",name:"X-Total-Size",required:!1,schema:{$ref:"#/components/schemas/X-Total-Size"}},{description:"Optional filename",in:"header",name:"Content-Disposition",required:!1,schema:{example:'attachment; filename="photo.jpg"',type:"string"}},{description:"Optional JSON metadata",in:"header",name:"X-File-Metadata",required:!1,schema:{example:'{"description":"My photo"}',type:"string"}}],requestBody:{content:{"application/octet-stream":{description:"File data as raw binary. For chunked upload initialization, body can be empty.",schema:{format:"binary",type:"string"}}},description:"File data (optional for chunked upload initialization)",required:!1},responses:{200:{description:"The file already exists, send a resume request",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL",schema:{example:`${t}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},201:{description:"File uploaded successfully or chunked upload session initialized",headers:{ETag:{description:"Upload ETag",schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},Location:{description:"File URL or chunked upload session URL",schema:{example:`${t}${e}/file-id`,format:"uri",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},400:{content:{"application/json":{example:{error:{code:"BadRequest",message:"Request body is required for non-chunked uploads"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Bad Request"},413:{content:{"application/json":{example:{error:{code:"RequestEntityTooLarge",message:"File size exceeds maximum allowed size"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Request Entity Too Large"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Upload file or initialize chunked upload",tags:s}}}}},"swaggerSpec");export{R as default};
@@ -0,0 +1 @@
1
+ var O=Object.defineProperty;var g=(c,t)=>O(c,"name",{value:t,configurable:!0});import{Readable as b}from"node:stream";import{z as C,B as M,$ as A,t as T}from"./storage-B-NDsI-o.js";import{d as I}from"./detect-file-type-5JhzC9RU.js";import{throwErrorCode as y,ERRORS as f}from"./ERRORS-CyOuSMLY.js";import{createRetryWrapper as R}from"./isRetryableError-BhizNeAz.js";import{v as k}from"./local-meta-storage-Bi0mK6gD.js";import{u as z}from"./update-size-DANV7aa2.js";import{r as v,o as P}from"./part-match-B5fLLmFw.js";import{o as x}from"./has-content-Bx2p8Okx.js";var B=Object.defineProperty,L=g((c,t)=>B(c,"name",{value:t,configurable:!0}),"o$1");const N=L((c,t)=>{const a={};return Object.keys(c).forEach(e=>{a[e]=t(c[e])}),a},"mapValues");var $=Object.defineProperty,K=g((c,t)=>$(c,"name",{value:t,configurable:!0}),"t");const j=K(c=>c===Number(c)?c:(C(c)??0)/1e3,"toSeconds");var D=Object.defineProperty,w=g((c,t)=>D(c,"name",{value:t,configurable:!0}),"m");const F=5*1024*1024,W=16*1024*1024;class S extends M{static{g(this,"S3BaseStorage")}static{w(this,"S3BaseStorage")}checksumTypes=["md5","crc32","crc32c","sha1","sha256"];bucket;meta;MAX_PARTS=1e4;partSize;retry;resolvedRetryConfig;constructor(t){if(super(t),this.bucket=t.bucket,this.partSize=typeof t.partSize=="string"?A(t.partSize):t.partSize||W,this.partSize<F)throw new Error("Minimum allowed partSize value is 5MB");const a={backoffMultiplier:2,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:w(i=>{const s=i;return s.statusCode&&[408,429,500,502,503,504].includes(s.statusCode)?!0:s.retryable??!1},"shouldRetry"),...t.retryConfig};this.retry=R(a),this.resolvedRetryConfig=a;const{metaStorage:e,metaStorageConfig:r}=t;if(e)this.meta=e;else{const i={...t,...r,logger:this.logger};"directory"in i?(this.logger?.debug("Using local meta storage"),this.meta=new k(i)):this.meta=new k(i)}this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(i=>{this.logger?.error("Storage access check failed: %O",i)})}getRetryConfig(){return this.resolvedRetryConfig}async create(t,a){return this.instrumentOperation("create",async()=>{const e={...t};if(t.ttl){const n=typeof t.ttl=="string"?T(t.ttl):t.ttl;n!==void 0&&(e.expiredAt=Date.now()+n)}const r=new(this.getFileClass())(e);r.name=this.namingFunction(r),await this.validate(r);try{const n=await this.getMeta(r.id);if(n.bytesWritten>=0)return n}catch{}const i=this.getS3Api();let s;try{s=await this.runOperation(a,n=>i.createMultipartUpload({ACL:this.getAcl(),Bucket:this.bucket,ContentType:r.contentType,Key:r.name,Metadata:N({originalName:r.originalName,...r.metadata},l=>encodeURI(String(l)))},{signal:n}))}catch{return y(f.FILE_ERROR,"s3 create upload error")}const{UploadId:o}=s||{};return o?(r.UploadId=o,r.bytesWritten=0,this.config.clientDirectUpload&&(r.partSize??=this.partSize),await this.saveMeta(r),r.status="created",await this.onCreate(r),this.config.clientDirectUpload?this.buildPresigned(r):r):y(f.FILE_ERROR,"s3 create upload error")})}async write(t,a){return this.instrumentOperation("write",async()=>{let e;if("contentType"in t&&"metadata"in t&&!("body"in t)&&!("start"in t)?e=t:(e=await this.getMeta(t.id),await this.checkIfExpired(e)),e.status==="completed")return e;if(typeof t.size=="number"&&t.size>0&&z(e,t.size),!v(t,e))return y(f.FILE_CONFLICT);if(this.config.clientDirectUpload)return this.buildPresigned(e);e.Parts??=await this.getParts(e),e.bytesWritten=e.Parts.map(i=>i.Size||0).reduce((i,s)=>i+s,0);const r=await this.lock(t.id);try{if(x(t)){if(this.isUnsupportedChecksum(t.checksumAlgorithm))return y(f.UNSUPPORTED_CHECKSUM_ALGORITHM);if(e.Parts.length===0&&(!e.contentType||e.contentType==="application/octet-stream"))try{const p=t.body instanceof b?t.body:b.fromWeb(t.body),{fileType:m,stream:u}=await I(p);m?.mime&&(e.contentType=m.mime),t.body=u}catch{}if(e.Parts.length>this.MAX_PARTS)throw new Error(`Exceeded ${this.MAX_PARTS} as part of the upload to ${this.bucket}.`);const i=e.Parts.length+1,s=this.getS3Api(),o=e.UploadId;if(!o)throw new Error("UploadId is required");const n=t.body,l=n instanceof Uint8Array,{ETag:h}=await this.runOperation(a,p=>s.uploadPart({Body:n,Bucket:this.bucket,ContentLength:t.contentLength||0,Key:e.name,PartNumber:i,UploadId:o,...t.checksumAlgorithm==="md5"?{ContentMD5:t.checksum}:{}},{signal:p}),{replayable:l}),d={ETag:h,PartNumber:i,Size:t.contentLength};e.Parts=[...e.Parts,d],e.bytesWritten+=t.contentLength||0}if(this.cache.set(e.id,e),e.status=P(e),e.status==="completed"){const[i]=await this.internalOnComplete(e);delete e.Parts,e.uri=i.Location,e.ETag=i.ETag}}finally{await this.unlock(t.id,r)}return e})}async delete({id:t},a){return this.instrumentOperation("delete",async()=>{const e=await this.getMeta(t);e.status="deleted",await this.abortMultipartUpload(e,a),await this.deleteMeta(e.id);const r={...e};return await this.onDelete(r),r})}async copy(t,a,e){return this.instrumentOperation("copy",async()=>{S.assertSafeId(t),S.assertSafeId(a);const r=await this.getMeta(t),i=`${this.bucket}/${t}`,s=this.bucket,o=a,n=this.getS3Api();return await this.runOperation(e,l=>n.copyObject({Bucket:s,CopySource:i,Key:o,...e?.storageClass&&{StorageClass:e.storageClass}},{signal:l})),{...r,id:o,name:o}})}async move(t,a,e){return this.instrumentOperation("move",async()=>{await this.copy(t,a,e);const r=this.getS3Api();return await this.runOperation(e,i=>r.deleteObject({Bucket:this.bucket,Key:t},{signal:i})),await this.getMeta(a)})}async list(t=1e3,a){return this.instrumentOperation("list",async()=>{const e=this.getS3Api(),r=Math.min(t,1e3);let i={Bucket:this.bucket,MaxKeys:r};const s=[];let o=!0;for(;o&&s.length<t;)try{const n=await this.runOperation(a,l=>e.listObjectsV2(i,{signal:l}));for(const{Key:l,LastModified:h}of n?.Contents||[]){if(s.length>=t)break;l!==void 0&&s.push({id:l,...h&&{createdAt:h}})}o=n.IsTruncated||!1,o&&n.NextContinuationToken&&s.length<t&&(i={...i,ContinuationToken:n.NextContinuationToken,MaxKeys:Math.min(r,t-s.length)})}catch(n){const l=this.normalizeError(n instanceof Error?n:new Error(String(n)));throw await this.onError(l),n}return s},{limit:t})}async exists({id:t},a){return this.instrumentOperation("exists",async()=>{try{await this.getMeta(t);const e=this.getS3Api();return await this.runOperation(a,r=>e.headObject({Bucket:this.bucket,Key:t},{signal:r})),!0}catch{return!1}})}async get({id:t},a){return this.instrumentOperation("get",async()=>{const e=this.getS3Api(),{Body:r,ContentLength:i,ContentType:s,ETag:o,Expires:n,LastModified:l,Metadata:h}=await this.runOperation(a,u=>e.getObject({Bucket:this.bucket,Key:t},{signal:u}));await this.checkIfExpired({expiredAt:n});const d=[];if(r)if(r instanceof b)for await(const u of r)d.push(u instanceof Uint8Array?u:new Uint8Array(u));else{const u=r.getReader();for(;;){const{done:U,value:E}=await u.read();if(U)break;d.push(E)}}const{originalName:p,...m}=h||{};return{content:Buffer.concat(d),contentType:s,ETag:o,expiredAt:n,id:t,metadata:m,modifiedAt:l,name:t,originalName:p||t,size:Number(i)}})}async buildPresigned(t){const a=t;if(a.Parts?.length||(a.Parts=await this.getParts(t)),a.bytesWritten=a.Parts.map(e=>e.Size||0).reduce((e,r)=>e+r,0),t.status=P(a),a.partsUrls?.length||(a.partsUrls=await this.getPartsPresignedUrls(t)),t.status==="completed"){const[e]=await this.internalOnComplete(t);return delete a.Parts,a.uri=e.Location,t}return t}async getPartsPresignedUrls(t){t.partSize??=this.partSize;const a=t.UploadId;if(!a)throw new Error("UploadId is required for getting presigned URLs");const e=Math.trunc(t.size/this.partSize)+1,r=[],i=Math.trunc(j(this.config.expiration?.maxAge||"6hrs")),s=this.getS3Api();for(let o=0;o<e;o++)r.push(s.getPresignedUrl({Bucket:this.bucket,expiresIn:i,Key:t.name,PartNumber:o+1,UploadId:a}));return Promise.all(r)}async getParts(t){const a=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const{Parts:r=[]}=await this.runOperation(void 0,i=>a.listParts({Bucket:this.bucket,Key:t.name,UploadId:e},{signal:i}));return r}completeMultipartUpload(t){const a=this.getS3Api(),e=t.UploadId;if(!e)throw new Error("UploadId is required");const r=t.Parts?.map(({ETag:i,PartNumber:s})=>{if(!i||!s)throw new Error("ETag and PartNumber are required");return{ETag:i,PartNumber:s}})||[];return this.runOperation(void 0,i=>a.completeMultipartUpload({Bucket:this.bucket,Key:t.name,Parts:r,UploadId:e},{signal:i}))}async abortMultipartUpload(t,a){if(t.status!=="completed")try{const e=this.getS3Api(),r=t.UploadId;if(!r)return;await this.runOperation(a,i=>e.abortMultipartUpload({Bucket:this.bucket,Key:t.name,UploadId:r},{signal:i}))}catch(e){this.logger?.error("abortMultipartUploadError: ",e);const r=this.normalizeError(e instanceof Error?e:new Error(String(e)));await this.onError(r)}}internalOnComplete=w(async t=>{const[a]=await Promise.all([this.completeMultipartUpload(t),this.deleteMeta(t.id)]);return[a,t]},"internalOnComplete")}export{S};
@@ -0,0 +1,260 @@
1
+ import { Readable } from 'node:stream';
2
+ import { F as File, M as MetaStorage, d as createRetryWrapper, R as RetryConfig, e as FileInit, B as BaseStorage, O as OperationOptions, f as FilePart, g as FileQuery, a as FileReturn } from "./storage.d-BoJgdi1n.js";
3
+ /**
4
+ * Part interface for multipart uploads.
5
+ */
6
+ interface Part {
7
+ ETag?: string;
8
+ PartNumber: number;
9
+ Size?: number;
10
+ }
11
+ /**
12
+ * Base file type for S3-compatible storage.
13
+ */
14
+ interface S3CompatibleFile extends File {
15
+ Parts?: Part[];
16
+ partSize?: number;
17
+ partsUrls?: string[];
18
+ UploadId?: string;
19
+ uri?: string;
20
+ }
21
+ /**
22
+ * Per-call options forwarded to the underlying AWS SDK send().
23
+ */
24
+ interface S3CallOptions {
25
+ /** Forwarded to `client.send(command, { abortSignal })`. */
26
+ signal?: AbortSignal;
27
+ }
28
+ /**
29
+ * S3 API operations interface that must be implemented by concrete storage classes.
30
+ */
31
+ interface S3ApiOperations {
32
+ abortMultipartUpload: (params: {
33
+ Bucket: string;
34
+ Key: string;
35
+ UploadId: string;
36
+ }, options?: S3CallOptions) => Promise<void>;
37
+ checkBucketAccess: (params: {
38
+ Bucket: string;
39
+ }) => Promise<void>;
40
+ completeMultipartUpload: (params: {
41
+ Bucket: string;
42
+ Key: string;
43
+ Parts: {
44
+ ETag: string;
45
+ PartNumber: number;
46
+ }[];
47
+ UploadId: string;
48
+ }, options?: S3CallOptions) => Promise<{
49
+ ETag?: string;
50
+ Location: string;
51
+ }>;
52
+ copyObject: (params: {
53
+ Bucket: string;
54
+ CopySource: string;
55
+ Key: string;
56
+ StorageClass?: string;
57
+ }, options?: S3CallOptions) => Promise<void>;
58
+ createMultipartUpload: (params: {
59
+ ACL?: string;
60
+ Bucket: string;
61
+ ContentType?: string;
62
+ Key: string;
63
+ Metadata?: Record<string, string>;
64
+ }, options?: S3CallOptions) => Promise<{
65
+ UploadId: string;
66
+ }>;
67
+ deleteObject: (params: {
68
+ Bucket: string;
69
+ Key: string;
70
+ }, options?: S3CallOptions) => Promise<void>;
71
+ getObject: (params: {
72
+ Bucket: string;
73
+ Key: string;
74
+ }, options?: S3CallOptions) => Promise<{
75
+ Body?: ReadableStream | Readable;
76
+ ContentLength?: number;
77
+ ContentType?: string;
78
+ ETag?: string;
79
+ Expires?: Date;
80
+ LastModified?: Date;
81
+ Metadata?: Record<string, string>;
82
+ }>;
83
+ getPresignedUrl: (params: {
84
+ Bucket: string;
85
+ expiresIn: number;
86
+ Key: string;
87
+ PartNumber: number;
88
+ UploadId: string;
89
+ }) => Promise<string>;
90
+ headObject: (params: {
91
+ Bucket: string;
92
+ Key: string;
93
+ }, options?: S3CallOptions) => Promise<{
94
+ ContentLength?: number;
95
+ ContentType?: string;
96
+ ETag?: string;
97
+ Expires?: Date;
98
+ LastModified?: Date;
99
+ Metadata?: Record<string, string>;
100
+ }>;
101
+ listObjectsV2: (params: {
102
+ Bucket: string;
103
+ ContinuationToken?: string;
104
+ MaxKeys?: number;
105
+ }, options?: S3CallOptions) => Promise<{
106
+ Contents?: {
107
+ Key?: string;
108
+ LastModified?: Date;
109
+ }[];
110
+ IsTruncated?: boolean;
111
+ NextContinuationToken?: string;
112
+ }>;
113
+ listParts: (params: {
114
+ Bucket: string;
115
+ Key: string;
116
+ UploadId: string;
117
+ }, options?: S3CallOptions) => Promise<{
118
+ Parts?: Part[];
119
+ }>;
120
+ uploadPart: (params: {
121
+ Body: Readable | ReadableStream | Uint8Array;
122
+ Bucket: string;
123
+ ContentLength?: number;
124
+ ContentMD5?: string;
125
+ Key: string;
126
+ PartNumber: number;
127
+ UploadId: string;
128
+ }, options?: S3CallOptions) => Promise<{
129
+ ETag: string;
130
+ }>;
131
+ }
132
+ /**
133
+ * Base class for S3-compatible storage implementations.
134
+ * Contains all shared business logic for S3 operations.
135
+ * @template TFile The file type used by this storage backend.
136
+ */
137
+ declare abstract class S3BaseStorage<TFile extends S3CompatibleFile = S3CompatibleFile> extends BaseStorage<TFile> {
138
+ override checksumTypes: string[];
139
+ protected bucket: string;
140
+ protected meta: MetaStorage<TFile>;
141
+ /**
142
+ * S3 multipart upload does not allow more than 10000 parts.
143
+ */
144
+ protected readonly MAX_PARTS = 1e4;
145
+ protected readonly partSize: number;
146
+ protected readonly retry: ReturnType<typeof createRetryWrapper>;
147
+ protected readonly resolvedRetryConfig: RetryConfig;
148
+ /**
149
+ * Abstract method to get S3 API operations implementation.
150
+ */
151
+ protected abstract getS3Api(): S3ApiOperations;
152
+ /**
153
+ * Abstract method to get the file class constructor.
154
+ */
155
+ protected abstract getFileClass(): new (config: FileInit) => TFile;
156
+ /**
157
+ * Abstract method to get ACL value.
158
+ */
159
+ protected abstract getAcl(): string | undefined;
160
+ /**
161
+ * Abstract method for access check.
162
+ */
163
+ protected abstract accessCheck(maxWaitTime?: number): Promise<void>;
164
+ constructor(config: {
165
+ bucket: string;
166
+ clientDirectUpload?: boolean;
167
+ expiration?: {
168
+ maxAge?: string;
169
+ };
170
+ filename?: (file: TFile) => string;
171
+ logger?: BaseStorage<TFile>["logger"];
172
+ metaStorage?: MetaStorage<TFile>;
173
+ metaStorageConfig?: unknown;
174
+ partSize?: number | string;
175
+ retryConfig?: RetryConfig;
176
+ });
177
+ protected override getRetryConfig(): RetryConfig;
178
+ /**
179
+ * Creates a new S3 multipart upload.
180
+ */
181
+ create(config: FileInit, options?: OperationOptions): Promise<TFile>;
182
+ /**
183
+ * Writes data to an S3 multipart upload.
184
+ */
185
+ write(part: FilePart | FileQuery | TFile, options?: OperationOptions): Promise<TFile>;
186
+ /**
187
+ * Deletes an upload and its metadata.
188
+ */
189
+ delete({
190
+ id
191
+ }: FileQuery, options?: OperationOptions): Promise<TFile>;
192
+ /**
193
+ * Copies an upload file to a new location.
194
+ */
195
+ copy(name: string, destination: string, options?: OperationOptions & {
196
+ storageClass?: string;
197
+ }): Promise<TFile>;
198
+ /**
199
+ * Moves an upload file to a new location.
200
+ */
201
+ move(name: string, destination: string, options?: OperationOptions): Promise<TFile>;
202
+ /**
203
+ * Lists files in the bucket.
204
+ */
205
+ override list(limit?: number, options?: OperationOptions): Promise<TFile[]>;
206
+ /**
207
+ * Checks if a file exists by verifying both metadata and the actual S3 object.
208
+ * Returns true only if both the metadata and the S3 object exist.
209
+ * @param query File query containing the file ID to check.
210
+ * @returns Promise resolving to true if both metadata and S3 object exist, false otherwise.
211
+ */
212
+ override exists({
213
+ id
214
+ }: FileQuery, options?: OperationOptions): Promise<boolean>;
215
+ /**
216
+ * Gets an uploaded file by ID.
217
+ */
218
+ get({
219
+ id
220
+ }: FileQuery, options?: OperationOptions): Promise<FileReturn>;
221
+ /**
222
+ * Gets file stream (abstract - must be implemented by subclasses due to stream differences).
223
+ */
224
+ abstract override getStream(query: FileQuery, options?: OperationOptions): Promise<{
225
+ headers?: Record<string, string>;
226
+ size?: number;
227
+ stream: Readable;
228
+ }>;
229
+ /**
230
+ * Builds presigned URLs for client uploads.
231
+ */
232
+ protected buildPresigned(file: TFile): Promise<TFile>;
233
+ /**
234
+ * Gets presigned URLs for all parts.
235
+ */
236
+ protected getPartsPresignedUrls(file: TFile): Promise<string[]>;
237
+ /**
238
+ * Gets parts for a multipart upload.
239
+ */
240
+ protected getParts(file: TFile): Promise<Part[]>;
241
+ /**
242
+ * Completes a multipart upload.
243
+ */
244
+ protected completeMultipartUpload(file: TFile): Promise<{
245
+ ETag?: string;
246
+ Location: string;
247
+ }>;
248
+ /**
249
+ * Aborts a multipart upload.
250
+ */
251
+ protected abortMultipartUpload(file: TFile, options?: OperationOptions): Promise<void>;
252
+ /**
253
+ * Internal onComplete handler.
254
+ */
255
+ protected internalOnComplete: (file: TFile) => Promise<[{
256
+ ETag?: string;
257
+ Location: string;
258
+ }, TFile]>;
259
+ }
260
+ export { Part as P, S3CallOptions as S, S3ApiOperations as a, S3BaseStorage as b };
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var n=(e,r)=>a(e,"name",{value:r,configurable:!0});var S=Object.defineProperty,t=n((e,r)=>S(e,"name",{value:r,configurable:!0}),"t");const o=new Set(["fr-par","nl-ams","pl-waw"]),C=t(e=>{const r=e?.accessKeyId??process.env.AWS_ACCESS_KEY_ID??process.env.SCALEWAY_ACCESS_KEY_ID??process.env.SCALEWAY_ACCESS_KEY,E=e?.endpoint??process.env.SCALEWAY_ENDPOINT,s=e?.region??process.env.SCALEWAY_REGION,c=e?.secretAccessKey??process.env.AWS_SECRET_ACCESS_KEY??process.env.SCALEWAY_SECRET_ACCESS_KEY??process.env.SCALEWAY_SECRET_KEY;if(!s||!r||!c)throw new Error("Missing required parameters for Scaleway Object Storage client.");if(!o.has(s))throw new Error(`Invalid Scaleway region "${s}". Expected one of: ${[...o].join(", ")}.`);return{credentials:{accessKeyId:r,secretAccessKey:c},endpoint:E??`https://s3.${s}.scw.cloud`,forcePathStyle:!1,region:s}},"scaleway");export{C as default};
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var d=(e,t)=>g(e,"name",{value:t,configurable:!0});var y=Object.defineProperty,r=d((e,t)=>y(e,"name",{value:t,configurable:!0}),"a");const l={value:{createdAt:"2022-12-16T10:35:17.466Z",id:"391c9157ec481ac6-f72b2d884632d7e6-cdeb2056546033e3",modifiedAt:"2022-12-16T10:35:17.470Z"}},s=r((e,t)=>e.map(i=>({...i,description:`[${t}] ${i.description}`,"x-group":t})),"createParameterGroup"),u=r((e,t=["jpeg","png","webp","avif","tiff","gif","mp4","webm","mkv","ogg","mp3","wav","aac","flac"])=>{if(!e)return[];const i=s([{description:"Output format for the transformed media",in:"query",name:"format",schema:{enum:t,type:"string"}},{description:"Quality setting (0-100 for images, affects compression)",in:"query",name:"quality",schema:{maximum:100,minimum:1,type:"integer"}}],"Common"),n=s([{description:"Desired width in pixels",in:"query",name:"width",schema:{minimum:1,type:"integer"}},{description:"Desired height in pixels",in:"query",name:"height",schema:{minimum:1,type:"integer"}},{description:"Resize fit mode",in:"query",name:"fit",schema:{enum:["cover","contain","fill","inside","outside"],type:"string"}},{description:"Position for cover/contain fits",in:"query",name:"position",schema:{oneOf:[{enum:["top","right","bottom","left","center"],type:"string"},{minimum:0,type:"integer"}]}},{description:"Avoid enlarging images smaller than specified dimensions",in:"query",name:"withoutEnlargement",schema:{type:"boolean"}},{description:"Avoid reducing images larger than specified dimensions",in:"query",name:"withoutReduction",schema:{type:"boolean"}},{description:"Resize kernel algorithm",in:"query",name:"kernel",schema:{enum:["nearest","cubic","mitchell","lanczos2","lanczos3"],type:"string"}},{description:"Fast shrink on load for large images",in:"query",name:"fastShrinkOnLoad",schema:{type:"boolean"}},{description:"Crop area left offset",in:"query",name:"left",schema:{minimum:0,type:"integer"}},{description:"Crop area top offset",in:"query",name:"top",schema:{minimum:0,type:"integer"}},{description:"Crop area width",in:"query",name:"cropWidth",schema:{minimum:1,type:"integer"}},{description:"Crop area height",in:"query",name:"cropHeight",schema:{minimum:1,type:"integer"}},{description:"Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect quality",in:"query",name:"angle",schema:{type:"number"}},{description:"Background color for rotation (hex, rgb, or color name)",in:"query",name:"background",schema:{type:"string"}},{description:"Apply blur effect",in:"query",name:"blur",schema:{type:"boolean"}},{description:"Apply sharpening",in:"query",name:"sharpen",schema:{type:"boolean"}},{description:"Apply median filter with specified size",in:"query",name:"median",schema:{minimum:1,type:"integer"}},{description:"Apply CLAHE (Contrast Limited Adaptive Histogram Equalization)",in:"query",name:"clahe",schema:{type:"boolean"}},{description:"Apply thresholding with specified value (0-255)",in:"query",name:"threshold",schema:{maximum:255,minimum:0,type:"integer"}},{description:"Apply gamma correction",in:"query",name:"gamma",schema:{type:"boolean"}},{description:"Negate (invert) the image",in:"query",name:"negate",schema:{type:"boolean"}},{description:"Normalise the image",in:"query",name:"normalise",schema:{type:"boolean"}},{description:"Flatten alpha channel",in:"query",name:"flatten",schema:{type:"boolean"}},{description:"Unflatten alpha channel",in:"query",name:"unflatten",schema:{type:"boolean"}},{description:"Flip image vertically",in:"query",name:"flip",schema:{type:"boolean"}},{description:"Flop image horizontally",in:"query",name:"flop",schema:{type:"boolean"}},{description:"Convert to greyscale",in:"query",name:"greyscale",schema:{type:"boolean"}},{description:"Apply modulation effects",in:"query",name:"modulate",schema:{type:"boolean"}},{description:"Brightness multiplier for modulation",in:"query",name:"brightness",schema:{type:"number"}},{description:"Saturation multiplier for modulation",in:"query",name:"saturation",schema:{type:"number"}},{description:"Hue rotation in degrees for modulation",in:"query",name:"hue",schema:{type:"integer"}},{description:"Lightness adjustment for modulation",in:"query",name:"lightness",schema:{type:"integer"}},{description:"Apply tinting",in:"query",name:"tint",schema:{type:"boolean"}},{description:"Convert colourspace",in:"query",name:"colourspace",schema:{enum:["srgb","rgb","cmyk","lab","b-w"],type:"string"}},{description:"Apply affine transformation",in:"query",name:"affine",schema:{type:"boolean"}},{description:"Apply dilation",in:"query",name:"dilate",schema:{type:"boolean"}},{description:"Apply erosion",in:"query",name:"erode",schema:{type:"boolean"}},{description:"Set pipeline colourspace",in:"query",name:"pipelineColourspace",schema:{type:"boolean"}},{description:"Convert to colourspace",in:"query",name:"toColourspace",schema:{type:"boolean"}},{description:"Remove alpha channel",in:"query",name:"removeAlpha",schema:{type:"boolean"}},{description:"Ensure alpha channel",in:"query",name:"ensureAlpha",schema:{type:"boolean"}}],"Image"),m=s([{description:"Desired width in pixels",in:"query",name:"width",schema:{minimum:1,type:"integer"}},{description:"Desired height in pixels",in:"query",name:"height",schema:{minimum:1,type:"integer"}},{description:"Video frame rate in Hz",in:"query",name:"frameRate",schema:{minimum:1,type:"number"}},{description:"Video key frame interval in seconds",in:"query",name:"keyFrameInterval",schema:{minimum:.1,type:"number"}}],"Video"),o=s([{description:"Target bitrate in bits per second",in:"query",name:"bitrate",schema:{minimum:1,type:"integer"}},{description:"Video or audio codec",in:"query",name:"codec",schema:{enum:["avc","hevc","vp8","vp9","av1","aac","opus","mp3","vorbis","flac"],type:"string"}}],"Video/Audio"),h=s([{description:"Audio channel count",in:"query",name:"numberOfChannels",schema:{enum:[1,2,3,4,5,6,7,8],type:"integer"}},{description:"Audio sample rate in Hz",in:"query",name:"sampleRate",schema:{enum:[8e3,11025,16e3,22050,32e3,44100,48e3,88200,96e3,192e3],type:"integer"}}],"Audio");let a=[];a=[...a,...i],(e===!0||e==="image")&&(a=[...a,...n]),(e===!0||e==="video")&&(a=[...a,...m]),(e===!0||e==="video"||e==="audio")&&(a=[...a,...o]),(e===!0||e==="audio")&&(a=[...a,...h]);const p=new Set;return a.filter(c=>p.has(c.name)?!1:(p.add(c.name),!0))},"getTransformationParameters"),q=r((e,t=["jpeg","png","webp","avif","tiff","gif","mp4","webm","mkv","ogg","mp3","wav","aac","flac"])=>{const i=u(e,t),n={};return i.forEach(m=>{const o=m["x-group"]||"Other";n[o]||(n[o]=[]),n[o].push(m.name)}),{groups:n,parameters:i}},"getOrganizedTransformationParameters"),f=r(e=>e?{"X-Media-Type":{description:"Type of media (image/video/audio)",schema:{enum:["image","video","audio"],type:"string"}},"X-Original-Format":{description:"Original file format",schema:{type:"string"}},"X-Transformed-Format":{description:"Transformed file format",schema:{type:"string"}}}:{},"getTransformationHeaders"),b=r(e=>e?{400:{content:{"application/json":{examples:{ValidationError:{value:{error:{code:"INVALID_PARAMS_FOR_IMAGE",details:{invalidParams:["codec","bitrate"],mediaType:"image",validParams:["format","quality","width","height","fit","position","withoutEnlargement","withoutReduction","kernel","fastShrinkOnLoad","left","top","cropWidth","cropHeight","angle","background","blur","sharpen","median","clahe","threshold","gamma","negate","normalise","flatten","unflatten","flip","flop","greyscale","modulate","brightness","saturation","hue","lightness","tint","colourspace","affine","dilate","erode","pipelineColourspace","toColourspace","removeAlpha","ensureAlpha"]},message:"Invalid query parameters for image transformation: codec, bitrate. Images support: format, quality, width, height, fit, position, withoutEnlargement, withoutReduction, kernel, fastShrinkOnLoad, left, top, cropWidth, cropHeight, angle, background, blur, sharpen, median, clahe, threshold, gamma, negate, normalise, flatten, unflatten, flip, flop, greyscale, modulate, brightness, saturation, hue, lightness, tint, colourspace, affine, dilate, erode, pipelineColourspace, toColourspace, removeAlpha, ensureAlpha. Video/audio parameters (codec, bitrate) are not supported for images.",name:"ValidationError"}}}},schema:{$ref:"#/components/schemas/ValidationError"}}},description:"Invalid transformation parameters"},413:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"File too large for transformation"},415:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Unsupported media type for transformation"}}:{},"getTransformationErrorResponses"),I=r((e,t,i,n)=>({description:"Get the uploaded file with optional media transformation support",operationId:e,parameters:[{in:"path",name:"id",required:!0,schema:{type:"string"}},...u(i,n)],responses:{200:{content:{"*/*":{schema:{description:i?"Transformed file content":"File content",format:"binary",type:"string"}}},description:i?"File retrieved and transformed successfully":"File retrieved successfully",headers:{"Content-Type":{description:`MIME type of the file${i?" (or transformed file)":""}`,schema:{type:"string"}},ETag:{description:`Upload ETag${i?" (or transformed file ETag)":""}`,schema:{example:"d41d8cd98f00b204e9800998ecf8427e",type:"string"}},"Last-Modified":{description:"Upload last modified date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},...f(i),"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},...b(i),404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"Not found"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Get the uploaded file",tags:t}),"sharedGet"),v=r((e,t)=>({description:"Get the uploaded file metadata",operationId:e,parameters:[{in:"path",name:"id",required:!0,schema:{type:"string"}}],responses:{200:{content:{"application/json":{schema:{$ref:"#/components/schemas/FileMeta"}}},description:"OK",headers:{"Last-Modified":{description:"Upload last modified date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}},"X-Upload-Expires":{description:"Upload expiration date",schema:{example:"2021-08-25T11:12:26.635Z",format:"date-time",type:"string"}}}},404:{content:{"application/json":{example:{error:{code:"FileNotFound",message:"File metadata not found"}},schema:{$ref:"#/components/schemas/Error"}}},description:"Not Found"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"Get the uploaded file metadata",tags:t}),"sharedGetMeta"),E={Error:{description:"Error",properties:{error:{properties:{code:{minLength:1,type:"string"},message:{minLength:1,type:"string"},name:{minLength:3,type:"string"}},required:["message"],type:"object"}},required:["error"],type:"object"},ValidationError:{description:"Validation error response",properties:{code:{enum:["INVALID_PARAMS_FOR_IMAGE","INVALID_PARAMS_FOR_VIDEO","INVALID_PARAMS_FOR_AUDIO","INVALID_FIT_VALUE","INVALID_ANGLE_VALUE","INVALID_FORMAT","INCOMPLETE_CROP_PARAMS","INVALID_VIDEO_CODEC","INVALID_VIDEO_FORMAT","INVALID_WIDTH","INVALID_HEIGHT","INVALID_BITRATE","INVALID_FRAME_RATE","INVALID_KEY_FRAME_INTERVAL","INVALID_AUDIO_CODEC","INVALID_AUDIO_FORMAT","INVALID_CHANNEL_COUNT","INVALID_SAMPLE_RATE"],type:"string"},details:{properties:{invalidParams:{items:{type:"string"},type:"array"},mediaType:{enum:["image","video","audio"],type:"string"},suggestions:{items:{type:"string"},type:"array"},validParams:{items:{type:"string"},type:"array"}},required:["invalidParams","validParams","mediaType"],type:"object"},message:{type:"string"},name:{enum:["ValidationError"],type:"string"}},required:["code","details","message","name"],type:"object"}},L={FileMeta:{description:"File meta",properties:{bytesWritten:{type:"integer"},contentType:{type:"string"},createdAt:{format:"date-time",type:"string"},id:{minLength:1,type:"string"},metadata:{type:"object"},name:{minLength:1,type:"string"},originalName:{minLength:1,type:"string"},status:{enum:["completed","part","deleted","created"],type:"string"}},type:"object"}},_={FileMeta:{value:[l]},FileMetaPagination:{value:{data:[l.value],meta:{firstPage:1,firstPageUrl:"/?page=1",lastPage:1,lastPageUrl:"/?page=10",nextPageUrl:"/?page=2",page:1,perPage:1,previousPageUrl:void 0,total:1}}}},F=r((e,t)=>({description:"List upload",operationId:e,parameters:[{description:"Maximum number of elements to retrieve.",in:"query",name:"limit",schema:{nullable:!0,type:"integer"}},{description:"Page number. Use only for pagination.",in:"query",name:"page",schema:{nullable:!0,type:"integer"}}],responses:{200:{content:{"application/json":{examples:{Default:{$ref:"#/components/examples/FileMeta"},Pagination:{$ref:"#/components/examples/FileMetaPagination"}},schema:{$ref:"#/components/schemas/FileMeta"}}},description:"OK"},default:{content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}},description:"Error"}},summary:"List upload",tags:t}),"sharedGetList");export{q as getOrganizedTransformationParameters,E as sharedErrorSchemaObject,_ as sharedFileMetaExampleObject,L as sharedFileMetaSchemaObject,I as sharedGet,F as sharedGetList,v as sharedGetMeta};
@@ -0,0 +1 @@
1
+ var H=Object.defineProperty;var p=(t,e)=>H(t,"name",{value:e,configurable:!0});import{Readable as X}from"node:stream";import{setInterval as J}from"node:timers";import{inspect as Q}from"node:util";import{L as ee,O as I}from"./path-D7rMc9nq-B718mbm6.js";import te from"type-is";import re from"./NoOpMetrics-Dky06sf1.js";import{N as oe}from"./cache-qV_5Umeq.js";import{ErrorMap as M,throwErrorCode as E,ERRORS as $}from"./ERRORS-CyOuSMLY.js";import{randomUUID as se}from"node:crypto";import{LRUCache as ae}from"lru-cache";import{retry as ie}from"./isRetryableError-BhizNeAz.js";import{o as ne}from"./is-expired-1JuZjDtb.js";var ce=Object.defineProperty,le=p((t,e)=>ce(t,"name",{value:e,configurable:!0}),"y$3"),ue=Object.defineProperty,me=le((t,e)=>ue(t,"name",{value:e,configurable:!0}),"y"),ge=Object.defineProperty,C=me((t,e)=>ge(t,"name",{value:e,configurable:!0}),"i");const de=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,he=/^KIBI/,pe=/^MIBI/,fe=/^GIBI/,ye=/^TEBI/,be=/^PEBI/,we=/^EXBI/,ve=/^ZEBI/,Ee=/^YIBI/,$e=/^(.)IB$/,_={iec:[{long:"Bytes",short:"B"},{long:"Kibibytes",short:"KiB"},{long:"Mebibytes",short:"MiB"},{long:"Gibibytes",short:"GiB"},{long:"Tebibytes",short:"TiB"},{long:"Pebibytes",short:"PiB"},{long:"Exbibytes",short:"EiB"},{long:"Zebibytes",short:"ZiB"},{long:"Yobibytes",short:"YiB"}],iec_octet:[{long:"Octets",short:"o"},{long:"Kibioctets",short:"Kio"},{long:"Mebioctets",short:"Mio"},{long:"Gibioctets",short:"Gio"},{long:"Tebioctets",short:"Tio"},{long:"Pebioctets",short:"Pio"},{long:"Exbioctets",short:"Eio"},{long:"Zebioctets",short:"Zio"},{long:"Yobioctets",short:"Yio"}],metric:[{long:"Bytes",short:"Bytes"},{long:"Kilobytes",short:"KB"},{long:"Megabytes",short:"MB"},{long:"Gigabytes",short:"GB"},{long:"Terabytes",short:"TB"},{long:"Petabytes",short:"PB"},{long:"Exabytes",short:"EB"},{long:"Zettabytes",short:"ZB"},{long:"Yottabytes",short:"YB"}],metric_octet:[{long:"Octets",short:"o"},{long:"Kilo-octets",short:"ko"},{long:"Mega-octets",short:"Mo"},{long:"Giga-octets",short:"Go"},{long:"Tera-octets",short:"To"},{long:"Peta-octets",short:"Po"},{long:"Exa-octets",short:"Eo"},{long:"Zetta-octets",short:"Zo"},{long:"Yotta-octets",short:"Yo"}]},xe=C((t,e)=>{const r=new Intl.NumberFormat(e).format(11111).replaceAll(new RegExp("\\p{Number}","gu"),""),o=new Intl.NumberFormat(e).format(1.1).replaceAll(new RegExp("\\p{Number}","gu"),"");return Number.parseFloat(t.replaceAll(new RegExp(`\\${r}`,"g"),"").replace(new RegExp(`\\${o}`),"."))},"parseLocalizedNumber"),R=C(t=>{switch(t){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},"fromBase"),j=C((t,e)=>{const r={base:2,locale:"en-US",units:"metric",...e};if(typeof t!="string"||t.length===0)throw new TypeError("Value is not a string or is empty.");if(t.length>100)throw new TypeError("Value exceeds the maximum length of 100 characters.");const o=de.exec(t)?.groups;if(!o)return Number.NaN;const s=xe(o.value,r.locale),a=(o.type??"Bytes").toUpperCase().replace(he,"KILO").replace(pe,"MEGA").replace(fe,"GIGA").replace(ye,"TERA").replace(be,"PETA").replace(we,"EXA").replace(ve,"ZETTA").replace(Ee,"YOTTA").replace($e,"$1B"),i=_[r.units].findIndex(u=>u.short[0].toUpperCase()===a[0]),l=R(r.base);return s*l**i},"parseBytes");C((t,e)=>{if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("Bytesize is not a number.");const{base:r,decimals:o,locale:s,long:a,unit:i,units:l,...u}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...e},n=R(r),m=Math.abs(t),g=e?.space??!0?" ":"",c=_[l],d=c.findIndex(w=>w.short===i);if(t===0){const w=Math.min(0,Math.max(d,c.length-1));return"0"+g+c[w][a?"long":"short"]}const h=d===-1?Math.min(Math.floor(Math.log(m)/Math.log(n)),c.length-1):d,N=c[h][a?"long":"short"],O=t/n**h,v=o<0?void 0:o;return new Intl.NumberFormat(s,{maximumFractionDigits:v,minimumFractionDigits:v,...u}).format(O)+g+N},"formatBytes");var Me=Object.defineProperty,Ne=p((t,e)=>Me(t,"name",{value:e,configurable:!0}),"u$3"),Oe=Object.defineProperty,Ae=Ne((t,e)=>Oe(t,"name",{value:e,configurable:!0}),"v"),Te=Object.defineProperty,Ce=Ae((t,e)=>Te(t,"name",{value:e,configurable:!0}),"D");const Se=Ce((t,e,r,o,s,a,i,l,u,n,m,g,c,d)=>{const h={d:o,h:s,m:a,mo:e,ms:l,s:i,w:r,y:t};return u!==void 0&&(h.future=u),n!==void 0&&(h.past=n),m!==void 0&&(h.decimal=m),g!==void 0&&(h.unitMap=g),c!==void 0&&(h.groupSeparator=c),d!==void 0&&(h.placeholderSeparator=d),h},"createDurationLanguage"),F={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Ie=Se(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",F,",","_");var Be=Object.defineProperty,Pe=p((t,e)=>Be(t,"name",{value:e,configurable:!0}),"o"),De=Object.defineProperty,Ue=Pe((t,e)=>De(t,"name",{value:e,configurable:!0}),"o"),ze=Object.defineProperty,je=Ue((t,e)=>ze(t,"name",{value:e,configurable:!0}),"o");const ke=je(t=>{const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const o of e)if(!Object.hasOwn(t,o))throw new TypeError(`Missing required property: ${o}`);if(typeof t.future!="string"||typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const r=["y","mo","w","d","h","m","s","ms"];for(const o of r)if(typeof t[o]!="string"&&typeof t[o]!="function")throw new TypeError(`Property ${o} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(o=>typeof o!="string"))throw new TypeError("All values in unitMap must be of type string")},"validateDurationLanguage");var _e=Object.defineProperty,Re=p((t,e)=>_e(t,"name",{value:e,configurable:!0}),"w"),Fe=Object.defineProperty,Le=Re((t,e)=>Fe(t,"name",{value:e,configurable:!0}),"S"),Ve=Object.defineProperty,Ge=Le((t,e)=>Ve(t,"name",{value:e,configurable:!0}),"h");const k={d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},A=/[-/\\^$*+?.()|[\]{}]/g,Ye=/^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/i,Ze=/^(?:(\d+):)?(?:(\d+):)?(\d+)$/,Ke=/^[+-]?\d+(?:\.\d+)?$/,We=/^[-+]/,qe=Ge((t,e)=>{if(typeof t!="string"||t.length===0)return;const{defaultUnit:r="ms",language:o=Ie}=e??{};ke(o);const s=o.decimal??".",a=o.groupSeparator??",",i=o.placeholderSeparator??"_",l=s.replaceAll(A,String.raw`\$&`),u=a.replaceAll(A,String.raw`\$&`),n=i.replaceAll(A,String.raw`\$&`),m=o.unitMap??F;let g=t.replaceAll(new RegExp(String.raw`(\d)[${n}${u}](\d)`,"g"),"$1$2");if(s!=="."&&(g=g.replace(l,".")),Ke.test(t)){const f=Number.parseFloat(g.trim());if(!Number.isNaN(f)){const y=m[r];if(y!==void 0)return f*k[y]}return}const c=Ye.exec(t);if(c){const f=Number.parseInt(c[1]??"0",10),y=Number.parseInt(c[2]??"0",10),x=Number.parseInt(c[3]??"0",10);return f*36e5+y*6e4+x*1e3}const d=Ze.exec(t);if(d){let f=0,y=0;d[2]!==void 0?(f=Number.parseInt(d[1]??"0",10),y=Number.parseInt(d[2],10)):d[1]!==void 0&&(y=Number.parseInt(d[1],10));const x=Number.parseInt(d[3]??"0",10);return f*36e5+y*6e4+x*1e3}const h=Object.keys(m).toSorted((f,y)=>y.length-f.length).map(f=>f.replaceAll(A,String.raw`\$&`)).join("|"),N=new RegExp(String.raw`(-?\d*\.?\d+)\s*(${h})`,"gi");let O=0,v,w=!1,P=-1,D=0;for(N.lastIndex=0;(v=N.exec(g))!==null;){w||(P=v.index),w=!0;const f=v[1],y=v[2];if(!f||!y)continue;const x=f.trim(),K=x.startsWith("-")?-1:1,W=x.replace(We,""),U=Number.parseFloat(W),z=m[y.toLowerCase()];if(z===void 0)continue;const q=k[z];if(Number.isNaN(U))return;O+=K*U*q,D=N.lastIndex}const Y=g.slice(0,P).trim(),Z=g.slice(D).trim();if(!(w&&(Y.length>0||Z.length>0))&&w)return O},"parseDuration");var He=Object.defineProperty,Xe=p((t,e)=>He(t,"name",{value:e,configurable:!0}),"n$1");let Je=class extends ae{static{p(this,"u")}static{Xe(this,"Locker")}constructor(e){super({ttl:3e4,ttlAutopurge:!0,...e})}lock(e){if(this.get(e)!==void 0)throw new Error(`${e} is locked`);const r=se();return this.set(e,r),r}unlock(e,r){return this.get(e)!==r?!1:this.delete(e)}};var Qe=Object.defineProperty,et=p((t,e)=>Qe(t,"name",{value:e,configurable:!0}),"e$1");const T=et(t=>{if(t===Number(t))return t;if(!t)return;const e=qe(t);if(e!==void 0)return e},"toMilliseconds");var tt=Object.defineProperty,rt=p((t,e)=>tt(t,"name",{value:e,configurable:!0}),"t");let ot=class extends Error{static{p(this,"d")}static{rt(this,"ValidationError")}code;statusCode;body;headers;name="ValidationError";constructor(e,r,o,s){const a=typeof o=="string"?o:o?.message||"Validation error";super(a),this.code=e,this.statusCode=r,this.body=o,this.headers=s}};var st=Object.defineProperty,S=p((t,e)=>st(t,"name",{value:e,configurable:!0}),"e");const at=S(t=>t&&t[0].toUpperCase()+t.slice(1),"capitalize"),it=S(t=>{if(!Array.isArray(t))return t;const[e,r,o]=t;return{body:r,headers:o,statusCode:e}},"toResponse");class nt{static{p(this,"Validator")}constructor(e="ValidationError"){this.prefix=e}prefix;static{S(this,"Validator")}validators={};add(e){Object.entries(e).forEach(([r,o])=>{const s=`${this.prefix}${at(r)}`;if(this.validators[s]={...this.validators[s],...o},typeof this.validators[s].isValid!="function")throw new TypeError('Validation config "isValid" is missing, or it is not a function!')})}async verify(e){for(const[r,o]of Object.entries(this.validators))if(!await o.isValid(e)){const s=o.response||(r in M?M[r]:M.UnknownError),a=it(s),{body:i,headers:l,message:u,statusCode:n}=a;throw new ot(r,n,i||u,l)}}}const St=S(t=>t.name==="ValidationError","isValidationError");var ct=Object.defineProperty,B=p((t,e)=>ct(t,"name",{value:e,configurable:!0}),"i");const lt=B(t=>{if(typeof t.name=="string")return t.name;if(typeof t.title=="string")return t.title;if(typeof t.originalName=="string")return t.originalName;if(typeof t.filename=="string")return t.filename},"extractOriginalName"),L=B((t,e)=>{const r={...t};return Object.keys(e).forEach(o=>{const s=e[o];if(s!==null&&typeof s=="object"&&!Array.isArray(s)){const a=r[o],i=a&&typeof a=="object"&&!Array.isArray(a)?a:{};r[o]=L(i,s)}else r[o]=s}),r},"deepMerge"),ut=B((t,e)=>{const r=L(t,e);Object.assign(t,r),t.originalName=lt(t.metadata)||t.originalName},"updateMetadata");var mt=Object.defineProperty,b=p((t,e)=>mt(t,"name",{value:e,configurable:!0}),"d");const gt=/(secret|password|passwd|pwd|token|api[_-]?key|credential|authorization|sas|signature|sessiontoken|connectionstring)/i,V=b(t=>{const e={};for(const[r,o]of Object.entries(t))typeof o=="string"&&gt.test(r)?e[r]="[REDACTED]":o&&typeof o=="object"&&!Array.isArray(o)&&o.constructor===Object?e[r]=V(o):e[r]=o;return e},"redactSecrets"),dt={allowMIME:["*/*"],filename:b(({id:t})=>t,"filename"),maxMetadataSize:"8MB",maxUploadSize:"5TB",onComplete:b(()=>{},"onComplete"),onCreate:b(()=>{},"onCreate"),onDelete:b(()=>{},"onDelete"),onError:b(()=>{},"onError"),onUpdate:b(()=>{},"onUpdate"),useRelativeLocation:!1,validation:{}},ht=b(t=>!t||t.length<3||t.length>255||I(t)?!1:!(t.toUpperCase().includes("../")||t.includes("\0")),"defaultCloudStorageFileNameValidation"),It=b(t=>{if(!t||t.length<3||t.length>255||I(t))return!1;const e=t.toUpperCase();return!['"',"*",":","<",">","?","\\","|","../","\0"].some(r=>e.includes(r))},"defaultFilesystemFileNameValidation");class G{static{p(this,"BaseStorage")}static{b(this,"BaseStorage")}onCreate;onUpdate;onComplete;onDelete;onError;isReady=!0;errorResponses={};cache;logger;metrics;genericConfig;maxMetadataSize;checksumTypes=[];maxUploadSize;expiration;locker;namingFunction;validation=new nt;assetFolder=void 0;concurrency;constructor(e){const r={...dt,...e};this.onCreate=r.onCreate,this.onUpdate=r.onUpdate,this.onComplete=r.onComplete,this.onDelete=r.onDelete,this.onError=r.onError,this.namingFunction=r.filename,this.maxUploadSize=typeof r.maxUploadSize=="string"?j(r.maxUploadSize):r.maxUploadSize,this.maxMetadataSize=typeof r.maxMetadataSize=="string"?j(r.maxMetadataSize):r.maxMetadataSize,this.expiration=r.expiration,this.genericConfig=r,r.assetFolder!==void 0&&(this.assetFolder=ee(r.assetFolder)),this.locker=new Je({max:1e3,ttl:3e4,ttlAutopurge:!0}),this.cache=r.cache??new oe,this.logger=r.logger,this.metrics=r.metrics??new re,this.logger?.debug(`${this.constructor.name} config: ${Q(V({...e,logger:this.logger.constructor}))}`);const o=T(r.expiration?.purgeInterval);o&&this.startAutoPurge(o);const s={isValid(u){if(u.size===void 0)return!0;const n=u.size;if(n==null)return!1;const m=typeof n=="number"?n:Number(n);if(Number.isNaN(m)||m<0)return!1;const g=typeof this.value=="number"?this.value:Number(this.value);return!Number.isNaN(g)&&m<=g},response:M.RequestEntityTooLarge,value:this.maxUploadSize},a={isValid(u){return!!te.is(u.contentType,this.value)},response:M.UnsupportedMediaType,value:r.allowMIME},i=r.fileNameValidation??ht,l={isValid(u){return i(u.name)},response:M.InvalidFileName};this.validation.add({filename:l,mime:a,size:s}),this.validation.add({...r.validation})}get raw(){}async getReadUrl(e,r){return E($.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getReadUrl()`)}async getUploadUrl(e,r){return E($.METHOD_NOT_ALLOWED,`${this.constructor.name} does not implement getUploadUrl()`)}get tusExtension(){const e=["creation","creation-with-upload","termination","checksum","creation-defer-length","concatenation"];return this.expiration&&e.push("expiration"),e}async validate(e){await this.validation.verify(e)}async exists(e,r){return this.instrumentOperation("exists",async()=>{try{return await this.getMeta(e.id,r),!0}catch{return!1}})}normalizeError(e){const r={code:e.name,message:e.message,name:e.name,statusCode:500};return{...r,message:`[${this.constructor.name}] ${r.message}`}}get config(){return this.genericConfig}async saveMeta(e){return G.assertSafeId(e.id),this.updateTimestamps(e),this.cache.set(e.id,e),this.meta.save(e.id,e)}static assertSafeId(e){(!e||typeof e!="string"||e.includes("\0")||e.includes("../")||e.includes("..\\")||e===".."||e.startsWith("../")||e.startsWith("..\\")||I(e)||/^[A-Z]:[/\\]/i.test(e))&&E($.INVALID_FILE_NAME,`Invalid file id: "${e}"`)}async deleteMeta(e){return this.cache.delete(e),this.meta.delete(e)}async getMeta(e,r){try{const o=await this.meta.get(e);return this.cache.set(o.id,o),{...o}}catch(o){const s=this.normalizeError(o instanceof Error?o:new Error(String(o)));return await this.onError(s),E($.FILE_NOT_FOUND)}}async checkIfExpired(e){return ne(e)?(this.delete(e).catch(()=>{}),this.deleteMeta(e.id).catch(()=>{}),E($.GONE)):e}async purge(e){return this.instrumentOperation("purge",async()=>{const r=T(e||this.expiration?.maxAge),o={items:[],maxAgeMs:r};if(r){const s=Date.now()-r,a=(await this.list()).filter(i=>Number(new Date(this.expiration?.rolling&&i.modifiedAt||i.createdAt))<s);for await(const{id:i,...l}of a)try{const u=await this.delete({id:i});o.items.push({...u,...l})}catch(u){this.logger?.warn(`Failed to delete file ${i} during purge: ${u instanceof Error?u.message:String(u)}`)}o.items.length>0&&(this.logger?.info(`Purge: removed ${o.items.length} uploads`),this.metrics.gauge("storage.operations.purge.items_count",o.items.length,{storage:this.constructor.name.toLowerCase().replace("storage","")}))}return o})}async getStream({id:e}){return this.instrumentOperation("getStream",async()=>{const r=await this.get({id:e}),o=X.from(r.content);return{headers:{"Content-Length":String(r.size),"Content-Type":r.contentType,...r.ETag&&{ETag:r.ETag},...r.modifiedAt&&{"Last-Modified":r.modifiedAt.toString()}},size:typeof r.size=="number"?r.size:void 0,stream:o}})}async list(e=1e3,r){return this.instrumentOperation("list",async()=>{throw new Error("Not implemented")})}async update({id:e},r){return this.instrumentOperation("update",async()=>{const o=await this.getMeta(e),s={...r};if("ttl"in s&&s.ttl!==void 0){const i=s.ttl,l=typeof i=="string"?T(i):i;l!==void 0&&(s.expiredAt=Date.now()+l),delete s.ttl}ut(o,s),await this.saveMeta(o);const a={...o,status:"updated"};return await this.onUpdate(a),a})}async deleteBatch(e,r){const o=Date.now(),s=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.delete.count",1,{batch_size:e.length,storage:s});const a=[],i=[],l=e.map(async m=>{try{return{file:await this.delete({id:m},r),id:m,success:!0}}catch(g){const c=g instanceof Error?g.message:"Delete failed";return this.metrics.increment("storage.operations.delete.error.count",1,{error:c,storage:s}),{error:c,id:m,success:!1}}}),u=await Promise.allSettled(l);for(const m of u)m.status==="fulfilled"?m.value.success?a.push(m.value.file):i.push({error:m.value.error,id:m.value.id}):i.push({error:m.reason?.message||"Delete failed",id:""});const n=Date.now()-o;return this.metrics.timing("storage.operations.batch.delete.duration",n,{batch_size:e.length,storage:s}),this.metrics.gauge("storage.operations.batch.delete.success_count",a.length,{storage:s}),this.metrics.gauge("storage.operations.batch.delete.failed_count",i.length,{storage:s}),{failed:i,failedCount:i.length,successful:a,successfulCount:a.length}}async copyBatch(e){const r=Date.now(),o=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.copy.count",1,{batch_size:e.length,storage:o});const s=[],a=[],i=e.map(async({destination:n,options:m,source:g})=>{try{return{file:await this.copy(g,n,m),id:n,success:!0}}catch(c){const d=c instanceof Error?c.message:"Copy failed";return this.metrics.increment("storage.operations.copy.error.count",1,{error:d,storage:o}),{error:d,id:n,success:!1}}}),l=await Promise.allSettled(i);for(const n of l)n.status==="fulfilled"?n.value.success&&n.value.file?s.push(n.value.file):a.push({error:n.value.error||"Copy failed",id:n.value.id}):a.push({error:n.reason?.message||"Copy failed",id:""});const u=Date.now()-r;return this.metrics.timing("storage.operations.batch.copy.duration",u,{batch_size:e.length,storage:o}),this.metrics.gauge("storage.operations.batch.copy.success_count",s.length,{storage:o}),this.metrics.gauge("storage.operations.batch.copy.failed_count",a.length,{storage:o}),{failed:a,failedCount:a.length,successful:s,successfulCount:s.length}}async moveBatch(e){const r=Date.now(),o=this.constructor.name.toLowerCase().replace("storage","");this.metrics.increment("storage.operations.batch.move.count",1,{batch_size:e.length,storage:o});const s=[],a=[],i=e.map(async({destination:n,source:m})=>{try{return{file:await this.move(m,n),id:n,success:!0}}catch(g){const c=g instanceof Error?g.message:"Move failed";return this.metrics.increment("storage.operations.move.error.count",1,{error:c,storage:o}),{error:c,id:n,success:!1}}}),l=await Promise.allSettled(i);for(const n of l)n.status==="fulfilled"?n.value.success&&n.value.file?s.push(n.value.file):a.push({error:n.value.error||"Move failed",id:n.value.id}):a.push({error:n.reason?.message||"Move failed",id:n.reason?.id||""});const u=Date.now()-r;return this.metrics.timing("storage.operations.batch.move.duration",u,{batch_size:e.length,storage:o}),this.metrics.gauge("storage.operations.batch.move.success_count",s.length,{storage:o}),this.metrics.gauge("storage.operations.batch.move.failed_count",a.length,{storage:o}),{failed:a,failedCount:a.length,successful:s,successfulCount:s.length}}async lock(e){const r=[...this.locker.keys()];return r.includes(e)?E($.FILE_LOCKED):this.config.concurrency&&typeof this.config.concurrency=="number"&&this.config.concurrency<r.length?E($.STORAGE_BUSY):this.locker.lock(e)}async unlock(e,r){if(r===void 0){this.locker.delete(e);return}this.locker.unlock(e,r)}async withLock(e,r){const o=await this.lock(e);try{return await r()}finally{await this.unlock(e,o)}}isUnsupportedChecksum(e=""){return!!e&&!this.checksumTypes.includes(e)}startAutoPurge(e){if(e>=2147483647)throw new Error("“purgeInterval” must be less than 2147483647 ms");J(()=>{this.purge().catch(r=>this.logger?.error(r))},e)}updateTimestamps(e){e.createdAt??=new Date().toISOString();const r=T(this.expiration?.maxAge);return r&&!e.expiredAt&&(e.expiredAt=this.expiration?.rolling?Date.now()+r:+new Date(e.createdAt)+r),e}getRetryConfig(){}runOperation(e,r,o){let s;typeof e?.retries=="number"?s={maxRetries:e.retries}:e?.retries&&(s=e.retries);const a={...this.getRetryConfig(),...s};o?.replayable===!1&&(a.maxRetries=0);const i=[];this.genericConfig.defaultSignal&&i.push(this.genericConfig.defaultSignal),e?.signal&&i.push(e.signal);let l;i.length===1?[l]=i:i.length>1&&(l=AbortSignal.any(i));const u=typeof e?.timeout=="number"?e.timeout:this.genericConfig.defaultTimeout,n=typeof u=="number"&&u>0?u:void 0,m=a.shouldRetry;a.shouldRetry=c=>l?.aborted||c instanceof Error&&c.name==="AbortError"?!1:m?m(c):!1;const g=b(c=>{if(c instanceof Error&&c.name==="AbortError")return c;const d=c instanceof Error&&c.message?c.message:"The operation was aborted",h=new Error(d,{cause:c});return h.name="AbortError",h},"toAbortError");return ie(async()=>{if(l?.aborted)throw g(l.reason);let c,d;if(n===void 0)d=l;else{const h=new AbortController;c=setTimeout(()=>{h.abort(new DOMException(`The operation timed out after ${n}ms`,"TimeoutError"))},n),d=l?AbortSignal.any([l,h.signal]):h.signal}try{return await r(d)}catch(h){throw d?.aborted?g(h):h}finally{c&&clearTimeout(c)}},a)}async instrumentOperation(e,r,o){const s=Date.now(),a={storage:this.constructor.name.toLowerCase().replace("storage",""),...o};try{this.metrics.increment(`storage.operations.${e}.count`,1,a);const i=await r(),l=Date.now()-s;return this.metrics.timing(`storage.operations.${e}.duration`,l,a),i&&typeof i=="object"&&"size"in i&&typeof i.size=="number"&&this.metrics.gauge("storage.files.size",i.size,{...a,operation:e}),i}catch(i){const l=Date.now()-s,u=i instanceof Error?i.message:"Unknown error";throw this.metrics.timing(`storage.operations.${e}.duration`,l,{...a,error:"true"}),this.metrics.increment(`storage.operations.${e}.error.count`,1,{...a,error:u}),i}}}export{j as $,G as B,It as a,ot as b,ht as d,St as i,T as t,ut as u,qe as z};