diff --git a/extensions/sql-bindings/src/common/azureFunctionsUtils.ts b/extensions/sql-bindings/src/common/azureFunctionsUtils.ts index 6c6af956a6..19263e3a4a 100644 --- a/extensions/sql-bindings/src/common/azureFunctionsUtils.ts +++ b/extensions/sql-bindings/src/common/azureFunctionsUtils.ts @@ -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 */ diff --git a/extensions/sql-bindings/src/test/testUtils.ts b/extensions/sql-bindings/src/test/testUtils.ts index 673a979471..588d84528f 100644 --- a/extensions/sql-bindings/src/test/testUtils.ts +++ b/extensions/sql-bindings/src/test/testUtils.ts @@ -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().object; + } + + promptForFirewallRule(_: string, __: vscodeMssql.IConnectionInfo): Promise { + throw new Error('Method not implemented.'); } sendRequest(_: RequestType, __?: P): Promise { throw new Error('Method not implemented.'); diff --git a/extensions/sql-bindings/src/typings/ref.d.ts b/extensions/sql-bindings/src/typings/ref.d.ts index cfdf5dd135..db9f33609a 100644 --- a/extensions/sql-bindings/src/typings/ref.d.ts +++ b/extensions/sql-bindings/src/typings/ref.d.ts @@ -6,4 +6,5 @@ /// /// /// +/// /// diff --git a/extensions/sql-database-projects/src/models/deploy/deployService.ts b/extensions/sql-database-projects/src/models/deploy/deployService.ts index 2f1d9c6145..6928008a46 100644 --- a/extensions/sql-database-projects/src/models/deploy/deployService.ts +++ b/extensions/sql-database-projects/src/models/deploy/deployService.ts @@ -271,7 +271,8 @@ export class DeployService { typeSystemVersion: undefined, workstationId: undefined, profileName: profile.profileName, - expiresOn: undefined + expiresOn: undefined, + tenantId: undefined }; let connectionUrl = await vscodeMssqlApi.connect(connectionProfile, saveConnectionAndPassword); return connectionUrl; diff --git a/extensions/sql-database-projects/src/typings/ref.d.ts b/extensions/sql-database-projects/src/typings/ref.d.ts index 6137c50b4c..5d0200b735 100644 --- a/extensions/sql-database-projects/src/typings/ref.d.ts +++ b/extensions/sql-database-projects/src/typings/ref.d.ts @@ -7,4 +7,5 @@ /// /// /// +/// /// diff --git a/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts b/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts deleted file mode 100644 index 7a5f03c460..0000000000 --- a/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts +++ /dev/null @@ -1,644 +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'; - - /** - * 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; - - /** - * Service for accessing AzureFunctions functionality - */ - readonly azureFunctions: IAzureFunctionsService; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - } - - /** - * 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; - - /** - * 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; - } - - export interface IDacFxService { - exportBacpac(databaseName: string, packageFilePath: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable; - importBacpac(packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable; - extractDacpac(databaseName: string, packageFilePath: string, applicationName: string, applicationVersion: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable; - createProjectFromDatabase(databaseName: string, targetFilePath: string, applicationName: string, applicationVersion: string, ownerUri: string, extractTarget: ExtractTarget, taskExecutionMode: TaskExecutionMode): Thenable; - deployDacpac(packageFilePath: string, databaseName: string, upgradeExisting: boolean, ownerUri: string, taskExecutionMode: TaskExecutionMode, sqlCommandVariableValues?: Record, deploymentOptions?: DeploymentOptions): Thenable; - generateDeployScript(packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: TaskExecutionMode, sqlCommandVariableValues?: Record, deploymentOptions?: DeploymentOptions): Thenable; - generateDeployPlan(packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable; - getOptionsFromProfile(profilePath: string): Thenable; - validateStreamingJob(packageFilePath: string, createStreamingJobTsql: string): Thenable; - } - - export interface IAzureFunctionsService { - /** - * Adds a SQL Binding to a specified Azure function in a file - * @param bindingType Type of SQL Binding - * @param filePath Path of the file where the Azure Functions are - * @param functionName Name of the function where the SQL Binding is to be added - * @param objectName Name of Object for the SQL Query - * @param connectionStringSetting Setting for the connection string - */ - addSqlBinding(bindingType: BindingType, filePath: string, functionName: string, objectName: string, connectionStringSetting: string): Thenable; - /** - * Gets the names of the Azure functions in the file - * @param filePath Path of the file to get the Azure functions - * @returns array of names of Azure functions in the file - */ - getAzureFunctions(filePath: string): Thenable; - } - - 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 \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; - deploymentOptions?: DeploymentOptions; - ownerUri: string; - taskExecutionMode: TaskExecutionMode; - } - - export interface GenerateDeployScriptParams { - packageFilePath: string; - databaseName: string; - sqlCommandVariableValues?: Record; - 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; - } - - /** - * Azure functions binding type - */ - export const enum BindingType { - input, - output - } - - /** - * Parameters for adding a SQL binding to an Azure function - */ - export interface AddSqlBindingParams { - /** - * Aboslute file path of file to add SQL binding - */ - filePath: string; - - /** - * Name of function to add SQL binding - */ - functionName: string; - - /** - * Name of object to use in SQL binding - */ - objectName: string; - - /** - * Type of Azure function binding - */ - bindingType: BindingType; - - /** - * Name of SQL connection string setting specified in local.settings.json - */ - connectionStringSetting: string; - } - - /** - * Parameters for getting the names of the Azure functions in a file - */ - export interface GetAzureFunctionsParams { - /** - * Absolute file path of file to get Azure functions - */ - filePath: string; - } - - /** - * Result from a get Azure functions request - */ - export interface GetAzureFunctionsResult extends ResultStatus { - /** - * Array of names of Azure functions in the file - */ - azureFunctions: string[]; - } - - /** - * Parameters to initialize a connection to a database - */ - export interface ConnectionDetails { - - options: { [name: string]: any }; - } -} diff --git a/extensions/sql-bindings/src/typings/vscode-azurefunctions.api.d.ts b/extensions/types/vscode-azurefunctions.api.d.ts similarity index 100% rename from extensions/sql-bindings/src/typings/vscode-azurefunctions.api.d.ts rename to extensions/types/vscode-azurefunctions.api.d.ts diff --git a/extensions/sql-bindings/src/typings/vscode-azuretools.api.d.ts b/extensions/types/vscode-azuretools.api.d.ts similarity index 100% rename from extensions/sql-bindings/src/typings/vscode-azuretools.api.d.ts rename to extensions/types/vscode-azuretools.api.d.ts diff --git a/extensions/sql-bindings/src/typings/vscode-mssql.d.ts b/extensions/types/vscode-mssql.d.ts similarity index 85% rename from extensions/sql-bindings/src/typings/vscode-mssql.d.ts rename to extensions/types/vscode-mssql.d.ts index 84045315bb..7510a5c195 100644 --- a/extensions/sql-bindings/src/typings/vscode-mssql.d.ts +++ b/extensions/types/vscode-mssql.d.ts @@ -40,6 +40,11 @@ declare module 'vscode-mssql' { */ readonly schemaCompare: ISchemaCompareService; + /** + * Service for accessing Azure Account functionality + */ + readonly azureAccountService: IAzureAccountService; + /** * 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) @@ -57,6 +62,14 @@ declare module 'vscode-mssql' { */ connect(connectionInfo: IConnectionInfo, saveConnection?: boolean): Promise; + /** + * Prompts the user to add firewall rule if connection failed with a firewall error. + * @param connectionUri The URI of the connection to add firewall rule to. + * @param connectionInfo The connection info + * @returns True if firewall rule added + */ + promptForFirewallRule(connectionUri: string, connectionInfo: IConnectionInfo): Promise; + /** * 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. @@ -296,6 +309,136 @@ declare module 'vscode-mssql' { validateStreamingJob(packageFilePath: string, createStreamingJobTsql: string): Thenable; } + /** + * Represents a tenant information for an account. + */ + export interface Tenant { + id: string; + displayName: string; + userId?: string; + tenantCategory?: string; + } + + /** + * Error that connect method throws if connection fails because of a fire wall rule error. + */ + export interface IFireWallRuleError extends Error { + connectionUri: string; + } + + /** + * Represents a key that identifies an account. + */ + export interface IAccountKey { + /** + * Identifier for the account, unique to the provider + */ + id: string; + /** + * Identifier of the provider + */ + providerId: string; + /** + * Version of the account + */ + accountVersion?: any; + } + + + export enum AccountType { + Microsoft = 'microsoft', + WorkSchool = 'work_school' + } + + /** + * Represents display information for an account. + */ + export interface IAccountDisplayInfo { + /** + * account provider (eg, Work/School vs Microsoft Account) + */ + accountType: AccountType; + /** + * User id that identifies the account, such as "user@contoso.com". + */ + userId: string; + /** + * A display name that identifies the account, such as "User Name". + */ + displayName: string; + /** + * email for AAD + */ + email?: string; + /** + * name of account + */ + name: string; + } + + export interface IAccount { + /** + * The key that identifies the account + */ + key: IAccountKey; + /** + * Display information for the account + */ + displayInfo: IAccountDisplayInfo; + /** + * Custom properties stored with the account + */ + properties: any; + /** + * Indicates if the account needs refreshing + */ + isStale: boolean; + /** + * Indicates if the account is signed in + */ + isSignedIn?: boolean; + } + + export interface TokenKey { + /** + * Account Key - uniquely identifies an account + */ + key: string; + } + export interface AccessToken extends TokenKey { + /** + * Access Token + */ + token: string; + /** + * Access token expiry timestamp + */ + expiresOn?: number; + } + export interface Token extends AccessToken { + /** + * TokenType + */ + tokenType: string; + } + + export interface IAzureAccountService { + /** + * Prompts user to login to Azure and returns the account + */ + addAccount(): Promise; + + /** + * Returns current Azure accounts + */ + getAccounts(): Promise; + + /** + * Returns an access token for given user and tenant + */ + getAccountSecurityToken(account: IAccount, tenantId: string | undefined): Promise; + } + export const enum TaskExecutionMode { execute = 0, script = 1,