@contentchef/contentchef-types 11.1.0-alpha.0 → 11.1.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.
@@ -1,7 +1,7 @@
1
1
  import { AuthorResponse } from './Author';
2
2
  import { PagedListResponse } from './common';
3
3
  import { AttributeViolation, ContentDefinitionId, GetContentDefinitionResponse, SchemaFieldViolationsErrors } from './ContentDefinition';
4
- import { FragmentDefinition } from './ContentDefinitionSchema';
4
+ import { ContentDefinitionSchemaInput, Field, FragmentDefinition } from './ContentDefinitionSchema';
5
5
  /**
6
6
  * The component unique id
7
7
  */
@@ -16,14 +16,24 @@ export declare const COMPONENT_NAME_PATTERN: RegExp;
16
16
  * else. Its labels, hints, placeholders and list value labels need at least one locale, any locale
17
17
  */
18
18
  export type ComponentFragment = Omit<FragmentDefinition, 'component'>;
19
+ /**
20
+ * This type represent a field a version renames, declared when it is published so that the values
21
+ * written under the old name follow
22
+ */
23
+ export type ComponentRename = {
24
+ from: string;
25
+ to: string;
26
+ };
19
27
  /**
20
28
  * This type represent field names, by what happened to them between two versions of a fragment.
21
- * A field whose type changed is `changed`
29
+ * A field whose type changed is `changed`; a renamed field is in `renamed`, and in neither `added` nor
30
+ * `removed`
22
31
  */
23
32
  export type FieldChanges = {
24
33
  added: string[];
25
34
  removed: string[];
26
35
  changed: string[];
36
+ renamed: ComponentRename[];
27
37
  };
28
38
  /**
29
39
  * This type represent the author of a component, or of one of its versions
@@ -206,6 +216,12 @@ export type PublishComponentRequest = {
206
216
  * A note on the version, at most 2000 characters
207
217
  */
208
218
  note?: string;
219
+ /**
220
+ * The fields the version renames: `from` a field of the latest version the draft no longer has, `to`
221
+ * a field of the draft the latest version does not have, of the same type and changed only as a kept
222
+ * field may. A name is in one rename at most
223
+ */
224
+ renames?: ComponentRename[];
209
225
  };
210
226
  /**
211
227
  * This type represent the response of a publish component API request, its `version` the one just
@@ -274,9 +290,11 @@ export declare enum ComponentErrorTypes {
274
290
  componentArchived = "ComponentArchived",
275
291
  componentAdoptionRequired = "ComponentAdoptionRequired",
276
292
  componentDowngradeRefused = "ComponentDowngradeRefused",
277
- componentUpgradeBlocked = "ComponentUpgradeBlocked",
278
293
  noFragmentToAdopt = "NoFragmentToAdopt",
279
- noFragmentToPromote = "NoFragmentToPromote"
294
+ noFragmentToPromote = "NoFragmentToPromote",
295
+ definitionMigrating = "DefinitionMigrating",
296
+ oneMigrationPerSave = "OneMigrationPerSave",
297
+ migrationPreviewNotFound = "MigrationPreviewNotFound"
280
298
  }
281
299
  /**
282
300
  * Thin enum represent the codes of a [[ComponentVersionViolation]]
@@ -293,7 +311,11 @@ export declare enum ComponentVersionViolationCodes {
293
311
  /**
294
312
  * A kept field may only change its texts, or loosen its constraints
295
313
  */
296
- notLooser = "component.notLooser"
314
+ notLooser = "component.notLooser",
315
+ /**
316
+ * A rename must go from a field the draft no longer has to a new one of the same type
317
+ */
318
+ invalidRename = "component.invalidRename"
297
319
  }
