@openfin/cloud-interop-core-api 0.0.1-alpha.384d88e → 0.0.1-alpha.47835ce

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.
@@ -13,13 +13,9 @@ export type ConnectParameters = {
13
13
  */
14
14
  platformId: string;
15
15
  /**
16
- * An identifier for the source environment e.g. a hostname, a browser name etc.
16
+ * An user-friendly identifier for the source session e.g. Windows Desktop, Android Phone, etc.
17
17
  */
18
18
  sourceId: string;
19
- /**
20
- * A display name for the source environment e.g. Andys Mobile
21
- */
22
- sourceDisplayName?: string;
23
19
  /**
24
20
  * The maximum number of times to retry connecting to the cloud interop service when the connection is dropped
25
21
  * defaults to 30
@@ -77,49 +73,13 @@ export type ConnectParameters = {
77
73
  export type CloudInteropSettings = {
78
74
  url: string;
79
75
  };
80
- /**
81
- * Represents a session
82
- */
83
- export type InteropSession = {
76
+ export type CreateSessionResponse = {
84
77
  sessionId: string;
85
- };
86
- /**
87
- * Represents a source session
88
- */
89
- export type Source = {
90
- /**
91
- * Source session id
92
- */
93
- sessionId: string;
94
- /**
95
- * source environment id
96
- */
78
+ sessionRootTopic: string;
79
+ url: string;
80
+ token: string;
81
+ orgId: string;
82
+ sub: string;
83
+ platformId: string;
97
84
  sourceId: string;
98
- /**
99
- * source environment display name
100
- */
101
- sourceDisplayName: string;
102
- };
103
- /**
104
- * Represents a context received from another cloud interop publisher
105
- *
106
- * @export
107
- * @type ContextEvent
108
- * @property {string} contextGroup - The context group
109
- * @property {object} context - The context
110
- * @property {Source} source - The source of the context
111
- */
112
- export type ContextEvent = {
113
- /**
114
- * The context group
115
- */
116
- contextGroup: string;
117
- /**
118
- * The context object
119
- */
120
- context: object;
121
- /**
122
- * The source of the context
123
- */
124
- source: Source;
125
85
  };
@@ -0,0 +1,15 @@
1
+ import { AggregateIntentDetailsEvent, ContextEvent, IntentDetailsEvent, IntentResultEvent, RaiseIntentEvent, ReportIntentsEvent } from '@openfin/shared-utils';
2
+ export type EventMap = {
3
+ reconnected: () => void;
4
+ disconnected: () => void;
5
+ context: (event: ContextEvent) => void;
6
+ reconnecting: (attemptNo: number) => void;
7
+ error: (error: Error) => void;
8
+ 'session-expired': () => void;
9
+ 'report-intents': (event: ReportIntentsEvent) => void;
10
+ 'intent-details': (event: IntentDetailsEvent) => void;
11
+ 'aggregate-intent-details': (event: AggregateIntentDetailsEvent) => void;
12
+ 'raise-intent': (event: RaiseIntentEvent) => void;
13
+ 'intent-result': (event: IntentResultEvent) => void;
14
+ };
15
+ export type EventListenersMap = Map<keyof EventMap, Array<(...args: Parameters<EventMap[keyof EventMap]>) => void>>;
@@ -0,0 +1,3 @@
1
+ export * from './connect.interface';
2
+ export * from './event.interface';
3
+ export * from './intents.interface';
@@ -0,0 +1,22 @@
1
+ import { AppIdentifier, FindIntentOptions, RaiseIntentOptions } from '@openfin/shared-utils';
2
+ /**
3
+ * Options used to start an Intent Discovery Operation, with possible constraints for the responses
4
+ */
5
+ export type StartIntentDiscoveryOptions = {
6
+ findOptions: FindIntentOptions;
7
+ /**
8
+ * The timeout in ms.
9
+ *
10
+ * Discovery will wait for all connected sessions to respond or until the timeout is reached.
11
+ *
12
+ * Defaults to 3000ms if not provided, minimum value 500ms
13
+ */
14
+ timeout?: number;
15
+ };
16
+ /**
17
+ * Options used to raise an Intent
18
+ */
19
+ export type RaiseIntentAPIOptions = {
20
+ raiseOptions: RaiseIntentOptions;
21
+ appId: AppIdentifier | string;
22
+ };
@@ -0,0 +1,25 @@
1
+ import { AppIdentifier, AppIntent, Source } from '@openfin/shared-utils';
2
+ import { ConnectParameters, CreateSessionResponse } from './interfaces';
3
+ export declare const APP_ID_DELIM = "::";
4
+ export declare const getRequestHeaders: (connectionParameters: ConnectParameters) => HeadersInit;
5
+ /**
6
+ * Encodes all app intents in the format: `appId::sourceId::sessionId`,
7
+ * where sourceId and sessionId are URI encoded
8
+ * @param appIntents
9
+ * @param source
10
+ * @returns
11
+ */
12
+ export declare const encodeAppIntents: (appIntents: AppIntent[], { sessionId, sourceId }: Source) => AppIntent[];
13
+ /**
14
+ * Decodes all app intents by URI decoding the parts previously encoded by `encodeAppIntents`
15
+ * @param appIntents
16
+ * @returns
17
+ */
18
+ export declare const decodeAppIntents: (appIntents: AppIntent[]) => AppIntent[];
19
+ /**
20
+ * Decodes the app id to extract the sessionId, returns '' if not able to parse
21
+ * @param app
22
+ * @returns
23
+ */
24
+ export declare const parseSessionId: (appId: AppIdentifier | string) => any;
25
+ export declare const getSourceFromSession: (sessionDetails: CreateSessionResponse) => Source;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/cloud-interop-core-api",
3
- "version": "0.0.1-alpha.384d88e",
3
+ "version": "0.0.1-alpha.47835ce",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "files": [
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "main": "./dist/index.cjs",
10
10
  "browser": "./dist/index.mjs",
11
- "types": "./dist/src/index.d.ts",
11
+ "types": "./dist/index.d.ts",
12
12
  "scripts": {
13
13
  "build": "rimraf dist && rollup -c",
14
14
  "build:watch": "rollup -c --watch",
@@ -42,7 +42,7 @@
42
42
  "typescript": "^5.6.3"
43
43
  },
44
44
  "dependencies": {
45
- "@openfin-direct/shared-utils": "file:../shared-utils",
45
+ "@openfin/shared-utils": "file:../shared-utils",
46
46
  "mqtt": "^5.3.1"
47
47
  },
48
48
  "eslintConfig": {
@@ -1,3 +0,0 @@
1
- export * from './api';
2
- export * from './errors/api.error';
3
- export * from './interfaces';
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,128 +0,0 @@
1
- export declare const DEFAULT_HEADERS: {
2
- 'Content-Type': string;
3
- };
4
- export declare const DEFAULT_AUTH_HEADER: {
5
- Authorization: string;
6
- };
7
- type Method = 'GET' | 'OPTIONS' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
8
- export declare enum Status {
9
- OK = 200,
10
- Created = 201,
11
- Accepted = 202,
12
- NonAuthoritativeInformation = 203,
13
- NoContent = 204,
14
- ResetContent = 205,
15
- PartialContent = 206,
16
- MultipleChoices = 300,
17
- MovedPermanently = 301,
18
- Found = 302,
19
- SeeOther = 303,
20
- NotModified = 304,
21
- UseProxy = 305,
22
- Unused = 306,
23
- TemporaryRedirect = 307,
24
- PermanentRedirect = 308,
25
- BadRequest = 400,
26
- Unauthorized = 401,
27
- PaymentRequired = 402,
28
- Forbidden = 403,
29
- NotFound = 404,
30
- MethodNotAllowed = 405,
31
- NotAcceptable = 406,
32
- ProxyAuthenticationRequired = 407,
33
- RequestTimeout = 408,
34
- Conflict = 409,
35
- Gone = 410,
36
- LengthRequired = 411,
37
- PreconditionFailed = 412,
38
- RequestEntityTooLarge = 413,
39
- RequestURITooLong = 414,
40
- UnsupportedMediaType = 415,
41
- RequestedRangeNotSatisfiable = 416,
42
- ExpectationFailed = 417,
43
- Imateapot = 418,
44
- MisdirectedRequest = 421,
45
- UnprocessableEntity = 422,
46
- Locked = 423,
47
- TooEarly = 425,
48
- UpgradeRequired = 426,
49
- PreconditionRequired = 428,
50
- TooManyRequests = 429,
51
- RequestHeaderFieldsTooLarge = 431,
52
- UnavailableForLegalReasons = 451,
53
- InternalServerError = 500,
54
- NotImplemented = 501,
55
- BadGateway = 502,
56
- ServiceUnavailable = 503,
57
- GatewayTimeout = 504,
58
- HTTPVersionNotSupported = 505,
59
- VariantAlsoNegotiates = 506,
60
- InsufficientStorage = 507,
61
- NetworkAuthenticationRequired = 511,
62
- Webserverisreturninganunknownerror = 520,
63
- Connectiontimedout = 522,
64
- Atimeoutoccurred = 524
65
- }
66
- /**
67
- * Stub API request, response in test cases.
68
- * - should be initialized and destroyed within the context of a specific case.
69
- * - highly customizable
70
- *
71
- * <pre>
72
- * describe("Fetch API", () => {
73
- * let fetchResolver!: FetchResolver;
74
- * beforeEach(() => {
75
- * fetchResolver = new FetchResolver();
76
- * });
77
- *
78
- * it("should load api", async () => {
79
- * // stub
80
- * fetchResolver.stub( "http://localhost:8080/endpoint", "post", { id: 100 }, { created: true }, 200);
81
- * // fetch
82
- * fetch("http://localhost:8080/endpoint",
83
- * { method: "post", body: JSON.stringify({ id: 100 })}
84
- * ).then((response) => {
85
- * if (response.ok) {
86
- * response.text().then((text) => {
87
- * console.log(text); // { created: true }
88
- * expect(text).toBeEqual({ created: true });
89
- * });
90
- * }
91
- * });
92
- * });
93
- *
94
- * afterEach(() => {
95
- * fetchResolver.clear();
96
- * });
97
- * });
98
- * </pre>
99
- *
100
- * Even though jest executes tests in parallel jest instance,
101
- * We can't go wrong if stubs are cleaned after its use
102
- */
103
- export declare class FetchResolver {
104
- readonly interopUrl: string;
105
- readonly sourceId: string;
106
- readonly platformId: string;
107
- private mocks;
108
- fetchSpy: jest.SpyInstance<Promise<Response>, [input: string | URL | Request, init?: RequestInit | undefined], any>;
109
- constructor(interopUrl?: string, sourceId?: string, platformId?: string);
110
- stubConnect(headers?: Record<string, string>): void;
111
- stubDelete(status?: number): void;
112
- stubFetchWithSourceAndPlatform(url: string, method: Method, headers: any, payload: any, response: any, status: number): void;
113
- stubFetch(url: string, method: Method, headers: any, payload: any, response: any, status: number): void;
114
- /**
115
- *
116
- * @param uri
117
- * @param method
118
- * @param headers pass null to delete headers from requestInit
119
- * @param payload pass null to delete body from requestInit
120
- * @param response
121
- * @param status
122
- */
123
- stub(uri: string, method: Method, headers: any, payload: any, response: any, status: Status): void;
124
- private prettyPrint;
125
- clear(): void;
126
- private init;
127
- }
128
- export {};
File without changes