@holochain/client 0.19.0-rc.1 → 0.20.0-dev.0
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/README.md +16 -12
- package/lib/api/admin/types.d.ts +10 -15
- package/lib/api/app/types.d.ts +3 -0
- package/lib/api/app/types.js +3 -0
- package/lib/api/app/websocket.d.ts +9 -1
- package/lib/api/app/websocket.js +12 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,12 +15,12 @@ A JavaScript client for the Holochain Conductor API (works with browsers as well
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
+
**JS client v0.20.x** is compatible with **Holochain v0.6.x**.
|
|
19
|
+
|
|
18
20
|
**JS client v0.19.x** is compatible with **Holochain v0.5.x**.
|
|
19
21
|
|
|
20
22
|
**JS client v0.18.x** is compatible with **Holochain v0.4.x**.
|
|
21
23
|
|
|
22
|
-
**JS client v0.17.x** is compatible with **Holochain v0.3.x**.
|
|
23
|
-
|
|
24
24
|
To install from NPM, run
|
|
25
25
|
```bash
|
|
26
26
|
npm install --save-exact @holochain/client
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
CellType,
|
|
39
39
|
type ActionHash,
|
|
40
40
|
type CallZomeRequest,
|
|
41
|
-
} from "
|
|
41
|
+
} from "./lib/index.js";
|
|
42
42
|
|
|
43
43
|
const adminWs = await AdminWebsocket.connect({
|
|
44
44
|
url: new URL("ws://127.0.0.1:65000"),
|
|
@@ -48,16 +48,18 @@ const agent_key = await adminWs.generateAgentPubKey();
|
|
|
48
48
|
const role_name = "foo";
|
|
49
49
|
const installed_app_id = "test-app";
|
|
50
50
|
const appInfo = await adminWs.installApp({
|
|
51
|
+
source: {
|
|
52
|
+
type: "path",
|
|
53
|
+
value: "./test/e2e/fixture/test.happ",
|
|
54
|
+
},
|
|
51
55
|
agent_key,
|
|
52
|
-
path: "./test/e2e/fixture/test.happ",
|
|
53
56
|
installed_app_id,
|
|
54
|
-
membrane_proofs: {},
|
|
55
57
|
});
|
|
56
58
|
await adminWs.enableApp({ installed_app_id });
|
|
57
|
-
if (
|
|
59
|
+
if (appInfo.cell_info[role_name][0].type !== CellType.Provisioned) {
|
|
58
60
|
throw new Error(`No cell found under role name ${role_name}`);
|
|
59
61
|
}
|
|
60
|
-
const { cell_id } = appInfo.cell_info[role_name][0]
|
|
62
|
+
const { cell_id } = appInfo.cell_info[role_name][0].value;
|
|
61
63
|
await adminWs.authorizeSigningCredentials(cell_id);
|
|
62
64
|
await adminWs.attachAppInterface({ port: 65001, allowed_origins: "my-happ" });
|
|
63
65
|
const issuedToken = await adminWs.issueAppAuthenticationToken({
|
|
@@ -86,7 +88,7 @@ await adminWs.client.close();
|
|
|
86
88
|
|
|
87
89
|
### Subscribe to signals
|
|
88
90
|
```typescript
|
|
89
|
-
import { AdminWebsocket, AppWebsocket, CellType } from "
|
|
91
|
+
import { AdminWebsocket, AppWebsocket, CellType } from "./lib/index.js";
|
|
90
92
|
|
|
91
93
|
const adminWs = await AdminWebsocket.connect({
|
|
92
94
|
url: new URL("ws://127.0.0.1:65000"),
|
|
@@ -96,16 +98,18 @@ const agent_key = await adminWs.generateAgentPubKey();
|
|
|
96
98
|
const role_name = "foo";
|
|
97
99
|
const installed_app_id = "test-app";
|
|
98
100
|
const appInfo = await adminWs.installApp({
|
|
101
|
+
source: {
|
|
102
|
+
type: "path",
|
|
103
|
+
value: "./test/e2e/fixture/test.happ",
|
|
104
|
+
},
|
|
99
105
|
agent_key,
|
|
100
|
-
path: "./test/e2e/fixture/test.happ",
|
|
101
106
|
installed_app_id,
|
|
102
|
-
membrane_proofs: {},
|
|
103
107
|
});
|
|
104
108
|
await adminWs.enableApp({ installed_app_id });
|
|
105
|
-
if (
|
|
109
|
+
if (appInfo.cell_info[role_name][0].type !== CellType.Provisioned) {
|
|
106
110
|
throw new Error(`No cell found under role name ${role_name}`);
|
|
107
111
|
}
|
|
108
|
-
const { cell_id } = appInfo.cell_info[role_name][0]
|
|
112
|
+
const { cell_id } = appInfo.cell_info[role_name][0].value;
|
|
109
113
|
await adminWs.authorizeSigningCredentials(cell_id);
|
|
110
114
|
await adminWs.attachAppInterface({ port: 65001, allowed_origins: "my-happ" });
|
|
111
115
|
const issuedToken = await adminWs.issueAppAuthenticationToken({
|
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -557,7 +557,7 @@ export type AgentInfoSigned = unknown;
|
|
|
557
557
|
* @public
|
|
558
558
|
*/
|
|
559
559
|
export type AgentInfoRequest = {
|
|
560
|
-
|
|
560
|
+
dna_hashes: DnaHash[] | null;
|
|
561
561
|
};
|
|
562
562
|
/**
|
|
563
563
|
* @public
|
|
@@ -936,20 +936,15 @@ export interface DumpNetworkMetricsRequest {
|
|
|
936
936
|
*
|
|
937
937
|
* @public
|
|
938
938
|
*/
|
|
939
|
-
export type DhtArc =
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
* The lower and upper bounds are inclusive.
|
|
949
|
-
*/
|
|
950
|
-
type: "arc";
|
|
951
|
-
value: [number, number];
|
|
952
|
-
};
|
|
939
|
+
export type DhtArc = /**
|
|
940
|
+
* No DHT locations are contained within this arc.
|
|
941
|
+
*/ null
|
|
942
|
+
/**
|
|
943
|
+
* A specific range of DHT locations are contained within this arc.
|
|
944
|
+
*
|
|
945
|
+
* The lower and upper bounds are inclusive.
|
|
946
|
+
*/
|
|
947
|
+
| [number, number];
|
|
953
948
|
/**
|
|
954
949
|
* Summary of a local agent's network state.
|
|
955
950
|
*
|
package/lib/api/app/types.d.ts
CHANGED
|
@@ -345,6 +345,9 @@ export declare enum SessionCompletionDecisionType {
|
|
|
345
345
|
export type SessionCompletionDecision = {
|
|
346
346
|
[SessionCompletionDecisionType.Complete]: SignedActionHashed;
|
|
347
347
|
} | SessionCompletionDecisionType.Abandoned | SessionCompletionDecisionType.Indeterminate | SessionCompletionDecisionType.Failed;
|
|
348
|
+
/**
|
|
349
|
+
* @public
|
|
350
|
+
*/
|
|
348
351
|
export declare enum SignalType {
|
|
349
352
|
App = "app",
|
|
350
353
|
System = "system"
|
package/lib/api/app/types.js
CHANGED
|
@@ -45,6 +45,9 @@ export var SessionCompletionDecisionType;
|
|
|
45
45
|
*/
|
|
46
46
|
SessionCompletionDecisionType["Failed"] = "Failed";
|
|
47
47
|
})(SessionCompletionDecisionType || (SessionCompletionDecisionType = {}));
|
|
48
|
+
/**
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
48
51
|
export var SignalType;
|
|
49
52
|
(function (SignalType) {
|
|
50
53
|
SignalType["App"] = "app";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnsubscribeFunction } from "emittery";
|
|
2
2
|
import { AgentPubKey, InstalledAppId, RoleName } from "../../types.js";
|
|
3
|
-
import { AppInfo, ClonedCell, DumpNetworkMetricsRequest, DumpNetworkMetricsResponse, DumpNetworkStatsResponse, MemproofMap } from "../admin/index.js";
|
|
3
|
+
import { AgentInfoRequest, AgentInfoResponse, AppInfo, ClonedCell, DumpNetworkMetricsRequest, DumpNetworkMetricsResponse, DumpNetworkStatsResponse, MemproofMap } from "../admin/index.js";
|
|
4
4
|
import { WsClient } from "../client.js";
|
|
5
5
|
import { AbandonCountersigningSessionStateRequest, AppClient, AppEvents, AppWebsocketConnectionOptions, CallZomeRequest, CallZomeRequestSigned, CreateCloneCellRequest, DisableCloneCellRequest, EnableCloneCellRequest, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, PublishCountersigningSessionStateRequest, RoleNameCallZomeRequest, SignalCb } from "./types.js";
|
|
6
6
|
/**
|
|
@@ -18,6 +18,7 @@ export declare class AppWebsocket implements AppClient {
|
|
|
18
18
|
private readonly callZomeTransform;
|
|
19
19
|
cachedAppInfo?: AppInfo | null;
|
|
20
20
|
private readonly appInfoRequester;
|
|
21
|
+
private readonly agentInfoRequester;
|
|
21
22
|
private readonly callZomeRequester;
|
|
22
23
|
private readonly provideMemproofRequester;
|
|
23
24
|
private readonly enableAppRequester;
|
|
@@ -45,6 +46,13 @@ export declare class AppWebsocket implements AppClient {
|
|
|
45
46
|
* @returns The app's {@link AppInfo}.
|
|
46
47
|
*/
|
|
47
48
|
appInfo(timeout?: number): Promise<AppInfo>;
|
|
49
|
+
/**
|
|
50
|
+
* Request the currently known agents of the app.
|
|
51
|
+
*
|
|
52
|
+
* @param req - An array of DNA hashes or null
|
|
53
|
+
* @returns The app's agent infos as JSON string.
|
|
54
|
+
*/
|
|
55
|
+
agentInfo(req: AgentInfoRequest, timeout?: number): Promise<AgentInfoResponse>;
|
|
48
56
|
/**
|
|
49
57
|
* Request network stats.
|
|
50
58
|
*
|
package/lib/api/app/websocket.js
CHANGED
|
@@ -24,6 +24,7 @@ export class AppWebsocket {
|
|
|
24
24
|
callZomeTransform;
|
|
25
25
|
cachedAppInfo;
|
|
26
26
|
appInfoRequester;
|
|
27
|
+
agentInfoRequester;
|
|
27
28
|
callZomeRequester;
|
|
28
29
|
provideMemproofRequester;
|
|
29
30
|
enableAppRequester;
|
|
@@ -44,6 +45,7 @@ export class AppWebsocket {
|
|
|
44
45
|
this.emitter = new Emittery();
|
|
45
46
|
this.cachedAppInfo = appInfo;
|
|
46
47
|
this.appInfoRequester = AppWebsocket.requester(this.client, "app_info", this.defaultTimeout);
|
|
48
|
+
this.agentInfoRequester = AppWebsocket.requester(this.client, "agent_info", this.defaultTimeout);
|
|
47
49
|
this.callZomeRequester = AppWebsocket.requester(this.client, "call_zome", this.defaultTimeout, this.callZomeTransform);
|
|
48
50
|
this.provideMemproofRequester = AppWebsocket.requester(this.client, "provide_memproofs", this.defaultTimeout);
|
|
49
51
|
this.enableAppRequester = AppWebsocket.requester(this.client, "enable_app", this.defaultTimeout);
|
|
@@ -109,6 +111,16 @@ export class AppWebsocket {
|
|
|
109
111
|
this.cachedAppInfo = appInfo;
|
|
110
112
|
return appInfo;
|
|
111
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Request the currently known agents of the app.
|
|
116
|
+
*
|
|
117
|
+
* @param req - An array of DNA hashes or null
|
|
118
|
+
* @returns The app's agent infos as JSON string.
|
|
119
|
+
*/
|
|
120
|
+
async agentInfo(req, timeout) {
|
|
121
|
+
const agentInfos = await this.agentInfoRequester(req, timeout);
|
|
122
|
+
return agentInfos;
|
|
123
|
+
}
|
|
112
124
|
/**
|
|
113
125
|
* Request network stats.
|
|
114
126
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0-dev.0",
|
|
4
4
|
"description": "A JavaScript client for the Holochain Conductor API",
|
|
5
5
|
"author": "Holochain Foundation <info@holochain.org> (https://holochain.org)",
|
|
6
6
|
"license": "CAL-1.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/holochain/holochain-client-js#readme",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=18.0.0 || >=20.0.0"
|
|
21
|
+
"node": ">=18.0.0 || >=20.0.0 || >= 22.0.0"
|
|
22
22
|
},
|
|
23
23
|
"main": "lib/index.js",
|
|
24
24
|
"module": "lib/index.js",
|