@holochain/client 0.19.0-dev.8 → 0.19.0-rc.1

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.
@@ -1,5 +1,5 @@
1
1
  import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js";
2
- import { ActionHash, AgentPubKey, CellId, DnaHash, DnaHashB64, DnaProperties, Duration, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
2
+ import { ActionHash, AgentPubKey, CellId, DnaHash, DnaHashB64, DnaProperties, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
3
3
  import { CloneCellId } from "../app/types.js";
4
4
  import { Requester } from "../common.js";
5
5
  /**
@@ -36,38 +36,44 @@ export type EnableAppResponse = {
36
36
  app: AppInfo;
37
37
  errors: Array<[CellId, string]>;
38
38
  };
39
- /**
40
- * @public
41
- */
42
- export type DeactivationReason = "never_activated" | "normal" | {
43
- quarantined: {
44
- error: string;
45
- };
46
- };
47
39
  /**
48
40
  * @public
49
41
  */
50
42
  export type PausedAppReason = {
51
- error: string;
43
+ type: "error";
44
+ value: string;
52
45
  };
53
46
  /**
54
47
  * @public
55
48
  */
56
- export type DisabledAppReason = "never_started" | "user" | "not_started_after_providing_memproofs" | {
57
- error: string;
49
+ export type DisabledAppReason = {
50
+ type: "never_started";
51
+ } | {
52
+ type: "user";
53
+ } | {
54
+ type: "not_started_after_providing_memproofs";
55
+ } | {
56
+ type: "error";
57
+ value: string;
58
58
  };
59
59
  /**
60
60
  * @public
61
61
  */
62
- export type InstalledAppInfoStatus = {
63
- paused: {
62
+ export type AppInfoStatus = {
63
+ type: "paused";
64
+ value: {
64
65
  reason: PausedAppReason;
65
66
  };
66
67
  } | {
67
- disabled: {
68
+ type: "disabled";
69
+ value: {
68
70
  reason: DisabledAppReason;
69
71
  };
70
- } | "awaiting_memproofs" | "running";
72
+ } | {
73
+ type: "awaiting_memproofs";
74
+ } | {
75
+ type: "running";
76
+ };
71
77
  /**
72
78
  * @public
73
79
  */
@@ -123,7 +129,7 @@ export type AppInfo = {
123
129
  agent_pub_key: AgentPubKey;
124
130
  installed_app_id: InstalledAppId;
125
131
  cell_info: Record<RoleName, Array<CellInfo>>;
126
- status: InstalledAppInfoStatus;
132
+ status: AppInfoStatus;
127
133
  installed_at: Timestamp;
128
134
  };
129
135
  /**
@@ -168,8 +174,6 @@ export type YamlProperties = unknown;
168
174
  export type DnaModifiersOpt = {
169
175
  network_seed?: NetworkSeed;
170
176
  properties?: YamlProperties;
171
- origin_time?: Timestamp;
172
- quantum_time?: Duration;
173
177
  };
174
178
  /**
175
179
  * @public
@@ -256,8 +260,6 @@ export type RegisterDnaResponse = HoloHash;
256
260
  export type DnaModifiers = {
257
261
  network_seed: NetworkSeed;
258
262
  properties: Uint8Array;
259
- origin_time: Timestamp;
260
- quantum_time: Duration;
261
263
  };
262
264
  /**
263
265
  * @public
@@ -303,14 +305,6 @@ export type GetDnaDefinitionRequest = DnaHash;
303
305
  * @public
304
306
  */
305
307
  export type GetDnaDefinitionResponse = DnaDefinition;
306
- /**
307
- * @public
308
- */
309
- export type GetCompatibleCellsRequest = DnaHashB64;
310
- /**
311
- * @public
312
- */
313
- export type GetCompatibleCellsResponse = Set<[InstalledAppId, Set<CellId>]>;
314
308
  /**
315
309
  * @public
316
310
  */
@@ -568,12 +562,12 @@ export type AgentInfoRequest = {
568
562
  /**
569
563
  * @public
570
564
  */
571
- export type AgentInfoResponse = Array<AgentInfoSigned>;
565
+ export type AgentInfoResponse = Array<string>;
572
566
  /**
573
567
  * @public
574
568
  */
575
569
  export type AddAgentInfoRequest = {
576
- agent_infos: Array<AgentInfoSigned>;
570
+ agent_infos: Array<string>;
577
571
  };
578
572
  /**
579
573
  * @public
@@ -859,10 +853,272 @@ export interface IssueAppAuthenticationTokenResponse {
859
853
  * @public
860
854
  */
861
855
  export type DumpNetworkStatsRequest = void;
856
+ /**
857
+ * Stats for a transport connection.
858
+ *
859
+ * This is intended to be a state dump that gives some insight into what the transport is doing.
860
+ *
861
+ * @public
862
+ */
863
+ export interface TransportStats {
864
+ /**
865
+ * The networking backend that is in use.
866
+ */
867
+ backend: string;
868
+ /**
869
+ * The list of peer urls that this Kitsune2 instance can currently be reached at.
870
+ */
871
+ peer_urls: string[];
872
+ /**
873
+ * The list of current connections.
874
+ *
875
+ * @public
876
+ */
877
+ connections: TransportConnectionStats[];
878
+ }
879
+ /**
880
+ * Stats for a single transport connection.
881
+ *
882
+ * @public
883
+ */
884
+ export interface TransportConnectionStats {
885
+ /**
886
+ * The public key of the remote peer.
887
+ */
888
+ pub_key: string;
889
+ /**
890
+ * The message count sent on this connection.
891
+ */
892
+ send_message_count: number;
893
+ /**
894
+ * The bytes sent on this connection.
895
+ */
896
+ send_bytes: number;
897
+ /**
898
+ * The message count received on this connection.
899
+ */
900
+ recv_message_count: number;
901
+ /**
902
+ * The bytes received on this connection
903
+ */
904
+ recv_bytes: number;
905
+ /**
906
+ * UNIX epoch timestamp in seconds when this connection was opened.
907
+ */
908
+ opened_at_s: number;
909
+ /**
910
+ * True if this connection has successfully upgraded to webrtc.
911
+ */
912
+ is_webrtc: boolean;
913
+ }
914
+ /**
915
+ * @public
916
+ */
917
+ export type DumpNetworkStatsResponse = TransportStats;
918
+ /**
919
+ * Arguments for dumping network metrics.
920
+ *
921
+ * @public
922
+ */
923
+ export interface DumpNetworkMetricsRequest {
924
+ /**
925
+ * The DNA hash of the app network to dump.
926
+ */
927
+ dna?: DnaHash;
928
+ /**
929
+ * Include DHT summary in the response.
930
+ */
931
+ include_dht_summary: boolean;
932
+ }
933
+ /**
934
+ * The definition of a storage arc compatible with the concept of
935
+ * storage and querying of items in a store that fall within that arc.
936
+ *
937
+ * @public
938
+ */
939
+ export type DhtArc = {
940
+ /**
941
+ * No DHT locations are contained within this arc.
942
+ */
943
+ type: "empty";
944
+ } | {
945
+ /**
946
+ * A specific range of DHT locations are contained within this arc.
947
+ *
948
+ * The lower and upper bounds are inclusive.
949
+ */
950
+ type: "arc";
951
+ value: [number, number];
952
+ };
953
+ /**
954
+ * Summary of a local agent's network state.
955
+ *
956
+ * @public
957
+ */
958
+ export interface LocalAgentSummary {
959
+ /**
960
+ * The agent's public key.
961
+ */
962
+ agent: AgentPubKey;
963
+ /**
964
+ * The current storage arc that the agent is declaring.
965
+ *
966
+ * This is the arc that the agent is claiming that it is an authority for.
967
+ */
968
+ storage_arc: DhtArc;
969
+ /**
970
+ * The target arc that the agent is trying to achieve as a storage arc.
971
+ *
972
+ * This is not declared to other peers on the network. It is used during gossip to try to sync
973
+ * ops in the target arc. Once the DHT state appears to be in sync with the target arc, the
974
+ * storage arc can be updated towards the target arc.
975
+ */
976
+ target_arc: DhtArc;
977
+ }
978
+ /**
979
+ * Summary of the fetch state.
980
+ *
981
+ * @public
982
+ */
983
+ export interface FetchStateSummary {
984
+ /**
985
+ * The op ids that are currently being fetched.
986
+ *
987
+ * Each op id is associated with one or more peer URL from which the op data could be
988
+ * requested.
989
+ */
990
+ pending_requests: Record<HoloHashB64, string[]>;
991
+ /**
992
+ * The peer URL for nodes that are currently on backoff because of failed fetch requests, and the timestamp when that backoff will expire.
993
+ *
994
+ * If peers are in here then they are not being used as potential sources in
995
+ * [`FetchStateSummary::pending_requests`].
996
+ */
997
+ peers_on_backoff: Map<string, number>;
998
+ }
999
+ /**
1000
+ * DHT segment state.
1001
+ *
1002
+ * @public
1003
+ */
1004
+ export interface DhtSegmentState {
1005
+ /**
1006
+ * The top hash of the DHT ring segment.
1007
+ */
1008
+ disc_top_hash: Uint8Array;
1009
+ /**
1010
+ * The boundary timestamp of the DHT ring segment.
1011
+ */
1012
+ disc_boundary: Timestamp;
1013
+ /**
1014
+ * The top hashes of each DHT ring segment.
1015
+ */
1016
+ ring_top_hashes: Uint8Array[];
1017
+ }
1018
+ /**
1019
+ * Peer metadata dump.
1020
+ *
1021
+ * @public
1022
+ */
1023
+ export interface PeerMeta {
1024
+ /**
1025
+ * The timestamp of the last gossip round.
1026
+ */
1027
+ last_gossip_timestamp?: Timestamp;
1028
+ /**
1029
+ * The bookmark of the last op bookmark received.
1030
+ */
1031
+ new_ops_bookmark?: Timestamp;
1032
+ /**
1033
+ * The number of behavior errors observed.
1034
+ */
1035
+ peer_behavior_errors?: number;
1036
+ /**
1037
+ * The number of local errors.
1038
+ */
1039
+ local_errors?: number;
1040
+ /**
1041
+ * The number of busy peer errors.
1042
+ */
1043
+ peer_busy?: number;
1044
+ /**
1045
+ * The number of terminated rounds.
1046
+ *
1047
+ * Note that termination is not necessarily an error.
1048
+ */
1049
+ peer_terminated?: number;
1050
+ /**
1051
+ * The number of completed rounds.
1052
+ */
1053
+ completed_rounds?: number;
1054
+ /**
1055
+ * The number of peer timeouts.
1056
+ */
1057
+ peer_timeouts?: number;
1058
+ }
1059
+ /**
1060
+ * Gossip round state summary.
1061
+ *
1062
+ * @public
1063
+ */
1064
+ export interface GossipRoundStateSummary {
1065
+ /**
1066
+ * The URL of the peer with which the round is initiated.
1067
+ */
1068
+ session_with_peer: string;
1069
+ }
1070
+ /**
1071
+ * Gossip state summary.
1072
+ *
1073
+ * @public
1074
+ */
1075
+ export interface GossipStateSummary {
1076
+ /**
1077
+ * The current initiated round summary.
1078
+ */
1079
+ initiated_round?: GossipRoundStateSummary;
1080
+ /**
1081
+ * The list of accepted round summaries.
1082
+ */
1083
+ accepted_rounds: GossipRoundStateSummary[];
1084
+ /**
1085
+ * DHT summary.
1086
+ */
1087
+ dht_summary: Record<string, DhtSegmentState>;
1088
+ /**
1089
+ * Peer metadata dump for each agent in this space.
1090
+ */
1091
+ peer_meta: Record<string, PeerMeta>;
1092
+ }
1093
+ /**
1094
+ * Network metrics from Kitsune2.
1095
+ *
1096
+ * @public
1097
+ */
1098
+ export interface NetworkMetrics {
1099
+ /**
1100
+ * A summary of the fetch queue.
1101
+ *
1102
+ * The fetch queue is used to retrieve op data based on op ids that have been discovered
1103
+ * through publish or gossip.
1104
+ */
1105
+ fetch_state_summary: FetchStateSummary;
1106
+ /**
1107
+ * A summary of the gossip state.
1108
+ *
1109
+ * This includes both live gossip rounds and metrics about peers that we've gossiped with.
1110
+ * Optionally, it can include a summary of the DHT state as Kitsune2 sees it.
1111
+ */
1112
+ gossip_state_summary: GossipStateSummary;
1113
+ /**
1114
+ * A summary of the state of each local agent.
1115
+ */
1116
+ local_agents: LocalAgentSummary[];
1117
+ }
862
1118
  /**
863
1119
  * @public
864
1120
  */
865
- export type DumpNetworkStatsResponse = string;
1121
+ export type DumpNetworkMetricsResponse = Record<DnaHashB64, NetworkMetrics>;
866
1122
  /**
867
1123
  * @public
868
1124
  */
@@ -2,7 +2,7 @@ import { CapSecret, GrantedFunctions } from "../../hdk/index.js";
2
2
  import type { AgentPubKey, CellId } from "../../types.js";
3
3
  import { WsClient } from "../client.js";
4
4
  import { Requester, Transformer, WebsocketConnectionOptions } from "../common.js";
5
- import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkStatsRequest, DumpNetworkStatsResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetCompatibleCellsRequest, GetCompatibleCellsResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, RevokeAgentKeyRequest, RevokeAgentKeyResponse, StorageInfoRequest, StorageInfoResponse, UninstallAppRequest, UninstallAppResponse, UpdateCoordinatorsRequest, UpdateCoordinatorsResponse } from "./types.js";
5
+ import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkMetricsRequest, DumpNetworkMetricsResponse, DumpNetworkStatsRequest, DumpNetworkStatsResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, RevokeAgentKeyRequest, RevokeAgentKeyResponse, 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
  *
@@ -65,7 +65,6 @@ export declare class AdminWebsocket implements AdminApi {
65
65
  * Get the DNA definition for the specified DNA hash.
66
66
  */
67
67
  getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
68
- getCompatibleCells: Requester<GetCompatibleCellsRequest, GetCompatibleCellsResponse>;
69
68
  /**
70
69
  * Uninstall the specified app from Holochain.
71
70
  */
@@ -114,6 +113,7 @@ export declare class AdminWebsocket implements AdminApi {
114
113
  storageInfo: Requester<StorageInfoRequest, StorageInfoResponse>;
115
114
  issueAppAuthenticationToken: Requester<IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse>;
116
115
  dumpNetworkStats: Requester<DumpNetworkStatsRequest, DumpNetworkStatsResponse>;
116
+ dumpNetworkMetrics: Requester<DumpNetworkMetricsRequest, DumpNetworkMetricsResponse>;
117
117
  /**
118
118
  * Grant a capability for signing zome calls.
119
119
  *
@@ -81,9 +81,6 @@ export class AdminWebsocket {
81
81
  * Get the DNA definition for the specified DNA hash.
82
82
  */
83
83
  getDnaDefinition = this._requester("get_dna_definition");
84
- /// Find installed cells which use a DNA that's forward-compatible with the given DNA hash.
85
- /// Namely, this finds cells with DNAs whose manifest lists the given DNA hash in its `lineage` field.
86
- getCompatibleCells = this._requester("get_compatible_cells");
87
84
  /**
88
85
  * Uninstall the specified app from Holochain.
89
86
  */
@@ -132,6 +129,7 @@ export class AdminWebsocket {
132
129
  storageInfo = this._requester("storage_info");
133
130
  issueAppAuthenticationToken = this._requester("issue_app_authentication_token");
134
131
  dumpNetworkStats = this._requester("dump_network_stats");
132
+ dumpNetworkMetrics = this._requester("dump_network_metrics");
135
133
  // zome call signing related methods
136
134
  /**
137
135
  * Grant a capability for signing zome calls.
@@ -1,9 +1,5 @@
1
1
  import { UnsubscribeFunction } from "emittery";
2
- import { AgentPubKey, AppAuthenticationToken, AppInfo, CapSecret, CellId, ClonedCell, DnaHash, DnaProperties, EntryHash, FunctionName, InstalledAppId, MembraneProof, MemproofMap, NetworkInfo, NetworkSeed, Nonce256Bit, RoleName, Timestamp, Transformer, WebsocketConnectionOptions, ZomeName, PreflightRequest, SignedAction, SignedActionHashed } from "../../index.js";
3
- /**
4
- * @public
5
- */
6
- export type AppNetworkInfoRequest = Omit<NetworkInfoRequest, "agent_pub_key">;
2
+ import { AgentPubKey, AppAuthenticationToken, AppInfo, CapSecret, CellId, ClonedCell, DnaHash, DnaProperties, EntryHash, FunctionName, InstalledAppId, MembraneProof, MemproofMap, NetworkSeed, Nonce256Bit, RoleName, Timestamp, Transformer, WebsocketConnectionOptions, ZomeName, PreflightRequest, SignedAction, SignedActionHashed, DumpNetworkStatsResponse, DumpNetworkMetricsResponse, DumpNetworkMetricsRequest } from "../../index.js";
7
3
  /**
8
4
  * @public
9
5
  */
@@ -95,12 +91,6 @@ export interface CreateCloneCellRequest {
95
91
  * override the DNA properties.
96
92
  */
97
93
  properties?: DnaProperties;
98
- /**
99
- * The time used to denote the origin of the network, used to calculate
100
- * time windows during gossip.
101
- * All Action timestamps must come after this time.
102
- */
103
- origin_time?: Timestamp;
104
94
  };
105
95
  /**
106
96
  * Optionally set a proof of membership for the new cell.
@@ -150,23 +140,6 @@ export type EnableCloneCellRequest = DisableCloneCellRequest;
150
140
  * @public
151
141
  */
152
142
  export type EnableCloneCellResponse = CreateCloneCellResponse;
153
- /**
154
- * @public
155
- */
156
- export interface NetworkInfoRequest {
157
- /**
158
- * The calling agent
159
- */
160
- agent_pub_key: AgentPubKey;
161
- /**
162
- * Get network info for these DNAs
163
- */
164
- dnas: DnaHash[];
165
- /**
166
- * Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX_EPOCH.
167
- */
168
- last_time_queried?: number;
169
- }
170
143
  /**
171
144
  * Cell id for which the countersigning session state is requested.
172
145
  *
@@ -372,24 +345,28 @@ export declare enum SessionCompletionDecisionType {
372
345
  export type SessionCompletionDecision = {
373
346
  [SessionCompletionDecisionType.Complete]: SignedActionHashed;
374
347
  } | SessionCompletionDecisionType.Abandoned | SessionCompletionDecisionType.Indeterminate | SessionCompletionDecisionType.Failed;
348
+ export declare enum SignalType {
349
+ App = "app",
350
+ System = "system"
351
+ }
375
352
  /**
376
353
  * @public
377
354
  */
378
355
  export type RawSignal = {
379
- type: "app";
356
+ type: SignalType.App;
380
357
  value: EncodedAppSignal;
381
358
  } | {
382
- type: "system";
359
+ type: SignalType.System;
383
360
  value: SystemSignal;
384
361
  };
385
362
  /**
386
363
  * @public
387
364
  */
388
365
  export type Signal = {
389
- type: "app";
366
+ type: SignalType.App;
390
367
  value: AppSignal;
391
368
  } | {
392
- type: "system";
369
+ type: SignalType.System;
393
370
  value: SystemSignal;
394
371
  };
395
372
  /**
@@ -418,10 +395,6 @@ export type SystemSignal = {
418
395
  * @public
419
396
  */
420
397
  export type SignalCb = (signal: Signal) => void;
421
- /**
422
- * @public
423
- */
424
- export type NetworkInfoResponse = NetworkInfo[];
425
398
  /**
426
399
  * @public
427
400
  */
@@ -431,10 +404,11 @@ export interface AppClient {
431
404
  appInfo(): Promise<AppInfoResponse>;
432
405
  myPubKey: AgentPubKey;
433
406
  installedAppId: InstalledAppId;
407
+ dumpNetworkStats(): Promise<DumpNetworkStatsResponse>;
408
+ dumpNetworkMetrics(args: DumpNetworkMetricsRequest): Promise<DumpNetworkMetricsResponse>;
434
409
  createCloneCell(args: CreateCloneCellRequest): Promise<CreateCloneCellResponse>;
435
410
  enableCloneCell(args: EnableCloneCellRequest): Promise<EnableCloneCellResponse>;
436
411
  disableCloneCell(args: DisableCloneCellRequest): Promise<DisableCloneCellResponse>;
437
- networkInfo(args: AppNetworkInfoRequest): Promise<NetworkInfoResponse>;
438
412
  }
439
413
  /**
440
414
  * @public
@@ -45,3 +45,8 @@ export var SessionCompletionDecisionType;
45
45
  */
46
46
  SessionCompletionDecisionType["Failed"] = "Failed";
47
47
  })(SessionCompletionDecisionType || (SessionCompletionDecisionType = {}));
48
+ export var SignalType;
49
+ (function (SignalType) {
50
+ SignalType["App"] = "app";
51
+ SignalType["System"] = "system";
52
+ })(SignalType || (SignalType = {}));
@@ -1,8 +1,8 @@
1
1
  import { UnsubscribeFunction } from "emittery";
2
2
  import { AgentPubKey, InstalledAppId, RoleName } from "../../types.js";
3
- import { AppInfo, ClonedCell, MemproofMap } from "../admin/index.js";
4
- import { AppClient, AppEvents, AppNetworkInfoRequest, SignalCb, CallZomeRequest, CallZomeRequestSigned, CreateCloneCellRequest, DisableCloneCellRequest, EnableCloneCellRequest, NetworkInfoResponse, AppWebsocketConnectionOptions, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, AbandonCountersigningSessionStateRequest, PublishCountersigningSessionStateRequest, RoleNameCallZomeRequest } from "./types.js";
3
+ import { AppInfo, ClonedCell, DumpNetworkMetricsRequest, DumpNetworkMetricsResponse, DumpNetworkStatsResponse, MemproofMap } from "../admin/index.js";
5
4
  import { WsClient } from "../client.js";
5
+ import { AbandonCountersigningSessionStateRequest, AppClient, AppEvents, AppWebsocketConnectionOptions, CallZomeRequest, CallZomeRequestSigned, CreateCloneCellRequest, DisableCloneCellRequest, EnableCloneCellRequest, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, PublishCountersigningSessionStateRequest, RoleNameCallZomeRequest, SignalCb } from "./types.js";
6
6
  /**
7
7
  * A class to establish a websocket connection to an App interface, for a
8
8
  * specific agent and app.
@@ -24,7 +24,8 @@ export declare class AppWebsocket implements AppClient {
24
24
  private readonly createCloneCellRequester;
25
25
  private readonly enableCloneCellRequester;
26
26
  private readonly disableCloneCellRequester;
27
- private readonly networkInfoRequester;
27
+ private readonly dumpNetworkStatsRequester;
28
+ private readonly dumpNetworkMetricsRequester;
28
29
  private readonly getCountersigningSessionStateRequester;
29
30
  private readonly abandonCountersigningSessionRequester;
30
31
  private readonly publishCountersigningSessionRequester;
@@ -44,6 +45,18 @@ export declare class AppWebsocket implements AppClient {
44
45
  * @returns The app's {@link AppInfo}.
45
46
  */
46
47
  appInfo(timeout?: number): Promise<AppInfo>;
48
+ /**
49
+ * Request network stats.
50
+ *
51
+ * @returns The conductor's {@link TransportStats}.
52
+ */
53
+ dumpNetworkStats(timeout?: number): Promise<DumpNetworkStatsResponse>;
54
+ /**
55
+ * Request network metrics.
56
+ *
57
+ * @returns The {@link NetworkMetrics}.
58
+ */
59
+ dumpNetworkMetrics(req: DumpNetworkMetricsRequest, timeout?: number): Promise<DumpNetworkMetricsResponse>;
47
60
  /**
48
61
  * Provide membrane proofs for the app.
49
62
  *
@@ -51,7 +64,7 @@ export declare class AppWebsocket implements AppClient {
51
64
  */
52
65
  provideMemproofs(memproofs: MemproofMap): Promise<void>;
53
66
  /**
54
- * Enablie an app only if the app is in the `AppStatus::Disabled(DisabledAppReason::NotStartedAfterProvidingMemproofs)`
67
+ * Enable an app only if the app is in the `AppStatus::Disabled(DisabledAppReason::NotStartedAfterProvidingMemproofs)`
55
68
  * state. Attempting to enable the app from other states (other than Running) will fail.
56
69
  */
57
70
  enableApp(): Promise<void>;
@@ -91,12 +104,6 @@ export declare class AppWebsocket implements AppClient {
91
104
  * @param args - Specify the clone cell to disable.
92
105
  */
93
106
  disableCloneCell(args: DisableCloneCellRequest): Promise<void>;
94
- /**
95
- * Request network info about gossip status.
96
- * @param args - Specify the DNAs for which you want network info
97
- * @returns Network info for the specified DNAs
98
- */
99
- networkInfo(args: AppNetworkInfoRequest): Promise<NetworkInfoResponse>;
100
107
  /**
101
108
  * Get the state of a countersigning session.
102
109
  */
@@ -1,14 +1,14 @@
1
+ import { decode, encode } from "@msgpack/msgpack";
1
2
  import Emittery from "emittery";
3
+ import { sha512 } from "js-sha512";
4
+ import _sodium from "libsodium-wrappers";
2
5
  import { omit } from "lodash-es";
3
- import { CellType, } from "../admin/index.js";
4
- import { catchError, DEFAULT_TIMEOUT, getBaseRoleNameFromCloneId, HolochainError, isCloneId, promiseTimeout, requesterTransformer, } from "../common.js";
5
6
  import { getHostZomeCallSigner, getLauncherEnvironment, } from "../../environments/launcher.js";
6
- import { decode, encode } from "@msgpack/msgpack";
7
- import { getNonceExpiration, getSigningCredentials, randomNonce, } from "../zome-call-signing.js";
8
7
  import { encodeHashToBase64 } from "../../utils/index.js";
9
- import _sodium from "libsodium-wrappers";
8
+ import { CellType, } from "../admin/index.js";
10
9
  import { WsClient } from "../client.js";
11
- import { sha512 } from "js-sha512";
10
+ import { catchError, DEFAULT_TIMEOUT, getBaseRoleNameFromCloneId, HolochainError, isCloneId, promiseTimeout, requesterTransformer, } from "../common.js";
11
+ import { getNonceExpiration, getSigningCredentials, randomNonce, } from "../zome-call-signing.js";
12
12
  /**
13
13
  * A class to establish a websocket connection to an App interface, for a
14
14
  * specific agent and app.
@@ -30,7 +30,8 @@ export class AppWebsocket {
30
30
  createCloneCellRequester;
31
31
  enableCloneCellRequester;
32
32
  disableCloneCellRequester;
33
- networkInfoRequester;
33
+ dumpNetworkStatsRequester;
34
+ dumpNetworkMetricsRequester;
34
35
  getCountersigningSessionStateRequester;
35
36
  abandonCountersigningSessionRequester;
36
37
  publishCountersigningSessionRequester;
@@ -49,7 +50,8 @@ export class AppWebsocket {
49
50
  this.createCloneCellRequester = AppWebsocket.requester(this.client, "create_clone_cell", this.defaultTimeout);
50
51
  this.enableCloneCellRequester = AppWebsocket.requester(this.client, "enable_clone_cell", this.defaultTimeout);
51
52
  this.disableCloneCellRequester = AppWebsocket.requester(this.client, "disable_clone_cell", this.defaultTimeout);
52
- this.networkInfoRequester = AppWebsocket.requester(this.client, "network_info", this.defaultTimeout);
53
+ this.dumpNetworkStatsRequester = AppWebsocket.requester(this.client, "dump_network_stats", this.defaultTimeout);
54
+ this.dumpNetworkMetricsRequester = AppWebsocket.requester(this.client, "dump_network_metrics", this.defaultTimeout);
53
55
  this.getCountersigningSessionStateRequester = AppWebsocket.requester(this.client, "get_countersigning_session_state", this.defaultTimeout);
54
56
  this.abandonCountersigningSessionRequester = AppWebsocket.requester(this.client, "abandon_countersigning_session", this.defaultTimeout);
55
57
  this.publishCountersigningSessionRequester = AppWebsocket.requester(this.client, "publish_countersigning_session", this.defaultTimeout);
@@ -107,6 +109,22 @@ export class AppWebsocket {
107
109
  this.cachedAppInfo = appInfo;
108
110
  return appInfo;
109
111
  }
112
+ /**
113
+ * Request network stats.
114
+ *
115
+ * @returns The conductor's {@link TransportStats}.
116
+ */
117
+ async dumpNetworkStats(timeout) {
118
+ return await this.dumpNetworkStatsRequester(undefined, timeout);
119
+ }
120
+ /**
121
+ * Request network metrics.
122
+ *
123
+ * @returns The {@link NetworkMetrics}.
124
+ */
125
+ async dumpNetworkMetrics(req, timeout) {
126
+ return await this.dumpNetworkMetricsRequester(req, timeout);
127
+ }
110
128
  /**
111
129
  * Provide membrane proofs for the app.
112
130
  *
@@ -116,7 +134,7 @@ export class AppWebsocket {
116
134
  await this.provideMemproofRequester(memproofs);
117
135
  }
118
136
  /**
119
- * Enablie an app only if the app is in the `AppStatus::Disabled(DisabledAppReason::NotStartedAfterProvidingMemproofs)`
137
+ * Enable an app only if the app is in the `AppStatus::Disabled(DisabledAppReason::NotStartedAfterProvidingMemproofs)`
120
138
  * state. Attempting to enable the app from other states (other than Running) will fail.
121
139
  */
122
140
  async enableApp() {
@@ -212,17 +230,6 @@ export class AppWebsocket {
212
230
  ...args,
213
231
  });
214
232
  }
215
- /**
216
- * Request network info about gossip status.
217
- * @param args - Specify the DNAs for which you want network info
218
- * @returns Network info for the specified DNAs
219
- */
220
- async networkInfo(args) {
221
- return this.networkInfoRequester({
222
- ...args,
223
- agent_pub_key: this.myPubKey,
224
- });
225
- }
226
233
  /**
227
234
  * Get the state of a countersigning session.
228
235
  */
package/lib/api/client.js CHANGED
@@ -2,6 +2,8 @@ import { decode, encode } from "@msgpack/msgpack";
2
2
  import Emittery from "emittery";
3
3
  import IsoWebSocket from "isomorphic-ws";
4
4
  import { HolochainError } from "./common.js";
5
+ import { SignalType } from "./app/index.js";
6
+ import { encodeHashToBase64 } from "../utils/base64.js";
5
7
  /**
6
8
  * A WebSocket client which can make requests and receive responses,
7
9
  * as well as send and receive signals.
@@ -158,9 +160,9 @@ export class WsClient extends Emittery {
158
160
  }
159
161
  const deserializedSignal = decode(message.data);
160
162
  assertHolochainSignal(deserializedSignal);
161
- if (deserializedSignal.type === "system") {
163
+ if (deserializedSignal.type === SignalType.System) {
162
164
  this.emit("signal", {
163
- type: "system",
165
+ type: SignalType.System,
164
166
  value: deserializedSignal.value,
165
167
  });
166
168
  }
@@ -173,7 +175,10 @@ export class WsClient extends Emittery {
173
175
  zome_name: encodedAppSignal.zome_name,
174
176
  payload,
175
177
  };
176
- this.emit("signal", { type: "app", value: signal });
178
+ this.emit("signal", {
179
+ type: SignalType.App,
180
+ value: signal,
181
+ });
177
182
  }
178
183
  }
179
184
  else if (message.type === "response") {
@@ -232,7 +237,19 @@ export class WsClient extends Emittery {
232
237
  this.pendingRequests[id].reject(new Error("Response canceled by responder"));
233
238
  }
234
239
  else {
235
- this.pendingRequests[id].resolve(decode(msg.data));
240
+ this.pendingRequests[id].resolve(decode(msg.data, {
241
+ mapKeyConverter: (key) => {
242
+ if (typeof key === "string" || typeof key === "number") {
243
+ return key;
244
+ }
245
+ if (key && typeof key === "object" && key instanceof Uint8Array) {
246
+ // Key of type byte array, must be a HoloHash.
247
+ return encodeHashToBase64(key);
248
+ }
249
+ throw new HolochainError("DeserializationError", "Encountered map with key of type 'object', but not HoloHash " +
250
+ key);
251
+ },
252
+ }));
236
253
  }
237
254
  delete this.pendingRequests[id];
238
255
  }
@@ -255,7 +272,7 @@ function assertHolochainSignal(signal) {
255
272
  signal !== null &&
256
273
  "type" in signal &&
257
274
  "value" in signal &&
258
- ["app", "signal"].some((type) => signal.type === type)) {
275
+ [SignalType.App, SignalType.System].some((type) => signal.type === type)) {
259
276
  return;
260
277
  }
261
278
  throw new HolochainError("UnknownSignalFormat", `incoming signal has unknown signal format ${JSON.stringify(signal, null, 4)}`);
@@ -65,7 +65,7 @@ export declare const getBaseRoleNameFromCloneId: (roleName: RoleName) => string;
65
65
  *
66
66
  * @public
67
67
  */
68
- export declare class CloneId {
68
+ export declare class CloneIdHelper {
69
69
  private readonly roleName;
70
70
  private readonly index;
71
71
  constructor(roleName: RoleName, index: number);
@@ -74,7 +74,7 @@ export declare class CloneId {
74
74
  * @param roleName - Role id to parse.
75
75
  * @returns A clone id instance.
76
76
  */
77
- static fromRoleName(roleName: RoleName): CloneId;
77
+ static fromRoleName(roleName: RoleName): CloneIdHelper;
78
78
  toString(): string;
79
79
  getBaseRoleName(): string;
80
80
  }
package/lib/api/common.js CHANGED
@@ -85,7 +85,7 @@ export const getBaseRoleNameFromCloneId = (roleName) => {
85
85
  *
86
86
  * @public
87
87
  */
88
- export class CloneId {
88
+ export class CloneIdHelper {
89
89
  roleName;
90
90
  index;
91
91
  constructor(roleName, index) {
@@ -102,7 +102,7 @@ export class CloneId {
102
102
  if (parts.length !== 2) {
103
103
  throw new HolochainError("MalformedCloneId", `clone id must consist of 'role_id.clone_index', but got ${roleName}`);
104
104
  }
105
- return new CloneId(parts[0], parseInt(parts[1]));
105
+ return new CloneIdHelper(parts[0], parseInt(parts[1]));
106
106
  }
107
107
  toString() {
108
108
  return `${this.roleName}${CLONE_ID_DELIMITER}${this.index}`;
@@ -1,5 +1,5 @@
1
1
  export * from "./admin/index.js";
2
2
  export * from "./app/index.js";
3
3
  export { IsoWebSocket, WsClient, type AppAuthenticationRequest, } from "./client.js";
4
- export { CloneId, HolochainError, getBaseRoleNameFromCloneId, isCloneId, type Requester, type Transformer, type WebsocketConnectionOptions, type WsClientOptions, } from "./common.js";
4
+ export { CloneIdHelper, HolochainError, getBaseRoleNameFromCloneId, isCloneId, type Requester, type Transformer, type WebsocketConnectionOptions, type WsClientOptions, } from "./common.js";
5
5
  export * from "./zome-call-signing.js";
package/lib/api/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "./admin/index.js";
2
2
  export * from "./app/index.js";
3
3
  export { IsoWebSocket, WsClient, } from "./client.js";
4
- export { CloneId, HolochainError, getBaseRoleNameFromCloneId, isCloneId, } from "./common.js";
4
+ export { CloneIdHelper, HolochainError, getBaseRoleNameFromCloneId, isCloneId, } from "./common.js";
5
5
  export * from "./zome-call-signing.js";
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.11"
8
+ "packageVersion": "7.52.3"
9
9
  }
10
10
  ]
11
11
  }
package/lib/types.d.ts CHANGED
@@ -112,17 +112,6 @@ export interface HoloHashed<T> {
112
112
  hash: HoloHash;
113
113
  content: T;
114
114
  }
115
- /**
116
- * @public
117
- */
118
- export interface NetworkInfo {
119
- fetch_pool_info: FetchPoolInfo;
120
- current_number_of_peers: number;
121
- arc_size: number;
122
- total_network_peers: number;
123
- bytes_since_last_time_queried: number;
124
- completed_rounds_since_last_time_queried: number;
125
- }
126
115
  /**
127
116
  * @public
128
117
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holochain/client",
3
- "version": "0.19.0-dev.8",
3
+ "version": "0.19.0-rc.1",
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",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@bitgo/blake2b": "^3.2.4",
46
- "@msgpack/msgpack": "^2.8.0",
46
+ "@msgpack/msgpack": "^3.1.1",
47
47
  "emittery": "^1.0.1",
48
48
  "isomorphic-ws": "^5.0.0",
49
49
  "js-base64": "^3.7.5",