@holochain/client 0.17.0-dev.6 → 0.17.0-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/api/app/types.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppAgentNetwor
|
|
|
14
14
|
export declare class AppAgentWebsocket implements AppAgentClient {
|
|
15
15
|
readonly appWebsocket: AppWebsocket;
|
|
16
16
|
installedAppId: InstalledAppId;
|
|
17
|
-
cachedAppInfo?: AppInfo;
|
|
17
|
+
cachedAppInfo?: AppInfo | null;
|
|
18
18
|
myPubKey: AgentPubKey;
|
|
19
19
|
readonly emitter: Emittery<AppAgentEvents>;
|
|
20
20
|
private constructor();
|
|
@@ -3,7 +3,7 @@ import { omit } from "lodash-es";
|
|
|
3
3
|
import { getLauncherEnvironment } from "../../environments/launcher.js";
|
|
4
4
|
import { CellType } from "../admin/types.js";
|
|
5
5
|
import { AppWebsocket } from "../app/websocket.js";
|
|
6
|
-
import { getBaseRoleNameFromCloneId, isCloneId, } from "../common.js";
|
|
6
|
+
import { HolochainError, getBaseRoleNameFromCloneId, isCloneId, } from "../common.js";
|
|
7
7
|
/**
|
|
8
8
|
* A class to establish a websocket connection to an App interface, for a
|
|
9
9
|
* specific agent and app.
|
|
@@ -18,6 +18,7 @@ export class AppAgentWebsocket {
|
|
|
18
18
|
emitter;
|
|
19
19
|
constructor(appWebsocket, installedAppId, myPubKey) {
|
|
20
20
|
this.appWebsocket = appWebsocket;
|
|
21
|
+
this.cachedAppInfo = null;
|
|
21
22
|
this.emitter = new Emittery();
|
|
22
23
|
// Ensure all super methods are bound to this instance because Emittery relies on `this` being the instance.
|
|
23
24
|
// Please retain until the upstream is fixed https://github.com/sindresorhus/emittery/issues/86.
|
|
@@ -46,6 +47,9 @@ export class AppAgentWebsocket {
|
|
|
46
47
|
const appInfo = await this.appWebsocket.appInfo({
|
|
47
48
|
installed_app_id: this.installedAppId,
|
|
48
49
|
});
|
|
50
|
+
if (!appInfo) {
|
|
51
|
+
throw new HolochainError("AppNotFound", `App info not found for the provided id "${this.installedAppId}". App needs to be installed and enabled.`);
|
|
52
|
+
}
|
|
49
53
|
this.cachedAppInfo = appInfo;
|
|
50
54
|
return appInfo;
|
|
51
55
|
}
|
|
@@ -58,9 +62,10 @@ export class AppAgentWebsocket {
|
|
|
58
62
|
*/
|
|
59
63
|
static async connect(installed_app_id, options = {}) {
|
|
60
64
|
const appWebsocket = await AppWebsocket.connect(options);
|
|
61
|
-
const appInfo = await appWebsocket.appInfo({
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
const appInfo = await appWebsocket.appInfo({ installed_app_id });
|
|
66
|
+
if (!appInfo) {
|
|
67
|
+
throw new HolochainError("AppNotFound", `App info not found for the provided id "${installed_app_id}". App needs to be installed and enabled.`);
|
|
68
|
+
}
|
|
64
69
|
const appAgentWs = new AppAgentWebsocket(appWebsocket, installed_app_id, appInfo.agent_pub_key);
|
|
65
70
|
appAgentWs.cachedAppInfo = appInfo;
|
|
66
71
|
return appAgentWs;
|
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/client",
|
|
3
|
-
"version": "0.17.0-dev.
|
|
3
|
+
"version": "0.17.0-dev.7",
|
|
4
4
|
"description": "A JavaScript client for the Holochain Conductor API",
|
|
5
5
|
"author": "Holochain Foundation <info@holochain.org> (http://holochain.org)",
|
|
6
6
|
"license": "CAL-1.0",
|
|
@@ -71,4 +71,4 @@
|
|
|
71
71
|
"ts-node": "^10.9.1",
|
|
72
72
|
"typescript": "^4.9.5"
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}
|