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

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.
@@ -281,7 +281,7 @@ export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{
281
281
  text: t.StringC;
282
282
  }>, t.PartialC<{
283
283
  spans: t.Type<({
284
- data?: ({
284
+ data: ({
285
285
  __TYPE__: "ImageLink";
286
286
  } & {
287
287
  id: string;
@@ -319,15 +319,21 @@ export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{
319
319
  preview?: {
320
320
  title?: string;
321
321
  } | null | undefined;
322
- }) | {
323
- label: string;
324
- };
325
- } & {
322
+ });
323
+ start: number;
324
+ end: number;
325
+ type: "hyperlink";
326
+ } | {
327
+ data: string;
326
328
  start: number;
327
329
  end: number;
328
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
330
+ type: "label";
331
+ } | {
332
+ start: number;
333
+ end: number;
334
+ type: string;
329
335
  })[], ({
330
- data?: ({
336
+ data: ({
331
337
  __TYPE__: "ImageLink";
332
338
  } & {
333
339
  id: string;
@@ -365,13 +371,19 @@ export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{
365
371
  preview?: {
366
372
  title?: string;
367
373
  } | null | undefined;
368
- }) | {
369
- label: string;
370
- };
371
- } & {
374
+ });
375
+ start: number;
376
+ end: number;
377
+ type: "hyperlink";
378
+ } | {
379
+ data: string;
372
380
  start: number;
373
381
  end: number;
374
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
382
+ type: "label";
383
+ } | {
384
+ start: number;
385
+ end: number;
386
+ type: string;
375
387
  })[], unknown>;
376
388
  }>]>;
377
389
  }>, t.PartialC<{
@@ -636,7 +648,7 @@ export declare const isNestableContent: (u: unknown) => u is {
636
648
  text: string;
637
649
  } & {
638
650
  spans?: ({
639
- data?: ({
651
+ data: ({
640
652
  __TYPE__: "ImageLink";
641
653
  } & {
642
654
  id: string;
@@ -674,13 +686,19 @@ export declare const isNestableContent: (u: unknown) => u is {
674
686
  preview?: {
675
687
  title?: string;
676
688
  } | null | undefined;
677
- }) | {
678
- label: string;
679
- };
680
- } & {
689
+ });
690
+ start: number;
691
+ end: number;
692
+ type: "hyperlink";
693
+ } | {
694
+ data: string;
681
695
  start: number;
682
696
  end: number;
683
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
697
+ type: "label";
698
+ } | {
699
+ start: number;
700
+ end: number;
701
+ type: string;
684
702
  })[];
685
703
  };
686
704
  } & {
@@ -944,7 +962,7 @@ export declare const NestableLegacy: (ctx: LegacyContentCtx) => {
944
962
  text: string;
945
963
  } & {
946
964
  spans?: ({
947
- data?: ({
965
+ data: ({
948
966
  __TYPE__: "ImageLink";
949
967
  } & {
950
968
  id: string;
@@ -982,13 +1000,19 @@ export declare const NestableLegacy: (ctx: LegacyContentCtx) => {
982
1000
  preview?: {
983
1001
  title?: string;
984
1002
  } | null | undefined;
985
- }) | {
986
- label: string;
987
- };
988
- } & {
1003
+ });
1004
+ start: number;
1005
+ end: number;
1006
+ type: "hyperlink";
1007
+ } | {
1008
+ data: string;
1009
+ start: number;
1010
+ end: number;
1011
+ type: "label";
1012
+ } | {
989
1013
  start: number;
990
1014
  end: number;
991
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
1015
+ type: string;
992
1016
  })[];
993
1017
  };
994
1018
  } & {
@@ -1,6 +1,6 @@
1
1
  import * as t from "io-ts";
2
- export declare const Span: t.ExactC<t.IntersectionC<[t.PartialC<{
3
- data: t.UnionC<[t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
2
+ export declare const Span: t.UnionC<[t.ExactC<t.TypeC<{
3
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
4
4
  __TYPE__: t.LiteralC<"ImageLink">;
5
5
  }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
6
6
  id: t.StringC;
@@ -106,34 +106,23 @@ export declare const Span: t.ExactC<t.IntersectionC<[t.PartialC<{
106
106
  preview?: {
107
107
  title?: string;
108
108
  } | null | undefined;
109
- }, unknown>]>, t.ExactC<t.TypeC<{
110
- label: t.StringC;
111
- }>>]>;
112
- }>, t.TypeC<{
109
+ }, unknown>]>;
113
110
  start: t.NumberC;
114
111
  end: t.NumberC;
115
- type: t.UnionC<[t.KeyofC<{
116
- heading1: null;
117
- heading2: null;
118
- heading3: null;
119
- heading4: null;
120
- heading5: null;
121
- heading6: null;
122
- paragraph: null;
123
- strong: null;
124
- em: null;
125
- preformatted: null;
126
- hyperlink: null;
127
- image: null;
128
- embed: null;
129
- "list-item": null;
130
- "o-list-item": null;
131
- rtl: null;
132
- }>, t.LiteralC<"label">]>;
133
- }>]>>;
112
+ type: t.LiteralC<"hyperlink">;
113
+ }>>, t.ExactC<t.TypeC<{
114
+ data: t.StringC;
115
+ start: t.NumberC;
116
+ end: t.NumberC;
117
+ type: t.LiteralC<"label">;
118
+ }>>, t.ExactC<t.TypeC<{
119
+ start: t.NumberC;
120
+ end: t.NumberC;
121
+ type: t.KeyofC<Record<string, null>>;
122
+ }>>]>;
134
123
  export declare type Span = t.TypeOf<typeof Span>;
