@openfin/node-adapter 46.100.65 → 46.100.67

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.
Files changed (2) hide show
  1. package/out/node-adapter.js +129 -74
  2. package/package.json +2 -2
@@ -12916,6 +12916,45 @@ class PrivateChannelProvider {
12916
12916
  }
12917
12917
  }
12918
12918
 
12919
+ /**
12920
+ * The default FDC3 user channels advertised by the Interop Broker.
12921
+ */
12922
+ const defaultColorChannels = {
12923
+ 'fdc3.channel.1': { name: 'Channel 1', color: 'red', glyph: '1' },
12924
+ 'fdc3.channel.2': { name: 'Channel 2', color: 'orange', glyph: '2' },
12925
+ 'fdc3.channel.3': { name: 'Channel 3', color: 'yellow', glyph: '3' },
12926
+ 'fdc3.channel.4': { name: 'Channel 4', color: 'green', glyph: '4' },
12927
+ 'fdc3.channel.5': { name: 'Channel 5', color: 'cyan', glyph: '5' },
12928
+ 'fdc3.channel.6': { name: 'Channel 6', color: 'blue', glyph: '6' },
12929
+ 'fdc3.channel.7': { name: 'Channel 7', color: 'magenta', glyph: '7' },
12930
+ 'fdc3.channel.8': { name: 'Channel 8', color: 'purple', glyph: '8' }
12931
+ };
12932
+ const legacyColorChannelIds = {
12933
+ red: 'fdc3.channel.1',
12934
+ orange: 'fdc3.channel.2',
12935
+ yellow: 'fdc3.channel.3',
12936
+ green: 'fdc3.channel.4',
12937
+ teal: 'fdc3.channel.5',
12938
+ blue: 'fdc3.channel.6',
12939
+ pink: 'fdc3.channel.7',
12940
+ // Legacy indigo (workspace) and purple (core) intentionally converge on the same FDC3 purple channel.
12941
+ indigo: 'fdc3.channel.8',
12942
+ purple: 'fdc3.channel.8'
12943
+ };
12944
+ /**
12945
+ * Converts a legacy color-named channel ID to its canonical FDC3 user-channel ID.
12946
+ * The removed legacy gray channel resolves to no channel.
12947
+ */
12948
+ function normalizeColorChannelId(colorChannelId) {
12949
+ if (colorChannelId === 'gray') {
12950
+ return undefined;
12951
+ }
12952
+ if (Object.prototype.hasOwnProperty.call(legacyColorChannelIds, colorChannelId)) {
12953
+ return legacyColorChannelIds[colorChannelId];
12954
+ }
12955
+ return colorChannelId;
12956
+ }
12957
+
12919
12958
  var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12920
12959
  if (kind === "m") throw new TypeError("Private method is not writable");
12921
12960
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -12928,50 +12967,7 @@ var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) |
12928
12967
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12929
12968
  };
12930
12969
  var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
