@holochain/conductor-api
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -114,2 +114,4 @@ /// <reference types="node" /> | ||
export declare type ListActiveAppsResponse = Array<InstalledAppId>; | ||
export declare type ListAppInterfacesRequest = void; | ||
export declare type ListAppInterfacesResponse = Array<number>; | ||
export declare type AgentInfoSigned = any; | ||
@@ -137,2 +139,3 @@ export declare type RequestAgentInfoRequest = { | ||
listActiveApps: Requester<ListActiveAppsRequest, ListActiveAppsResponse>; | ||
listAppInterfaces: Requester<ListAppInterfacesRequest, ListAppInterfacesResponse>; | ||
requestAgentInfo: Requester<RequestAgentInfoRequest, RequestAgentInfoResponse>; | ||
@@ -139,0 +142,0 @@ addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>; |
@@ -38,4 +38,5 @@ /** | ||
listActiveApps: Requester<Api.ListActiveAppsRequest, Api.ListActiveAppsResponse>; | ||
listAppInterfaces: Requester<Api.ListAppInterfacesRequest, Api.ListAppInterfacesResponse>; | ||
requestAgentInfo: Requester<Api.RequestAgentInfoRequest, Api.RequestAgentInfoResponse>; | ||
addAgentInfo: Requester<Api.AddAgentInfoRequest, Api.AddAgentInfoResponse>; | ||
} |
@@ -49,2 +49,3 @@ "use strict"; | ||
this.listActiveApps = this._requester('list_active_apps'); | ||
this.listAppInterfaces = this._requester('list_app_interfaces'); | ||
this.requestAgentInfo = this._requester('request_agent_info'); | ||
@@ -51,0 +52,0 @@ this.addAgentInfo = this._requester('add_agent_info'); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -49,3 +30,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
*/ | ||
const msgpack = __importStar(require("@msgpack/msgpack")); | ||
const msgpack_1 = require("@msgpack/msgpack"); | ||
const client_1 = require("./client"); | ||
@@ -72,9 +53,8 @@ const common_1 = require("./common"); | ||
input: (req) => { | ||
req.payload = msgpack.encode(req.payload); | ||
return req; | ||
return Object.assign(Object.assign({}, req), { payload: Buffer.from(msgpack_1.encode(req.payload)) }); | ||
}, | ||
output: (res) => { | ||
return msgpack.decode(res); | ||
return msgpack_1.decode(res); | ||
} | ||
}; | ||
//# sourceMappingURL=app.js.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -36,3 +17,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws")); | ||
const msgpack = __importStar(require("@msgpack/msgpack")); | ||
const msgpack_1 = require("@msgpack/msgpack"); | ||
/** | ||
@@ -57,6 +38,6 @@ * A Websocket client which can make requests and receive responses, | ||
} | ||
const msg = msgpack.decode(data); | ||
const msg = msgpack_1.decode(data); | ||
if (msg.type === "Signal") { | ||
if (signalCb) { | ||
const decodedMessage = msgpack.decode(msg.data); | ||
const decodedMessage = msgpack_1.decode(msg.data); | ||
// Note: holochain currently returns signals as an array of two values: cellId and the serialized signal payload | ||
@@ -89,5 +70,5 @@ // and this array is nested within the App key within the returned message. | ||
emitSignal(data) { | ||
const encodedMsg = msgpack.encode({ | ||
const encodedMsg = msgpack_1.encode({ | ||
type: "Signal", | ||
data: msgpack.encode(data), | ||
data: msgpack_1.encode(data), | ||
}); | ||
@@ -99,6 +80,6 @@ this.socket.send(encodedMsg); | ||
this.index += 1; | ||
const encodedMsg = msgpack.encode({ | ||
const encodedMsg = msgpack_1.encode({ | ||
id, | ||
type: "Request", | ||
data: msgpack.encode(data), | ||
data: msgpack_1.encode(data), | ||
}); | ||
@@ -124,3 +105,3 @@ const promise = new Promise((fulfill, reject) => { | ||
else { | ||
this.pendingRequests[id].fulfill(msgpack.decode(msg.data)); | ||
this.pendingRequests[id].fulfill(msgpack_1.decode(msg.data)); | ||
} | ||
@@ -156,4 +137,4 @@ } | ||
const signalTransform = (res) => { | ||
return msgpack.decode(res); | ||
return msgpack_1.decode(res); | ||
}; | ||
//# sourceMappingURL=client.js.map |
{ | ||
"name": "@holochain/conductor-api", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Encode/decode messages to/from the Holochain Conductor API over Websocket", | ||
@@ -12,3 +12,3 @@ "repository": { | ||
"scripts": { | ||
"build": "rm -rf ./lib ; tsc -d ", | ||
"build": "rm -rf ./lib ; tsc -d", | ||
"dev": "rm -rf ./lib ; tsc -d -w", | ||
@@ -23,5 +23,4 @@ "doc": "typedoc", | ||
"author": "", | ||
"license": "CAL-1.0", | ||
"dependencies": { | ||
"@msgpack/msgpack": "^2.1.0", | ||
"@msgpack/msgpack": "2.4.0", | ||
"@types/ws": "^7.2.4", | ||
@@ -28,0 +27,0 @@ "isomorphic-ws": "^4.0.1", |
@@ -28,3 +28,3 @@ # holochain/conductor-api | ||
### Use AdminWebsocket | ||
``` | ||
```typescript | ||
const admin = await AdminWebsocket.connect(`http://localhost:8000`, TIMEOUT) | ||
@@ -35,3 +35,3 @@ await admin.generateAgentPubKey() | ||
### Use AppWebsocket | ||
``` | ||
```typescript | ||
const signalCb = (signal: AppSignal) => { | ||
@@ -38,0 +38,0 @@ // impl... |
@@ -149,2 +149,5 @@ import { Requester } from "./common" | ||
export type ListAppInterfacesRequest = void | ||
export type ListAppInterfacesResponse = Array<number> | ||
// this type is meant to be opaque | ||
@@ -176,2 +179,3 @@ export type AgentInfoSigned = any | ||
listActiveApps: Requester<ListActiveAppsRequest, ListActiveAppsResponse> | ||
listAppInterfaces: Requester<ListAppInterfacesRequest, ListAppInterfacesResponse> | ||
requestAgentInfo: Requester<RequestAgentInfoRequest, RequestAgentInfoResponse> | ||
@@ -178,0 +182,0 @@ addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse> |
@@ -22,2 +22,3 @@ /** | ||
import { Transformer, requesterTransformer, Requester } from '../api/common' | ||
import {ListAppInterfacesRequest} from "../api/admin"; | ||
@@ -71,2 +72,4 @@ export class AdminWebsocket implements Api.AdminApi { | ||
= this._requester('list_active_apps') | ||
listAppInterfaces: Requester<Api.ListAppInterfacesRequest, Api.ListAppInterfacesResponse> | ||
= this._requester('list_app_interfaces') | ||
requestAgentInfo: Requester<Api.RequestAgentInfoRequest, Api.RequestAgentInfoResponse> | ||
@@ -73,0 +76,0 @@ = this._requester('request_agent_info') |
@@ -18,3 +18,3 @@ /** | ||
*/ | ||
import * as msgpack from '@msgpack/msgpack'; | ||
import { encode, decode} from '@msgpack/msgpack'; | ||
@@ -54,9 +54,11 @@ import { AppApi, CallZomeRequest, CallZomeResponse, AppInfoRequest, AppInfoResponse, CallZomeRequestGeneric, CallZomeResponseGeneric, AppSignalCb } from '../api/app' | ||
const callZomeTransform: Transformer<CallZomeRequestGeneric<any>, CallZomeRequestGeneric<Buffer>, CallZomeResponseGeneric<Buffer>, CallZomeResponseGeneric<any>> = { | ||
input: (req: CallZomeRequestGeneric<any>): CallZomeRequestGeneric<Buffer> => { | ||
req.payload = msgpack.encode(req.payload) | ||
return req | ||
input: (req: CallZomeRequestGeneric<any>): CallZomeRequestGeneric<Buffer> => { | ||
return { | ||
...req, | ||
payload: Buffer.from(encode(req.payload)) | ||
} | ||
}, | ||
output: (res: CallZomeResponseGeneric<Buffer>): CallZomeResponseGeneric<any> => { | ||
return msgpack.decode(res) | ||
return decode(res) | ||
} | ||
} |
import Websocket from "isomorphic-ws"; | ||
import * as msgpack from "@msgpack/msgpack"; | ||
import { encode, decode } from "@msgpack/msgpack"; | ||
import { nanoid } from "nanoid"; | ||
@@ -32,6 +32,6 @@ import { AppSignal, AppSignalCb, SignalResponseGeneric } from "../api/app"; | ||
const msg: any = msgpack.decode(data); | ||
const msg: any = decode(data); | ||
if (msg.type === "Signal") { | ||
if (signalCb) { | ||
const decodedMessage: SignalResponseGeneric<any> = msgpack.decode( | ||
const decodedMessage: SignalResponseGeneric<any> = decode( | ||
msg.data | ||
@@ -68,5 +68,5 @@ ); | ||
emitSignal(data: any) { | ||
const encodedMsg = msgpack.encode({ | ||
const encodedMsg = encode({ | ||
type: "Signal", | ||
data: msgpack.encode(data), | ||
data: encode(data), | ||
}); | ||
@@ -79,6 +79,6 @@ this.socket.send(encodedMsg); | ||
this.index += 1; | ||
const encodedMsg = msgpack.encode({ | ||
const encodedMsg = encode({ | ||
id, | ||
type: "Request", | ||
data: msgpack.encode(data), | ||
data: encode(data), | ||
}); | ||
@@ -105,3 +105,3 @@ const promise = new Promise((fulfill, reject) => { | ||
} else { | ||
this.pendingRequests[id].fulfill(msgpack.decode(msg.data)); | ||
this.pendingRequests[id].fulfill(decode(msg.data)); | ||
} | ||
@@ -145,3 +145,3 @@ } else { | ||
): SignalResponseGeneric<any> => { | ||
return msgpack.decode(res); | ||
return decode(res); | ||
}; |
@@ -169,2 +169,23 @@ const test = require('tape') | ||
test('can call a zome function twice, reusing args', withConductor(ADMIN_PORT, async t => { | ||
const [installed_app_id, cell_id, nick, client] = await installAppAndDna(ADMIN_PORT) | ||
const info = await client.appInfo({ installed_app_id }, 1000) | ||
t.deepEqual(info.cell_data[0].cell_id, cell_id) | ||
t.equal(info.cell_data[0].cell_nick, nick) | ||
const args = { | ||
// TODO: write a test with a real capability secret. | ||
cap: null, | ||
cell_id, | ||
zome_name: TEST_ZOME_NAME, | ||
fn_name: 'foo', | ||
provenance: fakeAgentPubKey('TODO'), | ||
payload: null, | ||
} | ||
const response = await client.callZome(args, 30000) | ||
t.equal(response, "foo") | ||
const response2 = await client.callZome(args, 30000) | ||
t.equal(response, "foo") | ||
})) | ||
test('can handle canceled response', withConductor(ADMIN_PORT, async t => { | ||
@@ -171,0 +192,0 @@ // const client = await WsClient.connect(`http://localhost:${ADMIN_PORT}`);A |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
100
120873
58
1765
+ Added@msgpack/msgpack@2.4.0(transitive)
- Removed@msgpack/msgpack@2.8.0(transitive)
Updated@msgpack/msgpack@2.4.0