Clean up some of the extensions (#8267)

* 💄

* prune unused code

* more cleanup

* remove abunch of used code
This commit is contained in:
Anthony Dresser
2019-11-08 11:44:43 -08:00
committed by GitHub
parent 738ca479e4
commit 7f7052ad42
94 changed files with 366 additions and 1158 deletions

View File

@@ -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",

View File

@@ -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"

View File

@@ -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<vscode.Uri[] | undefined> {
return vscode.window.showOpenDialog(options);
}
public showErrorMessage(message: string, ...items: string[]): Thenable<string | undefined> {
return vscode.window.showErrorMessage(message, ...items);
}
public get workspaceRootPath(): string {
return vscode.workspace.rootPath;
}
}

View File

@@ -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() {
}
}

View File

@@ -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<ScheduleData> = new vscode.EventEmitter<ScheduleData>();
public readonly onSuccess: vscode.Event<ScheduleData> = 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];
}
}
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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
*/

View File

@@ -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<DbServerGraphData, AzureResourceDatabaseServer> {

View File

@@ -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;

View File

@@ -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,

View File

@@ -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;
}
}

View File

@@ -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<IAzureResourceSubscriptionFilterService>(AzureResourceServiceNames.subscriptionFilterService, new AzureResourceSubscriptionFilterService(new AzureResourceCacheService(extensionContext)));
appContext.registerService<IAzureResourceTenantService>(AzureResourceServiceNames.tenantService, new AzureResourceTenantService());
}

View File

@@ -15,7 +15,7 @@ export async function authenticateKerberos(hostname: string): Promise<string> {
}
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
};
}

View File

@@ -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();

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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

View File

@@ -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';

View File

@@ -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);
}));
}

View File

@@ -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;

View File

@@ -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",

View File

@@ -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<Array<string>>;
dataLossAlerts: Set<string>;
}

View File

@@ -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"

View File

@@ -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",

View File

