Files
azuredatastudio/extensions/mssql/client/src/serialize/serialization.ts
Anthony Dresser 8570910a43 Move protocol client out (#643)
* close

* connection is working

* formatting

* adds all

* formatting

* formatting and changing how features are initialized

* formatting

* changed named of typings file

* update

* updated to use dataprotocol npm

* formatting

* removed unneeded logging

* readd npm shrinkwrap

* still not working

* removed unnecessary codfe

* addressed comments

* readded azure resource provider

* fix capabilities cacheing

* added backwards capat for older protocol

* update shrinkwrap

* update shrinkwrap

* updated shrinkwrap

* fixed tests

* removed dead code

* remove dead code

* fix compile

* remove backcompat stuff

* change location of npm

* vbump sqltools

* merge master

* fix imports

* fix build breaks

* update for sqlops

* update yarn dependencies
2018-02-20 13:38:16 -08:00

43 lines
1.7 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* 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 { ISerialization } from './iserialization';
import { SqlToolsServiceClient } from 'extensions-modules';
import * as sqlops from 'sqlops';
import { SqlOpsDataClient } from 'dataprotocol-client';
import * as path from 'path';
/**
* Implements serializer for query results
*/
export class Serialization implements ISerialization {
constructor(private _client?: SqlToolsServiceClient, private _languageClient?: SqlOpsDataClient) {
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<sqlops.SaveResultRequestResult> {
let self = this;
let resultsInfo: Contracts.SaveResultsInfo = new Contracts.SaveResultsInfo(saveFormat, savePath, results, appendToFile);
return new Promise<sqlops.SaveResultRequestResult>((resolve, reject) => {
self._client
.sendRequest(Contracts.SaveAsRequest.type, resultsInfo, this._languageClient)
.then(result => {
resolve(<sqlops.SaveResultRequestResult>result);
}, err => reject(err));
});
}
}