@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.
- package/lib/import/converters/fields/nestable/Image.d.ts +3 -1
- package/lib/import/converters/fields/nestable/Image.js +18 -2
- package/lib/import/converters/fields/nestable/Nestable.js +2 -0
- package/lib/import/converters/fields/nestable/RichText.d.ts +4 -0
- package/lib/import/converters/fields/nestable/RichText.js +55 -0
- package/lib/import/converters/fields/nestable/index.d.ts +1 -0
- package/lib/import/converters/fields/nestable/index.js +1 -0
- package/lib/import/validators/fields/ImportField.d.ts +6 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.js +1 -1
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.js +1 -1
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.js +1 -1
- package/lib/import/validators/fields/nestable/Embed.d.ts +3 -0
- package/lib/import/validators/fields/nestable/Embed.js +3 -8
- package/lib/import/validators/fields/nestable/GeoPoint.js +2 -2
- package/lib/import/validators/fields/nestable/Image/default.d.ts +22 -0
- package/lib/import/validators/fields/nestable/Image/default.js +19 -0
- package/lib/import/validators/fields/nestable/Image/index.d.ts +19 -0
- package/lib/import/validators/fields/nestable/Image/index.js +22 -22
- package/lib/import/validators/fields/nestable/Image/merge.d.ts +23 -0
- package/lib/import/validators/fields/nestable/Image/merge.js +44 -0
- package/lib/import/validators/fields/nestable/Image/validators.d.ts +35 -0
- package/lib/import/validators/fields/nestable/Image/validators.js +31 -0
- package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.d.ts +6 -0
- package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.js +25 -0
- package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.d.ts +24 -0
- package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.js +26 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.d.ts +6 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.js +18 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.d.ts +10 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.js +11 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.d.ts +8 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.js +11 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.d.ts +70 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.js +43 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.d.ts +65 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.js +20 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.d.ts +4 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.js +7 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.d.ts +24 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.js +18 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.d.ts +5 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.js +10 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.d.ts +17 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.js +22 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.d.ts +2 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.js +5 -0
- package/lib/import/validators/fields/nestable/ImportRichText/index.d.ts +2 -0
- package/lib/import/validators/fields/nestable/ImportRichText/index.js +7 -0
- package/lib/import/validators/fields/nestable/Link.d.ts +21 -6
- package/lib/import/validators/fields/nestable/Link.js +8 -8
- package/lib/import/validators/fields/nestable/Nestable.d.ts +8 -1
- package/lib/import/validators/fields/nestable/Nestable.js +5 -1
- package/lib/import/validators/fields/nestable/index.d.ts +2 -1
- package/lib/import/validators/fields/nestable/index.js +4 -1
- package/package.json +1 -1
- package/src/import/converters/fields/nestable/Image.ts +34 -4
- package/src/import/converters/fields/nestable/Nestable.ts +3 -0
- package/src/import/converters/fields/nestable/RichText.ts +62 -0
- package/src/import/converters/fields/nestable/index.ts +1 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.ts +1 -1
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.ts +1 -1
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.ts +1 -1
- package/src/import/validators/fields/nestable/Embed.ts +4 -17
- package/src/import/validators/fields/nestable/GeoPoint.ts +2 -2
- package/src/import/validators/fields/nestable/Image/default.ts +25 -0
- package/src/import/validators/fields/nestable/Image/index.ts +34 -36
- package/src/import/validators/fields/nestable/Image/{Decoder.ts → merge.ts} +23 -20
- package/src/import/validators/fields/nestable/Image/{Validator.ts → validators.ts} +9 -2
- package/src/import/validators/fields/nestable/ImportRichText/ImportBlock.ts +39 -0
- package/src/import/validators/fields/nestable/ImportRichText/ImportRichText.ts +41 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.ts +44 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.ts +13 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.ts +13 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.ts +56 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/Span.ts +44 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/index.ts +4 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.ts +24 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.ts +8 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.ts +26 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/index.ts +2 -0
- package/src/import/validators/fields/nestable/ImportRichText/index.ts +2 -0
- package/src/import/validators/fields/nestable/Link.ts +18 -13
- package/src/import/validators/fields/nestable/Nestable.ts +6 -1
- package/src/import/validators/fields/nestable/index.ts +2 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as t from "io-ts"
|
|
2
|
+
|
|
3
|
+
import { withCustomError } from "../../../../../../../validators/function"
|
|
4
|
+
import { Link } from "../../../Link"
|
|
5
|
+
import { SpanLocation } from "./SpanLocation"
|
|
6
|
+
|
|
7
|
+
export const HyperlinkSpanType = t.literal("hyperlink")
|
|
8
|
+
|
|
9
|
+
export type HyperlinkSpanType = t.TypeOf<typeof HyperlinkSpanType>
|
|
10
|
+
|
|
11
|
+
export const HyperlinkSpan = t.exact(
|
|
12
|
+
t.intersection([
|
|
13
|
+
t.type({
|
|
14
|
+
type: HyperlinkSpanType,
|
|
15
|
+
}),
|
|
16
|
+
SpanLocation,
|
|
17
|
+
withCustomError(
|
|
18
|
+
t.type({
|
|
19
|
+
data: Link,
|
|
20
|
+
}),
|
|
21
|
+
() => "Hyperlink span must contain a 'data' field with link data",
|
|
22
|
+
),
|
|
23
|
+
]),
|
|
24
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as t from "io-ts"
|
|
2
|
+
|
|
3
|
+
import { SpanLocation } from "./SpanLocation"
|
|
4
|
+
|
|
5
|
+
const TextSpanTypes = {
|
|
6
|
+
Strong: "strong",
|
|
7
|
+
Em: "em",
|
|
8
|
+
Label: "label",
|
|
9
|
+
} as const
|
|
10
|
+
|
|
11
|
+
export const TextSpanType = t.keyof({
|
|
12
|
+
[TextSpanTypes.Strong]: null,
|
|
13
|
+
[TextSpanTypes.Em]: null,
|
|
14
|
+
[TextSpanTypes.Label]: null,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export const TextSpan = t.exact(
|
|
18
|
+
t.intersection([
|
|
19
|
+
t.type({
|
|
20
|
+
type: TextSpanType,
|
|
21
|
+
}),
|
|
22
|
+
SpanLocation,
|
|
23
|
+
]),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
export type TextSpan = t.TypeOf<typeof TextSpan>
|
|
@@ -13,33 +13,38 @@ const LinkTypeValidator = t.type({
|
|
|
13
13
|
),
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
const WebLink = t.
|
|
17
|
-
t.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
const WebLink = t.exact(
|
|
17
|
+
t.intersection([
|
|
18
|
+
t.type({
|
|
19
|
+
link_type: t.literal("Web"),
|
|
20
|
+
url: String,
|
|
21
|
+
}),
|
|
22
|
+
t.partial({
|
|
23
|
+
target: String,
|
|
24
|
+
}),
|
|
25
|
+
]),
|
|
26
|
+
)
|
|
25
27
|
export type WebLink = t.TypeOf<typeof WebLink>
|
|
26
28
|
|
|
27
|
-
const DocumentLink = t.
|
|
29
|
+
const DocumentLink = t.strict({
|
|
28
30
|
link_type: t.literal("Document"),
|
|
29
31
|
id: DocumentId,
|
|
30
32
|
})
|
|
31
33
|
export type DocumentLink = t.TypeOf<typeof DocumentLink>
|
|
32
34
|
|
|
33
|
-
const MediaLink = t.
|
|
35
|
+
const MediaLink = t.strict({
|
|
34
36
|
link_type: t.literal("Media"),
|
|
35
37
|
id: String,
|
|
36
38
|
})
|
|
37
39
|
export type MediaLink = t.TypeOf<typeof MediaLink>
|
|
38
40
|
|
|
39
|
-
const Link = LinkTypeValidator.pipe(
|
|
41
|
+
export const Link = LinkTypeValidator.pipe(
|
|
42
|
+
t.union([WebLink, DocumentLink, MediaLink]),
|
|
43
|
+
)
|
|
44
|
+
export type Link = TypeOf<typeof Link>
|
|
40
45
|
|
|
41
46
|
// This is the default value for the link
|
|
42
|
-
const AnyLink = t.
|
|
47
|
+
const AnyLink = t.strict({
|
|
43
48
|
link_type: t.literal("Any"),
|
|
44
49
|
})
|
|
45
50
|
|
|
@@ -5,6 +5,7 @@ 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"
|
|
@@ -23,6 +24,7 @@ export type ImportNestable =
|
|
|
23
24
|
| ImportLink
|
|
24
25
|
| ImportGeoPoint
|
|
25
26
|
| ImportImage
|
|
27
|
+
| ImportRichText
|
|
26
28
|
|
|
27
29
|
export const ImportNestable = {
|
|
28
30
|
is(u: unknown): u is ImportNestable {
|
|
@@ -37,7 +39,8 @@ export const ImportNestable = {
|
|
|
37
39
|
ImportEmbed.is(u) ||
|
|
38
40
|
ImportLink.is(u) ||
|
|
39
41
|
ImportGeoPoint.is(u) ||
|
|
40
|
-
ImportImage().is(u)
|
|
42
|
+
ImportImage().is(u) ||
|
|
43
|
+
ImportRichText().is(u)
|
|
41
44
|
)
|
|
42
45
|
},
|
|
43
46
|
decode: (field: NestableWidget) => {
|
|
@@ -66,6 +69,8 @@ export const ImportNestable = {
|
|
|
66
69
|
return ImportImage(field)
|
|
67
70
|
case "GeoPoint":
|
|
68
71
|
return ImportGeoPoint
|
|
72
|
+
case "StructuredText":
|
|
73
|
+
return ImportRichText(field)
|
|
69
74
|
default:
|
|
70
75
|
throw new Error(`Unsupported type of nestable field ${field.type}`)
|
|
71
76
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * from "./Boolean"
|
|
2
2
|
export * from "./Color"
|
|
3
3
|
export * from "./Date"
|
|
4
|
-
export
|
|
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"
|