@interopio/desktop 6.17.0 → 6.18.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 CHANGED
@@ -1,3 +1,9 @@
1
+ 6.18.0
2
+ - feat: apps - inMemoryAppStore - remove method now accepts an array of app names for batch removal
3
+ - fix: apps - inMemoryAppStore - add input validation (non-empty strings, at least one name) to remove method
4
+ - fix: layouts - restore method timeout deprecated
5
+ - chore: apps - inMemoryAppStore - improve error message handling and add error cause chaining in import, remove, and clear methods
6
+ - chore: update core to 6.8.1
1
7
  6.17.0
2
8
  - feat: intents - add customConfig in intent's app definition
3
9
  - fix: layouts - restore method timeout removed
@@ -11,9 +17,9 @@
11
17
  6.16.1
12
18
  - fix: apps: if the method is not available, do not initialize the apps API
13
19
  - fix: prefs - when calling `io.prefs.get()`, the returned object looks like an unparsed fetch response
20
+ - chore: update core to 6.7.3
14
21
  6.16.0
15
22
  - feat: layouts - restoreWorkspacesByReference option added
16
-
17
23
  - chore: reconnect logic improvement
18
24
  6.15.0
19
25
  - fix: channels - creation inconsistency - G4E-9871
package/desktop.d.ts CHANGED
@@ -1018,7 +1018,7 @@ export declare namespace IOConnectDesktop {
1018
1018
  * Notifies when io.Connect will shut down or restart. If the callback is asynchronous, it will be awaited up to 60 seconds before shutdown continues.
1019
1019
  * @param callback Callback function for handling the event.
1020
1020
  */
1021
- onShuttingDown(callback: (args: ShuttingDownEventArgs) => Promise<{ prevent: boolean }>): UnsubscribeFunction;
1021
+ onShuttingDown(callback: (args: ShuttingDownEventArgs) => Promise<{ prevent: boolean }>): void;
1022
1022
  }
1023
1023
 
1024
1024
  /**
@@ -1910,8 +1910,20 @@ export declare namespace IOConnectDesktop {
1910
1910
  has(name: string): Promise<boolean>;
1911
1911
 
1912
1912
  /**
1913
- * Removes an app definition from the in-memory store.
1914
- * @param options Options for removing an app definition.
1913
+ * Removes one or more app definitions from the in-memory store.
1914
+ * @param options Options for removing one or more app definitions.
1915
+ *
1916
+ * @example
1917
+ * ```javascript
1918
+ * // Removing a single app.
1919
+ * await io.apps.registry.inMemory.remove({ name: "my-app" });
1920
+ *
1921
+ * // Removing multiple apps at a time.
1922
+ * await io.apps.registry.inMemory.remove({ name: ["my-app", "my-other-app"] })
1923
+ *
1924
+ * // Removing multiple apps and stopping all their instances.
1925
+ * await io.apps.registry.inMemory.remove({ name: ["my-app", "my-other-app"], stopInstances: true });
1926
+ * ```
1915
1927
  */
1916
1928
  remove(options: RemoveAppOptions): Promise<void>;
1917
1929
 
@@ -2362,17 +2374,17 @@ export declare namespace IOConnectDesktop {
2362
2374
  }
2363
2375
 
2364
2376
  /**
2365
- * Options for removing and app definition from the in-memory store.
2377
+ * Options for removing app definitions from the in-memory store.
2366
2378
  */
