@prismicio/types-internal 2.2.0-traverse.alpha-7 → 2.2.0-traverse.alpha-9

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.
Files changed (33) hide show
  1. package/lib/_internal/utils.d.ts +0 -3
  2. package/lib/content/Document.d.ts +96 -32
  3. package/lib/content/Document.js +1 -1
  4. package/lib/content/fields/GroupContent.d.ts +21 -7
  5. package/lib/content/fields/WidgetContent.d.ts +96 -32
  6. package/lib/content/fields/nestable/NestableContent.d.ts +12 -6
  7. package/lib/content/fields/nestable/NestableContent.js +1 -29
  8. package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +30 -12
  9. package/lib/content/fields/nestable/RichTextContent/Blocks.js +11 -2
  10. package/lib/content/fields/nestable/RichTextContent/index.d.ts +15 -5
  11. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +24 -8
  12. package/lib/content/fields/slices/Slice/CompositeSliceContent.js +15 -7
  13. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +9 -3
  14. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +24 -8
  15. package/lib/content/fields/slices/Slice/SharedSliceContent.js +5 -1
  16. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +24 -8
  17. package/lib/content/fields/slices/Slice/SimpleSliceContent.js +1 -1
  18. package/lib/content/fields/slices/Slice/index.d.ts +54 -18
  19. package/lib/content/fields/slices/SliceItem.d.ts +54 -18
  20. package/lib/content/fields/slices/SlicesContent.d.ts +72 -24
  21. package/lib/customtypes/CustomType.d.ts +1 -1
  22. package/lib/customtypes/CustomType.js +3 -3
  23. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +1 -2
  24. package/package.json +1 -1
  25. package/src/_internal/utils.ts +0 -4
  26. package/src/content/Document.ts +2 -2
  27. package/src/content/fields/nestable/NestableContent.ts +0 -32
  28. package/src/content/fields/nestable/RichTextContent/Blocks.ts +15 -3
  29. package/src/content/fields/slices/Slice/CompositeSliceContent.ts +22 -7
  30. package/src/content/fields/slices/Slice/SharedSliceContent.ts +7 -1
  31. package/src/content/fields/slices/Slice/SimpleSliceContent.ts +1 -1
  32. package/src/customtypes/CustomType.ts +1 -1
  33. package/src/customtypes/widgets/slices/SharedSlice.ts +2 -2
