@holochain/client 0.9.2 → 0.10.0
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/README.md +24 -0
- package/lib/api/admin/types.d.ts +37 -5
- package/lib/api/admin/types.js.map +1 -1
- package/lib/api/admin/websocket.d.ts +2 -0
- package/lib/api/admin/websocket.js +2 -0
- package/lib/api/admin/websocket.js.map +1 -1
- package/lib/api/app/types.d.ts +8 -3
- package/lib/api/app/websocket.d.ts +5 -2
- package/lib/api/app/websocket.js +13 -9
- package/lib/api/app/websocket.js.map +1 -1
- package/lib/api/app-agent/index.d.ts +2 -0
- package/lib/api/app-agent/index.js +3 -0
- package/lib/api/app-agent/index.js.map +1 -0
- package/lib/api/app-agent/types.d.ts +17 -0
- package/lib/api/app-agent/types.js +2 -0
- package/lib/api/app-agent/types.js.map +1 -0
- package/lib/api/app-agent/websocket.d.ts +36 -0
- package/lib/api/app-agent/websocket.js +76 -0
- package/lib/api/app-agent/websocket.js.map +1 -0
- package/lib/api/client.d.ts +3 -2
- package/lib/api/client.js +22 -26
- package/lib/api/client.js.map +1 -1
- package/lib/api/common.d.ts +6 -6
- package/lib/api/common.js +9 -9
- package/lib/api/common.js.map +1 -1
- package/lib/hdk/capabilities.d.ts +2 -4
- package/lib/hdk/entry.d.ts +9 -5
- package/lib/types.d.ts +16 -2
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -49,6 +49,30 @@ npm install --save-exact @holochain/client
|
|
|
49
49
|
}, 30000)
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
### Use AppAgentWebsocket
|
|
53
|
+
```typescript
|
|
54
|
+
const signalCb = (signal: AppSignal) => {
|
|
55
|
+
// impl...
|
|
56
|
+
resolve()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const TIMEOUT = 12000
|
|
60
|
+
// default timeout is set to 12000
|
|
61
|
+
const appWs = await AppWebsocket.connect(`ws://localhost:${appPort}`, 12000, signalCb)
|
|
62
|
+
|
|
63
|
+
const client = new AppAgentWebsocket(appWs, 'installed_app_id')
|
|
64
|
+
|
|
65
|
+
// default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
|
|
66
|
+
await client.callZome({
|
|
67
|
+
cap: null,
|
|
68
|
+
role_name: 'dnas_role_name', // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client,
|
|
69
|
+
zome_name: "test_zome",
|
|
70
|
+
fn_name: 'test_emitter_fn',
|
|
71
|
+
provenance: fakeAgentPubKey('TODO'),
|
|
72
|
+
payload: null,
|
|
73
|
+
}, 30000)
|
|
74
|
+
```
|
|
75
|
+
|
|
52
76
|
## API Reference
|
|
53
77
|
|
|
54
78
|
See [docs/API.md](docs/API.md)
|
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { AgentPubKey, CellId, DnaHash, DnaProperties, ActionHash, HoloHash, InstalledAppId, InstalledCell, KitsuneAgent, KitsuneSpace,
|
|
3
|
-
import { DhtOp, Entry, Action } from "../../hdk/index.js";
|
|
2
|
+
import { AgentPubKey, CellId, DnaHash, DnaProperties, ActionHash, HoloHash, InstalledAppId, InstalledCell, KitsuneAgent, KitsuneSpace, RoleName as RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
|
|
3
|
+
import { DhtOp, Entry, Action, ZomeCallCapGrant } from "../../hdk/index.js";
|
|
4
4
|
import { Requester } from "../common.js";
|
|
5
5
|
import { ArchiveCloneCellRequest, CreateCloneCellResponse } from "../app/types.js";
|
|
6
6
|
export declare type AttachAppInterfaceRequest = {
|
|
@@ -84,6 +84,30 @@ export declare type RegisterDnaRequest = {
|
|
|
84
84
|
};
|
|
85
85
|
} & DnaSource;
|
|
86
86
|
export declare type RegisterDnaResponse = HoloHash;
|
|
87
|
+
export declare type DnaModifiers = {
|
|
88
|
+
network_seed: NetworkSeed;
|
|
89
|
+
properties: DnaProperties;
|
|
90
|
+
origin_time: Timestamp;
|
|
91
|
+
};
|
|
92
|
+
export declare type FnName = string;
|
|
93
|
+
export declare type ZomeName = string;
|
|
94
|
+
export declare type ZomeDefinition = [
|
|
95
|
+
ZomeName,
|
|
96
|
+
{
|
|
97
|
+
wasm_hash: WasmHash;
|
|
98
|
+
dependencies: ZomeName[];
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
export declare type IntegrityZome = ZomeDefinition;
|
|
102
|
+
export declare type CoordinatorZome = ZomeDefinition;
|
|
103
|
+
export declare type DnaDefinition = {
|
|
104
|
+
name: string;
|
|
105
|
+
modifiers: DnaModifiers;
|
|
106
|
+
integrity_zomes: IntegrityZome[];
|
|
107
|
+
coordinator_zomes: CoordinatorZome[];
|
|
108
|
+
};
|
|
109
|
+
export declare type GetDnaDefinitionRequest = DnaHash;
|
|
110
|
+
export declare type GetDnaDefinitionResponse = DnaDefinition;
|
|
87
111
|
export declare type InstallAppRequest = {
|
|
88
112
|
installed_app_id: InstalledAppId;
|
|
89
113
|
agent_key: AgentPubKey;
|
|
@@ -131,7 +155,7 @@ export declare type AppRoleDnaManifest = {
|
|
|
131
155
|
version?: DnaVersionFlexible;
|
|
132
156
|
};
|
|
133
157
|
export declare type AppRoleManifest = {
|
|
134
|
-
|
|
158
|
+
name: RoleName;
|
|
135
159
|
provisioning?: CellProvisioning;
|
|
136
160
|
dna: AppRoleDnaManifest;
|
|
137
161
|
};
|
|
@@ -192,9 +216,15 @@ export declare type RestoreCloneCellRequest = ArchiveCloneCellRequest;
|
|
|
192
216
|
export declare type RestoreCloneCellResponse = CreateCloneCellResponse;
|
|
193
217
|
export interface DeleteArchivedCloneCellsRequest {
|
|
194
218
|
app_id: InstalledAppId;
|
|
195
|
-
|
|
219
|
+
role_name: RoleName;
|
|
196
220
|
}
|
|
197
221
|
export declare type DeleteArchivedCloneCellsResponse = void;
|
|
222
|
+
export interface GrantZomeCallCapabilityPayload {
|
|
223
|
+
cell_id: CellId;
|
|
224
|
+
cap_grant: ZomeCallCapGrant;
|
|
225
|
+
}
|
|
226
|
+
export declare type GrantZomeCallCapabilityRequest = GrantZomeCallCapabilityPayload;
|
|
227
|
+
export declare type GrantZomeCallCapabilityResponse = void;
|
|
198
228
|
export interface AdminApi {
|
|
199
229
|
attachAppInterface: Requester<AttachAppInterfaceRequest, AttachAppInterfaceResponse>;
|
|
200
230
|
activateApp: Requester<ActivateAppRequest, ActivateAppResponse>;
|
|
@@ -206,6 +236,7 @@ export interface AdminApi {
|
|
|
206
236
|
dumpFullState: Requester<DumpFullStateRequest, DumpFullStateResponse>;
|
|
207
237
|
generateAgentPubKey: Requester<GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse>;
|
|
208
238
|
registerDna: Requester<RegisterDnaRequest, RegisterDnaResponse>;
|
|
239
|
+
getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
|
|
209
240
|
installApp: Requester<InstallAppRequest, InstallAppResponse>;
|
|
210
241
|
uninstallApp: Requester<UninstallAppRequest, UninstallAppResponse>;
|
|
211
242
|
installAppBundle: Requester<InstallAppBundleRequest, InstallAppBundleResponse>;
|
|
@@ -218,10 +249,11 @@ export interface AdminApi {
|
|
|
218
249
|
addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
|
|
219
250
|
restoreCloneCell: Requester<RestoreCloneCellRequest, RestoreCloneCellResponse>;
|
|
220
251
|
deleteArchivedCloneCells: Requester<DeleteArchivedCloneCellsRequest, DeleteArchivedCloneCellsResponse>;
|
|
252
|
+
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
|
|
221
253
|
}
|
|
222
254
|
export declare type InstallAppDnaPayload = {
|
|
223
255
|
hash: HoloHash;
|
|
224
|
-
|
|
256
|
+
role_name: RoleName;
|
|
225
257
|
membrane_proof?: MembraneProof;
|
|
226
258
|
};
|
|
227
259
|
export declare type ZomeLocation = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/admin/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/admin/types.ts"],"names":[],"mappings":"AA8OA,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"}
|
|
@@ -33,6 +33,7 @@ export declare class AdminWebsocket implements Api.AdminApi {
|
|
|
33
33
|
dumpFullState: Requester<Api.DumpFullStateRequest, Api.DumpFullStateResponse>;
|
|
34
34
|
generateAgentPubKey: Requester<Api.GenerateAgentPubKeyRequest, Api.GenerateAgentPubKeyResponse>;
|
|
35
35
|
registerDna: Requester<Api.RegisterDnaRequest, Api.RegisterDnaResponse>;
|
|
36
|
+
getDnaDefinition: Requester<Api.GetDnaDefinitionRequest, Api.GetDnaDefinitionResponse>;
|
|
36
37
|
installApp: Requester<Api.InstallAppRequest, Api.InstallAppResponse>;
|
|
37
38
|
uninstallApp: Requester<Api.UninstallAppRequest, Api.UninstallAppResponse>;
|
|
38
39
|
installAppBundle: Requester<Api.InstallAppBundleRequest, Api.InstallAppBundleResponse>;
|
|
@@ -45,4 +46,5 @@ export declare class AdminWebsocket implements Api.AdminApi {
|
|
|
45
46
|
addAgentInfo: Requester<Api.AddAgentInfoRequest, Api.AddAgentInfoResponse>;
|
|
46
47
|
restoreCloneCell: Requester<Api.RestoreCloneCellRequest, Api.RestoreCloneCellResponse>;
|
|
47
48
|
deleteArchivedCloneCells: Requester<Api.DeleteArchivedCloneCellsRequest, Api.DeleteArchivedCloneCellsResponse>;
|
|
49
|
+
grantZomeCallCapability: Requester<Api.GrantZomeCallCapabilityRequest, Api.GrantZomeCallCapabilityResponse>;
|
|
48
50
|
}
|
|
@@ -51,6 +51,7 @@ export class AdminWebsocket {
|
|
|
51
51
|
dumpFullState = this._requester("dump_full_state");
|
|
52
52
|
generateAgentPubKey = this._requester("generate_agent_pub_key");
|
|
53
53
|
registerDna = this._requester("register_dna");
|
|
54
|
+
getDnaDefinition = this._requester("get_dna_definition");
|
|
54
55
|
installApp = this._requester("install_app");
|
|
55
56
|
uninstallApp = this._requester("uninstall_app");
|
|
56
57
|
installAppBundle = this._requester("install_app_bundle");
|
|
@@ -64,6 +65,7 @@ export class AdminWebsocket {
|
|
|
64
65
|
addAgentInfo = this._requester("add_agent_info");
|
|
65
66
|
restoreCloneCell = this._requester("restore_clone_cell");
|
|
66
67
|
deleteArchivedCloneCells = this._requester("delete_archived_clone_cells");
|
|
68
|
+
grantZomeCallCapability = this._requester("grant_zome_call_capability");
|
|
67
69
|
}
|
|
68
70
|
const listAppsTransform = {
|
|
69
71
|
input: (req) => {
|
|
@@ -1 +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,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAe,oBAAoB,EAAa,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,MAAM,OAAO,cAAc;IACzB,MAAM,CAAW;IACjB,cAAc,CAAS;IAEvB,YAAY,MAAgB,EAAE,cAAuB;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc;YACjB,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC;IACpE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,GAAW,EACX,cAAuB;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4B,CAAC,CAAC;CACnD;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"}
|
package/lib/api/app/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CapSecret } from "../../hdk/capabilities.js";
|
|
2
|
-
import { AgentPubKey, CellId, DnaProperties, InstalledAppId, InstalledCell,
|
|
2
|
+
import { AgentPubKey, CellId, DnaProperties, InstalledAppId, InstalledCell, RoleName, Timestamp, DnaHash, DnaGossipInfo } from "../../types.js";
|
|
3
3
|
import { Requester } from "../common.js";
|
|
4
4
|
import { InstalledAppInfo, MembraneProof, NetworkSeed } from "../admin/index.js";
|
|
5
5
|
export declare type CallZomeRequestGeneric<Payload> = {
|
|
@@ -25,7 +25,7 @@ export interface CreateCloneCellRequest {
|
|
|
25
25
|
/**
|
|
26
26
|
* The DNA's role id to clone.
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
role_name: RoleName;
|
|
29
29
|
/**
|
|
30
30
|
* Modifiers to set for the new cell.
|
|
31
31
|
* At least one of the modifiers must be set to obtain a distinct hash for
|
|
@@ -64,7 +64,7 @@ export interface CreateCloneCellRequest {
|
|
|
64
64
|
export declare type CreateCloneCellResponse = InstalledCell;
|
|
65
65
|
export interface ArchiveCloneCellRequest {
|
|
66
66
|
app_id: InstalledAppId;
|
|
67
|
-
clone_cell_id:
|
|
67
|
+
clone_cell_id: RoleName | CellId;
|
|
68
68
|
}
|
|
69
69
|
export declare type ArchiveCloneCellResponse = void;
|
|
70
70
|
export declare type AppSignal = {
|
|
@@ -74,6 +74,11 @@ export declare type AppSignal = {
|
|
|
74
74
|
payload: any;
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
+
export interface GossipInfoRequest {
|
|
78
|
+
/** The DNAs for which to get gossip info */
|
|
79
|
+
dnas: DnaHash[];
|
|
80
|
+
}
|
|
81
|
+
export declare type GossipInfoResponse = DnaGossipInfo[];
|
|
77
82
|
export declare type AppSignalCb = (signal: AppSignal) => void;
|
|
78
83
|
export declare type SignalResponseGeneric<Payload> = Payload;
|
|
79
84
|
export interface AppApi {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
1
3
|
import { InstalledAppId } from "../../types.js";
|
|
2
4
|
import { WsClient } from "../client.js";
|
|
3
5
|
import { Requester, Transformer } from "../common.js";
|
|
4
|
-
import { AppApi, AppInfoRequest, AppInfoResponse, AppSignalCb, CallZomeRequestGeneric, CallZomeResponseGeneric, ArchiveCloneCellRequest, CreateCloneCellRequest, CreateCloneCellResponse, ArchiveCloneCellResponse } from "./types.js";
|
|
5
|
-
export declare class AppWebsocket implements AppApi {
|
|
6
|
+
import { AppApi, AppInfoRequest, AppInfoResponse, AppSignalCb, CallZomeRequestGeneric, CallZomeResponseGeneric, ArchiveCloneCellRequest, CreateCloneCellRequest, CreateCloneCellResponse, ArchiveCloneCellResponse, GossipInfoRequest, GossipInfoResponse } from "./types.js";
|
|
7
|
+
export declare class AppWebsocket extends EventEmitter implements AppApi {
|
|
6
8
|
client: WsClient;
|
|
7
9
|
defaultTimeout: number;
|
|
8
10
|
overrideInstalledAppId?: InstalledAppId;
|
|
@@ -13,4 +15,5 @@ export declare class AppWebsocket implements AppApi {
|
|
|
13
15
|
callZome: Requester<CallZomeRequestGeneric<any>, CallZomeResponseGeneric<any>>;
|
|
14
16
|
createCloneCell: Requester<CreateCloneCellRequest, CreateCloneCellResponse>;
|
|
15
17
|
archiveCloneCell: Requester<ArchiveCloneCellRequest, ArchiveCloneCellResponse>;
|
|
18
|
+
gossipInfo: Requester<GossipInfoRequest, GossipInfoResponse>;
|
|
16
19
|
}
|
package/lib/api/app/websocket.js
CHANGED
|
@@ -2,47 +2,51 @@
|
|
|
2
2
|
* Defines AppWebsocket, an easy-to-use websocket implementation of the
|
|
3
3
|
* Conductor API for apps
|
|
4
4
|
*
|
|
5
|
-
* const client = AppWebsocket.connect(
|
|
6
|
-
* 'ws://localhost:9000',
|
|
7
|
-
* signal => console.log('got a signal:', signal)
|
|
8
|
-
* )
|
|
5
|
+
* const client = AppWebsocket.connect('ws://localhost:9000');
|
|
9
6
|
*
|
|
10
|
-
* client.callZome({...})
|
|
7
|
+
* client.callZome({...})
|
|
11
8
|
* .then(() => {
|
|
12
9
|
* console.log('DNA successfully installed')
|
|
13
10
|
* })
|
|
14
11
|
* .catch(err => {
|
|
15
12
|
* console.error('problem installing DNA:', err)
|
|
16
|
-
* })
|
|
13
|
+
* });
|
|
17
14
|
*/
|
|
18
15
|
import { decode, encode } from "@msgpack/msgpack";
|
|
16
|
+
import { EventEmitter } from "events";
|
|
19
17
|
import { getLauncherEnvironment } from "../../environments/launcher.js";
|
|
20
18
|
import { WsClient } from "../client.js";
|
|
21
19
|
import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, } from "../common.js";
|
|
22
|
-
export class AppWebsocket {
|
|
20
|
+
export class AppWebsocket extends EventEmitter {
|
|
23
21
|
client;
|
|
24
22
|
defaultTimeout;
|
|
25
23
|
overrideInstalledAppId;
|
|
26
24
|
constructor(client, defaultTimeout, overrideInstalledAppId) {
|
|
25
|
+
super();
|
|
27
26
|
this.client = client;
|
|
28
27
|
this.defaultTimeout =
|
|
29
28
|
defaultTimeout === undefined ? DEFAULT_TIMEOUT : defaultTimeout;
|
|
30
29
|
this.overrideInstalledAppId = overrideInstalledAppId;
|
|
31
30
|
}
|
|
32
|
-
static async connect(url, defaultTimeout,
|
|
31
|
+
static async connect(url, defaultTimeout,
|
|
32
|
+
//** @deprecated */
|
|
33
|
+
signalCb) {
|
|
33
34
|
// Check if we are in the launcher's environment, and if so, redirect the url to connect to
|
|
34
35
|
const env = await getLauncherEnvironment();
|
|
35
36
|
if (env) {
|
|
36
37
|
url = `ws://localhost:${env.APP_INTERFACE_PORT}`;
|
|
37
38
|
}
|
|
38
39
|
const wsClient = await WsClient.connect(url, signalCb);
|
|
39
|
-
|
|
40
|
+
const appWebsocket = new AppWebsocket(wsClient, defaultTimeout, env ? env.INSTALLED_APP_ID : undefined);
|
|
41
|
+
wsClient.on("signal", (signal) => appWebsocket.emit("signal", signal));
|
|
42
|
+
return appWebsocket;
|
|
40
43
|
}
|
|
41
44
|
_requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
|
|
42
45
|
appInfo = this._requester("app_info", appInfoTransform(this));
|
|
43
46
|
callZome = this._requester("zome_call", callZomeTransform);
|
|
44
47
|
createCloneCell = this._requester("create_clone_cell");
|
|
45
48
|
archiveCloneCell = this._requester("archive_clone_cell");
|
|
49
|
+
gossipInfo = this._requester("gossip_info");
|
|
46
50
|
}
|
|
47
51
|
const callZomeTransform = {
|
|
48
52
|
input: (req) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app/websocket.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,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;AAgBtB,MAAM,OAAO,YAAa,SAAQ,YAAY;IAC5C,MAAM,CAAW;IACjB,cAAc,CAAS;IACvB,sBAAsB,CAAkB;IAExC,YACE,MAAgB,EAChB,cAAuB,EACvB,sBAAuC;QAEvC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc;YACjB,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC;QAClE,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,GAAW,EACX,cAAuB;IACvB,mBAAmB;IACn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AED,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,KAAmB,EAMnB,EAAE,CAAC,CAAC;IACJ,KAAK,EAAE,CAAC,GAAmB,EAAkB,EAAE;QAC7C,IAAI,KAAK,CAAC,sBAAsB,EAAE;YAChC,OAAO;gBACL,gBAAgB,EAAE,KAAK,CAAC,sBAAsB;aAC/C,CAAC;SACH;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,EAAE,CAAC,GAAoB,EAAmB,EAAE;QAChD,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/app-agent/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import { ArchiveCloneCellResponse, CreateCloneCellRequest, CreateCloneCellResponse } from "..";
|
|
4
|
+
import { CellId, RoleName } from "../..";
|
|
5
|
+
import { CallZomeRequest, AppInfoResponse, ArchiveCloneCellRequest } from "../app";
|
|
6
|
+
export declare type AppAgentCallZomeRequest = Omit<CallZomeRequest, "cell_id"> & {
|
|
7
|
+
role_name?: RoleName;
|
|
8
|
+
cell_id?: CellId;
|
|
9
|
+
};
|
|
10
|
+
export declare type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
|
|
11
|
+
export declare type AppArchiveCloneCellRequest = Omit<ArchiveCloneCellRequest, "app_id">;
|
|
12
|
+
export interface AppAgentClient extends EventEmitter {
|
|
13
|
+
callZome(args: AppAgentCallZomeRequest, timeout?: number): Promise<any>;
|
|
14
|
+
appInfo(): Promise<AppInfoResponse>;
|
|
15
|
+
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
16
|
+
archiveCloneCell(args: AppArchiveCloneCellRequest): Promise<ArchiveCloneCellResponse>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/app-agent/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines AppAgentWebsocket, an easy-to-use websocket implementation of the
|
|
3
|
+
* Conductor API for apps, restricted to a single app provided on initialization
|
|
4
|
+
*
|
|
5
|
+
* const appWs = AppWebsocket.connect('ws://localhost:9000')
|
|
6
|
+
*
|
|
7
|
+
* const client = new AppAgentWebsocket(appWs, 'my_installed_app_id')
|
|
8
|
+
*
|
|
9
|
+
* client.callZome({
|
|
10
|
+
* role_name: 'my_role_name' // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client,
|
|
11
|
+
* zome_name: 'zome',
|
|
12
|
+
* fn_name: 'fn',
|
|
13
|
+
* payload: { value: 'v' }
|
|
14
|
+
* })
|
|
15
|
+
* .then(result => {
|
|
16
|
+
* console.log('callZome returned with:', result)
|
|
17
|
+
* })
|
|
18
|
+
* .catch(err => {
|
|
19
|
+
* console.error('callZome errored with:', err)
|
|
20
|
+
* })
|
|
21
|
+
*/
|
|
22
|
+
/// <reference types="node" />
|
|
23
|
+
import { EventEmitter } from "events";
|
|
24
|
+
import { InstalledAppId } from "../../types.js";
|
|
25
|
+
import { AppInfoResponse, AppWebsocket, ArchiveCloneCellResponse, CallZomeResponse, CreateCloneCellResponse, InstalledAppInfo } from "../index.js";
|
|
26
|
+
import { AppAgentCallZomeRequest, AppAgentClient, AppArchiveCloneCellRequest, AppCreateCloneCellRequest } from "./types.js";
|
|
27
|
+
export declare class AppAgentWebsocket extends EventEmitter implements AppAgentClient {
|
|
28
|
+
appWebsocket: AppWebsocket;
|
|
29
|
+
installedAppId: InstalledAppId;
|
|
30
|
+
cachedAppInfo?: InstalledAppInfo;
|
|
31
|
+
constructor(appWebsocket: AppWebsocket, installedAppId: InstalledAppId);
|
|
32
|
+
appInfo(): Promise<AppInfoResponse>;
|
|
33
|
+
callZome(request: AppAgentCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;
|
|
34
|
+
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
35
|
+
archiveCloneCell(args: AppArchiveCloneCellRequest): Promise<ArchiveCloneCellResponse>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines AppAgentWebsocket, an easy-to-use websocket implementation of the
|
|
3
|
+
* Conductor API for apps, restricted to a single app provided on initialization
|
|
4
|
+
*
|
|
5
|
+
* const appWs = AppWebsocket.connect('ws://localhost:9000')
|
|
6
|
+
*
|
|
7
|
+
* const client = new AppAgentWebsocket(appWs, 'my_installed_app_id')
|
|
8
|
+
*
|
|
9
|
+
* client.callZome({
|
|
10
|
+
* role_name: 'my_role_name' // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client,
|
|
11
|
+
* zome_name: 'zome',
|
|
12
|
+
* fn_name: 'fn',
|
|
13
|
+
* payload: { value: 'v' }
|
|
14
|
+
* })
|
|
15
|
+
* .then(result => {
|
|
16
|
+
* console.log('callZome returned with:', result)
|
|
17
|
+
* })
|
|
18
|
+
* .catch(err => {
|
|
19
|
+
* console.error('callZome errored with:', err)
|
|
20
|
+
* })
|
|
21
|
+
*/
|
|
22
|
+
import { EventEmitter } from "events";
|
|
23
|
+
import omit from "lodash/omit.js";
|
|
24
|
+
export class AppAgentWebsocket extends EventEmitter {
|
|
25
|
+
appWebsocket;
|
|
26
|
+
installedAppId;
|
|
27
|
+
cachedAppInfo;
|
|
28
|
+
constructor(appWebsocket, installedAppId) {
|
|
29
|
+
super();
|
|
30
|
+
this.appWebsocket = appWebsocket;
|
|
31
|
+
this.installedAppId = installedAppId;
|
|
32
|
+
this.appWebsocket.on("signal", (signal) => this.emit("signal", signal));
|
|
33
|
+
}
|
|
34
|
+
async appInfo() {
|
|
35
|
+
const appInfo = await this.appWebsocket.appInfo({
|
|
36
|
+
installed_app_id: this.installedAppId,
|
|
37
|
+
});
|
|
38
|
+
this.cachedAppInfo = appInfo;
|
|
39
|
+
return appInfo;
|
|
40
|
+
}
|
|
41
|
+
async callZome(request, timeout) {
|
|
42
|
+
if (request.role_name) {
|
|
43
|
+
const appInfo = this.cachedAppInfo || (await this.appInfo());
|
|
44
|
+
const cell_id = appInfo.cell_data.find((c) => c.role_name === request.role_name)?.cell_id;
|
|
45
|
+
if (!cell_id) {
|
|
46
|
+
throw new Error(`No cell found with role_name ${request.role_name}`);
|
|
47
|
+
}
|
|
48
|
+
const callZomeRequest = {
|
|
49
|
+
...omit(request, "role_name"),
|
|
50
|
+
cell_id,
|
|
51
|
+
};
|
|
52
|
+
return this.appWebsocket.callZome(callZomeRequest, timeout);
|
|
53
|
+
}
|
|
54
|
+
else if (request.cell_id) {
|
|
55
|
+
return this.appWebsocket.callZome(request, timeout);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw new Error("callZome requires a role_name or cell_id arg");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async createCloneCell(args) {
|
|
62
|
+
const clonedCell = this.appWebsocket.createCloneCell({
|
|
63
|
+
app_id: this.installedAppId,
|
|
64
|
+
...args,
|
|
65
|
+
});
|
|
66
|
+
this.cachedAppInfo = undefined;
|
|
67
|
+
return clonedCell;
|
|
68
|
+
}
|
|
69
|
+
async archiveCloneCell(args) {
|
|
70
|
+
return this.appWebsocket.archiveCloneCell({
|
|
71
|
+
app_id: this.installedAppId,
|
|
72
|
+
...args,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=websocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app-agent/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAmBlC,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IACjD,YAAY,CAAe;IAC3B,cAAc,CAAiB;IAC/B,aAAa,CAAoB;IAEjC,YAAY,YAA0B,EAAE,cAA8B;QACpE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;YAC9C,gBAAgB,EAAE,IAAI,CAAC,cAAc;SACtC,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,OAAgC,EAChC,OAAgB;QAEhB,IAAI,OAAO,CAAC,SAAS,EAAE;YACrB,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CACpC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,CACzC,EAAE,OAAO,CAAC;YAEX,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,IAAI,KAAK,CAAC,gCAAgC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;aACtE;YAED,MAAM,eAAe,GAAG;gBACtB,GAAG,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC;gBAC7B,OAAO;aACR,CAAC;YACF,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;SAC7D;aAAM,IAAI,OAAO,CAAC,OAAO,EAAE;YAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAA0B,EAAE,OAAO,CAAC,CAAC;SACxE;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;SACjE;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;CACF"}
|
package/lib/api/client.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="ws" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { decode } from "@msgpack/msgpack";
|
|
3
4
|
import Websocket from "isomorphic-ws";
|
|
5
|
+
import { EventEmitter } from "events";
|
|
4
6
|
import { AppSignalCb } from "./app/types.js";
|
|
5
7
|
/**
|
|
6
8
|
* A Websocket client which can make requests and receive responses,
|
|
@@ -8,14 +10,13 @@ import { AppSignalCb } from "./app/types.js";
|
|
|
8
10
|
*
|
|
9
11
|
* Uses Holochain's websocket WireMessage for communication.
|
|
10
12
|
*/
|
|
11
|
-
export declare class WsClient {
|
|
13
|
+
export declare class WsClient extends EventEmitter {
|
|
12
14
|
socket: Websocket;
|
|
13
15
|
pendingRequests: Record<number, {
|
|
14
16
|
fulfill: (msg: unknown) => ReturnType<typeof decode>;
|
|
15
17
|
reject: (error: Error) => void;
|
|
16
18
|
}>;
|
|
17
19
|
index: number;
|
|
18
|
-
alreadyWarnedNoSignalCb: boolean;
|
|
19
20
|
constructor(socket: any, signalCb?: AppSignalCb);
|
|
20
21
|
emitSignal(data: any): void;
|
|
21
22
|
request<Req, Res>(data: Req): Promise<Res>;
|
package/lib/api/client.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { decode, encode } from "@msgpack/msgpack";
|
|
2
2
|
import Websocket from "isomorphic-ws";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
3
4
|
/**
|
|
4
5
|
* A Websocket client which can make requests and receive responses,
|
|
5
6
|
* as well as send and receive signals
|
|
6
7
|
*
|
|
7
8
|
* Uses Holochain's websocket WireMessage for communication.
|
|
8
9
|
*/
|
|
9
|
-
export class WsClient {
|
|
10
|
+
export class WsClient extends EventEmitter {
|
|
10
11
|
socket;
|
|
11
12
|
pendingRequests;
|
|
12
13
|
index;
|
|
13
|
-
alreadyWarnedNoSignalCb;
|
|
14
14
|
constructor(socket, signalCb) {
|
|
15
|
+
super();
|
|
15
16
|
this.socket = socket;
|
|
16
17
|
this.pendingRequests = {};
|
|
17
18
|
this.index = 0;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
if (signalCb) {
|
|
20
|
+
console.log("Providing a signal callback on client initialization is deprecated. Instead, add an event handler using `.on('signal', signalCb)`.");
|
|
21
|
+
this.on("signal", signalCb);
|
|
22
|
+
}
|
|
20
23
|
socket.onmessage = async (encodedMsg) => {
|
|
21
24
|
let data = encodedMsg.data;
|
|
22
25
|
// If data is not a buffer (nodejs), it will be a blob (browser)
|
|
@@ -25,29 +28,22 @@ export class WsClient {
|
|
|
25
28
|
}
|
|
26
29
|
const msg = decode(data);
|
|
27
30
|
if (msg.type === "Signal") {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
// Note: holochain currently returns signals as an array of two values: cellId and the serialized signal payload
|
|
35
|
-
// and this array is nested within the App key within the returned message.
|
|
36
|
-
const decodedCellId = decodedMessage.App[0];
|
|
37
|
-
// Note:In order to return readible content to the UI, the signal payload must also be decoded.
|
|
38
|
-
const decodedPayload = signalTransform(decodedMessage.App[1]);
|
|
39
|
-
// Return a uniform format to UI (ie: { type, data } - the same format as with callZome and appInfo...)
|
|
40
|
-
const signal = {
|
|
41
|
-
type: msg.type,
|
|
42
|
-
data: { cellId: decodedCellId, payload: decodedPayload },
|
|
43
|
-
};
|
|
44
|
-
signalCb(signal);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
if (!this.alreadyWarnedNoSignalCb)
|
|
48
|
-
console.log("Received signal but no signal callback was set in constructor");
|
|
49
|
-
this.alreadyWarnedNoSignalCb = true;
|
|
31
|
+
const decodedMessage = decode(msg.data);
|
|
32
|
+
if (!decodedMessage.App) {
|
|
33
|
+
// We have received a system signal, do nothing
|
|
34
|
+
return;
|
|
50
35
|
}
|
|
36
|
+
// Note: holochain currently returns signals as an array of two values: cellId and the serialized signal payload
|
|
37
|
+
// and this array is nested within the App key within the returned message.
|
|
38
|
+
const decodedCellId = decodedMessage.App[0];
|
|
39
|
+
// Note:In order to return readible content to the UI, the signal payload must also be decoded.
|
|
40
|
+
const decodedPayload = signalTransform(decodedMessage.App[1]);
|
|
41
|
+
// Return a uniform format to UI (ie: { type, data } - the same format as with callZome and appInfo...)
|
|
42
|
+
const signal = {
|
|
43
|
+
type: msg.type,
|
|
44
|
+
data: { cellId: decodedCellId, payload: decodedPayload },
|
|
45
|
+
};
|
|
46
|
+
this.emit("signal", signal);
|
|
51
47
|
}
|
|
52
48
|
else if (msg.type === "Response") {
|
|
53
49
|
this.handleResponse(msg);
|
package/lib/api/client.js.map
CHANGED
|
@@ -1 +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,
|
|
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;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IACxC,MAAM,CAAY;IAClB,eAAe,CAMb;IACF,KAAK,CAAS;IAEd,YAAY,MAAW,EAAE,QAAsB;QAC7C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEf,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,GAAG,CACT,oIAAoI,CACrI,CAAC;YACF,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;SAC7B;QAED,MAAM,CAAC,SAAS,GAAG,KAAK,EAAE,UAAe,EAAE,EAAE;YAC3C,IAAI,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;YAE3B,gEAAgE;YAChE,IAAI,OAAO,MA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,CAAC,6CAA6C,EAAE,EAAE,CAAC,CAAC;SAClE;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAAW,EAAE,QAAsB;QAChD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;YAClC,kDAAkD;YAClD,oDAAoD;YACpD,0BAA0B;YAC1B,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;gBACpB,MAAM,CACJ,IAAI,KAAK,CACP,+GAA+G,GAAG,EAAE,CACrH,CACF,CAAC;YACJ,CAAC,CAAC;YACF,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;gBACnB,OAAO,CAAC,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"}
|
package/lib/api/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RoleName } from "../types.js";
|
|
2
2
|
export declare const DEFAULT_TIMEOUT = 15000;
|
|
3
3
|
export declare type Transformer<ReqO, ReqI, ResI, ResO> = {
|
|
4
4
|
input: (req: ReqO) => ReqI;
|
|
@@ -26,15 +26,15 @@ export declare const promiseTimeout: (promise: Promise<any>, tag: string, ms: nu
|
|
|
26
26
|
*/
|
|
27
27
|
export declare class CloneId {
|
|
28
28
|
private static readonly CLONE_ID_DELIMITER;
|
|
29
|
-
private readonly
|
|
29
|
+
private readonly roleName;
|
|
30
30
|
private readonly index;
|
|
31
|
-
constructor(
|
|
31
|
+
constructor(roleName: RoleName, index: number);
|
|
32
32
|
/**
|
|
33
33
|
* Parse a role id of a clone cell to obtain a clone id instance.
|
|
34
|
-
* @param
|
|
34
|
+
* @param roleName Role id to parse.
|
|
35
35
|
* @returns A clone id instance.
|
|
36
36
|
*/
|
|
37
|
-
static
|
|
37
|
+
static fromRoleName(roleName: RoleName): CloneId;
|
|
38
38
|
toString(): string;
|
|
39
|
-
|
|
39
|
+
getBaseRoleName(): string;
|
|
40
40
|
}
|
package/lib/api/common.js
CHANGED
|
@@ -46,29 +46,29 @@ export const promiseTimeout = (promise, tag, ms) => {
|
|
|
46
46
|
*/
|
|
47
47
|
export class CloneId {
|
|
48
48
|
static CLONE_ID_DELIMITER = ".";
|
|
49
|
-
|
|
49
|
+
roleName;
|
|
50
50
|
index;
|
|
51
|
-
constructor(
|
|
52
|
-
this.
|
|
51
|
+
constructor(roleName, index) {
|
|
52
|
+
this.roleName = roleName;
|
|
53
53
|
this.index = index;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Parse a role id of a clone cell to obtain a clone id instance.
|
|
57
|
-
* @param
|
|
57
|
+
* @param roleName Role id to parse.
|
|
58
58
|
* @returns A clone id instance.
|
|
59
59
|
*/
|
|
60
|
-
static
|
|
61
|
-
const parts =
|
|
60
|
+
static fromRoleName(roleName) {
|
|
61
|
+
const parts = roleName.split(CloneId.CLONE_ID_DELIMITER);
|
|
62
62
|
if (parts.length !== 2) {
|
|
63
63
|
throw new Error("Malformed clone id: must consist of {role id.clone index}");
|
|
64
64
|
}
|
|
65
65
|
return new CloneId(parts[0], parseInt(parts[1]));
|
|
66
66
|
}
|
|
67
67
|
toString() {
|
|
68
|
-
return `${this.
|
|
68
|
+
return `${this.roleName}${CloneId.CLONE_ID_DELIMITER}${this.index}`;
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
return this.
|
|
70
|
+
getBaseRoleName() {
|
|
71
|
+
return this.roleName;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
//# sourceMappingURL=common.js.map
|
package/lib/api/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAWrC;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,CACE,SAAgD,EAChD,GAAW,EACX,YAAiD,mBAAmB,EACpE,EAAE,CACJ,KAAK,EAAE,GAAS,EAAE,OAAgB,EAAE,EAAE;IACpC,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IACxD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AACJ,MAAM,QAAQ,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/B,MAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE;IACrC,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO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gentPubKey } from "../types.js";
|
|
2
3
|
export declare type CapSecret = Uint8Array;
|
|
3
4
|
export interface CapClaim {
|
|
@@ -8,10 +9,7 @@ export interface CapClaim {
|
|
|
8
9
|
export interface ZomeCallCapGrant {
|
|
9
10
|
tag: string;
|
|
10
11
|
access: CapAccess;
|
|
11
|
-
functions: Array<
|
|
12
|
-
zome: string;
|
|
13
|
-
fn_name: string;
|
|
14
|
-
}>;
|
|
12
|
+
functions: Array<[ZomeName, FnName]>;
|
|
15
13
|
}
|
|
16
14
|
export declare type CapAccess = "Unrestricted" | {
|
|
17
15
|
Transferable: {
|
package/lib/hdk/entry.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { CapClaim, ZomeCallCapGrant } from "./capabilities.js";
|
|
2
2
|
import { AgentPubKey } from "../types.js";
|
|
3
3
|
import { CounterSigningSessionData } from "./countersigning.js";
|
|
4
|
-
export declare type EntryVisibility =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare type EntryVisibility = {
|
|
5
|
+
Public: null;
|
|
6
|
+
} | {
|
|
7
|
+
Private: null;
|
|
8
|
+
};
|
|
9
|
+
export declare type AppEntryDef = {
|
|
10
|
+
entry_index: number;
|
|
11
|
+
zome_index: number;
|
|
8
12
|
visibility: EntryVisibility;
|
|
9
13
|
};
|
|
10
14
|
export declare type EntryType = "Agent" | {
|
|
11
|
-
App:
|
|
15
|
+
App: AppEntryDef;
|
|
12
16
|
} | "CapClaim" | "CapGrant";
|
|
13
17
|
export interface EntryContent<E extends string, C> {
|
|
14
18
|
entry_type: E;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare type HoloHash = Uint8Array;
|
|
2
2
|
export declare type AgentPubKey = HoloHash;
|
|
3
3
|
export declare type DnaHash = HoloHash;
|
|
4
|
+
export declare type WasmHash = HoloHash;
|
|
4
5
|
export declare type EntryHash = HoloHash;
|
|
5
6
|
export declare type ActionHash = HoloHash;
|
|
6
7
|
export declare type AnyDhtHash = HoloHash;
|
|
@@ -10,13 +11,26 @@ export declare type InstalledAppId = string;
|
|
|
10
11
|
export declare type Signature = Uint8Array;
|
|
11
12
|
export declare type CellId = [DnaHash, AgentPubKey];
|
|
12
13
|
export declare type DnaProperties = any;
|
|
13
|
-
export declare type
|
|
14
|
+
export declare type RoleName = string;
|
|
14
15
|
export declare type InstalledCell = {
|
|
15
16
|
cell_id: CellId;
|
|
16
|
-
|
|
17
|
+
role_name: RoleName;
|
|
17
18
|
};
|
|
18
19
|
export declare type Timestamp = number;
|
|
19
20
|
export interface HoloHashed<T> {
|
|
20
21
|
hash: HoloHash;
|
|
21
22
|
content: T;
|
|
22
23
|
}
|
|
24
|
+
export declare type DnaGossipInfo = {
|
|
25
|
+
total_historical_gossip_throughput: HistoricalGossipThroughput;
|
|
26
|
+
};
|
|
27
|
+
export declare type HistoricalGossipThroughput = {
|
|
28
|
+
expected_op_bytes: InOut;
|
|
29
|
+
expected_op_count: InOut;
|
|
30
|
+
op_bytes: InOut;
|
|
31
|
+
op_count: InOut;
|
|
32
|
+
};
|
|
33
|
+
export declare type InOut = {
|
|
34
|
+
incoming: number;
|
|
35
|
+
outgoing: number;
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
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",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"lint": "eslint --fix --ext .ts src test .eslintrc.cjs",
|
|
35
|
-
"test": "RUST_LOG=error RUST_BACKTRACE=1 node --loader ts-node/esm test/index.ts",
|
|
35
|
+
"test": "RUST_LOG=error RUST_BACKTRACE=1 node --experimental-wasm-modules --loader ts-node/esm test/index.ts",
|
|
36
36
|
"build": "rimraf ./lib && tsc -p tsconfig.build.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
@@ -41,17 +41,25 @@
|
|
|
41
41
|
"eslint-config-prettier": "^8.5.0",
|
|
42
42
|
"eslint-plugin-prettier": "^4.0.0",
|
|
43
43
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
44
|
+
"events": "^3.3.0",
|
|
44
45
|
"isomorphic-ws": "^5.0.0",
|
|
45
|
-
"
|
|
46
|
+
"lodash": "^4.5.0",
|
|
47
|
+
"prettier": "^2.6.2",
|
|
48
|
+
"tweetnacl": "^1.0.3"
|
|
46
49
|
},
|
|
47
50
|
"devDependencies": {
|
|
48
51
|
"@types/js-yaml": "^3.12.7",
|
|
52
|
+
"@types/lodash": "^4.5.7",
|
|
49
53
|
"@types/tape": "^4.13.2",
|
|
50
54
|
"@types/ws": "^8.5.3",
|
|
51
55
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
|
52
56
|
"@typescript-eslint/parser": "^5.27.0",
|
|
53
57
|
"eslint": "^8.16.0",
|
|
58
|
+
"eslint-config-prettier": "^8.5.0",
|
|
59
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
60
|
+
"eslint-plugin-tsdoc": "^0.2.16",
|
|
54
61
|
"js-yaml": "^3.14.1",
|
|
62
|
+
"prettier": "^2.6.2",
|
|
55
63
|
"rimraf": "^3.0.2",
|
|
56
64
|
"tape": "^5.5.3",
|
|
57
65
|
"ts-node": "^10.8.1",
|