Skip to content

DAB views and stored proc#22257

Open
aasimkhan30 wants to merge 10 commits into
mainfrom
aasim/fix/dabViewsAndStoredProc
Open

DAB views and stored proc#22257
aasimkhan30 wants to merge 10 commits into
mainfrom
aasim/fix/dabViewsAndStoredProc

Conversation

@aasimkhan30
Copy link
Copy Markdown
Contributor

Description

  1. Added DAB support for stored procedures and views.

Stored Procedure:

Grid Advanced Settings
image image

Views:

Grid Advanced Settings
image image
  1. Added support for tables without primary keys, allowing users to manually specify key columns.
image
  1. Improved permissions modeling for tables.

Tables can now grant different CRUD operations to anonymous and authenticated roles.
image

Column-level permissions can be expanded and configured when needed. They are collapsed by default.
image

  1. Added per-entity API exposure controls.
    Each entity can be included or excluded per API type, and API exposure plus permissions are now visible directly in the main grid.
image
  1. Removed the "All" API type option and added counters per API type.
Before After
image image

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

…ission management

- Updated `schemaDesignerRpcHandlers.ts` to include new methods for managing entity surface settings and permissions.
- Introduced `createEntityWithSurfaceEnabled` to handle enabling/disabling API types for entities.
- Added `validatePermissionConfig` to validate permissions for entities, ensuring correct role and action configurations.
- Enhanced `applyDabToolChange` to support new changes related to entity surface and permissions.
- Updated tests in `dabConfigFileBuilder.test.ts`, `dabSharedInterfaces.test.ts`, `dabTool.test.ts`, and `dabToolManifest.test.ts` to cover new functionalities and ensure correctness.
- Adjusted existing tests to reflect changes in entity configurations and expected outputs.
- Added `fieldAccess` to `EntityPermissionConfig` to allow role and action specific field access.
- Implemented normalization of permission field access in `normalizePermissionFieldAccess`.
- Updated `getEntityPermissions` to include normalized field access for each role.
- Introduced `PermissionColumnAccessGrid` component for managing column access per role in the UI.
- Enhanced the `DabEntitySettingsDialog` to support displaying and editing column access settings.
- Updated tests to verify the new field access functionality and ensure correct emission of permissions.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the Schema Designer “Data API Builder (DAB)” experience to support additional SQL object types (views + stored procedures), adds a “logical key” workflow for keyless tables/views, and upgrades per-entity exposure/permission modeling (including MCP surface controls), with corresponding UI and Copilot tool schema updates.

Changes:

  • Add metadata discovery + source-object modeling for DAB views and stored procedures (including columns/parameters).
  • Introduce per-surface exposure controls (REST/GraphQL/MCP), richer permission modeling, and logical-key support for entities without primary keys.
  • Update Schema Designer DAB UI (filters, pills/counters, grouping, settings entry points) and extend Copilot DAB tool schema + tests.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
localization/xliff/vscode-mssql.xlf Localization entries added for new DAB UI strings (ignored per guidelines).
extensions/mssql/test/unit/metadataService.test.ts Adds unit coverage for new DAB metadata helper queries/parsing.
extensions/mssql/test/unit/dabToolManifest.test.ts Validates updated Copilot DAB tool schema (new change types and settings).
extensions/mssql/test/unit/dabTool.test.ts Updates Copilot DAB tool behavior tests for new exposure/PK/keyless logic.
extensions/mssql/test/unit/dab/dabSharedInterfaces.test.ts Updates shared DAB defaults/permissions expectations.
extensions/mssql/test/unit/dab/dabConfigFileBuilder.test.ts Updates config builder tests for fields metadata + MCP/permissions output.
extensions/mssql/src/webviews/pages/SchemaDesigner/schemaDesignerRpcHandlers.ts Adds new change handlers (surface, permissions, metadata, MCP) + config normalization tweaks.
extensions/mssql/src/webviews/pages/SchemaDesigner/dab/dabToolbar.tsx Adds per-API counters and richer filtering (object type, exposed-via, auth mode).
extensions/mssql/src/webviews/pages/SchemaDesigner/dab/dabPills.tsx Introduces pill/count helpers for consistent UI styling.
extensions/mssql/src/webviews/pages/SchemaDesigner/dab/dabPills.css Adds pill/count CSS styling.
extensions/mssql/src/webviews/pages/SchemaDesigner/dab/dabEntityTable.tsx Major grid refresh: supports views/procs, grouping, pills, parameters, logical-key indicators.
extensions/mssql/src/webviews/pages/SchemaDesigner/dab/dabEntityFilters.ts Extends filter model to include source types, API exposure, and auth mode.
extensions/mssql/src/webviews/pages/SchemaDesigner/dab/dabContext.tsx Fetches non-table source objects + adds entity-config update plumbing.
extensions/mssql/src/webviews/common/locConstants.ts Adds new localized strings/constants for the updated DAB UI.
extensions/mssql/src/sharedInterfaces/metadata.ts Adds shared metadata interfaces for DAB views/procs.
extensions/mssql/src/sharedInterfaces/dab.ts Expands DAB model: permissions, surfaces, logical-key inference, MCP controls, new requests/changes.
extensions/mssql/src/services/metadataService.ts Implements view/proc discovery and parsing via simple-execute queries.
extensions/mssql/src/schemaDesigner/schemaDesignerWebviewController.ts Adds webview RPC handler to return DAB source objects (views/procs) from metadata.
extensions/mssql/src/dab/dabConfigFileBuilder.ts Emits updated DAB config format: fields metadata, richer permissions, MCP configuration.
extensions/mssql/src/copilot/tools/dabTool.ts Extends telemetry/receipt counters for new DAB change types.
extensions/mssql/package.json Updates Copilot DAB tool schema/description for new operations and settings.
extensions/mssql/l10n/bundle.l10n.json Localization bundle updates for new DAB UI strings (ignored per guidelines).

