@prismicio/types-internal 2.2.0-alpha.16 → 2.2.0-alpha.17

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 (84) hide show
  1. package/lib/import/converters/fields/nestable/Image.d.ts +3 -1
  2. package/lib/import/converters/fields/nestable/Image.js +18 -2
  3. package/lib/import/converters/fields/nestable/Nestable.js +2 -0
  4. package/lib/import/converters/fields/nestable/RichText.d.ts +4 -0
  5. package/lib/import/converters/fields/nestable/RichText.js +55 -0
  6. package/lib/import/converters/fields/nestable/index.d.ts +1 -0
  7. package/lib/import/converters/fields/nestable/index.js +1 -0
  8. package/lib/import/validators/fields/ImportField.d.ts +6 -0
  9. package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.js +1 -1
  10. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.js +1 -1
  11. package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.js +1 -1
  12. package/lib/import/validators/fields/nestable/Embed.d.ts +3 -0
  13. package/lib/import/validators/fields/nestable/Embed.js +3 -8
  14. package/lib/import/validators/fields/nestable/GeoPoint.js +2 -2
  15. package/lib/import/validators/fields/nestable/Image/default.d.ts +22 -0
  16. package/lib/import/validators/fields/nestable/Image/default.js +19 -0
  17. package/lib/import/validators/fields/nestable/Image/index.d.ts +19 -0
  18. package/lib/import/validators/fields/nestable/Image/index.js +22 -22
  19. package/lib/import/validators/fields/nestable/Image/merge.d.ts +23 -0
  20. package/lib/import/validators/fields/nestable/Image/merge.js +44 -0
  21. package/lib/import/validators/fields/nestable/Image/validators.d.ts +35 -0
  22. package/lib/import/validators/fields/nestable/Image/validators.js +31 -0
  23. package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.d.ts +6 -0
  24. package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.js +25 -0
  25. package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.d.ts +24 -0
  26. package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.js +26 -0
  27. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.d.ts +6 -0
  28. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.js +18 -0
  29. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.d.ts +10 -0
  30. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.js +11 -0
  31. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.d.ts +8 -0
  32. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.js +11 -0
  33. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.d.ts +70 -0
  34. package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.js +43 -0
  35. package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.d.ts +65 -0
  36. package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.js +20 -0
  37. package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.d.ts +4 -0
  38. package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.js +7 -0
  39. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.d.ts +24 -0
  40. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.js +18 -0
  41. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.d.ts +5 -0
  42. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.js +10 -0
  43. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.d.ts +17 -0
  44. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.js +22 -0
  45. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.d.ts +2 -0
  46. package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.js +5 -0
  47. package/lib/import/validators/fields/nestable/ImportRichText/index.d.ts +2 -0
  48. package/lib/import/validators/fields/nestable/ImportRichText/index.js +7 -0
  49. package/lib/import/validators/fields/nestable/Link.d.ts +21 -6
  50. package/lib/import/validators/fields/nestable/Link.js +8 -8
  51. package/lib/import/validators/fields/nestable/Nestable.d.ts +8 -1
  52. package/lib/import/validators/fields/nestable/Nestable.js +5 -1
  53. package/lib/import/validators/fields/nestable/index.d.ts +2 -1
  54. package/lib/import/validators/fields/nestable/index.js +4 -1
  55. package/package.json +1 -1
  56. package/src/import/converters/fields/nestable/Image.ts +34 -4
  57. package/src/import/converters/fields/nestable/Nestable.ts +3 -0
  58. package/src/import/converters/fields/nestable/RichText.ts +62 -0
  59. package/src/import/converters/fields/nestable/index.ts +1 -0
  60. package/src/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.ts +1 -1
  61. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.ts +1 -1
  62. package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.ts +1 -1
  63. package/src/import/validators/fields/nestable/Embed.ts +4 -17
  64. package/src/import/validators/fields/nestable/GeoPoint.ts +2 -2
  65. package/src/import/validators/fields/nestable/Image/default.ts +25 -0
  66. package/src/import/validators/fields/nestable/Image/index.ts +34 -36
  67. package/src/import/validators/fields/nestable/Image/{Decoder.ts → merge.ts} +23 -20
  68. package/src/import/validators/fields/nestable/Image/{Validator.ts → validators.ts} +9 -2
  69. package/src/import/validators/fields/nestable/ImportRichText/ImportBlock.ts +39 -0
  70. package/src/import/validators/fields/nestable/ImportRichText/ImportRichText.ts +41 -0
  71. package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.ts +44 -0
  72. package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.ts +13 -0
  73. package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.ts +13 -0
  74. package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.ts +56 -0
  75. package/src/import/validators/fields/nestable/ImportRichText/blocks/Span.ts +44 -0
  76. package/src/import/validators/fields/nestable/ImportRichText/blocks/index.ts +4 -0
  77. package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.ts +24 -0
  78. package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.ts +8 -0
  79. package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.ts +26 -0
  80. package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/index.ts +2 -0
  81. package/src/import/validators/fields/nestable/ImportRichText/index.ts +2 -0
  82. package/src/import/validators/fields/nestable/Link.ts +18 -13
  83. package/src/import/validators/fields/nestable/Nestable.ts +6 -1
  84. package/src/import/validators/fields/nestable/index.ts +2 -1
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportEmbedBlock = exports.ImportEmbedBlockType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const Embed_1 = require("../../Embed");
7
+ exports.ImportEmbedBlockType = t.literal("embed");
8
+ exports.ImportEmbedBlock = t.strict({
9
+ type: exports.ImportEmbedBlockType,
10
+ oembed: Embed_1.ImportEmbedValue,
11
+ });
@@ -0,0 +1,8 @@
1
+ import * as t from "io-ts";
2
+ export declare const ImportImageBlockType: t.LiteralC<"image">;
3
+ export declare type ImportImageBlockType = t.TypeOf<typeof ImportImageBlockType>;
4
+ export declare const ImportImageBlock: t.ExactC<t.TypeC<{
5
+ type: t.LiteralC<"image">;
6
+ id: t.StringC;
7
+ }>>;
8
+ export declare type ImportImageBlock = t.TypeOf<typeof ImportImageBlock>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportImageBlock = exports.ImportImageBlockType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../../../validators");
7
+ exports.ImportImageBlockType = t.literal("image");
8
+ exports.ImportImageBlock = t.strict({
9
+ type: exports.ImportImageBlockType,
10
+ id: validators_1.String,
11
+ });
@@ -0,0 +1,70 @@
1
+ import * as t from "io-ts";
2
+ export declare const ImportTextBlockTypes: {
3
+ readonly Paragraph: "paragraph";
4
+ readonly OListItem: "o-list-item";
5
+ readonly ListItem: "list-item";
6
+ readonly Heading1: "heading1";
7
+ readonly Heading2: "heading2";
8
+ readonly Heading3: "heading3";
9
+ readonly Heading4: "heading4";
10
+ readonly Heading5: "heading5";
11
+ readonly Heading6: "heading6";
12
+ readonly Preformatted: "preformatted";
13
+ };
14
+ export declare const ImportTextBlockType: t.KeyofC<{
15
+ paragraph: null;
16
+ "o-list-item": null;
17
+ "list-item": null;
18
+ heading1: null;
19
+ heading2: null;
20
+ heading3: null;
21
+ heading4: null;
22
+ heading5: null;
23
+ heading6: null;
24
+ preformatted: null;
25
+ }>;
26
+ export declare type ImportTextBlockType = t.TypeOf<typeof ImportTextBlockType>;
27
+ export declare const ImportTextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
28
+ type: t.KeyofC<{
29
+ paragraph: null;
30
+ "o-list-item": null;
31
+ "list-item": null;
32
+ heading1: null;
33
+ heading2: null;
34
+ heading3: null;
35
+ heading4: null;
36
+ heading5: null;
37
+ heading6: null;
38
+ preformatted: null;
39
+ }>;
40
+ text: t.StringC;
41
+ }>, t.PartialC<{
42
+ spans: t.ArrayC<t.Type<({
43
+ type: "hyperlink";
44
+ } & {
45
+ start: number;
46
+ end: number;
47
+ } & {
48
+ data: ({
49
+ link_type: "Web";
50
+ url: string;
51
+ } & {
52
+ target?: string;
53
+ }) | {
54
+ link_type: "Document";
55
+ id: string;
56
+ } | {
57
+ link_type: "Media";
58
+ id: string;
59
+ };
60
+ }) | ({
61
+ type: "label" | "strong" | "em";
62
+ } & {
63
+ start: number;
64
+ end: number;
65
+ }), {
66
+ type: "label" | "strong" | "em" | "hyperlink";
67
+ }, unknown>>;
68
+ direction: t.UnionC<[t.LiteralC<"ltr">, t.LiteralC<"rtl">]>;
69
+ }>]>>;
70
+ export declare type ImportTextBlock = t.TypeOf<typeof ImportTextBlock>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportTextBlock = exports.ImportTextBlockType = exports.ImportTextBlockTypes = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../../../validators");
7
+ const function_1 = require("../../../../../../validators/function");
8
+ const Span_1 = require("./Span");
9
+ exports.ImportTextBlockTypes = {
10
+ Paragraph: "paragraph",
11
+ OListItem: "o-list-item",
12
+ ListItem: "list-item",
13
+ Heading1: "heading1",
14
+ Heading2: "heading2",
15
+ Heading3: "heading3",
16
+ Heading4: "heading4",
17
+ Heading5: "heading5",
18
+ Heading6: "heading6",
19
+ Preformatted: "preformatted",
20
+ };
21
+ exports.ImportTextBlockType = t.keyof({
22
+ [exports.ImportTextBlockTypes.Paragraph]: null,
23
+ [exports.ImportTextBlockTypes.OListItem]: null,
24
+ [exports.ImportTextBlockTypes.ListItem]: null,
25
+ [exports.ImportTextBlockTypes.Heading1]: null,
26
+ [exports.ImportTextBlockTypes.Heading2]: null,
27
+ [exports.ImportTextBlockTypes.Heading3]: null,
28
+ [exports.ImportTextBlockTypes.Heading4]: null,
29
+ [exports.ImportTextBlockTypes.Heading5]: null,
30
+ [exports.ImportTextBlockTypes.Heading6]: null,
31
+ [exports.ImportTextBlockTypes.Preformatted]: null,
32
+ });
33
+ const TextDirection = (0, function_1.withCustomError)(t.union([t.literal("ltr"), t.literal("rtl")]), () => "The 'direction' property must be one of the following: ltr, rtl");
34
+ exports.ImportTextBlock = t.exact(t.intersection([
35
+ t.type({
36
+ type: exports.ImportTextBlockType,
37
+ text: validators_1.String,
38
+ }),
39
+ t.partial({
40
+ spans: (0, function_1.withCustomError)(t.array(Span_1.Span), () => "The 'spans' field must be an array"),
41
+ direction: TextDirection,
42
+ }),
43
+ ]));
@@ -0,0 +1,65 @@
1
+ import * as t from "io-ts";
2
+ declare const SpanType: t.UnionC<[t.LiteralC<"hyperlink">, t.KeyofC<{
3
+ strong: null;
4
+ em: null;
5
+ label: null;
6
+ }>]>;
7
+ export declare type SpanType = t.TypeOf<typeof SpanType>;
8
+ declare const SpanShape: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
9
+ type: t.LiteralC<"hyperlink">;
10
+ }>, t.TypeC<{
11
+ start: t.NumberC;
12
+ end: t.NumberC;
13
+ }>, t.TypeC<{
14
+ data: t.Type<({
15
+ link_type: "Web";
16
+ url: string;
17
+ } & {
18
+ target?: string;
19
+ }) | {
20
+ link_type: "Document";
21
+ id: string;
22
+ } | {
23
+ link_type: "Media";
24
+ id: string;
25
+ }, {
26
+ link_type: "Document" | "Web" | "Media";
27
+ }, unknown>;
28
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
29
+ type: t.KeyofC<{
30
+ strong: null;
31
+ em: null;
32
+ label: null;
33
+ }>;
34
+ }>, t.TypeC<{
35
+ start: t.NumberC;
36
+ end: t.NumberC;
37
+ }>]>>]>;
38
+ export declare type Span = t.TypeOf<typeof SpanShape>;
39
+ export declare const Span: t.Type<({
40
+ type: "hyperlink";
41
+ } & {
42
+ start: number;
43
+ end: number;
44
+ } & {
45
+ data: ({
46
+ link_type: "Web";
47
+ url: string;
48
+ } & {
49
+ target?: string;
50
+ }) | {
51
+ link_type: "Document";
52
+ id: string;
53
+ } | {
54
+ link_type: "Media";
55
+ id: string;
56
+ };
57
+ }) | ({
58
+ type: "label" | "strong" | "em";
59
+ } & {
60
+ start: number;
61
+ end: number;
62
+ }), {
63
+ type: "label" | "strong" | "em" | "hyperlink";
64
+ }, unknown>;
65
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Span = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const function_1 = require("../../../../../../validators/function");
7
+ const spans_1 = require("./spans");
8
+ const SpanType = (0, function_1.withCustomError)(t.union([spans_1.HyperlinkSpanType, spans_1.TextSpanType]), () => `Span 'type' field must be specified and have one of the following values: ${Object.keys(spans_1.TextSpanType.keys).join(", ")} or ${spans_1.HyperlinkSpanType.value}`);
9
+ const SpanTypeValidator = (0, function_1.withCustomError)(t.type({
10
+ type: SpanType,
11
+ }), () => "Span must be an object");
12
+ const SpanShape = t.union([spans_1.HyperlinkSpan, spans_1.TextSpan]);
13
+ exports.Span = SpanTypeValidator.pipe(new t.Type("Span", (u) => SpanShape.is(u), (u, c) => {
14
+ if (spans_1.HyperlinkSpanType.is(u.type)) {
15
+ return spans_1.HyperlinkSpan.validate(u, c);
16
+ }
17
+ else {
18
+ return spans_1.TextSpan.validate(u, c);
19
+ }
20
+ }, t.identity));
@@ -0,0 +1,4 @@
1
+ export * from "./ImportBlockType";
2
+ export * from "./ImportEmbedBlock";
3
+ export * from "./ImportImageBlock";
4
+ export * from "./ImportTextBlock";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./ImportBlockType"), exports);
5
+ (0, tslib_1.__exportStar)(require("./ImportEmbedBlock"), exports);
6
+ (0, tslib_1.__exportStar)(require("./ImportImageBlock"), exports);
7
+ (0, tslib_1.__exportStar)(require("./ImportTextBlock"), exports);
@@ -0,0 +1,24 @@
1
+ import * as t from "io-ts";
2
+ export declare const HyperlinkSpanType: t.LiteralC<"hyperlink">;
3
+ export declare type HyperlinkSpanType = t.TypeOf<typeof HyperlinkSpanType>;
4
+ export declare const HyperlinkSpan: t.ExactC<t.IntersectionC<[t.TypeC<{
5
+ type: t.LiteralC<"hyperlink">;
6
+ }>, t.TypeC<{
7
+ start: t.NumberC;
8
+ end: t.NumberC;
9
+ }>, t.TypeC<{
10
+ data: t.Type<({
11
+ link_type: "Web";
12
+ url: string;
13
+ } & {
14
+ target?: string;
15
+ }) | {
16
+ link_type: "Document";
17
+ id: string;
18
+ } | {
19
+ link_type: "Media";
20
+ id: string;
21
+ }, {
22
+ link_type: "Document" | "Web" | "Media";
23
+ }, unknown>;
24
+ }>]>>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HyperlinkSpan = exports.HyperlinkSpanType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const function_1 = require("../../../../../../../validators/function");
7
+ const Link_1 = require("../../../Link");
8
+ const SpanLocation_1 = require("./SpanLocation");
9
+ exports.HyperlinkSpanType = t.literal("hyperlink");
10
+ exports.HyperlinkSpan = t.exact(t.intersection([
11
+ t.type({
12
+ type: exports.HyperlinkSpanType,
13
+ }),
14
+ SpanLocation_1.SpanLocation,
15
+ (0, function_1.withCustomError)(t.type({
16
+ data: Link_1.Link,
17
+ }), () => "Hyperlink span must contain a 'data' field with link data"),
18
+ ]));
@@ -0,0 +1,5 @@
1
+ import * as t from "io-ts";
2
+ export declare const SpanLocation: t.TypeC<{
3
+ start: t.NumberC;
4
+ end: t.NumberC;
5
+ }>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpanLocation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const validators_1 = require("../../../../../../../validators");
7
+ exports.SpanLocation = t.type({
8
+ start: validators_1.Number,
9
+ end: validators_1.Number,
10
+ });
@@ -0,0 +1,17 @@
1
+ import * as t from "io-ts";
2
+ export declare const TextSpanType: t.KeyofC<{
3
+ strong: null;
4
+ em: null;
5
+ label: null;
6
+ }>;
7
+ export declare const TextSpan: t.ExactC<t.IntersectionC<[t.TypeC<{
8
+ type: t.KeyofC<{
9
+ strong: null;
10
+ em: null;
11
+ label: null;
12
+ }>;
13
+ }>, t.TypeC<{
14
+ start: t.NumberC;
15
+ end: t.NumberC;
16
+ }>]>>;
17
+ export declare type TextSpan = t.TypeOf<typeof TextSpan>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextSpan = exports.TextSpanType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const SpanLocation_1 = require("./SpanLocation");
7
+ const TextSpanTypes = {
8
+ Strong: "strong",
9
+ Em: "em",
10
+ Label: "label",
11
+ };
12
+ exports.TextSpanType = t.keyof({
13
+ [TextSpanTypes.Strong]: null,
14
+ [TextSpanTypes.Em]: null,
15
+ [TextSpanTypes.Label]: null,
16
+ });
17
+ exports.TextSpan = t.exact(t.intersection([
18
+ t.type({
19
+ type: exports.TextSpanType,
20
+ }),
21
+ SpanLocation_1.SpanLocation,
22
+ ]));
@@ -0,0 +1,2 @@
1
+ export * from "./HyperlinkSpan";
2
+ export * from "./TextSpan";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./HyperlinkSpan"), exports);
5
+ (0, tslib_1.__exportStar)(require("./TextSpan"), exports);
@@ -0,0 +1,2 @@
1
+ export { ImportBlock } from "./ImportBlock";
2
+ export { ImportRichText } from "./ImportRichText";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportRichText = exports.ImportBlock = void 0;
4
+ var ImportBlock_1 = require("./ImportBlock");
5
+ Object.defineProperty(exports, "ImportBlock", { enumerable: true, get: function () { return ImportBlock_1.ImportBlock; } });
6
+ var ImportRichText_1 = require("./ImportRichText");
7
+ Object.defineProperty(exports, "ImportRichText", { enumerable: true, get: function () { return ImportRichText_1.ImportRichText; } });
@@ -1,22 +1,37 @@
1
1
  import type { TypeOf } from "io-ts";
