@@ -438,54 +438,58 @@ const getAllApisForDomain = async (
438438 ) ;
439439} ;
440440
441- const getEndpointById =
442- ( cacheConfig : Required < CacheConfig > ) =>
443- async (
444- domain : string ,
445- apiDefinitionId : string ,
446- endpointId : EndpointId
447- ) : Promise < {
448- endpoint : ApiDefinition . EndpointDefinition ;
449- nodes : FernNavigation . EndpointNode [ ] ;
450- globalHeaders : ObjectProperty [ ] ;
451- authSchemes : AuthScheme [ ] ;
452- types : Record < TypeId , TypeDefinition > ;
453- } > => {
454- "use cache" ;
455- unstable_cacheTag ( domain , "getEndpointById" , apiDefinitionId , endpointId ) ;
456-
457- const api = await createGetPrunedApiCached ( domain , cacheConfig ) (
458- apiDefinitionId ,
459- {
460- type : "endpoint" ,
461- endpointId,
462- }
463- ) ;
441+ const getEndpointById = async ( {
442+ domain,
443+ apiDefinitionId,
444+ endpointId,
445+ cacheConfig,
446+ } : {
447+ domain : string ;
448+ apiDefinitionId : string ;
449+ endpointId : EndpointId ;
450+ cacheConfig : Required < CacheConfig > ;
451+ } ) : Promise < {
452+ endpoint : ApiDefinition . EndpointDefinition ;
453+ nodes : FernNavigation . EndpointNode [ ] ;
454+ globalHeaders : ObjectProperty [ ] ;
455+ authSchemes : AuthScheme [ ] ;
456+ types : Record < TypeId , TypeDefinition > ;
457+ } > => {
458+ "use cache" ;
459+ unstable_cacheTag ( domain , "getEndpointById" , apiDefinitionId , endpointId ) ;
464460
465- const endpoint = api . endpoints [ endpointId ] ;
466- if ( endpoint == null ) {
467- console . error ( "Could not find endpoint with ID" , endpointId ) ;
468- notFound ( ) ;
461+ const api = await createGetPrunedApiCached ( domain , cacheConfig ) (
462+ apiDefinitionId ,
463+ {
464+ type : "endpoint" ,
465+ endpointId,
469466 }
467+ ) ;
470468
471- const root = await unsafe_getFullRoot ( domain ) ;
472- return {
473- endpoint,
474- nodes : FernNavigation . NodeCollector . collect ( root )
475- . getNodesInOrder ( )
476- . filter ( FernNavigation . hasMetadata )
477- . filter (
478- ( node ) : node is FernNavigation . EndpointNode =>
479- node . type === "endpoint" &&
480- node . apiDefinitionId === api . id &&
481- node . endpointId === endpoint . id
482- ) ,
483- globalHeaders : api . globalHeaders ?? [ ] ,
484- authSchemes :
485- endpoint . auth ?. map ( ( id ) => api . auths [ id ] ) . filter ( isNonNullish ) ?? [ ] ,
486- types : api . types ,
487- } ;
469+ const endpoint = api . endpoints [ endpointId ] ;
470+ if ( endpoint == null ) {
471+ console . error ( "Could not find endpoint with ID" , endpointId ) ;
472+ notFound ( ) ;
473+ }
474+
475+ const root = await unsafe_getFullRoot ( domain ) ;
476+ return {
477+ endpoint,
478+ nodes : FernNavigation . NodeCollector . collect ( root )
479+ . getNodesInOrder ( )
480+ . filter ( FernNavigation . hasMetadata )
481+ . filter (
482+ ( node ) : node is FernNavigation . EndpointNode =>
483+ node . type === "endpoint" &&
484+ node . apiDefinitionId === api . id &&
485+ node . endpointId === endpoint . id
486+ ) ,
487+ globalHeaders : api . globalHeaders ?? [ ] ,
488+ authSchemes :
489+ endpoint . auth ?. map ( ( id ) => api . auths [ id ] ) . filter ( isNonNullish ) ?? [ ] ,
490+ types : api . types ,
488491 } ;
492+ } ;
489493
490494const getEndpointByLocator = async (
491495 domain : string ,
@@ -1036,7 +1040,12 @@ export const createCachedDocsLoader = async (
10361040 getMdxBundlerFiles : ( ) => getMdxBundlerFiles ( config ) ( domain ) ,
10371041 getPrunedApi : cache ( createGetPrunedApiCached ( domain , config ) ) ,
10381042 getEndpointById : cache ( ( apiDefinitionId : string , endpointId : EndpointId ) =>
1039- getEndpointById ( config ) ( domain , apiDefinitionId , endpointId )
1043+ getEndpointById ( {
1044+ domain,
1045+ apiDefinitionId,
1046+ endpointId,
1047+ cacheConfig : config ,
1048+ } )
10401049 ) ,
10411050 getEndpointByLocator : cache (
10421051 unstable_cache (
0 commit comments