@@ -78,18 +78,17 @@ export const blockItemWrapperSchema = <T extends z.AnyZodObject>(
78
78
export const blockOrSchema = < T extends z . AnyZodObject > (
79
79
schema : T ,
80
80
usesSchema : z . ZodTypeAny = defaultUsesSchema ,
81
- ) => z . union ( [ schema , blockItemWrapperSchema ( schema , usesSchema ) ] ) ;
82
-
83
- export const blockOrDiscriminatedUnionSchema = < T extends z . ZodType > (
84
- schema : T ,
85
- usesSchema : z . ZodTypeAny = defaultUsesSchema ,
86
- ) => z . union ( [ schema , z . object ( {
87
- uses : usesSchema ,
88
- with : z . record ( z . string ( ) ) . optional ( ) ,
89
- // For a discriminated union, we can't easily create a partial version
90
- // So we'll use any for the override
91
- override : z . any ( ) . optional ( ) ,
92
- } ) ] ) ;
81
+ isDiscriminatedUnion ?: boolean ,
82
+ ) => {
83
+ if ( isDiscriminatedUnion ) {
84
+ return z . union ( [ schema , z . object ( {
85
+ uses : usesSchema ,
86
+ with : z . record ( z . string ( ) ) . optional ( ) ,
87
+ override : z . any ( ) . optional ( ) ,
88
+ } ) ] ) ;
89
+ }
90
+ return z . union ( [ schema , blockItemWrapperSchema ( schema , usesSchema ) ] ) ;
91
+ } ;
93
92
94
93
export const commonMetadataSchema = z . object ( {
95
94
tags : z . string ( ) . optional ( ) ,
@@ -126,7 +125,7 @@ export const configYamlSchema = baseConfigYamlSchema.extend({
126
125
. optional ( ) ,
127
126
context : z . array ( blockOrSchema ( contextSchema ) ) . optional ( ) ,
128
127
data : z . array ( blockOrSchema ( dataSchema ) ) . optional ( ) ,
129
- mcpServers : z . array ( blockOrDiscriminatedUnionSchema ( mcpServerSchema ) ) . optional ( ) ,
128
+ mcpServers : z . array ( blockOrSchema ( mcpServerSchema as any , defaultUsesSchema , true ) ) . optional ( ) ,
130
129
rules : z
131
130
. array (
132
131
z . union ( [
@@ -251,4 +250,4 @@ export const configSchema = z.object({
251
250
api_key : z . string ( ) . optional ( ) ,
252
251
} ) ;
253
252
254
- export type Config = z . infer < typeof configSchema > ;
253
+ export type Config = z . infer < typeof configSchema > ;
0 commit comments