@visulima/storage 1.0.0-alpha.15 → 1.0.0-alpha.17

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 +13 -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-BkUIdJ5m.js → GCSMetaStorage-BygVH0Ee.js} +1 -1
  12. package/dist/packem_shared/{GCStorage-BnsSAjdW.js → GCStorage-4hSx_bN1.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-DBeGn2ix.js → gcs-meta-storage-8FovEDbW.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-ChmjTvjc.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-CpLzyd-S.d.ts +99 -0
  21. package/dist/packem_shared/types.d-DBjmJvIT.d.ts +708 -0
  22. package/dist/packem_shared/types.d-DviSTLOg.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,639 +0,0 @@
1
- import type { BaseStorage } from "../storage/storage.d.ts";
2
- import type { File, FileReturn } from "../storage/utils/index.d.ts";
3
- import type { Cache } from "../utils/cache.d.ts";
4
- import type BaseTransformer from "./base-transformer.d.ts";
5
- import type { BaseTransformerConfig } from "./transformer-config.d.ts";
6
- export type { BaseTransformerConfig } from "./transformer-config.d.ts";
7
- /**
8
- * Supported image formats for transformation
9
- */
10
- export type ImageFormat = "jpeg" | "png" | "webp" | "avif" | "tiff" | "gif";
11
- /**
12
- * Image transformation options
13
- */
14
- export interface TransformOptions {
15
- /** Quality of alpha layer for WebP (0-100) */
16
- alphaQuality?: number;
17
- /** Compression level for PNG (0-9) */
18
- compressionLevel?: number;
19
- /** GIF delay(s) between animation frames (in milliseconds) */
20
- delay?: number;
21
- /** Effort for AVIF encoding (0-10) */
22
- effort?: number;
23
- /** Output format */
24
- format?: ImageFormat;
25
- /** GIF number of animation iterations, use 0 for infinite */
26
- loop?: number;
27
- /** Whether to use lossless compression for WebP */
28
- lossless?: boolean;
29
- /** Whether to use progressive encoding for JPEG */
30
- progressive?: boolean;
31
- /** Quality for JPEG/WebP images (1-100) */
32
- quality?: number;
33
- }
34
- /**
35
- * Sharpen transformation options
36
- */
37
- export interface SharpenOptions extends TransformOptions {
38
- /** M1 for sharpen formula */
39
- m1?: number;
40
- /** M2 for sharpen formula */
41
- m2?: number;
42
- /** Sigma for Gaussian blur */
43
- sigma?: number;
44
- /** X1 for sharpen formula */
45
- x1?: number;
46
- /** Y2 for sharpen formula */
47
- y2?: number;
48
- /** Y3 for sharpen formula */
49
- y3?: number;
50
- }
51
- /**
52
- * Blur transformation options
53
- */
54
- export interface BlurOptions extends TransformOptions {
55
- /** M1 for blur formula */
56
- m1?: number;
57
- /** M2 for blur formula */
58
- m2?: number;
59
- /** Sigma for Gaussian blur */
60
- sigma?: number;
61
- /** X1 for blur formula */
62
- x1?: number;
63
- /** Y2 for blur formula */
64
- y2?: number;
65
- /** Y3 for blur formula */
66
- y3?: number;
67
- }
68
- /**
69
- * Median transformation options
70
- */
71
- export interface MedianOptions extends TransformOptions {
72
- /** Size of the median filter */
73
- size?: number;
74
- }
75
- /**
76
- * CLAHE (Contrast Limited Adaptive Histogram Equalization) options
77
- */
78
- export interface CLAHEOptions extends TransformOptions {
79
- /** Height of the tile grid */
80
- height?: number;
81
- /** Maximum slope value for contrast limiting */
82
- maxSlope?: number;
83
- /** Width of the tile grid */
84
- width?: number;
85
- }
86
- /**
87
- * Convolve transformation options
88
- */
89
- export interface ConvolveOptions extends TransformOptions {
90
- /** Height of the kernel in pixels */
91
- height?: number;
92
- /** Kernel values as flat array */
93
- kernel?: number[];
94
- /** Offset value */
95
- offset?: number;
96
- /** Scale factor */
97
- scale?: number;
98
- /** Width of the kernel in pixels */
99
- width?: number;
100
- }
101
- /**
102
- * Threshold transformation options
103
- */
104
- export interface ThresholdOptions extends TransformOptions {
105
- /** Alternative spelling for greyscale */
106
- grayscale?: boolean;
107
- /** Convert to greyscale */
108
- greyscale?: boolean;
109
- /** Threshold value (0-255) */
110
- threshold?: number;
111
- }
112
- /**
113
- * Boolean operation options
114
- */
115
- export interface BooleanOptions extends TransformOptions {
116
- /** Operand image buffer or path */
117
- operand: Buffer | string;
118
- /** Boolean operation: and, or, eor */
119
- operator: "and" | "or" | "eor";
120
- /** Raw operand options */
121
- raw?: {
122
- channels: number;
123
- height: number;
124
- width: number;
125
- };
126
- }
127
- /**
128
- * Linear transformation options
129
- */
130
- export interface LinearOptions extends TransformOptions {
131
- /** Multiplier values (per channel or single value) */
132
- a?: number | number[];
133
- /** Offset values (per channel or single value) */
134
- b?: number | number[];
135
- }
136
- /**
137
- * Recombine transformation options
138
- */
139
- export interface RecombineOptions extends TransformOptions {
140
- /** 3x3 or 4x4 recombination matrix */
141
- matrix: number[][];
142
- }
143
- /**
144
- * Modulate transformation options
145
- */
146
- export interface ModulateOptions extends TransformOptions {
147
- /** Brightness multiplier */
148
- brightness?: number;
149
- /** Hue rotation in degrees */
150
- hue?: number;
151
- /** Lightness adjustment */
152
- lightness?: number;
153
- /** Saturation multiplier */
154
- saturation?: number;
155
- }
156
- /**
157
- * Tint transformation options
158
- */
159
- export interface TintOptions extends TransformOptions {
160
- /** RGB tint values */
161
- rgb: [number, number, number] | string;
162
- }
163
- /**
164
- * Greyscale transformation options
165
- */
166
- export interface GreyscaleOptions extends TransformOptions {
167
- /** Alternative spelling */
168
- grayscale?: boolean;
169
- /** Convert to greyscale */
170
- greyscale?: boolean;
171
- }
172
- /**
173
- * Colourspace transformation options
174
- */
175
- export interface ColourspaceOptions extends TransformOptions {
176
- /** Target colourspace */
177
- colourspace: "srgb" | "rgb" | "cmyk" | "lab" | "b-w";
178
- }
179
- /**
180
- * Channel extraction options
181
- */
182
- export interface ExtractChannelOptions extends TransformOptions {
183
- /** Channel to extract (0-3 for RGBA) */
184
- channel: number;
185
- }
186
- /**
187
- * Options for joining multiple images as color channels into a single image.
188
- */
189
- export interface JoinChannelOptions extends TransformOptions {
190
- /** Images to join as channels */
191
- images: (Buffer | string)[];
192
- }
193
- /**
194
- * Options for performing boolean operations on image bands.
195
- */
196
- export interface BandboolOptions extends TransformOptions {
197
- /** Boolean operation: and, or, eor */
198
- operator: "and" | "or" | "eor";
199
- }
200
- /**
201
- * Options for applying affine transformations (rotation, scaling, shearing, translation) to images.
202
- */
203
- export interface AffineOptions extends TransformOptions {
204
- /** Background color for areas outside the transformed image */
205
- background?: string;
206
- /** Interpolation method */
207
- interpolation?: "nearest" | "bilinear" | "bicubic" | "nohalo" | "lbb" | "vsqbs";
208
- /** 2x3 transformation matrix */
209
- matrix: [number, number, number, number, number, number];
210
- }
211
- /**
212
- * Options for applying morphological dilation operation to images.
213
- */
214
- export interface DilateOptions extends TransformOptions {
215
- /** Kernel size for dilation */
216
- kernelSize?: number;
217
- }
218
- /**
219
- * Options for applying morphological erosion operation to images.
220
- */
221
- export interface ErodeOptions extends TransformOptions {
222
- /** Kernel size for erosion */
223
- kernelSize?: number;
224
- }
225
- /**
226
- * Options for setting the colourspace used for internal processing pipeline operations.
227
- */
228
- export interface PipelineColourspaceOptions extends TransformOptions {
229
- /** Colourspace for internal operations */
230
- colourspace: "rgb" | "srgb" | "cmyk" | "lab" | "b-w";
231
- }
232
- /**
233
- * Options for converting images to a target colourspace.
234
- */
235
- export interface ToColourspaceOptions extends TransformOptions {
236
- /** Target colourspace */
237
- colourspace: "srgb" | "rgb" | "cmyk" | "lab" | "b-w";
238
- }
239
- /**
240
- * Remove alpha channel options
241
- */
242
- export interface RemoveAlphaOptions extends TransformOptions {
243
- /** Background color to composite over alpha channel */
244
- background?: string;
245
- }
246
- /**
247
- * Ensure alpha channel options
248
- */
249
- export interface EnsureAlphaOptions extends TransformOptions {
250
- /** Alpha channel value to add */
251
- alpha?: number;
252
- }
253
- /**
254
- * Resize transformation options
255
- */
256
- export interface ResizeOptions extends TransformOptions {
257
- /** Background color for fill fit */
258
- background?: string;
259
- /** Whether to skip enlargement during initial load */
260
- fastShrinkOnLoad?: boolean;
261
- /** Resize fit mode */
262
- fit?: "cover" | "contain" | "fill" | "inside" | "outside";
263
- /** Height in pixels */
264
- height?: number;
265
- /** Resize kernel */
266
- kernel?: "nearest" | "cubic" | "mitchell" | "lanczos2" | "lanczos3";
267
- /** Position for cover/contain fits */
268
- position?: string | number;
269
- /** Width in pixels */
270
- width?: number;
271
- /** Whether to avoid enlarging images smaller than specified dimensions */
272
- withoutEnlargement?: boolean;
273
- /** Whether to avoid reducing images larger than specified dimensions */
274
- withoutReduction?: boolean;
275
- }
276
- /**
277
- * Crop transformation options
278
- */
279
- export interface CropOptions extends TransformOptions {
280
- /** Crop area height */
281
- height: number;
282
- /** Crop area left offset */
283
- left: number;
284
- /** Crop area top offset */
285
- top: number;
286
- /** Crop area width */
287
- width: number;
288
- }
289
- /**
290
- * Rotate transformation options
291
- */
292
- export interface RotateOptions extends TransformOptions {
293
- /** Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect image quality */
294
- angle: number;
295
- /** Background color for rotation */
296
- background?: string;
297
- }
298
- /**
299
- * Transformation pipeline step
300
- */
301
- export interface TransformationStep {
302
- options: TransformOptions | ResizeOptions | CropOptions | RotateOptions | SharpenOptions | BlurOptions | MedianOptions | CLAHEOptions | ConvolveOptions | ThresholdOptions | BooleanOptions | LinearOptions | RecombineOptions | ModulateOptions | TintOptions | GreyscaleOptions | ColourspaceOptions | ExtractChannelOptions | JoinChannelOptions | BandboolOptions | AffineOptions | DilateOptions | ErodeOptions | PipelineColourspaceOptions | ToColourspaceOptions | RemoveAlphaOptions | EnsureAlphaOptions;
303
- type: "resize" | "crop" | "rotate" | "format" | "quality" | "sharpen" | "blur" | "median" | "clahe" | "convolve" | "threshold" | "boolean" | "linear" | "recombine" | "modulate" | "tint" | "greyscale" | "colourspace" | "extractChannel" | "joinChannel" | "bandbool" | "autoOrient" | "flip" | "flop" | "affine" | "dilate" | "erode" | "pipelineColourspace" | "toColourspace" | "removeAlpha" | "ensureAlpha" | "flatten" | "unflatten" | "gamma" | "negate" | "normalise" | "normalize";
304
- }
305
- /**
306
- * Generic transformation pipeline step (for any media type)
307
- */
308
- export interface MediaTransformationStep {
309
- options: TransformOptions | ResizeOptions | CropOptions | RotateOptions | SharpenOptions | BlurOptions | MedianOptions | CLAHEOptions | ConvolveOptions | ThresholdOptions | BooleanOptions | LinearOptions | RecombineOptions | ModulateOptions | TintOptions | GreyscaleOptions | ColourspaceOptions | ExtractChannelOptions | JoinChannelOptions | BandboolOptions | VideoTransformOptions | VideoResizeOptions | VideoCropOptions | VideoRotateOptions | AudioTransformOptions | AudioChannelMixOptions | AudioResampleOptions;
310
- type: "resize" | "crop" | "rotate" | "format" | "quality" | "sharpen" | "blur" | "median" | "clahe" | "convolve" | "threshold" | "boolean" | "linear" | "recombine" | "modulate" | "tint" | "greyscale" | "colourspace" | "extractChannel" | "joinChannel" | "bandbool" | "autoOrient" | "flip" | "flop" | "affine" | "dilate" | "erode" | "flatten" | "unflatten" | "gamma" | "negate" | "normalise" | "normalize" | "codec" | "bitrate" | "frameRate" | "resample" | "channels";
311
- }
312
- /**
313
- * Video transformation options
314
- */
315
- export interface VideoTransformOptions extends TransformOptions {
316
- /** Video bitrate */
317
- bitrate?: number;
318
- /** Video codec */
319
- codec?: "avc" | "hevc" | "vp8" | "vp9" | "av1";
320
- /** Frame rate in Hz */
321
- frameRate?: number;
322
- /** Key frame interval in seconds */
323
- keyFrameInterval?: number;
324
- }
325
- /**
326
- * Audio transformation options
327
- */
328
- export interface AudioTransformOptions extends TransformOptions {
329
- /** Audio bitrate */
330
- bitrate?: number;
331
- /** Audio codec */
332
- codec?: "aac" | "opus" | "mp3" | "vorbis" | "flac";
333
- /** Number of channels */
334
- numberOfChannels?: number;
335
- /** Sample rate in Hz */
336
- sampleRate?: number;
337
- }
338
- /**
339
- * Video resize transformation options
340
- */
341
- export interface VideoResizeOptions extends VideoTransformOptions {
342
- /** Resize fit mode */
343
- fit?: "cover" | "contain" | "fill" | "inside" | "outside";
344
- /** Height in pixels */
345
- height?: number;
346
- /** Position for cover/contain fits */
347
- position?: string | number;
348
- /** Width in pixels */
349
- width?: number;
350
- /** Whether to avoid enlarging videos smaller than specified dimensions */
351
- withoutEnlargement?: boolean;
352
- /** Whether to avoid reducing videos larger than specified dimensions */
353
- withoutReduction?: boolean;
354
- }
355
- /**
356
- * Video crop transformation options
357
- */
358
- export interface VideoCropOptions extends VideoTransformOptions {
359
- /** Crop area height */
360
- height: number;
361
- /** Crop area left offset */
362
- left: number;
363
- /** Crop area top offset */
364
- top: number;
365
- /** Crop area width */
366
- width: number;
367
- }
368
- /**
369
- * Video rotate transformation options
370
- */
371
- export interface VideoRotateOptions extends VideoTransformOptions {
372
- /** Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect video quality */
373
- angle: number;
374
- /** Background color for rotation */
375
- background?: string;
376
- }
377
- /**
378
- * Audio channel mix transformation options
379
- */
380
- export interface AudioChannelMixOptions extends AudioTransformOptions {
381
- /** Number of output channels */
382
- numberOfChannels: number;
383
- }
384
- /**
385
- * Audio resample transformation options
386
- */
387
- export interface AudioResampleOptions extends AudioTransformOptions {
388
- /** Output sample rate in Hz */
389
- sampleRate: number;
390
- }
391
- /**
392
- * Video transformation pipeline step
393
- */
394
- export interface VideoTransformationStep {
395
- options: VideoTransformOptions | VideoResizeOptions | VideoCropOptions | VideoRotateOptions;
396
- type: "resize" | "crop" | "rotate" | "format" | "codec" | "bitrate" | "frameRate";
397
- }
398
- /**
399
- * Audio transformation pipeline step
400
- */
401
- export interface AudioTransformationStep {
402
- options: AudioTransformOptions | AudioChannelMixOptions | AudioResampleOptions;
403
- type: "resample" | "channels" | "format" | "codec" | "bitrate";
404
- }
405
- /**
406
- * Image transformation result
407
- */
408
- export interface TransformResult<TFileReturn extends FileReturn = FileReturn> {
409
- /** Transformed image buffer */
410
- buffer: Buffer;
411
- /** Image format */
412
- format: string;
413
- /** Image height in pixels */
414
- height: number;
415
- /** Original file information */
416
- originalFile: TFileReturn;
417
- /** Image size in bytes */
418
- size: number;
419
- /** Image width in pixels */
420
- width: number;
421
- }
422
- /**
423
- * Video transformation result
424
- */
425
- export interface VideoTransformResult<TFileReturn extends FileReturn = FileReturn> extends TransformResult<TFileReturn> {
426
- /** Video bitrate */
427
- bitrate?: number;
428
- /** Video duration in seconds */
429
- duration: number;
430
- }
431
- /**
432
- * Audio transformation result
433
- */
434
- export interface AudioTransformResult<TFileReturn extends FileReturn = FileReturn> extends Omit<TransformResult<TFileReturn>, "width" | "height"> {
435
- /** Audio bitrate */
436
- bitrate?: number;
437
- /** Audio duration in seconds */
438
- duration: number;
439
- /** Number of channels */
440
- numberOfChannels: number;
441
- /** Sample rate in Hz */
442
- sampleRate: number;
443
- }
444
- /**
445
- * Media transformer configuration (unified config for all transformers)
446
- */
447
- export interface MediaTransformerConfig<TFile extends File = File, TFileReturn extends FileReturn = FileReturn> {
448
- /** Default audio bitrate */
449
- audioBitrate?: number;
450
- /** Default audio codec */
451
- audioCodec?: "aac" | "opus" | "mp3" | "vorbis" | "flac";
452
- /** Audio transformer class (optional, enables audio transformations) */
453
- AudioTransformer?: new (storage: BaseStorage<TFile, TFileReturn>, config: AudioTransformerConfig) => BaseTransformer<AudioTransformerConfig, AudioTransformResult<TFileReturn>, TFile, TFileReturn>;
454
- /** Cache instance to use for caching */
455
- cache?: Cache;
456
- /** Cache TTL in seconds */
457
- cacheTtl?: number;
458
- /** Image transformer class (optional, enables image transformations) */
459
- ImageTransformer?: new (storage: BaseStorage<TFile, TFileReturn>, config: ImageTransformerConfig) => BaseTransformer<ImageTransformerConfig, TransformResult<TFileReturn>, TFile, TFileReturn>;
460
- /** Logger instance */
461
- logger?: Console;
462
- /** Maximum audio size to process (in bytes) */
463
- maxAudioSize?: number;
464
- /** Maximum image size to process (in bytes) */
465
- maxImageSize?: number;
466
- /** Maximum video size to process (in bytes) */
467
- maxVideoSize?: number;
468
- /** Save transformed files to storage for reuse */
469
- saveTransformedFiles?: boolean;
470
- /** Supported audio input formats */
471
- supportedAudioFormats?: string[];
472
- /** Supported image input formats */
473
- supportedImageFormats?: string[];
474
- /** Supported video input formats */
475
- supportedVideoFormats?: string[];
476
- /** Default video bitrate */
477
- videoBitrate?: number;
478
- /** Default video codec */
479
- videoCodec?: "avc" | "hevc" | "vp8" | "vp9" | "av1";
480
- /** Video transformer class (optional, enables video transformations) */
481
- VideoTransformer?: new (storage: BaseStorage<TFile, TFileReturn>, config: VideoTransformerConfig) => BaseTransformer<VideoTransformerConfig, VideoTransformResult<TFileReturn>, TFile, TFileReturn>;
482
- }
483
- /**
484
- * Unified media transformation result
485
- */
486
- export interface MediaTransformResult<TFileReturn extends FileReturn = FileReturn> {
487
- /** Video-specific properties */
488
- bitrate?: number;
489
- /** Transformed media buffer */
490
- buffer: Buffer;
491
- /** Video/Audio-specific properties */
492
- duration?: number;
493
- /** Media format */
494
- format: string;
495
- /** Image/Video-specific properties */
496
- height?: number;
497
- /** Media type */
498
- mediaType: "image" | "video" | "audio";
499
- /** Audio-specific properties */
500
- numberOfChannels?: number;
501
- /** Original file information */
502
- originalFile: TFileReturn;
503
- /** Audio-specific properties */
504
- sampleRate?: number;
505
- /** Media size in bytes */
506
- size: number;
507
- /** Image-specific properties */
508
- width?: number;
509
- }
510
- /**
511
- * Query parameters for media transformation
512
- */
513
- export interface MediaTransformQuery {
514
- /** Apply affine transformation */
515
- affine?: boolean;
516
- /** Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect media quality */
517
- angle?: number;
518
- /** Background color for rotation */
519
- background?: string;
520
- /** Video bitrate in bits per second */
521
- bitrate?: number;
522
- /** Apply blur effect */
523
- blur?: boolean;
524
- /** Brightness multiplier for modulation */
525
- brightness?: number;
526
- /** Apply CLAHE (Contrast Limited Adaptive Histogram Equalization) */
527
- clahe?: boolean;
528
- /** Video codec */
529
- codec?: "avc" | "hevc" | "vp8" | "vp9" | "av1" | "aac" | "opus" | "mp3" | "vorbis" | "flac";
530
- /** Crop area height */
531
- cropHeight?: number;
532
- /** Crop area width */
533
- cropWidth?: number;
534
- /** Apply dilation */
535
- dilate?: boolean;
536
- /** Ensure alpha channel */
537
- ensureAlpha?: boolean;
538
- /** Apply erosion */
539
- erode?: boolean;
540
- /** Fast shrink on load */
541
- fastShrinkOnLoad?: boolean;
542
- /** Resize fit mode */
543
- fit?: "cover" | "contain" | "fill" | "inside" | "outside";
544
- /** Flatten alpha channel */
545
- flatten?: boolean;
546
- /** Flip image vertically */
547
- flip?: boolean;
548
- /** Flop image horizontally */
549
- flop?: boolean;
550
- /** Output format */
551
- format?: string;
552
- /** Frame rate in Hz */
553
- frameRate?: number;
554
- /** Apply gamma correction */
555
- gamma?: boolean;
556
- /** Convert to greyscale */
557
- greyscale?: boolean;
558
- /** Height in pixels */
559
- height?: number;
560
- /** Hue rotation in degrees for modulation */
561
- hue?: number;
562
- /** Resize kernel */
563
- kernel?: string;
564
- /** Key frame interval in seconds */
565
- keyFrameInterval?: number;
566
- /** Crop area left offset */
567
- left?: number;
568
- /** Lightness adjustment for modulation */
569
- lightness?: number;
570
- /** Apply median filter with specified size */
571
- median?: number;
572
- /** Apply modulation effects */
573
- modulate?: boolean;
574
- /** Negate (invert) the image */
575
- negate?: boolean;
576
- /** Normalise the image */
577
- normalise?: boolean;
578
- /** Number of channels */
579
- numberOfChannels?: number;
580
- /** Set pipeline colourspace */
581
- pipelineColourspace?: boolean;
582
- /** Position for cover/contain fits */
583
- position?: string | number;
584
- /** Quality (0-100 for images, bitrate for video/audio) */
585
- quality?: number;
586
- /** Remove alpha channel */
587
- removeAlpha?: boolean;
588
- /** Sample rate in Hz */
589
- sampleRate?: number;
590
- /** Saturation multiplier for modulation */
591
- saturation?: number;
592
- /** Apply sharpening */
593
- sharpen?: boolean;
594
- /** Apply thresholding with specified value */
595
- threshold?: number;
596
- /** Apply tinting */
597
- tint?: boolean;
598
- /** Convert to colourspace */
599
- toColourspace?: boolean;
600
- /** Crop area top offset */
601
- top?: number;
602
- /** Unflatten alpha channel */
603
- unflatten?: boolean;
604
- /** Width in pixels */
605
- width?: number;
606
- /** Whether to avoid enlarging smaller images */
607
- withoutEnlargement?: boolean;
608
- /** Whether to avoid reducing larger images */
609
- withoutReduction?: boolean;
610
- }
611
- /**
612
- * Image transformer configuration
613
- */
614
- export interface ImageTransformerConfig extends BaseTransformerConfig {
615
- /** Maximum image size to process (in bytes) */
616
- maxImageSize?: number;
617
- }
618
- /**
619
- * Video transformer configuration
620
- */
621
- export interface VideoTransformerConfig extends BaseTransformerConfig {
622
- /** Default video bitrate */
623
- defaultBitrate?: number;
624
- /** Default video codec */
625
- defaultCodec?: "avc" | "hevc" | "vp8" | "vp9" | "av1";
626
- /** Maximum video size to process (in bytes) */
627
- maxVideoSize?: number;
628
- }
629
- /**
630
- * Audio transformer configuration
631
- */
632
- export interface AudioTransformerConfig extends BaseTransformerConfig {
633
- /** Default audio bitrate */
634
- defaultBitrate?: number;
635
- /** Default audio codec */
636
- defaultCodec?: "aac" | "opus" | "mp3" | "vorbis" | "flac";
637
- /** Maximum audio size to process (in bytes) */
638
- maxAudioSize?: number;
639
- }
@@ -1,33 +0,0 @@
1
- import type { FileReturn } from "../storage/utils/index.d.ts";
2
- /**
3
- * Check if a content type is valid for a specific media type.
4
- * @param contentType MIME content type string to validate
5
- * @param expectedType Expected media type ('image', 'video', or 'audio')
6
- * @returns True if the content type is valid for the expected media type
7
- */
8
- export declare const isValidMediaType: (contentType: string | undefined, expectedType: "image" | "video" | "audio") => boolean;
9
- /**
10
- * Get format (extension) from content type using mime package.
11
- * @param contentType MIME content type string to extract format from
12
- * @returns Format string or undefined if not found
13
- */
14
- export declare const getFormatFromContentType: (contentType: string | undefined) => string | undefined;
15
- /**
16
- * Validate a media file for a specific type with size and format checks.
17
- * @param file File to validate
18
- * @param expectedType Expected media type ('image', 'video', or 'audio')
19
- * @param config Validation configuration with optional maxSize and supportedFormats
20
- * @param config.maxSize Maximum allowed file size in bytes
21
- * @param config.supportedFormats Array of supported file formats
22
- * @throws Error if validation fails (size exceeded, wrong type, or unsupported format)
23
- */
24
- export declare const validateMediaFile: (file: FileReturn, expectedType: "image" | "video" | "audio", config?: {
25
- maxSize?: number;
26
- supportedFormats?: string[];
27
- }) => void;
28
- /**
29
- * Validate that a content type is known and supported by the mime package.
30
- * @param contentType MIME content type string to check
31
- * @returns True if the content type is known and has a registered extension
32
- */
33
- export declare const isKnownContentType: (contentType: string | undefined) => boolean;
@@ -1,23 +0,0 @@
1
- /**
2
- * Custom error class for validation failures
3
- */
4
- declare class ValidationError extends Error {
5
- readonly code: string;
6
- readonly details: {
7
- invalidParams: string[];
8
- mediaType: string;
9
- suggestions?: string[];
10
- validParams: string[];
11
- };
12
- /**
13
- * Creates a new ValidationError instance with detailed error information.
14
- * @param message Human-readable error message describing the validation failure
15
- * @param code Machine-readable error code for programmatic error handling
16
- * @param mediaType The media type where validation failed ('image', 'video', or 'audio')
17
- * @param invalidParameters Array of parameter names that were invalid
18
- * @param validParameters Array of valid parameter names or values
19
- * @param suggestions Optional array of suggested corrections or valid values
20
- */
21
- constructor(message: string, code: string, mediaType: string, invalidParameters: string[], validParameters: string[], suggestions?: string[]);
22
- }
23
- export default ValidationError;