Consolidate extension typings files (#18765)

* Consolidate extension typings files

* fix
This commit is contained in:
Charles Gagnon
2022-03-18 09:24:22 -07:00
committed by GitHub
parent b07266e8c2
commit a6d442bb3b
9 changed files with 155 additions and 647 deletions

View File

@@ -11,9 +11,9 @@ import * as constants from './constants';
import { BindingType } from 'sql-bindings';
import { ConnectionDetails, IConnectionInfo } from 'vscode-mssql';
// https://github.com/microsoft/vscode-azurefunctions/blob/main/src/vscode-azurefunctions.api.d.ts
import { AzureFunctionsExtensionApi } from '../typings/vscode-azurefunctions.api';
import { AzureFunctionsExtensionApi } from '../../../types/vscode-azurefunctions.api';
// https://github.com/microsoft/vscode-azuretools/blob/main/ui/api.d.ts
import { AzureExtensionApiProvider } from '../typings/vscode-azuretools.api';
import { AzureExtensionApiProvider } from '../../../types/vscode-azuretools.api';
/**
* Represents the settings in an Azure function project's locawl.settings.json file
*/

View File

@@ -236,10 +236,16 @@ export class MockVscodeMssqlIExtension implements vscodeMssql.IExtension {
sqlToolsServicePath: string = '';
dacFx: vscodeMssql.IDacFxService;
schemaCompare: vscodeMssql.ISchemaCompareService;
azureAccountService: vscodeMssql.IAzureAccountService;
constructor() {
this.dacFx = new MockDacFxMssqlService;
this.schemaCompare = new MockSchemaCompareService;
this.azureAccountService = TypeMoq.Mock.ofType<vscodeMssql.IAzureAccountService>().object;
}
promptForFirewallRule(_: string, __: vscodeMssql.IConnectionInfo): Promise<boolean> {
throw new Error('Method not implemented.');
}
sendRequest<P, R, E, R0>(_: RequestType<P, R, E, R0>, __?: P): Promise<R> {
throw new Error('Method not implemented.');

View File

@@ -6,4 +6,5 @@
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/sql/azdata.d.ts'/>
/// <reference path='../../../../src/sql/azdata.proposed.d.ts'/>
/// <reference path='../../../types/vscode-mssql.d.ts'/>
/// <reference types='@types/node'/>

View File

@@ -1,86 +0,0 @@
/*---------------------------------------------------------------------------------------------
* 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

@@ -1,23 +0,0 @@
/*---------------------------------------------------------------------------------------------
* 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

@@ -1,585 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode-mssql' {
import * as vscode from 'vscode';
import { RequestType } from 'vscode-languageclient';
/**
* Covers defining what the vscode-mssql extension exports to other extensions
*
* IMPORTANT: THIS IS NOT A HARD DEFINITION unlike vscode; therefore no enums or classes should be defined here
* (const enums get evaluated when typescript -> javascript so those are fine)
*/
export const enum extension {
name = 'ms-mssql.mssql'
}
/**
* The APIs provided by Mssql extension
*/
export interface IExtension {
/**
* Path to the root of the SQL Tools Service folder
*/
readonly sqlToolsServicePath: string;
/**
* Service for accessing DacFx functionality
*/
readonly dacFx: IDacFxService;
/**
* Service for accessing SchemaCompare functionality
*/
readonly schemaCompare: ISchemaCompareService;
/**
* Prompts the user to select an existing connection or create a new one, and then returns the result
* @param ignoreFocusOut Whether the quickpick prompt ignores focus out (default false)
*/
promptForConnection(ignoreFocusOut?: boolean): Promise<IConnectionInfo | undefined>;
/**
* Attempts to create a new connection for the given connection info. An error is thrown and displayed
* to the user if an error occurs while connecting.
* Warning: setting the saveConnection to true will save a new connection profile each time this is called.
* Make sure to use that parameter only when you want to actually save a new profile.
* @param connectionInfo The connection info
* @param saveConnection Save the connection profile if sets to true
* @returns The URI associated with this connection
*/
connect(connectionInfo: IConnectionInfo, saveConnection?: boolean): Promise<string>;
/**
* Lists the databases for a given connection. Must be given an already-opened connection to succeed.
* @param connectionUri The URI of the connection to list the databases for.
* @returns The list of database names
*/
listDatabases(connectionUri: string): Promise<string[]>;
/**
* Gets the database name for the node - which is the database name of the connection for a server node, the database name
* for nodes at or under a database node or a default value if it's neither of those.
* @param node The node to get the database name of
* @returns The database name
*/
getDatabaseNameFromTreeNode(node: ITreeNodeInfo): string;
/**
* Get the connection string for the provided connection Uri or connection details.
* @param connectionUriOrDetails Either the connection Uri for the connection or the connection details for the connection is required.
* @param includePassword (optional) if password should be included in connection string.
* @param includeApplicationName (optional) if application name should be included in connection string.
* @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;
/**
* Send a request to the SQL Tools Server client
* @param requestType The type of the request
* @param params The params to pass with the request
* @returns A promise object for when the request receives a response
*/
sendRequest<P, R, E, R0>(requestType: RequestType<P, R, E, R0>, params?: P): Promise<R>;
}
/**
* 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 | undefined;
/**
* accountId
*/
accountId: string | undefined;
/**
* tenantId
*/
tenantId: string | undefined;
/**
* 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 | undefined;
/**
* Access token expiry timestamp
*/
expiresOn: number | undefined;
/**
* 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 | undefined;
/**
* 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 | undefined;
/**
* 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 | undefined;
/**
* The number of reconnections attempted after identifying that there was an idle connection failure.
*/
connectRetryCount: number | undefined;
/**
* Amount of time (in seconds) between each reconnection attempt after identifying that there was an idle connection failure.
*/
connectRetryInterval: number | undefined;
/**
* Gets or sets the name of the application associated with the connection string.
*/
applicationName: string | undefined;
/**
* Gets or sets the name of the workstation connecting to SQL Server.
*/
workstationId: string | undefined;
/**
* Declares the application workload type when connecting to a database in an SQL Server Availability Group.
*/
applicationIntent: string | undefined;
/**
* Gets or sets the SQL Server Language record name.
*/
currentLanguage: string | undefined;
/**
* 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 | undefined;
/**
* Gets or sets the maximum number of connections allowed in the connection pool for this specific connection string.
*/
maxPoolSize: number | undefined;
/**
* Gets or sets the minimum number of connections allowed in the connection pool for this specific connection string.
*/
minPoolSize: number | undefined;
/**
* Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before being destroyed.
*/
loadBalanceTimeout: number | undefined;
/**
* Gets or sets a Boolean value that indicates whether replication is supported using the connection.
*/
replication: boolean | undefined;
/**
* 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 | undefined;
/**
* Gets or sets the name or address of the partner server to connect to if the primary server is down.
*/
failoverPartner: string | undefined;
/**
* 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 | undefined;
/**
* When true, an application can maintain multiple active result sets (MARS).
*/
multipleActiveResultSets: boolean | undefined;
/**
* Gets or sets the size in bytes of the network packets used to communicate with an instance of SQL Server.
*/
packetSize: number | undefined;
/**
* Gets or sets a string value that indicates the type system the application expects.
*/
typeSystemVersion: string | undefined;
/**
* Gets or sets the connection string to use for this connection.
*/
connectionString: string | undefined;
}
export const enum ExtractTarget {
dacpac = 0,
file = 1,
flat = 2,
objectType = 3,
schema = 4,
schemaObjectType = 5
}
export interface ISchemaCompareService {
schemaCompareGetDefaultOptions(): Thenable<SchemaCompareOptionsResult>;
}
export interface IDacFxService {
exportBacpac(databaseName: string, packageFilePath: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable<DacFxResult>;
importBacpac(packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable<DacFxResult>;
extractDacpac(databaseName: string, packageFilePath: string, applicationName: string, applicationVersion: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable<DacFxResult>;
createProjectFromDatabase(databaseName: string, targetFilePath: string, applicationName: string, applicationVersion: string, ownerUri: string, extractTarget: ExtractTarget, taskExecutionMode: TaskExecutionMode): Thenable<DacFxResult>;
deployDacpac(packageFilePath: string, databaseName: string, upgradeExisting: boolean, ownerUri: string, taskExecutionMode: TaskExecutionMode, sqlCommandVariableValues?: Record<string, string>, deploymentOptions?: DeploymentOptions): Thenable<DacFxResult>;
generateDeployScript(packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: TaskExecutionMode, sqlCommandVariableValues?: Record<string, string>, deploymentOptions?: DeploymentOptions): Thenable<DacFxResult>;
generateDeployPlan(packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable<GenerateDeployPlanResult>;
getOptionsFromProfile(profilePath: string): Thenable<DacFxOptionsResult>;
validateStreamingJob(packageFilePath: string, createStreamingJobTsql: string): Thenable<ValidateStreamingJobResult>;
}
export const enum TaskExecutionMode {
execute = 0,
script = 1,
executeAndScript = 2
}
export interface DeploymentOptions {
ignoreTableOptions: boolean;
ignoreSemicolonBetweenStatements: boolean;
ignoreRouteLifetime: boolean;
ignoreRoleMembership: boolean;
ignoreQuotedIdentifiers: boolean;
ignorePermissions: boolean;
ignorePartitionSchemes: boolean;
ignoreObjectPlacementOnPartitionScheme: boolean;
ignoreNotForReplication: boolean;
ignoreLoginSids: boolean;
ignoreLockHintsOnIndexes: boolean;
ignoreKeywordCasing: boolean;
ignoreIndexPadding: boolean;
ignoreIndexOptions: boolean;
ignoreIncrement: boolean;
ignoreIdentitySeed: boolean;
ignoreUserSettingsObjects: boolean;
ignoreFullTextCatalogFilePath: boolean;
ignoreWhitespace: boolean;
ignoreWithNocheckOnForeignKeys: boolean;
verifyCollationCompatibility: boolean;
unmodifiableObjectWarnings: boolean;
treatVerificationErrorsAsWarnings: boolean;
scriptRefreshModule: boolean;
scriptNewConstraintValidation: boolean;
scriptFileSize: boolean;
scriptDeployStateChecks: boolean;
scriptDatabaseOptions: boolean;
scriptDatabaseCompatibility: boolean;
scriptDatabaseCollation: boolean;
runDeploymentPlanExecutors: boolean;
registerDataTierApplication: boolean;
populateFilesOnFileGroups: boolean;
noAlterStatementsToChangeClrTypes: boolean;
includeTransactionalScripts: boolean;
includeCompositeObjects: boolean;
allowUnsafeRowLevelSecurityDataMovement: boolean;
ignoreWithNocheckOnCheckConstraints: boolean;
ignoreFillFactor: boolean;
ignoreFileSize: boolean;
ignoreFilegroupPlacement: boolean;
doNotAlterReplicatedObjects: boolean;
doNotAlterChangeDataCaptureObjects: boolean;
disableAndReenableDdlTriggers: boolean;
deployDatabaseInSingleUserMode: boolean;
createNewDatabase: boolean;
compareUsingTargetCollation: boolean;
commentOutSetVarDeclarations: boolean;
blockWhenDriftDetected: boolean;
blockOnPossibleDataLoss: boolean;
backupDatabaseBeforeChanges: boolean;
allowIncompatiblePlatform: boolean;
allowDropBlockingAssemblies: boolean;
dropConstraintsNotInSource: boolean;
dropDmlTriggersNotInSource: boolean;
dropExtendedPropertiesNotInSource: boolean;
dropIndexesNotInSource: boolean;
ignoreFileAndLogFilePath: boolean;
ignoreExtendedProperties: boolean;
ignoreDmlTriggerState: boolean;
ignoreDmlTriggerOrder: boolean;
ignoreDefaultSchema: boolean;
ignoreDdlTriggerState: boolean;
ignoreDdlTriggerOrder: boolean;
ignoreCryptographicProviderFilePath: boolean;
verifyDeployment: boolean;
ignoreComments: boolean;
ignoreColumnCollation: boolean;
ignoreAuthorizer: boolean;
ignoreAnsiNulls: boolean;
generateSmartDefaults: boolean;
dropStatisticsNotInSource: boolean;
dropRoleMembersNotInSource: boolean;
dropPermissionsNotInSource: boolean;
dropObjectsNotInSource: boolean;
ignoreColumnOrder: boolean;
doNotDropObjectTypes: SchemaObjectType[];
excludeObjectTypes: SchemaObjectType[];
}
/**
* Values from <DacFx>\Product\Source\DeploymentApi\ObjectTypes.cs
*/
export const enum SchemaObjectType {
Aggregates = 0,
ApplicationRoles = 1,
Assemblies = 2,
AssemblyFiles = 3,
AsymmetricKeys = 4,
BrokerPriorities = 5,
Certificates = 6,
ColumnEncryptionKeys = 7,
ColumnMasterKeys = 8,
Contracts = 9,
DatabaseOptions = 10,
DatabaseRoles = 11,
DatabaseTriggers = 12,
Defaults = 13,
ExtendedProperties = 14,
ExternalDataSources = 15,
ExternalFileFormats = 16,
ExternalTables = 17,
Filegroups = 18,
Files = 19,
FileTables = 20,
FullTextCatalogs = 21,
FullTextStoplists = 22,
MessageTypes = 23,
PartitionFunctions = 24,
PartitionSchemes = 25,
Permissions = 26,
Queues = 27,
RemoteServiceBindings = 28,
RoleMembership = 29,
Rules = 30,
ScalarValuedFunctions = 31,
SearchPropertyLists = 32,
SecurityPolicies = 33,
Sequences = 34,
Services = 35,
Signatures = 36,
StoredProcedures = 37,
SymmetricKeys = 38,
Synonyms = 39,
Tables = 40,
TableValuedFunctions = 41,
UserDefinedDataTypes = 42,
UserDefinedTableTypes = 43,
ClrUserDefinedTypes = 44,
Users = 45,
Views = 46,
XmlSchemaCollections = 47,
Audits = 48,
Credentials = 49,
CryptographicProviders = 50,
DatabaseAuditSpecifications = 51,
DatabaseEncryptionKeys = 52,
DatabaseScopedCredentials = 53,
Endpoints = 54,
ErrorMessages = 55,
EventNotifications = 56,
EventSessions = 57,
LinkedServerLogins = 58,
LinkedServers = 59,
Logins = 60,
MasterKeys = 61,
Routes = 62,
ServerAuditSpecifications = 63,
ServerRoleMembership = 64,
ServerRoles = 65,
ServerTriggers = 66,
ExternalStreams = 67,
ExternalStreamingJobs = 68
}
/**
* ResultStatus from d.ts
*/
export interface ResultStatus {
success: boolean;
errorMessage: string;
}
export interface DacFxResult extends ResultStatus {
operationId: string;
}
export interface GenerateDeployPlanResult extends DacFxResult {
report: string;
}
export interface DacFxOptionsResult extends ResultStatus {
deploymentOptions: DeploymentOptions;
}
export interface ValidateStreamingJobResult extends ResultStatus { }
export interface ExportParams {
databaseName: string;
packageFilePath: string;
ownerUri: string;
taskExecutionMode: TaskExecutionMode;
}
export interface ImportParams {
packageFilePath: string;
databaseName: string;
ownerUri: string;
taskExecutionMode: TaskExecutionMode;
}
export interface ExtractParams {
databaseName: string;
packageFilePath: string;
applicationName: string;
applicationVersion: string;
ownerUri: string;
extractTarget?: ExtractTarget;
taskExecutionMode: TaskExecutionMode;
}
export interface DeployParams {
packageFilePath: string;
databaseName: string;
upgradeExisting: boolean;
sqlCommandVariableValues?: Record<string, string>;
deploymentOptions?: DeploymentOptions;
ownerUri: string;
taskExecutionMode: TaskExecutionMode;
}
export interface GenerateDeployScriptParams {
packageFilePath: string;
databaseName: string;
sqlCommandVariableValues?: Record<string, string>;
deploymentOptions?: DeploymentOptions;
ownerUri: string;
taskExecutionMode: TaskExecutionMode;
}
export interface GenerateDeployPlanParams {
packageFilePath: string;
databaseName: string;
ownerUri: string;
taskExecutionMode: TaskExecutionMode;
}
export interface GetOptionsFromProfileParams {
profilePath: string;
}
export interface ValidateStreamingJobParams {
packageFilePath: string;
createStreamingJobTsql: string;
}
export interface SchemaCompareGetOptionsParams { }
export interface SchemaCompareOptionsResult extends ResultStatus {
defaultDeploymentOptions: DeploymentOptions;
}
export interface ITreeNodeInfo extends vscode.TreeItem {
readonly connectionInfo: IConnectionInfo;
nodeType: string;
metadata: ObjectMetadata;
parentNode: ITreeNodeInfo;
}
export const enum MetadataType {
Table = 0,
View = 1,
SProc = 2,
Function = 3
}
export interface ObjectMetadata {
metadataType: MetadataType;
metadataTypeName: string;
urn: string;
name: string;
schema: string;
parentName?: string;
parentTypeName?: string;
}
/**
* Parameters to initialize a connection to a database
*/
export interface ConnectionDetails {
options: { [name: string]: any };
}
}