88 */
99
1010import fs from "fs/promises" ;
11+ import type { JSONSchema7 } from "json-schema" ;
1112import path from "path" ;
1213import { fileURLToPath } from "url" ;
13- import type { JSONSchema7 } from "json-schema" ;
1414
1515const __filename = fileURLToPath ( import . meta. url ) ;
1616const __dirname = path . dirname ( __filename ) ;
@@ -663,6 +663,8 @@ interface EventVariant {
663663 className : string ;
664664 dataSchema : JSONSchema7 | null ;
665665 description ?: string ;
666+ stability ?: string ;
667+ deprecated ?: boolean ;
666668}
667669
668670function extractEventVariants ( schema : JSONSchema7 ) : EventVariant [ ] {
@@ -694,6 +696,8 @@ function extractEventVariants(schema: JSONSchema7): EventVariant[] {
694696 className : `${ baseName } Event` ,
695697 dataSchema : dataSchema ?? null ,
696698 description : resolved . description ,
699+ stability : ( variant as unknown as Record < string , unknown > ) . stability as string | undefined ,
700+ deprecated : ( variant as unknown as Record < string , unknown > ) . deprecated === true ,
697701 } ;
698702 } )
699703 . filter ( ( v ) => ! EXCLUDED_EVENT_TYPES . has ( v . typeName ) ) ;
@@ -985,15 +989,18 @@ async function generateEventVariantClass(
985989 if ( variant . description ) {
986990 lines . push ( `/**` ) ;
987991 lines . push ( ` * ${ variant . description } ` ) ;
988- lines . push ( ` *` ) ;
989- lines . push ( ` * @since 1.0.0` ) ;
990- lines . push ( ` */` ) ;
991992 } else {
992993 lines . push ( `/**` ) ;
993994 lines . push ( ` * The {@code ${ variant . typeName } } session event.` ) ;
995+ }
996+ if ( variant . stability === "experimental" ) {
994997 lines . push ( ` *` ) ;
995- lines . push ( ` * @since 1.0.0` ) ;
996- lines . push ( ` */` ) ;
998+ lines . push ( ` * @apiNote This method is experimental and may change in a future version.` ) ;
999+ }
1000+ lines . push ( ` * @since 1.0.0` ) ;
1001+ lines . push ( ` */` ) ;
1002+ if ( variant . deprecated ) {
1003+ lines . push ( `@Deprecated` ) ;
9971004 }
9981005 lines . push ( `@JsonIgnoreProperties(ignoreUnknown = true)` ) ;
9991006 lines . push ( `@JsonInclude(JsonInclude.Include.NON_NULL)` ) ;
@@ -1197,6 +1204,7 @@ interface RpcMethod {
11971204 params : JSONSchema7 | null ;
11981205 result : JSONSchema7 | null ;
11991206 stability ?: string ;
1207+ deprecated ?: boolean ;
12001208}
12011209
12021210function isRpcMethod ( node : unknown ) : node is RpcMethod {
@@ -1322,7 +1330,7 @@ async function generateRpcTypes(schemaPath: string): Promise<void> {
13221330 const paramsClassName = `${ className } Params` ;
13231331 if ( ! generatedClasses . has ( paramsClassName ) ) {
13241332 generatedClasses . set ( paramsClassName , true ) ;
1325- allFiles . push ( await generateRpcDataClass ( paramsClassName , paramsSchema , packageName , packageDir , method . rpcMethod , "params" ) ) ;
1333+ allFiles . push ( await generateRpcDataClass ( paramsClassName , paramsSchema , packageName , packageDir , method . rpcMethod , "params" , method . stability , method . deprecated === true ) ) ;
13261334 }
13271335 }
13281336
@@ -1336,7 +1344,7 @@ async function generateRpcTypes(schemaPath: string): Promise<void> {
13361344 const resultClassName = `${ className } Result` ;
13371345 if ( ! generatedClasses . has ( resultClassName ) ) {
13381346 generatedClasses . set ( resultClassName , true ) ;
1339- allFiles . push ( await generateRpcDataClass ( resultClassName , resultSchema , packageName , packageDir , method . rpcMethod , "result" ) ) ;
1347+ allFiles . push ( await generateRpcDataClass ( resultClassName , resultSchema , packageName , packageDir , method . rpcMethod , "result" , method . stability , method . deprecated === true ) ) ;
13401348 }
13411349 } else if ( resultRefName && resultSchema . type === "string" && resultSchema . enum ) {
13421350 // String enum → register for standalone generation
@@ -1373,7 +1381,9 @@ async function generateRpcDataClass(
13731381 packageName : string ,
13741382 packageDir : string ,
13751383 rpcMethod : string ,
1376- kind : "params" | "result"
1384+ kind : "params" | "result" ,
1385+ stability ?: string ,
1386+ deprecated ?: boolean
13771387) : Promise < string > {
13781388 const nestedTypes = new Map < string , { code : string } > ( ) ;
13791389 const { code, imports } = generateRpcClass ( className , schema , nestedTypes , packageName ) ;
@@ -1403,15 +1413,18 @@ async function generateRpcDataClass(
14031413 if ( schema . description ) {
14041414 lines . push ( `/**` ) ;
14051415 lines . push ( ` * ${ schema . description } ` ) ;
1406- lines . push ( ` *` ) ;
1407- lines . push ( ` * @since 1.0.0` ) ;
1408- lines . push ( ` */` ) ;
14091416 } else {
14101417 lines . push ( `/**` ) ;
14111418 lines . push ( ` * ${ kind === "params" ? "Request parameters" : "Result" } for the {@code ${ rpcMethod } } RPC method.` ) ;
1419+ }
1420+ if ( stability === "experimental" ) {
14121421 lines . push ( ` *` ) ;
1413- lines . push ( ` * @since 1.0.0` ) ;
1414- lines . push ( ` */` ) ;
1422+ lines . push ( ` * @apiNote This method is experimental and may change in a future version.` ) ;
1423+ }
1424+ lines . push ( ` * @since 1.0.0` ) ;
1425+ lines . push ( ` */` ) ;
1426+ if ( deprecated ) {
1427+ lines . push ( `@Deprecated` ) ;
14151428 }
14161429 lines . push ( GENERATED_ANNOTATION ) ;
14171430 lines . push ( code ) ;
@@ -1427,6 +1440,7 @@ async function generateRpcDataClass(
14271440interface RpcMethodNode {
14281441 rpcMethod : string ;
14291442 stability : string ;
1443+ deprecated : boolean ;
14301444 params : JSONSchema7 | null ;
14311445 result : JSONSchema7 | null ;
14321446}
@@ -1447,6 +1461,7 @@ function buildNamespaceTree(node: Record<string, unknown>): NamespaceTree {
14471461 tree . methods . set ( key , {
14481462 rpcMethod : String ( obj . rpcMethod ) ,
14491463 stability : String ( obj . stability ?? "stable" ) ,
1464+ deprecated : obj . deprecated === true ,
14501465 params : ( obj . params as JSONSchema7 ) ?? null ,
14511466 result : ( obj . result as JSONSchema7 ) ?? null ,
14521467 } ) ;
@@ -1588,6 +1603,9 @@ function generateApiMethod(
15881603 }
15891604 lines . push ( ` * @since 1.0.0` ) ;
15901605 lines . push ( ` */` ) ;
1606+ if ( method . deprecated ) {
1607+ lines . push ( ` @Deprecated` ) ;
1608+ }
15911609
15921610 // Signature
15931611 if ( hasExtraParams ) {
0 commit comments