Comment on lines +1699 to +1709
config.entities[resolvedEntity.index] = {
...resolvedEntity.entity,
enabledActions: change.permissions[0]?.actions ?? [],
advancedSettings: {
...resolvedEntity.entity.advancedSettings,
permissions: change.permissions.map((permission) => ({
role: permission.role,
actions: [...permission.actions],
})),
},
};

import SqlToolsServiceClient from "../languageservice/serviceclient";
import { RequestType } from "vscode-languageclient";
import { SimpleExecuteResult } from "vscode-mssql";
Comment on lines +1188 to +1192
const labels: Record<Dab.ApiType, string> = {
[Dab.ApiType.Rest]: locConstants.schemaDesigner.rest,
[Dab.ApiType.GraphQL]: "GQL",
[Dab.ApiType.Mcp]: locConstants.schemaDesigner.mcp,
};
Comment on lines +1236 to +1240
<Tooltip
content={`${locConstants.schemaDesigner.alias}: ${alias}`}
relationship="description">
<span className={classes.metadataDetailText}>
{locConstants.schemaDesigner.alias}: {alias}
Comment on lines +27 to +31
.dab-pill-rest {
border-color: rgba(63, 185, 80, 0.35) !important;
background: rgba(63, 185, 80, 0.12) !important;
color: #7ee787 !important;
}
@github-actions
Copy link
Copy Markdown

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 78788 KB 78803 KB ⚪ 15 KB ( 0% )
sql-database-projects VSIX 6309 KB 6309 KB ⚪ 0 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )
keymap VSIX 7 KB 7 KB ⚪ 0 KB ( 0% )

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 30, 2026

Codecov Report

❌ Patch coverage is 66.47365% with 579 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.24%. Comparing base (d76807d) to head (1689a12).

Files with missing lines Patch % Lines
.../pages/SchemaDesigner/schemaDesignerRpcHandlers.ts 18.80% 367 Missing ⚠️
.../schemaDesigner/schemaDesignerWebviewController.ts 9.55% 142 Missing ⚠️
extensions/mssql/src/sharedInterfaces/dab.ts 92.80% 36 Missing ⚠️
extensions/mssql/src/services/metadataService.ts 95.47% 20 Missing ⚠️
extensions/mssql/src/copilot/tools/dabTool.ts 71.42% 10 Missing ⚠️
...tensions/mssql/src/webviews/common/locConstants.ts 90.90% 4 Missing ⚠️

❌ Your patch status has failed because the patch coverage (66.47%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #22257      +/-   ##
==========================================
- Coverage   74.37%   74.24%   -0.13%     
==========================================
  Files         408      408              
  Lines      128293   129922    +1629     
  Branches     7768     7940     +172     
==========================================
+ Hits        95413    96466    +1053     
- Misses      32880    33456     +576     
Flag Coverage Δ
data-workspace 77.10% <ø> (ø)
mssql 73.87% <66.47%> (-0.14%) ⬇️
sqlproj 77.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
extensions/mssql/src/dab/dabConfigFileBuilder.ts 98.80% <100.00%> (+0.03%) ⬆️
extensions/mssql/src/sharedInterfaces/metadata.ts 100.00% <100.00%> (ø)
...tensions/mssql/src/webviews/common/locConstants.ts 30.22% <90.90%> (+0.94%) ⬆️
extensions/mssql/src/copilot/tools/dabTool.ts 97.10% <71.42%> (-2.01%) ⬇️
extensions/mssql/src/services/metadataService.ts 97.10% <95.47%> (-2.90%) ⬇️
extensions/mssql/src/sharedInterfaces/dab.ts 94.65% <92.80%> (-0.58%) ⬇️
.../schemaDesigner/schemaDesignerWebviewController.ts 73.63% <9.55%> (-10.51%) ⬇️
.../pages/SchemaDesigner/schemaDesignerRpcHandlers.ts 66.71% <18.80%> (-10.09%) ⬇️
🚀 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.

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