@contentchef/contentchef-types 11.1.1 → 11.2.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/Component.d.ts +92 -4
- package/dist/api/Component.js +6 -2
- package/dist/api/Content.d.ts +296 -1
- package/dist/api/Content.js +15 -1
- package/lib/api/Component.ts +84 -5
- package/lib/api/Content.ts +301 -0
- package/package.json +2 -2
package/dist/api/Component.d.ts
CHANGED
|
@@ -247,6 +247,13 @@ export type AdoptComponentRequest = {
|
|
|
247
247
|
definitionId: ContentDefinitionId;
|
|
248
248
|
mnemonicId: string;
|
|
249
249
|
version: number;
|
|
250
|
+
/**
|
|
251
|
+
* Fields of the fragment named otherwise in the version: `from` a field of the fragment the version
|
|
252
|
+
* does not have, `to` a field of the version the fragment does not have, each name in one rename at
|
|
253
|
+
* most. Unlike a version's rename, one may change the type: the values that do not fit the field
|
|
254
|
+
* they move to are set aside
|
|
255
|
+
*/
|
|
256
|
+
renames?: ComponentRename[];
|
|
250
257
|
};
|
|
251
258
|
/**
|
|
252
259
|
* This type represent the response of an adopt component API request: the definition, as the get
|
|
@@ -276,8 +283,73 @@ export type PromoteComponentResponse = {
|
|
|
276
283
|
definition: NonNullable<GetContentDefinitionResponse>;
|
|
277
284
|
};
|
|
278
285
|
/**
|
|
279
|
-
*
|
|
280
|
-
*
|
|
286
|
+
* This type represent one side of a compare component fields API request: a definition's fragment, own
|
|
287
|
+
* or a component's, fields of a definition's root, a component version, the latest by default, or
|
|
288
|
+
* fields saved nowhere, validated as a component draft
|
|
289
|
+
*/
|
|
290
|
+
export type ComponentCompareSide = {
|
|
291
|
+
definitionId: ContentDefinitionId;
|
|
292
|
+
fragment: string;
|
|
293
|
+
} | {
|
|
294
|
+
definitionId: ContentDefinitionId;
|
|
295
|
+
fields: string[];
|
|
296
|
+
} | {
|
|
297
|
+
component: string;
|
|
298
|
+
version?: number;
|
|
299
|
+
} | {
|
|
300
|
+
shape: ComponentFragment;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* This type represent the data needed to make a compare component fields API request: how `from`'s
|
|
304
|
+
* fields compare with `to`'s, as an adoption from one to the other would judge them, reading no content
|
|
305
|
+
*/
|
|
306
|
+
export type CompareComponentFieldsRequest = {
|
|
307
|
+
from: ComponentCompareSide;
|
|
308
|
+
to: ComponentCompareSide;
|
|
309
|
+
/**
|
|
310
|
+
* Fields of `from` that `to` names otherwise, as in [[AdoptComponentRequest.renames]]
|
|
311
|
+
*/
|
|
312
|
+
renames?: ComponentRename[];
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* This type represent what becomes of one field of `from`
|
|
316
|
+
*/
|
|
317
|
+
export type ComparedField = {
|
|
318
|
+
field: string;
|
|
319
|
+
/**
|
|
320
|
+
* The field of `to` it becomes, null when removed
|
|
321
|
+
*/
|
|
322
|
+
to: string | null;
|
|
323
|
+
outcome: 'kept' | 'renamed' | 'changed' | 'removed';
|
|
324
|
+
/**
|
|
325
|
+
* For a changed field, what differs, keyed by attribute or `constraints.<key>`: its type, a tighter
|
|
326
|
+
* limit, a list of values (by code)
|
|
327
|
+
*/
|
|
328
|
+
changes?: {
|
|
329
|
+
[attribute: string]: {
|
|
330
|
+
from: unknown;
|
|
331
|
+
to: unknown;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* This type represent the response of a compare component fields API request
|
|
337
|
+
*/
|
|
338
|
+
export type CompareComponentFieldsResponse = {
|
|
339
|
+
fields: ComparedField[];
|
|
340
|
+
/**
|
|
341
|
+
* The fields of `to` no field of `from` reaches
|
|
342
|
+
*/
|
|
343
|
+
added: string[];
|
|
344
|
+
/**
|
|
345
|
+
* What the adopt component API request would refuse, renames included
|
|
346
|
+
*/
|
|
347
|
+
violations: ComponentVersionViolation[];
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* Thin enum represent the error types of the component API requests, and of the content definition and
|
|
351
|
+
* content ones the components bring. Each is the `type` of a `RequestError`, whose `details` is a
|
|
352
|
+
* [[ComponentError]]
|
|
281
353
|
*/
|
|
282
354
|
export declare enum ComponentErrorTypes {
|
|
283
355
|
componentNotFound = "ComponentNotFound",
|
|
@@ -294,7 +366,10 @@ export declare enum ComponentErrorTypes {
|
|
|
294
366
|
noFragmentToPromote = "NoFragmentToPromote",
|
|
295
367
|
definitionMigrating = "DefinitionMigrating",
|
|
296
368
|
oneMigrationPerSave = "OneMigrationPerSave",
|
|
297
|
-
migrationPreviewNotFound = "MigrationPreviewNotFound"
|
|
369
|
+
migrationPreviewNotFound = "MigrationPreviewNotFound",
|
|
370
|
+
invalidComparison = "InvalidComparison",
|
|
371
|
+
fieldNotFound = "FieldNotFound",
|
|
372
|
+
profileTooLarge = "ProfileTooLarge"
|
|
298
373
|
}
|
|
299
374
|
/**
|
|
300
375
|
* Thin enum represent the codes of a [[ComponentVersionViolation]]
|
|
@@ -390,7 +465,19 @@ export type ComponentError = ComponentErrorOf<ComponentErrorTypes.componentNotFo
|
|
|
390
465
|
mnemonicIds: string[];
|
|
391
466
|
}> | ComponentErrorOf<ComponentErrorTypes.migrationPreviewNotFound, {
|
|
392
467
|
id: MigrationPreviewId;
|
|
393
|
-
}
|
|
468
|
+
}>
|
|
469
|
+
/**
|
|
470
|
+
* A side of a compare component fields API request that is none of the kinds it takes
|
|
471
|
+
*/
|
|
472
|
+
| ComponentErrorOf<ComponentErrorTypes.invalidComparison>
|
|
473
|
+
/**
|
|
474
|
+
* A fragment or field the request names that the definition does not have
|
|
475
|
+
*/
|
|
476
|
+
| ComponentErrorOf<ComponentErrorTypes.fieldNotFound>
|
|
477
|
+
/**
|
|
478
|
+
* A profile content values API request whose queries outlasted their time: ask for fewer fields
|
|
479
|
+
*/
|
|
480
|
+
| ComponentErrorOf<ComponentErrorTypes.profileTooLarge>;
|
|
394
481
|
/**
|
|
395
482
|
* This type represent where a definition's contents stand, as the get content definition, update content
|
|
396
483
|
* definition and get migration API requests answer it
|
|
@@ -487,6 +574,7 @@ export type MigrationPreviewRequest = {
|
|
|
487
574
|
adopt: {
|
|
488
575
|
mnemonicId: string;
|
|
489
576
|
version: number;
|
|
577
|
+
renames?: ComponentRename[];
|
|
490
578
|
};
|
|
491
579
|
};
|
|
492
580
|
/**
|
package/dist/api/Component.js
CHANGED
|
@@ -7,8 +7,9 @@ exports.ComponentVersionViolationCodes = exports.ComponentErrorTypes = exports.C
|
|
|
7
7
|
*/
|
|
8
8
|
exports.COMPONENT_NAME_PATTERN = /^[a-zA-Z0-9_]+$/;
|
|
9
9
|
/**
|
|
10
|
-
* Thin enum represent the error types of the component API requests, and of the content definition
|
|
11
|
-
* ones
|
|
10
|
+
* Thin enum represent the error types of the component API requests, and of the content definition and
|
|
11
|
+
* content ones the components bring. Each is the `type` of a `RequestError`, whose `details` is a
|
|
12
|
+
* [[ComponentError]]
|
|
12
13
|
*/
|
|
13
14
|
var ComponentErrorTypes;
|
|
14
15
|
(function (ComponentErrorTypes) {
|
|
@@ -27,6 +28,9 @@ var ComponentErrorTypes;
|
|
|
27
28
|
ComponentErrorTypes["definitionMigrating"] = "DefinitionMigrating";
|
|
28
29
|
ComponentErrorTypes["oneMigrationPerSave"] = "OneMigrationPerSave";
|
|
29
30
|
ComponentErrorTypes["migrationPreviewNotFound"] = "MigrationPreviewNotFound";
|
|
31
|
+
ComponentErrorTypes["invalidComparison"] = "InvalidComparison";
|
|
32
|
+
ComponentErrorTypes["fieldNotFound"] = "FieldNotFound";
|
|
33
|
+
ComponentErrorTypes["profileTooLarge"] = "ProfileTooLarge";
|
|
30
34
|
})(ComponentErrorTypes || (exports.ComponentErrorTypes = ComponentErrorTypes = {}));
|
|
31
35
|
/**
|
|
32
36
|
* Thin enum represent the codes of a [[ComponentVersionViolation]]
|
package/dist/api/Content.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { PagedListResponse } from "./common";
|
|
|
4
4
|
import { ContentDefinitionId, ContentDefinitionResponse } from "./ContentDefinition";
|
|
5
5
|
import { SchemaTypeIds } from "./ContentDefinitionSchema";
|
|
6
6
|
import { ContentRepositoryId, ContentRepositoryResponse } from "./ContentRepository";
|
|
7
|
-
import { ContentTranslation, ContentTranslationStatus } from "./ContentTranslation";
|
|
7
|
+
import { ContentTranslation, ContentTranslationStatus, FieldTranslation } from "./ContentTranslation";
|
|
8
8
|
import { CoverageReport } from "./Audience";
|
|
9
9
|
import { SetAsideResolution, SetAsideValue } from "./Component";
|
|
10
10
|
/**
|
|
@@ -309,6 +309,11 @@ export type UpdateContentRequest = {
|
|
|
309
309
|
* discarded
|
|
310
310
|
*/
|
|
311
311
|
setAside?: SetAsideResolution[];
|
|
312
|
+
/**
|
|
313
|
+
* The version the person saw: a save made meanwhile is refused with `VersionMoved` rather than
|
|
314
|
+
* overwritten unseen
|
|
315
|
+
*/
|
|
316
|
+
expectedVersion?: number;
|
|
312
317
|
};
|
|
313
318
|
/**
|
|
314
319
|
* This type represent the data that can be used to filter a list of contents
|
|
@@ -383,7 +388,42 @@ export type ListContentsFilters = {
|
|
|
383
388
|
* true lists only the contents holding values a migration set aside
|
|
384
389
|
*/
|
|
385
390
|
setAside?: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* This filter is used to search the contents of one definition holding a value of a kind in one field
|
|
393
|
+
*/
|
|
394
|
+
field?: ListContentsFieldFilter;
|
|
386
395
|
};
|
|
396
|
+
/**
|
|
397
|
+
* This type represent the JSON type of a value in a content payload
|
|
398
|
+
*/
|
|
399
|
+
export type JsonValueType = "string" | "number" | "boolean" | "object" | "array";
|
|
400
|
+
/**
|
|
401
|
+
* This type represent a filter on the values of one field: the contents of the definition where an
|
|
402
|
+
* instance of its root, or of the fragment wherever the definition places it, holds an empty value
|
|
403
|
+
* (missing, null, "", [] or {}), a value, a text longer than `length`, or a value not of `type`. With
|
|
404
|
+
* `locale`, where that locale's translation of the field does. A field the definition does not have is
|
|
405
|
+
* refused with `FieldNotFound`
|
|
406
|
+
*/
|
|
407
|
+
export type ListContentsFieldFilter = {
|
|
408
|
+
definitionId: ContentDefinitionId;
|
|
409
|
+
/**
|
|
410
|
+
* The fragment holding the field, the definition's root without it
|
|
411
|
+
*/
|
|
412
|
+
fragment?: string;
|
|
413
|
+
/**
|
|
414
|
+
* The field name
|
|
415
|
+
*/
|
|
416
|
+
name: string;
|
|
417
|
+
locale?: string;
|
|
418
|
+
} & ({
|
|
419
|
+
is: "empty" | "notEmpty";
|
|
420
|
+
} | {
|
|
421
|
+
is: "longerThan";
|
|
422
|
+
length: number;
|
|
423
|
+
} | {
|
|
424
|
+
is: "notType";
|
|
425
|
+
type: JsonValueType;
|
|
426
|
+
});
|
|
387
427
|
/**
|
|
388
428
|
* This type represent the data needed to make a list content API request
|
|
389
429
|
*/
|
|
@@ -873,3 +913,258 @@ export type AnalysePersonalizedRulesResponse = {
|
|
|
873
913
|
*/
|
|
874
914
|
fields: PersonalizedFieldCoverage[];
|
|
875
915
|
};
|
|
916
|
+
/**
|
|
917
|
+
* This type represent the data needed to make a profile content values API request: what the
|
|
918
|
+
* definition's contents, archived ones included, hold in the fields of its root or of one of its
|
|
919
|
+
* fragments wherever the definition places it. For investigating, never for a form
|
|
920
|
+
*/
|
|
921
|
+
export type ProfileContentValuesRequest = {
|
|
922
|
+
definitionId: ContentDefinitionId;
|
|
923
|
+
/**
|
|
924
|
+
* The fragment to profile, the definition's root without it
|
|
925
|
+
*/
|
|
926
|
+
fragment?: string;
|
|
927
|
+
/**
|
|
928
|
+
* The fields to profile, from 1 to 100, all of them without it
|
|
929
|
+
*/
|
|
930
|
+
fields?: string[];
|
|
931
|
+
};
|
|
932
|
+
/**
|
|
933
|
+
* This type represent what the contents hold in one field
|
|
934
|
+
*/
|
|
935
|
+
export type FieldValuesProfile = {
|
|
936
|
+
name: string;
|
|
937
|
+
type: string;
|
|
938
|
+
/**
|
|
939
|
+
* The objects of the place, each holding the field or not
|
|
940
|
+
*/
|
|
941
|
+
instances: number;
|
|
942
|
+
values: number;
|
|
943
|
+
/**
|
|
944
|
+
* The instances holding null, "", [], {} or nothing
|
|
945
|
+
*/
|
|
946
|
+
empty: number;
|
|
947
|
+
/**
|
|
948
|
+
* The contents holding at least one value
|
|
949
|
+
*/
|
|
950
|
+
contents: number;
|
|
951
|
+
/**
|
|
952
|
+
* The values by JSON type
|
|
953
|
+
*/
|
|
954
|
+
types: {
|
|
955
|
+
[type in JsonValueType]?: number;
|
|
956
|
+
};
|
|
957
|
+
/**
|
|
958
|
+
* The lengths of the text values, null without any
|
|
959
|
+
*/
|
|
960
|
+
length: {
|
|
961
|
+
min: number;
|
|
962
|
+
max: number;
|
|
963
|
+
p95: number;
|
|
964
|
+
} | null;
|
|
965
|
+
/**
|
|
966
|
+
* The translations holding text, by locale, null for a field that is not translatable
|
|
967
|
+
*/
|
|
968
|
+
translations: {
|
|
969
|
+
[locale: string]: number;
|
|
970
|
+
} | null;
|
|
971
|
+
};
|
|
972
|
+
/**
|
|
973
|
+
* This type represent the response of a profile content values API request. A fragment nested in itself
|
|
974
|
+
* is followed one level deep, and a profile whose queries outlast their time is refused with
|
|
975
|
+
* `ProfileTooLarge`
|
|
976
|
+
*/
|
|
977
|
+
export type ProfileContentValuesResponse = {
|
|
978
|
+
definitionId: ContentDefinitionId;
|
|
979
|
+
fragment: string | null;
|
|
980
|
+
contents: {
|
|
981
|
+
total: number;
|
|
982
|
+
archived: number;
|
|
983
|
+
};
|
|
984
|
+
/**
|
|
985
|
+
* Where the fragment sits, as `blocks[]<seo>` (an array of `oneFragmentOf` holding it) or
|
|
986
|
+
* `hero.variants[]` (a personalized field's variants), empty for the root
|
|
987
|
+
*/
|
|
988
|
+
placements: string[];
|
|
989
|
+
/**
|
|
990
|
+
* The objects of the place found in the contents
|
|
991
|
+
*/
|
|
992
|
+
instances: number;
|
|
993
|
+
fields: FieldValuesProfile[];
|
|
994
|
+
};
|
|
995
|
+
/**
|
|
996
|
+
* This type represent the kind of a version in a content's history: what a publish published, or the
|
|
997
|
+
* content as a restore found it, unpublished edits and translations included
|
|
998
|
+
*/
|
|
999
|
+
export type ContentHistoryKind = "published" | "beforeRestore";
|
|
1000
|
+
/**
|
|
1001
|
+
* This type represent the data needed to make a list content history API request
|
|
1002
|
+
*/
|
|
1003
|
+
export type ListContentHistoryRequest = {
|
|
1004
|
+
contentId: ContentId;
|
|
1005
|
+
/**
|
|
1006
|
+
* 0 by default
|
|
1007
|
+
*/
|
|
1008
|
+
skip?: number;
|
|
1009
|
+
/**
|
|
1010
|
+
* 20 by default, at most 100
|
|
1011
|
+
*/
|
|
1012
|
+
take?: number;
|
|
1013
|
+
};
|
|
1014
|
+
/**
|
|
1015
|
+
* This type represent a version in a content's history
|
|
1016
|
+
*/
|
|
1017
|
+
export type ContentHistoryEntry = {
|
|
1018
|
+
kind: ContentHistoryKind;
|
|
1019
|
+
/**
|
|
1020
|
+
* The publishing request's id for a `published` version, the restore's for a `beforeRestore` one
|
|
1021
|
+
*/
|
|
1022
|
+
id: number;
|
|
1023
|
+
/**
|
|
1024
|
+
* The content's version at the time
|
|
1025
|
+
*/
|
|
1026
|
+
version: number;
|
|
1027
|
+
date: Date;
|
|
1028
|
+
/**
|
|
1029
|
+
* Who published or restored, null when unknown
|
|
1030
|
+
*/
|
|
1031
|
+
author: Pick<AuthorResponse, "authorId" | "fullName"> | null;
|
|
1032
|
+
};
|
|
1033
|
+
/**
|
|
1034
|
+
* This type represent the response of a list content history API request: newest first, without the
|
|
1035
|
+
* publishes that failed or are still running
|
|
1036
|
+
*/
|
|
1037
|
+
export type ListContentHistoryResponse = {
|
|
1038
|
+
items: ContentHistoryEntry[];
|
|
1039
|
+
total: number;
|
|
1040
|
+
};
|
|
1041
|
+
/**
|
|
1042
|
+
* This type represent the data needed to make a get content history entry API request
|
|
1043
|
+
*/
|
|
1044
|
+
export type GetContentHistoryEntryRequest = {
|
|
1045
|
+
contentId: ContentId;
|
|
1046
|
+
kind: ContentHistoryKind;
|
|
1047
|
+
id: number;
|
|
1048
|
+
};
|
|
1049
|
+
/**
|
|
1050
|
+
* This type represent a violation of one constraint. `code` is one of [[ContentFieldViolationCodes]], or
|
|
1051
|
+
* of the translation ones such as `translation.unknownField`
|
|
1052
|
+
*/
|
|
1053
|
+
export type ContentConstraintViolation = {
|
|
1054
|
+
path?: string;
|
|
1055
|
+
code: string;
|
|
1056
|
+
};
|
|
1057
|
+
/**
|
|
1058
|
+
* This type represent the violations of one item of an array field, matched by its `itemKey`
|
|
1059
|
+
*/
|
|
1060
|
+
export type ContentArrayItemViolation = {
|
|
1061
|
+
itemKey: string;
|
|
1062
|
+
index: number;
|
|
1063
|
+
violations: (ContentConstraintViolation | ContentFieldViolation)[];
|
|
1064
|
+
};
|
|
1065
|
+
/**
|
|
1066
|
+
* This type represent the violations of one field of a payload, as an update content API request answers
|
|
1067
|
+
* them in its `validation`
|
|
1068
|
+
*/
|
|
1069
|
+
export type ContentFieldViolation = {
|
|
1070
|
+
field: string;
|
|
1071
|
+
violations: (ContentConstraintViolation | ContentFieldViolation | ContentArrayItemViolation)[];
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* This type represent what keeps a version of the history from being restored, all empty when it can be
|
|
1075
|
+
*/
|
|
1076
|
+
export type RestoreViolations = {
|
|
1077
|
+
payload: ContentFieldViolation[];
|
|
1078
|
+
/**
|
|
1079
|
+
* Per locale, the violations of its translated values
|
|
1080
|
+
*/
|
|
1081
|
+
translations: {
|
|
1082
|
+
locale: string;
|
|
1083
|
+
violations: ContentConstraintViolation[];
|
|
1084
|
+
}[];
|
|
1085
|
+
/**
|
|
1086
|
+
* Values a component migration since would set aside: the definition has no place for them any more
|
|
1087
|
+
*/
|
|
1088
|
+
setAside: {
|
|
1089
|
+
path: string;
|
|
1090
|
+
reason: "removed" | "changed";
|
|
1091
|
+
}[];
|
|
1092
|
+
};
|
|
1093
|
+
/**
|
|
1094
|
+
* This type represent the response of a get content history entry API request: the version as a restore
|
|
1095
|
+
* would write it, migrated to the definition as it is now, so it compares key by key with the get content
|
|
1096
|
+
* API request's
|
|
1097
|
+
*/
|
|
1098
|
+
export type GetContentHistoryEntryResponse = ContentHistoryEntry & {
|
|
1099
|
+
payload: object;
|
|
1100
|
+
translations: {
|
|
1101
|
+
locale: string;
|
|
1102
|
+
translations: FieldTranslation[];
|
|
1103
|
+
}[];
|
|
1104
|
+
restorable: boolean;
|
|
1105
|
+
violations: RestoreViolations;
|
|
1106
|
+
};
|
|
1107
|
+
/**
|
|
1108
|
+
* This type represent the data needed to make a restore content API request
|
|
1109
|
+
*/
|
|
1110
|
+
export type RestoreContentRequest = {
|
|
1111
|
+
contentId: ContentId;
|
|
1112
|
+
kind: ContentHistoryKind;
|
|
1113
|
+
id: number;
|
|
1114
|
+
/**
|
|
1115
|
+
* The version the person saw: a save made meanwhile is refused with `VersionMoved` rather than
|
|
1116
|
+
* overwritten unseen
|
|
1117
|
+
*/
|
|
1118
|
+
expectedVersion?: number;
|
|
1119
|
+
};
|
|
1120
|
+
/**
|
|
1121
|
+
* This type represent the response of a restore content API request: the content as an update content
|
|
1122
|
+
* API request answers it
|
|
1123
|
+
*/
|
|
1124
|
+
export type RestoreContentResponse = UpdateContentResponse;
|
|
1125
|
+
/**
|
|
1126
|
+
* Thin enum represent the error types of the content API requests: the update content one, and the content
|
|
1127
|
+
* history ones. Each is the `type` of a `RequestError`, whose `details` is a [[ContentError]]
|
|
1128
|
+
*/
|
|
1129
|
+
export declare enum ContentErrorTypes {
|
|
1130
|
+
contentNotFound = "ContentNotFound",
|
|
1131
|
+
failedContentPayloadValidation = "FailedContentPayloadValidation",
|
|
1132
|
+
publicIdNotExclusiveToDefinitionId = "PublicIdNotExclusiveToDefinitionId",
|
|
1133
|
+
versionMoved = "VersionMoved",
|
|
1134
|
+
definitionMoved = "DefinitionMoved",
|
|
1135
|
+
historyEntryNotFound = "HistoryEntryNotFound",
|
|
1136
|
+
restoreRefused = "RestoreRefused"
|
|
1137
|
+
}
|
|
1138
|
+
type ContentErrorOf<T extends ContentErrorTypes, D = {}> = {
|
|
1139
|
+
type: T;
|
|
1140
|
+
message: string;
|
|
1141
|
+
} & D;
|
|
1142
|
+
/**
|
|
1143
|
+
* This type represent the `details` of a `RequestError` whose `type` is one of [[ContentErrorTypes]]
|
|
1144
|
+
*/
|
|
1145
|
+
export type ContentError = ContentErrorOf<ContentErrorTypes.contentNotFound>
|
|
1146
|
+
/**
|
|
1147
|
+
* The payload does not fit its definition, field by field; nothing was written
|
|
1148
|
+
*/
|
|
1149
|
+
| ContentErrorOf<ContentErrorTypes.failedContentPayloadValidation, {
|
|
1150
|
+
validation: ContentFieldViolation[];
|
|
1151
|
+
}>
|
|
1152
|
+
/**
|
|
1153
|
+
* The public id is in use on a content of another definition
|
|
1154
|
+
*/
|
|
1155
|
+
| ContentErrorOf<ContentErrorTypes.publicIdNotExclusiveToDefinitionId>
|
|
1156
|
+
/**
|
|
1157
|
+
* The content is no longer at `expectedVersion`: read it again
|
|
1158
|
+
*/
|
|
1159
|
+
| ContentErrorOf<ContentErrorTypes.versionMoved>
|
|
1160
|
+
/**
|
|
1161
|
+
* The definition changed while the content was saved or restored: try again
|
|
1162
|
+
*/
|
|
1163
|
+
| ContentErrorOf<ContentErrorTypes.definitionMoved> | ContentErrorOf<ContentErrorTypes.historyEntryNotFound>
|
|
1164
|
+
/**
|
|
1165
|
+
* The version does not fit the definition as it is now; nothing was written
|
|
1166
|
+
*/
|
|
1167
|
+
| ContentErrorOf<ContentErrorTypes.restoreRefused, {
|
|
1168
|
+
violations: RestoreViolations;
|
|
1169
|
+
}>;
|
|
1170
|
+
export {};
|
package/dist/api/Content.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LocalizationSettings = exports.ContentFieldViolationCodes = exports.SortDirection = exports.ContentSortField = exports.ContentsStatus = void 0;
|
|
3
|
+
exports.ContentErrorTypes = exports.LocalizationSettings = exports.ContentFieldViolationCodes = exports.SortDirection = exports.ContentSortField = exports.ContentsStatus = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* This enum represent the possible content status
|
|
6
6
|
*/
|
|
@@ -100,3 +100,17 @@ var LocalizationSettings;
|
|
|
100
100
|
LocalizationSettings["DEFAULT"] = "default";
|
|
101
101
|
LocalizationSettings["MAIN"] = "main";
|
|
102
102
|
})(LocalizationSettings || (exports.LocalizationSettings = LocalizationSettings = {}));
|
|
103
|
+
/**
|
|
104
|
+
* Thin enum represent the error types of the content API requests: the update content one, and the content
|
|
105
|
+
* history ones. Each is the `type` of a `RequestError`, whose `details` is a [[ContentError]]
|
|
106
|
+
*/
|
|
107
|
+
var ContentErrorTypes;
|
|
108
|
+
(function (ContentErrorTypes) {
|
|
109
|
+
ContentErrorTypes["contentNotFound"] = "ContentNotFound";
|
|
110
|
+
ContentErrorTypes["failedContentPayloadValidation"] = "FailedContentPayloadValidation";
|
|
111
|
+
ContentErrorTypes["publicIdNotExclusiveToDefinitionId"] = "PublicIdNotExclusiveToDefinitionId";
|
|
112
|
+
ContentErrorTypes["versionMoved"] = "VersionMoved";
|
|
113
|
+
ContentErrorTypes["definitionMoved"] = "DefinitionMoved";
|
|
114
|
+
ContentErrorTypes["historyEntryNotFound"] = "HistoryEntryNotFound";
|
|
115
|
+
ContentErrorTypes["restoreRefused"] = "RestoreRefused";
|
|
116
|
+
})(ContentErrorTypes || (exports.ContentErrorTypes = ContentErrorTypes = {}));
|
package/lib/api/Component.ts
CHANGED
|
@@ -270,6 +270,13 @@ export type AdoptComponentRequest = {
|
|
|
270
270
|
definitionId: ContentDefinitionId;
|
|
271
271
|
mnemonicId: string;
|
|
272
272
|
version: number;
|
|
273
|
+
/**
|
|
274
|
+
* Fields of the fragment named otherwise in the version: `from` a field of the fragment the version
|
|
275
|
+
* does not have, `to` a field of the version the fragment does not have, each name in one rename at
|
|
276
|
+
* most. Unlike a version's rename, one may change the type: the values that do not fit the field
|
|
277
|
+
* they move to are set aside
|
|
278
|
+
*/
|
|
279
|
+
renames?: ComponentRename[];
|
|
273
280
|
};
|
|
274
281
|
|
|
275
282
|
/**
|
|
@@ -303,8 +310,65 @@ export type PromoteComponentResponse = {
|
|
|
303
310
|
};
|
|
304
311
|
|
|
305
312
|
/**
|
|
306
|
-
*
|
|
307
|
-
*
|
|
313
|
+
* This type represent one side of a compare component fields API request: a definition's fragment, own
|
|
314
|
+
* or a component's, fields of a definition's root, a component version, the latest by default, or
|
|
315
|
+
* fields saved nowhere, validated as a component draft
|
|
316
|
+
*/
|
|
317
|
+
export type ComponentCompareSide =
|
|
318
|
+
| { definitionId: ContentDefinitionId; fragment: string }
|
|
319
|
+
| { definitionId: ContentDefinitionId; fields: string[] }
|
|
320
|
+
| { component: string; version?: number }
|
|
321
|
+
| { shape: ComponentFragment };
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* This type represent the data needed to make a compare component fields API request: how `from`'s
|
|
325
|
+
* fields compare with `to`'s, as an adoption from one to the other would judge them, reading no content
|
|
326
|
+
*/
|
|
327
|
+
export type CompareComponentFieldsRequest = {
|
|
328
|
+
from: ComponentCompareSide;
|
|
329
|
+
to: ComponentCompareSide;
|
|
330
|
+
/**
|
|
331
|
+
* Fields of `from` that `to` names otherwise, as in [[AdoptComponentRequest.renames]]
|
|
332
|
+
*/
|
|
333
|
+
renames?: ComponentRename[];
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* This type represent what becomes of one field of `from`
|
|
338
|
+
*/
|
|
339
|
+
export type ComparedField = {
|
|
340
|
+
field: string;
|
|
341
|
+
/**
|
|
342
|
+
* The field of `to` it becomes, null when removed
|
|
343
|
+
*/
|
|
344
|
+
to: string | null;
|
|
345
|
+
outcome: 'kept' | 'renamed' | 'changed' | 'removed';
|
|
346
|
+
/**
|
|
347
|
+
* For a changed field, what differs, keyed by attribute or `constraints.<key>`: its type, a tighter
|
|
348
|
+
* limit, a list of values (by code)
|
|
349
|
+
*/
|
|
350
|
+
changes?: { [attribute: string]: { from: unknown; to: unknown } };
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* This type represent the response of a compare component fields API request
|
|
355
|
+
*/
|
|
356
|
+
export type CompareComponentFieldsResponse = {
|
|
357
|
+
fields: ComparedField[];
|
|
358
|
+
/**
|
|
359
|
+
* The fields of `to` no field of `from` reaches
|
|
360
|
+
*/
|
|
361
|
+
added: string[];
|
|
362
|
+
/**
|
|
363
|
+
* What the adopt component API request would refuse, renames included
|
|
364
|
+
*/
|
|
365
|
+
violations: ComponentVersionViolation[];
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Thin enum represent the error types of the component API requests, and of the content definition and
|
|
370
|
+
* content ones the components bring. Each is the `type` of a `RequestError`, whose `details` is a
|
|
371
|
+
* [[ComponentError]]
|
|
308
372
|
*/
|
|
309
373
|
export enum ComponentErrorTypes {
|
|
310
374
|
componentNotFound = 'ComponentNotFound',
|
|
@@ -321,7 +385,10 @@ export enum ComponentErrorTypes {
|
|
|
321
385
|
noFragmentToPromote = 'NoFragmentToPromote',
|
|
322
386
|
definitionMigrating = 'DefinitionMigrating',
|
|
323
387
|
oneMigrationPerSave = 'OneMigrationPerSave',
|
|
324
|
-
migrationPreviewNotFound = 'MigrationPreviewNotFound'
|
|
388
|
+
migrationPreviewNotFound = 'MigrationPreviewNotFound',
|
|
389
|
+
invalidComparison = 'InvalidComparison',
|
|
390
|
+
fieldNotFound = 'FieldNotFound',
|
|
391
|
+
profileTooLarge = 'ProfileTooLarge'
|
|
325
392
|
}
|
|
326
393
|
|
|
327
394
|
/**
|
|
@@ -406,7 +473,19 @@ export type ComponentError =
|
|
|
406
473
|
* has finished
|
|
407
474
|
*/
|
|
408
475
|
| ComponentErrorOf<ComponentErrorTypes.oneMigrationPerSave, { mnemonicIds: string[] }>
|
|
409
|
-
| ComponentErrorOf<ComponentErrorTypes.migrationPreviewNotFound, { id: MigrationPreviewId }
|
|
476
|
+
| ComponentErrorOf<ComponentErrorTypes.migrationPreviewNotFound, { id: MigrationPreviewId }>
|
|
477
|
+
/**
|
|
478
|
+
* A side of a compare component fields API request that is none of the kinds it takes
|
|
479
|
+
*/
|
|
480
|
+
| ComponentErrorOf<ComponentErrorTypes.invalidComparison>
|
|
481
|
+
/**
|
|
482
|
+
* A fragment or field the request names that the definition does not have
|
|
483
|
+
*/
|
|
484
|
+
| ComponentErrorOf<ComponentErrorTypes.fieldNotFound>
|
|
485
|
+
/**
|
|
486
|
+
* A profile content values API request whose queries outlasted their time: ask for fewer fields
|
|
487
|
+
*/
|
|
488
|
+
| ComponentErrorOf<ComponentErrorTypes.profileTooLarge>;
|
|
410
489
|
|
|
411
490
|
/**
|
|
412
491
|
* This type represent where a definition's contents stand, as the get content definition, update content
|
|
@@ -501,7 +580,7 @@ export type MigrationPreviewId = number;
|
|
|
501
580
|
*/
|
|
502
581
|
export type MigrationPreviewRequest =
|
|
503
582
|
| { id: ContentDefinitionId; schema: ContentDefinitionSchemaInput }
|
|
504
|
-
| { id: ContentDefinitionId; adopt: { mnemonicId: string; version: number } };
|
|
583
|
+
| { id: ContentDefinitionId; adopt: { mnemonicId: string; version: number; renames?: ComponentRename[] } };
|
|
505
584
|
|
|
506
585
|
/**
|
|
507
586
|
* This type represent the response of a migration preview API request: the preview's id, or null when
|
package/lib/api/Content.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
ContentTranslation,
|
|
15
15
|
ContentTranslationStatus,
|
|
16
|
+
FieldTranslation,
|
|
16
17
|
} from "./ContentTranslation";
|
|
17
18
|
import { CoverageReport } from "./Audience";
|
|
18
19
|
import { SetAsideResolution, SetAsideValue } from "./Component";
|
|
@@ -342,6 +343,12 @@ export type UpdateContentRequest = {
|
|
|
342
343
|
* discarded
|
|
343
344
|
*/
|
|
344
345
|
setAside?: SetAsideResolution[];
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* The version the person saw: a save made meanwhile is refused with `VersionMoved` rather than
|
|
349
|
+
* overwritten unseen
|
|
350
|
+
*/
|
|
351
|
+
expectedVersion?: number;
|
|
345
352
|
};
|
|
346
353
|
|
|
347
354
|
/**
|
|
@@ -420,8 +427,42 @@ export type ListContentsFilters = {
|
|
|
420
427
|
* true lists only the contents holding values a migration set aside
|
|
421
428
|
*/
|
|
422
429
|
setAside?: boolean;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* This filter is used to search the contents of one definition holding a value of a kind in one field
|
|
433
|
+
*/
|
|
434
|
+
field?: ListContentsFieldFilter;
|
|
423
435
|
};
|
|
424
436
|
|
|
437
|
+
/**
|
|
438
|
+
* This type represent the JSON type of a value in a content payload
|
|
439
|
+
*/
|
|
440
|
+
export type JsonValueType = "string" | "number" | "boolean" | "object" | "array";
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* This type represent a filter on the values of one field: the contents of the definition where an
|
|
444
|
+
* instance of its root, or of the fragment wherever the definition places it, holds an empty value
|
|
445
|
+
* (missing, null, "", [] or {}), a value, a text longer than `length`, or a value not of `type`. With
|
|
446
|
+
* `locale`, where that locale's translation of the field does. A field the definition does not have is
|
|
447
|
+
* refused with `FieldNotFound`
|
|
448
|
+
*/
|
|
449
|
+
export type ListContentsFieldFilter = {
|
|
450
|
+
definitionId: ContentDefinitionId;
|
|
451
|
+
/**
|
|
452
|
+
* The fragment holding the field, the definition's root without it
|
|
453
|
+
*/
|
|
454
|
+
fragment?: string;
|
|
455
|
+
/**
|
|
456
|
+
* The field name
|
|
457
|
+
*/
|
|
458
|
+
name: string;
|
|
459
|
+
locale?: string;
|
|
460
|
+
} & (
|
|
461
|
+
| { is: "empty" | "notEmpty" }
|
|
462
|
+
| { is: "longerThan"; length: number }
|
|
463
|
+
| { is: "notType"; type: JsonValueType }
|
|
464
|
+
);
|
|
465
|
+
|
|
425
466
|
/**
|
|
426
467
|
* This type represent the data needed to make a list content API request
|
|
427
468
|
*/
|
|
@@ -952,3 +993,263 @@ export type AnalysePersonalizedRulesResponse = {
|
|
|
952
993
|
*/
|
|
953
994
|
fields: PersonalizedFieldCoverage[];
|
|
954
995
|
};
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* This type represent the data needed to make a profile content values API request: what the
|
|
999
|
+
* definition's contents, archived ones included, hold in the fields of its root or of one of its
|
|
1000
|
+
* fragments wherever the definition places it. For investigating, never for a form
|
|
1001
|
+
*/
|
|
1002
|
+
export type ProfileContentValuesRequest = {
|
|
1003
|
+
definitionId: ContentDefinitionId;
|
|
1004
|
+
/**
|
|
1005
|
+
* The fragment to profile, the definition's root without it
|
|
1006
|
+
*/
|
|
1007
|
+
fragment?: string;
|
|
1008
|
+
/**
|
|
1009
|
+
* The fields to profile, from 1 to 100, all of them without it
|
|
1010
|
+
*/
|
|
1011
|
+
fields?: string[];
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* This type represent what the contents hold in one field
|
|
1016
|
+
*/
|
|
1017
|
+
export type FieldValuesProfile = {
|
|
1018
|
+
name: string;
|
|
1019
|
+
type: string;
|
|
1020
|
+
/**
|
|
1021
|
+
* The objects of the place, each holding the field or not
|
|
1022
|
+
*/
|
|
1023
|
+
instances: number;
|
|
1024
|
+
values: number;
|
|
1025
|
+
/**
|
|
1026
|
+
* The instances holding null, "", [], {} or nothing
|
|
1027
|
+
*/
|
|
1028
|
+
empty: number;
|
|
1029
|
+
/**
|
|
1030
|
+
* The contents holding at least one value
|
|
1031
|
+
*/
|
|
1032
|
+
contents: number;
|
|
1033
|
+
/**
|
|
1034
|
+
* The values by JSON type
|
|
1035
|
+
*/
|
|
1036
|
+
types: { [type in JsonValueType]?: number };
|
|
1037
|
+
/**
|
|
1038
|
+
* The lengths of the text values, null without any
|
|
1039
|
+
*/
|
|
1040
|
+
length: { min: number; max: number; p95: number } | null;
|
|
1041
|
+
/**
|
|
1042
|
+
* The translations holding text, by locale, null for a field that is not translatable
|
|
1043
|
+
*/
|
|
1044
|
+
translations: { [locale: string]: number } | null;
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* This type represent the response of a profile content values API request. A fragment nested in itself
|
|
1049
|
+
* is followed one level deep, and a profile whose queries outlast their time is refused with
|
|
1050
|
+
* `ProfileTooLarge`
|
|
1051
|
+
*/
|
|
1052
|
+
export type ProfileContentValuesResponse = {
|
|
1053
|
+
definitionId: ContentDefinitionId;
|
|
1054
|
+
fragment: string | null;
|
|
1055
|
+
contents: { total: number; archived: number };
|
|
1056
|
+
/**
|
|
1057
|
+
* Where the fragment sits, as `blocks[]<seo>` (an array of `oneFragmentOf` holding it) or
|
|
1058
|
+
* `hero.variants[]` (a personalized field's variants), empty for the root
|
|
1059
|
+
*/
|
|
1060
|
+
placements: string[];
|
|
1061
|
+
/**
|
|
1062
|
+
* The objects of the place found in the contents
|
|
1063
|
+
*/
|
|
1064
|
+
instances: number;
|
|
1065
|
+
fields: FieldValuesProfile[];
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* This type represent the kind of a version in a content's history: what a publish published, or the
|
|
1070
|
+
* content as a restore found it, unpublished edits and translations included
|
|
1071
|
+
*/
|
|
1072
|
+
export type ContentHistoryKind = "published" | "beforeRestore";
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* This type represent the data needed to make a list content history API request
|
|
1076
|
+
*/
|
|
1077
|
+
export type ListContentHistoryRequest = {
|
|
1078
|
+
contentId: ContentId;
|
|
1079
|
+
/**
|
|
1080
|
+
* 0 by default
|
|
1081
|
+
*/
|
|
1082
|
+
skip?: number;
|
|
1083
|
+
/**
|
|
1084
|
+
* 20 by default, at most 100
|
|
1085
|
+
*/
|
|
1086
|
+
take?: number;
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* This type represent a version in a content's history
|
|
1091
|
+
*/
|
|
1092
|
+
export type ContentHistoryEntry = {
|
|
1093
|
+
kind: ContentHistoryKind;
|
|
1094
|
+
/**
|
|
1095
|
+
* The publishing request's id for a `published` version, the restore's for a `beforeRestore` one
|
|
1096
|
+
*/
|
|
1097
|
+
id: number;
|
|
1098
|
+
/**
|
|
1099
|
+
* The content's version at the time
|
|
1100
|
+
*/
|
|
1101
|
+
version: number;
|
|
1102
|
+
date: Date;
|
|
1103
|
+
/**
|
|
1104
|
+
* Who published or restored, null when unknown
|
|
1105
|
+
*/
|
|
1106
|
+
author: Pick<AuthorResponse, "authorId" | "fullName"> | null;
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* This type represent the response of a list content history API request: newest first, without the
|
|
1111
|
+
* publishes that failed or are still running
|
|
1112
|
+
*/
|
|
1113
|
+
export type ListContentHistoryResponse = {
|
|
1114
|
+
items: ContentHistoryEntry[];
|
|
1115
|
+
total: number;
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* This type represent the data needed to make a get content history entry API request
|
|
1120
|
+
*/
|
|
1121
|
+
export type GetContentHistoryEntryRequest = {
|
|
1122
|
+
contentId: ContentId;
|
|
1123
|
+
kind: ContentHistoryKind;
|
|
1124
|
+
id: number;
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* This type represent a violation of one constraint. `code` is one of [[ContentFieldViolationCodes]], or
|
|
1129
|
+
* of the translation ones such as `translation.unknownField`
|
|
1130
|
+
*/
|
|
1131
|
+
export type ContentConstraintViolation = {
|
|
1132
|
+
path?: string;
|
|
1133
|
+
code: string;
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* This type represent the violations of one item of an array field, matched by its `itemKey`
|
|
1138
|
+
*/
|
|
1139
|
+
export type ContentArrayItemViolation = {
|
|
1140
|
+
itemKey: string;
|
|
1141
|
+
index: number;
|
|
1142
|
+
violations: (ContentConstraintViolation | ContentFieldViolation)[];
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* This type represent the violations of one field of a payload, as an update content API request answers
|
|
1147
|
+
* them in its `validation`
|
|
1148
|
+
*/
|
|
1149
|
+
export type ContentFieldViolation = {
|
|
1150
|
+
field: string;
|
|
1151
|
+
violations: (
|
|
1152
|
+
| ContentConstraintViolation
|
|
1153
|
+
| ContentFieldViolation
|
|
1154
|
+
| ContentArrayItemViolation
|
|
1155
|
+
)[];
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* This type represent what keeps a version of the history from being restored, all empty when it can be
|
|
1160
|
+
*/
|
|
1161
|
+
export type RestoreViolations = {
|
|
1162
|
+
payload: ContentFieldViolation[];
|
|
1163
|
+
/**
|
|
1164
|
+
* Per locale, the violations of its translated values
|
|
1165
|
+
*/
|
|
1166
|
+
translations: { locale: string; violations: ContentConstraintViolation[] }[];
|
|
1167
|
+
/**
|
|
1168
|
+
* Values a component migration since would set aside: the definition has no place for them any more
|
|
1169
|
+
*/
|
|
1170
|
+
setAside: { path: string; reason: "removed" | "changed" }[];
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* This type represent the response of a get content history entry API request: the version as a restore
|
|
1175
|
+
* would write it, migrated to the definition as it is now, so it compares key by key with the get content
|
|
1176
|
+
* API request's
|
|
1177
|
+
*/
|
|
1178
|
+
export type GetContentHistoryEntryResponse = ContentHistoryEntry & {
|
|
1179
|
+
payload: object;
|
|
1180
|
+
translations: { locale: string; translations: FieldTranslation[] }[];
|
|
1181
|
+
restorable: boolean;
|
|
1182
|
+
violations: RestoreViolations;
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* This type represent the data needed to make a restore content API request
|
|
1187
|
+
*/
|
|
1188
|
+
export type RestoreContentRequest = {
|
|
1189
|
+
contentId: ContentId;
|
|
1190
|
+
kind: ContentHistoryKind;
|
|
1191
|
+
id: number;
|
|
1192
|
+
/**
|
|
1193
|
+
* The version the person saw: a save made meanwhile is refused with `VersionMoved` rather than
|
|
1194
|
+
* overwritten unseen
|
|
1195
|
+
*/
|
|
1196
|
+
expectedVersion?: number;
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* This type represent the response of a restore content API request: the content as an update content
|
|
1201
|
+
* API request answers it
|
|
1202
|
+
*/
|
|
1203
|
+
export type RestoreContentResponse = UpdateContentResponse;
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Thin enum represent the error types of the content API requests: the update content one, and the content
|
|
1207
|
+
* history ones. Each is the `type` of a `RequestError`, whose `details` is a [[ContentError]]
|
|
1208
|
+
*/
|
|
1209
|
+
export enum ContentErrorTypes {
|
|
1210
|
+
contentNotFound = "ContentNotFound",
|
|
1211
|
+
failedContentPayloadValidation = "FailedContentPayloadValidation",
|
|
1212
|
+
publicIdNotExclusiveToDefinitionId = "PublicIdNotExclusiveToDefinitionId",
|
|
1213
|
+
versionMoved = "VersionMoved",
|
|
1214
|
+
definitionMoved = "DefinitionMoved",
|
|
1215
|
+
historyEntryNotFound = "HistoryEntryNotFound",
|
|
1216
|
+
restoreRefused = "RestoreRefused",
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
type ContentErrorOf<T extends ContentErrorTypes, D = {}> = {
|
|
1220
|
+
type: T;
|
|
1221
|
+
message: string;
|
|
1222
|
+
} & D;
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* This type represent the `details` of a `RequestError` whose `type` is one of [[ContentErrorTypes]]
|
|
1226
|
+
*/
|
|
1227
|
+
export type ContentError =
|
|
1228
|
+
| ContentErrorOf<ContentErrorTypes.contentNotFound>
|
|
1229
|
+
/**
|
|
1230
|
+
* The payload does not fit its definition, field by field; nothing was written
|
|
1231
|
+
*/
|
|
1232
|
+
| ContentErrorOf<
|
|
1233
|
+
ContentErrorTypes.failedContentPayloadValidation,
|
|
1234
|
+
{ validation: ContentFieldViolation[] }
|
|
1235
|
+
>
|
|
1236
|
+
/**
|
|
1237
|
+
* The public id is in use on a content of another definition
|
|
1238
|
+
*/
|
|
1239
|
+
| ContentErrorOf<ContentErrorTypes.publicIdNotExclusiveToDefinitionId>
|
|
1240
|
+
/**
|
|
1241
|
+
* The content is no longer at `expectedVersion`: read it again
|
|
1242
|
+
*/
|
|
1243
|
+
| ContentErrorOf<ContentErrorTypes.versionMoved>
|
|
1244
|
+
/**
|
|
1245
|
+
* The definition changed while the content was saved or restored: try again
|
|
1246
|
+
*/
|
|
1247
|
+
| ContentErrorOf<ContentErrorTypes.definitionMoved>
|
|
1248
|
+
| ContentErrorOf<ContentErrorTypes.historyEntryNotFound>
|
|
1249
|
+
/**
|
|
1250
|
+
* The version does not fit the definition as it is now; nothing was written
|
|
1251
|
+
*/
|
|
1252
|
+
| ContentErrorOf<
|
|
1253
|
+
ContentErrorTypes.restoreRefused,
|
|
1254
|
+
{ violations: RestoreViolations }
|
|
1255
|
+
>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentchef/contentchef-types",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.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": "411c20107357815791bd9bfaa1af348f40e88aa5"
|
|
38
38
|
}
|