@contentchef/contentchef-types 10.1.0-alpha.0 → 10.1.0-alpha.10

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.
@@ -0,0 +1,564 @@
1
+ import { AuthorResponse } from './Author';
2
+ import { PagedListResponse } from './common';
3
+ import { ContentId, ListContentsFilters } from './Content';
4
+
5
+ /**
6
+ * The content export request unique id
7
+ */
8
+ export type ContentExportRequestId = number;
9
+
10
+ /**
11
+ * The content import request unique id
12
+ */
13
+ export type ContentImportRequestId = number;
14
+
15
+ /**
16
+ * The content import request item unique id
17
+ */
18
+ export type ContentImportRequestItemId = number;
19
+
20
+ /**
21
+ * This enum represent the file format of a content export, and the format an import file is read with
22
+ */
23
+ export enum ContentExportFormat {
24
+ JSON = 'json',
25
+ CSV = 'csv'
26
+ }
27
+
28
+ /**
29
+ * This enum represent the lifecycle of a content export request. Exports are processed
30
+ * asynchronously, so a freshly created request is always `queued`
31
+ */
32
+ export enum ContentExportStatus {
33
+ QUEUED = 'queued',
34
+ PROCESSING = 'processing',
35
+ COMPLETED = 'completed',
36
+ FAILED = 'failed'
37
+ }
38
+
39
+ /**
40
+ * This enum represent the lifecycle of a content import request. A freshly created request is
41
+ * `awaiting_upload` until the import file is uploaded to
42
+ * [[CreateContentImportRequestResponse.uploadUrl]], which is what starts the import
43
+ */
44
+ export enum ContentImportStatus {
45
+ AWAITING_UPLOAD = 'awaiting_upload',
46
+ PROCESSING = 'processing',
47
+ COMPLETED = 'completed',
48
+ COMPLETED_WITH_ERRORS = 'completed_with_errors',
49
+ FAILED = 'failed'
50
+ }
51
+
52
+ /**
53
+ * This enum represent what an imported row describes: the content itself or one of its translations
54
+ */
55
+ export enum ContentImportRowType {
56
+ CONTENT = 'content',
57
+ TRANSLATION = 'translation'
58
+ }
59
+
60
+ /**
61
+ * This enum represent the outcome of a single imported row
62
+ */
63
+ export enum ContentImportItemStatus {
64
+ SUCCESS = 'success',
65
+ FAILED = 'failed'
66
+ }
67
+
68
+ /**
69
+ * This enum represent what the import did to the content of a successfully imported row
70
+ */
71
+ export enum ContentImportItemAction {
72
+ UPDATED = 'updated'
73
+ }
74
+
75
+ /**
76
+ * This type represent the error attached to a failed content export or import request
77
+ */
78
+ export type ContentExportImportError = {
79
+ /**
80
+ * The error type discriminator
81
+ */
82
+ type: string;
83
+ /**
84
+ * The human readable error message
85
+ */
86
+ message: string;
87
+ };
88
+
89
+ /**
90
+ * This type represent one of the files produced by a content export, one per exported content
91
+ * definition. The whole list is written when the export completes, so a `processing` export
92
+ * exposes no file yet
93
+ */
94
+ export type ContentExportFile = {
95
+ /**
96
+ * The mnemonic id of the content definition the file contains the contents of
97
+ */
98
+ definitionMnemonicId: string;
99
+ /**
100
+ * The internal storage key of the file. Not fetchable as is, pass
101
+ * [[definitionMnemonicId]] to [[ContentExportImportFacade.downloadExport]] to get a
102
+ * downloadable url
103
+ */
104
+ s3Key: string;
105
+ /**
106
+ * The number of contents written in the file
107
+ */
108
+ itemCount: number;
109
+ };
110
+
111
+ /**
112
+ * This type represent the model of a content export request
113
+ */
114
+ export type ContentExportRequestResponse = {
115
+ /**
116
+ * The content export request unique id
117
+ */
118
+ id: ContentExportRequestId;
119
+ /**
120
+ * The space the exported contents belong to
121
+ */
122
+ spaceId: string;
123
+ /**
124
+ * The current status of the export
125
+ */
126
+ status: ContentExportStatus;
127
+ /**
128
+ * The filters the exported contents have been selected with
129
+ */
130
+ filters: ListContentsFilters;
131
+ /**
132
+ * The format the export files are written in
133
+ */
134
+ format: ContentExportFormat;
135
+ /**
136
+ * The separator used by the exported csv files. Meaningless when [[format]] is `json`
137
+ */
138
+ csvSeparator: string;
139
+ /**
140
+ * The produced files, one per exported content definition. Empty until [[status]] is
141
+ * `completed`, the whole list is written in one go when the export finalizes
142
+ */
143
+ files: ContentExportFile[] | null;
144
+ /**
145
+ * The error describing why the export failed, null unless [[status]] is `failed`
146
+ */
147
+ error: ContentExportImportError | null;
148
+ /**
149
+ * The author that requested the export
150
+ */
151
+ author: AuthorResponse;
152
+ /**
153
+ * The last author that modified the export request. Only returned by
154
+ * [[ContentExportImportFacade.createExport]], the listing does not resolve it
155
+ */
156
+ latestContributor?: AuthorResponse;
157
+ /**
158
+ * The export request creation date
159
+ */
160
+ createdDate: Date;
161
+ /**
162
+ * The export request last modified date
163
+ */
164
+ lastModifiedDate: Date;
165
+ };
166
+
167
+ /**
168
+ * This type represent the data needed to make a create content export request API request
169
+ */
170
+ export type CreateContentExportRequestRequest = {
171
+ /**
172
+ * The filters selecting the contents to export, the same ones accepted by
173
+ * [[ContentFacade.list]]. When omitted every unarchived content of the space is exported.
174
+ * [[ListContentsFilters.contentsStatus]] cannot be given: archived contents cannot be
175
+ * imported back, so an export always covers the unarchived ones only
176
+ */
177
+ filters?: Omit<Partial<ListContentsFilters>, 'contentsStatus'>;
178
+ /**
179
+ * The format to write the export files in, defaults to `json`
180
+ */
181
+ format?: ContentExportFormat;
182
+ /**
183
+ * The single character separator to write the exported csv files with, defaults to `,`.
184
+ * Ignored when [[format]] is `json`
185
+ */
186
+ csvSeparator?: string;
187
+ };
188
+
189
+ /**
190
+ * This type represent the response of a create content export request API request.
191
+ * The returned export is always `queued`: it is processed asynchronously
192
+ */
193
+ export type CreateContentExportRequestResponse = ContentExportRequestResponse;
194
+
195
+ /**
196
+ * This type represent the data needed to make a list content export requests API request
197
+ */
198
+ export type ListContentExportRequestsRequest = {
199
+ /**
200
+ * The export requests to skip (used to paginate the result), defaults to 0
201
+ */
202
+ skip?: number;
203
+ /**
204
+ * The export requests to take (used to paginate the result), defaults to 20.
205
+ * Cannot exceed [[MAX_CONTENT_EXPORT_IMPORT_PAGE_SIZE]]
206
+ */
207
+ take?: number;
208
+ };
209
+
210
+ /**
211
+ * This type represent the response of a list content export requests API request,
212
+ * sorted by [[ContentExportRequestResponse.createdDate]] descending
213
+ */
214
+ export type ListContentExportRequestsResponse = PagedListResponse<ContentExportRequestResponse>;
215
+
216
+ /**
217
+ * This type represent the data needed to make a download content export API request
218
+ */
219
+ export type DownloadContentExportRequest = {
220
+ /**
221
+ * The unique id of the completed export request to download a file of
222
+ */
223
+ exportRequestId: ContentExportRequestId;
224
+ /**
225
+ * The mnemonic id of the content definition whose exported file is wanted.
226
+ * It must be one of the [[ContentExportRequestResponse.files]] entries
227
+ */
228
+ definitionMnemonicId: string;
229
+ };
230
+
231
+ /**
232
+ * This type represent the response of a download content export API request
233
+ */
234
+ export type DownloadContentExportResponse = {
235
+ /**
236
+ * The mnemonic id of the content definition the file contains the contents of
237
+ */
238
+ definitionMnemonicId: string;
239
+ /**
240
+ * The temporary url to download the exported file from. The client does not download the
241
+ * file, fetch this url yourself
242
+ */
243
+ downloadUrl: string;
244
+ /**
245
+ * The number of seconds [[downloadUrl]] stays valid for
246
+ */
247
+ expiresInSeconds: number;
248
+ /**
249
+ * The number of contents written in the file
250
+ */
251
+ itemCount: number;
252
+ };
253
+
254
+ /**
255
+ * This type represent the options a content import file is read with
256
+ */
257
+ export type ContentImportOptions = {
258
+ /**
259
+ * The format the import file is read as
260
+ */
261
+ format: ContentExportFormat;
262
+ /**
263
+ * The separator the imported csv file is read with. Meaningless when [[format]] is `json`
264
+ */
265
+ csvSeparator?: string;
266
+ /**
267
+ * Whether payloads violating their content definition schema are applied anyway, with the
268
+ * violations logged instead of failing the row
269
+ */
270
+ skipPayloadValidation?: boolean;
271
+ };
272
+
273
+ /**
274
+ * This type represent the model of a content import request
275
+ */
276
+ export type ContentImportRequestResponse = {
277
+ /**
278
+ * The content import request unique id
279
+ */
280
+ id: ContentImportRequestId;
281
+ /**
282
+ * The space the contents are imported in
283
+ */
284
+ spaceId: string;
285
+ /**
286
+ * The current status of the import
287
+ */
288
+ status: ContentImportStatus;
289
+ /**
290
+ * The name of the uploaded file, as declared when the import was created. Null when not declared
291
+ */
292
+ fileName: string | null;
293
+ /**
294
+ * The storage key the import file is expected at
295
+ */
296
+ s3Key: string;
297
+ /**
298
+ * The options the import file is read with
299
+ */
300
+ options: ContentImportOptions;
301
+ /**
302
+ * The arn of the workflow execution processing the import.
303
+ * Null while the import is still `awaiting_upload`
304
+ */
305
+ executionArn: string | null;
306
+ /**
307
+ * The number of rows found in the import file, null until the file has been read
308
+ */
309
+ totalItems: number | null;
310
+ /**
311
+ * The number of successfully imported rows, null until the import completes
312
+ */
313
+ succeededItems: number | null;
314
+ /**
315
+ * The number of rows that failed to import, null until the import completes.
316
+ * When greater than 0 the [[status]] is `completed_with_errors`
317
+ */
318
+ failedItems: number | null;
319
+ /**
320
+ * The error describing why the whole import failed, null unless [[status]] is `failed`.
321
+ * Single row failures are reported by [[ContentImportRequestItemResponse.error]] instead
322
+ */
323
+ error: ContentExportImportError | null;
324
+ /**
325
+ * The author that requested the import
326
+ */
327
+ author: AuthorResponse;
328
+ /**
329
+ * The import request creation date
330
+ */
331
+ createdDate: Date;
332
+ /**
333
+ * The import request last modified date
334
+ */
335
+ lastModifiedDate: Date;
336
+ };
337
+
338
+ /**
339
+ * This type represent the data needed to make a create content import request API request
340
+ */
341
+ export type CreateContentImportRequestRequest = {
342
+ /**
343
+ * The name of the file about to be uploaded, kept for display purposes only
344
+ */
345
+ fileName?: string;
346
+ /**
347
+ * The options to read the uploaded file with
348
+ */
349
+ options?: {
350
+ /**
351
+ * The format the uploaded file is read as, defaults to `json`
352
+ */
353
+ format?: ContentExportFormat;
354
+ /**
355
+ * The single character separator the uploaded csv file is read with, defaults to `,`.
356
+ * Ignored when [[format]] is `json`
357
+ */
358
+ csvSeparator?: string;
359
+ /**
360
+ * Whether to apply payloads that violate their content definition schema, recording the
361
+ * violations instead of failing the row. Defaults to false.
362
+ * [[ContentExportImportFacade.retryImport]] can turn it on for an already uploaded file
363
+ */
364
+ skipPayloadValidation?: boolean;
365
+ };
366
+ };
367
+
368
+ /**
369
+ * This type represent the response of a create content import request API request
370
+ */
371
+ export type CreateContentImportRequestResponse = {
372
+ /**
373
+ * The created content import request unique id
374
+ */
375
+ importRequestId: ContentImportRequestId;
376
+ /**
377
+ * The storage key the file is uploaded to
378
+ */
379
+ s3Key: string;
380
+ /**
381
+ * The temporary url to upload the import file to, with a `PUT` and a `Content-Type` of
382
+ * `text/csv` or `application/json` matching the requested format. The client does not upload
383
+ * the file, upload it yourself: the upload is what starts the import
384
+ */
385
+ uploadUrl: string;
386
+ /**
387
+ * The number of seconds [[uploadUrl]] stays valid for
388
+ */
389
+ expiresInSeconds: number;
390
+ };
391
+
392
+ /**
393
+ * This type represent the data needed to make a retry content import API request
394
+ */
395
+ export type RetryContentImportRequest = {
396
+ /**
397
+ * The unique id of the import request to re-run the file of. It must have been uploaded:
398
+ * an import still `awaiting_upload` has nothing to retry
399
+ */
400
+ importRequestId: ContentImportRequestId;
401
+ /**
402
+ * Whether to apply payloads that violate their content definition schema, recording the
403
+ * violations instead of failing the row. Use it to push through a run whose validation
404
+ * failures have been judged acceptable. Defaults to false
405
+ */
406
+ skipPayloadValidation?: boolean;
407
+ };
408
+
409
+ /**
410
+ * This type represent the response of a retry content import API request.
411
+ * A retry is a new import request re-running the whole original file, not only its failed rows:
412
+ * imports are update only and idempotent. Nothing has to be uploaded again, the file is copied
413
+ * server side, and that copy is what starts the new import
414
+ */
415
+ export type RetryContentImportResponse = {
416
+ /**
417
+ * The unique id of the created import request, the one to follow from now on
418
+ */
419
+ importRequestId: ContentImportRequestId;
420
+ /**
421
+ * The unique id of the import request being retried
422
+ */
423
+ retryOf: ContentImportRequestId;
424
+ /**
425
+ * The storage key the original file has been copied to
426
+ */
427
+ s3Key: string;
428
+ /**
429
+ * Whether the retry applies payloads violating their content definition schema
430
+ */
431
+ skipPayloadValidation: boolean;
432
+ };
433
+
434
+ /**
435
+ * This type represent the data needed to make a list content import requests API request
436
+ */
437
+ export type ListContentImportRequestsRequest = {
438
+ /**
439
+ * The import requests to skip (used to paginate the result), defaults to 0
440
+ */
441
+ skip?: number;
442
+ /**
443
+ * The import requests to take (used to paginate the result), defaults to 20.
444
+ * Cannot exceed [[MAX_CONTENT_EXPORT_IMPORT_PAGE_SIZE]]
445
+ */
446
+ take?: number;
447
+ };
448
+
449
+ /**
450
+ * This type represent the response of a list content import requests API request,
451
+ * sorted by [[ContentImportRequestResponse.createdDate]] descending
452
+ */
453
+ export type ListContentImportRequestsResponse = PagedListResponse<ContentImportRequestResponse>;
454
+
455
+ /**
456
+ * This type represent the error attached to a single failed imported row
457
+ */
458
+ export type ContentImportItemError = {
459
+ /**
460
+ * The error code discriminator
461
+ */
462
+ code: string;
463
+ /**
464
+ * The human readable error message
465
+ */
466
+ message?: string;
467
+ /**
468
+ * The error additional details, their shape depends on [[code]]
469
+ */
470
+ details?: any;
471
+ };
472
+
473
+ /**
474
+ * This type represent the outcome of a single row of a content import. One item is written per
475
+ * content row plus one per translation row, so a content with 3 translated locales produces 4 items
476
+ */
477
+ export type ContentImportRequestItemResponse = {
478
+ /**
479
+ * The content import request item unique id
480
+ */
481
+ id: ContentImportRequestItemId;
482
+ /**
483
+ * The space the contents are imported in
484
+ */
485
+ spaceId: string;
486
+ /**
487
+ * The unique id of the import request the item belongs to
488
+ */
489
+ importRequestId: ContentImportRequestId;
490
+ /**
491
+ * The zero based position of the row in the import file
492
+ */
493
+ itemIndex: number;
494
+ /**
495
+ * The public id of the imported content, null when the row did not carry a readable one
496
+ */
497
+ publicId: string | null;
498
+ /**
499
+ * The mnemonic id of the imported content definition, null when the row did not carry a
500
+ * readable one
501
+ */
502
+ definitionMnemonicId: string | null;
503
+ /**
504
+ * Whether the row describes the content itself or one of its translations
505
+ */
506
+ rowType: ContentImportRowType;
507
+ /**
508
+ * The locale the row has been imported in. Always null when [[rowType]] is `content`:
509
+ * only translation rows are locale specific
510
+ */
511
+ locale: string | null;
512
+ /**
513
+ * What the import did to the content. Null when the row failed, and on a translation row
514
+ * that carried nothing to apply, which succeeds as a no-op
515
+ */
516
+ action: ContentImportItemAction | null;
517
+ /**
518
+ * The outcome of the row
519
+ */
520
+ status: ContentImportItemStatus;
521
+ /**
522
+ * The unique id of the imported content, null when the row failed before the content
523
+ * could be resolved
524
+ */
525
+ contentId: ContentId | null;
526
+ /**
527
+ * The error describing why the row failed, null unless [[status]] is `failed`
528
+ */
529
+ error: ContentImportItemError | null;
530
+ };
531
+
532
+ /**
533
+ * This type represent the data needed to make a list content import request items API request
534
+ */
535
+ export type ListContentImportRequestItemsRequest = {
536
+ /**
537
+ * The unique id of the import request to list the items of
538
+ */
539
+ importRequestId: ContentImportRequestId;
540
+ /**
541
+ * The items to skip (used to paginate the result), defaults to 0
542
+ */
543
+ skip?: number;
544
+ /**
545
+ * The items to take (used to paginate the result), defaults to 50.
546
+ * Cannot exceed [[MAX_CONTENT_EXPORT_IMPORT_PAGE_SIZE]]
547
+ */
548
+ take?: number;
549
+ /**
550
+ * This filter is used to list only the items with the given outcome, typically `failed` to
551
+ * review what an import could not apply. When omitted every item is returned
552
+ */
553
+ status?: ContentImportItemStatus;
554
+ };
555
+
556
+ /**
557
+ * This type represent the response of a list content import request items API request
558
+ */
559
+ export type ListContentImportRequestItemsResponse = PagedListResponse<ContentImportRequestItemResponse>;
560
+
561
+ /**
562
+ * The maximum number of items a content export or import list API request can take in a single page
563
+ */
564
+ export const MAX_CONTENT_EXPORT_IMPORT_PAGE_SIZE = 100;