Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Description

Ports the ObjectManagementService RPC interface from Azure Data Studio to enable database object management operations (backup, restore, attach/detach, credentials, etc.) in VS Code MSSQL extension.

Implementation

Type Definitions (typings/vscode-mssql.d.ts)

  • IObjectManagementService interface with 17 methods for object/database operations
  • ObjectManagement namespace containing NodeType enum, SqlObject, ObjectViewInfo, SearchResultItem
  • Supporting types: BackupInfo, DatabaseFileData, BackupResponse, CredentialInfo

RPC Contracts (src/models/contracts/objectManagement/objectManagementContracts.ts)

  • 17 RequestType definitions matching Azure Data Studio's RPC method names
  • Request/response parameter interfaces for type safety

Service Implementation (src/services/objectManagementService.ts)

  • Implements IObjectManagementService using SqlToolsServiceClient
  • Follows established DacFxService pattern with async/await RPC calls

Methods Implemented

Object operations: initializeView, save, script, disposeView, rename, drop, search
Database operations: detachDatabase, attachDatabases, backupDatabase, dropDatabase
Helpers: getDataFolder, getBackupFolder, getAssociatedFiles, purgeQueryStoreData, createCredential, getCredentialNames

Note: Service is not yet wired into mainController.ts or extension.ts API—ready for integration when needed.

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

Original prompt

Agent Instructions: Porting RPC Methods from Azure Data Studio to VS Code MSSQL

Overview

This guide enables an AI agent to port RPC-based functionality from Azure Data Studio (ADS) to the VS Code MSSQL extension following established patterns.

Prerequisites

Input Required

The agent needs:

  1. Functionality Name: The feature to port (e.g., "Profiler", "QueryPlan", "Backup", "Restore")
  2. ADS Source Path: Path in ADS repo where the functionality exists (e.g., src/sql/workbench/services/profiler/)

Step-by-Step Porting Process

Phase 1: Discovery and Analysis in Azure Data Studio Repo

Step 1.1: Locate the Service Interface

Search Pattern: I{FunctionalityName}Service interface
Typical Location: src/sql/workbench/services/{functionality}/common/{functionality}Service.ts

Agent Actions:

  1. Find the interface definition (e.g., IProfilerService)
  2. Extract all method signatures
  3. Note the return types (Promise types are important)
  4. Document any event emitters or notifications

Example Interface to Extract:

export interface IProfilerService {
    createSession(ownerUri: string, sessionName: string, template: ProfilerSessionTemplate): Promise<boolean>;
    startSession(ownerUri: string, sessionName: string): Promise<boolean>;
    stopSession(ownerUri: string, sessionName: string): Promise<boolean>;
    // ... more methods
}

Step 1.2: Locate Request/Response Contracts

Search Pattern: Request and Response type definitions
Typical Location: src/sql/workbench/services/{functionality}/common/{functionality}Contracts.ts or similar

Agent Actions:

  1. Find all *Request and *Response types
  2. Find all *Params types
  3. Extract enums used by the functionality
  4. Note any notification types (e.g., *NotificationParams)

Example Contracts to Extract:

export interface CreateSessionRequest {
    ownerUri: string;
    sessionName: string;
    template: ProfilerSessionTemplate;
}

export interface CreateSessionResponse {
    succeeded: boolean;
    errorMessage?: string;
}

Step 1.3: Locate RPC Request Definitions

Search Pattern: RequestType and NotificationType definitions
Typical Location: Same file as contracts or in a separate *Contracts.ts file

Agent Actions:

  1. Find all RequestType<TParams, TResult> definitions
  2. Find all NotificationType<TParams> definitions
  3. Extract the RPC method names (string constants)
  4. Map each RequestType to its params and response types

Example RPC Definitions to Extract:

export namespace CreateXEventSessionRequest {
    export const type = new RequestType<CreateXEventSessionParams, CreateXEventSessionResponse, void, void>('profiler/createsession');
}

export namespace ProfilerEventsAvailableNotification {
    export const type = new NotificationType<ProfilerEventsAvailableParams, void>('profiler/eventsavailable');
}

Step 1.4: Locate Supporting Types

Agent Actions:

  1. Find all interface definitions used by the contracts (e.g., ProfilerSessionTemplate, ProfilerEvent)
  2. Find all enums (e.g., ProfilingSessionType)
  3. Extract complete type definitions with all properties
  4. Note any default values or constants

Phase 2: Generate VS Code MSSQL Extension Files

Step 2.1: Generate vscode-mssql.d.ts Types

File Location: mssql/typings/vscode-mssql.d.ts

Agent Instructions:

  1. Open the existing vscode-mssql.d.ts file
  2. Locate the declare module "vscode-mssql" section
  3. Add the service interface after existing service interfaces (e.g., after IDacFxService)
  4. Add all supporting types in the following order:
    • Enums first
    • Simple interfaces
    • Complex interfaces that depend on simple ones
    • The service interface last

Template for Service Interface:

export interface I{FunctionalityName}Service {
    // Method signatures from ADS IService interface
    {methodName}({params}): Promise<{ReturnType}>;
    
    // Notification registration methods
    registerOn{NotificationName}(handler: (params: {NotificationParams}) => void): void;
}

Template for Types:

// Enums
export enum {EnumName} {
    {Value1} = {Number},
    {Value2} = {Number}
}

// Parameter interfaces
export interface {FunctionalityName}{Operation}Params {
    {property}: {type};
    // ... more properties
}

// Response interfaces
export interface {FunctionalityName}{Operation}Response {
    succeeded: boolean;
    errorMessage?: string;
    // ... more properties
}

// Event/Notification interfaces
export interface {FunctionalityName}{Event}Params {
    // ... event properties
}

Important Notes:

  • Remove ADS-specific imports (like import * as azdata)
  • Convert azdata types to plain TypeScript types
  • Use `v...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Port RPC methods from Azure Data Studio to VS Code MSSQL Port ObjectManagementService RPC methods from Azure Data Studio Nov 18, 2025
Copilot AI requested a review from allancascante November 18, 2025 23:48
Copilot finished work on behalf of allancascante November 18, 2025 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants