@@ -163,7 +163,23 @@ let serverManagerApi: any;
163
163
// Map of the intersystems.server connection specs we have resolved via the API to that extension
164
164
const resolvedConnSpecs = new Map < string , any > ( ) ;
165
165
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
167
183
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
168
184
export function getResolvedConnectionSpec ( key : string , dflt : any ) : any {
169
185
return resolvedConnSpecs . has ( key ) ? resolvedConnSpecs . get ( key ) : dflt ;
@@ -418,15 +434,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
418
434
toCheck . set ( configName , uri ) ;
419
435
} ) ;
420
436
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 ) ;
430
439
checkConnection ( true , uri ) ;
431
440
} ) ;
432
441
0 commit comments