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

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 (225) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/LICENSE.md +6 -6
  3. package/README.md +33 -14
  4. package/dist/adapter/nuxt/module.d.ts +39 -0
  5. package/dist/adapter/nuxt/module.js +93 -0
  6. package/dist/adapter/nuxt/package.json +20 -0
  7. package/dist/handler/base/base-handler-core.d.ts +91 -0
  8. package/dist/handler/base/base-handler-fetch.d.ts +76 -0
  9. package/dist/handler/base/base-handler-node.d.ts +137 -0
  10. package/dist/handler/http/fetch/index.d.ts +4 -0
  11. package/dist/handler/http/fetch/index.js +4 -0
  12. package/dist/handler/http/hono/index.d.ts +67 -0
  13. package/dist/handler/http/hono/index.js +65 -0
  14. package/dist/handler/http/nextjs/index.d.ts +61 -0
  15. package/dist/handler/http/nextjs/index.js +37 -0
  16. package/dist/handler/http/node/index.d.ts +4 -0
  17. package/dist/handler/http/node/index.js +8 -0
  18. package/dist/handler/http/solid-start/index.d.ts +60 -0
  19. package/dist/handler/http/solid-start/index.js +44 -0
  20. package/dist/handler/multipart/multipart-base.d.ts +84 -0
  21. package/dist/handler/multipart/multipart-fetch.d.ts +64 -0
  22. package/dist/handler/multipart/multipart.d.ts +49 -0
  23. package/dist/handler/rest/rest-base.d.ts +106 -0
  24. package/dist/handler/rest/rest-fetch.d.ts +88 -0
  25. package/dist/handler/rest/rest.d.ts +93 -0
  26. package/dist/handler/tus/tus-base.d.ts +152 -0
  27. package/dist/handler/tus/tus-fetch.d.ts +72 -0
  28. package/dist/handler/tus/tus.d.ts +78 -0
  29. package/dist/handler/types.d.ts +53 -0
  30. package/dist/handler/utils/request-parser.d.ts +72 -0
  31. package/dist/handler/utils/response-builder.d.ts +83 -0
  32. package/dist/handler/utils/storage-utils.d.ts +10 -0
  33. package/dist/handler/utils/stream-utils.d.ts +29 -0
  34. package/dist/handler/utils/upload-handlers.d.ts +76 -0
  35. package/dist/index.d.ts +17 -0
  36. package/dist/index.js +13 -0
  37. package/dist/metrics/index.d.ts +2 -0
  38. package/dist/metrics/no-op-metrics.d.ts +15 -0
  39. package/dist/metrics/opentelemetry-metrics.d.ts +55 -0
  40. package/dist/openapi/index.d.ts +5 -0
  41. package/dist/openapi/index.js +5 -0
  42. package/dist/openapi/rest.d.ts +7 -0
  43. package/dist/openapi/shared.d.ts +13 -0
  44. package/dist/openapi/transform.d.ts +3 -0
  45. package/dist/openapi/tus.d.ts +7 -0
  46. package/dist/openapi/xhr.d.ts +7 -0
  47. package/dist/packem_shared/AwsLightFile-tTneXZgG.js +11 -0
  48. package/dist/packem_shared/AwsLightMetaStorage-D9qWQt6q.js +4 -0
  49. package/dist/packem_shared/AwsLightStorage-CEJTYBVv.js +133 -0
  50. package/dist/packem_shared/AzureFile-CesgFzps.js +8 -0
  51. package/dist/packem_shared/AzureSMetaStorage-BEbXX9Uk.js +89 -0
  52. package/dist/packem_shared/AzureStorage-CH6nvQx8.js +357 -0
  53. package/dist/packem_shared/BaseTransformer-9965D4pb.js +83 -0
  54. package/dist/packem_shared/DiskStorage-DziI2mwX.js +12 -0
  55. package/dist/packem_shared/DiskStorageWithChecksum-B_XY8_cO.js +240 -0
  56. package/dist/packem_shared/ERRORS-D0apMqnc.js +97 -0
  57. package/dist/packem_shared/File-Bb3P23dr.js +69 -0
  58. package/dist/packem_shared/GCSConfig-vPP22kN6.js +11 -0
  59. package/dist/packem_shared/GCSFile-BIEunhAN.js +8 -0
  60. package/dist/packem_shared/GCSMetaStorage-FypK8Tn1.js +7 -0
  61. package/dist/packem_shared/GCStorage-CasTo9rF.js +408 -0
  62. package/dist/packem_shared/LocalMetaStorage-BnllcjV9.js +7 -0
  63. package/dist/packem_shared/MediaTransformer-BErvw2vE.js +1196 -0
  64. package/dist/packem_shared/MetaStorage-pECeFOad.js +46 -0
  65. package/dist/packem_shared/Metadata-DRLXeJ0F.js +89 -0
  66. package/dist/packem_shared/Multipart-CDDlDOs7.js +163 -0
  67. package/dist/packem_shared/Multipart-vxBL2VXm.js +128 -0
  68. package/dist/packem_shared/NetlifyBlobFile-CXzyjqrD.js +14 -0
  69. package/dist/packem_shared/NetlifyBlobMetaStorage-DIkZ2umW.js +9 -0
  70. package/dist/packem_shared/NetlifyBlobStorage-DEpx_4q-.js +376 -0
  71. package/dist/packem_shared/NoOpMetrics-DhAk5rXc.js +10 -0
  72. package/dist/packem_shared/OpenTelemetryMetrics-BnxhqIaH.js +67 -0
  73. package/dist/packem_shared/Rest-CEj3EhMj.js +228 -0
  74. package/dist/packem_shared/Rest-D14vM7aJ.js +267 -0
  75. package/dist/packem_shared/S3File-DZiyk9Qt.js +11 -0
  76. package/dist/packem_shared/S3MetaStorage-yT4CznlV.js +77 -0
  77. package/dist/packem_shared/S3Storage-B0scgwPa.js +317 -0
  78. package/dist/packem_shared/TUS_RESUMABLE-Dtfsffnj.js +434 -0
  79. package/dist/packem_shared/Tus-Cjz87bpz.js +200 -0
  80. package/dist/packem_shared/Tus-WOVg-YnB.js +195 -0
  81. package/dist/packem_shared/ValidationError-BfF1aE4h.js +26 -0
  82. package/dist/packem_shared/VercelBlobFile-BCg4aTEq.js +18 -0
  83. package/dist/packem_shared/VercelBlobMetaStorage-c0M-TvAR.js +9 -0
  84. package/dist/packem_shared/VercelBlobStorage-wOYxv8F7.js +261 -0
  85. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
  86. package/dist/packem_shared/aws-light-meta-storage-Ba2b_h-o.js +447 -0
  87. package/dist/packem_shared/backblaze-BlMnIcBC.js +20 -0
  88. package/dist/packem_shared/base-handler-core-BoAqTyz7.js +303 -0
  89. package/dist/packem_shared/base-handler-fetch-CinvR65S.js +291 -0
  90. package/dist/packem_shared/base-handler-node-c02H0AxN.js +731 -0
  91. package/dist/packem_shared/cache-B88MXQ_2.js +18 -0
  92. package/dist/packem_shared/cloudflare-Bi1q8wXE.js +21 -0
  93. package/dist/packem_shared/defaultCloudStorageFileNameValidation-CGoYrGB2.js +11 -0
  94. package/dist/packem_shared/digitalOcean-CWQRJM3L.js +21 -0
  95. package/dist/packem_shared/disk-storage-DeivH-J5.js +816 -0
  96. package/dist/packem_shared/gcs-meta-storage-B0Baj0Xr.js +159 -0
  97. package/dist/packem_shared/has-content-CY66ehMK.js +3 -0
  98. package/dist/packem_shared/headers-YLRp1dLo.js +1318 -0
  99. package/dist/packem_shared/is-expired-CTThU1q5.js +8 -0
  100. package/dist/packem_shared/isRetryableError-Dycp7127.js +82 -0
  101. package/dist/packem_shared/isValidMediaType-BeDgiObq.js +35 -0
  102. package/dist/packem_shared/local-meta-storage-BlOk6m7F.js +647 -0
  103. package/dist/packem_shared/minio-C2YBZQOw.js +22 -0
  104. package/dist/packem_shared/multipart-base-C994naBi.js +102 -0
  105. package/dist/packem_shared/part-match-BMNqHDYD.js +96 -0
  106. package/dist/packem_shared/path-aV9lMdcn-DMU5H1-h.js +162 -0
  107. package/dist/packem_shared/response-builder-BtnRiBUI.js +45 -0
  108. package/dist/packem_shared/rest-base-D9URIFkc.js +457 -0
  109. package/dist/packem_shared/restOpenApiSpec-D1zbmid7.js +800 -0
  110. package/dist/packem_shared/s3-base-storage-CG21uusd.js +513 -0
  111. package/dist/packem_shared/sharedGet-DAyJfjhl.js +1018 -0
  112. package/dist/packem_shared/storage-CpJpqLdn.js +1184 -0
  113. package/dist/packem_shared/tigris-Hac8TKnX.js +21 -0
  114. package/dist/packem_shared/transformOpenApiSpec-BC0r6PzI.js +975 -0
  115. package/dist/packem_shared/tusOpenApiSpec-BLIjKf0s.js +740 -0
  116. package/dist/packem_shared/update-size-CCGm6i1J.js +8 -0
  117. package/dist/packem_shared/validator-DuO17wFF.js +79 -0
  118. package/dist/packem_shared/waitForStorage-Cscw85sx.js +18 -0
  119. package/dist/packem_shared/wasabi-DIyflHSd.js +21 -0
  120. package/dist/packem_shared/xhrOpenApiSpec-kItrSAsc.js +264 -0
  121. package/dist/storage/aws/clients/backblaze.d.ts +12 -0
  122. package/dist/storage/aws/clients/cloudflare.d.ts +13 -0
  123. package/dist/storage/aws/clients/digital-ocean.d.ts +12 -0
  124. package/dist/storage/aws/clients/index.d.ts +6 -0
  125. package/dist/storage/aws/clients/index.js +6 -0
  126. package/dist/storage/aws/clients/minio.d.ts +13 -0
  127. package/dist/storage/aws/clients/tigris.d.ts +12 -0
  128. package/dist/storage/aws/clients/types.d.ts +95 -0
  129. package/dist/storage/aws/clients/wasabi.d.ts +12 -0
  130. package/dist/storage/aws/index.d.ts +4 -0
  131. package/dist/storage/aws/index.js +3 -0
  132. package/dist/storage/aws/s3-base-storage.d.ts +248 -0
  133. package/dist/storage/aws/s3-client-adapter.d.ts +110 -0
  134. package/dist/storage/aws/s3-file.d.ts +10 -0
  135. package/dist/storage/aws/s3-meta-storage.d.ts +15 -0
  136. package/dist/storage/aws/s3-storage.d.ts +70 -0
  137. package/dist/storage/aws/types.d.ts +119 -0
  138. package/dist/storage/aws-light/aws-light-api-adapter.d.ts +130 -0
  139. package/dist/storage/aws-light/aws-light-file.d.ts +10 -0
  140. package/dist/storage/aws-light/aws-light-meta-storage.d.ts +19 -0
  141. package/dist/storage/aws-light/aws-light-storage.d.ts +65 -0
  142. package/dist/storage/aws-light/index.d.ts +4 -0
  143. package/dist/storage/aws-light/index.js +3 -0
  144. package/dist/storage/aws-light/types.d.ts +37 -0
  145. package/dist/storage/azure/azure-file.d.ts +6 -0
  146. package/dist/storage/azure/azure-meta-storage.d.ts +15 -0
  147. package/dist/storage/azure/azure-storage.d.ts +69 -0
  148. package/dist/storage/azure/index.d.ts +4 -0
  149. package/dist/storage/azure/index.js +3 -0
  150. package/dist/storage/azure/types.d.ts +62 -0
  151. package/dist/storage/gcs/fetch-error.d.ts +11 -0
  152. package/dist/storage/gcs/gcs-config.d.ts +2 -0
  153. package/dist/storage/gcs/gcs-file.d.ts +6 -0
  154. package/dist/storage/gcs/gcs-meta-storage.d.ts +27 -0
  155. package/dist/storage/gcs/gcs-storage.d.ts +91 -0
  156. package/dist/storage/gcs/index.d.ts +5 -0
  157. package/dist/storage/gcs/index.js +4 -0
  158. package/dist/storage/gcs/types.d.ts +55 -0
  159. package/dist/storage/gcs/utils.d.ts +7 -0
  160. package/dist/storage/local/disk-storage-with-checksum.d.ts +15 -0
  161. package/dist/storage/local/disk-storage.d.ts +135 -0
  162. package/dist/storage/local/index.d.ts +4 -0
  163. package/dist/storage/local/index.js +3 -0
  164. package/dist/storage/local/local-meta-storage.d.ts +32 -0
  165. package/dist/storage/meta-storage.d.ts +30 -0
  166. package/dist/storage/netlify-blob/index.d.ts +4 -0
  167. package/dist/storage/netlify-blob/index.js +3 -0
  168. package/dist/storage/netlify-blob/netlify-blob-file.d.ts +12 -0
  169. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +7 -0
  170. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +93 -0
  171. package/dist/storage/netlify-blob/types.d.ts +30 -0
  172. package/dist/storage/storage.d.ts +353 -0
  173. package/dist/storage/types.d.ts +221 -0
  174. package/dist/storage/utils/file/file.d.ts +25 -0
  175. package/dist/storage/utils/file/get-file-status.d.ts +9 -0
  176. package/dist/storage/utils/file/has-content.d.ts +9 -0
  177. package/dist/storage/utils/file/index.d.ts +10 -0
  178. package/dist/storage/utils/file/is-expired.d.ts +8 -0
  179. package/dist/storage/utils/file/metadata.d.ts +18 -0
  180. package/dist/storage/utils/file/part-match.d.ts +11 -0
  181. package/dist/storage/utils/file/types.d.ts +37 -0
  182. package/dist/storage/utils/file/update-metadata.d.ts +10 -0
  183. package/dist/storage/utils/file/update-size.d.ts +10 -0
  184. package/dist/storage/vercel-blob/index.d.ts +4 -0
  185. package/dist/storage/vercel-blob/index.js +3 -0
  186. package/dist/storage/vercel-blob/types.d.ts +32 -0
  187. package/dist/storage/vercel-blob/vercel-blob-file.d.ts +16 -0
  188. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +7 -0
  189. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +76 -0
  190. package/dist/transformer/audio-transformer.d.ts +128 -0
  191. package/dist/transformer/audio-transformer.js +278 -0
  192. package/dist/transformer/base-transformer.d.ts +63 -0
  193. package/dist/transformer/image-transformer.d.ts +571 -0
  194. package/dist/transformer/image-transformer.js +1100 -0
  195. package/dist/transformer/index.d.ts +5 -0
  196. package/dist/transformer/index.js +4 -0
  197. package/dist/transformer/media-transformer.d.ts +332 -0
  198. package/dist/transformer/types.d.ts +652 -0
  199. package/dist/transformer/utils.d.ts +33 -0
  200. package/dist/transformer/validation-error.d.ts +23 -0
  201. package/dist/transformer/video-transformer.d.ts +145 -0
  202. package/dist/transformer/video-transformer.js +310 -0
  203. package/dist/utils/cache.d.ts +32 -0
  204. package/dist/utils/chunked-upload.d.ts +65 -0
  205. package/dist/utils/detect-file-type.d.ts +28 -0
  206. package/dist/utils/errors.d.ts +74 -0
  207. package/dist/utils/file-path-url-matcher.d.ts +18 -0
  208. package/dist/utils/headers.d.ts +111 -0
  209. package/dist/utils/http.d.ts +92 -0
  210. package/dist/utils/locker.d.ts +26 -0
  211. package/dist/utils/pipes/stream-checksum.d.ts +47 -0
  212. package/dist/utils/pipes/stream-length.d.ts +22 -0
  213. package/dist/utils/primitives/get-last-one.d.ts +3 -0
  214. package/dist/utils/primitives/is-record.d.ts +2 -0
  215. package/dist/utils/primitives/map-values.d.ts +9 -0
  216. package/dist/utils/primitives/pick.d.ts +2 -0
  217. package/dist/utils/primitives/to-milliseconds.d.ts +12 -0
  218. package/dist/utils/primitives/to-seconds.d.ts +12 -0
  219. package/dist/utils/range-checksum.d.ts +33 -0
  220. package/dist/utils/range-hasher.d.ts +46 -0
  221. package/dist/utils/retry.d.ts +64 -0
  222. package/dist/utils/types.d.ts +108 -0
  223. package/dist/utils/validation-error.d.ts +22 -0
  224. package/dist/utils/validator.d.ts +36 -0
  225. package/package.json +9 -9
