diff --git a/extensions/admin-tool-ext-win/package.json b/extensions/admin-tool-ext-win/package.json index 9b8848c6c2..48d2890915 100644 --- a/extensions/admin-tool-ext-win/package.json +++ b/extensions/admin-tool-ext-win/package.json @@ -74,6 +74,7 @@ "vscode-nls": "^3.2.1" }, "devDependencies": { + "@types/node": "10", "mocha-junit-reporter": "^1.17.0", "mocha-multi-reporters": "^1.1.7", "should": "^13.2.3", diff --git a/extensions/admin-tool-ext-win/yarn.lock b/extensions/admin-tool-ext-win/yarn.lock index 82be150c8d..19ae10b456 100644 --- a/extensions/admin-tool-ext-win/yarn.lock +++ b/extensions/admin-tool-ext-win/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@types/node@10": + version "10.17.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.4.tgz#8993a4fe3c4022fda66bf4ea660d615fc5659c6f" + integrity sha512-F2pgg+LcIr/elguz+x+fdBX5KeZXGUOp7TV8M0TVIrDezYLFRNt8oMTyps0VQ1kj5WGGoR18RdxnRDHXrIFHMQ== + "ads-extension-telemetry@github:Charles-Gagnon/ads-extension-telemetry#0.1.0": version "0.1.0" resolved "https://codeload.github.com/Charles-Gagnon/ads-extension-telemetry/tar.gz/70c2fea10e9ff6e329c4c5ec0b77017ada514b6d" diff --git a/extensions/agent/src/apiWrapper.ts b/extensions/agent/src/apiWrapper.ts deleted file mode 100644 index 3329407e4b..0000000000 --- a/extensions/agent/src/apiWrapper.ts +++ /dev/null @@ -1,61 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as vscode from 'vscode'; -import * as data from 'azdata'; - -/** - * Wrapper class to act as a facade over VSCode and Data APIs and allow us to test / mock callbacks into - * this API from our code - * - * @export - */ -export class ApiWrapper { - // Data APIs - - public registerWebviewProvider(widgetId: string, handler: (webview: data.DashboardWebview) => void): void { - return data.dashboard.registerWebviewProvider(widgetId, handler); - } - - - public registerControlHostProvider(widgetId: string, handler: (webview: data.DashboardWebview) => void): void { - return data.dashboard.registerWebviewProvider(widgetId, handler); - } - - /** - * Get the configuration for a extensionName - * @param extensionName The string name of the extension to get the configuration for - * @param resource The optional URI, as a URI object or a string, to use to get resource-scoped configurations - */ - public getConfiguration(extensionName: string, resource?: vscode.Uri | string): vscode.WorkspaceConfiguration { - if (typeof resource === 'string') { - try { - resource = this.parseUri(resource); - } catch (e) { - resource = undefined; - } - } - return vscode.workspace.getConfiguration(extensionName, resource as vscode.Uri); - } - - /** - * Parse uri - */ - public parseUri(uri: string): vscode.Uri { - return vscode.Uri.parse(uri); - } - - public showOpenDialog(options: vscode.OpenDialogOptions): Thenable { - return vscode.window.showOpenDialog(options); - } - - public showErrorMessage(message: string, ...items: string[]): Thenable { - return vscode.window.showErrorMessage(message, ...items); - } - - public get workspaceRootPath(): string { - return vscode.workspace.rootPath; - } -} diff --git a/extensions/agent/src/data/scheduleData.ts b/extensions/agent/src/data/scheduleData.ts deleted file mode 100644 index 1903d728f0..0000000000 --- a/extensions/agent/src/data/scheduleData.ts +++ /dev/null @@ -1,30 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as azdata from 'azdata'; -import { AgentUtils } from '../agentUtils'; -import { IAgentDialogData, AgentDialogMode } from '../interfaces'; - -export class ScheduleData implements IAgentDialogData { - public dialogMode: AgentDialogMode = AgentDialogMode.CREATE; - public ownerUri: string; - public schedules: azdata.AgentJobScheduleInfo[]; - public selectedSchedule: azdata.AgentJobScheduleInfo; - - constructor(ownerUri: string) { - this.ownerUri = ownerUri; - } - - public async initialize() { - let agentService = await AgentUtils.getAgentService(); - let result = await agentService.getJobSchedules(this.ownerUri); - if (result && result.success) { - this.schedules = result.schedules; - } - } - - public async save() { - } -} diff --git a/extensions/agent/src/dialogs/scheduleDialog.ts b/extensions/agent/src/dialogs/scheduleDialog.ts deleted file mode 100644 index 87e4698c7a..0000000000 --- a/extensions/agent/src/dialogs/scheduleDialog.ts +++ /dev/null @@ -1,94 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as nls from 'vscode-nls'; -import * as azdata from 'azdata'; -import * as vscode from 'vscode'; -import { ScheduleData } from '../data/scheduleData'; - -const localize = nls.loadMessageBundle(); - -export class ScheduleDialog { - - // Top level - private readonly DialogTitle: string = localize('scheduleDialog.newSchedule', "New Schedule"); - private readonly OkButtonText: string = localize('scheduleDialog.ok', "OK"); - private readonly CancelButtonText: string = localize('scheduleDialog.cancel', "Cancel"); - private readonly ScheduleNameText: string = localize('scheduleDialog.scheduleName', "Schedule Name"); - private readonly SchedulesLabelText: string = localize('scheduleDialog.schedules', "Schedules"); - - // UI Components - private dialog: azdata.window.Dialog; - private schedulesTable: azdata.TableComponent; - - private model: ScheduleData; - - private _onSuccess: vscode.EventEmitter = new vscode.EventEmitter(); - public readonly onSuccess: vscode.Event = this._onSuccess.event; - - constructor(ownerUri: string) { - this.model = new ScheduleData(ownerUri); - } - - public async showDialog() { - await this.model.initialize(); - this.dialog = azdata.window.createModelViewDialog(this.DialogTitle); - this.initializeContent(); - this.dialog.okButton.onClick(async () => await this.execute()); - this.dialog.cancelButton.onClick(async () => await this.cancel()); - this.dialog.okButton.label = this.OkButtonText; - this.dialog.cancelButton.label = this.CancelButtonText; - - azdata.window.openDialog(this.dialog); - } - - private initializeContent() { - this.dialog.registerContent(async view => { - this.schedulesTable = view.modelBuilder.table() - .withProperties({ - columns: [ - this.ScheduleNameText - ], - data: [], - height: 600, - width: 400 - }).component(); - - let formModel = view.modelBuilder.formContainer() - .withFormItems([{ - component: this.schedulesTable, - title: this.SchedulesLabelText - }]).withLayout({ width: '100%' }).component(); - - await view.initializeModel(formModel); - - if (this.model.schedules) { - let data: any[][] = []; - for (let i = 0; i < this.model.schedules.length; ++i) { - let schedule = this.model.schedules[i]; - data[i] = [schedule.name]; - } - this.schedulesTable.data = data; - } - }); - } - - private async execute() { - this.updateModel(); - await this.model.save(); - this._onSuccess.fire(this.model); - } - - private async cancel() { - } - - private updateModel() { - let selectedRows = this.schedulesTable.selectedRows; - if (selectedRows && selectedRows.length > 0) { - let selectedRow = selectedRows[0]; - this.model.selectedSchedule = this.model.schedules[selectedRow]; - } - } -} diff --git a/extensions/agent/src/main.ts b/extensions/agent/src/main.ts index c4105a8e60..42223ae393 100644 --- a/extensions/agent/src/main.ts +++ b/extensions/agent/src/main.ts @@ -2,11 +2,10 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; -import vscode = require('vscode'); +import * as vscode from 'vscode'; import { MainController } from './mainController'; -export let controller: MainController; +let controller: MainController; export function activate(context: vscode.ExtensionContext) { controller = new MainController(context); diff --git a/extensions/agent/src/mainController.ts b/extensions/agent/src/mainController.ts index f94f882d7f..e41d870b14 100644 --- a/extensions/agent/src/mainController.ts +++ b/extensions/agent/src/mainController.ts @@ -25,12 +25,13 @@ const localize = nls.loadMessageBundle(); /** * The main controller class that initializes the extension */ -export class TemplateMapObject { +class TemplateMapObject { notebookInfo: azdata.AgentNotebookInfo; fileUri: vscode.Uri; tempPath: string; ownerUri: string; } + export class MainController { protected _context: vscode.ExtensionContext; diff --git a/extensions/azurecore/src/account-provider/interfaces.ts b/extensions/azurecore/src/account-provider/interfaces.ts index 2da13684e4..c99887c034 100644 --- a/extensions/azurecore/src/account-provider/interfaces.ts +++ b/extensions/azurecore/src/account-provider/interfaces.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as azdata from 'azdata'; /** @@ -30,7 +28,7 @@ export interface Tenant { /** * Represents a resource exposed by an Azure Active Directory */ -export interface Resource { +interface Resource { /** * Identifier of the resource */ @@ -42,25 +40,10 @@ export interface Resource { endpoint: string; } -/** - * Represents the arguments that identify an instantiation of the AAD account provider - */ -export interface Arguments { - /** - * Host of the authority - */ - host: string; - - /** - * Identifier of the client application - */ - clientId: string; -} - /** * Represents settings for an AAD account provider */ -export interface Settings { +interface Settings { /** * Host of the authority */ @@ -138,7 +121,7 @@ export interface AzureAccountProviderMetadata extends azdata.AccountProviderMeta /** * Properties specific to an Azure account */ -export interface AzureAccountProperties { +interface AzureAccountProperties { /** * Whether or not the account is a Microsoft account */ @@ -163,7 +146,7 @@ export interface AzureAccount extends azdata.Account { /** * Token returned from a request for an access token */ -export interface AzureAccountSecurityToken { +interface AzureAccountSecurityToken { /** * Access token, itself */ diff --git a/extensions/azurecore/src/azureResource/providers/postgresServer/postgresServerService.ts b/extensions/azurecore/src/azureResource/providers/postgresServer/postgresServerService.ts index ac8a031bf8..df50f734fc 100644 --- a/extensions/azurecore/src/azureResource/providers/postgresServer/postgresServerService.ts +++ b/extensions/azurecore/src/azureResource/providers/postgresServer/postgresServerService.ts @@ -8,14 +8,14 @@ import { ResourceServiceBase, GraphData } from '../resourceTreeDataProviderBase' import { AzureResourceDatabaseServer } from '../../interfaces'; -export interface DbServerGraphData extends GraphData { +interface DbServerGraphData extends GraphData { properties: { fullyQualifiedDomainName: string; administratorLogin: string; }; } -export const serversQuery = 'where type == "microsoft.dbforpostgresql/servers"'; +const serversQuery = 'where type == "microsoft.dbforpostgresql/servers"'; export class PostgresServerService extends ResourceServiceBase { diff --git a/extensions/azurecore/src/azureResource/providers/sqlinstance/sqlInstanceService.ts b/extensions/azurecore/src/azureResource/providers/sqlinstance/sqlInstanceService.ts index 3af8658749..f5f01f1219 100644 --- a/extensions/azurecore/src/azureResource/providers/sqlinstance/sqlInstanceService.ts +++ b/extensions/azurecore/src/azureResource/providers/sqlinstance/sqlInstanceService.ts @@ -6,7 +6,7 @@ import { AzureResourceDatabaseServer } from '../../interfaces'; import { ResourceServiceBase, GraphData } from '../resourceTreeDataProviderBase'; -export interface SqlInstanceGraphData extends GraphData { +interface SqlInstanceGraphData extends GraphData { properties: { fullyQualifiedDomainName: string; administratorLogin: string; diff --git a/extensions/azurecore/src/azureResource/tree/baseTreeNodes.ts b/extensions/azurecore/src/azureResource/tree/baseTreeNodes.ts index f5533a02ea..c17bc3950b 100644 --- a/extensions/azurecore/src/azureResource/tree/baseTreeNodes.ts +++ b/extensions/azurecore/src/azureResource/tree/baseTreeNodes.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import { AppContext } from '../../appContext'; import { TreeNode } from '../treeNode'; @@ -12,7 +10,7 @@ import { IAzureResourceTreeChangeHandler } from './treeChangeHandler'; import { IAzureResourceCacheService } from '../../azureResource/interfaces'; import { AzureResourceServiceNames } from '../constants'; -export abstract class AzureResourceTreeNodeBase extends TreeNode { +abstract class AzureResourceTreeNodeBase extends TreeNode { public constructor( public readonly appContext: AppContext, public readonly treeChangeHandler: IAzureResourceTreeChangeHandler, diff --git a/extensions/azurecore/src/azureResource/utils.ts b/extensions/azurecore/src/azureResource/utils.ts index 45c3d90fc8..910371714d 100644 --- a/extensions/azurecore/src/azureResource/utils.ts +++ b/extensions/azurecore/src/azureResource/utils.ts @@ -3,12 +3,10 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); -export function getErrorMessage(error: Error | string): string { +function getErrorMessage(error: Error | string): string { return (error instanceof Error) ? error.message : error; } @@ -93,4 +91,4 @@ export function equals(one: any, other: any): boolean { } } return true; -} \ No newline at end of file +} diff --git a/extensions/azurecore/src/extension.ts b/extensions/azurecore/src/extension.ts index db68a1bb53..6c96fa7aac 100644 --- a/extensions/azurecore/src/extension.ts +++ b/extensions/azurecore/src/extension.ts @@ -36,7 +36,7 @@ let extensionContext: vscode.ExtensionContext; // The function is a duplicate of \src\paths.js. IT would be better to import path.js but it doesn't // work for now because the extension is running in different process. -export function getAppDataPath() { +function getAppDataPath() { let platform = process.platform; switch (platform) { case 'win32': return process.env['APPDATA'] || path.join(process.env['USERPROFILE'], 'AppData', 'Roaming'); @@ -46,7 +46,7 @@ export function getAppDataPath() { } } -export function getDefaultLogLocation() { +function getDefaultLogLocation() { return path.join(getAppDataPath(), 'azuredatastudio'); } @@ -132,4 +132,3 @@ function registerAzureServices(appContext: AppContext): void { appContext.registerService(AzureResourceServiceNames.subscriptionFilterService, new AzureResourceSubscriptionFilterService(new AzureResourceCacheService(extensionContext))); appContext.registerService(AzureResourceServiceNames.tenantService, new AzureResourceTenantService()); } - diff --git a/extensions/big-data-cluster/src/bigDataCluster/auth.ts b/extensions/big-data-cluster/src/bigDataCluster/auth.ts index b15f904161..292216b3b7 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/auth.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/auth.ts @@ -15,7 +15,7 @@ export async function authenticateKerberos(hostname: string): Promise { } -export type HostAndIp = { host: string, port: string }; +type HostAndIp = { host: string, port: string }; export function getHostAndPortFromEndpoint(endpoint: string): HostAndIp { let authority = vscode.Uri.parse(endpoint).authority; @@ -32,4 +32,3 @@ export function getHostAndPortFromEndpoint(endpoint: string): HostAndIp { port: undefined }; } - diff --git a/extensions/big-data-cluster/src/bigDataCluster/dialog/addControllerDialog.ts b/extensions/big-data-cluster/src/bigDataCluster/dialog/addControllerDialog.ts index 1278613a6b..1536afcb92 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/dialog/addControllerDialog.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/dialog/addControllerDialog.ts @@ -9,9 +9,9 @@ import * as nls from 'vscode-nls'; import { ClusterController, ControllerError } from '../controller/clusterControllerApi'; import { ControllerTreeDataProvider } from '../tree/controllerTreeDataProvider'; import { AuthType } from '../constants'; -import { ManageControllerCommand } from '../../extension'; import { BdcDashboardOptions } from './bdcDashboardModel'; import { ControllerNode } from '../tree/controllerTreeNode'; +import { ManageControllerCommand } from '../../commands'; const localize = nls.loadMessageBundle(); diff --git a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts index b70e27f6c8..30cb2bad1b 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardModel.ts @@ -14,7 +14,7 @@ import { ControllerTreeDataProvider } from '../tree/controllerTreeDataProvider'; export type BdcDashboardOptions = { url: string, auth: AuthType, username: string, password: string, rememberPassword: boolean }; -export type BdcErrorType = 'bdcStatus' | 'bdcEndpoints' | 'general'; +type BdcErrorType = 'bdcStatus' | 'bdcEndpoints' | 'general'; export type BdcErrorEvent = { error: Error, errorType: BdcErrorType }; export class BdcDashboardModel { diff --git a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardResourceStatusPage.ts b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardResourceStatusPage.ts index 387bf90150..a6160dbf8b 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardResourceStatusPage.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/dialog/bdcDashboardResourceStatusPage.ts @@ -15,17 +15,6 @@ import { BdcDashboardPage } from './bdcDashboardPage'; const localize = nls.loadMessageBundle(); -export interface IGroup { - groupName: string; - instances: IInstanceStatus[]; -} - -export interface IInstanceStatus { - instanceName: string; - state: string; - healthStatus: string; -} - const healthAndStatusIconColumnWidth = 25; const healthAndStatusInstanceNameColumnWidth = 100; const healthAndStatusStateColumnWidth = 150; @@ -257,4 +246,3 @@ function createMetricsAndLogsRow(modelBuilder: azdata.ModelBuilder, instanceStat return metricsAndLogsRow; } - diff --git a/extensions/big-data-cluster/src/bigDataCluster/tree/controllerTreeNode.ts b/extensions/big-data-cluster/src/bigDataCluster/tree/controllerTreeNode.ts index faef44a872..dd9fa090eb 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/tree/controllerTreeNode.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/tree/controllerTreeNode.ts @@ -9,7 +9,7 @@ import { IControllerTreeChangeHandler } from './controllerTreeChangeHandler'; import { TreeNode } from './treeNode'; import { IconPathHelper, BdcItemType, IconPath, AuthType } from '../constants'; -export abstract class ControllerTreeNode extends TreeNode { +abstract class ControllerTreeNode extends TreeNode { constructor( label: string, diff --git a/extensions/big-data-cluster/src/bigDataCluster/utils.ts b/extensions/big-data-cluster/src/bigDataCluster/utils.ts index 7b07980c2d..de33e24295 100644 --- a/extensions/big-data-cluster/src/bigDataCluster/utils.ts +++ b/extensions/big-data-cluster/src/bigDataCluster/utils.ts @@ -234,14 +234,14 @@ interface RawEndpoint { port?: number; } -export interface IEndpoint { +interface IEndpoint { serviceName: string; description: string; endpoint: string; protocol: string; } -export function getClusterEndpoints(serverInfo: azdata.ServerInfo): IEndpoint[] { +function getClusterEndpoints(serverInfo: azdata.ServerInfo): IEndpoint[] { let endpoints: RawEndpoint[] = serverInfo.options[constants.clusterEndpointsProperty]; if (!endpoints || endpoints.length === 0) { return []; } @@ -272,8 +272,8 @@ export function getBdcStatusErrorMessage(error: Error): string { return localize('endpointsError', "Unexpected error retrieving BDC Endpoints: {0}", error.message); } -export const bdcConfigSectionName = 'bigDataCluster'; -export const ignoreSslConfigName = 'ignoreSslVerification'; +const bdcConfigSectionName = 'bigDataCluster'; +const ignoreSslConfigName = 'ignoreSslVerification'; /** * Retrieves the current setting for whether to ignore SSL verification errors diff --git a/extensions/big-data-cluster/src/commands.ts b/extensions/big-data-cluster/src/commands.ts new file mode 100644 index 0000000000..5c66bb1406 --- /dev/null +++ b/extensions/big-data-cluster/src/commands.ts @@ -0,0 +1,12 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +export const ManageControllerCommand = 'bigDataClusters.command.manageController'; +export const AddControllerCommand = 'bigDataClusters.command.addController'; +export const DeleteControllerCommand = 'bigDataClusters.command.deleteController'; +export const RefreshControllerCommand = 'bigDataClusters.command.refreshController'; +export const MountHdfsCommand = 'bigDataClusters.command.mount'; +export const RefreshMountCommand = 'bigDataClusters.command.refreshmount'; +export const DeleteMountCommand = 'bigDataClusters.command.deletemount'; diff --git a/extensions/big-data-cluster/src/extension.ts b/extensions/big-data-cluster/src/extension.ts index f7b62aafd3..6a2e78c885 100644 --- a/extensions/big-data-cluster/src/extension.ts +++ b/extensions/big-data-cluster/src/extension.ts @@ -15,18 +15,11 @@ import { BdcDashboard } from './bigDataCluster/dialog/bdcDashboard'; import { BdcDashboardModel, BdcDashboardOptions } from './bigDataCluster/dialog/bdcDashboardModel'; import { MountHdfsDialogModel as MountHdfsModel, MountHdfsProperties, MountHdfsDialog, DeleteMountDialog, DeleteMountModel, RefreshMountDialog, RefreshMountModel } from './bigDataCluster/dialog/mountHdfsDialog'; import { getControllerEndpoint } from './bigDataCluster/utils'; +import * as commands from './commands'; import { HdfsDialogCancelledError } from './bigDataCluster/dialog/hdfsDialogBase'; const localize = nls.loadMessageBundle(); -export const AddControllerCommand = 'bigDataClusters.command.addController'; -export const DeleteControllerCommand = 'bigDataClusters.command.deleteController'; -export const RefreshControllerCommand = 'bigDataClusters.command.refreshController'; -export const ManageControllerCommand = 'bigDataClusters.command.manageController'; -export const MountHdfsCommand = 'bigDataClusters.command.mount'; -export const RefreshMountCommand = 'bigDataClusters.command.refreshmount'; -export const DeleteMountCommand = 'bigDataClusters.command.deletemount'; - const endpointNotFoundError = localize('mount.error.endpointNotFound', "Controller endpoint information was not found"); let throttleTimers: { [key: string]: any } = {}; @@ -46,22 +39,22 @@ function registerTreeDataProvider(treeDataProvider: ControllerTreeDataProvider): } function registerCommands(context: vscode.ExtensionContext, treeDataProvider: ControllerTreeDataProvider): void { - vscode.commands.registerCommand(AddControllerCommand, (node?: TreeNode) => { - runThrottledAction(AddControllerCommand, () => addBdcController(treeDataProvider, node)); + vscode.commands.registerCommand(commands.AddControllerCommand, (node?: TreeNode) => { + runThrottledAction(commands.AddControllerCommand, () => addBdcController(treeDataProvider, node)); }); - vscode.commands.registerCommand(DeleteControllerCommand, async (node: TreeNode) => { + vscode.commands.registerCommand(commands.DeleteControllerCommand, async (node: TreeNode) => { await deleteBdcController(treeDataProvider, node); }); - vscode.commands.registerCommand(RefreshControllerCommand, (node: TreeNode) => { + vscode.commands.registerCommand(commands.RefreshControllerCommand, (node: TreeNode) => { if (!node) { return; } treeDataProvider.notifyNodeChanged(node); }); - vscode.commands.registerCommand(ManageControllerCommand, async (info: ControllerNode | BdcDashboardOptions, addOrUpdateController: boolean = false) => { + vscode.commands.registerCommand(commands.ManageControllerCommand, async (info: ControllerNode | BdcDashboardOptions, addOrUpdateController: boolean = false) => { const title: string = `${localize('bdc.dashboard.title', "Big Data Cluster Dashboard (preview) -")} ${ControllerNode.toIpAndPort(info.url)}`; if (addOrUpdateController) { // The info may be wrong, but if it is then we'll prompt to reconnect when the dashboard is opened @@ -78,13 +71,13 @@ function registerCommands(context: vscode.ExtensionContext, treeDataProvider: Co dashboard.showDashboard(); }); - vscode.commands.registerCommand(MountHdfsCommand, e => mountHdfs(e).catch(error => { + vscode.commands.registerCommand(commands.MountHdfsCommand, e => mountHdfs(e).catch(error => { vscode.window.showErrorMessage(error instanceof Error ? error.message : error); })); - vscode.commands.registerCommand(RefreshMountCommand, e => refreshMount(e).catch(error => { + vscode.commands.registerCommand(commands.RefreshMountCommand, e => refreshMount(e).catch(error => { vscode.window.showErrorMessage(error instanceof Error ? error.message : error); })); - vscode.commands.registerCommand(DeleteMountCommand, e => deleteMount(e).catch(error => { + vscode.commands.registerCommand(commands.DeleteMountCommand, e => deleteMount(e).catch(error => { vscode.window.showErrorMessage(error instanceof Error ? error.message : error); })); } diff --git a/extensions/cms/src/cmsUtils.ts b/extensions/cms/src/cmsUtils.ts index f44fb6aa12..c3abb28d83 100644 --- a/extensions/cms/src/cmsUtils.ts +++ b/extensions/cms/src/cmsUtils.ts @@ -16,7 +16,7 @@ const mssqlProvider: string = 'MSSQL'; const CredentialNamespace = 'cmsCredentials'; const sqlLoginAuthType: string = 'SqlLogin'; -export interface CreateCmsResult { +interface CreateCmsResult { listRegisteredServersResult: mssql.ListRegisteredServersResult; connection: azdata.connection.Connection; ownerUri: string; diff --git a/extensions/dacpac/package.json b/extensions/dacpac/package.json index 3813fb5f70..a8eb43b53e 100644 --- a/extensions/dacpac/package.json +++ b/extensions/dacpac/package.json @@ -57,6 +57,7 @@ }, "devDependencies": { "@types/mocha": "^5.2.5", + "@types/node": "10", "mocha": "^5.2.0", "mocha-junit-reporter": "^1.17.0", "mocha-multi-reporters": "^1.1.7", diff --git a/extensions/dacpac/src/wizard/pages/deployPlanPage.ts b/extensions/dacpac/src/wizard/pages/deployPlanPage.ts index b055475165..afced403e4 100644 --- a/extensions/dacpac/src/wizard/pages/deployPlanPage.ts +++ b/extensions/dacpac/src/wizard/pages/deployPlanPage.ts @@ -3,7 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; import * as azdata from 'azdata'; import * as nls from 'vscode-nls'; import * as parser from 'htmlparser2'; @@ -13,7 +12,7 @@ import { DacFxConfigPage } from '../api/dacFxConfigPage'; const localize = nls.loadMessageBundle(); -export enum deployPlanXml { +enum deployPlanXml { AlertElement = 'Alert', OperationElement = 'Operation', ItemElement = 'Item', @@ -24,14 +23,14 @@ export enum deployPlanXml { DataIssueAttribute = 'DataIssue' } -export class TableObject { +class TableObject { operation: string; object: string; type: string; dataloss: boolean; } -export class DeployPlanResult { +class DeployPlanResult { columnData: Array>; dataLossAlerts: Set; } diff --git a/extensions/dacpac/yarn.lock b/extensions/dacpac/yarn.lock index e940286d91..b02627ca80 100644 --- a/extensions/dacpac/yarn.lock +++ b/extensions/dacpac/yarn.lock @@ -7,6 +7,11 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.6.tgz#b8622d50557dd155e9f2f634b7d68fd38de5e94b" integrity sha512-1axi39YdtBI7z957vdqXI4Ac25e7YihYQtJa+Clnxg1zTJEaIRbndt71O3sP4GAMgiAm0pY26/b9BrY4MR/PMw== +"@types/node@10": + version "10.17.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.4.tgz#8993a4fe3c4022fda66bf4ea660d615fc5659c6f" + integrity sha512-F2pgg+LcIr/elguz+x+fdBX5KeZXGUOp7TV8M0TVIrDezYLFRNt8oMTyps0VQ1kj5WGGoR18RdxnRDHXrIFHMQ== + agent-base@4, agent-base@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" diff --git a/extensions/import/package.json b/extensions/import/package.json index 3f539eea66..f3b0fb56af 100644 --- a/extensions/import/package.json +++ b/extensions/import/package.json @@ -51,7 +51,7 @@ } ] }, - "configuration":{ + "configuration": { "type": "object", "title": "%flatfileimport.configuration.title%", "properties": { @@ -70,7 +70,9 @@ "vscode-extension-telemetry": "0.0.18", "vscode-nls": "^3.2.1" }, - "devDependencies": {}, + "devDependencies": { + "@types/node": "10" + }, "__metadata": { "id": "23", "publisherDisplayName": "Microsoft", diff --git a/extensions/import/src/services/features.ts b/extensions/import/src/services/features.ts index 15ccfec04c..3ffd5f418b 100644 --- a/extensions/import/src/services/features.ts +++ b/extensions/import/src/services/features.ts @@ -2,14 +2,14 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; import { SqlOpsDataClient, SqlOpsFeature } from 'dataprotocol-client'; import { ClientCapabilities, StaticFeature, RPCMessageType, - ServerCapabilities + ServerCapabilities, + RequestType } from 'vscode-languageclient'; import * as UUID from 'vscode-languageclient/lib/utils/uuid'; import { Disposable } from 'vscode'; @@ -57,7 +57,7 @@ export class FlatFileImportFeature extends SqlOpsFeature { protected registerProvider(options: undefined): Disposable { const client = this._client; - let requestSender = (requestType, params) => { + let requestSender = (requestType: RequestType, params: any) => { return client.sendRequest(requestType, params).then( r => { return r as any; diff --git a/extensions/import/src/services/serviceApiManager.ts b/extensions/import/src/services/serviceApiManager.ts index d7b8cd6c9b..c2469b1c26 100644 --- a/extensions/import/src/services/serviceApiManager.ts +++ b/extensions/import/src/services/serviceApiManager.ts @@ -3,29 +3,24 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as azdata from 'azdata'; import * as vscode from 'vscode'; -import * as contracts from './contracts'; -import { SqlOpsDataClient } from 'dataprotocol-client/lib/main'; export enum ApiType { FlatFileProvider = 'FlatFileProvider' } -export interface IServiceApi { +interface IServiceApi { onRegisteredApi(type: ApiType): vscode.Event; registerApi(type: ApiType, feature: T): vscode.Disposable; } -export interface IModelViewDefinition { +interface IModelViewDefinition { id: string; modelView: azdata.ModelView; } -export class ServiceApiManager implements IServiceApi { - private modelViewRegistrations: { [id: string]: boolean } = {}; +class ServiceApiManager implements IServiceApi { private featureEventChannels: { [type: string]: vscode.EventEmitter } = {}; private _onRegisteredModelView = new vscode.EventEmitter(); diff --git a/extensions/import/src/services/serviceClient.ts b/extensions/import/src/services/serviceClient.ts index e0631d315d..70d1ca162a 100644 --- a/extensions/import/src/services/serviceClient.ts +++ b/extensions/import/src/services/serviceClient.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import { SqlOpsDataClient, ClientOptions } from 'dataprotocol-client'; import { ServerProvider, Events } from 'service-downloader'; import { ServerOptions, TransportKind } from 'vscode-languageclient'; @@ -17,7 +15,6 @@ import { EventAndListener } from 'eventemitter2'; import { Telemetry, LanguageClientErrorHandler } from './telemetry'; import * as Constants from '../constants'; import { TelemetryFeature, FlatFileImportFeature } from './features'; -import * as serviceUtils from './serviceUtils'; import { promises as fs } from 'fs'; export class ServiceClient { diff --git a/extensions/import/src/services/serviceUtils.ts b/extensions/import/src/services/serviceUtils.ts index fed1422e87..0e2321150a 100644 --- a/extensions/import/src/services/serviceUtils.ts +++ b/extensions/import/src/services/serviceUtils.ts @@ -3,80 +3,9 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as path from 'path'; -import * as os from 'os'; - -// The function is a duplicate of \src\paths.js. IT would be better to import path.js but it doesn't -// work for now because the extension is running in different process. -export function getAppDataPath(): string { - let platform = process.platform; - switch (platform) { - case 'win32': return process.env['APPDATA'] || path.join(process.env['USERPROFILE'], 'AppData', 'Roaming'); - case 'darwin': return path.join(os.homedir(), 'Library', 'Application Support'); - case 'linux': return process.env['XDG_CONFIG_HOME'] || path.join(os.homedir(), '.config'); - default: throw new Error('Platform not supported'); - } -} - -export function ensure(target: object, key: string): any { +export function ensure(target: { [key: string]: any }, key: string): any { if (target[key] === void 0) { target[key] = {} as any; } return target[key]; } - -export interface IPackageInfo { - name: string; - version: string; - aiKey: string; -} - -export function getPackageInfo(packageJson: any): IPackageInfo { - if (packageJson) { - return { - name: packageJson.name, - version: packageJson.version, - aiKey: packageJson.aiKey - }; - } -} - -export function verifyPlatform(): Thenable { - if (os.platform() === 'darwin' && parseFloat(os.release()) < 16) { - return Promise.resolve(false); - } else { - return Promise.resolve(true); - } -} - -export function getRuntimeDisplayName(runtime: Runtime): string { - switch (runtime) { - case Runtime.Windows_64: - return 'Windows'; - case Runtime.Windows_86: - return 'Windows'; - case Runtime.OSX: - return 'OSX'; - case Runtime.Linux_64: - return 'Linux'; - default: - return 'Unknown'; - } -} - -export enum Runtime { - Unknown = 'Unknown', - Windows_86 = 'Windows_86', - Windows_64 = 'Windows_64', - OSX = 'OSX', - CentOS_7 = 'CentOS_7', - Debian_8 = 'Debian_8', - Fedora_23 = 'Fedora_23', - OpenSUSE_13_2 = 'OpenSUSE_13_2', - SLES_12_2 = 'SLES_12_2', - RHEL_7 = 'RHEL_7', - Ubuntu_14 = 'Ubuntu_14', - Ubuntu_16 = 'Ubuntu_16', - Linux_64 = 'Linux_64', - Linux_86 = 'Linux-86' -} diff --git a/extensions/import/src/services/telemetry.ts b/extensions/import/src/services/telemetry.ts index 0ed23ccb51..31c802dd6b 100644 --- a/extensions/import/src/services/telemetry.ts +++ b/extensions/import/src/services/telemetry.ts @@ -74,7 +74,7 @@ export class LanguageClientErrorHandler { /** * Filters error paths to only include source files. Exported to support testing */ -export function FilterErrorPath(line: string): string { +function FilterErrorPath(line: string): string | undefined { if (line) { let values: string[] = line.split('/out/'); if (values.length <= 1) { @@ -84,6 +84,7 @@ export function FilterErrorPath(line: string): string { return values[1]; } } + return undefined; } export class Telemetry { diff --git a/extensions/import/src/wizard/api/basePage.ts b/extensions/import/src/wizard/api/basePage.ts index 98fd14ff05..a5747b1e90 100644 --- a/extensions/import/src/wizard/api/basePage.ts +++ b/extensions/import/src/wizard/api/basePage.ts @@ -40,9 +40,9 @@ export abstract class BasePage { * Sets up a navigation validator. * This will be called right before onPageEnter(). */ - public abstract setupNavigationValidator(); + public abstract setupNavigationValidator(): void; - protected async getServerValues(): Promise<{ connection, displayName, name }[]> { + protected async getServerValues(): Promise<{ connection: azdata.connection.Connection, displayName: string, name: string }[]> { let cons = await azdata.connection.getActiveConnections(); // This user has no active connections ABORT MISSION if (!cons || cons.length === 0) { @@ -90,7 +90,7 @@ export abstract class BasePage { return values; } - protected async getDatabaseValues(): Promise<{ displayName, name }[]> { + protected async getDatabaseValues(): Promise<{ displayName: string, name: string }[]> { let idx = -1; let count = -1; let values = (await azdata.connection.listDatabases(this.model.server.connectionId)).map(db => { diff --git a/extensions/import/src/wizard/pages/prosePreviewPage.ts b/extensions/import/src/wizard/pages/prosePreviewPage.ts index 9f8b89b49b..0e777ea57c 100644 --- a/extensions/import/src/wizard/pages/prosePreviewPage.ts +++ b/extensions/import/src/wizard/pages/prosePreviewPage.ts @@ -3,15 +3,12 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as azdata from 'azdata'; import * as nls from 'vscode-nls'; import { ImportDataModel } from '../api/models'; import { ImportPage } from '../api/importPage'; import { FlatFileProvider } from '../../services/contracts'; import { FlatFileWizard } from '../flatFileWizard'; -import { PerformanceObserver } from 'perf_hooks'; const localize = nls.loadMessageBundle(); diff --git a/extensions/import/tsconfig.json b/extensions/import/tsconfig.json index e1ca13ebe6..833d784992 100644 --- a/extensions/import/tsconfig.json +++ b/extensions/import/tsconfig.json @@ -12,10 +12,7 @@ "moduleResolution": "node", "declaration": false, "strict": false, - "noImplicitAny": false, "noUnusedParameters": false, - "noImplicitReturns": false, - "noUnusedLocals": false, }, "exclude": [ "node_modules" diff --git a/extensions/import/yarn.lock b/extensions/import/yarn.lock index c0238c26c9..8866bfc1d3 100644 --- a/extensions/import/yarn.lock +++ b/extensions/import/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@types/node@10": + version "10.17.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.4.tgz#8993a4fe3c4022fda66bf4ea660d615fc5659c6f" + integrity sha512-F2pgg+LcIr/elguz+x+fdBX5KeZXGUOp7TV8M0TVIrDezYLFRNt8oMTyps0VQ1kj5WGGoR18RdxnRDHXrIFHMQ== + agent-base@4: version "4.2.1" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" diff --git a/extensions/integration-tests/package.json b/extensions/integration-tests/package.json index 19f63493fe..dc21a80dee 100644 --- a/extensions/integration-tests/package.json +++ b/extensions/integration-tests/package.json @@ -55,7 +55,6 @@ "chai": "3.5.0", "mocha-junit-reporter": "^1.17.0", "mocha-multi-reporters": "^1.1.7", - "uuid": "^3.3.2", "vscode": "1.1.5" }, "dependencies": { diff --git a/extensions/integration-tests/src/cms.test.ts b/extensions/integration-tests/src/cms.test.ts index b9bc5e6975..2ef798f8dc 100644 --- a/extensions/integration-tests/src/cms.test.ts +++ b/extensions/integration-tests/src/cms.test.ts @@ -3,14 +3,12 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'mocha'; import * as vscode from 'vscode'; import * as azdata from 'azdata'; import * as mssql from '../../mssql'; import * as utils from './utils'; -import * as uuid from 'uuid'; +import * as uuid from './uuid'; import { context } from './testContext'; import assert = require('assert'); import { getStandaloneServer, TestServerProfile, getBdcServer } from './testConfig'; diff --git a/extensions/integration-tests/src/dacpac.test.ts b/extensions/integration-tests/src/dacpac.test.ts index 627f8b9acd..13584585fa 100644 --- a/extensions/integration-tests/src/dacpac.test.ts +++ b/extensions/integration-tests/src/dacpac.test.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'mocha'; import * as azdata from 'azdata'; import * as utils from './utils'; @@ -15,7 +13,7 @@ import * as mssql from '../../mssql'; import * as vscode from 'vscode'; import { context } from './testContext'; import { getStandaloneServer } from './testConfig'; -import assert = require('assert'); +import * as assert from 'assert'; const retryCount = 24; // 2 minutes const dacpac1: string = path.join(__dirname, '../testData/Database1.dacpac'); diff --git a/extensions/integration-tests/src/index.ts b/extensions/integration-tests/src/index.ts index 3025a34988..06db934db6 100644 --- a/extensions/integration-tests/src/index.ts +++ b/extensions/integration-tests/src/index.ts @@ -10,7 +10,7 @@ import { SuiteType, getSuiteType } from 'adstest'; import { context } from './testContext'; -import path = require('path'); +import * as path from 'path'; const suite = getSuiteType(); diff --git a/extensions/integration-tests/src/notebook.test.ts b/extensions/integration-tests/src/notebook.test.ts index eb7130bfcb..7f309c0933 100644 --- a/extensions/integration-tests/src/notebook.test.ts +++ b/extensions/integration-tests/src/notebook.test.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'mocha'; import * as assert from 'assert'; import * as azdata from 'azdata'; @@ -458,4 +456,3 @@ class NotebookTester { assert(languageInNotebook === languageConfigured, `Expected cell language is: ${languageConfigured}, Actual: ${languageInNotebook}`); } } - diff --git a/extensions/integration-tests/src/notebook.util.ts b/extensions/integration-tests/src/notebook.util.ts index 64393781e8..f482ba651a 100644 --- a/extensions/integration-tests/src/notebook.util.ts +++ b/extensions/integration-tests/src/notebook.util.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'mocha'; import * as azdata from 'azdata'; import * as vscode from 'vscode'; diff --git a/extensions/integration-tests/src/objectExplorer.test.ts b/extensions/integration-tests/src/objectExplorer.test.ts index dbe87b9bfd..cac4fd90a0 100644 --- a/extensions/integration-tests/src/objectExplorer.test.ts +++ b/extensions/integration-tests/src/objectExplorer.test.ts @@ -3,14 +3,12 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'mocha'; import * as azdata from 'azdata'; import { context } from './testContext'; import { getBdcServer, TestServerProfile, getAzureServer, getStandaloneServer } from './testConfig'; import { connectToServer, createDB, deleteDB, DefaultConnectTimeoutInMs, asyncTimeout } from './utils'; -import assert = require('assert'); +import * as assert from 'assert'; import { stressify } from 'adstest'; if (context.RunTest) { diff --git a/extensions/integration-tests/src/schemaCompare.test.ts b/extensions/integration-tests/src/schemaCompare.test.ts index a81f600cb0..d4b7524c0f 100644 --- a/extensions/integration-tests/src/schemaCompare.test.ts +++ b/extensions/integration-tests/src/schemaCompare.test.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'mocha'; import * as azdata from 'azdata'; import * as vscode from 'vscode'; @@ -14,7 +12,7 @@ import * as os from 'os'; import * as fs from 'fs'; const path = require('path'); import { context } from './testContext'; -import assert = require('assert'); +import * as assert from 'assert'; import { getStandaloneServer } from './testConfig'; import { stressify } from 'adstest'; diff --git a/extensions/integration-tests/src/setup.test.ts b/extensions/integration-tests/src/setup.test.ts index e309042f3e..1f54d7819f 100644 --- a/extensions/integration-tests/src/setup.test.ts +++ b/extensions/integration-tests/src/setup.test.ts @@ -3,12 +3,10 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'mocha'; import * as vscode from 'vscode'; import { context } from './testContext'; -import assert = require('assert'); +import * as assert from 'assert'; import { getConfigValue, EnvironmentVariable_BDC_SERVER, EnvironmentVariable_BDC_USERNAME, EnvironmentVariable_BDC_PASSWORD, EnvironmentVariable_AZURE_PASSWORD, EnvironmentVariable_AZURE_SERVER, EnvironmentVariable_AZURE_USERNAME, EnvironmentVariable_STANDALONE_PASSWORD, EnvironmentVariable_STANDALONE_SERVER, EnvironmentVariable_STANDALONE_USERNAME, EnvironmentVariable_PYTHON_PATH } from './testConfig'; assert(getConfigValue(EnvironmentVariable_BDC_SERVER) !== undefined && @@ -34,4 +32,4 @@ if (!context.RunTest) { await vscode.commands.executeCommand('workbench.action.reloadWindow'); }); }); -} \ No newline at end of file +} diff --git a/extensions/integration-tests/src/testConfig.ts b/extensions/integration-tests/src/testConfig.ts index cbb1fdb6a6..4f495ee857 100644 --- a/extensions/integration-tests/src/testConfig.ts +++ b/extensions/integration-tests/src/testConfig.ts @@ -41,8 +41,8 @@ export enum EngineType { BigDataCluster } -let connectionProviderMapping = {}; -let authenticationTypeMapping = {}; +let connectionProviderMapping: { [key: string]: { name: string; displayName: string } } = {}; +let authenticationTypeMapping: { [key: string]: { name: string; displayName: string } } = {}; connectionProviderMapping[ConnectionProvider.SQLServer] = { name: 'MSSQL', displayName: 'Microsoft SQL Server' }; authenticationTypeMapping[AuthenticationType.SqlLogin] = { name: 'SqlLogin', displayName: 'SQL Login' }; diff --git a/extensions/integration-tests/src/utils.ts b/extensions/integration-tests/src/utils.ts index fecbc37e10..71a41c3eea 100644 --- a/extensions/integration-tests/src/utils.ts +++ b/extensions/integration-tests/src/utils.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import assert = require('assert'); +import * as assert from 'assert'; import * as azdata from 'azdata'; import * as vscode from 'vscode'; import * as fs from 'fs'; diff --git a/extensions/integration-tests/src/uuid.ts b/extensions/integration-tests/src/uuid.ts new file mode 100644 index 0000000000..c90b892dd4 --- /dev/null +++ b/extensions/integration-tests/src/uuid.ts @@ -0,0 +1,108 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +/** + * Represents a UUID as defined by rfc4122. + */ +export interface UUID { + + /** + * @returns the canonical representation in sets of hexadecimal numbers separated by dashes. + */ + asHex(): string; +} + +class ValueUUID implements UUID { + + constructor(public _value: string) { + // empty + } + + public asHex(): string { + return this._value; + } +} + +class V4UUID extends ValueUUID { + + private static readonly _chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']; + + private static readonly _timeHighBits = ['8', '9', 'a', 'b']; + + private static _oneOf(array: string[]): string { + return array[Math.floor(array.length * Math.random())]; + } + + private static _randomHex(): string { + return V4UUID._oneOf(V4UUID._chars); + } + + constructor() { + super([ + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + '-', + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + '-', + '4', + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + '-', + V4UUID._oneOf(V4UUID._timeHighBits), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + '-', + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + V4UUID._randomHex(), + ].join('')); + } +} + +export function v4(): UUID { + return new V4UUID(); +} + +const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; + +export function isUUID(value: string): boolean { + return _UUIDPattern.test(value); +} + +/** + * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. + * @param value A uuid string. + */ +export function parse(value: string): UUID { + if (!isUUID(value)) { + throw new Error('invalid uuid'); + } + + return new ValueUUID(value); +} + +export function generateUuid(): string { + return v4().asHex(); +} diff --git a/extensions/liveshare/src/guestSessionManager.ts b/extensions/liveshare/src/guestSessionManager.ts index 8b1941d9a8..a14986a2b4 100644 --- a/extensions/liveshare/src/guestSessionManager.ts +++ b/extensions/liveshare/src/guestSessionManager.ts @@ -55,7 +55,7 @@ export class GuestSessionManager { if (documentState) { let queryDocument = await azdata.queryeditor.getQueryDocument(doc.uri.toString()); if (queryDocument) { - let connectionOptions: Map = new Map(); + let connectionOptions: { [key: string]: any } = {}; connectionOptions['providerName'] = LiveShareProviderId; connectionOptions['serverName'] = documentState.serverName; connectionOptions['databaseName'] = documentState.databaseName; diff --git a/extensions/liveshare/src/liveshare.ts b/extensions/liveshare/src/liveshare.ts index 41012cfb0c..85efdca22f 100644 --- a/extensions/liveshare/src/liveshare.ts +++ b/extensions/liveshare/src/liveshare.ts @@ -9,27 +9,10 @@ import * as vscode from 'vscode'; -/** - * Root API that is used to acquire access to the main Live Share API. - * - * An implementation of this interface is returned by the Live Share extension's - * activation function. Ordinarily this interface is not used directly; use the - * `getApiAsync()` helper function above instead. - */ -export interface LiveShareExtension { - /** - * Requests a specific version of the Live Share API for use by another extension. - * - * @returns a promise that resolves to the requested API, or `null` if the requested - * API is not available - */ - getApi(requestedApiVersion: string): Promise; -} - /** * Forward definition of the ContactServiceProvider interface */ -export interface ContactServiceProvider { +interface ContactServiceProvider { } @@ -216,7 +199,7 @@ export interface LiveShare { getContacts(emails: string[]): Promise; } -export interface ShareOptions { +interface ShareOptions { /** * Suppress display of the usual notification that indicates that sharing * started. Also suppresses copying the join link to the clipboard. When @@ -232,7 +215,7 @@ export interface ShareOptions { access?: Access; } -export interface JoinOptions { +interface JoinOptions { /** * Open the joined workspace in a new window, instead of re-using the current window. */ @@ -243,7 +226,7 @@ export interface JoinOptions { /** * Represents a local TCP server listening on the given port. */ -export interface Server { +interface Server { /** * Local TCP port the server is listening on. */ @@ -258,14 +241,14 @@ export interface Server { browseUrl?: string; } -export enum Role { +enum Role { None = 0, Host = 1, Guest = 2, } /** This is just a placeholder for a richer access control model to be added later. */ -export enum Access { +enum Access { None = 0, ReadOnly = 1, ReadWrite = 3, @@ -278,7 +261,7 @@ export enum Access { * NOTE: Access to user information may be restricted. * If the caller is not permitted, the `Peer.user` property returns 'null'. */ -export interface UserInfo { +interface UserInfo { /** * User display name. */ @@ -304,7 +287,7 @@ export interface UserInfo { /** * Represents one participant in a sharing session. */ -export interface Peer { +interface Peer { /** Integer that uniquely identifies a peer within the scope of a session. */ readonly peerNumber: number; @@ -332,27 +315,27 @@ export interface Peer { /** * Information about the current session, including user information (in the base class). */ -export interface Session extends Peer { +interface Session extends Peer { /** * Globally unique identifier for the current session, or null if there is no active session. */ readonly id: string | null; } -export interface SessionChangeEvent { +interface SessionChangeEvent { readonly session: Session; } -export interface PeersChangeEvent { +interface PeersChangeEvent { readonly added: Peer[]; readonly removed: Peer[]; } -export interface RequestHandler { +interface RequestHandler { (args: any[], cancellation: vscode.CancellationToken): any | Promise; } -export interface NotifyHandler { +interface NotifyHandler { (args: object): void; } @@ -435,100 +418,19 @@ export interface SharedServiceProxy { notify(name: string, args: object): void; } -/** - * Error thrown by a proxy when a request to a shared service cannot be made - * because the service is not available or cannot be reached. - */ -export interface SharedServiceProxyError extends Error { -} - -/** - * Error thrown by a proxy when a shared service's request handler threw an error. - * The remote message and remote stack are propagated back to the proxy. - */ -export interface SharedServiceResponseError extends Error { - remoteStack?: string; -} - /** * Identifiers for Live Share tree views. These identifiers may be used by other extensions * to extend Live Share tree views with additional nodes via the `registerTreeDataProvider()` * API. */ -export enum View { +enum View { Session = 'liveshare.session', ExplorerSession = 'liveshare.session.explorer', Contacts = 'liveshare.contacts', Help = 'liveshare.help', } -/** - * Identifiers for Live Share tree view items. These identifiers may be used by other - * extensions to extend Live Share tree items with additional commands using conditional - * expressions in the `view/item/context` section of their own package.json. - */ -export enum ViewItem { - // session item groups - Participants = 'participants', - Servers = 'servers', - Terminals = 'terminals', - - // participants - CurrentUser = 'participants.currentuser', // (not currently shown) - Guest = 'participants.guest', - FollowedGuest = 'participants.guest.followed', - Participant = 'participants.participant', - FollowedParticipant = 'participants.participant.followed', - - GuestAnonymous = 'participants.guest.anonymous', - FollowedGuestAnonymous = 'participants.guest.followed.anonymous', - - GuestElevated = 'participants.guest.elevated', - FollowedGuestElevated = 'participants.guest.followed.elevated', - - // servers - LocalServer = 'servers.local', - RemoteServer = 'servers.remote', - - // terminals - LocalTerminalReadOnly = 'terminals.local.readonly', - LocalTerminalReadWrite = 'terminals.local.readwrite', - RemoteTerminal = 'terminals.remote', - - // contacts - SuggestedContacts = 'contacts.suggested', - AvailableContacts = 'contacts.available', - ContactsProvider = 'contacts.provider', - SelfContact = 'contacts.selfContact', - Contact = 'contacts.contact', - ContactOffline = 'contacts.contact.offline', - RecentContact = 'contacts.recentContact', - RecentContactOffline = 'contacts.recentContact.offline', - NoContact = 'contacts.noContact', - RecentContacts = 'contacts.RecentContacts', - NoSuggestedContacts = 'contacts.NoSuggestedUsers', - NoRecentContacts = 'contacts.NoRecentContacts', - InvitedContact = 'contacts.invited', - - // help - SessionFeedbackQuestion = 'help.sessionFeedback', - ReportAProblem = 'help.reportAProblem', - TweetUsYourFeedback = 'help.tweetUsYourFeedback', - Survey = 'help.survey', - GoodFeedback = 'help.goodFeedback', - BadFeedback = 'help.badFeedback', - DontAskAgain = 'help.dontAskAgain', - Thankyou = 'help.thankyou', - MoreInfo = 'help.moreinfo', - - // Shown while session sharing / joining is in progress - Loading = 'loading', - - // Other / unspecified item type - Other = 'other', -} - -export interface InviteContactOptions { +interface InviteContactOptions { /** * This option will force the invite to only use the email channel @@ -539,7 +441,7 @@ export interface InviteContactOptions { /** * Represent a contact with live presence support */ -export interface Contact { +interface Contact { readonly onDidChange: vscode.Event; readonly id: string; readonly email: string; @@ -553,7 +455,7 @@ export interface Contact { /** * Represent a collection of contacts that can be disposed at once */ -export interface ContactsCollection { +interface ContactsCollection { readonly contacts: { [email: string]: Contact }; dispose(): Promise; } diff --git a/extensions/liveshare/src/providers/statusProvider.ts b/extensions/liveshare/src/providers/statusProvider.ts index 15a87eb82c..9418a09a67 100644 --- a/extensions/liveshare/src/providers/statusProvider.ts +++ b/extensions/liveshare/src/providers/statusProvider.ts @@ -35,7 +35,7 @@ export class StatusProvider { if (args && args.ownerUri && args.profile) { let queryDocument = await azdata.queryeditor.getQueryDocument(args.ownerUri); if (queryDocument) { - let connectionOptions: Map = new Map(); + let connectionOptions: { [key: string]: any } = {}; connectionOptions['providerName'] = LiveShareProviderId; connectionOptions['serverName'] = args.profile.options['server']; connectionOptions['databaseName'] = args.profile.options['database']; diff --git a/extensions/liveshare/tsconfig.json b/extensions/liveshare/tsconfig.json index a80576b9e2..971db11d01 100644 --- a/extensions/liveshare/tsconfig.json +++ b/extensions/liveshare/tsconfig.json @@ -3,8 +3,7 @@ "compilerOptions": { "outDir": "./out", "strict": false, - "noUnusedParameters": false, - "noImplicitAny": false + "noUnusedParameters": false }, "include": [ "src/**/*" diff --git a/extensions/mssql/package.json b/extensions/mssql/package.json index 1b796dde20..441d002910 100644 --- a/extensions/mssql/package.json +++ b/extensions/mssql/package.json @@ -996,7 +996,6 @@ "error-ex": "^1.3.2", "figures": "^2.0.0", "find-remove": "1.2.1", - "fs-extra": "^3.0.1", "kerberos": "^1.1.3", "request": "^2.88.0", "request-promise": "^4.2.2", @@ -1004,14 +1003,16 @@ "stream-meter": "^1.0.4", "through2": "^3.0.1", "tough-cookie": "^3.0.1", - "uri-js": "^4.2.2", "vscode-extension-telemetry": "0.1.0", "vscode-languageclient": "5.2.1", "vscode-nls": "^4.0.0" }, "devDependencies": { + "@types/bytes": "^3.0.0", "@types/kerberos": "^1.1.0", "@types/request": "^2.48.2", + "@types/request-promise": "^4.1.44", + "@types/stream-meter": "^0.0.22", "@types/through2": "^2.0.34" } } diff --git a/extensions/mssql/src/apiWrapper.ts b/extensions/mssql/src/apiWrapper.ts index 87f6dc25eb..08c2d090c0 100644 --- a/extensions/mssql/src/apiWrapper.ts +++ b/extensions/mssql/src/apiWrapper.ts @@ -85,7 +85,7 @@ export class ApiWrapper { public openTextDocument(uri: vscode.Uri): Thenable; public openTextDocument(options: { language?: string; content?: string; }): Thenable; - public openTextDocument(uriOrOptions): Thenable { + public openTextDocument(uriOrOptions: any): Thenable { return vscode.workspace.openTextDocument(uriOrOptions); } diff --git a/extensions/mssql/src/cms/cmsService.ts b/extensions/mssql/src/cms/cmsService.ts index 5932c5e0c9..a06419f4db 100644 --- a/extensions/mssql/src/cms/cmsService.ts +++ b/extensions/mssql/src/cms/cmsService.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as azdata from 'azdata'; import * as constants from '../constants'; import * as contracts from '../contracts'; diff --git a/extensions/mssql/src/contextProvider.ts b/extensions/mssql/src/contextProvider.ts index 8c5ed23d2e..d2ba9c6969 100644 --- a/extensions/mssql/src/contextProvider.ts +++ b/extensions/mssql/src/contextProvider.ts @@ -2,18 +2,18 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; + import * as vscode from 'vscode'; import * as azdata from 'azdata'; import * as types from './types'; import * as Constants from './constants'; -export enum BuiltInCommands { +enum BuiltInCommands { SetContext = 'setContext', } -export enum ContextKeys { +enum ContextKeys { ISCLOUD = 'mssql:iscloud', EDITIONID = 'mssql:engineedition', ISCLUSTER = 'mssql:iscluster', @@ -26,7 +26,7 @@ const isCloudEditions = [ 11 ]; -export function setCommandContext(key: ContextKeys | string, value: any) { +function setCommandContext(key: ContextKeys | string, value: any) { return vscode.commands.executeCommand(BuiltInCommands.SetContext, key, value); } diff --git a/extensions/mssql/src/dashboard/bookExtensions.ts b/extensions/mssql/src/dashboard/bookExtensions.ts index 50cf641a10..c2c9f80a12 100644 --- a/extensions/mssql/src/dashboard/bookExtensions.ts +++ b/extensions/mssql/src/dashboard/bookExtensions.ts @@ -30,13 +30,13 @@ const resolveBookResources = (extension: vscode.Extension, books: BookContr return result; }; -export interface BookContribution { +interface BookContribution { name: string; path: string; when?: string; } -export namespace BookContributions { +namespace BookContributions { export function merge(a: BookContribution[], b: BookContribution[]): BookContribution[] { if (!a) { diff --git a/extensions/mssql/src/escapeException.ts b/extensions/mssql/src/escapeException.ts index 1614a9bcce..d6d2636d0a 100644 --- a/extensions/mssql/src/escapeException.ts +++ b/extensions/mssql/src/escapeException.ts @@ -2,6 +2,5 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; export default require('error-ex')('EscapeException'); diff --git a/extensions/mssql/src/hdfs/aclEntry.ts b/extensions/mssql/src/hdfs/aclEntry.ts index 096a5d978e..ac458ae8fe 100644 --- a/extensions/mssql/src/hdfs/aclEntry.ts +++ b/extensions/mssql/src/hdfs/aclEntry.ts @@ -290,7 +290,7 @@ export function parseAclList(aclString: string): AclEntry[] { * assumes the string has already been checked for validity. * @param aclString The string representation of the ACL entry */ -export function parseAclEntry(aclString: string): AclEntry { +function parseAclEntry(aclString: string): AclEntry { const parts: string[] = aclString.split(':'); let i = 0; const scope: AclEntryScope = parts.length === 4 && parts[i++] === 'default' ? AclEntryScope.default : AclEntryScope.access; diff --git a/extensions/mssql/src/hdfs/webhdfs.ts b/extensions/mssql/src/hdfs/webhdfs.ts index 40215d4693..bc3e7802e5 100644 --- a/extensions/mssql/src/hdfs/webhdfs.ts +++ b/extensions/mssql/src/hdfs/webhdfs.ts @@ -15,19 +15,20 @@ import { PermissionStatus, AclEntry, parseAclList, PermissionType, parseAclPermi import { Mount } from './mount'; import { everyoneName, ownerPostfix, owningGroupPostfix } from '../localizedConstants'; import { FileStatus, parseHdfsFileType } from './fileStatus'; +import { Readable, Transform } from 'stream'; const localize = nls.loadMessageBundle(); const ErrorMessageInvalidDataStructure = localize('webhdfs.invalidDataStructure', "Invalid Data Structure"); -const emitError = (instance, err) => { - const isErrorEmitted = instance.errorEmitted; +const emitError = (instance: request.Request | Transform, err: any) => { + const isErrorEmitted = (instance as any).errorEmitted; if (!isErrorEmitted) { instance.emit('error', err); instance.emit('finish'); } - instance.errorEmitted = true; + (instance as any).errorEmitted = true; }; export class WebHDFS { @@ -41,7 +42,7 @@ export class WebHDFS { } let missingProps = ['host', 'port', 'path'] - .filter(p => !opts.hasOwnProperty(p) || !opts[p]); + .filter((p: keyof IHdfsOptions) => !opts.hasOwnProperty(p) || !opts[p]); if (missingProps && missingProps.length > 0) { throw new Error(localize('webhdfs.missingProperties', "Unable to create WebHDFS client due to missing options: ${0}", missingProps.join(', '))); @@ -224,7 +225,7 @@ export class WebHDFS { ); this.ensureCookie(requestParams); // Add a wrapper to handle unauthorized requests by adding kerberos auth steps - let handler = (error, response) => { + let handler = (error: any, response: request.Response) => { if (error && error.statusCode === 401 && this._requestParams.isKerberos) { this.requestWithKerberosSync(requestParams, callback); } else { @@ -234,7 +235,7 @@ export class WebHDFS { this.doSendRequest(requestParams, handler); } - private ensureCookie(requestParams: { headers?: {} }) { + private ensureCookie(requestParams: { headers?: { [key: string]: string } }) { if (this._authCookie && this._authCookie.expiryTime() > Date.now()) { requestParams.headers = requestParams.headers || {}; requestParams.headers['cookie'] = `${this._authCookie.key}=${this._authCookie.value}`; @@ -242,7 +243,7 @@ export class WebHDFS { } private doSendRequest(requestParams: any, callback: (error: HdfsError, response: any) => void): void { - request(requestParams, (error, response, body) => { + request(requestParams, (error: any, response: request.Response, body: any) => { if (error || this.isError(response)) { let hdfsError = this.parseError(response, body, error); callback(hdfsError, response); @@ -486,7 +487,7 @@ export class WebHDFS { // Unknown type - just ignore since we don't currently support the other types return; } - e.getAllPermissions().forEach( sp => { + e.getAllPermissions().forEach(sp => { targetEntry.addPermission(sp.scope, sp.permission); }); }); @@ -727,7 +728,7 @@ export class WebHDFS { cb(); } }); - let handleErr = (err) => { + let handleErr = (err: any) => { replyStream.emit('error', err); replyStream.end(); }; @@ -735,7 +736,7 @@ export class WebHDFS { // After redirect, create valid stream to correct location // and pipe the intermediate stream to it, unblocking the data flow params.headers['content-type'] = 'application/octet-stream'; - let upload = request(params, (err, res, bo) => { + let upload = request(params, (err: any, res: request.Response, bo: any) => { if (err || this.isError(res)) { emitError(replyStream, this.parseError(res, bo, err)); replyStream.end(); @@ -760,11 +761,11 @@ export class WebHDFS { private doCreateWriteStream(params: any): fs.WriteStream { let canResume: boolean = true; - let stream = undefined; - let req = request(params, (error, response, body) => { + let stream: Readable; + let req = request(params, (error: any, response: request.Response, body: any) => { // Handle redirect only if there was not an error (e.g. res is defined) if (response && this.isRedirect(response)) { - let upload = request(Object.assign(params, { url: response.headers.location }), (err, res, bo) => { + let upload = request(Object.assign(params, { url: response.headers.location }), (err: any, res: request.Response, bo: any) => { if (err || this.isError(res)) { emitError(req, this.parseError(res, bo, err)); req.end(); @@ -784,7 +785,7 @@ export class WebHDFS { emitError(req, this.parseError(response, body, error)); } }); - req.on('pipe', (src) => { + req.on('pipe', (src: Readable) => { // Pause read stream stream = src; stream.pause(); @@ -794,7 +795,7 @@ export class WebHDFS { canResume = false; stream.on('resume', () => { if (!canResume) { - stream._readableState.flowing = false; + (stream as any)._readableState.flowing = false; // i guess we are unsafely accessing this } }); // Unpipe initial request @@ -845,7 +846,7 @@ export class WebHDFS { // Else, must add kerberos token and handle redirects params.followRedirect = false; let replyStream = through(); - let handleErr = (err) => { + let handleErr = (err: any) => { replyStream.emit('error', err); replyStream.end(); }; @@ -960,7 +961,7 @@ export class WebHDFS { this.unlink(path, recursive, callback); } - public static createClient(opts, requestParams): WebHDFS { + public static createClient(opts: IHdfsOptions, requestParams: IRequestParams): WebHDFS { return new WebHDFS( Object.assign( { diff --git a/extensions/mssql/src/main.ts b/extensions/mssql/src/main.ts index ca21c4b847..24e7ab68de 100644 --- a/extensions/mssql/src/main.ts +++ b/extensions/mssql/src/main.ts @@ -181,8 +181,8 @@ async function handleNewNotebookTask(oeContext?: azdata.ObjectExplorerContext, p async function handleOpenNotebookTask(profile: azdata.IConnectionProfile): Promise { let notebookFileTypeName = localize('notebookFileType', "Notebooks"); - let filter = {}; - filter[notebookFileTypeName] = 'ipynb'; + let filter: { [key: string]: string[] } = {}; + filter[notebookFileTypeName] = ['ipynb']; let uris = await vscode.window.showOpenDialog({ filters: filter, canSelectFiles: true, diff --git a/extensions/mssql/src/objectExplorerNodeProvider/command.ts b/extensions/mssql/src/objectExplorerNodeProvider/command.ts index b79f39bb54..dfb2b7ebd0 100644 --- a/extensions/mssql/src/objectExplorerNodeProvider/command.ts +++ b/extensions/mssql/src/objectExplorerNodeProvider/command.ts @@ -15,12 +15,12 @@ import * as utils from '../utils'; import * as constants from '../constants'; import { AppContext } from '../appContext'; -export interface ICommandContextParsingOptions { +interface ICommandContextParsingOptions { editor: boolean; uri: boolean; } -export interface ICommandBaseContext { +interface ICommandBaseContext { command: string; editor?: vscode.TextEditor; uri?: vscode.Uri; @@ -30,7 +30,7 @@ export interface ICommandUnknownContext extends ICommandBaseContext { type: 'unknown'; } -export interface ICommandUriContext extends ICommandBaseContext { +interface ICommandUriContext extends ICommandBaseContext { type: 'uri'; } @@ -44,7 +44,7 @@ export interface ICommandObjectExplorerContext extends ICommandBaseContext { explorerContext: azdata.ObjectExplorerContext; } -export type CommandContext = ICommandObjectExplorerContext | ICommandViewContext | ICommandUriContext | ICommandUnknownContext; +type CommandContext = ICommandObjectExplorerContext | ICommandViewContext | ICommandUriContext | ICommandUnknownContext; function isTextEditor(editor: any): editor is vscode.TextEditor { if (editor === undefined) { return false; } @@ -189,4 +189,4 @@ export function registerSearchServerCommand(appContext: AppContext): void { appContext.apiWrapper.registerCommand('mssql.clearSearchServerResult', () => { vscode.commands.executeCommand('registeredServers.clearSearchServerResult'); }); -} \ No newline at end of file +} diff --git a/extensions/mssql/src/objectExplorerNodeProvider/fileSources.ts b/extensions/mssql/src/objectExplorerNodeProvider/fileSources.ts index 82f65f6936..8751fb6878 100644 --- a/extensions/mssql/src/objectExplorerNodeProvider/fileSources.ts +++ b/extensions/mssql/src/objectExplorerNodeProvider/fileSources.ts @@ -106,10 +106,11 @@ export interface IFileSource { exists(path: string): Promise; } -export interface IHttpAuthentication { +interface IHttpAuthentication { user: string; pass: string; } + export interface IHdfsOptions { host?: string; port?: number; @@ -176,7 +177,7 @@ export class FileSourceFactory { } } -export class HdfsFileSource implements IFileSource { +class HdfsFileSource implements IFileSource { private mounts: Map; constructor(private client: WebHDFS) { } @@ -240,7 +241,7 @@ export class HdfsFileSource implements IFileSource { public readFile(path: string, maxBytes?: number): Promise { return new Promise((resolve, reject) => { let error: HdfsError = undefined; - let remoteFileStream = this.client.createReadStream(path); + let remoteFileStream: fs.ReadStream | meter.StreamMeter = this.client.createReadStream(path); remoteFileStream.on('error', (err) => { error = err; reject(error); diff --git a/extensions/mssql/src/objectExplorerNodeProvider/hdfsCommands.ts b/extensions/mssql/src/objectExplorerNodeProvider/hdfsCommands.ts index 5a80567f7f..2a039393de 100644 --- a/extensions/mssql/src/objectExplorerNodeProvider/hdfsCommands.ts +++ b/extensions/mssql/src/objectExplorerNodeProvider/hdfsCommands.ts @@ -71,8 +71,8 @@ export class UploadFilesCommand extends ProgressCommand { try { let folderNode = await getNode(context, this.appContext); const allFilesFilter = localize('allFiles', "All Files"); - let filter = {}; - filter[allFilesFilter] = '*'; + let filter: { [key: string]: string[] } = {}; + filter[allFilesFilter] = ['*']; if (folderNode) { let options: vscode.OpenDialogOptions = { canSelectFiles: true, @@ -175,7 +175,7 @@ export class MkDirCommand extends ProgressCommand { }).then(confirmed => confirmed); } - private async mkDir(fileName, folderNode: FolderNode, cancelToken: vscode.CancellationTokenSource): Promise { + private async mkDir(fileName: string, folderNode: FolderNode, cancelToken: vscode.CancellationTokenSource): Promise { await folderNode.mkdir(fileName); } } diff --git a/extensions/mssql/src/objectExplorerNodeProvider/hdfsProvider.ts b/extensions/mssql/src/objectExplorerNodeProvider/hdfsProvider.ts index 9d53ed330c..162abd40f4 100644 --- a/extensions/mssql/src/objectExplorerNodeProvider/hdfsProvider.ts +++ b/extensions/mssql/src/objectExplorerNodeProvider/hdfsProvider.ts @@ -11,7 +11,7 @@ import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); import * as Constants from '../constants'; -import { IFileSource, IHdfsOptions, IFile, File, FileSourceFactory, FileType } from './fileSources'; +import { IFileSource, IFile, File, FileType } from './fileSources'; import { CancelableStream } from './cancelableStream'; import { TreeNode } from './treeNodes'; import * as utils from '../utils'; @@ -28,53 +28,6 @@ export class TreeDataContext { } } -export class HdfsProvider implements vscode.TreeDataProvider, ITreeChangeHandler { - static readonly NoConnectionsMessage = 'No connections added'; - static readonly ConnectionsLabel = 'Connections'; - - private connections: ConnectionNode[]; - private _onDidChangeTreeData = new vscode.EventEmitter(); - private context: TreeDataContext; - - constructor(extensionContext: vscode.ExtensionContext) { - this.connections = []; - this.context = new TreeDataContext(extensionContext, this); - } - - public get onDidChangeTreeData(): vscode.Event { - return this._onDidChangeTreeData.event; - } - - getTreeItem(element: TreeNode): vscode.TreeItem | Thenable { - return element.getTreeItem(); - } - - getChildren(element?: TreeNode): vscode.ProviderResult { - if (element) { - return element.getChildren(false); - } else { - return this.connections.length > 0 ? this.connections : [ErrorNode.create(HdfsProvider.NoConnectionsMessage, element)]; - } - } - - addConnection(displayName: string, fileSource: IFileSource): void { - if (!this.connections.find(c => c.getDisplayName() === displayName)) { - this.connections.push(new ConnectionNode(this.context, displayName, fileSource)); - this._onDidChangeTreeData.fire(); - } - } - - public async addHdfsConnection(options: IHdfsOptions): Promise { - let displayName = `${options.user}@${options.host}:${options.port}`; - let fileSource = await FileSourceFactory.instance.createHdfsFileSource(options); - this.addConnection(displayName, fileSource); - } - - notifyNodeChanged(node: TreeNode): void { - this._onDidChangeTreeData.fire(node); - } -} - export abstract class HdfsFileSourceNode extends TreeNode { constructor(protected context: TreeDataContext, protected _path: string, public readonly fileSource: IFileSource, protected mountStatus?: MountStatus) { super(); @@ -362,7 +315,7 @@ export class FileNode extends HdfsFileSourceNode implements IFileNode { } } -export class ErrorNode extends TreeNode { +class ErrorNode extends TreeNode { static messageNum: number = 0; private _nodePathValue: string; diff --git a/extensions/mssql/src/objectExplorerNodeProvider/objectExplorerNodeProvider.ts b/extensions/mssql/src/objectExplorerNodeProvider/objectExplorerNodeProvider.ts index ea7e15425e..2637871498 100644 --- a/extensions/mssql/src/objectExplorerNodeProvider/objectExplorerNodeProvider.ts +++ b/extensions/mssql/src/objectExplorerNodeProvider/objectExplorerNodeProvider.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as azdata from 'azdata'; import * as vscode from 'vscode'; import * as nls from 'vscode-nls'; @@ -72,7 +70,7 @@ export class MssqlObjectExplorerNodeProvider extends ProviderBase implements azd private async doExpandNode(nodeInfo: azdata.ExpandNodeInfo, isRefresh: boolean = false): Promise { let session = this.sessionMap.get(nodeInfo.sessionId); - let response = { + let response: azdata.ObjectExplorerExpandInfo = { sessionId: nodeInfo.sessionId, nodePath: nodeInfo.nodePath, errorMessage: undefined, @@ -235,7 +233,7 @@ export class MssqlObjectExplorerNodeProvider extends ProviderBase implements azd } } -export class SqlClusterSession { +class SqlClusterSession { private _rootNode: SqlClusterRootNode; constructor( diff --git a/extensions/mssql/src/prompts/adapter.ts b/extensions/mssql/src/prompts/adapter.ts index ac9475b30a..be6a6d79f3 100644 --- a/extensions/mssql/src/prompts/adapter.ts +++ b/extensions/mssql/src/prompts/adapter.ts @@ -4,13 +4,13 @@ import { window } from 'vscode'; import PromptFactory from './factory'; import EscapeException from '../escapeException'; -import { IQuestion, IPrompter, IPromptCallback } from './question'; +import { IQuestion, IPrompter } from './question'; // Supports simple pattern for prompting for user input and acting on this export default class CodeAdapter implements IPrompter { // TODO define question interface - private fixQuestion(question: any): any { + private fixQuestion(question: IQuestion): any { if (question.type === 'checkbox' && Array.isArray(question.choices)) { // For some reason when there's a choice of checkboxes, they aren't formatted properly // Not sure where the issue is @@ -46,7 +46,7 @@ export default class CodeAdapter implements IPrompter { return PromptFactory.createPrompt(question, ignoreFocusOut); }).then(prompt => { if (!question.shouldPrompt || question.shouldPrompt(answers) === true) { - return prompt.render().then(result => { + return prompt.render().then((result: T) => { answers[question.name] = result; if (question.onAnswered) { @@ -67,14 +67,4 @@ export default class CodeAdapter implements IPrompter { window.showErrorMessage(err.message); }); } - - // Helper to make it possible to prompt using callback pattern. Generally Promise is a preferred flow - public promptCallback(questions: IQuestion[], callback: IPromptCallback): void { - // Collapse multiple questions into a set of prompt steps - this.prompt(questions).then(answers => { - if (callback) { - callback(answers); - } - }); - } } diff --git a/extensions/mssql/src/prompts/checkbox.ts b/extensions/mssql/src/prompts/checkbox.ts deleted file mode 100644 index 806199203e..0000000000 --- a/extensions/mssql/src/prompts/checkbox.ts +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -// This code is originally from https://github.com/DonJayamanne/bowerVSCode -// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE - -import { window } from 'vscode'; -import Prompt from './prompt'; -import EscapeException from '../escapeException'; - -const figures = require('figures'); - -export default class CheckboxPrompt extends Prompt { - - constructor(question: any, ignoreFocusOut?: boolean) { - super(question, ignoreFocusOut); - } - - public render(): any { - let choices = this._question.choices.reduce((result, choice) => { - let choiceName = choice.name || choice; - result[`${choice.checked === true ? figures.radioOn : figures.radioOff} ${choiceName}`] = choice; - return result; - }, {}); - - let options = this.defaultQuickPickOptions; - options.placeHolder = this._question.message; - - let quickPickOptions = Object.keys(choices); - quickPickOptions.push(figures.tick); - - return window.showQuickPick(quickPickOptions, options) - .then(result => { - if (result === undefined) { - throw new EscapeException(); - } - - if (result !== figures.tick) { - choices[result].checked = !choices[result].checked; - - return this.render(); - } - - return this._question.choices.reduce((result2, choice) => { - if (choice.checked === true) { - result2.push(choice.value); - } - - return result2; - }, []); - }); - } -} diff --git a/extensions/mssql/src/prompts/confirm.ts b/extensions/mssql/src/prompts/confirm.ts index 974b2b754c..a8b00aeb66 100644 --- a/extensions/mssql/src/prompts/confirm.ts +++ b/extensions/mssql/src/prompts/confirm.ts @@ -1,5 +1,3 @@ -'use strict'; - // This code is originally from https://github.com/DonJayamanne/bowerVSCode // License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE diff --git a/extensions/mssql/src/prompts/expand.ts b/extensions/mssql/src/prompts/expand.ts deleted file mode 100644 index df98b4dbed..0000000000 --- a/extensions/mssql/src/prompts/expand.ts +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -// This code is originally from https://github.com/DonJayamanne/bowerVSCode -// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE - -import vscode = require('vscode'); -import Prompt from './prompt'; -import EscapeException from '../escapeException'; -import { INameValueChoice } from './question'; - -const figures = require('figures'); - -export default class ExpandPrompt extends Prompt { - - constructor(question: any, ignoreFocusOut?: boolean) { - super(question, ignoreFocusOut); - } - - public render(): any { - // label indicates this is a quickpick item. Otherwise it's a name-value pair - if (this._question.choices[0].label) { - return this.renderQuickPick(this._question.choices); - } else { - return this.renderNameValueChoice(this._question.choices); - } - } - - private renderQuickPick(choices: vscode.QuickPickItem[]): any { - let options = this.defaultQuickPickOptions; - options.placeHolder = this._question.message; - - return vscode.window.showQuickPick(choices, options) - .then(result => { - if (result === undefined) { - throw new EscapeException(); - } - - return this.validateAndReturn(result || false); - }); - } - private renderNameValueChoice(choices: INameValueChoice[]): any { - const choiceMap = this._question.choices.reduce((result, choice) => { - result[choice.name] = choice.value; - return result; - }, {}); - - let options = this.defaultQuickPickOptions; - options.placeHolder = this._question.message; - - return vscode.window.showQuickPick(Object.keys(choiceMap), options) - .then(result => { - if (result === undefined) { - throw new EscapeException(); - } - - // Note: cannot be used with 0 or false responses - let returnVal = choiceMap[result] || false; - return this.validateAndReturn(returnVal); - }); - } - - private validateAndReturn(value: any): any { - if (!this.validate(value)) { - return this.render(); - } - return value; - } - - private validate(value: any): boolean { - const validationError = this._question.validate ? this._question.validate(value || '') : undefined; - - if (validationError) { - this._question.message = `${figures.warning} ${validationError}`; - return false; - } - return true; - } -} diff --git a/extensions/mssql/src/prompts/factory.ts b/extensions/mssql/src/prompts/factory.ts index 1b9db3dda5..d527a5e54d 100644 --- a/extensions/mssql/src/prompts/factory.ts +++ b/extensions/mssql/src/prompts/factory.ts @@ -1,33 +1,22 @@ -'use strict'; - // This code is originally from https://github.com/DonJayamanne/bowerVSCode // License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE import Prompt from './prompt'; import InputPrompt from './input'; import PasswordPrompt from './password'; -import ListPrompt from './list'; import ConfirmPrompt from './confirm'; -import CheckboxPrompt from './checkbox'; -import ExpandPrompt from './expand'; +import { IQuestion } from './question'; export default class PromptFactory { - public static createPrompt(question: any, ignoreFocusOut?: boolean): Prompt { - switch (question.type || 'input') { - case 'string': + public static createPrompt(question: IQuestion, ignoreFocusOut?: boolean): Prompt { + switch (question.type) { case 'input': return new InputPrompt(question, ignoreFocusOut); case 'password': return new PasswordPrompt(question, ignoreFocusOut); - case 'list': - return new ListPrompt(question, ignoreFocusOut); case 'confirm': return new ConfirmPrompt(question, ignoreFocusOut); - case 'checkbox': - return new CheckboxPrompt(question, ignoreFocusOut); - case 'expand': - return new ExpandPrompt(question, ignoreFocusOut); default: throw new Error(`Could not find a prompt for question type ${question.type}`); } diff --git a/extensions/mssql/src/prompts/input.ts b/extensions/mssql/src/prompts/input.ts index 41bedc2eb2..409d1ea55d 100644 --- a/extensions/mssql/src/prompts/input.ts +++ b/extensions/mssql/src/prompts/input.ts @@ -1,5 +1,3 @@ -'use strict'; - // This code is originally from https://github.com/DonJayamanne/bowerVSCode // License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE diff --git a/extensions/mssql/src/prompts/list.ts b/extensions/mssql/src/prompts/list.ts deleted file mode 100644 index 536f35be55..0000000000 --- a/extensions/mssql/src/prompts/list.ts +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; - -// This code is originally from https://github.com/DonJayamanne/bowerVSCode -// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE - -import { window } from 'vscode'; -import Prompt from './prompt'; -import EscapeException from '../escapeException'; - -export default class ListPrompt extends Prompt { - constructor(question: any, ignoreFocusOut?: boolean) { - super(question, ignoreFocusOut); - } - - public render(): any { - const choices = this._question.choices.reduce((result, choice) => { - result[choice.name] = choice.value; - return result; - }, {}); - - let options = this.defaultQuickPickOptions; - options.placeHolder = this._question.message; - - return window.showQuickPick(Object.keys(choices), options) - .then(result => { - if (result === undefined) { - throw new EscapeException(); - } - - return choices[result]; - }); - } -} diff --git a/extensions/mssql/src/prompts/password.ts b/extensions/mssql/src/prompts/password.ts index ef6de55886..cd084c2542 100644 --- a/extensions/mssql/src/prompts/password.ts +++ b/extensions/mssql/src/prompts/password.ts @@ -1,5 +1,3 @@ -'use strict'; - // This code is originally from https://github.com/DonJayamanne/bowerVSCode // License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE diff --git a/extensions/mssql/src/prompts/progressIndicator.ts b/extensions/mssql/src/prompts/progressIndicator.ts deleted file mode 100644 index 94fa5c7b15..0000000000 --- a/extensions/mssql/src/prompts/progressIndicator.ts +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -// This code is originally from https://github.com/DonJayamanne/bowerVSCode -// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE - -import {window, StatusBarItem, StatusBarAlignment} from 'vscode'; - -export default class ProgressIndicator { - - private _statusBarItem: StatusBarItem; - - constructor() { - this._statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left); - } - - private _tasks: string[] = []; - public beginTask(task: string): void { - this._tasks.push(task); - this.displayProgressIndicator(); - } - - public endTask(task: string): void { - if (this._tasks.length > 0) { - this._tasks.pop(); - } - - this.setMessage(); - } - - private setMessage(): void { - if (this._tasks.length === 0) { - this._statusBarItem.text = ''; - this.hideProgressIndicator(); - return; - } - - this._statusBarItem.text = this._tasks[this._tasks.length - 1]; - this._statusBarItem.show(); - } - - private _interval: any; - private displayProgressIndicator(): void { - this.setMessage(); - this.hideProgressIndicator(); - this._interval = setInterval(() => this.onDisplayProgressIndicator(), 100); - } - private hideProgressIndicator(): void { - if (this._interval) { - clearInterval(this._interval); - this._interval = undefined; - } - this.ProgressCounter = 0; - } - - private ProgressText = ['|', '/', '-', '\\', '|', '/', '-', '\\']; - private ProgressCounter = 0; - private onDisplayProgressIndicator(): void { - if (this._tasks.length === 0) { - return; - } - - let txt = this.ProgressText[this.ProgressCounter]; - this._statusBarItem.text = this._tasks[this._tasks.length - 1] + ' ' + txt; - this.ProgressCounter++; - - if (this.ProgressCounter >= this.ProgressText.length - 1) { - this.ProgressCounter = 0; - } - } -} diff --git a/extensions/mssql/src/prompts/prompt.ts b/extensions/mssql/src/prompts/prompt.ts index 700f577d66..ceb7adb467 100644 --- a/extensions/mssql/src/prompts/prompt.ts +++ b/extensions/mssql/src/prompts/prompt.ts @@ -1,16 +1,15 @@ -'use strict'; - // This code is originally from https://github.com/DonJayamanne/bowerVSCode // License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE import { InputBoxOptions, QuickPickOptions } from 'vscode'; +import { IQuestion } from './question'; abstract class Prompt { - protected _question: any; + protected _question: IQuestion; protected _ignoreFocusOut?: boolean; - constructor(question: any, ignoreFocusOut?: boolean) { + constructor(question: IQuestion, ignoreFocusOut?: boolean) { this._question = question; this._ignoreFocusOut = ignoreFocusOut ? ignoreFocusOut : false; } diff --git a/extensions/mssql/src/prompts/question.ts b/extensions/mssql/src/prompts/question.ts index af187c066b..aa1082368e 100644 --- a/extensions/mssql/src/prompts/question.ts +++ b/extensions/mssql/src/prompts/question.ts @@ -3,15 +3,12 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import vscode = require('vscode'); +import * as vscode from 'vscode'; export class QuestionTypes { public static get input(): string { return 'input'; } public static get password(): string { return 'password'; } - public static get list(): string { return 'list'; } public static get confirm(): string { return 'confirm'; } - public static get checkbox(): string { return 'checkbox'; } - public static get expand(): string { return 'expand'; } } // Question interface to clarify how to use the prompt feature @@ -40,19 +37,11 @@ export interface IQuestion { } // Pair used to display simple choices to the user -export interface INameValueChoice { +interface INameValueChoice { name: string; value: any; } -// Generic object that can be used to define a set of questions and handle the result -export interface IQuestionHandler { - // Set of questions to be answered - questions: IQuestion[]; - // Optional callback, since questions may handle themselves - callback?: IPromptCallback; -} - export interface IPrompter { promptSingle(question: IQuestion, ignoreFocusOut?: boolean): Promise; /** @@ -61,10 +50,5 @@ export interface IPrompter { * @returns Map of question IDs to results, or undefined if * the user canceled the question session */ - prompt(questions: IQuestion[], ignoreFocusOut?: boolean): Promise<{ [questionId: string]: any }>; - promptCallback(questions: IQuestion[], callback: IPromptCallback): void; -} - -export interface IPromptCallback { - (answers: { [id: string]: any }): void; + prompt(questions: IQuestion[], ignoreFocusOut?: boolean): Promise<{ [questionId: string]: any }>; } diff --git a/extensions/mssql/src/resourceProvider/constants.ts b/extensions/mssql/src/resourceProvider/constants.ts index f403cef451..11a7c30369 100644 --- a/extensions/mssql/src/resourceProvider/constants.ts +++ b/extensions/mssql/src/resourceProvider/constants.ts @@ -2,7 +2,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; export const serviceName = 'AzureResourceProvider'; export const providerId = 'azureresourceProvider'; diff --git a/extensions/mssql/src/resourceProvider/contracts.ts b/extensions/mssql/src/resourceProvider/contracts.ts index b48c1420c4..5bae70aab6 100644 --- a/extensions/mssql/src/resourceProvider/contracts.ts +++ b/extensions/mssql/src/resourceProvider/contracts.ts @@ -2,7 +2,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; import { RequestType } from 'vscode-languageclient'; import * as azdata from 'azdata'; @@ -25,7 +24,7 @@ export interface CreateFirewallRuleParams { securityTokenMappings: {}; } -export interface CreateFirewallRuleResponse { +interface CreateFirewallRuleResponse { result: boolean; errorMessage: string; } @@ -36,7 +35,7 @@ export interface HandleFirewallRuleParams { connectionTypeId: string; } -export interface HandleFirewallRuleResponse { +interface HandleFirewallRuleResponse { result: boolean; ipAddress: string; } diff --git a/extensions/mssql/src/resourceProvider/resourceProvider.ts b/extensions/mssql/src/resourceProvider/resourceProvider.ts index d7bb2d5396..2e64192eb5 100644 --- a/extensions/mssql/src/resourceProvider/resourceProvider.ts +++ b/extensions/mssql/src/resourceProvider/resourceProvider.ts @@ -2,7 +2,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; import * as azdata from 'azdata'; import { IConfig, ServerProvider } from 'service-downloader'; diff --git a/extensions/mssql/src/sparkFeature/dialog/dialogCommands.ts b/extensions/mssql/src/sparkFeature/dialog/dialogCommands.ts index 6f37b25177..9f0f44ba64 100644 --- a/extensions/mssql/src/sparkFeature/dialog/dialogCommands.ts +++ b/extensions/mssql/src/sparkFeature/dialog/dialogCommands.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as azdata from 'azdata'; import * as nls from 'vscode-nls'; import * as vscode from 'vscode'; diff --git a/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionDialog.ts b/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionDialog.ts index 37c17fbdb9..329450477c 100644 --- a/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionDialog.ts +++ b/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionDialog.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as azdata from 'azdata'; import * as vscode from 'vscode'; import * as nls from 'vscode-nls'; diff --git a/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionModel.ts b/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionModel.ts index 4af7db3a14..fbaa68a410 100644 --- a/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionModel.ts +++ b/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionModel.ts @@ -38,7 +38,7 @@ export class SparkJobSubmissionModel { private readonly _sqlClusterConnection: SqlClusterConnection, private readonly _dialog: azdata.window.Dialog, private readonly _appContext: AppContext, - requestService?: (args: any) => any) { + requestService?: typeof import('request-promise')) { if (!this._sqlClusterConnection || !this._dialog || !this._appContext) { throw new Error(localize('sparkJobSubmission.SparkJobSubmissionModelInitializeError', diff --git a/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionService.ts b/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionService.ts index cce9cafa6e..aafea5d0de 100644 --- a/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionService.ts +++ b/extensions/mssql/src/sparkFeature/dialog/sparkJobSubmission/sparkJobSubmissionService.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as os from 'os'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); @@ -12,12 +10,13 @@ import * as constants from '../../../constants'; import { SqlClusterConnection } from '../../../objectExplorerNodeProvider/connection'; import * as utils from '../../../utils'; import * as auth from '../../../util/auth'; +import { Options } from 'request-promise'; export class SparkJobSubmissionService { - private _requestPromise: (args: any) => any; + private _requestPromise: typeof import('request-promise'); constructor( - requestService?: (args: any) => any) { + requestService?: typeof import('request-promise')) { if (requestService) { // this is to fake the request service for test. this._requestPromise = requestService; @@ -33,7 +32,7 @@ export class SparkJobSubmissionService { // Get correct authentication headers let headers = await this.getAuthenticationHeaders(submissionArgs); - let options = { + let options: Options = { uri: livyUrl, method: 'POST', json: true, diff --git a/extensions/mssql/src/sparkFeature/historyTask.ts b/extensions/mssql/src/sparkFeature/historyTask.ts index 9ff6382d65..3c6b7a86bf 100644 --- a/extensions/mssql/src/sparkFeature/historyTask.ts +++ b/extensions/mssql/src/sparkFeature/historyTask.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import * as azdata from 'azdata'; import * as vscode from 'vscode'; import { AppContext } from '../appContext'; diff --git a/extensions/mssql/src/sparkFeature/sparkUtils.ts b/extensions/mssql/src/sparkFeature/sparkUtils.ts deleted file mode 100644 index 3d9623a62c..0000000000 --- a/extensions/mssql/src/sparkFeature/sparkUtils.ts +++ /dev/null @@ -1,217 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as childProcess from 'child_process'; -import * as fs from 'fs-extra'; -import * as path from 'path'; -import * as azdata from 'azdata'; -import * as vscode from 'vscode'; -import * as which from 'which'; -import * as constants from '../constants'; -import * as nls from 'vscode-nls'; -const localize = nls.loadMessageBundle(); - -export function getDropdownValue(dropdownValue: string | azdata.CategoryValue): string { - if (typeof (dropdownValue) === 'string') { - return dropdownValue; - } else { - return dropdownValue ? (dropdownValue).name : undefined; - } -} - -export function getServerAddressFromName(connection: azdata.ConnectionInfo | string): string { - // Strip TDS port number from the server URI - if ((connection).options && (connection).options[constants.hostPropName]) { - return (connection).options[constants.hostPropName].split(',')[0].split(':')[0]; - } else if ((connection).options && (connection).options['server']) { - return (connection).options['server'].split(',')[0].split(':')[0]; - } else { - return (connection).split(',')[0].split(':')[0]; - } -} - -export function getKnoxUrl(host: string, port: string): string { - return `https://${host}:${port}/gateway`; -} - -export function getLivyUrl(serverName: string, port: string): string { - return this.getKnoxUrl(serverName, port) + '/default/livy/v1/'; -} - -export function getTemplatePath(extensionPath: string, templateName: string): string { - return path.join(extensionPath, 'resources', templateName); -} -export function shellWhichResolving(cmd: string): Promise { - return new Promise(resolve => { - which(cmd, async (err, foundPath) => { - if (err) { - resolve(undefined); - } else { - // NOTE: Using realpath b/c some system installs are symlinked from */bin - resolve(await fs.promises.realpath(foundPath)); - } - }); - }); -} - -export async function mkDir(dirPath: string, outputChannel?: vscode.OutputChannel): Promise { - if (!await fs.exists(dirPath)) { - if (outputChannel) { - outputChannel.appendLine(localize('mkdirOutputMsg', "... Creating {0}", dirPath)); - } - await fs.ensureDir(dirPath); - } -} - -export function getErrorMessage(error: Error | string): string { - return (error instanceof Error) ? error.message : error; -} - -// COMMAND EXECUTION HELPERS /////////////////////////////////////////////// -export function executeBufferedCommand(cmd: string, options: childProcess.ExecOptions, outputChannel?: vscode.OutputChannel): Thenable { - return new Promise((resolve, reject) => { - if (outputChannel) { - outputChannel.appendLine(` > ${cmd}`); - } - - let child = childProcess.exec(cmd, options, (err, stdout) => { - if (err) { - reject(err); - } else { - resolve(stdout); - } - }); - - // Add listeners to print stdout and stderr if an output channel was provided - if (outputChannel) { - child.stdout.on('data', data => { outputDataChunk(data, outputChannel, ' stdout: '); }); - child.stderr.on('data', data => { outputDataChunk(data, outputChannel, ' stderr: '); }); - } - }); -} - -export function executeExitCodeCommand(cmd: string, outputChannel?: vscode.OutputChannel): Thenable { - return new Promise((resolve, reject) => { - if (outputChannel) { - outputChannel.appendLine(` > ${cmd}`); - } - - let child = childProcess.spawn(cmd, [], { shell: true, detached: false }); - - // Add listeners for the process to exit - child.on('error', reject); - child.on('exit', (code: number) => { resolve(code); }); - - // Add listeners to print stdout and stderr if an output channel was provided - if (outputChannel) { - child.stdout.on('data', data => { outputDataChunk(data, outputChannel, ' stdout: '); }); - child.stderr.on('data', data => { outputDataChunk(data, outputChannel, ' stderr: '); }); - } - }); -} - -export function executeStreamedCommand(cmd: string, outputChannel?: vscode.OutputChannel): Thenable { - return new Promise((resolve, reject) => { - // Start the command - if (outputChannel) { - outputChannel.appendLine(` > ${cmd}`); - } - let child = childProcess.spawn(cmd, [], { shell: true, detached: false }); - - // Add listeners to resolve/reject the promise on exit - child.on('error', reject); - child.on('exit', (code: number) => { - if (code === 0) { - resolve(); - } else { - reject(localize('executeCommandProcessExited', "Process exited with code {0}", code)); - } - }); - - // Add listeners to print stdout and stderr if an output channel was provided - if (outputChannel) { - child.stdout.on('data', data => { outputDataChunk(data, outputChannel, ' stdout: '); }); - child.stderr.on('data', data => { outputDataChunk(data, outputChannel, ' stderr: '); }); - } - }); -} - -export function isObjectExplorerContext(object: any): object is azdata.ObjectExplorerContext { - return 'connectionProfile' in object && 'isConnectionNode' in object; -} - -export function getUserHome(): string { - return process.env.HOME || process.env.USERPROFILE; -} - -export enum Platform { - Mac, - Linux, - Windows, - Others -} - -export function getOSPlatform(): Platform { - switch (process.platform) { - case 'win32': - return Platform.Windows; - case 'darwin': - return Platform.Mac; - case 'linux': - return Platform.Linux; - default: - return Platform.Others; - } -} - -export function getOSPlatformId(): string { - let platformId = undefined; - switch (process.platform) { - case 'win32': - platformId = 'win-x64'; - break; - case 'darwin': - platformId = 'osx'; - break; - default: - platformId = 'linux-x64'; - break; - } - return platformId; -} - -// PRIVATE HELPERS ///////////////////////////////////////////////////////// -function outputDataChunk(data: string | Buffer, outputChannel: vscode.OutputChannel, header: string): void { - data.toString().split(/\r?\n/) - .forEach(line => { - outputChannel.appendLine(header + line); - }); -} - -export function clone(obj: T): T { - if (!obj || typeof obj !== 'object') { - return obj; - } - if (obj instanceof RegExp) { - // See https://github.com/Microsoft/TypeScript/issues/10990 - return obj as any; - } - const result = (Array.isArray(obj)) ? [] : {}; - Object.keys(obj).forEach(key => { - if (obj[key] && typeof obj[key] === 'object') { - result[key] = clone(obj[key]); - } else { - result[key] = obj[key]; - } - }); - return result; -} - -export function isValidNumber(maybeNumber: any) { - return maybeNumber !== undefined - && maybeNumber !== null - && maybeNumber !== '' - && !isNaN(Number(maybeNumber.toString())); -} diff --git a/extensions/mssql/src/telemetry.ts b/extensions/mssql/src/telemetry.ts index dd24691853..e3b7265eb4 100644 --- a/extensions/mssql/src/telemetry.ts +++ b/extensions/mssql/src/telemetry.ts @@ -26,7 +26,7 @@ export interface ITelemetryEventMeasures { /** * Filters error paths to only include source files. Exported to support testing */ -export function FilterErrorPath(line: string): string { +function FilterErrorPath(line: string): string { if (line) { let values: string[] = line.split('/out/'); if (values.length <= 1) { diff --git a/extensions/mssql/src/typings/bufferStreamReader.d.ts b/extensions/mssql/src/typings/bufferStreamReader.d.ts new file mode 100644 index 0000000000..8f479ebcf9 --- /dev/null +++ b/extensions/mssql/src/typings/bufferStreamReader.d.ts @@ -0,0 +1,19 @@ +declare module 'buffer-stream-reader' { + import * as fs from 'fs'; + + class BufferStreamReader { + constructor(stream: string | Buffer); + pipe(pipe: fs.WriteStream): void + } + + namespace BufferStreamReader { + interface FindRemoveOptions { + age?: { + seconds?: number; + }; + limit?: number; + } + } + + export = BufferStreamReader; +} diff --git a/extensions/mssql/src/typings/findRemove.d.ts b/extensions/mssql/src/typings/findRemove.d.ts new file mode 100644 index 0000000000..c49686d1b3 --- /dev/null +++ b/extensions/mssql/src/typings/findRemove.d.ts @@ -0,0 +1,17 @@ +declare module 'find-remove' { + namespace findRemove { + interface FindRemoveApi { + (path: string, options: FindRemoveOptions): JSON; + } + + interface FindRemoveOptions { + age?: { + seconds?: number; + }; + limit?: number; + } + } + + const findRemove: findRemove.FindRemoveApi; + export = findRemove; +} diff --git a/extensions/mssql/src/util/dispose.ts b/extensions/mssql/src/util/dispose.ts index 83ac3bf543..22454093e1 100644 --- a/extensions/mssql/src/util/dispose.ts +++ b/extensions/mssql/src/util/dispose.ts @@ -5,7 +5,7 @@ import * as vscode from 'vscode'; -export function disposeAll(disposables: vscode.Disposable[]) { +function disposeAll(disposables: vscode.Disposable[]) { while (disposables.length) { const item = disposables.pop(); if (item) { @@ -39,4 +39,4 @@ export abstract class Disposable { protected get isDisposed() { return this._isDisposed; } -} \ No newline at end of file +} diff --git a/extensions/mssql/src/utils.ts b/extensions/mssql/src/utils.ts index 27b4b51ba1..95d206ae50 100644 --- a/extensions/mssql/src/utils.ts +++ b/extensions/mssql/src/utils.ts @@ -107,7 +107,7 @@ export function getCommonLaunchArgsAndCleanupOldLogFiles(logPath: string, fileNa return launchArgs; } -export function ensure(target: object, key: string): any { +export function ensure(target: { [key: string]: any }, key: string): any { if (target[key] === void 0) { target[key] = {} as any; } diff --git a/extensions/mssql/tsconfig.json b/extensions/mssql/tsconfig.json index a80576b9e2..971db11d01 100644 --- a/extensions/mssql/tsconfig.json +++ b/extensions/mssql/tsconfig.json @@ -3,8 +3,7 @@ "compilerOptions": { "outDir": "./out", "strict": false, - "noUnusedParameters": false, - "noImplicitAny": false + "noUnusedParameters": false }, "include": [ "src/**/*" diff --git a/extensions/mssql/yarn.lock b/extensions/mssql/yarn.lock index 7629678a02..1eae376916 100644 --- a/extensions/mssql/yarn.lock +++ b/extensions/mssql/yarn.lock @@ -2,6 +2,16 @@ # yarn lockfile v1 +"@types/bluebird@*": + version "3.5.28" + resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.28.tgz#04c1a520ff076649236bc8ca21198542ce2bdb09" + integrity sha512-0Vk/kqkukxPKSzP9c8WJgisgGDx5oZDbsLLWIP5t70yThO/YleE+GEm2S1GlRALTaack3O7U5OS5qEm7q2kciA== + +"@types/bytes@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/bytes/-/bytes-3.0.0.tgz#549eeacd0a8fecfaa459334583a4edcee738e6db" + integrity sha512-ZF43+CIIlzngQe8/Zo7L1kpY9W8O6rO006VDz3c5iM21ddtXWxCEyOXyft+q4pVF2tGqvrVuVrEDH1+gJEi1fQ== + "@types/caseless@*": version "0.12.2" resolved "https://registry.yarnpkg.com/@types/caseless/-/caseless-0.12.2.tgz#f65d3d6389e01eeb458bd54dc8f52b95a9463bc8" @@ -17,6 +27,24 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.2.tgz#c4e63af5e8823ce9cc3f0b34f7b998c2171f0c44" integrity sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg== +"@types/request-promise@^4.1.44": + version "4.1.44" + resolved "https://registry.yarnpkg.com/@types/request-promise/-/request-promise-4.1.44.tgz#05b59cd18445832fae16b68d5bb3d4621b549485" + integrity sha512-RId7eFsUKxfal1LirDDIcOp9u3MM3NXFDBcC3sqIMcmu7f4U6DsCEMD8RbLZtnPrQlN5Jc79di/WPsIEDO4keg== + dependencies: + "@types/bluebird" "*" + "@types/request" "*" + +"@types/request@*": + version "2.48.3" + resolved "https://registry.yarnpkg.com/@types/request/-/request-2.48.3.tgz#970b8ed2317568c390361d29c555a95e74bd6135" + integrity sha512-3Wo2jNYwqgXcIz/rrq18AdOZUQB8cQ34CXZo+LUwPJNpvRAL86+Kc2wwI8mqpz9Cr1V+enIox5v+WZhy/p3h8w== + dependencies: + "@types/caseless" "*" + "@types/node" "*" + "@types/tough-cookie" "*" + form-data "^2.5.0" + "@types/request@^2.48.2": version "2.48.2" resolved "https://registry.yarnpkg.com/@types/request/-/request-2.48.2.tgz#936374cbe1179d7ed529fc02543deb4597450fed" @@ -27,6 +55,13 @@ "@types/tough-cookie" "*" form-data "^2.5.0" +"@types/stream-meter@^0.0.22": + version "0.0.22" + resolved "https://registry.yarnpkg.com/@types/stream-meter/-/stream-meter-0.0.22.tgz#6602f644ea0f5468cae13931ee6611a3a03fbab1" + integrity sha512-gqqudd3q69aEmixGIL1p2qN1AySZ+UJ2j6y70ZXZBg8/SmzTM1MvkOKvmuelKNIpPS8bKml6Gw03pfbnI8YpwQ== + dependencies: + "@types/node" "*" + "@types/through2@^2.0.34": version "2.0.34" resolved "https://registry.yarnpkg.com/@types/through2/-/through2-2.0.34.tgz#9c2a259a238dace2a05a2f8e94b786961bc27ac4" @@ -534,15 +569,6 @@ fs-constants@^1.0.0: resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== -fs-extra@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291" - integrity sha1-N5TzeMWLNC6n27sjCVEJxLO2IpE= - dependencies: - graceful-fs "^4.1.2" - jsonfile "^3.0.0" - universalify "^0.1.0" - fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -594,7 +620,7 @@ glob@^7.0.5: once "^1.3.0" path-is-absolute "^1.0.0" -graceful-fs@^4.1.10, graceful-fs@^4.1.2, graceful-fs@^4.1.6: +graceful-fs@^4.1.10: version "4.1.15" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== @@ -742,13 +768,6 @@ json-stringify-safe@~5.0.1: resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= -jsonfile@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-3.0.1.tgz#a5ecc6f65f53f662c4415c7675a0331d0992ec66" - integrity sha1-pezG9l9T9mLEQVx2daAzHQmS7GY= - optionalDependencies: - graceful-fs "^4.1.6" - jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -1320,11 +1339,6 @@ unbzip2-stream@^1.0.9: buffer "^5.2.1" through "^2.3.8" -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - uri-js@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" diff --git a/src/sql/azdata.d.ts b/src/sql/azdata.d.ts index a23ca9ef51..25cb9df521 100644 --- a/src/sql/azdata.d.ts +++ b/src/sql/azdata.d.ts @@ -93,7 +93,7 @@ declare module 'azdata' { azureTenantId?: string; options: { [name: string]: any }; - static createFrom(options: Map): ConnectionProfile; + static createFrom(options: { [key: string]: any }): ConnectionProfile; } /** diff --git a/src/sql/workbench/api/common/sqlExtHostTypes.ts b/src/sql/workbench/api/common/sqlExtHostTypes.ts index 01d3f2559e..ade52e6de0 100644 --- a/src/sql/workbench/api/common/sqlExtHostTypes.ts +++ b/src/sql/workbench/api/common/sqlExtHostTypes.ts @@ -697,9 +697,9 @@ export class ConnectionProfile { this.options['azureTenantId'] = value; } - options: Map = new Map(); + options: { [key: string]: any } = {}; - static createFrom(options: Map): ConnectionProfile { + static createFrom(options: { [key: string]: any }): ConnectionProfile { let profile = new ConnectionProfile(); profile.options = options; return profile;