@prismicio/types-internal 3.4.0-alpha.2 → 3.4.0-alpha.4

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 (55) hide show
  1. package/lib/content/Document.d.ts +3305 -3323
  2. package/lib/content/fields/RepeatableContent.d.ts +51 -123
  3. package/lib/content/fields/RepeatableContent.js +10 -14
  4. package/lib/content/fields/WidgetContent.d.ts +3046 -3064
  5. package/lib/content/fields/nestable/NestableContent.d.ts +501 -504
  6. package/lib/content/fields/nestable/NestableContent.js +0 -7
  7. package/lib/content/fields/nestable/RichTextContent/Block.d.ts +1036 -0
  8. package/lib/content/fields/nestable/RichTextContent/Block.js +31 -0
  9. package/lib/content/fields/nestable/RichTextContent/EmbedBlock.d.ts +60 -0
  10. package/lib/content/fields/nestable/RichTextContent/EmbedBlock.js +53 -0
  11. package/lib/content/fields/nestable/RichTextContent/ImageBlock.d.ts +203 -0
  12. package/lib/content/fields/nestable/RichTextContent/ImageBlock.js +36 -0
  13. package/lib/content/fields/nestable/RichTextContent/TableBlock.d.ts +500 -0
  14. package/lib/content/fields/nestable/RichTextContent/TableBlock.js +21 -0
  15. package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +590 -0
  16. package/lib/content/fields/nestable/RichTextContent/TextBlock.js +80 -0
  17. package/lib/content/fields/nestable/RichTextContent/index.d.ts +637 -9
  18. package/lib/content/fields/nestable/RichTextContent/index.js +4 -4
  19. package/lib/content/fields/nestable/TableContent.d.ts +245 -12
  20. package/lib/content/fields/nestable/TableContent.js +7 -7
  21. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +1013 -1019
  22. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +234 -235
  23. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +1013 -1019
  24. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +501 -504
  25. package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +499 -502
  26. package/lib/content/fields/slices/Slice/index.d.ts +1852 -1862
  27. package/lib/content/fields/slices/SliceItem.d.ts +1957 -1967
  28. package/lib/content/fields/slices/SlicesContent.d.ts +2619 -2634
  29. package/lib/customtypes/CustomType.d.ts +0 -108
  30. package/lib/customtypes/Section.d.ts +0 -108
  31. package/lib/customtypes/diff/SharedSlice.d.ts +0 -48
  32. package/lib/customtypes/diff/Variation.d.ts +0 -48
  33. package/lib/customtypes/widgets/Group.d.ts +0 -36
  34. package/lib/customtypes/widgets/Widget.d.ts +0 -126
  35. package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +0 -6
  36. package/lib/customtypes/widgets/nestable/NestableWidget.js +0 -2
  37. package/lib/customtypes/widgets/nestable/RichText.d.ts +2 -0
  38. package/lib/customtypes/widgets/nestable/RichText.js +2 -0
  39. package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +0 -12
  40. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +0 -12
  41. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +0 -48
  42. package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +0 -36
  43. package/lib/customtypes/widgets/slices/Slices.d.ts +0 -168
  44. package/package.json +1 -1
  45. package/src/content/fields/nestable/NestableContent.ts +0 -12
  46. package/src/content/fields/nestable/RichTextContent/Block.ts +35 -0
  47. package/src/content/fields/nestable/RichTextContent/EmbedBlock.ts +81 -0
  48. package/src/content/fields/nestable/RichTextContent/ImageBlock.ts +42 -0
  49. package/src/content/fields/nestable/RichTextContent/TableBlock.ts +36 -0
  50. package/src/content/fields/nestable/RichTextContent/TextBlock.ts +108 -0
  51. package/src/content/fields/nestable/RichTextContent/index.ts +2 -2
  52. package/src/content/fields/nestable/TableContent.ts +6 -6
  53. package/src/customtypes/widgets/nestable/NestableWidget.ts +0 -2
  54. package/src/customtypes/widgets/nestable/RichText.ts +2 -0
  55. package/src/content/fields/nestable/RichTextContent/Blocks.ts +0 -238
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Block = exports.BlockLegacy = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const EmbedBlock_1 = require("./EmbedBlock");
7
+ const ImageBlock_1 = require("./ImageBlock");
8
+ const TableBlock_1 = require("./TableBlock");
9
+ const TextBlock_1 = require("./TextBlock");
10
+ const legacyBlockCodec = t.union([
11
+ EmbedBlock_1.EmbedBlockLegacy,
12
+ ImageBlock_1.ImageBlockLegacy,
13
+ TextBlock_1.TextBlockLegacy,
14
+ TableBlock_1.TableBlockLegacy,
15
+ ]);
16
+ exports.BlockLegacy = new t.Type("BlockLegacy", (u) => EmbedBlock_1.EmbedBlockLegacy.is(u) ||
17
+ ImageBlock_1.ImageBlockLegacy.is(u) ||
18
+ TextBlock_1.TextBlockLegacy.is(u) ||
19
+ TableBlock_1.TableBlockLegacy.is(u), (legacyBlock) => legacyBlockCodec.decode(legacyBlock), (block) => {
20
+ return (() => {
21
+ if (ImageBlock_1.ImageBlock.is(block))
22
+ return ImageBlock_1.ImageBlockLegacy.encode(block);
23
+ else if (EmbedBlock_1.EmbedBlock.is(block))
24
+ return EmbedBlock_1.EmbedBlockLegacy.encode(block);
25
+ else if (TableBlock_1.TableBlock.is(block))
26
+ return TableBlock_1.TableBlockLegacy.encode(block);
27
+ else
28
+ return TextBlock_1.TextBlockLegacy.encode(block);
29
+ })();
30
+ });
31
+ exports.Block = t.union([ImageBlock_1.ImageBlock, EmbedBlock_1.EmbedBlock, TextBlock_1.TextBlock, TableBlock_1.TableBlock]);
@@ -0,0 +1,60 @@
1
+ import * as t from "io-ts";
2
+ import type { Block } from "./Block";
3
+ export declare const EmbedBlockLegacy: t.Type<{
4
+ type: "embed";
5
+ data: {
6
+ embed_url: string;
7
+ type: string;
8
+ } & {
9
+ version?: string | number | null;
10
+ title?: string | null | undefined;
11
+ author_name?: string | null | undefined;
12
+ author_url?: string | null | undefined;
13
+ provider_name?: string | null | undefined;
14
+ provider_url?: string | null | undefined;
15
+ cache_age?: string | number | null;
16
+ thumbnail_url?: string | null | undefined;
17
+ thumbnail_width?: number | null | undefined;
18
+ thumbnail_height?: number | null | undefined;
19
+ html?: string | null | undefined;
20
+ } & {
21
+ __TYPE__: "EmbedContent";
22
+ all: unknown;
23
+ };
24
+ } & {
25
+ label?: string | null | undefined;
26
+ direction?: string | null | undefined;
27
+ }, {
28
+ type: "embed";
29
+ data: unknown;
30
+ } & {
31
+ label?: string | null | undefined;
32
+ direction?: string | null | undefined;
33
+ }, unknown>;
34
+ export declare const EmbedBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
35
+ type: t.LiteralC<"embed">;
36
+ data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
37
+ embed_url: t.StringC;
38
+ type: t.StringC;
39
+ }>, t.PartialC<{
40
+ version: t.UnionC<[t.StringC, t.NumberC, t.NullC]>;
41
+ title: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
42
+ author_name: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
43
+ author_url: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
44
+ provider_name: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
45
+ provider_url: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
46
+ cache_age: t.UnionC<[t.StringC, t.NumberC, t.NullC]>;
47
+ thumbnail_url: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
48
+ thumbnail_width: t.UnionC<[t.Type<number, number, unknown>, t.NullC, t.UndefinedC]>;
49
+ thumbnail_height: t.UnionC<[t.Type<number, number, unknown>, t.NullC, t.UndefinedC]>;
50
+ html: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
51
+ }>]>>, t.ExactC<t.TypeC<{
52
+ __TYPE__: t.LiteralC<"EmbedContent">;
53
+ all: t.UnknownC;
54
+ }>>]>;
55
+ }>, t.PartialC<{
56
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
57
+ direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
58
+ }>]>>;
59
+ export declare type EmbedBlock = t.TypeOf<typeof EmbedBlock>;
60
+ export declare function checkEmbedBlock(block: Block): block is EmbedBlock;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkEmbedBlock = exports.EmbedBlock = exports.EmbedBlockLegacy = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fp_ts_1 = require("fp-ts");
6
+ const function_1 = require("fp-ts/lib/function");
7
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
8
+ const nestable_1 = require("../../../../customtypes/widgets/nestable");
9
+ const validators_1 = require("../../../../validators");
10
+ const EmbedContent_1 = require("../EmbedContent");
11
+ const embedBlockLegacyCodec = t.exact(t.intersection([
12
+ t.type({
13
+ type: t.literal(nestable_1.RichTextNodeType.embed),
14
+ data: t.unknown,
15
+ }),
16
+ t.partial({
17
+ label: validators_1.StringOrNull,
18
+ direction: validators_1.StringOrNull,
19
+ }),
20
+ ]));
21
+ exports.EmbedBlockLegacy = new t.Type("EmbedBlockLegacy", (u) => u.type === "embed", (block) => (0, function_1.pipe)(embedBlockLegacyCodec.decode(block), fp_ts_1.either.chain((decodedBlock) => {
22
+ return fp_ts_1.either.map((decodedData) => {
23
+ return [decodedBlock, decodedData];
24
+ })(EmbedContent_1.EmbedContentLegacy.decode(decodedBlock.data));
25
+ }), fp_ts_1.either.map(([block, parsedData]) => {
26
+ return exports.EmbedBlock.encode({
27
+ ...block,
28
+ data: {
29
+ ...parsedData,
30
+ __TYPE__: EmbedContent_1.EmbedContentType,
31
+ all: block.data,
32
+ },
33
+ });
34
+ })), (embedBlock) => {
35
+ return {
36
+ ...embedBlockLegacyCodec.encode(embedBlock),
37
+ data: EmbedContent_1.EmbedContentLegacy.encode(embedBlock.data),
38
+ };
39
+ });
40
+ exports.EmbedBlock = t.exact(t.intersection([
41
+ t.type({
42
+ type: t.literal(nestable_1.RichTextNodeType.embed),
43
+ data: EmbedContent_1.EmbedContent,
44
+ }),
45
+ t.partial({
46
+ label: validators_1.StringOrNull,
47
+ direction: validators_1.StringOrNull,
48
+ }),
49
+ ]));
50
+ function checkEmbedBlock(block) {
51
+ return block.type === nestable_1.RichTextNodeType.embed;
52
+ }
53
+ exports.checkEmbedBlock = checkEmbedBlock;
@@ -0,0 +1,203 @@
1
+ import * as t from "io-ts";
2
+ import type { Block } from "./Block";
3
+ export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
4
+ type: t.LiteralC<"image">;
5
+ data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
6
+ origin: t.ExactC<t.TypeC<{
7
+ id: t.StringC;
8
+ url: t.StringC;
9
+ width: t.NumberC;
10
+ height: t.NumberC;
11
+ }>>;
12
+ width: t.NumberC;
13
+ height: t.NumberC;
14
+ edit: t.TypeC<{
15
+ zoom: t.NumberC;
16
+ crop: t.TypeC<{
17
+ x: t.NumberC;
18
+ y: t.NumberC;
19
+ }>;
20
+ background: t.StringC;
21
+ }>;
22
+ }>, t.PartialC<{
23
+ url: t.StringC;
24
+ credits: t.Type<string | null, string | null, unknown>;
25
+ alt: t.Type<string | null, string | null, unknown>;
26
+ provider: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
27
+ }>]>>, t.PartialC<{
28
+ linkTo: t.UnionC<[t.Type<({
29
+ __TYPE__: "ImageLink";
30
+ } & {
31
+ kind: "image";
32
+ id: string;
33
+ url: string;
34
+ height: string;
35
+ width: string;
36
+ size: string;
37
+ name: string;
38
+ } & {
39
+ date?: string | null | undefined;
40
+ }) | ({
41
+ __TYPE__: "FileLink";
42
+ } & {
43
+ kind: "file";
44
+ id: string;
45
+ url: string;
46
+ name: string;
47
+ size: string;
48
+ } & {
49
+ date?: string | null | undefined;
50
+ }) | ({
51
+ __TYPE__: "DocumentLink";
52
+ } & {
53
+ id: string;
54
+ }) | ({
55
+ __TYPE__: "ExternalLink";
56
+ } & {
57
+ url: string;
58
+ } & {
59
+ kind?: "web";
60
+ target?: string | null | undefined;
61
+ preview?: {
62
+ title?: string;
63
+ } | null | undefined;
64
+ }), ({
65
+ __TYPE__: "ImageLink";
66
+ } & {
67
+ kind: "image";
68
+ id: string;
69
+ url: string;
70
+ height: string;
71
+ width: string;
72
+ size: string;
73
+ name: string;
74
+ } & {
75
+ date?: string | null | undefined;
76
+ }) | ({
77
+ __TYPE__: "FileLink";
78
+ } & {
79
+ kind: "file";
80
+ id: string;
81
+ url: string;
82
+ name: string;
83
+ size: string;
84
+ } & {
85
+ date?: string | null | undefined;
86
+ }) | ({
87
+ __TYPE__: "DocumentLink";
88
+ } & {
89
+ id: string;
90
+ }) | ({
91
+ __TYPE__: "ExternalLink";
92
+ } & {
93
+ url: string;
94
+ } & {
95
+ kind?: "web";
96
+ target?: string | null | undefined;
97
+ preview?: {
98
+ title?: string;
99
+ } | null | undefined;
100
+ }), unknown>, t.NullC, t.UndefinedC]>;
101
+ }>]>;
102
+ }>, t.PartialC<{
103
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
104
+ direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
105
+ }>]>>;
106
+ export declare type ImageBlock = t.TypeOf<typeof ImageBlock>;
107
+ export declare const ImageBlockLegacy: t.ExactC<t.IntersectionC<[t.TypeC<{
108
+ type: t.LiteralC<"image">;
109
+ data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
110
+ origin: t.ExactC<t.TypeC<{
111
+ id: t.StringC;
112
+ url: t.StringC;
113
+ width: t.NumberC;
114
+ height: t.NumberC;
115
+ }>>;
116
+ width: t.NumberC;
117
+ height: t.NumberC;
118
+ edit: t.TypeC<{
119
+ zoom: t.NumberC;
120
+ crop: t.TypeC<{
121
+ x: t.NumberC;
122
+ y: t.NumberC;
123
+ }>;
124
+ background: t.StringC;
125
+ }>;
126
+ }>, t.PartialC<{
127
+ url: t.StringC;
128
+ credits: t.Type<string | null, string | null, unknown>;
129
+ alt: t.Type<string | null, string | null, unknown>;
130
+ provider: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
131
+ }>]>>, t.PartialC<{
132
+ linkTo: t.UnionC<[t.Type<({
133
+ __TYPE__: "ImageLink";
134
+ } & {
135
+ kind: "image";
136
+ id: string;
137
+ url: string;
138
+ height: string;
139
+ width: string;
140
+ size: string;
141
+ name: string;
142
+ } & {
143
+ date?: string | null | undefined;
144
+ }) | ({
145
+ __TYPE__: "FileLink";
146
+ } & {
147
+ kind: "file";
148
+ id: string;
149
+ url: string;
150
+ name: string;
151
+ size: string;
152
+ } & {
153
+ date?: string | null | undefined;
154
+ }) | ({
155
+ __TYPE__: "DocumentLink";
156
+ } & {
157
+ id: string;
158
+ }) | ({
159
+ __TYPE__: "ExternalLink";
160
+ } & {
161
+ url: string;
162
+ } & {
163
+ kind?: "web";
164
+ target?: string | null | undefined;
165
+ preview?: {
166
+ title?: string;
167
+ } | null | undefined;
168
+ }), ({
169
+ kind: "image";
170
+ id: string;
171
+ url: string;
172
+ height: string;
173
+ width: string;
174
+ size: string;
175
+ name: string;
176
+ } & {
177
+ date?: string | null | undefined;
178
+ }) | ({
179
+ kind: "file";
180
+ id: string;
181
+ url: string;
182
+ name: string;
183
+ size: string;
184
+ } & {
185
+ date?: string | null | undefined;
186
+ }) | {
187
+ id: string;
188
+ } | ({
189
+ url: string;
190
+ } & {
191
+ kind?: "web";
192
+ target?: string | null | undefined;
193
+ preview?: {
194
+ title?: string;
195
+ } | null | undefined;
196
+ }), unknown>, t.NullC, t.UndefinedC]>;
197
+ }>]>;
198
+ }>, t.PartialC<{
199
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
200
+ direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
201
+ }>]>>;
202
+ export declare type ImageBlockLegacy = t.TypeOf<typeof ImageBlockLegacy>;
203
+ export declare function checkImageBlock(block: Block): block is ImageBlock;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkImageBlock = exports.ImageBlockLegacy = exports.ImageBlock = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const nestable_1 = require("../../../../customtypes/widgets/nestable");
7
+ const validators_1 = require("../../../../validators");
8
+ const function_1 = require("../../../../validators/function");
9
+ const ImageContent_1 = require("../ImageContent");
10
+ const LinkContent_1 = require("../LinkContent");
11
+ // We allow any codec here and let TypeScript infer the resulting codec.
12
+ // Typing it more precisely creates conflicts.
13
+ //
14
+ // Using `t.Mixed` rather than `t.Type<A, O>` causes `data.linkTo` to be
15
+ // typed as `any`. It seems to be an issue with the `nullable` helper.
16
+ const ImageBlockCodec = (linkCodec) => t.exact(t.intersection([
17
+ t.type({
18
+ type: t.literal(nestable_1.RichTextNodeType.image),
19
+ data: t.intersection([
20
+ ImageContent_1.ImageContentView,
21
+ t.partial({
22
+ linkTo: (0, function_1.nullable)(linkCodec),
23
+ }),
24
+ ]),
25
+ }),
26
+ t.partial({
27
+ label: validators_1.StringOrNull,
28
+ direction: validators_1.StringOrNull,
29
+ }),
30
+ ]));
31
+ exports.ImageBlock = ImageBlockCodec(LinkContent_1.FilledLink);
32
+ exports.ImageBlockLegacy = ImageBlockCodec(LinkContent_1.FilledLinkLegacy);
33
+ function checkImageBlock(block) {
34
+ return block.type === nestable_1.RichTextNodeType.image;
35
+ }
36
+ exports.checkImageBlock = checkImageBlock;