UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

83 lines (82 loc) 4.52 kB
import * as semver from 'semver'; import { ServiceEndpoint } from '@hashgraph/sdk'; import { type NodeAlias, type NodeAliases } from '../types/aliases.js'; import { type CommandFlag } from '../types/flag_types.js'; import { type SoloLogger } from './logging.js'; import { type Duration } from './time/duration.js'; import { type ConsensusNode } from './model/consensus_node.js'; import { type Optional } from '../types/index.js'; import { type Version } from './config/remote/types.js'; import { NamespaceName } from './kube/resources/namespace/namespace_name.js'; import { type K8 } from './kube/k8.js'; export declare function getInternalIp(releaseVersion: semver.SemVer, namespaceName: NamespaceName, nodeAlias: NodeAlias): string; export declare function getExternalAddress(consensusNode: ConsensusNode, k8: K8, useLoadBalancer: boolean): Promise<string>; export declare function sleep(duration: Duration): Promise<void>; export declare function parseNodeAliases(input: string): NodeAliases; export declare function splitFlagInput(input: string, separator?: string): string[]; /** * @param arr - The array to be cloned * @returns a new array with the same elements as the input array */ export declare function cloneArray<T>(arr: T[]): T[]; export declare function getTmpDir(): string; export declare function createBackupDir(destDir: string, prefix?: string, curDate?: Date): string; export declare function makeBackup(fileMap?: Map<string, string>, removeOld?: boolean): void; export declare function backupOldTlsKeys(nodeAliases: NodeAliases, keysDir: string, curDate?: Date, dirPrefix?: string): string; export declare function backupOldPemKeys(nodeAliases: NodeAliases, keysDir: string, curDate?: Date, dirPrefix?: string): string; export declare function isNumeric(str: string): boolean; /** * Validate a path provided by the user to prevent path traversal attacks * @param input - the input provided by the user * @returns a validated path */ export declare function validatePath(input: string): string; /** * Create a map of node aliases to account IDs * @param nodeAliases * @returns the map of node IDs to account IDs */ export declare function getNodeAccountMap(nodeAliases: NodeAliases): Map<`node${number}`, string>; export declare function getEnvValue(envVarArray: string[], name: string): string; export declare function parseIpAddressToUint8Array(ipAddress: string): Uint8Array<ArrayBuffer>; /** If the basename of the src did not match expected basename, rename it first, then copy to destination */ export declare function renameAndCopyFile(srcFilePath: string, expectedBaseName: string, destDir: string, logger: SoloLogger): void; /** * Add debug options to valuesArg used by helm chart * @param valuesArg the valuesArg to update * @param debugNodeAlias the node ID to attach the debugger to * @param index the index of extraEnv to add the debug options to * @returns updated valuesArg */ export declare function addDebugOptions(valuesArg: string, debugNodeAlias: NodeAlias, index?: number): string; /** * Returns an object that can be written to a file without data loss. * Contains fields needed for adding a new node through separate commands * @param ctx * @returns file writable object */ export declare function addSaveContextParser(ctx: any): Record<string, string>; /** * Initializes objects in the context from a provided string * Contains fields needed for adding a new node through separate commands * @param ctx - accumulator object * @param ctxData - data in string format * @returns file writable object */ export declare function addLoadContextParser(ctx: any, ctxData: any): void; export declare function prepareEndpoints(endpointType: string, endpoints: string[], defaultPort: number | string): ServiceEndpoint[]; /** Adds all the types of flags as properties on the provided argv object */ export declare function addFlagsToArgv(argv: any, flags: { requiredFlags: CommandFlag[]; requiredFlagsWithDisabledPrompt: CommandFlag[]; optionalFlags: CommandFlag[]; }): any; export declare function resolveValidJsonFilePath(filePath: string, defaultPath?: string): string; export declare function populateHelmArgs(valuesMapping: Record<string, string | boolean | number>): string; /** * @param nodeAlias * @param consensusNodes * @returns context of the node */ export declare function extractContextFromConsensusNodes(nodeAlias: NodeAlias, consensusNodes?: ConsensusNode[]): Optional<string>; export declare function getSoloVersion(): Version;