135
- export declare const SpanLegacy: t.ExactC<t.IntersectionC<[t.PartialC<{
136
- data: t.UnionC<[t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
124
+ export declare const SpanLegacy: t.UnionC<[t.ExactC<t.TypeC<{
125
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
137
126
  __TYPE__: t.LiteralC<"ImageLink">;
138
127
  }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
139
128
  id: t.StringC;
@@ -239,34 +228,23 @@ export declare const SpanLegacy: t.ExactC<t.IntersectionC<[t.PartialC<{
239
228
  preview?: {
240
229
  title?: string;
241
230
  } | null | undefined;
242
- }, unknown>]>, t.ExactC<t.TypeC<{
243
- label: t.StringC;
244
- }>>]>;
245
- }>, t.TypeC<{
231
+ }, unknown>]>;
246
232
  start: t.NumberC;
247
233
  end: t.NumberC;
248
- type: t.UnionC<[t.KeyofC<{
249
- heading1: null;
250
- heading2: null;
251
- heading3: null;
252
- heading4: null;
253
- heading5: null;
254
- heading6: null;
255
- paragraph: null;
256
- strong: null;
257
- em: null;
258
- preformatted: null;
259
- hyperlink: null;
260
- image: null;
261
- embed: null;
262
- "list-item": null;
263
- "o-list-item": null;
264
- rtl: null;
265
- }>, t.LiteralC<"label">]>;
266
- }>]>>;
234
+ type: t.LiteralC<"hyperlink">;
235
+ }>>, t.ExactC<t.TypeC<{
236
+ data: t.StringC;
237
+ start: t.NumberC;
238
+ end: t.NumberC;
239
+ type: t.LiteralC<"label">;
240
+ }>>, t.ExactC<t.TypeC<{
241
+ start: t.NumberC;
242
+ end: t.NumberC;
243
+ type: t.KeyofC<Record<string, null>>;
244
+ }>>]>;
267
245
  export declare type SpanLegacy = t.TypeOf<typeof SpanLegacy>;
268
- export declare const ValidatedSpans: <C extends t.ExactC<t.IntersectionC<[t.PartialC<{
269
- data: t.UnionC<[t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
246
+ export declare const ValidatedSpans: <C extends t.UnionC<[t.ExactC<t.TypeC<{
247
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
270
248
  __TYPE__: t.LiteralC<"ImageLink">;
271
249
  }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
272
250
  id: t.StringC;
@@ -372,31 +350,20 @@ export declare const ValidatedSpans: <C extends t.ExactC<t.IntersectionC<[t.Part
372
350
  preview?: {
373
351
  title?: string;
374
352
  } | null | undefined;
375
- }, unknown>]>, t.ExactC<t.TypeC<{
376
- label: t.StringC;
377
- }>>]>;
378
- }>, t.TypeC<{
353
+ }, unknown>]>;
379
354
  start: t.NumberC;
380
355
  end: t.NumberC;
381
- type: t.UnionC<[t.KeyofC<{
382
- heading1: null;
383
- heading2: null;
384
- heading3: null;
385
- heading4: null;
386
- heading5: null;
387
- heading6: null;
388
- paragraph: null;
389
- strong: null;
390
- em: null;
391
- preformatted: null;
392
- hyperlink: null;
393
- image: null;
394
- embed: null;
395
- "list-item": null;
396
- "o-list-item": null;
397
- rtl: null;
398
- }>, t.LiteralC<"label">]>;
399
- }>]>>>(spanCodec: C) => t.Type<t.TypeOf<C>[], t.TypeOf<C>[], unknown>;
356
+ type: t.LiteralC<"hyperlink">;
357
+ }>>, t.ExactC<t.TypeC<{
358
+ data: t.StringC;
359
+ start: t.NumberC;
360
+ end: t.NumberC;
361
+ type: t.LiteralC<"label">;
362
+ }>>, t.ExactC<t.TypeC<{
363
+ start: t.NumberC;
364
+ end: t.NumberC;
365
+ type: t.KeyofC<Record<string, null>>;
366
+ }>>]>>(spanCodec: C) => t.Type<t.TypeOf<C>[], t.TypeOf<C>[], unknown>;
400
367
  export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
