@@ -15,25 +15,30 @@ console.log(`Generating JSON Schemas to ${OUT_DIR}...`);
1515
1616let count = 0 ;
1717
18- // Iterate over all exports in the protocol
19- for ( const [ key , value ] of Object . entries ( Protocol ) ) {
20- // Check if it looks like a Zod Schema
21- // Zod schemas usually have a parse method and safeParse method, or we can check instanceof
22- if ( value instanceof z . ZodType ) {
23- const schemaName = key . endsWith ( 'Schema' ) ? key . replace ( 'Schema' , '' ) : key ;
24-
25- // Convert to JSON Schema
26- const jsonSchema = zodToJsonSchema ( value , {
27- name : schemaName ,
28- $refStrategy : "none" // We want self-contained schemas for now, or use 'relative' if we handle refs
29- } ) ;
30-
31- const fileName = `${ schemaName } .json` ;
32- const filePath = path . join ( OUT_DIR , fileName ) ;
33-
34- fs . writeFileSync ( filePath , JSON . stringify ( jsonSchema , null , 2 ) ) ;
35- console . log ( `✓ ${ fileName } ` ) ;
36- count ++ ;
18+ // Protocol now exports namespaces (Data, UI, System, AI, API)
19+ // We need to iterate through each namespace
20+ for ( const [ namespaceName , namespaceExports ] of Object . entries ( Protocol ) ) {
21+ if ( typeof namespaceExports === 'object' && namespaceExports !== null ) {
22+ // Iterate over all exports in each namespace
23+ for ( const [ key , value ] of Object . entries ( namespaceExports ) ) {
24+ // Check if it looks like a Zod Schema
25+ if ( value instanceof z . ZodType ) {
26+ const schemaName = key . endsWith ( 'Schema' ) ? key . replace ( 'Schema' , '' ) : key ;
27+
28+ // Convert to JSON Schema
29+ const jsonSchema = zodToJsonSchema ( value , {
30+ name : schemaName ,
31+ $refStrategy : "none" // We want self-contained schemas for now
32+ } ) ;
33+
34+ const fileName = `${ schemaName } .json` ;
35+ const filePath = path . join ( OUT_DIR , fileName ) ;
36+
37+ fs . writeFileSync ( filePath , JSON . stringify ( jsonSchema , null , 2 ) ) ;
38+ console . log ( `✓ ${ fileName } ` ) ;
39+ count ++ ;
40+ }
41+ }
3742 }
3843}
3944
0 commit comments