@prismicio/types-internal 2.0.0-beta.0 → 2.0.0-beta.1
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/common/WidgetKey.d.ts +1 -1
- package/lib/common/WidgetKey.js +1 -1
- package/lib/common/index.js +1 -1
- package/lib/content/Document.d.ts +20 -100
- package/lib/content/Document.js +1 -1
- package/lib/content/LegacyContentCtx.d.ts +2 -2
- package/lib/content/LegacyContentCtx.js +1 -1
- package/lib/content/fields/EmptyContent.d.ts +1 -1
- package/lib/content/fields/EmptyContent.js +1 -1
- package/lib/content/fields/GroupContent.d.ts +8 -28
- package/lib/content/fields/GroupContent.js +1 -1
- package/lib/content/fields/UIDContent.d.ts +1 -1
- package/lib/content/fields/UIDContent.js +1 -1
- package/lib/content/fields/WidgetContent.d.ts +18 -98
- package/lib/content/fields/WidgetContent.js +1 -1
- package/lib/content/fields/index.js +6 -6
- package/lib/content/fields/nestable/BooleanContent.d.ts +1 -1
- package/lib/content/fields/nestable/BooleanContent.js +1 -1
- package/lib/content/fields/nestable/EmbedContent.d.ts +2 -2
- package/lib/content/fields/nestable/EmbedContent.js +1 -1
- package/lib/content/fields/nestable/FieldContent/ColorContent.d.ts +1 -1
- package/lib/content/fields/nestable/FieldContent/ColorContent.js +2 -2
- package/lib/content/fields/nestable/FieldContent/DateContent.d.ts +1 -1
- package/lib/content/fields/nestable/FieldContent/DateContent.js +2 -2
- package/lib/content/fields/nestable/FieldContent/NumberContent.d.ts +1 -1
- package/lib/content/fields/nestable/FieldContent/NumberContent.js +2 -2
- package/lib/content/fields/nestable/FieldContent/RangeContent.d.ts +1 -1
- package/lib/content/fields/nestable/FieldContent/RangeContent.js +2 -2
- package/lib/content/fields/nestable/FieldContent/SelectContent.d.ts +1 -1
- package/lib/content/fields/nestable/FieldContent/SelectContent.js +2 -2
- package/lib/content/fields/nestable/FieldContent/TextContent.d.ts +1 -1
- package/lib/content/fields/nestable/FieldContent/TextContent.js +2 -2
- package/lib/content/fields/nestable/FieldContent/TimestampContent.d.ts +1 -1
- package/lib/content/fields/nestable/FieldContent/TimestampContent.js +2 -2
- package/lib/content/fields/nestable/FieldContent/index.d.ts +2 -2
- package/lib/content/fields/nestable/FieldContent/index.js +9 -9
- package/lib/content/fields/nestable/GeoPointContent.d.ts +1 -1
- package/lib/content/fields/nestable/GeoPointContent.js +1 -1
- package/lib/content/fields/nestable/ImageContent.d.ts +2 -2
- package/lib/content/fields/nestable/ImageContent.js +1 -1
- package/lib/content/fields/nestable/IntegrationFieldContent.d.ts +1 -1
- package/lib/content/fields/nestable/IntegrationFieldContent.js +1 -1
- package/lib/content/fields/nestable/LinkContent.d.ts +6 -6
- package/lib/content/fields/nestable/LinkContent.js +1 -1
- package/lib/content/fields/nestable/NestableContent.d.ts +4 -14
- package/lib/content/fields/nestable/NestableContent.js +1 -1
- package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +11 -31
- package/lib/content/fields/nestable/RichTextContent/Blocks.js +15 -11
- package/lib/content/fields/nestable/RichTextContent/index.d.ts +3 -13
- package/lib/content/fields/nestable/RichTextContent/index.js +3 -3
- package/lib/content/fields/nestable/SeparatorContent.d.ts +1 -1
- package/lib/content/fields/nestable/SeparatorContent.js +1 -1
- package/lib/content/fields/nestable/index.js +10 -10
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +5 -25
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +1 -1
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +2 -12
- package/lib/content/fields/slices/Slice/RepeatableContent.js +1 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +5 -25
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +1 -1
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +279 -27
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +6 -2
- package/lib/content/fields/slices/Slice/index.d.ts +285 -73
- package/lib/content/fields/slices/Slice/index.js +4 -4
- package/lib/content/fields/slices/SliceItem.d.ts +13 -73
- package/lib/content/fields/slices/SliceItem.js +1 -1
- package/lib/content/fields/slices/SlicesContent.d.ts +14 -74
- package/lib/content/fields/slices/SlicesContent.js +1 -1
- package/lib/content/fields/slices/index.js +3 -3
- package/lib/content/index.js +3 -3
- package/lib/content/utils.d.ts +2 -2
- package/lib/content/utils.js +2 -1
- package/lib/customtypes/CustomType.d.ts +14 -2
- package/lib/customtypes/CustomType.js +7 -2
- package/lib/customtypes/Section.d.ts +2 -2
- package/lib/customtypes/Section.js +1 -1
- package/lib/customtypes/diff/Changes.d.ts +4 -4
- package/lib/customtypes/diff/SharedSlice.d.ts +671 -3
- package/lib/customtypes/diff/Variation.d.ts +657 -3
- package/lib/customtypes/diff/index.js +3 -3
- package/lib/customtypes/index.js +4 -4
- package/lib/customtypes/widgets/Group.d.ts +2 -2
- package/lib/customtypes/widgets/Group.js +1 -1
- package/lib/customtypes/widgets/UID.d.ts +2 -2
- package/lib/customtypes/widgets/UID.js +1 -1
- package/lib/customtypes/widgets/Widget.d.ts +3 -3
- package/lib/customtypes/widgets/Widget.js +1 -1
- package/lib/customtypes/widgets/index.js +6 -6
- package/lib/customtypes/widgets/nestable/BooleanField.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/BooleanField.js +1 -1
- package/lib/customtypes/widgets/nestable/Color.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Color.js +1 -1
- package/lib/customtypes/widgets/nestable/Date.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Date.js +1 -1
- package/lib/customtypes/widgets/nestable/Embed.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Embed.js +1 -1
- package/lib/customtypes/widgets/nestable/GeoPoint.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/GeoPoint.js +1 -1
- package/lib/customtypes/widgets/nestable/Image.d.ts +3 -3
- package/lib/customtypes/widgets/nestable/Image.js +2 -2
- package/lib/customtypes/widgets/nestable/IntegrationField.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/IntegrationField.js +1 -1
- package/lib/customtypes/widgets/nestable/Link/ContentRelationshipResolver.d.ts +29 -0
- package/lib/customtypes/widgets/nestable/Link/ContentRelationshipResolver.js +44 -0
- package/lib/customtypes/widgets/nestable/Link/index.d.ts +82 -0
- package/lib/customtypes/widgets/nestable/Link/index.js +56 -0
- package/lib/customtypes/widgets/nestable/Link.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Link.js +1 -1
- package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/NestableWidget.js +1 -1
- package/lib/customtypes/widgets/nestable/Number.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Number.js +1 -1
- package/lib/customtypes/widgets/nestable/Range.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Range.js +1 -1
- package/lib/customtypes/widgets/nestable/RichText.d.ts +3 -3
- package/lib/customtypes/widgets/nestable/RichText.js +2 -2
- package/lib/customtypes/widgets/nestable/Select.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Select.js +1 -1
- package/lib/customtypes/widgets/nestable/Separator.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Separator.js +1 -1
- package/lib/customtypes/widgets/nestable/Text.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Text.js +1 -1
- package/lib/customtypes/widgets/nestable/Timestamp.d.ts +2 -2
- package/lib/customtypes/widgets/nestable/Timestamp.js +1 -1
- package/lib/customtypes/widgets/nestable/index.js +16 -16
- package/lib/customtypes/widgets/shared/ImageConstraint.d.ts +1 -1
- package/lib/customtypes/widgets/shared/ImageConstraint.js +1 -1
- package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +2 -2
- package/lib/customtypes/widgets/slices/CompositeSlice.js +1 -1
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +1 -1
- package/lib/customtypes/widgets/slices/LegacySlice.js +1 -1
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +2 -2
- package/lib/customtypes/widgets/slices/SharedSlice.js +1 -1
- package/lib/customtypes/widgets/slices/SharedSliceRef.d.ts +1 -1
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +1 -1
- package/lib/customtypes/widgets/slices/Slice.d.ts +2 -2
- package/lib/customtypes/widgets/slices/Slices.d.ts +5 -5
- package/lib/customtypes/widgets/slices/Slices.js +1 -1
- package/lib/customtypes/widgets/slices/SlicesTypes.d.ts +1 -1
- package/lib/customtypes/widgets/slices/SlicesTypes.js +1 -1
- package/lib/customtypes/widgets/slices/index.js +7 -7
- package/lib/utils/index.js +2 -2
- package/lib/validators/DateFromString.js +1 -1
- package/lib/validators/DateFromStringOrNumber.js +1 -1
- package/lib/validators/DateFromTsMs.js +1 -1
- package/lib/validators/IntFromNumber.d.ts +2 -2
- package/lib/validators/IntFromNumber.js +1 -1
- package/lib/validators/IntFromPixels.d.ts +2 -2
- package/lib/validators/IntFromPixels.js +1 -1
- package/lib/validators/NonEmptyString.js +1 -1
- package/lib/validators/NonEmptyStringOrNull.js +1 -1
- package/lib/validators/NumberOrNull.js +1 -1
- package/lib/validators/StringFromBoolean.d.ts +2 -2
- package/lib/validators/StringFromBoolean.js +1 -1
- package/lib/validators/StringFromNumber.d.ts +2 -2
- package/lib/validators/StringFromNumber.js +1 -1
- package/lib/validators/StringOrNull.js +1 -1
- package/lib/validators/TrimmedString.d.ts +2 -2
- package/lib/validators/TrimmedString.js +1 -1
- package/lib/validators/function.js +1 -1
- package/lib/validators/index.js +12 -12
- package/package.json +1 -1
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +31 -23
- package/src/content/fields/nestable/RichTextContent/index.ts +1 -3
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +4 -1
- package/src/customtypes/CustomType.ts +6 -0
|
@@ -77,24 +77,31 @@ export const ValidatedMetas = (linkCodec: LinkCodec) =>
|
|
|
77
77
|
},
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
t.
|
|
82
|
-
t.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
80
|
+
const ImageBlockCodec = (linkCodec: LinkCodec) =>
|
|
81
|
+
t.exact(
|
|
82
|
+
t.intersection([
|
|
83
|
+
t.type({
|
|
84
|
+
type: t.literal(RichTextNodeType.image),
|
|
85
|
+
data: t.intersection([
|
|
86
|
+
ImageContentView,
|
|
87
|
+
t.partial({
|
|
88
|
+
linkTo: nullable(linkCodec),
|
|
89
|
+
}),
|
|
90
|
+
]),
|
|
91
|
+
}),
|
|
92
|
+
t.partial({
|
|
93
|
+
label: StringOrNull,
|
|
94
|
+
direction: StringOrNull,
|
|
95
|
+
}),
|
|
96
|
+
]),
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
export const ImageBlock = ImageBlockCodec(Link)
|
|
97
100
|
export type ImageBlock = t.TypeOf<typeof ImageBlock>
|
|
101
|
+
|
|
102
|
+
const ImageBlockLegacy = ImageBlockCodec(LinkLegacy)
|
|
103
|
+
type ImageBlockLegacy = t.TypeOf<typeof ImageBlockLegacy>
|
|
104
|
+
|
|
98
105
|
export function checkImageBlock(block: Block): block is ImageBlock {
|
|
99
106
|
return block.type === RichTextNodeType.image
|
|
100
107
|
}
|
|
@@ -196,7 +203,7 @@ type TextBlockLegacy = t.TypeOf<typeof TextBlockLegacy>
|
|
|
196
203
|
|
|
197
204
|
const legacyBlockCodec = t.union([
|
|
198
205
|
EmbedBlockLegacy,
|
|
199
|
-
|
|
206
|
+
ImageBlockLegacy,
|
|
200
207
|
TextBlockLegacy,
|
|
201
208
|
])
|
|
202
209
|
type BlockLegacy = t.TypeOf<typeof legacyBlockCodec>
|
|
@@ -204,13 +211,14 @@ type BlockLegacy = t.TypeOf<typeof legacyBlockCodec>
|
|
|
204
211
|
export const BlockLegacy = new t.Type<Block, BlockLegacy, unknown>(
|
|
205
212
|
"BlockLegacy",
|
|
206
213
|
(u): u is Block =>
|
|
207
|
-
EmbedBlockLegacy.is(u) ||
|
|
214
|
+
EmbedBlockLegacy.is(u) || ImageBlockLegacy.is(u) || TextBlockLegacy.is(u),
|
|
208
215
|
(legacyBlock) => legacyBlockCodec.decode(legacyBlock),
|
|
209
216
|
(block: Block) => {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return EmbedBlockLegacy.encode(block)
|
|
213
|
-
|
|
217
|
+
return (() => {
|
|
218
|
+
if (ImageBlock.is(block)) return ImageBlockLegacy.encode(block)
|
|
219
|
+
else if (EmbedBlock.is(block)) return EmbedBlockLegacy.encode(block)
|
|
220
|
+
else return TextBlockLegacy.encode(block)
|
|
221
|
+
})() as BlockLegacy
|
|
214
222
|
},
|
|
215
223
|
)
|
|
216
224
|
export const Block = t.union([ImageBlock, EmbedBlock, TextBlock])
|
|
@@ -28,9 +28,7 @@ export const RichTextLegacy = (ctx: LegacyContentCtx) =>
|
|
|
28
28
|
(u) => {
|
|
29
29
|
return pipe(
|
|
30
30
|
legacyReader.decode(u),
|
|
31
|
-
either.map((r) =>
|
|
32
|
-
RichTextContent.encode({ value: r, __TYPE__: RichTextContentType }),
|
|
33
|
-
),
|
|
31
|
+
either.map((r) => ({ value: r, __TYPE__: RichTextContentType })),
|
|
34
32
|
)
|
|
35
33
|
},
|
|
36
34
|
|
|
@@ -16,7 +16,10 @@ export const isSimpleSliceContent = (u: unknown): u is SimpleSliceContent =>
|
|
|
16
16
|
|
|
17
17
|
export const SimpleSliceLegacy = (ctx: LegacyContentCtx) => {
|
|
18
18
|
return {
|
|
19
|
-
decode: (
|
|
19
|
+
decode: (() => {
|
|
20
|
+
if (ctx.fieldType === "Group") return GroupLegacy(ctx).decode.bind(null)
|
|
21
|
+
return NestableLegacy(ctx).decode.bind(null)
|
|
22
|
+
})(),
|
|
20
23
|
|
|
21
24
|
encode: (value: SimpleSliceContent) => {
|
|
22
25
|
switch (value.__TYPE__) {
|
|
@@ -9,6 +9,11 @@ import type { DynamicSlice } from "./widgets/slices/Slice"
|
|
|
9
9
|
import type { DynamicSlices } from "./widgets/slices/Slices"
|
|
10
10
|
import type { DynamicWidget } from "./widgets/Widget"
|
|
11
11
|
|
|
12
|
+
export const CustomTypeFormat = {
|
|
13
|
+
page: "page",
|
|
14
|
+
custom: "custom",
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
class CustomTypeSlicesError extends Error {
|
|
13
18
|
slices: Array<string>
|
|
14
19
|
override message: string
|
|
@@ -41,6 +46,7 @@ function customTypeReader<T extends StaticSection | DynamicSection>(
|
|
|
41
46
|
}),
|
|
42
47
|
t.partial({
|
|
43
48
|
hash: t.string,
|
|
49
|
+
format: withFallback(t.keyof(CustomTypeFormat), "custom"),
|
|
44
50
|
}),
|
|
45
51
|
]),
|
|
46
52
|
)
|