298
320
  /**
299
321
  * This type represent a field a new version may not change as the draft does
@@ -306,20 +328,6 @@ export type ComponentVersionViolation = {
306
328
  code: string;
307
329
  message: string;
308
330
  };
309
- /**
310
- * This type represent a field an upgrade removes or changes while contents hold a value in it
311
- */
312
- export type ComponentUpgradeBlockingField = {
313
- field: string;
314
- /**
315
- * How many contents, archived ones and translations included, hold a value in the field
316
- */
317
- contents: number;
318
- /**
319
- * Up to 20 of their content ids
320
- */
321
- examples: number[];
322
- };
323
331
  type ComponentErrorOf<T extends ComponentErrorTypes, D = {}> = {
324
332
  type: T;
325
333
  message: string;
@@ -365,18 +373,202 @@ export type ComponentError = ComponentErrorOf<ComponentErrorTypes.componentNotFo
365
373
  mnemonicId: string;
366
374
  from: number;
367
375
  to: number;
368
- }> | ComponentErrorOf<ComponentErrorTypes.componentUpgradeBlocked, {
376
+ }> | ComponentErrorOf<ComponentErrorTypes.noFragmentToAdopt, {
369
377
  fragment: string;
378
+ }> | ComponentErrorOf<ComponentErrorTypes.noFragmentToPromote, {
379
+ fragment: string;
380
+ }>
381
+ /**
382
+ * A save changing the schema while the definition's contents are still being migrated
383
+ */
384
+ | ComponentErrorOf<ComponentErrorTypes.definitionMigrating, DefinitionMigrationState>
385
+ /**
386
+ * A save that would migrate the values of more than one component: save one, then the next once it
387
+ * has finished
388
+ */
389
+ | ComponentErrorOf<ComponentErrorTypes.oneMigrationPerSave, {
390
+ mnemonicIds: string[];
391
+ }> | ComponentErrorOf<ComponentErrorTypes.migrationPreviewNotFound, {
392
+ id: MigrationPreviewId;
393
+ }>;
394
+ /**
395
+ * This type represent where a definition's contents stand, as the get content definition API request
396
+ * answers it
397
+ *
398
+ * An upgrade or adoption that renames, removes or retypes fields bumps the definition's revision and
399
+ * migrates its contents in the background, one migration at a time per definition
400
+ */
401
+ export type DefinitionMigrationState = {
402
+ /**
403
+ * Bumped by each save that migrates values
404
+ */
405
+ revision: number;
406
+ /**
407
+ * The contents, archived ones included, still waiting for the migration to `revision`, 0 when none
408
+ * runs. While above 0, a save changing the schema is refused with `DefinitionMigrating`
409
+ */
410
+ behind: number;
411
+ };
412
+ /**
413
+ * This type represent a translation of a value set aside
414
+ */
415
+ export type SetAsideTranslation = {
416
+ /**
417
+ * Relative to the value's `path`, empty for the value itself
418
+ */
419
+ key: string;
420
+ value: string | null;
421
+ checksum: string | null;
422
+ };
423
+ /**
424
+ * This type represent a value a migration could not carry, waiting beside its content for a person to
425
+ * move into a field or discard
426
+ */
427
+ export type SetAsideValue = {
428
+ /**
429
+ * The definition revision whose migration set it aside
430
+ */
431
+ revision: number;
432
+ /**
433
+ * The component it was a value of
434
+ */
370
435
  mnemonicId: string;
371
436
  /**
372
- * Null when the definition's own fragment is adopted
437
+ * Where it was, in the key format translation entries use, with the names the payload has now:
438
+ * `pic.credit`, `gallery.$k1.width`
439
+ */
440
+ path: string;
441
+ /**
442
+ * The field as the version it came from defined it, for the form to show the value
443
+ */
444
+ field: Field;
445
+ reason: 'removed' | 'changed';
446
+ /**
447
+ * Null when the value followed its field and only its translations, which have no place there, wait
448
+ */
449
+ value: unknown;
450
+ /**
451
+ * Its translations by locale
452
+ */
453
+ translations: {
454
+ [locale: string]: SetAsideTranslation[];
455
+ };
456
+ /**
457
+ * Absent while the content still waits for its migration: the value is set aside by the read
458
+ */
459
+ setAsideDate?: Date;
460
+ };
461
+ /**
462
+ * This type represent a value set aside that a content save resolves. The value itself moves in the
463
+ * payload, where the person put it, and is then deleted; values not named stay
464
+ */
465
+ export type SetAsideResolution = {
466
+ revision: number;
467
+ path: string;
468
+ /**
469
+ * The path of the field the value moved to, for its translations to follow there, where that field
470
+ * is translatable. Left out, the value is discarded
471
+ */
472
+ into?: string;
473
+ };
474
+ /**
475
+ * The migration preview unique id
476
+ */
477
+ export type MigrationPreviewId = number;
478
+ /**
479
+ * This type represent the data needed to make a migration preview API request: the definition, and the
480
+ * schema about to be saved with the update content definition API request or the adoption about to be made
481
+ */
482
+ export type MigrationPreviewRequest = {
483
+ id: ContentDefinitionId;
484
+ schema: ContentDefinitionSchemaInput;
485
+ } | {
486
+ id: ContentDefinitionId;
487
+ adopt: {
488
+ mnemonicId: string;
489
+ version: number;
490
+ };
491
+ };
492
+ /**
493
+ * This type represent the response of a migration preview API request: the preview's id, or null when
494
+ * the save would migrate nothing
495
+ */
496
+ export type MigrationPreviewResponse = {
497
+ id: MigrationPreviewId | null;
498
+ };
499
+ /**
500
+ * This type represent the data needed to make a get migration preview API request
501
+ */
502
+ export type GetMigrationPreviewRequest = {
503
+ id: MigrationPreviewId;
504
+ };
505
+ /**
506
+ * This type represent what a migration does to one field of the version the definition is on, whose
507
+ * values move or are checked
508
+ */
509
+ export type MigrationPreviewField = {
510
+ field: string;
511
+ outcome: 'renamed' | 'changed' | 'removed';
512
+ /**
513
+ * The field it becomes, null when removed
514
+ */
515
+ to: string | null;
516
+ /**
517
+ * The contents holding a value of it
518
+ */
519
+ contents: number;
520
+ renamed: number;
521
+ converted: number;
522
+ setAside: number;
523
+ /**
524
+ * The translations moved
525
+ */
526
+ translations: number;
527
+ /**
528
+ * Up to 20 of the contents' ids
529
+ */
530
+ examples: number[];
531
+ };
532
+ /**
533
+ * This type represent the response of a get migration preview API request, to poll until `status` is
534
+ * `done`. Previews are kept a day
535
+ */
536
+ export type GetMigrationPreviewResponse = {
537
+ id: MigrationPreviewId;
538
+ definitionId: ContentDefinitionId;
539
+ mnemonicId: string;
540
+ /**
541
+ * Null for an adoption
373
542
  */
374
543
  from: number | null;
375
544
  to: number;
376
- fields: ComponentUpgradeBlockingField[];
377
- }> | ComponentErrorOf<ComponentErrorTypes.noFragmentToAdopt, {
378
- fragment: string;
379
- }> | ComponentErrorOf<ComponentErrorTypes.noFragmentToPromote, {
380
- fragment: string;
381
- }>;
545
+ status: 'running' | 'done';
546
+ /**
547
+ * The contents walked so far, out of `total`
548
+ */
549
+ scanned: number;
550
+ total: number;
551
+ fields: MigrationPreviewField[];
552
+ /**
553
+ * The contents whose payload or translations would change
554
+ */
555
+ changing: number;
556
+ /**
557
+ * The contents that would hold values set aside
558
+ */
559
+ settingAside: number;
560
+ };
561
+ /**
562
+ * This type represent the data needed to make a resume migration API request
563
+ */
564
+ export type ResumeMigrationRequest = {
565
+ /**
566
+ * The content definition unique id
567
+ */
568
+ id: ContentDefinitionId;
569
+ };
570
+ /**
571
+ * This type represent the response of a resume migration API request
572
+ */
573
+ export type ResumeMigrationResponse = DefinitionMigrationState;
382
574
  export {};
