@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
@@ -298,7 +298,9 @@ export declare const isCompositeSliceContent: (u: unknown) => u is {
298
298
  preview?: {
299
299
  title?: string;
300
300
  } | null | undefined;
301
- });
301
+ }) | {
302
+ label: string;
303
+ };
302
304
  } & {
303
305
  start: number;
304
306
  end: number;
@@ -606,7 +608,9 @@ export declare const isCompositeSliceContent: (u: unknown) => u is {
606
608
  preview?: {
607
609
  title?: string;
608
610
  } | null | undefined;
609
- });
611
+ }) | {
612
+ label: string;
613
+ };
610
614
  } & {
611
615
  start: number;
612
616
  end: number;
@@ -916,7 +920,9 @@ export declare const CompositeSliceLegacy: (ctx: LegacyContentCtx) => t.Type<{
916
920
  preview?: {
917
921
  title?: string;
918
922
  } | null | undefined;
919
- });
923
+ }) | {
924
+ label: string;
925
+ };
920
926
  } & {
921
927
  start: number;
922
928
  end: number;
@@ -1224,7 +1230,9 @@ export declare const CompositeSliceLegacy: (ctx: LegacyContentCtx) => t.Type<{
1224
1230
  preview?: {
1225
1231
  title?: string;
1226
1232
  } | null | undefined;
1227
- });
1233
+ }) | {
1234
+ label: string;
1235
+ };
1228
1236
  } & {
1229
1237
  start: number;
1230
1238
  end: number;
@@ -1566,7 +1574,9 @@ export declare const CompositeSliceContent: t.ExactC<t.TypeC<{
1566
1574
  preview?: {
1567
1575
  title?: string;
1568
1576
  } | null | undefined;
1569
- });
1577
+ }) | {
1578
+ label: string;
1579
+ };
1570
1580
  } & {
1571
1581
  start: number;
1572
1582
  end: number;
@@ -1610,7 +1620,9 @@ export declare const CompositeSliceContent: t.ExactC<t.TypeC<{
1610
1620
  preview?: {
1611
1621
  title?: string;
1612
1622
  } | null | undefined;
1613
- });
1623
+ }) | {
1624
+ label: string;
1625
+ };
1614
1626
  } & {
1615
1627
  start: number;
1616
1628
  end: number;
@@ -1945,7 +1957,9 @@ export declare const CompositeSliceContent: t.ExactC<t.TypeC<{
1945
1957
  preview?: {
1946
1958
  title?: string;
1947
1959
  } | null | undefined;
1948
- });
1960
+ }) | {
1961
+ label: string;
1962
+ };
1949
1963
  } & {
1950
1964
  start: number;
1951
1965
  end: number;
@@ -1989,7 +2003,9 @@ export declare const CompositeSliceContent: t.ExactC<t.TypeC<{
1989
2003
  preview?: {
1990
2004
  title?: string;
1991
2005
  } | null | undefined;
1992
- });
2006
+ }) | {
2007
+ label: string;
2008
+ };
1993
2009
  } & {
1994
2010
  start: number;
1995
2011
  end: number;
@@ -100,8 +100,12 @@ function traverseCompositeSliceContent({ path, sliceKey, sliceName, model, conte
100
100
  content: fieldContent,
101
101
  });
102
102
  // Can happen if the transform function returns undefined to filter out a field
103
- if (!transformedField || !(0, nestable_1.isNestableContent)(transformedField))
103
+ if (!transformedField)
104
104
  return acc;
105
+ if (!(0, nestable_1.isNestableContent)(transformedField)) {
106
+ console.warn(`Warn: Non nestable content with key [${fieldKey}] detected in a composite slice [${sliceName}] with key [${sliceKey}]`);
107
+ return acc;
108
+ }
105
109
  return {
106
110
  ...acc,
107
111
  [fieldKey]: transformedField,
@@ -139,18 +143,22 @@ function migrateCompositeSlice(model, content) {
139
143
  variation: model.variationId,
140
144
  primary: Object.entries(content.widget.nonRepeat).reduce((acc, [fieldKey, fieldContent]) => {
141
145
  var _a;
142
- return ((_a = model.fields.primary) === null || _a === void 0 ? void 0 : _a[fieldKey])
143
- ? { ...acc, [fieldKey]: fieldContent }
144
- : acc;
146
+ if (!((_a = model.fields.primary) === null || _a === void 0 ? void 0 : _a[fieldKey])) {
147
+ console.warn(`The widget ${fieldKey} in the non-repeat zone of the composite slice [${model.sliceName}] with key [${content.key}] doesn't exist in the model.`);
148
+ return acc;
149
+ }
150
+ return { ...acc, [fieldKey]: fieldContent };
145
151
  }, {}),
146
152
  items: content.widget.repeat.map((groupItem) => {
147
153
  return {
148
154
  __TYPE__: "GroupItemContent",
149
155
  value: groupItem.value.reduce((acc, [fieldKey, fieldContent]) => {
150
156
  var _a;
151
- return ((_a = model.fields.items) === null || _a === void 0 ? void 0 : _a[fieldKey])
152
- ? acc.concat([[fieldKey, fieldContent]])
153
- : acc;
157
+ if (!((_a = model.fields.items) === null || _a === void 0 ? void 0 : _a[fieldKey])) {
158
+ console.warn(`The widget ${fieldKey} in the repeat zone of the composite slice [${model.sliceName}] with key [${content.key}] doesn't exist in the model.`);
159
+ return acc;
160
+ }
161
+ return acc.concat([[fieldKey, fieldContent]]);
154
162
  }, []),
155
163
  };
156
164
  }, []),
@@ -293,7 +293,9 @@ export declare const RepeatableWidgetsLegacy: (ctx: LegacyContentCtx) => t.Array
293
293
  preview?: {
294
294
  title?: string;
295
295
  } | null | undefined;
296
- });
296
+ }) | {
297
+ label: string;
298
+ };
297
299
  } & {
298
300
  start: number;
299
301
  end: number;
@@ -631,7 +633,9 @@ export declare const RepeatableWidgets: t.ArrayC<t.ExactC<t.TypeC<{
631
633
  preview?: {
632
634
  title?: string;
633
635
  } | null | undefined;
634
- });
636
+ }) | {
637
+ label: string;
638
+ };
635
639
  } & {
636
640
  start: number;
637
641
  end: number;
@@ -675,7 +679,9 @@ export declare const RepeatableWidgets: t.ArrayC<t.ExactC<t.TypeC<{
675
679
  preview?: {
676
680
  title?: string;
677
681
  } | null | undefined;
678
- });
682
+ }) | {
683
+ label: string;
684
+ };
679
685
  } & {
680
686
  start: number;
681
687
  end: number;
@@ -299,7 +299,9 @@ export declare const isSharedSliceContent: (u: unknown) => u is {
299
299
  preview?: {
300
300
  title?: string;
301
301
  } | null | undefined;
302
- });
302
+ }) | {
303
+ label: string;
304
+ };
303
305
  } & {
304
306
  start: number;
305
307
  end: number;
@@ -607,7 +609,9 @@ export declare const isSharedSliceContent: (u: unknown) => u is {
607
609
  preview?: {
608
610
  title?: string;
609
611
  } | null | undefined;
610
- });
612
+ }) | {
613
+ label: string;
614
+ };
611
615
  } & {
612
616
  start: number;
613
617
  end: number;
@@ -918,7 +922,9 @@ export declare const SharedSliceLegacy: (ctx: LegacyContentCtx) => t.Type<{
918
922
  preview?: {
919
923
  title?: string;
920
924
  } | null | undefined;
921
- });
925
+ }) | {
926
+ label: string;
927
+ };
922
928
  } & {
923
929
  start: number;
924
930
  end: number;
@@ -1226,7 +1232,9 @@ export declare const SharedSliceLegacy: (ctx: LegacyContentCtx) => t.Type<{
1226
1232
  preview?: {
1227
1233
  title?: string;
1228
1234
  } | null | undefined;
1229
- });
1235
+ }) | {
1236
+ label: string;
1237
+ };
1230
1238
  } & {
1231
1239
  start: number;
1232
1240
  end: number;
@@ -1570,7 +1578,9 @@ export declare const SharedSliceContent: t.ExactC<t.TypeC<{
1570
1578
  preview?: {
1571
1579
  title?: string;
1572
1580
  } | null | undefined;
1573
- });
1581
+ }) | {
1582
+ label: string;
1583
+ };
1574
1584
  } & {
1575
1585
  start: number;
1576
1586
  end: number;
@@ -1614,7 +1624,9 @@ export declare const SharedSliceContent: t.ExactC<t.TypeC<{
1614
1624
  preview?: {
1615
1625
  title?: string;
1616
1626
  } | null | undefined;
1617
- });
1627
+ }) | {
1628
+ label: string;
1629
+ };
1618
1630
  } & {
1619
1631
  start: number;
1620
1632
  end: number;
@@ -1949,7 +1961,9 @@ export declare const SharedSliceContent: t.ExactC<t.TypeC<{
1949
1961
  preview?: {
1950
1962
  title?: string;
1951
1963
  } | null | undefined;
1952
- });
1964
+ }) | {
1965
+ label: string;
1966
+ };
1953
1967
  } & {
1954
1968
  start: number;
1955
1969
  end: number;
@@ -1993,7 +2007,9 @@ export declare const SharedSliceContent: t.ExactC<t.TypeC<{
1993
2007
  preview?: {
1994
2008
  title?: string;
1995
2009
  } | null | undefined;
1996
- });
2010
+ }) | {
2011
+ label: string;
2012
+ };
1997
2013
  } & {
1998
2014
  start: number;
1999
2015
  end: number;
@@ -113,8 +113,12 @@ function traverseSharedSliceContent({ path, sliceKey, sliceName, model, content,
113
113
  content: fieldContent,
114
114
  });
115
115
  // Can happen if the transform function returns undefined to filter out a field
116
- if (!transformedField || !(0, nestable_1.isNestableContent)(transformedField))
116
+ if (!transformedField)
117
117
  return acc;
118
+ if (!(0, nestable_1.isNestableContent)(transformedField)) {
119
+ console.warn(`Warn: Non nestable content with key [${fieldKey}] detected in a shared slice [${sliceName}] with key [${sliceKey}]`);
120
+ return acc;
121
+ }
118
122
  return {
119
123
  ...acc,
120
124
  [fieldKey]: transformedField,
@@ -322,7 +322,9 @@ export declare const SimpleSliceContent: t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
322
322
  preview?: {
323
323
  title?: string;
324
324
  } | null | undefined;
325
- });
325
+ }) | {
326
+ label: string;
327
+ };
326
328
  } & {
327
329
  start: number;
328
330
  end: number;
@@ -366,7 +368,9 @@ export declare const SimpleSliceContent: t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
366
368
  preview?: {
367
369
  title?: string;
368
370
  } | null | undefined;
369
- });
371
+ }) | {
372
+ label: string;
373
+ };
370
374
  } & {
371
375
  start: number;
372
376
  end: number;
@@ -702,7 +706,9 @@ export declare const SimpleSliceContent: t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
702
706
  preview?: {
703
707
  title?: string;
704
708
  } | null | undefined;
705
- });
709
+ }) | {
710
+ label: string;
711
+ };
706
712
  } & {
707
713
  start: number;
708
714
  end: number;
@@ -746,7 +752,9 @@ export declare const SimpleSliceContent: t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
746
752
  preview?: {
747
753
  title?: string;
748
754
  } | null | undefined;
749
- });
755
+ }) | {
756
+ label: string;
757
+ };
750
758
  } & {
751
759
  start: number;
752
760
  end: number;
@@ -1054,7 +1062,9 @@ export declare const isSimpleSliceContent: (u: unknown) => u is {
1054
1062
  preview?: {
1055
1063
  title?: string;
1056
1064
  } | null | undefined;
1057
- });
1065
+ }) | {
1066
+ label: string;
1067
+ };
1058
1068
  } & {
1059
1069
  start: number;
1060
1070
  end: number;
@@ -1362,7 +1372,9 @@ export declare const isSimpleSliceContent: (u: unknown) => u is {
1362
1372
  preview?: {
1363
1373
  title?: string;
1364
1374
  } | null | undefined;
1365
- });
1375
+ }) | {
1376
+ label: string;
1377
+ };
1366
1378
  } & {
1367
1379
  start: number;
1368
1380
  end: number;
@@ -1670,7 +1682,9 @@ export declare const SimpleSliceLegacy: (ctx: LegacyContentCtx) => {
1670
1682
  preview?: {
1671
1683
  title?: string;
1672
1684
  } | null | undefined;
1673
- });
1685
+ }) | {
1686
+ label: string;
1687
+ };
1674
1688
  } & {
1675
1689
  start: number;
1676
1690
  end: number;
@@ -1978,7 +1992,9 @@ export declare const SimpleSliceLegacy: (ctx: LegacyContentCtx) => {
1978
1992
  preview?: {
1979
1993
  title?: string;
1980
1994
  } | null | undefined;
1981
- });
1995
+ }) | {
1996
+ label: string;
1997
+ };
1982
1998
  } & {
1983
1999
  start: number;
1984
2000
  end: number;
@@ -118,7 +118,7 @@ function migrateSimpleSlice(model, content) {
118
118
  __TYPE__: "SharedSliceContent",
119
119
  variation: model.variationId,
120
120
  primary: ((_a = model.fields.primary) === null || _a === void 0 ? void 0 : _a[content.name])
121
- ? { [content.key]: content.widget }
121
+ ? { [content.name]: content.widget }
122
122
  : {},
123
123
  items: [],
124
124
  },
@@ -292,7 +292,9 @@ export declare const SliceLegacy: (ctx: LegacyContentCtx) => {
292
292
  preview?: {
293
293
  title?: string;
294
294
  } | null | undefined;
295
- });
295
+ }) | {
296
+ label: string;
297
+ };
296
298
  } & {
297
299
  start: number;
298
300
  end: number;
@@ -600,7 +602,9 @@ export declare const SliceLegacy: (ctx: LegacyContentCtx) => {
600
602
  preview?: {
601
603
  title?: string;
602
604
  } | null | undefined;
603
- });
605
+ }) | {
606
+ label: string;
607
+ };
604
608
  } & {
605
609
  start: number;
606
610
  end: number;
@@ -909,7 +913,9 @@ export declare const SliceLegacy: (ctx: LegacyContentCtx) => {
909
913
  preview?: {
910
914
  title?: string;
911
915
  } | null | undefined;
912
- });
916
+ }) | {
917
+ label: string;
918
+ };
913
919
  } & {
914
920
  start: number;
915
921
  end: number;
@@ -1217,7 +1223,9 @@ export declare const SliceLegacy: (ctx: LegacyContentCtx) => {
1217
1223
  preview?: {
1218
1224
  title?: string;
1219
1225
  } | null | undefined;
1220
- });
1226
+ }) | {
1227
+ label: string;
1228
+ };
1221
1229
  } & {
1222
1230
  start: number;
1223
1231
  end: number;
@@ -1527,7 +1535,9 @@ export declare const SliceLegacy: (ctx: LegacyContentCtx) => {
1527
1535
  preview?: {
1528
1536
  title?: string;
1529
1537
  } | null | undefined;
1530
- });
1538
+ }) | {
1539
+ label: string;
1540
+ };
1531
1541
  } & {
1532
1542
  start: number;
1533
1543
  end: number;
@@ -1835,7 +1845,9 @@ export declare const SliceLegacy: (ctx: LegacyContentCtx) => {
1835
1845
  preview?: {
1836
1846
  title?: string;
1837
1847
  } | null | undefined;
1838
- });
1848
+ }) | {
1849
+ label: string;
1850
+ };
1839
1851
  } & {
1840
1852
  start: number;
1841
1853
  end: number;
@@ -2174,7 +2186,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
2174
2186
  preview?: {
2175
2187
  title?: string;
2176
2188
  } | null | undefined;
2177
- });
2189
+ }) | {
2190
+ label: string;
2191
+ };
2178
2192
  } & {
2179
2193
  start: number;
2180
2194
  end: number;
@@ -2218,7 +2232,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
2218
2232
  preview?: {
2219
2233
  title?: string;
2220
2234
  } | null | undefined;
2221
- });
2235
+ }) | {
2236
+ label: string;
2237
+ };
2222
2238
  } & {
2223
2239
  start: number;
2224
2240
  end: number;
@@ -2553,7 +2569,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
2553
2569
  preview?: {
2554
2570
  title?: string;
2555
2571
  } | null | undefined;
2556
- });
2572
+ }) | {
2573
+ label: string;
2574
+ };
2557
2575
  } & {
2558
2576
  start: number;
2559
2577
  end: number;
@@ -2597,7 +2615,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
2597
2615
  preview?: {
2598
2616
  title?: string;
2599
2617
  } | null | undefined;
2600
- });
2618
+ }) | {
2619
+ label: string;
2620
+ };
2601
2621
  } & {
2602
2622
  start: number;
2603
2623
  end: number;
@@ -2934,7 +2954,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
2934
2954
  preview?: {
2935
2955
  title?: string;
2936
2956
  } | null | undefined;
2937
- });
2957
+ }) | {
2958
+ label: string;
2959
+ };
2938
2960
  } & {
2939
2961
  start: number;
2940
2962
  end: number;
@@ -2978,7 +3000,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
2978
3000
  preview?: {
2979
3001
  title?: string;
2980
3002
  } | null | undefined;
2981
- });
3003
+ }) | {
3004
+ label: string;
3005
+ };
2982
3006
  } & {
2983
3007
  start: number;
2984
3008
  end: number;
@@ -3313,7 +3337,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
3313
3337
  preview?: {
3314
3338
  title?: string;
3315
3339
  } | null | undefined;
3316
- });
3340
+ }) | {
3341
+ label: string;
3342
+ };
3317
3343
  } & {
3318
3344
  start: number;
3319
3345
  end: number;
@@ -3357,7 +3383,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
3357
3383
  preview?: {
3358
3384
  title?: string;
3359
3385
  } | null | undefined;
3360
- });
3386
+ }) | {
3387
+ label: string;
3388
+ };
3361
3389
  } & {
3362
3390
  start: number;
3363
3391
  end: number;
@@ -3691,7 +3719,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
3691
3719
  preview?: {
3692
3720
  title?: string;
3693
3721
  } | null | undefined;
3694
- });
3722
+ }) | {
3723
+ label: string;
3724
+ };
3695
3725
  } & {
3696
3726
  start: number;
3697
3727
  end: number;
@@ -3735,7 +3765,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
3735
3765
  preview?: {
3736
3766
  title?: string;
3737
3767
  } | null | undefined;
3738
- });
3768
+ }) | {
3769
+ label: string;
3770
+ };
3739
3771
  } & {
3740
3772
  start: number;
3741
3773
  end: number;
@@ -4071,7 +4103,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
4071
4103
  preview?: {
4072
4104
  title?: string;
4073
4105
  } | null | undefined;
4074
- });
4106
+ }) | {
4107
+ label: string;
4108
+ };
4075
4109
  } & {
4076
4110
  start: number;
4077
4111
  end: number;
@@ -4115,7 +4149,9 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
4115
4149
  preview?: {
4116
4150
  title?: string;
4117
4151
  } | null | undefined;
4118
- });
4152
+ }) | {
4153
+ label: string;
4154
+ };
4119
4155
  } & {
4120
4156
  start: number;
4121
4157
  end: number;