12931
- const defaultContextGroups = [
12932
- {
12933
- id: 'green',
12934
- displayMetadata: {
12935
- color: '#00CC88',
12936
- name: 'green'
12937
- }
12938
- },
12939
- {
12940
- id: 'purple',
12941
- displayMetadata: {
12942
- color: '#8C61FF',
12943
- name: 'purple'
12944
- }
12945
- },
12946
- {
12947
- id: 'orange',
12948
- displayMetadata: {
12949
- color: '#FF8C4C',
12950
- name: 'orange'
12951
- }
12952
- },
12953
- {
12954
- id: 'red',
12955
- displayMetadata: {
12956
- color: '#FF5E60',
12957
- name: 'red'
12958
- }
12959
- },
12960
- {
12961
- id: 'pink',
12962
- displayMetadata: {
12963
- color: '#FF8FB8',
12964
- name: 'pink'
12965
- }
12966
- },
12967
- {
12968
- id: 'yellow',
12969
- displayMetadata: {
12970
- color: '#E9FF8F',
12971
- name: 'yellow'
12972
- }
12973
- }
12974
- ];
12970
+ const defaultContextGroups = Object.entries(defaultColorChannels).map(([id, displayMetadata]) => ({ id, displayMetadata }));
12975
12971
  /**
12976
12972
  * {@link https://developers.openfin.co/of-docs/docs/enable-color-linking}
12977
12973
  *
@@ -13001,17 +12997,19 @@ const defaultContextGroups = [
13001
12997
  * "interopBrokerConfiguration": {
13002
12998
  * "contextGroups": [
13003
12999
  * {
13004
- * "id": "green",
13000
+ * "id": "fdc3.channel.4",
13005
13001
  * "displayMetadata": {
13006
- * "color": "#00CC88",
13007
- * "name": "green"
13002
+ * "color": "green",
13003
+ * "name": "Channel 4",
13004
+ * "glyph": "4"
13008
13005
  * }
13009
13006
  * },
13010
13007
  * {
13011
- * "id": "purple",
13008
+ * "id": "fdc3.channel.8",
13012
13009
  * "displayMetadata": {
13013
- * "color": "#8C61FF",
13014
- * "name": "purple"
13010
+ * "color": "purple",
13011
+ * "name": "Channel 8",
13012
+ * "glyph": "8"
13015
13013
  * }
13016
13014
  * },
13017
13015
  * ]
@@ -13174,9 +13172,13 @@ class InteropBroker extends Base {
13174
13172
  this.wire.sendAction('interop-broker-set-context-for-group').catch((e) => {
13175
13173
  // don't expose, analytics-only call
13176
13174
  });
13177
- const contextGroupState = this.contextGroupsById.get(contextGroupId);
13175
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13176
+ if (normalizedContextGroupId === undefined) {
13177
+ return;
13178
+ }
13179
+ const contextGroupState = this.contextGroupsById.get(normalizedContextGroupId);
13178
13180
  if (!contextGroupState) {
13179
- throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${contextGroupId}.`);
13181
+ throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${normalizedContextGroupId}.`);
13180
13182
  }
13181
13183
  const contextIntegrityCheckResult = InteropBroker.checkContextIntegrity(context);
13182
13184
  if (contextIntegrityCheckResult.isValid === false) {
@@ -13184,8 +13186,8 @@ class InteropBroker extends Base {
13184
13186
  }
13185
13187
  const broadcastedContextType = context.type;
13186
13188
  contextGroupState.set(broadcastedContextType, context);
13187
- this.lastContextMap.set(contextGroupId, broadcastedContextType);
13188
- const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === contextGroupId);
13189
+ this.lastContextMap.set(normalizedContextGroupId, broadcastedContextType);
13190
+ const clientsInSameContextGroup = Array.from(this.interopClients.values()).filter((connectedClient) => connectedClient.contextGroupId === normalizedContextGroupId);
13189
13191
  clientsInSameContextGroup.forEach((client) => {
13190
13192
  for (const [, handlerInfo] of client.contextHandlers) {
13191
13193
  if (InteropBroker.isContextTypeCompatible(broadcastedContextType, handlerInfo.contextType)) {
@@ -13231,10 +13233,20 @@ class InteropBroker extends Base {
13231
13233
  * @param joinContextGroupOptions - Id of the Context Group and identity of the entity to join to the group.
13232
13234
  * @param senderIdentity - Identity of the client sender.
13233
13235
  */
