@interopio/desktop 6.13.1 → 6.15.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/changelog.md +12 -0
- package/desktop.d.ts +135 -2
- package/dist/desktop.browser.js +314 -96
- package/dist/desktop.browser.js.map +1 -1
- package/dist/desktop.browser.min.js +1 -1
- package/dist/desktop.browser.min.js.map +1 -1
- package/dist/desktop.es.js +314 -96
- package/dist/desktop.es.js.map +1 -1
- package/dist/desktop.umd.js +314 -96
- package/dist/desktop.umd.js.map +1 -1
- package/dist/desktop.umd.min.js +1 -1
- package/dist/desktop.umd.min.js.map +1 -1
- package/package.json +4 -4
package/dist/desktop.browser.js
CHANGED
|
@@ -216,7 +216,10 @@
|
|
|
216
216
|
type: "define",
|
|
217
217
|
metrics: [rootStateMetric],
|
|
218
218
|
};
|
|
219
|
-
session.
|
|
219
|
+
session.sendFireAndForget(defineRootMetricsMsg)
|
|
220
|
+
.catch((err) => {
|
|
221
|
+
config.logger.warn(`Failed to send define for root state metric: ${JSON.stringify(err)}`);
|
|
222
|
+
});
|
|
220
223
|
if (reconnect) {
|
|
221
224
|
replayRepo(repo);
|
|
222
225
|
}
|
|
@@ -264,7 +267,10 @@
|
|
|
264
267
|
type: "define",
|
|
265
268
|
metrics: [metric],
|
|
266
269
|
};
|
|
267
|
-
session.
|
|
270
|
+
session.sendFireAndForget(createMetricsMsg)
|
|
271
|
+
.catch((err) => {
|
|
272
|
+
config.logger.warn(`Failed to send define for system state metric of ${system.name}: ${JSON.stringify(err)}`);
|
|
273
|
+
});
|
|
268
274
|
};
|
|
269
275
|
const updateSystem = async (system, state) => {
|
|
270
276
|
await joinPromise;
|
|
@@ -279,7 +285,10 @@
|
|
|
279
285
|
timestamp: Date.now(),
|
|
280
286
|
}],
|
|
281
287
|
};
|
|
282
|
-
session.
|
|
288
|
+
session.sendFireAndForget(shadowedUpdateMetric)
|
|
289
|
+
.catch((err) => {
|
|
290
|
+
config.logger.warn(`Failed to send update for system state metric of ${system.name}: ${JSON.stringify(err)}`);
|
|
291
|
+
});
|
|
283
292
|
const stateObj = composeMsgForRootStateMetric(system);
|
|
284
293
|
const rootMetric = {
|
|
285
294
|
type: "publish",
|
|
@@ -293,7 +302,10 @@
|
|
|
293
302
|
timestamp: Date.now(),
|
|
294
303
|
}],
|
|
295
304
|
};
|
|
296
|
-
session.
|
|
305
|
+
session.sendFireAndForget(rootMetric)
|
|
306
|
+
.catch((err) => {
|
|
307
|
+
config.logger.warn(`Failed to send update for root state metric of ${system.name}: ${JSON.stringify(err)}`);
|
|
308
|
+
});
|
|
297
309
|
};
|
|
298
310
|
const createMetric = async (metric) => {
|
|
299
311
|
const metricClone = cloneMetric(metric);
|
|
@@ -303,7 +315,10 @@
|
|
|
303
315
|
type: "define",
|
|
304
316
|
metrics: [m],
|
|
305
317
|
};
|
|
306
|
-
session.
|
|
318
|
+
session.sendFireAndForget(createMetricsMsg)
|
|
319
|
+
.catch((err) => {
|
|
320
|
+
config.logger.warn(`Failed to send define for metric ${metric.name}: ${JSON.stringify(err)}`);
|
|
321
|
+
});
|
|
307
322
|
if (typeof metricClone.value !== "undefined") {
|
|
308
323
|
updateMetricCore(metricClone);
|
|
309
324
|
}
|
|
@@ -324,7 +339,10 @@
|
|
|
324
339
|
timestamp: Date.now(),
|
|
325
340
|
}],
|
|
326
341
|
};
|
|
327
|
-
return session.sendFireAndForget(publishMetricsMsg)
|
|
342
|
+
return session.sendFireAndForget(publishMetricsMsg)
|
|
343
|
+
.catch((err) => {
|
|
344
|
+
config.logger.warn(`Failed to publish metric ${metric.name}: ${JSON.stringify(err)}`);
|
|
345
|
+
});
|
|
328
346
|
}
|
|
329
347
|
return Promise.resolve();
|
|
330
348
|
};
|
|
@@ -1191,12 +1209,10 @@
|
|
|
1191
1209
|
const pw = new PromiseWrapper$1();
|
|
1192
1210
|
this.logger.debug(`initiating ws to ${this.settings.ws}...`);
|
|
1193
1211
|
this.ws = new WebSocketConstructor(this.settings.ws ?? "");
|
|
1212
|
+
let wasOpen = false;
|
|
1194
1213
|
this.ws.onerror = (err) => {
|
|
1195
|
-
let reason
|
|
1214
|
+
let reason;
|
|
1196
1215
|
try {
|
|
1197
|
-
reason = JSON.stringify(err);
|
|
1198
|
-
}
|
|
1199
|
-
catch (error) {
|
|
1200
1216
|
const seen = new WeakSet();
|
|
1201
1217
|
const replacer = (key, value) => {
|
|
1202
1218
|
if (typeof value === "object" && value !== null) {
|
|
@@ -1205,23 +1221,42 @@
|
|
|
1205
1221
|
}
|
|
1206
1222
|
seen.add(value);
|
|
1207
1223
|
}
|
|
1224
|
+
if (value instanceof Error) {
|
|
1225
|
+
return {
|
|
1226
|
+
message: value.message,
|
|
1227
|
+
name: value.name,
|
|
1228
|
+
stack: value.stack
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1208
1231
|
return value;
|
|
1209
1232
|
};
|
|
1210
1233
|
reason = JSON.stringify(err, replacer);
|
|
1211
1234
|
}
|
|
1235
|
+
catch {
|
|
1236
|
+
reason = err.message;
|
|
1237
|
+
}
|
|
1212
1238
|
this.logger.info(`ws error - reason: ${reason}`);
|
|
1213
1239
|
pw.reject("error");
|
|
1240
|
+
if (wasOpen) {
|
|
1241
|
+
wasOpen = false;
|
|
1242
|
+
this.notifyForSocketState("error");
|
|
1243
|
+
}
|
|
1214
1244
|
this.notifyStatusChanged(false, reason);
|
|
1215
1245
|
};
|
|
1216
1246
|
this.ws.onclose = (err) => {
|
|
1217
1247
|
this.logger.info(`ws closed - code: ${err?.code} reason: ${err?.reason}`);
|
|
1218
1248
|
pw.reject("closed");
|
|
1249
|
+
if (wasOpen) {
|
|
1250
|
+
wasOpen = false;
|
|
1251
|
+
this.notifyForSocketState("closed");
|
|
1252
|
+
}
|
|
1219
1253
|
this.notifyStatusChanged(false);
|
|
1220
1254
|
};
|
|
1221
1255
|
this.ws.onopen = () => {
|
|
1222
1256
|
this.startupTimer.mark("ws-opened");
|
|
1223
1257
|
this.logger.info(`ws opened ${this.settings.identity?.application}`);
|
|
1224
1258
|
pw.resolve();
|
|
1259
|
+
wasOpen = true;
|
|
1225
1260
|
this.notifyStatusChanged(true);
|
|
1226
1261
|
};
|
|
1227
1262
|
this.ws.onmessage = (message) => {
|
|
@@ -1312,11 +1347,12 @@
|
|
|
1312
1347
|
}
|
|
1313
1348
|
}
|
|
1314
1349
|
|
|
1350
|
+
/* @ts-self-types="./index.d.ts" */
|
|
1315
1351
|
let urlAlphabet$1 =
|
|
1316
1352
|
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
1317
1353
|
let nanoid$1 = (size = 21) => {
|
|
1318
1354
|
let id = '';
|
|
1319
|
-
let i = size;
|
|
1355
|
+
let i = size | 0;
|
|
1320
1356
|
while (i--) {
|
|
1321
1357
|
id += urlAlphabet$1[(Math.random() * 64) | 0];
|
|
1322
1358
|
}
|
|
@@ -2054,17 +2090,31 @@
|
|
|
2054
2090
|
callbacks.execute("onJoined", wasReconnect);
|
|
2055
2091
|
}
|
|
2056
2092
|
function handleConnectionDisconnected() {
|
|
2057
|
-
_connectionOn = false;
|
|
2058
2093
|
logger.debug("connection is down");
|
|
2094
|
+
_connectionOn = false;
|
|
2059
2095
|
isJoined = false;
|
|
2060
2096
|
tryReconnecting = true;
|
|
2097
|
+
Object.keys(requestsMap).forEach(requestId => {
|
|
2098
|
+
const request = requestsMap[requestId];
|
|
2099
|
+
if (request) {
|
|
2100
|
+
logger.trace(`failing pending request ${requestId} due to connection lost`);
|
|
2101
|
+
request.error({
|
|
2102
|
+
err: "Connection lost - gateway connection was disconnected"
|
|
2103
|
+
});
|
|
2104
|
+
}
|
|
2105
|
+
});
|
|
2061
2106
|
callbacks.execute("onLeft", { disconnected: true });
|
|
2062
2107
|
}
|
|
2063
|
-
function handleConnectionLoggedIn() {
|
|
2108
|
+
async function handleConnectionLoggedIn() {
|
|
2064
2109
|
_connectionOn = true;
|
|
2065
2110
|
if (tryReconnecting) {
|
|
2066
2111
|
logger.debug("connection is now up - trying to reconnect...");
|
|
2067
|
-
|
|
2112
|
+
try {
|
|
2113
|
+
await join(_latestOptions);
|
|
2114
|
+
}
|
|
2115
|
+
catch {
|
|
2116
|
+
logger.trace(`failed to reconnect`);
|
|
2117
|
+
}
|
|
2068
2118
|
}
|
|
2069
2119
|
}
|
|
2070
2120
|
function onJoined(callback) {
|
|
@@ -2157,7 +2207,7 @@
|
|
|
2157
2207
|
connection
|
|
2158
2208
|
.send(msg, options)
|
|
2159
2209
|
.catch((err) => {
|
|
2160
|
-
requestsMap[requestId]
|
|
2210
|
+
requestsMap[requestId]?.error({ err });
|
|
2161
2211
|
});
|
|
2162
2212
|
});
|
|
2163
2213
|
}
|
|
@@ -2236,6 +2286,7 @@
|
|
|
2236
2286
|
initialLogin = true;
|
|
2237
2287
|
initialLoginAttempts = 3;
|
|
2238
2288
|
loginConfig;
|
|
2289
|
+
loginRetryInProgress = false;
|
|
2239
2290
|
constructor(settings, logger) {
|
|
2240
2291
|
this.settings = settings;
|
|
2241
2292
|
this.logger = logger;
|
|
@@ -2349,6 +2400,7 @@
|
|
|
2349
2400
|
return this.registry.add("disconnected", callback);
|
|
2350
2401
|
}
|
|
2351
2402
|
async login(authRequest, reconnect) {
|
|
2403
|
+
this.logger.debug(`Login initiated - reconnect: ${reconnect}, transport: ${this.transport.name()}`);
|
|
2352
2404
|
if (!this._defaultAuth) {
|
|
2353
2405
|
this._defaultAuth = authRequest;
|
|
2354
2406
|
}
|
|
@@ -2357,19 +2409,18 @@
|
|
|
2357
2409
|
const newAuth = this.transportSwap();
|
|
2358
2410
|
authRequest = newAuth ?? authRequest;
|
|
2359
2411
|
}
|
|
2360
|
-
this.logger.trace(`Starting login for transport: ${this.transport.name()} and auth ${JSON.stringify(authRequest)}`);
|
|
2361
2412
|
try {
|
|
2362
2413
|
await this.transport.open();
|
|
2363
|
-
this.logger.
|
|
2414
|
+
this.logger.debug(`Transport: ${this.transport.name()} opened, logging in`);
|
|
2364
2415
|
timer("connection").mark("transport-opened");
|
|
2365
2416
|
const identity = await this.loginCore(authRequest, reconnect);
|
|
2366
|
-
this.logger.
|
|
2417
|
+
this.logger.debug(`Logged in with identity: ${JSON.stringify(identity)}`);
|
|
2367
2418
|
timer("connection").mark("protocol-logged-in");
|
|
2368
2419
|
return identity;
|
|
2369
2420
|
}
|
|
2370
2421
|
catch (error) {
|
|
2371
2422
|
if (this._switchInProgress) {
|
|
2372
|
-
this.logger.
|
|
2423
|
+
this.logger.debug("An error while logging in after a transport swap, preparing a default swap.");
|
|
2373
2424
|
this.prepareDefaultSwap();
|
|
2374
2425
|
}
|
|
2375
2426
|
throw new Error(error);
|
|
@@ -2412,6 +2463,7 @@
|
|
|
2412
2463
|
setLoggedIn(value) {
|
|
2413
2464
|
this._isLoggedIn = value;
|
|
2414
2465
|
if (this._isLoggedIn) {
|
|
2466
|
+
this.initialLogin = false;
|
|
2415
2467
|
this.registry.execute("onLoggedIn");
|
|
2416
2468
|
}
|
|
2417
2469
|
}
|
|
@@ -2438,8 +2490,10 @@
|
|
|
2438
2490
|
}
|
|
2439
2491
|
handleConnectionChanged(connected) {
|
|
2440
2492
|
if (this._connected === connected) {
|
|
2493
|
+
this.logger.trace("connection state unchanged, skipping");
|
|
2441
2494
|
return;
|
|
2442
2495
|
}
|
|
2496
|
+
this.logger.info(`connection state changed to ${connected ? "connected" : "disconnected"}`);
|
|
2443
2497
|
this._connected = connected;
|
|
2444
2498
|
if (connected) {
|
|
2445
2499
|
if (this.settings?.replaySpecs?.length) {
|
|
@@ -2449,28 +2503,44 @@
|
|
|
2449
2503
|
this.registry.execute("connected");
|
|
2450
2504
|
}
|
|
2451
2505
|
else {
|
|
2452
|
-
this.
|
|
2506
|
+
this.setLoggedIn(false);
|
|
2507
|
+
if (this.shouldTryLogin) {
|
|
2508
|
+
this.attemptLoginWithRetry();
|
|
2509
|
+
}
|
|
2453
2510
|
this.registry.execute("disconnected");
|
|
2454
2511
|
}
|
|
2455
2512
|
}
|
|
2456
|
-
|
|
2457
|
-
this.
|
|
2458
|
-
|
|
2459
|
-
|
|
2513
|
+
async attemptLoginWithRetry() {
|
|
2514
|
+
if (!this.loginConfig) {
|
|
2515
|
+
throw new Error("no login info");
|
|
2516
|
+
}
|
|
2517
|
+
if (this.loginRetryInProgress) {
|
|
2518
|
+
this.logger.debug("login attempt already in progress, ignoring request...");
|
|
2519
|
+
return;
|
|
2520
|
+
}
|
|
2521
|
+
if (this._isLoggedIn) {
|
|
2522
|
+
this.logger.debug("already logged in, ignoring request...");
|
|
2523
|
+
return;
|
|
2524
|
+
}
|
|
2525
|
+
if (this.initialLogin) {
|
|
2526
|
+
this.logger.debug(`initial login attempt failed, ${this.initialLoginAttempts} attempts remaining...`);
|
|
2460
2527
|
if (this.initialLoginAttempts <= 0) {
|
|
2528
|
+
this.logger.info("maximum initial login attempts reached, will not try to login again");
|
|
2461
2529
|
return;
|
|
2462
2530
|
}
|
|
2463
2531
|
this.initialLoginAttempts--;
|
|
2464
2532
|
}
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2533
|
+
try {
|
|
2534
|
+
this.logger.debug(`will try a new login... ${this.loginRetryInProgress}`);
|
|
2535
|
+
this.loginRetryInProgress = true;
|
|
2536
|
+
await this.login(this.loginConfig, true);
|
|
2537
|
+
}
|
|
2538
|
+
catch (e) {
|
|
2539
|
+
this.logger.error(`error trying to login: ${e?.message}`, e);
|
|
2540
|
+
setTimeout(this.attemptLoginWithRetry.bind(this), this.settings.reconnectInterval ?? 1000);
|
|
2541
|
+
}
|
|
2542
|
+
finally {
|
|
2543
|
+
this.loginRetryInProgress = false;
|
|
2474
2544
|
}
|
|
2475
2545
|
}
|
|
2476
2546
|
handleTransportMessage(msg) {
|
|
@@ -2597,7 +2667,6 @@
|
|
|
2597
2667
|
return message;
|
|
2598
2668
|
}
|
|
2599
2669
|
async loginCore(config, reconnect) {
|
|
2600
|
-
this.logger.info("logging in...");
|
|
2601
2670
|
this.loginConfig = config;
|
|
2602
2671
|
if (!this.loginConfig) {
|
|
2603
2672
|
this.loginConfig = { username: "", password: "" };
|
|
@@ -2612,11 +2681,13 @@
|
|
|
2612
2681
|
if (config.sessionId) {
|
|
2613
2682
|
helloMsg.request_id = config.sessionId;
|
|
2614
2683
|
}
|
|
2615
|
-
|
|
2616
|
-
"
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2684
|
+
if (!this.globalDomain) {
|
|
2685
|
+
this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
|
|
2686
|
+
"welcome",
|
|
2687
|
+
"token",
|
|
2688
|
+
"authentication-request"
|
|
2689
|
+
]);
|
|
2690
|
+
}
|
|
2620
2691
|
const sendOptions = { skipPeerId: true };
|
|
2621
2692
|
if (this.initialLogin) {
|
|
2622
2693
|
sendOptions.retryInterval = this.settings.reconnectInterval;
|
|
@@ -2624,7 +2695,6 @@
|
|
|
2624
2695
|
}
|
|
2625
2696
|
try {
|
|
2626
2697
|
const welcomeMsg = await this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config);
|
|
2627
|
-
this.initialLogin = false;
|
|
2628
2698
|
this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
|
|
2629
2699
|
this.peerId = welcomeMsg.peer_id;
|
|
2630
2700
|
this.resolvedIdentity = welcomeMsg.resolved_identity;
|
|
@@ -2727,7 +2797,7 @@
|
|
|
2727
2797
|
clearTimeout(this.pingTimer);
|
|
2728
2798
|
}
|
|
2729
2799
|
const promises = this.sessions.map((session) => {
|
|
2730
|
-
session.leave();
|
|
2800
|
+
return session.leave();
|
|
2731
2801
|
});
|
|
2732
2802
|
await Promise.all(promises);
|
|
2733
2803
|
}
|
|
@@ -2866,7 +2936,10 @@
|
|
|
2866
2936
|
stack: error.stack ?? ""
|
|
2867
2937
|
};
|
|
2868
2938
|
}
|
|
2869
|
-
interop.invoke(Logger.InteropMethodName, args)
|
|
2939
|
+
interop.invoke(Logger.InteropMethodName, args)
|
|
2940
|
+
.catch((e) => {
|
|
2941
|
+
this.logFn.warn(`Unable to send log message to the platform: ${e.message}`, e);
|
|
2942
|
+
});
|
|
2870
2943
|
}
|
|
2871
2944
|
}
|
|
2872
2945
|
catch {
|
|
@@ -2900,7 +2973,12 @@
|
|
|
2900
2973
|
this.logFn.warn(toPrint);
|
|
2901
2974
|
break;
|
|
2902
2975
|
case "error":
|
|
2903
|
-
|
|
2976
|
+
if (error) {
|
|
2977
|
+
this.logFn.error(toPrint, error);
|
|
2978
|
+
}
|
|
2979
|
+
else {
|
|
2980
|
+
this.logFn.error(toPrint);
|
|
2981
|
+
}
|
|
2904
2982
|
break;
|
|
2905
2983
|
}
|
|
2906
2984
|
}
|
|
@@ -2944,7 +3022,7 @@
|
|
|
2944
3022
|
}
|
|
2945
3023
|
};
|
|
2946
3024
|
|
|
2947
|
-
var version$1 = "6.5.
|
|
3025
|
+
var version$1 = "6.5.3-iocd-beta";
|
|
2948
3026
|
|
|
2949
3027
|
function prepareConfig$1 (configuration, ext, glue42gd) {
|
|
2950
3028
|
let nodeStartingContext;
|
|
@@ -5109,7 +5187,11 @@
|
|
|
5109
5187
|
if (!this._reAnnounceKnownContexts) {
|
|
5110
5188
|
return this._connection.setLibReAnnounced({ name: "contexts" });
|
|
5111
5189
|
}
|
|
5112
|
-
this.reInitiateState()
|
|
5190
|
+
this.reInitiateState()
|
|
5191
|
+
.then(() => this._connection.setLibReAnnounced({ name: "contexts" }))
|
|
5192
|
+
.catch((err) => {
|
|
5193
|
+
this._logger.warn(`Error while re-announcing contexts: ${JSON.stringify(err)}`);
|
|
5194
|
+
});
|
|
5113
5195
|
});
|
|
5114
5196
|
this.subscribeToContextCreatedMessages();
|
|
5115
5197
|
this.subscribeToContextUpdatedMessages();
|
|
@@ -5187,7 +5269,8 @@
|
|
|
5187
5269
|
}
|
|
5188
5270
|
const contextData = this._contextNameToData[name];
|
|
5189
5271
|
if (!contextData || !contextData.isAnnounced) {
|
|
5190
|
-
|
|
5272
|
+
await this.createContext(name, delta);
|
|
5273
|
+
return;
|
|
5191
5274
|
}
|
|
5192
5275
|
let currentContext = contextData.context;
|
|
5193
5276
|
if (!contextData.hasCallbacks()) {
|
|
@@ -5304,11 +5387,11 @@
|
|
|
5304
5387
|
return Promise.resolve({});
|
|
5305
5388
|
}
|
|
5306
5389
|
if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
|
|
5307
|
-
return new Promise((resolve) => {
|
|
5390
|
+
return new Promise((resolve, reject) => {
|
|
5308
5391
|
this.subscribe(name, (data, _d, _r, un) => {
|
|
5309
5392
|
this.unsubscribe(un);
|
|
5310
5393
|
resolve(data);
|
|
5311
|
-
});
|
|
5394
|
+
}).catch(reject);
|
|
5312
5395
|
});
|
|
5313
5396
|
}
|
|
5314
5397
|
const context = contextData?.context ?? {};
|
|
@@ -5397,7 +5480,7 @@
|
|
|
5397
5480
|
type: GW_MESSAGE_DESTROY_CONTEXT,
|
|
5398
5481
|
domain: "global",
|
|
5399
5482
|
context_id: contextData.contextId,
|
|
5400
|
-
}).then((
|
|
5483
|
+
}).then(() => undefined);
|
|
5401
5484
|
}
|
|
5402
5485
|
handleUpdated(contextData, delta, extraData) {
|
|
5403
5486
|
const oldContext = contextData.context;
|
|
@@ -5450,7 +5533,7 @@
|
|
|
5450
5533
|
contextData.contextId = contextCreatedMsg.context_id;
|
|
5451
5534
|
contextData.activityId = contextCreatedMsg.activity_id;
|
|
5452
5535
|
if (!contextData.sentExplicitSubscription) {
|
|
5453
|
-
this.sendSubscribe(contextData);
|
|
5536
|
+
this.sendSubscribe(contextData).catch(() => { });
|
|
5454
5537
|
}
|
|
5455
5538
|
}
|
|
5456
5539
|
}
|
|
@@ -5602,16 +5685,25 @@
|
|
|
5602
5685
|
type: GW_MESSAGE_SUBSCRIBE_CONTEXT,
|
|
5603
5686
|
domain: "global",
|
|
5604
5687
|
context_id: contextData.contextId,
|
|
5605
|
-
})
|
|
5688
|
+
})
|
|
5689
|
+
.then(() => undefined)
|
|
5690
|
+
.catch(() => {
|
|
5691
|
+
contextData.sentExplicitSubscription = false;
|
|
5692
|
+
});
|
|
5606
5693
|
}
|
|
5607
5694
|
sendUnsubscribe(contextData) {
|
|
5695
|
+
const prev = contextData.sentExplicitSubscription;
|
|
5608
5696
|
contextData.sentExplicitSubscription = false;
|
|
5609
5697
|
return this._gw3Session
|
|
5610
5698
|
.send({
|
|
5611
5699
|
type: GW_MESSAGE_UNSUBSCRIBE_CONTEXT,
|
|
5612
5700
|
domain: "global",
|
|
5613
5701
|
context_id: contextData.contextId,
|
|
5614
|
-
})
|
|
5702
|
+
})
|
|
5703
|
+
.then(() => undefined)
|
|
5704
|
+
.catch(() => {
|
|
5705
|
+
contextData.sentExplicitSubscription = prev;
|
|
5706
|
+
});
|
|
5615
5707
|
}
|
|
5616
5708
|
calculateContextDeltaV1(from, to) {
|
|
5617
5709
|
const delta = { added: {}, updated: {}, removed: [], reset: undefined };
|
|
@@ -5664,10 +5756,7 @@
|
|
|
5664
5756
|
this._contextIdToName = {};
|
|
5665
5757
|
delete this._protocolVersion;
|
|
5666
5758
|
this._contextsTempCache = Object.keys(this._contextNameToData).reduce((cacheSoFar, ctxName) => {
|
|
5667
|
-
|
|
5668
|
-
if (contextData.isAnnounced && (contextData.activityId || contextData.sentExplicitSubscription)) {
|
|
5669
|
-
cacheSoFar[ctxName] = this._contextNameToData[ctxName].context;
|
|
5670
|
-
}
|
|
5759
|
+
cacheSoFar[ctxName] = this._contextNameToData[ctxName].context;
|
|
5671
5760
|
return cacheSoFar;
|
|
5672
5761
|
}, {});
|
|
5673
5762
|
this._contextNameToData = {};
|
|
@@ -7021,13 +7110,15 @@
|
|
|
7021
7110
|
session;
|
|
7022
7111
|
repository;
|
|
7023
7112
|
serverRepository;
|
|
7113
|
+
logger;
|
|
7024
7114
|
ERR_URI_SUBSCRIPTION_FAILED = "com.tick42.agm.errors.subscription.failure";
|
|
7025
7115
|
callbacks = CallbackRegistryFactory$1();
|
|
7026
7116
|
nextStreamId = 0;
|
|
7027
|
-
constructor(session, repository, serverRepository) {
|
|
7117
|
+
constructor(session, repository, serverRepository, logger) {
|
|
7028
7118
|
this.session = session;
|
|
7029
7119
|
this.repository = repository;
|
|
7030
7120
|
this.serverRepository = serverRepository;
|
|
7121
|
+
this.logger = logger;
|
|
7031
7122
|
session.on("add-interest", (msg) => {
|
|
7032
7123
|
this.handleAddInterest(msg);
|
|
7033
7124
|
});
|
|
@@ -7060,6 +7151,8 @@
|
|
|
7060
7151
|
type: "accepted",
|
|
7061
7152
|
subscription_id: key,
|
|
7062
7153
|
stream_id: streamId,
|
|
7154
|
+
}).catch((err) => {
|
|
7155
|
+
this.logger.warn(`Failed to send accepted message for subscription ${key}: ${JSON.stringify(err)}`);
|
|
7063
7156
|
});
|
|
7064
7157
|
this.callbacks.execute(SUBSCRIPTION_ADDED, subscription, streamingMethod);
|
|
7065
7158
|
}
|
|
@@ -7097,7 +7190,10 @@
|
|
|
7097
7190
|
stream_id: streamId,
|
|
7098
7191
|
data,
|
|
7099
7192
|
};
|
|
7100
|
-
this.session.sendFireAndForget(publishMessage)
|
|
7193
|
+
this.session.sendFireAndForget(publishMessage)
|
|
7194
|
+
.catch((err) => {
|
|
7195
|
+
this.logger.warn(`Failed to send publish message for stream ${streamId}: ${JSON.stringify(err)}`);
|
|
7196
|
+
});
|
|
7101
7197
|
});
|
|
7102
7198
|
}
|
|
7103
7199
|
pushDataToSingle(method, subscription, data) {
|
|
@@ -7109,7 +7205,10 @@
|
|
|
7109
7205
|
subscription_id: subscription.id,
|
|
7110
7206
|
data,
|
|
7111
7207
|
};
|
|
7112
|
-
this.session.sendFireAndForget(postMessage)
|
|
7208
|
+
this.session.sendFireAndForget(postMessage)
|
|
7209
|
+
.catch((err) => {
|
|
7210
|
+
this.logger.warn(`Failed to send post message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
|
|
7211
|
+
});
|
|
7113
7212
|
}
|
|
7114
7213
|
closeSingleSubscription(streamingMethod, subscription) {
|
|
7115
7214
|
if (streamingMethod.protocolState.subscriptionsMap) {
|
|
@@ -7120,7 +7219,10 @@
|
|
|
7120
7219
|
subscription_id: subscription.id,
|
|
7121
7220
|
reason: "Server dropping a single subscription",
|
|
7122
7221
|
};
|
|
7123
|
-
this.session.sendFireAndForget(dropSubscriptionMessage)
|
|
7222
|
+
this.session.sendFireAndForget(dropSubscriptionMessage)
|
|
7223
|
+
.catch((err) => {
|
|
7224
|
+
this.logger.warn(`Failed to send drop-subscription message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
|
|
7225
|
+
});
|
|
7124
7226
|
subscription.instance;
|
|
7125
7227
|
this.callbacks.execute(SUBSCRIPTION_REMOVED, subscription, streamingMethod);
|
|
7126
7228
|
}
|
|
@@ -7148,7 +7250,10 @@
|
|
|
7148
7250
|
subscription_id: subscription.id,
|
|
7149
7251
|
reason: "Server dropping all subscriptions on stream_id: " + subscription.streamId,
|
|
7150
7252
|
};
|
|
7151
|
-
this.session.sendFireAndForget(drop)
|
|
7253
|
+
this.session.sendFireAndForget(drop)
|
|
7254
|
+
.catch((err) => {
|
|
7255
|
+
this.logger.warn(`Failed to send drop-subscription message for subscription ${subscription.id}: ${JSON.stringify(err)}`);
|
|
7256
|
+
});
|
|
7152
7257
|
});
|
|
7153
7258
|
}
|
|
7154
7259
|
getSubscriptionList(streamingMethod, branchKey) {
|
|
@@ -7257,7 +7362,10 @@
|
|
|
7257
7362
|
reason,
|
|
7258
7363
|
request_id: subscriptionId,
|
|
7259
7364
|
};
|
|
7260
|
-
this.session.sendFireAndForget(errorMessage)
|
|
7365
|
+
this.session.sendFireAndForget(errorMessage)
|
|
7366
|
+
.catch((err) => {
|
|
7367
|
+
this.logger.warn(`Failed to send subscription failed message for subscription ${subscriptionId}: ${JSON.stringify(err)}`);
|
|
7368
|
+
});
|
|
7261
7369
|
}
|
|
7262
7370
|
getStreamId(streamingMethod, branchKey) {
|
|
7263
7371
|
if (typeof branchKey !== "string") {
|
|
@@ -7290,7 +7398,7 @@
|
|
|
7290
7398
|
this.clientRepository = clientRepository;
|
|
7291
7399
|
this.serverRepository = serverRepository;
|
|
7292
7400
|
this.logger = logger;
|
|
7293
|
-
this.streaming = new ServerStreaming(session, clientRepository, serverRepository);
|
|
7401
|
+
this.streaming = new ServerStreaming(session, clientRepository, serverRepository, logger.subLogger("streaming"));
|
|
7294
7402
|
this.session.on("invoke", (msg) => this.handleInvokeMessage(msg));
|
|
7295
7403
|
}
|
|
7296
7404
|
createStream(repoMethod) {
|
|
@@ -7349,7 +7457,10 @@
|
|
|
7349
7457
|
request_id: undefined,
|
|
7350
7458
|
};
|
|
7351
7459
|
}
|
|
7352
|
-
this.session.sendFireAndForget(msg)
|
|
7460
|
+
this.session.sendFireAndForget(msg)
|
|
7461
|
+
.catch((error => {
|
|
7462
|
+
this.logger.warn(`Failed to send method invocation result for method ${method.definition.name} invocation ${invocationId} - ${JSON.stringify(error)}`);
|
|
7463
|
+
}));
|
|
7353
7464
|
}
|
|
7354
7465
|
async unregister(method) {
|
|
7355
7466
|
const msg = {
|
|
@@ -7809,6 +7920,8 @@
|
|
|
7809
7920
|
subscription_id: server.subscriptionId,
|
|
7810
7921
|
reason_uri: "",
|
|
7811
7922
|
reason: ON_CLOSE_MSG_CLIENT_INIT,
|
|
7923
|
+
}).catch((err) => {
|
|
7924
|
+
this.logger.warn(`Error sending unsubscribe for subscription id ${server.subscriptionId}: ${JSON.stringify(err)}`);
|
|
7812
7925
|
});
|
|
7813
7926
|
delete this.subscriptionIdToLocalKeyMap[server.subscriptionId];
|
|
7814
7927
|
});
|
|
@@ -8148,7 +8261,10 @@
|
|
|
8148
8261
|
routing_key: routingKey,
|
|
8149
8262
|
target_identity: target
|
|
8150
8263
|
});
|
|
8151
|
-
this.session.send(args)
|
|
8264
|
+
this.session.send(args)
|
|
8265
|
+
.catch((err) => {
|
|
8266
|
+
this.logger.error(`Failed to publish message to topic ${topic} with routing key ${routingKey} for ${JSON.stringify(target)}: ${JSON.stringify(err)}`);
|
|
8267
|
+
});
|
|
8152
8268
|
};
|
|
8153
8269
|
subscribe = (topic, callback, options) => {
|
|
8154
8270
|
return new Promise((resolve, reject) => {
|
|
@@ -8166,8 +8282,12 @@
|
|
|
8166
8282
|
this.subscriptions.push({ subscription_id, topic, callback, source: target });
|
|
8167
8283
|
resolve({
|
|
8168
8284
|
unsubscribe: () => {
|
|
8169
|
-
this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId })
|
|
8170
|
-
|
|
8285
|
+
this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId })
|
|
8286
|
+
.then(() => {
|
|
8287
|
+
this.subscriptions = this.subscriptions.filter((s) => s.subscription_id !== subscription_id);
|
|
8288
|
+
}).catch((err) => {
|
|
8289
|
+
this.logger.warn(`Failed to send unsubscribe request for ${subscription_id}: ${JSON.stringify(err)}`);
|
|
8290
|
+
});
|
|
8171
8291
|
return Promise.resolve();
|
|
8172
8292
|
}
|
|
8173
8293
|
});
|
|
@@ -11702,6 +11822,9 @@
|
|
|
11702
11822
|
height: a.height
|
|
11703
11823
|
};
|
|
11704
11824
|
}
|
|
11825
|
+
static isRunningInIoCdContext() {
|
|
11826
|
+
return typeof window !== "undefined" && (window.glue42gd || window.iodesktop);
|
|
11827
|
+
}
|
|
11705
11828
|
static isNode() {
|
|
11706
11829
|
if (typeof Utils._isNode !== "undefined") {
|
|
11707
11830
|
return Utils._isNode;
|
|
@@ -12689,24 +12812,23 @@
|
|
|
12689
12812
|
.forEach((item) => entitlements.handleBranchesModified(item));
|
|
12690
12813
|
if (!initiated) {
|
|
12691
12814
|
initiated = true;
|
|
12692
|
-
const
|
|
12693
|
-
const
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
resolveFunc(configuration);
|
|
12697
|
-
}
|
|
12698
|
-
else {
|
|
12699
|
-
const un = applications.onInstanceStarted((i) => {
|
|
12700
|
-
if (i.id === agm.instance.instance) {
|
|
12701
|
-
un();
|
|
12702
|
-
resolveFunc(configuration);
|
|
12703
|
-
}
|
|
12704
|
-
});
|
|
12705
|
-
}
|
|
12706
|
-
}
|
|
12707
|
-
else {
|
|
12815
|
+
const myInstance = agm.instance;
|
|
12816
|
+
const hasMyAppInSnapShot = onApplicationAddedEventArgs.some((a) => a.Name === myInstance.application);
|
|
12817
|
+
const hasMyInstanceInSnapShot = onApplicationStartedEventArgs.some((i) => i.Id === myInstance.instance);
|
|
12818
|
+
if (!hasMyAppInSnapShot) {
|
|
12708
12819
|
resolveFunc(configuration);
|
|
12820
|
+
return;
|
|
12709
12821
|
}
|
|
12822
|
+
if (!hasMyInstanceInSnapShot && (Utils.isNode() || Utils.isRunningInIoCdContext())) {
|
|
12823
|
+
const un = applications.onInstanceStarted((i) => {
|
|
12824
|
+
if (i.id === myInstance.instance) {
|
|
12825
|
+
un();
|
|
12826
|
+
resolveFunc(configuration);
|
|
12827
|
+
}
|
|
12828
|
+
});
|
|
12829
|
+
return;
|
|
12830
|
+
}
|
|
12831
|
+
resolveFunc(configuration);
|
|
12710
12832
|
}
|
|
12711
12833
|
});
|
|
12712
12834
|
subscription.onFailed((err) => rejectFunc(err));
|
|
@@ -13511,6 +13633,9 @@
|
|
|
13511
13633
|
return executor.snap(resultWindow, target, direction);
|
|
13512
13634
|
}, success, error);
|
|
13513
13635
|
}
|
|
13636
|
+
function dragMove(dragMoveSettings) {
|
|
13637
|
+
return executor.dragMove(resultWindow, dragMoveSettings);
|
|
13638
|
+
}
|
|
13514
13639
|
function attachTab(tab, opt, success, error) {
|
|
13515
13640
|
return Utils.callbackifyPromise(() => {
|
|
13516
13641
|
var _a;
|
|
@@ -13740,6 +13865,9 @@
|
|
|
13740
13865
|
function place(placementSettings) {
|
|
13741
13866
|
return executor.place(resultWindow, placementSettings);
|
|
13742
13867
|
}
|
|
13868
|
+
function clearPlacement(clearPlacementSettings) {
|
|
13869
|
+
return executor.clearPlacement(resultWindow, clearPlacementSettings);
|
|
13870
|
+
}
|
|
13743
13871
|
function refresh(ignoreCache) {
|
|
13744
13872
|
return executor.refresh(resultWindow, ignoreCache);
|
|
13745
13873
|
}
|
|
@@ -14493,6 +14621,7 @@
|
|
|
14493
14621
|
center,
|
|
14494
14622
|
close,
|
|
14495
14623
|
snap,
|
|
14624
|
+
dragMove,
|
|
14496
14625
|
showLoader,
|
|
14497
14626
|
hideLoader,
|
|
14498
14627
|
updateContext,
|
|
@@ -14523,6 +14652,7 @@
|
|
|
14523
14652
|
print,
|
|
14524
14653
|
printToPDF,
|
|
14525
14654
|
place,
|
|
14655
|
+
clearPlacement,
|
|
14526
14656
|
ungroup,
|
|
14527
14657
|
refresh,
|
|
14528
14658
|
goBack,
|
|
@@ -15006,6 +15136,9 @@
|
|
|
15006
15136
|
await this.execute("snap", { windowId: w.id, options: args }, "CompositionChanged", `CompositionChanged-${targetWindow.id}`);
|
|
15007
15137
|
return w;
|
|
15008
15138
|
}
|
|
15139
|
+
dragMove(window, options) {
|
|
15140
|
+
return this.execute("dragMove", { windowId: window.id, options });
|
|
15141
|
+
}
|
|
15009
15142
|
async attachTab(w, sourceWindow, options) {
|
|
15010
15143
|
await this.execute("attachTab", {
|
|
15011
15144
|
windowId: w.id,
|
|
@@ -15266,6 +15399,9 @@
|
|
|
15266
15399
|
}
|
|
15267
15400
|
return this.execute("place", { windowId: window.id, options: { ...copy } });
|
|
15268
15401
|
}
|
|
15402
|
+
async clearPlacement(window, options) {
|
|
15403
|
+
return this.execute("clearPlacement", { windowId: window.id, options });
|
|
15404
|
+
}
|
|
15269
15405
|
async refresh(resultWindow, ignoreCache) {
|
|
15270
15406
|
await this.execute("refresh", { windowId: resultWindow.id, options: { ignoreCache } });
|
|
15271
15407
|
return resultWindow;
|
|
@@ -16928,7 +17064,8 @@
|
|
|
16928
17064
|
}
|
|
16929
17065
|
registerRequestMethods() {
|
|
16930
17066
|
this.interop.register(SaveContextMethodName, (args) => {
|
|
16931
|
-
const
|
|
17067
|
+
const { ignoreContexts, ...cbArgs } = args;
|
|
17068
|
+
const usersCbs = this.callbacks.execute("saveRequested", cbArgs);
|
|
16932
17069
|
if ((usersCbs === null || usersCbs === void 0 ? void 0 : usersCbs.length) > 1) {
|
|
16933
17070
|
this.logger.warn(`Multiple subscriptions for "glue.layouts.onSaveRequested" - only the first one will be used`);
|
|
16934
17071
|
}
|
|
@@ -16944,7 +17081,7 @@
|
|
|
16944
17081
|
if (this.isActivityOwner()) {
|
|
16945
17082
|
result.activityContext = requestResult === null || requestResult === void 0 ? void 0 : requestResult.activityContext;
|
|
16946
17083
|
}
|
|
16947
|
-
return result;
|
|
17084
|
+
return ignoreContexts ? { windowContext: undefined, activityContext: undefined } : result;
|
|
16948
17085
|
});
|
|
16949
17086
|
}
|
|
16950
17087
|
}
|
|
@@ -17150,6 +17287,9 @@
|
|
|
17150
17287
|
if (typeof layout.setAsCurrent === "boolean") {
|
|
17151
17288
|
layoutObject.options.setAsCurrent = layout.setAsCurrent;
|
|
17152
17289
|
}
|
|
17290
|
+
if (typeof layout.ignoreContexts === "boolean") {
|
|
17291
|
+
layoutObject.options.ignoreContexts = layout.ignoreContexts;
|
|
17292
|
+
}
|
|
17153
17293
|
}
|
|
17154
17294
|
else {
|
|
17155
17295
|
return reject(new Error(`layout type ${layout.type} is not supported`));
|
|
@@ -17401,6 +17541,16 @@
|
|
|
17401
17541
|
onChanged(callback) {
|
|
17402
17542
|
return this.callbacks.add("changed", callback);
|
|
17403
17543
|
}
|
|
17544
|
+
onDefaultGlobalChanged(callback) {
|
|
17545
|
+
if (typeof callback !== "function") {
|
|
17546
|
+
throw new Error("callback must be a function");
|
|
17547
|
+
}
|
|
17548
|
+
this.getDefaultGlobal()
|
|
17549
|
+
.then((layout) => callback(layout ? { name: layout.name } : undefined))
|
|
17550
|
+
.catch(() => {
|
|
17551
|
+
});
|
|
17552
|
+
return this.callbacks.add("default-changed", callback);
|
|
17553
|
+
}
|
|
17404
17554
|
onRestored(callback) {
|
|
17405
17555
|
return this.callbacks.add("restored", callback);
|
|
17406
17556
|
}
|
|
@@ -17586,6 +17736,8 @@
|
|
|
17586
17736
|
this.changeLayouts(transform(data.OnLayoutChanged));
|
|
17587
17737
|
this.renameLayouts(transform(data.OnLayoutRenamed));
|
|
17588
17738
|
this.restoredLayout(transform(data.OnLayoutRestored));
|
|
17739
|
+
this.selectedDefaultLayout(transform(data.OnLayoutSelectedDefault), false);
|
|
17740
|
+
this.selectedDefaultLayout(transform(data.OnLayoutDeselectedDefault), true);
|
|
17589
17741
|
this.callbacks.execute("streamEvent", data);
|
|
17590
17742
|
});
|
|
17591
17743
|
subs.onFailed((err) => {
|
|
@@ -17620,7 +17772,7 @@
|
|
|
17620
17772
|
});
|
|
17621
17773
|
setTimeout(() => {
|
|
17622
17774
|
if (!done) {
|
|
17623
|
-
reject(
|
|
17775
|
+
reject(new Error(`Timeout waiting for token ${token}`));
|
|
17624
17776
|
}
|
|
17625
17777
|
}, timeout);
|
|
17626
17778
|
});
|
|
@@ -17686,7 +17838,7 @@
|
|
|
17686
17838
|
throw Error(`received rename event for unknown layout with type ${renamedLayout.type} and name ${renamedLayout.oldName}`);
|
|
17687
17839
|
}
|
|
17688
17840
|
existingLayout.name = renamedLayout.newName;
|
|
17689
|
-
this.callbacks.execute("renamed", existingLayout);
|
|
17841
|
+
this.callbacks.execute("renamed", existingLayout, { name: renamedLayout.oldName });
|
|
17690
17842
|
});
|
|
17691
17843
|
}
|
|
17692
17844
|
compareLayouts(layout1, layout2) {
|
|
@@ -17707,6 +17859,17 @@
|
|
|
17707
17859
|
this.callbacks.execute("restored", existingLayout);
|
|
17708
17860
|
});
|
|
17709
17861
|
}
|
|
17862
|
+
selectedDefaultLayout(selectedDefaultLayouts, deselected) {
|
|
17863
|
+
if (!selectedDefaultLayouts || selectedDefaultLayouts.length === 0) {
|
|
17864
|
+
return;
|
|
17865
|
+
}
|
|
17866
|
+
if (deselected) {
|
|
17867
|
+
this.callbacks.execute("default-changed", undefined);
|
|
17868
|
+
}
|
|
17869
|
+
else {
|
|
17870
|
+
this.callbacks.execute("default-changed", selectedDefaultLayouts[0]);
|
|
17871
|
+
}
|
|
17872
|
+
}
|
|
17710
17873
|
}
|
|
17711
17874
|
|
|
17712
17875
|
function LayoutsFactory (config) {
|
|
@@ -18588,7 +18751,16 @@
|
|
|
18588
18751
|
data: info.data || {}
|
|
18589
18752
|
};
|
|
18590
18753
|
this.logger.trace(`adding channel: ${info.name}`);
|
|
18591
|
-
|
|
18754
|
+
try {
|
|
18755
|
+
await addOrRemoveChannel("addChannel", info.name, info.meta.color, (_a = info.meta) === null || _a === void 0 ? void 0 : _a.label);
|
|
18756
|
+
}
|
|
18757
|
+
catch (error) {
|
|
18758
|
+
if ("message" in error && error.message.includes(`Channel with name '${info.name}' already exists.`)) {
|
|
18759
|
+
this.logger.trace(`channel: ${info.name} already exists - ignore channel add request`);
|
|
18760
|
+
await this.verifyChannelExists(info.name, 10 * 1000);
|
|
18761
|
+
}
|
|
18762
|
+
throw error;
|
|
18763
|
+
}
|
|
18592
18764
|
await this.shared.updateChannel(info.name, context);
|
|
18593
18765
|
return context;
|
|
18594
18766
|
}
|
|
@@ -18694,7 +18866,7 @@
|
|
|
18694
18866
|
this.raiseChannelsChangedEvents();
|
|
18695
18867
|
this.logger.trace(`joined channel: ${name} ${changeSelector ? "" : "from command"} - current channel/s: ${this.currentChannelID.toString()}`);
|
|
18696
18868
|
}
|
|
18697
|
-
async verifyChannelExists(name) {
|
|
18869
|
+
async verifyChannelExists(name, timeout, interval) {
|
|
18698
18870
|
const doesChannelExist = (channelName) => {
|
|
18699
18871
|
const channelNames = this.shared.all();
|
|
18700
18872
|
return channelNames.includes(channelName);
|
|
@@ -18707,11 +18879,11 @@
|
|
|
18707
18879
|
clearInterval(intervalId);
|
|
18708
18880
|
resolve();
|
|
18709
18881
|
}
|
|
18710
|
-
}, 100);
|
|
18882
|
+
}, interval !== null && interval !== void 0 ? interval : 100);
|
|
18711
18883
|
const timeoutId = setTimeout(() => {
|
|
18712
18884
|
clearInterval(intervalId);
|
|
18713
18885
|
return reject(new Error(`A channel with name: ${name} doesn't exist!`));
|
|
18714
|
-
}, 3000);
|
|
18886
|
+
}, timeout !== null && timeout !== void 0 ? timeout : 3000);
|
|
18715
18887
|
});
|
|
18716
18888
|
await channelExistsPromise;
|
|
18717
18889
|
}
|
|
@@ -19183,7 +19355,7 @@
|
|
|
19183
19355
|
};
|
|
19184
19356
|
}
|
|
19185
19357
|
|
|
19186
|
-
var version = "6.
|
|
19358
|
+
var version = "6.15.0";
|
|
19187
19359
|
|
|
19188
19360
|
var prepareConfig = (options) => {
|
|
19189
19361
|
function getLibConfig(value, defaultMode, trueMode) {
|
|
@@ -21441,11 +21613,34 @@
|
|
|
21441
21613
|
throw new Error("Please provide waitUserResponseIndefinitely as a boolean");
|
|
21442
21614
|
}
|
|
21443
21615
|
};
|
|
21616
|
+
const isExcludeListValid = (excludeList) => {
|
|
21617
|
+
if (!Array.isArray(excludeList)) {
|
|
21618
|
+
return false;
|
|
21619
|
+
}
|
|
21620
|
+
const everyItemIsObject = excludeList.every(item => typeof item === "object" && !Array.isArray(item) && item !== null);
|
|
21621
|
+
if (!everyItemIsObject) {
|
|
21622
|
+
return false;
|
|
21623
|
+
}
|
|
21624
|
+
const everyItemHasValidKey = excludeList.every(item => "applicationName" in item || "instanceId" in item);
|
|
21625
|
+
if (!everyItemHasValidKey) {
|
|
21626
|
+
return false;
|
|
21627
|
+
}
|
|
21628
|
+
const everyItemKeysAreValid = excludeList.every(item => {
|
|
21629
|
+
if ("applicationName" in item) {
|
|
21630
|
+
return typeof item.applicationName === "string" && item.applicationName.length;
|
|
21631
|
+
}
|
|
21632
|
+
if ("instanceId" in item) {
|
|
21633
|
+
return typeof item.instanceId === "string" && item.instanceId.length;
|
|
21634
|
+
}
|
|
21635
|
+
return false;
|
|
21636
|
+
});
|
|
21637
|
+
return everyItemKeysAreValid;
|
|
21638
|
+
};
|
|
21444
21639
|
const validateHandlerFilter = (handlerFilter) => {
|
|
21445
21640
|
if (!handlerFilter) {
|
|
21446
21641
|
throw new Error(`Provide 'handlerFilter' with at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'`);
|
|
21447
21642
|
}
|
|
21448
|
-
const { title, openResolver, timeout, intent, contextTypes, resultType, applicationNames } = handlerFilter;
|
|
21643
|
+
const { title, openResolver, timeout, intent, contextTypes, resultType, applicationNames, excludeList } = handlerFilter;
|
|
21449
21644
|
if (typeof title !== "undefined" && (typeof title !== "string" || !title.length)) {
|
|
21450
21645
|
throw new Error(`Provide 'title' as a non empty string`);
|
|
21451
21646
|
}
|
|
@@ -21467,11 +21662,15 @@
|
|
|
21467
21662
|
if (typeof applicationNames !== "undefined" && (!Array.isArray(applicationNames) || applicationNames.some(appName => typeof appName !== "string"))) {
|
|
21468
21663
|
throw new Error(`Provide 'applicationNames' as an array of non empty strings`);
|
|
21469
21664
|
}
|
|
21665
|
+
const excludeListValidation = excludeList ? isExcludeListValid(excludeList) : true;
|
|
21666
|
+
if (!excludeListValidation) {
|
|
21667
|
+
throw new Error("Provide 'excludeList' as an array of objects with either 'applicationName' or 'instanceId' key");
|
|
21668
|
+
}
|
|
21470
21669
|
const errorMsg = "Provide at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'";
|
|
21471
21670
|
if (!Object.keys(handlerFilter).length) {
|
|
21472
21671
|
throw new Error(errorMsg);
|
|
21473
21672
|
}
|
|
21474
|
-
if (!intent && !resultType && (!contextTypes ||
|
|
21673
|
+
if (!intent && !resultType && (!(contextTypes === null || contextTypes === void 0 ? void 0 : contextTypes.length)) && (!(applicationNames === null || applicationNames === void 0 ? void 0 : applicationNames.length))) {
|
|
21475
21674
|
throw new Error(errorMsg);
|
|
21476
21675
|
}
|
|
21477
21676
|
};
|
|
@@ -21765,8 +21964,9 @@
|
|
|
21765
21964
|
throw new Error("Cannot resolve 'filterHandlers' request using Intents Resolver UI because it's globally disabled");
|
|
21766
21965
|
}
|
|
21767
21966
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Received 'filterHandlers' command with request: ${JSON.stringify(handlerFilter)}`);
|
|
21768
|
-
const
|
|
21769
|
-
|
|
21967
|
+
const intents = await this.all();
|
|
21968
|
+
const filteredHandlers = this.filterHandlersBy(intents, handlerFilter);
|
|
21969
|
+
if (!(filteredHandlers === null || filteredHandlers === void 0 ? void 0 : filteredHandlers.length)) {
|
|
21770
21970
|
return { handlers: [] };
|
|
21771
21971
|
}
|
|
21772
21972
|
const { open, reason } = this.checkIfResolverShouldBeOpenedForFilterHandlers(filteredHandlers, handlerFilter);
|
|
@@ -21881,6 +22081,9 @@
|
|
|
21881
22081
|
if (filter.intent && filter.intent !== intent.name) {
|
|
21882
22082
|
return;
|
|
21883
22083
|
}
|
|
22084
|
+
if (filter.excludeList) {
|
|
22085
|
+
intent.handlers = this.excludeIntentHandlers(intent, filter.excludeList);
|
|
22086
|
+
}
|
|
21884
22087
|
if (filter.resultType) {
|
|
21885
22088
|
const filteredHandlers = intent.handlers.filter((handler) => handler.resultType && handler.resultType === filter.resultType);
|
|
21886
22089
|
if (!filteredHandlers.length)
|
|
@@ -21903,6 +22106,21 @@
|
|
|
21903
22106
|
});
|
|
21904
22107
|
return filteredIntentsWithHandlers.map((intent) => intent.handlers).flat(1);
|
|
21905
22108
|
}
|
|
22109
|
+
excludeIntentHandlers(intent, excludeList) {
|
|
22110
|
+
const filtered = intent.handlers.filter((handler) => {
|
|
22111
|
+
const isExcluded = excludeList.some((exclusion) => {
|
|
22112
|
+
if ("applicationName" in exclusion) {
|
|
22113
|
+
return exclusion.applicationName === handler.applicationName;
|
|
22114
|
+
}
|
|
22115
|
+
if ("instanceId" in exclusion) {
|
|
22116
|
+
return exclusion.instanceId === handler.instanceId;
|
|
22117
|
+
}
|
|
22118
|
+
return false;
|
|
22119
|
+
});
|
|
22120
|
+
return !isExcluded;
|
|
22121
|
+
});
|
|
22122
|
+
return filtered;
|
|
22123
|
+
}
|
|
21906
22124
|
async coreRaiseIntent({ request, resolverInstance, timeout }) {
|
|
21907
22125
|
var _a, _b;
|
|
21908
22126
|
const intentDef = await this.get(request.intent);
|