mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-09 04:25:57 +00:00
Added documentation for Self Serve Model (#716)
* initial commit for docs * Added readme * modified selfServeutil docs * updated docs * moved documentation to docs folder * Updated ReadME for selfserve * added more comments * Added more function types * Update index.html * Update index.html * minro edits * minor edits * package.json updated * Added Module decorators * Added modules * initial commit for mongo shell refactor * undid changes * addressed PR comments * docs changes * addressed PR comments * More changes * Added selfserveexample types file * minor edits * minor edits * Addressed PR comments * format changes * added Metrics blade link * documentation changes * updated docs * Addressed PR comments * fixed format error
This commit is contained in:
committed by
GitHub
parent
a06e213b81
commit
62e205be6a
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* @module SelfServe/SelfServeUtils
|
||||
*/
|
||||
|
||||
import "reflect-metadata";
|
||||
import { userContext } from "../UserContext";
|
||||
import {
|
||||
@@ -18,9 +22,10 @@ import {
|
||||
StringInput,
|
||||
} from "./SelfServeTypes";
|
||||
|
||||
/**
|
||||
* The type used to identify the Self Serve Class
|
||||
*/
|
||||
export enum SelfServeType {
|
||||
// No self serve type passed, launch explorer
|
||||
none = "none",
|
||||
// Unsupported self serve type passed as feature flag
|
||||
invalid = "invalid",
|
||||
// Add your self serve types here
|
||||
@@ -28,15 +33,47 @@ export enum SelfServeType {
|
||||
sqlx = "sqlx",
|
||||
}
|
||||
|
||||
/**
|
||||
* Portal Blade types
|
||||
*/
|
||||
export enum BladeType {
|
||||
/**
|
||||
* Keys blade of a SQL API account.
|
||||
*/
|
||||
SqlKeys = "keys",
|
||||
/**
|
||||
* Keys blade of a Mongo API account.
|
||||
*/
|
||||
MongoKeys = "mongoDbKeys",
|
||||
/**
|
||||
* Keys blade of a Cassandra API account.
|
||||
*/
|
||||
CassandraKeys = "cassandraDbKeys",
|
||||
/**
|
||||
* Keys blade of a Gremlin API account.
|
||||
*/
|
||||
GremlinKeys = "keys",
|
||||
/**
|
||||
* Keys blade of a Table API account.
|
||||
*/
|
||||
TableKeys = "tableKeys",
|
||||
/**
|
||||
* Metrics blade of an Azure Cosmos DB account.
|
||||
*/
|
||||
Metrics = "metrics",
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the URL corresponding to the portal blade for the current Azure Cosmos DB account
|
||||
*/
|
||||
export const generateBladeLink = (blade: BladeType): string => {
|
||||
const subscriptionId = userContext.subscriptionId;
|
||||
const resourceGroupName = userContext.resourceGroup;
|
||||
const databaseAccountName = userContext.databaseAccount.name;
|
||||
return `${document.referrer}#@microsoft.onmicrosoft.com/resource/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDb/databaseAccounts/${databaseAccountName}/${blade}`;
|
||||
};
|
||||
|
||||
/**@internal */
|
||||
export interface DecoratorProperties {
|
||||
id: string;
|
||||
info?: (() => Promise<Info>) | Info;
|
||||
@@ -62,6 +99,7 @@ export interface DecoratorProperties {
|
||||
) => Map<string, SmartUiInput>;
|
||||
}
|
||||
|
||||
/**@internal */
|
||||
const setValue = <T extends keyof DecoratorProperties, K extends DecoratorProperties[T]>(
|
||||
name: T,
|
||||
value: K,
|
||||
@@ -70,10 +108,12 @@ const setValue = <T extends keyof DecoratorProperties, K extends DecoratorProper
|
||||
fieldObject[name] = value;
|
||||
};
|
||||
|
||||
/**@internal */
|
||||
const getValue = <T extends keyof DecoratorProperties>(name: T, fieldObject: DecoratorProperties): unknown => {
|
||||
return fieldObject[name];
|
||||
};
|
||||
|
||||
/**@internal */
|
||||
export const addPropertyToMap = <T extends keyof DecoratorProperties, K extends DecoratorProperties[T]>(
|
||||
target: unknown,
|
||||
propertyName: string,
|
||||
@@ -88,6 +128,7 @@ export const addPropertyToMap = <T extends keyof DecoratorProperties, K extends
|
||||
Reflect.defineMetadata(className, context, target);
|
||||
};
|
||||
|
||||
/**@internal */
|
||||
export const updateContextWithDecorator = <T extends keyof DecoratorProperties, K extends DecoratorProperties[T]>(
|
||||
context: Map<string, DecoratorProperties>,
|
||||
propertyName: string,
|
||||
@@ -111,12 +152,14 @@ export const updateContextWithDecorator = <T extends keyof DecoratorProperties,
|
||||
context.set(propertyName, propertyObject);
|
||||
};
|
||||
|
||||
/**@internal */
|
||||
export const buildSmartUiDescriptor = (className: string, target: unknown): void => {
|
||||
const context = Reflect.getMetadata(className, target) as Map<string, DecoratorProperties>;
|
||||
const smartUiDescriptor = mapToSmartUiDescriptor(context);
|
||||
Reflect.defineMetadata(className, smartUiDescriptor, target);
|
||||
};
|
||||
|
||||
/**@internal */
|
||||
export const mapToSmartUiDescriptor = (context: Map<string, DecoratorProperties>): SelfServeDescriptor => {
|
||||
const inputNames: string[] = [];
|
||||
const root = context.get("root");
|
||||
@@ -140,6 +183,7 @@ export const mapToSmartUiDescriptor = (context: Map<string, DecoratorProperties>
|
||||
return smartUiDescriptor;
|
||||
};
|
||||
|
||||
/**@internal */
|
||||
const addToDescriptor = (
|
||||
context: Map<string, DecoratorProperties>,
|
||||
root: Node,
|
||||
@@ -158,6 +202,7 @@ const addToDescriptor = (
|
||||
root.children.push(element);
|
||||
};
|
||||
|
||||
/**@internal */
|
||||
const getInput = (value: DecoratorProperties): AnyDisplay => {
|
||||
switch (value.type) {
|
||||
case "number":
|
||||
@@ -188,10 +233,3 @@ const getInput = (value: DecoratorProperties): AnyDisplay => {
|
||||
return value as ChoiceInput;
|
||||
}
|
||||
};
|
||||
|
||||
export const generateBladeLink = (blade: BladeType): string => {
|
||||
const { subscriptionId, resourceGroup, databaseAccount } = userContext;
|
||||
const databaseAccountName = databaseAccount.name;
|
||||
|
||||
return `${document.referrer}#@microsoft.onmicrosoft.com/resource/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.DocumentDb/databaseAccounts/${databaseAccountName}/${blade}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user