@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,975 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { createPaginationMetaSchemaObject, createPaginationSchemaObject } from '@visulima/pagination';
3
+ import { sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject } from './sharedGet-Cpo7QUyu.js';
4
+
5
+ const swaggerSpec = (path = "/", tags = ["Transform"]) => {
6
+ const pathHash = createHash("sha256").update(path).digest("base64");
7
+ return {
8
+ components: {
9
+ examples: sharedFileMetaExampleObject,
10
+ parameters: {
11
+ Affine: {
12
+ description: "Apply affine transformation",
13
+ in: "query",
14
+ name: "affine",
15
+ schema: {
16
+ type: "boolean"
17
+ }
18
+ },
19
+ Angle: {
20
+ description: "Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect quality",
21
+ in: "query",
22
+ name: "angle",
23
+ schema: {
24
+ type: "number"
25
+ }
26
+ },
27
+ Background: {
28
+ description: "Background color for rotation (hex, rgb, or color name)",
29
+ in: "query",
30
+ name: "background",
31
+ schema: {
32
+ type: "string"
33
+ }
34
+ },
35
+ Bitrate: {
36
+ description: "Target bitrate in bits per second",
37
+ in: "query",
38
+ name: "bitrate",
39
+ schema: {
40
+ minimum: 1,
41
+ type: "integer"
42
+ }
43
+ },
44
+ Blur: {
45
+ description: "Apply blur effect",
46
+ in: "query",
47
+ name: "blur",
48
+ schema: {
49
+ type: "boolean"
50
+ }
51
+ },
52
+ Brightness: {
53
+ description: "Brightness multiplier for modulation",
54
+ in: "query",
55
+ name: "brightness",
56
+ schema: {
57
+ type: "number"
58
+ }
59
+ },
60
+ Clahe: {
61
+ description: "Apply CLAHE (Contrast Limited Adaptive Histogram Equalization)",
62
+ in: "query",
63
+ name: "clahe",
64
+ schema: {
65
+ type: "boolean"
66
+ }
67
+ },
68
+ // Video/Audio parameters
69
+ Codec: {
70
+ description: "Video or audio codec",
71
+ in: "query",
72
+ name: "codec",
73
+ schema: {
74
+ enum: ["avc", "hevc", "vp8", "vp9", "av1", "aac", "opus", "mp3", "vorbis", "flac"],
75
+ type: "string"
76
+ }
77
+ },
78
+ Colourspace: {
79
+ description: "Convert colourspace",
80
+ in: "query",
81
+ name: "colourspace",
82
+ schema: {
83
+ enum: ["srgb", "rgb", "cmyk", "lab", "b-w"],
84
+ type: "string"
85
+ }
86
+ },
87
+ CropHeight: {
88
+ description: "Crop area height",
89
+ in: "query",
90
+ name: "cropHeight",
91
+ schema: {
92
+ minimum: 1,
93
+ type: "integer"
94
+ }
95
+ },
96
+ CropWidth: {
97
+ description: "Crop area width",
98
+ in: "query",
99
+ name: "cropWidth",
100
+ schema: {
101
+ minimum: 1,
102
+ type: "integer"
103
+ }
104
+ },
105
+ Dilate: {
106
+ description: "Apply dilation",
107
+ in: "query",
108
+ name: "dilate",
109
+ schema: {
110
+ type: "boolean"
111
+ }
112
+ },
113
+ EnsureAlpha: {
114
+ description: "Ensure alpha channel",
115
+ in: "query",
116
+ name: "ensureAlpha",
117
+ schema: {
118
+ type: "boolean"
119
+ }
120
+ },
121
+ Erode: {
122
+ description: "Apply erosion",
123
+ in: "query",
124
+ name: "erode",
125
+ schema: {
126
+ type: "boolean"
127
+ }
128
+ },
129
+ FastShrinkOnLoad: {
130
+ description: "Fast shrink on load for large images",
131
+ in: "query",
132
+ name: "fastShrinkOnLoad",
133
+ schema: {
134
+ type: "boolean"
135
+ }
136
+ },
137
+ FileID: {
138
+ description: "File identifier",
139
+ in: "path",
140
+ name: "id",
141
+ required: true,
142
+ schema: {
143
+ type: "string"
144
+ }
145
+ },
146
+ Fit: {
147
+ description: "Resize fit mode",
148
+ in: "query",
149
+ name: "fit",
150
+ schema: {
151
+ enum: ["cover", "contain", "fill", "inside", "outside"],
152
+ type: "string"
153
+ }
154
+ },
155
+ Flatten: {
156
+ description: "Flatten alpha channel",
157
+ in: "query",
158
+ name: "flatten",
159
+ schema: {
160
+ type: "boolean"
161
+ }
162
+ },
163
+ Flip: {
164
+ description: "Flip image vertically",
165
+ in: "query",
166
+ name: "flip",
167
+ schema: {
168
+ type: "boolean"
169
+ }
170
+ },
171
+ Flop: {
172
+ description: "Flop image horizontally",
173
+ in: "query",
174
+ name: "flop",
175
+ schema: {
176
+ type: "boolean"
177
+ }
178
+ },
179
+ // Common transformation parameters
180
+ Format: {
181
+ description: "Output format for the transformed media",
182
+ in: "query",
183
+ name: "format",
184
+ schema: {
185
+ enum: ["jpeg", "png", "webp", "avif", "tiff", "gif", "mp4", "webm", "mkv", "ogg", "mp3", "wav", "aac", "flac"],
186
+ type: "string"
187
+ }
188
+ },
189
+ FrameRate: {
190
+ description: "Video frame rate in Hz",
191
+ in: "query",
192
+ name: "frameRate",
193
+ schema: {
194
+ minimum: 1,
195
+ type: "number"
196
+ }
197
+ },
198
+ Gamma: {
199
+ description: "Apply gamma correction",
200
+ in: "query",
201
+ name: "gamma",
202
+ schema: {
203
+ type: "boolean"
204
+ }
205
+ },
206
+ Greyscale: {
207
+ description: "Convert to greyscale",
208
+ in: "query",
209
+ name: "greyscale",
210
+ schema: {
211
+ type: "boolean"
212
+ }
213
+ },
214
+ Height: {
215
+ description: "Desired height in pixels",
216
+ in: "query",
217
+ name: "height",
218
+ schema: {
219
+ minimum: 1,
220
+ type: "integer"
221
+ }
222
+ },
223
+ Hue: {
224
+ description: "Hue rotation in degrees for modulation",
225
+ in: "query",
226
+ name: "hue",
227
+ schema: {
228
+ type: "integer"
229
+ }
230
+ },
231
+ Kernel: {
232
+ description: "Resize kernel algorithm",
233
+ in: "query",
234
+ name: "kernel",
235
+ schema: {
236
+ enum: ["nearest", "cubic", "mitchell", "lanczos2", "lanczos3"],
237
+ type: "string"
238
+ }
239
+ },
240
+ KeyFrameInterval: {
241
+ description: "Video key frame interval in seconds",
242
+ in: "query",
243
+ name: "keyFrameInterval",
244
+ schema: {
245
+ minimum: 0.1,
246
+ type: "number"
247
+ }
248
+ },
249
+ // Crop parameters
250
+ Left: {
251
+ description: "Crop area left offset",
252
+ in: "query",
253
+ name: "left",
254
+ schema: {
255
+ minimum: 0,
256
+ type: "integer"
257
+ }
258
+ },
259
+ Lightness: {
260
+ description: "Lightness adjustment for modulation",
261
+ in: "query",
262
+ name: "lightness",
263
+ schema: {
264
+ type: "integer"
265
+ }
266
+ },
267
+ Median: {
268
+ description: "Apply median filter with specified size",
269
+ in: "query",
270
+ name: "median",
271
+ schema: {
272
+ minimum: 1,
273
+ type: "integer"
274
+ }
275
+ },
276
+ Modulate: {
277
+ description: "Apply modulation effects",
278
+ in: "query",
279
+ name: "modulate",
280
+ schema: {
281
+ type: "boolean"
282
+ }
283
+ },
284
+ Negate: {
285
+ description: "Negate (invert) the image",
286
+ in: "query",
287
+ name: "negate",
288
+ schema: {
289
+ type: "boolean"
290
+ }
291
+ },
292
+ Normalise: {
293
+ description: "Normalise the image",
294
+ in: "query",
295
+ name: "normalise",
296
+ schema: {
297
+ type: "boolean"
298
+ }
299
+ },
300
+ NumberOfChannels: {
301
+ description: "Audio channel count",
302
+ in: "query",
303
+ name: "numberOfChannels",
304
+ schema: {
305
+ enum: [1, 2, 3, 4, 5, 6, 7, 8],
306
+ type: "integer"
307
+ }
308
+ },
309
+ PipelineColourspace: {
310
+ description: "Set pipeline colourspace",
311
+ in: "query",
312
+ name: "pipelineColourspace",
313
+ schema: {
314
+ type: "boolean"
315
+ }
316
+ },
317
+ Position: {
318
+ description: "Position for cover/contain fits",
319
+ in: "query",
320
+ name: "position",
321
+ schema: {
322
+ oneOf: [
323
+ {
324
+ enum: ["top", "right", "bottom", "left", "center"],
325
+ type: "string"
326
+ },
327
+ {
328
+ minimum: 0,
329
+ type: "integer"
330
+ }
331
+ ]
332
+ }
333
+ },
334
+ Quality: {
335
+ description: "Quality setting (0-100 for images, affects compression)",
336
+ in: "query",
337
+ name: "quality",
338
+ schema: {
339
+ maximum: 100,
340
+ minimum: 1,
341
+ type: "integer"
342
+ }
343
+ },
344
+ RemoveAlpha: {
345
+ description: "Remove alpha channel",
346
+ in: "query",
347
+ name: "removeAlpha",
348
+ schema: {
349
+ type: "boolean"
350
+ }
351
+ },
352
+ SampleRate: {
353
+ description: "Audio sample rate in Hz",
354
+ in: "query",
355
+ name: "sampleRate",
356
+ schema: {
357
+ enum: [8e3, 11025, 16e3, 22050, 32e3, 44100, 48e3, 88200, 96e3, 192e3],
358
+ type: "integer"
359
+ }
360
+ },
361
+ Saturation: {
362
+ description: "Saturation multiplier for modulation",
363
+ in: "query",
364
+ name: "saturation",
365
+ schema: {
366
+ type: "number"
367
+ }
368
+ },
369
+ Sharpen: {
370
+ description: "Apply sharpening",
371
+ in: "query",
372
+ name: "sharpen",
373
+ schema: {
374
+ type: "boolean"
375
+ }
376
+ },
377
+ Threshold: {
378
+ description: "Apply thresholding with specified value (0-255)",
379
+ in: "query",
380
+ name: "threshold",
381
+ schema: {
382
+ maximum: 255,
383
+ minimum: 0,
384
+ type: "integer"
385
+ }
386
+ },
387
+ Tint: {
388
+ description: "Apply tinting",
389
+ in: "query",
390
+ name: "tint",
391
+ schema: {
392
+ type: "boolean"
393
+ }
394
+ },
395
+ ToColourspace: {
396
+ description: "Convert to colourspace",
397
+ in: "query",
398
+ name: "toColourspace",
399
+ schema: {
400
+ type: "boolean"
401
+ }
402
+ },
403
+ Top: {
404
+ description: "Crop area top offset",
405
+ in: "query",
406
+ name: "top",
407
+ schema: {
408
+ minimum: 0,
409
+ type: "integer"
410
+ }
411
+ },
412
+ Unflatten: {
413
+ description: "Unflatten alpha channel",
414
+ in: "query",
415
+ name: "unflatten",
416
+ schema: {
417
+ type: "boolean"
418
+ }
419
+ },
420
+ // Image transformation parameters
421
+ Width: {
422
+ description: "Desired width in pixels",
423
+ in: "query",
424
+ name: "width",
425
+ schema: {
426
+ minimum: 1,
427
+ type: "integer"
428
+ }
429
+ },
430
+ WithoutEnlargement: {
431
+ description: "Avoid enlarging images smaller than specified dimensions",
432
+ in: "query",
433
+ name: "withoutEnlargement",
434
+ schema: {
435
+ type: "boolean"
436
+ }
437
+ },
438
+ WithoutReduction: {
439
+ description: "Avoid reducing images larger than specified dimensions",
440
+ in: "query",
441
+ name: "withoutReduction",
442
+ schema: {
443
+ type: "boolean"
444
+ }
445
+ }
446
+ },
447
+ responses: {
448
+ 404: {
449
+ content: {
450
+ "application/json": {
451
+ schema: {
452
+ $ref: "#/components/schemas/Error"
453
+ }
454
+ }
455
+ },
456
+ description: "Not Found"
457
+ }
458
+ },
459
+ schemas: {
460
+ ...createPaginationSchemaObject(
461
+ "FileMetaPagination",
462
+ {
463
+ $ref: "#/components/schemas/PaginationMeta"
464
+ },
465
+ "#/components/schemas/PaginationMeta"
466
+ ),
467
+ ...createPaginationMetaSchemaObject("PaginationMeta"),
468
+ ...sharedErrorSchemaObject,
469
+ ...sharedFileMetaSchemaObject,
470
+ // Media transformation result
471
+ MediaTransformResult: {
472
+ description: "Result of media transformation",
473
+ properties: {
474
+ bitrate: {
475
+ description: "Bitrate for video/audio (bits per second)",
476
+ type: "integer"
477
+ },
478
+ buffer: {
479
+ description: "Binary data buffer (not included in JSON response)",
480
+ type: "string"
481
+ },
482
+ duration: {
483
+ description: "Duration for video/audio in seconds",
484
+ type: "number"
485
+ },
486
+ format: {
487
+ description: "Output format",
488
+ type: "string"
489
+ },
490
+ height: {
491
+ description: "Height for image/video in pixels",
492
+ type: "integer"
493
+ },
494
+ mediaType: {
495
+ description: "Type of media",
496
+ enum: ["image", "video", "audio"],
497
+ type: "string"
498
+ },
499
+ numberOfChannels: {
500
+ description: "Audio channel count",
501
+ type: "integer"
502
+ },
503
+ originalFile: {
504
+ $ref: "#/components/schemas/FileMeta"
505
+ },
506
+ sampleRate: {
507
+ description: "Audio sample rate in Hz",
508
+ type: "integer"
509
+ },
510
+ size: {
511
+ description: "File size in bytes",
512
+ type: "integer"
513
+ },
514
+ width: {
515
+ description: "Width for image/video in pixels",
516
+ type: "integer"
517
+ }
518
+ },
519
+ required: ["format", "mediaType", "originalFile", "size"],
520
+ type: "object"
521
+ },
522
+ // Validation error schema
523
+ ValidationError: {
524
+ description: "Validation error response",
525
+ properties: {
526
+ code: {
527
+ enum: [
528
+ "INVALID_PARAMS_FOR_IMAGE",
529
+ "INVALID_PARAMS_FOR_VIDEO",
530
+ "INVALID_PARAMS_FOR_AUDIO",
531
+ "INVALID_FIT_VALUE",
532
+ "INVALID_ANGLE_VALUE",
533
+ "INVALID_FORMAT",
534
+ "INCOMPLETE_CROP_PARAMS",
535
+ "INVALID_VIDEO_CODEC",
536
+ "INVALID_VIDEO_FORMAT",
537
+ "INVALID_WIDTH",
538
+ "INVALID_HEIGHT",
539
+ "INVALID_BITRATE",
540
+ "INVALID_FRAME_RATE",
541
+ "INVALID_KEY_FRAME_INTERVAL",
542
+ "INVALID_AUDIO_CODEC",
543
+ "INVALID_AUDIO_FORMAT",
544
+ "INVALID_CHANNEL_COUNT",
545
+ "INVALID_SAMPLE_RATE"
546
+ ],
547
+ type: "string"
548
+ },
549
+ details: {
550
+ properties: {
551
+ invalidParams: {
552
+ items: {
553
+ type: "string"
554
+ },
555
+ type: "array"
556
+ },
557
+ mediaType: {
558
+ enum: ["image", "video", "audio"],
559
+ type: "string"
560
+ },
561
+ suggestions: {
562
+ items: {
563
+ type: "string"
564
+ },
565
+ type: "array"
566
+ },
567
+ validParams: {
568
+ items: {
569
+ type: "string"
570
+ },
571
+ type: "array"
572
+ }
573
+ },
574
+ required: ["invalidParams", "validParams", "mediaType"],
575
+ type: "object"
576
+ },
577
+ message: {
578
+ type: "string"
579
+ },
580
+ name: {
581
+ enum: ["ValidationError"],
582
+ type: "string"
583
+ }
584
+ },
585
+ required: ["code", "details", "message", "name"],
586
+ type: "object"
587
+ }
588
+ }
589
+ },
590
+ paths: {
591
+ [`${path.replace(/\/$/, "")}/{id}/transform`]: {
592
+ get: {
593
+ description: "Get transformation metadata for a file without downloading. Returns information about supported transformations and current file properties.",
594
+ operationId: `${pathHash}TransformGetMetadata`,
595
+ parameters: [
596
+ {
597
+ $ref: "#/components/parameters/FileID"
598
+ }
599
+ ],
600
+ responses: {
601
+ 200: {
602
+ content: {
603
+ "application/json": {
604
+ schema: {
605
+ description: "File transformation metadata",
606
+ properties: {
607
+ bitrate: {
608
+ description: "Current bitrate for video/audio",
609
+ type: "integer"
610
+ },
611
+ dimensions: {
612
+ description: "Dimensions for image/video",
613
+ properties: {
614
+ height: {
615
+ type: "integer"
616
+ },
617
+ width: {
618
+ type: "integer"
619
+ }
620
+ },
621
+ type: "object"
622
+ },
623
+ duration: {
624
+ description: "Duration for video/audio in seconds",
625
+ type: "number"
626
+ },
627
+ mediaType: {
628
+ description: "Detected media type",
629
+ enum: ["image", "video", "audio"],
630
+ type: "string"
631
+ },
632
+ numberOfChannels: {
633
+ description: "Current channel count for audio",
634
+ type: "integer"
635
+ },
636
+ originalFormat: {
637
+ description: "Original file format",
638
+ type: "string"
639
+ },
640
+ sampleRate: {
641
+ description: "Current sample rate for audio",
642
+ type: "integer"
643
+ },
644
+ supportedFormats: {
645
+ description: "Supported output formats for this media type",
646
+ items: {
647
+ type: "string"
648
+ },
649
+ type: "array"
650
+ },
651
+ supportedParameters: {
652
+ description: "Supported transformation parameters",
653
+ items: {
654
+ type: "string"
655
+ },
656
+ type: "array"
657
+ }
658
+ },
659
+ required: ["mediaType", "supportedFormats", "supportedParameters"],
660
+ type: "object"
661
+ }
662
+ }
663
+ },
664
+ description: "Transformation metadata"
665
+ },
666
+ 404: {
667
+ $ref: "#/components/responses/404"
668
+ },
669
+ default: {
670
+ content: {
671
+ "application/json": {
672
+ schema: {
673
+ $ref: "#/components/schemas/Error"
674
+ }
675
+ }
676
+ },
677
+ description: "Error"
678
+ }
679
+ },
680
+ summary: "Get transformation metadata",
681
+ tags
682
+ }
683
+ },
684
+ [`${path.replace(/\/$/, "")}/{id}`]: {
685
+ get: {
686
+ description: "Retrieve and transform a file with optional media transformations. Supports resizing, cropping, format conversion, and codec changes based on query parameters.",
687
+ operationId: `${pathHash}TransformGetFile`,
688
+ parameters: [
689
+ {
690
+ $ref: "#/components/parameters/FileID"
691
+ },
692
+ // Common parameters
693
+ {
694
+ $ref: "#/components/parameters/Format"
695
+ },
696
+ {
697
+ $ref: "#/components/parameters/Quality"
698
+ },
699
+ // Image/Video parameters
700
+ {
701
+ $ref: "#/components/parameters/Width"
702
+ },
703
+ {
704
+ $ref: "#/components/parameters/Height"
705
+ },
706
+ {
707
+ $ref: "#/components/parameters/Fit"
708
+ },
709
+ {
710
+ $ref: "#/components/parameters/Position"
711
+ },
712
+ {
713
+ $ref: "#/components/parameters/WithoutEnlargement"
714
+ },
715
+ {
716
+ $ref: "#/components/parameters/WithoutReduction"
717
+ },
718
+ // Crop parameters
719
+ {
720
+ $ref: "#/components/parameters/Left"
721
+ },
722
+ {
723
+ $ref: "#/components/parameters/Top"
724
+ },
725
+ {
726
+ $ref: "#/components/parameters/CropWidth"
727
+ },
728
+ {
729
+ $ref: "#/components/parameters/CropHeight"
730
+ },
731
+ {
732
+ $ref: "#/components/parameters/Angle"
733
+ },
734
+ {
735
+ $ref: "#/components/parameters/Background"
736
+ },
737
+ // Resize parameters
738
+ {
739
+ $ref: "#/components/parameters/Kernel"
740
+ },
741
+ {
742
+ $ref: "#/components/parameters/FastShrinkOnLoad"
743
+ },
744
+ // Image operations
745
+ {
746
+ $ref: "#/components/parameters/Blur"
747
+ },
748
+ {
749
+ $ref: "#/components/parameters/Sharpen"
750
+ },
751
+ {
752
+ $ref: "#/components/parameters/Median"
753
+ },
754
+ {
755
+ $ref: "#/components/parameters/Clahe"
756
+ },
757
+ {
758
+ $ref: "#/components/parameters/Threshold"
759
+ },
760
+ {
761
+ $ref: "#/components/parameters/Gamma"
762
+ },
763
+ {
764
+ $ref: "#/components/parameters/Negate"
765
+ },
766
+ {
767
+ $ref: "#/components/parameters/Normalise"
768
+ },
769
+ {
770
+ $ref: "#/components/parameters/Flatten"
771
+ },
772
+ {
773
+ $ref: "#/components/parameters/Unflatten"
774
+ },
775
+ {
776
+ $ref: "#/components/parameters/Flip"
777
+ },
778
+ {
779
+ $ref: "#/components/parameters/Flop"
780
+ },
781
+ {
782
+ $ref: "#/components/parameters/Greyscale"
783
+ },
784
+ {
785
+ $ref: "#/components/parameters/Modulate"
786
+ },
787
+ {
788
+ $ref: "#/components/parameters/Brightness"
789
+ },
790
+ {
791
+ $ref: "#/components/parameters/Saturation"
792
+ },
793
+ {
794
+ $ref: "#/components/parameters/Hue"
795
+ },
796
+ {
797
+ $ref: "#/components/parameters/Lightness"
798
+ },
799
+ {
800
+ $ref: "#/components/parameters/Tint"
801
+ },
802
+ {
803
+ $ref: "#/components/parameters/Colourspace"
804
+ },
805
+ {
806
+ $ref: "#/components/parameters/Affine"
807
+ },
808
+ {
809
+ $ref: "#/components/parameters/Dilate"
810
+ },
811
+ {
812
+ $ref: "#/components/parameters/Erode"
813
+ },
814
+ {
815
+ $ref: "#/components/parameters/PipelineColourspace"
816
+ },
817
+ {
818
+ $ref: "#/components/parameters/ToColourspace"
819
+ },
820
+ {
821
+ $ref: "#/components/parameters/RemoveAlpha"
822
+ },
823
+ {
824
+ $ref: "#/components/parameters/EnsureAlpha"
825
+ },
826
+ // Video/Audio parameters
827
+ {
828
+ $ref: "#/components/parameters/Codec"
829
+ },
830
+ {
831
+ $ref: "#/components/parameters/Bitrate"
832
+ },
833
+ {
834
+ $ref: "#/components/parameters/FrameRate"
835
+ },
836
+ {
837
+ $ref: "#/components/parameters/KeyFrameInterval"
838
+ },
839
+ {
840
+ $ref: "#/components/parameters/NumberOfChannels"
841
+ },
842
+ {
843
+ $ref: "#/components/parameters/SampleRate"
844
+ }
845
+ ],
846
+ responses: {
847
+ 200: {
848
+ content: {
849
+ "*/*": {
850
+ schema: {
851
+ description: "Transformed media file",
852
+ format: "binary",
853
+ type: "string"
854
+ }
855
+ }
856
+ },
857
+ description: "Transformed file returned successfully",
858
+ headers: {
859
+ "Content-Type": {
860
+ description: "MIME type of the transformed file",
861
+ schema: {
862
+ type: "string"
863
+ }
864
+ },
865
+ ETag: {
866
+ description: "ETag of the transformed file",
867
+ schema: {
868
+ type: "string"
869
+ }
870
+ },
871
+ "X-Media-Type": {
872
+ description: "Type of media (image/video/audio)",
873
+ schema: {
874
+ enum: ["image", "video", "audio"],
875
+ type: "string"
876
+ }
877
+ },
878
+ "X-Original-Format": {
879
+ description: "Original file format",
880
+ schema: {
881
+ type: "string"
882
+ }
883
+ },
884
+ "X-Transformed-Format": {
885
+ description: "Transformed file format",
886
+ schema: {
887
+ type: "string"
888
+ }
889
+ }
890
+ }
891
+ },
892
+ 400: {
893
+ content: {
894
+ "application/json": {
895
+ examples: {
896
+ ValidationError: {
897
+ value: {
898
+ error: {
899
+ code: "INVALID_PARAMS_FOR_IMAGE",
900
+ details: {
901
+ invalidParams: ["codec", "bitrate"],
902
+ mediaType: "image",
903
+ validParams: [
904
+ "format",
905
+ "quality",
906
+ "width",
907
+ "height",
908
+ "fit",
909
+ "position",
910
+ "withoutEnlargement",
911
+ "withoutReduction",
912
+ "left",
913
+ "top",
914
+ "cropWidth",
915
+ "cropHeight",
916
+ "angle",
917
+ "background"
918
+ ]
919
+ },
920
+ message: "Invalid query parameters for image transformation: codec, bitrate. Images support: format, quality, width, height, fit, position, withoutEnlargement, withoutReduction, left, top, cropWidth, cropHeight, angle, background. Video/audio parameters (codec, bitrate) are not supported for images.",
921
+ name: "ValidationError"
922
+ }
923
+ }
924
+ }
925
+ },
926
+ schema: {
927
+ $ref: "#/components/schemas/ValidationError"
928
+ }
929
+ }
930
+ },
931
+ description: "Invalid transformation parameters"
932
+ },
933
+ 404: {
934
+ $ref: "#/components/responses/404"
935
+ },
936
+ 413: {
937
+ content: {
938
+ "application/json": {
939
+ schema: {
940
+ $ref: "#/components/schemas/Error"
941
+ }
942
+ }
943
+ },
944
+ description: "File too large for transformation"
945
+ },
946
+ 415: {
947
+ content: {
948
+ "application/json": {
949
+ schema: {
950
+ $ref: "#/components/schemas/Error"
951
+ }
952
+ }
953
+ },
954
+ description: "Unsupported media type for transformation"
955
+ },
956
+ default: {
957
+ content: {
958
+ "application/json": {
959
+ schema: {
960
+ $ref: "#/components/schemas/Error"
961
+ }
962
+ }
963
+ },
964
+ description: "Error"
965
+ }
966
+ },
967
+ summary: "Transform and retrieve file",
968
+ tags
969
+ }
970
+ }
971
+ }
972
+ };
973
+ };
974
+
975
+ export { swaggerSpec as default };