401
368
  type: t.LiteralC<"image">;
402
369
  data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
@@ -529,7 +496,7 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
529
496
  text: t.StringC;
530
497
  }>, t.PartialC<{
531
498
  spans: t.Type<({
532
- data?: ({
499
+ data: ({
533
500
  __TYPE__: "ImageLink";
534
501
  } & {
535
502
  id: string;
@@ -567,15 +534,21 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
567
534
  preview?: {
568
535
  title?: string;
569
536
  } | null | undefined;
570
- }) | {
571
- label: string;
572
- };
573
- } & {
537
+ });
538
+ start: number;
539
+ end: number;
540
+ type: "hyperlink";
541
+ } | {
542
+ data: string;
574
543
  start: number;
575
544
  end: number;
576
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
545
+ type: "label";
546
+ } | {
547
+ start: number;
548
+ end: number;
549
+ type: string;
577
550
  })[], ({
578
- data?: ({
551
+ data: ({
579
552
  __TYPE__: "ImageLink";
580
553
  } & {
581
554
  id: string;
@@ -613,13 +586,19 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
613
586
  preview?: {
614
587
  title?: string;
615
588
  } | null | undefined;
616
- }) | {
617
- label: string;
618
- };
619
- } & {
589
+ });
590
+ start: number;
591
+ end: number;
592
+ type: "hyperlink";
593
+ } | {
594
+ data: string;
620
595
  start: number;
621
596
  end: number;
622
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
597
+ type: "label";
598
+ } | {
599
+ start: number;
600
+ end: number;
601
+ type: string;
623
602
  })[], unknown>;
624
603
  }>]>;
