new drop object request (#22387)

* simplify drop object requests

* update sts

* pr comments
This commit is contained in:
Alan Ren
2023-03-21 10:51:55 -07:00
committed by GitHub
parent ffc7f05c10
commit 21f271671d
5 changed files with 40 additions and 86 deletions

View File

@@ -1,6 +1,6 @@
{
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
"version": "4.6.0.13",
"version": "4.6.0.14",
"downloadFileNames": {
"Windows_86": "win-x86-net7.0.zip",
"Windows_64": "win-x64-net7.0.zip",

View File

@@ -1539,15 +1539,6 @@ export namespace UpdateLoginRequest {
export const type = new RequestType<UpdateLoginRequestParams, void, void, void>('objectManagement/updateLogin');
}
export interface DeleteLoginRequestParams {
connectionUri: string;
name: string;
}
export namespace DeleteLoginRequest {
export const type = new RequestType<DeleteLoginRequestParams, void, void, void>('objectManagement/deleteLogin');
}
export interface DisposeLoginViewRequestParams {
contextId: string;
}
@@ -1586,16 +1577,6 @@ export namespace UpdateUserRequest {
export const type = new RequestType<UpdateUserRequestParams, void, void, void>('objectManagement/updateUser');
}
export interface DeleteUserRequestParams {
connectionUri: string;
database: string;
name: string;
}
export namespace DeleteUserRequest {
export const type = new RequestType<DeleteUserRequestParams, void, void, void>('objectManagement/deleteUser');
}
export interface DisposeUserViewRequestParams {
contextId: string;
}
@@ -1614,4 +1595,12 @@ export namespace RenameObjectRequest {
export const type = new RequestType<RenameObjectRequestParams, void, void, void>('objectManagement/rename');
}
export interface DropObjectRequestParams {
connectionUri: string;
objectUrn: string;
}
export namespace DropObjectRequest {
export const type = new RequestType<DropObjectRequestParams, void, void, void>('objectManagement/drop');
}
// ------------------------------- < Object Management > ------------------------------------

View File

@@ -1191,12 +1191,6 @@ declare module 'mssql' {
* @param login The login information.
*/
updateLogin(contextId: string, login: ObjectManagement.Login): Thenable<void>;
/**
* Delete a login.
* @param connectionUri The URI of the server connection.
* @param name Name of the login.
*/
deleteLogin(connectionUri: string, name: string): Thenable<void>;
/**
* Dispose the login view.
* @param contextId The id of the view.
@@ -1218,18 +1212,11 @@ declare module 'mssql' {
*/
createUser(contextId: string, user: ObjectManagement.User): Thenable<void>;
/**
* Create a login.
* Update a user.
* @param contextId Id of the view.
* @param user The user information.
*/
updateUser(contextId: string, user: ObjectManagement.User): Thenable<void>;
/**
* Create a login.
* @param connectionUri The URI of the server connection.
* @param database Name of the database.
* @param name Name of the user.
*/
deleteUser(connectionUri: string, database: string, name: string): Thenable<void>;
/**
* Dispose the user view.
* @param contextId The id of the view.
@@ -1238,10 +1225,16 @@ declare module 'mssql' {
/**
* Rename an object.
* @param connectionUri The URI of the server connection.
* @param objectUrn Urn of the object to be renamed. More information: https://learn.microsoft.com/en-us/sql/relational-databases/server-management-objects-smo/overview-smo.
* @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>;
/**
* Drop an object.
* @param connectionUri The URI of the server connection.
* @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>;
}
// Object Management - End.
}

View File

@@ -139,16 +139,7 @@ async function handleDeleteObjectCommand(context: azdata.ObjectExplorerContext,
operation: async (operation) => {
try {
const startTime = Date.now();
switch (context.nodeInfo.nodeType) {
case NodeType.Login:
await service.deleteLogin(connectionUri, context.nodeInfo.label);
break;
case NodeType.User:
await service.deleteUser(connectionUri, context.connectionProfile.databaseName, context.nodeInfo.label);
break;
default:
return;
}
await service.drop(connectionUri, context.nodeInfo.metadata.urn);
TelemetryReporter.sendTelemetryEvent(TelemetryActions.DeleteObject, {
objectType: context.nodeInfo.nodeType
}, {

View File

@@ -39,7 +39,7 @@ export class ObjectManagementService implements IObjectManagementService {
},
e => {
this.client.logFailedRequest(contracts.InitializeLoginViewRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
@@ -49,7 +49,7 @@ export class ObjectManagementService implements IObjectManagementService {
r => { },
e => {
this.client.logFailedRequest(contracts.CreateLoginRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
@@ -59,17 +59,7 @@ export class ObjectManagementService implements IObjectManagementService {
r => { },
e => {
this.client.logFailedRequest(contracts.UpdateLoginRequest.type, e);
return Promise.reject(new Error(e.message));
}
);
}
deleteLogin(connectionUri: string, name: string): Thenable<void> {
const params: contracts.DeleteLoginRequestParams = { connectionUri, name };
return this.client.sendRequest(contracts.DeleteLoginRequest.type, params).then(
r => { },
e => {
this.client.logFailedRequest(contracts.DeleteLoginRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
@@ -79,11 +69,10 @@ export class ObjectManagementService implements IObjectManagementService {
r => { },
e => {
this.client.logFailedRequest(contracts.DisposeLoginViewRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
initializeUserView(connectionUri: string, database: string, contextId: string, isNewObject: boolean, name: string | undefined): Thenable<ObjectManagement.UserViewInfo> {
const params: contracts.InitializeUserViewRequestParams = { connectionUri, database, contextId, isNewObject, name };
return this.client.sendRequest(contracts.InitializeUserViewRequest.type, params).then(
@@ -92,7 +81,7 @@ export class ObjectManagementService implements IObjectManagementService {
},
e => {
this.client.logFailedRequest(contracts.InitializeUserViewRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
@@ -102,7 +91,7 @@ export class ObjectManagementService implements IObjectManagementService {
r => { },
e => {
this.client.logFailedRequest(contracts.CreateUserRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
@@ -112,17 +101,7 @@ export class ObjectManagementService implements IObjectManagementService {
r => { },
e => {
this.client.logFailedRequest(contracts.UpdateUserRequest.type, e);
return Promise.reject(new Error(e.message));
}
);
}
deleteUser(connectionUri: string, database: string, name: string): Thenable<void> {
const params: contracts.DeleteUserRequestParams = { connectionUri, database, name };
return this.client.sendRequest(contracts.DeleteUserRequest.type, params).then(
r => { },
e => {
this.client.logFailedRequest(contracts.DeleteUserRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
@@ -132,7 +111,7 @@ export class ObjectManagementService implements IObjectManagementService {
r => { },
e => {
this.client.logFailedRequest(contracts.DisposeUserViewRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
@@ -142,7 +121,17 @@ export class ObjectManagementService implements IObjectManagementService {
r => { },
e => {
this.client.logFailedRequest(contracts.RenameObjectRequest.type, e);
return Promise.reject(new Error(e.message));
return Promise.reject(e);
}
);
}
drop(connectionUri: string, objectUrn: string): Thenable<void> {
const params: contracts.DropObjectRequestParams = { connectionUri, objectUrn };
return this.client.sendRequest(contracts.DropObjectRequest.type, params).then(
r => { },
e => {
this.client.logFailedRequest(contracts.DropObjectRequest.type, e);
return Promise.reject(e);
}
);
}
@@ -226,13 +215,6 @@ export class TestObjectManagementService implements IObjectManagementService {
}, 3000);
});
}
async deleteLogin(connectionUri: string, name: string): Promise<void> {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 3000);
});
}
async disposeLoginView(contextId: string): Promise<void> {
}
async initializeUserView(connectionUri: string, database: string, contextId: string, isNewObject: boolean, name: string): Promise<ObjectManagement.UserViewInfo> {
@@ -297,15 +279,14 @@ export class TestObjectManagementService implements IObjectManagementService {
async updateUser(contextId: string, login: ObjectManagement.User): Promise<void> {
return this.delayAndResolve();
}
async deleteUser(connectionUri: string, database: string, name: string): Promise<void> {
return this.delayAndResolve();
}
async disposeUserView(contextId: string): Promise<void> {
}
async rename(connectionUri: string, objectUrn: string, newName: string): Promise<void> {
return this.delayAndResolve();
}
async drop(connectionUri: string, objectUrn: string): Promise<void> {
return this.delayAndResolve();
}
private delayAndResolve(): Promise<void> {
return new Promise((resolve, reject) => {
setTimeout(() => {