simplify object management feature APIs (#22781)

This commit is contained in:
Alan Ren
2023-04-19 19:26:29 -07:00
committed by GitHub
parent 34d092a7dd
commit decbe8dded
14 changed files with 413 additions and 578 deletions

View File

@@ -875,6 +875,19 @@ declare module 'mssql' {
// Object Management - Begin.
export namespace ObjectManagement {
/**
* Object types.
*/
export const enum NodeType {
Column = "Column",
Database = "Database",
ServerLevelLogin = "ServerLevelLogin",
Table = "Table",
User = "User",
View = "View"
}
/**
* Base interface for all the objects.
*/
@@ -963,7 +976,7 @@ declare module 'mssql' {
/**
* The authentication types.
*/
export enum AuthenticationType {
export const enum AuthenticationType {
Windows = 'Windows',
Sql = 'Sql',
AzureActiveDirectory = 'AAD'
@@ -1086,7 +1099,7 @@ declare module 'mssql' {
/**
* User types.
*/
export enum UserType {
export const enum UserType {
/**
* User with a server level login.
*/
@@ -1188,81 +1201,48 @@ declare module 'mssql' {
export interface IObjectManagementService {
/**
* Initialize the login view and return the information to render the view.
* Initialize the object view and return the information to render the view.
* @param contextId The context id of the view, generated by the extension and will be used in subsequent save/script/dispose operations.
* @param objectType The object type.
* @param connectionUri The original connection's URI.
* @param contextId The context id of the view, generated by the extension and will be used in subsequent create/update/dispose operations.
* @param isNewObject Whether the view is for creating a new login object.
* @param name Name of the login. Only applicable when isNewObject is false.
* @param database The target database.
* @param isNewObject Whether the view is for creating a new object.
* @param parentUrn The parent object's URN.
* @param objectUrn The object's URN.
*/
initializeLoginView(connectionUri: string, contextId: string, isNewObject: boolean, name: string | undefined): Thenable<ObjectManagement.LoginViewInfo>;
initializeView(contextId: string, objectType: ObjectManagement.NodeType, connectionUri: string, database: string, isNewObject: boolean, parentUrn: string, objectUrn: string): Thenable<ObjectManagement.ObjectViewInfo<ObjectManagement.SqlObject>>;
/**
* Create a login.
* @param contextId The login view's context id.
* @param login The login information.
* Save an object.
* @param contextId The object view's context id.
* @param object The object to be saved.
*/
createLogin(contextId: string, login: ObjectManagement.Login): Thenable<void>;
save(contextId: string, object: ObjectManagement.SqlObject): Thenable<void>;
/**
* Update a login.
* @param contextId The login view's context id.
* @param login The login information.
* Script an object.
* @param contextId The object view's context id.
* @param object The object to be scripted.
*/
updateLogin(contextId: string, login: ObjectManagement.Login): Thenable<void>;
script(contextId: string, object: ObjectManagement.SqlObject): Thenable<string>;
/**
* Script a login.
* @param contextId The login view's context id.
* @param login The login information.
*/
scriptLogin(contextId: string, login: ObjectManagement.Login): Thenable<string>;
/**
* Dispose the login view.
* Dispose a view.
* @param contextId The id of the view.
*/
disposeLoginView(contextId: string): Thenable<void>;
/**
* Initialize the user view and return the information to render the view.
* @param connectionUri The original connection's URI.
* @param database Name of the database.
* @param contextId The id of the view, generated by the extension and will be used in subsequent create/update/dispose operations.
* @param isNewObject Whether the view is for creating a new user object.
* @param name Name of the user. Only applicable when isNewObject is false.
*/
initializeUserView(connectionUri: string, database: string, contextId: string, isNewObject: boolean, name: string | undefined): Thenable<ObjectManagement.UserViewInfo>;
/**
* Create a user.
* @param contextId Id of the view.
* @param user The user information.
*/
createUser(contextId: string, user: ObjectManagement.User): Thenable<void>;
/**
* Update a user.
* @param contextId Id of the view.
* @param user The user information.
*/
updateUser(contextId: string, user: ObjectManagement.User): Thenable<void>;
/**
* Script a user.
* @param contextId Id of the view.
* @param user The user information.
*/
scriptUser(contextId: string, user: ObjectManagement.User): Thenable<string>;
/**
* Dispose the user view.
* @param contextId The id of the view.
*/
disposeUserView(contextId: string): Thenable<void>;
disposeView(contextId: string): Thenable<void>;
/**
* Rename an object.
* @param connectionUri The URI of the server connection.
* @param objectType The object type.
* @param objectUrn SMO Urn of the object to be renamed. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo
* @param newName The new name of the object.
*/
rename(connectionUri: string, objectUrn: string, newName: string): Thenable<void>;
rename(connectionUri: string, objectType: ObjectManagement.NodeType, objectUrn: string, newName: string): Thenable<void>;
/**
* Drop an object.
* @param connectionUri The URI of the server connection.
* @param objectType The object type.
* @param objectUrn SMO Urn of the object to be dropped. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo
*/
drop(connectionUri: string, objectUrn: string): Thenable<void>;
drop(connectionUri: string, objectType: ObjectManagement.NodeType, objectUrn: string): Thenable<void>;
}
// Object Management - End.
}