@@ -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<undefined> {
protected registerProvider(options: undefined): Disposable {
const client = this._client;
let requestSender = (requestType, params) => {
let requestSender = (requestType: RequestType<any, any, void, void>, params: any) => {
return client.sendRequest(requestType, params).then(
r => {
return r as any;

View File

@@ -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<T>(type: ApiType): vscode.Event<T>;
registerApi<T>(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<any> } = {};
private _onRegisteredModelView = new vscode.EventEmitter<IModelViewDefinition>();

View File

@@ -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 {

View File

@@ -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<boolean> {
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 = <any>'Unknown',
Windows_86 = <any>'Windows_86',
Windows_64 = <any>'Windows_64',
OSX = <any>'OSX',
CentOS_7 = <any>'CentOS_7',
Debian_8 = <any>'Debian_8',
Fedora_23 = <any>'Fedora_23',
OpenSUSE_13_2 = <any>'OpenSUSE_13_2',
SLES_12_2 = <any>'SLES_12_2',
RHEL_7 = <any>'RHEL_7',
Ubuntu_14 = <any>'Ubuntu_14',
Ubuntu_16 = <any>'Ubuntu_16',
Linux_64 = <any>'Linux_64',
Linux_86 = <any>'Linux-86'
}

View File

@@ -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 {

View File

@@ -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 => {

View File

@@ -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();

View File

@@ -12,10 +12,7 @@
"moduleResolution": "node",
"declaration": false,
"strict": false,
"noImplicitAny": false,
"noUnusedParameters": false,
"noImplicitReturns": false,
"noUnusedLocals": false,
},
"exclude": [
"node_modules"

View File

@@ -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"

View File

@@ -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": {

View File

@@ -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';

View File

@@ -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');

View File

@@ -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();

View File

@@ -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}`);
}
}

View File

@@ -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';

View File

@@ -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) {

View File

@@ -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';

View File

@@ -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');
});
});
}
}

View File

@@ -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' };

View File

@@ -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';

View File

@@ -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();
}

View File

@@ -55,7 +55,7 @@ export class GuestSessionManager {
if (documentState) {
let queryDocument = await azdata.queryeditor.getQueryDocument(doc.uri.toString());
if (queryDocument) {
let connectionOptions: Map<string, any> = new Map<string, any>();
let connectionOptions: { [key: string]: any } = {};
connectionOptions['providerName'] = LiveShareProviderId;
connectionOptions['serverName'] = documentState.serverName;
connectionOptions['databaseName'] = documentState.databaseName;

View File

@@ -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<LiveShare | null>;
}
/**
* Forward definition of the ContactServiceProvider interface
*/
export interface ContactServiceProvider {
interface ContactServiceProvider {
}
@@ -216,7 +199,7 @@ export interface LiveShare {
getContacts(emails: string[]): Promise<ContactsCollection>;
}
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<any>;
}
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<string[]>;
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<void>;
}

View File

@@ -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<string, any> = new Map<string, any>();
let connectionOptions: { [key: string]: any } = {};
connectionOptions['providerName'] = LiveShareProviderId;
connectionOptions['serverName'] = args.profile.options['server'];
connectionOptions['databaseName'] = args.profile.options['database'];

View File

@@ -3,8 +3,7 @@
"compilerOptions": {
"outDir": "./out",
"strict": false,
"noUnusedParameters": false,
"noImplicitAny": false
"noUnusedParameters": false
},
"include": [
"src/**/*"

View File

@@ -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"
}
}

View File

@@ -85,7 +85,7 @@ export class ApiWrapper {
public openTextDocument(uri: vscode.Uri): Thenable<vscode.TextDocument>;
public openTextDocument(options: { language?: string; content?: string; }): Thenable<vscode.TextDocument>;
public openTextDocument(uriOrOptions): Thenable<vscode.TextDocument> {
public openTextDocument(uriOrOptions: any): Thenable<vscode.TextDocument> {
return vscode.workspace.openTextDocument(uriOrOptions);
}

View File

@@ -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';

View File

@@ -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);
}

View File

@@ -30,13 +30,13 @@ const resolveBookResources = (extension: vscode.Extension<any>, 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) {

View File

@@ -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');

View File

@@ -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;

View File

@@ -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(
{

View File

@@ -181,8 +181,8 @@ async function handleNewNotebookTask(oeContext?: azdata.ObjectExplorerContext, p
async function handleOpenNotebookTask(profile: azdata.IConnectionProfile): Promise<void> {
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,

View File

@@ -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');
});
}
}

View File

@@ -106,10 +106,11 @@ export interface IFileSource {
exists(path: string): Promise<boolean>;
}
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<string, Mount>;
constructor(private client: WebHDFS) {
}
@@ -240,7 +241,7 @@ export class HdfsFileSource implements IFileSource {
public readFile(path: string, maxBytes?: number): Promise<Buffer> {
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 = <HdfsError>err;
reject(error);

View File

@@ -71,8 +71,8 @@ export class UploadFilesCommand extends ProgressCommand {
try {
let folderNode = await getNode<FolderNode>(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 => <string>confirmed);
}
private async mkDir(fileName, folderNode: FolderNode, cancelToken: vscode.CancellationTokenSource): Promise<void> {
private async mkDir(fileName: string, folderNode: FolderNode, cancelToken: vscode.CancellationTokenSource): Promise<void> {
await folderNode.mkdir(fileName);
}
}

View File

@@ -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<TreeNode>, ITreeChangeHandler {
static readonly NoConnectionsMessage = 'No connections added';
static readonly ConnectionsLabel = 'Connections';
private connections: ConnectionNode[];
private _onDidChangeTreeData = new vscode.EventEmitter<TreeNode>();
private context: TreeDataContext;
constructor(extensionContext: vscode.ExtensionContext) {
this.connections = [];
this.context = new TreeDataContext(extensionContext, this);
}
public get onDidChangeTreeData(): vscode.Event<TreeNode> {
return this._onDidChangeTreeData.event;
}
getTreeItem(element: TreeNode): vscode.TreeItem | Thenable<vscode.TreeItem> {
return element.getTreeItem();
}
getChildren(element?: TreeNode): vscode.ProviderResult<TreeNode[]> {
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<void> {
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;

View File

@@ -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<boolean> {
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(

View File

@@ -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);
}
});
}
}

View File

@@ -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;
}, []);
});
}
}

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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}`);
}

View File

@@ -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

View File

@@ -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];
});
}
}

View File

@@ -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

View File

@@ -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;
}
}
}

View File

@@ -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;
}

View File

@@ -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<T>(question: IQuestion, ignoreFocusOut?: boolean): Promise<T>;
/**
@@ -61,10 +50,5 @@ export interface IPrompter {
* @returns Map of question IDs to results, or undefined if
* the user canceled the question session
*/
prompt<T>(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 }>;
}

View File

@@ -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';

View File

@@ -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;
}

View File

@@ -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';

View File

@@ -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';

View File

@@ -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';

View File

@@ -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',

View File

@@ -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,

View File

@@ -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';

View File

@@ -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 <string>dropdownValue;
} else {
return dropdownValue ? (<azdata.CategoryValue>dropdownValue).name : undefined;
}
}
export function getServerAddressFromName(connection: azdata.ConnectionInfo | string): string {
// Strip TDS port number from the server URI
if ((<azdata.ConnectionInfo>connection).options && (<azdata.ConnectionInfo>connection).options[constants.hostPropName]) {
return (<azdata.ConnectionInfo>connection).options[constants.hostPropName].split(',')[0].split(':')[0];
} else if ((<azdata.ConnectionInfo>connection).options && (<azdata.ConnectionInfo>connection).options['server']) {
return (<azdata.ConnectionInfo>connection).options['server'].split(',')[0].split(':')[0];
} else {
return (<string>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<string> {
return new Promise<string>(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<void> {
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<string> {
return new Promise<string>((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<number> {
return new Promise<number>((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<void> {
return new Promise<void>((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<T>(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)) ? <any>[] : <any>{};
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()));
}

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}

View File

@@ -3,8 +3,7 @@
"compilerOptions": {
"outDir": "./out",
"strict": false,
"noUnusedParameters": false,
"noImplicitAny": false
"noUnusedParameters": false
},
"include": [
"src/**/*"

View File

@@ -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"