@contentchef/contentchef-types 11.2.0-alpha.0 → 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.
@@ -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
@@ -987,3 +992,179 @@ export type ProfileContentValuesResponse = {
987
992
  instances: number;
988
993
  fields: FieldValuesProfile[];
989
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 {};
@@ -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 = {}));
@@ -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
  /**
@@ -1057,3 +1064,192 @@ export type ProfileContentValuesResponse = {
1057
1064
  instances: number;
1058
1065
  fields: FieldValuesProfile[];
1059
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.2.0-alpha.0",
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": "30ca15f956b396cce7e0db037e836b79406278cf"
37
+ "gitHead": "411c20107357815791bd9bfaa1af348f40e88aa5"
38
38
  }