@visulima/storage 1.0.0-alpha.1 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +33 -14
  3. package/dist/adapter/nuxt/module.d.ts +39 -0
  4. package/dist/adapter/nuxt/module.js +93 -0
  5. package/dist/adapter/nuxt/package.json +20 -0
  6. package/dist/handler/base/base-handler-core.d.ts +91 -0
  7. package/dist/handler/base/base-handler-fetch.d.ts +76 -0
  8. package/dist/handler/base/base-handler-node.d.ts +137 -0
  9. package/dist/handler/http/fetch/index.d.ts +4 -0
  10. package/dist/handler/http/fetch/index.js +4 -0
  11. package/dist/handler/http/hono/index.d.ts +67 -0
  12. package/dist/handler/http/hono/index.js +65 -0
  13. package/dist/handler/http/nextjs/index.d.ts +61 -0
  14. package/dist/handler/http/nextjs/index.js +37 -0
  15. package/dist/handler/http/node/index.d.ts +4 -0
  16. package/dist/handler/http/node/index.js +4 -0
  17. package/dist/handler/http/solid-start/index.d.ts +60 -0
  18. package/dist/handler/http/solid-start/index.js +44 -0
  19. package/dist/handler/multipart/multipart-base.d.ts +84 -0
  20. package/dist/handler/multipart/multipart-fetch.d.ts +64 -0
  21. package/dist/handler/multipart/multipart.d.ts +49 -0
  22. package/dist/handler/rest/rest-base.d.ts +106 -0
  23. package/dist/handler/rest/rest-fetch.d.ts +88 -0
  24. package/dist/handler/rest/rest.d.ts +93 -0
  25. package/dist/handler/tus/tus-base.d.ts +152 -0
  26. package/dist/handler/tus/tus-fetch.d.ts +72 -0
  27. package/dist/handler/tus/tus.d.ts +78 -0
  28. package/dist/handler/types.d.ts +53 -0
  29. package/dist/handler/utils/request-parser.d.ts +72 -0
  30. package/dist/handler/utils/response-builder.d.ts +83 -0
  31. package/dist/handler/utils/storage-utils.d.ts +10 -0
  32. package/dist/handler/utils/stream-utils.d.ts +29 -0
  33. package/dist/handler/utils/upload-handlers.d.ts +76 -0
  34. package/dist/index.d.ts +17 -0
  35. package/dist/index.js +13 -0
  36. package/dist/metrics/index.d.ts +2 -0
  37. package/dist/metrics/no-op-metrics.d.ts +15 -0
  38. package/dist/metrics/opentelemetry-metrics.d.ts +55 -0
  39. package/dist/openapi/index.d.ts +5 -0
  40. package/dist/openapi/index.js +5 -0
  41. package/dist/openapi/rest.d.ts +7 -0
  42. package/dist/openapi/shared.d.ts +13 -0
  43. package/dist/openapi/transform.d.ts +3 -0
  44. package/dist/openapi/tus.d.ts +7 -0
  45. package/dist/openapi/xhr.d.ts +7 -0
  46. package/dist/packem_shared/AwsLightFile-tTneXZgG.js +11 -0
  47. package/dist/packem_shared/AwsLightMetaStorage-BWSOtVaN.js +4 -0
  48. package/dist/packem_shared/AwsLightStorage-Blv-GP4v.js +133 -0
  49. package/dist/packem_shared/AzureFile-CesgFzps.js +8 -0
  50. package/dist/packem_shared/AzureSMetaStorage-CFs-OYJT.js +88 -0
  51. package/dist/packem_shared/AzureStorage-B0v048hG.js +357 -0
  52. package/dist/packem_shared/BaseTransformer-C2gLib6v.js +82 -0
  53. package/dist/packem_shared/DiskStorage-BlltBst6.js +12 -0
  54. package/dist/packem_shared/DiskStorageWithChecksum-BJTmMklc.js +238 -0
  55. package/dist/packem_shared/ERRORS-D0apMqnc.js +97 -0
  56. package/dist/packem_shared/File-Bb3P23dr.js +69 -0
  57. package/dist/packem_shared/GCSConfig-vPP22kN6.js +11 -0
  58. package/dist/packem_shared/GCSFile-BIEunhAN.js +8 -0
  59. package/dist/packem_shared/GCSMetaStorage-BMFEdzJ7.js +7 -0
  60. package/dist/packem_shared/GCStorage-DnhiwaS9.js +406 -0
  61. package/dist/packem_shared/LocalMetaStorage-CZHhKkMd.js +7 -0
  62. package/dist/packem_shared/MediaTransformer-D6658DL1.js +1197 -0
  63. package/dist/packem_shared/MetaStorage-pECeFOad.js +46 -0
  64. package/dist/packem_shared/Metadata-DRLXeJ0F.js +89 -0
  65. package/dist/packem_shared/Multipart-CNFK_Okz.js +163 -0
  66. package/dist/packem_shared/Multipart-CtUL7BQw.js +128 -0
  67. package/dist/packem_shared/NetlifyBlobFile-CXzyjqrD.js +14 -0
  68. package/dist/packem_shared/NetlifyBlobMetaStorage-DxZ5aDvD.js +9 -0
  69. package/dist/packem_shared/NetlifyBlobStorage-CLPtjHqd.js +376 -0
  70. package/dist/packem_shared/NoOpMetrics-DhAk5rXc.js +10 -0
  71. package/dist/packem_shared/OpenTelemetryMetrics-BnxhqIaH.js +67 -0
  72. package/dist/packem_shared/Rest-CAOAEkOj.js +267 -0
  73. package/dist/packem_shared/Rest-DNuLwBrK.js +228 -0
  74. package/dist/packem_shared/S3File-DZiyk9Qt.js +11 -0
  75. package/dist/packem_shared/S3MetaStorage-Dz9aDabA.js +76 -0
  76. package/dist/packem_shared/S3Storage-DHmTk-hU.js +316 -0
  77. package/dist/packem_shared/TUS_RESUMABLE-GJzZ9R-f.js +434 -0
  78. package/dist/packem_shared/Tus-B8PmlMgR.js +200 -0
  79. package/dist/packem_shared/Tus-C4F1aYOl.js +195 -0
  80. package/dist/packem_shared/ValidationError-BfF1aE4h.js +26 -0
  81. package/dist/packem_shared/VercelBlobFile-BCg4aTEq.js +18 -0
  82. package/dist/packem_shared/VercelBlobMetaStorage-Bd9F-VFm.js +9 -0
  83. package/dist/packem_shared/VercelBlobStorage-DD9LMOS6.js +261 -0
  84. package/dist/packem_shared/_commonjsHelpers-B85MJLTf.js +5 -0
  85. package/dist/packem_shared/aws-light-meta-storage-DKJBgbR6.js +446 -0
  86. package/dist/packem_shared/backblaze-BlMnIcBC.js +20 -0
  87. package/dist/packem_shared/base-handler-core-BKuf4YLT.js +303 -0
  88. package/dist/packem_shared/base-handler-fetch-Cr0hLiqg.js +291 -0
  89. package/dist/packem_shared/base-handler-node-gk5aN9Cx.js +730 -0
  90. package/dist/packem_shared/cache-B88MXQ_2.js +18 -0
  91. package/dist/packem_shared/cloudflare-Bi1q8wXE.js +21 -0
  92. package/dist/packem_shared/defaultCloudStorageFileNameValidation-DUuacjWv.js +11 -0
  93. package/dist/packem_shared/digitalOcean-CWQRJM3L.js +21 -0
  94. package/dist/packem_shared/disk-storage-Bh2wy3YW.js +810 -0
  95. package/dist/packem_shared/gcs-meta-storage-0tgMNnPO.js +158 -0
  96. package/dist/packem_shared/has-content-CY66ehMK.js +3 -0
  97. package/dist/packem_shared/headers-DoS5nwM-.js +3220 -0
  98. package/dist/packem_shared/is-expired-CTThU1q5.js +8 -0
  99. package/dist/packem_shared/isRetryableError-Dycp7127.js +82 -0
  100. package/dist/packem_shared/isValidMediaType-BeDgiObq.js +35 -0
  101. package/dist/packem_shared/local-meta-storage-By-3SNBI.js +649 -0
  102. package/dist/packem_shared/minio-C2YBZQOw.js +22 -0
  103. package/dist/packem_shared/multipart-base-B3i67SSX.js +102 -0
  104. package/dist/packem_shared/part-match-BMNqHDYD.js +96 -0
  105. package/dist/packem_shared/path-CR6YkPXX-7R1-9CMk.js +161 -0
  106. package/dist/packem_shared/response-builder-BtnRiBUI.js +45 -0
  107. package/dist/packem_shared/rest-base-GRCcnan7.js +457 -0
  108. package/dist/packem_shared/restOpenApiSpec-CwcHHY2C.js +800 -0
  109. package/dist/packem_shared/s3-base-storage-C1DIHTYY.js +510 -0
  110. package/dist/packem_shared/sharedGet-Cpo7QUyu.js +1019 -0
  111. package/dist/packem_shared/storage-C6NSXb8h.js +1175 -0
  112. package/dist/packem_shared/tigris-Hac8TKnX.js +21 -0
  113. package/dist/packem_shared/transformOpenApiSpec-DWM5WtnN.js +975 -0
  114. package/dist/packem_shared/tusOpenApiSpec-6ohiToBy.js +740 -0
  115. package/dist/packem_shared/update-size-CCGm6i1J.js +8 -0
  116. package/dist/packem_shared/validator-BeX_lJet.js +78 -0
  117. package/dist/packem_shared/waitForStorage-Cscw85sx.js +18 -0
  118. package/dist/packem_shared/wasabi-DIyflHSd.js +21 -0
  119. package/dist/packem_shared/xhrOpenApiSpec-DS17brnx.js +264 -0
  120. package/dist/storage/aws/clients/backblaze.d.ts +12 -0
  121. package/dist/storage/aws/clients/cloudflare.d.ts +13 -0
  122. package/dist/storage/aws/clients/digital-ocean.d.ts +12 -0
  123. package/dist/storage/aws/clients/index.d.ts +6 -0
  124. package/dist/storage/aws/clients/index.js +6 -0
  125. package/dist/storage/aws/clients/minio.d.ts +13 -0
  126. package/dist/storage/aws/clients/tigris.d.ts +12 -0
  127. package/dist/storage/aws/clients/types.d.ts +95 -0
  128. package/dist/storage/aws/clients/wasabi.d.ts +12 -0
  129. package/dist/storage/aws/index.d.ts +4 -0
  130. package/dist/storage/aws/index.js +3 -0
  131. package/dist/storage/aws/s3-base-storage.d.ts +248 -0
  132. package/dist/storage/aws/s3-client-adapter.d.ts +110 -0
  133. package/dist/storage/aws/s3-file.d.ts +10 -0
  134. package/dist/storage/aws/s3-meta-storage.d.ts +15 -0
  135. package/dist/storage/aws/s3-storage.d.ts +70 -0
  136. package/dist/storage/aws/types.d.ts +119 -0
  137. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +130 -0
  138. package/dist/storage/aws-light/aws-light-file.d.ts +10 -0
  139. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +19 -0
  140. package/dist/storage/aws-light/aws-light-storage.d.ts +65 -0
  141. package/dist/storage/aws-light/index.d.ts +4 -0
  142. package/dist/storage/aws-light/index.js +3 -0
  143. package/dist/storage/aws-light/types.d.ts +37 -0
  144. package/dist/storage/azure/azure-file.d.ts +6 -0
  145. package/dist/storage/azure/azure-meta-storage.d.ts +15 -0
  146. package/dist/storage/azure/azure-storage.d.ts +69 -0
  147. package/dist/storage/azure/index.d.ts +4 -0
  148. package/dist/storage/azure/index.js +3 -0
  149. package/dist/storage/azure/types.d.ts +62 -0
  150. package/dist/storage/gcs/fetch-error.d.ts +11 -0
  151. package/dist/storage/gcs/gcs-config.d.ts +2 -0
  152. package/dist/storage/gcs/gcs-file.d.ts +6 -0
  153. package/dist/storage/gcs/gcs-meta-storage.d.ts +27 -0
  154. package/dist/storage/gcs/gcs-storage.d.ts +91 -0
  155. package/dist/storage/gcs/index.d.ts +5 -0
  156. package/dist/storage/gcs/index.js +4 -0
  157. package/dist/storage/gcs/types.d.ts +55 -0
  158. package/dist/storage/gcs/utils.d.ts +7 -0
  159. package/dist/storage/local/disk-storage-with-checksum.d.ts +15 -0
  160. package/dist/storage/local/disk-storage.d.ts +135 -0
  161. package/dist/storage/local/index.d.ts +4 -0
  162. package/dist/storage/local/index.js +3 -0
  163. package/dist/storage/local/local-meta-storage.d.ts +32 -0
  164. package/dist/storage/meta-storage.d.ts +30 -0
  165. package/dist/storage/netlify-blob/index.d.ts +4 -0
  166. package/dist/storage/netlify-blob/index.js +3 -0
  167. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +12 -0
  168. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +7 -0
  169. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +93 -0
  170. package/dist/storage/netlify-blob/types.d.ts +30 -0
  171. package/dist/storage/storage.d.ts +353 -0
  172. package/dist/storage/types.d.ts +221 -0
  173. package/dist/storage/utils/file/file.d.ts +25 -0
  174. package/dist/storage/utils/file/get-file-status.d.ts +9 -0
  175. package/dist/storage/utils/file/has-content.d.ts +9 -0
  176. package/dist/storage/utils/file/index.d.ts +10 -0
  177. package/dist/storage/utils/file/is-expired.d.ts +8 -0
  178. package/dist/storage/utils/file/metadata.d.ts +18 -0
  179. package/dist/storage/utils/file/part-match.d.ts +11 -0
  180. package/dist/storage/utils/file/types.d.ts +37 -0
  181. package/dist/storage/utils/file/update-metadata.d.ts +10 -0
  182. package/dist/storage/utils/file/update-size.d.ts +10 -0
  183. package/dist/storage/vercel-blob/index.d.ts +4 -0
  184. package/dist/storage/vercel-blob/index.js +3 -0
  185. package/dist/storage/vercel-blob/types.d.ts +32 -0
  186. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +16 -0
  187. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +7 -0
  188. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +76 -0
  189. package/dist/transformer/audio-transformer.d.ts +128 -0
  190. package/dist/transformer/audio-transformer.js +278 -0
  191. package/dist/transformer/base-transformer.d.ts +63 -0
  192. package/dist/transformer/image-transformer.d.ts +571 -0
  193. package/dist/transformer/image-transformer.js +1100 -0
  194. package/dist/transformer/index.d.ts +5 -0
  195. package/dist/transformer/index.js +4 -0
  196. package/dist/transformer/media-transformer.d.ts +332 -0
  197. package/dist/transformer/types.d.ts +652 -0
  198. package/dist/transformer/utils.d.ts +33 -0
  199. package/dist/transformer/validation-error.d.ts +23 -0
  200. package/dist/transformer/video-transformer.d.ts +145 -0
  201. package/dist/transformer/video-transformer.js +310 -0
  202. package/dist/utils/cache.d.ts +32 -0
  203. package/dist/utils/chunked-upload.d.ts +65 -0
  204. package/dist/utils/detect-file-type.d.ts +28 -0
  205. package/dist/utils/errors.d.ts +74 -0
  206. package/dist/utils/file-path-url-matcher.d.ts +18 -0
  207. package/dist/utils/headers.d.ts +111 -0
  208. package/dist/utils/http.d.ts +92 -0
  209. package/dist/utils/locker.d.ts +26 -0
  210. package/dist/utils/pipes/stream-checksum.d.ts +47 -0
  211. package/dist/utils/pipes/stream-length.d.ts +22 -0
  212. package/dist/utils/primitives/get-last-one.d.ts +3 -0
  213. package/dist/utils/primitives/is-record.d.ts +2 -0
  214. package/dist/utils/primitives/map-values.d.ts +9 -0
  215. package/dist/utils/primitives/pick.d.ts +2 -0
  216. package/dist/utils/primitives/to-milliseconds.d.ts +12 -0
  217. package/dist/utils/primitives/to-seconds.d.ts +12 -0
  218. package/dist/utils/range-checksum.d.ts +33 -0
  219. package/dist/utils/range-hasher.d.ts +46 -0
  220. package/dist/utils/retry.d.ts +64 -0
  221. package/dist/utils/types.d.ts +108 -0
  222. package/dist/utils/validation-error.d.ts +22 -0
  223. package/dist/utils/validator.d.ts +36 -0
  224. package/package.json +5 -5
