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

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 (224) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +33 -14
  3. package/dist/adapter/nuxt/module.d.ts +39 -0
  4. package/dist/adapter/nuxt/module.js +93 -0
  5. package/dist/adapter/nuxt/package.json +20 -0
  6. package/dist/handler/base/base-handler-core.d.ts +91 -0
  7. package/dist/handler/base/base-handler-fetch.d.ts +76 -0
  8. package/dist/handler/base/base-handler-node.d.ts +137 -0
  9. package/dist/handler/http/fetch/index.d.ts +4 -0
  10. package/dist/handler/http/fetch/index.js +4 -0
  11. package/dist/handler/http/hono/index.d.ts +67 -0
  12. package/dist/handler/http/hono/index.js +65 -0
  13. package/dist/handler/http/nextjs/index.d.ts +61 -0
  14. package/dist/handler/http/nextjs/index.js +37 -0
  15. package/dist/handler/http/node/index.d.ts +4 -0
  16. package/dist/handler/http/node/index.js +4 -0
  17. package/dist/handler/http/solid-start/index.d.ts +60 -0
  18. package/dist/handler/http/solid-start/index.js +44 -0
  19. package/dist/handler/multipart/multipart-base.d.ts +84 -0
  20. package/dist/handler/multipart/multipart-fetch.d.ts +64 -0
  21. package/dist/handler/multipart/multipart.d.ts +49 -0
  22. package/dist/handler/rest/rest-base.d.ts +106 -0
  23. package/dist/handler/rest/rest-fetch.d.ts +88 -0
  24. package/dist/handler/rest/rest.d.ts +93 -0
  25. package/dist/handler/tus/tus-base.d.ts +152 -0
  26. package/dist/handler/tus/tus-fetch.d.ts +72 -0
  27. package/dist/handler/tus/tus.d.ts +78 -0
  28. package/dist/handler/types.d.ts +53 -0
  29. package/dist/handler/utils/request-parser.d.ts +72 -0
  30. package/dist/handler/utils/response-builder.d.ts +83 -0
  31. package/dist/handler/utils/storage-utils.d.ts +10 -0
  32. package/dist/handler/utils/stream-utils.d.ts +29 -0
  33. package/dist/handler/utils/upload-handlers.d.ts +76 -0
  34. package/dist/index.d.ts +17 -0
  35. package/dist/index.js +13 -0
  36. package/dist/metrics/index.d.ts +2 -0
  37. package/dist/metrics/no-op-metrics.d.ts +15 -0
  38. package/dist/metrics/opentelemetry-metrics.d.ts +55 -0
  39. package/dist/openapi/index.d.ts +5 -0
  40. package/dist/openapi/index.js +5 -0
  41. package/dist/openapi/rest.d.ts +7 -0
  42. package/dist/openapi/shared.d.ts +13 -0
  43. package/dist/openapi/transform.d.ts +3 -0
  44. package/dist/openapi/tus.d.ts +7 -0
  45. package/dist/openapi/xhr.d.ts +7 -0
  46. package/dist/packem_shared/AwsLightFile-tTneXZgG.js +11 -0
  47. package/dist/packem_shared/AwsLightMetaStorage-BWSOtVaN.js +4 -0
  48. package/dist/packem_shared/AwsLightStorage-Blv-GP4v.js +133 -0
  49. package/dist/packem_shared/AzureFile-CesgFzps.js +8 -0
  50. package/dist/packem_shared/AzureSMetaStorage-CFs-OYJT.js +88 -0
  51. package/dist/packem_shared/AzureStorage-B0v048hG.js +357 -0
  52. package/dist/packem_shared/BaseTransformer-C2gLib6v.js +82 -0
  53. package/dist/packem_shared/DiskStorage-BlltBst6.js +12 -0
  54. package/dist/packem_shared/DiskStorageWithChecksum-BJTmMklc.js +238 -0
  55. package/dist/packem_shared/ERRORS-D0apMqnc.js +97 -0
  56. package/dist/packem_shared/File-Bb3P23dr.js +69 -0
  57. package/dist/packem_shared/GCSConfig-vPP22kN6.js +11 -0
  58. package/dist/packem_shared/GCSFile-BIEunhAN.js +8 -0
  59. package/dist/packem_shared/GCSMetaStorage-BMFEdzJ7.js +7 -0
  60. package/dist/packem_shared/GCStorage-DnhiwaS9.js +406 -0
  61. package/dist/packem_shared/LocalMetaStorage-CZHhKkMd.js +7 -0
  62. package/dist/packem_shared/MediaTransformer-D6658DL1.js +1197 -0
  63. package/dist/packem_shared/MetaStorage-pECeFOad.js +46 -0
  64. package/dist/packem_shared/Metadata-DRLXeJ0F.js +89 -0
  65. package/dist/packem_shared/Multipart-CNFK_Okz.js +163 -0
  66. package/dist/packem_shared/Multipart-CtUL7BQw.js +128 -0
  67. package/dist/packem_shared/NetlifyBlobFile-CXzyjqrD.js +14 -0
  68. package/dist/packem_shared/NetlifyBlobMetaStorage-DxZ5aDvD.js +9 -0
  69. package/dist/packem_shared/NetlifyBlobStorage-CLPtjHqd.js +376 -0
  70. package/dist/packem_shared/NoOpMetrics-DhAk5rXc.js +10 -0
  71. package/dist/packem_shared/OpenTelemetryMetrics-BnxhqIaH.js +67 -0
  72. package/dist/packem_shared/Rest-CAOAEkOj.js +267 -0
  73. package/dist/packem_shared/Rest-DNuLwBrK.js +228 -0
  74. package/dist/packem_shared/S3File-DZiyk9Qt.js +11 -0
  75. package/dist/packem_shared/S3MetaStorage-Dz9aDabA.js +76 -0
  76. package/dist/packem_shared/S3Storage-DHmTk-hU.js +316 -0
  77. package/dist/packem_shared/TUS_RESUMABLE-GJzZ9R-f.js +434 -0
  78. package/dist/packem_shared/Tus-B8PmlMgR.js +200 -0
  79. package/dist/packem_shared/Tus-C4F1aYOl.js +195 -0
  80. package/dist/packem_shared/ValidationError-BfF1aE4h.js +26 -0
  81. package/dist/packem_shared/VercelBlobFile-BCg4aTEq.js +18 -0
  82. package/dist/packem_shared/VercelBlobMetaStorage-Bd9F-VFm.js +9 -0
  83. package/dist/packem_shared/VercelBlobStorage-DD9LMOS6.js +261 -0
  84. package/dist/packem_shared/_commonjsHelpers-B85MJLTf.js +5 -0
  85. package/dist/packem_shared/aws-light-meta-storage-DKJBgbR6.js +446 -0
  86. package/dist/packem_shared/backblaze-BlMnIcBC.js +20 -0
  87. package/dist/packem_shared/base-handler-core-BKuf4YLT.js +303 -0
  88. package/dist/packem_shared/base-handler-fetch-Cr0hLiqg.js +291 -0
  89. package/dist/packem_shared/base-handler-node-gk5aN9Cx.js +730 -0
  90. package/dist/packem_shared/cache-B88MXQ_2.js +18 -0
  91. package/dist/packem_shared/cloudflare-Bi1q8wXE.js +21 -0
  92. package/dist/packem_shared/defaultCloudStorageFileNameValidation-DUuacjWv.js +11 -0
  93. package/dist/packem_shared/digitalOcean-CWQRJM3L.js +21 -0
  94. package/dist/packem_shared/disk-storage-Bh2wy3YW.js +810 -0
  95. package/dist/packem_shared/gcs-meta-storage-0tgMNnPO.js +158 -0
  96. package/dist/packem_shared/has-content-CY66ehMK.js +3 -0
  97. package/dist/packem_shared/headers-DoS5nwM-.js +3220 -0
  98. package/dist/packem_shared/is-expired-CTThU1q5.js +8 -0
  99. package/dist/packem_shared/isRetryableError-Dycp7127.js +82 -0
  100. package/dist/packem_shared/isValidMediaType-BeDgiObq.js +35 -0
  101. package/dist/packem_shared/local-meta-storage-By-3SNBI.js +649 -0
  102. package/dist/packem_shared/minio-C2YBZQOw.js +22 -0
  103. package/dist/packem_shared/multipart-base-B3i67SSX.js +102 -0
  104. package/dist/packem_shared/part-match-BMNqHDYD.js +96 -0
  105. package/dist/packem_shared/path-CR6YkPXX-7R1-9CMk.js +161 -0
  106. package/dist/packem_shared/response-builder-BtnRiBUI.js +45 -0
  107. package/dist/packem_shared/rest-base-GRCcnan7.js +457 -0
  108. package/dist/packem_shared/restOpenApiSpec-CwcHHY2C.js +800 -0
  109. package/dist/packem_shared/s3-base-storage-C1DIHTYY.js +510 -0
  110. package/dist/packem_shared/sharedGet-Cpo7QUyu.js +1019 -0
  111. package/dist/packem_shared/storage-C6NSXb8h.js +1175 -0
  112. package/dist/packem_shared/tigris-Hac8TKnX.js +21 -0
  113. package/dist/packem_shared/transformOpenApiSpec-DWM5WtnN.js +975 -0
  114. package/dist/packem_shared/tusOpenApiSpec-6ohiToBy.js +740 -0
  115. package/dist/packem_shared/update-size-CCGm6i1J.js +8 -0
  116. package/dist/packem_shared/validator-BeX_lJet.js +78 -0
  117. package/dist/packem_shared/waitForStorage-Cscw85sx.js +18 -0
  118. package/dist/packem_shared/wasabi-DIyflHSd.js +21 -0
  119. package/dist/packem_shared/xhrOpenApiSpec-DS17brnx.js +264 -0
  120. package/dist/storage/aws/clients/backblaze.d.ts +12 -0
  121. package/dist/storage/aws/clients/cloudflare.d.ts +13 -0
  122. package/dist/storage/aws/clients/digital-ocean.d.ts +12 -0
  123. package/dist/storage/aws/clients/index.d.ts +6 -0
  124. package/dist/storage/aws/clients/index.js +6 -0
  125. package/dist/storage/aws/clients/minio.d.ts +13 -0
  126. package/dist/storage/aws/clients/tigris.d.ts +12 -0
  127. package/dist/storage/aws/clients/types.d.ts +95 -0
  128. package/dist/storage/aws/clients/wasabi.d.ts +12 -0
  129. package/dist/storage/aws/index.d.ts +4 -0
  130. package/dist/storage/aws/index.js +3 -0
  131. package/dist/storage/aws/s3-base-storage.d.ts +248 -0
  132. package/dist/storage/aws/s3-client-adapter.d.ts +110 -0
  133. package/dist/storage/aws/s3-file.d.ts +10 -0
  134. package/dist/storage/aws/s3-meta-storage.d.ts +15 -0
  135. package/dist/storage/aws/s3-storage.d.ts +70 -0
  136. package/dist/storage/aws/types.d.ts +119 -0
  137. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +130 -0
  138. package/dist/storage/aws-light/aws-light-file.d.ts +10 -0
  139. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +19 -0
  140. package/dist/storage/aws-light/aws-light-storage.d.ts +65 -0
  141. package/dist/storage/aws-light/index.d.ts +4 -0
  142. package/dist/storage/aws-light/index.js +3 -0
  143. package/dist/storage/aws-light/types.d.ts +37 -0
  144. package/dist/storage/azure/azure-file.d.ts +6 -0
  145. package/dist/storage/azure/azure-meta-storage.d.ts +15 -0
  146. package/dist/storage/azure/azure-storage.d.ts +69 -0
  147. package/dist/storage/azure/index.d.ts +4 -0
  148. package/dist/storage/azure/index.js +3 -0
  149. package/dist/storage/azure/types.d.ts +62 -0
  150. package/dist/storage/gcs/fetch-error.d.ts +11 -0
  151. package/dist/storage/gcs/gcs-config.d.ts +2 -0
  152. package/dist/storage/gcs/gcs-file.d.ts +6 -0
  153. package/dist/storage/gcs/gcs-meta-storage.d.ts +27 -0
  154. package/dist/storage/gcs/gcs-storage.d.ts +91 -0
  155. package/dist/storage/gcs/index.d.ts +5 -0
  156. package/dist/storage/gcs/index.js +4 -0
  157. package/dist/storage/gcs/types.d.ts +55 -0
  158. package/dist/storage/gcs/utils.d.ts +7 -0
  159. package/dist/storage/local/disk-storage-with-checksum.d.ts +15 -0
  160. package/dist/storage/local/disk-storage.d.ts +135 -0
  161. package/dist/storage/local/index.d.ts +4 -0
  162. package/dist/storage/local/index.js +3 -0
  163. package/dist/storage/local/local-meta-storage.d.ts +32 -0
  164. package/dist/storage/meta-storage.d.ts +30 -0
  165. package/dist/storage/netlify-blob/index.d.ts +4 -0
  166. package/dist/storage/netlify-blob/index.js +3 -0
  167. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +12 -0
  168. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +7 -0
  169. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +93 -0
  170. package/dist/storage/netlify-blob/types.d.ts +30 -0
  171. package/dist/storage/storage.d.ts +353 -0
  172. package/dist/storage/types.d.ts +221 -0
  173. package/dist/storage/utils/file/file.d.ts +25 -0
  174. package/dist/storage/utils/file/get-file-status.d.ts +9 -0
  175. package/dist/storage/utils/file/has-content.d.ts +9 -0
  176. package/dist/storage/utils/file/index.d.ts +10 -0
  177. package/dist/storage/utils/file/is-expired.d.ts +8 -0
  178. package/dist/storage/utils/file/metadata.d.ts +18 -0
  179. package/dist/storage/utils/file/part-match.d.ts +11 -0
  180. package/dist/storage/utils/file/types.d.ts +37 -0
  181. package/dist/storage/utils/file/update-metadata.d.ts +10 -0
  182. package/dist/storage/utils/file/update-size.d.ts +10 -0
  183. package/dist/storage/vercel-blob/index.d.ts +4 -0
  184. package/dist/storage/vercel-blob/index.js +3 -0
  185. package/dist/storage/vercel-blob/types.d.ts +32 -0
  186. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +16 -0
  187. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +7 -0
  188. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +76 -0
  189. package/dist/transformer/audio-transformer.d.ts +128 -0
  190. package/dist/transformer/audio-transformer.js +278 -0
  191. package/dist/transformer/base-transformer.d.ts +63 -0
  192. package/dist/transformer/image-transformer.d.ts +571 -0
  193. package/dist/transformer/image-transformer.js +1100 -0
  194. package/dist/transformer/index.d.ts +5 -0
  195. package/dist/transformer/index.js +4 -0
  196. package/dist/transformer/media-transformer.d.ts +332 -0
  197. package/dist/transformer/types.d.ts +652 -0
  198. package/dist/transformer/utils.d.ts +33 -0
  199. package/dist/transformer/validation-error.d.ts +23 -0
  200. package/dist/transformer/video-transformer.d.ts +145 -0
  201. package/dist/transformer/video-transformer.js +310 -0
  202. package/dist/utils/cache.d.ts +32 -0
  203. package/dist/utils/chunked-upload.d.ts +65 -0
  204. package/dist/utils/detect-file-type.d.ts +28 -0
  205. package/dist/utils/errors.d.ts +74 -0
  206. package/dist/utils/file-path-url-matcher.d.ts +18 -0
  207. package/dist/utils/headers.d.ts +111 -0
  208. package/dist/utils/http.d.ts +92 -0
  209. package/dist/utils/locker.d.ts +26 -0
  210. package/dist/utils/pipes/stream-checksum.d.ts +47 -0
  211. package/dist/utils/pipes/stream-length.d.ts +22 -0
  212. package/dist/utils/primitives/get-last-one.d.ts +3 -0
  213. package/dist/utils/primitives/is-record.d.ts +2 -0
  214. package/dist/utils/primitives/map-values.d.ts +9 -0
  215. package/dist/utils/primitives/pick.d.ts +2 -0
  216. package/dist/utils/primitives/to-milliseconds.d.ts +12 -0
  217. package/dist/utils/primitives/to-seconds.d.ts +12 -0
  218. package/dist/utils/range-checksum.d.ts +33 -0
  219. package/dist/utils/range-hasher.d.ts +46 -0
  220. package/dist/utils/retry.d.ts +64 -0
  221. package/dist/utils/types.d.ts +108 -0
  222. package/dist/utils/validation-error.d.ts +22 -0
  223. package/dist/utils/validator.d.ts +36 -0
  224. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,3 +1,33 @@
