From a322c5be9dfcd9d0ce667d0c19a8afbe6c555cfa Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 20 Jul 2021 13:30:32 -0700 Subject: [PATCH] List connections for sql proj publish quickpick (#16233) * List connections for sql proj publish quickpick * cleanup --- .../sql-database-projects/src/common/utils.ts | 10 +- .../src/dialogs/publishDatabaseQuickpick.ts | 7 +- .../src/typings/vscode-mssql.d.ts | 171 ++++++++++++++++++ 3 files changed, 181 insertions(+), 7 deletions(-) diff --git a/extensions/sql-database-projects/src/common/utils.ts b/extensions/sql-database-projects/src/common/utils.ts index 9b77014ce8..92df925983 100644 --- a/extensions/sql-database-projects/src/common/utils.ts +++ b/extensions/sql-database-projects/src/common/utils.ts @@ -256,16 +256,20 @@ export type IDacFxService = mssql.IDacFxService | vscodeMssql.IDacFxService; export async function getDacFxService(): Promise { if (getAzdataApi()) { - let ext = vscode.extensions.getExtension(mssql.extension.name) as vscode.Extension; + const ext = vscode.extensions.getExtension(mssql.extension.name) as vscode.Extension; const api = await ext.activate(); return api.dacFx; } else { - let ext = vscode.extensions.getExtension(vscodeMssql.extension.name) as vscode.Extension; - const api = await ext.activate(); + const api = await getVscodeMssqlApi(); return api.dacFx; } } +export async function getVscodeMssqlApi(): Promise { + const ext = vscode.extensions.getExtension(vscodeMssql.extension.name) as vscode.Extension; + return ext.activate(); +} + /* * Returns the default deployment options from DacFx */ diff --git a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts index 5e0b58d9d5..66f1106672 100644 --- a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts +++ b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts @@ -9,6 +9,7 @@ import { IGenerateScriptSettings, IPublishSettings } from '../models/IPublishSet import { Project } from '../models/project'; import { PublishProfile, readPublishProfile } from '../models/publishProfile/publishProfile'; import { promptForPublishProfile } from './publishDatabaseDialog'; +import { getVscodeMssqlApi } from '../common/utils'; /** * Create flow for Publishing a database using only VS Code-native APIs such as QuickPick @@ -70,10 +71,8 @@ export async function launchPublishDatabaseQuickpick(project: Project): Promise< } // 2. Select connection - // TODO@chgagnon: Hook up to MSSQL - const connectionProfile = await vscode.window.showQuickPick( - ['Connection 1', 'Connection 2', 'Create New Connection'], - { title: constants.selectConnection, ignoreFocusOut: true }); + const api = await getVscodeMssqlApi(); + const connectionProfile = await api.promptForConnection(); if (!connectionProfile) { return; } diff --git a/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts b/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts index d0fc4f7b64..448b768086 100644 --- a/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts +++ b/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts @@ -21,7 +21,178 @@ declare module 'vscode-mssql' { */ export interface IExtension { + /** + * Service for accessing DacFx functionality + */ readonly dacFx: IDacFxService; + + /** + * Prompts the user to select an existing connection or create a new one, and then returns the result + */ + promptForConnection(): Promise + } + + /** + * Information about a database connection + */ + export interface IConnectionInfo { + /** + * server name + */ + server: string; + + /** + * database name + */ + database: string; + + /** + * user name + */ + user: string; + + /** + * password + */ + password: string; + + /** + * email + */ + email: string; + + /** + * accountId + */ + accountId: string; + + /** + * The port number to connect to. + */ + port: number; + + /** + * Gets or sets the authentication to use. + */ + authenticationType: string; + + /** + * Gets or sets the azure account token to use. + */ + azureAccountToken: string; + + /** + * Gets or sets a Boolean value that indicates whether SQL Server uses SSL encryption for all data sent between the client and server if + * the server has a certificate installed. + */ + encrypt: boolean; + + /** + * Gets or sets a value that indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust. + */ + trustServerCertificate: boolean; + + /** + * Gets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection + * if the connection is open or has ever been in an open state. + */ + persistSecurityInfo: boolean; + + /** + * Gets or sets the length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. + */ + connectTimeout: number; + + /** + * The number of reconnections attempted after identifying that there was an idle connection failure. + */ + connectRetryCount: number; + + /** + * Amount of time (in seconds) between each reconnection attempt after identifying that there was an idle connection failure. + */ + connectRetryInterval: number; + + /** + * Gets or sets the name of the application associated with the connection string. + */ + applicationName: string; + + /** + * Gets or sets the name of the workstation connecting to SQL Server. + */ + workstationId: string; + + /** + * Declares the application workload type when connecting to a database in an SQL Server Availability Group. + */ + applicationIntent: string; + + /** + * Gets or sets the SQL Server Language record name. + */ + currentLanguage: string; + + /** + * Gets or sets a Boolean value that indicates whether the connection will be pooled or explicitly opened every time that the connection is requested. + */ + pooling: boolean; + + /** + * Gets or sets the maximum number of connections allowed in the connection pool for this specific connection string. + */ + maxPoolSize: number; + + /** + * Gets or sets the minimum number of connections allowed in the connection pool for this specific connection string. + */ + minPoolSize: number; + + /** + * Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before being destroyed. + */ + loadBalanceTimeout: number; + + /** + * Gets or sets a Boolean value that indicates whether replication is supported using the connection. + */ + replication: boolean; + + /** + * Gets or sets a string that contains the name of the primary data file. This includes the full path name of an attachable database. + */ + attachDbFilename: string; + + /** + * Gets or sets the name or address of the partner server to connect to if the primary server is down. + */ + failoverPartner: string; + + /** + * If your application is connecting to an AlwaysOn availability group (AG) on different subnets, setting MultiSubnetFailover=true + * provides faster detection of and connection to the (currently) active server. + */ + multiSubnetFailover: boolean; + + /** + * When true, an application can maintain multiple active result sets (MARS). + */ + multipleActiveResultSets: boolean; + + /** + * Gets or sets the size in bytes of the network packets used to communicate with an instance of SQL Server. + */ + packetSize: number; + + /** + * Gets or sets a string value that indicates the type system the application expects. + */ + typeSystemVersion: string; + + /** + * Gets or sets the connection string to use for this connection. + */ + connectionString: string; } export const enum ExtractTarget {