mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
connection contribution point (#880)
* init * finished compile erros * fixed all merge conflicts * fix dialog problems * formatting * fix opening dialog on first open * fix various problems with connectiondialog * formatting * fix tests * added connection contrib * formatting * formatting and adding capabilities to shutdown * fix connection buffering * formatting * fix tests
This commit is contained in:
@@ -189,6 +189,473 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"connectionProvider": {
|
||||||
|
"providerId": "MSSQL",
|
||||||
|
"displayName": "Microsoft SQL Server",
|
||||||
|
"connectionOptions": [
|
||||||
|
{
|
||||||
|
"specialValueType": "serverName",
|
||||||
|
"isIdentity": true,
|
||||||
|
"name": "server",
|
||||||
|
"displayName": "Server",
|
||||||
|
"description": "Name of the SQL Server instance",
|
||||||
|
"groupName": "Source",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": true,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": "databaseName",
|
||||||
|
"isIdentity": true,
|
||||||
|
"name": "database",
|
||||||
|
"displayName": "Database",
|
||||||
|
"description": "The name of the initial catalog or database int the data source",
|
||||||
|
"groupName": "Source",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": "authType",
|
||||||
|
"isIdentity": true,
|
||||||
|
"name": "authenticationType",
|
||||||
|
"displayName": "Authentication type",
|
||||||
|
"description": "Specifies the method of authenticating with SQL Server",
|
||||||
|
"groupName": "Security",
|
||||||
|
"valueType": "category",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": [
|
||||||
|
{
|
||||||
|
"displayName": "SQL Login",
|
||||||
|
"name": "SqlLogin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"displayName": "Windows Authentication",
|
||||||
|
"name": "Integrated"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isRequired": true,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": "userName",
|
||||||
|
"isIdentity": true,
|
||||||
|
"name": "user",
|
||||||
|
"displayName": "User name",
|
||||||
|
"description": "Indicates the user ID to be used when connecting to the data source",
|
||||||
|
"groupName": "Security",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": true,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": "password",
|
||||||
|
"isIdentity": true,
|
||||||
|
"name": "password",
|
||||||
|
"displayName": "Password",
|
||||||
|
"description": "Indicates the password to be used when connecting to the data source",
|
||||||
|
"groupName": "Security",
|
||||||
|
"valueType": "password",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": true,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "applicationIntent",
|
||||||
|
"displayName": "Application intent",
|
||||||
|
"description": "Declares the application workload type when connecting to a server",
|
||||||
|
"groupName": "Initialization",
|
||||||
|
"valueType": "category",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": [
|
||||||
|
{
|
||||||
|
"displayName": "ReadWrite",
|
||||||
|
"name": "ReadWrite"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"displayName": "ReadOnly",
|
||||||
|
"name": "ReadOnly"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "asynchronousProcessing",
|
||||||
|
"displayName": "Asynchronous processing enabled",
|
||||||
|
"description": "When true, enables usage of the Asynchronous functionality in the .Net Framework Data Provider",
|
||||||
|
"groupName": "Initialization",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "connectTimeout",
|
||||||
|
"displayName": "Connect timeout",
|
||||||
|
"description": "The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error",
|
||||||
|
"groupName": "Initialization",
|
||||||
|
"valueType": "number",
|
||||||
|
"defaultValue": "15",
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "currentLanguage",
|
||||||
|
"displayName": "Current language",
|
||||||
|
"description": "The SQL Server language record name",
|
||||||
|
"groupName": "Initialization",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "columnEncryptionSetting",
|
||||||
|
"displayName": "Column encryption setting",
|
||||||
|
"description": "Default column encryption setting for all the commands on the connection",
|
||||||
|
"groupName": "Security",
|
||||||
|
"valueType": "category",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": [
|
||||||
|
{
|
||||||
|
"displayName": null,
|
||||||
|
"name": "Disabled"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"displayName": null,
|
||||||
|
"name": "Enabled"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "encrypt",
|
||||||
|
"displayName": "Encrypt",
|
||||||
|
"description": "When true, SQL Server uses SSL encryption for all data sent between the client and server if the servers has a certificate installed",
|
||||||
|
"groupName": "Security",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "persistSecurityInfo",
|
||||||
|
"displayName": "Persist security info",
|
||||||
|
"description": "When false, security-sensitive information, such as the password, is not returned as part of the connection",
|
||||||
|
"groupName": "Security",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "trustServerCertificate",
|
||||||
|
"displayName": "Trust server certificate",
|
||||||
|
"description": "When true (and encrypt=true), SQL Server uses SSL encryption for all data sent between the client and server without validating the server certificate",
|
||||||
|
"groupName": "Security",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "attachedDBFileName",
|
||||||
|
"displayName": "Attached DB file name",
|
||||||
|
"description": "The name of the primary file, including the full path name, of an attachable database",
|
||||||
|
"groupName": "Source",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "contextConnection",
|
||||||
|
"displayName": "Context connection",
|
||||||
|
"description": "When true, indicates the connection should be from the SQL server context. Available only when running in the SQL Server process",
|
||||||
|
"groupName": "Source",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "port",
|
||||||
|
"displayName": "Port",
|
||||||
|
"description": null,
|
||||||
|
"groupName": null,
|
||||||
|
"valueType": "number",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "connectRetryCount",
|
||||||
|
"displayName": "Connect retry count",
|
||||||
|
"description": "Number of attempts to restore connection",
|
||||||
|
"groupName": "Connection Resiliency",
|
||||||
|
"valueType": "number",
|
||||||
|
"defaultValue": "1",
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "connectRetryInterval",
|
||||||
|
"displayName": "Connect retry interval",
|
||||||
|
"description": "Delay between attempts to restore connection",
|
||||||
|
"groupName": "Connection Resiliency",
|
||||||
|
"valueType": "number",
|
||||||
|
"defaultValue": "10",
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": "appName",
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "applicationName",
|
||||||
|
"displayName": "Application name",
|
||||||
|
"description": "The name of the application",
|
||||||
|
"groupName": "Context",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "workstationId",
|
||||||
|
"displayName": "Workstation Id",
|
||||||
|
"description": "The name of the workstation connecting to SQL Server",
|
||||||
|
"groupName": "Context",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "pooling",
|
||||||
|
"displayName": "Pooling",
|
||||||
|
"description": "When true, the connection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool",
|
||||||
|
"groupName": "Pooling",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "maxPoolSize",
|
||||||
|
"displayName": "Max pool size",
|
||||||
|
"description": "The maximum number of connections allowed in the pool",
|
||||||
|
"groupName": "Pooling",
|
||||||
|
"valueType": "number",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "minPoolSize",
|
||||||
|
"displayName": "Min pool size",
|
||||||
|
"description": "The minimum number of connections allowed in the pool",
|
||||||
|
"groupName": "Pooling",
|
||||||
|
"valueType": "number",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "loadBalanceTimeout",
|
||||||
|
"displayName": "Load balance timeout",
|
||||||
|
"description": "The minimum amount of time (in seconds) for this connection to live in the pool before being destroyed",
|
||||||
|
"groupName": "Pooling",
|
||||||
|
"valueType": "number",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "replication",
|
||||||
|
"displayName": "Replication",
|
||||||
|
"description": "Used by SQL Server in Replication",
|
||||||
|
"groupName": "Replication",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "attachDbFilename",
|
||||||
|
"displayName": "Attach DB filename",
|
||||||
|
"description": null,
|
||||||
|
"groupName": null,
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "failoverPartner",
|
||||||
|
"displayName": "Failover partner",
|
||||||
|
"description": "The name or network address of the instance of SQL Server that acts as a failover partner",
|
||||||
|
"groupName": " Source",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "multiSubnetFailover",
|
||||||
|
"displayName": "Multi subnet failover",
|
||||||
|
"description": null,
|
||||||
|
"groupName": null,
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "multipleActiveResultSets",
|
||||||
|
"displayName": "Multiple active result sets",
|
||||||
|
"description": "When true, multiple result sets can be returned and read from one connection",
|
||||||
|
"groupName": "Advanced",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "packetSize",
|
||||||
|
"displayName": "Packet size",
|
||||||
|
"description": "Size in bytes of the network packets used to communicate with an instance of SQL Server",
|
||||||
|
"groupName": "Advanced",
|
||||||
|
"valueType": "number",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"specialValueType": null,
|
||||||
|
"isIdentity": false,
|
||||||
|
"name": "typeSystemVersion",
|
||||||
|
"displayName": "Type system version",
|
||||||
|
"description": "Indicates which server type system then provider will expose through the DataReader",
|
||||||
|
"groupName": "Advanced",
|
||||||
|
"valueType": "string",
|
||||||
|
"defaultValue": null,
|
||||||
|
"objectType": null,
|
||||||
|
"categoryValues": null,
|
||||||
|
"isRequired": false,
|
||||||
|
"isArray": false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -111,3 +111,14 @@ export class TrieMap<E> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toObject<V>(map: Map<string, V>): { [key: string]: V } {
|
||||||
|
if (map) {
|
||||||
|
let rt: { [key: string]: V } = Object.create(null);
|
||||||
|
map.forEach((v, k) => {
|
||||||
|
rt[k] = v;
|
||||||
|
});
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function mixin(destination: any, source: any, overwrite: boolean = true,
|
|||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
if (Types.isObject(destination[key]) && Types.isObject(source[key])) {
|
if (Types.isObject(destination[key]) && Types.isObject(source[key])) {
|
||||||
mixin(destination[key], source[key], overwrite, fn);
|
mixin(destination[key], source[key], overwrite, fn);
|
||||||
} else if(fn) {
|
} else if (fn) {
|
||||||
destination[key] = fn(destination[key], source[key], overwrite);
|
destination[key] = fn(destination[key], source[key], overwrite);
|
||||||
} else {
|
} else {
|
||||||
destination[key] = source[key];
|
destination[key] = source[key];
|
||||||
@@ -51,3 +51,11 @@ export function mixin(destination: any, source: any, overwrite: boolean = true,
|
|||||||
}
|
}
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function entries<T>(o: { [key: string]: T }): [string, T][] {
|
||||||
|
return Object.entries(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function values<T>(o: { [key: string]: T }): T[] {
|
||||||
|
return Object.values(o);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,4 +17,10 @@ export class Deferred<T> {
|
|||||||
this.reject = reject;
|
this.reject = reject;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
|
||||||
|
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
|
||||||
|
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult> | void): Thenable<TResult> {
|
||||||
|
return this.promise.then(onfulfilled, onrejected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -239,14 +239,6 @@ export interface IConnectionManagementService {
|
|||||||
*/
|
*/
|
||||||
ensureDefaultLanguageFlavor(uri: string): void;
|
ensureDefaultLanguageFlavor(uri: string): void;
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an array of all known providers.
|
|
||||||
*
|
|
||||||
* @returns {string[]} An array of provider names
|
|
||||||
* @memberof IConnectionManagementService
|
|
||||||
*/
|
|
||||||
getProviderNames(): string[];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the IntelliSense cache for the connection with the given URI
|
* Refresh the IntelliSense cache for the connection with the given URI
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -30,12 +30,16 @@ import { warn } from 'sql/base/common/log';
|
|||||||
import { IResourceProviderService } from 'sql/parts/accountManagement/common/interfaces';
|
import { IResourceProviderService } from 'sql/parts/accountManagement/common/interfaces';
|
||||||
import { IAngularEventingService, AngularEventType } from 'sql/services/angularEventing/angularEventingService';
|
import { IAngularEventingService, AngularEventType } from 'sql/services/angularEventing/angularEventingService';
|
||||||
import * as QueryConstants from 'sql/parts/query/common/constants';
|
import * as QueryConstants from 'sql/parts/query/common/constants';
|
||||||
|
import { Deferred } from 'sql/base/common/promise';
|
||||||
|
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
|
import { values } from 'sql/base/common/objects';
|
||||||
|
import { ConnectionProviderProperties, IConnectionProviderRegistry, Extensions as ConnectionProviderExtensions } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||||
|
|
||||||
import * as sqlops from 'sqlops';
|
import * as sqlops from 'sqlops';
|
||||||
|
|
||||||
import * as nls from 'vs/nls';
|
import * as nls from 'vs/nls';
|
||||||
import * as errors from 'vs/base/common/errors';
|
import * as errors from 'vs/base/common/errors';
|
||||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import * as platform from 'vs/platform/registry/common/platform';
|
import * as platform from 'vs/platform/registry/common/platform';
|
||||||
@@ -55,30 +59,26 @@ import * as statusbar from 'vs/workbench/browser/parts/statusbar/statusbar';
|
|||||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||||
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
|
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
|
||||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
import { Deferred } from 'sql/base/common/promise';
|
|
||||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
|
||||||
|
|
||||||
export class ConnectionManagementService implements IConnectionManagementService {
|
export class ConnectionManagementService extends Disposable implements IConnectionManagementService {
|
||||||
|
|
||||||
_serviceBrand: any;
|
_serviceBrand: any;
|
||||||
|
|
||||||
private disposables: IDisposable[] = [];
|
private _providers = new Map<string, { onReady: Thenable<sqlops.ConnectionProvider>, properties: ConnectionProviderProperties }>();
|
||||||
|
|
||||||
private _providers: { [handle: string]: sqlops.ConnectionProvider; } = Object.create(null);
|
|
||||||
|
|
||||||
private _uriToProvider: { [uri: string]: string; } = Object.create(null);
|
private _uriToProvider: { [uri: string]: string; } = Object.create(null);
|
||||||
|
|
||||||
private _connectionStatusManager: ConnectionStatusManager;
|
private _connectionStatusManager = new ConnectionStatusManager(this._capabilitiesService);
|
||||||
|
|
||||||
private _onAddConnectionProfile: Emitter<IConnectionProfile>;
|
private _onAddConnectionProfile = new Emitter<IConnectionProfile>();
|
||||||
private _onDeleteConnectionProfile: Emitter<void>;
|
private _onDeleteConnectionProfile = new Emitter<void>();
|
||||||
private _onConnect: Emitter<IConnectionParams>;
|
private _onConnect = new Emitter<IConnectionParams>();
|
||||||
private _onDisconnect: Emitter<IConnectionParams>;
|
private _onDisconnect = new Emitter<IConnectionParams>();
|
||||||
private _onConnectRequestSent: Emitter<void>;
|
private _onConnectRequestSent = new Emitter<void>();
|
||||||
private _onConnectionChanged: Emitter<IConnectionParams>;
|
private _onConnectionChanged = new Emitter<IConnectionParams>();
|
||||||
private _onLanguageFlavorChanged: Emitter<sqlops.DidChangeLanguageFlavorParams>;
|
private _onLanguageFlavorChanged = new Emitter<sqlops.DidChangeLanguageFlavorParams>();
|
||||||
|
|
||||||
private _connectionGlobalStatus: ConnectionGlobalStatus;
|
private _connectionGlobalStatus = new ConnectionGlobalStatus(this._statusBarService);
|
||||||
|
|
||||||
private _configurationEditService: ConfigurationEditingService;
|
private _configurationEditService: ConfigurationEditingService;
|
||||||
|
|
||||||
@@ -103,6 +103,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
@IViewletService private _viewletService: IViewletService,
|
@IViewletService private _viewletService: IViewletService,
|
||||||
@IAngularEventingService private _angularEventing: IAngularEventingService
|
@IAngularEventingService private _angularEventing: IAngularEventingService
|
||||||
) {
|
) {
|
||||||
|
super();
|
||||||
if (this._instantiationService) {
|
if (this._instantiationService) {
|
||||||
this._configurationEditService = this._instantiationService.createInstance(ConfigurationEditingService);
|
this._configurationEditService = this._instantiationService.createInstance(ConfigurationEditingService);
|
||||||
}
|
}
|
||||||
@@ -116,20 +117,6 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
this._configurationEditService, this._workspaceConfigurationService, this._credentialsService, this._capabilitiesService);
|
this._configurationEditService, this._workspaceConfigurationService, this._credentialsService, this._capabilitiesService);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._connectionStatusManager = new ConnectionStatusManager(this._capabilitiesService);
|
|
||||||
this._connectionGlobalStatus = new ConnectionGlobalStatus(this._statusBarService);
|
|
||||||
|
|
||||||
// Setting up our event emitters
|
|
||||||
this._onAddConnectionProfile = new Emitter<IConnectionProfile>();
|
|
||||||
this._onDeleteConnectionProfile = new Emitter<void>();
|
|
||||||
this._onConnect = new Emitter<IConnectionParams>();
|
|
||||||
this._onDisconnect = new Emitter<IConnectionParams>();
|
|
||||||
this._onConnectionChanged = new Emitter<IConnectionParams>();
|
|
||||||
this._onConnectRequestSent = new Emitter<void>();
|
|
||||||
this._onLanguageFlavorChanged = new Emitter<sqlops.DidChangeLanguageFlavorParams>();
|
|
||||||
|
|
||||||
this._onProvidersReady = new Deferred();
|
|
||||||
|
|
||||||
// Register Statusbar item
|
// Register Statusbar item
|
||||||
(<statusbar.IStatusbarRegistry>platform.Registry.as(statusbar.Extensions.Statusbar)).registerStatusbarItem(new statusbar.StatusbarItemDescriptor(
|
(<statusbar.IStatusbarRegistry>platform.Registry.as(statusbar.Extensions.Statusbar)).registerStatusbarItem(new statusbar.StatusbarItemDescriptor(
|
||||||
ConnectionStatusbarItem,
|
ConnectionStatusbarItem,
|
||||||
@@ -137,19 +124,33 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
100 /* High Priority */
|
100 /* High Priority */
|
||||||
));
|
));
|
||||||
|
|
||||||
if (_capabilitiesService) {
|
if (_capabilitiesService && Object.keys(_capabilitiesService.providers).length > 0 && !this.hasRegisteredServers()) {
|
||||||
_capabilitiesService.onCapabilitiesRegistered((p => {
|
|
||||||
if (p === 'MSSQL') {
|
|
||||||
if (!this.hasRegisteredServers()) {
|
|
||||||
// prompt the user for a new connection on startup if no profiles are registered
|
// prompt the user for a new connection on startup if no profiles are registered
|
||||||
this.showConnectionDialog();
|
this.showConnectionDialog();
|
||||||
}
|
} else if (_capabilitiesService && !this.hasRegisteredServers()) {
|
||||||
}
|
_capabilitiesService.onCapabilitiesRegistered(e => {
|
||||||
}));
|
// prompt the user for a new connection on startup if no profiles are registered
|
||||||
|
this.showConnectionDialog();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.disposables.push(this._onAddConnectionProfile);
|
const registry = platform.Registry.as<IConnectionProviderRegistry>(ConnectionProviderExtensions.ConnectionProviderContributions);
|
||||||
this.disposables.push(this._onDeleteConnectionProfile);
|
|
||||||
|
let providerRegistration = (p: { id: string, properties: ConnectionProviderProperties }) => {
|
||||||
|
let provider = {
|
||||||
|
onReady: new Deferred<sqlops.ConnectionProvider>(),
|
||||||
|
properties: p.properties
|
||||||
|
};
|
||||||
|
this._providers.set(p.id, provider);
|
||||||
|
};
|
||||||
|
|
||||||
|
registry.onNewProvider(providerRegistration, this);
|
||||||
|
Object.entries(registry.providers).map(v => {
|
||||||
|
providerRegistration({ id: v[0], properties: v[1] });
|
||||||
|
});
|
||||||
|
|
||||||
|
this._register(this._onAddConnectionProfile);
|
||||||
|
this._register(this._onDeleteConnectionProfile);
|
||||||
|
|
||||||
// Refresh editor titles when connections start/end/change to ensure tabs are colored correctly
|
// Refresh editor titles when connections start/end/change to ensure tabs are colored correctly
|
||||||
this.onConnectionChanged(() => this.refreshEditorTitles());
|
this.onConnectionChanged(() => this.refreshEditorTitles());
|
||||||
@@ -186,37 +187,21 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
return this._onLanguageFlavorChanged.event;
|
return this._onLanguageFlavorChanged.event;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onProvidersReady: Deferred<void>;
|
|
||||||
|
|
||||||
private onProvidersReady(): Promise<void> {
|
|
||||||
return this._onProvidersReady.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _providerCount: number = 0;
|
private _providerCount: number = 0;
|
||||||
|
|
||||||
// Connection Provider Registration
|
// Connection Provider Registration
|
||||||
public registerProvider(providerId: string, provider: sqlops.ConnectionProvider): void {
|
public registerProvider(providerId: string, provider: sqlops.ConnectionProvider): void {
|
||||||
this._providers[providerId] = provider;
|
if (!this._providers.has(providerId)) {
|
||||||
|
console.error('Provider', providerId, 'attempted to register but has no metadata');
|
||||||
|
let providerType = {
|
||||||
|
onReady: new Deferred<sqlops.ConnectionProvider>(),
|
||||||
|
properties: undefined
|
||||||
|
};
|
||||||
|
this._providers.set(providerId, providerType);
|
||||||
|
}
|
||||||
|
|
||||||
// temporarily close splash screen when a connection provider has been registered
|
// we know this is a deferred promise because we made it
|
||||||
// @todo remove this code once a proper initialization event is available (karlb 4/1/2017)
|
(this._providers.get(providerId).onReady as Deferred<sqlops.ConnectionProvider>).resolve(provider);
|
||||||
++this._providerCount;
|
|
||||||
|
|
||||||
this._onProvidersReady.resolve();
|
|
||||||
|
|
||||||
if (this._providerCount === 1) {
|
|
||||||
// show the Registered Server viewlet
|
|
||||||
let startupConfig = this._workspaceConfigurationService.getValue('startup');
|
|
||||||
if (startupConfig) {
|
|
||||||
let showServerViewlet = <boolean>startupConfig['alwaysShowServersView'];
|
|
||||||
if (showServerViewlet) {
|
|
||||||
// only show the Servers viewlet if there isn't another active viewlet
|
|
||||||
if (!this._viewletService.getActiveViewlet()) {
|
|
||||||
this._commandService.executeCommand('workbench.view.connections', {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -675,19 +660,15 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getProviderNames(): string[] {
|
|
||||||
return Object.keys(this._providers);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getAdvancedProperties(): sqlops.ConnectionOption[] {
|
public getAdvancedProperties(): sqlops.ConnectionOption[] {
|
||||||
|
|
||||||
let providers = this._capabilitiesService.providers;
|
let providers = this._capabilitiesService.providers;
|
||||||
if (providers !== undefined && providers.length > 0) {
|
if (providers) {
|
||||||
// just grab the first registered provider for now, this needs to change
|
// just grab the first registered provider for now, this needs to change
|
||||||
// to lookup based on currently select provider
|
// to lookup based on currently select provider
|
||||||
let providerCapabilities = this._capabilitiesService.getCapabilities(providers[0]);
|
let providerCapabilities = values(providers)[0];
|
||||||
if (!!providerCapabilities.connectionProvider) {
|
if (!!providerCapabilities.connection) {
|
||||||
return providerCapabilities.connectionProvider.options;
|
return providerCapabilities.connection.connectionOptions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,7 +733,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
* @memberof ConnectionManagementService
|
* @memberof ConnectionManagementService
|
||||||
*/
|
*/
|
||||||
public doChangeLanguageFlavor(uri: string, language: string, provider: string): void {
|
public doChangeLanguageFlavor(uri: string, language: string, provider: string): void {
|
||||||
if (provider in this._providers) {
|
if (this._providers.has(provider)) {
|
||||||
this._onLanguageFlavorChanged.fire({
|
this._onLanguageFlavorChanged.fire({
|
||||||
uri: uri,
|
uri: uri,
|
||||||
language: language,
|
language: language,
|
||||||
@@ -772,7 +753,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
if (!this.getProviderIdFromUri(uri)) {
|
if (!this.getProviderIdFromUri(uri)) {
|
||||||
// Lookup the default settings and use this
|
// Lookup the default settings and use this
|
||||||
let defaultProvider = WorkbenchUtils.getSqlConfigValue<string>(this._workspaceConfigurationService, Constants.defaultEngine);
|
let defaultProvider = WorkbenchUtils.getSqlConfigValue<string>(this._workspaceConfigurationService, Constants.defaultEngine);
|
||||||
if (defaultProvider && defaultProvider in this._providers) {
|
if (defaultProvider && this._providers.has(defaultProvider)) {
|
||||||
// Only set a default if it's in the list of registered providers
|
// Only set a default if it's in the list of registered providers
|
||||||
this.doChangeLanguageFlavor(uri, 'sql', defaultProvider);
|
this.doChangeLanguageFlavor(uri, 'sql', defaultProvider);
|
||||||
}
|
}
|
||||||
@@ -788,15 +769,13 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
// setup URI to provider ID map for connection
|
// setup URI to provider ID map for connection
|
||||||
this._uriToProvider[uri] = connection.providerName;
|
this._uriToProvider[uri] = connection.providerName;
|
||||||
|
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return this._providers.get(connection.providerName).onReady.then((provider) => {
|
||||||
this.onProvidersReady().then(() => {
|
provider.connect(uri, connectionInfo);
|
||||||
this._providers[connection.providerName].connect(uri, connectionInfo);
|
|
||||||
this._onConnectRequestSent.fire();
|
this._onConnectRequestSent.fire();
|
||||||
|
|
||||||
// TODO make this generic enough to handle non-SQL languages too
|
// TODO make this generic enough to handle non-SQL languages too
|
||||||
this.doChangeLanguageFlavor(uri, 'sql', connection.providerName);
|
this.doChangeLanguageFlavor(uri, 'sql', connection.providerName);
|
||||||
resolve(true);
|
return true;
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,9 +785,9 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return this._providers.get(providerId).onReady.then(provider => {
|
||||||
this._providers[providerId].disconnect(uri);
|
provider.disconnect(uri);
|
||||||
resolve(true);
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,9 +797,9 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return this._providers.get(providerId).onReady.then(provider => {
|
||||||
this._providers[providerId].cancelConnect(uri);
|
provider.cancelConnect(uri);
|
||||||
resolve(true);
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,15 +809,12 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise<sqlops.ListDatabasesResult>((resolve, reject) => {
|
return this._providers.get(providerId).onReady.then(provider => {
|
||||||
let provider = this._providers[providerId];
|
return provider.listDatabases(uri).then(result => {
|
||||||
provider.listDatabases(uri).then(result => {
|
|
||||||
if (result && result.databaseNames) {
|
if (result && result.databaseNames) {
|
||||||
result.databaseNames.sort();
|
result.databaseNames.sort();
|
||||||
}
|
}
|
||||||
resolve(result);
|
return result;
|
||||||
}, error => {
|
|
||||||
reject(error);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -932,10 +908,6 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
public onIntelliSenseCacheComplete(handle: number, connectionUri: string): void {
|
public onIntelliSenseCacheComplete(handle: number, connectionUri: string): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
public dispose(): void {
|
|
||||||
this.disposables = dispose(this.disposables);
|
|
||||||
}
|
|
||||||
|
|
||||||
public shutdown(): void {
|
public shutdown(): void {
|
||||||
this._connectionStore.clearActiveConnections();
|
this._connectionStore.clearActiveConnections();
|
||||||
this._connectionMemento.saveMemento();
|
this._connectionMemento.saveMemento();
|
||||||
@@ -1202,13 +1174,14 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let provider = this._providers[providerId];
|
return this._providers.get(providerId).onReady.then(provider => {
|
||||||
return provider.changeDatabase(connectionUri, databaseName).then(result => {
|
return provider.changeDatabase(connectionUri, databaseName).then(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.getConnectionProfile(connectionUri).databaseName = databaseName;
|
this.getConnectionProfile(connectionUri).databaseName = databaseName;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
@@ -1316,8 +1289,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
return Promise.reject('No provider corresponding to the given URI');
|
return Promise.reject('No provider corresponding to the given URI');
|
||||||
}
|
}
|
||||||
|
|
||||||
let provider = this._providers[providerId];
|
return this._providers.get(providerId).onReady.then(provider => provider.rebuildIntelliSenseCache(connectionUri));
|
||||||
return provider.rebuildIntelliSenseCache(connectionUri);
|
|
||||||
}
|
}
|
||||||
return Promise.reject('The given URI is not currently connected');
|
return Promise.reject('The given URI is not currently connected');
|
||||||
}
|
}
|
||||||
@@ -1354,7 +1326,7 @@ export class ConnectionManagementService implements IConnectionManagementService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the password option for the connection provider
|
// Find the password option for the connection provider
|
||||||
let passwordOption = this._capabilitiesService.getCapabilities(profile.providerName).connectionProvider.options.find(
|
let passwordOption = this._capabilitiesService.getCapabilities(profile.providerName).connection.connectionOptions.find(
|
||||||
option => option.specialValueType === ConnectionOptionSpecialType.password);
|
option => option.specialValueType === ConnectionOptionSpecialType.password);
|
||||||
if (!passwordOption) {
|
if (!passwordOption) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ import * as interfaces from 'sql/parts/connection/common/interfaces';
|
|||||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
import * as Constants from 'sql/parts/connection/common/constants';
|
import * as Constants from 'sql/parts/connection/common/constants';
|
||||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||||
|
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||||
|
|
||||||
export class ProviderConnectionInfo extends Disposable implements sqlops.ConnectionInfo {
|
export class ProviderConnectionInfo extends Disposable implements sqlops.ConnectionInfo {
|
||||||
|
|
||||||
options: { [name: string]: any } = {};
|
options: { [name: string]: any } = {};
|
||||||
|
|
||||||
private _providerName: string;
|
private _providerName: string;
|
||||||
protected _serverCapabilities: sqlops.DataProtocolServerCapabilities;
|
protected _serverCapabilities: ConnectionProviderProperties;
|
||||||
private static readonly SqlAuthentication = 'SqlLogin';
|
private static readonly SqlAuthentication = 'SqlLogin';
|
||||||
public static readonly ProviderPropertyName = 'providerName';
|
public static readonly ProviderPropertyName = 'providerName';
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
|
|
||||||
if (!isString(model)) {
|
if (!isString(model)) {
|
||||||
if (model.options && this._serverCapabilities) {
|
if (model.options && this._serverCapabilities) {
|
||||||
this._serverCapabilities.connectionProvider.options.forEach(option => {
|
this._serverCapabilities.connectionOptions.forEach(option => {
|
||||||
let value = model.options[option.name];
|
let value = model.options[option.name];
|
||||||
this.options[option.name] = value;
|
this.options[option.name] = value;
|
||||||
});
|
});
|
||||||
@@ -55,10 +56,13 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
public set providerName(name: string) {
|
public set providerName(name: string) {
|
||||||
this._providerName = name;
|
this._providerName = name;
|
||||||
if (!this._serverCapabilities) {
|
if (!this._serverCapabilities) {
|
||||||
this._serverCapabilities = this.capabilitiesService.getCapabilities(this.providerName);
|
let capabilities = this.capabilitiesService.getCapabilities(this.providerName);
|
||||||
|
if (capabilities) {
|
||||||
|
this._serverCapabilities = capabilities.connection;
|
||||||
|
}
|
||||||
this._register(this.capabilitiesService.onCapabilitiesRegistered(e => {
|
this._register(this.capabilitiesService.onCapabilitiesRegistered(e => {
|
||||||
if (e === this.providerName) {
|
if (e.connection.providerId === this.providerName) {
|
||||||
this._serverCapabilities = this.capabilitiesService.getCapabilities(e);
|
this._serverCapabilities = e.connection;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -70,7 +74,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get serverCapabilities(): sqlops.DataProtocolServerCapabilities {
|
public get serverCapabilities(): ConnectionProviderProperties {
|
||||||
return this._serverCapabilities;
|
return this._serverCapabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +145,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
}
|
}
|
||||||
|
|
||||||
public isPasswordRequired(): boolean {
|
public isPasswordRequired(): boolean {
|
||||||
let optionMetadata = this._serverCapabilities.connectionProvider.options.find(
|
let optionMetadata = this._serverCapabilities.connectionOptions.find(
|
||||||
option => option.specialValueType === ConnectionOptionSpecialType.password);
|
option => option.specialValueType === ConnectionOptionSpecialType.password);
|
||||||
let isPasswordRequired: boolean = optionMetadata.isRequired;
|
let isPasswordRequired: boolean = optionMetadata.isRequired;
|
||||||
if (this.providerName === Constants.mssqlProviderName) {
|
if (this.providerName === Constants.mssqlProviderName) {
|
||||||
@@ -166,7 +170,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
public getOptionsKey(): string {
|
public getOptionsKey(): string {
|
||||||
let idNames = [];
|
let idNames = [];
|
||||||
if (this._serverCapabilities) {
|
if (this._serverCapabilities) {
|
||||||
idNames = this._serverCapabilities.connectionProvider.options.map(o => {
|
idNames = this._serverCapabilities.connectionOptions.map(o => {
|
||||||
if ((o.specialValueType || o.isIdentity) && o.specialValueType !== ConnectionOptionSpecialType.password) {
|
if ((o.specialValueType || o.isIdentity) && o.specialValueType !== ConnectionOptionSpecialType.password) {
|
||||||
return o.name;
|
return o.name;
|
||||||
} else {
|
} else {
|
||||||
@@ -210,7 +214,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
|
|
||||||
public getSpecialTypeOptionName(type: string): string {
|
public getSpecialTypeOptionName(type: string): string {
|
||||||
if (this._serverCapabilities) {
|
if (this._serverCapabilities) {
|
||||||
let optionMetadata = this._serverCapabilities.connectionProvider.options.find(o => o.specialValueType === type);
|
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === type);
|
||||||
return !!optionMetadata ? optionMetadata.name : undefined;
|
return !!optionMetadata ? optionMetadata.name : undefined;
|
||||||
} else {
|
} else {
|
||||||
return type.toString();
|
return type.toString();
|
||||||
@@ -225,7 +229,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get authenticationTypeDisplayName(): string {
|
public get authenticationTypeDisplayName(): string {
|
||||||
let optionMetadata = this._serverCapabilities.connectionProvider.options.find(o => o.specialValueType === ConnectionOptionSpecialType.authType);
|
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === ConnectionOptionSpecialType.authType);
|
||||||
let authType = this.authenticationType;
|
let authType = this.authenticationType;
|
||||||
let displayName: string = authType;
|
let displayName: string = authType;
|
||||||
|
|
||||||
@@ -240,7 +244,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getProviderOptions(): sqlops.ConnectionOption[] {
|
public getProviderOptions(): sqlops.ConnectionOption[] {
|
||||||
return this._serverCapabilities.connectionProvider.options;
|
return this._serverCapabilities.connectionOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static get idSeparator(): string {
|
public static get idSeparator(): string {
|
||||||
@@ -258,7 +262,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
|||||||
parts.push(this.databaseName);
|
parts.push(this.databaseName);
|
||||||
parts.push(this.authenticationTypeDisplayName);
|
parts.push(this.authenticationTypeDisplayName);
|
||||||
|
|
||||||
this._serverCapabilities.connectionProvider.options.forEach(element => {
|
this._serverCapabilities.connectionOptions.forEach(element => {
|
||||||
if (element.specialValueType !== ConnectionOptionSpecialType.serverName &&
|
if (element.specialValueType !== ConnectionOptionSpecialType.serverName &&
|
||||||
element.specialValueType !== ConnectionOptionSpecialType.databaseName &&
|
element.specialValueType !== ConnectionOptionSpecialType.databaseName &&
|
||||||
element.specialValueType !== ConnectionOptionSpecialType.authType &&
|
element.specialValueType !== ConnectionOptionSpecialType.authType &&
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import * as sqlops from 'sqlops';
|
|||||||
import * as Utils from 'sql/parts/connection/common/utils';
|
import * as Utils from 'sql/parts/connection/common/utils';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
|
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||||
|
|
||||||
export class ConnectionController implements IConnectionComponentController {
|
export class ConnectionController implements IConnectionComponentController {
|
||||||
private _container: HTMLElement;
|
private _container: HTMLElement;
|
||||||
@@ -31,14 +32,14 @@ export class ConnectionController implements IConnectionComponentController {
|
|||||||
|
|
||||||
constructor(container: HTMLElement,
|
constructor(container: HTMLElement,
|
||||||
connectionManagementService: IConnectionManagementService,
|
connectionManagementService: IConnectionManagementService,
|
||||||
sqlCapabilities: sqlops.DataProtocolServerCapabilities,
|
connectionProperties: ConnectionProviderProperties,
|
||||||
callback: IConnectionComponentCallbacks,
|
callback: IConnectionComponentCallbacks,
|
||||||
providerName: string,
|
providerName: string,
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService ) {
|
@IInstantiationService private _instantiationService: IInstantiationService) {
|
||||||
this._container = container;
|
this._container = container;
|
||||||
this._connectionManagementService = connectionManagementService;
|
this._connectionManagementService = connectionManagementService;
|
||||||
this._callback = callback;
|
this._callback = callback;
|
||||||
this._providerOptions = sqlCapabilities.connectionProvider.options;
|
this._providerOptions = connectionProperties.connectionOptions;
|
||||||
var specialOptions = this._providerOptions.filter(
|
var specialOptions = this._providerOptions.filter(
|
||||||
(property) => (property.specialValueType !== null && property.specialValueType !== undefined));
|
(property) => (property.specialValueType !== null && property.specialValueType !== undefined));
|
||||||
this._connectionWidget = this._instantiationService.createInstance(ConnectionWidget, specialOptions, {
|
this._connectionWidget = this._instantiationService.createInstance(ConnectionWidget, specialOptions, {
|
||||||
@@ -65,7 +66,7 @@ export class ConnectionController implements IConnectionComponentController {
|
|||||||
let uri = this._connectionManagementService.getConnectionId(tempProfile);
|
let uri = this._connectionManagementService.getConnectionId(tempProfile);
|
||||||
return new Promise<string[]>((resolve, reject) => {
|
return new Promise<string[]>((resolve, reject) => {
|
||||||
if (this._databaseCache.has(uri)) {
|
if (this._databaseCache.has(uri)) {
|
||||||
let cachedDatabases : string[] = this._databaseCache.get(uri);
|
let cachedDatabases: string[] = this._databaseCache.get(uri);
|
||||||
if (cachedDatabases !== null) {
|
if (cachedDatabases !== null) {
|
||||||
resolve(cachedDatabases);
|
resolve(cachedDatabases);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import { IWindowsService } from 'vs/platform/windows/common/windows';
|
|||||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
import * as types from 'vs/base/common/types';
|
import * as types from 'vs/base/common/types';
|
||||||
|
import { entries } from 'sql/base/common/objects';
|
||||||
|
|
||||||
export interface IConnectionValidateResult {
|
export interface IConnectionValidateResult {
|
||||||
isValid: boolean;
|
isValid: boolean;
|
||||||
@@ -190,7 +191,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
// Set the model name, initialize the controller if needed, and return the controller
|
// Set the model name, initialize the controller if needed, and return the controller
|
||||||
this._model.providerName = providerName;
|
this._model.providerName = providerName;
|
||||||
if (!this._connectionControllerMap[providerName]) {
|
if (!this._connectionControllerMap[providerName]) {
|
||||||
this._connectionControllerMap[providerName] = this._instantiationService.createInstance(ConnectionController, this._container, this._connectionManagementService, this._capabilitiesService.getCapabilities(providerName), {
|
this._connectionControllerMap[providerName] = this._instantiationService.createInstance(ConnectionController, this._container, this._connectionManagementService, this._capabilitiesService.getCapabilities(providerName).connection, {
|
||||||
onSetConnectButton: (enable: boolean) => this.handleSetConnectButtonEnable(enable)
|
onSetConnectButton: (enable: boolean) => this.handleSetConnectButtonEnable(enable)
|
||||||
}, providerName);
|
}, providerName);
|
||||||
}
|
}
|
||||||
@@ -274,12 +275,9 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
// only create the provider maps first time the dialog gets called
|
// only create the provider maps first time the dialog gets called
|
||||||
let capabilitiesPromise: Promise<void> = Promise.resolve();
|
let capabilitiesPromise: Promise<void> = Promise.resolve();
|
||||||
if (this._providerTypes.length === 0) {
|
if (this._providerTypes.length === 0) {
|
||||||
capabilitiesPromise = this._capabilitiesService.onCapabilitiesReady().then(() => {
|
entries(this._capabilitiesService.providers).forEach(p => {
|
||||||
this._capabilitiesService.providers.map(p => {
|
this._providerTypes.push(p[1].connection.displayName);
|
||||||
let capabilities = this._capabilitiesService.getCapabilities(p);
|
this._providerNameToDisplayNameMap[p[0]] = p[1].connection.displayName;
|
||||||
this._providerTypes.push(capabilities.providerDisplayName);
|
|
||||||
this._providerNameToDisplayNameMap[capabilities.providerName] = capabilities.providerDisplayName;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
capabilitiesPromise.then(s => {
|
capabilitiesPromise.then(s => {
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export class BackupUiService implements IBackupUiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getOptions(provider: string): ServiceOption[] {
|
private getOptions(provider: string): ServiceOption[] {
|
||||||
let feature = this._capabilitiesService.getCapabilities(this._currentProvider).features.find(f => f.featureName === 'backup');
|
let feature = this._capabilitiesService.getLegacyCapabilities(this._currentProvider).features.find(f => f.featureName === 'backup');
|
||||||
if (feature) {
|
if (feature) {
|
||||||
return feature.optionsMetadata;
|
return feature.optionsMetadata;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ export class RestoreDialogController implements IRestoreDialogController {
|
|||||||
private getRestoreOption(): sqlops.ServiceOption[] {
|
private getRestoreOption(): sqlops.ServiceOption[] {
|
||||||
let options: sqlops.ServiceOption[] = [];
|
let options: sqlops.ServiceOption[] = [];
|
||||||
let providerId: string = this.getCurrentProviderId();
|
let providerId: string = this.getCurrentProviderId();
|
||||||
let providerCapabilities = this._capabilitiesService.getCapabilities(providerId);
|
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);
|
||||||
|
|
||||||
if (providerCapabilities) {
|
if (providerCapabilities) {
|
||||||
let restoreMetadataProvider = providerCapabilities.features.find(f => f.featureName === this._restoreFeature);
|
let restoreMetadataProvider = providerCapabilities.features.find(f => f.featureName === this._restoreFeature);
|
||||||
|
|||||||
@@ -60,14 +60,6 @@ export class ServerTreeView {
|
|||||||
this);
|
this);
|
||||||
this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler);
|
this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler);
|
||||||
this._onSelectionOrFocusChange = new Emitter();
|
this._onSelectionOrFocusChange = new Emitter();
|
||||||
if (this._capabilitiesService) {
|
|
||||||
this._capabilitiesService.onCapabilitiesReady().then(() => {
|
|
||||||
if (this._connectionManagementService.hasRegisteredServers()) {
|
|
||||||
this.refreshTree();
|
|
||||||
this._treeSelectionHandler.onTreeActionStateChange(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,24 +8,31 @@
|
|||||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||||
import * as Constants from 'sql/common/constants';
|
import * as Constants from 'sql/common/constants';
|
||||||
import { Deferred } from 'sql/base/common/promise';
|
import { Deferred } from 'sql/base/common/promise';
|
||||||
|
import { ConnectionProviderProperties, IConnectionProviderRegistry, Extensions as ConnectionExtensions } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||||
|
import { toObject } from 'sql/base/common/map';
|
||||||
|
|
||||||
import * as sqlops from 'sqlops';
|
import * as sqlops from 'sqlops';
|
||||||
|
|
||||||
import Event, { Emitter } from 'vs/base/common/event';
|
import Event, { Emitter } from 'vs/base/common/event';
|
||||||
import { IAction } from 'vs/base/common/actions';
|
import { IAction } from 'vs/base/common/actions';
|
||||||
import { getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
|
||||||
import { IExtensionManagementService, ILocalExtension, IExtensionEnablementService, LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement';
|
|
||||||
import { Memento } from 'vs/workbench/common/memento';
|
import { Memento } from 'vs/workbench/common/memento';
|
||||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||||
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
|
|
||||||
export const SERVICE_ID = 'capabilitiesService';
|
export const SERVICE_ID = 'capabilitiesService';
|
||||||
export const HOST_NAME = 'sqlops';
|
export const HOST_NAME = 'sqlops';
|
||||||
export const HOST_VERSION = '1.0';
|
export const HOST_VERSION = '1.0';
|
||||||
|
|
||||||
interface IProtocolMomento {
|
const connectionRegistry = Registry.as<IConnectionProviderRegistry>(ConnectionExtensions.ConnectionProviderContributions);
|
||||||
[id: string]: sqlops.DataProtocolServerCapabilities;
|
|
||||||
|
interface ConnectionCache {
|
||||||
|
[id: string]: ConnectionProviderProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CapabilitiesMomento {
|
||||||
|
connectionProviderCache: ConnectionCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const clientCapabilities = {
|
export const clientCapabilities = {
|
||||||
@@ -33,6 +40,11 @@ export const clientCapabilities = {
|
|||||||
hostVersion: HOST_VERSION
|
hostVersion: HOST_VERSION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface ProviderFeatures {
|
||||||
|
connection: ConnectionProviderProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ICapabilitiesService = createDecorator<ICapabilitiesService>(SERVICE_ID);
|
export const ICapabilitiesService = createDecorator<ICapabilitiesService>(SERVICE_ID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +56,12 @@ export interface ICapabilitiesService {
|
|||||||
/**
|
/**
|
||||||
* Retrieve a list of registered capabilities providers
|
* Retrieve a list of registered capabilities providers
|
||||||
*/
|
*/
|
||||||
getCapabilities(provider: string): sqlops.DataProtocolServerCapabilities;
|
getCapabilities(provider: string): ProviderFeatures;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the old version of provider information
|
||||||
|
*/
|
||||||
|
getLegacyCapabilities(provider: string): sqlops.DataProtocolServerCapabilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a capabilities provider
|
* Register a capabilities provider
|
||||||
@@ -56,20 +73,15 @@ export interface ICapabilitiesService {
|
|||||||
*/
|
*/
|
||||||
isFeatureAvailable(action: IAction, connectionManagementInfo: ConnectionManagementInfo): boolean;
|
isFeatureAvailable(action: IAction, connectionManagementInfo: ConnectionManagementInfo): boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* Promise fulfilled when Capabilities are ready
|
|
||||||
*/
|
|
||||||
onCapabilitiesReady(): Promise<void>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a new capabilities is registered, it emits the provider name, be to use to get the new capabilities
|
* When a new capabilities is registered, it emits the provider name, be to use to get the new capabilities
|
||||||
*/
|
*/
|
||||||
readonly onCapabilitiesRegistered: Event<string>;
|
readonly onCapabilitiesRegistered: Event<ProviderFeatures>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array of all known providers
|
* Get an array of all known providers
|
||||||
*/
|
*/
|
||||||
readonly providers: string[];
|
readonly providers: { [id: string]: ProviderFeatures };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,89 +90,76 @@ export interface ICapabilitiesService {
|
|||||||
* to discover the DMP capabilties that a DMP provider offers.
|
* to discover the DMP capabilties that a DMP provider offers.
|
||||||
*/
|
*/
|
||||||
export class CapabilitiesService extends Disposable implements ICapabilitiesService {
|
export class CapabilitiesService extends Disposable implements ICapabilitiesService {
|
||||||
|
_serviceBrand: any;
|
||||||
|
|
||||||
public _serviceBrand: any;
|
private _momento = new Memento('capabilities');
|
||||||
|
private _providers = new Map<string, ProviderFeatures>();
|
||||||
|
private _featureUpdateEvents = new Map<string, Emitter<ProviderFeatures>>();
|
||||||
|
private _legacyProviders = new Map<string, sqlops.DataProtocolServerCapabilities>();
|
||||||
|
|
||||||
private _momento = new Memento('capabilitiesCache');
|
private _onCapabilitiesRegistered = this._register(new Emitter<ProviderFeatures>());
|
||||||
|
|
||||||
private static DATA_PROVIDER_CATEGORY: string = 'Data Provider';
|
|
||||||
|
|
||||||
private disposables: IDisposable[] = [];
|
|
||||||
|
|
||||||
private _onCapabilitiesReady = new Deferred<void>();
|
|
||||||
|
|
||||||
// Setting this to 1 by default as we have MS SQL provider by default and then we increament
|
|
||||||
// this number based on extensions installed.
|
|
||||||
// TODO once we have a complete extension story this might change and will have to be looked into
|
|
||||||
|
|
||||||
private _expectedCapabilitiesCount: number = 1;
|
|
||||||
|
|
||||||
private _registeredCapabilities: number = 0;
|
|
||||||
|
|
||||||
private _onCapabilitiesRegistered = this._register(new Emitter<string>());
|
|
||||||
public readonly onCapabilitiesRegistered = this._onCapabilitiesRegistered.event;
|
public readonly onCapabilitiesRegistered = this._onCapabilitiesRegistered.event;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IExtensionManagementService private extensionManagementService: IExtensionManagementService,
|
|
||||||
@IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService,
|
|
||||||
@IStorageService private _storageService: IStorageService
|
@IStorageService private _storageService: IStorageService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// Get extensions and filter where the category has 'Data Provider' in it
|
if (!this.capabilities.connectionProviderCache) {
|
||||||
this.extensionManagementService.getInstalled(LocalExtensionType.User).then((extensions: ILocalExtension[]) => {
|
this.capabilities.connectionProviderCache = {};
|
||||||
let dataProviderExtensions = extensions.filter(extension =>
|
|
||||||
extension.manifest.categories && extension.manifest.categories.indexOf(CapabilitiesService.DATA_PROVIDER_CATEGORY) > -1);
|
|
||||||
|
|
||||||
if (dataProviderExtensions.length > 0) {
|
|
||||||
// Scrape out disabled extensions
|
|
||||||
|
|
||||||
// @SQLTODO reenable this code
|
|
||||||
// this.extensionEnablementService.getDisabledExtensions()
|
|
||||||
// .then(disabledExtensions => {
|
|
||||||
|
|
||||||
// let disabledExtensionsId = disabledExtensions.map(disabledExtension => disabledExtension.id);
|
|
||||||
// dataProviderExtensions = dataProviderExtensions.filter(extension =>
|
|
||||||
// disabledExtensions.indexOf(getGalleryExtensionId(extension.manifest.publisher, extension.manifest.name)) < 0);
|
|
||||||
|
|
||||||
|
|
||||||
// // return extensions.map(extension => {
|
|
||||||
// // return {
|
|
||||||
// // identifier: { id: adoptToGalleryExtensionId(stripVersion(extension.identifier.id)), uuid: extension.identifier.uuid },
|
|
||||||
// // local: extension,
|
|
||||||
// // globallyEnabled: disabledExtensions.every(disabled => !areSameExtensions(disabled, extension.identifier))
|
|
||||||
// // };
|
|
||||||
// // });
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
// const disabledExtensions = this.extensionEnablementService.getGloballyDisabledExtensions()
|
|
||||||
// .map(disabledExtension => disabledExtension.id);
|
|
||||||
// dataProviderExtensions = dataProviderExtensions.filter(extension =>
|
|
||||||
// disabledExtensions.indexOf(getGalleryExtensionId(extension.manifest.publisher, extension.manifest.name)) < 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._expectedCapabilitiesCount += dataProviderExtensions.length;
|
// handle in case some extensions have already registered (unlikley)
|
||||||
|
Object.entries(connectionRegistry.providers).map(v => {
|
||||||
|
this.handleConnectionProvider({ id: v[0], properties: v[1] });
|
||||||
|
});
|
||||||
|
// register for when new extensions are added
|
||||||
|
connectionRegistry.onNewProvider(this.handleConnectionProvider, this);
|
||||||
|
|
||||||
|
// handle adding already known capabilities (could have caching problems)
|
||||||
|
Object.entries(this.capabilities.connectionProviderCache).map(v => {
|
||||||
|
this.handleConnectionProvider({ id: v[0], properties: v[1] }, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCapabilitiesReady(): Promise<void> {
|
private handleConnectionProvider(e: { id: string, properties: ConnectionProviderProperties }, isNew = true): void {
|
||||||
return this._onCapabilitiesReady.promise;
|
|
||||||
|
let provider = this._providers.get(e.id);
|
||||||
|
if (provider) {
|
||||||
|
provider.connection = e.properties;
|
||||||
|
} else {
|
||||||
|
provider = {
|
||||||
|
connection: e.properties
|
||||||
|
};
|
||||||
|
this._providers.set(e.id, provider);
|
||||||
|
}
|
||||||
|
if (!this._featureUpdateEvents.has(e.id)) {
|
||||||
|
this._featureUpdateEvents.set(e.id, new Emitter<ProviderFeatures>());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNew) {
|
||||||
|
this.capabilities.connectionProviderCache[e.id] = e.properties;
|
||||||
|
this._onCapabilitiesRegistered.fire(provider);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list of registered server capabilities
|
* Retrieve a list of registered server capabilities
|
||||||
*/
|
*/
|
||||||
public getCapabilities(provider: string): sqlops.DataProtocolServerCapabilities {
|
public getCapabilities(provider: string): ProviderFeatures {
|
||||||
return this.capabilities[provider];
|
return this._providers.get(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get providers(): string[] {
|
public getLegacyCapabilities(provider: string): sqlops.DataProtocolServerCapabilities {
|
||||||
return Object.keys(this.capabilities);
|
return this._legacyProviders.get(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
private get capabilities(): IProtocolMomento {
|
public get providers(): { [id: string]: ProviderFeatures } {
|
||||||
return this._momento.getMemento(this._storageService) as IProtocolMomento;
|
return toObject(this._providers);
|
||||||
|
}
|
||||||
|
|
||||||
|
private get capabilities(): CapabilitiesMomento {
|
||||||
|
return this._momento.getMemento(this._storageService) as CapabilitiesMomento;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,20 +169,10 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
|||||||
public registerProvider(provider: sqlops.CapabilitiesProvider): void {
|
public registerProvider(provider: sqlops.CapabilitiesProvider): void {
|
||||||
// request the capabilities from server
|
// request the capabilities from server
|
||||||
provider.getServerCapabilities(clientCapabilities).then(serverCapabilities => {
|
provider.getServerCapabilities(clientCapabilities).then(serverCapabilities => {
|
||||||
this.capabilities[serverCapabilities.providerName] = serverCapabilities;
|
this._legacyProviders.set(serverCapabilities.providerName, serverCapabilities);
|
||||||
this._momento.saveMemento();
|
|
||||||
this._onCapabilitiesRegistered.fire(serverCapabilities.providerName);
|
|
||||||
this._registeredCapabilities++;
|
|
||||||
this.resolveCapabilitiesIfReady();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private resolveCapabilitiesIfReady(): void {
|
|
||||||
if (this._registeredCapabilities === this._expectedCapabilitiesCount) {
|
|
||||||
this._onCapabilitiesReady.resolve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the feature is available for given connection
|
* Returns true if the feature is available for given connection
|
||||||
* @param featureComponent a component which should have the feature name
|
* @param featureComponent a component which should have the feature name
|
||||||
@@ -214,6 +203,9 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
|||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public shutdown(): void {
|
||||||
|
this._momento.saveMemento();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export class SerializationService implements ISerializationService {
|
|||||||
|
|
||||||
public getSerializationFeatureMetadataProvider(ownerUri: string): sqlops.FeatureMetadataProvider {
|
public getSerializationFeatureMetadataProvider(ownerUri: string): sqlops.FeatureMetadataProvider {
|
||||||
let providerId: string = this._connectionService.getProviderIdFromUri(ownerUri);
|
let providerId: string = this._connectionService.getProviderIdFromUri(ownerUri);
|
||||||
let providerCapabilities = this._capabilitiesService.getCapabilities(providerId);
|
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);
|
||||||
|
|
||||||
if (providerCapabilities) {
|
if (providerCapabilities) {
|
||||||
return providerCapabilities.features.find(f => f.featureName === SERVICE_ID);
|
return providerCapabilities.features.find(f => f.featureName === SERVICE_ID);
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
|
import { IExtensionPointUser, ExtensionsRegistry } from 'vs/platform/extensions/common/extensionsRegistry';
|
||||||
|
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||||
|
import { localize } from 'vs/nls';
|
||||||
|
import Event, { Emitter } from 'vs/base/common/event';
|
||||||
|
import { deepClone } from 'vs/base/common/objects';
|
||||||
|
|
||||||
|
import * as sqlops from 'sqlops';
|
||||||
|
|
||||||
|
export interface ConnectionProviderProperties {
|
||||||
|
providerId: string;
|
||||||
|
displayName: string;
|
||||||
|
connectionOptions: sqlops.ConnectionOption[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Extensions = {
|
||||||
|
ConnectionProviderContributions: 'connection.providers'
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IConnectionProviderRegistry {
|
||||||
|
registerConnectionProvider(id: string, properties: ConnectionProviderProperties): void;
|
||||||
|
getProperties(id: string): ConnectionProviderProperties;
|
||||||
|
readonly onNewProvider: Event<{ id: string, properties: ConnectionProviderProperties }>;
|
||||||
|
readonly providers: { [id: string]: ConnectionProviderProperties };
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionProviderRegistryImpl implements IConnectionProviderRegistry {
|
||||||
|
private _providers = new Map<string, ConnectionProviderProperties>();
|
||||||
|
private _onNewProvider = new Emitter<{ id: string, properties: ConnectionProviderProperties }>();
|
||||||
|
public readonly onNewProvider: Event<{ id: string, properties: ConnectionProviderProperties }> = this._onNewProvider.event;
|
||||||
|
|
||||||
|
public registerConnectionProvider(id: string, properties: ConnectionProviderProperties): void {
|
||||||
|
this._providers.set(id, properties);
|
||||||
|
this._onNewProvider.fire({ id, properties });
|
||||||
|
}
|
||||||
|
|
||||||
|
public getProperties(id: string): ConnectionProviderProperties {
|
||||||
|
return this._providers.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get providers(): { [id: string]: ConnectionProviderProperties } {
|
||||||
|
let rt: { [id: string]: ConnectionProviderProperties } = {};
|
||||||
|
this._providers.forEach((v, k) => {
|
||||||
|
rt[k] = deepClone(v);
|
||||||
|
});
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const connectionRegistry = new ConnectionProviderRegistryImpl();
|
||||||
|
Registry.add(Extensions.ConnectionProviderContributions, connectionRegistry);
|
||||||
|
|
||||||
|
const ConnectionProviderContrib: IJSONSchema = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
providerId: {
|
||||||
|
type: 'string',
|
||||||
|
description: localize('schema.providerId', "Common id for the provider")
|
||||||
|
},
|
||||||
|
displayName: {
|
||||||
|
type: 'string',
|
||||||
|
description: localize('schema.displayName', "Display Name for the provider")
|
||||||
|
},
|
||||||
|
connectionOptions: {
|
||||||
|
type: 'array',
|
||||||
|
description: localize('schema.connectionOptions', "Options for connection"),
|
||||||
|
items: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
specialValueType: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
isIdentity: {
|
||||||
|
type: 'boolean'
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
displayName: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
groupName: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
valueType: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
defaultValue: {
|
||||||
|
type: 'any'
|
||||||
|
},
|
||||||
|
objectType: {
|
||||||
|
type: 'any'
|
||||||
|
},
|
||||||
|
categoryValues: {
|
||||||
|
type: 'any'
|
||||||
|
},
|
||||||
|
isRequired: {
|
||||||
|
type: 'boolean'
|
||||||
|
},
|
||||||
|
isArray: {
|
||||||
|
type: 'bolean'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
required: ['providerId']
|
||||||
|
};
|
||||||
|
|
||||||
|
ExtensionsRegistry.registerExtensionPoint<ConnectionProviderProperties | ConnectionProviderProperties[]>('connectionProvider', [], ConnectionProviderContrib).setHandler(extensions => {
|
||||||
|
|
||||||
|
function handleCommand(contrib: ConnectionProviderProperties, extension: IExtensionPointUser<any>) {
|
||||||
|
connectionRegistry.registerConnectionProvider(contrib.providerId, contrib);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let extension of extensions) {
|
||||||
|
const { value } = extension;
|
||||||
|
if (Array.isArray<ConnectionProviderProperties>(value)) {
|
||||||
|
for (let command of value) {
|
||||||
|
handleCommand(command, extension);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handleCommand(value, extension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -32,7 +32,8 @@ import { WorkspaceConfigurationTestService } from 'sqltest/stubs/workspaceConfig
|
|||||||
|
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import * as TypeMoq from 'typemoq';
|
import * as TypeMoq from 'typemoq';
|
||||||
import { IConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||||
|
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||||
|
|
||||||
suite('SQL ConnectionManagementService tests', () => {
|
suite('SQL ConnectionManagementService tests', () => {
|
||||||
|
|
||||||
@@ -86,6 +87,8 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
mssqlConnectionProvider = TypeMoq.Mock.ofType(ConnectionProviderStub);
|
mssqlConnectionProvider = TypeMoq.Mock.ofType(ConnectionProviderStub);
|
||||||
let resourceProviderStub = new ResourceProviderStub();
|
let resourceProviderStub = new ResourceProviderStub();
|
||||||
resourceProviderStubMock = TypeMoq.Mock.ofInstance(resourceProviderStub);
|
resourceProviderStubMock = TypeMoq.Mock.ofInstance(resourceProviderStub);
|
||||||
|
let root = new ConnectionProfileGroup(ConnectionProfileGroup.RootGroupName, undefined, ConnectionProfileGroup.RootGroupName, undefined, undefined);
|
||||||
|
root.connections = [ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile)];
|
||||||
|
|
||||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined)).returns(() => TPromise.as(none));
|
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined)).returns(() => TPromise.as(none));
|
||||||
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, undefined)).returns(() => TPromise.as(none));
|
connectionDialogService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), undefined, undefined)).returns(() => TPromise.as(none));
|
||||||
@@ -105,6 +108,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
c => c.serverName === connectionProfileWithEmptyUnsavedPassword.serverName))).returns(
|
c => c.serverName === connectionProfileWithEmptyUnsavedPassword.serverName))).returns(
|
||||||
() => Promise.resolve({ profile: connectionProfileWithEmptyUnsavedPassword, savedCred: false }));
|
() => Promise.resolve({ profile: connectionProfileWithEmptyUnsavedPassword, savedCred: false }));
|
||||||
connectionStore.setup(x => x.isPasswordRequired(TypeMoq.It.isAny())).returns(() => true);
|
connectionStore.setup(x => x.isPasswordRequired(TypeMoq.It.isAny())).returns(() => true);
|
||||||
|
connectionStore.setup(x => x.getConnectionProfileGroups()).returns(() => [root]);
|
||||||
|
|
||||||
mssqlConnectionProvider.setup(x => x.connect(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => undefined);
|
mssqlConnectionProvider.setup(x => x.connect(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => undefined);
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ import * as sqlops from 'sqlops';
|
|||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||||
|
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||||
|
|
||||||
suite('SQL ConnectionProfileInfo tests', () => {
|
suite('SQL ConnectionProfileInfo tests', () => {
|
||||||
let msSQLCapabilities: sqlops.DataProtocolServerCapabilities;
|
let msSQLCapabilities: ConnectionProviderProperties;
|
||||||
let capabilitiesService: CapabilitiesTestService;
|
let capabilitiesService: CapabilitiesTestService;
|
||||||
|
|
||||||
let connectionProfile: IConnectionProfile = {
|
let connectionProfile: IConnectionProfile = {
|
||||||
@@ -49,9 +50,7 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
let capabilities: sqlops.DataProtocolServerCapabilities[] = [];
|
let connectionProvider: sqlops.ConnectionOption[] = [
|
||||||
let connectionProvider: sqlops.ConnectionProviderOptions = {
|
|
||||||
options: [
|
|
||||||
{
|
{
|
||||||
name: 'serverName',
|
name: 'serverName',
|
||||||
displayName: undefined,
|
displayName: undefined,
|
||||||
@@ -112,19 +111,14 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
|||||||
specialValueType: ConnectionOptionSpecialType.password,
|
specialValueType: ConnectionOptionSpecialType.password,
|
||||||
valueType: 0
|
valueType: 0
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
};
|
|
||||||
msSQLCapabilities = {
|
msSQLCapabilities = {
|
||||||
protocolVersion: '1',
|
providerId: 'MSSQL',
|
||||||
providerName: 'MSSQL',
|
displayName: 'MSSQL',
|
||||||
providerDisplayName: 'MSSQL',
|
connectionOptions: connectionProvider
|
||||||
connectionProvider: connectionProvider,
|
|
||||||
adminServicesProvider: undefined,
|
|
||||||
features: undefined
|
|
||||||
};
|
};
|
||||||
capabilities.push(msSQLCapabilities);
|
|
||||||
capabilitiesService = new CapabilitiesTestService();
|
capabilitiesService = new CapabilitiesTestService();
|
||||||
capabilitiesService.capabilities['MSSQL'] = msSQLCapabilities;
|
capabilitiesService.capabilities['MSSQL'] = { connection: msSQLCapabilities };
|
||||||
});
|
});
|
||||||
|
|
||||||
test('set properties should set the values correctly', () => {
|
test('set properties should set the values correctly', () => {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { Emitter } from 'vs/base/common/event';
|
|||||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
import { CapabilitiesTestService } from '../../stubs/capabilitiesTestService';
|
import { CapabilitiesTestService } from '../../stubs/capabilitiesTestService';
|
||||||
|
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||||
|
|
||||||
suite('SQL ConnectionStore tests', () => {
|
suite('SQL ConnectionStore tests', () => {
|
||||||
let defaultNamedProfile: IConnectionProfile;
|
let defaultNamedProfile: IConnectionProfile;
|
||||||
@@ -33,7 +34,7 @@ suite('SQL ConnectionStore tests', () => {
|
|||||||
let capabilitiesService: CapabilitiesTestService;
|
let capabilitiesService: CapabilitiesTestService;
|
||||||
let mementoArray: any = [];
|
let mementoArray: any = [];
|
||||||
let maxRecent = 5;
|
let maxRecent = 5;
|
||||||
let msSQLCapabilities: sqlops.DataProtocolServerCapabilities;
|
let msSQLCapabilities: ConnectionProviderProperties;
|
||||||
let defaultNamedConnectionProfile: ConnectionProfile;
|
let defaultNamedConnectionProfile: ConnectionProfile;
|
||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
@@ -96,9 +97,7 @@ suite('SQL ConnectionStore tests', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
capabilitiesService = new CapabilitiesTestService();
|
capabilitiesService = new CapabilitiesTestService();
|
||||||
let capabilities: { [id: string]: sqlops.DataProtocolServerCapabilities } = {};
|
let connectionProvider: sqlops.ConnectionOption[] = [
|
||||||
let connectionProvider: sqlops.ConnectionProviderOptions = {
|
|
||||||
options: [
|
|
||||||
{
|
{
|
||||||
name: 'serverName',
|
name: 'serverName',
|
||||||
displayName: undefined,
|
displayName: undefined,
|
||||||
@@ -159,18 +158,13 @@ suite('SQL ConnectionStore tests', () => {
|
|||||||
specialValueType: ConnectionOptionSpecialType.password,
|
specialValueType: ConnectionOptionSpecialType.password,
|
||||||
valueType: 0
|
valueType: 0
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
};
|
|
||||||
msSQLCapabilities = {
|
msSQLCapabilities = {
|
||||||
protocolVersion: '1',
|
providerId: 'MSSQL',
|
||||||
providerName: 'MSSQL',
|
displayName: 'MSSQL',
|
||||||
providerDisplayName: 'MSSQL',
|
connectionOptions: connectionProvider
|
||||||
connectionProvider: connectionProvider,
|
|
||||||
adminServicesProvider: undefined,
|
|
||||||
features: undefined
|
|
||||||
};
|
};
|
||||||
capabilities['MSSQL'] = msSQLCapabilities;
|
capabilitiesService.capabilities['MSSQL'] = { connection: msSQLCapabilities };
|
||||||
capabilitiesService.capabilities['MSSQL'] = msSQLCapabilities;
|
|
||||||
let groups: IConnectionProfileGroup[] = [
|
let groups: IConnectionProfileGroup[] = [
|
||||||
{
|
{
|
||||||
id: 'root',
|
id: 'root',
|
||||||
@@ -368,24 +362,19 @@ suite('SQL ConnectionStore tests', () => {
|
|||||||
|
|
||||||
test('isPasswordRequired should return false if the password is not required in capabilities', () => {
|
test('isPasswordRequired should return false if the password is not required in capabilities', () => {
|
||||||
let providerName: string = 'providername';
|
let providerName: string = 'providername';
|
||||||
let connectionProvider: sqlops.ConnectionProviderOptions = {
|
let connectionProvider = msSQLCapabilities.connectionOptions.map(o => {
|
||||||
options: msSQLCapabilities.connectionProvider.options.map(o => {
|
|
||||||
if (o.name === 'password') {
|
if (o.name === 'password') {
|
||||||
o.isRequired = false;
|
o.isRequired = false;
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
})
|
});
|
||||||
};
|
|
||||||
let providerCapabilities = {
|
let providerCapabilities = {
|
||||||
protocolVersion: '1',
|
providerId: providerName,
|
||||||
providerName: providerName,
|
displayName: providerName,
|
||||||
providerDisplayName: providerName,
|
connectionOptions: connectionProvider
|
||||||
connectionProvider: connectionProvider,
|
|
||||||
adminServicesProvider: undefined,
|
|
||||||
features: undefined
|
|
||||||
};
|
};
|
||||||
|
|
||||||
capabilitiesService.capabilities[providerName] = providerCapabilities;
|
capabilitiesService.capabilities[providerName] = { connection: providerCapabilities };
|
||||||
|
|
||||||
let connectionStore = new ConnectionStore(storageServiceMock.object, context.object, undefined, workspaceConfigurationServiceMock.object,
|
let connectionStore = new ConnectionStore(storageServiceMock.object, context.object, undefined, workspaceConfigurationServiceMock.object,
|
||||||
credentialStore.object, capabilitiesService, connectionConfig.object);
|
credentialStore.object, capabilitiesService, connectionConfig.object);
|
||||||
|
|||||||
@@ -342,15 +342,12 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
test('RefreshConnectionAction - refresh should be called if connection status is connect', (done) => {
|
test('RefreshConnectionAction - refresh should be called if connection status is connect', (done) => {
|
||||||
let isConnectedReturnValue: boolean = true;
|
let isConnectedReturnValue: boolean = true;
|
||||||
let sqlProvider = {
|
let sqlProvider = {
|
||||||
protocolVersion: '1',
|
providerId: 'MSSQL',
|
||||||
providerName: 'MSSQL',
|
displayName: 'MSSQL',
|
||||||
providerDisplayName: 'MSSQL',
|
connectionOptions: [],
|
||||||
connectionProvider: { options: [] },
|
|
||||||
adminServicesProvider: { databaseInfoOptions: [], databaseFileInfoOptions: [], fileGroupInfoOptions: [] },
|
|
||||||
features: undefined
|
|
||||||
};
|
};
|
||||||
|
|
||||||
capabilitiesService.capabilities['MSSQL'] = sqlProvider;
|
capabilitiesService.capabilities['MSSQL'] = { connection: sqlProvider };
|
||||||
|
|
||||||
var connection = new ConnectionProfile(capabilitiesService, {
|
var connection = new ConnectionProfile(capabilitiesService, {
|
||||||
savePassword: false,
|
savePassword: false,
|
||||||
@@ -433,15 +430,12 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
test('RefreshConnectionAction - refresh should not be called if connection status is not connect', (done) => {
|
test('RefreshConnectionAction - refresh should not be called if connection status is not connect', (done) => {
|
||||||
let isConnectedReturnValue: boolean = false;
|
let isConnectedReturnValue: boolean = false;
|
||||||
let sqlProvider = {
|
let sqlProvider = {
|
||||||
protocolVersion: '1',
|
providerId: 'MSSQL',
|
||||||
providerName: 'MSSQL',
|
displayName: 'MSSQL',
|
||||||
providerDisplayName: 'MSSQL',
|
connectionOptions: []
|
||||||
connectionProvider: { options: [] },
|
|
||||||
adminServicesProvider: { databaseInfoOptions: [], databaseFileInfoOptions: [], fileGroupInfoOptions: [] },
|
|
||||||
features: undefined
|
|
||||||
};
|
};
|
||||||
|
|
||||||
capabilitiesService.capabilities['MSSQL'] = sqlProvider;
|
capabilitiesService.capabilities['MSSQL'] = { connection: sqlProvider };
|
||||||
|
|
||||||
var connection = new ConnectionProfile(capabilitiesService, {
|
var connection = new ConnectionProfile(capabilitiesService, {
|
||||||
savePassword: false,
|
savePassword: false,
|
||||||
|
|||||||
@@ -128,11 +128,9 @@ suite('SQL Object Explorer Service tests', () => {
|
|||||||
let onCapabilitiesRegistered = new Emitter<string>();
|
let onCapabilitiesRegistered = new Emitter<string>();
|
||||||
|
|
||||||
let sqlProvider = {
|
let sqlProvider = {
|
||||||
protocolVersion: '1',
|
providerId: 'MSSQL',
|
||||||
providerName: 'MSSQL',
|
displayName: 'MSSQL',
|
||||||
providerDisplayName: 'MSSQL',
|
connectionOptions: [
|
||||||
connectionProvider: {
|
|
||||||
options: [
|
|
||||||
{
|
{
|
||||||
name: 'serverName',
|
name: 'serverName',
|
||||||
displayName: undefined,
|
displayName: undefined,
|
||||||
@@ -204,14 +202,12 @@ suite('SQL Object Explorer Service tests', () => {
|
|||||||
isRequired: false,
|
isRequired: false,
|
||||||
specialValueType: undefined,
|
specialValueType: undefined,
|
||||||
valueType: 0
|
valueType: 0
|
||||||
}]
|
}
|
||||||
},
|
]
|
||||||
adminServicesProvider: { databaseInfoOptions: [], databaseFileInfoOptions: [], fileGroupInfoOptions: [] },
|
|
||||||
features: undefined
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let capabilitiesService = new CapabilitiesTestService();
|
let capabilitiesService = new CapabilitiesTestService();
|
||||||
capabilitiesService.capabilities['MSSQL'] = sqlProvider;
|
capabilitiesService.capabilities['MSSQL'] = { connection: sqlProvider };
|
||||||
|
|
||||||
connection = new ConnectionProfile(capabilitiesService, {
|
connection = new ConnectionProfile(capabilitiesService, {
|
||||||
savePassword: false,
|
savePassword: false,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesServ
|
|||||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||||
|
|
||||||
suite('SQL ProviderConnectionInfo tests', () => {
|
suite('SQL ProviderConnectionInfo tests', () => {
|
||||||
let msSQLCapabilities: sqlops.DataProtocolServerCapabilities;
|
let msSQLCapabilities: any;
|
||||||
let capabilitiesService: CapabilitiesTestService;
|
let capabilitiesService: CapabilitiesTestService;
|
||||||
|
|
||||||
let connectionProfile: IConnectionProfile = {
|
let connectionProfile: IConnectionProfile = {
|
||||||
@@ -37,8 +37,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
|||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
let capabilities: sqlops.DataProtocolServerCapabilities[] = [];
|
let capabilities: sqlops.DataProtocolServerCapabilities[] = [];
|
||||||
let connectionProvider: sqlops.ConnectionProviderOptions = {
|
let connectionProvider: sqlops.ConnectionOption[] = [
|
||||||
options: [
|
|
||||||
{
|
{
|
||||||
name: 'serverName',
|
name: 'serverName',
|
||||||
displayName: undefined,
|
displayName: undefined,
|
||||||
@@ -111,19 +110,15 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
|||||||
specialValueType: undefined,
|
specialValueType: undefined,
|
||||||
valueType: 0
|
valueType: 0
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
};
|
|
||||||
msSQLCapabilities = {
|
msSQLCapabilities = {
|
||||||
protocolVersion: '1',
|
providerId: 'MSSQL',
|
||||||
providerName: 'MSSQL',
|
displayName: 'MSSQL',
|
||||||
providerDisplayName: 'MSSQL',
|
connectionOptions: connectionProvider,
|
||||||
connectionProvider: connectionProvider,
|
|
||||||
adminServicesProvider: undefined,
|
|
||||||
features: undefined
|
|
||||||
};
|
};
|
||||||
capabilities.push(msSQLCapabilities);
|
capabilities.push(msSQLCapabilities);
|
||||||
capabilitiesService = new CapabilitiesTestService();
|
capabilitiesService = new CapabilitiesTestService();
|
||||||
capabilitiesService.capabilities['MSSQL'] = msSQLCapabilities;
|
capabilitiesService.capabilities['MSSQL'] = { connection: msSQLCapabilities };
|
||||||
});
|
});
|
||||||
|
|
||||||
test('constructor should accept undefined parameters', () => {
|
test('constructor should accept undefined parameters', () => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import * as sqlops from 'sqlops';
|
import * as sqlops from 'sqlops';
|
||||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||||
import { ICapabilitiesService, clientCapabilities } from 'sql/services/capabilities/capabilitiesService';
|
import { ICapabilitiesService, clientCapabilities, ProviderFeatures } from 'sql/services/capabilities/capabilitiesService';
|
||||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||||
|
|
||||||
import Event, { Emitter } from 'vs/base/common/event';
|
import Event, { Emitter } from 'vs/base/common/event';
|
||||||
@@ -18,12 +18,11 @@ export class CapabilitiesTestService implements ICapabilitiesService {
|
|||||||
|
|
||||||
private _providers: sqlops.CapabilitiesProvider[] = [];
|
private _providers: sqlops.CapabilitiesProvider[] = [];
|
||||||
|
|
||||||
public capabilities: { [id: string]: sqlops.DataProtocolServerCapabilities } = {};
|
public capabilities: { [id: string]: ProviderFeatures } = {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
let connectionProvider: sqlops.ConnectionProviderOptions = {
|
let connectionProvider: sqlops.ConnectionOption[] = [
|
||||||
options: [
|
|
||||||
{
|
{
|
||||||
name: 'serverName',
|
name: 'serverName',
|
||||||
displayName: undefined,
|
displayName: undefined,
|
||||||
@@ -84,29 +83,29 @@ export class CapabilitiesTestService implements ICapabilitiesService {
|
|||||||
specialValueType: ConnectionOptionSpecialType.password,
|
specialValueType: ConnectionOptionSpecialType.password,
|
||||||
valueType: 0
|
valueType: 0
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
};
|
|
||||||
let msSQLCapabilities = {
|
let msSQLCapabilities = {
|
||||||
protocolVersion: '1',
|
providerId: 'MSSQL',
|
||||||
providerName: 'MSSQL',
|
displayName: 'MSSQL',
|
||||||
providerDisplayName: 'MSSQL',
|
connectionOptions: connectionProvider,
|
||||||
connectionProvider: connectionProvider,
|
|
||||||
adminServicesProvider: undefined,
|
|
||||||
features: undefined
|
|
||||||
};
|
};
|
||||||
this.capabilities['MSSQL'] = msSQLCapabilities;
|
this.capabilities['MSSQL'] = { connection: msSQLCapabilities };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list of registered server capabilities
|
* Retrieve a list of registered server capabilities
|
||||||
*/
|
*/
|
||||||
public getCapabilities(provider: string): sqlops.DataProtocolServerCapabilities {
|
public getCapabilities(provider: string): ProviderFeatures {
|
||||||
return this.capabilities[provider];
|
return this.capabilities[provider];
|
||||||
}
|
}
|
||||||
|
|
||||||
public get providers(): string[] {
|
public getLegacyCapabilities(provider: string): sqlops.DataProtocolServerCapabilities {
|
||||||
return Object.keys(this.capabilities);
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public get providers(): { [id: string]: ProviderFeatures } {
|
||||||
|
return this.capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,7 +128,7 @@ export class CapabilitiesTestService implements ICapabilitiesService {
|
|||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onCapabilitiesRegistered = new Emitter<string>();
|
private _onCapabilitiesRegistered = new Emitter<ProviderFeatures>();
|
||||||
public readonly onCapabilitiesRegistered = this._onCapabilitiesRegistered.event;
|
public readonly onCapabilitiesRegistered = this._onCapabilitiesRegistered.event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -684,7 +684,8 @@ export class Workbench implements IPartService {
|
|||||||
serviceCollection.set(INewDashboardTabDialogService, this.instantiationService.createInstance(NewDashboardTabDialogService));
|
serviceCollection.set(INewDashboardTabDialogService, this.instantiationService.createInstance(NewDashboardTabDialogService));
|
||||||
serviceCollection.set(ISqlOAuthService, this.instantiationService.createInstance(SqlOAuthService));
|
serviceCollection.set(ISqlOAuthService, this.instantiationService.createInstance(SqlOAuthService));
|
||||||
serviceCollection.set(sqlIClipboardService, this.instantiationService.createInstance(sqlClipboardService));
|
serviceCollection.set(sqlIClipboardService, this.instantiationService.createInstance(sqlClipboardService));
|
||||||
serviceCollection.set(ICapabilitiesService, this.instantiationService.createInstance(CapabilitiesService));
|
let capabilitiesService = this.instantiationService.createInstance(CapabilitiesService);
|
||||||
|
serviceCollection.set(ICapabilitiesService, capabilitiesService);
|
||||||
serviceCollection.set(IErrorMessageService, this.instantiationService.createInstance(ErrorMessageService));
|
serviceCollection.set(IErrorMessageService, this.instantiationService.createInstance(ErrorMessageService));
|
||||||
serviceCollection.set(IConnectionDialogService, this.instantiationService.createInstance(ConnectionDialogService));
|
serviceCollection.set(IConnectionDialogService, this.instantiationService.createInstance(ConnectionDialogService));
|
||||||
serviceCollection.set(IServerGroupController, this.instantiationService.createInstance(ServerGroupController));
|
serviceCollection.set(IServerGroupController, this.instantiationService.createInstance(ServerGroupController));
|
||||||
@@ -719,6 +720,7 @@ export class Workbench implements IPartService {
|
|||||||
this.toDispose.push(connectionManagementService);
|
this.toDispose.push(connectionManagementService);
|
||||||
this.toShutdown.push(connectionManagementService);
|
this.toShutdown.push(connectionManagementService);
|
||||||
this.toShutdown.push(accountManagementService);
|
this.toShutdown.push(accountManagementService);
|
||||||
|
this.toShutdown.push(capabilitiesService);
|
||||||
|
|
||||||
// Contributed services
|
// Contributed services
|
||||||
const contributedServices = getServices();
|
const contributedServices = getServices();
|
||||||
|
|||||||
Reference in New Issue
Block a user