@@ -449,29 +449,39 @@ async function loadMetadata(args:{
449449 }
450450 }
451451 if ( ! hasMetadata ) {
452- // If provided user-defined paths
453- if ( resolvePath || resolve ) {
454- await downloadMetadata ( resolvePath || metadataPath , resolve )
455- if ( Sole . metadata . value != null ) return
456- }
457452
458453 // If has registered API client
459454 // Using inject requires use within setup()
460455 const client = args . client ?? inject < JsonServiceClient > ( 'client' )
461- if ( client != null ) {
462- const api = await client . api ( new MetadataApp ( ) )
463- if ( api . succeeded ) {
464- setMetadata ( api . response )
465- }
466- }
467- if ( Sole . metadata . value != null ) return
468-
469- // Default to /metadata/app.json
470- await downloadMetadata ( metadataPath )
456+ await initMetadata ( { client, resolvePath, resolve } )
471457 }
472458 return Sole . metadata . value as any // avoid type explosion in api.d.ts until needed
473459}
474460
461+ export async function initMetadata ( args :{
462+ client ?:JsonServiceClient
463+ resolvePath ?: string ,
464+ resolve ?:( ) => Promise < Response >
465+ } ) {
466+ const { client, resolvePath, resolve } = args
467+ // If provided user-defined paths
468+ if ( resolvePath || resolve ) {
469+ await downloadMetadata ( resolvePath || metadataPath , resolve )
470+ if ( Sole . metadata . value != null ) return
471+ }
472+ if ( client != null ) {
473+ const api = await client . api ( new MetadataApp ( ) )
474+ if ( api . succeeded ) {
475+ setMetadata ( api . response )
476+ }
477+ }
478+ if ( Sole . metadata . value != null ) return
479+
480+ // Default to /metadata/app.json
481+ await downloadMetadata ( metadataPath )
482+ return Sole . metadata . value as any
483+ }
484+
475485/**
476486 * Resolve {MetadataType} for DTO name
477487 * @param name - Find MetadataType by name
0 commit comments