@contentchef/contentchef-types 10.1.0 → 11.0.0-alpha.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.
- package/dist/api/MediaGallery.d.ts +93 -24
- package/dist/api/MediaGallery.js +21 -0
- package/lib/api/MediaGallery.ts +99 -24
- package/package.json +2 -2
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { AuthorResponse } from './Author';
|
|
2
2
|
import { PagedListResponse } from './common';
|
|
3
|
+
/**
|
|
4
|
+
* The media provider that stores and serves a media.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum MediaProvider {
|
|
7
|
+
CLOUDFLARE = "cloudflare",
|
|
8
|
+
CLOUDINARY = "cloudinary"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The processing status of a media. Numeric values match the backend `smallint` column:
|
|
12
|
+
* 0 = QUEUED (upload requested, bytes not processed yet), 1 = READY, 2 = ERROR.
|
|
13
|
+
* MIGRATING (3) is reserved for provider migrations.
|
|
14
|
+
*/
|
|
15
|
+
export declare enum MediaStatus {
|
|
16
|
+
QUEUED = 0,
|
|
17
|
+
READY = 1,
|
|
18
|
+
ERROR = 2,
|
|
19
|
+
MIGRATING = 3
|
|
20
|
+
}
|
|
3
21
|
/**
|
|
4
22
|
* This type describe the result of a list request on media
|
|
5
23
|
* @template T The type of media requested
|
|
@@ -46,10 +64,6 @@ export type MediaGallery = {
|
|
|
46
64
|
* The chosen media gallery description
|
|
47
65
|
*/
|
|
48
66
|
description: string;
|
|
49
|
-
/**
|
|
50
|
-
* This is the media provider used to manage media
|
|
51
|
-
*/
|
|
52
|
-
provider: string;
|
|
53
67
|
/**
|
|
54
68
|
* The creation date of the media gallery
|
|
55
69
|
*/
|
|
@@ -79,6 +93,10 @@ export type MediaGallery = {
|
|
|
79
93
|
* This is the media unique id
|
|
80
94
|
*/
|
|
81
95
|
export type MediaPublicId = string;
|
|
96
|
+
/**
|
|
97
|
+
* This is the media numeric unique id (the media entity id)
|
|
98
|
+
*/
|
|
99
|
+
export type MediaId = number;
|
|
82
100
|
/**
|
|
83
101
|
* This type represent a media information
|
|
84
102
|
*/
|
|
@@ -116,9 +134,9 @@ export type Media = {
|
|
|
116
134
|
*/
|
|
117
135
|
originalUrl: string;
|
|
118
136
|
/**
|
|
119
|
-
* The thumbnail public url of the media
|
|
137
|
+
* The thumbnail public url of the media (not provided for every resource type / provider)
|
|
120
138
|
*/
|
|
121
|
-
thumbnailUrl
|
|
139
|
+
thumbnailUrl?: string;
|
|
122
140
|
/**
|
|
123
141
|
* The type of the media
|
|
124
142
|
*/
|
|
@@ -126,12 +144,38 @@ export type Media = {
|
|
|
126
144
|
/**
|
|
127
145
|
* The tags saved with the media
|
|
128
146
|
*/
|
|
129
|
-
tags
|
|
147
|
+
tags?: string[];
|
|
130
148
|
/**
|
|
131
|
-
* The
|
|
149
|
+
* The media format
|
|
132
150
|
* e.g. -> svg, jpg, png, ...
|
|
133
151
|
*/
|
|
134
|
-
format
|
|
152
|
+
format?: string;
|
|
153
|
+
/**
|
|
154
|
+
* The dominant colors of the media. Computed by Cloudinary; empty (`[]`) for providers
|
|
155
|
+
* that don't compute them, e.g. Cloudflare.
|
|
156
|
+
*/
|
|
157
|
+
colors?: any[];
|
|
158
|
+
/**
|
|
159
|
+
* The predominant color information of the media. Computed by Cloudinary; empty (`{}`)
|
|
160
|
+
* for providers that don't compute it, e.g. Cloudflare.
|
|
161
|
+
*/
|
|
162
|
+
predominant?: object;
|
|
163
|
+
/**
|
|
164
|
+
* The media name
|
|
165
|
+
*/
|
|
166
|
+
name?: string;
|
|
167
|
+
/**
|
|
168
|
+
* The processing status of the media. Present when the media is read from a stored row
|
|
169
|
+
* (get / list). Newly requested uploads start as `MediaStatus.QUEUED`.
|
|
170
|
+
*/
|
|
171
|
+
status?: MediaStatus;
|
|
172
|
+
/**
|
|
173
|
+
* Streaming playback urls (hls / dash) for video media, when available.
|
|
174
|
+
*/
|
|
175
|
+
playback?: {
|
|
176
|
+
hls?: string;
|
|
177
|
+
dash?: string;
|
|
178
|
+
};
|
|
135
179
|
};
|
|
136
180
|
/**
|
|
137
181
|
* This type represent all possible filters used to retrieve a list of media gallery
|
|
@@ -309,6 +353,7 @@ export type ListMediaGalleryFoldersResponse = {
|
|
|
309
353
|
*/
|
|
310
354
|
folders: Folder[];
|
|
311
355
|
};
|
|
356
|
+
export type MediaStatusFilter = 'ALL' | 'QUEUED' | 'READY';
|
|
312
357
|
/**
|
|
313
358
|
* This type represent the data needed to make a list media API request
|
|
314
359
|
*/
|
|
@@ -341,6 +386,10 @@ export type ListMediaRequest = {
|
|
|
341
386
|
* The tags that the media have to contain to be searched
|
|
342
387
|
*/
|
|
343
388
|
tags?: string[];
|
|
389
|
+
/**
|
|
390
|
+
* Needed for filtering list depending on media status
|
|
391
|
+
*/
|
|
392
|
+
status?: MediaStatusFilter;
|
|
344
393
|
};
|
|
345
394
|
/**
|
|
346
395
|
* This type represent the response of a list media API request
|
|
@@ -355,13 +404,9 @@ export type GetMediaRequest = {
|
|
|
355
404
|
*/
|
|
356
405
|
mediaGalleryId: MediaGalleryId;
|
|
357
406
|
/**
|
|
358
|
-
* The
|
|
359
|
-
*/
|
|
360
|
-
parentFolder?: string;
|
|
361
|
-
/**
|
|
362
|
-
* The media public id
|
|
407
|
+
* The media entity unique id
|
|
363
408
|
*/
|
|
364
|
-
|
|
409
|
+
mediaId: MediaId;
|
|
365
410
|
};
|
|
366
411
|
/**
|
|
367
412
|
* This type represent the response of a get media API request
|
|
@@ -395,28 +440,41 @@ export type UploadMediaRequest = {
|
|
|
395
440
|
* The tags saved with the media
|
|
396
441
|
*/
|
|
397
442
|
tags?: string[];
|
|
443
|
+
/**
|
|
444
|
+
* mimeType of the file to upload
|
|
445
|
+
*/
|
|
446
|
+
mimeType: string;
|
|
398
447
|
};
|
|
399
448
|
/**
|
|
400
449
|
* This type represent the response of a upload media API request
|
|
401
450
|
*/
|
|
402
451
|
export type UploadMediaResponse = {
|
|
403
452
|
/**
|
|
404
|
-
*
|
|
453
|
+
* The provider that will handle this upload, determined server-side from the media
|
|
454
|
+
* gallery's per-mediaType provider defaults. Also selects the upload protocol:
|
|
455
|
+
* - `cloudflare`: R2 presigned upload — PUT the raw file to `uploadUrl`.
|
|
456
|
+
* - `cloudinary`: POST FormData(file) to `uploadUrl`; for large files (`largeUpload === true`)
|
|
457
|
+
* PUT the raw file to `writeUrl`, then POST FormData(file=readUrl) to `uploadUrl`.
|
|
405
458
|
*/
|
|
406
|
-
|
|
459
|
+
type: MediaProvider;
|
|
407
460
|
/**
|
|
408
|
-
* The
|
|
461
|
+
* The signed url where to perform the upload request.
|
|
462
|
+
*
|
|
463
|
+
* How to send the bytes depends on `type` (see {@link MediaProvider}):
|
|
409
464
|
*
|
|
410
465
|
* e.g.
|
|
411
466
|
* ``` js
|
|
412
|
-
* if (
|
|
413
|
-
* //
|
|
467
|
+
* if (type === 'cloudflare') {
|
|
468
|
+
* // R2 presigned PUT of the raw file
|
|
469
|
+
* await axios.put(uploadUrl, <THE_FILE>, { headers: { 'Content-Type': mimeType } });
|
|
470
|
+
* } else if (largeUpload) {
|
|
471
|
+
* // Cloudinary large file: PUT to the scratch bucket, then let Cloudinary fetch it
|
|
414
472
|
* await axios.put(writeUrl, <THE_FILE>);
|
|
415
473
|
* const formData = new FormData();
|
|
416
474
|
* formData.append('file', readUrl);
|
|
417
|
-
* await axios.post(uploadUrl, formData)
|
|
475
|
+
* await axios.post(uploadUrl, formData);
|
|
418
476
|
* } else {
|
|
419
|
-
* //
|
|
477
|
+
* // Cloudinary (small file): multipart POST of the raw file
|
|
420
478
|
* const formData = new FormData();
|
|
421
479
|
* formData.append('file', <THE_FILE>);
|
|
422
480
|
* await axios.post(uploadUrl, formData);
|
|
@@ -429,11 +487,22 @@ export type UploadMediaResponse = {
|
|
|
429
487
|
*/
|
|
430
488
|
mediaPublicId: string;
|
|
431
489
|
/**
|
|
432
|
-
*
|
|
490
|
+
* Id of the media entity, created server-side as soon as the upload is requested
|
|
491
|
+
*/
|
|
492
|
+
mediaId: number;
|
|
493
|
+
/**
|
|
494
|
+
* Cloudinary only. When `true` the media exceeds the direct-upload size limit and must be
|
|
495
|
+
* uploaded via the `writeUrl` + `readUrl` two-step. Undefined for cloudflare providers.
|
|
496
|
+
*/
|
|
497
|
+
largeUpload?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* The url where to read the uploaded file. Present for cloudflare R2 uploads, and for
|
|
500
|
+
* cloudinary large uploads (`largeUpload === true`).
|
|
433
501
|
*/
|
|
434
502
|
readUrl?: string;
|
|
435
503
|
/**
|
|
436
|
-
*
|
|
504
|
+
* The url where to write the file. Present for cloudflare R2 uploads, and for
|
|
505
|
+
* cloudinary large uploads (`largeUpload === true`).
|
|
437
506
|
*/
|
|
438
507
|
writeUrl?: string;
|
|
439
508
|
};
|
package/dist/api/MediaGallery.js
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MediaStatus = exports.MediaProvider = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The media provider that stores and serves a media.
|
|
6
|
+
*/
|
|
7
|
+
var MediaProvider;
|
|
8
|
+
(function (MediaProvider) {
|
|
9
|
+
MediaProvider["CLOUDFLARE"] = "cloudflare";
|
|
10
|
+
MediaProvider["CLOUDINARY"] = "cloudinary";
|
|
11
|
+
})(MediaProvider || (exports.MediaProvider = MediaProvider = {}));
|
|
12
|
+
/**
|
|
13
|
+
* The processing status of a media. Numeric values match the backend `smallint` column:
|
|
14
|
+
* 0 = QUEUED (upload requested, bytes not processed yet), 1 = READY, 2 = ERROR.
|
|
15
|
+
* MIGRATING (3) is reserved for provider migrations.
|
|
16
|
+
*/
|
|
17
|
+
var MediaStatus;
|
|
18
|
+
(function (MediaStatus) {
|
|
19
|
+
MediaStatus[MediaStatus["QUEUED"] = 0] = "QUEUED";
|
|
20
|
+
MediaStatus[MediaStatus["READY"] = 1] = "READY";
|
|
21
|
+
MediaStatus[MediaStatus["ERROR"] = 2] = "ERROR";
|
|
22
|
+
MediaStatus[MediaStatus["MIGRATING"] = 3] = "MIGRATING";
|
|
23
|
+
})(MediaStatus || (exports.MediaStatus = MediaStatus = {}));
|
package/lib/api/MediaGallery.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { AuthorResponse } from './Author';
|
|
2
2
|
import { PagedListResponse } from './common';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The media provider that stores and serves a media.
|
|
6
|
+
*/
|
|
7
|
+
export enum MediaProvider {
|
|
8
|
+
CLOUDFLARE = 'cloudflare',
|
|
9
|
+
CLOUDINARY = 'cloudinary'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The processing status of a media. Numeric values match the backend `smallint` column:
|
|
14
|
+
* 0 = QUEUED (upload requested, bytes not processed yet), 1 = READY, 2 = ERROR.
|
|
15
|
+
* MIGRATING (3) is reserved for provider migrations.
|
|
16
|
+
*/
|
|
17
|
+
export enum MediaStatus {
|
|
18
|
+
QUEUED = 0,
|
|
19
|
+
READY = 1,
|
|
20
|
+
ERROR = 2,
|
|
21
|
+
MIGRATING = 3
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
/**
|
|
5
25
|
* This type describe the result of a list request on media
|
|
6
26
|
* @template T The type of media requested
|
|
@@ -49,10 +69,6 @@ export type MediaGallery = {
|
|
|
49
69
|
* The chosen media gallery description
|
|
50
70
|
*/
|
|
51
71
|
description: string;
|
|
52
|
-
/**
|
|
53
|
-
* This is the media provider used to manage media
|
|
54
|
-
*/
|
|
55
|
-
provider: string;
|
|
56
72
|
/**
|
|
57
73
|
* The creation date of the media gallery
|
|
58
74
|
*/
|
|
@@ -84,6 +100,11 @@ export type MediaGallery = {
|
|
|
84
100
|
*/
|
|
85
101
|
export type MediaPublicId = string;
|
|
86
102
|
|
|
103
|
+
/**
|
|
104
|
+
* This is the media numeric unique id (the media entity id)
|
|
105
|
+
*/
|
|
106
|
+
export type MediaId = number;
|
|
107
|
+
|
|
87
108
|
/**
|
|
88
109
|
* This type represent a media information
|
|
89
110
|
*/
|
|
@@ -121,9 +142,9 @@ export type Media = {
|
|
|
121
142
|
*/
|
|
122
143
|
originalUrl: string;
|
|
123
144
|
/**
|
|
124
|
-
* The thumbnail public url of the media
|
|
145
|
+
* The thumbnail public url of the media (not provided for every resource type / provider)
|
|
125
146
|
*/
|
|
126
|
-
thumbnailUrl
|
|
147
|
+
thumbnailUrl?: string;
|
|
127
148
|
/**
|
|
128
149
|
* The type of the media
|
|
129
150
|
*/
|
|
@@ -131,12 +152,38 @@ export type Media = {
|
|
|
131
152
|
/**
|
|
132
153
|
* The tags saved with the media
|
|
133
154
|
*/
|
|
134
|
-
tags
|
|
155
|
+
tags?: string[];
|
|
135
156
|
/**
|
|
136
|
-
* The
|
|
157
|
+
* The media format
|
|
137
158
|
* e.g. -> svg, jpg, png, ...
|
|
138
159
|
*/
|
|
139
|
-
format
|
|
160
|
+
format?: string;
|
|
161
|
+
/**
|
|
162
|
+
* The dominant colors of the media. Computed by Cloudinary; empty (`[]`) for providers
|
|
163
|
+
* that don't compute them, e.g. Cloudflare.
|
|
164
|
+
*/
|
|
165
|
+
colors?: any[];
|
|
166
|
+
/**
|
|
167
|
+
* The predominant color information of the media. Computed by Cloudinary; empty (`{}`)
|
|
168
|
+
* for providers that don't compute it, e.g. Cloudflare.
|
|
169
|
+
*/
|
|
170
|
+
predominant?: object;
|
|
171
|
+
/**
|
|
172
|
+
* The media name
|
|
173
|
+
*/
|
|
174
|
+
name?: string;
|
|
175
|
+
/**
|
|
176
|
+
* The processing status of the media. Present when the media is read from a stored row
|
|
177
|
+
* (get / list). Newly requested uploads start as `MediaStatus.QUEUED`.
|
|
178
|
+
*/
|
|
179
|
+
status?: MediaStatus;
|
|
180
|
+
/**
|
|
181
|
+
* Streaming playback urls (hls / dash) for video media, when available.
|
|
182
|
+
*/
|
|
183
|
+
playback?: {
|
|
184
|
+
hls?: string;
|
|
185
|
+
dash?: string;
|
|
186
|
+
};
|
|
140
187
|
};
|
|
141
188
|
|
|
142
189
|
/**
|
|
@@ -327,6 +374,8 @@ export type ListMediaGalleryFoldersResponse = {
|
|
|
327
374
|
folders: Folder[];
|
|
328
375
|
};
|
|
329
376
|
|
|
377
|
+
export type MediaStatusFilter = 'ALL' | 'QUEUED' | 'READY';
|
|
378
|
+
|
|
330
379
|
/**
|
|
331
380
|
* This type represent the data needed to make a list media API request
|
|
332
381
|
*/
|
|
@@ -359,6 +408,11 @@ export type ListMediaRequest = {
|
|
|
359
408
|
* The tags that the media have to contain to be searched
|
|
360
409
|
*/
|
|
361
410
|
tags?: string[];
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Needed for filtering list depending on media status
|
|
414
|
+
*/
|
|
415
|
+
status?: MediaStatusFilter;
|
|
362
416
|
};
|
|
363
417
|
|
|
364
418
|
/**
|
|
@@ -375,13 +429,9 @@ export type GetMediaRequest = {
|
|
|
375
429
|
*/
|
|
376
430
|
mediaGalleryId: MediaGalleryId;
|
|
377
431
|
/**
|
|
378
|
-
* The
|
|
379
|
-
*/
|
|
380
|
-
parentFolder?: string;
|
|
381
|
-
/**
|
|
382
|
-
* The media public id
|
|
432
|
+
* The media entity unique id
|
|
383
433
|
*/
|
|
384
|
-
|
|
434
|
+
mediaId: MediaId;
|
|
385
435
|
};
|
|
386
436
|
|
|
387
437
|
/**
|
|
@@ -417,6 +467,11 @@ export type UploadMediaRequest = {
|
|
|
417
467
|
* The tags saved with the media
|
|
418
468
|
*/
|
|
419
469
|
tags?: string[];
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* mimeType of the file to upload
|
|
473
|
+
*/
|
|
474
|
+
mimeType: string;
|
|
420
475
|
};
|
|
421
476
|
|
|
422
477
|
/**
|
|
@@ -424,22 +479,31 @@ export type UploadMediaRequest = {
|
|
|
424
479
|
*/
|
|
425
480
|
export type UploadMediaResponse = {
|
|
426
481
|
/**
|
|
427
|
-
*
|
|
482
|
+
* The provider that will handle this upload, determined server-side from the media
|
|
483
|
+
* gallery's per-mediaType provider defaults. Also selects the upload protocol:
|
|
484
|
+
* - `cloudflare`: R2 presigned upload — PUT the raw file to `uploadUrl`.
|
|
485
|
+
* - `cloudinary`: POST FormData(file) to `uploadUrl`; for large files (`largeUpload === true`)
|
|
486
|
+
* PUT the raw file to `writeUrl`, then POST FormData(file=readUrl) to `uploadUrl`.
|
|
428
487
|
*/
|
|
429
|
-
|
|
488
|
+
type: MediaProvider;
|
|
430
489
|
/**
|
|
431
|
-
* The
|
|
490
|
+
* The signed url where to perform the upload request.
|
|
491
|
+
*
|
|
492
|
+
* How to send the bytes depends on `type` (see {@link MediaProvider}):
|
|
432
493
|
*
|
|
433
494
|
* e.g.
|
|
434
495
|
* ``` js
|
|
435
|
-
* if (
|
|
436
|
-
* //
|
|
496
|
+
* if (type === 'cloudflare') {
|
|
497
|
+
* // R2 presigned PUT of the raw file
|
|
498
|
+
* await axios.put(uploadUrl, <THE_FILE>, { headers: { 'Content-Type': mimeType } });
|
|
499
|
+
* } else if (largeUpload) {
|
|
500
|
+
* // Cloudinary large file: PUT to the scratch bucket, then let Cloudinary fetch it
|
|
437
501
|
* await axios.put(writeUrl, <THE_FILE>);
|
|
438
502
|
* const formData = new FormData();
|
|
439
503
|
* formData.append('file', readUrl);
|
|
440
|
-
* await axios.post(uploadUrl, formData)
|
|
504
|
+
* await axios.post(uploadUrl, formData);
|
|
441
505
|
* } else {
|
|
442
|
-
* //
|
|
506
|
+
* // Cloudinary (small file): multipart POST of the raw file
|
|
443
507
|
* const formData = new FormData();
|
|
444
508
|
* formData.append('file', <THE_FILE>);
|
|
445
509
|
* await axios.post(uploadUrl, formData);
|
|
@@ -452,11 +516,22 @@ export type UploadMediaResponse = {
|
|
|
452
516
|
*/
|
|
453
517
|
mediaPublicId: string;
|
|
454
518
|
/**
|
|
455
|
-
*
|
|
519
|
+
* Id of the media entity, created server-side as soon as the upload is requested
|
|
520
|
+
*/
|
|
521
|
+
mediaId: number;
|
|
522
|
+
/**
|
|
523
|
+
* Cloudinary only. When `true` the media exceeds the direct-upload size limit and must be
|
|
524
|
+
* uploaded via the `writeUrl` + `readUrl` two-step. Undefined for cloudflare providers.
|
|
525
|
+
*/
|
|
526
|
+
largeUpload?: boolean;
|
|
527
|
+
/**
|
|
528
|
+
* The url where to read the uploaded file. Present for cloudflare R2 uploads, and for
|
|
529
|
+
* cloudinary large uploads (`largeUpload === true`).
|
|
456
530
|
*/
|
|
457
531
|
readUrl?: string;
|
|
458
532
|
/**
|
|
459
|
-
*
|
|
533
|
+
* The url where to write the file. Present for cloudflare R2 uploads, and for
|
|
534
|
+
* cloudinary large uploads (`largeUpload === true`).
|
|
460
535
|
*/
|
|
461
536
|
writeUrl?: string;
|
|
462
537
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentchef/contentchef-types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-alpha.0",
|
|
4
4
|
"description": "ContentChef types",
|
|
5
5
|
"author": "PierpaoloIannone <piannone@byte-code.com>",
|
|
6
6
|
"homepage": "https://github.com/ContentChef/contentchef-management-js-client#readme",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^5.9.3"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "2e427740786a96ee2e1d8262371799287a33dc88"
|
|
38
38
|
}
|