@prismicio/types-internal 4.0.0-pr.6.eb53f11 → 4.0.0-pr.9.e09af2c

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 (167) hide show
  1. package/README.md +5 -5
  2. package/dist/content/boolean.d.ts.map +1 -1
  3. package/dist/content/boolean.js.map +1 -1
  4. package/dist/content/document.d.ts +2 -3019
  5. package/dist/content/document.d.ts.map +1 -1
  6. package/dist/content/field.d.ts +1 -30
  7. package/dist/content/field.d.ts.map +1 -1
  8. package/dist/content/field.js +1 -1
  9. package/dist/content/field.js.map +1 -1
  10. package/dist/content/group.d.ts +2 -1
  11. package/dist/content/group.d.ts.map +1 -1
  12. package/dist/content/group.js.map +1 -1
  13. package/dist/content/legacy/boolean.d.ts +1 -0
  14. package/dist/content/legacy/embed.d.ts +1 -0
  15. package/dist/content/legacy/empty.d.ts +1 -0
  16. package/dist/content/legacy/field.d.ts +1 -0
  17. package/dist/content/legacy/geopoint.d.ts +1 -0
  18. package/dist/content/legacy/group.d.ts +9 -0
  19. package/dist/content/legacy/group.d.ts.map +1 -0
  20. package/dist/content/legacy/group.js.map +1 -1
  21. package/dist/content/legacy/integrationField.d.ts +1 -0
  22. package/dist/content/legacy/link.d.ts +41 -0
  23. package/dist/content/legacy/link.d.ts.map +1 -0
  24. package/dist/content/legacy/link.js.map +1 -1
  25. package/dist/content/legacy/nestable.d.ts +1 -0
  26. package/dist/content/legacy/nestable.js.map +1 -1
  27. package/dist/content/legacy/repeatable.d.ts +1 -0
  28. package/dist/content/legacy/repeatable.js +2 -8
  29. package/dist/content/legacy/repeatable.js.map +1 -1
  30. package/dist/content/legacy/richText.d.ts +109 -0
  31. package/dist/content/legacy/richText.d.ts.map +1 -0
  32. package/dist/content/legacy/richText.js.map +1 -1
  33. package/dist/content/legacy/separator.d.ts +1 -0
  34. package/dist/content/legacy/slice.js +2 -3
  35. package/dist/content/legacy/slice.js.map +1 -1
  36. package/dist/content/legacy/table.d.ts +1 -0
  37. package/dist/content/link.d.ts +74 -99
  38. package/dist/content/link.d.ts.map +1 -1
  39. package/dist/content/link.js +2 -2
  40. package/dist/content/link.js.map +1 -1
  41. package/dist/content/nestable.d.ts +13 -749
  42. package/dist/content/nestable.d.ts.map +1 -1
  43. package/dist/content/nestable.js +1 -0
  44. package/dist/content/nestable.js.map +1 -1
  45. package/dist/content/repeatable.d.ts +3 -98
  46. package/dist/content/repeatable.d.ts.map +1 -1
  47. package/dist/content/richText.d.ts +20 -248
  48. package/dist/content/richText.d.ts.map +1 -1
  49. package/dist/content/richText.js.map +1 -1
  50. package/dist/content/slice.d.ts +6 -4509
  51. package/dist/content/slice.d.ts.map +1 -1
  52. package/dist/content/slice.js.map +1 -1
  53. package/dist/content/slices.d.ts +8 -6765
  54. package/dist/content/slices.d.ts.map +1 -1
  55. package/dist/content/table.d.ts +2 -134
  56. package/dist/content/table.d.ts.map +1 -1
  57. package/dist/content/widget.d.ts +5 -3020
  58. package/dist/content/widget.d.ts.map +1 -1
  59. package/dist/content/widget.js.map +1 -1
  60. package/dist/helpers/contentPath.js +1 -1
  61. package/dist/helpers/customTypeModel.d.ts +3 -2
  62. package/dist/helpers/customTypeModel.d.ts.map +1 -1
  63. package/dist/helpers/customTypeModel.js +31 -1
  64. package/dist/helpers/customTypeModel.js.map +1 -1
  65. package/dist/helpers/documentContent.d.ts +3 -2
  66. package/dist/helpers/documentContent.d.ts.map +1 -1
  67. package/dist/helpers/documentContent.js +14 -1
  68. package/dist/helpers/documentContent.js.map +1 -1
  69. package/dist/helpers/sliceContent.d.ts +12 -0
  70. package/dist/helpers/sliceContent.d.ts.map +1 -0
  71. package/dist/helpers/sliceContent.js +60 -0
  72. package/dist/helpers/sliceContent.js.map +1 -0
  73. package/dist/helpers/traverseContent.d.ts +15 -16
  74. package/dist/helpers/traverseContent.d.ts.map +1 -1
  75. package/dist/helpers/traverseContent.js +53 -19
  76. package/dist/helpers/traverseContent.js.map +1 -1
  77. package/dist/helpers/traverseContentWithModel.d.ts +14 -15
  78. package/dist/helpers/traverseContentWithModel.d.ts.map +1 -1
  79. package/dist/helpers/traverseContentWithModel.js +61 -35
  80. package/dist/helpers/traverseContentWithModel.js.map +1 -1
  81. package/dist/helpers/withDefaultContent.d.ts +17 -0
  82. package/dist/helpers/withDefaultContent.d.ts.map +1 -0
  83. package/dist/helpers/withDefaultContent.js +113 -0
  84. package/dist/helpers/withDefaultContent.js.map +1 -0
  85. package/dist/index.d.ts +16 -14
  86. package/dist/index.js +4 -1
  87. package/dist/io-ts.d.ts +3629 -70848
  88. package/dist/io-ts.d.ts.map +1 -1
  89. package/dist/io-ts.js +126 -124
  90. package/dist/io-ts.js.map +1 -1
  91. package/dist/model/customType.d.ts +3 -3329
  92. package/dist/model/customType.d.ts.map +1 -1
  93. package/dist/model/group.d.ts +375 -376
  94. package/dist/model/group.d.ts.map +1 -1
  95. package/dist/model/group.js.map +1 -1
  96. package/dist/model/image.d.ts +4 -4
  97. package/dist/model/image.js.map +1 -1
  98. package/dist/model/link.d.ts +2 -2
  99. package/dist/model/link.js.map +1 -1
  100. package/dist/model/nestable.d.ts +17 -178
  101. package/dist/model/nestable.d.ts.map +1 -1
  102. package/dist/model/nestable.js +3 -3
  103. package/dist/model/nestable.js.map +1 -1
  104. package/dist/model/richText.d.ts +3 -7
  105. package/dist/model/richText.d.ts.map +1 -1
  106. package/dist/model/richText.js +4 -3
  107. package/dist/model/richText.js.map +1 -1
  108. package/dist/model/section.d.ts +3 -3329
  109. package/dist/model/section.d.ts.map +1 -1
  110. package/dist/model/select.d.ts +1 -1
  111. package/dist/model/select.js +1 -1
  112. package/dist/model/select.js.map +1 -1
  113. package/dist/model/slice.d.ts +1360 -3691
  114. package/dist/model/slice.d.ts.map +1 -1
  115. package/dist/model/slice.js +10 -5
  116. package/dist/model/slice.js.map +1 -1
  117. package/dist/model/slices.d.ts +3 -2195
  118. package/dist/model/slices.d.ts.map +1 -1
  119. package/dist/model/table.d.ts +2 -1
  120. package/dist/model/table.d.ts.map +1 -1
  121. package/dist/model/table.js +9 -7
  122. package/dist/model/table.js.map +1 -1
  123. package/dist/model/widget.d.ts +7 -3334
  124. package/dist/model/widget.d.ts.map +1 -1
  125. package/dist/model/widget.js +5 -2
  126. package/dist/model/widget.js.map +1 -1
  127. package/dist/zod4.d.ts +1796 -34837
  128. package/dist/zod4.d.ts.map +1 -1
  129. package/dist/zod4.js +126 -124
  130. package/dist/zod4.js.map +1 -1
  131. package/package.json +3 -2
  132. package/src/content/boolean.ts +0 -13
  133. package/src/content/field.ts +9 -16
  134. package/src/content/group.ts +6 -56
  135. package/src/content/legacy/group.ts +12 -4
  136. package/src/content/legacy/link.ts +32 -9
  137. package/src/content/legacy/nestable.ts +26 -2
  138. package/src/content/legacy/repeatable.ts +3 -16
  139. package/src/content/legacy/richText.ts +37 -5
  140. package/src/content/legacy/slice.ts +8 -7
  141. package/src/content/legacy/widget.ts +6 -2
  142. package/src/content/link.ts +32 -9
  143. package/src/content/nestable.ts +43 -22
  144. package/src/content/richText.ts +19 -7
  145. package/src/content/slice.ts +2 -2
  146. package/src/content/widget.ts +6 -2
  147. package/src/helpers/customTypeModel.ts +44 -0
  148. package/src/helpers/documentContent.ts +32 -1
  149. package/src/helpers/sliceContent.ts +86 -0
  150. package/src/helpers/traverseContent.ts +96 -32
  151. package/src/helpers/traverseContentWithModel.ts +73 -48
  152. package/src/helpers/withDefaultContent.ts +173 -0
  153. package/src/index.ts +6 -1
  154. package/src/io-ts.ts +166 -144
  155. package/src/model/diff/sharedSlice.ts +2 -2
  156. package/src/model/diff/variation.ts +7 -7
  157. package/src/model/group.ts +4 -1
  158. package/src/model/image.ts +1 -1
  159. package/src/model/link.ts +1 -1
  160. package/src/model/nestable.ts +33 -1
  161. package/src/model/richText.ts +2 -2
  162. package/src/model/select.ts +2 -2
  163. package/src/model/slice.ts +38 -13
  164. package/src/model/table.ts +11 -2
  165. package/src/model/widget.ts +14 -6
  166. package/src/zod4.ts +166 -144
  167. package/src/content/withDefaultValues.ts +0 -114
