Refactor Data Access Utility (#112)

This commit is contained in:
Steve Faulkner
2020-07-24 16:45:48 -05:00
committed by GitHub
parent 6dcdacc8c4
commit 6d142f16f9
25 changed files with 825 additions and 1014 deletions

View File

@@ -7,7 +7,7 @@ import { AddDbUtilities } from "../Shared/AddDatabaseUtility";
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
import { CosmosClient } from "../Common/CosmosClient";
import { HttpStatusCodes } from "../Common/Constants";
import { MessageHandler } from "../Common/MessageHandler";
import { sendMessage } from "../Common/MessageHandler";
import { MessageTypes } from "../Contracts/ExplorerContracts";
import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils";
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
@@ -108,7 +108,7 @@ export class CreateSqlCollectionUtilities {
`Error creating collection: ${JSON.stringify(response)}`
);
if (response.status === HttpStatusCodes.Forbidden) {
MessageHandler.sendMessage({ type: MessageTypes.ForbiddenError });
sendMessage({ type: MessageTypes.ForbiddenError });
}
throw new Error(`Error creating collection`);
}
@@ -202,7 +202,7 @@ export class CreateCollectionUtilities {
`Error creating graph: ${JSON.stringify(response)}`
);
if (response.status === HttpStatusCodes.Forbidden) {
MessageHandler.sendMessage({ type: MessageTypes.ForbiddenError });
sendMessage({ type: MessageTypes.ForbiddenError });
}
throw new Error(`Error creating graph`);
}
@@ -248,7 +248,7 @@ export class Utilities {
`Error creating table: ${JSON.stringify(reason)}, Payload: ${params}`
);
if (reason.status === HttpStatusCodes.Forbidden) {
MessageHandler.sendMessage({ type: MessageTypes.ForbiddenError });
sendMessage({ type: MessageTypes.ForbiddenError });
return;
}
throw new Error(`Error creating table`);

View File

@@ -4,7 +4,7 @@ import { config } from "../Config";
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
import { CosmosClient } from "../Common/CosmosClient";
import { HttpStatusCodes } from "../Common/Constants";
import { MessageHandler } from "../Common/MessageHandler";
import { sendMessage } from "../Common/MessageHandler";
import { MessageTypes } from "../Contracts/ExplorerContracts";
import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils";
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
@@ -164,7 +164,7 @@ export class AddDbUtilities {
`Error creating ${dbType}: ${JSON.stringify(reason)}, Payload: ${params}`
);
if (reason.status === HttpStatusCodes.Forbidden) {
MessageHandler.sendMessage({ type: MessageTypes.ForbiddenError });
sendMessage({ type: MessageTypes.ForbiddenError });
return;
}
throw new Error(`Error creating ${dbType}`);

View File

@@ -1,5 +1,5 @@
import { Action, ActionModifiers } from "./TelemetryConstants";
import { MessageHandler } from "../../Common/MessageHandler";
import { sendMessage } from "../../Common/MessageHandler";
import { MessageTypes } from "../../Contracts/ExplorerContracts";
import { appInsights } from "../appInsights";
import { config } from "../../Config";
@@ -11,7 +11,7 @@ import { config } from "../../Config";
// TODO: Log telemetry for StorageExplorer case/other clients as well
export default class TelemetryProcessor {
public static trace(action: Action, actionModifier: string = ActionModifiers.Mark, data?: any): void {
MessageHandler.sendMessage({
sendMessage({
type: MessageTypes.TelemetryInfo,
data: {
action: Action[action],
@@ -25,7 +25,7 @@ export default class TelemetryProcessor {
public static traceStart(action: Action, data?: any): number {
const timestamp: number = Date.now();
MessageHandler.sendMessage({
sendMessage({
type: MessageTypes.TelemetryInfo,
data: {
action: Action[action],
@@ -40,7 +40,7 @@ export default class TelemetryProcessor {
}
public static traceSuccess(action: Action, data?: any, timestamp?: number): void {
MessageHandler.sendMessage({
sendMessage({
type: MessageTypes.TelemetryInfo,
data: {
action: Action[action],
@@ -54,7 +54,7 @@ export default class TelemetryProcessor {
}
public static traceFailure(action: Action, data?: any, timestamp?: number): void {
MessageHandler.sendMessage({
sendMessage({
type: MessageTypes.TelemetryInfo,
data: {
action: Action[action],
@@ -68,7 +68,7 @@ export default class TelemetryProcessor {
}
public static traceCancel(action: Action, data?: any, timestamp?: number): void {
MessageHandler.sendMessage({
sendMessage({
type: MessageTypes.TelemetryInfo,
data: {
action: Action[action],
@@ -83,7 +83,7 @@ export default class TelemetryProcessor {
public static traceOpen(action: Action, data?: any, timestamp?: number): number {
const validTimestamp = timestamp || Date.now();
MessageHandler.sendMessage({
sendMessage({
type: MessageTypes.TelemetryInfo,
data: {
action: Action[action],
@@ -99,7 +99,7 @@ export default class TelemetryProcessor {
public static traceMark(action: Action, data?: any, timestamp?: number): number {
const validTimestamp = timestamp || Date.now();
MessageHandler.sendMessage({
sendMessage({
type: MessageTypes.TelemetryInfo,
data: {
action: Action[action],