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

@@ -0,0 +1,86 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export interface AzureFunctionsExtensionApi {
apiVersion: string;
revealTreeItem(resourceId: string): Promise<void>;
createFunction(options: ICreateFunctionOptions): Promise<void>;
downloadAppSettings(client: IAppSettingsClient): Promise<void>;
uploadAppSettings(client: IAppSettingsClient, exclude?: (RegExp | string)[]): Promise<void>;
}
export type ProjectLanguage = 'JavaScript' | 'TypeScript' | 'C#' | 'Python' | 'PowerShell' | 'Java';
export type ProjectVersion = '~1' | '~2' | '~3' | '~4';
export interface IAppSettingsClient {
fullName: string;
listApplicationSettings(): Promise<IStringDictionary>;
updateApplicationSettings(appSettings: IStringDictionary): Promise<IStringDictionary>;
}
interface IStringDictionary {
properties?: { [propertyName: string]: string };
}
/**
* The options to use when creating a function. If an option is not specified, the default will be used or the user will be prompted
*/
export interface ICreateFunctionOptions {
/**
* The folder containing the Azure Functions project
*/
folderPath?: string;
/**
* The name of the function
*/
functionName?: string;
/**
* The language of the project
*/
language?: ProjectLanguage;
/**
* A filter specifying the langauges to display when creating a project (if there's not already a project)
*/
languageFilter?: RegExp;
/**
* The version of the project. Defaults to the latest GA version
*/
version?: ProjectVersion;
/**
* The id of the template to use.
* NOTE: The language part of the id is optional. Aka "HttpTrigger" will work just as well as "HttpTrigger-JavaScript"
*/
templateId?: string;
/**
* A case-insensitive object of settings to use for the function
*/
functionSettings?: {
[key: string]: string | undefined
}
/**
* If set to true, it will automatically create a new project without prompting (if there's not already a project). Defaults to false
*/
suppressCreateProjectPrompt?: boolean;
/**
* If set to true, it will not try to open the folder after create finishes. Defaults to false
*/
suppressOpenFolder?: boolean;
/**
* If set, it will automatically select the worker runtime for .NET with the matching targetFramework
*/
targetFramework?: string | string[];
}

View File

@@ -0,0 +1,23 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// For now this file needs to be copied/pasted into your repo if you want the types. Eventually we may put it somewhere more distributable.
export interface AzureExtensionApi {
/**
* The API version for this extension. It should be versioned separately from the extension and ideally remains backwards compatible.
*/
apiVersion: string;
}
export interface AzureExtensionApiProvider {
/**
* Provides the API for an Azure Extension.
*
* @param apiVersionRange The version range of the API you need. Any semver syntax is allowed. For example "1" will return any "1.x.x" version or "1.2" will return any "1.2.x" version
* @throws Error if a matching version is not found.
*/
getApi<T extends AzureExtensionApi>(apiVersionRange: string): T;
}

View File

@@ -84,6 +84,14 @@ declare module 'vscode-mssql' {
* @returns connection string for the connection
*/
getConnectionString(connectionUriOrDetails: string | ConnectionDetails, includePassword?: boolean, includeApplicationName?: boolean): Promise<string>;
/**
* Set connection details for the provided connection info
* Able to use this for getConnectionString requests to STS that require ConnectionDetails type
* @param connectionInfo connection info of the connection
* @returns connection details credentials for the connection
*/
createConnectionDetails(connectionInfo: IConnectionInfo): ConnectionDetails;
}
/**
@@ -120,6 +128,11 @@ declare module 'vscode-mssql' {
*/
accountId: string | undefined;
/**
* tenantId
*/
tenantId: string | undefined;
/**
* The port number to connect to.
*/