@@ -57,7 +57,10 @@ async function getSchemaPath(): Promise<string> {
5757async function generateTypeScriptTypes ( schemaPath : string ) {
5858 console . log ( "🔄 Generating TypeScript types from JSON Schema..." ) ;
5959
60- const ts = await compile ( JSON . parse ( await fs . readFile ( schemaPath , "utf-8" ) ) , "SessionEvent" , {
60+ const schema = JSON . parse ( await fs . readFile ( schemaPath , "utf-8" ) ) as JSONSchema7 ;
61+ const processedSchema = postProcessSchema ( schema ) ;
62+
63+ const ts = await compile ( processedSchema , "SessionEvent" , {
6164 bannerComment : `/**
6265 * AUTO-GENERATED FILE - DO NOT EDIT
6366 *
@@ -84,9 +87,15 @@ async function generateTypeScriptTypes(schemaPath: string) {
8487 console . log ( `✅ Generated TypeScript types: ${ outputPath } ` ) ;
8588}
8689
90+ /**
91+ * Event types to exclude from generation (internal/legacy types)
92+ */
93+ const EXCLUDED_EVENT_TYPES = new Set ( [ "session.import_legacy" ] ) ;
94+
8795/**
8896 * Post-process JSON Schema to make it compatible with quicktype
8997 * Converts boolean const values to enum with single value
98+ * Filters out excluded event types
9099 */
91100function postProcessSchema ( schema : JSONSchema7 ) : JSONSchema7 {
92101 if ( typeof schema !== "object" || schema === null ) {
@@ -126,12 +135,21 @@ function postProcessSchema(schema: JSONSchema7): JSONSchema7 {
126135 }
127136 }
128137
129- // Process anyOf, allOf, oneOf
138+ // Process anyOf, allOf, oneOf - also filter out excluded event types
130139 for ( const combiner of [ "anyOf" , "allOf" , "oneOf" ] as const ) {
131140 if ( processed [ combiner ] ) {
132- processed [ combiner ] = processed [ combiner ] ! . map ( ( item ) =>
133- typeof item === "object" ? postProcessSchema ( item as JSONSchema7 ) : item
134- ) as JSONSchema7Definition [ ] ;
141+ processed [ combiner ] = processed [ combiner ] !
142+ . filter ( ( item ) => {
143+ if ( typeof item !== "object" ) return true ;
144+ const typeConst = ( item as JSONSchema7 ) . properties ?. type ;
145+ if ( typeof typeConst === "object" && "const" in typeConst ) {
146+ return ! EXCLUDED_EVENT_TYPES . has ( typeConst . const as string ) ;
147+ }
148+ return true ;
149+ } )
150+ . map ( ( item ) =>
151+ typeof item === "object" ? postProcessSchema ( item as JSONSchema7 ) : item
152+ ) as JSONSchema7Definition [ ] ;
135153 }
136154 }
137155
0 commit comments