mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
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
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as adal from 'adal-node';
|
||||
import * as data from 'data';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as request from 'request';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as vscode from 'vscode';
|
||||
@@ -22,7 +22,7 @@ import TokenCache from './tokenCache';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class AzureAccountProvider implements data.AccountProvider {
|
||||
export class AzureAccountProvider implements sqlops.AccountProvider {
|
||||
// CONSTANTS ///////////////////////////////////////////////////////////
|
||||
private static WorkSchoolAccountType: string = 'work_school';
|
||||
private static MicrosoftAccountType: string = 'microsoft';
|
||||
@@ -57,7 +57,7 @@ export class AzureAccountProvider implements data.AccountProvider {
|
||||
* @param {"data".AccountKey} accountKey Key identifying the account to delete tokens for
|
||||
* @returns {Thenable<void>} Promise to clear requested tokens from the token cache
|
||||
*/
|
||||
public clear(accountKey: data.AccountKey): Thenable<void> {
|
||||
public clear(accountKey: sqlops.AccountKey): Thenable<void> {
|
||||
return this.doIfInitialized(() => this.clearAccountTokens(accountKey));
|
||||
}
|
||||
|
||||
@@ -73,10 +73,10 @@ export class AzureAccountProvider implements data.AccountProvider {
|
||||
return this.doIfInitialized(() => this.getAccessTokens(account));
|
||||
}
|
||||
|
||||
public initialize(restoredAccounts: data.Account[]): Thenable<data.Account[]> {
|
||||
public initialize(restoredAccounts: sqlops.Account[]): Thenable<sqlops.Account[]> {
|
||||
let self = this;
|
||||
|
||||
let rehydrationTasks: Thenable<data.Account>[] = [];
|
||||
let rehydrationTasks: Thenable<sqlops.Account>[] = [];
|
||||
for (let account of restoredAccounts) {
|
||||
// Purge any invalid accounts
|
||||
if (!account) {
|
||||
@@ -145,7 +145,7 @@ export class AzureAccountProvider implements data.AccountProvider {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private clearAccountTokens(accountKey: data.AccountKey): Thenable<void> {
|
||||
private clearAccountTokens(accountKey: sqlops.AccountKey): Thenable<void> {
|
||||
// Put together a query to look up any tokens associated with the account key
|
||||
let query = <adal.TokenResponse>{ userId: accountKey.accountId };
|
||||
|
||||
@@ -180,7 +180,7 @@ export class AzureAccountProvider implements data.AccountProvider {
|
||||
if (error) {
|
||||
// TODO: We'll assume for now that the account is stale, though that might not be accurate
|
||||
account.isStale = true;
|
||||
data.accounts.accountUpdated(account);
|
||||
sqlops.accounts.accountUpdated(account);
|
||||
|
||||
reject(error);
|
||||
return;
|
||||
@@ -240,7 +240,7 @@ export class AzureAccountProvider implements data.AccountProvider {
|
||||
let title = isAddAccount ?
|
||||
localize('addAccount', 'Add {0} account', self._metadata.displayName) :
|
||||
localize('refreshAccount', 'Refresh {0} account', self._metadata.displayName);
|
||||
return data.accounts.beginAutoOAuthDeviceCode(self._metadata.id, title, oAuth.userCodeInfo.message, oAuth.userCodeInfo.userCode, oAuth.userCodeInfo.verificationUrl)
|
||||
return sqlops.accounts.beginAutoOAuthDeviceCode(self._metadata.id, title, oAuth.userCodeInfo.message, oAuth.userCodeInfo.userCode, oAuth.userCodeInfo.verificationUrl)
|
||||
.then(() => {
|
||||
return new Promise<adal.TokenResponse>((resolve, reject) => {
|
||||
let context = oAuth.context;
|
||||
@@ -249,14 +249,14 @@ export class AzureAccountProvider implements data.AccountProvider {
|
||||
if (err) {
|
||||
if (self._autoOAuthCancelled) {
|
||||
// Auto OAuth was cancelled by the user, indicate this with the error we return
|
||||
reject(<data.UserCancelledSignInError>{ userCancelledSignIn: true });
|
||||
reject(<sqlops.UserCancelledSignInError>{ userCancelledSignIn: true });
|
||||
} else {
|
||||
// Auto OAuth failed for some other reason
|
||||
data.accounts.endAutoOAuthDeviceCode();
|
||||
sqlops.accounts.endAutoOAuthDeviceCode();
|
||||
reject(err);
|
||||
}
|
||||
} else {
|
||||
data.accounts.endAutoOAuthDeviceCode();
|
||||
sqlops.accounts.endAutoOAuthDeviceCode();
|
||||
resolve(<adal.TokenResponse>response);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as constants from '../constants';
|
||||
import * as data from 'data';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as events from 'events';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as path from 'path';
|
||||
@@ -27,7 +27,7 @@ export class AzureAccountProviderService implements vscode.Disposable {
|
||||
// MEMBER VARIABLES ////////////////////////////////////////////////////////
|
||||
private _accountDisposals: { [accountProviderId: string]: vscode.Disposable };
|
||||
private _accountProviders: { [accountProviderId: string]: AzureAccountProvider };
|
||||
private _credentialProvider: data.CredentialProvider;
|
||||
private _credentialProvider: sqlops.CredentialProvider;
|
||||
private _configChangePromiseChain: Thenable<void>;
|
||||
private _currentConfig: vscode.WorkspaceConfiguration;
|
||||
private _event: events.EventEmitter;
|
||||
@@ -55,7 +55,7 @@ export class AzureAccountProviderService implements vscode.Disposable {
|
||||
// 2a) Store the credential provider for use later
|
||||
// 2b) Register the configuration change handler
|
||||
// 2c) Perform an initial config change handling
|
||||
return data.credentials.getProvider(AzureAccountProviderService.CredentialNamespace)
|
||||
return sqlops.credentials.getProvider(AzureAccountProviderService.CredentialNamespace)
|
||||
.then(credProvider => {
|
||||
self._credentialProvider = credProvider;
|
||||
|
||||
@@ -138,7 +138,7 @@ export class AzureAccountProviderService implements vscode.Disposable {
|
||||
let tokenCache = new CredentialServiceTokenCache(self._credentialProvider, tokenCacheKey, tokenCachePath);
|
||||
let accountProvider = new AzureAccountProvider(<AzureAccountProviderMetadata>provider.metadata, tokenCache);
|
||||
self._accountProviders[provider.metadata.id] = accountProvider;
|
||||
self._accountDisposals[provider.metadata.id] = data.accounts.registerAccountProvider(provider.metadata, accountProvider);
|
||||
self._accountDisposals[provider.metadata.id] = sqlops.accounts.registerAccountProvider(provider.metadata, accountProvider);
|
||||
resolve();
|
||||
} catch (e) {
|
||||
console.error(`Failed to register account provider: ${e}`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import * as data from 'data';
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
/**
|
||||
* Represents a tenant (an Azure Active Directory instance) to which a user has access
|
||||
@@ -118,7 +118,7 @@ export interface ProviderSettings {
|
||||
/**
|
||||
* Extension of account provider metadata to override settings type for Azure account providers
|
||||
*/
|
||||
export interface AzureAccountProviderMetadata extends data.AccountProviderMetadata {
|
||||
export interface AzureAccountProviderMetadata extends sqlops.AccountProviderMetadata {
|
||||
/**
|
||||
* Azure specific account provider settings.
|
||||
*/
|
||||
@@ -143,7 +143,7 @@ export interface AzureAccountProperties {
|
||||
/**
|
||||
* Override of the Account type to enforce properties that are AzureAccountProperties
|
||||
*/
|
||||
export interface AzureAccount extends data.Account {
|
||||
export interface AzureAccount extends sqlops.Account {
|
||||
/**
|
||||
* AzureAccountProperties specifically used for Azure accounts
|
||||
*/
|
||||
@@ -179,4 +179,4 @@ export interface AzureAccountSecurityToken {
|
||||
* Azure account security token maps a tenant ID to the information returned from a request to get
|
||||
* an access token. The list of tenants correspond to the tenants in the account properties.
|
||||
*/
|
||||
export type AzureAccountSecurityTokenCollection = {[tenantId: string]: AzureAccountSecurityToken};
|
||||
export type AzureAccountSecurityTokenCollection = { [tenantId: string]: AzureAccountSecurityToken };
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as adal from 'adal-node';
|
||||
import * as data from 'data';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as crypto from 'crypto';
|
||||
import * as fs from 'fs';
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class TokenCache implements adal.TokenCache {
|
||||
private _activeOperation: Thenable<any>;
|
||||
|
||||
constructor(
|
||||
private _credentialProvider: data.CredentialProvider,
|
||||
private _credentialProvider: sqlops.CredentialProvider,
|
||||
private _credentialServiceKey: string,
|
||||
private _cacheSerializationPath: string
|
||||
) {
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path='../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../src/sql/data.d.ts'/>
|
||||
/// <reference path='../../../../src/sql/sqlops.d.ts'/>
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import vscode = require('vscode');
|
||||
import data = require('data');
|
||||
import * as vscode from 'vscode';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { Constants } from '../models/constants';
|
||||
import { Serialization } from '../serialize/serialization';
|
||||
import { AzureResourceProvider } from '../resourceProvider/resourceProvider';
|
||||
import { CredentialStore } from '../credentialstore/credentialstore';
|
||||
import { AzureResourceProvider } from '../resourceProvider/resourceProvider';
|
||||
import { IExtensionConstants, Telemetry, Constants as SharedConstants, SqlToolsServiceClient, VscodeWrapper, Utils, PlatformInformation } from 'extensions-modules';
|
||||
import { SqlOpsDataClient } from 'dataprotocol-client';
|
||||
import * as path from 'path';
|
||||
@@ -101,7 +101,7 @@ export default class MainController implements vscode.Disposable {
|
||||
|
||||
self.createResourceProviderClient().then(rpClient => {
|
||||
let resourceProvider = new AzureResourceProvider(self._client, rpClient);
|
||||
data.resources.registerResourceProvider({
|
||||
sqlops.resources.registerResourceProvider({
|
||||
displayName: 'Azure SQL Resource Provider', // TODO Localize
|
||||
id: 'Microsoft.Azure.SQL.ResourceProvider',
|
||||
settings: {
|
||||
@@ -116,19 +116,19 @@ export default class MainController implements vscode.Disposable {
|
||||
self.createCredentialClient().then(credentialClient => {
|
||||
self._credentialStore.languageClient = credentialClient;
|
||||
credentialClient.onReady().then(() => {
|
||||
let credentialProvider: data.CredentialProvider = {
|
||||
let credentialProvider: sqlops.CredentialProvider = {
|
||||
handle: 0,
|
||||
saveCredential(credentialId: string, password: string): Thenable<boolean> {
|
||||
return self._credentialStore.saveCredential(credentialId, password);
|
||||
},
|
||||
readCredential(credentialId: string): Thenable<data.Credential> {
|
||||
readCredential(credentialId: string): Thenable<sqlops.Credential> {
|
||||
return self._credentialStore.readCredential(credentialId);
|
||||
},
|
||||
deleteCredential(credentialId: string): Thenable<boolean> {
|
||||
return self._credentialStore.deleteCredential(credentialId);
|
||||
}
|
||||
};
|
||||
data.credentials.registerProvider(credentialProvider);
|
||||
sqlops.credentials.registerProvider(credentialProvider);
|
||||
Utils.logDebug('credentialProvider registered', MainController._extensionConstants.extensionConfigSectionName);
|
||||
});
|
||||
}, error => {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { RequestType } from 'vscode-languageclient';
|
||||
import * as data from 'data';
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
// DEV-NOTE: Still finalizing what we'll need as part of this interface
|
||||
/**
|
||||
@@ -22,7 +22,7 @@ export class SaveResultsInfo {
|
||||
}
|
||||
|
||||
export namespace SaveAsRequest {
|
||||
export const type = new RequestType<SaveResultsInfo, data.SaveResultRequestResult, void, void>('query/saveAs');
|
||||
export const type = new RequestType<SaveResultsInfo, sqlops.SaveResultRequestResult, void, void>('query/saveAs');
|
||||
}
|
||||
|
||||
// --------------------------------- < Read Credential Request > -------------------------------------------------
|
||||
@@ -77,7 +77,7 @@ export namespace HandleFirewallRuleRequest {
|
||||
|
||||
// Firewall rule interfaces
|
||||
export interface CreateFirewallRuleParams {
|
||||
account: data.Account;
|
||||
account: sqlops.Account;
|
||||
serverName: string;
|
||||
startIpAddress: string;
|
||||
endIpAddress: string;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import * as Contracts from '../models/contracts';
|
||||
import { SqlToolsServiceClient } from 'extensions-modules';
|
||||
import { SqlOpsDataClient } from 'dataprotocol-client';
|
||||
import * as data from 'data';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as path from 'path';
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import * as path from 'path';
|
||||
*
|
||||
* Allows a single credential to be stored per service (that is, one username per service);
|
||||
*/
|
||||
export class AzureResourceProvider implements data.ResourceProvider {
|
||||
export class AzureResourceProvider implements sqlops.ResourceProvider {
|
||||
|
||||
public languageClient: SqlOpsDataClient;
|
||||
|
||||
@@ -27,9 +27,9 @@ export class AzureResourceProvider implements data.ResourceProvider {
|
||||
this.languageClient = langClient;
|
||||
}
|
||||
|
||||
public createFirewallRule(account: data.Account, firewallruleInfo: data.FirewallRuleInfo): Thenable<data.CreateFirewallRuleResponse> {
|
||||
public createFirewallRule(account: sqlops.Account, firewallruleInfo: sqlops.FirewallRuleInfo): Thenable<sqlops.CreateFirewallRuleResponse> {
|
||||
let self = this;
|
||||
return new Promise<data.CreateFirewallRuleResponse>((resolve, reject) => {
|
||||
return new Promise<sqlops.CreateFirewallRuleResponse>((resolve, reject) => {
|
||||
self._client.
|
||||
sendRequest(Contracts.CreateFirewallRuleRequest.type, self.asCreateFirewallRuleParams(account, firewallruleInfo), self.languageClient)
|
||||
.then(response => {
|
||||
@@ -38,9 +38,9 @@ export class AzureResourceProvider implements data.ResourceProvider {
|
||||
});
|
||||
}
|
||||
|
||||
public handleFirewallRule(errorCode: number, errorMessage: string, connectionTypeId: string): Thenable<data.HandleFirewallRuleResponse> {
|
||||
public handleFirewallRule(errorCode: number, errorMessage: string, connectionTypeId: string): Thenable<sqlops.HandleFirewallRuleResponse> {
|
||||
let self = this;
|
||||
return new Promise<data.HandleFirewallRuleResponse>((resolve, reject) => {
|
||||
return new Promise<sqlops.HandleFirewallRuleResponse>((resolve, reject) => {
|
||||
let params: Contracts.HandleFirewallRuleParams = { errorCode: errorCode, errorMessage: errorMessage, connectionTypeId: connectionTypeId };
|
||||
|
||||
self._client.
|
||||
@@ -51,7 +51,7 @@ export class AzureResourceProvider implements data.ResourceProvider {
|
||||
});
|
||||
}
|
||||
|
||||
private asCreateFirewallRuleParams(account: data.Account, params: data.FirewallRuleInfo): Contracts.CreateFirewallRuleParams {
|
||||
private asCreateFirewallRuleParams(account: sqlops.Account, params: sqlops.FirewallRuleInfo): Contracts.CreateFirewallRuleParams {
|
||||
return {
|
||||
account: account,
|
||||
serverName: params.serverName,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as data from 'data';
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
/**
|
||||
* Serializer for saving results into a different format
|
||||
@@ -13,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<sqlops.SaveResultRequestResult>;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import * as Contracts from '../models/contracts';
|
||||
import { ISerialization } from './iserialization';
|
||||
import { SqlToolsServiceClient } from 'extensions-modules';
|
||||
import * as data from 'data';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { SqlOpsDataClient } from 'dataprotocol-client';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -28,14 +28,14 @@ export class Serialization implements ISerialization {
|
||||
* @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> {
|
||||
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<data.SaveResultRequestResult>((resolve, reject) => {
|
||||
return new Promise<sqlops.SaveResultRequestResult>((resolve, reject) => {
|
||||
self._client
|
||||
.sendRequest(Contracts.SaveAsRequest.type, resultsInfo, this._languageClient)
|
||||
.then(result => {
|
||||
resolve(<data.SaveResultRequestResult>result);
|
||||
resolve(<sqlops.SaveResultRequestResult>result);
|
||||
}, err => reject(err));
|
||||
});
|
||||
}
|
||||
|
||||
2
extensions/mssql/client/src/typings/ref.d.ts
vendored
2
extensions/mssql/client/src/typings/ref.d.ts
vendored
@@ -4,5 +4,5 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../../src/sql/data.d.ts'/>
|
||||
/// <reference path='../../../../../src/sql/sqlops.d.ts'/>
|
||||
/// <reference types='@types/node'/>
|
||||
1766
extensions/yarn.lock
1766
extensions/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user