@visulima/storage 1.0.0-alpha.14 → 1.0.0-alpha.16

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 (144) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE.md +1094 -382
  3. package/dist/adapter/nuxt/module.d.ts +41 -34
  4. package/dist/handler/http/fetch/index.d.ts +297 -4
  5. package/dist/handler/http/hono/index.d.ts +1474 -58
  6. package/dist/handler/http/nextjs/index.d.ts +66 -58
  7. package/dist/handler/http/node/index.d.ts +361 -4
  8. package/dist/handler/http/solid-start/index.d.ts +66 -57
  9. package/dist/index.d.ts +376 -17
  10. package/dist/openapi/index.d.ts +24 -5
  11. package/dist/packem_shared/{GCSMetaStorage-BjdSXKri.js → GCSMetaStorage-CNXq7vGd.js} +1 -1
  12. package/dist/packem_shared/{GCStorage-D3JVWisH.js → GCStorage-CdnSuQwa.js} +1 -1
  13. package/dist/packem_shared/S3Client.d-CZ62Jztg.d.ts +20357 -0
  14. package/dist/packem_shared/disk-storage-with-checksum.d-hEoe2ugb.d.ts +148 -0
  15. package/dist/packem_shared/{gcs-meta-storage-C8rMsqR_.js → gcs-meta-storage-B5AVt1aS.js} +1 -1
  16. package/dist/packem_shared/local-meta-storage.d-Dop9RP9k.d.ts +20 -0
  17. package/dist/packem_shared/media-transformer.d-DeHZkBVx.d.ts +331 -0
  18. package/dist/packem_shared/s3-base-storage.d-CczjSe98.d.ts +251 -0
  19. package/dist/packem_shared/storage.d-BOMUJD96.d.ts +939 -0
  20. package/dist/packem_shared/tus-base.d-BftIixIA.d.ts +99 -0
  21. package/dist/packem_shared/types.d-BPd_JkW1.d.ts +708 -0
  22. package/dist/packem_shared/types.d-D-mlfmef.d.ts +49 -0
  23. package/dist/storage/aws/clients/index.d.ts +166 -6
  24. package/dist/storage/aws/index.d.ts +320 -4
  25. package/dist/storage/aws-light/index.d.ts +252 -4
  26. package/dist/storage/azure/index.d.ts +10422 -4
  27. package/dist/storage/gcs/index.d.ts +4107 -5
  28. package/dist/storage/gcs/index.js +2 -2
  29. package/dist/storage/local/index.d.ts +7 -4
  30. package/dist/storage/netlify-blob/index.d.ts +142 -4
  31. package/dist/storage/vercel-blob/index.d.ts +129 -4
  32. package/dist/transformer/audio-transformer.d.ts +127 -125
  33. package/dist/transformer/image-transformer.d.ts +569 -568
  34. package/dist/transformer/index.d.ts +62 -5
  35. package/dist/transformer/video-transformer.d.ts +144 -142
  36. package/package.json +38 -38
  37. package/dist/handler/base/base-handler-core.d.ts +0 -91
  38. package/dist/handler/base/base-handler-fetch.d.ts +0 -76
  39. package/dist/handler/base/base-handler-node.d.ts +0 -137
  40. package/dist/handler/multipart/multipart-base.d.ts +0 -84
  41. package/dist/handler/multipart/multipart-fetch.d.ts +0 -64
  42. package/dist/handler/multipart/multipart.d.ts +0 -49
  43. package/dist/handler/rest/rest-base.d.ts +0 -106
  44. package/dist/handler/rest/rest-fetch.d.ts +0 -88
  45. package/dist/handler/rest/rest.d.ts +0 -93
  46. package/dist/handler/tus/tus-base.d.ts +0 -152
  47. package/dist/handler/tus/tus-fetch.d.ts +0 -72
  48. package/dist/handler/tus/tus.d.ts +0 -78
  49. package/dist/handler/types.d.ts +0 -53
  50. package/dist/handler/utils/request-parser.d.ts +0 -72
  51. package/dist/handler/utils/response-builder.d.ts +0 -83
  52. package/dist/handler/utils/storage-utils.d.ts +0 -10
  53. package/dist/handler/utils/stream-utils.d.ts +0 -29
  54. package/dist/handler/utils/upload-handlers.d.ts +0 -76
  55. package/dist/metrics/index.d.ts +0 -2
  56. package/dist/metrics/no-op-metrics.d.ts +0 -15
  57. package/dist/metrics/opentelemetry-metrics.d.ts +0 -55
  58. package/dist/openapi/rest.d.ts +0 -7
  59. package/dist/openapi/shared.d.ts +0 -13
  60. package/dist/openapi/transform.d.ts +0 -3
  61. package/dist/openapi/tus.d.ts +0 -7
  62. package/dist/openapi/xhr.d.ts +0 -7
  63. package/dist/storage/aws/clients/backblaze.d.ts +0 -12
  64. package/dist/storage/aws/clients/cloudflare.d.ts +0 -13
  65. package/dist/storage/aws/clients/digital-ocean.d.ts +0 -12
  66. package/dist/storage/aws/clients/minio.d.ts +0 -13
  67. package/dist/storage/aws/clients/tigris.d.ts +0 -12
  68. package/dist/storage/aws/clients/types.d.ts +0 -95
  69. package/dist/storage/aws/clients/wasabi.d.ts +0 -12
  70. package/dist/storage/aws/s3-base-storage.d.ts +0 -248
  71. package/dist/storage/aws/s3-client-adapter.d.ts +0 -110
  72. package/dist/storage/aws/s3-file.d.ts +0 -10
  73. package/dist/storage/aws/s3-meta-storage.d.ts +0 -15
  74. package/dist/storage/aws/s3-storage.d.ts +0 -70
  75. package/dist/storage/aws/types.d.ts +0 -118
  76. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +0 -130
  77. package/dist/storage/aws-light/aws-light-file.d.ts +0 -10
  78. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +0 -19
  79. package/dist/storage/aws-light/aws-light-storage.d.ts +0 -66
  80. package/dist/storage/aws-light/types.d.ts +0 -36
  81. package/dist/storage/azure/azure-file.d.ts +0 -6
  82. package/dist/storage/azure/azure-meta-storage.d.ts +0 -15
  83. package/dist/storage/azure/azure-storage.d.ts +0 -69
  84. package/dist/storage/azure/types.d.ts +0 -61
  85. package/dist/storage/gcs/fetch-error.d.ts +0 -11
  86. package/dist/storage/gcs/gcs-config.d.ts +0 -2
  87. package/dist/storage/gcs/gcs-file.d.ts +0 -6
  88. package/dist/storage/gcs/gcs-meta-storage.d.ts +0 -27
  89. package/dist/storage/gcs/gcs-storage.d.ts +0 -91
  90. package/dist/storage/gcs/types.d.ts +0 -54
  91. package/dist/storage/gcs/utils.d.ts +0 -7
  92. package/dist/storage/local/disk-storage-with-checksum.d.ts +0 -15
  93. package/dist/storage/local/disk-storage.d.ts +0 -135
  94. package/dist/storage/local/local-meta-storage.d.ts +0 -27
  95. package/dist/storage/meta-storage-options.d.ts +0 -11
  96. package/dist/storage/meta-storage.d.ts +0 -30
  97. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +0 -12
  98. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +0 -6
  99. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +0 -93
  100. package/dist/storage/netlify-blob/types.d.ts +0 -29
  101. package/dist/storage/storage.d.ts +0 -353
  102. package/dist/storage/types.d.ts +0 -217
  103. package/dist/storage/utils/file/file.d.ts +0 -25
  104. package/dist/storage/utils/file/get-file-status.d.ts +0 -9
  105. package/dist/storage/utils/file/has-content.d.ts +0 -9
  106. package/dist/storage/utils/file/index.d.ts +0 -10
  107. package/dist/storage/utils/file/is-expired.d.ts +0 -8
  108. package/dist/storage/utils/file/metadata.d.ts +0 -18
  109. package/dist/storage/utils/file/part-match.d.ts +0 -11
  110. package/dist/storage/utils/file/types.d.ts +0 -37
  111. package/dist/storage/utils/file/update-metadata.d.ts +0 -10
  112. package/dist/storage/utils/file/update-size.d.ts +0 -10
  113. package/dist/storage/vercel-blob/types.d.ts +0 -31
  114. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +0 -16
  115. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +0 -6
  116. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +0 -76
  117. package/dist/transformer/base-transformer.d.ts +0 -63
  118. package/dist/transformer/media-transformer.d.ts +0 -332
  119. package/dist/transformer/transformer-config.d.ts +0 -16
  120. package/dist/transformer/types.d.ts +0 -639
  121. package/dist/transformer/utils.d.ts +0 -33
  122. package/dist/transformer/validation-error.d.ts +0 -23
  123. package/dist/utils/cache.d.ts +0 -32
  124. package/dist/utils/chunked-upload.d.ts +0 -65
  125. package/dist/utils/detect-file-type.d.ts +0 -28
  126. package/dist/utils/errors.d.ts +0 -74
  127. package/dist/utils/file-path-url-matcher.d.ts +0 -18
  128. package/dist/utils/headers.d.ts +0 -111
  129. package/dist/utils/http.d.ts +0 -92
  130. package/dist/utils/locker.d.ts +0 -26
  131. package/dist/utils/pipes/stream-checksum.d.ts +0 -47
  132. package/dist/utils/pipes/stream-length.d.ts +0 -22
  133. package/dist/utils/primitives/get-last-one.d.ts +0 -3
  134. package/dist/utils/primitives/is-record.d.ts +0 -2
  135. package/dist/utils/primitives/map-values.d.ts +0 -9
  136. package/dist/utils/primitives/pick.d.ts +0 -2
  137. package/dist/utils/primitives/to-milliseconds.d.ts +0 -12
  138. package/dist/utils/primitives/to-seconds.d.ts +0 -12
  139. package/dist/utils/range-checksum.d.ts +0 -33
  140. package/dist/utils/range-hasher.d.ts +0 -46
  141. package/dist/utils/retry.d.ts +0 -64
  142. package/dist/utils/types.d.ts +0 -108
  143. package/dist/utils/validation-error.d.ts +0 -22
  144. package/dist/utils/validator.d.ts +0 -36
