@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.
- package/CHANGELOG.md +25 -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-BjdSXKri.js → GCSMetaStorage-CNXq7vGd.js} +1 -1
- package/dist/packem_shared/{GCStorage-D3JVWisH.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-C8rMsqR_.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 +38 -38
- 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,5 +1,62 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export { type c as AudioChannelMixOptions, type b as AudioResampleOptions, type d as AudioTransformOptions, type a as AudioTransformResult, type e as AudioTransformationStep, type A as AudioTransformerConfig, B as BaseTransformer, type C as CropOptions, type g as ImageFormat, type I as ImageTransformerConfig, type U as MediaTransformQuery, type Q as MediaTransformResult, type W as MediaTransformationStep, type O as MediaTransformerConfig, type R as ResizeOptions, type f as RotateOptions, type h as TransformOptions, type T as TransformResult, type x as TransformationStep, type F as VideoCropOptions, type z as VideoResizeOptions, type H as VideoRotateOptions, type K as VideoTransformOptions, type y as VideoTransformResult, type N as VideoTransformationStep, type V as VideoTransformerConfig } from "../packem_shared/types.d-BPd_JkW1.js";
|
|
2
|
+
export { M as MediaTransformer } from "../packem_shared/media-transformer.d-DeHZkBVx.js";
|
|
3
|
+
import { a as FileReturn } from "../packem_shared/storage.d-BOMUJD96.js";
|
|
4
|
+
import 'node:stream';
|
|
5
|
+
import 'node:crypto';
|
|
6
|
+
import 'node:http';
|
|
7
|
+
import 'lru-cache';
|
|
8
|
+
/**
|
|
9
|
+
* Check if a content type is valid for a specific media type.
|
|
10
|
+
* @param contentType MIME content type string to validate
|
|
11
|
+
* @param expectedType Expected media type ('image', 'video', or 'audio')
|
|
12
|
+
* @returns True if the content type is valid for the expected media type
|
|
13
|
+
*/
|
|
14
|
+
declare const isValidMediaType: (contentType: string | undefined, expectedType: "image" | "video" | "audio") => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Get format (extension) from content type using mime package.
|
|
17
|
+
* @param contentType MIME content type string to extract format from
|
|
18
|
+
* @returns Format string or undefined if not found
|
|
19
|
+
*/
|
|
20
|
+
declare const getFormatFromContentType: (contentType: string | undefined) => string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Validate a media file for a specific type with size and format checks.
|
|
23
|
+
* @param file File to validate
|
|
24
|
+
* @param expectedType Expected media type ('image', 'video', or 'audio')
|
|
25
|
+
* @param config Validation configuration with optional maxSize and supportedFormats
|
|
26
|
+
* @param config.maxSize Maximum allowed file size in bytes
|
|
27
|
+
* @param config.supportedFormats Array of supported file formats
|
|
28
|
+
* @throws Error if validation fails (size exceeded, wrong type, or unsupported format)
|
|
29
|
+
*/
|
|
30
|
+
declare const validateMediaFile: (file: FileReturn, expectedType: "image" | "video" | "audio", config?: {
|
|
31
|
+
maxSize?: number;
|
|
32
|
+
supportedFormats?: string[];
|
|
33
|
+
}) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Validate that a content type is known and supported by the mime package.
|
|
36
|
+
* @param contentType MIME content type string to check
|
|
37
|
+
* @returns True if the content type is known and has a registered extension
|
|
38
|
+
*/
|
|
39
|
+
declare const isKnownContentType: (contentType: string | undefined) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Custom error class for validation failures
|
|
42
|
+
*/
|
|
43
|
+
declare class ValidationError extends Error {
|
|
44
|
+
readonly code: string;
|
|
45
|
+
readonly details: {
|
|
46
|
+
invalidParams: string[];
|
|
47
|
+
mediaType: string;
|
|
48
|
+
suggestions?: string[];
|
|
49
|
+
validParams: string[];
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new ValidationError instance with detailed error information.
|
|
53
|
+
* @param message Human-readable error message describing the validation failure
|
|
54
|
+
* @param code Machine-readable error code for programmatic error handling
|
|
55
|
+
* @param mediaType The media type where validation failed ('image', 'video', or 'audio')
|
|
56
|
+
* @param invalidParameters Array of parameter names that were invalid
|
|
57
|
+
* @param validParameters Array of valid parameter names or values
|
|
58
|
+
* @param suggestions Optional array of suggested corrections or valid values
|
|
59
|
+
*/
|
|
60
|
+
constructor(message: string, code: string, mediaType: string, invalidParameters: string[], validParameters: string[], suggestions?: string[]);
|
|
61
|
+
}
|
|
62
|
+
export { ValidationError, getFormatFromContentType, isKnownContentType, isValidMediaType, validateMediaFile };
|
|
@@ -1,145 +1,147 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { F as File, a as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-BOMUJD96.js";
|
|
2
|
+
import { V as VideoTransformerConfig, y as VideoTransformResult, z as VideoResizeOptions, F as VideoCropOptions, H as VideoRotateOptions, K as VideoTransformOptions, N as VideoTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-BPd_JkW1.js";
|
|
3
|
+
import 'node:stream';
|
|
4
|
+
import 'node:crypto';
|
|
5
|
+
import 'node:http';
|
|
6
|
+
import 'lru-cache';
|
|
5
7
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
8
|
+
* Video transformer that uses storage backends and Mediabunny library to retrieve and transform videos.
|
|
9
|
+
* @template TFile The file type used by this transformer.
|
|
10
|
+
* @template TFileReturn The return type for file retrieval operations.
|
|
11
|
+
*
|
|
12
|
+
* Supports video transformations with query parameters for on-demand video processing.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const transformer = new VideoTransformer(storage, {
|
|
16
|
+
* maxVideoSize: 100 * 1024 * 1024, // 100MB
|
|
17
|
+
* cache: new Map()
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Programmatic usage - resize a video
|
|
21
|
+
* const result = await transformer.resize('video-id', {
|
|
22
|
+
* width: 1920,
|
|
23
|
+
* height: 1080,
|
|
24
|
+
* fit: 'contain'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // URL-based transformations
|
|
28
|
+
* // GET /files/video-id?width=1280&height=720&fit=cover&bitrate=2000000
|
|
29
|
+
* // GET /files/video-id?codec=vp9&bitrate=1000000
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ## Supported Query Parameters
|
|
33
|
+
*
|
|
34
|
+
* - `width`: Width in pixels (Number)
|
|
35
|
+
* - `height`: Height in pixels (Number)
|
|
36
|
+
* - `fit`: Resize fit mode - cover/contain/fill/inside/outside
|
|
37
|
+
* - `codec`: Video codec - avc/hevc/vp8/vp9/av1
|
|
38
|
+
* - `bitrate`: Video bitrate in bits per second (Number)
|
|
39
|
+
* - `frameRate`: Frame rate in Hz (Number)
|
|
40
|
+
* - `format`: Output format - mp4/webm/mkv/ogg
|
|
41
|
+
*/
|
|
40
42
|
declare class VideoTransformer<TFile extends File = File, TFileReturn extends FileReturn = FileReturn> extends BaseTransformer<VideoTransformerConfig, VideoTransformResult<TFileReturn>, TFile, TFileReturn> {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new VideoTransformer instance.
|
|
45
|
+
* @param storage The storage backend for retrieving and storing video files.
|
|
46
|
+
* @param config Configuration options for video transformation including cache settings, codec defaults, and size limits.
|
|
47
|
+
*/
|
|
48
|
+
constructor(storage: BaseStorage<TFile, TFileReturn>, config?: VideoTransformerConfig);
|
|
49
|
+
/**
|
|
50
|
+
* Resizes a video to specified dimensions with optional fit mode.
|
|
51
|
+
* @param fileId Unique identifier of the video file to resize.
|
|
52
|
+
* @param options Resize options including width, height, and fit mode.
|
|
53
|
+
* @returns Promise resolving to transformed video result.
|
|
54
|
+
*/
|
|
55
|
+
resize(fileId: string, options: VideoResizeOptions): Promise<VideoTransformResult<TFileReturn>>;
|
|
56
|
+
/**
|
|
57
|
+
* Crops a video to the specified region.
|
|
58
|
+
* @param fileId Unique identifier of the video file to crop.
|
|
59
|
+
* @param options Crop options including region coordinates.
|
|
60
|
+
* @returns Promise resolving to transformed video result.
|
|
61
|
+
*/
|
|
62
|
+
crop(fileId: string, options: VideoCropOptions): Promise<VideoTransformResult<TFileReturn>>;
|
|
63
|
+
/**
|
|
64
|
+
* Rotates a video by the specified angle.
|
|
65
|
+
* @param fileId Unique identifier of the video file to rotate.
|
|
66
|
+
* @param options Rotation configuration with angle in degrees and optional background color.
|
|
67
|
+
* @returns Promise resolving to transformed video result.
|
|
68
|
+
*/
|
|
69
|
+
rotate(fileId: string, options: VideoRotateOptions): Promise<VideoTransformResult<TFileReturn>>;
|
|
70
|
+
/**
|
|
71
|
+
* Converts video format or codec.
|
|
72
|
+
* @param fileId Unique identifier of the video file to convert.
|
|
73
|
+
* @param format Target video format (e.g., "mp4", "webm", "mkv").
|
|
74
|
+
* @param options Video transformation options including quality, bitrate, and codec settings.
|
|
75
|
+
* @returns Promise resolving to transformed video result with updated format metadata.
|
|
76
|
+
*/
|
|
77
|
+
convertFormat(fileId: string, format: string, options?: VideoTransformOptions): Promise<VideoTransformResult<TFileReturn>>;
|
|
78
|
+
/**
|
|
79
|
+
* Transcodes video to different codec.
|
|
80
|
+
* @param fileId Unique identifier of the video file to transcode.
|
|
81
|
+
* @param codec Target video codec (e.g., "avc", "hevc", "vp9").
|
|
82
|
+
* @param options Additional transform options.
|
|
83
|
+
* @returns Promise resolving to transformed video result.
|
|
84
|
+
*/
|
|
85
|
+
transcode(fileId: string, codec: VideoTransformOptions["codec"], options?: Omit<VideoTransformOptions, "codec">): Promise<VideoTransformResult<TFileReturn>>;
|
|
86
|
+
/**
|
|
87
|
+
* Applies a custom transformation pipeline to a video.
|
|
88
|
+
* @param fileId Unique identifier of the video file to transform.
|
|
89
|
+
* @param steps Array of transformation steps to apply in sequence.
|
|
90
|
+
* @returns Promise resolving to transformed video result.
|
|
91
|
+
*/
|
|
92
|
+
transform(fileId: string, steps: VideoTransformationStep[]): Promise<VideoTransformResult<TFileReturn>>;
|
|
93
|
+
/**
|
|
94
|
+
* Applies multiple transformations in sequence using Mediabunny.
|
|
95
|
+
* @param buffer The original video buffer.
|
|
96
|
+
* @param steps Array of video transformation steps to apply.
|
|
97
|
+
* @returns Promise resolving to transformed video buffer.
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
private applyTransformations;
|
|
101
|
+
/**
|
|
102
|
+
* Converts transformation steps to Mediabunny video options.
|
|
103
|
+
* @param steps Array of video transformation steps to convert.
|
|
104
|
+
* @returns Mediabunny video options object for conversion.
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
private stepsToVideoOptions;
|
|
108
|
+
/**
|
|
109
|
+
* Determines output format based on transformation steps.
|
|
110
|
+
* @param steps Array of video transformation steps.
|
|
111
|
+
* @returns Mediabunny output format instance (defaults to MP4).
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
private determineOutputFormat;
|
|
115
|
+
/**
|
|
116
|
+
* Converts format string to Mediabunny output format.
|
|
117
|
+
* @param format Video format string (mp4, webm, mkv, ogg).
|
|
118
|
+
* @returns Mediabunny output format instance.
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
private formatStringToOutputFormat;
|
|
122
|
+
/**
|
|
123
|
+
* Validates that the file is a supported video.
|
|
124
|
+
* @param file The file to validate.
|
|
125
|
+
* @returns Promise that resolves if validation passes.
|
|
126
|
+
* @throws Error if file size exceeds limits, wrong content type, unsupported format, or invalid video.
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
private validateVideo;
|
|
130
|
+
/**
|
|
131
|
+
* Creates transformation result with metadata.
|
|
132
|
+
* @param buffer The transformed video buffer.
|
|
133
|
+
* @param originalFile The original file information.
|
|
134
|
+
* @returns Video transformation result with metadata.
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
private createTransformResult;
|
|
138
|
+
/**
|
|
139
|
+
* Generates cache key for transformation.
|
|
140
|
+
* @param fileId The file identifier.
|
|
141
|
+
* @param steps Array of transformation steps.
|
|
142
|
+
* @returns Unique cache key string.
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
private generateCacheKey;
|
|
144
146
|
}
|
|
145
|
-
export default
|
|
147
|
+
export { VideoTransformer as default };
|
package/package.json
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/storage",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.16",
|
|
4
4
|
"description": "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.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
7
|
-
"
|
|
7
|
+
"astro",
|
|
8
|
+
"aws",
|
|
9
|
+
"aws-s3",
|
|
10
|
+
"azure",
|
|
11
|
+
"better-upload",
|
|
12
|
+
"better-uploads",
|
|
13
|
+
"chunk",
|
|
14
|
+
"chunked-upload",
|
|
15
|
+
"chunked-uploads",
|
|
16
|
+
"cloudflare-r2",
|
|
17
|
+
"cloudflare-workers",
|
|
18
|
+
"digitalocean-spaces",
|
|
19
|
+
"edge-runtime",
|
|
20
|
+
"elysia",
|
|
21
|
+
"enterprise-security",
|
|
8
22
|
"express",
|
|
9
|
-
"
|
|
10
|
-
"uploads",
|
|
23
|
+
"fastify",
|
|
11
24
|
"file",
|
|
25
|
+
"file-upload",
|
|
12
26
|
"files",
|
|
13
|
-
"chunk",
|
|
14
|
-
"resumable",
|
|
15
|
-
"chunked-uploads",
|
|
16
|
-
"tus",
|
|
17
27
|
"form",
|
|
18
|
-
"post",
|
|
19
|
-
"multipart",
|
|
20
28
|
"form-data",
|
|
21
29
|
"formdata",
|
|
22
|
-
"
|
|
23
|
-
"better-upload",
|
|
24
|
-
"better-uploads",
|
|
25
|
-
"s3",
|
|
26
|
-
"azure",
|
|
27
|
-
"aws",
|
|
30
|
+
"framework-agnostic",
|
|
28
31
|
"gcs",
|
|
29
32
|
"google",
|
|
30
|
-
"storage",
|
|
31
|
-
"file-upload",
|
|
32
|
-
"cloudflare-r2",
|
|
33
|
-
"digitalocean-spaces",
|
|
34
33
|
"google-cloud-storage",
|
|
34
|
+
"hono",
|
|
35
|
+
"middleware",
|
|
35
36
|
"minio",
|
|
36
|
-
"
|
|
37
|
+
"multipart",
|
|
38
|
+
"multipart-upload",
|
|
37
39
|
"nextjs",
|
|
38
|
-
"remix",
|
|
39
|
-
"sveltekit",
|
|
40
40
|
"nuxt",
|
|
41
|
-
"
|
|
41
|
+
"post",
|
|
42
|
+
"presigned-urls",
|
|
42
43
|
"react",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"fastify",
|
|
47
|
-
"elysia",
|
|
48
|
-
"framework-agnostic",
|
|
49
|
-
"edge-runtime",
|
|
50
|
-
"cloudflare-workers",
|
|
51
|
-
"vercel-edge",
|
|
44
|
+
"remix",
|
|
45
|
+
"resumable",
|
|
46
|
+
"s3",
|
|
52
47
|
"serverless",
|
|
48
|
+
"storage",
|
|
49
|
+
"sveltekit",
|
|
50
|
+
"tus",
|
|
51
|
+
"typescript",
|
|
53
52
|
"universal",
|
|
54
|
-
"
|
|
55
|
-
"multipart-upload",
|
|
56
|
-
"chunked-upload",
|
|
53
|
+
"upload",
|
|
57
54
|
"upload-library",
|
|
58
|
-
"
|
|
55
|
+
"uploads",
|
|
56
|
+
"uploadthing",
|
|
57
|
+
"vercel-edge",
|
|
58
|
+
"visulima"
|
|
59
59
|
],
|
|
60
60
|
"homepage": "https://visulima.com/packages/uploads",
|
|
61
61
|
"repository": {
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
"dependencies": {
|
|
189
189
|
"@remix-run/multipart-parser": "0.15.0",
|
|
190
190
|
"@sindresorhus/fnv1a": "3.1.0",
|
|
191
|
-
"@visulima/pagination": "5.0.0-alpha.
|
|
191
|
+
"@visulima/pagination": "5.0.0-alpha.11",
|
|
192
192
|
"file-type": "22.0.1",
|
|
193
193
|
"lru-cache": "11.3.5",
|
|
194
194
|
"mime": "^4.1.0",
|
|
@@ -1,91 +0,0 @@
|
|
|
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;
|
|
@@ -1,76 +0,0 @@
|
|
|
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;
|