@holochain/client
Advanced tools
Comparing version 0.10.2 to 0.10.3
@@ -1,13 +0,17 @@ | ||
import Emittery from "emittery"; | ||
import { UnsubscribeFunction } from "emittery"; | ||
import { ArchiveCloneCellResponse, CreateCloneCellRequest, CreateCloneCellResponse } from ".."; | ||
import { CellId, RoleName } from "../.."; | ||
import { CallZomeRequest, AppInfoResponse, ArchiveCloneCellRequest } from "../app"; | ||
export declare type AppAgentCallZomeRequest = Omit<CallZomeRequest, "cell_id"> & { | ||
role_name?: RoleName; | ||
cell_id?: CellId; | ||
import { RoleName } from "../.."; | ||
import { CallZomeRequest, AppInfoResponse, ArchiveCloneCellRequest, AppSignal } from "../app"; | ||
export declare type RoleNameCallZomeRequest = Omit<CallZomeRequest, "cell_id"> & { | ||
role_name: RoleName; | ||
}; | ||
export declare type AppAgentCallZomeRequest = CallZomeRequest | RoleNameCallZomeRequest; | ||
export declare type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">; | ||
export declare type AppArchiveCloneCellRequest = Omit<ArchiveCloneCellRequest, "app_id">; | ||
export interface AppAgentClient extends Emittery { | ||
export interface AppAgentEvents { | ||
signal: AppSignal; | ||
} | ||
export interface AppAgentClient { | ||
callZome(args: AppAgentCallZomeRequest, timeout?: number): Promise<any>; | ||
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction; | ||
appInfo(): Promise<AppInfoResponse>; | ||
@@ -14,0 +18,0 @@ createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>; |
@@ -22,10 +22,11 @@ /** | ||
*/ | ||
import Emittery from "emittery"; | ||
import Emittery, { UnsubscribeFunction } from "emittery"; | ||
import { InstalledAppId } from "../../types.js"; | ||
import { AppInfoResponse, AppWebsocket, ArchiveCloneCellResponse, CallZomeResponse, CreateCloneCellResponse, InstalledAppInfo } from "../index.js"; | ||
import { AppAgentCallZomeRequest, AppAgentClient, AppArchiveCloneCellRequest, AppCreateCloneCellRequest } from "./types.js"; | ||
export declare class AppAgentWebsocket extends Emittery implements AppAgentClient { | ||
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppArchiveCloneCellRequest, AppCreateCloneCellRequest } from "./types.js"; | ||
export declare class AppAgentWebsocket implements AppAgentClient { | ||
appWebsocket: AppWebsocket; | ||
installedAppId: InstalledAppId; | ||
cachedAppInfo?: InstalledAppInfo; | ||
emitter: Emittery<AppAgentEvents, AppAgentEvents & import("emittery").OmnipresentEventData, never>; | ||
constructor(appWebsocket: AppWebsocket, installedAppId: InstalledAppId); | ||
@@ -36,2 +37,3 @@ appInfo(): Promise<AppInfoResponse>; | ||
archiveCloneCell(args: AppArchiveCloneCellRequest): Promise<ArchiveCloneCellResponse>; | ||
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction; | ||
} |
@@ -23,12 +23,12 @@ /** | ||
import Emittery from "emittery"; | ||
import omit from "lodash/omit.js"; | ||
export class AppAgentWebsocket extends Emittery { | ||
import { omit } from "lodash-es"; | ||
export class AppAgentWebsocket { | ||
appWebsocket; | ||
installedAppId; | ||
cachedAppInfo; | ||
emitter = new Emittery(); | ||
constructor(appWebsocket, installedAppId) { | ||
super(); | ||
this.appWebsocket = appWebsocket; | ||
this.installedAppId = installedAppId; | ||
this.appWebsocket.on("signal", (signal) => this.emit("signal", signal)); | ||
this.appWebsocket.on("signal", (signal) => this.emitter.emit("signal", signal)); | ||
} | ||
@@ -43,7 +43,9 @@ async appInfo() { | ||
async callZome(request, timeout) { | ||
if (request.role_name) { | ||
const role_name = request | ||
.role_name; | ||
if (role_name) { | ||
const appInfo = this.cachedAppInfo || (await this.appInfo()); | ||
const cell_id = appInfo.cell_data.find((c) => c.role_name === request.role_name)?.cell_id; | ||
const cell_id = appInfo.cell_data.find((c) => c.role_name === role_name)?.cell_id; | ||
if (!cell_id) { | ||
throw new Error(`No cell found with role_name ${request.role_name}`); | ||
throw new Error(`No cell found with role_name ${role_name}`); | ||
} | ||
@@ -77,3 +79,6 @@ const callZomeRequest = { | ||
} | ||
on(eventName, listener) { | ||
return this.emitter.on(eventName, listener); | ||
} | ||
} | ||
//# sourceMappingURL=websocket.js.map |
{ | ||
"name": "@holochain/client", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"description": "A JavaScript client for the Holochain Conductor API", | ||
@@ -43,3 +43,3 @@ "author": "Holochain Foundation <info@holochain.org> (http://holochain.org)", | ||
"isomorphic-ws": "^5.0.0", | ||
"lodash": "^4.5.0", | ||
"lodash-es": "^4.17.21", | ||
"tweetnacl": "^1.0.3" | ||
@@ -49,3 +49,3 @@ }, | ||
"@types/js-yaml": "^3.12.7", | ||
"@types/lodash": "^4.5.7", | ||
"@types/lodash-es": "^4.17.6", | ||
"@types/tape": "^4.13.2", | ||
@@ -52,0 +52,0 @@ "@types/ws": "^8.5.3", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79960
1505
+ Addedlodash-es@^4.17.21
+ Addedlodash-es@4.17.21(transitive)
- Removedlodash@^4.5.0
- Removedlodash@4.17.21(transitive)