mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Fix some no unsafe assignment errors in azurecore (#22643)
This commit is contained in:
@@ -11,7 +11,7 @@ import { AzureResourceItemType } from '../../../constants';
|
||||
import { generateGuid } from '../../../utils';
|
||||
import { IAzureResourceService } from '../../../interfaces';
|
||||
import { ResourceTreeDataProviderBase } from '../../resourceTreeDataProviderBase';
|
||||
import { azureResource } from 'azurecore';
|
||||
import { AzureAccountProperties, azureResource } from 'azurecore';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
export class CosmosDbMongoTreeDataProvider extends ResourceTreeDataProviderBase<azureResource.AzureResourceDatabaseServer> {
|
||||
@@ -52,7 +52,7 @@ export class CosmosDbMongoTreeDataProvider extends ResourceTreeDataProviderBase<
|
||||
azureAccount: account.key.accountId,
|
||||
azureTenantId: databaseServer.tenant,
|
||||
azureResourceId: databaseServer.id,
|
||||
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
|
||||
azurePortalEndpoint: (account.properties as AzureAccountProperties).providerSettings.settings.portalEndpoint
|
||||
},
|
||||
childProvider: CosmosDbMongoTreeDataProvider.COSMOSDG_MONGO_PROVIDER_ID,
|
||||
type: azdata.ExtensionNodeType.Server
|
||||
|
||||
@@ -11,7 +11,7 @@ import { AzureResourceItemType } from '../../constants';
|
||||
import { generateGuid } from '../../utils';
|
||||
import { IAzureResourceService } from '../../interfaces';
|
||||
import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase';
|
||||
import { azureResource } from 'azurecore';
|
||||
import { AzureAccountProperties, azureResource } from 'azurecore';
|
||||
import { Account, ExtensionNodeType, TreeItem, connection } from 'azdata';
|
||||
|
||||
export class MysqlFlexibleServerTreeDataProvider extends ResourceTreeDataProviderBase<azureResource.AzureResourceDatabaseServer> {
|
||||
@@ -54,7 +54,7 @@ export class MysqlFlexibleServerTreeDataProvider extends ResourceTreeDataProvide
|
||||
azureAccount: account.key.accountId,
|
||||
azureTenantId: databaseServer.tenant,
|
||||
azureResourceId: databaseServer.id,
|
||||
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
|
||||
azurePortalEndpoint: (account.properties as AzureAccountProperties).providerSettings.settings.portalEndpoint
|
||||
},
|
||||
childProvider: MysqlFlexibleServerTreeDataProvider.MYSQL_FLEXIBLE_SERVER_PROVIDER_ID,
|
||||
type: ExtensionNodeType.Server
|
||||
|
||||
@@ -11,6 +11,7 @@ import { AzureResourceErrorMessageUtil } from '../utils';
|
||||
import { ResourceGraphClient } from '@azure/arm-resourcegraph';
|
||||
import { AzureAccount, azureResource } from 'azurecore';
|
||||
import { Logger } from '../../utils/Logger';
|
||||
import { ErrorResponse } from '@azure/arm-resourcegraph/esm/models';
|
||||
|
||||
export abstract class ResourceTreeDataProviderBase<T extends azureResource.AzureResource> implements azureResource.IAzureResourceTreeDataProvider {
|
||||
public browseConnectionMode: boolean = false;
|
||||
@@ -78,7 +79,7 @@ export async function queryGraphResources<T extends GraphData>(resourceClient: R
|
||||
skipToken: skipToken
|
||||
}
|
||||
});
|
||||
const resources: T[] = response.data;
|
||||
const resources: T[] = response.data as T[];
|
||||
totalProcessed += resources.length;
|
||||
allResources.push(...resources);
|
||||
if (response.skipToken && totalProcessed < response.totalRecords) {
|
||||
@@ -91,7 +92,7 @@ export async function queryGraphResources<T extends GraphData>(resourceClient: R
|
||||
try {
|
||||
if (err.response?.body) {
|
||||
// The response object contains more useful error info than the error originally comes back with
|
||||
const response = JSON.parse(err.response.body);
|
||||
const response = JSON.parse(err.response.body) as ErrorResponse;
|
||||
if (response.error?.details && Array.isArray(response.error.details) && response.error.details.length > 0) {
|
||||
if (response.error.details[0].message) {
|
||||
err.message = `${response.error.details[0].message}\n${err.message}`;
|
||||
|
||||
@@ -97,7 +97,7 @@ export class AzureResourceService {
|
||||
}
|
||||
|
||||
for (const extension of extensions.all) {
|
||||
const contributes = extension.packageJSON && extension.packageJSON.contributes;
|
||||
const contributes = extension.packageJSON.contributes as { [key: string]: string } | undefined;
|
||||
if (!contributes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,20 @@ const handleNeverUsed = async (): Promise<void> => {
|
||||
}
|
||||
};
|
||||
|
||||
type CloudConsoleSettingsResponse = {
|
||||
properties?: {
|
||||
preferredShellType?: string,
|
||||
preferredLocation?: string
|
||||
}
|
||||
}
|
||||
|
||||
type CloudConsoleRequestResponse = {
|
||||
properties?: {
|
||||
provisioningState: string,
|
||||
uri: string
|
||||
}
|
||||
}
|
||||
|
||||
export class AzureTerminalService implements IAzureTerminalService {
|
||||
private readonly apiVersion = '?api-version=2018-10-01';
|
||||
|
||||
@@ -66,7 +80,7 @@ export class AzureTerminalService implements IAzureTerminalService {
|
||||
const metadata = account.properties.providerSettings;
|
||||
const userSettingsUri = this.getConsoleUserSettingsUri(metadata.settings.armResource.endpoint);
|
||||
|
||||
let userSettingsResult: AxiosResponse<any>;
|
||||
let userSettingsResult: AxiosResponse<CloudConsoleSettingsResponse>;
|
||||
try {
|
||||
userSettingsResult = await axios.get(userSettingsUri, settings);
|
||||
} catch (ex) {// Log as info as exception is handled
|
||||
@@ -83,7 +97,7 @@ export class AzureTerminalService implements IAzureTerminalService {
|
||||
settings.headers!['x-ms-console-preferred-location'] = preferredLocation;
|
||||
}
|
||||
|
||||
let provisionResult: AxiosResponse<any>;
|
||||
let provisionResult: AxiosResponse<CloudConsoleRequestResponse>;
|
||||
try {
|
||||
provisionResult = await axios.put(consoleRequestUri, {}, settings);
|
||||
} catch (ex) {// Log as info as exception is handled
|
||||
@@ -93,7 +107,7 @@ export class AzureTerminalService implements IAzureTerminalService {
|
||||
}
|
||||
|
||||
if (provisionResult.data?.properties?.provisioningState !== 'Succeeded') {
|
||||
throw new Error(provisionResult.data);
|
||||
throw new Error(JSON.stringify(provisionResult.data));
|
||||
}
|
||||
const consoleUri = provisionResult.data.properties.uri;
|
||||
|
||||
@@ -143,6 +157,13 @@ export class AzureTerminalService implements IAzureTerminalService {
|
||||
}
|
||||
}
|
||||
|
||||
type TerminalResponse = {
|
||||
socketUri?: string | undefined;
|
||||
error?: {
|
||||
message: string
|
||||
}
|
||||
}
|
||||
|
||||
class AzureTerminal implements vscode.Pseudoterminal {
|
||||
private readonly writeEmitter: vscode.EventEmitter<string>;
|
||||
public readonly onDidWrite: vscode.Event<string>;
|
||||
@@ -222,7 +243,7 @@ class AzureTerminal implements vscode.Pseudoterminal {
|
||||
|
||||
|
||||
private async establishTerminal(dimensions: vscode.TerminalDimensions | undefined): Promise<string | undefined> {
|
||||
let terminalResult: AxiosResponse<any>;
|
||||
let terminalResult: AxiosResponse<TerminalResponse>;
|
||||
try {
|
||||
const url = dimensions ?
|
||||
`${this.consoleUri}/terminals?rows=${dimensions.rows}&cols=${dimensions.columns}&shell=${this.shell}`
|
||||
@@ -247,8 +268,7 @@ class AzureTerminal implements vscode.Pseudoterminal {
|
||||
}
|
||||
|
||||
if (!terminalUri) {
|
||||
Logger.error(terminalResult);
|
||||
throw Error(terminalResult.data);
|
||||
throw Error(JSON.stringify(terminalResult.data));
|
||||
}
|
||||
|
||||
return terminalUri;
|
||||
|
||||
Reference in New Issue
Block a user