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