1
+ ## @visulima/storage [1.0.0-alpha.3](https://github.com/visulima/visulima/compare/@visulima/storage@1.0.0-alpha.2...@visulima/storage@1.0.0-alpha.3) (2025-12-10)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/humanizer:** upgraded to 3.0.0-alpha.3
7
+
8
+ ## @visulima/storage [1.0.0-alpha.2](https://github.com/visulima/visulima/compare/@visulima/storage@1.0.0-alpha.1...@visulima/storage@1.0.0-alpha.2) (2025-12-07)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+
12
+ * change min node version to 22.13
13
+
14
+ ### Bug Fixes
15
+
16
+ * add new package image, fixed readme rendering on npm, fixed building of packages ([b790ba2](https://github.com/visulima/visulima/commit/b790ba253ea07fef83528fd822a678facf021b5f))
17
+ * update Node.js engine version requirement to >=22.13 in multiple package.json files for improved compatibility ([b828e9a](https://github.com/visulima/visulima/commit/b828e9aeaebfc798eecddccd90e6ec7560c6d36a))
18
+
19
+ ### Miscellaneous Chores
20
+
21
+ * moved all packages into groups ([0615e9d](https://github.com/visulima/visulima/commit/0615e9d14a8a886e11da529ce150cf31ca973c10))
22
+ * update @anolilab/semantic-release-pnpm and @anolilab/semantic-release-preset to versions 3.2.2 and 12.1.2 across multiple package.json files for improved compatibility ([3921626](https://github.com/visulima/visulima/commit/3921626141fe5da398749bf0ba675f1596f18afb))
23
+ * update dependencies across multiple packages to improve compatibility and performance, including upgrading `@anolilab/semantic-release-pnpm` and `@anolilab/semantic-release-preset` to versions 3.2.0 and 12.1.0 respectively, and updating `react`, `react-dom`, and `next` versions to 19.2.1 and 16.0.7 in various package.json files ([aee8fcd](https://github.com/visulima/visulima/commit/aee8fcd796ae9b8d055903260e7150996ea9f53d))
24
+ * update implicit dependencies in project.json for storage package ([2473f8a](https://github.com/visulima/visulima/commit/2473f8a2297df40425ba4eb4d9eb14d40db0b6ac))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.1
30
+
1
31
  ## @visulima/storage 1.0.0-alpha.1 (2025-12-02)
2
32
 
3
33
  ### Features
package/README.md CHANGED
@@ -1,15 +1,24 @@
1
- <div align="center">
2
- <h3>Visulima upload</h3>
3
- <p>Visulima upload copies files to a web-accessible location and provides a consistent way to get the URLs that correspond to those files.</p>
4
- <p>Visulima upload can also resize, crop and autorotate uploaded images.</p>
5
- <p>Visulima upload includes S3-based, Azure-based, GCS-based and local filesystem-based backends and you may supply others.</p>
6
- </div>
1
+ <!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
2
+
3
+ <a href="https://www.anolilab.com/open-source" align="center">
4
+
5
+ <img src="__assets__/package-og.svg" alt="storage" />
6
+
7
+ </a>
8
+
9
+ <h3 align="center">Visulima upload - Store files in a web-accessible location via a simplified API. Can automatically scale and rotate images. Includes S3, Azure, GCS and local filesystem-based backends with the most convenient features of each.</h3>
10
+
11
+ <!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
7
12
 
8
13
  <br />
9
14
 
10
15
  <div align="center">
11
16
 
12
- [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
17
+ [![typescript-image][typescript-badge]][typescript-url]
18
+ [![mit licence][license-badge]][license]
19
+ [![npm downloads][npm-downloads-badge]][npm-downloads]
20
+ [![Chat][chat-badge]][chat]
21
+ [![PRs Welcome][prs-welcome-badge]][prs-welcome]
13
22
 
14
23
  </div>
15
24
 
@@ -549,13 +558,23 @@ If you would like to help take a look at the [list of issues](https://github.com
549
558
  - [Daniel Bannert](https://github.com/prisis)
550
559
  - [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
551
560
 
561
+ ## Made with ❤️ at Anolilab
562
+
563
+ This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
564
+
552
565
  ## License
553
566
 
554
- The visulima uploads is open-sourced software licensed under the [MIT][license-url]
567
+ The visulima uploads is open-sourced software licensed under the [MIT][license]
568
+
569
+ <!-- badges -->
555
570
 
556
- [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
557
- [typescript-url]: "typescript"
558
- [license-image]: https://img.shields.io/npm/l/@visulima/upload?color=blueviolet&style=for-the-badge
559
- [license-url]: LICENSE.md "license"
560
- [npm-image]: https://img.shields.io/npm/v/@visulima/upload/latest.svg?style=for-the-badge&logo=npm
561
- [npm-url]: https://www.npmjs.com/package/@visulima/upload/v/latest "npm"
571
+ [license-badge]: https://img.shields.io/npm/l/@visulima/upload?style=for-the-badge
572
+ [license]: https://github.com/visulima/visulima/blob/main/LICENSE
573
+ [npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/upload?style=for-the-badge
574
+ [npm-downloads]: https://www.npmjs.com/package/@visulima/upload
575
+ [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
576
+ [prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
577
+ [chat-badge]: https://img.shields.io/discord/932323359193186354.svg?style=for-the-badge
578
+ [chat]: https://discord.gg/TtFJY8xkFK
579
+ [typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
580
+ [typescript-url]: https://www.typescriptlang.org/
@@ -0,0 +1,39 @@
1
+ import type { UploadOptions } from "../../handler/types.d.ts";
2
+ import type { BaseStorage } from "../../storage/storage.d.ts";
3
+ import type { UploadFile } from "../../storage/utils/index.d.ts";
4
+ /**
5
+ * CORS configuration for upload endpoints
6
+ */
7
+ export interface CorsOptions {
8
+ /** Allowed CORS headers */
9
+ headers?: string[];
10
+ /** Allowed HTTP methods */
11
+ methods?: string[];
12
+ /** Allowed origins (use "*" for all origins) */
13
+ origin?: string | string[];
14
+ }
15
+ /**
16
+ * Configuration options for the Nuxt storage module
17
+ */
18
+ export interface ModuleOptions {
19
+ /** Base path for upload routes (default: '/api/upload') */
20
+ basePath?: string;
21
+ /** CORS configuration */
22
+ cors?: CorsOptions;
23
+ /** Enable multipart upload endpoint (default: true) */
24
+ multipart?: boolean;
25
+ /** Additional options for multipart handler */
26
+ multipartOptions?: Omit<UploadOptions<UploadFile>, "storage">;
27
+ /** Enable REST API endpoint for direct binary uploads (default: true) */
28
+ rest?: boolean;
29
+ /** Additional options for REST handler */
30
+ restOptions?: Omit<UploadOptions<UploadFile>, "storage">;
31
+ /** Storage instance to use for file uploads */
32
+ storage: BaseStorage;
33
+ /** Enable TUS resumable upload endpoint (default: true) */
34
+ tus?: boolean;
35
+ /** Additional options for TUS handler */
36
+ tusOptions?: Omit<UploadOptions<UploadFile>, "storage">;
37
+ }
38
+ declare const nuxtModule: any;
39
+ export default nuxtModule;
@@ -0,0 +1,93 @@
1
+ import { defineNuxtModule } from '@nuxt/kit';
2
+
3
+ const handlerStorage = /* @__PURE__ */ new Map();
4
+ const nuxtModule = defineNuxtModule({
5
+ defaults: {
6
+ basePath: "/api/upload",
7
+ cors: {
8
+ headers: ["Content-Type", "Upload-Offset", "Upload-Length", "Tus-Resumable"],
9
+ methods: ["GET", "POST", "PATCH", "PUT", "HEAD", "DELETE", "OPTIONS"],
10
+ origin: "*"
11
+ },
12
+ multipart: true,
13
+ rest: true,
14
+ tus: true
15
+ },
16
+ meta: {
17
+ compatibility: {
18
+ nuxt: ">=4.0.0"
19
+ },
20
+ configKey: "storage",
21
+ name: "@visulima/storage"
22
+ },
23
+ async setup(options, nuxt) {
24
+ const {
25
+ basePath = "/api/upload",
26
+ cors = {
27
+ headers: ["Content-Type", "Upload-Offset", "Upload-Length", "Tus-Resumable"],
28
+ methods: ["GET", "POST", "PATCH", "PUT", "HEAD", "DELETE", "OPTIONS"],
29
+ origin: "*"
30
+ },
31
+ multipart = true,
32
+ multipartOptions = {},
33
+ rest = true,
34
+ restOptions = {},
35
+ storage,
36
+ tus = true,
37
+ tusOptions = {}
38
+ } = options;
39
+ if (!storage) {
40
+ throw new Error("[@visulima/storage/nuxt] Storage instance is required");
41
+ }
42
+ const { Multipart, Rest, Tus } = await import('../../handler/http/node/index.js');
43
+ const multipartHandler = multipart ? new Multipart({ storage, ...multipartOptions }) : void 0;
44
+ const restHandler = rest ? new Rest({ storage, ...restOptions }) : void 0;
45
+ const tusHandler = tus ? new Tus({ storage, ...tusOptions }) : void 0;
46
+ const setCorsHeaders = (event) => {
47
+ const origin = Array.isArray(cors.origin) ? cors.origin.join(", ") : cors.origin || "*";
48
+ event.node.res.setHeader("Access-Control-Allow-Origin", origin);
49
+ if (cors.methods) {
50
+ event.node.res.setHeader("Access-Control-Allow-Methods", cors.methods.join(", "));
51
+ }
52
+ if (cors.headers) {
53
+ event.node.res.setHeader("Access-Control-Allow-Headers", cors.headers.join(", "));
54
+ }
55
+ };
56
+ if (multipartHandler) {
57
+ handlerStorage.set(`${basePath}/multipart`, { handler: multipartHandler, setCorsHeaders });
58
+ }
59
+ if (restHandler) {
60
+ handlerStorage.set(`${basePath}/rest`, { handler: restHandler, setCorsHeaders });
61
+ }
62
+ if (tusHandler) {
63
+ handlerStorage.set(`${basePath}/tus`, { handler: tusHandler, setCorsHeaders });
64
+ }
65
+ nuxt.hook("nitro:config", (nitroConfig) => {
66
+ const routeRules = nitroConfig.routeRules || {};
67
+ if (multipartHandler) {
68
+ routeRules[`${basePath}/multipart/**`] = { cors: true };
69
+ }
70
+ if (restHandler) {
71
+ routeRules[`${basePath}/rest/**`] = { cors: true };
72
+ }
73
+ if (tusHandler) {
74
+ routeRules[`${basePath}/tus/**`] = { cors: true };
75
+ }
76
+ nitroConfig.routeRules = routeRules;
77
+ });
78
+ nuxt.hook("nitro:init", (nitro) => {
79
+ nitro.hooks.hook("request", async (event) => {
80
+ const url = event.node.req.url || "";
81
+ for (const [route, { handler, setCorsHeaders: setHeaders }] of handlerStorage.entries()) {
82
+ if (url.startsWith(route)) {
83
+ setHeaders(event);
84
+ await handler.handle(event.node.req, event.node.res);
85
+ return;
86
+ }
87
+ }
88
+ });
89
+ });
90
+ }
91
+ });
92
+
93
+ export { nuxtModule as default };
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@visulima/storage-nuxt",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./module.d.ts",
8
+ "import": "./module.js"
9
+ }
10
+ },
11
+ "main": "./module.js",
12
+ "types": "./module.d.ts",
13
+ "files": [
14
+ "."
15
+ ],
16
+ "peerDependencies": {
17
+ "@nuxt/kit": ">=4.0.0",
18
+ "nuxt": ">=4.0.0"
19
+ }
20
+ }
@@ -0,0 +1,91 @@
1
+ import { EventEmitter } from "node:events";
2
+ import type { BaseStorage } from "../../storage/storage.d.ts";
3
+ import type { UploadFile } from "../../storage/utils/index.d.ts";
4
+ import type MediaTransformer from "../../transformer/media-transformer.d.ts";
5
+ import type { ErrorResponses } from "../../utils/errors.d.ts";
6
+ import type { ResponseBodyType } from "../../utils/types.d.ts";
7
+ import type { UploadOptions } from "../types.d.ts";
8
+ /**
9
+ * Core base class containing shared business logic for all handlers.
10
+ * This class is platform-agnostic and contains no Node.js or Web API specific code.
11
+ * @template TFile The file type used by this handler.
12
+ */
13
+ declare abstract class BaseHandlerCore<TFile extends UploadFile> extends EventEmitter {
14
+ /**
15
+ * Response body type for the handler.
16
+ */
17
+ responseType: ResponseBodyType;
18
+ /**
19
+ * Storage instance for file operations.
20
+ */
21
+ storage: BaseStorage<TFile>;
22
+ /**
23
+ * Optional media transformer for image/video processing.
24
+ */
25
+ mediaTransformer?: MediaTransformer;
26
+ /**
27
+ * Whether to disable termination for finished uploads.
28
+ */
29
+ disableTerminationForFinishedUploads?: boolean;
30
+ /**
31
+ * Logger instance for debugging and error reporting.
32
+ */
33
+ protected logger?: Console;
34
+ /**
35
+ * Gets the logger instance.
36
+ * @returns Logger instance or undefined.
37
+ */
38
+ get loggerInstance(): Console | undefined;
39
+ /**
40
+ * Internal error responses configuration.
41
+ */
42
+ protected internalErrorResponses: ErrorResponses;
43
+ /**
44
+ * Gets the error responses configuration.
45
+ * @returns Error responses configuration.
46
+ */
47
+ get errorResponses(): ErrorResponses;
48
+ constructor({ disableTerminationForFinishedUploads, mediaTransformer, storage }: UploadOptions<TFile>);
49
+ /**
50
+ * Sets custom error responses.
51
+ * @param value Partial error responses to override defaults.
52
+ */
53
+ set errorResponses(value: Partial<ErrorResponses>);
54
+ /**
55
+ * Assemble error responses by merging defaults with custom overrides.
56
+ * @param customErrors Custom error responses to override defaults
57
+ */
58
+ assembleErrors: (customErrors?: {}) => void;
59
+ /**
60
+ * Parses HTTP Range header and returns start/end byte positions for partial content requests.
61
+ * @param rangeHeader HTTP Range header value (e.g., "bytes=0-1023").
62
+ * @param fileSize Total size of the file in bytes.
63
+ * @returns Object with start and end positions, or undefined if range is invalid.
64
+ */
65
+ parseRangeHeader(rangeHeader: string | undefined, fileSize: number): {
66
+ end: number;
67
+ start: number;
68
+ } | undefined;
69
+ /**
70
+ * Build file URL from request and file data.
71
+ * Platform-agnostic version that accepts URL string.
72
+ * @param requestUrl Request URL string
73
+ * @param file File object containing ID and content type
74
+ * @returns Constructed file URL with extension based on content type
75
+ */
76
+ protected buildFileUrlFromString(requestUrl: string, file: TFile): string;
77
+ /**
78
+ * Negotiates content type based on Accept header and supported formats.
79
+ * Platform-agnostic version that accepts header string.
80
+ * @param acceptHeader Accept header value
81
+ * @param supportedTypes Array of supported MIME types to match against
82
+ * @returns Best matching content type or undefined if no match found
83
+ */
84
+ negotiateContentTypeFromHeader(acceptHeader: string | undefined, supportedTypes: string[]): string | undefined;
85
+ /**
86
+ * Check for undefined ID or path errors and throw appropriate HTTP errors.
87
+ * @param error The error to check
88
+ */
89
+ protected checkForUndefinedIdOrPath(error: unknown): void;
90
+ }
91
+ export default BaseHandlerCore;
@@ -0,0 +1,76 @@
1
+ import type { UploadFile } from "../../storage/utils/index.d.ts";
2
+ import type { UploadResponse } from "../../utils/types.d.ts";
3
+ import type { Handlers, ResponseFile, ResponseList, UploadOptions } from "../types.d.ts";
4
+ import BaseHandlerCore from "./base-handler-core.d.ts";
5
+ /**
6
+ * Base handler for Web API Fetch platform (Request/Response).
7
+ * Extends BaseHandlerCore with Fetch-specific request/response handling.
8
+ * @template TFile The file type used by this handler.
9
+ */
10
+ declare abstract class BaseHandlerFetch<TFile extends UploadFile> extends BaseHandlerCore<TFile> {
11
+ /**
12
+ * Limiting enabled HTTP method handler.
13
+ */
14
+ static readonly methods: Handlers[];
15
+ /**
16
+ * Map of registered HTTP method handlers.
17
+ */
18
+ protected registeredHandlers: Map<string, (request: Request) => Promise<ResponseFile<TFile> | ResponseList<TFile>>>;
19
+ constructor(options: UploadOptions<TFile>);
20
+ /**
21
+ * Gets the registered handlers map.
22
+ * @returns Map of registered handlers.
23
+ */
24
+ get handlers(): Map<string, (request: Request) => Promise<ResponseFile<TFile> | ResponseList<TFile>>>;
25
+ /**
26
+ * Handles Web API Fetch requests (for Hono, Cloudflare Workers, etc.).
27
+ * @param request Web API Request object.
28
+ * @returns Promise resolving to Web API Response.
29
+ */
30
+ fetch(request: Request): Promise<globalThis.Response>;
31
+ /**
32
+ * Compose and register HTTP method handlers.
33
+ * Subclasses should override this to register their specific handlers.
34
+ */
35
+ protected abstract compose(): void;
36
+ /**
37
+ * Handle the response from handlers for fetch requests and convert to Web API Response.
38
+ * @param request Web API Request object
39
+ * @param file Response file or list from handler
40
+ * @returns Promise resolving to Web API Response object
41
+ */
42
+ protected handleFetchResponse(request: Request, file: ResponseFile<TFile> | ResponseList<TFile>): Promise<globalThis.Response>;
43
+ /**
44
+ * Convert headers to Web API Headers format by flattening arrays and converting to strings.
45
+ * @param headers Headers object with potentially array values
46
+ * @returns Headers object with all values as strings
47
+ */
48
+ protected convertHeaders(headers: Record<string, number | string | string[]>): Record<string, string>;
49
+ /**
50
+ * Create Web API Response from UploadResponse object.
51
+ * @param uploadResponse Upload response containing body, headers, and status code
52
+ * @returns Web API Response object
53
+ */
54
+ protected createResponse(uploadResponse: UploadResponse): globalThis.Response;
55
+ /**
56
+ * Create error Response from Error object with appropriate status code and message.
57
+ * @param error Error object to convert to HTTP error response
58
+ * @returns Web API Response object with error details
59
+ */
60
+ protected createErrorResponse(error: Error): Promise<globalThis.Response>;
61
+ /**
62
+ * Build file URL from request and file data.
63
+ * @param request Web API Request object
64
+ * @param file File object containing ID and content type
65
+ * @returns Constructed file URL with extension based on content type
66
+ */
67
+ protected buildFileUrl(request: Request, file: TFile): string;
68
+ /**
69
+ * Negotiates content type based on Accept header and supported formats.
70
+ * @param request Web API Request object containing Accept header.
71
+ * @param supportedTypes Array of supported MIME types to match against.
72
+ * @returns Best matching content type or undefined if no match found.
73
+ */
74
+ negotiateContentType(request: Request, supportedTypes: string[]): string | undefined;
75
+ }
76
+ export default BaseHandlerFetch;
@@ -0,0 +1,137 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { Readable } from "node:stream";
3
+ import type { UploadFile } from "../../storage/utils/index.d.ts";
4
+ import type { UploadResponse } from "../../utils/types.d.ts";
5
+ import type { AsyncHandler, Handlers, MethodHandler, ResponseFile, ResponseList, UploadOptions } from "../types.d.ts";
6
+ import BaseHandlerCore from "./base-handler-core.d.ts";
7
+ /**
8
+ * Base handler for Node.js platform (IncomingMessage/ServerResponse).
9
+ * Extends BaseHandlerCore with Node.js-specific request/response handling.
10
+ * @template TFile The file type used by this handler.
11
+ * @template NodeRequest The Node.js request type.
12
+ * @template NodeResponse The Node.js response type.
13
+ */
14
+ declare abstract class BaseHandlerNode<TFile extends UploadFile, NodeRequest extends IncomingMessage = IncomingMessage, NodeResponse extends ServerResponse = ServerResponse> extends BaseHandlerCore<TFile> implements MethodHandler<NodeRequest, NodeResponse> {
15
+ /**
16
+ * Limiting enabled HTTP method handler.
17
+ */
18
+ static readonly methods: Handlers[];
19
+ /**
20
+ * Map of registered HTTP method handlers.
21
+ */
22
+ protected registeredHandlers: Map<string, AsyncHandler<NodeRequest, NodeResponse>>;
23
+ constructor(options: UploadOptions<TFile>);
24
+ /**
25
+ * Gets the registered handlers map.
26
+ * @returns Map of registered handlers.
27
+ */
28
+ get handlers(): Map<string, AsyncHandler<NodeRequest, NodeResponse>>;
29
+ /**
30
+ * Handles HTTP request (alias for upload method).
31
+ * @param request Node.js IncomingMessage.
32
+ * @param response Node.js ServerResponse.
33
+ */
34
+ handle: (request: NodeRequest, response: NodeResponse) => Promise<void>;
35
+ /**
36
+ * Main upload handler that processes HTTP requests and routes them to appropriate method handlers.
37
+ * @param request Node.js IncomingMessage.
38
+ * @param response Node.js ServerResponse.
39
+ * @param next Optional Express-style next function for middleware compatibility.
40
+ * @throws {UploadError} When storage is not ready or method is not allowed.
41
+ */
42
+ upload: (request: NodeRequest, response: NodeResponse, next?: () => void) => Promise<void>;
43
+ /**
44
+ * Compose and register HTTP method handlers.
45
+ * Subclasses should override this to register their specific handlers.
46
+ */
47
+ protected abstract compose(): void;
48
+ /**
49
+ * Sends an HTTP response with the provided body, headers, and status code.
50
+ * @param response Node.js ServerResponse to send data to.
51
+ * @param body Response body, headers, and status code.
52
+ */
53
+ send(response: NodeResponse, { body, headers, statusCode }: UploadResponse): void;
54
+ /**
55
+ * Sends an error response to the client with appropriate status code and message.
56
+ * @param response Node.js ServerResponse to send error to.
57
+ * @param error Error object to convert to HTTP error response.
58
+ */
59
+ sendError(response: NodeResponse, error: Error): Promise<void>;
60
+ /**
61
+ * Sends streaming response to client with proper backpressure handling and range request support.
62
+ * @param response Node.js ServerResponse to stream data to.
63
+ * @param stream Readable stream containing the file data.
64
+ * @param options Streaming options including headers, range, size, and status code.
65
+ */
66
+ sendStream(response: NodeResponse, stream: Readable, { headers, range, size, statusCode, }: {
67
+ headers?: Record<string, string | number>;
68
+ range?: {
69
+ end: number;
70
+ start: number;
71
+ };
72
+ size?: number;
73
+ statusCode?: number;
74
+ }): void;
75
+ /**
76
+ * Finish upload by sending final response to client with completed file data.
77
+ * @param _request HTTP request (unused parameter)
78
+ * @param response HTTP response object to send final response to
79
+ * @param uploadResponse Final upload response data containing body, headers, and status code
80
+ */
81
+ protected finish(_request: NodeRequest, response: NodeResponse, uploadResponse: UploadResponse | ResponseFile<TFile>): void;
82
+ /**
83
+ * Build file URL from request and file data.
84
+ * @param request HTTP request with optional originalUrl property
85
+ * @param file File object containing ID and content type
86
+ * @returns Constructed file URL with extension based on content type
87
+ */
88
+ protected buildFileUrl(request: NodeRequest & {
89
+ originalUrl?: string;
90
+ }, file: TFile): string;
91
+ /**
92
+ * Negotiates content type based on Accept header and supported formats.
93
+ * @param request HTTP request object containing Accept header.
94
+ * @param supportedTypes Array of supported MIME types to match against.
95
+ * @returns Best matching content type or undefined if no match found.
96
+ */
97
+ negotiateContentType(request: NodeRequest, supportedTypes: string[]): string | undefined;
98
+ /**
99
+ * Default OPTIONS handler.
100
+ * @param _request HTTP request (unused)
101
+ * @param _response HTTP response (unused)
102
+ * @returns Promise resolving to ResponseFile with CORS headers
103
+ */
104
+ options(_request: NodeRequest, _response: NodeResponse): Promise<ResponseFile<TFile>>;
105
+ /**
106
+ * Retrieves a file or list of files based on the request path.
107
+ * @param request Node.js IncomingMessage with optional originalUrl.
108
+ * @param response Node.js ServerResponse.
109
+ * @returns Promise resolving to a single file, paginated list, or array of files.
110
+ * @throws {UploadError} When file is not found or storage error occurs.
111
+ */
112
+ get(request: NodeRequest & {
113
+ originalUrl?: string;
114
+ }, _response: NodeResponse): Promise<ResponseFile<TFile> | ResponseList<TFile>>;
115
+ /**
116
+ * Returns a list of uploaded files with optional pagination support.
117
+ * @param request Node.js IncomingMessage containing query parameters for pagination.
118
+ * @param _response Node.js ServerResponse (unused).
119
+ * @returns Promise resolving to a paginated or complete list of uploaded files.
120
+ */
121
+ list(request: NodeRequest, _response: NodeResponse): Promise<ResponseList<TFile>>;
122
+ /**
123
+ * Streams download of a file with resumable support using HTTP range requests.
124
+ * @param request Node.js IncomingMessage with optional originalUrl and range header.
125
+ * @param response Node.js ServerResponse to stream the file to.
126
+ * @throws {HttpError} When file is not found or streaming is not supported.
127
+ */
128
+ download(request: NodeRequest & {
129
+ originalUrl?: string;
130
+ }, response: NodeResponse): Promise<void>;
131
+ /**
132
+ * Check if error is related to undefined ID or path and throw appropriate HTTP error.
133
+ * @param error Error object to check
134
+ */
135
+ protected checkForUndefinedIdOrPath(error: unknown): void;
136
+ }
137
+ export default BaseHandlerNode;
@@ -0,0 +1,4 @@
1
+ export { default as Multipart } from "../../multipart/multipart-fetch.d.ts";
2
+ export { default as Rest } from "../../rest/rest-fetch.d.ts";
3
+ export { Tus, TUS_RESUMABLE, TUS_VERSION } from "../../tus/tus-fetch.d.ts";
4
+ export type { AsyncHandler, BaseHandler, Handlers, MethodHandler, RequestEvent, UploadErrorEvent, UploadEvent, UploadOptions } from "../../types.d.ts";
@@ -0,0 +1,4 @@
1
+ export { default as Multipart } from '../../../packem_shared/Multipart-CNFK_Okz.js';
2
+ export { default as Rest } from '../../../packem_shared/Rest-CAOAEkOj.js';
3
+ export { Tus } from '../../../packem_shared/Tus-B8PmlMgR.js';
4
+ export { TUS_RESUMABLE, TUS_VERSION } from '../../../packem_shared/TUS_RESUMABLE-GJzZ9R-f.js';
@@ -0,0 +1,67 @@
1
+ import type { Hono } from "hono";
2
+ import type { UploadFile } from "../../../storage/utils/index.d.ts";
3
+ import type { UploadOptions } from "../../types.d.ts";
4
+ /**
5
+ * Registers upload handler routes on a Hono app instance.
6
+ * Automatically registers all required HTTP methods for the specified handler type.
7
+ * @param app Hono app instance to register routes on
8
+ * @param config Handler configuration including storage, type, and path
9
+ * @example
10
+ * ```ts
11
+ * import { Hono } from "hono";
12
+ * import { DiskStorage } from "@visulima/storage";
13
+ * import { createHonoHandler } from "@visulima/storage/handler/http/hono";
14
+ *
15
+ * const app = new Hono();
16
+ * const storage = new DiskStorage({ directory: "./uploads" });
17
+ *
18
+ * // Multipart handler - automatically registers POST, GET, DELETE, OPTIONS
19
+ * createHonoHandler(app, {
20
+ * path: "/files",
21
+ * storage,
22
+ * type: "multipart"
23
+ * });
24
+ * ```
25
+ * @example
26
+ * ```ts
27
+ * import { Hono } from "hono";
28
+ * import { DiskStorage } from "@visulima/storage";
29
+ * import { createHonoHandler } from "@visulima/storage/handler/http/hono";
30
+ *
31
+ * const app = new Hono();
32
+ * const storage = new DiskStorage({ directory: "./uploads" });
33
+ *
34
+ * // REST handler - automatically registers POST, PUT, PATCH, GET, HEAD, DELETE, OPTIONS
35
+ * createHonoHandler(app, {
36
+ * path: "/files-rest",
37
+ * storage,
38
+ * type: "rest"
39
+ * });
40
+ * ```
41
+ * @example
42
+ * ```ts
43
+ * import { Hono } from "hono";
44
+ * import { DiskStorage } from "@visulima/storage";
45
+ * import { createHonoHandler } from "@visulima/storage/handler/http/hono";
46
+ *
47
+ * const app = new Hono();
48
+ * const storage = new DiskStorage({ directory: "./uploads" });
49
+ *
50
+ * // TUS handler - automatically registers POST, PATCH, HEAD, GET, DELETE, OPTIONS
51
+ * createHonoHandler(app, {
52
+ * path: "/files-tus",
53
+ * storage,
54
+ * type: "tus"
55
+ * });
56
+ * ```
57
+ */
58
+ export declare const createStorageHandler: <TFile extends UploadFile>(app: Hono, config: HonoHandlerConfig<TFile>) => void;
59
+ /**
60
+ * Configuration for Hono handler.
61
+ */
62
+ export interface HonoHandlerConfig<TFile extends UploadFile> extends UploadOptions<TFile> {
63
+ /** Base path for the routes (e.g., "/files" or "/api/upload") */
64
+ path: string;
65
+ /** Handler type to use */
66
+ type: "multipart" | "rest" | "tus";
67
+ }