@@ -22,9 +22,11 @@ var ComponentErrorTypes;
22
22
  ComponentErrorTypes["componentArchived"] = "ComponentArchived";
23
23
  ComponentErrorTypes["componentAdoptionRequired"] = "ComponentAdoptionRequired";
24
24
  ComponentErrorTypes["componentDowngradeRefused"] = "ComponentDowngradeRefused";
25
- ComponentErrorTypes["componentUpgradeBlocked"] = "ComponentUpgradeBlocked";
26
25
  ComponentErrorTypes["noFragmentToAdopt"] = "NoFragmentToAdopt";
27
26
  ComponentErrorTypes["noFragmentToPromote"] = "NoFragmentToPromote";
27
+ ComponentErrorTypes["definitionMigrating"] = "DefinitionMigrating";
28
+ ComponentErrorTypes["oneMigrationPerSave"] = "OneMigrationPerSave";
29
+ ComponentErrorTypes["migrationPreviewNotFound"] = "MigrationPreviewNotFound";
28
30
  })(ComponentErrorTypes || (exports.ComponentErrorTypes = ComponentErrorTypes = {}));
29
31
  /**
30
32
  * Thin enum represent the codes of a [[ComponentVersionViolation]]
@@ -43,4 +45,8 @@ var ComponentVersionViolationCodes;
43
45
  * A kept field may only change its texts, or loosen its constraints
44
46
  */
