@prismicio/types-internal 4.0.0-pr.6.0ddf815 → 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/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/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/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/documentContent.d.ts +3 -9
- package/dist/helpers/documentContent.d.ts.map +1 -1
- package/dist/helpers/documentContent.js +4 -4
- package/dist/helpers/documentContent.js.map +1 -1
- package/dist/helpers/traverseContent.d.ts +10 -11
- package/dist/helpers/traverseContent.d.ts.map +1 -1
- package/dist/helpers/traverseContent.js +1 -1
- package/dist/helpers/traverseContent.js.map +1 -1
- package/dist/helpers/traverseContentWithModel.d.ts +10 -11
- package/dist/helpers/traverseContentWithModel.d.ts.map +1 -1
- package/dist/helpers/traverseContentWithModel.js +1 -1
- package/dist/helpers/traverseContentWithModel.js.map +1 -1
- package/dist/index.d.ts +25 -25
- package/dist/index.js +2 -1
- package/dist/io-ts.d.ts +3380 -70926
- package/dist/io-ts.d.ts.map +1 -1
- package/dist/io-ts.js +125 -122
- 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 +3 -3
- 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 -34797
- package/dist/zod4.d.ts.map +1 -1
- package/dist/zod4.js +125 -122
- package/dist/zod4.js.map +1 -1
- package/package.json +3 -2
- package/src/content/codec/link.ts +8 -8
- package/src/content/codec/richText.ts +10 -6
- 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/widget.ts +6 -2
- package/src/helpers/documentContent.ts +13 -16
- package/src/helpers/traverseContent.ts +12 -19
- package/src/helpers/traverseContentWithModel.ts +10 -16
- package/src/index.ts +4 -2
- package/src/io-ts.ts +166 -140
- 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 +8 -4
- package/src/zod4.ts +166 -140
package/src/model/link.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { z } from "zod/mini"
|
|
|
3
3
|
// Accepts string | string[], normalizes string to [string]
|
|
4
4
|
const MasksArrayStringSchema = z.pipe(
|
|
5
5
|
z.union([z.array(z.string()), z.string()]),
|
|
6
|
-
z.transform((val):
|
|
6
|
+
z.transform((val): string[] => (typeof val === "string" ? [val] : val)),
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
// --- CustomTypes hierarchy (field selection in content relationship fields) ---
|
|
@@ -15,9 +15,7 @@ const noDuplicateStrings = z.refine(
|
|
|
15
15
|
"Fields have duplicates.",
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
const CustomTypeLevel2FieldGroupFieldsSchema = z.
|
|
19
|
-
z.array(z.string()).check(noDuplicateStrings),
|
|
20
|
-
)
|
|
18
|
+
const CustomTypeLevel2FieldGroupFieldsSchema = z.array(z.string()).check(noDuplicateStrings)
|
|
21
19
|
|
|
22
20
|
const CustomTypeLevel2FieldSchema = z.union([
|
|
23
21
|
z.object({ id: z.string(), fields: CustomTypeLevel2FieldGroupFieldsSchema }),
|
|
@@ -30,18 +28,18 @@ const noDuplicateIds = (items: unknown) => {
|
|
|
30
28
|
return ids.size === arr.length
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
const CustomTypeLevel2FieldsSchema = z
|
|
34
|
-
|
|
35
|
-
)
|
|
31
|
+
const CustomTypeLevel2FieldsSchema = z
|
|
32
|
+
.array(CustomTypeLevel2FieldSchema)
|
|
33
|
+
.check(z.refine(noDuplicateIds, "Fields have duplicates."))
|
|
36
34
|
|
|
37
35
|
const CustomTypeLevel2Schema = z.union([
|
|
38
36
|
z.string(),
|
|
39
37
|
z.object({ id: z.string(), fields: CustomTypeLevel2FieldsSchema }),
|
|
40
38
|
])
|
|
41
39
|
|
|
42
|
-
const CustomTypesLevel2Schema = z
|
|
43
|
-
|
|
44
|
-
)
|
|
40
|
+
const CustomTypesLevel2Schema = z
|
|
41
|
+
.array(CustomTypeLevel2Schema)
|
|
42
|
+
.check(z.refine(noDuplicateIds, "Custom types have duplicates."))
|
|
45
43
|
|
|
46
44
|
// Level 1
|
|
47
45
|
|
|
@@ -55,11 +53,9 @@ const CustomTypeLevel1FieldGroupFieldSchema = z.union([
|
|
|
55
53
|
z.string(),
|
|
56
54
|
])
|
|
57
55
|
|
|
58
|
-
const CustomTypeLevel1FieldGroupFieldsSchema = z
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.check(z.refine(noDuplicateIds, "Fields have duplicates.")),
|
|
62
|
-
)
|
|
56
|
+
const CustomTypeLevel1FieldGroupFieldsSchema = z
|
|
57
|
+
.array(CustomTypeLevel1FieldGroupFieldSchema)
|
|
58
|
+
.check(z.refine(noDuplicateIds, "Fields have duplicates."))
|
|
63
59
|
|
|
64
60
|
const CustomTypeLevel1FieldSchema = z.union([
|
|
65
61
|
z.object({
|
|
@@ -70,45 +66,43 @@ const CustomTypeLevel1FieldSchema = z.union([
|
|
|
70
66
|
z.string(),
|
|
71
67
|
])
|
|
72
68
|
|
|
73
|
-
const CustomTypeLevel1FieldsSchema = z
|
|
74
|
-
|
|
75
|
-
)
|
|
69
|
+
const CustomTypeLevel1FieldsSchema = z
|
|
70
|
+
.array(CustomTypeLevel1FieldSchema)
|
|
71
|
+
.check(z.refine(noDuplicateIds, "Fields have duplicates."))
|
|
76
72
|
|
|
77
73
|
const CustomTypeLevel1Schema = z.union([
|
|
78
74
|
z.string(),
|
|
79
75
|
z.object({ id: z.string(), fields: CustomTypeLevel1FieldsSchema }),
|
|
80
76
|
])
|
|
81
77
|
|
|
82
|
-
const CustomTypesSchema = z.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
objects.add(id)
|
|
97
|
-
}
|
|
98
|
-
if (failed) {
|
|
99
|
-
push("Custom types have duplicates.")
|
|
100
|
-
return
|
|
101
|
-
}
|
|
78
|
+
const CustomTypesSchema = z.array(CustomTypeLevel1Schema).check(({ value, issues }) => {
|
|
79
|
+
const cts = value as ({ id: string } | string)[]
|
|
80
|
+
const push = (message: string) => issues.push({ code: "custom", input: value, message })
|
|
81
|
+
const strings = new Set<string>()
|
|
82
|
+
const objects = new Set<string>()
|
|
83
|
+
for (const ct of cts) {
|
|
84
|
+
let failed = false
|
|
85
|
+
if (typeof ct === "string") {
|
|
86
|
+
failed = objects.has(ct)
|
|
87
|
+
strings.add(ct)
|
|
88
|
+
} else {
|
|
89
|
+
const { id } = ct
|
|
90
|
+
failed = strings.has(id) || objects.has(id)
|
|
91
|
+
objects.add(id)
|
|
102
92
|
}
|
|
103
|
-
if (
|
|
104
|
-
push("
|
|
93
|
+
if (failed) {
|
|
94
|
+
push("Custom types have duplicates.")
|
|
105
95
|
return
|
|
106
96
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
97
|
+
}
|
|
98
|
+
if (objects.size > 1) {
|
|
99
|
+
push("Cannot have multiple custom types with fields selection.")
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
if (strings.size > 0 && objects.size > 0) {
|
|
103
|
+
push("Cannot mix custom types as strings and objects with fields.")
|
|
104
|
+
}
|
|
105
|
+
})
|
|
112
106
|
|
|
113
107
|
// --- Select with fallback to null ---
|
|
114
108
|
|
package/src/model/nestable.ts
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
|
+
import type { BooleanModel } from "./boolean"
|
|
3
4
|
import { BooleanModelSchema } from "./boolean"
|
|
5
|
+
import type { ColorModel } from "./color"
|
|
4
6
|
import { ColorModelSchema } from "./color"
|
|
7
|
+
import type { DateModel } from "./date"
|
|
5
8
|
import { DateModelSchema } from "./date"
|
|
9
|
+
import type { EmbedModel } from "./embed"
|
|
6
10
|
import { EmbedModelSchema } from "./embed"
|
|
11
|
+
import type { GeoPointModel } from "./geopoint"
|
|
7
12
|
import { GeoPointModelSchema } from "./geopoint"
|
|
13
|
+
import type { ImageModel } from "./image"
|
|
8
14
|
import { ImageModelSchema } from "./image"
|
|
15
|
+
import type { IntegrationFieldModel } from "./integrationField"
|
|
9
16
|
import { IntegrationFieldModelSchema } from "./integrationField"
|
|
17
|
+
import type { LinkModel } from "./link"
|
|
10
18
|
import { LinkModelSchema } from "./link"
|
|
19
|
+
import type { NumberModel } from "./number"
|
|
11
20
|
import { NumberModelSchema } from "./number"
|
|
21
|
+
import type { RangeModel } from "./range"
|
|
12
22
|
import { RangeModelSchema } from "./range"
|
|
23
|
+
import type { RichTextModel } from "./richText"
|
|
13
24
|
import { RichTextModelSchema } from "./richText"
|
|
25
|
+
import type { SelectModel } from "./select"
|
|
14
26
|
import { SelectModelSchema } from "./select"
|
|
27
|
+
import type { SeparatorModel } from "./separator"
|
|
15
28
|
import { SeparatorModelSchema } from "./separator"
|
|
29
|
+
import type { TableModel } from "./table"
|
|
16
30
|
import { TableModelSchema } from "./table"
|
|
31
|
+
import type { TextModel } from "./text"
|
|
17
32
|
import { TextModelSchema } from "./text"
|
|
33
|
+
import type { TimestampModel } from "./timestamp"
|
|
18
34
|
import { TimestampModelSchema } from "./timestamp"
|
|
19
35
|
|
|
20
36
|
export const NestableModelSchema = z.union([
|
|
@@ -36,4 +52,20 @@ export const NestableModelSchema = z.union([
|
|
|
36
52
|
TimestampModelSchema,
|
|
37
53
|
])
|
|
38
54
|
|
|
39
|
-
export type NestableModel =
|
|
55
|
+
export type NestableModel =
|
|
56
|
+
| BooleanModel
|
|
57
|
+
| ColorModel
|
|
58
|
+
| DateModel
|
|
59
|
+
| EmbedModel
|
|
60
|
+
| GeoPointModel
|
|
61
|
+
| ImageModel
|
|
62
|
+
| IntegrationFieldModel
|
|
63
|
+
| LinkModel
|
|
64
|
+
| NumberModel
|
|
65
|
+
| RangeModel
|
|
66
|
+
| RichTextModel
|
|
67
|
+
| SelectModel
|
|
68
|
+
| SeparatorModel
|
|
69
|
+
| TableModel
|
|
70
|
+
| TextModel
|
|
71
|
+
| TimestampModel
|
package/src/model/richText.ts
CHANGED
|
@@ -52,7 +52,7 @@ const RichTextOptionsSchema = z.pipe(
|
|
|
52
52
|
*/
|
|
53
53
|
const LegacyLabelsFormat = z.record(z.string(), z.array(z.object({ name: z.string() })))
|
|
54
54
|
|
|
55
|
-
const RichTextLabelsSchema = z.pipe(
|
|
55
|
+
const RichTextLabelsSchema: z.ZodMiniType<string[]> = z.pipe(
|
|
56
56
|
z.union([
|
|
57
57
|
z.pipe(
|
|
58
58
|
z.null(),
|
|
@@ -83,7 +83,7 @@ const RichTextLabelsSchema = z.pipe(
|
|
|
83
83
|
}),
|
|
84
84
|
),
|
|
85
85
|
]),
|
|
86
|
-
z.transform((result: string[]) => result as
|
|
86
|
+
z.transform((result: string[]) => result as string[]),
|
|
87
87
|
)
|
|
88
88
|
|
|
89
89
|
const RichTextConfigSchema = z.object({
|
package/src/model/select.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from "zod/mini"
|
|
|
2
2
|
|
|
3
3
|
// Options can be string, number, or boolean - all coerced to string
|
|
4
4
|
// Matches io-ts behavior: t.union([t.string, StringFromNumber, StringFromBoolean])
|
|
5
|
-
const SelectOptionSchema = z.union([
|
|
5
|
+
const SelectOptionSchema: z.ZodMiniType<string> = z.union([
|
|
6
6
|
z.string(),
|
|
7
7
|
z.pipe(
|
|
8
8
|
z.number(),
|
|
@@ -18,7 +18,7 @@ const SelectConfigSchema = z.object({
|
|
|
18
18
|
label: z.nullish(z.string()),
|
|
19
19
|
placeholder: z.optional(z.string()),
|
|
20
20
|
default_value: z.optional(z.string()),
|
|
21
|
-
options: z.optional(z.
|
|
21
|
+
options: z.optional(z.array(SelectOptionSchema)),
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
export const SelectModelSchema = z.object({
|
package/src/model/slice.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
3
|
import { WidgetKeySchema } from "../common/widgetKey"
|
|
4
|
+
import type { NestedGroupModel } from "./group"
|
|
4
5
|
import { GroupModelSchema, NestedGroupModelSchema } from "./group"
|
|
6
|
+
import type { NestableModel } from "./nestable"
|
|
5
7
|
import { NestableModelSchema } from "./nestable"
|
|
6
8
|
|
|
7
9
|
// Simple (before 2020)
|
|
8
|
-
export const LegacySliceModelSchema = z.union([
|
|
10
|
+
export const LegacySliceModelSchema: z.ZodMiniType<LegacySliceModel> = z.union([
|
|
11
|
+
NestableModelSchema,
|
|
12
|
+
NestedGroupModelSchema,
|
|
13
|
+
])
|
|
9
14
|
|
|
10
|
-
export type LegacySliceModel =
|
|
15
|
+
export type LegacySliceModel = NestableModel | NestedGroupModel
|
|
11
16
|
|
|
12
17
|
// Composite (2020 to 2021)
|
|
13
18
|
export const CompositeSliceType = "Slice" as const
|
|
@@ -43,7 +48,14 @@ export const SharedSliceVariationSchema = z.object({
|
|
|
43
48
|
docURL: z.string(),
|
|
44
49
|
version: z.string(),
|
|
45
50
|
display: z.optional(z.string()),
|
|
46
|
-
primary: z.optional(
|
|
51
|
+
primary: z.optional(
|
|
52
|
+
z.record(
|
|
53
|
+
z.string(),
|
|
54
|
+
z.union([NestableModelSchema, GroupModelSchema]) as z.ZodMiniType<
|
|
55
|
+
NestableModel | NestedGroupModel
|
|
56
|
+
>,
|
|
57
|
+
),
|
|
58
|
+
),
|
|
47
59
|
items: z.optional(z.record(z.string(), NestableModelSchema)),
|
|
48
60
|
})
|
|
49
61
|
|
|
@@ -68,34 +80,49 @@ export type SharedSliceRefModel = z.infer<typeof SharedSliceRefModelSchema>
|
|
|
68
80
|
|
|
69
81
|
// Used to represent a shared slice content which can only be
|
|
70
82
|
// of a given shared slice variation type.
|
|
71
|
-
export const
|
|
83
|
+
export const SharedSliceVariationContentModelSchema = z.object({
|
|
72
84
|
type: z.literal(SharedSliceType),
|
|
73
85
|
sliceName: z.string(),
|
|
74
86
|
variationID: z.string(),
|
|
75
87
|
fields: z.pick(SharedSliceVariationSchema, { primary: true, items: true }),
|
|
76
88
|
})
|
|
77
89
|
|
|
78
|
-
export type
|
|
90
|
+
export type SharedSliceVariationContentModel = z.infer<
|
|
91
|
+
typeof SharedSliceVariationContentModelSchema
|
|
92
|
+
>
|
|
79
93
|
|
|
80
94
|
// All
|
|
81
95
|
|
|
82
96
|
// Used when slices reference SharedSlice by ref (not full definition)
|
|
83
|
-
export const DynamicSliceModelSchema = z.union([
|
|
97
|
+
export const DynamicSliceModelSchema: z.ZodMiniType<DynamicSliceModel> = z.union([
|
|
84
98
|
CompositeSliceModelSchema,
|
|
85
99
|
LegacySliceModelSchema,
|
|
86
100
|
SharedSliceRefModelSchema,
|
|
87
101
|
])
|
|
88
102
|
|
|
89
|
-
export type DynamicSliceModel =
|
|
103
|
+
export type DynamicSliceModel = CompositeSliceModel | LegacySliceModel | SharedSliceRefModel
|
|
90
104
|
|
|
91
105
|
// Used when slices include full SharedSlice definition
|
|
92
|
-
export const StaticSliceModelSchema = z.union([
|
|
106
|
+
export const StaticSliceModelSchema: z.ZodMiniType<StaticSliceModel> = z.union([
|
|
93
107
|
CompositeSliceModelSchema,
|
|
94
108
|
LegacySliceModelSchema,
|
|
95
109
|
SharedSliceModelSchema,
|
|
96
110
|
])
|
|
97
111
|
|
|
98
|
-
export type StaticSliceModel =
|
|
112
|
+
export type StaticSliceModel = CompositeSliceModel | LegacySliceModel | SharedSliceModel
|
|
113
|
+
|
|
114
|
+
// Used to represent a slice content model as shared slice variations
|
|
115
|
+
// can only be of a given shared slice variation type.
|
|
116
|
+
export const SliceContentModelSchema: z.ZodMiniType<SliceContentModel> = z.union([
|
|
117
|
+
CompositeSliceModelSchema,
|
|
118
|
+
LegacySliceModelSchema,
|
|
119
|
+
SharedSliceVariationContentModelSchema,
|
|
120
|
+
])
|
|
121
|
+
|
|
122
|
+
export type SliceContentModel =
|
|
123
|
+
| CompositeSliceModel
|
|
124
|
+
| LegacySliceModel
|
|
125
|
+
| SharedSliceVariationContentModel
|
|
99
126
|
|
|
100
127
|
// Model types
|
|
101
128
|
export const SliceModelTypeSchema = z.union([
|
package/src/model/table.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
|
+
import { RichTextNodeType, type RichTextModel } from "./richText"
|
|
2
3
|
|
|
3
4
|
const TableConfigSchema = z.object({
|
|
4
5
|
label: z.nullish(z.string()),
|
|
@@ -12,9 +13,16 @@ export const TableModelSchema = z.object({
|
|
|
12
13
|
export type TableModel = z.infer<typeof TableModelSchema>
|
|
13
14
|
|
|
14
15
|
// TableCell configuration constant (used for cell rich text configuration)
|
|
15
|
-
export const
|
|
16
|
+
export const TableCellModelNodeTypes = [
|
|
17
|
+
RichTextNodeType.paragraph,
|
|
18
|
+
RichTextNodeType.strong,
|
|
19
|
+
RichTextNodeType.em,
|
|
20
|
+
RichTextNodeType.hyperlink
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
export const TableCellModel: RichTextModel = {
|
|
16
24
|
type: "StructuredText" as const,
|
|
17
25
|
config: {
|
|
18
|
-
multi:
|
|
26
|
+
multi: TableCellModelNodeTypes.join(","),
|
|
19
27
|
},
|
|
20
28
|
}
|
package/src/model/widget.ts
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import { z } from "zod/mini"
|
|
2
2
|
|
|
3
|
+
import type { GroupModel } from "./group"
|
|
3
4
|
import { GroupModelSchema } from "./group"
|
|
5
|
+
import type { NestableModel } from "./nestable"
|
|
4
6
|
import { NestableModelSchema } from "./nestable"
|
|
5
7
|
import { SliceModelTypeSchema } from "./slice"
|
|
8
|
+
import type { DynamicSlicesModel, StaticSlicesModel } from "./slices"
|
|
6
9
|
import { DynamicSlicesModelSchema, StaticSlicesModelSchema } from "./slices"
|
|
10
|
+
import type { UIDModel } from "./uid"
|
|
7
11
|
import { UIDModelSchema } from "./uid"
|
|
8
12
|
|
|
9
13
|
// StaticWidget = UID | Nestable | Group | StaticSlices
|
|
10
|
-
export const StaticWidgetModelSchema = z.union([
|
|
14
|
+
export const StaticWidgetModelSchema: z.ZodMiniType<StaticWidgetModel> = z.union([
|
|
11
15
|
UIDModelSchema,
|
|
12
16
|
NestableModelSchema,
|
|
13
17
|
GroupModelSchema,
|
|
14
18
|
StaticSlicesModelSchema,
|
|
15
19
|
])
|
|
16
20
|
|
|
17
|
-
export type StaticWidgetModel =
|
|
21
|
+
export type StaticWidgetModel = UIDModel | NestableModel | GroupModel | StaticSlicesModel
|
|
18
22
|
|
|
19
23
|
// DynamicWidget = UID | Nestable | Group | DynamicSlices
|
|
20
|
-
export const DynamicWidgetModelSchema = z.union([
|
|
24
|
+
export const DynamicWidgetModelSchema: z.ZodMiniType<DynamicWidgetModel> = z.union([
|
|
21
25
|
UIDModelSchema,
|
|
22
26
|
NestableModelSchema,
|
|
23
27
|
GroupModelSchema,
|
|
24
28
|
DynamicSlicesModelSchema,
|
|
25
29
|
])
|
|
26
30
|
|
|
27
|
-
export type DynamicWidgetModel =
|
|
31
|
+
export type DynamicWidgetModel = UIDModel | NestableModel | GroupModel | DynamicSlicesModel
|
|
28
32
|
|
|
29
33
|
// FieldModelType - all possible field type strings
|
|
30
34
|
export const FieldModelTypeSchema = z.enum([
|