@holochain/client 0.10.1 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/app-agent/types.d.ts +11 -7
- package/lib/api/app-agent/websocket.d.ts +5 -3
- package/lib/api/app-agent/websocket.js +12 -7
- package/lib/api/app-agent/websocket.js.map +1 -1
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/lib/api/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { UnsubscribeFunction } from "emittery";
|
|
2
2
|
import { ArchiveCloneCellResponse, CreateCloneCellRequest, CreateCloneCellResponse } from "..";
|
|
3
|
-
import {
|
|
4
|
-
import { CallZomeRequest, AppInfoResponse, ArchiveCloneCellRequest } from "../app";
|
|
5
|
-
export declare type
|
|
6
|
-
role_name
|
|
7
|
-
cell_id?: CellId;
|
|
3
|
+
import { RoleName } from "../..";
|
|
4
|
+
import { CallZomeRequest, AppInfoResponse, ArchiveCloneCellRequest, AppSignal } from "../app";
|
|
5
|
+
export declare type RoleNameCallZomeRequest = Omit<CallZomeRequest, "cell_id"> & {
|
|
6
|
+
role_name: RoleName;
|
|
8
7
|
};
|
|
8
|
+
export declare type AppAgentCallZomeRequest = CallZomeRequest | RoleNameCallZomeRequest;
|
|
9
9
|
export declare type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
|
|
10
10
|
export declare type AppArchiveCloneCellRequest = Omit<ArchiveCloneCellRequest, "app_id">;
|
|
11
|
-
export interface
|
|
11
|
+
export interface AppAgentEvents {
|
|
12
|
+
signal: AppSignal;
|
|
13
|
+
}
|
|
14
|
+
export interface AppAgentClient {
|
|
12
15
|
callZome(args: AppAgentCallZomeRequest, timeout?: number): Promise<any>;
|
|
16
|
+
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction;
|
|
13
17
|
appInfo(): Promise<AppInfoResponse>;
|
|
14
18
|
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
15
19
|
archiveCloneCell(args: AppArchiveCloneCellRequest): Promise<ArchiveCloneCellResponse>;
|
|
@@ -19,17 +19,19 @@
|
|
|
19
19
|
* console.error('callZome errored with:', err)
|
|
20
20
|
* })
|
|
21
21
|
*/
|
|
22
|
-
import Emittery from "emittery";
|
|
22
|
+
import Emittery, { UnsubscribeFunction } from "emittery";
|
|
23
23
|
import { InstalledAppId } from "../../types.js";
|
|
24
24
|
import { AppInfoResponse, AppWebsocket, ArchiveCloneCellResponse, CallZomeResponse, CreateCloneCellResponse, InstalledAppInfo } from "../index.js";
|
|
25
|
-
import { AppAgentCallZomeRequest, AppAgentClient, AppArchiveCloneCellRequest, AppCreateCloneCellRequest } from "./types.js";
|
|
26
|
-
export declare class AppAgentWebsocket
|
|
25
|
+
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppArchiveCloneCellRequest, AppCreateCloneCellRequest } from "./types.js";
|
|
26
|
+
export declare class AppAgentWebsocket implements AppAgentClient {
|
|
27
27
|
appWebsocket: AppWebsocket;
|
|
28
28
|
installedAppId: InstalledAppId;
|
|
29
29
|
cachedAppInfo?: InstalledAppInfo;
|
|
30
|
+
emitter: Emittery<AppAgentEvents, AppAgentEvents & import("emittery").OmnipresentEventData, never>;
|
|
30
31
|
constructor(appWebsocket: AppWebsocket, installedAppId: InstalledAppId);
|
|
31
32
|
appInfo(): Promise<AppInfoResponse>;
|
|
32
33
|
callZome(request: AppAgentCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;
|
|
33
34
|
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
34
35
|
archiveCloneCell(args: AppArchiveCloneCellRequest): Promise<ArchiveCloneCellResponse>;
|
|
36
|
+
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction;
|
|
35
37
|
}
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
* })
|
|
21
21
|
*/
|
|
22
22
|
import Emittery from "emittery";
|
|
23
|
-
import omit from "lodash
|
|
24
|
-
export class AppAgentWebsocket
|
|
23
|
+
import { omit } from "lodash-es";
|
|
24
|
+
export class AppAgentWebsocket {
|
|
25
25
|
appWebsocket;
|
|
26
26
|
installedAppId;
|
|
27
27
|
cachedAppInfo;
|
|
28
|
+
emitter = new Emittery();
|
|
28
29
|
constructor(appWebsocket, installedAppId) {
|
|
29
|
-
super();
|
|
30
30
|
this.appWebsocket = appWebsocket;
|
|
31
31
|
this.installedAppId = installedAppId;
|
|
32
|
-
this.appWebsocket.on("signal", (signal) => this.emit("signal", signal));
|
|
32
|
+
this.appWebsocket.on("signal", (signal) => this.emitter.emit("signal", signal));
|
|
33
33
|
}
|
|
34
34
|
async appInfo() {
|
|
35
35
|
const appInfo = await this.appWebsocket.appInfo({
|
|
@@ -39,11 +39,13 @@ export class AppAgentWebsocket extends Emittery {
|
|
|
39
39
|
return appInfo;
|
|
40
40
|
}
|
|
41
41
|
async callZome(request, timeout) {
|
|
42
|
-
|
|
42
|
+
const role_name = request
|
|
43
|
+
.role_name;
|
|
44
|
+
if (role_name) {
|
|
43
45
|
const appInfo = this.cachedAppInfo || (await this.appInfo());
|
|
44
|
-
const cell_id = appInfo.cell_data.find((c) => c.role_name ===
|
|
46
|
+
const cell_id = appInfo.cell_data.find((c) => c.role_name === role_name)?.cell_id;
|
|
45
47
|
if (!cell_id) {
|
|
46
|
-
throw new Error(`No cell found with role_name ${
|
|
48
|
+
throw new Error(`No cell found with role_name ${role_name}`);
|
|
47
49
|
}
|
|
48
50
|
const callZomeRequest = {
|
|
49
51
|
...omit(request, "role_name"),
|
|
@@ -72,5 +74,8 @@ export class AppAgentWebsocket extends Emittery {
|
|
|
72
74
|
...args,
|
|
73
75
|
});
|
|
74
76
|
}
|
|
77
|
+
on(eventName, listener) {
|
|
78
|
+
return this.emitter.on(eventName, listener);
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
//# sourceMappingURL=websocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app-agent/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app-agent/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,QAAiC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAqBjC,MAAM,OAAO,iBAAiB;IAC5B,YAAY,CAAe;IAC3B,cAAc,CAAiB;IAC/B,aAAa,CAAoB;IAEjC,OAAO,GAAG,IAAI,QAAQ,EAAkB,CAAC;IAEzC,YAAY,YAA0B,EAAE,cAA8B;QACpE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CACpC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;YAC9C,gBAAgB,EAAE,IAAI,CAAC,cAAc;SACtC,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,OAAgC,EAChC,OAAgB;QAEhB,MAAM,SAAS,GAAwB,OAAmC;aACvE,SAAS,CAAC;QACb,IAAI,SAA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CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
package/lib/api/index.d.ts
CHANGED
package/lib/api/index.js
CHANGED
package/lib/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/client",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "A JavaScript client for the Holochain Conductor API",
|
|
5
5
|
"author": "Holochain Foundation <info@holochain.org> (http://holochain.org)",
|
|
6
6
|
"license": "CAL-1.0",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"cross-fetch": "^3.1.5",
|
|
41
41
|
"emittery": "^1.0.1",
|
|
42
42
|
"isomorphic-ws": "^5.0.0",
|
|
43
|
-
"lodash": "^4.
|
|
43
|
+
"lodash-es": "^4.17.21",
|
|
44
44
|
"tweetnacl": "^1.0.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/js-yaml": "^3.12.7",
|
|
48
|
-
"@types/lodash": "^4.
|
|
48
|
+
"@types/lodash-es": "^4.17.6",
|
|
49
49
|
"@types/tape": "^4.13.2",
|
|
50
50
|
"@types/ws": "^8.5.3",
|
|
51
51
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|