45
47
  ComponentVersionViolationCodes["notLooser"] = "component.notLooser";
48
+ /**
49
+ * A rename must go from a field the draft no longer has to a new one of the same type
50
+ */
51
+ ComponentVersionViolationCodes["invalidRename"] = "component.invalidRename";
46
52
  })(ComponentVersionViolationCodes || (exports.ComponentVersionViolationCodes = ComponentVersionViolationCodes = {}));
@@ -6,6 +6,7 @@ import { SchemaTypeIds } from "./ContentDefinitionSchema";
6
6
  import { ContentRepositoryId, ContentRepositoryResponse } from "./ContentRepository";
7
7
  import { ContentTranslation, ContentTranslationStatus } from "./ContentTranslation";
8
8
  import { CoverageReport } from "./Audience";
9
+ import { SetAsideResolution, SetAsideValue } from "./Component";
9
10
  /**
10
11
  * This type represent the content unique id type
11
12
  */
@@ -303,6 +304,11 @@ export type UpdateContentRequest = {
303
304
  * set an identifier coming from a third party application
304
305
  */
305
306
  externalIdentifier?: string;
307
+ /**
308
+ * The values a migration set aside that this save resolves, moved into the payload by the person or
309
+ * discarded
310
+ */
311
+ setAside?: SetAsideResolution[];
306
312
  };
307
313
  /**
308
314
  * This type represent the data that can be used to filter a list of contents
@@ -373,6 +379,10 @@ export type ListContentsFilters = {
373
379
  * audience mnemonic ids inserted. Several of them narrow the result like `tags` do
374
380
  */
375
381
  audiences?: string[];
382
+ /**
383
+ * true lists only the contents holding values a migration set aside
384
+ */
385
+ setAside?: boolean;
376
386
  };
377
387
  /**
378
388
  * This type represent the data needed to make a list content API request
@@ -655,9 +665,12 @@ export type LinkingContents = ContentResponse;
655
665
  */
656
666
  export type GetContentResponse = {
657
667
  /**
658
- * The requested content
668
+ * The requested content, migrated when it still waits for its definition's migration, with the values
669
+ * set aside beside it
659
670
  */
660
- content: ContentResponse | undefined;
671
+ content: (ContentResponse & {
672
+ setAside: SetAsideValue[];
673
+ }) | undefined;
661
674
  /**
662
675
  * The contents that use the requested content
663
676
  */
@@ -1,6 +1,6 @@
1
1
  import { AuthorResponse } from './Author';
2
2
  import { PagedListResponse } from './common';
3
- import { FieldChanges } from './Component';
3
+ import { DefinitionMigrationState, FieldChanges } from './Component';
4
4
  import { ComponentMarker, ContentDefinitionSchema, ContentDefinitionSchemaInput, Field, I18NDictionary } from './ContentDefinitionSchema';
5
5
  import { Extension } from './Extension';
6
6
  /**
@@ -195,8 +195,8 @@ export type DefinitionComponent = ComponentMarker & {
195
195
  */
196
196
  archived: boolean;
197
197
  /**
198
- * What upgrading from `version` to `latestVersion` would add, remove and change, all empty when up
199
- * to date. Whether the upgrade would be blocked by the contents is only known by trying it
198
+ * What upgrading from `version` to `latestVersion` would add, remove, change and rename, all empty
199
+ * when up to date. What it would do to the contents is only known by previewing it
200
200
  */
201
201
  changes: FieldChanges;
202
202
  };
