Skip to content

Commit 02668f7

Browse files
authored
Connection sharing (#19542)
* Implement connection sharing service and related interface for managing SQL Server connections * Add localization for SQL Server connection access request message * Enhance connection sharing service with new commands and permissions management - Added commands for connection sharing: getConnectionIdForActiveEditor, connect, disconnect, isConnected, executeSimpleQuery, getServerInfo, and editConnectionSharingPermissions. - Updated connection sharing approval logic to handle denied status. - Introduced method to retrieve connection info from a given file URI in ConnectionManager. - Modified type definitions for connect and getServerInfo methods to return promises and appropriate types. * feat: Add connection sharing sample extension - Created a new VS Code extension for connection sharing. - Added package.json to define extension metadata and commands. - Implemented the main extension logic in src/extension.ts, including a command to execute a simple query. - Added TypeScript configuration in tsconfig.json for strict type-checking. - Included a test suite in src/test/extension.test.ts with a sample test case. - Updated connectionSharingService.ts to handle new permission options including "Clear" for resetting approvals. - Enhanced user prompts for connection sharing permissions with current status indicators. * feat: Enhance connection sharing service with new methods and update typings * refactor: Remove obsolete connection sharing sample extension files from dist * feat: Add new commands for connection sharing permissions management and enhance connection sharing service * feat: Update connection sharing sample extension and enhance permissions management * feat: Rename connection sharing methods and enhance typings for better clarity * feat: Enhance connection sharing permissions management with new methods and localized strings * feat: Add localized strings for connection sharing permissions management * refactor: Simplify support section in README by consolidating issue reporting instructions * fix: Update @types/mocha version to 5.2.7 and remove outdated version 10.0.10 * Fixing old webview compilation * Refactor connection sharing service to use constants for extension ID filtering * Implement scripting functionality for database objects in connection sharing service * Refactor ScriptingService to improve createScriptingParamsFromNode method and update tests * Update connection sharing permissions message in localization file * Delete samples/connection-sharing-sample/vsc-extension-quickstart.md
1 parent ef5241c commit 02668f7

33 files changed

+7457
-88
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ webviews-metafile.json
2929
# Ignore all l10n files except the default one (bundle.l10n.json)
3030
/localization/l10n/bundle.l10n.*.json
3131
.eslintcache
32-
.nyc_output
32+
.nyc_output
33+
samples/connection-sharing-sample/dist

localization/l10n/bundle.l10n.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,29 @@
16881688
]
16891689
},
16901690
"$(plug) Connect to MSSQL": "$(plug) Connect to MSSQL",
1691+
"The extension '{0}' is requesting access to your SQL Server connections. This will allow it to execute queries and access your database./{0} is the extension name": {
1692+
"message": "The extension '{0}' is requesting access to your SQL Server connections. This will allow it to execute queries and access your database.",
1693+
"comment": [
1694+
"{0} is the extension name"
1695+
]
1696+
},
1697+
"Approve": "Approve",
1698+
"Deny": "Deny",
1699+
"✅ Grant Access": "✅ Grant Access",
1700+
"✅ Grant Access (Current)": "✅ Grant Access (Current)",
1701+
"❌ Deny Access": "❌ Deny Access",
1702+
"❌ Deny Access (Current)": "❌ Deny Access (Current)",
1703+
"Allow this extension to access your connections": "Allow this extension to access your connections",
1704+
"Block this extension from accessing your connections": "Block this extension from accessing your connections",
1705+
"Select an extension to manage connection sharing permissions": "Select an extension to manage connection sharing permissions",
1706+
"Select new permission for extension: '{0}'/{0} is the extension name": {
1707+
"message": "Select new permission for extension: '{0}'",
1708+
"comment": [
1709+
"{0} is the extension name"
1710+
]
1711+
},
1712+
"Clear permissions for all extensions to access your connections": "Clear permissions for all extensions to access your connections",
1713+
"All permissions for extensions to access your connections have been cleared.": "All permissions for extensions to access your connections have been cleared.",
16911714
"Create Connection Group": "Create Connection Group",
16921715
"Edit Connection Group - {0}/{0} is the connection group name": {
16931716
"message": "Edit Connection Group - {0}",

localization/xliff/vscode-mssql.xlf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,18 @@
104104
<trans-unit id="++CODE++dfa2817fb2221c8b89c47c4fe8326d07c119b7c32e89e509d1061fc596fdf801">
105105
<source xml:lang="en">Advanced Options</source>
106106
</trans-unit>
107+
<trans-unit id="++CODE++08d0861fba87c9910b6c76342c1783be7d5504ff5248fbacd869963a7322992d">
108+
<source xml:lang="en">All permissions for extensions to access your connections have been cleared.</source>
109+
</trans-unit>
107110
<trans-unit id="++CODE++4d33c136b843b3ddc449137e1c655e000f830c7ce36da8d6645e9a76633d035f">
108111
<source xml:lang="en">Allow Null</source>
109112
</trans-unit>
110113
<trans-unit id="++CODE++ab4db1a876378f718e4073baa75897c34c0e7d2608d68cda6461e01de42fa962">
111114
<source xml:lang="en">Allow Nulls</source>
112115
</trans-unit>
116+
<trans-unit id="++CODE++5823192e37f38baf2e14f1fba3486615cbfa097b26c05b2a13a6c3473ce11c74">
117+
<source xml:lang="en">Allow this extension to access your connections</source>
118+
</trans-unit>
113119
<trans-unit id="++CODE++a49d631f8c6cf6fb1660fb5229dfa0c08b55727549c0e48cc0cef1f7770ba0e2">
114120
<source xml:lang="en">Alphabetical</source>
115121
</trans-unit>
@@ -148,6 +154,9 @@
148154
<trans-unit id="++CODE++757ac56c1f67056996dba37c6407eb302cbee2e590429afcb42210d125337f6a">
149155
<source xml:lang="en">Apply changes to target</source>
150156
</trans-unit>
157+
<trans-unit id="++CODE++6007acbe30b2cd98703e83350ea665c06009fcd51f26dd73b309294235f45f21">
158+
<source xml:lang="en">Approve</source>
159+
</trans-unit>
151160
<trans-unit id="++CODE++9d9d0bfa74aaf1db2f58269ddd7f7e8141a4069574d576aab3174f0f810ad1e0">
152161
<source xml:lang="en">Are you sure you want to delete the container {0}? This will remove both the container and its connection from VS Code.</source>
153162
<note>{0} is the container name</note>
@@ -257,6 +266,9 @@
257266
<trans-unit id="++CODE++79654f98221029c4c838b279ed9a41aa49c8a3cdb1cc95d81a456c510e6854d0">
258267
<source xml:lang="en">Blanks</source>
259268
</trans-unit>
269+
<trans-unit id="++CODE++886089b371ee3596c742b0c91467d1b7239b1d7f8f3eb86b88c1304644266abc">
270+
<source xml:lang="en">Block this extension from accessing your connections</source>
271+
</trans-unit>
260272
<trans-unit id="++CODE++ec811d30a89ce96d1c7555ffaede78b188fedb1d283adf7cdf55a4edae6697a7">
261273
<source xml:lang="en">Brightness</source>
262274
</trans-unit>
@@ -446,6 +458,9 @@
446458
<trans-unit id="++CODE++bb7638a0d8b3b374d81381caaf50ea1e5639135dd6ec1df7bc2dae0f344b72ec">
447459
<source xml:lang="en">Clear cache and refresh token</source>
448460
</trans-unit>
461+
<trans-unit id="++CODE++21f5ea19572773c428e8375b3d63058ad4f04aea83df347deb633f9ddad9a643">
462+
<source xml:lang="en">Clear permissions for all extensions to access your connections</source>
463+
</trans-unit>
449464
<trans-unit id="++CODE++6bca6724e27bd109d1b946c1684e16c2c4a5d71731a9ffe5f666bdd9d9846b1e">
450465
<source xml:lang="en">Click to connect to a database</source>
451466
</trans-unit>
@@ -781,6 +796,9 @@
781796
<trans-unit id="++CODE++a58008628a726d4f8798f9f92347d47f8f5c1c1aece67f8128600de9311a65e1">
782797
<source xml:lang="en">Deleting Container...</source>
783798
</trans-unit>
799+
<trans-unit id="++CODE++05a2d7332eb9d8bf164487c743a2e93c21b16bb2061a93e3ee2ceb508eadb753">
800+
<source xml:lang="en">Deny</source>
801+
</trans-unit>
784802
<trans-unit id="++CODE++526e0087cc3f254d9f86f6c7d8e23d954c4dfda2b312efc29194ae8a860106ba">
785803
<source xml:lang="en">Description</source>
786804
</trans-unit>
@@ -2117,9 +2135,16 @@
21172135
<trans-unit id="++CODE++ba89783a339fd43f48271d2e9813374075b46d8896bfa4f99444022a42847531">
21182136
<source xml:lang="en">Select an account</source>
21192137
</trans-unit>
2138+
<trans-unit id="++CODE++1032e1d25c0d5131be3195e1e53197385eb21d860f4f14f7bbc4cfcce4bfd109">
2139+
<source xml:lang="en">Select an extension to manage connection sharing permissions</source>
2140+
</trans-unit>
21202141
<trans-unit id="++CODE++6a8027c451f5eed5d0e62f3f599e8d39a787706b19612279423f6b706b1751f3">
21212142
<source xml:lang="en">Select image</source>
21222143
</trans-unit>
2144+
<trans-unit id="++CODE++154f133b3d7ef488e01090c00b0104ba7bf48bf4368e2ad71333fd3d863fb270">
2145+
<source xml:lang="en">Select new permission for extension: &apos;{0}&apos;</source>
2146+
<note>{0} is the extension name</note>
2147+
</trans-unit>
21232148
<trans-unit id="++CODE++e286357ecd532997834edbf13478a2b3ca334a9dda1c8e895c0bd8b26f6097b5">
21242149
<source xml:lang="en">Select profile to remove</source>
21252150
</trans-unit>
@@ -2407,6 +2432,10 @@
24072432
<trans-unit id="++CODE++ff83ab307bf5543897d2c5781d880385ba86a704904fb08dc5c67c990688d5ec">
24082433
<source xml:lang="en">The expression defining the check constraint.</source>
24092434
</trans-unit>
2435+
<trans-unit id="++CODE++dcf10fd537a0660c98f1a3890997024dfebb2ac795ee02dcbc7581ec4a0fe141">
2436+
<source xml:lang="en">The extension &apos;{0}&apos; is requesting access to your SQL Server connections. This will allow it to execute queries and access your database.</source>
2437+
<note>{0} is the extension name</note>
2438+
</trans-unit>
24102439
<trans-unit id="++CODE++d160b49baa7c6e4e8b95a21a984b19fda338b9d47a01d61c2d7445ed29cf174e">
24112440
<source xml:lang="en">The first value must be less than the second value for the {0} operator in the {1} filter</source>
24122441
<note>{0} is the operator for the filter
@@ -2757,6 +2786,18 @@
27572786
<trans-unit id="++CODE++c7c45c2f2ad470c2dc1a35bf3320d977e49bd4f4c804d9bf347d009669e5ebae">
27582787
<source xml:lang="en">{{put-server-name-here}}</source>
27592788
</trans-unit>
2789+
<trans-unit id="++CODE++097beaf7cff8a2792062a02ba2078dcf76e2166c13dd935fbffcd530d655cdf6">
2790+
<source xml:lang="en">✅ Grant Access</source>
2791+
</trans-unit>
2792+
<trans-unit id="++CODE++56034cb01aa84b5c8abe9389abf03d1c9a91ecea712a8711d611abb0ddd1637c">
2793+
<source xml:lang="en">✅ Grant Access (Current)</source>
2794+
</trans-unit>
2795+
<trans-unit id="++CODE++40609c19f7011fdd42630f286c30982b3d7a2d74640e310c4126b785a384149d">
2796+
<source xml:lang="en">❌ Deny Access</source>
2797+
</trans-unit>
2798+
<trans-unit id="++CODE++4d765d766973242c68c5a2d3b20c7164beb22948ceaf7095ce44f901cc2f4052">
2799+
<source xml:lang="en">❌ Deny Access (Current)</source>
2800+
</trans-unit>
27602801
</body></file>
27612802
<file original="package" source-language="en" datatype="plaintext"><body>
27622803
<trans-unit id="mssql.addObjectExplorer">
@@ -2798,6 +2839,9 @@
27982839
<trans-unit id="mssql.chooseAuthMethod">
27992840
<source xml:lang="en">Chooses which Authentication method to use</source>
28002841
</trans-unit>
2842+
<trans-unit id="mssql.connectionSharing.clearAllConnectionSharingPermissions">
2843+
<source xml:lang="en">Clear All Connection Sharing Permissions</source>
2844+
</trans-unit>
28012845
<trans-unit id="mssql.clearAllQueryHistory">
28022846
<source xml:lang="en">Clear All Query History</source>
28032847
</trans-unit>
@@ -2879,6 +2923,9 @@
28792923
<trans-unit id="mssql.connectionGroups.edit">
28802924
<source xml:lang="en">Edit Connection Group</source>
28812925
</trans-unit>
2926+
<trans-unit id="mssql.connectionSharing.editConnectionSharingPermissions">
2927+
<source xml:lang="en">Edit Connection Sharing Permissions</source>
2928+
</trans-unit>
28822929
<trans-unit id="mssql.editTable">
28832930
<source xml:lang="en">Edit Table</source>
28842931
</trans-unit>

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,16 @@
11071107
"title": "%mssql.copilot.rewriteQuery%",
11081108
"category": "MSSQL"
11091109
},
1110+
{
1111+
"command": "mssql.connectionSharing.editConnectionSharingPermissions",
1112+
"title": "%mssql.connectionSharing.editConnectionSharingPermissions%",
1113+
"category": "MSSQL"
1114+
},
1115+
{
1116+
"command": "mssql.connectionSharing.clearAllConnectionSharingPermissions",
1117+
"title": "%mssql.connectionSharing.clearAllConnectionSharingPermissions%",
1118+
"category": "MSSQL"
1119+
},
11101120
{
11111121
"command": "mssql.connectionGroups.create",
11121122
"title": "%mssql.connectionGroups.create%",

package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,7 @@
220220
"mssql.walkthroughs.nextSteps.objectExplorerFilters.title": "Filter your Object Explorer Tree",
221221
"mssql.walkthroughs.nextSteps.objectExplorerFilters.description": "Only see the database objects that matter most to you by applying filters to the Object Explorer tree.\nStart by clicking the filter button next to most folders in the Connections view.",
222222
"mssql.walkthroughs.nextSteps.objectExplorerFilters.altText": "Object Explorer filters",
223+
"mssql.connectionSharing.editConnectionSharingPermissions": "Edit Connection Sharing Permissions",
224+
"mssql.connectionSharing.clearAllConnectionSharingPermissions": "Clear All Connection Sharing Permissions",
223225
"mssql.statusBar.connectionInfoMaxLength.description": "The maximum number of characters to display for the connection info in the status bar. Set to -1 for no limit."
224226
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from '@vscode/test-cli';
2+
3+
export default defineConfig({
4+
files: 'out/test/**/*.test.js',
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", "ms-vscode.extension-test-runner"]
5+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": [
13+
"--extensionDevelopmentPath=${workspaceFolder}",
14+
"--extensionDevelopmentPath=${workspaceFolder}/../../",
15+
"--disable-extensions"
16+
],
17+
"outFiles": [
18+
"${workspaceFolder}/dist/**/*.js"
19+
],
20+
"preLaunchTask": "${defaultBuildTask}"
21+
}
22+
]
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"files.exclude": {
4+
"out": false, // set this to true to hide the "out" folder with the compiled JS files
5+
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
6+
},
7+
"search.exclude": {
8+
"out": true, // set this to false to include "out" folder in search results
9+
"dist": true // set this to false to include "dist" folder in search results
10+
},
11+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
12+
"typescript.tsc.autoDetect": "off"
13+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// for the documentation about the tasks.json format
3+
{
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "watch",
8+
"dependsOn": [
9+
"npm: watch:tsc",
10+
"npm: watch:esbuild"
11+
],
12+
"presentation": {
13+
"reveal": "never"
14+
},
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"type": "npm",
22+
"script": "watch:esbuild",
23+
"group": "build",
24+
"problemMatcher": "$esbuild-watch",
25+
"isBackground": true,
26+
"label": "npm: watch:esbuild",
27+
"presentation": {
28+
"group": "watch",
29+
"reveal": "never"
30+
}
31+
},
32+
{
33+
"type": "npm",
34+
"script": "watch:tsc",
35+
"group": "build",
36+
"problemMatcher": "$tsc-watch",
37+
"isBackground": true,
38+
"label": "npm: watch:tsc",
39+
"presentation": {
40+
"group": "watch",
41+
"reveal": "never"
42+
}
43+
},
44+
{
45+
"type": "npm",
46+
"script": "watch-tests",
47+
"problemMatcher": "$tsc-watch",
48+
"isBackground": true,
49+
"presentation": {
50+
"reveal": "never",
51+
"group": "watchers"
52+
},
53+
"group": "build"
54+
},
55+
{
56+
"label": "tasks: watch-tests",
57+
"dependsOn": [
58+
"npm: watch",
59+
"npm: watch-tests"
60+
],
61+
"problemMatcher": []
62+
}
63+
]
64+
}

0 commit comments

Comments
 (0)