Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import { Result } from "neverthrow";
import { FxError } from "../error";
/**
* Encrypt/decrypt secrets
*/
export interface CryptoProvider {
/**
* Encrypt string
* @param plaintext - original string
*/
encrypt(plaintext: string): Result<string, FxError>;
/**
* Decrypt cipher string
* @param ciphertext - encrypted string
*/
decrypt(ciphertext: string): Result<string, FxError>;
}
//# sourceMappingURL=crypto.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpD;;;OAGG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtD"}
+5
View File
@@ -0,0 +1,5 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=crypto.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC"}
+4
View File
@@ -0,0 +1,4 @@
export interface ExpServiceProvider {
getTreatmentVariableAsync<T extends boolean | number | string>(configId: string, name: string, checkCache?: boolean): Promise<T | undefined>;
}
//# sourceMappingURL=exp.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"exp.d.ts","sourceRoot":"","sources":["../../src/utils/exp.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,yBAAyB,CAAC,CAAC,SAAS,OAAO,GAAG,MAAM,GAAG,MAAM,EAC3D,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CAC3B"}
+5
View File
@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=exp.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"exp.js","sourceRoot":"","sources":["../../src/utils/exp.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC"}
+23
View File
@@ -0,0 +1,23 @@
import { UserInteraction } from "../qm/ui";
import { CryptoProvider } from "./crypto";
import { ExpServiceProvider } from "./exp";
import { LogProvider } from "./log";
import { TokenProvider } from "./login";
import { TelemetryReporter } from "./telemetry";
import { TreeProvider } from "./tree";
export * from "./login";
export * from "./log";
export * from "./telemetry";
export * from "./tree";
export * from "./crypto";
export * from "./exp";
export interface Tools {
logProvider: LogProvider;
tokenProvider: TokenProvider;
telemetryReporter?: TelemetryReporter;
treeProvider?: TreeProvider;
ui: UserInteraction;
cryptoProvider?: CryptoProvider;
expServiceProvider?: ExpServiceProvider;
}
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AAEtB,MAAM,WAAW,KAAK;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;IAC7B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,EAAE,EAAE,eAAe,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC"}
+12
View File
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./login"), exports);
tslib_1.__exportStar(require("./log"), exports);
tslib_1.__exportStar(require("./telemetry"), exports);
tslib_1.__exportStar(require("./tree"), exports);
tslib_1.__exportStar(require("./crypto"), exports);
tslib_1.__exportStar(require("./exp"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;AAUb,kDAAwB;AACxB,gDAAsB;AACtB,sDAA4B;AAC5B,iDAAuB;AACvB,mDAAyB;AACzB,gDAAsB"}
+97
View File
@@ -0,0 +1,97 @@
export declare enum LogLevel {
/**
* For debugging and development.
*/
Debug = 1,
/**
* Contain the most detailed messages.
*/
Verbose = 2,
/**
* Tracks the general flow of the app. May have long-term value.
*/
Info = 3,
/**
* For abnormal or unexpected events. Typically includes errors or conditions that don't cause the app to fail.
*/
Warning = 4,
/**
* For errors and exceptions that cannot be handled. These messages indicate a failure in the current operation or request, not an app-wide failure.
*/
Error = 5
}
export interface LogProvider {
/**
* log by level
*/
log(logLevel: LogLevel, message: string): void;
/**
* diagnostic information used by user
*/
verbose(message: string): void;
/**
* debug information used internally
*/
debug(message: string): void;
/**
* normal output information
*/
info(message: string): void;
/**
* normal output information, colored version
*/
info(message: Array<{
content: string;
color: Colors;
}>): void;
/**
* warning information
*/
warning(message: string): void;
/**
* error information
*/
error(message: string): void;
/**
* log content into file
*/
logInFile(logLevel: LogLevel, message: string): Promise<void>;
/**
* Get log file path
*/
getLogFilePath(): string;
}
/**
* Colors for CLI output message
*/
export declare enum Colors {
/**
* Primary text color
*/
BRIGHT_WHITE = 0,
/**
* Secondary text color
*/
WHITE = 1,
/**
* Important text color
*/
BRIGHT_MAGENTA = 2,
/**
* Success message indicator
*/
BRIGHT_GREEN = 3,
/**
* Warning message indicator
*/
BRIGHT_YELLOW = 4,
/**
* Error message indicator
*/
BRIGHT_RED = 5,
/**
* Hyperlink
*/
BRIGHT_CYAN = 6
}
//# sourceMappingURL=log.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAIA,oBAAY,QAAQ;IAClB;;OAEG;IACH,KAAK,IAAI;IACT;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,IAAI,IAAI;IACR;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,KAAK,IAAI;CACV;AAED,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/C;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IAE/D;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D;;OAEG;IACH,cAAc,IAAI,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,oBAAY,MAAM;IAChB;;OAEG;IACH,YAAY,IAAI;IAChB;;OAEG;IACH,KAAK,IAAI;IACT;;OAEG;IACH,cAAc,IAAI;IAClB;;OAEG;IACH,YAAY,IAAI;IAChB;;OAEG;IACH,aAAa,IAAI;IACjB;;OAEG;IACH,UAAU,IAAI;IACd;;OAEG;IACH,WAAW,IAAI;CAChB"}
+63
View File
@@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Colors = exports.LogLevel = void 0;
var LogLevel;
(function (LogLevel) {
/**
* For debugging and development.
*/
LogLevel[LogLevel["Debug"] = 1] = "Debug";
/**
* Contain the most detailed messages.
*/
LogLevel[LogLevel["Verbose"] = 2] = "Verbose";
/**
* Tracks the general flow of the app. May have long-term value.
*/
LogLevel[LogLevel["Info"] = 3] = "Info";
/**
* For abnormal or unexpected events. Typically includes errors or conditions that don't cause the app to fail.
*/
LogLevel[LogLevel["Warning"] = 4] = "Warning";
/**
* For errors and exceptions that cannot be handled. These messages indicate a failure in the current operation or request, not an app-wide failure.
*/
LogLevel[LogLevel["Error"] = 5] = "Error";
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
/**
* Colors for CLI output message
*/
var Colors;
(function (Colors) {
/**
* Primary text color
*/
Colors[Colors["BRIGHT_WHITE"] = 0] = "BRIGHT_WHITE";
/**
* Secondary text color
*/
Colors[Colors["WHITE"] = 1] = "WHITE";
/**
* Important text color
*/
Colors[Colors["BRIGHT_MAGENTA"] = 2] = "BRIGHT_MAGENTA";
/**
* Success message indicator
*/
Colors[Colors["BRIGHT_GREEN"] = 3] = "BRIGHT_GREEN";
/**
* Warning message indicator
*/
Colors[Colors["BRIGHT_YELLOW"] = 4] = "BRIGHT_YELLOW";
/**
* Error message indicator
*/
Colors[Colors["BRIGHT_RED"] = 5] = "BRIGHT_RED";
/**
* Hyperlink
*/
Colors[Colors["BRIGHT_CYAN"] = 6] = "BRIGHT_CYAN";
})(Colors = exports.Colors || (exports.Colors = {}));
//# sourceMappingURL=log.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;AAEb,IAAY,QAqBX;AArBD,WAAY,QAAQ;IAClB;;OAEG;IACH,yCAAS,CAAA;IACT;;OAEG;IACH,6CAAW,CAAA;IACX;;OAEG;IACH,uCAAQ,CAAA;IACR;;OAEG;IACH,6CAAW,CAAA;IACX;;OAEG;IACH,yCAAS,CAAA;AACX,CAAC,EArBW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAqBnB;AAgDD;;GAEG;AACH,IAAY,MA6BX;AA7BD,WAAY,MAAM;IAChB;;OAEG;IACH,mDAAgB,CAAA;IAChB;;OAEG;IACH,qCAAS,CAAA;IACT;;OAEG;IACH,uDAAkB,CAAA;IAClB;;OAEG;IACH,mDAAgB,CAAA;IAChB;;OAEG;IACH,qDAAiB,CAAA;IACjB;;OAEG;IACH,+CAAc,CAAA;IACd;;OAEG;IACH,iDAAe,CAAA;AACjB,CAAC,EA7BW,MAAM,GAAN,cAAM,KAAN,cAAM,QA6BjB"}
+184
View File
@@ -0,0 +1,184 @@
import { TokenCredential } from "@azure/core-auth";
import { Result } from "neverthrow";
import { FxError } from "../error";
export type AzureCredential = {
type: "AuthorizationCode";
/**
* The user account's e-mail address (user name).
*/
username: string;
/**
* The Microsoft Entra tenant (directory) ID.
* This parameter is used for multi-tenant account scenario
*/
tenantId?: string;
/**
* whether pop up sign in flow if the account is not signed in, default is true
*/
popUpSignIn?: boolean;
} | {
type: "ClientSecretCredential";
/**
* The Microsoft Entra tenant (directory) ID.
*/
tenantId: string;
/**
* The client (application) ID of an App Registration in the tenant.
*/
clientId: string;
/**
* A client secret that was generated for the App Registration.
*/
clientSecret: string;
} | {
type: "ClientCertificateCredential";
/**
* The Microsoft Entra tenant (directory) ID.
*/
tenantId: string;
/**
* The client (application) ID of an App Registration in the tenant.
*/
clientId: string;
/**
* The path to a PEM-encoded public/private key certificate on the filesystem.
*/
certificatePath: string;
};
/**
* Difference between getAccountCredential and getIdentityCredential [Node Azure Authenticate](https://docs.microsoft.com/en-us/azure/developer/javascript/core/node-sdk-azure-authenticate)
* You can search at [Azure JS SDK](https://docs.microsoft.com/en-us/javascript/api/overview/azure/?view=azure-node-latest) to see which credential you need.
*/
export interface AzureAccountProvider {
/**
* Async get identity [crendential](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-auth/src/tokenCredential.ts)
* @param showDialog Control whether the UI layer displays pop-up windows.
*/
getIdentityCredentialAsync(showDialog?: boolean): Promise<TokenCredential | undefined>;
/**
* To support credential per action feature, caller can specify credential info for on demand
* This method will be optional until V3 first release, after that it will be changed to required
* @param credential
*/
getIdentityCredential?(credential: AzureCredential): Promise<TokenCredential | undefined>;
/**
* Azure sign out
*/
signout(): Promise<boolean>;
/**
* Switch to specified tenant for current user account
* @param tenantId id of tenant that user wants to switch to
*/
switchTenant(tenantId: string): Promise<Result<TokenCredential, FxError>>;
/**
* Add update account info callback
* @param name callback name
* @param statusChange callback method
* @param immediateCall whether callback when register, the default value is true
*/
setStatusChangeMap(name: string, statusChange: (status: string, token?: string, accountInfo?: Record<string, unknown>) => Promise<void>, immediateCall?: boolean): Promise<boolean>;
/**
* Remove update account info callback
* @param name callback name
*/
removeStatusChangeMap(name: string): Promise<boolean>;
/**
* Get Azure token JSON object
* - tid : tenantId
* - unique_name : user name
* - ...
* @param showDialog Control whether the UI layer displays pop-up windows
*/
getJsonObject(showDialog?: boolean): Promise<Record<string, unknown> | undefined>;
/**
* List subscription detail
*/
listSubscriptions(): Promise<SubscriptionInfo[]>;
/**
* Set subscription id to memory
* @param subscriptionId user used subscription id (subscriptionId==="" will clear sub information in Azure account provider
* cache)
*/
setSubscription(subscriptionId: string): Promise<void>;
/**
* Get account information
*/
getAccountInfo(): Record<string, string> | undefined;
/**
* Get user select subscription, tenant information
* @param triggerUI whether means trigger login or select subscription workflow when user has not logged in or selected subscription
* @returns SubscriptionInfo.subscriptionId === "", means user does not select subscription
*/
getSelectedSubscription(triggerUI?: boolean): Promise<SubscriptionInfo | undefined>;
}
export type SubscriptionInfo = {
subscriptionName: string;
subscriptionId: string;
tenantId: string;
};
export declare type TokenRequest = {
scopes: Array<string>;
showDialog?: boolean;
};
export type LoginStatus = {
status: string;
token?: string;
accountInfo?: Record<string, unknown>;
};
/**
* Provide M365 accessToken and JSON object
*
*/
export interface M365TokenProvider {
/**
* Get M365 access token
* @param tokenRequest permission scopes or show user interactive UX
*/
getAccessToken(tokenRequest: TokenRequest): Promise<Result<string, FxError>>;
/**
* Get M365 token Json object
* - tid : tenantId
* - unique_name : user name
* - ...
* @param tokenRequest permission scopes or show user interactive UX
*/
getJsonObject(tokenRequest: TokenRequest): Promise<Result<Record<string, unknown>, FxError>>;
/**
* Get user login status
* @param tokenRequest permission scopes or show user interactive UX
*/
getStatus(tokenRequest: TokenRequest): Promise<Result<LoginStatus, FxError>>;
/**
* Switch to specified tenant for current user account
* @param tenantId id of tenant that user wants to switch to
*/
switchTenant(tenantId: string): Promise<Result<string, FxError>>;
/**
* Add update account info callback
* @param name callback name
* @param tokenRequest permission scopes
* @param statusChange callback method
* @param immediateCall whether callback when register, the default value is true
*/
setStatusChangeMap(name: string, tokenRequest: TokenRequest, statusChange: (status: string, token?: string, accountInfo?: Record<string, unknown>) => Promise<void>, immediateCall?: boolean): Promise<Result<boolean, FxError>>;
/**
* Remove update account info callback
* @param name callback name
*/
removeStatusChangeMap(name: string): Promise<Result<boolean, FxError>>;
}
export type TokenProvider = {
azureAccountProvider: AzureAccountProvider;
m365TokenProvider: M365TokenProvider;
};
/**
* Provide basic login framework
*/
export declare abstract class BasicLogin {
statusChangeMap: Map<any, any>;
setStatusChangeMap(name: string, tokenRequest: TokenRequest, statusChange: (status: string, token?: string, accountInfo?: Record<string, unknown>) => Promise<void>, immediateCall?: boolean): Promise<Result<boolean, FxError>>;
removeStatusChangeMap(name: string): Promise<Result<boolean, FxError>>;
abstract getStatus(tokenRequest: TokenRequest): Promise<Result<LoginStatus, FxError>>;
notifyStatus(tokenRequest: TokenRequest): Promise<void>;
}
//# sourceMappingURL=login.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/utils/login.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAM,MAAM,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GACD;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B;;OAEG;IACH,QAAQ,EAA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AO,CAAC,CAAC;IAE/E,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAY9D"}
+38
View File
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BasicLogin = void 0;
const neverthrow_1 = require("neverthrow");
/**
* Provide basic login framework
*/
class BasicLogin {
constructor() {
this.statusChangeMap = new Map();
}
async setStatusChangeMap(name, tokenRequest, statusChange, immediateCall = true) {
this.statusChangeMap.set(name, statusChange);
if (immediateCall) {
const loginStatusRes = await this.getStatus(tokenRequest);
if (loginStatusRes.isOk()) {
await statusChange(loginStatusRes.value.status, loginStatusRes.value.token, loginStatusRes.value.accountInfo);
}
}
return (0, neverthrow_1.ok)(true);
}
removeStatusChangeMap(name) {
this.statusChangeMap.delete(name);
return Promise.resolve((0, neverthrow_1.ok)(true));
}
async notifyStatus(tokenRequest) {
const loginStatusRes = await this.getStatus(tokenRequest);
if (loginStatusRes.isOk()) {
for (const entry of this.statusChangeMap.entries()) {
entry[1](loginStatusRes.value.status, loginStatusRes.value.token, loginStatusRes.value.accountInfo);
}
}
}
}
exports.BasicLogin = BasicLogin;
//# sourceMappingURL=login.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/utils/login.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;AAGb,2CAAwC;AA+MxC;;GAEG;AACH,MAAsB,UAAU;IAAhC;QACE,oBAAe,GAAG,IAAI,GAAG,EAAE,CAAC;IA6C9B,CAAC;IA3CC,KAAK,CAAC,kBAAkB,CACtB,IAAY,EACZ,YAA0B,EAC1B,YAIkB,EAClB,aAAa,GAAG,IAAI;QAEpB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC7C,IAAI,aAAa,EAAE;YACjB,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;YAC1D,IAAI,cAAc,CAAC,IAAI,EAAE,EAAE;gBACzB,MAAM,YAAY,CAChB,cAAc,CAAC,KAAK,CAAC,MAAM,EAC3B,cAAc,CAAC,KAAK,CAAC,KAAK,EAC1B,cAAc,CAAC,KAAK,CAAC,WAAW,CACjC,CAAC;aACH;SACF;QACD,OAAO,IAAA,eAAE,EAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAED,qBAAqB,CAAC,IAAY;QAChC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAA,eAAE,EAAC,IAAI,CAAC,CAAC,CAAC;IACnC,CAAC;IAID,KAAK,CAAC,YAAY,CAAC,YAA0B;QAC3C,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC1D,IAAI,cAAc,CAAC,IAAI,EAAE,EAAE;YACzB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE;gBAClD,KAAK,CAAC,CAAC,CAAC,CACN,cAAc,CAAC,KAAK,CAAC,MAAM,EAC3B,cAAc,CAAC,KAAK,CAAC,KAAK,EAC1B,cAAc,CAAC,KAAK,CAAC,WAAW,CACjC,CAAC;aACH;SACF;IACH,CAAC;CACF;AA9CD,gCA8CC"}
+42
View File
@@ -0,0 +1,42 @@
/**
* Reporter of telemetry to send event and exception to app insights.
* Event and exception follow the [Application Insights telemetry data model](https://docs.microsoft.com/en-us/azure/azure-monitor/app/data-model)
*/
export interface TelemetryReporter {
/**
* Send general events to App Insights
* @param eventName Event name. Max length: 512 characters. To allow proper grouping and useful metrics, restrict your application so that it generates a small number of separate event names.
* @param properties Name-value collection of custom properties. Max key length: 150, Max value length: 8192. this collection is used to extend standard telemetry with the custom dimensions.
* @param measurements Collection of custom measurements. Use this collection to report named measurement associated with the telemetry item.
*
*/
sendTelemetryEvent(eventName: string, properties?: {
[key: string]: string;
}, measurements?: {
[key: string]: number;
}): void;
/**
* Send error telemetry as traditional events to App Insights.
* @param eventName Event name. Max length: 512 characters.
* @param properties Name-value collection of custom properties. Max key length: 150, Max value length: 8192.
* @param measurements Collection of custom measurements.
* @param errorProps Str collection of valuable error messages.
*/
sendTelemetryErrorEvent(eventName: string, properties?: {
[key: string]: string;
}, measurements?: {
[key: string]: number;
}, errorProps?: string[]): void;
/**
* Send error for diagnostics in App Insights.
* @param error Error to troubleshooting.
* @param properties Name-value collection of custom properties. Max key length: 150, Max value length: 8192.
* @param measurements Collection of custom measurements.
*/
sendTelemetryException(error: Error, properties?: {
[key: string]: string;
}, measurements?: {
[key: string]: number;
}): void;
}
//# sourceMappingURL=telemetry.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,kBAAkB,CAChB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EACtC,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GACvC,IAAI,CAAC;IAER;;;;;;OAMG;IACH,uBAAuB,CACrB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EACtC,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EACxC,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,IAAI,CAAC;IAER;;;;;OAKG;IACH,sBAAsB,CACpB,KAAK,EAAE,KAAK,EACZ,UAAU,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EACtC,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GACvC,IAAI,CAAC;CACT"}
+5
View File
@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=telemetry.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/utils/telemetry.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC"}
+32
View File
@@ -0,0 +1,32 @@
import { Result } from "neverthrow";
import { FxError } from "../error";
export interface TreeItem {
commandId: string;
label: string;
callback?: (args: any) => Promise<Result<null, FxError>>;
parent?: TreeCategory | string;
contextValue?: string;
icon?: string;
subTreeItems?: TreeItem[];
tooltip?: {
value: string;
isMarkdown: boolean;
};
description?: string;
isCustom?: boolean;
expanded?: boolean;
}
export interface TreeProvider {
refresh: (tree: TreeItem[]) => Promise<Result<null, FxError>>;
add: (tree: TreeItem[]) => Promise<Result<null, FxError>>;
remove: (tree: TreeItem[]) => Promise<Result<null, FxError>>;
}
export declare enum TreeCategory {
GettingStarted = 0,
Account = 1,
Feedback = 2,
Project = 3,
Provision = 4,
Environment = 5
}
//# sourceMappingURL=tree.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/utils/tree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9D,GAAG,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1D,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9D;AAED,oBAAY,YAAY;IACtB,cAAc,IAAA;IACd,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,SAAS,IAAA;IACT,WAAW,IAAA;CACZ"}
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TreeCategory = void 0;
var TreeCategory;
(function (TreeCategory) {
TreeCategory[TreeCategory["GettingStarted"] = 0] = "GettingStarted";
TreeCategory[TreeCategory["Account"] = 1] = "Account";
TreeCategory[TreeCategory["Feedback"] = 2] = "Feedback";
TreeCategory[TreeCategory["Project"] = 3] = "Project";
TreeCategory[TreeCategory["Provision"] = 4] = "Provision";
TreeCategory[TreeCategory["Environment"] = 5] = "Environment";
})(TreeCategory = exports.TreeCategory || (exports.TreeCategory = {}));
//# sourceMappingURL=tree.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/utils/tree.ts"],"names":[],"mappings":";;;AA4BA,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,mEAAc,CAAA;IACd,qDAAO,CAAA;IACP,uDAAQ,CAAA;IACR,qDAAO,CAAA;IACP,yDAAS,CAAA;IACT,6DAAW,CAAA;AACb,CAAC,EAPW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAOvB"}