@@ -216,6 +216,10 @@ export type GetContentDefinitionResponse = (Omit<ContentDefinitionResponse, 'com
216
216
  * The components the definition uses, each with its latest version and what upgrading to it changes
217
217
  */
218
218
  components: DefinitionComponent[];
219
+ /**
220
+ * Where the definition's contents stand in its migrations
221
+ */
222
+ migration: DefinitionMigrationState;
219
223
  }) | undefined;
220
224
  /**
221
225
  * This type represent the data needed to make a validate definition field API request
@@ -6,7 +6,7 @@ import {
6
6
  GetContentDefinitionResponse,
7
7
  SchemaFieldViolationsErrors
8
8
  } from './ContentDefinition';
9
- import { FragmentDefinition } from './ContentDefinitionSchema';
9
+ import { ContentDefinitionSchemaInput, Field, FragmentDefinition } from './ContentDefinitionSchema';
10
10
 
11
11
  /**
12
12
  * The component unique id
@@ -25,14 +25,25 @@ export const COMPONENT_NAME_PATTERN = /^[a-zA-Z0-9_]+$/;
25
25
  */
26
26
  export type ComponentFragment = Omit<FragmentDefinition, 'component'>;
27
27
 
28
+ /**
29
+ * This type represent a field a version renames, declared when it is published so that the values
30
+ * written under the old name follow
31
+ */
32
+ export type ComponentRename = {
33
+ from: string;
34
+ to: string;
35
+ };
36
+
28
37
  /**
29
38
  * This type represent field names, by what happened to them between two versions of a fragment.
30
- * A field whose type changed is `changed`
39
+ * A field whose type changed is `changed`; a renamed field is in `renamed`, and in neither `added` nor
40
+ * `removed`
31
41
  */
32
42
  export type FieldChanges = {
33
43
  added: string[];
34
44
  removed: string[];
35
45
  changed: string[];
46
+ renamed: ComponentRename[];
36
47
  };
37
48
 
38
49
  /**
@@ -224,6 +235,12 @@ export type PublishComponentRequest = {
224
235
  * A note on the version, at most 2000 characters
225
236
  */
226
237
  note?: string;
238
+ /**
239
+ * The fields the version renames: `from` a field of the latest version the draft no longer has, `to`
240
+ * a field of the draft the latest version does not have, of the same type and changed only as a kept
241
+ * field may. A name is in one rename at most
242
+ */
243
+ renames?: ComponentRename[];
227
244
  };
228
245
 
229
246
  /**
@@ -300,9 +317,11 @@ export enum ComponentErrorTypes {
300
317
  componentArchived = 'ComponentArchived',
301
318
  componentAdoptionRequired = 'ComponentAdoptionRequired',
302
319
  componentDowngradeRefused = 'ComponentDowngradeRefused',
303
- componentUpgradeBlocked = 'ComponentUpgradeBlocked',
304
320
  noFragmentToAdopt = 'NoFragmentToAdopt',
305
- noFragmentToPromote = 'NoFragmentToPromote'
321
+ noFragmentToPromote = 'NoFragmentToPromote',
322
+ definitionMigrating = 'DefinitionMigrating',
323
+ oneMigrationPerSave = 'OneMigrationPerSave',
324
+ migrationPreviewNotFound = 'MigrationPreviewNotFound'
306
325
  }
307
326
 
308
327
  /**
@@ -320,7 +339,11 @@ export enum ComponentVersionViolationCodes {
320
339
  /**
321
340
  * A kept field may only change its texts, or loosen its constraints
322
341
  */