2
2
  import * as t from "io-ts";
3
- declare const WebLink: t.IntersectionC<[t.TypeC<{
3
+ declare const WebLink: t.ExactC<t.IntersectionC<[t.TypeC<{
4
4
  link_type: t.LiteralC<"Web">;
5
5
  url: t.StringC;
6
6
  }>, t.PartialC<{
7
7
  target: t.StringC;
8
- }>]>;
8
+ }>]>>;
9
9
  export declare type WebLink = t.TypeOf<typeof WebLink>;
10
- declare const DocumentLink: t.TypeC<{
10
+ declare const DocumentLink: t.ExactC<t.TypeC<{
11
11
  link_type: t.LiteralC<"Document">;
12
12
  id: t.Type<string, string, unknown>;
13
- }>;
13
+ }>>;
14
14
  export declare type DocumentLink = t.TypeOf<typeof DocumentLink>;
15
- declare const MediaLink: t.TypeC<{
15
+ declare const MediaLink: t.ExactC<t.TypeC<{
16
16
  link_type: t.LiteralC<"Media">;
17
17
  id: t.StringC;
18
- }>;
18
+ }>>;
19
19
  export declare type MediaLink = t.TypeOf<typeof MediaLink>;
20
+ export declare const Link: t.Type<({
21
+ link_type: "Web";
22
+ url: string;
23
+ } & {
24
+ target?: string;
25
+ }) | {
26
+ link_type: "Document";
27
+ id: string;
28
+ } | {
29
+ link_type: "Media";
30
+ id: string;
31
+ }, {
32
+ link_type: "Document" | "Web" | "Media";
33
+ }, unknown>;
34
+ export declare type Link = TypeOf<typeof Link>;
20
35
  export declare const ImportLink: t.Type<{
21
36
  type: "Link";
22
37
  value: ({
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ImportLink = void 0;
3
+ exports.ImportLink = exports.Link = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const t = (0, tslib_1.__importStar)(require("io-ts"));
6
6
  const DocumentId_1 = require("../../../../utils/DocumentId");
@@ -10,7 +10,7 @@ const ImportContent_1 = require("../ImportContent");
10
10
  const LinkTypeValidator = t.type({
11
11
  link_type: (0, function_1.withCustomError)(t.union([t.literal("Web"), t.literal("Document"), t.literal("Media")]), () => "The value must be `Web`, `Document` or `Media`"),
12
12
  });
13
- const WebLink = t.intersection([
13
+ const WebLink = t.exact(t.intersection([
14
14
  t.type({
15
15
  link_type: t.literal("Web"),
16
16
  url: validators_1.String,
@@ -18,18 +18,18 @@ const WebLink = t.intersection([
18
18
  t.partial({
19
19
  target: validators_1.String,
20
20
  }),
21
- ]);
22
- const DocumentLink = t.type({
21
+ ]));
22
+ const DocumentLink = t.strict({
23
23
  link_type: t.literal("Document"),
24
24
  id: DocumentId_1.DocumentId,
25
25
  });
26
- const MediaLink = t.type({
26
+ const MediaLink = t.strict({
27
27
  link_type: t.literal("Media"),
28
28
  id: validators_1.String,
29
29
  });
30
- const Link = LinkTypeValidator.pipe(t.union([WebLink, DocumentLink, MediaLink]));
30
+ exports.Link = LinkTypeValidator.pipe(t.union([WebLink, DocumentLink, MediaLink]));
31
31
  // This is the default value for the link
32
- const AnyLink = t.type({
32
+ const AnyLink = t.strict({
33
33
  link_type: t.literal("Any"),
34
34
  });
35
- exports.ImportLink = (0, ImportContent_1.ImportContent)("Link", (0, validators_1.DefaultOrElse)(AnyLink)(Link));
35
+ exports.ImportLink = (0, ImportContent_1.ImportContent)("Link", (0, validators_1.DefaultOrElse)(AnyLink)(exports.Link));
@@ -5,12 +5,13 @@ import { ImportDate } from "./Date";
5
5
  import { ImportEmbed } from "./Embed";
6
6
  import { ImportGeoPoint } from "./GeoPoint";
7
7
  import { ImportImage } from "./Image";
8
+ import { ImportRichText } from "./ImportRichText";
8
9
  import { ImportLink } from "./Link";
9
10
  import { ImportNumber } from "./Number";
10
11
  import { ImportSelect } from "./Select";
11
12
  import { ImportText } from "./Text";
12
13
  import { ImportTimestamp } from "./Timestamp";
13
- export declare type ImportNestable = ImportBoolean | ImportColor | ImportNumber | ImportSelect | ImportText | ImportDate | ImportTimestamp | ImportEmbed | ImportLink | ImportGeoPoint | ImportImage;
14
+ export declare type ImportNestable = ImportBoolean | ImportColor | ImportNumber | ImportSelect | ImportText | ImportDate | ImportTimestamp | ImportEmbed | ImportLink | ImportGeoPoint | ImportImage | ImportRichText;
14
15
  export declare const ImportNestable: {
15
16
  is(u: unknown): u is ImportNestable;
16
17
  decode: (field: NestableWidget) => (content: unknown) => {
@@ -59,6 +60,9 @@ export declare const ImportNestable: {
59
60
  }, {
60
61
  link_type: "Document" | "Web" | "Media";
61
62
  } | undefined, unknown> | import("io-ts").Type<{
63
+ type: "StructuredText";
64
+ value: import("./ImportRichText").ImportBlock[] | null;
65
+ }, unknown[] | undefined, unknown> | import("io-ts").Type<{
62
66
  type: "Number";
63
67
  value: number | null;
64
68
  }, number | undefined, unknown> | import("io-ts").Type<{
@@ -83,6 +87,9 @@ export declare const ImportNestable: {
83
87
  }> | import("fp-ts/lib/Either").Right<{
84
88
  type: "Number";
85
89
  value: number | null;
90
+ }> | import("fp-ts/lib/Either").Right<{
91
+ type: "StructuredText";
92
+ value: import("./ImportRichText").ImportBlock[] | null;
86
93
  }> | import("fp-ts/lib/Either").Right<{
87
94
  type: "Link";
88
95
  value: ({
@@ -7,6 +7,7 @@ const Date_1 = require("./Date");
7
7
  const Embed_1 = require("./Embed");
8
8
  const GeoPoint_1 = require("./GeoPoint");
9
9
  const Image_1 = require("./Image");
10
+ const ImportRichText_1 = require("./ImportRichText");
10
11
  const Link_1 = require("./Link");
11
12
  const Number_1 = require("./Number");
12
13
  const Select_1 = require("./Select");
@@ -24,7 +25,8 @@ exports.ImportNestable = {
24
25
  Embed_1.ImportEmbed.is(u) ||
25
26
  Link_1.ImportLink.is(u) ||
26
27
  GeoPoint_1.ImportGeoPoint.is(u) ||
27
- (0, Image_1.ImportImage)().is(u));
28
+ (0, Image_1.ImportImage)().is(u) ||
29
+ (0, ImportRichText_1.ImportRichText)().is(u));
28
30
  },
29
31
  decode: (field) => {
30
32
  return (content) => {
@@ -52,6 +54,8 @@ exports.ImportNestable = {
52
54
  return (0, Image_1.ImportImage)(field);
53
55
  case "GeoPoint":
54
56
  return GeoPoint_1.ImportGeoPoint;
57
+ case "StructuredText":
58
+ return (0, ImportRichText_1.ImportRichText)(field);
55
59
  default:
56
60
  throw new Error(`Unsupported type of nestable field ${field.type}`);
57
61
  }
@@ -1,10 +1,11 @@
1
1
  export * from "./Boolean";
2
2
  export * from "./Color";
3
3
  export * from "./Date";
4
- export * from "./Embed";
4
+ export { ImportEmbed } from "./Embed";
5
5
  export * from "./GeoPoint";
6
6
  export * from "./Image";
7
7
  export * from "./Image/index";
8
+ export * from "./ImportRichText";
8
9
  export * from "./Link";
9
10
  export * from "./Nestable";
10
11
  export * from "./Number";
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportEmbed = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  (0, tslib_1.__exportStar)(require("./Boolean"), exports);
5
6
  (0, tslib_1.__exportStar)(require("./Color"), exports);
6
7
  (0, tslib_1.__exportStar)(require("./Date"), exports);
7
- (0, tslib_1.__exportStar)(require("./Embed"), exports);
8
+ var Embed_1 = require("./Embed");
9
+ Object.defineProperty(exports, "ImportEmbed", { enumerable: true, get: function () { return Embed_1.ImportEmbed; } });
8
10
  (0, tslib_1.__exportStar)(require("./GeoPoint"), exports);
9
11
  (0, tslib_1.__exportStar)(require("./Image"), exports);
10
12
  (0, tslib_1.__exportStar)(require("./Image/index"), exports);
13
+ (0, tslib_1.__exportStar)(require("./ImportRichText"), exports);
11
14
  (0, tslib_1.__exportStar)(require("./Link"), exports);
12
15
  (0, tslib_1.__exportStar)(require("./Nestable"), exports);
13
16
  (0, tslib_1.__exportStar)(require("./Number"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "2.2.0-alpha.16",
3
+ "version": "2.2.0-alpha.17",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -1,11 +1,28 @@
1
1
  import type { Asset } from "../../../../common"
2
2
  import { getAssetOrThrow } from "../../../../common"
3
- import type { ImageContent } from "../../../../content"
3
+ import type { ImageContent, ImageContentView } from "../../../../content"
4
4
  import { withOptionals } from "../../../../utils/Objects"
5
5
  import type { ImageField, ImportImage } from "../../../validators"
6
+ import type { ImportImageBlock } from "../../../validators/fields/nestable/ImportRichText/blocks"
6
7
 
7
- function convertImage(imageField: ImageField, image: Asset) {
8
- return withOptionals<Omit<ImageContent, "__TYPE__" | "thumbnails">>(
8
+ function convertImage<Input extends ImageField | ImportImageBlock>(
9
+ inputImage: Input,
10
+ image: Asset,
11
+ ) {
12
+ // We can do that because anyway all properties being read
13
+ const imageField: ImageField = {
14
+ ...inputImage,
15
+ edit:
16
+ "edit" in inputImage
17
+ ? inputImage.edit
18
+ : {
19
+ x: 0,
20
+ y: 0,
21
+ zoom: 1,
22
+ },
23
+ dimensions: "dimensions" in inputImage ? inputImage.dimensions : {},
24
+ }
25
+ return withOptionals<ImageContentView>(
9
26
  {
10
27
  origin: {
11
28
  id: image.id,
@@ -57,6 +74,16 @@ function convertThumbnails(
57
74
  )
58
75
  }
59
76
 
77
+ export const imageBlockConverter = (
78
+ imageBlock: ImportImageBlock,
79
+ assets: Record<Asset["id"], Asset | undefined>,
80
+ ): ImageContentView => {
81
+ return convertImage<ImportImageBlock>(
82
+ imageBlock,
83
+ getAssetOrThrow(assets)(imageBlock.id),
84
+ )
85
+ }
86
+
60
87
  // All assets from `imageField` must be present in `assets`
61
88
  // If not then function will throw an error
62
89
  export const imageConverter = (
@@ -66,7 +93,10 @@ export const imageConverter = (
66
93
  if (!imageField) return
67
94
 
68
95
  return {
69
- ...convertImage(imageField, getAssetOrThrow(assets)(imageField.id)),
96
+ ...convertImage<ImageField>(
97
+ imageField,
98
+ getAssetOrThrow(assets)(imageField.id),
99
+ ),
70
100
  thumbnails: convertThumbnails(imageField, assets),
71
101
  __TYPE__: "ImageContent" as const,
72
102
  }
@@ -11,6 +11,7 @@ import {
11
11
  imageConverter,
12
12
  linkConverter,
13
13
  numberConverter,
14
+ richTextConverter,
14
15
  selectConverter,
15
16
  textConverter,
16
17
  timestampConverter,
@@ -44,6 +45,8 @@ export function convertNestableWidget(
44
45
  return linkConverter(field.value, assets)
45
46
  case "Image":
46
47
  return imageConverter(field.value, assets)
48
+ case "StructuredText":
49
+ return richTextConverter(field.value, assets, embeds)
47
50
  default:
48
51
  throw new Error(
49
52
  `Unsupported type of nestable converter ${JSON.stringify(field)}`,