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:
Anthony Dresser
2019-09-18 12:27:19 -07:00
committed by GitHub
parent 373828d76f
commit aad9c0f965
35 changed files with 193 additions and 184 deletions

2
.vscode/tasks.json vendored
View File

@@ -45,7 +45,7 @@
{ {
"type": "npm", "type": "npm",
"script": "strict-null-check-watch", "script": "strict-null-check-watch",
"label": "TS - Strict Null Cheks", "label": "TS - Strict Null Checks",
"isBackground": true, "isBackground": true,
"presentation": { "presentation": {
"reveal": "never" "reveal": "never"

View File

@@ -67,7 +67,7 @@ declare module 'azdata' {
} }
export interface SerializeDataResult { export interface SerializeDataResult {
messages: string; messages?: string;
succeeded: boolean; succeeded: boolean;
} }

View File

@@ -19,7 +19,7 @@ export const IBackupService = createDecorator<IBackupService>(SERVICE_ID);
export interface IBackupService { export interface IBackupService {
_serviceBrand: undefined; _serviceBrand: undefined;
getBackupConfigInfo(connectionUri: string): Thenable<azdata.BackupConfigInfo>; getBackupConfigInfo(connectionUri: string): Promise<azdata.BackupConfigInfo | undefined>;
/** /**
* Backup a data source using the provided connection * Backup a data source using the provided connection

View File

@@ -27,12 +27,12 @@ export class BackupService implements IBackupService {
/** /**
* Get database metadata needed to populate backup UI * 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); let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) { if (providerId) {
let provider = this._providers[providerId]; let provider = this._providers[providerId];
if (provider) { if (provider) {
return provider.getBackupConfigInfo(connectionUri); return Promise.resolve(provider.getBackupConfigInfo(connectionUri));
} }
} }
return Promise.resolve(undefined); 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); let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) { if (providerId) {
return { provider: this._providers[providerId], providerName: providerId }; return { provider: this._providers[providerId], providerName: providerId };

View File

@@ -31,7 +31,7 @@ export class SingleConnectionMetadataService {
private _uri: string private _uri: string
) { } ) { }
get metadata(): Observable<ProviderMetadata> { get metadata(): Observable<ProviderMetadata | undefined> {
return Observable.fromPromise(this._metadataService.getMetadata(this._uri)); return Observable.fromPromise(this._metadataService.getMetadata(this._uri));
} }

View File

@@ -5,7 +5,7 @@
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension'; 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 { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@@ -35,12 +35,12 @@ export interface ICapabilitiesService {
/** /**
* Retrieve a list of registered capabilities providers * Retrieve a list of registered capabilities providers
*/ */
getCapabilities(provider: string): ProviderFeatures; getCapabilities(provider: string): ProviderFeatures | undefined;
/** /**
* get the old version of provider information * get the old version of provider information
*/ */
getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities; getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities | undefined;
/** /**
* Register a capabilities provider * Register a capabilities provider

View File

@@ -122,11 +122,11 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
/** /**
* Retrieve a list of registered server capabilities * Retrieve a list of registered server capabilities
*/ */
public getCapabilities(provider: string): ProviderFeatures { public getCapabilities(provider: string): ProviderFeatures | undefined {
return this._providers.get(provider); return this._providers.get(provider);
} }
public getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities { public getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities | undefined {
return this._legacyProviders.get(provider); return this._legacyProviders.get(provider);
} }

View File

@@ -23,11 +23,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
let connectionProvider: azdata.ConnectionOption[] = [ let connectionProvider: azdata.ConnectionOption[] = [
{ {
name: 'connectionName', name: 'connectionName',
displayName: undefined, displayName: undefined!,
description: undefined, description: undefined!,
groupName: undefined, groupName: undefined!,
categoryValues: undefined, categoryValues: undefined!,
defaultValue: undefined, defaultValue: undefined!,
isIdentity: true, isIdentity: true,
isRequired: true, isRequired: true,
specialValueType: ConnectionOptionSpecialType.connectionName, specialValueType: ConnectionOptionSpecialType.connectionName,
@@ -35,11 +35,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
}, },
{ {
name: 'serverName', name: 'serverName',
displayName: undefined, displayName: undefined!,
description: undefined, description: undefined!,
groupName: undefined, groupName: undefined!,
categoryValues: undefined, categoryValues: undefined!,
defaultValue: undefined, defaultValue: undefined!,
isIdentity: true, isIdentity: true,
isRequired: true, isRequired: true,
specialValueType: ConnectionOptionSpecialType.serverName, specialValueType: ConnectionOptionSpecialType.serverName,
@@ -47,11 +47,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
}, },
{ {
name: 'databaseName', name: 'databaseName',
displayName: undefined, displayName: undefined!,
description: undefined, description: undefined!,
groupName: undefined, groupName: undefined!,
categoryValues: undefined, categoryValues: undefined!,
defaultValue: undefined, defaultValue: undefined!,
isIdentity: true, isIdentity: true,
isRequired: true, isRequired: true,
specialValueType: ConnectionOptionSpecialType.databaseName, specialValueType: ConnectionOptionSpecialType.databaseName,
@@ -59,11 +59,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
}, },
{ {
name: 'userName', name: 'userName',
displayName: undefined, displayName: undefined!,
description: undefined, description: undefined!,
groupName: undefined, groupName: undefined!,
categoryValues: undefined, categoryValues: undefined!,
defaultValue: undefined, defaultValue: undefined!,
isIdentity: true, isIdentity: true,
isRequired: true, isRequired: true,
specialValueType: ConnectionOptionSpecialType.userName, specialValueType: ConnectionOptionSpecialType.userName,
@@ -71,11 +71,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
}, },
{ {
name: 'authenticationType', name: 'authenticationType',
displayName: undefined, displayName: undefined!,
description: undefined, description: undefined!,
groupName: undefined, groupName: undefined!,
categoryValues: undefined, categoryValues: undefined!,
defaultValue: undefined, defaultValue: undefined!,
isIdentity: true, isIdentity: true,
isRequired: true, isRequired: true,
specialValueType: ConnectionOptionSpecialType.authType, specialValueType: ConnectionOptionSpecialType.authType,
@@ -83,11 +83,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
}, },
{ {
name: 'password', name: 'password',
displayName: undefined, displayName: undefined!,
description: undefined, description: undefined!,
groupName: undefined, groupName: undefined!,
categoryValues: undefined, categoryValues: undefined!,
defaultValue: undefined, defaultValue: undefined!,
isIdentity: true, isIdentity: true,
isRequired: true, isRequired: true,
specialValueType: ConnectionOptionSpecialType.password, specialValueType: ConnectionOptionSpecialType.password,
@@ -125,7 +125,7 @@ export class TestCapabilitiesService implements ICapabilitiesService {
// Event Emitters // Event Emitters
public get onProviderRegisteredEvent(): Event<azdata.DataProtocolServerCapabilities> { public get onProviderRegisteredEvent(): Event<azdata.DataProtocolServerCapabilities> {
return undefined; return Event.None;
} }
public isFeatureAvailable(featureName: Action, connectionManagementInfo: ConnectionManagementInfo): boolean { public isFeatureAvailable(featureName: Action, connectionManagementInfo: ConnectionManagementInfo): boolean {
@@ -133,7 +133,7 @@ export class TestCapabilitiesService implements ICapabilitiesService {
} }
public onCapabilitiesReady(): Promise<void> { public onCapabilitiesReady(): Promise<void> {
return Promise.resolve(null); return Promise.resolve();
} }
public fireCapabilitiesRegistered(providerFeatures: ProviderFeatures): void { public fireCapabilitiesRegistered(providerFeatures: ProviderFeatures): void {

View File

@@ -13,7 +13,7 @@ export const FILE_SCHEMA: string = 'file';
export function resolveCurrentDirectory(uri: string, rootPath: string): string | undefined { export function resolveCurrentDirectory(uri: string, rootPath: string): string | undefined {
let sqlUri = URI.parse(uri); let sqlUri = URI.parse(uri);
let currentDirectory: string; let currentDirectory: string | undefined;
// use current directory of the sql file if sql file is saved // use current directory of the sql file if sql file is saved
if (sqlUri.scheme === FILE_SCHEMA) { if (sqlUri.scheme === FILE_SCHEMA) {
@@ -30,12 +30,15 @@ export function resolveCurrentDirectory(uri: string, rootPath: string): string |
return currentDirectory; 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); let currentDirectory = resolveCurrentDirectory(uri, rootPath);
if (currentDirectory) {
return normalize(join(currentDirectory, filePath)); 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; let isWorkspace = contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
if (isWorkspace) { if (isWorkspace) {
let folder = contextService.getWorkspace().folders[0]; let folder = contextService.getWorkspace().folders[0];

View File

@@ -110,7 +110,7 @@ export interface IConnectionManagementService {
onIntelliSenseCacheComplete(handle: number, connectionUri: string): void; onIntelliSenseCacheComplete(handle: number, connectionUri: string): void;
onConnectionChangedNotification(handle: number, changedConnInfo: azdata.ChangedConnectionInfo); onConnectionChangedNotification(handle: number, changedConnInfo: azdata.ChangedConnectionInfo): void;
getConnectionGroups(providers?: string[]): ConnectionProfileGroup[]; getConnectionGroups(providers?: string[]): ConnectionProfileGroup[];

View File

@@ -22,7 +22,7 @@ import * as Constants from 'sql/platform/connection/common/constants';
*/ */
export class ConnectionProfile extends ProviderConnectionInfo implements interfaces.IConnectionProfile { export class ConnectionProfile extends ProviderConnectionInfo implements interfaces.IConnectionProfile {
public parent: ConnectionProfileGroup = null; public parent?: ConnectionProfileGroup;
private _id: string; private _id: string;
public savePassword: boolean; public savePassword: boolean;
private _groupName: string; private _groupName: string;
@@ -88,7 +88,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
this._id = generateUuid(); this._id = generateUuid();
} }
public getParent(): ConnectionProfileGroup { public getParent(): ConnectionProfileGroup | undefined {
return this.parent; return this.parent;
} }
@@ -103,11 +103,11 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
this._id = value; this._id = value;
} }
public get azureTenantId(): string { public get azureTenantId(): string | undefined {
return this.options['azureTenantId']; return this.options['azureTenantId'];
} }
public set azureTenantId(value: string) { public set azureTenantId(value: string | undefined) {
this.options['azureTenantId'] = value; this.options['azureTenantId'] = value;
} }
@@ -185,7 +185,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
databaseName: this.databaseName, databaseName: this.databaseName,
authenticationType: this.authenticationType, authenticationType: this.authenticationType,
getOptionsKey: this.getOptionsKey, getOptionsKey: this.getOptionsKey,
matches: undefined, matches: this.matches,
groupId: this.groupId, groupId: this.groupId,
groupFullName: this.groupFullName, groupFullName: this.groupFullName,
password: this.password, password: this.password,
@@ -244,9 +244,10 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
public static convertToProfileStore( public static convertToProfileStore(
capabilitiesService: ICapabilitiesService, capabilitiesService: ICapabilitiesService,
connectionProfile: interfaces.IConnectionProfile): interfaces.IConnectionProfileStore { connectionProfile: interfaces.IConnectionProfile): interfaces.IConnectionProfileStore | undefined {
if (connectionProfile) { if (connectionProfile) {
let connectionInfo = ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile); let connectionInfo = ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile);
if (connectionInfo) {
let profile: interfaces.IConnectionProfileStore = { let profile: interfaces.IConnectionProfileStore = {
options: {}, options: {},
groupId: connectionProfile.groupId, groupId: connectionProfile.groupId,
@@ -258,8 +259,9 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
profile.options = connectionInfo.options; profile.options = connectionInfo.options;
return profile; return profile;
} else { }
}
return undefined; return undefined;
} }
}
} }

View File

@@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
export interface IConnectionProfileGroup { export interface IConnectionProfileGroup {
id: string; id: string;
parentId: string; parentId?: string;
name: string; name: string;
color: string; color: string;
description: string; description: string;
@@ -18,7 +18,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
public children: ConnectionProfileGroup[]; public children: ConnectionProfileGroup[];
public connections: ConnectionProfile[]; public connections: ConnectionProfile[];
public parentId: string; public parentId?: string;
private _isRenamed: boolean; private _isRenamed: boolean;
public constructor( public constructor(
public name: string, public name: string,
@@ -53,8 +53,8 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
return this.name; return this.name;
} }
public get fullName(): string { public get fullName(): string | undefined {
let fullName: string = (this.id === 'root') ? undefined : this.name; let fullName: string | undefined = (this.id === 'root') ? undefined : this.name;
if (this.parent) { if (this.parent) {
let parentFullName = this.parent.fullName; let parentFullName = this.parent.fullName;
if (parentFullName) { if (parentFullName) {
@@ -156,7 +156,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
public isAncestorOf(node: ConnectionProfileGroup | ConnectionProfile): boolean { public isAncestorOf(node: ConnectionProfileGroup | ConnectionProfile): boolean {
let isAncestor = false; let isAncestor = false;
let currentNode = node; let currentNode: ConnectionProfileGroup | ConnectionProfile | undefined = node;
while (currentNode) { while (currentNode) {
if (currentNode.parent && currentNode.parent.id === this.id) { if (currentNode.parent && currentNode.parent.id === this.id) {
isAncestor = true; isAncestor = true;
@@ -195,7 +195,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
} }
public static getConnectionsInGroup(group: ConnectionProfileGroup): ConnectionProfile[] { public static getConnectionsInGroup(group: ConnectionProfileGroup): ConnectionProfile[] {
let connections = []; let connections: ConnectionProfile[] = [];
if (group && group.connections) { if (group && group.connections) {
group.connections.forEach((con) => connections.push(con)); group.connections.forEach((con) => connections.push(con));
} }
@@ -208,7 +208,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
} }
public static getSubgroups(group: ConnectionProfileGroup): ConnectionProfileGroup[] { public static getSubgroups(group: ConnectionProfileGroup): ConnectionProfileGroup[] {
let subgroups = []; let subgroups: ConnectionProfileGroup[] = [];
if (group && group.children) { if (group && group.children) {
group.children.forEach((grp) => subgroups.push(grp)); group.children.forEach((grp) => subgroups.push(grp));
group.children.forEach((subgroup) => { group.children.forEach((subgroup) => {

View File

@@ -104,27 +104,27 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
} }
public get connectionName(): string { public get connectionName(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.connectionName); return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.connectionName)!;
} }
public get serverName(): string { public get serverName(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.serverName); return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.serverName)!;
} }
public get databaseName(): string { public get databaseName(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.databaseName); return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.databaseName)!;
} }
public get userName(): string { public get userName(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.userName); return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.userName)!;
} }
public get password(): string { public get password(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.password); return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.password)!;
} }
public get authenticationType(): string { public get authenticationType(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.authType); return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.authType)!;
} }
public set connectionName(value: string) { public set connectionName(value: string) {
@@ -206,7 +206,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
return isPasswordRequired; return isPasswordRequired;
} }
private getSpecialTypeOptionValue(type: string): string { private getSpecialTypeOptionValue(type: string): string | undefined {
let name = this.getSpecialTypeOptionName(type); let name = this.getSpecialTypeOptionName(type);
if (name) { if (name) {
return this.options[name]; return this.options[name];
@@ -243,7 +243,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
let idValues: string[] = []; let idValues: string[] = [];
for (let index = 0; index < idNames.length; index++) { for (let index = 0; index < idNames.length; index++) {
let value = this.options[idNames[index]]; let value = this.options[idNames[index]!];
value = value ? value : ''; value = value ? value : '';
idValues.push(`${idNames[index]}${ProviderConnectionInfo.nameValueSeparator}${value}`); idValues.push(`${idNames[index]}${ProviderConnectionInfo.nameValueSeparator}${value}`);
} }
@@ -266,7 +266,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
return providerId; return providerId;
} }
public getSpecialTypeOptionName(type: string): string { public getSpecialTypeOptionName(type: string): string | undefined {
if (this._serverCapabilities) { if (this._serverCapabilities) {
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === type); let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === type);
return !!optionMetadata ? optionMetadata.name : undefined; return !!optionMetadata ? optionMetadata.name : undefined;

View File

@@ -31,7 +31,7 @@ suite('ConnectionStore', () => {
groupId: '', groupId: '',
groupFullName: '', groupFullName: '',
getOptionsKey: undefined, getOptionsKey: undefined,
matches: undefined, matches: () => false,
providerName: mssqlProviderName, providerName: mssqlProviderName,
options: {}, options: {},
saveProfile: true, saveProfile: true,

View File

@@ -46,7 +46,7 @@ export class FileBrowserService implements IFileBrowserService {
return this._onPathValidate.event; 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) => { return new Promise<boolean>((resolve, reject) => {
const provider = this.getProvider(ownerUri); const provider = this.getProvider(ownerUri);
if (provider) { if (provider) {
@@ -67,7 +67,7 @@ export class FileBrowserService implements IFileBrowserService {
&& fileBrowserOpenedParams.fileTree.rootNode && fileBrowserOpenedParams.fileTree.rootNode
&& fileBrowserOpenedParams.fileTree.selectedNode && 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 }); this._onAddFileTree.fire({ rootNode: fileTree.rootNode, selectedNode: fileTree.selectedNode, expandedNodes: fileTree.expandedNodes });
} else { } else {
let genericErrorMessage = localize('fileBrowserErrorMessage', "An error occured while loading the file browser."); 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; this._pathToFileNodeMap[fileNode.fullPath] = fileNode;
let self = this; let self = this;
return new Promise<FileNode[]>((resolve, reject) => { 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) => { return new Promise<boolean>((resolve, reject) => {
const provider = this.getProvider(ownerUri); const provider = this.getProvider(ownerUri);
if (provider) { if (provider) {
@@ -136,10 +136,10 @@ export class FileBrowserService implements IFileBrowserService {
this._onPathValidate.fire(fileBrowserValidatedParams); this._onPathValidate.fire(fileBrowserValidatedParams);
} }
public closeFileBrowser(ownerUri: string): Thenable<azdata.FileBrowserCloseResponse> { public closeFileBrowser(ownerUri: string): Promise<azdata.FileBrowserCloseResponse | undefined> {
let provider = this.getProvider(ownerUri); let provider = this.getProvider(ownerUri);
if (provider) { if (provider) {
return provider.closeFileBrowser(ownerUri); return Promise.resolve(provider.closeFileBrowser(ownerUri));
} }
return Promise.resolve(undefined); return Promise.resolve(undefined);
} }
@@ -147,7 +147,8 @@ export class FileBrowserService implements IFileBrowserService {
private generateResolveMapKey(ownerUri: string, expandPath: string): string { private generateResolveMapKey(ownerUri: string, expandPath: string): string {
return ownerUri + ':' + expandPath; return ownerUri + ':' + expandPath;
} }
private getProvider(connectionUri: string): azdata.FileBrowserProvider {
private getProvider(connectionUri: string): azdata.FileBrowserProvider | undefined {
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri); let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) { if (providerId) {
return this._providers[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; FileBrowserService.fileNodeId += 1;
let expandedNodes: FileNode[] = []; let expandedNodes: FileNode[] = [];
let selectedNode: FileNode; let selectedNode: FileNode | undefined;
let fileNode = new FileNode(FileBrowserService.fileNodeId.toString(), let fileNode = new FileNode(FileBrowserService.fileNodeId.toString(),
fileTreeNode.name, fileTreeNode.name,
fileTreeNode.fullPath, fileTreeNode.fullPath,

View File

@@ -24,35 +24,35 @@ export interface IFileBrowserService {
/** /**
* Open file browser * 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 * Event called when file browser is opened
*/ */
onFileBrowserOpened(handle: number, fileBrowserOpenedParams: azdata.FileBrowserOpenedParams); onFileBrowserOpened(handle: number, fileBrowserOpenedParams: azdata.FileBrowserOpenedParams): void;
/** /**
* Expand folder node * Expand folder node
*/ */
expandFolderNode(fileNode: FileNode): Thenable<FileNode[]>; expandFolderNode(fileNode: FileNode): Promise<FileNode[]>;
/** /**
* Event called when children nodes are retrieved * Event called when children nodes are retrieved
*/ */
onFolderNodeExpanded(handle: number, fileBrowserExpandedParams: azdata.FileBrowserExpandedParams); onFolderNodeExpanded(handle: number, fileBrowserExpandedParams: azdata.FileBrowserExpandedParams): void;
/** /**
* Validate selected file paths * 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 * Event called when the validation is complete
*/ */
onFilePathsValidated(handle: number, fileBrowserValidatedParams: azdata.FileBrowserValidatedParams); onFilePathsValidated(handle: number, fileBrowserValidatedParams: azdata.FileBrowserValidatedParams): void;
/** /**
* Close file browser * Close file browser
*/ */
closeFileBrowser(ownerUri: string): Thenable<azdata.FileBrowserCloseResponse>; closeFileBrowser(ownerUri: string): Promise<azdata.FileBrowserCloseResponse | undefined>;
} }

View File

@@ -14,13 +14,13 @@ export const IMetadataService = createDecorator<IMetadataService>(SERVICE_ID);
export interface IMetadataService { export interface IMetadataService {
_serviceBrand: undefined; _serviceBrand: undefined;
getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata>; getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata | undefined>;
getDatabaseNames(connectionUri: string): Thenable<string[]>; 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 * Register a metadata provider
@@ -37,7 +37,7 @@ export class MetadataService implements IMetadataService {
constructor(@IConnectionManagementService private _connectionService: IConnectionManagementService) { 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); let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) { if (providerId) {
let provider = this._providers[providerId]; let provider = this._providers[providerId];
@@ -61,7 +61,7 @@ export class MetadataService implements IMetadataService {
return Promise.resolve([]); 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); let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) { if (providerId) {
let provider = this._providers[providerId]; let provider = this._providers[providerId];
@@ -73,7 +73,7 @@ export class MetadataService implements IMetadataService {
return Promise.resolve(undefined); 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); let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) { if (providerId) {
let provider = this._providers[providerId]; let provider = this._providers[providerId];

View File

@@ -27,7 +27,7 @@ export interface IModelView extends IView {
setProperties(componentId: string, properties: { [key: string]: any }): void; setProperties(componentId: string, properties: { [key: string]: any }): void;
setDataProvider(handle: number, componentId: string, context: any): void; setDataProvider(handle: number, componentId: string, context: any): void;
refreshDataProvider(componentId: string, item: any): void; refreshDataProvider(componentId: string, item: any): void;
registerEvent(componentId: string); registerEvent(componentId: string): void;
onEvent: Event<IModelViewEventArgs>; onEvent: Event<IModelViewEventArgs>;
validate(componentId: string): Thenable<boolean>; validate(componentId: string): Thenable<boolean>;
readonly onDestroy: Event<void>; readonly onDestroy: Event<void>;

View File

@@ -13,7 +13,7 @@ export const SERVICE_ID = 'modelViewService';
export interface IModelViewService { export interface IModelViewService {
_serviceBrand: undefined; _serviceBrand: undefined;
onRegisteredModelView: Event<IModelView>; onRegisteredModelView: Event<IModelView>;
registerModelView(widget: IModelView); registerModelView(widget: IModelView): void;
} }
export const IModelViewService = createDecorator<IModelViewService>(SERVICE_ID); export const IModelViewService = createDecorator<IModelViewService>(SERVICE_ID);

View File

@@ -23,10 +23,4 @@ export interface ISqlOAuthService {
* @return Promise to return an authorization code * @return Promise to return an authorization code
*/ */
performOAuthAuthorization(eventId: string, url: string, silent: boolean): void; 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;
} }

View File

@@ -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);
}
} }

View File

@@ -25,7 +25,7 @@ export enum ScriptOperation {
export interface IScriptingService { export interface IScriptingService {
_serviceBrand: undefined; _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 * Register a scripting provider
@@ -45,7 +45,7 @@ export interface IScriptingService {
/** /**
* Returns the result for an operation if the operation failed * 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 { 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 * 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); let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) { if (providerId) {
@@ -91,7 +91,7 @@ export class ScriptingService implements IScriptingService {
* Returns the result for an operation if the operation failed * Returns the result for an operation if the operation failed
* @param operationId Operation Id * @param operationId Operation Id
*/ */
public getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult { public getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult | undefined {
if (operationId && operationId in this.failedScriptingOperations) { if (operationId && operationId in this.failedScriptingOperations) {
return this.failedScriptingOperations[operationId]; return this.failedScriptingOperations[operationId];
} else { } else {

View File

@@ -51,7 +51,7 @@ export interface ISerializationService {
serializeResults(request: SerializeDataParams): Promise<azdata.SerializeDataResult>; serializeResults(request: SerializeDataParams): Promise<azdata.SerializeDataResult>;
getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider; getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider | undefined;
} }
function getBatchSize(totalRows: number, currentIndex: number): number { 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 providerId: string = this._connectionService.getProviderIdFromUri(ownerUri);
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId); let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);

View File

@@ -28,7 +28,7 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
let disposable: IDisposable; let disposable: IDisposable;
let id: string; let id: string;
if (types.isString(idOrTask)) { if (types.isString(idOrTask)) {
disposable = CommandsRegistry.registerCommand(idOrTask, handler); disposable = CommandsRegistry.registerCommand(idOrTask, handler!);
id = idOrTask; id = idOrTask;
} else { } else {
if (idOrTask.iconClass) { if (idOrTask.iconClass) {
@@ -52,8 +52,8 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
}; };
} }
getOrCreateTaskIconClassName(item: ICommandAction): string { getOrCreateTaskIconClassName(item: ICommandAction): string | undefined {
let iconClass = null; let iconClass: string | undefined;
if (this.taskIdToIconClassNameMap.has(item.id)) { if (this.taskIdToIconClassNameMap.has(item.id)) {
iconClass = this.taskIdToIconClassNameMap.get(item.id); iconClass = this.taskIdToIconClassNameMap.get(item.id);
} else if (item.iconLocation) { } else if (item.iconLocation) {
@@ -74,17 +74,19 @@ export abstract class Task {
public readonly id: string; public readonly id: string;
public readonly title: string; public readonly title: string;
public readonly iconPathDark: string; public readonly iconPathDark: string;
public readonly iconPath: { dark: URI; light?: URI; }; public readonly iconPath?: { dark: URI; light?: URI; };
private readonly _iconClass: string; private readonly _iconClass?: string;
private readonly _description: ITaskHandlerDescription; private readonly _description?: ITaskHandlerDescription;
constructor(private opts: ITaskOptions) { constructor(private opts: ITaskOptions) {
this.id = opts.id; this.id = opts.id;
this.title = opts.title; this.title = opts.title;
if (opts.iconPath.dark) {
this.iconPath = { this.iconPath = {
dark: opts.iconPath ? URI.parse(opts.iconPath.dark) : undefined, dark: URI.parse(opts.iconPath.dark),
light: opts.iconPath ? URI.parse(opts.iconPath.light) : undefined, light: opts.iconPath.light ? URI.parse(opts.iconPath.light) : undefined,
}; };
}
this._iconClass = opts.iconClass; this._iconClass = opts.iconClass;
this._description = opts.description; this._description = opts.description;
} }

View File

@@ -16,7 +16,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
export interface ITaskOptions { export interface ITaskOptions {
id: string; id: string;
title: string; title: string;
iconPath: { dark: string; light: string; }; iconPath: { dark: string; light?: string; };
description?: ITaskHandlerDescription; description?: ITaskHandlerDescription;
iconClass?: string; iconClass?: string;
} }
@@ -55,6 +55,6 @@ export interface ITaskRegistry {
registerTask(id: string, command: ITaskHandler): IDisposable; registerTask(id: string, command: ITaskHandler): IDisposable;
registerTask(command: ITask): IDisposable; registerTask(command: ITask): IDisposable;
getTasks(): string[]; getTasks(): string[];
getOrCreateTaskIconClassName(item: ICommandAction): string; getOrCreateTaskIconClassName(item: ICommandAction): string | undefined;
onTaskRegistered: Event<string>; onTaskRegistered: Event<string>;
} }

View File

@@ -36,12 +36,12 @@ export class TaskNode {
/** /**
* sever name * sever name
*/ */
public serverName: string; public serverName?: string;
/** /**
* Database Name * Database Name
*/ */
public databaseName: string; public databaseName?: string;
/** /**
* Provider Name * Provider Name
@@ -99,7 +99,7 @@ export class TaskNode {
*/ */
public script: string; 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.id = taskId || generateUuid();
this.taskName = taskName; this.taskName = taskName;

View File

@@ -25,11 +25,11 @@ export interface ITaskService {
handleTaskComplete(eventArgs: TaskStatusChangeArgs): void; handleTaskComplete(eventArgs: TaskStatusChangeArgs): void;
getAllTasks(): TaskNode; getAllTasks(): TaskNode;
getNumberOfInProgressTasks(): number; getNumberOfInProgressTasks(): number;
onNewTaskCreated(handle: number, taskInfo: azdata.TaskInfo); onNewTaskCreated(handle: number, taskInfo: azdata.TaskInfo): void;
createNewTask(taskInfo: azdata.TaskInfo); createNewTask(taskInfo: azdata.TaskInfo): void;
updateTask(taskProgressInfo: azdata.TaskProgressInfo); updateTask(taskProgressInfo: azdata.TaskProgressInfo): void;
onTaskStatusChanged(handle: number, taskProgressInfo: azdata.TaskProgressInfo); onTaskStatusChanged(handle: number, taskProgressInfo: azdata.TaskProgressInfo): void;
cancelTask(providerId: string, taskId: string): Thenable<boolean>; cancelTask(providerId: string, taskId: string): Promise<boolean | undefined>;
/** /**
* Register a ObjectExplorer provider * Register a ObjectExplorer provider
*/ */
@@ -56,7 +56,7 @@ export class TaskService implements ITaskService {
@IQueryEditorService private queryEditorService: IQueryEditorService, @IQueryEditorService private queryEditorService: IQueryEditorService,
@IConnectionManagementService private connectionManagementService: IConnectionManagementService @IConnectionManagementService private connectionManagementService: IConnectionManagementService
) { ) {
this._taskQueue = new TaskNode('Root', undefined, undefined); this._taskQueue = new TaskNode('Root');
this._onTaskComplete = new Emitter<TaskNode>(); this._onTaskComplete = new Emitter<TaskNode>();
this._onAddNewTask = new Emitter<TaskNode>(); this._onAddNewTask = new Emitter<TaskNode>();
@@ -105,20 +105,22 @@ export class TaskService implements ITaskService {
this.updateTask(taskProgressInfo); 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); let task = this.getTaskInQueue(taskId);
if (task) {
task.status = TaskStatus.Canceling; task.status = TaskStatus.Canceling;
this._onTaskComplete.fire(task); this._onTaskComplete.fire(task);
if (providerId) { if (providerId) {
let provider = this._providers[providerId]; let provider = this._providers[providerId];
if (provider && provider.cancelTask) { if (provider && provider.cancelTask) {
return provider.cancelTask({ return Promise.resolve(provider.cancelTask({
taskId: taskId taskId: taskId
}); }));
} }
} else { } else {
return Promise.resolve(true); return Promise.resolve(true);
} }
}
return Promise.resolve(undefined); 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) { if (this._taskQueue.hasChildren) {
return this._taskQueue.children.find(x => x.id === taskId); return this._taskQueue.children.find(x => x.id === taskId);
} }

View File

@@ -14,7 +14,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
export interface IComponent extends IDisposable { export interface IComponent extends IDisposable {
descriptor: IComponentDescriptor; descriptor: IComponentDescriptor;
modelStore: IModelStore; modelStore: IModelStore;
layout(); layout(): void;
registerEventHandler(handler: (event: IComponentEventArgs) => void): IDisposable; registerEventHandler(handler: (event: IComponentEventArgs) => void): IDisposable;
clearContainer?: () => void; clearContainer?: () => void;
addToContainer?: (componentDescriptor: IComponentDescriptor, config: any, index?: number) => void; addToContainer?: (componentDescriptor: IComponentDescriptor, config: any, index?: number) => void;
@@ -76,7 +76,7 @@ export interface IModelStore {
* Creates and saves the reference of a component descriptor. * Creates and saves the reference of a component descriptor.
* This can be used during creation of a component later * This can be used during creation of a component later
*/ */
createComponentDescriptor(type: string, createComponentDescriptor): IComponentDescriptor; createComponentDescriptor(type: string, createComponentDescriptor: string): IComponentDescriptor;
/** /**
* gets the descriptor for a previously created component ID * gets the descriptor for a previously created component ID
*/ */

View File

@@ -47,7 +47,7 @@ export function scriptSelect(connectionProfile: IConnectionProfile, metadata: az
connectionService.connectIfNotConnected(connectionProfile).then(connectionResult => { connectionService.connectIfNotConnected(connectionProfile).then(connectionResult => {
let paramDetails: azdata.ScriptingParamDetails = getScriptingParamDetails(connectionService, connectionResult, metadata); let paramDetails: azdata.ScriptingParamDetails = getScriptingParamDetails(connectionService, connectionResult, metadata);
scriptingService.script(connectionResult, metadata, ScriptOperation.Select, paramDetails).then(result => { scriptingService.script(connectionResult, metadata, ScriptOperation.Select, paramDetails).then(result => {
if (result.script) { if (result && result.script) {
queryEditorService.newSqlEditor(result.script).then((owner: IConnectableInput) => { queryEditorService.newSqlEditor(result.script).then((owner: IConnectableInput) => {
// Connect our editor to the input connection // Connect our editor to the input connection
let options: IConnectionCompletionOptions = { let options: IConnectionCompletionOptions = {
@@ -82,7 +82,7 @@ export function scriptEditSelect(connectionProfile: IConnectionProfile, metadata
connectionService.connectIfNotConnected(connectionProfile).then(connectionResult => { connectionService.connectIfNotConnected(connectionProfile).then(connectionResult => {
let paramDetails: azdata.ScriptingParamDetails = getScriptingParamDetails(connectionService, connectionResult, metadata); let paramDetails: azdata.ScriptingParamDetails = getScriptingParamDetails(connectionService, connectionResult, metadata);
scriptingService.script(connectionResult, metadata, ScriptOperation.Select, paramDetails).then(result => { scriptingService.script(connectionResult, metadata, ScriptOperation.Select, paramDetails).then(result => {
if (result.script) { if (result && result.script) {
queryEditorService.newEditDataEditor(metadata.schema, metadata.name, result.script).then((owner: EditDataInput) => { queryEditorService.newEditDataEditor(metadata.schema, metadata.name, result.script).then((owner: EditDataInput) => {
// Connect our editor // Connect our editor
let options: IConnectionCompletionOptions = { let options: IConnectionCompletionOptions = {

View File

@@ -26,7 +26,7 @@ export const Extensions = {
export interface IConnectionProviderRegistry { export interface IConnectionProviderRegistry {
registerConnectionProvider(id: string, properties: ConnectionProviderProperties): void; registerConnectionProvider(id: string, properties: ConnectionProviderProperties): void;
getProperties(id: string): ConnectionProviderProperties; getProperties(id: string): ConnectionProviderProperties | undefined;
readonly onNewProvider: Event<{ id: string, properties: ConnectionProviderProperties }>; readonly onNewProvider: Event<{ id: string, properties: ConnectionProviderProperties }>;
readonly providers: { [id: string]: ConnectionProviderProperties }; readonly providers: { [id: string]: ConnectionProviderProperties };
} }
@@ -41,7 +41,7 @@ class ConnectionProviderRegistryImpl implements IConnectionProviderRegistry {
this._onNewProvider.fire({ id, properties }); this._onNewProvider.fire({ id, properties });
} }
public getProperties(id: string): ConnectionProviderProperties { public getProperties(id: string): ConnectionProviderProperties | undefined {
return this._providers.get(id); return this._providers.get(id);
} }

View File

@@ -257,7 +257,7 @@ class DataResourceDataProvider implements IGridDataProvider {
return serializer.handleSerialization(this.documentUri, format, (filePath) => this.doSerialize(serializer, filePath, format, selection)); return serializer.handleSerialization(this.documentUri, format, (filePath) => this.doSerialize(serializer, filePath, format, selection));
} }
private async doSerialize(serializer: ResultSerializer, filePath: string, format: SaveFormat, selection: Slick.Range[]): Promise<SaveResultsResponse> { private doSerialize(serializer: ResultSerializer, filePath: string, format: SaveFormat, selection: Slick.Range[]): Promise<SaveResultsResponse | undefined> {
// TODO implement selection support // TODO implement selection support
let columns = this.resultSet.columnInfo; let columns = this.resultSet.columnInfo;
let rowLength = this.rows.length; let rowLength = this.rows.length;
@@ -296,8 +296,7 @@ class DataResourceDataProvider implements IGridDataProvider {
getRowRange: (rowStart, numberOfRows) => getRows(rowStart, numberOfRows), getRowRange: (rowStart, numberOfRows) => getRows(rowStart, numberOfRows),
rowCount: rowLength rowCount: rowLength
}); });
let result = await this._serializationService.serializeResults(serializeRequestParams); return this._serializationService.serializeResults(serializeRequestParams);
return result;
} }
/** /**

View File

@@ -32,7 +32,7 @@ let prevSavePath: string;
export interface SaveResultsResponse { export interface SaveResultsResponse {
succeeded: boolean; succeeded: boolean;
messages: string; messages?: string;
} }
interface ICsvConfig { interface ICsvConfig {
@@ -94,7 +94,7 @@ export class ResultSerializer {
/** /**
* Handle save request by getting filename from user and sending request to service * Handle save request by getting filename from user and sending request to service
*/ */
public handleSerialization(uri: string, format: SaveFormat, sendRequest: ((filePath: string) => Promise<SaveResultsResponse>)): Thenable<void> { public handleSerialization(uri: string, format: SaveFormat, sendRequest: ((filePath: string) => Promise<SaveResultsResponse | undefined>)): Thenable<void> {
const self = this; const self = this;
return this.promptForFilepath(format, uri).then(filePath => { return this.promptForFilepath(format, uri).then(filePath => {
if (filePath) { if (filePath) {
@@ -103,7 +103,7 @@ export class ResultSerializer {
} }
return self.doSave(filePath, format, () => sendRequest(filePath)); return self.doSave(filePath, format, () => sendRequest(filePath));
} }
return Promise.resolve(undefined); return Promise.resolve();
}); });
} }
@@ -331,19 +331,19 @@ export class ResultSerializer {
/** /**
* Send request to sql tools service to save a result set * Send request to sql tools service to save a result set
*/ */
private async doSave(filePath: string, format: string, sendRequest: () => Promise<SaveResultsResponse>): Promise<void> { private async doSave(filePath: string, format: string, sendRequest: () => Promise<SaveResultsResponse | undefined>): Promise<void> {
this.logToOutputChannel(LocalizedConstants.msgSaveStarted + filePath); this.logToOutputChannel(LocalizedConstants.msgSaveStarted + filePath);
// send message to the sqlserverclient for converting results to the requested format and saving to filepath // send message to the sqlserverclient for converting results to the requested format and saving to filepath
try { try {
let result = await sendRequest(); let result = await sendRequest();
if (result.messages) { if (!result || result.messages) {
this._notificationService.notify({ this._notificationService.notify({
severity: Severity.Error, severity: Severity.Error,
message: LocalizedConstants.msgSaveFailed + result.messages message: LocalizedConstants.msgSaveFailed + (result ? result.messages : '')
}); });
this.logToOutputChannel(LocalizedConstants.msgSaveFailed + result.messages); this.logToOutputChannel(LocalizedConstants.msgSaveFailed + (result ? result.messages : ''));
} else { } else {
this.promptFileSavedNotification(filePath); this.promptFileSavedNotification(filePath);
this.logToOutputChannel(LocalizedConstants.msgSaveSucceeded + filePath); this.logToOutputChannel(LocalizedConstants.msgSaveSucceeded + filePath);

View File

@@ -10,6 +10,6 @@ import { FileNode } from 'sql/workbench/services/fileBrowser/common/fileNode';
*/ */
export class FileBrowserTree { export class FileBrowserTree {
public rootNode: FileNode; public rootNode: FileNode;
public selectedNode: FileNode; public selectedNode?: FileNode;
public expandedNodes: FileNode[]; public expandedNodes: FileNode[];
} }

View File

@@ -33,7 +33,7 @@ export class FileNode {
/** /**
* Parent node * Parent node
*/ */
public parent: FileNode; public parent?: FileNode;
/** /**
* Children nodes * Children nodes
@@ -55,7 +55,7 @@ export class FileNode {
*/ */
public hasChildren: boolean; public hasChildren: boolean;
constructor(id: string, name: string, fullPath: string, isFile: boolean, isExpanded: boolean, ownerUri: string, parent: FileNode) { constructor(id: string, name: string, fullPath: string, isFile: boolean, isExpanded: boolean, ownerUri: string, parent?: FileNode) {
if (id) { if (id) {
this.id = id; this.id = id;
} else { } else {

View File

@@ -5,7 +5,7 @@
"strictNullChecks": true, "strictNullChecks": true,
"noImplicitAny": true, "noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true, "suppressImplicitAnyIndexErrors": true,
"skipLibCheck": true, "skipLibCheck": true
}, },
"include": [ "include": [
"./typings", "./typings",
@@ -18,10 +18,24 @@
"./sql/base/**/*.ts", "./sql/base/**/*.ts",
"./sql/editor/**/*.ts", "./sql/editor/**/*.ts",
"./sql/platform/angularEventing/**/*.ts", "./sql/platform/angularEventing/**/*.ts",
// "./sql/platform/accounts/**/*.ts", "./sql/platform/backup/**/*.ts",
"./sql/platform/browser/**/*.ts",
"./sql/platform/capabilities/**/*.ts",
"./sql/platform/clipboard/**/*.ts", "./sql/platform/clipboard/**/*.ts",
"./sql/platform/common/**/*.ts",
"./sql/platform/credentials/**/*.ts", "./sql/platform/credentials/**/*.ts",
"./sql/platform/theme/**/*.ts", "./sql/platform/errorMessage/**/*.ts",
"./sql/platform/telemetry/**/*.ts" "./sql/platform/fileBrowser/**/*.ts",
"./sql/platform/metadata/**/*.ts",
"./sql/platform/model/**/*.ts",
"./sql/platform/modelComponents/**/*.ts",
"./sql/platform/notebooks/**/*.ts",
"./sql/platform/oAuth/**/*.ts",
"./sql/platform/scripting/**/*.ts",
"./sql/platform/serialization/**/*.ts",
"./sql/platform/serverGroup/**/*.ts",
"./sql/platform/tasks/**/*.ts",
"./sql/platform/telemetry/**/*.ts",
"./sql/platform/theme/**/*.ts"
] ]
} }