@holochain/client 0.12.4 → 0.13.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 +5 -0
- package/lib/api/admin/types.d.ts +80 -0
- package/lib/api/admin/websocket.d.ts +7 -1
- package/lib/api/admin/websocket.js +6 -0
- package/lib/api/app-agent/websocket.js +1 -6
- package/lib/api/client.js +3 -3
- package/lib/types.d.ts +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,11 @@ A JavaScript client for the Holochain Conductor API (works with browsers as well
|
|
|
12
12
|
|
|
13
13
|
[Complete API reference](./docs/client.md)
|
|
14
14
|
|
|
15
|
+
## Compatibility
|
|
16
|
+
|
|
17
|
+
**JS client v0.12.x** is compatible with **Holochain v0.1.x**.
|
|
18
|
+
**JS client v0.13.x** is compatible with **Holochain v0.2.x**.
|
|
19
|
+
|
|
15
20
|
## Installation
|
|
16
21
|
|
|
17
22
|
To install from NPM, run
|
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -252,6 +252,16 @@ export declare type UninstallAppRequest = {
|
|
|
252
252
|
* @public
|
|
253
253
|
*/
|
|
254
254
|
export declare type UninstallAppResponse = null;
|
|
255
|
+
/**
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
258
|
+
export declare type UpdateCoordinatorsRequest = {
|
|
259
|
+
dna_hash: DnaHash;
|
|
260
|
+
} & CoordinatorSource;
|
|
261
|
+
/**
|
|
262
|
+
* @public
|
|
263
|
+
*/
|
|
264
|
+
export declare type UpdateCoordinatorsResponse = void;
|
|
255
265
|
/**
|
|
256
266
|
* @public
|
|
257
267
|
*/
|
|
@@ -500,13 +510,41 @@ export declare type InstallAppDnaPayload = {
|
|
|
500
510
|
* @public
|
|
501
511
|
*/
|
|
502
512
|
export declare type ZomeLocation = Location;
|
|
513
|
+
/**
|
|
514
|
+
* @public
|
|
515
|
+
*/
|
|
516
|
+
export interface ZomeDependency {
|
|
517
|
+
name: ZomeName;
|
|
518
|
+
}
|
|
503
519
|
/**
|
|
504
520
|
* @public
|
|
505
521
|
*/
|
|
506
522
|
export declare type ZomeManifest = {
|
|
507
523
|
name: string;
|
|
508
524
|
hash?: string;
|
|
525
|
+
dependencies?: ZomeDependency[];
|
|
509
526
|
} & ZomeLocation;
|
|
527
|
+
/**
|
|
528
|
+
* @public
|
|
529
|
+
*/
|
|
530
|
+
export interface CoordinatorManifest {
|
|
531
|
+
zomes: Array<ZomeManifest>;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* @public
|
|
535
|
+
*/
|
|
536
|
+
export interface CoordinatorBundle {
|
|
537
|
+
manifest: CoordinatorManifest;
|
|
538
|
+
resources: ResourceMap;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* @public
|
|
542
|
+
*/
|
|
543
|
+
export declare type CoordinatorSource = {
|
|
544
|
+
path: string;
|
|
545
|
+
} | {
|
|
546
|
+
bundle: CoordinatorBundle;
|
|
547
|
+
};
|
|
510
548
|
/**
|
|
511
549
|
* @public
|
|
512
550
|
*/
|
|
@@ -624,6 +662,46 @@ export interface FullStateDump {
|
|
|
624
662
|
source_chain_dump: SourceChainJsonDump;
|
|
625
663
|
integration_dump: FullIntegrationStateDump;
|
|
626
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* @public
|
|
667
|
+
*/
|
|
668
|
+
export interface DnaStorageInfo {
|
|
669
|
+
authored_data_size: number;
|
|
670
|
+
authored_data_size_on_disk: number;
|
|
671
|
+
dht_data_size: number;
|
|
672
|
+
dht_data_size_on_disk: number;
|
|
673
|
+
cache_data_size: number;
|
|
674
|
+
cache_data_size_on_disk: number;
|
|
675
|
+
used_by: Array<InstalledAppId>;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* @public
|
|
679
|
+
*/
|
|
680
|
+
export interface DnaStorageBlob {
|
|
681
|
+
Dna: DnaStorageInfo;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* @public
|
|
685
|
+
*/
|
|
686
|
+
export interface StorageInfo {
|
|
687
|
+
blobs: Array<DnaStorageBlob>;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* @public
|
|
691
|
+
*/
|
|
692
|
+
export declare type StorageInfoRequest = void;
|
|
693
|
+
/**
|
|
694
|
+
* @public
|
|
695
|
+
*/
|
|
696
|
+
export declare type StorageInfoResponse = StorageInfo;
|
|
697
|
+
/**
|
|
698
|
+
* @public
|
|
699
|
+
*/
|
|
700
|
+
export declare type DumpNetworkStatsRequest = void;
|
|
701
|
+
/**
|
|
702
|
+
* @public
|
|
703
|
+
*/
|
|
704
|
+
export declare type DumpNetworkStatsResponse = string;
|
|
627
705
|
/**
|
|
628
706
|
* @public
|
|
629
707
|
*/
|
|
@@ -646,4 +724,6 @@ export interface AdminApi {
|
|
|
646
724
|
addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
|
|
647
725
|
deleteCloneCell: Requester<DeleteCloneCellRequest, DeleteCloneCellResponse>;
|
|
648
726
|
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
|
|
727
|
+
storageInfo: Requester<StorageInfoRequest, StorageInfoResponse>;
|
|
728
|
+
dumpNetworkStats: Requester<DumpNetworkStatsRequest, DumpNetworkStatsResponse>;
|
|
649
729
|
}
|
|
@@ -2,7 +2,7 @@ import { CapSecret, GrantedFunctions } from "../../hdk/capabilities.js";
|
|
|
2
2
|
import type { AgentPubKey, CellId } from "../../types.js";
|
|
3
3
|
import { WsClient } from "../client.js";
|
|
4
4
|
import { Requester, Transformer } from "../common.js";
|
|
5
|
-
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, UninstallAppRequest, UninstallAppResponse } from "./types.js";
|
|
5
|
+
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkStatsRequest, DumpNetworkStatsResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StorageInfoRequest, StorageInfoResponse, UninstallAppRequest, UninstallAppResponse, UpdateCoordinatorsRequest, UpdateCoordinatorsResponse } from "./types.js";
|
|
6
6
|
/**
|
|
7
7
|
* A class for interacting with a conductor's Admin API.
|
|
8
8
|
*
|
|
@@ -70,6 +70,10 @@ export declare class AdminWebsocket implements AdminApi {
|
|
|
70
70
|
* Install the specified app into Holochain.
|
|
71
71
|
*/
|
|
72
72
|
installApp: Requester<InstallAppRequest, InstallAppResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Update coordinators for an installed app.
|
|
75
|
+
*/
|
|
76
|
+
updateCoordinators: Requester<UpdateCoordinatorsRequest, UpdateCoordinatorsResponse>;
|
|
73
77
|
/**
|
|
74
78
|
* List all registered DNAs.
|
|
75
79
|
*/
|
|
@@ -103,6 +107,8 @@ export declare class AdminWebsocket implements AdminApi {
|
|
|
103
107
|
* calls.
|
|
104
108
|
*/
|
|
105
109
|
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
|
|
110
|
+
storageInfo: Requester<StorageInfoRequest, StorageInfoResponse>;
|
|
111
|
+
dumpNetworkStats: Requester<DumpNetworkStatsRequest, DumpNetworkStatsResponse>;
|
|
106
112
|
/**
|
|
107
113
|
* Grant a capability for signing zome calls.
|
|
108
114
|
*
|
|
@@ -85,6 +85,10 @@ export class AdminWebsocket {
|
|
|
85
85
|
* Install the specified app into Holochain.
|
|
86
86
|
*/
|
|
87
87
|
installApp = this._requester("install_app");
|
|
88
|
+
/**
|
|
89
|
+
* Update coordinators for an installed app.
|
|
90
|
+
*/
|
|
91
|
+
updateCoordinators = this._requester("update_coordinators");
|
|
88
92
|
/**
|
|
89
93
|
* List all registered DNAs.
|
|
90
94
|
*/
|
|
@@ -118,6 +122,8 @@ export class AdminWebsocket {
|
|
|
118
122
|
* calls.
|
|
119
123
|
*/
|
|
120
124
|
grantZomeCallCapability = this._requester("grant_zome_call_capability");
|
|
125
|
+
storageInfo = this._requester("storage_info");
|
|
126
|
+
dumpNetworkStats = this._requester("dump_network_stats");
|
|
121
127
|
// zome call signing related methods
|
|
122
128
|
/**
|
|
123
129
|
* Grant a capability for signing zome calls.
|
|
@@ -92,12 +92,7 @@ export class AppAgentWebsocket {
|
|
|
92
92
|
* @returns The zome call's response.
|
|
93
93
|
*/
|
|
94
94
|
async callZome(request, timeout) {
|
|
95
|
-
if ("provenance" in request) {
|
|
96
|
-
if ("role_name" in request && request.role_name) {
|
|
97
|
-
throw new Error("Cannot find other agent's cells based on role name. Use cell id when providing a provenance.");
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
95
|
+
if (!("provenance" in request)) {
|
|
101
96
|
request = {
|
|
102
97
|
...request,
|
|
103
98
|
provenance: this.myPubKey,
|
package/lib/api/client.js
CHANGED
|
@@ -64,16 +64,16 @@ export class WsClient extends Emittery {
|
|
|
64
64
|
console.error(`Got unrecognized Websocket message type: ${message.type}`);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
socket.
|
|
67
|
+
socket.onclose = (event) => {
|
|
68
68
|
const pendingRequestIds = Object.keys(this.pendingRequests).map((id) => parseInt(id));
|
|
69
69
|
if (pendingRequestIds.length) {
|
|
70
70
|
pendingRequestIds.forEach((id) => {
|
|
71
|
-
const error = new Error(`Websocket closed with pending requests. Close event: ${event}, request id: ${id}`);
|
|
71
|
+
const error = new Error(`Websocket closed with pending requests. Close event code: ${event.code}, request id: ${id}`);
|
|
72
72
|
this.pendingRequests[id].reject(error);
|
|
73
73
|
delete this.pendingRequests[id];
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
};
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Instance factory for creating WsClients.
|
package/lib/types.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ export declare type CellId = [DnaHash, AgentPubKey];
|
|
|
78
78
|
/**
|
|
79
79
|
* @public
|
|
80
80
|
*/
|
|
81
|
-
export declare type DnaProperties =
|
|
81
|
+
export declare type DnaProperties = unknown;
|
|
82
82
|
/**
|
|
83
83
|
* @public
|
|
84
84
|
*/
|
|
@@ -113,6 +113,11 @@ export interface HoloHashed<T> {
|
|
|
113
113
|
*/
|
|
114
114
|
export interface NetworkInfo {
|
|
115
115
|
fetch_pool_info: FetchPoolInfo;
|
|
116
|
+
current_number_of_peers: number;
|
|
117
|
+
arc_size: number;
|
|
118
|
+
total_network_peers: number;
|
|
119
|
+
bytes_since_last_time_queried: number;
|
|
120
|
+
completed_rounds_since_last_time_queried: number;
|
|
116
121
|
}
|
|
117
122
|
/**
|
|
118
123
|
* @public
|
package/package.json
CHANGED