@prismicio/types-internal 4.1.0 → 4.2.0-pr.13.0d96267

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 (83) hide show
  1. package/dist/content/field.js +1 -1
  2. package/dist/content/field.js.map +1 -1
  3. package/dist/content/group.d.ts +1 -2
  4. package/dist/content/group.d.ts.map +1 -1
  5. package/dist/content/group.js +1 -1
  6. package/dist/content/group.js.map +1 -1
  7. package/dist/content/legacy/link.d.ts +4 -4
  8. package/dist/content/legacy/link.js +4 -4
  9. package/dist/content/legacy/link.js.map +1 -1
  10. package/dist/content/legacy/richText.d.ts +23 -12
  11. package/dist/content/legacy/richText.d.ts.map +1 -1
  12. package/dist/content/legacy/richText.js +2 -2
  13. package/dist/content/legacy/richText.js.map +1 -1
  14. package/dist/content/link.d.ts +4 -4
  15. package/dist/content/nestable.d.ts +3 -3
  16. package/dist/content/nestable.d.ts.map +1 -1
  17. package/dist/content/nestable.js +3 -9
  18. package/dist/content/nestable.js.map +1 -1
  19. package/dist/content/richText.d.ts +1 -1
  20. package/dist/content/richText.d.ts.map +1 -1
  21. package/dist/content/richText.js +1 -1
  22. package/dist/content/richText.js.map +1 -1
  23. package/dist/content/slice.d.ts +507 -5
  24. package/dist/content/slice.d.ts.map +1 -1
  25. package/dist/content/slice.js +1 -1
  26. package/dist/content/slice.js.map +1 -1
  27. package/dist/content/slices.d.ts +507 -5
  28. package/dist/content/slices.d.ts.map +1 -1
  29. package/dist/content/table.d.ts +5 -2
  30. package/dist/content/table.d.ts.map +1 -1
  31. package/dist/content/widget.js +1 -1
  32. package/dist/content/widget.js.map +1 -1
  33. package/dist/helpers/customTypeModel.d.ts +4 -5
  34. package/dist/helpers/customTypeModel.d.ts.map +1 -1
  35. package/dist/helpers/customTypeModel.js.map +1 -1
  36. package/dist/index.d.ts +6 -7
  37. package/dist/io-ts.d.ts +5138 -1917
  38. package/dist/io-ts.d.ts.map +1 -1
  39. package/dist/io-ts.js +7 -6
  40. package/dist/io-ts.js.map +1 -1
  41. package/dist/model/customType.d.ts +9 -3
  42. package/dist/model/customType.d.ts.map +1 -1
  43. package/dist/model/customType.js +42 -5
  44. package/dist/model/customType.js.map +1 -1
  45. package/dist/model/group.d.ts +2 -2
  46. package/dist/model/group.js +1 -1
  47. package/dist/model/group.js.map +1 -1
  48. package/dist/model/nestable.js +1 -1
  49. package/dist/model/nestable.js.map +1 -1
  50. package/dist/model/slice.d.ts +10 -10
  51. package/dist/model/slice.d.ts.map +1 -1
  52. package/dist/model/slice.js +12 -6
  53. package/dist/model/slice.js.map +1 -1
  54. package/dist/model/widget.d.ts.map +1 -1
  55. package/dist/model/widget.js +2 -2
  56. package/dist/model/widget.js.map +1 -1
  57. package/dist/zod4.d.ts +1814 -249
  58. package/dist/zod4.d.ts.map +1 -1
  59. package/dist/zod4.js +7 -6
  60. package/dist/zod4.js.map +1 -1
  61. package/package.json +9 -6
  62. package/src/content/field.ts +1 -1
  63. package/src/content/group.ts +1 -1
  64. package/src/content/legacy/link.ts +4 -4
  65. package/src/content/legacy/richText.ts +14 -21
  66. package/src/content/nestable.ts +3 -18
  67. package/src/content/richText.ts +9 -6
  68. package/src/content/slice.ts +1 -1
  69. package/src/content/widget.ts +1 -1
  70. package/src/helpers/customTypeModel.ts +8 -5
  71. package/src/index.ts +7 -2
  72. package/src/io-ts.ts +8 -8
  73. package/src/model/customType.ts +72 -17
  74. package/src/model/group.ts +1 -1
  75. package/src/model/nestable.ts +1 -1
  76. package/src/model/slice.ts +36 -25
  77. package/src/model/widget.ts +8 -12
  78. package/src/zod4.ts +8 -8
  79. package/dist/model/section.d.ts +0 -11
  80. package/dist/model/section.d.ts.map +0 -1
  81. package/dist/model/section.js +0 -10
  82. package/dist/model/section.js.map +0 -1
  83. package/src/model/section.ts +0 -12
