@holochain/client 0.11.12 → 0.11.14

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.
Files changed (75) hide show
  1. package/README.md +1 -1
  2. package/lib/api/admin/index.js +0 -1
  3. package/lib/api/admin/types.d.ts +355 -41
  4. package/lib/api/admin/types.js +40 -1
  5. package/lib/api/admin/websocket.d.ts +80 -1
  6. package/lib/api/admin/websocket.js +82 -4
  7. package/lib/api/app/index.js +0 -1
  8. package/lib/api/app/types.d.ts +78 -3
  9. package/lib/api/app/types.js +3 -1
  10. package/lib/api/app/websocket.d.ts +54 -0
  11. package/lib/api/app/websocket.js +48 -1
  12. package/lib/api/app-agent/index.js +0 -1
  13. package/lib/api/app-agent/types.d.ts +27 -0
  14. package/lib/api/app-agent/types.js +0 -1
  15. package/lib/api/app-agent/websocket.d.ts +57 -0
  16. package/lib/api/app-agent/websocket.js +57 -1
  17. package/lib/api/client.d.ts +25 -9
  18. package/lib/api/client.js +37 -14
  19. package/lib/api/common.d.ts +30 -1
  20. package/lib/api/common.js +18 -2
  21. package/lib/api/index.d.ts +2 -1
  22. package/lib/api/index.js +1 -1
  23. package/lib/api/zome-call-signing.d.ts +24 -1
  24. package/lib/api/zome-call-signing.js +18 -2
  25. package/lib/environments/launcher.js +0 -1
  26. package/lib/hdk/action.d.ts +45 -0
  27. package/lib/hdk/action.js +3 -1
  28. package/lib/hdk/capabilities.d.ts +21 -0
  29. package/lib/hdk/capabilities.js +3 -1
  30. package/lib/hdk/countersigning.d.ts +30 -0
  31. package/lib/hdk/countersigning.js +0 -1
  32. package/lib/hdk/dht-ops.d.ts +18 -0
  33. package/lib/hdk/dht-ops.js +15 -1
  34. package/lib/hdk/entry.d.ts +15 -0
  35. package/lib/hdk/entry.js +0 -1
  36. package/lib/hdk/index.d.ts +1 -0
  37. package/lib/hdk/index.js +1 -1
  38. package/lib/hdk/record.d.ts +6 -0
  39. package/lib/hdk/record.js +0 -1
  40. package/lib/index.js +0 -1
  41. package/lib/tsdoc-metadata.json +11 -0
  42. package/lib/types.d.ts +81 -0
  43. package/lib/types.js +0 -1
  44. package/lib/utils/base64.d.ts +16 -0
  45. package/lib/utils/base64.js +16 -1
  46. package/lib/utils/fake-hash.d.ts +23 -1
  47. package/lib/utils/fake-hash.js +23 -2
  48. package/lib/utils/index.js +0 -1
  49. package/package.json +5 -2
  50. package/lib/api/admin/index.js.map +0 -1
  51. package/lib/api/admin/types.js.map +0 -1
  52. package/lib/api/admin/websocket.js.map +0 -1
  53. package/lib/api/app/index.js.map +0 -1
  54. package/lib/api/app/types.js.map +0 -1
  55. package/lib/api/app/websocket.js.map +0 -1
  56. package/lib/api/app-agent/index.js.map +0 -1
  57. package/lib/api/app-agent/types.js.map +0 -1
  58. package/lib/api/app-agent/websocket.js.map +0 -1
  59. package/lib/api/client.js.map +0 -1
  60. package/lib/api/common.js.map +0 -1
  61. package/lib/api/index.js.map +0 -1
  62. package/lib/api/zome-call-signing.js.map +0 -1
  63. package/lib/environments/launcher.js.map +0 -1
  64. package/lib/hdk/action.js.map +0 -1
  65. package/lib/hdk/capabilities.js.map +0 -1
  66. package/lib/hdk/countersigning.js.map +0 -1
  67. package/lib/hdk/dht-ops.js.map +0 -1
  68. package/lib/hdk/entry.js.map +0 -1
  69. package/lib/hdk/index.js.map +0 -1
  70. package/lib/hdk/record.js.map +0 -1
  71. package/lib/index.js.map +0 -1
  72. package/lib/types.js.map +0 -1
  73. package/lib/utils/base64.js.map +0 -1
  74. package/lib/utils/fake-hash.js.map +0 -1
  75. package/lib/utils/index.js.map +0 -1
