@holochain/client 0.3.0 → 0.3.4

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 (81) hide show
  1. package/README.md +14 -15
  2. package/lib/api/admin/index.d.ts +2 -0
  3. package/lib/api/admin/index.js +3 -0
  4. package/lib/api/admin/index.js.map +1 -0
  5. package/lib/api/{admin.d.ts → admin/types.d.ts} +71 -4
  6. package/lib/api/{admin.js → admin/types.js} +3 -6
  7. package/lib/api/admin/types.js.map +1 -0
  8. package/lib/{websocket/admin.d.ts → api/admin/websocket.d.ts} +3 -3
  9. package/lib/api/admin/websocket.js +107 -0
  10. package/lib/api/admin/websocket.js.map +1 -0
  11. package/lib/api/app/index.d.ts +2 -0
  12. package/lib/api/app/index.js +3 -0
  13. package/lib/api/app/index.js.map +1 -0
  14. package/lib/api/{app.d.ts → app/types.d.ts} +4 -4
  15. package/lib/api/app/types.js +2 -0
  16. package/lib/api/app/types.js.map +1 -0
  17. package/lib/{websocket/app.d.ts → api/app/websocket.d.ts} +6 -5
  18. package/lib/{websocket/app.js → api/app/websocket.js} +19 -20
  19. package/lib/api/app/websocket.js.map +1 -0
  20. package/lib/{websocket → api}/client.d.ts +2 -2
  21. package/lib/{websocket → api}/client.js +23 -26
  22. package/lib/api/client.js.map +1 -0
  23. package/lib/api/common.d.ts +9 -6
  24. package/lib/api/common.js +26 -6
  25. package/lib/api/common.js.map +1 -1
  26. package/lib/api/index.d.ts +2 -0
  27. package/lib/api/index.js +3 -0
  28. package/lib/api/index.js.map +1 -0
  29. package/lib/bundle.d.ts +6 -0
  30. package/lib/bundle.js +32 -0
  31. package/lib/bundle.js.map +1 -0
  32. package/lib/environments/launcher.d.ts +1 -1
  33. package/lib/environments/launcher.js +7 -12
  34. package/lib/environments/launcher.js.map +1 -1
  35. package/lib/{types → hdk}/capabilities.d.ts +1 -1
  36. package/lib/hdk/capabilities.js +2 -0
  37. package/lib/{types → hdk}/capabilities.js.map +1 -1
  38. package/lib/{types → hdk}/dht-ops.d.ts +3 -3
  39. package/lib/{types → hdk}/dht-ops.js +6 -13
  40. package/lib/hdk/dht-ops.js.map +1 -0
  41. package/lib/{types → hdk}/entry.d.ts +2 -2
  42. package/lib/hdk/entry.js +2 -0
  43. package/lib/{types → hdk}/entry.js.map +1 -1
  44. package/lib/{types → hdk}/header.d.ts +2 -3
  45. package/lib/{types → hdk}/header.js +2 -5
  46. package/lib/hdk/header.js.map +1 -0
  47. package/lib/hdk/index.d.ts +4 -0
  48. package/lib/hdk/index.js +5 -0
  49. package/lib/hdk/index.js.map +1 -0
  50. package/lib/index.d.ts +4 -5
  51. package/lib/index.js +4 -17
  52. package/lib/index.js.map +1 -1
  53. package/lib/{types/common.d.ts → types.d.ts} +0 -0
  54. package/lib/types.js +2 -0
  55. package/lib/types.js.map +1 -0
  56. package/package.json +29 -21
  57. package/lib/api/admin.js.map +0 -1
  58. package/lib/api/app.js +0 -3
  59. package/lib/api/app.js.map +0 -1
  60. package/lib/api/state-dump.d.ts +0 -36
  61. package/lib/api/state-dump.js +0 -3
  62. package/lib/api/state-dump.js.map +0 -1
  63. package/lib/api/types.d.ts +0 -39
  64. package/lib/api/types.js +0 -8
  65. package/lib/api/types.js.map +0 -1
  66. package/lib/types/capabilities.js +0 -3
  67. package/lib/types/common.js +0 -3
  68. package/lib/types/common.js.map +0 -1
  69. package/lib/types/dht-ops.js.map +0 -1
  70. package/lib/types/entry.js +0 -3
  71. package/lib/types/header.js.map +0 -1
  72. package/lib/types/index.d.ts +0 -5
  73. package/lib/types/index.js +0 -18
  74. package/lib/types/index.js.map +0 -1
  75. package/lib/websocket/admin.js +0 -127
  76. package/lib/websocket/admin.js.map +0 -1
  77. package/lib/websocket/app.js.map +0 -1
  78. package/lib/websocket/client.js.map +0 -1
  79. package/lib/websocket/common.d.ts +0 -3
  80. package/lib/websocket/common.js +0 -34
  81. package/lib/websocket/common.js.map +0 -1
