mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-15 01:25:36 -05:00
Add azdata.d.ts for new extensibility APIs (#4247)
* Add azdata.d.ts for new extensibility APIs * Update azdata typing files for connection API proposal * Add implementation for azdata module * Fix build break in agent
This commit is contained in:
@@ -8,6 +8,7 @@ import { ExtHostConnectionManagementShape, SqlMainContext, MainThreadConnectionM
|
||||
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
export class ExtHostConnectionManagement extends ExtHostConnectionManagementShape {
|
||||
|
||||
@@ -20,11 +21,20 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadConnectionManagement);
|
||||
}
|
||||
|
||||
public $getCurrentConnection(): Thenable<azdata.connection.ConnectionProfile> {
|
||||
let connection: any = this._proxy.$getCurrentConnection();
|
||||
connection.then((conn) => {
|
||||
conn.providerId = conn.providerName;
|
||||
});
|
||||
return connection;
|
||||
}
|
||||
|
||||
// "sqlops" back-compat connection APIs
|
||||
public $getActiveConnections(): Thenable<sqlops.connection.Connection[]> {
|
||||
return this._proxy.$getActiveConnections();
|
||||
}
|
||||
|
||||
public $getCurrentConnection(): Thenable<sqlops.connection.Connection> {
|
||||
public $getSqlOpsCurrentConnection(): Thenable<sqlops.connection.Connection> {
|
||||
return this._proxy.$getCurrentConnection();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import { realpath } from 'fs';
|
||||
import * as extHostTypes from 'vs/workbench/api/node/extHostTypes';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as vscode from 'vscode';
|
||||
import { SqlExtHostContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
@@ -46,6 +47,7 @@ import { ExtHostExtensionManagement } from 'sql/workbench/api/node/extHostExtens
|
||||
export interface ISqlExtensionApiFactory {
|
||||
vsCodeFactory(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry): typeof vscode;
|
||||
sqlopsFactory(extension: IExtensionDescription): typeof sqlops;
|
||||
azdataFactory(extension: IExtensionDescription): typeof azdata;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,6 +88,479 @@ export function createApiFactory(
|
||||
|
||||
return {
|
||||
vsCodeFactory: vsCodeFactory,
|
||||
azdataFactory: function (extension: IExtensionDescription): typeof azdata {
|
||||
// namespace: connection
|
||||
const connection: typeof azdata.connection = {
|
||||
// "azdata" API definition
|
||||
ConnectionProfile: sqlExtHostTypes.ConnectionProfile,
|
||||
|
||||
getCurrentConnection(): Thenable<azdata.connection.ConnectionProfile> {
|
||||
return extHostConnectionManagement.$getCurrentConnection();
|
||||
},
|
||||
|
||||
// "sqlops" back-compat APIs
|
||||
getActiveConnections(): Thenable<sqlops.connection.Connection[]> {
|
||||
return extHostConnectionManagement.$getActiveConnections();
|
||||
},
|
||||
getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {
|
||||
return extHostConnectionManagement.$getCredentials(connectionId);
|
||||
},
|
||||
getServerInfo(connectionId: string): Thenable<sqlops.ServerInfo> {
|
||||
return extHostConnectionManagement.$getServerInfo(connectionId);
|
||||
},
|
||||
openConnectionDialog(providers?: string[], initialConnectionProfile?: sqlops.IConnectionProfile, connectionCompletionOptions?: sqlops.IConnectionCompletionOptions): Thenable<sqlops.connection.Connection> {
|
||||
return extHostConnectionManagement.$openConnectionDialog(providers, initialConnectionProfile, connectionCompletionOptions);
|
||||
},
|
||||
listDatabases(connectionId: string): Thenable<string[]> {
|
||||
return extHostConnectionManagement.$listDatabases(connectionId);
|
||||
},
|
||||
getConnectionString(connectionId: string, includePassword: boolean): Thenable<string> {
|
||||
return extHostConnectionManagement.$getConnectionString(connectionId, includePassword);
|
||||
},
|
||||
getUriForConnection(connectionId: string): Thenable<string> {
|
||||
return extHostConnectionManagement.$getUriForConnection(connectionId);
|
||||
},
|
||||
connect(connectionProfile: sqlops.IConnectionProfile): Thenable<sqlops.ConnectionResult> {
|
||||
return extHostConnectionManagement.$connect(connectionProfile);
|
||||
}
|
||||
};
|
||||
|
||||
// Backcompat "sqlops" APIs
|
||||
// namespace: accounts
|
||||
const accounts: typeof sqlops.accounts = {
|
||||
registerAccountProvider(providerMetadata: sqlops.AccountProviderMetadata, provider: sqlops.AccountProvider): vscode.Disposable {
|
||||
return extHostAccountManagement.$registerAccountProvider(providerMetadata, provider);
|
||||
},
|
||||
beginAutoOAuthDeviceCode(providerId: string, title: string, message: string, userCode: string, uri: string): Thenable<void> {
|
||||
return extHostAccountManagement.$beginAutoOAuthDeviceCode(providerId, title, message, userCode, uri);
|
||||
},
|
||||
endAutoOAuthDeviceCode(): void {
|
||||
return extHostAccountManagement.$endAutoOAuthDeviceCode();
|
||||
},
|
||||
accountUpdated(updatedAccount: sqlops.Account): void {
|
||||
return extHostAccountManagement.$accountUpdated(updatedAccount);
|
||||
},
|
||||
getAllAccounts(): Thenable<sqlops.Account[]> {
|
||||
return extHostAccountManagement.$getAllAccounts();
|
||||
},
|
||||
getSecurityToken(account: sqlops.Account, resource?: sqlops.AzureResource): Thenable<{}> {
|
||||
return extHostAccountManagement.$getSecurityToken(account, resource);
|
||||
},
|
||||
onDidChangeAccounts(listener: (e: sqlops.DidChangeAccountsParams) => void, thisArgs?: any, disposables?: extHostTypes.Disposable[]) {
|
||||
return extHostAccountManagement.onDidChangeAccounts(listener, thisArgs, disposables);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: credentials
|
||||
const credentials: typeof sqlops.credentials = {
|
||||
registerProvider(provider: sqlops.CredentialProvider): vscode.Disposable {
|
||||
return extHostCredentialManagement.$registerCredentialProvider(provider);
|
||||
},
|
||||
getProvider(namespaceId: string): Thenable<sqlops.CredentialProvider> {
|
||||
return extHostCredentialManagement.$getCredentialProvider(namespaceId);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: objectexplorer
|
||||
const objectExplorer: typeof sqlops.objectexplorer = {
|
||||
getNode(connectionId: string, nodePath?: string): Thenable<sqlops.objectexplorer.ObjectExplorerNode> {
|
||||
return extHostObjectExplorer.$getNode(connectionId, nodePath);
|
||||
},
|
||||
getActiveConnectionNodes(): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||
return extHostObjectExplorer.$getActiveConnectionNodes();
|
||||
},
|
||||
findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<sqlops.objectexplorer.ObjectExplorerNode[]> {
|
||||
return extHostObjectExplorer.$findNodes(connectionId, type, schema, name, database, parentObjectNames);
|
||||
},
|
||||
getNodeActions(connectionId: string, nodePath: string): Thenable<string[]> {
|
||||
return extHostObjectExplorer.$getNodeActions(connectionId, nodePath);
|
||||
},
|
||||
getSessionConnectionProfile(sessionId: string): Thenable<sqlops.IConnectionProfile> {
|
||||
return extHostObjectExplorer.$getSessionConnectionProfile(sessionId);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: serialization
|
||||
const serialization: typeof sqlops.serialization = {
|
||||
registerProvider(provider: sqlops.SerializationProvider): vscode.Disposable {
|
||||
return extHostSerializationProvider.$registerSerializationProvider(provider);
|
||||
},
|
||||
};
|
||||
|
||||
// namespace: serialization
|
||||
const resources: typeof sqlops.resources = {
|
||||
registerResourceProvider(providerMetadata: sqlops.ResourceProviderMetadata, provider: sqlops.ResourceProvider): vscode.Disposable {
|
||||
return extHostResourceProvider.$registerResourceProvider(providerMetadata, provider);
|
||||
}
|
||||
};
|
||||
|
||||
let registerConnectionProvider = (provider: sqlops.ConnectionProvider): vscode.Disposable => {
|
||||
// Connection callbacks
|
||||
provider.registerOnConnectionComplete((connSummary: sqlops.ConnectionInfoSummary) => {
|
||||
extHostDataProvider.$onConnectComplete(provider.handle, connSummary);
|
||||
});
|
||||
|
||||
provider.registerOnIntelliSenseCacheComplete((connectionUri: string) => {
|
||||
extHostDataProvider.$onIntelliSenseCacheComplete(provider.handle, connectionUri);
|
||||
});
|
||||
|
||||
provider.registerOnConnectionChanged((changedConnInfo: sqlops.ChangedConnectionInfo) => {
|
||||
extHostDataProvider.$onConnectionChanged(provider.handle, changedConnInfo);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerConnectionProvider(provider);
|
||||
};
|
||||
|
||||
let registerQueryProvider = (provider: sqlops.QueryProvider): vscode.Disposable => {
|
||||
provider.registerOnQueryComplete((result: sqlops.QueryExecuteCompleteNotificationResult) => {
|
||||
extHostDataProvider.$onQueryComplete(provider.handle, result);
|
||||
});
|
||||
|
||||
provider.registerOnBatchStart((batchInfo: sqlops.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchStart(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.registerOnBatchComplete((batchInfo: sqlops.QueryExecuteBatchNotificationParams) => {
|
||||
extHostDataProvider.$onBatchComplete(provider.handle, batchInfo);
|
||||
});
|
||||
|
||||
provider.registerOnResultSetAvailable((resultSetInfo: sqlops.QueryExecuteResultSetNotificationParams) => {
|
||||
extHostDataProvider.$onResultSetAvailable(provider.handle, resultSetInfo);
|
||||
});
|
||||
|
||||
provider.registerOnResultSetUpdated((resultSetInfo: sqlops.QueryExecuteResultSetNotificationParams) => {
|
||||
extHostDataProvider.$onResultSetUpdated(provider.handle, resultSetInfo);
|
||||
});
|
||||
|
||||
provider.registerOnMessage((message: sqlops.QueryExecuteMessageParams) => {
|
||||
extHostDataProvider.$onQueryMessage(provider.handle, message);
|
||||
});
|
||||
|
||||
provider.registerOnEditSessionReady((ownerUri: string, success: boolean, message: string) => {
|
||||
extHostDataProvider.$onEditSessionReady(provider.handle, ownerUri, success, message);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerQueryProvider(provider);
|
||||
};
|
||||
|
||||
let registerObjectExplorerProvider = (provider: sqlops.ObjectExplorerProvider): vscode.Disposable => {
|
||||
provider.registerOnSessionCreated((response: sqlops.ObjectExplorerSession) => {
|
||||
extHostDataProvider.$onObjectExplorerSessionCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
if (provider.registerOnSessionDisconnected) {
|
||||
provider.registerOnSessionDisconnected((response: sqlops.ObjectExplorerSession) => {
|
||||
extHostDataProvider.$onObjectExplorerSessionDisconnected(provider.handle, response);
|
||||
});
|
||||
}
|
||||
|
||||
provider.registerOnExpandCompleted((response: sqlops.ObjectExplorerExpandInfo) => {
|
||||
extHostDataProvider.$onObjectExplorerNodeExpanded(provider.providerId, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerObjectExplorerProvider(provider);
|
||||
};
|
||||
|
||||
let registerObjectExplorerNodeProvider = (provider: sqlops.ObjectExplorerNodeProvider): vscode.Disposable => {
|
||||
provider.registerOnExpandCompleted((response: sqlops.ObjectExplorerExpandInfo) => {
|
||||
extHostDataProvider.$onObjectExplorerNodeExpanded(provider.providerId, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerObjectExplorerNodeProvider(provider);
|
||||
};
|
||||
|
||||
let registerTaskServicesProvider = (provider: sqlops.TaskServicesProvider): vscode.Disposable => {
|
||||
provider.registerOnTaskCreated((response: sqlops.TaskInfo) => {
|
||||
extHostDataProvider.$onTaskCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnTaskStatusChanged((response: sqlops.TaskProgressInfo) => {
|
||||
extHostDataProvider.$onTaskStatusChanged(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerTaskServicesProvider(provider);
|
||||
};
|
||||
|
||||
let registerFileBrowserProvider = (provider: sqlops.FileBrowserProvider): vscode.Disposable => {
|
||||
provider.registerOnFileBrowserOpened((response: sqlops.FileBrowserOpenedParams) => {
|
||||
extHostDataProvider.$onFileBrowserOpened(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnFolderNodeExpanded((response: sqlops.FileBrowserExpandedParams) => {
|
||||
extHostDataProvider.$onFolderNodeExpanded(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnFilePathsValidated((response: sqlops.FileBrowserValidatedParams) => {
|
||||
extHostDataProvider.$onFilePathsValidated(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerFileBrowserProvider(provider);
|
||||
};
|
||||
|
||||
let registerScriptingProvider = (provider: sqlops.ScriptingProvider): vscode.Disposable => {
|
||||
provider.registerOnScriptingComplete((response: sqlops.ScriptingCompleteResult) => {
|
||||
extHostDataProvider.$onScriptingComplete(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerScriptingProvider(provider);
|
||||
};
|
||||
|
||||
let registerProfilerProvider = (provider: sqlops.ProfilerProvider): vscode.Disposable => {
|
||||
provider.registerOnSessionEventsAvailable((response: sqlops.ProfilerSessionEvents) => {
|
||||
extHostDataProvider.$onSessionEventsAvailable(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnSessionStopped((response: sqlops.ProfilerSessionStoppedParams) => {
|
||||
extHostDataProvider.$onSessionStopped(provider.handle, response);
|
||||
});
|
||||
|
||||
provider.registerOnProfilerSessionCreated((response: sqlops.ProfilerSessionCreatedParams) => {
|
||||
extHostDataProvider.$onProfilerSessionCreated(provider.handle, response);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerProfilerProvider(provider);
|
||||
};
|
||||
|
||||
let registerBackupProvider = (provider: sqlops.BackupProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerBackupProvider(provider);
|
||||
};
|
||||
|
||||
let registerRestoreProvider = (provider: sqlops.RestoreProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerRestoreProvider(provider);
|
||||
};
|
||||
|
||||
let registerMetadataProvider = (provider: sqlops.MetadataProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerMetadataProvider(provider);
|
||||
};
|
||||
|
||||
let registerCapabilitiesServiceProvider = (provider: sqlops.CapabilitiesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerCapabilitiesServiceProvider(provider);
|
||||
};
|
||||
|
||||
let registerAdminServicesProvider = (provider: sqlops.AdminServicesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerAdminServicesProvider(provider);
|
||||
};
|
||||
|
||||
let registerAgentServicesProvider = (provider: sqlops.AgentServicesProvider): vscode.Disposable => {
|
||||
provider.registerOnUpdated(() => {
|
||||
extHostDataProvider.$onJobDataUpdated(provider.handle);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerAgentServiceProvider(provider);
|
||||
};
|
||||
|
||||
let registerDacFxServicesProvider = (provider: sqlops.DacFxServicesProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerDacFxServiceProvider(provider);
|
||||
};
|
||||
|
||||
// namespace: dataprotocol
|
||||
const dataprotocol: typeof sqlops.dataprotocol = {
|
||||
registerBackupProvider,
|
||||
registerConnectionProvider,
|
||||
registerFileBrowserProvider,
|
||||
registerMetadataProvider,
|
||||
registerObjectExplorerProvider,
|
||||
registerObjectExplorerNodeProvider,
|
||||
registerProfilerProvider,
|
||||
registerRestoreProvider,
|
||||
registerScriptingProvider,
|
||||
registerTaskServicesProvider,
|
||||
registerQueryProvider,
|
||||
registerAdminServicesProvider,
|
||||
registerAgentServicesProvider,
|
||||
registerCapabilitiesServiceProvider,
|
||||
registerDacFxServicesProvider,
|
||||
onDidChangeLanguageFlavor(listener: (e: sqlops.DidChangeLanguageFlavorParams) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) {
|
||||
return extHostDataProvider.onDidChangeLanguageFlavor(listener, thisArgs, disposables);
|
||||
},
|
||||
getProvider<T extends sqlops.DataProvider>(providerId: string, providerType: sqlops.DataProviderType) {
|
||||
return extHostDataProvider.getProvider<T>(providerId, providerType);
|
||||
},
|
||||
getProvidersByType<T extends sqlops.DataProvider>(providerType: sqlops.DataProviderType) {
|
||||
return extHostDataProvider.getProvidersByType<T>(providerType);
|
||||
}
|
||||
};
|
||||
|
||||
const modelViewDialog: typeof sqlops.window.modelviewdialog = {
|
||||
createDialog(title: string, dialogName?: string): sqlops.window.modelviewdialog.Dialog {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createDialog has been deprecated, replace it with sqlops.window.createModelViewDialog');
|
||||
return extHostModelViewDialog.createDialog(title, dialogName, extension);
|
||||
},
|
||||
createTab(title: string): sqlops.window.modelviewdialog.DialogTab {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createTab has been deprecated, replace it with sqlops.window.createTab');
|
||||
return extHostModelViewDialog.createTab(title, extension);
|
||||
},
|
||||
createButton(label: string): sqlops.window.modelviewdialog.Button {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createButton has been deprecated, replace it with sqlops.window.createButton');
|
||||
return extHostModelViewDialog.createButton(label);
|
||||
},
|
||||
openDialog(dialog: sqlops.window.modelviewdialog.Dialog) {
|
||||
console.warn('the method sqlops.window.modelviewdialog.openDialog has been deprecated, replace it with sqlops.window.openDialog');
|
||||
return extHostModelViewDialog.openDialog(dialog);
|
||||
},
|
||||
closeDialog(dialog: sqlops.window.modelviewdialog.Dialog) {
|
||||
console.warn('the method sqlops.window.modelviewdialog.closeDialog has been deprecated, replace it with sqlops.window.closeDialog');
|
||||
return extHostModelViewDialog.closeDialog(dialog);
|
||||
},
|
||||
createWizardPage(title: string): sqlops.window.modelviewdialog.WizardPage {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createWizardPage has been deprecated, replace it with sqlops.window.createWizardPage');
|
||||
return extHostModelViewDialog.createWizardPage(title);
|
||||
},
|
||||
createWizard(title: string): sqlops.window.modelviewdialog.Wizard {
|
||||
console.warn('the method sqlops.window.modelviewdialog.createWizard has been deprecated, replace it with sqlops.window.createWizard');
|
||||
return extHostModelViewDialog.createWizard(title);
|
||||
},
|
||||
MessageLevel: sqlExtHostTypes.MessageLevel
|
||||
};
|
||||
|
||||
const window: typeof sqlops.window = {
|
||||
createDialog(name: string) {
|
||||
console.warn('the method sqlops.window.createDialog has been deprecated, replace it with sqlops.window.createWebViewDialog');
|
||||
return extHostModalDialogs.createDialog(name);
|
||||
},
|
||||
modelviewdialog: modelViewDialog,
|
||||
createWebViewDialog(name: string) {
|
||||
return extHostModalDialogs.createDialog(name);
|
||||
},
|
||||
createModelViewDialog(title: string, dialogName?: string): sqlops.window.Dialog {
|
||||
return extHostModelViewDialog.createDialog(title, dialogName, extension);
|
||||
},
|
||||
createTab(title: string): sqlops.window.DialogTab {
|
||||
return extHostModelViewDialog.createTab(title, extension);
|
||||
},
|
||||
createButton(label: string): sqlops.window.Button {
|
||||
return extHostModelViewDialog.createButton(label);
|
||||
},
|
||||
openDialog(dialog: sqlops.window.Dialog) {
|
||||
return extHostModelViewDialog.openDialog(dialog);
|
||||
},
|
||||
closeDialog(dialog: sqlops.window.Dialog) {
|
||||
return extHostModelViewDialog.closeDialog(dialog);
|
||||
},
|
||||
createWizardPage(title: string): sqlops.window.WizardPage {
|
||||
return extHostModelViewDialog.createWizardPage(title);
|
||||
},
|
||||
createWizard(title: string): sqlops.window.Wizard {
|
||||
return extHostModelViewDialog.createWizard(title);
|
||||
},
|
||||
MessageLevel: sqlExtHostTypes.MessageLevel
|
||||
};
|
||||
|
||||
const tasks: typeof sqlops.tasks = {
|
||||
registerTask(id: string, task: (...args: any[]) => any, thisArgs?: any): vscode.Disposable {
|
||||
return extHostTasks.registerTask(id, task, thisArgs);
|
||||
},
|
||||
startBackgroundOperation(operationInfo: sqlops.BackgroundOperationInfo): void {
|
||||
extHostBackgroundTaskManagement.$registerTask(operationInfo);
|
||||
}
|
||||
};
|
||||
|
||||
const workspace: typeof sqlops.workspace = {
|
||||
onDidOpenDashboard: extHostDashboard.onDidOpenDashboard,
|
||||
onDidChangeToDashboard: extHostDashboard.onDidChangeToDashboard,
|
||||
createModelViewEditor(title: string, options?: sqlops.ModelViewEditorOptions): sqlops.workspace.ModelViewEditor {
|
||||
return extHostModelViewDialog.createModelViewEditor(title, extension, options);
|
||||
}
|
||||
};
|
||||
|
||||
const dashboard = {
|
||||
registerWebviewProvider(widgetId: string, handler: (webview: sqlops.DashboardWebview) => void) {
|
||||
extHostWebviewWidgets.$registerProvider(widgetId, handler);
|
||||
}
|
||||
};
|
||||
|
||||
const ui = {
|
||||
registerModelViewProvider(modelViewId: string, handler: (view: sqlops.ModelView) => void): void {
|
||||
extHostModelView.$registerProvider(modelViewId, handler, extension);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: queryeditor
|
||||
const queryEditor: typeof sqlops.queryeditor = {
|
||||
|
||||
connect(fileUri: string, connectionId: string): Thenable<void> {
|
||||
return extHostQueryEditor.$connect(fileUri, connectionId);
|
||||
},
|
||||
|
||||
runQuery(fileUri: string): void {
|
||||
extHostQueryEditor.$runQuery(fileUri);
|
||||
}
|
||||
};
|
||||
|
||||
const extensions: typeof sqlops.extensions = {
|
||||
install(vsixPath: string): Thenable<string> {
|
||||
return extHostExtensionManagement.$install(vsixPath);
|
||||
}
|
||||
};
|
||||
|
||||
const nb = {
|
||||
get notebookDocuments() {
|
||||
return extHostNotebookDocumentsAndEditors.getAllDocuments().map(doc => doc.document);
|
||||
},
|
||||
get activeNotebookEditor() {
|
||||
return extHostNotebookDocumentsAndEditors.getActiveEditor();
|
||||
},
|
||||
get visibleNotebookEditors() {
|
||||
return extHostNotebookDocumentsAndEditors.getAllEditors();
|
||||
},
|
||||
get onDidOpenNotebookDocument() {
|
||||
return extHostNotebookDocumentsAndEditors.onDidOpenNotebookDocument;
|
||||
},
|
||||
get onDidChangeNotebookCell() {
|
||||
return extHostNotebookDocumentsAndEditors.onDidChangeNotebookCell;
|
||||
},
|
||||
showNotebookDocument(uri: vscode.Uri, showOptions: sqlops.nb.NotebookShowOptions) {
|
||||
return extHostNotebookDocumentsAndEditors.showNotebookDocument(uri, showOptions);
|
||||
},
|
||||
registerNotebookProvider(provider: sqlops.nb.NotebookProvider): vscode.Disposable {
|
||||
return extHostNotebook.registerNotebookProvider(provider);
|
||||
},
|
||||
CellRange: sqlExtHostTypes.CellRange
|
||||
};
|
||||
|
||||
return {
|
||||
accounts,
|
||||
connection,
|
||||
credentials,
|
||||
objectexplorer: objectExplorer,
|
||||
resources,
|
||||
serialization,
|
||||
dataprotocol,
|
||||
DataProviderType: sqlExtHostTypes.DataProviderType,
|
||||
DeclarativeDataType: sqlExtHostTypes.DeclarativeDataType,
|
||||
ServiceOptionType: sqlExtHostTypes.ServiceOptionType,
|
||||
ConnectionOptionSpecialType: sqlExtHostTypes.ConnectionOptionSpecialType,
|
||||
EditRowState: sqlExtHostTypes.EditRowState,
|
||||
MetadataType: sqlExtHostTypes.MetadataType,
|
||||
TaskStatus: sqlExtHostTypes.TaskStatus,
|
||||
TaskExecutionMode: sqlExtHostTypes.TaskExecutionMode,
|
||||
ScriptOperation: sqlExtHostTypes.ScriptOperation,
|
||||
WeekDays: sqlExtHostTypes.WeekDays,
|
||||
NotifyMethods: sqlExtHostTypes.NotifyMethods,
|
||||
JobCompletionActionCondition: sqlExtHostTypes.JobCompletionActionCondition,
|
||||
JobExecutionStatus: sqlExtHostTypes.JobExecutionStatus,
|
||||
AlertType: sqlExtHostTypes.AlertType,
|
||||
FrequencyTypes: sqlExtHostTypes.FrequencyTypes,
|
||||
FrequencySubDayTypes: sqlExtHostTypes.FrequencySubDayTypes,
|
||||
FrequencyRelativeIntervals: sqlExtHostTypes.FrequencyRelativeIntervals,
|
||||
window,
|
||||
tasks,
|
||||
dashboard,
|
||||
workspace,
|
||||
queryeditor: queryEditor,
|
||||
ui: ui,
|
||||
StatusIndicator: sqlExtHostTypes.StatusIndicator,
|
||||
CardType: sqlExtHostTypes.CardType,
|
||||
Orientation: sqlExtHostTypes.Orientation,
|
||||
SqlThemeIcon: sqlExtHostTypes.SqlThemeIcon,
|
||||
TreeComponentItem: sqlExtHostTypes.TreeComponentItem,
|
||||
nb: nb,
|
||||
AzureResource: sqlExtHostTypes.AzureResource,
|
||||
TreeItem: sqlExtHostTypes.TreeItem,
|
||||
};
|
||||
},
|
||||
|
||||
// "sqlops" namespace provided for back-compat only, add new interfaces to "azdata"
|
||||
sqlopsFactory: function (extension: IExtensionDescription): typeof sqlops {
|
||||
// namespace: accounts
|
||||
const accounts: typeof sqlops.accounts = {
|
||||
@@ -118,7 +593,7 @@ export function createApiFactory(
|
||||
return extHostConnectionManagement.$getActiveConnections();
|
||||
},
|
||||
getCurrentConnection(): Thenable<sqlops.connection.Connection> {
|
||||
return extHostConnectionManagement.$getCurrentConnection();
|
||||
return extHostConnectionManagement.$getSqlOpsCurrentConnection();
|
||||
},
|
||||
getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {
|
||||
return extHostConnectionManagement.$getCredentials(connectionId);
|
||||
@@ -583,13 +1058,15 @@ function createExtensionPathIndex(extensionService: ExtHostExtensionService, ext
|
||||
}
|
||||
|
||||
function defineAPI(factory: ISqlExtensionApiFactory, extensionPaths: TrieMap<IExtensionDescription>, extensionRegistry: ExtensionDescriptionRegistry): void {
|
||||
type ApiImpl = typeof vscode | typeof sqlops;
|
||||
type ApiImpl = typeof vscode | typeof azdata | typeof sqlops;
|
||||
|
||||
// each extension is meant to get its own api implementation
|
||||
const extApiImpl = new Map<string, typeof vscode>();
|
||||
const dataExtApiImpl = new Map<string, typeof sqlops>();
|
||||
const azDataExtApiImpl = new Map<string, typeof azdata>();
|
||||
let defaultApiImpl: typeof vscode;
|
||||
let defaultDataApiImpl: typeof sqlops;
|
||||
let defaultAzDataApiImpl: typeof azdata;
|
||||
|
||||
// The module factory looks for an entry in the API map for an extension. If found, it reuses this.
|
||||
// If not, it loads it & saves it in the map
|
||||
@@ -628,6 +1105,12 @@ function defineAPI(factory: ISqlExtensionApiFactory, extensionPaths: TrieMap<IEx
|
||||
defaultApiImpl,
|
||||
(impl) => defaultApiImpl = <typeof vscode>impl,
|
||||
parent);
|
||||
} else if (request === 'azdata') {
|
||||
return getModuleFactory(azDataExtApiImpl,
|
||||
(ext) => factory.azdataFactory(ext),
|
||||
defaultDataApiImpl,
|
||||
(impl) => defaultAzDataApiImpl = <typeof azdata>impl,
|
||||
parent);
|
||||
} else if (request === 'sqlops') {
|
||||
return getModuleFactory(dataExtApiImpl,
|
||||
(ext) => factory.sqlopsFactory(ext),
|
||||
|
||||
Reference in New Issue
Block a user