mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
Revert "Update dataprotocol client" (#500)
* Revert "Fix #494 Connection error when connecting to an Azure SQL Server with no firewall rule (#497)" This reverts commitedd867b6fc. * Revert "Update dataprotocol client (#418)" This reverts commit7808496416.
This commit is contained in:
@@ -13,6 +13,10 @@ const filter = require('gulp-filter');
|
||||
|
||||
gulp.task('clean-mssql-extension', util.rimraf('extensions/mssql/node_modules'));
|
||||
gulp.task('clean-credentials-extension', util.rimraf('extensions/credentials/node_modules'));
|
||||
gulp.task('clean-client', util.rimraf('dataprotocol-node/client/node_modules'));
|
||||
gulp.task('clean-jsonrpc', util.rimraf('dataprotocol-node/jsonrpc/node_modules'));
|
||||
gulp.task('clean-server', util.rimraf('dataprotocol-node/server/node_modules'));
|
||||
gulp.task('clean-types', util.rimraf('dataprotocol-node/types/node_modules'));
|
||||
gulp.task('clean-extensions-modules', util.rimraf('extensions-modules/node_modules'));
|
||||
gulp.task('clean-protocol', ['clean-extensions-modules', 'clean-mssql-extension', 'clean-credentials-extension', 'clean-client', 'clean-jsonrpc', 'clean-server', 'clean-types']);
|
||||
|
||||
|
||||
@@ -20,7 +20,15 @@ function npmInstall(location, opts) {
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
npmInstall('dataprotocol-client');
|
||||
const protocol = [
|
||||
'jsonrpc',
|
||||
'types',
|
||||
'client'
|
||||
];
|
||||
|
||||
protocol.forEach(item => npmInstall(`dataprotocol-node/${item}`));
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
npmInstall('extensions-modules');
|
||||
npmInstall('extensions'); // node modules shared by all extensions
|
||||
|
||||
|
||||
3
dataprotocol-client/.gitignore
vendored
3
dataprotocol-client/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
lib
|
||||
node_modules
|
||||
npm-debug.log
|
||||
@@ -1,3 +0,0 @@
|
||||
src
|
||||
.gitignore
|
||||
tsfmt.json
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "dataprotocol-client",
|
||||
"version": "1.0.0",
|
||||
"description": "SQL Operations Studio studio implementation of vscode-language-client",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"prepublish": "node ./node_modules/vscode/bin/install && tsc -p ./src",
|
||||
"compile": "tsc -p ./src",
|
||||
"watch": "tsc -w -p ./src",
|
||||
"update-vscode": "node ./node_modules/vscode/bin/install"
|
||||
},
|
||||
"author": "Microsoft",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"vscode": "1.1.5",
|
||||
"vscode-languageclient": "3.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "2.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.15"
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import * as data from 'data';
|
||||
import * as proto from './protocol';
|
||||
import * as types from './types';
|
||||
|
||||
export interface Ic2p {
|
||||
asConnectionParams(connectionUri: string, connectionInfo: data.ConnectionInfo): proto.ConnectParams;
|
||||
asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): data.ExecutionPlanOptions;
|
||||
asScriptingParams(connectionUri: string, operation: data.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): types.ScriptingParams;
|
||||
}
|
||||
|
||||
function asConnectionParams(ownerUri: string, connInfo: data.ConnectionInfo): proto.ConnectParams {
|
||||
return {
|
||||
ownerUri,
|
||||
connection: {
|
||||
options: connInfo.options
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): data.ExecutionPlanOptions {
|
||||
return {
|
||||
displayEstimatedQueryPlan: planOptions ? planOptions.displayEstimatedQueryPlan : undefined,
|
||||
displayActualQueryPlan: planOptions ? planOptions.displayActualQueryPlan : undefined
|
||||
};
|
||||
}
|
||||
|
||||
function asScriptingParams(ownerURI: string, operation: data.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): types.ScriptingParams {
|
||||
let scriptingObject: types.ScriptingObject = {
|
||||
type: metadata.metadataTypeName,
|
||||
schema: metadata.schema,
|
||||
name: metadata.name
|
||||
};
|
||||
let targetDatabaseEngineEdition = paramDetails.targetDatabaseEngineEdition;
|
||||
let targetDatabaseEngineType = paramDetails.targetDatabaseEngineType;
|
||||
let scriptCompatibilityOption = paramDetails.scriptCompatibilityOption;
|
||||
let scriptOptions: types.ScriptOptions = {
|
||||
scriptCreateDrop: (operation === types.ScriptOperation.Delete) ? 'ScriptDrop' :
|
||||
(operation === types.ScriptOperation.Select) ? 'ScriptSelect' : 'ScriptCreate',
|
||||
typeOfDataToScript: 'SchemaOnly',
|
||||
scriptStatistics: 'ScriptStatsNone',
|
||||
targetDatabaseEngineEdition: targetDatabaseEngineEdition ? targetDatabaseEngineEdition : 'SqlServerEnterpriseEdition',
|
||||
targetDatabaseEngineType: targetDatabaseEngineType ? targetDatabaseEngineType : 'SingleInstance',
|
||||
scriptCompatibilityOption: scriptCompatibilityOption ? scriptCompatibilityOption : 'Script140Compat'
|
||||
};
|
||||
return {
|
||||
connectionString: null,
|
||||
filePath: paramDetails.filePath,
|
||||
scriptingObjects: [scriptingObject],
|
||||
scriptDestination: 'ToEditor',
|
||||
includeObjectCriteria: null,
|
||||
excludeObjectCriteria: null,
|
||||
includeSchemas: null,
|
||||
excludeSchemas: null,
|
||||
includeTypes: null,
|
||||
excludeTypes: null,
|
||||
scriptOptions,
|
||||
connectionDetails: null,
|
||||
selectScript: null,
|
||||
ownerURI,
|
||||
operation
|
||||
};
|
||||
}
|
||||
|
||||
export const c2p: Ic2p = {
|
||||
asConnectionParams,
|
||||
asExecutionPlanOptions,
|
||||
asScriptingParams
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,633 +0,0 @@
|
||||
import { ClientCapabilities as VSClientCapabilities, RequestType, NotificationType } from 'vscode-languageclient';
|
||||
|
||||
import * as types from './types';
|
||||
import * as data from 'data';
|
||||
|
||||
export interface ConnectionClientCapabilities {
|
||||
connection?: {
|
||||
/**
|
||||
* Whether the connection support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
backup?: {
|
||||
/**
|
||||
* Whether the backup support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
restore?: {
|
||||
/**
|
||||
* Whether the restore support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
query?: {
|
||||
/**
|
||||
* Whether the query support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
objectExplorer?: {
|
||||
/**
|
||||
* Whether the object explorer support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
scripting?: {
|
||||
/**
|
||||
* Whether the scripting support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
taskServices?: {
|
||||
/**
|
||||
* Whether the task services support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
fileBrowser?: {
|
||||
/**
|
||||
* Whether the file browser support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
profiler?: {
|
||||
/**
|
||||
* Whether the profiler support dynamic registration
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
capabilities?: {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
metadata?: {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
adminServices?: {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
dynamicRegistration?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ClientCapabilities extends VSClientCapabilities {
|
||||
connection?: ConnectionClientCapabilities;
|
||||
}
|
||||
|
||||
//---- Refresh IntelliSense ----------------------------------------
|
||||
|
||||
/**
|
||||
* Notification sent when the an IntelliSense cache invalidation is requested
|
||||
*/
|
||||
export namespace RebuildIntelliSenseNotification {
|
||||
export const type = new NotificationType<RebuildIntelliSenseParams, void>('textDocument/rebuildIntelliSense');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild IntelliSense notification parameters
|
||||
*/
|
||||
export class RebuildIntelliSenseParams {
|
||||
/**
|
||||
* URI identifying the text document
|
||||
*/
|
||||
public ownerUri: string;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------- < Connect Request > ----------------------------------------------
|
||||
|
||||
/**
|
||||
* Connection request message format
|
||||
*/
|
||||
export interface ConnectParams {
|
||||
/**
|
||||
* URI identifying the owner of the connection
|
||||
*/
|
||||
ownerUri: string;
|
||||
|
||||
/**
|
||||
* Details for creating the connection
|
||||
*/
|
||||
connection: types.ConnectionDetails;
|
||||
}
|
||||
|
||||
|
||||
// Connection request message callback declaration
|
||||
export namespace ConnectionRequest {
|
||||
export const type = new RequestType<ConnectParams, boolean, void, void>('connection/connect');
|
||||
}
|
||||
|
||||
// ------------------------------- < Connection Complete Event > ------------------------------------
|
||||
|
||||
|
||||
export namespace ConnectionCompleteNotification {
|
||||
export const type = new NotificationType<types.ConnectionCompleteParams, void>('connection/complete');
|
||||
}
|
||||
|
||||
// ------------------------------- < Connection Changed Event > -------------------------------------
|
||||
|
||||
/**
|
||||
* Parameters for the ConnectionChanged notification.
|
||||
*/
|
||||
export class ConnectionChangedParams {
|
||||
/**
|
||||
* Owner URI of the connection that changed.
|
||||
*/
|
||||
public ownerUri: string;
|
||||
|
||||
/**
|
||||
* Summary of details containing any connection changes.
|
||||
*/
|
||||
public connection: types.ConnectionSummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection changed event callback declaration.
|
||||
*/
|
||||
export namespace ConnectionChangedNotification {
|
||||
export const type = new NotificationType<ConnectionChangedParams, void>('connection/connectionchanged');
|
||||
}
|
||||
|
||||
// ------------------------------- < Disconnect Request > -------------------------------------------
|
||||
|
||||
// Disconnect request message format
|
||||
export class DisconnectParams {
|
||||
// URI identifying the owner of the connection
|
||||
public ownerUri: string;
|
||||
}
|
||||
|
||||
// Disconnect response format
|
||||
export type DisconnectResult = boolean;
|
||||
|
||||
// Disconnect request message callback declaration
|
||||
export namespace DisconnectRequest {
|
||||
export const type = new RequestType<DisconnectParams, DisconnectResult, void, void>('connection/disconnect');
|
||||
}
|
||||
|
||||
// ------------------------------- < Cancel Connect Request > ---------------------------------------
|
||||
|
||||
|
||||
// Cancel connect request message format
|
||||
export class CancelConnectParams {
|
||||
/**
|
||||
* URI identifying the owner of the connection
|
||||
*/
|
||||
public ownerUri: string;
|
||||
}
|
||||
|
||||
// Cancel connect response format.
|
||||
export type CancelConnectResult = boolean;
|
||||
|
||||
// Cancel connect request message callback declaration
|
||||
export namespace CancelConnectRequest {
|
||||
export const type = new RequestType<CancelConnectParams, CancelConnectResult, void, void>('connection/cancelconnect');
|
||||
}
|
||||
|
||||
// ------------------------------- < Change Database Request > -------------------------------------
|
||||
|
||||
export class ChangeDatabaseParams {
|
||||
public ownerUri: string;
|
||||
public newDatabase: string;
|
||||
}
|
||||
|
||||
export namespace ChangeDatabaseRequest {
|
||||
export const type = new RequestType<ChangeDatabaseParams, boolean, void, void>('connection/changedatabase');
|
||||
}
|
||||
|
||||
// ------------------------------- < List Databases Request > ---------------------------------------
|
||||
|
||||
// List databases request format
|
||||
export class ListDatabasesParams {
|
||||
// Connection information to use for querying master
|
||||
public ownerUri: string;
|
||||
}
|
||||
|
||||
// List databases request callback declaration
|
||||
export namespace ListDatabasesRequest {
|
||||
export const type = new RequestType<ListDatabasesParams, data.ListDatabasesResult, void, void>('connection/listdatabases');
|
||||
}
|
||||
|
||||
// Language Flavor Changed ================================================================================
|
||||
|
||||
/**
|
||||
* Parameters to provide when sending a language flavor changed notification
|
||||
*/
|
||||
export interface DidChangeLanguageFlavorParams {
|
||||
uri: string;
|
||||
language: string;
|
||||
flavor: string;
|
||||
}
|
||||
|
||||
// ------------------------------- < Language Flavor Changed Notification > ---------------------------------------
|
||||
export namespace LanguageFlavorChangedNotification {
|
||||
export const type = new NotificationType<DidChangeLanguageFlavorParams, void>('connection/languageflavorchanged');
|
||||
}
|
||||
|
||||
// ------------------------------- < Table Metadata Request > ---------------------------------------
|
||||
|
||||
// Table metadata request format
|
||||
export class TableMetadataParams {
|
||||
// Connection information to use for querying master
|
||||
public ownerUri: string;
|
||||
|
||||
public schema: string;
|
||||
|
||||
public objectName: string;
|
||||
}
|
||||
|
||||
// Table metadata response format
|
||||
export class TableMetadataResult {
|
||||
public columns: data.ColumnMetadata[];
|
||||
}
|
||||
|
||||
// Table metadata request callback declaration
|
||||
export namespace TableMetadataRequest {
|
||||
export const type = new RequestType<TableMetadataParams, TableMetadataResult, void, void>('metadata/table');
|
||||
}
|
||||
|
||||
// ------------------------------- < View Metadata Request > ---------------------------------------
|
||||
|
||||
// Table metadata request callback declaration
|
||||
export namespace ViewMetadataRequest {
|
||||
export const type = new RequestType<TableMetadataParams, TableMetadataResult, void, void>('metadata/view');
|
||||
}
|
||||
|
||||
/**
|
||||
* Event sent when the language service is finished updating after a connection
|
||||
*/
|
||||
export namespace IntelliSenseReadyNotification {
|
||||
export const type = new NotificationType<types.IntelliSenseReadyParams, void>('textDocument/intelliSenseReady');
|
||||
}
|
||||
|
||||
// ------------------------------- < Capabilties Discovery Event > ------------------------------------
|
||||
|
||||
export class CapabiltiesDiscoveryParams {
|
||||
public hostName: string;
|
||||
|
||||
public hostVersion: string;
|
||||
}
|
||||
|
||||
export namespace CapabiltiesDiscoveryRequest {
|
||||
export const type = new RequestType<CapabiltiesDiscoveryParams, types.CapabiltiesDiscoveryResult, void, void>('capabilities/list');
|
||||
}
|
||||
|
||||
// Query Execution ================================================================================
|
||||
// ------------------------------- < Query Cancellation Request > ------------------------------------
|
||||
export namespace QueryCancelRequest {
|
||||
export const type = new RequestType<QueryCancelParams, data.QueryCancelResult, void, void>('query/cancel');
|
||||
}
|
||||
|
||||
export interface QueryCancelParams {
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
// ------------------------------- < Query Dispose Request > ------------------------------------
|
||||
|
||||
export namespace QueryDisposeRequest {
|
||||
export const type = new RequestType<QueryDisposeParams, QueryDisposeResult, void, void>('query/dispose');
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters to provide when disposing of a query
|
||||
*/
|
||||
export interface QueryDisposeParams {
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Result received upon successful disposal of a query
|
||||
*/
|
||||
export interface QueryDisposeResult {
|
||||
}
|
||||
|
||||
// ------------------------------- < Query Execution Complete Notification > ------------------------------------
|
||||
export namespace QueryExecuteCompleteNotification {
|
||||
export const type = new NotificationType<data.QueryExecuteCompleteNotificationResult, void>('query/complete');
|
||||
}
|
||||
|
||||
// ------------------------------- < Query Batch Start Notification > ------------------------------------
|
||||
export namespace QueryExecuteBatchStartNotification {
|
||||
export const type = new NotificationType<data.QueryExecuteBatchNotificationParams, void>('query/batchStart');
|
||||
}
|
||||
|
||||
// ------------------------------- < Query Batch Complete Notification > ------------------------------------
|
||||
export namespace QueryExecuteBatchCompleteNotification {
|
||||
export const type = new NotificationType<data.QueryExecuteBatchNotificationParams, void>('query/batchComplete');
|
||||
}
|
||||
|
||||
// ------------------------------- < Query ResultSet Complete Notification > ------------------------------------
|
||||
export namespace QueryExecuteResultSetCompleteNotification {
|
||||
export const type = new NotificationType<data.QueryExecuteResultSetCompleteNotificationParams, void>('query/resultSetComplete');
|
||||
}
|
||||
|
||||
// ------------------------------- < Query Message Notification > ------------------------------------
|
||||
export namespace QueryExecuteMessageNotification {
|
||||
export const type = new NotificationType<data.QueryExecuteMessageParams, void>('query/message');
|
||||
}
|
||||
|
||||
// ------------------------------- < Query Execution Request > ------------------------------------
|
||||
export namespace QueryExecuteRequest {
|
||||
export const type = new RequestType<data.QueryExecuteParams, QueryExecuteResult, void, void>('query/executeDocumentSelection');
|
||||
}
|
||||
|
||||
export interface QueryExecuteResult { }
|
||||
|
||||
// ------------------------------- < Query Results Request > ------------------------------------
|
||||
export namespace QueryExecuteSubsetRequest {
|
||||
export const type = new RequestType<data.QueryExecuteSubsetParams, data.QueryExecuteSubsetResult, void, void>('query/subset');
|
||||
}
|
||||
|
||||
export interface ResultSetSubset {
|
||||
rowCount: number;
|
||||
rows: data.DbCellValue[][];
|
||||
}
|
||||
|
||||
// ------------------------------- < Execute Statement > ------------------------------------
|
||||
export interface QueryExecuteStatementParams {
|
||||
ownerUri: string;
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export namespace QueryExecuteStatementRequest {
|
||||
export const type = new RequestType<QueryExecuteStatementParams, QueryExecuteResult, void, void>('query/executedocumentstatement');
|
||||
}
|
||||
|
||||
// --------------------------------- < Save Results as CSV Request > ------------------------------------------
|
||||
|
||||
// save results in csv format
|
||||
export namespace SaveResultsAsCsvRequest {
|
||||
export const type = new RequestType<data.SaveResultsRequestParams, data.SaveResultRequestResult, void, void>('query/saveCsv');
|
||||
}
|
||||
// --------------------------------- </ Save Results as CSV Request > ------------------------------------------
|
||||
|
||||
// --------------------------------- < Save Results as JSON Request > ------------------------------------------
|
||||
// save results in json format
|
||||
export namespace SaveResultsAsJsonRequest {
|
||||
export const type = new RequestType<data.SaveResultsRequestParams, data.SaveResultRequestResult, void, void>('query/saveJson');
|
||||
}
|
||||
// --------------------------------- </ Save Results as JSON Request > ------------------------------------------
|
||||
|
||||
// --------------------------------- < Save Results as Excel Request > ------------------------------------------
|
||||
// save results in Excel format
|
||||
export namespace SaveResultsAsExcelRequest {
|
||||
export const type = new RequestType<data.SaveResultsRequestParams, data.SaveResultRequestResult, void, void>('query/saveExcel');
|
||||
}
|
||||
// --------------------------------- </ Save Results as Excel Request > ------------------------------------------
|
||||
|
||||
// ------------------------------- < Execute and Return > -----------------------------------
|
||||
|
||||
export namespace SimpleExecuteRequest {
|
||||
export const type = new RequestType<data.SimpleExecuteParams, data.SimpleExecuteResult, void, void>('query/simpleexecute');
|
||||
}
|
||||
|
||||
// ------------------------------- < Execute String > ------------------------------------
|
||||
export interface QueryExecuteStringParams {
|
||||
query: string;
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
export namespace QueryExecuteStringRequest {
|
||||
export const type = new RequestType<QueryExecuteStringParams, QueryExecuteResult, void, void>('query/executeString');
|
||||
}
|
||||
|
||||
// ------------------------------- < Metadata Events > ------------------------------------
|
||||
|
||||
export namespace MetadataQueryRequest {
|
||||
export const type = new RequestType<types.MetadataQueryParams, types.MetadataQueryResult, void, void>('metadata/list');
|
||||
}
|
||||
|
||||
// ------------------------------- < Scripting Events > ------------------------------------
|
||||
|
||||
export namespace ScriptingRequest {
|
||||
export const type = new RequestType<types.ScriptingParams, data.ScriptingResult, void, void>('scripting/script');
|
||||
}
|
||||
|
||||
// ------------------------------- < Scripting Complete Event > ------------------------------------
|
||||
|
||||
export namespace ScriptingCompleteNotification {
|
||||
export const type = new NotificationType<types.ScriptingCompleteParams, void>('scripting/scriptComplete');
|
||||
}
|
||||
|
||||
|
||||
// Edit Data ======================================================================================
|
||||
// Shared Interfaces --------------------------------------------------------------------------
|
||||
export interface EditSessionOperationParams {
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
export interface EditRowOperationParams extends EditSessionOperationParams {
|
||||
rowId: number;
|
||||
}
|
||||
|
||||
export interface EditCellResult {
|
||||
cell: data.EditCell;
|
||||
isRowDirty: boolean;
|
||||
}
|
||||
|
||||
// edit/commit --------------------------------------------------------------------------------
|
||||
export namespace EditCommitRequest {
|
||||
export const type = new RequestType<data.EditCommitParams, EditCommitResult, void, void>('edit/commit');
|
||||
}
|
||||
|
||||
export interface EditCommitResult { }
|
||||
|
||||
// edit/createRow -----------------------------------------------------------------------------
|
||||
export namespace EditCreateRowRequest {
|
||||
export const type = new RequestType<data.EditCreateRowParams, data.EditCreateRowResult, void, void>('edit/createRow');
|
||||
}
|
||||
|
||||
// edit/deleteRow -----------------------------------------------------------------------------
|
||||
export namespace EditDeleteRowRequest {
|
||||
export const type = new RequestType<data.EditDeleteRowParams, EditDeleteRowResult, void, void>('edit/deleteRow');
|
||||
}
|
||||
|
||||
export interface EditDeleteRowResult { }
|
||||
|
||||
// edit/dispose -------------------------------------------------------------------------------
|
||||
export namespace EditDisposeRequest {
|
||||
export const type = new RequestType<data.EditDisposeParams, EditDisposeResult, void, void>('edit/dispose');
|
||||
}
|
||||
|
||||
export interface EditDisposeResult { }
|
||||
|
||||
// edit/initialize ----------------------------------------------------------------------------
|
||||
export namespace EditInitializeRequest {
|
||||
export const type = new RequestType<data.EditInitializeParams, EditInitializeResult, void, void>('edit/initialize');
|
||||
}
|
||||
|
||||
export interface EditInitializeResult { }
|
||||
|
||||
// edit/revertCell --------------------------------------------------------------------------------
|
||||
export namespace EditRevertCellRequest {
|
||||
export const type = new RequestType<data.EditRevertCellParams, data.EditRevertCellResult, void, void>('edit/revertCell');
|
||||
}
|
||||
|
||||
// edit/revertRow -----------------------------------------------------------------------------
|
||||
export namespace EditRevertRowRequest {
|
||||
export const type = new RequestType<data.EditRevertRowParams, EditRevertRowResult, void, void>('edit/revertRow');
|
||||
}
|
||||
|
||||
export interface EditRevertRowResult { }
|
||||
|
||||
// edit/sessionReady Event --------------------------------------------------------------------
|
||||
export namespace EditSessionReadyNotification {
|
||||
export const type = new NotificationType<data.EditSessionReadyParams, void>('edit/sessionReady');
|
||||
}
|
||||
|
||||
// edit/updateCell ----------------------------------------------------------------------------
|
||||
export namespace EditUpdateCellRequest {
|
||||
export const type = new RequestType<data.EditUpdateCellParams, data.EditUpdateCellResult, void, void>('edit/updateCell');
|
||||
}
|
||||
|
||||
// edit/subset ------------------------------------------------------------------------------------
|
||||
export namespace EditSubsetRequest {
|
||||
export const type = new RequestType<data.EditSubsetParams, data.EditSubsetResult, void, void>('edit/subset');
|
||||
}
|
||||
|
||||
// ------------------------------- < Object Explorer Events > ------------------------------------
|
||||
|
||||
export namespace ObjectExplorerCreateSessionRequest {
|
||||
export const type = new RequestType<types.ConnectionDetails, types.CreateSessionResponse, void, void>('objectexplorer/createsession');
|
||||
}
|
||||
|
||||
export namespace ObjectExplorerExpandRequest {
|
||||
export const type = new RequestType<types.ExpandParams, boolean, void, void>('objectexplorer/expand');
|
||||
}
|
||||
|
||||
export namespace ObjectExplorerRefreshRequest {
|
||||
export const type = new RequestType<types.ExpandParams, boolean, void, void>('objectexplorer/refresh');
|
||||
}
|
||||
|
||||
export namespace ObjectExplorerCloseSessionRequest {
|
||||
export const type = new RequestType<types.CloseSessionParams, types.CloseSessionResponse, void, void>('objectexplorer/closesession');
|
||||
}
|
||||
|
||||
// ------------------------------- < Object Explorer Events > ------------------------------------
|
||||
|
||||
|
||||
export namespace ObjectExplorerCreateSessionCompleteNotification {
|
||||
export const type = new NotificationType<types.SessionCreatedParameters, void>('objectexplorer/sessioncreated');
|
||||
}
|
||||
|
||||
export namespace ObjectExplorerExpandCompleteNotification {
|
||||
export const type = new NotificationType<types.ExpandResponse, void>('objectexplorer/expandCompleted');
|
||||
}
|
||||
|
||||
// ------------------------------- < Task Service Events > ------------------------------------
|
||||
|
||||
export namespace ListTasksRequest {
|
||||
export const type = new RequestType<data.ListTasksParams, data.ListTasksResponse, void, void>('tasks/listtasks');
|
||||
}
|
||||
|
||||
export namespace CancelTaskRequest {
|
||||
export const type = new RequestType<data.CancelTaskParams, boolean, void, void>('tasks/canceltask');
|
||||
}
|
||||
|
||||
// ------------------------------- < Task Service Events > ------------------------------------
|
||||
|
||||
|
||||
export namespace TaskStatusChangedNotification {
|
||||
export const type = new NotificationType<data.TaskProgressInfo, void>('tasks/statuschanged');
|
||||
}
|
||||
|
||||
export namespace TaskCreatedNotification {
|
||||
export const type = new NotificationType<data.TaskInfo, void>('tasks/newtaskcreated');
|
||||
}
|
||||
|
||||
// ------------------------------- < Admin Service Events > ------------------------------------
|
||||
|
||||
export namespace CreateDatabaseRequest {
|
||||
export const type = new RequestType<types.CreateDatabaseParams, data.CreateDatabaseResponse, void, void>('admin/createdatabase');
|
||||
}
|
||||
|
||||
export namespace DefaultDatabaseInfoRequest {
|
||||
export const type = new RequestType<types.DefaultDatabaseInfoParams, types.DefaultDatabaseInfoResponse, void, void>('admin/defaultdatabaseinfo');
|
||||
}
|
||||
|
||||
export namespace CreateLoginRequest {
|
||||
export const type = new RequestType<types.CreateLoginParams, data.CreateLoginResponse, void, void>('admin/createlogin');
|
||||
}
|
||||
|
||||
export namespace GetDatabaseInfoRequest {
|
||||
export const type = new RequestType<types.GetDatabaseInfoParams, types.GetDatabaseInfoResponse, void, void>('admin/getdatabaseinfo');
|
||||
}
|
||||
|
||||
// ------------------------------- < Disaster Recovery Events > ------------------------------------
|
||||
|
||||
export namespace BackupRequest {
|
||||
export const type = new RequestType<types.BackupParams, data.BackupResponse, void, void>('backup/backup');
|
||||
}
|
||||
|
||||
export namespace BackupConfigInfoRequest {
|
||||
export const type = new RequestType<types.DefaultDatabaseInfoParams, types.BackupConfigInfoResponse, void, void>('backup/backupconfiginfo');
|
||||
}
|
||||
|
||||
export namespace RestoreRequest {
|
||||
export const type = new RequestType<types.RestoreParams, data.RestoreResponse, void, void>('restore/restore');
|
||||
}
|
||||
|
||||
export namespace RestorePlanRequest {
|
||||
export const type = new RequestType<types.RestoreParams, data.RestorePlanResponse, void, void>('restore/restoreplan');
|
||||
}
|
||||
|
||||
export namespace CancelRestorePlanRequest {
|
||||
export const type = new RequestType<types.RestoreParams, boolean, void, void>('restore/cancelrestoreplan');
|
||||
}
|
||||
|
||||
export namespace RestoreConfigInfoRequest {
|
||||
export const type = new RequestType<types.RestoreConfigInfoRequestParams, types.RestoreConfigInfoResponse, void, void>('restore/restoreconfiginfo');
|
||||
}
|
||||
|
||||
// ------------------------------- < File Browser Events > ------------------------------------
|
||||
|
||||
export namespace FileBrowserOpenRequest {
|
||||
export const type = new RequestType<types.FileBrowserOpenParams, boolean, void, void>('filebrowser/open');
|
||||
}
|
||||
|
||||
export namespace FileBrowserOpenedNotification {
|
||||
export const type = new NotificationType<data.FileBrowserOpenedParams, void>('filebrowser/opencomplete');
|
||||
}
|
||||
|
||||
export namespace FileBrowserExpandRequest {
|
||||
export const type = new RequestType<types.FileBrowserExpandParams, boolean, void, void>('filebrowser/expand');
|
||||
}
|
||||
|
||||
export namespace FileBrowserExpandedNotification {
|
||||
export const type = new NotificationType<data.FileBrowserExpandedParams, void>('filebrowser/expandcomplete');
|
||||
}
|
||||
|
||||
export namespace FileBrowserValidateRequest {
|
||||
export const type = new RequestType<types.FileBrowserValidateParams, boolean, void, void>('filebrowser/validate');
|
||||
}
|
||||
|
||||
export namespace FileBrowserValidatedNotification {
|
||||
export const type = new NotificationType<data.FileBrowserValidatedParams, void>('filebrowser/validatecomplete');
|
||||
}
|
||||
|
||||
export namespace FileBrowserCloseRequest {
|
||||
export const type = new RequestType<types.FileBrowserCloseParams, data.FileBrowserCloseResponse, void, void>('filebrowser/close');
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------- < Profiler Events > ------------------------------------
|
||||
|
||||
export namespace StartProfilingRequest {
|
||||
export const type = new RequestType<types.StartProfilingParams, types.StartProfilingResponse, void, void>('profiler/start');
|
||||
}
|
||||
|
||||
export namespace StopProfilingRequest {
|
||||
export const type = new RequestType<types.StopProfilingParams, types.StopProfilingResponse, void, void>('profiler/stop');
|
||||
}
|
||||
|
||||
export namespace ProfilerEventsAvailableNotification {
|
||||
export const type = new NotificationType<types.ProfilerEventsAvailableParams, void>('profiler/eventsavailable');
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import * as data from 'data';
|
||||
import * as types from './types';
|
||||
|
||||
export interface Ip2c {
|
||||
asProviderMetadata(params: types.MetadataQueryResult): data.ProviderMetadata;
|
||||
}
|
||||
|
||||
function asProviderMetadata(params: types.MetadataQueryResult): data.ProviderMetadata {
|
||||
let objectMetadata: data.ObjectMetadata[] = [];
|
||||
|
||||
if (!params.metadata || !params.metadata.length) {
|
||||
return {
|
||||
objectMetadata
|
||||
};
|
||||
}
|
||||
|
||||
for (let i = 0; i < params.metadata.length; ++i) {
|
||||
let metadata: data.ObjectMetadata = params.metadata[i];
|
||||
|
||||
let metadataTypeName: string;
|
||||
if (metadata.metadataTypeName) {
|
||||
// Read from the provider since it's defined
|
||||
metadataTypeName = metadata.metadataTypeName;
|
||||
} else if (metadata.metadataType === types.MetadataType.View) {
|
||||
metadataTypeName = 'View';
|
||||
} else if (metadata.metadataType === types.MetadataType.SProc) {
|
||||
metadataTypeName = 'StoredProcedure';
|
||||
} else if (metadata.metadataType === types.MetadataType.Function) {
|
||||
metadataTypeName = 'Function';
|
||||
} else {
|
||||
metadataTypeName = 'Table';
|
||||
}
|
||||
|
||||
objectMetadata.push({
|
||||
metadataTypeName,
|
||||
metadataType: metadata.metadataType,
|
||||
name: metadata.name,
|
||||
schema: metadata.schema,
|
||||
urn: metadata.urn
|
||||
});
|
||||
}
|
||||
|
||||
return <data.ProviderMetadata>{
|
||||
objectMetadata
|
||||
};
|
||||
}
|
||||
|
||||
export const p2c: Ip2c = {
|
||||
asProviderMetadata
|
||||
};
|
||||
@@ -1,928 +0,0 @@
|
||||
import * as data from 'data';
|
||||
|
||||
export interface CreateSessionResponse {
|
||||
sessionId: string;
|
||||
}
|
||||
|
||||
export interface SessionCreatedParameters {
|
||||
success: boolean;
|
||||
sessionId: string;
|
||||
rootNode: NodeInfo;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
export interface ExpandResponse {
|
||||
nodePath: string;
|
||||
sessionId: string;
|
||||
nodes: NodeInfo[];
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
export interface NodeInfo {
|
||||
nodePath: string;
|
||||
nodeType: string;
|
||||
nodeSubType: string;
|
||||
nodeStatus: string;
|
||||
label: string;
|
||||
isLeaf: boolean;
|
||||
metadata: data.ObjectMetadata;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
export interface ExpandParams {
|
||||
sessionId: string;
|
||||
nodePath: string;
|
||||
}
|
||||
|
||||
export interface CloseSessionParams {
|
||||
sessionId: string;
|
||||
}
|
||||
|
||||
export interface CloseSessionResponse {
|
||||
success: boolean;
|
||||
sessionId: string;
|
||||
}
|
||||
|
||||
export interface CategoryValue {
|
||||
displayName: string;
|
||||
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ServiceOption {
|
||||
name: string;
|
||||
|
||||
displayName: string;
|
||||
|
||||
description: string;
|
||||
|
||||
groupName: string;
|
||||
|
||||
valueType: string;
|
||||
|
||||
defaultValue: string;
|
||||
|
||||
objectType: string;
|
||||
|
||||
categoryValues: CategoryValue[];
|
||||
|
||||
isRequired: boolean;
|
||||
|
||||
isArray: boolean;
|
||||
}
|
||||
|
||||
export interface ConnectionOption {
|
||||
name: string;
|
||||
|
||||
displayName: string;
|
||||
|
||||
description: string;
|
||||
|
||||
groupName: string;
|
||||
|
||||
valueType: string;
|
||||
|
||||
defaultValue: string;
|
||||
|
||||
objectType: string;
|
||||
|
||||
categoryValues: CategoryValue[];
|
||||
|
||||
specialValueType: string;
|
||||
|
||||
isIdentity: boolean;
|
||||
|
||||
isRequired: boolean;
|
||||
|
||||
isArray: boolean;
|
||||
}
|
||||
|
||||
export interface ConnectionProviderOptions {
|
||||
options: ConnectionOption[];
|
||||
}
|
||||
|
||||
export interface AdminServicesProviderOptions {
|
||||
databaseInfoOptions: ServiceOption[];
|
||||
|
||||
databaseFileInfoOptions: ServiceOption[];
|
||||
|
||||
fileGroupInfoOptions: ServiceOption[];
|
||||
}
|
||||
|
||||
export interface FeatureMetadataProvider {
|
||||
enabled: boolean;
|
||||
featureName: string;
|
||||
optionsMetadata: ServiceOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters to initialize a connection to a database
|
||||
*/
|
||||
export interface ConnectionDetails {
|
||||
|
||||
/**
|
||||
* connection options
|
||||
*/
|
||||
options: {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary that identifies a unique database connection.
|
||||
*/
|
||||
export class ConnectionSummary {
|
||||
/**
|
||||
* server name
|
||||
*/
|
||||
public serverName: string;
|
||||
|
||||
/**
|
||||
* database name
|
||||
*/
|
||||
public databaseName: string;
|
||||
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
public userName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection response format.
|
||||
*/
|
||||
export class ConnectionCompleteParams {
|
||||
/**
|
||||
* URI identifying the owner of the connection
|
||||
*/
|
||||
public ownerUri: string;
|
||||
|
||||
/**
|
||||
* connection id returned from service host.
|
||||
*/
|
||||
public connectionId: string;
|
||||
|
||||
/**
|
||||
* any diagnostic messages return from the service host.
|
||||
*/
|
||||
public messages: string;
|
||||
|
||||
/**
|
||||
* Error message returned from the engine, if any.
|
||||
*/
|
||||
public errorMessage: string;
|
||||
|
||||
/**
|
||||
* Error number returned from the engine, if any.
|
||||
*/
|
||||
public errorNumber: number;
|
||||
|
||||
/**
|
||||
* Information about the connected server.
|
||||
*/
|
||||
public serverInfo: ServerInfo;
|
||||
|
||||
/**
|
||||
* information about the actual connection established
|
||||
*/
|
||||
public connectionSummary: ConnectionSummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update event parameters
|
||||
*/
|
||||
export class IntelliSenseReadyParams {
|
||||
/**
|
||||
* URI identifying the text document
|
||||
*/
|
||||
public ownerUri: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about a SQL Server instance.
|
||||
*/
|
||||
export class ServerInfo {
|
||||
/**
|
||||
* The major version of the SQL Server instance.
|
||||
*/
|
||||
public serverMajorVersion: number;
|
||||
|
||||
/**
|
||||
* The minor version of the SQL Server instance.
|
||||
*/
|
||||
public serverMinorVersion: number;
|
||||
|
||||
/**
|
||||
* The build of the SQL Server instance.
|
||||
*/
|
||||
public serverReleaseVersion: number;
|
||||
|
||||
/**
|
||||
* The ID of the engine edition of the SQL Server instance.
|
||||
*/
|
||||
public engineEditionId: number;
|
||||
|
||||
/**
|
||||
* String containing the full server version text.
|
||||
*/
|
||||
public serverVersion: string;
|
||||
|
||||
/**
|
||||
* String describing the product level of the server.
|
||||
*/
|
||||
public serverLevel: string;
|
||||
|
||||
/**
|
||||
* The edition of the SQL Server instance.
|
||||
*/
|
||||
public serverEdition: string;
|
||||
|
||||
/**
|
||||
* Whether the SQL Server instance is running in the cloud (Azure) or not.
|
||||
*/
|
||||
public isCloud: boolean;
|
||||
|
||||
/**
|
||||
* The version of Azure that the SQL Server instance is running on, if applicable.
|
||||
*/
|
||||
public azureVersion: number;
|
||||
|
||||
/**
|
||||
* The Operating System version string of the machine running the SQL Server instance.
|
||||
*/
|
||||
public osVersion: string;
|
||||
}
|
||||
|
||||
export class CapabiltiesDiscoveryResult {
|
||||
public capabilities: data.DataProtocolServerCapabilities;
|
||||
}
|
||||
|
||||
// Task Services types
|
||||
|
||||
export enum TaskStatus {
|
||||
notStarted = 0,
|
||||
inProgress = 1,
|
||||
succeeded = 2,
|
||||
succeededWithWarning = 3,
|
||||
failed = 4,
|
||||
canceled = 5
|
||||
}
|
||||
|
||||
// Admin Services types
|
||||
|
||||
export interface CreateDatabaseParams {
|
||||
ownerUri: string;
|
||||
|
||||
databaseInfo: data.DatabaseInfo;
|
||||
}
|
||||
|
||||
export interface DefaultDatabaseInfoParams {
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
export interface DefaultDatabaseInfoResponse {
|
||||
defaultDatabaseInfo: data.DatabaseInfo;
|
||||
}
|
||||
|
||||
export interface GetDatabaseInfoResponse {
|
||||
databaseInfo: data.DatabaseInfo;
|
||||
}
|
||||
|
||||
export interface GetDatabaseInfoParams {
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
export interface BackupConfigInfoResponse {
|
||||
backupConfigInfo: data.BackupConfigInfo;
|
||||
}
|
||||
|
||||
export interface CreateLoginParams {
|
||||
ownerUri: string;
|
||||
|
||||
loginInfo: data.LoginInfo;
|
||||
}
|
||||
|
||||
// Disaster Recovery types
|
||||
|
||||
export interface BackupInfo {
|
||||
ownerUri: string;
|
||||
|
||||
databaseName: string;
|
||||
|
||||
backupType: number;
|
||||
|
||||
backupComponent: number;
|
||||
|
||||
backupDeviceType: number;
|
||||
|
||||
selectedFiles: string;
|
||||
|
||||
backupsetName: string;
|
||||
|
||||
selectedFileGroup: { [path: string]: string };
|
||||
|
||||
// List of {key: backup path, value: device type}
|
||||
backupPathDevices: { [path: string]: number };
|
||||
|
||||
backupPathList: [string];
|
||||
|
||||
isCopyOnly: boolean;
|
||||
|
||||
formatMedia: boolean;
|
||||
|
||||
initialize: boolean;
|
||||
|
||||
skipTapeHeader: boolean;
|
||||
|
||||
mediaName: string;
|
||||
|
||||
mediaDescription: string;
|
||||
|
||||
checksum: boolean;
|
||||
|
||||
continueAfterError: boolean;
|
||||
|
||||
logTruncation: boolean;
|
||||
|
||||
tailLogBackup: boolean;
|
||||
|
||||
retainDays: number;
|
||||
|
||||
compressionOption: number;
|
||||
|
||||
verifyBackupRequired: boolean;
|
||||
|
||||
encryptionAlgorithm: number;
|
||||
|
||||
encryptorType: number;
|
||||
|
||||
encryptorName: string;
|
||||
}
|
||||
|
||||
export interface BackupParams {
|
||||
ownerUri: string;
|
||||
|
||||
backupInfo: BackupInfo;
|
||||
|
||||
taskExecutionMode: data.TaskExecutionMode;
|
||||
}
|
||||
|
||||
export interface RestoreParams {
|
||||
ownerUri: string;
|
||||
options: {};
|
||||
taskExecutionMode: data.TaskExecutionMode;
|
||||
}
|
||||
|
||||
export interface RestoreConfigInfoRequestParams {
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
export interface RestoreConfigInfoResponse {
|
||||
configInfo: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface RestoreDatabaseFileInfo {
|
||||
fileType: string;
|
||||
|
||||
logicalFileName: string;
|
||||
|
||||
originalFileName: string;
|
||||
|
||||
restoreAsFileName: string;
|
||||
}
|
||||
|
||||
export interface FileBrowserOpenParams {
|
||||
ownerUri: string;
|
||||
expandPath: string;
|
||||
fileFilters: string[];
|
||||
changeFilter: boolean;
|
||||
}
|
||||
|
||||
export interface FileTreeNode {
|
||||
children: FileTreeNode[];
|
||||
isExpanded: boolean;
|
||||
isFile: boolean;
|
||||
name: string;
|
||||
fullPath: string;
|
||||
}
|
||||
|
||||
export interface FileTree {
|
||||
rootNode: FileTreeNode;
|
||||
selectedNode: FileTreeNode;
|
||||
}
|
||||
|
||||
export interface FileBrowserExpandParams {
|
||||
ownerUri: string;
|
||||
expandPath: string;
|
||||
}
|
||||
|
||||
export interface FileBrowserValidateParams {
|
||||
ownerUri: string;
|
||||
serviceType: string;
|
||||
selectedFiles: string[];
|
||||
}
|
||||
|
||||
export interface FileBrowserCloseParams {
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
export interface DatabaseFileInfo {
|
||||
properties: LocalizedPropertyInfo[];
|
||||
id: string;
|
||||
isSelected: boolean;
|
||||
}
|
||||
|
||||
export interface LocalizedPropertyInfo {
|
||||
propertyName: string;
|
||||
propertyValue: string;
|
||||
propertyDisplayName: string;
|
||||
propertyValueDisplayName: string;
|
||||
}
|
||||
|
||||
export interface RestorePlanDetailInfo {
|
||||
name: string;
|
||||
currentValue: any;
|
||||
isReadOnly: boolean;
|
||||
isVisible: boolean;
|
||||
defaultValue: any;
|
||||
|
||||
}
|
||||
|
||||
// Query Execution types
|
||||
export interface ResultSetSummary {
|
||||
id: number;
|
||||
batchId: number;
|
||||
rowCount: number;
|
||||
columnInfo: IDbColumn[];
|
||||
}
|
||||
|
||||
export interface BatchSummary {
|
||||
hasError: boolean;
|
||||
id: number;
|
||||
selection: data.ISelectionData;
|
||||
resultSetSummaries: ResultSetSummary[];
|
||||
executionElapsed: string;
|
||||
executionEnd: string;
|
||||
executionStart: string;
|
||||
}
|
||||
|
||||
export interface IDbColumn {
|
||||
allowDBNull?: boolean;
|
||||
baseCatalogName: string;
|
||||
baseColumnName: string;
|
||||
baseSchemaName: string;
|
||||
baseServerName: string;
|
||||
baseTableName: string;
|
||||
columnName: string;
|
||||
columnOrdinal?: number;
|
||||
columnSize?: number;
|
||||
isAliased?: boolean;
|
||||
isAutoIncrement?: boolean;
|
||||
isExpression?: boolean;
|
||||
isHidden?: boolean;
|
||||
isIdentity?: boolean;
|
||||
isKey?: boolean;
|
||||
isBytes?: boolean;
|
||||
isChars?: boolean;
|
||||
isSqlVariant?: boolean;
|
||||
isUdt?: boolean;
|
||||
dataType: string;
|
||||
isXml?: boolean;
|
||||
isJson?: boolean;
|
||||
isLong?: boolean;
|
||||
isReadOnly?: boolean;
|
||||
isUnique?: boolean;
|
||||
numericPrecision?: number;
|
||||
numericScale?: number;
|
||||
udtAssemblyQualifiedName: string;
|
||||
dataTypeName: string;
|
||||
}
|
||||
|
||||
export interface IGridResultSet {
|
||||
columns: IDbColumn[];
|
||||
rowsUri: string;
|
||||
numberOfRows: number;
|
||||
}
|
||||
|
||||
export interface IResultMessage {
|
||||
batchId?: number;
|
||||
isError: boolean;
|
||||
time: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export enum EditRowState {
|
||||
clean = 0,
|
||||
dirtyInsert = 1,
|
||||
dirtyDelete = 2,
|
||||
dirtyUpdate = 3
|
||||
}
|
||||
|
||||
export interface EditRow {
|
||||
cells: data.DbCellValue[];
|
||||
id: number;
|
||||
isDirty: boolean;
|
||||
state: EditRowState;
|
||||
}
|
||||
|
||||
export class MetadataQueryParams {
|
||||
/**
|
||||
* Owner URI of the connection that changed.
|
||||
*/
|
||||
public ownerUri: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used as value version of data.MetadataType THESE SHOULD MIRROR
|
||||
*/
|
||||
export enum MetadataType {
|
||||
Table = 0,
|
||||
View = 1,
|
||||
SProc = 2,
|
||||
Function = 3
|
||||
}
|
||||
|
||||
export class MetadataQueryResult {
|
||||
public metadata: data.ObjectMetadata[];
|
||||
}
|
||||
|
||||
export interface ScriptOptions {
|
||||
/**
|
||||
* Generate ANSI padding statements
|
||||
*/
|
||||
scriptANSIPadding?: boolean;
|
||||
|
||||
/**
|
||||
* Append the generated script to a file
|
||||
*/
|
||||
appendToFile?: boolean;
|
||||
|
||||
/**
|
||||
* Continue to script if an error occurs. Otherwise, stop.
|
||||
*/
|
||||
continueScriptingOnError?: boolean;
|
||||
|
||||
/**
|
||||
* Convert user-defined data types to base types.
|
||||
*/
|
||||
convertUDDTToBaseType?: boolean;
|
||||
|
||||
/**
|
||||
* Generate script for dependent objects for each object scripted.
|
||||
*/
|
||||
generateScriptForDependentObjects?: boolean;
|
||||
|
||||
/**
|
||||
* Include descriptive headers for each object generated.
|
||||
*/
|
||||
includeDescriptiveHeaders?: boolean;
|
||||
|
||||
/**
|
||||
* Check that an object with the given name exists before dropping or altering or that an object with the given name does not exist before creating.
|
||||
*/
|
||||
includeIfNotExists?: boolean;
|
||||
|
||||
/**
|
||||
* Script options to set vardecimal storage format.
|
||||
*/
|
||||
includeVarDecimal?: boolean;
|
||||
|
||||
/**
|
||||
* Include system generated constraint names to enforce declarative referential integrity.
|
||||
*/
|
||||
scriptDRIIncludeSystemNames?: boolean;
|
||||
|
||||
/**
|
||||
* Include statements in the script that are not supported on the specified SQL Server database engine type.
|
||||
*/
|
||||
includeUnsupportedStatements?: boolean;
|
||||
|
||||
/**
|
||||
* Prefix object names with the object schema.
|
||||
*/
|
||||
schemaQualify?: boolean;
|
||||
|
||||
/**
|
||||
* Script options to set bindings option.
|
||||
*/
|
||||
bindings?: boolean;
|
||||
|
||||
/**
|
||||
* Script the objects that use collation.
|
||||
*/
|
||||
collation?: boolean;
|
||||
|
||||
/**
|
||||
* Script the default values.
|
||||
*/
|
||||
default?: boolean;
|
||||
|
||||
/**
|
||||
* Script Object CREATE/DROP statements.
|
||||
*/
|
||||
scriptCreateDrop: string;
|
||||
|
||||
/**
|
||||
* Script the Extended Properties for each object scripted.
|
||||
*/
|
||||
scriptExtendedProperties?: boolean;
|
||||
|
||||
/**
|
||||
* Script only features compatible with the specified version of SQL Server.
|
||||
*/
|
||||
scriptCompatibilityOption: string;
|
||||
|
||||
/**
|
||||
* Script only features compatible with the specified SQL Server database engine type.
|
||||
*/
|
||||
targetDatabaseEngineType: string;
|
||||
|
||||
/**
|
||||
* Script only features compatible with the specified SQL Server database engine edition.
|
||||
*/
|
||||
targetDatabaseEngineEdition: string;
|
||||
|
||||
/**
|
||||
* Script all logins available on the server. Passwords will not be scripted.
|
||||
*/
|
||||
scriptLogins?: boolean;
|
||||
|
||||
/**
|
||||
* Generate object-level permissions.
|
||||
*/
|
||||
scriptObjectLevelPermissions?: boolean;
|
||||
|
||||
/**
|
||||
* Script owner for the objects.
|
||||
*/
|
||||
scriptOwner?: boolean;
|
||||
|
||||
/**
|
||||
* Script statistics, and optionally include histograms, for each selected table or view.
|
||||
*/
|
||||
scriptStatistics: string;
|
||||
|
||||
/**
|
||||
* Generate USE DATABASE statement.
|
||||
*/
|
||||
scripUseDatabase?: boolean;
|
||||
|
||||
/**
|
||||
* Generate script that contains schema only or schema and data.
|
||||
*/
|
||||
typeOfDataToScript: string;
|
||||
|
||||
/**
|
||||
* Scripts the change tracking information.
|
||||
*/
|
||||
scriptChangeTracking?: boolean;
|
||||
|
||||
/**
|
||||
* Script the check constraints for each table or view scripted.
|
||||
*/
|
||||
scriptCheckConstraints?: boolean;
|
||||
|
||||
/**
|
||||
* Scripts the data compression information.
|
||||
*/
|
||||
scriptDataCompressionOptions?: boolean;
|
||||
|
||||
/**
|
||||
* Script the foreign keys for each table scripted.
|
||||
*/
|
||||
scriptForeignKeys?: boolean;
|
||||
|
||||
/**
|
||||
* Script the full-text indexes for each table or indexed view scripted.
|
||||
*/
|
||||
scriptFullTextIndexes?: boolean;
|
||||
|
||||
/**
|
||||
* Script the indexes (including XML and clustered indexes) for each table or indexed view scripted.
|
||||
*/
|
||||
scriptIndexes?: boolean;
|
||||
|
||||
/**
|
||||
* Script the primary keys for each table or view scripted
|
||||
*/
|
||||
scriptPrimaryKeys?: boolean;
|
||||
|
||||
/**
|
||||
* Script the triggers for each table or view scripted
|
||||
*/
|
||||
scriptTriggers?: boolean;
|
||||
|
||||
/**
|
||||
* Script the unique keys for each table or view scripted.
|
||||
*/
|
||||
uniqueKeys?: boolean;
|
||||
}
|
||||
|
||||
export interface ScriptingObject {
|
||||
/**
|
||||
* The database object type
|
||||
*/
|
||||
type: string;
|
||||
|
||||
/**
|
||||
* The schema of the database object
|
||||
*/
|
||||
schema: string;
|
||||
|
||||
/**
|
||||
* The database object name
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ScriptingParams {
|
||||
/**
|
||||
* File path used when writing out the script.
|
||||
*/
|
||||
filePath: string;
|
||||
|
||||
/**
|
||||
* Whether scripting to a single file or file per object.
|
||||
*/
|
||||
scriptDestination: string;
|
||||
|
||||
/**
|
||||
* Connection string of the target database the scripting operation will run against.
|
||||
*/
|
||||
connectionString: string;
|
||||
|
||||
/**
|
||||
* A list of scripting objects to script
|
||||
*/
|
||||
scriptingObjects: ScriptingObject[];
|
||||
|
||||
/**
|
||||
* A list of scripting object which specify the include criteria of objects to script.
|
||||
*/
|
||||
includeObjectCriteria: ScriptingObject[];
|
||||
|
||||
/**
|
||||
* A list of scripting object which specify the exclude criteria of objects to not script.
|
||||
*/
|
||||
excludeObjectCriteria: ScriptingObject[];
|
||||
|
||||
/**
|
||||
* A list of schema name of objects to script.
|
||||
*/
|
||||
includeSchemas: string[];
|
||||
|
||||
/**
|
||||
* A list of schema name of objects to not script.
|
||||
*/
|
||||
excludeSchemas: string[];
|
||||
|
||||
/**
|
||||
* A list of type name of objects to script.
|
||||
*/
|
||||
includeTypes: string[];
|
||||
|
||||
/**
|
||||
* A list of type name of objects to not script.
|
||||
*/
|
||||
excludeTypes: string[];
|
||||
|
||||
/**
|
||||
* Scripting options for the ScriptingParams
|
||||
*/
|
||||
scriptOptions: ScriptOptions;
|
||||
|
||||
/**
|
||||
* Connection details for the ScriptingParams
|
||||
*/
|
||||
connectionDetails: ConnectionDetails;
|
||||
|
||||
/**
|
||||
* Owner URI of the connection
|
||||
*/
|
||||
ownerURI: string;
|
||||
|
||||
/**
|
||||
* Whether the scripting operation is for
|
||||
* select script statements
|
||||
*/
|
||||
selectScript: boolean;
|
||||
|
||||
/**
|
||||
* Operation associated with the script request
|
||||
*/
|
||||
operation: data.ScriptOperation;
|
||||
}
|
||||
|
||||
export interface ScriptingCompleteParams {
|
||||
/**
|
||||
* The error details for an error that occurred during the scripting operation.
|
||||
*/
|
||||
errorDetails: string;
|
||||
|
||||
/**
|
||||
* The error message for an error that occurred during the scripting operation.
|
||||
*/
|
||||
errorMessage: string;
|
||||
|
||||
/**
|
||||
* A value to indicate an error occurred during the scripting operation.
|
||||
*/
|
||||
hasError: boolean;
|
||||
|
||||
/**
|
||||
* A value to indicate the scripting operation was canceled.
|
||||
*/
|
||||
canceled: boolean;
|
||||
|
||||
/**
|
||||
* A value to indicate the scripting operation successfully completed.
|
||||
*/
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export class TableMetadata {
|
||||
|
||||
columns: data.ColumnMetadata[];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters to start a profiler session
|
||||
*/
|
||||
export interface StartProfilingParams {
|
||||
/**
|
||||
* Session Owner URI
|
||||
*/
|
||||
ownerUri: string;
|
||||
|
||||
/**
|
||||
* Session options
|
||||
*/
|
||||
options: {};
|
||||
}
|
||||
|
||||
export interface StartProfilingResponse {
|
||||
succeeded: string;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters to start a profiler session
|
||||
*/
|
||||
export interface StopProfilingParams {
|
||||
/**
|
||||
* Session Owner URI
|
||||
*/
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
export interface StopProfilingResponse {
|
||||
succeeded: string;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profiler Event
|
||||
*/
|
||||
export interface ProfilerEvent {
|
||||
/**
|
||||
* Event class name
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Event timestamp
|
||||
*/
|
||||
timestamp: string;
|
||||
|
||||
/**
|
||||
* Event values
|
||||
*/
|
||||
values: {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Profiler events available notification parameters
|
||||
*/
|
||||
export interface ProfilerEventsAvailableParams {
|
||||
/**
|
||||
* Session owner URI
|
||||
*/
|
||||
ownerUri: string;
|
||||
|
||||
/**
|
||||
* New profiler events available
|
||||
*/
|
||||
events: ProfilerEvent[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Used as value version of data.ScriptOperation THESE SHOULD BE THE SAME
|
||||
*/
|
||||
export enum ScriptOperation {
|
||||
Select = 0,
|
||||
Create = 1,
|
||||
Insert = 2,
|
||||
Update = 3,
|
||||
Delete = 4,
|
||||
Execute = 5,
|
||||
Alter = 6
|
||||
}
|
||||
2
dataprotocol-client/src/typings/ref.d.ts
vendored
2
dataprotocol-client/src/typings/ref.d.ts
vendored
@@ -1,2 +0,0 @@
|
||||
|
||||
/// <reference path='../../../src/sql/data.d.ts'/>
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"tabSize": 4,
|
||||
"indentSize": 4,
|
||||
"newLineCharacter": "\n",
|
||||
"convertTabsToSpaces": false,
|
||||
"insertSpaceAfterCommaDelimiter": true,
|
||||
"insertSpaceAfterSemicolonInForStatements": true,
|
||||
"insertSpaceBeforeAndAfterBinaryOperators": true,
|
||||
"insertSpaceAfterKeywordsInControlFlowStatements": true,
|
||||
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
|
||||
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
|
||||
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
|
||||
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
|
||||
"insertSpaceBeforeFunctionParenthesis": false,
|
||||
"placeOpenBraceOnNewLineForFunctions": false,
|
||||
"placeOpenBraceOnNewLineForControlBlocks": false
|
||||
}
|
||||
29
dataprotocol-node/.gitignore
vendored
Normal file
29
dataprotocol-node/.gitignore
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
lib/
|
||||
out/
|
||||
|
||||
# Dependency directory
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
|
||||
node_modules
|
||||
|
||||
# Debug log from npm
|
||||
npm-debug.log
|
||||
18
dataprotocol-node/License.txt
Normal file
18
dataprotocol-node/License.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Source EULA
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
4
dataprotocol-node/README.md
Normal file
4
dataprotocol-node/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Microsoft Data Management Protocol - Node
|
||||
|
||||
## License
|
||||
[MIT](https://github.com/Microsoft/carbon/blob/dev/license.txt)
|
||||
24
dataprotocol-node/client/.eslintrc
Normal file
24
dataprotocol-node/client/.eslintrc
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"rules": {
|
||||
"indent": [
|
||||
2,
|
||||
"tab"
|
||||
],
|
||||
"quotes": [
|
||||
2,
|
||||
"single"
|
||||
],
|
||||
"linebreak-style": [
|
||||
2,
|
||||
"windows"
|
||||
],
|
||||
"semi": [
|
||||
2,
|
||||
"always"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
||||
9
dataprotocol-node/client/.npmignore
Normal file
9
dataprotocol-node/client/.npmignore
Normal file
@@ -0,0 +1,9 @@
|
||||
.vscode/
|
||||
lib/test/
|
||||
lib/*.map
|
||||
src/
|
||||
test/
|
||||
.eslintrc
|
||||
.gitignore
|
||||
gulpfile.js
|
||||
tsd.json
|
||||
32
dataprotocol-node/client/.vscode/launch.json
vendored
Normal file
32
dataprotocol-node/client/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
// List of configurations. Add new configurations or edit existing ones.
|
||||
// ONLY "node" and "mono" are supported, change "type" to switch.
|
||||
"configurations": [
|
||||
{
|
||||
"request": "launch",
|
||||
// Name of configuration; appears in the launch configuration drop down menu.
|
||||
"name": "Mocha",
|
||||
// Type of configuration. Possible values: "node", "mono".
|
||||
"type": "node",
|
||||
// Workspace relative or absolute path to the program.
|
||||
"program": "node_modules/mocha/bin/_mocha",
|
||||
// Automatically stop program after launch.
|
||||
"stopOnEntry": false,
|
||||
// Command line arguments passed to the program.
|
||||
"args": ["--timeout", "999999"],
|
||||
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
|
||||
"cwd": ".",
|
||||
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
|
||||
"runtimeExecutable": null,
|
||||
// Optional arguments passed to the runtime executable.
|
||||
"runtimeArgs": [],
|
||||
// Environment variables passed to the program.
|
||||
"env": { },
|
||||
// Use JavaScript source maps (if they exist).
|
||||
"sourceMaps": true,
|
||||
// If JavaScript source maps are enabled, the generated code is expected in this directory.
|
||||
"outDir": "lib"
|
||||
}
|
||||
]
|
||||
}
|
||||
11
dataprotocol-node/client/.vscode/settings.json
vendored
Normal file
11
dataprotocol-node/client/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"javascript.validate.enable": false,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"eslint.enable": false,
|
||||
"editor.insertSpaces": false,
|
||||
"editor.tabSize": 4,
|
||||
"tslint.enable": false,
|
||||
"typescript.tsdk": "./node_modules/typescript/lib",
|
||||
"typescript.tsserver.trace": "off"
|
||||
}
|
||||
9
dataprotocol-node/client/.vscode/tasks.json
vendored
Normal file
9
dataprotocol-node/client/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "npm",
|
||||
"isShellCommand": true,
|
||||
"args": ["run", "watch"],
|
||||
"showOutput": "silent",
|
||||
"isWatching": true,
|
||||
"problemMatcher": "$tsc-watch"
|
||||
}
|
||||
4
dataprotocol-node/client/README.md
Normal file
4
dataprotocol-node/client/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Microsoft Data Management Protocol - Node
|
||||
|
||||
## License
|
||||
[MIT](https://github.com/Microsoft/carbon/blob/dev/license.txt)
|
||||
32
dataprotocol-node/client/package.json
Normal file
32
dataprotocol-node/client/package.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "dataprotocol-client",
|
||||
"description": "VSCode Language client implementation",
|
||||
"version": "2.6.3",
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"vscode": "^1.5.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/vscode-languageserver-node.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
|
||||
},
|
||||
"main": "./lib/main.js",
|
||||
"typings": "./lib/main",
|
||||
"devDependencies": {
|
||||
"typescript": "2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"dataprotocol-jsonrpc": "file:../jsonrpc",
|
||||
"dataprotocol-languageserver-types": "file:../types"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "tsc -p ./src",
|
||||
"compile": "tsc -p ./src",
|
||||
"watch": "tsc -w -p ./src",
|
||||
"update-vscode": "node ./node_modules/vscode/bin/install"
|
||||
}
|
||||
}
|
||||
526
dataprotocol-node/client/src/codeConverter.ts
Normal file
526
dataprotocol-node/client/src/codeConverter.ts
Normal file
@@ -0,0 +1,526 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 code from 'vscode';
|
||||
import * as data from 'data';
|
||||
import * as ls from 'dataprotocol-languageserver-types';
|
||||
import * as proto from './protocol';
|
||||
import * as is from './utils/is';
|
||||
import ProtocolCompletionItem from './protocolCompletionItem';
|
||||
import ProtocolCodeLens from './protocolCodeLens';
|
||||
import os = require('os');
|
||||
import path = require('path');
|
||||
|
||||
export interface Converter {
|
||||
|
||||
asUri(uri: code.Uri): string;
|
||||
|
||||
asTextDocumentIdentifier(textDocument: code.TextDocument): ls.TextDocumentIdentifier;
|
||||
|
||||
asOpenTextDocumentParams(textDocument: code.TextDocument): proto.DidOpenTextDocumentParams;
|
||||
|
||||
asChangeTextDocumentParams(textDocument: code.TextDocument): proto.DidChangeTextDocumentParams;
|
||||
asChangeTextDocumentParams(event: code.TextDocumentChangeEvent): proto.DidChangeTextDocumentParams;
|
||||
|
||||
asCloseTextDocumentParams(textDocument: code.TextDocument): proto.DidCloseTextDocumentParams;
|
||||
|
||||
asSaveTextDocumentParams(textDocument: code.TextDocument): proto.DidSaveTextDocumentParams;
|
||||
|
||||
asTextDocumentPositionParams(textDocument: code.TextDocument, position: code.Position): proto.TextDocumentPositionParams;
|
||||
|
||||
asWorkerPosition(position: code.Position): ls.Position;
|
||||
|
||||
asRange(value: code.Range): ls.Range;
|
||||
|
||||
asPosition(value: code.Position): ls.Position;
|
||||
|
||||
asDiagnosticSeverity(value: code.DiagnosticSeverity): ls.DiagnosticSeverity;
|
||||
|
||||
asDiagnostic(item: code.Diagnostic): ls.Diagnostic;
|
||||
asDiagnostics(items: code.Diagnostic[]): ls.Diagnostic[];
|
||||
|
||||
asCompletionItem(item: code.CompletionItem): ls.CompletionItem;
|
||||
|
||||
asTextEdit(edit: code.TextEdit): ls.TextEdit;
|
||||
|
||||
asReferenceParams(textDocument: code.TextDocument, position: code.Position, options: { includeDeclaration: boolean; }): proto.ReferenceParams;
|
||||
|
||||
asCodeActionContext(context: code.CodeActionContext): ls.CodeActionContext;
|
||||
|
||||
asCommand(item: code.Command): ls.Command;
|
||||
|
||||
asCodeLens(item: code.CodeLens): ls.CodeLens;
|
||||
|
||||
asFormattingOptions(item: code.FormattingOptions): ls.FormattingOptions;
|
||||
|
||||
asDocumentSymbolParams(textDocument: code.TextDocument): proto.DocumentSymbolParams;
|
||||
|
||||
asCodeLensParams(textDocument: code.TextDocument): proto.CodeLensParams;
|
||||
|
||||
asDocumentLink(item: code.DocumentLink): ls.DocumentLink;
|
||||
|
||||
asDocumentLinkParams(textDocument: code.TextDocument): proto.DocumentLinkParams;
|
||||
|
||||
asConnectionParams(connectionUri: string, connectionInfo: data.ConnectionInfo): proto.ConnectParams;
|
||||
|
||||
asCapabilitiesParams(client: data.DataProtocolClientCapabilities): proto.CapabiltiesDiscoveryParams;
|
||||
|
||||
asMetadataQueryParams(connectionUri: string): ls.MetadataQueryParams;
|
||||
|
||||
asListDatabasesParams(connectionUri: string): proto.ListDatabasesParams;
|
||||
|
||||
asTableMetadataParams(connectionUri: string, metadata: data.ObjectMetadata): proto.TableMetadataParams;
|
||||
|
||||
asScriptingParams(connectionUri: string, operation: ls.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): ls.ScriptingParams;
|
||||
|
||||
asConnectionDetail(connInfo: data.ConnectionInfo): ls.ConnectionDetails;
|
||||
|
||||
asExpandInfo(nodeInfo: data.ExpandNodeInfo): ls.ExpandParams;
|
||||
|
||||
asCloseSessionInfo(nodeInfo: data.ObjectExplorerCloseSessionInfo): ls.CloseSessionParams;
|
||||
|
||||
asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): proto.ExecutionPlanOptions;
|
||||
|
||||
asListTasksParams(params: data.ListTasksParams): ls.ListTasksParams;
|
||||
|
||||
asCancelTaskParams(params: data.CancelTaskParams): ls.CancelTaskParams;
|
||||
|
||||
asRestoreParams(ownerUri: string, params: data.RestoreInfo): ls.RestoreParams;
|
||||
|
||||
asRestoreConfigInfoParams(ownerUri: string): ls.RestoreConfigInfoRequestParams;
|
||||
}
|
||||
|
||||
export interface URIConverter {
|
||||
(value: code.Uri): string;
|
||||
}
|
||||
|
||||
export function createConverter(uriConverter?: URIConverter): Converter {
|
||||
|
||||
const nullConverter = (value: code.Uri) => value.toString();
|
||||
|
||||
const _uriConverter: URIConverter = uriConverter || nullConverter;
|
||||
|
||||
function asUri(value: code.Uri): string {
|
||||
return _uriConverter(value);
|
||||
}
|
||||
|
||||
function asTextDocumentIdentifier(textDocument: code.TextDocument): ls.TextDocumentIdentifier {
|
||||
return {
|
||||
uri: _uriConverter(textDocument.uri)
|
||||
};
|
||||
}
|
||||
|
||||
function asOpenTextDocumentParams(textDocument: code.TextDocument): proto.DidOpenTextDocumentParams {
|
||||
return {
|
||||
textDocument: {
|
||||
uri: _uriConverter(textDocument.uri),
|
||||
languageId: textDocument.languageId,
|
||||
version: textDocument.version,
|
||||
text: textDocument.getText()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function isTextDocumentChangeEvent(value: any): value is code.TextDocumentChangeEvent {
|
||||
let candidate = <code.TextDocumentChangeEvent>value;
|
||||
return is.defined(candidate.document) && is.defined(candidate.contentChanges);
|
||||
}
|
||||
|
||||
function isTextDocument(value: any): value is code.TextDocument {
|
||||
let candidate = <code.TextDocument>value;
|
||||
return is.defined(candidate.uri) && is.defined(candidate.version);
|
||||
}
|
||||
|
||||
function asChangeTextDocumentParams(textDocument: code.TextDocument): proto.DidChangeTextDocumentParams;
|
||||
function asChangeTextDocumentParams(event: code.TextDocumentChangeEvent): proto.DidChangeTextDocumentParams;
|
||||
function asChangeTextDocumentParams(arg: code.TextDocumentChangeEvent | code.TextDocument): proto.DidChangeTextDocumentParams {
|
||||
if (isTextDocument(arg)) {
|
||||
let result: proto.DidChangeTextDocumentParams = {
|
||||
textDocument: {
|
||||
uri: _uriConverter(arg.uri),
|
||||
version: arg.version
|
||||
},
|
||||
contentChanges: [{ text: arg.getText() }]
|
||||
}
|
||||
return result;
|
||||
} else if (isTextDocumentChangeEvent(arg)) {
|
||||
let document = arg.document;
|
||||
let result: proto.DidChangeTextDocumentParams = {
|
||||
textDocument: {
|
||||
uri: _uriConverter(document.uri),
|
||||
version: document.version
|
||||
},
|
||||
contentChanges: arg.contentChanges.map((change): proto.TextDocumentContentChangeEvent => {
|
||||
let range = change.range;
|
||||
return {
|
||||
range: {
|
||||
start: { line: range.start.line, character: range.start.character },
|
||||
end: { line: range.end.line, character: range.end.character }
|
||||
},
|
||||
rangeLength: change.rangeLength,
|
||||
text: change.text
|
||||
}
|
||||
})
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
throw Error('Unsupported text document change parameter');
|
||||
}
|
||||
}
|
||||
|
||||
function asCloseTextDocumentParams(textDocument: code.TextDocument): proto.DidCloseTextDocumentParams {
|
||||
return {
|
||||
textDocument: asTextDocumentIdentifier(textDocument)
|
||||
};
|
||||
}
|
||||
|
||||
function asSaveTextDocumentParams(textDocument: code.TextDocument): proto.DidSaveTextDocumentParams {
|
||||
return {
|
||||
textDocument: asTextDocumentIdentifier(textDocument)
|
||||
}
|
||||
}
|
||||
|
||||
function asTextDocumentPositionParams(textDocument: code.TextDocument, position: code.Position): proto.TextDocumentPositionParams {
|
||||
return {
|
||||
textDocument: asTextDocumentIdentifier(textDocument),
|
||||
position: asWorkerPosition(position)
|
||||
};
|
||||
}
|
||||
|
||||
function asWorkerPosition(position: code.Position): ls.Position {
|
||||
return { line: position.line, character: position.character };
|
||||
}
|
||||
|
||||
function asRange(value: code.Range): ls.Range {
|
||||
if (is.undefined(value)) {
|
||||
return undefined;
|
||||
} else if (is.nil(value)) {
|
||||
return null;
|
||||
}
|
||||
return { start: asPosition(value.start), end: asPosition(value.end) };
|
||||
}
|
||||
|
||||
function asPosition(value: code.Position): ls.Position {
|
||||
if (is.undefined(value)) {
|
||||
return undefined;
|
||||
} else if (is.nil(value)) {
|
||||
return null;
|
||||
}
|
||||
return { line: value.line, character: value.character };
|
||||
}
|
||||
|
||||
function set(value, func: () => void): void {
|
||||
if (is.defined(value)) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
function asDiagnosticSeverity(value: code.DiagnosticSeverity): ls.DiagnosticSeverity {
|
||||
switch (value) {
|
||||
case code.DiagnosticSeverity.Error:
|
||||
return ls.DiagnosticSeverity.Error;
|
||||
case code.DiagnosticSeverity.Warning:
|
||||
return ls.DiagnosticSeverity.Warning;
|
||||
case code.DiagnosticSeverity.Information:
|
||||
return ls.DiagnosticSeverity.Information;
|
||||
case code.DiagnosticSeverity.Hint:
|
||||
return ls.DiagnosticSeverity.Hint;
|
||||
}
|
||||
}
|
||||
|
||||
function asDiagnostic(item: code.Diagnostic): ls.Diagnostic {
|
||||
let result: ls.Diagnostic = ls.Diagnostic.create(asRange(item.range), item.message);
|
||||
set(item.severity, () => result.severity = asDiagnosticSeverity(item.severity));
|
||||
set(item.code, () => result.code = item.code);
|
||||
set(item.source, () => result.source = item.source);
|
||||
return result;
|
||||
}
|
||||
|
||||
function asDiagnostics(items: code.Diagnostic[]): ls.Diagnostic[] {
|
||||
if (is.undefined(items) || is.nil(items)) {
|
||||
return items;
|
||||
}
|
||||
return items.map(asDiagnostic);
|
||||
}
|
||||
|
||||
function asCompletionItem(item: code.CompletionItem): ls.CompletionItem {
|
||||
let result: ls.CompletionItem = { label: item.label };
|
||||
set(item.detail, () => result.detail = item.detail);
|
||||
set(item.documentation, () => result.documentation = item.documentation);
|
||||
set(item.filterText, () => result.filterText = item.filterText);
|
||||
set(item.insertText, () => result.insertText = String(item.insertText));
|
||||
// Protocol item kind is 1 based, codes item kind is zero based.
|
||||
set(item.kind, () => result.kind = item.kind + 1);
|
||||
set(item.sortText, () => result.sortText = item.sortText);
|
||||
set(item.textEdit, () => result.textEdit = asTextEdit(item.textEdit));
|
||||
set(item.additionalTextEdits, () => result.additionalTextEdits = asTextEdits(item.additionalTextEdits));
|
||||
set(item.command, () => result.command = asCommand(item.command));
|
||||
if (item instanceof ProtocolCompletionItem) {
|
||||
set(item.data, () => result.data = item.data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function asTextEdit(edit: code.TextEdit): ls.TextEdit {
|
||||
return { range: asRange(edit.range), newText: edit.newText };
|
||||
}
|
||||
|
||||
function asTextEdits(edits: code.TextEdit[]): ls.TextEdit[] {
|
||||
if (is.undefined(edits) || is.nil(edits)) {
|
||||
return edits;
|
||||
}
|
||||
return edits.map(asTextEdit);
|
||||
}
|
||||
|
||||
function asReferenceParams(textDocument: code.TextDocument, position: code.Position, options: { includeDeclaration: boolean; }): proto.ReferenceParams {
|
||||
return {
|
||||
textDocument: asTextDocumentIdentifier(textDocument),
|
||||
position: asWorkerPosition(position),
|
||||
context: { includeDeclaration: options.includeDeclaration }
|
||||
};
|
||||
}
|
||||
|
||||
function asCodeActionContext(context: code.CodeActionContext): ls.CodeActionContext {
|
||||
if (is.undefined(context) || is.nil(context)) {
|
||||
return context;
|
||||
}
|
||||
return ls.CodeActionContext.create(asDiagnostics(context.diagnostics));
|
||||
}
|
||||
|
||||
function asCommand(item: code.Command): ls.Command {
|
||||
let result = ls.Command.create(item.title, item.command);
|
||||
if (is.defined(item.arguments)) result.arguments = item.arguments;
|
||||
return result;
|
||||
}
|
||||
|
||||
function asCodeLens(item: code.CodeLens): ls.CodeLens {
|
||||
let result = ls.CodeLens.create(asRange(item.range));
|
||||
if (is.defined(item.command)) result.command = asCommand(item.command);
|
||||
if (item instanceof ProtocolCodeLens) {
|
||||
if (is.defined(item.data)) result.data = item.data;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function asFormattingOptions(item: code.FormattingOptions): ls.FormattingOptions {
|
||||
return { tabSize: item.tabSize, insertSpaces: item.insertSpaces };
|
||||
}
|
||||
|
||||
function asDocumentSymbolParams(textDocument: code.TextDocument): proto.DocumentSymbolParams {
|
||||
return {
|
||||
textDocument: asTextDocumentIdentifier(textDocument)
|
||||
}
|
||||
}
|
||||
|
||||
function asCodeLensParams(textDocument: code.TextDocument): proto.CodeLensParams {
|
||||
return {
|
||||
textDocument: asTextDocumentIdentifier(textDocument)
|
||||
};
|
||||
}
|
||||
|
||||
function asDocumentLink(item: code.DocumentLink): ls.DocumentLink {
|
||||
let result = ls.DocumentLink.create(asRange(item.range));
|
||||
if (is.defined(item.target)) result.target = asUri(item.target);
|
||||
return result;
|
||||
}
|
||||
|
||||
function asDocumentLinkParams(textDocument: code.TextDocument): proto.DocumentLinkParams {
|
||||
return {
|
||||
textDocument: asTextDocumentIdentifier(textDocument)
|
||||
};
|
||||
}
|
||||
|
||||
function asCapabilitiesParams(client: data.DataProtocolClientCapabilities): proto.CapabiltiesDiscoveryParams {
|
||||
let params: proto.CapabiltiesDiscoveryParams = {
|
||||
hostName: client.hostName,
|
||||
hostVersion: client.hostVersion
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
function asConnectionParams(connUri: string, connInfo: data.ConnectionInfo): proto.ConnectParams {
|
||||
return {
|
||||
ownerUri: connUri,
|
||||
connection: {
|
||||
options: connInfo.options
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function asMetadataQueryParams(connectionUri: string): ls.MetadataQueryParams {
|
||||
return <ls.MetadataQueryParams>{
|
||||
ownerUri: connectionUri
|
||||
};
|
||||
}
|
||||
|
||||
function asListDatabasesParams(connectionUri: string): proto.ListDatabasesParams {
|
||||
return <proto.ListDatabasesParams>{
|
||||
ownerUri: connectionUri
|
||||
};
|
||||
}
|
||||
|
||||
function asTableMetadataParams(connectionUri: string, metadata: data.ObjectMetadata): proto.TableMetadataParams {
|
||||
return <proto.TableMetadataParams>{
|
||||
ownerUri: connectionUri,
|
||||
schema: metadata.schema,
|
||||
objectName: metadata.name
|
||||
};
|
||||
}
|
||||
|
||||
function asScriptingParams(connectionUri: string, operation: ls.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): ls.ScriptingParams {
|
||||
let scriptingObject: ls.ScriptingObject = {
|
||||
type: metadata.metadataTypeName,
|
||||
schema: metadata.schema,
|
||||
name: metadata.name
|
||||
}
|
||||
let targetDatabaseEngineEdition = paramDetails.targetDatabaseEngineEdition;
|
||||
let targetDatabaseEngineType = paramDetails.targetDatabaseEngineType;
|
||||
let scriptCompatibilityOption = paramDetails.scriptCompatibilityOption;
|
||||
let options: ls.ScriptOptions = {
|
||||
scriptCreateDrop: (operation === ls.ScriptOperation.Delete) ? "ScriptDrop" :
|
||||
(operation === ls.ScriptOperation.Select) ? "ScriptSelect" : "ScriptCreate",
|
||||
typeOfDataToScript: "SchemaOnly",
|
||||
scriptStatistics: "ScriptStatsNone",
|
||||
targetDatabaseEngineEdition: targetDatabaseEngineEdition ? targetDatabaseEngineEdition : "SqlServerEnterpriseEdition",
|
||||
targetDatabaseEngineType: targetDatabaseEngineType ? targetDatabaseEngineType : "SingleInstance",
|
||||
scriptCompatibilityOption: scriptCompatibilityOption ? scriptCompatibilityOption : "Script140Compat"
|
||||
}
|
||||
return <ls.ScriptingParams> {
|
||||
connectionString: null,
|
||||
filePath: paramDetails.filePath,
|
||||
scriptingObjects: [scriptingObject],
|
||||
scriptDestination: "ToEditor",
|
||||
includeObjectCriteria: null,
|
||||
excludeObjectCriteria: null,
|
||||
includeSchemas: null,
|
||||
excludeSchemas: null,
|
||||
includeTypes: null,
|
||||
excludeTypes: null,
|
||||
scriptOptions: options,
|
||||
connectionDetails: null,
|
||||
ownerURI: connectionUri,
|
||||
operation: operation
|
||||
};
|
||||
}
|
||||
|
||||
function asConnectionDetail(connInfo: data.ConnectionInfo): ls.ConnectionDetails {
|
||||
return <ls.ConnectionDetails>{
|
||||
options: connInfo.options
|
||||
};
|
||||
}
|
||||
|
||||
function asExpandInfo(nodeInfo: data.ExpandNodeInfo): ls.ExpandParams {
|
||||
return <ls.ExpandParams>{
|
||||
sessionId: nodeInfo.sessionId,
|
||||
nodePath: nodeInfo.nodePath
|
||||
};
|
||||
}
|
||||
|
||||
function asCloseSessionInfo(nodeInfo: data.ObjectExplorerCloseSessionInfo): ls.CloseSessionParams {
|
||||
return <ls.CloseSessionParams>{
|
||||
sessionId: nodeInfo.sessionId
|
||||
};
|
||||
}
|
||||
|
||||
function asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): proto.ExecutionPlanOptions {
|
||||
return <proto.ExecutionPlanOptions>{
|
||||
includeEstimatedExecutionPlanXml: planOptions ? planOptions.displayEstimatedQueryPlan : undefined,
|
||||
includeActualExecutionPlanXml: planOptions ? planOptions.displayActualQueryPlan : undefined
|
||||
};
|
||||
}
|
||||
|
||||
function asListTasksParams(params: data.ListTasksParams): ls.ListTasksParams {
|
||||
return <ls.ListTasksParams>{
|
||||
listActiveTasksOnly: params.listActiveTasksOnly
|
||||
};
|
||||
}
|
||||
|
||||
function asCancelTaskParams(params: data.CancelTaskParams): ls.CancelTaskParams {
|
||||
return <ls.CancelTaskParams>{
|
||||
taskId: params.taskId
|
||||
};
|
||||
}
|
||||
|
||||
function asRestoreParams(ownerUri: string, params: data.RestoreInfo): ls.RestoreParams {
|
||||
return <ls.RestoreParams>{
|
||||
ownerUri: ownerUri,
|
||||
options: params.options,
|
||||
taskExecutionMode: params.taskExecutionMode
|
||||
};
|
||||
}
|
||||
|
||||
function asRestoreConfigInfoParams(ownerUri: string): ls.RestoreConfigInfoRequestParams {
|
||||
return <ls.RestoreConfigInfoRequestParams>{
|
||||
ownerUri: ownerUri
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
asUri,
|
||||
asTextDocumentIdentifier,
|
||||
asOpenTextDocumentParams,
|
||||
asChangeTextDocumentParams,
|
||||
asCloseTextDocumentParams,
|
||||
asSaveTextDocumentParams,
|
||||
asTextDocumentPositionParams,
|
||||
asWorkerPosition,
|
||||
asRange,
|
||||
asPosition,
|
||||
asDiagnosticSeverity,
|
||||
asDiagnostic,
|
||||
asDiagnostics,
|
||||
asCompletionItem,
|
||||
asTextEdit,
|
||||
asReferenceParams,
|
||||
asCodeActionContext,
|
||||
asCommand,
|
||||
asCodeLens,
|
||||
asFormattingOptions,
|
||||
asDocumentSymbolParams,
|
||||
asCodeLensParams,
|
||||
asDocumentLink,
|
||||
asDocumentLinkParams,
|
||||
asCapabilitiesParams,
|
||||
asConnectionParams,
|
||||
asMetadataQueryParams,
|
||||
asTableMetadataParams,
|
||||
asListDatabasesParams,
|
||||
asScriptingParams,
|
||||
asConnectionDetail,
|
||||
asExpandInfo,
|
||||
asCloseSessionInfo,
|
||||
asExecutionPlanOptions,
|
||||
asListTasksParams,
|
||||
asCancelTaskParams,
|
||||
asRestoreParams,
|
||||
asRestoreConfigInfoParams
|
||||
};
|
||||
}
|
||||
|
||||
// This for backward compatibility since we exported the converter functions as API.
|
||||
let defaultConverter = createConverter();
|
||||
|
||||
export const asTextDocumentIdentifier: (textDocument: code.TextDocument) => ls.TextDocumentIdentifier = defaultConverter.asTextDocumentIdentifier;
|
||||
export const asOpenTextDocumentParams: (textDocument: code.TextDocument) => proto.DidOpenTextDocumentParams = defaultConverter.asOpenTextDocumentParams;
|
||||
export const asChangeTextDocumentParams: (arg: code.TextDocumentChangeEvent | code.TextDocument) => proto.DidChangeTextDocumentParams = defaultConverter.asChangeTextDocumentParams;
|
||||
export const asCloseTextDocumentParams: (textDocument: code.TextDocument) => proto.DidCloseTextDocumentParams = defaultConverter.asCloseTextDocumentParams;
|
||||
export const asSaveTextDocumentParams: (textDocument: code.TextDocument) => proto.DidSaveTextDocumentParams = defaultConverter.asSaveTextDocumentParams;
|
||||
export const asTextDocumentPositionParams: (textDocument: code.TextDocument, position: code.Position) => proto.TextDocumentPositionParams = defaultConverter.asTextDocumentPositionParams;
|
||||
export const asWorkerPosition: (position: code.Position) => ls.Position = defaultConverter.asWorkerPosition;
|
||||
export const asRange: (value: code.Range) => ls.Range = defaultConverter.asRange;
|
||||
export const asPosition: (value: code.Position) => ls.Position = defaultConverter.asPosition;
|
||||
export const asDiagnosticSeverity: (value: code.DiagnosticSeverity) => ls.DiagnosticSeverity = defaultConverter.asDiagnosticSeverity;
|
||||
export const asDiagnostic: (item: code.Diagnostic) => ls.Diagnostic = defaultConverter.asDiagnostic;
|
||||
export const asDiagnostics: (items: code.Diagnostic[]) => ls.Diagnostic[] = defaultConverter.asDiagnostics;
|
||||
export const asCompletionItem: (item: code.CompletionItem) => ls.CompletionItem = defaultConverter.asCompletionItem;
|
||||
export const asTextEdit: (edit: code.TextEdit) => ls.TextEdit = defaultConverter.asTextEdit;
|
||||
export const asReferenceParams: (textDocument: code.TextDocument, position: code.Position, options: { includeDeclaration: boolean; }) => proto.ReferenceParams = defaultConverter.asReferenceParams;
|
||||
export const asCodeActionContext: (context: code.CodeActionContext) => ls.CodeActionContext = defaultConverter.asCodeActionContext;
|
||||
export const asCommand: (item: code.Command) => ls.Command = defaultConverter.asCommand;
|
||||
export const asCodeLens: (item: code.CodeLens) => ls.CodeLens = defaultConverter.asCodeLens;
|
||||
export const asFormattingOptions: (item: code.FormattingOptions) => ls.FormattingOptions = defaultConverter.asFormattingOptions;
|
||||
export const asDocumentSymbolParams: (textDocument: code.TextDocument) => proto.DocumentSymbolParams = defaultConverter.asDocumentSymbolParams;
|
||||
export const asCodeLensParams: (textDocument: code.TextDocument) => proto.CodeLensParams = defaultConverter.asCodeLensParams;
|
||||
2612
dataprotocol-node/client/src/main.ts
Normal file
2612
dataprotocol-node/client/src/main.ts
Normal file
File diff suppressed because it is too large
Load Diff
1601
dataprotocol-node/client/src/protocol.ts
Normal file
1601
dataprotocol-node/client/src/protocol.ts
Normal file
File diff suppressed because it is too large
Load Diff
16
dataprotocol-node/client/src/protocolCodeLens.ts
Normal file
16
dataprotocol-node/client/src/protocolCodeLens.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 code from 'vscode';
|
||||
|
||||
export default class ProtocolCodeLens extends code.CodeLens {
|
||||
|
||||
public data: any;
|
||||
|
||||
constructor(range: code.Range) {
|
||||
super(range);
|
||||
}
|
||||
}
|
||||
16
dataprotocol-node/client/src/protocolCompletionItem.ts
Normal file
16
dataprotocol-node/client/src/protocolCompletionItem.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 code from 'vscode';
|
||||
|
||||
export default class ProtocolCompletionItem extends code.CompletionItem {
|
||||
|
||||
public data: any;
|
||||
|
||||
constructor(label: string) {
|
||||
super(label);
|
||||
}
|
||||
}
|
||||
769
dataprotocol-node/client/src/protocolConverter.ts
Normal file
769
dataprotocol-node/client/src/protocolConverter.ts
Normal file
@@ -0,0 +1,769 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 code from 'vscode';
|
||||
import * as data from 'data';
|
||||
import * as ls from 'dataprotocol-languageserver-types';
|
||||
import * as is from './utils/is';
|
||||
import ProtocolCompletionItem from './protocolCompletionItem';
|
||||
import ProtocolCodeLens from './protocolCodeLens';
|
||||
|
||||
export interface Converter {
|
||||
|
||||
asUri(value: string): code.Uri;
|
||||
|
||||
asDiagnostics(diagnostics: ls.Diagnostic[]): code.Diagnostic[];
|
||||
|
||||
asDiagnostic(diagnostic: ls.Diagnostic): code.Diagnostic;
|
||||
|
||||
asRange(value: ls.Range): code.Range;
|
||||
|
||||
asPosition(value: ls.Position): code.Position;
|
||||
|
||||
asDiagnosticSeverity(value: number): code.DiagnosticSeverity;
|
||||
|
||||
asHover(hover: ls.Hover): code.Hover;
|
||||
|
||||
asCompletionResult(result: ls.CompletionItem[] | ls.CompletionList): code.CompletionItem[] | code.CompletionList
|
||||
|
||||
asCompletionItem(item: ls.CompletionItem): ProtocolCompletionItem;
|
||||
|
||||
asTextEdit(edit: ls.TextEdit): code.TextEdit;
|
||||
|
||||
asTextEdits(items: ls.TextEdit[]): code.TextEdit[];
|
||||
|
||||
asSignatureHelp(item: ls.SignatureHelp): code.SignatureHelp;
|
||||
|
||||
asSignatureInformations(items: ls.SignatureInformation[]): code.SignatureInformation[];
|
||||
|
||||
asSignatureInformation(item: ls.SignatureInformation): code.SignatureInformation;
|
||||
|
||||
asParameterInformations(item: ls.ParameterInformation[]): code.ParameterInformation[];
|
||||
|
||||
asParameterInformation(item: ls.ParameterInformation): code.ParameterInformation;
|
||||
|
||||
asDefinitionResult(item: ls.Definition): code.Definition;
|
||||
|
||||
asLocation(item: ls.Location): code.Location;
|
||||
|
||||
asReferences(values: ls.Location[]): code.Location[];
|
||||
|
||||
asDocumentHighlights(values: ls.DocumentHighlight[]): code.DocumentHighlight[];
|
||||
|
||||
asDocumentHighlight(item: ls.DocumentHighlight): code.DocumentHighlight;
|
||||
|
||||
asDocumentHighlightKind(item: ls.DocumentHighlightKind): code.DocumentHighlightKind;
|
||||
|
||||
asSymbolInformations(values: ls.SymbolInformation[], uri?: code.Uri): code.SymbolInformation[];
|
||||
|
||||
asSymbolInformation(item: ls.SymbolInformation, uri?: code.Uri): code.SymbolInformation;
|
||||
|
||||
asCommand(item: ls.Command): code.Command;
|
||||
|
||||
asCommands(items: ls.Command[]): code.Command[];
|
||||
|
||||
asCodeLens(item: ls.CodeLens): code.CodeLens;
|
||||
|
||||
asCodeLenses(items: ls.CodeLens[]): code.CodeLens[];
|
||||
|
||||
asWorkspaceEdit(item: ls.WorkspaceEdit): code.WorkspaceEdit;
|
||||
|
||||
asDocumentLink(item: ls.DocumentLink): code.DocumentLink;
|
||||
|
||||
asDocumentLinks(items: ls.DocumentLink[]): code.DocumentLink[];
|
||||
|
||||
asConnectionSummary(params: ls.ConnectionCompleteParams): data.ConnectionInfoSummary;
|
||||
|
||||
asServerCapabilities(params: ls.CapabiltiesDiscoveryResult): data.DataProtocolServerCapabilities;
|
||||
|
||||
asProviderMetadata(params: ls.MetadataQueryResult): data.ProviderMetadata;
|
||||
|
||||
asScriptingResult(params: ls.ScriptingResult): data.ScriptingResult;
|
||||
|
||||
asObjectExplorerSession(params: ls.SessionCreatedParameters): data.ObjectExplorerSession;
|
||||
|
||||
asObjectExplorerCreateSessionResponse(params: ls.CreateSessionResponse): data.ObjectExplorerSessionResponse;
|
||||
|
||||
asObjectExplorerNodeInfo(params: ls.ExpandResponse): data.ObjectExplorerExpandInfo;
|
||||
|
||||
asObjectExplorerCloseSessionResponse(params: ls.CloseSessionResponse): data.ObjectExplorerCloseSessionResponse;
|
||||
|
||||
asListTasksResponse(response: ls.ListTasksResponse): data.ListTasksResponse;
|
||||
|
||||
asTaskInfo(params: ls.TaskInfo): data.TaskInfo;
|
||||
|
||||
asRestorePlanResponse(params: ls.RestorePlanResponse): data.RestorePlanResponse;
|
||||
|
||||
asRestoreResponse(params: ls.RestoreResponse): data.RestoreResponse;
|
||||
|
||||
asRestoreConfigInfo(params: ls.RestoreConfigInfoResponse): data.RestoreConfigInfo;
|
||||
}
|
||||
|
||||
export interface URIConverter {
|
||||
(value: string): code.Uri;
|
||||
}
|
||||
|
||||
export function createConverter(uriConverter?: URIConverter): Converter {
|
||||
|
||||
const nullConverter = (value: string) => code.Uri.parse(value);
|
||||
|
||||
const _uriConverter: URIConverter = uriConverter || nullConverter;
|
||||
|
||||
function asUri(value: string): code.Uri {
|
||||
return _uriConverter(value);
|
||||
}
|
||||
|
||||
function asDiagnostics(diagnostics: ls.Diagnostic[]): code.Diagnostic[] {
|
||||
return diagnostics.map(asDiagnostic);
|
||||
}
|
||||
|
||||
function asDiagnostic(diagnostic: ls.Diagnostic): code.Diagnostic {
|
||||
let result = new code.Diagnostic(asRange(diagnostic.range), diagnostic.message, asDiagnosticSeverity(diagnostic.severity));
|
||||
if (is.defined(diagnostic.code)) {
|
||||
result.code = diagnostic.code;
|
||||
}
|
||||
if (is.defined(diagnostic.source)) {
|
||||
result.source = diagnostic.source;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function asRange(value: ls.Range): code.Range {
|
||||
if (is.undefined(value)) {
|
||||
return undefined;
|
||||
} else if (is.nil(value)) {
|
||||
return null;
|
||||
}
|
||||
return new code.Range(asPosition(value.start), asPosition(value.end));
|
||||
}
|
||||
|
||||
function asPosition(value: ls.Position): code.Position {
|
||||
if (is.undefined(value)) {
|
||||
return undefined;
|
||||
} else if (is.nil(value)) {
|
||||
return null;
|
||||
}
|
||||
return new code.Position(value.line, value.character);
|
||||
}
|
||||
|
||||
function asDiagnosticSeverity(value: number): code.DiagnosticSeverity {
|
||||
if (is.undefined(value) || is.nil(value)) {
|
||||
return code.DiagnosticSeverity.Error;
|
||||
}
|
||||
switch (value) {
|
||||
case ls.DiagnosticSeverity.Error:
|
||||
return code.DiagnosticSeverity.Error;
|
||||
case ls.DiagnosticSeverity.Warning:
|
||||
return code.DiagnosticSeverity.Warning;
|
||||
case ls.DiagnosticSeverity.Information:
|
||||
return code.DiagnosticSeverity.Information;
|
||||
case ls.DiagnosticSeverity.Hint:
|
||||
return code.DiagnosticSeverity.Hint;
|
||||
}
|
||||
return code.DiagnosticSeverity.Error;
|
||||
}
|
||||
|
||||
function asHover(hover: ls.Hover): code.Hover {
|
||||
if (is.undefined(hover)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(hover)) {
|
||||
return null;
|
||||
}
|
||||
if (is.nil(hover.contents) || is.undefined(hover.contents)) {
|
||||
// Contents must be defined or hover will throw
|
||||
return null;
|
||||
}
|
||||
return new code.Hover(hover.contents, is.defined(hover.range) ? asRange(hover.range) : undefined);
|
||||
}
|
||||
|
||||
function asCompletionResult(result: ls.CompletionItem[] | ls.CompletionList): code.CompletionItem[] | code.CompletionList {
|
||||
if (is.undefined(result)) {
|
||||
return undefined;
|
||||
} else if (is.nil(result)) {
|
||||
return null;
|
||||
}
|
||||
if (Array.isArray(result)) {
|
||||
let items = <ls.CompletionItem[]>result;
|
||||
return items.map(asCompletionItem);
|
||||
}
|
||||
let list = <ls.CompletionList>result;
|
||||
return new code.CompletionList(list.items.map(asCompletionItem), list.isIncomplete);
|
||||
}
|
||||
|
||||
function set<T>(value: T, func: () => void): void {
|
||||
if (is.defined(value)) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
function asCompletionItem(item: ls.CompletionItem): ProtocolCompletionItem {
|
||||
let result = new ProtocolCompletionItem(item.label);
|
||||
set(item.detail, () => result.detail = item.detail);
|
||||
set(item.documentation, () => result.documentation = item.documentation);
|
||||
set(item.filterText, () => result.filterText = item.filterText);
|
||||
set(item.insertText, () => result.insertText = item.insertText);
|
||||
// Protocol item kind is 1 based, codes item kind is zero based.
|
||||
set(item.kind, () => result.kind = item.kind - 1);
|
||||
set(item.sortText, () => result.sortText = item.sortText);
|
||||
set(item.textEdit, () => result.textEdit = asTextEdit(item.textEdit));
|
||||
set(item.additionalTextEdits, () => result.additionalTextEdits = asTextEdits(item.additionalTextEdits));
|
||||
set(item.command, () => result.command = asCommand(item.command));
|
||||
set(item.data, () => result.data = item.data);
|
||||
return result;
|
||||
}
|
||||
|
||||
function asTextEdit(edit: ls.TextEdit): code.TextEdit {
|
||||
return new code.TextEdit(asRange(edit.range), edit.newText);
|
||||
}
|
||||
|
||||
function asTextEdits(items: ls.TextEdit[]): code.TextEdit[] {
|
||||
if (is.undefined(items)) {
|
||||
return undefined;
|
||||
} else if (is.nil(items)) {
|
||||
return null;
|
||||
}
|
||||
return items.map(asTextEdit);
|
||||
}
|
||||
|
||||
function asSignatureHelp(item: ls.SignatureHelp): code.SignatureHelp {
|
||||
if (is.undefined(item)) {
|
||||
return undefined;
|
||||
} else if (is.nil(item)) {
|
||||
return null;
|
||||
}
|
||||
let result = new code.SignatureHelp();
|
||||
set(item.activeParameter, () => result.activeParameter = item.activeParameter);
|
||||
set(item.activeSignature, () => result.activeSignature = item.activeSignature);
|
||||
set(item.signatures, () => result.signatures = asSignatureInformations(item.signatures));
|
||||
return result;
|
||||
}
|
||||
|
||||
function asSignatureInformations(items: ls.SignatureInformation[]): code.SignatureInformation[] {
|
||||
return items ? items.map(asSignatureInformation) : undefined;
|
||||
}
|
||||
|
||||
function asSignatureInformation(item: ls.SignatureInformation): code.SignatureInformation {
|
||||
if (!item) {
|
||||
return undefined;
|
||||
}
|
||||
let result = new code.SignatureInformation(item.label);
|
||||
set(item.documentation, () => result.documentation = item.documentation);
|
||||
set(item.parameters, () => result.parameters = asParameterInformations(item.parameters));
|
||||
return result;
|
||||
}
|
||||
|
||||
function asParameterInformations(item: ls.ParameterInformation[]): code.ParameterInformation[] {
|
||||
return item.map(asParameterInformation);
|
||||
}
|
||||
|
||||
function asParameterInformation(item: ls.ParameterInformation): code.ParameterInformation {
|
||||
let result = new code.ParameterInformation(item.label);
|
||||
set(item.documentation, () => result.documentation = item.documentation);
|
||||
return result;
|
||||
}
|
||||
|
||||
function asDefinitionResult(item: ls.Definition): code.Definition {
|
||||
if (is.undefined(item)) {
|
||||
return undefined;
|
||||
} else if (is.nil(item)) {
|
||||
return null;
|
||||
}
|
||||
if (is.array(item)) {
|
||||
return item.map(asLocation);
|
||||
} else {
|
||||
return asLocation(item);
|
||||
}
|
||||
}
|
||||
|
||||
function asLocation(item: ls.Location): code.Location {
|
||||
if (is.undefined(item)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(item)) {
|
||||
return null;
|
||||
}
|
||||
return new code.Location(_uriConverter(item.uri), asRange(item.range));
|
||||
}
|
||||
|
||||
function asReferences(values: ls.Location[]): code.Location[] {
|
||||
if (is.undefined(values)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(values)) {
|
||||
return null;
|
||||
}
|
||||
return values.map(asLocation);
|
||||
}
|
||||
|
||||
function asDocumentHighlights(values: ls.DocumentHighlight[]): code.DocumentHighlight[] {
|
||||
if (is.undefined(values)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(values)) {
|
||||
return null;
|
||||
}
|
||||
return values.map(asDocumentHighlight);
|
||||
}
|
||||
|
||||
function asDocumentHighlight(item: ls.DocumentHighlight): code.DocumentHighlight {
|
||||
let result = new code.DocumentHighlight(asRange(item.range));
|
||||
set(item.kind, () => result.kind = asDocumentHighlightKind(item.kind));
|
||||
return result;
|
||||
}
|
||||
|
||||
function asDocumentHighlightKind(item: ls.DocumentHighlightKind): code.DocumentHighlightKind {
|
||||
switch (item) {
|
||||
case ls.DocumentHighlightKind.Text:
|
||||
return code.DocumentHighlightKind.Text;
|
||||
case ls.DocumentHighlightKind.Read:
|
||||
return code.DocumentHighlightKind.Read;
|
||||
case ls.DocumentHighlightKind.Write:
|
||||
return code.DocumentHighlightKind.Write;
|
||||
}
|
||||
return code.DocumentHighlightKind.Text;
|
||||
}
|
||||
|
||||
function asSymbolInformations(values: ls.SymbolInformation[], uri?: code.Uri): code.SymbolInformation[] {
|
||||
if (is.undefined(values)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(values)) {
|
||||
return null;
|
||||
}
|
||||
return values.map(information => asSymbolInformation(information, uri));
|
||||
}
|
||||
|
||||
function asSymbolInformation(item: ls.SymbolInformation, uri?: code.Uri): code.SymbolInformation {
|
||||
// Symbol kind is one based in the protocol and zero based in code.
|
||||
let result = new code.SymbolInformation(
|
||||
item.name, item.kind - 1,
|
||||
asRange(item.location.range),
|
||||
item.location.uri ? _uriConverter(item.location.uri) : uri);
|
||||
set(item.containerName, () => result.containerName = item.containerName);
|
||||
return result;
|
||||
}
|
||||
|
||||
function asCommand(item: ls.Command): code.Command {
|
||||
let result: code.Command = { title: item.title, command: item.command };
|
||||
set(item.arguments, () => result.arguments = item.arguments);
|
||||
return result;
|
||||
}
|
||||
|
||||
function asCommands(items: ls.Command[]): code.Command[] {
|
||||
if (is.undefined(items)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(items)) {
|
||||
return null;
|
||||
}
|
||||
return items.map(asCommand);
|
||||
}
|
||||
|
||||
function asCodeLens(item: ls.CodeLens): code.CodeLens {
|
||||
let result: ProtocolCodeLens = new ProtocolCodeLens(asRange(item.range));
|
||||
if (is.defined(item.command)) { result.command = asCommand(item.command); }
|
||||
if (is.defined(item.data)) { result.data = item.data; }
|
||||
return result;
|
||||
}
|
||||
|
||||
function asCodeLenses(items: ls.CodeLens[]): code.CodeLens[] {
|
||||
if (is.undefined(items)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(items)) {
|
||||
return null;
|
||||
}
|
||||
return items.map(asCodeLens);
|
||||
}
|
||||
|
||||
function asWorkspaceEdit(item: ls.WorkspaceEdit): code.WorkspaceEdit {
|
||||
if (is.undefined(item)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(item)) {
|
||||
return null;
|
||||
}
|
||||
let result = new code.WorkspaceEdit();
|
||||
let keys = Object.keys(item.changes);
|
||||
keys.forEach(key => result.set(_uriConverter(key), asTextEdits(item.changes[key])));
|
||||
return result;
|
||||
}
|
||||
|
||||
function asDocumentLink(item: ls.DocumentLink): code.DocumentLink {
|
||||
let range = asRange(item.range);
|
||||
let target = is.defined(item.target) && asUri(item.target);
|
||||
return new code.DocumentLink(range, target);
|
||||
}
|
||||
|
||||
function asDocumentLinks(items: ls.DocumentLink[]): code.DocumentLink[] {
|
||||
if (is.undefined(items)) {
|
||||
return undefined;
|
||||
}
|
||||
if (is.nil(items)) {
|
||||
return null;
|
||||
}
|
||||
return items.map(asDocumentLink);
|
||||
}
|
||||
|
||||
function asConnectionSummary(params: ls.ConnectionCompleteParams): data.ConnectionInfoSummary {
|
||||
let connSummary: data.ConnectionInfoSummary = {
|
||||
ownerUri: params.ownerUri,
|
||||
connectionId: params.connectionId,
|
||||
messages: params.messages,
|
||||
errorMessage: params.errorMessage,
|
||||
errorNumber: params.errorNumber,
|
||||
serverInfo: params.serverInfo,
|
||||
connectionSummary: params.connectionSummary
|
||||
};
|
||||
return connSummary;
|
||||
}
|
||||
|
||||
function asServiceOptionType(val: string): data.ServiceOptionType {
|
||||
if (val === 'string') {
|
||||
return data.ServiceOptionType.string;
|
||||
} else if (val === 'multistring') {
|
||||
return data.ServiceOptionType.multistring;
|
||||
} else if (val === 'password') {
|
||||
return data.ServiceOptionType.password;
|
||||
} else if (val === 'number') {
|
||||
return data.ServiceOptionType.number;
|
||||
} else if (val === 'boolean') {
|
||||
return data.ServiceOptionType.boolean;
|
||||
} else if (val === 'category') {
|
||||
return data.ServiceOptionType.category;
|
||||
} else if (val === 'object') {
|
||||
return data.ServiceOptionType.object;
|
||||
}
|
||||
|
||||
// assume string for unknown value types
|
||||
return data.ServiceOptionType.string;
|
||||
}
|
||||
|
||||
function asServerCapabilities(result: ls.CapabiltiesDiscoveryResult): data.DataProtocolServerCapabilities {
|
||||
let capabilities: data.DataProtocolServerCapabilities = {
|
||||
protocolVersion: result.capabilities.protocolVersion,
|
||||
providerName: result.capabilities.providerName,
|
||||
providerDisplayName: result.capabilities.providerDisplayName,
|
||||
connectionProvider: undefined,
|
||||
adminServicesProvider: undefined,
|
||||
features: []
|
||||
};
|
||||
|
||||
if (result.capabilities.adminServicesProvider) {
|
||||
capabilities.adminServicesProvider = <data.AdminServicesOptions>{
|
||||
databaseInfoOptions: new Array<data.ServiceOption>(),
|
||||
databaseFileInfoOptions: new Array<data.ServiceOption>(),
|
||||
fileGroupInfoOptions: new Array<data.ServiceOption>()
|
||||
};
|
||||
|
||||
if (result.capabilities.adminServicesProvider.databaseInfoOptions
|
||||
&& result.capabilities.adminServicesProvider.databaseInfoOptions.length > 0) {
|
||||
for (let i = 0; i < result.capabilities.adminServicesProvider.databaseInfoOptions.length; ++i) {
|
||||
let srcOption: ls.ServiceOption = result.capabilities.adminServicesProvider.databaseInfoOptions[i];
|
||||
let descOption: data.ServiceOption = buildServiceOption(srcOption);
|
||||
capabilities.adminServicesProvider.databaseInfoOptions.push(descOption);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.capabilities.adminServicesProvider.databaseFileInfoOptions
|
||||
&& result.capabilities.adminServicesProvider.databaseFileInfoOptions.length > 0) {
|
||||
for (let i = 0; i < result.capabilities.adminServicesProvider.databaseFileInfoOptions.length; ++i) {
|
||||
let srcOption: ls.ServiceOption = result.capabilities.adminServicesProvider.databaseFileInfoOptions[i];
|
||||
let descOption: data.ServiceOption = buildServiceOption(srcOption);
|
||||
capabilities.adminServicesProvider.databaseFileInfoOptions.push(descOption);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.capabilities.adminServicesProvider.fileGroupInfoOptions
|
||||
&& result.capabilities.adminServicesProvider.fileGroupInfoOptions.length > 0) {
|
||||
for (let i = 0; i < result.capabilities.adminServicesProvider.fileGroupInfoOptions.length; ++i) {
|
||||
let srcOption: ls.ServiceOption = result.capabilities.adminServicesProvider.fileGroupInfoOptions[i];
|
||||
let descOption: data.ServiceOption = buildServiceOption(srcOption);
|
||||
capabilities.adminServicesProvider.fileGroupInfoOptions.push(descOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.capabilities.connectionProvider
|
||||
&& result.capabilities.connectionProvider.options
|
||||
&& result.capabilities.connectionProvider.options.length > 0) {
|
||||
capabilities.connectionProvider = <data.ConnectionProviderOptions>{
|
||||
options: new Array<data.ConnectionOption>()
|
||||
};
|
||||
for (let i = 0; i < result.capabilities.connectionProvider.options.length; ++i) {
|
||||
let srcOption: ls.ConnectionOption = result.capabilities.connectionProvider.options[i];
|
||||
let descOption: data.ConnectionOption = {
|
||||
name: srcOption.name,
|
||||
displayName: srcOption.displayName ? srcOption.displayName : srcOption.name,
|
||||
description: srcOption.description,
|
||||
groupName: srcOption.groupName,
|
||||
defaultValue: srcOption.defaultValue,
|
||||
categoryValues: srcOption.categoryValues,
|
||||
isIdentity: srcOption.isIdentity,
|
||||
isRequired: srcOption.isRequired,
|
||||
valueType: asServiceOptionType(srcOption.valueType),
|
||||
specialValueType: undefined
|
||||
};
|
||||
|
||||
if (srcOption.specialValueType === 'serverName') {
|
||||
descOption.specialValueType = data.ConnectionOptionSpecialType.serverName;
|
||||
} else if (srcOption.specialValueType === 'databaseName') {
|
||||
descOption.specialValueType = data.ConnectionOptionSpecialType.databaseName;
|
||||
} else if (srcOption.specialValueType === 'authType') {
|
||||
descOption.specialValueType = data.ConnectionOptionSpecialType.authType;
|
||||
} else if (srcOption.specialValueType === 'userName') {
|
||||
descOption.specialValueType = data.ConnectionOptionSpecialType.userName;
|
||||
} else if (srcOption.specialValueType === 'password') {
|
||||
descOption.specialValueType = data.ConnectionOptionSpecialType.password;
|
||||
} else if (srcOption.specialValueType === 'appName') {
|
||||
descOption.specialValueType = data.ConnectionOptionSpecialType.appName;
|
||||
}
|
||||
|
||||
capabilities.connectionProvider.options.push(descOption);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.capabilities.features
|
||||
&& result.capabilities.features.length > 0) {
|
||||
result.capabilities.features.forEach(feature => {
|
||||
let descFeature: data.FeatureMetadataProvider = {
|
||||
enabled: feature.enabled,
|
||||
featureName: feature.featureName,
|
||||
optionsMetadata: []
|
||||
};
|
||||
capabilities.features.push(descFeature);
|
||||
if (feature.optionsMetadata) {
|
||||
feature.optionsMetadata.forEach(srcOption => {
|
||||
descFeature.optionsMetadata.push(buildServiceOption(srcOption));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
function buildServiceOption(srcOption: ls.ServiceOption): data.ServiceOption {
|
||||
return {
|
||||
name: srcOption.name,
|
||||
displayName: srcOption.displayName ? srcOption.displayName : srcOption.name,
|
||||
description: srcOption.description,
|
||||
groupName: srcOption.groupName,
|
||||
defaultValue: srcOption.defaultValue,
|
||||
categoryValues: srcOption.categoryValues,
|
||||
isRequired: srcOption.isRequired,
|
||||
isArray: srcOption.isArray,
|
||||
objectType: srcOption.objectType,
|
||||
valueType: asServiceOptionType(srcOption.valueType),
|
||||
};
|
||||
}
|
||||
|
||||
function asProviderMetadata(params: ls.MetadataQueryResult): data.ProviderMetadata {
|
||||
let objectMetadata: data.ObjectMetadata[] = [];
|
||||
|
||||
if (!params.metadata || !params.metadata.length) {
|
||||
return {
|
||||
objectMetadata: objectMetadata
|
||||
};
|
||||
}
|
||||
|
||||
for (let i = 0; i < params.metadata.length; ++i) {
|
||||
let metadata: ls.ObjectMetadata = params.metadata[i];
|
||||
|
||||
let metadataTypeName: string;
|
||||
if (metadata.metadataTypeName) {
|
||||
// Read from the provider since it's defined
|
||||
metadataTypeName = metadata.metadataTypeName;
|
||||
} else if (metadata.metadataType === ls.MetadataType.View) {
|
||||
metadataTypeName = 'View';
|
||||
} else if (metadata.metadataType === ls.MetadataType.SProc) {
|
||||
metadataTypeName = 'StoredProcedure';
|
||||
} else if (metadata.metadataType === ls.MetadataType.Function) {
|
||||
metadataTypeName = 'Function';
|
||||
} else {
|
||||
metadataTypeName = 'Table';
|
||||
}
|
||||
|
||||
objectMetadata.push({
|
||||
metadataTypeName: metadataTypeName,
|
||||
metadataType: metadata.metadataType,
|
||||
name: metadata.name,
|
||||
schema: metadata.schema,
|
||||
urn: metadata.urn
|
||||
});
|
||||
}
|
||||
|
||||
return <data.ProviderMetadata>{
|
||||
objectMetadata: objectMetadata
|
||||
};
|
||||
}
|
||||
|
||||
function asObjectExplorerSession(params: ls.SessionCreatedParameters): data.ObjectExplorerSession {
|
||||
return <data.ObjectExplorerSession>{
|
||||
success: params.success,
|
||||
sessionId: params.sessionId,
|
||||
rootNode: params.rootNode,
|
||||
errorMessage: params.errorMessage
|
||||
};
|
||||
}
|
||||
|
||||
function asObjectExplorerCreateSessionResponse(params: ls.CreateSessionResponse): data.ObjectExplorerSessionResponse {
|
||||
return <data.ObjectExplorerSessionResponse>{
|
||||
sessionId: params.sessionId
|
||||
};
|
||||
}
|
||||
|
||||
function asObjectExplorerNodeInfo(params: ls.ExpandResponse): data.ObjectExplorerExpandInfo {
|
||||
return <data.ObjectExplorerExpandInfo>{
|
||||
sessionId: params.sessionId,
|
||||
nodes: params.nodes,
|
||||
errorMessage: params.errorMessage,
|
||||
nodePath: params.nodePath
|
||||
};
|
||||
}
|
||||
|
||||
function asObjectExplorerCloseSessionResponse(params: ls.CloseSessionResponse): data.ObjectExplorerCloseSessionResponse {
|
||||
return <data.ObjectExplorerCloseSessionResponse>{
|
||||
sessionId: params.sessionId,
|
||||
success: params.success
|
||||
};
|
||||
}
|
||||
|
||||
function asScriptingResult(params: ls.ScriptingResult): data.ScriptingResult {
|
||||
return <data.ScriptingResult>{
|
||||
operationId: params.operationId,
|
||||
script: params.script
|
||||
};
|
||||
}
|
||||
|
||||
function asListTasksResponse(response: ls.ListTasksResponse): data.ListTasksResponse {
|
||||
return <data.ListTasksResponse>{
|
||||
tasks: response.tasks
|
||||
};
|
||||
}
|
||||
|
||||
function asTaskInfo(params: ls.TaskInfo): data.TaskInfo {
|
||||
return <data.TaskInfo>{
|
||||
taskId: params.taskId,
|
||||
status: params.status,
|
||||
taskExecutionMode: params.taskExecutionMode,
|
||||
serverName: params.serverName,
|
||||
name: params.name,
|
||||
databaseName: params.databaseName,
|
||||
description: params.description,
|
||||
providerName: params.providerName,
|
||||
isCancelable: params.isCancelable,
|
||||
};
|
||||
}
|
||||
|
||||
function asRestorePlanResponse(params: ls.RestorePlanResponse): data.RestorePlanResponse {
|
||||
return <data.RestorePlanResponse>{
|
||||
backupSetsToRestore: params.backupSetsToRestore,
|
||||
canRestore: params.canRestore,
|
||||
databaseNamesFromBackupSets: params.databaseNamesFromBackupSets,
|
||||
dbFiles: params.dbFiles,
|
||||
errorMessage: params.errorMessage,
|
||||
planDetails: params.planDetails,
|
||||
sessionId: params.sessionId
|
||||
};
|
||||
}
|
||||
|
||||
function asRestoreResponse(params: ls.RestoreResponse): data.RestoreResponse {
|
||||
return <data.RestoreResponse>{
|
||||
result: params.result,
|
||||
errorMessage: params.errorMessage,
|
||||
taskId: params.taskId
|
||||
};
|
||||
}
|
||||
|
||||
function asRestoreConfigInfo(params: ls.RestoreConfigInfoResponse): data.RestoreConfigInfo {
|
||||
return <data.RestoreConfigInfo>{
|
||||
configInfo: params.configInfo
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
asUri,
|
||||
asDiagnostics,
|
||||
asDiagnostic,
|
||||
asRange,
|
||||
asPosition,
|
||||
asDiagnosticSeverity,
|
||||
asHover,
|
||||
asCompletionResult,
|
||||
asCompletionItem,
|
||||
asTextEdit,
|
||||
asTextEdits,
|
||||
asSignatureHelp,
|
||||
asSignatureInformations,
|
||||
asSignatureInformation,
|
||||
asParameterInformations,
|
||||
asParameterInformation,
|
||||
asDefinitionResult,
|
||||
asLocation,
|
||||
asReferences,
|
||||
asDocumentHighlights,
|
||||
asDocumentHighlight,
|
||||
asDocumentHighlightKind,
|
||||
asSymbolInformations,
|
||||
asSymbolInformation,
|
||||
asCommand,
|
||||
asCommands,
|
||||
asCodeLens,
|
||||
asCodeLenses,
|
||||
asWorkspaceEdit,
|
||||
asDocumentLink,
|
||||
asDocumentLinks,
|
||||
asConnectionSummary,
|
||||
asServerCapabilities,
|
||||
asProviderMetadata,
|
||||
asScriptingResult,
|
||||
asObjectExplorerSession,
|
||||
asObjectExplorerCreateSessionResponse,
|
||||
asObjectExplorerNodeInfo,
|
||||
asObjectExplorerCloseSessionResponse,
|
||||
asListTasksResponse,
|
||||
asTaskInfo,
|
||||
asRestorePlanResponse,
|
||||
asRestoreResponse,
|
||||
asRestoreConfigInfo
|
||||
};
|
||||
}
|
||||
|
||||
// This for backward compatibility since we exported the converter functions as API.
|
||||
const defaultConverter = createConverter();
|
||||
|
||||
export const asDiagnostics: (diagnostics: ls.Diagnostic[]) => code.Diagnostic[] = defaultConverter.asDiagnostics;
|
||||
export const asDiagnostic: (diagnostic: ls.Diagnostic) => code.Diagnostic = defaultConverter.asDiagnostic;
|
||||
export const asRange: (value: ls.Range) => code.Range = defaultConverter.asRange;
|
||||
export const asPosition: (value: ls.Position) => code.Position = defaultConverter.asPosition;
|
||||
export const asDiagnosticSeverity: (value: number) => code.DiagnosticSeverity = defaultConverter.asDiagnosticSeverity;
|
||||
export const asHover: (hover: ls.Hover) => code.Hover = defaultConverter.asHover;
|
||||
export const asCompletionResult: (result: ls.CompletionItem[] | ls.CompletionList) => code.CompletionItem[] | code.CompletionList = defaultConverter.asCompletionResult;
|
||||
export const asCompletionItem: (item: ls.CompletionItem) => ProtocolCompletionItem = defaultConverter.asCompletionItem;
|
||||
export const asTextEdit: (edit: ls.TextEdit) => code.TextEdit = defaultConverter.asTextEdit;
|
||||
export const asTextEdits: (items: ls.TextEdit[]) => code.TextEdit[] = defaultConverter.asTextEdits;
|
||||
export const asSignatureHelp: (item: ls.SignatureHelp) => code.SignatureHelp = defaultConverter.asSignatureHelp;
|
||||
export const asSignatureInformations: (items: ls.SignatureInformation[]) => code.SignatureInformation[] = defaultConverter.asSignatureInformations;
|
||||
export const asSignatureInformation: (item: ls.SignatureInformation) => code.SignatureInformation = defaultConverter.asSignatureInformation;
|
||||
export const asParameterInformations: (item: ls.ParameterInformation[]) => code.ParameterInformation[] = defaultConverter.asParameterInformations;
|
||||
export const asParameterInformation: (item: ls.ParameterInformation) => code.ParameterInformation = defaultConverter.asParameterInformation;
|
||||
export const asDefinitionResult: (item: ls.Definition) => code.Definition = defaultConverter.asDefinitionResult;
|
||||
export const asLocation: (item: ls.Location) => code.Location = defaultConverter.asLocation;
|
||||
export const asReferences: (values: ls.Location[]) => code.Location[] = defaultConverter.asReferences;
|
||||
export const asDocumentHighlights: (values: ls.DocumentHighlight[]) => code.DocumentHighlight[] = defaultConverter.asDocumentHighlights;
|
||||
export const asDocumentHighlight: (item: ls.DocumentHighlight) => code.DocumentHighlight = defaultConverter.asDocumentHighlight;
|
||||
export const asDocumentHighlightKind: (item: ls.DocumentHighlightKind) => code.DocumentHighlightKind = defaultConverter.asDocumentHighlightKind;
|
||||
export const asSymbolInformations: (values: ls.SymbolInformation[], uri?: code.Uri) => code.SymbolInformation[] = defaultConverter.asSymbolInformations;
|
||||
export const asSymbolInformation: (item: ls.SymbolInformation, uri?: code.Uri) => code.SymbolInformation = defaultConverter.asSymbolInformation;
|
||||
export const asCommand: (item: ls.Command) => code.Command = defaultConverter.asCommand;
|
||||
export const asCommands: (items: ls.Command[]) => code.Command[] = defaultConverter.asCommands;
|
||||
export const asCodeLens: (item: ls.CodeLens) => code.CodeLens = defaultConverter.asCodeLens;
|
||||
export const asCodeLenses: (items: ls.CodeLens[]) => code.CodeLens[] = defaultConverter.asCodeLenses;
|
||||
export const asWorkspaceEdit: (item: ls.WorkspaceEdit) => code.WorkspaceEdit = defaultConverter.asWorkspaceEdit;
|
||||
export const asDocumentLink: (item: ls.DocumentLink) => code.DocumentLink = defaultConverter.asDocumentLink;
|
||||
export const asDocumentLinks: (item: ls.DocumentLink[]) => code.DocumentLink[] = defaultConverter.asDocumentLinks;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": false,
|
||||
84
dataprotocol-node/client/src/typings/es6-promise/index.d.ts
vendored
Normal file
84
dataprotocol-node/client/src/typings/es6-promise/index.d.ts
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
// Type definitions for es6-promise
|
||||
// Project: https://github.com/jakearchibald/ES6-Promise
|
||||
// Definitions by: François de Campredon <https://github.com/fdecampredon/>, vvakame <https://github.com/vvakame>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Thenable<T> {
|
||||
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
|
||||
}
|
||||
|
||||
declare class Promise<T> implements Thenable<T> {
|
||||
/**
|
||||
* If you call resolve in the body of the callback passed to the constructor,
|
||||
* your promise is fulfilled with result object passed to resolve.
|
||||
* If you call reject your promise is rejected with the object passed to reject.
|
||||
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
|
||||
* Any errors thrown in the constructor callback will be implicitly passed to reject().
|
||||
*/
|
||||
constructor(callback: (resolve : (value?: T | Thenable<T>) => void, reject: (error?: any) => void) => void);
|
||||
|
||||
/**
|
||||
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
|
||||
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
|
||||
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
|
||||
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
|
||||
* If an error is thrown in the callback, the returned promise rejects with that error.
|
||||
*
|
||||
* @param onFulfilled called when/if "promise" resolves
|
||||
* @param onRejected called when/if "promise" rejects
|
||||
*/
|
||||
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
|
||||
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
|
||||
|
||||
/**
|
||||
* Sugar for promise.then(undefined, onRejected)
|
||||
*
|
||||
* @param onRejected called when/if "promise" rejects
|
||||
*/
|
||||
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare namespace Promise {
|
||||
/**
|
||||
* Make a new promise from the thenable.
|
||||
* A thenable is promise-like in as far as it has a "then" method.
|
||||
*/
|
||||
function resolve<T>(value?: T | Thenable<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
|
||||
*/
|
||||
function reject(error: any): Promise<any>;
|
||||
function reject<T>(error: T): Promise<T>;
|
||||
|
||||
/**
|
||||
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
|
||||
* the array passed to all can be a mixture of promise-like objects and other objects.
|
||||
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
|
||||
*/
|
||||
function all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>, T10 | Thenable<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
|
||||
function all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
|
||||
function all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
|
||||
function all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
|
||||
function all<T1, T2, T3, T4, T5, T6>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
|
||||
function all<T1, T2, T3, T4, T5>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
function all<T1, T2, T3, T4>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
function all<T1, T2, T3>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>]): Promise<[T1, T2, T3]>;
|
||||
function all<T1, T2>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>]): Promise<[T1, T2]>;
|
||||
function all<T>(values: (T | Thenable<T>)[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
|
||||
*/
|
||||
function race<T>(promises: (T | Thenable<T>)[]): Promise<T>;
|
||||
}
|
||||
|
||||
declare module 'es6-promise' {
|
||||
var foo: typeof Promise; // Temp variable to reference Promise in local context
|
||||
namespace rsvp {
|
||||
export var Promise: typeof foo;
|
||||
export function polyfill(): void;
|
||||
}
|
||||
export = rsvp;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"es6-promise-tests.ts"
|
||||
]
|
||||
}
|
||||
7
dataprotocol-node/client/src/typings/ref.d.ts
vendored
Normal file
7
dataprotocol-node/client/src/typings/ref.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path='../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../src/sql/data.d.ts'/>
|
||||
82
dataprotocol-node/client/src/utils/async.ts
Normal file
82
dataprotocol-node/client/src/utils/async.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 interface ITask<T> {
|
||||
(): T;
|
||||
}
|
||||
|
||||
export class Delayer<T> {
|
||||
|
||||
public defaultDelay: number;
|
||||
private timeout: NodeJS.Timer;
|
||||
private completionPromise: Promise<T>;
|
||||
private onSuccess: (value?: T | Thenable<T>) => void;
|
||||
private task: ITask<T>;
|
||||
|
||||
constructor(defaultDelay: number) {
|
||||
this.defaultDelay = defaultDelay;
|
||||
this.timeout = null;
|
||||
this.completionPromise = null;
|
||||
this.onSuccess = null;
|
||||
this.task = null;
|
||||
}
|
||||
|
||||
public trigger(task: ITask<T>, delay: number = this.defaultDelay): Promise<T> {
|
||||
this.task = task;
|
||||
if (delay >= 0) {
|
||||
this.cancelTimeout();
|
||||
}
|
||||
|
||||
if (!this.completionPromise) {
|
||||
this.completionPromise = new Promise<T>((resolve) => {
|
||||
this.onSuccess = resolve
|
||||
}).then(() => {
|
||||
this.completionPromise = null;
|
||||
this.onSuccess = null;
|
||||
var result = this.task();
|
||||
this.task = null;
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
if (delay >= 0 || this.timeout === null) {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.timeout = null;
|
||||
this.onSuccess(null);
|
||||
}, delay >= 0 ? delay : this.defaultDelay);
|
||||
}
|
||||
|
||||
return this.completionPromise;
|
||||
}
|
||||
|
||||
public forceDelivery(): T {
|
||||
if (!this.completionPromise) {
|
||||
return null;
|
||||
}
|
||||
this.cancelTimeout();
|
||||
let result: T = this.task();
|
||||
this.completionPromise = null;
|
||||
this.onSuccess = null;
|
||||
this.task = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
public isTriggered(): boolean {
|
||||
return this.timeout !== null;
|
||||
}
|
||||
|
||||
public cancel(): void {
|
||||
this.cancelTimeout();
|
||||
this.completionPromise = null;
|
||||
}
|
||||
|
||||
private cancelTimeout(): void {
|
||||
if (this.timeout !== null) {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
123
dataprotocol-node/client/src/utils/electron.ts
Normal file
123
dataprotocol-node/client/src/utils/electron.ts
Normal file
@@ -0,0 +1,123 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 path = require('path');
|
||||
import os = require('os');
|
||||
import net = require('net');
|
||||
import cp = require('child_process');
|
||||
|
||||
export interface IForkOptions {
|
||||
cwd?: string;
|
||||
env?: any;
|
||||
encoding?: string;
|
||||
execArgv?: string[];
|
||||
}
|
||||
|
||||
function makeRandomHexString(length: number): string {
|
||||
let chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
let idx = Math.floor(chars.length * Math.random());
|
||||
result += chars[idx];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function generatePipeName(): string {
|
||||
var randomName = 'vscode-' + makeRandomHexString(40);
|
||||
if (process.platform === 'win32') {
|
||||
return '\\\\.\\pipe\\' + randomName + '-sock';
|
||||
}
|
||||
|
||||
// Mac/Unix: use socket file
|
||||
return path.join(os.tmpdir(), randomName + '.sock');
|
||||
}
|
||||
|
||||
function generatePatchedEnv(env: any, stdInPipeName: string, stdOutPipeName: string): any {
|
||||
// Set the two unique pipe names and the electron flag as process env
|
||||
|
||||
var newEnv: any = {};
|
||||
for (var key in env) {
|
||||
newEnv[key] = env[key];
|
||||
}
|
||||
|
||||
newEnv['STDIN_PIPE_NAME'] = stdInPipeName;
|
||||
newEnv['STDOUT_PIPE_NAME'] = stdOutPipeName;
|
||||
newEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
|
||||
|
||||
return newEnv;
|
||||
}
|
||||
|
||||
export function fork(modulePath: string, args: string[], options: IForkOptions, callback: (error: any, cp: cp.ChildProcess) => void): void {
|
||||
|
||||
var callbackCalled = false;
|
||||
var resolve = (result: cp.ChildProcess) => {
|
||||
if (callbackCalled) {
|
||||
return;
|
||||
}
|
||||
callbackCalled = true;
|
||||
callback(null, result);
|
||||
};
|
||||
var reject = (err: any) => {
|
||||
if (callbackCalled) {
|
||||
return;
|
||||
}
|
||||
callbackCalled = true;
|
||||
callback(err, null);
|
||||
};
|
||||
|
||||
// Generate two unique pipe names
|
||||
var stdInPipeName = generatePipeName();
|
||||
var stdOutPipeName = generatePipeName();
|
||||
|
||||
var newEnv = generatePatchedEnv(options.env || process.env, stdInPipeName, stdOutPipeName);
|
||||
|
||||
var childProcess: cp.ChildProcess;
|
||||
|
||||
// Begin listening to stdout pipe
|
||||
var server = net.createServer((stream) => {
|
||||
// The child process will write exactly one chunk with content `ready` when it has installed a listener to the stdin pipe
|
||||
|
||||
stream.once('data', (chunk: Buffer) => {
|
||||
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
|
||||
childProcess.stdin = <any>net.connect(stdInPipeName);
|
||||
|
||||
// From now on the childProcess.stdout is available for reading
|
||||
childProcess.stdout = stream;
|
||||
|
||||
resolve(childProcess);
|
||||
});
|
||||
});
|
||||
server.listen(stdOutPipeName);
|
||||
|
||||
var serverClosed = false;
|
||||
var closeServer = () => {
|
||||
if (serverClosed) {
|
||||
return;
|
||||
}
|
||||
serverClosed = true;
|
||||
server.close();
|
||||
}
|
||||
|
||||
// Create the process
|
||||
let bootstrapperPath = path.join(__dirname, 'electronForkStart');
|
||||
childProcess = cp.fork(bootstrapperPath, [modulePath].concat(args), <any>{
|
||||
silent: true,
|
||||
cwd: options.cwd,
|
||||
env: newEnv,
|
||||
execArgv: options.execArgv
|
||||
});
|
||||
|
||||
childProcess.once('error', (err: Error) => {
|
||||
closeServer();
|
||||
reject(err);
|
||||
});
|
||||
|
||||
childProcess.once('exit', (err: Error) => {
|
||||
closeServer();
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
183
dataprotocol-node/client/src/utils/electronForkStart.ts
Normal file
183
dataprotocol-node/client/src/utils/electronForkStart.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
var net = require('net'),
|
||||
fs = require('fs'),
|
||||
stream = require('stream'),
|
||||
util = require('util');
|
||||
|
||||
var ENABLE_LOGGING = false;
|
||||
|
||||
var log = (function () {
|
||||
if (!ENABLE_LOGGING) {
|
||||
return function () { };
|
||||
}
|
||||
var isFirst = true;
|
||||
var LOG_LOCATION = 'C:\\stdFork.log';
|
||||
return function log(str) {
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
fs.writeFileSync(LOG_LOCATION, str + '\n');
|
||||
return;
|
||||
}
|
||||
fs.appendFileSync(LOG_LOCATION, str + '\n');
|
||||
}
|
||||
})();
|
||||
|
||||
var stdInPipeName = process.env['STDIN_PIPE_NAME'];
|
||||
var stdOutPipeName = process.env['STDOUT_PIPE_NAME'];
|
||||
|
||||
log('STDIN_PIPE_NAME: ' + stdInPipeName);
|
||||
log('STDOUT_PIPE_NAME: ' + stdOutPipeName);
|
||||
log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE']);
|
||||
|
||||
// stdout redirection to named pipe
|
||||
(function () {
|
||||
log('Beginning stdout redirection...');
|
||||
|
||||
// Create a writing stream to the stdout pipe
|
||||
var stdOutStream = net.connect(stdOutPipeName);
|
||||
|
||||
// unref stdOutStream to behave like a normal standard out
|
||||
stdOutStream.unref();
|
||||
|
||||
// handle process.stdout
|
||||
(<any>process).__defineGetter__('stdout', function () { return stdOutStream; });
|
||||
|
||||
// handle process.stderr
|
||||
(<any>process).__defineGetter__('stderr', function () { return stdOutStream; });
|
||||
|
||||
var fsWriteSyncString = function (fd, str, position, encoding) {
|
||||
// fs.writeSync(fd, string[, position[, encoding]]);
|
||||
var buf = new Buffer(str, encoding || 'utf8');
|
||||
return fsWriteSyncBuffer(fd, buf, 0, buf.length);
|
||||
};
|
||||
|
||||
var fsWriteSyncBuffer = function (fd, buffer, off, len) {
|
||||
off = Math.abs(off | 0);
|
||||
len = Math.abs(len | 0);
|
||||
|
||||
// fs.writeSync(fd, buffer, offset, length[, position]);
|
||||
var buffer_length = buffer.length;
|
||||
|
||||
if (off > buffer_length) {
|
||||
throw new Error('offset out of bounds');
|
||||
}
|
||||
if (len > buffer_length) {
|
||||
throw new Error('length out of bounds');
|
||||
}
|
||||
if (((off + len) | 0) < off) {
|
||||
throw new Error('off + len overflow');
|
||||
}
|
||||
if (buffer_length - off < len) {
|
||||
// Asking for more than is left over in the buffer
|
||||
throw new Error('off + len > buffer.length');
|
||||
}
|
||||
|
||||
var slicedBuffer = buffer;
|
||||
if (off !== 0 || len !== buffer_length) {
|
||||
slicedBuffer = buffer.slice(off, off + len);
|
||||
}
|
||||
|
||||
stdOutStream.write(slicedBuffer);
|
||||
return slicedBuffer.length;
|
||||
};
|
||||
|
||||
// handle fs.writeSync(1, ...)
|
||||
var originalWriteSync = fs.writeSync;
|
||||
fs.writeSync = function (fd, data, position, encoding) {
|
||||
if (fd !== 1) {
|
||||
return originalWriteSync.apply(fs, arguments);
|
||||
}
|
||||
// usage:
|
||||
// fs.writeSync(fd, buffer, offset, length[, position]);
|
||||
// OR
|
||||
// fs.writeSync(fd, string[, position[, encoding]]);
|
||||
|
||||
if (data instanceof Buffer) {
|
||||
return fsWriteSyncBuffer.apply(null, arguments);
|
||||
}
|
||||
|
||||
// For compatibility reasons with fs.writeSync, writing null will write "null", etc
|
||||
if (typeof data !== 'string') {
|
||||
data += '';
|
||||
}
|
||||
|
||||
return fsWriteSyncString.apply(null, arguments);
|
||||
};
|
||||
|
||||
log('Finished defining process.stdout, process.stderr and fs.writeSync');
|
||||
})();
|
||||
|
||||
// stdin redirection to named pipe
|
||||
(function () {
|
||||
|
||||
// Begin listening to stdin pipe
|
||||
var server = net.createServer(function (stream) {
|
||||
// Stop accepting new connections, keep the existing one alive
|
||||
server.close();
|
||||
|
||||
log('Parent process has connected to my stdin. All should be good now.');
|
||||
|
||||
// handle process.stdin
|
||||
(<any>process).__defineGetter__('stdin', function () {
|
||||
return stream;
|
||||
});
|
||||
|
||||
// Remove myself from process.argv
|
||||
process.argv.splice(1, 1);
|
||||
|
||||
// Load the actual program
|
||||
var program = process.argv[1];
|
||||
log('Loading program: ' + program);
|
||||
|
||||
// Unset the custom environmental variables that should not get inherited
|
||||
delete process.env['STDIN_PIPE_NAME'];
|
||||
delete process.env['STDOUT_PIPE_NAME'];
|
||||
delete process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
|
||||
|
||||
require(program);
|
||||
|
||||
log('Finished loading program.');
|
||||
|
||||
var stdinIsReferenced = true;
|
||||
var timer = setInterval(function () {
|
||||
var listenerCount = (
|
||||
stream.listeners('data').length +
|
||||
stream.listeners('end').length +
|
||||
stream.listeners('close').length +
|
||||
stream.listeners('error').length
|
||||
);
|
||||
// log('listenerCount: ' + listenerCount);
|
||||
if (listenerCount <= 1) {
|
||||
// No more "actual" listeners, only internal node
|
||||
if (stdinIsReferenced) {
|
||||
stdinIsReferenced = false;
|
||||
// log('unreferencing stream!!!');
|
||||
stream.unref();
|
||||
}
|
||||
} else {
|
||||
// There are "actual" listeners
|
||||
if (!stdinIsReferenced) {
|
||||
stdinIsReferenced = true;
|
||||
stream.ref();
|
||||
}
|
||||
}
|
||||
// log(
|
||||
// '' + stream.listeners('data').length +
|
||||
// ' ' + stream.listeners('end').length +
|
||||
// ' ' + stream.listeners('close').length +
|
||||
// ' ' + stream.listeners('error').length
|
||||
// );
|
||||
}, 1000);
|
||||
timer.unref();
|
||||
});
|
||||
|
||||
|
||||
server.listen(stdInPipeName, function () {
|
||||
// signal via stdout that the parent process can now begin writing to stdin pipe
|
||||
process.stdout.write('ready');
|
||||
});
|
||||
|
||||
})();
|
||||
55
dataprotocol-node/client/src/utils/is.ts
Normal file
55
dataprotocol-node/client/src/utils/is.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
'use strict';
|
||||
|
||||
const toString = Object.prototype.toString;
|
||||
|
||||
export function defined(value: any): boolean {
|
||||
return typeof value !== 'undefined';
|
||||
}
|
||||
|
||||
export function undefined(value: any): boolean {
|
||||
return typeof value === 'undefined';
|
||||
}
|
||||
|
||||
export function nil(value: any): boolean {
|
||||
return value === null;
|
||||
}
|
||||
|
||||
export function boolean(value: any): value is boolean {
|
||||
return value === true || value === false;
|
||||
}
|
||||
|
||||
export function string(value: any): value is string {
|
||||
return toString.call(value) === '[object String]';
|
||||
}
|
||||
|
||||
export function number(value: any): value is number {
|
||||
return toString.call(value) === '[object Number]';
|
||||
}
|
||||
|
||||
export function error(value: any): value is Error {
|
||||
return toString.call(value) === '[object Error]';
|
||||
}
|
||||
|
||||
export function func(value: any): value is Function {
|
||||
return toString.call(value) === '[object Function]';
|
||||
}
|
||||
|
||||
export function array<T>(value: any): value is T[] {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
|
||||
export function stringArray(value: any): value is string[] {
|
||||
return array(value) && (<any[]>value).every(elem => string(elem));
|
||||
}
|
||||
|
||||
export function typedArray<T>(value: any, check: (value: any) => boolean): value is T[] {
|
||||
return Array.isArray(value) && (<any[]>value).every(check);
|
||||
}
|
||||
|
||||
export function thenable<T>(value: any): value is Thenable<T> {
|
||||
return value && func(value.then);
|
||||
}
|
||||
44
dataprotocol-node/client/src/utils/processes.ts
Normal file
44
dataprotocol-node/client/src/utils/processes.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 cp from 'child_process';
|
||||
import ChildProcess = cp.ChildProcess;
|
||||
|
||||
import { join } from 'path';
|
||||
|
||||
const isWindows = (process.platform === 'win32');
|
||||
const isMacintosh = (process.platform === 'darwin');
|
||||
const isLinux = (process.platform === 'linux');
|
||||
export function terminate(process: ChildProcess, cwd?: string): boolean {
|
||||
if (isWindows) {
|
||||
try {
|
||||
// This we run in Atom execFileSync is available.
|
||||
// Ignore stderr since this is otherwise piped to parent.stderr
|
||||
// which might be already closed.
|
||||
let options: any = {
|
||||
stdio: ['pipe', 'pipe', 'ignore']
|
||||
};
|
||||
if (cwd) {
|
||||
options.cwd = cwd
|
||||
}
|
||||
(<any>cp).execFileSync('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
} else if (isLinux || isMacintosh) {
|
||||
try {
|
||||
var cmd = join(__dirname, 'terminateProcess.sh');
|
||||
var result = (<any>cp).spawnSync(cmd, [process.pid.toString()]);
|
||||
return result.error ? false : true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
process.kill('SIGKILL');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
16
dataprotocol-node/client/src/utils/terminateProcess.sh
Normal file
16
dataprotocol-node/client/src/utils/terminateProcess.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
# --------------------------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
terminateTree() {
|
||||
for cpid in $(pgrep -P $1); do
|
||||
terminateTree $cpid
|
||||
done
|
||||
kill -9 $1 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
for pid in $*; do
|
||||
terminateTree $pid
|
||||
done
|
||||
31
dataprotocol-node/client/thirdpartynotices.txt
Normal file
31
dataprotocol-node/client/thirdpartynotices.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
|
||||
For Microsoft vscode-languageclient
|
||||
|
||||
This project incorporates material from the project(s) listed below (collectively, “Third Party Code”).
|
||||
Microsoft is not the original author of the Third Party Code. The original copyright notice and license
|
||||
under which Microsoft received such Third Party Code are set out below. This Third Party Code is licensed
|
||||
to you under their original license terms set forth below. Microsoft reserves all other rights not expressly
|
||||
granted, whether by implication, estoppel or otherwise.
|
||||
|
||||
1. DefinitelyTyped version 0.0.1 (https://github.com/borisyankov/DefinitelyTyped)
|
||||
|
||||
This project is licensed under the MIT license.
|
||||
Copyrights are respective of each contributor listed at the beginning of each definition file.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
24
dataprotocol-node/jsonrpc/.eslintrc
Normal file
24
dataprotocol-node/jsonrpc/.eslintrc
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"rules": {
|
||||
"indent": [
|
||||
2,
|
||||
"tab"
|
||||
],
|
||||
"quotes": [
|
||||
2,
|
||||
"single"
|
||||
],
|
||||
"linebreak-style": [
|
||||
2,
|
||||
"windows"
|
||||
],
|
||||
"semi": [
|
||||
2,
|
||||
"always"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
||||
9
dataprotocol-node/jsonrpc/.npmignore
Normal file
9
dataprotocol-node/jsonrpc/.npmignore
Normal file
@@ -0,0 +1,9 @@
|
||||
.vscode/
|
||||
lib/test/
|
||||
lib/*.map
|
||||
src/
|
||||
test/
|
||||
.eslintrc
|
||||
.gitignore
|
||||
gulpfile.js
|
||||
tsd.json
|
||||
32
dataprotocol-node/jsonrpc/.vscode/launch.json
vendored
Normal file
32
dataprotocol-node/jsonrpc/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
// List of configurations. Add new configurations or edit existing ones.
|
||||
// ONLY "node" and "mono" are supported, change "type" to switch.
|
||||
"configurations": [
|
||||
{
|
||||
"request": "launch",
|
||||
// Name of configuration; appears in the launch configuration drop down menu.
|
||||
"name": "Mocha",
|
||||
// Type of configuration. Possible values: "node", "mono".
|
||||
"type": "node",
|
||||
// Workspace relative or absolute path to the program.
|
||||
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
|
||||
// Automatically stop program after launch.
|
||||
"stopOnEntry": false,
|
||||
// Command line arguments passed to the program.
|
||||
"args": ["--timeout", "999999"],
|
||||
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
|
||||
"cwd": "${workspaceRoot}",
|
||||
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
|
||||
"runtimeExecutable": null,
|
||||
// Optional arguments passed to the runtime executable.
|
||||
"runtimeArgs": [],
|
||||
// Environment variables passed to the program.
|
||||
"env": { },
|
||||
// Use JavaScript source maps (if they exist).
|
||||
"sourceMaps": true,
|
||||
// If JavaScript source maps are enabled, the generated code is expected in this directory.
|
||||
"outDir": "${workspaceRoot}/lib"
|
||||
}
|
||||
]
|
||||
}
|
||||
9
dataprotocol-node/jsonrpc/.vscode/settings.json
vendored
Normal file
9
dataprotocol-node/jsonrpc/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"javascript.validate.enable": false,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"eslint.enable": false,
|
||||
"editor.insertSpaces": false,
|
||||
"editor.tabSize": 4,
|
||||
"typescript.tsdk": "./node_modules/typescript/lib"
|
||||
}
|
||||
9
dataprotocol-node/jsonrpc/.vscode/tasks.json
vendored
Normal file
9
dataprotocol-node/jsonrpc/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "npm",
|
||||
"isShellCommand": true,
|
||||
"args": ["run", "watch"],
|
||||
"showOutput": "silent",
|
||||
"isWatching": true,
|
||||
"problemMatcher": "$tsc-watch"
|
||||
}
|
||||
4
dataprotocol-node/jsonrpc/README.md
Normal file
4
dataprotocol-node/jsonrpc/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Microsoft Data Management Protocol - Node
|
||||
|
||||
## License
|
||||
[MIT](https://github.com/Microsoft/carbon/blob/dev/license.txt)
|
||||
29
dataprotocol-node/jsonrpc/package.json
Normal file
29
dataprotocol-node/jsonrpc/package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "dataprotocol-jsonrpc",
|
||||
"description": "A json rpc implementation over streams",
|
||||
"version": "2.4.0",
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/vscode-languageserver-node.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0 || >=6.0.0"
|
||||
},
|
||||
"main": "./lib/main.js",
|
||||
"typings": "./lib/main",
|
||||
"devDependencies": {
|
||||
"mocha": "^3.0.2",
|
||||
"typescript": "2.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "tsc -p ./src",
|
||||
"compile": "tsc -p ./src",
|
||||
"watch": "tsc -w -p ./src",
|
||||
"test": "mocha"
|
||||
}
|
||||
}
|
||||
97
dataprotocol-node/jsonrpc/src/cancellation.ts
Normal file
97
dataprotocol-node/jsonrpc/src/cancellation.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { Event, Emitter } from './events';
|
||||
|
||||
export interface CancellationToken {
|
||||
/**
|
||||
* Is `true` when the token has been cancelled, `false` otherwise.
|
||||
*/
|
||||
isCancellationRequested: boolean;
|
||||
|
||||
/**
|
||||
* An [event](#Event) which fires upon cancellation.
|
||||
*/
|
||||
onCancellationRequested: Event<any>;
|
||||
}
|
||||
|
||||
export namespace CancellationToken {
|
||||
|
||||
export const None: CancellationToken = Object.freeze({
|
||||
isCancellationRequested: false,
|
||||
onCancellationRequested: Event.None
|
||||
});
|
||||
|
||||
export const Cancelled: CancellationToken = Object.freeze({
|
||||
isCancellationRequested: true,
|
||||
onCancellationRequested: Event.None
|
||||
});
|
||||
}
|
||||
|
||||
const shortcutEvent: Event<any> = Object.freeze(function (callback, context?) {
|
||||
let handle = setTimeout(callback.bind(context), 0);
|
||||
return { dispose() { clearTimeout(handle); } };
|
||||
});
|
||||
|
||||
class MutableToken implements CancellationToken {
|
||||
|
||||
private _isCancelled: boolean = false;
|
||||
private _emitter: Emitter<any>;
|
||||
|
||||
public cancel() {
|
||||
if (!this._isCancelled) {
|
||||
this._isCancelled = true;
|
||||
if (this._emitter) {
|
||||
this._emitter.fire(undefined);
|
||||
this._emitter = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get isCancellationRequested(): boolean {
|
||||
return this._isCancelled;
|
||||
}
|
||||
|
||||
get onCancellationRequested(): Event<any> {
|
||||
if (this._isCancelled) {
|
||||
return shortcutEvent;
|
||||
}
|
||||
if (!this._emitter) {
|
||||
this._emitter = new Emitter<any>();
|
||||
}
|
||||
return this._emitter.event;
|
||||
}
|
||||
}
|
||||
|
||||
export class CancellationTokenSource {
|
||||
|
||||
private _token: CancellationToken;
|
||||
|
||||
get token(): CancellationToken {
|
||||
if (!this._token) {
|
||||
// be lazy and create the token only when
|
||||
// actually needed
|
||||
this._token = new MutableToken();
|
||||
}
|
||||
return this._token;
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
if (!this._token) {
|
||||
// save an object by returning the default
|
||||
// cancelled token when cancellation happens
|
||||
// before someone asks for the token
|
||||
this._token = CancellationToken.Cancelled;
|
||||
} else {
|
||||
(<MutableToken>this._token).cancel();
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
213
dataprotocol-node/jsonrpc/src/events.ts
Normal file
213
dataprotocol-node/jsonrpc/src/events.ts
Normal file
@@ -0,0 +1,213 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 interface Disposable {
|
||||
/**
|
||||
* Dispose this object.
|
||||
*/
|
||||
dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a typed event.
|
||||
*/
|
||||
export interface Event<T> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param listener The listener function will be call when the event happens.
|
||||
* @param thisArgs The 'this' which will be used when calling the event listener.
|
||||
* @param disposables An array to which a {{IDisposable}} will be added. The
|
||||
* @return
|
||||
*/
|
||||
(listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
|
||||
}
|
||||
|
||||
export namespace Event {
|
||||
const _disposable = { dispose() { } };
|
||||
export const None: Event<any> = function () { return _disposable; };
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a type which can release resources, such
|
||||
* as event listening or a timer.
|
||||
*/
|
||||
class DisposableImpl implements Disposable {
|
||||
|
||||
/**
|
||||
* Combine many disposable-likes into one. Use this method
|
||||
* when having objects with a dispose function which are not
|
||||
* instances of Disposable.
|
||||
*
|
||||
* @return Returns a new disposable which, upon dispose, will
|
||||
* dispose all provides disposable-likes.
|
||||
*/
|
||||
static from(...disposables: { dispose(): any }[]): DisposableImpl {
|
||||
return new DisposableImpl(function () {
|
||||
if (disposables) {
|
||||
for (let disposable of disposables) {
|
||||
disposable.dispose();
|
||||
}
|
||||
disposables = undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private _callOnDispose: Function;
|
||||
|
||||
constructor(callOnDispose: Function) {
|
||||
this._callOnDispose = callOnDispose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose this object.
|
||||
*/
|
||||
dispose(): any {
|
||||
if (typeof this._callOnDispose === 'function') {
|
||||
this._callOnDispose();
|
||||
this._callOnDispose = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CallbackList {
|
||||
|
||||
private _callbacks: Function[];
|
||||
private _contexts: any[];
|
||||
|
||||
public add(callback: Function, context: any = null, bucket?: Disposable[]): void {
|
||||
if (!this._callbacks) {
|
||||
this._callbacks = [];
|
||||
this._contexts = [];
|
||||
}
|
||||
this._callbacks.push(callback);
|
||||
this._contexts.push(context);
|
||||
|
||||
if (Array.isArray(bucket)) {
|
||||
bucket.push({ dispose: () => this.remove(callback, context) });
|
||||
}
|
||||
}
|
||||
|
||||
public remove(callback: Function, context: any = null): void {
|
||||
if (!this._callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
var foundCallbackWithDifferentContext = false;
|
||||
for (var i = 0, len = this._callbacks.length; i < len; i++) {
|
||||
if (this._callbacks[i] === callback) {
|
||||
if (this._contexts[i] === context) {
|
||||
// callback & context match => remove it
|
||||
this._callbacks.splice(i, 1);
|
||||
this._contexts.splice(i, 1);
|
||||
return;
|
||||
} else {
|
||||
foundCallbackWithDifferentContext = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundCallbackWithDifferentContext) {
|
||||
throw new Error('When adding a listener with a context, you should remove it with the same context');
|
||||
}
|
||||
}
|
||||
|
||||
public invoke(...args: any[]): any[] {
|
||||
if (!this._callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
var ret: any[] = [],
|
||||
callbacks = this._callbacks.slice(0),
|
||||
contexts = this._contexts.slice(0);
|
||||
|
||||
for (var i = 0, len = callbacks.length; i < len; i++) {
|
||||
try {
|
||||
ret.push(callbacks[i].apply(contexts[i], args));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public isEmpty(): boolean {
|
||||
return !this._callbacks || this._callbacks.length === 0;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._callbacks = undefined;
|
||||
this._contexts = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export interface EmitterOptions {
|
||||
onFirstListenerAdd?: Function;
|
||||
onLastListenerRemove?: Function;
|
||||
}
|
||||
|
||||
export class Emitter<T> {
|
||||
|
||||
private static _noop = function () { };
|
||||
|
||||
private _event: Event<T>;
|
||||
private _callbacks: CallbackList;
|
||||
|
||||
constructor(private _options?: EmitterOptions) {
|
||||
}
|
||||
|
||||
/**
|
||||
* For the public to allow to subscribe
|
||||
* to events from this Emitter
|
||||
*/
|
||||
get event(): Event<T> {
|
||||
if (!this._event) {
|
||||
this._event = (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]) => {
|
||||
if (!this._callbacks) {
|
||||
this._callbacks = new CallbackList();
|
||||
}
|
||||
if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
|
||||
this._options.onFirstListenerAdd(this);
|
||||
}
|
||||
this._callbacks.add(listener, thisArgs);
|
||||
|
||||
let result: Disposable;
|
||||
result = {
|
||||
dispose: () => {
|
||||
this._callbacks.remove(listener, thisArgs);
|
||||
result.dispose = Emitter._noop;
|
||||
if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
|
||||
this._options.onLastListenerRemove(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Array.isArray(disposables)) {
|
||||
disposables.push(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
return this._event;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be kept private to fire an event to
|
||||
* subscribers
|
||||
*/
|
||||
fire(event: T): any {
|
||||
if (this._callbacks) {
|
||||
this._callbacks.invoke.call(this._callbacks, event);
|
||||
}
|
||||
}
|
||||
|
||||
dispose() {
|
||||
if (this._callbacks) {
|
||||
this._callbacks.dispose();
|
||||
this._callbacks = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
dataprotocol-node/jsonrpc/src/is.ts
Normal file
47
dataprotocol-node/jsonrpc/src/is.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
'use strict';
|
||||
|
||||
const toString = Object.prototype.toString;
|
||||
|
||||
export function defined(value: any): boolean {
|
||||
return typeof value !== 'undefined';
|
||||
}
|
||||
|
||||
export function undefined(value: any): boolean {
|
||||
return typeof value === 'undefined';
|
||||
}
|
||||
|
||||
export function nil(value: any): boolean {
|
||||
return value === null;
|
||||
}
|
||||
|
||||
export function boolean(value: any): value is boolean {
|
||||
return value === true || value === false;
|
||||
}
|
||||
|
||||
export function string(value: any): value is string {
|
||||
return toString.call(value) === '[object String]';
|
||||
}
|
||||
|
||||
export function number(value: any): value is number {
|
||||
return toString.call(value) === '[object Number]';
|
||||
}
|
||||
|
||||
export function error(value: any): value is Error {
|
||||
return toString.call(value) === '[object Error]';
|
||||
}
|
||||
|
||||
export function func(value: any): value is Function {
|
||||
return toString.call(value) === '[object Function]';
|
||||
}
|
||||
|
||||
export function array<T>(value: any): value is T[] {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
|
||||
export function stringArray(value: any): value is string[] {
|
||||
return array(value) && (<any[]>value).every(elem => string(elem));
|
||||
}
|
||||
576
dataprotocol-node/jsonrpc/src/main.ts
Normal file
576
dataprotocol-node/jsonrpc/src/main.ts
Normal file
@@ -0,0 +1,576 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 is from './is';
|
||||
|
||||
import {
|
||||
Message,
|
||||
RequestMessage, RequestType, isRequestMessage,
|
||||
ResponseMessage, isReponseMessage, ResponseError, ErrorCodes,
|
||||
NotificationMessage, NotificationType, isNotificationMessage
|
||||
} from './messages';
|
||||
|
||||
import { MessageReader, DataCallback, StreamMessageReader, IPCMessageReader } from './messageReader';
|
||||
import { MessageWriter, StreamMessageWriter, IPCMessageWriter } from './messageWriter';
|
||||
import { Disposable, Event, Emitter } from './events';
|
||||
import { CancellationTokenSource, CancellationToken } from './cancellation';
|
||||
|
||||
export {
|
||||
Message, ErrorCodes, ResponseError,
|
||||
RequestMessage, RequestType,
|
||||
NotificationMessage, NotificationType,
|
||||
MessageReader, DataCallback, StreamMessageReader, IPCMessageReader,
|
||||
MessageWriter, StreamMessageWriter, IPCMessageWriter,
|
||||
CancellationTokenSource, CancellationToken,
|
||||
Disposable, Event, Emitter
|
||||
}
|
||||
|
||||
interface CancelParams {
|
||||
/**
|
||||
* The request id to cancel.
|
||||
*/
|
||||
id: number | string;
|
||||
}
|
||||
|
||||
namespace CancelNotification {
|
||||
export const type: NotificationType<CancelParams> = { get method() { return '$/cancelRequest'; } };
|
||||
}
|
||||
|
||||
export interface RequestHandler<P, R, E> {
|
||||
(params: P, token: CancellationToken): R | ResponseError<E> | Thenable<R | ResponseError<E>>;
|
||||
}
|
||||
|
||||
export interface NotificationHandler<P> {
|
||||
(params: P): void;
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
error(message: string): void;
|
||||
warn(message: string): void;
|
||||
info(message: string): void;
|
||||
log(message: string): void;
|
||||
}
|
||||
|
||||
export enum Trace {
|
||||
Off, Messages, Verbose
|
||||
}
|
||||
|
||||
export type TraceValues = 'off' | 'messages' | 'verbose';
|
||||
export namespace Trace {
|
||||
export function fromString(value: string): Trace {
|
||||
value = value.toLowerCase();
|
||||
switch (value) {
|
||||
case 'off':
|
||||
return Trace.Off;
|
||||
case 'messages':
|
||||
return Trace.Messages;
|
||||
case 'verbose':
|
||||
return Trace.Verbose;
|
||||
default:
|
||||
return Trace.Off;
|
||||
}
|
||||
}
|
||||
|
||||
export function toString(value: Trace): TraceValues {
|
||||
switch (value) {
|
||||
case Trace.Off:
|
||||
return 'off';
|
||||
case Trace.Messages:
|
||||
return 'messages';
|
||||
case Trace.Verbose:
|
||||
return 'verbose';
|
||||
default:
|
||||
return 'off';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface SetTraceParams {
|
||||
value: TraceValues;
|
||||
}
|
||||
|
||||
export namespace SetTraceNotification {
|
||||
export const type: NotificationType<SetTraceParams> = { get method() { return '$/setTraceNotification'; } };
|
||||
}
|
||||
|
||||
export interface LogTraceParams {
|
||||
message: string;
|
||||
verbose?: string;
|
||||
}
|
||||
|
||||
export namespace LogTraceNotification {
|
||||
export const type: NotificationType<LogTraceParams> = { get method() { return '$/logTraceNotification'; } };
|
||||
}
|
||||
|
||||
export interface Tracer {
|
||||
log(message: string, data?: string): void;
|
||||
}
|
||||
|
||||
export interface MessageConnection {
|
||||
sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Thenable<R>;
|
||||
onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): void;
|
||||
sendNotification<P>(type: NotificationType<P>, params?: P): void;
|
||||
onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): void;
|
||||
trace(value: Trace, tracer: Tracer, sendNotification?: boolean): void;
|
||||
onError: Event<[Error, Message, number]>;
|
||||
onClose: Event<void>;
|
||||
onUnhandledNotification: Event<NotificationMessage>;
|
||||
listen();
|
||||
onDispose: Event<void>;
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
export interface ServerMessageConnection extends MessageConnection {
|
||||
}
|
||||
|
||||
export interface ClientMessageConnection extends MessageConnection {
|
||||
}
|
||||
|
||||
interface ResponsePromise {
|
||||
method: string;
|
||||
timerStart: number;
|
||||
resolve: (response) => void;
|
||||
reject: (error: any) => void
|
||||
}
|
||||
|
||||
enum ConnectionState {
|
||||
New = 1,
|
||||
Listening = 2,
|
||||
Closed = 3,
|
||||
Disposed = 4
|
||||
}
|
||||
|
||||
function createMessageConnection<T extends MessageConnection>(messageReader: MessageReader, messageWriter: MessageWriter, logger: Logger, client: boolean = false): T {
|
||||
let sequenceNumber = 0;
|
||||
const version: string = '2.0';
|
||||
|
||||
let requestHandlers: { [name: string]: RequestHandler<any, any, any> } = Object.create(null);
|
||||
let eventHandlers: { [name: string]: NotificationHandler<any> } = Object.create(null);
|
||||
|
||||
let responsePromises: { [name: string]: ResponsePromise } = Object.create(null);
|
||||
let requestTokens: { [id: string]: CancellationTokenSource } = Object.create(null);
|
||||
|
||||
let trace: Trace = Trace.Off;
|
||||
let tracer: Tracer;
|
||||
|
||||
let state: ConnectionState = ConnectionState.New;
|
||||
let errorEmitter: Emitter<[Error, Message, number]> = new Emitter<[Error, Message, number]>();
|
||||
let closeEmitter: Emitter<void> = new Emitter<void>();
|
||||
let unhandledNotificationEmitter: Emitter<NotificationMessage> = new Emitter<NotificationMessage>();
|
||||
let disposeEmitter: Emitter<void> = new Emitter<void>();
|
||||
|
||||
function isListening(): boolean {
|
||||
return state === ConnectionState.Listening;
|
||||
}
|
||||
|
||||
function isClosed(): boolean {
|
||||
return state === ConnectionState.Closed;
|
||||
}
|
||||
|
||||
function isDisposed(): boolean {
|
||||
return state === ConnectionState.Disposed;
|
||||
}
|
||||
|
||||
function closeHandler(): void {
|
||||
if (state === ConnectionState.New || state === ConnectionState.Listening) {
|
||||
state = ConnectionState.Closed;
|
||||
closeEmitter.fire(undefined);
|
||||
}
|
||||
// If the connection is disposed don't sent close events.
|
||||
};
|
||||
|
||||
function readErrorHandler(error: Error): void {
|
||||
errorEmitter.fire([error, undefined, undefined]);
|
||||
}
|
||||
|
||||
function writeErrorHandler(data: [Error, Message, number]): void {
|
||||
errorEmitter.fire(data);
|
||||
}
|
||||
|
||||
messageReader.onClose(closeHandler);
|
||||
messageReader.onError(readErrorHandler);
|
||||
|
||||
messageWriter.onClose(closeHandler);
|
||||
messageWriter.onError(writeErrorHandler);
|
||||
|
||||
function handleRequest(requestMessage: RequestMessage) {
|
||||
if (isDisposed()) {
|
||||
// we return here silently since we fired an event when the
|
||||
// connection got disposed.
|
||||
return;
|
||||
}
|
||||
|
||||
function reply(resultOrError: any | ResponseError<any>): void {
|
||||
let message: ResponseMessage = {
|
||||
jsonrpc: version,
|
||||
id: requestMessage.id
|
||||
};
|
||||
if (resultOrError instanceof ResponseError) {
|
||||
message.error = (<ResponseError<any>>resultOrError).toJson();
|
||||
} else {
|
||||
message.result = is.undefined(resultOrError) ? null : resultOrError;
|
||||
}
|
||||
messageWriter.write(message);
|
||||
}
|
||||
function replyError(error: ResponseError<any>) {
|
||||
let message: ResponseMessage = {
|
||||
jsonrpc: version,
|
||||
id: requestMessage.id,
|
||||
error: error.toJson()
|
||||
};
|
||||
messageWriter.write(message);
|
||||
}
|
||||
function replySuccess(result: any) {
|
||||
// The JSON RPC defines that a response must either have a result or an error
|
||||
// So we can't treat undefined as a valid response result.
|
||||
if (is.undefined(result)) {
|
||||
result = null;
|
||||
}
|
||||
let message: ResponseMessage = {
|
||||
jsonrpc: version,
|
||||
id: requestMessage.id,
|
||||
result: result
|
||||
};
|
||||
messageWriter.write(message);
|
||||
}
|
||||
|
||||
let requestHandler = requestHandlers[requestMessage.method];
|
||||
if (requestHandler) {
|
||||
let cancellationSource = new CancellationTokenSource();
|
||||
let tokenKey = String(requestMessage.id);
|
||||
requestTokens[tokenKey] = cancellationSource;
|
||||
try {
|
||||
let handlerResult = requestHandler(requestMessage.params, cancellationSource.token);
|
||||
let promise = <Thenable<any | ResponseError<any>>>handlerResult;
|
||||
if (!handlerResult) {
|
||||
delete requestTokens[tokenKey];
|
||||
replySuccess(handlerResult);
|
||||
} else if (promise.then) {
|
||||
promise.then((resultOrError): any | ResponseError<any> => {
|
||||
delete requestTokens[tokenKey];
|
||||
reply(resultOrError);
|
||||
}, error => {
|
||||
delete requestTokens[tokenKey];
|
||||
if (error instanceof ResponseError) {
|
||||
replyError(<ResponseError<any>>error);
|
||||
} else if (error && is.string(error.message)) {
|
||||
replyError(new ResponseError<void>(ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`));
|
||||
} else {
|
||||
replyError(new ResponseError<void>(ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
delete requestTokens[tokenKey];
|
||||
reply(handlerResult);
|
||||
}
|
||||
} catch (error) {
|
||||
delete requestTokens[tokenKey];
|
||||
if (error instanceof ResponseError) {
|
||||
reply(<ResponseError<any>>error);
|
||||
} else if (error && is.string(error.message)) {
|
||||
replyError(new ResponseError<void>(ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`));
|
||||
} else {
|
||||
replyError(new ResponseError<void>(ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
replyError(new ResponseError<void>(ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`));
|
||||
}
|
||||
}
|
||||
|
||||
function handleResponse(responseMessage: ResponseMessage) {
|
||||
if (isDisposed()) {
|
||||
// See handle request.
|
||||
return;
|
||||
}
|
||||
|
||||
let key = String(responseMessage.id);
|
||||
let responsePromise = responsePromises[key];
|
||||
if (trace != Trace.Off && tracer) {
|
||||
traceResponse(responseMessage, responsePromise);
|
||||
}
|
||||
if (responsePromise) {
|
||||
delete responsePromises[key];
|
||||
try {
|
||||
if (is.defined(responseMessage.error)) {
|
||||
let error = responseMessage.error;
|
||||
responsePromise.reject(new ResponseError(error.code, error.message, error.data));
|
||||
} else if (is.defined(responseMessage.result)) {
|
||||
responsePromise.resolve(responseMessage.result);
|
||||
} else {
|
||||
throw new Error('Should never happen.');
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.message) {
|
||||
logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
|
||||
} else {
|
||||
logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleNotification(message: NotificationMessage) {
|
||||
if (isDisposed()) {
|
||||
// See handle request.
|
||||
return;
|
||||
}
|
||||
let eventHandler: NotificationHandler<any>;
|
||||
if (message.method === CancelNotification.type.method) {
|
||||
eventHandler = (params: CancelParams) => {
|
||||
let id = params.id;
|
||||
let source = requestTokens[String(id)];
|
||||
if (source) {
|
||||
source.cancel();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eventHandler = eventHandlers[message.method];
|
||||
}
|
||||
if (eventHandler) {
|
||||
try {
|
||||
if (trace != Trace.Off && tracer) {
|
||||
traceReceivedNotification(message);
|
||||
}
|
||||
eventHandler(message.params);
|
||||
} catch (error) {
|
||||
if (error.message) {
|
||||
logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
|
||||
} else {
|
||||
logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unhandledNotificationEmitter.fire(message);
|
||||
}
|
||||
}
|
||||
|
||||
function handleInvalidMessage(message: Message) {
|
||||
if (!message) {
|
||||
logger.error('Received empty message.');
|
||||
return;
|
||||
}
|
||||
logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
|
||||
// Test whether we find an id to reject the promise
|
||||
let responseMessage: ResponseMessage = message as ResponseMessage;
|
||||
if (is.string(responseMessage.id) || is.number(responseMessage.id)) {
|
||||
let key = String(responseMessage.id);
|
||||
let responseHandler = responsePromises[key];
|
||||
if (responseHandler) {
|
||||
responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function traceRequest(message: RequestMessage): void {
|
||||
let data: string = undefined;
|
||||
if (trace === Trace.Verbose && message.params) {
|
||||
data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
|
||||
}
|
||||
tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
|
||||
}
|
||||
|
||||
function traceSendNotification(message: NotificationMessage): void {
|
||||
let data: string = undefined;
|
||||
if (trace === Trace.Verbose) {
|
||||
if (message.params) {
|
||||
data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
|
||||
} else {
|
||||
data = 'No parameters provided.\n\n';
|
||||
}
|
||||
}
|
||||
tracer.log(`Sending notification '${message.method}'.`, data);
|
||||
}
|
||||
|
||||
function traceReceivedNotification(message: NotificationMessage): void {
|
||||
if (message.method === LogTraceNotification.type.method) {
|
||||
return;
|
||||
}
|
||||
let data: string = undefined;
|
||||
if (trace === Trace.Verbose) {
|
||||
if (message.params) {
|
||||
data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
|
||||
} else {
|
||||
data = 'No parameters provided.\n\n';
|
||||
}
|
||||
}
|
||||
tracer.log(`Received notification '${message.method}'.`, data);
|
||||
}
|
||||
|
||||
function traceResponse(message: ResponseMessage, responsePromise: ResponsePromise): void {
|
||||
let data: string = undefined;
|
||||
if (trace === Trace.Verbose) {
|
||||
if (message.error && message.error.data) {
|
||||
data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
|
||||
} else {
|
||||
if (message.result) {
|
||||
data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
|
||||
} else if (is.undefined(message.error)) {
|
||||
data = 'No result returned.\n\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (responsePromise) {
|
||||
let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
|
||||
tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
|
||||
} else {
|
||||
tracer.log(`Received response ${message.id} without active response promise.`, data);
|
||||
}
|
||||
}
|
||||
|
||||
let callback: DataCallback = (message) => {
|
||||
if (isRequestMessage(message)) {
|
||||
handleRequest(message);
|
||||
} else if (isReponseMessage(message)) {
|
||||
handleResponse(message)
|
||||
} else if (isNotificationMessage(message)) {
|
||||
handleNotification(message);
|
||||
} else {
|
||||
handleInvalidMessage(message);
|
||||
}
|
||||
};
|
||||
|
||||
function throwIfClosedOrDisposed() {
|
||||
if (isClosed()) {
|
||||
throw new Error('Connection is closed.');
|
||||
}
|
||||
if (isDisposed()) {
|
||||
throw new Error('Connection is disposed.');
|
||||
}
|
||||
}
|
||||
|
||||
function throwIfListening() {
|
||||
if (isListening()) {
|
||||
throw new Error('Connection is already listening');
|
||||
}
|
||||
}
|
||||
|
||||
let connection: MessageConnection = {
|
||||
sendNotification: <P>(type: NotificationType<P>, params): void => {
|
||||
throwIfClosedOrDisposed();
|
||||
|
||||
let notificatioMessage: NotificationMessage = {
|
||||
jsonrpc: version,
|
||||
method: type.method,
|
||||
params: params
|
||||
}
|
||||
if (trace != Trace.Off && tracer) {
|
||||
traceSendNotification(notificatioMessage);
|
||||
}
|
||||
messageWriter.write(notificatioMessage);
|
||||
},
|
||||
onNotification: <P>(type: NotificationType<P>, handler: NotificationHandler<P>) => {
|
||||
throwIfClosedOrDisposed();
|
||||
|
||||
eventHandlers[type.method] = handler;
|
||||
},
|
||||
sendRequest: <P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken) => {
|
||||
throwIfClosedOrDisposed();
|
||||
|
||||
let id = sequenceNumber++;
|
||||
let result = new Promise<R | ResponseError<E>>((resolve, reject) => {
|
||||
let requestMessage: RequestMessage = {
|
||||
jsonrpc: version,
|
||||
id: id,
|
||||
method: type.method,
|
||||
params: params
|
||||
}
|
||||
let responsePromise: ResponsePromise = { method: type.method, timerStart: Date.now(), resolve, reject };
|
||||
if (trace != Trace.Off && tracer) {
|
||||
traceRequest(requestMessage);
|
||||
}
|
||||
try {
|
||||
messageWriter.write(requestMessage);
|
||||
} catch (e) {
|
||||
// Writing the message failed. So we need to reject the promise.
|
||||
responsePromise.reject(new ResponseError<void>(ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
|
||||
responsePromise = null;
|
||||
}
|
||||
if (responsePromise) {
|
||||
responsePromises[String(id)] = responsePromise;
|
||||
}
|
||||
});
|
||||
if (token) {
|
||||
token.onCancellationRequested((event) => {
|
||||
connection.sendNotification(CancelNotification.type, { id });
|
||||
});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
onRequest: <P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>) => {
|
||||
throwIfClosedOrDisposed();
|
||||
|
||||
requestHandlers[type.method] = handler;
|
||||
},
|
||||
trace: (_value: Trace, _tracer: Tracer, sendNotification: boolean = false) => {
|
||||
trace = _value;
|
||||
if (trace === Trace.Off) {
|
||||
tracer = null;
|
||||
} else {
|
||||
tracer = _tracer;
|
||||
}
|
||||
if (sendNotification && !isClosed() && !isDisposed()) {
|
||||
connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
|
||||
}
|
||||
},
|
||||
onError: errorEmitter.event,
|
||||
onClose: closeEmitter.event,
|
||||
onUnhandledNotification: unhandledNotificationEmitter.event,
|
||||
onDispose: disposeEmitter.event,
|
||||
dispose: () => {
|
||||
if (isDisposed()) {
|
||||
return;
|
||||
}
|
||||
state = ConnectionState.Disposed;
|
||||
disposeEmitter.fire(undefined);
|
||||
let error = new Error('Connection got disposed.');
|
||||
Object.keys(responsePromises).forEach((key) => {
|
||||
responsePromises[key].reject(error);
|
||||
});
|
||||
responsePromises = Object.create(null);
|
||||
requestTokens = Object.create(null);
|
||||
},
|
||||
listen: () => {
|
||||
throwIfClosedOrDisposed();
|
||||
throwIfListening();
|
||||
|
||||
state = ConnectionState.Listening;
|
||||
messageReader.listen(callback);
|
||||
}
|
||||
};
|
||||
|
||||
connection.onNotification(LogTraceNotification.type, (params) => {
|
||||
if (trace === Trace.Off) {
|
||||
return;
|
||||
}
|
||||
tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
|
||||
});
|
||||
return connection as T;
|
||||
}
|
||||
|
||||
function isMessageReader(value: any): value is MessageReader {
|
||||
return is.defined(value.listen) && is.undefined(value.read);
|
||||
}
|
||||
|
||||
function isMessageWriter(value: any): value is MessageWriter {
|
||||
return is.defined(value.write) && is.undefined(value.end);
|
||||
}
|
||||
|
||||
export function createServerMessageConnection(reader: MessageReader, writer: MessageWriter, logger: Logger): ServerMessageConnection;
|
||||
export function createServerMessageConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, logger: Logger): ServerMessageConnection;
|
||||
export function createServerMessageConnection(input: MessageReader | NodeJS.ReadableStream, output: MessageWriter | NodeJS.WritableStream, logger: Logger): ServerMessageConnection {
|
||||
let reader = isMessageReader(input) ? input : new StreamMessageReader(input);
|
||||
let writer = isMessageWriter(output) ? output : new StreamMessageWriter(output);
|
||||
return createMessageConnection<ServerMessageConnection>(reader, writer, logger);
|
||||
}
|
||||
|
||||
export function createClientMessageConnection(reader: MessageReader, writer: MessageWriter, logger: Logger): ClientMessageConnection;
|
||||
export function createClientMessageConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, logger: Logger): ClientMessageConnection;
|
||||
export function createClientMessageConnection(input: MessageReader | NodeJS.ReadableStream, output: MessageWriter | NodeJS.WritableStream, logger: Logger): ClientMessageConnection {
|
||||
let reader = isMessageReader(input) ? input : new StreamMessageReader(input);
|
||||
let writer = isMessageWriter(output) ? output : new StreamMessageWriter(output);
|
||||
return createMessageConnection<ClientMessageConnection>(reader, writer, logger, true);
|
||||
}
|
||||
265
dataprotocol-node/jsonrpc/src/messageReader.ts
Normal file
265
dataprotocol-node/jsonrpc/src/messageReader.ts
Normal file
@@ -0,0 +1,265 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 { ChildProcess } from 'child_process';
|
||||
|
||||
import { Message } from './messages';
|
||||
import { Event, Emitter } from './events';
|
||||
import * as is from './is';
|
||||
|
||||
let DefaultSize: number = 8192;
|
||||
let CR: number = new Buffer('\r', 'ascii')[0];
|
||||
let LF: number = new Buffer('\n', 'ascii')[0];
|
||||
let CRLF: string = '\r\n';
|
||||
|
||||
class MessageBuffer {
|
||||
|
||||
private encoding: string;
|
||||
private index: number;
|
||||
private buffer: Buffer;
|
||||
|
||||
constructor(encoding: string = 'utf-8') {
|
||||
this.encoding = encoding;
|
||||
this.index = 0;
|
||||
this.buffer = new Buffer(DefaultSize);
|
||||
}
|
||||
|
||||
public append(chunk: Buffer | String): void {
|
||||
var toAppend: Buffer = <Buffer>chunk;
|
||||
if (typeof (chunk) == 'string') {
|
||||
var str = <string>chunk;
|
||||
toAppend = new Buffer(str.length);
|
||||
toAppend.write(str, 0, str.length, this.encoding);
|
||||
}
|
||||
if (this.buffer.length - this.index >= toAppend.length) {
|
||||
toAppend.copy(this.buffer, this.index, 0, toAppend.length);
|
||||
} else {
|
||||
var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
|
||||
if (this.index === 0) {
|
||||
this.buffer = new Buffer(newSize);
|
||||
toAppend.copy(this.buffer, 0, 0, toAppend.length);
|
||||
} else {
|
||||
this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
|
||||
}
|
||||
}
|
||||
this.index += toAppend.length;
|
||||
}
|
||||
|
||||
public tryReadHeaders(): { [key: string]: string; } {
|
||||
let result: { [key: string]: string; } = undefined;
|
||||
let current = 0;
|
||||
while (current + 3 < this.index && (this.buffer[current] !== CR || this.buffer[current + 1] !== LF || this.buffer[current + 2] !== CR || this.buffer[current + 3] !== LF)) {
|
||||
current++;
|
||||
}
|
||||
// No header / body separator found (e.g CRLFCRLF)
|
||||
if (current + 3 >= this.index) {
|
||||
return result;
|
||||
}
|
||||
result = Object.create(null);
|
||||
let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
|
||||
headers.forEach((header) => {
|
||||
let index: number = header.indexOf(':');
|
||||
if (index === -1) {
|
||||
throw new Error('Message header must separate key and value using :');
|
||||
}
|
||||
let key = header.substr(0, index);
|
||||
let value = header.substr(index + 1).trim();
|
||||
result[key] = value;
|
||||
})
|
||||
|
||||
let nextStart = current + 4;
|
||||
this.buffer = this.buffer.slice(nextStart);
|
||||
this.index = this.index - nextStart;
|
||||
return result;
|
||||
}
|
||||
|
||||
public tryReadContent(length: number): string {
|
||||
if (this.index < length) {
|
||||
return null;
|
||||
}
|
||||
let result = this.buffer.toString(this.encoding, 0, length);
|
||||
let nextStart = length;
|
||||
this.buffer.copy(this.buffer, 0, nextStart);
|
||||
this.index = this.index - nextStart;
|
||||
return result;
|
||||
}
|
||||
|
||||
public get numberOfBytes(): number {
|
||||
return this.index;
|
||||
}
|
||||
}
|
||||
|
||||
export interface DataCallback {
|
||||
(data: Message): void;
|
||||
}
|
||||
|
||||
export interface PartialMessageInfo {
|
||||
messageToken: number;
|
||||
waitingTime: number;
|
||||
}
|
||||
|
||||
export interface MessageReader {
|
||||
onError: Event<Error>;
|
||||
onClose: Event<void>;
|
||||
onPartialMessage: Event<PartialMessageInfo>;
|
||||
listen(callback: DataCallback): void;
|
||||
}
|
||||
|
||||
export abstract class AbstractMessageReader {
|
||||
|
||||
private errorEmitter: Emitter<Error>;
|
||||
private closeEmitter: Emitter<void>;
|
||||
|
||||
private partialMessageEmitter: Emitter<PartialMessageInfo>;
|
||||
|
||||
constructor() {
|
||||
this.errorEmitter = new Emitter<Error>();
|
||||
this.closeEmitter = new Emitter<void>();
|
||||
this.partialMessageEmitter = new Emitter<PartialMessageInfo>();
|
||||
}
|
||||
|
||||
public get onError(): Event<Error> {
|
||||
return this.errorEmitter.event;
|
||||
}
|
||||
|
||||
protected fireError(error: any): void {
|
||||
this.errorEmitter.fire(this.asError(error));
|
||||
}
|
||||
|
||||
public get onClose(): Event<void> {
|
||||
return this.closeEmitter.event;
|
||||
}
|
||||
|
||||
protected fireClose(): void {
|
||||
this.closeEmitter.fire(undefined);
|
||||
}
|
||||
|
||||
public get onPartialMessage(): Event<PartialMessageInfo> {
|
||||
return this.partialMessageEmitter.event;
|
||||
}
|
||||
|
||||
protected firePartialMessage(info: PartialMessageInfo): void {
|
||||
this.partialMessageEmitter.fire(info);
|
||||
}
|
||||
|
||||
private asError(error: any): Error {
|
||||
if (error instanceof Error) {
|
||||
return error;
|
||||
} else {
|
||||
return new Error(`Reader recevied error. Reason: ${is.string(error.message) ? error.message : 'unknown'}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class StreamMessageReader extends AbstractMessageReader implements MessageReader {
|
||||
|
||||
private readable: NodeJS.ReadableStream;
|
||||
private callback: DataCallback;
|
||||
private buffer: MessageBuffer;
|
||||
private nextMessageLength: number;
|
||||
private messageToken: number;
|
||||
private partialMessageTimer: NodeJS.Timer;
|
||||
private _partialMessageTimeout: number;
|
||||
|
||||
public constructor(readable: NodeJS.ReadableStream, encoding: string = 'utf-8') {
|
||||
super();
|
||||
this.readable = readable;
|
||||
this.buffer = new MessageBuffer(encoding);
|
||||
this._partialMessageTimeout = 10000;
|
||||
}
|
||||
|
||||
public set partialMessageTimeout(timeout: number) {
|
||||
this._partialMessageTimeout = timeout;
|
||||
}
|
||||
|
||||
public get partialMessageTimeout(): number {
|
||||
return this._partialMessageTimeout;
|
||||
}
|
||||
|
||||
public listen(callback: DataCallback): void {
|
||||
this.nextMessageLength = -1;
|
||||
this.messageToken = 0;
|
||||
this.partialMessageTimer = undefined;
|
||||
this.callback = callback;
|
||||
this.readable.on('data', (data: Buffer) => {
|
||||
this.onData(data);
|
||||
});
|
||||
this.readable.on('error', (error: any) => this.fireError(error));
|
||||
this.readable.on('close', () => this.fireClose());
|
||||
}
|
||||
|
||||
private onData(data: Buffer | String): void {
|
||||
this.buffer.append(data);
|
||||
while (true) {
|
||||
if (this.nextMessageLength === -1) {
|
||||
let headers = this.buffer.tryReadHeaders();
|
||||
if (!headers) {
|
||||
return;
|
||||
}
|
||||
let contentLength = headers['Content-Length'];
|
||||
if (!contentLength) {
|
||||
throw new Error('Header must provide a Content-Length property.');
|
||||
}
|
||||
let length = parseInt(contentLength);
|
||||
if (isNaN(length)) {
|
||||
throw new Error('Content-Length value must be a number.');
|
||||
}
|
||||
this.nextMessageLength = length;
|
||||
}
|
||||
var msg = this.buffer.tryReadContent(this.nextMessageLength);
|
||||
if (msg === null) {
|
||||
/** We haven't recevied the full message yet. */
|
||||
this.setPartialMessageTimer();
|
||||
return;
|
||||
}
|
||||
this.clearPartialMessageTimer();
|
||||
this.nextMessageLength = -1;
|
||||
this.messageToken++;
|
||||
var json = JSON.parse(msg);
|
||||
this.callback(json);
|
||||
}
|
||||
}
|
||||
|
||||
private clearPartialMessageTimer(): void {
|
||||
if (this.partialMessageTimer) {
|
||||
clearTimeout(this.partialMessageTimer);
|
||||
this.partialMessageTimer = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private setPartialMessageTimer(): void {
|
||||
this.clearPartialMessageTimer();
|
||||
if (this._partialMessageTimeout <= 0) {
|
||||
return;
|
||||
}
|
||||
this.partialMessageTimer = setTimeout((token, timeout) => {
|
||||
this.partialMessageTimer = undefined;
|
||||
if (token === this.messageToken) {
|
||||
this.firePartialMessage({ messageToken: token, waitingTime: timeout });
|
||||
this.setPartialMessageTimer();
|
||||
}
|
||||
}, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
export class IPCMessageReader extends AbstractMessageReader implements MessageReader {
|
||||
|
||||
private process: NodeJS.Process | ChildProcess;
|
||||
|
||||
public constructor(process: NodeJS.Process | ChildProcess) {
|
||||
super();
|
||||
this.process = process;
|
||||
|
||||
let eventEmitter: NodeJS.EventEmitter = <NodeJS.EventEmitter>this.process;
|
||||
eventEmitter.on('error', (error: any) => this.fireError(error));
|
||||
eventEmitter.on('close', () => this.fireClose());
|
||||
}
|
||||
|
||||
public listen(callback: DataCallback): void {
|
||||
let eventEmitter: NodeJS.EventEmitter = <NodeJS.EventEmitter>this.process;
|
||||
eventEmitter.on('message', callback);
|
||||
}
|
||||
}
|
||||
118
dataprotocol-node/jsonrpc/src/messageWriter.ts
Normal file
118
dataprotocol-node/jsonrpc/src/messageWriter.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 { ChildProcess } from 'child_process';
|
||||
|
||||
import { Message } from './messages';
|
||||
import { Event, Emitter } from './events';
|
||||
import * as is from './is';
|
||||
|
||||
let ContentLength: string = 'Content-Length: ';
|
||||
let CRLF = '\r\n';
|
||||
|
||||
export interface MessageWriter {
|
||||
onError: Event<[Error, Message, number]>;
|
||||
onClose: Event<void>;
|
||||
write(msg: Message): void;
|
||||
}
|
||||
|
||||
export abstract class AbstractMessageWriter {
|
||||
|
||||
private errorEmitter: Emitter<[Error, Message, number]>;
|
||||
private closeEmitter: Emitter<void>;
|
||||
|
||||
constructor() {
|
||||
this.errorEmitter = new Emitter<[Error, Message, number]>();
|
||||
this.closeEmitter = new Emitter<void>();
|
||||
}
|
||||
|
||||
public get onError(): Event<[Error, Message, number]> {
|
||||
return this.errorEmitter.event;
|
||||
}
|
||||
|
||||
protected fireError(error: any, message?: Message, count?: number): void {
|
||||
this.errorEmitter.fire([this.asError(error), message, count]);
|
||||
}
|
||||
|
||||
public get onClose(): Event<void> {
|
||||
return this.closeEmitter.event;
|
||||
}
|
||||
|
||||
protected fireClose(): void {
|
||||
this.closeEmitter.fire(undefined);
|
||||
}
|
||||
|
||||
private asError(error: any): Error {
|
||||
if (error instanceof Error) {
|
||||
return error;
|
||||
} else {
|
||||
return new Error(`Writer recevied error. Reason: ${is.string(error.message) ? error.message : 'unknown'}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class StreamMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
||||
|
||||
private writable: NodeJS.WritableStream;
|
||||
private encoding: string;
|
||||
private errorCount: number;
|
||||
|
||||
public constructor(writable: NodeJS.WritableStream, encoding: string = 'utf8') {
|
||||
super();
|
||||
this.writable = writable;
|
||||
this.encoding = encoding;
|
||||
this.errorCount = 0;
|
||||
this.writable.on('error', (error) => this.fireError(error));
|
||||
this.writable.on('close', () => this.fireClose());
|
||||
}
|
||||
|
||||
public write(msg: Message): void {
|
||||
let json = JSON.stringify(msg);
|
||||
let contentLength = Buffer.byteLength(json, this.encoding);
|
||||
|
||||
let headers: string[] = [
|
||||
ContentLength, contentLength.toString(), CRLF,
|
||||
CRLF
|
||||
];
|
||||
try {
|
||||
// Header must be written in ASCII encoding
|
||||
this.writable.write(headers.join(''), 'ascii');
|
||||
|
||||
// Now write the content. This can be written in any encoding
|
||||
this.writable.write(json, this.encoding);
|
||||
this.errorCount = 0;
|
||||
} catch (error) {
|
||||
this.errorCount++;
|
||||
this.fireError(error, msg, this.errorCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class IPCMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
||||
|
||||
private process: NodeJS.Process | ChildProcess;
|
||||
private errorCount: number;
|
||||
|
||||
public constructor(process: NodeJS.Process | ChildProcess) {
|
||||
super();
|
||||
this.process = process;
|
||||
this.errorCount = 0;
|
||||
|
||||
let eventEmitter: NodeJS.EventEmitter = <NodeJS.EventEmitter>this.process;
|
||||
eventEmitter.on('error', (error) => this.fireError(error));
|
||||
eventEmitter.on('close', () => this.fireClose);
|
||||
}
|
||||
|
||||
public write(msg: Message): void {
|
||||
try {
|
||||
(this.process.send as Function)(msg);
|
||||
this.errorCount = 0;
|
||||
} catch (error) {
|
||||
this.errorCount++;
|
||||
this.fireError(error, msg, this.errorCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
175
dataprotocol-node/jsonrpc/src/messages.ts
Normal file
175
dataprotocol-node/jsonrpc/src/messages.ts
Normal file
@@ -0,0 +1,175 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* 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 is from './is';
|
||||
|
||||
/**
|
||||
* A language server message
|
||||
*/
|
||||
export interface Message {
|
||||
jsonrpc: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request message
|
||||
*/
|
||||
export interface RequestMessage extends Message {
|
||||
|
||||
/**
|
||||
* The request id.
|
||||
*/
|
||||
id: number | string;
|
||||
|
||||
/**
|
||||
* The method to be invoked.
|
||||
*/
|
||||
method: string;
|
||||
|
||||
/**
|
||||
* The method's params.
|
||||
*/
|
||||
params?: any
|
||||
}
|
||||
|
||||
/**
|
||||
* Predefined error codes.
|
||||
*/
|
||||
export namespace ErrorCodes {
|
||||
// Defined by JSON RPC
|
||||
export const ParseError: number = -32700;
|
||||
export const InvalidRequest: number = -32600;
|
||||
export const MethodNotFound: number = -32601;
|
||||
export const InvalidParams: number = -32602;
|
||||
export const InternalError: number = -32603;
|
||||
export const serverErrorStart: number = -32099
|
||||
export const serverErrorEnd: number = -32000;
|
||||
|
||||
// Defined by VSCode.
|
||||
export const MessageWriteError: number = 1;
|
||||
export const MessageReadError: number = 2;
|
||||
}
|
||||
|
||||
export interface ResponseErrorLiteral<D> {
|
||||
/**
|
||||
* A number indicating the error type that occured.
|
||||
*/
|
||||
code: number;
|
||||
|
||||
/**
|
||||
* A string providing a short decription of the error.
|
||||
*/
|
||||
message: string;
|
||||
|
||||
/**
|
||||
* A Primitive or Structured value that contains additional
|
||||
* information about the error. Can be omitted.
|
||||
*/
|
||||
data?: D;
|
||||
}
|
||||
|
||||
/**
|
||||
* A error object return in a response in case a request
|
||||
* has failed.
|
||||
*/
|
||||
export class ResponseError<D> extends Error {
|
||||
|
||||
public code: number;
|
||||
|
||||
public message: string;
|
||||
|
||||
public data: D;
|
||||
|
||||
constructor(code: number, message: string, data?: D) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
if (is.defined(data)) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
public toJson(): ResponseErrorLiteral<D> {
|
||||
let result: ResponseErrorLiteral<D> = {
|
||||
code: this.code,
|
||||
message: this.message
|
||||
};
|
||||
if (is.defined(this.data)) {
|
||||
result.data = this.data
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A response message.
|
||||
*/
|
||||
export interface ResponseMessage extends Message {
|
||||
/**
|
||||
* The request id.
|
||||
*/
|
||||
id: number | string;
|
||||
|
||||
/**
|
||||
* The result of a request. This can be omitted in
|
||||
* the case of an error.
|
||||
*/
|
||||
result?: any;
|
||||
|
||||
/**
|
||||
* The error object in case a request fails.
|
||||
*/
|
||||
error?: ResponseErrorLiteral<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A interface to type the request parameter / response pair
|
||||
*/
|
||||
export interface RequestType<P, R, E> {
|
||||
method: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Message
|
||||
*/
|
||||
export interface NotificationMessage extends Message {
|
||||
/**
|
||||
* The method to be invoked.
|
||||
*/
|
||||
method: string;
|
||||
|
||||
/**
|
||||
* The notification's params.
|
||||
*/
|
||||
params?: any
|
||||
}
|
||||
|
||||
export interface NotificationType<P> {
|
||||
method: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the given message is a request message
|
||||
*/
|
||||
export function isRequestMessage(message: Message): message is RequestMessage {
|
||||
let candidate = <RequestMessage>message;
|
||||
return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the given message is a notification message
|
||||
*/
|
||||
export function isNotificationMessage(message: Message): message is NotificationMessage {
|
||||
let candidate = <NotificationMessage>message;
|
||||
return candidate && is.string(candidate.method) && is.undefined((<any>message).id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the given message is a response message
|
||||
*/
|
||||
export function isReponseMessage(message: Message): message is ResponseMessage {
|
||||
let candidate = <ResponseMessage>message;
|
||||
return candidate && (is.defined(candidate.result) || is.defined(candidate.error)) && (is.string(candidate.id) || is.number(candidate.id));
|
||||
}
|
||||
11
dataprotocol-node/jsonrpc/src/tsconfig.json
Normal file
11
dataprotocol-node/jsonrpc/src/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"stripInternal": true,
|
||||
"outDir": "../lib"
|
||||
}
|
||||
}
|
||||
112
dataprotocol-node/jsonrpc/src/typings/promise.d.ts
vendored
Normal file
112
dataprotocol-node/jsonrpc/src/typings/promise.d.ts
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/**
|
||||
* The Thenable (E.g. PromiseLike) and Promise declarions are taken from TypeScript's
|
||||
* lib.core.es6.d.ts file. See above Copyright notice.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
|
||||
* and others. This API makes no assumption about what promise libary is being used which
|
||||
* enables reusing existing code without migrating to a specific promise implementation. Still,
|
||||
* we recommand the use of native promises which are available in VS Code.
|
||||
*/
|
||||
interface Thenable<R> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
interface Promise<T> extends Thenable<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Promise<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected?: (reason: any) => T | Thenable<T>): Promise<T>;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Creates a new Promise.
|
||||
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
|
||||
* a resolve callback used resolve the promise with a value or the result of another promise,
|
||||
* and a reject callback used to reject the promise with a provided reason or error.
|
||||
*/
|
||||
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T>(values: Array<T | Thenable<T>>): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T>(values: Array<T | Thenable<T>>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject(reason: any): Promise<void>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject<T>(reason: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T | Thenable<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise .
|
||||
* @returns A resolved promise.
|
||||
*/
|
||||
resolve(): Promise<void>;
|
||||
}
|
||||
|
||||
declare var Promise: PromiseConstructor;
|
||||
31
dataprotocol-node/jsonrpc/thirdpartynotices.txt
Normal file
31
dataprotocol-node/jsonrpc/thirdpartynotices.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
|
||||
For Microsoft vscode-jsonrpc
|
||||
|
||||
This project incorporates material from the project(s) listed below (collectively, “Third Party Code”).
|
||||
Microsoft is not the original author of the Third Party Code. The original copyright notice and license
|
||||
under which Microsoft received such Third Party Code are set out below. This Third Party Code is licensed
|
||||
to you under their original license terms set forth below. Microsoft reserves all other rights not expressly
|
||||
granted, whether by implication, estoppel or otherwise.
|
||||
|
||||
1. DefinitelyTyped version 0.0.1 (https://github.com/borisyankov/DefinitelyTyped)
|
||||
|
||||
This project is licensed under the MIT license.
|
||||
Copyrights are respective of each contributor listed at the beginning of each definition file.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
24
dataprotocol-node/types/.eslintrc
Normal file
24
dataprotocol-node/types/.eslintrc
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"rules": {
|
||||
"indent": [
|
||||
2,
|
||||
"tab"
|
||||
],
|
||||
"quotes": [
|
||||
2,
|
||||
"single"
|
||||
],
|
||||
"linebreak-style": [
|
||||
2,
|
||||
"windows"
|
||||
],
|
||||
"semi": [
|
||||
2,
|
||||
"always"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
||||
1
dataprotocol-node/types/.gitignore
vendored
Normal file
1
dataprotocol-node/types/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!bin/
|
||||
9
dataprotocol-node/types/.npmignore
Normal file
9
dataprotocol-node/types/.npmignore
Normal file
@@ -0,0 +1,9 @@
|
||||
.vscode/
|
||||
lib/test/
|
||||
lib/*.map
|
||||
src/
|
||||
test/
|
||||
.eslintrc
|
||||
.gitignore
|
||||
gulpfile.js
|
||||
tsd.json
|
||||
9
dataprotocol-node/types/.vscode/settings.json
vendored
Normal file
9
dataprotocol-node/types/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"javascript.validate.enable": false,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"eslint.enable": false,
|
||||
"editor.insertSpaces": false,
|
||||
"editor.tabSize": 4,
|
||||
"typescript.tsdk": "./node_modules/typescript/lib"
|
||||
}
|
||||
9
dataprotocol-node/types/.vscode/tasks.json
vendored
Normal file
9
dataprotocol-node/types/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "npm",
|
||||
"isShellCommand": true,
|
||||
"args": ["run", "watch"],
|
||||
"showOutput": "silent",
|
||||
"isWatching": true,
|
||||
"problemMatcher": "$tsc-watch"
|
||||
}
|
||||
4
dataprotocol-node/types/README.md
Normal file
4
dataprotocol-node/types/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Microsoft Data Management Protocol - Node
|
||||
|
||||
## License
|
||||
[MIT](https://github.com/Microsoft/carbon/blob/dev/license.txt)
|
||||
26
dataprotocol-node/types/package.json
Normal file
26
dataprotocol-node/types/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "dataprotocol-languageserver-types",
|
||||
"description": "Types used by the Language server for node",
|
||||
"version": "1.0.4",
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/vscode-languageserver-node.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
|
||||
},
|
||||
"main": "./lib/main.js",
|
||||
"typings": "./lib/main",
|
||||
"devDependencies": {
|
||||
"mocha": "^2.4.5",
|
||||
"typescript": "2.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "tsc -p ./src",
|
||||
"compile": "tsc -p ./src",
|
||||
"watch": "tsc -w -p ./src",
|
||||
"test": "mocha"
|
||||
}
|
||||
}
|
||||
2541
dataprotocol-node/types/src/main.ts
Normal file
2541
dataprotocol-node/types/src/main.ts
Normal file
File diff suppressed because it is too large
Load Diff
10
dataprotocol-node/types/src/tsconfig.json
Normal file
10
dataprotocol-node/types/src/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES5",
|
||||
"module": "umd",
|
||||
"sourceMap": false,
|
||||
"declaration": true,
|
||||
"stripInternal": true,
|
||||
"outDir": "../lib"
|
||||
}
|
||||
}
|
||||
112
dataprotocol-node/types/src/typings/promise.d.ts
vendored
Normal file
112
dataprotocol-node/types/src/typings/promise.d.ts
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/**
|
||||
* The Thenable (E.g. PromiseLike) and Promise declarions are taken from TypeScript's
|
||||
* lib.core.es6.d.ts file. See above Copyright notice.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
|
||||
* and others. This API makes no assumption about what promise libary is being used which
|
||||
* enables reusing existing code without migrating to a specific promise implementation. Still,
|
||||
* we recommand the use of native promises which are available in VS Code.
|
||||
*/
|
||||
interface Thenable<R> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
interface Promise<T> extends Thenable<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Promise<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected?: (reason: any) => T | Thenable<T>): Promise<T>;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Creates a new Promise.
|
||||
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
|
||||
* a resolve callback used resolve the promise with a value or the result of another promise,
|
||||
* and a reject callback used to reject the promise with a provided reason or error.
|
||||
*/
|
||||
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T>(values: Array<T | Thenable<T>>): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T>(values: Array<T | Thenable<T>>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject(reason: any): Promise<void>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject<T>(reason: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T | Thenable<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise .
|
||||
* @returns A resolved promise.
|
||||
*/
|
||||
resolve(): Promise<void>;
|
||||
}
|
||||
|
||||
declare var Promise: PromiseConstructor;
|
||||
@@ -3,15 +3,14 @@
|
||||
"version": "0.1.0",
|
||||
"description": "Shared modules for Carbon extensions",
|
||||
"dependencies": {
|
||||
"dataprotocol-client": "file:./../dataprotocol-client",
|
||||
"dataprotocol-client": "file:../dataprotocol-node/client",
|
||||
"decompress": "^4.2.0",
|
||||
"fs-extra-promise": "^1.0.1",
|
||||
"http-proxy-agent": "^2.0.0",
|
||||
"https-proxy-agent": "^2.1.0",
|
||||
"opener": "^1.4.3",
|
||||
"tmp": "0.0.33",
|
||||
"vscode-extension-telemetry": "0.0.8",
|
||||
"vscode-languageclient": "^3.5.0"
|
||||
"vscode-extension-telemetry": "0.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^6.0.61",
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
'use strict';
|
||||
|
||||
import { ExtensionContext, workspace, window, OutputChannel, languages } from 'vscode';
|
||||
import { SqlOpsDataClient, LanguageClientOptions } from 'dataprotocol-client';
|
||||
import { CloseAction, ErrorAction, ServerOptions, NotificationHandler, NotificationType, RequestType, TransportKind } from 'vscode-languageclient';
|
||||
import {
|
||||
LanguageClient, LanguageClientOptions, ServerOptions,
|
||||
TransportKind, RequestType, NotificationType, NotificationHandler,
|
||||
ErrorAction, CloseAction
|
||||
} from 'dataprotocol-client';
|
||||
|
||||
import { VscodeWrapper } from '../controllers/vscodeWrapper';
|
||||
import { Telemetry } from '../models/telemetry';
|
||||
@@ -132,14 +135,14 @@ export class SqlToolsServiceClient {
|
||||
}
|
||||
|
||||
// VS Code Language Client
|
||||
private _client: SqlOpsDataClient = undefined;
|
||||
private _client: LanguageClient = undefined;
|
||||
|
||||
// getter method for the Language Client
|
||||
private get client(): SqlOpsDataClient {
|
||||
private get client(): LanguageClient {
|
||||
return this._client;
|
||||
}
|
||||
|
||||
private set client(client: SqlOpsDataClient) {
|
||||
private set client(client: LanguageClient) {
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
@@ -230,7 +233,6 @@ export class SqlToolsServiceClient {
|
||||
}
|
||||
|
||||
this._logger.appendLine();
|
||||
|
||||
this._server.getServerPath(platformInfo.runtimeId).then(serverPath => {
|
||||
if (serverPath === undefined) {
|
||||
// Check if the service already installed and if not open the output channel to show the logs
|
||||
@@ -317,9 +319,9 @@ export class SqlToolsServiceClient {
|
||||
}
|
||||
}
|
||||
|
||||
public createClient(context: ExtensionContext, runtimeId: Runtime, languageClientHelper: LanguageServiceContracts.ILanguageClientHelper, executableFiles: string[]): Promise<SqlOpsDataClient> {
|
||||
return new Promise<SqlOpsDataClient>((resolve, reject) => {
|
||||
let client: SqlOpsDataClient;
|
||||
public createClient(context: ExtensionContext, runtimeId: Runtime, languageClientHelper: LanguageServiceContracts.ILanguageClientHelper, executableFiles: string[]): Promise<LanguageClient> {
|
||||
return new Promise<LanguageClient>((resolve, reject) => {
|
||||
let client: LanguageClient;
|
||||
this._server.findServerPath(this.installDirectory, executableFiles).then(serverPath => {
|
||||
if (serverPath === undefined) {
|
||||
reject(new Error(SqlToolsServiceClient._constants.invalidServiceFilePath));
|
||||
@@ -340,7 +342,7 @@ export class SqlToolsServiceClient {
|
||||
};
|
||||
this._serviceStatus.showServiceLoading();
|
||||
// cache the client instance for later use
|
||||
client = new SqlOpsDataClient(SqlToolsServiceClient._constants.serviceName, serverOptions, clientOptions);
|
||||
client = new LanguageClient(SqlToolsServiceClient._constants.serviceName, serverOptions, clientOptions);
|
||||
|
||||
if (context !== undefined) {
|
||||
// Create the language client and start the client.
|
||||
@@ -387,7 +389,7 @@ export class SqlToolsServiceClient {
|
||||
return serverOptions;
|
||||
}
|
||||
|
||||
private createLanguageClient(serverOptions: ServerOptions): SqlOpsDataClient {
|
||||
private createLanguageClient(serverOptions: ServerOptions): LanguageClient {
|
||||
// Options to control the language client
|
||||
let clientOptions: LanguageClientOptions = {
|
||||
documentSelector: [SqlToolsServiceClient._constants.languageId],
|
||||
@@ -401,7 +403,7 @@ export class SqlToolsServiceClient {
|
||||
|
||||
this._serviceStatus.showServiceLoading();
|
||||
// cache the client instance for later use
|
||||
let client = new SqlOpsDataClient(SqlToolsServiceClient._constants.serviceName, serverOptions, clientOptions);
|
||||
let client = new LanguageClient(SqlToolsServiceClient._constants.serviceName, serverOptions, clientOptions);
|
||||
client.onReady().then(() => {
|
||||
this.checkServiceCompatibility();
|
||||
this._serviceStatus.showServiceLoaded();
|
||||
@@ -447,7 +449,7 @@ export class SqlToolsServiceClient {
|
||||
* @param params The params to pass with the request
|
||||
* @returns A thenable object for when the request receives a response
|
||||
*/
|
||||
public sendRequest<P, R, E, RO>(type: RequestType<P, R, E, RO>, params?: P, client: SqlOpsDataClient = undefined): Thenable<R> {
|
||||
public sendRequest<P, R, E>(type: RequestType<P, R, E>, params?: P, client: LanguageClient = undefined): Thenable<R> {
|
||||
if (client === undefined) {
|
||||
client = this._client;
|
||||
}
|
||||
@@ -461,7 +463,7 @@ export class SqlToolsServiceClient {
|
||||
* @param type The notification type to register the handler for
|
||||
* @param handler The handler to register
|
||||
*/
|
||||
public onNotification<P, RO>(type: NotificationType<P, RO>, handler: NotificationHandler<P>, client: SqlOpsDataClient = undefined): void {
|
||||
public onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>, client: LanguageClient = undefined): void {
|
||||
if (client === undefined) {
|
||||
client = this._client;
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { RequestType } from 'vscode-languageclient';
|
||||
import { RequestType } from 'dataprotocol-client';
|
||||
import { Runtime, LinuxDistribution } from '../platform';
|
||||
|
||||
// --------------------------------- < Version Request > -------------------------------------------------
|
||||
|
||||
// Version request message callback declaration
|
||||
export namespace VersionRequest {
|
||||
export const type = new RequestType<void, VersionResult, void, void>('version');
|
||||
export const type: RequestType<void, VersionResult, void> = { get method(): string { return 'version'; } };
|
||||
}
|
||||
|
||||
// Version response format
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { NotificationType, ServerOptions } from 'vscode-languageclient';
|
||||
import { NotificationType, ServerOptions } from 'dataprotocol-client';
|
||||
import { ITelemetryEventProperties, ITelemetryEventMeasures } from '../telemetry';
|
||||
import { Runtime } from '../platform';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Runtime } from '../platform';
|
||||
* Event sent when the language service send a telemetry event
|
||||
*/
|
||||
export namespace TelemetryNotification {
|
||||
export const type = new NotificationType<TelemetryParams, void>('telemetry/sqlevent');
|
||||
export const type: NotificationType<TelemetryParams> = { get method(): string { return 'telemetry/sqlevent'; } };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ export class TelemetryParams {
|
||||
* Event sent when the language service send a status change event
|
||||
*/
|
||||
export namespace StatusChangedNotification {
|
||||
export const type = new NotificationType<StatusChangeParams, void>('textDocument/statusChanged');
|
||||
export const type: NotificationType<StatusChangeParams> = { get method(): string { return 'textDocument/statusChanged'; } };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { RequestType } from 'vscode-languageclient';
|
||||
import { RequestType } from 'dataprotocol-client';
|
||||
import * as data from 'data';
|
||||
|
||||
// DEV-NOTE: Still finalizing what we'll need as part of this interface
|
||||
@@ -22,14 +22,14 @@ export class SaveResultsInfo {
|
||||
}
|
||||
|
||||
export namespace SaveAsRequest {
|
||||
export const type = new RequestType<SaveResultsInfo, data.SaveResultRequestResult, void, void>('query/saveAs');
|
||||
export const type: RequestType<SaveResultsInfo, data.SaveResultRequestResult, void> = { get method(): string { return 'query/saveAs'; } };
|
||||
}
|
||||
|
||||
// --------------------------------- < Read Credential Request > -------------------------------------------------
|
||||
|
||||
// Read Credential request message callback declaration
|
||||
export namespace ReadCredentialRequest {
|
||||
export const type = new RequestType<Credential, Credential, void, void>('credential/read');
|
||||
export const type: RequestType<Credential, Credential, void> = { get method(): string { return 'credential/read'; } };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ export class Credential {
|
||||
|
||||
// Save Credential request message callback declaration
|
||||
export namespace SaveCredentialRequest {
|
||||
export const type = new RequestType<Credential, boolean, void, void>('credential/save');
|
||||
export const type: RequestType<Credential, boolean, void> = { get method(): string { return 'credential/save'; } };
|
||||
}
|
||||
// --------------------------------- </ Save Credential Request > -------------------------------------------------
|
||||
|
||||
@@ -62,17 +62,17 @@ export namespace SaveCredentialRequest {
|
||||
|
||||
// Delete Credential request message callback declaration
|
||||
export namespace DeleteCredentialRequest {
|
||||
export const type = new RequestType<Credential, boolean, void, void>('credential/delete');
|
||||
export const type: RequestType<Credential, boolean, void> = { get method(): string { return 'credential/delete'; } };
|
||||
}
|
||||
// --------------------------------- </ Delete Credential Request > -------------------------------------------------
|
||||
|
||||
// ------------------------------- < Resource Events > ------------------------------------
|
||||
export namespace CreateFirewallRuleRequest {
|
||||
export const type = new RequestType<CreateFirewallRuleParams, CreateFirewallRuleResponse, void, void>('resource/createFirewallRule');
|
||||
export const type: RequestType<CreateFirewallRuleParams, CreateFirewallRuleResponse, void> = { get method(): string { return 'resource/createFirewallRule'; } };
|
||||
}
|
||||
|
||||
export namespace HandleFirewallRuleRequest {
|
||||
export const type = new RequestType<HandleFirewallRuleParams, HandleFirewallRuleResponse, void, void>('resource/handleFirewallRule');
|
||||
export const type: RequestType<HandleFirewallRuleParams, HandleFirewallRuleResponse, void> = { get method(): string { return 'resource/handleFirewallRule'; } };
|
||||
}
|
||||
|
||||
// Firewall rule interfaces
|
||||
|
||||
21
extensions/mssql/npm-shrinkwrap.json
generated
21
extensions/mssql/npm-shrinkwrap.json
generated
@@ -1,4 +1,21 @@
|
||||
{
|
||||
"name": "mssql",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"dataprotocol-client": {
|
||||
"version": "2.6.3",
|
||||
"from": "..\\..\\dataprotocol-node\\client",
|
||||
"resolved": "file:..\\..\\dataprotocol-node\\client"
|
||||
},
|
||||
"dataprotocol-jsonrpc": {
|
||||
"version": "2.4.0",
|
||||
"from": "..\\..\\dataprotocol-node\\jsonrpc",
|
||||
"resolved": "file:..\\..\\dataprotocol-node\\jsonrpc"
|
||||
},
|
||||
"dataprotocol-languageserver-types": {
|
||||
"version": "1.0.4",
|
||||
"from": "..\\..\\dataprotocol-node\\types",
|
||||
"resolved": "file:..\\..\\dataprotocol-node\\types"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"scripts": {
|
||||
"compile": "gulp compile-extension:mssql-client",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install",
|
||||
"update-grammar": "node ../../build/npm/update-grammar.js Microsoft/vscode-mssql syntaxes/SQL.plist ./syntaxes/sql.tmLanguage.json"
|
||||
"update-grammar": "node ../../build/npm/update-grammar.js Microsoft/vscode-mssql syntaxes/SQL.plist ./syntaxes/sql.tmLanguage.json"
|
||||
},
|
||||
"contributes": {
|
||||
"languages": [
|
||||
@@ -191,6 +191,9 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"dataprotocol-client": "file:../../dataprotocol-node/client"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vscode": "1.0.1"
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { SplitView, CollapsibleState } from 'sql/base/browser/ui/splitview/splitview';
|
||||
import { Builder, $ } from 'vs/base/browser/builder';
|
||||
import { Widget } from 'vs/base/browser/ui/widget';
|
||||
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export class CategoryView extends FixedCollapsibleView {
|
||||
private _treecontainer: HTMLElement;
|
||||
@@ -168,13 +167,13 @@ export class OptionsDialog extends Modal {
|
||||
var widget: Widget = this._optionElements[optionName].optionWidget;
|
||||
var option = this._optionElements[optionName].option;
|
||||
switch (option.valueType) {
|
||||
case ServiceOptionType.category:
|
||||
case ServiceOptionType.boolean:
|
||||
case OptionsDialogHelper.ServiceOptionType.category:
|
||||
case OptionsDialogHelper.ServiceOptionType.boolean:
|
||||
this._register(styler.attachSelectBoxStyler(<SelectBox>widget, this._themeService));
|
||||
break;
|
||||
case ServiceOptionType.string:
|
||||
case ServiceOptionType.password:
|
||||
case ServiceOptionType.number:
|
||||
case OptionsDialogHelper.ServiceOptionType.string:
|
||||
case OptionsDialogHelper.ServiceOptionType.password:
|
||||
case OptionsDialogHelper.ServiceOptionType.number:
|
||||
this._register(styler.attachInputBoxStyler(<InputBox>widget, this._themeService));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import data = require('data');
|
||||
import { localize } from 'vs/nls';
|
||||
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export interface IOptionElement {
|
||||
optionWidget: any;
|
||||
@@ -22,6 +21,15 @@ export interface IOptionElement {
|
||||
optionValue: any;
|
||||
}
|
||||
|
||||
export enum ServiceOptionType {
|
||||
string = 0,
|
||||
multistring = 1,
|
||||
password = 2,
|
||||
number = 3,
|
||||
category = 4,
|
||||
boolean = 5
|
||||
}
|
||||
|
||||
export function createOptionElement(option: data.ServiceOption, rowContainer: Builder, options: { [name: string]: any },
|
||||
optionsMap: { [optionName: string]: IOptionElement }, contextViewService: IContextViewService, onFocus: (name) => void): void {
|
||||
let possibleInputs: string[] = [];
|
||||
|
||||
113
src/sql/data.d.ts
vendored
113
src/sql/data.d.ts
vendored
@@ -11,29 +11,7 @@ declare module 'data' {
|
||||
* Namespace for Data Management Protocol global methods
|
||||
*/
|
||||
export namespace dataprotocol {
|
||||
export function registerConnectionProvider(provider: ConnectionProvider): vscode.Disposable;
|
||||
|
||||
export function registerBackupProvider(provider: BackupProvider): vscode.Disposable;
|
||||
|
||||
export function registerRestoreProvider(provider: RestoreProvider): vscode.Disposable;
|
||||
|
||||
export function registerScriptingProvider(provider: ScriptingProvider): vscode.Disposable;
|
||||
|
||||
export function registerObjectExplorerProvider(provider: ObjectExplorerProvider): vscode.Disposable;
|
||||
|
||||
export function registerTaskServicesProvider(provider: TaskServicesProvider): vscode.Disposable;
|
||||
|
||||
export function registerFileBrowserProvider(provider: FileBrowserProvider): vscode.Disposable;
|
||||
|
||||
export function registerProfilerProvider(provider: ProfilerProvider): vscode.Disposable;
|
||||
|
||||
export function registerMetadataProvider(provider: MetadataProvider): vscode.Disposable;
|
||||
|
||||
export function registerQueryProvider(provider: QueryProvider): vscode.Disposable;
|
||||
|
||||
export function registerAdminServicesProvider(provider: AdminServicesProvider): vscode.Disposable;
|
||||
|
||||
export function registerCapabilitiesServiceProvider(provider: CapabilitiesProvider): vscode.Disposable;
|
||||
export function registerProvider(provider: DataProtocolProvider): vscode.Disposable;
|
||||
|
||||
/**
|
||||
* An [event](#Event) which fires when the specific flavor of a language used in DMP
|
||||
@@ -177,12 +155,8 @@ declare module 'data' {
|
||||
osVersion: string;
|
||||
}
|
||||
|
||||
export interface DataProvider {
|
||||
handle?: number;
|
||||
readonly providerId: string;
|
||||
}
|
||||
|
||||
export interface ConnectionProvider extends DataProvider {
|
||||
export interface ConnectionProvider {
|
||||
handle: number;
|
||||
|
||||
connect(connectionUri: string, connectionInfo: ConnectionInfo): Thenable<boolean>;
|
||||
|
||||
@@ -196,11 +170,11 @@ declare module 'data' {
|
||||
|
||||
rebuildIntelliSenseCache(connectionUri: string): Thenable<void>;
|
||||
|
||||
registerOnConnectionComplete(handler: (connSummary: ConnectionInfoSummary) => any): void;
|
||||
registerOnConnectionComplete(handler: (connSummary: ConnectionInfoSummary) => any);
|
||||
|
||||
registerOnIntelliSenseCacheComplete(handler: (connectionUri: string) => any): void;
|
||||
registerOnIntelliSenseCacheComplete(handler: (connectionUri: string) => any);
|
||||
|
||||
registerOnConnectionChanged(handler: (changedConnInfo: ChangedConnectionInfo) => any): void;
|
||||
registerOnConnectionChanged(handler: (changedConnInfo: ChangedConnectionInfo) => any);
|
||||
}
|
||||
|
||||
export enum ServiceOptionType {
|
||||
@@ -214,12 +188,12 @@ declare module 'data' {
|
||||
}
|
||||
|
||||
export enum ConnectionOptionSpecialType {
|
||||
serverName = 'serverName',
|
||||
databaseName = 'databaseName',
|
||||
authType = 'authType',
|
||||
userName = 'userName',
|
||||
password = 'password',
|
||||
appName = 'appName'
|
||||
serverName = 0,
|
||||
databaseName = 1,
|
||||
authType = 2,
|
||||
userName = 3,
|
||||
password = 4,
|
||||
appName = 5
|
||||
}
|
||||
|
||||
export interface CategoryValue {
|
||||
@@ -332,7 +306,7 @@ declare module 'data' {
|
||||
hostVersion: string;
|
||||
}
|
||||
|
||||
export interface CapabilitiesProvider extends DataProvider {
|
||||
export interface CapabilitiesProvider {
|
||||
getServerCapabilities(client: DataProtocolClientCapabilities): Thenable<DataProtocolServerCapabilities>;
|
||||
}
|
||||
|
||||
@@ -413,7 +387,7 @@ declare module 'data' {
|
||||
objectMetadata: ObjectMetadata[];
|
||||
}
|
||||
|
||||
export interface MetadataProvider extends DataProvider {
|
||||
export interface MetadataProvider {
|
||||
getMetadata(connectionUri: string): Thenable<ProviderMetadata>;
|
||||
|
||||
getDatabases(connectionUri: string): Thenable<string[]>;
|
||||
@@ -445,7 +419,7 @@ declare module 'data' {
|
||||
targetDatabaseEngineType: string;
|
||||
}
|
||||
|
||||
export interface ScriptingProvider extends DataProvider {
|
||||
export interface ScriptingProvider {
|
||||
|
||||
scriptAsOperation(connectionUri: string, operation: ScriptOperation, metadata: ObjectMetadata, paramDetails: ScriptingParamDetails): Thenable<ScriptingResult>;
|
||||
|
||||
@@ -465,6 +439,38 @@ declare module 'data' {
|
||||
|
||||
operationId: string;
|
||||
}
|
||||
/**
|
||||
* Data Management Protocol main provider class that DMP extensions should implement.
|
||||
* This provider interface contains references to providers for the various capabilitiesProvider
|
||||
* that an extension can implement.
|
||||
*/
|
||||
export interface DataProtocolProvider {
|
||||
handle: number;
|
||||
|
||||
providerId: string;
|
||||
|
||||
capabilitiesProvider: CapabilitiesProvider;
|
||||
|
||||
connectionProvider: ConnectionProvider;
|
||||
|
||||
queryProvider: QueryProvider;
|
||||
|
||||
metadataProvider: MetadataProvider;
|
||||
|
||||
scriptingProvider: ScriptingProvider;
|
||||
|
||||
objectExplorerProvider: ObjectExplorerProvider;
|
||||
|
||||
adminServicesProvider: AdminServicesProvider;
|
||||
|
||||
disasterRecoveryProvider: DisasterRecoveryProvider;
|
||||
|
||||
taskServicesProvider: TaskServicesProvider;
|
||||
|
||||
fileBrowserProvider: FileBrowserProvider;
|
||||
|
||||
profilerProvider: ProfilerProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters to initialize a connection to a database
|
||||
@@ -503,7 +509,10 @@ declare module 'data' {
|
||||
flavor: string;
|
||||
}
|
||||
|
||||
export interface QueryProvider extends DataProvider {
|
||||
export interface QueryProvider {
|
||||
handle: number;
|
||||
// TODO replace this temporary queryType field with a standard definition for supported platform
|
||||
queryType: string;
|
||||
cancelQuery(ownerUri: string): Thenable<QueryCancelResult>;
|
||||
runQuery(ownerUri: string, selection: ISelectionData, runOptions?: ExecutionPlanOptions): Thenable<void>;
|
||||
runQueryStatement(ownerUri: string, line: number, column: number): Thenable<void>;
|
||||
@@ -664,7 +673,6 @@ declare module 'data' {
|
||||
export interface QueryExecuteParams {
|
||||
ownerUri: string;
|
||||
querySelection: ISelectionData;
|
||||
executionPlanOptions?: ExecutionPlanOptions;
|
||||
}
|
||||
|
||||
export interface QueryExecuteSubsetParams {
|
||||
@@ -686,7 +694,6 @@ declare module 'data' {
|
||||
}
|
||||
|
||||
export interface QueryExecuteSubsetResult {
|
||||
message: string;
|
||||
resultSubset: ResultSetSubset;
|
||||
}
|
||||
|
||||
@@ -753,15 +760,12 @@ declare module 'data' {
|
||||
export interface EditInitializeFiltering {
|
||||
LimitResults?: number;
|
||||
}
|
||||
|
||||
export interface EditInitializeParams extends IEditSessionOperationParams {
|
||||
filters: EditInitializeFiltering;
|
||||
objectName: string;
|
||||
schemaName: string;
|
||||
objectType: string;
|
||||
}
|
||||
|
||||
|
||||
export interface EditInitializeResult { }
|
||||
|
||||
// edit/revertCell ----------------------------------------------------------------------------
|
||||
@@ -845,7 +849,7 @@ declare module 'data' {
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface ObjectExplorerProvider extends DataProvider {
|
||||
export interface ObjectExplorerProvider {
|
||||
createNewSession(connInfo: ConnectionInfo): Thenable<ObjectExplorerSessionResponse>;
|
||||
|
||||
expandNode(nodeInfo: ExpandNodeInfo): Thenable<boolean>;
|
||||
@@ -879,7 +883,7 @@ declare module 'data' {
|
||||
taskId: number;
|
||||
}
|
||||
|
||||
export interface AdminServicesProvider extends DataProvider {
|
||||
export interface AdminServicesProvider {
|
||||
createDatabase(connectionUri: string, database: DatabaseInfo): Thenable<CreateDatabaseResponse>;
|
||||
|
||||
createLogin(connectionUri: string, login: LoginInfo): Thenable<CreateLoginResponse>;
|
||||
@@ -937,7 +941,7 @@ declare module 'data' {
|
||||
duration: number;
|
||||
}
|
||||
|
||||
export interface TaskServicesProvider extends DataProvider {
|
||||
export interface TaskServicesProvider {
|
||||
getAllTasks(listTasksParams: ListTasksParams): Thenable<ListTasksResponse>;
|
||||
|
||||
cancelTask(cancelTaskParams: CancelTaskParams): Thenable<boolean>;
|
||||
@@ -960,12 +964,9 @@ declare module 'data' {
|
||||
taskId: number;
|
||||
}
|
||||
|
||||
export interface BackupProvider extends DataProvider {
|
||||
export interface DisasterRecoveryProvider {
|
||||
backup(connectionUri: string, backupInfo: { [key: string]: any }, taskExecutionMode: TaskExecutionMode): Thenable<BackupResponse>;
|
||||
getBackupConfigInfo(connectionUri: string): Thenable<BackupConfigInfo>;
|
||||
}
|
||||
|
||||
export interface RestoreProvider extends DataProvider {
|
||||
getRestorePlan(connectionUri: string, restoreInfo: RestoreInfo): Thenable<RestorePlanResponse>;
|
||||
cancelRestorePlan(connectionUri: string, restoreInfo: RestoreInfo): Thenable<boolean>;
|
||||
restore(connectionUri: string, restoreInfo: RestoreInfo): Thenable<RestoreResponse>;
|
||||
@@ -1028,7 +1029,7 @@ declare module 'data' {
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
export interface ProfilerProvider extends DataProvider {
|
||||
export interface ProfilerProvider {
|
||||
startSession(sessionId: string): Thenable<boolean>;
|
||||
stopSession(sessionId: string): Thenable<boolean>;
|
||||
pauseSession(sessionId: string): Thenable<boolean>;
|
||||
@@ -1080,7 +1081,7 @@ declare module 'data' {
|
||||
|
||||
// File browser interfaces -----------------------------------------------------------------------
|
||||
|
||||
export interface FileBrowserProvider extends DataProvider {
|
||||
export interface FileBrowserProvider {
|
||||
openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean>;
|
||||
registerOnFileBrowserOpened(handler: (response: FileBrowserOpenedParams) => any);
|
||||
expandFolderNode(ownerUri: string, expandPath: string): Thenable<boolean>;
|
||||
|
||||
@@ -136,7 +136,7 @@ export interface IConnectionManagementService {
|
||||
|
||||
clearRecentConnectionsList(): void;
|
||||
|
||||
clearRecentConnection(connectionProfile: IConnectionProfile): void;
|
||||
clearRecentConnection(connectionProfile: IConnectionProfile) : void;
|
||||
|
||||
getActiveConnections(): ConnectionProfile[];
|
||||
|
||||
@@ -278,6 +278,24 @@ export interface IErrorMessageService {
|
||||
showDialog(severity: Severity, headerTitle: string, message: string, messageDetails?: string, actions?: IAction[]): void;
|
||||
}
|
||||
|
||||
export enum ServiceOptionType {
|
||||
string = 0,
|
||||
multistring = 1,
|
||||
password = 2,
|
||||
number = 3,
|
||||
category = 4,
|
||||
boolean = 5
|
||||
}
|
||||
|
||||
export enum ConnectionOptionSpecialType {
|
||||
serverName = 0,
|
||||
databaseName = 1,
|
||||
authType = 2,
|
||||
userName = 3,
|
||||
password = 4,
|
||||
appName = 5
|
||||
}
|
||||
|
||||
export enum RunQueryOnConnectionMode {
|
||||
none = 0,
|
||||
executeQuery = 1,
|
||||
|
||||
@@ -52,11 +52,6 @@ export class ConnectionStore {
|
||||
this._connectionConfig = new ConnectionConfig(this._configurationEditService,
|
||||
this._workspaceConfigurationService, this._capabilitiesService, cachedServerCapabilities);
|
||||
}
|
||||
if (_capabilitiesService) {
|
||||
_capabilitiesService.onProviderRegisteredEvent(e => {
|
||||
this.saveCachedServerCapabilities();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static get CRED_PREFIX(): string { return 'Microsoft.SqlTools'; }
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import data = require('data');
|
||||
import * as interfaces from 'sql/parts/connection/common/interfaces';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import * as Constants from 'sql/parts/connection/common/constants';
|
||||
|
||||
export class ProviderConnectionInfo implements data.ConnectionInfo {
|
||||
@@ -114,7 +114,7 @@ export class ProviderConnectionInfo implements data.ConnectionInfo {
|
||||
return isPasswordRequired;
|
||||
}
|
||||
|
||||
private getSpecialTypeOptionValue(type: string): string {
|
||||
private getSpecialTypeOptionValue(type: number): string {
|
||||
let name = this.getSpecialTypeOptionName(type);
|
||||
if (name) {
|
||||
return this.options[name];
|
||||
@@ -172,7 +172,7 @@ export class ProviderConnectionInfo implements data.ConnectionInfo {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public getSpecialTypeOptionName(type: string): string {
|
||||
public getSpecialTypeOptionName(type: number): string {
|
||||
if (this._serverCapabilities) {
|
||||
let optionMetadata = this._serverCapabilities.connectionProvider.options.find(o => o.specialValueType === type);
|
||||
return !!optionMetadata ? optionMetadata.name : undefined;
|
||||
@@ -181,7 +181,7 @@ export class ProviderConnectionInfo implements data.ConnectionInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public setSpecialTypeOptionName(type: string, value: string): void {
|
||||
public setSpecialTypeOptionName(type: number, value: string): void {
|
||||
let name = this.getSpecialTypeOptionName(type);
|
||||
if (!!name) {
|
||||
this.options[name] = value;
|
||||
@@ -238,3 +238,4 @@ export class ProviderConnectionInfo implements data.ConnectionInfo {
|
||||
return parts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionManagementService, ConnectionOptionSpecialType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionComponentCallbacks, IConnectionComponentController, IConnectionValidateResult } from 'sql/parts/connection/connectionDialog/connectionDialogService';
|
||||
import { ConnectionWidget } from 'sql/parts/connection/connectionDialog/connectionWidget';
|
||||
import { AdvancedPropertiesController } from 'sql/parts/connection/connectionDialog/advancedPropertiesController';
|
||||
@@ -15,7 +15,6 @@ import * as Constants from 'sql/parts/connection/common/constants';
|
||||
import data = require('data');
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export class ConnectionController implements IConnectionComponentController {
|
||||
private _container: HTMLElement;
|
||||
|
||||
@@ -291,7 +291,8 @@ export class ConnectionDialogWidget extends Modal {
|
||||
this.onConnectionClick({ payload: { origin: origin, originalEvent: eventish } }, element);
|
||||
}
|
||||
};
|
||||
let actionProvider = this._instantiationService.createInstance(RecentConnectionActionsProvider);
|
||||
let actionProvider = this._instantiationService.createInstance(RecentConnectionActionsProvider, this._instantiationService, this._connectionManagementService,
|
||||
this._messageService);
|
||||
let controller = new RecentConnectionTreeController(leftClick, actionProvider, this._connectionManagementService, this._contextMenuService);
|
||||
actionProvider.onRecentConnectionRemoved(() => {
|
||||
this.open(this._connectionManagementService.getRecentConnections().length > 0);
|
||||
|
||||
@@ -16,7 +16,7 @@ import * as DialogHelper from 'sql/base/browser/ui/modal/dialogHelper';
|
||||
import { IConnectionComponentCallbacks } from 'sql/parts/connection/connectionDialog/connectionDialogService';
|
||||
import * as lifecycle from 'vs/base/common/lifecycle';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { ConnectionOptionSpecialType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import * as Constants from 'sql/parts/connection/common/constants';
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
@@ -87,7 +87,7 @@ export class ConnectionWidget {
|
||||
}
|
||||
|
||||
var authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
if (authTypeOption) {
|
||||
if(authTypeOption) {
|
||||
if (OS === OperatingSystem.Windows) {
|
||||
authTypeOption.defaultValue = this.getAuthTypeDisplayName(Constants.integrated);
|
||||
} else {
|
||||
@@ -250,11 +250,11 @@ export class ConnectionWidget {
|
||||
}
|
||||
}
|
||||
|
||||
private setConnectButton(): void {
|
||||
private setConnectButton() : void {
|
||||
let authDisplayName: string = this.getAuthTypeDisplayName(this.authenticationType);
|
||||
let authType: AuthenticationType = this.getMatchingAuthType(authDisplayName);
|
||||
let showUsernameAndPassword: boolean = true;
|
||||
if (authType) {
|
||||
if(authType) {
|
||||
showUsernameAndPassword = authType.showUsernameAndPassword;
|
||||
}
|
||||
showUsernameAndPassword ? this._callbacks.onSetConnectButton(!!this.serverName && !!this.userName) :
|
||||
@@ -366,7 +366,7 @@ export class ConnectionWidget {
|
||||
var displayName: string;
|
||||
var authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType];
|
||||
|
||||
if (authTypeOption) {
|
||||
if(authTypeOption) {
|
||||
authTypeOption.categoryValues.forEach(c => {
|
||||
if (c.name === authTypeName) {
|
||||
displayName = c.displayName;
|
||||
|
||||
@@ -17,7 +17,7 @@ import { SplitView } from 'sql/base/browser/ui/splitview/splitview';
|
||||
import { attachButtonStyler, attachListBoxStyler, attachInputBoxStyler, attachSelectBoxStyler } from 'sql/common/theme/styler';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import * as BackupConstants from 'sql/parts/disasterRecovery/backup/constants';
|
||||
import { IBackupService, IBackupUiService, TaskExecutionMode } from 'sql/parts/disasterRecovery/backup/common/backupService';
|
||||
import { IDisasterRecoveryService, IDisasterRecoveryUiService, TaskExecutionMode } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import FileValidationConstants = require('sql/parts/fileBrowser/common/fileValidationServiceConstants');
|
||||
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
@@ -140,8 +140,8 @@ export class BackupComponent {
|
||||
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
private _backupService: IBackupService;
|
||||
private _backupUiService: IBackupUiService;
|
||||
private _disasterRecoveryService: IDisasterRecoveryService;
|
||||
private _disasterRecoveryUiService: IDisasterRecoveryUiService;
|
||||
private _uri: string;
|
||||
private _toDispose: lifecycle.IDisposable[] = [];
|
||||
private _advancedHeaderSize = 32;
|
||||
@@ -198,9 +198,9 @@ export class BackupComponent {
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeDetectorRef: ChangeDetectorRef,
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService,
|
||||
) {
|
||||
this._backupService = _bootstrapService.backupService;
|
||||
this._backupUiService = _bootstrapService.backupUiService;
|
||||
this._backupUiService.onShowBackupEvent((param) => this.onGetBackupConfigInfo(param));
|
||||
this._disasterRecoveryService = _bootstrapService.disasterRecoveryService;
|
||||
this._disasterRecoveryUiService = _bootstrapService.disasterRecoveryUiService;
|
||||
this._disasterRecoveryUiService.onShowBackupEvent((param) => this.onGetBackupConfigInfo(param));
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -315,12 +315,12 @@ export class BackupComponent {
|
||||
ngAfterViewInit() {
|
||||
// Set category view for advanced options. This should be defined in ngAfterViewInit so that it correctly calculates the text height after data binding.
|
||||
var splitview = new SplitView(this.advancedOptionElement.nativeElement);
|
||||
var advancedBodySize = DOM.getTotalHeight(this.advancedOptionBodyElement.nativeElement);
|
||||
var advancedBodySize = DOM.getTotalHeight(this.advancedOptionBodyElement.nativeElement);
|
||||
var categoryView = new CategoryView(this.advancedConfigurationLabel, this.advancedOptionBodyElement.nativeElement, true, advancedBodySize, this._advancedHeaderSize);
|
||||
splitview.addView(categoryView);
|
||||
splitview.layout(advancedBodySize + this._advancedHeaderSize);
|
||||
|
||||
this._backupUiService.onShowBackupDialog();
|
||||
this._disasterRecoveryUiService.onShowBackupDialog();
|
||||
}
|
||||
|
||||
private onGetBackupConfigInfo(param: DashboardComponentParams) {
|
||||
@@ -336,7 +336,7 @@ export class BackupComponent {
|
||||
this._uri = param.ownerUri;
|
||||
|
||||
// Get backup configuration info
|
||||
this._backupService.getBackupConfigInfo(this._uri).then(configInfo => {
|
||||
this._disasterRecoveryService.getBackupConfigInfo(this._uri).then(configInfo => {
|
||||
if (configInfo) {
|
||||
this.defaultNewBackupFolder = configInfo.defaultBackupFolder;
|
||||
this.recoveryModel = configInfo.recoveryModel;
|
||||
@@ -546,12 +546,12 @@ export class BackupComponent {
|
||||
* UI event handlers
|
||||
*/
|
||||
private onScript(): void {
|
||||
this._backupService.backup(this._uri, this.createBackupInfo(), TaskExecutionMode.script);
|
||||
this._disasterRecoveryService.backup(this._uri, this.createBackupInfo(), TaskExecutionMode.script);
|
||||
this.close();
|
||||
}
|
||||
|
||||
private onOk(): void {
|
||||
this._backupService.backup(this._uri, this.createBackupInfo(), TaskExecutionMode.executeAndScript);
|
||||
this._disasterRecoveryService.backup(this._uri, this.createBackupInfo(), TaskExecutionMode.executeAndScript);
|
||||
this.close();
|
||||
}
|
||||
|
||||
@@ -561,7 +561,7 @@ export class BackupComponent {
|
||||
}
|
||||
|
||||
private close(): void {
|
||||
this._backupUiService.closeBackup();
|
||||
this._disasterRecoveryUiService.closeBackup();
|
||||
this.resetDialog();
|
||||
}
|
||||
|
||||
|
||||
149
src/sql/parts/disasterRecovery/common/disasterRecoveryService.ts
Normal file
149
src/sql/parts/disasterRecovery/common/disasterRecoveryService.ts
Normal file
@@ -0,0 +1,149 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import data = require('data');
|
||||
import { IDisasterRecoveryService, TaskExecutionMode } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import * as Constants from 'sql/common/constants';
|
||||
import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
||||
import * as TelemetryUtils from 'sql/common/telemetryUtilities';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
|
||||
export class DisasterRecoveryService implements IDisasterRecoveryService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
private _providers: { [handle: string]: data.DisasterRecoveryProvider; } = Object.create(null);
|
||||
|
||||
constructor(
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService,
|
||||
@ITelemetryService private _telemetryService: ITelemetryService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get database metadata needed to populate backup UI
|
||||
*/
|
||||
public getBackupConfigInfo(connectionUri: string): Thenable<data.BackupConfigInfo> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
if (provider) {
|
||||
return provider.getBackupConfigInfo(connectionUri);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup a data source using the provided connection
|
||||
*/
|
||||
public backup(connectionUri: string, backupInfo: { [key: string]: any }, taskExecutionMode: TaskExecutionMode): Thenable<data.BackupResponse> {
|
||||
return new Promise<data.BackupResponse>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.BackupCreated, { provider: providerResult.providerName });
|
||||
providerResult.provider.backup(connectionUri, backupInfo, taskExecutionMode).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets restore config Info
|
||||
*/
|
||||
getRestoreConfigInfo(connectionUri: string): Thenable<data.RestoreConfigInfo> {
|
||||
return new Promise<data.RestoreConfigInfo>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
providerResult.provider.getRestoreConfigInfo(connectionUri).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a data source using a backup file or database
|
||||
*/
|
||||
restore(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestoreResponse> {
|
||||
return new Promise<data.RestoreResponse>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.RestoreRequested, { provider: providerResult.providerName });
|
||||
providerResult.provider.restore(connectionUri, restoreInfo).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getProvider(connectionUri: string): { provider: data.DisasterRecoveryProvider, providerName: string } {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
return { provider: this._providers[providerId], providerName: providerId };
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets restore plan to do the restore operation on a database
|
||||
*/
|
||||
getRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestorePlanResponse> {
|
||||
return new Promise<data.RestorePlanResponse>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
providerResult.provider.getRestorePlan(connectionUri, restoreInfo).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels a restore plan
|
||||
*/
|
||||
cancelRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
providerResult.provider.cancelRestorePlan(connectionUri, restoreInfo).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a disaster recovery provider
|
||||
*/
|
||||
public registerProvider(providerId: string, provider: data.DisasterRecoveryProvider): void {
|
||||
this._providers[providerId] = provider;
|
||||
}
|
||||
}
|
||||
@@ -4,87 +4,25 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import * as data from 'data';
|
||||
import * as Constants from 'sql/common/constants';
|
||||
import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
||||
import * as TelemetryUtils from 'sql/common/telemetryUtilities';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IBackupService, TaskExecutionMode, IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService';
|
||||
import { BackupDialog } from 'sql/parts/disasterRecovery/backup/backupDialog';
|
||||
import { OptionsDialog } from 'sql/base/browser/ui/modal/optionsDialog';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import * as data from 'data';
|
||||
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as ConnectionUtils from 'sql/parts/connection/common/utils';
|
||||
import { OptionsDialog } from 'sql/base/browser/ui/modal/optionsDialog';
|
||||
import { BackupDialog } from 'sql/parts/disasterRecovery/backup/backupDialog';
|
||||
import { IDisasterRecoveryService, IDisasterRecoveryUiService, TaskExecutionMode } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import ConnectionUtils = require('sql/parts/connection/common/utils');
|
||||
import { ProviderConnectionInfo } from 'sql/parts/connection/common/providerConnectionInfo';
|
||||
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
|
||||
export class BackupService implements IBackupService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
private _providers: { [handle: string]: data.BackupProvider; } = Object.create(null);
|
||||
|
||||
constructor(
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService,
|
||||
@ITelemetryService private _telemetryService: ITelemetryService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get database metadata needed to populate backup UI
|
||||
*/
|
||||
public getBackupConfigInfo(connectionUri: string): Thenable<data.BackupConfigInfo> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
if (provider) {
|
||||
return provider.getBackupConfigInfo(connectionUri);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup a data source using the provided connection
|
||||
*/
|
||||
public backup(connectionUri: string, backupInfo: { [key: string]: any }, taskExecutionMode: TaskExecutionMode): Thenable<data.BackupResponse> {
|
||||
return new Promise<data.BackupResponse>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.BackupCreated, { provider: providerResult.providerName });
|
||||
providerResult.provider.backup(connectionUri, backupInfo, taskExecutionMode).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getProvider(connectionUri: string): { provider: data.BackupProvider, providerName: string } {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
return { provider: this._providers[providerId], providerName: providerId };
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a disaster recovery provider
|
||||
*/
|
||||
public registerProvider(providerId: string, provider: data.BackupProvider): void {
|
||||
this._providers[providerId] = provider;
|
||||
}
|
||||
}
|
||||
|
||||
export class BackupUiService implements IBackupUiService {
|
||||
export class DisasterRecoveryUiService implements IDisasterRecoveryUiService {
|
||||
public _serviceBrand: any;
|
||||
private _backupDialogs: { [providerName: string]: BackupDialog | OptionsDialog } = {};
|
||||
private _currentProvider: string;
|
||||
@@ -99,10 +37,10 @@ export class BackupUiService implements IBackupUiService {
|
||||
constructor( @IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IPartService private _partService: IPartService,
|
||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||
@IBackupService private _disasterRecoveryService: IBackupService,
|
||||
@IDisasterRecoveryService private _disasterRecoveryService: IDisasterRecoveryService,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService) {
|
||||
this._onShowBackupEvent = new Emitter<DashboardComponentParams>();
|
||||
}
|
||||
this._onShowBackupEvent = new Emitter<DashboardComponentParams>();
|
||||
}
|
||||
|
||||
public showBackup(connection: IConnectionProfile): Promise<any> {
|
||||
let self = this;
|
||||
@@ -148,16 +86,16 @@ export class BackupUiService implements IBackupUiService {
|
||||
} else {
|
||||
let uri = this._connectionManagementService.getConnectionId(connection)
|
||||
+ ProviderConnectionInfo.idSeparator
|
||||
+ ConnectionUtils.ConnectionUriBackupIdAttributeName
|
||||
+ Utils.ConnectionUriBackupIdAttributeName
|
||||
+ ProviderConnectionInfo.nameValueSeparator
|
||||
+ BackupUiService._connectionUniqueId;
|
||||
+ DisasterRecoveryUiService._connectionUniqueId;
|
||||
|
||||
BackupUiService._connectionUniqueId++;
|
||||
DisasterRecoveryUiService._connectionUniqueId++;
|
||||
|
||||
// Create connection if needed
|
||||
if (!this._connectionManagementService.isConnected(uri)) {
|
||||
this._connectionManagementService.connect(connection, uri).then(() => {
|
||||
this._onShowBackupEvent.fire({ connection: connection, ownerUri: uri });
|
||||
this._onShowBackupEvent.fire({connection: connection, ownerUri: uri});
|
||||
});
|
||||
}
|
||||
(backupDialog as BackupDialog).open(connection);
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import Event from 'vs/base/common/event';
|
||||
import data = require('data');
|
||||
@@ -19,12 +20,12 @@ export enum TaskExecutionMode {
|
||||
executeAndScript = 2,
|
||||
}
|
||||
|
||||
export const SERVICE_ID = 'backupService';
|
||||
export const UI_SERVICE_ID = 'backupUiService';
|
||||
export const SERVICE_ID = 'disasterRecoveryService';
|
||||
export const UI_SERVICE_ID = 'disasterRecoveryUiService';
|
||||
|
||||
export const IBackupUiService = createDecorator<IBackupUiService>(UI_SERVICE_ID);
|
||||
export const IDisasterRecoveryUiService = createDecorator<IDisasterRecoveryUiService>(UI_SERVICE_ID);
|
||||
|
||||
export interface IBackupUiService {
|
||||
export interface IDisasterRecoveryUiService {
|
||||
_serviceBrand: any;
|
||||
|
||||
/**
|
||||
@@ -48,9 +49,9 @@ export interface IBackupUiService {
|
||||
onShowBackupDialog();
|
||||
}
|
||||
|
||||
export const IBackupService = createDecorator<IBackupService>(SERVICE_ID);
|
||||
export const IDisasterRecoveryService = createDecorator<IDisasterRecoveryService>(SERVICE_ID);
|
||||
|
||||
export interface IBackupService {
|
||||
export interface IDisasterRecoveryService {
|
||||
_serviceBrand: any;
|
||||
|
||||
getBackupConfigInfo(connectionUri: string): Thenable<data.BackupConfigInfo>;
|
||||
@@ -63,5 +64,31 @@ export interface IBackupService {
|
||||
/**
|
||||
* Register a disaster recovery provider
|
||||
*/
|
||||
registerProvider(providerId: string, provider: data.BackupProvider): void;
|
||||
registerProvider(providerId: string, provider: data.DisasterRecoveryProvider): void;
|
||||
|
||||
/**
|
||||
* Restore a data source using a backup file or database
|
||||
*/
|
||||
restore(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestoreResponse>;
|
||||
|
||||
/**
|
||||
* Gets restore plan to do the restore operation on a database
|
||||
*/
|
||||
getRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestorePlanResponse>;
|
||||
|
||||
/**
|
||||
* Gets restore config Info
|
||||
*/
|
||||
getRestoreConfigInfo(connectionUri: string): Thenable<data.RestoreConfigInfo>;
|
||||
|
||||
/**
|
||||
* Cancel restore plan
|
||||
*/
|
||||
cancelRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<boolean>;
|
||||
}
|
||||
|
||||
export const IRestoreDialogController = createDecorator<IRestoreDialogController>('restoreDialogService');
|
||||
export interface IRestoreDialogController {
|
||||
_serviceBrand: any;
|
||||
showDialog(connection: IConnectionProfile): TPromise<void>;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as data from 'data';
|
||||
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
|
||||
export const SERVICE_ID = 'restoreService';
|
||||
export const IRestoreService = createDecorator<IRestoreService>(SERVICE_ID);
|
||||
export { TaskExecutionMode } from 'sql/parts/disasterRecovery/backup/common/backupService';
|
||||
|
||||
export interface IRestoreService {
|
||||
_serviceBrand: any;
|
||||
|
||||
/**
|
||||
* Register a disaster recovery provider
|
||||
*/
|
||||
registerProvider(providerId: string, provider: data.RestoreProvider): void;
|
||||
|
||||
/**
|
||||
* Restore a data source using a backup file or database
|
||||
*/
|
||||
restore(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestoreResponse>;
|
||||
|
||||
/**
|
||||
* Gets restore plan to do the restore operation on a database
|
||||
*/
|
||||
getRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestorePlanResponse>;
|
||||
|
||||
/**
|
||||
* Gets restore config Info
|
||||
*/
|
||||
getRestoreConfigInfo(connectionUri: string): Thenable<data.RestoreConfigInfo>;
|
||||
|
||||
/**
|
||||
* Cancel restore plan
|
||||
*/
|
||||
cancelRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<boolean>;
|
||||
}
|
||||
|
||||
export const IRestoreDialogController = createDecorator<IRestoreDialogController>('restoreDialogService');
|
||||
export interface IRestoreDialogController {
|
||||
_serviceBrand: any;
|
||||
showDialog(connection: IConnectionProfile): TPromise<void>;
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import * as DialogHelper from 'sql/base/browser/ui/modal/dialogHelper';
|
||||
import { Modal } from 'sql/base/browser/ui/modal/modal';
|
||||
import { attachButtonStyler, attachModalDialogStyler, attachTableStyler, attachInputBoxStyler, attachSelectBoxStyler, attachEditableDropdownStyler } from 'sql/common/theme/styler';
|
||||
import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
||||
import { ServiceOptionType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import * as BackupConstants from 'sql/parts/disasterRecovery/backup/constants';
|
||||
import { RestoreViewModel, RestoreOptionParam, SouceDatabaseNamesParam } from 'sql/parts/disasterRecovery/restore/restoreViewModel';
|
||||
import * as FileValidationConstants from 'sql/parts/fileBrowser/common/fileValidationServiceConstants';
|
||||
@@ -39,7 +40,6 @@ import { TabbedPanel, PanelTabIdentifier } from 'sql/base/browser/ui/panel/panel
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import * as data from 'data';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
interface FileListElement {
|
||||
logicalFileName: string;
|
||||
|
||||
@@ -4,128 +4,21 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import * as data from 'data';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as Constants from 'sql/common/constants';
|
||||
import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
||||
import * as TelemetryUtils from 'sql/common/telemetryUtilities';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { IRestoreService, IRestoreDialogController, TaskExecutionMode } from 'sql/parts/disasterRecovery/restore/common/restoreService';
|
||||
|
||||
import { OptionsDialog } from 'sql/base/browser/ui/modal/optionsDialog';
|
||||
import { RestoreDialog } from 'sql/parts/disasterRecovery/restore/restoreDialog';
|
||||
import * as ConnectionConstants from 'sql/parts/connection/common/constants';
|
||||
import { MssqlRestoreInfo } from 'sql/parts/disasterRecovery/restore/mssqlRestoreInfo';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import * as ConnectionConstants from 'sql/parts/connection/common/constants';
|
||||
import { ProviderConnectionInfo } from 'sql/parts/connection/common/providerConnectionInfo';
|
||||
import { IDisasterRecoveryService, IRestoreDialogController, TaskExecutionMode } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import { MssqlRestoreInfo } from 'sql/parts/disasterRecovery/restore/mssqlRestoreInfo';
|
||||
import { RestoreDialog } from 'sql/parts/disasterRecovery/restore/restoreDialog';
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
|
||||
export class RestoreService implements IRestoreService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
private _providers: { [handle: string]: data.RestoreProvider; } = Object.create(null);
|
||||
|
||||
constructor(
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService,
|
||||
@ITelemetryService private _telemetryService: ITelemetryService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets restore config Info
|
||||
*/
|
||||
getRestoreConfigInfo(connectionUri: string): Thenable<data.RestoreConfigInfo> {
|
||||
return new Promise<data.RestoreConfigInfo>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
providerResult.provider.getRestoreConfigInfo(connectionUri).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a data source using a backup file or database
|
||||
*/
|
||||
restore(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestoreResponse> {
|
||||
return new Promise<data.RestoreResponse>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.RestoreRequested, { provider: providerResult.providerName });
|
||||
providerResult.provider.restore(connectionUri, restoreInfo).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getProvider(connectionUri: string): { provider: data.RestoreProvider, providerName: string } {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
return { provider: this._providers[providerId], providerName: providerId };
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets restore plan to do the restore operation on a database
|
||||
*/
|
||||
getRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestorePlanResponse> {
|
||||
return new Promise<data.RestorePlanResponse>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
providerResult.provider.getRestorePlan(connectionUri, restoreInfo).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels a restore plan
|
||||
*/
|
||||
cancelRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
let providerResult = this.getProvider(connectionUri);
|
||||
if (providerResult) {
|
||||
providerResult.provider.cancelRestorePlan(connectionUri, restoreInfo).then(result => {
|
||||
resolve(result);
|
||||
}, error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject(Constants.InvalidProvider);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a disaster recovery provider
|
||||
*/
|
||||
public registerProvider(providerId: string, provider: data.RestoreProvider): void {
|
||||
this._providers[providerId] = provider;
|
||||
}
|
||||
}
|
||||
|
||||
import * as data from 'data';
|
||||
|
||||
export class RestoreDialogController implements IRestoreDialogController {
|
||||
_serviceBrand: any;
|
||||
@@ -139,7 +32,7 @@ export class RestoreDialogController implements IRestoreDialogController {
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IRestoreService private _restoreService: IRestoreService,
|
||||
@IDisasterRecoveryService private _disasterRecoveryService: IDisasterRecoveryService,
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService,
|
||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService
|
||||
) {
|
||||
@@ -153,14 +46,14 @@ export class RestoreDialogController implements IRestoreDialogController {
|
||||
restoreOption.taskExecutionMode = TaskExecutionMode.executeAndScript;
|
||||
}
|
||||
|
||||
this._restoreService.restore(this._ownerUri, restoreOption);
|
||||
this._disasterRecoveryService.restore(this._ownerUri, restoreOption);
|
||||
let restoreDialog = this._restoreDialogs[this._currentProvider];
|
||||
restoreDialog.close();
|
||||
}
|
||||
|
||||
private handleMssqlOnValidateFile(overwriteTargetDatabase: boolean = false): void {
|
||||
let restoreDialog = this._restoreDialogs[this._currentProvider] as RestoreDialog;
|
||||
this._restoreService.getRestorePlan(this._ownerUri, this.setRestoreOption(overwriteTargetDatabase)).then(restorePlanResponse => {
|
||||
this._disasterRecoveryService.getRestorePlan(this._ownerUri, this.setRestoreOption(overwriteTargetDatabase)).then(restorePlanResponse => {
|
||||
this._sessionId = restorePlanResponse.sessionId;
|
||||
|
||||
if (restorePlanResponse.errorMessage) {
|
||||
@@ -195,7 +88,7 @@ export class RestoreDialogController implements IRestoreDialogController {
|
||||
private getMssqlRestoreConfigInfo(): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let restoreDialog = this._restoreDialogs[this._currentProvider] as RestoreDialog;
|
||||
this._restoreService.getRestoreConfigInfo(this._ownerUri).then(restoreConfigInfo => {
|
||||
this._disasterRecoveryService.getRestoreConfigInfo(this._ownerUri).then(restoreConfigInfo => {
|
||||
restoreDialog.viewModel.updateOptionWithConfigInfo(restoreConfigInfo.configInfo);
|
||||
resolve();
|
||||
}, error => {
|
||||
@@ -257,7 +150,7 @@ export class RestoreDialogController implements IRestoreDialogController {
|
||||
private handleOnCancel(): void {
|
||||
let restoreInfo = new MssqlRestoreInfo();
|
||||
restoreInfo.sessionId = this._sessionId;
|
||||
this._restoreService.cancelRestorePlan(this._ownerUri, restoreInfo).then(() => {
|
||||
this._disasterRecoveryService.cancelRestorePlan(this._ownerUri, restoreInfo).then(() => {
|
||||
this._connectionService.disconnect(this._ownerUri);
|
||||
});
|
||||
}
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
'use strict';
|
||||
import * as data from 'data';
|
||||
import { ServiceOptionType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import * as DialogHelper from 'sql/base/browser/ui/modal/dialogHelper';
|
||||
import * as types from 'vs/base/common/types';
|
||||
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export interface RestoreOptionsElement {
|
||||
optionMetadata: data.ServiceOption;
|
||||
|
||||
@@ -31,7 +31,6 @@ const columns = [
|
||||
];
|
||||
|
||||
export class ProfilerTestBackend implements data.ProfilerProvider {
|
||||
public readonly providerId = 'MSSQL';
|
||||
private index = 0;
|
||||
private timeOutMap = new Map<string, number>();
|
||||
private testData: Array<Array<string>> = new Array<Array<string>>();
|
||||
|
||||
@@ -15,8 +15,7 @@ import { IScriptingService } from 'sql/services/scripting/scriptingService';
|
||||
import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
|
||||
import { IQueryManagementService } from 'sql/parts/query/common/queryManagement';
|
||||
import { IAdminService } from 'sql/parts/admin/common/adminService';
|
||||
import { IRestoreDialogController, IRestoreService } from 'sql/parts/disasterRecovery/restore/common/restoreService';
|
||||
import { IBackupService, IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService';
|
||||
import { IDisasterRecoveryService, IDisasterRecoveryUiService, IRestoreDialogController } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import { IInsightsDialogService } from 'sql/parts/insights/common/interfaces';
|
||||
import { ISqlOAuthService } from 'sql/common/sqlOAuthService';
|
||||
import { IFileBrowserService, IFileBrowserDialogController } from 'sql/parts/fileBrowser/common/interfaces';
|
||||
@@ -58,9 +57,8 @@ export interface IBootstrapService {
|
||||
connectionDialogService: IConnectionDialogService;
|
||||
queryModelService: IQueryModelService;
|
||||
adminService: IAdminService;
|
||||
backupService: IBackupService;
|
||||
backupUiService: IBackupUiService;
|
||||
restoreService: IRestoreService;
|
||||
disasterRecoveryService: IDisasterRecoveryService;
|
||||
disasterRecoveryUiService: IDisasterRecoveryUiService;
|
||||
keybindingService: IKeybindingService;
|
||||
contextKeyService: IContextKeyService;
|
||||
contextMenuService: IContextMenuService;
|
||||
|
||||
@@ -16,8 +16,7 @@ import { IScriptingService } from 'sql/services/scripting/scriptingService';
|
||||
import { IQueryManagementService } from 'sql/parts/query/common/queryManagement';
|
||||
import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
|
||||
import { IAdminService } from 'sql/parts/admin/common/adminService';
|
||||
import { IRestoreDialogController, IRestoreService } from 'sql/parts/disasterRecovery/restore/common/restoreService';
|
||||
import { IBackupService, IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService';
|
||||
import { IDisasterRecoveryService, IDisasterRecoveryUiService, IRestoreDialogController } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import { IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
|
||||
import { IInsightsDialogService } from 'sql/parts/insights/common/interfaces';
|
||||
import { ISqlOAuthService } from 'sql/common/sqlOAuthService';
|
||||
@@ -68,10 +67,9 @@ export class BootstrapService implements IBootstrapService {
|
||||
@IAdminService public adminService: IAdminService,
|
||||
@IWorkbenchThemeService public themeService: IWorkbenchThemeService,
|
||||
@IWorkbenchEditorService public editorService: IWorkbenchEditorService,
|
||||
@IBackupService public backupService: IBackupService,
|
||||
@IBackupUiService public backupUiService: IBackupUiService,
|
||||
@IDisasterRecoveryService public disasterRecoveryService: IDisasterRecoveryService,
|
||||
@IDisasterRecoveryUiService public disasterRecoveryUiService: IDisasterRecoveryUiService,
|
||||
@IRestoreDialogController public restoreDialogService: IRestoreDialogController,
|
||||
@IRestoreService public restoreService: IRestoreService,
|
||||
@IConnectionDialogService public connectionDialogService: IConnectionDialogService,
|
||||
@IQueryModelService public queryModelService: IQueryModelService,
|
||||
@IKeybindingService public keybindingService: IKeybindingService,
|
||||
|
||||
@@ -20,7 +20,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
private _proxy: MainThreadDataProtocolShape;
|
||||
|
||||
private static _handlePool: number = 0;
|
||||
private _adapter = new Map<number, data.DataProvider>();
|
||||
private _adapter = new Map<number, data.DataProtocolProvider>();
|
||||
|
||||
constructor(
|
||||
threadService: IThreadService
|
||||
@@ -40,121 +40,71 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
return ExtHostDataProtocol._handlePool++;
|
||||
}
|
||||
|
||||
private _resolveProvider<P extends data.DataProvider>(handle: number): P {
|
||||
let provider = this._adapter.get(handle) as P;
|
||||
if (provider) {
|
||||
return provider;
|
||||
} else {
|
||||
throw new Error(`Unfound provider ${handle}`);
|
||||
}
|
||||
private _runWithProvider<T>(handle: number, action: (p: data.DataProtocolProvider) => Thenable<T>): Thenable<T> {
|
||||
let provider = this._adapter.get(handle);
|
||||
return provider !== undefined
|
||||
? action(provider)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
private registerProvider(provider: data.DataProvider): vscode.Disposable {
|
||||
|
||||
$registerProvider(provider: data.DataProtocolProvider): vscode.Disposable {
|
||||
provider.handle = this._nextHandle();
|
||||
this._adapter.set(provider.handle, provider);
|
||||
|
||||
this._proxy.$registerProvider(provider.providerId, provider.handle);
|
||||
return this._createDisposable(provider.handle);
|
||||
};
|
||||
|
||||
$registerConnectionProvider(provider: data.ConnectionProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerConnectionProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerBackupProvider(provider: data.BackupProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerBackupProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerRestoreProvider(provider: data.RestoreProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerRestoreProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerScriptingProvider(provider: data.ScriptingProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerScriptingProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerQueryProvider(provider: data.QueryProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerQueryProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerMetadataProvider(provider: data.MetadataProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerMetadataProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerTaskServicesProvider(provider: data.TaskServicesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerTaskServicesProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerFileBrowserProvider(provider: data.FileBrowserProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerFileBrowserProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerObjectExplorerProvider(provider: data.ObjectExplorerProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerObjectExplorerProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerProfilerProvider(provider: data.ProfilerProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerProfilerProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerAdminServicesProvider(provider: data.AdminServicesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerAdminServicesProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerCapabilitiesServiceProvider(provider: data.CapabilitiesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider);
|
||||
this._proxy.$registerCapabilitiesServiceProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
// Capabilities Discovery handlers
|
||||
$getServerCapabilities(handle: number, client: data.DataProtocolClientCapabilities): Thenable<data.DataProtocolServerCapabilities> {
|
||||
return this._resolveProvider<data.CapabilitiesProvider>(handle).getServerCapabilities(client);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.capabilitiesProvider ? provider.capabilitiesProvider.getServerCapabilities(client)
|
||||
: undefined;
|
||||
});
|
||||
}
|
||||
|
||||
// Connection Management handlers
|
||||
$connect(handle: number, connectionUri: string, connection: data.ConnectionInfo): Thenable<boolean> {
|
||||
return this._resolveProvider<data.ConnectionProvider>(handle).connect(connectionUri, connection);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.connectionProvider ? provider.connectionProvider.connect(connectionUri, connection)
|
||||
: undefined;
|
||||
});
|
||||
}
|
||||
|
||||
$disconnect(handle: number, connectionUri: string): Thenable<boolean> {
|
||||
return this._resolveProvider<data.ConnectionProvider>(handle).disconnect(connectionUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.connectionProvider ? provider.connectionProvider.disconnect(connectionUri)
|
||||
: undefined;
|
||||
});
|
||||
}
|
||||
|
||||
$cancelConnect(handle: number, connectionUri: string): Thenable<boolean> {
|
||||
return this._resolveProvider<data.ConnectionProvider>(handle).cancelConnect(connectionUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.connectionProvider ? provider.connectionProvider.cancelConnect(connectionUri)
|
||||
: undefined;
|
||||
});
|
||||
}
|
||||
|
||||
$changeDatabase(handle: number, connectionUri: string, newDatabase: string): Thenable<boolean> {
|
||||
return this._resolveProvider<data.ConnectionProvider>(handle).changeDatabase(connectionUri, newDatabase);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.connectionProvider ? provider.connectionProvider.changeDatabase(connectionUri, newDatabase)
|
||||
: undefined;
|
||||
});
|
||||
}
|
||||
|
||||
$listDatabases(handle: number, connectionUri: string): Thenable<data.ListDatabasesResult> {
|
||||
return this._resolveProvider<data.ConnectionProvider>(handle).listDatabases(connectionUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.connectionProvider ? provider.connectionProvider.listDatabases(connectionUri)
|
||||
: undefined;
|
||||
});
|
||||
}
|
||||
|
||||
$rebuildIntelliSenseCache(handle: number, connectionUri: string): Thenable<void> {
|
||||
return this._resolveProvider<data.ConnectionProvider>(handle).rebuildIntelliSenseCache(connectionUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.connectionProvider ? provider.connectionProvider.rebuildIntelliSenseCache(connectionUri)
|
||||
: undefined;
|
||||
});
|
||||
}
|
||||
|
||||
$onConnectComplete(handle: number, connectionInfoSummary: data.ConnectionInfoSummary): void {
|
||||
@@ -177,31 +127,45 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
// Query Management handlers
|
||||
|
||||
$cancelQuery(handle: number, ownerUri: string): Thenable<data.QueryCancelResult> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).cancelQuery(ownerUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.cancelQuery(ownerUri);
|
||||
});
|
||||
}
|
||||
|
||||
$runQuery(handle: number, ownerUri: string, selection: data.ISelectionData, runOptions?: data.ExecutionPlanOptions): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).runQuery(ownerUri, selection, runOptions);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.runQuery(ownerUri, selection, runOptions);
|
||||
});
|
||||
}
|
||||
|
||||
$runQueryStatement(handle: number, ownerUri: string, line: number, column: number): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).runQueryStatement(ownerUri, line, column);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.runQueryStatement(ownerUri, line, column);
|
||||
});
|
||||
}
|
||||
|
||||
$runQueryString(handle: number, ownerUri: string, queryString: string): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).runQueryString(ownerUri, queryString);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.runQueryString(ownerUri, queryString);
|
||||
});
|
||||
}
|
||||
|
||||
$runQueryAndReturn(handle: number, ownerUri: string, queryString: string): Thenable<data.SimpleExecuteResult> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).runQueryAndReturn(ownerUri, queryString);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.runQueryAndReturn(ownerUri, queryString);
|
||||
});
|
||||
}
|
||||
|
||||
$getQueryRows(handle: number, rowData: data.QueryExecuteSubsetParams): Thenable<data.QueryExecuteSubsetResult> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).getQueryRows(rowData);
|
||||
return this._runWithProvider(handle, (provider) => {
|
||||
return provider.queryProvider.getQueryRows(rowData);
|
||||
});
|
||||
}
|
||||
|
||||
$disposeQuery(handle: number, ownerUri: string): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).disposeQuery(ownerUri);
|
||||
return this._runWithProvider(handle, (provider) => {
|
||||
return provider.queryProvider.disposeQuery(ownerUri);
|
||||
});
|
||||
}
|
||||
|
||||
$onQueryComplete(handle: number, result: data.QueryExecuteCompleteNotificationResult): void {
|
||||
@@ -221,44 +185,64 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
}
|
||||
|
||||
$saveResults(handle: number, requestParams: data.SaveResultsRequestParams): Thenable<data.SaveResultRequestResult> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).saveResults(requestParams);
|
||||
return this._runWithProvider(handle, (provider) => {
|
||||
return provider.queryProvider.saveResults(requestParams);
|
||||
});
|
||||
}
|
||||
|
||||
// Edit Data handlers
|
||||
$commitEdit(handle: number, ownerUri: string): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).commitEdit(ownerUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.commitEdit(ownerUri);
|
||||
});
|
||||
}
|
||||
|
||||
$createRow(handle: number, ownerUri: string): Thenable<data.EditCreateRowResult> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).createRow(ownerUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.createRow(ownerUri);
|
||||
});
|
||||
}
|
||||
|
||||
$deleteRow(handle: number, ownerUri: string, rowId: number): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).deleteRow(ownerUri, rowId);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.deleteRow(ownerUri, rowId);
|
||||
});
|
||||
}
|
||||
|
||||
$disposeEdit(handle: number, ownerUri: string): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).disposeEdit(ownerUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.disposeEdit(ownerUri);
|
||||
});
|
||||
}
|
||||
|
||||
$initializeEdit(handle: number, ownerUri: string, schemaName: string, objectName: string, objectType: string, rowLimit: number): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).initializeEdit(ownerUri, schemaName, objectName, objectType, rowLimit);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.initializeEdit(ownerUri, schemaName, objectName, objectType, rowLimit);
|
||||
});
|
||||
}
|
||||
|
||||
$revertCell(handle: number, ownerUri: string, rowId: number, columnId: number): Thenable<data.EditRevertCellResult> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).revertCell(ownerUri, rowId, columnId);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.revertCell(ownerUri, rowId, columnId);
|
||||
});
|
||||
}
|
||||
|
||||
$revertRow(handle: number, ownerUri: string, rowId: number): Thenable<void> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).revertRow(ownerUri, rowId);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.revertRow(ownerUri, rowId);
|
||||
});
|
||||
}
|
||||
|
||||
$updateCell(handle: number, ownerUri: string, rowId: number, columnId: number, newValue: string): Thenable<data.EditUpdateCellResult> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).updateCell(ownerUri, rowId, columnId, newValue);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.queryProvider.updateCell(ownerUri, rowId, columnId, newValue);
|
||||
});
|
||||
}
|
||||
|
||||
$getEditRows(handle: number, rowData: data.EditSubsetParams): Thenable<data.EditSubsetResult> {
|
||||
return this._resolveProvider<data.QueryProvider>(handle).getEditRows(rowData);
|
||||
return this._runWithProvider(handle, (provider) => {
|
||||
return provider.queryProvider.getEditRows(rowData);
|
||||
});
|
||||
}
|
||||
|
||||
$onEditSessionReady(handle: number, ownerUri: string, success: boolean, message: string): void {
|
||||
@@ -267,36 +251,39 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
|
||||
// Metadata handlers
|
||||
public $getMetadata(handle: number, connectionUri: string): Thenable<data.ProviderMetadata> {
|
||||
return this._resolveProvider<data.MetadataProvider>(handle).getMetadata(connectionUri);
|
||||
}
|
||||
|
||||
public $getDatabases(handle: number, connectionUri: string): Thenable<string[]> {
|
||||
return this._resolveProvider<data.MetadataProvider>(handle).getDatabases(connectionUri);
|
||||
}
|
||||
|
||||
public $getTableInfo(handle: number, connectionUri: string, metadata: data.ObjectMetadata): Thenable<data.ColumnMetadata[]> {
|
||||
return this._resolveProvider<data.MetadataProvider>(handle).getTableInfo(connectionUri, metadata);
|
||||
}
|
||||
|
||||
public $getViewInfo(handle: number, connectionUri: string, metadata: data.ObjectMetadata): Thenable<data.ColumnMetadata[]> {
|
||||
return this._resolveProvider<data.MetadataProvider>(handle).getViewInfo(connectionUri, metadata);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.metadataProvider ? provider.metadataProvider.getMetadata(connectionUri)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
// Object Explorer Service
|
||||
public $createObjectExplorerSession(handle: number, connInfo: data.ConnectionInfo): Thenable<data.ObjectExplorerSessionResponse> {
|
||||
return this._resolveProvider<data.ObjectExplorerProvider>(handle).createNewSession(connInfo);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.objectExplorerProvider ? provider.objectExplorerProvider.createNewSession(connInfo)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $expandObjectExplorerNode(handle: number, nodeInfo: data.ExpandNodeInfo): Thenable<boolean> {
|
||||
return this._resolveProvider<data.ObjectExplorerProvider>(handle).expandNode(nodeInfo);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.objectExplorerProvider ? provider.objectExplorerProvider.expandNode(nodeInfo)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $refreshObjectExplorerNode(handle: number, nodeInfo: data.ExpandNodeInfo): Thenable<boolean> {
|
||||
return this._resolveProvider<data.ObjectExplorerProvider>(handle).refreshNode(nodeInfo);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.objectExplorerProvider ? provider.objectExplorerProvider.refreshNode(nodeInfo)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $closeObjectExplorerSession(handle: number, closeSessionInfo: data.ObjectExplorerCloseSessionInfo): Thenable<data.ObjectExplorerCloseSessionResponse> {
|
||||
return this._resolveProvider<data.ObjectExplorerProvider>(handle).closeSession(closeSessionInfo);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.objectExplorerProvider ? provider.objectExplorerProvider.closeSession(closeSessionInfo)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $onObjectExplorerSessionCreated(handle: number, response: data.ObjectExplorerSession): void {
|
||||
@@ -309,11 +296,17 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
|
||||
// Task Service
|
||||
public $getAllTasks(handle: number, listTasksParams: data.ListTasksParams): Thenable<data.ListTasksResponse> {
|
||||
return this._resolveProvider<data.TaskServicesProvider>(handle).getAllTasks(listTasksParams);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.taskServicesProvider ? provider.taskServicesProvider.getAllTasks(listTasksParams)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $cancelTask(handle: number, cancelTaskParams: data.CancelTaskParams): Thenable<boolean> {
|
||||
return this._resolveProvider<data.TaskServicesProvider>(handle).cancelTask(cancelTaskParams);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.taskServicesProvider ? provider.taskServicesProvider.cancelTask(cancelTaskParams)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $onTaskStatusChanged(handle: number, response: data.TaskProgressInfo): void {
|
||||
@@ -324,10 +317,34 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
this._proxy.$onTaskCreated(handle, response);
|
||||
}
|
||||
|
||||
public $getDatabases(handle: number, connectionUri: string): Thenable<string[]> {
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.metadataProvider ? provider.metadataProvider.getDatabases(connectionUri)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $getTableInfo(handle: number, connectionUri: string, metadata: data.ObjectMetadata): Thenable<data.ColumnMetadata[]> {
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.metadataProvider ? provider.metadataProvider.getTableInfo(connectionUri, metadata)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $getViewInfo(handle: number, connectionUri: string, metadata: data.ObjectMetadata): Thenable<data.ColumnMetadata[]> {
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.metadataProvider ? provider.metadataProvider.getViewInfo(connectionUri, metadata)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
// Scripting handlers
|
||||
|
||||
public $scriptAsOperation(handle: number, connectionUri: string, operation: data.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): Thenable<data.ScriptingResult> {
|
||||
return this._resolveProvider<data.ScriptingProvider>(handle).scriptAsOperation(connectionUri, operation, metadata, paramDetails);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.scriptingProvider ? provider.scriptingProvider.scriptAsOperation(connectionUri, operation, metadata, paramDetails)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
public $onScriptingComplete(handle: number, scriptingCompleteResult: data.ScriptingCompleteResult): void {
|
||||
@@ -338,77 +355,110 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
* Create a new database on the provided connection
|
||||
*/
|
||||
public $createDatabase(handle: number, connectionUri: string, database: data.DatabaseInfo): Thenable<data.CreateDatabaseResponse> {
|
||||
return this._resolveProvider<data.AdminServicesProvider>(handle).createDatabase(connectionUri, database);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.adminServicesProvider ? provider.adminServicesProvider.createDatabase(connectionUri, database)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database on the provided connection
|
||||
*/
|
||||
public $getDefaultDatabaseInfo(handle: number, connectionUri: string): Thenable<data.DatabaseInfo> {
|
||||
return this._resolveProvider<data.AdminServicesProvider>(handle).getDefaultDatabaseInfo(connectionUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.adminServicesProvider ? provider.adminServicesProvider.getDefaultDatabaseInfo(connectionUri)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the info on a database
|
||||
*/
|
||||
public $getDatabaseInfo(handle: number, connectionUri: string): Thenable<data.DatabaseInfo> {
|
||||
return this._resolveProvider<data.AdminServicesProvider>(handle).getDatabaseInfo(connectionUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.adminServicesProvider ? provider.adminServicesProvider.getDatabaseInfo(connectionUri)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new login on the provided connection
|
||||
*/
|
||||
public $createLogin(handle: number, connectionUri: string, login: data.LoginInfo): Thenable<data.CreateLoginResponse> {
|
||||
return this._resolveProvider<data.AdminServicesProvider>(handle).createLogin(connectionUri, login);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.adminServicesProvider ? provider.adminServicesProvider.createLogin(connectionUri, login)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup a database
|
||||
*/
|
||||
public $backup(handle: number, connectionUri: string, backupInfo: { [key: string]: any }, taskExecutionMode: data.TaskExecutionMode): Thenable<data.BackupResponse> {
|
||||
return this._resolveProvider<data.BackupProvider>(handle).backup(connectionUri, backupInfo, taskExecutionMode);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.disasterRecoveryProvider ? provider.disasterRecoveryProvider.backup(connectionUri, backupInfo, taskExecutionMode)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database on the provided connection
|
||||
*/
|
||||
public $getBackupConfigInfo(handle: number, connectionUri: string): Thenable<data.BackupConfigInfo> {
|
||||
return this._resolveProvider<data.BackupProvider>(handle).getBackupConfigInfo(connectionUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.disasterRecoveryProvider ? provider.disasterRecoveryProvider.getBackupConfigInfo(connectionUri)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores a database
|
||||
*/
|
||||
public $restore(handle: number, connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestoreResponse> {
|
||||
return this._resolveProvider<data.RestoreProvider>(handle).restore(connectionUri, restoreInfo);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.disasterRecoveryProvider ? provider.disasterRecoveryProvider.restore(connectionUri, restoreInfo)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a plan for restoring a database
|
||||
*/
|
||||
public $getRestorePlan(handle: number, connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestorePlanResponse> {
|
||||
return this._resolveProvider<data.RestoreProvider>(handle).getRestorePlan(connectionUri, restoreInfo);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.disasterRecoveryProvider ? provider.disasterRecoveryProvider.getRestorePlan(connectionUri, restoreInfo)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels a restore plan
|
||||
*/
|
||||
public $cancelRestorePlan(handle: number, connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<boolean> {
|
||||
return this._resolveProvider<data.RestoreProvider>(handle).cancelRestorePlan(connectionUri, restoreInfo);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.disasterRecoveryProvider ? provider.disasterRecoveryProvider.cancelRestorePlan(connectionUri, restoreInfo)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets restore config Info
|
||||
*/
|
||||
public $getRestoreConfigInfo(handle: number, connectionUri: string): Thenable<data.RestoreConfigInfo> {
|
||||
return this._resolveProvider<data.RestoreProvider>(handle).getRestoreConfigInfo(connectionUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.disasterRecoveryProvider ? provider.disasterRecoveryProvider.getRestoreConfigInfo(connectionUri)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file browser
|
||||
*/
|
||||
public $openFileBrowser(handle: number, ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean> {
|
||||
return this._resolveProvider<data.FileBrowserProvider>(handle).openFileBrowser(ownerUri, expandPath, fileFilters, changeFilter);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.fileBrowserProvider ? provider.fileBrowserProvider.openFileBrowser(ownerUri, expandPath, fileFilters, changeFilter)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,7 +472,10 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
* Expand a folder node
|
||||
*/
|
||||
public $expandFolderNode(handle: number, ownerUri: string, expandPath: string): Thenable<boolean> {
|
||||
return this._resolveProvider<data.FileBrowserProvider>(handle).expandFolderNode(ownerUri, expandPath);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.fileBrowserProvider ? provider.fileBrowserProvider.expandFolderNode(ownerUri, expandPath)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,7 +489,10 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
* Validate selected file path
|
||||
*/
|
||||
public $validateFilePaths(handle: number, ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean> {
|
||||
return this._resolveProvider<data.FileBrowserProvider>(handle).validateFilePaths(ownerUri, serviceType, selectedFiles);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.fileBrowserProvider ? provider.fileBrowserProvider.validateFilePaths(ownerUri, serviceType, selectedFiles)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,7 +506,10 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
* Close file browser
|
||||
*/
|
||||
public $closeFileBrowser(handle: number, ownerUri: string): Thenable<data.FileBrowserCloseResponse> {
|
||||
return this._resolveProvider<data.FileBrowserProvider>(handle).closeFileBrowser(ownerUri);
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.fileBrowserProvider ? provider.fileBrowserProvider.closeFileBrowser(ownerUri)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -460,15 +519,21 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
/**
|
||||
* Start a profiler session
|
||||
*/
|
||||
public $startSession(handle: number, sessionId: string): Thenable<boolean> {
|
||||
return this._resolveProvider<data.ProfilerProvider>(handle).startSession(sessionId);
|
||||
public $startSession(handle: number, sessionId: string): Thenable<boolean> {
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.profilerProvider ? provider.profilerProvider.startSession(sessionId)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a profiler session
|
||||
*/
|
||||
public $stopSession(handle: number, sessionId: string): Thenable<boolean> {
|
||||
return this._resolveProvider<data.ProfilerProvider>(handle).stopSession(sessionId);
|
||||
public $stopSession(handle: number, sessionId: string): Thenable<boolean> {
|
||||
return this._runWithProvider(handle, provider => {
|
||||
return provider.profilerProvider ? provider.profilerProvider.stopSession(sessionId)
|
||||
: Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,8 +18,7 @@ import { IMetadataService } from 'sql/services/metadata/metadataService';
|
||||
import { IObjectExplorerService } from 'sql/parts/registeredServer/common/objectExplorerService';
|
||||
import { IScriptingService } from 'sql/services/scripting/scriptingService';
|
||||
import { IAdminService } from 'sql/parts/admin/common/adminService';
|
||||
import { IBackupService } from 'sql/parts/disasterRecovery/backup/common/backupService';
|
||||
import { IRestoreService } from 'sql/parts/disasterRecovery/restore/common/restoreService';
|
||||
import { IDisasterRecoveryService } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import { ITaskService } from 'sql/parts/taskHistory/common/taskService';
|
||||
import { IProfilerService } from 'sql/parts/profiler/service/interfaces';
|
||||
import { ISerializationService } from 'sql/services/serialization/serializationService';
|
||||
@@ -48,8 +47,7 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
||||
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
|
||||
@IScriptingService private _scriptingService: IScriptingService,
|
||||
@IAdminService private _adminService: IAdminService,
|
||||
@IBackupService private _backupService: IBackupService,
|
||||
@IRestoreService private _restoreService: IRestoreService,
|
||||
@IDisasterRecoveryService private _disasterRecoveryService: IDisasterRecoveryService,
|
||||
@ITaskService private _taskService: ITaskService,
|
||||
@IProfilerService private _profilerService: IProfilerService,
|
||||
@ISerializationService private _serializationService: ISerializationService,
|
||||
@@ -68,8 +66,10 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $registerConnectionProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
public $registerProvider(providerId: string, handle: number): TPromise<any> {
|
||||
let self = this;
|
||||
|
||||
// register connection management provider
|
||||
this._connectionManagementService.registerProvider(providerId, <data.ConnectionProvider>{
|
||||
connect(connectionUri: string, connectionInfo: data.ConnectionInfo): Thenable<boolean> {
|
||||
return self._proxy.$connect(handle, connectionUri, connectionInfo);
|
||||
@@ -91,11 +91,13 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
this._capabilitiesService.registerProvider(<data.CapabilitiesProvider>{
|
||||
getServerCapabilities(client: data.DataProtocolClientCapabilities): Thenable<data.DataProtocolServerCapabilities> {
|
||||
return self._proxy.$getServerCapabilities(handle, client);
|
||||
}
|
||||
});
|
||||
|
||||
public $registerQueryProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
// register query provider
|
||||
this._queryManagementService.addQueryRequestHandler(providerId, {
|
||||
cancelQuery(ownerUri: string): Thenable<data.QueryCancelResult> {
|
||||
return self._proxy.$cancelQuery(handle, ownerUri);
|
||||
@@ -159,45 +161,6 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerBackupProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._backupService.registerProvider(providerId, <data.BackupProvider>{
|
||||
backup(connectionUri: string, backupInfo: { [key: string]: any }, taskExecutionMode: data.TaskExecutionMode): Thenable<data.BackupResponse> {
|
||||
return self._proxy.$backup(handle, connectionUri, backupInfo, taskExecutionMode);
|
||||
},
|
||||
getBackupConfigInfo(connectionUri: string): Thenable<data.BackupConfigInfo> {
|
||||
return self._proxy.$getBackupConfigInfo(handle, connectionUri);
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerRestoreProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._restoreService.registerProvider(providerId, <data.RestoreProvider>{
|
||||
getRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestorePlanResponse> {
|
||||
return self._proxy.$getRestorePlan(handle, connectionUri, restoreInfo);
|
||||
},
|
||||
cancelRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<boolean> {
|
||||
return self._proxy.$cancelRestorePlan(handle, connectionUri, restoreInfo);
|
||||
},
|
||||
restore(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestoreResponse> {
|
||||
return self._proxy.$restore(handle, connectionUri, restoreInfo);
|
||||
},
|
||||
getRestoreConfigInfo(connectionUri: string): Thenable<data.RestoreConfigInfo> {
|
||||
return self._proxy.$getRestoreConfigInfo(handle, connectionUri);
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerMetadataProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._metadataService.registerProvider(providerId, <data.MetadataProvider>{
|
||||
getMetadata(connectionUri: string): Thenable<data.ProviderMetadata> {
|
||||
return self._proxy.$getMetadata(handle, connectionUri);
|
||||
@@ -213,11 +176,6 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerObjectExplorerProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._objectExplorerService.registerProvider(providerId, <data.ObjectExplorerProvider>{
|
||||
createNewSession(connection: data.ConnectionInfo): Thenable<data.ObjectExplorerSessionResponse> {
|
||||
return self._proxy.$createObjectExplorerSession(handle, connection);
|
||||
@@ -233,11 +191,6 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerTaskServicesProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._taskService.registerProvider(providerId, <data.TaskServicesProvider>{
|
||||
getAllTasks(listTasksParams: data.ListTasksParams): Thenable<data.ListTasksResponse> {
|
||||
return self._proxy.$getAllTasks(handle, listTasksParams);
|
||||
@@ -247,65 +200,12 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerScriptingProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._scriptingService.registerProvider(providerId, <data.ScriptingProvider>{
|
||||
scriptAsOperation(connectionUri: string, operation: data.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): Thenable<data.ScriptingResult> {
|
||||
return self._proxy.$scriptAsOperation(handle, connectionUri, operation, metadata, paramDetails);
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerFileBrowserProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._fileBrowserService.registerProvider(providerId, <data.FileBrowserProvider>{
|
||||
openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean> {
|
||||
return self._proxy.$openFileBrowser(handle, ownerUri, expandPath, fileFilters, changeFilter);
|
||||
},
|
||||
expandFolderNode(ownerUri: string, expandPath: string): Thenable<boolean> {
|
||||
return self._proxy.$expandFolderNode(handle, ownerUri, expandPath);
|
||||
},
|
||||
validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean> {
|
||||
return self._proxy.$validateFilePaths(handle, ownerUri, serviceType, selectedFiles);
|
||||
},
|
||||
closeFileBrowser(ownerUri: string): Thenable<data.FileBrowserCloseResponse> {
|
||||
return self._proxy.$closeFileBrowser(handle, ownerUri);
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerProfilerProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._profilerService.registerProvider(providerId, <data.ProfilerProvider>{
|
||||
startSession(sessionId: string): Thenable<boolean> {
|
||||
return self._proxy.$startSession(handle, sessionId);
|
||||
},
|
||||
stopSession(sessionId: string): Thenable<boolean> {
|
||||
return self._proxy.$stopSession(handle, sessionId);
|
||||
},
|
||||
pauseSession(sessionId: string): Thenable<boolean> {
|
||||
return TPromise.as(true);
|
||||
},
|
||||
connectSession(sessionId: string): Thenable<boolean> {
|
||||
return TPromise.as(true);
|
||||
},
|
||||
disconnectSession(sessionId: string): Thenable<boolean> {
|
||||
return TPromise.as(true);
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerAdminServicesProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._adminService.registerProvider(providerId, <data.AdminServicesProvider>{
|
||||
createDatabase(connectionUri: string, database: data.DatabaseInfo): Thenable<data.CreateDatabaseResponse> {
|
||||
return self._proxy.$createDatabase(handle, connectionUri, database);
|
||||
@@ -321,14 +221,57 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
this._disasterRecoveryService.registerProvider(providerId, <data.DisasterRecoveryProvider>{
|
||||
backup(connectionUri: string, backupInfo: { [key: string]: any }, taskExecutionMode: data.TaskExecutionMode): Thenable<data.BackupResponse> {
|
||||
return self._proxy.$backup(handle, connectionUri, backupInfo, taskExecutionMode);
|
||||
},
|
||||
getBackupConfigInfo(connectionUri: string): Thenable<data.BackupConfigInfo> {
|
||||
return self._proxy.$getBackupConfigInfo(handle, connectionUri);
|
||||
},
|
||||
getRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestorePlanResponse> {
|
||||
return self._proxy.$getRestorePlan(handle, connectionUri, restoreInfo);
|
||||
},
|
||||
cancelRestorePlan(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<boolean> {
|
||||
return self._proxy.$cancelRestorePlan(handle, connectionUri, restoreInfo);
|
||||
},
|
||||
restore(connectionUri: string, restoreInfo: data.RestoreInfo): Thenable<data.RestoreResponse> {
|
||||
return self._proxy.$restore(handle, connectionUri, restoreInfo);
|
||||
},
|
||||
getRestoreConfigInfo(connectionUri: string): Thenable<data.RestoreConfigInfo> {
|
||||
return self._proxy.$getRestoreConfigInfo(handle, connectionUri);
|
||||
}
|
||||
});
|
||||
|
||||
public $registerCapabilitiesServiceProvider(providerId: string, handle: number): TPromise<any> {
|
||||
const self = this;
|
||||
this._capabilitiesService.registerProvider(<data.CapabilitiesProvider>{
|
||||
getServerCapabilities(client: data.DataProtocolClientCapabilities): Thenable<data.DataProtocolServerCapabilities> {
|
||||
return self._proxy.$getServerCapabilities(handle, client);
|
||||
this._fileBrowserService.registerProvider(providerId, <data.FileBrowserProvider>{
|
||||
openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean> {
|
||||
return self._proxy.$openFileBrowser(handle, ownerUri, expandPath, fileFilters, changeFilter);
|
||||
},
|
||||
expandFolderNode(ownerUri: string, expandPath: string): Thenable<boolean> {
|
||||
return self._proxy.$expandFolderNode(handle, ownerUri, expandPath);
|
||||
},
|
||||
validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean> {
|
||||
return self._proxy.$validateFilePaths(handle, ownerUri, serviceType, selectedFiles);
|
||||
},
|
||||
closeFileBrowser(ownerUri: string): Thenable<data.FileBrowserCloseResponse> {
|
||||
return self._proxy.$closeFileBrowser(handle, ownerUri);
|
||||
}
|
||||
});
|
||||
|
||||
this._profilerService.registerProvider(providerId, <data.ProfilerProvider>{
|
||||
startSession(sessionId: string): Thenable<boolean> {
|
||||
return self._proxy.$startSession(handle, sessionId);
|
||||
},
|
||||
stopSession(sessionId: string): Thenable<boolean> {
|
||||
return self._proxy.$stopSession(handle, sessionId);
|
||||
},
|
||||
pauseSession(sessionId: string): Thenable<boolean> {
|
||||
return TPromise.as(true);
|
||||
},
|
||||
connectSession(sessionId: string): Thenable<boolean> {
|
||||
return TPromise.as(true);
|
||||
},
|
||||
disconnectSession(sessionId: string): Thenable<boolean> {
|
||||
return TPromise.as(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { ExtHostDataProtocol } from 'sql/workbench/api/node/extHostDataProtocol'
|
||||
import { ExtHostSerializationProvider } from 'sql/workbench/api/node/extHostSerializationProvider';
|
||||
import { ExtHostResourceProvider } from 'sql/workbench/api/node/extHostResourceProvider';
|
||||
import { ExtHostThreadService } from 'vs/workbench/services/thread/node/extHostThreadService';
|
||||
import * as sqlExtHostTypes from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import * as sqlExtHostTypes from 'sql/workbench/api/node/sqlExtHostTypes';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
|
||||
import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration';
|
||||
|
||||
@@ -95,141 +95,92 @@ export function createApiFactory(
|
||||
}
|
||||
};
|
||||
|
||||
let registerConnectionProvider = (provider: data.ConnectionProvider): vscode.Disposable => {
|
||||
// Connection callbacks
|
||||
provider.registerOnConnectionComplete((connSummary: data.ConnectionInfoSummary) => {
|
||||
extHostDataProvider.$onConnectComplete(provider.handle, connSummary);
|
||||
});
|
||||
|
||||
provider.registerOnIntelliSenseCacheComplete((connectionUri: string) => {
|
||||
extHostDataProvider.$onIntelliSenseCacheComplete(provider.handle, connectionUri);
|
||||
});
|
||||
|
||||
provider.registerOnConnectionChanged((changedConnInfo: data.ChangedConnectionInfo) => {
|
||||
extHostDataProvider.$onConnectionChanged(provider.handle, changedConnInfo);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerConnectionProvider(provider);
|
||||
};
|
||||
|
||||
let registerQueryProvider = (provider: data.QueryProvider): vscode.Disposable => {
|
||||
provider.registerOnQueryComplete((result: data.QueryExecuteCompleteNotificationResult) => {
|
||||
extHostDataProvider.$onQueryComplete(provider.handle, result);
|
||||
});
|
||||
|
||||
provider.registerOnBatchStart((batchInfo: data.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchStart(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.registerOnBatchComplete((batchInfo: data.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchComplete(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.registerOnResultSetComplete((resultSetInfo: data.QueryExecuteResultSetCompleteNotificationParams) => {
|
||||
extHostDataProvider.$onResultSetComplete(provider.handle, resultSetInfo);
|
||||
});
|
||||
|
||||
provider.registerOnMessage((message: data.QueryExecuteMessageParams) => {
|
||||
extHostDataProvider.$onQueryMessage(provider.handle, message);
|
||||
});
|
||||
|
||||
provider.registerOnEditSessionReady((ownerUri: string, success: boolean, message: string) => {
|
||||
extHostDataProvider.$onEditSessionReady(provider.handle, ownerUri, success, message);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerQueryProvider(provider);
|
||||
};
|
||||
|
||||
let registerObjectExplorerProvider = (provider: data.ObjectExplorerProvider): vscode.Disposable => {
|
||||
provider.registerOnSessionCreated((response: data.ObjectExplorerSession) => {
|
||||
extHostDataProvider.$onObjectExplorerSessionCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnExpandCompleted((response: data.ObjectExplorerExpandInfo) => {
|
||||
extHostDataProvider.$onObjectExplorerNodeExpanded(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerObjectExplorerProvider(provider);
|
||||
};
|
||||
|
||||
let registerTaskServicesProvider = (provider: data.TaskServicesProvider): vscode.Disposable => {
|
||||
provider.registerOnTaskCreated((response: data.TaskInfo) => {
|
||||
extHostDataProvider.$onTaskCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnTaskStatusChanged((response: data.TaskProgressInfo) => {
|
||||
extHostDataProvider.$onTaskStatusChanged(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerTaskServicesProvider(provider);
|
||||
};
|
||||
|
||||
let registerFileBrowserProvider = (provider: data.FileBrowserProvider): vscode.Disposable => {
|
||||
provider.registerOnFileBrowserOpened((response: data.FileBrowserOpenedParams) => {
|
||||
extHostDataProvider.$onFileBrowserOpened(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnFolderNodeExpanded((response: data.FileBrowserExpandedParams) => {
|
||||
extHostDataProvider.$onFolderNodeExpanded(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnFilePathsValidated((response: data.FileBrowserValidatedParams) => {
|
||||
extHostDataProvider.$onFilePathsValidated(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerFileBrowserProvider(provider);
|
||||
};
|
||||
|
||||
let registerScriptingProvider = (provider: data.ScriptingProvider): vscode.Disposable => {
|
||||
provider.registerOnScriptingComplete((response: data.ScriptingCompleteResult) => {
|
||||
extHostDataProvider.$onScriptingComplete(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerScriptingProvider(provider);
|
||||
};
|
||||
|
||||
let registerProfilerProvider = (provider: data.ProfilerProvider): vscode.Disposable => {
|
||||
provider.registerOnSessionEventsAvailable((response: data.ProfilerSessionEvents) => {
|
||||
extHostDataProvider.$onSessionEventsAvailable(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerProfilerProvider(provider);
|
||||
};
|
||||
|
||||
let registerBackupProvider = (provider: data.BackupProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerBackupProvider(provider);
|
||||
};
|
||||
|
||||
let registerRestoreProvider = (provider: data.RestoreProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerRestoreProvider(provider);
|
||||
};
|
||||
|
||||
let registerMetadataProvider = (provider: data.MetadataProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerMetadataProvider(provider);
|
||||
};
|
||||
|
||||
let registerCapabilitiesServiceProvider = (provider: data.CapabilitiesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerCapabilitiesServiceProvider(provider);
|
||||
};
|
||||
|
||||
let registerAdminServicesProvider = (provider: data.AdminServicesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerAdminServicesProvider(provider);
|
||||
};
|
||||
|
||||
// namespace: dataprotocol
|
||||
const dataprotocol: typeof data.dataprotocol = {
|
||||
registerBackupProvider,
|
||||
registerConnectionProvider,
|
||||
registerFileBrowserProvider,
|
||||
registerMetadataProvider,
|
||||
registerObjectExplorerProvider,
|
||||
registerProfilerProvider,
|
||||
registerRestoreProvider,
|
||||
registerScriptingProvider,
|
||||
registerTaskServicesProvider,
|
||||
registerQueryProvider,
|
||||
registerAdminServicesProvider,
|
||||
registerCapabilitiesServiceProvider,
|
||||
registerProvider(provider: data.DataProtocolProvider): vscode.Disposable {
|
||||
// Connection callbacks
|
||||
provider.connectionProvider.registerOnConnectionComplete((connSummary: data.ConnectionInfoSummary) => {
|
||||
extHostDataProvider.$onConnectComplete(provider.handle, connSummary);
|
||||
});
|
||||
|
||||
provider.connectionProvider.registerOnIntelliSenseCacheComplete((connectionUri: string) => {
|
||||
extHostDataProvider.$onIntelliSenseCacheComplete(provider.handle, connectionUri);
|
||||
});
|
||||
|
||||
provider.connectionProvider.registerOnConnectionChanged((changedConnInfo: data.ChangedConnectionInfo) => {
|
||||
extHostDataProvider.$onConnectionChanged(provider.handle, changedConnInfo);
|
||||
});
|
||||
|
||||
// Query callbacks
|
||||
provider.queryProvider.registerOnQueryComplete((result: data.QueryExecuteCompleteNotificationResult) => {
|
||||
extHostDataProvider.$onQueryComplete(provider.handle, result);
|
||||
});
|
||||
|
||||
provider.queryProvider.registerOnBatchStart((batchInfo: data.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchStart(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.queryProvider.registerOnBatchComplete((batchInfo: data.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchComplete(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.queryProvider.registerOnResultSetComplete((resultSetInfo: data.QueryExecuteResultSetCompleteNotificationParams) => {
|
||||
extHostDataProvider.$onResultSetComplete(provider.handle, resultSetInfo);
|
||||
});
|
||||
|
||||
provider.queryProvider.registerOnMessage((message: data.QueryExecuteMessageParams) => {
|
||||
extHostDataProvider.$onQueryMessage(provider.handle, message);
|
||||
});
|
||||
|
||||
//OE callbacks
|
||||
provider.objectExplorerProvider.registerOnSessionCreated((response: data.ObjectExplorerSession) => {
|
||||
extHostDataProvider.$onObjectExplorerSessionCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.objectExplorerProvider.registerOnExpandCompleted((response: data.ObjectExplorerExpandInfo) => {
|
||||
extHostDataProvider.$onObjectExplorerNodeExpanded(provider.handle, response);
|
||||
});
|
||||
|
||||
//Tasks callbacks
|
||||
provider.taskServicesProvider.registerOnTaskCreated((response: data.TaskInfo) => {
|
||||
extHostDataProvider.$onTaskCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.taskServicesProvider.registerOnTaskStatusChanged((response: data.TaskProgressInfo) => {
|
||||
extHostDataProvider.$onTaskStatusChanged(provider.handle, response);
|
||||
});
|
||||
|
||||
// Edit Data callbacks
|
||||
provider.queryProvider.registerOnEditSessionReady((ownerUri: string, success: boolean, message: string) => {
|
||||
extHostDataProvider.$onEditSessionReady(provider.handle, ownerUri, success, message);
|
||||
});
|
||||
|
||||
// File browser callbacks
|
||||
provider.fileBrowserProvider.registerOnFileBrowserOpened((response: data.FileBrowserOpenedParams) => {
|
||||
extHostDataProvider.$onFileBrowserOpened(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.fileBrowserProvider.registerOnFolderNodeExpanded((response: data.FileBrowserExpandedParams) => {
|
||||
extHostDataProvider.$onFolderNodeExpanded(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.fileBrowserProvider.registerOnFilePathsValidated((response: data.FileBrowserValidatedParams) => {
|
||||
extHostDataProvider.$onFilePathsValidated(provider.handle, response);
|
||||
});
|
||||
|
||||
// Scripting callbacks
|
||||
provider.scriptingProvider.registerOnScriptingComplete((response: data.ScriptingCompleteResult) => {
|
||||
extHostDataProvider.$onScriptingComplete(provider.handle, response);
|
||||
});
|
||||
|
||||
// Profiler callbacks
|
||||
provider.profilerProvider.registerOnSessionEventsAvailable((response: data.ProfilerSessionEvents) => {
|
||||
extHostDataProvider.$onSessionEventsAvailable(provider.handle, response);
|
||||
});
|
||||
|
||||
// Complete registration
|
||||
return extHostDataProvider.$registerProvider(provider);
|
||||
},
|
||||
onDidChangeLanguageFlavor(listener: (e: data.DidChangeLanguageFlavorParams) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) {
|
||||
return extHostDataProvider.onDidChangeLanguageFlavor(listener, thisArgs, disposables);
|
||||
}
|
||||
|
||||
@@ -352,18 +352,7 @@ export abstract class MainThreadResourceProviderShape {
|
||||
}
|
||||
|
||||
export abstract class MainThreadDataProtocolShape {
|
||||
$registerConnectionProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerBackupProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerRestoreProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerScriptingProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerQueryProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerProfilerProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerObjectExplorerProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerMetadataProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerTaskServicesProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerFileBrowserProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerCapabilitiesServiceProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerAdminServicesProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$registerProvider(providerId: string, handle: number): TPromise<any> { throw ni(); }
|
||||
$unregisterProvider(handle: number): TPromise<any> { throw ni(); }
|
||||
$onConnectionComplete(handle: number, connectionInfoSummary: data.ConnectionInfoSummary): void { throw ni(); }
|
||||
$onIntelliSenseCacheComplete(handle: number, connectionUri: string): void { throw ni(); }
|
||||
|
||||
@@ -16,14 +16,15 @@ export enum ServiceOptionType {
|
||||
}
|
||||
|
||||
export enum ConnectionOptionSpecialType {
|
||||
serverName = 'serverName',
|
||||
databaseName = 'databaseName',
|
||||
authType = 'authType',
|
||||
userName = 'userName',
|
||||
password = 'password',
|
||||
appName = 'appName'
|
||||
serverName = 0,
|
||||
databaseName = 1,
|
||||
authType = 2,
|
||||
userName = 3,
|
||||
password = 4,
|
||||
appName = 5
|
||||
}
|
||||
|
||||
|
||||
export enum MetadataType {
|
||||
Table = 0,
|
||||
View = 1,
|
||||
@@ -38,6 +39,7 @@ export enum EditRowState {
|
||||
dirtyUpdate = 3
|
||||
}
|
||||
|
||||
|
||||
export enum TaskStatus {
|
||||
notStarted = 0,
|
||||
inProgress = 1,
|
||||
@@ -61,4 +63,4 @@ export enum ScriptOperation {
|
||||
Delete = 4,
|
||||
Execute = 5,
|
||||
Alter = 6
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,7 @@ import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IInsightsConfig } from 'sql/parts/dashboard/widgets/insights/interfaces';
|
||||
import { IScriptingService } from 'sql/services/scripting/scriptingService';
|
||||
import { IRestoreDialogController } from 'sql/parts/disasterRecovery/restore/common/restoreService';
|
||||
import { IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService';
|
||||
import { IDisasterRecoveryUiService, IRestoreDialogController } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import { IAngularEventingService, AngularEventType } from 'sql/services/angularEventing/angularEventingService';
|
||||
import { IInsightsDialogService } from 'sql/parts/insights/common/interfaces';
|
||||
import { IAdminService } from 'sql/parts/admin/common/adminService';
|
||||
@@ -285,7 +284,7 @@ export class BackupAction extends TaskAction {
|
||||
|
||||
constructor(
|
||||
id: string, label: string, icon: string,
|
||||
@IBackupUiService protected _backupUiService: IBackupUiService
|
||||
@IDisasterRecoveryUiService protected _disasterRecoveryService: IDisasterRecoveryUiService
|
||||
) {
|
||||
super(id, label, icon);
|
||||
}
|
||||
@@ -294,7 +293,7 @@ export class BackupAction extends TaskAction {
|
||||
return new TPromise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.showBackup(
|
||||
actionContext.profile,
|
||||
this._backupUiService,
|
||||
this._disasterRecoveryService,
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
|
||||
@@ -14,8 +14,7 @@ import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
|
||||
import { IScriptingService } from 'sql/services/scripting/scriptingService';
|
||||
import { EditDataInput } from 'sql/parts/editData/common/editDataInput';
|
||||
import { IAdminService } from 'sql/parts/admin/common/adminService';
|
||||
import { IRestoreDialogController } from 'sql/parts/disasterRecovery/restore/common/restoreService';
|
||||
import { IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService';
|
||||
import { IDisasterRecoveryUiService, IRestoreDialogController } from 'sql/parts/disasterRecovery/common/interfaces';
|
||||
import { IInsightsConfig } from 'sql/parts/dashboard/widgets/insights/interfaces';
|
||||
import { IInsightsDialogService } from 'sql/parts/insights/common/interfaces';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||
@@ -315,9 +314,9 @@ export function showCreateLogin(uri: string, connection: IConnectionProfile, adm
|
||||
});
|
||||
}
|
||||
|
||||
export function showBackup(connection: IConnectionProfile, backupUiService: IBackupUiService): Promise<void> {
|
||||
export function showBackup(connection: IConnectionProfile, disasterRecoveryUiService: IDisasterRecoveryUiService): Promise<void> {
|
||||
return new Promise<void>((resolve) => {
|
||||
backupUiService.showBackup(connection);
|
||||
disasterRecoveryUiService.showBackup(connection);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user