@prismicio/types-internal 2.0.0-alpha.3 → 2.0.0-alpha.5
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.js +4 -3
- package/lib/content/LegacyContentCtx.js +1 -1
- package/lib/content/fields/GroupContent.d.ts +1 -1
- package/lib/content/fields/GroupContent.js +3 -3
- package/lib/content/fields/WidgetContent.d.ts +1 -1
- package/lib/content/fields/nestable/EmbedContent.d.ts +0 -1
- package/lib/content/fields/nestable/NestableContent.js +2 -1
- package/lib/content/fields/nestable/RichTextContent/Blocks.js +4 -4
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +4 -4
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +4 -4
- package/lib/content/fields/slices/SliceItem.js +2 -1
- package/lib/content/utils.js +3 -3
- package/lib/customtypes/index.d.ts +2 -2
- package/lib/customtypes/index.js +2 -3
- package/lib/customtypes/widgets/Group.d.ts +164 -3
- package/lib/customtypes/widgets/Group.js +4 -5
- package/lib/customtypes/widgets/UID.d.ts +8 -3
- package/lib/customtypes/widgets/UID.js +4 -5
- package/lib/customtypes/widgets/Widget.d.ts +2 -2
- package/lib/customtypes/widgets/Widget.js +5 -5
- package/lib/customtypes/widgets/nestable/Link.d.ts +0 -1
- package/lib/customtypes/widgets/nestable/Link.js +0 -1
- package/lib/customtypes/widgets/nestable/RichText.d.ts +1 -1
- package/lib/customtypes/widgets/nestable/RichText.js +10 -10
- package/lib/customtypes/widgets/nestable/Text.d.ts +0 -1
- package/lib/customtypes/widgets/nestable/Text.js +0 -1
- package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +6 -3
- package/lib/customtypes/widgets/slices/CompositeSlice.js +4 -5
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +2 -3
- package/lib/customtypes/widgets/slices/LegacySlice.js +3 -3
- package/lib/customtypes/widgets/slices/SharedSliceRef.d.ts +2 -3
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +2 -2
- package/lib/customtypes/widgets/slices/Slice.d.ts +3 -3
- package/lib/customtypes/widgets/slices/Slices.d.ts +13 -4
- package/lib/customtypes/widgets/slices/Slices.js +9 -9
- package/lib/customtypes/widgets/slices/index.d.ts +6 -6
- package/lib/customtypes/widgets/slices/index.js +6 -11
- package/package.json +1 -1
- package/src/content/Document.ts +4 -3
- package/src/content/LegacyContentCtx.ts +2 -2
- package/src/content/fields/GroupContent.ts +4 -4
- package/src/content/fields/WidgetContent.ts +1 -1
- package/src/content/fields/nestable/EmbedContent.ts +1 -1
- package/src/content/fields/nestable/NestableContent.ts +2 -1
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +4 -4
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +4 -3
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +4 -3
- package/src/content/fields/slices/SliceItem.ts +2 -2
- package/src/content/utils.ts +4 -5
- package/src/customtypes/index.ts +2 -2
- package/src/customtypes/widgets/Group.ts +4 -6
- package/src/customtypes/widgets/UID.ts +4 -6
- package/src/customtypes/widgets/Widget.ts +5 -5
- package/src/customtypes/widgets/nestable/Link.ts +0 -2
- package/src/customtypes/widgets/nestable/RichText.ts +16 -16
- package/src/customtypes/widgets/nestable/Text.ts +0 -2
- package/src/customtypes/widgets/slices/CompositeSlice.ts +4 -6
- package/src/customtypes/widgets/slices/LegacySlice.ts +3 -5
- package/src/customtypes/widgets/slices/SharedSliceRef.ts +2 -4
- package/src/customtypes/widgets/slices/Slice.ts +3 -3
- package/src/customtypes/widgets/slices/Slices.ts +7 -7
- package/src/customtypes/widgets/slices/index.ts +6 -6
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { either
|
|
1
|
+
import { either } from "fp-ts/"
|
|
2
|
+
import { getOrElseW } from "fp-ts/lib/Either"
|
|
3
|
+
import { pipe } from "fp-ts/lib/function"
|
|
2
4
|
import * as t from "io-ts"
|
|
3
5
|
|
|
4
6
|
import { StringOrNull } from "../../../validators"
|
|
@@ -9,7 +11,7 @@ export const RichTextFieldType = "StructuredText"
|
|
|
9
11
|
export const DEFAULT_OPTION = "paragraph"
|
|
10
12
|
|
|
11
13
|
export type RichTextNodeType =
|
|
12
|
-
typeof RichTextNodeType[keyof typeof RichTextNodeType]
|
|
14
|
+
(typeof RichTextNodeType)[keyof typeof RichTextNodeType]
|
|
13
15
|
export const RichTextNodeType = {
|
|
14
16
|
heading1: "heading1",
|
|
15
17
|
heading2: "heading2",
|
|
@@ -51,21 +53,21 @@ export const RichTextNodeTypeCodec = t.keyof({
|
|
|
51
53
|
const RichTextOptions = new t.Type<string, string, unknown>(
|
|
52
54
|
"RichTextOptions",
|
|
53
55
|
(u: unknown): u is string => typeof u === "string",
|
|
54
|
-
(u: unknown
|
|
55
|
-
return
|
|
56
|
-
t.union([t.string, t.null]).
|
|
57
|
-
(s: string | null) => {
|
|
58
|
-
if (!s) return
|
|
56
|
+
(u: unknown) => {
|
|
57
|
+
return pipe(
|
|
58
|
+
t.union([t.string, t.null]).decode(u),
|
|
59
|
+
either.map((s: string | null) => {
|
|
60
|
+
if (!s) return DEFAULT_OPTION
|
|
59
61
|
const entries = s.split(",").map((e: string) => e.trim())
|
|
60
62
|
const filtered = entries.filter((entry) => {
|
|
61
63
|
return getOrElseW(() => undefined)(
|
|
62
64
|
RichTextNodeTypeCodec.decode(entry),
|
|
63
65
|
)
|
|
64
66
|
})
|
|
65
|
-
if (!filtered.length) return
|
|
67
|
+
if (!filtered.length) return DEFAULT_OPTION
|
|
66
68
|
|
|
67
|
-
return
|
|
68
|
-
},
|
|
69
|
+
return filtered.join(",")
|
|
70
|
+
}),
|
|
69
71
|
)
|
|
70
72
|
},
|
|
71
73
|
(a) => a,
|
|
@@ -169,11 +171,9 @@ const RichTextLabels = new t.Type<ReadonlyArray<string>, object, unknown>(
|
|
|
169
171
|
)
|
|
170
172
|
const validator = t.readonlyArray(t.string)
|
|
171
173
|
|
|
172
|
-
return
|
|
173
|
-
t
|
|
174
|
-
|
|
175
|
-
.validate(u, context),
|
|
176
|
-
(labels) => {
|
|
174
|
+
return pipe(
|
|
175
|
+
t.union([legacyValidator, validator, t.string, t.null]).decode(u),
|
|
176
|
+
either.chain((labels) => {
|
|
177
177
|
return (
|
|
178
178
|
NoLabels(labels) ||
|
|
179
179
|
LabelsAsArray(labels) ||
|
|
@@ -181,7 +181,7 @@ const RichTextLabels = new t.Type<ReadonlyArray<string>, object, unknown>(
|
|
|
181
181
|
LabelsAsString(labels) ||
|
|
182
182
|
t.failure(u, context)
|
|
183
183
|
)
|
|
184
|
-
},
|
|
184
|
+
}),
|
|
185
185
|
)
|
|
186
186
|
},
|
|
187
187
|
(res) => res,
|
|
@@ -6,14 +6,14 @@ import { NestableWidget } from "../nestable/NestableWidget"
|
|
|
6
6
|
|
|
7
7
|
export const CompositeSliceType = "Slice"
|
|
8
8
|
|
|
9
|
-
const CompositeSliceConfig = t.exact(
|
|
9
|
+
export const CompositeSliceConfig = t.exact(
|
|
10
10
|
t.partial({
|
|
11
11
|
label: StringOrNull,
|
|
12
12
|
}),
|
|
13
13
|
)
|
|
14
|
-
type CompositeSliceConfig = t.TypeOf<typeof CompositeSliceConfig>
|
|
14
|
+
export type CompositeSliceConfig = t.TypeOf<typeof CompositeSliceConfig>
|
|
15
15
|
|
|
16
|
-
const CompositeSlice = t.exact(
|
|
16
|
+
export const CompositeSlice = t.exact(
|
|
17
17
|
t.intersection([
|
|
18
18
|
t.type({
|
|
19
19
|
type: t.literal(CompositeSliceType),
|
|
@@ -29,6 +29,4 @@ const CompositeSlice = t.exact(
|
|
|
29
29
|
}),
|
|
30
30
|
]),
|
|
31
31
|
)
|
|
32
|
-
type CompositeSlice = t.TypeOf<typeof CompositeSlice>
|
|
33
|
-
|
|
34
|
-
export default CompositeSlice
|
|
32
|
+
export type CompositeSlice = t.TypeOf<typeof CompositeSlice>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
|
|
3
|
-
import Group from "../Group"
|
|
3
|
+
import { Group } from "../Group"
|
|
4
4
|
import { NestableWidget } from "../nestable/NestableWidget"
|
|
5
5
|
|
|
6
|
-
const LegacySlice = t.union([NestableWidget, Group])
|
|
6
|
+
export const LegacySlice = t.union([NestableWidget, Group])
|
|
7
7
|
|
|
8
|
-
type LegacySlice = t.TypeOf<typeof LegacySlice>
|
|
9
|
-
|
|
10
|
-
export default LegacySlice
|
|
8
|
+
export type LegacySlice = t.TypeOf<typeof LegacySlice>
|
|
@@ -2,11 +2,9 @@ import * as t from "io-ts"
|
|
|
2
2
|
|
|
3
3
|
import { SharedSliceType } from "./SharedSlice"
|
|
4
4
|
|
|
5
|
-
const SharedSliceRef = t.exact(
|
|
5
|
+
export const SharedSliceRef = t.exact(
|
|
6
6
|
t.type({
|
|
7
7
|
type: t.literal(SharedSliceType),
|
|
8
8
|
}),
|
|
9
9
|
)
|
|
10
|
-
type SharedSliceRef = t.TypeOf<typeof SharedSliceRef>
|
|
11
|
-
|
|
12
|
-
export default SharedSliceRef
|
|
10
|
+
export type SharedSliceRef = t.TypeOf<typeof SharedSliceRef>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type CompositeSlice from "./CompositeSlice"
|
|
2
|
-
import type LegacySlice from "./LegacySlice"
|
|
1
|
+
import type { CompositeSlice } from "./CompositeSlice"
|
|
2
|
+
import type { LegacySlice } from "./LegacySlice"
|
|
3
3
|
import type { SharedSlice } from "./SharedSlice"
|
|
4
|
-
import type SharedSliceRef from "./SharedSliceRef"
|
|
4
|
+
import type { SharedSliceRef } from "./SharedSliceRef"
|
|
5
5
|
|
|
6
6
|
export type DynamicSlice = CompositeSlice | LegacySlice | SharedSliceRef
|
|
7
7
|
export type StaticSlice = CompositeSlice | LegacySlice | SharedSlice
|
|
@@ -2,10 +2,10 @@ import * as t from "io-ts"
|
|
|
2
2
|
|
|
3
3
|
import { WidgetKey } from "../../../common"
|
|
4
4
|
import { StringOrNull } from "../../../validators"
|
|
5
|
-
import CompositeSlice from "./CompositeSlice"
|
|
6
|
-
import LegacySlice from "./LegacySlice"
|
|
5
|
+
import { CompositeSlice } from "./CompositeSlice"
|
|
6
|
+
import { LegacySlice } from "./LegacySlice"
|
|
7
7
|
import { SharedSlice } from "./SharedSlice"
|
|
8
|
-
import SharedSliceRef from "./SharedSliceRef"
|
|
8
|
+
import { SharedSliceRef } from "./SharedSliceRef"
|
|
9
9
|
|
|
10
10
|
export const LegacySlicesFieldType = "Choice"
|
|
11
11
|
export const SlicesFieldType = "Slices"
|
|
@@ -77,10 +77,10 @@ export function slicesReader<
|
|
|
77
77
|
return t.exact(
|
|
78
78
|
t.intersection([
|
|
79
79
|
t.type({
|
|
80
|
-
type: t.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
type: t.keyof({
|
|
81
|
+
[SlicesFieldType]: null,
|
|
82
|
+
[LegacySlicesFieldType]: null,
|
|
83
|
+
}),
|
|
84
84
|
}),
|
|
85
85
|
t.partial({
|
|
86
86
|
fieldset: StringOrNull,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from "./CompositeSlice"
|
|
2
|
+
export * from "./LegacySlice"
|
|
3
3
|
export * from "./SharedSlice"
|
|
4
|
-
export
|
|
5
|
-
export *
|
|
6
|
-
export *
|
|
7
|
-
export
|
|
4
|
+
export * from "./SharedSliceRef"
|
|
5
|
+
export * from "./Slice"
|
|
6
|
+
export * from "./Slices"
|
|
7
|
+
export * from "./SlicesTypes"
|