hypha-rpc 0.20.60 → 0.20.61
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 +122 -110
- 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 +122 -110
- package/dist/hypha-rpc-websocket.mjs.map +1 -1
- package/package.json +1 -1
- package/src/rpc.js +50 -38
- package/src/utils/schema.js +1 -1
- package/src/webrtc-client.js +1 -1
- package/src/websocket-client.js +1 -1
- package/tests/websocket_client_test.js +212 -0
|
@@ -23,8 +23,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23
23
|
/* harmony export */ API_VERSION: () => (/* binding */ API_VERSION),
|
|
24
24
|
/* harmony export */ RPC: () => (/* binding */ RPC)
|
|
25
25
|
/* harmony export */ });
|
|
26
|
-
/* harmony import */ var
|
|
27
|
-
/* harmony import */ var
|
|
26
|
+
/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils/index.js */ "./src/utils/index.js");
|
|
27
|
+
/* harmony import */ var _utils_schema_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils/schema.js */ "./src/utils/schema.js");
|
|
28
28
|
/* harmony import */ var _msgpack_msgpack__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @msgpack/msgpack */ "./node_modules/@msgpack/msgpack/dist.es5+esm/decode.mjs");
|
|
29
29
|
/* harmony import */ var _msgpack_msgpack__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @msgpack/msgpack */ "./node_modules/@msgpack/msgpack/dist.es5+esm/encode.mjs");
|
|
30
30
|
/**
|
|
@@ -123,7 +123,7 @@ function _annotate_service(service, serviceTypeInfo) {
|
|
|
123
123
|
annotateRecursive(v, schemaInfo[k], newPath);
|
|
124
124
|
} else if (typeof v === "function") {
|
|
125
125
|
if (schemaInfo.hasOwnProperty(k)) {
|
|
126
|
-
newService[k] = (0,
|
|
126
|
+
newService[k] = (0,_utils_schema_js__WEBPACK_IMPORTED_MODULE_1__.schemaFunction)(v, {
|
|
127
127
|
name: schemaInfo[k]["name"],
|
|
128
128
|
description: schemaInfo[k].description || "",
|
|
129
129
|
parameters: schemaInfo[k]["parameters"],
|
|
@@ -145,7 +145,7 @@ function _annotate_service(service, serviceTypeInfo) {
|
|
|
145
145
|
annotateRecursive(v, schemaInfo[i], newPath);
|
|
146
146
|
} else if (typeof v === "function") {
|
|
147
147
|
if (schemaInfo.hasOwnProperty(i)) {
|
|
148
|
-
newService[i] = (0,
|
|
148
|
+
newService[i] = (0,_utils_schema_js__WEBPACK_IMPORTED_MODULE_1__.schemaFunction)(v, {
|
|
149
149
|
name: schemaInfo[i]["name"],
|
|
150
150
|
description: schemaInfo[i].description || "",
|
|
151
151
|
parameters: schemaInfo[i]["parameters"],
|
|
@@ -280,7 +280,7 @@ class RemoteService extends Object {}
|
|
|
280
280
|
* and receive messages from the opposite site (basically it
|
|
281
281
|
* should only provide send() and onMessage() methods)
|
|
282
282
|
*/
|
|
283
|
-
class RPC extends
|
|
283
|
+
class RPC extends _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
284
284
|
constructor(
|
|
285
285
|
connection,
|
|
286
286
|
{
|
|
@@ -300,8 +300,8 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
300
300
|
) {
|
|
301
301
|
super(debug);
|
|
302
302
|
this._codecs = codecs || {};
|
|
303
|
-
(0,
|
|
304
|
-
(0,
|
|
303
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(client_id && typeof client_id === "string");
|
|
304
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(client_id, "client_id is required");
|
|
305
305
|
this._client_id = client_id;
|
|
306
306
|
this._name = name;
|
|
307
307
|
this._app_id = app_id || "*";
|
|
@@ -344,8 +344,8 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
344
344
|
this.on("method", this._handle_method.bind(this));
|
|
345
345
|
this.on("error", console.error);
|
|
346
346
|
|
|
347
|
-
(0,
|
|
348
|
-
(0,
|
|
347
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(connection.emit_message && connection.on_message);
|
|
348
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
349
349
|
connection.manager_id !== undefined,
|
|
350
350
|
"Connection must have manager_id",
|
|
351
351
|
);
|
|
@@ -428,7 +428,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
async _ping(msg, context) {
|
|
431
|
-
(0,
|
|
431
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(msg == "ping");
|
|
432
432
|
return "pong";
|
|
433
433
|
}
|
|
434
434
|
|
|
@@ -440,7 +440,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
440
440
|
_rpromise: true,
|
|
441
441
|
_rdoc: "Ping a remote client",
|
|
442
442
|
});
|
|
443
|
-
(0,
|
|
443
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)((await method("ping", timeout)) == "pong");
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
_create_message(key, heartbeat, overwrite, context) {
|
|
@@ -473,7 +473,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
473
473
|
if (!cache[key]) {
|
|
474
474
|
throw new Error(`Message with key ${key} does not exists.`);
|
|
475
475
|
}
|
|
476
|
-
(0,
|
|
476
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(data instanceof ArrayBufferView);
|
|
477
477
|
cache[key].push(data);
|
|
478
478
|
}
|
|
479
479
|
|
|
@@ -488,7 +488,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
488
488
|
if (!cache[key]) {
|
|
489
489
|
throw new Error(`Message with key ${key} does not exists.`);
|
|
490
490
|
}
|
|
491
|
-
(0,
|
|
491
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(data instanceof ArrayBufferView);
|
|
492
492
|
cache[key][index] = data;
|
|
493
493
|
}
|
|
494
494
|
|
|
@@ -508,7 +508,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
508
508
|
this._object_store[key]["timer"].reset();
|
|
509
509
|
}
|
|
510
510
|
const cache = this._object_store["message_cache"];
|
|
511
|
-
(0,
|
|
511
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(!!context, "Context is required");
|
|
512
512
|
if (!cache[key]) {
|
|
513
513
|
throw new Error(`Message with key ${key} does not exists.`);
|
|
514
514
|
}
|
|
@@ -630,9 +630,9 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
630
630
|
return this._services;
|
|
631
631
|
}
|
|
632
632
|
get_local_service(service_id, context) {
|
|
633
|
-
(0,
|
|
633
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(service_id);
|
|
634
634
|
const [ws, client_id] = context["to"].split("/");
|
|
635
|
-
(0,
|
|
635
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
636
636
|
client_id === this._client_id,
|
|
637
637
|
"Services can only be accessed locally",
|
|
638
638
|
);
|
|
@@ -671,12 +671,12 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
671
671
|
service_id = service_id.split("@")[0];
|
|
672
672
|
const app_id = service_uri.split("@")[1];
|
|
673
673
|
if (this._app_id && this._app_id !== "*")
|
|
674
|
-
(0,
|
|
674
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
675
675
|
app_id === this._app_id,
|
|
676
676
|
`Invalid app id: ${app_id} != ${this._app_id}`,
|
|
677
677
|
);
|
|
678
678
|
}
|
|
679
|
-
(0,
|
|
679
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(provider, `Invalid service uri: ${service_uri}`);
|
|
680
680
|
|
|
681
681
|
try {
|
|
682
682
|
const method = this._generate_remote_method({
|
|
@@ -686,19 +686,19 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
686
686
|
_rpromise: true,
|
|
687
687
|
_rdoc: "Get a remote service",
|
|
688
688
|
});
|
|
689
|
-
let svc = await (0,
|
|
689
|
+
let svc = await (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.waitFor)(
|
|
690
690
|
method(service_id),
|
|
691
691
|
timeout,
|
|
692
692
|
"Timeout Error: Failed to get remote service: " + service_uri,
|
|
693
693
|
);
|
|
694
694
|
svc.id = `${provider}:${service_id}`;
|
|
695
695
|
if (kwargs_expansion) {
|
|
696
|
-
svc = (0,
|
|
696
|
+
svc = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.expandKwargs)(svc);
|
|
697
697
|
}
|
|
698
698
|
if (case_conversion)
|
|
699
699
|
return Object.assign(
|
|
700
700
|
new RemoteService(),
|
|
701
|
-
(0,
|
|
701
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.convertCase)(svc, case_conversion),
|
|
702
702
|
);
|
|
703
703
|
else return Object.assign(new RemoteService(), svc);
|
|
704
704
|
} catch (e) {
|
|
@@ -777,7 +777,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
777
777
|
api.id = api.id || "default";
|
|
778
778
|
api = normApi;
|
|
779
779
|
}
|
|
780
|
-
(0,
|
|
780
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
781
781
|
api.id && typeof api.id === "string",
|
|
782
782
|
`Service id not found: ${api}`,
|
|
783
783
|
);
|
|
@@ -797,7 +797,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
797
797
|
require_context = api.config.require_context;
|
|
798
798
|
if (api.config.run_in_executor) run_in_executor = true;
|
|
799
799
|
const visibility = api.config.visibility || "protected";
|
|
800
|
-
(0,
|
|
800
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(["protected", "public"].includes(visibility));
|
|
801
801
|
this._annotate_service_methods(
|
|
802
802
|
api,
|
|
803
803
|
api["id"],
|
|
@@ -886,7 +886,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
886
886
|
} else {
|
|
887
887
|
service_id = service.id;
|
|
888
888
|
}
|
|
889
|
-
(0,
|
|
889
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
890
890
|
service_id && typeof service_id === "string",
|
|
891
891
|
`Invalid service id: ${service_id}`,
|
|
892
892
|
);
|
|
@@ -910,7 +910,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
910
910
|
}
|
|
911
911
|
|
|
912
912
|
_ndarray(typedArray, shape, dtype) {
|
|
913
|
-
const _dtype = (0,
|
|
913
|
+
const _dtype = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.typedArrayToDtype)(typedArray);
|
|
914
914
|
if (dtype && dtype !== _dtype) {
|
|
915
915
|
throw (
|
|
916
916
|
"dtype doesn't match the type of the array: " + _dtype + " != " + dtype
|
|
@@ -953,12 +953,20 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
953
953
|
`Error in callback(${method_id}, ${description}): ${error}`,
|
|
954
954
|
);
|
|
955
955
|
} finally {
|
|
956
|
+
// Clear the timer first if it exists
|
|
956
957
|
if (timer && timer.started) {
|
|
957
958
|
timer.clear();
|
|
958
959
|
}
|
|
960
|
+
|
|
961
|
+
// Clean up the entire session when resolve/reject is called
|
|
959
962
|
if (clear_after_called && self._object_store[session_id]) {
|
|
960
|
-
//
|
|
961
|
-
|
|
963
|
+
// For promise callbacks (resolve/reject), clean up the entire session
|
|
964
|
+
if (name === "resolve" || name === "reject") {
|
|
965
|
+
delete self._object_store[session_id];
|
|
966
|
+
} else {
|
|
967
|
+
// For other callbacks, just clean up this specific callback
|
|
968
|
+
self._cleanup_session_if_needed(session_id, name);
|
|
969
|
+
}
|
|
962
970
|
}
|
|
963
971
|
}
|
|
964
972
|
};
|
|
@@ -968,31 +976,22 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
968
976
|
|
|
969
977
|
// Clean session management - all logic in one place
|
|
970
978
|
_cleanup_session_if_needed(session_id, callback_name) {
|
|
971
|
-
|
|
972
|
-
if (
|
|
973
|
-
|
|
974
|
-
// Promise sessions: let the promise manager decide cleanup
|
|
975
|
-
if (store._promise_manager) {
|
|
976
|
-
if (store._promise_manager.should_cleanup_on_callback(callback_name)) {
|
|
977
|
-
store._promise_manager.settle();
|
|
978
|
-
delete this._object_store[session_id];
|
|
979
|
-
}
|
|
980
|
-
return;
|
|
979
|
+
// Python-style immediate cleanup - no complex logic needed
|
|
980
|
+
if (this._object_store[session_id]) {
|
|
981
|
+
delete this._object_store[session_id];
|
|
981
982
|
}
|
|
982
|
-
|
|
983
|
-
// Regular sessions: cleanup immediately
|
|
984
|
-
delete this._object_store[session_id];
|
|
985
983
|
}
|
|
986
984
|
|
|
987
985
|
// Clean helper to identify promise method calls by session type
|
|
988
986
|
_is_promise_method_call(method_path) {
|
|
989
987
|
const session_id = method_path.split(".")[0];
|
|
990
|
-
|
|
991
|
-
return
|
|
988
|
+
// Simply check if session exists - no complex promise manager needed
|
|
989
|
+
return this._object_store[session_id] !== undefined;
|
|
992
990
|
}
|
|
993
991
|
|
|
994
|
-
//
|
|
992
|
+
// Simplified Promise Manager - no complex lifecycle needed
|
|
995
993
|
_create_promise_manager() {
|
|
994
|
+
// Return minimal manager - Python doesn't need complex promise tracking
|
|
996
995
|
return {
|
|
997
996
|
settled: false,
|
|
998
997
|
settle() {
|
|
@@ -1002,6 +1001,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1002
1001
|
return this.settled;
|
|
1003
1002
|
},
|
|
1004
1003
|
should_cleanup_on_callback(callback_name) {
|
|
1004
|
+
// Always cleanup on resolve/reject like Python
|
|
1005
1005
|
return callback_name === "resolve" || callback_name === "reject";
|
|
1006
1006
|
},
|
|
1007
1007
|
};
|
|
@@ -1025,9 +1025,8 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1025
1025
|
}
|
|
1026
1026
|
let encoded = {};
|
|
1027
1027
|
|
|
1028
|
-
//
|
|
1029
|
-
store
|
|
1030
|
-
|
|
1028
|
+
// Simplified promise lifecycle - no complex manager needed
|
|
1029
|
+
// Just store the timer if needed
|
|
1031
1030
|
if (timer && reject && this._method_timeout) {
|
|
1032
1031
|
[encoded.heartbeat, store.heartbeat] = this._encode_callback(
|
|
1033
1032
|
"heartbeat",
|
|
@@ -1041,11 +1040,12 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1041
1040
|
encoded.interval = this._method_timeout / 2;
|
|
1042
1041
|
}
|
|
1043
1042
|
|
|
1043
|
+
// Always use immediate cleanup like Python
|
|
1044
1044
|
[encoded.resolve, store.resolve] = this._encode_callback(
|
|
1045
1045
|
"resolve",
|
|
1046
1046
|
resolve,
|
|
1047
1047
|
session_id,
|
|
1048
|
-
|
|
1048
|
+
true, // Always cleanup immediately
|
|
1049
1049
|
timer,
|
|
1050
1050
|
local_workspace,
|
|
1051
1051
|
`resolve (${description})`,
|
|
@@ -1054,7 +1054,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1054
1054
|
"reject",
|
|
1055
1055
|
reject,
|
|
1056
1056
|
session_id,
|
|
1057
|
-
|
|
1057
|
+
true, // Always cleanup immediately
|
|
1058
1058
|
timer,
|
|
1059
1059
|
local_workspace,
|
|
1060
1060
|
`reject (${description})`,
|
|
@@ -1074,13 +1074,13 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
|
|
1076
1076
|
const message_cache = remote_services.message_cache;
|
|
1077
|
-
const message_id = session_id || (0,
|
|
1077
|
+
const message_id = session_id || (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.randId)();
|
|
1078
1078
|
const total_size = data.length;
|
|
1079
1079
|
const start_time = Date.now(); // measure time
|
|
1080
1080
|
const chunk_num = Math.ceil(total_size / this._long_message_chunk_size);
|
|
1081
1081
|
if (remote_services.config.api_version >= 3) {
|
|
1082
1082
|
await message_cache.create(message_id, !!session_id);
|
|
1083
|
-
const semaphore = new
|
|
1083
|
+
const semaphore = new _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.Semaphore(CONCURRENCY_LIMIT);
|
|
1084
1084
|
|
|
1085
1085
|
const tasks = [];
|
|
1086
1086
|
for (let idx = 0; idx < chunk_num; idx++) {
|
|
@@ -1136,7 +1136,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
1138
|
emit(main_message, extra_data) {
|
|
1139
|
-
(0,
|
|
1139
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1140
1140
|
typeof main_message === "object" && main_message.type,
|
|
1141
1141
|
"Invalid message, must be an object with a `type` fields.",
|
|
1142
1142
|
);
|
|
@@ -1178,7 +1178,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1178
1178
|
|
|
1179
1179
|
function remote_method() {
|
|
1180
1180
|
return new Promise(async (resolve, reject) => {
|
|
1181
|
-
let local_session_id = (0,
|
|
1181
|
+
let local_session_id = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.randId)();
|
|
1182
1182
|
if (local_parent) {
|
|
1183
1183
|
// Store the children session under the parent
|
|
1184
1184
|
local_session_id = local_parent + "." + local_session_id;
|
|
@@ -1369,7 +1369,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1369
1369
|
let reject = null;
|
|
1370
1370
|
let heartbeat_task = null;
|
|
1371
1371
|
try {
|
|
1372
|
-
(0,
|
|
1372
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(data.method && data.ctx && data.from);
|
|
1373
1373
|
const method_name = data.from + ":" + data.method;
|
|
1374
1374
|
const remote_workspace = data.from.split("/")[0];
|
|
1375
1375
|
const remote_client_id = data.from.split("/")[1];
|
|
@@ -1383,7 +1383,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1383
1383
|
local_workspace = data["to"].split("/")[0];
|
|
1384
1384
|
} else {
|
|
1385
1385
|
if (this._local_workspace && this._local_workspace !== "*") {
|
|
1386
|
-
(0,
|
|
1386
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1387
1387
|
data["to"].split("/")[0] === this._local_workspace,
|
|
1388
1388
|
"Workspace mismatch: " +
|
|
1389
1389
|
data["to"].split("/")[0] +
|
|
@@ -1433,10 +1433,10 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1433
1433
|
try {
|
|
1434
1434
|
method = indexObject(this._object_store, data["method"]);
|
|
1435
1435
|
} catch (e) {
|
|
1436
|
-
//
|
|
1437
|
-
if (this.
|
|
1436
|
+
// Simplified error handling like Python - just check if method exists
|
|
1437
|
+
if (!this._object_store[data["method"].split(".")[0]]) {
|
|
1438
1438
|
console.debug(
|
|
1439
|
-
`
|
|
1439
|
+
`Method ${data["method"]} not available (session cleaned up), ignoring: ${method_name}`,
|
|
1440
1440
|
);
|
|
1441
1441
|
return;
|
|
1442
1442
|
}
|
|
@@ -1446,7 +1446,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1446
1446
|
);
|
|
1447
1447
|
}
|
|
1448
1448
|
|
|
1449
|
-
(0,
|
|
1449
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1450
1450
|
method && typeof method === "function",
|
|
1451
1451
|
"Invalid method: " + method_name,
|
|
1452
1452
|
);
|
|
@@ -1496,7 +1496,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1496
1496
|
// Make sure the parent session is still open
|
|
1497
1497
|
if (local_parent) {
|
|
1498
1498
|
// The parent session should be a session that generate the current method call
|
|
1499
|
-
(0,
|
|
1499
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1500
1500
|
this._get_session_store(local_parent, true) !== null,
|
|
1501
1501
|
"Parent session was closed: " + local_parent,
|
|
1502
1502
|
);
|
|
@@ -1517,18 +1517,30 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1517
1517
|
this._method_annotations.has(method) &&
|
|
1518
1518
|
this._method_annotations.get(method).require_context
|
|
1519
1519
|
) {
|
|
1520
|
-
// if
|
|
1521
|
-
//
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1520
|
+
// Check if this is a remote service (from external clients)
|
|
1521
|
+
// Remote services start with a session ID or client ID, not "services."
|
|
1522
|
+
const isRemoteService = !data.method.startsWith("services.");
|
|
1523
|
+
|
|
1524
|
+
if (isRemoteService) {
|
|
1525
|
+
// For remote services (external client services), the method.length reflects
|
|
1526
|
+
// the original signature and cannot be modified. We inject context as the last argument
|
|
1527
|
+
// and skip the strict argument validation that fails for external services.
|
|
1528
|
+
args.push(data.ctx);
|
|
1529
|
+
} else {
|
|
1530
|
+
// For local services, use the existing logic with padding and validation
|
|
1531
|
+
// if args.length + 1 is less than the required number of arguments we will pad with undefined
|
|
1532
|
+
// so we make sure the last argument is the context
|
|
1533
|
+
if (args.length + 1 < method.length) {
|
|
1534
|
+
for (let i = args.length; i < method.length - 1; i++) {
|
|
1535
|
+
args.push(undefined);
|
|
1536
|
+
}
|
|
1525
1537
|
}
|
|
1538
|
+
args.push(data.ctx);
|
|
1539
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1540
|
+
args.length === method.length,
|
|
1541
|
+
`Runtime Error: Invalid number of arguments for method ${method_name}, expected ${method.length} but got ${args.length}`,
|
|
1542
|
+
);
|
|
1526
1543
|
}
|
|
1527
|
-
args.push(data.ctx);
|
|
1528
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1529
|
-
args.length === method.length,
|
|
1530
|
-
`Runtime Error: Invalid number of arguments for method ${method_name}, expected ${method.length} but got ${args.length}`,
|
|
1531
|
-
);
|
|
1532
1544
|
}
|
|
1533
1545
|
// console.debug(`Executing method: ${method_name} (${data.method})`);
|
|
1534
1546
|
if (data.promise) {
|
|
@@ -1652,23 +1664,23 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1652
1664
|
return bObject;
|
|
1653
1665
|
}
|
|
1654
1666
|
|
|
1655
|
-
if ((0,
|
|
1667
|
+
if ((0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.isGenerator)(aObject) || (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.isAsyncGenerator)(aObject)) {
|
|
1656
1668
|
// Handle generator functions and generator objects
|
|
1657
|
-
(0,
|
|
1669
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1658
1670
|
session_id && typeof session_id === "string",
|
|
1659
1671
|
"Session ID is required for generator encoding",
|
|
1660
1672
|
);
|
|
1661
|
-
const object_id = (0,
|
|
1673
|
+
const object_id = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.randId)();
|
|
1662
1674
|
|
|
1663
1675
|
// Get the session store
|
|
1664
1676
|
const store = this._get_session_store(session_id, true);
|
|
1665
|
-
(0,
|
|
1677
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1666
1678
|
store !== null,
|
|
1667
1679
|
`Failed to create session store ${session_id} due to invalid parent`,
|
|
1668
1680
|
);
|
|
1669
1681
|
|
|
1670
1682
|
// Check if it's an async generator
|
|
1671
|
-
const isAsync = (0,
|
|
1683
|
+
const isAsync = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.isAsyncGenerator)(aObject);
|
|
1672
1684
|
|
|
1673
1685
|
// Define method to get next item from the generator
|
|
1674
1686
|
const nextItemMethod = async () => {
|
|
@@ -1716,12 +1728,12 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1716
1728
|
_rname: aObject.name,
|
|
1717
1729
|
};
|
|
1718
1730
|
} else {
|
|
1719
|
-
(0,
|
|
1731
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(typeof session_id === "string");
|
|
1720
1732
|
let object_id;
|
|
1721
1733
|
if (aObject.__name__) {
|
|
1722
|
-
object_id = `${(0,
|
|
1734
|
+
object_id = `${(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.randId)()}#${aObject.__name__}`;
|
|
1723
1735
|
} else {
|
|
1724
|
-
object_id = (0,
|
|
1736
|
+
object_id = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.randId)();
|
|
1725
1737
|
}
|
|
1726
1738
|
bObject = {
|
|
1727
1739
|
_rtype: "method",
|
|
@@ -1732,7 +1744,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1732
1744
|
_rname: aObject.name,
|
|
1733
1745
|
};
|
|
1734
1746
|
let store = this._get_session_store(session_id, true);
|
|
1735
|
-
(0,
|
|
1747
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
1736
1748
|
store !== null,
|
|
1737
1749
|
`Failed to create session store ${session_id} due to invalid parent`,
|
|
1738
1750
|
);
|
|
@@ -1798,7 +1810,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1798
1810
|
if (!aObject.selection || !aObject.selection.data) {
|
|
1799
1811
|
throw new Error("Invalid NumJS array: missing selection or data");
|
|
1800
1812
|
}
|
|
1801
|
-
const dtype = (0,
|
|
1813
|
+
const dtype = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.typedArrayToDtype)(aObject.selection.data);
|
|
1802
1814
|
bObject = {
|
|
1803
1815
|
_rtype: "ndarray",
|
|
1804
1816
|
_rvalue: new Uint8Array(aObject.selection.data.buffer),
|
|
@@ -1861,7 +1873,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1861
1873
|
seek: await this._encode(seek, session_id, local_workspace),
|
|
1862
1874
|
};
|
|
1863
1875
|
} else if (aObject instanceof ArrayBufferView) {
|
|
1864
|
-
const dtype = (0,
|
|
1876
|
+
const dtype = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__.typedArrayToDtype)(aObject);
|
|
1865
1877
|
bObject = {
|
|
1866
1878
|
_rtype: "typedarray",
|
|
1867
1879
|
_rvalue: new Uint8Array(aObject.buffer),
|
|
@@ -1993,7 +2005,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1993
2005
|
if (Array.isArray(aObject._rvalue)) {
|
|
1994
2006
|
aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);
|
|
1995
2007
|
}
|
|
1996
|
-
const arraytype =
|
|
2008
|
+
const arraytype = _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.dtypeToTypedArray[aObject._rdtype];
|
|
1997
2009
|
bObject = tf.tensor(
|
|
1998
2010
|
new arraytype(aObject._rvalue),
|
|
1999
2011
|
aObject._rshape,
|
|
@@ -2008,7 +2020,7 @@ class RPC extends _utils__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
2008
2020
|
"RemoteError: " + aObject._rvalue + "\n" + (aObject._rtrace || ""),
|
|
2009
2021
|
);
|
|
2010
2022
|
} else if (aObject._rtype === "typedarray") {
|
|
2011
|
-
const arraytype =
|
|
2023
|
+
const arraytype = _utils_index_js__WEBPACK_IMPORTED_MODULE_0__.dtypeToTypedArray[aObject._rdtype];
|
|
2012
2024
|
if (!arraytype)
|
|
2013
2025
|
throw new Error("unsupported dtype: " + aObject._rdtype);
|
|
2014
2026
|
const buffer = aObject._rvalue.buffer.slice(
|
|
@@ -2719,7 +2731,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2719
2731
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2720
2732
|
/* harmony export */ schemaFunction: () => (/* binding */ schemaFunction)
|
|
2721
2733
|
/* harmony export */ });
|
|
2722
|
-
/* harmony import */ var
|
|
2734
|
+
/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index.js */ "./src/utils/index.js");
|
|
2723
2735
|
|
|
2724
2736
|
|
|
2725
2737
|
function schemaFunction(
|
|
@@ -2729,9 +2741,9 @@ function schemaFunction(
|
|
|
2729
2741
|
if (!func || typeof func !== "function") {
|
|
2730
2742
|
throw Error("func should be a function");
|
|
2731
2743
|
}
|
|
2732
|
-
(0,
|
|
2733
|
-
(0,
|
|
2734
|
-
(0,
|
|
2744
|
+
(0,_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(schema_type === "auto", "schema_type should be auto");
|
|
2745
|
+
(0,_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(name, "name should not be null");
|
|
2746
|
+
(0,_index_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
2735
2747
|
parameters && parameters.type === "object",
|
|
2736
2748
|
"parameters should be an object",
|
|
2737
2749
|
);
|
|
@@ -2758,7 +2770,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2758
2770
|
/* harmony export */ registerRTCService: () => (/* binding */ registerRTCService)
|
|
2759
2771
|
/* harmony export */ });
|
|
2760
2772
|
/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rpc.js */ "./src/rpc.js");
|
|
2761
|
-
/* harmony import */ var
|
|
2773
|
+
/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils/index.js */ "./src/utils/index.js");
|
|
2762
2774
|
/* harmony import */ var _utils_schema_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils/schema.js */ "./src/utils/schema.js");
|
|
2763
2775
|
|
|
2764
2776
|
|
|
@@ -2806,12 +2818,12 @@ class WebRTCConnection {
|
|
|
2806
2818
|
}
|
|
2807
2819
|
|
|
2808
2820
|
on_message(handler) {
|
|
2809
|
-
(0,
|
|
2821
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(handler, "handler is required");
|
|
2810
2822
|
this._handle_message = handler;
|
|
2811
2823
|
}
|
|
2812
2824
|
|
|
2813
2825
|
async emit_message(data) {
|
|
2814
|
-
(0,
|
|
2826
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(this._handle_message, "No handler for message");
|
|
2815
2827
|
try {
|
|
2816
2828
|
this._last_message = data;
|
|
2817
2829
|
this._data_channel.send(data);
|
|
@@ -2830,10 +2842,10 @@ class WebRTCConnection {
|
|
|
2830
2842
|
}
|
|
2831
2843
|
|
|
2832
2844
|
async function _setupRPC(config) {
|
|
2833
|
-
(0,
|
|
2834
|
-
(0,
|
|
2845
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(config.channel, "No channel provided");
|
|
2846
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(config.workspace, "No workspace provided");
|
|
2835
2847
|
const channel = config.channel;
|
|
2836
|
-
const clientId = config.client_id || (0,
|
|
2848
|
+
const clientId = config.client_id || (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.randId)();
|
|
2837
2849
|
const connection = new WebRTCConnection(channel);
|
|
2838
2850
|
config.context = config.context || {};
|
|
2839
2851
|
config.context.connection_type = "webrtc";
|
|
@@ -2913,7 +2925,7 @@ async function _createOffer(params, server, config, onInit, context) {
|
|
|
2913
2925
|
|
|
2914
2926
|
async function getRTCService(server, service_id, config) {
|
|
2915
2927
|
config = config || {};
|
|
2916
|
-
config.peer_id = config.peer_id || (0,
|
|
2928
|
+
config.peer_id = config.peer_id || (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.randId)();
|
|
2917
2929
|
|
|
2918
2930
|
const pc = new RTCPeerConnection({
|
|
2919
2931
|
iceServers: config.ice_servers || [
|
|
@@ -3013,11 +3025,11 @@ async function getRTCService(server, service_id, config) {
|
|
|
3013
3025
|
const rpc = await _setupRPC(config);
|
|
3014
3026
|
pc.rpc = rpc;
|
|
3015
3027
|
async function get_service(name, ...args) {
|
|
3016
|
-
(0,
|
|
3028
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(
|
|
3017
3029
|
!name.includes(":"),
|
|
3018
3030
|
"WebRTC service name should not contain ':'",
|
|
3019
3031
|
);
|
|
3020
|
-
(0,
|
|
3032
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(
|
|
3021
3033
|
!name.includes("/"),
|
|
3022
3034
|
"WebRTC service name should not contain '/'",
|
|
3023
3035
|
);
|
|
@@ -5102,14 +5114,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5102
5114
|
/* harmony export */ connectToServer: () => (/* binding */ connectToServer),
|
|
5103
5115
|
/* harmony export */ getRTCService: () => (/* reexport safe */ _webrtc_client_js__WEBPACK_IMPORTED_MODULE_3__.getRTCService),
|
|
5104
5116
|
/* harmony export */ getRemoteService: () => (/* binding */ getRemoteService),
|
|
5105
|
-
/* harmony export */ loadRequirements: () => (/* reexport safe */
|
|
5117
|
+
/* harmony export */ loadRequirements: () => (/* reexport safe */ _utils_index_js__WEBPACK_IMPORTED_MODULE_1__.loadRequirements),
|
|
5106
5118
|
/* harmony export */ login: () => (/* binding */ login),
|
|
5107
5119
|
/* harmony export */ registerRTCService: () => (/* reexport safe */ _webrtc_client_js__WEBPACK_IMPORTED_MODULE_3__.registerRTCService),
|
|
5108
5120
|
/* harmony export */ schemaFunction: () => (/* reexport safe */ _utils_schema_js__WEBPACK_IMPORTED_MODULE_2__.schemaFunction),
|
|
5109
5121
|
/* harmony export */ setupLocalClient: () => (/* binding */ setupLocalClient)
|
|
5110
5122
|
/* harmony export */ });
|
|
5111
5123
|
/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rpc.js */ "./src/rpc.js");
|
|
5112
|
-
/* harmony import */ var
|
|
5124
|
+
/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils/index.js */ "./src/utils/index.js");
|
|
5113
5125
|
/* harmony import */ var _utils_schema_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils/schema.js */ "./src/utils/schema.js");
|
|
5114
5126
|
/* harmony import */ var _webrtc_client_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webrtc-client.js */ "./src/webrtc-client.js");
|
|
5115
5127
|
|
|
@@ -5134,7 +5146,7 @@ class WebsocketRPCConnection {
|
|
|
5134
5146
|
WebSocketClass = null,
|
|
5135
5147
|
token_refresh_interval = 2 * 60 * 60,
|
|
5136
5148
|
) {
|
|
5137
|
-
(0,
|
|
5149
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(server_url && client_id, "server_url and client_id are required");
|
|
5138
5150
|
this._server_url = server_url;
|
|
5139
5151
|
this._client_id = client_id;
|
|
5140
5152
|
this._workspace = workspace;
|
|
@@ -5175,7 +5187,7 @@ class WebsocketRPCConnection {
|
|
|
5175
5187
|
}
|
|
5176
5188
|
|
|
5177
5189
|
on_message(handler) {
|
|
5178
|
-
(0,
|
|
5190
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(handler, "handler is required");
|
|
5179
5191
|
this._handle_message = handler;
|
|
5180
5192
|
}
|
|
5181
5193
|
|
|
@@ -5253,7 +5265,7 @@ class WebsocketRPCConnection {
|
|
|
5253
5265
|
if (first_message.type == "connection_info") {
|
|
5254
5266
|
this.connection_info = first_message;
|
|
5255
5267
|
if (this._workspace) {
|
|
5256
|
-
(0,
|
|
5268
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(
|
|
5257
5269
|
this.connection_info.workspace === this._workspace,
|
|
5258
5270
|
`Connected to the wrong workspace: ${this.connection_info.workspace}, expected: ${this._workspace}`,
|
|
5259
5271
|
);
|
|
@@ -5324,7 +5336,7 @@ class WebsocketRPCConnection {
|
|
|
5324
5336
|
});
|
|
5325
5337
|
this._websocket.send(authInfo);
|
|
5326
5338
|
// Wait for the first message from the server
|
|
5327
|
-
await (0,
|
|
5339
|
+
await (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.waitFor)(
|
|
5328
5340
|
this._establish_connection(),
|
|
5329
5341
|
this._timeout,
|
|
5330
5342
|
"Failed to receive the first message from the server",
|
|
@@ -5537,7 +5549,7 @@ async function login(config) {
|
|
|
5537
5549
|
});
|
|
5538
5550
|
try {
|
|
5539
5551
|
const svc = await server.getService(service_id);
|
|
5540
|
-
(0,
|
|
5552
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(svc, `Failed to get the login service: ${service_id}`);
|
|
5541
5553
|
let context;
|
|
5542
5554
|
if (workspace) {
|
|
5543
5555
|
context = await svc.start({ workspace, expires_in, _rkwargs: true });
|
|
@@ -5563,7 +5575,7 @@ async function webrtcGetService(wm, rtc_service_id, query, config) {
|
|
|
5563
5575
|
const webrtc_config = config.webrtc_config;
|
|
5564
5576
|
if (config.webrtc !== undefined) delete config.webrtc;
|
|
5565
5577
|
if (config.webrtc_config !== undefined) delete config.webrtc_config;
|
|
5566
|
-
(0,
|
|
5578
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(
|
|
5567
5579
|
[undefined, true, false, "auto"].includes(webrtc),
|
|
5568
5580
|
"webrtc must be true, false or 'auto'",
|
|
5569
5581
|
);
|
|
@@ -5601,7 +5613,7 @@ async function connectToServer(config) {
|
|
|
5601
5613
|
}
|
|
5602
5614
|
let clientId = config.client_id;
|
|
5603
5615
|
if (!clientId) {
|
|
5604
|
-
clientId = (0,
|
|
5616
|
+
clientId = (0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.randId)();
|
|
5605
5617
|
config.client_id = clientId;
|
|
5606
5618
|
}
|
|
5607
5619
|
|
|
@@ -5617,7 +5629,7 @@ async function connectToServer(config) {
|
|
|
5617
5629
|
config.WebSocketClass,
|
|
5618
5630
|
);
|
|
5619
5631
|
const connection_info = await connection.open();
|
|
5620
|
-
(0,
|
|
5632
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(
|
|
5621
5633
|
connection_info,
|
|
5622
5634
|
"Failed to connect to the server, no connection info obtained. This issue is most likely due to an outdated Hypha server version. Please use `imjoy-rpc` for compatibility, or upgrade the Hypha server to the latest version.",
|
|
5623
5635
|
);
|
|
@@ -5676,11 +5688,11 @@ async function connectToServer(config) {
|
|
|
5676
5688
|
|
|
5677
5689
|
async function getApp(clientId) {
|
|
5678
5690
|
clientId = clientId || "*";
|
|
5679
|
-
(0,
|
|
5691
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(!clientId.includes(":"), "clientId should not contain ':'");
|
|
5680
5692
|
if (!clientId.includes("/")) {
|
|
5681
5693
|
clientId = connection_info.workspace + "/" + clientId;
|
|
5682
5694
|
}
|
|
5683
|
-
(0,
|
|
5695
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(
|
|
5684
5696
|
clientId.split("/").length === 2,
|
|
5685
5697
|
"clientId should match pattern workspace/clientId",
|
|
5686
5698
|
);
|
|
@@ -5689,8 +5701,8 @@ async function connectToServer(config) {
|
|
|
5689
5701
|
|
|
5690
5702
|
async function listApps(ws) {
|
|
5691
5703
|
ws = ws || workspace;
|
|
5692
|
-
(0,
|
|
5693
|
-
(0,
|
|
5704
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(!ws.includes(":"), "workspace should not contain ':'");
|
|
5705
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.assert)(!ws.includes("/"), "workspace should not contain '/'");
|
|
5694
5706
|
const query = { workspace: ws, service_id: "default" };
|
|
5695
5707
|
return await wm.listServices(query);
|
|
5696
5708
|
}
|
|
@@ -5932,7 +5944,7 @@ async function connectToServer(config) {
|
|
|
5932
5944
|
|
|
5933
5945
|
async function getRemoteService(serviceUri, config = {}) {
|
|
5934
5946
|
const { serverUrl, workspace, clientId, serviceId, appId } =
|
|
5935
|
-
(0,
|
|
5947
|
+
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__.parseServiceUrl)(serviceUri);
|
|
5936
5948
|
const fullServiceId = `${workspace}/${clientId}:${serviceId}@${appId}`;
|
|
5937
5949
|
|
|
5938
5950
|
if (config.serverUrl) {
|