@holochain/client 0.18.0-dev.0 → 0.18.0-dev.1

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.
@@ -1,5 +1,5 @@
1
1
  import { UnsubscribeFunction } from "emittery";
2
- import { AgentPubKey, AppAuthenticationToken, AppInfo, CapSecret, CellId, ClonedCell, DnaHash, DnaProperties, FunctionName, MembraneProof, NetworkInfo, NetworkSeed, Nonce256Bit, RoleName, Timestamp, WebsocketConnectionOptions, ZomeName } from "../../index.js";
2
+ import { AgentPubKey, AppAuthenticationToken, AppInfo, CapSecret, CellId, ClonedCell, DnaHash, DnaProperties, FunctionName, InstalledAppId, MembraneProof, NetworkInfo, NetworkSeed, Nonce256Bit, RoleName, Timestamp, Transformer, WebsocketConnectionOptions, ZomeName } from "../../index.js";
3
3
  /**
4
4
  * @public
5
5
  */
@@ -214,6 +214,7 @@ export interface AppClient {
214
214
  on<Name extends keyof AppEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
215
215
  appInfo(): Promise<AppInfoResponse>;
216
216
  myPubKey: AgentPubKey;
217
+ installedAppId: InstalledAppId;
217
218
  createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
218
219
  enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;
219
220
  disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
@@ -224,4 +225,6 @@ export interface AppClient {
224
225
  */
225
226
  export interface AppWebsocketConnectionOptions extends WebsocketConnectionOptions {
226
227
  token?: AppAuthenticationToken;
228
+ callZomeTransform?: CallZomeTransform;
227
229
  }
230
+ export type CallZomeTransform = Transformer<CallZomeRequest | CallZomeRequestSigned, Promise<CallZomeRequestSigned>, CallZomeResponseGeneric<Uint8Array>, CallZomeResponse>;
@@ -1,5 +1,5 @@
1
1
  import { UnsubscribeFunction } from "emittery";
2
- import { AgentPubKey, CellId, RoleName } from "../../types.js";
2
+ import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js";
3
3
  import { AppInfo } from "../admin/index.js";
4
4
  import { AppCallZomeRequest, AppClient, AppEvents, AppNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest, AppSignalCb, CallZomeRequest, CallZomeRequestSigned, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse, NetworkInfoResponse, AppWebsocketConnectionOptions } from "./types.js";
5
5
  import { WsClient } from "../client.js";
@@ -12,8 +12,10 @@ import { WsClient } from "../client.js";
12
12
  export declare class AppWebsocket implements AppClient {
13
13
  readonly client: WsClient;
14
14
  readonly myPubKey: AgentPubKey;
15
+ readonly installedAppId: InstalledAppId;
15
16
  private readonly defaultTimeout;
16
17
  private readonly emitter;
18
+ private readonly callZomeTransform;
17
19
  cachedAppInfo?: AppInfo | null;
18
20
  private readonly appInfoRequester;
19
21
  private readonly callZomeRequester;
@@ -18,8 +18,10 @@ import { WsClient } from "../client.js";
18
18
  export class AppWebsocket {
19
19
  client;
20
20
  myPubKey;
21
+ installedAppId;
21
22
  defaultTimeout;
22
23
  emitter;
24
+ callZomeTransform;
23
25
  cachedAppInfo;
24
26
  appInfoRequester;
25
27
  callZomeRequester;
@@ -27,14 +29,16 @@ export class AppWebsocket {
27
29
  enableCloneCellRequester;
28
30
  disableCloneCellRequester;
29
31
  networkInfoRequester;
30
- constructor(client, appInfo, defaultTimeout) {
32
+ constructor(client, appInfo, callZomeTransform, defaultTimeout) {
31
33
  this.client = client;
32
34
  this.myPubKey = appInfo.agent_pub_key;
35
+ this.installedAppId = appInfo.installed_app_id;
33
36
  this.defaultTimeout = defaultTimeout ?? DEFAULT_TIMEOUT;
37
+ this.callZomeTransform = callZomeTransform ?? defaultCallZomeTransform;
34
38
  this.emitter = new Emittery();
35
39
  this.cachedAppInfo = appInfo;
36
40
  this.appInfoRequester = AppWebsocket.requester(this.client, "app_info", this.defaultTimeout);
37
- this.callZomeRequester = AppWebsocket.requester(this.client, "call_zome", this.defaultTimeout, callZomeTransform);
41
+ this.callZomeRequester = AppWebsocket.requester(this.client, "call_zome", this.defaultTimeout, this.callZomeTransform);
38
42
  this.createCloneCellRequester = AppWebsocket.requester(this.client, "create_clone_cell", this.defaultTimeout);
39
43
  this.enableCloneCellRequester = AppWebsocket.requester(this.client, "enable_clone_cell", this.defaultTimeout);
40
44
  this.disableCloneCellRequester = AppWebsocket.requester(this.client, "disable_clone_cell", this.defaultTimeout);
@@ -85,7 +89,7 @@ export class AppWebsocket {
85
89
  if (!appInfo) {
86
90
  throw new HolochainError("AppNotFound", `The app your connection token was issued for was not found. The app needs to be installed and enabled.`);
87
91
  }
88
- return new AppWebsocket(client, appInfo, options.defaultTimeout);
92
+ return new AppWebsocket(client, appInfo, options.callZomeTransform, options.defaultTimeout);
89
93
  }
90
94
  /**
91
95
  * Request the app's info, including all cell infos.
@@ -236,7 +240,7 @@ export class AppWebsocket {
236
240
  return false;
237
241
  }
238
242
  }
239
- const callZomeTransform = {
243
+ const defaultCallZomeTransform = {
240
244
  input: async (request) => {
241
245
  if ("signature" in request) {
242
246
  return request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holochain/client",
3
- "version": "0.18.0-dev.0",
3
+ "version": "0.18.0-dev.1",
4
4
  "description": "A JavaScript client for the Holochain Conductor API",
5
5
  "author": "Holochain Foundation <info@holochain.org> (https://holochain.org)",
6
6
  "license": "CAL-1.0",