Refactor vscode-mssql sql bindings logic to sql bindings ext (#18725)

* wip for refactor of mssql to sql-bindings

* remove STS dependency

* work to bring function over and setup with vscodeMsql APIs

* copy typings from vscode-mssql
This commit is contained in:
Vasu Bhog
2022-03-14 13:07:27 -07:00
committed by GitHub
parent a86301312c
commit 2d1ffeb47c
12 changed files with 627 additions and 81 deletions

View File

@@ -3,12 +3,35 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { getAzdataApi } from './common/utils';
import { ITreeNodeInfo } from 'vscode-mssql';
import { getAzdataApi, getVscodeMssqlApi } from './common/utils';
import { launchAddSqlBindingQuickpick } from './dialogs/addSqlBindingQuickpick';
import { createAzureFunction } from './services/azureFunctionsService';
export async function activate(context: vscode.ExtensionContext): Promise<void> {
const vscodeMssqlApi = await getVscodeMssqlApi();
export function activate(context: vscode.ExtensionContext): void {
void vscode.commands.executeCommand('setContext', 'azdataAvailable', !!getAzdataApi());
// register the add sql binding command
context.subscriptions.push(vscode.commands.registerCommand('sqlBindings.addSqlBinding', async (uri: vscode.Uri | undefined) => { return launchAddSqlBindingQuickpick(uri); }));
// Generate Azure Function command
context.subscriptions.push(vscode.commands.registerCommand('sqlBindings.createAzureFunction', async (node: ITreeNodeInfo) => {
let connectionInfo = node.connectionInfo;
// set the database containing the selected table so it can be used
// for the initial catalog property of the connection string
let newNode: ITreeNodeInfo = node;
while (newNode) {
if (newNode.nodeType === 'Database') {
connectionInfo.database = newNode.metadata.name;
break;
} else {
newNode = newNode.parentNode;
}
}
const connectionDetails = vscodeMssqlApi.createConnectionDetails(connectionInfo);
const connectionString = await vscodeMssqlApi.getConnectionString(connectionDetails, false, false);
await createAzureFunction(connectionString, node.metadata.schema, node.metadata.name);
}));
}
export function deactivate(): void {