@openfin/cloud-interop 0.1.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.
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Represents the parameters to use to connect to an interop server
3
+ */
4
+ export interface ConnectParams {
5
+ /**
6
+ * The URL of the server to connect to.
7
+ */
8
+ url: string;
9
+ /**
10
+ * The user ID to connect as.
11
+ * Note: Might be the sub from a openid JWT
12
+ */
13
+ userId?: string;
14
+ /**
15
+ * ID for a group of shared applications. Until we have auth we can't rely on only userId.
16
+ */
17
+ platformId: string;
18
+ /**
19
+ * An identifier for the source environment e.g. a hostname, a browser name etc.
20
+ */
21
+ sourceId?: string;
22
+ /**
23
+ * A display name for the source environment e.g. Andys Mobile
24
+ */
25
+ sourceDisplayName?: string;
26
+ /**
27
+ * Specifies an optional extra divider to use that allows separation of interop messages for the
28
+ * same user
29
+ * defaults to "default"
30
+ */
31
+ realm?: string;
32
+ }
33
+ /**
34
+ * Represents a session
35
+ */
36
+ export interface InteropSession {
37
+ sessionId: string;
38
+ }
39
+ /**
40
+ * Represents a source session
41
+ */
42
+ export interface Source {
43
+ /**
44
+ * Source session id
45
+ */
46
+ sessionId: string;
47
+ /**
48
+ * source environment id
49
+ */
50
+ sourceId: string;
51
+ /**
52
+ * source environment display name
53
+ */
54
+ sourceDisplayName: string;
55
+ }
56
+ /**
57
+ * Represents the details of an intent found during discovery
58
+ */
59
+ export interface IntentDetail {
60
+ /**
61
+ * The location of the intent implementation
62
+ */
63
+ source: Source;
64
+ /**
65
+ * The instance id of the intent
66
+ */
67
+ intentInstanceId: string;
68
+ /**
69
+ * The name of the intent
70
+ */
71
+ intentName: string;
72
+ }
73
+ export interface Client {
74
+ /**
75
+ * Connects to an interop server and returns a session
76
+ * @param params The parameters to use to connect
77
+ */
78
+ connect(params: ConnectParams): Promise<void>;
79
+ /**
80
+ * Disconnects from an interop server
81
+ */
82
+ disconnect(): Promise<void>;
83
+ /**
84
+ * Publishes a new context for the given context group to the user other connected sessions
85
+ * @param contextGroup
86
+ * @param context
87
+ */
88
+ setContext(contextGroup: string, context: object): Promise<void>;
89
+ /**
90
+ * Adds a listener for any received context changes
91
+ * @param callback
92
+ */
93
+ addContextListener(callback: (contextGroup: string, context: object, source: Source) => void): void;
94
+ /**
95
+ * Starts the remote intent discovery flow
96
+ *
97
+ * @param intentName The name of the intent to discover when discovering by name
98
+ * @param context The context to use when discovering by context
99
+ *
100
+ * @returns A discovery id that can be used to end the discovery flow
101
+ */
102
+ startIntentDiscovery(intentName?: string, context?: object): Promise<string>;
103
+ /**
104
+ * Ends the remote intent discovery flow
105
+ *
106
+ * @param discoveryId The discovery id returned from startIntentDiscovery
107
+ */
108
+ endIntentDiscovery(discoveryId: string): Promise<void>;
109
+ /**
110
+ * Any client that is responding to an intent discovery request
111
+ * should call this method to send the details of an intent to the requesting client
112
+ * As intents are registered on each client and during a previously started intent discovery flow, this method
113
+ * can be called multiple times to support live intent discovery
114
+ */
115
+ sendIntentDetail(discoveryId: string, intentDetail: IntentDetail): Promise<void>;
116
+ /**
117
+ * Raises the given intent on the given session
118
+ *
119
+ * @param targetSession The session to raise the intent on
120
+ * @param intentInstanceId The instance id of the intent to raise
121
+ * @param context The context to use when raising the intent
122
+ *
123
+ * @returns A promise that resolves to the result of the intent invocation
124
+ */
125
+ raiseIntent(targetSession: string, intentInstanceId: string, context: Object): Promise<any>;
126
+ /**
127
+ * Adds a listener for any received intent details in a client that has invoked startIntentDiscovery
128
+ */
129
+ addIntentDetailListener(callback: (discoveryId: string, intentDetail: IntentDetail) => void): void;
130
+ }
@@ -0,0 +1,5 @@
1
+ import type OpenFin from '@openfin/core';
2
+ import type { ConnectParams } from './interfaces';
3
+ export type CloudInteropOverrideParams = ConnectParams;
4
+ export type CloudInteropConnectionStates = 'connected' | 'reconnecting' | 'disconnected';
5
+ export declare function cloudInteropOverride(config: CloudInteropOverrideParams): Promise<OpenFin.ConstructorOverride<OpenFin.InteropBroker>>;
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@openfin/cloud-interop",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "files": [
6
+ "./dist/*"
7
+ ],
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "scripts": {
11
+ "build": "rollup -c"
12
+ },
13
+ "author": "",
14
+ "license": "SEE LICENSE IN LICENSE.md",
15
+ "devDependencies": {
16
+ "@rollup/plugin-node-resolve": "^15.2.3",
17
+ "@rollup/plugin-typescript": "^11.1.6",
18
+ "@types/node": "^20.10.0",
19
+ "rollup": "^4.9.6",
20
+ "typescript": "^5.3.2"
21
+ },
22
+ "dependencies": {
23
+ "@openfin/core": "^37.80.39",
24
+ "axios": "^1.6.2",
25
+ "mqtt": "^5.3.1"
26
+ }
27
+ }