@holochain/tryorama
Version:
Toolset to manage Holochain conductors and facilitate running test scenarios
234 lines (233 loc) • 9.74 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { AddAgentInfoRequest, AgentInfoRequest, AgentPubKey, AppAuthenticationToken, AppBundleSource, SignalCb, AttachAppInterfaceRequest, CallZomeRequest, CapSecret, CellId, CreateCloneCellRequest, DeleteCloneCellRequest, DisableAppRequest, DisableCloneCellRequest, DnaDefinition, DnaHash, DumpFullStateRequest, DumpNetworkStatsRequest, DumpStateRequest, EnableAppRequest, EnableCloneCellRequest, FullStateDump, GetCompatibleCellsRequest, GetCompatibleCellsResponse, GetDnaDefinitionRequest, GrantedFunctions, GrantZomeCallCapabilityRequest, InstallAppRequest, IssueAppAuthenticationTokenRequest, ListAppsRequest, MemproofMap, NetworkInfoRequest, RegisterDnaRequest, StartAppRequest, StorageInfoRequest, UninstallAppRequest, UpdateCoordinatorsRequest, RevokeAgentKeyRequest } from "@holochain/client";
import { URL } from "node:url";
import { AgentsAppsOptions, AppOptions, IConductor } from "../../types.js";
import { TryCpClient, TryCpConductorLogLevel } from "../index.js";
/**
* The default partial config for a TryCP conductor.
*
* @public
*/
export declare const DEFAULT_PARTIAL_PLAYER_CONFIG: string;
/**
* @public
*/
export type ConductorId = string;
/**
* @public
*/
export interface TryCpConductorOptions {
/**
* Identifier for the conductor (optional).
*/
id?: ConductorId;
/**
* Configuration for the conductor (optional).
*/
partialConfig?: string;
/**
* Disable DPKI in the conductor instance.
*
* default: false // defaults to using DPKI
*
* unstable
*/
/**
* Set a DPKI network seed.
*
* unstable
*/
/**
* Start up conductor after creation.
*
* default: true
*/
startup?: boolean;
/**
* Log level of the conductor (optional).
*
* default: "error"
*/
logLevel?: TryCpConductorLogLevel;
}
/**
* The function to create a TryCP Conductor. By default configures and starts
* it.
*
* @param tryCpClient - The client connection to the TryCP server on which to
* create the conductor.
* @param options - Options to configure how the conductor will be started and run.
* @returns A conductor instance.
*
* @public
*/
export declare const createTryCpConductor: (tryCpClient: TryCpClient, options?: TryCpConductorOptions) => Promise<TryCpConductor>;
/**
* A class to manage a conductor running on a TryCP server.
*
* @public
*/
export declare class TryCpConductor implements IConductor {
readonly id: string;
readonly tryCpClient: TryCpClient;
constructor(tryCpClient: TryCpClient, id?: ConductorId);
static defaultPartialConfig(): string;
/**
* Create conductor configuration.
*
* @param partialConfig - The configuration to add to the default configuration.
* @param noDpki - Disable the DPKI service on this conductor.
* @param dpkiNetworkSeed - Set DPKI network seed.
* @returns An empty success response.
*/
configure(partialConfig?: string, noDpki?: boolean, dpkiNetworkSeed?: string): Promise<null>;
/**
* Start a configured conductor.
*
* @param options - Log level of the conductor. Defaults to "info".
* @returns An empty success response.
*
* @public
*/
startUp(options?: {
logLevel?: TryCpConductorLogLevel;
}): Promise<null>;
/**
* Shut down the conductor.
*
* @returns An empty success response.
*
* @public
*/
shutDown(): Promise<null>;
/**
* Disconnect the TryCP client from the TryCP server.
*
* @returns The web socket close code.
*/
disconnectClient(): Promise<number>;
/**
* Download a DNA from a URL to the server's file system.
*
* @returns The relative path to the downloaded DNA file.
*/
downloadDna(url: URL): Promise<string>;
/**
* Upload a DNA file from the local file system to the server.
*
* @param dnaContent - The DNA as binary content.
* @returns The relative path to the saved DNA file.
*/
saveDna(dnaContent: Buffer): Promise<string>;
/**
* Connect a web socket to the App API.
*
* @param port - The port to attach the app interface to.
* @returns An empty success response.
*/
connectAppInterface(token: AppAuthenticationToken, port: number): Promise<null>;
/**
* Disconnect a web socket from the App API.
*
* @param port - The port of the app interface to disconnect.
* @returns An empty success response.
*/
disconnectAppInterface(port: number): Promise<null>;
downloadLogs(): Promise<import("../types.js").DownloadLogsResponse>;
/**
* Attach a signal handler.
*
* @param signalHandler - The signal handler to register.
* @param port - The port of the app interface.
*/
on(port: number, signalHandler: SignalCb): void;
/**
* Detach the registered signal handler.
*/
off(port: number): void;
/**
* Send a call to the Admin API.
*
* @param message - The call to send to the Admin API.
* @returns The response of the call.
*
* @internal
*/
private callAdminApi;
/**
* Get all
* {@link https://github.com/holochain/holochain-client-js/blob/develop/docs/API_adminwebsocket.md | Admin API methods}
* of the Holochain client.
*
* @returns The Admin API web socket.
*/
adminWs(): {
addAgentInfo: (request: AddAgentInfoRequest) => Promise<void>;
agentInfo: (req: AgentInfoRequest) => Promise<import("@holochain/client").AgentInfoResponse>;
attachAppInterface: (request?: AttachAppInterfaceRequest) => Promise<{
port: number;
}>;
authorizeSigningCredentials: (cellId: CellId, functions?: GrantedFunctions) => Promise<void>;
deleteCloneCell: (request: DeleteCloneCellRequest) => Promise<void>;
disableApp: (request: DisableAppRequest) => Promise<null>;
dumpFullState: (request: DumpFullStateRequest) => Promise<FullStateDump>;
dumpNetworkStats: (request: DumpNetworkStatsRequest) => Promise<string>;
dumpState: (request: DumpStateRequest) => Promise<[FullStateDump, string]>;
enableApp: (request: EnableAppRequest) => Promise<import("@holochain/client").EnableAppResponse>;
generateAgentPubKey: () => Promise<AgentPubKey>;
getCompatibleCells: (dnaHash: GetCompatibleCellsRequest) => Promise<GetCompatibleCellsResponse>;
getDnaDefinition: (dnaHash: GetDnaDefinitionRequest) => Promise<DnaDefinition>;
grantSigningKey: (cellId: CellId, functions: GrantedFunctions, signingKey: AgentPubKey) => Promise<CapSecret>;
grantZomeCallCapability: (request: GrantZomeCallCapabilityRequest) => Promise<void>;
installApp: (request: InstallAppRequest) => Promise<import("@holochain/client").AppInfo>;
listAppInterfaces: () => Promise<import("@holochain/client").ListAppInterfacesResponse>;
listApps: (request: ListAppsRequest) => Promise<import("@holochain/client").ListAppsResponse>;
listCellIds: () => Promise<import("@holochain/client").ListCellIdsResponse>;
listDnas: () => Promise<import("@holochain/client").ListDnasResponse>;
registerDna: (request: RegisterDnaRequest) => Promise<DnaHash>;
revokeAgentKey: (request: RevokeAgentKeyRequest) => Promise<import("@holochain/client").RevokeAgentKeyResponse>;
startApp: (request: StartAppRequest) => Promise<boolean>;
storageInfo: (request: StorageInfoRequest) => Promise<import("@holochain/client").StorageInfo>;
uninstallApp: (request: UninstallAppRequest) => Promise<null>;
updateCoordinators: (request: UpdateCoordinatorsRequest) => Promise<void>;
issueAppAuthenticationToken: (request: IssueAppAuthenticationTokenRequest) => Promise<import("@holochain/client").IssueAppAuthenticationTokenResponse>;
};
/**
* Call to the conductor's App API.
*/
private callAppApi;
/**
* Get all
* {@link https://github.com/holochain/holochain-client-js/blob/develop/docs/API_appwebsocket.md | App API methods}
* of the Holochain client.
*
* @returns The App API web socket.
*/
connectAppWs(_token: AppAuthenticationToken, port: number): Promise<{
appInfo: () => Promise<import("@holochain/client").AppInfoResponse>;
callZome: <T>(request: CallZomeRequest) => Promise<T>;
enableApp: () => Promise<void>;
createCloneCell: (request: CreateCloneCellRequest) => Promise<import("@holochain/client").ClonedCell>;
enableCloneCell: (request: EnableCloneCellRequest) => Promise<import("@holochain/client").ClonedCell>;
disableCloneCell: (request: DisableCloneCellRequest) => Promise<void>;
networkInfo: (request: NetworkInfoRequest) => Promise<import("@holochain/client").NetworkInfoResponse>;
provideMemproofs: (request: MemproofMap) => Promise<void>;
}>;
/**
* Install a hApp bundle into the conductor.
*
* @param appBundleSource - The bundle or path to the bundle.
* @param options - {@link AppOptions} for the hApp bundle (optional).
* @returns The installed app info.
*/
installApp(appBundleSource: AppBundleSource, options?: AppOptions): Promise<import("@holochain/client").AppInfo>;
/**
* Install a hApp bundle into the conductor.
*
* @param options - Apps to install for each agent, with agent pub keys etc.
* @returns The installed app infos.
*/
installAgentsApps(options: AgentsAppsOptions): Promise<import("@holochain/client").AppInfo[]>;
}