Extensions Cleanup (#359)

* clean up extensions

* updated copyrights

* formatting
This commit is contained in:
Anthony Dresser
2017-12-20 21:35:52 -08:00
committed by GitHub
parent b1b3a92717
commit 8afebd2e10
72 changed files with 2352 additions and 5359 deletions

View File

@@ -1,13 +1,14 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as Contracts from '../models/contracts';
import { ICredentialStore } from './icredentialstore';
import { SqlToolsServiceClient, Utils } from 'extensions-modules';
import { LanguageClient } from 'dataprotocol-client';
import * as path from 'path';
/**
* Implements a credential storage for Windows, Mac (darwin), or Linux.
@@ -16,58 +17,58 @@ import { LanguageClient } from 'dataprotocol-client';
*/
export class CredentialStore implements ICredentialStore {
public languageClient: LanguageClient;
public languageClient: LanguageClient;
constructor(private _client?: SqlToolsServiceClient) {
if (!this._client) {
this._client = SqlToolsServiceClient.instance;
}
}
constructor(private _client?: SqlToolsServiceClient) {
if (!this._client) {
this._client = SqlToolsServiceClient.getInstance(path.join(__dirname, '../config.json'));
}
}
/**
* Gets a credential saved in the credential store
*
* @param {string} credentialId the ID uniquely identifying this credential
* @returns {Promise<Credential>} Promise that resolved to the credential, or undefined if not found
*/
public readCredential(credentialId: string): Promise<Contracts.Credential> {
Utils.logDebug(this.languageClient, 'MainController._extensionConstants');
let self = this;
let cred: Contracts.Credential = new Contracts.Credential();
cred.credentialId = credentialId;
return new Promise<Contracts.Credential>( (resolve, reject) => {
self._client
.sendRequest(Contracts.ReadCredentialRequest.type, cred, this.languageClient)
.then(returnedCred => {
resolve(<Contracts.Credential>returnedCred);
}, err => reject(err));
});
}
/**
* Gets a credential saved in the credential store
*
* @param {string} credentialId the ID uniquely identifying this credential
* @returns {Promise<Credential>} Promise that resolved to the credential, or undefined if not found
*/
public readCredential(credentialId: string): Promise<Contracts.Credential> {
Utils.logDebug(this.languageClient, 'MainController._extensionConstants');
let self = this;
let cred: Contracts.Credential = new Contracts.Credential();
cred.credentialId = credentialId;
return new Promise<Contracts.Credential>((resolve, reject) => {
self._client
.sendRequest(Contracts.ReadCredentialRequest.type, cred, this.languageClient)
.then(returnedCred => {
resolve(<Contracts.Credential>returnedCred);
}, err => reject(err));
});
}
public saveCredential(credentialId: string, password: any): Promise<boolean> {
let self = this;
let cred: Contracts.Credential = new Contracts.Credential();
cred.credentialId = credentialId;
cred.password = password;
return new Promise<boolean>( (resolve, reject) => {
self._client
.sendRequest(Contracts.SaveCredentialRequest.type, cred, this.languageClient)
.then(status => {
resolve(<boolean>status);
}, err => reject(err));
});
}
public saveCredential(credentialId: string, password: any): Promise<boolean> {
let self = this;
let cred: Contracts.Credential = new Contracts.Credential();
cred.credentialId = credentialId;
cred.password = password;
return new Promise<boolean>((resolve, reject) => {
self._client
.sendRequest(Contracts.SaveCredentialRequest.type, cred, this.languageClient)
.then(status => {
resolve(<boolean>status);
}, err => reject(err));
});
}
public deleteCredential(credentialId: string): Promise<boolean> {
let self = this;
let cred: Contracts.Credential = new Contracts.Credential();
cred.credentialId = credentialId;
return new Promise<boolean>( (resolve, reject) => {
self._client
.sendRequest(Contracts.DeleteCredentialRequest.type, cred, this.languageClient)
.then(status => {
resolve(<boolean>status);
}, err => reject(err));
});
}
public deleteCredential(credentialId: string): Promise<boolean> {
let self = this;
let cred: Contracts.Credential = new Contracts.Credential();
cred.credentialId = credentialId;
return new Promise<boolean>((resolve, reject) => {
self._client
.sendRequest(Contracts.DeleteCredentialRequest.type, cred, this.languageClient)
.then(status => {
resolve(<boolean>status);
}, err => reject(err));
});
}
}

View File

@@ -1,7 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
@@ -17,7 +17,7 @@ import { Credential } from '../models/contracts';
* @interface ICredentialStore
*/
export interface ICredentialStore {
readCredential(credentialId: string): Promise<Credential>;
saveCredential(credentialId: string, password: any): Promise<boolean>;
deleteCredential(credentialId: string): Promise<boolean>;
readCredential(credentialId: string): Promise<Credential>;
saveCredential(credentialId: string, password: any): Promise<boolean>;
deleteCredential(credentialId: string): Promise<boolean>;
}