@prismicio/types-internal 3.4.0-alpha.9 → 3.5.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.
Files changed (70) hide show
  1. package/lib/content/Document.d.ts +507 -3393
  2. package/lib/content/Document.js +8 -0
  3. package/lib/content/fields/GroupContent.d.ts +1 -1
  4. package/lib/content/fields/GroupContent.js +12 -1
  5. package/lib/content/fields/RepeatableContent.d.ts +123 -51
  6. package/lib/content/fields/RepeatableContent.js +14 -10
  7. package/lib/content/fields/WidgetContent.d.ts +503 -3389
  8. package/lib/content/fields/nestable/NestableContent.d.ts +70 -551
  9. package/lib/content/fields/nestable/NestableContent.js +7 -8
  10. package/lib/content/fields/nestable/RepeatableContent.d.ts +2 -2
  11. package/lib/content/fields/nestable/RepeatableContent.js +5 -2
  12. package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +112 -0
  13. package/lib/content/fields/nestable/RichTextContent/Blocks.js +5 -5
  14. package/lib/content/fields/nestable/RichTextContent/index.d.ts +9 -641
  15. package/lib/content/fields/nestable/RichTextContent/index.js +4 -8
  16. package/lib/content/fields/nestable/TableContent.d.ts +536 -618
  17. package/lib/content/fields/nestable/TableContent.js +101 -15
  18. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +192 -1154
  19. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +25 -252
  20. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +192 -1154
  21. package/lib/content/fields/slices/Slice/SharedSliceContent.js +12 -0
  22. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +70 -551
  23. package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +70 -551
  24. package/lib/content/fields/slices/Slice/index.d.ts +268 -2038
  25. package/lib/content/fields/slices/SliceItem.d.ts +259 -2029
  26. package/lib/content/fields/slices/SlicesContent.d.ts +405 -2810
  27. package/lib/customtypes/CustomType.d.ts +108 -0
  28. package/lib/customtypes/Section.d.ts +108 -0
  29. package/lib/customtypes/diff/SharedSlice.d.ts +48 -0
  30. package/lib/customtypes/diff/Variation.d.ts +48 -0
  31. package/lib/customtypes/widgets/Group.d.ts +36 -0
  32. package/lib/customtypes/widgets/Widget.d.ts +126 -0
  33. package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +6 -0
  34. package/lib/customtypes/widgets/nestable/NestableWidget.js +2 -0
  35. package/lib/customtypes/widgets/nestable/RichText.d.ts +0 -2
  36. package/lib/customtypes/widgets/nestable/RichText.js +0 -2
  37. package/lib/customtypes/widgets/nestable/Table.d.ts +6 -0
  38. package/lib/customtypes/widgets/nestable/Table.js +13 -1
  39. package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +12 -0
  40. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +12 -0
  41. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +48 -0
  42. package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +36 -0
  43. package/lib/customtypes/widgets/slices/Slices.d.ts +168 -0
  44. package/package.json +1 -1
  45. package/src/content/Document.ts +9 -0
  46. package/src/content/fields/GroupContent.ts +15 -1
  47. package/src/content/fields/nestable/NestableContent.ts +13 -9
  48. package/src/content/fields/nestable/RepeatableContent.ts +6 -2
  49. package/src/content/fields/nestable/RichTextContent/Blocks.ts +238 -0
  50. package/src/content/fields/nestable/RichTextContent/index.ts +3 -7
  51. package/src/content/fields/nestable/TableContent.ts +131 -14
  52. package/src/content/fields/slices/Slice/SharedSliceContent.ts +13 -0
  53. package/src/customtypes/widgets/nestable/NestableWidget.ts +2 -0
  54. package/src/customtypes/widgets/nestable/RichText.ts +0 -2
  55. package/src/customtypes/widgets/nestable/Table.ts +13 -0
  56. package/lib/content/fields/nestable/RichTextContent/Block.d.ts +0 -1036
  57. package/lib/content/fields/nestable/RichTextContent/Block.js +0 -31
  58. package/lib/content/fields/nestable/RichTextContent/EmbedBlock.d.ts +0 -60
  59. package/lib/content/fields/nestable/RichTextContent/EmbedBlock.js +0 -53
  60. package/lib/content/fields/nestable/RichTextContent/ImageBlock.d.ts +0 -203
  61. package/lib/content/fields/nestable/RichTextContent/ImageBlock.js +0 -36
  62. package/lib/content/fields/nestable/RichTextContent/TableBlock.d.ts +0 -500
  63. package/lib/content/fields/nestable/RichTextContent/TableBlock.js +0 -21
  64. package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +0 -590
  65. package/lib/content/fields/nestable/RichTextContent/TextBlock.js +0 -80
  66. package/src/content/fields/nestable/RichTextContent/Block.ts +0 -35
  67. package/src/content/fields/nestable/RichTextContent/EmbedBlock.ts +0 -81
  68. package/src/content/fields/nestable/RichTextContent/ImageBlock.ts +0 -42
  69. package/src/content/fields/nestable/RichTextContent/TableBlock.ts +0 -36
  70. package/src/content/fields/nestable/RichTextContent/TextBlock.ts +0 -108
