@holochain/client 0.10.2 → 0.10.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.
- package/lib/api/admin/types.d.ts +1 -2
- package/lib/api/app-agent/types.d.ts +11 -7
- package/lib/api/app-agent/websocket.d.ts +5 -3
- package/lib/api/app-agent/websocket.js +12 -7
- package/lib/api/app-agent/websocket.js.map +1 -1
- package/lib/environments/launcher.d.ts +2 -2
- package/lib/environments/launcher.js +4 -37
- package/lib/environments/launcher.js.map +1 -1
- package/package.json +3 -4
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -219,11 +219,10 @@ export interface DeleteArchivedCloneCellsRequest {
|
|
|
219
219
|
role_name: RoleName;
|
|
220
220
|
}
|
|
221
221
|
export declare type DeleteArchivedCloneCellsResponse = void;
|
|
222
|
-
export interface
|
|
222
|
+
export interface GrantZomeCallCapabilityRequest {
|
|
223
223
|
cell_id: CellId;
|
|
224
224
|
cap_grant: ZomeCallCapGrant;
|
|
225
225
|
}
|
|
226
|
-
export declare type GrantZomeCallCapabilityRequest = GrantZomeCallCapabilityPayload;
|
|
227
226
|
export declare type GrantZomeCallCapabilityResponse = void;
|
|
228
227
|
export interface AdminApi {
|
|
229
228
|
attachAppInterface: Requester<AttachAppInterfaceRequest, AttachAppInterfaceResponse>;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { UnsubscribeFunction } from "emittery";
|
|
2
2
|
import { ArchiveCloneCellResponse, CreateCloneCellRequest, CreateCloneCellResponse } from "..";
|
|
3
|
-
import {
|
|
4
|
-
import { CallZomeRequest, AppInfoResponse, ArchiveCloneCellRequest } from "../app";
|
|
5
|
-
export declare type
|
|
6
|
-
role_name
|
|
7
|
-
cell_id?: CellId;
|
|
3
|
+
import { RoleName } from "../..";
|
|
4
|
+
import { CallZomeRequest, AppInfoResponse, ArchiveCloneCellRequest, AppSignal } from "../app";
|
|
5
|
+
export declare type RoleNameCallZomeRequest = Omit<CallZomeRequest, "cell_id"> & {
|
|
6
|
+
role_name: RoleName;
|
|
8
7
|
};
|
|
8
|
+
export declare type AppAgentCallZomeRequest = CallZomeRequest | RoleNameCallZomeRequest;
|
|
9
9
|
export declare type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
|
|
10
10
|
export declare type AppArchiveCloneCellRequest = Omit<ArchiveCloneCellRequest, "app_id">;
|
|
11
|
-
export interface
|
|
11
|
+
export interface AppAgentEvents {
|
|
12
|
+
signal: AppSignal;
|
|
13
|
+
}
|
|
14
|
+
export interface AppAgentClient {
|
|
12
15
|
callZome(args: AppAgentCallZomeRequest, timeout?: number): Promise<any>;
|
|
16
|
+
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction;
|
|
13
17
|
appInfo(): Promise<AppInfoResponse>;
|
|
14
18
|
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
15
19
|
archiveCloneCell(args: AppArchiveCloneCellRequest): Promise<ArchiveCloneCellResponse>;
|
|
@@ -19,17 +19,19 @@
|
|
|
19
19
|
* console.error('callZome errored with:', err)
|
|
20
20
|
* })
|
|
21
21
|
*/
|
|
22
|
-
import Emittery from "emittery";
|
|
22
|
+
import Emittery, { UnsubscribeFunction } from "emittery";
|
|
23
23
|
import { InstalledAppId } from "../../types.js";
|
|
24
24
|
import { AppInfoResponse, AppWebsocket, ArchiveCloneCellResponse, CallZomeResponse, CreateCloneCellResponse, InstalledAppInfo } from "../index.js";
|
|
25
|
-
import { AppAgentCallZomeRequest, AppAgentClient, AppArchiveCloneCellRequest, AppCreateCloneCellRequest } from "./types.js";
|
|
26
|
-
export declare class AppAgentWebsocket
|
|
25
|
+
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppArchiveCloneCellRequest, AppCreateCloneCellRequest } from "./types.js";
|
|
26
|
+
export declare class AppAgentWebsocket implements AppAgentClient {
|
|
27
27
|
appWebsocket: AppWebsocket;
|
|
28
28
|
installedAppId: InstalledAppId;
|
|
29
29
|
cachedAppInfo?: InstalledAppInfo;
|
|
30
|
+
emitter: Emittery<AppAgentEvents, AppAgentEvents & import("emittery").OmnipresentEventData, never>;
|
|
30
31
|
constructor(appWebsocket: AppWebsocket, installedAppId: InstalledAppId);
|
|
31
32
|
appInfo(): Promise<AppInfoResponse>;
|
|
32
33
|
callZome(request: AppAgentCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;
|
|
33
34
|
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
34
35
|
archiveCloneCell(args: AppArchiveCloneCellRequest): Promise<ArchiveCloneCellResponse>;
|
|
36
|
+
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction;
|
|
35
37
|
}
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
* })
|
|
21
21
|
*/
|
|
22
22
|
import Emittery from "emittery";
|
|
23
|
-
import omit from "lodash
|
|
24
|
-
export class AppAgentWebsocket
|
|
23
|
+
import { omit } from "lodash-es";
|
|
24
|
+
export class AppAgentWebsocket {
|
|
25
25
|
appWebsocket;
|
|
26
26
|
installedAppId;
|
|
27
27
|
cachedAppInfo;
|
|
28
|
+
emitter = new Emittery();
|
|
28
29
|
constructor(appWebsocket, installedAppId) {
|
|
29
|
-
super();
|
|
30
30
|
this.appWebsocket = appWebsocket;
|
|
31
31
|
this.installedAppId = installedAppId;
|
|
32
|
-
this.appWebsocket.on("signal", (signal) => this.emit("signal", signal));
|
|
32
|
+
this.appWebsocket.on("signal", (signal) => this.emitter.emit("signal", signal));
|
|
33
33
|
}
|
|
34
34
|
async appInfo() {
|
|
35
35
|
const appInfo = await this.appWebsocket.appInfo({
|
|
@@ -39,11 +39,13 @@ export class AppAgentWebsocket extends Emittery {
|
|
|
39
39
|
return appInfo;
|
|
40
40
|
}
|
|
41
41
|
async callZome(request, timeout) {
|
|
42
|
-
|
|
42
|
+
const role_name = request
|
|
43
|
+
.role_name;
|
|
44
|
+
if (role_name) {
|
|
43
45
|
const appInfo = this.cachedAppInfo || (await this.appInfo());
|
|
44
|
-
const cell_id = appInfo.cell_data.find((c) => c.role_name ===
|
|
46
|
+
const cell_id = appInfo.cell_data.find((c) => c.role_name === role_name)?.cell_id;
|
|
45
47
|
if (!cell_id) {
|
|
46
|
-
throw new Error(`No cell found with role_name ${
|
|
48
|
+
throw new Error(`No cell found with role_name ${role_name}`);
|
|
47
49
|
}
|
|
48
50
|
const callZomeRequest = {
|
|
49
51
|
...omit(request, "role_name"),
|
|
@@ -72,5 +74,8 @@ export class AppAgentWebsocket extends Emittery {
|
|
|
72
74
|
...args,
|
|
73
75
|
});
|
|
74
76
|
}
|
|
77
|
+
on(eventName, listener) {
|
|
78
|
+
return this.emitter.on(eventName, listener);
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
//# sourceMappingURL=websocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app-agent/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app-agent/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,QAAiC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAqBjC,MAAM,OAAO,iBAAiB;IAC5B,YAAY,CAAe;IAC3B,cAAc,CAAiB;IAC/B,aAAa,CAAoB;IAEjC,OAAO,GAAG,IAAI,QAAQ,EAAkB,CAAC;IAEzC,YAAY,YAA0B,EAAE,cAA8B;QACpE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC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;IACH,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAA+B;QAE/B,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC;YACnD,MAAM,EAAE,IAAI,CAAC,cAAc;YAC3B,GAAG,IAAI;SACR,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAE/B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,IAAgC;QAEhC,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC;YACxC,MAAM,EAAE,IAAI,CAAC,cAAc;YAC3B,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC;IAED,EAAE,CACA,SAAiC,EACjC,QAAmE;QAEnE,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InstalledAppId } from "../types.js";
|
|
2
|
-
export declare const LAUNCHER_ENV_URL = "/.launcher-env.json";
|
|
3
2
|
export interface LauncherEnvironment {
|
|
4
3
|
APP_INTERFACE_PORT: number;
|
|
5
4
|
ADMIN_INTERFACE_PORT: number;
|
|
6
5
|
INSTALLED_APP_ID: InstalledAppId;
|
|
7
6
|
}
|
|
8
|
-
export declare
|
|
7
|
+
export declare const isLauncher: boolean;
|
|
8
|
+
export declare const getLauncherEnvironment: () => LauncherEnvironment | undefined;
|
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
async function fetchLauncherEnvironment() {
|
|
6
|
-
const env = await fetch(LAUNCHER_ENV_URL);
|
|
7
|
-
if (env.ok) {
|
|
8
|
-
const launcherEnvironment = await env.json();
|
|
9
|
-
return launcherEnvironment;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
// We are not in the launcher environment
|
|
13
|
-
if (env.status === 404) {
|
|
14
|
-
console.warn("[@holochain/conductor-api]: you are in a development environment. When this UI is run in the Holochain Launcher, `AppWebsocket.connect()`, `AdminWebsocket.connect()` and `appWebsocket.appInfo()` will have their parameters ignored and substituted by the ones provided by the Holochain Launcher.");
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
throw new Error(`Error trying to fetch the launcher environment: ${env.statusText}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const isBrowser = typeof window !== "undefined";
|
|
23
|
-
const isJest = typeof process !== "undefined" &&
|
|
24
|
-
process.env &&
|
|
25
|
-
process.env.JEST_WORKER_ID !== undefined;
|
|
26
|
-
let promise;
|
|
27
|
-
if (isBrowser && !isJest) {
|
|
28
|
-
promise = fetchLauncherEnvironment().catch(console.error);
|
|
29
|
-
}
|
|
30
|
-
export async function getLauncherEnvironment() {
|
|
31
|
-
if (isBrowser) {
|
|
32
|
-
return promise;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
export const isLauncher = typeof window === "object" && "__HC_LAUNCHER_ENV__" in window;
|
|
2
|
+
export const getLauncherEnvironment = () => isLauncher
|
|
3
|
+
? window.__HC_LAUNCHER_ENV__
|
|
4
|
+
: undefined;
|
|
38
5
|
//# sourceMappingURL=launcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.js","sourceRoot":"","sources":["../../src/environments/launcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"launcher.js","sourceRoot":"","sources":["../../src/environments/launcher.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,UAAU,GACrB,OAAO,MAAM,KAAK,QAAQ,IAAI,qBAAqB,IAAI,MAAM,CAAC;AAEhE,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAoC,EAAE,CAC1E,UAAU;IACR,CAAC,CACG,MAED,CAAC,mBAAmB;IACvB,CAAC,CAAC,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/client",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
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",
|
|
@@ -37,15 +37,14 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@msgpack/msgpack": "^2.7.2",
|
|
40
|
-
"cross-fetch": "^3.1.5",
|
|
41
40
|
"emittery": "^1.0.1",
|
|
42
41
|
"isomorphic-ws": "^5.0.0",
|
|
43
|
-
"lodash": "^4.
|
|
42
|
+
"lodash-es": "^4.17.21",
|
|
44
43
|
"tweetnacl": "^1.0.3"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@types/js-yaml": "^3.12.7",
|
|
48
|
-
"@types/lodash": "^4.
|
|
47
|
+
"@types/lodash-es": "^4.17.6",
|
|
49
48
|
"@types/tape": "^4.13.2",
|
|
50
49
|
"@types/ws": "^8.5.3",
|
|
51
50
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|