@@ -1,9 +1,49 @@
1
+ /**
2
+ * @public
3
+ */
1
4
  export var CellType;
2
5
  (function (CellType) {
3
6
  CellType["Provisioned"] = "Provisioned";
4
7
  CellType["Cloned"] = "Cloned";
5
8
  CellType["Stem"] = "Stem";
6
9
  })(CellType || (CellType = {}));
10
+ /**
11
+ * @public
12
+ */
13
+ export var CellProvisioningStrategy;
14
+ (function (CellProvisioningStrategy) {
15
+ /**
16
+ * Always create a new Cell when installing this App
17
+ */
18
+ CellProvisioningStrategy["Create"] = "create";
19
+ /**
20
+ * Always create a new Cell when installing the App,
21
+ * and use a unique network seed to ensure a distinct DHT network.
22
+ *
23
+ * Not implemented
24
+ */
25
+ // CreateClone = "create_clone",
26
+ /**
27
+ * Require that a Cell is already installed which matches the DNA version
28
+ * spec, and which has an Agent that's associated with this App's agent
29
+ * via DPKI. If no such Cell exists, *app installation fails*.
30
+ */
31
+ CellProvisioningStrategy["UseExisting"] = "use_existing";
32
+ /**
33
+ * Try `UseExisting`, and if that fails, fallback to `Create`
34
+ */
35
+ CellProvisioningStrategy["CreateIfNoExists"] = "create_if_no_exists";
36
+ /**
37
+ * Disallow provisioning altogether. In this case, we expect
38
+ * `clone_limit > 0`: otherwise, no Cells will ever be created.
39
+ *
40
+ * Not implemented
41
+ */
42
+ // Disabled = "disabled",
43
+ })(CellProvisioningStrategy || (CellProvisioningStrategy = {}));
44
+ /**
45
+ * @public
46
+ */
7
47
  export var AppStatusFilter;
8
48
  (function (AppStatusFilter) {
9
49
  AppStatusFilter["Enabled"] = "enabled";
@@ -12,4 +52,3 @@ export var AppStatusFilter;
12
52
  AppStatusFilter["Stopped"] = "stopped";
13
53
  AppStatusFilter["Paused"] = "paused";
14
54
  })(AppStatusFilter || (AppStatusFilter = {}));
15
- //# sourceMappingURL=types.js.map
@@ -3,30 +3,109 @@ import type { AgentPubKey, CellId } from "../../types.js";
3
3
  import { WsClient } from "../client.js";
4
4
  import { Requester, Transformer } from "../common.js";