package/README.md CHANGED
@@ -1,16 +1,14 @@
1
- # holochain-client-js
2
-
3
- [![Project](https://img.shields.io/badge/project-holochain-blue.svg?style=flat-square)](http://holochain.org/)
4
- [![Forum](https://img.shields.io/badge/chat-forum%2eholochain%2enet-blue.svg?style=flat-square)](https://forum.holochain.org)
5
-
1
+ [![Project](https://img.shields.io/badge/Project-Holochain-blue.svg?style=flat-square)](http://holochain.org/)
2
+ [![Forum](https://img.shields.io/badge/Forum-forum%2eholochain%2enet-blue.svg?style=flat-square)](https://forum.holochain.org)
3
+ [![License: CAL 1.0](https://img.shields.io/badge/License-CAL%201.0-blue.svg)](https://github.com/holochain/cryptographic-autonomy-license)
4
+ ![Test](https://github.com/holochain/holochain-client-js/actions/workflows/test.yml/badge.svg?branch=main)
6
5
  [![Twitter Follow](https://img.shields.io/twitter/follow/holochain.svg?style=social&label=Follow)](https://twitter.com/holochain)
7
- License: [![License: CAL 1.0](https://img.shields.io/badge/License-CAL%201.0-blue.svg)](https://github.com/holochain/cryptographic-autonomy-license)
8
6
 
9
- A Nodejs client for the Holochain Conductor API
7
+ # Holochain Client - JavaScript
10
8
 
11
- # Conductor API documentation
9
+ A JavaScript client for the Holochain Conductor API (works with browsers as well as Nodejs).
12
10
 
13
- Holochain's Conductor API is under active development. This client package tracks that development fairly closely but sometimes gets behind.
11
+ > Holochain's Conductor API is under active development. This client package tracks that development fairly closely but sometimes gets behind.
14
12
 
15
13
  ## Installation
16
14
 
@@ -58,11 +56,10 @@ See [docs/API.md](docs/API.md)
58
56
 
59
57
  # Holochain Compatibility
60
58
 
61
- This version of `@holochain/client` is currently working with
62
- - `holochain/holochain` at tag [holochain-0.0.121][https://github.com/holochain/holochain/tree/holochain-0.0.121)
63
- - hdk version [0.0.117 from crates.io](https://crates.io/crates/hdk/0.0.117)
59
+ See [default.nix](./default.nix) for the Holochain version this package is compatible with.
64
60
 
65
- If updating this code, please make changes to the git `rev/sha` above. (You can get this from `hn-introspect` after updating the holonix-hash)
61
+ If updating the Holochain version included in holonix, please use `niv update` as explained in the
62
+ [Holochain Installation Guide](https://developer.holochain.org/install/#upgrading-the-holochain-version).
66
63
 
67
64
  ## Running tests
68
65
 
@@ -77,16 +74,18 @@ nix-shell
77
74
  ```
78
75
 
79
76
  ## Contribute
77
+
80
78
  Holochain is an open source project. We welcome all sorts of participation and are actively working on increasing surface area to accept it. Please see our [contribution guidelines](/CONTRIBUTING.md) for our general practices and protocols on participating in the community, as well as specific expectations around things like code formatting, testing practices, continuous integration, etc.
81
79
 
82
80
  * Connect with us on our [forum](https://forum.holochain.org)
83
81
 
84
82
  ## License
83
+
85
84
  [![License: CAL 1.0](https://img.shields.io/badge/License-CAL%201.0-blue.svg)](https://github.com/holochain/cryptographic-autonomy-license)
86
85
 
87
- Copyright (C) 2020-2021, Holochain Foundation
86
+ Copyright (C) 2020-2022, Holochain Foundation
88
87
 
89
88
  This program is free software: you can redistribute it and/or modify it under the terms of the license
90
89
  provided in the LICENSE file (CAL-1.0). This program is distributed in the hope that it will be useful,
91
90
  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
92
- PURPOSE.
91
+ PURPOSE.
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ export * from "./websocket.js";
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export * from "./websocket.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/admin/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
@@ -1,8 +1,7 @@
1
1
  /// <reference types="node" />
2
- import { Requester } from "./common";
3
- import { HoloHash, AgentPubKey, DnaProperties, InstalledAppId, CellId, RoleId } from "../types/common";
4
- import { InstalledAppInfo, MembraneProof } from "./types";
5
- import { FullStateDump } from "./state-dump";
2
+ import { AgentPubKey, CellId, DnaHash, DnaProperties, HeaderHash, HoloHash, InstalledAppId, InstalledCell, KitsuneAgent, KitsuneSpace, RoleId, Signature } from "../../types.js";
3
+ import { DhtOp, Entry, Header } from "../../hdk/index.js";
4
+ import { Requester } from "../common.js";
6
5
  export declare type AttachAppInterfaceRequest = {
7
6
  port: number;
8
7
  };
@@ -22,6 +21,42 @@ export declare type EnableAppResponse = {
22
21
  app: InstalledAppInfo;
23
22
  errors: Array<[CellId, string]>;
24
23
  };
24
+ export declare type DeactivationReason = {
25
+ never_activated: null;
26
+ } | {
27
+ normal: null;
28
+ } | {
29
+ quarantined: {
30
+ error: string;
31
+ };
32
+ };
33
+ export declare type PausedAppReason = {
34
+ error: string;
35
+ };
36
+ export declare type DisabledAppReason = {
37
+ never_started: null;
38
+ } | {
39
+ user: null;
40
+ } | {
41
+ error: string;
42
+ };
43
+ export declare type InstalledAppInfoStatus = {
44
+ paused: {
45
+ reason: PausedAppReason;
46
+ };
47
+ } | {
48
+ disabled: {
49
+ reason: DisabledAppReason;
50
+ };
51
+ } | {
52
+ running: null;
53
+ };
54
+ export declare type InstalledAppInfo = {
55
+ installed_app_id: InstalledAppId;
56
+ cell_data: Array<InstalledCell>;
57
+ status: InstalledAppInfoStatus;
58
+ };
59
+ export declare type MembraneProof = Buffer;
25
60
  export declare type DisableAppRequest = {
26
61
  installed_app_id: InstalledAppId;
27
62
  };
@@ -222,3 +257,35 @@ export declare type Zomes = Array<[string, {
222
257
  export declare type WasmCode = [HoloHash, {
223
258
  code: Array<number>;
224
259
  }];
260
+ export interface AgentInfoDump {
261
+ kitsune_agent: KitsuneAgent;
262
+ kitsune_space: KitsuneSpace;
263
+ dump: string;
264
+ }
265
+ export interface P2pAgentsDump {
266
+ this_agent_info: AgentInfoDump | undefined;
267
+ this_dna: [DnaHash, KitsuneSpace] | undefined;
268
+ this_agent: [AgentPubKey, KitsuneAgent] | undefined;
269
+ peers: Array<AgentInfoDump>;
270
+ }
271
+ export interface FullIntegrationStateDump {
272
+ validation_limbo: Array<DhtOp>;
273
+ integration_limbo: Array<DhtOp>;
274
+ integrated: Array<DhtOp>;
275
+ dht_ops_cursor: number;
276
+ }
277
+ export interface SourceChainJsonElement {
278
+ signature: Signature;
279
+ header_address: HeaderHash;
280
+ header: Header;
281
+ entry: Entry | undefined;
282
+ }
283
+ export interface SourceChainJsonDump {
284
+ elements: Array<SourceChainJsonElement>;
285
+ published_ops_count: number;
286
+ }
287
+ export interface FullStateDump {
288
+ peer_dump: P2pAgentsDump;
289
+ source_chain_dump: SourceChainJsonDump;
290
+ integration_dump: FullIntegrationStateDump;
291
+ }
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppStatusFilter = void 0;
4
- var AppStatusFilter;
1
+ export var AppStatusFilter;
5
2
  (function (AppStatusFilter) {
6
3
  AppStatusFilter["Enabled"] = "enabled";
7
4
  AppStatusFilter["Disabled"] = "disabled";
8
5
  AppStatusFilter["Running"] = "running";
9
6
  AppStatusFilter["Stopped"] = "stopped";
10
7
  AppStatusFilter["Paused"] = "paused";
11
- })(AppStatusFilter = exports.AppStatusFilter || (exports.AppStatusFilter = {}));
12
- //# sourceMappingURL=admin.js.map
8
+ })(AppStatusFilter || (AppStatusFilter = {}));
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/admin/types.ts"],"names":[],"mappings":"AAgOA,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,wCAAqB,CAAA;IACrB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;AACnB,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B"}
@@ -14,9 +14,9 @@
14
14
  * console.error('problem generating agent:', err)
15
15
  * })
16
16
  */
17
- import * as Api from '../api/admin';
18
- import { WsClient } from './client';
19
- import { Transformer, Requester } from '../api/common';
17
+ import * as Api from "./types.js";
18
+ import { WsClient } from "../client.js";
19
+ import { Transformer, Requester } from "../common.js";
20
20
  export declare class AdminWebsocket implements Api.AdminApi {
21
21
  client: WsClient;
22
22
  defaultTimeout: number;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Defines AdminWebsocket, an easy-to-use websocket implementation of the
3
+ * Conductor Admin API
4
+ *
5
+ * const client = AdminWebsocket.connect(
6
+ * 'ws://localhost:9000'
7
+ * )
8
+ *
9
+ * client.generateAgentPubKey()
10
+ * .then(agentPubKey => {
11
+ * console.log('Agent successfully generated:', agentPubKey)
12
+ * })
13
+ * .catch(err => {
14
+ * console.error('problem generating agent:', err)
15
+ * })
16
+ */
17
+ import * as Api from "./types.js";
18
+ import { WsClient } from "../client.js";
19
+ import { catchError, promiseTimeout, DEFAULT_TIMEOUT } from "../common.js";
20
+ import { requesterTransformer } from "../common.js";
21
+ import { getLauncherEnvironment } from "../../environments/launcher.js";
22
+ export class AdminWebsocket {
23
+ client;
24
+ defaultTimeout;
25
+ constructor(client, defaultTimeout) {
26
+ this.client = client;
27
+ this.defaultTimeout =
28
+ defaultTimeout === undefined ? DEFAULT_TIMEOUT : defaultTimeout;
29
+ }
30
+ static async connect(url, defaultTimeout) {
31
+ // Check if we are in the launcher's environment, and if so, redirect the url to connect to
32
+ const env = await getLauncherEnvironment();
33
+ if (env) {
34
+ url = `ws://localhost:${env.ADMIN_INTERFACE_PORT}`;
35
+ }
36
+ const wsClient = await WsClient.connect(url);
37
+ return new AdminWebsocket(wsClient, defaultTimeout);
38
+ }
39
+ _requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
40
+ // the specific request/response types come from the Interface
41
+ // which this class implements
42
+ attachAppInterface = this._requester("attach_app_interface");
43
+ // Deprecated
44
+ activateApp = this._requester("activate_app");
45
+ // Deprecated
46
+ deactivateApp = this._requester("deactivate_app");
47
+ enableApp = this._requester("enable_app");
48
+ disableApp = this._requester("disable_app");
49
+ startApp = this._requester("start_app");
50
+ dumpState = this._requester("dump_state", dumpStateTransform);
51
+ dumpFullState = this._requester("dump_full_state");
52
+ generateAgentPubKey = this._requester("generate_agent_pub_key");
53
+ registerDna = this._requester("register_dna");
54
+ installApp = this._requester("install_app");
55
+ uninstallApp = this._requester("uninstall_app");
56
+ installAppBundle = this._requester("install_app_bundle");
57
+ createCloneCell = this._requester("create_clone_cell");
58
+ listDnas = this._requester("list_dnas");
59
+ listCellIds = this._requester("list_cell_ids");
60
+ // Deprecated
61
+ listActiveApps = this._requester("list_active_apps");
62
+ listApps = this._requester("list_apps", listAppsTransform);
63
+ listAppInterfaces = this._requester("list_app_interfaces");
64
+ requestAgentInfo = this._requester("request_agent_info");
65
+ addAgentInfo = this._requester("add_agent_info");
66
+ }
67
+ const listAppsTransform = {
68
+ input: (req) => {
69
+ const args = {};
70
+ if (req.status_filter) {
71
+ args.status_filter = getAppStatusInApiForm(req.status_filter);
72
+ }
73
+ return args;
74
+ },
75
+ output: (res) => res,
76
+ };
77
+ const dumpStateTransform = {
78
+ input: (req) => req,
79
+ output: (res) => {
80
+ return JSON.parse(res);
81
+ },
82
+ };
83
+ function getAppStatusInApiForm(status_filter) {
84
+ switch (status_filter) {
85
+ case Api.AppStatusFilter.Running:
86
+ return {
87
+ Running: null,
88
+ };
89
+ case Api.AppStatusFilter.Enabled:
90
+ return {
91
+ Enabled: null,
92
+ };
93
+ case Api.AppStatusFilter.Paused:
94
+ return {
95
+ Paused: null,
96
+ };
97
+ case Api.AppStatusFilter.Disabled:
98
+ return {
99
+ Disabled: null,
100
+ };
101
+ case Api.AppStatusFilter.Stopped:
102
+ return {
103
+ Stopped: null,
104
+ };
105
+ }
106
+ }
107
+ //# sourceMappingURL=websocket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/admin/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM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AAC,gBAAgB,CAAC,CAAC;CACrC;AAWD,MAAM,iBAAiB,GAKnB;IACF,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,IAAI,GAA4B,EAAE,CAAC;QAEzC,IAAI,GAAG,CAAC,aAAa,EAAE;YACrB,IAAI,CAAC,aAAa,GAAG,qBAAqB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;SAC/D;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;CACrB,CAAC;AAEF,MAAM,kBAAkB,GAKpB;IACF,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;IACnB,MAAM,EAAE,CAAC,GAAW,EAAyB,EAAE;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF,CAAC;AAEF,SAAS,qBAAqB,CAAC,aAAkC;IAC/D,QAAQ,aAAa,EAAE;QACrB,KAAK,GAAG,CAAC,eAAe,CAAC,OAAO;YAC9B,OAAO;gBACL,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,KAAK,GAAG,CAAC,eAAe,CAAC,OAAO;YAC9B,OAAO;gBACL,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,KAAK,GAAG,CAAC,eAAe,CAAC,MAAM;YAC7B,OAAO;gBACL,MAAM,EAAE,IAAI;aACb,CAAC;QACJ,KAAK,GAAG,CAAC,eAAe,CAAC,QAAQ;YAC/B,OAAO;gBACL,QAAQ,EAAE,IAAI;aACf,CAAC;QACJ,KAAK,GAAG,CAAC,eAAe,CAAC,OAAO;YAC9B,OAAO;gBACL,OAAO,EAAE,IAAI;aACd,CAAC;KACL;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ export * from "./websocket.js";
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export * from "./websocket.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/app/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
@@ -1,7 +1,7 @@
1
- import { Requester } from "./common";
2
- import { CellId, AgentPubKey, InstalledAppId } from "../types/common";
3
- import { InstalledAppInfo } from "./types";
4
- import { CapSecret } from "../types/capabilities";
1
+ import { CapSecret } from "../../hdk/capabilities.js";
2
+ import { AgentPubKey, CellId, InstalledAppId } from "../../types.js";
3
+ import { Requester } from "../common.js";
4
+ import { InstalledAppInfo } from "../admin/index.js";
5
5
  export declare type CallZomeRequestGeneric<Payload> = {
6
6
  cap_secret: CapSecret | null;
7
7
  cell_id: CellId;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/app/types.ts"],"names":[],"mappings":""}
@@ -1,11 +1,12 @@
1
- import { AppApi, AppInfoRequest, AppInfoResponse, CallZomeRequestGeneric, CallZomeResponseGeneric, AppSignalCb } from '../api/app';
2
- import { WsClient } from './client';
3
- import { Transformer, Requester } from '../api/common';
1
+ import { InstalledAppId } from "../../types.js";
2
+ import { WsClient } from "../client.js";
3
+ import { Requester, Transformer } from "../common.js";
4
+ import { AppApi, AppInfoRequest, AppInfoResponse, AppSignalCb, CallZomeRequestGeneric, CallZomeResponseGeneric } from "./types.js";
4
5
  export declare class AppWebsocket implements AppApi {
5
- protected overrideInstalledAppId?: string | undefined;
6
6
  client: WsClient;
7
7
  defaultTimeout: number;
8
- constructor(client: WsClient, defaultTimeout?: number, overrideInstalledAppId?: string | undefined);
8
+ protected overrideInstalledAppId?: InstalledAppId;
9
+ constructor(client: WsClient, defaultTimeout?: number, overrideInstalledAppId?: InstalledAppId);
9
10
  static connect(url: string, defaultTimeout?: number, signalCb?: AppSignalCb): Promise<AppWebsocket>;
10
11
  _requester: <ReqO, ReqI, ResI, ResO>(tag: string, transformer?: Transformer<ReqO, ReqI, ResI, ResO> | undefined) => (req: ReqO, timeout?: number | undefined) => Promise<ResO>;
11
12
  appInfo: Requester<AppInfoRequest, AppInfoResponse>;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppWebsocket = void 0;
4
1
  /**
5
2
  * Defines AppWebsocket, an easy-to-use websocket implementation of the
6
3
  * Conductor API for apps
@@ -18,40 +15,42 @@ exports.AppWebsocket = void 0;
18
15
  * console.error('problem installing DNA:', err)
19
16
  * })
20
17
  */
21
- const msgpack_1 = require("@msgpack/msgpack");
22
- const client_1 = require("./client");
23
- const common_1 = require("./common");
24
- const common_2 = require("../api/common");
25
- const launcher_1 = require("../environments/launcher");
26
- class AppWebsocket {
18
+ import { decode, encode } from "@msgpack/msgpack";
19
+ import { getLauncherEnvironment } from "../../environments/launcher.js";
20
+ import { WsClient } from "../client.js";
21
+ import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, } from "../common.js";
22
+ export class AppWebsocket {
23
+ client;
24
+ defaultTimeout;
25
+ overrideInstalledAppId;
27
26
  constructor(client, defaultTimeout, overrideInstalledAppId) {
28
- this.overrideInstalledAppId = overrideInstalledAppId;
29
- this._requester = (tag, transformer) => (0, common_2.requesterTransformer)((req, timeout) => (0, common_1.promiseTimeout)(this.client.request(req), tag, timeout || this.defaultTimeout).then(common_1.catchError), tag, transformer);
30
- this.appInfo = this._requester('app_info', appInfoTransform(this.overrideInstalledAppId));
31
- this.callZome = this._requester('zome_call', callZomeTransform);
32
27
  this.client = client;
33
- this.defaultTimeout = defaultTimeout === undefined ? common_1.DEFAULT_TIMEOUT : defaultTimeout;
28
+ this.defaultTimeout =
29
+ defaultTimeout === undefined ? DEFAULT_TIMEOUT : defaultTimeout;
30
+ this.overrideInstalledAppId = overrideInstalledAppId;
34
31
  }
35
32
  static async connect(url, defaultTimeout, signalCb) {
36
33
  // Check if we are in the launcher's environment, and if so, redirect the url to connect to
37
- const env = await (0, launcher_1.getLauncherEnvironment)();
34
+ const env = await getLauncherEnvironment();
38
35
  if (env) {
39
36
  url = `ws://localhost:${env.APP_INTERFACE_PORT}`;
40
37
  }
41
- const wsClient = await client_1.WsClient.connect(url, signalCb);
38
+ const wsClient = await WsClient.connect(url, signalCb);
42
39
  return new AppWebsocket(wsClient, defaultTimeout, env ? env.INSTALLED_APP_ID : undefined);
43
40
  }
41
+ _requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
42
+ appInfo = this._requester("app_info", appInfoTransform(this.overrideInstalledAppId));
43
+ callZome = this._requester("zome_call", callZomeTransform);
44
44
  }
45
- exports.AppWebsocket = AppWebsocket;
46
45
  const callZomeTransform = {
47
46
  input: (req) => {
48
47
  return {
49
48
  ...req,
50
- payload: (0, msgpack_1.encode)(req.payload),
49
+ payload: encode(req.payload),
51
50
  };
52
51
  },
53
52
  output: (res) => {
54
- return (0, msgpack_1.decode)(res);
53
+ return decode(res);
55
54
  },
56
55
  };
57
56
  const appInfoTransform = (overrideInstalledAppId) => ({
@@ -67,4 +66,4 @@ const appInfoTransform = (overrideInstalledAppId) => ({
67
66
  return res;
68
67
  },
69
68
  });
70
- //# sourceMappingURL=app.js.map
69
+ //# sourceMappingURL=websocket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EAEd,oBAAoB,GAErB,MAAM,cAAc,CAAC;AA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C,WAAW,EAAE,iBAAiB,CAAC,CAAC;CACrD;AAED,MAAM,iBAAiB,GAKnB;IACF,KAAK,EAAE,CACL,GAAgC,EACI,EAAE;QACtC,OAAO;YACL,GAAG,GAAG;YACN,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;SAC7B,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,CACN,GAAwC,EACV,EAAE;QAChC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;CACF,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACvB,sBAAuC,EAMvC,EAAE,CAAC,CAAC;IACJ,KAAK,EAAE,CAAC,GAAmB,EAAkB,EAAE;QAC7C,IAAI,sBAAsB,EAAE;YAC1B,OAAO;gBACL,gBAAgB,EAAE,sBAAsB;aACzC,CAAC;SACH;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,EAAE,CAAC,GAAoB,EAAmB,EAAE;QAChD,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
- import Websocket from "isomorphic-ws";
2
1
  import { decode } from "@msgpack/msgpack";
3
- import { AppSignalCb } from "../api/app";
2
+ import Websocket from "isomorphic-ws";
3
+ import { AppSignalCb } from "./app/types.js";
4
4
  /**
5
5
  * A Websocket client which can make requests and receive responses,
6
6
  * as well as send and receive signals
@@ -1,18 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.WsClient = void 0;
7
- const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
8
- const msgpack_1 = require("@msgpack/msgpack");
1
+ import { decode, encode } from "@msgpack/msgpack";
2
+ import Websocket from "isomorphic-ws";
9
3
  /**
10
4
  * A Websocket client which can make requests and receive responses,
11
5
  * as well as send and receive signals
12
6
  *
13
7
  * Uses Holochain's websocket WireMessage for communication.
14
8
  */
15
- class WsClient {
9
+ export class WsClient {
10
+ socket;
11
+ pendingRequests;
12
+ index;
13
+ alreadyWarnedNoSignalCb;
16
14
  constructor(socket, signalCb) {
17
15
  this.socket = socket;
18
16
  this.pendingRequests = {};
@@ -25,10 +23,10 @@ class WsClient {
25
23
  if (typeof Buffer === "undefined" || !Buffer.isBuffer(data)) {
26
24
  data = await data.arrayBuffer();
27
25
  }
28
- const msg = (0, msgpack_1.decode)(data);
26
+ const msg = decode(data);
29
27
  if (msg.type === "Signal") {
30
28
  if (signalCb) {
31
- const decodedMessage = (0, msgpack_1.decode)(msg.data);
29
+ const decodedMessage = decode(msg.data);
32
30
  if (!decodedMessage.App) {
33
31
  // We have received a system signal, do nothing
34
32
  return;
@@ -47,11 +45,11 @@ class WsClient {
47
45
  }
48
46
  else {
49
47
  if (!this.alreadyWarnedNoSignalCb)
50
- console.log('Received signal but no signal callback was set in constructor');
48
+ console.log("Received signal but no signal callback was set in constructor");
51
49
  this.alreadyWarnedNoSignalCb = true;
52
50
  }
53
51
  }
54
- else if (msg.type === 'Response') {
52
+ else if (msg.type === "Response") {
55
53
  this.handleResponse(msg);
56
54
  }
57
55
  else {
@@ -60,19 +58,19 @@ class WsClient {
60
58
  };
61
59
  }
62
60
  emitSignal(data) {
63
- const encodedMsg = (0, msgpack_1.encode)({
64
- type: 'Signal',
65
- data: (0, msgpack_1.encode)(data),
61
+ const encodedMsg = encode({
62
+ type: "Signal",
63
+ data: encode(data),
66
64
  });
67
65
  this.socket.send(encodedMsg);
68
66
  }
69
67
  request(data) {
70
68
  const id = this.index;
71
69
  this.index += 1;
72
- const encodedMsg = (0, msgpack_1.encode)({
70
+ const encodedMsg = encode({
73
71
  id,
74
- type: 'Request',
75
- data: (0, msgpack_1.encode)(data),
72
+ type: "Request",
73
+ data: encode(data),
76
74
  });
77
75
  const promise = new Promise((fulfill, reject) => {
78
76
  this.pendingRequests[id] = { fulfill, reject };
@@ -81,7 +79,7 @@ class WsClient {
81
79
  this.socket.send(encodedMsg);
82
80
  }
83
81
  else {
84
- return Promise.reject(new Error('Socket is not open'));
82
+ return Promise.reject(new Error("Socket is not open"));
85
83
  }
86
84
  return promise;
87
85
  }
@@ -90,10 +88,10 @@ class WsClient {
90
88
  if (this.pendingRequests[id]) {
91
89
  // resolve response
92
90
  if (msg.data === null || msg.data === undefined) {
93
- this.pendingRequests[id].reject(new Error('Response canceled by responder'));
91
+ this.pendingRequests[id].reject(new Error("Response canceled by responder"));
94
92
  }
95
93
  else {
96
- this.pendingRequests[id].fulfill((0, msgpack_1.decode)(msg.data));
94
+ this.pendingRequests[id].fulfill(decode(msg.data));
97
95
  }
98
96
  }
99
97
  else {
@@ -105,11 +103,11 @@ class WsClient {
105
103
  return this.awaitClose();
106
104
  }
107
105
  awaitClose() {
108
- return new Promise((resolve) => this.socket.on('close', resolve));
106
+ return new Promise((resolve) => this.socket.on("close", resolve));
109
107
  }
110
108
  static connect(url, signalCb) {
111
109
  return new Promise((resolve, reject) => {
112
- const socket = new isomorphic_ws_1.default(url);
110
+ const socket = new Websocket(url);
113
111
  // make sure that there are no uncaught connection
114
112
  // errors because that causes nodejs thread to crash
115
113
  // with uncaught exception
@@ -122,8 +120,7 @@ class WsClient {
122
120
  });
123
121
  }
124
122
  }
125
- exports.WsClient = WsClient;
126
123
  const signalTransform = (res) => {
127
- return (0, msgpack_1.decode)(res);
124
+ return decode(res);
128
125
  };
129
126
  //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,SAAS,MAAM,eAAe,CAAC;AAGtC;;;;;GAKG;AACH,MAAM,OAAO,QAAQ;IACnB,MAAM,CAAY;IAClB,eAAe,CAMb;IACF,KAAK,CAAS;IACd,uBAAuB,CAAU;IAEjC,YAAY,MAAW,EAAE,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C,IAAI,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,eAAe,GAAG,CACtB,GAAkC,EACN,EAAE;IAC9B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC,CAAC"}
@@ -1,9 +1,4 @@
1
- /**
2
- * Take a Requester function which deals with tagged requests and responses,
3
- * and return a Requester which deals only with the inner data types, also
4
- * with the optional Transformer applied to further modify the input and output.
5
- */
6
- export declare const requesterTransformer: <ReqO, ReqI, ResI, ResO>(requester: Requester<Tagged<ReqI>, Tagged<ResI>>, tag: string, transform?: Transformer<ReqO, ReqI, ResI, ResO>) => (req: ReqO, timeout?: number | undefined) => Promise<ResO>;
1
+ export declare const DEFAULT_TIMEOUT = 15000;
7
2
  export declare type Transformer<ReqO, ReqI, ResI, ResO> = {
8
3
  input: (req: ReqO) => ReqI;
9
4
  output: (res: ResI) => ResO;
@@ -14,3 +9,11 @@ export declare type Tagged<T> = {
14
9
  type: string;
15
10
  data: T;
16
11
  };
12
+ /**
13
+ * Take a Requester function which deals with tagged requests and responses,
14
+ * and return a Requester which deals only with the inner data types, also
15
+ * with the optional Transformer applied to further modify the input and output.
16
+ */
17
+ export declare const requesterTransformer: <ReqO, ReqI, ResI, ResO>(requester: Requester<Tagged<ReqI>, Tagged<ResI>>, tag: string, transform?: Transformer<ReqO, ReqI, ResI, ResO>) => (req: ReqO, timeout?: number) => Promise<ResO>;
18
+ export declare const catchError: (res: any) => Promise<any>;
19
+ export declare const promiseTimeout: (promise: Promise<any>, tag: string, ms: number) => Promise<unknown>;