@prismicio/types-internal 4.0.0-pr.6.e3136c3 → 4.0.0-pr.7.9dec8db

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.
Files changed (164) hide show
  1. package/README.md +5 -5
  2. package/dist/content/codec/link.js +8 -8
  3. package/dist/content/codec/link.js.map +1 -1
  4. package/dist/content/codec/richText.js +2 -2
  5. package/dist/content/codec/richText.js.map +1 -1
  6. package/dist/content/document.d.ts +2 -3019
  7. package/dist/content/document.d.ts.map +1 -1
  8. package/dist/content/field.d.ts +1 -30
  9. package/dist/content/field.d.ts.map +1 -1
  10. package/dist/content/field.js.map +1 -1
  11. package/dist/content/group.d.ts +2 -1
  12. package/dist/content/group.d.ts.map +1 -1
  13. package/dist/content/group.js.map +1 -1
  14. package/dist/content/legacy/boolean.d.ts +1 -0
  15. package/dist/content/legacy/embed.d.ts +1 -0
  16. package/dist/content/legacy/empty.d.ts +1 -0
  17. package/dist/content/legacy/field.d.ts +1 -0
  18. package/dist/content/legacy/geopoint.d.ts +1 -0
  19. package/dist/content/legacy/group.d.ts +9 -0
  20. package/dist/content/legacy/group.d.ts.map +1 -0
  21. package/dist/content/legacy/group.js.map +1 -1
  22. package/dist/content/legacy/integrationField.d.ts +1 -0
  23. package/dist/content/legacy/link.d.ts +41 -0
  24. package/dist/content/legacy/link.d.ts.map +1 -0
  25. package/dist/content/legacy/link.js.map +1 -1
  26. package/dist/content/legacy/nestable.d.ts +1 -0
  27. package/dist/content/legacy/nestable.js.map +1 -1
  28. package/dist/content/legacy/repeatable.d.ts +1 -0
  29. package/dist/content/legacy/repeatable.js +2 -8
  30. package/dist/content/legacy/repeatable.js.map +1 -1
  31. package/dist/content/legacy/richText.d.ts +109 -0
  32. package/dist/content/legacy/richText.d.ts.map +1 -0
  33. package/dist/content/legacy/richText.js +3 -3
  34. package/dist/content/legacy/richText.js.map +1 -1
  35. package/dist/content/legacy/separator.d.ts +1 -0
  36. package/dist/content/legacy/slice.js +2 -3
  37. package/dist/content/legacy/slice.js.map +1 -1
  38. package/dist/content/legacy/table.d.ts +1 -0
  39. package/dist/content/link.d.ts +74 -99
  40. package/dist/content/link.d.ts.map +1 -1
  41. package/dist/content/link.js +2 -2
  42. package/dist/content/link.js.map +1 -1
  43. package/dist/content/nestable.d.ts +13 -749
  44. package/dist/content/nestable.d.ts.map +1 -1
  45. package/dist/content/nestable.js +1 -0
  46. package/dist/content/nestable.js.map +1 -1
  47. package/dist/content/repeatable.d.ts +3 -98
  48. package/dist/content/repeatable.d.ts.map +1 -1
  49. package/dist/content/richText.d.ts +81 -131
  50. package/dist/content/richText.d.ts.map +1 -1
  51. package/dist/content/richText.js +5 -4
  52. package/dist/content/richText.js.map +1 -1
  53. package/dist/content/slice.d.ts +6 -4509
  54. package/dist/content/slice.d.ts.map +1 -1
  55. package/dist/content/slice.js.map +1 -1
  56. package/dist/content/slices.d.ts +8 -6765
  57. package/dist/content/slices.d.ts.map +1 -1
  58. package/dist/content/table.d.ts +2 -134
  59. package/dist/content/table.d.ts.map +1 -1
  60. package/dist/content/widget.d.ts +5 -3020
  61. package/dist/content/widget.d.ts.map +1 -1
  62. package/dist/content/widget.js.map +1 -1
  63. package/dist/helpers/contentPath.js +1 -1
  64. package/dist/helpers/customTypeModel.d.ts +3 -2
  65. package/dist/helpers/customTypeModel.d.ts.map +1 -1
  66. package/dist/helpers/customTypeModel.js +31 -1
  67. package/dist/helpers/customTypeModel.js.map +1 -1
  68. package/dist/helpers/documentContent.d.ts +5 -10
  69. package/dist/helpers/documentContent.d.ts.map +1 -1
  70. package/dist/helpers/documentContent.js +18 -5
  71. package/dist/helpers/documentContent.js.map +1 -1
  72. package/dist/helpers/sliceContent.d.ts +12 -0
  73. package/dist/helpers/sliceContent.d.ts.map +1 -0
  74. package/dist/helpers/sliceContent.js +60 -0
  75. package/dist/helpers/sliceContent.js.map +1 -0
  76. package/dist/helpers/traverseContent.d.ts +21 -22
  77. package/dist/helpers/traverseContent.d.ts.map +1 -1
  78. package/dist/helpers/traverseContent.js +54 -22
  79. package/dist/helpers/traverseContent.js.map +1 -1
  80. package/dist/helpers/traverseContentWithModel.d.ts +20 -21
  81. package/dist/helpers/traverseContentWithModel.d.ts.map +1 -1
  82. package/dist/helpers/traverseContentWithModel.js +64 -38
  83. package/dist/helpers/traverseContentWithModel.js.map +1 -1
  84. package/dist/index.d.ts +26 -25
  85. package/dist/index.js +3 -1
  86. package/dist/io-ts.d.ts +3304 -70918
  87. package/dist/io-ts.d.ts.map +1 -1
  88. package/dist/io-ts.js +125 -122
  89. package/dist/io-ts.js.map +1 -1
  90. package/dist/model/customType.d.ts +3 -3329
  91. package/dist/model/customType.d.ts.map +1 -1
  92. package/dist/model/group.d.ts +391 -392
  93. package/dist/model/group.d.ts.map +1 -1
  94. package/dist/model/group.js.map +1 -1
  95. package/dist/model/image.d.ts +4 -4
  96. package/dist/model/image.js.map +1 -1
  97. package/dist/model/link.d.ts +18 -18
  98. package/dist/model/link.d.ts.map +1 -1
  99. package/dist/model/link.js +7 -7
  100. package/dist/model/link.js.map +1 -1
  101. package/dist/model/nestable.d.ts +17 -178
  102. package/dist/model/nestable.d.ts.map +1 -1
  103. package/dist/model/nestable.js +3 -3
  104. package/dist/model/nestable.js.map +1 -1
  105. package/dist/model/richText.d.ts +3 -7
  106. package/dist/model/richText.d.ts.map +1 -1
  107. package/dist/model/richText.js +4 -3
  108. package/dist/model/richText.js.map +1 -1
  109. package/dist/model/section.d.ts +3 -3329
  110. package/dist/model/section.d.ts.map +1 -1
  111. package/dist/model/select.d.ts +1 -1
  112. package/dist/model/select.js +1 -1
  113. package/dist/model/select.js.map +1 -1
  114. package/dist/model/slice.d.ts +861 -3800
  115. package/dist/model/slice.d.ts.map +1 -1
  116. package/dist/model/slice.js +7 -2
  117. package/dist/model/slice.js.map +1 -1
  118. package/dist/model/slices.d.ts +3 -2195
  119. package/dist/model/slices.d.ts.map +1 -1
  120. package/dist/model/table.d.ts +2 -1
  121. package/dist/model/table.d.ts.map +1 -1
  122. package/dist/model/table.js +9 -7
  123. package/dist/model/table.js.map +1 -1
  124. package/dist/model/widget.d.ts +14 -3339
  125. package/dist/model/widget.d.ts.map +1 -1
  126. package/dist/model/widget.js.map +1 -1
  127. package/dist/zod4.d.ts +1345 -34797
  128. package/dist/zod4.d.ts.map +1 -1
  129. package/dist/zod4.js +125 -122
  130. package/dist/zod4.js.map +1 -1
  131. package/package.json +3 -2
  132. package/src/content/codec/link.ts +8 -8
  133. package/src/content/codec/richText.ts +10 -6
  134. package/src/content/field.ts +9 -2
  135. package/src/content/group.ts +5 -2
  136. package/src/content/legacy/group.ts +12 -4
  137. package/src/content/legacy/link.ts +32 -9
  138. package/src/content/legacy/nestable.ts +26 -2
  139. package/src/content/legacy/repeatable.ts +3 -16
  140. package/src/content/legacy/richText.ts +40 -7
  141. package/src/content/legacy/slice.ts +8 -7
  142. package/src/content/legacy/widget.ts +6 -2
  143. package/src/content/link.ts +32 -9
  144. package/src/content/nestable.ts +42 -2
  145. package/src/content/richText.ts +31 -9
  146. package/src/content/slice.ts +2 -2
  147. package/src/content/widget.ts +6 -2
  148. package/src/helpers/customTypeModel.ts +44 -0
  149. package/src/helpers/documentContent.ts +45 -17
  150. package/src/helpers/sliceContent.ts +86 -0
  151. package/src/helpers/traverseContent.ts +108 -41
  152. package/src/helpers/traverseContentWithModel.ts +91 -60
  153. package/src/index.ts +5 -2
  154. package/src/io-ts.ts +166 -140
  155. package/src/model/group.ts +4 -1
  156. package/src/model/image.ts +1 -1
  157. package/src/model/link.ts +39 -45
  158. package/src/model/nestable.ts +33 -1
  159. package/src/model/richText.ts +2 -2
  160. package/src/model/select.ts +2 -2
  161. package/src/model/slice.ts +36 -9
  162. package/src/model/table.ts +11 -2
  163. package/src/model/widget.ts +8 -4
  164. package/src/zod4.ts +166 -140
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod/mini"
2
2
 