@@ -0,0 +1,173 @@
1
+ import { BooleanContentType } from "../content/boolean"
2
+ import type { DocumentContent } from "../content/document"
3
+ import { FieldContentType, SelectFieldType } from "../content/field"
4
+ import type { GroupContent, GroupItemContent } from "../content/group"
5
+ import { GroupContentType } from "../content/group"
6
+ import type { SliceContent } from "../content/slice"
7
+ import { CompositeSliceContentType, SharedSliceContentType } from "../content/slice"
8
+ import type { SlicesContent } from "../content/slices"
9
+ import { SlicesContentType } from "../content/slices"
10
+ import type { WidgetContent } from "../content/widget"
11
+ import type { StaticCustomTypeModel } from "../model/customType"
12
+ import type { GroupModel } from "../model/group"
13
+ import type { NestableModel } from "../model/nestable"
14
+ import type { StaticSliceModel } from "../model/slice"
15
+ import type { StaticWidgetModel } from "../model/widget"
16
+ import * as customTypeModel from "./customTypeModel"
17
+
18
+ export function document(content: DocumentContent, model: StaticCustomTypeModel): DocumentContent {
19
+ return record(content, customTypeModel.flatten(model))
20
+ }
21
+
22
+ export function slice(content: SliceContent, model: StaticSliceModel | undefined): SliceContent {
23
+ if (!model) {
24
+ return content
25
+ }
26
+
27
+ if (model.type === "SharedSlice") {
28
+ if (content.__TYPE__ !== SharedSliceContentType) {
29
+ return content
30
+ }
31
+
32
+ const variation = model.variations.find((variation) => variation.id === content.variation)
33
+ if (!variation) {
34
+ return content
35
+ }
36
+
37
+ return {
38
+ ...content,
39
+ primary: record(content.primary, variation?.primary),
40
+ items: items(content.items, variation?.items),
41
+ }
42
+ }
43
+
44
+ if (model.type === "Slice") {
45
+ if (content.__TYPE__ !== CompositeSliceContentType) {
46
+ return content
47
+ }
48
+
49
+ return {
50
+ ...content,
51
+ nonRepeat: record(content.nonRepeat, model["non-repeat"]),
52
+ repeat: items(content.repeat, model.repeat),
53
+ }
54
+ }
55
+
56
+ if (
57
+ content.__TYPE__ === SharedSliceContentType ||
58
+ content.__TYPE__ === CompositeSliceContentType
59
+ ) {
60
+ return content
61
+ }
62
+
63
+ return widget(content, model)
64
+ }
65
+
66
+ export function widget<TContent extends WidgetContent | undefined>(
67
+ content: TContent,
68
+ model: StaticWidgetModel | undefined,
69
+ ): TContent {
70
+ if (!model) {
71
+ return content
72
+ }
73
+
74
+ if (
75
+ (model.type === "Slices" || model.type === "Choice") &&
76
+ content?.__TYPE__ === SlicesContentType
77
+ ) {
78
+ if (!model.config?.choices) return content
79
+
80
+ const value: SlicesContent["value"] = []
81
+ for (const sliceItem of content.value) {
82
+ value.push({
83
+ ...sliceItem,
84
+ widget: slice(sliceItem.widget, model.config.choices[sliceItem.name]),
85
+ })
86
+ }
87
+
88
+ return { ...content, value }
89
+ }
90
+
91
+ if (model.type === "Group" && content?.__TYPE__ === GroupContentType) {
92
+ return { ...content, value: items(content.value, model.config?.fields) }
93
+ }
94
+
95
+ if (model.type === "Boolean" && !content) {
96
+ if (model.config?.default_value === undefined) {
97
+ return <TContent>undefined
98
+ }
99
+
100
+ return <TContent>{
101
+ __TYPE__: BooleanContentType,
102
+ value: model.config.default_value,
103
+ }
104
+ }
105
+
106
+ if (model.type === "Select" && !content) {
107
+ if (!model.config?.default_value) {
108
+ return <TContent>undefined
109
+ }
110
+
111
+ return <TContent>{
112
+ __TYPE__: FieldContentType,
113
+ type: SelectFieldType,
114
+ value: model.config.default_value,
115
+ }
116
+ }
117
+
118
+ return content
119
+ }
120
+
121
+ function items(
122
+ items: GroupContent["value"],
123
+ fields: Record<string, GroupModel | NestableModel> | undefined,
124
+ ): GroupContent["value"] {
125
+ if (!fields) {
126
+ return items
127
+ }
128
+
129
+ const itemsWithDefaults: GroupContent["value"] = []
130
+ for (const item of items) {
131
+ const itemValue: GroupItemContent["value"] = []
132
+
133
+ const missingFields = { ...fields }
134
+ for (const [key, value] of item.value) {
135
+ delete missingFields[key]
136
+ itemValue.push([key, widget(value, fields[key])])
137
+ }
138
+ for (const [key, field] of Object.entries(missingFields)) {
139
+ const content = widget(undefined, field)
140
+ if (content) {
141
+ itemValue.push([key, content])
142
+ }
143
+ }
144
+
145
+ itemsWithDefaults.push({ ...item, value: itemValue })
146
+ }
147
+
148
+ return itemsWithDefaults
149
+ }
150
+
151
+ function record<TContent extends WidgetContent>(
152
+ record: Record<string, TContent>,
153
+ fields: Record<string, StaticWidgetModel> | undefined,
154
+ ): Record<string, TContent> {
155
+ if (!fields) {
156
+ return record
157
+ }
158
+
159
+ const missingFields = { ...fields }
160
+ const recordWithDefaults: Record<string, TContent> = {}
161
+ for (const [key, value] of Object.entries(record)) {
162
+ delete missingFields[key]
163
+ recordWithDefaults[key] = widget(value, fields[key])
164
+ }
165
+ for (const [key, field] of Object.entries(missingFields)) {
166
+ const content = widget(undefined, field)
167
+ if (content) {
168
+ recordWithDefaults[key] = content
169
+ }
170
+ }
171
+
172
+ return recordWithDefaults
173
+ }
package/src/index.ts CHANGED
@@ -69,13 +69,16 @@ export type {
69
69
  CompositeSliceModel,
70
70
  SharedSliceModel,
71
71
  SharedSliceRefModel,
72
- SharedSliceVariationModel,
72
+ SharedSliceModelVariation,
73
+ SharedSliceVariationContentModel,
73
74
  StaticSliceModel,
74
75
  DynamicSliceModel,
76
+ SliceContentModel,
75
77
  SliceModelType,
76
78
  } from "./model/slice"
