@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.
- package/lib/content/Document.d.ts +1783 -859
- package/lib/content/fields/WidgetContent.d.ts +1782 -858
- package/lib/content/fields/nestable/LinkContent.d.ts +207 -90
- package/lib/content/fields/nestable/LinkContent.js +93 -48
- package/lib/content/fields/nestable/NestableContent.d.ts +297 -143
- package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +546 -249
- package/lib/content/fields/nestable/RichTextContent/index.d.ts +270 -130
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +594 -286
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +135 -65
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +594 -286
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +297 -143
- package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +297 -143
- package/lib/content/fields/slices/Slice/index.d.ts +1080 -520
- package/lib/content/fields/slices/SliceItem.d.ts +1080 -520
- package/lib/content/fields/slices/SlicesContent.d.ts +1485 -715
- package/lib/customtypes/CustomType.d.ts +180 -342
- package/lib/customtypes/Section.d.ts +180 -342
- package/lib/customtypes/diff/SharedSlice.d.ts +80 -152
- package/lib/customtypes/diff/Variation.d.ts +80 -152
- package/lib/customtypes/widgets/Group.d.ts +6 -60
- package/lib/customtypes/widgets/Widget.d.ts +129 -318
- package/lib/customtypes/widgets/nestable/Link.d.ts +2 -20
- package/lib/customtypes/widgets/nestable/Link.js +1 -2
- package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +1 -10
- package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +2 -20
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +2 -20
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +8 -80
- package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +33 -87
- package/lib/customtypes/widgets/slices/Slices.d.ts +172 -424
- package/package.json +1 -1
- package/src/content/fields/nestable/LinkContent.ts +118 -58
- package/src/customtypes/widgets/nestable/Link.ts +1 -2
- package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +0 -727
- package/lib/content/fields/nestable/RichTextContent/TextBlock.js +0 -80
- package/lib/customtypes/widgets/slices/SliceWidget.d.ts +0 -327
- package/lib/customtypes/widgets/slices/SliceWidget.js +0 -8
package/package.json
CHANGED
|
@@ -10,23 +10,31 @@ import { hasContentType } from "../../utils"
|
|
|
10
10
|
|
|
11
11
|
export const ImageLinkType = "ImageLink"
|
|
12
12
|
|
|
13
|
-
const imageLinkLegacyCodec = t.
|
|
14
|
-
t.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
|
62
|
-
t.
|
|
63
|
-
t.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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.
|
|
153
|
-
t.
|
|
154
|
-
t.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
81
|
+
allowText: t.boolean,
|
|
83
82
|
}),
|
|
84
83
|
)
|
|
85
84
|
export type LinkConfig = t.TypeOf<typeof LinkConfig>
|