323
- notLooser = 'component.notLooser'
342
+ notLooser = 'component.notLooser',
343
+ /**
344
+ * A rename must go from a field the draft no longer has to a new one of the same type
345
+ */
346
+ invalidRename = 'component.invalidRename'
324
347
  }
325
348
 
326
349
  /**
@@ -335,21 +358,6 @@ export type ComponentVersionViolation = {
335
358
  message: string;
336
359
  };
337
360
 
338
- /**
339
- * This type represent a field an upgrade removes or changes while contents hold a value in it
340
- */
341
- export type ComponentUpgradeBlockingField = {
342
- field: string;
343
- /**
344
- * How many contents, archived ones and translations included, hold a value in the field
345
- */
346
- contents: number;
347
- /**
348
- * Up to 20 of their content ids
349
- */
350
- examples: number[];
351
- };
352
-
353
361
  type ComponentErrorOf<T extends ComponentErrorTypes, D = {}> = { type: T; message: string } & D;
354
362
 
355
363
  /**
@@ -387,15 +395,198 @@ export type ComponentError =
387
395
  | ComponentErrorOf<ComponentErrorTypes.componentArchived, { fragment: string }>
388
396
  | ComponentErrorOf<ComponentErrorTypes.componentAdoptionRequired, { fragment: string }>
389
397
  | ComponentErrorOf<ComponentErrorTypes.componentDowngradeRefused, { fragment: string; mnemonicId: string; from: number; to: number }>
390
- | ComponentErrorOf<ComponentErrorTypes.componentUpgradeBlocked, {
391
- fragment: string;
392
- mnemonicId: string;
393
- /**
394
- * Null when the definition's own fragment is adopted
395
- */
396
- from: number | null;
397
- to: number;
398
- fields: ComponentUpgradeBlockingField[];
399
- }>
400
398
  | ComponentErrorOf<ComponentErrorTypes.noFragmentToAdopt, { fragment: string }>
