mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 00:41:31 +00:00
Remove Explorer.features (#563)
In addition this makes the URL-passed feature flags type safe
This commit is contained in:
@@ -2,34 +2,44 @@ import { AuthType } from "./AuthType";
|
||||
import { DatabaseAccount } from "./Contracts/DataModels";
|
||||
import { SubscriptionType } from "./Contracts/SubscriptionType";
|
||||
import { DefaultAccountExperienceType } from "./DefaultAccountExperienceType";
|
||||
import { extractFeatures, Features } from "./Platform/Hosted/extractFeatures";
|
||||
|
||||
interface UserContext {
|
||||
authType?: AuthType;
|
||||
masterKey?: string;
|
||||
subscriptionId?: string;
|
||||
resourceGroup?: string;
|
||||
databaseAccount?: DatabaseAccount;
|
||||
endpoint?: string;
|
||||
accessToken?: string;
|
||||
authorizationToken?: string;
|
||||
resourceToken?: string;
|
||||
defaultExperience?: DefaultAccountExperienceType;
|
||||
useSDKOperations?: boolean;
|
||||
subscriptionType?: SubscriptionType;
|
||||
quotaId?: string;
|
||||
readonly authType?: AuthType;
|
||||
readonly masterKey?: string;
|
||||
readonly subscriptionId?: string;
|
||||
readonly resourceGroup?: string;
|
||||
readonly databaseAccount?: DatabaseAccount;
|
||||
readonly endpoint?: string;
|
||||
readonly accessToken?: string;
|
||||
readonly authorizationToken?: string;
|
||||
readonly resourceToken?: string;
|
||||
readonly useSDKOperations: boolean;
|
||||
readonly defaultExperience?: DefaultAccountExperienceType;
|
||||
readonly subscriptionType?: SubscriptionType;
|
||||
readonly quotaId?: string;
|
||||
// API Type is not yet provided by ARM. You need to manually inspect all the capabilities+kind so we abstract that logic in userContext
|
||||
// This is coming in a future Cosmos ARM API version as a prperty on databaseAccount
|
||||
apiType?: ApiType;
|
||||
isTryCosmosDBSubscription?: boolean;
|
||||
portalEnv?: PortalEnv;
|
||||
readonly apiType?: ApiType;
|
||||
readonly isTryCosmosDBSubscription?: boolean;
|
||||
readonly portalEnv?: PortalEnv;
|
||||
readonly features: Features;
|
||||
}
|
||||
|
||||
type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra";
|
||||
export type PortalEnv = "localhost" | "blackforest" | "fairfax" | "mooncake" | "prod" | "dev";
|
||||
|
||||
const userContext: UserContext = { isTryCosmosDBSubscription: false, portalEnv: "prod" };
|
||||
const features = extractFeatures();
|
||||
const { enableSDKoperations: useSDKOperations } = features;
|
||||
|
||||
function updateUserContext(newContext: UserContext): void {
|
||||
const userContext: UserContext = {
|
||||
isTryCosmosDBSubscription: false,
|
||||
portalEnv: "prod",
|
||||
features,
|
||||
useSDKOperations,
|
||||
};
|
||||
|
||||
function updateUserContext(newContext: Partial<UserContext>): void {
|
||||
Object.assign(userContext, newContext);
|
||||
Object.assign(userContext, { apiType: apiType(userContext.databaseAccount) });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user