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,10 +1,9 @@
/*---------------------------------------------------------------------------------------------
* 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 { SaveResultsInfo } from '../models/contracts';
import * as data from 'data';
/**
@@ -14,5 +13,5 @@ import * as data from 'data';
* @interface ISerialization
*/
export interface ISerialization {
saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Promise<data.SaveResultRequestResult>;
saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Promise<data.SaveResultRequestResult>;
}

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';
import * as Contracts from '../models/contracts';
@@ -9,33 +9,34 @@ import { ISerialization } from './iserialization';
import { SqlToolsServiceClient } from 'extensions-modules';
import * as data from 'data';
import { LanguageClient } from 'dataprotocol-client';
import * as path from 'path';
/**
* Implements serializer for query results
*/
export class Serialization implements ISerialization {
constructor(private _client?: SqlToolsServiceClient, private _languageClient?: LanguageClient) {
if (!this._client) {
this._client = SqlToolsServiceClient.instance;
}
}
constructor(private _client?: SqlToolsServiceClient, private _languageClient?: LanguageClient) {
if (!this._client) {
this._client = SqlToolsServiceClient.getInstance(path.join(__dirname, '../config.json'));
}
}
/**
* Saves results as a specified path
*
* @param {string} credentialId the ID uniquely identifying this credential
* @returns {Promise<ISaveResultsInfo>} Promise that resolved to the credential, or undefined if not found
*/
public saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Promise<data.SaveResultRequestResult> {
let self = this;
let resultsInfo: Contracts.SaveResultsInfo = new Contracts.SaveResultsInfo(saveFormat, savePath, results, appendToFile);
return new Promise<data.SaveResultRequestResult>( (resolve, reject) => {
self._client
.sendRequest(Contracts.SaveAsRequest.type, resultsInfo, this._languageClient)
.then(result => {
resolve(<data.SaveResultRequestResult>result);
}, err => reject(err));
});
}
/**
* Saves results as a specified path
*
* @param {string} credentialId the ID uniquely identifying this credential
* @returns {Promise<ISaveResultsInfo>} Promise that resolved to the credential, or undefined if not found
*/
public saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Promise<data.SaveResultRequestResult> {
let self = this;
let resultsInfo: Contracts.SaveResultsInfo = new Contracts.SaveResultsInfo(saveFormat, savePath, results, appendToFile);
return new Promise<data.SaveResultRequestResult>((resolve, reject) => {
self._client
.sendRequest(Contracts.SaveAsRequest.type, resultsInfo, this._languageClient)
.then(result => {
resolve(<data.SaveResultRequestResult>result);
}, err => reject(err));
});
}
}