401
- | ComponentErrorOf<ComponentErrorTypes.noFragmentToPromote, { fragment: string }>;
399
+ | ComponentErrorOf<ComponentErrorTypes.noFragmentToPromote, { fragment: string }>
400
+ /**
401
+ * A save changing the schema while the definition's contents are still being migrated
402
+ */
403
+ | ComponentErrorOf<ComponentErrorTypes.definitionMigrating, DefinitionMigrationState>
404
+ /**
405
+ * A save that would migrate the values of more than one component: save one, then the next once it
406
+ * has finished
407
+ */
408
+ | ComponentErrorOf<ComponentErrorTypes.oneMigrationPerSave, { mnemonicIds: string[] }>
409
+ | ComponentErrorOf<ComponentErrorTypes.migrationPreviewNotFound, { id: MigrationPreviewId }>;
410
+
411
+ /**
412
+ * This type represent where a definition's contents stand, as the get content definition API request
413
+ * answers it
414
+ *
415
+ * An upgrade or adoption that renames, removes or retypes fields bumps the definition's revision and
416
+ * migrates its contents in the background, one migration at a time per definition
417
+ */
418
+ export type DefinitionMigrationState = {
419
+ /**
420
+ * Bumped by each save that migrates values
421
+ */
422
+ revision: number;
423
+ /**
424
+ * The contents, archived ones included, still waiting for the migration to `revision`, 0 when none
425
+ * runs. While above 0, a save changing the schema is refused with `DefinitionMigrating`
426
+ */
427
+ behind: number;
428
+ };
429
+
430
+ /**
431
+ * This type represent a translation of a value set aside
432
+ */
433
+ export type SetAsideTranslation = {
434
+ /**
435
+ * Relative to the value's `path`, empty for the value itself
436
+ */
437
+ key: string;
438
+ value: string | null;
439
+ checksum: string | null;
440
+ };
441
+
442
+ /**
443
+ * This type represent a value a migration could not carry, waiting beside its content for a person to
444
+ * move into a field or discard
445
+ */
446
+ export type SetAsideValue = {
447
+ /**
448
+ * The definition revision whose migration set it aside
449
+ */
450
+ revision: number;
451
+ /**
452
+ * The component it was a value of
453
+ */
454
+ mnemonicId: string;
455
+ /**
456
+ * Where it was, in the key format translation entries use, with the names the payload has now:
457
+ * `pic.credit`, `gallery.$k1.width`
458
+ */
459
+ path: string;
460
+ /**
461
+ * The field as the version it came from defined it, for the form to show the value
462
+ */
463
+ field: Field;
464
+ reason: 'removed' | 'changed';
465
+ /**
466
+ * Null when the value followed its field and only its translations, which have no place there, wait
467
+ */
468
+ value: unknown;
469
+ /**
470
+ * Its translations by locale
471
+ */
472
+ translations: { [locale: string]: SetAsideTranslation[] };
473
+ /**
474
+ * Absent while the content still waits for its migration: the value is set aside by the read
475
+ */
476
+ setAsideDate?: Date;
477
+ };
478
+
479
+ /**
480
+ * This type represent a value set aside that a content save resolves. The value itself moves in the
481
+ * payload, where the person put it, and is then deleted; values not named stay
482
+ */
483
+ export type SetAsideResolution = {
484
+ revision: number;
485
+ path: string;
486
+ /**
487
+ * The path of the field the value moved to, for its translations to follow there, where that field
488
+ * is translatable. Left out, the value is discarded
489
+ */
490
+ into?: string;
491
+ };
492
+
493
+ /**
494
+ * The migration preview unique id
495
+ */
496
+ export type MigrationPreviewId = number;
497
+
498
+ /**
499
+ * This type represent the data needed to make a migration preview API request: the definition, and the
500
+ * schema about to be saved with the update content definition API request or the adoption about to be made
501
+ */
502
+ export type MigrationPreviewRequest =
503
+ | { id: ContentDefinitionId; schema: ContentDefinitionSchemaInput }
504
+ | { id: ContentDefinitionId; adopt: { mnemonicId: string; version: number } };
505
+
506
+ /**
507
+ * This type represent the response of a migration preview API request: the preview's id, or null when
508
+ * the save would migrate nothing
509
+ */
510
+ export type MigrationPreviewResponse = {
511
+ id: MigrationPreviewId | null;
512
+ };
513
+
514
+ /**
515
+ * This type represent the data needed to make a get migration preview API request
516
+ */
517
+ export type GetMigrationPreviewRequest = {
518
+ id: MigrationPreviewId;
519
+ };
520
+
521
+ /**
522
+ * This type represent what a migration does to one field of the version the definition is on, whose
523
+ * values move or are checked
524
+ */
525
+ export type MigrationPreviewField = {
526
+ field: string;
527
+ outcome: 'renamed' | 'changed' | 'removed';
528
+ /**
529
+ * The field it becomes, null when removed
530
+ */
531
+ to: string | null;
532
+ /**
533
+ * The contents holding a value of it
534
+ */
535
+ contents: number;
536
+ renamed: number;
537
+ converted: number;
538
+ setAside: number;
539
+ /**
540
+ * The translations moved
541
+ */
542
+ translations: number;
543
+ /**
544
+ * Up to 20 of the contents' ids
545
+ */
546
+ examples: number[];
547
+ };
548
+
549
+ /**
550
+ * This type represent the response of a get migration preview API request, to poll until `status` is
551
+ * `done`. Previews are kept a day
552
+ */
553
+ export type GetMigrationPreviewResponse = {
554
+ id: MigrationPreviewId;
555
+ definitionId: ContentDefinitionId;
556
+ mnemonicId: string;
557
+ /**
558
+ * Null for an adoption
559
+ */
560
+ from: number | null;
561
+ to: number;
562
+ status: 'running' | 'done';
563
+ /**
564
+ * The contents walked so far, out of `total`
565
+ */
566
+ scanned: number;
567
+ total: number;
568
+ fields: MigrationPreviewField[];
569
+ /**
570
+ * The contents whose payload or translations would change
571
+ */
572
+ changing: number;
573
+ /**
574
+ * The contents that would hold values set aside
575
+ */
576
+ settingAside: number;
577
+ };
578
+
579
+ /**
580
+ * This type represent the data needed to make a resume migration API request
581
+ */
582
+ export type ResumeMigrationRequest = {
583
+ /**
584
+ * The content definition unique id
585
+ */
586
+ id: ContentDefinitionId;
587
+ };
588
+
589
+ /**
590
+ * This type represent the response of a resume migration API request
591
+ */
592
+ export type ResumeMigrationResponse = DefinitionMigrationState;
@@ -15,6 +15,7 @@ import {
15
15
  ContentTranslationStatus,
16
16
  } from "./ContentTranslation";
