UNPKG

@holochain/tryorama

Version:

Toolset to manage Holochain conductors and facilitate running test scenarios

79 lines (78 loc) 2.71 kB
/// <reference types="node" /> /// <reference types="node" /> /// <reference types="node" /> import { SignalCb } from "@holochain/client"; import { URL } from "node:url"; import { TryCpConductor, TryCpConductorOptions } from "./conductor/conductor.js"; import { TryCpRequest, TryCpSuccessResponse } from "./types.js"; /** * A factory class to create client connections to a running TryCP server. * * With a client, conductors on the server can ba configured, started and * stopped. All valid Admin and App API commands can be sent to the server too. * * @public */ export declare class TryCpClient { private readonly ws; private requestPromises; private signalHandlers; bootstrapServerUrl: URL | undefined; signalingServerUrl: URL | undefined; conductors: TryCpConductor[]; private constructor(); /** * Create a client connection to a running TryCP server. * * @param serverUrl - The URL of the TryCP server. * @returns The created client connection. */ static create(serverUrl: URL, timeout?: number): Promise<TryCpClient>; setSignalHandler(port: number, signalHandler?: SignalCb): void; unsetSignalHandler(port: number): void; /** * Closes the client connection. * * @returns A promise that resolves when the connection was closed. */ close(): Promise<unknown>; /** * Send a ping with data. * * @param data - Data to send and receive with the ping-pong. * @returns A promise that resolves when the pong was received. */ ping(data: unknown): Promise<Buffer>; /** * Send a call to the TryCP server. * * @param request - {@link TryCpRequest} * @returns A promise that resolves to the {@link TryCpSuccessResponse} */ call(request: TryCpRequest): Promise<TryCpSuccessResponse>; /** * Create and add a conductor to the client. * * @param options - Conductor configuration, log level and other settings (optional). * @returns The newly added conductor instance. */ addConductor(options?: TryCpConductorOptions): Promise<TryCpConductor>; /** * Shut down all conductors on the connected TryCP server and disconnect * their app interfaces. */ shutDownConductors(): Promise<void>; /** * Run the `reset` command on the TryCP server to delete all conductor data. * * @returns An empty success response. */ cleanAllConductors(): Promise<null>; /** * Shut down all registered conductors and delete them, and close the client * connection. */ cleanUp(): Promise<void>; private processSuccessResponse; private getFormattedResponseLog; }