@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,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,8 @@
1
+ import * as t from "io-ts"
2
+
3
+ import { Number } from "../../../../../../../validators"
4
+
5
+ export const SpanLocation = t.type({
6
+ start: Number,
7
+ end: Number,
8
+ })
@@ -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>
@@ -0,0 +1,2 @@
1
+ export * from "./HyperlinkSpan"
2
+ export * from "./TextSpan"
@@ -0,0 +1,2 @@
1
+ export { ImportBlock } from "./ImportBlock"
2
+ export { ImportRichText } from "./ImportRichText"
@@ -13,33 +13,38 @@ const LinkTypeValidator = t.type({
13
13
  ),
14
14
  })
15
15
 
16
- const WebLink = t.intersection([
17
- t.type({
18
- link_type: t.literal("Web"),
19
- url: String,
20
- }),
21
- t.partial({
22
- target: String,
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.type({
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.type({
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(t.union([WebLink, DocumentLink, MediaLink]))
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.type({
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 * 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"