@prismicio/types-internal 2.7.0-alpha.2 → 2.7.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 (36) hide show
  1. package/lib/content/Document.d.ts +1783 -859
  2. package/lib/content/fields/WidgetContent.d.ts +1782 -858
  3. package/lib/content/fields/nestable/LinkContent.d.ts +207 -90
  4. package/lib/content/fields/nestable/LinkContent.js +93 -48
  5. package/lib/content/fields/nestable/NestableContent.d.ts +297 -143
  6. package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +546 -249
  7. package/lib/content/fields/nestable/RichTextContent/index.d.ts +270 -130
  8. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +594 -286
  9. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +135 -65
  10. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +594 -286
  11. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +297 -143
  12. package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +297 -143
  13. package/lib/content/fields/slices/Slice/index.d.ts +1080 -520
  14. package/lib/content/fields/slices/SliceItem.d.ts +1080 -520
  15. package/lib/content/fields/slices/SlicesContent.d.ts +1485 -715
  16. package/lib/customtypes/CustomType.d.ts +180 -342
  17. package/lib/customtypes/Section.d.ts +180 -342
  18. package/lib/customtypes/diff/SharedSlice.d.ts +80 -152
  19. package/lib/customtypes/diff/Variation.d.ts +80 -152
  20. package/lib/customtypes/widgets/Group.d.ts +6 -60
  21. package/lib/customtypes/widgets/Widget.d.ts +129 -318
  22. package/lib/customtypes/widgets/nestable/Link.d.ts +2 -20
  23. package/lib/customtypes/widgets/nestable/Link.js +1 -2
  24. package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +1 -10
  25. package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +2 -20
  26. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +2 -20
  27. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +8 -80
  28. package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +33 -87
  29. package/lib/customtypes/widgets/slices/Slices.d.ts +172 -424
  30. package/package.json +1 -1
  31. package/src/content/fields/nestable/LinkContent.ts +118 -58
  32. package/src/customtypes/widgets/nestable/Link.ts +1 -2
  33. package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +0 -727
  34. package/lib/content/fields/nestable/RichTextContent/TextBlock.js +0 -80
  35. package/lib/customtypes/widgets/slices/SliceWidget.d.ts +0 -327
  36. package/lib/customtypes/widgets/slices/SliceWidget.js +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "2.7.0-alpha.2",
3
+ "version": "2.7.0-alpha.4",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -10,23 +10,31 @@ import { hasContentType } from "../../utils"
10
10
 
11
11
  export const ImageLinkType = "ImageLink"
12
12
 