77
79
  export type { DynamicSlicesModel, StaticSlicesModel } from "./model/slices"
78
80
  export type { TableModel } from "./model/table"
81
+ export { TableCellModelNodeTypes } from "./model/table"
79
82
  export type { TextModel } from "./model/text"
80
83
  export type { TimestampModel } from "./model/timestamp"
81
84
  export type { UIDModel } from "./model/uid"
@@ -88,6 +91,8 @@ export { LegacyContentCtx, getFieldCtx, defaultCtx } from "./content/codec/legac
88
91
  export * as contentPath from "./helpers/contentPath"
89
92
  export * as customTypeModel from "./helpers/customTypeModel"
90
93
  export * as documentContent from "./helpers/documentContent"
94
+ export * as sliceContent from "./helpers/sliceContent"
95
+ export * as withDefaultContent from "./helpers/withDefaultContent"
91
96
  export {
92
97
  traverseDocumentContent,
93
98
  traverseSlicesContent,
package/src/io-ts.ts CHANGED
@@ -2,13 +2,13 @@ import * as t from "io-ts"
2
2
  import type { ZodMiniType } from "zod/mini"
3
3
 
4
4
  // Common
5
- import { AssetSchema } from "./common/asset"
6
- import { EmbedSchema } from "./common/embed"
7
- import { HexaColorCodeSchema } from "./common/hexaColorCode"
8
- import { NonEmptyStringSchema } from "./common/nonEmptyString"
9
- import { WidgetKeySchema } from "./common/widgetKey"
5
+ import { AssetSchema as rawAssetSchema } from "./common/asset"
6
+ import { EmbedSchema as rawEmbedSchema } from "./common/embed"
7
+ import { HexaColorCodeSchema as rawHexaColorCodeSchema } from "./common/hexaColorCode"
8
+ import { NonEmptyStringSchema as rawNonEmptyStringSchema } from "./common/nonEmptyString"
9
+ import { WidgetKeySchema as rawWidgetKeySchema } from "./common/widgetKey"
10
10
  // Content
11
- import { BooleanContentSchema } from "./content/boolean"
11
+ import { BooleanContentSchema as rawBooleanContentSchema } from "./content/boolean"
12
12
  import { BooleanLegacyCodec } from "./content/codec/boolean"
13
13
  import { DocumentLegacyCodec } from "./content/codec/document"
14
14
  import { EmbedLegacyCodec } from "./content/codec/embed"
@@ -42,125 +42,145 @@ import { SliceItemLegacyCodec, SlicesLegacyCodec } from "./content/codec/slices"
42
42
  import { TableLegacyCodec } from "./content/codec/table"
43
43
  import { UIDLegacyCodec } from "./content/codec/uid"
44
44
  import { WidgetLegacyCodec } from "./content/codec/widget"
45
- import { DocumentContentSchema } from "./content/document"
46
- import { EmbedContentSchema } from "./content/embed"
47
- import { EmptyContentSchema } from "./content/empty"
45
+ import { DocumentContentSchema as rawDocumentContentSchema } from "./content/document"
46
+ import { EmbedContentSchema as rawEmbedContentSchema } from "./content/embed"
47
+ import { EmptyContentSchema as rawEmptyContentSchema } from "./content/empty"
48
48
  import {
49
- ColorContentSchema,
50
- DateContentSchema,
51
- NumberContentSchema,
52
- RangeContentSchema,
53
- SelectContentSchema,
54
- TextContentSchema,
55
- TimestampContentSchema,
56
- FieldContentSchema,
49
+ ColorContentSchema as rawColorContentSchema,
50
+ DateContentSchema as rawDateContentSchema,
51
+ NumberContentSchema as rawNumberContentSchema,
52
+ RangeContentSchema as rawRangeContentSchema,
53
+ SelectContentSchema as rawSelectContentSchema,
54
+ TextContentSchema as rawTextContentSchema,
55
+ TimestampContentSchema as rawTimestampContentSchema,
56
+ FieldContentSchema as rawFieldContentSchema,
57
57
  } from "./content/field"
58
- import { GeoPointContentSchema } from "./content/geopoint"
59
- import { GroupContentSchema, GroupItemContentSchema } from "./content/group"
60
- import { ImageContentSchema } from "./content/image"
61
- import { IntegrationFieldContentSchema } from "./content/integrationField"
62
- import { LinkContentSchema } from "./content/link"
63
- import { NestableContentSchema } from "./content/nestable"
64
- import { RepeatableContentSchema } from "./content/repeatable"
58
+ import { GeoPointContentSchema as rawGeoPointContentSchema } from "./content/geopoint"
65
59
  import {
66
- RichTextContentSchema,
67
- RichTextContentBlockSchema,
68
- RichTextContentSpanSchema,
60
+ GroupContentSchema as rawGroupContentSchema,
61
+ GroupItemContentSchema as rawGroupItemContentSchema,
62
+ } from "./content/group"
63
+ import { ImageContentSchema as rawImageContentSchema } from "./content/image"
64
+ import { IntegrationFieldContentSchema as rawIntegrationFieldContentSchema } from "./content/integrationField"
65
+ import { LinkContentSchema as rawLinkContentSchema } from "./content/link"
66
+ import { NestableContentSchema as rawNestableContentSchema } from "./content/nestable"
67
+ import { RepeatableContentSchema as rawRepeatableContentSchema } from "./content/repeatable"
68
+ import {
69
+ RichTextContentSchema as rawRichTextContentSchema,
70
+ RichTextContentBlockSchema as rawRichTextContentBlockSchema,
71
+ RichTextContentSpanSchema as rawRichTextContentSpanSchema,
69
72
  } from "./content/richText"
70
- import { SeparatorContentSchema } from "./content/separator"
73
+ import { SeparatorContentSchema as rawSeparatorContentSchema } from "./content/separator"
71
74
  import {
72
- LegacySliceContentSchema,
73
- CompositeSliceContentSchema,
74
- SharedSliceContentSchema,
75
- SliceContentSchema,
75
+ LegacySliceContentSchema as rawLegacySliceContentSchema,
76
+ CompositeSliceContentSchema as rawCompositeSliceContentSchema,
77
+ SharedSliceContentSchema as rawSharedSliceContentSchema,
78
+ SliceContentSchema as rawSliceContentSchema,
76
79
  } from "./content/slice"
77
80
  import {
78
- LegacySliceItemContentSchema,
79
- CompositeSliceItemContentSchema,
80
- SharedSliceItemContentSchema,
81
- SliceItemContentSchema,
82
- SlicesContentSchema,
81
+ LegacySliceItemContentSchema as rawLegacySliceItemContentSchema,
82
+ CompositeSliceItemContentSchema as rawCompositeSliceItemContentSchema,
83
+ SharedSliceItemContentSchema as rawSharedSliceItemContentSchema,
84
+ SliceItemContentSchema as rawSliceItemContentSchema,
85
+ SlicesContentSchema as rawSlicesContentSchema,
83
86
  } from "./content/slices"
84
- import { TableContentSchema } from "./content/table"
85
- import { UIDContentSchema } from "./content/uid"
86
- import { WidgetContentSchema } from "./content/widget"
87
+ import { TableContentSchema as rawTableContentSchema } from "./content/table"
88
+ import { UIDContentSchema as rawUIDContentSchema } from "./content/uid"
89
+ import { WidgetContentSchema as rawWidgetContentSchema } from "./content/widget"
87
90
  // Model
88
- import { BooleanModelSchema } from "./model/boolean"
89
- import { ColorModelSchema } from "./model/color"
90
- import { StaticCustomTypeModelSchema, CustomTypeModelSchema } from "./model/customType"
91
- import { DateModelSchema } from "./model/date"
92
- import { EmbedModelSchema } from "./model/embed"
93
- import { GeoPointModelSchema } from "./model/geopoint"
94
- import { GroupModelSchema, NestedGroupModelSchema } from "./model/group"
95
- import { ImageModelSchema } from "./model/image"
96
- import { IntegrationFieldModelSchema } from "./model/integrationField"
97
- import { LinkModelSchema } from "./model/link"
98
- import { NestableModelSchema } from "./model/nestable"
99
- import { NumberModelSchema } from "./model/number"
100
- import { RangeModelSchema } from "./model/range"
101
- import { RichTextModelSchema } from "./model/richText"
102
- import { StaticSectionModelSchema, DynamicSectionModelSchema } from "./model/section"
103
- import { SelectModelSchema } from "./model/select"
104
- import { SeparatorModelSchema } from "./model/separator"
91
+ import { BooleanModelSchema as rawBooleanModelSchema } from "./model/boolean"
92
+ import { ColorModelSchema as rawColorModelSchema } from "./model/color"
93
+ import {
94
+ StaticCustomTypeModelSchema as rawStaticCustomTypeModelSchema,
95
+ CustomTypeModelSchema as rawCustomTypeModelSchema,
96
+ } from "./model/customType"
97
+ import { DateModelSchema as rawDateModelSchema } from "./model/date"
98
+ import { EmbedModelSchema as rawEmbedModelSchema } from "./model/embed"
99
+ import { GeoPointModelSchema as rawGeoPointModelSchema } from "./model/geopoint"
100
+ import {
101
+ GroupModelSchema as rawGroupModelSchema,
102
+ NestedGroupModelSchema as rawNestedGroupModelSchema,
103
+ } from "./model/group"
104
+ import { ImageModelSchema as rawImageModelSchema } from "./model/image"
105
+ import { IntegrationFieldModelSchema as rawIntegrationFieldModelSchema } from "./model/integrationField"
106
+ import { LinkModelSchema as rawLinkModelSchema } from "./model/link"
107
+ import { NestableModelSchema as rawNestableModelSchema } from "./model/nestable"
108
+ import { NumberModelSchema as rawNumberModelSchema } from "./model/number"
109
+ import { RangeModelSchema as rawRangeModelSchema } from "./model/range"
110
+ import { RichTextModelSchema as rawRichTextModelSchema } from "./model/richText"
105
111
  import {
106
- LegacySliceModelSchema,
107
- CompositeSliceModelSchema,
108
- SharedSliceModelSchema,
109
- SharedSliceRefModelSchema,
110
- StaticSliceModelSchema,
111
- DynamicSliceModelSchema,
112
+ StaticSectionModelSchema as rawStaticSectionModelSchema,
113
+ DynamicSectionModelSchema as rawDynamicSectionModelSchema,
114
+ } from "./model/section"
115
+ import { SelectModelSchema as rawSelectModelSchema } from "./model/select"
116
+ import { SeparatorModelSchema as rawSeparatorModelSchema } from "./model/separator"
117
+ import {
118
+ LegacySliceModelSchema as rawLegacySliceModelSchema,
119
+ CompositeSliceModelSchema as rawCompositeSliceModelSchema,
120
+ SharedSliceModelSchema as rawSharedSliceModelSchema,
121
+ SharedSliceModelVariationSchema as rawSharedSliceModelVariationSchema,
122
+ SharedSliceRefModelSchema as rawSharedSliceRefModelSchema,
123
+ StaticSliceModelSchema as rawStaticSliceModelSchema,
124
+ DynamicSliceModelSchema as rawDynamicSliceModelSchema,
125
+ SliceContentModelSchema as rawSliceContentModelSchema,
112
126
  } from "./model/slice"
113
- import { DynamicSlicesModelSchema, StaticSlicesModelSchema } from "./model/slices"
114
- import { TableModelSchema } from "./model/table"
115
- import { TextModelSchema } from "./model/text"
116
- import { TimestampModelSchema } from "./model/timestamp"
117
- import { UIDModelSchema } from "./model/uid"
118
- import { StaticWidgetModelSchema, DynamicWidgetModelSchema } from "./model/widget"
127
+ import {
128
+ DynamicSlicesModelSchema as rawDynamicSlicesModelSchema,
129
+ StaticSlicesModelSchema as rawStaticSlicesModelSchema,
130
+ } from "./model/slices"
131
+ import { TableModelSchema as rawTableModelSchema } from "./model/table"
132
+ import { TextModelSchema as rawTextModelSchema } from "./model/text"
133
+ import { TimestampModelSchema as rawTimestampModelSchema } from "./model/timestamp"
134
+ import { UIDModelSchema as rawUIDModelSchema } from "./model/uid"
135
+ import {
136
+ StaticWidgetModelSchema as rawStaticWidgetModelSchema,
137
+ DynamicWidgetModelSchema as rawDynamicWidgetModelSchema,
138
+ } from "./model/widget"
119
139
 
120
140
  // Common
121
- export const Asset = toIOTS(AssetSchema)
122
- export const Embed = toIOTS(EmbedSchema)
123
- export const HexaColorCode = toIOTS(HexaColorCodeSchema)
124
- export const NonEmptyString = toIOTS(NonEmptyStringSchema)
125
- export const WidgetKey = toIOTS(WidgetKeySchema)
141
+ export const AssetSchema = toIOTS(rawAssetSchema)
142
+ export const EmbedSchema = toIOTS(rawEmbedSchema)
143
+ export const HexaColorCodeSchema = toIOTS(rawHexaColorCodeSchema)
144
+ export const NonEmptyStringSchema = toIOTS(rawNonEmptyStringSchema)
145
+ export const WidgetKeySchema = toIOTS(rawWidgetKeySchema)
126
146
 
127
147
  // Content
128
- export const BooleanContent = toIOTS(BooleanContentSchema)
129
- export const ColorContent = toIOTS(ColorContentSchema)
130
- export const DateContent = toIOTS(DateContentSchema)
131
- export const EmptyContent = toIOTS(EmptyContentSchema)
132
- export const GeoPointContent = toIOTS(GeoPointContentSchema)
133
- export const LinkContent = toIOTS(LinkContentSchema)
134
- export const NumberContent = toIOTS(NumberContentSchema)
135
- export const RangeContent = toIOTS(RangeContentSchema)
136
- export const SelectContent = toIOTS(SelectContentSchema)
137
- export const SeparatorContent = toIOTS(SeparatorContentSchema)
138
- export const SharedSliceContent = toIOTS(SharedSliceContentSchema)
139
- export const TextContent = toIOTS(TextContentSchema)
140
- export const TimestampContent = toIOTS(TimestampContentSchema)
141
- export const FieldContent = toIOTS(FieldContentSchema)
142
- export const UIDContent = toIOTS(UIDContentSchema)
143
- export const IntegrationFieldContent = toIOTS(IntegrationFieldContentSchema)
144
- export const EmbedContent = toIOTS(EmbedContentSchema)
145
- export const ImageContent = toIOTS(ImageContentSchema)
146
- export const RichTextContent = toIOTS(RichTextContentSchema)
147
- export const RichTextContentBlock = toIOTS(RichTextContentBlockSchema)
148
- export const RichTextContentSpan = toIOTS(RichTextContentSpanSchema)
149
- export const TableContent = toIOTS(TableContentSchema)
150
- export const RepeatableContent = toIOTS(RepeatableContentSchema)
151
- export const NestableContent = toIOTS(NestableContentSchema)
152
- export const GroupContent = toIOTS(GroupContentSchema)
153
- export const GroupItemContent = toIOTS(GroupItemContentSchema)
154
- export const CompositeSliceContent = toIOTS(CompositeSliceContentSchema)
155
- export const LegacySliceContent = toIOTS(LegacySliceContentSchema)
156
- export const SliceContent = toIOTS(SliceContentSchema)
157
- export const LegacySliceItemContent = toIOTS(LegacySliceItemContentSchema)
158
- export const CompositeSliceItemContent = toIOTS(CompositeSliceItemContentSchema)
159
- export const SharedSliceItemContent = toIOTS(SharedSliceItemContentSchema)
160
- export const SliceItemContent = toIOTS(SliceItemContentSchema)
161
- export const SlicesContent = toIOTS(SlicesContentSchema)
162
- export const WidgetContent = toIOTS(WidgetContentSchema)
163
- export const DocumentContent = toIOTS(DocumentContentSchema)
148
+ export const BooleanContentSchema = toIOTS(rawBooleanContentSchema)
149
+ export const ColorContentSchema = toIOTS(rawColorContentSchema)
150
+ export const DateContentSchema = toIOTS(rawDateContentSchema)
151
+ export const EmptyContentSchema = toIOTS(rawEmptyContentSchema)
152
+ export const GeoPointContentSchema = toIOTS(rawGeoPointContentSchema)
153
+ export const LinkContentSchema = toIOTS(rawLinkContentSchema)
154
+ export const NumberContentSchema = toIOTS(rawNumberContentSchema)
155
+ export const RangeContentSchema = toIOTS(rawRangeContentSchema)
156
+ export const SelectContentSchema = toIOTS(rawSelectContentSchema)
157
+ export const SeparatorContentSchema = toIOTS(rawSeparatorContentSchema)
158
+ export const SharedSliceContentSchema = toIOTS(rawSharedSliceContentSchema)
159
+ export const TextContentSchema = toIOTS(rawTextContentSchema)
160
+ export const TimestampContentSchema = toIOTS(rawTimestampContentSchema)
161
+ export const FieldContentSchema = toIOTS(rawFieldContentSchema)
162
+ export const UIDContentSchema = toIOTS(rawUIDContentSchema)
163
+ export const IntegrationFieldContentSchema = toIOTS(rawIntegrationFieldContentSchema)
164
+ export const EmbedContentSchema = toIOTS(rawEmbedContentSchema)
165
+ export const ImageContentSchema = toIOTS(rawImageContentSchema)
166
+ export const RichTextContentSchema = toIOTS(rawRichTextContentSchema)
167
+ export const RichTextContentBlockSchema = toIOTS(rawRichTextContentBlockSchema)
168
+ export const RichTextContentSpanSchema = toIOTS(rawRichTextContentSpanSchema)
169
+ export const TableContentSchema = toIOTS(rawTableContentSchema)
170
+ export const RepeatableContentSchema = toIOTS(rawRepeatableContentSchema)
171
+ export const NestableContentSchema = toIOTS(rawNestableContentSchema)
172
+ export const GroupContentSchema = toIOTS(rawGroupContentSchema)
173
+ export const GroupItemContentSchema = toIOTS(rawGroupItemContentSchema)
174
+ export const CompositeSliceContentSchema = toIOTS(rawCompositeSliceContentSchema)
175
+ export const LegacySliceContentSchema = toIOTS(rawLegacySliceContentSchema)
176
+ export const SliceContentSchema = toIOTS(rawSliceContentSchema)
177
+ export const LegacySliceItemContentSchema = toIOTS(rawLegacySliceItemContentSchema)
178
+ export const CompositeSliceItemContentSchema = toIOTS(rawCompositeSliceItemContentSchema)
179
+ export const SharedSliceItemContentSchema = toIOTS(rawSharedSliceItemContentSchema)
180
+ export const SliceItemContentSchema = toIOTS(rawSliceItemContentSchema)
181
+ export const SlicesContentSchema = toIOTS(rawSlicesContentSchema)
182
+ export const WidgetContentSchema = toIOTS(rawWidgetContentSchema)
183
+ export const DocumentContentSchema = toIOTS(rawDocumentContentSchema)
164
184
 
165
185
  // Content legacy
166
186
  export const BooleanLegacy = toIOTSCodec(BooleanLegacyCodec)
@@ -195,40 +215,42 @@ export const WidgetLegacy = toIOTSCodec(WidgetLegacyCodec)
195
215
  export const DocumentLegacy = toIOTSCodec(DocumentLegacyCodec)
196
216
 
197
217
  // Model
198
- export const BooleanModel = toIOTS(BooleanModelSchema)
199
- export const ColorModel = toIOTS(ColorModelSchema)
200
- export const DateModel = toIOTS(DateModelSchema)
201
- export const EmbedModel = toIOTS(EmbedModelSchema)
202
- export const GeoPointModel = toIOTS(GeoPointModelSchema)
203
- export const ImageModel = toIOTS(ImageModelSchema)
204
- export const IntegrationFieldModel = toIOTS(IntegrationFieldModelSchema)
205
- export const LinkModel = toIOTS(LinkModelSchema)
206
- export const NestableModel = toIOTS(NestableModelSchema)
207
- export const NumberModel = toIOTS(NumberModelSchema)
208
- export const RangeModel = toIOTS(RangeModelSchema)
209
- export const RichTextModel = toIOTS(RichTextModelSchema)
210
- export const SelectModel = toIOTS(SelectModelSchema)
211
- export const SeparatorModel = toIOTS(SeparatorModelSchema)
212
- export const SharedSliceModel = toIOTS(SharedSliceModelSchema)
213
- export const TableModel = toIOTS(TableModelSchema)
214
- export const TextModel = toIOTS(TextModelSchema)
215
- export const TimestampModel = toIOTS(TimestampModelSchema)
216
- export const UIDModel = toIOTS(UIDModelSchema)
217
- export const GroupModel = toIOTS(GroupModelSchema)
218
- export const NestedGroupModel = toIOTS(NestedGroupModelSchema)
219
- export const SharedSliceRefModel = toIOTS(SharedSliceRefModelSchema)
220
- export const CompositeSliceModel = toIOTS(CompositeSliceModelSchema)
221
- export const LegacySliceModel = toIOTS(LegacySliceModelSchema)
222
- export const DynamicSliceModel = toIOTS(DynamicSliceModelSchema)
223
- export const StaticSliceModel = toIOTS(StaticSliceModelSchema)
224
- export const DynamicSlicesModel = toIOTS(DynamicSlicesModelSchema)
225
- export const StaticSlicesModel = toIOTS(StaticSlicesModelSchema)
226
- export const StaticWidgetModel = toIOTS(StaticWidgetModelSchema)
227
- export const DynamicWidgetModel = toIOTS(DynamicWidgetModelSchema)
228
- export const StaticSectionModel = toIOTS(StaticSectionModelSchema)
229
- export const DynamicSectionModel = toIOTS(DynamicSectionModelSchema)
230
- export const StaticCustomTypeModel = toIOTS(StaticCustomTypeModelSchema)
231
- export const CustomTypeModel = toIOTS(CustomTypeModelSchema)
218
+ export const BooleanModelSchema = toIOTS(rawBooleanModelSchema)
219
+ export const ColorModelSchema = toIOTS(rawColorModelSchema)
220
+ export const DateModelSchema = toIOTS(rawDateModelSchema)
221
+ export const EmbedModelSchema = toIOTS(rawEmbedModelSchema)
222
+ export const GeoPointModelSchema = toIOTS(rawGeoPointModelSchema)
223
+ export const ImageModelSchema = toIOTS(rawImageModelSchema)
224
+ export const IntegrationFieldModelSchema = toIOTS(rawIntegrationFieldModelSchema)
225
+ export const LinkModelSchema = toIOTS(rawLinkModelSchema)
226
+ export const NestableModelSchema = toIOTS(rawNestableModelSchema)
227
+ export const NumberModelSchema = toIOTS(rawNumberModelSchema)
228
+ export const RangeModelSchema = toIOTS(rawRangeModelSchema)
229
+ export const RichTextModelSchema = toIOTS(rawRichTextModelSchema)
230
+ export const SelectModelSchema = toIOTS(rawSelectModelSchema)
231
+ export const SeparatorModelSchema = toIOTS(rawSeparatorModelSchema)
232
+ export const SharedSliceModelSchema = toIOTS(rawSharedSliceModelSchema)
233
+ export const TableModelSchema = toIOTS(rawTableModelSchema)
234
+ export const TextModelSchema = toIOTS(rawTextModelSchema)
235
+ export const TimestampModelSchema = toIOTS(rawTimestampModelSchema)
236
+ export const UIDModelSchema = toIOTS(rawUIDModelSchema)
237
+ export const GroupModelSchema = toIOTS(rawGroupModelSchema)
238
+ export const NestedGroupModelSchema = toIOTS(rawNestedGroupModelSchema)
239
+ export const SharedSliceModelVariationSchema = toIOTS(rawSharedSliceModelVariationSchema)
240
+ export const SharedSliceRefModelSchema = toIOTS(rawSharedSliceRefModelSchema)
241
+ export const CompositeSliceModelSchema = toIOTS(rawCompositeSliceModelSchema)
242
+ export const LegacySliceModelSchema = toIOTS(rawLegacySliceModelSchema)
243
+ export const DynamicSliceModelSchema = toIOTS(rawDynamicSliceModelSchema)
244
+ export const StaticSliceModelSchema = toIOTS(rawStaticSliceModelSchema)
245
+ export const SliceContentModelSchema = toIOTS(rawSliceContentModelSchema)
246
+ export const DynamicSlicesModelSchema = toIOTS(rawDynamicSlicesModelSchema)
247
+ export const StaticSlicesModelSchema = toIOTS(rawStaticSlicesModelSchema)
248
+ export const StaticWidgetModelSchema = toIOTS(rawStaticWidgetModelSchema)
249
+ export const DynamicWidgetModelSchema = toIOTS(rawDynamicWidgetModelSchema)
250
+ export const StaticSectionModelSchema = toIOTS(rawStaticSectionModelSchema)
251
+ export const DynamicSectionModelSchema = toIOTS(rawDynamicSectionModelSchema)
252
+ export const StaticCustomTypeModelSchema = toIOTS(rawStaticCustomTypeModelSchema)
253
+ export const CustomTypeModelSchema = toIOTS(rawCustomTypeModelSchema)
232
254
 
233
255
  function toIOTS<T>(type: ZodMiniType<T>): t.Type<T> {
234
256
  return new t.Type<T>(
@@ -1,4 +1,4 @@
1
- import type { SharedSliceModel, SharedSliceVariation } from "../slice"
1
+ import type { SharedSliceModel, SharedSliceModelVariation } from "../slice"
2
2
  import { type DiffChange, DiffOperation } from "./changes"
3
3
  import { isNotEmpty, toRecord, zipObjects } from "./utils"
4
4
  import { type VariationDiff, VariationComparator } from "./variation"
@@ -41,7 +41,7 @@ export const SliceComparator = {
41
41
 
42
42
  const diffMeta = compareSliceMeta(sliceA, sliceB)
43
43
 
44
- const zippedSlices = zipObjects<SharedSliceVariation>(
44
+ const zippedSlices = zipObjects<SharedSliceModelVariation>(
45
45
  sliceA && toRecord(sliceA.variations, (v) => v.id),
46
46
  sliceB && toRecord(sliceB.variations, (v) => v.id),
47
47
  )
@@ -1,7 +1,7 @@
1
1
  import type { GroupModel } from "../group"
2
2
  import { GroupFieldType } from "../group"
3
3
  import type { NestableModel } from "../nestable"
4
- import type { SharedSliceVariation } from "../slice"
4
+ import type { SharedSliceModelVariation } from "../slice"
5
5
  import { type DiffChange, DiffOperation } from "./changes"
6
6
  import { isNotEmpty, zipObjects } from "./utils"
7
7
  import type {
@@ -10,9 +10,9 @@ import type {
10
10
  SlicePrimaryWidgetDiff,
11
11
  } from "./widgets"
12
12
 
13
- export type VariationMetadata = Omit<SharedSliceVariation, "primary" | "items">
13
+ export type VariationMetadata = Omit<SharedSliceModelVariation, "primary" | "items">
14
14
  export type VariationDiff = DiffChange<
15
- SharedSliceVariation,
15
+ SharedSliceModelVariation,
16
16
  Partial<VariationMetadata> & {
17
17
  primary?: Record<string, SlicePrimaryWidgetDiff>
18
18
  items?: Record<string, NestableWidgetDiff>
@@ -20,8 +20,8 @@ export type VariationDiff = DiffChange<
20
20
  >
21
21
 
22
22
  function compareVariationMeta(
23
- variationA?: SharedSliceVariation,
24
- variationB?: SharedSliceVariation,
23
+ variationA?: SharedSliceModelVariation,
24
+ variationB?: SharedSliceModelVariation,
25
25
  ): Partial<VariationMetadata> {
26
26
  const zippedVariations = zipObjects(variationA, variationB)
27
27
 
@@ -119,8 +119,8 @@ function compareWidgets<TWidget extends NestableModel | GroupModel>(
119
119
 
120
120
  export const VariationComparator = {
121
121
  compare(
122
- variationA?: SharedSliceVariation,
123
- variationB?: SharedSliceVariation,
122
+ variationA?: SharedSliceModelVariation,
123
+ variationB?: SharedSliceModelVariation,
124
124
  ): VariationDiff | undefined {
125
125
  if (variationA && !variationB)
126
126
  return {
@@ -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) ---