@contentchef/contentchef-types 11.1.1 → 11.2.0-alpha.0

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.
@@ -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
- * Thin enum represent the error types of the component API requests, and of the content definition
280
- * ones using components. Each is the `type` of a `RequestError`, whose `details` is a [[ComponentError]]
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
  /**
@@ -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 using components. Each is the `type` of a `RequestError`, whose `details` is a [[ComponentError]]
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]]
@@ -383,7 +383,42 @@ export type ListContentsFilters = {
383
383
  * true lists only the contents holding values a migration set aside
384
384
  */
385
385
  setAside?: boolean;
386
+ /**
387
+ * This filter is used to search the contents of one definition holding a value of a kind in one field
388
+ */
389
+ field?: ListContentsFieldFilter;
386
390
  };
391
+ /**
392
+ * This type represent the JSON type of a value in a content payload
393
+ */
394
+ export type JsonValueType = "string" | "number" | "boolean" | "object" | "array";
395
+ /**
396
+ * This type represent a filter on the values of one field: the contents of the definition where an
397
+ * instance of its root, or of the fragment wherever the definition places it, holds an empty value
398
+ * (missing, null, "", [] or {}), a value, a text longer than `length`, or a value not of `type`. With
399
+ * `locale`, where that locale's translation of the field does. A field the definition does not have is
400
+ * refused with `FieldNotFound`
401
+ */
402
+ export type ListContentsFieldFilter = {
403
+ definitionId: ContentDefinitionId;
404
+ /**
405
+ * The fragment holding the field, the definition's root without it
406
+ */
407
+ fragment?: string;
408
+ /**
409
+ * The field name
410
+ */
411
+ name: string;
412
+ locale?: string;
413
+ } & ({
414
+ is: "empty" | "notEmpty";
415
+ } | {
416
+ is: "longerThan";
417
+ length: number;
418
+ } | {
419
+ is: "notType";
420
+ type: JsonValueType;
421
+ });
387
422
  /**
388
423
  * This type represent the data needed to make a list content API request
389
424
  */
@@ -873,3 +908,82 @@ export type AnalysePersonalizedRulesResponse = {
873
908
  */
874
909
  fields: PersonalizedFieldCoverage[];
875
910
  };
911
+ /**
912
+ * This type represent the data needed to make a profile content values API request: what the
913
+ * definition's contents, archived ones included, hold in the fields of its root or of one of its
914
+ * fragments wherever the definition places it. For investigating, never for a form
915
+ */
916
+ export type ProfileContentValuesRequest = {
917
+ definitionId: ContentDefinitionId;
918
+ /**
919
+ * The fragment to profile, the definition's root without it
920
+ */
921
+ fragment?: string;
922
+ /**
923
+ * The fields to profile, from 1 to 100, all of them without it
924
+ */
925
+ fields?: string[];
926
+ };
927
+ /**
928
+ * This type represent what the contents hold in one field
929
+ */
930
+ export type FieldValuesProfile = {
931
+ name: string;
932
+ type: string;
933
+ /**
934
+ * The objects of the place, each holding the field or not
935
+ */
936
+ instances: number;
937
+ values: number;
938
+ /**
939
+ * The instances holding null, "", [], {} or nothing
940
+ */
941
+ empty: number;
942
+ /**
943
+ * The contents holding at least one value
944
+ */
945
+ contents: number;
946
+ /**
947
+ * The values by JSON type
948
+ */
949
+ types: {
950
+ [type in JsonValueType]?: number;
951
+ };
952
+ /**
953
+ * The lengths of the text values, null without any
954
+ */
955
+ length: {
956
+ min: number;
957
+ max: number;
958
+ p95: number;
959
+ } | null;
960
+ /**
961
+ * The translations holding text, by locale, null for a field that is not translatable
962
+ */
963
+ translations: {
964
+ [locale: string]: number;
965
+ } | null;
966
+ };
967
+ /**
968
+ * This type represent the response of a profile content values API request. A fragment nested in itself
969
+ * is followed one level deep, and a profile whose queries outlast their time is refused with
970
+ * `ProfileTooLarge`
971
+ */
972
+ export type ProfileContentValuesResponse = {
973
+ definitionId: ContentDefinitionId;
974
+ fragment: string | null;
975
+ contents: {
976
+ total: number;
977
+ archived: number;
978
+ };
979
+ /**
980
+ * Where the fragment sits, as `blocks[]<seo>` (an array of `oneFragmentOf` holding it) or
981
+ * `hero.variants[]` (a personalized field's variants), empty for the root
982
+ */
983
+ placements: string[];
984
+ /**
985
+ * The objects of the place found in the contents
986
+ */
987
+ instances: number;
988
+ fields: FieldValuesProfile[];
989
+ };
@@ -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
- * Thin enum represent the error types of the component API requests, and of the content definition
307
- * ones using components. Each is the `type` of a `RequestError`, whose `details` is a [[ComponentError]]
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
@@ -420,8 +420,42 @@ export type ListContentsFilters = {
420
420
  * true lists only the contents holding values a migration set aside
421
421
  */
422
422
  setAside?: boolean;
423
+
424
+ /**
425
+ * This filter is used to search the contents of one definition holding a value of a kind in one field
426
+ */
427
+ field?: ListContentsFieldFilter;
423
428
  };