5
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, StartAppRequest, StartAppResponse, UninstallAppRequest, UninstallAppResponse } from "./types.js";
6
+ /**
7
+ * A class for interacting with a conductor's Admin API.
8
+ *
9
+ * @public
10
+ */
6
11
  export declare class AdminWebsocket implements AdminApi {
12
+ /**
13
+ * The websocket client used for transporting requests and responses.
14
+ */
7
15
  readonly client: WsClient;
16
+ /**
17
+ * Default timeout for any request made over the websocket.
18
+ */
8
19
  defaultTimeout: number;
9
20
  private constructor();
21
+ /**
22
+ * Factory mehtod to create a new instance connected to the given URL.
23
+ *
24
+ * @param url - A `ws://` URL used as the connection address.
25
+ * @param defaultTimeout - The default timeout for any request.
26
+ * @returns A promise for a new connected instance.
27
+ */
10
28
  static connect(url: string, defaultTimeout?: number): Promise<AdminWebsocket>;
11
- _requester: <ReqO, ReqI, ResI, ResO>(tag: string, transformer?: Transformer<ReqO, ReqI, ResI, ResO> | undefined) => (req: ReqO, timeout?: number | undefined) => Promise<ResO>;
29
+ _requester<ReqI, ReqO, ResI, ResO>(tag: string, transformer?: Transformer<ReqI, ReqO, ResI, ResO>): (req: ReqI, timeout?: number | undefined) => Promise<ResO>;
30
+ /**
31
+ * Send a request to open the given port for {@link AppWebsocket} connections.
32
+ */
12
33
  attachAppInterface: Requester<AttachAppInterfaceRequest, AttachAppInterfaceResponse>;
34
+ /**
35
+ * Enable a stopped app.
36
+ */
13
37
  enableApp: Requester<EnableAppRequest, EnableAppResponse>;
38
+ /**
39
+ * Disable a running app.
40
+ */
14
41
  disableApp: Requester<DisableAppRequest, DisableAppResponse>;
42
+ /**
43
+ * Start an app.
44
+ */
15
45
  startApp: Requester<StartAppRequest, StartAppResponse>;
46
+ /**
47
+ * Dump the state of the specified cell, including its source chain, as JSON.
48
+ */
16
49
  dumpState: Requester<DumpStateRequest, DumpStateResponse>;
50
+ /**
51
+ * Dump the full state of the specified cell, including its chain and DHT
52
+ * shard, as JSON.
53
+ */
17
54
  dumpFullState: Requester<DumpFullStateRequest, DumpFullStateResponse>;
55
+ /**
56
+ * Generate a new agent pub key.
57
+ */
18
58
  generateAgentPubKey: Requester<GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse>;
59
+ /**
60
+ * Register a DNA for later app installation.
61
+ *
62
+ * Stores the given DNA into the Holochain DNA database and returns the hash of it.
63
+ */
19
64
  registerDna: Requester<RegisterDnaRequest, RegisterDnaResponse>;
65
+ /**
66
+ * Get the DNA definition for the specified DNA hash.
67
+ */
20
68
  getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
69
+ /**
70
+ * Uninstall the specified app from Holochain.
71
+ */
21
72
  uninstallApp: Requester<UninstallAppRequest, UninstallAppResponse>;
73
+ /**
74
+ * Install the specified app into Holochain.
75
+ */
22
76
  installApp: Requester<InstallAppRequest, InstallAppResponse>;
77
+ /**
78
+ * List all registered DNAs.
79
+ */
23
80
  listDnas: Requester<ListDnasRequest, ListDnasResponse>;
81
+ /**
82
+ * List all installed cell ids.
83
+ */
24
84
  listCellIds: Requester<ListCellIdsRequest, ListCellIdsResponse>;
85
+ /**
86
+ * List all installed apps.
87
+ */
25
88
  listApps: Requester<ListAppsRequest, ListAppsResponse>;
89
+ /**
90
+ * List all attached app interfaces.
91
+ */
26
92
  listAppInterfaces: Requester<ListAppInterfacesRequest, ListAppInterfacesResponse>;
93
+ /**
94
+ * Request all available info about an agent.
95
+ */
27
96
  agentInfo: Requester<AgentInfoRequest, AgentInfoResponse>;
97
+ /**
98
+ * Add an existing agent to Holochain.
99
+ */
28
100
  addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
101
+ /**
102
+ * Delete a disabled clone cell.
103
+ */
29
104
  deleteCloneCell: Requester<DeleteCloneCellRequest, DeleteCloneCellResponse>;
105
+ /**
106
+ * Grant a zome call capability for an agent, to be used for signing zome
107
+ * calls.
108
+ */
30
109
  grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
31
110
  /**
32
111
  * Grant a capability for signing zome calls.
@@ -4,14 +4,32 @@ import { WsClient } from "../client.js";
4
4
  import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, } from "../common.js";
5
5
  import { generateSigningKeyPair, randomCapSecret, setSigningCredentials, } from "../zome-call-signing.js";
6
6
  import { AppStatusFilter, } from "./types.js";
7
+ /**
8
+ * A class for interacting with a conductor's Admin API.
9
+ *
10
+ * @public
11
+ */
7
12
  export class AdminWebsocket {
13
+ /**
14
+ * The websocket client used for transporting requests and responses.
15
+ */
8
16
  client;
17
+ /**
18
+ * Default timeout for any request made over the websocket.
19
+ */
9
20
  defaultTimeout;
10
21
  constructor(client, defaultTimeout) {
11
22
  this.client = client;
12
23
  this.defaultTimeout =
13
24
  defaultTimeout === undefined ? DEFAULT_TIMEOUT : defaultTimeout;
14
25
  }
26
+ /**
27
+ * Factory mehtod to create a new instance connected to the given URL.
28
+ *
29
+ * @param url - A `ws://` URL used as the connection address.
30
+ * @param defaultTimeout - The default timeout for any request.
31
+ * @returns A promise for a new connected instance.
32
+ */
15
33
  static async connect(url, defaultTimeout) {
16
34
  // Check if we are in the launcher's environment, and if so, redirect the url to connect to
17
35
  const env = getLauncherEnvironment();
@@ -21,27 +39,88 @@ export class AdminWebsocket {
21
39
  const wsClient = await WsClient.connect(url);
22
40
  return new AdminWebsocket(wsClient, defaultTimeout);
23
41
  }
24
- _requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
25
- // the specific request/response types come from the Interface
26
- // which this class implements
42
+ _requester(tag, transformer) {
43
+ return requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
44
+ }
45
+ /**
46
+ * Send a request to open the given port for {@link AppWebsocket} connections.
47
+ */
27
48
  attachAppInterface = this._requester("attach_app_interface");
49
+ /**
50
+ * Enable a stopped app.
51
+ */
28
52
  enableApp = this._requester("enable_app");
53
+ /**
54
+ * Disable a running app.
55
+ */
29
56
  disableApp = this._requester("disable_app");
57
+ /**
58
+ * Start an app.
59
+ */
30
60
  startApp = this._requester("start_app");
61
+ /**
62
+ * Dump the state of the specified cell, including its source chain, as JSON.
63
+ */
31
64
  dumpState = this._requester("dump_state", dumpStateTransform);
65
+ /**
66
+ * Dump the full state of the specified cell, including its chain and DHT
67
+ * shard, as JSON.
68
+ */
32
69
  dumpFullState = this._requester("dump_full_state");
70
+ /**
71
+ * Generate a new agent pub key.
72
+ */
33
73
  generateAgentPubKey = this._requester("generate_agent_pub_key");
74
+ /**
75
+ * Register a DNA for later app installation.
76
+ *
77
+ * Stores the given DNA into the Holochain DNA database and returns the hash of it.
78
+ */
34
79
  registerDna = this._requester("register_dna");
80
+ /**
81
+ * Get the DNA definition for the specified DNA hash.
82
+ */
35
83
  getDnaDefinition = this._requester("get_dna_definition");
84
+ /**
85
+ * Uninstall the specified app from Holochain.
86
+ */
36
87
  uninstallApp = this._requester("uninstall_app");
88
+ /**
89
+ * Install the specified app into Holochain.
90
+ */
37
91
  installApp = this._requester("install_app");
92
+ /**
93
+ * List all registered DNAs.
94
+ */
38
95
  listDnas = this._requester("list_dnas");
96
+ /**
97
+ * List all installed cell ids.
98
+ */
39
99
  listCellIds = this._requester("list_cell_ids");
100
+ /**
101
+ * List all installed apps.
102
+ */
40
103
  listApps = this._requester("list_apps", listAppsTransform);
104
+ /**
105
+ * List all attached app interfaces.
106
+ */
41
107
  listAppInterfaces = this._requester("list_app_interfaces");
108
+ /**
109
+ * Request all available info about an agent.
110
+ */
42
111
  agentInfo = this._requester("agent_info");
112
+ /**
113
+ * Add an existing agent to Holochain.
114
+ */
43
115
  addAgentInfo = this._requester("add_agent_info");
116
+ /**
117
+ * Delete a disabled clone cell.
118
+ */
44
119
  deleteCloneCell = this._requester("delete_clone_cell");
120
+ /**
121
+ * Grant a zome call capability for an agent, to be used for signing zome
122
+ * calls.
123
+ */
45
124
  grantZomeCallCapability = this._requester("grant_zome_call_capability");
46
125
  // zome call signing related methods
47
126
  /**
@@ -123,4 +202,3 @@ function getAppStatusInApiForm(status_filter) {
123
202
  };
124
203
  }
125
204
  }
126
- //# sourceMappingURL=websocket.js.map
@@ -1,3 +1,2 @@
1
1
  export * from "./types.js";
2
2
  export * from "./websocket.js";
3
- //# sourceMappingURL=index.js.map
@@ -1,6 +1,9 @@
1
1
  import { AgentPubKey, CellId, DnaHash, DnaProperties, InstalledAppId, InstalledCell, NetworkInfo, RoleName, Timestamp } from "../../types.js";
2
2
  import { AppInfo, FunctionName, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
3
3
  import { Requester } from "../common.js";
4
+ /**
5
+ * @public
6
+ */
4
7
  export declare type CallZomeRequestGeneric<Payload> = {
5
8
  cell_id: CellId;
6
9
  zome_name: ZomeName;
@@ -8,13 +11,31 @@ export declare type CallZomeRequestGeneric<Payload> = {
8
11
  payload: Payload;
9
12
  provenance: AgentPubKey;
10
13
  };
14
+ /**
15
+ * @public
16
+ */
11
17
  export declare type CallZomeRequest = CallZomeRequestGeneric<any>;
18
+ /**
19
+ * @public
20
+ */
12
21
  export declare type CallZomeResponseGeneric<Payload> = Payload;
22
+ /**
23
+ * @public
24
+ */
13
25
  export declare type CallZomeResponse = CallZomeResponseGeneric<any>;
26
+ /**
27
+ * @public
28
+ */
14
29
  export declare type AppInfoRequest = {
15
30
  installed_app_id: InstalledAppId;
16
31
  };
32
+ /**
33
+ * @public
34
+ */
17
35
  export declare type AppInfoResponse = AppInfo;
36
+ /**
37
+ * @public
38
+ */
18
39
  export interface CreateCloneCellRequest {
19
40
  /**
20
41
  * The app id that the DNA to clone belongs to
@@ -59,32 +80,86 @@ export interface CreateCloneCellRequest {
59
80
  */
60
81
  name?: string;
61
82
  }
83
+ /**
84
+ * @public
85
+ */
62
86
  export declare type CreateCloneCellResponse = InstalledCell;
87
+ /**
88
+ * @public
89
+ */
63
90
  export interface DisableCloneCellRequest {
91
+ /**
92
+ * The app id that the clone cell belongs to
93
+ */
64
94
  app_id: InstalledAppId;
95
+ /**
96
+ * The clone id or cell id of the clone cell
97
+ */
65
98
  clone_cell_id: RoleName | CellId;
66
99
  }
100
+ /**
101
+ * @public
102
+ */
67
103
  export declare type DisableCloneCellResponse = void;
104
+ /**
105
+ * @public
106
+ */
68
107
  export declare type EnableCloneCellRequest = DisableCloneCellRequest;
108
+ /**
109
+ * @public
110
+ */
69
111
  export declare type EnableCloneCellResponse = CreateCloneCellResponse;
112
+ /**
113
+ * @public
114
+ */
70
115
  export interface NetworkInfoRequest {
71
- /** The DNAs for which to get network info */
116
+ /**
117
+ * The DNAs for which to get network info
118
+ */
72
119
  dnas: DnaHash[];
73
120
  }
121
+ /**
122
+ * @public
123
+ */
74
124
  export declare const SignalType: {
75
125
  readonly App: "App";
76
126
  readonly System: "System";
77
127
  };
128
+ /**
129
+ * @public
130
+ */
78
131
  export declare type Signal = {
79
- [SignalType.App]: [CellId, any];
132
+ [SignalType.App]: EncodedAppSignal;
133
+ } | {
80
134
  [SignalType.System]: unknown;
81
135
  };
136
+ /**
137
+ * @public
138
+ */
139
+ export declare type EncodedAppSignal = {
140
+ cell_id: CellId;
141
+ zome_name: string;
142
+ signal: Uint8Array;
143
+ };
144
+ /**
145
+ * @public
146
+ */
82
147
  export declare type AppSignal = {
83
148
  cell_id: CellId;
84
- payload: any;
149
+ zome_name: string;
150
+ payload: unknown;
85
151
  };
152
+ /**
153
+ * @public
154
+ */
86
155
  export declare type AppSignalCb = (signal: AppSignal) => void;
156
+ /**
157
+ * @public
158
+ */
87
159
  export declare type NetworkInfoResponse = NetworkInfo[];
160
+ /**
161
+ * @public
162
+ */
88
163
  export interface AppApi {
89
164
  appInfo: Requester<AppInfoRequest, AppInfoResponse>;
90
165
  callZome: Requester<CallZomeRequest, CallZomeResponse>;
@@ -1,5 +1,7 @@
1
+ /**
2
+ * @public
3
+ */
1
4
  export const SignalType = {
2
5
  App: "App",
3
6
  System: "System",
4
7
  };
5
- //# sourceMappingURL=types.js.map
@@ -5,26 +5,80 @@ import { WsClient } from "../client.js";
5
5
  import { Requester, Transformer } from "../common.js";
6
6
  import { Nonce256Bit } from "../zome-call-signing.js";
7
7
  import { AppApi, AppInfoRequest, AppInfoResponse, CallZomeRequest, CallZomeResponse, CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellRequest, DisableCloneCellResponse, EnableCloneCellRequest, EnableCloneCellResponse, NetworkInfoRequest, NetworkInfoResponse } from "./types.js";
8
+ /**
9
+ * A class to establish a websocket connection to an App interface of a
10
+ * Holochain conductor.
11
+ *
12
+ * @public
13
+ */
8
14
  export declare class AppWebsocket extends Emittery implements AppApi {
9
15
  readonly client: WsClient;
10
16
  defaultTimeout: number;
11
17
  overrideInstalledAppId?: InstalledAppId;
12
18
  private constructor();
19
+ /**
20
+ * Instance factory for creating AppWebsockets.
21
+ *
22
+ * @param url - The `ws://` URL of the App API to connect to.
23
+ * @param defaultTimeout - Timeout to default to for all operations.
24
+ * @returns A new instance of an AppWebsocket.
25
+ */
13
26
  static connect(url: string, defaultTimeout?: number): Promise<AppWebsocket>;
14
27
  _requester: <ReqI, ReqO, ResI, ResO>(tag: string, transformer?: Transformer<ReqI, ReqO, ResI, ResO> | undefined) => (req: ReqI, timeout?: number | undefined) => Promise<ResO>;
28
+ /**
29
+ * Request the app's info, including all cell infos.
30
+ *
31
+ * @returns The app's {@link AppInfo}.
32
+ */
15
33
  appInfo: Requester<AppInfoRequest, AppInfoResponse>;
34
+ /**
35
+ * Call a zome.
36
+ *
37
+ * @param request - The zome call arguments.
38
+ * @param timeout - A timeout to override the default.
39
+ * @returns The zome call's response.
40
+ */
16
41
  callZome: Requester<CallZomeRequest | CallZomeRequestSigned, CallZomeResponse>;
42
+ /**
43
+ * Clone an existing provisioned cell.
44
+ *
45
+ * @param args - Specify the cell to clone.
46
+ * @returns The created clone cell.
47
+ */
17
48
  createCloneCell: Requester<CreateCloneCellRequest, CreateCloneCellResponse>;
49
+ /**
50
+ * Enable a disabled clone cell.
51
+ *
52
+ * @param args - Specify the clone cell to enable.
53
+ * @returns The enabled clone cell.
54
+ */
18
55
  enableCloneCell: Requester<EnableCloneCellRequest, EnableCloneCellResponse>;
56
+ /**
57
+ * Disable an enabled clone cell.
58
+ *
59
+ * @param args - Specify the clone cell to disable.
60
+ */
19
61
  disableCloneCell: Requester<DisableCloneCellRequest, DisableCloneCellResponse>;
62
+ /**
63
+ * Request network info about gossip status.
64
+ */
20
65
  networkInfo: Requester<NetworkInfoRequest, NetworkInfoResponse>;
21
66
  }
67
+ /**
68
+ * @public
69
+ */
22
70
  export interface CallZomeRequestUnsigned extends CallZomeRequest {
23
71
  cap_secret: CapSecret | null;
24
72
  nonce: Nonce256Bit;
25
73
  expires_at: number;
26
74
  }
75
+ /**
76
+ * @public
77
+ */
27
78
  export interface CallZomeRequestSigned extends CallZomeRequestUnsigned {
28
79
  signature: Uint8Array;
29
80
  }
81
+ /**
82
+ * @public
83
+ */
30
84
  export declare const signZomeCall: (request: CallZomeRequest) => Promise<CallZomeRequestSigned>;
@@ -7,6 +7,12 @@ import { encodeHashToBase64 } from "../../utils/base64.js";
7
7
  import { WsClient } from "../client.js";
8
8
  import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, } from "../common.js";
9
9
  import { getNonceExpiration, getSigningCredentials, randomNonce, } from "../zome-call-signing.js";
10
+ /**
11
+ * A class to establish a websocket connection to an App interface of a
12
+ * Holochain conductor.
13
+ *
14
+ * @public
15
+ */
10
16
  export class AppWebsocket extends Emittery {
11
17
  client;
12
18
  defaultTimeout;
@@ -18,6 +24,13 @@ export class AppWebsocket extends Emittery {
18
24
  defaultTimeout === undefined ? DEFAULT_TIMEOUT : defaultTimeout;
19
25
  this.overrideInstalledAppId = overrideInstalledAppId;
20
26
  }
27
+ /**
28
+ * Instance factory for creating AppWebsockets.
29
+ *
30
+ * @param url - The `ws://` URL of the App API to connect to.
31
+ * @param defaultTimeout - Timeout to default to for all operations.
32
+ * @returns A new instance of an AppWebsocket.
33
+ */
21
34
  static async connect(url, defaultTimeout) {
22
35
  // Check if we are in the launcher's environment, and if so, redirect the url to connect to
23
36
  const env = getLauncherEnvironment();
@@ -30,11 +43,43 @@ export class AppWebsocket extends Emittery {
30
43
  return appWebsocket;
31
44
  }
32
45
  _requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
46
+ /**
47
+ * Request the app's info, including all cell infos.
48
+ *
49
+ * @returns The app's {@link AppInfo}.
50
+ */
33
51
  appInfo = this._requester("app_info", appInfoTransform(this));
52
+ /**
53
+ * Call a zome.
54
+ *
55
+ * @param request - The zome call arguments.
56
+ * @param timeout - A timeout to override the default.
57
+ * @returns The zome call's response.
58
+ */
34
59
  callZome = this._requester("call_zome", callZomeTransform);
60
+ /**
61
+ * Clone an existing provisioned cell.
62
+ *
63
+ * @param args - Specify the cell to clone.
64
+ * @returns The created clone cell.
65
+ */
35
66
  createCloneCell = this._requester("create_clone_cell");
67
+ /**
68
+ * Enable a disabled clone cell.
69
+ *
70
+ * @param args - Specify the clone cell to enable.
71
+ * @returns The enabled clone cell.
72
+ */
36
73
  enableCloneCell = this._requester("enable_clone_cell");
74
+ /**
75
+ * Disable an enabled clone cell.
76
+ *
77
+ * @param args - Specify the clone cell to disable.
78
+ */
37
79
  disableCloneCell = this._requester("disable_clone_cell");
80
+ /**
81
+ * Request network info about gossip status.
82
+ */
38
83
  networkInfo = this._requester("network_info");
39
84
  }
40
85
  const callZomeTransform = {
@@ -60,6 +105,9 @@ const appInfoTransform = (appWs) => ({
60
105
  },
61
106
  output: (response) => response,
62
107
  });
108
+ /**
109
+ * @public
110
+ */
63
111
  export const signZomeCall = async (request) => {
64
112
  const signingCredentialsForCell = getSigningCredentials(request.cell_id);
65
113
  if (!signingCredentialsForCell) {
@@ -85,4 +133,3 @@ export const signZomeCall = async (request) => {
85
133
  };
86
134
  return signedZomeCall;
87
135
  };
88
- //# sourceMappingURL=websocket.js.map
@@ -1,3 +1,2 @@
1
1
  export * from "./types.js";
2
2
  export * from "./websocket.js";
3
- //# sourceMappingURL=index.js.map
@@ -2,20 +2,47 @@ import { UnsubscribeFunction } from "emittery";
2
2
  import { AgentPubKey, RoleName } from "../../index.js";
3
3
  import { AppInfoResponse, AppSignal, AppSignalCb, CallZomeRequest, CallZomeRequestSigned, DisableCloneCellRequest, EnableCloneCellRequest, EnableCloneCellResponse } from "../app/index.js";
4
4
  import { CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellResponse } from "../index.js";
5
+ /**
6
+ * @public
7
+ */
5
8
  export declare type NonProvenanceCallZomeRequest = Omit<CallZomeRequest, "provenance">;
9
+ /**
10
+ * @public
11
+ */
6
12
  export declare type RoleNameCallZomeRequest = Omit<NonProvenanceCallZomeRequest, "cell_id"> & {
7
13
  role_name: RoleName;
8
14
  };
15
+ /**
16
+ * @public
17
+ */
9
18
  export declare type RoleNameCallZomeRequestSigned = Omit<CallZomeRequestSigned, "cell_id"> & {
10
19
  role_name: RoleName;
11
20
  };
21
+ /**
22
+ * @public
23
+ */
12
24
  export declare type AppAgentCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequestSigned | RoleNameCallZomeRequestSigned;
25
+ /**
26
+ * @public
27
+ */
13
28
  export declare type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
29
+ /**
30
+ * @public
31
+ */
14
32
  export declare type AppEnableCloneCellRequest = Omit<EnableCloneCellRequest, "app_id">;
33
+ /**
34
+ * @public
35
+ */
15
36
  export declare type AppDisableCloneCellRequest = Omit<DisableCloneCellRequest, "app_id">;
37
+ /**
38
+ * @public
39
+ */
16
40
  export interface AppAgentEvents {
17
41
  signal: AppSignal;
18
42
  }
43
+ /**
44
+ * @public
45
+ */
19
46
  export interface AppAgentClient {
20
47
  callZome(args: AppAgentCallZomeRequest, timeout?: number): Promise<any>;
21
48
  on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map