mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Separate Fabric-specific message types (#1848)
* Update message de->fabric to v3
* Reinstate get authorization token path which doesn't get called every 5 minutes anymore
* Remove obsolete comment
* Add missing types
* Fix format
* Fix build issue
* Revert "Reinstate get authorization token path which doesn't get called every 5 minutes anymore"
This reverts commit a3f3511043
.
* Keep 3 old fabric message types enums for compatibility with the portal
* Re-add warning comment about not changing existing message type enums
---------
Co-authored-by: Laurent Nguyen <languye@microsoft.com>
This commit is contained in:
parent
36736882ee
commit
f669a99228
@ -1,6 +1,6 @@
|
|||||||
import * as Cosmos from "@azure/cosmos";
|
import * as Cosmos from "@azure/cosmos";
|
||||||
import { getAuthorizationTokenUsingResourceTokens } from "Common/getAuthorizationTokenUsingResourceTokens";
|
import { getAuthorizationTokenUsingResourceTokens } from "Common/getAuthorizationTokenUsingResourceTokens";
|
||||||
import { AuthorizationToken } from "Contracts/MessageTypes";
|
import { AuthorizationToken } from "Contracts/FabricMessageTypes";
|
||||||
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
|
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
|
||||||
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
@ -59,7 +59,7 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
|||||||
/* ************** TODO: Uncomment this code if we need to support these operations **************
|
/* ************** TODO: Uncomment this code if we need to support these operations **************
|
||||||
// User master tokens
|
// User master tokens
|
||||||
const authorizationToken = await sendCachedDataMessage<AuthorizationToken>(
|
const authorizationToken = await sendCachedDataMessage<AuthorizationToken>(
|
||||||
MessageTypes.GetAuthorizationToken,
|
FabricMessageTypes.GetAuthorizationToken,
|
||||||
[requestInfo],
|
[requestInfo],
|
||||||
userContext.fabricContext.connectionId,
|
userContext.fabricContext.connectionId,
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { FabricMessageTypes } from "Contracts/FabricMessageTypes";
|
||||||
import Q from "q";
|
import Q from "q";
|
||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
@ -36,7 +37,7 @@ export function handleCachedDataMessage(message: any): void {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function sendCachedDataMessage<TResponseDataModel>(
|
export function sendCachedDataMessage<TResponseDataModel>(
|
||||||
messageType: MessageTypes,
|
messageType: MessageTypes | FabricMessageTypes,
|
||||||
params: Object[],
|
params: Object[],
|
||||||
scope?: string,
|
scope?: string,
|
||||||
timeoutInMs?: number,
|
timeoutInMs?: number,
|
||||||
|
@ -1,37 +1,22 @@
|
|||||||
import { MessageTypes } from "./MessageTypes";
|
import { FabricMessageTypes } from "./FabricMessageTypes";
|
||||||
|
|
||||||
// This is the current version of these messages
|
// This is the current version of these messages
|
||||||
export const DATA_EXPLORER_RPC_VERSION = "2";
|
export const DATA_EXPLORER_RPC_VERSION = "3";
|
||||||
|
|
||||||
// Data Explorer to Fabric
|
// Data Explorer to Fabric
|
||||||
|
export type DataExploreMessageV3 =
|
||||||
// TODO Remove when upgrading to Fabric v2
|
|
||||||
export type DataExploreMessageV1 =
|
|
||||||
| "ready"
|
|
||||||
| {
|
| {
|
||||||
type: MessageTypes.GetAuthorizationToken;
|
type: FabricMessageTypes.Ready;
|
||||||
id: string;
|
|
||||||
params: GetCosmosTokenMessageOptions[];
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: MessageTypes.GetAllResourceTokens;
|
|
||||||
id: string;
|
|
||||||
};
|
|
||||||
// -----------------------------
|
|
||||||
|
|
||||||
export type DataExploreMessageV2 =
|
|
||||||
| {
|
|
||||||
type: MessageTypes.Ready;
|
|
||||||
id: string;
|
id: string;
|
||||||
params: [string]; // version
|
params: [string]; // version
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: MessageTypes.GetAuthorizationToken;
|
type: FabricMessageTypes.GetAuthorizationToken;
|
||||||
id: string;
|
id: string;
|
||||||
params: GetCosmosTokenMessageOptions[];
|
params: GetCosmosTokenMessageOptions[];
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: MessageTypes.GetAllResourceTokens;
|
type: FabricMessageTypes.GetAllResourceTokens;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
13
src/Contracts/FabricMessageTypes.ts
Normal file
13
src/Contracts/FabricMessageTypes.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Data Explorer -> Fabric communication.
|
||||||
|
*/
|
||||||
|
export enum FabricMessageTypes {
|
||||||
|
GetAuthorizationToken = "GetAuthorizationToken",
|
||||||
|
GetAllResourceTokens = "GetAllResourceTokens",
|
||||||
|
Ready = "Ready",
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuthorizationToken {
|
||||||
|
XDate: string;
|
||||||
|
PrimaryReadWriteToken: string;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import { AuthorizationToken } from "./MessageTypes";
|
import { AuthorizationToken } from "Contracts/FabricMessageTypes";
|
||||||
|
|
||||||
// This is the version of these messages
|
// This is the version of these messages
|
||||||
export const FABRIC_RPC_VERSION = "2";
|
export const FABRIC_RPC_VERSION = "2";
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* Messaging types used with Data Explorer <-> Portal communication,
|
* Messaging types used with Data Explorer <-> Portal communication,
|
||||||
* Hosted <-> Explorer communication and Data Explorer -> Fabric communication.
|
* Hosted <-> Explorer communication
|
||||||
*
|
*
|
||||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
* WARNING: !!!!!!! YOU CAN ONLY ADD NEW TYPES TO THE END OF THIS ENUM !!!!!!!
|
* WARNING: !!!!!!! YOU CAN ONLY ADD NEW TYPES TO THE END OF THIS ENUM !!!!!!!
|
||||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
*
|
*
|
||||||
* Enum are integers, so inserting or deleting a type will break the communication.
|
* Enum are integers, so inserting or deleting a type will break the communication.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
export enum MessageTypes {
|
export enum MessageTypes {
|
||||||
TelemetryInfo,
|
TelemetryInfo,
|
||||||
@ -43,14 +44,9 @@ export enum MessageTypes {
|
|||||||
DisplayNPSSurvey,
|
DisplayNPSSurvey,
|
||||||
OpenVCoreMongoNetworkingBlade,
|
OpenVCoreMongoNetworkingBlade,
|
||||||
OpenVCoreMongoConnectionStringsBlade,
|
OpenVCoreMongoConnectionStringsBlade,
|
||||||
GetAuthorizationToken, // Data Explorer -> Fabric
|
GetAuthorizationToken, // unused. Can be removed if the portal uses the same list of enums.
|
||||||
GetAllResourceTokens, // Data Explorer -> Fabric
|
GetAllResourceTokens, // unused. Can be removed if the portal uses the same list of enums.
|
||||||
Ready, // Data Explorer -> Fabric
|
Ready, // unused. Can be removed if the portal uses the same list of enums.
|
||||||
OpenCESCVAFeedbackBlade,
|
OpenCESCVAFeedbackBlade,
|
||||||
ActivateTab,
|
ActivateTab,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthorizationToken {
|
|
||||||
XDate: string;
|
|
||||||
PrimaryReadWriteToken: string;
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { sendCachedDataMessage } from "Common/MessageHandler";
|
import { sendCachedDataMessage } from "Common/MessageHandler";
|
||||||
|
import { FabricMessageTypes } from "Contracts/FabricMessageTypes";
|
||||||
import { FabricDatabaseConnectionInfo } from "Contracts/FabricMessagesContract";
|
import { FabricDatabaseConnectionInfo } from "Contracts/FabricMessagesContract";
|
||||||
import { MessageTypes } from "Contracts/MessageTypes";
|
|
||||||
import { updateUserContext, userContext } from "UserContext";
|
import { updateUserContext, userContext } from "UserContext";
|
||||||
import { logConsoleError } from "Utils/NotificationConsoleUtils";
|
import { logConsoleError } from "Utils/NotificationConsoleUtils";
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ const requestDatabaseResourceTokens = async (): Promise<void> => {
|
|||||||
lastRequestTimestamp = Date.now();
|
lastRequestTimestamp = Date.now();
|
||||||
try {
|
try {
|
||||||
const fabricDatabaseConnectionInfo = await sendCachedDataMessage<FabricDatabaseConnectionInfo>(
|
const fabricDatabaseConnectionInfo = await sendCachedDataMessage<FabricDatabaseConnectionInfo>(
|
||||||
MessageTypes.GetAllResourceTokens,
|
FabricMessageTypes.GetAllResourceTokens,
|
||||||
[],
|
[],
|
||||||
userContext.fabricContext.connectionId,
|
userContext.fabricContext.connectionId,
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { createUri } from "Common/UrlUtility";
|
import { createUri } from "Common/UrlUtility";
|
||||||
import { DATA_EXPLORER_RPC_VERSION } from "Contracts/DataExplorerMessagesContract";
|
import { DATA_EXPLORER_RPC_VERSION } from "Contracts/DataExplorerMessagesContract";
|
||||||
|
import { FabricMessageTypes } from "Contracts/FabricMessageTypes";
|
||||||
import { FABRIC_RPC_VERSION, FabricMessageV2 } from "Contracts/FabricMessagesContract";
|
import { FABRIC_RPC_VERSION, FabricMessageV2 } from "Contracts/FabricMessagesContract";
|
||||||
import Explorer from "Explorer/Explorer";
|
import Explorer from "Explorer/Explorer";
|
||||||
import { useSelectedNode } from "Explorer/useSelectedNode";
|
import { useSelectedNode } from "Explorer/useSelectedNode";
|
||||||
@ -156,7 +157,7 @@ async function configureFabric(): Promise<Explorer> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
sendMessage({
|
sendMessage({
|
||||||
type: MessageTypes.Ready,
|
type: FabricMessageTypes.Ready,
|
||||||
id: "ready",
|
id: "ready",
|
||||||
params: [DATA_EXPLORER_RPC_VERSION],
|
params: [DATA_EXPLORER_RPC_VERSION],
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user