@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.
- package/LICENSE.md +4 -0
- package/README.md +49 -0
- package/dist/api.d.ts +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3451 -0
- package/dist/interfaces.d.ts +130 -0
- package/dist/override.d.ts +5 -0
- package/package.json +27 -0
package/LICENSE.md
ADDED
package/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# @openfin/cloud-interop
|
2
|
+
|
3
|
+
This package contains an override that enables Cloud Interop for OpenFin `InteropBroker`'s unlocking Interop across applications and devices.
|
4
|
+
|
5
|
+
Overrides are passed to `fin.Platform.init` when initializing a platform or to `fin.Interop.init` when creating an `InteropBroker` directly.
|
6
|
+
|
7
|
+
Once overriden the `InteropBroker` will connect to Cloud Interop. `Context` will be sent to the Cloud Interop server and the broker will receive `Context` updates from other any other connected brokers in the shared session.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
In a Platform:
|
12
|
+
|
13
|
+
```typescript
|
14
|
+
import { cloudInteropOverride } from "@openfin/cloud-interop";
|
15
|
+
import { ExampleOverride } from "./example";
|
16
|
+
|
17
|
+
const cloudConfig = {
|
18
|
+
userId: "andy",
|
19
|
+
platformId: "8cef8205-d5a8-41c4-b368-47475b32c019", // This id is shared between platforms that should communicate
|
20
|
+
url: "<CLOUD_INTEROP_SERVER_URL>",
|
21
|
+
sourceId: fin.me.identity.uuid,
|
22
|
+
source: "Desktop",
|
23
|
+
};
|
24
|
+
|
25
|
+
const InitializedCloudInteropOverride = await cloudInteropOverride(cloudConfig);
|
26
|
+
|
27
|
+
// Ordering is important, ensure Cloud Interop Override is at the end of the list to send overriden Context to the cloud
|
28
|
+
await fin.Platform.init({
|
29
|
+
interopOverride: [ExampleOverride, InitializedCloudInteropOverride],
|
30
|
+
});
|
31
|
+
```
|
32
|
+
|
33
|
+
When creating an `InteropBroker` directly:
|
34
|
+
|
35
|
+
```typescript
|
36
|
+
import { cloudInteropOverride } from "@openfin/cloud-interop";
|
37
|
+
|
38
|
+
const cloudConfig = {
|
39
|
+
userId: "andy",
|
40
|
+
platformId: "8cef8205-d5a8-41c4-b368-47475b32c019", // This id is shared between platforms that should communicate
|
41
|
+
url: "<CLOUD_INTEROP_SERVER_URL>",
|
42
|
+
sourceId: fin.me.identity.uuid,
|
43
|
+
source: "Desktop",
|
44
|
+
};
|
45
|
+
|
46
|
+
const InitializedCloudInteropOverride = await cloudInteropOverride(cloudConfig);
|
47
|
+
|
48
|
+
await fin.Interop.init(fin.me.uuid, InitializedCloudInteropOverride);
|
49
|
+
```
|
package/dist/api.d.ts
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import mqtt from 'mqtt';
|
3
|
+
import { Client, ConnectParams, Source, IntentDetail } from './interfaces';
|
4
|
+
export type { ConnectParams };
|
5
|
+
interface ConnectResponse {
|
6
|
+
sessionId: string;
|
7
|
+
sessionRootTopic: string;
|
8
|
+
mqttUrl: string;
|
9
|
+
mqttToken?: string;
|
10
|
+
}
|
11
|
+
export declare class CloudInteropAPI implements Client {
|
12
|
+
private connectParams;
|
13
|
+
private _sessionDetails?;
|
14
|
+
private _mqttClient?;
|
15
|
+
private reconnectRetryLimit;
|
16
|
+
private reconnectRetries;
|
17
|
+
private contextListener?;
|
18
|
+
constructor(connectParams: ConnectParams);
|
19
|
+
get sessionDetails(): ConnectResponse | undefined;
|
20
|
+
get mqttClient(): mqtt.MqttClient | undefined;
|
21
|
+
connect(params: ConnectParams): Promise<void>;
|
22
|
+
disconnect(): Promise<void>;
|
23
|
+
setContext(contextGroup: string, context: object): Promise<void>;
|
24
|
+
addContextListener(callback: (contextGroup: string, context: object, source: Source) => void): void;
|
25
|
+
startIntentDiscovery(intentName?: string | undefined, context?: object | undefined): Promise<string>;
|
26
|
+
endIntentDiscovery(discoveryId: string): Promise<void>;
|
27
|
+
sendIntentDetail(discoveryId: string, intentDetail: IntentDetail): Promise<void>;
|
28
|
+
raiseIntent(targetSession: string, intentInstanceId: string, context: Object): Promise<any>;
|
29
|
+
addIntentDetailListener(callback: (discoveryId: string, intentDetail: IntentDetail) => void): void;
|
30
|
+
handleCommand(topic: string, message: Buffer, sessionDetails: ConnectResponse): void;
|
31
|
+
}
|
package/dist/index.d.ts
ADDED