@openfin/core 29.71.4 → 29.71.15

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/OpenFin.d.ts CHANGED
@@ -1429,6 +1429,7 @@ declare namespace OpenFin {
1429
1429
 
1430
1430
  export type IntentMetadata<TargetType = any> = {
1431
1431
  target?: TargetType;
1432
+ resultType?: string;
1432
1433
  };
1433
1434
 
1434
1435
  export type IntentHandler = (intent: OpenFin.Intent) => void;
@@ -1482,9 +1483,15 @@ declare namespace OpenFin {
1482
1483
  metadata?: MetadataType;
1483
1484
  };
1484
1485
 
1485
- export type InfoForIntentOptions = {
1486
+ export type InfoForIntentOptions<MetadataType = IntentMetadata> = {
1486
1487
  name: string;
1487
1488
  context?: OpenFin.Context;
1489
+ metadata?: MetadataType;
1490
+ };
1491
+
1492
+ export type FindIntentsByContextOptions<MetadataType = IntentMetadata> = {
1493
+ context: OpenFin.Context;
1494
+ metadata?: MetadataType;
1488
1495
  };
1489
1496
 
1490
1497
  export type ProviderIdentity = Identity & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "29.71.4",
3
+ "version": "29.71.15",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
@@ -304,7 +304,7 @@ export declare class InteropBroker extends Base {
304
304
  * @tutorial interop.handleInfoForIntentsByContext
305
305
  * @experimental
306
306
  */
307
- handleInfoForIntentsByContext(context: OpenFin.Context, clientIdentity: OpenFin.ClientIdentity): Promise<unknown>;
307
+ handleInfoForIntentsByContext(context: OpenFin.Context | OpenFin.FindIntentsByContextOptions, clientIdentity: OpenFin.ClientIdentity): Promise<unknown>;
308
308
  /**
309
309
  * Responsible for resolving an Intent based on a specific Context.
310
310
  * Must be overridden.
@@ -332,6 +332,8 @@ export declare class InteropBroker extends Base {
332
332
  app: FDC3.TargetApp;
333
333
  context: OpenFin.Context;
334
334
  }, clientIdentity: OpenFin.ClientIdentity): Promise<void>;
335
+ fdc3HandleFindInstances(app: FDC3v2.AppIdentifier, clientIdentity: OpenFin.ClientIdentity): Promise<unknown>;
336
+ fdc3HandleGetAppMetadata(app: FDC3v2.AppIdentifier, clientIdentity: OpenFin.ClientIdentity): Promise<unknown>;
335
337
  decorateSnapshot(snapshot: OpenFin.Snapshot): OpenFin.Snapshot;
336
338
  applySnapshot(snapshot: OpenFin.Snapshot, options: OpenFin.ApplySnapshotOptions): void;
337
339
  updateExistingClients(contextGroupStates: OpenFin.ContextGroupStates): void;
@@ -628,6 +628,18 @@ class InteropBroker extends base_1.Base {
628
628
  console.warn(warning);
629
629
  throw new Error(utils_1.BROKER_ERRORS.fdc3Open);
630
630
  }
631
+ // eslint-disable-next-line class-methods-use-this
632
+ async fdc3HandleFindInstances(app, clientIdentity) {
633
+ const warning = utils_1.generateOverrideWarning('fdc3.open', 'InteropBroker.fdc3HandleFindInstances', clientIdentity);
634
+ console.warn(warning);
635
+ throw new Error(utils_1.BROKER_ERRORS.fdc3FindInstances);
636
+ }
637
+ // eslint-disable-next-line class-methods-use-this
638
+ async fdc3HandleGetAppMetadata(app, clientIdentity) {
639
+ const warning = utils_1.generateOverrideWarning('fdc3.getAppMetadata', 'InteropBroker.fdc3HandleGetAppMetadata', clientIdentity);
640
+ console.warn(warning);
641
+ throw new Error(utils_1.BROKER_ERRORS.fdc3FindInstances);
642
+ }
631
643
  /*
632
644
  Snapshot APIs
633
645
  */
@@ -936,6 +948,9 @@ class InteropBroker extends base_1.Base {
936
948
  channel.register('sessionContextGroup:createIfNeeded', this.handleJoinSessionContextGroup.bind(this));
937
949
  // fdc3 only methods
938
950
  channel.register('fdc3Open', this.fdc3HandleOpen.bind(this));
951
+ channel.register('fdc3v2FindIntentsByContext', this.handleInfoForIntentsByContext.bind(this));
952
+ channel.register('fdc3FindInstances', this.fdc3HandleFindInstances.bind(this));
953
+ channel.register('fdc3GetAppMetadata', this.fdc3HandleGetAppMetadata.bind(this));
939
954
  }
940
955
  /**
941
956
  * Can be used to completely prevent a connection. Return false to prevent connections. Allows all connections by default.
@@ -217,7 +217,7 @@ export declare class InteropClient extends Base {
217
217
  * @tutorial interop.registerIntentHandler
218
218
  * @experimental
219
219
  */
220
- registerIntentHandler(handler: OpenFin.IntentHandler, intentName: string): Promise<{
220
+ registerIntentHandler(handler: OpenFin.IntentHandler, intentName: string, options?: any): Promise<{
221
221
  unsubscribe: () => Promise<void>;
222
222
  }>;
223
223
  /**
@@ -324,7 +324,7 @@ class InteropClient extends base_1.Base {
324
324
  * @tutorial interop.registerIntentHandler
325
325
  * @experimental
326
326
  */
327
- async registerIntentHandler(handler, intentName) {
327
+ async registerIntentHandler(handler, intentName, options) {
328
328
  this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
329
329
  // don't expose, this is only for api analytics purposes
330
330
  });
@@ -333,7 +333,7 @@ class InteropClient extends base_1.Base {
333
333
  const wrappedHandler = utils_1.wrapIntentHandler(handler, handlerId);
334
334
  try {
335
335
  await client.register(handlerId, wrappedHandler);
336
- await client.dispatch('intentHandlerRegistered', { handlerId });
336
+ await client.dispatch('intentHandlerRegistered', { handlerId, ...options });
337
337
  }
338
338
  catch (error) {
339
339
  throw new Error('Unable to register intent handler');
@@ -215,7 +215,9 @@ class Fdc3Module extends base_1.Base {
215
215
  const contextHandler = (raisedIntent) => {
216
216
  handler(raisedIntent.context);
217
217
  };
218
- const listener = this.fin.me.interop.registerIntentHandler(contextHandler, intent);
218
+ const listener = this.fin.me.interop.registerIntentHandler(contextHandler, intent, {
219
+ fdc3Version: '1.2'
220
+ });
219
221
  return {
220
222
  ...listener,
221
223
  unsubscribe: () => listener.then((l) => l.unsubscribe())
@@ -0,0 +1,24 @@
1
+ import { Base } from '../../base';
2
+ import Transport from '../../../transport/transport';
3
+ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
4
+ private fdc3Module;
5
+ constructor(wire: Transport);
6
+ open(app: FDC3v2.AppIdentifier | FDC3.TargetApp, context?: OpenFin.Context): Promise<FDC3v2.AppIdentifier | void>;
7
+ findInstances(app: FDC3v2.AppIdentifier): Promise<Array<FDC3v2.AppIdentifier>>;
8
+ getAppMetadata(app: FDC3v2.AppIdentifier): Promise<FDC3.AppMetadata>;
9
+ broadcast(context: OpenFin.Context): Promise<void>;
10
+ addContextListener(contextType: string | null, handler: OpenFin.ContextHandler): Promise<FDC3.Listener>;
11
+ findIntent(intent: string, context?: OpenFin.Context, resultType?: string): Promise<FDC3.AppIntent>;
12
+ findIntentsByContext(context: OpenFin.Context, resultType?: string): Promise<Array<FDC3.AppIntent>>;
13
+ raiseIntent(intent: string, context: OpenFin.Context, app?: FDC3v2.AppIdentifier | FDC3.TargetApp): Promise<FDC3.IntentResolution>;
14
+ raiseIntentForContext(context: OpenFin.Context, app?: FDC3v2.AppIdentifier | FDC3.TargetApp): Promise<FDC3.IntentResolution>;
15
+ addIntentListener(intent: string, handler: FDC3v2.IntentHandler): Promise<FDC3.Listener>;
16
+ getOrCreateChannel(channelId: string): Promise<FDC3.Channel>;
17
+ createPrivateChannel(): Promise<FDC3v2.PrivateChannel | void>;
18
+ getUserChannels(): Promise<Array<OpenFin.ContextGroupInfo>>;
19
+ getSystemChannels(): Promise<Array<OpenFin.ContextGroupInfo>>;
20
+ joinUserChannel(channelId: string): Promise<void>;
21
+ getCurrentChannel(): Promise<FDC3.Channel | null>;
22
+ leaveCurrentChannel(): Promise<void>;
23
+ getInfo(): Promise<FDC3.ImplementationMetadata>;
24
+ }
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ // THIS IS NOT PRODUCTION-READY. Until we implement the missing features: getResult, Private Channels and Instance Management we should not document this.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const base_1 = require("../../base");
5
+ const utils_1 = require("../utils");
6
+ const InteropClient_1 = require("../InteropClient");
7
+ const fdc3_1_2_1 = require("./fdc3-1.2");
8
+ class Fdc3Module2 extends base_1.Base {
9
+ constructor(wire) {
10
+ super(wire);
11
+ // we get the module for fdc 1.2 here so we can reuse it wherever we can
12
+ this.fdc3Module = new fdc3_1_2_1.default(this.wire);
13
+ }
14
+ async open(app, context) {
15
+ return this.fdc3Module.open(app, context);
16
+ }
17
+ async findInstances(app) {
18
+ this.wire.sendAction('fdc3-find-instances').catch((e) => {
19
+ // we do not want to expose this error, just continue if this analytics-only call fails
20
+ });
21
+ try {
22
+ return await InteropClient_1.InteropClient.ferryFdc3Call(fin.me.interop, 'fdc3FindInstances', app);
23
+ }
24
+ catch (error) {
25
+ const errorToThrow = error.message === utils_1.BROKER_ERRORS.fdc3FindInstances ? 'ResolverUnavailable' : error;
26
+ throw new Error(errorToThrow);
27
+ }
28
+ }
29
+ async getAppMetadata(app) {
30
+ this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
31
+ // we do not want to expose this error, just continue if this analytics-only call fails
32
+ });
33
+ try {
34
+ return await InteropClient_1.InteropClient.ferryFdc3Call(fin.me.interop, 'fdc3GetAppMetadata', app);
35
+ }
36
+ catch (error) {
37
+ const errorToThrow = error.message === utils_1.BROKER_ERRORS.fdc3GetAppMetadata ? 'ResolverUnavailable' : error;
38
+ throw new Error(errorToThrow);
39
+ }
40
+ }
41
+ async broadcast(context) {
42
+ return this.fdc3Module.broadcast(context);
43
+ }
44
+ async addContextListener(contextType, handler) {
45
+ this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
46
+ // we do not want to expose this error, just continue if this analytics-only call fails
47
+ });
48
+ let listener;
49
+ if (typeof contextType === 'function') {
50
+ console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
51
+ listener = await this.fin.me.interop.addContextHandler(contextType);
52
+ }
53
+ else {
54
+ listener = await this.fin.me.interop.addContextHandler(handler, contextType === null ? undefined : contextType);
55
+ }
56
+ return listener;
57
+ }
58
+ async findIntent(intent, context, resultType) {
59
+ this.wire.sendAction('fdc3-find-intent').catch((e) => {
60
+ // we do not want to expose this error, just continue if this analytics-only call fails
61
+ });
62
+ try {
63
+ return await this.fin.me.interop.getInfoForIntent({ name: intent, context, metadata: { resultType } });
64
+ }
65
+ catch (error) {
66
+ const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error;
67
+ throw new Error(errorToThrow);
68
+ }
69
+ }
70
+ async findIntentsByContext(context, resultType) {
71
+ this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
72
+ // we do not want to expose this error, just continue if this analytics-only call fails
73
+ });
74
+ try {
75
+ return await InteropClient_1.InteropClient.ferryFdc3Call(fin.me.interop, 'fdc3v2FindIntentsByContext', {
76
+ context,
77
+ resultType
78
+ });
79
+ }
80
+ catch (error) {
81
+ const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error;
82
+ throw new Error(errorToThrow);
83
+ }
84
+ }
85
+ async raiseIntent(intent, context, app) {
86
+ return this.fdc3Module.raiseIntent(intent, context, app);
87
+ }
88
+ async raiseIntentForContext(context, app) {
89
+ return this.fdc3Module.raiseIntentForContext(context, app);
90
+ }
91
+ async addIntentListener(intent, handler) {
92
+ this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
93
+ // we do not want to expose this error, just continue if this analytics-only call fails
94
+ });
95
+ const contextHandler = (raisedIntent) => {
96
+ handler(raisedIntent.context);
97
+ };
98
+ return this.fin.me.interop.registerIntentHandler(contextHandler, intent, { fdc3Version: '2.0' });
99
+ }
100
+ async getOrCreateChannel(channelId) {
101
+ return this.fdc3Module.getOrCreateChannel(channelId);
102
+ }
103
+ // eslint-disable-next-line class-methods-use-this
104
+ async createPrivateChannel() {
105
+ // private channels will be implemented in another PR
106
+ }
107
+ async getUserChannels() {
108
+ return this.fdc3Module.getSystemChannels();
109
+ }
110
+ async getSystemChannels() {
111
+ return this.fdc3Module.getSystemChannels();
112
+ }
113
+ async joinUserChannel(channelId) {
114
+ return this.fdc3Module.joinChannel(channelId);
115
+ }
116
+ async getCurrentChannel() {
117
+ return this.fdc3Module.getCurrentChannel();
118
+ }
119
+ async leaveCurrentChannel() {
120
+ return this.leaveCurrentChannel();
121
+ }
122
+ async getInfo() {
123
+ return this.fdc3Module.getInfo();
124
+ }
125
+ }
126
+ exports.default = Fdc3Module2;
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerFdc3Shim = exports.versionMap = void 0;
4
4
  const fdc3_1_2_1 = require("./fdc3-1.2");