625
604
  }>, t.PartialC<{
@@ -725,7 +704,7 @@ export declare const BlockLegacy: t.Type<({
725
704
  text: string;
726
705
  } & {
727
706
  spans?: ({
728
- data?: ({
707
+ data: ({
729
708
  __TYPE__: "ImageLink";
730
709
  } & {
731
710
  id: string;
@@ -763,13 +742,19 @@ export declare const BlockLegacy: t.Type<({
763
742
  preview?: {
764
743
  title?: string;
765
744
  } | null | undefined;
766
- }) | {
767
- label: string;
768
- };
769
- } & {
745
+ });
770
746
  start: number;
771
747
  end: number;
772
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
748
+ type: "hyperlink";
749
+ } | {
750
+ data: string;
751
+ start: number;
752
+ end: number;
753
+ type: "label";
754
+ } | {
755
+ start: number;
756
+ end: number;
757
+ type: string;
773
758
  })[];
774
759
  };
775
760
  } & {
@@ -873,7 +858,7 @@ export declare const BlockLegacy: t.Type<({
873
858
  text: string;
874
859
  } & {
875
860
  spans?: ({
876
- data?: ({
861
+ data: ({
877
862
  __TYPE__: "ImageLink";
878
863
  } & {
879
864
  id: string;
@@ -911,13 +896,19 @@ export declare const BlockLegacy: t.Type<({
911
896
  preview?: {
912
897
  title?: string;
913
898
  } | null | undefined;
914
- }) | {
915
- label: string;
916
- };
917
- } & {
899
+ });
900
+ start: number;
901
+ end: number;
902
+ type: "hyperlink";
903
+ } | {
904
+ data: string;
905
+ start: number;
906
+ end: number;
907
+ type: "label";
908
+ } | {
918
909
  start: number;
919
910
  end: number;
920
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
911
+ type: string;
921
912
  })[];
922
913
  };
923
914
  } & {
@@ -1050,7 +1041,7 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1050
1041
  text: t.StringC;
1051
1042
  }>, t.PartialC<{
1052
1043
  spans: t.Type<({
1053
- data?: ({
1044
+ data: ({
1054
1045
  __TYPE__: "ImageLink";
1055
1046
  } & {
1056
1047
  id: string;
@@ -1088,15 +1079,21 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1088
1079
  preview?: {
1089
1080
  title?: string;
1090
1081
  } | null | undefined;
1091
- }) | {
1092
- label: string;
1093
- };
1094
- } & {
1082
+ });
1083
+ start: number;
1084
+ end: number;
1085
+ type: "hyperlink";
1086
+ } | {
1087
+ data: string;
1088
+ start: number;
1089
+ end: number;
1090
+ type: "label";
1091
+ } | {
1095
1092
  start: number;
1096
1093
  end: number;
1097
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
1094
+ type: string;
1098
1095
  })[], ({
1099
- data?: ({
1096
+ data: ({
1100
1097
  __TYPE__: "ImageLink";
1101
1098
  } & {
1102
1099
  id: string;
@@ -1134,13 +1131,19 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1134
1131
  preview?: {
1135
1132
  title?: string;
1136
1133
  } | null | undefined;
1137
- }) | {
1138
- label: string;
1139
- };
1140
- } & {
1134
+ });
1135
+ start: number;
1136
+ end: number;
1137
+ type: "hyperlink";
1138
+ } | {
1139
+ data: string;
1140
+ start: number;
1141
+ end: number;
1142
+ type: "label";
1143
+ } | {
1141
1144
  start: number;
1142
1145
  end: number;
1143
- type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
1146
+ type: string;
1144
1147
  })[], unknown>;
1145
1148
  }>]>;
1146
1149
  }>, t.PartialC<{
@@ -6,27 +6,36 @@ const fp_ts_1 = require("fp-ts");
6
6
  const Either_1 = require("fp-ts/lib/Either");
7
7
  const function_1 = require("fp-ts/lib/function");
8
8
  const t = (0, tslib_1.__importStar)(require("io-ts"));
9
+ const io_ts_types_1 = require("io-ts-types");
9
10
  const nestable_1 = require("../../../../customtypes/widgets/nestable");
10
11
  const validators_1 = require("../../../../validators");
11
12
  const function_2 = require("../../../../validators/function");
12
13
  const EmbedContent_1 = require("../EmbedContent");
13
14
  const ImageContent_1 = require("../ImageContent");
14
15
  const LinkContent_1 = require("../LinkContent");
15
- const labelCodec = t.strict({
16
- label: t.string,
16
+ const linkSpan = (linkCodec) => t.strict({
17
+ data: linkCodec,
18
+ start: t.number,
19
+ end: t.number,
20
+ type: t.literal(nestable_1.RichTextNodeType.hyperlink),
17
21
  });
18
- const SpanFn = (linkCodec) => t.exact(t.intersection([
19
- t.partial({
20
- data: t.union([linkCodec, labelCodec]),
21
- }),
22
- t.type({
23
- start: t.number,
24
- end: t.number,
25
- type: t.union([nestable_1.RichTextNodeTypeCodec, t.literal("label")]),
26
- }),
27
- ]));
28
- exports.Span = SpanFn(LinkContent_1.Link);
29
- exports.SpanLegacy = SpanFn(LinkContent_1.LinkLegacy);
22
+ const labelSpan = t.strict({
23
+ data: (0, io_ts_types_1.withFallback)(t.string, ""),
24
+ start: t.number,
25
+ end: t.number,
26
+ type: t.literal("label"),
27
+ });
28
+ const span = t.strict({
29
+ start: t.number,
30
+ end: t.number,
31
+ type: t.keyof(Object.entries(nestable_1.RichTextNodeType).reduce((acc, [, name]) => {
32
+ if (name === nestable_1.RichTextNodeType.hyperlink)
33
+ return acc;
34
+ return { ...acc, [name]: null };
35
+ }, {})),
36
+ });
37
+ exports.Span = t.union([linkSpan(LinkContent_1.Link), labelSpan, span]);
38
+ exports.SpanLegacy = t.union([linkSpan(LinkContent_1.LinkLegacy), labelSpan, span]);
30
39
  const ValidatedSpans = (spanCodec) => {
31
40
  return new t.Type("ValidatedSpans", (spans) => Array.isArray(spans) && spans.every(spanCodec.is), (spans, c) => {
32
41
  if (Array.isArray(spans)) {
@@ -35,10 +44,6 @@ const ValidatedSpans = (spanCodec) => {
35
44
  const decodedSpan = spanCodec.decode(maybeSpan);
36
45
  if ((0, Either_1.isLeft)(decodedSpan))
37
46
  return acc;
38
- if ((decodedSpan.right.type === "hyperlink" ||
39
- decodedSpan.right.type === "label") &&
40
- !decodedSpan.right.data)
41
- return acc;
42
47
  return [...acc, decodedSpan.right];
43
48
  }, [])
44
49
  .sort((m1, m2) => m1.start - m2.start);