Remove typings and replace missing methods with vscodes (#8217)

* remove typings and replace missing methods with vscodes

* fix strict-null-checks

* fix tests
This commit is contained in:
Anthony Dresser
2019-11-05 13:03:20 -08:00
committed by GitHub
parent 4645a8ba6b
commit 22a427f934
184 changed files with 634 additions and 43388 deletions

View File

@@ -7,6 +7,7 @@ import * as azdata from 'azdata';
import { AccountAdditionResult } from 'sql/platform/accounts/common/eventTypes';
import { IAccountStore } from 'sql/platform/accounts/common/interfaces';
import { deepClone } from 'vs/base/common/objects';
import { firstIndex } from 'vs/base/common/arrays';
export default class AccountStore implements IAccountStore {
// CONSTANTS ///////////////////////////////////////////////////////////
@@ -23,7 +24,7 @@ export default class AccountStore implements IAccountStore {
return this.readFromMemento()
.then(accounts => {
// Determine if account exists and proceed accordingly
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, newAccount.key));
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, newAccount.key));
return match < 0
? this.addToAccountList(accounts, newAccount)
: this.updateAccountList(accounts, newAccount.key, matchAccount => AccountStore.mergeAccounts(newAccount, matchAccount));
@@ -100,7 +101,7 @@ export default class AccountStore implements IAccountStore {
private addToAccountList(accounts: azdata.Account[], accountToAdd: azdata.Account): AccountListOperationResult {
// Check if the entry already exists
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToAdd.key));
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToAdd.key));
if (match >= 0) {
// Account already exists, we won't do anything
return {
@@ -125,7 +126,7 @@ export default class AccountStore implements IAccountStore {
private removeFromAccountList(accounts: azdata.Account[], accountToRemove: azdata.AccountKey): AccountListOperationResult {
// Check if the entry exists
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToRemove));
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToRemove));
if (match >= 0) {
// Account exists, remove it from the account list
accounts.splice(match, 1);
@@ -142,7 +143,7 @@ export default class AccountStore implements IAccountStore {
private updateAccountList(accounts: azdata.Account[], accountToUpdate: azdata.AccountKey, updateOperation: (account: azdata.Account) => void): AccountListOperationResult {
// Check if the entry exists
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToUpdate));
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToUpdate));
if (match < 0) {
// Account doesn't exist, we won't do anything
return {

View File

@@ -20,7 +20,7 @@ export interface IAccountManagementService {
addAccount(providerId: string): Thenable<void>;
getAccountProviderMetadata(): Thenable<azdata.AccountProviderMetadata[]>;
getAccountsForProvider(providerId: string): Thenable<azdata.Account[]>;
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{}>;
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{ [key: string]: { token: string } }>;
removeAccount(accountKey: azdata.AccountKey): Thenable<boolean>;
refreshAccount(account: azdata.Account): Thenable<azdata.Account>;