@@ -5,7 +5,6 @@ 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"));
7
7
  const EmptyContent_1 = require("../EmptyContent");
8
- const _1 = require(".");
9
8
  const BooleanContent_1 = require("./BooleanContent");
10
9
  const EmbedContent_1 = require("./EmbedContent");
11
10
  const FieldContent_1 = require("./FieldContent");
@@ -35,8 +34,8 @@ exports.NestableContent = t.union([
35
34
  LinkContent_1.LinkContent,
36
35
  RichTextContent_1.RichTextContent,
37
36
  SeparatorContent_1.SeparatorContent,
38
- RepeatableContent_1.RepeatableContent,
39
37
  TableContent_1.TableContent,
38
+ RepeatableContent_1.RepeatableContent,
40
39
  ]);
41
40
  const NestableContentDefaultValue = (widgetDef) => {
42
41
  switch (widgetDef.type) {
@@ -64,9 +63,9 @@ const isNestableContent = (u) => (0, FieldContent_1.isTextContent)(u) ||
64
63
  (0, IntegrationFieldContent_1.isIntegrationFieldContent)(u) ||
65
64
  (0, LinkContent_1.isLinkContent)(u) ||
66
65
  (0, SeparatorContent_1.isSeparatorContent)(u) ||
66
+ (0, TableContent_1.isTableContent)(u) ||
67
67
  (0, EmptyContent_1.isEmptyContent)(u) ||
68
- (0, RepeatableContent_1.isRepeatableContent)(u) ||
69
- (0, _1.isTableContent)(u);
68
+ (0, RepeatableContent_1.isRepeatableContent)(u);
70
69
  exports.isNestableContent = isNestableContent;
71
70
  const NestableLegacy = (ctx) => {
72
71
  return {
@@ -108,10 +107,10 @@ const NestableLegacy = (ctx) => {
108
107
  return (0, LinkContent_1.LinkContentLegacy)(ctx);
109
108
  case "Separator":
110
109
  return (0, SeparatorContent_1.SeparatorLegacy)(ctx);
111
- case "Repeatable.Link":
112
- return (0, RepeatableContent_1.RepeatableLegacy)(ctx, "Link");
113
110
  case "Table":
114
111
  return (0, TableContent_1.TableLegacy)(ctx);
112
+ case "Repeatable.Link":
113
+ return (0, RepeatableContent_1.RepeatableLegacy)(ctx, "Link");
115
114
  default:
116
115
  return;
117
116
  }
@@ -155,10 +154,10 @@ const NestableLegacy = (ctx) => {
155
154
  return (0, LinkContent_1.LinkContentLegacy)(ctx).encode(value);
156
155
  case SeparatorContent_1.SeparatorContentType:
157
156
  return (0, SeparatorContent_1.SeparatorLegacy)(ctx).encode(value);
158
- case "RepeatableContent":
159
- return (0, RepeatableContent_1.RepeatableLegacy)(ctx, value.type).encode(value);
160
157
  case TableContent_1.TableContentType:
161
158
  return (0, TableContent_1.TableLegacy)(ctx).encode(value);
159
+ case "RepeatableContent":
160
+ return (0, RepeatableContent_1.RepeatableLegacy)(ctx, value.type).encode(value);
162
161
  default:
163
162
  return;
164
163
  }
@@ -85,7 +85,7 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
85
85
  }>>]>>;
86
86
  }>>;
87
87
  export declare type RepeatableContent = t.TypeOf<typeof RepeatableContent>;
88
- export declare const isRepeatableContent: t.Is<{
88
+ export declare const isRepeatableContent: (u: unknown) => u is {
89
89
  __TYPE__: "RepeatableContent";
90
90
  type: "Link";
91
91
  value: ({
@@ -164,7 +164,7 @@ export declare const isRepeatableContent: t.Is<{
164
164
  variant?: string;
165
165
  });
166
166
  })[];
167
- }>;
167
+ };
168
168
  export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType: "Link") => t.Type<RepeatableContent, WithTypes<Array<unknown>>, unknown>;