@@ -0,0 +1,1018 @@
1
+ const FileMetaExample = {
2
+ value: {
3
+ createdAt: "2022-12-16T10:35:17.466Z",
4
+ id: "391c9157ec481ac6-f72b2d884632d7e6-cdeb2056546033e3",
5
+ modifiedAt: "2022-12-16T10:35:17.470Z"
6
+ }
7
+ };
8
+ const createParameterGroup = (parameters, groupName) => parameters.map((parameter) => {
9
+ return {
10
+ ...parameter,
11
+ description: `[${groupName}] ${parameter.description}`,
12
+ // Add extension for better tooling support
13
+ "x-group": groupName
14
+ };
15
+ });
16
+ const getTransformationParameters = (transform, format = ["jpeg", "png", "webp", "avif", "tiff", "gif", "mp4", "webm", "mkv", "ogg", "mp3", "wav", "aac", "flac"]) => {
17
+ if (!transform) {
18
+ return [];
19
+ }
20
+ const commonParameters = createParameterGroup(
21
+ [
22
+ {
23
+ description: "Output format for the transformed media",
24
+ in: "query",
25
+ name: "format",
26
+ schema: {
27
+ enum: format,
28
+ type: "string"
29
+ }
30
+ },
31
+ {
32
+ description: "Quality setting (0-100 for images, affects compression)",
33
+ in: "query",
34
+ name: "quality",
35
+ schema: {
36
+ maximum: 100,
37
+ minimum: 1,
38
+ type: "integer"
39
+ }
40
+ }
41
+ ],
42
+ "Common"
43
+ );
44
+ const imageParameters = createParameterGroup(
45
+ [
46
+ {
47
+ description: "Desired width in pixels",
48
+ in: "query",
49
+ name: "width",
50
+ schema: {
51
+ minimum: 1,
52
+ type: "integer"
53
+ }
54
+ },
55
+ {
56
+ description: "Desired height in pixels",
57
+ in: "query",
58
+ name: "height",
59
+ schema: {
60
+ minimum: 1,
61
+ type: "integer"
62
+ }
63
+ },
64
+ {
65
+ description: "Resize fit mode",
66
+ in: "query",
67
+ name: "fit",
68
+ schema: {
69
+ enum: ["cover", "contain", "fill", "inside", "outside"],
70
+ type: "string"
71
+ }
72
+ },
73
+ {
74
+ description: "Position for cover/contain fits",
75
+ in: "query",
76
+ name: "position",
77
+ schema: {
78
+ oneOf: [
79
+ {
80
+ enum: ["top", "right", "bottom", "left", "center"],
81
+ type: "string"
82
+ },
83
+ {
84
+ minimum: 0,
85
+ type: "integer"
86
+ }
87
+ ]
88
+ }
89
+ },
90
+ {
91
+ description: "Avoid enlarging images smaller than specified dimensions",
92
+ in: "query",
93
+ name: "withoutEnlargement",
94
+ schema: {
95
+ type: "boolean"
96
+ }
97
+ },
98
+ {
99
+ description: "Avoid reducing images larger than specified dimensions",
100
+ in: "query",
101
+ name: "withoutReduction",
102
+ schema: {
103
+ type: "boolean"
104
+ }
105
+ },
106
+ {
107
+ description: "Resize kernel algorithm",
108
+ in: "query",
109
+ name: "kernel",
110
+ schema: {
111
+ enum: ["nearest", "cubic", "mitchell", "lanczos2", "lanczos3"],
112
+ type: "string"
113
+ }
114
+ },
115
+ {
116
+ description: "Fast shrink on load for large images",
117
+ in: "query",
118
+ name: "fastShrinkOnLoad",
119
+ schema: {
120
+ type: "boolean"
121
+ }
122
+ },
123
+ // Crop parameters
124
+ {
125
+ description: "Crop area left offset",
126
+ in: "query",
127
+ name: "left",
128
+ schema: {
129
+ minimum: 0,
130
+ type: "integer"
131
+ }
132
+ },
133
+ {
134
+ description: "Crop area top offset",
135
+ in: "query",
136
+ name: "top",
137
+ schema: {
138
+ minimum: 0,
139
+ type: "integer"
140
+ }
141
+ },
142
+ {
143
+ description: "Crop area width",
144
+ in: "query",
145
+ name: "cropWidth",
146
+ schema: {
147
+ minimum: 1,
148
+ type: "integer"
149
+ }
150
+ },
151
+ {
152
+ description: "Crop area height",
153
+ in: "query",
154
+ name: "cropHeight",
155
+ schema: {
156
+ minimum: 1,
157
+ type: "integer"
158
+ }
159
+ },
160
+ {
161
+ description: "Rotation angle in degrees. Note: angles other than 90°, 180°, and 270° require interpolation and may affect quality",
162
+ in: "query",
163
+ name: "angle",
164
+ schema: {
165
+ type: "number"
166
+ }
167
+ },
168
+ {
169
+ description: "Background color for rotation (hex, rgb, or color name)",
170
+ in: "query",
171
+ name: "background",
172
+ schema: {
173
+ type: "string"
174
+ }
175
+ },
176
+ // Image operations
177
+ {
178
+ description: "Apply blur effect",
179
+ in: "query",
180
+ name: "blur",
181
+ schema: {
182
+ type: "boolean"
183
+ }
184
+ },
185
+ {
186
+ description: "Apply sharpening",
187
+ in: "query",
188
+ name: "sharpen",
189
+ schema: {
190
+ type: "boolean"
191
+ }
192
+ },
193
+ {
194
+ description: "Apply median filter with specified size",
195
+ in: "query",
196
+ name: "median",
197
+ schema: {
198
+ minimum: 1,
199
+ type: "integer"
200
+ }
201
+ },
202
+ {
203
+ description: "Apply CLAHE (Contrast Limited Adaptive Histogram Equalization)",
204
+ in: "query",
205
+ name: "clahe",
206
+ schema: {
207
+ type: "boolean"
208
+ }
209
+ },
210
+ {
211
+ description: "Apply thresholding with specified value (0-255)",
212
+ in: "query",
213
+ name: "threshold",
214
+ schema: {
215
+ maximum: 255,
216
+ minimum: 0,
217
+ type: "integer"
218
+ }
219
+ },
220
+ {
221
+ description: "Apply gamma correction",
222
+ in: "query",
223
+ name: "gamma",
224
+ schema: {
225
+ type: "boolean"
226
+ }
227
+ },
228
+ {
229
+ description: "Negate (invert) the image",
230
+ in: "query",
231
+ name: "negate",
232
+ schema: {
233
+ type: "boolean"
234
+ }
235
+ },
236
+ {
237
+ description: "Normalise the image",
238
+ in: "query",
239
+ name: "normalise",
240
+ schema: {
241
+ type: "boolean"
242
+ }
243
+ },
244
+ {
245
+ description: "Flatten alpha channel",
246
+ in: "query",
247
+ name: "flatten",
248
+ schema: {
249
+ type: "boolean"
250
+ }
251
+ },
252
+ {
253
+ description: "Unflatten alpha channel",
254
+ in: "query",
255
+ name: "unflatten",
256
+ schema: {
257
+ type: "boolean"
258
+ }
259
+ },
260
+ {
261
+ description: "Flip image vertically",
262
+ in: "query",
263
+ name: "flip",
264
+ schema: {
265
+ type: "boolean"
266
+ }
267
+ },
268
+ {
269
+ description: "Flop image horizontally",
270
+ in: "query",
271
+ name: "flop",
272
+ schema: {
273
+ type: "boolean"
274
+ }
275
+ },
276
+ {
277
+ description: "Convert to greyscale",
278
+ in: "query",
279
+ name: "greyscale",
280
+ schema: {
281
+ type: "boolean"
282
+ }
283
+ },
284
+ {
285
+ description: "Apply modulation effects",
286
+ in: "query",
287
+ name: "modulate",
288
+ schema: {
289
+ type: "boolean"
290
+ }
291
+ },
292
+ {
293
+ description: "Brightness multiplier for modulation",
294
+ in: "query",
295
+ name: "brightness",
296
+ schema: {
297
+ type: "number"
298
+ }
299
+ },
300
+ {
301
+ description: "Saturation multiplier for modulation",
302
+ in: "query",
303
+ name: "saturation",
304
+ schema: {
305
+ type: "number"
306
+ }
307
+ },
308
+ {
309
+ description: "Hue rotation in degrees for modulation",
310
+ in: "query",
311
+ name: "hue",
312
+ schema: {
313
+ type: "integer"
314
+ }
315
+ },
316
+ {
317
+ description: "Lightness adjustment for modulation",
318
+ in: "query",
319
+ name: "lightness",
320
+ schema: {
321
+ type: "integer"
322
+ }
323
+ },
324
+ {
325
+ description: "Apply tinting",
326
+ in: "query",
327
+ name: "tint",
328
+ schema: {
329
+ type: "boolean"
330
+ }
331
+ },
332
+ {
333
+ description: "Convert colourspace",
334
+ in: "query",
335
+ name: "colourspace",
336
+ schema: {
337
+ enum: ["srgb", "rgb", "cmyk", "lab", "b-w"],
338
+ type: "string"
339
+ }
340
+ },
341
+ {
342
+ description: "Apply affine transformation",
343
+ in: "query",
344
+ name: "affine",
345
+ schema: {
346
+ type: "boolean"
347
+ }
348
+ },
349
+ {
350
+ description: "Apply dilation",
351
+ in: "query",
352
+ name: "dilate",
353
+ schema: {
354
+ type: "boolean"
355
+ }
356
+ },
357
+ {
358
+ description: "Apply erosion",
359
+ in: "query",
360
+ name: "erode",
361
+ schema: {
362
+ type: "boolean"
363
+ }
364
+ },
365
+ {
366
+ description: "Set pipeline colourspace",
367
+ in: "query",
368
+ name: "pipelineColourspace",
369
+ schema: {
370
+ type: "boolean"
371
+ }
372
+ },
373
+ {
374
+ description: "Convert to colourspace",
375
+ in: "query",
376
+ name: "toColourspace",
377
+ schema: {
378
+ type: "boolean"
379
+ }
380
+ },
381
+ {
382
+ description: "Remove alpha channel",
383
+ in: "query",
384
+ name: "removeAlpha",
385
+ schema: {
386
+ type: "boolean"
387
+ }
388
+ },
389
+ {
390
+ description: "Ensure alpha channel",
391
+ in: "query",
392
+ name: "ensureAlpha",
393
+ schema: {
394
+ type: "boolean"
395
+ }
396
+ }
397
+ ],
398
+ "Image"
399
+ );
400
+ const videoParameters = createParameterGroup(
401
+ [
402
+ {
403
+ description: "Desired width in pixels",
404
+ in: "query",
405
+ name: "width",
406
+ schema: {
407
+ minimum: 1,
408
+ type: "integer"
409
+ }
410
+ },
411
+ {
412
+ description: "Desired height in pixels",
413
+ in: "query",
414
+ name: "height",
415
+ schema: {
416
+ minimum: 1,
417
+ type: "integer"
418
+ }
419
+ },
420
+ {
421
+ description: "Video frame rate in Hz",
422
+ in: "query",
423
+ name: "frameRate",
424
+ schema: {
425
+ minimum: 1,
426
+ type: "number"
427
+ }
428
+ },
429
+ {
430
+ description: "Video key frame interval in seconds",
431
+ in: "query",
432
+ name: "keyFrameInterval",
433
+ schema: {
434
+ minimum: 0.1,
435
+ type: "number"
436
+ }
437
+ }
438
+ ],
439
+ "Video"
440
+ );
441
+ const videoAudioParameters = createParameterGroup(
442
+ [
443
+ {
444
+ description: "Target bitrate in bits per second",
445
+ in: "query",
446
+ name: "bitrate",
447
+ schema: {
448
+ minimum: 1,
449
+ type: "integer"
450
+ }
451
+ },
452
+ {
453
+ description: "Video or audio codec",
454
+ in: "query",
455
+ name: "codec",
456
+ schema: {
457
+ enum: ["avc", "hevc", "vp8", "vp9", "av1", "aac", "opus", "mp3", "vorbis", "flac"],
458
+ type: "string"
459
+ }
460
+ }
461
+ ],
462
+ "Video/Audio"
463
+ );
464
+ const audioParameters = createParameterGroup(
465
+ [
466
+ {
467
+ description: "Audio channel count",
468
+ in: "query",
469
+ name: "numberOfChannels",
470
+ schema: {
471
+ enum: [1, 2, 3, 4, 5, 6, 7, 8],
472
+ type: "integer"
473
+ }
474
+ },
475
+ {
476
+ description: "Audio sample rate in Hz",
477
+ in: "query",
478
+ name: "sampleRate",
479
+ schema: {
480
+ enum: [8e3, 11025, 16e3, 22050, 32e3, 44100, 48e3, 88200, 96e3, 192e3],
481
+ type: "integer"
482
+ }
483
+ }
484
+ ],
485
+ "Audio"
486
+ );
487
+ let parameters = [];
488
+ parameters = [...parameters, ...commonParameters];
489
+ if (transform === true || transform === "image") {
490
+ parameters = [...parameters, ...imageParameters];
491
+ }
492
+ if (transform === true || transform === "video") {
493
+ parameters = [...parameters, ...videoParameters];
494
+ }
495
+ if (transform === true || transform === "video" || transform === "audio") {
496
+ parameters = [...parameters, ...videoAudioParameters];
497
+ }
498
+ if (transform === true || transform === "audio") {
499
+ parameters = [...parameters, ...audioParameters];
500
+ }
501
+ const seen = /* @__PURE__ */ new Set();
502
+ return parameters.filter((parameter) => {
503
+ if (seen.has(parameter.name)) {
504
+ return false;
505
+ }
506
+ seen.add(parameter.name);
507
+ return true;
508
+ });
509
+ };
510
+ const getOrganizedTransformationParameters = (transform, format = ["jpeg", "png", "webp", "avif", "tiff", "gif", "mp4", "webm", "mkv", "ogg", "mp3", "wav", "aac", "flac"]) => {
511
+ const parameters = getTransformationParameters(transform, format);
512
+ const groups = {};
513
+ parameters.forEach((parameter) => {
514
+ const group = parameter["x-group"] || "Other";
515
+ if (!groups[group]) {
516
+ groups[group] = [];
517
+ }
518
+ groups[group].push(parameter.name);
519
+ });
520
+ return { groups, parameters };
521
+ };
522
+ const getTransformationHeaders = (transform) => {
523
+ if (!transform) return {};
524
+ const headers = {
525
+ "X-Media-Type": {
526
+ description: "Type of media (image/video/audio)",
527
+ schema: {
528
+ enum: ["image", "video", "audio"],
529
+ type: "string"
530
+ }
531
+ },
532
+ "X-Original-Format": {
533
+ description: "Original file format",
534
+ schema: {
535
+ type: "string"
536
+ }
537
+ },
538
+ "X-Transformed-Format": {
539
+ description: "Transformed file format",
540
+ schema: {
541
+ type: "string"
542
+ }
543
+ }
544
+ };
545
+ return headers;
546
+ };
547
+ const getTransformationErrorResponses = (transform) => {
548
+ if (!transform) return {};
549
+ return {
550
+ 400: {
551
+ content: {
552
+ "application/json": {
553
+ examples: {
554
+ ValidationError: {
555
+ value: {
556
+ error: {
557
+ code: "INVALID_PARAMS_FOR_IMAGE",
558
+ details: {
559
+ invalidParams: ["codec", "bitrate"],
560
+ mediaType: "image",
561
+ validParams: [
562
+ "format",
563
+ "quality",
564
+ "width",
565
+ "height",
566
+ "fit",
567
+ "position",
568
+ "withoutEnlargement",
569
+ "withoutReduction",
570
+ "kernel",
571
+ "fastShrinkOnLoad",
572
+ "left",
573
+ "top",
574
+ "cropWidth",
575
+ "cropHeight",
576
+ "angle",
577
+ "background",
578
+ "blur",
579
+ "sharpen",
580
+ "median",
581
+ "clahe",
582
+ "threshold",
583
+ "gamma",
584
+ "negate",
585
+ "normalise",
586
+ "flatten",
587
+ "unflatten",
588
+ "flip",
589
+ "flop",
590
+ "greyscale",
591
+ "modulate",
592
+ "brightness",
593
+ "saturation",
594
+ "hue",
595
+ "lightness",
596
+ "tint",
597
+ "colourspace",
598
+ "affine",
599
+ "dilate",
600
+ "erode",
601
+ "pipelineColourspace",
602
+ "toColourspace",
603
+ "removeAlpha",
604
+ "ensureAlpha"
605
+ ]
606
+ },
607
+ message: "Invalid query parameters for image transformation: codec, bitrate. Images support: format, quality, width, height, fit, position, withoutEnlargement, withoutReduction, kernel, fastShrinkOnLoad, left, top, cropWidth, cropHeight, angle, background, blur, sharpen, median, clahe, threshold, gamma, negate, normalise, flatten, unflatten, flip, flop, greyscale, modulate, brightness, saturation, hue, lightness, tint, colourspace, affine, dilate, erode, pipelineColourspace, toColourspace, removeAlpha, ensureAlpha. Video/audio parameters (codec, bitrate) are not supported for images.",
608
+ name: "ValidationError"
609
+ }
610
+ }
611
+ }
612
+ },
613
+ schema: {
614
+ $ref: "#/components/schemas/ValidationError"
615
+ }
616
+ }
617
+ },
618
+ description: "Invalid transformation parameters"
619
+ },
620
+ 413: {
621
+ content: {
622
+ "application/json": {
623
+ schema: {
624
+ $ref: "#/components/schemas/Error"
625
+ }
626
+ }
627
+ },
628
+ description: "File too large for transformation"
629
+ },
630
+ 415: {
631
+ content: {
632
+ "application/json": {
633
+ schema: {
634
+ $ref: "#/components/schemas/Error"
635
+ }
636
+ }
637
+ },
638
+ description: "Unsupported media type for transformation"
639
+ }
640
+ };
641
+ };
642
+ const sharedGet = (operationId, tags, transform, transformerFormat) => {
643
+ return {
644
+ description: "Get the uploaded file with optional media transformation support",
645
+ operationId,
646
+ parameters: [
647
+ {
648
+ in: "path",
649
+ name: "id",
650
+ required: true,
651
+ schema: {
652
+ type: "string"
653
+ }
654
+ },
655
+ ...getTransformationParameters(transform, transformerFormat)
656
+ ],
657
+ responses: {
658
+ 200: {
659
+ content: {
660
+ "*/*": {
661
+ schema: {
662
+ description: transform ? "Transformed file content" : "File content",
663
+ format: "binary",
664
+ type: "string"
665
+ }
666
+ }
667
+ },
668
+ description: transform ? "File retrieved and transformed successfully" : "File retrieved successfully",
669
+ headers: {
670
+ "Content-Type": {
671
+ description: `MIME type of the file${transform ? " (or transformed file)" : ""}`,
672
+ schema: {
673
+ type: "string"
674
+ }
675
+ },
676
+ ETag: {
677
+ description: `Upload ETag${transform ? " (or transformed file ETag)" : ""}`,
678
+ schema: {
679
+ example: "d41d8cd98f00b204e9800998ecf8427e",
680
+ type: "string"
681
+ }
682
+ },
683
+ "Last-Modified": {
684
+ description: "Upload last modified date",
685
+ schema: {
686
+ example: "2021-08-25T11:12:26.635Z",
687
+ format: "date-time",
688
+ type: "string"
689
+ }
690
+ },
691
+ ...getTransformationHeaders(transform),
692
+ "X-Upload-Expires": {
693
+ description: "Upload expiration date",
694
+ schema: {
695
+ example: "2021-08-25T11:12:26.635Z",
696
+ format: "date-time",
697
+ type: "string"
698
+ }
699
+ }
700
+ }
701
+ },
702
+ ...getTransformationErrorResponses(transform),
703
+ 404: {
704
+ content: {
705
+ "application/json": {
706
+ example: {
707
+ error: {
708
+ code: "FileNotFound",
709
+ message: "Not found"
710
+ }
711
+ },
712
+ schema: {
713
+ $ref: "#/components/schemas/Error"
714
+ }
715
+ }
716
+ },
717
+ description: "Not Found"
718
+ },
719
+ default: {
720
+ content: {
721
+ "application/json": {
722
+ schema: {
723
+ $ref: "#/components/schemas/Error"
724
+ }
725
+ }
726
+ },
727
+ description: "Error"
728
+ }
729
+ },
730
+ summary: "Get the uploaded file",
731
+ tags
732
+ };
733
+ };
734
+ const sharedGetMeta = (operationId, tags) => {
735
+ return {
736
+ description: "Get the uploaded file metadata",
737
+ operationId,
738
+ parameters: [
739
+ {
740
+ in: "path",
741
+ name: "id",
742
+ required: true,
743
+ schema: {
744
+ type: "string"
745
+ }
746
+ }
747
+ ],
748
+ responses: {
749
+ 200: {
750
+ content: {
751
+ "application/json": {
752
+ schema: {
753
+ $ref: "#/components/schemas/FileMeta"
754
+ }
755
+ }
756
+ },
757
+ description: "OK",
758
+ headers: {
759
+ "Last-Modified": {
760
+ description: "Upload last modified date",
761
+ schema: {
762
+ example: "2021-08-25T11:12:26.635Z",
763
+ format: "date-time",
764
+ type: "string"
765
+ }
766
+ },
767
+ "X-Upload-Expires": {
768
+ description: "Upload expiration date",
769
+ schema: {
770
+ example: "2021-08-25T11:12:26.635Z",
771
+ format: "date-time",
772
+ type: "string"
773
+ }
774
+ }
775
+ }
776
+ },
777
+ 404: {
778
+ content: {
779
+ "application/json": {
780
+ example: {
781
+ error: {
782
+ code: "FileNotFound",
783
+ message: "File metadata not found"
784
+ }
785
+ },
786
+ schema: {
787
+ $ref: "#/components/schemas/Error"
788
+ }
789
+ }
790
+ },
791
+ description: "Not Found"
792
+ },
793
+ default: {
794
+ content: {
795
+ "application/json": {
796
+ schema: {
797
+ $ref: "#/components/schemas/Error"
798
+ }
799
+ }
800
+ },
801
+ description: "Error"
802
+ }
803
+ },
804
+ summary: "Get the uploaded file metadata",
805
+ tags
806
+ };
807
+ };
808
+ const sharedErrorSchemaObject = {
809
+ Error: {
810
+ description: "Error",
811
+ properties: {
812
+ error: {
813
+ properties: {
814
+ code: {
815
+ minLength: 1,
816
+ type: "string"
817
+ },
818
+ message: {
819
+ minLength: 1,
820
+ type: "string"
821
+ },
822
+ name: {
823
+ minLength: 3,
824
+ type: "string"
825
+ }
826
+ },
827
+ required: ["message"],
828
+ type: "object"
829
+ }
830
+ },
831
+ required: ["error"],
832
+ type: "object"
833
+ },
834
+ // Validation error schema
835
+ ValidationError: {
836
+ description: "Validation error response",
837
+ properties: {
838
+ code: {
839
+ enum: [
840
+ "INVALID_PARAMS_FOR_IMAGE",
841
+ "INVALID_PARAMS_FOR_VIDEO",
842
+ "INVALID_PARAMS_FOR_AUDIO",
843
+ "INVALID_FIT_VALUE",
844
+ "INVALID_ANGLE_VALUE",
845
+ "INVALID_FORMAT",
846
+ "INCOMPLETE_CROP_PARAMS",
847
+ "INVALID_VIDEO_CODEC",
848
+ "INVALID_VIDEO_FORMAT",
849
+ "INVALID_WIDTH",
850
+ "INVALID_HEIGHT",
851
+ "INVALID_BITRATE",
852
+ "INVALID_FRAME_RATE",
853
+ "INVALID_KEY_FRAME_INTERVAL",
854
+ "INVALID_AUDIO_CODEC",
855
+ "INVALID_AUDIO_FORMAT",
856
+ "INVALID_CHANNEL_COUNT",
857
+ "INVALID_SAMPLE_RATE"
858
+ ],
859
+ type: "string"
860
+ },
861
+ details: {
862
+ properties: {
863
+ invalidParams: {
864
+ items: {
865
+ type: "string"
866
+ },
867
+ type: "array"
868
+ },
869
+ mediaType: {
870
+ enum: ["image", "video", "audio"],
871
+ type: "string"
872
+ },
873
+ suggestions: {
874
+ items: {
875
+ type: "string"
876
+ },
877
+ type: "array"
878
+ },
879
+ validParams: {
880
+ items: {
881
+ type: "string"
882
+ },
883
+ type: "array"
884
+ }
885
+ },
886
+ required: ["invalidParams", "validParams", "mediaType"],
887
+ type: "object"
888
+ },
889
+ message: {
890
+ type: "string"
891
+ },
892
+ name: {
893
+ enum: ["ValidationError"],
894
+ type: "string"
895
+ }
896
+ },
897
+ required: ["code", "details", "message", "name"],
898
+ type: "object"
899
+ }
900
+ };
901
+ const sharedFileMetaSchemaObject = {
902
+ FileMeta: {
903
+ description: "File meta",
904
+ properties: {
905
+ bytesWritten: {
906
+ type: "integer"
907
+ },
908
+ contentType: {
909
+ type: "string"
910
+ },
911
+ createdAt: {
912
+ format: "date-time",
913
+ type: "string"
914
+ },
915
+ id: {
916
+ minLength: 1,
917
+ type: "string"
918
+ },
919
+ metadata: {
920
+ type: "object"
921
+ },
922
+ name: {
923
+ minLength: 1,
924
+ type: "string"
925
+ },
926
+ originalName: {
927
+ minLength: 1,
928
+ type: "string"
929
+ },
930
+ status: {
931
+ enum: ["completed", "part", "deleted", "created"],
932
+ type: "string"
933
+ }
934
+ },
935
+ type: "object"
936
+ }
937
+ };
938
+ const sharedFileMetaExampleObject = {
939
+ FileMeta: {
940
+ value: [FileMetaExample]
941
+ },
942
+ FileMetaPagination: {
943
+ value: {
944
+ data: [FileMetaExample.value],
945
+ meta: {
946
+ firstPage: 1,
947
+ firstPageUrl: "/?page=1",
948
+ lastPage: 1,
949
+ lastPageUrl: "/?page=10",
950
+ nextPageUrl: "/?page=2",
951
+ page: 1,
952
+ perPage: 1,
953
+ previousPageUrl: void 0,
954
+ total: 1
955
+ }
956
+ }
957
+ }
958
+ };
959
+ const sharedGetList = (operationId, tags) => {
960
+ return {
961
+ description: "List upload",
962
+ operationId,
963
+ parameters: [
964
+ {
965
+ description: "Maximum number of elements to retrieve.",
966
+ in: "query",
967
+ name: "limit",
968
+ schema: {
969
+ nullable: true,
970
+ type: "integer"
971
+ }
972
+ },
973
+ {
974
+ description: "Page number. Use only for pagination.",
975
+ in: "query",
976
+ name: "page",
977
+ schema: {
978
+ nullable: true,
979
+ type: "integer"
980
+ }
981
+ }
982
+ ],
983
+ responses: {
984
+ 200: {
985
+ content: {
986
+ "application/json": {
987
+ examples: {
988
+ Default: {
989
+ $ref: "#/components/examples/FileMeta"
990
+ },
991
+ Pagination: {
992
+ $ref: "#/components/examples/FileMetaPagination"
993
+ }
994
+ },
995
+ schema: {
996
+ $ref: "#/components/schemas/FileMeta"
997
+ }
998
+ }
999
+ },
1000
+ description: "OK"
1001
+ },
1002
+ default: {
1003
+ content: {
1004
+ "application/json": {
1005
+ schema: {
1006
+ $ref: "#/components/schemas/Error"
1007
+ }
1008
+ }
1009
+ },
1010
+ description: "Error"
1011
+ }
1012
+ },
1013
+ summary: "List upload",
1014
+ tags
1015
+ };
1016
+ };
1017
+
1018
+ export { getOrganizedTransformationParameters, sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedFileMetaSchemaObject, sharedGet, sharedGetList, sharedGetMeta };