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

This reverts commit 22a427f934.
This commit is contained in:
Elliot Boschwitz
2019-11-06 11:33:55 -08:00
committed by GitHub
parent 3b1eaca58e
commit e801a04bcf
184 changed files with 43388 additions and 634 deletions

View File

@@ -7,7 +7,6 @@ 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 ///////////////////////////////////////////////////////////
@@ -24,7 +23,7 @@ export default class AccountStore implements IAccountStore {
return this.readFromMemento()
.then(accounts => {
// Determine if account exists and proceed accordingly
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, newAccount.key));
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, newAccount.key));
return match < 0
? this.addToAccountList(accounts, newAccount)
: this.updateAccountList(accounts, newAccount.key, matchAccount => AccountStore.mergeAccounts(newAccount, matchAccount));
@@ -101,7 +100,7 @@ export default class AccountStore implements IAccountStore {
private addToAccountList(accounts: azdata.Account[], accountToAdd: azdata.Account): AccountListOperationResult {
// Check if the entry already exists
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToAdd.key));
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToAdd.key));
if (match >= 0) {
// Account already exists, we won't do anything
return {
@@ -126,7 +125,7 @@ export default class AccountStore implements IAccountStore {
private removeFromAccountList(accounts: azdata.Account[], accountToRemove: azdata.AccountKey): AccountListOperationResult {
// Check if the entry exists
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToRemove));
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToRemove));
if (match >= 0) {
// Account exists, remove it from the account list
accounts.splice(match, 1);
@@ -143,7 +142,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 = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToUpdate));
const match = accounts.findIndex(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<{ [key: string]: { token: string } }>;
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{}>;
removeAccount(accountKey: azdata.AccountKey): Thenable<boolean>;
refreshAccount(account: azdata.Account): Thenable<azdata.Account>;

View File

@@ -12,7 +12,6 @@ import * as Utils from 'sql/platform/connection/common/utils';
import { generateUuid } from 'vs/base/common/uuid';
import * as nls from 'vs/nls';
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { find, firstIndex } from 'vs/base/common/arrays';
const GROUPS_CONFIG_KEY = 'datasource.connectionGroups';
const CONNECTIONS_CONFIG_KEY = 'datasource.connections';
@@ -44,7 +43,7 @@ export class ConnectionConfig {
if (user) {
if (workspace) {
user = user.filter(x => find(workspace, f => this.isSameGroupName(f, x)) === undefined);
user = user.filter(x => workspace.find(f => this.isSameGroupName(f, x)) === undefined);
allGroups = allGroups.concat(workspace);
}
allGroups = allGroups.concat(user);
@@ -72,12 +71,12 @@ export class ConnectionConfig {
let newProfile = ConnectionProfile.convertToProfileStore(this._capabilitiesService, connectionProfile);
// Remove the profile if already set
let sameProfileInList = find(profiles, value => {
let sameProfileInList = profiles.find(value => {
let providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
return providerConnectionProfile.matches(connectionProfile);
});
if (sameProfileInList) {
let profileIndex = firstIndex(profiles, value => value === sameProfileInList);
let profileIndex = profiles.findIndex(value => value === sameProfileInList);
newProfile.id = sameProfileInList.id;
connectionProfile.id = sameProfileInList.id;
profiles[profileIndex] = newProfile;
@@ -124,7 +123,7 @@ export class ConnectionConfig {
return Promise.resolve(profileGroup.id);
} else {
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
let sameNameGroup = groups ? find(groups, group => group.name === profileGroup.name) : undefined;
let sameNameGroup = groups ? groups.find(group => group.name === profileGroup.name) : undefined;
if (sameNameGroup) {
let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists.");
return Promise.reject(errMessage);
@@ -277,7 +276,7 @@ export class ConnectionConfig {
*/
public canChangeConnectionConfig(profile: ConnectionProfile, newGroupID: string): boolean {
let profiles = this.getConnections(true);
let existingProfile = find(profiles, p => p.getConnectionInfoId() === profile.getConnectionInfoId()
let existingProfile = profiles.find(p => p.getConnectionInfoId() === profile.getConnectionInfoId()
&& p.groupId === newGroupID);
return existingProfile === undefined;
}
@@ -329,7 +328,7 @@ export class ConnectionConfig {
public editGroup(source: ConnectionProfileGroup): Promise<void> {
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
let sameNameGroup = groups ? find(groups, group => group.name === source.name && group.id !== source.id) : undefined;
let sameNameGroup = groups ? groups.find(group => group.name === source.name && group.id !== source.id) : undefined;
if (sameNameGroup) {
let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists.");
return Promise.reject(errMessage);
@@ -370,7 +369,7 @@ export class ConnectionConfig {
color: color,
description: description
} as IConnectionProfileGroup;
let found = find(groupTree, group => this.isSameGroupName(group, newGroup));
let found = groupTree.find(group => this.isSameGroupName(group, newGroup));
if (found) {
if (index === groupNames.length - 1) {
newGroupId = found.id;

View File

@@ -14,7 +14,6 @@ import { isString } from 'vs/base/common/types';
import { deepClone } from 'vs/base/common/objects';
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
import * as Constants from 'sql/platform/connection/common/constants';
import { find } from 'vs/base/common/arrays';
// Concrete implementation of the IConnectionProfile interface
@@ -47,7 +46,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
let capabilities = this.capabilitiesService.getCapabilities(model.providerName);
if (capabilities && capabilities.connection && capabilities.connection.connectionOptions) {
const options = capabilities.connection.connectionOptions;
let appNameOption = find(options, option => option.specialValueType === ConnectionOptionSpecialType.appName);
let appNameOption = options.find(option => option.specialValueType === ConnectionOptionSpecialType.appName);
if (appNameOption) {
let appNameKey = appNameOption.name;
this.options[appNameKey] = Constants.applicationName;

View File

@@ -6,8 +6,6 @@
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { Disposable } from 'vs/base/common/lifecycle';
import { isUndefinedOrNull } from 'vs/base/common/types';
import { assign } from 'vs/base/common/objects';
import { find } from 'vs/base/common/arrays';
export interface IConnectionProfileGroup {
id: string;
@@ -49,7 +47,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
});
}
return assign({}, { name: this.name, id: this.id, parentId: this.parentId, children: subgroups, color: this.color, description: this.description });
return Object.assign({}, { name: this.name, id: this.id, parentId: this.parentId, children: subgroups, color: this.color, description: this.description });
}
public get groupName(): string {
@@ -87,7 +85,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
*/
public get hasValidConnections(): boolean {
if (this.connections) {
let invalidConnections = find(this.connections, c => !c.isConnectionOptionsValid);
let invalidConnections = this.connections.find(c => !c.isConnectionOptionsValid);
if (invalidConnections !== undefined) {
return false;
} else {

View File

@@ -14,9 +14,6 @@ import { join } from 'vs/base/common/path';
import * as Utils from 'sql/platform/connection/common/utils';
import * as azdata from 'azdata';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { startsWith } from 'vs/base/common/strings';
import { values } from 'vs/base/common/collections';
import { firstIndex, find } from 'vs/base/common/arrays';
export class ConnectionStatusManager {
@@ -38,8 +35,8 @@ export class ConnectionStatusManager {
}
}
public findConnectionByProfileId(profileId: string): ConnectionManagementInfo | undefined {
return find(values(this._connections), connection => connection.connectionProfile.id === profileId);
public findConnectionByProfileId(profileId: string): ConnectionManagementInfo {
return Object.values(this._connections).find((connection: ConnectionManagementInfo) => connection.connectionProfile.id === profileId);
}
public findConnectionProfile(connectionProfile: IConnectionProfile): ConnectionManagementInfo | undefined {
@@ -193,7 +190,7 @@ export class ConnectionStatusManager {
}
private isSharedSession(fileUri: string): boolean {
return !!(fileUri && startsWith(fileUri, 'vsls:'));
return !!(fileUri && fileUri.startsWith('vsls:'));
}
public isConnected(id: string): boolean {
@@ -208,7 +205,7 @@ export class ConnectionStatusManager {
}
public isDefaultTypeUri(uri: string): boolean {
return !!(uri && startsWith(uri, Utils.uriPrefixes.default));
return !!(uri && uri.startsWith(Utils.uriPrefixes.default));
}
public getProviderIdFromUri(ownerUri: string): string {
@@ -228,12 +225,12 @@ export class ConnectionStatusManager {
* Get a list of the active connection profiles managed by the status manager
*/
public getActiveConnectionProfiles(providers?: string[]): ConnectionProfile[] {
let profiles = values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
let profiles = Object.values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
// Remove duplicate profiles that may be listed multiple times under different URIs by filtering for profiles that don't have the same ID as an earlier profile in the list
profiles = profiles.filter((profile, index) => firstIndex(profiles, otherProfile => otherProfile.id === profile.id) === index);
profiles = profiles.filter((profile, index) => profiles.findIndex(otherProfile => otherProfile.id === profile.id) === index);
if (providers) {
profiles = profiles.filter(f => find(providers, x => x === f.providerName));
profiles = profiles.filter(f => providers.includes(f.providerName));
}
return profiles;
}

View File

@@ -13,7 +13,6 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { ICredentialsService } from 'sql/platform/credentials/common/credentialsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { find } from 'vs/base/common/arrays';
const MAX_CONNECTIONS_DEFAULT = 25;
@@ -151,7 +150,7 @@ export class ConnectionStore {
public getRecentlyUsedConnections(providers?: string[]): ConnectionProfile[] {
let mru = this.mru.slice();
if (providers && providers.length > 0) {
mru = mru.filter(c => find(providers, x => x === c.providerName));
mru = mru.filter(c => providers.includes(c.providerName));
}
return this.convertConfigValuesToConnectionProfiles(mru);
}
@@ -278,7 +277,7 @@ export class ConnectionStore {
if (!withoutConnections) {
profilesInConfiguration = this.connectionConfig.getConnections(true);
if (providers && providers.length > 0) {
profilesInConfiguration = profilesInConfiguration.filter(x => find(providers, p => p === x.providerName));
profilesInConfiguration = profilesInConfiguration.filter(x => providers.includes(x.providerName));
}
}
const groups = this.connectionConfig.getAllGroups();
@@ -314,9 +313,9 @@ export class ConnectionStore {
return result;
}
public getGroupFromId(groupId: string): IConnectionProfileGroup | undefined {
public getGroupFromId(groupId: string): IConnectionProfileGroup {
const groups = this.connectionConfig.getAllGroups();
return find(groups, group => group.id === groupId);
return groups.find(group => group.id === groupId);
}
private getMaxRecentConnectionsCount(): number {

View File

@@ -10,8 +10,6 @@ import * as azdata from 'azdata';
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
import * as Constants from 'sql/platform/connection/common/constants';
import { ICapabilitiesService, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { assign } from 'vs/base/common/objects';
import { find } from 'vs/base/common/arrays';
type SettableProperty = 'serverName' | 'authenticationType' | 'databaseName' | 'password' | 'connectionName' | 'userName';
@@ -96,7 +94,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
public clone(): ProviderConnectionInfo {
let instance = new ProviderConnectionInfo(this.capabilitiesService, this.providerName);
instance.options = assign({}, this.options);
instance.options = Object.assign({}, this.options);
return instance;
}
@@ -198,9 +196,9 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
return false;
}
let optionMetadata = find(this._serverCapabilities.connectionOptions,
option => option.specialValueType === ConnectionOptionSpecialType.password)!; // i guess we are going to assume there is a password field
let isPasswordRequired = optionMetadata.isRequired;
let optionMetadata = this._serverCapabilities.connectionOptions.find(
option => option.specialValueType === ConnectionOptionSpecialType.password);
let isPasswordRequired: boolean = optionMetadata.isRequired;
if (this.providerName === Constants.mssqlProviderName) {
isPasswordRequired = this.authenticationType === ProviderConnectionInfo.SqlAuthentication && optionMetadata.isRequired;
}
@@ -269,7 +267,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
public getSpecialTypeOptionName(type: string): string | undefined {
if (this._serverCapabilities) {
let optionMetadata = find(this._serverCapabilities.connectionOptions, o => o.specialValueType === type);
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === type);
return !!optionMetadata ? optionMetadata.name : undefined;
} else {
return type.toString();
@@ -284,7 +282,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
}
public get authenticationTypeDisplayName(): string {
let optionMetadata = find(this._serverCapabilities.connectionOptions, o => o.specialValueType === ConnectionOptionSpecialType.authType);
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === ConnectionOptionSpecialType.authType);
let authType = this.authenticationType;
let displayName: string = authType;

View File

@@ -17,7 +17,6 @@ import * as TypeMoq from 'typemoq';
import { Emitter } from 'vs/base/common/event';
import { deepClone, deepFreeze } from 'vs/base/common/objects';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { find } from 'vs/base/common/arrays';
suite('ConnectionConfig', () => {
let capabilitiesService: TypeMoq.Mock<ICapabilitiesService>;
@@ -211,7 +210,7 @@ suite('ConnectionConfig', () => {
}
for (let group of groups1) {
let g2 = find(groups2, g => g.name === group.name);
let g2 = groups2.find(g => g.name === group.name);
// if we couldn't find the group it means they must not be equal
if (!g2) {
return false;
@@ -374,12 +373,12 @@ suite('ConnectionConfig', () => {
let allConnections = config.getConnections(false);
assert.equal(allConnections.length, testConnections.length);
allConnections.forEach(connection => {
let userConnection = find(testConnections, u => u.options['serverName'] === connection.serverName);
let userConnection = testConnections.find(u => u.options['serverName'] === connection.serverName);
if (userConnection !== undefined) {
assert.notEqual(connection.id, connection.getOptionsKey());
assert.ok(!!connection.id);
} else {
let workspaceConnection = find(workspaceConnections, u => u.options['serverName'] === connection.serverName);
let workspaceConnection = workspaceConnections.find(u => u.options['serverName'] === connection.serverName);
assert.notEqual(connection.id, connection.getOptionsKey());
assert.equal(workspaceConnection.id, connection.id);
}
@@ -395,7 +394,7 @@ suite('ConnectionConfig', () => {
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
assert.ok(!!result);
assert.equal(result.groups.length, testGroups.length + 2, 'The result groups length is invalid');
let newGroup = find(result.groups, g => g.name === 'new-group2');
let newGroup = result.groups.find(g => g.name === 'new-group2');
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
});
@@ -408,7 +407,7 @@ suite('ConnectionConfig', () => {
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
assert.ok(!!result);
assert.equal(result.groups.length, testGroups.length + 1, 'The result groups length is invalid');
let newGroup = find(result.groups, g => g.name === 'g2-5');
let newGroup = result.groups.find(g => g.name === 'g2-5');
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
});
@@ -421,7 +420,7 @@ suite('ConnectionConfig', () => {
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
assert.ok(!!result);
assert.equal(result.groups.length, testGroups.length, 'The result groups length is invalid');
let newGroup = find(result.groups, g => g.name === 'g2-1');
let newGroup = result.groups.find(g => g.name === 'g2-1');
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
});
@@ -531,7 +530,7 @@ suite('ConnectionConfig', () => {
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
assert.equal(editedGroups.length, testGroups.length);
let editedGroup = find(editedGroups, group => group.id === 'g2');
let editedGroup = editedGroups.find(group => group.id === 'g2');
assert.ok(!!editedGroup);
assert.equal(editedGroup.name, 'g-renamed');
});
@@ -548,7 +547,7 @@ suite('ConnectionConfig', () => {
assert.fail();
} catch (e) {
let groups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
let originalGroup = find(groups, g => g.id === 'g2');
let originalGroup = groups.find(g => g.id === 'g2');
assert.ok(!!originalGroup);
assert.equal(originalGroup.name, 'g2');
}
@@ -566,7 +565,7 @@ suite('ConnectionConfig', () => {
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
assert.equal(editedGroups.length, testGroups.length);
let editedGroup = find(editedGroups, group => group.id === 'g2');
let editedGroup = editedGroups.find(group => group.id === 'g2');
assert.ok(!!editedGroup);
assert.equal(editedGroup.parentId, 'g3');
});
@@ -623,7 +622,7 @@ suite('ConnectionConfig', () => {
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user;
// two
assert.equal(editedConnections.length, _testConnections.length);
let editedConnection = find(editedConnections, con => con.id === 'server3-2');
let editedConnection = editedConnections.find(con => con.id === 'server3-2');
assert.ok(!!editedConnection);
assert.equal(editedConnection.groupId, 'g3');
}
@@ -659,7 +658,7 @@ suite('ConnectionConfig', () => {
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user;
assert.equal(editedConnections.length, testConnections.length);
let editedConnection = find(editedConnections, con => con.id === 'server3');
let editedConnection = editedConnections.find(con => con.id === 'server3');
assert.ok(!!editedConnection);
assert.equal(editedConnection.groupId, 'newid');
});

View File

@@ -11,7 +11,6 @@ import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/ap
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { assign } from 'vs/base/common/objects';
suite('SQL ConnectionProfileInfo tests', () => {
let msSQLCapabilities: ConnectionProviderProperties;
@@ -188,7 +187,7 @@ suite('SQL ConnectionProfileInfo tests', () => {
});
test('createFromStoredProfile should set the id to new guid if not set in stored profile', () => {
let savedProfile = assign({}, storedProfile, { id: undefined });
let savedProfile = Object.assign({}, storedProfile, { id: undefined });
let connectionProfile = ConnectionProfile.createFromStoredProfile(savedProfile, capabilitiesService);
assert.equal(savedProfile.groupId, connectionProfile.groupId);
assert.deepEqual(savedProfile.providerName, connectionProfile.providerName);

View File

@@ -13,12 +13,11 @@ import { TestConfigurationService } from 'sql/platform/connection/test/common/te
import { TestCredentialsService } from 'sql/platform/credentials/test/common/testCredentialsService';
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
import { deepClone, deepFreeze, assign } from 'vs/base/common/objects';
import { deepClone, deepFreeze } from 'vs/base/common/objects';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { InMemoryStorageService } from 'vs/platform/storage/common/storage';
import { find } from 'vs/base/common/arrays';
suite('ConnectionStore', () => {
let defaultNamedProfile: IConnectionProfile = deepFreeze({
@@ -154,7 +153,7 @@ suite('ConnectionStore', () => {
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
for (let i = 0; i < numCreds; i++) {
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
await connectionStore.addRecentConnection(connectionProfile);
const current = connectionStore.getRecentlyUsedConnections();
@@ -190,7 +189,7 @@ suite('ConnectionStore', () => {
// Then expect the only 1 instance of that connection to be listed in the MRU
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + 1 });
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + 1 });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
await connectionStore.addRecentConnection(defaultNamedConnectionProfile);
await connectionStore.addRecentConnection(connectionProfile);
@@ -212,13 +211,13 @@ suite('ConnectionStore', () => {
// Given we save 1 connection with password and multiple other connections without
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
const integratedCred = assign({}, defaultNamedProfile, {
const integratedCred = Object.assign({}, defaultNamedProfile, {
serverName: defaultNamedProfile.serverName + 'Integrated',
authenticationType: 'Integrated',
userName: '',
password: ''
});
const noPwdCred = assign({}, defaultNamedProfile, {
const noPwdCred = Object.assign({}, defaultNamedProfile, {
serverName: defaultNamedProfile.serverName + 'NoPwd',
password: ''
});
@@ -233,7 +232,7 @@ suite('ConnectionStore', () => {
// Then verify that since its password based we save the password
assert.equal(credentialsService.credentials.size, 1);
assert.strictEqual(recentCredential.password, defaultNamedProfile.password);
assert.ok(recentCredential.credentialId.indexOf('Profile') > -1, 'Expect credential to be marked as an Profile cred');
assert.ok(recentCredential.credentialId.includes('Profile'), 'Expect credential to be marked as an Profile cred');
assert.ok(!current[0].password);
// When add integrated auth connection
const integratedCredConnectionProfile = new ConnectionProfile(capabilitiesService, integratedCred);
@@ -313,7 +312,7 @@ suite('ConnectionStore', () => {
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
const connectionProfile: IConnectionProfile = assign({}, defaultNamedProfile, { providerName: providerName });
const connectionProfile: IConnectionProfile = Object.assign({}, defaultNamedProfile, { providerName: providerName });
assert.ok(!connectionStore.isPasswordRequired(connectionProfile));
});
@@ -324,7 +323,7 @@ suite('ConnectionStore', () => {
const credentialsService = new TestCredentialsService();
const password: string = 'asdf!@#$';
const connectionProfile: IConnectionProfile = assign({}, defaultNamedProfile, { password });
const connectionProfile: IConnectionProfile = Object.assign({}, defaultNamedProfile, { password });
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
@@ -394,7 +393,7 @@ suite('ConnectionStore', () => {
const profile = deepClone(defaultNamedProfile);
profile.options['password'] = profile.password;
profile.id = 'testId';
let expectedProfile = assign({}, profile);
let expectedProfile = Object.assign({}, profile);
expectedProfile.password = '';
expectedProfile.options['password'] = '';
expectedProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, expectedProfile).toIConnectionProfile();
@@ -407,7 +406,7 @@ suite('ConnectionStore', () => {
const configurationService = new TestConfigurationService();
const credentialsService = new TestCredentialsService();
const profile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, assign({}, defaultNamedProfile, { password: undefined }));
const profile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, Object.assign({}, defaultNamedProfile, { password: undefined }));
const credId = `Microsoft.SqlTools|itemtype:Profile|id:${profile.getConnectionInfoId()}`;
const password: string = 'asdf!@#$';
@@ -454,7 +453,7 @@ suite('ConnectionStore', () => {
const connectionGroups = connectionStore.getConnectionProfileGroups();
for (const group of connectionGroups) {
const foundGroup = find(groups, g => g.id === group.id);
const foundGroup = groups.find(g => g.id === group.id);
assert.ok(foundGroup);
}
});
@@ -468,7 +467,7 @@ suite('ConnectionStore', () => {
credentialsService, capabilitiesService);
for (let i = 0; i < 5; i++) {
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
await connectionStore.addRecentConnection(connectionProfile);
const current = connectionStore.getRecentlyUsedConnections();
@@ -476,7 +475,7 @@ suite('ConnectionStore', () => {
}
for (let i = 0; i < 5; i++) {
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
connectionStore.removeRecentConnection(connectionProfile);
const current = connectionStore.getRecentlyUsedConnections();

View File

@@ -10,7 +10,6 @@ import * as assert from 'assert';
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { assign } from 'vs/base/common/objects';
suite('SQL ProviderConnectionInfo tests', () => {
let msSQLCapabilities: any;
@@ -203,7 +202,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
test('constructor should initialize the options given a valid model with options', () => {
let options = {};
options['encrypt'] = 'test value';
let conn2 = assign({}, connectionProfile, { options: options });
let conn2 = Object.assign({}, connectionProfile, { options: options });
let conn = new ProviderConnectionInfo(capabilitiesService, conn2);
assert.equal(conn.connectionName, conn2.connectionName);
@@ -224,7 +223,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
test('getOptionsKey should create different id for different server names', () => {
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
let conn2 = new ProviderConnectionInfo(capabilitiesService, assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
let conn2 = new ProviderConnectionInfo(capabilitiesService, Object.assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
assert.notEqual(conn.getOptionsKey(), conn2.getOptionsKey());
});
@@ -261,4 +260,4 @@ suite('SQL ProviderConnectionInfo tests', () => {
assert.equal(expectedProviderId, actual);
});
});
});

View File

@@ -15,7 +15,6 @@ import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { NullLogService } from 'vs/platform/log/common/log';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { assign } from 'vs/base/common/objects';
let connections: ConnectionStatusManager;
let capabilitiesService: TestCapabilitiesService;
@@ -172,7 +171,7 @@ suite('SQL ConnectionStatusManager tests', () => {
let expectedConnectionId = 'new id';
connections.addConnection(connectionProfile, connection1Id);
let updatedConnection = assign({}, connectionProfile, { groupId: expected, getOptionsKey: () => connectionProfile.getOptionsKey() + expected, id: expectedConnectionId });
let updatedConnection = Object.assign({}, connectionProfile, { groupId: expected, getOptionsKey: () => connectionProfile.getOptionsKey() + expected, id: expectedConnectionId });
let actualId = connections.updateConnectionProfile(updatedConnection, connection1Id);
let newId = Utils.generateUri(updatedConnection);
@@ -247,7 +246,7 @@ suite('SQL ConnectionStatusManager tests', () => {
test('getActiveConnectionProfiles should return a list of all the unique connections that the status manager knows about', () => {
// Add duplicate connections
let newConnection = assign({}, connectionProfile);
let newConnection = Object.assign({}, connectionProfile);
newConnection.id = 'test_id';
newConnection.serverName = 'new_server_name';
newConnection.options['databaseDisplayName'] = newConnection.databaseName;

View File

@@ -8,7 +8,6 @@ import * as platform from 'vs/platform/registry/common/platform';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import * as nls from 'vs/nls';
import { IInsightData } from 'sql/workbench/parts/charts/browser/interfaces';
import { values } from 'vs/base/common/collections';
export type InsightIdentifier = string;
@@ -108,7 +107,7 @@ class InsightRegistry implements IInsightRegistry {
}
public getAllCtors(): Array<Type<IInsightsView>> {
return values(this._idToCtor);
return Object.values(this._idToCtor);
}
public getAllIds(): Array<string> {

View File

@@ -7,7 +7,6 @@ import { ModelComponentTypes } from 'sql/workbench/api/common/sqlExtHostTypes';
import * as platform from 'vs/platform/registry/common/platform';
import { IComponent } from 'sql/workbench/browser/modelComponents/interfaces';
import { values } from 'vs/base/common/collections';
export type ComponentIdentifier = string;
@@ -47,7 +46,7 @@ class ComponentRegistry implements IComponentRegistry {
}
public getAllCtors(): Array<Type<IComponent>> {
return values(this._idToCtor);
return Object.values(this._idToCtor);
}
public getAllIds(): Array<string> {

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { find } from 'vs/base/common/arrays';
export class JobManagementUtilities {
@@ -42,7 +41,7 @@ export class JobManagementUtilities {
}
public static convertToNextRun(date: string) {
if (find(date, x => x === '1/1/0001')) {
if (date.includes('1/1/0001')) {
return nls.localize('agentUtilities.notScheduled', "Not Scheduled");
} else {
return date;
@@ -50,7 +49,7 @@ export class JobManagementUtilities {
}
public static convertToLastRun(date: string) {
if (find(date, x => x === '1/1/0001')) {
if (date.includes('1/1/0001')) {
return nls.localize('agentUtilities.neverRun', "Never Run");
} else {
return date;
@@ -58,7 +57,7 @@ export class JobManagementUtilities {
}
public static setRunnable(icon: HTMLElement, index: number) {
if (find(icon.className, x => x === 'non-runnable')) {
if (icon.className.includes('non-runnable')) {
icon.className = icon.className.slice(0, index);
}
}

View File

@@ -14,7 +14,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { Event, Emitter } from 'vs/base/common/event';
import { keys } from 'vs/base/common/map';
import { ILogService } from 'vs/platform/log/common/log';
import { assign } from 'vs/base/common/objects';
export const SERVICE_ID = 'queryManagementService';
@@ -174,7 +173,7 @@ export class QueryManagementService implements IQueryManagementService {
provider: providerId,
};
if (runOptions) {
data = assign({}, data, {
data = Object.assign({}, data, {
displayEstimatedQueryPlan: runOptions.displayEstimatedQueryPlan,
displayActualQueryPlan: runOptions.displayActualQueryPlan
});

View File

@@ -27,7 +27,6 @@ import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { IGridDataProvider, getResultsString } from 'sql/platform/query/common/gridDataProvider';
import { getErrorMessage } from 'vs/base/common/errors';
import { ILogService } from 'vs/platform/log/common/log';
import { find } from 'vs/base/common/arrays';
export interface IEditSessionReadyEvent {
ownerUri: string;
@@ -347,7 +346,7 @@ export default class QueryRunner extends Disposable {
}
// handle getting queryPlanxml if we need too
// check if this result has show plan, this needs work, it won't work for any other provider
let hasShowPlan = !!find(result.resultSetSummary.columnInfo, e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
let hasShowPlan = !!result.resultSetSummary.columnInfo.find(e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
if (hasShowPlan) {
this._isQueryPlan = true;
@@ -374,7 +373,7 @@ export default class QueryRunner extends Disposable {
batchSet = this._batchSets[resultSet.batchId];
// handle getting queryPlanxml if we need too
// check if this result has show plan, this needs work, it won't work for any other provider
let hasShowPlan = !!find(result.resultSetSummary.columnInfo, e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
let hasShowPlan = !!result.resultSetSummary.columnInfo.find(e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
if (hasShowPlan) {
this._isQueryPlan = true;
this.getQueryRows(0, 1, result.resultSetSummary.batchId, result.resultSetSummary.id).then(e => {

View File

@@ -14,7 +14,6 @@ import { IConnectionManagementService } from 'sql/platform/connection/common/con
import { Event, Emitter } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { find } from 'vs/base/common/arrays';
/**
* Service that collects the results of executed queries
@@ -42,7 +41,7 @@ export class QueryHistoryService extends Disposable implements IQueryHistoryServ
this._captureEnabled = !!this._configurationService.getValue<boolean>('queryHistory.captureEnabled');
this._register(this._configurationService.onDidChangeConfiguration((e: IConfigurationChangeEvent) => {
if (find(e.affectedKeys, x => x === 'queryHistory.captureEnabled')) {
if (e.affectedKeys.includes('queryHistory.captureEnabled')) {
this.updateCaptureEnabled();
}
}));

View File

@@ -24,7 +24,6 @@ import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilitie
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { invalidProvider } from 'sql/base/common/errors';
import { ILogService } from 'vs/platform/log/common/log';
import { find } from 'vs/base/common/arrays';
export class RestoreService implements IRestoreService {
@@ -273,7 +272,7 @@ export class RestoreDialogController implements IRestoreDialogController {
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);
if (providerCapabilities) {
let restoreMetadataProvider = find(providerCapabilities.features, f => f.featureName === this._restoreFeature);
let restoreMetadataProvider = providerCapabilities.features.find(f => f.featureName === this._restoreFeature);
if (restoreMetadataProvider) {
options = restoreMetadataProvider.optionsMetadata;
}

View File

@@ -3,13 +3,12 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
import * as azdata from 'azdata';
import { localize } from 'vs/nls';
import { getErrorMessage } from 'vs/base/common/errors';
import { find } from 'vs/base/common/arrays';
export const SERVICE_ID = 'serializationService';
@@ -96,7 +95,7 @@ export class SerializationService implements ISerializationService {
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);
if (providerCapabilities) {
return find(providerCapabilities.features, f => f.featureName === SERVICE_ID);
return providerCapabilities.features.find(f => f.featureName === SERVICE_ID);
}
return undefined;

View File

@@ -13,7 +13,6 @@ import { localize } from 'vs/nls';
import Severity from 'vs/base/common/severity';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { find } from 'vs/base/common/arrays';
export const SERVICE_ID = 'taskHistoryService';
export const ITaskService = createDecorator<ITaskService>(SERVICE_ID);
@@ -227,7 +226,7 @@ export class TaskService implements ITaskService {
private getTaskInQueue(taskId: string): TaskNode | undefined {
if (this._taskQueue.hasChildren) {
return find(this._taskQueue.children, x => x.id === taskId);
return this._taskQueue.children.find(x => x.id === taskId);
}
return undefined;
}

View File

@@ -6,7 +6,6 @@
import { IAdsTelemetryService, ITelemetryInfo, ITelemetryEvent, ITelemetryConnectionInfo, ITelemetryEventMeasures, ITelemetryEventProperties } from 'sql/platform/telemetry/common/telemetry';
import { ILogService } from 'vs/platform/log/common/log';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { assign } from 'vs/base/common/objects';
class TelemetryEventImpl implements ITelemetryEvent {
@@ -34,17 +33,17 @@ class TelemetryEventImpl implements ITelemetryEvent {
}
public withAdditionalProperties(additionalProperties: ITelemetryEventProperties): ITelemetryEvent {
assign(this._properties, additionalProperties);
Object.assign(this._properties, additionalProperties);
return this;
}
public withAdditionalMeasurements(additionalMeasurements: ITelemetryEventMeasures): ITelemetryEvent {
assign(this._measurements, additionalMeasurements);
Object.assign(this._measurements, additionalMeasurements);
return this;
}
public withConnectionInfo(connectionInfo: ITelemetryConnectionInfo): ITelemetryEvent {
assign(this._properties,
Object.assign(this._properties,
{
authenticationType: connectionInfo.authenticationType,
providerName: connectionInfo.providerName,