3
3
  import { WidgetKeySchema } from "../common/widgetKey"
4
+ import type { NestableModel } from "./nestable"
4
5
  import { NestableModelSchema } from "./nestable"
5
6
 
6
7
  export const GroupFieldType = "Group"
@@ -30,7 +31,9 @@ export type NestedGroupModel = z.infer<typeof NestedGroupModelSchema>
30
31
 
31
32
  // Group - allows Nestable | NestedGroup in fields (max 2 levels of nesting)
32
33
  export const GroupModelSchema = createGroupSchema(
33
- z.union([NestableModelSchema, NestedGroupModelSchema]),
34
+ z.union([NestableModelSchema, NestedGroupModelSchema]) as z.ZodMiniType<
35
+ NestableModel | NestedGroupModel
36
+ >,
34
37
  )
35
38
 
36
39
  export type GroupModel = z.infer<typeof GroupModelSchema>
@@ -8,7 +8,7 @@ import { z } from "zod/mini"
8
8
  * - "auto" or "" → null
9
9
  * - null
10
10
  */
11
- export const SideConstraintSchema = z.union([
11
+ export const SideConstraintSchema: z.ZodMiniType<number | null> = z.union([
12
12
  z.pipe(
13
13
  z.literal("auto"),
14
14
  z.transform(() => null),
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): readonly string[] => (typeof val === "string" ? [val] : 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.readonly(
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.readonly(
34
- z.array(CustomTypeLevel2FieldSchema).check(z.refine(noDuplicateIds, "Fields have duplicates.")),
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.readonly(
43
- z.array(CustomTypeLevel2Schema).check(z.refine(noDuplicateIds, "Custom types have duplicates.")),
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.readonly(
59
- z
60
- .array(CustomTypeLevel1FieldGroupFieldSchema)
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.readonly(
74
- z.array(CustomTypeLevel1FieldSchema).check(z.refine(noDuplicateIds, "Fields have duplicates.")),
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.readonly(
83
- z.array(CustomTypeLevel1Schema).check(({ value, issues }) => {
84
- const cts = value as ({ id: string } | string)[]
85
- const push = (message: string) => issues.push({ code: "custom", input: value, message })
86
- const strings = new Set<string>()
87
- const objects = new Set<string>()
88
- for (const ct of cts) {
89
- let failed = false
90
- if (typeof ct === "string") {
91
- failed = objects.has(ct)
92
- strings.add(ct)
93
- } else {
94
- const { id } = ct
95
- failed = strings.has(id) || objects.has(id)
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 (objects.size > 1) {
104
- push("Cannot have multiple custom types with fields selection.")
93
+ if (failed) {
94
+ push("Custom types have duplicates.")
105
95
  return
106
96
  }
107
- if (strings.size > 0 && objects.size > 0) {
108
- push("Cannot mix custom types as strings and objects with fields.")
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
 
@@ -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 = z.infer<typeof NestableModelSchema>
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
@@ -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 readonly string[]),
86
+ z.transform((result: string[]) => result as string[]),
87
87
  )
88
88
 
89
89
  const RichTextConfigSchema = z.object({
@@ -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.readonly(z.array(SelectOptionSchema))),
21
+ options: z.optional(z.array(SelectOptionSchema)),
22
22
  })
23
23
 
24
24
  export const SelectModelSchema = z.object({
@@ -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([NestableModelSchema, NestedGroupModelSchema])
10
+ export const LegacySliceModelSchema: z.ZodMiniType<LegacySliceModel> = z.union([
11
+ NestableModelSchema,
12
+ NestedGroupModelSchema,
13
+ ])
9
14
 
10
- export type LegacySliceModel = z.infer<typeof LegacySliceModelSchema>
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(z.record(z.string(), z.union([NestableModelSchema, GroupModelSchema]))),
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 SharedSliceVariationModelSchema = z.object({
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 SharedSliceVariationModel = z.infer<typeof SharedSliceVariationModelSchema>
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 = z.infer<typeof DynamicSliceModelSchema>
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 = z.infer<typeof StaticSliceModelSchema>
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([
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod/mini"
2
2
 
3
+ import { RichTextNodeType, type RichTextModel } from "./richText"
4
+
3
5
  const TableConfigSchema = z.object({
4
6
  label: z.nullish(z.string()),
5
7
  })
@@ -12,9 +14,16 @@ export const TableModelSchema = z.object({
12
14
  export type TableModel = z.infer<typeof TableModelSchema>
13
15
 
14
16
  // TableCell configuration constant (used for cell rich text configuration)
15
- export const TableCellModel = {
17
+ export const TableCellModelNodeTypes = [
18
+ RichTextNodeType.paragraph,
19
+ RichTextNodeType.strong,
20
+ RichTextNodeType.em,
21
+ RichTextNodeType.hyperlink,
22
+ ]
23
+
24
+ export const TableCellModel: RichTextModel = {
16
25
  type: "StructuredText" as const,
17
26
  config: {
18
- multi: ["paragraph", "strong", "em", "hyperlink"].join(","),
27
+ multi: TableCellModelNodeTypes.join(","),
19
28
  },
20
29
  }
@@ -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 = z.infer<typeof StaticWidgetModelSchema>
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 = z.infer<typeof DynamicWidgetModelSchema>
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([