13
- const imageLinkLegacyCodec = t.exact(
14
- t.intersection([
15
- t.type({
16
- id: t.string,
17
- url: t.string,
18
- height: t.string,
19
- width: t.string,
20
- size: t.string,
21
- name: t.string,
22
- kind: t.string,
23
- }),
24
- t.partial({
25
- date: StringOrNull,
13
+ const imageLinkLegacyCodec = t.intersection([
14
+ t.strict({ kind: t.literal("image") }),
15
+ t.union([
16
+ t.exact(
17
+ t.intersection([
18
+ t.type({
19
+ id: t.string,
20
+ url: t.string,
21
+ height: t.string,
22
+ width: t.string,
23
+ size: t.string,
24
+ name: t.string,
25
+ }),
26
+ t.partial({
27
+ date: StringOrNull,
28
+ text: t.string,
29
+ }),
30
+ ]),
31
+ ),
32
+ t.strict({
26
33
  text: t.string,
27
34
  }),
28
35
  ]),
29
- )
36
+ ])
37
+
30
38
  type ImageLinkLegacy = t.TypeOf<typeof imageLinkLegacyCodec>
31
39
  const ImageLinkLegacy = new t.Type<ImageLinkContent, ImageLinkLegacy, unknown>(
32
40
  "ImageLink",
@@ -58,21 +66,31 @@ export type ImageLinkContent = t.TypeOf<typeof ImageLinkContent>
58
66
 
59
67
  export const FileLinkType = "FileLink"
60
68
 
61
- const fileLinkLegacyCodec = t.exact(
62
- t.intersection([
63
- t.type({
64
- id: t.string,
65
- url: t.string,
66
- name: t.string,
67
- kind: t.string,
68
- size: withFallback(t.string, "0"),
69
- }),
70
- t.partial({
71
- date: nullable(t.string),
69
+ const fileLinkLegacyCodec = t.intersection([
70
+ t.strict({
71
+ kind: t.literal("file"),
72
+ }),
73
+ t.union([
74
+ t.exact(
75
+ t.intersection([
76
+ t.type({
77
+ id: t.string,
78
+ url: t.string,
79
+ name: t.string,
80
+ size: withFallback(t.string, "0"),
81
+ }),
82
+ t.partial({
83
+ date: StringOrNull,
84
+ text: t.string,
85
+ }),
86
+ ]),
87
+ ),
88
+ t.strict({
72
89
  text: t.string,
73
90
  }),
74
91
  ]),
75
- )
92
+ ])
93
+
76
94
  type FileLinkLegacy = t.TypeOf<typeof fileLinkLegacyCodec>
77
95
  const FileLinkLegacy = new t.Type<FileLinkContent, FileLinkLegacy>(
78
96
  "FileLink",
@@ -94,31 +112,31 @@ const FileLinkLegacy = new t.Type<FileLinkContent, FileLinkLegacy>(
94
112
  )
95
113
 
96
114
  export const FileLinkContent = t.intersection([
115
+ t.strict({
116
+ __TYPE__: t.literal(FileLinkType),
117
+ }),
97
118
  fileLinkLegacyCodec,
119
+ ])
120
+ export type FileLinkContent = t.TypeOf<typeof FileLinkContent>
121
+
122
+ export const DocumentLinkType = "DocumentLink"
123
+
124
+ const documentLinkLegacyCodec = t.union([
98
125
  t.exact(
99
126
  t.intersection([
100
- t.type({
101
- __TYPE__: t.literal(FileLinkType),
102
- }),
127
+ t.type({ id: NonEmptyString }),
103
128
  t.partial({
104
- size: withFallback(t.string, "0"),
129
+ kind: t.literal("document"),
105
130
  text: t.string,
106
131
  }),
107
132
  ]),
108
133
  ),
134
+ t.strict({
135
+ kind: t.literal("document"),
136
+ text: t.string,
137
+ }),
109
138
  ])
110
- export type FileLinkContent = t.TypeOf<typeof FileLinkContent>
111
-
112
- export const DocumentLinkType = "DocumentLink"
113
139
 
114
- const documentLinkLegacyCodec = t.exact(
115
- t.intersection([
116
- t.type({ id: NonEmptyString }),
117
- t.partial({
118
- text: t.string,
119
- }),
120
- ]),
121
- )
122
140
  type DocumentLinkLegacy = t.TypeOf<typeof documentLinkLegacyCodec>
123
141
  const DocumentLinkLegacy = new t.Type<DocumentLinkContent, DocumentLinkLegacy>(
124
142
  "DocumentLink",
@@ -149,23 +167,29 @@ export type DocumentLinkContent = t.TypeOf<typeof DocumentLinkContent>
149
167
 
150
168
  export const ExternalLinkType = "ExternalLink"
151
169
 
152
- const externalLinkLegacyCodec = t.exact(
153
- t.intersection([
154
- t.type({
155
- url: t.string,
156
- }),
157
- t.partial({
158
- kind: t.literal("web"),
159
- target: StringOrNull,
160
- preview: nullable(
161
- t.partial({
162
- title: t.string,
163
- }),
164
- ),
165
- text: t.string,
166
- }),
167
- ]),
168
- )
170
+ const externalLinkLegacyCodec = t.union([
171
+ t.exact(
172
+ t.intersection([
173
+ t.type({
174
+ url: t.string,
175
+ }),
176
+ t.partial({
177
+ kind: t.literal("web"),
178
+ target: StringOrNull,
179
+ preview: nullable(
180
+ t.partial({
181
+ title: t.string,
182
+ }),
183
+ ),
184
+ text: t.string,
185
+ }),
186
+ ]),
187
+ ),
188
+ t.strict({
189
+ kind: t.literal("web"),
190
+ text: t.string,
191
+ }),
192
+ ])
169
193
 
170
194
  type ExternalLinkLegacy = t.TypeOf<typeof externalLinkLegacyCodec>
171
195
  const ExternalLinkLegacy = new t.Type<ExternalLinkContent, ExternalLinkLegacy>(
@@ -196,6 +220,40 @@ export const ExternalLinkContent = t.intersection([
196
220
  ])
197
221
  export type ExternalLinkContent = t.TypeOf<typeof ExternalLinkContent>
198
222
 
223
+ export const AnyLinkType = "AnyLink"
224
+
225
+ const anyLinkLegacyCodec = t.strict({
226
+ text: t.string,
227
+ })
228
+
229
+ type AnyLinkLegacy = t.TypeOf<typeof anyLinkLegacyCodec>
230
+ const AnyLinkLegacy = new t.Type<AnyLinkContent, AnyLinkLegacy>(
231
+ "AnyLink",
232
+ (u): u is AnyLinkContent => hasContentType(u) && u.__TYPE__ === AnyLinkType,
233
+ (anyLink) => {
234
+ return pipe(
235
+ anyLinkLegacyCodec.decode(anyLink),
236
+ either.map((parsedAnyLink) => {
237
+ return AnyLinkContent.encode({
238
+ ...parsedAnyLink,
239
+ __TYPE__: AnyLinkType,
240
+ })
241
+ }),
242
+ )
243
+ },
244
+ (anyLink: AnyLinkContent): AnyLinkLegacy => {
245
+ return anyLinkLegacyCodec.encode(anyLink)
246
+ },
247
+ )
248
+
249
+ export const AnyLinkContent = t.intersection([
250
+ t.strict({
251
+ __TYPE__: t.literal(AnyLinkType),
252
+ }),
253
+ anyLinkLegacyCodec,
254
+ ])
255
+ export type AnyLinkContent = t.TypeOf<typeof AnyLinkContent>
256
+
199
257
  export const LinkContentType = "LinkContent"
200
258
 
201
259
  export const isLinkContent = (u: unknown): u is LinkContent =>
@@ -206,6 +264,7 @@ export const LinkLegacy = t.union([
206
264
  FileLinkLegacy,
207
265
  DocumentLinkLegacy,
208
266
  ExternalLinkLegacy,
267
+ AnyLinkLegacy,
209
268
  ])
210
269
 
211
270
  type LinkLegacy = t.OutputOf<typeof LinkLegacy>
@@ -239,6 +298,7 @@ export const Link = t.union([
239
298
  FileLinkContent,
240
299
  DocumentLinkContent,
241
300
  ExternalLinkContent,
301
+ AnyLinkContent,
242
302
  ])
243
303
  export const LinkContent = t.strict({
244
304
  __TYPE__: t.literal(LinkContentType),
@@ -3,7 +3,6 @@ import * as t from "io-ts"
3
3
  import { withFallback } from "io-ts-types/lib/withFallback"
4
4
 
5
5
  import { StringOrNull } from "../../../validators"
6
- import { Text } from "./Text"
7
6
 
8
7
  const arrayString = (
9
8
  entries:
@@ -79,7 +78,7 @@ export const LinkConfig = t.exact(
79
78
  masks: MasksArrayString,
80
79
  tags: MasksArrayString,
81
80
  allowTargetBlank: t.boolean,
82
- text: Text,
81
+ allowText: t.boolean,
83
82
  }),
84
83
  )
85
84
  export type LinkConfig = t.TypeOf<typeof LinkConfig>