@holochain/client
Version:
A JavaScript client for the Holochain Conductor API
112 lines (111 loc) • 4.68 kB
TypeScript
import { UnsubscribeFunction } from "emittery";
import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js";
import { AppInfo, MemproofMap } from "../admin/index.js";
import { AppCallZomeRequest, AppClient, AppEvents, AppNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest, SignalCb, CallZomeRequest, CallZomeRequestSigned, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse, NetworkInfoResponse, AppWebsocketConnectionOptions } from "./types.js";
import { WsClient } from "../client.js";
/**
* A class to establish a websocket connection to an App interface, for a
* specific agent and app.
*
* @public
*/
export declare class AppWebsocket implements AppClient {
readonly client: WsClient;
readonly myPubKey: AgentPubKey;
readonly installedAppId: InstalledAppId;
private readonly defaultTimeout;
private readonly emitter;
private readonly callZomeTransform;
private readonly appAuthenticationToken;
cachedAppInfo?: AppInfo | null;
private readonly appInfoRequester;
private readonly callZomeRequester;
private readonly provideMemproofRequester;
private readonly enableAppRequester;
private readonly createCloneCellRequester;
private readonly enableCloneCellRequester;
private readonly disableCloneCellRequester;
private readonly networkInfoRequester;
private constructor();
/**
* Instance factory for creating an {@link AppWebsocket}.
*
* @param token - A token to authenticate the websocket connection. Get a token using AdminWebsocket#issueAppAuthenticationToken.
* @param options - {@link (WebsocketConnectionOptions:interface)}
* @returns A new instance of an AppWebsocket.
*/
static connect(options?: AppWebsocketConnectionOptions): Promise<AppWebsocket>;
/**
* Request the app's info, including all cell infos.
*
* @param timeout - A timeout to override the default.
* @returns The app's {@link AppInfo}.
*/
appInfo(timeout?: number): Promise<AppInfo>;
/**
* Provide membrane proofs for the app.
*
* @param memproofs - A map of {@link MembraneProof}s.
*/
provideMemproofs(memproofs: MemproofMap): Promise<void>;
/**
* Enablie an app only if the app is in the `AppStatus::Disabled(DisabledAppReason::NotStartedAfterProvidingMemproofs)`
* state. Attempting to enable the app from other states (other than Running) will fail.
*/
enableApp(): Promise<void>;
/**
* Get a cell id by its role name or clone id.
*
* @param roleName - The role name or clone id of the cell.
* @param appInfo - The app info containing all cell infos.
* @returns The cell id or throws an error if not found.
*/
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo): CellId;
/**
* Call a zome.
*
* @param request - The zome call arguments.
* @param timeout - A timeout to override the default.
* @returns The zome call's response.
*/
callZome(request: AppCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;
/**
* Clone an existing provisioned cell.
*
* @param args - Specify the cell to clone.
* @returns The created clone cell.
*/
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
/**
* Enable a disabled clone cell.
*
* @param args - Specify the clone cell to enable.
* @returns The enabled clone cell.
*/
enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;
/**
* Disable an enabled clone cell.
*
* @param args - Specify the clone cell to disable.
*/
disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
/**
* Request network info about gossip status.
* @param args - Specify the DNAs for which you want network info
* @returns Network info for the specified DNAs
*/
networkInfo(args: AppNetworkInfoRequest): Promise<NetworkInfoResponse>;
/**
* Register an event listener for signals.
*
* @param eventName - Event name to listen to (currently only "signal").
* @param listener - The function to call when event is triggered.
* @returns A function to unsubscribe the event listener.
*/
on<Name extends keyof AppEvents>(eventName: Name | readonly Name[], listener: SignalCb): UnsubscribeFunction;
private static requester;
}
/**
* @public
*/
export declare const signZomeCall: (request: CallZomeRequest) => Promise<CallZomeRequestSigned>;