424
429
 
430
+ /**
431
+ * This type represent the JSON type of a value in a content payload
432
+ */
433
+ export type JsonValueType = "string" | "number" | "boolean" | "object" | "array";
434
+
435
+ /**
436
+ * This type represent a filter on the values of one field: the contents of the definition where an
437
+ * instance of its root, or of the fragment wherever the definition places it, holds an empty value
438
+ * (missing, null, "", [] or {}), a value, a text longer than `length`, or a value not of `type`. With
439
+ * `locale`, where that locale's translation of the field does. A field the definition does not have is
440
+ * refused with `FieldNotFound`
441
+ */
442
+ export type ListContentsFieldFilter = {
443
+ definitionId: ContentDefinitionId;
444
+ /**
445
+ * The fragment holding the field, the definition's root without it
446
+ */
447
+ fragment?: string;
448
+ /**
449
+ * The field name
450
+ */
451
+ name: string;
452
+ locale?: string;
453
+ } & (
454
+ | { is: "empty" | "notEmpty" }
455
+ | { is: "longerThan"; length: number }
456
+ | { is: "notType"; type: JsonValueType }
457
+ );
458
+
425
459
  /**
426
460
  * This type represent the data needed to make a list content API request
427
461
  */
@@ -952,3 +986,74 @@ export type AnalysePersonalizedRulesResponse = {
952
986
  */
953
987
  fields: PersonalizedFieldCoverage[];
954
988
  };
989
+
990
+ /**
991
+ * This type represent the data needed to make a profile content values API request: what the
992
+ * definition's contents, archived ones included, hold in the fields of its root or of one of its
993
+ * fragments wherever the definition places it. For investigating, never for a form
994
+ */
995
+ export type ProfileContentValuesRequest = {
996
+ definitionId: ContentDefinitionId;
997
+ /**
998
+ * The fragment to profile, the definition's root without it
999
+ */
1000
+ fragment?: string;
1001
+ /**
1002
+ * The fields to profile, from 1 to 100, all of them without it
1003
+ */
1004
+ fields?: string[];
1005
+ };
1006
+
1007
+ /**
1008
+ * This type represent what the contents hold in one field
1009
+ */
1010
+ export type FieldValuesProfile = {
1011
+ name: string;
1012
+ type: string;
1013
+ /**
1014
+ * The objects of the place, each holding the field or not
1015
+ */
1016
+ instances: number;
1017
+ values: number;
1018
+ /**
1019
+ * The instances holding null, "", [], {} or nothing
1020
+ */
1021
+ empty: number;
1022
+ /**
1023
+ * The contents holding at least one value
1024
+ */
1025
+ contents: number;
1026
+ /**
1027
+ * The values by JSON type
1028
+ */
1029
+ types: { [type in JsonValueType]?: number };
1030
+ /**
1031
+ * The lengths of the text values, null without any
1032
+ */
1033
+ length: { min: number; max: number; p95: number } | null;
1034
+ /**
1035
+ * The translations holding text, by locale, null for a field that is not translatable
1036
+ */
1037
+ translations: { [locale: string]: number } | null;
1038
+ };
1039
+
1040
+ /**
1041
+ * This type represent the response of a profile content values API request. A fragment nested in itself
1042
+ * is followed one level deep, and a profile whose queries outlast their time is refused with
1043
+ * `ProfileTooLarge`
1044
+ */
1045
+ export type ProfileContentValuesResponse = {
1046
+ definitionId: ContentDefinitionId;
1047
+ fragment: string | null;
1048
+ contents: { total: number; archived: number };
1049
+ /**
1050
+ * Where the fragment sits, as `blocks[]<seo>` (an array of `oneFragmentOf` holding it) or
1051
+ * `hero.variants[]` (a personalized field's variants), empty for the root
1052
+ */
1053
+ placements: string[];
1054
+ /**
1055
+ * The objects of the place found in the contents
1056
+ */
1057
+ instances: number;
1058
+ fields: FieldValuesProfile[];
1059
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentchef/contentchef-types",
3
- "version": "11.1.1",
3
+ "version": "11.2.0-alpha.0",
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": "8ea4c3670efedc53c388f679bd4b3c859f7a066a"
37
+ "gitHead": "30ca15f956b396cce7e0db037e836b79406278cf"
38
38
  }