@imagekit/javascript 5.1.0 → 5.2.0

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.
@@ -1,98 +1,160 @@
1
1
  /**
2
- * Type of files to include in result set. Accepts three values:
3
- * all - include all types of files in result set
4
- * image - only search in image type files
5
- * non-image - only search in files which are not image, e.g., JS or CSS or video files.
6
- *
7
- * {@link https://imagekit.io/docs/api-reference/digital-asset-management-dam/list-and-search-assets}
2
+ * JSON object containing metadata.
8
3
  */
9
- type FileType = "all" | "image" | "non-image";
10
- /**
11
- * Metadata object structure
12
- *
13
- * {@link https://imagekit.io/docs/api-reference/file-metadata/get-uploaded-file-metadata#Responses}
14
- *
15
- * Contents of Object
16
- *
17
- * - Exif
18
- *
19
- * For more information about the Exif standard, please refer to the specification found on http://www.exif.org. A comprehensive list of available Exif attributes and their meaning can be found on http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/.
20
- *
21
- * - Perceptual Hash (pHash)
22
- *
23
- * Perceptual hashing allows you to construct a hash value that uniquely identifies an input image based on the image's contents. It is different from cryptographic hash functions like MD5 and SHA1. pHash provides similar hash value after minor distortions, like small rotations, blurring, and compression in the image.
24
- */
25
- interface Metadata {
26
- height: number;
27
- width: number;
28
- size: number;
29
- format: string;
30
- hasColorProfile: boolean;
31
- quality: number;
32
- density: number;
33
- hasTransparency: boolean;
34
- pHash: string;
35
- exif: {
36
- image: {
37
- Make: string;
38
- Model: string;
39
- Orientation: number;
40
- XResolution: number;
41
- YResolution: number;
42
- ResolutionUnit: number;
43
- Software: string;
44
- ModifyDate: string;
45
- YCbCrPositioning: number;
46
- ExifOffset: number;
47
- GPSInfo: number;
48
- };
49
- thumbnail: {
50
- Compression: number;
51
- XResolution: number;
52
- YResolution: number;
53
- ResolutionUnit: number;
54
- ThumbnailOffset: number;
55
- ThumbnailLength: number;
56
- };
57
- exif: {
58
- ExposureTime: number;
59
- FNumber: number;
60
- ExposureProgram: number;
61
- ISO: number;
62
- ExifVersion: string;
63
- DateTimeOriginal: string;
64
- CreateDate: string;
65
- ShutterSpeedValue: number;
66
- ApertureValue: number;
67
- ExposureCompensation: number;
68
- MeteringMode: number;
69
- Flash: number;
70
- FocalLength: number;
71
- SubSecTime: string;
72
- SubSecTimeOriginal: string;
73
- SubSecTimeDigitized: string;
74
- FlashpixVersion: string;
75
- ColorSpace: number;
76
- ExifImageWidth: number;
77
- ExifImageHeight: number;
78
- InteropOffset: number;
79
- FocalPlaneXResolution: number;
80
- FocalPlaneYResolution: number;
81
- FocalPlaneResolutionUnit: number;
82
- CustomRendered: number;
83
- ExposureMode: number;
84
- WhiteBalance: number;
85
- SceneCaptureType: number;
86
- };
87
- gps: {
88
- GPSVersionID: number[];
89
- };
90
- interoperability: {
91
- InteropIndex: string;
92
- InteropVersion: string;
4
+ export interface Metadata {
5
+ /**
6
+ * The audio codec used in the video (only for video).
7
+ */
8
+ audioCodec?: string;
9
+ /**
10
+ * The bit rate of the video in kbps (only for video).
11
+ */
12
+ bitRate?: number;
13
+ /**
14
+ * The density of the image in DPI.
15
+ */
16
+ density?: number;
17
+ /**
18
+ * The duration of the video in seconds (only for video).
19
+ */
20
+ duration?: number;
21
+ exif?: Metadata.Exif;
22
+ /**
23
+ * The format of the file (e.g., 'jpg', 'mp4').
24
+ */
25
+ format?: string;
26
+ /**
27
+ * Indicates if the image has a color profile.
28
+ */
29
+ hasColorProfile?: boolean;
30
+ /**
31
+ * Indicates if the image contains transparent areas.
32
+ */
33
+ hasTransparency?: boolean;
34
+ /**
35
+ * The height of the image or video in pixels.
36
+ */
37
+ height?: number;
38
+ /**
39
+ * Perceptual hash of the image.
40
+ */
41
+ pHash?: string;
42
+ /**
43
+ * The quality indicator of the image.
44
+ */
45
+ quality?: number;
46
+ /**
47
+ * The file size in bytes.
48
+ */
49
+ size?: number;
50
+ /**
51
+ * The video codec used in the video (only for video).
52
+ */
53
+ videoCodec?: string;
54
+ /**
55
+ * The width of the image or video in pixels.
56
+ */
57
+ width?: number;
58
+ }
59
+ export declare namespace Metadata {
60
+ interface Exif {
61
+ /**
62
+ * Object containing Exif details.
63
+ */
64
+ exif?: Exif.Exif;
65
+ /**
66
+ * Object containing GPS information.
67
+ */
68
+ gps?: Exif.Gps;
69
+ /**
70
+ * Object containing EXIF image information.
71
+ */
72
+ image?: Exif.Image;
73
+ /**
74
+ * JSON object.
75
+ */
76
+ interoperability?: Exif.Interoperability;
77
+ makernote?: {
78
+ [key: string]: unknown;
93
79
  };
94
- makernote: any;
95
- };
80
+ /**
81
+ * Object containing Thumbnail information.
82
+ */
83
+ thumbnail?: Exif.Thumbnail;
84
+ }
85
+ namespace Exif {
86
+ /**
87
+ * Object containing Exif details.
88
+ */
89
+ interface Exif {
90
+ ApertureValue?: number;
91
+ ColorSpace?: number;
92
+ CreateDate?: string;
93
+ CustomRendered?: number;
94
+ DateTimeOriginal?: string;
95
+ ExifImageHeight?: number;
96
+ ExifImageWidth?: number;
97
+ ExifVersion?: string;
98
+ ExposureCompensation?: number;
99
+ ExposureMode?: number;
100
+ ExposureProgram?: number;
101
+ ExposureTime?: number;
102
+ Flash?: number;
103
+ FlashpixVersion?: string;
104
+ FNumber?: number;
105
+ FocalLength?: number;
106
+ FocalPlaneResolutionUnit?: number;
107
+ FocalPlaneXResolution?: number;
108
+ FocalPlaneYResolution?: number;
109
+ InteropOffset?: number;
110
+ ISO?: number;
111
+ MeteringMode?: number;
112
+ SceneCaptureType?: number;
113
+ ShutterSpeedValue?: number;
114
+ SubSecTime?: string;
115
+ WhiteBalance?: number;
116
+ }
117
+ /**
118
+ * Object containing GPS information.
119
+ */
120
+ interface Gps {
121
+ GPSVersionID?: Array<number>;
122
+ }
123
+ /**
124
+ * Object containing EXIF image information.
125
+ */
126
+ interface Image {
127
+ ExifOffset?: number;
128
+ GPSInfo?: number;
129
+ Make?: string;
130
+ Model?: string;
131
+ ModifyDate?: string;
132
+ Orientation?: number;
133
+ ResolutionUnit?: number;
134
+ Software?: string;
135
+ XResolution?: number;
136
+ YCbCrPositioning?: number;
137
+ YResolution?: number;
138
+ }
139
+ /**
140
+ * JSON object.
141
+ */
142
+ interface Interoperability {
143
+ InteropIndex?: string;
144
+ InteropVersion?: string;
145
+ }
146
+ /**
147
+ * Object containing Thumbnail information.
148
+ */
149
+ interface Thumbnail {
150
+ Compression?: number;
151
+ ResolutionUnit?: number;
152
+ ThumbnailLength?: number;
153
+ ThumbnailOffset?: number;
154
+ XResolution?: number;
155
+ YResolution?: number;
156
+ }
157
+ }
96
158
  }
97
159
  export interface ResponseMetadata {
98
160
  statusCode: number;
@@ -100,67 +162,148 @@ export interface ResponseMetadata {
100
162
  headers: Record<string, string | number | boolean>;
101
163
  }
102
164
  /**
103
- * Response from server when file is uploaded successfully.
104
- *
105
- * {@link https://imagekit.io/docs/api-reference/upload-file/upload-file#Responses}
165
+ * Object containing details of a successful upload.
106
166
  */
107
167
  export interface UploadResponse {
108
168
  /**
109
- * Unique fileId. Store this fileld in your database, as this will be used to perform update action on this file.
169
+ * An array of tags assigned to the uploaded file by auto tagging.
110
170
  */
111
- fileId?: string;
171
+ AITags?: Array<FileUploadResponse.AITag> | null;
112
172
  /**
113
- * The name of the uploaded file.
173
+ * The audio codec used in the video (only for video).
114
174
  */
115
- name?: string;
175
+ audioCodec?: string;
116
176
  /**
117
- * The URL of the file.
177
+ * The bit rate of the video in kbps (only for video).
118
178
  */
119
- url?: string;
179
+ bitRate?: number;
120
180
  /**
121
- * In case of an image, a small thumbnail URL.
181
+ * Value of custom coordinates associated with the image in the format
182
+ * `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`.
183
+ * Send `customCoordinates` in `responseFields` in API request to get the value of
184
+ * this field.
122
185
  */
123
- thumbnailUrl?: string;
186
+ customCoordinates?: string | null;
124
187
  /**
125
- * Height of the uploaded image file. Only applicable when file type is image.
188
+ * A key-value data associated with the asset. Use `responseField` in API request
189
+ * to get `customMetadata` in the upload API response. Before setting any custom
190
+ * metadata on an asset, you have to create the field using custom metadata fields
191
+ * API. Send `customMetadata` in `responseFields` in API request to get the value
192
+ * of this field.
126
193
  */
127
- height?: number;
194
+ customMetadata?: {
195
+ [key: string]: unknown;
196
+ };
128
197
  /**
129
- * Width of the uploaded image file. Only applicable when file type is image.
198
+ * Optional text to describe the contents of the file. Can be set by the user or
199
+ * the ai-auto-description extension.
130
200
  */
131
- width?: number;
201
+ description?: string;
132
202
  /**
133
- * Size of the uploaded file in bytes.
203
+ * The duration of the video in seconds (only for video).
134
204
  */
135
- size?: number;
205
+ duration?: number;
136
206
  /**
137
- * Type of file. It can either be image or non-image.
207
+ * Consolidated embedded metadata associated with the file. It includes exif, iptc,
208
+ * and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get
209
+ * embeddedMetadata in the upload API response.
138
210
  */
139
- fileType?: FileType;
211
+ embeddedMetadata?: {
212
+ [key: string]: unknown;
213
+ };
140
214
  /**
141
- * The path of the file uploaded. It includes any folder that you specified while uploading.
215
+ * Extension names with their processing status at the time of completion of the
216
+ * request. It could have one of the following status values:
217
+ *
218
+ * `success`: The extension has been successfully applied. `failed`: The extension
219
+ * has failed and will not be retried. `pending`: The extension will finish
220
+ * processing in some time. On completion, the final status (success / failed) will
221
+ * be sent to the `webhookUrl` provided.
222
+ *
223
+ * If no extension was requested, then this parameter is not returned.
224
+ */
225
+ extensionStatus?: FileUploadResponse.ExtensionStatus;
226
+ /**
227
+ * Unique fileId. Store this fileld in your database, as this will be used to
228
+ * perform update action on this file.
229
+ */
230
+ fileId?: string;
231
+ /**
232
+ * The relative path of the file in the media library e.g.
233
+ * `/marketing-assets/new-banner.jpg`.
142
234
  */
143
235
  filePath?: string;
144
236
  /**
145
- * Array of tags associated with the image.
237
+ * Type of the uploaded file. Possible values are `image`, `non-image`.
146
238
  */
147
- tags?: string[];
239
+ fileType?: string;
148
240
  /**
149
- * Is the file marked as private. It can be either true or false.
241
+ * Height of the image in pixels (Only for images)
242
+ */
243
+ height?: number;
244
+ /**
245
+ * Is the file marked as private. It can be either `true` or `false`. Send
246
+ * `isPrivateFile` in `responseFields` in API request to get the value of this
247
+ * field.
150
248
  */
151
249
  isPrivateFile?: boolean;
152
250
  /**
153
- * Value of custom coordinates associated with the image in format x,y,width,height.
251
+ * Is the file published or in draft state. It can be either `true` or `false`.
252
+ * Send `isPublished` in `responseFields` in API request to get the value of this
253
+ * field.
154
254
  */
155
- customCoordinates?: string | null;
255
+ isPublished?: boolean;
156
256
  /**
157
- * The metadata of the upload file. Use responseFields property in request to get the metadata returned in response of upload API.
257
+ * Legacy metadata. Send `metadata` in `responseFields` in API request to get
258
+ * metadata in the upload API response.
158
259
  */
159
260
  metadata?: Metadata;
160
- AITags?: object[];
161
- extensionStatus?: {
162
- [key: string]: string;
261
+ /**
262
+ * Name of the asset.
263
+ */
264
+ name?: string;
265
+ /**
266
+ * This field is included in the response only if the Path policy feature is
267
+ * available in the plan. It contains schema definitions for the custom metadata
268
+ * fields selected for the specified file path. Field selection can only be done
269
+ * when the Path policy feature is enabled.
270
+ *
271
+ * Keys are the names of the custom metadata fields; the value object has details
272
+ * about the custom metadata schema.
273
+ */
274
+ selectedFieldsSchema?: {
275
+ [key: string]: FileUploadResponse.SelectedFieldsSchema;
163
276
  };
277
+ /**
278
+ * Size of the image file in Bytes.
279
+ */
280
+ size?: number;
281
+ /**
282
+ * The array of tags associated with the asset. If no tags are set, it will be
283
+ * `null`. Send `tags` in `responseFields` in API request to get the value of this
284
+ * field.
285
+ */
286
+ tags?: Array<string> | null;
287
+ /**
288
+ * In the case of an image, a small thumbnail URL.
289
+ */
290
+ thumbnailUrl?: string;
291
+ /**
292
+ * A publicly accessible URL of the file.
293
+ */
294
+ url?: string;
295
+ /**
296
+ * An object containing the file or file version's `id` (versionId) and `name`.
297
+ */
298
+ versionInfo?: FileUploadResponse.VersionInfo;
299
+ /**
300
+ * The video codec used in the video (only for video).
301
+ */
302
+ videoCodec?: string;
303
+ /**
304
+ * Width of the image in pixels (Only for Images)
305
+ */
306
+ width?: number;
164
307
  /**
165
308
  * Message indicating that the file upload is accepted. This field is only present when the upload is accepted but not yet processed.
166
309
  * This can happen when the file is being processed for pre-transformation for video.
@@ -172,4 +315,102 @@ export interface UploadResponse {
172
315
  */
173
316
  readonly $ResponseMetadata: ResponseMetadata;
174
317
  }
175
- export {};
318
+ export declare namespace FileUploadResponse {
319
+ interface AITag {
320
+ /**
321
+ * Confidence score of the tag.
322
+ */
323
+ confidence?: number;
324
+ /**
325
+ * Name of the tag.
326
+ */
327
+ name?: string;
328
+ /**
329
+ * Array of `AITags` associated with the image. If no `AITags` are set, it will be
330
+ * null. These tags can be added using the `google-auto-tagging` or
331
+ * `aws-auto-tagging` extensions.
332
+ */
333
+ source?: string;
334
+ }
335
+ /**
336
+ * Extension names with their processing status at the time of completion of the
337
+ * request. It could have one of the following status values:
338
+ *
339
+ * `success`: The extension has been successfully applied. `failed`: The extension
340
+ * has failed and will not be retried. `pending`: The extension will finish
341
+ * processing in some time. On completion, the final status (success / failed) will
342
+ * be sent to the `webhookUrl` provided.
343
+ *
344
+ * If no extension was requested, then this parameter is not returned.
345
+ */
346
+ interface ExtensionStatus {
347
+ 'ai-auto-description'?: 'success' | 'pending' | 'failed';
348
+ 'ai-tasks'?: 'success' | 'pending' | 'failed';
349
+ 'aws-auto-tagging'?: 'success' | 'pending' | 'failed';
350
+ 'google-auto-tagging'?: 'success' | 'pending' | 'failed';
351
+ 'remove-bg'?: 'success' | 'pending' | 'failed';
352
+ }
353
+ interface SelectedFieldsSchema {
354
+ /**
355
+ * Type of the custom metadata field.
356
+ */
357
+ type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect';
358
+ /**
359
+ * The default value for this custom metadata field. The value should match the
360
+ * `type` of custom metadata field.
361
+ */
362
+ defaultValue?: string | number | boolean | Array<string | number | boolean>;
363
+ /**
364
+ * Specifies if the custom metadata field is required or not.
365
+ */
366
+ isValueRequired?: boolean;
367
+ /**
368
+ * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`.
369
+ */
370
+ maxLength?: number;
371
+ /**
372
+ * Maximum value of the field. Only set if field type is `Date` or `Number`. For
373
+ * `Date` type field, the value will be in ISO8601 string format. For `Number` type
374
+ * field, it will be a numeric value.
375
+ */
376
+ maxValue?: string | number;
377
+ /**
378
+ * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`.
379
+ */
380
+ minLength?: number;
381
+ /**
382
+ * Minimum value of the field. Only set if field type is `Date` or `Number`. For
383
+ * `Date` type field, the value will be in ISO8601 string format. For `Number` type
384
+ * field, it will be a numeric value.
385
+ */
386
+ minValue?: string | number;
387
+ /**
388
+ * Indicates whether the custom metadata field is read only. A read only field
389
+ * cannot be modified after being set. This field is configurable only via the
390
+ * **Path policy** feature.
391
+ */
392
+ readOnly?: boolean;
393
+ /**
394
+ * An array of allowed values when field type is `SingleSelect` or `MultiSelect`.
395
+ */
396
+ selectOptions?: Array<string | number | boolean>;
397
+ /**
398
+ * Specifies if the selectOptions array is truncated. It is truncated when number
399
+ * of options are > 100.
400
+ */
401
+ selectOptionsTruncated?: boolean;
402
+ }
403
+ /**
404
+ * An object containing the file or file version's `id` (versionId) and `name`.
405
+ */
406
+ interface VersionInfo {
407
+ /**
408
+ * Unique identifier of the file version.
409
+ */
410
+ id?: string;
411
+ /**
412
+ * Name of the file version.
413
+ */
414
+ name?: string;
415
+ }
416
+ }
@@ -1,4 +1,3 @@
1
+ export * from './shared';
1
2
  export * from './UploadResponse';
2
3
  export * from './UploadOptions';
3
- export * from './Transformation';
4
- export * from './SrcOptions';