mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add findNodes Object Explorer API (#916)
This commit is contained in:
@@ -68,6 +68,8 @@ export interface IObjectExplorerService {
|
|||||||
|
|
||||||
getServerTreeView(): ServerTreeView;
|
getServerTreeView(): ServerTreeView;
|
||||||
|
|
||||||
|
findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames?: string[]): Thenable<sqlops.NodeInfo[]>;
|
||||||
|
|
||||||
getActiveConnectionNodes(): TreeNode[];
|
getActiveConnectionNodes(): TreeNode[];
|
||||||
|
|
||||||
getTreeNode(connectionId: string, nodePath: string): Thenable<TreeNode>;
|
getTreeNode(connectionId: string, nodePath: string): Thenable<TreeNode>;
|
||||||
@@ -447,6 +449,24 @@ export class ObjectExplorerService implements IObjectExplorerService {
|
|||||||
return this._serverTreeView;
|
return this._serverTreeView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames?: string[]): Thenable<sqlops.NodeInfo[]> {
|
||||||
|
let rootNode = this._activeObjectExplorerNodes[connectionId];
|
||||||
|
if (!rootNode) {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
let sessionId = rootNode.session.sessionId;
|
||||||
|
return this._providers[this._sessions[sessionId].connection.providerName].findNodes({
|
||||||
|
type: type,
|
||||||
|
name: name,
|
||||||
|
schema: schema,
|
||||||
|
database: database,
|
||||||
|
parentObjectNames: parentObjectNames,
|
||||||
|
sessionId: sessionId
|
||||||
|
}).then(response => {
|
||||||
|
return response.nodes;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public getActiveConnectionNodes(): TreeNode[] {
|
public getActiveConnectionNodes(): TreeNode[] {
|
||||||
return Object.values(this._activeObjectExplorerNodes);
|
return Object.values(this._activeObjectExplorerNodes);
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/sql/sqlops.d.ts
vendored
27
src/sql/sqlops.d.ts
vendored
@@ -129,6 +129,18 @@ declare module 'sqlops' {
|
|||||||
*/
|
*/
|
||||||
export function getActiveConnectionNodes(): Thenable<ObjectExplorerNode[]>;
|
export function getActiveConnectionNodes(): Thenable<ObjectExplorerNode[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find Object Explorer nodes that match the given information
|
||||||
|
* @param {string} connectionId The id of the connection that the node exists on
|
||||||
|
* @param {string} type The type of the object to retrieve
|
||||||
|
* @param {string} schema The schema of the object, if applicable
|
||||||
|
* @param {string} name The name of the object
|
||||||
|
* @param {string} database The database the object exists under, if applicable
|
||||||
|
* @param {string[]} parentObjectNames A list of names of parent objects in the tree, ordered from highest to lowest level
|
||||||
|
* (for example when searching for a table's column, provide the name of its parent table for this argument)
|
||||||
|
*/
|
||||||
|
export function findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<ObjectExplorerNode[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for representing and interacting with items in Object Explorer
|
* Interface for representing and interacting with items in Object Explorer
|
||||||
*/
|
*/
|
||||||
@@ -942,6 +954,15 @@ declare module 'sqlops' {
|
|||||||
nodePath: string;
|
nodePath: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface FindNodesInfo {
|
||||||
|
sessionId: string;
|
||||||
|
type: string;
|
||||||
|
schema: string;
|
||||||
|
name: string;
|
||||||
|
database: string;
|
||||||
|
parentObjectNames: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface ObjectExplorerCloseSessionInfo {
|
export interface ObjectExplorerCloseSessionInfo {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
}
|
}
|
||||||
@@ -951,6 +972,10 @@ declare module 'sqlops' {
|
|||||||
success: boolean;
|
success: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ObjectExplorerFindNodesResponse {
|
||||||
|
nodes: NodeInfo[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface ObjectExplorerProvider extends DataProvider {
|
export interface ObjectExplorerProvider extends DataProvider {
|
||||||
createNewSession(connInfo: ConnectionInfo): Thenable<ObjectExplorerSessionResponse>;
|
createNewSession(connInfo: ConnectionInfo): Thenable<ObjectExplorerSessionResponse>;
|
||||||
|
|
||||||
@@ -960,6 +985,8 @@ declare module 'sqlops' {
|
|||||||
|
|
||||||
closeSession(closeSessionInfo: ObjectExplorerCloseSessionInfo): Thenable<ObjectExplorerCloseSessionResponse>;
|
closeSession(closeSessionInfo: ObjectExplorerCloseSessionInfo): Thenable<ObjectExplorerCloseSessionResponse>;
|
||||||
|
|
||||||
|
findNodes(findNodesInfo: FindNodesInfo): Thenable<ObjectExplorerFindNodesResponse>;
|
||||||
|
|
||||||
registerOnSessionCreated(handler: (response: ObjectExplorerSession) => any);
|
registerOnSessionCreated(handler: (response: ObjectExplorerSession) => any);
|
||||||
|
|
||||||
registerOnExpandCompleted(handler: (response: ObjectExplorerExpandInfo) => any);
|
registerOnExpandCompleted(handler: (response: ObjectExplorerExpandInfo) => any);
|
||||||
|
|||||||
@@ -299,6 +299,10 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
|||||||
return this._resolveProvider<sqlops.ObjectExplorerProvider>(handle).closeSession(closeSessionInfo);
|
return this._resolveProvider<sqlops.ObjectExplorerProvider>(handle).closeSession(closeSessionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public $findNodes(handle: number, findNodesInfo: sqlops.FindNodesInfo): Thenable<sqlops.ObjectExplorerFindNodesResponse> {
|
||||||
|
return this._resolveProvider<sqlops.ObjectExplorerProvider>(handle).findNodes(findNodesInfo);
|
||||||
|
}
|
||||||
|
|
||||||
public $onObjectExplorerSessionCreated(handle: number, response: sqlops.ObjectExplorerSession): void {
|
public $onObjectExplorerSessionCreated(handle: number, response: sqlops.ObjectExplorerSession): void {
|
||||||
this._proxy.$onObjectExplorerSessionCreated(handle, response);
|
this._proxy.$onObjectExplorerSessionCreated(handle, response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ export class ExtHostObjectExplorer implements ExtHostObjectExplorerShape {
|
|||||||
public $getActiveConnectionNodes(): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
public $getActiveConnectionNodes(): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||||
return this._proxy.$getActiveConnectionNodes().then(results => results.map(result => new ExtHostObjectExplorerNode(result.nodeInfo, result.connectionId, this._proxy)));
|
return this._proxy.$getActiveConnectionNodes().then(results => results.map(result => new ExtHostObjectExplorerNode(result.nodeInfo, result.connectionId, this._proxy)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public $findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||||
|
return this._proxy.$findNodes(connectionId, type, schema, name, database, parentObjectNames).then(results => results.map(result => new ExtHostObjectExplorerNode(result, connectionId, this._proxy)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExtHostObjectExplorerNode implements sqlops.objectexplorer.ObjectExplorerNode {
|
class ExtHostObjectExplorerNode implements sqlops.objectexplorer.ObjectExplorerNode {
|
||||||
|
|||||||
@@ -232,6 +232,9 @@ export class MainThreadDataProtocol implements MainThreadDataProtocolShape {
|
|||||||
},
|
},
|
||||||
closeSession(closeSessionInfo: sqlops.ObjectExplorerCloseSessionInfo): Thenable<sqlops.ObjectExplorerCloseSessionResponse> {
|
closeSession(closeSessionInfo: sqlops.ObjectExplorerCloseSessionInfo): Thenable<sqlops.ObjectExplorerCloseSessionResponse> {
|
||||||
return self._proxy.$closeObjectExplorerSession(handle, closeSessionInfo);
|
return self._proxy.$closeObjectExplorerSession(handle, closeSessionInfo);
|
||||||
|
},
|
||||||
|
findNodes(findNodesInfo: sqlops.FindNodesInfo): Thenable<sqlops.ObjectExplorerFindNodesResponse> {
|
||||||
|
return self._proxy.$findNodes(handle, findNodesInfo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -69,4 +69,8 @@ export class MainThreadObjectExplorer implements MainThreadObjectExplorerShape {
|
|||||||
public $isExpanded(connectionId: string, nodePath: string): Thenable<boolean> {
|
public $isExpanded(connectionId: string, nodePath: string): Thenable<boolean> {
|
||||||
return this._objectExplorerService.getTreeNode(connectionId, nodePath).then(treeNode => treeNode.isExpanded());
|
return this._objectExplorerService.getTreeNode(connectionId, nodePath).then(treeNode => treeNode.isExpanded());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public $findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<sqlops.NodeInfo[]> {
|
||||||
|
return this._objectExplorerService.findNodes(connectionId, type, schema, name, database, parentObjectNames);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ export function createApiFactory(
|
|||||||
},
|
},
|
||||||
getActiveConnectionNodes(): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
getActiveConnectionNodes(): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||||
return extHostObjectExplorer.$getActiveConnectionNodes();
|
return extHostObjectExplorer.$getActiveConnectionNodes();
|
||||||
|
},
|
||||||
|
findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||||
|
return extHostObjectExplorer.$findNodes(connectionId, type, schema, name, database, parentObjectNames);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ export abstract class ExtHostDataProtocolShape {
|
|||||||
|
|
||||||
$closeObjectExplorerSession(handle: number, closeSessionInfo: sqlops.ObjectExplorerCloseSessionInfo): Thenable<sqlops.ObjectExplorerCloseSessionResponse> { throw ni(); }
|
$closeObjectExplorerSession(handle: number, closeSessionInfo: sqlops.ObjectExplorerCloseSessionInfo): Thenable<sqlops.ObjectExplorerCloseSessionResponse> { throw ni(); }
|
||||||
|
|
||||||
|
$findNodes(handle: number, findNodesInfo: sqlops.FindNodesInfo): Thenable<sqlops.ObjectExplorerFindNodesResponse> { throw ni(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tasks
|
* Tasks
|
||||||
*/
|
*/
|
||||||
@@ -498,4 +500,5 @@ export interface MainThreadObjectExplorerShape extends IDisposable {
|
|||||||
$setSelected(connectionId: string, nodePath: string, selected: boolean, clearOtherSelections?: boolean): Thenable<void>;
|
$setSelected(connectionId: string, nodePath: string, selected: boolean, clearOtherSelections?: boolean): Thenable<void>;
|
||||||
$getChildren(connectionId: string, nodePath: string): Thenable<sqlops.NodeInfo[]>;
|
$getChildren(connectionId: string, nodePath: string): Thenable<sqlops.NodeInfo[]>;
|
||||||
$isExpanded(connectionId: string, nodePath: string): Thenable<boolean>;
|
$isExpanded(connectionId: string, nodePath: string): Thenable<boolean>;
|
||||||
|
$findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<sqlops.NodeInfo[]>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,4 +33,8 @@ export class ObjectExplorerProviderTestService implements sqlops.ObjectExplorerP
|
|||||||
public registerOnExpandCompleted(handler: (response: sqlops.ObjectExplorerExpandInfo) => any): void {
|
public registerOnExpandCompleted(handler: (response: sqlops.ObjectExplorerExpandInfo) => any): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public findNodes(findNodesInfo: sqlops.FindNodesInfo): Thenable<sqlops.ObjectExplorerFindNodesResponse> {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user