@@ -1,91 +0,0 @@
1
- import type { HttpError } from "../../utils/types.d.ts";
2
- import type MetaStorage from "../meta-storage.d.ts";
3
- import { BaseStorage } from "../storage.d.ts";
4
- import type { FileInit, FilePart, FileQuery, FileReturn } from "../utils/index.d.ts";
5
- import GCSFile from "./gcs-file.d.ts";
6
- import type { ClientError, GCStorageOptions } from "./types.d.ts";
7
- /**
8
- * Google cloud storage based backend.
9
- * @example
10
- * ```ts
11
- * const storage = new GCStorage({
12
- * bucket: <YOUR_BUCKET>,
13
- * keyFile: <PATH_TO_KEY_FILE>,
14
- * metaStorage: new MetaStorage(),
15
- * clientDirectUpload: true,
16
- * maxUploadSize: '15GB',
17
- * allowMIME: ['video/*', 'image/*'],
18
- * filename: file => file.originalName
19
- * });
20
- * ```
21
- * @remarks
22
- * ## Supported Operations
23
- * - ✅ create, write, delete, get, list, update, copy, move
24
- * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage)
25
- * - ✅ exists: Implemented (checks metadata and GCS object)
26
- * - ❌ getStream: Not implemented (use get() for file retrieval)
27
- * - ❌ getUrl: Not implemented (GCS public URLs not supported)
28
- * - ❌ getUploadUrl: Not implemented (resumable upload URLs handled internally)
29
- */
30
- declare class GCStorage extends BaseStorage {
31
- static readonly name: string;
32
- checksumTypes: string[];
33
- protected meta: MetaStorage;
34
- private readonly bucket;
35
- private authClient;
36
- private readonly storageBaseURI;
37
- private readonly uploadBaseURI;
38
- private readonly isCustomEndpoint;
39
- private readonly retryOptions;
40
- private readonly useAuthWithCustomEndpoint;
41
- private readonly userProject;
42
- constructor(config: GCStorageOptions);
43
- normalizeError(error: ClientError): HttpError;
44
- create(config: FileInit): Promise<GCSFile>;
45
- write(part: FilePart | FileQuery | GCSFile): Promise<GCSFile>;
46
- /**
47
- * Deletes an upload and its metadata.
48
- * @param query File query containing the file ID to delete.
49
- * @param query.id File ID to delete.
50
- * @returns Promise resolving to the deleted file object with status: "deleted".
51
- * @throws {UploadError} If the file metadata cannot be found.
52
- */
53
- delete({ id }: FileQuery): Promise<GCSFile>;
54
- /**
55
- * Copies an upload file to a new location.
56
- * @param name Source file name/ID.
57
- * @param destination Destination file name/ID.
58
- * @returns Promise resolving to the copied file object.
59
- * @throws {UploadError} If the source file cannot be found.
60
- */
61
- copy(name: string, destination: string): Promise<GCSFile>;
62
- /**
63
- * Moves an upload file to a new location.
64
- * @param name Source file name/ID.
65
- * @param destination Destination file name/ID.
66
- * @returns Promise resolving to the moved file object.
67
- * @throws {UploadError} If the source file cannot be found.
68
- */
69
- move(name: string, destination: string): Promise<GCSFile>;
70
- /**
71
- * Gets an uploaded file by ID with content buffer.
72
- * @param query File query object containing the file ID.
73
- * @param query.id Unique identifier of the file to retrieve.
74
- * @returns Promise resolving to file object with content buffer.
75
- * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE).
76
- */
77
- get({ id }: FileQuery): Promise<FileReturn>;
78
- /**
79
- * Checks if a file exists by verifying both metadata and the actual GCS object.
80
- * Returns true only if both the metadata and the GCS object exist.
81
- * @param query File query containing the file ID to check.
82
- * @returns Promise resolving to true if both metadata and GCS object exist, false otherwise.
83
- */
84
- exists({ id }: FileQuery): Promise<boolean>;
85
- list(limit?: number): Promise<GCSFile[]>;
86
- protected internalWrite(part: GCSFile & Partial<FilePart>): Promise<number>;
87
- private internalOnComplete;
88
- private makeRequest;
89
- private accessCheck;
90
- }
91
- export default GCStorage;
@@ -1,54 +0,0 @@
1
- import type { RetryConfig } from "gaxios";
2
- import type { GoogleAuth, GoogleAuthOptions } from "google-auth-library";
3
- import type { LocalMetaStorageOptions } from "../local/local-meta-storage.d.ts";
4
- import type { BaseStorageOptions, MetaStorageOptions } from "../types.d.ts";
5
- interface StorageSettings {
6
- projectId: string;
7
- retryOptions?: RetryConfig;
8
- storageAPI?: string;
9
- uploadAPI?: string;
10
- useAuthWithCustomEndpoint?: boolean;
11
- userProject?: string;
12
- }
13
- export interface ClientError extends Error {
14
- code: string;
15
- config: Record<string, unknown>;
16
- response?: Record<string, unknown>;
17
- }
18
- export interface GCStorageOptions extends BaseStorageOptions, Omit<GoogleAuthOptions, "authClient" | "projectId">, StorageSettings {
19
- /**
20
- * Google Cloud Storage bucket
21
- */
22
- bucket?: string;
23
- /**
24
- * Force compatible client upload directly to GCS
25
- */
26
- clientDirectUpload?: boolean;
27
- /**
28
- * Configure metafiles storage
29
- * @example
30
- * ```ts
31
- * Using local metafiles
32
- * const storage = new GCStorage({
33
- * bucket: 'upload',
34
- * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
35
- * })
36
- * ```
37
- * Using a separate bucket for metafiles
38
- * ```ts
39
- * const storage = new GCStorage({
40
- * bucket: 'upload',
41
- * metaStorageConfig: { bucket: 'upload-metafiles' }
42
- * })
43
- * ```
44
- */
45
- metaStorageConfig?: GCSMetaStorageOptions | LocalMetaStorageOptions;
46
- }
47
- export interface GCSMetaStorageOptions extends MetaStorageOptions, Omit<GoogleAuthOptions, "authClient" | "projectId">, StorageSettings {
48
- /**
49
- * @internal
50
- */
51
- authClient?: GoogleAuth;
52
- bucket?: string;
53
- }
54
- export {};
@@ -1,7 +0,0 @@
1
- import type { GaxiosError, RetryConfig } from "gaxios";
2
- import type { FilePart } from "../utils/index.d.ts";
3
- import type GCSFile from "./gcs-file.d.ts";
4
- export declare const getRangeEnd: (range: string) => number;
5
- export declare const buildContentRange: (part: GCSFile & Partial<FilePart>) => string;
6
- export declare const shouldRetry: (error: GaxiosError) => boolean;
7
- export declare const retryOptions: RetryConfig;
@@ -1,15 +0,0 @@
1
- import { ERRORS } from "../../utils/errors.d.ts";
2
- import type { DiskStorageWithChecksumOptions } from "../types.d.ts";
3
- import type { File, FilePart, FileQuery } from "../utils/index.d.ts";
4
- import DiskStorage from "./disk-storage.d.ts";
5
- /**
6
- * Additionally calculates checksum of the file/range.
7
- */
8
- declare class DiskStorageWithChecksum<TFile extends File = File> extends DiskStorage<TFile> {
9
- private hashes;
10
- constructor(config: DiskStorageWithChecksumOptions<TFile>);
11
- delete({ id }: FileQuery): Promise<TFile>;
12
- write(part: FilePart | FileQuery): Promise<TFile>;
13
- protected lazyWrite(part: File & FilePart): Promise<[number, ERRORS?]>;
14
- }
15
- export default DiskStorageWithChecksum;
@@ -1,135 +0,0 @@
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> {
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;
@@ -1,27 +0,0 @@
1
- import MetaStorage from "../meta-storage.d.ts";
2
- import type { LocalMetaStorageOptions } from "../meta-storage-options.d.ts";
3
- import type { File } from "../utils/index.d.ts";
4
- export type { LocalMetaStorageOptions } from "../meta-storage-options.d.ts";
5
- /**
6
- * Stores upload metafiles on local disk
7
- */
8
- declare class LocalMetaStorage<T extends File = File> extends MetaStorage<T> {
9
- readonly directory: string;
10
- constructor(config?: LocalMetaStorageOptions);
11
- /**
12
- * Returns metafile path.
13
- * @param id upload id
14
- */
15
- getMetaPath: (id: string) => string;
16
- /**
17
- * Returns upload id from metafile path.
18
- * @internal
19
- */
20
- getIdFromPath: (metaFilePath: string) => string;
21
- save(id: string, file: T): Promise<T>;
22
- touch(id: string, file: T): Promise<T>;
23
- get(id: string): Promise<T>;
24
- delete(id: string): Promise<void>;
25
- private accessCheck;
26
- }
27
- export default LocalMetaStorage;
@@ -1,11 +0,0 @@
1
- export interface MetaStorageOptions {
2
- logger?: Console;
3
- prefix?: string;
4
- suffix?: string;
5
- }
6
- export interface LocalMetaStorageOptions extends MetaStorageOptions {
7
- /**
8
- * Where the upload metadata should be stored
9
- */
10
- directory?: string;
11
- }
@@ -1,30 +0,0 @@
1
- import type { MetaStorageOptions } from "./meta-storage-options.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;
@@ -1,12 +0,0 @@
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;
@@ -1,6 +0,0 @@
1
- import type { LocalMetaStorageOptions } from "../local/local-meta-storage.d.ts";
2
- import LocalMetaStorage from "../local/local-meta-storage.d.ts";
3
- declare class NetlifyBlobMetaStorage extends LocalMetaStorage {
4
- constructor(config?: LocalMetaStorageOptions);
5
- }
6
- export default NetlifyBlobMetaStorage;
@@ -1,93 +0,0 @@
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 {
26
- static readonly name: string;
27
- checksumTypes: string[];
28
- protected meta: MetaStorage;
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;
@@ -1,29 +0,0 @@
1
- import type { LocalMetaStorageOptions } from "../local/local-meta-storage.d.ts";
2
- import type { BaseStorageOptions } from "../types.d.ts";
3
- export interface NetlifyBlobStorageOptions extends BaseStorageOptions {
4
- /**
5
- * Configure metafiles storage
6
- * @example
7
- * Using local metafiles
8
- * ```ts
9
- * const storage = new NetlifyBlobStorage({
10
- * storeName: 'uploads',
11
- * metaStorageConfig: { directory: '/tmp/upload-metafiles' }
12
- * })
13
- * ```
14
- */
15
- metaStorageConfig?: LocalMetaStorageOptions;
16
- /**
17
- * Netlify site ID (optional, used for explicit store access)
18
- */
19
- siteID?: string;
20
- /**
21
- * Netlify Blob store name
22
- * @default 'default'
23
- */
24
- storeName?: string;
25
- /**
26
- * Netlify API token (optional, can use environment variable NETLIFY_TOKEN)
27
- */
28
- token?: string;
29
- }