@@ -91,8 +91,20 @@ ensureDir(OUT_DIR);
9191console . log ( `Generating JSON Schemas to ${ OUT_DIR } ...` ) ;
9292
9393let count = 0 ;
94+ let skippedCount = 0 ;
9495let errorCount = 0 ;
9596
97+ // Error messages for schema types that inherently cannot be represented in JSON Schema.
98+ // These are expected warnings, not build-breaking errors.
99+ const KNOWN_UNSUPPORTED_PATTERNS = [
100+ 'cannot be represented in JSON Schema' ,
101+ ] ;
102+
103+ function isKnownUnsupported ( error : unknown ) : boolean {
104+ const msg = error instanceof Error ? error . message : String ( error ) ;
105+ return KNOWN_UNSUPPORTED_PATTERNS . some ( ( p ) => msg . includes ( p ) ) ;
106+ }
107+
96108// Protocol now exports namespaces (Data, UI, System, AI, API)
97109// We need to iterate through each namespace
98110for ( const [ namespaceName , namespaceExports ] of Object . entries ( Protocol ) ) {
@@ -126,21 +138,33 @@ for (const [namespaceName, namespaceExports] of Object.entries(Protocol)) {
126138 const filePath = path . join ( categoryDir , fileName ) ;
127139
128140 writeFileWithRetry ( filePath , JSON . stringify ( jsonSchema , null , 2 ) ) ;
129- console . log ( `✓ ${ namespaceName . toLowerCase ( ) } /${ fileName } ` ) ;
141+ console . log ( ` ✓ ${ namespaceName . toLowerCase ( ) } /${ fileName } ` ) ;
130142 count ++ ;
131143 } catch ( error ) {
132- console . error ( `Failed to generate schema for ${ namespaceName } .${ key } :` , error ) ;
133- errorCount ++ ;
144+ if ( isKnownUnsupported ( error ) ) {
145+ // Functions, transforms, Date types etc. have no JSON Schema representation — skip gracefully
146+ const msg = error instanceof Error ? error . message : String ( error ) ;
147+ console . warn ( ` ⊘ ${ namespaceName } .${ key } : ${ msg } (skipped)` ) ;
148+ skippedCount ++ ;
149+ } else {
150+ console . error ( ` ✗ Failed to generate schema for ${ namespaceName } .${ key } :` , error ) ;
151+ errorCount ++ ;
152+ }
134153 }
135154 }
136155 }
137156 }
138157}
139158
159+ console . log ( `\n─── Summary ───` ) ;
160+ console . log ( ` Generated: ${ count } ` ) ;
161+ if ( skippedCount > 0 ) {
162+ console . log ( ` Skipped: ${ skippedCount } (unsupported types: function, transform, date)` ) ;
163+ }
164+
140165if ( errorCount > 0 ) {
141- console . error ( `\n❌ Completed with ${ errorCount } error(s). ${ count } schemas generated successfully.` ) ;
142- console . error ( `\nNote: Partial schema generation occurred. Some schemas may be missing.` ) ;
143- console . error ( `This typically indicates a Zod schema definition error or file system issue.` ) ;
166+ console . error ( ` Errors: ${ errorCount } ` ) ;
167+ console . error ( `\n❌ Build failed with ${ errorCount } unexpected error(s).` ) ;
144168 process . exit ( 1 ) ;
145169}
146170
0 commit comments