5
+ const fdc3_2_0_1 = require("./fdc3-2.0");
5
6
  exports.versionMap = {
6
- '1.2': fdc3_1_2_1.default
7
+ '1.2': fdc3_1_2_1.default,
8
+ '2.0': fdc3_2_0_1.default
7
9
  };
8
10
  function registerFdc3Shim(version, transport) {
9
11
  if (Object.keys(exports.versionMap).includes(version)) {
@@ -10,5 +10,7 @@ export declare const BROKER_ERRORS: {
10
10
  getInfoForIntentsByContext: string;
11
11
  joinSessionContextGroupWithJoinContextGroup: string;
12
12
  fdc3Open: string;
13
+ fdc3FindInstances: string;
14
+ fdc3GetAppMetadata: string;
13
15
  };
14
16
  export declare const wrapIntentHandler: (handler: OpenFin.IntentHandler, handlerId: string) => (intent: OpenFin.Intent) => Promise<void>;
@@ -37,7 +37,9 @@ exports.BROKER_ERRORS = {
37
37
  getInfoForIntent: exports.generateOverrideError('getInfoForIntent', 'handleInfoForIntent'),
38
38
  getInfoForIntentsByContext: exports.generateOverrideError('getInfoForIntentsByContext', 'handleInfoForIntentsByContext'),
39
39
  joinSessionContextGroupWithJoinContextGroup: 'The Context Group you have tried to join is a Session Context Group. Custom Context Groups can only be defined by the Interop Broker through code or manifest configuration. Please use joinSessionContextGroup.',
40
- fdc3Open: exports.generateOverrideError('fdc3.open', 'fdc3HandleOpen')
40
+ fdc3Open: exports.generateOverrideError('fdc3.open', 'fdc3HandleOpen'),
41
+ fdc3FindInstances: exports.generateOverrideError('fdc3.findInstances', 'fdc3HandleFindInstances'),
42
+ fdc3GetAppMetadata: exports.generateOverrideError('fdc3.getAppMetadata', 'fdc3HandleGetAppMetadata')
41
43
  };
42
44
  exports.wrapIntentHandler = (handler, handlerId) => {
43
45
  return async (intent) => {