@contentchef/contentchef-types 10.1.0 → 11.0.0-alpha.1
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/Content.d.ts +3 -1
- package/dist/api/Content.js +2 -0
- package/dist/api/ContentDefinition.d.ts +4 -1
- package/dist/api/ContentDefinition.js +3 -0
- package/dist/api/ContentDefinitionSchema.d.ts +69 -2
- package/dist/api/ContentDefinitionSchema.js +11 -1
- package/dist/api/MediaGallery.d.ts +93 -24
- package/dist/api/MediaGallery.js +21 -0
- package/lib/api/Content.ts +2 -0
- package/lib/api/ContentDefinition.ts +4 -1
- package/lib/api/ContentDefinitionSchema.ts +68 -1
- package/lib/api/MediaGallery.ts +99 -24
- package/package.json +2 -2
package/dist/api/Content.d.ts
CHANGED
|
@@ -769,7 +769,9 @@ export declare enum ContentFieldViolationCodes {
|
|
|
769
769
|
textFieldPatternNotMatched = "textField.patternNotMatched",
|
|
770
770
|
textFieldValueMissingInListOfValue = "textField.valueMissingInListOfValue",
|
|
771
771
|
textFieldValueIsNotAString = "textField.valueIsNotAString",
|
|
772
|
-
textFieldBlankValueNotAllowed = "textField.blankValueNotAllowed"
|
|
772
|
+
textFieldBlankValueNotAllowed = "textField.blankValueNotAllowed",
|
|
773
|
+
segmentedFieldValueIsNotSegmented = "segmentedField.valueIsNotSegmented",
|
|
774
|
+
segmentedFieldSegmentNotDeclared = "segmentedField.segmentNotDeclared"
|
|
773
775
|
}
|
|
774
776
|
/**
|
|
775
777
|
* Request type for getContentStatus
|
package/dist/api/Content.js
CHANGED
|
@@ -86,6 +86,8 @@ var ContentFieldViolationCodes;
|
|
|
86
86
|
ContentFieldViolationCodes["textFieldValueMissingInListOfValue"] = "textField.valueMissingInListOfValue";
|
|
87
87
|
ContentFieldViolationCodes["textFieldValueIsNotAString"] = "textField.valueIsNotAString";
|
|
88
88
|
ContentFieldViolationCodes["textFieldBlankValueNotAllowed"] = "textField.blankValueNotAllowed";
|
|
89
|
+
ContentFieldViolationCodes["segmentedFieldValueIsNotSegmented"] = "segmentedField.valueIsNotSegmented";
|
|
90
|
+
ContentFieldViolationCodes["segmentedFieldSegmentNotDeclared"] = "segmentedField.segmentNotDeclared";
|
|
89
91
|
})(ContentFieldViolationCodes || (exports.ContentFieldViolationCodes = ContentFieldViolationCodes = {}));
|
|
90
92
|
var LocalizationSettings;
|
|
91
93
|
(function (LocalizationSettings) {
|
|
@@ -366,6 +366,7 @@ export declare enum SchemaFieldViolationCodes {
|
|
|
366
366
|
invalidNumberValueInList = "invalidNumberValueInList",
|
|
367
367
|
invalidArrayValue = "invalidArrayValue",
|
|
368
368
|
invalidEmptyArray = "invalidEmptyArray",
|
|
369
|
+
invalidEmptyObject = "invalidEmptyObject",
|
|
369
370
|
invalidListOfValuesValue = "invalidListOfValuesValue",
|
|
370
371
|
fragmentNameNotFound = "fragmentNameNotFound",
|
|
371
372
|
fragmentNameAlreadyInUse = "fragmentNameAlreadyInUse",
|
|
@@ -387,5 +388,7 @@ export declare enum SchemaFieldViolationCodes {
|
|
|
387
388
|
extensionNotSupportedForType = "extensionNotSupportedForType",
|
|
388
389
|
translatableNotAllowed = "translatableNotAllowed",
|
|
389
390
|
invalidEnumValue = "invalidEnumValue",
|
|
390
|
-
compactCannotBeNested = "compactCannotBeNested"
|
|
391
|
+
compactCannotBeNested = "compactCannotBeNested",
|
|
392
|
+
segmentTypeNotAllowed = "segmentTypeNotAllowed",
|
|
393
|
+
segmentNameNotFound = "segmentNameNotFound"
|
|
391
394
|
}
|
|
@@ -22,6 +22,7 @@ var SchemaFieldViolationCodes;
|
|
|
22
22
|
SchemaFieldViolationCodes["invalidNumberValueInList"] = "invalidNumberValueInList";
|
|
23
23
|
SchemaFieldViolationCodes["invalidArrayValue"] = "invalidArrayValue";
|
|
24
24
|
SchemaFieldViolationCodes["invalidEmptyArray"] = "invalidEmptyArray";
|
|
25
|
+
SchemaFieldViolationCodes["invalidEmptyObject"] = "invalidEmptyObject";
|
|
25
26
|
SchemaFieldViolationCodes["invalidListOfValuesValue"] = "invalidListOfValuesValue";
|
|
26
27
|
SchemaFieldViolationCodes["fragmentNameNotFound"] = "fragmentNameNotFound";
|
|
27
28
|
SchemaFieldViolationCodes["fragmentNameAlreadyInUse"] = "fragmentNameAlreadyInUse";
|
|
@@ -44,4 +45,6 @@ var SchemaFieldViolationCodes;
|
|
|
44
45
|
SchemaFieldViolationCodes["translatableNotAllowed"] = "translatableNotAllowed";
|
|
45
46
|
SchemaFieldViolationCodes["invalidEnumValue"] = "invalidEnumValue";
|
|
46
47
|
SchemaFieldViolationCodes["compactCannotBeNested"] = "compactCannotBeNested";
|
|
48
|
+
SchemaFieldViolationCodes["segmentTypeNotAllowed"] = "segmentTypeNotAllowed";
|
|
49
|
+
SchemaFieldViolationCodes["segmentNameNotFound"] = "segmentNameNotFound";
|
|
47
50
|
})(SchemaFieldViolationCodes || (exports.SchemaFieldViolationCodes = SchemaFieldViolationCodes = {}));
|
|
@@ -19,7 +19,8 @@ export declare enum SchemaTypeIds {
|
|
|
19
19
|
ONE_LINKED_CONTENT_OF = "oneLinkedContentOf",
|
|
20
20
|
ARRAY = "array",
|
|
21
21
|
SLUG = "slug",
|
|
22
|
-
MEDIA = "media"
|
|
22
|
+
MEDIA = "media",
|
|
23
|
+
SEGMENTED = "segmented"
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* This enum represent al possible long text sub types
|
|
@@ -293,6 +294,68 @@ export type OneLinkedContentOfConstraints = {
|
|
|
293
294
|
lazy?: boolean;
|
|
294
295
|
linkType?: LinkType;
|
|
295
296
|
};
|
|
297
|
+
/**
|
|
298
|
+
* This type represent one segment of a segmented field: the same `{ type, constraints }` pair a
|
|
299
|
+
* schema field carries, minus the name, because the map key in `SegmentsTable` is the name
|
|
300
|
+
*
|
|
301
|
+
* `oneLinkedContentOf` is the only reference form admitted, `linked-content` is its single
|
|
302
|
+
* definition special case and carries the identical payload value
|
|
303
|
+
*/
|
|
304
|
+
export type SegmentDescriptor = {
|
|
305
|
+
type: SchemaTypeIds.FRAGMENT;
|
|
306
|
+
constraints: FragmentFieldConstraints;
|
|
307
|
+
} | {
|
|
308
|
+
type: SchemaTypeIds.ONE_FRAGMENT_OF;
|
|
309
|
+
constraints: OneFragmentOfConstraints;
|
|
310
|
+
} | {
|
|
311
|
+
type: SchemaTypeIds.ONE_LINKED_CONTENT_OF;
|
|
312
|
+
constraints: OneLinkedContentOfConstraints;
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* This type represent the model to define a segment of a segmented field
|
|
316
|
+
*/
|
|
317
|
+
export type SegmentDefinition = SegmentDescriptor & {
|
|
318
|
+
/**
|
|
319
|
+
* The friendly labels of the segment
|
|
320
|
+
*/
|
|
321
|
+
labels?: I18NDictionary;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* This type represent the model of the attribute segments of a segmented field, keyed by segment
|
|
325
|
+
* name, like `FragmentsTable`
|
|
326
|
+
* Names must match `^[a-z0-9_-]+$` and are unordered
|
|
327
|
+
*/
|
|
328
|
+
export type SegmentsTable = {
|
|
329
|
+
/**
|
|
330
|
+
* The name is the unique id of the segment and its value is the model representing the segment
|
|
331
|
+
*/
|
|
332
|
+
[name: string]: SegmentDefinition;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* This enum constrains every segment of a field to one family
|
|
336
|
+
* When omitted, segments of both families are allowed in the same field
|
|
337
|
+
*/
|
|
338
|
+
export declare enum SegmentsType {
|
|
339
|
+
FRAGMENTS = "fragments",
|
|
340
|
+
REFERENCES = "references"
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* This type represent the model of a segmented field constraints
|
|
344
|
+
*/
|
|
345
|
+
export type SegmentedFieldConstraints = {
|
|
346
|
+
/**
|
|
347
|
+
* Set this value to define the segments the field is made of
|
|
348
|
+
*/
|
|
349
|
+
segments: SegmentsTable;
|
|
350
|
+
/**
|
|
351
|
+
* Set this value to define the segment served when the request matches none of this field's segments
|
|
352
|
+
*/
|
|
353
|
+
defaultSegment?: string;
|
|
354
|
+
/**
|
|
355
|
+
* Set this value to constrain every segment of the field to one family
|
|
356
|
+
*/
|
|
357
|
+
segmentsType?: SegmentsType;
|
|
358
|
+
};
|
|
296
359
|
/**
|
|
297
360
|
* This type represent the model of an array field constraints
|
|
298
361
|
* @template T The type of the item used ad children of the array
|
|
@@ -444,6 +507,10 @@ export type OneFragmentOfSchemaType = SchemaType<SchemaTypeIds.ONE_FRAGMENT_OF,
|
|
|
444
507
|
* A one linked content of field can be indexed and searched when requesting the content
|
|
445
508
|
*/
|
|
446
509
|
export type OneLinkedContentOfSchemaType = IndexableSchemaType<SchemaTypeIds.ONE_LINKED_CONTENT_OF, OneLinkedContentOfConstraints>;
|
|
510
|
+
/**
|
|
511
|
+
* This type represent a segmented field schema type
|
|
512
|
+
*/
|
|
513
|
+
export type SegmentedSchemaType = SchemaType<SchemaTypeIds.SEGMENTED, SegmentedFieldConstraints>;
|
|
447
514
|
/**
|
|
448
515
|
* Slug schema type
|
|
449
516
|
* This type is indexable and translatable by default
|
|
@@ -469,7 +536,7 @@ export type TranslatableSchemaTypes = NumberSchemaType | TextSchemaType | LongTe
|
|
|
469
536
|
/**
|
|
470
537
|
* This type group all the schema types of a content definition that are not indexable
|
|
471
538
|
*/
|
|
472
|
-
export type PlainSchemaTypes = DateSchemaType | FragmentSchemaType | OneFragmentOfSchemaType | SlugSchemaType;
|
|
539
|
+
export type PlainSchemaTypes = DateSchemaType | FragmentSchemaType | OneFragmentOfSchemaType | SlugSchemaType | SegmentedSchemaType;
|
|
473
540
|
/**
|
|
474
541
|
* This type group all schema types of a content definition
|
|
475
542
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkType = exports.LongTextSubTypes = exports.SchemaTypeIds = void 0;
|
|
3
|
+
exports.SegmentsType = exports.LinkType = exports.LongTextSubTypes = exports.SchemaTypeIds = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* This enum represent al possible schema field type ids
|
|
6
6
|
*/
|
|
@@ -23,6 +23,7 @@ var SchemaTypeIds;
|
|
|
23
23
|
SchemaTypeIds["ARRAY"] = "array";
|
|
24
24
|
SchemaTypeIds["SLUG"] = "slug";
|
|
25
25
|
SchemaTypeIds["MEDIA"] = "media";
|
|
26
|
+
SchemaTypeIds["SEGMENTED"] = "segmented";
|
|
26
27
|
})(SchemaTypeIds || (exports.SchemaTypeIds = SchemaTypeIds = {}));
|
|
27
28
|
/**
|
|
28
29
|
* This enum represent al possible long text sub types
|
|
@@ -39,3 +40,12 @@ var LinkType;
|
|
|
39
40
|
LinkType[LinkType["LAZY"] = 1] = "LAZY";
|
|
40
41
|
LinkType[LinkType["COMPACT"] = 2] = "COMPACT";
|
|
41
42
|
})(LinkType || (exports.LinkType = LinkType = {}));
|
|
43
|
+
/**
|
|
44
|
+
* This enum constrains every segment of a field to one family
|
|
45
|
+
* When omitted, segments of both families are allowed in the same field
|
|
46
|
+
*/
|
|
47
|
+
var SegmentsType;
|
|
48
|
+
(function (SegmentsType) {
|
|
49
|
+
SegmentsType["FRAGMENTS"] = "fragments";
|
|
50
|
+
SegmentsType["REFERENCES"] = "references";
|
|
51
|
+
})(SegmentsType || (exports.SegmentsType = SegmentsType = {}));
|
|
@@ -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/Content.ts
CHANGED
|
@@ -838,6 +838,8 @@ export enum ContentFieldViolationCodes {
|
|
|
838
838
|
textFieldValueMissingInListOfValue = "textField.valueMissingInListOfValue",
|
|
839
839
|
textFieldValueIsNotAString = "textField.valueIsNotAString",
|
|
840
840
|
textFieldBlankValueNotAllowed = "textField.blankValueNotAllowed",
|
|
841
|
+
segmentedFieldValueIsNotSegmented = "segmentedField.valueIsNotSegmented",
|
|
842
|
+
segmentedFieldSegmentNotDeclared = "segmentedField.segmentNotDeclared",
|
|
841
843
|
}
|
|
842
844
|
|
|
843
845
|
/**
|
|
@@ -393,6 +393,7 @@ export enum SchemaFieldViolationCodes {
|
|
|
393
393
|
invalidNumberValueInList = 'invalidNumberValueInList',
|
|
394
394
|
invalidArrayValue = 'invalidArrayValue',
|
|
395
395
|
invalidEmptyArray = 'invalidEmptyArray',
|
|
396
|
+
invalidEmptyObject = 'invalidEmptyObject',
|
|
396
397
|
invalidListOfValuesValue = 'invalidListOfValuesValue',
|
|
397
398
|
fragmentNameNotFound = 'fragmentNameNotFound',
|
|
398
399
|
fragmentNameAlreadyInUse = 'fragmentNameAlreadyInUse',
|
|
@@ -414,5 +415,7 @@ export enum SchemaFieldViolationCodes {
|
|
|
414
415
|
extensionNotSupportedForType = 'extensionNotSupportedForType',
|
|
415
416
|
translatableNotAllowed = 'translatableNotAllowed',
|
|
416
417
|
invalidEnumValue = 'invalidEnumValue',
|
|
417
|
-
compactCannotBeNested = 'compactCannotBeNested'
|
|
418
|
+
compactCannotBeNested = 'compactCannotBeNested',
|
|
419
|
+
segmentTypeNotAllowed = 'segmentTypeNotAllowed',
|
|
420
|
+
segmentNameNotFound = 'segmentNameNotFound'
|
|
418
421
|
}
|
|
@@ -21,6 +21,7 @@ export enum SchemaTypeIds {
|
|
|
21
21
|
ARRAY = 'array',
|
|
22
22
|
SLUG = 'slug',
|
|
23
23
|
MEDIA = 'media',
|
|
24
|
+
SEGMENTED = 'segmented',
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -319,6 +320,67 @@ export type OneLinkedContentOfConstraints = {
|
|
|
319
320
|
linkType?: LinkType;
|
|
320
321
|
};
|
|
321
322
|
|
|
323
|
+
/**
|
|
324
|
+
* This type represent one segment of a segmented field: the same `{ type, constraints }` pair a
|
|
325
|
+
* schema field carries, minus the name, because the map key in `SegmentsTable` is the name
|
|
326
|
+
*
|
|
327
|
+
* `oneLinkedContentOf` is the only reference form admitted, `linked-content` is its single
|
|
328
|
+
* definition special case and carries the identical payload value
|
|
329
|
+
*/
|
|
330
|
+
export type SegmentDescriptor =
|
|
331
|
+
| { type: SchemaTypeIds.FRAGMENT; constraints: FragmentFieldConstraints; }
|
|
332
|
+
| { type: SchemaTypeIds.ONE_FRAGMENT_OF; constraints: OneFragmentOfConstraints; }
|
|
333
|
+
| { type: SchemaTypeIds.ONE_LINKED_CONTENT_OF; constraints: OneLinkedContentOfConstraints; };
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* This type represent the model to define a segment of a segmented field
|
|
337
|
+
*/
|
|
338
|
+
export type SegmentDefinition = SegmentDescriptor & {
|
|
339
|
+
/**
|
|
340
|
+
* The friendly labels of the segment
|
|
341
|
+
*/
|
|
342
|
+
labels?: I18NDictionary;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* This type represent the model of the attribute segments of a segmented field, keyed by segment
|
|
347
|
+
* name, like `FragmentsTable`
|
|
348
|
+
* Names must match `^[a-z0-9_-]+$` and are unordered
|
|
349
|
+
*/
|
|
350
|
+
export type SegmentsTable = {
|
|
351
|
+
/**
|
|
352
|
+
* The name is the unique id of the segment and its value is the model representing the segment
|
|
353
|
+
*/
|
|
354
|
+
[name: string]: SegmentDefinition;
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* This enum constrains every segment of a field to one family
|
|
359
|
+
* When omitted, segments of both families are allowed in the same field
|
|
360
|
+
*/
|
|
361
|
+
export enum SegmentsType {
|
|
362
|
+
FRAGMENTS = 'fragments',
|
|
363
|
+
REFERENCES = 'references'
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* This type represent the model of a segmented field constraints
|
|
368
|
+
*/
|
|
369
|
+
export type SegmentedFieldConstraints = {
|
|
370
|
+
/**
|
|
371
|
+
* Set this value to define the segments the field is made of
|
|
372
|
+
*/
|
|
373
|
+
segments: SegmentsTable;
|
|
374
|
+
/**
|
|
375
|
+
* Set this value to define the segment served when the request matches none of this field's segments
|
|
376
|
+
*/
|
|
377
|
+
defaultSegment?: string;
|
|
378
|
+
/**
|
|
379
|
+
* Set this value to constrain every segment of the field to one family
|
|
380
|
+
*/
|
|
381
|
+
segmentsType?: SegmentsType;
|
|
382
|
+
};
|
|
383
|
+
|
|
322
384
|
/**
|
|
323
385
|
* This type represent the model of an array field constraints
|
|
324
386
|
* @template T The type of the item used ad children of the array
|
|
@@ -483,6 +545,11 @@ export type OneFragmentOfSchemaType = SchemaType<SchemaTypeIds.ONE_FRAGMENT_OF,
|
|
|
483
545
|
*/
|
|
484
546
|
export type OneLinkedContentOfSchemaType = IndexableSchemaType<SchemaTypeIds.ONE_LINKED_CONTENT_OF, OneLinkedContentOfConstraints>;
|
|
485
547
|
|
|
548
|
+
/**
|
|
549
|
+
* This type represent a segmented field schema type
|
|
550
|
+
*/
|
|
551
|
+
export type SegmentedSchemaType = SchemaType<SchemaTypeIds.SEGMENTED, SegmentedFieldConstraints>;
|
|
552
|
+
|
|
486
553
|
/**
|
|
487
554
|
* Slug schema type
|
|
488
555
|
* This type is indexable and translatable by default
|
|
@@ -515,7 +582,7 @@ export type TranslatableSchemaTypes = NumberSchemaType | TextSchemaType | LongTe
|
|
|
515
582
|
/**
|
|
516
583
|
* This type group all the schema types of a content definition that are not indexable
|
|
517
584
|
*/
|
|
518
|
-
export type PlainSchemaTypes = DateSchemaType | FragmentSchemaType | OneFragmentOfSchemaType | SlugSchemaType;
|
|
585
|
+
export type PlainSchemaTypes = DateSchemaType | FragmentSchemaType | OneFragmentOfSchemaType | SlugSchemaType | SegmentedSchemaType;
|
|
519
586
|
|
|
520
587
|
/**
|
|
521
588
|
* This type group all schema types of a content definition
|
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.1",
|
|
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": "b618c00d0b1642ac9a75685fa08e214b83e22fc8"
|
|
38
38
|
}
|