mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
Add more areas to strict null (#7243)
* add more areas to strict null * fix compile errors * fix tests * fix checks * address PR comments
This commit is contained in:
@@ -19,7 +19,7 @@ export const IBackupService = createDecorator<IBackupService>(SERVICE_ID);
|
||||
export interface IBackupService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
getBackupConfigInfo(connectionUri: string): Thenable<azdata.BackupConfigInfo>;
|
||||
getBackupConfigInfo(connectionUri: string): Promise<azdata.BackupConfigInfo | undefined>;
|
||||
|
||||
/**
|
||||
* Backup a data source using the provided connection
|
||||
|
||||
@@ -27,12 +27,12 @@ export class BackupService implements IBackupService {
|
||||
/**
|
||||
* Get database metadata needed to populate backup UI
|
||||
*/
|
||||
public getBackupConfigInfo(connectionUri: string): Thenable<azdata.BackupConfigInfo> {
|
||||
public getBackupConfigInfo(connectionUri: string): Promise<azdata.BackupConfigInfo | undefined> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
if (provider) {
|
||||
return provider.getBackupConfigInfo(connectionUri);
|
||||
return Promise.resolve(provider.getBackupConfigInfo(connectionUri));
|
||||
}
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
@@ -57,7 +57,7 @@ export class BackupService implements IBackupService {
|
||||
});
|
||||
}
|
||||
|
||||
private getProvider(connectionUri: string): { provider: azdata.BackupProvider, providerName: string } {
|
||||
private getProvider(connectionUri: string): { provider: azdata.BackupProvider, providerName: string } | undefined {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
return { provider: this._providers[providerId], providerName: providerId };
|
||||
|
||||
@@ -31,7 +31,7 @@ export class SingleConnectionMetadataService {
|
||||
private _uri: string
|
||||
) { }
|
||||
|
||||
get metadata(): Observable<ProviderMetadata> {
|
||||
get metadata(): Observable<ProviderMetadata | undefined> {
|
||||
return Observable.fromPromise(this._metadataService.getMetadata(this._uri));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||
|
||||
import * as azdata from 'sqlops';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -35,12 +35,12 @@ export interface ICapabilitiesService {
|
||||
/**
|
||||
* Retrieve a list of registered capabilities providers
|
||||
*/
|
||||
getCapabilities(provider: string): ProviderFeatures;
|
||||
getCapabilities(provider: string): ProviderFeatures | undefined;
|
||||
|
||||
/**
|
||||
* get the old version of provider information
|
||||
*/
|
||||
getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities;
|
||||
getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities | undefined;
|
||||
|
||||
/**
|
||||
* Register a capabilities provider
|
||||
|
||||
@@ -122,11 +122,11 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
||||
/**
|
||||
* Retrieve a list of registered server capabilities
|
||||
*/
|
||||
public getCapabilities(provider: string): ProviderFeatures {
|
||||
public getCapabilities(provider: string): ProviderFeatures | undefined {
|
||||
return this._providers.get(provider);
|
||||
}
|
||||
|
||||
public getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities {
|
||||
public getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities | undefined {
|
||||
return this._legacyProviders.get(provider);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
|
||||
let connectionProvider: azdata.ConnectionOption[] = [
|
||||
{
|
||||
name: 'connectionName',
|
||||
displayName: undefined,
|
||||
description: undefined,
|
||||
groupName: undefined,
|
||||
categoryValues: undefined,
|
||||
defaultValue: undefined,
|
||||
displayName: undefined!,
|
||||
description: undefined!,
|
||||
groupName: undefined!,
|
||||
categoryValues: undefined!,
|
||||
defaultValue: undefined!,
|
||||
isIdentity: true,
|
||||
isRequired: true,
|
||||
specialValueType: ConnectionOptionSpecialType.connectionName,
|
||||
@@ -35,11 +35,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
|
||||
},
|
||||
{
|
||||
name: 'serverName',
|
||||
displayName: undefined,
|
||||
description: undefined,
|
||||
groupName: undefined,
|
||||
categoryValues: undefined,
|
||||
defaultValue: undefined,
|
||||
displayName: undefined!,
|
||||
description: undefined!,
|
||||
groupName: undefined!,
|
||||
categoryValues: undefined!,
|
||||
defaultValue: undefined!,
|
||||
isIdentity: true,
|
||||
isRequired: true,
|
||||
specialValueType: ConnectionOptionSpecialType.serverName,
|
||||
@@ -47,11 +47,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
|
||||
},
|
||||
{
|
||||
name: 'databaseName',
|
||||
displayName: undefined,
|
||||
description: undefined,
|
||||
groupName: undefined,
|
||||
categoryValues: undefined,
|
||||
defaultValue: undefined,
|
||||
displayName: undefined!,
|
||||
description: undefined!,
|
||||
groupName: undefined!,
|
||||
categoryValues: undefined!,
|
||||
defaultValue: undefined!,
|
||||
isIdentity: true,
|
||||
isRequired: true,
|
||||
specialValueType: ConnectionOptionSpecialType.databaseName,
|
||||
@@ -59,11 +59,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
|
||||
},
|
||||
{
|
||||
name: 'userName',
|
||||
displayName: undefined,
|
||||
description: undefined,
|
||||
groupName: undefined,
|
||||
categoryValues: undefined,
|
||||
defaultValue: undefined,
|
||||
displayName: undefined!,
|
||||
description: undefined!,
|
||||
groupName: undefined!,
|
||||
categoryValues: undefined!,
|
||||
defaultValue: undefined!,
|
||||
isIdentity: true,
|
||||
isRequired: true,
|
||||
specialValueType: ConnectionOptionSpecialType.userName,
|
||||
@@ -71,11 +71,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
|
||||
},
|
||||
{
|
||||
name: 'authenticationType',
|
||||
displayName: undefined,
|
||||
description: undefined,
|
||||
groupName: undefined,
|
||||
categoryValues: undefined,
|
||||
defaultValue: undefined,
|
||||
displayName: undefined!,
|
||||
description: undefined!,
|
||||
groupName: undefined!,
|
||||
categoryValues: undefined!,
|
||||
defaultValue: undefined!,
|
||||
isIdentity: true,
|
||||
isRequired: true,
|
||||
specialValueType: ConnectionOptionSpecialType.authType,
|
||||
@@ -83,11 +83,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
|
||||
},
|
||||
{
|
||||
name: 'password',
|
||||
displayName: undefined,
|
||||
description: undefined,
|
||||
groupName: undefined,
|
||||
categoryValues: undefined,
|
||||
defaultValue: undefined,
|
||||
displayName: undefined!,
|
||||
description: undefined!,
|
||||
groupName: undefined!,
|
||||
categoryValues: undefined!,
|
||||
defaultValue: undefined!,
|
||||
isIdentity: true,
|
||||
isRequired: true,
|
||||
specialValueType: ConnectionOptionSpecialType.password,
|
||||
@@ -125,7 +125,7 @@ export class TestCapabilitiesService implements ICapabilitiesService {
|
||||
|
||||
// Event Emitters
|
||||
public get onProviderRegisteredEvent(): Event<azdata.DataProtocolServerCapabilities> {
|
||||
return undefined;
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
public isFeatureAvailable(featureName: Action, connectionManagementInfo: ConnectionManagementInfo): boolean {
|
||||
@@ -133,7 +133,7 @@ export class TestCapabilitiesService implements ICapabilitiesService {
|
||||
}
|
||||
|
||||
public onCapabilitiesReady(): Promise<void> {
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
public fireCapabilitiesRegistered(providerFeatures: ProviderFeatures): void {
|
||||
|
||||
@@ -13,7 +13,7 @@ export const FILE_SCHEMA: string = 'file';
|
||||
|
||||
export function resolveCurrentDirectory(uri: string, rootPath: string): string | undefined {
|
||||
let sqlUri = URI.parse(uri);
|
||||
let currentDirectory: string;
|
||||
let currentDirectory: string | undefined;
|
||||
|
||||
// use current directory of the sql file if sql file is saved
|
||||
if (sqlUri.scheme === FILE_SCHEMA) {
|
||||
@@ -30,12 +30,15 @@ export function resolveCurrentDirectory(uri: string, rootPath: string): string |
|
||||
return currentDirectory;
|
||||
}
|
||||
|
||||
export function resolveFilePath(uri: string, filePath: string, rootPath: string): string {
|
||||
export function resolveFilePath(uri: string, filePath: string, rootPath: string): string | undefined {
|
||||
let currentDirectory = resolveCurrentDirectory(uri, rootPath);
|
||||
return normalize(join(currentDirectory, filePath));
|
||||
if (currentDirectory) {
|
||||
return normalize(join(currentDirectory, filePath));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getRootPath(contextService: IWorkspaceContextService): string {
|
||||
export function getRootPath(contextService: IWorkspaceContextService): string | undefined {
|
||||
let isWorkspace = contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
|
||||
if (isWorkspace) {
|
||||
let folder = contextService.getWorkspace().folders[0];
|
||||
|
||||
@@ -110,7 +110,7 @@ export interface IConnectionManagementService {
|
||||
|
||||
onIntelliSenseCacheComplete(handle: number, connectionUri: string): void;
|
||||
|
||||
onConnectionChangedNotification(handle: number, changedConnInfo: azdata.ChangedConnectionInfo);
|
||||
onConnectionChangedNotification(handle: number, changedConnInfo: azdata.ChangedConnectionInfo): void;
|
||||
|
||||
getConnectionGroups(providers?: string[]): ConnectionProfileGroup[];
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import * as Constants from 'sql/platform/connection/common/constants';
|
||||
*/
|
||||
export class ConnectionProfile extends ProviderConnectionInfo implements interfaces.IConnectionProfile {
|
||||
|
||||
public parent: ConnectionProfileGroup = null;
|
||||
public parent?: ConnectionProfileGroup;
|
||||
private _id: string;
|
||||
public savePassword: boolean;
|
||||
private _groupName: string;
|
||||
@@ -88,7 +88,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
||||
this._id = generateUuid();
|
||||
}
|
||||
|
||||
public getParent(): ConnectionProfileGroup {
|
||||
public getParent(): ConnectionProfileGroup | undefined {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
@@ -103,11 +103,11 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
||||
this._id = value;
|
||||
}
|
||||
|
||||
public get azureTenantId(): string {
|
||||
public get azureTenantId(): string | undefined {
|
||||
return this.options['azureTenantId'];
|
||||
}
|
||||
|
||||
public set azureTenantId(value: string) {
|
||||
public set azureTenantId(value: string | undefined) {
|
||||
this.options['azureTenantId'] = value;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
||||
databaseName: this.databaseName,
|
||||
authenticationType: this.authenticationType,
|
||||
getOptionsKey: this.getOptionsKey,
|
||||
matches: undefined,
|
||||
matches: this.matches,
|
||||
groupId: this.groupId,
|
||||
groupFullName: this.groupFullName,
|
||||
password: this.password,
|
||||
@@ -244,22 +244,24 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
||||
|
||||
public static convertToProfileStore(
|
||||
capabilitiesService: ICapabilitiesService,
|
||||
connectionProfile: interfaces.IConnectionProfile): interfaces.IConnectionProfileStore {
|
||||
connectionProfile: interfaces.IConnectionProfile): interfaces.IConnectionProfileStore | undefined {
|
||||
if (connectionProfile) {
|
||||
let connectionInfo = ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile);
|
||||
let profile: interfaces.IConnectionProfileStore = {
|
||||
options: {},
|
||||
groupId: connectionProfile.groupId,
|
||||
providerName: connectionInfo.providerName,
|
||||
savePassword: connectionInfo.savePassword,
|
||||
id: connectionInfo.id
|
||||
};
|
||||
if (connectionInfo) {
|
||||
let profile: interfaces.IConnectionProfileStore = {
|
||||
options: {},
|
||||
groupId: connectionProfile.groupId,
|
||||
providerName: connectionInfo.providerName,
|
||||
savePassword: connectionInfo.savePassword,
|
||||
id: connectionInfo.id
|
||||
};
|
||||
|
||||
profile.options = connectionInfo.options;
|
||||
profile.options = connectionInfo.options;
|
||||
|
||||
return profile;
|
||||
} else {
|
||||
return undefined;
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export interface IConnectionProfileGroup {
|
||||
id: string;
|
||||
parentId: string;
|
||||
parentId?: string;
|
||||
name: string;
|
||||
color: string;
|
||||
description: string;
|
||||
@@ -18,7 +18,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
|
||||
public children: ConnectionProfileGroup[];
|
||||
public connections: ConnectionProfile[];
|
||||
public parentId: string;
|
||||
public parentId?: string;
|
||||
private _isRenamed: boolean;
|
||||
public constructor(
|
||||
public name: string,
|
||||
@@ -53,8 +53,8 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public get fullName(): string {
|
||||
let fullName: string = (this.id === 'root') ? undefined : this.name;
|
||||
public get fullName(): string | undefined {
|
||||
let fullName: string | undefined = (this.id === 'root') ? undefined : this.name;
|
||||
if (this.parent) {
|
||||
let parentFullName = this.parent.fullName;
|
||||
if (parentFullName) {
|
||||
@@ -156,7 +156,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
|
||||
public isAncestorOf(node: ConnectionProfileGroup | ConnectionProfile): boolean {
|
||||
let isAncestor = false;
|
||||
let currentNode = node;
|
||||
let currentNode: ConnectionProfileGroup | ConnectionProfile | undefined = node;
|
||||
while (currentNode) {
|
||||
if (currentNode.parent && currentNode.parent.id === this.id) {
|
||||
isAncestor = true;
|
||||
@@ -195,7 +195,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
}
|
||||
|
||||
public static getConnectionsInGroup(group: ConnectionProfileGroup): ConnectionProfile[] {
|
||||
let connections = [];
|
||||
let connections: ConnectionProfile[] = [];
|
||||
if (group && group.connections) {
|
||||
group.connections.forEach((con) => connections.push(con));
|
||||
}
|
||||
@@ -208,7 +208,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
}
|
||||
|
||||
public static getSubgroups(group: ConnectionProfileGroup): ConnectionProfileGroup[] {
|
||||
let subgroups = [];
|
||||
let subgroups: ConnectionProfileGroup[] = [];
|
||||
if (group && group.children) {
|
||||
group.children.forEach((grp) => subgroups.push(grp));
|
||||
group.children.forEach((subgroup) => {
|
||||
|
||||
@@ -104,27 +104,27 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
}
|
||||
|
||||
public get connectionName(): string {
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.connectionName);
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.connectionName)!;
|
||||
}
|
||||
|
||||
public get serverName(): string {
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.serverName);
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.serverName)!;
|
||||
}
|
||||
|
||||
public get databaseName(): string {
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.databaseName);
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.databaseName)!;
|
||||
}
|
||||
|
||||
public get userName(): string {
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.userName);
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.userName)!;
|
||||
}
|
||||
|
||||
public get password(): string {
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.password);
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.password)!;
|
||||
}
|
||||
|
||||
public get authenticationType(): string {
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.authType);
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.authType)!;
|
||||
}
|
||||
|
||||
public set connectionName(value: string) {
|
||||
@@ -206,7 +206,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
return isPasswordRequired;
|
||||
}
|
||||
|
||||
private getSpecialTypeOptionValue(type: string): string {
|
||||
private getSpecialTypeOptionValue(type: string): string | undefined {
|
||||
let name = this.getSpecialTypeOptionName(type);
|
||||
if (name) {
|
||||
return this.options[name];
|
||||
@@ -243,7 +243,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
|
||||
let idValues: string[] = [];
|
||||
for (let index = 0; index < idNames.length; index++) {
|
||||
let value = this.options[idNames[index]];
|
||||
let value = this.options[idNames[index]!];
|
||||
value = value ? value : '';
|
||||
idValues.push(`${idNames[index]}${ProviderConnectionInfo.nameValueSeparator}${value}`);
|
||||
}
|
||||
@@ -266,7 +266,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public getSpecialTypeOptionName(type: string): string {
|
||||
public getSpecialTypeOptionName(type: string): string | undefined {
|
||||
if (this._serverCapabilities) {
|
||||
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === type);
|
||||
return !!optionMetadata ? optionMetadata.name : undefined;
|
||||
|
||||
@@ -31,7 +31,7 @@ suite('ConnectionStore', () => {
|
||||
groupId: '',
|
||||
groupFullName: '',
|
||||
getOptionsKey: undefined,
|
||||
matches: undefined,
|
||||
matches: () => false,
|
||||
providerName: mssqlProviderName,
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
|
||||
@@ -46,7 +46,7 @@ export class FileBrowserService implements IFileBrowserService {
|
||||
return this._onPathValidate.event;
|
||||
}
|
||||
|
||||
public openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean> {
|
||||
public openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
const provider = this.getProvider(ownerUri);
|
||||
if (provider) {
|
||||
@@ -67,7 +67,7 @@ export class FileBrowserService implements IFileBrowserService {
|
||||
&& fileBrowserOpenedParams.fileTree.rootNode
|
||||
&& fileBrowserOpenedParams.fileTree.selectedNode
|
||||
) {
|
||||
let fileTree = this.convertFileTree(null, fileBrowserOpenedParams.fileTree.rootNode, fileBrowserOpenedParams.fileTree.selectedNode.fullPath, fileBrowserOpenedParams.ownerUri);
|
||||
let fileTree = this.convertFileTree(undefined, fileBrowserOpenedParams.fileTree.rootNode, fileBrowserOpenedParams.fileTree.selectedNode.fullPath, fileBrowserOpenedParams.ownerUri);
|
||||
this._onAddFileTree.fire({ rootNode: fileTree.rootNode, selectedNode: fileTree.selectedNode, expandedNodes: fileTree.expandedNodes });
|
||||
} else {
|
||||
let genericErrorMessage = localize('fileBrowserErrorMessage', "An error occured while loading the file browser.");
|
||||
@@ -77,7 +77,7 @@ export class FileBrowserService implements IFileBrowserService {
|
||||
}
|
||||
}
|
||||
|
||||
public expandFolderNode(fileNode: FileNode): Thenable<FileNode[]> {
|
||||
public expandFolderNode(fileNode: FileNode): Promise<FileNode[]> {
|
||||
this._pathToFileNodeMap[fileNode.fullPath] = fileNode;
|
||||
let self = this;
|
||||
return new Promise<FileNode[]>((resolve, reject) => {
|
||||
@@ -117,7 +117,7 @@ export class FileBrowserService implements IFileBrowserService {
|
||||
}
|
||||
}
|
||||
|
||||
public validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean> {
|
||||
public validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
const provider = this.getProvider(ownerUri);
|
||||
if (provider) {
|
||||
@@ -136,10 +136,10 @@ export class FileBrowserService implements IFileBrowserService {
|
||||
this._onPathValidate.fire(fileBrowserValidatedParams);
|
||||
}
|
||||
|
||||
public closeFileBrowser(ownerUri: string): Thenable<azdata.FileBrowserCloseResponse> {
|
||||
public closeFileBrowser(ownerUri: string): Promise<azdata.FileBrowserCloseResponse | undefined> {
|
||||
let provider = this.getProvider(ownerUri);
|
||||
if (provider) {
|
||||
return provider.closeFileBrowser(ownerUri);
|
||||
return Promise.resolve(provider.closeFileBrowser(ownerUri));
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
@@ -147,7 +147,8 @@ export class FileBrowserService implements IFileBrowserService {
|
||||
private generateResolveMapKey(ownerUri: string, expandPath: string): string {
|
||||
return ownerUri + ':' + expandPath;
|
||||
}
|
||||
private getProvider(connectionUri: string): azdata.FileBrowserProvider {
|
||||
|
||||
private getProvider(connectionUri: string): azdata.FileBrowserProvider | undefined {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
return this._providers[providerId];
|
||||
@@ -156,10 +157,10 @@ export class FileBrowserService implements IFileBrowserService {
|
||||
}
|
||||
}
|
||||
|
||||
private convertFileTree(parentNode: FileNode, fileTreeNode: azdata.FileTreeNode, expandPath: string, ownerUri: string): FileBrowserTree {
|
||||
private convertFileTree(parentNode: FileNode | undefined, fileTreeNode: azdata.FileTreeNode, expandPath: string, ownerUri: string): FileBrowserTree {
|
||||
FileBrowserService.fileNodeId += 1;
|
||||
let expandedNodes: FileNode[] = [];
|
||||
let selectedNode: FileNode;
|
||||
let selectedNode: FileNode | undefined;
|
||||
let fileNode = new FileNode(FileBrowserService.fileNodeId.toString(),
|
||||
fileTreeNode.name,
|
||||
fileTreeNode.fullPath,
|
||||
|
||||
@@ -24,35 +24,35 @@ export interface IFileBrowserService {
|
||||
/**
|
||||
* Open file browser
|
||||
*/
|
||||
openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean>;
|
||||
openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Event called when file browser is opened
|
||||
*/
|
||||
onFileBrowserOpened(handle: number, fileBrowserOpenedParams: azdata.FileBrowserOpenedParams);
|
||||
onFileBrowserOpened(handle: number, fileBrowserOpenedParams: azdata.FileBrowserOpenedParams): void;
|
||||
|
||||
/**
|
||||
* Expand folder node
|
||||
*/
|
||||
expandFolderNode(fileNode: FileNode): Thenable<FileNode[]>;
|
||||
expandFolderNode(fileNode: FileNode): Promise<FileNode[]>;
|
||||
|
||||
/**
|
||||
* Event called when children nodes are retrieved
|
||||
*/
|
||||
onFolderNodeExpanded(handle: number, fileBrowserExpandedParams: azdata.FileBrowserExpandedParams);
|
||||
onFolderNodeExpanded(handle: number, fileBrowserExpandedParams: azdata.FileBrowserExpandedParams): void;
|
||||
|
||||
/**
|
||||
* Validate selected file paths
|
||||
*/
|
||||
validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean>;
|
||||
validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Event called when the validation is complete
|
||||
*/
|
||||
onFilePathsValidated(handle: number, fileBrowserValidatedParams: azdata.FileBrowserValidatedParams);
|
||||
onFilePathsValidated(handle: number, fileBrowserValidatedParams: azdata.FileBrowserValidatedParams): void;
|
||||
|
||||
/**
|
||||
* Close file browser
|
||||
*/
|
||||
closeFileBrowser(ownerUri: string): Thenable<azdata.FileBrowserCloseResponse>;
|
||||
closeFileBrowser(ownerUri: string): Promise<azdata.FileBrowserCloseResponse | undefined>;
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ export const IMetadataService = createDecorator<IMetadataService>(SERVICE_ID);
|
||||
export interface IMetadataService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata>;
|
||||
getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata | undefined>;
|
||||
|
||||
getDatabaseNames(connectionUri: string): Thenable<string[]>;
|
||||
|
||||
getTableInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]>;
|
||||
getTableInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[] | undefined>;
|
||||
|
||||
getViewInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]>;
|
||||
getViewInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[] | undefined>;
|
||||
|
||||
/**
|
||||
* Register a metadata provider
|
||||
@@ -37,7 +37,7 @@ export class MetadataService implements IMetadataService {
|
||||
constructor(@IConnectionManagementService private _connectionService: IConnectionManagementService) {
|
||||
}
|
||||
|
||||
public getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata> {
|
||||
public getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata | undefined> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
@@ -61,7 +61,7 @@ export class MetadataService implements IMetadataService {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
public getTableInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]> {
|
||||
public getTableInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[] | undefined> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
@@ -73,7 +73,7 @@ export class MetadataService implements IMetadataService {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public getViewInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]> {
|
||||
public getViewInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[] | undefined> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
|
||||
@@ -27,7 +27,7 @@ export interface IModelView extends IView {
|
||||
setProperties(componentId: string, properties: { [key: string]: any }): void;
|
||||
setDataProvider(handle: number, componentId: string, context: any): void;
|
||||
refreshDataProvider(componentId: string, item: any): void;
|
||||
registerEvent(componentId: string);
|
||||
registerEvent(componentId: string): void;
|
||||
onEvent: Event<IModelViewEventArgs>;
|
||||
validate(componentId: string): Thenable<boolean>;
|
||||
readonly onDestroy: Event<void>;
|
||||
|
||||
@@ -13,7 +13,7 @@ export const SERVICE_ID = 'modelViewService';
|
||||
export interface IModelViewService {
|
||||
_serviceBrand: undefined;
|
||||
onRegisteredModelView: Event<IModelView>;
|
||||
registerModelView(widget: IModelView);
|
||||
registerModelView(widget: IModelView): void;
|
||||
}
|
||||
|
||||
export const IModelViewService = createDecorator<IModelViewService>(SERVICE_ID);
|
||||
|
||||
@@ -23,10 +23,4 @@ export interface ISqlOAuthService {
|
||||
* @return Promise to return an authorization code
|
||||
*/
|
||||
performOAuthAuthorization(eventId: string, url: string, silent: boolean): void;
|
||||
|
||||
/**
|
||||
* Registers a handler for the oauth-reply event on the IPC channel
|
||||
* @param handler Handler to call when the event is triggered
|
||||
*/
|
||||
registerOAuthCallback(handler: (event, args) => void): void;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,4 @@ export class SqlOAuthService implements ISqlOAuthService {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a handler for the oauth-reply event on the IPC channel
|
||||
* @param handler Handler to call when the event is triggered
|
||||
*/
|
||||
registerOAuthCallback(handler: (event, args) => void): void {
|
||||
electron.ipcRenderer.on('oauth-reply', handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export enum ScriptOperation {
|
||||
export interface IScriptingService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
script(connectionUri: string, metadata: azdata.ObjectMetadata, operation: ScriptOperation, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult>;
|
||||
script(connectionUri: string, metadata: azdata.ObjectMetadata, operation: ScriptOperation, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult | undefined>;
|
||||
|
||||
/**
|
||||
* Register a scripting provider
|
||||
@@ -45,7 +45,7 @@ export interface IScriptingService {
|
||||
/**
|
||||
* Returns the result for an operation if the operation failed
|
||||
*/
|
||||
getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult;
|
||||
getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult | undefined;
|
||||
}
|
||||
|
||||
export class ScriptingService implements IScriptingService {
|
||||
@@ -63,7 +63,7 @@ export class ScriptingService implements IScriptingService {
|
||||
/**
|
||||
* Call the service for scripting based on provider and scripting operation
|
||||
*/
|
||||
public script(connectionUri: string, metadata: azdata.ObjectMetadata, operation: ScriptOperation, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult> {
|
||||
public script(connectionUri: string, metadata: azdata.ObjectMetadata, operation: ScriptOperation, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult | undefined> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
|
||||
if (providerId) {
|
||||
@@ -91,7 +91,7 @@ export class ScriptingService implements IScriptingService {
|
||||
* Returns the result for an operation if the operation failed
|
||||
* @param operationId Operation Id
|
||||
*/
|
||||
public getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult {
|
||||
public getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult | undefined {
|
||||
if (operationId && operationId in this.failedScriptingOperations) {
|
||||
return this.failedScriptingOperations[operationId];
|
||||
} else {
|
||||
|
||||
@@ -51,7 +51,7 @@ export interface ISerializationService {
|
||||
|
||||
serializeResults(request: SerializeDataParams): Promise<azdata.SerializeDataResult>;
|
||||
|
||||
getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider;
|
||||
getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider | undefined;
|
||||
}
|
||||
|
||||
function getBatchSize(totalRows: number, currentIndex: number): number {
|
||||
@@ -90,7 +90,7 @@ export class SerializationService implements ISerializationService {
|
||||
|
||||
}
|
||||
|
||||
public getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider {
|
||||
public getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider | undefined {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(ownerUri);
|
||||
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
|
||||
let disposable: IDisposable;
|
||||
let id: string;
|
||||
if (types.isString(idOrTask)) {
|
||||
disposable = CommandsRegistry.registerCommand(idOrTask, handler);
|
||||
disposable = CommandsRegistry.registerCommand(idOrTask, handler!);
|
||||
id = idOrTask;
|
||||
} else {
|
||||
if (idOrTask.iconClass) {
|
||||
@@ -52,8 +52,8 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
|
||||
};
|
||||
}
|
||||
|
||||
getOrCreateTaskIconClassName(item: ICommandAction): string {
|
||||
let iconClass = null;
|
||||
getOrCreateTaskIconClassName(item: ICommandAction): string | undefined {
|
||||
let iconClass: string | undefined;
|
||||
if (this.taskIdToIconClassNameMap.has(item.id)) {
|
||||
iconClass = this.taskIdToIconClassNameMap.get(item.id);
|
||||
} else if (item.iconLocation) {
|
||||
@@ -74,17 +74,19 @@ export abstract class Task {
|
||||
public readonly id: string;
|
||||
public readonly title: string;
|
||||
public readonly iconPathDark: string;
|
||||
public readonly iconPath: { dark: URI; light?: URI; };
|
||||
private readonly _iconClass: string;
|
||||
private readonly _description: ITaskHandlerDescription;
|
||||
public readonly iconPath?: { dark: URI; light?: URI; };
|
||||
private readonly _iconClass?: string;
|
||||
private readonly _description?: ITaskHandlerDescription;
|
||||
|
||||
constructor(private opts: ITaskOptions) {
|
||||
this.id = opts.id;
|
||||
this.title = opts.title;
|
||||
this.iconPath = {
|
||||
dark: opts.iconPath ? URI.parse(opts.iconPath.dark) : undefined,
|
||||
light: opts.iconPath ? URI.parse(opts.iconPath.light) : undefined,
|
||||
};
|
||||
if (opts.iconPath.dark) {
|
||||
this.iconPath = {
|
||||
dark: URI.parse(opts.iconPath.dark),
|
||||
light: opts.iconPath.light ? URI.parse(opts.iconPath.light) : undefined,
|
||||
};
|
||||
}
|
||||
this._iconClass = opts.iconClass;
|
||||
this._description = opts.description;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
|
||||
export interface ITaskOptions {
|
||||
id: string;
|
||||
title: string;
|
||||
iconPath: { dark: string; light: string; };
|
||||
iconPath: { dark: string; light?: string; };
|
||||
description?: ITaskHandlerDescription;
|
||||
iconClass?: string;
|
||||
}
|
||||
@@ -55,6 +55,6 @@ export interface ITaskRegistry {
|
||||
registerTask(id: string, command: ITaskHandler): IDisposable;
|
||||
registerTask(command: ITask): IDisposable;
|
||||
getTasks(): string[];
|
||||
getOrCreateTaskIconClassName(item: ICommandAction): string;
|
||||
getOrCreateTaskIconClassName(item: ICommandAction): string | undefined;
|
||||
onTaskRegistered: Event<string>;
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ export class TaskNode {
|
||||
/**
|
||||
* sever name
|
||||
*/
|
||||
public serverName: string;
|
||||
public serverName?: string;
|
||||
|
||||
/**
|
||||
* Database Name
|
||||
*/
|
||||
public databaseName: string;
|
||||
public databaseName?: string;
|
||||
|
||||
/**
|
||||
* Provider Name
|
||||
@@ -99,7 +99,7 @@ export class TaskNode {
|
||||
*/
|
||||
public script: string;
|
||||
|
||||
constructor(taskName: string, serverName: string, databaseName: string, taskId: string = undefined, taskExecutionMode: TaskExecutionMode = TaskExecutionMode.execute, isCancelable: boolean = true) {
|
||||
constructor(taskName: string, serverName?: string, databaseName?: string, taskId: string | undefined = undefined, taskExecutionMode: TaskExecutionMode = TaskExecutionMode.execute, isCancelable: boolean = true) {
|
||||
this.id = taskId || generateUuid();
|
||||
|
||||
this.taskName = taskName;
|
||||
|
||||
@@ -25,11 +25,11 @@ export interface ITaskService {
|
||||
handleTaskComplete(eventArgs: TaskStatusChangeArgs): void;
|
||||
getAllTasks(): TaskNode;
|
||||
getNumberOfInProgressTasks(): number;
|
||||
onNewTaskCreated(handle: number, taskInfo: azdata.TaskInfo);
|
||||
createNewTask(taskInfo: azdata.TaskInfo);
|
||||
updateTask(taskProgressInfo: azdata.TaskProgressInfo);
|
||||
onTaskStatusChanged(handle: number, taskProgressInfo: azdata.TaskProgressInfo);
|
||||
cancelTask(providerId: string, taskId: string): Thenable<boolean>;
|
||||
onNewTaskCreated(handle: number, taskInfo: azdata.TaskInfo): void;
|
||||
createNewTask(taskInfo: azdata.TaskInfo): void;
|
||||
updateTask(taskProgressInfo: azdata.TaskProgressInfo): void;
|
||||
onTaskStatusChanged(handle: number, taskProgressInfo: azdata.TaskProgressInfo): void;
|
||||
cancelTask(providerId: string, taskId: string): Promise<boolean | undefined>;
|
||||
/**
|
||||
* Register a ObjectExplorer provider
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ export class TaskService implements ITaskService {
|
||||
@IQueryEditorService private queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService private connectionManagementService: IConnectionManagementService
|
||||
) {
|
||||
this._taskQueue = new TaskNode('Root', undefined, undefined);
|
||||
this._taskQueue = new TaskNode('Root');
|
||||
this._onTaskComplete = new Emitter<TaskNode>();
|
||||
this._onAddNewTask = new Emitter<TaskNode>();
|
||||
|
||||
@@ -105,19 +105,21 @@ export class TaskService implements ITaskService {
|
||||
this.updateTask(taskProgressInfo);
|
||||
}
|
||||
|
||||
public cancelTask(providerId: string, taskId: string): Thenable<boolean> {
|
||||
public cancelTask(providerId: string, taskId: string): Promise<boolean | undefined> {
|
||||
let task = this.getTaskInQueue(taskId);
|
||||
task.status = TaskStatus.Canceling;
|
||||
this._onTaskComplete.fire(task);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
if (provider && provider.cancelTask) {
|
||||
return provider.cancelTask({
|
||||
taskId: taskId
|
||||
});
|
||||
if (task) {
|
||||
task.status = TaskStatus.Canceling;
|
||||
this._onTaskComplete.fire(task);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
if (provider && provider.cancelTask) {
|
||||
return Promise.resolve(provider.cancelTask({
|
||||
taskId: taskId
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
} else {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
@@ -222,7 +224,7 @@ export class TaskService implements ITaskService {
|
||||
|
||||
}
|
||||
|
||||
private getTaskInQueue(taskId: string): TaskNode {
|
||||
private getTaskInQueue(taskId: string): TaskNode | undefined {
|
||||
if (this._taskQueue.hasChildren) {
|
||||
return this._taskQueue.children.find(x => x.id === taskId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user