@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
@@ -0,0 +1,135 @@
1
+ import type { Readable } from "node:stream";
2
+ import { ERRORS } from "../../utils/errors.d.ts";
3
+ import type { HttpError } from "../../utils/types.d.ts";
4
+ import type MetaStorage from "../meta-storage.d.ts";
5
+ import { BaseStorage } from "../storage.d.ts";
6
+ import type { DiskStorageOptions } from "../types.d.ts";
7
+ import type { FileInit, FilePart, FileQuery } from "../utils/index.d.ts";
8
+ import { File } from "../utils/index.d.ts";
9
+ import type { FileReturn } from "../utils/file/types.d.ts";
10
+ /**
11
+ * Local disk-based storage implementation.
12
+ * @template TFile The file type used by this storage backend.
13
+ * @remarks
14
+ * ## Error Handling
15
+ * - Filesystem operations throw errors directly (no retry logic)
16
+ * - File not found errors are thrown immediately
17
+ * - Permission errors are propagated as-is
18
+ *
19
+ * ## Retry Behavior
20
+ * - No automatic retries (filesystem operations are typically immediate)
21
+ * - Errors are thrown directly for immediate feedback
22
+ *
23
+ * ## File Paths
24
+ * - Files are stored in the configured directory
25
+ * - Metadata files use the `.META` suffix by default
26
+ * - File paths are resolved relative to the storage directory
27
+ */
28
+ declare class DiskStorage<TFile extends File = File> extends BaseStorage<TFile, FileReturn> {
29
+ static readonly name: string;
30
+ checksumTypes: string[];
31
+ directory: string;
32
+ meta: MetaStorage<TFile>;
33
+ constructor(config: DiskStorageOptions<TFile>);
34
+ /**
35
+ * Normalizes errors with disk storage context.
36
+ * @param error The error to normalize.
37
+ * @returns Normalized HTTP error.
38
+ */
39
+ normalizeError(error: Error): HttpError;
40
+ /**
41
+ * Creates a new file upload and saves its metadata.
42
+ * @param fileInit File initialization configuration.
43
+ * @returns Promise resolving to the created file object.
44
+ * @throws {Error} If validation fails or file already exists and is completed.
45
+ * @remarks
46
+ * Supports TTL (time-to-live) option in fileInit.
47
+ * Creates the file on disk if it doesn't exist.
48
+ * Returns existing file if it's already completed.
49
+ */
50
+ create(fileInit: FileInit): Promise<TFile>;
51
+ /**
52
+ * Writes data to a file upload.
53
+ * @param part File part containing data to write, file query, or full file object.
54
+ * @returns Promise resolving to the updated file object.
55
+ * @throws {Error} If file is expired (ERRORS.GONE), locked (ERRORS.FILE_LOCKED), or conflicts occur (ERRORS.FILE_CONFLICT).
56
+ * @remarks
57
+ * Supports chunked uploads with start position.
58
+ * Automatically detects file type from stream on first chunk if contentType is not set.
59
+ * Validates checksum algorithms if provided.
60
+ * Uses file locking to prevent concurrent writes.
61
+ * Updates file status to "completed" when all bytes are written.
62
+ */
63
+ write(part: FilePart | FileQuery | TFile): Promise<TFile>;
64
+ /**
65
+ * Gets an uploaded file by ID.
66
+ * @param query File query containing the file ID to retrieve.
67
+ * @param query.id File ID to retrieve.
68
+ * @returns Promise resolving to the file data including content buffer.
69
+ * @throws {Error} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
70
+ * @remarks
71
+ * Loads the entire file content into memory as a Buffer.
72
+ * For large files, consider using getStream() instead.
73
+ * Includes ETag (MD5 hash) for content verification.
74
+ */
75
+ get({ id }: FileQuery): Promise<FileReturn>;
76
+ /**
77
+ * Checks if a file exists by verifying both metadata and the actual filesystem file.
78
+ * Returns true only if both the metadata and the file exist.
79
+ * @param query File query containing the file ID to check.
80
+ * @returns Promise resolving to true if both metadata and file exist, false otherwise.
81
+ */
82
+ exists({ id }: FileQuery): Promise<boolean>;
83
+ /**
84
+ * Gets an uploaded file as a readable stream for efficient large file handling.
85
+ * @param query File query containing the file ID to stream.
86
+ * @param query.id File ID to stream.
87
+ * @returns Promise resolving to an object containing the stream, headers, and size.
88
+ * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
89
+ * @remarks Creates a readable stream directly from the file system for efficient memory usage.
90
+ */
91
+ getStream({ id }: FileQuery): Promise<{
92
+ headers?: Record<string, string>;
93
+ size?: number;
94
+ stream: Readable;
95
+ }>;
96
+ /**
97
+ * Deletes an upload and its metadata.
98
+ * @param query File query containing the file ID to delete.
99
+ * @param query.id File ID to delete.
100
+ * @returns Promise resolving to the deleted file object with status: "deleted".
101
+ * @throws {UploadError} If the file metadata cannot be found.
102
+ */
103
+ delete({ id }: FileQuery): Promise<TFile>;
104
+ /**
105
+ * Copies an upload file to a new location.
106
+ * @param name Source file name/ID.
107
+ * @param destination Destination file name/ID.
108
+ * @returns Promise resolving to the copied file object.
109
+ * @throws {UploadError} If the source file cannot be found.
110
+ */
111
+ copy(name: string, destination: string): Promise<TFile>;
112
+ /**
113
+ * Moves an upload file to a new location.
114
+ * @param name Source file name/ID.
115
+ * @param destination Destination file name/ID.
116
+ * @returns Promise resolving to the moved file object.
117
+ * @throws {Error} If the source file cannot be found.
118
+ */
119
+ move(name: string, destination: string): Promise<TFile>;
120
+ /**
121
+ * Retrieves a list of uploaded files.
122
+ * @returns Promise resolving to an array of file metadata objects.
123
+ * @remarks Walks the storage directory and returns all files, excluding metadata files.
124
+ */
125
+ list(): Promise<TFile[]>;
126
+ /**
127
+ * Returns path for the uploaded file
128
+ * If filename is already an absolute path, returns it as-is.
129
+ * Otherwise, joins it with the storage directory.
130
+ */
131
+ protected getFilePath(filename: string): string;
132
+ protected lazyWrite(part: File & FilePart): Promise<[number, ERRORS?]>;
133
+ private accessCheck;
134
+ }
135
+ export default DiskStorage;
@@ -0,0 +1,4 @@
1
+ export { default as DiskStorage } from "./disk-storage.d.ts";
2
+ export { default as DiskStorageWithChecksum } from "./disk-storage-with-checksum.d.ts";
3
+ export type { LocalMetaStorageOptions } from "./local-meta-storage.d.ts";
4
+ export { default as LocalMetaStorage } from "./local-meta-storage.d.ts";
@@ -0,0 +1,3 @@
1
+ export { D as DiskStorage } from '../../packem_shared/disk-storage-Bh2wy3YW.js';
2
+ export { default as DiskStorageWithChecksum } from '../../packem_shared/DiskStorageWithChecksum-BJTmMklc.js';
3
+ export { L as LocalMetaStorage } from '../../packem_shared/local-meta-storage-By-3SNBI.js';
@@ -0,0 +1,32 @@
1
+ import MetaStorage from "../meta-storage.d.ts";
2
+ import type { MetaStorageOptions } from "../types.d.ts";
3
+ import type { File } from "../utils/index.d.ts";
4
+ /**
5
+ * Stores upload metafiles on local disk
6
+ */
7
+ declare class LocalMetaStorage<T extends File = File> extends MetaStorage<T> {
8
+ readonly directory: string;
9
+ constructor(config?: LocalMetaStorageOptions);
10
+ /**
11
+ * Returns metafile path.
12
+ * @param id upload id
13
+ */
14
+ getMetaPath: (id: string) => string;
15
+ /**
16
+ * Returns upload id from metafile path.
17
+ * @internal
18
+ */
19
+ getIdFromPath: (metaFilePath: string) => string;
20
+ save(id: string, file: T): Promise<T>;
21
+ touch(id: string, file: T): Promise<T>;
22
+ get(id: string): Promise<T>;
23
+ delete(id: string): Promise<void>;
24
+ private accessCheck;
25
+ }
26
+ export interface LocalMetaStorageOptions extends MetaStorageOptions {
27
+ /**
28
+ * Where the upload metadata should be stored
29
+ */
30
+ directory?: string;
31
+ }
32
+ export default LocalMetaStorage;
@@ -0,0 +1,30 @@
1
+ import type { MetaStorageOptions } from "./types.d.ts";
2
+ import type { File } from "./utils/index.d.ts";
3
+ /**
4
+ * Stores upload metadata.
5
+ */
6
+ declare class MetaStorage<T extends File = File> {
7
+ prefix: string;
8
+ suffix: string;
9
+ protected readonly logger?: Console;
10
+ constructor(config?: MetaStorageOptions);
11
+ /**
12
+ * Saves upload metadata.
13
+ */
14
+ save(_id: string, file: T): Promise<T>;
15
+ /**
16
+ * Deletes an upload metadata.
17
+ */
18
+ delete(_id: string): Promise<void>;
19
+ /**
20
+ * Retrieves upload metadata.
21
+ */
22
+ get(_id: string): Promise<T>;
23
+ /**
24
+ * Marks upload active.
25
+ */
26
+ touch(_id: string, _file: T): Promise<T>;
27
+ getMetaName(id: string): string;
28
+ getIdFromMetaName(name: string): string;
29
+ }
30
+ export default MetaStorage;
@@ -0,0 +1,4 @@
1
+ export { default as NetlifyBlobFile } from "./netlify-blob-file.d.ts";
2
+ export { default as NetlifyBlobMetaStorage } from "./netlify-blob-meta-storage.d.ts";
3
+ export { default as NetlifyBlobStorage } from "./netlify-blob-storage.d.ts";
4
+ export type { NetlifyBlobStorageOptions } from "./types.d.ts";
@@ -0,0 +1,3 @@
1
+ export { default as NetlifyBlobFile } from '../../packem_shared/NetlifyBlobFile-CXzyjqrD.js';
2
+ export { default as NetlifyBlobMetaStorage } from '../../packem_shared/NetlifyBlobMetaStorage-DxZ5aDvD.js';
3
+ export { default as NetlifyBlobStorage } from '../../packem_shared/NetlifyBlobStorage-CLPtjHqd.js';
@@ -0,0 +1,12 @@
1
+ import { File } from "../utils/index.d.ts";
2
+ declare class NetlifyBlobFile extends File {
3
+ /**
4
+ * The blob's public URL
5
+ */
6
+ url?: string;
7
+ /**
8
+ * The blob's pathname within the store
9
+ */
10
+ pathname?: string;
11
+ }
12
+ export default NetlifyBlobFile;
@@ -0,0 +1,7 @@
1
+ import type { LocalMetaStorageOptions } from "../local/local-meta-storage.d.ts";
2
+ import LocalMetaStorage from "../local/local-meta-storage.d.ts";
3
+ import type NetlifyBlobFile from "./netlify-blob-file.d.ts";
4
+ declare class NetlifyBlobMetaStorage extends LocalMetaStorage<NetlifyBlobFile> {
5
+ constructor(config?: LocalMetaStorageOptions);
6
+ }
7
+ export default NetlifyBlobMetaStorage;
@@ -0,0 +1,93 @@
1
+ import type MetaStorage from "../meta-storage.d.ts";
2
+ import { BaseStorage } from "../storage.d.ts";
3
+ import type { FileInit, FilePart, FileQuery, FileReturn } from "../utils/index.d.ts";
4
+ import NetlifyBlobFile from "./netlify-blob-file.d.ts";
5
+ import type { NetlifyBlobStorageOptions } from "./types.d.ts";
6
+ /**
7
+ * Netlify Blob storage based backend.
8
+ * @example
9
+ * ```ts
10
+ * const storage = new NetlifyBlobStorage({
11
+ * storeName: 'uploads',
12
+ * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
13
+ * });
14
+ * ```
15
+ * @remarks
16
+ * ## Supported Operations
17
+ * - ✅ create, write, delete, get, list, copy, move
18
+ * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage)
19
+ * - ✅ exists: Implemented (checks metadata and Netlify Blob)
20
+ * - ✅ update: Implemented (updates metadata file, Netlify Blob API doesn't support blob metadata updates)
21
+ * - ❌ getStream: Not implemented (use get() for file retrieval)
22
+ * - ❌ getUrl: Not implemented (Netlify Blob URLs available via Netlify Blob API)
23
+ * - ❌ getUploadUrl: Not implemented (Netlify Blob upload URLs handled internally)
24
+ */
25
+ declare class NetlifyBlobStorage extends BaseStorage<NetlifyBlobFile, FileReturn> {
26
+ static readonly name: string;
27
+ checksumTypes: string[];
28
+ protected meta: MetaStorage<NetlifyBlobFile>;
29
+ private readonly storeName;
30
+ private readonly siteID?;
31
+ private readonly token?;
32
+ private store;
33
+ private readonly retry;
34
+ constructor(config: NetlifyBlobStorageOptions);
35
+ create(config: FileInit): Promise<NetlifyBlobFile>;
36
+ write(part: FilePart | FileQuery | NetlifyBlobFile): Promise<NetlifyBlobFile>;
37
+ /**
38
+ * Deletes an upload and its metadata.
39
+ * @param query File query containing the file ID to delete.
40
+ * @param query.id File ID to delete.
41
+ * @returns Promise resolving to the deleted file object with status: "deleted".
42
+ * @throws {UploadError} If the file metadata cannot be found.
43
+ */
44
+ delete({ id }: FileQuery): Promise<NetlifyBlobFile>;
45
+ /**
46
+ * Checks if a file exists by verifying both metadata and the actual Netlify Blob.
47
+ * Returns true only if both the metadata and the blob exist.
48
+ * @param query File query containing the file ID to check.
49
+ * @returns Promise resolving to true if both metadata and blob exist, false otherwise.
50
+ */
51
+ exists({ id }: FileQuery): Promise<boolean>;
52
+ get({ id }: FileQuery): Promise<FileReturn>;
53
+ /**
54
+ * Copies an upload file to a new location.
55
+ * @param name Source file name/ID.
56
+ * @param destination Destination file name/ID.
57
+ * @returns Promise resolving to the copied file object.
58
+ * @throws {UploadError} If the source file cannot be found.
59
+ */
60
+ copy(name: string, destination: string): Promise<NetlifyBlobFile>;
61
+ /**
62
+ * Moves an upload file to a new location.
63
+ * @param name Source file name/ID.
64
+ * @param destination Destination file name/ID.
65
+ * @returns Promise resolving to the moved file object.
66
+ * @throws {UploadError} If the source file cannot be found.
67
+ */
68
+ move(name: string, destination: string): Promise<NetlifyBlobFile>;
69
+ /**
70
+ * Updates file metadata with user-provided key-value pairs.
71
+ * Updates the metadata file (overwrites it) but does not update Netlify Blob metadata
72
+ * since the Netlify Blob API doesn't support metadata updates.
73
+ * @param query File query containing the file ID to update.
74
+ * @param query.id File ID to update.
75
+ * @param metadata Partial file object containing fields to update.
76
+ * @returns Promise resolving to the updated file object.
77
+ * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND).
78
+ * @remarks
79
+ * Supports TTL (time-to-live) option: if metadata contains a 'ttl' field,
80
+ * it will be converted to an 'expiredAt' timestamp.
81
+ * TTL can be a number (milliseconds) or string (e.g., "1h", "30m", "7d").
82
+ */
83
+ update({ id }: FileQuery, metadata: Partial<NetlifyBlobFile>): Promise<NetlifyBlobFile>;
84
+ list(limit?: number): Promise<NetlifyBlobFile[]>;
85
+ private internalOnComplete;
86
+ /**
87
+ * Generate a URL for a blob in Netlify Blob store
88
+ * Note: Netlify Blob doesn't provide direct public URLs like Vercel Blob
89
+ * In production, you would typically serve these through Netlify Functions or Edge Functions
90
+ */
91
+ private getBlobUrl;
92
+ }
93
+ export default NetlifyBlobStorage;
@@ -0,0 +1,30 @@
1
+ import type { LocalMetaStorageOptions } from "../local/local-meta-storage.d.ts";
2
+ import type { BaseStorageOptions } from "../types.d.ts";
3
+ import type NetlifyBlobFile from "./netlify-blob-file.d.ts";
4
+ export interface NetlifyBlobStorageOptions extends BaseStorageOptions<NetlifyBlobFile> {
5
+ /**
6
+ * Configure metafiles storage
7
+ * @example
8
+ * Using local metafiles
9
+ * ```ts
10
+ * const storage = new NetlifyBlobStorage({
11
+ * storeName: 'uploads',
12
+ * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
13
+ * })
14
+ * ```
15
+ */
16
+ metaStorageConfig?: LocalMetaStorageOptions;
17
+ /**
18
+ * Netlify site ID (optional, used for explicit store access)
19
+ */
20
+ siteID?: string;
21
+ /**
22
+ * Netlify Blob store name
23
+ * @default 'default'
24
+ */
25
+ storeName?: string;
26
+ /**
27
+ * Netlify API token (optional, can use environment variable NETLIFY_TOKEN)
28
+ */
29
+ token?: string;
30
+ }