@@ -329,7 +329,9 @@ export declare const SliceItemContent: t.TypeC<{
329
329
  preview?: {
330
330
  title?: string;
331
331
  } | null | undefined;
332
- });
332
+ }) | {
333
+ label: string;
334
+ };
333
335
  } & {
334
336
  start: number;
335
337
  end: number;
@@ -373,7 +375,9 @@ export declare const SliceItemContent: t.TypeC<{
373
375
  preview?: {
374
376
  title?: string;
375
377
  } | null | undefined;
376
- });
378
+ }) | {
379
+ label: string;
380
+ };
377
381
  } & {
378
382
  start: number;
379
383
  end: number;
@@ -708,7 +712,9 @@ export declare const SliceItemContent: t.TypeC<{
708
712
  preview?: {
709
713
  title?: string;
710
714
  } | null | undefined;
711
- });
715
+ }) | {
716
+ label: string;
717
+ };
712
718
  } & {
713
719
  start: number;
714
720
  end: number;
@@ -752,7 +758,9 @@ export declare const SliceItemContent: t.TypeC<{
752
758
  preview?: {
753
759
  title?: string;
754
760
  } | null | undefined;
755
- });
761
+ }) | {
762
+ label: string;
763
+ };
756
764
  } & {
757
765
  start: number;
758
766
  end: number;
@@ -1089,7 +1097,9 @@ export declare const SliceItemContent: t.TypeC<{
1089
1097
  preview?: {
1090
1098
  title?: string;
1091
1099
  } | null | undefined;
1092
- });
1100
+ }) | {
1101
+ label: string;
1102
+ };
1093
1103
  } & {
1094
1104
  start: number;
1095
1105
  end: number;
@@ -1133,7 +1143,9 @@ export declare const SliceItemContent: t.TypeC<{
1133
1143
  preview?: {
1134
1144
  title?: string;
1135
1145
  } | null | undefined;
1136
- });
1146
+ }) | {
1147
+ label: string;
1148
+ };
1137
1149
  } & {
1138
1150
  start: number;
1139
1151
  end: number;
@@ -1468,7 +1480,9 @@ export declare const SliceItemContent: t.TypeC<{
1468
1480
  preview?: {
1469
1481
  title?: string;
1470
1482
  } | null | undefined;
1471
- });
1483
+ }) | {
1484
+ label: string;
1485
+ };
1472
1486
  } & {
1473
1487
  start: number;
1474
1488
  end: number;
@@ -1512,7 +1526,9 @@ export declare const SliceItemContent: t.TypeC<{
1512
1526
  preview?: {
1513
1527
  title?: string;
1514
1528
  } | null | undefined;
1515
- });
1529
+ }) | {
1530
+ label: string;
1531
+ };
1516
1532
  } & {
1517
1533
  start: number;
1518
1534
  end: number;
@@ -1846,7 +1862,9 @@ export declare const SliceItemContent: t.TypeC<{
1846
1862
  preview?: {
1847
1863
  title?: string;
1848
1864
  } | null | undefined;
1849
- });
1865
+ }) | {
1866
+ label: string;
1867
+ };
1850
1868
  } & {
1851
1869
  start: number;
1852
1870
  end: number;
@@ -1890,7 +1908,9 @@ export declare const SliceItemContent: t.TypeC<{
1890
1908
  preview?: {
1891
1909
  title?: string;
1892
1910
  } | null | undefined;
1893
- });
1911
+ }) | {
1912
+ label: string;
1913
+ };
1894
1914
  } & {
1895
1915
  start: number;
1896
1916
  end: number;
@@ -2226,7 +2246,9 @@ export declare const SliceItemContent: t.TypeC<{
2226
2246
  preview?: {
2227
2247
  title?: string;
2228
2248
  } | null | undefined;
2229
- });
2249
+ }) | {
2250
+ label: string;
2251
+ };
2230
2252
  } & {
2231
2253
  start: number;
2232
2254
  end: number;
@@ -2270,7 +2292,9 @@ export declare const SliceItemContent: t.TypeC<{
2270
2292
  preview?: {
2271
2293
  title?: string;
2272
2294
  } | null | undefined;
2273
- });
2295
+ }) | {
2296
+ label: string;
2297
+ };
2274
2298
  } & {
2275
2299
  start: number;
2276
2300
  end: number;
@@ -2595,7 +2619,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
2595
2619
  preview?: {
2596
2620
  title?: string;
2597
2621
  } | null | undefined;
2598
- });
2622
+ }) | {
2623
+ label: string;
2624
+ };
2599
2625
  } & {
2600
2626
  start: number;
2601
2627
  end: number;
@@ -2903,7 +2929,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
2903
2929
  preview?: {
2904
2930
  title?: string;
2905
2931
  } | null | undefined;
2906
- });
2932
+ }) | {
2933
+ label: string;
2934
+ };
2907
2935
  } & {
2908
2936
  start: number;
2909
2937
  end: number;
@@ -3212,7 +3240,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
3212
3240
  preview?: {
3213
3241
  title?: string;
3214
3242
  } | null | undefined;
3215
- });
3243
+ }) | {
3244
+ label: string;
3245
+ };
3216
3246
  } & {
3217
3247
  start: number;
3218
3248
  end: number;
@@ -3520,7 +3550,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
3520
3550
  preview?: {
3521
3551
  title?: string;
3522
3552
  } | null | undefined;
3523
- });
3553
+ }) | {
3554
+ label: string;
3555
+ };
3524
3556
  } & {
3525
3557
  start: number;
3526
3558
  end: number;
@@ -3830,7 +3862,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
3830
3862
  preview?: {
3831
3863
  title?: string;
3832
3864
  } | null | undefined;
3833
- });
3865
+ }) | {
3866
+ label: string;
3867
+ };
3834
3868
  } & {
3835
3869
  start: number;
3836
3870
  end: number;
@@ -4138,7 +4172,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
4138
4172
  preview?: {
4139
4173
  title?: string;
4140
4174
  } | null | undefined;
4141
- });
4175
+ }) | {
4176
+ label: string;
4177
+ };
4142
4178
  } & {
4143
4179
  start: number;
4144
4180
  end: number;
@@ -300,7 +300,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
300
300
  preview?: {
301
301
  title?: string;
302
302
  } | null | undefined;
303
- });
303
+ }) | {
304
+ label: string;
305
+ };
304
306
  } & {
305
307
  start: number;
306
308
  end: number;
@@ -608,7 +610,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
608
610
  preview?: {
609
611
  title?: string;
610
612
  } | null | undefined;
611
- });
613
+ }) | {
614
+ label: string;
615
+ };
612
616
  } & {
613
617
  start: number;
614
618
  end: number;
@@ -917,7 +921,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
917
921
  preview?: {
918
922
  title?: string;
919
923
  } | null | undefined;
920
- });
924
+ }) | {
925
+ label: string;
926
+ };
921
927
  } & {
922
928
  start: number;
923
929
  end: number;
@@ -1225,7 +1231,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
1225
1231
  preview?: {
1226
1232
  title?: string;
1227
1233
  } | null | undefined;
1228
- });
1234
+ }) | {
1235
+ label: string;
1236
+ };
1229
1237
  } & {
1230
1238
  start: number;
1231
1239
  end: number;
@@ -1535,7 +1543,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
1535
1543
  preview?: {
1536
1544
  title?: string;
1537
1545
  } | null | undefined;
1538
- });
1546
+ }) | {
1547
+ label: string;
1548
+ };
1539
1549
  } & {
1540
1550
  start: number;
1541
1551
  end: number;
@@ -1843,7 +1853,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
1843
1853
  preview?: {
1844
1854
  title?: string;
1845
1855
  } | null | undefined;
1846
- });
1856
+ }) | {
1857
+ label: string;
1858
+ };
1847
1859
  } & {
1848
1860
  start: number;
1849
1861
  end: number;
@@ -2159,7 +2171,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
2159
2171
  preview?: {
2160
2172
  title?: string;
2161
2173
  } | null | undefined;
2162
- });
2174
+ }) | {
2175
+ label: string;
2176
+ };
2163
2177
  } & {
2164
2178
  start: number;
2165
2179
  end: number;
@@ -2467,7 +2481,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
2467
2481
  preview?: {
2468
2482
  title?: string;
2469
2483
  } | null | undefined;
2470
- });
2484
+ }) | {
2485
+ label: string;
2486
+ };
2471
2487
  } & {
2472
2488
  start: number;
2473
2489
  end: number;
@@ -2776,7 +2792,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
2776
2792
  preview?: {
2777
2793
  title?: string;
2778
2794
  } | null | undefined;
2779
- });
2795
+ }) | {
2796
+ label: string;
2797
+ };
2780
2798
  } & {
2781
2799
  start: number;
2782
2800
  end: number;
@@ -3084,7 +3102,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
3084
3102
  preview?: {
3085
3103
  title?: string;
3086
3104
  } | null | undefined;
3087
- });
3105
+ }) | {
3106
+ label: string;
3107
+ };
3088
3108
  } & {
3089
3109
  start: number;
3090
3110
  end: number;
@@ -3394,7 +3414,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
3394
3414
  preview?: {
3395
3415
  title?: string;
3396
3416
  } | null | undefined;
3397
- });
3417
+ }) | {
3418
+ label: string;
3419
+ };
3398
3420
  } & {
3399
3421
  start: number;
3400
3422
  end: number;
@@ -3702,7 +3724,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
3702
3724
  preview?: {
3703
3725
  title?: string;
3704
3726
  } | null | undefined;
3705
- });
3727
+ }) | {
3728
+ label: string;
3729
+ };
3706
3730
  } & {
3707
3731
  start: number;
3708
3732
  end: number;
@@ -4047,7 +4071,9 @@ export declare const SlicesContent: t.TypeC<{
4047
4071
  preview?: {
4048
4072
  title?: string;
4049
4073
  } | null | undefined;
4050
- });
4074
+ }) | {
4075
+ label: string;
4076
+ };
4051
4077
  } & {
4052
4078
  start: number;
4053
4079
  end: number;
@@ -4091,7 +4117,9 @@ export declare const SlicesContent: t.TypeC<{
4091
4117
  preview?: {
4092
4118
  title?: string;
4093
4119
  } | null | undefined;
4094
- });
4120
+ }) | {
4121
+ label: string;
4122
+ };
4095
4123
  } & {
4096
4124
  start: number;
4097
4125
  end: number;
@@ -4426,7 +4454,9 @@ export declare const SlicesContent: t.TypeC<{
4426
4454
  preview?: {
4427
4455
  title?: string;
4428
4456
  } | null | undefined;
4429
- });
4457
+ }) | {
4458
+ label: string;
4459
+ };
4430
4460
  } & {
4431
4461
  start: number;
4432
4462
  end: number;
@@ -4470,7 +4500,9 @@ export declare const SlicesContent: t.TypeC<{
4470
4500
  preview?: {
4471
4501
  title?: string;
4472
4502
  } | null | undefined;
4473
- });
4503
+ }) | {
4504
+ label: string;
4505
+ };
4474
4506
  } & {
4475
4507
  start: number;
4476
4508
  end: number;
@@ -4807,7 +4839,9 @@ export declare const SlicesContent: t.TypeC<{
4807
4839
  preview?: {
4808
4840
  title?: string;
4809
4841
  } | null | undefined;
4810
- });
4842
+ }) | {
4843
+ label: string;
4844
+ };
4811
4845
  } & {
4812
4846
  start: number;
4813
4847
  end: number;
@@ -4851,7 +4885,9 @@ export declare const SlicesContent: t.TypeC<{
4851
4885
  preview?: {
4852
4886
  title?: string;
4853
4887
  } | null | undefined;
4854
- });
4888
+ }) | {
4889
+ label: string;
4890
+ };
4855
4891
  } & {
4856
4892
  start: number;
4857
4893
  end: number;
@@ -5186,7 +5222,9 @@ export declare const SlicesContent: t.TypeC<{
5186
5222
  preview?: {
5187
5223
  title?: string;
5188
5224
  } | null | undefined;
5189
- });
5225
+ }) | {
5226
+ label: string;
5227
+ };
5190
5228
  } & {
5191
5229
  start: number;
5192
5230
  end: number;
@@ -5230,7 +5268,9 @@ export declare const SlicesContent: t.TypeC<{
5230
5268
  preview?: {
5231
5269
  title?: string;
5232
5270
  } | null | undefined;
5233
- });
5271
+ }) | {
5272
+ label: string;
5273
+ };
5234
5274
  } & {
5235
5275
  start: number;
5236
5276
  end: number;
@@ -5564,7 +5604,9 @@ export declare const SlicesContent: t.TypeC<{
5564
5604
  preview?: {
5565
5605
  title?: string;
5566
5606
  } | null | undefined;
5567
- });
5607
+ }) | {
5608
+ label: string;
5609
+ };
5568
5610
  } & {
5569
5611
  start: number;
5570
5612
  end: number;
@@ -5608,7 +5650,9 @@ export declare const SlicesContent: t.TypeC<{
5608
5650
  preview?: {
5609
5651
  title?: string;
5610
5652
  } | null | undefined;
5611
- });
5653
+ }) | {
5654
+ label: string;
5655
+ };
5612
5656
  } & {
5613
5657
  start: number;
5614
5658
  end: number;
@@ -5944,7 +5988,9 @@ export declare const SlicesContent: t.TypeC<{
5944
5988
  preview?: {
5945
5989
  title?: string;
5946
5990
  } | null | undefined;
5947
- });
5991
+ }) | {
5992
+ label: string;
5993
+ };
5948
5994
  } & {
5949
5995
  start: number;
5950
5996
  end: number;
@@ -5988,7 +6034,9 @@ export declare const SlicesContent: t.TypeC<{
5988
6034
  preview?: {
5989
6035
  title?: string;
5990
6036
  } | null | undefined;
5991
- });
6037
+ }) | {
6038
+ label: string;
6039
+ };
5992
6040
  } & {
5993
6041
  start: number;
5994
6042
  end: number;
@@ -2393,7 +2393,7 @@ export declare const CustomType: t.ExactC<t.IntersectionC<[t.TypeC<{
2393
2393
  }>]>>;
2394
2394
  export declare type CustomType = t.TypeOf<typeof CustomType>;
2395
2395
  export declare function flattenWidgets(customType: CustomType): Array<[string, DynamicWidget]>;
2396
- export declare function flattenStaticWidgets(customType: StaticCustomType): Array<[string, StaticWidget]>;
2396
+ export declare function flattenSections(customType: StaticCustomType): Array<[string, StaticWidget]>;
2397
2397
  export declare function toStatic(customType: CustomType, sharedSlices: Map<string, SharedSlice>): StaticCustomType;
2398
2398
  export declare function validateSlices(customType: CustomType, sharedSlices: Map<string, SharedSlice>): Either<CustomTypeSlicesError, CustomType>;
2399
2399
  export declare function collectWidgets(customType: CustomType, f: (ref: string, widget: DynamicWidget) => DynamicWidget | undefined): CustomType;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.collectSharedSlices = exports.flattenCustomTypeFields = exports.filterMissingSharedSlices = exports.collectWidgets = exports.validateSlices = exports.toStatic = exports.flattenStaticWidgets = exports.flattenWidgets = exports.CustomType = exports.StaticCustomType = exports.CustomTypeFormat = void 0;
3
+ exports.collectSharedSlices = exports.flattenCustomTypeFields = exports.filterMissingSharedSlices = exports.collectWidgets = exports.validateSlices = exports.toStatic = exports.flattenSections = exports.flattenWidgets = exports.CustomType = exports.StaticCustomType = exports.CustomTypeFormat = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Either_1 = require("fp-ts/lib/Either");
6
6
  const t = (0, tslib_1.__importStar)(require("io-ts"));
@@ -60,13 +60,13 @@ function flattenWidgets(customType) {
60
60
  }, []);