2367
2379
  export interface RemoveAppOptions {
2368
2380
 
2369
2381
  /**
2370
- * Name of the app whose definition to remove.
2382
+ * Name of the app whose definition to remove or an array of app names if you want to remove multiple apps at a time.
2371
2383
  */
2372
- readonly name: string;
2384
+ readonly name: string | string[];
2373
2385
 
2374
2386
  /**
2375
- * If `true`, all currently running instances of the app will be stopped.
2387
+ * If `true`, all currently running instances of the removed apps will be stopped.
2376
2388
  * @default false
2377
2389
  */
2378
2390
  readonly stopInstances?: boolean;
@@ -2506,7 +2518,7 @@ export declare namespace IOConnectDesktop {
2506
2518
  * before the platform shuts down or restarts. The available time for the execution of your code is 60 seconds.
2507
2519
  * To prevent the platform shutdown or restart, the callback must resolve with an object with a `prevent` property set to `true`.
2508
2520
  */
2509
- onShuttingDown(callback: (args: ShuttingDownEventArgs) => Promise<{ prevent: boolean }>): UnsubscribeFunction;
2521
+ onShuttingDown(callback: (args: ShuttingDownEventArgs) => Promise<{ prevent: boolean }>): () => void;
2510
2522
  }
2511
2523
 
2512
2524
  /**
@@ -3322,6 +3334,13 @@ export declare namespace IOConnectDesktop {
3322
3334
  */
3323
3335
  context?: unknown;
3324
3336
 
3337
+ /**
3338
+ * Timeout in milliseconds for restoring the Layout.
3339
+ * If the time limit is hit, all apps opened up to this point will be closed and an error will be thrown.
3340
+ * @deprecated
3341
+ */
3342
+ timeout?: number;
3343
+
3325
3344
  /**
3326
3345
  * Only if the type is `"Activity"`. If `true`, will try to reuse existing windows when restoring the Layout.
3327
3346
  * @default true
@@ -1224,6 +1224,13 @@
1224
1224
  }
1225
1225
  seen.add(value);
1226
1226
  }
1227
+ if (value instanceof Error) {
1228
+ return {
1229
+ message: value.message,
1230
+ name: value.name,
1231
+ stack: value.stack
1232
+ };
1233
+ }
1227
1234
  return value;
1228
1235
  };
1229
1236
  reason = JSON.stringify(err, replacer);
@@ -1468,6 +1475,7 @@
1468
1475
  this.notifyStatusChanged(true);
1469
1476
  }
1470
1477
  close() {
1478
+ this.logger.debug(`closing connection - clientId: ${this.myClientId}, windowId: ${this.identity?.windowId || "unknown"}, client connected: ${this.iAmConnected}`);
1471
1479
  const message = {
1472
1480
  glue42core: {
1473
1481
  type: this.messages.gatewayDisconnect.name,
@@ -1540,7 +1548,7 @@
1540
1548
  selfAssignedWindowId: this.selfAssignedWindowId
1541
1549
  }
1542
1550
  };
1543
- this.logger.debug("sending connection request");
1551
+ this.logger.debug(`sending connection request - clientId: ${this.myClientId}`);
1544
1552
  if (this.extContentConnecting) {
1545
1553
  request.glue42core.clientType = "child";
1546
1554
  request.glue42core.bridgeInstanceId = this.myClientId;
@@ -1567,6 +1575,7 @@
1567
1575
  this.logger.debug("skipping generic message listener, because this is an internal client");
1568
1576
  return;
1569
1577
  }
1578
+ this.logger.debug("setting up window message listener");
1570
1579
  window.addEventListener("message", (event) => {
1571
1580
  const data = event.data?.glue42core;
1572
1581
  if (!data || this.rejected) {
@@ -1591,6 +1600,7 @@
1591
1600
  this.logger.debug("skipping unload event listener, because this is an internal client");
1592
1601
  return;
1593
1602
  }
1603
+ this.logger.debug("setting up unload event listeners");
1594
1604
  window.addEventListener("beforeunload", () => {
1595
1605
  if (this._connectionProtocolVersion) {
1596
1606
  return;
@@ -1608,6 +1618,7 @@
1608
1618
  if (this.extContentConnected) {
1609
1619
  return;
1610
1620
  }
1621
+ this.logger.debug(`signaling client disappearing for clientId: ${this.myClientId}`);
1611
1622
  const message = {
1612
1623
  glue42core: {
1613
1624
  type: this.messages.clientUnload.name,
@@ -1742,6 +1753,7 @@
1742
1753
  source.postMessage(message, event.origin);
1743
1754
  }
1744
1755
  setupPlatformUnloadListener() {
1756
+ this.logger.debug("setting up platform unload listener");
1745
1757
  this.onMessage((msg) => {
1746
1758
  if (msg.type === "platformUnload") {
1747
1759
  this.logger.debug("detected a web platform unload");
@@ -1751,6 +1763,7 @@
1751
1763
  });
1752
1764
  }
1753
1765
  handleManualUnload() {
1766
+ this.logger.debug("handling manual unload");
1754
1767
  const message = {
1755
1768
  glue42core: {
1756
1769
  type: this.messages.clientUnload.name,
@@ -1769,6 +1782,7 @@
1769
1782
  return;
1770
1783
  }
1771
1784
  notifyStatusChanged(status, reason) {
1785
+ this.logger.debug(`status changed - connected: ${status}, reason: ${reason || "none"}`);
1772
1786
  this.iAmConnected = status;
1773
1787
  this.registry.execute("onConnectedChanged", status, reason);
1774
1788
  }
@@ -2738,7 +2752,7 @@
2738
2752
  return authentication;
2739
2753
  }
2740
2754
  async logoutCore() {
2741
- this.logger.debug("logging out...");
2755
+ this.logger.debug("core logging out...");
2742
2756
  this.shouldTryLogin = false;
2743
2757
  if (this.pingTimer) {
2744
2758
  clearTimeout(this.pingTimer);
@@ -2969,7 +2983,7 @@
2969
2983
  }
2970
2984
  };
2971
2985
 
2972
- var version$1 = "6.7.3";
2986
+ var version$1 = "6.8.1";
2973
2987
 
2974
2988
  function prepareConfig$1 (configuration, ext, glue42gd) {
2975
2989
  let nodeStartingContext;
@@ -6752,7 +6766,6 @@
6752
6766
  };
6753
6767
  const nonEmptyStringDecoder$1 = string$1().where((s) => s.length > 0, "Expected a non-empty string");
6754
6768
  const nonNegativeNumberDecoder$1 = number$1().where((num) => num >= 0, "Expected a non-negative number or 0");
6755
- const positiveNumberDecoder = number$1().where((num) => num > 0, "Expected a positive number");
6756
6769
  const methodDefinitionDecoder = object$1({
6757
6770
  name: nonEmptyStringDecoder$1,
6758
6771
  objectTypes: optional$1(array$1(nonEmptyStringDecoder$1)),
@@ -6785,8 +6798,8 @@
6785
6798
  });
6786
6799
  const targetDecoder = union(constant$1("best"), constant$1("all"), constant$1("skipMine"), instanceDecoder, array$1(instanceDecoder));
6787
6800
  const invokeOptionsDecoder = object$1({
6788
- waitTimeoutMs: optional$1(positiveNumberDecoder),
6789
- methodResponseTimeoutMs: optional$1(positiveNumberDecoder)
6801
+ waitTimeoutMs: optional$1(nonNegativeNumberDecoder$1),
6802
+ methodResponseTimeoutMs: optional$1(nonNegativeNumberDecoder$1)
6790
6803
  });
6791
6804
 
6792
6805
  var InvokeStatus;
@@ -20467,7 +20480,7 @@
20467
20480
  }
20468
20481
  }
20469
20482
 
20470
- var version = "6.17.0";
20483
+ var version = "6.18.0";
20471
20484
 
20472
20485
  var prepareConfig = (options) => {
20473
20486
  function getLibConfig(value, defaultMode, trueMode) {
@@ -24438,9 +24451,10 @@
24438
24451
  };
24439
24452
  }
24440
24453
  catch (error) {
24441
- const msg = `Failed to import app definitions: ${error.message}`;
24454
+ const errorMessage = error instanceof Error ? error.message : String(error);
24455
+ const msg = `Failed to import app definitions: ${errorMessage}`;
24442
24456
  this.logger.error(msg, error);
24443
- throw new Error(msg);
24457
+ throw new Error(msg, { cause: error });
24444
24458
  }
24445
24459
  }
24446
24460
  async has(name) {
@@ -24451,18 +24465,40 @@
24451
24465
  return result.returned.result !== undefined ? result.returned.result : false;
24452
24466
  }
24453
24467
  async remove(options) {
24454
- if (!(options === null || options === void 0 ? void 0 : options.name)) {
24468
+ if ((options === null || options === void 0 ? void 0 : options.name) === undefined) {
24455
24469
  throw new Error("App name is required for removal");
24456
24470
  }
24457
- this.logger.debug(`Removing app definition: ${options.name}`);
24471
+ const names = Array.isArray(options.name) ? options.name : [options.name];
24472
+ if (names.length === 0) {
24473
+ throw new Error("At least one app name is required for removal");
24474
+ }
24475
+ const invalidEntries = [];
24476
+ names.forEach((entry, index) => {
24477
+ if (typeof entry !== 'string') {
24478
+ invalidEntries.push(`index ${index}: expected string, got ${typeof entry}`);
24479
+ }
24480
+ else if (entry.trim() === '') {
24481
+ invalidEntries.push(`index ${index}: empty or whitespace-only string`);
24482
+ }
24483
+ });
24484
+ if (invalidEntries.length > 0) {
24485
+ throw new Error(`Invalid app name(s) for removal: ${invalidEntries.join('; ')}`);
24486
+ }
24487
+ const maxSampleSize = 10;
24488
+ const sampleNames = names.slice(0, maxSampleSize);
24489
+ const displayNames = Array.isArray(options.name)
24490
+ ? `[${sampleNames.join(", ")}${names.length > maxSampleSize ? ", ..." : ""}] (total ${names.length})`
24491
+ : options.name;
24492
+ this.logger.debug(`Removing app definition(s): ${displayNames}`);
24458
24493
  try {
24459
24494
  await invokeAppsCommand(this.interop, "in-memory-remove", options);
24460
- this.logger.debug(`Removed app definition: ${options.name}`);
24495
+ this.logger.debug(`Removed app definition(s): ${displayNames}`);
24461
24496
  }
24462
24497
  catch (error) {
24463
- const msg = `Failed to remove app definition: ${options.name}`;
24498
+ const errorMessage = error instanceof Error ? error.message : String(error);
24499
+ const msg = `Failed to remove app definition(s): ${displayNames}. ${errorMessage}`;
24464
24500
  this.logger.error(msg, error);
24465
- throw new Error(msg);
24501
+ throw new Error(msg, { cause: error });
24466
24502
  }
24467
24503
  }
24468
24504
  async clear(options) {
@@ -24471,9 +24507,10 @@
24471
24507
  await invokeAppsCommand(this.interop, "in-memory-clear", options);
24472
24508
  }
24473
24509
  catch (error) {
24474
- const msg = `Failed to clear in-memory app definitions: ${error.message}`;
24510
+ const errorMessage = error instanceof Error ? error.message : String(error);
24511
+ const msg = `Failed to clear in-memory app definitions: ${errorMessage}`;
24475
24512
  this.logger.error(msg, error);
24476
- throw new Error(msg);
24513
+ throw new Error(msg, { cause: error });
24477
24514
  }
24478
24515
  }
24479
24516
  }