@@ -0,0 +1,652 @@
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
+ /**
6
+ * Supported image formats for transformation
7
+ */
8
+ export type ImageFormat = "jpeg" | "png" | "webp" | "avif" | "tiff" | "gif";
9
+ /**
10
+ * Image transformation options
11
+ */
12
+ export interface TransformOptions {
13
+ /** Quality of alpha layer for WebP (0-100) */
14
+ alphaQuality?: number;
15
+ /** Compression level for PNG (0-9) */
16
+ compressionLevel?: number;
17
+ /** GIF delay(s) between animation frames (in milliseconds) */
18
+ delay?: number;
19
+ /** Effort for AVIF encoding (0-10) */
20
+ effort?: number;
21
+ /** Output format */
22
+ format?: ImageFormat;
23
+ /** GIF number of animation iterations, use 0 for infinite */
24
+ loop?: number;
25
+ /** Whether to use lossless compression for WebP */
26
+ lossless?: boolean;
27
+ /** Whether to use progressive encoding for JPEG */
28
+ progressive?: boolean;
29
+ /** Quality for JPEG/WebP images (1-100) */
30
+ quality?: number;
31
+ }
32
+ /**
33
+ * Sharpen transformation options
34
+ */
35
+ export interface SharpenOptions extends TransformOptions {
36
+ /** M1 for sharpen formula */
37
+ m1?: number;
38
+ /** M2 for sharpen formula */
39
+ m2?: number;
40
+ /** Sigma for Gaussian blur */
41
+ sigma?: number;
42
+ /** X1 for sharpen formula */
43
+ x1?: number;
44
+ /** Y2 for sharpen formula */
45
+ y2?: number;
46
+ /** Y3 for sharpen formula */
47
+ y3?: number;
48
+ }
49
+ /**
50
+ * Blur transformation options
51
+ */
52
+ export interface BlurOptions extends TransformOptions {
53
+ /** M1 for blur formula */
54
+ m1?: number;
55
+ /** M2 for blur formula */
56
+ m2?: number;
57
+ /** Sigma for Gaussian blur */
58
+ sigma?: number;
59
+ /** X1 for blur formula */
60
+ x1?: number;
61
+ /** Y2 for blur formula */
62
+ y2?: number;
63
+ /** Y3 for blur formula */
64
+ y3?: number;
65
+ }
66
+ /**
67
+ * Median transformation options
68
+ */
69
+ export interface MedianOptions extends TransformOptions {
70
+ /** Size of the median filter */
71
+ size?: number;
72
+ }
73
+ /**
74
+ * CLAHE (Contrast Limited Adaptive Histogram Equalization) options
75
+ */
76
+ export interface CLAHEOptions extends TransformOptions {
77
+ /** Height of the tile grid */
78
+ height?: number;
79
+ /** Maximum slope value for contrast limiting */
80
+ maxSlope?: number;
81
+ /** Width of the tile grid */
82
+ width?: number;
83
+ }
84
+ /**
85
+ * Convolve transformation options
86
+ */
87
+ export interface ConvolveOptions extends TransformOptions {
88
+ /** Height of the kernel in pixels */
89
+ height?: number;
90
+ /** Kernel values as flat array */
91
+ kernel?: number[];
92
+ /** Offset value */
93
+ offset?: number;
94
+ /** Scale factor */
95
+ scale?: number;
96
+ /** Width of the kernel in pixels */
97
+ width?: number;
98
+ }
99
+ /**
100
+ * Threshold transformation options
101
+ */
102
+ export interface ThresholdOptions extends TransformOptions {
103
+ /** Alternative spelling for greyscale */
104
+ grayscale?: boolean;
105
+ /** Convert to greyscale */
106
+ greyscale?: boolean;
107
+ /** Threshold value (0-255) */
108
+ threshold?: number;
109
+ }
110
+ /**
111
+ * Boolean operation options
112
+ */
113
+ export interface BooleanOptions extends TransformOptions {
114
+ /** Operand image buffer or path */
115
+ operand: Buffer | string;
116
+ /** Boolean operation: and, or, eor */
117
+ operator: "and" | "or" | "eor";
118
+ /** Raw operand options */
119
+ raw?: {
120
+ channels: number;
121
+ height: number;
122
+ width: number;
123
+ };
124
+ }
125
+ /**
126
+ * Linear transformation options
127
+ */
128
+ export interface LinearOptions extends TransformOptions {
129
+ /** Multiplier values (per channel or single value) */
130
+ a?: number | number[];
131
+ /** Offset values (per channel or single value) */
132
+ b?: number | number[];
133
+ }
134
+ /**
135
+ * Recombine transformation options
136
+ */
137
+ export interface RecombineOptions extends TransformOptions {
138
+ /** 3x3 or 4x4 recombination matrix */
139
+ matrix: number[][];
140
+ }
141
+ /**
142
+ * Modulate transformation options
143
+ */
144
+ export interface ModulateOptions extends TransformOptions {
145
+ /** Brightness multiplier */
146
+ brightness?: number;
147
+ /** Hue rotation in degrees */
148
+ hue?: number;
149
+ /** Lightness adjustment */
150
+ lightness?: number;
151
+ /** Saturation multiplier */
152
+ saturation?: number;
153
+ }
154
+ /**
155
+ * Tint transformation options
156
+ */
157
+ export interface TintOptions extends TransformOptions {
158
+ /** RGB tint values */
159
+ rgb: [number, number, number] | string;
160
+ }
161
+ /**
162
+ * Greyscale transformation options
163
+ */
164
+ export interface GreyscaleOptions extends TransformOptions {
165
+ /** Alternative spelling */
166
+ grayscale?: boolean;
167
+ /** Convert to greyscale */
168
+ greyscale?: boolean;
169
+ }
170
+ /**
171
+ * Colourspace transformation options
172
+ */
173
+ export interface ColourspaceOptions extends TransformOptions {
174
+ /** Target colourspace */
175
+ colourspace: "srgb" | "rgb" | "cmyk" | "lab" | "b-w";
176
+ }
177
+ /**
178
+ * Channel extraction options
179
+ */
180
+ export interface ExtractChannelOptions extends TransformOptions {
181
+ /** Channel to extract (0-3 for RGBA) */
182
+ channel: number;
183
+ }
184
+ /**
185
+ * Options for joining multiple images as color channels into a single image.
186
+ */
187
+ export interface JoinChannelOptions extends TransformOptions {
188
+ /** Images to join as channels */
189
+ images: (Buffer | string)[];
190
+ }
191
+ /**
192
+ * Options for performing boolean operations on image bands.
193
+ */
194
+ export interface BandboolOptions extends TransformOptions {
195
+ /** Boolean operation: and, or, eor */
196
+ operator: "and" | "or" | "eor";
197
+ }
198
+ /**
199
+ * Options for applying affine transformations (rotation, scaling, shearing, translation) to images.
200
+ */
201
+ export interface AffineOptions extends TransformOptions {
202
+ /** Background color for areas outside the transformed image */
203
+ background?: string;
204
+ /** Interpolation method */
205
+ interpolation?: "nearest" | "bilinear" | "bicubic" | "nohalo" | "lbb" | "vsqbs";
206
+ /** 2x3 transformation matrix */
207
+ matrix: [number, number, number, number, number, number];
208
+ }
209
+ /**
210
+ * Options for applying morphological dilation operation to images.
211
+ */
212
+ export interface DilateOptions extends TransformOptions {
213
+ /** Kernel size for dilation */
214
+ kernelSize?: number;
215
+ }
216
+ /**
217
+ * Options for applying morphological erosion operation to images.
218
+ */
219
+ export interface ErodeOptions extends TransformOptions {
220
+ /** Kernel size for erosion */
221
+ kernelSize?: number;
222
+ }
223
+ /**
224
+ * Options for setting the colourspace used for internal processing pipeline operations.
225
+ */
226
+ export interface PipelineColourspaceOptions extends TransformOptions {
227
+ /** Colourspace for internal operations */
228
+ colourspace: "rgb" | "srgb" | "cmyk" | "lab" | "b-w";
229
+ }
230
+ /**
231
+ * Options for converting images to a target colourspace.
232
+ */
233
+ export interface ToColourspaceOptions extends TransformOptions {
234
+ /** Target colourspace */
235
+ colourspace: "srgb" | "rgb" | "cmyk" | "lab" | "b-w";
236
+ }
237
+ /**
238
+ * Remove alpha channel options
239
+ */
240
+ export interface RemoveAlphaOptions extends TransformOptions {
241
+ /** Background color to composite over alpha channel */
242
+ background?: string;
243
+ }
244
+ /**
245
+ * Ensure alpha channel options
246
+ */
247
+ export interface EnsureAlphaOptions extends TransformOptions {
248
+ /** Alpha channel value to add */
249
+ alpha?: number;
250
+ }
251
+ /**
252
+ * Resize transformation options
253
+ */
254
+ export interface ResizeOptions extends TransformOptions {
255
+ /** Background color for fill fit */
256
+ background?: string;
257
+ /** Whether to skip enlargement during initial load */
258
+ fastShrinkOnLoad?: boolean;
259
+ /** Resize fit mode */
260
+ fit?: "cover" | "contain" | "fill" | "inside" | "outside";
261
+ /** Height in pixels */
262
+ height?: number;
263
+ /** Resize kernel */
264
+ kernel?: "nearest" | "cubic" | "mitchell" | "lanczos2" | "lanczos3";
265
+ /** Position for cover/contain fits */
266
+ position?: string | number;
267
+ /** Width in pixels */
268
+ width?: number;
269
+ /** Whether to avoid enlarging images smaller than specified dimensions */
270
+ withoutEnlargement?: boolean;
271
+ /** Whether to avoid reducing images larger than specified dimensions */
272
+ withoutReduction?: boolean;
273
+ }
274
+ /**
275
+ * Crop transformation options
276
+ */
277
+ export interface CropOptions extends TransformOptions {
278
+ /** Crop area height */
279
+ height: number;
280
+ /** Crop area left offset */
281
+ left: number;
282
+ /** Crop area top offset */
283
+ top: number;
284
+ /** Crop area width */
285
+ width: number;
286
+ }
287
+ /**
288
+ * Rotate transformation options
289
+ */
290
+ export interface RotateOptions extends TransformOptions {
291
+ /** Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect image quality */
292
+ angle: number;
293
+ /** Background color for rotation */
294
+ background?: string;
295
+ }
296
+ /**
297
+ * Transformation pipeline step
298
+ */
299
+ export interface TransformationStep {
300
+ 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;
301
+ 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";
302
+ }
303
+ /**
304
+ * Generic transformation pipeline step (for any media type)
305
+ */
306
+ export interface MediaTransformationStep {
307
+ 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;
308
+ 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";
309
+ }
310
+ /**
311
+ * Video transformation options
312
+ */
313
+ export interface VideoTransformOptions extends TransformOptions {
314
+ /** Video bitrate */
315
+ bitrate?: number;
316
+ /** Video codec */
317
+ codec?: "avc" | "hevc" | "vp8" | "vp9" | "av1";
318
+ /** Frame rate in Hz */
319
+ frameRate?: number;
320
+ /** Key frame interval in seconds */
321
+ keyFrameInterval?: number;
322
+ }
323
+ /**
324
+ * Audio transformation options
325
+ */
326
+ export interface AudioTransformOptions extends TransformOptions {
327
+ /** Audio bitrate */
328
+ bitrate?: number;
329
+ /** Audio codec */
330
+ codec?: "aac" | "opus" | "mp3" | "vorbis" | "flac";
331
+ /** Number of channels */
332
+ numberOfChannels?: number;
333
+ /** Sample rate in Hz */
334
+ sampleRate?: number;
335
+ }
336
+ /**
337
+ * Video resize transformation options
338
+ */
339
+ export interface VideoResizeOptions extends VideoTransformOptions {
340
+ /** Resize fit mode */
341
+ fit?: "cover" | "contain" | "fill" | "inside" | "outside";
342
+ /** Height in pixels */
343
+ height?: number;
344
+ /** Position for cover/contain fits */
345
+ position?: string | number;
346
+ /** Width in pixels */
347
+ width?: number;
348
+ /** Whether to avoid enlarging videos smaller than specified dimensions */
349
+ withoutEnlargement?: boolean;
350
+ /** Whether to avoid reducing videos larger than specified dimensions */
351
+ withoutReduction?: boolean;
352
+ }
353
+ /**
354
+ * Video crop transformation options
355
+ */
356
+ export interface VideoCropOptions extends VideoTransformOptions {
357
+ /** Crop area height */
358
+ height: number;
359
+ /** Crop area left offset */
360
+ left: number;
361
+ /** Crop area top offset */
362
+ top: number;
363
+ /** Crop area width */
364
+ width: number;
365
+ }
366
+ /**
367
+ * Video rotate transformation options
368
+ */
369
+ export interface VideoRotateOptions extends VideoTransformOptions {
370
+ /** Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect video quality */
371
+ angle: number;
372
+ /** Background color for rotation */
373
+ background?: string;
374
+ }
375
+ /**
376
+ * Audio channel mix transformation options
377
+ */
378
+ export interface AudioChannelMixOptions extends AudioTransformOptions {
379
+ /** Number of output channels */
380
+ numberOfChannels: number;
381
+ }
382
+ /**
383
+ * Audio resample transformation options
384
+ */
385
+ export interface AudioResampleOptions extends AudioTransformOptions {
386
+ /** Output sample rate in Hz */
387
+ sampleRate: number;
388
+ }
389
+ /**
390
+ * Video transformation pipeline step
391
+ */
392
+ export interface VideoTransformationStep {
393
+ options: VideoTransformOptions | VideoResizeOptions | VideoCropOptions | VideoRotateOptions;
394
+ type: "resize" | "crop" | "rotate" | "format" | "codec" | "bitrate" | "frameRate";
395
+ }
396
+ /**
397
+ * Audio transformation pipeline step
398
+ */
399
+ export interface AudioTransformationStep {
400
+ options: AudioTransformOptions | AudioChannelMixOptions | AudioResampleOptions;
401
+ type: "resample" | "channels" | "format" | "codec" | "bitrate";
402
+ }
403
+ /**
404
+ * Image transformation result
405
+ */
406
+ export interface TransformResult<TFileReturn extends FileReturn = FileReturn> {
407
+ /** Transformed image buffer */
408
+ buffer: Buffer;
409
+ /** Image format */
410
+ format: string;
411
+ /** Image height in pixels */
412
+ height: number;
413
+ /** Original file information */
414
+ originalFile: TFileReturn;
415
+ /** Image size in bytes */
416
+ size: number;
417
+ /** Image width in pixels */
418
+ width: number;
419
+ }
420
+ /**
421
+ * Video transformation result
422
+ */
423
+ export interface VideoTransformResult<TFileReturn extends FileReturn = FileReturn> extends TransformResult<TFileReturn> {
424
+ /** Video bitrate */
425
+ bitrate?: number;
426
+ /** Video duration in seconds */
427
+ duration: number;
428
+ }
429
+ /**
430
+ * Audio transformation result
431
+ */
432
+ export interface AudioTransformResult<TFileReturn extends FileReturn = FileReturn> extends Omit<TransformResult<TFileReturn>, "width" | "height"> {
433
+ /** Audio bitrate */
434
+ bitrate?: number;
435
+ /** Audio duration in seconds */
436
+ duration: number;
437
+ /** Number of channels */
438
+ numberOfChannels: number;
439
+ /** Sample rate in Hz */
440
+ sampleRate: number;
441
+ }
442
+ /**
443
+ * Media transformer configuration (unified config for all transformers)
444
+ */
445
+ export interface MediaTransformerConfig<TFile extends File = File, TFileReturn extends FileReturn = FileReturn> {
446
+ /** Default audio bitrate */
447
+ audioBitrate?: number;
448
+ /** Default audio codec */
449
+ audioCodec?: "aac" | "opus" | "mp3" | "vorbis" | "flac";
450
+ /** Audio transformer class (optional, enables audio transformations) */
451
+ AudioTransformer?: new (storage: BaseStorage<TFile, TFileReturn>, config: AudioTransformerConfig) => BaseTransformer<AudioTransformerConfig, AudioTransformResult<TFileReturn>, TFile, TFileReturn>;
452
+ /** Cache instance to use for caching */
453
+ cache?: Cache;
454
+ /** Cache TTL in seconds */
455
+ cacheTtl?: number;
456
+ /** Image transformer class (optional, enables image transformations) */
457
+ ImageTransformer?: new (storage: BaseStorage<TFile, TFileReturn>, config: ImageTransformerConfig) => BaseTransformer<ImageTransformerConfig, TransformResult<TFileReturn>, TFile, TFileReturn>;
458
+ /** Logger instance */
459
+ logger?: Console;
460
+ /** Maximum audio size to process (in bytes) */
461
+ maxAudioSize?: number;
462
+ /** Maximum image size to process (in bytes) */
463
+ maxImageSize?: number;
464
+ /** Maximum video size to process (in bytes) */
465
+ maxVideoSize?: number;
466
+ /** Save transformed files to storage for reuse */
467
+ saveTransformedFiles?: boolean;
468
+ /** Supported audio input formats */
469
+ supportedAudioFormats?: string[];
470
+ /** Supported image input formats */
471
+ supportedImageFormats?: string[];
472
+ /** Supported video input formats */
473
+ supportedVideoFormats?: string[];
474
+ /** Default video bitrate */
475
+ videoBitrate?: number;
476
+ /** Default video codec */
477
+ videoCodec?: "avc" | "hevc" | "vp8" | "vp9" | "av1";
478
+ /** Video transformer class (optional, enables video transformations) */
479
+ VideoTransformer?: new (storage: BaseStorage<TFile, TFileReturn>, config: VideoTransformerConfig) => BaseTransformer<VideoTransformerConfig, VideoTransformResult<TFileReturn>, TFile, TFileReturn>;
480
+ }
481
+ /**
482
+ * Unified media transformation result
483
+ */
484
+ export interface MediaTransformResult<TFileReturn extends FileReturn = FileReturn> {
485
+ /** Video-specific properties */
486
+ bitrate?: number;
487
+ /** Transformed media buffer */
488
+ buffer: Buffer;
489
+ /** Video/Audio-specific properties */
490
+ duration?: number;
491
+ /** Media format */
492
+ format: string;
493
+ /** Image/Video-specific properties */
494
+ height?: number;
495
+ /** Media type */
496
+ mediaType: "image" | "video" | "audio";
497
+ /** Audio-specific properties */
498
+ numberOfChannels?: number;
499
+ /** Original file information */
500
+ originalFile: TFileReturn;
501
+ /** Audio-specific properties */
502
+ sampleRate?: number;
503
+ /** Media size in bytes */
504
+ size: number;
505
+ /** Image-specific properties */
506
+ width?: number;
507
+ }
508
+ /**
509
+ * Query parameters for media transformation
510
+ */
511
+ export interface MediaTransformQuery {
512
+ /** Apply affine transformation */
513
+ affine?: boolean;
514
+ /** Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect media quality */
515
+ angle?: number;
516
+ /** Background color for rotation */
517
+ background?: string;
518
+ /** Video bitrate in bits per second */
519
+ bitrate?: number;
520
+ /** Apply blur effect */
521
+ blur?: boolean;
522
+ /** Brightness multiplier for modulation */
523
+ brightness?: number;
524
+ /** Apply CLAHE (Contrast Limited Adaptive Histogram Equalization) */
525
+ clahe?: boolean;
526
+ /** Video codec */
527
+ codec?: "avc" | "hevc" | "vp8" | "vp9" | "av1" | "aac" | "opus" | "mp3" | "vorbis" | "flac";
528
+ /** Crop area height */
529
+ cropHeight?: number;
530
+ /** Crop area width */
531
+ cropWidth?: number;
532
+ /** Apply dilation */
533
+ dilate?: boolean;
534
+ /** Ensure alpha channel */
535
+ ensureAlpha?: boolean;
536
+ /** Apply erosion */
537
+ erode?: boolean;
538
+ /** Fast shrink on load */
539
+ fastShrinkOnLoad?: boolean;
540
+ /** Resize fit mode */
541
+ fit?: "cover" | "contain" | "fill" | "inside" | "outside";
542
+ /** Flatten alpha channel */
543
+ flatten?: boolean;
544
+ /** Flip image vertically */
545
+ flip?: boolean;
546
+ /** Flop image horizontally */
547
+ flop?: boolean;
548
+ /** Output format */
549
+ format?: string;
550
+ /** Frame rate in Hz */
551
+ frameRate?: number;
552
+ /** Apply gamma correction */
553
+ gamma?: boolean;
554
+ /** Convert to greyscale */
555
+ greyscale?: boolean;
556
+ /** Height in pixels */
557
+ height?: number;
558
+ /** Hue rotation in degrees for modulation */
559
+ hue?: number;
560
+ /** Resize kernel */
561
+ kernel?: string;
562
+ /** Key frame interval in seconds */
563
+ keyFrameInterval?: number;
564
+ /** Crop area left offset */
565
+ left?: number;
566
+ /** Lightness adjustment for modulation */
567
+ lightness?: number;
568
+ /** Apply median filter with specified size */
569
+ median?: number;
570
+ /** Apply modulation effects */
571
+ modulate?: boolean;
572
+ /** Negate (invert) the image */
573
+ negate?: boolean;
574
+ /** Normalise the image */
575
+ normalise?: boolean;
576
+ /** Number of channels */
577
+ numberOfChannels?: number;
578
+ /** Set pipeline colourspace */
579
+ pipelineColourspace?: boolean;
580
+ /** Position for cover/contain fits */
581
+ position?: string | number;
582
+ /** Quality (0-100 for images, bitrate for video/audio) */
583
+ quality?: number;
584
+ /** Remove alpha channel */
585
+ removeAlpha?: boolean;
586
+ /** Sample rate in Hz */
587
+ sampleRate?: number;
588
+ /** Saturation multiplier for modulation */
589
+ saturation?: number;
590
+ /** Apply sharpening */
591
+ sharpen?: boolean;
592
+ /** Apply thresholding with specified value */
593
+ threshold?: number;
594
+ /** Apply tinting */
595
+ tint?: boolean;
596
+ /** Convert to colourspace */
597
+ toColourspace?: boolean;
598
+ /** Crop area top offset */
599
+ top?: number;
600
+ /** Unflatten alpha channel */
601
+ unflatten?: boolean;
602
+ /** Width in pixels */
603
+ width?: number;
604
+ /** Whether to avoid enlarging smaller images */
605
+ withoutEnlargement?: boolean;
606
+ /** Whether to avoid reducing larger images */
607
+ withoutReduction?: boolean;
608
+ }
609
+ /**
610
+ * Base transformer configuration with common properties
611
+ */
612
+ export interface BaseTransformerConfig {
613
+ /** Cache instance to use for caching */
614
+ cache?: Cache;
615
+ /** Cache TTL in seconds */
616
+ cacheTtl?: number;
617
+ /** Logger instance */
618
+ logger?: Console;
619
+ /** Maximum number of cached items */
620
+ maxCacheSize?: number;
621
+ /** Supported input formats */
622
+ supportedFormats?: string[] | undefined;
623
+ }
624
+ /**
625
+ * Image transformer configuration
626
+ */
627
+ export interface ImageTransformerConfig extends BaseTransformerConfig {
628
+ /** Maximum image size to process (in bytes) */
629
+ maxImageSize?: number;
630
+ }
631
+ /**
632
+ * Video transformer configuration
633
+ */
634
+ export interface VideoTransformerConfig extends BaseTransformerConfig {
635
+ /** Default video bitrate */
636
+ defaultBitrate?: number;
637
+ /** Default video codec */
638
+ defaultCodec?: "avc" | "hevc" | "vp8" | "vp9" | "av1";
639
+ /** Maximum video size to process (in bytes) */
640
+ maxVideoSize?: number;
641
+ }
642
+ /**
643
+ * Audio transformer configuration
644
+ */
645
+ export interface AudioTransformerConfig extends BaseTransformerConfig {
646
+ /** Default audio bitrate */
647
+ defaultBitrate?: number;
648
+ /** Default audio codec */
649
+ defaultCodec?: "aac" | "opus" | "mp3" | "vorbis" | "flac";
650
+ /** Maximum audio size to process (in bytes) */
651
+ maxAudioSize?: number;
652
+ }
@@ -0,0 +1,33 @@
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;