Move protocol client out (#643)

* close

* connection is working

* formatting

* adds all

* formatting

* formatting and changing how features are initialized

* formatting

* changed named of typings file

* update

* updated to use dataprotocol npm

* formatting

* removed unneeded logging

* readd npm shrinkwrap

* still not working

* removed unnecessary codfe

* addressed comments

* readded azure resource provider

* fix capabilities cacheing

* added backwards capat for older protocol

* update shrinkwrap

* update shrinkwrap

* updated shrinkwrap

* fixed tests

* removed dead code

* remove dead code

* fix compile

* remove backcompat stuff

* change location of npm

* vbump sqltools

* merge master

* fix imports

* fix build breaks

* update for sqlops

* update yarn dependencies
This commit is contained in:
Anthony Dresser
2018-02-20 13:38:16 -08:00
committed by GitHub
parent 8a9ee40524
commit 8570910a43
159 changed files with 4421 additions and 7180 deletions

View File

@@ -10,7 +10,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
import { TPromise } from 'vs/base/common/winjs.base';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import * as data from 'data';
import * as sqlops from 'sqlops';
import { IQueryManagementService } from 'sql/parts/query/common/queryManagement';
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
@@ -281,37 +281,37 @@ export class RunQueryShortcutAction extends Action {
let dbName = this.getDatabaseName(editor);
let query = `exec dbo.sp_sproc_columns @procedure_name = N'${escapeSqlString(shortcutText, singleQuote)}', @procedure_owner = null, @procedure_qualifier = N'${escapeSqlString(dbName, singleQuote)}'`;
return this._queryManagementService.runQueryAndReturn(editor.uri, query)
.then(result => {
switch(this.isProcWithSingleArgument(result)) {
case 1:
// sproc was found and it meets criteria of having 1 string param
// if selection is quoted, leave as-is. Else quote
let trimmedText = parameterText.trim();
if (trimmedText.length > 0) {
if (trimmedText.charAt(0) !== singleQuote || trimmedText.charAt(trimmedText.length - 1) !== singleQuote) {
// Note: SSMS uses the original text, but this causes issues if you have spaces. We intentionally use
// trimmed text since it's likely to be more accurate in this case. For non-quoted cases it shouldn't matter
return `'${trimmedText}'`;
.then(result => {
switch (this.isProcWithSingleArgument(result)) {
case 1:
// sproc was found and it meets criteria of having 1 string param
// if selection is quoted, leave as-is. Else quote
let trimmedText = parameterText.trim();
if (trimmedText.length > 0) {
if (trimmedText.charAt(0) !== singleQuote || trimmedText.charAt(trimmedText.length - 1) !== singleQuote) {
// Note: SSMS uses the original text, but this causes issues if you have spaces. We intentionally use
// trimmed text since it's likely to be more accurate in this case. For non-quoted cases it shouldn't matter
return `'${trimmedText}'`;
}
}
}
break;
case -1:
break;
case -1:
// sproc was found but didn't meet criteria, so append as-is
case 0:
// sproc wasn't found, just append as-is and hope it works
break;
}
return parameterText;
}, err => {
return parameterText;
});
case 0:
// sproc wasn't found, just append as-is and hope it works
break;
}
return parameterText;
}, err => {
return parameterText;
});
}
return TPromise.as(parameterText);
}
return TPromise.as('');
}
private isProcWithSingleArgument(result: data.SimpleExecuteResult): number {
private isProcWithSingleArgument(result: sqlops.SimpleExecuteResult): number {
let columnTypeOrdinal = this.getColumnIndex(result.columnInfo, 'COLUMN_TYPE');
let dataTypeOrdinal = this.getColumnIndex(result.columnInfo, 'DATA_TYPE');
if (columnTypeOrdinal && dataTypeOrdinal) {
@@ -345,7 +345,7 @@ export class RunQueryShortcutAction extends Action {
return -1; // Couldn't process so return default value
}
private getColumnIndex(columnInfo: data.IDbColumn[], columnName: string): number {
private getColumnIndex(columnInfo: sqlops.IDbColumn[], columnName: string): number {
return columnInfo ? columnInfo.findIndex(c => c.columnName === columnName) : undefined;
}

View File

@@ -14,7 +14,7 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
import { IMessageService, Severity } from 'vs/platform/message/common/message';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ISelectionData } from 'data';
import { ISelectionData } from 'sqlops';
import {
IConnectionManagementService,
IConnectionParams,

View File

@@ -18,7 +18,7 @@ import {
EditCreateRowResult,
EditRevertCellResult,
ExecutionPlanOptions
} from 'data';
} from 'sqlops';
export const SERVICE_ID = 'queryModelService';

View File

@@ -14,7 +14,7 @@ import { QueryInput } from 'sql/parts/query/common/queryInput';
import { QueryStatusbarItem } from 'sql/parts/query/execution/queryStatus';
import { SqlFlavorStatusbarItem } from 'sql/parts/query/common/flavorStatus';
import * as data from 'data';
import * as sqlops from 'sqlops';
import { ISlickRange } from 'angular2-slickgrid';
import * as nls from 'vs/nls';
@@ -41,7 +41,7 @@ class QueryInfo {
public queryRunner: QueryRunner;
public dataService: DataService;
public queryEventQueue: QueryEvent[];
public selection: Array<data.ISelectionData>;
public selection: Array<sqlops.ISelectionData>;
public queryInput: QueryInput;
public selectionSnippet: string;
@@ -66,12 +66,12 @@ export class QueryModelService implements IQueryModelService {
private _queryInfoMap: Map<string, QueryInfo>;
private _onRunQueryStart: Emitter<string>;
private _onRunQueryComplete: Emitter<string>;
private _onEditSessionReady: Emitter<data.EditSessionReadyParams>;
private _onEditSessionReady: Emitter<sqlops.EditSessionReadyParams>;
// EVENTS /////////////////////////////////////////////////////////////
public get onRunQueryStart(): Event<string> { return this._onRunQueryStart.event; }
public get onRunQueryComplete(): Event<string> { return this._onRunQueryComplete.event; }
public get onEditSessionReady(): Event<data.EditSessionReadyParams> { return this._onEditSessionReady.event; }
public get onEditSessionReady(): Event<sqlops.EditSessionReadyParams> { return this._onEditSessionReady.event; }
// CONSTRUCTOR /////////////////////////////////////////////////////////
constructor(
@@ -81,7 +81,7 @@ export class QueryModelService implements IQueryModelService {
this._queryInfoMap = new Map<string, QueryInfo>();
this._onRunQueryStart = new Emitter<string>();
this._onRunQueryComplete = new Emitter<string>();
this._onEditSessionReady = new Emitter<data.EditSessionReadyParams>();
this._onEditSessionReady = new Emitter<sqlops.EditSessionReadyParams>();
// Register Statusbar items
(<statusbar.IStatusbarRegistry>platform.Registry.as(statusbar.Extensions.Statusbar)).registerStatusbarItem(new statusbar.StatusbarItemDescriptor(
@@ -141,13 +141,13 @@ export class QueryModelService implements IQueryModelService {
/**
* Get more data rows from the current resultSets from the service layer
*/
public getQueryRows(uri: string, rowStart: number, numberOfRows: number, batchId: number, resultId: number): Thenable<data.ResultSetSubset> {
public getQueryRows(uri: string, rowStart: number, numberOfRows: number, batchId: number, resultId: number): Thenable<sqlops.ResultSetSubset> {
return this._getQueryInfo(uri).queryRunner.getQueryRows(rowStart, numberOfRows, batchId, resultId).then(results => {
return results.resultSubset;
});
}
public getEditRows(uri: string, rowStart: number, numberOfRows: number): Thenable<data.EditSubsetResult> {
public getEditRows(uri: string, rowStart: number, numberOfRows: number): Thenable<sqlops.EditSubsetResult> {
return this._queryInfoMap.get(uri).queryRunner.getEditRows(rowStart, numberOfRows).then(results => {
return results;
});
@@ -191,15 +191,15 @@ export class QueryModelService implements IQueryModelService {
/**
* Run a query for the given URI with the given text selection
*/
public runQuery(uri: string, selection: data.ISelectionData,
title: string, queryInput: QueryInput, runOptions?: data.ExecutionPlanOptions): void {
public runQuery(uri: string, selection: sqlops.ISelectionData,
title: string, queryInput: QueryInput, runOptions?: sqlops.ExecutionPlanOptions): void {
this.doRunQuery(uri, selection, title, queryInput, false, runOptions);
}
/**
* Run the current SQL statement for the given URI
*/
public runQueryStatement(uri: string, selection: data.ISelectionData,
public runQueryStatement(uri: string, selection: sqlops.ISelectionData,
title: string, queryInput: QueryInput): void {
this.doRunQuery(uri, selection, title, queryInput, true);
}
@@ -215,9 +215,9 @@ export class QueryModelService implements IQueryModelService {
/**
* Run Query implementation
*/
private doRunQuery(uri: string, selection: data.ISelectionData | string,
private doRunQuery(uri: string, selection: sqlops.ISelectionData | string,
title: string, queryInput: QueryInput,
runCurrentStatement: boolean, runOptions?: data.ExecutionPlanOptions): void {
runCurrentStatement: boolean, runOptions?: sqlops.ExecutionPlanOptions): void {
// Reuse existing query runner if it exists
let queryRunner: QueryRunner;
let info: QueryInfo;
@@ -422,7 +422,7 @@ export class QueryModelService implements IQueryModelService {
return TPromise.as(null);
}
public updateCell(ownerUri: string, rowId: number, columnId: number, newValue: string): Thenable<data.EditUpdateCellResult> {
public updateCell(ownerUri: string, rowId: number, columnId: number, newValue: string): Thenable<sqlops.EditUpdateCellResult> {
// Get existing query runner
let queryRunner = this._getQueryRunner(ownerUri);
if (queryRunner) {
@@ -446,7 +446,7 @@ export class QueryModelService implements IQueryModelService {
return TPromise.as(null);
}
public createRow(ownerUri: string): Thenable<data.EditCreateRowResult> {
public createRow(ownerUri: string): Thenable<sqlops.EditCreateRowResult> {
// Get existing query runner
let queryRunner = this._getQueryRunner(ownerUri);
if (queryRunner) {
@@ -464,7 +464,7 @@ export class QueryModelService implements IQueryModelService {
return TPromise.as(null);
}
public revertCell(ownerUri: string, rowId: number, columnId: number): Thenable<data.EditRevertCellResult> {
public revertCell(ownerUri: string, rowId: number, columnId: number): Thenable<sqlops.EditRevertCellResult> {
// Get existing query runner
let queryRunner = this._getQueryRunner(ownerUri);
if (queryRunner) {
@@ -539,9 +539,9 @@ export class QueryModelService implements IQueryModelService {
// TODO remove this funciton and its usages when #821 in vscode-mssql is fixed and
// the SqlToolsService version is updated in this repo - coquagli 4/19/2017
private _validateSelection(selection: data.ISelectionData): data.ISelectionData {
private _validateSelection(selection: sqlops.ISelectionData): sqlops.ISelectionData {
if (!selection) {
selection = <data.ISelectionData>{};
selection = <sqlops.ISelectionData>{};
}
selection.endColumn = selection ? Math.max(0, selection.endColumn) : 0;
selection.endLine = selection ? Math.max(0, selection.endLine) : 0;

View File

@@ -5,7 +5,7 @@
'use strict';
import * as data from 'data';
import * as sqlops from 'sqlops';
import * as Constants from 'sql/parts/query/common/constants';
import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
@@ -41,10 +41,10 @@ export const enum EventType {
export interface IEventType {
start: void;
complete: string;
message: data.IResultMessage;
batchStart: data.BatchSummary;
batchComplete: data.BatchSummary;
resultSet: data.ResultSetSummary;
message: sqlops.IResultMessage;
batchStart: sqlops.BatchSummary;
batchComplete: sqlops.BatchSummary;
resultSet: sqlops.ResultSetSummary;
editSessionReady: IEditSessionReadyEvent;
}
@@ -58,7 +58,7 @@ export default class QueryRunner {
private _totalElapsedMilliseconds: number = 0;
private _isExecuting: boolean = false;
private _hasCompleted: boolean = false;
private _batchSets: data.BatchSummary[] = [];
private _batchSets: sqlops.BatchSummary[] = [];
private _eventEmitter = new EventEmitter();
// CONSTRUCTOR /////////////////////////////////////////////////////////
@@ -79,7 +79,7 @@ export default class QueryRunner {
return this._hasCompleted;
}
get batchSets(): data.BatchSummary[] {
get batchSets(): sqlops.BatchSummary[] {
return this._batchSets;
}
@@ -92,7 +92,7 @@ export default class QueryRunner {
/**
* Cancels the running query, if there is one
*/
public cancelQuery(): Thenable<data.QueryCancelResult> {
public cancelQuery(): Thenable<sqlops.QueryCancelResult> {
return this._queryManagementService.cancelQuery(this.uri);
}
@@ -100,13 +100,13 @@ export default class QueryRunner {
* Runs the query with the provided query
* @param input Query string to execute
*/
public runQuery(input: string, runOptions?: data.ExecutionPlanOptions): Thenable<void>;
public runQuery(input: string, runOptions?: sqlops.ExecutionPlanOptions): Thenable<void>;
/**
* Runs the query by pulling the query from the document using the provided selection data
* @param input selection data
*/
public runQuery(input: data.ISelectionData, runOptions?: data.ExecutionPlanOptions): Thenable<void>;
public runQuery(input, runOptions?: data.ExecutionPlanOptions): Thenable<void> {
public runQuery(input: sqlops.ISelectionData, runOptions?: sqlops.ExecutionPlanOptions): Thenable<void>;
public runQuery(input, runOptions?: sqlops.ExecutionPlanOptions): Thenable<void> {
return this.doRunQuery(input, false, runOptions);
}
@@ -114,7 +114,7 @@ export default class QueryRunner {
* Runs the current SQL statement by pulling the query from the document using the provided selection data
* @param input selection data
*/
public runQueryStatement(input: data.ISelectionData): Thenable<void> {
public runQueryStatement(input: sqlops.ISelectionData): Thenable<void> {
return this.doRunQuery(input, true);
}
@@ -122,9 +122,9 @@ export default class QueryRunner {
* Implementation that runs the query with the provided query
* @param input Query string to execute
*/
private doRunQuery(input: string, runCurrentStatement: boolean, runOptions?: data.ExecutionPlanOptions): Thenable<void>;
private doRunQuery(input: data.ISelectionData, runCurrentStatement: boolean, runOptions?: data.ExecutionPlanOptions): Thenable<void>;
private doRunQuery(input, runCurrentStatement: boolean, runOptions?: data.ExecutionPlanOptions): Thenable<void> {
private doRunQuery(input: string, runCurrentStatement: boolean, runOptions?: sqlops.ExecutionPlanOptions): Thenable<void>;
private doRunQuery(input: sqlops.ISelectionData, runCurrentStatement: boolean, runOptions?: sqlops.ExecutionPlanOptions): Thenable<void>;
private doRunQuery(input, runCurrentStatement: boolean, runOptions?: sqlops.ExecutionPlanOptions): Thenable<void> {
let ownerUri = this.uri;
this._batchSets = [];
this._hasCompleted = false;
@@ -160,20 +160,20 @@ export default class QueryRunner {
// Attempting to launch the query failed, show the error message
const eol = this.getEolString();
let message = nls.localize('query.ExecutionFailedError', 'Execution failed due to an unexpected error: {0}\t{1}', eol, error);
this.handleMessage(<data.QueryExecuteMessageParams> {
this.handleMessage(<sqlops.QueryExecuteMessageParams>{
ownerUri: this.uri,
message: {
isError: true,
message: message
}
});
this.handleQueryComplete(<data.QueryExecuteCompleteNotificationResult> { ownerUri: this.uri });
this.handleQueryComplete(<sqlops.QueryExecuteCompleteNotificationResult>{ ownerUri: this.uri });
}
/**
* Handle a QueryComplete from the service layer
*/
public handleQueryComplete(result: data.QueryExecuteCompleteNotificationResult): void {
public handleQueryComplete(result: sqlops.QueryExecuteCompleteNotificationResult): void {
// Store the batch sets we got back as a source of "truth"
this._isExecuting = false;
@@ -194,7 +194,7 @@ export default class QueryRunner {
/**
* Handle a BatchStart from the service layer
*/
public handleBatchStart(result: data.QueryExecuteBatchNotificationParams): void {
public handleBatchStart(result: sqlops.QueryExecuteBatchNotificationParams): void {
let batch = result.batchSummary;
// Recalculate the start and end lines, relative to the result line offset
@@ -214,8 +214,8 @@ export default class QueryRunner {
/**
* Handle a BatchComplete from the service layer
*/
public handleBatchComplete(result: data.QueryExecuteBatchNotificationParams): void {
let batch: data.BatchSummary = result.batchSummary;
public handleBatchComplete(result: sqlops.QueryExecuteBatchNotificationParams): void {
let batch: sqlops.BatchSummary = result.batchSummary;
// Store the batch again to get the rest of the data
this.batchSets[batch.id] = batch;
@@ -231,17 +231,17 @@ export default class QueryRunner {
/**
* Handle a ResultSetComplete from the service layer
*/
public handleResultSetComplete(result: data.QueryExecuteResultSetCompleteNotificationParams): void {
public handleResultSetComplete(result: sqlops.QueryExecuteResultSetCompleteNotificationParams): void {
if (result && result.resultSetSummary) {
let resultSet = result.resultSetSummary;
let batchSet: data.BatchSummary;
let batchSet: sqlops.BatchSummary;
if (!resultSet.batchId) {
// Missing the batchId. In this case, default to always using the first batch in the list
// or create one in the case the DMP extension didn't obey the contract perfectly
if (this.batchSets.length > 0) {
batchSet = this.batchSets[0];
} else {
batchSet = <data.BatchSummary>{
batchSet = <sqlops.BatchSummary>{
id: 0,
selection: undefined,
hasError: false,
@@ -263,7 +263,7 @@ export default class QueryRunner {
/**
* Handle a Mssage from the service layer
*/
public handleMessage(obj: data.QueryExecuteMessageParams): void {
public handleMessage(obj: sqlops.QueryExecuteMessageParams): void {
let message = obj.message;
message.time = new Date(message.time).toLocaleTimeString();
@@ -274,9 +274,9 @@ export default class QueryRunner {
/**
* Get more data rows from the current resultSets from the service layer
*/
public getQueryRows(rowStart: number, numberOfRows: number, batchIndex: number, resultSetIndex: number): Thenable<data.QueryExecuteSubsetResult> {
public getQueryRows(rowStart: number, numberOfRows: number, batchIndex: number, resultSetIndex: number): Thenable<sqlops.QueryExecuteSubsetResult> {
const self = this;
let rowData: data.QueryExecuteSubsetParams = <data.QueryExecuteSubsetParams>{
let rowData: sqlops.QueryExecuteSubsetParams = <sqlops.QueryExecuteSubsetParams>{
ownerUri: this.uri,
resultSetIndex: resultSetIndex,
rowsCount: numberOfRows,
@@ -284,7 +284,7 @@ export default class QueryRunner {
batchIndex: batchIndex
};
return new Promise<data.QueryExecuteSubsetResult>((resolve, reject) => {
return new Promise<sqlops.QueryExecuteSubsetResult>((resolve, reject) => {
self._queryManagementService.getQueryRows(rowData).then(result => {
resolve(result);
}, error => {
@@ -322,15 +322,15 @@ export default class QueryRunner {
* @param rowStart The index of the row to start returning (inclusive)
* @param numberOfRows The number of rows to return
*/
public getEditRows(rowStart: number, numberOfRows: number): Thenable<data.EditSubsetResult> {
public getEditRows(rowStart: number, numberOfRows: number): Thenable<sqlops.EditSubsetResult> {
const self = this;
let rowData: data.EditSubsetParams = {
let rowData: sqlops.EditSubsetParams = {
ownerUri: this.uri,
rowCount: numberOfRows,
rowStartIndex: rowStart
};
return new Promise<data.EditSubsetResult>((resolve, reject) => {
return new Promise<sqlops.EditSubsetResult>((resolve, reject) => {
self._queryManagementService.getEditRows(rowData).then(result => {
if (!result.hasOwnProperty('rowCount')) {
let error = `Nothing returned from subset query`;
@@ -350,7 +350,7 @@ export default class QueryRunner {
this._eventEmitter.emit(EventType.EDIT_SESSION_READY, { ownerUri, success, message });
}
public updateCell(ownerUri: string, rowId: number, columnId: number, newValue: string): Thenable<data.EditUpdateCellResult> {
public updateCell(ownerUri: string, rowId: number, columnId: number, newValue: string): Thenable<sqlops.EditUpdateCellResult> {
return this._queryManagementService.updateCell(ownerUri, rowId, columnId, newValue);
}
@@ -358,7 +358,7 @@ export default class QueryRunner {
return this._queryManagementService.commitEdit(ownerUri);
}
public createRow(ownerUri: string): Thenable<data.EditCreateRowResult> {
public createRow(ownerUri: string): Thenable<sqlops.EditCreateRowResult> {
return this._queryManagementService.createRow(ownerUri).then(result => {
return result;
});
@@ -368,7 +368,7 @@ export default class QueryRunner {
return this._queryManagementService.deleteRow(ownerUri, rowId);
}
public revertCell(ownerUri: string, rowId: number, columnId: number): Thenable<data.EditRevertCellResult> {
public revertCell(ownerUri: string, rowId: number, columnId: number): Thenable<sqlops.EditRevertCellResult> {
return this._queryManagementService.revertCell(ownerUri, rowId, columnId).then(result => {
return result;
});
@@ -468,7 +468,7 @@ export default class QueryRunner {
private getColumnHeaders(batchId: number, resultId: number, range: ISlickRange): string[] {
let headers: string[] = undefined;
let batchSummary: data.BatchSummary = this.batchSets[batchId];
let batchSummary: sqlops.BatchSummary = this.batchSets[batchId];
if (batchSummary !== undefined) {
let resultSetSummary = batchSummary.resultSetSummaries[resultId];
headers = resultSetSummary.columnInfo.slice(range.fromCell, range.toCell + 1).map((info, i) => {
@@ -495,7 +495,7 @@ export default class QueryRunner {
// get config copyRemoveNewLine option from vscode config
let showBatchTime: boolean = WorkbenchUtils.getSqlConfigValue<boolean>(this._workspaceConfigurationService, Constants.configShowBatchTime);
if (showBatchTime) {
let message: data.IResultMessage = {
let message: sqlops.IResultMessage = {
batchId: batchId,
message: nls.localize('elapsedBatchTime', 'Batch execution time: {0}', executionTime),
time: undefined,