@visulima/storage 1.0.0-alpha.15 → 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.
- package/CHANGELOG.md +11 -0
- package/LICENSE.md +1094 -382
- package/dist/adapter/nuxt/module.d.ts +41 -34
- package/dist/handler/http/fetch/index.d.ts +297 -4
- package/dist/handler/http/hono/index.d.ts +1474 -58
- package/dist/handler/http/nextjs/index.d.ts +66 -58
- package/dist/handler/http/node/index.d.ts +361 -4
- package/dist/handler/http/solid-start/index.d.ts +66 -57
- package/dist/index.d.ts +376 -17
- package/dist/openapi/index.d.ts +24 -5
- package/dist/packem_shared/{GCSMetaStorage-BkUIdJ5m.js → GCSMetaStorage-CNXq7vGd.js} +1 -1
- package/dist/packem_shared/{GCStorage-BnsSAjdW.js → GCStorage-CdnSuQwa.js} +1 -1
- package/dist/packem_shared/S3Client.d-CZ62Jztg.d.ts +20357 -0
- package/dist/packem_shared/disk-storage-with-checksum.d-hEoe2ugb.d.ts +148 -0
- package/dist/packem_shared/{gcs-meta-storage-DBeGn2ix.js → gcs-meta-storage-B5AVt1aS.js} +1 -1
- package/dist/packem_shared/local-meta-storage.d-Dop9RP9k.d.ts +20 -0
- package/dist/packem_shared/media-transformer.d-DeHZkBVx.d.ts +331 -0
- package/dist/packem_shared/s3-base-storage.d-CczjSe98.d.ts +251 -0
- package/dist/packem_shared/storage.d-BOMUJD96.d.ts +939 -0
- package/dist/packem_shared/tus-base.d-BftIixIA.d.ts +99 -0
- package/dist/packem_shared/types.d-BPd_JkW1.d.ts +708 -0
- package/dist/packem_shared/types.d-D-mlfmef.d.ts +49 -0
- package/dist/storage/aws/clients/index.d.ts +166 -6
- package/dist/storage/aws/index.d.ts +320 -4
- package/dist/storage/aws-light/index.d.ts +252 -4
- package/dist/storage/azure/index.d.ts +10422 -4
- package/dist/storage/gcs/index.d.ts +4107 -5
- package/dist/storage/gcs/index.js +2 -2
- package/dist/storage/local/index.d.ts +7 -4
- package/dist/storage/netlify-blob/index.d.ts +142 -4
- package/dist/storage/vercel-blob/index.d.ts +129 -4
- package/dist/transformer/audio-transformer.d.ts +127 -125
- package/dist/transformer/image-transformer.d.ts +569 -568
- package/dist/transformer/index.d.ts +62 -5
- package/dist/transformer/video-transformer.d.ts +144 -142
- package/package.json +37 -37
- package/dist/handler/base/base-handler-core.d.ts +0 -91
- package/dist/handler/base/base-handler-fetch.d.ts +0 -76
- package/dist/handler/base/base-handler-node.d.ts +0 -137
- package/dist/handler/multipart/multipart-base.d.ts +0 -84
- package/dist/handler/multipart/multipart-fetch.d.ts +0 -64
- package/dist/handler/multipart/multipart.d.ts +0 -49
- package/dist/handler/rest/rest-base.d.ts +0 -106
- package/dist/handler/rest/rest-fetch.d.ts +0 -88
- package/dist/handler/rest/rest.d.ts +0 -93
- package/dist/handler/tus/tus-base.d.ts +0 -152
- package/dist/handler/tus/tus-fetch.d.ts +0 -72
- package/dist/handler/tus/tus.d.ts +0 -78
- package/dist/handler/types.d.ts +0 -53
- package/dist/handler/utils/request-parser.d.ts +0 -72
- package/dist/handler/utils/response-builder.d.ts +0 -83
- package/dist/handler/utils/storage-utils.d.ts +0 -10
- package/dist/handler/utils/stream-utils.d.ts +0 -29
- package/dist/handler/utils/upload-handlers.d.ts +0 -76
- package/dist/metrics/index.d.ts +0 -2
- package/dist/metrics/no-op-metrics.d.ts +0 -15
- package/dist/metrics/opentelemetry-metrics.d.ts +0 -55
- package/dist/openapi/rest.d.ts +0 -7
- package/dist/openapi/shared.d.ts +0 -13
- package/dist/openapi/transform.d.ts +0 -3
- package/dist/openapi/tus.d.ts +0 -7
- package/dist/openapi/xhr.d.ts +0 -7
- package/dist/storage/aws/clients/backblaze.d.ts +0 -12
- package/dist/storage/aws/clients/cloudflare.d.ts +0 -13
- package/dist/storage/aws/clients/digital-ocean.d.ts +0 -12
- package/dist/storage/aws/clients/minio.d.ts +0 -13
- package/dist/storage/aws/clients/tigris.d.ts +0 -12
- package/dist/storage/aws/clients/types.d.ts +0 -95
- package/dist/storage/aws/clients/wasabi.d.ts +0 -12
- package/dist/storage/aws/s3-base-storage.d.ts +0 -248
- package/dist/storage/aws/s3-client-adapter.d.ts +0 -110
- package/dist/storage/aws/s3-file.d.ts +0 -10
- package/dist/storage/aws/s3-meta-storage.d.ts +0 -15
- package/dist/storage/aws/s3-storage.d.ts +0 -70
- package/dist/storage/aws/types.d.ts +0 -118
- package/dist/storage/aws-light/aws-light-api-adapter.d.ts +0 -130
- package/dist/storage/aws-light/aws-light-file.d.ts +0 -10
- package/dist/storage/aws-light/aws-light-meta-storage.d.ts +0 -19
- package/dist/storage/aws-light/aws-light-storage.d.ts +0 -66
- package/dist/storage/aws-light/types.d.ts +0 -36
- package/dist/storage/azure/azure-file.d.ts +0 -6
- package/dist/storage/azure/azure-meta-storage.d.ts +0 -15
- package/dist/storage/azure/azure-storage.d.ts +0 -69
- package/dist/storage/azure/types.d.ts +0 -61
- package/dist/storage/gcs/fetch-error.d.ts +0 -11
- package/dist/storage/gcs/gcs-config.d.ts +0 -2
- package/dist/storage/gcs/gcs-file.d.ts +0 -6
- package/dist/storage/gcs/gcs-meta-storage.d.ts +0 -27
- package/dist/storage/gcs/gcs-storage.d.ts +0 -91
- package/dist/storage/gcs/types.d.ts +0 -54
- package/dist/storage/gcs/utils.d.ts +0 -7
- package/dist/storage/local/disk-storage-with-checksum.d.ts +0 -15
- package/dist/storage/local/disk-storage.d.ts +0 -135
- package/dist/storage/local/local-meta-storage.d.ts +0 -27
- package/dist/storage/meta-storage-options.d.ts +0 -11
- package/dist/storage/meta-storage.d.ts +0 -30
- package/dist/storage/netlify-blob/netlify-blob-file.d.ts +0 -12
- package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +0 -6
- package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +0 -93
- package/dist/storage/netlify-blob/types.d.ts +0 -29
- package/dist/storage/storage.d.ts +0 -353
- package/dist/storage/types.d.ts +0 -217
- package/dist/storage/utils/file/file.d.ts +0 -25
- package/dist/storage/utils/file/get-file-status.d.ts +0 -9
- package/dist/storage/utils/file/has-content.d.ts +0 -9
- package/dist/storage/utils/file/index.d.ts +0 -10
- package/dist/storage/utils/file/is-expired.d.ts +0 -8
- package/dist/storage/utils/file/metadata.d.ts +0 -18
- package/dist/storage/utils/file/part-match.d.ts +0 -11
- package/dist/storage/utils/file/types.d.ts +0 -37
- package/dist/storage/utils/file/update-metadata.d.ts +0 -10
- package/dist/storage/utils/file/update-size.d.ts +0 -10
- package/dist/storage/vercel-blob/types.d.ts +0 -31
- package/dist/storage/vercel-blob/vercel-blob-file.d.ts +0 -16
- package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +0 -6
- package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +0 -76
- package/dist/transformer/base-transformer.d.ts +0 -63
- package/dist/transformer/media-transformer.d.ts +0 -332
- package/dist/transformer/transformer-config.d.ts +0 -16
- package/dist/transformer/types.d.ts +0 -639
- package/dist/transformer/utils.d.ts +0 -33
- package/dist/transformer/validation-error.d.ts +0 -23
- package/dist/utils/cache.d.ts +0 -32
- package/dist/utils/chunked-upload.d.ts +0 -65
- package/dist/utils/detect-file-type.d.ts +0 -28
- package/dist/utils/errors.d.ts +0 -74
- package/dist/utils/file-path-url-matcher.d.ts +0 -18
- package/dist/utils/headers.d.ts +0 -111
- package/dist/utils/http.d.ts +0 -92
- package/dist/utils/locker.d.ts +0 -26
- package/dist/utils/pipes/stream-checksum.d.ts +0 -47
- package/dist/utils/pipes/stream-length.d.ts +0 -22
- package/dist/utils/primitives/get-last-one.d.ts +0 -3
- package/dist/utils/primitives/is-record.d.ts +0 -2
- package/dist/utils/primitives/map-values.d.ts +0 -9
- package/dist/utils/primitives/pick.d.ts +0 -2
- package/dist/utils/primitives/to-milliseconds.d.ts +0 -12
- package/dist/utils/primitives/to-seconds.d.ts +0 -12
- package/dist/utils/range-checksum.d.ts +0 -33
- package/dist/utils/range-hasher.d.ts +0 -46
- package/dist/utils/retry.d.ts +0 -64
- package/dist/utils/types.d.ts +0 -108
- package/dist/utils/validation-error.d.ts +0 -22
- 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,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
|
-
}
|