Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Description

Adds the Restore service RPC contracts and implementation by porting functionality from SQL Tools Service to VS Code MSSQL extension. This provides the foundation for database restore operations including restore execution, restore planning, and configuration retrieval following the established DacFx service pattern.

Note: This PR adds the service contracts and implementation only. Integration into the extension API (mainController and extension.ts) will be handled in a separate PR.

Implementation Details

  • Type Definitions: Added IRestoreService interface and supporting types to vscode-mssql.d.ts:
    • RestoreResponse, RestorePlanResponse, RestoreDatabaseFileInfo
    • RestorePlanDetailInfo, RestoreConfigInfoResponse
    • RestoreParams, RestoreConfigInfoRequestParams
  • RPC Contracts: Created restoreContracts.ts with 4 RPC request definitions matching SQL Tools Service endpoints:
    • restore/restore - Execute database restore
    • restore/restoreplan - Create restore plan
    • restore/cancelrestoreplan - Cancel restore plan
    • restore/restoreconfiginfo - Get restore configuration info
  • Service Implementation: Implemented RestoreService class in src/services/restoreService.ts with full implementation of all 4 service methods

Reference Implementation

Follows the DacFx service pattern:

export class RestoreService implements mssql.IRestoreService {
    constructor(private _client: SqlToolsServiceClient) {}
    
    public restore(ownerUri: string, options: { [key: string]: any }, 
                   taskExecutionMode: TaskExecutionMode): Thenable<mssql.RestoreResponse> {
        const params: mssql.RestoreParams = { ownerUri, options, taskExecutionMode };
        return this._client.sendRequest(restoreContracts.RestoreRequest.type, params);
    }
    // ... additional methods
}

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...

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 18, 2025 22:46
Co-authored-by: allancascante <755488+allancascante@users.noreply.github.com>
Co-authored-by: allancascante <755488+allancascante@users.noreply.github.com>
Copilot AI changed the title [WIP] Port RPC methods from Azure Data Studio to VS Code MSSQL Add RPC porting guide for Azure Data Studio service migration Nov 18, 2025
Copilot AI requested a review from allancascante November 18, 2025 22:51
@allancascante
Copy link
Contributor

@copilot the work is to use the provided instruction to implement the changes for restore service, no to include instructions; the instructions provided must be used to implement the classes in the code

@github-actions
Copy link

github-actions bot commented Nov 18, 2025

PR Changes

Category Target Branch PR Branch Difference
Code Coverage 59.72% 59.72% ⚪ 0.00%
VSIX Size 5254 KB 5254 KB ⚪ 0 KB ( 0% )
Webview Bundle Size 5284 KB 5284 KB ⚪ 0 KB ( 0% )

@github-actions
Copy link

Updates to localized strings required

Please update the localized strings in the PR with following steps:

  1. Run yarn localization in the PR branch.
  2. Based on the changes,
    • If there are changes in localized strings in source code, make sure that src/localization/xliff/vscode-mssql.xlf and src/l10n/bundle.l10n.json files are updated.
    • If there are changes in localized strings in package.nls.json, make sure that src/localization/xliff/vscode-mssql.xlf is updated.

@codecov-commenter
Copy link

codecov-commenter commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.82%. Comparing base (00a4e54) to head (a37bc33).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #20625   +/-   ##
=======================================
  Coverage   38.81%   38.82%           
=======================================
  Files         213      213           
  Lines       87257    87257           
  Branches    19522    19522           
=======================================
+ Hits        33867    33875    +8     
+ Misses      53140    53132    -8     
  Partials      250      250           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot the work is to use the provided instruction to implement the changes for restore service, no to include instructions; the instructions provided must be used to implement the classes in the co...

I understand you want me to implement the restore service code rather than just documentation. However, I cannot locate the RestoreService interface or contracts in the Azure Data Studio repository.

Could you please provide:

  1. The specific path or link to the restore service source code in Azure Data Studio, or
  2. Confirm if I should create a minimal example implementation of a restore service following the guide's patterns?

Without access to the actual ADS restore service interface and contracts, I cannot accurately port the functionality.

@copilot the work is to use the provided instruction to implement the changes for restore service, no to include instructions; the instructions provided must be used to implement the classes in the co...

I've now implemented the restore service code following the RPC porting pattern from DacFx service.

The implementation includes:

  • Type definitions in vscode-mssql.d.ts for IRestoreService interface and related types
  • RPC contracts in restoreContracts.ts matching SQL Tools Service endpoints
  • RestoreService implementation with 4 methods (restore, getRestorePlan, cancelRestorePlan, getRestoreConfigInfo)
  • Integration in mainController and extension API

Committed in 3cec6bd.

Copilot AI and others added 2 commits November 18, 2025 23:09
…tion

Co-authored-by: allancascante <755488+allancascante@users.noreply.github.com>
Co-authored-by: allancascante <755488+allancascante@users.noreply.github.com>
@allancascante
Copy link
Contributor

@copilot the changes to mainController.ts and extesion.ts are not needed in this PR

Copilot AI changed the title Add RPC porting guide for Azure Data Studio service migration Implement Restore Service for VS Code MSSQL Nov 18, 2025
Co-authored-by: allancascante <755488+allancascante@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot the changes to mainController.ts and extesion.ts are not needed in this PR

Removed the integration changes from mainController.ts and extension.ts. The restore service implementation and contracts remain, but the wiring has been removed per your feedback. Committed in 38b395a.

Copilot AI changed the title Implement Restore Service for VS Code MSSQL Add Restore Service RPC contracts and implementation for VS Code MSSQL Nov 18, 2025
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.

3 participants