17
17
  import { CoverageReport } from "./Audience";
18
+ import { SetAsideResolution, SetAsideValue } from "./Component";
18
19
 
19
20
  /**
20
21
  * This type represent the content unique id type
@@ -335,6 +336,12 @@ export type UpdateContentRequest = {
335
336
  * set an identifier coming from a third party application
336
337
  */
337
338
  externalIdentifier?: string;
339
+
340
+ /**
341
+ * The values a migration set aside that this save resolves, moved into the payload by the person or
342
+ * discarded
343
+ */
344
+ setAside?: SetAsideResolution[];
338
345
  };
339
346
 
340
347
  /**
@@ -408,6 +415,11 @@ export type ListContentsFilters = {
408
415
  * audience mnemonic ids inserted. Several of them narrow the result like `tags` do
409
416
  */
410
417
  audiences?: string[];
418
+
419
+ /**
420
+ * true lists only the contents holding values a migration set aside
421
+ */
422
+ setAside?: boolean;
411
423
  };
412
424
 
413
425
  /**
@@ -716,9 +728,10 @@ export type LinkingContents = ContentResponse;
716
728
  */
717
729
  export type GetContentResponse = {
718
730
  /**
719
- * The requested content
731
+ * The requested content, migrated when it still waits for its definition's migration, with the values
732
+ * set aside beside it
720
733
  */
721
- content: ContentResponse | undefined;
734
+ content: (ContentResponse & { setAside: SetAsideValue[] }) | undefined;
722
735
  /**
723
736
  * The contents that use the requested content
724
737
  */
@@ -1,6 +1,6 @@
1
1
  import { AuthorResponse } from './Author';
2
2
  import { PagedListResponse } from './common';
3
- import { FieldChanges } from './Component';
3
+ import { DefinitionMigrationState, FieldChanges } from './Component';
4
4
  import { ComponentMarker, ContentDefinitionSchema, ContentDefinitionSchemaInput, Field, I18NDictionary } from './ContentDefinitionSchema';
5
5
  import { Extension } from './Extension';
6
6
 
@@ -211,8 +211,8 @@ export type DefinitionComponent = ComponentMarker & {
211
211
  */
212
212
  archived: boolean;
213
213
  /**
214
- * What upgrading from `version` to `latestVersion` would add, remove and change, all empty when up
215
- * to date. Whether the upgrade would be blocked by the contents is only known by trying it
214
+ * What upgrading from `version` to `latestVersion` would add, remove, change and rename, all empty
215
+ * when up to date. What it would do to the contents is only known by previewing it
216
216
  */
217
217
  changes: FieldChanges;
218
218
  };
@@ -233,6 +233,10 @@ export type GetContentDefinitionResponse = (Omit<ContentDefinitionResponse, 'com
233
233
  * The components the definition uses, each with its latest version and what upgrading to it changes
234
234
  */
235
235
  components: DefinitionComponent[];
236
+ /**
237
+ * Where the definition's contents stand in its migrations
238
+ */
239
+ migration: DefinitionMigrationState;
236
240
  }) | undefined;
237
241
 
238
242
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentchef/contentchef-types",
3
- "version": "11.1.0-alpha.0",
3
+ "version": "11.1.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": "06b0724c9e74c0e2975a4af2917924010858759d"
37
+ "gitHead": "8970d38d1236984dee510da19687d73078f76a70"
38
38
  }