169
169
  export declare type RepeatableCustomType = Link;
170
170
  export declare function traverseRepeatableContent({ path, key, apiId, model, content, }: {
@@ -6,13 +6,16 @@ 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 utils_1 = require("../../utils");
9
10
  const LinkContent_1 = require("./LinkContent");
11
+ const RepeatableContentType = "RepeatableContent";
10
12
  exports.RepeatableContent = t.strict({
11
- __TYPE__: t.literal("RepeatableContent"),
13
+ __TYPE__: t.literal(RepeatableContentType),
12
14
  type: t.literal("Link"),
13
15
  value: t.array(LinkContent_1.LinkContent),
14
16
  });
15
- exports.isRepeatableContent = exports.RepeatableContent.is;
17
+ const isRepeatableContent = (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === RepeatableContentType;
18
+ exports.isRepeatableContent = isRepeatableContent;
16
19
  const RepeatableLegacy = (ctx, fieldType) => {
17
20
  return new t.Type("RepeatableLegacy", exports.isRepeatableContent, (items) => {
18
21
  const parsed = (0, function_1.pipe)(t.array(t.unknown).decode(items), fp_ts_1.either.map((items) => {
@@ -608,6 +608,118 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
608
608
  direction: t.StringC;
609
609
  }>]>>;
610
610
  export declare type TextBlock = t.TypeOf<typeof TextBlock>;
611
+ export declare const TextBlockLegacy: t.ExactC<t.IntersectionC<[t.TypeC<{
612
+ type: t.Type<"image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", unknown>;
613
+ content: t.IntersectionC<[t.TypeC<{
614
+ text: t.StringC;
615
+ }>, t.PartialC<{
616
+ spans: t.Type<({
617
+ data: ({
618
+ __TYPE__: "ImageLink";
619
+ } & {
620
+ kind: "image";
621
+ id: string;
622
+ url: string;
623
+ height: string;
624
+ width: string;
625
+ size: string;
626
+ name: string;
627
+ } & {
628
+ date?: string | null | undefined;
629
+ }) | ({
630
+ __TYPE__: "FileLink";
631
+ } & {
632
+ kind: "file";
633
+ id: string;
634
+ url: string;
635
+ name: string;
636
+ size: string;
637
+ } & {
638
+ date?: string | null | undefined;
639
+ }) | ({
640
+ __TYPE__: "DocumentLink";
641
+ } & {
642
+ id: string;
643
+ }) | ({
644
+ __TYPE__: "ExternalLink";
645
+ } & {
646
+ url: string;
647
+ } & {
648
+ kind?: "web";
649
+ target?: string | null | undefined;
650
+ preview?: {
651
+ title?: string;
652
+ } | null | undefined;
653
+ });
654
+ start: number;
655
+ end: number;
656
+ type: "hyperlink";
657
+ } | {
658
+ data: string;
659
+ start: number;
660
+ end: number;
661
+ type: "label";
662
+ } | {
663
+ start: number;
664
+ end: number;
665
+ type: "strong" | "em" | "list-item";
666
+ })[], ({
667
+ data: ({
668
+ __TYPE__: "ImageLink";
669
+ } & {
670
+ kind: "image";
671
+ id: string;
672
+ url: string;
673
+ height: string;
674
+ width: string;
675
+ size: string;
676
+ name: string;
677
+ } & {
678
+ date?: string | null | undefined;
679
+ }) | ({
680
+ __TYPE__: "FileLink";
681
+ } & {
682
+ kind: "file";
683
+ id: string;
684
+ url: string;
685
+ name: string;
686
+ size: string;
687
+ } & {
688
+ date?: string | null | undefined;
689
+ }) | ({
690
+ __TYPE__: "DocumentLink";
691
+ } & {
692
+ id: string;
693
+ }) | ({
694
+ __TYPE__: "ExternalLink";
695
+ } & {
696
+ url: string;
697
+ } & {
698
+ kind?: "web";
699
+ target?: string | null | undefined;
700
+ preview?: {
701
+ title?: string;
702
+ } | null | undefined;
703
+ });
704
+ start: number;
705
+ end: number;
706
+ type: "hyperlink";
707
+ } | {
708
+ data: string;
709
+ start: number;
710
+ end: number;
711
+ type: "label";
712
+ } | {
713
+ start: number;
714
+ end: number;
715
+ type: "strong" | "em" | "list-item";
716
+ })[], unknown>;
717
+ }>]>;
718
+ }>, t.PartialC<{
719
+ label: t.StringC;
720
+ direction: t.StringC;
721
+ }>]>>;
722
+ export declare type TextBlockLegacy = t.TypeOf<typeof TextBlockLegacy>;
611
723
  export declare const BlockLegacy: t.Type<({
612
724
  type: "image";
613
725
  data: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Block = exports.BlockLegacy = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.checkImageBlock = exports.ImageBlock = exports.ValidatedSpans = exports.SpanLegacy = exports.Span = void 0;
3
+ exports.Block = exports.BlockLegacy = exports.TextBlockLegacy = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.checkImageBlock = exports.ImageBlock = exports.ValidatedSpans = exports.SpanLegacy = exports.Span = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fp_ts_1 = require("fp-ts");
6
6
  const Either_1 = require("fp-ts/lib/Either");
@@ -151,20 +151,20 @@ const TextBlockCodec = (spanCodec) => t.exact(t.intersection([
151
151
  ]));
152
152
  /* These Text block will decode codec A and encode from codec B to A */
153
153
  exports.TextBlock = TextBlockCodec(exports.Span);
154
- const TextBlockLegacy = TextBlockCodec(exports.SpanLegacy);
154
+ exports.TextBlockLegacy = TextBlockCodec(exports.SpanLegacy);
155
155
  const legacyBlockCodec = t.union([
156
156
  EmbedBlockLegacy,
157
157
  ImageBlockLegacy,
158
- TextBlockLegacy,
158
+ exports.TextBlockLegacy,
159
159
  ]);
160
- exports.BlockLegacy = new t.Type("BlockLegacy", (u) => EmbedBlockLegacy.is(u) || ImageBlockLegacy.is(u) || TextBlockLegacy.is(u), (legacyBlock) => legacyBlockCodec.decode(legacyBlock), (block) => {
160
+ exports.BlockLegacy = new t.Type("BlockLegacy", (u) => EmbedBlockLegacy.is(u) || ImageBlockLegacy.is(u) || exports.TextBlockLegacy.is(u), (legacyBlock) => legacyBlockCodec.decode(legacyBlock), (block) => {
161
161
  return (() => {
162
162
  if (exports.ImageBlock.is(block))
163
163
  return ImageBlockLegacy.encode(block);
164
164
  else if (exports.EmbedBlock.is(block))
165
165
  return EmbedBlockLegacy.encode(block);
166
166
  else
167
- return TextBlockLegacy.encode(block);
167
+ return exports.TextBlockLegacy.encode(block);
168
168
  })();
169
169
  });
170
170
  exports.Block = t.union([exports.ImageBlock, exports.EmbedBlock, exports.TextBlock]);