@@ -33,7 +33,7 @@ import { TextModelSchema } from "./text"
33
33
  import type { TimestampModel } from "./timestamp"
34
34
  import { TimestampModelSchema } from "./timestamp"
35
35
 
36
- export const NestableModelSchema = z.union([
36
+ export const NestableModelSchema = z.discriminatedUnion("type", [
37
37
  BooleanModelSchema,
38
38
  ColorModelSchema,
39
39
  DateModelSchema,
@@ -7,7 +7,7 @@ import type { NestableModel } from "./nestable"
7
7
  import { NestableModelSchema } from "./nestable"
8
8
 
9
9
  // Simple (before 2020)
10
- export const LegacySliceModelSchema: z.ZodMiniType<LegacySliceModel> = z.union([
10
+ export const LegacySliceModelSchema = z.discriminatedUnion("type", [
11
11
  NestableModelSchema,
12
12
  NestedGroupModelSchema,
13
13
  ])
@@ -51,7 +51,9 @@ export const SharedSliceModelVariationSchema = z.object({
51
51
  primary: z.optional(
52
52
  z.record(
53
53
  z.string(),
54
- z.union([NestableModelSchema, GroupModelSchema]) as z.ZodMiniType<NestableModel | GroupModel>,
54
+ z.discriminatedUnion("type", [NestableModelSchema, GroupModelSchema]) as z.ZodMiniType<
55
+ NestableModel | GroupModel
56
+ >,
55
57
  ),
56
58
  ),
57
59
  items: z.optional(z.record(z.string(), NestableModelSchema)),
@@ -59,14 +61,26 @@ export const SharedSliceModelVariationSchema = z.object({
59
61
 
60
62
  export type SharedSliceModelVariation = z.infer<typeof SharedSliceModelVariationSchema>
61
63
 
62
- export const SharedSliceModelSchema = z.object({
63
- id: z.string(),
64
- type: z.literal(SharedSliceType),
65
- name: z.string(),
66
- variations: z.array(SharedSliceModelVariationSchema),
67
- description: z.optional(z.string()),
68
- legacyPaths: z.optional(z.record(z.string(), z.string())),
69
- })
64
+ export const SharedSliceModelSchema = z
65
+ .object({
66
+ id: z.string(),
67
+ type: z.literal(SharedSliceType),
68
+ name: z.string(),
69
+ variations: z.array(SharedSliceModelVariationSchema),
70
+ description: z.optional(z.string()),
71
+ legacyPaths: z.optional(z.record(z.string(), z.string())),
72
+ })
73
+ .check(
74
+ z.superRefine((model, ctx) => {
75
+ if (model.variations.length === 0) {
76
+ ctx.addIssue({
77
+ code: "custom",
78
+ message: `Shared slice "${model.id}" must have at least one variation`,
79
+ path: ["variations"],
80
+ })
81
+ }
82
+ }),
83
+ )
70
84
 
71
85
  export type SharedSliceModel = z.infer<typeof SharedSliceModelSchema>
72
86
 
@@ -92,30 +106,27 @@ export type SharedSliceVariationContentModel = z.infer<
92
106
  // All
93
107
 
94
108
  // Used when slices reference SharedSlice by ref (not full definition)
95
- export const DynamicSliceModelSchema: z.ZodMiniType<DynamicSliceModel> = z.union([
96
- CompositeSliceModelSchema,
97
- LegacySliceModelSchema,
98
- SharedSliceRefModelSchema,
99
- ])
109
+ export const DynamicSliceModelSchema: z.ZodMiniType<DynamicSliceModel> = z.discriminatedUnion(
110
+ "type",
111
+ [CompositeSliceModelSchema, LegacySliceModelSchema, SharedSliceRefModelSchema],
112
+ )
100
113
 
101
114
  export type DynamicSliceModel = CompositeSliceModel | LegacySliceModel | SharedSliceRefModel
102
115
 
103
116
  // Used when slices include full SharedSlice definition
104
- export const StaticSliceModelSchema: z.ZodMiniType<StaticSliceModel> = z.union([
105
- CompositeSliceModelSchema,
106
- LegacySliceModelSchema,
107
- SharedSliceModelSchema,
108
- ])
117
+ export const StaticSliceModelSchema: z.ZodMiniType<StaticSliceModel> = z.discriminatedUnion(
118
+ "type",
119
+ [CompositeSliceModelSchema, LegacySliceModelSchema, SharedSliceModelSchema],
120
+ )
109
121
 
110
122
  export type StaticSliceModel = CompositeSliceModel | LegacySliceModel | SharedSliceModel
111
123
 
112
124
  // Used to represent a slice content model as shared slice variations
113
125
  // can only be of a given shared slice variation type.
114
- export const SliceContentModelSchema: z.ZodMiniType<SliceContentModel> = z.union([
115
- CompositeSliceModelSchema,
116
- LegacySliceModelSchema,
117
- SharedSliceVariationContentModelSchema,
118
- ])
126
+ export const SliceContentModelSchema: z.ZodMiniType<SliceContentModel> = z.discriminatedUnion(
127
+ "type",
128
+ [CompositeSliceModelSchema, LegacySliceModelSchema, SharedSliceVariationContentModelSchema],
129
+ )
119
130
 
120
131
  export type SliceContentModel =
121
132
  | CompositeSliceModel
@@ -11,22 +11,18 @@ import type { UIDModel } from "./uid"
11
11
  import { UIDModelSchema } from "./uid"
12
12
 
13
13
  // StaticWidget = UID | Nestable | Group | StaticSlices
14
- export const StaticWidgetModelSchema: z.ZodMiniType<StaticWidgetModel> = z.union([
15
- UIDModelSchema,
16
- NestableModelSchema,
17
- GroupModelSchema,
18
- StaticSlicesModelSchema,
19
- ])
14
+ export const StaticWidgetModelSchema: z.ZodMiniType<StaticWidgetModel> = z.discriminatedUnion(
15
+ "type",
16
+ [UIDModelSchema, NestableModelSchema, GroupModelSchema, StaticSlicesModelSchema],
17
+ )
20
18
 
21
19
  export type StaticWidgetModel = UIDModel | NestableModel | GroupModel | StaticSlicesModel
22
20
 
23
21
  // DynamicWidget = UID | Nestable | Group | DynamicSlices
24
- export const DynamicWidgetModelSchema: z.ZodMiniType<DynamicWidgetModel> = z.union([
25
- UIDModelSchema,
26
- NestableModelSchema,
27
- GroupModelSchema,
28
- DynamicSlicesModelSchema,
29
- ])
22
+ export const DynamicWidgetModelSchema: z.ZodMiniType<DynamicWidgetModel> = z.discriminatedUnion(
23
+ "type",
24
+ [UIDModelSchema, NestableModelSchema, GroupModelSchema, DynamicSlicesModelSchema],
25
+ )
30
26
 
31
27
  export type DynamicWidgetModel = UIDModel | NestableModel | GroupModel | DynamicSlicesModel
32
28
 
package/src/zod4.ts CHANGED
@@ -63,7 +63,9 @@ import { BooleanModelSchema as rawBooleanModelSchema } from "./model/boolean"
63
63
  import { ColorModelSchema as rawColorModelSchema } from "./model/color"
64
64
  import {
65
65
  StaticCustomTypeModelSchema as rawStaticCustomTypeModelSchema,
66
- CustomTypeModelSchema as rawCustomTypeModelSchema,
66
+ DynamicCustomTypeModelSchema as rawDynamicCustomTypeModelSchema,
67
+ StaticCustomTypeModelTabSchema as rawStaticCustomTypeModelTabSchema,
68
+ DynamicCustomTypeModelTabSchema as rawDynamicCustomTypeModelTabSchema,
67
69
  } from "./model/customType"
68
70
  import { DateModelSchema as rawDateModelSchema } from "./model/date"
69
71
  import { EmbedModelSchema as rawEmbedModelSchema } from "./model/embed"
@@ -79,10 +81,6 @@ import { NestableModelSchema as rawNestableModelSchema } from "./model/nestable"
79
81
  import { NumberModelSchema as rawNumberModelSchema } from "./model/number"
80
82
  import { RangeModelSchema as rawRangeModelSchema } from "./model/range"
81
83
  import { RichTextModelSchema as rawRichTextModelSchema } from "./model/richText"
82
- import {
83
- StaticSectionModelSchema as rawStaticSectionModelSchema,
84
- DynamicSectionModelSchema as rawDynamicSectionModelSchema,
85
- } from "./model/section"
86
84
  import { SelectModelSchema as rawSelectModelSchema } from "./model/select"
87
85
  import { SeparatorModelSchema as rawSeparatorModelSchema } from "./model/separator"
88
86
  import {
@@ -189,10 +187,12 @@ export const DynamicSlicesModelSchema = toZod4(rawDynamicSlicesModelSchema)
189
187
  export const StaticSlicesModelSchema = toZod4(rawStaticSlicesModelSchema)
190
188
  export const StaticWidgetModelSchema = toZod4(rawStaticWidgetModelSchema)
191
189
  export const DynamicWidgetModelSchema = toZod4(rawDynamicWidgetModelSchema)
192
- export const StaticSectionModelSchema = toZod4(rawStaticSectionModelSchema)
193
- export const DynamicSectionModelSchema = toZod4(rawDynamicSectionModelSchema)
190
+ export const StaticCustomTypeModelTabSchema = toZod4(rawStaticCustomTypeModelTabSchema)
191
+ export const DynamicCustomTypeModelTabSchema = toZod4(rawDynamicCustomTypeModelTabSchema)
194
192
  export const StaticCustomTypeModelSchema = toZod4(rawStaticCustomTypeModelSchema)
195
- export const CustomTypeModelSchema = toZod4(rawCustomTypeModelSchema)
193
+ export const DynamicCustomTypeModelSchema = toZod4(rawDynamicCustomTypeModelSchema)
194
+ /** @deprecated Use DynamicCustomTypeModelSchema instead */
195
+ export const CustomTypeModelSchema = DynamicCustomTypeModelSchema
196
196
 
197
197
  function toZod4<T>(type: T): T {
198
198
  return type
@@ -1,11 +0,0 @@
1
- import { DynamicWidgetModel, StaticWidgetModel } from "./widget.js";
2
- import { z } from "zod/mini";
3
-
4
- //#region src/model/section.d.ts
5
- declare const StaticSectionModelSchema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniType<StaticWidgetModel, unknown, z.core.$ZodTypeInternals<StaticWidgetModel, unknown>>>;
6
- type StaticSectionModel = z.infer<typeof StaticSectionModelSchema>;
7
- declare const DynamicSectionModelSchema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniType<DynamicWidgetModel, unknown, z.core.$ZodTypeInternals<DynamicWidgetModel, unknown>>>;
8
- type DynamicSectionModel = z.infer<typeof DynamicSectionModelSchema>;
9
- //#endregion
10
- export { DynamicSectionModel, StaticSectionModel };
11
- //# sourceMappingURL=section.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"section.d.ts","names":[],"sources":["../../src/model/section.ts"],"mappings":";;;;cAMa,wBAAA,EAAwB,CAAA,CAAA,aAAA,CAAA,CAAA,CAAA,aAAA,UAAA,CAAA,CAAA,WAAA,CAAA,iBAAA,WAAA,CAAA,CAAA,IAAA,CAAA,iBAAA,CAAA,iBAAA;AAAA,KACzB,kBAAA,GAAqB,CAAA,CAAE,KAAA,QAAa,wBAAA;AAAA,cAGnC,yBAAA,EAAyB,CAAA,CAAA,aAAA,CAAA,CAAA,CAAA,aAAA,UAAA,CAAA,CAAA,WAAA,CAAA,kBAAA,WAAA,CAAA,CAAA,IAAA,CAAA,iBAAA,CAAA,kBAAA;AAAA,KAC1B,mBAAA,GAAsB,CAAA,CAAE,KAAA,QAAa,yBAAA"}
@@ -1,10 +0,0 @@
1
- import { WidgetKeySchema } from "../common/widgetKey.js";
2
- import { DynamicWidgetModelSchema, StaticWidgetModelSchema } from "./widget.js";
3
- import { z } from "zod/mini";
4
- //#region src/model/section.ts
5
- const StaticSectionModelSchema = z.record(WidgetKeySchema, StaticWidgetModelSchema);
6
- const DynamicSectionModelSchema = z.record(WidgetKeySchema, DynamicWidgetModelSchema);
7
- //#endregion
8
- export { DynamicSectionModelSchema, StaticSectionModelSchema };
9
-
10
- //# sourceMappingURL=section.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"section.js","names":[],"sources":["../../src/model/section.ts"],"sourcesContent":["import { z } from \"zod/mini\"\n\nimport { WidgetKeySchema } from \"../common/widgetKey\"\nimport { DynamicWidgetModelSchema, StaticWidgetModelSchema } from \"./widget\"\n\n// StaticSection = Record<WidgetKey, StaticWidget>\nexport const StaticSectionModelSchema = z.record(WidgetKeySchema, StaticWidgetModelSchema)\nexport type StaticSectionModel = z.infer<typeof StaticSectionModelSchema>\n\n// DynamicSection = Record<WidgetKey, DynamicWidget>\nexport const DynamicSectionModelSchema = z.record(WidgetKeySchema, DynamicWidgetModelSchema)\nexport type DynamicSectionModel = z.infer<typeof DynamicSectionModelSchema>\n"],"mappings":";;;;AAMA,MAAa,2BAA2B,EAAE,OAAO,iBAAiB,wBAAwB;AAI1F,MAAa,4BAA4B,EAAE,OAAO,iBAAiB,yBAAyB"}
@@ -1,12 +0,0 @@
1
- import { z } from "zod/mini"
2
-
3
- import { WidgetKeySchema } from "../common/widgetKey"
4
- import { DynamicWidgetModelSchema, StaticWidgetModelSchema } from "./widget"
5
-
6
- // StaticSection = Record<WidgetKey, StaticWidget>
7
- export const StaticSectionModelSchema = z.record(WidgetKeySchema, StaticWidgetModelSchema)
8
- export type StaticSectionModel = z.infer<typeof StaticSectionModelSchema>
9
-
10
- // DynamicSection = Record<WidgetKey, DynamicWidget>
11
- export const DynamicSectionModelSchema = z.record(WidgetKeySchema, DynamicWidgetModelSchema)
12
- export type DynamicSectionModel = z.infer<typeof DynamicSectionModelSchema>