@hawtio/react
Version:
A Hawtio reimplementation based on TypeScript + React.
921 lines (881 loc) • 37.6 kB
TypeScript
import { P as Plugin, H as Hawtconfig, a as HawtioPlugin } from './logging-DrlUYu4j.js';
export { e as AboutConfig, f as AboutProductInfo, A as AppearanceConfig, h as AuthenticationKind, j as AuthenticationMethod, i as AuthenticationResult, k as BasicAuthenticationMethod, B as BrandingConfig, x as ChildLogger, C as ConfigManager, D as DEFAULT_APP_NAME, b as DEFAULT_LOGIN_TITLE, g as DisabledRoutes, F as FormAuthenticationMethod, c as HAWTCONFIG_JSON, q as HawtioAsyncPlugin, t as HawtioCore, w as HawtioLogger, r as HawtioRemote, o as HeaderItem, m as IConfigManager, s as IHawtio, I as InitializationTasks, J as JmxConfig, y as Logger, L as LoginConfig, d as LoginLink, l as OidcAuthenticationMethod, O as OnlineConfig, v as STORAGE_KEY_CHILD_LOGGERS, S as STORAGE_KEY_LOG_LEVEL, T as TaskState, U as UniversalHeaderItem, n as configManager, u as hawtio, p as isUniversalHeaderItem } from './logging-DrlUYu4j.js';
import * as React$1 from 'react';
import React__default, { ChangeEvent } from 'react';
export * from 'js-logger';
import { IJolokiaSimple, SimpleRequestOptions } from '@jolokia.js/simple';
import * as _patternfly_react_icons_dist_esm_createIcon from '@patternfly/react-icons/dist/esm/createIcon';
import { TreeViewDataItem } from '@patternfly/react-core';
import { MBeanInfo, MBeanAttribute, MBeanOperation, MBeanInfoError, RequestOptions, JolokiaRequest, JolokiaSuccessResponse, JolokiaErrorResponse, JolokiaFetchErrorResponse } from 'jolokia.js';
import '@module-federation/utilities';
declare const PUBLIC_USER = "public";
/**
* Custom React hook for accessing information about currently logged in user and
* information about user loading process state.
*
* This hook holds:
* * a state for user name
* * a state for a flag indicating user is correctly logged in (is not a guest/public user)
* * a state for a flag indicating failed login attempt
* * a state for a flag indicating error message if there was a login error
* * a state for a flag indicating userService finished its async operation (user retrieval)
* * a state for selected login method - depending on which plugin successfully fetched the user
* * an effect that synchronizes with `userService` to alter the state
*
* This hook synchronizes with information retrieved from `userService` (which in turn may use auth hooks).
*/
declare function useUser(): {
username: string;
isLogin: boolean;
userLoaded: boolean;
loginMethod: string;
isLoginError: boolean;
loginError: string;
};
/** Information about logged-in user */
type User = {
/** Name of the user */
username: string;
/** Flag for actual user (`false` means guest or public user) */
isLogin: boolean;
/** Identifier of authentication method used to fetch the user, so we can later use correct logout */
loginMethod: string;
};
/** Information about attempt to login a user. Only if it indicates success we have `user` promise resolved */
type UserAuthResult = {
/** Should the result be ignored? */
isIgnore: boolean;
/** Was authentication successful? */
isError: boolean;
/** For error logins, message provides some details */
errorMessage?: string | null;
/** Identifier of authentication method used to fetch the user, so we can later use correct logout */
loginMethod: string;
};
/** User resolving function that resolves user promise */
type ResolveUser = (user: User) => void;
/** A function that may be registered by authentication plugin used to get information about logged-in user */
type FetchUserHook = (resolve: ResolveUser, proceed?: () => boolean) => Promise<UserAuthResult>;
/** A function that may be registered by authentication plugin used to log out a user */
type LogoutHook = () => Promise<boolean>;
interface IUserService {
addFetchUserHook(name: string, hook: FetchUserHook): void;
addLogoutHook(name: string, hook: LogoutHook): void;
fetchUser(retry?: boolean, proceed?: () => boolean): Promise<void>;
getUsername(): Promise<string | null>;
isLogin(): Promise<boolean>;
isLoginError(): Promise<boolean>;
loginError(): Promise<string | null>;
getLoginMethod(): Promise<string>;
getToken(): string | null;
setToken(token: string): void;
logout(): Promise<boolean>;
}
declare class UserService implements IUserService {
/** The main promise resolving to `User` instance. That's why we need full browser redirect on logout. */
private readonly user;
/** user promise resolve method - to be called by registered auth plugins or default auth plugin */
private resolveUser;
/** Result of fetching user with plugins. When it indicates an error `user` promise won't be resolved */
private userAuthResult;
/** Named authentication hooks used to fetch information about actual user logged into Hawtio. */
private fetchUserHooks;
/** Named authentication hooks used to logout the user. */
private logoutHooks;
/** Bearer Token to be used by Jolokia, set by plugins on successful authentication */
private token;
constructor();
addFetchUserHook(name: string, hook: FetchUserHook): void;
addLogoutHook(name: string, hook: LogoutHook): void;
/**
* Sync login status with the server by fetching login user.
*/
fetchUser(retry?: boolean, proceed?: () => boolean): Promise<void>;
/**
* Default user fetching logic that checks `/user` endpoint that returns json string value with named/logged-in user
* @param retry
* @param proceed
* @private
*/
private defaultFetchUser;
getUsername(): Promise<string | null>;
isLogin(): Promise<boolean>;
isLoginError(): Promise<boolean>;
loginError(): Promise<string | null>;
getLoginMethod(): Promise<string>;
getToken(): string | null;
setToken(token: string): void;
logout(): Promise<boolean>;
}
declare const userService: UserService;
declare const __testing__: {
UserService: typeof UserService;
};
type NotificationType = 'info' | 'success' | 'warning' | 'danger' | 'custom';
type Notification = {
type: NotificationType;
message: React__default.ReactNode;
duration?: number;
};
type EventListener = () => void;
type NotificationListener = (notification: Notification) => void;
type HawtioEvent = 'notify' | 'login' | 'logout' | 'refresh' | 'pluginsUpdated';
declare const EVENT_NOTIFY: HawtioEvent;
declare const EVENT_LOGIN: HawtioEvent;
declare const EVENT_LOGOUT: HawtioEvent;
declare const EVENT_REFRESH: HawtioEvent;
declare const EVENT_PLUGINS_UPDATED: HawtioEvent;
interface IEventService {
notify(notification: Notification): void;
onNotify(listener: NotificationListener): void;
login(): void;
onLogin(listener: EventListener): void;
logout(): void;
onLogout(listener: EventListener): void;
refresh(): void;
onRefresh(listener: EventListener): void;
pluginsUpdated(): void;
onPluginsUpdated(listener: EventListener): void;
removeListener(event: HawtioEvent, listener: EventListener | NotificationListener): void;
}
declare class EventService implements IEventService {
private eventEmitter;
notify(notification: Notification): void;
onNotify(listener: NotificationListener): void;
login(): void;
onLogin(listener: EventListener): void;
logout(): void;
onLogout(listener: EventListener): void;
refresh(): void;
onRefresh(listener: EventListener): void;
pluginsUpdated(): void;
onPluginsUpdated(listener: EventListener): void;
removeListener(event: HawtioEvent, listener: EventListener | NotificationListener): void;
}
declare const eventService: EventService;
/**
* Custom React hook for accessing information about Hawtio plugins.
*
* This hook holds:
* * a state for an array of Plugin objects
* * a state for a flag indicating that plugins are loaded
*
* This hook synchronizes with interal Hawtio services that manage plugins state and configuration.
*/
declare function usePlugins(): {
plugins: Plugin[];
pluginsLoaded: boolean;
};
/**
* Custom React hook for using `hawtconfig.json`.
*
* This hook holds:
* * a state for `Hawtconfig` object
*
* This hook synchronizes (once, cached in `configManager`) with `hawtconfig.json` resource.
*/
declare function useHawtconfig(): {
hawtconfig: Hawtconfig;
hawtconfigLoaded: boolean;
};
type Help = {
id: string;
title: string;
content: string;
order: number;
};
declare class HelpRegistry {
private helps;
add(id: string, title: string, content: string, order?: number): void;
getHelps(): Help[];
reset(): void;
}
declare const helpRegistry: HelpRegistry;
declare const keycloak: HawtioPlugin;
declare const oidc: HawtioPlugin;
declare const camel: HawtioPlugin;
declare const HawtioEmptyCard: React__default.FunctionComponent<{
title?: string;
message: string;
testid?: string;
}>;
declare const HawtioLoadingCard: React__default.FunctionComponent<{
message?: string;
testid?: string;
}>;
declare const JmxContentMBeans: React.FunctionComponent;
interface ToolbarProps {
onSearch: (event: ChangeEvent<HTMLInputElement>) => void;
onSetExpanded: (newExpanded: boolean) => void;
}
declare const PluginTreeViewToolbar: React__default.FunctionComponent<ToolbarProps>;
declare const Attributes: React__default.FunctionComponent;
declare const AttributeModal: React__default.FunctionComponent<{
isOpen: boolean;
onClose: () => void;
onUpdate: () => void;
input: {
name: string;
value: string;
};
}>;
declare const AttributeTable: React__default.FunctionComponent;
declare const Chart: React__default.FunctionComponent;
type Connections = {
[key: string]: Connection;
};
type Connection = {
id: string;
name: string;
scheme: 'http' | 'https';
host: string;
port: number;
path: string;
jolokiaUrl?: string;
username?: string;
password?: string;
};
declare const INITIAL_CONNECTION: Connection;
type ConnectionTestResult = {
status: ConnectStatus;
message: string;
};
type ConnectionCredentials = {
username: string;
password: string;
};
type LoginResult = {
type: 'success';
} | {
type: 'failure';
} | {
type: 'throttled';
retryAfter: number;
} | {
type: 'session-expired';
};
/**
* Remote connection status. "not-reachable-securely" is for connections that can't be used in insecure contexts.
*/
type ConnectStatus = 'not-reachable' | 'reachable' | 'not-reachable-securely';
declare const SESSION_KEY_CURRENT_CONNECTION = "connect.currentConnection";
declare const PARAM_KEY_CONNECTION = "con";
declare const PARAM_KEY_REDIRECT = "redirect";
interface IConnectService {
getCurrentConnectionId(): string | null;
getCurrentConnectionName(): string | null;
getCurrentConnection(): Promise<Connection | null>;
getCurrentCredentials(): Promise<ConnectionCredentials | null>;
loadConnections(): Connections;
saveConnections(connections: Connections): void;
getConnection(id: string): Connection | null;
connectionToUrl(connection: Connection): string;
checkReachable(connection: Connection): Promise<ConnectStatus>;
testConnection(connection: Connection): Promise<ConnectionTestResult>;
connect(connection: Connection, current?: boolean): void;
login(username: string, password: string): Promise<LoginResult>;
redirect(): void;
createJolokia(connection: Connection, checkCredentials?: boolean): IJolokiaSimple;
getJolokiaUrl(connection: Connection): string;
getJolokiaUrlFromId(name: string): string | null;
getLoginPath(): string;
export(connections: Connections): void;
}
declare class ConnectService implements IConnectService {
private currentConnectionId;
constructor();
/**
* The precedence of the current connection is as follows:
* 1. URL query parameter: {@link PARAM_KEY_CONNECTION}
* 2. Session storage: {@link SESSION_KEY_CURRENT_CONNECTION}
* 3. Preset connections from the backend API: {@link PATH_PRESET_CONNECTIONS}
* (after page reload or new tabs opened)
*/
private initCurrentConnectionId;
private resolveConnectionId;
/**
* See: https://github.com/hawtio/hawtio/issues/3731
*/
private loadPresetConnections;
private getPresetConnectionsPath;
getCurrentConnectionId(): string | null;
getCurrentConnectionName(): string | null;
getCurrentConnection(): Promise<Connection | null>;
setCurrentConnection(connection: Connection): void;
private clearCredentialsOnLogout;
getCurrentCredentials(): Promise<ConnectionCredentials | null>;
private setCurrentCredentials;
loadConnections(): Connections;
saveConnections(connections: Connections): void;
generateId(connection: Connection, connections: Connections): void;
getConnection(id: string): Connection | null;
connectionToUrl(connection: Connection): string;
checkReachable(connection: Connection): Promise<ConnectStatus>;
testConnection(connection: Connection): Promise<ConnectionTestResult>;
private forbiddenReasonMatches;
connect(connection: Connection, current?: boolean): void;
/**
* Log in to the current connection.
*/
login(username: string, password: string): Promise<LoginResult>;
/**
* Redirect to the URL specified in the query parameter {@link PARAM_KEY_REDIRECT}.
*/
redirect(): void;
/**
* Create a Jolokia instance with the given connection.
*/
createJolokia(connection: Connection, checkCredentials?: boolean): IJolokiaSimple;
/**
* Get the Jolokia URL for the given connection.
*/
getJolokiaUrl(connection: Connection): string;
/**
* Get the Jolokia URL for the given connection ID.
*/
getJolokiaUrlFromId(id: string): string | null;
getLoginPath(): string;
export(connections: Connections): void;
}
declare const connectService: ConnectService;
declare const Icons: {
readonly folder: React__default.CElement<_patternfly_react_icons_dist_esm_createIcon.SVGIconProps, React__default.Component<_patternfly_react_icons_dist_esm_createIcon.SVGIconProps, any, any>>;
readonly folderOpen: React__default.CElement<_patternfly_react_icons_dist_esm_createIcon.SVGIconProps, React__default.Component<_patternfly_react_icons_dist_esm_createIcon.SVGIconProps, any, any>>;
readonly mbean: React__default.CElement<_patternfly_react_icons_dist_esm_createIcon.SVGIconProps, React__default.Component<_patternfly_react_icons_dist_esm_createIcon.SVGIconProps, any, any>>;
readonly locked: React__default.CElement<_patternfly_react_icons_dist_esm_createIcon.SVGIconProps, React__default.Component<_patternfly_react_icons_dist_esm_createIcon.SVGIconProps, any, any>>;
};
type OptimisedJmxDomains = Record<string, OptimisedJmxDomain>;
declare function isJmxDomains(value: unknown): value is OptimisedJmxDomains;
type OptimisedJmxDomain = Record<string, OptimisedMBeanInfo>;
declare function isJmxDomain(value: unknown): value is OptimisedJmxDomain;
interface OptimisedMBeanInfo extends Omit<MBeanInfo, 'attr' | 'op'> {
attr?: Record<string, OptimisedMBeanAttribute>;
op?: OptimisedMBeanOperations;
opByString?: Record<string, OptimisedMBeanOperation>;
canInvoke?: boolean;
}
declare function isMBeanInfo(value: unknown): value is OptimisedMBeanInfo;
declare function isMBeanInfoError(value: unknown): value is MBeanInfoError;
interface OptimisedMBeanAttribute extends MBeanAttribute {
canInvoke?: boolean;
canRead?: boolean;
canWrite?: boolean;
}
type OptimisedMBeanOperations = Record<string, OptimisedMBeanOperation | OptimisedMBeanOperation[]>;
interface OptimisedMBeanOperation extends MBeanOperation {
canInvoke?: boolean;
}
type MBeanNodeFilterFn = (node: MBeanNode) => boolean;
declare const MBEAN_NODE_ID_SEPARATOR = "-";
declare class MBeanNode implements TreeViewDataItem {
parent: MBeanNode | null;
readonly name: string;
private readonly folder;
/**
* ID of the tree view item in HTML.
*/
id: string;
icon: React__default.ReactNode;
expandedIcon?: React__default.ReactNode;
children?: MBeanNode[];
/**
* Various metadata that can be attached to the node for processing it in the MBean tree.
*/
private metadata;
objectName?: string;
mbean?: OptimisedMBeanInfo;
propertyList?: PropertyList;
defaultExpanded?: boolean;
/**
* A new node
* @constructor
* @param {MBeanNode|null} parent - The parent of the new node. Otherwise, for a singleton node use null.
* @param {string} name - The name of the new node.
* @param {boolean} folder - Whether this new node is a folder, ie. has children
*/
constructor(parent: MBeanNode | null, name: string, folder: boolean);
private generateId;
initId(recursive: boolean): void;
populateMBean(propList: string, mbean: OptimisedMBeanInfo): void;
private createMBeanNode;
private configureMBean;
private applyCanInvoke;
/**
* Copy the node to a new node with the given name, transferring the icons, children,
* metadata, and MBean info.
*/
copyTo(name: string): MBeanNode;
/**
* Find children with the given name. There can be at most two nodes with the
* same name, one as an MBean and the other as a folder.
*
* Think about the following case:
* - MBean1: 'com.example:type=Example,name=App'
* - MBean2: 'com.example:type=Example,name=App,sub=Part1'
* - MBean3: 'com.example:type=Example,name=App,sub=Part2'
* In this case, there can be two nodes with the same name 'App', one is MBean1,
* and the other is the folder that contains MBean2 and MBean3.
*/
findChildren(name: string): MBeanNode[];
/**
* Return a child node with the given name or null. The 'folder' parameter is
* required to identify a single node, as there can be at most two nodes with
* the same name, one as an MBean and the other as a folder.
*
* See the JSDoc comment for the findChildren(name: string) method for more detail.
*/
get(name: string, folder: boolean): MBeanNode | null;
getIndex(index: number): MBeanNode | null;
getChildren(): MBeanNode[];
create(name: string, folder: boolean): MBeanNode;
getOrCreate(name: string, folder: boolean): MBeanNode;
removeChildren(): MBeanNode[];
removeChild(child: MBeanNode): MBeanNode | null;
childCount(): number;
getType(): string | undefined;
setType(type: string): void;
getMetadata(key: string): string | undefined;
addMetadata(key: string, value: string): void;
getProperty(key: string): string | undefined;
static sorter(a: MBeanNode, b: MBeanNode): number;
sort(recursive: boolean): void;
path(): string[];
navigate(...namePath: string[]): MBeanNode | null;
/**
* Perform a function on each node in the given path
* where the namePath drills down to descendants from
* this node
*/
forEach(namePath: string[], eachFn: (node: MBeanNode) => void): void;
/**
* Searches this node and all its descendants for the first node to match the filter.
*/
find(filter: MBeanNodeFilterFn): MBeanNode | null;
private findByNamePattern;
/**
* Finds MBeans in this node and all its descendants based on the properties.
*/
findMBeans(properties: Record<string, string>): MBeanNode[];
/**
* Matches the node with the given MBean properties.
* Since only MBean node holds the properties, this method always returns false
* when invoked on a folder node.
*/
match(properties: Record<string, string>): boolean;
/**
* Returns the chain of nodes forming the tree branch of ancestors
* @method findAncestors
* @for Node
* @return {MBeanNode[]}
*/
findAncestors(): MBeanNode[];
/**
* Returns the first node in the tree branch of ancestors that satisfies the given filter
* @method findAncestor
* @for Node
* @return {MBeanNode}
*/
findAncestor(filter: MBeanNodeFilterFn): MBeanNode | null;
filterClone(filter: MBeanNodeFilterFn): MBeanNode | null;
adopt(child: MBeanNode): void;
/**
* Recursive method to flatten MBeans.
*/
flatten(mbeans: Record<string, MBeanNode>): void;
/**
* Returns true if RBACDecorator has been already applied to this node at server side.
* If the node doesn't have mbean or mbean.op, it always returns true.
* https://github.com/hawtio/hawtio/blob/main/platforms/hawtio-osgi-jmx/src/main/java/io/hawt/osgi/jmx/RBACDecorator.java
*/
isRBACDecorated(): boolean;
updateCanInvoke(canInvoke: boolean): void;
setIcons(icon: React__default.ReactNode, expandedIcon?: React__default.ReactNode): void;
/**
* Returns true only if all the given operations exist in this MBean node.
*/
hasOperations(...names: string[]): boolean;
/**
* Returns true only if all the given methods can be invoked.
*/
hasInvokeRights(...methods: string[]): boolean;
/**
* Returns true only if all relevant operations can be invoked.
*/
private resolveCanInvokeInOps;
private resolveCanInvoke;
}
declare class PropertyList {
private domain;
private propList;
private properties;
private paths;
typeName?: string;
serviceName?: string;
private readonly propRegex;
constructor(domain: MBeanNode, propList: string);
private parse;
private parseProperty;
/**
* Reorders paths when they aren't in the correct order.
*/
private maybeReorderPaths;
get(key: string): string | undefined;
match(properties: Record<string, string>): boolean;
getPaths(): string[];
objectName(): string;
}
/**
* The object representation of MBean tree.
* Internally, it is constructed of MBeanNode[].
*/
declare class MBeanTree {
private id;
private tree;
static createEmpty(id: string): MBeanTree;
static createFromDomains(id: string, domains: OptimisedJmxDomains): Promise<MBeanTree>;
static createFromNodes(id: string, nodes: MBeanNode[]): MBeanTree;
static filter(originalTree: MBeanNode[], filter: MBeanNodeFilterFn): MBeanNode[];
private constructor();
private populate;
private populateDomain;
private getOrCreateNode;
private sortTree;
getTree(): MBeanNode[];
get(name: string): MBeanNode | null;
isEmpty(): boolean;
/**
* Searches the entire tree for the first MBean node to match the filter.
*/
find(filter: MBeanNodeFilterFn): MBeanNode | null;
/**
* Finds MBeans in the tree based on the domain name and properties.
*/
findMBeans(domainName: string, properties: Record<string, string>): MBeanNode[];
private descendByPathEntry;
navigate(...namePath: string[]): MBeanNode | null;
/**
* Perform a function on each node in the given path
* where the namePath drills down to descendants of this tree
*/
forEach(namePath: string[], eachFn: (node: MBeanNode) => void): void;
/**
* Flattens the tree of nested folder and MBean nodes into a map of object names and MBeans.
*/
flatten(): Record<string, MBeanNode>;
}
type TreeProcessor = (tree: MBeanTree) => Promise<void>;
type TreeProcessors = {
[name: string]: TreeProcessor;
};
interface ITreeProcessorRegistry {
add(name: string, processor: TreeProcessor): void;
process(tree: MBeanTree): Promise<void>;
getProcessors(): TreeProcessors;
reset(): void;
}
declare class TreeProcessorRegistry implements ITreeProcessorRegistry {
private processors;
add(name: string, processor: TreeProcessor): void;
process(tree: MBeanTree): Promise<void>;
getProcessors(): TreeProcessors;
reset(): void;
}
declare const treeProcessorRegistry: TreeProcessorRegistry;
declare const DEFAULT_MAX_DEPTH = 7;
declare const DEFAULT_MAX_COLLECTION_SIZE = 50000;
declare const DEFAULT_UPDATE_RATE = 5000;
declare const DEFAULT_AUTO_REFRESH = false;
declare enum JolokiaListMethod {
/** The default LIST+EXEC Jolokia operations. */
DEFAULT = 0,
/** The optimised list operation provided by Hawtio RBACRegistry MBean. */
OPTIMISED = 1,
/** THe optimised list operation provided directly by Jolokia 2.1+ */
NATIVE = 2,
/** Not determined. */
UNDETERMINED = 3
}
type OptimisedListResponse = {
cache: OptimisedMBeanInfoCache;
domains: CacheableOptimisedJmxDomains;
};
type OptimisedMBeanInfoCache = Record<string, OptimisedMBeanInfo>;
type CacheableOptimisedJmxDomains = Record<string, CacheableOptimisedJmxDomain>;
type CacheableOptimisedJmxDomain = Record<string, OptimisedMBeanInfo | string>;
type JolokiaConfig = {
method: JolokiaListMethod;
mbean: string;
};
type JolokiaStoredOptions = {
maxDepth: number;
maxCollectionSize: number;
};
declare const STORAGE_KEY_JOLOKIA_OPTIONS = "connect.jolokia.options";
declare const STORAGE_KEY_UPDATE_RATE = "connect.jolokia.updateRate";
declare const STORAGE_KEY_AUTO_REFRESH = "connect.jolokia.autoRefresh";
/** Narrowed Jolokia ReadResponseValue type - only a record of attribute values */
type AttributeValues = Record<string, unknown>;
/**
* Jolokia access interface used by Hawtio. Underneath, Jolokia's own {@link IJolokiaSimple} interface is used, but it
* can also be obtained from this interface, to be used directly.
*/
interface IJolokiaService {
reset(): void;
getJolokiaUrl(): Promise<string | null>;
getFullJolokiaUrl(): Promise<string>;
getJolokia(): Promise<IJolokiaSimple>;
getListMethod(): Promise<JolokiaListMethod>;
list(options?: SimpleRequestOptions): Promise<OptimisedJmxDomains>;
sublist(paths: string | string[], options?: SimpleRequestOptions): Promise<OptimisedJmxDomains>;
readAttributes(mbean: string, options?: RequestOptions): Promise<AttributeValues>;
readSpecifiedAttributes(mbean: string, attributes: string[], options?: RequestOptions): Promise<AttributeValues>;
readAttribute(mbean: string, attribute: string, options?: RequestOptions): Promise<unknown>;
writeAttribute(mbean: string, attribute: string, value: unknown, options?: RequestOptions): Promise<unknown>;
execute(mbean: string, operation: string, args?: unknown[], options?: SimpleRequestOptions): Promise<unknown>;
search(mbeanPattern: string, options?: SimpleRequestOptions): Promise<string[]>;
bulkRequest(requests: JolokiaRequest[], options?: RequestOptions): Promise<(JolokiaSuccessResponse | JolokiaErrorResponse)[]>;
register(request: JolokiaRequest, callback: (response: JolokiaSuccessResponse | JolokiaErrorResponse | JolokiaFetchErrorResponse) => void): Promise<number>;
unregister(handle: number): void;
loadUpdateRate(): number;
saveUpdateRate(value: number): void;
loadAutoRefresh(): boolean;
saveAutoRefresh(value: boolean): void;
loadJolokiaStoredOptions(): JolokiaStoredOptions;
saveJolokiaStoredOptions(options: JolokiaStoredOptions): void;
errorMessage(error: unknown): string | null;
}
declare class JolokiaService implements IJolokiaService {
private jolokiaUrl?;
private jolokia?;
private config;
private readonly JOLOKIA_PATHS;
constructor();
reset(): void;
/**
* Get the Jolokia URL that the service is connected to.
*
* The URL may not be a full URL including origin (`http(s)://host:port`).
* It can be a path relative to the root (`/hawtio/jolokia`) or to the current
* path (`jolokia`).
*
* @see Use {@link getFullJolokiaUrl} for getting the full URL.
*/
getJolokiaUrl(): Promise<string | null>;
getJolokia(): Promise<IJolokiaSimple>;
private initJolokiaUrl;
private tryProbeJolokiaPath;
private createJolokia;
private configureAuthorization;
private fetchError;
/**
* Queries available server-side MBean to check if we can call optimised `jolokia.list()`
* operation.
*
* @param jolokia Jolokia instance to use
*/
protected checkListOptimisation(jolokia: IJolokiaSimple): Promise<void>;
private loadJolokiaOptions;
/**
* Get the full Jolokia URL that the service is connected to.
*
* The origin part (`http(s)://host:port`) is resolved based on `window.location`.
*
* @see {@link getJolokiaUrl}
*/
getFullJolokiaUrl(): Promise<string>;
getListMethod(): Promise<JolokiaListMethod>;
list(options?: SimpleRequestOptions): Promise<OptimisedJmxDomains>;
sublist(paths: string | string[], options?: SimpleRequestOptions): Promise<OptimisedJmxDomains>;
private doList;
/**
* Detects whether the given response comes from optimised or default list and
* restores its shape to the standard list response of type {@link OptimisedJmxDomains}.
*
* @param response response value from Jolokia LIST
* @param path optional path information to restore the response to {@link OptimisedJmxDomains}
*/
unwindListResponse(response: unknown, path?: string[]): OptimisedJmxDomains;
private bulkList;
private mergeDomains;
/**
* Configure Jolokia's `fetchError` callback which ensures that promises returned by this API are rejected
* in case of Jolokia/HTTP error
* @param options
* @param reject
* @param context additional information when there's an unknown error
* @private
*/
private configureFetchErrorCallback;
/**
* Reading all attributes of an MBean as a record (key-value pairs)
* @param mbean
* @param options
*/
readAttributes(mbean: string, options?: RequestOptions): Promise<AttributeValues>;
/**
* Reading multiple specified attributes of an MBean
* @param mbean
* @param attributes
* @param options
*/
readSpecifiedAttributes(mbean: string, attributes: string[], options?: RequestOptions): Promise<AttributeValues>;
/**
* Reading single attribute of an MBean
* @param mbean
* @param attribute
* @param options
*/
readAttribute(mbean: string, attribute: string, options?: RequestOptions): Promise<unknown>;
/**
* Writing a single attribute of an MBean
* @param mbean
* @param attribute
* @param value
* @param options
*/
writeAttribute(mbean: string, attribute: string, value: unknown, options?: RequestOptions): Promise<unknown>;
/**
* Execute an operation on an MBean
* @param mbean
* @param operation
* @param args
* @param options
*/
execute(mbean: string, operation: string, args?: unknown[], options?: SimpleRequestOptions): Promise<unknown>;
/**
* Execute a search operation, which finds matching MBeans by a pattern
* @param mbeanPattern
*/
search(mbeanPattern: string): Promise<string[]>;
/**
* Perform a bulk request to send multiple Jolokia requests using single HTTP request
* @param requests
* @param options
*/
bulkRequest(requests: JolokiaRequest[], options?: RequestOptions): Promise<(JolokiaSuccessResponse | JolokiaErrorResponse)[]>;
/**
* Register single Jolokia request to be invoked periodically
* @param request
* @param callback
*/
register(request: JolokiaRequest, callback: (response: JolokiaSuccessResponse | JolokiaErrorResponse | JolokiaFetchErrorResponse) => void): Promise<number>;
/**
* Unregisters previously registered _job_
* @param handle
*/
unregister(handle: number): Promise<void>;
loadUpdateRate(): number;
saveUpdateRate(value: number): void;
loadAutoRefresh(): boolean;
saveAutoRefresh(value: boolean): void;
loadJolokiaStoredOptions(): JolokiaStoredOptions;
saveJolokiaStoredOptions(options: JolokiaStoredOptions): void;
errorMessage(error: unknown): string | null;
}
declare const jolokiaService: JolokiaService;
declare const Operations: React__default.FunctionComponent;
interface IWorkspace {
hasErrors(): Promise<boolean>;
getErrors(): Promise<Error[]>;
refreshTree(): Promise<void>;
getTree(): Promise<MBeanTree>;
hasMBeans(): Promise<boolean>;
treeContainsDomainAndProperties(domainName: string, properties?: Record<string, unknown>): Promise<boolean>;
findMBeans(domainName: string, properties: Record<string, unknown>): Promise<MBeanNode[]>;
}
declare const workspace: IWorkspace;
declare const ADD = "ADD";
declare const UPDATE = "UPDATE";
declare const DELETE = "DELETE";
declare const IMPORT = "IMPORT";
declare const RESET = "RESET";
type ConnectionsAction = {
type: typeof ADD;
connection: Connection;
} | {
type: typeof UPDATE;
id: string;
connection: Connection;
} | {
type: typeof DELETE;
id: string;
} | {
type: typeof IMPORT;
connections: Connection[];
} | {
type: typeof RESET;
};
declare function reducer(state: Connections, action: ConnectionsAction): Connections;
declare const connect: HawtioPlugin;
/**
* Target application status plugin,
* only active if the workspace contains no mbeans, ie, totally empty.
* and / or the workspace has produced errors.
* Will communicate this to the user with a notice component.
*/
declare const consoleStatus: HawtioPlugin;
declare const diagnostics: HawtioPlugin;
declare const jmx: HawtioPlugin;
declare const logs: HawtioPlugin;
declare const quartz: HawtioPlugin;
interface IRBACService {
reset(): void;
getACLMBean(): Promise<string | null>;
}
declare class RBACService implements IRBACService {
private aclMBean?;
reset(): void;
getACLMBean(): Promise<string | null>;
private fetchACLMBean;
}
declare const rbacService: RBACService;
declare const rbac: HawtioPlugin;
declare const runtime: HawtioPlugin;
declare const springboot: HawtioPlugin;
/**
* Custom React hook for using a selected node from JMX plugin.
*
* This hook holds:
* * a state for `selectedNode` react value
*
* This hook doesn't synchronize with any external service.
*/
declare function usePluginNodeSelected(): {
selectedNode: MBeanNode | null;
setSelectedNode: React$1.Dispatch<React$1.SetStateAction<MBeanNode | null>>;
};
type PluginNodeSelectionContext = {
/** {@link MBeanNode} selected in the JMX tree, stored in `usePluginNodeSelected` hook's state. */
selectedNode: MBeanNode | null;
/** State setter for currently selected JMX node. */
setSelectedNode: (selectedNode: MBeanNode | null) => void;
};
/**
* PluginNodeSelectionContext gives access to:
* * selected node in JMX tree
* * function to set currently selected node (state setter function)
*
* This context is _provided_ in top level `<HawtioPage>` component and the values come from
* `usePluginNodeSelected` hook.
*/
declare const PluginNodeSelectionContext: React$1.Context<PluginNodeSelectionContext>;
/**
* Registers the builtin plugins for Hawtio React.
*
* The order of loading the builtin plugins is defined by this function.
*/
declare const registerPlugins: () => void;
type Preferences = {
id: string;
title: string;
component: React__default.ComponentType<any>;
order: number;
};
declare class PreferencesRegistry {
private preferences;
add(id: string, title: string, component: React__default.ComponentType<any>, order?: number): void;
getPreferences(): Preferences[];
reset(): void;
}
declare const preferencesRegistry: PreferencesRegistry;
export { ADD, AttributeModal, AttributeTable, type AttributeValues, Attributes, type CacheableOptimisedJmxDomain, type CacheableOptimisedJmxDomains, Chart, type ConnectStatus, type Connection, type ConnectionCredentials, type ConnectionTestResult, type Connections, type ConnectionsAction, DEFAULT_AUTO_REFRESH, DEFAULT_MAX_COLLECTION_SIZE, DEFAULT_MAX_DEPTH, DEFAULT_UPDATE_RATE, DELETE, EVENT_LOGIN, EVENT_LOGOUT, EVENT_NOTIFY, EVENT_PLUGINS_UPDATED, EVENT_REFRESH, type EventListener, type FetchUserHook, Hawtconfig, HawtioEmptyCard, type HawtioEvent, HawtioLoadingCard, HawtioPlugin, type Help, type IConnectService, type IEventService, type IJolokiaService, IMPORT, INITIAL_CONNECTION, type IRBACService, type ITreeProcessorRegistry, type IUserService, type IWorkspace, Icons, JmxContentMBeans, type JolokiaConfig, JolokiaListMethod, type JolokiaStoredOptions, type LoginResult, type LogoutHook, MBEAN_NODE_ID_SEPARATOR, MBeanNode, type MBeanNodeFilterFn, MBeanTree, type Notification, type NotificationListener, type NotificationType, Operations, type OptimisedJmxDomain, type OptimisedJmxDomains, type OptimisedListResponse, type OptimisedMBeanAttribute, type OptimisedMBeanInfo, type OptimisedMBeanInfoCache, type OptimisedMBeanOperation, type OptimisedMBeanOperations, PARAM_KEY_CONNECTION, PARAM_KEY_REDIRECT, PUBLIC_USER, Plugin, PluginNodeSelectionContext, PluginTreeViewToolbar, type Preferences, PropertyList, RESET, type ResolveUser, SESSION_KEY_CURRENT_CONNECTION, STORAGE_KEY_AUTO_REFRESH, STORAGE_KEY_JOLOKIA_OPTIONS, STORAGE_KEY_UPDATE_RATE, type TreeProcessor, type TreeProcessors, UPDATE, type User, type UserAuthResult, __testing__, camel, connect, connectService, consoleStatus, diagnostics, eventService, helpRegistry, isJmxDomain, isJmxDomains, isMBeanInfo, isMBeanInfoError, jmx, jolokiaService, keycloak, logs, oidc, preferencesRegistry, quartz, rbac, rbacService, reducer, registerPlugins, runtime, springboot, treeProcessorRegistry, useHawtconfig, usePluginNodeSelected, usePlugins, useUser, userService, workspace };