@visulima/storage 1.0.0-alpha.2 → 1.0.0-alpha.21

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 (307) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/LICENSE.md +1256 -512
  3. package/README.md +4 -4
  4. package/dist/adapter/nuxt/module.d.ts +41 -34
  5. package/dist/adapter/nuxt/module.js +1 -93
  6. package/dist/handler/http/fetch/index.d.ts +297 -4
  7. package/dist/handler/http/fetch/index.js +1 -4
  8. package/dist/handler/http/hono/index.d.ts +1474 -58
  9. package/dist/handler/http/hono/index.js +1 -65
  10. package/dist/handler/http/nextjs/index.d.ts +66 -58
  11. package/dist/handler/http/nextjs/index.js +1 -37
  12. package/dist/handler/http/node/index.d.ts +361 -4
  13. package/dist/handler/http/node/index.js +1 -4
  14. package/dist/handler/http/solid-start/index.d.ts +66 -57
  15. package/dist/handler/http/solid-start/index.js +1 -44
  16. package/dist/index.d.ts +376 -17
  17. package/dist/index.js +1 -13
  18. package/dist/openapi/index.d.ts +24 -5
  19. package/dist/openapi/index.js +1 -5
  20. package/dist/packem_shared/AwsLightFile-BTLiRxXj.js +1 -0
  21. package/dist/packem_shared/AwsLightMetaStorage-DHz1nf_H.js +1 -0
  22. package/dist/packem_shared/AwsLightStorage-CA9cdfJ6.js +1 -0
  23. package/dist/packem_shared/AzureFile-BKHru1zB.js +1 -0
  24. package/dist/packem_shared/AzureSMetaStorage-BqA4jUDJ.js +1 -0
  25. package/dist/packem_shared/AzureStorage-BKUjCymW.js +1 -0
  26. package/dist/packem_shared/BaseTransformer-D68eLyz1.js +1 -0
  27. package/dist/packem_shared/DiskStorage-DNjpDMX9.js +1 -0
  28. package/dist/packem_shared/DiskStorageWithChecksum-Bb6JX_tC.js +1 -0
  29. package/dist/packem_shared/ERRORS-B9jkvKwx.js +1 -0
  30. package/dist/packem_shared/File-alcSNpLq.js +1 -0
  31. package/dist/packem_shared/GCSConfig-BQ0OpVhe.js +1 -0
  32. package/dist/packem_shared/GCSFile-CHjX_fJk.js +1 -0
  33. package/dist/packem_shared/GCSMetaStorage-BRDiGnC1.js +1 -0
  34. package/dist/packem_shared/GCStorage-BPkZ9tex.js +1 -0
  35. package/dist/packem_shared/LocalMetaStorage-BWuFvWn4.js +1 -0
  36. package/dist/packem_shared/MediaTransformer-2C8MJeAg.js +1 -0
  37. package/dist/packem_shared/MetaStorage-Y4m1dWgd.js +1 -0
  38. package/dist/packem_shared/Metadata-B6Ir0KO7.js +1 -0
  39. package/dist/packem_shared/Multipart-Bd9YFFn0.js +1 -0
  40. package/dist/packem_shared/Multipart-D5bcEvga.js +1 -0
  41. package/dist/packem_shared/NetlifyBlobFile-CpzkMKng.js +1 -0
  42. package/dist/packem_shared/NetlifyBlobMetaStorage-dD0oBLom.js +1 -0
  43. package/dist/packem_shared/NetlifyBlobStorage-ByTwCN-h.js +1 -0
  44. package/dist/packem_shared/NoOpMetrics-Dky06sf1.js +1 -0
  45. package/dist/packem_shared/OpenTelemetryMetrics-9uxQMSlg.js +1 -0
  46. package/dist/packem_shared/Rest-CYEBbtCD.js +1 -0
  47. package/dist/packem_shared/Rest-DoonVU7B.js +1 -0
  48. package/dist/packem_shared/S3Client.d-CZ62Jztg.d.ts +20357 -0
  49. package/dist/packem_shared/S3File-Du6wP0Sz.js +1 -0
  50. package/dist/packem_shared/S3MetaStorage-vcriiosn.js +1 -0
  51. package/dist/packem_shared/S3Storage-Fx6-OSc-.js +1 -0
  52. package/dist/packem_shared/TUS_RESUMABLE-B7KtPVeC.js +1 -0
  53. package/dist/packem_shared/Tus-Bd_2Ki2G.js +1 -0
  54. package/dist/packem_shared/Tus-CUBCkuPE.js +1 -0
  55. package/dist/packem_shared/ValidationError-D8KKJiKA.js +1 -0
  56. package/dist/packem_shared/VercelBlobFile-CL9MjKcY.js +1 -0
  57. package/dist/packem_shared/VercelBlobMetaStorage-BsOTx-Su.js +1 -0
  58. package/dist/packem_shared/VercelBlobStorage-kNkk5Cn4.js +1 -0
  59. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
  60. package/dist/packem_shared/aws-light-meta-storage-TPyQwLvk.js +4 -0
  61. package/dist/packem_shared/backblaze-DEflv87m.js +1 -0
  62. package/dist/packem_shared/base-handler-core-DaggCVsq.js +1 -0
  63. package/dist/packem_shared/base-handler-fetch-DnarP64X.js +1 -0
  64. package/dist/packem_shared/base-handler-node-BTes6sql.js +1 -0
  65. package/dist/packem_shared/cache-qV_5Umeq.js +1 -0
  66. package/dist/packem_shared/cloudflare-DLAeQvgD.js +1 -0
  67. package/dist/packem_shared/defaultCloudStorageFileNameValidation-yiM9GxHr.js +1 -0
  68. package/dist/packem_shared/digitalOcean-nhZUds87.js +1 -0
  69. package/dist/packem_shared/disk-storage-BvdK4bqF.js +5 -0
  70. package/dist/packem_shared/disk-storage-with-checksum.d-CaMptIUg.d.ts +148 -0
  71. package/dist/packem_shared/gcs-meta-storage-DZMf4IHn.js +1 -0
  72. package/dist/packem_shared/has-content-Bx2p8Okx.js +1 -0
  73. package/dist/packem_shared/headers-DC2MEOrK.js +27 -0
  74. package/dist/packem_shared/is-expired-1JuZjDtb.js +1 -0
  75. package/dist/packem_shared/isRetryableError-DQNSZiBc.js +1 -0
  76. package/dist/packem_shared/isValidMediaType-B-2UKjZx.js +1 -0
  77. package/dist/packem_shared/local-meta-storage-Bkwqi_gi.js +1 -0
  78. package/dist/packem_shared/local-meta-storage.d-CGSVabni.d.ts +20 -0
  79. package/dist/packem_shared/media-transformer.d-CLxm_69K.d.ts +331 -0
  80. package/dist/packem_shared/minio-BWwgGXeE.js +1 -0
  81. package/dist/packem_shared/multipart-base-C6OjBwMS.js +1 -0
  82. package/dist/packem_shared/part-match-DqD5U7An.js +1 -0
  83. package/dist/packem_shared/path-D7rMc9nq-B718mbm6.js +1 -0
  84. package/dist/packem_shared/response-builder-Wdo_fvcF.js +1 -0
  85. package/dist/packem_shared/rest-base-B2Dv7esY.js +1 -0
  86. package/dist/packem_shared/restOpenApiSpec-PaIVbESh.js +1 -0
  87. package/dist/packem_shared/s3-base-storage-xHZNtsGe.js +1 -0
  88. package/dist/packem_shared/s3-base-storage.d-BkRmde_Q.d.ts +251 -0
  89. package/dist/packem_shared/sharedGet-Ce7WGAsc.js +1 -0
  90. package/dist/packem_shared/storage-m_Cxgiih.js +1 -0
  91. package/dist/packem_shared/storage.d-Cxs42eEK.d.ts +939 -0
  92. package/dist/packem_shared/tigris-DZoyrMNd.js +1 -0
  93. package/dist/packem_shared/transformOpenApiSpec-C0vEbDTO.js +1 -0
  94. package/dist/packem_shared/tus-base.d-dim7udrK.d.ts +99 -0
  95. package/dist/packem_shared/tusOpenApiSpec-DF0-hlWV.js +1 -0
  96. package/dist/packem_shared/types.d-76N78ehR.d.ts +708 -0
  97. package/dist/packem_shared/types.d-LqXtPPaF.d.ts +49 -0
  98. package/dist/packem_shared/update-size-DANV7aa2.js +1 -0
  99. package/dist/packem_shared/validator-DK41xp8N.js +1 -0
  100. package/dist/packem_shared/waitForStorage-ChSBLhLc.js +1 -0
  101. package/dist/packem_shared/wasabi-Dmce4x9s.js +1 -0
  102. package/dist/packem_shared/xhrOpenApiSpec-nyoboz83.js +1 -0
  103. package/dist/storage/aws/clients/index.d.ts +166 -6
  104. package/dist/storage/aws/clients/index.js +1 -6
  105. package/dist/storage/aws/index.d.ts +320 -4
  106. package/dist/storage/aws/index.js +1 -3
  107. package/dist/storage/aws-light/index.d.ts +252 -4
  108. package/dist/storage/aws-light/index.js +1 -3
  109. package/dist/storage/azure/index.d.ts +10422 -4
  110. package/dist/storage/azure/index.js +1 -3
  111. package/dist/storage/gcs/index.d.ts +4107 -5
  112. package/dist/storage/gcs/index.js +1 -4
  113. package/dist/storage/local/index.d.ts +7 -4
  114. package/dist/storage/local/index.js +1 -3
  115. package/dist/storage/netlify-blob/index.d.ts +142 -4
  116. package/dist/storage/netlify-blob/index.js +1 -3
  117. package/dist/storage/vercel-blob/index.d.ts +129 -4
  118. package/dist/storage/vercel-blob/index.js +1 -3
  119. package/dist/transformer/audio-transformer.d.ts +127 -125
  120. package/dist/transformer/audio-transformer.js +1 -278
  121. package/dist/transformer/image-transformer.d.ts +569 -568
  122. package/dist/transformer/image-transformer.js +1 -1100
  123. package/dist/transformer/index.d.ts +62 -5
  124. package/dist/transformer/index.js +1 -4
  125. package/dist/transformer/video-transformer.d.ts +144 -142
  126. package/dist/transformer/video-transformer.js +1 -310
  127. package/package.json +45 -45
  128. package/dist/handler/base/base-handler-core.d.ts +0 -91
  129. package/dist/handler/base/base-handler-fetch.d.ts +0 -76
  130. package/dist/handler/base/base-handler-node.d.ts +0 -137
  131. package/dist/handler/multipart/multipart-base.d.ts +0 -84
  132. package/dist/handler/multipart/multipart-fetch.d.ts +0 -64
  133. package/dist/handler/multipart/multipart.d.ts +0 -49
  134. package/dist/handler/rest/rest-base.d.ts +0 -106
  135. package/dist/handler/rest/rest-fetch.d.ts +0 -88
  136. package/dist/handler/rest/rest.d.ts +0 -93
  137. package/dist/handler/tus/tus-base.d.ts +0 -152
  138. package/dist/handler/tus/tus-fetch.d.ts +0 -72
  139. package/dist/handler/tus/tus.d.ts +0 -78
  140. package/dist/handler/types.d.ts +0 -53
  141. package/dist/handler/utils/request-parser.d.ts +0 -72
  142. package/dist/handler/utils/response-builder.d.ts +0 -83
  143. package/dist/handler/utils/storage-utils.d.ts +0 -10
  144. package/dist/handler/utils/stream-utils.d.ts +0 -29
  145. package/dist/handler/utils/upload-handlers.d.ts +0 -76
  146. package/dist/metrics/index.d.ts +0 -2
  147. package/dist/metrics/no-op-metrics.d.ts +0 -15
  148. package/dist/metrics/opentelemetry-metrics.d.ts +0 -55
  149. package/dist/openapi/rest.d.ts +0 -7
  150. package/dist/openapi/shared.d.ts +0 -13
  151. package/dist/openapi/transform.d.ts +0 -3
  152. package/dist/openapi/tus.d.ts +0 -7
  153. package/dist/openapi/xhr.d.ts +0 -7
  154. package/dist/packem_shared/AwsLightFile-tTneXZgG.js +0 -11
  155. package/dist/packem_shared/AwsLightMetaStorage-BWSOtVaN.js +0 -4
  156. package/dist/packem_shared/AwsLightStorage-Cwkkc-z3.js +0 -133
  157. package/dist/packem_shared/AzureFile-CesgFzps.js +0 -8
  158. package/dist/packem_shared/AzureSMetaStorage-CFs-OYJT.js +0 -88
  159. package/dist/packem_shared/AzureStorage-9MoV2W8q.js +0 -357
  160. package/dist/packem_shared/BaseTransformer-C2gLib6v.js +0 -82
  161. package/dist/packem_shared/DiskStorage-CJtTzMQ3.js +0 -12
  162. package/dist/packem_shared/DiskStorageWithChecksum-BgrG8pvC.js +0 -238
  163. package/dist/packem_shared/ERRORS-D0apMqnc.js +0 -97
  164. package/dist/packem_shared/File-Bb3P23dr.js +0 -69
  165. package/dist/packem_shared/GCSConfig-vPP22kN6.js +0 -11
  166. package/dist/packem_shared/GCSFile-BIEunhAN.js +0 -8
  167. package/dist/packem_shared/GCSMetaStorage-sYiSjLUx.js +0 -7
  168. package/dist/packem_shared/GCStorage-DPl1_DAm.js +0 -406
  169. package/dist/packem_shared/LocalMetaStorage-CZHhKkMd.js +0 -7
  170. package/dist/packem_shared/MediaTransformer-D6658DL1.js +0 -1197
  171. package/dist/packem_shared/MetaStorage-pECeFOad.js +0 -46
  172. package/dist/packem_shared/Metadata-DRLXeJ0F.js +0 -89
  173. package/dist/packem_shared/Multipart-CNFK_Okz.js +0 -163
  174. package/dist/packem_shared/Multipart-CtUL7BQw.js +0 -128
  175. package/dist/packem_shared/NetlifyBlobFile-CXzyjqrD.js +0 -14
  176. package/dist/packem_shared/NetlifyBlobMetaStorage-DxZ5aDvD.js +0 -9
  177. package/dist/packem_shared/NetlifyBlobStorage-C6AX-X0P.js +0 -376
  178. package/dist/packem_shared/NoOpMetrics-DhAk5rXc.js +0 -10
  179. package/dist/packem_shared/OpenTelemetryMetrics-BnxhqIaH.js +0 -67
  180. package/dist/packem_shared/Rest-CAOAEkOj.js +0 -267
  181. package/dist/packem_shared/Rest-DNuLwBrK.js +0 -228
  182. package/dist/packem_shared/S3File-DZiyk9Qt.js +0 -11
  183. package/dist/packem_shared/S3MetaStorage-Dz9aDabA.js +0 -76
  184. package/dist/packem_shared/S3Storage-CgheE2yH.js +0 -316
  185. package/dist/packem_shared/TUS_RESUMABLE-GJzZ9R-f.js +0 -434
  186. package/dist/packem_shared/Tus-B8PmlMgR.js +0 -200
  187. package/dist/packem_shared/Tus-C4F1aYOl.js +0 -195
  188. package/dist/packem_shared/ValidationError-BfF1aE4h.js +0 -26
  189. package/dist/packem_shared/VercelBlobFile-BCg4aTEq.js +0 -18
  190. package/dist/packem_shared/VercelBlobMetaStorage-Bd9F-VFm.js +0 -9
  191. package/dist/packem_shared/VercelBlobStorage-BbuEYhOz.js +0 -261
  192. package/dist/packem_shared/_commonjsHelpers-B85MJLTf.js +0 -5
  193. package/dist/packem_shared/aws-light-meta-storage-DKJBgbR6.js +0 -446
  194. package/dist/packem_shared/backblaze-BlMnIcBC.js +0 -20
  195. package/dist/packem_shared/base-handler-core-BKuf4YLT.js +0 -303
  196. package/dist/packem_shared/base-handler-fetch-Cr0hLiqg.js +0 -291
  197. package/dist/packem_shared/base-handler-node-gk5aN9Cx.js +0 -730
  198. package/dist/packem_shared/cache-B88MXQ_2.js +0 -18
  199. package/dist/packem_shared/cloudflare-Bi1q8wXE.js +0 -21
  200. package/dist/packem_shared/defaultCloudStorageFileNameValidation-oVDgf-Sw.js +0 -11
  201. package/dist/packem_shared/digitalOcean-CWQRJM3L.js +0 -21
  202. package/dist/packem_shared/disk-storage-DkDoHnKB.js +0 -810
  203. package/dist/packem_shared/gcs-meta-storage-etw4wuh5.js +0 -158
  204. package/dist/packem_shared/has-content-CY66ehMK.js +0 -3
  205. package/dist/packem_shared/headers-DoS5nwM-.js +0 -3220
  206. package/dist/packem_shared/is-expired-CTThU1q5.js +0 -8
  207. package/dist/packem_shared/isRetryableError-Dycp7127.js +0 -82
  208. package/dist/packem_shared/isValidMediaType-BeDgiObq.js +0 -35
  209. package/dist/packem_shared/local-meta-storage-By-3SNBI.js +0 -649
  210. package/dist/packem_shared/minio-C2YBZQOw.js +0 -22
  211. package/dist/packem_shared/multipart-base-B3i67SSX.js +0 -102
  212. package/dist/packem_shared/part-match-BMNqHDYD.js +0 -96
  213. package/dist/packem_shared/path-CR6YkPXX-7R1-9CMk.js +0 -161
  214. package/dist/packem_shared/response-builder-BtnRiBUI.js +0 -45
  215. package/dist/packem_shared/rest-base-GRCcnan7.js +0 -457
  216. package/dist/packem_shared/restOpenApiSpec-CwcHHY2C.js +0 -800
  217. package/dist/packem_shared/s3-base-storage-xw6NJFX7.js +0 -510
  218. package/dist/packem_shared/sharedGet-Cpo7QUyu.js +0 -1019
  219. package/dist/packem_shared/storage-BwdYUHs3.js +0 -864
  220. package/dist/packem_shared/tigris-Hac8TKnX.js +0 -21
  221. package/dist/packem_shared/transformOpenApiSpec-DWM5WtnN.js +0 -975
  222. package/dist/packem_shared/tusOpenApiSpec-6ohiToBy.js +0 -740
  223. package/dist/packem_shared/update-size-CCGm6i1J.js +0 -8
  224. package/dist/packem_shared/validator-BeX_lJet.js +0 -78
  225. package/dist/packem_shared/waitForStorage-Cscw85sx.js +0 -18
  226. package/dist/packem_shared/wasabi-DIyflHSd.js +0 -21
  227. package/dist/packem_shared/xhrOpenApiSpec-DS17brnx.js +0 -264
  228. package/dist/storage/aws/clients/backblaze.d.ts +0 -12
  229. package/dist/storage/aws/clients/cloudflare.d.ts +0 -13
  230. package/dist/storage/aws/clients/digital-ocean.d.ts +0 -12
  231. package/dist/storage/aws/clients/minio.d.ts +0 -13
  232. package/dist/storage/aws/clients/tigris.d.ts +0 -12
  233. package/dist/storage/aws/clients/types.d.ts +0 -95
  234. package/dist/storage/aws/clients/wasabi.d.ts +0 -12
  235. package/dist/storage/aws/s3-base-storage.d.ts +0 -248
  236. package/dist/storage/aws/s3-client-adapter.d.ts +0 -110
  237. package/dist/storage/aws/s3-file.d.ts +0 -10
  238. package/dist/storage/aws/s3-meta-storage.d.ts +0 -15
  239. package/dist/storage/aws/s3-storage.d.ts +0 -70
  240. package/dist/storage/aws/types.d.ts +0 -119
  241. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +0 -130
  242. package/dist/storage/aws-light/aws-light-file.d.ts +0 -10
  243. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +0 -19
  244. package/dist/storage/aws-light/aws-light-storage.d.ts +0 -65
  245. package/dist/storage/aws-light/types.d.ts +0 -37
  246. package/dist/storage/azure/azure-file.d.ts +0 -6
  247. package/dist/storage/azure/azure-meta-storage.d.ts +0 -15
  248. package/dist/storage/azure/azure-storage.d.ts +0 -69
  249. package/dist/storage/azure/types.d.ts +0 -62
  250. package/dist/storage/gcs/fetch-error.d.ts +0 -11
  251. package/dist/storage/gcs/gcs-config.d.ts +0 -2
  252. package/dist/storage/gcs/gcs-file.d.ts +0 -6
  253. package/dist/storage/gcs/gcs-meta-storage.d.ts +0 -27
  254. package/dist/storage/gcs/gcs-storage.d.ts +0 -91
  255. package/dist/storage/gcs/types.d.ts +0 -55
  256. package/dist/storage/gcs/utils.d.ts +0 -7
  257. package/dist/storage/local/disk-storage-with-checksum.d.ts +0 -15
  258. package/dist/storage/local/disk-storage.d.ts +0 -135
  259. package/dist/storage/local/local-meta-storage.d.ts +0 -32
  260. package/dist/storage/meta-storage.d.ts +0 -30
  261. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +0 -12
  262. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +0 -7
  263. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +0 -93
  264. package/dist/storage/netlify-blob/types.d.ts +0 -30
  265. package/dist/storage/storage.d.ts +0 -353
  266. package/dist/storage/types.d.ts +0 -221
  267. package/dist/storage/utils/file/file.d.ts +0 -25
  268. package/dist/storage/utils/file/get-file-status.d.ts +0 -9
  269. package/dist/storage/utils/file/has-content.d.ts +0 -9
  270. package/dist/storage/utils/file/index.d.ts +0 -10
  271. package/dist/storage/utils/file/is-expired.d.ts +0 -8
  272. package/dist/storage/utils/file/metadata.d.ts +0 -18
  273. package/dist/storage/utils/file/part-match.d.ts +0 -11
  274. package/dist/storage/utils/file/types.d.ts +0 -37
  275. package/dist/storage/utils/file/update-metadata.d.ts +0 -10
  276. package/dist/storage/utils/file/update-size.d.ts +0 -10
  277. package/dist/storage/vercel-blob/types.d.ts +0 -32
  278. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +0 -16
  279. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +0 -7
  280. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +0 -76
  281. package/dist/transformer/base-transformer.d.ts +0 -63
  282. package/dist/transformer/media-transformer.d.ts +0 -332
  283. package/dist/transformer/types.d.ts +0 -652
  284. package/dist/transformer/utils.d.ts +0 -33
  285. package/dist/transformer/validation-error.d.ts +0 -23
  286. package/dist/utils/cache.d.ts +0 -32
  287. package/dist/utils/chunked-upload.d.ts +0 -65
  288. package/dist/utils/detect-file-type.d.ts +0 -28
  289. package/dist/utils/errors.d.ts +0 -74
  290. package/dist/utils/file-path-url-matcher.d.ts +0 -18
  291. package/dist/utils/headers.d.ts +0 -111
  292. package/dist/utils/http.d.ts +0 -92
  293. package/dist/utils/locker.d.ts +0 -26
  294. package/dist/utils/pipes/stream-checksum.d.ts +0 -47
  295. package/dist/utils/pipes/stream-length.d.ts +0 -22
  296. package/dist/utils/primitives/get-last-one.d.ts +0 -3
  297. package/dist/utils/primitives/is-record.d.ts +0 -2
  298. package/dist/utils/primitives/map-values.d.ts +0 -9
  299. package/dist/utils/primitives/pick.d.ts +0 -2
  300. package/dist/utils/primitives/to-milliseconds.d.ts +0 -12
  301. package/dist/utils/primitives/to-seconds.d.ts +0 -12
  302. package/dist/utils/range-checksum.d.ts +0 -33
  303. package/dist/utils/range-hasher.d.ts +0 -46
  304. package/dist/utils/retry.d.ts +0 -64
  305. package/dist/utils/types.d.ts +0 -108
  306. package/dist/utils/validation-error.d.ts +0 -22
  307. package/dist/utils/validator.d.ts +0 -36
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var t=(e,r)=>a(e,"name",{value:r,configurable:!0});import s from"./File-alcSNpLq.js";var i=Object.defineProperty,l=t((e,r)=>i(e,"name",{value:r,configurable:!0}),"t");class d extends s{static{t(this,"e")}static{l(this,"S3File")}Parts;UploadId;uri;partsUrls;partSize}export{d as default};
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var o=(c,t)=>r(c,"name",{value:t,configurable:!0});import{S3Client as d,HeadObjectCommand as m,DeleteObjectCommand as h,PutObjectCommand as u,waitUntilBucketExists as f}from"@aws-sdk/client-s3";import{fromIni as l}from"@aws-sdk/credential-providers";import p from"./MetaStorage-Y4m1dWgd.js";import{parseMetadata as w,stringifyMetadata as k}from"./Metadata-B6Ir0KO7.js";import{o as b}from"./is-expired-1JuZjDtb.js";var g=Object.defineProperty,y=o((c,t)=>g(c,"name",{value:t,configurable:!0}),"c");class B extends p{static{o(this,"b")}constructor(t){super(t),this.config=t;const{client:e,...a}=t,i=a.bucket||process.env.S3_BUCKET;if(e===void 0){if(!i)throw new Error("S3 bucket is not defined");const n=a.keyFile||process.env.S3_KEYFILE;n&&(a.credentials=l({configFilepath:n})),this.client=new d(a),this.accessCheck(i).catch(s=>{throw s})}else this.client=e;this.bucket=i}config;static{y(this,"S3MetaStorage")}bucket;client;async get(t){const e=this.getMetaName(t),a={Bucket:this.bucket,Key:e},{Expires:i,Metadata:n}=await this.client.send(new m(a));if(i&&b({expiredAt:i}))throw await this.delete(e),new Error(`Metafile ${t} not found`);if(n?.metadata!==void 0){const s=JSON.parse(decodeURIComponent(n.metadata));return s.metadata&&typeof s.metadata=="string"&&(s.metadata=w(s.metadata)),s}throw new Error(`Metafile ${t} not found`)}async touch(t,e){return this.save(t,e)}async delete(t){const e={Bucket:this.bucket,Key:this.getMetaName(t)};await this.client.send(new h(e))}async save(t,e){const a={...e};a.metadata&&(a.metadata=k(e.metadata));const i=encodeURIComponent(JSON.stringify(a)),n={Bucket:this.bucket,ContentLength:0,Key:this.getMetaName(t),Metadata:{metadata:i}};return await this.client.send(new u(n)),e}async accessCheck(t,e=30){await f({client:this.client,maxWaitTime:e},{Bucket:t})}}export{B as default};
@@ -0,0 +1 @@
1
+ var h=Object.defineProperty;var u=(i,e)=>h(i,"name",{value:e,configurable:!0});import{Readable as p}from"node:stream";import{CreateMultipartUploadCommand as C,UploadPartCommand as g,CompleteMultipartUploadCommand as f,AbortMultipartUploadCommand as k,ListPartsCommand as w,GetObjectCommand as b,HeadObjectCommand as B,DeleteObjectCommand as S,CopyObjectCommand as E,ListObjectsV2Command as T,waitUntilBucketExists as U,S3Client as K}from"@aws-sdk/client-s3";import{fromIni as x}from"@aws-sdk/credential-providers";import{S as L}from"./s3-base-storage-xHZNtsGe.js";import{ReadableStream as y}from"node:stream/web";import{getSignedUrl as M}from"@aws-sdk/s3-request-presigner";import P from"./S3File-Du6wP0Sz.js";import I from"./S3MetaStorage-vcriiosn.js";var A=Object.defineProperty,O=u((i,e)=>A(i,"name",{value:e,configurable:!0}),"s");class j{static{u(this,"T")}constructor(e,a){this.client=e}client;static{O(this,"S3ClientAdapter")}async createMultipartUpload(e){const a=new C({ACL:e.ACL,Bucket:e.Bucket,ContentType:e.ContentType,Key:e.Key,Metadata:e.Metadata}),t=await this.client.send(a);if(!t.UploadId)throw new Error("Failed to create multipart upload");return{UploadId:t.UploadId}}async uploadPart(e){const a=e.Body instanceof y?p.fromWeb(e.Body):e.Body,t=new g({Body:a,Bucket:e.Bucket,ContentLength:e.ContentLength,ContentMD5:e.ContentMD5,Key:e.Key,PartNumber:e.PartNumber,UploadId:e.UploadId}),n=await this.client.send(t);if(!n.ETag)throw new Error("Failed to upload part");return{ETag:n.ETag}}async completeMultipartUpload(e){const a=new f({Bucket:e.Bucket,Key:e.Key,MultipartUpload:{Parts:e.Parts.map(({ETag:n,PartNumber:o})=>({ETag:n,PartNumber:o}))},UploadId:e.UploadId}),t=await this.client.send(a);if(!t.Location)throw new Error("Failed to complete multipart upload");return{ETag:t.ETag,Location:t.Location}}async abortMultipartUpload(e){const a=new k({Bucket:e.Bucket,Key:e.Key,UploadId:e.UploadId});await this.client.send(a)}async listParts(e){const a=new w({Bucket:e.Bucket,Key:e.Key,UploadId:e.UploadId}),t=await this.client.send(a),n=[];if(t.Parts)for(const o of t.Parts)o.ETag&&o.PartNumber&&n.push({ETag:o.ETag,PartNumber:o.PartNumber,Size:o.Size});return{Parts:n.length>0?n:void 0}}async getObject(e){const a=new b({Bucket:e.Bucket,Key:e.Key}),t=await this.client.send(a);let n;if(t.Body){const o=t.Body;o instanceof p||typeof o=="object"&&"transform"in o&&o instanceof y?n=o:n=p.from(o)}return{Body:n,ContentLength:t.ContentLength,ContentType:t.ContentType,ETag:t.ETag,Expires:t.Expires,LastModified:t.LastModified,Metadata:t.Metadata}}async headObject(e){const a=new B({Bucket:e.Bucket,Key:e.Key}),t=await this.client.send(a);return{ContentLength:t.ContentLength,ContentType:t.ContentType,ETag:t.ETag,Expires:t.Expires,LastModified:t.LastModified}}async deleteObject(e){const a=new S({Bucket:e.Bucket,Key:e.Key});await this.client.send(a)}async copyObject(e){const a={Bucket:e.Bucket,CopySource:e.CopySource,Key:e.Key};e.StorageClass&&(a.StorageClass=e.StorageClass);const t=new E(a);await this.client.send(t)}async listObjectsV2(e){const a=new T({Bucket:e.Bucket,ContinuationToken:e.ContinuationToken,MaxKeys:e.MaxKeys}),t=await this.client.send(a);return{Contents:t.Contents?.map(n=>({Key:n.Key,LastModified:n.LastModified})),IsTruncated:t.IsTruncated,NextContinuationToken:t.NextContinuationToken}}async getPresignedUrl(e){const a=new g({Bucket:e.Bucket,Key:e.Key,PartNumber:e.PartNumber,UploadId:e.UploadId});return M(this.client,a,{expiresIn:e.expiresIn})}async checkBucketAccess(e){await U({client:this.client,maxWaitTime:30},{Bucket:e.Bucket})}}var N=Object.defineProperty,v=u((i,e)=>N(i,"name",{value:e,configurable:!0}),"u");class H extends L{static name="s3";s3Api;constructor(e){const{bucket:a=process.env.S3_BUCKET,region:t=process.env.S3_REGION}=e;if(!a)throw new Error("S3 bucket is not defined");if(!t)throw new Error("S3 region is not defined");e.region=t;const n=e.keyFile||process.env.S3_KEYFILE;n&&(e.credentials=x({configFilepath:n}));const o=new K(e);super({bucket:a,clientDirectUpload:e.clientDirectUpload,expiration:e.expiration?.maxAge?{maxAge:String(e.expiration.maxAge)}:void 0,filename:e.filename,logger:e.logger,metaStorage:e.metaStorage,metaStorageConfig:e.metaStorageConfig?{...e.metaStorageConfig,...e}:{...e},partSize:e.partSize,retryConfig:{...e.retryConfig,shouldRetry:v(s=>{const r=s;if(r.$metadata){const l=r.$metadata.httpStatusCode;if(l&&[408,429,500,502,503,504].includes(l)||r.$fault==="server")return!0}return r.retryable??!1},"shouldRetry")}}),this.s3Api=new j(o,a);const{metaStorage:d,metaStorageConfig:c}=e;if(!d){const s={...e,...c,logger:this.logger};"directory"in s||(this.meta=new I(s))}this.config.clientDirectUpload&&(this.onCreate=async()=>{})}normalizeError(e){return e.$metadata?{code:e.Code||e.name,message:e.message,name:e.name,statusCode:e.$metadata.httpStatusCode||500}:super.normalizeError(e)}async update({id:e},a){if(this.config.clientDirectUpload){const t=await this.getMeta(e);return this.buildPresigned({...t,...a})}return super.update({id:e},a)}async getStream({id:e}){return this.instrumentOperation("getStream",async()=>{const a=this.getS3Api(),{Body:t,ContentLength:n,ContentType:o,ETag:d,Expires:c,LastModified:s}=await this.retry(()=>a.getObject({Bucket:this.bucket,Key:e}));await this.checkIfExpired({expiredAt:c});const r=t,l=new p({read(){r.on("data",m=>{this.push(m)}),r.on("end",()=>{this.push(null)}),r.on("error",m=>{this.destroy(m)})}});return{headers:{"Content-Length":n?.toString()??"0","Content-Type":o,...d&&{ETag:d},...c&&{"X-Upload-Expires":c.toString()},...s&&{"Last-Modified":s.toString()}},size:Number(n),stream:l}})}getS3Api(){return this.s3Api}getFileClass(){return P}getAcl(){return this.config.acl}async accessCheck(e=30){await this.s3Api.checkBucketAccess({Bucket:this.bucket})}}export{H as default};
@@ -0,0 +1 @@
1
+ var M=Object.defineProperty;var v=(u,t)=>M(u,"name",{value:t,configurable:!0});import{n as s,H as z}from"./headers-DC2MEOrK.js";import{Metadata as W}from"./Metadata-B6Ir0KO7.js";var H=Object.defineProperty,L=v((u,t)=>H(u,"name",{value:t,configurable:!0}),"x");const T="1.0.0",N="1.0.0",x=L((u="")=>{const t=u.split(",").map(o=>o.split(" ")),e=Object.create(W.prototype);return Object.values(t).forEach(([o,r])=>{o&&(e[o]=r?Buffer.from(r,"base64").toString():"")}),e},"parseMetadata"),k=L(u=>!u||Object.keys(u).length===0?"":Object.entries(u).map(([t,e])=>e===void 0?t:`${t} ${Buffer.from(String(e)).toString("base64")}`).toString(),"serializeMetadata");class j{static{v(this,"TusBase")}static{L(this,"TusBase")}get storage(){throw new Error("storage must be implemented")}buildFileUrl(t,e){throw new Error("buildFileUrl must be implemented")}handleOptions(t){return{headers:{"Access-Control-Allow-Headers":"Authorization, Content-Type, Location, Tus-Extension, Tus-Max-Size, Tus-Resumable, Tus-Version, Upload-Concat, Upload-Defer-Length, Upload-Length, Upload-Metadata, Upload-Offset, X-HTTP-Method-Override, X-Requested-With","Access-Control-Allow-Methods":t.map(e=>e.toUpperCase()).join(", "),"Access-Control-Max-Age":86400,"Tus-Checksum-Algorithm":this.storage.checksumTypes.join(","),"Tus-Extension":this.storage.tusExtension.toString(),"Tus-Max-Size":this.storage.maxUploadSize,"Tus-Version":N},statusCode:204}}async handlePost(t,e,o,r,p,m,f,U){if(e!==void 0){if(!this.storage.tusExtension.includes("creation-defer-length"))throw s(501,"creation-defer-length extension is not (yet) supported.");if(t===void 0){const l={metadata:r?x(r):{}};let i=await this.storage.create(l);U==="application/offset+octet-stream"&&f>0&&(i=await this.storage.write({...i,body:m,contentLength:f,start:0}));let a={};this.storage.tusExtension.includes("expiration")&&typeof i.expiredAt=="number"&&i.size===void 0&&(a={"Upload-Expires":new Date(i.expiredAt).toUTCString()});const c=this.buildFileUrl(p,i);a={...a,...this.buildHeaders(i,{Location:c})},a.Location||(a.Location=c),i.bytesWritten>0&&(a["Upload-Offset"]=i.bytesWritten.toString()),a["Upload-Defer-Length"]="1";const b=i.bytesWritten>0?200:201;return{...i,headers:a,statusCode:b}}}if(o){if(!this.storage.tusExtension.includes("concatenation"))throw s(501,"Concatenation extension is not (yet) supported. Disable parallel upload in the tus client.");const l=r?x(r):{};if(o==="partial"){const i={metadata:{...l,uploadConcat:"partial"},size:t};let a=await this.storage.create(i);U==="application/offset+octet-stream"&&f>0&&(a=await this.storage.write({...a,body:m,contentLength:f,start:0}));let c={};this.storage.tusExtension.includes("expiration")&&typeof a.expiredAt=="number"&&a.bytesWritten!==(a.size??0)&&(c={"Upload-Expires":new Date(a.expiredAt).toUTCString()});const b=this.buildFileUrl(p,a);c={...c,...this.buildHeaders(a,{Location:b})},c.Location||(c.Location=b),a.bytesWritten>0&&(c["Upload-Offset"]=a.bytesWritten.toString()),c["Upload-Concat"]="partial";const w=a.bytesWritten>0?200:201;return{...a,headers:c,statusCode:w}}if(o.startsWith("final;")){const i=o.slice(6).trim().split(/\s+/).filter(Boolean);if(i.length===0)throw s(400,"Upload-Concat final must include at least one partial upload ID");let a=0;const c=[];for(const C of i)try{const g=await this.storage.getMeta(C);if(await this.storage.checkIfExpired(g),g.metadata?.uploadConcat!=="partial")throw s(400,`Upload ${C} is not a partial upload`);if(g.status!=="completed"||g.size===void 0)throw s(409,`Partial upload ${C} is not completed`);c.push(g),a+=g.size}catch(g){const S=g;throw S.statusCode===404||S.statusCode===410?s(409,`Partial upload ${C} not found or expired`):g}const b={metadata:{...l,partialIds:i,uploadConcat:`final;${i.join(" ")}`},size:a},w=await this.storage.create(b);await this.concatenateFiles(w,c);const A=this.buildFileUrl(p,w),O={...this.buildHeaders(w,{Location:A}),"Upload-Concat":o};return{...w,headers:O,statusCode:201}}throw s(400,"Invalid Upload-Concat header format")}if(t===void 0&&e===void 0)throw s(400,"Either upload-length or upload-defer-length must be specified.");if(t!==void 0&&Number.isNaN(Number(t)))throw s(400,"Invalid upload-length");const E={metadata:r?x(r):{},size:t};let n=await this.storage.create(E);U==="application/offset+octet-stream"&&f>0&&(n=await this.storage.write({...n,body:m,contentLength:f,start:0}));let h={};this.storage.tusExtension.includes("expiration")&&typeof n.expiredAt=="number"&&n.bytesWritten!==Number.parseInt(t,10)&&(h={"Upload-Expires":new Date(n.expiredAt).toUTCString()});const y=this.buildFileUrl(p,n);h={...h,...this.buildHeaders(n,{Location:y})},h.Location||(h.Location=y),n.bytesWritten>0&&(h["Upload-Offset"]=n.bytesWritten.toString());const d=n.bytesWritten>0?200:201;return{...n,headers:h,statusCode:d}}async handlePatch(t,e,o,r,p,m,f,U,E){const n=r?x(r):void 0;if(n)try{await this.storage.update({id:t},{id:t,metadata:n})}catch(l){throw l.UploadErrorCode==="FILE_NOT_FOUND"?s(410,"Upload expired"):l}let h;try{h=await this.storage.getMeta(t),await this.storage.checkIfExpired(h)}catch(l){const i=l;throw i.UploadErrorCode==="GONE"||i.UploadErrorCode==="FILE_NOT_FOUND"?s(410,"Upload expired"):l}const y=h.metadata?.uploadConcat;if(typeof y=="string"&&y.startsWith("final;"))throw s(403,"Cannot PATCH a final concatenation upload");let d=await this.storage.write({body:U,checksum:p,checksumAlgorithm:m,contentLength:E,id:t,start:e});if(o!==void 0){if(!this.storage.tusExtension.includes("creation-defer-length"))throw s(501,"creation-defer-length extension is not (yet) supported.");if(d.size!==void 0&&!Number.isNaN(d.size))throw s(412,"Upload-Length has already been set for this upload");const l=Number.parseInt(o,10);if(Number.isNaN(l))throw s(400,"Invalid Upload-Length value");if(l<d.bytesWritten)throw s(400,"Upload-Length is smaller than the current offset");d=await this.storage.update({id:t},{size:l}),d.bytesWritten===d.size&&(d={...d,status:"completed"})}return{...d,headers:this.buildHeaders(d,{"Upload-Offset":d.bytesWritten}),statusCode:d.status==="completed"?200:204}}async handleHead(t){const e=await this.storage.getMeta(t);await this.storage.checkIfExpired(e);const o={...typeof e.size=="number"&&!Number.isNaN(e.size)?{"Upload-Length":e.size}:{"Upload-Defer-Length":"1"},...this.buildHeaders(e,{"Cache-Control":z.createCacheControlPreset("no-store"),"Upload-Metadata":k(e.metadata),"Upload-Offset":e.bytesWritten})},r=e.metadata?.uploadConcat;return typeof r=="string"&&(o["Upload-Concat"]=r),{headers:o,statusCode:200}}async handleGet(t){const e=await this.storage.getMeta(t);return{...e,body:e,headers:this.buildHeaders(e,{"Content-Type":z.createContentType({mediaType:"application/json"})}),statusCode:200}}async handleDelete(t){if(this.disableTerminationForFinishedUploads&&(await this.storage.getMeta(t)).status==="completed")throw s(400,"Termination of finished uploads is disabled");const e=await this.storage.delete({id:t});if(e.status===void 0)throw s(404,"File not found");return{...e,headers:this.buildHeaders(e),statusCode:204}}buildHeaders(t,e={}){return e["Tus-Resumable"]=T,this.storage.tusExtension.includes("expiration")&&t.expiredAt!==void 0&&(e["Upload-Expires"]=new Date(t.expiredAt).toUTCString()),e}extractChecksum(t){if(!t)return{checksum:void 0,checksumAlgorithm:void 0};const[e,o]=t.split(/\s+/).filter(Boolean);return{checksum:o,checksumAlgorithm:e}}validateTusResumableHeader(t){if(!t)throw s(412,"Missing Tus-Resumable header");if(t!==T)throw s(412,`Unsupported TUS version: ${t}. Server supports: ${T}`)}async concatenateFiles(t,e){let o=0;for(const r of e){if(!this.storage.getStream)throw s(501,"getStream is not supported by this storage backend");const{size:p,stream:m}=await this.storage.getStream({id:r.id});if(p===void 0)throw s(500,"Partial upload size is undefined");const f=await this.storage.write({...t,body:m,contentLength:p,start:o});Object.assign(t,f),o+=p}}}const P=T,B=N;export{P as TUS_RESUMABLE,B as TUS_VERSION,j as TusBase,x as parseMetadata,k as serializeMetadata};
@@ -0,0 +1 @@
1
+ var y=Object.defineProperty;var g=(i,e)=>y(i,"name",{value:e,configurable:!0});import{n as a}from"./headers-DC2MEOrK.js";import{O as B}from"./base-handler-fetch-DnarP64X.js";import{TusBase as O}from"./TUS_RESUMABLE-B7KtPVeC.js";import{TUS_RESUMABLE as L,TUS_VERSION as P}from"./TUS_RESUMABLE-B7KtPVeC.js";var w=Object.defineProperty,f=g((i,e)=>w(i,"name",{value:e,configurable:!0}),"g");const l=f(i=>{try{const e=new URL(i).pathname.split("/").filter(Boolean);return e[e.length-1]||void 0}catch{return}},"getIdFromRequestUrl");class T extends B{static{g(this,"Tus")}static{f(this,"Tus")}static methods=["delete","download","get","head","options","patch","post"];tusBase;constructor(e){super(e),this.disableTerminationForFinishedUploads=e.disableTerminationForFinishedUploads??!1;const r=this;this.tusBase=new class extends O{get storage(){return r.storage}get disableTerminationForFinishedUploads(){return r.disableTerminationForFinishedUploads??!1}buildFileUrl(t,s){return r.buildFileUrlForTus(t,s)}}}async options(){return this.tusBase.handleOptions(T.methods)}async post(e){const r=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(r||void 0);const t=e.headers.get("upload-length")||void 0,s=e.headers.get("upload-defer-length")||void 0,o=e.headers.get("upload-concat")||void 0,d=e.headers.get("upload-metadata")||void 0,u=e.headers.get("content-type")||"",n=e.headers.get("content-length"),h=n?Number.parseInt(n,10):0,c=e.url,p=e.body;return this.tusBase.handlePost(t,s,o,d,c,p,h,u)}async patch(e){const r=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(r||void 0);const t=l(e.url);if(!t)throw a(404,"File not found");const s=e.headers.get("upload-offset");if(!s)throw a(412,"Missing Upload-Offset header");const o=e.headers.get("content-type");if(!o)throw a(412,"Content-Type header required");if(o!=="application/offset+octet-stream")throw a(415,"Unsupported Media Type");const d=Number.parseInt(s,10),u=e.headers.get("upload-length")||void 0,n=e.headers.get("upload-metadata")||void 0,h=e.headers.get("content-length"),c=h?Number.parseInt(h,10):0,p=e.headers.get("upload-checksum")||void 0,{checksum:U,checksumAlgorithm:F}=this.tusBase.extractChecksum(p),v=e.url,E=e.body;try{return this.tusBase.handlePatch(t,d,u,n,U,F,v,E,c)}catch(m){const b=m;throw b.UploadErrorCode==="GONE"||b.UploadErrorCode==="FILE_NOT_FOUND"?a(410,"Upload expired"):m}}async head(e){const r=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(r||void 0);const t=l(e.url);if(!t)throw a(404,"File not found");try{return this.tusBase.handleHead(t)}catch(s){const o=s;throw o.UploadErrorCode==="GONE"||o.UploadErrorCode==="FILE_NOT_FOUND"?a(410,"Upload expired"):s}}async get(e){const r=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(r||void 0);const t=l(e.url);if(!t)throw a(404,"File not found");try{return this.tusBase.handleGet(t)}catch(s){throw s.UploadErrorCode==="GONE"?a(410,"Upload expired"):s}}async delete(e){const r=e.headers.get("tus-resumable");this.tusBase.validateTusResumableHeader(r||void 0);const t=l(e.url);if(!t)throw a(404,"File not found");try{return this.tusBase.handleDelete(t)}catch(s){throw s.code==="ENOENT"?a(404,"File not found"):s}}compose(){this.registeredHandlers.set("POST",this.post.bind(this)),this.registeredHandlers.set("PATCH",this.patch.bind(this)),this.registeredHandlers.set("HEAD",this.head.bind(this)),this.registeredHandlers.set("GET",this.get.bind(this)),this.registeredHandlers.set("DELETE",this.delete.bind(this)),this.registeredHandlers.set("OPTIONS",this.options.bind(this)),this.logger?.debug("Registered handler: %s",[...this.registeredHandlers.keys()].join(", "))}buildFileUrlForTus(e,r){const t=new URL(e),{pathname:s,search:o}=t,d=`${s}/${r.id}${o}`;return this.storage.config.useRelativeLocation?d:t.origin+d}}export{L as TUS_RESUMABLE,P as TUS_VERSION,T as Tus};
@@ -0,0 +1 @@
1
+ var U=Object.defineProperty;var p=(h,e)=>U(h,"name",{value:e,configurable:!0});import{format as F}from"node:url";import{n as d}from"./headers-DC2MEOrK.js";import{a,b as m,g as n,c as T}from"./base-handler-core-DaggCVsq.js";import{F as E}from"./base-handler-node-BTes6sql.js";import{TusBase as y}from"./TUS_RESUMABLE-B7KtPVeC.js";import{TUS_RESUMABLE as k,TUS_VERSION as w}from"./TUS_RESUMABLE-B7KtPVeC.js";var O=Object.defineProperty,B=p((h,e)=>O(h,"name",{value:e,configurable:!0}),"h");class g extends E{static{p(this,"Tus")}static{B(this,"Tus")}static methods=["delete","download","get","head","options","patch","post"];disableTerminationForFinishedUploads=!1;tusBase;constructor(e){super(e),this.disableTerminationForFinishedUploads=e.disableTerminationForFinishedUploads??!1;const t=this;this.tusBase=new class extends y{get storage(){return t.storage}get disableTerminationForFinishedUploads(){return t.disableTerminationForFinishedUploads}buildFileUrl(s,r){return t.buildFileUrlForTus(s,r)}}}async options(){return this.tusBase.handleOptions(g.methods)}async post(e){this.tusBase.validateTusResumableHeader(a(e,"tus-resumable"));const t=e.headers["upload-length"],s=e.headers["upload-defer-length"],r=e.headers["upload-concat"],o=a(e,"upload-metadata",!0),i=a(e,"content-type")||"",l=Number.parseInt(a(e,"content-length")||"0",10),u=e.originalUrl||e.url||"",c=m(e);return this.tusBase.handlePost(t,s,r,o,u,c,l,i)}async patch(e){this.tusBase.validateTusResumableHeader(a(e,"tus-resumable"));try{const t=n(e);if(e.headers["upload-offset"]===void 0)throw d(412,"Missing Upload-Offset header");if(e.headers["content-type"]===void 0)throw d(412,"Content-Type header required");if(e.headers["content-type"]!=="application/offset+octet-stream")throw d(415,"Unsupported Media Type");const s=Number.parseInt(a(e,"upload-offset"),10),r=e.headers["upload-length"],o=a(e,"upload-metadata",!0),i=Number(a(e,"content-length")),l=a(e,"upload-checksum"),{checksum:u,checksumAlgorithm:c}=this.tusBase.extractChecksum(l),b=e.originalUrl||e.url||"",f=m(e);return this.tusBase.handlePatch(t,s,r,o,u,c,b,f,i)}catch(t){this.checkForUndefinedIdOrPath(t);const s=t;throw s.UploadErrorCode==="GONE"||s.UploadErrorCode==="FILE_NOT_FOUND"?d(410,"Upload expired"):t}}async head(e){this.tusBase.validateTusResumableHeader(a(e,"tus-resumable"));try{const t=n(e);return this.tusBase.handleHead(t)}catch(t){this.checkForUndefinedIdOrPath(t);const s=t;throw s.UploadErrorCode==="GONE"||s.UploadErrorCode==="FILE_NOT_FOUND"?d(410,"Upload expired"):t}}async get(e){this.tusBase.validateTusResumableHeader(a(e,"tus-resumable"));try{const t=n(e);return this.tusBase.handleGet(t)}catch(t){throw this.checkForUndefinedIdOrPath(t),t.UploadErrorCode==="GONE"?d(410,"Upload expired"):t}}async delete(e){this.tusBase.validateTusResumableHeader(a(e,"tus-resumable"));try{const t=n(e);return this.tusBase.handleDelete(t)}catch(t){throw this.checkForUndefinedIdOrPath(t),t.code==="ENOENT"?d(404,"File not found"):t}}send(e,{body:t="",headers:s={},statusCode:r=200}){const o={body:t,headers:{...s,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control","Tus-Resumable":"1.0.0"},statusCode:r||200};super.send(e,o)}compose(){this.registeredHandlers.set("POST",this.post.bind(this)),this.registeredHandlers.set("PATCH",this.patch.bind(this)),this.registeredHandlers.set("HEAD",this.head.bind(this)),this.registeredHandlers.set("GET",this.get.bind(this)),this.registeredHandlers.set("DELETE",this.delete.bind(this)),this.registeredHandlers.set("OPTIONS",this.options.bind(this)),this.logger?.debug("Registered handler: %s",[...this.registeredHandlers.keys()].join(", "))}buildFileUrlForTus(e,t){const s=new URL(e,"http://localhost"),{pathname:r}=s,o=Object.fromEntries(s.searchParams.entries()),i=F({pathname:`${r}/${t.id}`,query:o});return this.storage.config.useRelativeLocation?i:T({url:e})+i}}export{k as TUS_RESUMABLE,w as TUS_VERSION,g as Tus};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var r=(e,a)=>l(e,"name",{value:a,configurable:!0});var n=Object.defineProperty,c=r((e,a)=>n(e,"name",{value:a,configurable:!0}),"s");class m extends Error{static{r(this,"g")}static{c(this,"ValidationError")}code;details;constructor(a,s,t,i,o,d){super(a),this.name="ValidationError",this.code=s,this.details={invalidParams:i,mediaType:t,suggestions:d,validParams:o}}}export{m as default};
@@ -0,0 +1 @@
1
+ var t=Object.defineProperty;var a=(e,r)=>t(e,"name",{value:r,configurable:!0});import l from"./File-alcSNpLq.js";var o=Object.defineProperty,n=a((e,r)=>o(e,"name",{value:r,configurable:!0}),"e");class c extends l{static{a(this,"n")}static{n(this,"VercelBlobFile")}url;downloadUrl;pathname}export{c as default};
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var t=(r,e)=>a(r,"name",{value:e,configurable:!0});import{O as o}from"./local-meta-storage-Bkwqi_gi.js";var s=Object.defineProperty,c=t((r,e)=>s(r,"name",{value:e,configurable:!0}),"e");class i extends o{static{t(this,"l")}static{c(this,"VercelBlobMetaStorage")}constructor(e){super(e)}}export{i as default};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var l=(n,e)=>p(n,"name",{value:e,configurable:!0});import{put as h,del as d,copy as f,list as w}from"@vercel/blob";import{o as c,r as y,a as g}from"./part-match-DqD5U7An.js";import{B as E,t as O}from"./storage-m_Cxgiih.js";import{O as b}from"./local-meta-storage-Bkwqi_gi.js";import m from"./VercelBlobFile-CL9MjKcY.js";import{u as v}from"./update-size-DANV7aa2.js";import{o as B}from"./has-content-Bx2p8Okx.js";var T=Object.defineProperty,k=l((n,e)=>T(n,"name",{value:e,configurable:!0}),"l");class z extends E{static name="vercel-blob";checksumTypes=["md5"];meta;token;multipart;constructor(e){if(super(e),this.token=e.token||process.env.BLOB_READ_WRITE_TOKEN||process.env.VERCEL_BLOB_TOKEN||"",!this.token)throw new Error("Vercel Blob token is required. Set BLOB_READ_WRITE_TOKEN or VERCEL_BLOB_TOKEN environment variable, or provide token in config.");this.multipart=e.multipart??!1;const{metaStorage:t,metaStorageConfig:a}=e;this.meta=t||new b(a),this.isReady=!0}async create(e){return this.instrumentOperation("create",async()=>{const t={...e};if(e.ttl){const i=typeof e.ttl=="string"?O(e.ttl):e.ttl;t.expiredAt=i===void 0?void 0:Date.now()+i}const a=new m(t);a.name=this.namingFunction(a),await this.validate(a);try{const i=await this.getMeta(a.id);if(i.bytesWritten>=0)return i}catch{}return a.bytesWritten=0,a.status=c(a),await this.saveMeta(a),await this.onCreate(a),a})}async write(e){return this.instrumentOperation("write",async()=>{let t;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?t=e:(t=await this.getMeta(e.id),await this.checkIfExpired(t)),t.status==="completed")return t;if(e.size!==void 0&&v(t,e.size),!y(e,t))throw new Error("File part does not match");await this.lock(e.id);try{if(B(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))throw new Error("Unsupported checksum algorithm");const a=[],i=e.body;for await(const o of i)a.push(Buffer.from(o));const r=Buffer.concat(a);if((t.bytesWritten===0||Number.isNaN(t.bytesWritten))&&(!t.contentType||t.contentType==="application/octet-stream"))try{const o=await g(r);o?.mime&&(t.contentType=o.mime)}catch{}const u=new Blob([r],{type:t.contentType}),s=await h(t.name,u,{access:"public",multipart:this.shouldUseMultipart(t)});t.url=s.url,t.pathname=s.pathname,t.downloadUrl=s.downloadUrl,t.bytesWritten=r.length}return t.status=c(t),t.status==="completed"&&await this.internalOnComplete(t),await this.saveMeta(t),t}finally{await this.unlock(e.id)}})}async delete({id:e}){return this.instrumentOperation("delete",async()=>{const t=await this.getMeta(e);if(!t.url)throw new Error(`File ${e} does not have a valid URL`);t.status="deleted";try{await d(t.url,{token:this.token})}catch(i){this.logger?.error("Failed to delete blob from Vercel Blob:",i);const r=this.normalizeError(i instanceof Error?i:new Error(String(i)));await this.onError(r)}await this.deleteMeta(t.id);const a={...t};return await this.onDelete(a),a})}async exists({id:e}){return this.instrumentOperation("exists",async()=>{try{const t=await this.getMeta(e);return!t.url||t.url.length===0?!1:(await fetch(t.url,{method:"HEAD"})).ok}catch{return!1}})}async get({id:e}){return this.instrumentOperation("get",async()=>{const t=await this.checkIfExpired(await this.getMeta(e));if(!t.url||t.url.length===0)throw new Error("File URL not found");const a=await fetch(t.url),i=Buffer.from(await a.arrayBuffer());return{content:i,contentType:t.contentType,ETag:t.ETag,expiredAt:t.expiredAt,id:e,metadata:t.metadata,modifiedAt:t.modifiedAt,name:t.name,originalName:t.originalName,size:t.size||i.length}})}async copy(e,t){return this.instrumentOperation("copy",async()=>{const a=await this.getMeta(e);if(!a.url)throw new Error("Source file URL not found");const i=await f(a.url,t,{access:"public"});return{...a,id:t,name:t,pathname:i.pathname,url:i.url}})}async move(e,t){return this.instrumentOperation("move",async()=>{const a=await this.copy(e,t);return await this.delete({id:e}),a})}async list(e=1e3){return this.instrumentOperation("list",async()=>(await w({limit:e})).blobs.map(t=>{const a=new m({contentType:"application/octet-stream",metadata:{},originalName:t.pathname});return a.createdAt=t.uploadedAt?.toISOString(),a.id=t.pathname,a.modifiedAt=t.uploadedAt?.toISOString(),a.name=t.pathname,a.pathname=t.pathname,a.size=t.size,a.url=t.url,a.downloadUrl=t.downloadUrl,a}),{limit:e})}internalOnComplete=k(e=>this.deleteMeta(e.id),"internalOnComplete");shouldUseMultipart(e){return typeof this.multipart=="boolean"?this.multipart:typeof this.multipart=="number"&&e.size!==void 0?e.size>=this.multipart:!1}}export{z as default};
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var r=(t,e)=>c(t,"name",{value:e,configurable:!0});var p=Object.defineProperty,a=r((t,e)=>p(t,"name",{value:e,configurable:!0}),"t");function f(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}r(f,"getDefaultExportFromCjs");a(f,"getDefaultExportFromCjs");function l(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}r(l,"getDefaultExportFromNamespaceIfPresent");a(l,"getDefaultExportFromNamespaceIfPresent");function s(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")&&Object.keys(t).length===1?t.default:t}r(s,"getDefaultExportFromNamespaceIfNotNamed");a(s,"getDefaultExportFromNamespaceIfNotNamed");function m(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var o=a(r(function n(){var u=!1;try{u=this instanceof n}catch{}return u?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)},"a"),"a");o.prototype=e.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var u=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(o,n,u.get?u:{enumerable:!0,get:a(function(){return t[n]},"get")})}),o}r(m,"getAugmentedNamespace");a(m,"getAugmentedNamespace");export{f as g};
@@ -0,0 +1,4 @@
1
+ var f=Object.defineProperty;var u=(l,t)=>f(l,"name",{value:t,configurable:!0});import b from"./MetaStorage-Y4m1dWgd.js";import{parseMetadata as T,stringifyMetadata as k}from"./Metadata-B6Ir0KO7.js";import{Readable as w}from"node:stream";import{AwsClient as C}from"aws4fetch";import{o as E}from"./is-expired-1JuZjDtb.js";var x=Object.defineProperty,y=u((l,t)=>x(l,"name",{value:t,configurable:!0}),"p");const p=y(l=>{const t={},a=l.replaceAll(/<\?xml[^>]*\?>/g,"").replaceAll(/xmlns[^=]*="[^"]*"/g,""),e=/<([^>]+)>([^<]*)<\/\1>/g,o=[...a.matchAll(e)];for(const r of o){const[,n,i]=r;n&&i?.trim()&&(t[n]?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(i.trim())):t[n]=i.trim())}const s=/<([^>]+)>([\s\S]*?)<\/\1>/g;let c;for(;(c=s.exec(a))!==null;){const[,r,n]=c;if(r&&n?.includes("<")){const i=p(n);Object.keys(i).length>0&&(t[r]=i)}}return t},"parseXml");class U{static{u(this,"w")}static{y(this,"AwsLightApiAdapter")}aws;bucket;endpoint;constructor(t){this.bucket=t.bucket,this.endpoint=t.endpoint||`https://${t.bucket}.s3.${t.region}.amazonaws.com`,this.aws=new C({accessKeyId:t.accessKeyId,region:t.region,secretAccessKey:t.secretAccessKey,service:t.service||"s3",sessionToken:t.sessionToken})}async createMultipartUpload(t){const a={uploads:""},e={};if(t.ContentType&&(e["Content-Type"]=t.ContentType),t.ACL&&(e["x-amz-acl"]=t.ACL),t.Metadata)for(const[i,d]of Object.entries(t.Metadata))e[`x-amz-meta-${i}`]=d;const o=this.buildUrl(t.Key,a),s=await this.aws.fetch(o,{headers:e,method:"POST"}),c=await s.text();if(!s.ok)throw new Error(`Failed to create multipart upload: ${s.status} ${c}`);const r=p(c),n=r.UploadId||r.InitiateMultipartUploadResult?.UploadId;if(!n){const i=new Error("Failed to parse UploadId from response");throw i.retryable=!1,i}return{UploadId:n}}async uploadPart(t){const a={partNumber:String(t.PartNumber),uploadId:t.UploadId},e={};t.ContentLength&&(e["Content-Length"]=String(t.ContentLength)),t.ContentMD5&&(e["Content-MD5"]=t.ContentMD5);const o=t.Body instanceof w?w.toWeb(t.Body):t.Body,s=this.buildUrl(t.Key,a),c=await this.aws.fetch(s,{body:o,headers:e,method:"PUT"});if(!c.ok){const n=await c.text();throw new Error(`Failed to upload part: ${c.status} ${n}`)}const r=c.headers.get("ETag");if(!r)throw new Error("Failed to get ETag from response");return{ETag:r.replaceAll(/(^"|"$)/g,"")}}async completeMultipartUpload(t){const a={uploadId:t.UploadId},e=`<?xml version="1.0" encoding="UTF-8"?>
2
+ <CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
3
+ ${t.Parts.map(({ETag:d,PartNumber:h})=>`<Part><PartNumber>${h}</PartNumber><ETag>"${d}"</ETag></Part>`).join("")}
4
+ </CompleteMultipartUpload>`,o=this.buildUrl(t.Key,a),s=await this.aws.fetch(o,{body:e,headers:{"Content-Type":"application/xml"},method:"POST"}),c=await s.text();if(!s.ok)throw new Error(`Failed to complete multipart upload: ${s.status} ${c}`);const r=p(c),n=r.CompleteMultipartUploadResult||r,i=n.Location||`${this.endpoint}/${t.Key}`;return{ETag:n.ETag?.replaceAll(/(^"|"$)/g,""),Location:i}}async abortMultipartUpload(t){const a={uploadId:t.UploadId},e=this.buildUrl(t.Key,a),o=await this.aws.fetch(e,{method:"DELETE"});if(!o.ok){const s=await o.text();throw new Error(`Failed to abort multipart upload: ${o.status} ${s}`)}}async listParts(t){const a={uploadId:t.UploadId},e=this.buildUrl(t.Key,a),o=await this.aws.fetch(e,{method:"GET"}),s=await o.text();if(!o.ok)throw new Error(`Failed to list parts: ${o.status} ${s}`);const c=p(s),r=c.ListPartsResult||c;let n=[];return r.Part&&(n=Array.isArray(r.Part)?r.Part:[r.Part]),{Parts:n.map(i=>({ETag:i.ETag?.replaceAll(/(^"|"$)/g,""),PartNumber:Number(i.PartNumber)||0,Size:i.Size?Number(i.Size):void 0}))}}async getObject(t){const a=this.buildUrl(t.Key),e=await this.aws.fetch(a,{method:"GET"});if(!e.ok){const h=await e.text();throw new Error(`Failed to get object: ${e.status} ${h}`)}const o=e.headers.get("Content-Length"),s=e.headers.get("Content-Type"),c=e.headers.get("ETag"),r=e.headers.get("Expires"),n=e.headers.get("Last-Modified"),i={};for(const[h,m]of e.headers.entries())if(h.toLowerCase().startsWith("x-amz-meta-")){const g=h.toLowerCase().replace("x-amz-meta-","");i[g]=m}const{body:d}=e;return{Body:d?this.streamToReadable(d):void 0,ContentLength:o?Number(o):void 0,ContentType:s||void 0,ETag:c?.replaceAll(/(^"|"$)/g,"")||void 0,Expires:r?new Date(r):void 0,LastModified:n?new Date(n):void 0,Metadata:Object.keys(i).length>0?i:void 0}}async headObject(t){const a=this.buildUrl(t.Key),e=await this.aws.fetch(a,{method:"HEAD"});if(!e.ok){const d=await e.text();throw new Error(`Failed to head object: ${e.status} ${d}`)}const o=e.headers.get("Content-Length"),s=e.headers.get("Content-Type"),c=e.headers.get("ETag"),r=e.headers.get("Expires"),n=e.headers.get("Last-Modified"),i={};for(const[d,h]of e.headers.entries())if(d.toLowerCase().startsWith("x-amz-meta-")){const m=d.toLowerCase().replace("x-amz-meta-","");i[m]=h}return{ContentLength:o?Number(o):void 0,ContentType:s||void 0,ETag:c?.replaceAll(/(^"|"$)/g,"")||void 0,Expires:r?new Date(r):void 0,LastModified:n?new Date(n):void 0,Metadata:Object.keys(i).length>0?i:void 0}}async deleteObject(t){const a=this.buildUrl(t.Key),e=await this.aws.fetch(a,{method:"DELETE"});if(!e.ok){const o=await e.text();throw new Error(`Failed to delete object: ${e.status} ${o}`)}}async copyObject(t){const a={"x-amz-copy-source":t.CopySource};t.StorageClass&&(a["x-amz-storage-class"]=t.StorageClass);let e=this.buildUrl(t.Key);t.Bucket!==this.bucket&&(e=e.replace(this.bucket,t.Bucket));const o=await this.aws.fetch(e,{headers:a,method:"PUT"});if(!o.ok){const s=await o.text();throw new Error(`Failed to copy object: ${o.status} ${s}`)}}async listObjectsV2(t){const a={"list-type":"2"};t.MaxKeys&&(a["max-keys"]=String(t.MaxKeys)),t.ContinuationToken&&(a["continuation-token"]=t.ContinuationToken);const e=this.buildUrl("",a),o=await this.aws.fetch(e,{method:"GET"}),s=await o.text();if(!o.ok)throw new Error(`Failed to list objects: ${o.status} ${s}`);const c=p(s),r=c.ListBucketResult||c,n=r.Contents||(Array.isArray(r.Contents)?r.Contents:[]);return{Contents:Array.isArray(n)?n.map(i=>({Key:i.Key,LastModified:i.LastModified?new Date(String(i.LastModified)):void 0})):[],IsTruncated:r.IsTruncated==="true"||r.IsTruncated===!0,NextContinuationToken:r.NextContinuationToken}}async getPresignedUrl(t){const a={partNumber:String(t.PartNumber),uploadId:t.UploadId,"X-Amz-Expires":String(t.expiresIn)};return this.buildUrl(t.Key,a)}async putObject(t){const a=this.buildUrl(t.Key),e={};if(t.ContentType&&(e["Content-Type"]=t.ContentType),t.ContentLength!==void 0&&(e["Content-Length"]=String(t.ContentLength)),t.Metadata)for(const[c,r]of Object.entries(t.Metadata))e[`x-amz-meta-${c}`]=r;let o;t.Body===void 0?o=void 0:t.Body instanceof Uint8Array?o=new Uint8Array(t.Body):t.Body instanceof ReadableStream?o=t.Body:o=void 0;const s=await this.aws.fetch(a,{body:o,headers:e,method:"PUT"});if(!s.ok){const c=await s.text();throw new Error(`Failed to put object: ${s.status} ${c}`)}}async checkBucketAccess(t){const a=this.buildUrl(""),e=await this.aws.fetch(a,{method:"HEAD"});if(!e.ok&&e.status!==404){const o=await e.text();throw new Error(`Failed to access bucket: ${e.status} ${o}`)}}buildUrl(t,a){const e=new URL(t,this.endpoint);if(a)for(const[o,s]of Object.entries(a))e.searchParams.set(o,s);return e.toString()}streamToReadable(t){return w.fromWeb(t)}}var $=Object.defineProperty,A=u((l,t)=>$(l,"name",{value:t,configurable:!0}),"n");class I extends b{static{u(this,"l")}constructor(t){super(t),this.config=t;const a=t.bucket||process.env.S3_BUCKET||process.env.AWS_S3_BUCKET;if(!a)throw new Error("S3 bucket is not defined");this.bucket=a,this.adapter=new U({accessKeyId:t.accessKeyId,bucket:a,endpoint:t.endpoint,region:t.region,secretAccessKey:t.secretAccessKey,service:t.service,sessionToken:t.sessionToken}),this.adapter.checkBucketAccess({Bucket:a}).catch(e=>{throw e})}config;static{A(this,"AwsLightMetaStorage")}adapter;bucket;async get(t){const a=this.getMetaName(t),{Expires:e,Metadata:o}=await this.adapter.headObject({Bucket:this.bucket,Key:a});if(e&&E({expiredAt:e}))throw await this.delete(a),new Error(`Metafile ${t} not found`);if(o?.metadata!==void 0){const s=JSON.parse(decodeURIComponent(o.metadata));return s.metadata&&typeof s.metadata=="string"&&(s.metadata=T(s.metadata)),s}throw new Error(`Metafile ${t} not found`)}async touch(t,a){return this.save(t,a)}async delete(t){await this.adapter.deleteObject({Bucket:this.bucket,Key:this.getMetaName(t)})}async save(t,a){const e={...a};e.metadata&&(e.metadata=k(a.metadata));const o=encodeURIComponent(JSON.stringify(e));return await this.adapter.putObject({Bucket:this.bucket,ContentLength:0,ContentType:"application/json",Key:this.getMetaName(t),Metadata:{metadata:o}}),a}}export{I as l,U as w};
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var n=(r,e)=>a(r,"name",{value:e,configurable:!0});var o=Object.defineProperty,p=n((r,e)=>o(r,"name",{value:e,configurable:!0}),"n");const i=p(r=>{const{applicationKey:e,applicationKeyId:c,region:s}=r??{applicationKey:process.env.AWS_SECRET_ACCESS_KEY||process.env.B2_APP_KEY||process.env.BACKBLAZE_APP_KEY,applicationKeyId:process.env.AWS_ACCESS_KEY_ID||process.env.B2_APP_KEY_ID||process.env.BACKBLAZE_APP_KEY_ID,region:process.env.AWS_REGION||process.env.B2_REGION||process.env.BACKBLAZE_REGION};if(!s||!c||!e)throw new Error("Missing required parameters for Backblaze B2 client.");return{credentials:{accessKeyId:c,secretAccessKey:e},endpoint:`https://s3.${s}.backblazeb2.com`,region:s}},"backblaze");export{i as backblaze,i as default};
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var c=(r,e)=>g(r,"name",{value:e,configurable:!0});import{EventEmitter as b}from"node:events";import{format as y}from"node:url";import w from"mime";import{ErrorMap as E}from"./ERRORS-B9jkvKwx.js";import{H as R}from"./headers-DC2MEOrK.js";import{Readable as h}from"node:stream";import v,{hasBody as U}from"type-is";var H=Object.defineProperty,I=c((r,e)=>H(r,"name",{value:e,configurable:!0}),"a");const L=I(r=>r.at(-1),"getLastOne");var N=Object.defineProperty,i=c((r,e)=>N(r,"name",{value:e,configurable:!0}),"n");const x=i(r=>{let e="",t="";const s=f(r,"forwarded");return s&&s.split(";").forEach(n=>{const[a,o]=n.split("=");a==="proto"&&(e=o),a==="host"&&(t=o)}),{host:t,proto:e}},"extractForwarded"),P=i((r,e="utf8",t)=>new Promise((s,n)=>{let a="";r.setEncoding(e),r.on("data",o=>{if(t&&a.length+o.length>t){n(new Error("Request body length limit exceeded"));return}a+=o}),r.once("end",()=>{s(a)})}),"readBody"),f=i((r,e,t=!1)=>{const s=r.headers?.[e.toLowerCase()];if(!s||s.length===0)return"";if(t)return s.toString().trim();const n=Array.isArray(s)?s:s.split(",");return L(n).trim()},"getHeader");i(async(r,e=16777216)=>{if(!v(r,["json"]))return{};if(r.body)return{...r.body};if(U(r)){const s=Number.parseInt(f(r,"content-length"),10);if(!Number.isNaN(s)&&s>e)throw new Error("body length limit")}const t=await P(r,"utf8",e);return{...JSON.parse(t)}},"getMetadata");const $=i((r,e,t)=>{const s=[r.getHeader(e),t].flat().filter(Boolean).toString();r.setHeader(e,s)},"appendHeader"),G=i((r,e={})=>{const t=Object.keys(e);t.length>0&&$(r,"Access-Control-Expose-Headers",t),t.forEach(s=>{["link","location"].includes(s.toLowerCase())?r.setHeader(s,encodeURI(e[s].toString())):r.setHeader(s,e[s])})},"setHeaders"),q=i(r=>f(r,"host")||f(r,"x-forwarded-host"),"extractHost"),F=i(r=>f(r,"x-forwarded-proto").toLowerCase(),"extractProto"),T=i(r=>{let{host:e,proto:t}=x(r);return e||=q(r),t||=F(r),e?t?`${t}://${e}`:`//${e}`:""},"getBaseUrl"),B=i(r=>{let e=(r.originalUrl||r.url||"").split("?")[0];if(!e)throw new TypeError("Invalid request URL");return e.startsWith("/")||(e=`/${e}`),e.startsWith("http")&&(e=new URL(e).pathname),e},"getRealPath"),O=/(?:[\dA-Z]+-){2}[\dA-Z]+/i,K=i(r=>{const e=B(r).split("/").filter(Boolean);if(e.length===0)throw new Error("Invalid request URL");for(let n=e.length-1;n>=0;n-=1){const a=e[n];if(!a)continue;const o=a.replace(/\.[^/.]+$/,"");if(!["files","metadata","upload","download","http-rest","http-rest-chunked"].includes(o.toLowerCase())&&O.test(o))return o}const t=e[e.length-1];if(!t)throw new Error("Invalid request URL");const s=t.replace(/\.[^/.]+$/,"");if(["files","metadata","upload","download","http-rest","http-rest-chunked"].includes(s.toLowerCase()))throw new Error("Invalid request URL");if(s.length<8)throw new Error("Invalid request URL");if(e.length>1)return s;throw new Error("Invalid request URL")},"getIdFromRequest"),Q=i(r=>"body"in r&&r.body&&typeof r.body.getReader=="function"?h.fromWeb(r.body):"body"in r&&r.body&&r.body instanceof Uint8Array?h.from(Buffer.from(r.body)):r instanceof h?r:h.from(new Uint8Array(0)),"getRequestStream");var j=Object.defineProperty,C=c((r,e)=>j(r,"name",{value:e,configurable:!0}),"r");const V=C((r,e)=>{const t={};return e.forEach(s=>{t[s]=r[s]}),t},"pick");var A=Object.defineProperty,p=c((r,e)=>A(r,"name",{value:e,configurable:!0}),"d");class X extends b{static{c(this,"E")}static{p(this,"BaseHandlerCore")}responseType="json";storage;mediaTransformer;disableTerminationForFinishedUploads;logger;get loggerInstance(){return this.logger}internalErrorResponses={};get errorResponses(){return this.internalErrorResponses}constructor({disableTerminationForFinishedUploads:e,mediaTransformer:t,storage:s}){super(),this.storage=s,this.mediaTransformer=t,this.disableTerminationForFinishedUploads=e,this.logger=this.storage?.logger,this.assembleErrors()}set errorResponses(e){this.assembleErrors(e)}assembleErrors=p((e={})=>{this.internalErrorResponses={...E,...this.internalErrorResponses,...this.storage.errorResponses,...e}},"assembleErrors");parseRangeHeader(e,t){if(!e?.startsWith("bytes="))return;const s=e.slice(6).split(",");if(s.length!==1)return;const n=s[0]?.trim();if(!n)return;const a=n.split("-");if(a.length!==2)return;const[o,u]=a;let d,l;if(o&&u)d=Number.parseInt(o,10),l=Number.parseInt(u,10);else if(o&&!u)d=Number.parseInt(o,10),l=t-1;else if(!o&&u){const m=Number.parseInt(u,10);d=Math.max(0,t-m),l=t-1}else return;if(!(Number.isNaN(d)||Number.isNaN(l)||d>=t||l>=t||d>l))return{end:l,start:d}}buildFileUrlFromString(e,t){const s=new URL(e,"http://localhost"),{pathname:n}=s,a=Object.fromEntries(s.searchParams.entries()),o=y({pathname:`${n}/${t.id}`,query:a});return`${this.storage.config.useRelativeLocation?"":T({url:e})}${o}.${w.getExtension(t.contentType)}`}negotiateContentTypeFromHeader(e,t){if(e)return R.getPreferredMediaType(e,t)}checkForUndefinedIdOrPath(e){if(e instanceof Error&&["Id is undefined","Invalid request URL","Path is undefined"].includes(e.message))throw e}}export{X as E,V as T,f as a,Q as b,T as c,B as d,K as g,P as r,G as s,O as u};
@@ -0,0 +1 @@
1
+ var E=Object.defineProperty;var u=(h,t)=>E(h,"name",{value:t,configurable:!0});import{H as m,h as b}from"./headers-DC2MEOrK.js";import{ERRORS as g,isUploadError as R}from"./ERRORS-B9jkvKwx.js";import{E as v,T as O}from"./base-handler-core-DaggCVsq.js";import{i as H}from"./validator-DK41xp8N.js";import{waitForStorage as w}from"./waitForStorage-ChSBLhLc.js";var T=Object.defineProperty,x=u((h,t)=>T(h,"name",{value:t,configurable:!0}),"m");class z extends v{static{u(this,"O")}static{x(this,"BaseHandlerFetch")}static methods=["delete","get","head","options","patch","post","put"];registeredHandlers=new Map;constructor(t){super(t),this.compose()}get handlers(){return this.registeredHandlers}async fetch(t){this.logger?.debug("[fetch request]: %s %s",t.method,t.url);const e=this.registeredHandlers.get(t.method||"GET");if(!e)return this.createErrorResponse({UploadErrorCode:g.METHOD_NOT_ALLOWED});try{await w(this.storage)}catch{return this.createErrorResponse({UploadErrorCode:g.STORAGE_ERROR})}try{const r=await e.call(this,t);return this.handleFetchResponse(t,r)}catch(r){const s=r instanceof Error?r:new Error(String(r)),o={...O(s,["name",...Object.getOwnPropertyNames(s)]),request:{headers:Object.fromEntries(t.headers.entries()),method:t.method,url:t.url}};return this.listenerCount("error")>0&&this.emit("error",o),this.logger?.error("[fetch error]: %O",o),this.createErrorResponse(s)}}async handleFetchResponse(t,e){if(t.method==="HEAD"||t.method==="OPTIONS"){const{headers:n,statusCode:d}=e;return new Response(void 0,{headers:this.convertHeaders({...n,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control"}),status:d})}if(t.method==="GET"){const{headers:n,statusCode:d}=e;let c="";return e.content!==void 0?c=new Uint8Array(e.content):typeof e=="object"&&"data"in e&&(c=JSON.stringify(e.data)),new Response(c,{headers:this.convertHeaders({...n,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control"}),status:d})}const{headers:r,statusCode:s,...o}=e;if(o.status!==void 0&&this.listenerCount(o.status)>0&&this.emit(o.status,{...o,request:{headers:Object.fromEntries(t.headers.entries()),method:t.method,url:t.url}}),o.status==="completed"){const n=e;n.headers===void 0&&(n.headers={}),n.statusCode===void 0&&(n.statusCode=200);try{await this.storage.onComplete(o,n)}catch(p){throw this.logger?.error("[onComplete error]: %O",p),p}const{headers:d,statusCode:c,...f}=n,{content:j,stream:S,...C}=f;return this.createResponse({body:C,headers:d||r,statusCode:c||s||200})}const y={...r,...e.headers},a=this.convertHeaders({...y,"Access-Control-Expose-Headers":"location,upload-expires,upload-offset,upload-length,upload-metadata,upload-defer-length,tus-resumable,tus-extension,tus-max-size,tus-version,tus-checksum-algorithm,cache-control",...o.hash===void 0?{}:{[`X-Range-${o.hash?.algorithm.toUpperCase()}`]:o.hash?.value}}),l=e.headers||{};l.Location&&!a.location&&!a.Location?a.location=String(l.Location):l.location&&!a.location&&!a.Location?a.location=String(l.location):r.Location&&!a.location&&!a.Location?a.location=String(r.Location):r.location&&!a.location&&!a.Location&&(a.location=String(r.location));let i;return s>=200&&s<300&&(i=Object.keys(o).length>0?{...o}:{},"content"in i&&delete i.content,"stream"in i&&delete i.stream,Object.keys(i).length===0&&(i={})),this.createResponse({body:i,headers:a,statusCode:s||200})}convertHeaders(t){const e={};for(const[r,s]of Object.entries(t))e[r]=Array.isArray(s)?s.join(", "):String(s);return e}createResponse(t){const{body:e,headers:r={},statusCode:s}=t;let o;return s===204?o=null:typeof e=="string"?o=e:e instanceof Buffer?o=new Uint8Array(e):e&&typeof e=="object"?(o=JSON.stringify(e),r["Content-Type"]||(r["Content-Type"]=m.createContentType({charset:"utf8",mediaType:"application/json"}))):e===void 0&&s!==void 0&&s>=200&&s<300&&(o="{}",r["Content-Type"]||(r["Content-Type"]=m.createContentType({charset:"utf8",mediaType:"application/json"}))),new Response(o,{headers:this.convertHeaders(r),status:s})}async createErrorResponse(t){let e;R(t)?e=this.internalErrorResponses[t.UploadErrorCode]:!H(t)&&!b.isHttpError(t)?e=this.storage.normalizeError(t):e={...t,code:t.code||t.name,headers:t.headers||{},message:t.message,name:t.name,statusCode:t.statusCode||500},await this.storage.onError(e);let r;return e.body?typeof e.body=="object"&&e.body!==null?r={body:e.body,headers:e.headers,statusCode:e.statusCode}:r={body:{error:{code:e.code||e.name||"Error",message:e.body||e.message||"Unknown error",name:e.name||"Error"}},headers:e.headers,statusCode:e.statusCode||500}:r={body:{error:{code:e.code||e.name||"Error",message:e.message||"Unknown error",name:e.name||"Error"}},headers:e.headers,statusCode:e.statusCode||500},this.createResponse(r)}buildFileUrl(t,e){return this.buildFileUrlFromString(t.url,e)}negotiateContentType(t,e){return super.negotiateContentTypeFromHeader(t.headers.get("accept")||void 0,e)}}export{z as O};
@@ -0,0 +1 @@
1
+ var M=Object.defineProperty;var C=(i,e)=>M(i,"name",{value:e,configurable:!0});import{paginate as P}from"@visulima/pagination";import{H as T,h as z,n as y}from"./headers-DC2MEOrK.js";import O from"mime";import{isUploadError as $,ERRORS as m}from"./ERRORS-B9jkvKwx.js";import{match as k}from"path-to-regexp";import{T as S,E as q,s as A,d as U,u as x}from"./base-handler-core-DaggCVsq.js";import{i as D}from"./validator-DK41xp8N.js";import{waitForStorage as _}from"./waitForStorage-ChSBLhLc.js";import{PassThrough as I}from"node:stream";import{e as H}from"./response-builder-Wdo_fvcF.js";var X=Object.defineProperty,G=C((i,e)=>X(i,"name",{value:e,configurable:!0}),"n");const W=k(["/:uuid","/*path/:uuid.:ext/:metadata","/*path/:uuid/:metadata","/*path/:uuid.:ext","/*path/:uuid"],{decode:decodeURIComponent}),L=G(i=>{const e=W(i);if(!e)return;const{params:t}=e;if(!t.uuid)return;const r={uuid:t.uuid};return t.metadata!==void 0&&(r.metadata=t.metadata),t.path!==void 0&&(r.path=t.path),t.ext!==void 0&&(r.ext=t.ext),{params:r,path:e.path}},"filePathUrlMatcher");var B=Object.defineProperty,v=C((i,e)=>B(i,"name",{value:e,configurable:!0}),"a");const J=v((i,e,t)=>{let r=0,a=0;const o=t-e+1;return new I({highWaterMark:Math.min(64*1024,o),transform(n,h,s){const l=n.length,d=r,p=d+l-1;if(r+=l,p<e){s();return}if(d>t){this.end(),s();return}const u=Math.max(0,e-d),f=Math.min(l,t-d+1);if(u<f){const b=n.subarray(u,f);a+=b.length,this.push(b)||i.pause()}a>=o&&(this.end(),i.destroy()),s()}})},"createRangeLimitedStream"),V=v((i,e,t)=>{let r=!1;const a=v(()=>{r||(r=!0,i.destroy())},"cleanup");e.on("drain",()=>{i.resume()}),e.on("close",a),e.on("finish",a),e.on("error",a),i.on("end",()=>{e.end()}),i.on("error",async o=>{r||(await t(e,o),a())}),i.on("data",o=>{e.write(o)||i.pause()}),typeof e.listeners=="function"&&e.listeners("close")?.length===0&&e.on("close",a)},"pipeWithBackpressure");v((i,e,t={})=>({headers:t,size:e,stream:i}),"createStreamResponse");var K=Object.defineProperty,w=C((i,e)=>K(i,"name",{value:e,configurable:!0}),"u");const Q=w((i,e,t)=>{const{headers:r,statusCode:a}=i;e(t,{headers:r,statusCode:a})},"handleHeadOptionsRequest"),Y=w((i,e,t,r,a,o,n)=>{e.body=i?.data===void 0?i:i.data;const{headers:h,statusCode:s}=i,l=i;if(l.stream)if(typeof r=="function")r();else{const d=n(e.headers.range,l.size||0);o(t,l.stream,{headers:h,range:d||void 0,size:l.size,statusCode:s})}else{let d="";i.content!==void 0?d=i.content:typeof i=="object"&&"data"in i&&(d=i.data),typeof r=="function"?r():a(t,{body:d,headers:h,statusCode:s})}},"handleGetRequest"),Z=w(async(i,e,t,r,a,o,n)=>{const{headers:h,statusCode:s,...l}=i;if(typeof r=="function")e._body=!0,e.body=l,r();else{const d=i,p=d.headers?{...d.headers}:{};d.headers===void 0&&(d.headers={}),d.statusCode===void 0&&(d.statusCode=200);try{const u=a.onComplete(l,d,e);u instanceof Promise&&await u}catch(u){throw o?.error&&o.error("[onComplete error]: %O",u),u}Object.keys(d.headers||{}).length===0&&Object.keys(p).length>0?d.headers=p:d.headers&&Object.keys(p).length>0&&(d.headers={...p,...d.headers}),n(e,t,d)}},"handleCompletedUpload"),ee=w((i,e,t,r)=>{const{headers:a,statusCode:o,...n}=i,h=a||{},s=h["X-Chunked-Upload"]==="true"||h["x-chunked-upload"]==="true";let l;const d={...H(h),...a?H(a):{},...n.hash===void 0?{}:{[`X-Range-${n.hash?.algorithm.toUpperCase()}`]:String(n.hash?.value)}};s&&(l=JSON.stringify(n),!d["Content-Type"]&&!d["content-type"]&&(d["Content-Type"]="application/json; charset=utf-8")),e.method==="HEAD"&&(l=""),r(t,{body:l,headers:d,statusCode:o||200})},"handlePartialUpload"),te=w(async(i,e,t,r,a,o,n)=>{const h=i instanceof Error?i:new Error(String(i)),s={...S(h,["name",...Object.getOwnPropertyNames(h)]),request:S(e,["headers","method","url"])};r("error")>0&&t("error",s),a?.error&&a.error("[error]: %O",s),await o(n,h)},"handleUploadError");var re=Object.defineProperty,R=C((i,e)=>re(i,"name",{value:e,configurable:!0}),"C");const g="Content-Type";class N extends q{static{C(this,"F")}static{R(this,"BaseHandlerNode")}static methods=["delete","get","head","options","patch","post","put"];registeredHandlers=new Map;constructor(e){super(e),this.compose()}get handlers(){return this.registeredHandlers}handle=R(async(e,t)=>this.upload(e,t),"handle");upload=R(async(e,t,r)=>{e.on("error",o=>this.logger?.error("[request error]: %O",o)),this.logger?.debug("[request]: %s %s",e.method,e.url);const a=this.registeredHandlers.get(e.method);if(!a){await this.sendError(t,{UploadErrorCode:m.METHOD_NOT_ALLOWED});return}try{await _(this.storage)}catch{await this.sendError(t,{UploadErrorCode:m.STORAGE_ERROR});return}try{const o=await a.call(this,e,t);if(["HEAD","OPTIONS"].includes(e.method))Q(o,this.send.bind(this),t);else if(e.method==="GET"){const n=o;n&&Y(n,e,t,r,this.send.bind(this),this.sendStream.bind(this),this.parseRangeHeader.bind(this))}else{const{headers:n,statusCode:h,...s}=o;this.logger?.debug("[%s]: %s: %d/%d",s.status,s.name,s.bytesWritten,s.size),s.status!==void 0&&this.listenerCount(s.status)>0&&this.emit(s.status,{...s,request:S(e,["headers","method","url"])}),s.status==="completed"?await Z(o,e,t,r,this.storage,this.logger,(l,d,p)=>{this.finish(l,d,p)}):ee(o,e,t,(l,d)=>{this.send(l,{body:d.body,headers:d.headers,statusCode:d.statusCode})})}}catch(o){await te(o,e,this.emit.bind(this),this.listenerCount.bind(this),this.logger,this.sendError.bind(this),t)}},"upload");send(e,{body:t="",headers:r={},statusCode:a=200}){let o;const n={...r};if(typeof t=="string"){if(o=t,n[g]===void 0)n[g]=T.createContentType({mediaType:"text/plain"});else{const h=Array.isArray(n[g])?n[g].join(", "):String(n[g]);n[g]=T.ensureCharset(h)}n["Content-Length"]===void 0&&(n["Content-Length"]=Buffer.byteLength(t))}else t instanceof Buffer?o=t:(o=JSON.stringify(t),n[g]||(n[g]=T.createContentType({charset:"utf8",mediaType:"application/json"})));A(e,n),e.statusCode=a,e.end(o)}async sendError(e,t){let r;$(t)?r=this.internalErrorResponses[t.UploadErrorCode]:!D(t)&&!z.isHttpError(t)?r=this.storage.normalizeError(t):r={...t,code:t.code||t.name,headers:t.headers||{},message:t.message,name:t.name,statusCode:t.statusCode||500},await this.storage.onError(r);let a;r.body?typeof r.body=="object"&&r.body!==null?a={body:r.body,headers:r.headers,statusCode:r.statusCode}:a={body:{error:{code:r.code||r.name||"Error",message:r.body||r.message||"Unknown error",name:r.name||"Error"}},headers:r.headers,statusCode:r.statusCode||500}:a={body:{error:{code:r.code||r.name||"Error",message:r.message||"Unknown error",name:r.name||"Error"}},headers:r.headers,statusCode:r.statusCode||500},this.send(e,a)}sendStream(e,t,{headers:r={},range:a,size:o,statusCode:n=200}){A(e,r),e.statusCode=n;let h=t;a&&o?(e.statusCode=206,e.setHeader("Content-Range",`bytes ${a.start}-${a.end}/${o}`),e.setHeader("Content-Length",a.end-a.start+1),e.setHeader("Accept-Ranges","bytes"),h=J(t,a.start,a.end)):(o&&e.setHeader("Content-Length",o),e.setHeader("Accept-Ranges","bytes")),V(h,e,(s,l)=>this.sendError(s,l))}finish(e,t,r){const a="id"in r&&"headers"in r&&!("body"in r);let o,n,h;if(a){const s=r,l=s.headers||{},d=s.statusCode||200,{headers:p,statusCode:u,...f}=s;o=f,n={...l},h=d}else{const s=r;o=s.body,n=s.headers||{},h=s.statusCode||200}if(o&&typeof o=="object"&&o.content!==void 0){const{content:s,contentType:l}=o;o=s,n={...n,"Content-Type":l}}this.send(t,{body:o||r,headers:n,statusCode:h})}buildFileUrl(e,t){return this.buildFileUrlFromString(e.originalUrl||e.url,t)}negotiateContentType(e,t){return super.negotiateContentTypeFromHeader(e.headers.accept,t)}async options(e,t){return{headers:{"Access-Control-Allow-Methods":(this.constructor.methods||N.methods).map(r=>r.toUpperCase()).join(", ")},statusCode:204}}async get(e,t){const r=L(U(e));if(r?.params.uuid){const{ext:a,metadata:o,uuid:n}=r.params,h=a?n.replace(new RegExp(String.raw`\.${a}$`),""):n;if(o==="metadata"&&U(e).endsWith("/metadata"))try{const s=await this.storage.getMeta(h);return{...s,content:JSON.stringify(s),headers:{"Content-Type":T.createContentType({charset:"utf8",mediaType:"application/json"}),...s.expiredAt===void 0?{}:{"X-Upload-Expires":s.expiredAt.toString()},...s.modifiedAt===void 0?{}:{"Last-Modified":s.modifiedAt.toString()}},statusCode:200}}catch(s){const l=s;throw l.UploadErrorCode===m.FILE_NOT_FOUND||l.UploadErrorCode===m.GONE?y(404,"File metadata not found"):s}if(!x.test(h))return this.list(e,t);try{const s=new URL(e.url||"","http://localhost"),l=Object.fromEntries(s.searchParams.entries());if(Object.keys(l).length>0&&this.mediaTransformer&&this.mediaTransformer)try{const c=await this.mediaTransformer.handle(h,l);return{content:c.buffer,headers:{"Content-Length":String(c.size),"Content-Type":`${c.mediaType}/${c.format}`,"X-Media-Type":c.mediaType,"X-Original-Format":c.originalFile?.contentType?.split("/")[1]||"","X-Transformed-Format":c.format,...c.originalFile?.expiredAt===void 0?{}:{"X-Upload-Expires":c.originalFile.expiredAt.toString()},...c.originalFile?.modifiedAt===void 0?{}:{"Last-Modified":c.originalFile.modifiedAt.toString()},...c.originalFile?.ETag===void 0?{}:{ETag:c.originalFile.ETag}},statusCode:200}}catch(c){if(c.name==="ValidationError")throw y(400,c.message);this.logger?.warn(`Media transformation failed: ${c.message}`)}const d=await this.storage.getMeta(h);if((e.headers.range||d.size&&d.size>1024*1024)&&this.storage.getStream)try{const c=await this.storage.getStream({id:h});let E=c.headers?.["Content-Type"]||d.contentType;return E.includes("image")&&typeof a=="string"&&(E=O.getType(a)||E),{headers:{...c.headers,"Accept-Ranges":"bytes","Content-Type":E},size:c.size,statusCode:200,stream:c.stream,...d,contentType:E}}catch(c){this.logger?.warn(`Streaming failed, falling back to buffer: ${c}`)}const p=await this.storage.get({id:h});let{contentType:u}=p;u.includes("image")&&typeof a=="string"&&(u=O.getType(a)||u);const{ETag:f,expiredAt:b,modifiedAt:F,size:j}=p;return{headers:{"Accept-Ranges":"bytes","Content-Length":String(j),"Content-Type":u,...b===void 0?{}:{"X-Upload-Expires":b.toString()},...F===void 0?{}:{"Last-Modified":F.toString()},...f===void 0?{}:{ETag:f}},statusCode:200,...p,contentType:u}}catch(s){const l=s;throw l.UploadErrorCode===m.FILE_NOT_FOUND||l.UploadErrorCode===m.GONE?y(404,"File not found"):s}}return this.list(e,t)}async list(e,t){const r=new URL(e.url||"","http://localhost"),a=r.searchParams.get("limit"),o=r.searchParams.get("page"),n=await this.storage.list(Number(a||1e3));return n.length===0?{data:[],headers:{},statusCode:200}:o!==void 0&&a!==void 0?{data:P(Number(o),Number(a),n.length,n),headers:{},statusCode:200}:{data:n,headers:{},statusCode:200}}async download(e,t){const r=L(U(e));if(!r?.params.uuid||!x.test(r.params.uuid))throw y(404,"File not found");const{ext:a,uuid:o}=r.params;try{const n=await this.storage.getMeta(o);if(!this.storage.getStream){await this.sendError(t,y(501,"Streaming download not supported"));return}const h=await this.storage.getStream({id:o});let s=h.headers?.["Content-Type"]||n.contentType;s.includes("image")&&typeof a=="string"&&(s=O.getType(a)||s);const l=this.parseRangeHeader(e.headers.range,h.size||0),d={...h.headers,"Accept-Ranges":"bytes","Content-Disposition":T.createContentDisposition({filename:n.originalName||o,type:"attachment"}),"Content-Type":s};this.sendStream(t,h.stream,{headers:d,range:l||void 0,size:h.size,statusCode:l?206:200})}catch(n){const h=n;if(h.UploadErrorCode===m.FILE_NOT_FOUND||h.UploadErrorCode===m.GONE){await this.sendError(t,y(404,"File not found"));return}await this.sendError(t,n)}}checkForUndefinedIdOrPath(e){if(e instanceof Error&&["Id is undefined","Invalid request URL","Path is undefined"].includes(e.message))throw y(404,"File not found")}}export{N as F};
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var t=(e,r)=>a(e,"name",{value:r,configurable:!0});var s=Object.defineProperty,u=t((e,r)=>s(e,"name",{value:r,configurable:!0}),"n");class n{static{t(this,"NoOpCache")}static{u(this,"NoOpCache")}get(){}set(){return!0}delete(){return!0}clear(){}has(){return!1}}export{n as N};
@@ -0,0 +1 @@
1
+ var C=Object.defineProperty;var n=(s,e)=>C(s,"name",{value:e,configurable:!0});var t=Object.defineProperty,E=n((s,e)=>t(s,"name",{value:e,configurable:!0}),"C");const _=E(s=>{const{accessKeyId:e,accountId:c,jurisdiction:r,secretAccessKey:o}=s??{accessKeyId:process.env.AWS_ACCESS_KEY_ID||process.env.CLOUDFLARE_ACCESS_KEY_ID||process.env.CLOUDFLARE_ACCESS_KEY,accountId:process.env.CLOUDFLARE_ACCOUNT_ID,jurisdiction:process.env.CLOUDFLARE_JURISDICTION||process.env.CLOUDFLARE_R2_JURISDICTION,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY||process.env.CLOUDFLARE_SECRET_ACCESS_KEY||process.env.CLOUDFLARE_SECRET_KEY};if(!c||!e||!o)throw new Error("Missing required parameters for Cloudflare R2 client.");return{credentials:{accessKeyId:e,secretAccessKey:o},endpoint:`https://${c}.${r?`${r}.`:""}r2.cloudflarestorage.com`,region:"auto"}},"cloudflare");export{_ as cloudflare,_ as default};
@@ -0,0 +1 @@
1
+ import"node:stream";import"node:timers";import"node:util";import{B as u,d as F,a as g}from"./storage-m_Cxgiih.js";import"./path-D7rMc9nq-B718mbm6.js";import"type-is";import"./NoOpMetrics-Dky06sf1.js";import"./cache-qV_5Umeq.js";import"./ERRORS-B9jkvKwx.js";import"./validator-DK41xp8N.js";import"./is-expired-1JuZjDtb.js";export{u as BaseStorage,F as defaultCloudStorageFileNameValidation,g as defaultFilesystemFileNameValidation};
@@ -0,0 +1 @@
1
+ var t=Object.defineProperty;var n=(r,e)=>t(r,"name",{value:e,configurable:!0});var a=Object.defineProperty,o=n((r,e)=>a(r,"name",{value:e,configurable:!0}),"n");const S=o(r=>{const{key:e,region:s,secret:c}=r??{key:process.env.AWS_ACCESS_KEY_ID||process.env.SPACES_KEY,region:process.env.AWS_REGION||process.env.SPACES_REGION,secret:process.env.AWS_SECRET_ACCESS_KEY||process.env.SPACES_SECRET};if(!s||!e||!c)throw new Error("Missing required parameters for DigitalOcean Spaces client.");return{credentials:{accessKeyId:e,secretAccessKey:c},endpoint:`https://${s}.digitaloceanspaces.com`,forcePathStyle:!1,region:"us-east-1"}},"digitalOcean");export{S as default};
@@ -0,0 +1,5 @@
1
+ var le=Object.defineProperty;var m=(t,e)=>le(t,"name",{value:e,configurable:!0});import{createReadStream as ue,createWriteStream as me}from"node:fs";import{truncate as he,stat as I,copyFile as C}from"node:fs/promises";import{Transform as H,PassThrough as de,pipeline as ye}from"node:stream";import{f as x,l as fe,w as K,U as b,_ as ge,i as pe,O as we,B as be,y as W}from"./local-meta-storage-Bkwqi_gi.js";import{createRequire as P}from"node:module";import{K as w,C as T,M as Q,L as ve,Q as Ee,O as $e}from"./path-D7rMc9nq-B718mbm6.js";import{g as Se}from"./_commonjsHelpers-D6W6KoPK.js";import Oe from"crypto";import Te from"fs";import{o as A,r as ke,d as Fe}from"./part-match-DqD5U7An.js";import{throwErrorCode as p,ERRORS as f,isUploadError as Pe}from"./ERRORS-B9jkvKwx.js";import{createHash as Ne}from"node:crypto";import{B as De,a as _e,t as je}from"./storage-m_Cxgiih.js";import Me from"./File-alcSNpLq.js";import{u as Re}from"./update-size-DANV7aa2.js";import{o as xe}from"./has-content-Bx2p8Okx.js";var Le=Object.defineProperty,ze=m((t,e)=>Le(t,"name",{value:e,configurable:!0}),"i$4"),Ie=Object.defineProperty,X=ze((t,e)=>Ie(t,"name",{value:e,configurable:!0}),"t");const Ce=P(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,We=X(t=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[e,r]=$.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return $.getBuiltinModule(t)}return Ce(t)},"__cjs_getBuiltinModule"),{lstat:Ae,writeFile:Be}=We("node:fs/promises");var Ue=Object.defineProperty,qe=X((t,e)=>Ue(t,"name",{value:e,configurable:!0}),"o");const M=qe(async t=>{x(t);try{const e=await Ae(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(fe(e))}'`)}catch(e){if(e.code==="ENOENT"){await K(w(b(t))),await Be(t,new Uint8Array);return}throw e}},"ensureFile");var Ve=Object.defineProperty,Y=m((t,e)=>Ve(t,"name",{value:e,configurable:!0}),"t$2"),He=Object.defineProperty,G=Y((t,e)=>He(t,"name",{value:e,configurable:!0}),"t"),Ke=Object.defineProperty,Qe=G((t,e)=>Ke(t,"name",{value:e,configurable:!0}),"t");let B=class extends Error{static{m(this,"l")}static{Y(this,"c")}static{G(this,"i")}static{Qe(this,"WalkError")}root;constructor(e,r){super(`${e instanceof Error?e.message:String(e)} for path "${r}"`),this.cause=e,this.root=r}get name(){return"WalkError"}set name(e){throw new Error("Cannot overwrite name of WalkError")}};var Xe=Object.defineProperty,Ye=m((t,e)=>Xe(t,"name",{value:e,configurable:!0}),"n"),Ge=Object.defineProperty,J=Ye((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"t"),Je=Object.defineProperty,Ze=J((t,e)=>Je(t,"name",{value:e,configurable:!0}),"g");const U=Ze(t=>{const e=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,String.raw`\.`).replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${e}$`)},"globToRegExp");var et=Object.defineProperty,tt=J((t,e)=>et(t,"name",{value:e,configurable:!0}),"n");const F=tt((t,e,r,i)=>Array.isArray(e)&&e.length>0&&!e.some(s=>t.endsWith(s))||r&&!r.some(s=>s.test(t))?!1:!i?.some(s=>s.test(t)),"walkInclude");var rt=Object.defineProperty,Z=m((t,e)=>rt(t,"name",{value:e,configurable:!0}),"u$1"),it=Object.defineProperty,L=Z((t,e)=>it(t,"name",{value:e,configurable:!0}),"y");const at=P(import.meta.url),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,st=L(t=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[e,r]=S.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return S.getBuiltinModule(t)}return at(t)},"__cjs_getBuiltinModule"),{readdir:nt,realpath:ot,stat:ct}=st("node:fs/promises");var lt=Object.defineProperty,g=L((t,e)=>lt(t,"name",{value:e,configurable:!0}),"r");const ut=g(async t=>{const e=ve(t),r=Ee(e),i=await ct(e);return{isDirectory:g(()=>i.isDirectory(),"isDirectory"),isFile:g(()=>i.isFile(),"isFile"),isSymbolicLink:g(()=>i.isSymbolicLink(),"isSymbolicLink"),name:r,path:e}},"_createWalkEntry");async function*k(t,{extensions:e,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:s=!0,includeSymlinks:n=!0,match:o,maxDepth:h=Number.POSITIVE_INFINITY,skip:d}={}){if(x(t),h<0)return;const a=o?o.map(c=>typeof c=="string"?U(c):c):void 0,l=d?d.map(c=>typeof c=="string"?U(c):c):void 0;if(t=T(b(t)),i&&F(t,e,a,l)&&(yield await ut(t)),!(h<1||!F(t,void 0,void 0,l)))try{const c=await nt(t,{withFileTypes:!0});for(const u of c){let y=Q(t,u.name);if(u.isSymbolicLink())if(r)y=await ot(y);else if(n&&F(y,e,a,l)){yield{isDirectory:g(()=>u.isDirectory(),"isDirectory"),isFile:g(()=>u.isFile(),"isFile"),isSymbolicLink:g(()=>u.isSymbolicLink(),"isSymbolicLink"),name:u.name,path:y};continue}else continue;u.isDirectory()?yield*k(y,{extensions:e,followSymlinks:r,includeDirs:i,includeFiles:s,includeSymlinks:n,match:a,maxDepth:h-1,skip:l}):u.isFile()&&s&&F(y,e,a,l)&&(yield{isDirectory:g(()=>u.isDirectory(),"isDirectory"),isFile:g(()=>u.isFile(),"isFile"),isSymbolicLink:g(()=>u.isSymbolicLink(),"isSymbolicLink"),name:u.name,path:y})}}catch(c){throw c instanceof B?c:new B(c,t)}}m(k,"f$1");Z(k,"D");L(k,"g");g(k,"walk");var mt=Object.defineProperty,ee=m((t,e)=>mt(t,"name",{value:e,configurable:!0}),"t"),ht=Object.defineProperty,z=ee((t,e)=>ht(t,"name",{value:e,configurable:!0}),"t");const dt=P(import.meta.url),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,yt=z(t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,r]=O.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return O.getBuiltinModule(t)}return dt(t)},"__cjs_getBuiltinModule"),{accessSync:ft}=yt("node:fs");var gt=Object.defineProperty,pt=z((t,e)=>gt(t,"name",{value:e,configurable:!0}),"o");function N(t,e=ge){x(t),t=b(t);try{return ft(t,e),!0}catch{return!1}}m(N,"i$1");ee(N,"d");z(N,"m");pt(N,"isAccessibleSync");var wt=Object.defineProperty,te=m((t,e)=>wt(t,"name",{value:e,configurable:!0}),"v"),bt=Object.defineProperty,E=te((t,e)=>bt(t,"name",{value:e,configurable:!0}),"i");const vt=P(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,re=E(t=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[e,r]=v.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return v.getBuiltinModule(t)}return vt(t)},"__cjs_getBuiltinModule"),{cwd:D}=v,{mkdir:Et,rename:$t,copyFile:St,unlink:Ot}=re("node:fs/promises"),{mkdirSync:Tt,renameSync:kt,copyFileSync:Ft,unlinkSync:Pt}=re("node:fs");var Nt=Object.defineProperty,ie=E((t,e)=>Nt(t,"name",{value:e,configurable:!0}),"o");class Dt extends Error{static{m(this,"V")}static{te(this,"O")}static{E(this,"a")}static{ie(this,"SameDirectoryError")}constructor(e,r){super(`Source directory "${w(e)}" does not match destination directory "${w(r)}"`),this.name="SameDirectoryError"}}const ae=ie((t,e)=>{if(!t||!e)throw new Error("Source and destination paths must not be empty");if(w(t)!==w(e))throw new Dt(t,e)},"validateSameDirectory");var _t=Object.defineProperty,jt=E((t,e)=>_t(t,"name",{value:e,configurable:!0}),"m$1");const se=jt(async(t,e,{cwd:r,directoryMode:i,overwrite:s,validateDirectory:n})=>{if(r&&(t=T(r,t),e=T(r,e)),n&&ae(t,e),!s&&await pe(e))throw new Error(`The destination file exists: ${e}`);await Et(w(e),{mode:i,recursive:!0});try{await $t(t,e)}catch(o){if(o.code==="EXDEV")await St(t,e),await Ot(t);else throw o}},"internalMoveFile");var Mt=Object.defineProperty,Rt=E((t,e)=>Mt(t,"name",{value:e,configurable:!0}),"m");const ne=Rt((t,e,{cwd:r,directoryMode:i,overwrite:s,validateDirectory:n})=>{if(r&&(t=T(r,t),e=T(r,e)),n&&ae(t,e),!s&&N(e))throw new Error(`The destination file exists: ${e}`);Tt(w(e),{mode:i,recursive:!0});try{kt(t,e)}catch(o){if(o.code==="EXDEV")Ft(t,e),Pt(t);else throw o}},"internalMoveFileSync");var xt=Object.defineProperty,_=E((t,e)=>xt(t,"name",{value:e,configurable:!0}),"i");const Lt=_(async(t,e,r={})=>{const i={overwrite:!0,validateDirectory:!1,...r,cwd:r.cwd?b(r.cwd):D()};await se(t,e,i)},"move");_((t,e,r)=>{const i={overwrite:!0,validateDirectory:!1,...r};i.cwd=i.cwd?b(i.cwd):D(),ne(t,e,i)},"moveSync");_(async(t,e,r)=>{const i={overwrite:!0,...r,validateDirectory:!0};i.cwd=i.cwd?b(i.cwd):D(),await se(t,e,i)},"rename");_((t,e,r)=>{const i={overwrite:!0,...r,validateDirectory:!0};i.cwd=i.cwd?b(i.cwd):D(),ne(t,e,i)},"renameSync");var R,q;function zt(){if(q)return R;q=1;var t=Object.defineProperty,e=m((a,l)=>t(a,"name",{value:l,configurable:!0}),"i");/*!
2
+ * etag
3
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
4
+ * MIT Licensed
5
+ */R=o;var r=Oe,i=Te.Stats,s=Object.prototype.toString;function n(a){if(a.length===0)return'"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';var l=r.createHash("sha1").update(a,"utf8").digest("base64").substring(0,27),c=typeof a=="string"?Buffer.byteLength(a,"utf8"):a.length;return'"'+c.toString(16)+"-"+l+'"'}m(n,"entitytag"),e(n,"entitytag");function o(a,l){if(a==null)throw new TypeError("argument entity is required");var c=h(a),u=l&&typeof l.weak=="boolean"?l.weak:c;if(!c&&typeof a!="string"&&!Buffer.isBuffer(a))throw new TypeError("argument entity must be string, Buffer, or fs.Stats");var y=c?d(a):n(a);return u?"W/"+y:y}m(o,"etag"),e(o,"etag");function h(a){return typeof i=="function"&&a instanceof i?!0:a&&typeof a=="object"&&"ctime"in a&&s.call(a.ctime)==="[object Date]"&&"mtime"in a&&s.call(a.mtime)==="[object Date]"&&"ino"in a&&typeof a.ino=="number"&&"size"in a&&typeof a.size=="number"}m(h,"isstats"),e(h,"isstats");function d(a){var l=a.mtime.getTime().toString(16),c=a.size.toString(16);return'"'+c+"-"+l+'"'}return m(d,"stattag"),e(d,"stattag"),R}m(zt,"requireEtag");var It=zt();const Ct=Se(It);var Wt=Object.defineProperty,oe=m((t,e)=>Wt(t,"name",{value:e,configurable:!0}),"r");class At extends H{static{m(this,"StreamChecksum")}constructor(e,r,i="base64"){super(),this.checksum=e,this.algorithm=r,this.encoding=i,this.hash=Ne(r)}checksum;algorithm;encoding;static{oe(this,"StreamChecksum")}length=0;digest="";hash;get calculatedDigest(){return this.digest}_transform(e,r,i){this.push(e),this.hash.update(e),this.length+=e.length,i()}_flush(e){this.digest=this.hash.digest(this.encoding),this.checksum&&this.checksum!==this.digest?e(new Error("Checksum mismatch")):e()}}const Bt=oe((t,e,r="base64")=>e?new At(t,e,r):new de,"streamChecksum");var Ut=Object.defineProperty,qt=m((t,e)=>Ut(t,"name",{value:e,configurable:!0}),"o");class Vt extends H{static{m(this,"m")}constructor(e=Number.POSITIVE_INFINITY){super(),this.limit=e}limit;static{qt(this,"StreamLength")}length=0;_transform(e,r,i){const s=this.length+e.length;this.limit>=s?(this.push(e),this.length=s,i()):i(new Error("Stream length limit exceeded"))}}var Ht=Object.defineProperty,V=m((t,e)=>Ht(t,"name",{value:e,configurable:!0}),"p");class mr extends De{static name="disk";checksumTypes=["md5","sha1"];directory;meta;constructor(e){if(super(e),this.directory=e.directory,e.metaStorage)this.meta=e.metaStorage;else{const r={...e,...e.metaStorageConfig,logger:this.logger};this.meta=new we(r)}e.fileNameValidation||(e.fileNameValidation=_e),this.isReady=!1,this.accessCheck().then(()=>{this.isReady=!0}).catch(r=>{this.logger?.error("Storage access check failed: %O",r)})}normalizeError(e){return super.normalizeError(e)}async create(e){return this.instrumentOperation("create",async()=>{const r={...e};if(e.ttl){const n=typeof e.ttl=="string"?je(e.ttl):e.ttl;n!==void 0&&(r.expiredAt=Date.now()+n)}r.size!==void 0&&Number(r.size)<0&&p(f.REQUEST_ENTITY_TOO_LARGE,"Request entity too large");const i=new Me(r);try{const n=await this.getMeta(i.id);if(n.status==="completed")return n}catch{}i.name=this.namingFunction(i),(i.size===void 0||Number.isNaN(i.size))&&(i.size===void 0||(i.size=this.maxUploadSize)),await this.validate(i);const s=this.getFilePath(i.name);try{await M(s),i.bytesWritten=0}catch(n){const o=this.normalizeError(n instanceof Error?n:new Error(String(n)));await this.onError(o),p(f.FILE_ERROR,o.message)}return i.status=A(i),await this.saveMeta(i),await this.onCreate(i),i})}async write(e){return this.instrumentOperation("write",async()=>{let r;if("contentType"in e&&"metadata"in e&&!("body"in e)&&!("start"in e)?r=e:(r=await this.getMeta(e.id),await this.checkIfExpired(r)),r.status==="completed")return r;if(e.size!==void 0&&Re(r,e.size),!ke(e,r))return p(f.FILE_CONFLICT);const i=this.getFilePath(r.name);await this.lock(i);try{const s=e.start||0;if(await M(i),r.bytesWritten===0&&(r.bytesWritten=s),xe(e)){if(this.isUnsupportedChecksum(e.checksumAlgorithm))return p(f.UNSUPPORTED_CHECKSUM_ALGORITHM);if((e.start===0||e.start===void 0)&&(r.bytesWritten===0||Number.isNaN(r.bytesWritten))&&(!r.contentType||r.contentType==="application/octet-stream"))try{const{fileType:l,stream:c}=await Fe(e.body);l?.mime&&(r.contentType=l.mime),e.body=c}catch{}const n=e.signal,o={...r,...e,body:e.body};n&&(o.signal=n);const[h,d]=await this.lazyWrite(o);if(d)return await he(i,r.bytesWritten),p(d);const a=s+(e.contentLength||0);r.bytesWritten=Math.max(r.bytesWritten||0,a),r.bytesWritten=Math.max(r.bytesWritten||0,h),r.status=A(r),await this.saveMeta(r)}else await M(i),r.bytesWritten=0;return r}catch(s){if(Pe(s))throw s;const n=this.normalizeError(s instanceof Error?s:new Error(String(s)));return await this.onError(n),p(f.FILE_ERROR,(typeof n.message=="string"?n.message:String(s))||String(s))}finally{await this.unlock(i)}})}async get({id:e}){return this.instrumentOperation("get",async()=>{const r=await this.checkIfExpired(await this.meta.get(e)),{bytesWritten:i,contentType:s,expiredAt:n,metadata:o,modifiedAt:h,name:d,originalName:a,size:l}=r;let c;try{c=await be(this.getFilePath(d),{buffer:!0})}catch(u){const y=u;if(y.code==="ENOENT"||y.code==="EPERM"){const j=this.normalizeError(u instanceof Error?u:new Error(y.message||String(u)));return await this.onError(j),p(f.FILE_NOT_FOUND,(typeof j.message=="string"?j.message:String(u))||String(u))}const ce=this.normalizeError(u instanceof Error?u:new Error(String(u)));throw await this.onError(ce),u}return{content:c,contentType:s,ETag:Ct(c),expiredAt:n,id:e,metadata:o,modifiedAt:h,name:d,originalName:a,size:l||i}})}async exists({id:e}){return this.instrumentOperation("exists",async()=>{try{const r=await this.getMeta(e),i=this.getFilePath(r.name);return await I(i),!0}catch{return!1}})}async getStream({id:e}){return this.instrumentOperation("getStream",async()=>{try{const r=await this.checkIfExpired(await this.meta.get(e)),{bytesWritten:i,contentType:s,expiredAt:n,modifiedAt:o,name:h,size:d}=r,a=ue(this.getFilePath(h));return{headers:{"Content-Length":String(d||i),"Content-Type":s,...n&&{"X-Upload-Expires":n.toString()},...o&&{"Last-Modified":o.toString()}},size:d||i,stream:a}}catch(r){const i=this.normalizeError(r instanceof Error?r:new Error(String(r)));throw await this.onError(i),p(f.FILE_NOT_FOUND,(typeof i.message=="string"?i.message:String(r))||String(r))}})}async delete({id:e}){return this.instrumentOperation("delete",async()=>{const r=await this.getMeta(e);await W(this.getFilePath(r.name)),await this.deleteMeta(e);const i={...r,status:"deleted"};return await this.onDelete(i),i})}async copy(e,r){return this.instrumentOperation("copy",async()=>{const i=await this.getMeta(e);return await C(this.getFilePath(i.name),this.getFilePath(r)),{...i,name:r}})}async move(e,r){return this.instrumentOperation("move",async()=>{const i=await this.getMeta(e),s=this.getFilePath(i.name),n=this.getFilePath(r);try{await Lt(s,n)}catch(o){if(o?.code==="EXDEV")await C(s,n),await W(s);else{const h=this.normalizeError(o instanceof Error?o:new Error(String(o)));throw await this.onError(h),o}}return{...i,id:i.id,name:r}})}async list(){return this.instrumentOperation("list",async()=>{const e={followSymlinks:!1,includeDirs:!1,includeFiles:!0,skip:["*.META$"]},r=[],{directory:i}=this;for await(const s of k(i,e)){const{suffix:n}=this.meta,{path:o}=s;if(!o.includes(n)){const{birthtime:h,ctime:d,mtime:a}=await I(o);r.push({createdAt:h||d,id:o.replace(i,""),modifiedAt:a})}}return r})}getFilePath(e){return $e(e)?e:Q(this.directory,e)}lazyWrite(e){return new Promise((r,i)=>{const s=me(this.getFilePath(e.name),{flags:"r+",start:e.start}),n=new Vt(e.contentLength||e.size-e.start),o=Bt(e.checksum,e.checksumAlgorithm),h=!e.checksum,{signal:d}=e,a=V(()=>{s.close(),n.destroy(),o.destroy()},"cleanupStreams"),l=V(c=>{a(),r([Number.NaN,c])},"failWithCode");if(n.on("error",()=>{l(f.FILE_CONFLICT)}),o.on("error",()=>{l(f.CHECKSUM_MISMATCH)}),e.body.on("aborted",()=>{l(h?void 0:f.REQUEST_ABORTED)}),e.body.on("error",c=>{a(),i(c)}),d?.aborted){l(h?void 0:f.REQUEST_ABORTED);return}d&&d.addEventListener("abort",()=>{a(),s.destroy(),n.destroy(),o.destroy(),e.body.destroy(),r([Number.NaN,h?void 0:f.REQUEST_ABORTED])}),ye(e.body,n,o,s,c=>{if(c){if(a(),d?.aborted){r([Number.NaN,h?void 0:f.REQUEST_ABORTED]);return}r([Number.NaN,f.FILE_ERROR]);return}r([e.start+s.bytesWritten])})})}async accessCheck(){await K(this.directory)}}export{Vt as m,mr as q,Bt as s,M as y};
@@ -0,0 +1,148 @@
1
+ import { F as File, M as MetaStorage, D as DiskStorageOptions, H as HttpError, e as FileInit, f as FilePart, g as FileQuery, a as FileReturn, E as ERRORS, B as BaseStorage, h as DiskStorageWithChecksumOptions } from "./storage.d-Cxs42eEK.js";
2
+ import { Readable } from 'node:stream';
3
+ /**
4
+ * Local disk-based storage implementation.
5
+ * @template TFile The file type used by this storage backend.
6
+ * @remarks
7
+ * ## Error Handling
8
+ * - Filesystem operations throw errors directly (no retry logic)
9
+ * - File not found errors are thrown immediately
10
+ * - Permission errors are propagated as-is
11
+ *
12
+ * ## Retry Behavior
13
+ * - No automatic retries (filesystem operations are typically immediate)
14
+ * - Errors are thrown directly for immediate feedback
15
+ *
16
+ * ## File Paths
17
+ * - Files are stored in the configured directory
18
+ * - Metadata files use the `.META` suffix by default
19
+ * - File paths are resolved relative to the storage directory
20
+ */
21
+ declare class DiskStorage<TFile extends File = File> extends BaseStorage<TFile> {
22
+ static override readonly name: string;
23
+ override checksumTypes: string[];
24
+ directory: string;
25
+ meta: MetaStorage<TFile>;
26
+ constructor(config: DiskStorageOptions<TFile>);
27
+ /**
28
+ * Normalizes errors with disk storage context.
29
+ * @param error The error to normalize.
30
+ * @returns Normalized HTTP error.
31
+ */
32
+ override normalizeError(error: Error): HttpError;
33
+ /**
34
+ * Creates a new file upload and saves its metadata.
35
+ * @param fileInit File initialization configuration.
36
+ * @returns Promise resolving to the created file object.
37
+ * @throws {Error} If validation fails or file already exists and is completed.
38
+ * @remarks
39
+ * Supports TTL (time-to-live) option in fileInit.
40
+ * Creates the file on disk if it doesn't exist.
41
+ * Returns existing file if it's already completed.
42
+ */
43
+ create(fileInit: FileInit): Promise<TFile>;
44
+ /**
45
+ * Writes data to a file upload.
46
+ * @param part File part containing data to write, file query, or full file object.
47
+ * @returns Promise resolving to the updated file object.
48
+ * @throws {Error} If file is expired (ERRORS.GONE), locked (ERRORS.FILE_LOCKED), or conflicts occur (ERRORS.FILE_CONFLICT).
49
+ * @remarks
50
+ * Supports chunked uploads with start position.
51
+ * Automatically detects file type from stream on first chunk if contentType is not set.
52
+ * Validates checksum algorithms if provided.
53
+ * Uses file locking to prevent concurrent writes.
54
+ * Updates file status to "completed" when all bytes are written.
55
+ */
56
+ write(part: FilePart | FileQuery | TFile): Promise<TFile>;
57
+ /**
58
+ * Gets an uploaded file by ID.
59
+ * @param query File query containing the file ID to retrieve.
60
+ * @param query.id File ID to retrieve.
61
+ * @returns Promise resolving to the file data including content buffer.
62
+ * @throws {Error} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
63
+ * @remarks
64
+ * Loads the entire file content into memory as a Buffer.
65
+ * For large files, consider using getStream() instead.
66
+ * Includes ETag (MD5 hash) for content verification.
67
+ */
68
+ get({
69
+ id
70
+ }: FileQuery): Promise<FileReturn>;
71
+ /**
72
+ * Checks if a file exists by verifying both metadata and the actual filesystem file.
73
+ * Returns true only if both the metadata and the file exist.
74
+ * @param query File query containing the file ID to check.
75
+ * @returns Promise resolving to true if both metadata and file exist, false otherwise.
76
+ */
77
+ override exists({
78
+ id
79
+ }: FileQuery): Promise<boolean>;
80
+ /**
81
+ * Gets an uploaded file as a readable stream for efficient large file handling.
82
+ * @param query File query containing the file ID to stream.
83
+ * @param query.id File ID to stream.
84
+ * @returns Promise resolving to an object containing the stream, headers, and size.
85
+ * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
86
+ * @remarks Creates a readable stream directly from the file system for efficient memory usage.
87
+ */
88
+ override getStream({
89
+ id
90
+ }: FileQuery): Promise<{
91
+ headers?: Record<string, string>;
92
+ size?: number;
93
+ stream: Readable;
94
+ }>;
95
+ /**
96
+ * Deletes an upload and its metadata.
97
+ * @param query File query containing the file ID to delete.
98
+ * @param query.id File ID to delete.
99
+ * @returns Promise resolving to the deleted file object with status: "deleted".
100
+ * @throws {UploadError} If the file metadata cannot be found.
101
+ */
102
+ delete({
103
+ id
104
+ }: FileQuery): Promise<TFile>;
105
+ /**
106
+ * Copies an upload file to a new location.
107
+ * @param name Source file name/ID.
108
+ * @param destination Destination file name/ID.
109
+ * @returns Promise resolving to the copied file object.
110
+ * @throws {UploadError} If the source file cannot be found.
111
+ */
112
+ copy(name: string, destination: string): Promise<TFile>;
113
+ /**
114
+ * Moves an upload file to a new location.
115
+ * @param name Source file name/ID.
116
+ * @param destination Destination file name/ID.
117
+ * @returns Promise resolving to the moved file object.
118
+ * @throws {Error} If the source file cannot be found.
119
+ */
120
+ move(name: string, destination: string): Promise<TFile>;
121
+ /**
122
+ * Retrieves a list of uploaded files.
123
+ * @returns Promise resolving to an array of file metadata objects.
124
+ * @remarks Walks the storage directory and returns all files, excluding metadata files.
125
+ */
126
+ override list(): Promise<TFile[]>;
127
+ /**
128
+ * Returns path for the uploaded file
129
+ * If filename is already an absolute path, returns it as-is.
130
+ * Otherwise, joins it with the storage directory.
131
+ */
132
+ protected getFilePath(filename: string): string;
133
+ protected lazyWrite(part: File & FilePart): Promise<[number, ERRORS?]>;
134
+ private accessCheck;
135
+ }
136
+ /**
137
+ * Additionally calculates checksum of the file/range.
138
+ */
139
+ declare class DiskStorageWithChecksum<TFile extends File = File> extends DiskStorage<TFile> {
140
+ private hashes;
141
+ constructor(config: DiskStorageWithChecksumOptions<TFile>);
142
+ override delete({
143
+ id
144
+ }: FileQuery): Promise<TFile>;
145
+ override write(part: FilePart | FileQuery): Promise<TFile>;
146
+ protected override lazyWrite(part: File & FilePart): Promise<[number, ERRORS?]>;
147
+ }
148
+ export { DiskStorage as D, DiskStorageWithChecksum as a };
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var o=(s,t)=>g(s,"name",{value:t,configurable:!0});import{randomUUID as y}from"node:crypto";import{request as f}from"gaxios";import{GoogleAuth as C}from"google-auth-library";import v from"./MetaStorage-Y4m1dWgd.js";import{stringifyMetadata as R,parseMetadata as E}from"./Metadata-B6Ir0KO7.js";import n from"./GCSConfig-BQ0OpVhe.js";import{o as $}from"./has-content-Bx2p8Okx.js";var I="@visulima/storage",P="1.0.0-alpha.20";const i={name:I,version:P};var A=Object.defineProperty,u=o((s,t)=>A(s,"name",{value:t,configurable:!0}),"n");const T=u(s=>{const t=s.match(/(\d+)-(\d+)/),e=t?.[2]?+t[2]:0;return e>0?e+1:0},"getRangeEnd"),G=u(s=>{if($(s)){const t=s.contentLength?s.start+s.contentLength-1:"*";return`bytes ${s.start}-${t}/${s.size??"*"}`}return`bytes */${s.size??"*"}`},"buildContentRange"),U=u(s=>{if(s.response!==void 0){const{response:t}=s;return t?.data?.error?.errors?.map(({reason:e=""})=>e==="rateLimitExceeded"||e==="userRateLimitExceeded"?!0:!!(e&&e.includes("EAI_AGAIN"))).includes(!0)}return!1},"shouldRetry"),w={retry:3,shouldRetry:U,statusCodesToRetry:[[408,429,500,502,503,504],[100,199],[429],[500,599]]};var b=Object.defineProperty,j=o((s,t)=>b(s,"name",{value:t,configurable:!0}),"p");class N extends v{static{o(this,"E")}constructor(t){super(t),this.config=t;const{authClient:e,...a}=t,r=a.bucket||process.env.GCS_BUCKET;if(e===void 0){if(!r)throw new Error("GCS bucket is not defined");if(!a.projectId)throw new Error("Sorry, we cannot connect to Cloud Services without a project ID.");a.scopes||=n.authScopes,this.authClient=new C(a)}else this.authClient=e;this.storageBaseURI=`${a.storageAPI||n.storageAPI}/${r}/o`,this.uploadBaseURI=`${a.uploadAPI||n.uploadAPI}/${r}/o`;const h=["storage.googleapis.com"],d=new URL(this.storageBaseURI).hostname;this.isCustomEndpoint=!h.includes(d);const{retryOptions:m,useAuthWithCustomEndpoint:p,userProject:l}=t;this.userProject=l,this.useAuthWithCustomEndpoint=p||!1,this.retryOptions={...w,...m},e===void 0&&this.accessCheck().catch(c=>{throw c.code==="404"?new Error(`Bucket ${r} does not exist`):c})}config;static{j(this,"GCSMetaStorage")}authClient;storageBaseURI;uploadBaseURI;isCustomEndpoint=!1;retryOptions={};useAuthWithCustomEndpoint;userProject;async save(t,e){const a={...e};return a.metadata&&(a.metadata=R(e.metadata)),await this.makeRequest({body:JSON.stringify(a),headers:{"Content-Type":"application/json; charset=utf-8"},method:"POST",params:{name:encodeURIComponent(this.getMetaName(t)),uploadType:"media"},url:this.uploadBaseURI}),e}async delete(t){const e=this.getMetaPath(t);await this.makeRequest({method:"DELETE",url:e})}async get(t){const e=this.getMetaPath(t),{data:a}=await this.makeRequest({params:{alt:"media"},url:e});return a.metadata&&typeof a.metadata=="string"&&(a.metadata=E(a.metadata)),a}async touch(t,e){return this.save(t,e)}async accessCheck(){return this.makeRequest({url:this.storageBaseURI.replace("/o","")})}getMetaPath(t){return`${this.storageBaseURI}/${this.getMetaName(t)}`}async makeRequest(t){return typeof t.url=="string"&&(t.url=t.url.replaceAll("/:",":")),t={...t,headers:{"User-Agent":`${i.name}/${i.version}`,"x-goog-api-client":`gl-node/${process.versions.node} gccl/${i.version} gccl-invocation-id/${y()}`},params:{...this.userProject===void 0?{}:{userProject:this.userProject}},retry:!0,retryConfig:this.retryOptions,timeout:6e4},this.isCustomEndpoint&&!this.useAuthWithCustomEndpoint?f(t):this.authClient.request(t)}}export{N as E,G as b,i as d,T as g,w as r};
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var t=(e,r)=>a(e,"name",{value:r,configurable:!0});var o=Object.defineProperty,n=t((e,r)=>o(e,"name",{value:r,configurable:!0}),"e");const s=n(e=>typeof e.start=="number"&&e.start>=0&&!!e.body,"hasContent");export{s as o};
@@ -0,0 +1,27 @@
1
+ var ke=Object.defineProperty;var n=(a,e)=>ke(a,"name",{value:e,configurable:!0});import{g as Ne}from"./_commonjsHelpers-D6W6KoPK.js";import Re from"path";var V={exports:{}},J,pe;function Me(){if(pe)return J;pe=1;var a=Object.defineProperty,e=n((i,o)=>a(i,"name",{value:o,configurable:!0}),"i");/*!
2
+ * depd
3
+ * Copyright(c) 2014-2018 Douglas Christopher Wilson
4
+ * MIT Licensed
5
+ */var t=Re.relative;J=d;var r=process.cwd();function s(i,o){for(var f=i.split(/[ ,]+/),c=String(o).toLowerCase(),l=0;l<f.length;l++){var w=f[l];if(w&&(w==="*"||w.toLowerCase()===c))return!0}return!1}n(s,"containsNamespace"),e(s,"containsNamespace");function u(i,o,f){var c=Object.getOwnPropertyDescriptor(i,o),l=c.value;return c.get=e(function(){return l},"getter"),c.writable&&(c.set=e(function(w){return l=w},"setter")),delete c.value,delete c.writable,Object.defineProperty(i,o,c),c}n(u,"convertDataDescriptorToAccessor"),e(u,"convertDataDescriptorToAccessor");function p(i){for(var o="",f=0;f<i;f++)o+=", arg"+f;return o.substr(2)}n(p,"createArgumentsString"),e(p,"createArgumentsString");function m(i){var o=this.name+": "+this.namespace;this.message&&(o+=" deprecated "+this.message);for(var f=0;f<i.length;f++)o+=`
6
+ at `+i[f].toString();return o}n(m,"createStackString"),e(m,"createStackString");function d(i){if(!i)throw new TypeError("argument namespace is required");var o=b(),f=P(o[1]),c=f[0];function l(w){O.call(l,w)}return n(l,"t"),e(l,"deprecate"),l._file=c,l._ignored=x(i),l._namespace=i,l._traced=$(i),l._warned=Object.create(null),l.function=C,l.property=v,l}n(d,"depd"),e(d,"depd");function y(i,o){var f=typeof i.listenerCount!="function"?i.listeners(o).length:i.listenerCount(o);return f>0}n(y,"eehaslisteners"),e(y,"eehaslisteners");function x(i){if(process.noDeprecation)return!0;var o=process.env.NO_DEPRECATION||"";return s(o,i)}n(x,"isignored"),e(x,"isignored");function $(i){if(process.traceDeprecation)return!0;var o=process.env.TRACE_DEPRECATION||"";return s(o,i)}n($,"istraced"),e($,"istraced");function O(i,o){var f=y(process,"deprecation");if(!(!f&&this._ignored)){var c,l,w,j,T=0,q=!1,R=b(),_=this._file;for(o?(j=o,w=P(R[1]),w.name=j.name,_=w[0]):(T=2,j=P(R[T]),w=j);T<R.length;T++)if(c=P(R[T]),l=c[0],l===_)q=!0;else if(l===this._file)_=this._file;else if(q)break;var G=c?j.join(":")+"__"+c.join(":"):void 0;if(!(G!==void 0&&G in this._warned)){this._warned[G]=!0;var H=i;if(H||(H=w===j||!w.name?k(j):k(w)),f){var Te=S(this._namespace,H,R.slice(T));process.emit("deprecation",Te);return}var Ae=process.stderr.isTTY?N:I,Le=Ae.call(this,H,c,R.slice(T));process.stderr.write(Le+`
7
+ `,"utf8")}}}n(O,"log"),e(O,"log");function P(i){var o=i.getFileName()||"<anonymous>",f=i.getLineNumber(),c=i.getColumnNumber();i.isEval()&&(o=i.getEvalOrigin()+", "+o);var l=[o,f,c];return l.callSite=i,l.name=i.getFunctionName(),l}n(P,"callSiteLocation"),e(P,"callSiteLocation");function k(i){var o=i.callSite,f=i.name;f||(f="<anonymous@"+h(i)+">");var c=o.getThis(),l=c&&o.getTypeName();return l==="Object"&&(l=void 0),l==="Function"&&(l=c.name||l),l&&o.getMethodName()?l+"."+f:f}n(k,"defaultMessage"),e(k,"defaultMessage");function I(i,o,f){var c=new Date().toUTCString(),l=c+" "+this._namespace+" deprecated "+i;if(this._traced){for(var w=0;w<f.length;w++)l+=`
8
+ at `+f[w].toString();return l}return o&&(l+=" at "+h(o)),l}n(I,"formatPlain"),e(I,"formatPlain");function N(i,o,f){var c="\x1B[36;1m"+this._namespace+"\x1B[22;39m \x1B[33;1mdeprecated\x1B[22;39m \x1B[0m"+i+"\x1B[39m";if(this._traced){for(var l=0;l<f.length;l++)c+=`
9
+ \x1B[36mat `+f[l].toString()+"\x1B[39m";return c}return o&&(c+=" \x1B[36m"+h(o)+"\x1B[39m"),c}n(N,"formatColor"),e(N,"formatColor");function h(i){return t(r,i[0])+":"+i[1]+":"+i[2]}n(h,"formatLocation"),e(h,"formatLocation");function b(){var i=Error.stackTraceLimit,o={},f=Error.prepareStackTrace;Error.prepareStackTrace=g,Error.stackTraceLimit=Math.max(10,i),Error.captureStackTrace(o);var c=o.stack.slice(1);return Error.prepareStackTrace=f,Error.stackTraceLimit=i,c}n(b,"getStack"),e(b,"getStack");function g(i,o){return o}n(g,"prepareObjectStackTrace"),e(g,"prepareObjectStackTrace");function C(i,o){if(typeof i!="function")throw new TypeError("argument fn must be a function");var f=p(i.length),c=b(),l=P(c[1]);l.name=i.name;var w=new Function("fn","log","deprecate","message","site",`"use strict"
10
+ return function (`+f+`) {log.call(deprecate, message, site)
11
+ return fn.apply(this, arguments)
12
+ }`)(i,O,this,o,l);return w}n(C,"wrapfunction"),e(C,"wrapfunction");function v(i,o,f){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("argument obj must be object");var c=Object.getOwnPropertyDescriptor(i,o);if(!c)throw new TypeError("must call property on owner object");if(!c.configurable)throw new TypeError("property must be configurable");var l=this,w=b(),j=P(w[1]);j.name=o,"value"in c&&(c=u(i,o));var T=c.get,q=c.set;typeof T=="function"&&(c.get=e(function(){return O.call(l,f,j),T.apply(this,arguments)},"getter")),typeof q=="function"&&(c.set=e(function(){return O.call(l,f,j),q.apply(this,arguments)},"setter")),Object.defineProperty(i,o,c)}n(v,"wrapproperty"),e(v,"wrapproperty");function S(i,o,f){var c=new Error,l;return Object.defineProperty(c,"constructor",{value:S}),Object.defineProperty(c,"message",{configurable:!0,enumerable:!1,value:o,writable:!0}),Object.defineProperty(c,"name",{enumerable:!1,configurable:!0,value:"DeprecationError",writable:!0}),Object.defineProperty(c,"namespace",{configurable:!0,enumerable:!1,value:i,writable:!0}),Object.defineProperty(c,"stack",{configurable:!0,enumerable:!1,get:e(function(){return l!==void 0?l:l=m.call(this,f)},"get"),set:e(function(w){l=w},"setter")}),c}return n(S,"DeprecationError"),e(S,"DeprecationError"),J}n(Me,"requireDepd");var X,he;function Ie(){if(he)return X;he=1;var a=Object.defineProperty,e=n((s,u)=>a(s,"name",{value:u,configurable:!0}),"n");X=Object.setPrototypeOf||({__proto__:[]}instanceof Array?t:r);function t(s,u){return s.__proto__=u,s}n(t,"setProtoOf"),e(t,"setProtoOf");function r(s,u){for(var p in u)Object.prototype.hasOwnProperty.call(s,p)||(s[p]=u[p]);return s}return n(r,"mixinProperties"),e(r,"mixinProperties"),X}n(Ie,"requireSetprototypeof");var K,me;function qe(){return me||(me=1,K={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}),K}n(qe,"requireCodes");var Y,de;function De(){if(de)return Y;de=1;var a=Object.defineProperty,e=n((d,y)=>a(d,"name",{value:y,configurable:!0}),"r");/*!
13
+ * statuses
14
+ * Copyright(c) 2014 Jonathan Ong
15
+ * Copyright(c) 2016 Douglas Christopher Wilson
16
+ * MIT Licensed
17
+ */var t=qe();Y=m,m.message=t,m.code=r(t),m.codes=s(t),m.redirect={300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},m.empty={204:!0,205:!0,304:!0},m.retry={502:!0,503:!0,504:!0};function r(d){var y={};return Object.keys(d).forEach(e(function(x){var $=d[x],O=Number(x);y[$.toLowerCase()]=O},"forEachCode")),y}n(r,"createMessageToStatusCodeMap"),e(r,"createMessageToStatusCodeMap");function s(d){return Object.keys(d).map(e(function(y){return Number(y)},"mapCode"))}n(s,"createStatusCodeList"),e(s,"createStatusCodeList");function u(d){var y=d.toLowerCase();if(!Object.prototype.hasOwnProperty.call(m.code,y))throw new Error('invalid status message: "'+d+'"');return m.code[y]}n(u,"getStatusCode"),e(u,"getStatusCode");function p(d){if(!Object.prototype.hasOwnProperty.call(m.message,d))throw new Error("invalid status code: "+d);return m.message[d]}n(p,"getStatusMessage"),e(p,"getStatusMessage");function m(d){if(typeof d=="number")return p(d);if(typeof d!="string")throw new TypeError("code must be a number or string");var y=parseInt(d,10);return isNaN(y)?u(d):p(y)}return n(m,"status"),e(m,"status"),Y}n(De,"requireStatuses");var z={exports:{}},U={exports:{}},ge;function Fe(){if(ge)return U.exports;ge=1;var a=Object.defineProperty,e=n((t,r)=>a(t,"name",{value:r,configurable:!0}),"o");return typeof Object.create=="function"?U.exports=e(function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))},"inherits"):U.exports=e(function(t,r){if(r){t.super_=r;var s=e(function(){},"TempCtor");s.prototype=r.prototype,t.prototype=new s,t.prototype.constructor=t}},"inherits"),U.exports}n(Fe,"requireInherits_browser");var ve;function We(){if(ve)return z.exports;ve=1;try{var a=require("util");if(typeof a.inherits!="function")throw"";z.exports=a.inherits}catch{z.exports=Fe()}return z.exports}n(We,"requireInherits");var Q,ye;function He(){if(ye)return Q;ye=1;var a=Object.defineProperty,e=n((r,s)=>a(r,"name",{value:s,configurable:!0}),"t");/*!
18
+ * toidentifier
19
+ * Copyright(c) 2016 Douglas Christopher Wilson
20
+ * MIT Licensed
21
+ */Q=t;function t(r){return r.split(" ").map(function(s){return s.slice(0,1).toUpperCase()+s.slice(1)}).join("").replace(/[^ _0-9a-z]/gi,"")}return n(t,"toIdentifier"),e(t,"toIdentifier"),Q}n(He,"requireToidentifier");var be;function ze(){return be||(be=1,(function(a){var e=Object.defineProperty,t=n((h,b)=>e(h,"name",{value:b,configurable:!0}),"u");/*!
22
+ * http-errors
23
+ * Copyright(c) 2014 Jonathan Ong
24
+ * Copyright(c) 2016 Douglas Christopher Wilson
25
+ * MIT Licensed
26
+ */var r=Me()("http-errors"),s=Ie(),u=De(),p=We(),m=He();a.exports=y,a.exports.HttpError=x(),a.exports.isHttpError=O(a.exports.HttpError),I(a.exports,u.codes,a.exports.HttpError);function d(h){return+(String(h).charAt(0)+"00")}n(d,"codeClass"),t(d,"codeClass");function y(){for(var h,b,g=500,C={},v=0;v<arguments.length;v++){var S=arguments[v],i=typeof S;if(i==="object"&&S instanceof Error)h=S,g=h.status||h.statusCode||g;else if(i==="number"&&v===0)g=S;else if(i==="string")b=S;else if(i==="object")C=S;else throw new TypeError("argument #"+(v+1)+" unsupported type "+i)}typeof g=="number"&&(g<400||g>=600)&&r("non-error status code; use only 4xx or 5xx status codes"),(typeof g!="number"||!u.message[g]&&(g<400||g>=600))&&(g=500);var o=y[g]||y[d(g)];h||(h=o?new o(b):new Error(b||u.message[g]),Error.captureStackTrace(h,y)),(!o||!(h instanceof o)||h.status!==g)&&(h.expose=g<500,h.status=h.statusCode=g);for(var f in C)f!=="status"&&f!=="statusCode"&&(h[f]=C[f]);return h}n(y,"createError"),t(y,"createError");function x(){function h(){throw new TypeError("cannot construct abstract class")}return n(h,"e"),t(h,"HttpError"),p(h,Error),h}n(x,"createHttpErrorConstructor"),t(x,"createHttpErrorConstructor");function $(h,b,g){var C=N(b);function v(S){var i=S??u.message[g],o=new Error(i);return Error.captureStackTrace(o,v),s(o,v.prototype),Object.defineProperty(o,"message",{enumerable:!0,configurable:!0,value:i,writable:!0}),Object.defineProperty(o,"name",{enumerable:!1,configurable:!0,value:C,writable:!0}),o}return n(v,"t"),t(v,"ClientError"),p(v,h),k(v,C),v.prototype.status=g,v.prototype.statusCode=g,v.prototype.expose=!0,v}n($,"createClientErrorConstructor"),t($,"createClientErrorConstructor");function O(h){return t(function(b){return!b||typeof b!="object"?!1:b instanceof h?!0:b instanceof Error&&typeof b.expose=="boolean"&&typeof b.statusCode=="number"&&b.status===b.statusCode},"isHttpError")}n(O,"createIsHttpErrorFunction"),t(O,"createIsHttpErrorFunction");function P(h,b,g){var C=N(b);function v(S){var i=S??u.message[g],o=new Error(i);return Error.captureStackTrace(o,v),s(o,v.prototype),Object.defineProperty(o,"message",{enumerable:!0,configurable:!0,value:i,writable:!0}),Object.defineProperty(o,"name",{enumerable:!1,configurable:!0,value:C,writable:!0}),o}return n(v,"t"),t(v,"ServerError"),p(v,h),k(v,C),v.prototype.status=g,v.prototype.statusCode=g,v.prototype.expose=!1,v}n(P,"createServerErrorConstructor"),t(P,"createServerErrorConstructor");function k(h,b){var g=Object.getOwnPropertyDescriptor(h,"name");g&&g.configurable&&(g.value=b,Object.defineProperty(h,"name",g))}n(k,"nameFunc"),t(k,"nameFunc");function I(h,b,g){b.forEach(t(function(C){var v,S=m(u.message[C]);switch(d(C)){case 400:v=$(g,S,C);break;case 500:v=P(g,S,C);break}v&&(h[C]=v,h[S]=v)},"forEachCode"))}n(I,"populateConstructorExports"),t(I,"populateConstructorExports");function N(h){return h.slice(-5)==="Error"?h:h+"Error"}n(N,"toClassName"),t(N,"toClassName")})(V)),V.exports}n(ze,"requireHttpErrors");var Ue=ze();const Tt=Ne(Ue);var Be=Object.defineProperty,we=n((a,e)=>Be(a,"name",{value:e,configurable:!0}),"t$2");function A(a,e=";"){let t=e===";"?/(?:^|;)\s*([^=;\s]+)(\s*=\s*(?:"((?:[^"\\]|\\.)*)"|((?:[^;]|\\\;)+))?)?/g:/(?:^|,)\s*([^=,\s]+)(\s*=\s*(?:"((?:[^"\\]|\\.)*)"|((?:[^,]|\\\,)+))?)?/g,r=[],s;for(;(s=t.exec(a))!==null;){let u=s[1].trim(),p;s[2]&&(p=(s[3]||s[4]||"").replace(/\\(.)/g,"$1").trim()),r.push([u,p])}return r}n(A,"parseParams");we(A,"parseParams");function L(a){return a.includes('"')||a.includes(";")||a.includes(" ")?`"${a.replace(/"/g,'\\"')}"`:a}n(L,"quote");we(L,"quote");var _e=Object.defineProperty,M=n((a,e)=>_e(a,"name",{value:e,configurable:!0}),"t$1");function Ce(a){return a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()}n(Ce,"capitalize");M(Ce,"capitalize");function W(a){return a!=null&&typeof a[Symbol.iterator]=="function"}n(W,"isIterable");M(W,"isIterable");function Se(a){return a instanceof Date&&!isNaN(a.getTime())}n(Se,"isValidDate");M(Se,"isValidDate");function E(a){return a==="*"||/^(W\/)?".*"$/.test(a)?a:`"${a}"`}n(E,"quoteEtag");M(E,"quoteEtag");function Z(a){let e=a instanceof Date?a.getTime():a;return Math.floor(e/1e3)}n(Z,"removeMilliseconds");M(Z,"removeMilliseconds");const Ge=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/;function xe(a){if(!Ge.test(a))return null;let e=Date.parse(a);return isNaN(e)?null:e}n(xe,"parseHttpDate");M(xe,"parseHttpDate");var Ve=Object.defineProperty,Je=n((a,e)=>Ve(a,"name",{value:e,configurable:!0}),"l$3");class B{static{n(this,"Accept")}static{Je(this,"Accept")}#e;constructor(e){if(e)return B.from(e);this.#e=new Map}#t(){this.#e=new Map([...this.#e].sort((e,t)=>t[1]-e[1]))}get mediaTypes(){return Array.from(this.#e.keys())}get weights(){return Array.from(this.#e.values())}get size(){return this.#e.size}accepts(e){return this.getWeight(e)>0}getWeight(e){let[t,r]=e.toLowerCase().split("/");for(let[s,u]of this){let[p,m]=s.split("/");if((p===t||p==="*"||t==="*")&&(m===r||m==="*"||r==="*"))return u}return 0}getPreferred(e){let t=e.map(r=>[r,this.getWeight(r)]).sort((r,s)=>s[1]-r[1])[0];return t!==void 0&&t[1]>0?t[0]:null}get(e){return this.#e.get(e.toLowerCase())??null}set(e,t=1){this.#e.set(e.toLowerCase(),t),this.#t()}delete(e){this.#e.delete(e.toLowerCase())}has(e){return this.#e.has(e.toLowerCase())}clear(){this.#e.clear()}entries(){return this.#e.entries()}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[r,s]of this)e.call(t,r,s,this)}toString(){let e=[];for(let[t,r]of this.#e)e.push(`${t}${r===1?"":`;q=${r}`}`);return e.join(",")}static from(e){let t=new B;if(e!==null){if(typeof e=="string")for(let r of e.split(/\s*,\s*/)){let s=A(r);if(s.length<1)continue;let u=s[0][0],p=1;for(let m=1;m<s.length;m++){let[d,y]=s[m];if(d==="q"){p=Number(y);break}}t.#e.set(u.toLowerCase(),p)}else if(W(e))for(let r of e)Array.isArray(r)?t.#e.set(r[0].toLowerCase(),r[1]):t.#e.set(r.toLowerCase(),1);else for(let r of Object.getOwnPropertyNames(e))t.#e.set(r.toLowerCase(),e[r]);t.#t()}return t}}var Xe=Object.defineProperty,Ke=n((a,e)=>Xe(a,"name",{value:e,configurable:!0}),"h$1");class ee{static{n(this,"AcceptEncoding")}static{Ke(this,"AcceptEncoding")}#e;constructor(e){if(e)return ee.from(e);this.#e=new Map}#t(){this.#e=new Map([...this.#e].sort((e,t)=>t[1]-e[1]))}get encodings(){return Array.from(this.#e.keys())}get weights(){return Array.from(this.#e.values())}get size(){return this.#e.size}accepts(e){return e.toLowerCase()==="identity"||this.getWeight(e)>0}getWeight(e){let t=e.toLowerCase();for(let[r,s]of this)if(r===t||r==="*"||t==="*")return s;return 0}getPreferred(e){let t=e.map(r=>[r,this.getWeight(r)]).sort((r,s)=>s[1]-r[1])[0];return t!==void 0&&t[1]>0?t[0]:null}get(e){return this.#e.get(e.toLowerCase())??null}set(e,t=1){this.#e.set(e.toLowerCase(),t),this.#t()}delete(e){this.#e.delete(e.toLowerCase())}has(e){return this.#e.has(e.toLowerCase())}clear(){this.#e.clear()}entries(){return this.#e.entries()}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[r,s]of this)e.call(t,r,s,this)}toString(){let e=[];for(let[t,r]of this.#e)e.push(`${t}${r===1?"":`;q=${r}`}`);return e.join(",")}static from(e){let t=new ee;if(e!==null){if(typeof e=="string")for(let r of e.split(/\s*,\s*/)){let s=A(r);if(s.length<1)continue;let u=s[0][0],p=1;for(let m=1;m<s.length;m++){let[d,y]=s[m];if(d==="q"){p=Number(y);break}}t.#e.set(u.toLowerCase(),p)}else if(W(e))for(let r of e)Array.isArray(r)?t.#e.set(r[0].toLowerCase(),r[1]):t.#e.set(r.toLowerCase(),1);else for(let r of Object.getOwnPropertyNames(e))t.#e.set(r.toLowerCase(),e[r]);t.#t()}return t}}var Ye=Object.defineProperty,Qe=n((a,e)=>Ye(a,"name",{value:e,configurable:!0}),"l$2");class te{static{n(this,"AcceptLanguage")}static{Qe(this,"AcceptLanguage")}#e;constructor(e){if(e)return te.from(e);this.#e=new Map}#t(){this.#e=new Map([...this.#e].sort((e,t)=>t[1]-e[1]))}get languages(){return Array.from(this.#e.keys())}get weights(){return Array.from(this.#e.values())}get size(){return this.#e.size}accepts(e){return this.getWeight(e)>0}getWeight(e){let[t,r]=e.toLowerCase().split("-");for(let[s,u]of this){let[p,m]=s.split("-");if((p===t||p==="*"||t==="*")&&(m===r||m===void 0||r===void 0))return u}return 0}getPreferred(e){let t=e.map(r=>[r,this.getWeight(r)]).sort((r,s)=>s[1]-r[1])[0];return t!==void 0&&t[1]>0?t[0]:null}get(e){return this.#e.get(e.toLowerCase())??null}set(e,t=1){this.#e.set(e.toLowerCase(),t),this.#t()}delete(e){this.#e.delete(e.toLowerCase())}has(e){return this.#e.has(e.toLowerCase())}clear(){this.#e.clear()}entries(){return this.#e.entries()}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[r,s]of this)e.call(t,r,s,this)}toString(){let e=[];for(let[t,r]of this.#e)e.push(`${t}${r===1?"":`;q=${r}`}`);return e.join(",")}static from(e){let t=new te;if(e!==null){if(typeof e=="string")for(let r of e.split(/\s*,\s*/)){let s=A(r);if(s.length<1)continue;let u=s[0][0],p=1;for(let m=1;m<s.length;m++){let[d,y]=s[m];if(d==="q"){p=Number(y);break}}t.#e.set(u.toLowerCase(),p)}else if(W(e))for(let r of e)Array.isArray(r)?t.#e.set(r[0].toLowerCase(),r[1]):t.#e.set(r.toLowerCase(),1);else for(let r of Object.getOwnPropertyNames(e))t.#e.set(r.toLowerCase(),e[r]);t.#t()}return t}}var Ze=Object.defineProperty,et=n((a,e)=>Ze(a,"name",{value:e,configurable:!0}),"s$2");class re{static{n(this,"CacheControl")}static{et(this,"CacheControl")}maxAge;maxStale;minFresh;sMaxage;noCache;noStore;noTransform;onlyIfCached;mustRevalidate;proxyRevalidate;mustUnderstand;private;public;immutable;staleWhileRevalidate;staleIfError;constructor(e){if(e)return re.from(e)}toString(){let e=[];return this.public&&e.push("public"),this.private&&e.push("private"),typeof this.maxAge=="number"&&e.push(`max-age=${this.maxAge}`),typeof this.sMaxage=="number"&&e.push(`s-maxage=${this.sMaxage}`),this.noCache&&e.push("no-cache"),this.noStore&&e.push("no-store"),this.noTransform&&e.push("no-transform"),this.onlyIfCached&&e.push("only-if-cached"),this.mustRevalidate&&e.push("must-revalidate"),this.proxyRevalidate&&e.push("proxy-revalidate"),this.mustUnderstand&&e.push("must-understand"),this.immutable&&e.push("immutable"),typeof this.staleWhileRevalidate=="number"&&e.push(`stale-while-revalidate=${this.staleWhileRevalidate}`),typeof this.staleIfError=="number"&&e.push(`stale-if-error=${this.staleIfError}`),typeof this.maxStale=="number"&&e.push(`max-stale=${this.maxStale}`),typeof this.minFresh=="number"&&e.push(`min-fresh=${this.minFresh}`),e.join(", ")}static from(e){let t=new re;if(e!==null)if(typeof e=="string"){let r=A(e,",");if(r.length>0)for(let[s,u]of r)switch(s){case"max-age":t.maxAge=Number(u);break;case"max-stale":t.maxStale=Number(u);break;case"min-fresh":t.minFresh=Number(u);break;case"s-maxage":t.sMaxage=Number(u);break;case"no-cache":t.noCache=!0;break;case"no-store":t.noStore=!0;break;case"no-transform":t.noTransform=!0;break;case"only-if-cached":t.onlyIfCached=!0;break;case"must-revalidate":t.mustRevalidate=!0;break;case"proxy-revalidate":t.proxyRevalidate=!0;break;case"must-understand":t.mustUnderstand=!0;break;case"private":t.private=!0;break;case"public":t.public=!0;break;case"immutable":t.immutable=!0;break;case"stale-while-revalidate":t.staleWhileRevalidate=Number(u);break;case"stale-if-error":t.staleIfError=Number(u);break}}else t.maxAge=e.maxAge,t.maxStale=e.maxStale,t.minFresh=e.minFresh,t.sMaxage=e.sMaxage,t.noCache=e.noCache,t.noStore=e.noStore,t.noTransform=e.noTransform,t.onlyIfCached=e.onlyIfCached,t.mustRevalidate=e.mustRevalidate,t.proxyRevalidate=e.proxyRevalidate,t.mustUnderstand=e.mustUnderstand,t.private=e.private,t.public=e.public,t.immutable=e.immutable,t.staleWhileRevalidate=e.staleWhileRevalidate,t.staleIfError=e.staleIfError;return t}}var tt=Object.defineProperty,fe=n((a,e)=>tt(a,"name",{value:e,configurable:!0}),"l$1");class D{static{n(this,"ContentDisposition")}static{fe(this,"ContentDisposition")}filename;filenameSplat;name;type;constructor(e){if(e)return D.from(e)}get preferredFilename(){let e=this.filenameSplat;if(e){let t=Ee(e);if(t)return t}return this.filename}toString(){if(!this.type)return"";let e=[this.type];return this.name&&e.push(`name=${L(this.name)}`),this.filename&&e.push(`filename=${L(this.filename)}`),this.filenameSplat&&e.push(`filename*=${L(this.filenameSplat)}`),e.join("; ")}static from(e){let t=new D;if(e!==null)if(typeof e=="string"){let r=A(e);if(r.length>0){t.type=r[0][0];for(let[s,u]of r.slice(1))s==="filename"?t.filename=u:s==="filename*"?t.filenameSplat=u:s==="name"&&(t.name=u)}}else t.filename=e.filename,t.filenameSplat=e.filenameSplat,t.name=e.name,t.type=e.type;return t}}function Ee(a){let e=a.match(/^([\w-]+)'([^']*)'(.+)$/);if(!e)return null;let[,t,,r]=e,s=$e(r);try{let u=new TextDecoder(t),p=new Uint8Array(s.split("").map(m=>m.charCodeAt(0)));return u.decode(p)}catch(u){return console.warn(`Failed to decode filename from charset ${t}:`,u),s}}n(Ee,"c");fe(Ee,"decodeFilenameSplat");function $e(a){return a.replace(/\+/g," ").replace(/%([0-9A-Fa-f]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}n($e,"d");fe($e,"percentDecode");var rt=Object.defineProperty,at=n((a,e)=>rt(a,"name",{value:e,configurable:!0}),"s$1");class ae{static{n(this,"ContentRange")}static{at(this,"ContentRange")}unit="";start=null;end=null;size;constructor(e){if(e)return ae.from(e)}toString(){if(!this.unit||this.size===void 0)return"";let e=this.start!==null&&this.end!==null?`${this.start}-${this.end}`:"*";return`${this.unit} ${e}/${this.size}`}static from(e){let t=new ae;if(e!==null)if(typeof e=="string"){let r=e.match(/^(\w+)\s+(?:(\d+)-(\d+)|\*)\/((?:\d+|\*))$/);r&&(t.unit=r[1],t.start=r[2]?parseInt(r[2],10):null,t.end=r[3]?parseInt(r[3],10):null,t.size=r[4]==="*"?"*":parseInt(r[4],10))}else e.unit!==void 0&&(t.unit=e.unit),e.start!==void 0&&(t.start=e.start),e.end!==void 0&&(t.end=e.end),e.size!==void 0&&(t.size=e.size);return t}}var nt=Object.defineProperty,st=n((a,e)=>nt(a,"name",{value:e,configurable:!0}),"i$4");class F{static{n(this,"ContentType")}static{st(this,"ContentType")}boundary;charset;mediaType;constructor(e){if(e)return F.from(e)}toString(){if(!this.mediaType)return"";let e=[this.mediaType];return this.charset&&e.push(`charset=${L(this.charset)}`),this.boundary&&e.push(`boundary=${L(this.boundary)}`),e.join("; ")}static from(e){let t=new F;if(e!==null)if(typeof e=="string"){let r=A(e);if(r.length>0){t.mediaType=r[0][0];for(let[s,u]of r.slice(1))s==="boundary"?t.boundary=u:s==="charset"&&(t.charset=u)}}else t.boundary=e.boundary,t.charset=e.charset,t.mediaType=e.mediaType;return t}}var it=Object.defineProperty,ot=n((a,e)=>it(a,"name",{value:e,configurable:!0}),"i$3");class ne{static{n(this,"Cookie")}static{ot(this,"Cookie")}#e;constructor(e){if(e)return ne.from(e);this.#e=new Map}get names(){return Array.from(this.#e.keys())}get values(){return Array.from(this.#e.values())}get size(){return this.#e.size}get(e){return this.#e.get(e)??null}set(e,t){this.#e.set(e,t)}delete(e){this.#e.delete(e)}has(e){return this.#e.has(e)}clear(){this.#e.clear()}entries(){return this.#e.entries()}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[r,s]of this)e.call(t,r,s,this)}toString(){let e=[];for(let[t,r]of this.#e)e.push(`${t}=${L(r)}`);return e.join("; ")}static from(e){let t=new ne;if(e!==null)if(typeof e=="string"){let r=A(e);for(let[s,u]of r)t.#e.set(s,u??"")}else if(W(e))for(let[r,s]of e)t.#e.set(r,s);else for(let r of Object.getOwnPropertyNames(e))t.#e.set(r,e[r]);return t}}var ut=Object.defineProperty,lt=n((a,e)=>ut(a,"name",{value:e,configurable:!0}),"i$2");class se{static{n(this,"IfMatch")}static{lt(this,"IfMatch")}tags=[];constructor(e){if(e)return se.from(e)}has(e){return this.tags.includes(E(e))}matches(e){if(this.tags.length===0||this.tags.includes("*"))return!0;let t=E(e);if(t.startsWith("W/"))return!1;for(let r of this.tags)if(!r.startsWith("W/")&&r===t)return!0;return!1}toString(){return this.tags.join(", ")}static from(e){let t=new se;return e!==null&&(typeof e=="string"?t.tags.push(...e.split(/\s*,\s*/).map(E)):Array.isArray(e)?t.tags.push(...e.map(E)):t.tags.push(...e.tags.map(E))),t}}var ct=Object.defineProperty,ft=n((a,e)=>ct(a,"name",{value:e,configurable:!0}),"i$1");class ie{static{n(this,"IfNoneMatch")}static{ft(this,"IfNoneMatch")}tags=[];constructor(e){if(e)return ie.from(e)}has(e){return this.tags.includes(E(e))}matches(e){return this.has(e)||this.tags.includes("*")}toString(){return this.tags.join(", ")}static from(e){let t=new ie;return e!==null&&(typeof e=="string"?t.tags.push(...e.split(/\s*,\s*/).map(E)):Array.isArray(e)?t.tags.push(...e.map(E)):t.tags.push(...e.tags.map(E))),t}}var pt=Object.defineProperty,ht=n((a,e)=>pt(a,"name",{value:e,configurable:!0}),"l");class oe{static{n(this,"IfRange")}static{ht(this,"IfRange")}value="";constructor(e){if(e)return oe.from(e)}matches(e){if(!this.value)return!0;let t=xe(this.value);if(t!==null&&e.lastModified!=null)return Z(t)===Z(e.lastModified);if(e.etag!=null){let r=E(this.value),s=E(e.etag);return r.startsWith("W/")||s.startsWith("W/")?!1:r===s}return!1}toString(){return this.value}static from(e){let t=new oe;return e!==null&&(typeof e=="string"?t.value=e:t.value=e.toUTCString()),t}}var mt=Object.defineProperty,dt=n((a,e)=>mt(a,"name",{value:e,configurable:!0}),"a$2");class ue{static{n(this,"Range")}static{dt(this,"Range")}unit="";ranges=[];constructor(e){if(e)return ue.from(e)}canSatisfy(e){if(!this.unit||this.ranges.length===0)return!1;for(let t of this.ranges)if(t.start===void 0&&t.end===void 0||t.start!==void 0&&t.end!==void 0&&t.start>t.end)return!1;for(let t of this.ranges)if(t.start===void 0||t.start<e)return!0;return!1}normalize(e){return this.canSatisfy(e)?this.ranges.map(t=>{if(t.start!==void 0&&t.end!==void 0)return{start:t.start,end:Math.min(t.end,e-1)};if(t.start!==void 0)return{start:t.start,end:e-1};{let r=t.end;return{start:Math.max(0,e-r),end:e-1}}}):[]}toString(){if(!this.unit||this.ranges.length===0)return"";let e=this.ranges.map(t=>t.start!==void 0&&t.end!==void 0?`${t.start}-${t.end}`:t.start!==void 0?`${t.start}-`:t.end!==void 0?`-${t.end}`:"");return`${this.unit}=${e.join(",")}`}static from(e){let t=new ue;if(e!==null)if(typeof e=="string"){let r=e.match(/^(\w+)=(.+)$/);if(r){t.unit=r[1];let s=r[2].split(","),u=!1;for(let p of s){let m=p.trim().match(/^(\d*)-(\d*)$/);if(!m){u=!0;continue}let[,d,y]=m;if(!d&&!y){u=!0;continue}let x=d?parseInt(d,10):void 0,$=y?parseInt(y,10):void 0;if(x!==void 0&&$!==void 0&&x>$){u=!0;continue}t.ranges.push({start:x,end:$})}u&&(t.ranges=[])}}else e.unit!==void 0&&(t.unit=e.unit),e.ranges!==void 0&&(t.ranges=e.ranges);return t}}var gt=Object.defineProperty,vt=n((a,e)=>gt(a,"name",{value:e,configurable:!0}),"r");class le{static{n(this,"SetCookie")}static{vt(this,"SetCookie")}domain;expires;httpOnly;maxAge;name;partitioned;path;sameSite;secure;value;constructor(e){if(e)return le.from(e)}toString(){if(!this.name)return"";let e=[`${this.name}=${L(this.value||"")}`];return this.domain&&e.push(`Domain=${this.domain}`),this.expires&&e.push(`Expires=${this.expires.toUTCString()}`),this.httpOnly&&e.push("HttpOnly"),this.maxAge!=null&&e.push(`Max-Age=${this.maxAge}`),this.partitioned&&e.push("Partitioned"),this.path&&e.push(`Path=${this.path}`),this.sameSite&&e.push(`SameSite=${this.sameSite}`),this.secure&&e.push("Secure"),e.join("; ")}static from(e){let t=new le;if(e!==null)if(typeof e=="string"){let r=A(e);if(r.length>0){t.name=r[0][0],t.value=r[0][1];for(let[s,u]of r.slice(1))switch(s.toLowerCase()){case"domain":t.domain=u;break;case"expires":{if(typeof u=="string"){let p=new Date(u);Se(p)&&(t.expires=p)}break}case"httponly":t.httpOnly=!0;break;case"max-age":{if(typeof u=="string"){let p=parseInt(u,10);isNaN(p)||(t.maxAge=p)}break}case"partitioned":t.partitioned=!0;break;case"path":t.path=u;break;case"samesite":typeof u=="string"&&/strict|lax|none/i.test(u)&&(t.sameSite=Ce(u));break;case"secure":t.secure=!0;break}}}else t.domain=e.domain,t.expires=e.expires,t.httpOnly=e.httpOnly,t.maxAge=e.maxAge,t.name=e.name,t.partitioned=e.partitioned,t.path=e.path,t.sameSite=e.sameSite,t.secure=e.secure,t.value=e.value;return t}}var yt=Object.defineProperty,bt=n((a,e)=>yt(a,"name",{value:e,configurable:!0}),"o$1");class ce{static{n(this,"Vary")}static{bt(this,"Vary")}#e;constructor(e){if(e)return ce.from(e);this.#e=new Set}get headerNames(){return Array.from(this.#e)}get size(){return this.#e.size}has(e){return this.#e.has(e.toLowerCase())}add(e){let t=e.trim();t&&this.#e.add(t.toLowerCase())}delete(e){this.#e.delete(e.toLowerCase())}clear(){this.#e.clear()}forEach(e,t){for(let r of this)e.call(t,r,this)}[Symbol.iterator](){return this.#e.values()}toString(){return Array.from(this.#e).join(", ")}static from(e){let t=new ce;if(e!==null)if(typeof e=="string")for(let r of e.split(",")){let s=r.trim();s&&t.#e.add(s.toLowerCase())}else if(Array.isArray(e))for(let r of e){let s=r.trim();s&&t.#e.add(s.toLowerCase())}else for(let r of e.headerNames){let s=r.trim();s&&t.#e.add(s.toLowerCase())}return t}}var wt=Object.defineProperty,Ct=n((a,e)=>wt(a,"name",{value:e,configurable:!0}),"t");const St={ct:"CT",etag:"ETag",te:"TE",www:"WWW",x:"X",xss:"XSS"};function je(a){return a.toLowerCase().split("-").map(e=>St[e]||e.charAt(0).toUpperCase()+e.slice(1)).join("-")}n(je,"canonicalHeaderName");Ct(je,"canonicalHeaderName");var xt=Object.defineProperty,Oe=n((a,e)=>xt(a,"name",{value:e,configurable:!0}),"a");const Pe=`\r
27
+ `;function Et(a){let e=new Headers;for(let t of a.split(Pe)){let r=t.match(/^([^:]+):(.*)/);r&&e.append(r[1].trim(),r[2].trim())}return e}n(Et,"parse");Oe(Et,"parse");function $t(a){let e="";for(let[t,r]of a)e&&(e+=Pe),e+=`${je(t)}: ${r}`;return e}n($t,"stringify");Oe($t,"stringify");const At={acceptsMediaType(a,e){const t=this.parseAccept(a);return t?t.accepts(e):!1},createCacheControl(a){const e=[];return a.public&&e.push("public"),a.private&&e.push("private"),a.noCache&&e.push("no-cache"),a.noStore&&e.push("no-store"),a.immutable&&e.push("immutable"),a.mustRevalidate&&e.push("must-revalidate"),a.proxyRevalidate&&e.push("proxy-revalidate"),a.maxAge!==void 0&&e.push(`max-age=${a.maxAge}`),a.sMaxAge!==void 0&&e.push(`s-maxage=${a.sMaxAge}`),a.minFresh!==void 0&&e.push(`min-fresh=${a.minFresh}`),a.staleWhileRevalidate!==void 0&&e.push(`stale-while-revalidate=${a.staleWhileRevalidate}`),a.staleIfError!==void 0&&e.push(`stale-if-error=${a.staleIfError}`),e.join(", ")},createCacheControlPreset(a){const e={immutable:{immutable:!0,maxAge:31536e3},"no-cache":{noCache:!0},"no-store":{noStore:!0},private:{maxAge:3600,private:!0},public:{maxAge:3600,public:!0}};return this.createCacheControl(e[a])},createContentDisposition(a){return new D({type:a.type,...a.filename&&{filename:a.filename},...a.filenameSplat&&{filenameSplat:a.filenameSplat}}).toString()},createContentType(a){return new F({mediaType:a.mediaType,...a.charset&&{charset:a.charset},...a.boundary&&{boundary:a.boundary}}).toString()},ensureCharset(a,e="utf8"){const t=this.parseContentType(a);return t?(t.charset||(t.charset=e),t.toString()):a},fromHeaders(a){const e=new Headers;return Array.isArray(a)?a.forEach(([t,r])=>{e.set(t,Array.isArray(r)?r.join(", "):String(r))}):Object.entries(a).forEach(([t,r])=>{e.set(t,Array.isArray(r)?r.join(", "):String(r))}),e},getPreferredMediaType(a,e){const t=this.parseAccept(a);if(t){for(const r of e)if(t.accepts(r))return r}},parseAccept(a){if(a)try{return new B(a)}catch{return}},parseContentDisposition(a){if(a)try{return new D(a)}catch{return}},parseContentType(a){if(a)try{return new F(a)}catch{return}}};export{At as H,Ue as h,Tt as n};
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var t=(e,r)=>a(e,"name",{value:r,configurable:!0});var i=Object.defineProperty,n=t((e,r)=>i(e,"name",{value:r,configurable:!0}),"t");const p=n(e=>e.expiredAt?Date.now()>+new Date(e.expiredAt):!1,"isExpired");export{p as o};
@@ -0,0 +1 @@
1
+ var b=Object.defineProperty;var d=(e,t)=>b(e,"name",{value:t,configurable:!0});var R=Object.defineProperty,i=d((e,t)=>R(e,"name",{value:t,configurable:!0}),"o");const l={backoffMultiplier:2,calculateDelay:void 0,initialDelay:1e3,maxDelay:3e4,maxRetries:3,retryableStatusCodes:[408,429,500,502,503,504],shouldRetry:i(()=>!0,"shouldRetry")},p=i((e,t,a,o)=>{const r=t*a**e;return Math.min(r,o)},"calculateExponentialBackoff"),D=i(e=>new Promise(t=>{setTimeout(t,e)}),"sleep"),C=i((e,t=l.retryableStatusCodes)=>{if(e instanceof Error){const a=e.code,o=e.name;if(a==="ECONNRESET"||a==="ETIMEDOUT"||a==="ENOTFOUND"||a==="ECONNREFUSED"||a==="EAI_AGAIN"||o==="NetworkError"||o==="TimeoutError")return!0;const r=e;if(r.$metadata){const u=r.$metadata.httpStatusCode;if(u&&t.includes(u)||r.$fault==="server")return!0}if(r.statusCode&&t.includes(r.statusCode))return!0;const{retryable:s}=r;return s===!0||typeof s=="string"&&s==="true"}return!1},"isRetryableError"),h=i(async(e,t={})=>{const{backoffMultiplier:a=l.backoffMultiplier,calculateDelay:o=l.calculateDelay,initialDelay:r=l.initialDelay,maxDelay:s=l.maxDelay,maxRetries:u=l.maxRetries,retryableStatusCodes:m=l.retryableStatusCodes,shouldRetry:E=l.shouldRetry}=t;let f;for(let n=0;n<=u;n+=1)try{return await e()}catch(c){if(f=c,n>=u)break;if(!(E(c)||C(c,m)))throw c;const y=o?o(n,c):p(n,r,a,s);y!==void 0&&y>0&&await D(y)}throw f},"retry"),N=i((e={})=>t=>h(t,e),"createRetryWrapper");export{N as createRetryWrapper,C as isRetryableError,h as retry};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var r=(e,t)=>p(e,"name",{value:t,configurable:!0});import s from"mime";var m=Object.defineProperty,o=r((e,t)=>m(e,"name",{value:t,configurable:!0}),"i");const d=o((e,t)=>e?e.startsWith(`${t}/`):!1,"isValidMediaType"),l=o(e=>{if(e)return s.getExtension(e)||void 0},"getFormatFromContentType"),c=o((e,t,i)=>{const a=typeof e.size=="string"?Number.parseInt(e.size,10):e.size;if(i?.maxSize&&a>i.maxSize)throw new Error(`${t} size ${a} exceeds maximum allowed size ${i.maxSize}`);if(!d(e.contentType,t))throw new Error(`File is not ${t==="image"?"an":"a"} ${t}: ${e.contentType}`);const n=l(e.contentType);if(i?.supportedFormats&&n&&!i.supportedFormats.includes(n))throw new Error(`Unsupported ${t} format: ${n}`)},"validateMediaFile"),u=o(e=>e?!!s.getExtension(e):!1,"isKnownContentType");export{l as getFormatFromContentType,u as isKnownContentType,d as isValidMediaType,c as validateMediaFile};