@contentchef/contentchef-types 11.2.0-alpha.4 → 11.2.0-alpha.5

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.
@@ -24,6 +24,17 @@ export type ComponentRename = {
24
24
  from: string;
25
25
  to: string;
26
26
  };
27
+ /**
28
+ * This type represent a field of a definition's root, or of one of its own fragments, that a save gives
29
+ * another name, so that its values and translations follow. Unlike a version's rename, the type may
30
+ * change: the values are then checked against the field they move to
31
+ */
32
+ export type DefinitionRename = ComponentRename & {
33
+ /**
34
+ * The definition's own fragment holding the field, left out or null at the root
35
+ */
36
+ fragment?: string | null;
37
+ };
27
38
  /**
28
39
  * This type represent field names, by what happened to them between two versions of a fragment.
29
40
  * A field whose type changed is `changed`; a renamed field is in `renamed`, and in neither `added` nor
@@ -366,6 +377,7 @@ export declare enum ComponentErrorTypes {
366
377
  noFragmentToPromote = "NoFragmentToPromote",
367
378
  definitionMigrating = "DefinitionMigrating",
368
379
  oneMigrationPerSave = "OneMigrationPerSave",
380
+ definitionRenamesRefused = "DefinitionRenamesRefused",
369
381
  migrationPreviewNotFound = "MigrationPreviewNotFound",
370
382
  invalidComparison = "InvalidComparison",
371
383
  fieldNotFound = "FieldNotFound",
@@ -403,6 +415,23 @@ export type ComponentVersionViolation = {
403
415
  code: string;
404
416
  message: string;
405
417
  };
418
+ /**
419
+ * This type represent a rename a definition save may not declare: from a field the definition does not
420
+ * have or the save still has, onto one the save does not have or the definition has already, a field in
421
+ * two renames, or a `fragment` that is not one of the definition's own on both sides
422
+ */
423
+ export type DefinitionRenameViolation = {
424
+ /**
425
+ * The rename's fragment, null at the root
426
+ */
427
+ fragment: string | null;
428
+ /**
429
+ * The rename's `to`
430
+ */
431
+ field: string;
432
+ code: 'definition.invalidRename';
433
+ message: string;
434
+ };
406
435
  type ComponentErrorOf<T extends ComponentErrorTypes, D = {}> = {
407
436
  type: T;
408
437
  message: string;
@@ -458,11 +487,14 @@ export type ComponentError = ComponentErrorOf<ComponentErrorTypes.componentNotFo
458
487
  */
459
488
  | ComponentErrorOf<ComponentErrorTypes.definitionMigrating, DefinitionMigrationState>
460
489
  /**
461
- * A save that would migrate the values of more than one component: save one, then the next once it
462
- * has finished
490
+ * A save that would migrate the values of more than one component, or of a component and of the
491
+ * definition's own fields (`ownFields`): save one, then the other once its migration has finished
463
492
  */
464
493
  | ComponentErrorOf<ComponentErrorTypes.oneMigrationPerSave, {
465
494
  mnemonicIds: string[];
495
+ ownFields: boolean;
496
+ }> | ComponentErrorOf<ComponentErrorTypes.definitionRenamesRefused, {
497
+ violations: DefinitionRenameViolation[];
466
498
  }> | ComponentErrorOf<ComponentErrorTypes.migrationPreviewNotFound, {
467
499
  id: MigrationPreviewId;
468
500
  }>
@@ -482,8 +514,9 @@ export type ComponentError = ComponentErrorOf<ComponentErrorTypes.componentNotFo
482
514
  * This type represent where a definition's contents stand, as the get content definition, update content
483
515
  * definition and get migration API requests answer it
484
516
  *
485
- * An upgrade or adoption that renames, removes or retypes fields bumps the definition's revision and
486
- * migrates its contents in the background, one migration at a time per definition
517
+ * An upgrade, an adoption, or a save of the definition's own fields that renames, removes or retypes
518
+ * fields bumps the definition's revision and migrates its contents in the background, one migration at a
519
+ * time per definition
487
520
  */
488
521
  export type DefinitionMigrationState = {
489
522
  /**
@@ -517,9 +550,13 @@ export type SetAsideValue = {
517
550
  */
518
551
  revision: number;
519
552
  /**
520
- * The component it was a value of
553
+ * The component it was a value of, null for a value of the definition's own fields
521
554
  */
522
- mnemonicId: string;
555
+ mnemonicId: string | null;
556
+ /**
557
+ * The definition's own fragment it was in, null at the root and for a component's value
558
+ */
559
+ fragment: string | null;
523
560
  /**
524
561
  * Where it was, in the key format translation entries use, with the names the payload has now:
525
562
  * `pic.credit`, `gallery.$k1.width`
@@ -564,11 +601,13 @@ export type SetAsideResolution = {
564
601
  export type MigrationPreviewId = number;
565
602
  /**
566
603
  * This type represent the data needed to make a migration preview API request: the definition, and the
567
- * schema about to be saved with the update content definition API request or the adoption about to be made
604
+ * schema about to be saved with the update content definition API request with the renames it will
605
+ * declare, or the adoption about to be made
568
606
  */
569
607
  export type MigrationPreviewRequest = {
570
608
  id: ContentDefinitionId;
571
609
  schema: ContentDefinitionSchemaInput;
610
+ renames?: DefinitionRename[];
572
611
  } | {
573
612
  id: ContentDefinitionId;
574
613
  adopt: {
@@ -595,6 +634,10 @@ export type GetMigrationPreviewRequest = {
595
634
  * values move or are checked
596
635
  */
597
636
  export type MigrationPreviewField = {
637
+ /**
638
+ * The definition's own fragment holding the field, null at the root and for a component's field
639
+ */
640
+ fragment: string | null;
598
641
  field: string;
599
642
  outcome: 'renamed' | 'changed' | 'removed';
600
643
  /**
@@ -624,12 +667,15 @@ export type MigrationPreviewField = {
624
667
  export type GetMigrationPreviewResponse = {
625
668
  id: MigrationPreviewId;
626
669
  definitionId: ContentDefinitionId;
627
- mnemonicId: string;
628
670
  /**
629
- * Null for an adoption
671
+ * The component, null for a save changing the definition's own fields, as `from` and `to`
672
+ */
673
+ mnemonicId: string | null;
674
+ /**
675
+ * Null for an adoption, and for the definition's own fields
630
676
  */
631
677
  from: number | null;
632
- to: number;
678
+ to: number | null;
633
679
  status: 'running' | 'done';
634
680
  /**
635
681
  * The contents walked so far, out of `total`
@@ -672,4 +718,67 @@ export type ResumeMigrationRequest = {
672
718
  * This type represent the response of a resume migration API request
673
719
  */
674
720
  export type ResumeMigrationResponse = DefinitionMigrationState;
721
+ /**
722
+ * This type represent the data needed to make a get set aside API request
723
+ */
724
+ export type GetSetAsideRequest = {
725
+ /**
726
+ * The content definition unique id
727
+ */
728
+ id: ContentDefinitionId;
729
+ };
730
+ /**
731
+ * This type represent what a definition's contents hold set aside for one field by one revision
732
+ */
733
+ export type SetAsideGroup = {
734
+ revision: number;
735
+ /**
736
+ * The component, null for the definition's own fields
737
+ */
738
+ mnemonicId: string | null;
739
+ /**
740
+ * The definition's own fragment, null at the root and for a component's field
741
+ */
742
+ fragment: string | null;
743
+ /**
744
+ * The field's name as the version it came from had it
745
+ */
746
+ field: string;
747
+ reason: 'removed' | 'changed';
748
+ /**
749
+ * The contents holding such values
750
+ */
751
+ contents: number;
752
+ values: number;
753
+ };
754
+ /**
755
+ * This type represent the response of a get set aside API request, by revision, then fragment, then field,
756
+ * components' values included
757
+ */
758
+ export type GetSetAsideResponse = SetAsideGroup[];
759
+ /**
760
+ * This type represent the data needed to make a discard set aside API request: one group as the get set
761
+ * aside API request answers it
762
+ */
763
+ export type DiscardSetAsideRequest = {
764
+ /**
765
+ * The content definition unique id
766
+ */
767
+ id: ContentDefinitionId;
768
+ revision: number;
769
+ fragment?: string | null;
770
+ field: string;
771
+ /**
772
+ * Where the previous call stopped, its `next`
773
+ */
774
+ after?: number;
775
+ };
776
+ /**
777
+ * This type represent the response of a discard set aside API request. A call works for about five
778
+ * seconds: call again with `after: next` until `next` is null
779
+ */
780
+ export type DiscardSetAsideResponse = {
781
+ discarded: number;
782
+ next: number | null;
783
+ };
675
784
  export {};
@@ -27,6 +27,7 @@ var ComponentErrorTypes;
27
27
  ComponentErrorTypes["noFragmentToPromote"] = "NoFragmentToPromote";
28
28
  ComponentErrorTypes["definitionMigrating"] = "DefinitionMigrating";
29
29
  ComponentErrorTypes["oneMigrationPerSave"] = "OneMigrationPerSave";
30
+ ComponentErrorTypes["definitionRenamesRefused"] = "DefinitionRenamesRefused";
30
31
  ComponentErrorTypes["migrationPreviewNotFound"] = "MigrationPreviewNotFound";
31
32
  ComponentErrorTypes["invalidComparison"] = "InvalidComparison";
32
33
  ComponentErrorTypes["fieldNotFound"] = "FieldNotFound";
@@ -1083,7 +1083,8 @@ export type RestoreViolations = {
1083
1083
  violations: ContentConstraintViolation[];
1084
1084
  }[];
1085
1085
  /**
1086
- * Values a component migration since would set aside: the definition has no place for them any more
1086
+ * @deprecated Always empty: what the migrations since set aside no longer keeps a version from being
1087
+ * restored, see [[GetContentHistoryEntryResponse.setAside]]
1087
1088
  */
1088
1089
  setAside: {
1089
1090
  path: string;
@@ -1104,13 +1105,19 @@ export type GetContentHistoryEntryResponse = ContentHistoryEntry & {
1104
1105
  restorable: boolean;
1105
1106
  violations: RestoreViolations;
1106
1107
  /**
1107
- * Values of fields removed from the definition by hand since, `path` in the key format of translation
1108
- * entries. They are left out of `payload` and `translations`, as a save leaves them out, so they do not
1109
- * keep the version from being restored
1108
+ * Values of fields removed from the definition by hand, before saves migrated contents, `path` in the key
1109
+ * format of translation entries. They are left out of `payload` and `translations`, as a save leaves them
1110
+ * out, so they do not keep the version from being restored
1110
1111
  */
1111
1112
  dropped: {
1112
1113
  path: string;
1113
1114
  }[];
1115
+ /**
1116
+ * Values the migrations since set aside, removed or retyped fields of a component or of the definition.
1117
+ * They are left out of `payload` and `translations`, and a restore writes them beside the content, once,
1118
+ * for a person to move or discard
1119
+ */
1120
+ setAside: SetAsideValue[];
1114
1121
  };
1115
1122
  /**
1116
1123
  * This type represent the data needed to make a restore content API request
@@ -1,6 +1,6 @@
1
1
  import { AuthorResponse } from './Author';
2
2
  import { PagedListResponse } from './common';
3
- import { DefinitionMigrationState, FieldChanges } from './Component';
3
+ import { DefinitionMigrationState, DefinitionRename, FieldChanges } from './Component';
4
4
  import { ComponentMarker, ContentDefinitionSchema, ContentDefinitionSchemaInput, Field, I18NDictionary } from './ContentDefinitionSchema';
5
5
  import { Extension } from './Extension';
6
6
  /**
@@ -131,6 +131,11 @@ export type UpdateContentDefinitionRequest = {
131
131
  * will bypass content definition mnemonicId validation for every linked-content field
132
132
  */
133
133
  bypassLinkedContentValidation?: boolean;
134
+ /**
135
+ * The fields the save gives another name, at the root or in one of the definition's own fragments, for
136
+ * their values to follow. Undeclared, a rename is a removal and an addition, and the values are set aside
137
+ */
138
+ renames?: DefinitionRename[];
134
139
  };
135
140
  /**
136
141
  * This type represent the model of a content definition
@@ -34,6 +34,18 @@ export type ComponentRename = {
34
34
  to: string;
35
35
  };
36
36
 
37
+ /**
38
+ * This type represent a field of a definition's root, or of one of its own fragments, that a save gives
39
+ * another name, so that its values and translations follow. Unlike a version's rename, the type may
40
+ * change: the values are then checked against the field they move to
41
+ */
42
+ export type DefinitionRename = ComponentRename & {
43
+ /**
44
+ * The definition's own fragment holding the field, left out or null at the root
45
+ */
46
+ fragment?: string | null;
47
+ };
48
+
37
49
  /**
38
50
  * This type represent field names, by what happened to them between two versions of a fragment.
39
51
  * A field whose type changed is `changed`; a renamed field is in `renamed`, and in neither `added` nor
@@ -385,6 +397,7 @@ export enum ComponentErrorTypes {
385
397
  noFragmentToPromote = 'NoFragmentToPromote',
386
398
  definitionMigrating = 'DefinitionMigrating',
387
399
  oneMigrationPerSave = 'OneMigrationPerSave',
400
+ definitionRenamesRefused = 'DefinitionRenamesRefused',
388
401
  migrationPreviewNotFound = 'MigrationPreviewNotFound',
389
402
  invalidComparison = 'InvalidComparison',
390
403
  fieldNotFound = 'FieldNotFound',
@@ -425,6 +438,24 @@ export type ComponentVersionViolation = {
425
438
  message: string;
426
439
  };
427
440
 
441
+ /**
442
+ * This type represent a rename a definition save may not declare: from a field the definition does not
443
+ * have or the save still has, onto one the save does not have or the definition has already, a field in
444
+ * two renames, or a `fragment` that is not one of the definition's own on both sides
445
+ */
446
+ export type DefinitionRenameViolation = {
447
+ /**
448
+ * The rename's fragment, null at the root
449
+ */
450
+ fragment: string | null;
451
+ /**
452
+ * The rename's `to`
453
+ */
454
+ field: string;
455
+ code: 'definition.invalidRename';
456
+ message: string;
457
+ };
458
+
428
459
  type ComponentErrorOf<T extends ComponentErrorTypes, D = {}> = { type: T; message: string } & D;
429
460
 
430
461
  /**
@@ -469,10 +500,11 @@ export type ComponentError =
469
500
  */
470
501
  | ComponentErrorOf<ComponentErrorTypes.definitionMigrating, DefinitionMigrationState>
471
502
  /**
472
- * A save that would migrate the values of more than one component: save one, then the next once it
473
- * has finished
503
+ * A save that would migrate the values of more than one component, or of a component and of the
504
+ * definition's own fields (`ownFields`): save one, then the other once its migration has finished
474
505
  */
475
- | ComponentErrorOf<ComponentErrorTypes.oneMigrationPerSave, { mnemonicIds: string[] }>
506
+ | ComponentErrorOf<ComponentErrorTypes.oneMigrationPerSave, { mnemonicIds: string[]; ownFields: boolean }>
507
+ | ComponentErrorOf<ComponentErrorTypes.definitionRenamesRefused, { violations: DefinitionRenameViolation[] }>
476
508
  | ComponentErrorOf<ComponentErrorTypes.migrationPreviewNotFound, { id: MigrationPreviewId }>
477
509
  /**
478
510
  * A side of a compare component fields API request that is none of the kinds it takes
@@ -491,8 +523,9 @@ export type ComponentError =
491
523
  * This type represent where a definition's contents stand, as the get content definition, update content
492
524
  * definition and get migration API requests answer it
493
525
  *
494
- * An upgrade or adoption that renames, removes or retypes fields bumps the definition's revision and
495
- * migrates its contents in the background, one migration at a time per definition
526
+ * An upgrade, an adoption, or a save of the definition's own fields that renames, removes or retypes
527
+ * fields bumps the definition's revision and migrates its contents in the background, one migration at a
528
+ * time per definition
496
529
  */
497
530
  export type DefinitionMigrationState = {
498
531
  /**
@@ -528,9 +561,13 @@ export type SetAsideValue = {
528
561
  */
529
562
  revision: number;
530
563
  /**
531
- * The component it was a value of
564
+ * The component it was a value of, null for a value of the definition's own fields
532
565
  */
533
- mnemonicId: string;
566
+ mnemonicId: string | null;
567
+ /**
568
+ * The definition's own fragment it was in, null at the root and for a component's value
569
+ */
570
+ fragment: string | null;
534
571
  /**
535
572
  * Where it was, in the key format translation entries use, with the names the payload has now:
536
573
  * `pic.credit`, `gallery.$k1.width`
@@ -576,10 +613,11 @@ export type MigrationPreviewId = number;
576
613
 
577
614
  /**
578
615
  * This type represent the data needed to make a migration preview API request: the definition, and the
579
- * schema about to be saved with the update content definition API request or the adoption about to be made
616
+ * schema about to be saved with the update content definition API request with the renames it will
617
+ * declare, or the adoption about to be made
580
618
  */
581
619
  export type MigrationPreviewRequest =
582
- | { id: ContentDefinitionId; schema: ContentDefinitionSchemaInput }
620
+ | { id: ContentDefinitionId; schema: ContentDefinitionSchemaInput; renames?: DefinitionRename[] }
583
621
  | { id: ContentDefinitionId; adopt: { mnemonicId: string; version: number; renames?: ComponentRename[] } };
584
622
 
585
623
  /**
@@ -602,6 +640,10 @@ export type GetMigrationPreviewRequest = {
602
640
  * values move or are checked
603
641
  */
604
642
  export type MigrationPreviewField = {
643
+ /**
644
+ * The definition's own fragment holding the field, null at the root and for a component's field
645
+ */
646
+ fragment: string | null;
605
647
  field: string;
606
648
  outcome: 'renamed' | 'changed' | 'removed';
607
649
  /**
@@ -632,12 +674,15 @@ export type MigrationPreviewField = {
632
674
  export type GetMigrationPreviewResponse = {
633
675
  id: MigrationPreviewId;
634
676
  definitionId: ContentDefinitionId;
635
- mnemonicId: string;
636
677
  /**
637
- * Null for an adoption
678
+ * The component, null for a save changing the definition's own fields, as `from` and `to`
679
+ */
680
+ mnemonicId: string | null;
681
+ /**
682
+ * Null for an adoption, and for the definition's own fields
638
683
  */
639
684
  from: number | null;
640
- to: number;
685
+ to: number | null;
641
686
  status: 'running' | 'done';
642
687
  /**
643
688
  * The contents walked so far, out of `total`
@@ -684,3 +729,71 @@ export type ResumeMigrationRequest = {
684
729
  * This type represent the response of a resume migration API request
685
730
  */
686
731
  export type ResumeMigrationResponse = DefinitionMigrationState;
732
+
733
+ /**
734
+ * This type represent the data needed to make a get set aside API request
735
+ */
736
+ export type GetSetAsideRequest = {
737
+ /**
738
+ * The content definition unique id
739
+ */
740
+ id: ContentDefinitionId;
741
+ };
742
+
743
+ /**
744
+ * This type represent what a definition's contents hold set aside for one field by one revision
745
+ */
746
+ export type SetAsideGroup = {
747
+ revision: number;
748
+ /**
749
+ * The component, null for the definition's own fields
750
+ */
751
+ mnemonicId: string | null;
752
+ /**
753
+ * The definition's own fragment, null at the root and for a component's field
754
+ */
755
+ fragment: string | null;
756
+ /**
757
+ * The field's name as the version it came from had it
758
+ */
759
+ field: string;
760
+ reason: 'removed' | 'changed';
761
+ /**
762
+ * The contents holding such values
763
+ */
764
+ contents: number;
765
+ values: number;
766
+ };
767
+
768
+ /**
769
+ * This type represent the response of a get set aside API request, by revision, then fragment, then field,
770
+ * components' values included
771
+ */
772
+ export type GetSetAsideResponse = SetAsideGroup[];
773
+
774
+ /**
775
+ * This type represent the data needed to make a discard set aside API request: one group as the get set
776
+ * aside API request answers it
777
+ */
778
+ export type DiscardSetAsideRequest = {
779
+ /**
780
+ * The content definition unique id
781
+ */
782
+ id: ContentDefinitionId;
783
+ revision: number;
784
+ fragment?: string | null;
785
+ field: string;
786
+ /**
787
+ * Where the previous call stopped, its `next`
788
+ */
789
+ after?: number;
790
+ };
791
+
792
+ /**
793
+ * This type represent the response of a discard set aside API request. A call works for about five
794
+ * seconds: call again with `after: next` until `next` is null
795
+ */
796
+ export type DiscardSetAsideResponse = {
797
+ discarded: number;
798
+ next: number | null;
799
+ };
@@ -1165,7 +1165,8 @@ export type RestoreViolations = {
1165
1165
  */
1166
1166
  translations: { locale: string; violations: ContentConstraintViolation[] }[];
1167
1167
  /**
1168
- * Values a component migration since would set aside: the definition has no place for them any more
1168
+ * @deprecated Always empty: what the migrations since set aside no longer keeps a version from being
1169
+ * restored, see [[GetContentHistoryEntryResponse.setAside]]
1169
1170
  */
1170
1171
  setAside: { path: string; reason: "removed" | "changed" }[];
1171
1172
  };
@@ -1181,11 +1182,17 @@ export type GetContentHistoryEntryResponse = ContentHistoryEntry & {
1181
1182
  restorable: boolean;
1182
1183
  violations: RestoreViolations;
1183
1184
  /**
1184
- * Values of fields removed from the definition by hand since, `path` in the key format of translation
1185
- * entries. They are left out of `payload` and `translations`, as a save leaves them out, so they do not
1186
- * keep the version from being restored
1185
+ * Values of fields removed from the definition by hand, before saves migrated contents, `path` in the key
1186
+ * format of translation entries. They are left out of `payload` and `translations`, as a save leaves them
1187
+ * out, so they do not keep the version from being restored
1187
1188
  */
1188
1189
  dropped: { path: string }[];
1190
+ /**
1191
+ * Values the migrations since set aside, removed or retyped fields of a component or of the definition.
1192
+ * They are left out of `payload` and `translations`, and a restore writes them beside the content, once,
1193
+ * for a person to move or discard
1194
+ */
1195
+ setAside: SetAsideValue[];
1189
1196
  };
1190
1197
 
1191
1198
  /**
@@ -1,6 +1,6 @@
1
1
  import { AuthorResponse } from './Author';
2
2
  import { PagedListResponse } from './common';
3
- import { DefinitionMigrationState, FieldChanges } from './Component';
3
+ import { DefinitionMigrationState, DefinitionRename, FieldChanges } from './Component';
4
4
  import { ComponentMarker, ContentDefinitionSchema, ContentDefinitionSchemaInput, Field, I18NDictionary } from './ContentDefinitionSchema';
5
5
  import { Extension } from './Extension';
6
6
 
@@ -142,6 +142,11 @@ export type UpdateContentDefinitionRequest = {
142
142
  * will bypass content definition mnemonicId validation for every linked-content field
143
143
  */
144
144
  bypassLinkedContentValidation?: boolean;
145
+ /**
146
+ * The fields the save gives another name, at the root or in one of the definition's own fragments, for
147
+ * their values to follow. Undeclared, a rename is a removal and an addition, and the values are set aside
148
+ */
149
+ renames?: DefinitionRename[];
145
150
  };
146
151
 
147
152
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentchef/contentchef-types",
3
- "version": "11.2.0-alpha.4",
3
+ "version": "11.2.0-alpha.5",
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": "4768ad3fee441d17e997f7461a28ec12dbe19b5e"
37
+ "gitHead": "ccaa9d0ae10d67701cf34df7ec127c3c40fefae4"
38
38
  }