13234
- async joinContextGroup({ contextGroupId, target }, senderIdentity) {
13236
+ async joinContextGroup({ contextGroupId: requestedContextGroupId, target }, senderIdentity) {
13235
13237
  this.wire.sendAction('interop-broker-join-context-group').catch((e) => {
13236
13238
  // don't expose, analytics-only call
13237
13239
  });
13240
+ const contextGroupId = this.normalizeContextGroupId(requestedContextGroupId);
13241
+ if (contextGroupId === undefined) {
13242
+ if (target) {
13243
+ await this.removeFromContextGroup({ target }, senderIdentity);
13244
+ }
13245
+ else {
13246
+ await this.removeClientFromContextGroup(senderIdentity);
13247
+ }
13248
+ return;
13249
+ }
13238
13250
  if (this.sessionContextGroupMap.has(contextGroupId)) {
13239
13251
  throw new Error(BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup);
13240
13252
  }
@@ -13276,10 +13288,15 @@ class InteropBroker extends Base {
13276
13288
  * @param addClientToContextGroupOptions - Contains the contextGroupId
13277
13289
  * @param clientIdentity - Identity of the client sender.
13278
13290
  */
13279
- async addClientToContextGroup({ contextGroupId }, clientIdentity) {
13291
+ async addClientToContextGroup({ contextGroupId: requestedContextGroupId }, clientIdentity) {
13280
13292
  this.wire.sendAction('interop-broker-add-client-to-context-group').catch((e) => {
13281
13293
  // don't expose, analytics-only call
13282
13294
  });
13295
+ const contextGroupId = this.normalizeContextGroupId(requestedContextGroupId);
13296
+ if (contextGroupId === undefined) {
13297
+ await this.removeClientFromContextGroup(clientIdentity);
13298
+ return;
13299
+ }
13283
13300
  const clientSubscriptionState = this.getClientState(clientIdentity);
13284
13301
  if (!clientSubscriptionState) {
13285
13302
  throw new Error(`Client with Identity: ${clientIdentity.uuid} ${clientIdentity.name} not in Client State Map`);
@@ -13378,6 +13395,9 @@ class InteropBroker extends Base {
13378
13395
  clientState.contextGroupId = undefined;
13379
13396
  }
13380
13397
  await this.setCurrentContextGroupInClientOptions(clientIdentity, null);
13398
+ if (previousContextGroupId === undefined) {
13399
+ return;
13400
+ }
13381
13401
  // All settled will suppress uncaught exceptions. We don't want to await this because it could
13382
13402
  // result in the operation hanging.
13383
13403
  Promise.allSettled(this.channel.publish('client-changed-context-group', {
@@ -13415,7 +13435,11 @@ class InteropBroker extends Base {
13415
13435
  this.wire.sendAction('interop-broker-get-info-for-context-group').catch((e) => {
13416
13436
  // don't expose, analytics-only call
13417
13437
  });
13418
- return this.getContextGroups().find((contextGroup) => contextGroup.id === contextGroupId);
13438
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13439
+ if (normalizedContextGroupId === undefined) {
13440
+ return undefined;
13441
+ }
13442
+ return this.getContextGroups().find((contextGroup) => contextGroup.id === normalizedContextGroupId);
13419
13443
  }
13420
13444
  // Used by platform windows to get all clients for a context group.
13421
13445
  /**
@@ -13431,8 +13455,12 @@ class InteropBroker extends Base {
13431
13455
  this.wire.sendAction('interop-broker-get-all-clients-in-context-group').catch((e) => {
13432
13456
  // don't expose, analytics-only call
13433
13457
  });
13458
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
13459
+ if (normalizedContextGroupId === undefined) {
13460
+ return [];
13461
+ }
13434
13462
  const clientsInContextGroup = Array.from(this.interopClients.values())
13435
- .filter((connectedClient) => connectedClient.contextGroupId === contextGroupId)
13463
+ .filter((connectedClient) => connectedClient.contextGroupId === normalizedContextGroupId)
13436
13464
  .map((subscriptionState) => {
13437
13465
  return subscriptionState.clientIdentity;
13438
13466
  });
@@ -13879,8 +13907,9 @@ class InteropBroker extends Base {
13879
13907
  }
13880
13908
  // Used to restore interop broker state in snapshots.
13881
13909
  applySnapshot(snapshot, options) {
13882
- const contextGroupStates = snapshot?.interopSnapshotDetails?.contextGroupStates;
13883
- if (contextGroupStates) {
13910
+ const incomingContextGroupStates = snapshot?.interopSnapshotDetails?.contextGroupStates;
13911
+ if (incomingContextGroupStates) {
13912
+ const contextGroupStates = this.normalizeContextGroupStates(incomingContextGroupStates);
13884
13913
  if (!options?.closeExistingWindows) {
13885
13914
  this.updateExistingClients(contextGroupStates);
13886
13915
  }
@@ -14025,6 +14054,23 @@ class InteropBroker extends Base {
14025
14054
  });
14026
14055
  return newObject;
14027
14056
  }
14057
+ normalizeContextGroupStates(incomingContextGroupStates) {
14058
+ const normalizedContextGroupStates = {};
14059
+ for (const [contextGroupId, contexts] of Object.entries(incomingContextGroupStates)) {
14060
+ const normalizedContextGroupId = this.normalizeContextGroupId(contextGroupId);
14061
+ if (normalizedContextGroupId !== undefined) {
14062
+ normalizedContextGroupStates[normalizedContextGroupId] = {
14063
+ ...normalizedContextGroupStates[normalizedContextGroupId],
14064
+ ...contexts
14065
+ };
14066
+ }
14067
+ }
14068
+ return normalizedContextGroupStates;
14069
+ }
14070
+ normalizeContextGroupId(contextGroupId) {
14071
+ const usesDefaultColorChannels = Object.keys(defaultColorChannels).every((defaultContextGroupId) => this.contextGroupsById.has(defaultContextGroupId));
14072
+ return usesDefaultColorChannels ? normalizeColorChannelId(contextGroupId) : contextGroupId;
14073
+ }
14028
14074
  // Util to check a client identity.
14029
14075
  static hasEndpointId(target) {
14030
14076
  return target.endpointId !== undefined;
@@ -14088,8 +14134,14 @@ class InteropBroker extends Base {
14088
14134
  clientIdentity
14089
14135
  };
14090
14136
  // Only allow the client to join a contextGroup that actually exists.
14091
- if (payload?.currentContextGroup && this.contextGroupsById.has(payload.currentContextGroup)) {
14092
- clientSubscriptionState.contextGroupId = payload?.currentContextGroup;
14137
+ const currentContextGroup = payload?.currentContextGroup
14138
+ ? this.normalizeContextGroupId(payload.currentContextGroup)
14139
+ : undefined;
14140
+ if (currentContextGroup && this.contextGroupsById.has(currentContextGroup)) {
14141
+ clientSubscriptionState.contextGroupId = currentContextGroup;
14142
+ if (currentContextGroup !== payload.currentContextGroup) {
14143
+ await this.setCurrentContextGroupInClientOptions(clientIdentity, currentContextGroup);
14144
+ }
14093
14145
  }
14094
14146
  this.interopClients.set(clientIdentity.endpointId, clientSubscriptionState);
14095
14147
  });
@@ -14659,7 +14711,7 @@ class InteropClient extends Base {
14659
14711
  *
14660
14712
  * getLastFocusedView()
14661
14713
  * .then(lastFocusedViewIdentity => {
14662
- * joinViewToContextGroup('red', lastFocusedViewIdentity)
14714
+ * joinViewToContextGroup('fdc3.channel.1', lastFocusedViewIdentity)
14663
14715
  * })
14664
14716
  * ```
14665
14717
  */
@@ -14709,7 +14761,7 @@ class InteropClient extends Base {
14709
14761
  *
14710
14762
  * @example
14711
14763
  * ```js
14712
- * fin.me.interop.getAllClientsInContextGroup('red')
14764
+ * fin.me.interop.getAllClientsInContextGroup('fdc3.channel.1')
14713
14765
  * .then(clientsInContextGroup => {
14714
14766
  * console.log(clientsInContextGroup)
14715
14767
  * })
@@ -14733,7 +14785,7 @@ class InteropClient extends Base {
14733
14785
  *
14734
14786
  * @example
14735
14787
  * ```js
14736
- * fin.me.interop.getInfoForContextGroup('red')
14788
+ * fin.me.interop.getInfoForContextGroup('fdc3.channel.1')
14737
14789
  * .then(contextGroupInfo => {
14738
14790
  * console.log(contextGroupInfo.displayMetadata.name)
14739
14791
  * console.log(contextGroupInfo.displayMetadata.color)
@@ -14822,12 +14874,12 @@ class InteropClient extends Base {
14822
14874
  *
14823
14875
  * @example
14824
14876
  * ```js
14825
- * await fin.me.interop.joinContextGroup('yellow');
14877
+ * await fin.me.interop.joinContextGroup('fdc3.channel.3');
14826
14878
  * await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
14827
14879
  * const currentContext = await fin.me.interop.getCurrentContext();
14828
14880
  *
14829
14881
  * // with a specific context
14830
- * await fin.me.interop.joinContextGroup('yellow');
14882
+ * await fin.me.interop.joinContextGroup('fdc3.channel.3');
14831
14883
  * await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
14832
14884
  * await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
14833
14885
  * const currentContext = await fin.me.interop.getCurrentContext('country');
@@ -15493,15 +15545,18 @@ class FDC3ModuleBase {
15493
15545
  async joinChannel(channelId) {
15494
15546
  this.wire.recordAnalytic('fdc3-join-channel');
15495
15547
  try {
15548
+ const contextGroup = await this.client.getInfoForContextGroup(channelId);
15549
+ if (!contextGroup) {
15550
+ console.error(`No User Channel was found with the ID "${channelId}". If this is an App Channel, use getOrCreateChannel instead.`);
15551
+ throw new Error(ChannelError.NoChannelFound);
15552
+ }
15496
15553
  return await this.client.joinContextGroup(channelId);
15497
15554
  }
15498
15555
  catch (error) {
15499
- if (error.message === BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
15500
- console.error('The Channel you have tried to join is an App Channel. Custom Channels can only be defined by the Interop Broker through code or manifest configuration. Please use getOrCreateChannel.');
15501
- }
15502
- else {
15503
- console.error(error.message);
15556
+ if (error.message === ChannelError.NoChannelFound) {
15557
+ throw new Error(ChannelError.NoChannelFound);
15504
15558
  }
15559
+ console.error(error.message);
15505
15560
  if (error.message.startsWith('Attempting to join a context group that does not exist')) {
15506
15561
  throw new Error(ChannelError.NoChannelFound);
15507
15562
  }
@@ -16181,7 +16236,7 @@ class InteropModule extends Base {
16181
16236
  * @example
16182
16237
  * ```js
16183
16238
  * const interopConfig = {
16184
- * currentContextGroup: 'green'
16239
+ * currentContextGroup: 'fdc3.channel.4'
16185
16240
  * }
16186
16241
  *
16187
16242
  * const interopBroker = await fin.Interop.init('openfin');
@@ -17495,7 +17550,7 @@ class NodeEnvironment extends BaseEnvironment {
17495
17550
  };
17496
17551
  }
17497
17552
  getAdapterVersionSync() {
17498
- return "46.100.65";
17553
+ return "46.100.67";
17499
17554
  }
17500
17555
  observeBounds(element, onChange) {
17501
17556
  throw new Error('Method not implemented.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/node-adapter",
3
- "version": "46.100.65",
3
+ "version": "46.100.67",
4
4
  "description": "See README.md",
5
5
  "main": "out/node-adapter.js",
6
6
  "types": "out/node-adapter.d.ts",
@@ -20,7 +20,7 @@
20
20
  "es-toolkit": "^1.39.3",
21
21
  "ws": "^7.5.11",
22
22
  "tslib": "2.8.1",
23
- "@openfin/core": "46.100.65"
23
+ "@openfin/core": "46.100.67"
24
24
  },
25
25
  "scripts": {
26
26
  "prebuild": "rimraf ./out",