hypha-rpc 0.20.18 → 0.20.19
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/dist/hypha-rpc-websocket.js +29 -49
- package/dist/hypha-rpc-websocket.js.map +1 -1
- package/dist/hypha-rpc-websocket.min.js +1 -1
- package/dist/hypha-rpc-websocket.min.js.map +1 -1
- package/dist/hypha-rpc-websocket.min.mjs +1 -1
- package/dist/hypha-rpc-websocket.min.mjs.map +1 -1
- package/dist/hypha-rpc-websocket.mjs +29 -49
- package/dist/hypha-rpc-websocket.mjs.map +1 -1
- package/index.d.ts +1 -2
- package/package.json +1 -1
- package/src/rpc.js +3 -1
- package/src/webrtc-client.js +11 -2
- package/src/websocket-client.js +15 -46
- package/tests/websocket_client_test.js +0 -1
|
@@ -742,7 +742,9 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
742
742
|
return _get_schema(service, null, skipContext);
|
|
743
743
|
}
|
|
744
744
|
|
|
745
|
-
async register_service(api,
|
|
745
|
+
async register_service(api, config) {
|
|
746
|
+
let { check_type, notify, overwrite } = config || {};
|
|
747
|
+
notify = notify === undefined ? true : notify;
|
|
746
748
|
let manager;
|
|
747
749
|
if (check_type && api.type) {
|
|
748
750
|
try {
|
|
@@ -2423,13 +2425,22 @@ async function getRTCService(server, service_id, config) {
|
|
|
2423
2425
|
pc.close();
|
|
2424
2426
|
}
|
|
2425
2427
|
pc.getService = (0,_utils_schema_js__WEBPACK_IMPORTED_MODULE_2__.schemaFunction)(get_service, {
|
|
2426
|
-
name: "
|
|
2428
|
+
name: "getService",
|
|
2427
2429
|
description: "Get a remote service via webrtc",
|
|
2428
2430
|
parameters: {
|
|
2429
2431
|
type: "object",
|
|
2430
2432
|
properties: {
|
|
2431
|
-
|
|
2433
|
+
service_id: {
|
|
2434
|
+
type: "string",
|
|
2435
|
+
description:
|
|
2436
|
+
"Service ID. This should be a service id in the format: 'workspace/service_id', 'workspace/client_id:service_id' or 'workspace/client_id:service_id@app_id'",
|
|
2437
|
+
},
|
|
2438
|
+
config: {
|
|
2439
|
+
type: "object",
|
|
2440
|
+
description: "Options for the service",
|
|
2441
|
+
},
|
|
2432
2442
|
},
|
|
2443
|
+
required: ["id"],
|
|
2433
2444
|
},
|
|
2434
2445
|
});
|
|
2435
2446
|
pc.disconnect = (0,_utils_schema_js__WEBPACK_IMPORTED_MODULE_2__.schemaFunction)(disconnect, {
|
|
@@ -4816,7 +4827,7 @@ async function webrtcGetService(wm, rtc_service_id, query, config) {
|
|
|
4816
4827
|
try {
|
|
4817
4828
|
// Assuming that the client registered a webrtc service with the client_id + "-rtc"
|
|
4818
4829
|
const peer = await (0,_webrtc_client_js__WEBPACK_IMPORTED_MODULE_3__.getRTCService)(wm, rtc_service_id, webrtc_config);
|
|
4819
|
-
const rtcSvc = await peer.
|
|
4830
|
+
const rtcSvc = await peer.getService(svc.id.split(":")[1], config);
|
|
4820
4831
|
rtcSvc._webrtc = true;
|
|
4821
4832
|
rtcSvc._peer = peer;
|
|
4822
4833
|
rtcSvc._service = svc;
|
|
@@ -4887,7 +4898,7 @@ async function connectToServer(config) {
|
|
|
4887
4898
|
api.id = "default";
|
|
4888
4899
|
api.name = api.name || config.name || api.id;
|
|
4889
4900
|
api.description = api.description || config.description;
|
|
4890
|
-
await rpc.register_service(api, true);
|
|
4901
|
+
await rpc.register_service(api, { overwrite: true });
|
|
4891
4902
|
}
|
|
4892
4903
|
|
|
4893
4904
|
async function getApp(clientId) {
|
|
@@ -5051,29 +5062,18 @@ async function connectToServer(config) {
|
|
|
5051
5062
|
});
|
|
5052
5063
|
}
|
|
5053
5064
|
if (config.webrtc) {
|
|
5054
|
-
await (0,_webrtc_client_js__WEBPACK_IMPORTED_MODULE_3__.registerRTCService)(wm, clientId
|
|
5065
|
+
await (0,_webrtc_client_js__WEBPACK_IMPORTED_MODULE_3__.registerRTCService)(wm, `${clientId}-rtc`, config.webrtc_config);
|
|
5055
5066
|
// make a copy of wm, so webrtc can use the original wm.getService
|
|
5056
5067
|
const _wm = Object.assign({}, wm);
|
|
5068
|
+
const description = _wm.getService.__schema__.description;
|
|
5069
|
+
// TODO: Fix the schema for adding options for webrtc
|
|
5070
|
+
const parameters = _wm.getService.__schema__.parameters;
|
|
5057
5071
|
wm.getService = (0,_utils_schema_js__WEBPACK_IMPORTED_MODULE_2__.schemaFunction)(
|
|
5058
|
-
webrtcGetService.bind(null, _wm, clientId
|
|
5072
|
+
webrtcGetService.bind(null, _wm, `${workspace}/${clientId}-rtc`),
|
|
5059
5073
|
{
|
|
5060
5074
|
name: "getService",
|
|
5061
|
-
description
|
|
5062
|
-
parameters
|
|
5063
|
-
properties: {
|
|
5064
|
-
query: {
|
|
5065
|
-
description: "The query to get the service",
|
|
5066
|
-
type: "object",
|
|
5067
|
-
},
|
|
5068
|
-
config: {
|
|
5069
|
-
description:
|
|
5070
|
-
"The config for the service, including `webrtc`, `webrtc_config` and other get_service options",
|
|
5071
|
-
type: "object",
|
|
5072
|
-
},
|
|
5073
|
-
},
|
|
5074
|
-
required: ["query"],
|
|
5075
|
-
type: "object",
|
|
5076
|
-
},
|
|
5075
|
+
description,
|
|
5076
|
+
parameters,
|
|
5077
5077
|
},
|
|
5078
5078
|
);
|
|
5079
5079
|
|
|
@@ -5093,32 +5093,12 @@ async function connectToServer(config) {
|
|
|
5093
5093
|
});
|
|
5094
5094
|
} else {
|
|
5095
5095
|
const _getService = wm.getService;
|
|
5096
|
-
wm.getService = (
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
{
|
|
5103
|
-
name: "getService",
|
|
5104
|
-
description: "Get a service.",
|
|
5105
|
-
parameters: {
|
|
5106
|
-
properties: {
|
|
5107
|
-
query: {
|
|
5108
|
-
description: "The query to get the service",
|
|
5109
|
-
type: "object",
|
|
5110
|
-
},
|
|
5111
|
-
config: {
|
|
5112
|
-
description:
|
|
5113
|
-
"The config for the service, including `webrtc`, `webrtc_config` and other get_service options",
|
|
5114
|
-
type: "object",
|
|
5115
|
-
},
|
|
5116
|
-
},
|
|
5117
|
-
required: ["query"],
|
|
5118
|
-
type: "object",
|
|
5119
|
-
},
|
|
5120
|
-
},
|
|
5121
|
-
);
|
|
5096
|
+
wm.getService = (query, config) => {
|
|
5097
|
+
config = config || {};
|
|
5098
|
+
config.case_conversion = config.case_conversion || "camel";
|
|
5099
|
+
return _getService(query, config);
|
|
5100
|
+
};
|
|
5101
|
+
wm.getService.__schema__ = _getService.__schema__;
|
|
5122
5102
|
}
|
|
5123
5103
|
return wm;
|
|
5124
5104
|
}
|