61
61
  }
62
62
  exports.flattenWidgets = flattenWidgets;
63
- function flattenStaticWidgets(customType) {
63
+ function flattenSections(customType) {
64
64
  return Object.entries(customType.json).reduce((acc, [, section]) => {
65
65
  const sectionWidgets = Object.entries(section);
66
66
  return acc.concat(sectionWidgets);
67
67
  }, []);
68
68
  }
69
- exports.flattenStaticWidgets = flattenStaticWidgets;
69
+ exports.flattenSections = flattenSections;
70
70
  function _retrieveSharedSlicesRef(customType) {
71
71
  const slicezones = flattenWidgets(customType).filter(([, widget]) => widget.type === "Slices");
72
72
  const allSharedRefs = slicezones.reduce((acc, [, slicezone]) => {
@@ -1,5 +1,4 @@
1
1
  import * as t from "io-ts";
2
- import type { PickOnly } from "../../../_internal/utils";
3
2
  import type { SharedSliceRef } from "./SharedSliceRef";
4
3
  import type { DynamicSlice, StaticSlice } from "./Slice";
5
4
  export declare const Variation: t.ExactC<t.IntersectionC<[t.TypeC<{
@@ -331,7 +330,7 @@ export declare type VariationFields = {
331
330
  type: "SharedSlice";
332
331
  sliceName: string;
333
332
  variationId: string;
334
- fields: PickOnly<Variation, "primary" | "items">;
333
+ fields: Pick<Variation, "primary" | "items">;
335
334
  };
336
335
  export declare const SharedSliceType = "SharedSlice";
337
336
  export declare const SharedSlice: t.ExactC<t.IntersectionC<[t.TypeC<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "2.2.0-traverse.alpha-7",
3
+ "version": "2.2.0-traverse.alpha-9",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -12,10 +12,6 @@ import type {
12
12
  VariationFields,
13
13
  } from "../customtypes"
14
14
 
15
- export type PickOnly<T, K extends keyof T> = Pick<T, K> & {
16
- [P in Exclude<keyof T, K>]?: never
17
- }
18
-
19
15
  export type TraverseSliceContentFn = <
20
16
  S extends SliceItemContent | SharedSliceItemContent,
21
17
  D extends VariationFields | CompositeSlice | Group | NestableWidget,
@@ -12,7 +12,7 @@ import { WidgetKey } from "../common"
12
12
  import {
13
13
  type StaticWidget,
14
14
  collectSharedSlices,
15
- flattenStaticWidgets,
15
+ flattenSections,
16
16
  StaticCustomType,
17
17
  } from "../customtypes"
18
18
  import {
@@ -253,7 +253,7 @@ function simplifyCustomType(customType: StaticCustomType): {
253
253
  } {
254
254
  return {
255
255
  customTypeId: customType?.id,
256
- fields: Object.fromEntries(flattenStaticWidgets(customType)),
256
+ fields: Object.fromEntries(flattenSections(customType)),
257
257
  }
258
258
  }
259
259
 
@@ -1,7 +1,6 @@
1
1
  import { isRight } from "fp-ts/lib/Either"
2
2
  import * as t from "io-ts"
3
3
 
4
- import type { NestableWidget } from "../../../customtypes"
5
4
  import type { LegacyContentCtx } from "../../LegacyContentCtx"
6
5
  import { EmptyContent, EmptyLegacy, isEmptyContent } from "../EmptyContent"
7
6
  import {
@@ -201,34 +200,3 @@ export const NestableLegacy = (ctx: LegacyContentCtx) => {
201
200
  },
202
201
  }
203
202
  }
204
-
205
- export function isValidStaticNestableContent(
206
- content: NestableContent,
207
- model?: NestableWidget,
208
- ) {
209
- if (!model) return false
210
-
211
- switch (content.__TYPE__) {
212
- // special case for no content so we can consider it valid no matter its model
213
- case "EmptyContent":
214
- return true
215
- case "BooleanContent":
216
- return model.type === "Boolean"
217
- case "EmbedContent":
218
- return model.type === "Embed"
219
- case "FieldContent":
220
- return content.type === model.type
221
- case "GeoPointContent":
222
- return model.type === "GeoPoint"
223
- case "ImageContent":
224
- return model.type === "Image"
225
- case "IntegrationFieldsContent":
226
- return model.type === "IntegrationFields"
227
- case "LinkContent":
228
- return model.type === "Link"
229
- case "StructuredTextContent":
230
- return model.type === "StructuredText"
231
- case "SeparatorContent":
232
- return model.type === "Separator"
233
- }
234
- }
@@ -1,5 +1,5 @@
1
1
  import { either } from "fp-ts"
2
- import { isRight } from "fp-ts/lib/Either"
2
+ import { isLeft } from "fp-ts/lib/Either"
3
3
  import { pipe } from "fp-ts/lib/function"
4
4
  import * as t from "io-ts"
5
5
 
@@ -18,11 +18,15 @@ import {
18
18
  import { ImageContentView } from "../ImageContent"
19
19
  import { Link, LinkLegacy } from "../LinkContent"
20
20
 
21
+ const labelCodec = t.strict({
22
+ label: t.string,
23
+ })
24
+
21
25
  const SpanFn = (linkCodec: typeof Link | typeof LinkLegacy) =>
22
26
  t.exact(
23
27
  t.intersection([
24
28
  t.partial({
25
- data: linkCodec,
29
+ data: t.union([linkCodec, labelCodec]),
26
30
  }),
27
31
  t.type({
28
32
  start: t.number,
@@ -51,7 +55,15 @@ export const ValidatedSpans = <C extends typeof Span | typeof SpanLegacy>(
51
55
  const res = spans
52
56
  .reduce<Array<S>>((acc, maybeSpan) => {
53
57
  const decodedSpan = spanCodec.decode(maybeSpan)
54
- return isRight(decodedSpan) ? [...acc, decodedSpan.right] : acc
58
+ if (isLeft(decodedSpan)) return acc
59
+ if (
60
+ (decodedSpan.right.type === "hyperlink" ||
61
+ decodedSpan.right.type === "label") &&
62
+ !decodedSpan.right.data
63
+ )
64
+ return acc
65
+
66
+ return [...acc, decodedSpan.right]
55
67
  }, [])
56
68
  .sort((m1: S, m2: S) => m1.start - m2.start)
57
69
  return t.success(res)
@@ -170,7 +170,13 @@ export function traverseCompositeSliceContent({
170
170
  content: fieldContent,
171
171
  })
172
172
  // Can happen if the transform function returns undefined to filter out a field
173
- if (!transformedField || !isNestableContent(transformedField)) return acc
173
+ if (!transformedField) return acc
174
+ if (!isNestableContent(transformedField)) {
175
+ console.warn(
176
+ `Warn: Non nestable content with key [${fieldKey}] detected in a composite slice [${sliceName}] with key [${sliceKey}]`,
177
+ )
178
+ return acc
179
+ }
174
180
  return {
175
181
  ...acc,
176
182
  [fieldKey]: transformedField,
@@ -214,9 +220,14 @@ export function migrateCompositeSlice(
214
220
  variation: model.variationId,
215
221
  primary: Object.entries(content.widget.nonRepeat).reduce(
216
222
  (acc, [fieldKey, fieldContent]) => {
217
- return model.fields.primary?.[fieldKey]
218
- ? { ...acc, [fieldKey]: fieldContent }
219
- : acc
223
+ if (!model.fields.primary?.[fieldKey]) {
224
+ console.warn(
225
+ `The widget ${fieldKey} in the non-repeat zone of the composite slice [${model.sliceName}] with key [${content.key}] doesn't exist in the model.`,
226
+ )
227
+ return acc
228
+ }
229
+
230
+ return { ...acc, [fieldKey]: fieldContent }
220
231
  },
221
232
  {},
222
233
  ),
@@ -225,9 +236,13 @@ export function migrateCompositeSlice(
225
236
  __TYPE__: "GroupItemContent",
226
237
  value: groupItem.value.reduce<GroupItemContent["value"]>(
227
238
  (acc, [fieldKey, fieldContent]) => {
228
- return model.fields.items?.[fieldKey]
229
- ? acc.concat([[fieldKey, fieldContent]])
230
- : acc
239
+ if (!model.fields.items?.[fieldKey]) {
240
+ console.warn(
241
+ `The widget ${fieldKey} in the repeat zone of the composite slice [${model.sliceName}] with key [${content.key}] doesn't exist in the model.`,
242
+ )
243
+ return acc
244
+ }
245
+ return acc.concat([[fieldKey, fieldContent]])
231
246
  },
232
247
  [],
233
248
  ),