@prismicio/types-internal 4.0.0-pr.6.09bccf8 → 4.0.0-pr.6.38cb7de
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/dist/content/codec/document.js +1 -1
- package/dist/content/codec/legacyContentCtx.d.ts.map +1 -1
- package/dist/content/codec/legacyContentCtx.js.map +1 -1
- package/dist/content/codec/link.js +8 -8
- package/dist/content/codec/link.js.map +1 -1
- package/dist/content/codec/richText.js +2 -2
- package/dist/content/codec/richText.js.map +1 -1
- package/dist/content/codec/slice.js.map +1 -1
- package/dist/content/document.d.ts +2 -3019
- package/dist/content/document.d.ts.map +1 -1
- package/dist/content/field.d.ts +1 -30
- package/dist/content/field.d.ts.map +1 -1
- package/dist/content/field.js.map +1 -1
- package/dist/content/group.d.ts +2 -1
- package/dist/content/group.d.ts.map +1 -1
- package/dist/content/group.js.map +1 -1
- package/dist/content/legacy/boolean.d.ts +1 -0
- package/dist/content/legacy/embed.d.ts +1 -0
- package/dist/content/legacy/empty.d.ts +1 -0
- package/dist/content/legacy/field.d.ts +1 -0
- package/dist/content/legacy/geopoint.d.ts +1 -0
- package/dist/content/legacy/group.d.ts +9 -0
- package/dist/content/legacy/group.d.ts.map +1 -0
- package/dist/content/legacy/group.js.map +1 -1
- package/dist/content/legacy/integrationField.d.ts +1 -0
- package/dist/content/legacy/link.d.ts +41 -0
- package/dist/content/legacy/link.d.ts.map +1 -0
- package/dist/content/legacy/link.js.map +1 -1
- package/dist/content/legacy/nestable.d.ts +1 -0
- package/dist/content/legacy/nestable.js.map +1 -1
- package/dist/content/legacy/repeatable.d.ts +1 -0
- package/dist/content/legacy/richText.d.ts +109 -0
- package/dist/content/legacy/richText.d.ts.map +1 -0
- package/dist/content/legacy/richText.js +3 -3
- package/dist/content/legacy/richText.js.map +1 -1
- package/dist/content/legacy/separator.d.ts +1 -0
- package/dist/content/legacy/slice.js.map +1 -1
- package/dist/content/legacy/table.d.ts +1 -0
- package/dist/content/link.d.ts +74 -99
- package/dist/content/link.d.ts.map +1 -1
- package/dist/content/link.js +2 -2
- package/dist/content/link.js.map +1 -1
- package/dist/content/nestable.d.ts +13 -749
- package/dist/content/nestable.d.ts.map +1 -1
- package/dist/content/nestable.js.map +1 -1
- package/dist/content/repeatable.d.ts +3 -98
- package/dist/content/repeatable.d.ts.map +1 -1
- package/dist/content/richText.d.ts +81 -131
- package/dist/content/richText.d.ts.map +1 -1
- package/dist/content/richText.js +5 -4
- package/dist/content/richText.js.map +1 -1
- package/dist/content/slice.d.ts +6 -4509
- package/dist/content/slice.d.ts.map +1 -1
- package/dist/content/slice.js.map +1 -1
- package/dist/content/slices.d.ts +8 -6765
- package/dist/content/slices.d.ts.map +1 -1
- package/dist/content/slices.js +4 -4
- package/dist/content/slices.js.map +1 -1
- package/dist/content/table.d.ts +2 -134
- package/dist/content/table.d.ts.map +1 -1
- package/dist/content/widget.d.ts +5 -3020
- package/dist/content/widget.d.ts.map +1 -1
- package/dist/content/widget.js.map +1 -1
- package/dist/helpers/customTypeModel.d.ts +1 -1
- package/dist/helpers/customTypeModel.d.ts.map +1 -1
- package/dist/helpers/customTypeModel.js.map +1 -1
- package/dist/helpers/documentContent.d.ts +3 -9
- package/dist/helpers/documentContent.d.ts.map +1 -1
- package/dist/helpers/documentContent.js +5 -5
- package/dist/helpers/documentContent.js.map +1 -1
- package/dist/helpers/traverseContent.d.ts +16 -17
- package/dist/helpers/traverseContent.d.ts.map +1 -1
- package/dist/helpers/traverseContent.js +4 -4
- package/dist/helpers/traverseContent.js.map +1 -1
- package/dist/helpers/traverseContentWithModel.d.ts +16 -17
- package/dist/helpers/traverseContentWithModel.d.ts.map +1 -1
- package/dist/helpers/traverseContentWithModel.js +4 -4
- package/dist/helpers/traverseContentWithModel.js.map +1 -1
- package/dist/index.d.ts +26 -26
- package/dist/index.js +2 -1
- package/dist/io-ts.d.ts +3380 -67677
- package/dist/io-ts.d.ts.map +1 -1
- package/dist/io-ts.js +125 -119
- package/dist/io-ts.js.map +1 -1
- package/dist/model/customType.d.ts +3 -3329
- package/dist/model/customType.d.ts.map +1 -1
- package/dist/model/group.d.ts +391 -392
- package/dist/model/group.d.ts.map +1 -1
- package/dist/model/group.js.map +1 -1
- package/dist/model/image.d.ts +4 -4
- package/dist/model/image.js.map +1 -1
- package/dist/model/link.d.ts +18 -18
- package/dist/model/link.d.ts.map +1 -1
- package/dist/model/link.js +7 -7
- package/dist/model/link.js.map +1 -1
- package/dist/model/nestable.d.ts +17 -178
- package/dist/model/nestable.d.ts.map +1 -1
- package/dist/model/nestable.js +2 -2
- package/dist/model/nestable.js.map +1 -1
- package/dist/model/richText.d.ts +3 -7
- package/dist/model/richText.d.ts.map +1 -1
- package/dist/model/richText.js +4 -3
- package/dist/model/richText.js.map +1 -1
- package/dist/model/section.d.ts +3 -3329
- package/dist/model/section.d.ts.map +1 -1
- package/dist/model/select.d.ts +1 -1
- package/dist/model/select.js +1 -1
- package/dist/model/select.js.map +1 -1
- package/dist/model/slice.d.ts +861 -3800
- package/dist/model/slice.d.ts.map +1 -1
- package/dist/model/slice.js +7 -2
- package/dist/model/slice.js.map +1 -1
- package/dist/model/slices.d.ts +3 -2195
- package/dist/model/slices.d.ts.map +1 -1
- package/dist/model/table.d.ts +2 -1
- package/dist/model/table.d.ts.map +1 -1
- package/dist/model/table.js +9 -7
- package/dist/model/table.js.map +1 -1
- package/dist/model/widget.d.ts +6 -3331
- package/dist/model/widget.d.ts.map +1 -1
- package/dist/model/widget.js.map +1 -1
- package/dist/zod4.d.ts +1345 -32523
- package/dist/zod4.d.ts.map +1 -1
- package/dist/zod4.js +125 -119
- package/dist/zod4.js.map +1 -1
- package/package.json +3 -2
- package/src/content/codec/legacyContentCtx.ts +1 -0
- package/src/content/codec/link.ts +8 -8
- package/src/content/codec/richText.ts +10 -6
- package/src/content/codec/slice.ts +3 -1
- package/src/content/field.ts +9 -2
- package/src/content/group.ts +5 -2
- package/src/content/legacy/group.ts +10 -4
- package/src/content/legacy/link.ts +32 -9
- package/src/content/legacy/nestable.ts +26 -2
- package/src/content/legacy/richText.ts +40 -7
- package/src/content/legacy/slice.ts +2 -2
- package/src/content/legacy/widget.ts +6 -2
- package/src/content/link.ts +32 -9
- package/src/content/nestable.ts +40 -2
- package/src/content/richText.ts +31 -9
- package/src/content/slice.ts +2 -2
- package/src/content/slices.ts +5 -3
- package/src/content/widget.ts +6 -2
- package/src/helpers/customTypeModel.ts +6 -3
- package/src/helpers/documentContent.ts +24 -29
- package/src/helpers/traverseContent.ts +32 -27
- package/src/helpers/traverseContentWithModel.ts +35 -27
- package/src/index.ts +11 -3
- package/src/io-ts.ts +173 -134
- package/src/model/group.ts +4 -1
- package/src/model/image.ts +1 -1
- package/src/model/link.ts +39 -45
- package/src/model/nestable.ts +33 -1
- package/src/model/richText.ts +2 -2
- package/src/model/select.ts +2 -2
- package/src/model/slice.ts +36 -9
- package/src/model/table.ts +10 -2
- package/src/model/widget.ts +10 -9
- package/src/zod4.ts +168 -133
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
|
+
import type { NestableLegacy } from "./nestable"
|
|
3
4
|
import { NestableLegacySchema } from "./nestable"
|
|
4
5
|
|
|
5
6
|
export const GroupItemLegacySchema = z.record(z.string(), z.unknown())
|
|
6
7
|
|
|
7
8
|
export type GroupItemLegacy = z.infer<typeof GroupItemLegacySchema>
|
|
8
9
|
|
|
9
|
-
export const GroupLegacySchema = z.array(
|
|
10
|
+
export const GroupLegacySchema: z.ZodMiniType<GroupLegacy> = z.array(
|
|
11
|
+
z.union([GroupItemLegacySchema, z.null()]),
|
|
12
|
+
)
|
|
10
13
|
|
|
11
|
-
export type GroupLegacy =
|
|
14
|
+
export type GroupLegacy = (GroupItemLegacy | null)[]
|
|
12
15
|
|
|
13
|
-
export const NestableAndGroupLegacySchema = z.union([
|
|
16
|
+
export const NestableAndGroupLegacySchema: z.ZodMiniType<NestableAndGroupLegacy> = z.union([
|
|
17
|
+
NestableLegacySchema,
|
|
18
|
+
GroupLegacySchema,
|
|
19
|
+
])
|
|
14
20
|
|
|
15
|
-
export type NestableAndGroupLegacy =
|
|
21
|
+
export type NestableAndGroupLegacy = NestableLegacy | GroupLegacy
|
|
@@ -109,16 +109,24 @@ export const AnyLinkLegacySchema = z.strictObject({
|
|
|
109
109
|
|
|
110
110
|
// All
|
|
111
111
|
|
|
112
|
-
export const FilledLinkValueLegacySchema = z.union([
|
|
112
|
+
export const FilledLinkValueLegacySchema: z.ZodMiniType<FilledLinkValueLegacy> = z.union([
|
|
113
113
|
FilledImageLinkValueLegacySchema,
|
|
114
114
|
FilledFileLinkValueLegacySchema,
|
|
115
115
|
FilledDocumentLinkValueLegacySchema,
|
|
116
116
|
FilledExternalLinkValueLegacySchema,
|
|
117
117
|
])
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
type FilledImageLinkValueLegacy = z.infer<typeof FilledImageLinkValueLegacySchema>
|
|
120
|
+
type FilledFileLinkValueLegacy = z.infer<typeof FilledFileLinkValueLegacySchema>
|
|
121
|
+
type FilledDocumentLinkValueLegacy = z.infer<typeof FilledDocumentLinkValueLegacySchema>
|
|
122
|
+
type FilledExternalLinkValueLegacy = z.infer<typeof FilledExternalLinkValueLegacySchema>
|
|
123
|
+
export type FilledLinkValueLegacy =
|
|
124
|
+
| FilledImageLinkValueLegacy
|
|
125
|
+
| FilledFileLinkValueLegacy
|
|
126
|
+
| FilledDocumentLinkValueLegacy
|
|
127
|
+
| FilledExternalLinkValueLegacy
|
|
128
|
+
|
|
129
|
+
const EmptyLinkValueLegacySchema: z.ZodMiniType<EmptyLinkValueLegacy> = z.union([
|
|
122
130
|
EmptyImageLinkValueLegacySchema,
|
|
123
131
|
EmptyFileLinkValueLegacySchema,
|
|
124
132
|
EmptyMediaLinkValueLegacySchema,
|
|
@@ -127,11 +135,26 @@ const EmptyLinkValueLegacySchema = z.union([
|
|
|
127
135
|
AnyLinkLegacySchema,
|
|
128
136
|
])
|
|
129
137
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
138
|
+
type EmptyImageLinkValueLegacy = z.infer<typeof EmptyImageLinkValueLegacySchema>
|
|
139
|
+
type EmptyFileLinkValueLegacy = z.infer<typeof EmptyFileLinkValueLegacySchema>
|
|
140
|
+
type EmptyMediaLinkValueLegacy = z.infer<typeof EmptyMediaLinkValueLegacySchema>
|
|
141
|
+
type EmptyDocumentLinkValueLegacy = z.infer<typeof EmptyDocumentLinkValueLegacySchema>
|
|
142
|
+
type EmptyExternalLinkValueLegacy = z.infer<typeof EmptyExternalLinkValueLegacySchema>
|
|
143
|
+
type AnyLinkLegacy = z.infer<typeof AnyLinkLegacySchema>
|
|
144
|
+
export type EmptyLinkValueLegacy =
|
|
145
|
+
| EmptyImageLinkValueLegacy
|
|
146
|
+
| EmptyFileLinkValueLegacy
|
|
147
|
+
| EmptyMediaLinkValueLegacy
|
|
148
|
+
| EmptyDocumentLinkValueLegacy
|
|
149
|
+
| EmptyExternalLinkValueLegacy
|
|
150
|
+
| AnyLinkLegacy
|
|
151
|
+
|
|
152
|
+
const LinkValueLegacySchema: z.ZodMiniType<LinkValueLegacy> = z.union([
|
|
153
|
+
FilledLinkValueLegacySchema,
|
|
154
|
+
EmptyLinkValueLegacySchema,
|
|
155
|
+
])
|
|
133
156
|
|
|
134
|
-
export type LinkValueLegacy =
|
|
157
|
+
export type LinkValueLegacy = FilledLinkValueLegacy | EmptyLinkValueLegacy
|
|
135
158
|
|
|
136
159
|
// We cannot use z.extend here because we're working with unions.
|
|
137
160
|
// z.intersection wouldn't work also for the same reason.
|
|
@@ -157,7 +180,7 @@ export const LinkLegacySchema = z.pipe(
|
|
|
157
180
|
key: z.optional(z.string()),
|
|
158
181
|
text: z.optional(z.string()),
|
|
159
182
|
variant: z.optional(z.string()),
|
|
160
|
-
value: LinkValueLegacySchema,
|
|
183
|
+
value: LinkValueLegacySchema as z.ZodMiniType<LinkValueLegacy, Record<string, unknown>>,
|
|
161
184
|
}),
|
|
162
185
|
),
|
|
163
186
|
z.transform(({ key, text, variant, value }) => ({
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
|
+
import type { BooleanLegacy } from "./boolean"
|
|
3
4
|
import { BooleanLegacySchema } from "./boolean"
|
|
5
|
+
import type { EmbedLegacy } from "./embed"
|
|
4
6
|
import { EmbedLegacyLooseSchema } from "./embed"
|
|
7
|
+
import type { EmptyLegacy } from "./empty"
|
|
5
8
|
import { EmptyLegacySchema } from "./empty"
|
|
9
|
+
import type { StringLegacy} from "./field";
|
|
6
10
|
import { StringLegacySchema } from "./field"
|
|
11
|
+
import type { GeoPointLegacy } from "./geopoint"
|
|
7
12
|
import { GeoPointLegacySchema } from "./geopoint"
|
|
13
|
+
import type { ImageLegacy } from "./image"
|
|
8
14
|
import { ImageLegacySchema } from "./image"
|
|
15
|
+
import type { IntegrationFieldLegacy } from "./integrationField"
|
|
9
16
|
import { IntegrationFieldLegacySchema } from "./integrationField"
|
|
17
|
+
import type { LinkLegacy } from "./link"
|
|
10
18
|
import { LinkLegacySchema } from "./link"
|
|
19
|
+
import type { RepeatableLegacy } from "./repeatable"
|
|
11
20
|
import { RepeatableLegacySchema } from "./repeatable"
|
|
21
|
+
import type { RichTextLegacy } from "./richText"
|
|
12
22
|
import { RichTextLegacySchema } from "./richText"
|
|
23
|
+
import type { SeparatorLegacy } from "./separator"
|
|
13
24
|
import { SeparatorLegacySchema } from "./separator"
|
|
25
|
+
import type { TableLegacy } from "./table"
|
|
14
26
|
import { TableLegacySchema } from "./table"
|
|
15
27
|
|
|
16
|
-
export const NestableLegacySchema = z.union([
|
|
28
|
+
export const NestableLegacySchema: z.ZodMiniType<NestableLegacy> = z.union([
|
|
17
29
|
EmptyLegacySchema,
|
|
18
30
|
BooleanLegacySchema,
|
|
19
31
|
EmbedLegacyLooseSchema,
|
|
@@ -28,4 +40,16 @@ export const NestableLegacySchema = z.union([
|
|
|
28
40
|
TableLegacySchema,
|
|
29
41
|
])
|
|
30
42
|
|
|
31
|
-
export type NestableLegacy =
|
|
43
|
+
export type NestableLegacy =
|
|
44
|
+
| EmptyLegacy
|
|
45
|
+
| BooleanLegacy
|
|
46
|
+
| EmbedLegacy
|
|
47
|
+
| StringLegacy
|
|
48
|
+
| GeoPointLegacy
|
|
49
|
+
| ImageLegacy
|
|
50
|
+
| IntegrationFieldLegacy
|
|
51
|
+
| LinkLegacy
|
|
52
|
+
| RepeatableLegacy
|
|
53
|
+
| RichTextLegacy
|
|
54
|
+
| SeparatorLegacy
|
|
55
|
+
| TableLegacy
|
|
@@ -4,10 +4,11 @@ import { z } from "zod/mini"
|
|
|
4
4
|
// avoid runtime circular dependencies!
|
|
5
5
|
import type { EmbedContentSchema } from "../embed"
|
|
6
6
|
import type { ImageViewContentSchema } from "../image"
|
|
7
|
-
import type { FilledLinkValueContentSchema } from "../link"
|
|
7
|
+
import type { FilledLinkValueContent, FilledLinkValueContentSchema } from "../link"
|
|
8
8
|
import { EmbedLegacyLooseSchema } from "./embed"
|
|
9
9
|
import { ImageViewLegacySchema } from "./image"
|
|
10
10
|
import { FilledLinkValueLegacySchema } from "./link"
|
|
11
|
+
import type { FilledLinkValueLegacy } from "./link"
|
|
11
12
|
|
|
12
13
|
export const RichTextNodeType = {
|
|
13
14
|
paragraph: "paragraph",
|
|
@@ -28,6 +29,13 @@ export const RichTextNodeType = {
|
|
|
28
29
|
} as const
|
|
29
30
|
|
|
30
31
|
// Spans
|
|
32
|
+
type HyperlinkSpan<TData extends FilledLinkValueLegacy | FilledLinkValueContent> = {
|
|
33
|
+
type: typeof RichTextNodeType.hyperlink
|
|
34
|
+
start: number
|
|
35
|
+
end: number
|
|
36
|
+
data: TData
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
const getHyperlinkSpanSchema = <
|
|
32
40
|
TData extends typeof FilledLinkValueLegacySchema | typeof FilledLinkValueContentSchema,
|
|
33
41
|
>(
|
|
@@ -40,7 +48,14 @@ const getHyperlinkSpanSchema = <
|
|
|
40
48
|
data,
|
|
41
49
|
})
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
type LabelSpan = {
|
|
52
|
+
type: "label"
|
|
53
|
+
start: number
|
|
54
|
+
end: number
|
|
55
|
+
data: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const LabelSpanSchema: z.ZodMiniType<LabelSpan> = z.object({
|
|
44
59
|
type: z.literal("label"),
|
|
45
60
|
start: z.number(),
|
|
46
61
|
end: z.number(),
|
|
@@ -50,7 +65,13 @@ const LabelSpanSchema = z.object({
|
|
|
50
65
|
),
|
|
51
66
|
})
|
|
52
67
|
|
|
53
|
-
|
|
68
|
+
type BasicSpan = {
|
|
69
|
+
type: typeof RichTextNodeType.strong | typeof RichTextNodeType.em | "list-item"
|
|
70
|
+
start: number
|
|
71
|
+
end: number
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const BasicSpanSchema: z.ZodMiniType<BasicSpan> = z.object({
|
|
54
75
|
type: z.union([
|
|
55
76
|
z.literal(RichTextNodeType.strong),
|
|
56
77
|
z.literal(RichTextNodeType.em),
|
|
@@ -60,7 +81,13 @@ const BasicSpanSchema = z.object({
|
|
|
60
81
|
end: z.number(),
|
|
61
82
|
})
|
|
62
83
|
|
|
63
|
-
|
|
84
|
+
export type Span<TLink extends FilledLinkValueLegacy | FilledLinkValueContent> =
|
|
85
|
+
| HyperlinkSpan<TLink>
|
|
86
|
+
| LabelSpan
|
|
87
|
+
| BasicSpan
|
|
88
|
+
|
|
89
|
+
// oxlint-disable-next-line explicit-module-boundary-types
|
|
90
|
+
export const getSpanSchema = <
|
|
64
91
|
TLinkSchema extends typeof FilledLinkValueLegacySchema | typeof FilledLinkValueContentSchema,
|
|
65
92
|
>(
|
|
66
93
|
linkSchema: TLinkSchema,
|
|
@@ -113,6 +140,8 @@ export const getTextBlockSchema = <
|
|
|
113
140
|
|
|
114
141
|
const TextBlockLegacySchema = getTextBlockSchema(FilledLinkValueLegacySchema)
|
|
115
142
|
|
|
143
|
+
type TextBlockLegacy = z.infer<typeof TextBlockLegacySchema>
|
|
144
|
+
|
|
116
145
|
// Image block
|
|
117
146
|
|
|
118
147
|
// oxlint-disable-next-line explicit-module-boundary-types
|
|
@@ -135,6 +164,8 @@ const ImageBlockLegacySchema = getImageBlockSchema(
|
|
|
135
164
|
FilledLinkValueLegacySchema,
|
|
136
165
|
)
|
|
137
166
|
|
|
167
|
+
type ImageBlockLegacy = z.infer<typeof ImageBlockLegacySchema>
|
|
168
|
+
|
|
138
169
|
// Embed block
|
|
139
170
|
// oxlint-disable-next-line explicit-module-boundary-types
|
|
140
171
|
export const getEmbedBlockSchema = <
|
|
@@ -151,15 +182,17 @@ export const getEmbedBlockSchema = <
|
|
|
151
182
|
|
|
152
183
|
const EmbedBlockLegacySchema = getEmbedBlockSchema(EmbedLegacyLooseSchema)
|
|
153
184
|
|
|
185
|
+
type EmbedBlockLegacy = z.infer<typeof EmbedBlockLegacySchema>
|
|
186
|
+
|
|
154
187
|
// Blocks
|
|
155
|
-
export const
|
|
188
|
+
export const RichTextLegacyBlockSchema: z.ZodMiniType<RichTextLegacyBlock> = z.union([
|
|
156
189
|
TextBlockLegacySchema,
|
|
157
190
|
ImageBlockLegacySchema,
|
|
158
191
|
EmbedBlockLegacySchema,
|
|
159
192
|
])
|
|
160
193
|
|
|
161
|
-
export type
|
|
194
|
+
export type RichTextLegacyBlock = TextBlockLegacy | ImageBlockLegacy | EmbedBlockLegacy
|
|
162
195
|
|
|
163
|
-
export const RichTextLegacySchema = z.array(
|
|
196
|
+
export const RichTextLegacySchema = z.array(RichTextLegacyBlockSchema)
|
|
164
197
|
|
|
165
198
|
export type RichTextLegacy = z.infer<typeof RichTextLegacySchema>
|
|
@@ -28,10 +28,10 @@ export const SharedSliceLegacySchema = z.object({
|
|
|
28
28
|
export type SharedSliceLegacy = z.infer<typeof SharedSliceLegacySchema>
|
|
29
29
|
|
|
30
30
|
// All
|
|
31
|
-
export const SliceLegacySchema = z.union([
|
|
31
|
+
export const SliceLegacySchema: z.ZodMiniType<SliceLegacy> = z.union([
|
|
32
32
|
LegacySliceLegacySchema,
|
|
33
33
|
CompositeSliceLegacySchema,
|
|
34
34
|
SharedSliceLegacySchema,
|
|
35
35
|
])
|
|
36
36
|
|
|
37
|
-
export type SliceLegacy =
|
|
37
|
+
export type SliceLegacy = LegacySliceLegacy | CompositeSliceLegacy | SharedSliceLegacy
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
|
+
import type { GroupLegacy } from "./group"
|
|
3
4
|
import { GroupLegacySchema } from "./group"
|
|
5
|
+
import type { NestableLegacy } from "./nestable"
|
|
4
6
|
import { NestableLegacySchema } from "./nestable"
|
|
7
|
+
import type { SlicesLegacy } from "./slices"
|
|
5
8
|
import { SlicesLegacySchema } from "./slices"
|
|
9
|
+
import type { UIDLegacy } from "./uid"
|
|
6
10
|
import { UIDLegacySchema } from "./uid"
|
|
7
11
|
|
|
8
|
-
export const WidgetLegacySchema = z.union([
|
|
12
|
+
export const WidgetLegacySchema: z.ZodMiniType<WidgetLegacy> = z.union([
|
|
9
13
|
UIDLegacySchema,
|
|
10
14
|
GroupLegacySchema,
|
|
11
15
|
SlicesLegacySchema,
|
|
12
16
|
NestableLegacySchema,
|
|
13
17
|
])
|
|
14
18
|
|
|
15
|
-
export type WidgetLegacy =
|
|
19
|
+
export type WidgetLegacy = UIDLegacy | GroupLegacy | SlicesLegacy | NestableLegacy
|
package/src/content/link.ts
CHANGED
|
@@ -63,7 +63,7 @@ const AnyLinkValueContentSchema = z.extend(AnyLinkLegacySchema, {
|
|
|
63
63
|
// All
|
|
64
64
|
|
|
65
65
|
// Used by content/richText
|
|
66
|
-
export const FilledLinkValueContentSchema = z.union([
|
|
66
|
+
export const FilledLinkValueContentSchema: z.ZodMiniType<FilledLinkValueContent> = z.union([
|
|
67
67
|
FilledImageLinkValueContentSchema,
|
|
68
68
|
FilledFileLinkValueContentSchema,
|
|
69
69
|
FilledDocumentLinkValueContentSchema,
|
|
@@ -71,9 +71,17 @@ export const FilledLinkValueContentSchema = z.union([
|
|
|
71
71
|
])
|
|
72
72
|
|
|
73
73
|
// Used by content/legacy/link
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
type FilledImageLinkValueContent = z.infer<typeof FilledImageLinkValueContentSchema>
|
|
75
|
+
type FilledFileLinkValueContent = z.infer<typeof FilledFileLinkValueContentSchema>
|
|
76
|
+
type FilledDocumentLinkValueContent = z.infer<typeof FilledDocumentLinkValueContentSchema>
|
|
77
|
+
type FilledExternalLinkValueContent = z.infer<typeof FilledExternalLinkValueContentSchema>
|
|
78
|
+
export type FilledLinkValueContent =
|
|
79
|
+
| FilledImageLinkValueContent
|
|
80
|
+
| FilledFileLinkValueContent
|
|
81
|
+
| FilledDocumentLinkValueContent
|
|
82
|
+
| FilledExternalLinkValueContent
|
|
83
|
+
|
|
84
|
+
const EmptyLinkValueContentSchema: z.ZodMiniType<EmptyLinkValueContent> = z.union([
|
|
77
85
|
EmptyImageLinkValueContentSchema,
|
|
78
86
|
EmptyFileLinkValueContentSchema,
|
|
79
87
|
EmptyMediaLinkValueContentSchema,
|
|
@@ -83,12 +91,27 @@ const EmptyLinkValueContentSchema = z.union([
|
|
|
83
91
|
])
|
|
84
92
|
|
|
85
93
|
// Used by content/codec/link
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
type EmptyImageLinkValueContent = z.infer<typeof EmptyImageLinkValueContentSchema>
|
|
95
|
+
type EmptyFileLinkValueContent = z.infer<typeof EmptyFileLinkValueContentSchema>
|
|
96
|
+
type EmptyMediaLinkValueContent = z.infer<typeof EmptyMediaLinkValueContentSchema>
|
|
97
|
+
type EmptyDocumentLinkValueContent = z.infer<typeof EmptyDocumentLinkValueContentSchema>
|
|
98
|
+
type EmptyExternalLinkValueContent = z.infer<typeof EmptyExternalLinkValueContentSchema>
|
|
99
|
+
type AnyLinkValueContent = z.infer<typeof AnyLinkValueContentSchema>
|
|
100
|
+
export type EmptyLinkValueContent =
|
|
101
|
+
| EmptyImageLinkValueContent
|
|
102
|
+
| EmptyFileLinkValueContent
|
|
103
|
+
| EmptyMediaLinkValueContent
|
|
104
|
+
| EmptyDocumentLinkValueContent
|
|
105
|
+
| EmptyExternalLinkValueContent
|
|
106
|
+
| AnyLinkValueContent
|
|
107
|
+
|
|
108
|
+
const LinkValueContentSchema: z.ZodMiniType<LinkValueContent> = z.union([
|
|
109
|
+
FilledLinkValueContentSchema,
|
|
110
|
+
EmptyLinkValueContentSchema,
|
|
111
|
+
])
|
|
89
112
|
|
|
90
113
|
// Used by content/codec/link
|
|
91
|
-
export type LinkValueContent =
|
|
114
|
+
export type LinkValueContent = FilledLinkValueContent | EmptyLinkValueContent
|
|
92
115
|
|
|
93
116
|
// Content
|
|
94
117
|
export const LinkContentType = "LinkContent" as const
|
|
@@ -117,7 +140,7 @@ export const LinkContentSchema = z.object({
|
|
|
117
140
|
z.object({
|
|
118
141
|
text: z.optional(z.string()),
|
|
119
142
|
variant: z.optional(z.string()),
|
|
120
|
-
value: z.
|
|
143
|
+
value: LinkValueContentSchema as z.ZodMiniType<LinkValueContent, Record<string, unknown>>,
|
|
121
144
|
}),
|
|
122
145
|
),
|
|
123
146
|
z.transform(({ text, variant, value }) => ({
|
package/src/content/nestable.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
3
|
import type { NestableModel } from "../model/nestable"
|
|
4
|
+
import type { BooleanContent } from "./boolean"
|
|
4
5
|
import { BooleanContentDefaultValue, BooleanContentSchema, BooleanContentType } from "./boolean"
|
|
6
|
+
import type { EmbedContent } from "./embed"
|
|
5
7
|
import { EmbedContentSchema, EmbedContentType } from "./embed"
|
|
8
|
+
import type { EmptyContent } from "./empty"
|
|
6
9
|
import { EmptyContentSchema, EmptyContentType } from "./empty"
|
|
10
|
+
import type {
|
|
11
|
+
ColorContent,
|
|
12
|
+
DateContent,
|
|
13
|
+
NumberContent,
|
|
14
|
+
RangeContent,
|
|
15
|
+
SelectContent,
|
|
16
|
+
TextContent,
|
|
17
|
+
TimestampContent,
|
|
18
|
+
} from "./field"
|
|
7
19
|
import {
|
|
8
20
|
ColorContentSchema,
|
|
9
21
|
DateContentSchema,
|
|
@@ -15,16 +27,24 @@ import {
|
|
|
15
27
|
TextContentSchema,
|
|
16
28
|
TimestampContentSchema,
|
|
17
29
|
} from "./field"
|
|
30
|
+
import type { GeoPointContent } from "./geopoint"
|
|
18
31
|
import { GeoPointContentSchema, GeoPointContentType } from "./geopoint"
|
|
32
|
+
import type { ImageContent } from "./image"
|
|
19
33
|
import { ImageContentSchema, ImageContentType } from "./image"
|
|
34
|
+
import type { IntegrationFieldContent } from "./integrationField"
|
|
20
35
|
import { IntegrationFieldContentSchema, IntegrationFieldContentType } from "./integrationField"
|
|
36
|
+
import type { LinkContent } from "./link"
|
|
21
37
|
import { LinkContentSchema, LinkContentType } from "./link"
|
|
38
|
+
import type { RepeatableContent } from "./repeatable"
|
|
22
39
|
import { RepeatableContentSchema, RepeatableContentType } from "./repeatable"
|
|
40
|
+
import type { RichTextContent } from "./richText"
|
|
23
41
|
import { RichTextContentSchema, RichTextContentType } from "./richText"
|
|
42
|
+
import type { SeparatorContent } from "./separator"
|
|
24
43
|
import { SeparatorContentSchema, SeparatorContentType } from "./separator"
|
|
44
|
+
import type { TableContent } from "./table"
|
|
25
45
|
import { TableContentSchema, TableContentType } from "./table"
|
|
26
46
|
|
|
27
|
-
export const NestableContentSchema = z.union([
|
|
47
|
+
export const NestableContentSchema: z.ZodMiniType<NestableContent> = z.union([
|
|
28
48
|
EmptyContentSchema,
|
|
29
49
|
BooleanContentSchema,
|
|
30
50
|
ColorContentSchema,
|
|
@@ -45,7 +65,25 @@ export const NestableContentSchema = z.union([
|
|
|
45
65
|
TimestampContentSchema,
|
|
46
66
|
])
|
|
47
67
|
|
|
48
|
-
export type NestableContent =
|
|
68
|
+
export type NestableContent =
|
|
69
|
+
| EmptyContent
|
|
70
|
+
| BooleanContent
|
|
71
|
+
| ColorContent
|
|
72
|
+
| DateContent
|
|
73
|
+
| EmbedContent
|
|
74
|
+
| GeoPointContent
|
|
75
|
+
| ImageContent
|
|
76
|
+
| IntegrationFieldContent
|
|
77
|
+
| LinkContent
|
|
78
|
+
| NumberContent
|
|
79
|
+
| RangeContent
|
|
80
|
+
| RepeatableContent
|
|
81
|
+
| RichTextContent
|
|
82
|
+
| SelectContent
|
|
83
|
+
| SeparatorContent
|
|
84
|
+
| TableContent
|
|
85
|
+
| TextContent
|
|
86
|
+
| TimestampContent
|
|
49
87
|
|
|
50
88
|
const NestableContentTypes = [
|
|
51
89
|
EmptyContentType,
|
package/src/content/richText.ts
CHANGED
|
@@ -2,31 +2,53 @@ import { z } from "zod/mini"
|
|
|
2
2
|
|
|
3
3
|
import { EmbedContentSchema } from "./embed"
|
|
4
4
|
import { ImageViewContentSchema } from "./image"
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getEmbedBlockSchema,
|
|
7
|
+
getImageBlockSchema,
|
|
8
|
+
getSpanSchema,
|
|
9
|
+
getTextBlockSchema,
|
|
10
|
+
} from "./legacy/richText"
|
|
11
|
+
import type { Span } from "./legacy/richText"
|
|
12
|
+
import type { FilledLinkValueContent } from "./link"
|
|
6
13
|
import { FilledLinkValueContentSchema } from "./link"
|
|
7
14
|
|
|
15
|
+
// Spans
|
|
16
|
+
export type RichTextContentSpan = Span<FilledLinkValueContent>
|
|
17
|
+
|
|
18
|
+
export const RichTextContentSpanSchema: z.ZodMiniType<RichTextContentSpan> = getSpanSchema(
|
|
19
|
+
FilledLinkValueContentSchema,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
// Blocks
|
|
8
23
|
const TextBlockValueSchema = getTextBlockSchema(FilledLinkValueContentSchema)
|
|
24
|
+
type TextBlockValue = z.infer<typeof TextBlockValueSchema>
|
|
25
|
+
|
|
9
26
|
const ImageBlockValueSchema = getImageBlockSchema(
|
|
10
27
|
ImageViewContentSchema,
|
|
11
28
|
FilledLinkValueContentSchema,
|
|
12
29
|
)
|
|
30
|
+
type ImageBlockValue = z.infer<typeof ImageBlockValueSchema>
|
|
31
|
+
|
|
13
32
|
const EmbedBlockValueSchema = getEmbedBlockSchema(EmbedContentSchema)
|
|
33
|
+
type EmbedBlockValue = z.infer<typeof EmbedBlockValueSchema>
|
|
14
34
|
|
|
15
|
-
|
|
16
|
-
const BlockValueSchema = z.union([
|
|
35
|
+
export const RichTextContentBlockSchema: z.ZodMiniType<RichTextContentBlock> = z.union([
|
|
17
36
|
TextBlockValueSchema,
|
|
18
37
|
ImageBlockValueSchema,
|
|
19
38
|
EmbedBlockValueSchema,
|
|
20
39
|
])
|
|
21
40
|
|
|
22
|
-
// Used by content/richText
|
|
23
|
-
export type
|
|
41
|
+
// Used by content/codec/richText
|
|
42
|
+
export type RichTextContentBlock = TextBlockValue | ImageBlockValue | EmbedBlockValue
|
|
24
43
|
|
|
25
44
|
export const RichTextContentType = "StructuredTextContent" as const
|
|
26
45
|
|
|
27
|
-
export
|
|
46
|
+
export type RichTextContent = {
|
|
47
|
+
__TYPE__: typeof RichTextContentType
|
|
48
|
+
value: RichTextContentBlock[]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const RichTextContentSchema: z.ZodMiniType<RichTextContent> = z.object({
|
|
28
52
|
__TYPE__: z.literal(RichTextContentType),
|
|
29
|
-
value: z.array(
|
|
53
|
+
value: z.array(RichTextContentBlockSchema),
|
|
30
54
|
})
|
|
31
|
-
|
|
32
|
-
export type RichTextContent = z.infer<typeof RichTextContentSchema>
|
package/src/content/slice.ts
CHANGED
|
@@ -32,10 +32,10 @@ export const SharedSliceContentSchema = z.object({
|
|
|
32
32
|
export type SharedSliceContent = z.infer<typeof SharedSliceContentSchema>
|
|
33
33
|
|
|
34
34
|
// All
|
|
35
|
-
export const SliceContentSchema = z.union([
|
|
35
|
+
export const SliceContentSchema: z.ZodMiniType<SliceContent> = z.union([
|
|
36
36
|
LegacySliceContentSchema,
|
|
37
37
|
CompositeSliceContentSchema,
|
|
38
38
|
SharedSliceContentSchema,
|
|
39
39
|
])
|
|
40
40
|
|
|
41
|
-
export type SliceContent =
|
|
41
|
+
export type SliceContent = LegacySliceContent | CompositeSliceContent | SharedSliceContent
|
package/src/content/slices.ts
CHANGED
|
@@ -25,15 +25,17 @@ const getSliceItemContentSchema = <
|
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const LegacySliceItemContentSchema = getSliceItemContentSchema(LegacySliceContentSchema)
|
|
28
|
+
export const LegacySliceItemContentSchema = getSliceItemContentSchema(LegacySliceContentSchema)
|
|
29
29
|
|
|
30
30
|
export type LegacySliceItemContent = z.infer<typeof LegacySliceItemContentSchema>
|
|
31
31
|
|
|
32
|
-
const CompositeSliceItemContentSchema = getSliceItemContentSchema(
|
|
32
|
+
export const CompositeSliceItemContentSchema = getSliceItemContentSchema(
|
|
33
|
+
CompositeSliceContentSchema,
|
|
34
|
+
)
|
|
33
35
|
|
|
34
36
|
export type CompositeSliceItemContent = z.infer<typeof CompositeSliceItemContentSchema>
|
|
35
37
|
|
|
36
|
-
const SharedSliceItemContentSchema = getSliceItemContentSchema(SharedSliceContentSchema)
|
|
38
|
+
export const SharedSliceItemContentSchema = getSliceItemContentSchema(SharedSliceContentSchema)
|
|
37
39
|
|
|
38
40
|
export type SharedSliceItemContent = z.infer<typeof SharedSliceItemContentSchema>
|
|
39
41
|
|
package/src/content/widget.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
|
+
import type { GroupContent } from "./group"
|
|
3
4
|
import { GroupContentSchema } from "./group"
|
|
5
|
+
import type { NestableContent } from "./nestable"
|
|
4
6
|
import { NestableContentSchema } from "./nestable"
|
|
7
|
+
import type { SlicesContent } from "./slices"
|
|
5
8
|
import { SlicesContentSchema } from "./slices"
|
|
9
|
+
import type { UIDContent } from "./uid"
|
|
6
10
|
import { UIDContentSchema } from "./uid"
|
|
7
11
|
|
|
8
|
-
export const WidgetContentSchema = z.union([
|
|
12
|
+
export const WidgetContentSchema: z.ZodMiniType<WidgetContent> = z.union([
|
|
9
13
|
GroupContentSchema,
|
|
10
14
|
NestableContentSchema,
|
|
11
15
|
UIDContentSchema,
|
|
12
16
|
SlicesContentSchema,
|
|
13
17
|
])
|
|
14
18
|
|
|
15
|
-
export type WidgetContent =
|
|
19
|
+
export type WidgetContent = GroupContent | NestableContent | UIDContent | SlicesContent
|
|
16
20
|
|
|
17
21
|
export type ContentType = WidgetContent["__TYPE__"]
|
|
@@ -8,7 +8,8 @@ export function toStatic(
|
|
|
8
8
|
): StaticCustomTypeModel {
|
|
9
9
|
const json: StaticCustomTypeModel["json"] = {}
|
|
10
10
|
|
|
11
|
-
const sharedSlicesMap =
|
|
11
|
+
const sharedSlicesMap =
|
|
12
|
+
sharedSlices instanceof Map ? sharedSlices : new Map(Object.entries(sharedSlices))
|
|
12
13
|
|
|
13
14
|
for (const [tabKey, tab] of Object.entries(customType.json)) {
|
|
14
15
|
const tabJSON: StaticCustomTypeModel["json"][string] = {}
|
|
@@ -30,7 +31,7 @@ export function toStatic(
|
|
|
30
31
|
|
|
31
32
|
tabJSON[key] = {
|
|
32
33
|
...widget,
|
|
33
|
-
config: { ...widget.config, choices }
|
|
34
|
+
config: { ...widget.config, choices },
|
|
34
35
|
}
|
|
35
36
|
break
|
|
36
37
|
default:
|
|
@@ -48,7 +49,9 @@ export function flatten(customType: StaticCustomTypeModel): StaticSectionModel {
|
|
|
48
49
|
return Object.values(customType.json).reduce((acc, fields) => ({ ...acc, ...fields }), {})
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
export function collectSharedSlices(
|
|
52
|
+
export function collectSharedSlices(
|
|
53
|
+
customType: StaticCustomTypeModel,
|
|
54
|
+
): Record<string, SharedSliceModel> {
|
|
52
55
|
const sharedSlices: Record<string, SharedSliceModel> = {}
|
|
53
56
|
|
|
54
57
|
const flattened = flatten(customType)
|