diff --git a/extensions/azurecore/src/account-provider/azureAccountProvider.ts b/extensions/azurecore/src/account-provider/azureAccountProvider.ts index 47eb193b2d..e3f6ae7adf 100644 --- a/extensions/azurecore/src/account-provider/azureAccountProvider.ts +++ b/extensions/azurecore/src/account-provider/azureAccountProvider.ts @@ -433,6 +433,7 @@ export class AzureAccountProvider implements azdata.AccountProvider { name: tokenResponse.userId, displayInfo: { accountType: accountType, + userId: tokenResponse.userId, contextualDisplayName: contextualDisplayName, displayName: displayName }, diff --git a/extensions/azurecore/src/test/azureResource/providers/database/databaseTreeDataProvider.test.ts b/extensions/azurecore/src/test/azureResource/providers/database/databaseTreeDataProvider.test.ts index eeaade48bf..bee44c4a3a 100644 --- a/extensions/azurecore/src/test/azureResource/providers/database/databaseTreeDataProvider.test.ts +++ b/extensions/azurecore/src/test/azureResource/providers/database/databaseTreeDataProvider.test.ts @@ -32,7 +32,8 @@ const mockAccount: azdata.Account = { displayInfo: { displayName: 'mock_account@test.com', accountType: 'Microsoft', - contextualDisplayName: 'test' + contextualDisplayName: 'test', + userId: 'test@email.com' }, properties: undefined, isStale: false diff --git a/extensions/azurecore/src/test/azureResource/providers/databaseServer/databaseServerTreeDataProvider.test.ts b/extensions/azurecore/src/test/azureResource/providers/databaseServer/databaseServerTreeDataProvider.test.ts index be601e3a86..ed055d0375 100644 --- a/extensions/azurecore/src/test/azureResource/providers/databaseServer/databaseServerTreeDataProvider.test.ts +++ b/extensions/azurecore/src/test/azureResource/providers/databaseServer/databaseServerTreeDataProvider.test.ts @@ -32,7 +32,8 @@ const mockAccount: azdata.Account = { displayInfo: { displayName: 'mock_account@test.com', accountType: 'Microsoft', - contextualDisplayName: 'test' + contextualDisplayName: 'test', + userId: 'test@email.com' }, properties: undefined, isStale: false diff --git a/extensions/azurecore/src/test/azureResource/resourceService.test.ts b/extensions/azurecore/src/test/azureResource/resourceService.test.ts index a7ac1ee90c..b8f10817a5 100644 --- a/extensions/azurecore/src/test/azureResource/resourceService.test.ts +++ b/extensions/azurecore/src/test/azureResource/resourceService.test.ts @@ -23,7 +23,8 @@ const mockAccount: azdata.Account = { displayInfo: { displayName: 'mock_account@test.com', accountType: 'Microsoft', - contextualDisplayName: 'test' + contextualDisplayName: 'test', + userId: 'test@email.com' }, properties: undefined, isStale: false diff --git a/extensions/azurecore/src/test/azureResource/resourceTreeNode.test.ts b/extensions/azurecore/src/test/azureResource/resourceTreeNode.test.ts index 15a98d3cab..b73f0a2368 100644 --- a/extensions/azurecore/src/test/azureResource/resourceTreeNode.test.ts +++ b/extensions/azurecore/src/test/azureResource/resourceTreeNode.test.ts @@ -26,7 +26,8 @@ const mockAccount: azdata.Account = { displayInfo: { displayName: 'mock_account@test.com', accountType: 'Microsoft', - contextualDisplayName: 'test' + contextualDisplayName: 'test', + userId: 'test@email.com' }, properties: undefined, isStale: false diff --git a/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts b/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts index 46a8d87aab..67fedb2518 100644 --- a/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts +++ b/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts @@ -50,7 +50,8 @@ const mockAccount: azdata.Account = { displayInfo: { displayName: 'mock_account@test.com', accountType: 'Microsoft', - contextualDisplayName: 'test' + contextualDisplayName: 'test', + userId: 'test@email.com' }, properties: { tenants: [ diff --git a/extensions/azurecore/src/test/azureResource/tree/subscriptionTreeNode.test.ts b/extensions/azurecore/src/test/azureResource/tree/subscriptionTreeNode.test.ts index 87d92e703f..84c9236220 100644 --- a/extensions/azurecore/src/test/azureResource/tree/subscriptionTreeNode.test.ts +++ b/extensions/azurecore/src/test/azureResource/tree/subscriptionTreeNode.test.ts @@ -40,7 +40,8 @@ const mockAccount: azdata.Account = { displayInfo: { displayName: 'mock_account@test.com', accountType: 'Microsoft', - contextualDisplayName: 'test' + contextualDisplayName: 'test', + userId: 'test@email.com' }, properties: undefined, isStale: false diff --git a/extensions/azurecore/src/test/azureResource/tree/treeProvider.test.ts b/extensions/azurecore/src/test/azureResource/tree/treeProvider.test.ts index 1d89c2daea..c1aa52baf6 100644 --- a/extensions/azurecore/src/test/azureResource/tree/treeProvider.test.ts +++ b/extensions/azurecore/src/test/azureResource/tree/treeProvider.test.ts @@ -38,7 +38,8 @@ const mockAccount1: azdata.Account = { displayInfo: { displayName: 'mock_account_1@test.com', accountType: 'Microsoft', - contextualDisplayName: 'test' + contextualDisplayName: 'test', + userId: 'test@email.com' }, properties: undefined, isStale: false @@ -51,7 +52,8 @@ const mockAccount2: azdata.Account = { displayInfo: { displayName: 'mock_account_2@test.com', accountType: 'Microsoft', - contextualDisplayName: 'test' + contextualDisplayName: 'test', + userId: 'test@email.com' }, properties: undefined, isStale: false diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index cbc583d338..342fd7e8e0 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -2055,9 +2055,14 @@ declare module 'azdata' { accountType: string; /** - * A display name that identifies the account, such as "user@contoso.com". + * A display name that identifies the account, such as "User Name". */ displayName: string; + + /** + * User id that identifies the account, such as "user@contoso.com". + */ + userId: string; } /** diff --git a/src/sql/platform/accounts/browser/accountListRenderer.ts b/src/sql/platform/accounts/browser/accountListRenderer.ts index 14ae74b698..f35523e078 100644 --- a/src/sql/platform/accounts/browser/accountListRenderer.ts +++ b/src/sql/platform/accounts/browser/accountListRenderer.ts @@ -69,7 +69,14 @@ export class AccountPickerListRenderer implements IListRenderer; - - /** - * Closes the flyout dialog opened by {@link beginAutoOAuthDeviceCode} - */ - export function endAutoOAuthDeviceCode(): void; - - /** - * Notifies the account management service that an account has updated (usually due to the - * account going stale). - * @param {Account} updatedAccount Account object with updated properties - */ - export function accountUpdated(updatedAccount: Account): void; - - /** - * Gets all added accounts. - * @returns {Thenable} Promise to return the accounts - */ - export function getAllAccounts(): Thenable; - - /** - * Generates a security token by asking the account's provider - * @param {Account} account Account to generate security token for (defaults to - * AzureResource.ResourceManagement if not given) - * @return {Thenable<{}>} Promise to return the security token - */ - export function getSecurityToken(account: Account, resource?: AzureResource): Thenable<{}>; - - /** - * An [event](#Event) which fires when the accounts have changed. - */ - export const onDidChangeAccounts: vscode.Event; - } - - /** - * Represents display information for an account. - */ - export interface AccountDisplayInfo { - /** - * A display name that offers context for the account, such as "Contoso". - */ - contextualDisplayName: string; - - /** - * account provider (eg, Work/School vs Microsoft Account) - */ - accountType: string; - - /** - * A display name that identifies the account, such as "user@contoso.com". - */ - displayName: string; - } - - /** - * Represents a key that identifies an account. - */ - export interface AccountKey { - /** - * Identifier of the provider - */ - providerId: string; - - /** - * Any arguments that identify an instantiation of the provider - */ - providerArgs?: any; - - /** - * Identifier for the account, unique to the provider - */ - accountId: string; - } - - /** - * Represents an account. - */ - export interface Account { - /** - * The key that identifies the account - */ - key: AccountKey; - - /** - * Display information for the account - */ - displayInfo: AccountDisplayInfo; - - /** - * Custom properties stored with the account - */ - properties: any; - - /** - * Indicates if the account needs refreshing - */ - isStale: boolean; - } - export enum AzureResource { ResourceManagement = 0, Sql = 1 } - export interface DidChangeAccountsParams { - // Updated accounts - accounts: Account[]; - } - - // - ACCOUNT PROVIDER ////////////////////////////////////////////////// - /** - * Error to be used when the user has cancelled the prompt or refresh methods. When - * AccountProvider.refresh or AccountProvider.prompt are rejected with this error, the error - * will not be reported to the user. - */ - export interface UserCancelledSignInError extends Error { - /** - * Type guard for differentiating user cancelled sign in errors from other errors - */ - userCancelledSignIn: boolean; - } - - /** - * Represents a provider of accounts. - */ - export interface AccountProviderMetadata { - /** - * The identifier of the provider - */ - id: string; - - /** - * Display name of the provider - */ - displayName: string; - - /** - * Any arguments that identify an instantiation of the provider - */ - args?: any; - - /** - * Optional settings that identify an instantiation of a provider - */ - settings?: {}; - } - - /** - * Represents a provider of accounts for use with the account management service - */ - export interface AccountProvider { - /** - * Initializes the account provider with the accounts restored from the memento, - * @param {Account[]} storedAccounts Accounts restored from the memento - * @return {Thenable} Account objects after being rehydrated (if necessary) - */ - initialize(storedAccounts: Account[]): Thenable; - - /** - * Generates a security token for the provided account - * @param {Account} account The account to generate a security token for - * @param {AzureResource} resource The resource to get the token for - * @return {Thenable<{}>} Promise to return a security token object - */ - getSecurityToken(account: Account, resource: AzureResource): Thenable<{}>; - - /** - * Prompts the user to enter account information. - * Returns an error if the user canceled the operation. - */ - prompt(): Thenable; - - /** - * Refreshes a stale account. - * Returns an error if the user canceled the operation. - * Otherwise, returns a new updated account instance. - * @param account - An account. - */ - refresh(account: Account): Thenable; - - /** - * Clears sensitive information for an account. To be called when account is removed - * @param accountKey - Key that uniquely identifies the account to clear - */ - clear(accountKey: AccountKey): Thenable; - - /** - * Called from the account management service when the user has cancelled an auto OAuth - * authorization process. Implementations should use this to cancel any polling process - * and call the end OAuth method. - */ - autoOAuthCancelled(): Thenable; - } - - // Resource provider interfaces ----------------------------------------------------------------------- - - // - ACCOUNT PROVIDER ////////////////////////////////////////////////// - /** - * Represents a provider of accounts. - */ - export interface ResourceProviderMetadata { - /** - * The identifier of the provider - */ - id: string; - - /** - * Display name of the provider - */ - displayName: string; - - /** - * Optional settings that identify an instantiation of a provider - */ - settings?: {}; - } - - export namespace resources { - /** - * Registers a resource provider that can suport - */ - export function registerResourceProvider(providerMetadata: ResourceProviderMetadata, provider: ResourceProvider): vscode.Disposable; - } - - /** - * Represents a provider of resource - */ - export interface ResourceProvider { - createFirewallRule(account: Account, firewallruleInfo: FirewallRuleInfo): Thenable; - handleFirewallRule(errorCode: number, errorMessage: string, connectionTypeId: string): Thenable; - } - - export interface FirewallRuleInfo { - startIpAddress: string; - endIpAddress: string; - serverName: string; - securityTokenMappings: {}; - } - - export interface CreateFirewallRuleResponse { - result: boolean; - errorMessage: string; - } - - export interface HandleFirewallRuleResponse { - result: boolean; - ipAddress: string; - } - export interface ModalDialog { /** * Title of the webview. diff --git a/src/sql/workbench/api/node/sqlExtHost.api.impl.ts b/src/sql/workbench/api/node/sqlExtHost.api.impl.ts index 9c0e2a4fff..d58e8a0f12 100644 --- a/src/sql/workbench/api/node/sqlExtHost.api.impl.ts +++ b/src/sql/workbench/api/node/sqlExtHost.api.impl.ts @@ -531,30 +531,6 @@ export function createApiFactory( // "sqlops" namespace provided for back-compat only, add new interfaces to "azdata" sqlopsFactory: function (extension: IExtensionDescription): typeof sqlops { - // namespace: accounts - const accounts: typeof sqlops.accounts = { - registerAccountProvider(providerMetadata: sqlops.AccountProviderMetadata, provider: sqlops.AccountProvider): vscode.Disposable { - return extHostAccountManagement.$registerAccountProvider(providerMetadata, provider); - }, - beginAutoOAuthDeviceCode(providerId: string, title: string, message: string, userCode: string, uri: string): Thenable { - return extHostAccountManagement.$beginAutoOAuthDeviceCode(providerId, title, message, userCode, uri); - }, - endAutoOAuthDeviceCode(): void { - return extHostAccountManagement.$endAutoOAuthDeviceCode(); - }, - accountUpdated(updatedAccount: sqlops.Account): void { - return extHostAccountManagement.$accountUpdated(updatedAccount); - }, - getAllAccounts(): Thenable { - return extHostAccountManagement.$getAllAccounts(); - }, - getSecurityToken(account: sqlops.Account, resource?: sqlops.AzureResource): Thenable<{}> { - return extHostAccountManagement.$getSecurityToken(account, resource); - }, - onDidChangeAccounts(listener: (e: sqlops.DidChangeAccountsParams) => void, thisArgs?: any, disposables?: extHostTypes.Disposable[]) { - return extHostAccountManagement.onDidChangeAccounts(listener, thisArgs, disposables); - } - }; // namespace: connection const connection: typeof sqlops.connection = { @@ -623,12 +599,6 @@ export function createApiFactory( }, }; - // namespace: serialization - const resources: typeof sqlops.resources = { - registerResourceProvider(providerMetadata: sqlops.ResourceProviderMetadata, provider: sqlops.ResourceProvider): vscode.Disposable { - return extHostResourceProvider.$registerResourceProvider(providerMetadata, provider); - } - }; let registerConnectionProvider = (provider: sqlops.ConnectionProvider): vscode.Disposable => { // Connection callbacks @@ -955,11 +925,9 @@ export function createApiFactory( }; return { - accounts, connection, credentials, objectexplorer: objectExplorer, - resources, serialization, dataprotocol, DataProviderType: sqlExtHostTypes.DataProviderType, diff --git a/src/sqltest/parts/accountManagement/accountPickerService.test.ts b/src/sqltest/parts/accountManagement/accountPickerService.test.ts index 3159aefa8c..48a8c06944 100644 --- a/src/sqltest/parts/accountManagement/accountPickerService.test.ts +++ b/src/sqltest/parts/accountManagement/accountPickerService.test.ts @@ -71,7 +71,8 @@ suite('Account picker service tests', () => { displayInfo: { contextualDisplayName: 'Microsoft Account', accountType: 'microsoft', - displayName: 'Account 1' + displayName: 'Account 1', + userId: 'user@email.com' }, properties: [], isStale: false diff --git a/src/sqltest/parts/accountManagement/accountPickerViewModel.test.ts b/src/sqltest/parts/accountManagement/accountPickerViewModel.test.ts index 2ce96dc263..99cbf03788 100644 --- a/src/sqltest/parts/accountManagement/accountPickerViewModel.test.ts +++ b/src/sqltest/parts/accountManagement/accountPickerViewModel.test.ts @@ -31,7 +31,8 @@ suite('Account picker view model tests', () => { displayInfo: { contextualDisplayName: 'Microsoft Account', accountType: 'microsoft', - displayName: 'Account 1' + displayName: 'Account 1', + userId: 'user@email.com' }, properties: [], isStale: false @@ -42,7 +43,8 @@ suite('Account picker view model tests', () => { displayInfo: { contextualDisplayName: 'Work/School Account', accountType: 'microsoft', - displayName: 'Account 2' + displayName: 'Account 2', + userId: 'user@email.com' }, properties: [], isStale: true diff --git a/src/sqltest/parts/accountManagement/accountViewModel.test.ts b/src/sqltest/parts/accountManagement/accountViewModel.test.ts index c78d5f0a54..ac5bd87269 100644 --- a/src/sqltest/parts/accountManagement/accountViewModel.test.ts +++ b/src/sqltest/parts/accountManagement/accountViewModel.test.ts @@ -36,7 +36,8 @@ suite('Account Management Dialog ViewModel Tests', () => { displayInfo: { contextualDisplayName: 'Microsoft Account', accountType: 'microsoft', - displayName: 'Account 1' + displayName: 'Account 1', + userId: 'user@email.com' }, properties: [], isStale: false @@ -47,7 +48,8 @@ suite('Account Management Dialog ViewModel Tests', () => { displayInfo: { contextualDisplayName: 'Work/School Account', accountType: 'work_school', - displayName: 'Account 2' + displayName: 'Account 2', + userId: 'user@email.com' }, properties: [], isStale: true diff --git a/src/sqltest/parts/accountManagement/firewallRuleDialogController.test.ts b/src/sqltest/parts/accountManagement/firewallRuleDialogController.test.ts index d605586c7a..03f491da8d 100644 --- a/src/sqltest/parts/accountManagement/firewallRuleDialogController.test.ts +++ b/src/sqltest/parts/accountManagement/firewallRuleDialogController.test.ts @@ -36,7 +36,8 @@ suite('Firewall rule dialog controller tests', () => { displayInfo: { contextualDisplayName: 'Microsoft Account', accountType: 'microsoft', - displayName: 'Account 1' + displayName: 'Account 1', + userId: 'user@email.com' }, properties: [], isStale: false diff --git a/src/sqltest/services/accountManagement/accountManagementService.test.ts b/src/sqltest/services/accountManagement/accountManagementService.test.ts index a0568ec4d8..16aa676bef 100644 --- a/src/sqltest/services/accountManagement/accountManagementService.test.ts +++ b/src/sqltest/services/accountManagement/accountManagementService.test.ts @@ -36,7 +36,9 @@ const account: azdata.Account = { displayInfo: { displayName: 'Test Account 1', accountType: 'test', - contextualDisplayName: 'Azure Account' + contextualDisplayName: 'Azure Account', + userId: 'user@email.com' + }, isStale: false, properties: {} diff --git a/src/sqltest/workbench/api/extHostAccountManagement.test.ts b/src/sqltest/workbench/api/extHostAccountManagement.test.ts index b51f61d946..aa070b7c1b 100644 --- a/src/sqltest/workbench/api/extHostAccountManagement.test.ts +++ b/src/sqltest/workbench/api/extHostAccountManagement.test.ts @@ -54,6 +54,7 @@ suite('ExtHostAccountManagement', () => { properties: {}, displayInfo: { displayName: 'Test Account', + userId: 'user@email.com', contextualDisplayName: 'Test Kind Of Account', accountType: 'test' }, @@ -272,7 +273,8 @@ suite('ExtHostAccountManagement', () => { displayInfo: { contextualDisplayName: 'Microsoft Account', accountType: 'microsoft', - displayName: 'Azure Account 1' + displayName: 'Azure Account 1', + userId: 'user@email.com' }, properties: [], isStale: false @@ -285,7 +287,8 @@ suite('ExtHostAccountManagement', () => { displayInfo: { contextualDisplayName: 'Work/School Account', accountType: 'microsoft', - displayName: 'Azure Account 2' + displayName: 'Azure Account 2', + userId: 'user@email.com' }, properties: [], isStale: false @@ -347,7 +350,8 @@ suite('ExtHostAccountManagement', () => { displayInfo: { contextualDisplayName: 'Microsoft Account', accountType: 'microsoft', - displayName: 'Azure Account 1' + displayName: 'Azure Account 1', + userId: 'user@email.com' }, properties: [], isStale: false @@ -385,7 +389,8 @@ suite('ExtHostAccountManagement', () => { displayInfo: { contextualDisplayName: 'Microsoft Account', accountType: 'microsoft', - displayName: 'Azure Account 1' + displayName: 'Azure Account 1', + userId: 'user@email.com' }, properties: [], isStale: false @@ -409,7 +414,8 @@ suite('ExtHostAccountManagement', () => { displayInfo: { contextualDisplayName: 'Work/School Account', accountType: 'microsoft', - displayName: 'Azure Account 2' + displayName: 'Azure Account 2', + userId: 'user@email.com' }, properties: [], isStale: false