@@ -163,7 +163,23 @@ let serverManagerApi: any;
163163// Map of the intersystems.server connection specs we have resolved via the API to that extension
164164const resolvedConnSpecs = new Map < string , any > ( ) ;
165165
166- // Accessor for the connection specs
166+ /**
167+ * If servermanager extension is available, fetch the connection spec unless already cached.
168+ * Prompt for credentials if necessary.
169+ * @param serverName authority element of an isfs uri, or `objectscript.conn.server` property
170+ */
171+ export async function resolveConnectionSpec ( serverName : string ) : Promise < void > {
172+ if ( serverManagerApi && serverManagerApi . getServerSpec ) {
173+ if ( serverName && serverName !== "" && ! resolvedConnSpecs . has ( serverName ) ) {
174+ const connSpec = await serverManagerApi . getServerSpec ( serverName ) ;
175+ if ( connSpec ) {
176+ resolvedConnSpecs . set ( serverName , connSpec ) ;
177+ }
178+ }
179+ }
180+ }
181+
182+ // Accessor for the cache of resolved connection specs
167183// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
168184export function getResolvedConnectionSpec ( key : string , dflt : any ) : any {
169185 return resolvedConnSpecs . has ( key ) ? resolvedConnSpecs . get ( key ) : dflt ;
@@ -418,15 +434,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
418434 toCheck . set ( configName , uri ) ;
419435 } ) ;
420436 toCheck . forEach ( async function ( uri , configName ) {
421- if ( serverManagerApi && serverManagerApi . getServerSpec ) {
422- const serverName = uri . scheme === "file" ? config ( "conn" , configName ) . server : configName ;
423- if ( serverName && serverName !== "" && ! resolvedConnSpecs . has ( serverName ) ) {
424- const connSpec = await serverManagerApi . getServerSpec ( serverName ) ;
425- if ( connSpec ) {
426- resolvedConnSpecs . set ( serverName , connSpec ) ;
427- }
428- }
429- }
437+ const serverName = uri . scheme === "file" ? config ( "conn" , configName ) . server : configName ;
438+ await resolveConnectionSpec ( serverName ) ;
430439 checkConnection ( true , uri ) ;
431440 } ) ;
432441
0 commit comments